You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
1.3 KiB
20 lines
1.3 KiB
import { randomBytes, getWebcryptoSubtle } from '@noble/ciphers/crypto'; |
|
import { AsyncCipher, Cipher } from './utils.js'; |
|
/** |
|
* Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS. |
|
*/ |
|
export { randomBytes, getWebcryptoSubtle }; |
|
type RemoveNonceInner<T extends any[], Ret> = ((...args: T) => Ret) extends (arg0: any, arg1: any, ...rest: infer R) => any ? (key: Uint8Array, ...args: R) => Ret : never; |
|
type RemoveNonce<T extends (...args: any) => any> = RemoveNonceInner<Parameters<T>, ReturnType<T>>; |
|
type CipherWithNonce = ((key: Uint8Array, nonce: Uint8Array, ...args: any[]) => Cipher) & { |
|
nonceLength: number; |
|
}; |
|
export declare function managedNonce<T extends CipherWithNonce>(fn: T): RemoveNonce<T>; |
|
export declare const utils: { |
|
encrypt(key: Uint8Array, keyParams: any, cryptParams: any, plaintext: Uint8Array): Promise<Uint8Array>; |
|
decrypt(key: Uint8Array, keyParams: any, cryptParams: any, ciphertext: Uint8Array): Promise<Uint8Array>; |
|
}; |
|
export declare const cbc: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => AsyncCipher; |
|
export declare const ctr: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => AsyncCipher; |
|
export declare const gcm: (key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => AsyncCipher; |
|
//# sourceMappingURL=webcrypto.d.ts.map
|