import { AsymmetricSignatureVerificationDetachedResult } from '../../Operator/Types/AsymmetricSignatureVerificationDetachedResult' import { KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common' import { BackupFile, DecryptedPayloadInterface, EncryptedPayloadInterface, ItemContent, ItemsKeyInterface, RootKeyInterface, KeySystemIdentifier, KeySystemItemsKeyInterface, AsymmetricMessagePayload, KeySystemRootKeyInterface, KeySystemRootKeyParamsInterface, TrustedContactInterface, } from '@standardnotes/models' import { ClientDisplayableError } from '@standardnotes/responses' import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' import { KeyedDecryptionSplit } from '../../Split/KeyedDecryptionSplit' import { KeyedEncryptionSplit } from '../../Split/KeyedEncryptionSplit' import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' import { PkcKeyPair } from '@standardnotes/sncrypto-common' import { PublicKeySet } from '../../Operator/Types/PublicKeySet' import { KeySystemKeyManagerInterface } from '../KeySystemKeyManagerInterface' import { AsymmetricallyEncryptedString } from '../../Operator/Types/Types' export interface EncryptionProviderInterface { keys: KeySystemKeyManagerInterface encryptSplitSingle(split: KeyedEncryptionSplit): Promise encryptSplit(split: KeyedEncryptionSplit): Promise decryptSplitSingle< C extends ItemContent = ItemContent, P extends DecryptedPayloadInterface = DecryptedPayloadInterface, >( split: KeyedDecryptionSplit, ): Promise

decryptSplit< C extends ItemContent = ItemContent, P extends DecryptedPayloadInterface = DecryptedPayloadInterface, >( split: KeyedDecryptionSplit, ): Promise<(P | EncryptedPayloadInterface)[]> getEmbeddedPayloadAuthenticatedData( payload: EncryptedPayloadInterface, ): D | undefined getKeyEmbeddedKeyParamsFromItemsKey(key: EncryptedPayloadInterface): SNRootKeyParams | undefined supportedVersions(): ProtocolVersion[] isVersionNewerThanLibraryVersion(version: ProtocolVersion): boolean platformSupportsKeyDerivation(keyParams: SNRootKeyParams): boolean decryptBackupFile( file: BackupFile, password?: string, ): Promise getUserVersion(): ProtocolVersion | undefined hasAccount(): boolean hasPasscode(): boolean removePasscode(): Promise validateAccountPassword(password: string): Promise< | { valid: true artifacts: { rootKey: RootKeyInterface } } | { valid: boolean } > decryptErroredPayloads(): Promise deleteWorkspaceSpecificKeyStateFromDevice(): Promise computeRootKey(password: string, keyParams: SNRootKeyParams): Promise computeWrappingKey(passcode: string): Promise hasRootKeyEncryptionSource(): boolean createRootKey( identifier: string, password: string, origination: KeyParamsOrigination, version?: ProtocolVersion, ): Promise getRootKeyParams(): SNRootKeyParams | undefined setNewRootKeyWrapper(wrappingKey: RootKeyInterface): Promise createNewItemsKeyWithRollback(): Promise<() => Promise> reencryptApplicableItemsAfterUserRootKeyChange(): Promise getSureDefaultItemsKey(): ItemsKeyInterface createRandomizedKeySystemRootKey(dto: { systemIdentifier: KeySystemIdentifier }): KeySystemRootKeyInterface createUserInputtedKeySystemRootKey(dto: { systemIdentifier: KeySystemIdentifier userInputtedPassword: string }): KeySystemRootKeyInterface deriveUserInputtedKeySystemRootKey(dto: { keyParams: KeySystemRootKeyParamsInterface userInputtedPassword: string }): KeySystemRootKeyInterface createKeySystemItemsKey( uuid: string, keySystemIdentifier: KeySystemIdentifier, sharedVaultUuid: string | undefined, rootKeyToken: string, ): KeySystemItemsKeyInterface reencryptKeySystemItemsKeysForVault(keySystemIdentifier: KeySystemIdentifier): Promise getKeyPair(): PkcKeyPair getSigningKeyPair(): PkcKeyPair asymmetricallyEncryptMessage(dto: { message: AsymmetricMessagePayload senderKeyPair: PkcKeyPair senderSigningKeyPair: PkcKeyPair recipientPublicKey: string }): string asymmetricallyDecryptMessage(dto: { encryptedString: AsymmetricallyEncryptedString trustedSender: TrustedContactInterface | undefined privateKey: string }): M | undefined asymmetricSignatureVerifyDetached( encryptedString: AsymmetricallyEncryptedString, ): AsymmetricSignatureVerificationDetachedResult getSenderPublicKeySetFromAsymmetricallyEncryptedString(string: string): PublicKeySet }