jose 5.10.0 → 6.0.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.
- package/README.md +15 -15
- package/dist/types/index.d.ts +5 -5
- package/dist/types/jwe/compact/decrypt.d.ts +4 -4
- package/dist/types/jwe/compact/encrypt.d.ts +4 -4
- package/dist/types/jwe/flattened/decrypt.d.ts +4 -4
- package/dist/types/jwe/flattened/encrypt.d.ts +6 -6
- package/dist/types/jwe/general/decrypt.d.ts +4 -4
- package/dist/types/jwe/general/encrypt.d.ts +7 -7
- package/dist/types/jwk/embedded.d.ts +2 -2
- package/dist/types/jwk/thumbprint.d.ts +5 -5
- package/dist/types/jwks/local.d.ts +2 -2
- package/dist/types/jwks/remote.d.ts +104 -25
- package/dist/types/jws/compact/sign.d.ts +4 -4
- package/dist/types/jws/compact/verify.d.ts +4 -4
- package/dist/types/jws/flattened/sign.d.ts +4 -4
- package/dist/types/jws/flattened/verify.d.ts +4 -4
- package/dist/types/jws/general/sign.d.ts +6 -6
- package/dist/types/jws/general/verify.d.ts +4 -4
- package/dist/types/jwt/decrypt.d.ts +5 -5
- package/dist/types/jwt/encrypt.d.ts +4 -4
- package/dist/types/jwt/produce.d.ts +3 -3
- package/dist/types/jwt/sign.d.ts +3 -3
- package/dist/types/jwt/unsecured.d.ts +5 -5
- package/dist/types/jwt/verify.d.ts +5 -5
- package/dist/types/key/export.d.ts +10 -12
- package/dist/types/key/generate_key_pair.d.ts +10 -11
- package/dist/types/key/generate_secret.d.ts +6 -9
- package/dist/types/key/import.d.ts +20 -27
- package/dist/types/types.d.ts +27 -29
- package/dist/types/util/decode_jwt.d.ts +2 -2
- package/dist/types/util/decode_protected_header.d.ts +2 -2
- package/dist/types/util/errors.d.ts +6 -6
- package/dist/{browser → webapi}/index.js +2 -2
- package/dist/{node/esm → webapi}/jwe/flattened/decrypt.js +8 -4
- package/dist/{node/esm → webapi}/jwe/flattened/encrypt.js +7 -3
- package/dist/{node/esm → webapi}/jwe/general/encrypt.js +8 -3
- package/dist/{node/esm → webapi}/jwk/thumbprint.js +18 -8
- package/dist/{node/esm → webapi}/jwks/local.js +1 -6
- package/dist/{node/esm → webapi}/jwks/remote.js +34 -6
- package/dist/{node/esm → webapi}/jws/flattened/sign.js +7 -5
- package/dist/{browser → webapi}/jws/flattened/verify.js +8 -14
- package/dist/{browser → webapi}/jwt/unsecured.js +1 -1
- package/dist/{node/esm → webapi}/key/export.js +2 -3
- package/dist/{browser/runtime/generate.js → webapi/key/generate_key_pair.js} +4 -57
- package/dist/webapi/key/generate_secret.js +40 -0
- package/dist/{browser → webapi}/key/import.js +8 -6
- package/dist/{node/esm → webapi}/lib/aesgcmkw.js +3 -3
- package/dist/{browser/runtime → webapi/lib}/aeskw.js +9 -16
- package/dist/{browser/runtime → webapi/lib}/asn1.js +24 -20
- package/dist/{browser/runtime → webapi/lib}/base64url.js +17 -9
- package/dist/{browser → webapi}/lib/buffer_utils.js +4 -19
- package/dist/{browser → webapi}/lib/cek.js +1 -2
- package/dist/{browser/runtime → webapi/lib}/check_cek_length.js +1 -2
- package/dist/{browser → webapi}/lib/check_iv_length.js +1 -2
- package/dist/webapi/lib/check_key_type.js +126 -0
- package/dist/{node/esm → webapi}/lib/crypto_key.js +9 -26
- package/dist/{browser/runtime → webapi/lib}/decrypt.js +26 -10
- package/dist/{node/esm → webapi}/lib/decrypt_key_management.js +22 -24
- package/dist/{browser/runtime → webapi/lib}/digest.js +1 -3
- package/dist/webapi/lib/ecdhes.js +46 -0
- package/dist/{browser/runtime → webapi/lib}/encrypt.js +8 -10
- package/dist/{node/esm → webapi}/lib/encrypt_key_management.js +26 -23
- package/dist/webapi/lib/get_sign_verify_key.js +12 -0
- package/dist/{node/esm → webapi}/lib/is_disjoint.js +1 -2
- package/dist/{browser → webapi}/lib/is_jwk.js +1 -1
- package/dist/webapi/lib/is_key_like.js +14 -0
- package/dist/{browser → webapi}/lib/is_object.js +2 -2
- package/dist/{node/esm → webapi}/lib/iv.js +1 -2
- package/dist/{browser/runtime → webapi/lib}/jwk_to_key.js +3 -13
- package/dist/webapi/lib/key_to_jwk.js +27 -0
- package/dist/webapi/lib/normalize_key.js +164 -0
- package/dist/webapi/lib/pbes2kw.js +37 -0
- package/dist/webapi/lib/rsaes.js +24 -0
- package/dist/{browser/runtime → webapi/lib}/sign.js +1 -3
- package/dist/{browser/runtime → webapi/lib}/subtle_dsa.js +4 -5
- package/dist/{browser → webapi}/lib/validate_algorithms.js +1 -2
- package/dist/{node/esm → webapi}/lib/validate_crit.js +3 -4
- package/dist/{browser/runtime → webapi/lib}/verify.js +1 -3
- package/dist/{node/esm → webapi}/util/base64url.js +1 -1
- package/package.json +36 -219
- package/dist/browser/jwe/compact/encrypt.js +0 -26
- package/dist/browser/jwe/flattened/decrypt.js +0 -161
- package/dist/browser/jwe/flattened/encrypt.js +0 -153
- package/dist/browser/jwe/general/encrypt.js +0 -174
- package/dist/browser/jwk/thumbprint.js +0 -53
- package/dist/browser/jwks/local.js +0 -124
- package/dist/browser/jwks/remote.js +0 -139
- package/dist/browser/jws/compact/sign.js +0 -17
- package/dist/browser/jws/flattened/sign.js +0 -81
- package/dist/browser/jws/general/sign.js +0 -67
- package/dist/browser/jwt/encrypt.js +0 -68
- package/dist/browser/jwt/produce.js +0 -75
- package/dist/browser/jwt/sign.js +0 -20
- package/dist/browser/key/export.js +0 -12
- package/dist/browser/key/generate_key_pair.js +0 -4
- package/dist/browser/key/generate_secret.js +0 -4
- package/dist/browser/lib/aesgcmkw.js +0 -16
- package/dist/browser/lib/check_key_type.js +0 -77
- package/dist/browser/lib/check_p2s.js +0 -6
- package/dist/browser/lib/crypto_key.js +0 -157
- package/dist/browser/lib/decrypt_key_management.js +0 -129
- package/dist/browser/lib/encrypt_key_management.js +0 -89
- package/dist/browser/lib/format_pem.js +0 -4
- package/dist/browser/lib/is_disjoint.js +0 -22
- package/dist/browser/lib/iv.js +0 -20
- package/dist/browser/lib/validate_crit.js +0 -34
- package/dist/browser/package.json +0 -1
- package/dist/browser/runtime/bogus.js +0 -6
- package/dist/browser/runtime/ecdhes.js +0 -47
- package/dist/browser/runtime/fetch_jwks.js +0 -34
- package/dist/browser/runtime/get_sign_verify_key.js +0 -24
- package/dist/browser/runtime/is_key_like.js +0 -8
- package/dist/browser/runtime/key_to_jwk.js +0 -21
- package/dist/browser/runtime/normalize_key.js +0 -68
- package/dist/browser/runtime/pbes2kw.js +0 -51
- package/dist/browser/runtime/random.js +0 -2
- package/dist/browser/runtime/rsaes.js +0 -37
- package/dist/browser/runtime/runtime.js +0 -1
- package/dist/browser/runtime/subtle_rsaes.js +0 -12
- package/dist/browser/runtime/timing_safe_equal.js +0 -19
- package/dist/browser/runtime/webcrypto.js +0 -2
- package/dist/browser/util/base64url.js +0 -3
- package/dist/browser/util/errors.js +0 -114
- package/dist/browser/util/runtime.js +0 -2
- package/dist/node/cjs/index.js +0 -69
- package/dist/node/cjs/jwe/compact/decrypt.js +0 -30
- package/dist/node/cjs/jwe/compact/encrypt.js +0 -31
- package/dist/node/cjs/jwe/flattened/decrypt.js +0 -164
- package/dist/node/cjs/jwe/flattened/encrypt.js +0 -165
- package/dist/node/cjs/jwe/general/decrypt.js +0 -34
- package/dist/node/cjs/jwe/general/encrypt.js +0 -186
- package/dist/node/cjs/jwk/embedded.js +0 -20
- package/dist/node/cjs/jwk/thumbprint.js +0 -57
- package/dist/node/cjs/jwks/local.js +0 -128
- package/dist/node/cjs/jwks/remote.js +0 -152
- package/dist/node/cjs/jws/compact/sign.js +0 -22
- package/dist/node/cjs/jws/compact/verify.js +0 -24
- package/dist/node/cjs/jws/flattened/sign.js +0 -88
- package/dist/node/cjs/jws/flattened/verify.js +0 -125
- package/dist/node/cjs/jws/general/sign.js +0 -77
- package/dist/node/cjs/jws/general/verify.js +0 -27
- package/dist/node/cjs/jwt/decrypt.js +0 -26
- package/dist/node/cjs/jwt/encrypt.js +0 -79
- package/dist/node/cjs/jwt/produce.js +0 -80
- package/dist/node/cjs/jwt/sign.js +0 -25
- package/dist/node/cjs/jwt/unsecured.js +0 -36
- package/dist/node/cjs/jwt/verify.js +0 -18
- package/dist/node/cjs/key/export.js +0 -17
- package/dist/node/cjs/key/generate_key_pair.js +0 -7
- package/dist/node/cjs/key/generate_secret.js +0 -7
- package/dist/node/cjs/key/import.js +0 -51
- package/dist/node/cjs/lib/aesgcmkw.js +0 -20
- package/dist/node/cjs/lib/buffer_utils.js +0 -60
- package/dist/node/cjs/lib/cek.js +0 -23
- package/dist/node/cjs/lib/check_iv_length.js +0 -10
- package/dist/node/cjs/lib/check_key_type.js +0 -80
- package/dist/node/cjs/lib/check_p2s.js +0 -9
- package/dist/node/cjs/lib/crypto_key.js +0 -161
- package/dist/node/cjs/lib/decrypt_key_management.js +0 -131
- package/dist/node/cjs/lib/encrypt_key_management.js +0 -91
- package/dist/node/cjs/lib/epoch.js +0 -3
- package/dist/node/cjs/lib/invalid_key_input.js +0 -34
- package/dist/node/cjs/lib/is_disjoint.js +0 -24
- package/dist/node/cjs/lib/is_jwk.js +0 -19
- package/dist/node/cjs/lib/is_object.js +0 -19
- package/dist/node/cjs/lib/iv.js +0 -23
- package/dist/node/cjs/lib/jwt_claims_set.js +0 -106
- package/dist/node/cjs/lib/private_symbols.js +0 -4
- package/dist/node/cjs/lib/secs.js +0 -57
- package/dist/node/cjs/lib/validate_algorithms.js +0 -13
- package/dist/node/cjs/lib/validate_crit.js +0 -36
- package/dist/node/cjs/runtime/aeskw.js +0 -55
- package/dist/node/cjs/runtime/asn1.js +0 -54
- package/dist/node/cjs/runtime/base64url.js +0 -20
- package/dist/node/cjs/runtime/cbc_tag.js +0 -11
- package/dist/node/cjs/runtime/check_cek_length.js +0 -37
- package/dist/node/cjs/runtime/check_key_length.js +0 -18
- package/dist/node/cjs/runtime/ciphers.js +0 -8
- package/dist/node/cjs/runtime/decrypt.js +0 -103
- package/dist/node/cjs/runtime/digest.js +0 -5
- package/dist/node/cjs/runtime/dsa_digest.js +0 -26
- package/dist/node/cjs/runtime/ecdhes.js +0 -70
- package/dist/node/cjs/runtime/encrypt.js +0 -80
- package/dist/node/cjs/runtime/fetch_jwks.js +0 -45
- package/dist/node/cjs/runtime/generate.js +0 -103
- package/dist/node/cjs/runtime/get_named_curve.js +0 -61
- package/dist/node/cjs/runtime/get_sign_verify_key.js +0 -31
- package/dist/node/cjs/runtime/hmac_digest.js +0 -16
- package/dist/node/cjs/runtime/is_key_like.js +0 -11
- package/dist/node/cjs/runtime/is_key_object.js +0 -4
- package/dist/node/cjs/runtime/jwk_to_key.js +0 -10
- package/dist/node/cjs/runtime/key_to_jwk.js +0 -36
- package/dist/node/cjs/runtime/node_key.js +0 -111
- package/dist/node/cjs/runtime/normalize_key.js +0 -3
- package/dist/node/cjs/runtime/pbes2kw.js +0 -48
- package/dist/node/cjs/runtime/random.js +0 -5
- package/dist/node/cjs/runtime/rsaes.js +0 -71
- package/dist/node/cjs/runtime/runtime.js +0 -3
- package/dist/node/cjs/runtime/sign.js +0 -19
- package/dist/node/cjs/runtime/timing_safe_equal.js +0 -5
- package/dist/node/cjs/runtime/verify.js +0 -31
- package/dist/node/cjs/runtime/webcrypto.js +0 -9
- package/dist/node/cjs/util/base64url.js +0 -6
- package/dist/node/cjs/util/decode_jwt.js +0 -35
- package/dist/node/cjs/util/decode_protected_header.js +0 -37
- package/dist/node/cjs/util/errors.js +0 -117
- package/dist/node/cjs/util/runtime.js +0 -4
- package/dist/node/esm/index.js +0 -30
- package/dist/node/esm/jwe/compact/decrypt.js +0 -27
- package/dist/node/esm/jwe/general/decrypt.js +0 -31
- package/dist/node/esm/jwk/embedded.js +0 -17
- package/dist/node/esm/jws/compact/verify.js +0 -21
- package/dist/node/esm/jws/flattened/verify.js +0 -122
- package/dist/node/esm/jws/general/verify.js +0 -24
- package/dist/node/esm/jwt/decrypt.js +0 -23
- package/dist/node/esm/jwt/unsecured.js +0 -32
- package/dist/node/esm/jwt/verify.js +0 -15
- package/dist/node/esm/key/generate_key_pair.js +0 -4
- package/dist/node/esm/key/generate_secret.js +0 -4
- package/dist/node/esm/key/import.js +0 -45
- package/dist/node/esm/lib/buffer_utils.js +0 -51
- package/dist/node/esm/lib/cek.js +0 -20
- package/dist/node/esm/lib/check_iv_length.js +0 -8
- package/dist/node/esm/lib/check_key_type.js +0 -77
- package/dist/node/esm/lib/check_p2s.js +0 -6
- package/dist/node/esm/lib/epoch.js +0 -1
- package/dist/node/esm/lib/invalid_key_input.js +0 -31
- package/dist/node/esm/lib/is_jwk.js +0 -13
- package/dist/node/esm/lib/is_object.js +0 -16
- package/dist/node/esm/lib/jwt_claims_set.js +0 -104
- package/dist/node/esm/lib/private_symbols.js +0 -1
- package/dist/node/esm/lib/secs.js +0 -55
- package/dist/node/esm/lib/validate_algorithms.js +0 -11
- package/dist/node/esm/package.json +0 -1
- package/dist/node/esm/runtime/aeskw.js +0 -50
- package/dist/node/esm/runtime/asn1.js +0 -46
- package/dist/node/esm/runtime/base64url.js +0 -14
- package/dist/node/esm/runtime/cbc_tag.js +0 -8
- package/dist/node/esm/runtime/check_cek_length.js +0 -35
- package/dist/node/esm/runtime/check_key_length.js +0 -16
- package/dist/node/esm/runtime/ciphers.js +0 -6
- package/dist/node/esm/runtime/decrypt.js +0 -101
- package/dist/node/esm/runtime/digest.js +0 -3
- package/dist/node/esm/runtime/dsa_digest.js +0 -23
- package/dist/node/esm/runtime/ecdhes.js +0 -64
- package/dist/node/esm/runtime/encrypt.js +0 -78
- package/dist/node/esm/runtime/fetch_jwks.js +0 -43
- package/dist/node/esm/runtime/generate.js +0 -99
- package/dist/node/esm/runtime/get_named_curve.js +0 -58
- package/dist/node/esm/runtime/get_sign_verify_key.js +0 -28
- package/dist/node/esm/runtime/hmac_digest.js +0 -13
- package/dist/node/esm/runtime/is_key_like.js +0 -8
- package/dist/node/esm/runtime/is_key_object.js +0 -2
- package/dist/node/esm/runtime/jwk_to_key.js +0 -8
- package/dist/node/esm/runtime/key_to_jwk.js +0 -34
- package/dist/node/esm/runtime/node_key.js +0 -108
- package/dist/node/esm/runtime/normalize_key.js +0 -1
- package/dist/node/esm/runtime/pbes2kw.js +0 -43
- package/dist/node/esm/runtime/random.js +0 -1
- package/dist/node/esm/runtime/rsaes.js +0 -66
- package/dist/node/esm/runtime/runtime.js +0 -1
- package/dist/node/esm/runtime/sign.js +0 -17
- package/dist/node/esm/runtime/timing_safe_equal.js +0 -3
- package/dist/node/esm/runtime/verify.js +0 -29
- package/dist/node/esm/runtime/webcrypto.js +0 -5
- package/dist/node/esm/util/decode_jwt.js +0 -32
- package/dist/node/esm/util/decode_protected_header.js +0 -34
- package/dist/node/esm/util/runtime.js +0 -2
- package/dist/types/util/runtime.d.ts +0 -3
- /package/dist/{browser → webapi}/jwe/compact/decrypt.js +0 -0
- /package/dist/{node/esm → webapi}/jwe/compact/encrypt.js +0 -0
- /package/dist/{browser → webapi}/jwe/general/decrypt.js +0 -0
- /package/dist/{browser → webapi}/jwk/embedded.js +0 -0
- /package/dist/{node/esm → webapi}/jws/compact/sign.js +0 -0
- /package/dist/{browser → webapi}/jws/compact/verify.js +0 -0
- /package/dist/{node/esm → webapi}/jws/general/sign.js +0 -0
- /package/dist/{browser → webapi}/jws/general/verify.js +0 -0
- /package/dist/{browser → webapi}/jwt/decrypt.js +0 -0
- /package/dist/{node/esm → webapi}/jwt/encrypt.js +0 -0
- /package/dist/{node/esm → webapi}/jwt/produce.js +0 -0
- /package/dist/{node/esm → webapi}/jwt/sign.js +0 -0
- /package/dist/{browser → webapi}/jwt/verify.js +0 -0
- /package/dist/{browser/runtime → webapi/lib}/check_key_length.js +0 -0
- /package/dist/{browser → webapi}/lib/epoch.js +0 -0
- /package/dist/{browser → webapi}/lib/invalid_key_input.js +0 -0
- /package/dist/{browser → webapi}/lib/jwt_claims_set.js +0 -0
- /package/dist/{browser → webapi}/lib/private_symbols.js +0 -0
- /package/dist/{browser → webapi}/lib/secs.js +0 -0
- /package/dist/{browser → webapi}/util/decode_jwt.js +0 -0
- /package/dist/{browser → webapi}/util/decode_protected_header.js +0 -0
- /package/dist/{node/esm → webapi}/util/errors.js +0 -0
package/README.md
CHANGED
|
@@ -18,24 +18,18 @@ Support from the community to continue maintaining and improving this module is
|
|
|
18
18
|
|
|
19
19
|
## Dependencies: 0
|
|
20
20
|
|
|
21
|
-
`jose` has no dependencies and it exports tree-shakeable ESM.
|
|
21
|
+
`jose` has no dependencies and it exports tree-shakeable ESM[^cjs].
|
|
22
22
|
|
|
23
23
|
## Documentation
|
|
24
24
|
|
|
25
|
-
`jose` is distributed via [npmjs.com](https://www.npmjs.com/package/jose), [deno.land/x](https://deno.land/x/jose), [cdnjs.com](https://cdnjs.com/libraries/jose), [jsdelivr.com](https://www.jsdelivr.com/package/npm/jose), and [github.com](https://github.com/panva/jose).
|
|
25
|
+
`jose` is distributed via [npmjs.com](https://www.npmjs.com/package/jose), [jsr.io](https://jsr.io/@panva/jose), [deno.land/x](https://deno.land/x/jose), [cdnjs.com](https://cdnjs.com/libraries/jose), [jsdelivr.com](https://www.jsdelivr.com/package/npm/jose), and [github.com](https://github.com/panva/jose).
|
|
26
26
|
|
|
27
|
-
**`example`** ESM import
|
|
27
|
+
**`example`** ESM import[^cjs]
|
|
28
28
|
|
|
29
29
|
```js
|
|
30
30
|
import * as jose from 'jose'
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
**`example`** CJS require
|
|
34
|
-
|
|
35
|
-
```js
|
|
36
|
-
const jose = require('jose')
|
|
37
|
-
```
|
|
38
|
-
|
|
39
33
|
### JSON Web Tokens (JWT)
|
|
40
34
|
|
|
41
35
|
The `jose` module supports JSON Web Tokens (JWT) and provides functionality for signing and verifying tokens, as well as their JWT Claims Set validation.
|
|
@@ -122,11 +116,12 @@ Please note that certain algorithms may not be available depending on the runtim
|
|
|
122
116
|
|
|
123
117
|
## Supported Versions
|
|
124
118
|
|
|
125
|
-
| Version | Security Fixes 🔑 | Other Bug Fixes 🐞 | New Features ⭐ |
|
|
126
|
-
| ----------------------------------------------- | ----------------- | ------------------ | --------------- |
|
|
127
|
-
| [
|
|
128
|
-
| [
|
|
129
|
-
| [
|
|
119
|
+
| Version | Security Fixes 🔑 | Other Bug Fixes 🐞 | New Features ⭐ | Runtime and Module type |
|
|
120
|
+
| ----------------------------------------------- | ----------------- | ------------------ | --------------- | ------------------------------- |
|
|
121
|
+
| [v6.x](https://github.com/panva/jose/tree/v6.x) | ✅ | ✅ | ✅ | Universal[^universal] ESM[^cjs] |
|
|
122
|
+
| [v5.x](https://github.com/panva/jose/tree/v5.x) | ✅ | ❌ | ❌ | Universal[^universal] CJS + ESM |
|
|
123
|
+
| [v4.x](https://github.com/panva/jose/tree/v4.x) | ✅ | ❌ | ❌ | Universal[^universal] CJS + ESM |
|
|
124
|
+
| [v2.x](https://github.com/panva/jose/tree/v2.x) | ✅ | ❌ | ❌ | Node.js CJS |
|
|
130
125
|
|
|
131
126
|
## Specifications
|
|
132
127
|
|
|
@@ -142,10 +137,15 @@ Please note that certain algorithms may not be available depending on the runtim
|
|
|
142
137
|
- JSON Web Key Thumbprint URI - [RFC9278](https://www.rfc-editor.org/rfc/rfc9278)
|
|
143
138
|
- JWS Unencoded Payload Option - [RFC7797](https://www.rfc-editor.org/rfc/rfc7797)
|
|
144
139
|
- CFRG Elliptic Curve ECDH and Signatures - [RFC8037](https://www.rfc-editor.org/rfc/rfc8037)
|
|
145
|
-
- secp256k1 EC Key curve support - [RFC8812](https://www.rfc-editor.org/rfc/rfc8812)
|
|
146
140
|
|
|
147
141
|
The algorithm implementations in `jose` have been tested using test vectors from their respective specifications as well as [RFC7520](https://www.rfc-editor.org/rfc/rfc7520).
|
|
148
142
|
|
|
149
143
|
</details>
|
|
150
144
|
|
|
151
145
|
[sponsor-auth0]: https://a0.to/signup/panva
|
|
146
|
+
[WebCryptoAPI]: https://w3c.github.io/webcrypto/
|
|
147
|
+
[Fetch API]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
|
|
148
|
+
|
|
149
|
+
[^cjs]: CJS style `let jose = require('jose')` is possible in Node.js versions where `process.features.require_module` is `true` by default (^20.19.0 || ^22.12.0 || >= 23.0.0) or with the `--experimental-require-module` Node.js CLI flag.
|
|
150
|
+
|
|
151
|
+
[^universal]: Assumes runtime support of [WebCryptoAPI][] and [Fetch API][]
|
package/dist/types/index.d.ts
CHANGED
|
@@ -28,13 +28,13 @@ export { EncryptJWT } from './jwt/encrypt';
|
|
|
28
28
|
export { calculateJwkThumbprint, calculateJwkThumbprintUri } from './jwk/thumbprint';
|
|
29
29
|
export { EmbeddedJWK } from './jwk/embedded';
|
|
30
30
|
export { createLocalJWKSet } from './jwks/local';
|
|
31
|
-
export { createRemoteJWKSet, jwksCache
|
|
32
|
-
export type { RemoteJWKSetOptions, JWKSCacheInput, ExportedJWKSCache } from './jwks/remote';
|
|
31
|
+
export { createRemoteJWKSet, jwksCache } from './jwks/remote';
|
|
32
|
+
export type { RemoteJWKSetOptions, JWKSCacheInput, ExportedJWKSCache, customFetch, FetchImplementation, } from './jwks/remote';
|
|
33
33
|
export { UnsecuredJWT } from './jwt/unsecured';
|
|
34
34
|
export type { UnsecuredResult } from './jwt/unsecured';
|
|
35
35
|
export { exportPKCS8, exportSPKI, exportJWK } from './key/export';
|
|
36
36
|
export { importSPKI, importPKCS8, importX509, importJWK } from './key/import';
|
|
37
|
-
export type {
|
|
37
|
+
export type { KeyImportOptions } from './key/import';
|
|
38
38
|
export { decodeProtectedHeader } from './util/decode_protected_header';
|
|
39
39
|
export { decodeJwt } from './util/decode_jwt';
|
|
40
40
|
export type { ProtectedHeaderParameters } from './util/decode_protected_header';
|
|
@@ -44,5 +44,5 @@ export type { GenerateKeyPairResult, GenerateKeyPairOptions } from './key/genera
|
|
|
44
44
|
export { generateSecret } from './key/generate_secret';
|
|
45
45
|
export type { GenerateSecretOptions } from './key/generate_secret';
|
|
46
46
|
export * as base64url from './util/base64url';
|
|
47
|
-
export type {
|
|
48
|
-
export
|
|
47
|
+
export type { CompactDecryptResult, CompactJWEHeaderParameters, CompactJWSHeaderParameters, CompactVerifyResult, CritOption, CryptoKey, DecryptOptions, EncryptOptions, FlattenedDecryptResult, FlattenedJWE, FlattenedJWS, FlattenedJWSInput, FlattenedVerifyResult, GeneralDecryptResult, GeneralJWE, GeneralJWS, GeneralJWSInput, GeneralVerifyResult, GetKeyFunction, JoseHeaderParameters, JSONWebKeySet, JWEHeaderParameters, JWEKeyManagementHeaderParameters, JWK_EC_Private, JWK_EC_Public, JWK_oct, JWK_OKP_Private, JWK_OKP_Public, JWK_RSA_Private, JWK_RSA_Public, JWK, JWKParameters, JWSHeaderParameters, JWTClaimVerificationOptions, JWTDecryptResult, JWTHeaderParameters, JWTPayload, JWTVerifyResult, KeyObject, ResolvedKey, SignOptions, VerifyOptions, } from './types';
|
|
48
|
+
export declare const cryptoRuntime = "WebCryptoAPI";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Interface for Compact JWE Decryption dynamic key resolution. No token components have been
|
|
4
4
|
* verified at the time of this function call.
|
|
5
5
|
*/
|
|
6
|
-
export interface CompactDecryptGetKey extends GetKeyFunction<CompactJWEHeaderParameters, FlattenedJWE> {
|
|
6
|
+
export interface CompactDecryptGetKey extends types.GetKeyFunction<types.CompactJWEHeaderParameters, types.FlattenedJWE> {
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Decrypts a Compact JWE.
|
|
@@ -16,11 +16,11 @@ export interface CompactDecryptGetKey extends GetKeyFunction<CompactJWEHeaderPar
|
|
|
16
16
|
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
17
17
|
* @param options JWE Decryption options.
|
|
18
18
|
*/
|
|
19
|
-
export declare function compactDecrypt(jwe: string | Uint8Array, key:
|
|
19
|
+
export declare function compactDecrypt(jwe: string | Uint8Array, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.DecryptOptions): Promise<types.CompactDecryptResult>;
|
|
20
20
|
/**
|
|
21
21
|
* @param jwe Compact JWE.
|
|
22
22
|
* @param getKey Function resolving Private Key or Secret to decrypt the JWE with. See
|
|
23
23
|
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
24
24
|
* @param options JWE Decryption options.
|
|
25
25
|
*/
|
|
26
|
-
export declare function compactDecrypt
|
|
26
|
+
export declare function compactDecrypt(jwe: string | Uint8Array, getKey: CompactDecryptGetKey, options?: types.DecryptOptions): Promise<types.CompactDecryptResult & types.ResolvedKey>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* The CompactEncrypt class is used to build and encrypt Compact JWE strings.
|
|
4
4
|
*
|
|
@@ -35,7 +35,7 @@ export declare class CompactEncrypt {
|
|
|
35
35
|
*
|
|
36
36
|
* @param protectedHeader JWE Protected Header object.
|
|
37
37
|
*/
|
|
38
|
-
setProtectedHeader(protectedHeader: CompactJWEHeaderParameters): this;
|
|
38
|
+
setProtectedHeader(protectedHeader: types.CompactJWEHeaderParameters): this;
|
|
39
39
|
/**
|
|
40
40
|
* Sets the JWE Key Management parameters to be used when encrypting the Content Encryption Key.
|
|
41
41
|
* You do not need to invoke this method, it is only really intended for test and vector
|
|
@@ -43,7 +43,7 @@ export declare class CompactEncrypt {
|
|
|
43
43
|
*
|
|
44
44
|
* @param parameters JWE Key Management parameters.
|
|
45
45
|
*/
|
|
46
|
-
setKeyManagementParameters(parameters: JWEKeyManagementHeaderParameters): this;
|
|
46
|
+
setKeyManagementParameters(parameters: types.JWEKeyManagementHeaderParameters): this;
|
|
47
47
|
/**
|
|
48
48
|
* Encrypts and resolves the value of the Compact JWE string.
|
|
49
49
|
*
|
|
@@ -51,5 +51,5 @@ export declare class CompactEncrypt {
|
|
|
51
51
|
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
52
52
|
* @param options JWE Encryption options.
|
|
53
53
|
*/
|
|
54
|
-
encrypt(key:
|
|
54
|
+
encrypt(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.EncryptOptions): Promise<string>;
|
|
55
55
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Interface for Flattened JWE Decryption dynamic key resolution. No token components have been
|
|
4
4
|
* verified at the time of this function call.
|
|
5
5
|
*/
|
|
6
|
-
export interface FlattenedDecryptGetKey extends GetKeyFunction<JWEHeaderParameters | undefined, FlattenedJWE> {
|
|
6
|
+
export interface FlattenedDecryptGetKey extends types.GetKeyFunction<types.JWEHeaderParameters | undefined, types.FlattenedJWE> {
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Decrypts a Flattened JWE.
|
|
@@ -16,11 +16,11 @@ export interface FlattenedDecryptGetKey extends GetKeyFunction<JWEHeaderParamete
|
|
|
16
16
|
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
17
17
|
* @param options JWE Decryption options.
|
|
18
18
|
*/
|
|
19
|
-
export declare function flattenedDecrypt(jwe: FlattenedJWE, key:
|
|
19
|
+
export declare function flattenedDecrypt(jwe: types.FlattenedJWE, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.DecryptOptions): Promise<types.FlattenedDecryptResult>;
|
|
20
20
|
/**
|
|
21
21
|
* @param jwe Flattened JWE.
|
|
22
22
|
* @param getKey Function resolving Private Key or Secret to decrypt the JWE with. See
|
|
23
23
|
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
24
24
|
* @param options JWE Decryption options.
|
|
25
25
|
*/
|
|
26
|
-
export declare function flattenedDecrypt
|
|
26
|
+
export declare function flattenedDecrypt(jwe: types.FlattenedJWE, getKey: FlattenedDecryptGetKey, options?: types.DecryptOptions): Promise<types.FlattenedDecryptResult & types.ResolvedKey>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* The FlattenedEncrypt class is used to build and encrypt Flattened JWE objects.
|
|
4
4
|
*
|
|
@@ -25,25 +25,25 @@ export declare class FlattenedEncrypt {
|
|
|
25
25
|
*
|
|
26
26
|
* @param parameters JWE Key Management parameters.
|
|
27
27
|
*/
|
|
28
|
-
setKeyManagementParameters(parameters: JWEKeyManagementHeaderParameters): this;
|
|
28
|
+
setKeyManagementParameters(parameters: types.JWEKeyManagementHeaderParameters): this;
|
|
29
29
|
/**
|
|
30
30
|
* Sets the JWE Protected Header on the FlattenedEncrypt object.
|
|
31
31
|
*
|
|
32
32
|
* @param protectedHeader JWE Protected Header.
|
|
33
33
|
*/
|
|
34
|
-
setProtectedHeader(protectedHeader: JWEHeaderParameters): this;
|
|
34
|
+
setProtectedHeader(protectedHeader: types.JWEHeaderParameters): this;
|
|
35
35
|
/**
|
|
36
36
|
* Sets the JWE Shared Unprotected Header on the FlattenedEncrypt object.
|
|
37
37
|
*
|
|
38
38
|
* @param sharedUnprotectedHeader JWE Shared Unprotected Header.
|
|
39
39
|
*/
|
|
40
|
-
setSharedUnprotectedHeader(sharedUnprotectedHeader: JWEHeaderParameters): this;
|
|
40
|
+
setSharedUnprotectedHeader(sharedUnprotectedHeader: types.JWEHeaderParameters): this;
|
|
41
41
|
/**
|
|
42
42
|
* Sets the JWE Per-Recipient Unprotected Header on the FlattenedEncrypt object.
|
|
43
43
|
*
|
|
44
44
|
* @param unprotectedHeader JWE Per-Recipient Unprotected Header.
|
|
45
45
|
*/
|
|
46
|
-
setUnprotectedHeader(unprotectedHeader: JWEHeaderParameters): this;
|
|
46
|
+
setUnprotectedHeader(unprotectedHeader: types.JWEHeaderParameters): this;
|
|
47
47
|
/**
|
|
48
48
|
* Sets the Additional Authenticated Data on the FlattenedEncrypt object.
|
|
49
49
|
*
|
|
@@ -77,5 +77,5 @@ export declare class FlattenedEncrypt {
|
|
|
77
77
|
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
78
78
|
* @param options JWE Encryption options.
|
|
79
79
|
*/
|
|
80
|
-
encrypt(key:
|
|
80
|
+
encrypt(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.EncryptOptions): Promise<types.FlattenedJWE>;
|
|
81
81
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Interface for General JWE Decryption dynamic key resolution. No token components have been
|
|
4
4
|
* verified at the time of this function call.
|
|
5
5
|
*/
|
|
6
|
-
export interface GeneralDecryptGetKey extends GetKeyFunction<JWEHeaderParameters, FlattenedJWE> {
|
|
6
|
+
export interface GeneralDecryptGetKey extends types.GetKeyFunction<types.JWEHeaderParameters, types.FlattenedJWE> {
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Decrypts a General JWE.
|
|
@@ -16,11 +16,11 @@ export interface GeneralDecryptGetKey extends GetKeyFunction<JWEHeaderParameters
|
|
|
16
16
|
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
17
17
|
* @param options JWE Decryption options.
|
|
18
18
|
*/
|
|
19
|
-
export declare function generalDecrypt(jwe: GeneralJWE, key:
|
|
19
|
+
export declare function generalDecrypt(jwe: types.GeneralJWE, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.DecryptOptions): Promise<types.GeneralDecryptResult>;
|
|
20
20
|
/**
|
|
21
21
|
* @param jwe General JWE.
|
|
22
22
|
* @param getKey Function resolving Private Key or Secret to decrypt the JWE with. See
|
|
23
23
|
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
24
24
|
* @param options JWE Decryption options.
|
|
25
25
|
*/
|
|
26
|
-
export declare function generalDecrypt
|
|
26
|
+
export declare function generalDecrypt(jwe: types.GeneralJWE, getKey: GeneralDecryptGetKey, options?: types.DecryptOptions): Promise<types.GeneralDecryptResult & types.ResolvedKey>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../../types';
|
|
2
2
|
export interface Recipient {
|
|
3
3
|
/**
|
|
4
4
|
* Sets the JWE Per-Recipient Unprotected Header on the Recipient object.
|
|
5
5
|
*
|
|
6
6
|
* @param unprotectedHeader JWE Per-Recipient Unprotected Header.
|
|
7
7
|
*/
|
|
8
|
-
setUnprotectedHeader(unprotectedHeader: JWEHeaderParameters): Recipient;
|
|
8
|
+
setUnprotectedHeader(unprotectedHeader: types.JWEHeaderParameters): Recipient;
|
|
9
9
|
/** A shorthand for calling addRecipient() on the enclosing GeneralEncrypt instance */
|
|
10
10
|
addRecipient(...args: Parameters<GeneralEncrypt['addRecipient']>): Recipient;
|
|
11
11
|
/** A shorthand for calling encrypt() on the enclosing GeneralEncrypt instance */
|
|
12
|
-
encrypt(...args: Parameters<GeneralEncrypt['encrypt']>): Promise<GeneralJWE>;
|
|
12
|
+
encrypt(...args: Parameters<GeneralEncrypt['encrypt']>): Promise<types.GeneralJWE>;
|
|
13
13
|
/** Returns the enclosing GeneralEncrypt */
|
|
14
14
|
done(): GeneralEncrypt;
|
|
15
15
|
}
|
|
@@ -35,19 +35,19 @@ export declare class GeneralEncrypt {
|
|
|
35
35
|
* See {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
36
36
|
* @param options JWE Encryption options.
|
|
37
37
|
*/
|
|
38
|
-
addRecipient(key:
|
|
38
|
+
addRecipient(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.CritOption): Recipient;
|
|
39
39
|
/**
|
|
40
40
|
* Sets the JWE Protected Header on the GeneralEncrypt object.
|
|
41
41
|
*
|
|
42
42
|
* @param protectedHeader JWE Protected Header object.
|
|
43
43
|
*/
|
|
44
|
-
setProtectedHeader(protectedHeader: JWEHeaderParameters): this;
|
|
44
|
+
setProtectedHeader(protectedHeader: types.JWEHeaderParameters): this;
|
|
45
45
|
/**
|
|
46
46
|
* Sets the JWE Shared Unprotected Header on the GeneralEncrypt object.
|
|
47
47
|
*
|
|
48
48
|
* @param sharedUnprotectedHeader JWE Shared Unprotected Header object.
|
|
49
49
|
*/
|
|
50
|
-
setSharedUnprotectedHeader(sharedUnprotectedHeader: JWEHeaderParameters): this;
|
|
50
|
+
setSharedUnprotectedHeader(sharedUnprotectedHeader: types.JWEHeaderParameters): this;
|
|
51
51
|
/**
|
|
52
52
|
* Sets the Additional Authenticated Data on the GeneralEncrypt object.
|
|
53
53
|
*
|
|
@@ -55,5 +55,5 @@ export declare class GeneralEncrypt {
|
|
|
55
55
|
*/
|
|
56
56
|
setAdditionalAuthenticatedData(aad: Uint8Array): this;
|
|
57
57
|
/** Encrypts and resolves the value of the General JWE object. */
|
|
58
|
-
encrypt(): Promise<GeneralJWE>;
|
|
58
|
+
encrypt(): Promise<types.GeneralJWE>;
|
|
59
59
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* EmbeddedJWK is an implementation of a GetKeyFunction intended to be used with the JWS/JWT verify
|
|
4
4
|
* operations whenever you need to opt-in to verify signatures with a public key embedded in the
|
|
@@ -9,4 +9,4 @@ import type { KeyLike, FlattenedJWSInput, JWSHeaderParameters } from '../types';
|
|
|
9
9
|
* as from its subpath export `'jose/jwk/embedded'`.
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
|
-
export declare function EmbeddedJWK
|
|
12
|
+
export declare function EmbeddedJWK(protectedHeader?: types.JWSHeaderParameters, token?: types.FlattenedJWSInput): Promise<types.CryptoKey>;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Calculates a base64url-encoded JSON Web Key (JWK) Thumbprint
|
|
4
4
|
*
|
|
5
5
|
* This function is exported (as a named export) from the main `'jose'` module entry point as well
|
|
6
6
|
* as from its subpath export `'jose/jwk/thumbprint'`.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
8
|
+
* @param key Key to calculate the thumbprint for.
|
|
9
9
|
* @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
|
|
10
10
|
* "sha256".
|
|
11
11
|
*
|
|
12
12
|
* @see {@link https://www.rfc-editor.org/rfc/rfc7638 RFC7638}
|
|
13
13
|
*/
|
|
14
|
-
export declare function calculateJwkThumbprint(
|
|
14
|
+
export declare function calculateJwkThumbprint(key: types.JWK | types.CryptoKey | types.KeyObject, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
|
|
15
15
|
/**
|
|
16
16
|
* Calculates a JSON Web Key (JWK) Thumbprint URI
|
|
17
17
|
*
|
|
18
18
|
* This function is exported (as a named export) from the main `'jose'` module entry point as well
|
|
19
19
|
* as from its subpath export `'jose/jwk/thumbprint'`.
|
|
20
20
|
*
|
|
21
|
-
* @param
|
|
21
|
+
* @param key Key to calculate the thumbprint for.
|
|
22
22
|
* @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
|
|
23
23
|
* "sha256".
|
|
24
24
|
*
|
|
25
25
|
* @see {@link https://www.rfc-editor.org/rfc/rfc9278 RFC9278}
|
|
26
26
|
*/
|
|
27
|
-
export declare function calculateJwkThumbprintUri(
|
|
27
|
+
export declare function calculateJwkThumbprintUri(key: types.CryptoKey | types.KeyObject | types.JWK, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Returns a function that resolves a JWS JOSE Header to a public key object from a locally stored,
|
|
4
4
|
* or otherwise available, JSON Web Key Set.
|
|
@@ -20,4 +20,4 @@ import type { KeyLike, JWSHeaderParameters, JSONWebKeySet, FlattenedJWSInput } f
|
|
|
20
20
|
*
|
|
21
21
|
* @param jwks JSON Web Key Set formatted object.
|
|
22
22
|
*/
|
|
23
|
-
export declare function createLocalJWKSet
|
|
23
|
+
export declare function createLocalJWKSet(jwks: types.JSONWebKeySet): (protectedHeader?: types.JWSHeaderParameters, token?: types.FlattenedJWSInput) => Promise<types.CryptoKey>;
|
|
@@ -1,4 +1,100 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* When passed to {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} this allows the resolver
|
|
4
|
+
* to make use of advanced fetch configurations, HTTP Proxies, retry on network errors, etc.
|
|
5
|
+
*
|
|
6
|
+
* import ky from 'ky'
|
|
7
|
+
*
|
|
8
|
+
* let logRequest!: (request: Request) => void
|
|
9
|
+
* let logResponse!: (request: Request, response: Response) => void
|
|
10
|
+
* let logRetry!: (request: Request, error: Error, retryCount: number) => void
|
|
11
|
+
*
|
|
12
|
+
* const JWKS = jose.createRemoteJWKSet(url, {
|
|
13
|
+
* [jose.customFetch]: (...args) =>
|
|
14
|
+
* ky(args[0], {
|
|
15
|
+
* ...args[1],
|
|
16
|
+
* hooks: {
|
|
17
|
+
* beforeRequest: [
|
|
18
|
+
* (request) => {
|
|
19
|
+
* logRequest(request)
|
|
20
|
+
* },
|
|
21
|
+
* ],
|
|
22
|
+
* beforeRetry: [
|
|
23
|
+
* ({ request, error, retryCount }) => {
|
|
24
|
+
* logRetry(request, error, retryCount)
|
|
25
|
+
* },
|
|
26
|
+
* ],
|
|
27
|
+
* afterResponse: [
|
|
28
|
+
* (request, _, response) => {
|
|
29
|
+
* logResponse(request, response)
|
|
30
|
+
* },
|
|
31
|
+
* ],
|
|
32
|
+
* },
|
|
33
|
+
* }),
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* import * as undici from 'undici'
|
|
38
|
+
*
|
|
39
|
+
* // see https://undici.nodejs.org/#/docs/api/EnvHttpProxyAgent
|
|
40
|
+
* let envHttpProxyAgent = new undici.EnvHttpProxyAgent()
|
|
41
|
+
*
|
|
42
|
+
* // @ts-ignore
|
|
43
|
+
* const JWKS = jose.createRemoteJWKSet(url, {
|
|
44
|
+
* [jose.customFetch]: (...args) => {
|
|
45
|
+
* // @ts-ignore
|
|
46
|
+
* return undici.fetch(args[0], { ...args[1], dispatcher: envHttpProxyAgent }) // prettier-ignore
|
|
47
|
+
* },
|
|
48
|
+
* })
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* import * as undici from 'undici'
|
|
52
|
+
*
|
|
53
|
+
* // see https://undici.nodejs.org/#/docs/api/RetryAgent
|
|
54
|
+
* let retryAgent = new undici.RetryAgent(new undici.Agent(), {
|
|
55
|
+
* statusCodes: [],
|
|
56
|
+
* errorCodes: [
|
|
57
|
+
* 'ECONNRESET',
|
|
58
|
+
* 'ECONNREFUSED',
|
|
59
|
+
* 'ENOTFOUND',
|
|
60
|
+
* 'ENETDOWN',
|
|
61
|
+
* 'ENETUNREACH',
|
|
62
|
+
* 'EHOSTDOWN',
|
|
63
|
+
* 'UND_ERR_SOCKET',
|
|
64
|
+
* ],
|
|
65
|
+
* })
|
|
66
|
+
*
|
|
67
|
+
* // @ts-ignore
|
|
68
|
+
* const JWKS = jose.createRemoteJWKSet(url, {
|
|
69
|
+
* [jose.customFetch]: (...args) => {
|
|
70
|
+
* // @ts-ignore
|
|
71
|
+
* return undici.fetch(args[0], { ...args[1], dispatcher: retryAgent }) // prettier-ignore
|
|
72
|
+
* },
|
|
73
|
+
* })
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* import * as undici from 'undici'
|
|
77
|
+
*
|
|
78
|
+
* // see https://undici.nodejs.org/#/docs/api/MockAgent
|
|
79
|
+
* let mockAgent = new undici.MockAgent()
|
|
80
|
+
* mockAgent.disableNetConnect()
|
|
81
|
+
*
|
|
82
|
+
* // @ts-ignore
|
|
83
|
+
* const JWKS = jose.createRemoteJWKSet(url, {
|
|
84
|
+
* [jose.customFetch]: (...args) => {
|
|
85
|
+
* // @ts-ignore
|
|
86
|
+
* return undici.fetch(args[0], { ...args[1], dispatcher: mockAgent }) // prettier-ignore
|
|
87
|
+
* },
|
|
88
|
+
* })
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare const customFetch: unique symbol;
|
|
92
|
+
export type FetchImplementation = (url: string, options: {
|
|
93
|
+
headers: Headers;
|
|
94
|
+
method: 'GET';
|
|
95
|
+
redirect: 'manual';
|
|
96
|
+
signal: AbortSignal;
|
|
97
|
+
}) => Promise<Response>;
|
|
2
98
|
/**
|
|
3
99
|
* DANGER ZONE - This option has security implications that must be understood, assessed for
|
|
4
100
|
* applicability, and accepted before use. It is critical that the JSON Web Key Set cache only be
|
|
@@ -67,26 +163,15 @@ export interface RemoteJWKSetOptions {
|
|
|
67
163
|
* minutes).
|
|
68
164
|
*/
|
|
69
165
|
cacheMaxAge?: number | typeof Infinity;
|
|
70
|
-
/**
|
|
71
|
-
* An instance of {@link https://nodejs.org/api/http.html#class-httpagent http.Agent} or
|
|
72
|
-
* {@link https://nodejs.org/api/https.html#class-httpsagent https.Agent} to pass to the
|
|
73
|
-
* {@link https://nodejs.org/api/http.html#httpgetoptions-callback http.get} or
|
|
74
|
-
* {@link https://nodejs.org/api/https.html#httpsgetoptions-callback https.get} method's options.
|
|
75
|
-
* Use when behind an http(s) proxy. This is a Node.js runtime specific option, it is ignored when
|
|
76
|
-
* used outside of Node.js runtime.
|
|
77
|
-
*/
|
|
78
|
-
agent?: any;
|
|
79
|
-
/**
|
|
80
|
-
* Headers to be sent with the HTTP request. Default is that `User-Agent: jose/v${version}` header
|
|
81
|
-
* is added unless the runtime is a browser in which adding an explicit headers fetch
|
|
82
|
-
* configuration would cause an unnecessary CORS preflight request.
|
|
83
|
-
*/
|
|
166
|
+
/** Headers to be sent with the HTTP request. */
|
|
84
167
|
headers?: Record<string, string>;
|
|
85
168
|
/** See {@link jwksCache}. */
|
|
86
169
|
[jwksCache]?: JWKSCacheInput;
|
|
170
|
+
/** See {@link customFetch}. */
|
|
171
|
+
[customFetch]?: FetchImplementation;
|
|
87
172
|
}
|
|
88
173
|
export interface ExportedJWKSCache {
|
|
89
|
-
jwks: JSONWebKeySet;
|
|
174
|
+
jwks: types.JSONWebKeySet;
|
|
90
175
|
uat: number;
|
|
91
176
|
}
|
|
92
177
|
export type JWKSCacheInput = ExportedJWKSCache | Record<string, never>;
|
|
@@ -114,8 +199,8 @@ export type JWKSCacheInput = ExportedJWKSCache | Record<string, never>;
|
|
|
114
199
|
* @param url URL to fetch the JSON Web Key Set from.
|
|
115
200
|
* @param options Options for the remote JSON Web Key Set.
|
|
116
201
|
*/
|
|
117
|
-
export declare function createRemoteJWKSet
|
|
118
|
-
(protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput): Promise<
|
|
202
|
+
export declare function createRemoteJWKSet(url: URL, options?: RemoteJWKSetOptions): {
|
|
203
|
+
(protectedHeader?: types.JWSHeaderParameters, token?: types.FlattenedJWSInput): Promise<types.CryptoKey>;
|
|
119
204
|
/** @ignore */
|
|
120
205
|
coolingDown: boolean;
|
|
121
206
|
/** @ignore */
|
|
@@ -125,11 +210,5 @@ export declare function createRemoteJWKSet<KeyLikeType extends KeyLike = KeyLike
|
|
|
125
210
|
/** @ignore */
|
|
126
211
|
reload: () => Promise<void>;
|
|
127
212
|
/** @ignore */
|
|
128
|
-
jwks: () => JSONWebKeySet | undefined;
|
|
213
|
+
jwks: () => types.JSONWebKeySet | undefined;
|
|
129
214
|
};
|
|
130
|
-
/**
|
|
131
|
-
* @ignore
|
|
132
|
-
*
|
|
133
|
-
* @deprecated Use {@link jwksCache}.
|
|
134
|
-
*/
|
|
135
|
-
export declare const experimental_jwksCache: symbol;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* The CompactSign class is used to build and sign Compact JWS strings.
|
|
4
4
|
*
|
|
@@ -11,11 +11,11 @@ export declare class CompactSign {
|
|
|
11
11
|
/** @param payload Binary representation of the payload to sign. */
|
|
12
12
|
constructor(payload: Uint8Array);
|
|
13
13
|
/**
|
|
14
|
-
* Sets the JWS Protected Header on the
|
|
14
|
+
* Sets the JWS Protected Header on the CompactSign object.
|
|
15
15
|
*
|
|
16
16
|
* @param protectedHeader JWS Protected Header.
|
|
17
17
|
*/
|
|
18
|
-
setProtectedHeader(protectedHeader: CompactJWSHeaderParameters): this;
|
|
18
|
+
setProtectedHeader(protectedHeader: types.CompactJWSHeaderParameters): this;
|
|
19
19
|
/**
|
|
20
20
|
* Signs and resolves the value of the Compact JWS string.
|
|
21
21
|
*
|
|
@@ -23,5 +23,5 @@ export declare class CompactSign {
|
|
|
23
23
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
24
24
|
* @param options JWS Sign options.
|
|
25
25
|
*/
|
|
26
|
-
sign(key:
|
|
26
|
+
sign(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.SignOptions): Promise<string>;
|
|
27
27
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Interface for Compact JWS Verification dynamic key resolution. No token components have been
|
|
4
4
|
* verified at the time of this function call.
|
|
5
5
|
*
|
|
6
6
|
* @see {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} to verify using a remote JSON Web Key Set.
|
|
7
7
|
*/
|
|
8
|
-
export interface CompactVerifyGetKey extends GenericGetKeyFunction<CompactJWSHeaderParameters, FlattenedJWSInput,
|
|
8
|
+
export interface CompactVerifyGetKey extends types.GenericGetKeyFunction<types.CompactJWSHeaderParameters, types.FlattenedJWSInput, types.CryptoKey | types.KeyObject | types.JWK | Uint8Array> {
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Verifies the signature and format of and afterwards decodes the Compact JWS.
|
|
@@ -18,11 +18,11 @@ export interface CompactVerifyGetKey extends GenericGetKeyFunction<CompactJWSHea
|
|
|
18
18
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
19
19
|
* @param options JWS Verify options.
|
|
20
20
|
*/
|
|
21
|
-
export declare function compactVerify(jws: string | Uint8Array, key:
|
|
21
|
+
export declare function compactVerify(jws: string | Uint8Array, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.VerifyOptions): Promise<types.CompactVerifyResult>;
|
|
22
22
|
/**
|
|
23
23
|
* @param jws Compact JWS.
|
|
24
24
|
* @param getKey Function resolving a key to verify the JWS with. See
|
|
25
25
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
26
26
|
* @param options JWS Verify options.
|
|
27
27
|
*/
|
|
28
|
-
export declare function compactVerify
|
|
28
|
+
export declare function compactVerify(jws: string | Uint8Array, getKey: CompactVerifyGetKey, options?: types.VerifyOptions): Promise<types.CompactVerifyResult & types.ResolvedKey>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* The FlattenedSign class is used to build and sign Flattened JWS objects.
|
|
4
4
|
*
|
|
@@ -17,13 +17,13 @@ export declare class FlattenedSign {
|
|
|
17
17
|
*
|
|
18
18
|
* @param protectedHeader JWS Protected Header.
|
|
19
19
|
*/
|
|
20
|
-
setProtectedHeader(protectedHeader: JWSHeaderParameters): this;
|
|
20
|
+
setProtectedHeader(protectedHeader: types.JWSHeaderParameters): this;
|
|
21
21
|
/**
|
|
22
22
|
* Sets the JWS Unprotected Header on the FlattenedSign object.
|
|
23
23
|
*
|
|
24
24
|
* @param unprotectedHeader JWS Unprotected Header.
|
|
25
25
|
*/
|
|
26
|
-
setUnprotectedHeader(unprotectedHeader: JWSHeaderParameters): this;
|
|
26
|
+
setUnprotectedHeader(unprotectedHeader: types.JWSHeaderParameters): this;
|
|
27
27
|
/**
|
|
28
28
|
* Signs and resolves the value of the Flattened JWS object.
|
|
29
29
|
*
|
|
@@ -31,5 +31,5 @@ export declare class FlattenedSign {
|
|
|
31
31
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
32
32
|
* @param options JWS Sign options.
|
|
33
33
|
*/
|
|
34
|
-
sign(key:
|
|
34
|
+
sign(key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.SignOptions): Promise<types.FlattenedJWS>;
|
|
35
35
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as types from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Interface for Flattened JWS Verification dynamic key resolution. No token components have been
|
|
4
4
|
* verified at the time of this function call.
|
|
5
5
|
*
|
|
6
6
|
* @see {@link jwks/remote.createRemoteJWKSet createRemoteJWKSet} to verify using a remote JSON Web Key Set.
|
|
7
7
|
*/
|
|
8
|
-
export interface FlattenedVerifyGetKey extends GenericGetKeyFunction<JWSHeaderParameters | undefined, FlattenedJWSInput,
|
|
8
|
+
export interface FlattenedVerifyGetKey extends types.GenericGetKeyFunction<types.JWSHeaderParameters | undefined, types.FlattenedJWSInput, types.CryptoKey | types.KeyObject | types.JWK | Uint8Array> {
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Verifies the signature and format of and afterwards decodes the Flattened JWS.
|
|
@@ -18,11 +18,11 @@ export interface FlattenedVerifyGetKey extends GenericGetKeyFunction<JWSHeaderPa
|
|
|
18
18
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
19
19
|
* @param options JWS Verify options.
|
|
20
20
|
*/
|
|
21
|
-
export declare function flattenedVerify(jws: FlattenedJWSInput, key:
|
|
21
|
+
export declare function flattenedVerify(jws: types.FlattenedJWSInput, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array, options?: types.VerifyOptions): Promise<types.FlattenedVerifyResult>;
|
|
22
22
|
/**
|
|
23
23
|
* @param jws Flattened JWS.
|
|
24
24
|
* @param getKey Function resolving a key to verify the JWS with. See
|
|
25
25
|
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
26
26
|
* @param options JWS Verify options.
|
|
27
27
|
*/
|
|
28
|
-
export declare function flattenedVerify
|
|
28
|
+
export declare function flattenedVerify(jws: types.FlattenedJWSInput, getKey: FlattenedVerifyGetKey, options?: types.VerifyOptions): Promise<types.FlattenedVerifyResult & types.ResolvedKey>;
|