jose 5.9.3 → 5.9.5
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 +43 -31
- package/dist/browser/jwks/remote.js +1 -1
- package/dist/browser/util/errors.js +29 -64
- package/dist/node/cjs/jwe/compact/decrypt.js +1 -2
- package/dist/node/cjs/jwe/flattened/decrypt.js +1 -2
- package/dist/node/cjs/jwe/general/decrypt.js +1 -2
- package/dist/node/cjs/jwk/embedded.js +1 -2
- package/dist/node/cjs/jwk/thumbprint.js +2 -3
- package/dist/node/cjs/jwks/local.js +1 -2
- package/dist/node/cjs/jwks/remote.js +3 -3
- package/dist/node/cjs/jws/compact/verify.js +1 -2
- package/dist/node/cjs/jws/flattened/verify.js +1 -2
- package/dist/node/cjs/jws/general/verify.js +1 -2
- package/dist/node/cjs/jwt/decrypt.js +1 -2
- package/dist/node/cjs/jwt/verify.js +1 -2
- package/dist/node/cjs/key/export.js +3 -4
- package/dist/node/cjs/key/generate_key_pair.js +1 -2
- package/dist/node/cjs/key/generate_secret.js +1 -2
- package/dist/node/cjs/key/import.js +4 -5
- package/dist/node/cjs/lib/aesgcmkw.js +2 -3
- package/dist/node/cjs/lib/buffer_utils.js +7 -7
- package/dist/node/cjs/lib/cek.js +1 -2
- package/dist/node/cjs/lib/check_p2s.js +1 -1
- package/dist/node/cjs/lib/crypto_key.js +2 -3
- package/dist/node/cjs/lib/invalid_key_input.js +1 -2
- package/dist/node/cjs/lib/is_jwk.js +4 -5
- package/dist/node/cjs/lib/is_object.js +1 -1
- package/dist/node/cjs/lib/iv.js +1 -2
- package/dist/node/cjs/runtime/cbc_tag.js +1 -1
- package/dist/node/cjs/runtime/dsa_digest.js +1 -1
- package/dist/node/cjs/runtime/ecdhes.js +3 -3
- package/dist/node/cjs/runtime/generate.js +2 -3
- package/dist/node/cjs/runtime/get_sign_verify_key.js +1 -1
- package/dist/node/cjs/runtime/hmac_digest.js +1 -1
- package/dist/node/cjs/runtime/node_key.js +1 -1
- package/dist/node/cjs/util/decode_jwt.js +1 -2
- package/dist/node/cjs/util/decode_protected_header.js +1 -2
- package/dist/node/cjs/util/errors.js +34 -54
- package/dist/node/esm/jwks/remote.js +1 -1
- package/dist/node/esm/util/errors.js +34 -54
- package/dist/types/jwks/remote.d.ts +2 -2
- package/dist/types/util/errors.d.ts +39 -21
- package/package.json +151 -211
package/README.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
`jose` is JavaScript module for JSON Object Signing and Encryption, providing support for JSON Web Tokens (JWT), JSON Web Signature (JWS), JSON Web Encryption (JWE), JSON Web Key (JWK), JSON Web Key Set (JWKS), and more. The module is designed to work across various Web-interoperable runtimes including Node.js, browsers, Cloudflare Workers, Deno, Bun, and others.
|
|
4
4
|
|
|
5
|
+
## Sponsor
|
|
6
|
+
|
|
7
|
+
<picture>
|
|
8
|
+
<source media="(prefers-color-scheme: dark)" srcset="./sponsor/Auth0byOkta_dark.png">
|
|
9
|
+
<source media="(prefers-color-scheme: light)" srcset="./sponsor/Auth0byOkta_light.png">
|
|
10
|
+
<img height="65" align="left" alt="Auth0 by Okta" src="./sponsor/Auth0byOkta_light.png">
|
|
11
|
+
</picture>
|
|
12
|
+
|
|
13
|
+
If you want to quickly add JWT authentication to JavaScript apps, feel free to check out Auth0's JavaScript SDK and free plan. [Create an Auth0 account; it's free!][sponsor-auth0]<br><br>
|
|
14
|
+
|
|
5
15
|
## [💗 Help the project](https://github.com/sponsors/panva)
|
|
6
16
|
|
|
7
17
|
Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).
|
|
@@ -28,69 +38,69 @@ const jose = require('jose')
|
|
|
28
38
|
|
|
29
39
|
The `jose` module supports JSON Web Tokens (JWT) and provides functionality for signing and verifying tokens, as well as their JWT Claims Set validation.
|
|
30
40
|
|
|
31
|
-
- [JWT Claims Set Validation & Signature Verification](docs/functions/
|
|
32
|
-
- [Using a remote JSON Web Key Set (JWKS)](docs/functions/
|
|
33
|
-
- [Using a local JSON Web Key Set (JWKS)](docs/functions/
|
|
34
|
-
- [Signing](docs/classes/
|
|
41
|
+
- [JWT Claims Set Validation & Signature Verification](docs/jwt/verify/functions/jwtVerify.md) using the `jwtVerify` function
|
|
42
|
+
- [Using a remote JSON Web Key Set (JWKS)](docs/jwks/remote/functions/createRemoteJWKSet.md)
|
|
43
|
+
- [Using a local JSON Web Key Set (JWKS)](docs/jwks/local/functions/createLocalJWKSet.md)
|
|
44
|
+
- [Signing](docs/jwt/sign/classes/SignJWT.md) using the `SignJWT` class
|
|
35
45
|
- Utility functions
|
|
36
|
-
- [Decoding Token's Protected Header](docs/functions/
|
|
37
|
-
- [Decoding JWT Claims Set](docs/functions/
|
|
46
|
+
- [Decoding Token's Protected Header](docs/util/decode_protected_header/functions/decodeProtectedHeader.md)
|
|
47
|
+
- [Decoding JWT Claims Set](docs/util/decode_jwt/functions/decodeJwt.md) prior to its validation
|
|
38
48
|
|
|
39
49
|
### Encrypted JSON Web Tokens
|
|
40
50
|
|
|
41
51
|
The `jose` module supports encrypted JSON Web Tokens and provides functionality for encrypting and decrypting tokens, as well as their JWT Claims Set validation.
|
|
42
52
|
|
|
43
|
-
- [Decryption & JWT Claims Set Validation](docs/functions/
|
|
44
|
-
- [Encryption](docs/classes/
|
|
53
|
+
- [Decryption & JWT Claims Set Validation](docs/jwt/decrypt/functions/jwtDecrypt.md) using the `jwtDecrypt` function
|
|
54
|
+
- [Encryption](docs/jwt/encrypt/classes/EncryptJWT.md) using the `EncryptJWT` class
|
|
45
55
|
- Utility functions
|
|
46
|
-
- [Decoding Token's Protected Header](docs/functions/
|
|
56
|
+
- [Decoding Token's Protected Header](docs/util/decode_protected_header/functions/decodeProtectedHeader.md)
|
|
47
57
|
|
|
48
58
|
### Key Utilities
|
|
49
59
|
|
|
50
60
|
The `jose` module supports importing, exporting, and generating keys and secrets in various formats, including PEM formats like SPKI, X.509 certificate, and PKCS #8, as well as JSON Web Key (JWK).
|
|
51
61
|
|
|
52
62
|
- Key Import Functions
|
|
53
|
-
- [JWK Import](docs/functions/
|
|
54
|
-
- [Public Key Import (SPKI)](docs/functions/
|
|
55
|
-
- [Public Key Import (X.509 Certificate)](docs/functions/
|
|
56
|
-
- [Private Key Import (PKCS #8)](docs/functions/
|
|
63
|
+
- [JWK Import](docs/key/import/functions/importJWK.md)
|
|
64
|
+
- [Public Key Import (SPKI)](docs/key/import/functions/importSPKI.md)
|
|
65
|
+
- [Public Key Import (X.509 Certificate)](docs/key/import/functions/importX509.md)
|
|
66
|
+
- [Private Key Import (PKCS #8)](docs/key/import/functions/importPKCS8.md)
|
|
57
67
|
- Key and Secret Generation Functions
|
|
58
|
-
- [Asymmetric Key Pair Generation](docs/functions/
|
|
59
|
-
- [Symmetric Secret Generation](docs/functions/
|
|
68
|
+
- [Asymmetric Key Pair Generation](docs/key/generate_key_pair/functions/generateKeyPair.md)
|
|
69
|
+
- [Symmetric Secret Generation](docs/key/generate_secret/functions/generateSecret.md)
|
|
60
70
|
- Key Export Functions
|
|
61
|
-
- [JWK Export](docs/functions/
|
|
62
|
-
- [Private Key Export](docs/functions/
|
|
63
|
-
- [Public Key Export](docs/functions/
|
|
71
|
+
- [JWK Export](docs/key/export/functions/exportJWK.md)
|
|
72
|
+
- [Private Key Export](docs/key/export/functions/exportPKCS8.md)
|
|
73
|
+
- [Public Key Export](docs/key/export/functions/exportSPKI.md)
|
|
64
74
|
|
|
65
75
|
### JSON Web Signature (JWS)
|
|
66
76
|
|
|
67
77
|
The `jose` module supports signing and verification of JWS messages with arbitrary payloads in Compact, Flattened JSON, and General JSON serialization syntaxes.
|
|
68
78
|
|
|
69
|
-
- Signing - [Compact](docs/classes/
|
|
70
|
-
- Verification - [Compact](docs/functions/
|
|
71
|
-
- [Using a remote JSON Web Key Set (JWKS)](docs/functions/
|
|
72
|
-
- [Using a local JSON Web Key Set (JWKS)](docs/functions/
|
|
79
|
+
- Signing - [Compact](docs/jws/compact/sign/classes/CompactSign.md), [Flattened JSON](docs/jws/flattened/sign/classes/FlattenedSign.md), [General JSON](docs/jws/general/sign/classes/GeneralSign.md)
|
|
80
|
+
- Verification - [Compact](docs/jws/compact/verify/functions/compactVerify.md), [Flattened JSON](docs/jws/flattened/verify/functions/flattenedVerify.md), [General JSON](docs/jws/general/verify/functions/generalVerify.md)
|
|
81
|
+
- [Using a remote JSON Web Key Set (JWKS)](docs/jwks/remote/functions/createRemoteJWKSet.md)
|
|
82
|
+
- [Using a local JSON Web Key Set (JWKS)](docs/jwks/local/functions/createLocalJWKSet.md)
|
|
73
83
|
- Utility functions
|
|
74
|
-
- [Decoding Token's Protected Header](docs/functions/
|
|
84
|
+
- [Decoding Token's Protected Header](docs/util/decode_protected_header/functions/decodeProtectedHeader.md)
|
|
75
85
|
|
|
76
86
|
### JSON Web Encryption (JWE)
|
|
77
87
|
|
|
78
88
|
The `jose` module supports encryption and decryption of JWE messages with arbitrary plaintext in Compact, Flattened JSON, and General JSON serialization syntaxes.
|
|
79
89
|
|
|
80
|
-
- Encryption - [Compact](docs/classes/
|
|
81
|
-
- Decryption - [Compact](docs/functions/
|
|
90
|
+
- Encryption - [Compact](docs/jwe/compact/encrypt/classes/CompactEncrypt.md), [Flattened JSON](docs/jwe/flattened/encrypt/classes/FlattenedEncrypt.md), [General JSON](docs/jwe/general/encrypt/classes/GeneralEncrypt.md)
|
|
91
|
+
- Decryption - [Compact](docs/jwe/compact/decrypt/functions/compactDecrypt.md), [Flattened JSON](docs/jwe/flattened/decrypt/functions/flattenedDecrypt.md), [General JSON](docs/jwe/general/decrypt/functions/generalDecrypt.md)
|
|
82
92
|
- Utility functions
|
|
83
|
-
- [Decoding Token's Protected Header](docs/functions/
|
|
93
|
+
- [Decoding Token's Protected Header](docs/util/decode_protected_header/functions/decodeProtectedHeader.md)
|
|
84
94
|
|
|
85
95
|
### Other
|
|
86
96
|
|
|
87
97
|
The following are additional features and utilities provided by the `jose` module:
|
|
88
98
|
|
|
89
|
-
- [Calculating JWK Thumbprint](docs/functions/
|
|
90
|
-
- [Calculating JWK Thumbprint URI](docs/functions/
|
|
91
|
-
- [Verification using a JWK Embedded in a JWS Header](docs/functions/
|
|
92
|
-
- [Unsecured JWT](docs/classes/
|
|
93
|
-
- [JOSE Errors](docs/
|
|
99
|
+
- [Calculating JWK Thumbprint](docs/jwk/thumbprint/functions/calculateJwkThumbprint.md)
|
|
100
|
+
- [Calculating JWK Thumbprint URI](docs/jwk/thumbprint/functions/calculateJwkThumbprintUri.md)
|
|
101
|
+
- [Verification using a JWK Embedded in a JWS Header](docs/jwk/embedded/functions/EmbeddedJWK.md)
|
|
102
|
+
- [Unsecured JWT](docs/jwt/unsecured/classes/UnsecuredJWT.md)
|
|
103
|
+
- [JOSE Errors](docs/util/errors/README.md)
|
|
94
104
|
|
|
95
105
|
## Supported Runtimes
|
|
96
106
|
|
|
@@ -135,3 +145,5 @@ The algorithm implementations in `jose` have been tested using test vectors from
|
|
|
135
145
|
|
|
136
146
|
|
|
137
147
|
</details>
|
|
148
|
+
|
|
149
|
+
[sponsor-auth0]: https://auth0.com/signup?utm_source=external_sites&utm_medium=panva&utm_campaign=devn_signup
|
|
@@ -10,7 +10,7 @@ function isCloudflareWorkers() {
|
|
|
10
10
|
let USER_AGENT;
|
|
11
11
|
if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
|
|
12
12
|
const NAME = 'jose';
|
|
13
|
-
const VERSION = 'v5.9.
|
|
13
|
+
const VERSION = 'v5.9.5';
|
|
14
14
|
USER_AGENT = `${NAME}/${VERSION}`;
|
|
15
15
|
}
|
|
16
16
|
export const jwksCache = Symbol();
|
|
@@ -1,149 +1,114 @@
|
|
|
1
1
|
export class JOSEError extends Error {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
2
|
+
constructor(message, options) {
|
|
3
|
+
super(message, options);
|
|
7
4
|
this.code = 'ERR_JOSE_GENERIC';
|
|
8
5
|
this.name = this.constructor.name;
|
|
9
6
|
Error.captureStackTrace?.(this, this.constructor);
|
|
10
7
|
}
|
|
11
8
|
}
|
|
9
|
+
JOSEError.code = 'ERR_JOSE_GENERIC';
|
|
12
10
|
export class JWTClaimValidationFailed extends JOSEError {
|
|
13
|
-
static get code() {
|
|
14
|
-
return 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
15
|
-
}
|
|
16
11
|
constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {
|
|
17
|
-
super(message);
|
|
12
|
+
super(message, { cause: { claim, reason, payload } });
|
|
18
13
|
this.code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
19
14
|
this.claim = claim;
|
|
20
15
|
this.reason = reason;
|
|
21
16
|
this.payload = payload;
|
|
22
17
|
}
|
|
23
18
|
}
|
|
19
|
+
JWTClaimValidationFailed.code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
24
20
|
export class JWTExpired extends JOSEError {
|
|
25
|
-
static get code() {
|
|
26
|
-
return 'ERR_JWT_EXPIRED';
|
|
27
|
-
}
|
|
28
21
|
constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {
|
|
29
|
-
super(message);
|
|
22
|
+
super(message, { cause: { claim, reason, payload } });
|
|
30
23
|
this.code = 'ERR_JWT_EXPIRED';
|
|
31
24
|
this.claim = claim;
|
|
32
25
|
this.reason = reason;
|
|
33
26
|
this.payload = payload;
|
|
34
27
|
}
|
|
35
28
|
}
|
|
29
|
+
JWTExpired.code = 'ERR_JWT_EXPIRED';
|
|
36
30
|
export class JOSEAlgNotAllowed extends JOSEError {
|
|
37
31
|
constructor() {
|
|
38
32
|
super(...arguments);
|
|
39
33
|
this.code = 'ERR_JOSE_ALG_NOT_ALLOWED';
|
|
40
34
|
}
|
|
41
|
-
static get code() {
|
|
42
|
-
return 'ERR_JOSE_ALG_NOT_ALLOWED';
|
|
43
|
-
}
|
|
44
35
|
}
|
|
36
|
+
JOSEAlgNotAllowed.code = 'ERR_JOSE_ALG_NOT_ALLOWED';
|
|
45
37
|
export class JOSENotSupported extends JOSEError {
|
|
46
38
|
constructor() {
|
|
47
39
|
super(...arguments);
|
|
48
40
|
this.code = 'ERR_JOSE_NOT_SUPPORTED';
|
|
49
41
|
}
|
|
50
|
-
static get code() {
|
|
51
|
-
return 'ERR_JOSE_NOT_SUPPORTED';
|
|
52
|
-
}
|
|
53
42
|
}
|
|
43
|
+
JOSENotSupported.code = 'ERR_JOSE_NOT_SUPPORTED';
|
|
54
44
|
export class JWEDecryptionFailed extends JOSEError {
|
|
55
|
-
constructor() {
|
|
56
|
-
super(
|
|
45
|
+
constructor(message = 'decryption operation failed', options) {
|
|
46
|
+
super(message, options);
|
|
57
47
|
this.code = 'ERR_JWE_DECRYPTION_FAILED';
|
|
58
|
-
this.message = 'decryption operation failed';
|
|
59
|
-
}
|
|
60
|
-
static get code() {
|
|
61
|
-
return 'ERR_JWE_DECRYPTION_FAILED';
|
|
62
48
|
}
|
|
63
49
|
}
|
|
50
|
+
JWEDecryptionFailed.code = 'ERR_JWE_DECRYPTION_FAILED';
|
|
64
51
|
export class JWEInvalid extends JOSEError {
|
|
65
52
|
constructor() {
|
|
66
53
|
super(...arguments);
|
|
67
54
|
this.code = 'ERR_JWE_INVALID';
|
|
68
55
|
}
|
|
69
|
-
static get code() {
|
|
70
|
-
return 'ERR_JWE_INVALID';
|
|
71
|
-
}
|
|
72
56
|
}
|
|
57
|
+
JWEInvalid.code = 'ERR_JWE_INVALID';
|
|
73
58
|
export class JWSInvalid extends JOSEError {
|
|
74
59
|
constructor() {
|
|
75
60
|
super(...arguments);
|
|
76
61
|
this.code = 'ERR_JWS_INVALID';
|
|
77
62
|
}
|
|
78
|
-
static get code() {
|
|
79
|
-
return 'ERR_JWS_INVALID';
|
|
80
|
-
}
|
|
81
63
|
}
|
|
64
|
+
JWSInvalid.code = 'ERR_JWS_INVALID';
|
|
82
65
|
export class JWTInvalid extends JOSEError {
|
|
83
66
|
constructor() {
|
|
84
67
|
super(...arguments);
|
|
85
68
|
this.code = 'ERR_JWT_INVALID';
|
|
86
69
|
}
|
|
87
|
-
static get code() {
|
|
88
|
-
return 'ERR_JWT_INVALID';
|
|
89
|
-
}
|
|
90
70
|
}
|
|
71
|
+
JWTInvalid.code = 'ERR_JWT_INVALID';
|
|
91
72
|
export class JWKInvalid extends JOSEError {
|
|
92
73
|
constructor() {
|
|
93
74
|
super(...arguments);
|
|
94
75
|
this.code = 'ERR_JWK_INVALID';
|
|
95
76
|
}
|
|
96
|
-
static get code() {
|
|
97
|
-
return 'ERR_JWK_INVALID';
|
|
98
|
-
}
|
|
99
77
|
}
|
|
78
|
+
JWKInvalid.code = 'ERR_JWK_INVALID';
|
|
100
79
|
export class JWKSInvalid extends JOSEError {
|
|
101
80
|
constructor() {
|
|
102
81
|
super(...arguments);
|
|
103
82
|
this.code = 'ERR_JWKS_INVALID';
|
|
104
83
|
}
|
|
105
|
-
static get code() {
|
|
106
|
-
return 'ERR_JWKS_INVALID';
|
|
107
|
-
}
|
|
108
84
|
}
|
|
85
|
+
JWKSInvalid.code = 'ERR_JWKS_INVALID';
|
|
109
86
|
export class JWKSNoMatchingKey extends JOSEError {
|
|
110
|
-
constructor() {
|
|
111
|
-
super(
|
|
87
|
+
constructor(message = 'no applicable key found in the JSON Web Key Set', options) {
|
|
88
|
+
super(message, options);
|
|
112
89
|
this.code = 'ERR_JWKS_NO_MATCHING_KEY';
|
|
113
|
-
this.message = 'no applicable key found in the JSON Web Key Set';
|
|
114
|
-
}
|
|
115
|
-
static get code() {
|
|
116
|
-
return 'ERR_JWKS_NO_MATCHING_KEY';
|
|
117
90
|
}
|
|
118
91
|
}
|
|
92
|
+
JWKSNoMatchingKey.code = 'ERR_JWKS_NO_MATCHING_KEY';
|
|
119
93
|
export class JWKSMultipleMatchingKeys extends JOSEError {
|
|
120
|
-
constructor() {
|
|
121
|
-
super(
|
|
94
|
+
constructor(message = 'multiple matching keys found in the JSON Web Key Set', options) {
|
|
95
|
+
super(message, options);
|
|
122
96
|
this.code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
|
|
123
|
-
this.message = 'multiple matching keys found in the JSON Web Key Set';
|
|
124
|
-
}
|
|
125
|
-
static get code() {
|
|
126
|
-
return 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
|
|
127
97
|
}
|
|
128
98
|
}
|
|
129
99
|
Symbol.asyncIterator;
|
|
100
|
+
JWKSMultipleMatchingKeys.code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
|
|
130
101
|
export class JWKSTimeout extends JOSEError {
|
|
131
|
-
constructor() {
|
|
132
|
-
super(
|
|
102
|
+
constructor(message = 'request timed out', options) {
|
|
103
|
+
super(message, options);
|
|
133
104
|
this.code = 'ERR_JWKS_TIMEOUT';
|
|
134
|
-
this.message = 'request timed out';
|
|
135
|
-
}
|
|
136
|
-
static get code() {
|
|
137
|
-
return 'ERR_JWKS_TIMEOUT';
|
|
138
105
|
}
|
|
139
106
|
}
|
|
107
|
+
JWKSTimeout.code = 'ERR_JWKS_TIMEOUT';
|
|
140
108
|
export class JWSSignatureVerificationFailed extends JOSEError {
|
|
141
|
-
constructor() {
|
|
142
|
-
super(
|
|
109
|
+
constructor(message = 'signature verification failed', options) {
|
|
110
|
+
super(message, options);
|
|
143
111
|
this.code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
|
|
144
|
-
this.message = 'signature verification failed';
|
|
145
|
-
}
|
|
146
|
-
static get code() {
|
|
147
|
-
return 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
|
|
148
112
|
}
|
|
149
113
|
}
|
|
114
|
+
JWSSignatureVerificationFailed.code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compactDecrypt =
|
|
3
|
+
exports.compactDecrypt = compactDecrypt;
|
|
4
4
|
const decrypt_js_1 = require("../flattened/decrypt.js");
|
|
5
5
|
const errors_js_1 = require("../../util/errors.js");
|
|
6
6
|
const buffer_utils_js_1 = require("../../lib/buffer_utils.js");
|
|
@@ -28,4 +28,3 @@ async function compactDecrypt(jwe, key, options) {
|
|
|
28
28
|
}
|
|
29
29
|
return result;
|
|
30
30
|
}
|
|
31
|
-
exports.compactDecrypt = compactDecrypt;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.flattenedDecrypt =
|
|
3
|
+
exports.flattenedDecrypt = flattenedDecrypt;
|
|
4
4
|
const base64url_js_1 = require("../../runtime/base64url.js");
|
|
5
5
|
const decrypt_js_1 = require("../../runtime/decrypt.js");
|
|
6
6
|
const errors_js_1 = require("../../util/errors.js");
|
|
@@ -162,4 +162,3 @@ async function flattenedDecrypt(jwe, key, options) {
|
|
|
162
162
|
}
|
|
163
163
|
return result;
|
|
164
164
|
}
|
|
165
|
-
exports.flattenedDecrypt = flattenedDecrypt;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generalDecrypt =
|
|
3
|
+
exports.generalDecrypt = generalDecrypt;
|
|
4
4
|
const decrypt_js_1 = require("../flattened/decrypt.js");
|
|
5
5
|
const errors_js_1 = require("../../util/errors.js");
|
|
6
6
|
const is_object_js_1 = require("../../lib/is_object.js");
|
|
@@ -32,4 +32,3 @@ async function generalDecrypt(jwe, key, options) {
|
|
|
32
32
|
}
|
|
33
33
|
throw new errors_js_1.JWEDecryptionFailed();
|
|
34
34
|
}
|
|
35
|
-
exports.generalDecrypt = generalDecrypt;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EmbeddedJWK =
|
|
3
|
+
exports.EmbeddedJWK = EmbeddedJWK;
|
|
4
4
|
const import_js_1 = require("../key/import.js");
|
|
5
5
|
const is_object_js_1 = require("../lib/is_object.js");
|
|
6
6
|
const errors_js_1 = require("../util/errors.js");
|
|
@@ -18,4 +18,3 @@ async function EmbeddedJWK(protectedHeader, token) {
|
|
|
18
18
|
}
|
|
19
19
|
return key;
|
|
20
20
|
}
|
|
21
|
-
exports.EmbeddedJWK = EmbeddedJWK;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.calculateJwkThumbprint = calculateJwkThumbprint;
|
|
4
|
+
exports.calculateJwkThumbprintUri = calculateJwkThumbprintUri;
|
|
4
5
|
const digest_js_1 = require("../runtime/digest.js");
|
|
5
6
|
const base64url_js_1 = require("../runtime/base64url.js");
|
|
6
7
|
const errors_js_1 = require("../util/errors.js");
|
|
@@ -49,10 +50,8 @@ async function calculateJwkThumbprint(jwk, digestAlgorithm) {
|
|
|
49
50
|
const data = buffer_utils_js_1.encoder.encode(JSON.stringify(components));
|
|
50
51
|
return (0, base64url_js_1.encode)(await (0, digest_js_1.default)(digestAlgorithm, data));
|
|
51
52
|
}
|
|
52
|
-
exports.calculateJwkThumbprint = calculateJwkThumbprint;
|
|
53
53
|
async function calculateJwkThumbprintUri(jwk, digestAlgorithm) {
|
|
54
54
|
digestAlgorithm ??= 'sha256';
|
|
55
55
|
const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm);
|
|
56
56
|
return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;
|
|
57
57
|
}
|
|
58
|
-
exports.calculateJwkThumbprintUri = calculateJwkThumbprintUri;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createLocalJWKSet =
|
|
3
|
+
exports.createLocalJWKSet = createLocalJWKSet;
|
|
4
4
|
const import_js_1 = require("../key/import.js");
|
|
5
5
|
const errors_js_1 = require("../util/errors.js");
|
|
6
6
|
const is_object_js_1 = require("../lib/is_object.js");
|
|
@@ -123,4 +123,3 @@ function createLocalJWKSet(jwks) {
|
|
|
123
123
|
});
|
|
124
124
|
return localJWKSet;
|
|
125
125
|
}
|
|
126
|
-
exports.createLocalJWKSet = createLocalJWKSet;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.experimental_jwksCache = exports.
|
|
3
|
+
exports.experimental_jwksCache = exports.jwksCache = void 0;
|
|
4
|
+
exports.createRemoteJWKSet = createRemoteJWKSet;
|
|
4
5
|
const fetch_jwks_js_1 = require("../runtime/fetch_jwks.js");
|
|
5
6
|
const errors_js_1 = require("../util/errors.js");
|
|
6
7
|
const local_js_1 = require("./local.js");
|
|
@@ -13,7 +14,7 @@ function isCloudflareWorkers() {
|
|
|
13
14
|
let USER_AGENT;
|
|
14
15
|
if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
|
|
15
16
|
const NAME = 'jose';
|
|
16
|
-
const VERSION = 'v5.9.
|
|
17
|
+
const VERSION = 'v5.9.5';
|
|
17
18
|
USER_AGENT = `${NAME}/${VERSION}`;
|
|
18
19
|
}
|
|
19
20
|
exports.jwksCache = Symbol();
|
|
@@ -148,5 +149,4 @@ function createRemoteJWKSet(url, options) {
|
|
|
148
149
|
});
|
|
149
150
|
return remoteJWKSet;
|
|
150
151
|
}
|
|
151
|
-
exports.createRemoteJWKSet = createRemoteJWKSet;
|
|
152
152
|
exports.experimental_jwksCache = exports.jwksCache;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compactVerify =
|
|
3
|
+
exports.compactVerify = compactVerify;
|
|
4
4
|
const verify_js_1 = require("../flattened/verify.js");
|
|
5
5
|
const errors_js_1 = require("../../util/errors.js");
|
|
6
6
|
const buffer_utils_js_1 = require("../../lib/buffer_utils.js");
|
|
@@ -22,4 +22,3 @@ async function compactVerify(jws, key, options) {
|
|
|
22
22
|
}
|
|
23
23
|
return result;
|
|
24
24
|
}
|
|
25
|
-
exports.compactVerify = compactVerify;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.flattenedVerify =
|
|
3
|
+
exports.flattenedVerify = flattenedVerify;
|
|
4
4
|
const base64url_js_1 = require("../../runtime/base64url.js");
|
|
5
5
|
const verify_js_1 = require("../../runtime/verify.js");
|
|
6
6
|
const errors_js_1 = require("../../util/errors.js");
|
|
@@ -123,4 +123,3 @@ async function flattenedVerify(jws, key, options) {
|
|
|
123
123
|
}
|
|
124
124
|
return result;
|
|
125
125
|
}
|
|
126
|
-
exports.flattenedVerify = flattenedVerify;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generalVerify =
|
|
3
|
+
exports.generalVerify = generalVerify;
|
|
4
4
|
const verify_js_1 = require("../flattened/verify.js");
|
|
5
5
|
const errors_js_1 = require("../../util/errors.js");
|
|
6
6
|
const is_object_js_1 = require("../../lib/is_object.js");
|
|
@@ -25,4 +25,3 @@ async function generalVerify(jws, key, options) {
|
|
|
25
25
|
}
|
|
26
26
|
throw new errors_js_1.JWSSignatureVerificationFailed();
|
|
27
27
|
}
|
|
28
|
-
exports.generalVerify = generalVerify;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jwtDecrypt =
|
|
3
|
+
exports.jwtDecrypt = jwtDecrypt;
|
|
4
4
|
const decrypt_js_1 = require("../jwe/compact/decrypt.js");
|
|
5
5
|
const jwt_claims_set_js_1 = require("../lib/jwt_claims_set.js");
|
|
6
6
|
const errors_js_1 = require("../util/errors.js");
|
|
@@ -24,4 +24,3 @@ async function jwtDecrypt(jwt, key, options) {
|
|
|
24
24
|
}
|
|
25
25
|
return result;
|
|
26
26
|
}
|
|
27
|
-
exports.jwtDecrypt = jwtDecrypt;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jwtVerify =
|
|
3
|
+
exports.jwtVerify = jwtVerify;
|
|
4
4
|
const verify_js_1 = require("../jws/compact/verify.js");
|
|
5
5
|
const jwt_claims_set_js_1 = require("../lib/jwt_claims_set.js");
|
|
6
6
|
const errors_js_1 = require("../util/errors.js");
|
|
@@ -16,4 +16,3 @@ async function jwtVerify(jwt, key, options) {
|
|
|
16
16
|
}
|
|
17
17
|
return result;
|
|
18
18
|
}
|
|
19
|
-
exports.jwtVerify = jwtVerify;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.exportSPKI = exportSPKI;
|
|
4
|
+
exports.exportPKCS8 = exportPKCS8;
|
|
5
|
+
exports.exportJWK = exportJWK;
|
|
4
6
|
const asn1_js_1 = require("../runtime/asn1.js");
|
|
5
7
|
const asn1_js_2 = require("../runtime/asn1.js");
|
|
6
8
|
const key_to_jwk_js_1 = require("../runtime/key_to_jwk.js");
|
|
7
9
|
async function exportSPKI(key) {
|
|
8
10
|
return (0, asn1_js_1.toSPKI)(key);
|
|
9
11
|
}
|
|
10
|
-
exports.exportSPKI = exportSPKI;
|
|
11
12
|
async function exportPKCS8(key) {
|
|
12
13
|
return (0, asn1_js_2.toPKCS8)(key);
|
|
13
14
|
}
|
|
14
|
-
exports.exportPKCS8 = exportPKCS8;
|
|
15
15
|
async function exportJWK(key) {
|
|
16
16
|
return (0, key_to_jwk_js_1.default)(key);
|
|
17
17
|
}
|
|
18
|
-
exports.exportJWK = exportJWK;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateKeyPair =
|
|
3
|
+
exports.generateKeyPair = generateKeyPair;
|
|
4
4
|
const generate_js_1 = require("../runtime/generate.js");
|
|
5
5
|
async function generateKeyPair(alg, options) {
|
|
6
6
|
return (0, generate_js_1.generateKeyPair)(alg, options);
|
|
7
7
|
}
|
|
8
|
-
exports.generateKeyPair = generateKeyPair;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateSecret =
|
|
3
|
+
exports.generateSecret = generateSecret;
|
|
4
4
|
const generate_js_1 = require("../runtime/generate.js");
|
|
5
5
|
async function generateSecret(alg, options) {
|
|
6
6
|
return (0, generate_js_1.generateSecret)(alg, options);
|
|
7
7
|
}
|
|
8
|
-
exports.generateSecret = generateSecret;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.importSPKI = importSPKI;
|
|
4
|
+
exports.importX509 = importX509;
|
|
5
|
+
exports.importPKCS8 = importPKCS8;
|
|
6
|
+
exports.importJWK = importJWK;
|
|
4
7
|
const base64url_js_1 = require("../runtime/base64url.js");
|
|
5
8
|
const asn1_js_1 = require("../runtime/asn1.js");
|
|
6
9
|
const jwk_to_key_js_1 = require("../runtime/jwk_to_key.js");
|
|
@@ -12,21 +15,18 @@ async function importSPKI(spki, alg, options) {
|
|
|
12
15
|
}
|
|
13
16
|
return (0, asn1_js_1.fromSPKI)(spki, alg, options);
|
|
14
17
|
}
|
|
15
|
-
exports.importSPKI = importSPKI;
|
|
16
18
|
async function importX509(x509, alg, options) {
|
|
17
19
|
if (typeof x509 !== 'string' || x509.indexOf('-----BEGIN CERTIFICATE-----') !== 0) {
|
|
18
20
|
throw new TypeError('"x509" must be X.509 formatted string');
|
|
19
21
|
}
|
|
20
22
|
return (0, asn1_js_1.fromX509)(x509, alg, options);
|
|
21
23
|
}
|
|
22
|
-
exports.importX509 = importX509;
|
|
23
24
|
async function importPKCS8(pkcs8, alg, options) {
|
|
24
25
|
if (typeof pkcs8 !== 'string' || pkcs8.indexOf('-----BEGIN PRIVATE KEY-----') !== 0) {
|
|
25
26
|
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
26
27
|
}
|
|
27
28
|
return (0, asn1_js_1.fromPKCS8)(pkcs8, alg, options);
|
|
28
29
|
}
|
|
29
|
-
exports.importPKCS8 = importPKCS8;
|
|
30
30
|
async function importJWK(jwk, alg) {
|
|
31
31
|
if (!(0, is_object_js_1.default)(jwk)) {
|
|
32
32
|
throw new TypeError('JWK must be an object');
|
|
@@ -49,4 +49,3 @@ async function importJWK(jwk, alg) {
|
|
|
49
49
|
throw new errors_js_1.JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
exports.importJWK = importJWK;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.wrap = wrap;
|
|
4
|
+
exports.unwrap = unwrap;
|
|
4
5
|
const encrypt_js_1 = require("../runtime/encrypt.js");
|
|
5
6
|
const decrypt_js_1 = require("../runtime/decrypt.js");
|
|
6
7
|
const base64url_js_1 = require("../runtime/base64url.js");
|
|
@@ -13,9 +14,7 @@ async function wrap(alg, key, cek, iv) {
|
|
|
13
14
|
tag: (0, base64url_js_1.encode)(wrapped.tag),
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
|
-
exports.wrap = wrap;
|
|
17
17
|
async function unwrap(alg, key, encryptedKey, iv, tag) {
|
|
18
18
|
const jweAlgorithm = alg.slice(0, 7);
|
|
19
19
|
return (0, decrypt_js_1.default)(jweAlgorithm, key, encryptedKey, iv, tag, new Uint8Array(0));
|
|
20
20
|
}
|
|
21
|
-
exports.unwrap = unwrap;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.decoder = exports.encoder = void 0;
|
|
4
|
+
exports.concat = concat;
|
|
5
|
+
exports.p2s = p2s;
|
|
6
|
+
exports.uint64be = uint64be;
|
|
7
|
+
exports.uint32be = uint32be;
|
|
8
|
+
exports.lengthAndInput = lengthAndInput;
|
|
9
|
+
exports.concatKdf = concatKdf;
|
|
4
10
|
const digest_js_1 = require("../runtime/digest.js");
|
|
5
11
|
exports.encoder = new TextEncoder();
|
|
6
12
|
exports.decoder = new TextDecoder();
|
|
@@ -15,11 +21,9 @@ function concat(...buffers) {
|
|
|
15
21
|
}
|
|
16
22
|
return buf;
|
|
17
23
|
}
|
|
18
|
-
exports.concat = concat;
|
|
19
24
|
function p2s(alg, p2sInput) {
|
|
20
25
|
return concat(exports.encoder.encode(alg), new Uint8Array([0]), p2sInput);
|
|
21
26
|
}
|
|
22
|
-
exports.p2s = p2s;
|
|
23
27
|
function writeUInt32BE(buf, value, offset) {
|
|
24
28
|
if (value < 0 || value >= MAX_INT32) {
|
|
25
29
|
throw new RangeError(`value must be >= 0 and <= ${MAX_INT32 - 1}. Received ${value}`);
|
|
@@ -34,17 +38,14 @@ function uint64be(value) {
|
|
|
34
38
|
writeUInt32BE(buf, low, 4);
|
|
35
39
|
return buf;
|
|
36
40
|
}
|
|
37
|
-
exports.uint64be = uint64be;
|
|
38
41
|
function uint32be(value) {
|
|
39
42
|
const buf = new Uint8Array(4);
|
|
40
43
|
writeUInt32BE(buf, value);
|
|
41
44
|
return buf;
|
|
42
45
|
}
|
|
43
|
-
exports.uint32be = uint32be;
|
|
44
46
|
function lengthAndInput(input) {
|
|
45
47
|
return concat(uint32be(input.length), input);
|
|
46
48
|
}
|
|
47
|
-
exports.lengthAndInput = lengthAndInput;
|
|
48
49
|
async function concatKdf(secret, bits, value) {
|
|
49
50
|
const iterations = Math.ceil((bits >> 3) / 32);
|
|
50
51
|
const res = new Uint8Array(iterations * 32);
|
|
@@ -57,4 +58,3 @@ async function concatKdf(secret, bits, value) {
|
|
|
57
58
|
}
|
|
58
59
|
return res.slice(0, bits >> 3);
|
|
59
60
|
}
|
|
60
|
-
exports.concatKdf = concatKdf;
|