unjwt 0.5.35 → 0.5.36
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.mjs +10 -10
- package/dist/adapters/h3v2.mjs +10 -10
- package/package.json +1 -1
package/dist/adapters/h3.mjs
CHANGED
|
@@ -215,15 +215,15 @@ async function sealJWESession(event, config) {
|
|
|
215
215
|
const key = getEncryptKey(config.key || config.secret);
|
|
216
216
|
const sessionName = config.name || DEFAULT_NAME$1;
|
|
217
217
|
const session = event.context.sessions?.[sessionName] || await getJWESession(event, config);
|
|
218
|
-
const
|
|
219
|
-
const
|
|
218
|
+
const iat = Math.floor(Date.now() / 1e3);
|
|
219
|
+
const exp = config.maxAge === void 0 ? void 0 : iat + computeExpiresInSeconds(config.maxAge);
|
|
220
220
|
const payload = {
|
|
221
221
|
...session.data,
|
|
222
222
|
jti: session.id,
|
|
223
|
-
iat
|
|
223
|
+
iat
|
|
224
224
|
};
|
|
225
|
-
if (
|
|
226
|
-
payload.exp =
|
|
225
|
+
if (exp) {
|
|
226
|
+
payload.exp = exp;
|
|
227
227
|
}
|
|
228
228
|
let typ = void 0;
|
|
229
229
|
if (config.jwe?.encryptOptions?.protectedHeader?.typ && typeof config.jwe.encryptOptions.protectedHeader.typ === "string" && config.jwe.encryptOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
|
|
@@ -563,15 +563,15 @@ async function signJWSSession(event, config) {
|
|
|
563
563
|
const key = getSignKey(config.key);
|
|
564
564
|
const sessionName = config.name || DEFAULT_NAME;
|
|
565
565
|
const session = event.context.sessions?.[sessionName] || await getJWSSession(event, config);
|
|
566
|
-
const
|
|
567
|
-
const
|
|
566
|
+
const iat = Math.floor(Date.now() / 1e3);
|
|
567
|
+
const exp = config.maxAge === void 0 ? void 0 : iat + computeExpiresInSeconds(config.maxAge);
|
|
568
568
|
const payload = {
|
|
569
569
|
...session.data,
|
|
570
570
|
jti: session.id,
|
|
571
|
-
iat
|
|
571
|
+
iat
|
|
572
572
|
};
|
|
573
|
-
if (
|
|
574
|
-
payload.exp =
|
|
573
|
+
if (exp) {
|
|
574
|
+
payload.exp = exp;
|
|
575
575
|
}
|
|
576
576
|
let typ = void 0;
|
|
577
577
|
if (config.jws?.signOptions?.protectedHeader?.typ && typeof config.jws.signOptions.protectedHeader.typ === "string" && config.jws.signOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
|
package/dist/adapters/h3v2.mjs
CHANGED
|
@@ -175,15 +175,15 @@ async function sealJWESession(event, config) {
|
|
|
175
175
|
const sessionName = config.name || DEFAULT_NAME$1;
|
|
176
176
|
const context = getEventContext(event);
|
|
177
177
|
const session = context.sessions?.[sessionName] || await getJWESession(event, config);
|
|
178
|
-
const
|
|
179
|
-
const
|
|
178
|
+
const iat = Math.floor(Date.now() / 1e3);
|
|
179
|
+
const exp = config.maxAge === void 0 ? void 0 : iat + computeExpiresInSeconds(config.maxAge);
|
|
180
180
|
const payload = {
|
|
181
181
|
...session.data,
|
|
182
182
|
jti: session.id,
|
|
183
|
-
iat
|
|
183
|
+
iat
|
|
184
184
|
};
|
|
185
|
-
if (
|
|
186
|
-
payload.exp =
|
|
185
|
+
if (exp) {
|
|
186
|
+
payload.exp = exp;
|
|
187
187
|
}
|
|
188
188
|
let typ = void 0;
|
|
189
189
|
if (config.jwe?.encryptOptions?.protectedHeader?.typ && typeof config.jwe.encryptOptions.protectedHeader.typ === "string" && config.jwe.encryptOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
|
|
@@ -488,15 +488,15 @@ async function signJWSSession(event, config) {
|
|
|
488
488
|
const sessionName = config.name || DEFAULT_NAME;
|
|
489
489
|
const context = getEventContext(event);
|
|
490
490
|
const session = context.sessions?.[sessionName] || await getJWSSession(event, config);
|
|
491
|
-
const
|
|
492
|
-
const
|
|
491
|
+
const iat = Math.floor(Date.now() / 1e3);
|
|
492
|
+
const exp = config.maxAge === void 0 ? void 0 : iat + computeExpiresInSeconds(config.maxAge);
|
|
493
493
|
const payload = {
|
|
494
494
|
...session.data,
|
|
495
495
|
jti: session.id,
|
|
496
|
-
iat
|
|
496
|
+
iat
|
|
497
497
|
};
|
|
498
|
-
if (
|
|
499
|
-
payload.exp =
|
|
498
|
+
if (exp) {
|
|
499
|
+
payload.exp = exp;
|
|
500
500
|
}
|
|
501
501
|
let typ;
|
|
502
502
|
if (config.jws?.signOptions?.protectedHeader?.typ && typeof config.jws.signOptions.protectedHeader.typ === "string" && config.jws.signOptions.protectedHeader.typ.toLowerCase().includes("jwt")) {
|