unjwt 0.5.33 → 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.
@@ -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>;
@@ -167,6 +168,7 @@ interface SessionHooksJWS<T extends Record<string, any> = SessionClaims, MaxAge
167
168
  config: SessionConfigJWS<T, MaxAge>;
168
169
  }) => void | Promise<void>;
169
170
  onClear?: (args: {
171
+ session: SessionJWS<T, MaxAge> | undefined;
170
172
  event: H3Event;
171
173
  config: Partial<SessionConfigJWS<T, MaxAge>>;
172
174
  }) => void | Promise<void>;
@@ -285,6 +285,10 @@ async function unsealJWESession(event, config, sealed) {
285
285
  }
286
286
  async function clearJWESession(event, config) {
287
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
+ }
288
292
  if (event.context.sessions?.[sessionName]) {
289
293
  delete event.context.sessions[sessionName];
290
294
  }
@@ -295,6 +299,7 @@ async function clearJWESession(event, config) {
295
299
  maxAge: void 0
296
300
  });
297
301
  await config.hooks?.onClear?.({
302
+ session,
298
303
  event,
299
304
  config
300
305
  });
@@ -620,6 +625,10 @@ async function verifyJWSSession(event, config, token) {
620
625
  }
621
626
  async function clearJWSSession(event, config) {
622
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
+ }
623
632
  if (event.context.sessions?.[sessionName]) {
624
633
  delete event.context.sessions[sessionName];
625
634
  }
@@ -630,6 +639,7 @@ async function clearJWSSession(event, config) {
630
639
  maxAge: void 0
631
640
  });
632
641
  await config.hooks?.onClear?.({
642
+ session,
633
643
  event,
634
644
  config
635
645
  });
@@ -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>;
@@ -132,6 +133,7 @@ interface SessionHooksJWS<T extends Record<string, any> = SessionClaims, MaxAge
132
133
  config: SessionConfigJWS<T, MaxAge>;
133
134
  }) => void | Promise<void>;
134
135
  onClear?: (args: {
136
+ session: SessionJWS<T, MaxAge> | undefined;
135
137
  event: HTTPEvent;
136
138
  config: Partial<SessionConfigJWS<T, MaxAge>>;
137
139
  }) => void | Promise<void>;
@@ -243,6 +243,10 @@ async function unsealJWESession(event, config, sealed) {
243
243
  async function clearJWESession(event, config) {
244
244
  const context = getEventContext(event);
245
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
+ }
246
250
  if (context.sessions?.[sessionName]) {
247
251
  delete context.sessions[sessionName];
248
252
  }
@@ -254,6 +258,7 @@ async function clearJWESession(event, config) {
254
258
  maxAge: void 0
255
259
  });
256
260
  await config.hooks?.onClear?.({
261
+ session,
257
262
  event,
258
263
  config
259
264
  });
@@ -545,6 +550,10 @@ async function verifyJWSSession(event, config, token) {
545
550
  async function clearJWSSession(event, config) {
546
551
  const context = getEventContext(event);
547
552
  const sessionName = config.name || DEFAULT_NAME;
553
+ let session = context.sessions?.[sessionName];
554
+ if (session && session[kGetSessionPromise]) {
555
+ session = await session[kGetSessionPromise];
556
+ }
548
557
  if (context.sessions?.[sessionName]) {
549
558
  delete context.sessions[sessionName];
550
559
  }
@@ -556,6 +565,7 @@ async function clearJWSSession(event, config) {
556
565
  maxAge: void 0
557
566
  });
558
567
  await config.hooks?.onClear?.({
568
+ session,
559
569
  event,
560
570
  config
561
571
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unjwt",
3
- "version": "0.5.33",
3
+ "version": "0.5.34",
4
4
  "description": "Low-level JWT utilities",
5
5
  "repository": "sandros94/unjwt",
6
6
  "license": "MIT",