jose 4.8.3 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +6 -3
  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/node/cjs/index.js +2 -1
  7. package/dist/node/cjs/jwe/flattened/decrypt.js +1 -1
  8. package/dist/node/cjs/jwk/thumbprint.js +9 -2
  9. package/dist/node/cjs/jws/flattened/verify.js +1 -1
  10. package/dist/node/cjs/runtime/key_to_jwk.js +4 -0
  11. package/dist/node/esm/index.js +1 -1
  12. package/dist/node/esm/jwe/flattened/decrypt.js +1 -1
  13. package/dist/node/esm/jwk/thumbprint.js +7 -1
  14. package/dist/node/esm/jws/flattened/verify.js +1 -1
  15. package/dist/node/esm/runtime/key_to_jwk.js +4 -0
  16. package/dist/types/index.d.ts +1 -1
  17. package/dist/types/jwe/compact/decrypt.d.ts +9 -7
  18. package/dist/types/jwe/compact/encrypt.d.ts +14 -20
  19. package/dist/types/jwe/flattened/decrypt.d.ts +12 -13
  20. package/dist/types/jwe/flattened/encrypt.d.ts +17 -26
  21. package/dist/types/jwe/general/decrypt.d.ts +13 -14
  22. package/dist/types/jwe/general/encrypt.d.ts +6 -15
  23. package/dist/types/jwk/embedded.d.ts +8 -7
  24. package/dist/types/jwk/thumbprint.d.ts +30 -7
  25. package/dist/types/jwks/local.d.ts +12 -15
  26. package/dist/types/jwks/remote.d.ts +22 -36
  27. package/dist/types/jws/compact/sign.d.ts +3 -6
  28. package/dist/types/jws/compact/verify.d.ts +11 -8
  29. package/dist/types/jws/flattened/sign.d.ts +3 -6
  30. package/dist/types/jws/flattened/verify.d.ts +12 -9
  31. package/dist/types/jws/general/sign.d.ts +7 -18
  32. package/dist/types/jws/general/verify.d.ts +14 -11
  33. package/dist/types/jwt/decrypt.d.ts +13 -12
  34. package/dist/types/jwt/encrypt.d.ts +15 -18
  35. package/dist/types/jwt/produce.d.ts +9 -14
  36. package/dist/types/jwt/sign.d.ts +2 -2
  37. package/dist/types/jwt/unsecured.d.ts +4 -4
  38. package/dist/types/jwt/verify.d.ts +15 -13
  39. package/dist/types/key/export.d.ts +13 -8
  40. package/dist/types/key/generate_key_pair.d.ts +14 -19
  41. package/dist/types/key/generate_secret.d.ts +3 -2
  42. package/dist/types/key/import.d.ts +50 -39
  43. package/dist/types/types.d.ts +196 -371
  44. package/dist/types/util/decode_jwt.d.ts +7 -6
  45. package/dist/types/util/decode_protected_header.d.ts +3 -2
  46. package/dist/types/util/errors.d.ts +20 -61
  47. package/package.json +1 -1
@@ -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
  /**
@@ -1,34 +1,35 @@
1
1
  import type { KeyLike, DecryptOptions, JWTClaimVerificationOptions, GetKeyFunction, CompactJWEHeaderParameters, FlattenedJWE, JWTDecryptResult, ResolvedKey } from '../types';
2
- /**
3
- * Combination of JWE Decryption options and JWT Claims Set verification options.
4
- */
2
+ /** Combination of JWE Decryption options and JWT Claims Set verification options. */
5
3
  export interface JWTDecryptOptions extends DecryptOptions, JWTClaimVerificationOptions {
6
4
  }
7
5
  /**
8
- * Interface for JWT Decryption dynamic key resolution.
9
- * No token components have been verified at the time of this function call.
6
+ * Interface for JWT Decryption dynamic key resolution. No token components have been verified at
7
+ * the time of this function call.
10
8
  */
11
9
  export interface JWTDecryptGetKey extends GetKeyFunction<CompactJWEHeaderParameters, FlattenedJWE> {
12
10
  }
13
11
  /**
14
- * Verifies the JWT format (to be a JWE Compact format), decrypts the ciphertext, validates the JWT Claims Set.
15
- *
16
- * @param jwt JSON Web Token value (encoded as JWE).
17
- * @param key Private Key or Secret to decrypt and verify the JWT with.
18
- * @param options JWT Decryption and JWT Claims Set validation options.
12
+ * Verifies the JWT format (to be a JWE Compact format), decrypts the ciphertext, validates the JWT
13
+ * Claims Set.
19
14
  *
20
15
  * @example Usage
16
+ *
21
17
  * ```js
22
- * const jwt = 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..KVcNLqK-3-8ZkYIC.xSwF4VxO0kUMUD2W-cifsNUxnr-swyBq-nADBptyt6y9n79-iNc5b0AALJpRwc0wwDkJw8hNOMjApNUTMsK9b-asToZ3DXFMvwfJ6n1aWefvd7RsoZ2LInWFfVAuttJDzoGB.uuexQoWHwrLMEYRElT8pBQ'
18
+ * const jwt =
19
+ * 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..KVcNLqK-3-8ZkYIC.xSwF4VxO0kUMUD2W-cifsNUxnr-swyBq-nADBptyt6y9n79-iNc5b0AALJpRwc0wwDkJw8hNOMjApNUTMsK9b-asToZ3DXFMvwfJ6n1aWefvd7RsoZ2LInWFfVAuttJDzoGB.uuexQoWHwrLMEYRElT8pBQ'
23
20
  *
24
21
  * const { payload, protectedHeader } = await jose.jwtDecrypt(jwt, secretKey, {
25
22
  * issuer: 'urn:example:issuer',
26
- * audience: 'urn:example:audience'
23
+ * audience: 'urn:example:audience',
27
24
  * })
28
25
  *
29
26
  * console.log(protectedHeader)
30
27
  * console.log(payload)
31
28
  * ```
29
+ *
30
+ * @param jwt JSON Web Token value (encoded as JWE).
31
+ * @param key Private Key or Secret to decrypt and verify the JWT with.
32
+ * @param options JWT Decryption and JWT Claims Set validation options.
32
33
  */
33
34
  export declare function jwtDecrypt(jwt: string | Uint8Array, key: KeyLike | Uint8Array, options?: JWTDecryptOptions): Promise<JWTDecryptResult>;
34
35
  /**
@@ -4,6 +4,7 @@ import { ProduceJWT } from './produce';
4
4
  * The EncryptJWT class is a utility for creating Compact JWE formatted JWT strings.
5
5
  *
6
6
  * @example Usage
7
+ *
7
8
  * ```js
8
9
  * const jwt = await new jose.EncryptJWT({ 'urn:example:claim': true })
9
10
  * .setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })
@@ -27,39 +28,35 @@ export declare class EncryptJWT extends ProduceJWT {
27
28
  /**
28
29
  * Sets the JWE Protected Header on the EncryptJWT object.
29
30
  *
30
- * @param protectedHeader JWE Protected Header.
31
- * Must contain an "alg" (JWE Algorithm) and "enc" (JWE
32
- * Encryption Algorithm) properties.
31
+ * @param protectedHeader JWE Protected Header. Must contain an "alg" (JWE Algorithm) and "enc"
32
+ * (JWE Encryption Algorithm) properties.
33
33
  */
34
34
  setProtectedHeader(protectedHeader: CompactJWEHeaderParameters): this;
35
35
  /**
36
- * Sets the JWE Key Management parameters to be used when encrypting.
37
- * Use of this is method is really only needed for ECDH based algorithms
38
- * when utilizing the Agreement PartyUInfo or Agreement PartyVInfo parameters.
39
- * Other parameters will always be randomly generated when needed and missing.
36
+ * Sets the JWE Key Management parameters to be used when encrypting. Use of this is method is
37
+ * really only needed for ECDH based algorithms when utilizing the Agreement PartyUInfo or
38
+ * Agreement PartyVInfo parameters. Other parameters will always be randomly generated when needed
39
+ * and missing.
40
40
  *
41
41
  * @param parameters JWE Key Management parameters.
42
42
  */
43
43
  setKeyManagementParameters(parameters: JWEKeyManagementHeaderParameters): this;
44
44
  /**
45
- * Sets a content encryption key to use, by default a random suitable one
46
- * is generated for the JWE enc" (Encryption Algorithm) Header Parameter.
45
+ * Sets a content encryption key to use, by default a random suitable one is generated for the JWE
46
+ * enc" (Encryption Algorithm) Header Parameter.
47
47
  *
48
+ * @deprecated You should not use this method. It is only really intended for test and vector
49
+ * validation purposes.
48
50
  * @param cek JWE Content Encryption Key.
49
- *
50
- * @deprecated You should not use this method. It is only really intended
51
- * for test and vector validation purposes.
52
51
  */
53
52
  setContentEncryptionKey(cek: Uint8Array): this;
54
53
  /**
55
- * Sets the JWE Initialization Vector to use for content encryption, by default
56
- * a random suitable one is generated for the JWE enc" (Encryption Algorithm)
57
- * Header Parameter.
54
+ * Sets the JWE Initialization Vector to use for content encryption, by default a random suitable
55
+ * one is generated for the JWE enc" (Encryption Algorithm) Header Parameter.
58
56
  *
57
+ * @deprecated You should not use this method. It is only really intended for test and vector
58
+ * validation purposes.
59
59
  * @param iv JWE Initialization Vector.
60
- *
61
- * @deprecated You should not use this method. It is only really intended
62
- * for test and vector validation purposes.
63
60
  */
64
61
  setInitializationVector(iv: Uint8Array): this;
65
62
  /**
@@ -1,12 +1,8 @@
1
1
  import type { JWTPayload } from '../types';
2
- /**
3
- * Generic class for JWT producing.
4
- */
2
+ /** Generic class for JWT producing. */
5
3
  export declare class ProduceJWT {
6
4
  protected _payload: JWTPayload;
7
- /**
8
- * @param payload The JWT Claims Set object.
9
- */
5
+ /** @param payload The JWT Claims Set object. */
10
6
  constructor(payload: JWTPayload);
11
7
  /**
12
8
  * Set "iss" (Issuer) Claim.
@@ -35,24 +31,23 @@ export declare class ProduceJWT {
35
31
  /**
36
32
  * Set "nbf" (Not Before) Claim.
37
33
  *
38
- * @param input "nbf" (Not Before) Claim value to set on the JWT Claims Set.
39
- * When number is passed that is used as a value, when string is passed
40
- * it is resolved to a time span and added to the current timestamp.
34
+ * @param input "nbf" (Not Before) Claim value to set on the JWT Claims Set. When number is passed
35
+ * that is used as a value, when string is passed it is resolved to a time span and added to the
36
+ * current timestamp.
41
37
  */
42
38
  setNotBefore(input: number | string): this;
43
39
  /**
44
40
  * Set "exp" (Expiration Time) Claim.
45
41
  *
46
- * @param input "exp" (Expiration Time) Claim value to set on the JWT Claims Set.
47
- * When number is passed that is used as a value, when string is passed
48
- * it is resolved to a time span and added to the current timestamp.
42
+ * @param input "exp" (Expiration Time) Claim value to set on the JWT Claims Set. When number is
43
+ * passed that is used as a value, when string is passed it is resolved to a time span and added
44
+ * to the current timestamp.
49
45
  */
50
46
  setExpirationTime(input: number | string): this;
51
47
  /**
52
48
  * Set "iat" (Issued At) Claim.
53
49
  *
54
- * @param input "iat" (Issued At) Claim value to set on the JWT Claims Set.
55
- * Default is current timestamp.
50
+ * @param input "iat" (Issued At) Claim value to set on the JWT Claims Set. Default is current timestamp.
56
51
  */
57
52
  setIssuedAt(input?: number): this;
58
53
  }
@@ -4,6 +4,7 @@ import { ProduceJWT } from './produce';
4
4
  * The SignJWT class is a utility for creating Compact JWS formatted JWT strings.
5
5
  *
6
6
  * @example Usage
7
+ *
7
8
  * ```js
8
9
  * const jwt = await new jose.SignJWT({ 'urn:example:claim': true })
9
10
  * .setProtectedHeader({ alg: 'ES256' })
@@ -21,8 +22,7 @@ export declare class SignJWT extends ProduceJWT {
21
22
  /**
22
23
  * Sets the JWS Protected Header on the SignJWT object.
23
24
  *
24
- * @param protectedHeader JWS Protected Header.
25
- * Must contain an "alg" (JWS Algorithm) property.
25
+ * @param protectedHeader JWS Protected Header. Must contain an "alg" (JWS Algorithm) property.
26
26
  */
27
27
  setProtectedHeader(protectedHeader: JWTHeaderParameters): this;
28
28
  /**
@@ -8,6 +8,7 @@ export interface UnsecuredResult {
8
8
  * The UnsecuredJWT class is a utility for dealing with `{ "alg": "none" }` Unsecured JWTs.
9
9
  *
10
10
  * @example Encoding
11
+ *
11
12
  * ```js
12
13
  * const unsecuredJwt = new jose.UnsecuredJWT({ 'urn:example:claim': true })
13
14
  * .setIssuedAt()
@@ -20,19 +21,18 @@ export interface UnsecuredResult {
20
21
  * ```
21
22
  *
22
23
  * @example Decoding
24
+ *
23
25
  * ```js
24
26
  * const payload = jose.UnsecuredJWT.decode(jwt, {
25
27
  * issuer: 'urn:example:issuer',
26
- * audience: 'urn:example:audience'
28
+ * audience: 'urn:example:audience',
27
29
  * })
28
30
  *
29
31
  * console.log(payload)
30
32
  * ```
31
33
  */
32
34
  export declare class UnsecuredJWT extends ProduceJWT {
33
- /**
34
- * Encodes the Unsecured JWT.
35
- */
35
+ /** Encodes the Unsecured JWT. */
36
36
  encode(): string;
37
37
  /**
38
38
  * Decodes an unsecured JWT.