@ontrails/permits 1.0.0-beta.14 → 1.0.0-beta.15
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/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +7 -0
- package/README.md +14 -14
- package/dist/auth-layer.d.ts +3 -3
- package/dist/auth-layer.js +3 -3
- package/dist/auth-resource.d.ts +11 -0
- package/dist/auth-resource.d.ts.map +1 -0
- package/dist/{auth-provision.js → auth-resource.js} +5 -5
- package/dist/auth-resource.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/permit.d.ts +2 -2
- package/dist/permit.js +2 -2
- package/dist/rules.d.ts +2 -2
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js.map +1 -1
- package/dist/testing.d.ts +4 -4
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +5 -5
- package/dist/testing.js.map +1 -1
- package/dist/trails/auth-verify.d.ts +2 -2
- package/dist/trails/auth-verify.d.ts.map +1 -1
- package/dist/trails/auth-verify.js +4 -4
- package/dist/trails/auth-verify.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/{auth-gate.test.ts → auth-layer.test.ts} +11 -11
- package/src/__tests__/{auth-provision.test.ts → auth-resource.test.ts} +9 -9
- package/src/__tests__/auth-verify.test.ts +7 -7
- package/src/__tests__/permit.test.ts +1 -1
- package/src/__tests__/testing.test.ts +13 -13
- package/src/{auth-gate.ts → auth-layer.ts} +9 -9
- package/src/{auth-provision.ts → auth-resource.ts} +4 -4
- package/src/index.ts +3 -3
- package/src/permit.ts +2 -2
- package/src/rules.ts +2 -2
- package/src/testing.ts +5 -5
- package/src/trails/auth-verify.ts +4 -4
- package/tsconfig.tests.json +10 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/adapter.d.ts +0 -26
- package/dist/adapter.d.ts.map +0 -1
- package/dist/adapter.js +0 -2
- package/dist/adapter.js.map +0 -1
- package/dist/adapters/jwt.d.ts +0 -25
- package/dist/adapters/jwt.d.ts.map +0 -1
- package/dist/adapters/jwt.js +0 -148
- package/dist/adapters/jwt.js.map +0 -1
- package/dist/auth-gate.d.ts +0 -18
- package/dist/auth-gate.d.ts.map +0 -1
- package/dist/auth-gate.js +0 -56
- package/dist/auth-gate.js.map +0 -1
- package/dist/auth-provision.d.ts +0 -11
- package/dist/auth-provision.d.ts.map +0 -1
- package/dist/auth-provision.js.map +0 -1
- package/dist/auth-service.d.ts +0 -10
- package/dist/auth-service.d.ts.map +0 -1
- package/dist/auth-service.js +0 -21
- package/dist/auth-service.js.map +0 -1
package/.turbo/turbo-lint.log
CHANGED
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Scope-based authorization for Trails.
|
|
4
4
|
|
|
5
|
-
The permits package owns the connector-agnostic `
|
|
5
|
+
The permits package owns the connector-agnostic `authResource` and `authLayer`. Connector packages bind those declarations to concrete auth logic, just like a surface connector binds a topo to CLI, MCP, or HTTP.
|
|
6
6
|
|
|
7
7
|
## The core pattern
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ The permits package owns the connector-agnostic `authProvision` and `authGate`.
|
|
|
12
12
|
export const create = trail('gist.create', {
|
|
13
13
|
permit: { scopes: ['gist:write'] },
|
|
14
14
|
blaze: async (input, ctx) => {
|
|
15
|
-
//
|
|
15
|
+
// authLayer enforces scopes before blaze runs
|
|
16
16
|
return Result.ok(newGist);
|
|
17
17
|
},
|
|
18
18
|
});
|
|
@@ -26,19 +26,19 @@ export const search = trail('gist.search', {
|
|
|
26
26
|
});
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
### 2. Register the auth
|
|
29
|
+
### 2. Register the auth layer
|
|
30
30
|
|
|
31
31
|
```typescript
|
|
32
|
-
import {
|
|
32
|
+
import { authLayer } from '@ontrails/permits';
|
|
33
33
|
|
|
34
|
-
export const
|
|
35
|
-
// Register
|
|
34
|
+
export const graph = topo('my-app', gistModule);
|
|
35
|
+
// Register authLayer with your surface
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
The
|
|
38
|
+
The layer reads each trail's `permit` field:
|
|
39
39
|
|
|
40
|
-
- `'public'` or `undefined` —
|
|
41
|
-
- `{ scopes: [...] }` —
|
|
40
|
+
- `'public'` or `undefined` — layer passes through
|
|
41
|
+
- `{ scopes: [...] }` — layer checks that `ctx.permit` contains all required scopes
|
|
42
42
|
|
|
43
43
|
### 3. Bind a connector at bootstrap
|
|
44
44
|
|
|
@@ -135,19 +135,19 @@ import { authVerify } from '@ontrails/permits';
|
|
|
135
135
|
|
|
136
136
|
## Testing with mock permits
|
|
137
137
|
|
|
138
|
-
Use `
|
|
138
|
+
Use `createTestPermit()` and `createPermitForTrail()` in tests:
|
|
139
139
|
|
|
140
140
|
```typescript
|
|
141
|
-
import {
|
|
141
|
+
import { createTestPermit, createPermitForTrail } from '@ontrails/permits';
|
|
142
142
|
|
|
143
|
-
const permit =
|
|
143
|
+
const permit = createTestPermit({
|
|
144
144
|
id: 'user-123',
|
|
145
145
|
scopes: ['gist:read', 'gist:write'],
|
|
146
146
|
roles: ['editor'],
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
//
|
|
150
|
-
const trailPermit =
|
|
149
|
+
// Create a permit matching a trail's requirements
|
|
150
|
+
const trailPermit = createPermitForTrail(myTrail);
|
|
151
151
|
// { id: 'test-...', scopes: ['gist:write'] }
|
|
152
152
|
```
|
|
153
153
|
|
package/dist/auth-layer.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ import type { Layer } from '@ontrails/core';
|
|
|
9
9
|
* all required scopes. A superset is fine; missing scopes produce a
|
|
10
10
|
* `PermitError`.
|
|
11
11
|
*
|
|
12
|
-
* Because `ctx.
|
|
13
|
-
* this layer automatically re-checks on every invocation in a
|
|
14
|
-
* No special
|
|
12
|
+
* Because `ctx.cross()` re-enters `executeTrail` (which applies layers),
|
|
13
|
+
* this layer automatically re-checks on every invocation in a crossing chain.
|
|
14
|
+
* No special crossing-chain handling is needed — it is built into the
|
|
15
15
|
* architecture.
|
|
16
16
|
*/
|
|
17
17
|
export declare const authLayer: Layer;
|
package/dist/auth-layer.js
CHANGED
|
@@ -25,9 +25,9 @@ const findMissing = (required, held) => required.filter((s) => !held.includes(s)
|
|
|
25
25
|
* all required scopes. A superset is fine; missing scopes produce a
|
|
26
26
|
* `PermitError`.
|
|
27
27
|
*
|
|
28
|
-
* Because `ctx.
|
|
29
|
-
* this layer automatically re-checks on every invocation in a
|
|
30
|
-
* No special
|
|
28
|
+
* Because `ctx.cross()` re-enters `executeTrail` (which applies layers),
|
|
29
|
+
* this layer automatically re-checks on every invocation in a crossing chain.
|
|
30
|
+
* No special crossing-chain handling is needed — it is built into the
|
|
31
31
|
* architecture.
|
|
32
32
|
*/
|
|
33
33
|
export const authLayer = {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AuthConnector } from './connectors/connector.js';
|
|
2
|
+
/**
|
|
3
|
+
* Auth resource — manages the auth connector lifecycle.
|
|
4
|
+
*
|
|
5
|
+
* The v1 factory returns a no-op connector that always succeeds (null permit).
|
|
6
|
+
* Real connector configuration will come through `ResourceSpec.config`
|
|
7
|
+
* (TRL-91). The mock factory provides a synthetic connector that always
|
|
8
|
+
* succeeds.
|
|
9
|
+
*/
|
|
10
|
+
export declare const authResource: import("@ontrails/core").Resource<AuthConnector>;
|
|
11
|
+
//# sourceMappingURL=auth-resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-resource.d.ts","sourceRoot":"","sources":["../src/auth-resource.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,kDAavB,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Result,
|
|
1
|
+
import { Result, resource } from '@ontrails/core';
|
|
2
2
|
/**
|
|
3
|
-
* Auth
|
|
3
|
+
* Auth resource — manages the auth connector lifecycle.
|
|
4
4
|
*
|
|
5
5
|
* The v1 factory returns a no-op connector that always succeeds (null permit).
|
|
6
|
-
* Real connector configuration will come through `
|
|
6
|
+
* Real connector configuration will come through `ResourceSpec.config`
|
|
7
7
|
* (TRL-91). The mock factory provides a synthetic connector that always
|
|
8
8
|
* succeeds.
|
|
9
9
|
*/
|
|
10
|
-
export const
|
|
10
|
+
export const authResource = resource('auth', {
|
|
11
11
|
create: (_svc) => Result.ok({
|
|
12
12
|
// oxlint-disable-next-line require-await -- stub connector satisfies async interface
|
|
13
13
|
authenticate: async () => Result.ok(null),
|
|
@@ -19,4 +19,4 @@ export const authProvision = provision('auth', {
|
|
|
19
19
|
authenticate: async () => Result.ok(null),
|
|
20
20
|
}),
|
|
21
21
|
});
|
|
22
|
-
//# sourceMappingURL=auth-
|
|
22
|
+
//# sourceMappingURL=auth-resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-resource.js","sourceRoot":"","sources":["../src/auth-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAIlD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAgB,MAAM,EAAE;IAC1D,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CACf,MAAM,CAAC,EAAE,CAAC;QACR,qFAAqF;QACrF,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;KAClB,CAAC;IAC5B,WAAW,EAAE,0BAA0B;IACvC,IAAI,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE;IACpC,IAAI,EAAE,GAAG,EAAE,CACT,CAAC;QACC,qFAAqF;QACrF,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;KAC1C,CAAyB;CAC7B,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { type AuthConnector, type AuthCredentials, type AuthError, } from './connectors/connector.js';
|
|
2
2
|
export { createJwtConnector, type JwtConnectorOptions, } from './connectors/jwt.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { authLayer } from './auth-layer.js';
|
|
4
|
+
export { authResource } from './auth-resource.js';
|
|
5
5
|
export { authVerify } from './trails/auth-verify.js';
|
|
6
6
|
export { PermitError } from './errors.js';
|
|
7
7
|
export { type PermitExtractionInput } from './extraction.js';
|
|
8
8
|
export { type Permit, getPermit } from './permit.js';
|
|
9
9
|
export { validatePermits, type PermitDiagnostic } from './rules.js';
|
|
10
|
-
export {
|
|
10
|
+
export { createTestPermit, createPermitForTrail } from './testing.js';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,SAAS,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,SAAS,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,KAAK,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export {} from './connectors/connector.js';
|
|
2
2
|
export { createJwtConnector, } from './connectors/jwt.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { authLayer } from './auth-layer.js';
|
|
4
|
+
export { authResource } from './auth-resource.js';
|
|
5
5
|
export { authVerify } from './trails/auth-verify.js';
|
|
6
6
|
export { PermitError } from './errors.js';
|
|
7
7
|
export {} from './extraction.js';
|
|
8
8
|
export { getPermit } from './permit.js';
|
|
9
9
|
export { validatePermits } from './rules.js';
|
|
10
|
-
export {
|
|
10
|
+
export { createTestPermit, createPermitForTrail } from './testing.js';
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,kBAAkB,GAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,kBAAkB,GAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAA8B,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAe,SAAS,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,eAAe,EAAyB,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/permit.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export interface Permit extends BasePermit {
|
|
|
9
9
|
* Type-safe accessor for `ctx.permit` with a downcast to `Permit`.
|
|
10
10
|
*
|
|
11
11
|
* `TrailContext.permit` is typed as `BasePermit` (id + scopes). This accessor
|
|
12
|
-
* returns the full `Permit` when the auth
|
|
13
|
-
* the auth
|
|
12
|
+
* returns the full `Permit` when the auth layer has set one. Safe because
|
|
13
|
+
* the auth layer is the only writer and always sets a full `Permit`.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```typescript
|
package/dist/permit.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Type-safe accessor for `ctx.permit` with a downcast to `Permit`.
|
|
3
3
|
*
|
|
4
4
|
* `TrailContext.permit` is typed as `BasePermit` (id + scopes). This accessor
|
|
5
|
-
* returns the full `Permit` when the auth
|
|
6
|
-
* the auth
|
|
5
|
+
* returns the full `Permit` when the auth layer has set one. Safe because
|
|
6
|
+
* the auth layer is the only writer and always sets a full `Permit`.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
package/dist/rules.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface PermitDiagnostic {
|
|
|
6
6
|
readonly severity: 'error' | 'warning';
|
|
7
7
|
readonly message: string;
|
|
8
8
|
}
|
|
9
|
-
type AnyTrail = Trail<unknown, unknown>;
|
|
9
|
+
type AnyTrail = Trail<unknown, unknown, unknown>;
|
|
10
10
|
type Rule = (trails: readonly AnyTrail[]) => readonly PermitDiagnostic[];
|
|
11
11
|
/**
|
|
12
12
|
* Destructive trails without a real permit declaration are a governance failure.
|
|
@@ -42,6 +42,6 @@ export declare const orphanScopeDetection: Rule;
|
|
|
42
42
|
* Returns a flat array of diagnostics from every rule. An empty array
|
|
43
43
|
* means the topo passes all permit governance checks.
|
|
44
44
|
*/
|
|
45
|
-
export declare const validatePermits: (trails: readonly Trail<unknown, unknown>[]) => readonly PermitDiagnostic[];
|
|
45
|
+
export declare const validatePermits: (trails: readonly Trail<unknown, unknown, unknown>[]) => readonly PermitDiagnostic[];
|
|
46
46
|
export {};
|
|
47
47
|
//# sourceMappingURL=rules.d.ts.map
|
package/dist/rules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAM5C,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAMD,KAAK,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAM5C,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,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GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB;IAClF,IAAI,EAAE,sBAAsB;IAC5B,QAAQ,EAAE,SAAkB;IAC5B,OAAO,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;CAC3B,CAAC,CAAC,CAAC;AAER;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAS,CAAC,MAAM,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,iBAAiB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,MAAM,QAAQ,GAAoB;IAChC,oBAAoB;IACpB,kBAAkB;IAClB,sBAAsB;IACtB,oBAAoB;CACrB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,MAAmD,EACtB,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { PermitRequirement } from '@ontrails/core';
|
|
2
2
|
import type { Permit } from './permit.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Create a synthetic test permit with exactly the declared scopes.
|
|
5
5
|
* No admin permit, no wildcard — tests get only what the trail declares.
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const createTestPermit: (options?: {
|
|
8
8
|
readonly id?: string;
|
|
9
9
|
readonly scopes?: readonly string[];
|
|
10
10
|
readonly roles?: readonly string[];
|
|
@@ -12,9 +12,9 @@ export declare const mintTestPermit: (options?: {
|
|
|
12
12
|
}) => Permit;
|
|
13
13
|
/**
|
|
14
14
|
* Create a test permit matching a trail's permit requirement.
|
|
15
|
-
* Extracts scopes from the requirement and
|
|
15
|
+
* Extracts scopes from the requirement and creates a permit with exactly those scopes.
|
|
16
16
|
*/
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const createPermitForTrail: (trail: {
|
|
18
18
|
readonly permit?: PermitRequirement | undefined;
|
|
19
19
|
}) => Permit | undefined;
|
|
20
20
|
//# sourceMappingURL=testing.d.ts.map
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,UAAU;IACzC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,KAAG,MAOF,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;CACjD,KAAG,MAAM,GAAG,SAKZ,CAAC"}
|
package/dist/testing.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Create a synthetic test permit with exactly the declared scopes.
|
|
3
3
|
* No admin permit, no wildcard — tests get only what the trail declares.
|
|
4
4
|
*/
|
|
5
|
-
export const
|
|
5
|
+
export const createTestPermit = (options) => ({
|
|
6
6
|
id: options?.id ??
|
|
7
7
|
`test-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
8
8
|
scopes: [...(options?.scopes ?? [])],
|
|
@@ -11,12 +11,12 @@ export const mintTestPermit = (options) => ({
|
|
|
11
11
|
});
|
|
12
12
|
/**
|
|
13
13
|
* Create a test permit matching a trail's permit requirement.
|
|
14
|
-
* Extracts scopes from the requirement and
|
|
14
|
+
* Extracts scopes from the requirement and creates a permit with exactly those scopes.
|
|
15
15
|
*/
|
|
16
|
-
export const
|
|
16
|
+
export const createPermitForTrail = (trail) => {
|
|
17
17
|
if (!trail.permit || trail.permit === 'public') {
|
|
18
18
|
return undefined;
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return createTestPermit({ scopes: trail.permit.scopes });
|
|
21
21
|
};
|
|
22
22
|
//# sourceMappingURL=testing.js.map
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAKhC,EAAU,EAAE,CAAC,CAAC;IACb,EAAE,EACA,OAAO,EAAE,EAAE;QACX,QAAQ,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;IAChE,MAAM,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC;IACpC,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;IACtE,GAAG,CAAC,OAAO,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;CAC3E,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAEpC,EAAsB,EAAE;IACvB,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,gBAAgB,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAC3D,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Infrastructure trail that verifies a bearer token and returns the resolved permit.
|
|
3
3
|
*
|
|
4
|
-
* Reads the auth connector from `
|
|
4
|
+
* Reads the auth connector from `authResource` — the connector is configured
|
|
5
5
|
* at bootstrap (e.g. JWT with HMAC secret). The mock connector always
|
|
6
6
|
* succeeds with a null permit, so `testAll(app)` works without configuration.
|
|
7
7
|
*/
|
|
@@ -18,5 +18,5 @@ export declare const authVerify: import("@ontrails/core").Trail<{
|
|
|
18
18
|
roles?: string[] | undefined;
|
|
19
19
|
tenantId?: string | undefined;
|
|
20
20
|
} | undefined;
|
|
21
|
-
}>;
|
|
21
|
+
}, never>;
|
|
22
22
|
//# sourceMappingURL=auth-verify.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-verify.d.ts","sourceRoot":"","sources":["../../src/trails/auth-verify.ts"],"names":[],"mappings":"AA4CA;;;;;;GAMG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"auth-verify.d.ts","sourceRoot":"","sources":["../../src/trails/auth-verify.ts"],"names":[],"mappings":"AA4CA;;;;;;GAMG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;SAiDrB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result, TRAILHEAD_KEY, trail } from '@ontrails/core';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { authResource } from '../auth-resource.js';
|
|
4
4
|
const permitSchema = z.object({
|
|
5
5
|
id: z.string(),
|
|
6
6
|
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
@@ -31,13 +31,13 @@ const getTrailhead = (ctx) => {
|
|
|
31
31
|
/**
|
|
32
32
|
* Infrastructure trail that verifies a bearer token and returns the resolved permit.
|
|
33
33
|
*
|
|
34
|
-
* Reads the auth connector from `
|
|
34
|
+
* Reads the auth connector from `authResource` — the connector is configured
|
|
35
35
|
* at bootstrap (e.g. JWT with HMAC secret). The mock connector always
|
|
36
36
|
* succeeds with a null permit, so `testAll(app)` works without configuration.
|
|
37
37
|
*/
|
|
38
38
|
export const authVerify = trail('auth.verify', {
|
|
39
39
|
blaze: async (input, ctx) => {
|
|
40
|
-
const connector =
|
|
40
|
+
const connector = authResource.from(ctx);
|
|
41
41
|
const result = await connector.authenticate({
|
|
42
42
|
bearerToken: input.token,
|
|
43
43
|
requestId: ctx.requestId,
|
|
@@ -80,6 +80,6 @@ export const authVerify = trail('auth.verify', {
|
|
|
80
80
|
permit: permitSchema.optional(),
|
|
81
81
|
valid: z.boolean(),
|
|
82
82
|
}),
|
|
83
|
-
|
|
83
|
+
resources: [authResource],
|
|
84
84
|
});
|
|
85
85
|
//# sourceMappingURL=auth-verify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-verify.js","sourceRoot":"","sources":["../../src/trails/auth-verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"auth-verify.js","sourceRoot":"","sources":["../../src/trails/auth-verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IACtD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACrC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC;IACjC,eAAe;IACf,oBAAoB;IACpB,eAAe;IACf,qBAAqB;CACtB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC;IAC1C,GAAG,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS;QAC/B,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,CAAC,YAAY,CAAC;CAC1B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontrails/permits",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/index.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@ontrails/core": "^1.0.0-beta.
|
|
18
|
+
"@ontrails/core": "^1.0.0-beta.14",
|
|
19
19
|
"zod": "^4.3.5"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/* oxlint-disable require-await --
|
|
1
|
+
/* oxlint-disable require-await -- layer wrappers satisfy async interfaces without awaiting */
|
|
2
2
|
import { describe, expect, test } from 'bun:test';
|
|
3
3
|
|
|
4
4
|
import { Result, trail } from '@ontrails/core';
|
|
5
5
|
import type { TrailContext } from '@ontrails/core';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { authLayer } from '../auth-layer';
|
|
9
9
|
import { PermitError } from '../errors';
|
|
10
10
|
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
@@ -27,10 +27,10 @@ const okImpl = async () => Result.ok({ done: true });
|
|
|
27
27
|
// Tests
|
|
28
28
|
// ---------------------------------------------------------------------------
|
|
29
29
|
|
|
30
|
-
describe('
|
|
30
|
+
describe('authLayer', () => {
|
|
31
31
|
test('has correct name and description', () => {
|
|
32
|
-
expect(
|
|
33
|
-
expect(
|
|
32
|
+
expect(authLayer.name).toBe('auth');
|
|
33
|
+
expect(authLayer.description).toBeDefined();
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
describe('pass-through cases', () => {
|
|
@@ -41,7 +41,7 @@ describe('authGate', () => {
|
|
|
41
41
|
output: z.object({ done: z.boolean() }),
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
const wrapped =
|
|
44
|
+
const wrapped = authLayer.wrap(t, okImpl);
|
|
45
45
|
const result = await wrapped({}, makeCtx());
|
|
46
46
|
|
|
47
47
|
expect(result.isOk()).toBe(true);
|
|
@@ -56,7 +56,7 @@ describe('authGate', () => {
|
|
|
56
56
|
permit: 'public',
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
const wrapped =
|
|
59
|
+
const wrapped = authLayer.wrap(t, okImpl);
|
|
60
60
|
const result = await wrapped({}, makeCtx());
|
|
61
61
|
|
|
62
62
|
expect(result.isOk()).toBe(true);
|
|
@@ -73,7 +73,7 @@ describe('authGate', () => {
|
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
test('passes when ctx.permit has matching scopes', async () => {
|
|
76
|
-
const wrapped =
|
|
76
|
+
const wrapped = authLayer.wrap(scopedTrail, okImpl);
|
|
77
77
|
const result = await wrapped(
|
|
78
78
|
{},
|
|
79
79
|
makeCtx({ id: 'usr-1', scopes: ['user:read'] })
|
|
@@ -84,7 +84,7 @@ describe('authGate', () => {
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
test('returns error when ctx has no permit', async () => {
|
|
87
|
-
const wrapped =
|
|
87
|
+
const wrapped = authLayer.wrap(scopedTrail, okImpl);
|
|
88
88
|
const result = await wrapped({}, makeCtx());
|
|
89
89
|
|
|
90
90
|
expect(result.isErr()).toBe(true);
|
|
@@ -101,7 +101,7 @@ describe('authGate', () => {
|
|
|
101
101
|
permit: { scopes: ['user:read', 'user:write'] },
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
-
const wrapped =
|
|
104
|
+
const wrapped = authLayer.wrap(multiScopeTrail, okImpl);
|
|
105
105
|
const result = await wrapped(
|
|
106
106
|
{},
|
|
107
107
|
makeCtx({ id: 'usr-1', scopes: ['user:read'] })
|
|
@@ -114,7 +114,7 @@ describe('authGate', () => {
|
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
test('passes when permit has superset of required scopes', async () => {
|
|
117
|
-
const wrapped =
|
|
117
|
+
const wrapped = authLayer.wrap(scopedTrail, okImpl);
|
|
118
118
|
const result = await wrapped(
|
|
119
119
|
{},
|
|
120
120
|
makeCtx({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { describe, expect, test } from 'bun:test';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { ResourceContext } from '@ontrails/core';
|
|
4
4
|
|
|
5
5
|
import type { AuthConnector } from '../connectors/connector.js';
|
|
6
|
-
import {
|
|
6
|
+
import { authResource } from '../auth-resource.js';
|
|
7
7
|
import type { PermitExtractionInput } from '../extraction.js';
|
|
8
8
|
|
|
9
9
|
/** Minimal extraction input for tests. */
|
|
@@ -19,7 +19,7 @@ const testInput = (
|
|
|
19
19
|
// Helpers
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
21
21
|
|
|
22
|
-
const testSvcCtx:
|
|
22
|
+
const testSvcCtx: ResourceContext = {
|
|
23
23
|
config: undefined,
|
|
24
24
|
cwd: '/tmp',
|
|
25
25
|
env: {},
|
|
@@ -30,18 +30,18 @@ const testSvcCtx: ProvisionContext = {
|
|
|
30
30
|
// Tests
|
|
31
31
|
// ---------------------------------------------------------------------------
|
|
32
32
|
|
|
33
|
-
describe('
|
|
33
|
+
describe('authResource', () => {
|
|
34
34
|
test('has correct id and kind', () => {
|
|
35
|
-
expect(
|
|
36
|
-
expect(
|
|
35
|
+
expect(authResource.id).toBe('auth');
|
|
36
|
+
expect(authResource.kind).toBe('resource');
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
test('has infrastructure meta', () => {
|
|
40
|
-
expect(
|
|
40
|
+
expect(authResource.meta).toEqual({ category: 'infrastructure' });
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
test('mock returns an AuthConnector', async () => {
|
|
44
|
-
const mock =
|
|
44
|
+
const mock = authResource.mock?.();
|
|
45
45
|
expect(mock).toBeDefined();
|
|
46
46
|
|
|
47
47
|
const connector = mock as AuthConnector;
|
|
@@ -51,7 +51,7 @@ describe('authProvision', () => {
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
test('create returns Result.ok with an AuthConnector', async () => {
|
|
54
|
-
const result = await
|
|
54
|
+
const result = await authResource.create(testSvcCtx);
|
|
55
55
|
expect(result.isOk()).toBe(true);
|
|
56
56
|
|
|
57
57
|
const connector = result.unwrap() as AuthConnector;
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@ontrails/core';
|
|
9
9
|
|
|
10
10
|
import type { AuthConnector } from '../connectors/connector.js';
|
|
11
|
-
import {
|
|
11
|
+
import { authResource } from '../auth-resource.js';
|
|
12
12
|
import { createJwtConnector } from '../connectors/jwt.js';
|
|
13
13
|
import type { Permit } from '../permit.js';
|
|
14
14
|
import { authVerify } from '../trails/auth-verify.js';
|
|
@@ -59,7 +59,7 @@ const TEST_SECRET = 'test-secret-for-hmac-256';
|
|
|
59
59
|
const jwtConnector = (): AuthConnector =>
|
|
60
60
|
createJwtConnector({ secret: TEST_SECRET });
|
|
61
61
|
|
|
62
|
-
/** Execute auth.verify with a given connector injected as the auth
|
|
62
|
+
/** Execute auth.verify with a given connector injected as the auth resource. */
|
|
63
63
|
const runVerify = async (
|
|
64
64
|
token: string,
|
|
65
65
|
connector: AuthConnector,
|
|
@@ -95,7 +95,7 @@ const runVerify = async (
|
|
|
95
95
|
options?.trailhead === undefined
|
|
96
96
|
? undefined
|
|
97
97
|
: { extensions: { [TRAILHEAD_KEY]: options.trailhead } },
|
|
98
|
-
|
|
98
|
+
resources: { [authResource.id]: connector },
|
|
99
99
|
}
|
|
100
100
|
);
|
|
101
101
|
return result as Result<
|
|
@@ -134,9 +134,9 @@ describe('auth.verify trail', () => {
|
|
|
134
134
|
expect(authVerify.examples?.length).toBeGreaterThan(0);
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
test('declares
|
|
138
|
-
expect(authVerify.
|
|
139
|
-
expect(authVerify.
|
|
137
|
+
test('declares authResource dependency', () => {
|
|
138
|
+
expect(authVerify.resources).toHaveLength(1);
|
|
139
|
+
expect(authVerify.resources[0]?.id).toBe('auth');
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
|
|
@@ -267,7 +267,7 @@ describe('auth.verify trail', () => {
|
|
|
267
267
|
authVerify,
|
|
268
268
|
{ token: '' },
|
|
269
269
|
{
|
|
270
|
-
|
|
270
|
+
resources: { [authResource.id]: jwtConnector() },
|
|
271
271
|
}
|
|
272
272
|
);
|
|
273
273
|
|
|
@@ -60,7 +60,7 @@ describe('getPermit()', () => {
|
|
|
60
60
|
expect(result).toBeUndefined();
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
test('preserves extended permit fields from the auth
|
|
63
|
+
test('preserves extended permit fields from the auth layer', () => {
|
|
64
64
|
const ctx = {
|
|
65
65
|
permit: {
|
|
66
66
|
id: 'usr_2',
|