anbaric-cloud-hosting 1.21.2 → 1.21.4

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.4",
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.4",
22
+ "anbaric-plugins": "^1.21.4",
23
+ "anbaric-tsapi": "^1.21.4",
24
+ "anbaric-web": "^1.21.4",
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.4",
32
+ "anbaric-state-machine": "^1.21.4",
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 {
@@ -72,6 +72,8 @@ const ensureSchema = async (pool : Pool) : Promise<void> => {
72
72
  )
73
73
  `);
74
74
  await pool.query("ALTER TABLE queue ADD COLUMN IF NOT EXISTS app_id TEXT");
75
+ await pool.query("ALTER TABLE queue ADD COLUMN IF NOT EXISTS retry_at TIMESTAMPTZ");
76
+ await pool.query("ALTER TABLE queue ADD COLUMN IF NOT EXISTS attempts INT NOT NULL DEFAULT 0");
75
77
  await pool.query(`UPDATE queue
76
78
  SET app_id = split_part(workflow_id, '/', 1),
77
79
  workflow_id = substring(workflow_id from position('/' in workflow_id) + 1)
@@ -4,7 +4,7 @@ import {AuditRecordStore} from "../auditing/AuditRecordStore";
4
4
  import {Authenticator} from "../auth/Authenticator";
5
5
  import {CliAuthorizer} from "../auth/CliAuthorizer";
6
6
  import {TokenAuthenticator} from "../auth/TokenAuthenticator";
7
- import {ConfirmableQueue} from "../queuing/ConfirmableQueue";
7
+ import {RemoteQueue} from "../queuing/RemoteQueue";
8
8
  import {ConsumerRegistry} from "../queuing/ConsumerRegistry";
9
9
  import {AppProxyHandler} from "./handlers/AppProxyHandler";
10
10
  import {AppLinkFallbackHandler} from "./handlers/AppLinkFallbackHandler";
@@ -42,7 +42,7 @@ class HostingServer {
42
42
  private publicServer : Server;
43
43
  private internalServer : Server;
44
44
 
45
- constructor(persistence : JobPersistence, queue : ConfirmableQueue,
45
+ constructor(persistence : JobPersistence, queue : RemoteQueue,
46
46
  registry : ConsumerRegistry = new ConsumerRegistry(),
47
47
  buildLayer? : BuildLayer,
48
48
  documentStoreFor? : (appId : string, collection : string) => JsonStore,
@@ -1,10 +1,10 @@
1
- import {ConfirmableQueue} from "../../queuing/ConfirmableQueue";
1
+ import {RemoteQueue} from "../../queuing/RemoteQueue";
2
2
  import {Request} from "../Request";
3
3
  import {RequestHandler} from "../RequestHandler";
4
4
 
5
5
  class QueueHandler implements RequestHandler {
6
6
 
7
- constructor(private queue : ConfirmableQueue) {}
7
+ constructor(private queue : RemoteQueue) {}
8
8
 
9
9
  async handle(request : Request) : Promise<void> {
10
10
  if (request.subresource) return request.notFound();
@@ -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();