anbaric-impl-cloud 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-impl-cloud",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "Public client library for the Anbaric Cloud hosting API, providing JobPersistence and Queue implementations backed by the cloud service",
5
5
  "license": "MIT",
6
6
  "author": "chris@anbaric.ai",
@@ -11,7 +11,7 @@
11
11
  "test": "vitest run"
12
12
  },
13
13
  "dependencies": {
14
- "anbaric-tsapi": "^1.18.0"
14
+ "anbaric-tsapi": "^1.19.0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/node": "^26.2.0",
@@ -0,0 +1,22 @@
1
+ import {ResolvedSession, SessionResolver} from "anbaric-tsapi";
2
+ import {CloudApiClient} from "./CloudApiClient";
3
+
4
+ /* Resolves a platform session token by asking the platform to verify it (an app
5
+ holds no signing secret). A rejected request - an invalid or expired token
6
+ answers 401 - resolves to undefined. */
7
+ class CloudSessionResolver implements SessionResolver {
8
+
9
+ constructor(private client : CloudApiClient = new CloudApiClient(CloudApiClient.defaultBaseUrl())) {}
10
+
11
+ async resolve(sessionToken : string) : Promise<ResolvedSession | undefined> {
12
+ try {
13
+ const result = await this.client.request("POST", "/sessions/resolve", { session: sessionToken });
14
+ return { id: result.id, roles: result.roles ?? [], tenant: result.tenant };
15
+ } catch {
16
+ return undefined;
17
+ }
18
+ }
19
+
20
+ }
21
+
22
+ export { CloudSessionResolver }
package/src/index.ts CHANGED
@@ -4,3 +4,4 @@ export * from "./CloudJsonStore";
4
4
  export * from "./CloudSecretStore";
5
5
  export * from "./CloudQueue";
6
6
  export * from "./CloudAuditor";
7
+ export * from "./CloudSessionResolver";