@@ -374,94 +374,96 @@ export type GenericEncryptor = {
374374 * An encryptor interface that supports encrypting and decrypting
375375 * serializable data with a password, and exporting and importing keys.
376376 */
377- export type ExportableKeyEncryptor < EncryptionKey = unknown > =
378- GenericEncryptor & {
379- /**
380- * Encrypts the given object with the given encryption key.
381- *
382- * @param key - The encryption key to encrypt with.
383- * @param object - The object to encrypt.
384- * @returns The encryption result.
385- */
386- encryptWithKey : (
387- key : EncryptionKey ,
388- object : Json ,
389- ) => Promise < encryptorUtils . EncryptionResult > ;
390- /**
391- * Encrypts the given object with the given password, and returns the
392- * encryption result and the exported key string.
393- *
394- * @param password - The password to encrypt with.
395- * @param object - The object to encrypt.
396- * @param salt - The optional salt to use for encryption.
397- * @returns The encrypted string and the exported key string.
398- */
399- encryptWithDetail : (
400- password : string ,
401- object : Json ,
402- salt ?: string ,
403- ) => Promise < encryptorUtils . DetailedEncryptionResult > ;
404- /**
405- * Decrypts the given encrypted string with the given encryption key.
406- *
407- * @param key - The encryption key to decrypt with.
408- * @param encryptedString - The encrypted string to decrypt.
409- * @returns The decrypted object.
410- */
411- decryptWithKey : (
412- key : EncryptionKey ,
413- encryptedString : string ,
414- ) => Promise < unknown > ;
415- /**
416- * Decrypts the given encrypted string with the given password, and returns
417- * the decrypted object and the salt and exported key string used for
418- * encryption.
419- *
420- * @param password - The password to decrypt with.
421- * @param encryptedString - The encrypted string to decrypt.
422- * @returns The decrypted object and the salt and exported key string used for
423- * encryption.
424- */
425- decryptWithDetail : (
426- password : string ,
427- encryptedString : string ,
428- ) => Promise < encryptorUtils . DetailedDecryptResult > ;
429- /**
430- * Generates an encryption key from exported key string.
431- *
432- * @param key - The exported key string.
433- * @returns The encryption key.
434- */
435- importKey : ( key : string ) => Promise < EncryptionKey > ;
436- /**
437- * Exports the encryption key as a string.
438- *
439- * @param key - The encryption key to export.
440- * @returns The exported key string.
441- */
442- exportKey : ( key : EncryptionKey ) => Promise < string > ;
443- /**
444- * Derives an encryption key from a password.
445- *
446- * @param password - The password to derive the key from.
447- * @param salt - The salt to use for key derivation.
448- * @param exportable - Whether the key should be exportable or not.
449- * @param options - Optional key derivation options.
450- * @returns The derived encryption key.
451- */
452- keyFromPassword : (
453- password : string ,
454- salt : string ,
455- exportable ?: boolean ,
456- // setting this to unknown as currently each client has different
457- // key derivation options
458- keyDerivationOptions ?: unknown ,
459- ) => Promise < EncryptionKey > ;
460- /**
461- * Generates a random salt for key derivation.
462- */
463- generateSalt : typeof encryptorUtils . generateSalt ;
464- } ;
377+ export type ExportableKeyEncryptor <
378+ EncryptionKey = unknown ,
379+ SupportedKeyDerivationParams = unknown ,
380+ > = GenericEncryptor & {
381+ /**
382+ * Encrypts the given object with the given encryption key.
383+ *
384+ * @param key - The encryption key to encrypt with.
385+ * @param object - The object to encrypt.
386+ * @returns The encryption result.
387+ */
388+ encryptWithKey : (
389+ key : EncryptionKey ,
390+ object : Json ,
391+ ) => Promise < encryptorUtils . EncryptionResult > ;
392+ /**
393+ * Encrypts the given object with the given password, and returns the
394+ * encryption result and the exported key string.
395+ *
396+ * @param password - The password to encrypt with.
397+ * @param object - The object to encrypt.
398+ * @param salt - The optional salt to use for encryption.
399+ * @returns The encrypted string and the exported key string.
400+ */
401+ encryptWithDetail : (
402+ password : string ,
403+ object : Json ,
404+ salt ?: string ,
405+ ) => Promise < encryptorUtils . DetailedEncryptionResult > ;
406+ /**
407+ * Decrypts the given encrypted string with the given encryption key.
408+ *
409+ * @param key - The encryption key to decrypt with.
410+ * @param encryptedString - The encrypted string to decrypt.
411+ * @returns The decrypted object.
412+ */
413+ decryptWithKey : (
414+ key : EncryptionKey ,
415+ encryptedString : string ,
416+ ) => Promise < unknown > ;
417+ /**
418+ * Decrypts the given encrypted string with the given password, and returns
419+ * the decrypted object and the salt and exported key string used for
420+ * encryption.
421+ *
422+ * @param password - The password to decrypt with.
423+ * @param encryptedString - The encrypted string to decrypt.
424+ * @returns The decrypted object and the salt and exported key string used for
425+ * encryption.
426+ */
427+ decryptWithDetail : (
428+ password : string ,
429+ encryptedString : string ,
430+ ) => Promise < encryptorUtils . DetailedDecryptResult > ;
431+ /**
432+ * Generates an encryption key from exported key string.
433+ *
434+ * @param key - The exported key string.
435+ * @returns The encryption key.
436+ */
437+ importKey : ( key : string ) => Promise < EncryptionKey > ;
438+ /**
439+ * Exports the encryption key as a string.
440+ *
441+ * @param key - The encryption key to export.
442+ * @returns The exported key string.
443+ */
444+ exportKey : ( key : EncryptionKey ) => Promise < string > ;
445+ /**
446+ * Derives an encryption key from a password.
447+ *
448+ * @param password - The password to derive the key from.
449+ * @param salt - The salt to use for key derivation.
450+ * @param exportable - Whether the key should be exportable or not.
451+ * @param options - Optional key derivation options.
452+ * @returns The derived encryption key.
453+ */
454+ keyFromPassword : (
455+ password : string ,
456+ salt : string ,
457+ exportable ?: boolean ,
458+ // setting this to unknown as currently each client has different
459+ // key derivation options
460+ keyDerivationOptions ?: SupportedKeyDerivationParams ,
461+ ) => Promise < EncryptionKey > ;
462+ /**
463+ * Generates a random salt for key derivation.
464+ */
465+ generateSalt : typeof encryptorUtils . generateSalt ;
466+ } ;
465467
466468export type KeyringSelector =
467469 | {
0 commit comments