unjwt 0.5.16 → 0.5.17

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.
@@ -1,4 +1,4 @@
1
- import { K as KeyManagementAlgorithm, d as ContentEncryptionAlgorithm, O as JoseHeaderParameters, f as JWK_EC_Public, r as JWK, R as JWTClaimValidationOptions, P as JWTClaims, C as CompositeKey, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, M as JWKAlgorithm, N as JWKPEMAlgorithm, J as JWKParameters, s as JWKSet, A as JWK_AES_CBC_HMAC, B as JWK_AES_GCM, z as JWK_AES_GCM_KW, y as JWK_AES_KW, L as JWK_Asymmetric_Algorithm, h as JWK_EC, F as JWK_ECDH_ES, w as JWK_ECDSA, g as JWK_EC_Private, t as JWK_HMAC, n as JWK_OKP, m as JWK_OKP_Private, l as JWK_OKP_Public, H as JWK_OKP_SIGN, E as JWK_PBES2, q as JWK_Private, p as JWK_Public, k as JWK_RSA, x as JWK_RSA_ENC, v as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, u as JWK_RSA_SIGN, I as JWK_Symmetric_Algorithm, o as JWK_oct, Q as JWT, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './unjwt.OzI0aGB_.mjs';
1
+ import { K as KeyManagementAlgorithm, f as ContentEncryptionAlgorithm, Q as JoseHeaderParameters, h as JWK_EC_Public, i as JWK_EC_Private, t as JWK, T as JWTClaimValidationOptions, R as JWTClaims, C as CompositeKey, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.ClaeEBcy.mjs';
2
2
 
3
3
  /** Recognized JWE Header Parameters, any other Header Members may also be present. */
4
4
  interface JWEHeaderParameters extends JoseHeaderParameters {
@@ -60,7 +60,11 @@ interface JWEKeyManagementHeaderParameters {
60
60
  /**
61
61
  * For Internal use only
62
62
  */
63
- epk?: CryptoKey;
63
+ epk?: CryptoKey | JWK_EC_Public;
64
+ /**
65
+ * For Internal use only
66
+ */
67
+ epkPrivateKey?: CryptoKey | JWK_EC_Private;
64
68
  }
65
69
  /**
66
70
  * JWE (JSON Web Encryption) encryption options
@@ -75,17 +79,28 @@ interface JWEEncryptOptions {
75
79
  /** Time at which the JWT should expire, if no `exp` was already provided (only when typ is "JWT" or explicitly parsing JWT). */
76
80
  expiresIn?: number;
77
81
  /** Additional JWE Protected Header parameters. */
78
- protectedHeader?: Omit<JWEHeaderParameters, "alg" | "enc" | "iv" | "tag" | "p2s" | "p2c" | "apu" | "apv">;
82
+ protectedHeader?: Omit<JWEHeaderParameters, "alg" | "enc" | "iv" | "tag" | "p2s" | "p2c" | "epk" | "apu" | "apv">;
79
83
  /** Initialization Vector for AES-GCMKW key wrapping. Generated if not provided. */
80
84
  keyManagementIV?: Uint8Array<ArrayBuffer>;
81
85
  /** PBES2 Salt value (p2s). Required for PBES2 algorithms. */
82
86
  p2s?: Uint8Array<ArrayBuffer>;
83
87
  /** PBES2 Iteration count (p2c). Required for PBES2 algorithms. */
84
88
  p2c?: number;
85
- /** ECDH-ES Agreement PartyUInfo. */
86
- ecdhPartyUInfo?: Uint8Array<ArrayBuffer>;
87
- /** ECDH-ES Agreement PartyVInfo. */
88
- ecdhPartyVInfo?: Uint8Array<ArrayBuffer>;
89
+ /** ECDH-ES specific options. */
90
+ ecdh?: {
91
+ /**
92
+ * ECDH-ES Ephemeral key material. Provide a private key (CryptoKey or JWK),
93
+ * a CryptoKeyPair, or an object exposing both public and private parts.
94
+ */
95
+ ephemeralKey?: CryptoKey | JWK_EC_Private | CryptoKeyPair | {
96
+ publicKey: CryptoKey | JWK_EC_Public;
97
+ privateKey: CryptoKey | JWK_EC_Private;
98
+ };
99
+ /** ECDH-ES Agreement PartyUInfo. */
100
+ partyUInfo?: Uint8Array<ArrayBuffer>;
101
+ /** ECDH-ES Agreement PartyVInfo. */
102
+ partyVInfo?: Uint8Array<ArrayBuffer>;
103
+ };
89
104
  /**
90
105
  * Content Encryption Key (CEK) to use.
91
106
  * If provided, it will be used directly. Otherwise, a CEK will be generated.
@@ -176,6 +191,8 @@ declare const jwe_CompositeKey: typeof CompositeKey;
176
191
  declare const jwe_ContentEncryptionAlgorithm: typeof ContentEncryptionAlgorithm;
177
192
  declare const jwe_DeriveKeyOptions: typeof DeriveKeyOptions;
178
193
  declare const jwe_DeriveKeyReturn: typeof DeriveKeyReturn;
194
+ declare const jwe_GenerateJWKOptions: typeof GenerateJWKOptions;
195
+ declare const jwe_GenerateJWKReturn: typeof GenerateJWKReturn;
179
196
  declare const jwe_GenerateKeyAlgorithm: typeof GenerateKeyAlgorithm;
180
197
  declare const jwe_GenerateKeyOptions: typeof GenerateKeyOptions;
181
198
  declare const jwe_GenerateKeyReturn: typeof GenerateKeyReturn;
@@ -227,7 +244,7 @@ declare const jwe_WrapKeyResult: typeof WrapKeyResult;
227
244
  declare const jwe_decrypt: typeof decrypt;
228
245
  declare const jwe_encrypt: typeof encrypt;
229
246
  declare namespace jwe {
230
- export { jwe_CompositeKey as CompositeKey, jwe_ContentEncryptionAlgorithm as ContentEncryptionAlgorithm, jwe_DeriveKeyOptions as DeriveKeyOptions, jwe_DeriveKeyReturn as DeriveKeyReturn, jwe_GenerateKeyAlgorithm as GenerateKeyAlgorithm, jwe_GenerateKeyOptions as GenerateKeyOptions, jwe_GenerateKeyReturn as GenerateKeyReturn, jwe_JWK as JWK, jwe_JWKAlgorithm as JWKAlgorithm, jwe_JWKPEMAlgorithm as JWKPEMAlgorithm, jwe_JWKParameters as JWKParameters, jwe_JWKSet as JWKSet, jwe_JWK_AES_CBC_HMAC as JWK_AES_CBC_HMAC, jwe_JWK_AES_GCM as JWK_AES_GCM, jwe_JWK_AES_GCM_KW as JWK_AES_GCM_KW, jwe_JWK_AES_KW as JWK_AES_KW, jwe_JWK_Asymmetric_Algorithm as JWK_Asymmetric_Algorithm, jwe_JWK_EC as JWK_EC, jwe_JWK_ECDH_ES as JWK_ECDH_ES, jwe_JWK_ECDSA as JWK_ECDSA, jwe_JWK_EC_Private as JWK_EC_Private, jwe_JWK_EC_Public as JWK_EC_Public, jwe_JWK_HMAC as JWK_HMAC, jwe_JWK_OKP as JWK_OKP, jwe_JWK_OKP_Private as JWK_OKP_Private, jwe_JWK_OKP_Public as JWK_OKP_Public, jwe_JWK_OKP_SIGN as JWK_OKP_SIGN, jwe_JWK_PBES2 as JWK_PBES2, jwe_JWK_Private as JWK_Private, jwe_JWK_Public as JWK_Public, jwe_JWK_RSA as JWK_RSA, jwe_JWK_RSA_ENC as JWK_RSA_ENC, jwe_JWK_RSA_PSS as JWK_RSA_PSS, jwe_JWK_RSA_Private as JWK_RSA_Private, jwe_JWK_RSA_Public as JWK_RSA_Public, jwe_JWK_RSA_SIGN as JWK_RSA_SIGN, jwe_JWK_Symmetric_Algorithm as JWK_Symmetric_Algorithm, jwe_JWK_oct as JWK_oct, jwe_JWT as JWT, jwe_JWTClaimValidationOptions as JWTClaimValidationOptions, jwe_JWTClaims as JWTClaims, jwe_JoseHeaderParameters as JoseHeaderParameters, jwe_KeyManagementAlgorithm as KeyManagementAlgorithm, jwe_UnwrapKeyOptions as UnwrapKeyOptions, jwe_WrapKeyOptions as WrapKeyOptions, jwe_WrapKeyResult as WrapKeyResult, jwe_decrypt as decrypt, jwe_encrypt as encrypt };
247
+ export { jwe_CompositeKey as CompositeKey, jwe_ContentEncryptionAlgorithm as ContentEncryptionAlgorithm, jwe_DeriveKeyOptions as DeriveKeyOptions, jwe_DeriveKeyReturn as DeriveKeyReturn, jwe_GenerateJWKOptions as GenerateJWKOptions, jwe_GenerateJWKReturn as GenerateJWKReturn, jwe_GenerateKeyAlgorithm as GenerateKeyAlgorithm, jwe_GenerateKeyOptions as GenerateKeyOptions, jwe_GenerateKeyReturn as GenerateKeyReturn, jwe_JWK as JWK, jwe_JWKAlgorithm as JWKAlgorithm, jwe_JWKPEMAlgorithm as JWKPEMAlgorithm, jwe_JWKParameters as JWKParameters, jwe_JWKSet as JWKSet, jwe_JWK_AES_CBC_HMAC as JWK_AES_CBC_HMAC, jwe_JWK_AES_GCM as JWK_AES_GCM, jwe_JWK_AES_GCM_KW as JWK_AES_GCM_KW, jwe_JWK_AES_KW as JWK_AES_KW, jwe_JWK_Asymmetric_Algorithm as JWK_Asymmetric_Algorithm, jwe_JWK_EC as JWK_EC, jwe_JWK_ECDH_ES as JWK_ECDH_ES, jwe_JWK_ECDSA as JWK_ECDSA, jwe_JWK_EC_Private as JWK_EC_Private, jwe_JWK_EC_Public as JWK_EC_Public, jwe_JWK_HMAC as JWK_HMAC, jwe_JWK_OKP as JWK_OKP, jwe_JWK_OKP_Private as JWK_OKP_Private, jwe_JWK_OKP_Public as JWK_OKP_Public, jwe_JWK_OKP_SIGN as JWK_OKP_SIGN, jwe_JWK_PBES2 as JWK_PBES2, jwe_JWK_Private as JWK_Private, jwe_JWK_Public as JWK_Public, jwe_JWK_RSA as JWK_RSA, jwe_JWK_RSA_ENC as JWK_RSA_ENC, jwe_JWK_RSA_PSS as JWK_RSA_PSS, jwe_JWK_RSA_Private as JWK_RSA_Private, jwe_JWK_RSA_Public as JWK_RSA_Public, jwe_JWK_RSA_SIGN as JWK_RSA_SIGN, jwe_JWK_Symmetric_Algorithm as JWK_Symmetric_Algorithm, jwe_JWK_oct as JWK_oct, jwe_JWT as JWT, jwe_JWTClaimValidationOptions as JWTClaimValidationOptions, jwe_JWTClaims as JWTClaims, jwe_JoseHeaderParameters as JoseHeaderParameters, jwe_KeyManagementAlgorithm as KeyManagementAlgorithm, jwe_UnwrapKeyOptions as UnwrapKeyOptions, jwe_WrapKeyOptions as WrapKeyOptions, jwe_WrapKeyResult as WrapKeyResult, jwe_decrypt as decrypt, jwe_encrypt as encrypt };
231
248
  export type { jwe_JWEDecryptOptions as JWEDecryptOptions, jwe_JWEDecryptResult as JWEDecryptResult, jwe_JWEEncryptOptions as JWEEncryptOptions, jwe_JWEHeaderParameters as JWEHeaderParameters, jwe_JWEKeyLookupFunction as JWEKeyLookupFunction, jwe_JWEKeyManagementHeaderParameters as JWEKeyManagementHeaderParameters };
232
249
  }
233
250
 
@@ -1,6 +1,5 @@
1
- import { i as importKey, g as getJWKFromSet } from './unjwt.D1MC63Yb.mjs';
2
- import { s as sanitizeObject, a as isJWK, b as applyTypCtyDefaults, c as computeJwtTimeClaims, d as base64UrlEncode, t as textEncoder, e as textDecoder, f as base64UrlDecode, g as isJWKSet, h as decodePayloadFromB64UrlSegment, v as validateCriticalHeadersJWS, j as validateJwtClaims } from './unjwt.CRHfsi7v.mjs';
3
- import { s as sign$1, v as verify$1 } from './unjwt.BpusjhPR.mjs';
1
+ import { i as importKey, s as sign$1, b as getJWKFromSet, v as verify$1 } from './unjwt.A5jxFsjh.mjs';
2
+ import { s as sanitizeObject, a as isJWK, b as applyTypCtyDefaults, c as computeJwtTimeClaims, d as base64UrlEncode, t as textEncoder, l as textDecoder, e as base64UrlDecode, m as isJWKSet, n as decodePayloadFromB64UrlSegment, o as validateCriticalHeadersJWS, h as validateJwtClaims } from './unjwt.tM5bsBSH.mjs';
4
3
 
5
4
  async function sign(payload, key, options = {}) {
6
5
  const { protectedHeader: additionalProtectedHeader } = options;
@@ -5,7 +5,7 @@ type CompositeKey = {
5
5
  /** The HMAC key for integrity/authentication. */
6
6
  macKey: CryptoKey;
7
7
  };
8
- type GenerateKeyAlgorithm = Exclude<JWKAlgorithm, "none" | "dir" | JWK_PBES2 | JWK_ECDH_ES>;
8
+ type GenerateKeyAlgorithm = Exclude<JWKAlgorithm, "none" | "dir" | JWK_PBES2>;
9
9
  /** Options for the generateKey function. */
10
10
  interface GenerateKeyOptions {
11
11
  /** Key usages for the generated key(s). Note: For composite keys (CBC), default usages are applied separately. */
@@ -16,15 +16,25 @@ interface GenerateKeyOptions {
16
16
  modulusLength?: number;
17
17
  /** RSA public exponent. Defaults to 65537 (0x010001). */
18
18
  publicExponent?: Uint8Array<ArrayBuffer>;
19
+ /** Named curve for EC or OKP keys. Defaults to "P-256" for EC and "Ed25519" for OKP. */
20
+ namedCurve?: "P-256" | "P-384" | "P-521" | "X25519" | "Ed25519" | "Ed448";
19
21
  /** Export the generated key(s) as JWK. If true, the key(s) will be returned in JWK format. */
20
22
  toJWK?: undefined | boolean | Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">;
21
23
  }
22
- type GenerateKeyReturnJWK<TAlg extends GenerateKeyAlgorithm> = TAlg extends JWK_Asymmetric_Algorithm ? {
23
- privateKey: JWK;
24
- publicKey: JWK;
25
- } : JWK;
24
+ type GenerateKeyReturnJWK<TAlg extends GenerateKeyAlgorithm> = TAlg extends JWK_Asymmetric_Algorithm ? TAlg extends JWK_RSA_SIGN | JWK_RSA_PSS | JWK_RSA_ENC ? {
25
+ privateKey: JWK_RSA_Private;
26
+ publicKey: JWK_RSA_Public;
27
+ } : TAlg extends JWK_ECDSA | JWK_ECDH_ES ? {
28
+ privateKey: JWK_EC_Private;
29
+ publicKey: JWK_EC_Public;
30
+ } : TAlg extends JWK_OKP_SIGN ? {
31
+ privateKey: JWK_OKP_Private;
32
+ publicKey: JWK_OKP_Public;
33
+ } : never : TAlg extends JWK_AES_CBC_HMAC | JWK_Symmetric_Algorithm ? JWK_oct : never;
26
34
  type GenerateKeyReturnCrypto<TAlg extends GenerateKeyAlgorithm> = TAlg extends JWK_AES_CBC_HMAC ? Uint8Array<ArrayBuffer> : TAlg extends JWK_Asymmetric_Algorithm ? CryptoKeyPair : CryptoKey;
27
35
  type GenerateKeyReturn<TAlg extends GenerateKeyAlgorithm, TOptions extends GenerateKeyOptions> = TOptions["toJWK"] extends true ? GenerateKeyReturnJWK<TAlg> : TOptions["toJWK"] extends object ? GenerateKeyReturnJWK<TAlg> : GenerateKeyReturnCrypto<TAlg>;
36
+ type GenerateJWKOptions = Omit<GenerateKeyOptions, "toJWK">;
37
+ type GenerateJWKReturn<TAlg extends GenerateKeyAlgorithm> = GenerateKeyReturnJWK<TAlg>;
28
38
  /** Options for the deriveKeyFromPassword function. */
29
39
  interface DeriveKeyOptions {
30
40
  /** Salt value (p2s). Must be at least 8 bytes. */
@@ -86,11 +96,13 @@ interface UnwrapKeyOptions {
86
96
  /** PBES2 Iteration count (required for PBES2). */
87
97
  p2c?: number;
88
98
  /** ECDH-ES Ephemeral Public Key (required for ECDH-ES). */
89
- epk?: JWK_EC_Public;
99
+ epk?: JWK_EC_Public | CryptoKey;
90
100
  /** ECDH-ES Agreement PartyUInfo. Base64URL encoded or Uint8Array. */
91
101
  apu?: Uint8Array<ArrayBuffer> | string;
92
102
  /** ECDH-ES Agreement PartyVInfo. Base64URL encoded or Uint8Array. */
93
103
  apv?: Uint8Array<ArrayBuffer> | string;
104
+ /** Content Encryption Algorithm used with ECDH-ES (required for direct key agreement). */
105
+ enc?: ContentEncryptionAlgorithm;
94
106
  /** Expected unwrapped key algorithm (e.g., 'AES-GCM', 'AES-CBC'). Used by crypto.subtle.unwrapKey. */
95
107
  unwrappedKeyAlgorithm?: string | Algorithm | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams;
96
108
  /** Expected key usages for the unwrapped key. */
@@ -227,7 +239,7 @@ type JWK_PBES2 = "PBES2-HS256+A128KW" | "PBES2-HS384+A192KW" | "PBES2-HS512+A256
227
239
  type JWK_ECDH_ES = "ECDH-ES" | "ECDH-ES+A128KW" | "ECDH-ES+A192KW" | "ECDH-ES+A256KW";
228
240
  type JWK_OKP_SIGN = "Ed25519" | "EdDSA";
229
241
  type JWK_Symmetric_Algorithm = JWK_HMAC | JWK_AES_KW | JWK_AES_GCM;
230
- type JWK_Asymmetric_Algorithm = JWK_RSA_SIGN | JWK_RSA_PSS | JWK_ECDSA | JWK_RSA_ENC | JWK_OKP_SIGN;
242
+ type JWK_Asymmetric_Algorithm = JWK_RSA_SIGN | JWK_RSA_PSS | JWK_ECDSA | JWK_RSA_ENC | JWK_OKP_SIGN | JWK_ECDH_ES;
231
243
  type JWKAlgorithm = JWK_Symmetric_Algorithm | JWK_Asymmetric_Algorithm | JWK_AES_CBC_HMAC | JWK_PBES2 | JWK_ECDH_ES | ("none" | "dir");
232
244
  type JWKPEMAlgorithm = JWK_RSA_PSS | JWK_RSA_SIGN | JWK_RSA_ENC | JWK_ECDSA | JWK_ECDH_ES | JWK_OKP_SIGN;
233
245
 
@@ -306,4 +318,4 @@ interface JWTClaimValidationOptions {
306
318
  critical?: string[];
307
319
  }
308
320
 
309
- export type { JWK_AES_CBC_HMAC as A, JWK_AES_GCM as B, CompositeKey as C, DeriveKeyOptions as D, JWK_PBES2 as E, JWK_ECDH_ES as F, GenerateKeyAlgorithm as G, JWK_OKP_SIGN as H, JWK_Symmetric_Algorithm as I, JWKParameters as J, KeyManagementAlgorithm as K, JWK_Asymmetric_Algorithm as L, JWKAlgorithm as M, JWKPEMAlgorithm as N, JoseHeaderParameters as O, JWTClaims as P, JWT as Q, JWTClaimValidationOptions as R, 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_OKP_Public as l, JWK_OKP_Private as m, JWK_OKP as n, JWK_oct as o, JWK_Public as p, JWK_Private as q, JWK as r, JWKSet as s, JWK_HMAC as t, JWK_RSA_SIGN as u, JWK_RSA_PSS as v, JWK_ECDSA as w, JWK_RSA_ENC as x, JWK_AES_KW as y, JWK_AES_GCM_KW as z };
321
+ export type { JWK_AES_KW as A, JWK_AES_GCM_KW as B, CompositeKey as C, DeriveKeyOptions as D, JWK_AES_CBC_HMAC as E, JWK_AES_GCM as F, GenerateKeyAlgorithm as G, JWK_PBES2 as H, JWK_ECDH_ES as I, JWKParameters as J, KeyManagementAlgorithm as K, JWK_OKP_SIGN as L, JWK_Symmetric_Algorithm as M, JWK_Asymmetric_Algorithm as N, JWKAlgorithm as O, JWKPEMAlgorithm as P, JoseHeaderParameters as Q, JWTClaims as R, JWT as S, JWTClaimValidationOptions as T, UnwrapKeyOptions as U, WrapKeyOptions as W, GenerateKeyOptions as a, GenerateKeyReturn as b, GenerateJWKOptions as c, GenerateJWKReturn as d, DeriveKeyReturn as e, ContentEncryptionAlgorithm as f, WrapKeyResult as g, JWK_EC_Public as h, JWK_EC_Private as i, JWK_EC as j, JWK_RSA_Public as k, JWK_RSA_Private as l, JWK_RSA as m, JWK_OKP_Public as n, JWK_OKP_Private as o, JWK_OKP as p, JWK_oct as q, JWK_Public as r, JWK_Private as s, JWK as t, JWKSet as u, JWK_HMAC as v, JWK_RSA_SIGN as w, JWK_RSA_PSS as x, JWK_ECDSA as y, JWK_RSA_ENC as z };
@@ -0,0 +1,247 @@
1
+ import { i as importKey, e as encryptKey, g as generateIV, a as encrypt$1, u as unwrapKey, d as decrypt$1 } from './unjwt.A5jxFsjh.mjs';
2
+ import { r as randomBytes, a as isJWK, s as sanitizeObject, b as applyTypCtyDefaults, c as computeJwtTimeClaims, g as getPlaintextBytes, d as base64UrlEncode, t as textEncoder, e as base64UrlDecode, f as decodePayloadFromBytes, v as validateCriticalHeadersJWE, h as validateJwtClaims, j as isCryptoKeyPair, k as isCryptoKey } from './unjwt.tM5bsBSH.mjs';
3
+
4
+ async function encrypt(payload, key, options = {}) {
5
+ const {
6
+ protectedHeader: additionalProtectedHeader,
7
+ cek: providedCek,
8
+ contentEncryptionIV: providedContentIV,
9
+ keyManagementIV,
10
+ p2s = randomBytes(16),
11
+ p2c = 2048,
12
+ ecdh
13
+ } = options;
14
+ let { alg, enc } = options;
15
+ if (!alg) {
16
+ if (typeof key === "string" || key instanceof Uint8Array) {
17
+ alg = "PBES2-HS256+A128KW";
18
+ } else if (isJWK(key)) {
19
+ alg = key.alg;
20
+ }
21
+ }
22
+ if (!alg) {
23
+ throw new TypeError(
24
+ 'JWE "alg" (Key Management Algorithm) must be provided in options or inferable from the key'
25
+ );
26
+ }
27
+ if (!enc) {
28
+ enc = isJWK(key) && "enc" in key ? key.enc : "A128GCM";
29
+ }
30
+ const jweKeyManagementParams = {};
31
+ if (keyManagementIV) jweKeyManagementParams.iv = keyManagementIV;
32
+ if (p2s) jweKeyManagementParams.p2s = p2s;
33
+ if (p2c) jweKeyManagementParams.p2c = p2c;
34
+ if (ecdh?.partyUInfo) jweKeyManagementParams.apu = ecdh.partyUInfo;
35
+ if (ecdh?.partyVInfo) jweKeyManagementParams.apv = ecdh.partyVInfo;
36
+ if (ecdh?.ephemeralKey) {
37
+ const { epk, epkPrivateKey } = parseEphemeralKey(ecdh.ephemeralKey);
38
+ jweKeyManagementParams.epk = epk;
39
+ jweKeyManagementParams.epkPrivateKey = epkPrivateKey;
40
+ }
41
+ const wrappingKeyMaterial = await importKey(key, alg);
42
+ const {
43
+ cek: finalCek,
44
+ // This is the CEK (CryptoKey | Uint8Array) to be used for content encryption
45
+ encryptedKey: jweEncryptedKey,
46
+ // This is the JWE Encrypted Key (Uint8Array | undefined)
47
+ parameters: keyManagementHeaderParams
48
+ // JWE header params from key encryption (e.g., epk, p2s, iv, tag)
49
+ } = await encryptKey(
50
+ alg,
51
+ enc,
52
+ wrappingKeyMaterial,
53
+ providedCek,
54
+ jweKeyManagementParams
55
+ );
56
+ const baseProtectedHeader = { ...additionalProtectedHeader };
57
+ delete baseProtectedHeader.alg;
58
+ delete baseProtectedHeader.enc;
59
+ const jweProtectedHeader = sanitizeObject({
60
+ ...baseProtectedHeader,
61
+ ...keyManagementHeaderParams,
62
+ alg,
63
+ enc
64
+ });
65
+ const protectedHeader = applyTypCtyDefaults(jweProtectedHeader, payload);
66
+ const computedPayload = computeJwtTimeClaims(
67
+ payload,
68
+ protectedHeader.typ,
69
+ options.expiresIn,
70
+ options.currentDate
71
+ );
72
+ const plaintextBytes = getPlaintextBytes(computedPayload || payload);
73
+ const protectedHeaderSerialized = JSON.stringify(protectedHeader);
74
+ const protectedHeaderEncoded = base64UrlEncode(protectedHeaderSerialized);
75
+ const aadBytes = textEncoder.encode(protectedHeaderEncoded);
76
+ const contentIVBytes = providedContentIV ?? generateIV(enc);
77
+ const {
78
+ ciphertext: contentCiphertext,
79
+ tag: contentAuthTag,
80
+ iv: actualContentIV
81
+ } = await encrypt$1(
82
+ enc,
83
+ plaintextBytes,
84
+ finalCek,
85
+ contentIVBytes,
86
+ aadBytes
87
+ );
88
+ if (!actualContentIV) {
89
+ throw new Error("Content encryption IV was not generated or returned.");
90
+ }
91
+ if (!contentAuthTag) {
92
+ throw new Error(
93
+ "Content encryption auth tag was not generated or returned."
94
+ );
95
+ }
96
+ const encryptedKeyEncoded = jweEncryptedKey ? base64UrlEncode(jweEncryptedKey) : "";
97
+ const jweParts = [
98
+ protectedHeaderEncoded,
99
+ encryptedKeyEncoded,
100
+ base64UrlEncode(actualContentIV),
101
+ base64UrlEncode(contentCiphertext),
102
+ base64UrlEncode(contentAuthTag)
103
+ ];
104
+ return jweParts.join(".");
105
+ }
106
+ async function decrypt(jwe, key, options = {}) {
107
+ const parts = jwe.split(".");
108
+ if (parts.length !== 5) {
109
+ throw new Error(
110
+ "Invalid JWE: Must contain five sections (RFC7516, section-3)."
111
+ );
112
+ }
113
+ const [
114
+ protectedHeaderEncoded,
115
+ encryptedKeyEncoded,
116
+ ivEncoded,
117
+ ciphertextEncoded,
118
+ authTagEncoded
119
+ ] = parts;
120
+ let protectedHeader;
121
+ try {
122
+ const protectedHeaderJson = base64UrlDecode(protectedHeaderEncoded);
123
+ protectedHeader = sanitizeObject(
124
+ JSON.parse(protectedHeaderJson)
125
+ );
126
+ } catch (error_) {
127
+ throw new Error(
128
+ `Invalid JWE: Protected header is not valid Base64URL or JSON (${error_ instanceof Error ? error_.message : error_})`
129
+ );
130
+ }
131
+ if (!protectedHeader || typeof protectedHeader !== "object" || !protectedHeader.alg || !protectedHeader.enc) {
132
+ throw new Error(
133
+ 'Invalid JWE: Protected header must be an object with "alg" and "enc" properties.'
134
+ );
135
+ }
136
+ const alg = protectedHeader.alg;
137
+ const enc = protectedHeader.enc;
138
+ if (options?.algorithms && !options.algorithms.includes(alg)) {
139
+ throw new Error(`Key management algorithm not allowed: ${alg}`);
140
+ }
141
+ if (options?.encryptionAlgorithms && !options.encryptionAlgorithms.includes(enc)) {
142
+ throw new Error(`Content encryption algorithm not allowed: ${enc}`);
143
+ }
144
+ const resolvedKeyMaterial = typeof key === "function" ? await key(protectedHeader, jwe) : key;
145
+ const unwrappingKey = await importKey(resolvedKeyMaterial, alg);
146
+ const encryptedKeyBytes = base64UrlDecode(encryptedKeyEncoded, false);
147
+ const contentIVBytes = base64UrlDecode(ivEncoded, false);
148
+ const contentAuthTagBytes = base64UrlDecode(authTagEncoded, false);
149
+ const ciphertextBytes = base64UrlDecode(ciphertextEncoded, false);
150
+ const unwrapKeyOpts = {
151
+ iv: protectedHeader.iv,
152
+ tag: protectedHeader.tag,
153
+ p2s: protectedHeader.p2s,
154
+ p2c: protectedHeader.p2c,
155
+ epk: protectedHeader.epk,
156
+ apu: protectedHeader.apu,
157
+ apv: protectedHeader.apv,
158
+ enc,
159
+ unwrappedKeyAlgorithm: options?.unwrappedKeyAlgorithm,
160
+ keyUsage: options?.keyUsage,
161
+ extractable: options?.extractable,
162
+ returnAs: false
163
+ // Returning CEK as Uint8Array<ArrayBuffer>
164
+ };
165
+ const cekBytes = await unwrapKey(
166
+ alg,
167
+ encryptedKeyBytes,
168
+ unwrappingKey,
169
+ unwrapKeyOpts
170
+ );
171
+ const aadBytes = textEncoder.encode(protectedHeaderEncoded);
172
+ const plaintextBytes = await decrypt$1(
173
+ enc,
174
+ cekBytes,
175
+ ciphertextBytes,
176
+ contentIVBytes,
177
+ contentAuthTagBytes,
178
+ aadBytes
179
+ );
180
+ const payload = decodePayloadFromBytes(
181
+ plaintextBytes,
182
+ protectedHeader,
183
+ options?.forceUint8Array
184
+ );
185
+ validateCriticalHeadersJWE(protectedHeader, [
186
+ ...options?.critical || [],
187
+ ...options?.requiredHeaders || []
188
+ ]);
189
+ if (payload && typeof payload === "object" && options.validateJWT !== false && (options.validateJWT === true || protectedHeader.typ?.toLowerCase().includes("jwt")) && !options.forceUint8Array && !(payload instanceof Uint8Array)) {
190
+ validateJwtClaims(payload, options);
191
+ }
192
+ return {
193
+ payload,
194
+ protectedHeader,
195
+ cek: cekBytes,
196
+ aad: aadBytes
197
+ };
198
+ }
199
+ function parseEphemeralKey(ephemeralKey) {
200
+ let epk;
201
+ let epkPrivateKey;
202
+ if (isCryptoKeyPair(ephemeralKey)) {
203
+ epk = ephemeralKey.publicKey;
204
+ epkPrivateKey = ephemeralKey.privateKey;
205
+ } else if (typeof ephemeralKey === "object" && ephemeralKey !== null && "publicKey" in ephemeralKey && "privateKey" in ephemeralKey) {
206
+ const candidate = ephemeralKey;
207
+ if (!candidate.publicKey || !candidate.privateKey) {
208
+ throw new TypeError(
209
+ "ECDH-ES custom ephemeral key must include both publicKey and privateKey."
210
+ );
211
+ }
212
+ epk = candidate.publicKey;
213
+ epkPrivateKey = candidate.privateKey;
214
+ } else if (isCryptoKey(ephemeralKey)) {
215
+ if (ephemeralKey.type !== "private") {
216
+ throw new TypeError(
217
+ "ECDH-ES custom ephemeral CryptoKey must include private key material."
218
+ );
219
+ }
220
+ epk = ephemeralKey;
221
+ epkPrivateKey = ephemeralKey;
222
+ } else if (isJWK(ephemeralKey)) {
223
+ if (!("d" in ephemeralKey) || typeof ephemeralKey.d !== "string") {
224
+ throw new TypeError(
225
+ 'ECDH-ES custom ephemeral JWK must include private parameter "d".'
226
+ );
227
+ }
228
+ epk = ephemeralKey;
229
+ epkPrivateKey = ephemeralKey;
230
+ } else {
231
+ throw new TypeError(
232
+ "Unsupported ECDH-ES ephemeral key material provided in options."
233
+ );
234
+ }
235
+ return {
236
+ epk,
237
+ epkPrivateKey
238
+ };
239
+ }
240
+
241
+ const jwe = {
242
+ __proto__: null,
243
+ decrypt: decrypt,
244
+ encrypt: encrypt
245
+ };
246
+
247
+ export { decrypt as d, encrypt as e, jwe as j };
@@ -1,4 +1,4 @@
1
- import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, E as JWK_PBES2, D as DeriveKeyOptions, c as DeriveKeyReturn, o as JWK_oct, r as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, e as WrapKeyResult, U as UnwrapKeyOptions, N as JWKPEMAlgorithm, s as JWKSet, O as JoseHeaderParameters, C as CompositeKey, d as ContentEncryptionAlgorithm, M as JWKAlgorithm, J as JWKParameters, A as JWK_AES_CBC_HMAC, B as JWK_AES_GCM, z as JWK_AES_GCM_KW, y as JWK_AES_KW, L as JWK_Asymmetric_Algorithm, h as JWK_EC, F as JWK_ECDH_ES, w as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, t as JWK_HMAC, n as JWK_OKP, m as JWK_OKP_Private, l as JWK_OKP_Public, H as JWK_OKP_SIGN, q as JWK_Private, p as JWK_Public, k as JWK_RSA, x as JWK_RSA_ENC, v as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, u as JWK_RSA_SIGN, I as JWK_Symmetric_Algorithm, Q as JWT, R as JWTClaimValidationOptions, P as JWTClaims } from './unjwt.OzI0aGB_.mjs';
1
+ import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, J as JWKParameters, c as GenerateJWKOptions, d as GenerateJWKReturn, H as JWK_PBES2, D as DeriveKeyOptions, e as DeriveKeyReturn, q as JWK_oct, t as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, g as WrapKeyResult, U as UnwrapKeyOptions, P as JWKPEMAlgorithm, u as JWKSet, Q as JoseHeaderParameters, C as CompositeKey, f as ContentEncryptionAlgorithm, O as JWKAlgorithm, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, S as JWT, T as JWTClaimValidationOptions, R as JWTClaims } from './unjwt.ClaeEBcy.mjs';
2
2
 
3
3
  /**
4
4
  * This is a fork of Jose library's utility functions.
@@ -22,6 +22,15 @@ interface KeyImportOptions {
22
22
  * @returns A Promise resolving to the generated key (CryptoKey, CryptoKeyPair, or Uint8Array) or its JWK representation.
23
23
  */
24
24
  declare function generateKey<TAlg extends GenerateKeyAlgorithm, TOptions extends GenerateKeyOptions>(alg: TAlg, options?: TOptions): Promise<GenerateKeyReturn<TAlg, TOptions>>;
25
+ /**
26
+ * Generates a Json Web Key (JWK) for the specified algorithm.
27
+ *
28
+ * @param alg The JWA algorithm identifier (e.g., "HS256", "RS256", "A128GCM").
29
+ * @param jwkParams Optional partial JWK to merge with the generated key, allowing overrides.
30
+ * @param options Configuration options for key generation.
31
+ * @returns A Promise resolving to the generated JWK or JWK pair representation.
32
+ */
33
+ declare function generateJWK<TAlg extends GenerateKeyAlgorithm>(alg: TAlg, jwkParams?: Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">, options?: GenerateJWKOptions): Promise<GenerateJWKReturn<TAlg>>;
25
34
  /**
26
35
  * Derives a key from a password using PBKDF2 as specified by PBES2 algorithms.
27
36
  *
@@ -124,6 +133,8 @@ declare const jwk_CompositeKey: typeof CompositeKey;
124
133
  declare const jwk_ContentEncryptionAlgorithm: typeof ContentEncryptionAlgorithm;
125
134
  declare const jwk_DeriveKeyOptions: typeof DeriveKeyOptions;
126
135
  declare const jwk_DeriveKeyReturn: typeof DeriveKeyReturn;
136
+ declare const jwk_GenerateJWKOptions: typeof GenerateJWKOptions;
137
+ declare const jwk_GenerateJWKReturn: typeof GenerateJWKReturn;
127
138
  declare const jwk_GenerateKeyAlgorithm: typeof GenerateKeyAlgorithm;
128
139
  declare const jwk_GenerateKeyOptions: typeof GenerateKeyOptions;
129
140
  declare const jwk_GenerateKeyReturn: typeof GenerateKeyReturn;
@@ -169,6 +180,7 @@ declare const jwk_WrapKeyResult: typeof WrapKeyResult;
169
180
  declare const jwk_deriveKeyFromPassword: typeof deriveKeyFromPassword;
170
181
  declare const jwk_exportJWKToPEM: typeof exportJWKToPEM;
171
182
  declare const jwk_exportKey: typeof exportKey;
183
+ declare const jwk_generateJWK: typeof generateJWK;
172
184
  declare const jwk_generateKey: typeof generateKey;
173
185
  declare const jwk_getJWKFromSet: typeof getJWKFromSet;
174
186
  declare const jwk_importJWKFromPEM: typeof importJWKFromPEM;
@@ -181,6 +193,8 @@ declare namespace jwk {
181
193
  jwk_ContentEncryptionAlgorithm as ContentEncryptionAlgorithm,
182
194
  jwk_DeriveKeyOptions as DeriveKeyOptions,
183
195
  jwk_DeriveKeyReturn as DeriveKeyReturn,
196
+ jwk_GenerateJWKOptions as GenerateJWKOptions,
197
+ jwk_GenerateJWKReturn as GenerateJWKReturn,
184
198
  jwk_GenerateKeyAlgorithm as GenerateKeyAlgorithm,
185
199
  jwk_GenerateKeyOptions as GenerateKeyOptions,
186
200
  jwk_GenerateKeyReturn as GenerateKeyReturn,
@@ -226,6 +240,7 @@ declare namespace jwk {
226
240
  jwk_deriveKeyFromPassword as deriveKeyFromPassword,
227
241
  jwk_exportJWKToPEM as exportJWKToPEM,
228
242
  jwk_exportKey as exportKey,
243
+ jwk_generateJWK as generateJWK,
229
244
  jwk_generateKey as generateKey,
230
245
  jwk_getJWKFromSet as getJWKFromSet,
231
246
  jwk_importJWKFromPEM as importJWKFromPEM,
@@ -235,4 +250,4 @@ declare namespace jwk {
235
250
  };
236
251
  }
237
252
 
238
- 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 };
253
+ export { generateJWK as a, importJWKFromPEM as b, exportJWKToPEM as c, deriveKeyFromPassword as d, exportKey as e, getJWKFromSet as f, generateKey as g, importKey as i, jwk as j, unwrapKey as u, wrapKey as w };
@@ -1,4 +1,4 @@
1
- import { P as JWTClaims, R as JWTClaimValidationOptions, r as JWK, s as JWKSet, o as JWK_oct, q as JWK_Private, p as JWK_Public } from './unjwt.OzI0aGB_.mjs';
1
+ import { R as JWTClaims, T as JWTClaimValidationOptions, t as JWK, u as JWKSet, q as JWK_oct, s as JWK_Private, r as JWK_Public } from './unjwt.ClaeEBcy.mjs';
2
2
 
3
3
  /**
4
4
  * Apply default typ/cty semantics shared by JWS & JWE.
@@ -1,4 +1,4 @@
1
- import { t as JWK_HMAC, u as JWK_RSA_SIGN, v as JWK_RSA_PSS, w as JWK_ECDSA, O as JoseHeaderParameters, r as JWK, s as JWKSet, R as JWTClaimValidationOptions, P as JWTClaims, C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, M as JWKAlgorithm, N as JWKPEMAlgorithm, J as JWKParameters, A as JWK_AES_CBC_HMAC, B as JWK_AES_GCM, z as JWK_AES_GCM_KW, y as JWK_AES_KW, L as JWK_Asymmetric_Algorithm, h as JWK_EC, F as JWK_ECDH_ES, g as JWK_EC_Private, f as JWK_EC_Public, n as JWK_OKP, m as JWK_OKP_Private, l as JWK_OKP_Public, H as JWK_OKP_SIGN, E as JWK_PBES2, q as JWK_Private, p as JWK_Public, k as JWK_RSA, x as JWK_RSA_ENC, j as JWK_RSA_Private, i as JWK_RSA_Public, I as JWK_Symmetric_Algorithm, o as JWK_oct, Q as JWT, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './unjwt.OzI0aGB_.mjs';
1
+ import { v as JWK_HMAC, w as JWK_RSA_SIGN, x as JWK_RSA_PSS, y as JWK_ECDSA, Q as JoseHeaderParameters, t as JWK, u as JWKSet, T as JWTClaimValidationOptions, R as JWTClaims, C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, i as JWK_EC_Private, h as JWK_EC_Public, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, l as JWK_RSA_Private, k as JWK_RSA_Public, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.ClaeEBcy.mjs';
2
2
 
3
3
  type JWS_SIGN_EXTRA = "Ed25519" | "EdDSA";
4
4
  /** JWS Signing Algorithm Identifier. */
@@ -104,6 +104,8 @@ declare const jws_CompositeKey: typeof CompositeKey;
104
104
  declare const jws_ContentEncryptionAlgorithm: typeof ContentEncryptionAlgorithm;
105
105
  declare const jws_DeriveKeyOptions: typeof DeriveKeyOptions;
106
106
  declare const jws_DeriveKeyReturn: typeof DeriveKeyReturn;
107
+ declare const jws_GenerateJWKOptions: typeof GenerateJWKOptions;
108
+ declare const jws_GenerateJWKReturn: typeof GenerateJWKReturn;
107
109
  declare const jws_GenerateKeyAlgorithm: typeof GenerateKeyAlgorithm;
108
110
  declare const jws_GenerateKeyOptions: typeof GenerateKeyOptions;
109
111
  declare const jws_GenerateKeyReturn: typeof GenerateKeyReturn;
@@ -156,7 +158,7 @@ declare const jws_WrapKeyResult: typeof WrapKeyResult;
156
158
  declare const jws_sign: typeof sign;
157
159
  declare const jws_verify: typeof verify;
158
160
  declare namespace jws {
159
- export { jws_CompositeKey as CompositeKey, jws_ContentEncryptionAlgorithm as ContentEncryptionAlgorithm, jws_DeriveKeyOptions as DeriveKeyOptions, jws_DeriveKeyReturn as DeriveKeyReturn, jws_GenerateKeyAlgorithm as GenerateKeyAlgorithm, jws_GenerateKeyOptions as GenerateKeyOptions, jws_GenerateKeyReturn as GenerateKeyReturn, jws_JWK as JWK, jws_JWKAlgorithm as JWKAlgorithm, jws_JWKPEMAlgorithm as JWKPEMAlgorithm, jws_JWKParameters as JWKParameters, jws_JWKSet as JWKSet, jws_JWK_AES_CBC_HMAC as JWK_AES_CBC_HMAC, jws_JWK_AES_GCM as JWK_AES_GCM, jws_JWK_AES_GCM_KW as JWK_AES_GCM_KW, jws_JWK_AES_KW as JWK_AES_KW, jws_JWK_Asymmetric_Algorithm as JWK_Asymmetric_Algorithm, jws_JWK_EC as JWK_EC, jws_JWK_ECDH_ES as JWK_ECDH_ES, jws_JWK_ECDSA as JWK_ECDSA, jws_JWK_EC_Private as JWK_EC_Private, jws_JWK_EC_Public as JWK_EC_Public, jws_JWK_HMAC as JWK_HMAC, jws_JWK_OKP as JWK_OKP, jws_JWK_OKP_Private as JWK_OKP_Private, jws_JWK_OKP_Public as JWK_OKP_Public, jws_JWK_OKP_SIGN as JWK_OKP_SIGN, jws_JWK_PBES2 as JWK_PBES2, jws_JWK_Private as JWK_Private, jws_JWK_Public as JWK_Public, jws_JWK_RSA as JWK_RSA, jws_JWK_RSA_ENC as JWK_RSA_ENC, jws_JWK_RSA_PSS as JWK_RSA_PSS, jws_JWK_RSA_Private as JWK_RSA_Private, jws_JWK_RSA_Public as JWK_RSA_Public, jws_JWK_RSA_SIGN as JWK_RSA_SIGN, jws_JWK_Symmetric_Algorithm as JWK_Symmetric_Algorithm, jws_JWK_oct as JWK_oct, jws_JWT as JWT, jws_JWTClaimValidationOptions as JWTClaimValidationOptions, jws_JWTClaims as JWTClaims, jws_JoseHeaderParameters as JoseHeaderParameters, jws_KeyManagementAlgorithm as KeyManagementAlgorithm, jws_UnwrapKeyOptions as UnwrapKeyOptions, jws_WrapKeyOptions as WrapKeyOptions, jws_WrapKeyResult as WrapKeyResult, jws_sign as sign, jws_verify as verify };
161
+ export { jws_CompositeKey as CompositeKey, jws_ContentEncryptionAlgorithm as ContentEncryptionAlgorithm, jws_DeriveKeyOptions as DeriveKeyOptions, jws_DeriveKeyReturn as DeriveKeyReturn, jws_GenerateJWKOptions as GenerateJWKOptions, jws_GenerateJWKReturn as GenerateJWKReturn, jws_GenerateKeyAlgorithm as GenerateKeyAlgorithm, jws_GenerateKeyOptions as GenerateKeyOptions, jws_GenerateKeyReturn as GenerateKeyReturn, jws_JWK as JWK, jws_JWKAlgorithm as JWKAlgorithm, jws_JWKPEMAlgorithm as JWKPEMAlgorithm, jws_JWKParameters as JWKParameters, jws_JWKSet as JWKSet, jws_JWK_AES_CBC_HMAC as JWK_AES_CBC_HMAC, jws_JWK_AES_GCM as JWK_AES_GCM, jws_JWK_AES_GCM_KW as JWK_AES_GCM_KW, jws_JWK_AES_KW as JWK_AES_KW, jws_JWK_Asymmetric_Algorithm as JWK_Asymmetric_Algorithm, jws_JWK_EC as JWK_EC, jws_JWK_ECDH_ES as JWK_ECDH_ES, jws_JWK_ECDSA as JWK_ECDSA, jws_JWK_EC_Private as JWK_EC_Private, jws_JWK_EC_Public as JWK_EC_Public, jws_JWK_HMAC as JWK_HMAC, jws_JWK_OKP as JWK_OKP, jws_JWK_OKP_Private as JWK_OKP_Private, jws_JWK_OKP_Public as JWK_OKP_Public, jws_JWK_OKP_SIGN as JWK_OKP_SIGN, jws_JWK_PBES2 as JWK_PBES2, jws_JWK_Private as JWK_Private, jws_JWK_Public as JWK_Public, jws_JWK_RSA as JWK_RSA, jws_JWK_RSA_ENC as JWK_RSA_ENC, jws_JWK_RSA_PSS as JWK_RSA_PSS, jws_JWK_RSA_Private as JWK_RSA_Private, jws_JWK_RSA_Public as JWK_RSA_Public, jws_JWK_RSA_SIGN as JWK_RSA_SIGN, jws_JWK_Symmetric_Algorithm as JWK_Symmetric_Algorithm, jws_JWK_oct as JWK_oct, jws_JWT as JWT, jws_JWTClaimValidationOptions as JWTClaimValidationOptions, jws_JWTClaims as JWTClaims, jws_JoseHeaderParameters as JoseHeaderParameters, jws_KeyManagementAlgorithm as KeyManagementAlgorithm, jws_UnwrapKeyOptions as UnwrapKeyOptions, jws_WrapKeyOptions as WrapKeyOptions, jws_WrapKeyResult as WrapKeyResult, jws_sign as sign, jws_verify as verify };
160
162
  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 };
161
163
  }
162
164
 
@@ -384,4 +384,4 @@ const index = {
384
384
  validateJwtClaims: validateJwtClaims
385
385
  };
386
386
 
387
- export { isPrivateJWK as A, isPublicJWK as B, isJWTContent as C, decodeMaybeJWTString as D, isJWK as a, applyTypCtyDefaults as b, computeJwtTimeClaims as c, base64UrlEncode as d, textDecoder as e, base64UrlDecode as f, isJWKSet as g, decodePayloadFromB64UrlSegment as h, index as i, validateJwtClaims as j, concatUint8Arrays as k, assertCryptoKey as l, isCryptoKey as m, getPlaintextBytes as n, decodePayloadFromBytes as o, validateCriticalHeadersJWE as p, base64Decode as q, randomBytes as r, sanitizeObject as s, textEncoder as t, base64Encode as u, validateCriticalHeadersJWS as v, maybeArray as w, isCryptoKeyPair as x, isSymmetricJWK as y, isAsymmetricJWK as z };
387
+ export { isPrivateJWK as A, isPublicJWK as B, isJWTContent as C, decodeMaybeJWTString as D, isJWK as a, applyTypCtyDefaults as b, computeJwtTimeClaims as c, base64UrlEncode as d, base64UrlDecode as e, decodePayloadFromBytes as f, getPlaintextBytes as g, validateJwtClaims as h, index as i, isCryptoKeyPair as j, isCryptoKey as k, textDecoder as l, isJWKSet as m, decodePayloadFromB64UrlSegment as n, validateCriticalHeadersJWS as o, concatUint8Arrays as p, base64Decode as q, randomBytes as r, sanitizeObject as s, textEncoder as t, base64Encode as u, validateCriticalHeadersJWE as v, assertCryptoKey as w, isAsymmetricJWK as x, maybeArray as y, isSymmetricJWK as z };
package/dist/utils.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import './shared/unjwt.OzI0aGB_.mjs';
2
- export { s as applyTypCtyDefaults, j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, z as computeJwtTimeClaims, f as concatUint8Arrays, v as decodeMaybeJWTString, x as decodePayloadFromB64UrlSegment, w as decodePayloadFromBytes, y as getPlaintextBytes, o as isAsymmetricJWK, k as isCryptoKey, l as isCryptoKeyPair, g as isJWK, h as isJWKSet, u as isJWTContent, p as isPrivateJWK, q as isPublicJWK, n as isSymmetricJWK, m as maybeArray, r as randomBytes, D as sanitizeObject, a as textDecoder, t as textEncoder, C as validateCriticalHeadersJWE, B as validateCriticalHeadersJWS, A as validateJwtClaims } from './shared/unjwt.DUVOOOvO.mjs';
1
+ import './shared/unjwt.ClaeEBcy.mjs';
2
+ export { s as applyTypCtyDefaults, j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, z as computeJwtTimeClaims, f as concatUint8Arrays, v as decodeMaybeJWTString, x as decodePayloadFromB64UrlSegment, w as decodePayloadFromBytes, y as getPlaintextBytes, o as isAsymmetricJWK, k as isCryptoKey, l as isCryptoKeyPair, g as isJWK, h as isJWKSet, u as isJWTContent, p as isPrivateJWK, q as isPublicJWK, n as isSymmetricJWK, m as maybeArray, r as randomBytes, D as sanitizeObject, a as textDecoder, t as textEncoder, C as validateCriticalHeadersJWE, B as validateCriticalHeadersJWS, A as validateJwtClaims } from './shared/unjwt.DuLUtSpD.mjs';
package/dist/utils.mjs CHANGED
@@ -1 +1 @@
1
- export { b as applyTypCtyDefaults, l as assertCryptoKey, q as base64Decode, u as base64Encode, f as base64UrlDecode, d as base64UrlEncode, c as computeJwtTimeClaims, k as concatUint8Arrays, D as decodeMaybeJWTString, h as decodePayloadFromB64UrlSegment, o as decodePayloadFromBytes, n as getPlaintextBytes, z as isAsymmetricJWK, m as isCryptoKey, x as isCryptoKeyPair, a as isJWK, g as isJWKSet, C as isJWTContent, A as isPrivateJWK, B as isPublicJWK, y as isSymmetricJWK, w as maybeArray, r as randomBytes, s as sanitizeObject, e as textDecoder, t as textEncoder, p as validateCriticalHeadersJWE, v as validateCriticalHeadersJWS, j as validateJwtClaims } from './shared/unjwt.CRHfsi7v.mjs';
1
+ export { b as applyTypCtyDefaults, w as assertCryptoKey, q as base64Decode, u as base64Encode, e as base64UrlDecode, d as base64UrlEncode, c as computeJwtTimeClaims, p as concatUint8Arrays, D as decodeMaybeJWTString, n as decodePayloadFromB64UrlSegment, f as decodePayloadFromBytes, g as getPlaintextBytes, x as isAsymmetricJWK, k as isCryptoKey, j as isCryptoKeyPair, a as isJWK, m as isJWKSet, C as isJWTContent, A as isPrivateJWK, B as isPublicJWK, z as isSymmetricJWK, y as maybeArray, r as randomBytes, s as sanitizeObject, l as textDecoder, t as textEncoder, v as validateCriticalHeadersJWE, o as validateCriticalHeadersJWS, h as validateJwtClaims } from './shared/unjwt.tM5bsBSH.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unjwt",
3
- "version": "0.5.16",
3
+ "version": "0.5.17",
4
4
  "description": "Low-level JWT utilities",
5
5
  "repository": "sandros94/unjwt",
6
6
  "license": "MIT",
@@ -45,8 +45,8 @@
45
45
  "lint:fix": "automd && eslint . --fix && prettier -w .",
46
46
  "prepack": "pnpm build",
47
47
  "release": "pnpm test && pnpm prepack && changelogen --release --push --publish",
48
- "test": "pnpm lint && pnpm test:types && vitest run --slowTestThreshold=500",
49
- "test:coverage": "pnpm lint && pnpm test:types && vitest run --coverage --slowTestThreshold=500",
48
+ "test": "pnpm lint && pnpm test:types && vitest run --slowTestThreshold=1000",
49
+ "test:coverage": "pnpm lint && pnpm test:types && vitest run --coverage --slowTestThreshold=1000",
50
50
  "test:types": "tsc --noEmit --skipLibCheck",
51
51
  "bench": "vitest bench --run"
52
52
  },