diff --git a/src/abstractions/cipher.service.ts b/src/abstractions/cipher.service.ts index 7a0fab508f..97c9c37abc 100644 --- a/src/abstractions/cipher.service.ts +++ b/src/abstractions/cipher.service.ts @@ -22,6 +22,7 @@ export abstract class CipherService { getAllDecrypted: () => Promise; getAllDecryptedForGrouping: (groupingId: string, folder?: boolean) => Promise; getAllDecryptedForUrl: (url: string, includeOtherTypes?: CipherType[]) => Promise; + getAllFromApiForOrganization: (organizationId: string) => Promise; getLastUsedForUrl: (url: string) => Promise; updateLastUsedDate: (id: string) => Promise; saveNeverDomain: (domain: string) => Promise; diff --git a/src/services/cipher.service.ts b/src/services/cipher.service.ts index b9ffee1eb7..9b90cf50d2 100644 --- a/src/services/cipher.service.ts +++ b/src/services/cipher.service.ts @@ -405,6 +405,24 @@ export class CipherService implements CipherServiceAbstraction { }); } + async getAllFromApiForOrganization(organizationId: string): Promise { + const ciphers = await this.apiService.getCiphersOrganization(organizationId); + if (ciphers != null && ciphers.data != null && ciphers.data.length) { + const decCiphers: CipherView[] = []; + const promises: any[] = []; + ciphers.data.forEach((r) => { + const data = new CipherData(r); + const cipher = new Cipher(data); + promises.push(cipher.decrypt().then((c) => decCiphers.push(c))); + }); + await Promise.all(promises); + decCiphers.sort(this.getLocaleSortingFunction()); + return decCiphers; + } else { + return []; + } + } + async getLastUsedForUrl(url: string): Promise { const ciphers = await this.getAllDecryptedForUrl(url); if (ciphers.length === 0) {