unjwt 0.5.40 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +147 -6
  2. package/dist/_chunks/_crypto.mjs +1014 -0
  3. package/dist/_chunks/error.d.mts +67 -0
  4. package/dist/_chunks/index.d.mts +149 -45
  5. package/dist/_chunks/jwk.d.mts +154 -57
  6. package/dist/_chunks/jws.mjs +729 -683
  7. package/dist/_chunks/utils.mjs +74 -70
  8. package/dist/{_chunks/jws.d.mts → adapters/h3v1/index.d.mts} +98 -58
  9. package/dist/{_chunks/jws2.mjs → adapters/h3v1/index.mjs} +198 -85
  10. package/dist/adapters/h3v2/index.d.mts +213 -0
  11. package/dist/adapters/{h3v2.mjs → h3v2/index.mjs} +195 -89
  12. package/dist/core/_crypto/index.d.mts +71 -0
  13. package/dist/core/_crypto/index.mjs +2 -0
  14. package/dist/core/jwe.d.mts +40 -0
  15. package/dist/{_chunks → core}/jwe.mjs +61 -32
  16. package/dist/core/jwk.d.mts +231 -0
  17. package/dist/core/jwk.mjs +686 -0
  18. package/dist/core/jws.d.mts +31 -0
  19. package/dist/core/jws.mjs +104 -0
  20. package/dist/{_chunks/index2.d.mts → core/utils/index.d.mts} +13 -12
  21. package/dist/core/utils/index.mjs +2 -0
  22. package/dist/index.d.mts +7 -6
  23. package/dist/index.mjs +5 -5
  24. package/package.json +49 -40
  25. package/dist/_chunks/chunk.mjs +0 -13
  26. package/dist/_chunks/jwe.d.mts +0 -43
  27. package/dist/_chunks/jwk.mjs +0 -1592
  28. package/dist/adapters/h3.d.mts +0 -3
  29. package/dist/adapters/h3.mjs +0 -3
  30. package/dist/adapters/h3v1.d.mts +0 -3
  31. package/dist/adapters/h3v1.mjs +0 -3
  32. package/dist/adapters/h3v2.d.mts +0 -183
  33. package/dist/jwe.d.mts +0 -3
  34. package/dist/jwe.mjs +0 -2
  35. package/dist/jwk.d.mts +0 -3
  36. package/dist/jwk.mjs +0 -2
  37. package/dist/jws.d.mts +0 -3
  38. package/dist/jws.mjs +0 -2
  39. package/dist/utils.d.mts +0 -3
  40. package/dist/utils.mjs +0 -2
@@ -1,4 +1,58 @@
1
1
  //#region src/core/types/jwk.d.ts
2
+ /**
3
+ * The decoded JOSE protected header received by a {@link JWKLookupFunction}.
4
+ *
5
+ * The most commonly inspected fields are explicitly typed; additional
6
+ * algorithm-specific parameters (`epk`, `p2s`, `p2c`, `apu`, `apv`, …) are
7
+ * accessible through the index signature.
8
+ *
9
+ * `alg` is always present on both JWS and JWE tokens. `enc` is only present
10
+ * on JWE tokens.
11
+ */
12
+ type JWKLookupFunctionHeader = {
13
+ kid?: string;
14
+ alg?: string;
15
+ enc?: string;
16
+ typ?: string;
17
+ crit?: string[];
18
+ [propName: string]: unknown;
19
+ };
20
+ /**
21
+ * A callback that resolves the decryption or verification key from a token's
22
+ * decoded protected header and the raw compact token string.
23
+ *
24
+ * Accepted by both {@link verify} (JWS) and {@link decrypt} (JWE). When a
25
+ * {@link JWKSet} is returned, the library tries each key whose `kid` and `alg`
26
+ * are compatible with the header in order, stopping at the first that succeeds
27
+ * — see {@link getJWKsFromSet} for the selection logic.
28
+ *
29
+ * Returning a `string` is meaningful for JWE only (PBES2 password); for JWS
30
+ * a string return is encoded to bytes and used as a raw symmetric key.
31
+ */
32
+ type JWKLookupFunction = (header: JWKLookupFunctionHeader, token: string) => CryptoKey | JWK | JWKSet | string | Uint8Array<ArrayBuffer> | Promise<CryptoKey | JWK | JWKSet | string | Uint8Array<ArrayBuffer>>;
33
+ /**
34
+ * Interface for custom JWK import cache implementations.
35
+ *
36
+ * The adapter receives the full JWK object so each implementation can choose
37
+ * its own keying strategy:
38
+ * - {@link WeakMapJWKCache} uses the object reference (GC-friendly, no string hashing needed)
39
+ * - A `kid`-keyed cache extracts `jwk.kid` and uses it as a string key
40
+ * - A content-hash cache hashes `jwk.k` or `jwk.n`+`jwk.e`
41
+ *
42
+ * @example Use a custom kid-keyed cache:
43
+ * ```ts
44
+ * import { configureJWKCache } from 'unjwt/jwk';
45
+ * const map = new Map<string, CryptoKey>();
46
+ * configureJWKCache({
47
+ * get: (jwk, alg) => map.get(`${jwk.kid}:${alg}`),
48
+ * set: (jwk, alg, key) => map.set(`${jwk.kid}:${alg}`, key),
49
+ * });
50
+ * ```
51
+ */
52
+ interface JWKCacheAdapter {
53
+ get(jwk: JWK, alg: string): CryptoKey | undefined;
54
+ set(jwk: JWK, alg: string, key: CryptoKey): void;
55
+ }
2
56
  /** Structure returned for composite AES-CBC + HMAC keys. */
3
57
  type CompositeKey = {
4
58
  /** The AES-CBC encryption/decryption key. */encryptionKey: CryptoKey; /** The HMAC key for integrity/authentication. */
@@ -17,8 +71,12 @@ interface GenerateKeyOptions {
17
71
  publicExponent?: Uint8Array<ArrayBuffer>;
18
72
  /** Named curve for EC or OKP keys. Defaults to "P-256" for EC and "Ed25519" for OKP. */
19
73
  namedCurve?: "P-256" | "P-384" | "P-521" | "X25519" | "Ed25519" | "Ed448";
20
- /** Export the generated key(s) as JWK. If true, the key(s) will be returned in JWK format. */
21
- toJWK?: undefined | boolean | Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">;
74
+ /**
75
+ * Export the generated key(s) as JWK. When `true`, keys are returned in JWK
76
+ * format with a generated `kid`. To include additional JWK parameters
77
+ * (e.g. a custom `kid`), use {@link generateJWK} instead.
78
+ */
79
+ toJWK?: boolean;
22
80
  }
23
81
  type GenerateKeyReturnJWK<TAlg extends GenerateKeyAlgorithm> = TAlg extends JWK_Asymmetric_Algorithm ? TAlg extends JWK_RSA_SIGN | JWK_RSA_PSS | JWK_RSA_ENC ? {
24
82
  privateKey: JWK_RSA_Private;
@@ -31,7 +89,7 @@ type GenerateKeyReturnJWK<TAlg extends GenerateKeyAlgorithm> = TAlg extends JWK_
31
89
  publicKey: JWK_OKP_Public;
32
90
  } : never : TAlg extends JWK_AES_CBC_HMAC | JWK_Symmetric_Algorithm ? JWK_oct : never;
33
91
  type GenerateKeyReturnCrypto<TAlg extends GenerateKeyAlgorithm> = TAlg extends JWK_AES_CBC_HMAC ? Uint8Array<ArrayBuffer> : TAlg extends JWK_Asymmetric_Algorithm ? CryptoKeyPair : CryptoKey;
34
- type GenerateKeyReturn<TAlg extends GenerateKeyAlgorithm, TOptions extends GenerateKeyOptions> = TOptions["toJWK"] extends true ? GenerateKeyReturnJWK<TAlg> : TOptions["toJWK"] extends object ? GenerateKeyReturnJWK<TAlg> : GenerateKeyReturnCrypto<TAlg>;
92
+ type GenerateKeyReturn<TAlg extends GenerateKeyAlgorithm, TOptions extends GenerateKeyOptions> = TOptions["toJWK"] extends true ? GenerateKeyReturnJWK<TAlg> : GenerateKeyReturnCrypto<TAlg>;
35
93
  type GenerateJWKOptions = Omit<GenerateKeyOptions, "toJWK">;
36
94
  type GenerateJWKReturn<TAlg extends GenerateKeyAlgorithm> = GenerateKeyReturnJWK<TAlg>;
37
95
  /** Options for the deriveKeyFromPassword function. */
@@ -44,11 +102,15 @@ interface DeriveKeyOptions {
44
102
  keyUsage?: KeyUsage[];
45
103
  /** Mark the derived key as extractable. Defaults to false. */
46
104
  extractable?: boolean;
47
- /** Export the derived key as JWK. If true, the key will be returned in JWK_oct format. */
48
- toJWK?: undefined | boolean | Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">;
105
+ /**
106
+ * Export the derived key as JWK_oct. When `true`, returns the derived key in
107
+ * JWK format. To include additional JWK parameters (e.g. a custom `kid`),
108
+ * use {@link deriveJWKFromPassword} instead.
109
+ */
110
+ toJWK?: boolean;
49
111
  }
50
112
  type DeriveKeyReturn<TOptions extends DeriveKeyOptions> = TOptions["toJWK"] extends true ? JWK_oct : TOptions["toJWK"] extends object ? JWK_oct : CryptoKey;
51
- type KeyManagementAlgorithm = JWK_RSA_ENC | JWK_AES_KW | JWK_AES_GCM | JWK_AES_GCM_KW | JWK_PBES2 | JWK_ECDH_ES;
113
+ type KeyManagementAlgorithm = JWK_RSA_ENC | JWK_AES_KW | JWK_AES_GCM | JWK_AES_GCM_KW | JWK_PBES2 | JWK_ECDH_ES | "dir";
52
114
  type ContentEncryptionAlgorithm = JWK_AES_GCM | JWK_AES_CBC_HMAC;
53
115
  /** Options for the wrapKey function. */
54
116
  interface WrapKeyOptions {
@@ -58,12 +120,25 @@ interface WrapKeyOptions {
58
120
  p2s?: Uint8Array<ArrayBuffer>;
59
121
  /** PBES2 Iteration count (p2c). Required for PBES2 algorithms. */
60
122
  p2c?: number;
61
- /** ECDH-ES Ephemeral Public Key. Generated if not provided for ECDH-ES. */
62
- epk?: JWK_EC_Public;
63
- /** ECDH-ES Agreement PartyUInfo. */
64
- apu?: Uint8Array<ArrayBuffer>;
65
- /** ECDH-ES Agreement PartyVInfo. */
66
- apv?: Uint8Array<ArrayBuffer>;
123
+ /** ECDH-ES specific options. */
124
+ ecdh?: {
125
+ /**
126
+ * ECDH-ES ephemeral key material. A fresh ephemeral key pair is generated
127
+ * automatically when this is not provided.
128
+ */
129
+ ephemeralKey?: CryptoKey | JWK_EC_Private | CryptoKeyPair | {
130
+ publicKey: CryptoKey | JWK_EC_Public;
131
+ privateKey: CryptoKey | JWK_EC_Private;
132
+ }; /** Agreement PartyUInfo (apu). */
133
+ partyUInfo?: Uint8Array<ArrayBuffer>; /** Agreement PartyVInfo (apv). */
134
+ partyVInfo?: Uint8Array<ArrayBuffer>;
135
+ /**
136
+ * Content encryption algorithm used for key-length derivation.
137
+ * Required only when `alg` is `"ECDH-ES"` (direct key agreement).
138
+ * Not needed for `ECDH-ES+A128KW`, `+A192KW`, or `+A256KW`.
139
+ */
140
+ enc?: ContentEncryptionAlgorithm;
141
+ };
67
142
  }
68
143
  /** Result of the wrapKey function. */
69
144
  interface WrapKeyResult {
@@ -86,6 +161,13 @@ interface WrapKeyResult {
86
161
  }
87
162
  /** Options for the unwrapKey function. */
88
163
  interface UnwrapKeyOptions {
164
+ /**
165
+ * Output format of the unwrapped key.
166
+ * - `"cryptokey"` (default) — returns a `CryptoKey` ready for use with WebCrypto.
167
+ * - `"raw"` — returns the raw key bytes as `Uint8Array` (useful for
168
+ * interoperability or when the algorithm is not directly importable).
169
+ */
170
+ format?: "cryptokey" | "raw";
89
171
  /** Initialization Vector (required for AES-GCMKW). Base64URL encoded or Uint8Array. */
90
172
  iv?: Uint8Array<ArrayBuffer> | string;
91
173
  /** Authentication Tag (required for AES-GCMKW). Base64URL encoded or Uint8Array. */
@@ -108,7 +190,6 @@ interface UnwrapKeyOptions {
108
190
  keyUsage?: KeyUsage[];
109
191
  /** Mark the unwrapped key as extractable. Defaults to true. */
110
192
  extractable?: boolean;
111
- returnAs?: boolean | undefined;
112
193
  }
113
194
  /**
114
195
  * Forked from https://github.com/panva/jose/tree/v6.0.10
@@ -141,6 +222,12 @@ interface JWKParameters {
141
222
  x5u?: string;
142
223
  /** JWK "kid" (Key ID) Parameter */
143
224
  kid?: string;
225
+ /**
226
+ * Non-standard JWK content encryption algorithm hint.
227
+ * When `alg` is `"dir"`, the library reads this field to infer the
228
+ * content encryption algorithm (`enc`) when it is not provided in options.
229
+ */
230
+ enc?: ContentEncryptionAlgorithm;
144
231
  }
145
232
  /** Public EC JSON Web Keys */
146
233
  interface JWK_EC_Public extends JWKParameters {
@@ -256,7 +343,7 @@ type JWK_ECDH_ES = "ECDH-ES" | "ECDH-ES+A128KW" | "ECDH-ES+A192KW" | "ECDH-ES+A2
256
343
  type JWK_OKP_SIGN = "Ed25519" | "EdDSA";
257
344
  type JWK_Symmetric_Algorithm = JWK_HMAC | JWK_AES_KW | JWK_AES_GCM | JWK_AES_GCM_KW;
258
345
  type JWK_Asymmetric_Algorithm = JWK_RSA_SIGN | JWK_RSA_PSS | JWK_ECDSA | JWK_RSA_ENC | JWK_OKP_SIGN | JWK_ECDH_ES;
259
- type JWKAlgorithm = JWK_Symmetric_Algorithm | JWK_Asymmetric_Algorithm | JWK_AES_CBC_HMAC | JWK_PBES2 | JWK_ECDH_ES | ("none" | "dir");
346
+ type JWKAlgorithm = JWK_Symmetric_Algorithm | JWK_Asymmetric_Algorithm | JWK_AES_CBC_HMAC | JWK_PBES2 | JWK_ECDH_ES | "dir";
260
347
  type JWKPEMAlgorithm = JWK_RSA_PSS | JWK_RSA_SIGN | JWK_RSA_ENC | JWK_ECDSA | JWK_ECDH_ES | JWK_OKP_SIGN;
261
348
  //#endregion
262
349
  //#region src/core/types/jwt.d.ts
@@ -283,6 +370,15 @@ interface JoseHeaderParameters {
283
370
  /** Any other JWS/JWE Header member. */
284
371
  [propName: string]: unknown;
285
372
  }
373
+ /**
374
+ * Payload accepted by {@link sign} and {@link encrypt}.
375
+ *
376
+ * Covers raw strings and bytes for non-JWT use, plus any JSON-serializable
377
+ * object for JWT and generic structured payloads. JWT-specific claim names
378
+ * are not enforced at this level — use {@link JWTClaims} when you want typed
379
+ * claim names and spec-compliant field types.
380
+ */
381
+ type JOSEPayload = string | Uint8Array<ArrayBuffer> | Record<string, unknown>;
286
382
  interface JWTClaims {
287
383
  /** "iss" (Issuer) Claim */
288
384
  iss?: string;
@@ -324,20 +420,18 @@ interface JWTClaimValidationOptions {
324
420
  currentDate?: Date;
325
421
  /** Additional required claim names. */
326
422
  requiredClaims?: string[];
327
- /** List of critical header parameters that must be understood and processed. */
328
- requiredHeaders?: string[];
329
423
  /**
330
- * Critical Header Parameters to be understood and processed.
331
- * If the JWT contains critical headers not in this list (and not inherently understood by the library), decryption will fail.
332
- * @deprecated use {@link requiredHeaders `recognizedHeaders` option} instead.
424
+ * Critical header parameters that this caller understands and has processed.
425
+ * If the token's `crit` header lists a parameter not present in this list
426
+ * (and not natively understood by the library), verification will fail per
427
+ * RFC 7515 §4.1.11 / RFC 7516 §4.1.13.
333
428
  */
334
- critical?: string[];
429
+ recognizedHeaders?: string[];
335
430
  }
336
431
  //#endregion
337
432
  //#region src/core/types/jws.d.ts
338
- type JWS_SIGN_EXTRA = "Ed25519" | "EdDSA";
339
433
  /** JWS Signing Algorithm Identifier. */
340
- type JWSAlgorithm = JWK_HMAC | JWK_RSA_SIGN | JWK_RSA_PSS | JWK_ECDSA | JWS_SIGN_EXTRA;
434
+ type JWSAlgorithm = JWK_HMAC | JWK_RSA_SIGN | JWK_RSA_PSS | JWK_ECDSA | JWK_OKP_SIGN;
341
435
  /** Recognized JWS Header Parameters, any other Header Members may also be present. */
342
436
  interface JWSHeaderParameters extends JoseHeaderParameters {
343
437
  /** JWS "alg" (Algorithm) Header Parameter */
@@ -373,7 +467,7 @@ interface JWSSignOptions {
373
467
  expiresIn?: ExpiresIn;
374
468
  }
375
469
  /** Result of JWS verification */
376
- interface JWSVerifyResult<T extends JWTClaims | Uint8Array<ArrayBuffer> | string = JWTClaims | Uint8Array<ArrayBuffer> | string> {
470
+ interface JWSVerifyResult<T extends JOSEPayload = JOSEPayload> {
377
471
  /** The decoded and verified payload. */
378
472
  payload: T;
379
473
  /** The JWS Protected Header. */
@@ -385,16 +479,15 @@ interface JWSVerifyOptions extends JWTClaimValidationOptions {
385
479
  algorithms?: JWSAlgorithm[];
386
480
  /** If true, forces the payload to be returned as a Uint8Array, otherwise type is inferred. */
387
481
  forceUint8Array?: boolean;
388
- /** Unless false, will parse payload as JWT and validate claims if applicable (typ "JWT"). */
389
- validateJWT?: boolean;
482
+ /**
483
+ * Controls JWT claim validation after a successful verification.
484
+ *
485
+ * - `true` — always validate claims regardless of the `typ` header
486
+ * - `false` — skip claim validation entirely
487
+ * - `undefined` (default) — validate when `typ` is `"JWT"` or contains `"jwt"`
488
+ */
489
+ validateClaims?: boolean;
390
490
  }
391
- /**
392
- * Key lookup function for JWS verification.
393
- * @param header The JWS Protected Header.
394
- * @param token The JWS token.
395
- * @returns The key material (CryptoKey, JWK, or raw Uint8Array) or a Promise resolving to it.
396
- */
397
- type JWSKeyLookupFunction = (header: JWSProtectedHeader, token: string) => CryptoKey | JWK | JWKSet | Uint8Array<ArrayBuffer> | Promise<CryptoKey | JWK | JWKSet | Uint8Array<ArrayBuffer>>;
398
491
  //#endregion
399
492
  //#region src/core/utils/types.d.ts
400
493
  type StrictOmit<T, K extends keyof T | (string & {}) | (number & {}) | (symbol & {})> = { [P in keyof T as P extends K ? never : P]: T[P] };
@@ -405,11 +498,11 @@ interface JWEHeaderParameters extends JoseHeaderParameters {
405
498
  /**
406
499
  * `alg` (Algorithm): Header Parameter - Key Management Algorithm
407
500
  */
408
- alg?: string;
501
+ alg?: KeyManagementAlgorithm | (string & {});
409
502
  /**
410
503
  * `enc` (Encryption Algorithm): Header Parameter - Content Encryption Algorithm
411
504
  */
412
- enc?: string;
505
+ enc?: ContentEncryptionAlgorithm | (string & {});
413
506
  /**
414
507
  * `p2c` (PBES2 Count): Header Parameter
415
508
  */
@@ -511,12 +604,6 @@ interface JWEEncryptOptions {
511
604
  contentEncryptionIV?: Uint8Array<ArrayBuffer>;
512
605
  }
513
606
  /**
514
- * Key lookup function for JWE decryption.
515
- * @param header The JWE Protected Header.
516
- * @returns The key material (CryptoKey, JWK, password string, or raw Uint8Array) or a Promise resolving to it.
517
- */
518
- type JWEKeyLookupFunction = (header: JWEHeaderParameters, token: string) => CryptoKey | JWK | string | Uint8Array<ArrayBuffer> | Promise<CryptoKey | JWK | string | Uint8Array<ArrayBuffer>>;
519
- /**
520
607
  * JWE (JSON Web Encryption) decryption options
521
608
  */
522
609
  interface JWEDecryptOptions extends JWTClaimValidationOptions {
@@ -532,19 +619,36 @@ interface JWEDecryptOptions extends JWTClaimValidationOptions {
532
619
  extractable?: boolean;
533
620
  /** If true, forces the payload to be returned as a Uint8Array, otherwise type is inferred based on JWE headers. */
534
621
  forceUint8Array?: boolean;
535
- /** Unless false, will parse payload as JWT and validate claims if applicable (typ "JWT"). */
536
- validateJWT?: boolean;
622
+ /**
623
+ * Controls JWT claim validation after a successful decryption.
624
+ *
625
+ * - `true` — always validate claims regardless of the `typ` header
626
+ * - `false` — skip claim validation entirely
627
+ * - `undefined` (default) — validate when `typ` is `"JWT"` or contains `"jwt"`
628
+ */
629
+ validateClaims?: boolean;
537
630
  /** If true, include the Content Encryption Key (CEK) and Additional Authenticated Data (AAD) in the result. */
538
631
  returnCek?: boolean;
539
632
  }
540
633
  /**
634
+ * JWE Protected Header — the parsed and validated protected header returned
635
+ * after a successful {@link decrypt} call. Both `alg` and `enc` are present
636
+ * and strongly typed because decryption could not have succeeded without them.
637
+ */
638
+ interface JWEProtectedHeader extends JWEHeaderParameters {
639
+ /** Key management algorithm. */
640
+ alg: KeyManagementAlgorithm;
641
+ /** Content encryption algorithm. */
642
+ enc: ContentEncryptionAlgorithm;
643
+ }
644
+ /**
541
645
  * Result of a JWE decryption operation.
542
646
  */
543
- interface JWEDecryptResult<T extends JWTClaims | Uint8Array<ArrayBuffer> | string = JWTClaims | Uint8Array<ArrayBuffer> | string> {
647
+ interface JWEDecryptResult<T extends JOSEPayload = JOSEPayload> {
544
648
  /** The decrypted payload. */
545
649
  payload: T;
546
650
  /** The JWE Protected Header. */
547
- protectedHeader: JWEHeaderParameters;
651
+ protectedHeader: JWEProtectedHeader;
548
652
  /** The Content Encryption Key (CEK) used for decryption, as Uint8Array. Only present when `returnCek` is true. */
549
653
  cek?: Uint8Array<ArrayBuffer>;
550
654
  /** The Additional Authenticated Data (AAD) used, as Uint8Array. Only present when `returnCek` is true. */
@@ -555,16 +659,6 @@ interface JWEDecryptResult<T extends JWTClaims | Uint8Array<ArrayBuffer> | strin
555
659
  type ExpiresIn = number | `${number}` | `${number}${"s" | "second" | "seconds" | "m" | "minute" | "minutes" | "h" | "hour" | "hours" | "D" | "day" | "days" | "W" | "week" | "weeks" | "M" | "month" | "months" | "Y" | "year" | "years"}`;
556
660
  type MaxTokenAge = ExpiresIn;
557
661
  //#endregion
558
- //#region src/core/jose/asn1.d.ts
559
- /** Key Import Function options. */
560
- interface KeyImportOptions {
561
- /**
562
- * The value to use as {@link !SubtleCrypto.importKey} `extractable` argument. Default is false for
563
- * private keys, true otherwise.
564
- */
565
- extractable?: boolean;
566
- }
567
- //#endregion
568
662
  //#region src/core/jwk.d.ts
569
663
  /**
570
664
  * Generates a Json Web Key (JWK) for the specified algorithm.
@@ -596,7 +690,10 @@ declare function deriveJWKFromPassword(password: string | Uint8Array<ArrayBuffer
596
690
  * @param jwkExtras Additional properties to merge into the resulting JWK.
597
691
  * @returns A Promise resolving to the imported key as a JWK.
598
692
  */
599
- declare function importJWKFromPEM<T extends JWK>(pem: string, pemType: "pkcs8" | "spki" | "x509", alg: JWKPEMAlgorithm, importOptions?: KeyImportOptions, jwkExtras?: Partial<JWK>): Promise<T>;
693
+ declare function importFromPEM<T extends JWK>(pem: string, pemType: "pkcs8" | "spki" | "x509", alg: JWKPEMAlgorithm, options?: {
694
+ /** Passed to `crypto.subtle.importKey`. Defaults to `false` for private keys, `true` otherwise. */extractable?: boolean; /** Additional JWK properties merged into the exported key (e.g. `kid`). */
695
+ jwkParams?: Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">;
696
+ }): Promise<T>;
600
697
  /**
601
698
  * Exports a JWK to a PEM-encoded string.
602
699
  *
@@ -606,6 +703,6 @@ declare function importJWKFromPEM<T extends JWK>(pem: string, pemType: "pkcs8" |
606
703
  * required to correctly convert it to a CryptoKey first.
607
704
  * @returns A Promise resolving to the PEM-encoded key string.
608
705
  */
609
- declare function exportJWKToPEM(jwk: JWK, pemFormat: "pkcs8" | "spki", algForCryptoKeyImport?: JWKPEMAlgorithm): Promise<string>;
706
+ declare function exportToPEM(jwk: JWK, pemFormat: "pkcs8" | "spki", algForCryptoKeyImport?: JWKPEMAlgorithm): Promise<string>;
610
707
  //#endregion
611
- export { JWK_OKP_Public as $, GenerateJWKReturn as A, JWK_AES_GCM as B, JWTClaims as C, DeriveKeyOptions as D, ContentEncryptionAlgorithm as E, JWKAlgorithm as F, JWK_EC as G, JWK_AES_KW as H, JWKPEMAlgorithm as I, JWK_EC_Private as J, JWK_ECDH_ES as K, JWKParameters as L, GenerateKeyOptions as M, GenerateKeyReturn as N, DeriveKeyReturn as O, JWK as P, JWK_OKP_Private as Q, JWKSet as R, JWTClaimValidationOptions as S, CompositeKey as T, JWK_Asymmetric as U, JWK_AES_GCM_KW as V, JWK_Asymmetric_Algorithm as W, JWK_HMAC as X, JWK_EC_Public as Y, JWK_OKP as Z, JWSProtectedHeader as _, WrapKeyResult as _t, ExpiresIn as a, JWK_RSA as at, JWSVerifyResult as b, JWEDecryptResult as c, JWK_RSA_Private as ct, JWEKeyLookupFunction as d, JWK_Symmetric as dt, JWK_OKP_SIGN as et, JWEKeyManagementHeaderParameters as f, JWK_Symmetric_Algorithm as ft, JWSKeyLookupFunction as g, WrapKeyOptions as gt, JWSHeaderParameters as h, UnwrapKeyOptions as ht, importJWKFromPEM as i, JWK_Public as it, GenerateKeyAlgorithm as j, GenerateJWKOptions as k, JWEEncryptOptions as l, JWK_RSA_Public as lt, JWSAlgorithm as m, KeyManagementAlgorithm as mt, exportJWKToPEM as n, JWK_Pair as nt, MaxTokenAge as o, JWK_RSA_ENC as ot, StrictOmit as p, JWK_oct as pt, JWK_ECDSA as q, generateJWK as r, JWK_Private as rt, JWEDecryptOptions as s, JWK_RSA_PSS as st, deriveJWKFromPassword as t, JWK_PBES2 as tt, JWEHeaderParameters as u, JWK_RSA_SIGN as ut, JWSSignOptions as v, JoseHeaderParameters as w, JWT as x, JWSVerifyOptions as y, JWK_AES_CBC_HMAC as z };
708
+ export { JWK_HMAC as $, GenerateJWKReturn as A, JWKParameters as B, JWTClaims as C, DeriveKeyOptions as D, ContentEncryptionAlgorithm as E, JWKAlgorithm as F, JWK_AES_KW as G, JWK_AES_CBC_HMAC as H, JWKCacheAdapter as I, JWK_EC as J, JWK_Asymmetric as K, JWKLookupFunction as L, GenerateKeyOptions as M, GenerateKeyReturn as N, DeriveKeyReturn as O, JWK as P, JWK_EC_Public as Q, JWKLookupFunctionHeader as R, JWTClaimValidationOptions as S, CompositeKey as T, JWK_AES_GCM as U, JWKSet as V, JWK_AES_GCM_KW as W, JWK_ECDSA as X, JWK_ECDH_ES as Y, JWK_EC_Private as Z, JWSSignOptions as _, KeyManagementAlgorithm as _t, ExpiresIn as a, JWK_Pair as at, JOSEPayload as b, WrapKeyResult as bt, JWEDecryptResult as c, JWK_RSA as ct, JWEKeyManagementHeaderParameters as d, JWK_RSA_Private as dt, JWK_OKP as et, JWEProtectedHeader as f, JWK_RSA_Public as ft, JWSProtectedHeader as g, JWK_oct as gt, JWSHeaderParameters as h, JWK_Symmetric_Algorithm as ht, importFromPEM as i, JWK_PBES2 as it, GenerateKeyAlgorithm as j, GenerateJWKOptions as k, JWEEncryptOptions as l, JWK_RSA_ENC as lt, JWSAlgorithm as m, JWK_Symmetric as mt, exportToPEM as n, JWK_OKP_Public as nt, MaxTokenAge as o, JWK_Private as ot, StrictOmit as p, JWK_RSA_SIGN as pt, JWK_Asymmetric_Algorithm as q, generateJWK as r, JWK_OKP_SIGN as rt, JWEDecryptOptions as s, JWK_Public as st, deriveJWKFromPassword as t, JWK_OKP_Private as tt, JWEHeaderParameters as u, JWK_RSA_PSS as ut, JWSVerifyOptions as v, UnwrapKeyOptions as vt, JoseHeaderParameters as w, JWT as x, JWSVerifyResult as y, WrapKeyOptions as yt, JWKPEMAlgorithm as z };