1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-07-16 13:55:52 +02:00

null key checks

This commit is contained in:
Kyle Spearrin 2018-07-31 14:37:39 -04:00
parent ee13a562f9
commit a1112988c4

View File

@ -12,11 +12,14 @@ export class TotpService implements TotpServiceAbstraction {
constructor(private storageService: StorageService, private cryptoFunctionService: CryptoFunctionService) { }
async getCode(key: string): Promise<string> {
if (key == null) {
return null;
}
let period = 30;
let alg: 'sha1' | 'sha256' | 'sha512' = 'sha1';
let digits = 6;
let keyB32 = key;
if (key.indexOf('otpauth://') === 0) {
if (key.toLowerCase().indexOf('otpauth://') === 0) {
const params = Utils.getQueryParams(key);
if (params.has('digits') && params.get('digits') != null) {
try {
@ -73,7 +76,7 @@ export class TotpService implements TotpServiceAbstraction {
getTimeInterval(key: string): number {
let period = 30;
if (key.indexOf('otpauth://') === 0) {
if (key != null && key.toLowerCase().indexOf('otpauth://') === 0) {
const params = Utils.getQueryParams(key);
if (params.has('period') && params.get('period') != null) {
try {