diff --git a/packages/services/src/Domain/Application/ApplicationInterface.ts b/packages/services/src/Domain/Application/ApplicationInterface.ts index fe3cc784d..24cbc40af 100644 --- a/packages/services/src/Domain/Application/ApplicationInterface.ts +++ b/packages/services/src/Domain/Application/ApplicationInterface.ts @@ -34,6 +34,7 @@ import { UserClientInterface } from '../User/UserClientInterface' import { SessionsClientInterface } from '../Session/SessionsClientInterface' import { HomeServerServiceInterface } from '../HomeServer/HomeServerServiceInterface' import { User } from '@standardnotes/responses' +import { PureCryptoInterface } from '@standardnotes/sncrypto-common' export interface ApplicationInterface { deinit(mode: DeinitMode, source: DeinitSource): void @@ -92,6 +93,7 @@ export interface ApplicationInterface { syncOptions?: SyncOptions, ): Promise + get crypto(): PureCryptoInterface get features(): FeaturesClientInterface get componentManager(): ComponentManagerInterface get items(): ItemManagerInterface diff --git a/packages/snjs/lib/Application/Application.ts b/packages/snjs/lib/Application/Application.ts index 2374f35b3..f687bbdf6 100644 --- a/packages/snjs/lib/Application/Application.ts +++ b/packages/snjs/lib/Application/Application.ts @@ -111,6 +111,7 @@ import { GetRevision } from '@Lib/Domain/UseCase/GetRevision/GetRevision' import { DeleteRevision } from '@Lib/Domain/UseCase/DeleteRevision/DeleteRevision' import { GetAuthenticatorAuthenticationResponse } from '@Lib/Domain/UseCase/GetAuthenticatorAuthenticationResponse/GetAuthenticatorAuthenticationResponse' import { GetAuthenticatorAuthenticationOptions } from '@Lib/Domain/UseCase/GetAuthenticatorAuthenticationOptions/GetAuthenticatorAuthenticationOptions' +import { PureCryptoInterface } from '@standardnotes/sncrypto-common' /** How often to automatically sync, in milliseconds */ const DEFAULT_AUTO_SYNC_INTERVAL = 30_000 @@ -283,6 +284,10 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli this.defineInternalEventHandlers() } + get crypto(): PureCryptoInterface { + return this.options.crypto + } + get subscriptions(): ExternalServices.SubscriptionManagerInterface { return this.subscriptionManager } diff --git a/packages/snjs/mocha/004.test.js b/packages/snjs/mocha/004.test.js index 390a5fc81..1aac3f042 100644 --- a/packages/snjs/mocha/004.test.js +++ b/packages/snjs/mocha/004.test.js @@ -64,7 +64,7 @@ describe('004 protocol operations', function () { it('generates random key', async function () { const length = 96 - const key = await application.encryptionService.crypto.generateRandomKey(length) + const key = await application.crypto.generateRandomKey(length) expect(key.length).to.equal(length / 4) }) diff --git a/packages/snjs/mocha/lib/factory.js b/packages/snjs/mocha/lib/factory.js index 87e5f9311..970c6a6d3 100644 --- a/packages/snjs/mocha/lib/factory.js +++ b/packages/snjs/mocha/lib/factory.js @@ -112,7 +112,7 @@ export function registerUserToApplication({ application, email, password, epheme } export async function setOldVersionPasscode({ application, passcode, version }) { - const identifier = await application.encryptionService.crypto.generateUUID() + const identifier = await application.crypto.generateUUID() const operator = application.encryptionService.operators.operatorForVersion(version) const key = await operator.createRootKey(identifier, passcode, KeyParamsOrigination.PasscodeCreate) await application.encryptionService.setNewRootKeyWrapper(key)