@travetto/auth-session 7.1.4 → 8.0.0-alpha.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/auth-session",
3
- "version": "7.1.4",
3
+ "version": "8.0.0-alpha.0",
4
4
  "type": "module",
5
5
  "description": "Session provider for the travetto auth module.",
6
6
  "keywords": [
@@ -26,12 +26,12 @@
26
26
  "directory": "module/auth-session"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/auth": "^7.1.4",
30
- "@travetto/config": "^7.1.4",
31
- "@travetto/model": "^7.1.4"
29
+ "@travetto/auth": "^8.0.0-alpha.0",
30
+ "@travetto/config": "^8.0.0-alpha.0",
31
+ "@travetto/model": "^8.0.0-alpha.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@travetto/test": "^7.1.4"
34
+ "@travetto/test": "^8.0.0-alpha.0"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@travetto/test": {
package/src/service.ts CHANGED
@@ -38,7 +38,7 @@ export class SessionService {
38
38
 
39
39
  const session = new Session({
40
40
  ...record,
41
- data: JSONUtil.parseBase64(record.data)
41
+ data: JSONUtil.fromBase64(record.data)
42
42
  });
43
43
 
44
44
  // Validate session
@@ -67,7 +67,7 @@ export class SessionService {
67
67
  }
68
68
 
69
69
  // Ensure latest expiry information before persisting
70
- await this.authService.manageExpiry(this.authContext.principal);
70
+ this.authService.manageExpiry(this.authContext.principal);
71
71
 
72
72
  const principal = this.authContext.principal;
73
73
 
@@ -80,7 +80,7 @@ export class SessionService {
80
80
  if (session.action === 'create' || session.isChanged()) {
81
81
  await this.#modelService.upsert(SessionEntry, SessionEntry.from({
82
82
  ...session,
83
- data: JSONUtil.stringifyBase64(session.data)
83
+ data: JSONUtil.toBase64(session.data)
84
84
  }));
85
85
  }
86
86
  // If destroying
package/src/session.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { type AnyMap, castKey, castTo } from '@travetto/runtime';
1
+ import { type AnyMap, castKey, castTo, JSONUtil } from '@travetto/runtime';
2
+
2
3
 
3
4
  /**
4
5
  * @concrete
@@ -57,7 +58,7 @@ export class Session<T extends SessionData = SessionData> {
57
58
  this.#expiresAtLoaded = this.expiresAt ?? new Date();
58
59
 
59
60
  // Hash the session as it stands
60
- this.#payload = JSON.stringify(this);
61
+ this.#payload = JSONUtil.toUTF8(this);
61
62
  }
62
63
 
63
64
  /**
@@ -79,7 +80,7 @@ export class Session<T extends SessionData = SessionData> {
79
80
  * Determine if session has changed
80
81
  */
81
82
  isChanged(): boolean {
82
- return this.isTimeChanged() || this.#payload !== JSON.stringify(this);
83
+ return this.isTimeChanged() || this.#payload !== JSONUtil.toUTF8(this);
83
84
  }
84
85
 
85
86
  /**
@@ -66,7 +66,6 @@ export abstract class AuthSessionServerSuite {
66
66
  @WithAsyncContext()
67
67
  @Test()
68
68
  async testUnauthenticatedSession() {
69
- await assert.throws(() => this.sessionContext.get(true), AuthenticationError);
70
-
69
+ assert.throws(() => this.sessionContext.get(true), AuthenticationError);
71
70
  }
72
71
  }