@ontrails/permits 1.0.0-beta.13 → 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 +18 -0
- package/README.md +175 -0
- 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-resource.js +22 -0
- package/dist/auth-resource.js.map +1 -0
- package/dist/{adapter.d.ts → connectors/connector.d.ts} +8 -8
- package/dist/connectors/connector.d.ts.map +1 -0
- package/dist/connectors/connector.js +2 -0
- package/dist/connectors/connector.js.map +1 -0
- package/dist/{adapters → connectors}/jwt.d.ts +5 -5
- package/dist/connectors/jwt.d.ts.map +1 -0
- package/dist/{adapters → connectors}/jwt.js +2 -2
- package/dist/connectors/jwt.js.map +1 -0
- package/dist/extraction.d.ts +6 -6
- package/dist/extraction.d.ts.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- 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 +4 -4
- package/dist/trails/auth-verify.d.ts.map +1 -1
- package/dist/trails/auth-verify.js +31 -31
- 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.map +0 -1
- package/dist/adapter.js +0 -2
- package/dist/adapter.js.map +0 -1
- package/dist/adapters/jwt.d.ts.map +0 -1
- package/dist/adapters/jwt.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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Result,
|
|
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(),
|
|
@@ -23,42 +23,25 @@ const toOutputPermit = (permit) => ({
|
|
|
23
23
|
id: permit.id,
|
|
24
24
|
scopes: [...permit.scopes],
|
|
25
25
|
});
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
return
|
|
26
|
+
const isTrailhead = (value) => value === 'http' || value === 'mcp' || value === 'cli';
|
|
27
|
+
const getTrailhead = (ctx) => {
|
|
28
|
+
const trailhead = ctx.extensions?.[TRAILHEAD_KEY];
|
|
29
|
+
return isTrailhead(trailhead) ? trailhead : 'http';
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Infrastructure trail that verifies a bearer token and returns the resolved permit.
|
|
33
33
|
*
|
|
34
|
-
* Reads the auth
|
|
35
|
-
* bootstrap (e.g. JWT with HMAC secret). The mock
|
|
36
|
-
* a null permit, so `testAll(app)` works without configuration.
|
|
34
|
+
* Reads the auth connector from `authResource` — the connector is configured
|
|
35
|
+
* at bootstrap (e.g. JWT with HMAC secret). The mock connector always
|
|
36
|
+
* succeeds with a null permit, so `testAll(app)` works without configuration.
|
|
37
37
|
*/
|
|
38
38
|
export const authVerify = trail('auth.verify', {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
name: 'Verify a token',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
input: z.object({
|
|
46
|
-
token: z.string().min(1).describe('Bearer token to verify'),
|
|
47
|
-
}),
|
|
48
|
-
intent: 'read',
|
|
49
|
-
metadata: { category: 'infrastructure' },
|
|
50
|
-
output: z.object({
|
|
51
|
-
error: z.string().optional(),
|
|
52
|
-
errorCode: authErrorCodeSchema.optional(),
|
|
53
|
-
permit: permitSchema.optional(),
|
|
54
|
-
valid: z.boolean(),
|
|
55
|
-
}),
|
|
56
|
-
run: async (input, ctx) => {
|
|
57
|
-
const adapter = authService.from(ctx);
|
|
58
|
-
const result = await adapter.authenticate({
|
|
39
|
+
blaze: async (input, ctx) => {
|
|
40
|
+
const connector = authResource.from(ctx);
|
|
41
|
+
const result = await connector.authenticate({
|
|
59
42
|
bearerToken: input.token,
|
|
60
43
|
requestId: ctx.requestId,
|
|
61
|
-
|
|
44
|
+
trailhead: getTrailhead(ctx),
|
|
62
45
|
});
|
|
63
46
|
if (result.isErr()) {
|
|
64
47
|
return Result.ok({
|
|
@@ -80,6 +63,23 @@ export const authVerify = trail('auth.verify', {
|
|
|
80
63
|
valid: true,
|
|
81
64
|
});
|
|
82
65
|
},
|
|
83
|
-
|
|
66
|
+
examples: [
|
|
67
|
+
{
|
|
68
|
+
input: { token: 'test-token' },
|
|
69
|
+
name: 'Verify a token',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
input: z.object({
|
|
73
|
+
token: z.string().min(1).describe('Bearer token to verify'),
|
|
74
|
+
}),
|
|
75
|
+
intent: 'read',
|
|
76
|
+
meta: { category: 'infrastructure' },
|
|
77
|
+
output: z.object({
|
|
78
|
+
error: z.string().optional(),
|
|
79
|
+
errorCode: authErrorCodeSchema.optional(),
|
|
80
|
+
permit: permitSchema.optional(),
|
|
81
|
+
valid: z.boolean(),
|
|
82
|
+
}),
|
|
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,
|
|
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,E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AE;QAC/B,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE;KACnB,CAAC;IACF,SAAS,EAAE,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',
|
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import { describe, expect, test } from 'bun:test';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { createPermitForTrail, createTestPermit } from '../testing';
|
|
4
4
|
|
|
5
|
-
describe('
|
|
5
|
+
describe('createTestPermit()', () => {
|
|
6
6
|
test('returns a Permit with the given scopes', () => {
|
|
7
|
-
const permit =
|
|
7
|
+
const permit = createTestPermit({ scopes: ['user:read', 'user:write'] });
|
|
8
8
|
expect(permit.scopes).toEqual(['user:read', 'user:write']);
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
test('generates a unique id when not specified', () => {
|
|
12
|
-
const a =
|
|
13
|
-
const b =
|
|
12
|
+
const a = createTestPermit();
|
|
13
|
+
const b = createTestPermit();
|
|
14
14
|
expect(a.id).not.toBe(b.id);
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
test('uses the provided id when specified', () => {
|
|
18
|
-
const permit =
|
|
18
|
+
const permit = createTestPermit({ id: 'custom-id' });
|
|
19
19
|
expect(permit.id).toBe('custom-id');
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
test('returns empty scopes when no options provided', () => {
|
|
23
|
-
const permit =
|
|
23
|
+
const permit = createTestPermit();
|
|
24
24
|
expect(permit.scopes).toEqual([]);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
test('includes roles when provided', () => {
|
|
28
|
-
const permit =
|
|
28
|
+
const permit = createTestPermit({ roles: ['admin', 'editor'] });
|
|
29
29
|
expect(permit.roles).toEqual(['admin', 'editor']);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
test('includes tenantId when provided', () => {
|
|
33
|
-
const permit =
|
|
33
|
+
const permit = createTestPermit({ tenantId: 'tenant_abc' });
|
|
34
34
|
expect(permit.tenantId).toBe('tenant_abc');
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
describe('
|
|
38
|
+
describe('createPermitForTrail()', () => {
|
|
39
39
|
test('extracts scopes from trail permit requirement', () => {
|
|
40
40
|
const trail = { permit: { scopes: ['entity:read', 'entity:write'] } };
|
|
41
|
-
const permit =
|
|
41
|
+
const permit = createPermitForTrail(trail);
|
|
42
42
|
expect(permit).toBeDefined();
|
|
43
43
|
expect(permit?.scopes).toEqual(['entity:read', 'entity:write']);
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
test('returns undefined for public trails', () => {
|
|
47
47
|
const trail = { permit: 'public' as const };
|
|
48
|
-
const permit =
|
|
48
|
+
const permit = createPermitForTrail(trail);
|
|
49
49
|
expect(permit).toBeUndefined();
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
test('returns undefined when no permit declared', () => {
|
|
53
53
|
const trail = {};
|
|
54
|
-
const permit =
|
|
54
|
+
const permit = createPermitForTrail(trail);
|
|
55
55
|
expect(permit).toBeUndefined();
|
|
56
56
|
});
|
|
57
57
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Result } from '@ontrails/core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Layer } from '@ontrails/core';
|
|
3
3
|
|
|
4
4
|
import { PermitError } from './errors.js';
|
|
5
5
|
import { getPermit } from './permit.js';
|
|
@@ -25,25 +25,25 @@ const findMissing = (
|
|
|
25
25
|
): readonly string[] => required.filter((s) => !held.includes(s));
|
|
26
26
|
|
|
27
27
|
// ---------------------------------------------------------------------------
|
|
28
|
-
// Auth
|
|
28
|
+
// Auth layer
|
|
29
29
|
// ---------------------------------------------------------------------------
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* A {@link
|
|
32
|
+
* A {@link Layer} that enforces permit scopes declared on trails.
|
|
33
33
|
*
|
|
34
|
-
* The
|
|
34
|
+
* The layer reads the trail's `permit` field (a `PermitRequirement`):
|
|
35
35
|
*
|
|
36
|
-
* - If `permit` is `'public'` or `undefined` the
|
|
37
|
-
* - If `permit` has `scopes`, the
|
|
36
|
+
* - If `permit` is `'public'` or `undefined` the layer passes through.
|
|
37
|
+
* - If `permit` has `scopes`, the layer checks that `ctx.permit` contains
|
|
38
38
|
* all required scopes. A superset is fine; missing scopes produce a
|
|
39
39
|
* `PermitError`.
|
|
40
40
|
*
|
|
41
|
-
* Because `ctx.cross()` re-enters `executeTrail` (which applies
|
|
42
|
-
* this
|
|
41
|
+
* Because `ctx.cross()` re-enters `executeTrail` (which applies layers),
|
|
42
|
+
* this layer automatically re-checks on every invocation in a crossing chain.
|
|
43
43
|
* No special crossing-chain handling is needed — it is built into the
|
|
44
44
|
* architecture.
|
|
45
45
|
*/
|
|
46
|
-
export const
|
|
46
|
+
export const authLayer: Layer = {
|
|
47
47
|
description: 'Enforces permit scopes declared on trails',
|
|
48
48
|
name: 'auth',
|
|
49
49
|
wrap: (_trail, impl) => {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Result,
|
|
1
|
+
import { Result, resource } from '@ontrails/core';
|
|
2
2
|
|
|
3
3
|
import type { AuthConnector } from './connectors/connector.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Auth
|
|
6
|
+
* Auth resource — manages the auth connector lifecycle.
|
|
7
7
|
*
|
|
8
8
|
* The v1 factory returns a no-op connector that always succeeds (null permit).
|
|
9
|
-
* Real connector configuration will come through `
|
|
9
|
+
* Real connector configuration will come through `ResourceSpec.config`
|
|
10
10
|
* (TRL-91). The mock factory provides a synthetic connector that always
|
|
11
11
|
* succeeds.
|
|
12
12
|
*/
|
|
13
|
-
export const
|
|
13
|
+
export const authResource = resource<AuthConnector>('auth', {
|
|
14
14
|
create: (_svc) =>
|
|
15
15
|
Result.ok({
|
|
16
16
|
// oxlint-disable-next-line require-await -- stub connector satisfies async interface
|
package/src/index.ts
CHANGED
|
@@ -7,11 +7,11 @@ export {
|
|
|
7
7
|
createJwtConnector,
|
|
8
8
|
type JwtConnectorOptions,
|
|
9
9
|
} from './connectors/jwt.js';
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
10
|
+
export { authLayer } from './auth-layer.js';
|
|
11
|
+
export { authResource } from './auth-resource.js';
|
|
12
12
|
export { authVerify } from './trails/auth-verify.js';
|
|
13
13
|
export { PermitError } from './errors.js';
|
|
14
14
|
export { type PermitExtractionInput } from './extraction.js';
|
|
15
15
|
export { type Permit, getPermit } from './permit.js';
|
|
16
16
|
export { validatePermits, type PermitDiagnostic } from './rules.js';
|
|
17
|
-
export {
|
|
17
|
+
export { createTestPermit, createPermitForTrail } from './testing.js';
|
package/src/permit.ts
CHANGED
|
@@ -11,8 +11,8 @@ export interface Permit extends BasePermit {
|
|
|
11
11
|
* Type-safe accessor for `ctx.permit` with a downcast to `Permit`.
|
|
12
12
|
*
|
|
13
13
|
* `TrailContext.permit` is typed as `BasePermit` (id + scopes). This accessor
|
|
14
|
-
* returns the full `Permit` when the auth
|
|
15
|
-
* the auth
|
|
14
|
+
* returns the full `Permit` when the auth layer has set one. Safe because
|
|
15
|
+
* the auth layer is the only writer and always sets a full `Permit`.
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
package/src/rules.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface PermitDiagnostic {
|
|
|
16
16
|
// Helpers
|
|
17
17
|
// ---------------------------------------------------------------------------
|
|
18
18
|
|
|
19
|
-
type AnyTrail = Trail<unknown, unknown>;
|
|
19
|
+
type AnyTrail = Trail<unknown, unknown, unknown>;
|
|
20
20
|
type Rule = (trails: readonly AnyTrail[]) => readonly PermitDiagnostic[];
|
|
21
21
|
|
|
22
22
|
/** Check whether a trail has any permit declaration (scopes object or 'public'). */
|
|
@@ -179,5 +179,5 @@ const allRules: readonly Rule[] = [
|
|
|
179
179
|
* means the topo passes all permit governance checks.
|
|
180
180
|
*/
|
|
181
181
|
export const validatePermits = (
|
|
182
|
-
trails: readonly Trail<unknown, unknown>[]
|
|
182
|
+
trails: readonly Trail<unknown, unknown, unknown>[]
|
|
183
183
|
): readonly PermitDiagnostic[] => allRules.flatMap((rule) => rule(trails));
|
package/src/testing.ts
CHANGED
|
@@ -3,10 +3,10 @@ import type { PermitRequirement } from '@ontrails/core';
|
|
|
3
3
|
import type { Permit } from './permit.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Create a synthetic test permit with exactly the declared scopes.
|
|
7
7
|
* No admin permit, no wildcard — tests get only what the trail declares.
|
|
8
8
|
*/
|
|
9
|
-
export const
|
|
9
|
+
export const createTestPermit = (options?: {
|
|
10
10
|
readonly id?: string;
|
|
11
11
|
readonly scopes?: readonly string[];
|
|
12
12
|
readonly roles?: readonly string[];
|
|
@@ -22,13 +22,13 @@ export const mintTestPermit = (options?: {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Create a test permit matching a trail's permit requirement.
|
|
25
|
-
* Extracts scopes from the requirement and
|
|
25
|
+
* Extracts scopes from the requirement and creates a permit with exactly those scopes.
|
|
26
26
|
*/
|
|
27
|
-
export const
|
|
27
|
+
export const createPermitForTrail = (trail: {
|
|
28
28
|
readonly permit?: PermitRequirement | undefined;
|
|
29
29
|
}): Permit | undefined => {
|
|
30
30
|
if (!trail.permit || trail.permit === 'public') {
|
|
31
31
|
return undefined;
|
|
32
32
|
}
|
|
33
|
-
return
|
|
33
|
+
return createTestPermit({ scopes: trail.permit.scopes });
|
|
34
34
|
};
|
|
@@ -2,7 +2,7 @@ import { Result, TRAILHEAD_KEY, trail } from '@ontrails/core';
|
|
|
2
2
|
import type { TrailContext } from '@ontrails/core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { authResource } from '../auth-resource.js';
|
|
6
6
|
import type { PermitExtractionInput } from '../extraction.js';
|
|
7
7
|
import type { Permit } from '../permit.js';
|
|
8
8
|
|
|
@@ -45,13 +45,13 @@ const getTrailhead = (
|
|
|
45
45
|
/**
|
|
46
46
|
* Infrastructure trail that verifies a bearer token and returns the resolved permit.
|
|
47
47
|
*
|
|
48
|
-
* Reads the auth connector from `
|
|
48
|
+
* Reads the auth connector from `authResource` — the connector is configured
|
|
49
49
|
* at bootstrap (e.g. JWT with HMAC secret). The mock connector always
|
|
50
50
|
* succeeds with a null permit, so `testAll(app)` works without configuration.
|
|
51
51
|
*/
|
|
52
52
|
export const authVerify = trail('auth.verify', {
|
|
53
53
|
blaze: async (input, ctx) => {
|
|
54
|
-
const connector =
|
|
54
|
+
const connector = authResource.from(ctx);
|
|
55
55
|
const result = await connector.authenticate({
|
|
56
56
|
bearerToken: input.token,
|
|
57
57
|
requestId: ctx.requestId,
|
|
@@ -97,5 +97,5 @@ export const authVerify = trail('auth.verify', {
|
|
|
97
97
|
permit: permitSchema.optional(),
|
|
98
98
|
valid: z.boolean(),
|
|
99
99
|
}),
|
|
100
|
-
|
|
100
|
+
resources: [authResource],
|
|
101
101
|
});
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/
|
|
1
|
+
{"root":["./src/auth-layer.ts","./src/auth-resource.ts","./src/errors.ts","./src/extraction.ts","./src/index.ts","./src/permit.ts","./src/rules.ts","./src/testing.ts","./src/connectors/connector.ts","./src/connectors/jwt.ts","./src/trails/auth-verify.ts"],"version":"5.9.3"}
|
package/dist/adapter.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAEpD,iCAAiC;AACjC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EACT,eAAe,GACf,oBAAoB,GACpB,eAAe,GACf,qBAAqB,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,YAAY,EAAE,CACrB,KAAK,EAAE,qBAAqB,KACzB,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;CAChD"}
|
package/dist/adapter.js
DELETED
package/dist/adapter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/adapters/jwt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,eAAe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,EACnB,OAA0B,EACC,EAAE;IAC7B,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAA0B,EAAe,EAAE;IAC1E,MAAM,YAAY,GAAG,KAAK,EACxB,KAA4B,EACe,EAAE;QAC7C,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,OAAO,OAAO,CAAC,eAAe,EAAE,sBAAsB,CAAC,CAAC;QAC1D,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACzE,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC,CAAC;IAEF,OAAO,EAAE,YAAY,EAAE,CAAC;AAC1B,CAAC,CAAC"}
|
package/dist/auth-service.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AuthAdapter } from './adapter.js';
|
|
2
|
-
/**
|
|
3
|
-
* Auth service — manages the auth adapter lifecycle.
|
|
4
|
-
*
|
|
5
|
-
* The v1 factory returns a no-op adapter that always succeeds (null permit).
|
|
6
|
-
* Real adapter configuration will come through `ServiceSpec.config` (TRL-91).
|
|
7
|
-
* The mock factory provides a synthetic adapter that always succeeds.
|
|
8
|
-
*/
|
|
9
|
-
export declare const authService: import("@ontrails/core").Service<AuthAdapter>;
|
|
10
|
-
//# sourceMappingURL=auth-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-service.d.ts","sourceRoot":"","sources":["../src/auth-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,+CAatB,CAAC"}
|
package/dist/auth-service.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Result, service } from '@ontrails/core';
|
|
2
|
-
/**
|
|
3
|
-
* Auth service — manages the auth adapter lifecycle.
|
|
4
|
-
*
|
|
5
|
-
* The v1 factory returns a no-op adapter that always succeeds (null permit).
|
|
6
|
-
* Real adapter configuration will come through `ServiceSpec.config` (TRL-91).
|
|
7
|
-
* The mock factory provides a synthetic adapter that always succeeds.
|
|
8
|
-
*/
|
|
9
|
-
export const authService = service('auth', {
|
|
10
|
-
create: (_svc) => Result.ok({
|
|
11
|
-
// oxlint-disable-next-line require-await -- stub adapter satisfies async interface
|
|
12
|
-
authenticate: async () => Result.ok(null),
|
|
13
|
-
}),
|
|
14
|
-
description: 'Authentication adapter',
|
|
15
|
-
metadata: { category: 'infrastructure' },
|
|
16
|
-
mock: () => ({
|
|
17
|
-
// oxlint-disable-next-line require-await -- mock adapter satisfies async interface
|
|
18
|
-
authenticate: async () => Result.ok(null),
|
|
19
|
-
}),
|
|
20
|
-
});
|
|
21
|
-
//# sourceMappingURL=auth-service.js.map
|