jose 4.13.1 → 4.13.2

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 (34) hide show
  1. package/README.md +94 -88
  2. package/dist/browser/jws/general/sign.js +1 -1
  3. package/dist/node/cjs/jws/general/sign.js +1 -1
  4. package/dist/node/esm/jws/general/sign.js +1 -1
  5. package/dist/types/jwe/compact/decrypt.d.ts +4 -14
  6. package/dist/types/jwe/compact/encrypt.d.ts +3 -13
  7. package/dist/types/jwe/flattened/decrypt.d.ts +4 -24
  8. package/dist/types/jwe/flattened/encrypt.d.ts +3 -14
  9. package/dist/types/jwe/general/decrypt.d.ts +4 -28
  10. package/dist/types/jwe/general/encrypt.d.ts +2 -16
  11. package/dist/types/jwk/embedded.d.ts +0 -14
  12. package/dist/types/jwk/thumbprint.d.ts +2 -30
  13. package/dist/types/jwks/local.d.ts +0 -59
  14. package/dist/types/jwks/remote.d.ts +5 -48
  15. package/dist/types/jws/compact/sign.d.ts +3 -13
  16. package/dist/types/jws/compact/verify.d.ts +5 -17
  17. package/dist/types/jws/flattened/sign.d.ts +3 -13
  18. package/dist/types/jws/flattened/verify.d.ts +5 -22
  19. package/dist/types/jws/general/sign.d.ts +3 -16
  20. package/dist/types/jws/general/verify.d.ts +5 -25
  21. package/dist/types/jwt/decrypt.d.ts +4 -18
  22. package/dist/types/jwt/encrypt.d.ts +12 -22
  23. package/dist/types/jwt/sign.d.ts +3 -93
  24. package/dist/types/jwt/unsecured.d.ts +0 -23
  25. package/dist/types/jwt/verify.d.ts +5 -84
  26. package/dist/types/key/export.d.ts +0 -26
  27. package/dist/types/key/generate_key_pair.d.ts +1 -9
  28. package/dist/types/key/generate_secret.d.ts +1 -8
  29. package/dist/types/key/import.d.ts +15 -80
  30. package/dist/types/types.d.ts +38 -94
  31. package/dist/types/util/decode_jwt.d.ts +0 -7
  32. package/dist/types/util/decode_protected_header.d.ts +0 -7
  33. package/dist/types/util/errors.d.ts +57 -14
  34. package/package.json +1 -1
@@ -3,14 +3,6 @@ import type { JWK, KeyLike } from '../types';
3
3
  * Exports a runtime-specific public key representation (KeyObject or CryptoKey) to a PEM-encoded
4
4
  * SPKI string format.
5
5
  *
6
- * @example Usage
7
- *
8
- * ```js
9
- * const spkiPem = await jose.exportSPKI(publicKey)
10
- *
11
- * console.log(spkiPem)
12
- * ```
13
- *
14
6
  * @param key Key representation to transform to a PEM-encoded SPKI string format.
15
7
  */
16
8
  export declare function exportSPKI(key: KeyLike): Promise<string>;
@@ -18,30 +10,12 @@ export declare function exportSPKI(key: KeyLike): Promise<string>;
18
10
  * Exports a runtime-specific private key representation (KeyObject or CryptoKey) to a PEM-encoded
19
11
  * PKCS8 string format.
20
12
  *
21
- * @example Usage
22
- *
23
- * ```js
24
- * const pkcs8Pem = await jose.exportPKCS8(privateKey)
25
- *
26
- * console.log(pkcs8Pem)
27
- * ```
28
- *
29
13
  * @param key Key representation to transform to a PEM-encoded PKCS8 string format.
30
14
  */
31
15
  export declare function exportPKCS8(key: KeyLike): Promise<string>;
32
16
  /**
33
17
  * Exports a runtime-specific key representation (KeyLike) to a JWK.
34
18
  *
35
- * @example Usage
36
- *
37
- * ```js
38
- * const privateJwk = await jose.exportJWK(privateKey)
39
- * const publicJwk = await jose.exportJWK(publicKey)
40
- *
41
- * console.log(privateJwk)
42
- * console.log(publicJwk)
43
- * ```
44
- *
45
19
  * @param key Key representation to export as JWK.
46
20
  */
47
21
  export declare function exportJWK(key: KeyLike | Uint8Array): Promise<JWK>;
@@ -18,7 +18,7 @@ export interface GenerateKeyPairOptions {
18
18
  modulusLength?: number;
19
19
  /**
20
20
  * (Only effective in Web Crypto API runtimes) The value to use as
21
- * [SubtleCrypto.generateKey()](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey)
21
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey SubtleCrypto.generateKey()}
22
22
  * `extractable` argument. Default is false.
23
23
  */
24
24
  extractable?: boolean;
@@ -30,14 +30,6 @@ export interface GenerateKeyPairOptions {
30
30
  * Note: Under Web Crypto API runtime the `privateKey` is generated with `extractable` set to
31
31
  * `false` by default.
32
32
  *
33
- * @example Usage
34
- *
35
- * ```js
36
- * const { publicKey, privateKey } = await jose.generateKeyPair('PS256')
37
- * console.log(publicKey)
38
- * console.log(privateKey)
39
- * ```
40
- *
41
33
  * @param alg JWA Algorithm Identifier to be used with the generated key pair.
42
34
  * @param options Additional options passed down to the key pair generation.
43
35
  */
@@ -2,7 +2,7 @@ import type { KeyLike } from '../types';
2
2
  export interface GenerateSecretOptions {
3
3
  /**
4
4
  * (Only effective in Web Crypto API runtimes) The value to use as
5
- * [SubtleCrypto.generateKey()](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey)
5
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey SubtleCrypto.generateKey()}
6
6
  * `extractable` argument. Default is false.
7
7
  */
8
8
  extractable?: boolean;
@@ -13,13 +13,6 @@ export interface GenerateSecretOptions {
13
13
  * Note: Under Web Crypto API runtime the secret key is generated with `extractable` set to `false`
14
14
  * by default.
15
15
  *
16
- * @example Usage
17
- *
18
- * ```js
19
- * const secret = await jose.generateSecret('HS256')
20
- * console.log(secret)
21
- * ```
22
- *
23
16
  * @param alg JWA Algorithm Identifier to be used with the generated secret.
24
17
  * @param options Additional options passed down to the secret generation.
25
18
  */
@@ -2,117 +2,52 @@ import type { JWK, KeyLike } from '../types';
2
2
  export interface PEMImportOptions {
3
3
  /**
4
4
  * (Only effective in Web Crypto API runtimes) The value to use as
5
- * [SubtleCrypto.importKey()](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey)
5
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey SubtleCrypto.importKey()}
6
6
  * `extractable` argument. Default is false.
7
7
  */
8
8
  extractable?: boolean;
9
9
  }
10
10
  /**
11
11
  * Imports a PEM-encoded SPKI string as a runtime-specific public key representation (KeyObject or
12
- * CryptoKey). See [Algorithm Key Requirements](https://github.com/panva/jose/issues/210) to learn
13
- * about key to algorithm requirements and mapping.
14
- *
15
- * @example Usage
16
- *
17
- * ```js
18
- * const algorithm = 'ES256'
19
- * const spki = `-----BEGIN PUBLIC KEY-----
20
- * MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFlHHWfLk0gLBbsLTcuCrbCqoHqmM
21
- * YJepMC+Q+Dd6RBmBiA41evUsNMwLeN+PNFqib+xwi9JkJ8qhZkq8Y/IzGg==
22
- * -----END PUBLIC KEY-----`
23
- * const ecPublicKey = await jose.importSPKI(spki, algorithm)
24
- * ```
12
+ * CryptoKey).
25
13
  *
26
14
  * @param pem PEM-encoded SPKI string
27
15
  * @param alg (Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used
28
- * with the imported key, its presence is only enforced in Web Crypto API runtimes.
16
+ * with the imported key, its presence is only enforced in Web Crypto API runtimes. See
17
+ * {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}.
29
18
  */
30
19
  export declare function importSPKI<T extends KeyLike = KeyLike>(spki: string, alg: string, options?: PEMImportOptions): Promise<T>;
31
20
  /**
32
21
  * Imports the SPKI from an X.509 string certificate as a runtime-specific public key representation
33
- * (KeyObject or CryptoKey). See [Algorithm Key
34
- * Requirements](https://github.com/panva/jose/issues/210) to learn about key to algorithm
35
- * requirements and mapping.
36
- *
37
- * @example Usage
38
- *
39
- * ```js
40
- * const algorithm = 'ES256'
41
- * const x509 = `-----BEGIN CERTIFICATE-----
42
- * MIIBXjCCAQSgAwIBAgIGAXvykuMKMAoGCCqGSM49BAMCMDYxNDAyBgNVBAMMK3Np
43
- * QXBNOXpBdk1VaXhXVWVGaGtjZXg1NjJRRzFyQUhXaV96UlFQTVpQaG8wHhcNMjEw
44
- * OTE3MDcwNTE3WhcNMjIwNzE0MDcwNTE3WjA2MTQwMgYDVQQDDCtzaUFwTTl6QXZN
45
- * VWl4V1VlRmhrY2V4NTYyUUcxckFIV2lfelJRUE1aUGhvMFkwEwYHKoZIzj0CAQYI
46
- * KoZIzj0DAQcDQgAE8PbPvCv5D5xBFHEZlBp/q5OEUymq7RIgWIi7tkl9aGSpYE35
47
- * UH+kBKDnphJO3odpPZ5gvgKs2nwRWcrDnUjYLDAKBggqhkjOPQQDAgNIADBFAiEA
48
- * 1yyMTRe66MhEXID9+uVub7woMkNYd0LhSHwKSPMUUTkCIFQGsfm1ecXOpeGOufAh
49
- * v+A1QWZMuTWqYt+uh/YSRNDn
50
- * -----END CERTIFICATE-----`
51
- * const ecPublicKey = await jose.importX509(x509, algorithm)
52
- * ```
22
+ * (KeyObject or CryptoKey).
53
23
  *
54
24
  * @param pem X.509 certificate string
55
25
  * @param alg (Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used
56
- * with the imported key, its presence is only enforced in Web Crypto API runtimes.
26
+ * with the imported key, its presence is only enforced in Web Crypto API runtimes. See
27
+ * {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}.
57
28
  */
58
29
  export declare function importX509<T extends KeyLike = KeyLike>(x509: string, alg: string, options?: PEMImportOptions): Promise<T>;
59
30
  /**
60
31
  * Imports a PEM-encoded PKCS#8 string as a runtime-specific private key representation (KeyObject
61
- * or CryptoKey). See [Algorithm Key Requirements](https://github.com/panva/jose/issues/210) to
62
- * learn about key to algorithm requirements and mapping. Encrypted keys are not supported.
63
- *
64
- * @example Usage
65
- *
66
- * ```js
67
- * const algorithm = 'ES256'
68
- * const pkcs8 = `-----BEGIN PRIVATE KEY-----
69
- * MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgiyvo0X+VQ0yIrOaN
70
- * nlrnUclopnvuuMfoc8HHly3505OhRANCAAQWUcdZ8uTSAsFuwtNy4KtsKqgeqYxg
71
- * l6kwL5D4N3pEGYGIDjV69Sw0zAt43480WqJv7HCL0mQnyqFmSrxj8jMa
72
- * -----END PRIVATE KEY-----`
73
- * const ecPrivateKey = await jose.importPKCS8(pkcs8, algorithm)
74
- * ```
32
+ * or CryptoKey).
75
33
  *
76
34
  * @param pem PEM-encoded PKCS#8 string
77
35
  * @param alg (Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used
78
- * with the imported key, its presence is only enforced in Web Crypto API runtimes.
36
+ * with the imported key, its presence is only enforced in Web Crypto API runtimes. See
37
+ * {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}.
79
38
  */
80
39
  export declare function importPKCS8<T extends KeyLike = KeyLike>(pkcs8: string, alg: string, options?: PEMImportOptions): Promise<T>;
81
40
  /**
82
41
  * Imports a JWK to a runtime-specific key representation (KeyLike). Either JWK "alg" (Algorithm)
83
- * Parameter must be present or the optional "alg" argument. When running on a runtime using [Web
84
- * Cryptography API](https://www.w3.org/TR/WebCryptoAPI/) the jwk parameters "use", "key_ops", and
85
- * "ext" are also used in the resulting `CryptoKey`. See [Algorithm Key
86
- * Requirements](https://github.com/panva/jose/issues/210) to learn about key to algorithm
87
- * requirements and mapping.
88
- *
89
- * @example Usage
90
- *
91
- * ```js
92
- * const ecPublicKey = await jose.importJWK(
93
- * {
94
- * crv: 'P-256',
95
- * kty: 'EC',
96
- * x: 'ySK38C1jBdLwDsNWKzzBHqKYEE5Cgv-qjWvorUXk9fw',
97
- * y: '_LeQBw07cf5t57Iavn4j-BqJsAD1dpoz8gokd3sBsOo',
98
- * },
99
- * 'ES256',
100
- * )
101
- *
102
- * const rsaPublicKey = await jose.importJWK(
103
- * {
104
- * kty: 'RSA',
105
- * e: 'AQAB',
106
- * n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoMjFbvOtgyts55fXKdMWv7I9HMD5HwE9uW839PWA514qhbcIsXEYSFMPMV6fnlsiZvQQ',
107
- * },
108
- * 'PS256',
109
- * )
110
- * ```
42
+ * Parameter must be present or the optional "alg" argument. When running on a runtime using
43
+ * {@link https://www.w3.org/TR/WebCryptoAPI/ Web Cryptography API} the jwk parameters "use",
44
+ * "key_ops", and "ext" are also used in the resulting `CryptoKey`.
111
45
  *
112
46
  * @param jwk JSON Web Key.
113
47
  * @param alg (Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used
114
48
  * with the imported key. Default is the "alg" property on the JWK, its presence is only enforced
115
- * in Web Crypto API runtimes.
49
+ * in Web Crypto API runtimes. See
50
+ * {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}.
116
51
  * @param octAsKeyObject Forces a symmetric key to be imported to a KeyObject or CryptoKey. Default
117
52
  * is true unless JWK "ext" (Extractable) is true.
118
53
  */
@@ -1,98 +1,37 @@
1
1
  /**
2
2
  * KeyLike are runtime-specific classes representing asymmetric keys or symmetric secrets. These are
3
- * instances of [CryptoKey](https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey) and
4
- * additionally [KeyObject](https://nodejs.org/api/crypto.html#class-keyobject) in Node.js runtime.
5
- * [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
3
+ * instances of {@link https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey CryptoKey} and
4
+ * additionally {@link https://nodejs.org/api/crypto.html#class-keyobject KeyObject} in Node.js
5
+ * runtime.
6
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array Uint8Array}
6
7
  * instances are also accepted as symmetric secret representation only.
7
8
  *
8
- * [Key Import Functions](../modules/key_import.md#readme) can be used to import PEM, or JWK
9
- * formatted asymmetric keys and certificates to these runtime-specific representations.
9
+ * [Key Import Functions](../modules/key_import.md) can be used to import PEM, or JWK formatted
10
+ * asymmetric keys and certificates to these runtime-specific representations.
10
11
  *
11
- * In Node.js the [Buffer](https://nodejs.org/api/buffer.html#buffer) class is a subclass of
12
+ * In Node.js the {@link https://nodejs.org/api/buffer.html#buffer Buffer} class is a subclass of
12
13
  * Uint8Array and so Buffer can be provided for symmetric secrets as well.
13
14
  *
14
- * [KeyObject](https://nodejs.org/api/crypto.html#class-keyobject) is a representation of a
15
+ * {@link https://nodejs.org/api/crypto.html#class-keyobject KeyObject} is a representation of a
15
16
  * key/secret available in the Node.js runtime. In addition to the import functions of this library
16
17
  * you may use the runtime APIs
17
- * [crypto.createPublicKey](https://nodejs.org/api/crypto.html#cryptocreatepublickeykey),
18
- * [crypto.createPrivateKey](https://nodejs.org/api/crypto.html#cryptocreateprivatekeykey), and
19
- * [crypto.createSecretKey](https://nodejs.org/api/crypto.html#cryptocreatesecretkeykey-encoding) to
20
- * obtain a KeyObject from your existing key material.
18
+ * {@link https://nodejs.org/api/crypto.html#cryptocreatepublickeykey crypto.createPublicKey},
19
+ * {@link https://nodejs.org/api/crypto.html#cryptocreateprivatekeykey crypto.createPrivateKey}, and
20
+ * {@link https://nodejs.org/api/crypto.html#cryptocreatesecretkeykey-encoding crypto.createSecretKey}
21
+ * to obtain a `KeyObject` from your existing key material.
21
22
  *
22
- * [CryptoKey](https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey) is a representation of a
23
- * key/secret available in the Browser and Web-interoperable runtimes. In addition to the import
24
- * functions of this library you may use the
25
- * [SubtleCrypto.importKey](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey)
23
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey CryptoKey} is a representation
24
+ * of a key/secret available in the Browser and Web-interoperable runtimes. In addition to the
25
+ * import functions of this library you may use the
26
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey SubtleCrypto.importKey}
26
27
  * API to obtain a CryptoKey from your existing key material.
27
28
  *
28
- * @example Import a PEM-encoded SPKI Public Key
29
- *
30
- * ```js
31
- * const algorithm = 'ES256'
32
- * const spki = `-----BEGIN PUBLIC KEY-----
33
- * MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFlHHWfLk0gLBbsLTcuCrbCqoHqmM
34
- * YJepMC+Q+Dd6RBmBiA41evUsNMwLeN+PNFqib+xwi9JkJ8qhZkq8Y/IzGg==
35
- * -----END PUBLIC KEY-----`
36
- * const ecPublicKey = await jose.importSPKI(spki, algorithm)
37
- * ```
38
- *
39
- * @example Import SPKI from an X.509 Certificate
40
- *
41
- * ```js
42
- * const algorithm = 'ES256'
43
- * const x509 = `-----BEGIN CERTIFICATE-----
44
- * MIIBXjCCAQSgAwIBAgIGAXvykuMKMAoGCCqGSM49BAMCMDYxNDAyBgNVBAMMK3Np
45
- * QXBNOXpBdk1VaXhXVWVGaGtjZXg1NjJRRzFyQUhXaV96UlFQTVpQaG8wHhcNMjEw
46
- * OTE3MDcwNTE3WhcNMjIwNzE0MDcwNTE3WjA2MTQwMgYDVQQDDCtzaUFwTTl6QXZN
47
- * VWl4V1VlRmhrY2V4NTYyUUcxckFIV2lfelJRUE1aUGhvMFkwEwYHKoZIzj0CAQYI
48
- * KoZIzj0DAQcDQgAE8PbPvCv5D5xBFHEZlBp/q5OEUymq7RIgWIi7tkl9aGSpYE35
49
- * UH+kBKDnphJO3odpPZ5gvgKs2nwRWcrDnUjYLDAKBggqhkjOPQQDAgNIADBFAiEA
50
- * 1yyMTRe66MhEXID9+uVub7woMkNYd0LhSHwKSPMUUTkCIFQGsfm1ecXOpeGOufAh
51
- * v+A1QWZMuTWqYt+uh/YSRNDn
52
- * -----END CERTIFICATE-----`
53
- * const ecPublicKey = await jose.importX509(x509, algorithm)
54
- * ```
55
- *
56
- * @example Import a PEM-encoded PKCS8 Private Key
57
- *
58
- * ```js
59
- * const algorithm = 'ES256'
60
- * const pkcs8 = `-----BEGIN PRIVATE KEY-----
61
- * MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgiyvo0X+VQ0yIrOaN
62
- * nlrnUclopnvuuMfoc8HHly3505OhRANCAAQWUcdZ8uTSAsFuwtNy4KtsKqgeqYxg
63
- * l6kwL5D4N3pEGYGIDjV69Sw0zAt43480WqJv7HCL0mQnyqFmSrxj8jMa
64
- * -----END PRIVATE KEY-----`
65
- * const ecPrivateKey = await jose.importPKCS8(pkcs8, algorithm)
66
- * ```
67
- *
68
- * @example Import a JSON Web Key (JWK)
69
- *
70
- * ```js
71
- * const ecPublicKey = await jose.importJWK(
72
- * {
73
- * crv: 'P-256',
74
- * kty: 'EC',
75
- * x: 'ySK38C1jBdLwDsNWKzzBHqKYEE5Cgv-qjWvorUXk9fw',
76
- * y: '_LeQBw07cf5t57Iavn4j-BqJsAD1dpoz8gokd3sBsOo',
77
- * },
78
- * 'ES256',
79
- * )
80
- *
81
- * const rsaPublicKey = await jose.importJWK(
82
- * {
83
- * kty: 'RSA',
84
- * e: 'AQAB',
85
- * n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoMjFbvOtgyts55fXKdMWv7I9HMD5HwE9uW839PWA514qhbcIsXEYSFMPMV6fnlsiZvQQ',
86
- * },
87
- * 'PS256',
88
- * )
89
- * ```
90
29
  */
91
30
  export type KeyLike = { type: string }
92
31
 
93
32
  /**
94
- * JSON Web Key ([JWK](https://www.rfc-editor.org/rfc/rfc7517)). "RSA", "EC", "OKP", and "oct" key
95
- * types are supported.
33
+ * JSON Web Key ({@link https://www.rfc-editor.org/rfc/rfc7517 JWK}). "RSA", "EC", "OKP", and "oct"
34
+ * key types are supported.
96
35
  */
97
36
  export interface JWK {
98
37
  /** JWK "alg" (Algorithm) Parameter. */
@@ -185,8 +124,9 @@ export interface FlattenedJWSInput {
185
124
  */
186
125
  export interface GeneralJWSInput {
187
126
  /**
188
- * The "payload" member MUST be present and contain the value BASE64URL(JWS Payload). When RFC7797
189
- * "b64": false is used the value passed may also be a Uint8Array.
127
+ * The "payload" member MUST be present and contain the value BASE64URL(JWS Payload). When when
128
+ * JWS Unencoded Payload ({@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}) "b64": false is
129
+ * used the value passed may also be a Uint8Array.
190
130
  */
191
131
  payload: string | Uint8Array
192
132
 
@@ -199,7 +139,7 @@ export interface GeneralJWSInput {
199
139
 
200
140
  /**
201
141
  * Flattened JWS definition. Payload is returned as an empty string when JWS Unencoded Payload
202
- * Option [RFC7797](https://www.rfc-editor.org/rfc/rfc7797) is used.
142
+ * ({@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}) is used.
203
143
  */
204
144
  export interface FlattenedJWS extends Partial<FlattenedJWSInput> {
205
145
  payload: string
@@ -207,8 +147,8 @@ export interface FlattenedJWS extends Partial<FlattenedJWSInput> {
207
147
  }
208
148
 
209
149
  /**
210
- * General JWS definition. Payload is returned as an empty string when JWS Unencoded Payload Option
211
- * [RFC7797](https://www.rfc-editor.org/rfc/rfc7797) is used.
150
+ * General JWS definition. Payload is returned as an empty string when JWS Unencoded Payload
151
+ * ({@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}) is used.
212
152
  */
213
153
  export interface GeneralJWS {
214
154
  payload: string
@@ -248,7 +188,7 @@ export interface JWSHeaderParameters extends JoseHeaderParameters {
248
188
 
249
189
  /**
250
190
  * This JWS Extension Header Parameter modifies the JWS Payload representation and the JWS Signing
251
- * Input computation as per [RFC7797](https://www.rfc-editor.org/rfc/rfc7797).
191
+ * Input computation as per {@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}.
252
192
  */
253
193
  b64?: boolean
254
194
 
@@ -475,45 +415,49 @@ export interface JWTPayload {
475
415
  /**
476
416
  * JWT Issuer
477
417
  *
478
- * @see [RFC7519#section-4.1.1](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.1)
418
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.1 RFC7519#section-4.1.1}
479
419
  */
480
420
  iss?: string
481
421
 
482
422
  /**
483
423
  * JWT Subject
484
424
  *
485
- * @see [RFC7519#section-4.1.2](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.2)
425
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.2 RFC7519#section-4.1.2}
486
426
  */
487
427
  sub?: string
488
428
 
489
- /** JWT Audience [RFC7519#section-4.1.3](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.3). */
429
+ /**
430
+ * JWT Audience
431
+ *
432
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.3 RFC7519#section-4.1.3}
433
+ */
490
434
  aud?: string | string[]
491
435
 
492
436
  /**
493
437
  * JWT ID
494
438
  *
495
- * @see [RFC7519#section-4.1.7](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.7)
439
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.7 RFC7519#section-4.1.7}
496
440
  */
497
441
  jti?: string
498
442
 
499
443
  /**
500
444
  * JWT Not Before
501
445
  *
502
- * @see [RFC7519#section-4.1.5](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.5)
446
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.5 RFC7519#section-4.1.5}
503
447
  */
504
448
  nbf?: number
505
449
 
506
450
  /**
507
451
  * JWT Expiration Time
508
452
  *
509
- * @see [RFC7519#section-4.1.4](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4)
453
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4 RFC7519#section-4.1.4}
510
454
  */
511
455
  exp?: number
512
456
 
513
457
  /**
514
458
  * JWT Issued At
515
459
  *
516
- * @see [RFC7519#section-4.1.6](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.6)
460
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.6 RFC7519#section-4.1.6}
517
461
  */
518
462
  iat?: number
519
463
 
@@ -523,7 +467,7 @@ export interface JWTPayload {
523
467
 
524
468
  /**
525
469
  * Deflate Raw implementation, e.g. promisified
526
- * [zlib.deflateRaw](https://nodejs.org/api/zlib.html#zlibdeflaterawbuffer-options-callback).
470
+ * {@link https://nodejs.org/api/zlib.html#zlibdeflaterawbuffer-options-callback zlib.deflateRaw}.
527
471
  */
528
472
  export interface DeflateFunction {
529
473
  (input: Uint8Array): Promise<Uint8Array>
@@ -531,7 +475,7 @@ export interface DeflateFunction {
531
475
 
532
476
  /**
533
477
  * Inflate Raw implementation, e.g. promisified
534
- * [zlib.inflateRaw](https://nodejs.org/api/zlib.html#zlibinflaterawbuffer-options-callback).
478
+ * {@link https://nodejs.org/api/zlib.html#zlibinflaterawbuffer-options-callback zlib.inflateRaw}.
535
479
  */
536
480
  export interface InflateFunction {
537
481
  (input: Uint8Array): Promise<Uint8Array>
@@ -5,13 +5,6 @@ import type { JWTPayload } from '../types';
5
5
  * and JWS signature verification use `jose.jwtVerify()`. For an encrypted JWT Claims Set validation
6
6
  * and JWE decryption use `jose.jwtDecrypt()`.
7
7
  *
8
- * @example Usage
9
- *
10
- * ```js
11
- * const claims = jose.decodeJwt(token)
12
- * console.log(claims)
13
- * ```
14
- *
15
8
  * @param jwt JWT token in compact JWS serialization.
16
9
  */
17
10
  export declare function decodeJwt(jwt: string): JWTPayload;
@@ -3,13 +3,6 @@ export type ProtectedHeaderParameters = JWSHeaderParameters & JWEHeaderParameter
3
3
  /**
4
4
  * Decodes the Protected Header of a JWE/JWS/JWT token utilizing any JOSE serialization.
5
5
  *
6
- * @example Usage
7
- *
8
- * ```js
9
- * const protectedHeader = jose.decodeProtectedHeader(token)
10
- * console.log(protectedHeader)
11
- * ```
12
- *
13
6
  * @param token JWE/JWS/JWT token in any JOSE serialization.
14
7
  */
15
8
  export declare function decodeProtectedHeader(token: string | object): ProtectedHeaderParameters;
@@ -1,5 +1,8 @@
1
1
  import type { KeyLike } from '../types';
2
- /** A generic Error subclass that all other specific JOSE Error subclasses inherit from. */
2
+ /**
3
+ * A generic Error that all other JOSE specific Error subclasses extend.
4
+ *
5
+ */
3
6
  export declare class JOSEError extends Error {
4
7
  /** A unique error code for the particular error subclass. */
5
8
  static get code(): string;
@@ -7,7 +10,10 @@ export declare class JOSEError extends Error {
7
10
  code: string;
8
11
  constructor(message?: string);
9
12
  }
10
- /** An error subclass thrown when a JWT Claim Set member validation fails. */
13
+ /**
14
+ * An error subclass thrown when a JWT Claim Set member validation fails.
15
+ *
16
+ */
11
17
  export declare class JWTClaimValidationFailed extends JOSEError {
12
18
  static get code(): 'ERR_JWT_CLAIM_VALIDATION_FAILED';
13
19
  code: string;
@@ -17,7 +23,10 @@ export declare class JWTClaimValidationFailed extends JOSEError {
17
23
  reason: string;
18
24
  constructor(message: string, claim?: string, reason?: string);
19
25
  }
20
- /** An error subclass thrown when a JWT is expired. */
26
+ /**
27
+ * An error subclass thrown when a JWT is expired.
28
+ *
29
+ */
21
30
  export declare class JWTExpired extends JOSEError implements JWTClaimValidationFailed {
22
31
  static get code(): 'ERR_JWT_EXPIRED';
23
32
  code: string;
@@ -27,7 +36,10 @@ export declare class JWTExpired extends JOSEError implements JWTClaimValidationF
27
36
  reason: string;
28
37
  constructor(message: string, claim?: string, reason?: string);
29
38
  }
30
- /** An error subclass thrown when a JOSE Algorithm is not allowed per developer preference. */
39
+ /**
40
+ * An error subclass thrown when a JOSE Algorithm is not allowed per developer preference.
41
+ *
42
+ */
31
43
  export declare class JOSEAlgNotAllowed extends JOSEError {
32
44
  static get code(): 'ERR_JOSE_ALG_NOT_ALLOWED';
33
45
  code: string;
@@ -35,49 +47,74 @@ export declare class JOSEAlgNotAllowed extends JOSEError {
35
47
  /**
36
48
  * An error subclass thrown when a particular feature or algorithm is not supported by this
37
49
  * implementation or JOSE in general.
50
+ *
38
51
  */
39
52
  export declare class JOSENotSupported extends JOSEError {
40
53
  static get code(): 'ERR_JOSE_NOT_SUPPORTED';
41
54
  code: string;
42
55
  }
43
- /** An error subclass thrown when a JWE ciphertext decryption fails. */
56
+ /**
57
+ * An error subclass thrown when a JWE ciphertext decryption fails.
58
+ *
59
+ */
44
60
  export declare class JWEDecryptionFailed extends JOSEError {
45
61
  static get code(): 'ERR_JWE_DECRYPTION_FAILED';
46
62
  code: string;
47
63
  message: string;
48
64
  }
49
- /** An error subclass thrown when a JWE is invalid. */
65
+ /**
66
+ * An error subclass thrown when a JWE is invalid.
67
+ *
68
+ */
50
69
  export declare class JWEInvalid extends JOSEError {
51
70
  static get code(): 'ERR_JWE_INVALID';
52
71
  code: string;
53
72
  }
54
- /** An error subclass thrown when a JWS is invalid. */
73
+ /**
74
+ * An error subclass thrown when a JWS is invalid.
75
+ *
76
+ */
55
77
  export declare class JWSInvalid extends JOSEError {
56
78
  static get code(): 'ERR_JWS_INVALID';
57
79
  code: string;
58
80
  }
59
- /** An error subclass thrown when a JWT is invalid. */
81
+ /**
82
+ * An error subclass thrown when a JWT is invalid.
83
+ *
84
+ */
60
85
  export declare class JWTInvalid extends JOSEError {
61
86
  static get code(): 'ERR_JWT_INVALID';
62
87
  code: string;
63
88
  }
64
- /** An error subclass thrown when a JWK is invalid. */
89
+ /**
90
+ * An error subclass thrown when a JWK is invalid.
91
+ *
92
+ */
65
93
  export declare class JWKInvalid extends JOSEError {
66
94
  static get code(): 'ERR_JWK_INVALID';
67
95
  code: string;
68
96
  }
69
- /** An error subclass thrown when a JWKS is invalid. */
97
+ /**
98
+ * An error subclass thrown when a JWKS is invalid.
99
+ *
100
+ */
70
101
  export declare class JWKSInvalid extends JOSEError {
71
102
  static get code(): 'ERR_JWKS_INVALID';
72
103
  code: string;
73
104
  }
74
- /** An error subclass thrown when no keys match from a JWKS. */
105
+ /**
106
+ * An error subclass thrown when no keys match from a JWKS.
107
+ *
108
+ */
75
109
  export declare class JWKSNoMatchingKey extends JOSEError {
76
110
  static get code(): 'ERR_JWKS_NO_MATCHING_KEY';
77
111
  code: string;
78
112
  message: string;
79
113
  }
80
- /** An error subclass thrown when multiple keys match from a JWKS. */
114
+ /**
115
+ * An error subclass thrown when multiple keys match from a JWKS.
116
+ *
117
+ */
81
118
  export declare class JWKSMultipleMatchingKeys extends JOSEError {
82
119
  /** @ignore */
83
120
  [Symbol.asyncIterator]: () => AsyncIterableIterator<KeyLike>;
@@ -85,13 +122,19 @@ export declare class JWKSMultipleMatchingKeys extends JOSEError {
85
122
  code: string;
86
123
  message: string;
87
124
  }
88
- /** Timeout was reached when retrieving the JWKS response. */
125
+ /**
126
+ * Timeout was reached when retrieving the JWKS response.
127
+ *
128
+ */
89
129
  export declare class JWKSTimeout extends JOSEError {
90
130
  static get code(): 'ERR_JWKS_TIMEOUT';
91
131
  code: string;
92
132
  message: string;
93
133
  }
94
- /** An error subclass thrown when JWS signature verification fails. */
134
+ /**
135
+ * An error subclass thrown when JWS signature verification fails.
136
+ *
137
+ */
95
138
  export declare class JWSSignatureVerificationFailed extends JOSEError {
96
139
  static get code(): 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
97
140
  code: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jose",
3
- "version": "4.13.1",
3
+ "version": "4.13.2",
4
4
  "description": "'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes",
5
5
  "keywords": [
6
6
  "browser",