From 3bf322a904cd7ccb8c7e77edbecf8e152feb7364 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sun, 20 Sep 2020 09:47:35 -0400 Subject: [PATCH] support defaultMatch for getAllDecryptedForUrl --- src/abstractions/cipher.service.ts | 4 +++- src/services/cipher.service.ts | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/abstractions/cipher.service.ts b/src/abstractions/cipher.service.ts index 8ec886e240..339ca0a461 100644 --- a/src/abstractions/cipher.service.ts +++ b/src/abstractions/cipher.service.ts @@ -1,4 +1,5 @@ import { CipherType } from '../enums/cipherType'; +import { UriMatchType } from '../enums/uriMatchType'; import { CipherData } from '../models/data/cipherData'; @@ -21,7 +22,8 @@ export abstract class CipherService { getAll: () => Promise; getAllDecrypted: () => Promise; getAllDecryptedForGrouping: (groupingId: string, folder?: boolean) => Promise; - getAllDecryptedForUrl: (url: string, includeOtherTypes?: CipherType[]) => Promise; + getAllDecryptedForUrl: (url: string, includeOtherTypes?: CipherType[], + defaultMatch?: UriMatchType) => Promise; getAllFromApiForOrganization: (organizationId: string) => Promise; getLastUsedForUrl: (url: string) => Promise; getNextCipherForUrl: (url: string) => Promise; diff --git a/src/services/cipher.service.ts b/src/services/cipher.service.ts index fe661bdeea..1942628898 100644 --- a/src/services/cipher.service.ts +++ b/src/services/cipher.service.ts @@ -328,7 +328,8 @@ export class CipherService implements CipherServiceAbstraction { }); } - async getAllDecryptedForUrl(url: string, includeOtherTypes?: CipherType[]): Promise { + async getAllDecryptedForUrl(url: string, includeOtherTypes?: CipherType[], + defaultMatch: UriMatchType = null): Promise { if (url == null && includeOtherTypes == null) { return Promise.resolve([]); } @@ -354,9 +355,11 @@ export class CipherService implements CipherServiceAbstraction { const matchingDomains = result[0]; const ciphers = result[1]; - let defaultMatch = await this.storageService.get(ConstantsService.defaultUriMatch); if (defaultMatch == null) { - defaultMatch = UriMatchType.Domain; + defaultMatch = await this.storageService.get(ConstantsService.defaultUriMatch); + if (defaultMatch == null) { + defaultMatch = UriMatchType.Domain; + } } return ciphers.filter((cipher) => {