anbaric-cloud-hosting 1.21.2 → 1.21.3

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": "anbaric-cloud-hosting",
3
- "version": "1.21.2",
3
+ "version": "1.21.3",
4
4
  "description": "Anbaric Cloud hosting service: Postgres-backed job persistence and queuing exposed over an HTTP API",
5
5
  "license": "MIT",
6
6
  "author": "chris@anbaric.ai",
@@ -18,18 +18,18 @@
18
18
  "@aws-sdk/client-s3": "^3.1110.0",
19
19
  "@aws-sdk/client-secrets-manager": "^3.700.0",
20
20
  "@aws-sdk/client-servicediscovery": "^3.1110.0",
21
- "anbaric-data-store": "^1.21.2",
22
- "anbaric-plugins": "^1.21.2",
23
- "anbaric-tsapi": "^1.21.2",
24
- "anbaric-web": "^1.21.2",
21
+ "anbaric-data-store": "^1.21.3",
22
+ "anbaric-plugins": "^1.21.3",
23
+ "anbaric-tsapi": "^1.21.3",
24
+ "anbaric-web": "^1.21.3",
25
25
  "esbuild": "^0.28.2",
26
26
  "pg": "^8.16.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^26.2.0",
30
30
  "@types/pg": "^8.15.0",
31
- "anbaric-impl-cloud": "^1.21.2",
32
- "anbaric-state-machine": "^1.21.2",
31
+ "anbaric-impl-cloud": "^1.21.3",
32
+ "anbaric-state-machine": "^1.21.3",
33
33
  "tsx": "^4.20.0",
34
34
  "typescript": "^7.0.2"
35
35
  },
@@ -40,6 +40,8 @@ class SessionSigner {
40
40
  sub: user.id,
41
41
  tenant: tenant?.id,
42
42
  roles: user.roles.map(role => role.id),
43
+ name: user.name,
44
+ picture: user.picture,
43
45
  exp: nowSeconds() + this.ttlSeconds,
44
46
  };
45
47
  const payload = base64url(JSON.stringify(claims));
@@ -52,7 +54,7 @@ class SessionSigner {
52
54
  const [payload, signature] = token.split(".");
53
55
  if (!payload || !signature || !this.signatureMatches(payload, signature)) return undefined;
54
56
 
55
- let claims : { sub? : unknown, tenant? : unknown, roles? : unknown, exp? : unknown };
57
+ let claims : { sub? : unknown, tenant? : unknown, roles? : unknown, name? : unknown, picture? : unknown, exp? : unknown };
56
58
  try {
57
59
  claims = JSON.parse(Buffer.from(payload, "base64url").toString());
58
60
  } catch {
@@ -64,7 +66,9 @@ class SessionSigner {
64
66
 
65
67
  const roles = Array.isArray(claims.roles) ? claims.roles.map(id => new Role(String(id))) : [];
66
68
  const tenant = typeof claims.tenant === "string" ? new Tenant(claims.tenant) : undefined;
67
- return [new User(claims.sub, roles), tenant];
69
+ const name = typeof claims.name === "string" ? claims.name : undefined;
70
+ const picture = typeof claims.picture === "string" ? claims.picture : undefined;
71
+ return [new User(claims.sub, roles, [], name, picture), tenant];
68
72
  }
69
73
 
70
74
  // Sets (or, for a still-valid session, refreshes) the session cookie.
package/src/auth/User.ts CHANGED
@@ -6,11 +6,16 @@ class User {
6
6
  readonly id : string;
7
7
  roles : Array<Role>;
8
8
  keyPairs : Array<KeyPair>;
9
+ readonly name? : string;
10
+ readonly picture? : string;
9
11
 
10
- constructor(id : string, roles : Array<Role> = [], keyPairs : Array<KeyPair> = []) {
12
+ constructor(id : string, roles : Array<Role> = [], keyPairs : Array<KeyPair> = [],
13
+ name? : string, picture? : string) {
11
14
  this.id = id;
12
15
  this.roles = roles;
13
16
  this.keyPairs = keyPairs;
17
+ this.name = name;
18
+ this.picture = picture;
14
19
  }
15
20
 
16
21
  hasRole(role : Role) : boolean {
@@ -8,6 +8,8 @@ class WhoamiHandler implements RequestHandler {
8
8
  return request.reply(200, {
9
9
  id: request.user.id,
10
10
  roles: request.user.roles.map(role => role.id),
11
+ name: request.user.name,
12
+ picture: request.user.picture,
11
13
  });
12
14
  }
13
15
  request.notFound();