jose 6.2.11 → 6.2.13

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 (85) hide show
  1. package/README.md +2 -2
  2. package/dist/types/index.d.ts +1 -2
  3. package/dist/types/jwe/compact/decrypt.d.ts +9 -12
  4. package/dist/types/jwe/compact/encrypt.d.ts +14 -17
  5. package/dist/types/jwe/flattened/decrypt.d.ts +9 -12
  6. package/dist/types/jwe/flattened/encrypt.d.ts +17 -20
  7. package/dist/types/jwe/general/decrypt.d.ts +12 -17
  8. package/dist/types/jwe/general/encrypt.d.ts +19 -22
  9. package/dist/types/jwk/embedded.d.ts +3 -1
  10. package/dist/types/jwk/thumbprint.d.ts +4 -6
  11. package/dist/types/jwks/local.d.ts +5 -4
  12. package/dist/types/jwks/remote.d.ts +20 -21
  13. package/dist/types/jws/compact/sign.d.ts +7 -6
  14. package/dist/types/jws/compact/verify.d.ts +9 -12
  15. package/dist/types/jws/flattened/sign.d.ts +8 -7
  16. package/dist/types/jws/flattened/verify.d.ts +10 -12
  17. package/dist/types/jws/general/sign.d.ts +16 -17
  18. package/dist/types/jws/general/verify.d.ts +14 -18
  19. package/dist/types/jwt/decrypt.d.ts +15 -11
  20. package/dist/types/jwt/encrypt.d.ts +25 -23
  21. package/dist/types/jwt/sign.d.ts +4 -8
  22. package/dist/types/jwt/unsecured.d.ts +3 -7
  23. package/dist/types/jwt/verify.d.ts +12 -7
  24. package/dist/types/key/export.d.ts +6 -6
  25. package/dist/types/key/generate_key_pair.d.ts +9 -14
  26. package/dist/types/key/generate_secret.d.ts +10 -10
  27. package/dist/types/key/import.d.ts +21 -20
  28. package/dist/types/types.d.ts +217 -254
  29. package/dist/types/util/base64url.d.ts +7 -7
  30. package/dist/types/util/decode_jwt.d.ts +6 -1
  31. package/dist/types/util/decode_protected_header.d.ts +4 -3
  32. package/dist/types/util/errors.d.ts +30 -41
  33. package/dist/webapi/jwe/compact/decrypt.js +1 -2
  34. package/dist/webapi/jwe/compact/encrypt.js +9 -26
  35. package/dist/webapi/jwe/flattened/decrypt.js +3 -3
  36. package/dist/webapi/jwe/flattened/encrypt.js +11 -30
  37. package/dist/webapi/jwe/general/decrypt.js +6 -6
  38. package/dist/webapi/jwe/general/encrypt.js +36 -60
  39. package/dist/webapi/jwk/embedded.js +3 -4
  40. package/dist/webapi/jwk/thumbprint.js +11 -14
  41. package/dist/webapi/jwks/local.js +18 -11
  42. package/dist/webapi/jwks/remote.js +5 -5
  43. package/dist/webapi/jws/compact/sign.js +2 -4
  44. package/dist/webapi/jws/compact/verify.js +2 -2
  45. package/dist/webapi/jws/flattened/sign.js +8 -15
  46. package/dist/webapi/jws/flattened/verify.js +4 -14
  47. package/dist/webapi/jws/general/sign.js +6 -13
  48. package/dist/webapi/jws/general/verify.js +8 -10
  49. package/dist/webapi/jwt/decrypt.js +2 -3
  50. package/dist/webapi/jwt/encrypt.js +13 -27
  51. package/dist/webapi/jwt/sign.js +3 -3
  52. package/dist/webapi/jwt/unsecured.js +4 -5
  53. package/dist/webapi/jwt/verify.js +4 -4
  54. package/dist/webapi/key/export.js +12 -16
  55. package/dist/webapi/key/generate_key_pair.js +4 -13
  56. package/dist/webapi/key/generate_secret.js +5 -5
  57. package/dist/webapi/key/import.js +5 -9
  58. package/dist/webapi/lib/asn1.js +4 -6
  59. package/dist/webapi/lib/buffer_utils.js +39 -4
  60. package/dist/webapi/lib/content_encryption.js +29 -37
  61. package/dist/webapi/lib/deflate.js +9 -19
  62. package/dist/webapi/lib/jwe_algorithms.js +0 -4
  63. package/dist/webapi/lib/jwe_decrypt.js +30 -63
  64. package/dist/webapi/lib/jwe_encrypt.js +27 -60
  65. package/dist/webapi/lib/jws_algorithms.js +2 -2
  66. package/dist/webapi/lib/jws_sign.js +31 -45
  67. package/dist/webapi/lib/jws_verify.js +43 -48
  68. package/dist/webapi/lib/jwt_claims_set.js +45 -44
  69. package/dist/webapi/lib/key.js +122 -62
  70. package/dist/webapi/lib/key_management.js +57 -92
  71. package/dist/webapi/lib/{options.js → validate.js} +64 -3
  72. package/dist/webapi/util/base64url.js +5 -19
  73. package/dist/webapi/util/decode_jwt.js +13 -13
  74. package/dist/webapi/util/decode_protected_header.js +6 -6
  75. package/package.json +1 -1
  76. package/dist/webapi/lib/base64.js +0 -20
  77. package/dist/webapi/lib/crypto_key.js +0 -27
  78. package/dist/webapi/lib/helpers.js +0 -45
  79. package/dist/webapi/lib/invalid_key_input.js +0 -12
  80. package/dist/webapi/lib/is_key_like.js +0 -19
  81. package/dist/webapi/lib/jwk_metadata.js +0 -19
  82. package/dist/webapi/lib/jwk_to_key.js +0 -10
  83. package/dist/webapi/lib/key_options.js +0 -8
  84. package/dist/webapi/lib/signing.js +0 -22
  85. package/dist/webapi/lib/type_checks.js +0 -30
@@ -1,7 +1,4 @@
1
- /**
2
- * JWS "alg" (Algorithm) Header Parameter values supported by this module. Availability of a given
3
- * identifier additionally depends on the runtime.
4
- */
1
+ /** Supported JWS "alg" (Algorithm) Header Parameter values. Availability depends on the runtime. */
5
2
  export type JWSAlgorithm =
6
3
  | 'HS256'
7
4
  | 'HS384'
@@ -22,10 +19,7 @@ export type JWSAlgorithm =
22
19
  | 'ML-DSA-87'
23
20
  | (string & {})
24
21
 
25
- /**
26
- * JWE "alg" (Algorithm) Header Parameter values supported by this module. Availability of a given
27
- * identifier additionally depends on the runtime.
28
- */
22
+ /** Supported JWE "alg" (Algorithm) Header Parameter values. Availability depends on the runtime. */
29
23
  export type JWEKeyManagementAlgorithm =
30
24
  | 'dir'
31
25
  | 'A128KW'
@@ -48,8 +42,8 @@ export type JWEKeyManagementAlgorithm =
48
42
  | (string & {})
49
43
 
50
44
  /**
51
- * JWE "enc" (Encryption Algorithm) Header Parameter values supported by this module. Availability
52
- * of a given identifier additionally depends on the runtime.
45
+ * Supported JWE "enc" (Encryption Algorithm) Header Parameter values. Availability depends on the
46
+ * runtime.
53
47
  */
54
48
  export type JWEContentEncryptionAlgorithm =
55
49
  | 'A128CBC-HS256'
@@ -74,35 +68,43 @@ export type JWKParameters = {
74
68
  kty?: JWKKeyType
75
69
  /** JWK "alg" (Algorithm) Parameter */
76
70
  alg?: JWSAlgorithm | JWEKeyManagementAlgorithm | JWEContentEncryptionAlgorithm
77
- /** JWK "key_ops" (Key Operations) Parameter */
71
+ /** JWK "key_ops" (Key Operations) Parameter (RFC 7517, Section 4.3). */
78
72
  key_ops?: string[]
79
- /** JWK "ext" (Extractable) Parameter */
73
+ /** Web Crypto "ext" (Extractable) member; whether the key may be exported. */
80
74
  ext?: boolean
75
+
81
76
  /** JWK "use" (Public Key Use) Parameter */
82
77
  use?: 'sig' | 'enc' | (string & {})
83
- /** JWK "x5c" (X.509 Certificate Chain) Parameter */
78
+ /**
79
+ * "x5c" (X.509 Certificate Chain): base64-encoded DER certificates (RFC 7517, Section 4.7; RFC
80
+ * 7515, Section 4.1.6).
81
+ */
84
82
  x5c?: string[]
85
- /** JWK "x5t" (X.509 Certificate SHA-1 Thumbprint) Parameter */
83
+ /** "x5t" (X.509 Certificate SHA-1 Thumbprint): base64url-encoded digest of the DER certificate. */
86
84
  x5t?: string
87
- /** JWK "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Parameter */
85
+ /**
86
+ * "x5t#S256" (X.509 Certificate SHA-256 Thumbprint): base64url-encoded digest of the DER
87
+ * certificate.
88
+ */
88
89
  'x5t#S256'?: string
89
- /** JWK "x5u" (X.509 URL) Parameter */
90
+ /** JWK "x5u" (X.509 URL) Parameter: URL of a PEM-encoded certificate or certificate chain. */
90
91
  x5u?: string
92
+
91
93
  /** JWK "kid" (Key ID) Parameter */
92
94
  kid?: string
93
95
  }
94
96
 
95
97
  /** Convenience interface for public OKP JSON Web Keys. */
96
98
  export interface JWK_OKP_Public extends JWKParameters {
97
- /** OKP JWK "crv" (The Subtype of Key Pair) Parameter */
99
+ /** JWK "crv" (Subtype of Key Pair) Parameter (RFC 8037, Section 2). */
98
100
  crv: string
99
- /** OKP JWK "x" (The public key) Parameter */
101
+ /** Base64url-encoded public key (RFC 8037, Section 2). */
100
102
  x: string
101
103
  }
102
104
 
103
105
  /** Convenience interface for private OKP JSON Web Keys. */
104
106
  export interface JWK_OKP_Private extends JWK_OKP_Public {
105
- /** OKP JWK "d" (The Private Key) Parameter */
107
+ /** Base64url-encoded private key (RFC 8037, Section 2). */
106
108
  d: string
107
109
  }
108
110
 
@@ -110,59 +112,63 @@ export interface JWK_OKP_Private extends JWK_OKP_Public {
110
112
  export interface JWK_AKP_Public extends JWKParameters {
111
113
  /** JWK "alg" (Algorithm) Parameter */
112
114
  alg: string
113
- /** AKP JWK "pub" (The Public key) Parameter */
115
+
116
+ /** AKP JWK "pub" (Public Key): base64url-encoded public key (RFC 9964, Section 3) */
114
117
  pub: string
115
118
  }
116
119
 
117
120
  /** Convenience interface for private AKP JSON Web Keys. */
118
121
  export interface JWK_AKP_Private extends JWK_AKP_Public {
119
- /** AKP JWK "priv" (The Private Key) Parameter */
122
+ /**
123
+ * AKP JWK "priv" (Private Key): base64url-encoded private key; ML-DSA uses a 32-octet seed (RFC
124
+ * 9964, Sections 3-4)
125
+ */
120
126
  priv: string
121
127
  }
122
128
 
123
129
  /** Convenience interface for public EC JSON Web Keys. */
124
130
  export interface JWK_EC_Public extends JWKParameters {
125
- /** EC JWK "crv" (Curve) Parameter */
131
+ /** JWK "crv" (Curve) Parameter (RFC 7518, Section 6.2.1.1). */
126
132
  crv: string
127
- /** EC JWK "x" (X Coordinate) Parameter */
133
+ /** Base64url-encoded x-coordinate (RFC 7518, Section 6.2.1.2). */
128
134
  x: string
129
- /** EC JWK "y" (Y Coordinate) Parameter */
135
+ /** Base64url-encoded y-coordinate (RFC 7518, Section 6.2.1.3). */
130
136
  y: string
131
137
  }
132
138
 
133
139
  /** Convenience interface for private EC JSON Web Keys. */
134
140
  export interface JWK_EC_Private extends JWK_EC_Public {
135
- /** EC JWK "d" (ECC Private Key) Parameter */
141
+ /** Base64url-encoded private key (RFC 7518, Section 6.2.2). */
136
142
  d: string
137
143
  }
138
144
 
139
145
  /** Convenience interface for public RSA JSON Web Keys. */
140
146
  export interface JWK_RSA_Public extends JWKParameters {
141
- /** RSA JWK "e" (Exponent) Parameter */
147
+ /** Public exponent, encoded as Base64urlUInt (RFC 7518, Section 6.3.1). */
142
148
  e: string
143
- /** RSA JWK "n" (Modulus) Parameter */
149
+ /** Modulus, encoded as Base64urlUInt (RFC 7518, Section 6.3.1). */
144
150
  n: string
145
151
  }
146
152
 
147
153
  /** Convenience interface for private RSA JSON Web Keys. */
148
154
  export interface JWK_RSA_Private extends JWK_RSA_Public {
149
- /** RSA JWK "d" (Private Exponent) Parameter */
155
+ /** Private exponent, encoded as Base64urlUInt (RFC 7518, Section 6.3.2). */
150
156
  d: string
151
- /** RSA JWK "dp" (First Factor CRT Exponent) Parameter */
157
+ /** First factor CRT exponent, encoded as Base64urlUInt (RFC 7518, Section 6.3.2). */
152
158
  dp: string
153
- /** RSA JWK "dq" (Second Factor CRT Exponent) Parameter */
159
+ /** Second factor CRT exponent, encoded as Base64urlUInt (RFC 7518, Section 6.3.2). */
154
160
  dq: string
155
- /** RSA JWK "p" (First Prime Factor) Parameter */
161
+ /** First prime factor, encoded as Base64urlUInt (RFC 7518, Section 6.3.2). */
156
162
  p: string
157
- /** RSA JWK "q" (Second Prime Factor) Parameter */
163
+ /** Second prime factor, encoded as Base64urlUInt (RFC 7518, Section 6.3.2). */
158
164
  q: string
159
- /** RSA JWK "qi" (First CRT Coefficient) Parameter */
165
+ /** First CRT coefficient, encoded as Base64urlUInt (RFC 7518, Section 6.3.2). */
160
166
  qi: string
161
167
  }
162
168
 
163
169
  /** Convenience interface for "oct" JSON Web Keys. */
164
170
  export interface JWK_oct extends JWKParameters {
165
- /** Oct JWK "k" (Key Value) Parameter */
171
+ /** JWK "k" (Key Value): base64url-encoded key octets (RFC 7518, Section 6.4.1). */
166
172
  k: string
167
173
  }
168
174
 
@@ -180,75 +186,82 @@ export type JWK = {
180
186
  kty?: JWKKeyType
181
187
  /** JWK "alg" (Algorithm) Parameter */
182
188
  alg?: JWSAlgorithm | JWEKeyManagementAlgorithm | JWEContentEncryptionAlgorithm
183
- /** JWK "key_ops" (Key Operations) Parameter */
189
+ /** JWK "key_ops" (Key Operations) Parameter (RFC 7517, Section 4.3). */
184
190
  key_ops?: string[]
185
- /** JWK "ext" (Extractable) Parameter */
191
+ /** Web Crypto "ext" (Extractable) member; whether the key may be exported. */
186
192
  ext?: boolean
193
+
187
194
  /** JWK "use" (Public Key Use) Parameter */
188
195
  use?: 'sig' | 'enc' | (string & {})
189
- /** JWK "x5c" (X.509 Certificate Chain) Parameter */
196
+ /**
197
+ * "x5c" (X.509 Certificate Chain): base64-encoded DER certificates (RFC 7517, Section 4.7; RFC
198
+ * 7515, Section 4.1.6).
199
+ */
190
200
  x5c?: string[]
191
- /** JWK "x5t" (X.509 Certificate SHA-1 Thumbprint) Parameter */
201
+ /** "x5t" (X.509 Certificate SHA-1 Thumbprint): base64url-encoded digest of the DER certificate. */
192
202
  x5t?: string
193
- /** JWK "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Parameter */
203
+ /**
204
+ * "x5t#S256" (X.509 Certificate SHA-256 Thumbprint): base64url-encoded digest of the DER
205
+ * certificate.
206
+ */
194
207
  'x5t#S256'?: string
195
- /** JWK "x5u" (X.509 URL) Parameter */
208
+ /** JWK "x5u" (X.509 URL) Parameter: URL of a PEM-encoded certificate or certificate chain. */
196
209
  x5u?: string
210
+
197
211
  /** JWK "kid" (Key ID) Parameter */
198
212
  kid?: string
199
- /**
200
- * - EC JWK "crv" (Curve) Parameter
201
- * - OKP JWK "crv" (The Subtype of Key Pair) Parameter
202
- */
213
+ /** JWK "crv" Parameter: Curve for EC keys or Subtype of Key Pair for OKP keys. */
203
214
  crv?: string
204
215
  /**
205
- * - Private RSA JWK "d" (Private Exponent) Parameter
206
- * - Private EC JWK "d" (ECC Private Key) Parameter
207
- * - Private OKP JWK "d" (The Private Key) Parameter
216
+ * Private key material: Base64urlUInt for RSA (RFC 7518, Section 6.3.2.1), base64url-encoded
217
+ * octets for EC (Section 6.2.2.1) or OKP (RFC 8037, Section 2).
208
218
  */
209
219
  d?: string
210
- /** Private RSA JWK "dp" (First Factor CRT Exponent) Parameter */
220
+ /** RSA first factor CRT exponent, encoded as Base64urlUInt (RFC 7518, Section 6.3). */
211
221
  dp?: string
212
- /** Private RSA JWK "dq" (Second Factor CRT Exponent) Parameter */
222
+ /** RSA second factor CRT exponent, encoded as Base64urlUInt (RFC 7518, Section 6.3). */
213
223
  dq?: string
214
- /** RSA JWK "e" (Exponent) Parameter */
224
+ /** RSA public exponent, encoded as Base64urlUInt (RFC 7518, Section 6.3). */
215
225
  e?: string
216
- /** Oct JWK "k" (Key Value) Parameter */
226
+ /** JWK "k" (Key Value): base64url-encoded key octets (RFC 7518, Section 6.4.1). */
217
227
  k?: string
218
- /** RSA JWK "n" (Modulus) Parameter */
228
+ /** RSA modulus, encoded as Base64urlUInt (RFC 7518, Section 6.3). */
219
229
  n?: string
220
- /** Private RSA JWK "p" (First Prime Factor) Parameter */
230
+ /** RSA first prime factor, encoded as Base64urlUInt (RFC 7518, Section 6.3). */
221
231
  p?: string
222
- /** Private RSA JWK "q" (Second Prime Factor) Parameter */
232
+ /** RSA second prime factor, encoded as Base64urlUInt (RFC 7518, Section 6.3). */
223
233
  q?: string
224
- /** Private RSA JWK "qi" (First CRT Coefficient) Parameter */
234
+ /** RSA first CRT coefficient, encoded as Base64urlUInt (RFC 7518, Section 6.3). */
225
235
  qi?: string
226
236
  /**
227
- * - EC JWK "x" (X Coordinate) Parameter
228
- * - OKP JWK "x" (The public key) Parameter
237
+ * Base64url-encoded EC x-coordinate (RFC 7518, Section 6.2.1.2) or OKP public key (RFC 8037,
238
+ * Section 2).
229
239
  */
230
240
  x?: string
231
- /** EC JWK "y" (Y Coordinate) Parameter */
241
+ /** Base64url-encoded EC y-coordinate (RFC 7518, Section 6.2.1.3). */
232
242
  y?: string
233
- /** AKP JWK "pub" (Public Key) Parameter */
243
+
244
+ /** AKP JWK "pub" (Public Key): base64url-encoded public key (RFC 9964, Section 3) */
234
245
  pub?: string
235
- /** AKP JWK "priv" (Private key) Parameter */
246
+
247
+ /**
248
+ * AKP JWK "priv" (Private Key): base64url-encoded private key; ML-DSA uses a 32-octet seed (RFC
249
+ * 9964, Sections 3-4)
250
+ */
236
251
  priv?: string
237
- /** RSA JWK "oth" (Other Primes Info) Parameter */
252
+ /** Additional RSA prime factors. */
238
253
  oth?: Array<{
239
- /** The Factor CRT Exponent */
254
+ /** Factor CRT exponent, encoded as Base64urlUInt (RFC 7518, Section 6.3). */
240
255
  d?: string
241
- /** The Prime Factor */
256
+ /** Prime factor, encoded as Base64urlUInt (RFC 7518, Section 6.3). */
242
257
  r?: string
243
- /** The Factor CRT Coefficient */
258
+ /** Factor CRT coefficient, encoded as Base64urlUInt (RFC 7518, Section 6.3). */
244
259
  t?: string
245
260
  }>
246
261
  }
247
262
 
248
- /** Discriminated union of the supported JSON Web Key shapes. */
249
- // The "kty" is intersected into each arm one at a time rather than distributed over a parenthesised
250
- // union - `X & (A | B)` means the same thing, but typedoc renders it without the parentheses, which
251
- // reads as though the second arm carried no "kty" at all.
263
+ /** Discriminated union of supported JSON Web Key shapes, narrowed by the "kty" (Key Type) Parameter. */
264
+ // Intersect "kty" into each member separately: typedoc omits the parentheses in `X & (A | B)`.
252
265
  export type AnyJWK =
253
266
  | (JWK_EC_Private & { kty: 'EC' })
254
267
  | (JWK_EC_Public & { kty: 'EC' })
@@ -266,64 +279,53 @@ export type KeyInput = CryptoKey | KeyObject | JWK | Uint8Array
266
279
  /** Dynamic key resolver for consuming operations. */
267
280
  export interface GetKeyFunction<IProtectedHeader, IToken, KeyTypes extends KeyInput = KeyInput> {
268
281
  /**
269
- * Dynamic key resolution function. No token components have been verified at the time of this
270
- * function call. If a suitable key for the token cannot be matched, throw an error instead.
282
+ * Resolves a key for an unverified token. Throw if no suitable key can be resolved.
271
283
  *
272
- * @param token The consumed JWE or JWS token.
284
+ * @param token The consumed JWE or JWS token; none of its components have been verified.
273
285
  */
274
286
  (protectedHeader: IProtectedHeader, token: IToken): Promise<KeyTypes> | KeyTypes
275
287
  }
276
288
 
277
- /** Flattened JWS verification input. */
289
+ /** Flattened JWS JSON Serialization verification input. */
278
290
  export interface FlattenedJWSInput {
279
- /**
280
- * The "header" member MUST be present and contain the value JWS Unprotected Header when the JWS
281
- * Unprotected Header value is non- empty; otherwise, it MUST be absent. This value is represented
282
- * as an unencoded JSON object, rather than as a string. These Header Parameter values are not
283
- * integrity protected.
284
- */
291
+ /** JWS Unprotected Header as a JSON object. Not integrity protected; omit when empty. */
285
292
  header?: JWSHeaderParameters
286
293
 
287
- /**
288
- * The "payload" member MUST be present and contain the value BASE64URL(JWS Payload). When RFC7797
289
- * "b64": false is used the value passed may also be a {@link !Uint8Array}.
290
- */
294
+ /** Base64url-encoded JWS Payload; with `b64: false`, supply an unencoded string or Uint8Array. */
291
295
  payload: string | Uint8Array
292
296
 
293
- /**
294
- * The "protected" member MUST be present and contain the value BASE64URL(UTF8(JWS Protected
295
- * Header)) when the JWS Protected Header value is non-empty; otherwise, it MUST be absent. These
296
- * Header Parameter values are integrity protected.
297
- */
297
+ /** Base64url-encoded UTF-8 JWS Protected Header. Integrity protected; omit when empty. */
298
298
  protected?: string
299
299
 
300
- /** The "signature" member MUST be present and contain the value BASE64URL(JWS Signature). */
300
+ /** Base64url-encoded JWS Signature (digital signature or MAC). */
301
301
  signature: string
302
302
  }
303
303
 
304
- /** General JWS verification input. */
304
+ /** General JWS JSON Serialization verification input. */
305
305
  export interface GeneralJWSInput {
306
- /**
307
- * The "payload" member MUST be present and contain the value BASE64URL(JWS Payload). When when
308
- * JWS Unencoded Payload ({@link https://www.rfc-editor.org/info/rfc7797/ RFC7797}) "b64": false is
309
- * used the value passed may also be a {@link !Uint8Array}.
310
- */
306
+ /** Base64url-encoded JWS Payload; with `b64: false`, supply an unencoded string or Uint8Array. */
311
307
  payload: string | Uint8Array
312
308
 
313
309
  /**
314
- * The "signatures" member value MUST be an array of JSON objects. Each object represents a
315
- * signature or MAC over the JWS Payload and the JWS Protected Header.
310
+ * The "signatures" member value MUST be an array of JSON objects. Each object represents a JWS
311
+ * Signature (digital signature or MAC) over the JWS Payload and the JWS Protected Header.
316
312
  */
317
313
  signatures: Omit<FlattenedJWSInput, 'payload'>[]
318
314
  }
319
315
 
320
- /** Flattened JWS JSON Serialization token. */
316
+ /**
317
+ * Flattened JWS JSON Serialization token. The payload is an empty string for detached content when
318
+ * the {@link https://www.rfc-editor.org/info/rfc7797/ unencoded payload option} is used.
319
+ */
321
320
  export interface FlattenedJWS extends Partial<FlattenedJWSInput> {
322
321
  payload: string
323
322
  signature: string
324
323
  }
325
324
 
326
- /** General JWS JSON Serialization token. */
325
+ /**
326
+ * General JWS JSON Serialization token. The payload is an empty string for detached content when
327
+ * the {@link https://www.rfc-editor.org/info/rfc7797/ unencoded payload option} is used.
328
+ */
327
329
  export interface GeneralJWS {
328
330
  payload: string
329
331
  signatures: Omit<FlattenedJWSInput, 'payload'>[]
@@ -334,28 +336,31 @@ export interface JoseHeaderParameters {
334
336
  /** "kid" (Key ID) Header Parameter */
335
337
  kid?: string
336
338
 
337
- /** "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter */
339
+ /** "x5t" (X.509 Certificate SHA-1 Thumbprint): base64url-encoded digest of the DER certificate. */
338
340
  x5t?: string
339
341
 
340
- /** "x5c" (X.509 Certificate Chain) Header Parameter */
342
+ /**
343
+ * "x5c" (X.509 Certificate Chain): base64-encoded DER certificates (RFC 7517, Section 4.7; RFC
344
+ * 7515, Section 4.1.6).
345
+ */
341
346
  x5c?: string[]
342
347
 
343
- /** "x5u" (X.509 URL) Header Parameter */
348
+ /** "x5u" (X.509 URL) Header Parameter: URL of a PEM-encoded certificate or certificate chain. */
344
349
  x5u?: string
345
350
 
346
- /** "jku" (JWK Set URL) Header Parameter */
351
+ /** "jku" (JWK Set URL) Header Parameter (RFC 7515, Section 4.1.2). */
347
352
  jku?: string
348
353
 
349
354
  /**
350
- * "jwk" (JSON Web Key) Header Parameter. This must be a public JSON Web Key; private and
351
- * symmetric key parameters are not permitted.
355
+ * "jwk" (JSON Web Key) Header Parameter: public JWK only; private and symmetric key parameters
356
+ * are not permitted.
352
357
  */
353
358
  jwk?: Omit<JWK, 'd' | 'dp' | 'dq' | 'k' | 'p' | 'q' | 'qi' | 'priv' | 'oth'>
354
359
 
355
360
  /** "typ" (Type) Header Parameter */
356
361
  typ?: string
357
362
 
358
- /** "cty" (Content Type) Header Parameter */
363
+ /** "cty" (Content Type) Header Parameter (RFC 7515, Section 4.1.10). */
359
364
  cty?: string
360
365
  }
361
366
 
@@ -365,12 +370,16 @@ export interface JWSHeaderParameters extends JoseHeaderParameters {
365
370
  alg?: JWSAlgorithm
366
371
 
367
372
  /**
368
- * This JWS Extension Header Parameter modifies the JWS Payload representation and the JWS Signing
369
- * Input computation as per {@link https://www.rfc-editor.org/info/rfc7797/ RFC7797}.
373
+ * Controls payload encoding and the JWS Signing Input as defined by
374
+ * {@link https://www.rfc-editor.org/info/rfc7797/ RFC7797}. Set to `false` and list `b64` in
375
+ * `crit` to use an unencoded payload.
370
376
  */
371
377
  b64?: boolean
372
378
 
373
- /** JWS "crit" (Critical) Header Parameter */
379
+ /**
380
+ * "crit" (Critical) Header Parameter: names of extensions that must be understood and processed;
381
+ * must be integrity protected (RFC 7515, Section 4.1.11).
382
+ */
374
383
  crit?: string[]
375
384
 
376
385
  /** Any other JWS Header member. */
@@ -380,91 +389,71 @@ export interface JWSHeaderParameters extends JoseHeaderParameters {
380
389
  /** Recognized JWE Key Management-related Header Parameters. */
381
390
  export interface JWEKeyManagementHeaderParameters {
382
391
  /**
383
- * ECDH-ES "apu" (Agreement PartyUInfo). This will be used as a JOSE Header Parameter and will be
384
- * used in ECDH's ConcatKDF.
392
+ * Raw Agreement PartyUInfo bytes; base64url-encoded as the "apu" Header Parameter (RFC 7518,
393
+ * Section 4.6.1.2).
385
394
  */
386
395
  apu?: Uint8Array
387
396
 
388
397
  /**
389
- * ECDH-ES "apv" (Agreement PartyVInfo). This will be used as a JOSE Header Parameter and will be
390
- * used in ECDH's ConcatKDF.
398
+ * Raw Agreement PartyVInfo bytes; base64url-encoded as the "apv" Header Parameter (RFC 7518,
399
+ * Section 4.6.1.3).
391
400
  */
392
401
  apv?: Uint8Array
393
402
 
394
403
  /**
395
- * PBES2 "p2c" (PBES2 Count). This will be used as a JOSE Header Parameter and as the PBKDF2
396
- * iteration count.
404
+ * "p2c" (PBES2 Count) Header Parameter: positive PBKDF2 iteration count (RFC 7518, Section
405
+ * 4.8.1.2).
397
406
  */
398
407
  p2c?: number
399
408
 
400
409
  /**
401
- * @deprecated You should not use this parameter. It is only intended for testing and vector
402
- * validation purposes.
410
+ * Raw PBES2 Salt Input bytes (RFC 7518, Section 4.8.1.1).
411
+ *
412
+ * @deprecated For testing and vector validation only.
403
413
  */
404
414
  p2s?: Uint8Array
405
415
  /**
406
- * @deprecated You should not use this parameter. It is only intended for testing and vector
407
- * validation purposes.
416
+ * Raw Initialization Vector bytes for AES GCM Key Encryption (RFC 7518, Section 4.7.1.1).
417
+ *
418
+ * @deprecated For testing and vector validation only.
408
419
  */
409
420
  iv?: Uint8Array
410
421
  /**
411
- * @deprecated You should not use this parameter. It is only intended for testing and vector
412
- * validation purposes.
422
+ * Ephemeral private key input. The resulting "epk" (Ephemeral Public Key) Header Parameter
423
+ * contains only the public key (RFC 7518, Section 4.6.1.1).
424
+ *
425
+ * @deprecated For testing and vector validation only.
413
426
  */
414
427
  epk?: CryptoKey | KeyObject
415
428
  }
416
429
 
417
430
  /** Flattened JWE JSON Serialization token. */
418
431
  export interface FlattenedJWE {
419
- /**
420
- * The "aad" member MUST be present and contain the value BASE64URL(JWE AAD)) when the JWE AAD
421
- * value is non-empty; otherwise, it MUST be absent. A JWE AAD value can be included to supply a
422
- * base64url-encoded value to be integrity protected but not encrypted.
423
- */
432
+ /** Base64url-encoded JWE AAD; integrity protected but not encrypted. Omit when empty. */
424
433
  aad?: string
425
434
 
426
- /** The "ciphertext" member MUST be present and contain the value BASE64URL(JWE Ciphertext). */
435
+ /** Base64url-encoded JWE Ciphertext. */
427
436
  ciphertext: string
428
437
 
429
- /**
430
- * The "encrypted_key" member MUST be present and contain the value BASE64URL(JWE Encrypted Key)
431
- * when the JWE Encrypted Key value is non-empty; otherwise, it MUST be absent.
432
- */
438
+ /** Base64url-encoded JWE Encrypted Key. Omit when empty. */
433
439
  encrypted_key?: string
434
440
 
435
441
  /**
436
- * The "header" member MUST be present and contain the value JWE Per- Recipient Unprotected Header
437
- * when the JWE Per-Recipient Unprotected Header value is non-empty; otherwise, it MUST be absent.
438
- * This value is represented as an unencoded JSON object, rather than as a string. These Header
439
- * Parameter values are not integrity protected.
442
+ * JWE Per-Recipient Unprotected Header as a JSON object. Not integrity protected; omit when
443
+ * empty.
440
444
  */
441
445
  header?: JWEHeaderParameters
442
446
 
443
- /**
444
- * The "iv" member MUST be present and contain the value BASE64URL(JWE Initialization Vector) when
445
- * the JWE Initialization Vector value is non-empty; otherwise, it MUST be absent.
446
- */
447
+ /** Base64url-encoded JWE Initialization Vector. Omit when empty. */
447
448
  iv?: string
448
449
 
449
- /**
450
- * The "protected" member MUST be present and contain the value BASE64URL(UTF8(JWE Protected
451
- * Header)) when the JWE Protected Header value is non-empty; otherwise, it MUST be absent. These
452
- * Header Parameter values are integrity protected.
453
- */
450
+ /** Base64url-encoded UTF-8 JWE Protected Header. Integrity protected; omit when empty. */
454
451
  protected?: string
455
452
 
456
- /**
457
- * The "tag" member MUST be present and contain the value BASE64URL(JWE Authentication Tag) when
458
- * the JWE Authentication Tag value is non-empty; otherwise, it MUST be absent.
459
- */
453
+ /** Base64url-encoded JWE Authentication Tag. Omit when empty. */
460
454
  tag?: string
461
455
 
462
- /**
463
- * The "unprotected" member MUST be present and contain the value JWE Shared Unprotected Header
464
- * when the JWE Shared Unprotected Header value is non-empty; otherwise, it MUST be absent. This
465
- * value is represented as an unencoded JSON object, rather than as a string. These Header
466
- * Parameter values are not integrity protected.
467
- */
456
+ /** JWE Shared Unprotected Header as a JSON object. Not integrity protected; omit when empty. */
468
457
  unprotected?: JWEHeaderParameters
469
458
  }
470
459
 
@@ -481,13 +470,16 @@ export interface JWEHeaderParameters extends JoseHeaderParameters {
481
470
  /** JWE "enc" (Encryption Algorithm) Header Parameter */
482
471
  enc?: JWEContentEncryptionAlgorithm
483
472
 
484
- /** JWE "crit" (Critical) Header Parameter */
473
+ /**
474
+ * "crit" (Critical) Header Parameter: names of extensions that must be understood and processed;
475
+ * must be integrity protected (RFC 7516, Section 4.1.13).
476
+ */
485
477
  crit?: string[]
486
478
 
487
479
  /**
488
- * JWE "zip" (Compression Algorithm) Header Parameter. The only supported value is `"DEF"`
489
- * (DEFLATE), and it requires the `CompressionStream` / `DecompressionStream` APIs to be available
490
- * in the runtime.
480
+ * JWE "zip" (Compression Algorithm) Header Parameter; must be integrity protected. Only `"DEF"`
481
+ * (raw DEFLATE) is supported, requiring the runtime's `CompressionStream` / `DecompressionStream`
482
+ * APIs.
491
483
  */
492
484
  zip?: 'DEF' | (string & {})
493
485
 
@@ -498,16 +490,13 @@ export interface JWEHeaderParameters extends JoseHeaderParameters {
498
490
  /** Shared "crit" option for signing, verification, encryption, and decryption. */
499
491
  export interface CritOption {
500
492
  /**
501
- * An object with keys representing recognized "crit" (Critical) Header Parameter names. The value
502
- * for those is either `true` or `false`. `true` when the Header Parameter MUST be integrity
503
- * protected, `false` when it's irrelevant. The JWS extension Header Parameter `b64` is always
504
- * recognized and processed properly; no other registered Header Parameters currently receive this
505
- * built-in treatment.
493
+ * Recognized "crit" (Critical) Header Parameter names. Set each value to `true` to require
494
+ * integrity protection, or `false` when protection is optional. The JWS `b64` extension is always
495
+ * recognized and processed.
506
496
  *
507
- * > Warning: This only checks that the Header Parameter is syntactically correct when provided and,
508
- * > optionally, integrity protected. It does not process the Header Parameter or reject the
509
- * > operation when it is missing. You MUST still verify its presence and process it according to
510
- * > the profile's validation steps after the operation succeeds.
497
+ * > Warning: Other extensions are only checked for syntax and optional integrity protection. Their presence
498
+ * > is not required by this option. You must check their presence and process them according to the
499
+ * > profile's validation steps after the operation succeeds.
511
500
  */
512
501
  crit?: {
513
502
  [propName: string]: boolean
@@ -517,31 +506,27 @@ export interface CritOption {
517
506
  /** JWE Decryption options. */
518
507
  export interface DecryptOptions extends CritOption {
519
508
  /**
520
- * A list of accepted JWE "alg" (Algorithm) Header Parameter values. By default all "alg"
521
- * (Algorithm) Header Parameter values applicable for the used key/secret are allowed except for
522
- * all PBES2 Key Management Algorithms, these need to be explicitly allowed using this option.
509
+ * Accepted JWE "alg" (Algorithm) Header Parameter values. Defaults to all algorithms applicable
510
+ * to the key or secret except PBES2, which must be explicitly allowed.
523
511
  */
524
512
  keyManagementAlgorithms?: JWEKeyManagementAlgorithm[]
525
513
 
526
514
  /**
527
- * A list of accepted JWE "enc" (Encryption Algorithm) Header Parameter values. By default all
528
- * "enc" (Encryption Algorithm) values applicable for the used key/secret are allowed.
515
+ * Accepted JWE "enc" (Encryption Algorithm) Header Parameter values. Defaults to all algorithms
516
+ * applicable to the key or secret.
529
517
  */
530
518
  contentEncryptionAlgorithms?: JWEContentEncryptionAlgorithm[]
531
519
 
532
520
  /**
533
- * (PBES2 Key Management Algorithms only) Maximum allowed "p2c" (PBES2 Count) Header Parameter
534
- * value. The PBKDF2 iteration count defines the algorithm's computational expense. By default
535
- * this value is set to 10000. The value must be a positive safe integer or `Infinity`. Set it to
536
- * `Infinity` to disable the limit.
521
+ * Maximum "p2c" (PBES2 Count) Header Parameter value, limiting PBKDF2 iterations and their
522
+ * computational expense. Defaults to 10000; must be a positive safe integer or `Infinity` to
523
+ * disable the limit.
537
524
  */
538
525
  maxPBES2Count?: number
539
526
 
540
527
  /**
541
- * Maximum allowed size (in bytes) of the decompressed plaintext when the JWE `"zip"` (Compression
542
- * Algorithm) Header Parameter is present. By default this value is set to 250000 (250 KB). The
543
- * value must be `0`, a positive safe integer, or `Infinity`. Set it to `0` to reject all
544
- * compressed JWEs during decryption or to `Infinity` to disable the decompressed size limit.
528
+ * Maximum decompressed plaintext size in bytes. Defaults to 250000; `0` rejects compressed JWEs,
529
+ * and `Infinity` disables the limit. Other values must be positive safe integers.
545
530
  */
546
531
  maxDecompressedLength?: number
547
532
  }
@@ -551,55 +536,38 @@ export interface EncryptOptions extends CritOption {}
551
536
 
552
537
  /** JWT Claims Set verification options. */
553
538
  export interface JWTClaimVerificationOptions {
554
- /**
555
- * Expected JWT "aud" (Audience) Claim value(s). This option makes the JWT "aud" (Audience) Claim
556
- * presence required.
557
- */
539
+ /** Expected JWT "aud" (Audience) Claim value(s). Requires the claim to be present. */
558
540
  audience?: string | string[]
559
541
 
560
542
  /**
561
- * Clock skew tolerance in seconds when a number (e.g. 5), or resolved into seconds when a string
562
- * (e.g. "5 seconds", "10 minutes", "2 hours"). Used when validating the JWT "nbf" (Not Before)
563
- * and "exp" (Expiration Time) claims, and when validating the "iat" (Issued At) claim if the
564
- * {@link maxTokenAge `maxTokenAge` option} is set.
543
+ * Clock skew tolerance in seconds or a duration string (e.g. "5 seconds"). Applies to the "nbf"
544
+ * (Not Before) and "exp" (Expiration Time) claims, and to "iat" (Issued At) when
545
+ * {@link maxTokenAge} is set.
565
546
  */
566
547
  clockTolerance?: string | number
567
548
 
568
- /**
569
- * Expected JWT "iss" (Issuer) Claim value(s). This option makes the JWT "iss" (Issuer) Claim
570
- * presence required.
571
- */
549
+ /** Expected JWT "iss" (Issuer) Claim value(s). Requires the claim to be present. */
572
550
  issuer?: string | string[]
573
551
 
574
552
  /**
575
- * Maximum time elapsed from the JWT "iat" (Issued At) Claim value, in seconds when a number (e.g.
576
- * 5), or resolved into seconds when a string (e.g. "5 seconds", "10 minutes", "2 hours"). This
577
- * option makes the JWT "iat" (Issued At) Claim presence required.
553
+ * Maximum time since the JWT "iat" (Issued At) Claim, in seconds or a duration string (e.g. "2
554
+ * hours"). Requires the claim to be present.
578
555
  */
579
556
  maxTokenAge?: string | number
580
557
 
581
- /**
582
- * Expected JWT "sub" (Subject) Claim value. This option makes the JWT "sub" (Subject) Claim
583
- * presence required.
584
- */
558
+ /** Expected JWT "sub" (Subject) Claim value. Requires the claim to be present. */
585
559
  subject?: string
586
560
 
587
- /**
588
- * Expected JWT "typ" (Type) Header Parameter value. This option makes the JWT "typ" (Type) Header
589
- * Parameter presence required.
590
- */
561
+ /** Expected JWT "typ" (Type) Header Parameter value. Requires the parameter to be present. */
591
562
  typ?: string
592
563
 
593
- /** Date to use when comparing NumericDate claims, defaults to `new Date()`. */
564
+ /** Date for NumericDate comparisons. Defaults to `new Date()`. */
594
565
  currentDate?: Date
595
566
 
596
567
  /**
597
- * Array of required Claim Names that must be present in the JWT Claims Set. Default is that: if
598
- * the {@link issuer `issuer` option} is set, then JWT "iss" (Issuer) Claim must be present; if the
599
- * {@link audience `audience` option} is set, then JWT "aud" (Audience) Claim must be present; if
600
- * the {@link subject `subject` option} is set, then JWT "sub" (Subject) Claim must be present; if
601
- * the {@link maxTokenAge `maxTokenAge` option} is set, then JWT "iat" (Issued At) Claim must be
602
- * present.
568
+ * Additional claim names required in the JWT Claims Set. The {@link issuer}, {@link audience},
569
+ * {@link subject}, and {@link maxTokenAge} options independently require "iss", "aud", "sub", and
570
+ * "iat", respectively.
603
571
  */
604
572
  requiredClaims?: string[]
605
573
  }
@@ -607,10 +575,8 @@ export interface JWTClaimVerificationOptions {
607
575
  /** JWS Verification options. */
608
576
  export interface VerifyOptions extends CritOption {
609
577
  /**
610
- * A list of accepted JWS "alg" (Algorithm) Header Parameter values. By default all "alg"
611
- * (Algorithm) values applicable for the used key/secret are allowed.
612
- *
613
- * > Note: Unsecured JWTs (`{ "alg": "none" }`) are never accepted by this API.
578
+ * Accepted JWS "alg" (Algorithm) Header Parameter values. Defaults to all algorithms applicable
579
+ * to the key or secret. Unsecured JWTs (`alg: "none"`) are never accepted.
614
580
  */
615
581
  algorithms?: JWSAlgorithm[]
616
582
  }
@@ -620,34 +586,34 @@ export interface SignOptions extends CritOption {}
620
586
 
621
587
  /** Recognized JWT Claims Set members; additional members may also be present. */
622
588
  export interface JWTPayload {
623
- /** JWT Issuer */
589
+ /** "iss" (Issuer) Claim. */
624
590
  iss?: string
625
591
 
626
- /** JWT Subject */
592
+ /** "sub" (Subject) Claim. */
627
593
  sub?: string
628
594
 
629
- /** JWT Audience */
595
+ /** "aud" (Audience) Claim. */
630
596
  aud?: string | string[]
631
597
 
632
- /** JWT ID */
598
+ /** "jti" (JWT ID) Claim. */
633
599
  jti?: string
634
600
 
635
- /** JWT Not Before */
601
+ /** "nbf" (Not Before) Claim, expressed as a NumericDate (seconds since the Unix epoch). */
636
602
  nbf?: number
637
603
 
638
- /** JWT Expiration Time */
604
+ /** "exp" (Expiration Time) Claim, expressed as a NumericDate (seconds since the Unix epoch). */
639
605
  exp?: number
640
606
 
641
- /** JWT Issued At */
607
+ /** "iat" (Issued At) Claim, expressed as a NumericDate (seconds since the Unix epoch). */
642
608
  iat?: number
643
609
 
644
- /** Any other JWT Claim Set member. */
610
+ /** Any other JWT Claims Set member. */
645
611
  [propName: string]: unknown
646
612
  }
647
613
 
648
614
  /** Flattened JWE JSON Serialization decryption result. */
649
615
  export interface FlattenedDecryptResult {
650
- /** JWE AAD. */
616
+ /** Decoded JWE AAD bytes, integrity protected but not encrypted. */
651
617
  additionalAuthenticatedData?: Uint8Array
652
618
 
653
619
  /** Plaintext. */
@@ -656,17 +622,17 @@ export interface FlattenedDecryptResult {
656
622
  /** JWE Protected Header. */
657
623
  protectedHeader?: JWEHeaderParameters
658
624
 
659
- /** JWE Shared Unprotected Header. */
625
+ /** JWE Shared Unprotected Header. Not integrity protected. */
660
626
  sharedUnprotectedHeader?: JWEHeaderParameters
661
627
 
662
- /** JWE Per-Recipient Unprotected Header. */
628
+ /** JWE Per-Recipient Unprotected Header. Not integrity protected. */
663
629
  unprotectedHeader?: JWEHeaderParameters
664
630
  }
665
631
 
666
632
  /** General JWE JSON Serialization decryption result. */
667
633
  export interface GeneralDecryptResult extends FlattenedDecryptResult {}
668
634
 
669
- /** Compact JWE decryption result. */
635
+ /** JWE Compact Serialization decryption result. */
670
636
  export interface CompactDecryptResult {
671
637
  /** Plaintext. */
672
638
  plaintext: Uint8Array
@@ -683,14 +649,14 @@ export interface FlattenedVerifyResult {
683
649
  /** JWS Protected Header. */
684
650
  protectedHeader?: JWSHeaderParameters
685
651
 
686
- /** JWS Unprotected Header. */
652
+ /** JWS Unprotected Header. Not integrity protected. */
687
653
  unprotectedHeader?: JWSHeaderParameters
688
654
  }
689
655
 
690
656
  /** General JWS JSON Serialization verification result. */
691
657
  export interface GeneralVerifyResult extends FlattenedVerifyResult {}
692
658
 
693
- /** Compact JWS verification result. */
659
+ /** JWS Compact Serialization verification result. */
694
660
  export interface CompactVerifyResult {
695
661
  /** JWS Payload. */
696
662
  payload: Uint8Array
@@ -699,7 +665,7 @@ export interface CompactVerifyResult {
699
665
  protectedHeader: CompactJWSHeaderParameters
700
666
  }
701
667
 
702
- /** Signed JSON Web Token (JWT) verification result. */
668
+ /** Signed or MACed JSON Web Token (JWT) verification result. */
703
669
  export interface JWTVerifyResult<PayloadType = JWTPayload> {
704
670
  /** JWT Claims Set. */
705
671
  payload: PayloadType &
@@ -723,21 +689,21 @@ export interface JWTDecryptResult<PayloadType = JWTPayload> {
723
689
 
724
690
  /** Key resolver result metadata. */
725
691
  export interface ResolvedKey<KeyType extends CryptoKey | Uint8Array = CryptoKey | Uint8Array> {
726
- /** Key resolved from the key resolver function. */
692
+ /** The resolved key, present only when a key resolver is used. */
727
693
  key: KeyType
728
694
  }
729
695
 
730
- /** Recognized Compact JWS Header Parameters; additional members may also be present. */
696
+ /** Recognized JWS Compact Serialization Header Parameters; additional members may also be present. */
731
697
  export interface CompactJWSHeaderParameters extends JWSHeaderParameters {
732
698
  alg: JWSAlgorithm
733
699
  }
734
700
 
735
- /** Recognized signed JWT Header Parameters; additional members may also be present. */
701
+ /** Recognized JWT Header Parameters for JWS; additional members may also be present. */
736
702
  export interface JWTHeaderParameters extends CompactJWSHeaderParameters {
737
703
  b64?: boolean
738
704
  }
739
705
 
740
- /** Recognized Compact JWE Header Parameters; additional members may also be present. */
706
+ /** Recognized JWE Compact Serialization Header Parameters; additional members may also be present. */
741
707
  export interface CompactJWEHeaderParameters extends JWEHeaderParameters {
742
708
  alg: JWEKeyManagementAlgorithm
743
709
  enc: JWEContentEncryptionAlgorithm
@@ -745,6 +711,7 @@ export interface CompactJWEHeaderParameters extends JWEHeaderParameters {
745
711
 
746
712
  /** JSON Web Key Set. */
747
713
  export interface JSONWebKeySet {
714
+ /** "keys" Parameter: an array of JWKs (RFC 7517, Section 5.1). */
748
715
  keys: JWK[]
749
716
  }
750
717
 
@@ -753,14 +720,14 @@ export interface KeyObject {
753
720
  type: string
754
721
  }
755
722
 
756
- /** Web Cryptography API {@link !CryptoKey} representation accepted as key input. */
723
+ /** The runtime's Web Crypto {@link !CryptoKey} representation accepted as key input. */
757
724
  export type CryptoKey = typeof globalThis extends {
758
725
  crypto: { subtle: { generateKey(...args: any[]): Promise<infer R> } }
759
726
  }
760
727
  ? Extract<R, { type: string }>
761
728
  : CryptoKeyStructuralFallback
762
729
 
763
- /** Structural fallback used when a host {@link !CryptoKey} type cannot be inferred. */
730
+ /** Structural fallback used when the host {@link !CryptoKey} type cannot be inferred. */
764
731
  export interface CryptoKeyStructuralFallback {
765
732
  readonly algorithm: { name: string }
766
733
  readonly extractable: boolean
@@ -771,61 +738,57 @@ export interface CryptoKeyStructuralFallback {
771
738
  /** Shared fluent API for JWT-producing classes. */
772
739
  export interface ProduceJWT {
773
740
  /**
774
- * Set the "iss" (Issuer) Claim.
741
+ * Set the "iss" (Issuer) Claim (RFC 7519, Section 4.1.1).
775
742
  *
776
743
  * @param issuer "Issuer" Claim value to set on the JWT Claims Set.
777
744
  */
778
745
  setIssuer(issuer: string): this
779
746
 
780
747
  /**
781
- * Set the "sub" (Subject) Claim.
748
+ * Set the "sub" (Subject) Claim (RFC 7519, Section 4.1.2).
782
749
  *
783
750
  * @param subject "sub" (Subject) Claim value to set on the JWT Claims Set.
784
751
  */
785
752
  setSubject(subject: string): this
786
753
 
787
754
  /**
788
- * Set the "aud" (Audience) Claim.
755
+ * Set the "aud" (Audience) Claim (RFC 7519, Section 4.1.3).
789
756
  *
790
757
  * @param audience "aud" (Audience) Claim value to set on the JWT Claims Set.
791
758
  */
792
759
  setAudience(audience: string | string[]): this
793
760
 
794
761
  /**
795
- * Set the "jti" (JWT ID) Claim.
762
+ * Set the "jti" (JWT ID) Claim (RFC 7519, Section 4.1.7).
796
763
  *
797
764
  * @param jwtId "jti" (JWT ID) Claim value to set on the JWT Claims Set.
798
765
  */
799
766
  setJti(jwtId: string): this
800
767
 
801
768
  /**
802
- * Set the "nbf" (Not Before) Claim. A `number` is used directly, a `Date` is converted to a Unix
803
- * timestamp, and a `string` is parsed as a time span relative to the current Unix timestamp.
804
- * String units may be seconds, minutes, hours, days, weeks, or years; months are unsupported and
805
- * a year is 365.25 days. A leading `-` or trailing `"ago"` subtracts the time span.
769
+ * Set the "nbf" (Not Before) Claim. Numbers are NumericDate values (seconds since the Unix
770
+ * epoch); Dates are converted to seconds. Strings are relative to now, using seconds, minutes,
771
+ * hours, days, weeks, or years (365.25 days; no months). Prefix `-` or suffix `ago` subtracts the
772
+ * duration.
806
773
  *
807
- * @param input "nbf" (Not Before) Claim value to set on the JWT Claims Set.
774
+ * @param input "nbf" (Not Before) Claim value as a timestamp, Date, or relative duration.
808
775
  */
809
776
  setNotBefore(input: number | string | Date): this
810
777
 
811
778
  /**
812
- * Set the "exp" (Expiration Time) Claim. A `number` is used directly, a `Date` is converted to a
813
- * Unix timestamp, and a `string` is parsed as a time span relative to the current Unix timestamp.
814
- * String units may be seconds, minutes, hours, days, weeks, or years; months are unsupported and
815
- * a year is 365.25 days. A leading `-` or trailing `"ago"` subtracts the time span.
779
+ * Set the "exp" (Expiration Time) Claim. Accepts a NumericDate value (seconds since the Unix
780
+ * epoch), a Date, or a duration relative to now using the same formats as {@link setNotBefore}.
816
781
  *
817
- * @param input "exp" (Expiration Time) Claim value to set on the JWT Claims Set.
782
+ * @param input "exp" (Expiration Time) Claim value as a timestamp, Date, or relative duration.
818
783
  */
819
784
  setExpirationTime(input: number | string | Date): this
820
785
 
821
786
  /**
822
- * Set the "iat" (Issued At) Claim. With no argument the current Unix timestamp is used. A
823
- * `number` is used directly, a `Date` is converted to a Unix timestamp, and a `string` is parsed
824
- * as a time span relative to the current Unix timestamp. String units may be seconds, minutes,
825
- * hours, days, weeks, or years; months are unsupported and a year is 365.25 days. A leading `-`
826
- * or trailing `"ago"` subtracts the time span.
787
+ * Set the "iat" (Issued At) Claim. Defaults to the current Unix timestamp in seconds. Accepts a
788
+ * Unix timestamp in seconds, a Date, or a duration relative to now using the same formats as
789
+ * {@link setNotBefore}.
827
790
  *
828
- * @param input "iat" (Issued At) Claim value to set on the JWT Claims Set.
791
+ * @param input "iat" (Issued At) Claim value as a timestamp, Date, or relative duration.
829
792
  */
830
793
  setIssuedAt(input?: number | string | Date): this
831
794
  }