jose 4.8.1 → 4.9.1

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 (57) hide show
  1. package/README.md +7 -6
  2. package/dist/browser/index.js +1 -1
  3. package/dist/browser/jwe/flattened/decrypt.js +1 -1
  4. package/dist/browser/jwk/thumbprint.js +7 -1
  5. package/dist/browser/jws/flattened/verify.js +1 -1
  6. package/dist/browser/lib/crypto_key.js +1 -6
  7. package/dist/browser/runtime/asn1.js +3 -5
  8. package/dist/browser/runtime/env.js +0 -8
  9. package/dist/browser/runtime/generate.js +3 -7
  10. package/dist/browser/runtime/jwk_to_key.js +2 -6
  11. package/dist/browser/runtime/subtle_dsa.js +2 -2
  12. package/dist/node/cjs/index.js +2 -1
  13. package/dist/node/cjs/jwe/flattened/decrypt.js +1 -1
  14. package/dist/node/cjs/jwk/thumbprint.js +9 -2
  15. package/dist/node/cjs/jws/flattened/verify.js +1 -1
  16. package/dist/node/cjs/lib/crypto_key.js +0 -5
  17. package/dist/node/cjs/runtime/env.js +1 -5
  18. package/dist/node/cjs/runtime/key_to_jwk.js +4 -0
  19. package/dist/node/esm/index.js +1 -1
  20. package/dist/node/esm/jwe/flattened/decrypt.js +1 -1
  21. package/dist/node/esm/jwk/thumbprint.js +7 -1
  22. package/dist/node/esm/jws/flattened/verify.js +1 -1
  23. package/dist/node/esm/lib/crypto_key.js +1 -6
  24. package/dist/node/esm/runtime/env.js +0 -3
  25. package/dist/node/esm/runtime/key_to_jwk.js +4 -0
  26. package/dist/types/index.d.ts +1 -1
  27. package/dist/types/jwe/compact/decrypt.d.ts +9 -7
  28. package/dist/types/jwe/compact/encrypt.d.ts +14 -20
  29. package/dist/types/jwe/flattened/decrypt.d.ts +12 -13
  30. package/dist/types/jwe/flattened/encrypt.d.ts +17 -26
  31. package/dist/types/jwe/general/decrypt.d.ts +13 -14
  32. package/dist/types/jwe/general/encrypt.d.ts +6 -15
  33. package/dist/types/jwk/embedded.d.ts +8 -7
  34. package/dist/types/jwk/thumbprint.d.ts +30 -7
  35. package/dist/types/jwks/local.d.ts +12 -15
  36. package/dist/types/jwks/remote.d.ts +22 -36
  37. package/dist/types/jws/compact/sign.d.ts +3 -6
  38. package/dist/types/jws/compact/verify.d.ts +11 -8
  39. package/dist/types/jws/flattened/sign.d.ts +3 -6
  40. package/dist/types/jws/flattened/verify.d.ts +12 -9
  41. package/dist/types/jws/general/sign.d.ts +7 -18
  42. package/dist/types/jws/general/verify.d.ts +14 -11
  43. package/dist/types/jwt/decrypt.d.ts +13 -12
  44. package/dist/types/jwt/encrypt.d.ts +15 -18
  45. package/dist/types/jwt/produce.d.ts +9 -14
  46. package/dist/types/jwt/sign.d.ts +2 -2
  47. package/dist/types/jwt/unsecured.d.ts +4 -4
  48. package/dist/types/jwt/verify.d.ts +15 -13
  49. package/dist/types/key/export.d.ts +13 -8
  50. package/dist/types/key/generate_key_pair.d.ts +14 -19
  51. package/dist/types/key/generate_secret.d.ts +3 -2
  52. package/dist/types/key/import.d.ts +50 -39
  53. package/dist/types/types.d.ts +196 -371
  54. package/dist/types/util/decode_jwt.d.ts +7 -6
  55. package/dist/types/util/decode_protected_header.d.ts +3 -2
  56. package/dist/types/util/errors.d.ts +20 -61
  57. package/package.json +4 -2
@@ -1,18 +1,14 @@
1
1
  import type { KeyLike, FlattenedJWE, JWEHeaderParameters, JWEKeyManagementHeaderParameters, EncryptOptions } from '../../types';
2
- /**
3
- * @private
4
- */
2
+ /** @private */
5
3
  export declare const unprotected: unique symbol;
6
4
  /**
7
- * The FlattenedEncrypt class is a utility for creating Flattened JWE
8
- * objects.
5
+ * The FlattenedEncrypt class is a utility for creating Flattened JWE objects.
9
6
  *
10
7
  * @example Usage
8
+ *
11
9
  * ```js
12
10
  * const jwe = await new jose.FlattenedEncrypt(
13
- * new TextEncoder().encode(
14
- * 'It’s a dangerous business, Frodo, going out your door.'
15
- * )
11
+ * new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
16
12
  * )
17
13
  * .setProtectedHeader({ alg: 'RSA-OAEP-256', enc: 'A256GCM' })
18
14
  * .setAdditionalAuthenticatedData(encoder.encode('The Fellowship of the Ring'))
@@ -30,15 +26,13 @@ export declare class FlattenedEncrypt {
30
26
  private _cek;
31
27
  private _iv;
32
28
  private _keyManagementParameters;
33
- /**
34
- * @param plaintext Binary representation of the plaintext to encrypt.
35
- */
29
+ /** @param plaintext Binary representation of the plaintext to encrypt. */
36
30
  constructor(plaintext: Uint8Array);
37
31
  /**
38
- * Sets the JWE Key Management parameters to be used when encrypting.
39
- * Use of this is method is really only needed for ECDH based algorithms
40
- * when utilizing the Agreement PartyUInfo or Agreement PartyVInfo parameters.
41
- * Other parameters will always be randomly generated when needed and missing.
32
+ * Sets the JWE Key Management parameters to be used when encrypting. Use of this is method is
33
+ * really only needed for ECDH based algorithms when utilizing the Agreement PartyUInfo or
34
+ * Agreement PartyVInfo parameters. Other parameters will always be randomly generated when needed
35
+ * and missing.
42
36
  *
43
37
  * @param parameters JWE Key Management parameters.
44
38
  */
@@ -68,24 +62,21 @@ export declare class FlattenedEncrypt {
68
62
  */
69
63
  setAdditionalAuthenticatedData(aad: Uint8Array): this;
70
64
  /**
71
- * Sets a content encryption key to use, by default a random suitable one
72
- * is generated for the JWE enc" (Encryption Algorithm) Header Parameter.
65
+ * Sets a content encryption key to use, by default a random suitable one is generated for the JWE
66
+ * enc" (Encryption Algorithm) Header Parameter.
73
67
  *
68
+ * @deprecated You should not use this method. It is only really intended for test and vector
69
+ * validation purposes.
74
70
  * @param cek JWE Content Encryption Key.
75
- *
76
- * @deprecated You should not use this method. It is only really intended
77
- * for test and vector validation purposes.
78
71
  */
79
72
  setContentEncryptionKey(cek: Uint8Array): this;
80
73
  /**
81
- * Sets the JWE Initialization Vector to use for content encryption, by default
82
- * a random suitable one is generated for the JWE enc" (Encryption Algorithm)
83
- * Header Parameter.
74
+ * Sets the JWE Initialization Vector to use for content encryption, by default a random suitable
75
+ * one is generated for the JWE enc" (Encryption Algorithm) Header Parameter.
84
76
  *
77
+ * @deprecated You should not use this method. It is only really intended for test and vector
78
+ * validation purposes.
85
79
  * @param iv JWE Initialization Vector.
86
- *
87
- * @deprecated You should not use this method. It is only really intended
88
- * for test and vector validation purposes.
89
80
  */
90
81
  setInitializationVector(iv: Uint8Array): this;
91
82
  /**
@@ -1,18 +1,15 @@
1
1
  import type { KeyLike, DecryptOptions, JWEHeaderParameters, GetKeyFunction, FlattenedJWE, GeneralJWE, GeneralDecryptResult, ResolvedKey } from '../../types';
2
2
  /**
3
- * Interface for General JWE Decryption dynamic key resolution.
4
- * No token components have been verified at the time of this function call.
3
+ * Interface for General JWE Decryption dynamic key resolution. No token components have been
4
+ * verified at the time of this function call.
5
5
  */
6
6
  export interface GeneralDecryptGetKey extends GetKeyFunction<JWEHeaderParameters, FlattenedJWE> {
7
7
  }
8
8
  /**
9
9
  * Decrypts a General JWE.
10
10
  *
11
- * @param jwe General JWE.
12
- * @param key Private Key or Secret to decrypt the JWE with.
13
- * @param options JWE Decryption options.
14
- *
15
11
  * @example Usage
12
+ *
16
13
  * ```js
17
14
  * const jwe = {
18
15
  * ciphertext: '9EzjFISUyoG-ifC2mSihfP0DPC80yeyrxhTzKt1C_VJBkxeBG0MI4Te61Pk45RAGubUvBpU9jm4',
@@ -22,22 +19,24 @@ export interface GeneralDecryptGetKey extends GetKeyFunction<JWEHeaderParameters
22
19
  * protected: 'eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0',
23
20
  * recipients: [
24
21
  * {
25
- * encrypted_key: 'Z6eD4UK_yFb5ZoKvKkGAdqywEG_m0e4IYo0x8Vf30LAMJcsc-_zSgIeiF82teZyYi2YYduHKoqImk7MRnoPZOlEs0Q5BNK1OgBmSOhCE8DFyqh9Zh48TCTP6lmBQ52naqoUJFMtHzu-0LwZH26hxos0GP3Dt19O379MJB837TdKKa87skq0zHaVLAquRHOBF77GI54Bc7O49d8aOrSu1VEFGMThlW2caspPRiTSePDMDPq7_WGk50izRhB3Asl9wmP9wEeaTrkJKRnQj5ips1SAZ1hDBsqEQKKukxP1HtdcopHV5_qgwU8Hjm5EwSLMluMQuiE6hwlkXGOujZLVizA'
26
- * }
27
- * ]
22
+ * encrypted_key:
23
+ * 'Z6eD4UK_yFb5ZoKvKkGAdqywEG_m0e4IYo0x8Vf30LAMJcsc-_zSgIeiF82teZyYi2YYduHKoqImk7MRnoPZOlEs0Q5BNK1OgBmSOhCE8DFyqh9Zh48TCTP6lmBQ52naqoUJFMtHzu-0LwZH26hxos0GP3Dt19O379MJB837TdKKa87skq0zHaVLAquRHOBF77GI54Bc7O49d8aOrSu1VEFGMThlW2caspPRiTSePDMDPq7_WGk50izRhB3Asl9wmP9wEeaTrkJKRnQj5ips1SAZ1hDBsqEQKKukxP1HtdcopHV5_qgwU8Hjm5EwSLMluMQuiE6hwlkXGOujZLVizA',
24
+ * },
25
+ * ],
28
26
  * }
29
27
  *
30
- * const {
31
- * plaintext,
32
- * protectedHeader,
33
- * additionalAuthenticatedData
34
- * } = await jose.generalDecrypt(jwe, privateKey)
28
+ * const { plaintext, protectedHeader, additionalAuthenticatedData } =
29
+ * await jose.generalDecrypt(jwe, privateKey)
35
30
  *
36
31
  * console.log(protectedHeader)
37
32
  * const decoder = new TextDecoder()
38
33
  * console.log(decoder.decode(plaintext))
39
34
  * console.log(decoder.decode(additionalAuthenticatedData))
40
35
  * ```
36
+ *
37
+ * @param jwe General JWE.
38
+ * @param key Private Key or Secret to decrypt the JWE with.
39
+ * @param options JWE Decryption options.
41
40
  */
42
41
  export declare function generalDecrypt(jwe: GeneralJWE, key: KeyLike | Uint8Array, options?: DecryptOptions): Promise<GeneralDecryptResult>;
43
42
  /**
@@ -6,28 +6,21 @@ export interface Recipient {
6
6
  * @param unprotectedHeader JWE Per-Recipient Unprotected Header.
7
7
  */
8
8
  setUnprotectedHeader(unprotectedHeader: JWEHeaderParameters): Recipient;
9
- /**
10
- * A shorthand for calling addRecipient() on the enclosing GeneralEncrypt instance
11
- */
9
+ /** A shorthand for calling addRecipient() on the enclosing GeneralEncrypt instance */
12
10
  addRecipient(...args: Parameters<GeneralEncrypt['addRecipient']>): Recipient;
13
- /**
14
- * A shorthand for calling encrypt() on the enclosing GeneralEncrypt instance
15
- */
11
+ /** A shorthand for calling encrypt() on the enclosing GeneralEncrypt instance */
16
12
  encrypt(...args: Parameters<GeneralEncrypt['encrypt']>): Promise<GeneralJWE>;
17
- /**
18
- * Returns the enclosing GeneralEncrypt
19
- */
13
+ /** Returns the enclosing GeneralEncrypt */
20
14
  done(): GeneralEncrypt;
21
15
  }
22
16
  /**
23
17
  * The GeneralEncrypt class is a utility for creating General JWE objects.
24
18
  *
25
19
  * @example Usage
20
+ *
26
21
  * ```js
27
22
  * const jwe = await new jose.GeneralEncrypt(
28
- * new TextEncoder().encode(
29
- * 'It’s a dangerous business, Frodo, going out your door.'
30
- * )
23
+ * new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
31
24
  * )
32
25
  * .setProtectedHeader({ enc: 'A256GCM' })
33
26
  * .addRecipient(ecPublicKey)
@@ -45,9 +38,7 @@ export declare class GeneralEncrypt {
45
38
  private _protectedHeader;
46
39
  private _unprotectedHeader;
47
40
  private _aad;
48
- /**
49
- * @param plaintext Binary representation of the plaintext to encrypt.
50
- */
41
+ /** @param plaintext Binary representation of the plaintext to encrypt. */
51
42
  constructor(plaintext: Uint8Array);
52
43
  /**
53
44
  * Adds an additional recipient for the General JWE object.
@@ -1,18 +1,19 @@
1
1
  import type { FlattenedJWSInput, JWSHeaderParameters } from '../types';
2
2
  /**
3
- * EmbeddedJWK is an implementation of a GetKeyFunction intended to be used with the
4
- * JWS/JWT verify operations whenever you need to opt-in to verify signatures with
5
- * a public key embedded in the token's "jwk" (JSON Web Key) Header Parameter.
6
- * It is recommended to combine this with the verify algorithms option to whitelist
7
- * JWS algorithms to accept.
3
+ * EmbeddedJWK is an implementation of a GetKeyFunction intended to be used with the JWS/JWT verify
4
+ * operations whenever you need to opt-in to verify signatures with a public key embedded in the
5
+ * token's "jwk" (JSON Web Key) Header Parameter. It is recommended to combine this with the verify
6
+ * algorithms option to whitelist JWS algorithms to accept.
8
7
  *
9
8
  * @example Usage
9
+ *
10
10
  * ```js
11
- * const jwt = 'eyJqd2siOnsiY3J2IjoiUC0yNTYiLCJ4IjoiVU05ZzVuS25aWFlvdldBbE03NmNMejl2VG96UmpfX0NIVV9kT2wtZ09vRSIsInkiOiJkczhhZVF3MWwyY0RDQTdiQ2tPTnZ3REtwWEFidFhqdnFDbGVZSDhXc19VIiwia3R5IjoiRUMifSwiYWxnIjoiRVMyNTYifQ.eyJpc3MiOiJ1cm46ZXhhbXBsZTppc3N1ZXIiLCJhdWQiOiJ1cm46ZXhhbXBsZTphdWRpZW5jZSIsImlhdCI6MTYwNDU4MDc5NH0.60boak3_dErnW47ZPty1C0nrjeVq86EN_eK0GOq6K8w2OA0thKoBxFK4j-NuU9yZ_A9UKGxPT_G87DladBaV9g'
11
+ * const jwt =
12
+ * 'eyJqd2siOnsiY3J2IjoiUC0yNTYiLCJ4IjoiVU05ZzVuS25aWFlvdldBbE03NmNMejl2VG96UmpfX0NIVV9kT2wtZ09vRSIsInkiOiJkczhhZVF3MWwyY0RDQTdiQ2tPTnZ3REtwWEFidFhqdnFDbGVZSDhXc19VIiwia3R5IjoiRUMifSwiYWxnIjoiRVMyNTYifQ.eyJpc3MiOiJ1cm46ZXhhbXBsZTppc3N1ZXIiLCJhdWQiOiJ1cm46ZXhhbXBsZTphdWRpZW5jZSIsImlhdCI6MTYwNDU4MDc5NH0.60boak3_dErnW47ZPty1C0nrjeVq86EN_eK0GOq6K8w2OA0thKoBxFK4j-NuU9yZ_A9UKGxPT_G87DladBaV9g'
12
13
  *
13
14
  * const { payload, protectedHeader } = await jose.jwtVerify(jwt, jose.EmbeddedJWK, {
14
15
  * issuer: 'urn:example:issuer',
15
- * audience: 'urn:example:audience'
16
+ * audience: 'urn:example:audience',
16
17
  * })
17
18
  *
18
19
  * console.log(protectedHeader)
@@ -3,19 +3,42 @@ import type { JWK } from '../types';
3
3
  * Calculates a base64url-encoded JSON Web Key (JWK) Thumbprint as per
4
4
  * [RFC7638](https://www.rfc-editor.org/rfc/rfc7638).
5
5
  *
6
- * @param jwk JSON Web Key.
7
- * @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint.
8
- * Default is sha256. Accepted is "sha256", "sha384", "sha512".
9
- *
10
6
  * @example Usage
7
+ *
11
8
  * ```js
12
9
  * const thumbprint = await jose.calculateJwkThumbprint({
13
- * kty: 'RSA',
14
- * e: 'AQAB',
15
- * n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoMjFbvOtgyts55fXKdMWv7I9HMD5HwE9uW839PWA514qhbcIsXEYSFMPMV6fnlsiZvQQ'
10
+ * kty: 'EC',
11
+ * crv: 'P-256',
12
+ * x: 'jJ6Flys3zK9jUhnOHf6G49Dyp5hah6CNP84-gY-n9eo',
13
+ * y: 'nhI6iD5eFXgBTLt_1p3aip-5VbZeMhxeFSpjfEAf7Ww',
16
14
  * })
17
15
  *
18
16
  * console.log(thumbprint)
17
+ * // 'w9eYdC6_s_tLQ8lH6PUpc0mddazaqtPgeC2IgWDiqY8'
19
18
  * ```
19
+ *
20
+ * @param jwk JSON Web Key.
21
+ * @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is "sha256".
20
22
  */
21
23
  export declare function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
24
+ /**
25
+ * Calculates a JSON Web Key (JWK) Thumbprint URI as per [RFC9278](https://www.rfc-editor.org/rfc/rfc9278).
26
+ *
27
+ * @example Usage
28
+ *
29
+ * ```js
30
+ * const thumbprintUri = await jose.calculateJwkThumbprintUri({
31
+ * kty: 'EC',
32
+ * crv: 'P-256',
33
+ * x: 'jJ6Flys3zK9jUhnOHf6G49Dyp5hah6CNP84-gY-n9eo',
34
+ * y: 'nhI6iD5eFXgBTLt_1p3aip-5VbZeMhxeFSpjfEAf7Ww',
35
+ * })
36
+ *
37
+ * console.log(thumbprint)
38
+ * // 'urn:ietf:params:oauth:jwk-thumbprint:sha-256:w9eYdC6_s_tLQ8lH6PUpc0mddazaqtPgeC2IgWDiqY8'
39
+ * ```
40
+ *
41
+ * @param jwk JSON Web Key.
42
+ * @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is "sha256".
43
+ */
44
+ export declare function calculateJwkThumbprintUri(jwk: JWK, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
@@ -1,11 +1,7 @@
1
1
  import type { KeyLike, JWSHeaderParameters, JSONWebKeySet, FlattenedJWSInput, GetKeyFunction } from '../types';
2
- /**
3
- * @private
4
- */
2
+ /** @private */
5
3
  export declare function isJWKSLike(jwks: unknown): jwks is JSONWebKeySet;
6
- /**
7
- * @private
8
- */
4
+ /** @private */
9
5
  export declare class LocalJWKSet {
10
6
  protected _jwks?: JSONWebKeySet;
11
7
  private _cached;
@@ -13,14 +9,13 @@ export declare class LocalJWKSet {
13
9
  getKey(protectedHeader: JWSHeaderParameters, token: FlattenedJWSInput): Promise<KeyLike>;
14
10
  }
15
11
  /**
16
- * Returns a function that resolves to a key object from a locally
17
- * stored, or otherwise available, JSON Web Key Set.
12
+ * Returns a function that resolves to a key object from a locally stored, or otherwise available,
13
+ * JSON Web Key Set.
18
14
  *
19
15
  * Only a single public key must match the selection process.
20
16
  *
21
- * @param jwks JSON Web Key Set formatted object.
22
- *
23
17
  * @example Usage
18
+ *
24
19
  * ```js
25
20
  * const JWKS = jose.createLocalJWKSet({
26
21
  * keys: [
@@ -28,24 +23,26 @@ export declare class LocalJWKSet {
28
23
  * kty: 'RSA',
29
24
  * e: 'AQAB',
30
25
  * n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoMjFbvOtgyts55fXKdMWv7I9HMD5HwE9uW839PWA514qhbcIsXEYSFMPMV6fnlsiZvQQ',
31
- * alg: 'PS256'
26
+ * alg: 'PS256',
32
27
  * },
33
28
  * {
34
29
  * crv: 'P-256',
35
30
  * kty: 'EC',
36
31
  * x: 'ySK38C1jBdLwDsNWKzzBHqKYEE5Cgv-qjWvorUXk9fw',
37
32
  * y: '_LeQBw07cf5t57Iavn4j-BqJsAD1dpoz8gokd3sBsOo',
38
- * alg: 'ES256'
39
- * }
40
- * ]
33
+ * alg: 'ES256',
34
+ * },
35
+ * ],
41
36
  * })
42
37
  *
43
38
  * const { payload, protectedHeader } = await jose.jwtVerify(jwt, JWKS, {
44
39
  * issuer: 'urn:example:issuer',
45
- * audience: 'urn:example:audience'
40
+ * audience: 'urn:example:audience',
46
41
  * })
47
42
  * console.log(protectedHeader)
48
43
  * console.log(payload)
49
44
  * ```
45
+ *
46
+ * @param jwks JSON Web Key Set formatted object.
50
47
  */
51
48
  export declare function createLocalJWKSet(jwks: JSONWebKeySet): GetKeyFunction<JWSHeaderParameters, FlattenedJWSInput>;
@@ -1,68 +1,54 @@
1
1
  import type { JWSHeaderParameters, FlattenedJWSInput, GetKeyFunction } from '../types';
2
- /**
3
- * Options for the remote JSON Web Key Set.
4
- */
2
+ /** Options for the remote JSON Web Key Set. */
5
3
  export interface RemoteJWKSetOptions {
6
4
  /**
7
- * Timeout (in milliseconds) for the HTTP request. When reached the request
8
- * will be aborted and the verification will fail. Default is 5000 (5
9
- * seconds).
5
+ * Timeout (in milliseconds) for the HTTP request. When reached the request will be aborted and
6
+ * the verification will fail. Default is 5000 (5 seconds).
10
7
  */
11
8
  timeoutDuration?: number;
12
9
  /**
13
- * Duration (in milliseconds) for which no more HTTP requests will be
14
- * triggered after a previous successful fetch. Default is 30000 (30 seconds).
10
+ * Duration (in milliseconds) for which no more HTTP requests will be triggered after a previous
11
+ * successful fetch. Default is 30000 (30 seconds).
15
12
  */
16
13
  cooldownDuration?: number;
17
- /**
18
- * Maximum time (in milliseconds) between successful HTTP requests. Default is
19
- * 600000 (10 minutes).
20
- */
14
+ /** Maximum time (in milliseconds) between successful HTTP requests. Default is 600000 (10 minutes). */
21
15
  cacheMaxAge?: number | typeof Infinity;
22
16
  /**
23
- * An instance of
24
- * [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) or
25
- * [https.Agent](https://nodejs.org/api/https.html#https_class_https_agent) to
26
- * pass to the
27
- * [http.get](https://nodejs.org/api/http.html#http_http_get_options_callback)
28
- * or
29
- * [https.get](https://nodejs.org/api/https.html#https_https_get_options_callback)
30
- * method's options. Use when behind an http(s) proxy. This is a Node.js
31
- * runtime specific option, it is ignored when used outside of Node.js
32
- * runtime.
17
+ * An instance of [http.Agent](https://nodejs.org/api/http.html#class-httpagent) or
18
+ * [https.Agent](https://nodejs.org/api/https.html#class-httpsagent) to pass to the
19
+ * [http.get](https://nodejs.org/api/http.html#httpgetoptions-callback) or
20
+ * [https.get](https://nodejs.org/api/https.html#httpsgetoptions-callback) method's options. Use
21
+ * when behind an http(s) proxy. This is a Node.js runtime specific option, it is ignored when
22
+ * used outside of Node.js runtime.
33
23
  */
34
24
  agent?: any;
35
- /**
36
- * Optional headers to be sent with the HTTP request.
37
- */
25
+ /** Optional headers to be sent with the HTTP request. */
38
26
  headers?: Record<string, string>;
39
27
  }
40
28
  interface URL {
41
29
  href: string;
42
30
  }
43
31
  /**
44
- * Returns a function that resolves to a key object downloaded from a
45
- * remote endpoint returning a JSON Web Key Set, that is, for example,
46
- * an OAuth 2.0 or OIDC jwks_uri. Only a single public key must match
47
- * the selection process.
48
- * The JSON Web Key Set is fetched when no key matches the selection
49
- * process but only as frequently as the `cooldownDuration` option allows,
50
- * to prevent abuse.
51
- *
52
- * @param url URL to fetch the JSON Web Key Set from.
53
- * @param options Options for the remote JSON Web Key Set.
32
+ * Returns a function that resolves to a key object downloaded from a remote endpoint returning a
33
+ * JSON Web Key Set, that is, for example, an OAuth 2.0 or OIDC jwks_uri. Only a single public key
34
+ * must match the selection process. The JSON Web Key Set is fetched when no key matches the
35
+ * selection process but only as frequently as the `cooldownDuration` option allows, to prevent abuse.
54
36
  *
55
37
  * @example Usage
38
+ *
56
39
  * ```js
57
40
  * const JWKS = jose.createRemoteJWKSet(new URL('https://www.googleapis.com/oauth2/v3/certs'))
58
41
  *
59
42
  * const { payload, protectedHeader } = await jose.jwtVerify(jwt, JWKS, {
60
43
  * issuer: 'urn:example:issuer',
61
- * audience: 'urn:example:audience'
44
+ * audience: 'urn:example:audience',
62
45
  * })
63
46
  * console.log(protectedHeader)
64
47
  * console.log(payload)
65
48
  * ```
49
+ *
50
+ * @param url URL to fetch the JSON Web Key Set from.
51
+ * @param options Options for the remote JSON Web Key Set.
66
52
  */
67
53
  export declare function createRemoteJWKSet(url: URL, options?: RemoteJWKSetOptions): GetKeyFunction<JWSHeaderParameters, FlattenedJWSInput>;
68
54
  export {};
@@ -3,11 +3,10 @@ import type { CompactJWSHeaderParameters, KeyLike, SignOptions } from '../../typ
3
3
  * The CompactSign class is a utility for creating Compact JWS strings.
4
4
  *
5
5
  * @example Usage
6
+ *
6
7
  * ```js
7
8
  * const jws = await new jose.CompactSign(
8
- * new TextEncoder().encode(
9
- * 'It’s a dangerous business, Frodo, going out your door.'
10
- * )
9
+ * new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
11
10
  * )
12
11
  * .setProtectedHeader({ alg: 'ES256' })
13
12
  * .sign(privateKey)
@@ -17,9 +16,7 @@ import type { CompactJWSHeaderParameters, KeyLike, SignOptions } from '../../typ
17
16
  */
18
17
  export declare class CompactSign {
19
18
  private _flattened;
20
- /**
21
- * @param payload Binary representation of the payload to sign.
22
- */
19
+ /** @param payload Binary representation of the payload to sign. */
23
20
  constructor(payload: Uint8Array);
24
21
  /**
25
22
  * Sets the JWS Protected Header on the Sign object.
@@ -1,9 +1,10 @@
1
1
  import type { CompactVerifyResult, FlattenedJWSInput, GetKeyFunction, CompactJWSHeaderParameters, KeyLike, VerifyOptions, ResolvedKey } from '../../types';
2
2
  /**
3
- * Interface for Compact JWS Verification dynamic key resolution.
4
- * No token components have been verified at the time of this function call.
3
+ * Interface for Compact JWS Verification dynamic key resolution. No token components have been
4
+ * verified at the time of this function call.
5
5
  *
6
- * See [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset)
6
+ * See
7
+ * [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset)
7
8
  * to verify using a remote JSON Web Key Set.
8
9
  */
9
10
  export interface CompactVerifyGetKey extends GetKeyFunction<CompactJWSHeaderParameters, FlattenedJWSInput> {
@@ -11,19 +12,21 @@ export interface CompactVerifyGetKey extends GetKeyFunction<CompactJWSHeaderPara
11
12
  /**
12
13
  * Verifies the signature and format of and afterwards decodes the Compact JWS.
13
14
  *
14
- * @param jws Compact JWS.
15
- * @param key Key to verify the JWS with.
16
- * @param options JWS Verify options.
17
- *
18
15
  * @example Usage
16
+ *
19
17
  * ```js
20
- * const jws = 'eyJhbGciOiJFUzI1NiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4.kkAs_gPPxWMI3rHuVlxHaTPfDWDoqdI8jSvuSmqV-8IHIWXg9mcAeC9ggV-45ZHRbiRJ3obUIFo1rHphPA5URg'
18
+ * const jws =
19
+ * 'eyJhbGciOiJFUzI1NiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4.kkAs_gPPxWMI3rHuVlxHaTPfDWDoqdI8jSvuSmqV-8IHIWXg9mcAeC9ggV-45ZHRbiRJ3obUIFo1rHphPA5URg'
21
20
  *
22
21
  * const { payload, protectedHeader } = await jose.compactVerify(jws, publicKey)
23
22
  *
24
23
  * console.log(protectedHeader)
25
24
  * console.log(new TextDecoder().decode(payload))
26
25
  * ```
26
+ *
27
+ * @param jws Compact JWS.
28
+ * @param key Key to verify the JWS with.
29
+ * @param options JWS Verify options.
27
30
  */
28
31
  export declare function compactVerify(jws: string | Uint8Array, key: KeyLike | Uint8Array, options?: VerifyOptions): Promise<CompactVerifyResult>;
29
32
  /**
@@ -3,11 +3,10 @@ import type { KeyLike, FlattenedJWS, JWSHeaderParameters, SignOptions } from '..
3
3
  * The FlattenedSign class is a utility for creating Flattened JWS objects.
4
4
  *
5
5
  * @example Usage
6
+ *
6
7
  * ```js
7
8
  * const jws = await new jose.FlattenedSign(
8
- * new TextEncoder().encode(
9
- * 'It’s a dangerous business, Frodo, going out your door.'
10
- * )
9
+ * new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
11
10
  * )
12
11
  * .setProtectedHeader({ alg: 'ES256' })
13
12
  * .sign(privateKey)
@@ -19,9 +18,7 @@ export declare class FlattenedSign {
19
18
  private _payload;
20
19
  private _protectedHeader;
21
20
  private _unprotectedHeader;
22
- /**
23
- * @param payload Binary representation of the payload to sign.
24
- */
21
+ /** @param payload Binary representation of the payload to sign. */
25
22
  constructor(payload: Uint8Array);
26
23
  /**
27
24
  * Sets the JWS Protected Header on the FlattenedSign object.
@@ -1,9 +1,10 @@
1
1
  import type { FlattenedVerifyResult, KeyLike, FlattenedJWSInput, JWSHeaderParameters, VerifyOptions, GetKeyFunction, ResolvedKey } from '../../types';
2
2
  /**
3
- * Interface for Flattened JWS Verification dynamic key resolution.
4
- * No token components have been verified at the time of this function call.
3
+ * Interface for Flattened JWS Verification dynamic key resolution. No token components have been
4
+ * verified at the time of this function call.
5
5
  *
6
- * See [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset)
6
+ * See
7
+ * [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset)
7
8
  * to verify using a remote JSON Web Key Set.
8
9
  */
9
10
  export interface FlattenedVerifyGetKey extends GetKeyFunction<JWSHeaderParameters | undefined, FlattenedJWSInput> {
@@ -11,17 +12,15 @@ export interface FlattenedVerifyGetKey extends GetKeyFunction<JWSHeaderParameter
11
12
  /**
12
13
  * Verifies the signature and format of and afterwards decodes the Flattened JWS.
13
14
  *
14
- * @param jws Flattened JWS.
15
- * @param key Key to verify the JWS with.
16
- * @param options JWS Verify options.
17
- *
18
15
  * @example Usage
16
+ *
19
17
  * ```js
20
18
  * const decoder = new TextDecoder()
21
19
  * const jws = {
22
- * signature: 'FVVOXwj6kD3DqdfD9yYqfT2W9jv-Nop4kOehp_DeDGNB5dQNSPRvntBY6xH3uxlCxE8na9d_kyhYOcanpDJ0EA',
20
+ * signature:
21
+ * 'FVVOXwj6kD3DqdfD9yYqfT2W9jv-Nop4kOehp_DeDGNB5dQNSPRvntBY6xH3uxlCxE8na9d_kyhYOcanpDJ0EA',
23
22
  * payload: 'SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4',
24
- * protected: 'eyJhbGciOiJFUzI1NiJ9'
23
+ * protected: 'eyJhbGciOiJFUzI1NiJ9',
25
24
  * }
26
25
  *
27
26
  * const { payload, protectedHeader } = await jose.flattenedVerify(jws, publicKey)
@@ -29,6 +28,10 @@ export interface FlattenedVerifyGetKey extends GetKeyFunction<JWSHeaderParameter
29
28
  * console.log(protectedHeader)
30
29
  * console.log(decoder.decode(payload))
31
30
  * ```
31
+ *
32
+ * @param jws Flattened JWS.
33
+ * @param key Key to verify the JWS with.
34
+ * @param options JWS Verify options.
32
35
  */
33
36
  export declare function flattenedVerify(jws: FlattenedJWSInput, key: KeyLike | Uint8Array, options?: VerifyOptions): Promise<FlattenedVerifyResult>;
34
37
  /**
@@ -12,28 +12,21 @@ export interface Signature {
12
12
  * @param unprotectedHeader JWS Unprotected Header.
13
13
  */
14
14
  setUnprotectedHeader(unprotectedHeader: JWSHeaderParameters): Signature;
15
- /**
16
- * A shorthand for calling addSignature() on the enclosing GeneralSign instance
17
- */
15
+ /** A shorthand for calling addSignature() on the enclosing GeneralSign instance */
18
16
  addSignature(...args: Parameters<GeneralSign['addSignature']>): Signature;
19
- /**
20
- * A shorthand for calling encrypt() on the enclosing GeneralSign instance
21
- */
17
+ /** A shorthand for calling encrypt() on the enclosing GeneralSign instance */
22
18
  sign(...args: Parameters<GeneralSign['sign']>): Promise<GeneralJWS>;
23
- /**
24
- * Returns the enclosing GeneralSign
25
- */
19
+ /** Returns the enclosing GeneralSign */
26
20
  done(): GeneralSign;
27
21
  }
28
22
  /**
29
23
  * The GeneralSign class is a utility for creating General JWS objects.
30
24
  *
31
25
  * @example Usage
26
+ *
32
27
  * ```js
33
28
  * const jws = await new jose.GeneralSign(
34
- * new TextEncoder().encode(
35
- * 'It’s a dangerous business, Frodo, going out your door.'
36
- * )
29
+ * new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
37
30
  * )
38
31
  * .addSignature(ecPrivateKey)
39
32
  * .setProtectedHeader({ alg: 'ES256' })
@@ -47,9 +40,7 @@ export interface Signature {
47
40
  export declare class GeneralSign {
48
41
  private _payload;
49
42
  private _signatures;
50
- /**
51
- * @param payload Binary representation of the payload to sign.
52
- */
43
+ /** @param payload Binary representation of the payload to sign. */
53
44
  constructor(payload: Uint8Array);
54
45
  /**
55
46
  * Adds an additional signature for the General JWS object.
@@ -58,8 +49,6 @@ export declare class GeneralSign {
58
49
  * @param options JWS Sign options.
59
50
  */
60
51
  addSignature(key: KeyLike | Uint8Array, options?: SignOptions): Signature;
61
- /**
62
- * Signs and resolves the value of the General JWS object.
63
- */
52
+ /** Signs and resolves the value of the General JWS object. */
64
53
  sign(): Promise<GeneralJWS>;
65
54
  }
@@ -1,9 +1,10 @@
1
1
  import type { GeneralJWSInput, GeneralVerifyResult, FlattenedJWSInput, GetKeyFunction, JWSHeaderParameters, KeyLike, VerifyOptions, ResolvedKey } from '../../types';
2
2
  /**
3
- * Interface for General JWS Verification dynamic key resolution.
4
- * No token components have been verified at the time of this function call.
3
+ * Interface for General JWS Verification dynamic key resolution. No token components have been
4
+ * verified at the time of this function call.
5
5
  *
6
- * See [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset)
6
+ * See
7
+ * [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset)
7
8
  * to verify using a remote JSON Web Key Set.
8
9
  */
9
10
  export interface GeneralVerifyGetKey extends GetKeyFunction<JWSHeaderParameters, FlattenedJWSInput> {
@@ -11,20 +12,18 @@ export interface GeneralVerifyGetKey extends GetKeyFunction<JWSHeaderParameters,
11
12
  /**
12
13
  * Verifies the signature and format of and afterwards decodes the General JWS.
13
14
  *
14
- * @param jws General JWS.
15
- * @param key Key to verify the JWS with.
16
- * @param options JWS Verify options.
17
- *
18
15
  * @example Usage
16
+ *
19
17
  * ```js
20
18
  * const jws = {
21
19
  * payload: 'SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4',
22
20
  * signatures: [
23
21
  * {
24
- * signature: 'FVVOXwj6kD3DqdfD9yYqfT2W9jv-Nop4kOehp_DeDGNB5dQNSPRvntBY6xH3uxlCxE8na9d_kyhYOcanpDJ0EA',
25
- * protected: 'eyJhbGciOiJFUzI1NiJ9'
26
- * }
27
- * ]
22
+ * signature:
23
+ * 'FVVOXwj6kD3DqdfD9yYqfT2W9jv-Nop4kOehp_DeDGNB5dQNSPRvntBY6xH3uxlCxE8na9d_kyhYOcanpDJ0EA',
24
+ * protected: 'eyJhbGciOiJFUzI1NiJ9',
25
+ * },
26
+ * ],
28
27
  * }
29
28
  *
30
29
  * const { payload, protectedHeader } = await jose.generalVerify(jws, publicKey)
@@ -32,6 +31,10 @@ export interface GeneralVerifyGetKey extends GetKeyFunction<JWSHeaderParameters,
32
31
  * console.log(protectedHeader)
33
32
  * console.log(new TextDecoder().decode(payload))
34
33
  * ```
34
+ *
35
+ * @param jws General JWS.
36
+ * @param key Key to verify the JWS with.
37
+ * @param options JWS Verify options.
35
38
  */
36
39
  export declare function generalVerify(jws: GeneralJWSInput, key: KeyLike | Uint8Array, options?: VerifyOptions): Promise<GeneralVerifyResult>;
37
40
  /**