From 70e021965a0e6addef355d40b8b392dae8d29970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Rame=CC=81?= Date: Tue, 28 Apr 2026 11:54:37 +0200 Subject: [PATCH] wip --- .../src/features/encryption/global.d.ts | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/features/encryption/global.d.ts b/src/frontend/src/features/encryption/global.d.ts index 607034fc..1b55ca11 100644 --- a/src/frontend/src/features/encryption/global.d.ts +++ b/src/frontend/src/features/encryption/global.d.ts @@ -10,18 +10,23 @@ declare global { getPublicKey(): Promise<{ publicKey: ArrayBuffer }> encryptWithoutKey( data: ArrayBuffer, - userPublicKeys: Record + userPublicKeys: Record, + options?: { optimizeMemory?: boolean } ): Promise<{ encryptedContent: ArrayBuffer encryptedKeys: Record }> encryptWithKey( data: ArrayBuffer, - encryptedSymmetricKey: ArrayBuffer + encryptedSymmetricKey: ArrayBuffer, + encryptedKeyChain?: ArrayBuffer[], + options?: { optimizeMemory?: boolean } ): Promise<{ encryptedData: ArrayBuffer }> decryptWithKey( encryptedData: ArrayBuffer, - encryptedSymmetricKey: ArrayBuffer + encryptedSymmetricKey: ArrayBuffer, + encryptedKeyChain?: ArrayBuffer[], + options?: { optimizeMemory?: boolean } ): Promise<{ data: ArrayBuffer }> shareKeys( encryptedSymmetricKey: ArrayBuffer, @@ -59,6 +64,29 @@ declare global { off(event: K, listener: (data: unknown) => void): void } + /** + * Stable error codes carried by `VaultError`. Sourced from the + * encryption SDK (re-exported on `window.EncryptionClient.VaultErrorCode`) + * — meet consumers match on these via `(err as VaultError).code` rather + * than regexing message text. Keep in sync with the SDK definition. + */ + type VaultErrorCode = + | 'MISSING_KEYS' + | 'WRONG_SECRET_KEY' + | 'INVALID_BACKUP' + | 'INVALID_MNEMONIC' + | 'NOT_INITIALIZED' + | 'AUTH_REQUIRED' + | 'PRIVILEGED_ORIGIN_REQUIRED' + | 'TIMEOUT' + | 'IFRAME_REQUIRED' + | 'CIPHERTEXT_TOO_SHORT' + | 'UNKNOWN' + + interface VaultError extends Error { + readonly code: VaultErrorCode + } + interface Window { EncryptionClient: { VaultClient: new (options: { @@ -68,6 +96,9 @@ declare global { theme?: string lang?: string }) => VaultClient + VaultError: new (code: VaultErrorCode, message: string) => VaultError + VaultErrorCode: { readonly [K in VaultErrorCode]: K } + isVaultError: (err: unknown) => err is VaultError } } }