unjwt 0.5.34 → 0.5.35

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.
@@ -44,6 +44,7 @@ interface SessionHooksJWE<T extends Record<string, any> = SessionClaims, MaxAge
44
44
  }) => void | Promise<void>;
45
45
  onUpdate?: (args: {
46
46
  session: SessionJWE<T, MaxAge>;
47
+ oldSession: SessionJWE<T, MaxAge>;
47
48
  event: H3Event;
48
49
  config: SessionConfigJWE<T, MaxAge>;
49
50
  }) => void | Promise<void>;
@@ -164,6 +165,7 @@ interface SessionHooksJWS<T extends Record<string, any> = SessionClaims, MaxAge
164
165
  }) => void | Promise<void>;
165
166
  onUpdate?: (args: {
166
167
  session: SessionJWS<T, MaxAge>;
168
+ oldSession: SessionJWS<T, MaxAge>;
167
169
  event: H3Event;
168
170
  config: SessionConfigJWS<T, MaxAge>;
169
171
  }) => void | Promise<void>;
@@ -189,10 +189,12 @@ async function updateJWESession(event, config, update) {
189
189
  update = update(session.data);
190
190
  }
191
191
  if (update) {
192
+ const oldSession = { ...session, data: { ...session.data } };
192
193
  Object.assign(session.data, update);
193
194
  await config.hooks?.onUpdate?.({
194
- event,
195
195
  session,
196
+ oldSession,
197
+ event,
196
198
  config
197
199
  });
198
200
  }
@@ -536,10 +538,12 @@ async function updateJWSSession(event, config, update) {
536
538
  update = update(session.data);
537
539
  }
538
540
  if (update) {
541
+ const oldSession = { ...session, data: { ...session.data } };
539
542
  Object.assign(session.data, update);
540
543
  await config.hooks?.onUpdate?.({
541
- event,
542
544
  session,
545
+ oldSession,
546
+ event,
543
547
  config
544
548
  });
545
549
  }
@@ -38,6 +38,7 @@ interface SessionHooksJWE<T extends Record<string, any> = SessionClaims, MaxAge
38
38
  }) => void | Promise<void>;
39
39
  onUpdate?: (args: {
40
40
  session: SessionJWE<T, MaxAge>;
41
+ oldSession: SessionJWE<T, MaxAge>;
41
42
  event: HTTPEvent;
42
43
  config: SessionConfigJWE<T, MaxAge>;
43
44
  }) => void | Promise<void>;
@@ -129,6 +130,7 @@ interface SessionHooksJWS<T extends Record<string, any> = SessionClaims, MaxAge
129
130
  }) => void | Promise<void>;
130
131
  onUpdate?: (args: {
131
132
  session: SessionJWS<T, MaxAge>;
133
+ oldSession: SessionJWS<T, MaxAge>;
132
134
  event: HTTPEvent;
133
135
  config: SessionConfigJWS<T, MaxAge>;
134
136
  }) => void | Promise<void>;
@@ -149,10 +149,12 @@ async function updateJWESession(event, config, update) {
149
149
  update = update(session.data);
150
150
  }
151
151
  if (update) {
152
+ const oldSession = { ...session, data: { ...session.data } };
152
153
  Object.assign(session.data, update);
153
154
  await config.hooks?.onUpdate?.({
154
- event,
155
+ oldSession,
155
156
  session,
157
+ event,
156
158
  config
157
159
  });
158
160
  }
@@ -460,10 +462,12 @@ async function updateJWSSession(event, config, update) {
460
462
  update = update(session.data);
461
463
  }
462
464
  if (update) {
465
+ const oldSession = { ...session, data: { ...session.data } };
463
466
  Object.assign(session.data, update);
464
467
  await config.hooks?.onUpdate?.({
465
- event,
466
468
  session,
469
+ oldSession,
470
+ event,
467
471
  config
468
472
  });
469
473
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unjwt",
3
- "version": "0.5.34",
3
+ "version": "0.5.35",
4
4
  "description": "Low-level JWT utilities",
5
5
  "repository": "sandros94/unjwt",
6
6
  "license": "MIT",