type AlgorithmIdentifier = Algorithm | string; type BufferSource = ArrayBufferView | ArrayBuffer; type KeyFormat = "jwk" | "pkcs8" | "raw" | "spki"; type KeyType = "private" | "public" | "secret"; type KeyUsage = "decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey"; type HashAlgorithmIdentifier = AlgorithmIdentifier; type NamedCurve = string; interface Algorithm { name: string; } interface AesCbcParams extends Algorithm { iv: BufferSource; } interface AesCtrParams extends Algorithm { counter: BufferSource; length: number; } interface AesDerivedKeyParams extends Algorithm { length: number; } interface AesGcmParams extends Algorithm { additionalData?: BufferSource; iv: BufferSource; tagLength?: number; } interface AesKeyGenParams extends Algorithm { length: number; } interface EcKeyGenParams extends Algorithm { namedCurve: NamedCurve; } interface EcKeyImportParams extends Algorithm { namedCurve: NamedCurve; } interface EcdhKeyDeriveParams extends Algorithm { public: CryptoKey; } interface EcdsaParams extends Algorithm { hash: HashAlgorithmIdentifier; } interface HkdfParams extends Algorithm { hash: HashAlgorithmIdentifier; info: BufferSource; salt: BufferSource; } interface HmacKeyGenParams extends Algorithm { hash: HashAlgorithmIdentifier; length?: number; } interface HmacImportParams extends Algorithm { hash: HashAlgorithmIdentifier; length?: number; } interface Pbkdf2Params extends Algorithm { hash: HashAlgorithmIdentifier; iterations: number; salt: BufferSource; } interface RsaHashedImportParams extends Algorithm { hash: HashAlgorithmIdentifier; } interface RsaKeyGenParams extends Algorithm { modulusLength: number; publicExponent: Uint8Array; } interface RsaOaepParams extends Algorithm { label?: BufferSource; } interface RsaPssParams extends Algorithm { saltLength: number; } interface KeyAlgorithm { name: string; } interface AesKeyAlgorithm extends KeyAlgorithm { length: number; } interface RsaHashedKeyGenParams extends RsaKeyGenParams { hash: HashAlgorithmIdentifier; } interface CryptoKey { readonly algorithm: KeyAlgorithm; readonly extractable: boolean; readonly type: KeyType; readonly usages: KeyUsage[]; } interface CryptoKeyPair { privateKey: CryptoKey; publicKey: CryptoKey; } interface JsonWebKey { alg?: string; crv?: string; d?: string; dp?: string; dq?: string; e?: string; ext?: boolean; k?: string; key_ops?: string[]; kty?: string; n?: string; oth?: RsaOtherPrimesInfo[]; p?: string; q?: string; qi?: string; use?: string; x?: string; y?: string; } interface RsaOtherPrimesInfo { d?: string; r?: string; t?: string; } interface SubtleCrypto { decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise; deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise; digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise; encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; exportKey(format: "jwk", key: CryptoKey): Promise; exportKey(format: Exclude, key: CryptoKey): Promise; generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]): Promise; generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise; generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise; importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise; importKey(format: Exclude, keyData: BufferSource, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise; sign(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams, key: CryptoKey, data: BufferSource): Promise; unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise; verify(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise; wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams): Promise; } interface Crypto { readonly subtle: SubtleCrypto; getRandomValues(array: T): T; randomUUID(): string; } export type { Crypto };