@agentage/extension 0.25.1 → 0.25.2

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.
@@ -6,6 +6,7 @@ export interface Caller {
6
6
  sub: string;
7
7
  scopes: readonly string[];
8
8
  }
9
+ export declare const tokenIdOf: (caller: Caller | null | undefined) => string | undefined;
9
10
  export declare const withJti: (caller: Caller, jti: string | undefined) => Caller;
10
11
  export type TokenCheck = (authorization: string | undefined, access: Access, at?: string) => Promise<Caller | null>;
11
12
  export declare const setCaller: (request: object, caller: Caller | null) => void;
@@ -9,6 +9,8 @@ export const badScope = (scope, allowed = ACCESS) => scope === undefined || allo
9
9
  : `scope ${String(scope)}: one of ${allowed.join(', ')}`;
10
10
  // The token id beside a caller, never on it: the log's session when the client sends no agsid.
11
11
  const tokenIds = new WeakMap();
12
+ // The token id (jti) of a verified bearer; undefined for a caller with none (a session, a test caller).
13
+ export const tokenIdOf = (caller) => caller ? tokenIds.get(caller) : undefined;
12
14
  export const withJti = (caller, jti) => {
13
15
  if (jti !== undefined)
14
16
  tokenIds.set(caller, jti);
@@ -22,7 +24,7 @@ export const setCaller = (request, caller) => {
22
24
  if (!scope || !caller)
23
25
  return;
24
26
  scope.sub = caller.sub;
25
- scope.session ??= tokenIds.get(caller) ?? null;
27
+ scope.session ??= tokenIdOf(caller) ?? null;
26
28
  };
27
29
  export const callerOf = (request) => callers.get(request) ?? null;
28
30
  // The access the route guard let a request through at; open: the host takes no token by design.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { type ApiContext, type ParamsOf, type RouteHandler, type RouteMethod, type RouteRegistrar, type RouteRequest, type RouteSpec, } from './api/routes.js';
2
2
  export { download, type DownloadAnswer, type DownloadBody, type DownloadOptions, } from './api/download.js';
3
3
  export { pageOf, PageQuerySchema, type Pagination } from './api/page.js';
4
- export { type Access, type Caller } from './auth/token-check.js';
4
+ export { tokenIdOf, type Access, type Caller } from './auth/token-check.js';
5
5
  export { type ArgValue } from './command/args.js';
6
6
  export { type CliClient, type CliContext, type CliCreate, type CommandExtension, type CommandHandler, } from './command/command.types.js';
7
7
  export { type Out } from './command/out.js';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export {} from './api/routes.js';
2
2
  export { download, } from './api/download.js';
3
3
  export { pageOf, PageQuerySchema } from './api/page.js';
4
- export {} from './auth/token-check.js';
4
+ export { tokenIdOf } from './auth/token-check.js';
5
5
  export {} from './command/args.js';
6
6
  export {} from './command/command.types.js';
7
7
  export {} from './command/out.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentage/extension",
3
- "version": "0.25.1",
3
+ "version": "0.25.2",
4
4
  "description": "The agentage extension kit: create(ctx) per part (pages, ui, api, mcp, worker, cli), the store, /health, discovery, the envelope, and the build tool with up and token",
5
5
  "type": "module",
6
6
  "license": "MIT",