Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

SubtleCrypto#importKey should accept `readonly KeyUsage[]`

Open
#1,929 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
tooling

Research direction

Start by locating the generated SubtleCrypto declarations and the generator input or entry point for importKey, deriveKey, generateKey, and unwrapKey. Compare every overload's keyUsages parameter with the Web Cryptography API reference, then verify that all affected overloads accept readonly KeyUsage arrays and run the relevant generation or type tests if available.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
740
Forks
474
Avg merge
2d 8h
Merged PRs (30d)
15

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/TypeScript-DOM-lib-generator

All issues in microsoft/TypeScript-DOM-lib-generator

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.