@decionis/agent-safe-pipeline 0.3.7 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/Index.d.ts +12 -0
- package/dist/Index.d.ts.map +1 -1
- package/dist/Index.js +12 -0
- package/dist/Index.js.map +1 -1
- package/dist/decision/DecionisGate.d.ts +6 -1
- package/dist/decision/DecionisGate.d.ts.map +1 -1
- package/dist/decision/DecionisGate.js +61 -11
- package/dist/decision/DecionisGate.js.map +1 -1
- package/dist/decision/DecisionAuthority.d.ts +16 -0
- package/dist/decision/DecisionAuthority.d.ts.map +1 -1
- package/dist/decision/DecisionAuthority.js.map +1 -1
- package/dist/execution/AuthorizationVerifier.d.ts +33 -4
- package/dist/execution/AuthorizationVerifier.d.ts.map +1 -1
- package/dist/execution/AuthorizationVerifier.js +74 -10
- package/dist/execution/AuthorizationVerifier.js.map +1 -1
- package/dist/execution/EffectAdapter.d.ts +117 -0
- package/dist/execution/EffectAdapter.d.ts.map +1 -0
- package/dist/execution/EffectAdapter.js +22 -0
- package/dist/execution/EffectAdapter.js.map +1 -0
- package/dist/execution/ExecutionDeadline.d.ts +35 -0
- package/dist/execution/ExecutionDeadline.d.ts.map +1 -0
- package/dist/execution/ExecutionDeadline.js +52 -0
- package/dist/execution/ExecutionDeadline.js.map +1 -0
- package/dist/execution/ExecutionJournal.d.ts +148 -0
- package/dist/execution/ExecutionJournal.d.ts.map +1 -0
- package/dist/execution/ExecutionJournal.js +157 -0
- package/dist/execution/ExecutionJournal.js.map +1 -0
- package/dist/execution/ExecutionOutcome.d.ts +186 -0
- package/dist/execution/ExecutionOutcome.d.ts.map +1 -0
- package/dist/execution/ExecutionOutcome.js +2 -0
- package/dist/execution/ExecutionOutcome.js.map +1 -0
- package/dist/execution/ExecutionPosture.d.ts +50 -0
- package/dist/execution/ExecutionPosture.d.ts.map +1 -0
- package/dist/execution/ExecutionPosture.js +20 -0
- package/dist/execution/ExecutionPosture.js.map +1 -0
- package/dist/execution/ExecutorEvidence.d.ts +64 -0
- package/dist/execution/ExecutorEvidence.d.ts.map +1 -0
- package/dist/execution/ExecutorEvidence.js +14 -0
- package/dist/execution/ExecutorEvidence.js.map +1 -0
- package/dist/execution/GovernedExecutionRunner.d.ts +309 -0
- package/dist/execution/GovernedExecutionRunner.d.ts.map +1 -0
- package/dist/execution/GovernedExecutionRunner.js +1341 -0
- package/dist/execution/GovernedExecutionRunner.js.map +1 -0
- package/dist/execution/NativeExecutor.d.ts +220 -0
- package/dist/execution/NativeExecutor.d.ts.map +1 -0
- package/dist/execution/NativeExecutor.js +22 -0
- package/dist/execution/NativeExecutor.js.map +1 -0
- package/dist/execution/NativeExecutorSchema.d.ts +387 -0
- package/dist/execution/NativeExecutorSchema.d.ts.map +1 -0
- package/dist/execution/NativeExecutorSchema.js +261 -0
- package/dist/execution/NativeExecutorSchema.js.map +1 -0
- package/dist/execution/PostgresExecutionJournal.d.ts +54 -0
- package/dist/execution/PostgresExecutionJournal.d.ts.map +1 -0
- package/dist/execution/PostgresExecutionJournal.js +131 -0
- package/dist/execution/PostgresExecutionJournal.js.map +1 -0
- package/dist/execution/RegistryExecutor.d.ts +35 -0
- package/dist/execution/RegistryExecutor.d.ts.map +1 -0
- package/dist/execution/RegistryExecutor.js +84 -0
- package/dist/execution/RegistryExecutor.js.map +1 -0
- package/dist/execution/SafeExecutor.d.ts +22 -193
- package/dist/execution/SafeExecutor.d.ts.map +1 -1
- package/dist/execution/SafeExecutor.js +49 -521
- package/dist/execution/SafeExecutor.js.map +1 -1
- package/dist/http/AuthorityPaths.d.ts +51 -0
- package/dist/http/AuthorityPaths.d.ts.map +1 -0
- package/dist/http/AuthorityPaths.js +84 -0
- package/dist/http/AuthorityPaths.js.map +1 -0
- package/dist/shadow/ShadowPipeline.d.ts +3 -1
- package/dist/shadow/ShadowPipeline.d.ts.map +1 -1
- package/dist/shadow/ShadowPipeline.js +3 -3
- package/dist/shadow/ShadowPipeline.js.map +1 -1
- package/dist/testing/Index.d.ts +2 -1
- package/dist/testing/Index.d.ts.map +1 -1
- package/dist/testing/Index.js +2 -1
- package/dist/testing/Index.js.map +1 -1
- package/dist/testing/LocalAuthority.d.ts +35 -1
- package/dist/testing/LocalAuthority.d.ts.map +1 -1
- package/dist/testing/LocalAuthority.js +122 -2
- package/dist/testing/LocalAuthority.js.map +1 -1
- package/dist/testing/SignedSignals.d.ts +150 -0
- package/dist/testing/SignedSignals.d.ts.map +1 -0
- package/dist/testing/SignedSignals.js +291 -0
- package/dist/testing/SignedSignals.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every execution-authority path this package calls, in one place, as the
|
|
3
|
+
* REST resources Decionis serves them (`decionis-outcome-infrastructure`
|
|
4
|
+
* plan §3.0): a decision binds a grant, and a grant has claims, receipts and
|
|
5
|
+
* reconciliations, each created by a POST. The verb routes these replace
|
|
6
|
+
* stay registered on the authority as aliases of the same handlers, and are
|
|
7
|
+
* named here only for the one case that needs them: a grant whose id cannot
|
|
8
|
+
* be read from its token.
|
|
9
|
+
*
|
|
10
|
+
* A grant's id is its `jti`: the id the authority returns as
|
|
11
|
+
* `execution_token_jti`, records with the grant, and signs into the token.
|
|
12
|
+
*/
|
|
13
|
+
export declare class AuthorityPaths {
|
|
14
|
+
/** Evaluate an intent and bind a single-use grant: `POST`. */
|
|
15
|
+
static readonly GRANTS = "/v1/authority/grants";
|
|
16
|
+
/**
|
|
17
|
+
* The verb routes the REST resources replace. Deprecated on the authority
|
|
18
|
+
* and kept there as aliases on the same handlers, for clients that predate
|
|
19
|
+
* the resources.
|
|
20
|
+
*/
|
|
21
|
+
static readonly LEGACY: Readonly<{
|
|
22
|
+
enforceAndBind: "/v1/authority/enforce-and-bind";
|
|
23
|
+
verifyToken: "/v1/execution/verify-token";
|
|
24
|
+
claimToken: "/v1/execution/claim-token";
|
|
25
|
+
finalizeToken: "/v1/execution/finalize-token";
|
|
26
|
+
}>;
|
|
27
|
+
/** Read and verify one grant: `GET`. */
|
|
28
|
+
static grant(grantId: string): string;
|
|
29
|
+
/** Claim a grant, once, immediately before the write: `POST`. */
|
|
30
|
+
static claims(grantId: string): string;
|
|
31
|
+
/** Record how the claimed attempt ended (finalize): `POST`. */
|
|
32
|
+
static receipts(grantId: string): string;
|
|
33
|
+
/** Report how an attempt finalized `INDETERMINATE` resolved: `POST`. */
|
|
34
|
+
static reconciliations(grantId: string): string;
|
|
35
|
+
/** One managed escalation: `GET` its state, `DELETE` to cancel it. */
|
|
36
|
+
static escalation(escalationId: string): string;
|
|
37
|
+
/** Where to claim the grant an execution token stands for. */
|
|
38
|
+
static claimFor(executionToken: string): string;
|
|
39
|
+
/** Where to record the receipt for the grant an execution token stands for. */
|
|
40
|
+
static receiptFor(executionToken: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* The grant id a Decionis execution token names (its `jti`), read without
|
|
43
|
+
* verifying anything: it only addresses the resource, and the authority
|
|
44
|
+
* verifies the token itself and refuses a path whose id is not the
|
|
45
|
+
* token's. Null for a token that is not a JWT or whose `jti` is not a UUID
|
|
46
|
+
* (the only grant id the authority routes), in which case the caller uses
|
|
47
|
+
* the legacy alias.
|
|
48
|
+
*/
|
|
49
|
+
static grantIdOf(executionToken: string): string | null;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=AuthorityPaths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthorityPaths.d.ts","sourceRoot":"","sources":["../../src/http/AuthorityPaths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,qBAAa,cAAc;IACzB,8DAA8D;IAC9D,gBAAuB,MAAM,0BAA0B;IAEvD;;;;OAIG;IACH,gBAAuB,MAAM;;;;;OAK1B;IAEH,wCAAwC;WAC1B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAI5C,iEAAiE;WACnD,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAI7C,+DAA+D;WACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAI/C,wEAAwE;WAC1D,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAItD,sEAAsE;WACxD,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAItD,8DAA8D;WAChD,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;IAKtD,+EAA+E;WACjE,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;IAOxD;;;;;;;OAOG;WACW,SAAS,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAY/D"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every execution-authority path this package calls, in one place, as the
|
|
3
|
+
* REST resources Decionis serves them (`decionis-outcome-infrastructure`
|
|
4
|
+
* plan §3.0): a decision binds a grant, and a grant has claims, receipts and
|
|
5
|
+
* reconciliations, each created by a POST. The verb routes these replace
|
|
6
|
+
* stay registered on the authority as aliases of the same handlers, and are
|
|
7
|
+
* named here only for the one case that needs them: a grant whose id cannot
|
|
8
|
+
* be read from its token.
|
|
9
|
+
*
|
|
10
|
+
* A grant's id is its `jti`: the id the authority returns as
|
|
11
|
+
* `execution_token_jti`, records with the grant, and signs into the token.
|
|
12
|
+
*/
|
|
13
|
+
export class AuthorityPaths {
|
|
14
|
+
/** Evaluate an intent and bind a single-use grant: `POST`. */
|
|
15
|
+
static GRANTS = "/v1/authority/grants";
|
|
16
|
+
/**
|
|
17
|
+
* The verb routes the REST resources replace. Deprecated on the authority
|
|
18
|
+
* and kept there as aliases on the same handlers, for clients that predate
|
|
19
|
+
* the resources.
|
|
20
|
+
*/
|
|
21
|
+
static LEGACY = Object.freeze({
|
|
22
|
+
enforceAndBind: "/v1/authority/enforce-and-bind",
|
|
23
|
+
verifyToken: "/v1/execution/verify-token",
|
|
24
|
+
claimToken: "/v1/execution/claim-token",
|
|
25
|
+
finalizeToken: "/v1/execution/finalize-token",
|
|
26
|
+
});
|
|
27
|
+
/** Read and verify one grant: `GET`. */
|
|
28
|
+
static grant(grantId) {
|
|
29
|
+
return `${AuthorityPaths.GRANTS}/${encodeURIComponent(grantId)}`;
|
|
30
|
+
}
|
|
31
|
+
/** Claim a grant, once, immediately before the write: `POST`. */
|
|
32
|
+
static claims(grantId) {
|
|
33
|
+
return `${AuthorityPaths.grant(grantId)}/claims`;
|
|
34
|
+
}
|
|
35
|
+
/** Record how the claimed attempt ended (finalize): `POST`. */
|
|
36
|
+
static receipts(grantId) {
|
|
37
|
+
return `${AuthorityPaths.grant(grantId)}/receipts`;
|
|
38
|
+
}
|
|
39
|
+
/** Report how an attempt finalized `INDETERMINATE` resolved: `POST`. */
|
|
40
|
+
static reconciliations(grantId) {
|
|
41
|
+
return `${AuthorityPaths.grant(grantId)}/reconciliations`;
|
|
42
|
+
}
|
|
43
|
+
/** One managed escalation: `GET` its state, `DELETE` to cancel it. */
|
|
44
|
+
static escalation(escalationId) {
|
|
45
|
+
return `/v1/authority/escalations/${encodeURIComponent(escalationId)}`;
|
|
46
|
+
}
|
|
47
|
+
/** Where to claim the grant an execution token stands for. */
|
|
48
|
+
static claimFor(executionToken) {
|
|
49
|
+
const grantId = AuthorityPaths.grantIdOf(executionToken);
|
|
50
|
+
return grantId === null ? AuthorityPaths.LEGACY.claimToken : AuthorityPaths.claims(grantId);
|
|
51
|
+
}
|
|
52
|
+
/** Where to record the receipt for the grant an execution token stands for. */
|
|
53
|
+
static receiptFor(executionToken) {
|
|
54
|
+
const grantId = AuthorityPaths.grantIdOf(executionToken);
|
|
55
|
+
return grantId === null
|
|
56
|
+
? AuthorityPaths.LEGACY.finalizeToken
|
|
57
|
+
: AuthorityPaths.receipts(grantId);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The grant id a Decionis execution token names (its `jti`), read without
|
|
61
|
+
* verifying anything: it only addresses the resource, and the authority
|
|
62
|
+
* verifies the token itself and refuses a path whose id is not the
|
|
63
|
+
* token's. Null for a token that is not a JWT or whose `jti` is not a UUID
|
|
64
|
+
* (the only grant id the authority routes), in which case the caller uses
|
|
65
|
+
* the legacy alias.
|
|
66
|
+
*/
|
|
67
|
+
static grantIdOf(executionToken) {
|
|
68
|
+
const parts = executionToken.split(".");
|
|
69
|
+
const payload = parts[1];
|
|
70
|
+
if (parts.length !== 3 || payload === undefined || payload.length === 0)
|
|
71
|
+
return null;
|
|
72
|
+
try {
|
|
73
|
+
const claims = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
74
|
+
const jti = claims?.jti;
|
|
75
|
+
return typeof jti === "string" && GRANT_ID.test(jti) ? jti : null;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** A grant id as the authority mints and routes it: a UUID, which no path segment has to escape. */
|
|
83
|
+
const GRANT_ID = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i;
|
|
84
|
+
//# sourceMappingURL=AuthorityPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthorityPaths.js","sourceRoot":"","sources":["../../src/http/AuthorityPaths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,cAAc;IACzB,8DAA8D;IACvD,MAAM,CAAU,MAAM,GAAG,sBAAsB,CAAC;IAEvD;;;;OAIG;IACI,MAAM,CAAU,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5C,cAAc,EAAE,gCAAgC;QAChD,WAAW,EAAE,4BAA4B;QACzC,UAAU,EAAE,2BAA2B;QACvC,aAAa,EAAE,8BAA8B;KAC9C,CAAC,CAAC;IAEH,wCAAwC;IACjC,MAAM,CAAC,KAAK,CAAC,OAAe;QACjC,OAAO,GAAG,cAAc,CAAC,MAAM,I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ACxC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACrF,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAY,CAAC;YACzF,MAAM,GAAG,GAAI,MAA4C,EAAE,GAAG,CAAC;YAC/D,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;QACpE,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;;AAGH,oGAAoG;AACpG,MAAM,QAAQ,GAAG,4DAA4D,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AuditRecorder } from "../audit/AuditRecorder.js";
|
|
2
|
-
import type { DecisionAuthority, DecisionVerdict } from "../decision/DecisionAuthority.js";
|
|
2
|
+
import type { DecisionAuthority, DecisionEvidence, DecisionVerdict } from "../decision/DecisionAuthority.js";
|
|
3
3
|
import type { CapturedIntent } from "../intent/ExecutionIntent.js";
|
|
4
4
|
export type ShadowObservationStatus = "OBSERVED" | "UNAVAILABLE" | "TIMED_OUT" | "INVALID" | "ABORTED";
|
|
5
5
|
/**
|
|
@@ -53,6 +53,8 @@ export interface ShadowPipelineOptions {
|
|
|
53
53
|
export interface ShadowObserveOptions {
|
|
54
54
|
/** Cancels the observation only; production execution is never cancelled by this pipeline. */
|
|
55
55
|
readonly signal?: AbortSignal;
|
|
56
|
+
/** Evidence the proposal carried, such as a producer's signed signals, observed as the authority would see it. */
|
|
57
|
+
readonly evidence?: DecisionEvidence;
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* Runs an existing production execution unchanged while asking an authority
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShadowPipeline.d.ts","sourceRoot":"","sources":["../../src/shadow/ShadowPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EACV,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"ShadowPipeline.d.ts","sourceRoot":"","sources":["../../src/shadow/ShadowPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAEhB,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GACjC,UAAU,GAAG,aAAa,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,+EAA+E;IAC/E,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,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CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;gBAGlB,SAAS,EAAE,iBAAiB,EAC7C,OAAO,GAAE,qBAA0B;IAarC;;;;OAIG;IACU,OAAO,CAAC,OAAO,EAC1B,QAAQ,EAAE,cAAc,EACxB,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,EACnD,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAW9B,6FAA6F;IAChF,OAAO,CAAC,OAAO,EAC1B,QAAQ,EAAE,cAAc,EACxB,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,EACnD,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IASrC,OAAO,CAAC,QAAQ;YA4CF,MAAM;IAiBpB,OAAO,CAAC,MAAM,CAAC,KAAK;IAWpB,6FAA6F;IAC7F,OAAO,CAAC,MAAM,CAAC,QAAQ;IAyCvB,OAAO,CAAC,MAAM,CAAC,mBAAmB;CAUnC"}
|
|
@@ -31,7 +31,7 @@ export class ShadowPipeline {
|
|
|
31
31
|
* never rejects and never delays production.
|
|
32
32
|
*/
|
|
33
33
|
async observe(captured, existingExecution, options = {}) {
|
|
34
|
-
const observation = this.evaluate(captured, options.signal);
|
|
34
|
+
const observation = this.evaluate(captured, options.signal, options.evidence);
|
|
35
35
|
let production;
|
|
36
36
|
try {
|
|
37
37
|
production = { status: "COMPLETED", result: await existingExecution() };
|
|
@@ -50,7 +50,7 @@ export class ShadowPipeline {
|
|
|
50
50
|
observation: await run.observation,
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
evaluate(captured, signal) {
|
|
53
|
+
evaluate(captured, signal, evidence) {
|
|
54
54
|
const startedAt = this.clock();
|
|
55
55
|
const settled = new Promise((resolve) => {
|
|
56
56
|
let done = false;
|
|
@@ -71,7 +71,7 @@ export class ShadowPipeline {
|
|
|
71
71
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
72
72
|
// Promise.resolve().then isolates a synchronously throwing authority.
|
|
73
73
|
void Promise.resolve()
|
|
74
|
-
.then(async () => await this.authority.evaluate(captured))
|
|
74
|
+
.then(async () => await this.authority.evaluate(captured, evidence))
|
|
75
75
|
.then((decision) => finish(ShadowPipeline.classify(captured, decision)), () => finish(ShadowPipeline.empty("UNAVAILABLE")));
|
|
76
76
|
});
|
|
77
77
|
return settled.then(async (classified) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShadowPipeline.js","sourceRoot":"","sources":["../../src/shadow/ShadowPipeline.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ShadowPipeline.js","sourceRoot":"","sources":["../../src/shadow/ShadowPipeline.ts"],"names":[],"mappings":"AAoEA,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAO1E;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAMN;IALF,KAAK,CAA4B;IACjC,SAAS,CAAS;IAClB,KAAK,CAAe;IAErC,YACmB,SAA4B,EAC7C,UAAiC,EAAE;QADlB,cAAS,GAAT,SAAS,CAAmB;QAG7C,IAAI,SAAS,CAAC,cAAc,KAAK,aAAa,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3E,MAAM,IAAI,KAAK,CAAC,wBAA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AC,CAAC;YACzC,IAAI,QAAQ,IAAI,IAAI,IAAI,QAAQ,KAAK,IAAI;gBAAE,OAAO,KAAK,CAAC;QAC1D,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/dist/testing/Index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@
|
|
|
8
8
|
export { FixtureAuthorizationVerifier, FixtureDecisionAuthority, createFixtureAuthorityPair, type FixtureAuthorityPair, type FixtureCommitRecord, type FixtureVerdictResolver, type UnsafeFixtureAuthorityOptions, } from "../decision/FixtureDecisionAuthority.js";
|
|
9
9
|
export { InMemoryReplayStore } from "../execution/ReplayStore.js";
|
|
10
10
|
export { LocalPresence, LOCAL_PRESENCE_API_KEY, readBody, type LocalAuthenticator, type LocalCeremonyResponse, type LocalPresenceOptions, type LocalPresenceRequestRecord, type LocalReceipt, type LocalReceiptBinding, type LocalReceiptVerification, type LocalVerificationRecord, type LocalVerificationStatus, } from "./LocalPresence.js";
|
|
11
|
-
export { AUTONOMOUS_LIMIT_MINOR, CLAIM_ATTESTATION_TYPE, EFFECT_RECEIPT_TYPE, HUMAN_LIMIT_MINOR, LocalAuthority, LOCAL_AUTHORITY_API_KEY, LOCAL_AUTHORITY_ISSUER, LOCAL_AUTHORITY_JWKS_PATH, hashBinding, stableStringify, type LocalAuthorityOptions, type LocalClaimAttestationClaims, type LocalEffectReceiptCode, type LocalEffectReceiptRecord, type LocalProviderKey, type LocalAuthorityPolicy, type LocalAuthorityRequestRecord, type LocalGrantRecord, type LocalManagedEscalationRecord, type LocalRouteOverride, } from "./LocalAuthority.js";
|
|
11
|
+
export { AUTONOMOUS_LIMIT_MINOR, CLAIM_ATTESTATION_TYPE, EFFECT_RECEIPT_TYPE, HUMAN_LIMIT_MINOR, LocalAuthority, LOCAL_AUTHORITY_API_KEY, LOCAL_AUTHORITY_ISSUER, LOCAL_AUTHORITY_JWKS_PATH, hashBinding, stableStringify, type LocalAuthorityOptions, type LocalClaimAttestationClaims, type LocalEffectReceiptCode, type LocalEffectReceiptRecord, type LocalProviderKey, PROVIDER_KEY_PURPOSES, type LocalAuthorityPolicy, type LocalAuthorityPolicyInput, type LocalProviderKeyPurpose, type LocalAuthorityRequestRecord, type LocalGrantRecord, type LocalManagedEscalationRecord, type LocalRouteOverride, } from "./LocalAuthority.js";
|
|
12
|
+
export { SIGNED_SIGNAL_MAX_LIFETIME_SECONDS, SIGNED_SIGNAL_REFUSAL_CODES, SIGNED_SIGNAL_TYPE, mintSignedSignal, signedSignalFacts, verifySignedSignal, verifySignedSignals, type SignedSignalClaims, type SignedSignalCoverage, type SignedSignalFacts, type SignedSignalIntentView, type SignedSignalKey, type SignedSignalRefusalCode, type SignedSignalVerification, type VerifiedSignedSignal, } from "./SignedSignals.js";
|
|
12
13
|
//# sourceMappingURL=Index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../../src/testing/Index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,GACnC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,QAAQ,EACR,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,GAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,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,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kCAAkC,EAClC,2BAA2B,EAC3B,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC"}
|
package/dist/testing/Index.js
CHANGED
|
@@ -8,5 +8,6 @@
|
|
|
8
8
|
export { FixtureAuthorizationVerifier, FixtureDecisionAuthority, createFixtureAuthorityPair, } from "../decision/FixtureDecisionAuthority.js";
|
|
9
9
|
export { InMemoryReplayStore } from "../execution/ReplayStore.js";
|
|
10
10
|
export { LocalPresence, LOCAL_PRESENCE_API_KEY, readBody, } from "./LocalPresence.js";
|
|
11
|
-
export { AUTONOMOUS_LIMIT_MINOR, CLAIM_ATTESTATION_TYPE, EFFECT_RECEIPT_TYPE, HUMAN_LIMIT_MINOR, LocalAuthority, LOCAL_AUTHORITY_API_KEY, LOCAL_AUTHORITY_ISSUER, LOCAL_AUTHORITY_JWKS_PATH, hashBinding, stableStringify, } from "./LocalAuthority.js";
|
|
11
|
+
export { AUTONOMOUS_LIMIT_MINOR, CLAIM_ATTESTATION_TYPE, EFFECT_RECEIPT_TYPE, HUMAN_LIMIT_MINOR, LocalAuthority, LOCAL_AUTHORITY_API_KEY, LOCAL_AUTHORITY_ISSUER, LOCAL_AUTHORITY_JWKS_PATH, hashBinding, stableStringify, PROVIDER_KEY_PURPOSES, } from "./LocalAuthority.js";
|
|
12
|
+
export { SIGNED_SIGNAL_MAX_LIFETIME_SECONDS, SIGNED_SIGNAL_REFUSAL_CODES, SIGNED_SIGNAL_TYPE, mintSignedSignal, signedSignalFacts, verifySignedSignal, verifySignedSignals, } from "./SignedSignals.js";
|
|
12
13
|
//# sourceMappingURL=Index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../src/testing/Index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,0BAA0B,GAK3B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,QAAQ,GAUT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,WAAW,EACX,eAAe,
|
|
1
|
+
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../src/testing/Index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,0BAA0B,GAK3B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,QAAQ,GAUT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,WAAW,EACX,eAAe,EAMf,qBAAqB,GAQtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kCAAkC,EAClC,2BAA2B,EAC3B,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GASpB,MAAM,oBAAoB,CAAC"}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { type KeyObject } from "node:crypto";
|
|
19
19
|
import { z } from "zod";
|
|
20
20
|
import { type LocalPresence } from "./LocalPresence.js";
|
|
21
|
+
import { type SignedSignalFacts } from "./SignedSignals.js";
|
|
21
22
|
export declare const LOCAL_AUTHORITY_API_KEY = "test-key";
|
|
22
23
|
export declare const AUTONOMOUS_LIMIT_MINOR = 10000;
|
|
23
24
|
export declare const HUMAN_LIMIT_MINOR = 100000;
|
|
@@ -44,6 +45,9 @@ declare const AuthorityRequestSchema: z.ZodObject<{
|
|
|
44
45
|
provider: z.ZodLiteral<"attestation">;
|
|
45
46
|
attestation: z.ZodString;
|
|
46
47
|
}, z.core.$strict>], "provider">>;
|
|
48
|
+
signals: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
49
|
+
token: z.ZodString;
|
|
50
|
+
}, z.core.$strict>>>;
|
|
47
51
|
}, z.core.$strict>>;
|
|
48
52
|
escalation: z.ZodOptional<z.ZodObject<{
|
|
49
53
|
mode: z.ZodLiteral<"MANAGED">;
|
|
@@ -87,6 +91,9 @@ declare const AuthorityRequestSchema: z.ZodObject<{
|
|
|
87
91
|
}, z.core.$strict>;
|
|
88
92
|
expected_effect_digest: z.ZodOptional<z.ZodString>;
|
|
89
93
|
}, z.core.$strict>;
|
|
94
|
+
/** What a registered key may sign, as the hosted `ExecutionProviderKeyPurpose` names it. */
|
|
95
|
+
export declare const PROVIDER_KEY_PURPOSES: readonly ["effect_receipt", "presence_attestation", "usage_report", "signed_signal"];
|
|
96
|
+
export type LocalProviderKeyPurpose = (typeof PROVIDER_KEY_PURPOSES)[number];
|
|
90
97
|
export type LocalAuthorityRequest = z.infer<typeof AuthorityRequestSchema>;
|
|
91
98
|
type Verdict = "ALLOW" | "ESCALATE" | "BLOCK";
|
|
92
99
|
type ManagedStatus = "PENDING_PRESENCE" | "PRESENCE_REQUESTED" | "AWAITING_APPROVER" | "PRESENCE_VERIFIED" | "REAUTHORIZING" | "GRANT_READY" | "EXPIRED" | "REJECTED" | "BLOCKED" | "CANCELLED" | "FAILED";
|
|
@@ -96,7 +103,15 @@ type LifecycleEntry = ManagedStatus | {
|
|
|
96
103
|
};
|
|
97
104
|
type Decision = Record<string, unknown>;
|
|
98
105
|
/** Verdict for an intent evaluated without evidence; evidence handling stays generic. */
|
|
99
|
-
|
|
106
|
+
/**
|
|
107
|
+
* What a policy hook sees: the request, and the facts of every signed signal
|
|
108
|
+
* it carried, verified, under `signed_signals` by name, as the hosted
|
|
109
|
+
* authority writes them under `agent_safe.signed_signals`.
|
|
110
|
+
*/
|
|
111
|
+
export type LocalAuthorityPolicyInput = LocalAuthorityRequest & {
|
|
112
|
+
readonly signed_signals?: Readonly<Record<string, SignedSignalFacts>>;
|
|
113
|
+
};
|
|
114
|
+
export type LocalAuthorityPolicy = (request: LocalAuthorityPolicyInput) => Verdict;
|
|
100
115
|
export interface LocalRouteOverride {
|
|
101
116
|
readonly status?: number;
|
|
102
117
|
readonly body?: unknown;
|
|
@@ -164,6 +179,7 @@ export interface LocalProviderKey {
|
|
|
164
179
|
readonly issuer: string;
|
|
165
180
|
readonly publicKey: KeyObject;
|
|
166
181
|
readonly label: string | null;
|
|
182
|
+
readonly purpose: LocalProviderKeyPurpose;
|
|
167
183
|
}
|
|
168
184
|
export interface LocalManagedEscalationRecord {
|
|
169
185
|
readonly escalationId: string;
|
|
@@ -324,7 +340,17 @@ export declare class LocalAuthority {
|
|
|
324
340
|
readonly issuer: string;
|
|
325
341
|
readonly publicJwk: JsonWebKey;
|
|
326
342
|
readonly label?: string;
|
|
343
|
+
/** What the key may sign; a receipt key by default, as the hosted route defaults. */
|
|
344
|
+
readonly purpose?: LocalProviderKeyPurpose;
|
|
327
345
|
}): void;
|
|
346
|
+
/** The key a signed signal's `kid` names, when it was registered to sign signals. */
|
|
347
|
+
private signedSignalKey;
|
|
348
|
+
/**
|
|
349
|
+
* The signed signals a request carries, verified as the hosted authority
|
|
350
|
+
* verifies them, as facts by name for the policy hook; a refusal names its
|
|
351
|
+
* code, and the route answers it with a 409 like a refused attestation.
|
|
352
|
+
*/
|
|
353
|
+
private signedSignalsOf;
|
|
328
354
|
/**
|
|
329
355
|
* Reads a receipt the way the hosted authority does: the protected header
|
|
330
356
|
* names an Ed25519 key the organisation registered; the signature verifies
|
|
@@ -347,6 +373,14 @@ export declare class LocalAuthority {
|
|
|
347
373
|
/** Statuses returned, in order, for the next managed escalation instead of orchestration. */
|
|
348
374
|
scriptNextManagedLifecycle(statuses: readonly LifecycleEntry[]): void;
|
|
349
375
|
private handle;
|
|
376
|
+
/** A grant resource addressed by an id that is not the presented token's grant: refused, as hosted. */
|
|
377
|
+
private grantIdMismatch;
|
|
378
|
+
/**
|
|
379
|
+
* `POST /v1/authority/grants/{grantId}/reconciliations`: how an attempt
|
|
380
|
+
* finalized `INDETERMINATE` resolved, from the executor that claimed it.
|
|
381
|
+
* Recorded once; the grant is never reopened.
|
|
382
|
+
*/
|
|
383
|
+
private reconcile;
|
|
350
384
|
/** `POST /v1/execution/provider-keys`: the public half only, or a 400 naming why. */
|
|
351
385
|
private registerProviderKeyRoute;
|
|
352
386
|
private enforceAndBind;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalAuthority.d.ts","sourceRoot":"","sources":["../../src/testing/LocalAuthority.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"LocalAuthority.d.ts","sourceRoot":"","sources":["../../src/testing/LocalAuthority.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAClE,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kHhB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAIzB,+EAA+E;IAC/E,OAAO,CAAC,aAAa;YAiBP,OAAO;IAmCrB,OAAO,CAAC,IAAI;IAYZ,OAAO,CAAC,MAAM,CAAC,UAAU;CAU1B"}
|
|
@@ -19,6 +19,7 @@ import { createHash, createPublicKey, generateKeyPairSync, randomBytes, randomUU
|
|
|
19
19
|
import { createServer } from "node:http";
|
|
20
20
|
import { z } from "zod";
|
|
21
21
|
import { readBody } from "./LocalPresence.js";
|
|
22
|
+
import { verifySignedSignals, } from "./SignedSignals.js";
|
|
22
23
|
export const LOCAL_AUTHORITY_API_KEY = "test-key";
|
|
23
24
|
export const AUTONOMOUS_LIMIT_MINOR = 10_000;
|
|
24
25
|
export const HUMAN_LIMIT_MINOR = 100_000;
|
|
@@ -173,6 +174,12 @@ const AuthorityEvidenceSchema = z.strictObject({
|
|
|
173
174
|
}),
|
|
174
175
|
])
|
|
175
176
|
.optional(),
|
|
177
|
+
/** A producer's signed standing signals (`SignedSignalEvidence`), at most eight. */
|
|
178
|
+
signals: z
|
|
179
|
+
.array(z.strictObject({ token: z.string().max(20_000).regex(COMPACT_JWS) }))
|
|
180
|
+
.min(1)
|
|
181
|
+
.max(8)
|
|
182
|
+
.optional(),
|
|
176
183
|
});
|
|
177
184
|
/** `ExecutionAuthorityRequest`: the binding plus hash, mode, evidence, and managed constraints. */
|
|
178
185
|
const AuthorityRequestSchema = z.strictObject({
|
|
@@ -206,6 +213,22 @@ const FinalizeRequestSchema = z.strictObject({
|
|
|
206
213
|
// is verified and recorded, never a reason to refuse the finalization.
|
|
207
214
|
effect_receipt: z.string().min(1).max(20_000).regex(COMPACT_JWS).optional(),
|
|
208
215
|
});
|
|
216
|
+
const ReconcileRequestSchema = z.strictObject({
|
|
217
|
+
execution_token: z.string().min(1).max(20_000),
|
|
218
|
+
claim_token: z.string().regex(/^[\w-]{43,128}$/),
|
|
219
|
+
commit_correlation_id: boundedId,
|
|
220
|
+
outcome: z.enum(["COMMITTED", "FAILED"]),
|
|
221
|
+
reconciliation_note: z.string().min(1).max(2_000).optional(),
|
|
222
|
+
downstream_evidence: z.record(z.string(), z.unknown()).optional(),
|
|
223
|
+
effect_evidence: z.unknown().optional(),
|
|
224
|
+
});
|
|
225
|
+
/** What a registered key may sign, as the hosted `ExecutionProviderKeyPurpose` names it. */
|
|
226
|
+
export const PROVIDER_KEY_PURPOSES = [
|
|
227
|
+
"effect_receipt",
|
|
228
|
+
"presence_attestation",
|
|
229
|
+
"usage_report",
|
|
230
|
+
"signed_signal",
|
|
231
|
+
];
|
|
209
232
|
/** `ExecutionProviderKeyRegistrationRequest`: the public half of an Ed25519 key. */
|
|
210
233
|
const ProviderKeyRegistrationSchema = z.strictObject({
|
|
211
234
|
org_id: z.uuid().optional(),
|
|
@@ -221,6 +244,7 @@ const ProviderKeyRegistrationSchema = z.strictObject({
|
|
|
221
244
|
use: z.literal("sig").optional(),
|
|
222
245
|
}),
|
|
223
246
|
label: z.string().max(200).optional(),
|
|
247
|
+
purpose: z.enum(PROVIDER_KEY_PURPOSES).optional(),
|
|
224
248
|
});
|
|
225
249
|
const BINDING_KEYS = Object.keys(IntentBindingSchema.shape);
|
|
226
250
|
function effectStatus(value) {
|
|
@@ -392,7 +416,37 @@ export class LocalAuthority {
|
|
|
392
416
|
issuer: input.issuer,
|
|
393
417
|
publicKey: createPublicKey({ key: input.publicJwk, format: "jwk" }),
|
|
394
418
|
label: input.label ?? null,
|
|
419
|
+
purpose: input.purpose ?? "effect_receipt",
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
/** The key a signed signal's `kid` names, when it was registered to sign signals. */
|
|
423
|
+
signedSignalKey(kid) {
|
|
424
|
+
const key = this.providerKeys.get(kid);
|
|
425
|
+
return key !== undefined && key.purpose === "signed_signal"
|
|
426
|
+
? { kid: key.kid, issuer: key.issuer, publicKey: key.publicKey }
|
|
427
|
+
: null;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* The signed signals a request carries, verified as the hosted authority
|
|
431
|
+
* verifies them, as facts by name for the policy hook; a refusal names its
|
|
432
|
+
* code, and the route answers it with a 409 like a refused attestation.
|
|
433
|
+
*/
|
|
434
|
+
signedSignalsOf(request) {
|
|
435
|
+
const signals = request.evidence?.signals;
|
|
436
|
+
if (signals === undefined)
|
|
437
|
+
return { facts: undefined };
|
|
438
|
+
const verification = verifySignedSignals(signals.map((signal) => signal.token), {
|
|
439
|
+
orgId: request.tenant_id,
|
|
440
|
+
findKey: (kid) => this.signedSignalKey(kid),
|
|
441
|
+
intent: {
|
|
442
|
+
action: request.action.type,
|
|
443
|
+
actorId: request.actor.id,
|
|
444
|
+
resource: request.action.resource,
|
|
445
|
+
parameters: request.action.parameters,
|
|
446
|
+
},
|
|
447
|
+
nowMs: this.clock(),
|
|
395
448
|
});
|
|
449
|
+
return verification.ok ? { facts: verification.facts } : { refused: verification.code };
|
|
396
450
|
}
|
|
397
451
|
/**
|
|
398
452
|
* Reads a receipt the way the hosted authority does: the protected header
|
|
@@ -584,9 +638,25 @@ export class LocalAuthority {
|
|
|
584
638
|
if (req.headers["content-type"] !== "application/json") {
|
|
585
639
|
return this.send(res, record, 415, { error: "UNSUPPORTED_MEDIA_TYPE" });
|
|
586
640
|
}
|
|
641
|
+
// The grant's REST resources, as the hosted authority serves them: the
|
|
642
|
+
// path names the grant by its id, which must be the presented token's.
|
|
643
|
+
const grantResource = url.pathname.match(/^\/v1\/authority\/grants\/([^/]+)\/(claims|receipts|reconciliations)$/);
|
|
644
|
+
if (grantResource !== null) {
|
|
645
|
+
const mismatch = this.grantIdMismatch(record, decodeURIComponent(grantResource[1] ?? ""));
|
|
646
|
+
if (mismatch !== null)
|
|
647
|
+
return this.send(res, record, 409, mismatch);
|
|
648
|
+
if (grantResource[2] === "claims") {
|
|
649
|
+
return this.respond(res, record, "claim", this.claim(record));
|
|
650
|
+
}
|
|
651
|
+
if (grantResource[2] === "receipts") {
|
|
652
|
+
return this.respond(res, record, "finalize", this.finalize(record));
|
|
653
|
+
}
|
|
654
|
+
return this.send(res, record, ...this.reconcile(record));
|
|
655
|
+
}
|
|
587
656
|
switch (url.pathname) {
|
|
588
657
|
case "/v1/execution/provider-keys":
|
|
589
658
|
return this.send(res, record, ...this.registerProviderKeyRoute(record));
|
|
659
|
+
case "/v1/authority/grants":
|
|
590
660
|
case "/v1/authority/enforce-and-bind":
|
|
591
661
|
return this.respond(res, record, "enforce", this.enforceAndBind(record));
|
|
592
662
|
case "/v1/execution/claim-token":
|
|
@@ -598,6 +668,48 @@ export class LocalAuthority {
|
|
|
598
668
|
return this.send(res, record, 404, { error: "NOT_FOUND" });
|
|
599
669
|
}
|
|
600
670
|
}
|
|
671
|
+
/** A grant resource addressed by an id that is not the presented token's grant: refused, as hosted. */
|
|
672
|
+
grantIdMismatch(record, grantId) {
|
|
673
|
+
const token = record.body?.execution_token;
|
|
674
|
+
const grant = typeof token === "string" ? this.grants.get(token) : undefined;
|
|
675
|
+
if (grant === undefined || grant.jti === grantId)
|
|
676
|
+
return null;
|
|
677
|
+
return { valid: false, reason_codes: ["GRANT_ID_MISMATCH"] };
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* `POST /v1/authority/grants/{grantId}/reconciliations`: how an attempt
|
|
681
|
+
* finalized `INDETERMINATE` resolved, from the executor that claimed it.
|
|
682
|
+
* Recorded once; the grant is never reopened.
|
|
683
|
+
*/
|
|
684
|
+
reconcile(record) {
|
|
685
|
+
const parsed = ReconcileRequestSchema.safeParse(record.body);
|
|
686
|
+
if (!parsed.success)
|
|
687
|
+
return [400, { error: "REQUEST_INVALID" }];
|
|
688
|
+
const refused = (reasonCode) => [
|
|
689
|
+
409,
|
|
690
|
+
{ reconciled: false, reason_codes: [reasonCode] },
|
|
691
|
+
];
|
|
692
|
+
const grant = this.grants.get(parsed.data.execution_token);
|
|
693
|
+
if (grant === undefined)
|
|
694
|
+
return refused("GRANT_INVALID");
|
|
695
|
+
if (!grant.claimed || grant.claimToken !== parsed.data.claim_token) {
|
|
696
|
+
return refused("NONCE_REPLAY_DETECTED");
|
|
697
|
+
}
|
|
698
|
+
if (grant.correlationId !== parsed.data.commit_correlation_id) {
|
|
699
|
+
return refused("EXECUTION_CORRELATION_MISMATCH");
|
|
700
|
+
}
|
|
701
|
+
if (grant.finalized !== "INDETERMINATE")
|
|
702
|
+
return refused("EXECUTION_NOT_INDETERMINATE");
|
|
703
|
+
grant.finalized = parsed.data.outcome;
|
|
704
|
+
return [
|
|
705
|
+
200,
|
|
706
|
+
{
|
|
707
|
+
reconciled: true,
|
|
708
|
+
resolution: parsed.data.outcome === "COMMITTED" ? "FINALIZED" : "FAILED",
|
|
709
|
+
reason_codes: [],
|
|
710
|
+
},
|
|
711
|
+
];
|
|
712
|
+
}
|
|
601
713
|
/** `POST /v1/execution/provider-keys`: the public half only, or a 400 naming why. */
|
|
602
714
|
registerProviderKeyRoute(record) {
|
|
603
715
|
const parsed = ProviderKeyRegistrationSchema.safeParse(record.body);
|
|
@@ -609,6 +721,7 @@ export class LocalAuthority {
|
|
|
609
721
|
issuer: body.issuer,
|
|
610
722
|
publicJwk: { kty: body.public_jwk.kty, crv: body.public_jwk.crv, x: body.public_jwk.x },
|
|
611
723
|
...(body.label === undefined ? {} : { label: body.label }),
|
|
724
|
+
...(body.purpose === undefined ? {} : { purpose: body.purpose }),
|
|
612
725
|
});
|
|
613
726
|
return [
|
|
614
727
|
201,
|
|
@@ -715,7 +828,11 @@ export class LocalAuthority {
|
|
|
715
828
|
}
|
|
716
829
|
/** Policy plus evidence handling: a valid receipt turns an escalation into an allow. */
|
|
717
830
|
evaluate(request) {
|
|
718
|
-
const
|
|
831
|
+
const signed = this.signedSignalsOf(request);
|
|
832
|
+
if ("refused" in signed) {
|
|
833
|
+
return { status: "BLOCK", reasonCode: signed.refused, approval: null, error: signed.refused };
|
|
834
|
+
}
|
|
835
|
+
const verdict = this.policy(signed.facts === undefined ? request : { ...request, signed_signals: signed.facts });
|
|
719
836
|
if (verdict === "BLOCK") {
|
|
720
837
|
return { status: "BLOCK", reasonCode: "POLICY_HARD_LIMIT_EXCEEDED", approval: null };
|
|
721
838
|
}
|
|
@@ -1050,7 +1167,10 @@ export class LocalAuthority {
|
|
|
1050
1167
|
if (!verification.ok)
|
|
1051
1168
|
return done("FAILED", ["PRESENCE_VERIFICATION_FAILED", verification.reasonCode]);
|
|
1052
1169
|
// PRESENCE_VERIFIED and REAUTHORIZING are passed through within one lookup, as Decionis does.
|
|
1053
|
-
const
|
|
1170
|
+
const signed = this.signedSignalsOf(managed.request);
|
|
1171
|
+
const reevaluated = this.policy("refused" in signed || signed.facts === undefined
|
|
1172
|
+
? managed.request
|
|
1173
|
+
: { ...managed.request, signed_signals: signed.facts });
|
|
1054
1174
|
if (reevaluated === "BLOCK")
|
|
1055
1175
|
return done("BLOCKED", ["REAUTHORIZATION_BLOCKED"]);
|
|
1056
1176
|
return done("GRANT_READY", ["PRESENCE_RECEIPT_VERIFIED"]);
|