jose 4.10.0 → 4.10.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.
package/README.md
CHANGED
|
@@ -96,31 +96,6 @@ import * as jose from 'https://deno.land/x/jose/index.ts'
|
|
|
96
96
|
| [v4.x](https://github.com/panva/jose/tree/v4.x) | ✅ | ✅ | ✅ |
|
|
97
97
|
| [v3.x](https://github.com/panva/jose/tree/v3.x), [v2.x](https://github.com/panva/jose/tree/v2.x), [v1.x](https://github.com/panva/jose/tree/v1.x) | ✅ | ❌ | ❌ |
|
|
98
98
|
|
|
99
|
-
#### Semver?
|
|
100
|
-
|
|
101
|
-
**Yes.** All module's public API is subject to [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html).
|
|
102
|
-
|
|
103
|
-
#### How is it different from [`jws`](https://github.com/brianloveswords/node-jws), [`jwa`](https://github.com/brianloveswords/node-jwa) or [`jsonwebtoken`](https://github.com/auth0/node-jsonwebtoken)?
|
|
104
|
-
|
|
105
|
-
- it supports Browser, Deno, Cloudflare Workers, and other Web-interoperable runtimes
|
|
106
|
-
- it supports encrypted JWTs (i.e. in JWE format)
|
|
107
|
-
- supports secp256k1, Ed25519, Ed448, X25519, and X448
|
|
108
|
-
- it supports JWK Key Format for all four key types (oct, RSA, EC and OKP)
|
|
109
|
-
- it is exclusively using native platform Key object representations (CryptoKey and KeyObject)
|
|
110
|
-
- there is JSON Web Encryption support
|
|
111
|
-
- it supports the General and Flattened JSON Serialization Syntaxes
|
|
112
|
-
- it supports the "crit" member validations to make sure extensions are handled correctly
|
|
113
|
-
|
|
114
|
-
#### How is it different from [`node-jose`](https://github.com/cisco/node-jose)?
|
|
115
|
-
|
|
116
|
-
`node-jose` is built to work in any javascript runtime, to be able to do that it packs a lot of
|
|
117
|
-
polyfills and javascript implementation code in the form of
|
|
118
|
-
[`node-forge`](https://github.com/digitalbazaar/forge), this significantly increases the footprint
|
|
119
|
-
of the modules with dependencies that either aren't ever used or have native implementation available
|
|
120
|
-
in the runtime already, those are often times faster and more reliable.
|
|
121
|
-
|
|
122
|
-
- supports secp256k1, Ed25519, Ed448, X25519, and X448
|
|
123
|
-
|
|
124
99
|
#### Uint8Array?!
|
|
125
100
|
|
|
126
101
|
- Whenever `Uint8Array` is a valid input, so is [`Buffer`](https://nodejs.org/api/buffer.html#buffer_buffer) since buffers are instances of Uint8Array.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { JWK } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* Calculates a base64url-encoded JSON Web Key (JWK) Thumbprint
|
|
4
|
-
* [RFC7638](https://www.rfc-editor.org/rfc/rfc7638).
|
|
3
|
+
* Calculates a base64url-encoded JSON Web Key (JWK) Thumbprint
|
|
5
4
|
*
|
|
6
5
|
* @example Usage
|
|
7
6
|
*
|
|
@@ -18,11 +17,13 @@ import type { JWK } from '../types';
|
|
|
18
17
|
* ```
|
|
19
18
|
*
|
|
20
19
|
* @param jwk JSON Web Key.
|
|
21
|
-
* @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
|
|
20
|
+
* @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
|
|
21
|
+
* "sha256".
|
|
22
|
+
* @see [RFC7638](https://www.rfc-editor.org/rfc/rfc7638)
|
|
22
23
|
*/
|
|
23
24
|
export declare function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
|
|
24
25
|
/**
|
|
25
|
-
* Calculates a JSON Web Key (JWK) Thumbprint URI
|
|
26
|
+
* Calculates a JSON Web Key (JWK) Thumbprint URI
|
|
26
27
|
*
|
|
27
28
|
* @example Usage
|
|
28
29
|
*
|
|
@@ -39,6 +40,8 @@ export declare function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: 'sha2
|
|
|
39
40
|
* ```
|
|
40
41
|
*
|
|
41
42
|
* @param jwk JSON Web Key.
|
|
42
|
-
* @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
|
|
43
|
+
* @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
|
|
44
|
+
* "sha256".
|
|
45
|
+
* @see [RFC9278](https://www.rfc-editor.org/rfc/rfc9278)
|
|
43
46
|
*/
|
|
44
47
|
export declare function calculateJwkThumbprintUri(jwk: JWK, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
|
|
@@ -11,7 +11,10 @@ export interface RemoteJWKSetOptions {
|
|
|
11
11
|
* successful fetch. Default is 30000 (30 seconds).
|
|
12
12
|
*/
|
|
13
13
|
cooldownDuration?: number;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Maximum time (in milliseconds) between successful HTTP requests. Default is 600000 (10
|
|
16
|
+
* minutes).
|
|
17
|
+
*/
|
|
15
18
|
cacheMaxAge?: number | typeof Infinity;
|
|
16
19
|
/**
|
|
17
20
|
* An instance of [http.Agent](https://nodejs.org/api/http.html#class-httpagent) or
|
|
@@ -25,14 +28,12 @@ export interface RemoteJWKSetOptions {
|
|
|
25
28
|
/** Optional headers to be sent with the HTTP request. */
|
|
26
29
|
headers?: Record<string, string>;
|
|
27
30
|
}
|
|
28
|
-
interface URL {
|
|
29
|
-
href: string;
|
|
30
|
-
}
|
|
31
31
|
/**
|
|
32
32
|
* Returns a function that resolves to a key object downloaded from a remote endpoint returning a
|
|
33
33
|
* JSON Web Key Set, that is, for example, an OAuth 2.0 or OIDC jwks_uri. Only a single public key
|
|
34
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
|
|
35
|
+
* selection process but only as frequently as the `cooldownDuration` option allows, to prevent
|
|
36
|
+
* abuse.
|
|
36
37
|
*
|
|
37
38
|
* @example Usage
|
|
38
39
|
*
|
|
@@ -51,4 +52,3 @@ interface URL {
|
|
|
51
52
|
* @param options Options for the remote JSON Web Key Set.
|
|
52
53
|
*/
|
|
53
54
|
export declare function createRemoteJWKSet(url: URL, options?: RemoteJWKSetOptions): GetKeyFunction<JWSHeaderParameters, FlattenedJWSInput>;
|
|
54
|
-
export {};
|
|
@@ -47,7 +47,8 @@ export declare class ProduceJWT {
|
|
|
47
47
|
/**
|
|
48
48
|
* Set "iat" (Issued At) Claim.
|
|
49
49
|
*
|
|
50
|
-
* @param input "iat" (Issued At) Claim value to set on the JWT Claims Set. Default is current
|
|
50
|
+
* @param input "iat" (Issued At) Claim value to set on the JWT Claims Set. Default is current
|
|
51
|
+
* timestamp.
|
|
51
52
|
*/
|
|
52
53
|
setIssuedAt(input?: number): this;
|
|
53
54
|
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -368,7 +368,7 @@ export interface CritOption {
|
|
|
368
368
|
* for those is either `true` or `false`. `true` when the Header Parameter MUST be integrity
|
|
369
369
|
* protected, `false` when it's irrelevant.
|
|
370
370
|
*
|
|
371
|
-
* This makes the "Extension Header Parameter "
|
|
371
|
+
* This makes the "Extension Header Parameter "..." is not recognized" error go away.
|
|
372
372
|
*
|
|
373
373
|
* Use this when a given JWS/JWT/JWE profile requires the use of proprietary non-registered "crit"
|
|
374
374
|
* (Critical) Header Parameters. This will only make sure the Header Parameter is syntactically
|
|
@@ -378,7 +378,8 @@ export interface CritOption {
|
|
|
378
378
|
* the operation succeeds.
|
|
379
379
|
*
|
|
380
380
|
* The JWS extension Header Parameter `b64` is always recognized and processed properly. No other
|
|
381
|
-
* registered Header Parameters that need this kind of default built-in treatment are currently
|
|
381
|
+
* registered Header Parameters that need this kind of default built-in treatment are currently
|
|
382
|
+
* available.
|
|
382
383
|
*/
|
|
383
384
|
crit?: {
|
|
384
385
|
[propName: string]: boolean
|
|
@@ -460,7 +461,8 @@ export interface JWTClaimVerificationOptions {
|
|
|
460
461
|
export interface VerifyOptions extends CritOption {
|
|
461
462
|
/**
|
|
462
463
|
* A list of accepted JWS "alg" (Algorithm) Header Parameter values. By default all "alg"
|
|
463
|
-
* (Algorithm) values applicable for the used key/secret are allowed. Note: "none" is never
|
|
464
|
+
* (Algorithm) values applicable for the used key/secret are allowed. Note: "none" is never
|
|
465
|
+
* accepted.
|
|
464
466
|
*/
|
|
465
467
|
algorithms?: string[]
|
|
466
468
|
}
|
|
@@ -470,25 +472,49 @@ export interface SignOptions extends CritOption {}
|
|
|
470
472
|
|
|
471
473
|
/** Recognized JWT Claims Set members, any other members may also be present. */
|
|
472
474
|
export interface JWTPayload {
|
|
473
|
-
/**
|
|
475
|
+
/**
|
|
476
|
+
* JWT Issuer
|
|
477
|
+
*
|
|
478
|
+
* @see [RFC7519#section-4.1.1](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.1)
|
|
479
|
+
*/
|
|
474
480
|
iss?: string
|
|
475
481
|
|
|
476
|
-
/**
|
|
482
|
+
/**
|
|
483
|
+
* JWT Subject
|
|
484
|
+
*
|
|
485
|
+
* @see [RFC7519#section-4.1.2](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.2)
|
|
486
|
+
*/
|
|
477
487
|
sub?: string
|
|
478
488
|
|
|
479
489
|
/** JWT Audience [RFC7519#section-4.1.3](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.3). */
|
|
480
490
|
aud?: string | string[]
|
|
481
491
|
|
|
482
|
-
/**
|
|
492
|
+
/**
|
|
493
|
+
* JWT ID
|
|
494
|
+
*
|
|
495
|
+
* @see [RFC7519#section-4.1.7](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.7)
|
|
496
|
+
*/
|
|
483
497
|
jti?: string
|
|
484
498
|
|
|
485
|
-
/**
|
|
499
|
+
/**
|
|
500
|
+
* JWT Not Before
|
|
501
|
+
*
|
|
502
|
+
* @see [RFC7519#section-4.1.5](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.5)
|
|
503
|
+
*/
|
|
486
504
|
nbf?: number
|
|
487
505
|
|
|
488
|
-
/**
|
|
506
|
+
/**
|
|
507
|
+
* JWT Expiration Time
|
|
508
|
+
*
|
|
509
|
+
* @see [RFC7519#section-4.1.4](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4)
|
|
510
|
+
*/
|
|
489
511
|
exp?: number
|
|
490
512
|
|
|
491
|
-
/**
|
|
513
|
+
/**
|
|
514
|
+
* JWT Issued At
|
|
515
|
+
*
|
|
516
|
+
* @see [RFC7519#section-4.1.6](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.6)
|
|
517
|
+
*/
|
|
492
518
|
iat?: number
|
|
493
519
|
|
|
494
520
|
/** Any other JWT Claim Set member. */
|
package/package.json
CHANGED