@owlmeans/server-auth-token 0.1.18-rc.4 → 0.1.18-rc.6

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/README.md CHANGED
@@ -6,7 +6,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
6
6
  your project's skill store (`.agents/skills/`):
7
7
 
8
8
  ```sh
9
- npx @owlmeans/agent-skills@^0.1.18-rc.16
9
+ npx @owlmeans/agent-skills@^0.1.18-rc.18
10
10
  ```
11
11
 
12
12
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
3
  "package": "@owlmeans/server-auth-token",
4
- "version": "0.1.18-rc.4",
5
- "generatedAt": "2026-09-12T12:32:46.383Z",
4
+ "version": "0.1.18-rc.6",
5
+ "generatedAt": "2026-09-12T13:35:38.922Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -8,7 +8,7 @@ user-invocable: false
8
8
  # @owlmeans/server-auth-token
9
9
 
10
10
  **Layer:** Server
11
- **Install:** `"@owlmeans/server-auth-token": "^0.1.18-rc.4"` in `dependencies`
11
+ **Install:** `"@owlmeans/server-auth-token": "^0.1.18-rc.6"` in `dependencies`
12
12
  **Contracts:** `@owlmeans/auth-token` — the record, the routes, the format helpers
13
13
 
14
14
  ## Key Exports
@@ -21,7 +21,7 @@ user-invocable: false
21
21
  | `makeAccessTokenResource(dbAlias?)` | The Mongo resource, with its three indexes |
22
22
  | `prefixOf(context, opts?)` | The deployment's prefix: guard options → config → default |
23
23
  | `hashAccessToken(token)` · `mintAccessToken(prefix)` | The stored form; one minted `{ token, hash, display }` |
24
- | `setupAuthTokenCoguard(entrypoints, guard?)` | Append the guard to every entrypoint that already has one |
24
+ | `withAuthTokenCoguard(protocolTree, guard?)` | Return the same-shaped immutable tree with the guard appended to every already-guarded protocol |
25
25
  | `listAccessTokens` · `createAccessToken` · `revokeAccessToken` | The three handlers |
26
26
  | `AuthTokenGuardOptions` (`prefix`, `denyAliases`, `touchInterval`, `resourceAlias`, `profileAlias`) · `AuthTokenConfig` · `AccessTokenResource` | Types |
27
27
 
@@ -99,7 +99,7 @@ tokens that are not theirs.
99
99
  ## The coguard admits a token everywhere, and the deny list lives in the GUARD
100
100
 
101
101
  ```typescript
102
- setupAuthTokenCoguard(managerEntrypoints as Array<{ guards?: string[] }>)
102
+ const guardedManagerProtocols = withAuthTokenCoguard(managerProtocols)
103
103
  ```
104
104
 
105
105
  An API client drives the same surface a browser does — projects, stories, files — so admitting the
@@ -108,8 +108,8 @@ never substitutes: the primary guard stays first and still claims its own creden
108
108
  matches only a value carrying the prefix. It skips entrypoints that have no guard, and it is
109
109
  idempotent.
110
110
 
111
- **Run it after the final binding**, because it reads the guard list each entrypoint actually ended
112
- up with.
111
+ Decorate the declaration tree before bindings are created. The helper preserves the input tree's
112
+ shape, leaves unguarded protocols unchanged, and is idempotent.
113
113
 
114
114
  Routes that must stay behind an interactive session — opening a checkout, starting an OAuth flow,
115
115
  minting another token — are named in `AuthTokenGuardOptions.denyAliases` rather than skipped here.
@@ -1,4 +1,4 @@
1
- import type { EntrypointProtocolDeclaration } from '@owlmeans/entrypoint';
1
+ import type { EntrypointTree } from '@owlmeans/entrypoint';
2
2
  /**
3
3
  * Let an access token authenticate every route that already has a guard.
4
4
  *
@@ -11,5 +11,5 @@ import type { EntrypointProtocolDeclaration } from '@owlmeans/entrypoint';
11
11
  * than skipped here — a child entrypoint inherits every guard its ancestors declare and cannot
12
12
  * drop one, so the refusal has to live where the credential is inspected.
13
13
  */
14
- export declare const withAuthTokenCoguard: <Protocol extends EntrypointProtocolDeclaration>(declarations: readonly Protocol[], guard?: string) => Protocol[];
14
+ export declare const withAuthTokenCoguard: <Tree extends EntrypointTree>(tree: Tree, guard?: string) => Tree;
15
15
  //# sourceMappingURL=coguard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coguard.d.ts","sourceRoot":"","sources":["../src/coguard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAA;AAEzE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,SAAS,6BAA6B,gBACnE,SAAS,QAAQ,EAAE,UAAS,MAAM,KAC/C,QAAQ,EAIT,CAAA"}
1
+ {"version":3,"file":"coguard.d.ts","sourceRoot":"","sources":["../src/coguard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAAI,IAAI,SAAS,cAAc,QACxD,IAAI,UAAS,MAAM,KACxB,IAID,CAAA"}
package/build/coguard.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { GUARD_AUTH_TOKEN } from '@owlmeans/auth-token';
2
- import { decorateEntrypoint } from '@owlmeans/entrypoint';
2
+ import { decorateEntrypoint, mapProtocols } from '@owlmeans/entrypoint';
3
3
  /**
4
4
  * Let an access token authenticate every route that already has a guard.
5
5
  *
@@ -12,7 +12,7 @@ import { decorateEntrypoint } from '@owlmeans/entrypoint';
12
12
  * than skipped here — a child entrypoint inherits every guard its ancestors declare and cannot
13
13
  * drop one, so the refusal has to live where the credential is inspected.
14
14
  */
15
- export const withAuthTokenCoguard = (declarations, guard = GUARD_AUTH_TOKEN) => declarations.map(declaration => {
15
+ export const withAuthTokenCoguard = (tree, guard = GUARD_AUTH_TOKEN) => mapProtocols(tree, declaration => {
16
16
  if (declaration.guards.length < 1 || declaration.guards.includes(guard))
17
17
  return declaration;
18
18
  return decorateEntrypoint(declaration, { guards: [...declaration.guards, guard] });
@@ -1 +1 @@
1
- {"version":3,"file":"coguard.js","sourceRoot":"","sources":["../src/coguard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAGzD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,YAAiC,EAAE,KAAK,GAAW,gBAAgB,EACvD,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;IAC9C,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,WAAW,CAAA;IAE3F,OAAO,kBAAkB,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;AACpF,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"coguard.js","sourceRoot":"","sources":["../src/coguard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGvE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,IAAU,EAAE,KAAK,GAAW,gBAAgB,EACtC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE;IAC1C,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,WAAW,CAAA;IAE3F,OAAO,kBAAkB,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;AACpF,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/server-auth-token",
3
- "version": "0.1.18-rc.4",
3
+ "version": "0.1.18-rc.6",
4
4
  "license": "MIT",
5
5
  "description": "The server half of OwlMeans access tokens — the store, the guard that verifies a presented token, the management handlers and the coguard that admits one on an existing route.",
6
6
  "type": "module",
@@ -24,16 +24,16 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@noble/hashes": "^1.5.0",
27
- "@owlmeans/auth": "^0.1.18-rc.13",
28
- "@owlmeans/auth-common": "^0.1.18-rc.17",
29
- "@owlmeans/auth-token": "^0.1.18-rc.4",
30
- "@owlmeans/context": "^0.1.18-rc.12",
31
- "@owlmeans/entrypoint": "^0.1.18-rc.15",
32
- "@owlmeans/mongo-resource": "^0.1.18-rc.16",
33
- "@owlmeans/resource": "^0.1.18-rc.13",
34
- "@owlmeans/server-api": "^0.1.18-rc.21",
35
- "@owlmeans/server-auth-identity": "^0.1.18-rc.17",
36
- "@owlmeans/server-context": "^0.1.18-rc.16",
27
+ "@owlmeans/auth": "^0.1.18-rc.15",
28
+ "@owlmeans/auth-common": "^0.1.18-rc.19",
29
+ "@owlmeans/auth-token": "^0.1.18-rc.6",
30
+ "@owlmeans/context": "^0.1.18-rc.14",
31
+ "@owlmeans/entrypoint": "^0.1.18-rc.17",
32
+ "@owlmeans/mongo-resource": "^0.1.18-rc.18",
33
+ "@owlmeans/resource": "^0.1.18-rc.15",
34
+ "@owlmeans/server-api": "^0.1.18-rc.23",
35
+ "@owlmeans/server-auth-identity": "^0.1.18-rc.19",
36
+ "@owlmeans/server-context": "^0.1.18-rc.18",
37
37
  "@scure/base": "^1.1.9"
38
38
  },
39
39
  "devDependencies": {
package/src/coguard.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { GUARD_AUTH_TOKEN } from '@owlmeans/auth-token'
2
- import { decorateEntrypoint } from '@owlmeans/entrypoint'
3
- import type { EntrypointProtocolDeclaration } from '@owlmeans/entrypoint'
2
+ import { decorateEntrypoint, mapProtocols } from '@owlmeans/entrypoint'
3
+ import type { EntrypointTree } from '@owlmeans/entrypoint'
4
4
 
5
5
  /**
6
6
  * Let an access token authenticate every route that already has a guard.
@@ -14,9 +14,9 @@ import type { EntrypointProtocolDeclaration } from '@owlmeans/entrypoint'
14
14
  * than skipped here — a child entrypoint inherits every guard its ancestors declare and cannot
15
15
  * drop one, so the refusal has to live where the credential is inspected.
16
16
  */
17
- export const withAuthTokenCoguard = <Protocol extends EntrypointProtocolDeclaration>(
18
- declarations: readonly Protocol[], guard: string = GUARD_AUTH_TOKEN,
19
- ): Protocol[] => declarations.map(declaration => {
17
+ export const withAuthTokenCoguard = <Tree extends EntrypointTree>(
18
+ tree: Tree, guard: string = GUARD_AUTH_TOKEN,
19
+ ): Tree => mapProtocols(tree, declaration => {
20
20
  if (declaration.guards.length < 1 || declaration.guards.includes(guard)) return declaration
21
21
 
22
22
  return decorateEntrypoint(declaration, { guards: [...declaration.guards, guard] })
@@ -1,13 +1,13 @@
1
1
  import { describe, expect, test } from 'bun:test'
2
2
  import { GUARD_AUTH_TOKEN } from '@owlmeans/auth-token'
3
- import { openProtocol } from '@owlmeans/entrypoint'
3
+ import { openProtocol, protocols } from '@owlmeans/entrypoint'
4
4
  import { route } from '@owlmeans/route'
5
5
  import { withAuthTokenCoguard } from '../src/coguard.js'
6
6
 
7
7
  describe('@owlmeans/server-auth-token — the coguard', () => {
8
8
  test('decorates a guarded protocol and leaves the primary guard first', () => {
9
9
  const guarded = openProtocol(route('guarded', '/guarded'), { guards: 'auth' })
10
- const [decorated] = withAuthTokenCoguard([guarded])
10
+ const [decorated] = protocols(withAuthTokenCoguard({ guarded }))
11
11
 
12
12
  expect(decorated.guards).toEqual(['auth', GUARD_AUTH_TOKEN])
13
13
  expect(guarded.guards).toEqual(['auth'])
@@ -15,20 +15,20 @@ describe('@owlmeans/server-auth-token — the coguard', () => {
15
15
 
16
16
  test('leaves an unguarded protocol unchanged', () => {
17
17
  const open = openProtocol(route('open', '/open'))
18
- expect(withAuthTokenCoguard([open])[0]).toBe(open)
18
+ expect(protocols(withAuthTokenCoguard({ open }))[0]).toBe(open)
19
19
  })
20
20
 
21
21
  test('is idempotent', () => {
22
22
  const guarded = openProtocol(route('guarded', '/guarded'), { guards: 'auth' })
23
- const [once] = withAuthTokenCoguard([guarded])
24
- const [twice] = withAuthTokenCoguard([once])
23
+ const [once] = protocols(withAuthTokenCoguard({ guarded }))
24
+ const [twice] = protocols(withAuthTokenCoguard({ once }))
25
25
 
26
26
  expect(twice.guards).toEqual(['auth', GUARD_AUTH_TOKEN])
27
27
  })
28
28
 
29
29
  test('honours a custom guard alias', () => {
30
30
  const guarded = openProtocol(route('guarded', '/guarded'), { guards: 'auth' })
31
- expect(withAuthTokenCoguard([guarded], 'other-guard')[0].guards)
31
+ expect(protocols(withAuthTokenCoguard({ guarded }, 'other-guard'))[0].guards)
32
32
  .toEqual(['auth', 'other-guard'])
33
33
  })
34
34
  })