chore: fix tests accessing crypto

This commit is contained in:
Karol Sójko
2023-07-14 13:47:19 +02:00
parent 2bd34b8d70
commit 6122d55965
4 changed files with 9 additions and 2 deletions

View File

@@ -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<void>
get crypto(): PureCryptoInterface
get features(): FeaturesClientInterface
get componentManager(): ComponentManagerInterface
get items(): ItemManagerInterface

View File

@@ -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
}

View File

@@ -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)
})

View File

@@ -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)