TypeScript-DOM-lib-generator
TypeScript-DOM-lib-generator copied to clipboard
SubtleCrypto#importKey should accept `readonly KeyUsage[]`
As of @types/[email protected], SubtleCrypto is declared as:
interface SubtleCrypto {
importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
importKey(format: Exclude<KeyFormat, "jwk">, keyData: BufferSource, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
}
Notably, the keyUsages argument in the first overload accepts readonly KeyUsage[], while the second overload requires a mutable array.
Web Cryptography API section 14.3.9 does not have any procedure that would mutate this argument.
Hence, this argument should accept readonly in both overloads.
The same problem also occurs in one of the overloads in deriveKey and generateKey and unwrapKey methods.