@ontrails/permits 1.0.0-beta.14 → 1.0.0-beta.16
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/CHANGELOG.md +76 -0
- package/README.md +35 -27
- package/package.json +12 -3
- package/src/adapters/adapter.ts +41 -0
- package/src/{connectors → adapters}/jwt.ts +148 -21
- package/src/auth-resource.ts +89 -0
- package/src/boundary.ts +200 -0
- package/src/errors.ts +1 -18
- package/src/extraction.ts +22 -16
- package/src/index.ts +22 -10
- package/src/permit.ts +2 -2
- package/src/rules.ts +2 -2
- package/src/testing.ts +5 -5
- package/src/trails/auth-verify.ts +13 -15
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-lint.log +0 -3
- package/.turbo/turbo-typecheck.log +0 -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-layer.d.ts +0 -18
- package/dist/auth-layer.d.ts.map +0 -1
- package/dist/auth-layer.js +0 -56
- package/dist/auth-layer.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 +0 -22
- 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/dist/connectors/connector.d.ts +0 -26
- package/dist/connectors/connector.d.ts.map +0 -1
- package/dist/connectors/connector.js +0 -2
- package/dist/connectors/connector.js.map +0 -1
- package/dist/connectors/jwt.d.ts +0 -25
- package/dist/connectors/jwt.d.ts.map +0 -1
- package/dist/connectors/jwt.js +0 -148
- package/dist/connectors/jwt.js.map +0 -1
- package/dist/errors.d.ts +0 -15
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -15
- package/dist/errors.js.map +0 -1
- package/dist/extraction.d.ts +0 -20
- package/dist/extraction.d.ts.map +0 -1
- package/dist/extraction.js +0 -2
- package/dist/extraction.js.map +0 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -11
- package/dist/index.js.map +0 -1
- package/dist/permit.d.ts +0 -26
- package/dist/permit.d.ts.map +0 -1
- package/dist/permit.js +0 -17
- package/dist/permit.js.map +0 -1
- package/dist/rules.d.ts +0 -47
- package/dist/rules.d.ts.map +0 -1
- package/dist/rules.js +0 -127
- package/dist/rules.js.map +0 -1
- package/dist/testing.d.ts +0 -20
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js +0 -22
- package/dist/testing.js.map +0 -1
- package/dist/trails/auth-verify.d.ts +0 -22
- package/dist/trails/auth-verify.d.ts.map +0 -1
- package/dist/trails/auth-verify.js +0 -85
- package/dist/trails/auth-verify.js.map +0 -1
- package/src/__tests__/auth-gate.test.ts +0 -130
- package/src/__tests__/auth-provision.test.ts +0 -62
- package/src/__tests__/auth-verify.test.ts +0 -278
- package/src/__tests__/connector.test.ts +0 -338
- package/src/__tests__/permit.test.ts +0 -122
- package/src/__tests__/rules.test.ts +0 -239
- package/src/__tests__/testing.test.ts +0 -57
- package/src/auth-gate.ts +0 -80
- package/src/auth-provision.ts +0 -26
- package/src/connectors/connector.ts +0 -35
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/dist/auth-gate.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Gate } from '@ontrails/core';
|
|
2
|
-
/**
|
|
3
|
-
* A {@link Gate} that enforces permit scopes declared on trails.
|
|
4
|
-
*
|
|
5
|
-
* The gate reads the trail's `permit` field (a `PermitRequirement`):
|
|
6
|
-
*
|
|
7
|
-
* - If `permit` is `'public'` or `undefined` the gate passes through.
|
|
8
|
-
* - If `permit` has `scopes`, the gate checks that `ctx.permit` contains
|
|
9
|
-
* all required scopes. A superset is fine; missing scopes produce a
|
|
10
|
-
* `PermitError`.
|
|
11
|
-
*
|
|
12
|
-
* Because `ctx.cross()` re-enters `executeTrail` (which applies gates),
|
|
13
|
-
* this gate automatically re-checks on every invocation in a crossing chain.
|
|
14
|
-
* No special crossing-chain handling is needed — it is built into the
|
|
15
|
-
* architecture.
|
|
16
|
-
*/
|
|
17
|
-
export declare const authGate: Gate;
|
|
18
|
-
//# sourceMappingURL=auth-gate.d.ts.map
|
package/dist/auth-gate.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-gate.d.ts","sourceRoot":"","sources":["../src/auth-gate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AA6B3C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ,EAAE,IAkCtB,CAAC"}
|
package/dist/auth-gate.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Result } from '@ontrails/core';
|
|
2
|
-
import { PermitError } from './errors.js';
|
|
3
|
-
import { getPermit } from './permit.js';
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
5
|
-
// Helpers (defined before callers — no use-before-define)
|
|
6
|
-
// ---------------------------------------------------------------------------
|
|
7
|
-
/**
|
|
8
|
-
* Returns `true` when the permit requirement means "no enforcement needed."
|
|
9
|
-
* Either the trail hasn't declared a permit posture or has explicitly
|
|
10
|
-
* opted out with `'public'`.
|
|
11
|
-
*/
|
|
12
|
-
const isPassThrough = (requirement) => requirement === undefined || requirement === 'public';
|
|
13
|
-
/** Returns scopes present in `required` but absent from `held`. */
|
|
14
|
-
const findMissing = (required, held) => required.filter((s) => !held.includes(s));
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Auth gate
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
/**
|
|
19
|
-
* A {@link Gate} that enforces permit scopes declared on trails.
|
|
20
|
-
*
|
|
21
|
-
* The gate reads the trail's `permit` field (a `PermitRequirement`):
|
|
22
|
-
*
|
|
23
|
-
* - If `permit` is `'public'` or `undefined` the gate passes through.
|
|
24
|
-
* - If `permit` has `scopes`, the gate checks that `ctx.permit` contains
|
|
25
|
-
* all required scopes. A superset is fine; missing scopes produce a
|
|
26
|
-
* `PermitError`.
|
|
27
|
-
*
|
|
28
|
-
* Because `ctx.cross()` re-enters `executeTrail` (which applies gates),
|
|
29
|
-
* this gate automatically re-checks on every invocation in a crossing chain.
|
|
30
|
-
* No special crossing-chain handling is needed — it is built into the
|
|
31
|
-
* architecture.
|
|
32
|
-
*/
|
|
33
|
-
export const authGate = {
|
|
34
|
-
description: 'Enforces permit scopes declared on trails',
|
|
35
|
-
name: 'auth',
|
|
36
|
-
wrap: (_trail, impl) => {
|
|
37
|
-
const requirement = _trail.permit;
|
|
38
|
-
if (isPassThrough(requirement)) {
|
|
39
|
-
return impl;
|
|
40
|
-
}
|
|
41
|
-
return (input, ctx) => {
|
|
42
|
-
const permit = getPermit(ctx);
|
|
43
|
-
if (!permit) {
|
|
44
|
-
return Promise.resolve(Result.err(new PermitError('No permit provided')));
|
|
45
|
-
}
|
|
46
|
-
const missing = findMissing(requirement.scopes, permit.scopes);
|
|
47
|
-
if (missing.length > 0) {
|
|
48
|
-
return Promise.resolve(Result.err(new PermitError(`Missing scopes: ${missing.join(', ')}`, {
|
|
49
|
-
context: { missing, required: requirement.scopes },
|
|
50
|
-
})));
|
|
51
|
-
}
|
|
52
|
-
return Promise.resolve(impl(input, ctx));
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=auth-gate.js.map
|
package/dist/auth-gate.js.map
DELET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AAO,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YAE/D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,OAAO,OAAO,CAAC,OAAO,CACpB,MAAM,CAAC,GAAG,CACR,IAAI,WAAW,CAAC,mBAAmB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE;oBACvD,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE;iBACnD,CAAC,CACH,CACF,CAAC;YACJ,CAAC;YAED,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/dist/auth-layer.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Layer } from '@ontrails/core';
|
|
2
|
-
/**
|
|
3
|
-
* A {@link Layer} that enforces permit scopes declared on trails.
|
|
4
|
-
*
|
|
5
|
-
* The layer reads the trail's `permit` field (a `PermitRequirement`):
|
|
6
|
-
*
|
|
7
|
-
* - If `permit` is `'public'` or `undefined` the layer passes through.
|
|
8
|
-
* - If `permit` has `scopes`, the layer checks that `ctx.permit` contains
|
|
9
|
-
* all required scopes. A superset is fine; missing scopes produce a
|
|
10
|
-
* `PermitError`.
|
|
11
|
-
*
|
|
12
|
-
* Because `ctx.follow()` re-enters `executeTrail` (which applies layers),
|
|
13
|
-
* this layer automatically re-checks on every invocation in a follow chain.
|
|
14
|
-
* No special follow-chain handling is needed — it is built into the
|
|
15
|
-
* architecture.
|
|
16
|
-
*/
|
|
17
|
-
export declare const authLayer: Layer;
|
|
18
|
-
//# sourceMappingURL=auth-layer.d.ts.map
|
package/dist/auth-layer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-layer.d.ts","sourceRoot":"","sources":["../src/auth-layer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AA6B5C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,EAAE,KAkCvB,CAAC"}
|
package/dist/auth-layer.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Result } from '@ontrails/core';
|
|
2
|
-
import { PermitError } from './errors.js';
|
|
3
|
-
import { getPermit } from './permit.js';
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
5
|
-
// Helpers (defined before callers — no use-before-define)
|
|
6
|
-
// ---------------------------------------------------------------------------
|
|
7
|
-
/**
|
|
8
|
-
* Returns `true` when the permit requirement means "no enforcement needed."
|
|
9
|
-
* Either the trail hasn't declared a permit posture or has explicitly
|
|
10
|
-
* opted out with `'public'`.
|
|
11
|
-
*/
|
|
12
|
-
const isPassThrough = (requirement) => requirement === undefined || requirement === 'public';
|
|
13
|
-
/** Returns scopes present in `required` but absent from `held`. */
|
|
14
|
-
const findMissing = (required, held) => required.filter((s) => !held.includes(s));
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Auth layer
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
/**
|
|
19
|
-
* A {@link Layer} that enforces permit scopes declared on trails.
|
|
20
|
-
*
|
|
21
|
-
* The layer reads the trail's `permit` field (a `PermitRequirement`):
|
|
22
|
-
*
|
|
23
|
-
* - If `permit` is `'public'` or `undefined` the layer passes through.
|
|
24
|
-
* - If `permit` has `scopes`, the layer checks that `ctx.permit` contains
|
|
25
|
-
* all required scopes. A superset is fine; missing scopes produce a
|
|
26
|
-
* `PermitError`.
|
|
27
|
-
*
|
|
28
|
-
* Because `ctx.follow()` re-enters `executeTrail` (which applies layers),
|
|
29
|
-
* this layer automatically re-checks on every invocation in a follow chain.
|
|
30
|
-
* No special follow-chain handling is needed — it is built into the
|
|
31
|
-
* architecture.
|
|
32
|
-
*/
|
|
33
|
-
export const authLayer = {
|
|
34
|
-
description: 'Enforces permit scopes declared on trails',
|
|
35
|
-
name: 'auth',
|
|
36
|
-
wrap: (_trail, impl) => {
|
|
37
|
-
const requirement = _trail.permit;
|
|
38
|
-
if (isPassThrough(requirement)) {
|
|
39
|
-
return impl;
|
|
40
|
-
}
|
|
41
|
-
return (input, ctx) => {
|
|
42
|
-
const permit = getPermit(ctx);
|
|
43
|
-
if (!permit) {
|
|
44
|
-
return Promise.resolve(Result.err(new PermitError('No permit provided')));
|
|
45
|
-
}
|
|
46
|
-
const missing = findMissing(requirement.scopes, permit.scopes);
|
|
47
|
-
if (missing.length > 0) {
|
|
48
|
-
return Promise.resolve(Result.err(new PermitError(`Missing scopes: ${missing.join(', ')}`, {
|
|
49
|
-
context: { missing, required: requirement.scopes },
|
|
50
|
-
})));
|
|
51
|
-
}
|
|
52
|
-
return Promise.resolve(impl(input, ctx));
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=auth-layer.js.map
|
package/dist/auth-layer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-layer.js","sourceRoot":"","sources":["../src/auth-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,8EAA8E;AAC9E,0DAA0D;AAC1D,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,aAAa,GAAG,CACpB,WAAoB,EACiB,EAAE,CACvC,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,QAAQ,CAAC;AAExD,mEAAmE;AACnE,MAAM,WAAW,GAAG,CAClB,QAA2B,EAC3B,IAAuB,EACJ,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAA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|
-
import type { AuthConnector } from './connectors/connector.js';
|
|
2
|
-
/**
|
|
3
|
-
* Auth provision — 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 `ProvisionSpec.config`
|
|
7
|
-
* (TRL-91). The mock factory provides a synthetic connector that always
|
|
8
|
-
* succeeds.
|
|
9
|
-
*/
|
|
10
|
-
export declare const authProvision: import("@ontrails/core").Provision<AuthConnector>;
|
|
11
|
-
//# sourceMappingURL=auth-provision.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-provision.d.ts","sourceRoot":"","sources":["../src/auth-provision.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,mDAaxB,CAAC"}
|
package/dist/auth-provision.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Result, provision } from '@ontrails/core';
|
|
2
|
-
/**
|
|
3
|
-
* Auth provision — 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 `ProvisionSpec.config`
|
|
7
|
-
* (TRL-91). The mock factory provides a synthetic connector that always
|
|
8
|
-
* succeeds.
|
|
9
|
-
*/
|
|
10
|
-
export const authProvision = provision('auth', {
|
|
11
|
-
create: (_svc) => Result.ok({
|
|
12
|
-
// oxlint-disable-next-line require-await -- stub connector satisfies async interface
|
|
13
|
-
authenticate: async () => Result.ok(null),
|
|
14
|
-
}),
|
|
15
|
-
description: 'Authentication connector',
|
|
16
|
-
meta: { category: 'infrastructure' },
|
|
17
|
-
mock: () => ({
|
|
18
|
-
// oxlint-disable-next-line require-await -- mock connector satisfies async interface
|
|
19
|
-
authenticate: async () => Result.ok(null),
|
|
20
|
-
}),
|
|
21
|
-
});
|
|
22
|
-
//# sourceMappingURL=auth-provision.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-provision.js","sourceRoot":"","sources":["../src/auth-provision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAInD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAgB,MAAM,EAAE;IAC5D,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/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
|
package/dist/auth-service.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-service.js","sourceRoot":"","sources":["../src/auth-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAIjD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAc,MAAM,EAAE;IACtD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CACf,MAAM,CAAC,EAAE,CAAC;QACR,mFAAmF;QACnF,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;KACpB,CAAC;IAC1B,WAAW,EAAE,wBAAwB;IACrC,QAAQ,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE;IACxC,IAAI,EAAE,GAAG,EAAE,CACT,CAAC;QACC,mFAAmF;QACnF,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;KAC1C,CAAuB;CAC3B,CAAC,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Result } from '@ontrails/core';
|
|
2
|
-
import type { PermitExtractionInput } from '../extraction.js';
|
|
3
|
-
import type { Permit } from '../permit.js';
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Use {@link PermitExtractionInput} instead. Kept as an alias
|
|
6
|
-
* for backward compatibility during migration.
|
|
7
|
-
*/
|
|
8
|
-
export type AuthCredentials = PermitExtractionInput;
|
|
9
|
-
/** Errors from auth connectors. */
|
|
10
|
-
export interface AuthError {
|
|
11
|
-
readonly code: 'expired_token' | 'insufficient_scope' | 'invalid_token' | 'missing_credentials';
|
|
12
|
-
readonly message: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Auth connector port. Given extraction input, produce a permit or an error.
|
|
16
|
-
*
|
|
17
|
-
* The connector receives the full {@link PermitExtractionInput} — trailhead,
|
|
18
|
-
* headers, requestId, and credential fields — so it can make richer
|
|
19
|
-
* decisions (e.g., rate-limit by trailhead or correlate via requestId).
|
|
20
|
-
*
|
|
21
|
-
* Deliberately narrow — no session management, no token refresh.
|
|
22
|
-
*/
|
|
23
|
-
export interface AuthConnector {
|
|
24
|
-
readonly authenticate: (input: PermitExtractionInput) => Promise<Result<Permit | null, AuthError>>;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/connectors/connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAEpD,mCAAmC;AACnC,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,aAAa;IAC5B,QAAQ,CAAC,YAAY,EAAE,CACrB,KAAK,EAAE,qBAAqB,KACzB,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;CAChD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../../src/connectors/connector.ts"],"names":[],"mappings":""}
|
package/dist/connectors/jwt.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { AuthConnector } from './connector.js';
|
|
2
|
-
/** Configuration for the JWT auth connector. */
|
|
3
|
-
export interface JwtConnectorOptions {
|
|
4
|
-
/** HMAC secret for HS256 verification. */
|
|
5
|
-
readonly secret?: string;
|
|
6
|
-
/** JWKS endpoint for RS256/ES256 (not yet implemented). */
|
|
7
|
-
readonly jwksUrl?: string;
|
|
8
|
-
/** Expected issuer claim. */
|
|
9
|
-
readonly issuer?: string;
|
|
10
|
-
/** Expected audience claim. */
|
|
11
|
-
readonly audience?: string;
|
|
12
|
-
/** Claim containing scopes (default: 'scope'). */
|
|
13
|
-
readonly scopesClaim?: string;
|
|
14
|
-
/** Claim containing roles (default: 'roles'). */
|
|
15
|
-
readonly rolesClaim?: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Create a JWT auth connector using Bun's native crypto.
|
|
19
|
-
*
|
|
20
|
-
* Verifies HS256-signed JWTs, extracts claims into a Permit, and checks
|
|
21
|
-
* issuer/audience when configured. Returns `Result.ok(null)` when no
|
|
22
|
-
* credentials are provided.
|
|
23
|
-
*/
|
|
24
|
-
export declare const createJwtConnector: (options: JwtConnectorOptions) => AuthConnector;
|
|
25
|
-
//# sourceMappingURL=jwt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/connectors/jwt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAa,MAAM,gBAAgB,CAAC;AAI/D,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,+BAA+B;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kDAAkD;IAClD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,iDAAiD;IACjD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AA2LD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,mBAAmB,KAC3B,aAeF,CAAC"}
|
package/dist/connectors/jwt.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { Result } from '@ontrails/core';
|
|
2
|
-
// ---------------------------------------------------------------------------
|
|
3
|
-
// Helpers (defined before callers)
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
5
|
-
const authErr = (code, message) => Result.err({ code, message });
|
|
6
|
-
/** Base64url-decode a string to bytes. */
|
|
7
|
-
const base64urlDecode = (input) => {
|
|
8
|
-
const padded = input
|
|
9
|
-
.replaceAll('-', '+')
|
|
10
|
-
.replaceAll('_', '/')
|
|
11
|
-
.padEnd(input.length + ((4 - (input.length % 4)) % 4), '=');
|
|
12
|
-
const binary = atob(padded);
|
|
13
|
-
const bytes = new Uint8Array(binary.length);
|
|
14
|
-
for (let i = 0; i < binary.length; i += 1) {
|
|
15
|
-
bytes[i] = binary.codePointAt(i) ?? 0;
|
|
16
|
-
}
|
|
17
|
-
return bytes;
|
|
18
|
-
};
|
|
19
|
-
/** Decode a JWT payload without verifying the signature. */
|
|
20
|
-
const decodePayload = (token) => {
|
|
21
|
-
const parts = token.split('.');
|
|
22
|
-
if (parts.length !== 3) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
const json = new TextDecoder().decode(base64urlDecode(parts[1] ?? ''));
|
|
27
|
-
return JSON.parse(json);
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
/** Import a secret as an HMAC CryptoKey. */
|
|
34
|
-
const importHmacKey = (secret) => {
|
|
35
|
-
const encoder = new TextEncoder();
|
|
36
|
-
return crypto.subtle.importKey('raw', encoder.encode(secret), { hash: 'SHA-256', name: 'HMAC' }, false, ['verify']);
|
|
37
|
-
};
|
|
38
|
-
/** Verify the HMAC-SHA256 signature of a JWT. */
|
|
39
|
-
const verifyHmacSignature = (token, key) => {
|
|
40
|
-
const lastDot = token.lastIndexOf('.');
|
|
41
|
-
if (lastDot === -1) {
|
|
42
|
-
return Promise.resolve(false);
|
|
43
|
-
}
|
|
44
|
-
const data = token.slice(0, lastDot);
|
|
45
|
-
const signature = base64urlDecode(token.slice(lastDot + 1));
|
|
46
|
-
const encoder = new TextEncoder();
|
|
47
|
-
return crypto.subtle.verify('HMAC', key, signature.buffer, encoder.encode(data));
|
|
48
|
-
};
|
|
49
|
-
/** Validate standard claims (exp, iss, aud). */
|
|
50
|
-
const validateClaims = (payload, options) => {
|
|
51
|
-
if (payload.exp !== undefined &&
|
|
52
|
-
payload.exp < Math.floor(Date.now() / 1000)) {
|
|
53
|
-
return { code: 'expired_token', message: 'Token has expired' };
|
|
54
|
-
}
|
|
55
|
-
if (options.issuer && payload.iss !== options.issuer) {
|
|
56
|
-
return { code: 'invalid_token', message: 'Issuer mismatch' };
|
|
57
|
-
}
|
|
58
|
-
if (options.audience) {
|
|
59
|
-
const { aud } = payload;
|
|
60
|
-
const matches = Array.isArray(aud)
|
|
61
|
-
? aud.includes(options.audience)
|
|
62
|
-
: aud === options.audience;
|
|
63
|
-
if (!matches) {
|
|
64
|
-
return { code: 'invalid_token', message: 'Audience mismatch' };
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return undefined;
|
|
68
|
-
};
|
|
69
|
-
/** Extract scopes from a payload claim (space-separated string or array). */
|
|
70
|
-
const extractScopes = (payload, claim) => {
|
|
71
|
-
const raw = payload[claim];
|
|
72
|
-
if (typeof raw === 'string') {
|
|
73
|
-
return raw.split(' ').filter(Boolean);
|
|
74
|
-
}
|
|
75
|
-
if (Array.isArray(raw)) {
|
|
76
|
-
return raw.filter((s) => typeof s === 'string' && s.length > 0);
|
|
77
|
-
}
|
|
78
|
-
return [];
|
|
79
|
-
};
|
|
80
|
-
/** Extract roles from a payload claim (string array). */
|
|
81
|
-
const extractRoles = (payload, claim) => {
|
|
82
|
-
const raw = payload[claim];
|
|
83
|
-
if (!Array.isArray(raw)) {
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
return raw.filter((r) => typeof r === 'string');
|
|
87
|
-
};
|
|
88
|
-
/** Build a Permit from a validated JWT payload. */
|
|
89
|
-
const buildPermit = (payload, options) => {
|
|
90
|
-
if (!payload.sub) {
|
|
91
|
-
return authErr('invalid_token', 'Missing subject claim (sub)');
|
|
92
|
-
}
|
|
93
|
-
const roles = extractRoles(payload, options.rolesClaim ?? 'roles');
|
|
94
|
-
return Result.ok({
|
|
95
|
-
id: payload.sub,
|
|
96
|
-
scopes: extractScopes(payload, options.scopesClaim ?? 'scope'),
|
|
97
|
-
...(roles ? { roles } : {}),
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
/** Verify the signature and return the decoded payload, or an error. */
|
|
101
|
-
const decodeAndVerify = async (token, secret) => {
|
|
102
|
-
const payload = decodePayload(token);
|
|
103
|
-
if (!payload) {
|
|
104
|
-
return authErr('invalid_token', 'Malformed JWT');
|
|
105
|
-
}
|
|
106
|
-
try {
|
|
107
|
-
const key = await importHmacKey(secret);
|
|
108
|
-
const valid = await verifyHmacSignature(token, key);
|
|
109
|
-
return valid
|
|
110
|
-
? Result.ok(payload)
|
|
111
|
-
: authErr('invalid_token', 'Invalid signature');
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
return authErr('invalid_token', 'Malformed token signature');
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
/** Validate claims and build a permit from a verified payload. */
|
|
118
|
-
const payloadToPermit = (payload, options) => {
|
|
119
|
-
const claimError = validateClaims(payload, options);
|
|
120
|
-
if (claimError) {
|
|
121
|
-
return Result.err(claimError);
|
|
122
|
-
}
|
|
123
|
-
return buildPermit(payload, options);
|
|
124
|
-
};
|
|
125
|
-
// ---------------------------------------------------------------------------
|
|
126
|
-
// Factory
|
|
127
|
-
// ---------------------------------------------------------------------------
|
|
128
|
-
/**
|
|
129
|
-
* Create a JWT auth connector using Bun's native crypto.
|
|
130
|
-
*
|
|
131
|
-
* Verifies HS256-signed JWTs, extracts claims into a Permit, and checks
|
|
132
|
-
* issuer/audience when configured. Returns `Result.ok(null)` when no
|
|
133
|
-
* credentials are provided.
|
|
134
|
-
*/
|
|
135
|
-
export const createJwtConnector = (options) => {
|
|
136
|
-
const authenticate = async (input) => {
|
|
137
|
-
if (!input.bearerToken) {
|
|
138
|
-
return Result.ok(null);
|
|
139
|
-
}
|
|
140
|
-
if (!options.secret) {
|
|
141
|
-
return authErr('invalid_token', 'No secret configured');
|
|
142
|
-
}
|
|
143
|
-
const decoded = await decodeAndVerify(input.bearerToken, options.secret);
|
|
144
|
-
return decoded.isErr() ? decoded : payloadToPermit(decoded.value, options);
|
|
145
|
-
};
|
|
146
|
-
return { authenticate };
|
|
147
|
-
};
|
|
148
|
-
//# sourceMappingURL=jwt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../src/connectors/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AA+BxC,8EAA8E;AAC9E,mCAAmC;AACnC,8EAA8E;AAE9E,MAAM,OAAO,GAAG,CACd,IAAuB,EACvB,OAAe,EACW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAE7D,0CAA0C;AAC1C,MAAM,eAAe,GAAG,CAAC,KAAa,EAAc,EAAE;IACpD,MAAM,MAAM,GAAG,KAAK;SACjB,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;SACpB,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;SACpB,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,4DAA4D;AAC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AAG,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/errors.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PermissionError } from '@ontrails/core';
|
|
2
|
-
/**
|
|
3
|
-
* Error returned when permit scope enforcement fails.
|
|
4
|
-
*
|
|
5
|
-
* Extends `PermissionError` (category `'permission'`, HTTP 403) because
|
|
6
|
-
* it represents an *authorization* failure — the caller's identity is known
|
|
7
|
-
* but lacks the required scopes.
|
|
8
|
-
*/
|
|
9
|
-
export declare class PermitError extends PermissionError {
|
|
10
|
-
constructor(message: string, options?: {
|
|
11
|
-
cause?: Error;
|
|
12
|
-
context?: Record<string, unknown>;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;;GAMG;AACH,qBAAa,WAAY,SAAQ,eAAe;gBAE5C,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;CAKjE"}
|
package/dist/errors.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PermissionError } from '@ontrails/core';
|
|
2
|
-
/**
|
|
3
|
-
* Error returned when permit scope enforcement fails.
|
|
4
|
-
*
|
|
5
|
-
* Extends `PermissionError` (category `'permission'`, HTTP 403) because
|
|
6
|
-
* it represents an *authorization* failure — the caller's identity is known
|
|
7
|
-
* but lacks the required scopes.
|
|
8
|
-
*/
|
|
9
|
-
export class PermitError extends PermissionError {
|
|
10
|
-
constructor(message, options) {
|
|
11
|
-
super(message, options);
|
|
12
|
-
this.name = 'PermitError';
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,OAAO,WAAY,SAAQ,eAAe;IAC9C,YACE,OAAe,EACf,OAA8D;QAE9D,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF"}
|
package/dist/extraction.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Normalized input for auth connectors.
|
|
3
|
-
*
|
|
4
|
-
* Each trailhead extracts raw credentials from its transport and normalizes
|
|
5
|
-
* them into this shape. No trailhead types (Request, McpSession, etc.) cross
|
|
6
|
-
* into core — only this interface.
|
|
7
|
-
*/
|
|
8
|
-
export interface PermitExtractionInput {
|
|
9
|
-
/** Which trailhead produced this extraction */
|
|
10
|
-
readonly trailhead: 'http' | 'mcp' | 'cli';
|
|
11
|
-
/** Bearer token from Authorization header or equivalent */
|
|
12
|
-
readonly bearerToken?: string;
|
|
13
|
-
/** Session identifier from transport handshake */
|
|
14
|
-
readonly sessionId?: string;
|
|
15
|
-
/** Raw headers (HTTP trailhead only, typically) */
|
|
16
|
-
readonly headers?: Headers;
|
|
17
|
-
/** Correlation ID for tracing */
|
|
18
|
-
readonly requestId: string;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=extraction.d.ts.map
|
package/dist/extraction.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../src/extraction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IAC3C,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,kDAAkD;IAClD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
|
package/dist/extraction.js
DELETED
package/dist/extraction.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extraction.js","sourceRoot":"","sources":["../src/extraction.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { type AuthConnector, type AuthCredentials, type AuthError, } from './connectors/connector.js';
|
|
2
|
-
export { createJwtConnector, type JwtConnectorOptions, } from './connectors/jwt.js';
|
|
3
|
-
export { authGate } from './auth-gate.js';
|
|
4
|
-
export { authProvision } from './auth-provision.js';
|
|
5
|
-
export { authVerify } from './trails/auth-verify.js';
|
|
6
|
-
export { PermitError } from './errors.js';
|
|
7
|
-
export { type PermitExtractionInput } from './extraction.js';
|
|
8
|
-
export { type Permit, getPermit } from './permit.js';
|
|
9
|
-
export { validatePermits, type PermitDiagnostic } from './rules.js';
|
|
10
|
-
export { mintTestPermit, mintPermitForTrail } from './testing.js';
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,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,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export {} from './connectors/connector.js';
|
|
2
|
-
export { createJwtConnector, } from './connectors/jwt.js';
|
|
3
|
-
export { authGate } from './auth-gate.js';
|
|
4
|
-
export { authProvision } from './auth-provision.js';
|
|
5
|
-
export { authVerify } from './trails/auth-verify.js';
|
|
6
|
-
export { PermitError } from './errors.js';
|
|
7
|
-
export {} from './extraction.js';
|
|
8
|
-
export { getPermit } from './permit.js';
|
|
9
|
-
export { validatePermits } from './rules.js';
|
|
10
|
-
export { mintTestPermit, mintPermitForTrail } from './testing.js';
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,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,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/permit.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { BasePermit } from '@ontrails/core';
|
|
2
|
-
/** The resolved identity and scopes from a successful authentication. */
|
|
3
|
-
export interface Permit extends BasePermit {
|
|
4
|
-
readonly roles?: readonly string[];
|
|
5
|
-
readonly tenantId?: string;
|
|
6
|
-
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Type-safe accessor for `ctx.permit` with a downcast to `Permit`.
|
|
10
|
-
*
|
|
11
|
-
* `TrailContext.permit` is typed as `BasePermit` (id + scopes). This accessor
|
|
12
|
-
* returns the full `Permit` when the auth gate has set one. Safe because
|
|
13
|
-
* the auth gate is the only writer and always sets a full `Permit`.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const permit = getPermit(ctx);
|
|
18
|
-
* if (permit) {
|
|
19
|
-
* console.log(permit.roles, permit.tenantId);
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare const getPermit: (ctx: {
|
|
24
|
-
permit?: BasePermit;
|
|
25
|
-
}) => Permit | undefined;
|
|
26
|
-
//# sourceMappingURL=permit.d.ts.map
|
package/dist/permit.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permit.d.ts","sourceRoot":"","sources":["../src/permit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,yEAAyE;AACzE,MAAM,WAAW,MAAO,SAAQ,UAAU;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvD;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK;IAAE,MAAM,CAAC,EAAE,UAAU,CAAA;CAAE,KAAG,MAAM,GAAG,SACH,CAAC"}
|