unjwt 0.5.15 → 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.
- package/README.md +2 -10
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +4 -5
- package/dist/jwe.d.mts +2 -2
- package/dist/jwe.mjs +3 -4
- package/dist/jwk.d.mts +2 -2
- package/dist/jwk.mjs +2 -2
- package/dist/jws.d.mts +2 -2
- package/dist/jws.mjs +3 -4
- package/dist/shared/{unjwt.D1MC63Yb.mjs → unjwt.A5jxFsjh.mjs} +578 -44
- package/dist/shared/{unjwt.BeWVYyaf.d.mts → unjwt.BQUETRUD.d.mts} +67 -8
- package/dist/shared/{unjwt.u3h40Nr-.mjs → unjwt.Bui8we0H.mjs} +2 -3
- package/dist/shared/{unjwt.BsgIQHVD.d.mts → unjwt.ClaeEBcy.d.mts} +21 -9
- package/dist/shared/unjwt.D5J5ziZr.mjs +247 -0
- package/dist/shared/{unjwt.C6b_GyXm.d.mts → unjwt.Djt8pPsc.d.mts} +17 -2
- package/dist/shared/{unjwt.CfL4cArP.d.mts → unjwt.DuLUtSpD.d.mts} +3 -3
- package/dist/shared/{unjwt.Bw4pzdE0.d.mts → unjwt.fumhLslo.d.mts} +46 -2
- package/dist/shared/{unjwt.CRHfsi7v.mjs → unjwt.tM5bsBSH.mjs} +1 -1
- package/dist/utils.d.mts +2 -2
- package/dist/utils.mjs +1 -1
- package/package.json +3 -3
- package/dist/shared/unjwt.BZ3B0Ak8.mjs +0 -395
- package/dist/shared/unjwt.BpusjhPR.mjs +0 -101
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as KeyManagementAlgorithm,
|
|
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
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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.
|
|
@@ -172,20 +187,64 @@ declare function decrypt(jwe: string, key: CryptoKey | JWK | string | Uint8Array
|
|
|
172
187
|
forceUint8Array: true;
|
|
173
188
|
}): Promise<JWEDecryptResult<Uint8Array<ArrayBuffer>>>;
|
|
174
189
|
|
|
190
|
+
declare const jwe_CompositeKey: typeof CompositeKey;
|
|
191
|
+
declare const jwe_ContentEncryptionAlgorithm: typeof ContentEncryptionAlgorithm;
|
|
192
|
+
declare const jwe_DeriveKeyOptions: typeof DeriveKeyOptions;
|
|
193
|
+
declare const jwe_DeriveKeyReturn: typeof DeriveKeyReturn;
|
|
194
|
+
declare const jwe_GenerateJWKOptions: typeof GenerateJWKOptions;
|
|
195
|
+
declare const jwe_GenerateJWKReturn: typeof GenerateJWKReturn;
|
|
196
|
+
declare const jwe_GenerateKeyAlgorithm: typeof GenerateKeyAlgorithm;
|
|
197
|
+
declare const jwe_GenerateKeyOptions: typeof GenerateKeyOptions;
|
|
198
|
+
declare const jwe_GenerateKeyReturn: typeof GenerateKeyReturn;
|
|
175
199
|
type jwe_JWEDecryptOptions = JWEDecryptOptions;
|
|
176
200
|
type jwe_JWEDecryptResult<T extends JWTClaims | Uint8Array<ArrayBuffer> | string = JWTClaims | Uint8Array<ArrayBuffer> | string> = JWEDecryptResult<T>;
|
|
177
201
|
type jwe_JWEEncryptOptions = JWEEncryptOptions;
|
|
178
202
|
type jwe_JWEHeaderParameters = JWEHeaderParameters;
|
|
179
203
|
type jwe_JWEKeyLookupFunction = JWEKeyLookupFunction;
|
|
180
204
|
type jwe_JWEKeyManagementHeaderParameters = JWEKeyManagementHeaderParameters;
|
|
205
|
+
declare const jwe_JWK: typeof JWK;
|
|
206
|
+
declare const jwe_JWKAlgorithm: typeof JWKAlgorithm;
|
|
207
|
+
declare const jwe_JWKPEMAlgorithm: typeof JWKPEMAlgorithm;
|
|
208
|
+
declare const jwe_JWKParameters: typeof JWKParameters;
|
|
209
|
+
declare const jwe_JWKSet: typeof JWKSet;
|
|
210
|
+
declare const jwe_JWK_AES_CBC_HMAC: typeof JWK_AES_CBC_HMAC;
|
|
211
|
+
declare const jwe_JWK_AES_GCM: typeof JWK_AES_GCM;
|
|
212
|
+
declare const jwe_JWK_AES_GCM_KW: typeof JWK_AES_GCM_KW;
|
|
213
|
+
declare const jwe_JWK_AES_KW: typeof JWK_AES_KW;
|
|
214
|
+
declare const jwe_JWK_Asymmetric_Algorithm: typeof JWK_Asymmetric_Algorithm;
|
|
215
|
+
declare const jwe_JWK_EC: typeof JWK_EC;
|
|
216
|
+
declare const jwe_JWK_ECDH_ES: typeof JWK_ECDH_ES;
|
|
217
|
+
declare const jwe_JWK_ECDSA: typeof JWK_ECDSA;
|
|
218
|
+
declare const jwe_JWK_EC_Private: typeof JWK_EC_Private;
|
|
219
|
+
declare const jwe_JWK_EC_Public: typeof JWK_EC_Public;
|
|
220
|
+
declare const jwe_JWK_HMAC: typeof JWK_HMAC;
|
|
221
|
+
declare const jwe_JWK_OKP: typeof JWK_OKP;
|
|
222
|
+
declare const jwe_JWK_OKP_Private: typeof JWK_OKP_Private;
|
|
223
|
+
declare const jwe_JWK_OKP_Public: typeof JWK_OKP_Public;
|
|
224
|
+
declare const jwe_JWK_OKP_SIGN: typeof JWK_OKP_SIGN;
|
|
225
|
+
declare const jwe_JWK_PBES2: typeof JWK_PBES2;
|
|
226
|
+
declare const jwe_JWK_Private: typeof JWK_Private;
|
|
227
|
+
declare const jwe_JWK_Public: typeof JWK_Public;
|
|
228
|
+
declare const jwe_JWK_RSA: typeof JWK_RSA;
|
|
229
|
+
declare const jwe_JWK_RSA_ENC: typeof JWK_RSA_ENC;
|
|
230
|
+
declare const jwe_JWK_RSA_PSS: typeof JWK_RSA_PSS;
|
|
231
|
+
declare const jwe_JWK_RSA_Private: typeof JWK_RSA_Private;
|
|
232
|
+
declare const jwe_JWK_RSA_Public: typeof JWK_RSA_Public;
|
|
233
|
+
declare const jwe_JWK_RSA_SIGN: typeof JWK_RSA_SIGN;
|
|
234
|
+
declare const jwe_JWK_Symmetric_Algorithm: typeof JWK_Symmetric_Algorithm;
|
|
235
|
+
declare const jwe_JWK_oct: typeof JWK_oct;
|
|
181
236
|
declare const jwe_JWT: typeof JWT;
|
|
182
237
|
declare const jwe_JWTClaimValidationOptions: typeof JWTClaimValidationOptions;
|
|
183
238
|
declare const jwe_JWTClaims: typeof JWTClaims;
|
|
184
239
|
declare const jwe_JoseHeaderParameters: typeof JoseHeaderParameters;
|
|
240
|
+
declare const jwe_KeyManagementAlgorithm: typeof KeyManagementAlgorithm;
|
|
241
|
+
declare const jwe_UnwrapKeyOptions: typeof UnwrapKeyOptions;
|
|
242
|
+
declare const jwe_WrapKeyOptions: typeof WrapKeyOptions;
|
|
243
|
+
declare const jwe_WrapKeyResult: typeof WrapKeyResult;
|
|
185
244
|
declare const jwe_decrypt: typeof decrypt;
|
|
186
245
|
declare const jwe_encrypt: typeof encrypt;
|
|
187
246
|
declare namespace jwe {
|
|
188
|
-
export { jwe_JWT as JWT, jwe_JWTClaimValidationOptions as JWTClaimValidationOptions, jwe_JWTClaims as JWTClaims, jwe_JoseHeaderParameters as JoseHeaderParameters, 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 };
|
|
189
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 };
|
|
190
249
|
}
|
|
191
250
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { i as importKey,
|
|
2
|
-
import { s as sanitizeObject, a as isJWK, b as applyTypCtyDefaults, c as computeJwtTimeClaims, d as base64UrlEncode, t as textEncoder,
|
|
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
|
|
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:
|
|
24
|
-
publicKey:
|
|
25
|
-
} :
|
|
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. */
|
|
@@ -198,7 +210,7 @@ interface JWK_oct extends JWKParameters {
|
|
|
198
210
|
k: string;
|
|
199
211
|
}
|
|
200
212
|
/** Public JSON Web Keys */
|
|
201
|
-
type JWK_Public = JWK_RSA_Public | JWK_EC_Public | JWK_OKP_Public
|
|
213
|
+
type JWK_Public = JWK_RSA_Public | JWK_EC_Public | JWK_OKP_Public;
|
|
202
214
|
/** Private JSON Web Keys */
|
|
203
215
|
type JWK_Private = JWK_RSA_Private | JWK_EC_Private | JWK_OKP_Private;
|
|
204
216
|
/**
|
|
@@ -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 {
|
|
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,
|
|
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 {
|
|
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 {
|
|
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.
|
|
@@ -85,9 +85,9 @@ declare function assertCryptoKey(key: unknown): asserts key is CryptoKey;
|
|
|
85
85
|
declare function isCryptoKey(key: unknown): key is CryptoKey;
|
|
86
86
|
declare const isCryptoKeyPair: (key: any) => key is CryptoKeyPair;
|
|
87
87
|
/** Returns true if the JWK is a symmetric (oct) key. */
|
|
88
|
-
declare function isSymmetricJWK(key: unknown): key is JWK_oct
|
|
88
|
+
declare function isSymmetricJWK(key: unknown): key is Extract<JWK, JWK_oct>;
|
|
89
89
|
/** Returns true if the JWK is an asymmetric (RSA, EC, OKP) key. */
|
|
90
|
-
declare function isAsymmetricJWK(key: unknown): key is JWK_oct
|
|
90
|
+
declare function isAsymmetricJWK(key: unknown): key is Exclude<JWK, JWK_oct>;
|
|
91
91
|
/**
|
|
92
92
|
* Type guard that checks if the provided JWK contains private key material.
|
|
93
93
|
* It relies purely on the presence of private components (e.g. "d"), not on the alg value.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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. */
|
|
@@ -100,6 +100,46 @@ declare function verify(jws: string, key: CryptoKey | JWK | JWKSet | Uint8Array<
|
|
|
100
100
|
forceUint8Array: true;
|
|
101
101
|
}): Promise<JWSVerifyResult<Uint8Array<ArrayBuffer>>>;
|
|
102
102
|
|
|
103
|
+
declare const jws_CompositeKey: typeof CompositeKey;
|
|
104
|
+
declare const jws_ContentEncryptionAlgorithm: typeof ContentEncryptionAlgorithm;
|
|
105
|
+
declare const jws_DeriveKeyOptions: typeof DeriveKeyOptions;
|
|
106
|
+
declare const jws_DeriveKeyReturn: typeof DeriveKeyReturn;
|
|
107
|
+
declare const jws_GenerateJWKOptions: typeof GenerateJWKOptions;
|
|
108
|
+
declare const jws_GenerateJWKReturn: typeof GenerateJWKReturn;
|
|
109
|
+
declare const jws_GenerateKeyAlgorithm: typeof GenerateKeyAlgorithm;
|
|
110
|
+
declare const jws_GenerateKeyOptions: typeof GenerateKeyOptions;
|
|
111
|
+
declare const jws_GenerateKeyReturn: typeof GenerateKeyReturn;
|
|
112
|
+
declare const jws_JWK: typeof JWK;
|
|
113
|
+
declare const jws_JWKAlgorithm: typeof JWKAlgorithm;
|
|
114
|
+
declare const jws_JWKPEMAlgorithm: typeof JWKPEMAlgorithm;
|
|
115
|
+
declare const jws_JWKParameters: typeof JWKParameters;
|
|
116
|
+
declare const jws_JWKSet: typeof JWKSet;
|
|
117
|
+
declare const jws_JWK_AES_CBC_HMAC: typeof JWK_AES_CBC_HMAC;
|
|
118
|
+
declare const jws_JWK_AES_GCM: typeof JWK_AES_GCM;
|
|
119
|
+
declare const jws_JWK_AES_GCM_KW: typeof JWK_AES_GCM_KW;
|
|
120
|
+
declare const jws_JWK_AES_KW: typeof JWK_AES_KW;
|
|
121
|
+
declare const jws_JWK_Asymmetric_Algorithm: typeof JWK_Asymmetric_Algorithm;
|
|
122
|
+
declare const jws_JWK_EC: typeof JWK_EC;
|
|
123
|
+
declare const jws_JWK_ECDH_ES: typeof JWK_ECDH_ES;
|
|
124
|
+
declare const jws_JWK_ECDSA: typeof JWK_ECDSA;
|
|
125
|
+
declare const jws_JWK_EC_Private: typeof JWK_EC_Private;
|
|
126
|
+
declare const jws_JWK_EC_Public: typeof JWK_EC_Public;
|
|
127
|
+
declare const jws_JWK_HMAC: typeof JWK_HMAC;
|
|
128
|
+
declare const jws_JWK_OKP: typeof JWK_OKP;
|
|
129
|
+
declare const jws_JWK_OKP_Private: typeof JWK_OKP_Private;
|
|
130
|
+
declare const jws_JWK_OKP_Public: typeof JWK_OKP_Public;
|
|
131
|
+
declare const jws_JWK_OKP_SIGN: typeof JWK_OKP_SIGN;
|
|
132
|
+
declare const jws_JWK_PBES2: typeof JWK_PBES2;
|
|
133
|
+
declare const jws_JWK_Private: typeof JWK_Private;
|
|
134
|
+
declare const jws_JWK_Public: typeof JWK_Public;
|
|
135
|
+
declare const jws_JWK_RSA: typeof JWK_RSA;
|
|
136
|
+
declare const jws_JWK_RSA_ENC: typeof JWK_RSA_ENC;
|
|
137
|
+
declare const jws_JWK_RSA_PSS: typeof JWK_RSA_PSS;
|
|
138
|
+
declare const jws_JWK_RSA_Private: typeof JWK_RSA_Private;
|
|
139
|
+
declare const jws_JWK_RSA_Public: typeof JWK_RSA_Public;
|
|
140
|
+
declare const jws_JWK_RSA_SIGN: typeof JWK_RSA_SIGN;
|
|
141
|
+
declare const jws_JWK_Symmetric_Algorithm: typeof JWK_Symmetric_Algorithm;
|
|
142
|
+
declare const jws_JWK_oct: typeof JWK_oct;
|
|
103
143
|
type jws_JWSAlgorithm = JWSAlgorithm;
|
|
104
144
|
type jws_JWSHeaderParameters = JWSHeaderParameters;
|
|
105
145
|
type jws_JWSKeyLookupFunction = JWSKeyLookupFunction;
|
|
@@ -111,10 +151,14 @@ declare const jws_JWT: typeof JWT;
|
|
|
111
151
|
declare const jws_JWTClaimValidationOptions: typeof JWTClaimValidationOptions;
|
|
112
152
|
declare const jws_JWTClaims: typeof JWTClaims;
|
|
113
153
|
declare const jws_JoseHeaderParameters: typeof JoseHeaderParameters;
|
|
154
|
+
declare const jws_KeyManagementAlgorithm: typeof KeyManagementAlgorithm;
|
|
155
|
+
declare const jws_UnwrapKeyOptions: typeof UnwrapKeyOptions;
|
|
156
|
+
declare const jws_WrapKeyOptions: typeof WrapKeyOptions;
|
|
157
|
+
declare const jws_WrapKeyResult: typeof WrapKeyResult;
|
|
114
158
|
declare const jws_sign: typeof sign;
|
|
115
159
|
declare const jws_verify: typeof verify;
|
|
116
160
|
declare namespace jws {
|
|
117
|
-
export { jws_JWT as JWT, jws_JWTClaimValidationOptions as JWTClaimValidationOptions, jws_JWTClaims as JWTClaims, jws_JoseHeaderParameters as JoseHeaderParameters, 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 };
|
|
118
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 };
|
|
119
163
|
}
|
|
120
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,
|
|
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.
|
|
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.
|
|
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,
|
|
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';
|