unjwt 0.5.32 → 0.5.34
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/dist/adapters/h3.d.mts +21 -9
- package/dist/adapters/h3.mjs +39 -21
- package/dist/adapters/h3v1.d.mts +4 -4
- package/dist/adapters/h3v1.mjs +3 -3
- package/dist/adapters/h3v2.d.mts +21 -9
- package/dist/adapters/h3v2.mjs +33 -15
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +3 -3
- package/dist/jwe.d.mts +3 -3
- package/dist/jwe.mjs +2 -2
- package/dist/jwk.d.mts +2 -2
- package/dist/jwk.mjs +1 -1
- package/dist/jws.d.mts +3 -3
- package/dist/jws.mjs +2 -2
- package/dist/shared/{unjwt.B9nv94SS.d.mts → unjwt.4JQCoID_.d.mts} +2 -2
- package/dist/shared/{unjwt.KqQq9jpF.mjs → unjwt.B-v62plj.mjs} +4 -2
- package/dist/shared/{unjwt.CtHrClHc.d.mts → unjwt.BCi3FEWr.d.mts} +3 -3
- package/dist/shared/{unjwt.BjP_dGnX.d.mts → unjwt.BYDTEWa-.d.mts} +1 -1
- package/dist/shared/{unjwt.BsLgL0DQ.d.mts → unjwt.BqdNUKDr.d.mts} +1 -1
- package/dist/shared/{unjwt.BU3IrsCv.d.mts → unjwt.CMNtw8ek.d.mts} +1 -1
- package/dist/shared/{unjwt.CkkdXjZD.d.mts → unjwt.Cy2MlkUe.d.mts} +1 -1
- package/dist/shared/{unjwt.C5jNR_1K.d.mts → unjwt.D0_ccT7g.d.mts} +2 -2
- package/dist/shared/{unjwt.DQVUT7FU.mjs → unjwt.DdLN9vwI.mjs} +2 -2
- package/dist/shared/{unjwt.DyouTtLD.mjs → unjwt.Dpl__ZAR.mjs} +7 -3
- package/dist/utils.d.mts +2 -2
- package/package.json +3 -3
package/dist/adapters/h3.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { b as JWEEncryptOptions } from '../shared/unjwt.
|
|
2
|
-
export { d as JWEDecryptOptions, e as JWEDecryptResult,
|
|
3
|
-
import { X as JWTClaims, E as ExpiresIn, r as JWK_Symmetric, u as JWK_Private, t as JWK_Public, Z as JWTClaimValidationOptions, w as JWKSet } from '../shared/unjwt.
|
|
4
|
-
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters,
|
|
1
|
+
import { b as JWEEncryptOptions, J as JWEHeaderParameters } from '../shared/unjwt.CMNtw8ek.mjs';
|
|
2
|
+
export { d as JWEDecryptOptions, e as JWEDecryptResult, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters } from '../shared/unjwt.CMNtw8ek.mjs';
|
|
3
|
+
import { X as JWTClaims, E as ExpiresIn, r as JWK_Symmetric, u as JWK_Private, t as JWK_Public, Z as JWTClaimValidationOptions, w as JWKSet } from '../shared/unjwt.BCi3FEWr.mjs';
|
|
4
|
+
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, H as JWK_AES_CBC_HMAC, I as JWK_AES_GCM, L as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, N as JWK_PBES2, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, Q as JWK_Symmetric_Algorithm, q as JWK_oct, Y as JWT, V as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from '../shared/unjwt.BCi3FEWr.mjs';
|
|
5
5
|
import { S as StrictOmit } from '../shared/unjwt.JdKqVANs.mjs';
|
|
6
6
|
import { CookieSerializeOptions } from 'cookie-es';
|
|
7
7
|
import { H3Event } from 'h3';
|
|
8
|
-
import { c as JWSSignOptions } from '../shared/unjwt.
|
|
9
|
-
export { d as deriveJWKFromPassword, e as exportJWKToPEM, g as generateJWK, i as importJWKFromPEM } from '../shared/unjwt.
|
|
8
|
+
import { c as JWSSignOptions, b as JWSProtectedHeader } from '../shared/unjwt.BqdNUKDr.mjs';
|
|
9
|
+
export { d as deriveJWKFromPassword, e as exportJWKToPEM, g as generateJWK, i as importJWKFromPEM } from '../shared/unjwt.BYDTEWa-.mjs';
|
|
10
10
|
|
|
11
11
|
interface SessionClaims extends Required<Pick<JWTClaims, "jti" | "iat">>, StrictOmit<JWTClaims, "jti" | "iat"> {
|
|
12
12
|
}
|
|
@@ -48,6 +48,7 @@ interface SessionHooksJWE<T extends Record<string, any> = SessionClaims, MaxAge
|
|
|
48
48
|
config: SessionConfigJWE<T, MaxAge>;
|
|
49
49
|
}) => void | Promise<void>;
|
|
50
50
|
onClear?: (args: {
|
|
51
|
+
session: SessionJWE<T, MaxAge> | undefined;
|
|
51
52
|
event: H3Event;
|
|
52
53
|
config: Partial<SessionConfigJWE<T, MaxAge>>;
|
|
53
54
|
}) => void | Promise<void>;
|
|
@@ -61,6 +62,11 @@ interface SessionHooksJWE<T extends Record<string, any> = SessionClaims, MaxAge
|
|
|
61
62
|
error: any;
|
|
62
63
|
config: SessionConfigJWE<T, MaxAge>;
|
|
63
64
|
}) => void | Promise<void>;
|
|
65
|
+
onUnsealKeyLookup?: (args: {
|
|
66
|
+
header: JWEHeaderParameters;
|
|
67
|
+
event: H3Event;
|
|
68
|
+
config: SessionConfigJWE<T, MaxAge>;
|
|
69
|
+
}) => JWK_Symmetric | JWK_Private | Promise<JWK_Symmetric | JWK_Private>;
|
|
64
70
|
}
|
|
65
71
|
interface SessionConfigJWE<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
66
72
|
/** @deprecated use `key` instead */
|
|
@@ -130,7 +136,7 @@ declare function sealJWESession<T extends Record<string, any> = SessionClaims, M
|
|
|
130
136
|
/**
|
|
131
137
|
* Decrypt the JWE and return a Session-compatible object.
|
|
132
138
|
*/
|
|
133
|
-
declare function unsealJWESession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(
|
|
139
|
+
declare function unsealJWESession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: H3Event | CompatEvent$1, config: SessionConfigJWE<T, MaxAge>, sealed: string): Promise<Partial<SessionJWE<T, MaxAge>>>;
|
|
134
140
|
/**
|
|
135
141
|
* Clear the session (delete from context and drop cookie).
|
|
136
142
|
*/
|
|
@@ -162,6 +168,7 @@ interface SessionHooksJWS<T extends Record<string, any> = SessionClaims, MaxAge
|
|
|
162
168
|
config: SessionConfigJWS<T, MaxAge>;
|
|
163
169
|
}) => void | Promise<void>;
|
|
164
170
|
onClear?: (args: {
|
|
171
|
+
session: SessionJWS<T, MaxAge> | undefined;
|
|
165
172
|
event: H3Event;
|
|
166
173
|
config: Partial<SessionConfigJWS<T, MaxAge>>;
|
|
167
174
|
}) => void | Promise<void>;
|
|
@@ -175,6 +182,11 @@ interface SessionHooksJWS<T extends Record<string, any> = SessionClaims, MaxAge
|
|
|
175
182
|
error: any;
|
|
176
183
|
config: SessionConfigJWS<T, MaxAge>;
|
|
177
184
|
}) => void | Promise<void>;
|
|
185
|
+
onVerifyKeyLookup?: (args: {
|
|
186
|
+
header: JWSProtectedHeader;
|
|
187
|
+
event: H3Event;
|
|
188
|
+
config: SessionConfigJWS<T, MaxAge>;
|
|
189
|
+
}) => JWKSet | JWK_Symmetric | JWK_Public | Promise<JWKSet | JWK_Symmetric | JWK_Public>;
|
|
178
190
|
}
|
|
179
191
|
interface SessionConfigJWS<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
180
192
|
/**
|
|
@@ -241,11 +253,11 @@ declare function signJWSSession<T extends Record<string, any> = SessionClaims, M
|
|
|
241
253
|
* - ensures jti & iat presence
|
|
242
254
|
* - enforces maxAge if provided
|
|
243
255
|
*/
|
|
244
|
-
declare function verifyJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(
|
|
256
|
+
declare function verifyJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: H3Event | CompatEvent, config: SessionConfigJWS<T, MaxAge>, token: string): Promise<Partial<SessionJWS<T, MaxAge>>>;
|
|
245
257
|
/**
|
|
246
258
|
* Destroy the session (context + cookie).
|
|
247
259
|
*/
|
|
248
260
|
declare function clearJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: H3Event, config: Partial<SessionConfigJWS<T, MaxAge>>): Promise<void>;
|
|
249
261
|
|
|
250
|
-
export { JWEEncryptOptions, JWKSet, JWK_Private, JWK_Public, JWK_Symmetric, JWTClaimValidationOptions, JWTClaims, clearJWESession, clearJWSSession, getJWESession, getJWESessionToken, getJWSSession, sealJWESession, signJWSSession, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession };
|
|
262
|
+
export { JWEEncryptOptions, JWEHeaderParameters, JWKSet, JWK_Private, JWK_Public, JWK_Symmetric, JWTClaimValidationOptions, JWTClaims, clearJWESession, clearJWSSession, getJWESession, getJWESessionToken, getJWSSession, sealJWESession, signJWSSession, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession };
|
|
251
263
|
export type { SessionClaims, SessionConfigJWE, SessionConfigJWS, SessionData, SessionHooksJWE, SessionHooksJWS, SessionJWE, SessionJWEConfig, SessionJWS, SessionJWSConfig, SessionManager, SessionUpdate };
|
package/dist/adapters/h3.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { k as deriveJWKFromPassword, h as exportJWKToPEM, c as generateJWK, f as importJWKFromPEM } from '../shared/unjwt.
|
|
1
|
+
export { k as deriveJWKFromPassword, h as exportJWKToPEM, c as generateJWK, f as importJWKFromPEM } from '../shared/unjwt.Dpl__ZAR.mjs';
|
|
2
2
|
import { isEvent, setCookie } from 'h3';
|
|
3
3
|
import { parse } from 'cookie-es';
|
|
4
|
-
import { e as encrypt, d as decrypt } from '../shared/unjwt.
|
|
4
|
+
import { e as encrypt, d as decrypt } from '../shared/unjwt.B-v62plj.mjs';
|
|
5
5
|
import { p as computeExpiresInSeconds, q as isSymmetricJWK, u as isPrivateJWK, w as isPublicJWK } from '../shared/unjwt.Be8NxwFK.mjs';
|
|
6
|
-
import { s as sign, v as verify } from '../shared/unjwt.
|
|
6
|
+
import { s as sign, v as verify } from '../shared/unjwt.DdLN9vwI.mjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* This is a fork of h3 library's session utility functions.
|
|
@@ -142,13 +142,7 @@ function getJWESessionToken(event, config) {
|
|
|
142
142
|
token = headerValue.startsWith("Bearer ") ? headerValue.slice(7).trim() : headerValue;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
if (
|
|
146
|
-
const cookieHeader = _getReqHeader$1(event, "cookie");
|
|
147
|
-
if (cookieHeader) {
|
|
148
|
-
token = parse(String(cookieHeader))[sessionName];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (!token) {
|
|
145
|
+
if (config.cookie !== false) {
|
|
152
146
|
const setCookie2 = _getResHeader$1(event, "set-cookie");
|
|
153
147
|
if (typeof setCookie2 === "string") {
|
|
154
148
|
token = findSetCookie$1(setCookie2, sessionName);
|
|
@@ -161,6 +155,12 @@ function getJWESessionToken(event, config) {
|
|
|
161
155
|
}
|
|
162
156
|
}
|
|
163
157
|
}
|
|
158
|
+
if (!token) {
|
|
159
|
+
const cookieHeader = _getReqHeader$1(event, "cookie");
|
|
160
|
+
if (cookieHeader) {
|
|
161
|
+
token = parse(String(cookieHeader))[sessionName];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
164
|
return token;
|
|
165
165
|
}
|
|
166
166
|
function _getReqHeader$1(event, name) {
|
|
@@ -240,8 +240,12 @@ async function sealJWESession(event, config) {
|
|
|
240
240
|
});
|
|
241
241
|
return token;
|
|
242
242
|
}
|
|
243
|
-
async function unsealJWESession(
|
|
244
|
-
const key =
|
|
243
|
+
async function unsealJWESession(event, config, sealed) {
|
|
244
|
+
const key = config.hooks?.onUnsealKeyLookup ? (header) => config.hooks.onUnsealKeyLookup({
|
|
245
|
+
header,
|
|
246
|
+
event,
|
|
247
|
+
config
|
|
248
|
+
}) : getDecryptKey(config.key || config.secret);
|
|
245
249
|
const alg = config.jwe?.encryptOptions?.alg;
|
|
246
250
|
const enc = config.jwe?.encryptOptions?.enc;
|
|
247
251
|
if (config.jwe?.encryptOptions?.protectedHeader?.typ && typeof config.jwe.encryptOptions.protectedHeader.typ === "string" && config.jwe.encryptOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
|
|
@@ -281,6 +285,10 @@ async function unsealJWESession(_event, config, sealed) {
|
|
|
281
285
|
}
|
|
282
286
|
async function clearJWESession(event, config) {
|
|
283
287
|
const sessionName = config.name || DEFAULT_NAME$1;
|
|
288
|
+
let session = event.context.sessions?.[sessionName];
|
|
289
|
+
if (session && session[kGetSessionPromise$1]) {
|
|
290
|
+
session = await session[kGetSessionPromise$1];
|
|
291
|
+
}
|
|
284
292
|
if (event.context.sessions?.[sessionName]) {
|
|
285
293
|
delete event.context.sessions[sessionName];
|
|
286
294
|
}
|
|
@@ -291,6 +299,7 @@ async function clearJWESession(event, config) {
|
|
|
291
299
|
maxAge: void 0
|
|
292
300
|
});
|
|
293
301
|
await config.hooks?.onClear?.({
|
|
302
|
+
session,
|
|
294
303
|
event,
|
|
295
304
|
config
|
|
296
305
|
});
|
|
@@ -480,13 +489,7 @@ function getJWSSessionToken(event, config) {
|
|
|
480
489
|
token = headerValue.startsWith("Bearer ") ? headerValue.slice(7).trim() : headerValue;
|
|
481
490
|
}
|
|
482
491
|
}
|
|
483
|
-
if (
|
|
484
|
-
const cookieHeader = _getReqHeader(event, "cookie");
|
|
485
|
-
if (cookieHeader) {
|
|
486
|
-
token = parse(String(cookieHeader))[sessionName];
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
if (!token) {
|
|
492
|
+
if (config.cookie !== false) {
|
|
490
493
|
const setCookie2 = _getResHeader(event, "set-cookie");
|
|
491
494
|
if (typeof setCookie2 === "string") {
|
|
492
495
|
token = findSetCookie(setCookie2, sessionName);
|
|
@@ -499,6 +502,12 @@ function getJWSSessionToken(event, config) {
|
|
|
499
502
|
}
|
|
500
503
|
}
|
|
501
504
|
}
|
|
505
|
+
if (!token) {
|
|
506
|
+
const cookieHeader = _getReqHeader(event, "cookie");
|
|
507
|
+
if (cookieHeader) {
|
|
508
|
+
token = parse(String(cookieHeader))[sessionName];
|
|
509
|
+
}
|
|
510
|
+
}
|
|
502
511
|
return token;
|
|
503
512
|
}
|
|
504
513
|
function _getReqHeader(event, name) {
|
|
@@ -577,9 +586,13 @@ async function signJWSSession(event, config) {
|
|
|
577
586
|
});
|
|
578
587
|
return token;
|
|
579
588
|
}
|
|
580
|
-
async function verifyJWSSession(
|
|
589
|
+
async function verifyJWSSession(event, config, token) {
|
|
581
590
|
const alg = config.jws?.signOptions?.alg;
|
|
582
|
-
const jwk =
|
|
591
|
+
const jwk = config.hooks?.onVerifyKeyLookup ? (header) => config.hooks.onVerifyKeyLookup({
|
|
592
|
+
header,
|
|
593
|
+
event,
|
|
594
|
+
config
|
|
595
|
+
}) : getVerifyKey(config.key);
|
|
583
596
|
let typ = void 0;
|
|
584
597
|
if (config.jws?.signOptions?.protectedHeader?.typ && typeof config.jws.signOptions.protectedHeader.typ === "string" && config.jws.signOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
|
|
585
598
|
typ = config.jws.signOptions.protectedHeader.typ;
|
|
@@ -612,6 +625,10 @@ async function verifyJWSSession(_event, config, token) {
|
|
|
612
625
|
}
|
|
613
626
|
async function clearJWSSession(event, config) {
|
|
614
627
|
const sessionName = config.name || DEFAULT_NAME;
|
|
628
|
+
let session = event.context.sessions?.[sessionName];
|
|
629
|
+
if (session && session[kGetSessionPromise]) {
|
|
630
|
+
session = await session[kGetSessionPromise];
|
|
631
|
+
}
|
|
615
632
|
if (event.context.sessions?.[sessionName]) {
|
|
616
633
|
delete event.context.sessions[sessionName];
|
|
617
634
|
}
|
|
@@ -622,6 +639,7 @@ async function clearJWSSession(event, config) {
|
|
|
622
639
|
maxAge: void 0
|
|
623
640
|
});
|
|
624
641
|
await config.hooks?.onClear?.({
|
|
642
|
+
session,
|
|
625
643
|
event,
|
|
626
644
|
config
|
|
627
645
|
});
|
package/dist/adapters/h3v1.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters } from '../shared/unjwt.
|
|
2
|
-
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet,
|
|
1
|
+
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters } from '../shared/unjwt.CMNtw8ek.mjs';
|
|
2
|
+
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet, H as JWK_AES_CBC_HMAC, I as JWK_AES_GCM, L as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, N as JWK_PBES2, u as JWK_Private, t as JWK_Public, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, r as JWK_Symmetric, Q as JWK_Symmetric_Algorithm, q as JWK_oct, Y as JWT, Z as JWTClaimValidationOptions, X as JWTClaims, V as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from '../shared/unjwt.BCi3FEWr.mjs';
|
|
3
3
|
export { SessionClaims, SessionConfigJWE, SessionConfigJWS, SessionData, SessionHooksJWE, SessionHooksJWS, SessionJWE, SessionJWEConfig, SessionJWS, SessionJWSConfig, SessionManager, SessionUpdate, clearJWESession, clearJWSSession, getJWESession, getJWESessionToken, getJWSSession, sealJWESession, signJWSSession, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession } from './h3.mjs';
|
|
4
|
-
export { d as deriveJWKFromPassword, e as exportJWKToPEM, g as generateJWK, i as importJWKFromPEM } from '../shared/unjwt.
|
|
4
|
+
export { d as deriveJWKFromPassword, e as exportJWKToPEM, g as generateJWK, i as importJWKFromPEM } from '../shared/unjwt.BYDTEWa-.mjs';
|
|
5
5
|
import '../shared/unjwt.JdKqVANs.mjs';
|
|
6
6
|
import 'cookie-es';
|
|
7
7
|
import 'h3';
|
|
8
|
-
import '../shared/unjwt.
|
|
8
|
+
import '../shared/unjwt.BqdNUKDr.mjs';
|
package/dist/adapters/h3v1.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { k as deriveJWKFromPassword, h as exportJWKToPEM, c as generateJWK, f as importJWKFromPEM } from '../shared/unjwt.
|
|
1
|
+
export { k as deriveJWKFromPassword, h as exportJWKToPEM, c as generateJWK, f as importJWKFromPEM } from '../shared/unjwt.Dpl__ZAR.mjs';
|
|
2
2
|
export { clearJWESession, clearJWSSession, getJWESession, getJWESessionToken, getJWSSession, sealJWESession, signJWSSession, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession } from './h3.mjs';
|
|
3
3
|
import '../shared/unjwt.Be8NxwFK.mjs';
|
|
4
4
|
import 'h3';
|
|
5
5
|
import 'cookie-es';
|
|
6
|
-
import '../shared/unjwt.
|
|
7
|
-
import '../shared/unjwt.
|
|
6
|
+
import '../shared/unjwt.B-v62plj.mjs';
|
|
7
|
+
import '../shared/unjwt.DdLN9vwI.mjs';
|
package/dist/adapters/h3v2.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { b as JWEEncryptOptions } from '../shared/unjwt.
|
|
2
|
-
export { d as JWEDecryptOptions, e as JWEDecryptResult,
|
|
3
|
-
import { X as JWTClaims, E as ExpiresIn, r as JWK_Symmetric, u as JWK_Private, t as JWK_Public, Z as JWTClaimValidationOptions, w as JWKSet } from '../shared/unjwt.
|
|
4
|
-
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters,
|
|
1
|
+
import { b as JWEEncryptOptions, J as JWEHeaderParameters } from '../shared/unjwt.CMNtw8ek.mjs';
|
|
2
|
+
export { d as JWEDecryptOptions, e as JWEDecryptResult, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters } from '../shared/unjwt.CMNtw8ek.mjs';
|
|
3
|
+
import { X as JWTClaims, E as ExpiresIn, r as JWK_Symmetric, u as JWK_Private, t as JWK_Public, Z as JWTClaimValidationOptions, w as JWKSet } from '../shared/unjwt.BCi3FEWr.mjs';
|
|
4
|
+
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, H as JWK_AES_CBC_HMAC, I as JWK_AES_GCM, L as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, N as JWK_PBES2, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, Q as JWK_Symmetric_Algorithm, q as JWK_oct, Y as JWT, V as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from '../shared/unjwt.BCi3FEWr.mjs';
|
|
5
5
|
import { S as StrictOmit } from '../shared/unjwt.JdKqVANs.mjs';
|
|
6
6
|
import { HTTPEvent } from 'h3';
|
|
7
7
|
import { CookieSerializeOptions } from 'cookie-es';
|
|
8
|
-
import { c as JWSSignOptions } from '../shared/unjwt.
|
|
9
|
-
export { d as deriveJWKFromPassword, e as exportJWKToPEM, g as generateJWK, i as importJWKFromPEM } from '../shared/unjwt.
|
|
8
|
+
import { c as JWSSignOptions, b as JWSProtectedHeader } from '../shared/unjwt.BqdNUKDr.mjs';
|
|
9
|
+
export { d as deriveJWKFromPassword, e as exportJWKToPEM, g as generateJWK, i as importJWKFromPEM } from '../shared/unjwt.BYDTEWa-.mjs';
|
|
10
10
|
|
|
11
11
|
interface SessionClaims extends Required<Pick<JWTClaims, "jti" | "iat">>, StrictOmit<JWTClaims, "jti" | "iat"> {
|
|
12
12
|
}
|
|
@@ -42,6 +42,7 @@ interface SessionHooksJWE<T extends Record<string, any> = SessionClaims, MaxAge
|
|
|
42
42
|
config: SessionConfigJWE<T, MaxAge>;
|
|
43
43
|
}) => void | Promise<void>;
|
|
44
44
|
onClear?: (args: {
|
|
45
|
+
session: SessionJWE<T, MaxAge> | undefined;
|
|
45
46
|
event: HTTPEvent;
|
|
46
47
|
config: Partial<SessionConfigJWE<T, MaxAge>>;
|
|
47
48
|
}) => void | Promise<void>;
|
|
@@ -55,6 +56,11 @@ interface SessionHooksJWE<T extends Record<string, any> = SessionClaims, MaxAge
|
|
|
55
56
|
error: any;
|
|
56
57
|
config: SessionConfigJWE<T, MaxAge>;
|
|
57
58
|
}) => void | Promise<void>;
|
|
59
|
+
onUnsealKeyLookup?: (args: {
|
|
60
|
+
header: JWEHeaderParameters;
|
|
61
|
+
event: HTTPEvent;
|
|
62
|
+
config: SessionConfigJWE<T, MaxAge>;
|
|
63
|
+
}) => JWK_Symmetric | JWK_Private | Promise<JWK_Symmetric | JWK_Private>;
|
|
58
64
|
}
|
|
59
65
|
interface SessionConfigJWE<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
60
66
|
/** Shared secret used, string for PBES2 or Json Web Key (JWK) */
|
|
@@ -101,7 +107,7 @@ declare function sealJWESession<T extends Record<string, any> = SessionClaims, M
|
|
|
101
107
|
/**
|
|
102
108
|
* Decrypt the JWE and return a Session-compatible object.
|
|
103
109
|
*/
|
|
104
|
-
declare function unsealJWESession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(
|
|
110
|
+
declare function unsealJWESession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWE<T, MaxAge>, sealed: string): Promise<Partial<SessionJWE<T, MaxAge>>>;
|
|
105
111
|
/**
|
|
106
112
|
* Clear the session (delete from context and drop cookie).
|
|
107
113
|
*/
|
|
@@ -127,6 +133,7 @@ interface SessionHooksJWS<T extends Record<string, any> = SessionClaims, MaxAge
|
|
|
127
133
|
config: SessionConfigJWS<T, MaxAge>;
|
|
128
134
|
}) => void | Promise<void>;
|
|
129
135
|
onClear?: (args: {
|
|
136
|
+
session: SessionJWS<T, MaxAge> | undefined;
|
|
130
137
|
event: HTTPEvent;
|
|
131
138
|
config: Partial<SessionConfigJWS<T, MaxAge>>;
|
|
132
139
|
}) => void | Promise<void>;
|
|
@@ -140,6 +147,11 @@ interface SessionHooksJWS<T extends Record<string, any> = SessionClaims, MaxAge
|
|
|
140
147
|
error: any;
|
|
141
148
|
config: SessionConfigJWS<T, MaxAge>;
|
|
142
149
|
}) => void | Promise<void>;
|
|
150
|
+
onVerifyKeyLookup?: (args: {
|
|
151
|
+
header: JWSProtectedHeader;
|
|
152
|
+
event: HTTPEvent;
|
|
153
|
+
config: SessionConfigJWS<T, MaxAge>;
|
|
154
|
+
}) => JWKSet | JWK_Symmetric | JWK_Public | Promise<JWKSet | JWK_Symmetric | JWK_Public>;
|
|
143
155
|
}
|
|
144
156
|
interface SessionConfigJWS<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
145
157
|
key: JWK_Symmetric | {
|
|
@@ -164,8 +176,8 @@ declare function getJWSSession<T extends Record<string, any> = SessionClaims, Ma
|
|
|
164
176
|
declare function getJWSSessionToken<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWS<T, MaxAge>): string | undefined;
|
|
165
177
|
declare function updateJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWS<T, MaxAge>, update?: SessionUpdate<T>): Promise<SessionJWS<T, MaxAge>>;
|
|
166
178
|
declare function signJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWS<T, MaxAge>): Promise<string>;
|
|
167
|
-
declare function verifyJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(
|
|
179
|
+
declare function verifyJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWS<T, MaxAge>, token: string): Promise<Partial<SessionJWS<T, MaxAge>>>;
|
|
168
180
|
declare function clearJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: Partial<SessionConfigJWS<T, MaxAge>>): Promise<void>;
|
|
169
181
|
|
|
170
|
-
export { JWEEncryptOptions, JWKSet, JWK_Private, JWK_Public, JWK_Symmetric, JWTClaimValidationOptions, JWTClaims, clearJWESession, clearJWSSession, getJWESession, getJWESessionToken, getJWSSession, getJWSSessionToken, sealJWESession, signJWSSession, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession };
|
|
182
|
+
export { JWEEncryptOptions, JWEHeaderParameters, JWKSet, JWK_Private, JWK_Public, JWK_Symmetric, JWTClaimValidationOptions, JWTClaims, clearJWESession, clearJWSSession, getJWESession, getJWESessionToken, getJWSSession, getJWSSessionToken, sealJWESession, signJWSSession, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession };
|
|
171
183
|
export type { SessionClaims, SessionConfigJWE, SessionConfigJWS, SessionData, SessionHooksJWE, SessionHooksJWS, SessionJWE, SessionJWS, SessionManager, SessionUpdate };
|
package/dist/adapters/h3v2.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { k as deriveJWKFromPassword, h as exportJWKToPEM, c as generateJWK, f as importJWKFromPEM } from '../shared/unjwt.
|
|
1
|
+
export { k as deriveJWKFromPassword, h as exportJWKToPEM, c as generateJWK, f as importJWKFromPEM } from '../shared/unjwt.Dpl__ZAR.mjs';
|
|
2
2
|
import { getEventContext, getChunkedCookie, setChunkedCookie } from 'h3';
|
|
3
3
|
import { NullProtoObj } from 'rou3';
|
|
4
|
-
import { e as encrypt, d as decrypt } from '../shared/unjwt.
|
|
4
|
+
import { e as encrypt, d as decrypt } from '../shared/unjwt.B-v62plj.mjs';
|
|
5
5
|
import { p as computeExpiresInSeconds, q as isSymmetricJWK, u as isPrivateJWK, w as isPublicJWK } from '../shared/unjwt.Be8NxwFK.mjs';
|
|
6
|
-
import { s as sign, v as verify } from '../shared/unjwt.
|
|
6
|
+
import { s as sign, v as verify } from '../shared/unjwt.DdLN9vwI.mjs';
|
|
7
7
|
|
|
8
8
|
const kGetSessionPromise$1 = Symbol("h3_jwe_getSession");
|
|
9
9
|
const DEFAULT_NAME$1 = "h3-jwe";
|
|
@@ -130,15 +130,15 @@ function getJWESessionToken(event, config) {
|
|
|
130
130
|
token = headerValue.startsWith("Bearer ") ? headerValue.slice(7).trim() : headerValue;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
if (
|
|
134
|
-
token = getChunkedCookie(event, sessionName);
|
|
135
|
-
}
|
|
136
|
-
if (!token && hasWritableResponse$1(event)) {
|
|
133
|
+
if (config.cookie !== false && hasWritableResponse$1(event)) {
|
|
137
134
|
const setCookie = event.res.headers.get("set-cookie");
|
|
138
135
|
if (typeof setCookie === "string") {
|
|
139
136
|
token = findSetCookie$1(setCookie, sessionName);
|
|
140
137
|
}
|
|
141
138
|
}
|
|
139
|
+
if (!token) {
|
|
140
|
+
token = getChunkedCookie(event, sessionName);
|
|
141
|
+
}
|
|
142
142
|
return token;
|
|
143
143
|
}
|
|
144
144
|
async function updateJWESession(event, config, update) {
|
|
@@ -199,8 +199,12 @@ async function sealJWESession(event, config) {
|
|
|
199
199
|
});
|
|
200
200
|
return token;
|
|
201
201
|
}
|
|
202
|
-
async function unsealJWESession(
|
|
203
|
-
const key =
|
|
202
|
+
async function unsealJWESession(event, config, sealed) {
|
|
203
|
+
const key = config.hooks?.onUnsealKeyLookup ? (header) => config.hooks.onUnsealKeyLookup({
|
|
204
|
+
header,
|
|
205
|
+
event,
|
|
206
|
+
config
|
|
207
|
+
}) : getDecryptKey(config.key);
|
|
204
208
|
const alg = config.jwe?.encryptOptions?.alg;
|
|
205
209
|
const enc = config.jwe?.encryptOptions?.enc;
|
|
206
210
|
if (config.jwe?.encryptOptions?.protectedHeader?.typ && typeof config.jwe.encryptOptions.protectedHeader.typ === "string" && config.jwe.encryptOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
|
|
@@ -239,6 +243,10 @@ async function unsealJWESession(_event, config, sealed) {
|
|
|
239
243
|
async function clearJWESession(event, config) {
|
|
240
244
|
const context = getEventContext(event);
|
|
241
245
|
const sessionName = config.name || DEFAULT_NAME$1;
|
|
246
|
+
let session = context.sessions?.[sessionName];
|
|
247
|
+
if (session && session[kGetSessionPromise$1]) {
|
|
248
|
+
session = await session[kGetSessionPromise$1];
|
|
249
|
+
}
|
|
242
250
|
if (context.sessions?.[sessionName]) {
|
|
243
251
|
delete context.sessions[sessionName];
|
|
244
252
|
}
|
|
@@ -250,6 +258,7 @@ async function clearJWESession(event, config) {
|
|
|
250
258
|
maxAge: void 0
|
|
251
259
|
});
|
|
252
260
|
await config.hooks?.onClear?.({
|
|
261
|
+
session,
|
|
253
262
|
event,
|
|
254
263
|
config
|
|
255
264
|
});
|
|
@@ -432,15 +441,15 @@ function getJWSSessionToken(event, config) {
|
|
|
432
441
|
token = headerValue.startsWith("Bearer ") ? headerValue.slice(7).trim() : headerValue;
|
|
433
442
|
}
|
|
434
443
|
}
|
|
435
|
-
if (
|
|
436
|
-
token = getChunkedCookie(event, sessionName);
|
|
437
|
-
}
|
|
438
|
-
if (!token && hasWritableResponse(event)) {
|
|
444
|
+
if (config.cookie !== false && hasWritableResponse(event)) {
|
|
439
445
|
const setCookie = event.res.headers.get("set-cookie");
|
|
440
446
|
if (typeof setCookie === "string") {
|
|
441
447
|
token = findSetCookie(setCookie, sessionName);
|
|
442
448
|
}
|
|
443
449
|
}
|
|
450
|
+
if (!token) {
|
|
451
|
+
token = getChunkedCookie(event, sessionName);
|
|
452
|
+
}
|
|
444
453
|
return token;
|
|
445
454
|
}
|
|
446
455
|
async function updateJWSSession(event, config, update) {
|
|
@@ -502,9 +511,13 @@ async function signJWSSession(event, config) {
|
|
|
502
511
|
});
|
|
503
512
|
return token;
|
|
504
513
|
}
|
|
505
|
-
async function verifyJWSSession(
|
|
506
|
-
const jwk = getVerifyKey(config.key);
|
|
514
|
+
async function verifyJWSSession(event, config, token) {
|
|
507
515
|
const alg = config.jws?.signOptions?.alg;
|
|
516
|
+
const jwk = config.hooks?.onVerifyKeyLookup ? (header) => config.hooks.onVerifyKeyLookup({
|
|
517
|
+
header,
|
|
518
|
+
event,
|
|
519
|
+
config
|
|
520
|
+
}) : getVerifyKey(config.key);
|
|
508
521
|
let typ;
|
|
509
522
|
if (config.jws?.signOptions?.protectedHeader?.typ && typeof config.jws.signOptions.protectedHeader.typ === "string" && config.jws.signOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
|
|
510
523
|
typ = config.jws.signOptions.protectedHeader.typ;
|
|
@@ -537,6 +550,10 @@ async function verifyJWSSession(_event, config, token) {
|
|
|
537
550
|
async function clearJWSSession(event, config) {
|
|
538
551
|
const context = getEventContext(event);
|
|
539
552
|
const sessionName = config.name || DEFAULT_NAME;
|
|
553
|
+
let session = context.sessions?.[sessionName];
|
|
554
|
+
if (session && session[kGetSessionPromise]) {
|
|
555
|
+
session = await session[kGetSessionPromise];
|
|
556
|
+
}
|
|
540
557
|
if (context.sessions?.[sessionName]) {
|
|
541
558
|
delete context.sessions[sessionName];
|
|
542
559
|
}
|
|
@@ -548,6 +565,7 @@ async function clearJWSSession(event, config) {
|
|
|
548
565
|
maxAge: void 0
|
|
549
566
|
});
|
|
550
567
|
await config.hooks?.onClear?.({
|
|
568
|
+
session,
|
|
551
569
|
event,
|
|
552
570
|
config
|
|
553
571
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, E as ExpiresIn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet,
|
|
2
|
-
export { i as utils } from './shared/unjwt.
|
|
3
|
-
export { j as jwe } from './shared/unjwt.
|
|
4
|
-
export { j as jwk } from './shared/unjwt.
|
|
5
|
-
export { j as jws } from './shared/unjwt.
|
|
6
|
-
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult } from './shared/unjwt.
|
|
7
|
-
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters } from './shared/unjwt.
|
|
1
|
+
export { C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, E as ExpiresIn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet, H as JWK_AES_CBC_HMAC, I as JWK_AES_GCM, L as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, N as JWK_PBES2, u as JWK_Private, t as JWK_Public, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, r as JWK_Symmetric, Q as JWK_Symmetric_Algorithm, q as JWK_oct, Y as JWT, Z as JWTClaimValidationOptions, X as JWTClaims, V as JoseHeaderParameters, K as KeyManagementAlgorithm, M as MaxTokenAge, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.BCi3FEWr.mjs';
|
|
2
|
+
export { i as utils } from './shared/unjwt.Cy2MlkUe.mjs';
|
|
3
|
+
export { j as jwe } from './shared/unjwt.4JQCoID_.mjs';
|
|
4
|
+
export { j as jwk } from './shared/unjwt.BYDTEWa-.mjs';
|
|
5
|
+
export { j as jws } from './shared/unjwt.D0_ccT7g.mjs';
|
|
6
|
+
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult } from './shared/unjwt.BqdNUKDr.mjs';
|
|
7
|
+
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters } from './shared/unjwt.CMNtw8ek.mjs';
|
|
8
8
|
import './shared/unjwt.JdKqVANs.mjs';
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { i as utils } from './shared/unjwt.Be8NxwFK.mjs';
|
|
2
|
-
export { j as jwe } from './shared/unjwt.
|
|
3
|
-
export { j as jwk } from './shared/unjwt.
|
|
4
|
-
export { j as jws } from './shared/unjwt.
|
|
2
|
+
export { j as jwe } from './shared/unjwt.B-v62plj.mjs';
|
|
3
|
+
export { j as jwk } from './shared/unjwt.Dpl__ZAR.mjs';
|
|
4
|
+
export { j as jws } from './shared/unjwt.DdLN9vwI.mjs';
|
package/dist/jwe.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet,
|
|
2
|
-
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters } from './shared/unjwt.
|
|
3
|
-
export { d as decrypt, e as encrypt } from './shared/unjwt.
|
|
1
|
+
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet, H as JWK_AES_CBC_HMAC, I as JWK_AES_GCM, L as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, N as JWK_PBES2, u as JWK_Private, t as JWK_Public, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, r as JWK_Symmetric, Q as JWK_Symmetric_Algorithm, q as JWK_oct, Y as JWT, Z as JWTClaimValidationOptions, X as JWTClaims, V as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.BCi3FEWr.mjs';
|
|
2
|
+
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters } from './shared/unjwt.CMNtw8ek.mjs';
|
|
3
|
+
export { d as decrypt, e as encrypt } from './shared/unjwt.4JQCoID_.mjs';
|
|
4
4
|
import './shared/unjwt.JdKqVANs.mjs';
|
package/dist/jwe.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
1
|
+
import './shared/unjwt.Dpl__ZAR.mjs';
|
|
2
2
|
import './shared/unjwt.Be8NxwFK.mjs';
|
|
3
|
-
export { d as decrypt, e as encrypt } from './shared/unjwt.
|
|
3
|
+
export { d as decrypt, e as encrypt } from './shared/unjwt.B-v62plj.mjs';
|
package/dist/jwk.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet,
|
|
2
|
-
export { d as deriveJWKFromPassword, b as deriveKeyFromPassword, e as exportJWKToPEM, f as exportKey, g as generateJWK, a as generateKey, h as getJWKFromSet, i as importJWKFromPEM, c as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.
|
|
1
|
+
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet, H as JWK_AES_CBC_HMAC, I as JWK_AES_GCM, L as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, N as JWK_PBES2, u as JWK_Private, t as JWK_Public, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, r as JWK_Symmetric, Q as JWK_Symmetric_Algorithm, q as JWK_oct, Y as JWT, Z as JWTClaimValidationOptions, X as JWTClaims, V as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.BCi3FEWr.mjs';
|
|
2
|
+
export { d as deriveJWKFromPassword, b as deriveKeyFromPassword, e as exportJWKToPEM, f as exportKey, g as generateJWK, a as generateKey, h as getJWKFromSet, i as importJWKFromPEM, c as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.BYDTEWa-.mjs';
|
package/dist/jwk.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './shared/unjwt.Be8NxwFK.mjs';
|
|
2
|
-
export { k as deriveJWKFromPassword, m as deriveKeyFromPassword, h as exportJWKToPEM, n as exportKey, c as generateJWK, l as generateKey, b as getJWKFromSet, f as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.
|
|
2
|
+
export { k as deriveJWKFromPassword, m as deriveKeyFromPassword, h as exportJWKToPEM, n as exportKey, c as generateJWK, l as generateKey, b as getJWKFromSet, f as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.Dpl__ZAR.mjs';
|
package/dist/jws.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet,
|
|
2
|
-
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult } from './shared/unjwt.
|
|
3
|
-
export { s as sign, v as verify } from './shared/unjwt.
|
|
1
|
+
export { 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet, H as JWK_AES_CBC_HMAC, I as JWK_AES_GCM, L as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, N as JWK_PBES2, u as JWK_Private, t as JWK_Public, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, r as JWK_Symmetric, Q as JWK_Symmetric_Algorithm, q as JWK_oct, Y as JWT, Z as JWTClaimValidationOptions, X as JWTClaims, V as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.BCi3FEWr.mjs';
|
|
2
|
+
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult } from './shared/unjwt.BqdNUKDr.mjs';
|
|
3
|
+
export { s as sign, v as verify } from './shared/unjwt.D0_ccT7g.mjs';
|
package/dist/jws.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
1
|
+
import './shared/unjwt.Dpl__ZAR.mjs';
|
|
2
2
|
import './shared/unjwt.Be8NxwFK.mjs';
|
|
3
|
-
export { s as sign, v as verify } from './shared/unjwt.
|
|
3
|
+
export { s as sign, v as verify } from './shared/unjwt.DdLN9vwI.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { X as JWTClaims, v as JWK, K as KeyManagementAlgorithm, f as ContentEncryptionAlgorithm, r as JWK_Symmetric, u as JWK_Private, C as CompositeKey, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet,
|
|
2
|
-
import { b as JWEEncryptOptions, c as JWEKeyLookupFunction, d as JWEDecryptOptions, e as JWEDecryptResult, J as JWEHeaderParameters, a as JWEKeyManagementHeaderParameters } from './unjwt.
|
|
1
|
+
import { X as JWTClaims, v as JWK, K as KeyManagementAlgorithm, f as ContentEncryptionAlgorithm, r as JWK_Symmetric, u as JWK_Private, C as CompositeKey, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, w as JWKSet, H as JWK_AES_CBC_HMAC, I as JWK_AES_GCM, L as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, N as JWK_PBES2, t as JWK_Public, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, Q as JWK_Symmetric_Algorithm, q as JWK_oct, Y as JWT, Z as JWTClaimValidationOptions, V as JoseHeaderParameters, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.BCi3FEWr.mjs';
|
|
2
|
+
import { b as JWEEncryptOptions, c as JWEKeyLookupFunction, d as JWEDecryptOptions, e as JWEDecryptResult, J as JWEHeaderParameters, a as JWEKeyManagementHeaderParameters } from './unjwt.CMNtw8ek.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Encrypts a payload to produce a JWE Compact Serialization string.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as importKey, e as encryptKey, g as generateIV, a as encrypt$1, u as unwrapKey, d as decrypt$1 } from './unjwt.
|
|
1
|
+
import { i as importKey, e as encryptKey, g as generateIV, a as encrypt$1, u as unwrapKey, d as decrypt$1 } from './unjwt.Dpl__ZAR.mjs';
|
|
2
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.Be8NxwFK.mjs';
|
|
3
3
|
|
|
4
4
|
async function encrypt(payload, key, options = {}) {
|
|
@@ -16,7 +16,7 @@ async function encrypt(payload, key, options = {}) {
|
|
|
16
16
|
if (typeof key === "string" || key instanceof Uint8Array) {
|
|
17
17
|
alg = "PBES2-HS256+A128KW";
|
|
18
18
|
} else if (isJWK(key)) {
|
|
19
|
-
alg = key.alg;
|
|
19
|
+
alg = key.alg === "A128GCM" || key.alg === "A192GCM" || key.alg === "A256GCM" ? `${key.alg}KW` : key.alg;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
if (!alg) {
|
|
@@ -59,6 +59,8 @@ async function encrypt(payload, key, options = {}) {
|
|
|
59
59
|
const jweProtectedHeader = sanitizeObject({
|
|
60
60
|
...baseProtectedHeader,
|
|
61
61
|
...keyManagementHeaderParams,
|
|
62
|
+
...isJWK(key) && key.kid ? { kid: key.kid } : {},
|
|
63
|
+
// Include kid if available
|
|
62
64
|
alg,
|
|
63
65
|
enc
|
|
64
66
|
});
|
|
@@ -236,13 +236,13 @@ type JWK_RSA_PSS = "PS256" | "PS384" | "PS512";
|
|
|
236
236
|
type JWK_ECDSA = "ES256" | "ES384" | "ES512";
|
|
237
237
|
type JWK_RSA_ENC = "RSA-OAEP" | "RSA-OAEP-256" | "RSA-OAEP-384" | "RSA-OAEP-512";
|
|
238
238
|
type JWK_AES_KW = "A128KW" | "A192KW" | "A256KW";
|
|
239
|
-
type JWK_AES_GCM_KW = "A128GCMKW" | "A192GCMKW" | "A256GCMKW";
|
|
240
239
|
type JWK_AES_CBC_HMAC = "A128CBC-HS256" | "A192CBC-HS384" | "A256CBC-HS512";
|
|
241
240
|
type JWK_AES_GCM = "A128GCM" | "A192GCM" | "A256GCM";
|
|
241
|
+
type JWK_AES_GCM_KW = "A128GCMKW" | "A192GCMKW" | "A256GCMKW";
|
|
242
242
|
type JWK_PBES2 = "PBES2-HS256+A128KW" | "PBES2-HS384+A192KW" | "PBES2-HS512+A256KW";
|
|
243
243
|
type JWK_ECDH_ES = "ECDH-ES" | "ECDH-ES+A128KW" | "ECDH-ES+A192KW" | "ECDH-ES+A256KW";
|
|
244
244
|
type JWK_OKP_SIGN = "Ed25519" | "EdDSA";
|
|
245
|
-
type JWK_Symmetric_Algorithm = JWK_HMAC | JWK_AES_KW | JWK_AES_GCM;
|
|
245
|
+
type JWK_Symmetric_Algorithm = JWK_HMAC | JWK_AES_KW | JWK_AES_GCM | JWK_AES_GCM_KW;
|
|
246
246
|
type JWK_Asymmetric_Algorithm = JWK_RSA_SIGN | JWK_RSA_PSS | JWK_ECDSA | JWK_RSA_ENC | JWK_OKP_SIGN | JWK_ECDH_ES;
|
|
247
247
|
type JWKAlgorithm = JWK_Symmetric_Algorithm | JWK_Asymmetric_Algorithm | JWK_AES_CBC_HMAC | JWK_PBES2 | JWK_ECDH_ES | ("none" | "dir");
|
|
248
248
|
type JWKPEMAlgorithm = JWK_RSA_PSS | JWK_RSA_SIGN | JWK_RSA_ENC | JWK_ECDSA | JWK_ECDH_ES | JWK_OKP_SIGN;
|
|
@@ -325,4 +325,4 @@ interface JWTClaimValidationOptions {
|
|
|
325
325
|
type ExpiresIn = number | `${number}` | `${number}${"s" | "second" | "seconds" | "m" | "minute" | "minutes" | "h" | "hour" | "hours" | "D" | "day" | "days" | "W" | "week" | "weeks" | "M" | "month" | "months" | "Y" | "year" | "years"}`;
|
|
326
326
|
type MaxTokenAge = ExpiresIn;
|
|
327
327
|
|
|
328
|
-
export type { JWK_ECDSA as A, JWK_RSA_ENC as B, CompositeKey as C, DeriveKeyOptions as D, ExpiresIn as E, JWK_AES_KW as F, GenerateKeyAlgorithm as G,
|
|
328
|
+
export type { JWK_ECDSA as A, JWK_RSA_ENC as B, CompositeKey as C, DeriveKeyOptions as D, ExpiresIn as E, JWK_AES_KW as F, GenerateKeyAlgorithm as G, JWK_AES_CBC_HMAC as H, JWK_AES_GCM as I, JWKParameters as J, KeyManagementAlgorithm as K, JWK_AES_GCM_KW as L, MaxTokenAge as M, JWK_PBES2 as N, JWK_ECDH_ES as O, JWK_OKP_SIGN as P, JWK_Symmetric_Algorithm as Q, JWK_Asymmetric_Algorithm as R, JWKAlgorithm as S, JWKPEMAlgorithm as T, UnwrapKeyOptions as U, JoseHeaderParameters as V, WrapKeyOptions as W, JWTClaims as X, JWT as Y, JWTClaimValidationOptions as Z, 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_Symmetric as r, JWK_Asymmetric as s, JWK_Public as t, JWK_Private as u, JWK as v, JWKSet as w, JWK_HMAC as x, JWK_RSA_SIGN as y, JWK_RSA_PSS as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, J as JWKParameters, c as GenerateJWKOptions, d as GenerateJWKReturn, N as JWK_PBES2, D as DeriveKeyOptions, e as DeriveKeyReturn, q as JWK_oct, v as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, g as WrapKeyResult, U as UnwrapKeyOptions, T as JWKPEMAlgorithm, w as JWKSet, V as JoseHeaderParameters, C as CompositeKey, f as ContentEncryptionAlgorithm, S as JWKAlgorithm,
|
|
1
|
+
import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, J as JWKParameters, c as GenerateJWKOptions, d as GenerateJWKReturn, N as JWK_PBES2, D as DeriveKeyOptions, e as DeriveKeyReturn, q as JWK_oct, v as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, g as WrapKeyResult, U as UnwrapKeyOptions, T as JWKPEMAlgorithm, w as JWKSet, V as JoseHeaderParameters, C as CompositeKey, f as ContentEncryptionAlgorithm, S as JWKAlgorithm, H as JWK_AES_CBC_HMAC, I as JWK_AES_GCM, L as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, u as JWK_Private, t as JWK_Public, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, r as JWK_Symmetric, Q as JWK_Symmetric_Algorithm, Y as JWT, Z as JWTClaimValidationOptions, X as JWTClaims } from './unjwt.BCi3FEWr.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This is a fork of Jose library's utility functions.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { x as JWK_HMAC, y as JWK_RSA_SIGN, z as JWK_RSA_PSS, A as JWK_ECDSA, V as JoseHeaderParameters, E as ExpiresIn, v as JWK, w as JWKSet, Z as JWTClaimValidationOptions, X as JWTClaims } from './unjwt.
|
|
1
|
+
import { x as JWK_HMAC, y as JWK_RSA_SIGN, z as JWK_RSA_PSS, A as JWK_ECDSA, V as JoseHeaderParameters, E as ExpiresIn, v as JWK, w as JWKSet, Z as JWTClaimValidationOptions, X as JWTClaims } from './unjwt.BCi3FEWr.mjs';
|
|
2
2
|
|
|
3
3
|
type JWS_SIGN_EXTRA = "Ed25519" | "EdDSA";
|
|
4
4
|
/** JWS Signing Algorithm Identifier. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as KeyManagementAlgorithm, f as ContentEncryptionAlgorithm, E as ExpiresIn, V as JoseHeaderParameters, h as JWK_EC_Public, i as JWK_EC_Private, v as JWK, Z as JWTClaimValidationOptions, X as JWTClaims } from './unjwt.
|
|
1
|
+
import { K as KeyManagementAlgorithm, f as ContentEncryptionAlgorithm, E as ExpiresIn, V as JoseHeaderParameters, h as JWK_EC_Public, i as JWK_EC_Private, v as JWK, Z as JWTClaimValidationOptions, X as JWTClaims } from './unjwt.BCi3FEWr.mjs';
|
|
2
2
|
import { S as StrictOmit } from './unjwt.JdKqVANs.mjs';
|
|
3
3
|
|
|
4
4
|
/** Recognized JWE Header Parameters, any other Header Members may also be present. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as ExpiresIn, X as JWTClaims, Z as JWTClaimValidationOptions, v as JWK, w as JWKSet, q as JWK_oct, u as JWK_Private, t as JWK_Public } from './unjwt.
|
|
1
|
+
import { E as ExpiresIn, X as JWTClaims, Z as JWTClaimValidationOptions, v as JWK, w as JWKSet, q as JWK_oct, u as JWK_Private, t as JWK_Public } from './unjwt.BCi3FEWr.mjs';
|
|
2
2
|
import { S as StrictOmit } from './unjwt.JdKqVANs.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { X as JWTClaims, r as JWK_Symmetric, u as JWK_Private, t as JWK_Public, w as JWKSet, 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters,
|
|
2
|
-
import { c as JWSSignOptions, J as JWSAlgorithm, f as JWSKeyLookupFunction, e as JWSVerifyOptions, d as JWSVerifyResult, a as JWSHeaderParameters, b as JWSProtectedHeader } from './unjwt.
|
|
1
|
+
import { X as JWTClaims, r as JWK_Symmetric, u as JWK_Private, t as JWK_Public, w as JWKSet, 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, H as JWK_AES_CBC_HMAC, I as JWK_AES_GCM, L as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, N as JWK_PBES2, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, Q as JWK_Symmetric_Algorithm, q as JWK_oct, Y as JWT, Z as JWTClaimValidationOptions, V as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.BCi3FEWr.mjs';
|
|
2
|
+
import { c as JWSSignOptions, J as JWSAlgorithm, f as JWSKeyLookupFunction, e as JWSVerifyOptions, d as JWSVerifyResult, a as JWSHeaderParameters, b as JWSProtectedHeader } from './unjwt.BqdNUKDr.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Creates a JWS (JSON Web Signature) in Compact Serialization format.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as importKey, s as sign$1, b as getJWKFromSet, v as verify$1 } from './unjwt.
|
|
1
|
+
import { i as importKey, s as sign$1, b as getJWKFromSet, v as verify$1 } from './unjwt.Dpl__ZAR.mjs';
|
|
2
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.Be8NxwFK.mjs';
|
|
3
3
|
|
|
4
4
|
async function sign(payload, key, options = {}) {
|
|
@@ -18,7 +18,7 @@ async function sign(payload, key, options = {}) {
|
|
|
18
18
|
const signingKey = await importKey(key, alg);
|
|
19
19
|
const protectedHeader = {
|
|
20
20
|
...safeAdditionalHeader,
|
|
21
|
-
...isJWK(key) && key.kid ? { kid:
|
|
21
|
+
...isJWK(key) && key.kid ? { kid: key.kid } : {},
|
|
22
22
|
// Include kid if available
|
|
23
23
|
alg,
|
|
24
24
|
typ: safeAdditionalHeader?.typ
|
|
@@ -2010,10 +2010,14 @@ function getGenerateKeyParams(alg, options) {
|
|
|
2010
2010
|
// AES GCM Encryption
|
|
2011
2011
|
case "A128GCM":
|
|
2012
2012
|
case "A192GCM":
|
|
2013
|
-
case "A256GCM":
|
|
2014
|
-
|
|
2013
|
+
case "A256GCM":
|
|
2014
|
+
case "A128GCMKW":
|
|
2015
|
+
case "A192GCMKW":
|
|
2016
|
+
case "A256GCMKW": {
|
|
2017
|
+
const baseAlg = alg.replace("KW", "");
|
|
2018
|
+
const length = Number.parseInt(baseAlg.slice(1, 4), 10);
|
|
2015
2019
|
algorithm = { name: "AES-GCM", length };
|
|
2016
|
-
keyUsages = defaultKeyUsage ?? ["encrypt", "decrypt"];
|
|
2020
|
+
keyUsages = defaultKeyUsage ?? (alg.endsWith("KW") ? ["wrapKey", "unwrapKey"] : ["encrypt", "decrypt"]);
|
|
2017
2021
|
break;
|
|
2018
2022
|
}
|
|
2019
2023
|
// ECDSA Signatures
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
1
|
+
import './shared/unjwt.BCi3FEWr.mjs';
|
|
2
2
|
export { S as StrictOmit } from './shared/unjwt.JdKqVANs.mjs';
|
|
3
|
-
export { s as applyTypCtyDefaults, j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, z as computeExpiresInSeconds, B as computeJwtTimeClaims, A as computeMaxTokenAgeSeconds, 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, F as sanitizeObject, a as textDecoder, t as textEncoder, E as validateCriticalHeadersJWE, D as validateCriticalHeadersJWS, C as validateJwtClaims } from './shared/unjwt.
|
|
3
|
+
export { s as applyTypCtyDefaults, j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, z as computeExpiresInSeconds, B as computeJwtTimeClaims, A as computeMaxTokenAgeSeconds, 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, F as sanitizeObject, a as textDecoder, t as textEncoder, E as validateCriticalHeadersJWE, D as validateCriticalHeadersJWS, C as validateJwtClaims } from './shared/unjwt.Cy2MlkUe.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unjwt",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.34",
|
|
4
4
|
"description": "Low-level JWT utilities",
|
|
5
5
|
"repository": "sandros94/unjwt",
|
|
6
6
|
"license": "MIT",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "^22",
|
|
67
67
|
"@types/supertest": "^6.0.3",
|
|
68
|
-
"@vitest/coverage-v8": "^
|
|
68
|
+
"@vitest/coverage-v8": "^4.0.14",
|
|
69
69
|
"automd": "^0.4.2",
|
|
70
70
|
"changelogen": "^0.6.2",
|
|
71
71
|
"cookie-esv1": "npm:cookie-es@^1.2.2",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"supertest": "^7.1.4",
|
|
80
80
|
"typescript": "^5.9.2",
|
|
81
81
|
"unbuild": "^3.6.1",
|
|
82
|
-
"vitest": "^
|
|
82
|
+
"vitest": "^4.0.14"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"cookie-es": "^1.2.2 || ^2.0.0",
|