unjwt 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +23 -5
  2. package/dist/index.d.mts +6 -6
  3. package/dist/index.d.ts +6 -6
  4. package/dist/index.mjs +5 -5
  5. package/dist/jwe.d.mts +3 -3
  6. package/dist/jwe.d.ts +3 -3
  7. package/dist/jwe.mjs +4 -4
  8. package/dist/jwk.d.mts +3 -2
  9. package/dist/jwk.d.ts +3 -2
  10. package/dist/jwk.mjs +2 -2
  11. package/dist/jws.d.mts +3 -3
  12. package/dist/jws.d.ts +3 -3
  13. package/dist/jws.mjs +4 -4
  14. package/dist/shared/{unjwt.D1J1DelP.d.mts → unjwt.B4NFVxpx.d.ts} +26 -2
  15. package/dist/shared/{unjwt.B0XDPf8a.d.ts → unjwt.BJPVLhUb.d.ts} +3 -3
  16. package/dist/shared/{unjwt.ZsOShfhX.mjs → unjwt.BPpolBff.mjs} +41 -2
  17. package/dist/shared/{unjwt.ByclPbtq.mjs → unjwt.BtEHeKmp.mjs} +4 -4
  18. package/dist/shared/{unjwt.TbszLNOP.d.ts → unjwt.BvA-8hLQ.d.mts} +15 -8
  19. package/dist/shared/{unjwt.Cd9nTEWg.d.mts → unjwt.BvIkEGGz.d.mts} +1 -1
  20. package/dist/shared/{unjwt.kiNPBQh0.d.mts → unjwt.C5blWtcA.d.ts} +15 -8
  21. package/dist/shared/{unjwt.z_U3fRJ-.mjs → unjwt.CauxOPN5.mjs} +1 -1
  22. package/dist/shared/{unjwt.BJEchXrM.d.mts → unjwt.CbvzYE-m.d.mts} +5 -2
  23. package/dist/shared/{unjwt.B5N3dPN9.d.ts → unjwt.D4DUiNeM.d.ts} +5 -2
  24. package/dist/shared/{unjwt.CxhGjEAX.d.ts → unjwt.D9da8HQF.d.mts} +10 -2
  25. package/dist/shared/{unjwt.CxhGjEAX.d.mts → unjwt.D9da8HQF.d.ts} +10 -2
  26. package/dist/shared/{unjwt.DQIYSlHj.d.mts → unjwt.DLOO5Rmq.d.mts} +3 -3
  27. package/dist/shared/{unjwt.WvWb2zNM.d.ts → unjwt.DZjogLQk.d.mts} +26 -2
  28. package/dist/shared/{unjwt.COPr8ebc.mjs → unjwt.Dsh9nxbB.mjs} +5 -4
  29. package/dist/shared/{unjwt.DOI5UE8K.mjs → unjwt.X5vzu_l_.mjs} +5 -1
  30. package/dist/shared/{unjwt.BISJ5yt1.d.ts → unjwt.c10n3uM8.d.ts} +1 -1
  31. package/dist/utils.d.mts +2 -2
  32. package/dist/utils.d.ts +2 -2
  33. package/dist/utils.mjs +1 -1
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -44,14 +44,25 @@ import { encrypt, decrypt } from "unjwt/jwe";
44
44
  // JWK functions
45
45
  import {
46
46
  generateKey,
47
- deriveKeyFromPassword,
48
47
  importKey,
49
48
  exportKey,
50
49
  wrapKey,
51
50
  unwrapKey,
51
+ getJWKFromSet,
52
+ importJWKFromPEM,
53
+ exportJWKToPEM,
54
+ deriveKeyFromPassword,
52
55
  } from "unjwt/jwk";
53
56
  // Utility functions
54
- import { base64UrlEncode, base64UrlDecode, randomBytes } from "unjwt/utils";
57
+ import {
58
+ isJWK,
59
+ isJWKSet,
60
+ isCryptoKey,
61
+ isCryptoKeyPair,
62
+ base64UrlEncode,
63
+ base64UrlDecode,
64
+ randomBytes,
65
+ } from "unjwt/utils";
55
66
  ```
56
67
 
57
68
  **CDN** (Deno, Bun and Browsers)
@@ -65,14 +76,21 @@ import { encrypt, decrypt } from "https://esm.sh/unjwt/jwe";
65
76
  // JWK functions
66
77
  import {
67
78
  generateKey,
68
- deriveKeyFromPassword,
69
79
  importKey,
70
80
  exportKey,
71
81
  wrapKey,
72
82
  unwrapKey,
83
+ getJWKFromSet,
84
+ importJWKFromPEM,
85
+ exportJWKToPEM,
86
+ deriveKeyFromPassword,
73
87
  } from "https://esm.sh/unjwt/jwk";
74
88
  // Utility functions
75
89
  import {
90
+ isJWK,
91
+ isJWKSet,
92
+ isCryptoKey,
93
+ isCryptoKeyPair,
76
94
  base64UrlEncode,
77
95
  base64UrlDecode,
78
96
  randomBytes,
@@ -129,8 +147,8 @@ console.log(token);
129
147
  Verifies a JWS token.
130
148
 
131
149
  - `jws`: The JWS token string.
132
- - `key`: The verification key (`CryptoKey`, `JWK`, `Uint8Array`, or a `KeyLookupFunction`).
133
- A `KeyLookupFunction` has the signature `(header: JWSProtectedHeader) => Promise<CryptoKey | JWK | Uint8Array> | CryptoKey | JWK | Uint8Array`.
150
+ - `key`: The verification key (`CryptoKey`, `JWK`, `JWKSet`, `Uint8Array`, or a `KeyLookupFunction`).
151
+ A `KeyLookupFunction` has the signature `(header: JWSProtectedHeader, jws: string) => Promise<CryptoKey | JWK | JWKSet | Uint8Array> | CryptoKey | JWK | JWKSet | Uint8Array`.
134
152
  - `options` (optional):
135
153
  - `algorithms`: An array of allowed JWS `alg` values. If not provided, the `alg` from the JWS header is used.
136
154
  - `critical`: An array of JWS header parameter names that the application understands and processes.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, B as JWKAlgorithm, E as JWKPEMAlgorithm, J as JWKParameters, u as JWK_AES_CBC_HMAC, v as JWK_AES_GCM, t as JWK_AES_GCM_KW, s as JWK_AES_KW, A as JWK_Asymmetric_Algorithm, h as JWK_EC, x as JWK_ECDH_ES, q as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, y as JWK_ED, n as JWK_HMAC, w as JWK_PBES2, k as JWK_RSA, r as JWK_RSA_ENC, p as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, o as JWK_RSA_SIGN, z as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.CxhGjEAX.mjs';
2
- export { b as JWT, a as JWTClaims, J as JoseHeaderParameters } from './shared/unjwt.Cd9nTEWg.mjs';
3
- export { J as JWSAlgorithm, a as JWSHeaderParameters, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, j as jws } from './shared/unjwt.kiNPBQh0.mjs';
4
- export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, j as jwe } from './shared/unjwt.DQIYSlHj.mjs';
5
- export { i as utils } from './shared/unjwt.BJEchXrM.mjs';
6
- export { j as jwk } from './shared/unjwt.D1J1DelP.mjs';
1
+ export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, E as JWKAlgorithm, F as JWKPEMAlgorithm, J as JWKParameters, n as JWKSet, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, x as JWK_PBES2, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.D9da8HQF.mjs';
2
+ export { b as JWT, a as JWTClaims, J as JoseHeaderParameters } from './shared/unjwt.BvIkEGGz.mjs';
3
+ export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, j as jws } from './shared/unjwt.BvA-8hLQ.mjs';
4
+ export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, j as jwe } from './shared/unjwt.DLOO5Rmq.mjs';
5
+ export { i as utils } from './shared/unjwt.CbvzYE-m.mjs';
6
+ export { j as jwk } from './shared/unjwt.DZjogLQk.mjs';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, B as JWKAlgorithm, E as JWKPEMAlgorithm, J as JWKParameters, u as JWK_AES_CBC_HMAC, v as JWK_AES_GCM, t as JWK_AES_GCM_KW, s as JWK_AES_KW, A as JWK_Asymmetric_Algorithm, h as JWK_EC, x as JWK_ECDH_ES, q as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, y as JWK_ED, n as JWK_HMAC, w as JWK_PBES2, k as JWK_RSA, r as JWK_RSA_ENC, p as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, o as JWK_RSA_SIGN, z as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.CxhGjEAX.js';
2
- export { b as JWT, a as JWTClaims, J as JoseHeaderParameters } from './shared/unjwt.BISJ5yt1.js';
3
- export { J as JWSAlgorithm, a as JWSHeaderParameters, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, j as jws } from './shared/unjwt.TbszLNOP.js';
4
- export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, j as jwe } from './shared/unjwt.B0XDPf8a.js';
5
- export { i as utils } from './shared/unjwt.B5N3dPN9.js';
6
- export { j as jwk } from './shared/unjwt.WvWb2zNM.js';
1
+ export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, E as JWKAlgorithm, F as JWKPEMAlgorithm, J as JWKParameters, n as JWKSet, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, x as JWK_PBES2, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.D9da8HQF.js';
2
+ export { b as JWT, a as JWTClaims, J as JoseHeaderParameters } from './shared/unjwt.c10n3uM8.js';
3
+ export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, j as jws } from './shared/unjwt.C5blWtcA.js';
4
+ export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, j as jwe } from './shared/unjwt.BJPVLhUb.js';
5
+ export { i as utils } from './shared/unjwt.D4DUiNeM.js';
6
+ export { j as jwk } from './shared/unjwt.B4NFVxpx.js';
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { i as utils } from './shared/unjwt.DOI5UE8K.mjs';
2
- export { j as jwe } from './shared/unjwt.ByclPbtq.mjs';
3
- export { j as jwk } from './shared/unjwt.ZsOShfhX.mjs';
4
- export { j as jws } from './shared/unjwt.COPr8ebc.mjs';
5
- import './shared/unjwt.z_U3fRJ-.mjs';
1
+ export { i as utils } from './shared/unjwt.X5vzu_l_.mjs';
2
+ export { j as jwe } from './shared/unjwt.BtEHeKmp.mjs';
3
+ export { j as jwk } from './shared/unjwt.BPpolBff.mjs';
4
+ export { j as jws } from './shared/unjwt.Dsh9nxbB.mjs';
5
+ import './shared/unjwt.CauxOPN5.mjs';
package/dist/jwe.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import './shared/unjwt.CxhGjEAX.mjs';
2
- import './shared/unjwt.Cd9nTEWg.mjs';
3
- export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, g as decrypt, f as encrypt } from './shared/unjwt.DQIYSlHj.mjs';
1
+ import './shared/unjwt.D9da8HQF.mjs';
2
+ import './shared/unjwt.BvIkEGGz.mjs';
3
+ export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, g as decrypt, f as encrypt } from './shared/unjwt.DLOO5Rmq.mjs';
package/dist/jwe.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import './shared/unjwt.CxhGjEAX.js';
2
- import './shared/unjwt.BISJ5yt1.js';
3
- export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, g as decrypt, f as encrypt } from './shared/unjwt.B0XDPf8a.js';
1
+ import './shared/unjwt.D9da8HQF.js';
2
+ import './shared/unjwt.c10n3uM8.js';
3
+ export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, g as decrypt, f as encrypt } from './shared/unjwt.BJPVLhUb.js';
package/dist/jwe.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import './shared/unjwt.ZsOShfhX.mjs';
2
- import './shared/unjwt.DOI5UE8K.mjs';
3
- export { d as decrypt, e as encrypt } from './shared/unjwt.ByclPbtq.mjs';
4
- import './shared/unjwt.z_U3fRJ-.mjs';
1
+ import './shared/unjwt.BPpolBff.mjs';
2
+ import './shared/unjwt.X5vzu_l_.mjs';
3
+ export { d as decrypt, e as encrypt } from './shared/unjwt.BtEHeKmp.mjs';
4
+ import './shared/unjwt.CauxOPN5.mjs';
package/dist/jwk.d.mts CHANGED
@@ -1,2 +1,3 @@
1
- export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, B as JWKAlgorithm, E as JWKPEMAlgorithm, J as JWKParameters, u as JWK_AES_CBC_HMAC, v as JWK_AES_GCM, t as JWK_AES_GCM_KW, s as JWK_AES_KW, A as JWK_Asymmetric_Algorithm, h as JWK_EC, x as JWK_ECDH_ES, q as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, y as JWK_ED, n as JWK_HMAC, w as JWK_PBES2, k as JWK_RSA, r as JWK_RSA_ENC, p as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, o as JWK_RSA_SIGN, z as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.CxhGjEAX.mjs';
2
- export { d as deriveKeyFromPassword, b as exportJWKToPEM, e as exportKey, g as generateKey, a as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.D1J1DelP.mjs';
1
+ export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, E as JWKAlgorithm, F as JWKPEMAlgorithm, J as JWKParameters, n as JWKSet, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, x as JWK_PBES2, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.D9da8HQF.mjs';
2
+ import './shared/unjwt.BvIkEGGz.mjs';
3
+ export { d as deriveKeyFromPassword, b as exportJWKToPEM, e as exportKey, g as generateKey, c as getJWKFromSet, a as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.DZjogLQk.mjs';
package/dist/jwk.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, B as JWKAlgorithm, E as JWKPEMAlgorithm, J as JWKParameters, u as JWK_AES_CBC_HMAC, v as JWK_AES_GCM, t as JWK_AES_GCM_KW, s as JWK_AES_KW, A as JWK_Asymmetric_Algorithm, h as JWK_EC, x as JWK_ECDH_ES, q as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, y as JWK_ED, n as JWK_HMAC, w as JWK_PBES2, k as JWK_RSA, r as JWK_RSA_ENC, p as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, o as JWK_RSA_SIGN, z as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.CxhGjEAX.js';
2
- export { d as deriveKeyFromPassword, b as exportJWKToPEM, e as exportKey, g as generateKey, a as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.WvWb2zNM.js';
1
+ export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, E as JWKAlgorithm, F as JWKPEMAlgorithm, J as JWKParameters, n as JWKSet, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, x as JWK_PBES2, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.D9da8HQF.js';
2
+ import './shared/unjwt.c10n3uM8.js';
3
+ export { d as deriveKeyFromPassword, b as exportJWKToPEM, e as exportKey, g as generateKey, c as getJWKFromSet, a as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.B4NFVxpx.js';
package/dist/jwk.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import './shared/unjwt.DOI5UE8K.mjs';
2
- export { o as deriveKeyFromPassword, s as exportJWKToPEM, p as exportKey, n as generateKey, r as importJWKFromPEM, i as importKey, l as unwrapKey, q as wrapKey } from './shared/unjwt.ZsOShfhX.mjs';
1
+ import './shared/unjwt.X5vzu_l_.mjs';
2
+ export { p as deriveKeyFromPassword, t as exportJWKToPEM, q as exportKey, o as generateKey, g as getJWKFromSet, s as importJWKFromPEM, i as importKey, m as unwrapKey, r as wrapKey } from './shared/unjwt.BPpolBff.mjs';
package/dist/jws.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import './shared/unjwt.CxhGjEAX.mjs';
2
- import './shared/unjwt.Cd9nTEWg.mjs';
3
- export { J as JWSAlgorithm, a as JWSHeaderParameters, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, s as sign, v as verify } from './shared/unjwt.kiNPBQh0.mjs';
1
+ import './shared/unjwt.D9da8HQF.mjs';
2
+ import './shared/unjwt.BvIkEGGz.mjs';
3
+ export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, s as sign, v as verify } from './shared/unjwt.BvA-8hLQ.mjs';
package/dist/jws.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import './shared/unjwt.CxhGjEAX.js';
2
- import './shared/unjwt.BISJ5yt1.js';
3
- export { J as JWSAlgorithm, a as JWSHeaderParameters, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, s as sign, v as verify } from './shared/unjwt.TbszLNOP.js';
1
+ import './shared/unjwt.D9da8HQF.js';
2
+ import './shared/unjwt.c10n3uM8.js';
3
+ export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, s as sign, v as verify } from './shared/unjwt.C5blWtcA.js';
package/dist/jws.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import './shared/unjwt.ZsOShfhX.mjs';
2
- import './shared/unjwt.DOI5UE8K.mjs';
3
- import './shared/unjwt.z_U3fRJ-.mjs';
4
- export { s as sign, v as verify } from './shared/unjwt.COPr8ebc.mjs';
1
+ import './shared/unjwt.BPpolBff.mjs';
2
+ import './shared/unjwt.X5vzu_l_.mjs';
3
+ import './shared/unjwt.CauxOPN5.mjs';
4
+ export { s as sign, v as verify } from './shared/unjwt.Dsh9nxbB.mjs';
@@ -1,4 +1,5 @@
1
- import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, w as JWK_PBES2, D as DeriveKeyOptions, c as DeriveKeyReturn, l as JWK_oct, m as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, e as WrapKeyResult, U as UnwrapKeyOptions, E as JWKPEMAlgorithm, C as CompositeKey, d as ContentEncryptionAlgorithm, B as JWKAlgorithm, J as JWKParameters, u as JWK_AES_CBC_HMAC, v as JWK_AES_GCM, t as JWK_AES_GCM_KW, s as JWK_AES_KW, A as JWK_Asymmetric_Algorithm, h as JWK_EC, x as JWK_ECDH_ES, q as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, y as JWK_ED, n as JWK_HMAC, k as JWK_RSA, r as JWK_RSA_ENC, p as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, o as JWK_RSA_SIGN, z as JWK_Symmetric_Algorithm } from './unjwt.CxhGjEAX.mjs';
1
+ import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, x as JWK_PBES2, D as DeriveKeyOptions, c as DeriveKeyReturn, l as JWK_oct, m as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, e as WrapKeyResult, U as UnwrapKeyOptions, F as JWKPEMAlgorithm, n as JWKSet, C as CompositeKey, d as ContentEncryptionAlgorithm, E as JWKAlgorithm, J as JWKParameters, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm } from './unjwt.D9da8HQF.js';
2
+ import { J as JoseHeaderParameters } from './unjwt.c10n3uM8.js';
2
3
 
3
4
  /**
4
5
  * This is a fork of Jose library's utility functions.
@@ -101,6 +102,25 @@ declare function importJWKFromPEM(pem: string, pemType: "pkcs8" | "spki" | "x509
101
102
  * @returns A Promise resolving to the PEM-encoded key string.
102
103
  */
103
104
  declare function exportJWKToPEM(jwk: JWK, pemFormat: "pkcs8" | "spki", algForCryptoKeyImport?: JWKPEMAlgorithm): Promise<string>;
105
+ /**
106
+ * Retrieves a JWK (JSON Web Key) from a JWKSet based on a key ID (kid) or
107
+ * properties from a JOSE Header.
108
+ *
109
+ * @param jwkSet The JWKSet to search within.
110
+ * @param kidOrProtectedHeader Either a string representing the 'kid' (Key ID)
111
+ * or an object representing the JOSE Protected Header. If an object is
112
+ * provided, it must contain a 'kid' property. It can optionally contain
113
+ * 'alg' (Algorithm) and 'kty' (Key Type) to further refine the search.
114
+ * @returns The matching JWK from the set.
115
+ * @throws TypeError if `jwkSet` is invalid or `kidOrProtectedHeader` is not a
116
+ * string or a valid header object.
117
+ * @throws Error if no key is found matching the provided criteria, or if the
118
+ * header object is missing the 'kid' property.
119
+ */
120
+ declare function getJWKFromSet(jwkSet: JWKSet, kidOrProtectedHeader: string | (JoseHeaderParameters & {
121
+ alg?: string;
122
+ kty?: string;
123
+ })): JWK;
104
124
 
105
125
  declare const jwk_CompositeKey: typeof CompositeKey;
106
126
  declare const jwk_ContentEncryptionAlgorithm: typeof ContentEncryptionAlgorithm;
@@ -113,6 +133,7 @@ declare const jwk_JWK: typeof JWK;
113
133
  declare const jwk_JWKAlgorithm: typeof JWKAlgorithm;
114
134
  declare const jwk_JWKPEMAlgorithm: typeof JWKPEMAlgorithm;
115
135
  declare const jwk_JWKParameters: typeof JWKParameters;
136
+ declare const jwk_JWKSet: typeof JWKSet;
116
137
  declare const jwk_JWK_AES_CBC_HMAC: typeof JWK_AES_CBC_HMAC;
117
138
  declare const jwk_JWK_AES_GCM: typeof JWK_AES_GCM;
118
139
  declare const jwk_JWK_AES_GCM_KW: typeof JWK_AES_GCM_KW;
@@ -142,6 +163,7 @@ declare const jwk_deriveKeyFromPassword: typeof deriveKeyFromPassword;
142
163
  declare const jwk_exportJWKToPEM: typeof exportJWKToPEM;
143
164
  declare const jwk_exportKey: typeof exportKey;
144
165
  declare const jwk_generateKey: typeof generateKey;
166
+ declare const jwk_getJWKFromSet: typeof getJWKFromSet;
145
167
  declare const jwk_importJWKFromPEM: typeof importJWKFromPEM;
146
168
  declare const jwk_importKey: typeof importKey;
147
169
  declare const jwk_unwrapKey: typeof unwrapKey;
@@ -159,6 +181,7 @@ declare namespace jwk {
159
181
  jwk_JWKAlgorithm as JWKAlgorithm,
160
182
  jwk_JWKPEMAlgorithm as JWKPEMAlgorithm,
161
183
  jwk_JWKParameters as JWKParameters,
184
+ jwk_JWKSet as JWKSet,
162
185
  jwk_JWK_AES_CBC_HMAC as JWK_AES_CBC_HMAC,
163
186
  jwk_JWK_AES_GCM as JWK_AES_GCM,
164
187
  jwk_JWK_AES_GCM_KW as JWK_AES_GCM_KW,
@@ -188,6 +211,7 @@ declare namespace jwk {
188
211
  jwk_exportJWKToPEM as exportJWKToPEM,
189
212
  jwk_exportKey as exportKey,
190
213
  jwk_generateKey as generateKey,
214
+ jwk_getJWKFromSet as getJWKFromSet,
191
215
  jwk_importJWKFromPEM as importJWKFromPEM,
192
216
  jwk_importKey as importKey,
193
217
  jwk_unwrapKey as unwrapKey,
@@ -195,4 +219,4 @@ declare namespace jwk {
195
219
  };
196
220
  }
197
221
 
198
- export { importJWKFromPEM as a, exportJWKToPEM as b, deriveKeyFromPassword as d, exportKey as e, generateKey as g, importKey as i, jwk as j, unwrapKey as u, wrapKey as w };
222
+ export { importJWKFromPEM as a, exportJWKToPEM as b, getJWKFromSet as c, deriveKeyFromPassword as d, exportKey as e, generateKey as g, importKey as i, jwk as j, unwrapKey as u, wrapKey as w };
@@ -1,5 +1,5 @@
1
- import { K as KeyManagementAlgorithm, d as ContentEncryptionAlgorithm, f as JWK_EC_Public, m as JWK } from './unjwt.CxhGjEAX.js';
2
- import { J as JoseHeaderParameters, a as JWTClaims } from './unjwt.BISJ5yt1.js';
1
+ import { K as KeyManagementAlgorithm, d as ContentEncryptionAlgorithm, f as JWK_EC_Public, m as JWK } from './unjwt.D9da8HQF.js';
2
+ import { J as JoseHeaderParameters, a as JWTClaims } from './unjwt.c10n3uM8.js';
3
3
 
4
4
  /** Recognized JWE Header Parameters, any other Header Members may also be present. */
5
5
  interface JWEHeaderParameters extends JoseHeaderParameters {
@@ -99,7 +99,7 @@ interface JWEEncryptOptions {
99
99
  * @param header The JWE Protected Header.
100
100
  * @returns The key material (CryptoKey, JWK, password string, or raw Uint8Array) or a Promise resolving to it.
101
101
  */
102
- type JWEKeyLookupFunction = (header: JWEHeaderParameters) => CryptoKey | JWK | string | Uint8Array | Promise<CryptoKey | JWK | string | Uint8Array>;
102
+ type JWEKeyLookupFunction = (header: JWEHeaderParameters, token: string) => CryptoKey | JWK | string | Uint8Array | Promise<CryptoKey | JWK | string | Uint8Array>;
103
103
  /**
104
104
  * JWE (JSON Web Encryption) decryption options
105
105
  */
@@ -1,4 +1,4 @@
1
- import { g as isCryptoKey, e as concatUint8Arrays, b as base64UrlEncode, h as base64Decode, j as base64Encode, t as textEncoder, r as randomBytes, a as isJWK, d as base64UrlDecode } from './unjwt.DOI5UE8K.mjs';
1
+ import { h as isCryptoKey, f as concatUint8Arrays, b as base64UrlEncode, j as base64Decode, k as base64Encode, t as textEncoder, r as randomBytes, a as isJWK, d as base64UrlDecode, e as isJWKSet } from './unjwt.X5vzu_l_.mjs';
2
2
 
3
3
  /**
4
4
  * This is a fork of Jose library's utility functions.
@@ -1383,6 +1383,44 @@ async function exportJWKToPEM(jwk, pemFormat, algForCryptoKeyImport) {
1383
1383
  }
1384
1384
  }
1385
1385
  }
1386
+ function getJWKFromSet(jwkSet, kidOrProtectedHeader) {
1387
+ if (!jwkSet || !isJWKSet(jwkSet)) {
1388
+ throw new TypeError("Invalid JWK Set provided");
1389
+ }
1390
+ if (typeof kidOrProtectedHeader === "string") {
1391
+ const kid = kidOrProtectedHeader;
1392
+ const selectedKey = jwkSet.keys.find((k) => k.kid === kid);
1393
+ if (!selectedKey) {
1394
+ throw new Error(`No key found in JWK Set with kid "${kid}".`);
1395
+ }
1396
+ return selectedKey;
1397
+ } else if (typeof kidOrProtectedHeader === "object") {
1398
+ const { kid, alg, kty } = kidOrProtectedHeader;
1399
+ if (!kid) {
1400
+ throw new Error(
1401
+ "JWS Protected Header is missing 'kid' (Key ID) and a JWK Set was provided. Cannot select key from JWK Set automatically."
1402
+ );
1403
+ }
1404
+ const selectedKey = jwkSet.keys.find((k) => {
1405
+ return k.kid === kid && (!alg || k.alg === alg) && (!kty || k.kty === kty);
1406
+ });
1407
+ if (!selectedKey) {
1408
+ let errorMessage = `No key found in JWK Set with kid "${kid}"`;
1409
+ if (alg) {
1410
+ errorMessage += ` and alg "${alg}"`;
1411
+ }
1412
+ if (kty) {
1413
+ errorMessage += ` and kty "${kty}"`;
1414
+ }
1415
+ errorMessage += ".";
1416
+ throw new Error(errorMessage);
1417
+ }
1418
+ return selectedKey;
1419
+ }
1420
+ throw new TypeError(
1421
+ "`kidOrProtectedHeader` must be a string (kid) or an object (JOSE Protected Header)."
1422
+ );
1423
+ }
1386
1424
  function getGenerateKeyParams(alg, options) {
1387
1425
  let algorithm;
1388
1426
  let keyUsages;
@@ -1498,10 +1536,11 @@ const jwk = {
1498
1536
  exportJWKToPEM: exportJWKToPEM,
1499
1537
  exportKey: exportKey,
1500
1538
  generateKey: generateKey,
1539
+ getJWKFromSet: getJWKFromSet,
1501
1540
  importJWKFromPEM: importJWKFromPEM,
1502
1541
  importKey: importKey,
1503
1542
  unwrapKey: unwrapKey,
1504
1543
  wrapKey: wrapKey
1505
1544
  };
1506
1545
 
1507
- export { checkEncCryptoKey as a, bitLengthCEK as b, checkSigCryptoKey as c, jwkTokey as d, encryptIV as e, generateIV as f, generateCEK as g, encrypt as h, importKey as i, jwk as j, keyToJWK as k, unwrapKey as l, decrypt as m, generateKey as n, deriveKeyFromPassword as o, exportKey as p, wrapKey as q, importJWKFromPEM as r, exportJWKToPEM as s, uint32be as u, wrap as w };
1546
+ export { checkEncCryptoKey as a, generateCEK as b, checkSigCryptoKey as c, bitLengthCEK as d, encryptIV as e, jwkTokey as f, getJWKFromSet as g, generateIV as h, importKey as i, jwk as j, keyToJWK as k, encrypt as l, unwrapKey as m, decrypt as n, generateKey as o, deriveKeyFromPassword as p, exportKey as q, wrapKey as r, importJWKFromPEM as s, exportJWKToPEM as t, uint32be as u, wrap as w };
@@ -1,6 +1,6 @@
1
- import { a as checkEncCryptoKey, u as uint32be, g as generateCEK, e as encryptIV, w as wrap, k as keyToJWK, b as bitLengthCEK, d as jwkTokey, i as importKey, f as generateIV, h as encrypt$1, l as unwrapKey, m as decrypt$1 } from './unjwt.ZsOShfhX.mjs';
2
- import { e as concatUint8Arrays, t as textEncoder, f as assertCryptoKey, b as base64UrlEncode, g as isCryptoKey, a as isJWK, d as base64UrlDecode, r as randomBytes, c as textDecoder } from './unjwt.DOI5UE8K.mjs';
3
- import { c as checkKeyLength } from './unjwt.z_U3fRJ-.mjs';
1
+ import { a as checkEncCryptoKey, u as uint32be, b as generateCEK, e as encryptIV, w as wrap, k as keyToJWK, d as bitLengthCEK, f as jwkTokey, i as importKey, h as generateIV, l as encrypt$1, m as unwrapKey, n as decrypt$1 } from './unjwt.BPpolBff.mjs';
2
+ import { f as concatUint8Arrays, t as textEncoder, g as assertCryptoKey, b as base64UrlEncode, h as isCryptoKey, a as isJWK, d as base64UrlDecode, r as randomBytes, c as textDecoder } from './unjwt.X5vzu_l_.mjs';
3
+ import { c as checkKeyLength } from './unjwt.CauxOPN5.mjs';
4
4
 
5
5
  function lengthAndInput(input) {
6
6
  return concatUint8Arrays(uint32be(input.length), input);
@@ -327,7 +327,7 @@ async function decrypt(jwe, key, options) {
327
327
  if (options?.encryptionAlgorithms && !options.encryptionAlgorithms.includes(enc)) {
328
328
  throw new Error(`Content encryption algorithm not allowed: ${enc}`);
329
329
  }
330
- const resolvedKeyMaterial = typeof key === "function" ? await key(protectedHeader) : key;
330
+ const resolvedKeyMaterial = typeof key === "function" ? await key(protectedHeader, jwe) : key;
331
331
  const unwrappingKey = await importKey(resolvedKeyMaterial, alg);
332
332
  const encryptedKeyBytes = base64UrlDecode(encryptedKeyEncoded, false);
333
333
  const contentIVBytes = base64UrlDecode(ivEncoded, false);
@@ -1,5 +1,5 @@
1
- import { n as JWK_HMAC, o as JWK_RSA_SIGN, p as JWK_RSA_PSS, q as JWK_ECDSA, m as JWK } from './unjwt.CxhGjEAX.js';
2
- import { J as JoseHeaderParameters, a as JWTClaims } from './unjwt.BISJ5yt1.js';
1
+ import { o as JWK_HMAC, p as JWK_RSA_SIGN, q as JWK_RSA_PSS, r as JWK_ECDSA, m as JWK, n as JWKSet } from './unjwt.D9da8HQF.mjs';
2
+ import { J as JoseHeaderParameters, a as JWTClaims } from './unjwt.BvIkEGGz.mjs';
3
3
 
4
4
  type JWS_SIGN_EXTRA = "Ed25519" | "EdDSA";
5
5
  /** JWS Signing Algorithm Identifier. */
@@ -101,6 +101,13 @@ interface JWSVerifyOptions {
101
101
  */
102
102
  critical?: string[];
103
103
  }
104
+ /**
105
+ * Key lookup function for JWS verification.
106
+ * @param header The JWS Protected Header.
107
+ * @param token The JWS token.
108
+ * @returns The key material (CryptoKey, JWK, or raw Uint8Array) or a Promise resolving to it.
109
+ */
110
+ type JWSKeyLookupFunction = (header: JWSProtectedHeader, token: string) => CryptoKey | JWK | JWKSet | Uint8Array | Promise<CryptoKey | JWK | JWKSet | Uint8Array>;
104
111
 
105
112
  /**
106
113
  * Creates a JWS (JSON Web Signature) in Compact Serialization format.
@@ -121,23 +128,23 @@ declare function sign(payload: string | Uint8Array | Record<string, any>, key: C
121
128
  declare function sign(payload: string | Uint8Array | Record<string, any>, key: CryptoKey | JWK | Uint8Array, options: JWSSignOptions & {
122
129
  alg: JWSAlgorithm;
123
130
  }): Promise<string>;
124
- type KeyLookupFunction = (header: JWSProtectedHeader) => CryptoKey | JWK | Uint8Array | Promise<CryptoKey | JWK | Uint8Array>;
125
131
  /**
126
132
  * Verifies a JWS (JSON Web Signature) in Compact Serialization format.
127
133
  *
128
134
  * @param jws The JWS Compact Serialization string.
129
- * @param key The verification key (CryptoKey, JWK, raw symmetric key as Uint8Array, or a function resolving the key).
135
+ * @param key The verification key (CryptoKey, JWK, JWKSet, raw symmetric key as Uint8Array, or a function resolving the key or set).
130
136
  * @param options Verification options, such as allowed algorithms.
131
137
  * @returns A Promise resolving to an object containing the verified payload and protected header.
132
138
  * @throws If the JWS is invalid, signature verification fails, or options are not met.
133
139
  */
134
- declare function verify<T = JWTClaims | Uint8Array | string>(jws: string, key: CryptoKey | JWK | Uint8Array | KeyLookupFunction, options?: JWSVerifyOptions): Promise<JWSVerifyResult<T>>;
135
- declare function verify(jws: string, key: CryptoKey | JWK | Uint8Array | KeyLookupFunction, options: JWSVerifyOptions & {
140
+ declare function verify<T = JWTClaims | Uint8Array | string>(jws: string, key: CryptoKey | JWK | JWKSet | Uint8Array | JWSKeyLookupFunction, options?: JWSVerifyOptions): Promise<JWSVerifyResult<T>>;
141
+ declare function verify(jws: string, key: CryptoKey | JWK | JWKSet | Uint8Array | JWSKeyLookupFunction, options: JWSVerifyOptions & {
136
142
  forceUint8Array: true;
137
143
  }): Promise<JWSVerifyResult<Uint8Array>>;
138
144
 
139
145
  type jws_JWSAlgorithm = JWSAlgorithm;
140
146
  type jws_JWSHeaderParameters = JWSHeaderParameters;
147
+ type jws_JWSKeyLookupFunction = JWSKeyLookupFunction;
141
148
  type jws_JWSProtectedHeader = JWSProtectedHeader;
142
149
  type jws_JWSSignOptions = JWSSignOptions;
143
150
  type jws_JWSVerifyOptions = JWSVerifyOptions;
@@ -146,8 +153,8 @@ declare const jws_sign: typeof sign;
146
153
  declare const jws_verify: typeof verify;
147
154
  declare namespace jws {
148
155
  export { jws_sign as sign, jws_verify as verify };
149
- export type { jws_JWSAlgorithm as JWSAlgorithm, jws_JWSHeaderParameters as JWSHeaderParameters, jws_JWSProtectedHeader as JWSProtectedHeader, jws_JWSSignOptions as JWSSignOptions, jws_JWSVerifyOptions as JWSVerifyOptions, jws_JWSVerifyResult as JWSVerifyResult };
156
+ export type { jws_JWSAlgorithm as JWSAlgorithm, jws_JWSHeaderParameters as JWSHeaderParameters, jws_JWSKeyLookupFunction as JWSKeyLookupFunction, jws_JWSProtectedHeader as JWSProtectedHeader, jws_JWSSignOptions as JWSSignOptions, jws_JWSVerifyOptions as JWSVerifyOptions, jws_JWSVerifyResult as JWSVerifyResult };
150
157
  }
151
158
 
152
159
  export { jws as j, sign as s, verify as v };
153
- export type { JWSAlgorithm as J, JWSHeaderParameters as a, JWSProtectedHeader as b, JWSSignOptions as c, JWSVerifyResult as d, JWSVerifyOptions as e };
160
+ export type { JWSAlgorithm as J, JWSHeaderParameters as a, JWSProtectedHeader as b, JWSSignOptions as c, JWSVerifyResult as d, JWSVerifyOptions as e, JWSKeyLookupFunction as f };
@@ -1,4 +1,4 @@
1
- import { i as JWK_RSA_Public } from './unjwt.CxhGjEAX.mjs';
1
+ import { i as JWK_RSA_Public } from './unjwt.D9da8HQF.mjs';
2
2
 
3
3
  /** Header Parameters common to JWE and JWS */
4
4
  interface JoseHeaderParameters {
@@ -1,5 +1,5 @@
1
- import { n as JWK_HMAC, o as JWK_RSA_SIGN, p as JWK_RSA_PSS, q as JWK_ECDSA, m as JWK } from './unjwt.CxhGjEAX.mjs';
2
- import { J as JoseHeaderParameters, a as JWTClaims } from './unjwt.Cd9nTEWg.mjs';
1
+ import { o as JWK_HMAC, p as JWK_RSA_SIGN, q as JWK_RSA_PSS, r as JWK_ECDSA, m as JWK, n as JWKSet } from './unjwt.D9da8HQF.js';
2
+ import { J as JoseHeaderParameters, a as JWTClaims } from './unjwt.c10n3uM8.js';
3
3
 
4
4
  type JWS_SIGN_EXTRA = "Ed25519" | "EdDSA";
5
5
  /** JWS Signing Algorithm Identifier. */
@@ -101,6 +101,13 @@ interface JWSVerifyOptions {
101
101
  */
102
102
  critical?: string[];
103
103
  }
104
+ /**
105
+ * Key lookup function for JWS verification.
106
+ * @param header The JWS Protected Header.
107
+ * @param token The JWS token.
108
+ * @returns The key material (CryptoKey, JWK, or raw Uint8Array) or a Promise resolving to it.
109
+ */
110
+ type JWSKeyLookupFunction = (header: JWSProtectedHeader, token: string) => CryptoKey | JWK | JWKSet | Uint8Array | Promise<CryptoKey | JWK | JWKSet | Uint8Array>;
104
111
 
105
112
  /**
106
113
  * Creates a JWS (JSON Web Signature) in Compact Serialization format.
@@ -121,23 +128,23 @@ declare function sign(payload: string | Uint8Array | Record<string, any>, key: C
121
128
  declare function sign(payload: string | Uint8Array | Record<string, any>, key: CryptoKey | JWK | Uint8Array, options: JWSSignOptions & {
122
129
  alg: JWSAlgorithm;
123
130
  }): Promise<string>;
124
- type KeyLookupFunction = (header: JWSProtectedHeader) => CryptoKey | JWK | Uint8Array | Promise<CryptoKey | JWK | Uint8Array>;
125
131
  /**
126
132
  * Verifies a JWS (JSON Web Signature) in Compact Serialization format.
127
133
  *
128
134
  * @param jws The JWS Compact Serialization string.
129
- * @param key The verification key (CryptoKey, JWK, raw symmetric key as Uint8Array, or a function resolving the key).
135
+ * @param key The verification key (CryptoKey, JWK, JWKSet, raw symmetric key as Uint8Array, or a function resolving the key or set).
130
136
  * @param options Verification options, such as allowed algorithms.
131
137
  * @returns A Promise resolving to an object containing the verified payload and protected header.
132
138
  * @throws If the JWS is invalid, signature verification fails, or options are not met.
133
139
  */
134
- declare function verify<T = JWTClaims | Uint8Array | string>(jws: string, key: CryptoKey | JWK | Uint8Array | KeyLookupFunction, options?: JWSVerifyOptions): Promise<JWSVerifyResult<T>>;
135
- declare function verify(jws: string, key: CryptoKey | JWK | Uint8Array | KeyLookupFunction, options: JWSVerifyOptions & {
140
+ declare function verify<T = JWTClaims | Uint8Array | string>(jws: string, key: CryptoKey | JWK | JWKSet | Uint8Array | JWSKeyLookupFunction, options?: JWSVerifyOptions): Promise<JWSVerifyResult<T>>;
141
+ declare function verify(jws: string, key: CryptoKey | JWK | JWKSet | Uint8Array | JWSKeyLookupFunction, options: JWSVerifyOptions & {
136
142
  forceUint8Array: true;
137
143
  }): Promise<JWSVerifyResult<Uint8Array>>;
138
144
 
139
145
  type jws_JWSAlgorithm = JWSAlgorithm;
140
146
  type jws_JWSHeaderParameters = JWSHeaderParameters;
147
+ type jws_JWSKeyLookupFunction = JWSKeyLookupFunction;
141
148
  type jws_JWSProtectedHeader = JWSProtectedHeader;
142
149
  type jws_JWSSignOptions = JWSSignOptions;
143
150
  type jws_JWSVerifyOptions = JWSVerifyOptions;
@@ -146,8 +153,8 @@ declare const jws_sign: typeof sign;
146
153
  declare const jws_verify: typeof verify;
147
154
  declare namespace jws {
148
155
  export { jws_sign as sign, jws_verify as verify };
149
- export type { jws_JWSAlgorithm as JWSAlgorithm, jws_JWSHeaderParameters as JWSHeaderParameters, jws_JWSProtectedHeader as JWSProtectedHeader, jws_JWSSignOptions as JWSSignOptions, jws_JWSVerifyOptions as JWSVerifyOptions, jws_JWSVerifyResult as JWSVerifyResult };
156
+ export type { jws_JWSAlgorithm as JWSAlgorithm, jws_JWSHeaderParameters as JWSHeaderParameters, jws_JWSKeyLookupFunction as JWSKeyLookupFunction, jws_JWSProtectedHeader as JWSProtectedHeader, jws_JWSSignOptions as JWSSignOptions, jws_JWSVerifyOptions as JWSVerifyOptions, jws_JWSVerifyResult as JWSVerifyResult };
150
157
  }
151
158
 
152
159
  export { jws as j, sign as s, verify as v };
153
- export type { JWSAlgorithm as J, JWSHeaderParameters as a, JWSProtectedHeader as b, JWSSignOptions as c, JWSVerifyResult as d, JWSVerifyOptions as e };
160
+ export type { JWSAlgorithm as J, JWSHeaderParameters as a, JWSProtectedHeader as b, JWSSignOptions as c, JWSVerifyResult as d, JWSVerifyOptions as e, JWSKeyLookupFunction as f };
@@ -1,4 +1,4 @@
1
- import { c as checkSigCryptoKey } from './unjwt.ZsOShfhX.mjs';
1
+ import { c as checkSigCryptoKey } from './unjwt.BPpolBff.mjs';
2
2
 
3
3
  /**
4
4
  * This is a fork of Jose library's utility functions.
@@ -1,4 +1,4 @@
1
- import { m as JWK } from './unjwt.CxhGjEAX.mjs';
1
+ import { m as JWK, n as JWKSet } from './unjwt.D9da8HQF.mjs';
2
2
 
3
3
  declare const textEncoder: TextEncoder;
4
4
  declare const textDecoder: TextDecoder;
@@ -17,6 +17,7 @@ declare function randomBytes(length: Readonly<number>): Uint8Array;
17
17
  declare function concatUint8Arrays(...arrays: Readonly<Uint8Array[]>): Uint8Array;
18
18
  declare function maybeArray<T>(item: T | T[]): T[];
19
19
  declare function isJWK(key: any): key is JWK;
20
+ declare function isJWKSet(key: any): key is JWKSet;
20
21
  declare function assertCryptoKey(key: unknown): asserts key is CryptoKey;
21
22
  declare function isCryptoKey(key: unknown): key is CryptoKey;
22
23
  declare const isCryptoKeyPair: (key: any) => key is CryptoKeyPair;
@@ -30,6 +31,7 @@ declare const index_concatUint8Arrays: typeof concatUint8Arrays;
30
31
  declare const index_isCryptoKey: typeof isCryptoKey;
31
32
  declare const index_isCryptoKeyPair: typeof isCryptoKeyPair;
32
33
  declare const index_isJWK: typeof isJWK;
34
+ declare const index_isJWKSet: typeof isJWKSet;
33
35
  declare const index_maybeArray: typeof maybeArray;
34
36
  declare const index_randomBytes: typeof randomBytes;
35
37
  declare const index_textDecoder: typeof textDecoder;
@@ -45,6 +47,7 @@ declare namespace index {
45
47
  index_isCryptoKey as isCryptoKey,
46
48
  index_isCryptoKeyPair as isCryptoKeyPair,
47
49
  index_isJWK as isJWK,
50
+ index_isJWKSet as isJWKSet,
48
51
  index_maybeArray as maybeArray,
49
52
  index_randomBytes as randomBytes,
50
53
  index_textDecoder as textDecoder,
@@ -52,4 +55,4 @@ declare namespace index {
52
55
  };
53
56
  }
54
57
 
55
- export { textDecoder as a, base64Encode as b, base64UrlEncode as c, base64Decode as d, base64UrlDecode as e, concatUint8Arrays as f, isJWK as g, assertCryptoKey as h, index as i, isCryptoKey as j, isCryptoKeyPair as k, maybeArray as m, randomBytes as r, textEncoder as t };
58
+ export { textDecoder as a, base64Encode as b, base64UrlEncode as c, base64Decode as d, base64UrlDecode as e, concatUint8Arrays as f, isJWK as g, isJWKSet as h, index as i, assertCryptoKey as j, isCryptoKey as k, isCryptoKeyPair as l, maybeArray as m, randomBytes as r, textEncoder as t };
@@ -1,4 +1,4 @@
1
- import { m as JWK } from './unjwt.CxhGjEAX.js';
1
+ import { m as JWK, n as JWKSet } from './unjwt.D9da8HQF.js';
2
2
 
3
3
  declare const textEncoder: TextEncoder;
4
4
  declare const textDecoder: TextDecoder;
@@ -17,6 +17,7 @@ declare function randomBytes(length: Readonly<number>): Uint8Array;
17
17
  declare function concatUint8Arrays(...arrays: Readonly<Uint8Array[]>): Uint8Array;
18
18
  declare function maybeArray<T>(item: T | T[]): T[];
19
19
  declare function isJWK(key: any): key is JWK;
20
+ declare function isJWKSet(key: any): key is JWKSet;
20
21
  declare function assertCryptoKey(key: unknown): asserts key is CryptoKey;
21
22
  declare function isCryptoKey(key: unknown): key is CryptoKey;
22
23
  declare const isCryptoKeyPair: (key: any) => key is CryptoKeyPair;
@@ -30,6 +31,7 @@ declare const index_concatUint8Arrays: typeof concatUint8Arrays;
30
31
  declare const index_isCryptoKey: typeof isCryptoKey;
31
32
  declare const index_isCryptoKeyPair: typeof isCryptoKeyPair;
32
33
  declare const index_isJWK: typeof isJWK;
34
+ declare const index_isJWKSet: typeof isJWKSet;
33
35
  declare const index_maybeArray: typeof maybeArray;
34
36
  declare const index_randomBytes: typeof randomBytes;
35
37
  declare const index_textDecoder: typeof textDecoder;
@@ -45,6 +47,7 @@ declare namespace index {
45
47
  index_isCryptoKey as isCryptoKey,
46
48
  index_isCryptoKeyPair as isCryptoKeyPair,
47
49
  index_isJWK as isJWK,
50
+ index_isJWKSet as isJWKSet,
48
51
  index_maybeArray as maybeArray,
49
52
  index_randomBytes as randomBytes,
50
53
  index_textDecoder as textDecoder,
@@ -52,4 +55,4 @@ declare namespace index {
52
55
  };
53
56
  }
54
57
 
55
- export { textDecoder as a, base64Encode as b, base64UrlEncode as c, base64Decode as d, base64UrlDecode as e, concatUint8Arrays as f, isJWK as g, assertCryptoKey as h, index as i, isCryptoKey as j, isCryptoKeyPair as k, maybeArray as m, randomBytes as r, textEncoder as t };
58
+ export { textDecoder as a, base64Encode as b, base64UrlEncode as c, base64Decode as d, base64UrlDecode as e, concatUint8Arrays as f, isJWK as g, isJWKSet as h, index as i, assertCryptoKey as j, isCryptoKey as k, isCryptoKeyPair as l, maybeArray as m, randomBytes as r, textEncoder as t };
@@ -178,9 +178,17 @@ interface JWK_oct extends JWKParameters {
178
178
  k: string;
179
179
  }
180
180
  /**
181
- * JSON Web Key ({@link https://www.rfc-editor.org/rfc/rfc7517 JWK}). "RSA" and "oct" key types are supported.
181
+ * JSON Web Key ({@link https://www.rfc-editor.org/rfc/rfc7517 JWK}). "RSA", "EC" and "oct" key types are supported.
182
182
  */
183
183
  type JWK = JWK_oct | JWK_RSA | JWK_EC;
184
+ /**
185
+ * JSON Web Key Set ({@link https://www.rfc-editor.org/rfc/rfc7517 JWK Set}). "RSA", "EC" and "oct" key types are supported.
186
+ */
187
+ interface JWKSet {
188
+ /** JWK Set "keys" Parameter */
189
+ keys: JWK[];
190
+ [parameter: string]: unknown;
191
+ }
184
192
  /** JWK Key Algorithms */
185
193
  type JWK_HMAC = "HS256" | "HS384" | "HS512";
186
194
  type JWK_RSA_SIGN = "RS256" | "RS384" | "RS512";
@@ -199,4 +207,4 @@ type JWK_Asymmetric_Algorithm = JWK_RSA_SIGN | JWK_RSA_PSS | JWK_ECDSA | JWK_RSA
199
207
  type JWKAlgorithm = JWK_Symmetric_Algorithm | JWK_Asymmetric_Algorithm | JWK_AES_CBC_HMAC | JWK_PBES2 | JWK_ECDH_ES | ("none" | "dir");
200
208
  type JWKPEMAlgorithm = JWK_RSA_PSS | JWK_RSA_SIGN | JWK_RSA_ENC | JWK_ECDSA | JWK_ECDH_ES | JWK_ED;
201
209
 
202
- export type { JWK_Asymmetric_Algorithm as A, JWKAlgorithm as B, CompositeKey as C, DeriveKeyOptions as D, JWKPEMAlgorithm as E, GenerateKeyAlgorithm as G, JWKParameters as J, KeyManagementAlgorithm as K, UnwrapKeyOptions as U, WrapKeyOptions as W, GenerateKeyOptions as a, GenerateKeyReturn as b, DeriveKeyReturn as c, ContentEncryptionAlgorithm as d, WrapKeyResult as e, JWK_EC_Public as f, JWK_EC_Private as g, JWK_EC as h, JWK_RSA_Public as i, JWK_RSA_Private as j, JWK_RSA as k, JWK_oct as l, JWK as m, JWK_HMAC as n, JWK_RSA_SIGN as o, JWK_RSA_PSS as p, JWK_ECDSA as q, JWK_RSA_ENC as r, JWK_AES_KW as s, JWK_AES_GCM_KW as t, JWK_AES_CBC_HMAC as u, JWK_AES_GCM as v, JWK_PBES2 as w, JWK_ECDH_ES as x, JWK_ED as y, JWK_Symmetric_Algorithm as z };
210
+ export type { JWK_Symmetric_Algorithm as A, JWK_Asymmetric_Algorithm as B, CompositeKey as C, DeriveKeyOptions as D, JWKAlgorithm as E, JWKPEMAlgorithm as F, GenerateKeyAlgorithm as G, JWKParameters as J, KeyManagementAlgorithm as K, UnwrapKeyOptions as U, WrapKeyOptions as W, GenerateKeyOptions as a, GenerateKeyReturn as b, DeriveKeyReturn as c, ContentEncryptionAlgorithm as d, WrapKeyResult as e, JWK_EC_Public as f, JWK_EC_Private as g, JWK_EC as h, JWK_RSA_Public as i, JWK_RSA_Private as j, JWK_RSA as k, JWK_oct as l, JWK as m, JWKSet as n, JWK_HMAC as o, JWK_RSA_SIGN as p, JWK_RSA_PSS as q, JWK_ECDSA as r, JWK_RSA_ENC as s, JWK_AES_KW as t, JWK_AES_GCM_KW as u, JWK_AES_CBC_HMAC as v, JWK_AES_GCM as w, JWK_PBES2 as x, JWK_ECDH_ES as y, JWK_ED as z };
@@ -178,9 +178,17 @@ interface JWK_oct extends JWKParameters {
178
178
  k: string;
179
179
  }
180
180
  /**
181
- * JSON Web Key ({@link https://www.rfc-editor.org/rfc/rfc7517 JWK}). "RSA" and "oct" key types are supported.
181
+ * JSON Web Key ({@link https://www.rfc-editor.org/rfc/rfc7517 JWK}). "RSA", "EC" and "oct" key types are supported.
182
182
  */
183
183
  type JWK = JWK_oct | JWK_RSA | JWK_EC;
184
+ /**
185
+ * JSON Web Key Set ({@link https://www.rfc-editor.org/rfc/rfc7517 JWK Set}). "RSA", "EC" and "oct" key types are supported.
186
+ */
187
+ interface JWKSet {
188
+ /** JWK Set "keys" Parameter */
189
+ keys: JWK[];
190
+ [parameter: string]: unknown;
191
+ }
184
192
  /** JWK Key Algorithms */
185
193
  type JWK_HMAC = "HS256" | "HS384" | "HS512";
186
194
  type JWK_RSA_SIGN = "RS256" | "RS384" | "RS512";
@@ -199,4 +207,4 @@ type JWK_Asymmetric_Algorithm = JWK_RSA_SIGN | JWK_RSA_PSS | JWK_ECDSA | JWK_RSA
199
207
  type JWKAlgorithm = JWK_Symmetric_Algorithm | JWK_Asymmetric_Algorithm | JWK_AES_CBC_HMAC | JWK_PBES2 | JWK_ECDH_ES | ("none" | "dir");
200
208
  type JWKPEMAlgorithm = JWK_RSA_PSS | JWK_RSA_SIGN | JWK_RSA_ENC | JWK_ECDSA | JWK_ECDH_ES | JWK_ED;
201
209
 
202
- export type { JWK_Asymmetric_Algorithm as A, JWKAlgorithm as B, CompositeKey as C, DeriveKeyOptions as D, JWKPEMAlgorithm as E, GenerateKeyAlgorithm as G, JWKParameters as J, KeyManagementAlgorithm as K, UnwrapKeyOptions as U, WrapKeyOptions as W, GenerateKeyOptions as a, GenerateKeyReturn as b, DeriveKeyReturn as c, ContentEncryptionAlgorithm as d, WrapKeyResult as e, JWK_EC_Public as f, JWK_EC_Private as g, JWK_EC as h, JWK_RSA_Public as i, JWK_RSA_Private as j, JWK_RSA as k, JWK_oct as l, JWK as m, JWK_HMAC as n, JWK_RSA_SIGN as o, JWK_RSA_PSS as p, JWK_ECDSA as q, JWK_RSA_ENC as r, JWK_AES_KW as s, JWK_AES_GCM_KW as t, JWK_AES_CBC_HMAC as u, JWK_AES_GCM as v, JWK_PBES2 as w, JWK_ECDH_ES as x, JWK_ED as y, JWK_Symmetric_Algorithm as z };
210
+ export type { JWK_Symmetric_Algorithm as A, JWK_Asymmetric_Algorithm as B, CompositeKey as C, DeriveKeyOptions as D, JWKAlgorithm as E, JWKPEMAlgorithm as F, GenerateKeyAlgorithm as G, JWKParameters as J, KeyManagementAlgorithm as K, UnwrapKeyOptions as U, WrapKeyOptions as W, GenerateKeyOptions as a, GenerateKeyReturn as b, DeriveKeyReturn as c, ContentEncryptionAlgorithm as d, WrapKeyResult as e, JWK_EC_Public as f, JWK_EC_Private as g, JWK_EC as h, JWK_RSA_Public as i, JWK_RSA_Private as j, JWK_RSA as k, JWK_oct as l, JWK as m, JWKSet as n, JWK_HMAC as o, JWK_RSA_SIGN as p, JWK_RSA_PSS as q, JWK_ECDSA as r, JWK_RSA_ENC as s, JWK_AES_KW as t, JWK_AES_GCM_KW as u, JWK_AES_CBC_HMAC as v, JWK_AES_GCM as w, JWK_PBES2 as x, JWK_ECDH_ES as y, JWK_ED as z };
@@ -1,5 +1,5 @@
1
- import { K as KeyManagementAlgorithm, d as ContentEncryptionAlgorithm, f as JWK_EC_Public, m as JWK } from './unjwt.CxhGjEAX.mjs';
2
- import { J as JoseHeaderParameters, a as JWTClaims } from './unjwt.Cd9nTEWg.mjs';
1
+ import { K as KeyManagementAlgorithm, d as ContentEncryptionAlgorithm, f as JWK_EC_Public, m as JWK } from './unjwt.D9da8HQF.mjs';
2
+ import { J as JoseHeaderParameters, a as JWTClaims } from './unjwt.BvIkEGGz.mjs';
3
3
 
4
4
  /** Recognized JWE Header Parameters, any other Header Members may also be present. */
5
5
  interface JWEHeaderParameters extends JoseHeaderParameters {
@@ -99,7 +99,7 @@ interface JWEEncryptOptions {
99
99
  * @param header The JWE Protected Header.
100
100
  * @returns The key material (CryptoKey, JWK, password string, or raw Uint8Array) or a Promise resolving to it.
101
101
  */
102
- type JWEKeyLookupFunction = (header: JWEHeaderParameters) => CryptoKey | JWK | string | Uint8Array | Promise<CryptoKey | JWK | string | Uint8Array>;
102
+ type JWEKeyLookupFunction = (header: JWEHeaderParameters, token: string) => CryptoKey | JWK | string | Uint8Array | Promise<CryptoKey | JWK | string | Uint8Array>;
103
103
  /**
104
104
  * JWE (JSON Web Encryption) decryption options
105
105
  */
@@ -1,4 +1,5 @@
1
- import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, w as JWK_PBES2, D as DeriveKeyOptions, c as DeriveKeyReturn, l as JWK_oct, m as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, e as WrapKeyResult, U as UnwrapKeyOptions, E as JWKPEMAlgorithm, C as CompositeKey, d as ContentEncryptionAlgorithm, B as JWKAlgorithm, J as JWKParameters, u as JWK_AES_CBC_HMAC, v as JWK_AES_GCM, t as JWK_AES_GCM_KW, s as JWK_AES_KW, A as JWK_Asymmetric_Algorithm, h as JWK_EC, x as JWK_ECDH_ES, q as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, y as JWK_ED, n as JWK_HMAC, k as JWK_RSA, r as JWK_RSA_ENC, p as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, o as JWK_RSA_SIGN, z as JWK_Symmetric_Algorithm } from './unjwt.CxhGjEAX.js';
1
+ import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, x as JWK_PBES2, D as DeriveKeyOptions, c as DeriveKeyReturn, l as JWK_oct, m as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, e as WrapKeyResult, U as UnwrapKeyOptions, F as JWKPEMAlgorithm, n as JWKSet, C as CompositeKey, d as ContentEncryptionAlgorithm, E as JWKAlgorithm, J as JWKParameters, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm } from './unjwt.D9da8HQF.mjs';
2
+ import { J as JoseHeaderParameters } from './unjwt.BvIkEGGz.mjs';
2
3
 
3
4
  /**
4
5
  * This is a fork of Jose library's utility functions.
@@ -101,6 +102,25 @@ declare function importJWKFromPEM(pem: string, pemType: "pkcs8" | "spki" | "x509
101
102
  * @returns A Promise resolving to the PEM-encoded key string.
102
103
  */
103
104
  declare function exportJWKToPEM(jwk: JWK, pemFormat: "pkcs8" | "spki", algForCryptoKeyImport?: JWKPEMAlgorithm): Promise<string>;
105
+ /**
106
+ * Retrieves a JWK (JSON Web Key) from a JWKSet based on a key ID (kid) or
107
+ * properties from a JOSE Header.
108
+ *
109
+ * @param jwkSet The JWKSet to search within.
110
+ * @param kidOrProtectedHeader Either a string representing the 'kid' (Key ID)
111
+ * or an object representing the JOSE Protected Header. If an object is
112
+ * provided, it must contain a 'kid' property. It can optionally contain
113
+ * 'alg' (Algorithm) and 'kty' (Key Type) to further refine the search.
114
+ * @returns The matching JWK from the set.
115
+ * @throws TypeError if `jwkSet` is invalid or `kidOrProtectedHeader` is not a
116
+ * string or a valid header object.
117
+ * @throws Error if no key is found matching the provided criteria, or if the
118
+ * header object is missing the 'kid' property.
119
+ */
120
+ declare function getJWKFromSet(jwkSet: JWKSet, kidOrProtectedHeader: string | (JoseHeaderParameters & {
121
+ alg?: string;
122
+ kty?: string;
123
+ })): JWK;
104
124
 
105
125
  declare const jwk_CompositeKey: typeof CompositeKey;
106
126
  declare const jwk_ContentEncryptionAlgorithm: typeof ContentEncryptionAlgorithm;
@@ -113,6 +133,7 @@ declare const jwk_JWK: typeof JWK;
113
133
  declare const jwk_JWKAlgorithm: typeof JWKAlgorithm;
114
134
  declare const jwk_JWKPEMAlgorithm: typeof JWKPEMAlgorithm;
115
135
  declare const jwk_JWKParameters: typeof JWKParameters;
136
+ declare const jwk_JWKSet: typeof JWKSet;
116
137
  declare const jwk_JWK_AES_CBC_HMAC: typeof JWK_AES_CBC_HMAC;
117
138
  declare const jwk_JWK_AES_GCM: typeof JWK_AES_GCM;
118
139
  declare const jwk_JWK_AES_GCM_KW: typeof JWK_AES_GCM_KW;
@@ -142,6 +163,7 @@ declare const jwk_deriveKeyFromPassword: typeof deriveKeyFromPassword;
142
163
  declare const jwk_exportJWKToPEM: typeof exportJWKToPEM;
143
164
  declare const jwk_exportKey: typeof exportKey;
144
165
  declare const jwk_generateKey: typeof generateKey;
166
+ declare const jwk_getJWKFromSet: typeof getJWKFromSet;
145
167
  declare const jwk_importJWKFromPEM: typeof importJWKFromPEM;
146
168
  declare const jwk_importKey: typeof importKey;
147
169
  declare const jwk_unwrapKey: typeof unwrapKey;
@@ -159,6 +181,7 @@ declare namespace jwk {
159
181
  jwk_JWKAlgorithm as JWKAlgorithm,
160
182
  jwk_JWKPEMAlgorithm as JWKPEMAlgorithm,
161
183
  jwk_JWKParameters as JWKParameters,
184
+ jwk_JWKSet as JWKSet,
162
185
  jwk_JWK_AES_CBC_HMAC as JWK_AES_CBC_HMAC,
163
186
  jwk_JWK_AES_GCM as JWK_AES_GCM,
164
187
  jwk_JWK_AES_GCM_KW as JWK_AES_GCM_KW,
@@ -188,6 +211,7 @@ declare namespace jwk {
188
211
  jwk_exportJWKToPEM as exportJWKToPEM,
189
212
  jwk_exportKey as exportKey,
190
213
  jwk_generateKey as generateKey,
214
+ jwk_getJWKFromSet as getJWKFromSet,
191
215
  jwk_importJWKFromPEM as importJWKFromPEM,
192
216
  jwk_importKey as importKey,
193
217
  jwk_unwrapKey as unwrapKey,
@@ -195,4 +219,4 @@ declare namespace jwk {
195
219
  };
196
220
  }
197
221
 
198
- export { importJWKFromPEM as a, exportJWKToPEM as b, deriveKeyFromPassword as d, exportKey as e, generateKey as g, importKey as i, jwk as j, unwrapKey as u, wrapKey as w };
222
+ export { importJWKFromPEM as a, exportJWKToPEM as b, getJWKFromSet as c, deriveKeyFromPassword as d, exportKey as e, generateKey as g, importKey as i, jwk as j, unwrapKey as u, wrapKey as w };
@@ -1,6 +1,6 @@
1
- import { i as importKey } from './unjwt.ZsOShfhX.mjs';
2
- import { a as isJWK, b as base64UrlEncode, t as textEncoder, c as textDecoder, d as base64UrlDecode, m as maybeArray } from './unjwt.DOI5UE8K.mjs';
3
- import { s as sign$1, v as verify$1 } from './unjwt.z_U3fRJ-.mjs';
1
+ import { i as importKey, g as getJWKFromSet } from './unjwt.BPpolBff.mjs';
2
+ import { a as isJWK, b as base64UrlEncode, t as textEncoder, c as textDecoder, d as base64UrlDecode, e as isJWKSet, m as maybeArray } from './unjwt.X5vzu_l_.mjs';
3
+ import { s as sign$1, v as verify$1 } from './unjwt.CauxOPN5.mjs';
4
4
 
5
5
  async function sign(payload, key, options = {}) {
6
6
  const { protectedHeader: additionalProtectedHeader } = options;
@@ -85,7 +85,8 @@ async function verify(jws, key, options = {}) {
85
85
  `Invalid JWS: Signature is not valid Base64URL (${error_ instanceof Error ? error_.message : error_})`
86
86
  );
87
87
  }
88
- const resolvedKey = typeof key === "function" ? await key(protectedHeader) : key;
88
+ const keyInput = typeof key === "function" ? await key(protectedHeader, jws) : key;
89
+ const resolvedKey = isJWKSet(keyInput) ? getJWKFromSet(keyInput, protectedHeader) : keyInput;
89
90
  const verificationKey = await importKey(resolvedKey, alg);
90
91
  const signingInputString = `${protectedHeaderEncoded}.${payloadEncoded}`;
91
92
  const signingInputBytes = textEncoder.encode(signingInputString);
@@ -57,6 +57,9 @@ function maybeArray(item) {
57
57
  function isJWK(key) {
58
58
  return typeof key === "object" && key !== null && "kty" in key && typeof key.kty === "string";
59
59
  }
60
+ function isJWKSet(key) {
61
+ return key && typeof key === "object" && "keys" in key && Array.isArray(key.keys);
62
+ }
60
63
  function assertCryptoKey(key) {
61
64
  if (!isCryptoKey(key)) {
62
65
  throw new Error("CryptoKey instance expected");
@@ -78,10 +81,11 @@ const index = {
78
81
  isCryptoKey: isCryptoKey,
79
82
  isCryptoKeyPair: isCryptoKeyPair,
80
83
  isJWK: isJWK,
84
+ isJWKSet: isJWKSet,
81
85
  maybeArray: maybeArray,
82
86
  randomBytes: randomBytes,
83
87
  textDecoder: textDecoder,
84
88
  textEncoder: textEncoder
85
89
  };
86
90
 
87
- export { isJWK as a, base64UrlEncode as b, textDecoder as c, base64UrlDecode as d, concatUint8Arrays as e, assertCryptoKey as f, isCryptoKey as g, base64Decode as h, index as i, base64Encode as j, isCryptoKeyPair as k, maybeArray as m, randomBytes as r, textEncoder as t };
91
+ export { isJWK as a, base64UrlEncode as b, textDecoder as c, base64UrlDecode as d, isJWKSet as e, concatUint8Arrays as f, assertCryptoKey as g, isCryptoKey as h, index as i, base64Decode as j, base64Encode as k, isCryptoKeyPair as l, maybeArray as m, randomBytes as r, textEncoder as t };
@@ -1,4 +1,4 @@
1
- import { i as JWK_RSA_Public } from './unjwt.CxhGjEAX.js';
1
+ import { i as JWK_RSA_Public } from './unjwt.D9da8HQF.js';
2
2
 
3
3
  /** Header Parameters common to JWE and JWS */
4
4
  interface JoseHeaderParameters {
package/dist/utils.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import './shared/unjwt.CxhGjEAX.mjs';
2
- export { h as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, f as concatUint8Arrays, j as isCryptoKey, k as isCryptoKeyPair, g as isJWK, m as maybeArray, r as randomBytes, a as textDecoder, t as textEncoder } from './shared/unjwt.BJEchXrM.mjs';
1
+ import './shared/unjwt.D9da8HQF.mjs';
2
+ export { j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, f as concatUint8Arrays, k as isCryptoKey, l as isCryptoKeyPair, g as isJWK, h as isJWKSet, m as maybeArray, r as randomBytes, a as textDecoder, t as textEncoder } from './shared/unjwt.CbvzYE-m.mjs';
package/dist/utils.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import './shared/unjwt.CxhGjEAX.js';
2
- export { h as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, f as concatUint8Arrays, j as isCryptoKey, k as isCryptoKeyPair, g as isJWK, m as maybeArray, r as randomBytes, a as textDecoder, t as textEncoder } from './shared/unjwt.B5N3dPN9.js';
1
+ import './shared/unjwt.D9da8HQF.js';
2
+ export { j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, f as concatUint8Arrays, k as isCryptoKey, l as isCryptoKeyPair, g as isJWK, h as isJWKSet, m as maybeArray, r as randomBytes, a as textDecoder, t as textEncoder } from './shared/unjwt.D4DUiNeM.js';
package/dist/utils.mjs CHANGED
@@ -1 +1 @@
1
- export { f as assertCryptoKey, h as base64Decode, j as base64Encode, d as base64UrlDecode, b as base64UrlEncode, e as concatUint8Arrays, g as isCryptoKey, k as isCryptoKeyPair, a as isJWK, m as maybeArray, r as randomBytes, c as textDecoder, t as textEncoder } from './shared/unjwt.DOI5UE8K.mjs';
1
+ export { g as assertCryptoKey, j as base64Decode, k as base64Encode, d as base64UrlDecode, b as base64UrlEncode, f as concatUint8Arrays, h as isCryptoKey, l as isCryptoKeyPair, a as isJWK, e as isJWKSet, m as maybeArray, r as randomBytes, c as textDecoder, t as textEncoder } from './shared/unjwt.X5vzu_l_.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unjwt",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Low-level JWT utilities",
5
5
  "repository": "sandros94/unjwt",
6
6
  "license": "MIT",