anbaric-tsapi 1.18.0 → 1.19.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": "anbaric-tsapi",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "These are the shared libraries - types, classes, etc - that both the public state-machine and hosting services share",
5
5
  "license": "MIT",
6
6
  "author": "chris@anbaric.ai",
@@ -4,7 +4,7 @@ interface Actor {
4
4
 
5
5
  type : ActorType;
6
6
  id : string;
7
- role : string;
7
+ roles : Array<string>;
8
8
 
9
9
  }
10
10
 
@@ -4,7 +4,7 @@ class SystemActor implements Actor {
4
4
 
5
5
  type : ActorType = "SYSTEM";
6
6
  id = "_SYSTEM";
7
- role = "_SYSTEM";
7
+ roles = ["_SYSTEM"];
8
8
 
9
9
  static actor = new SystemActor();
10
10
 
@@ -8,12 +8,12 @@ class Agent implements Actor {
8
8
 
9
9
  readonly type = "AGENT" as const;
10
10
  readonly id : string;
11
- readonly role : string;
11
+ readonly roles : Array<string>;
12
12
  readonly client : Agent.Client;
13
13
 
14
- constructor(id : string, role : string, client : Agent.Client) {
14
+ constructor(id : string, roles : Array<string> | string, client : Agent.Client) {
15
15
  this.id = id;
16
- this.role = role;
16
+ this.roles = typeof roles === "string" ? [roles] : roles;
17
17
  this.client = client;
18
18
  }
19
19
 
@@ -10,7 +10,7 @@ type WorkflowDefinition = {
10
10
  states : Array<{
11
11
  id : string,
12
12
  isTerminal : boolean,
13
- actions : Array<{ name : string, description : string, actor : { id : string, type : string, role : string } }>,
13
+ actions : Array<{ name : string, description : string, actor : { id : string, type : string, roles : Array<string> } }>,
14
14
  transitions : Array<{ to : string }>,
15
15
  }>,
16
16
 
@@ -0,0 +1,20 @@
1
+ /* The identity behind a platform session token, as resolved by the platform. */
2
+ type ResolvedSession = {
3
+
4
+ id : string,
5
+ roles : Array<string>,
6
+ tenant? : string,
7
+
8
+ };
9
+
10
+ /* Resolves a platform session token (the anbaric_session cookie) into the
11
+ user's identity. A deployed app cannot verify the token itself - it is signed
12
+ with a platform-only secret - so the resolution is a call to the platform.
13
+ Returns undefined when the token is missing, invalid or expired. */
14
+ interface SessionResolver {
15
+
16
+ resolve(sessionToken : string) : Promise<ResolvedSession | undefined>;
17
+
18
+ }
19
+
20
+ export type { SessionResolver, ResolvedSession }
package/src/index.ts CHANGED
@@ -14,6 +14,7 @@ export * from "./api/auditing/NoOpAuditor"
14
14
  export * from "./api/transitions/Transition"
15
15
  export * from "./api/actors/Actor"
16
16
  export * from "./api/actors/SystemActor"
17
+ export * from "./api/sessions/SessionResolver"
17
18
  export * from "./api/documents/JsonStore"
18
19
  export * from "./api/secrets/SecretStore"
19
20
  export * from "./api/sql/SqlStore"