Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubtleCrypto#importKey should accept readonly KeyUsage[] #1929

Open
yoursunny opened this issue Mar 6, 2025 · 0 comments
Open

SubtleCrypto#importKey should accept readonly KeyUsage[] #1929

yoursunny opened this issue Mar 6, 2025 · 0 comments

Comments

@yoursunny
Copy link

As of @types/web@0.0.208, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant