@agenticprimitives/admission 0.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/digests.d.ts +46 -0
- package/dist/digests.d.ts.map +1 -0
- package/dist/digests.js +164 -0
- package/dist/digests.js.map +1 -0
- package/dist/engine.d.ts +51 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +224 -0
- package/dist/engine.js.map +1 -0
- package/dist/execution.d.ts +53 -0
- package/dist/execution.d.ts.map +1 -0
- package/dist/execution.js +166 -0
- package/dist/execution.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/invariants.d.ts +80 -0
- package/dist/invariants.d.ts.map +1 -0
- package/dist/invariants.js +288 -0
- package/dist/invariants.js.map +1 -0
- package/dist/ports.d.ts +149 -0
- package/dist/ports.d.ts.map +1 -0
- package/dist/ports.js +9 -0
- package/dist/ports.js.map +1 -0
- package/dist/request-proof.d.ts +61 -0
- package/dist/request-proof.d.ts.map +1 -0
- package/dist/request-proof.js +175 -0
- package/dist/request-proof.js.map +1 -0
- package/dist/transport-policy.d.ts +47 -0
- package/dist/transport-policy.d.ts.map +1 -0
- package/dist/transport-policy.js +95 -0
- package/dist/transport-policy.js.map +1 -0
- package/dist/types.d.ts +430 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +28 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// The non-equivalences, as executable checks (spec 339 §5.2, §21.5).
|
|
2
|
+
//
|
|
3
|
+
// WHY CODE AND NOT PROSE. The architecture's central claims are all of the form "X is not Y" —
|
|
4
|
+
// a certificate is not an owner, a SPIFFE ID is not an agent, a grant is not a tool permission. Those
|
|
5
|
+
// survive review and then die in implementation, because the mistake never looks like a mistake: it
|
|
6
|
+
// looks like `if (req.transport.mtls) { /* trusted peer */ }`, written by someone in a hurry who had
|
|
7
|
+
// a genuinely authenticated TLS connection in front of them.
|
|
8
|
+
//
|
|
9
|
+
// A type cannot catch that — `mtls: true` is a perfectly good boolean. So the checks live here, run
|
|
10
|
+
// fail-closed, and every one of them corresponds to a specific way the layers get collapsed.
|
|
11
|
+
//
|
|
12
|
+
// These are STRUCTURAL. They prove a request is coherent enough to be worth evaluating; they never
|
|
13
|
+
// prove it should be admitted. Passing every check here and then admitting would be its own instance
|
|
14
|
+
// of the mistake, so nothing in this file returns anything resembling "allow".
|
|
15
|
+
/**
|
|
16
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
17
|
+
* An agent id IS an ERC-4337 Smart Agent address. Not a URN, not a name.
|
|
18
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
19
|
+
*
|
|
20
|
+
* ADR-0010: every person, org and service IS its ERC-4337 SA address; names, profiles, registry
|
|
21
|
+
* entries and handles are facets pointing AT it. `@agenticprimitives/types` carries both forms —
|
|
22
|
+
* `CanonicalAgentIdentity` (the within-chain `Address`) and `CanonicalAgentId` (the chain-qualified
|
|
23
|
+
* CAIP-10 `namespace:reference:address`).
|
|
24
|
+
*
|
|
25
|
+
* SPEC 339 AS AUTHORED USES `urn:ap:agent:<org>:<name>`. That convention is fine for a greenfield
|
|
26
|
+
* system and wrong here, because a URN is a NAME: it is assigned by whoever runs the namespace, it can
|
|
27
|
+
* be reassigned, and nothing about holding one proves control of anything. Building admission on it
|
|
28
|
+
* would put a naming authority underneath the authority model — the exact inversion ADR-0010 exists to
|
|
29
|
+
* prevent, and it would quietly decouple admission from the ERC-4337 account that actually signs.
|
|
30
|
+
*
|
|
31
|
+
* So the check below is the ERC-4337 anchor: a principal or acting agent id must be CAIP-10 ending in
|
|
32
|
+
* a 20-byte address. There is deliberately no "name resolution" fallback — resolving a name here would
|
|
33
|
+
* make admission depend on a registry lookup that can return a different answer tomorrow (ADR-0013).
|
|
34
|
+
*
|
|
35
|
+
* `runtimeId` is EXEMPT and that is intentional. A runtime is a deployment, not an account; it need
|
|
36
|
+
* not have an SA, and requiring one would force every process to be an on-chain identity.
|
|
37
|
+
*/
|
|
38
|
+
const CAIP10_ADDRESS = /^[a-z0-9-]+:[a-zA-Z0-9._-]+:0x[0-9a-fA-F]{40}$/;
|
|
39
|
+
/** Does this id name an ERC-4337 Smart Agent, chain-qualified? */
|
|
40
|
+
export function isCanonicalAgentId(id) {
|
|
41
|
+
return CAIP10_ADDRESS.test(id);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The address an agent id resolves to, or `null`.
|
|
45
|
+
*
|
|
46
|
+
* Pure parsing — never a registry read. `null` means "this is not an agent id", never "look it up".
|
|
47
|
+
*/
|
|
48
|
+
export function agentAddressOf(id) {
|
|
49
|
+
return CAIP10_ADDRESS.test(id) ? id.split(':').pop().toLowerCase() : null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
53
|
+
* OAuth authenticates a CLIENT. A signed proof authenticates a PRINCIPAL.
|
|
54
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
55
|
+
*
|
|
56
|
+
* THIS REPO'S BINDING POSITION, narrower than spec 339's source text (see ADR-0057 §"OAuth is
|
|
57
|
+
* subordinate", and ADR-0041 which established it for the A2A→MCP hop):
|
|
58
|
+
*
|
|
59
|
+
* Spec 339 as authored treats OAuth/OIDC and the signed Agentic request proof as co-equal application
|
|
60
|
+
* authentication. On this substrate they are not, and treating them as interchangeable is how the
|
|
61
|
+
* ERC-1271 authority model gets replaced by an issuer-granted scope without anyone deciding to.
|
|
62
|
+
*
|
|
63
|
+
* OAuth bearer → an IdP asserts a client obtained a token. Nothing is signed by the principal's
|
|
64
|
+
* Smart Agent. It is an ingress ENVELOPE: it may carry a principal claim and a
|
|
65
|
+
* grant reference, never delegation payload or field-level authority.
|
|
66
|
+
*
|
|
67
|
+
* Request proof → the principal's own key signed THIS request. Verified through
|
|
68
|
+
* `UniversalSignatureValidator` — ERC-1271 / ERC-6492 / ECDSA / WebAuthn — so
|
|
69
|
+
* it is not a competing mechanism, it IS the substrate's mechanism at the HTTP
|
|
70
|
+
* layer. SA-bound, signature-verified, on-chain revocable.
|
|
71
|
+
*
|
|
72
|
+
* The consequence enforced below: an operation that CLAIMS AUTHORITY (cites delegations or
|
|
73
|
+
* entitlements) requires principal authentication. OAuth alone can carry a request through the door;
|
|
74
|
+
* it can never be the thing that says a principal delegated anything.
|
|
75
|
+
*
|
|
76
|
+
* ADR-0013 applies too: these are not a fallback chain. A failed proof does not degrade to
|
|
77
|
+
* "well, the OAuth token was valid" — it denies.
|
|
78
|
+
*/
|
|
79
|
+
export function hasPrincipalAuthentication(req) {
|
|
80
|
+
// Only a signature by the principal's own key qualifies. Deliberately not "oauth ?? proof".
|
|
81
|
+
return !!req.authentication.requestProof;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Does this request claim authority to act, as opposed to merely asking to be heard?
|
|
85
|
+
*
|
|
86
|
+
* Citing a delegation or an entitlement IS the claim. A request that cites neither may still be
|
|
87
|
+
* admitted (a public capability, a challenge exchange) — it just cannot later be used to justify
|
|
88
|
+
* acting on someone's behalf.
|
|
89
|
+
*/
|
|
90
|
+
export function claimsAuthority(req) {
|
|
91
|
+
return req.delegationRefs.length > 0 || req.entitlementRefs.length > 0;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Was the calling execution context authenticated AT THE APPLICATION LAYER?
|
|
95
|
+
*
|
|
96
|
+
* The question exists because transport evidence is so tempting to answer it with. A valid client
|
|
97
|
+
* certificate authenticates a connection; it says nothing about which principal is on the other end of
|
|
98
|
+
* it, and a deployment that treats mTLS as login has replaced its authority model with its network
|
|
99
|
+
* topology.
|
|
100
|
+
*/
|
|
101
|
+
export function hasApplicationAuthentication(req) {
|
|
102
|
+
return !!(req.authentication.oauth ?? req.authentication.requestProof);
|
|
103
|
+
}
|
|
104
|
+
/** Derive assurance from what was actually validated, rather than trusting a self-reported label. */
|
|
105
|
+
export function observedTransportAssurance(e) {
|
|
106
|
+
if (!e || !e.mtls)
|
|
107
|
+
return 'HTTPS';
|
|
108
|
+
if (e.validation.certificateValid !== true)
|
|
109
|
+
return 'HTTPS'; // unverified cert proves nothing
|
|
110
|
+
if (e.workloadBinding && e.validation.workloadBindingValid === true)
|
|
111
|
+
return 'SPIFFE_MTLS';
|
|
112
|
+
return 'MTLS';
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Structural coherence of an admission request. Empty means coherent, NOT admissible.
|
|
116
|
+
*
|
|
117
|
+
* Every violation below is a layer collapse someone has shipped in production somewhere.
|
|
118
|
+
*/
|
|
119
|
+
export function checkAdmissionInvariants(req) {
|
|
120
|
+
const out = [];
|
|
121
|
+
const t = req.authentication.optionalTransportEvidence;
|
|
122
|
+
// ── Transport is never authentication ────────────────────────────────────
|
|
123
|
+
if (!hasApplicationAuthentication(req)) {
|
|
124
|
+
out.push({
|
|
125
|
+
code: 'OAUTH_TOKEN_REQUIRED',
|
|
126
|
+
detail: 'no OAuth token and no request proof — a TLS connection, mutual or not, authenticates no principal',
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// An OAuth token that carries authority payload has already drifted inward. Scopes describe what a
|
|
130
|
+
// client asked its IdP for; they are not a delegation, and a boundary that reads them as one has
|
|
131
|
+
// swapped an SA-bound, on-chain-revocable grant for an opaque issuer assertion (ADR-0041).
|
|
132
|
+
const scopes = req.authentication.oauth?.scopes ?? [];
|
|
133
|
+
const authorityShapedScope = scopes.find((s) => /^(delegation|entitlement|vault):/i.test(s));
|
|
134
|
+
if (authorityShapedScope) {
|
|
135
|
+
out.push({
|
|
136
|
+
code: 'PRINCIPAL_AUTHENTICATION_REQUIRED',
|
|
137
|
+
detail: `scope "${authorityShapedScope}" encodes authority — scopes are transport envelope, not delegation`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
// ── Agent ids are ERC-4337 accounts, not names ───────────────────────────
|
|
141
|
+
// Checked before anything else reads them: every downstream decision — delegation lookup, signature
|
|
142
|
+
// verification, revocation — is against an ACCOUNT. An id that is not one cannot be any of those.
|
|
143
|
+
for (const [field, id] of [
|
|
144
|
+
['principalAgentId', req.actor.principalAgentId],
|
|
145
|
+
['actingAgentId', req.actor.actingAgentId],
|
|
146
|
+
['targetAgentId', req.targetAgentId],
|
|
147
|
+
]) {
|
|
148
|
+
if (!isCanonicalAgentId(id)) {
|
|
149
|
+
out.push({
|
|
150
|
+
code: 'NON_CANONICAL_AGENT_ID',
|
|
151
|
+
detail: `${field} "${id}" is not a CAIP-10 Smart Agent address — a name is a facet, never the identity (ADR-0010)`,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// ── OAuth is an envelope, never authority ────────────────────────────────
|
|
156
|
+
if (claimsAuthority(req) && !hasPrincipalAuthentication(req)) {
|
|
157
|
+
// The collapse this catches: a valid OAuth token plus a delegation REFERENCE, read as "the
|
|
158
|
+
// principal delegated this". It did not — an IdP said a client holds a token. Nothing in that
|
|
159
|
+
// chain is signed by the principal's Smart Agent, which is the only thing that can delegate
|
|
160
|
+
// (ADR-0041, ADR-0010).
|
|
161
|
+
out.push({
|
|
162
|
+
code: 'PRINCIPAL_AUTHENTICATION_REQUIRED',
|
|
163
|
+
detail: 'request cites delegation/entitlement authority but carries no principal-signed proof — ' +
|
|
164
|
+
'an OAuth bearer authenticates a client, never a principal',
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
// A self-reported assurance above what was validated is the quiet version of the same error.
|
|
168
|
+
const observed = observedTransportAssurance(t);
|
|
169
|
+
const claimed = req.transport.assurance;
|
|
170
|
+
const RANK = { HTTPS: 0, MTLS: 1, SPIFFE_MTLS: 2 };
|
|
171
|
+
if (RANK[claimed] > RANK[observed]) {
|
|
172
|
+
out.push({
|
|
173
|
+
code: 'CLIENT_CERTIFICATE_INVALID',
|
|
174
|
+
detail: `request claims ${claimed} but only ${observed} was validated`,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (req.transport.mtls !== (t?.mtls ?? false)) {
|
|
178
|
+
out.push({
|
|
179
|
+
code: 'CLIENT_CERTIFICATE_INVALID',
|
|
180
|
+
detail: 'transport.mtls disagrees with the evidence it summarizes',
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
// ── A workload identifier is not an agent ────────────────────────────────
|
|
184
|
+
if (t?.workloadIdentifier && !t.workloadBinding) {
|
|
185
|
+
// The SPIFFE-as-identity mistake, exactly: a trust-domain path is not a statement about which
|
|
186
|
+
// agent a process may act as. Somebody has to have signed that, and that signature IS the binding.
|
|
187
|
+
out.push({
|
|
188
|
+
code: 'WORKLOAD_BINDING_NOT_FOUND',
|
|
189
|
+
detail: 'workload identifier presented with no binding — an agent may not be inferred from a trust-domain path',
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
if (t?.workloadBinding && t.workloadBinding.status !== 'ACTIVE') {
|
|
193
|
+
out.push({
|
|
194
|
+
code: 'WORKLOAD_BINDING_REVOKED',
|
|
195
|
+
detail: `workload binding is ${t.workloadBinding.status}`,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
if (t?.workloadBinding && t.workloadBinding.bindsAgentId !== req.actor.actingAgentId) {
|
|
199
|
+
out.push({
|
|
200
|
+
code: 'CANONICAL_AGENT_MISMATCH',
|
|
201
|
+
detail: 'workload binding names a different agent than the resolved actor',
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (t?.workloadBinding && t.workloadBinding.bindsRuntimeId !== req.actor.runtimeId) {
|
|
205
|
+
out.push({
|
|
206
|
+
code: 'RUNTIME_BINDING_MISMATCH',
|
|
207
|
+
detail: 'workload binding names a different runtime than the resolved actor',
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
// ── Resolution must have happened ────────────────────────────────────────
|
|
211
|
+
if (req.actor.authenticationMethods.length === 0) {
|
|
212
|
+
out.push({
|
|
213
|
+
code: 'APPLICATION_IDENTITY_BINDING_NOT_FOUND',
|
|
214
|
+
detail: 'actor carries no authentication method — it was asserted, not resolved',
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
// ── A proof must be about THIS request ───────────────────────────────────
|
|
218
|
+
const proof = req.authentication.requestProof;
|
|
219
|
+
if (proof) {
|
|
220
|
+
const c = proof.claims;
|
|
221
|
+
if (c.actingAgentId !== req.actor.actingAgentId || c.principalAgentId !== req.actor.principalAgentId) {
|
|
222
|
+
out.push({
|
|
223
|
+
code: 'CANONICAL_AGENT_MISMATCH',
|
|
224
|
+
detail: 'request proof names a different actor than the one resolved',
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
if (c.a2a.operation !== req.a2a.operation) {
|
|
228
|
+
out.push({
|
|
229
|
+
code: 'REQUEST_PROOF_INVALID',
|
|
230
|
+
detail: 'request proof was signed over a different A2A operation',
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
// RFC 8705: a certificate-bound proof presented without that certificate is not bound to anything.
|
|
234
|
+
if (c.transportConfirmation && c.transportConfirmation.certificateThumbprint !== t?.clientCertificateSha256) {
|
|
235
|
+
out.push({
|
|
236
|
+
code: 'CERTIFICATE_TOKEN_BINDING_MISMATCH',
|
|
237
|
+
detail: 'proof is certificate-bound but the presented certificate differs',
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Is this invocation INSIDE the grant's ceiling?
|
|
245
|
+
*
|
|
246
|
+
* READ THE RETURN VALUE CAREFULLY: `[]` means the grant does not forbid this call. It does NOT mean
|
|
247
|
+
* the call is authorized. Delegation and entitlement are re-checked live at the gateway, because they
|
|
248
|
+
* can be revoked between admission and invocation — and that window is exactly when revocation has to
|
|
249
|
+
* work (spec 339 §21.5).
|
|
250
|
+
*/
|
|
251
|
+
export function checkInvocationAgainstGrant(grant, invocation, now = new Date()) {
|
|
252
|
+
const out = [];
|
|
253
|
+
if (invocation.admissionGrantId !== grant.grantId) {
|
|
254
|
+
out.push({ code: 'MCP_OPERATION_NOT_AUTHORIZED', detail: 'invocation cites a different grant' });
|
|
255
|
+
return out; // Nothing else is meaningful against the wrong grant.
|
|
256
|
+
}
|
|
257
|
+
if (Date.parse(grant.expiresAt) <= now.getTime()) {
|
|
258
|
+
out.push({ code: 'MCP_OPERATION_NOT_AUTHORIZED', detail: 'grant has expired' });
|
|
259
|
+
}
|
|
260
|
+
// The actor may not change between admission and invocation.
|
|
261
|
+
if (invocation.principalAgentId !== grant.principalAgentId ||
|
|
262
|
+
invocation.actingAgentId !== grant.actingAgentId ||
|
|
263
|
+
invocation.runtimeId !== grant.runtimeId) {
|
|
264
|
+
out.push({ code: 'CANONICAL_AGENT_MISMATCH', detail: 'invocation actor differs from the admitted actor' });
|
|
265
|
+
}
|
|
266
|
+
// An empty ceiling admits nothing. Fail-closed: absence of a list is not a wildcard.
|
|
267
|
+
if (grant.permittedCapabilityIds.length === 0) {
|
|
268
|
+
out.push({
|
|
269
|
+
code: 'CAPABILITY_NOT_ADMITTED',
|
|
270
|
+
detail: 'grant permits no capabilities — an empty ceiling is empty, not unlimited',
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (!invocation.canonicalArgumentsDigest) {
|
|
274
|
+
out.push({
|
|
275
|
+
code: 'EXACT_INVOCATION_PROOF_REQUIRED',
|
|
276
|
+
detail: 'no canonical arguments digest — the gateway would be authorizing an operation name, not a call',
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
if (invocation.delegationRefs.length === 0) {
|
|
280
|
+
// The grant got them through the door. It is not itself the authority to act.
|
|
281
|
+
out.push({
|
|
282
|
+
code: 'MCP_OPERATION_NOT_AUTHORIZED',
|
|
283
|
+
detail: 'no delegation presented at invocation — a grant is admission, not authority',
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
return out;
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=invariants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariants.js","sourceRoot":"","sources":["../src/invariants.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,+FAA+F;AAC/F,sGAAsG;AACtG,oGAAoG;AACpG,qGAAqG;AACrG,6DAA6D;AAC7D,EAAE;AACF,oGAAoG;AACpG,6FAA6F;AAC7F,EAAE;AACF,mGAAmG;AACnG,qGAAqG;AACrG,+EAA+E;AA4C/E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,cAAc,GAAG,gDAAgD,CAAC;AAExE,kEAAkE;AAClE,MAAM,UAAU,kBAAkB,CAAC,EAAU;IAC3C,OAAO,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,OAAO,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAa,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACxF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAqB;IAC9D,4FAA4F;IAC5F,OAAO,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,GAAqB;IACnD,OAAO,GAAG,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAAC,GAAqB;IAChE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,IAAI,GAAG,CA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
|
1
|
+
import type { AdmissionDecision, AdmissionPolicyContribution, AdmissionRequest, CanonicalActorContext, ExactMcpInvocationRequest, ExecutionDecision, OAuthEvidence, OptionalTransportEvidence, RequestProofEvidence, ApplicationAuthenticationMethod, WorkloadIdentifier, WorkloadIdentityBinding } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates the calling execution context.
|
|
4
|
+
*
|
|
5
|
+
* Returns `subjectHints` — CLAIMS, not conclusions. Naming them hints is the guardrail: an
|
|
6
|
+
* authenticated subject is not a resolved agent, and a field called `principalAgentId` sitting on an
|
|
7
|
+
* authenticator's output is exactly how that line gets crossed by accident.
|
|
8
|
+
*/
|
|
9
|
+
export interface ApplicationAuthenticator {
|
|
10
|
+
readonly method: ApplicationAuthenticationMethod;
|
|
11
|
+
authenticate(input: {
|
|
12
|
+
headers: Headers;
|
|
13
|
+
method: string;
|
|
14
|
+
authority: string;
|
|
15
|
+
pathAndQuery: string;
|
|
16
|
+
rawBody: Uint8Array;
|
|
17
|
+
optionalTransportEvidence?: OptionalTransportEvidence;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
oauth?: OAuthEvidence;
|
|
20
|
+
requestProof?: RequestProofEvidence;
|
|
21
|
+
subjectHints: {
|
|
22
|
+
principalAgentId?: string;
|
|
23
|
+
actingAgentId?: string;
|
|
24
|
+
runtimeId?: string;
|
|
25
|
+
};
|
|
26
|
+
evidenceRefs: string[];
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Turns evidence into a canonical actor.
|
|
31
|
+
*
|
|
32
|
+
* `claimed*` inputs are what the caller ASSERTED. A resolver that echoed them would make the whole
|
|
33
|
+
* pipeline self-certifying; they are there to be checked against bindings, not adopted.
|
|
34
|
+
*/
|
|
35
|
+
export interface CanonicalIdentityResolver {
|
|
36
|
+
resolve(input: {
|
|
37
|
+
oauth?: OAuthEvidence;
|
|
38
|
+
requestProof?: RequestProofEvidence;
|
|
39
|
+
optionalTransportEvidence?: OptionalTransportEvidence;
|
|
40
|
+
claimedPrincipalAgentId?: string;
|
|
41
|
+
claimedActingAgentId?: string;
|
|
42
|
+
claimedRuntimeId?: string;
|
|
43
|
+
targetAgentId: string;
|
|
44
|
+
at: string;
|
|
45
|
+
}): Promise<CanonicalActorContext>;
|
|
46
|
+
}
|
|
47
|
+
/** One evaluator in the pipeline. Contributes an opinion; never issues the grant. */
|
|
48
|
+
export interface AdmissionPolicyEvaluator {
|
|
49
|
+
readonly contributorId: string;
|
|
50
|
+
evaluate(request: AdmissionRequest): Promise<AdmissionPolicyContribution>;
|
|
51
|
+
}
|
|
52
|
+
/** Composes contributions into one decision and signs any grant. */
|
|
53
|
+
export interface AdmissionEngine {
|
|
54
|
+
evaluate(request: AdmissionRequest): Promise<AdmissionDecision>;
|
|
55
|
+
}
|
|
56
|
+
/** The gateway's per-invocation check. Re-runs authority; never trusts the grant alone. */
|
|
57
|
+
export interface ExecutionAuthorityPoint {
|
|
58
|
+
authorize(request: ExactMcpInvocationRequest): Promise<ExecutionDecision>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Single-use consumption of a replay id.
|
|
62
|
+
*
|
|
63
|
+
* MUST be atomic — a check-then-write leaves a window two concurrent replays both pass through, and a
|
|
64
|
+
* replay defence with a race is not a replay defence. `CONFLICT` (same id, different digest) is kept
|
|
65
|
+
* distinct from `REPLAY` because it means something worse: someone is reusing an id across payloads.
|
|
66
|
+
*/
|
|
67
|
+
export interface AtomicReplayStore {
|
|
68
|
+
consume(input: {
|
|
69
|
+
namespace: string;
|
|
70
|
+
replayId: string;
|
|
71
|
+
digest: string;
|
|
72
|
+
expiresAt: string;
|
|
73
|
+
}): Promise<'CONSUMED' | 'REPLAY' | 'CONFLICT'>;
|
|
74
|
+
}
|
|
75
|
+
/** Exactly-once for effectful operations: reserve → do the work → complete. */
|
|
76
|
+
export interface IdempotencyStore {
|
|
77
|
+
reserve(input: {
|
|
78
|
+
principalAgentId: string;
|
|
79
|
+
targetBoundaryId: string;
|
|
80
|
+
operation: string;
|
|
81
|
+
idempotencyKey: string;
|
|
82
|
+
requestDigest: string;
|
|
83
|
+
expiresAt: string;
|
|
84
|
+
}): Promise<{
|
|
85
|
+
state: 'RESERVED';
|
|
86
|
+
reservationId: string;
|
|
87
|
+
} | {
|
|
88
|
+
state: 'IN_PROGRESS';
|
|
89
|
+
reservationId: string;
|
|
90
|
+
} | {
|
|
91
|
+
state: 'COMPLETED';
|
|
92
|
+
outcomeReceiptRef: string;
|
|
93
|
+
}
|
|
94
|
+
/** Same key, DIFFERENT request — never a silent retry. */
|
|
95
|
+
| {
|
|
96
|
+
state: 'CONFLICT';
|
|
97
|
+
}>;
|
|
98
|
+
complete(input: {
|
|
99
|
+
reservationId: string;
|
|
100
|
+
outcomeReceiptRef: string;
|
|
101
|
+
outcomeDigest: string;
|
|
102
|
+
}): Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The audit sink. FAIL-HARD by contract: if `append` rejects, the caller MUST refuse the operation.
|
|
106
|
+
*
|
|
107
|
+
* Named for the behaviour rather than the storage because the behaviour is the requirement. An audit
|
|
108
|
+
* sink you can proceed past is a log; this is a precondition.
|
|
109
|
+
*/
|
|
110
|
+
export interface FailHardAuditSink {
|
|
111
|
+
append(record: Readonly<Record<string, unknown>>): Promise<{
|
|
112
|
+
receiptRef: string;
|
|
113
|
+
recordHash: string;
|
|
114
|
+
}>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* How a non-A2A ingress could ever participate — by normalizing itself into `AdmissionRequest`.
|
|
118
|
+
*
|
|
119
|
+
* This is the deliberate answer to every "what about <messaging protocol / broker / mail transport>"
|
|
120
|
+
* request (ADR-0057 lists the specific ones by name; this file does not, so the gate that keeps them
|
|
121
|
+
* out of core stays meaningful here). They do not get to add transports to the substrate; they get to
|
|
122
|
+
* arrive already shaped as an admission request. The core never enumerates adapters, so adding one
|
|
123
|
+
* cannot change identity, delegation, or admission semantics — which is the property that makes this
|
|
124
|
+
* extension point safe to leave open.
|
|
125
|
+
*/
|
|
126
|
+
export interface InteractionIngressAdapter {
|
|
127
|
+
readonly adapterId: string;
|
|
128
|
+
authenticateAndNormalize(input: unknown): Promise<{
|
|
129
|
+
admissionRequest: AdmissionRequest;
|
|
130
|
+
interactionPayload: unknown;
|
|
131
|
+
}>;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Resolves an operational workload identifier to its signed binding.
|
|
135
|
+
*
|
|
136
|
+
* The baseline profile omits this entirely. When present it answers one narrow question — "which agent
|
|
137
|
+
* was this workload bound to, and is that binding live?" — and returns `null` when there is no answer.
|
|
138
|
+
* `null` is a real answer here and MUST deny; it must never fall back to inferring an agent from a
|
|
139
|
+
* trust-domain path (ADR-0013, ADR-0057).
|
|
140
|
+
*/
|
|
141
|
+
export interface WorkloadIdentityBindingResolver {
|
|
142
|
+
resolve(input: {
|
|
143
|
+
identifierType: WorkloadIdentifier['type'];
|
|
144
|
+
identifierValue: string;
|
|
145
|
+
environment: string;
|
|
146
|
+
at: string;
|
|
147
|
+
}): Promise<WorkloadIdentityBinding | null>;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,yBAAyB,EACzB,oBAAoB,EACpB,+BAA+B,EAC/B,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,+BAA+B,CAAC;IAEjD,YAAY,CAAC,KAAK,EAAE;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE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,MAAM,CAAC;KACpB,CAAC,CAAC;CACJ;AAID;;;;;;;;;GASG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;QAChD,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,kBAAkB,EAAE,OAAO,CAAC;KAC7B,CAAC,CAAC;CACJ;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,+BAA+B;IAC9C,OAAO,CAAC,KAAK,EAAE;QACb,cAAc,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAC3C,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,EAAE,EAAE,MAAM,CAAC;KACZ,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;CAC7C"}
|
package/dist/ports.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Ports (spec 339 §24). Every one is injected; this package performs no I/O and imports no provider.
|
|
2
|
+
//
|
|
3
|
+
// The two at the bottom — `InteractionIngressAdapter` and `WorkloadIdentityBindingResolver` — are the
|
|
4
|
+
// ONLY extension points the architecture preserves. Both point INWARD: an adapter imports these
|
|
5
|
+
// contracts, and nothing here ever discovers or imports an adapter. That direction is what keeps
|
|
6
|
+
// "optional" from quietly becoming "installed by default", and `check:optional-package-boundaries`
|
|
7
|
+
// enforces it rather than trusting review.
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=ports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ports.js","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,EAAE;AACF,sGAAsG;AACtG,gGAAgG;AAChG,iGAAiG;AACjG,mGAAmG;AACnG,2CAA2C"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AdmissionReasonCode } from './invariants.js';
|
|
2
|
+
import type { AtomicReplayStore } from './ports.js';
|
|
3
|
+
import type { AgenticRequestProofClaims } from './types.js';
|
|
4
|
+
/** `sha256:<hex>` over raw bytes — for `http.bodySha256` and `accessTokenSha256`. */
|
|
5
|
+
export declare function sha256Of(bytes: Uint8Array | string): Promise<string>;
|
|
6
|
+
/**
|
|
7
|
+
* The canonical body a proof signature covers.
|
|
8
|
+
*
|
|
9
|
+
* Every claim is included. There is no "unsigned extras" slot, deliberately: a field outside the
|
|
10
|
+
* signature is a field an intermediary can rewrite, and the whole point of this object is that nobody
|
|
11
|
+
* between the signer and the boundary can change what it says.
|
|
12
|
+
*/
|
|
13
|
+
export declare function requestProofBody(claims: AgenticRequestProofClaims): Record<string, unknown>;
|
|
14
|
+
/** The digest the session key signs. */
|
|
15
|
+
export declare function requestProofDigest(claims: AgenticRequestProofClaims): Promise<string>;
|
|
16
|
+
export interface VerifyRequestProofInput {
|
|
17
|
+
claims: AgenticRequestProofClaims;
|
|
18
|
+
signature: string;
|
|
19
|
+
/** What actually arrived. Recomputed here — never taken from the claims themselves. */
|
|
20
|
+
observed: {
|
|
21
|
+
method: string;
|
|
22
|
+
authority: string;
|
|
23
|
+
pathAndQuery: string;
|
|
24
|
+
rawBody: Uint8Array;
|
|
25
|
+
/** The bearer this request carried, if any. Hashed here; never stored. */
|
|
26
|
+
accessToken?: string;
|
|
27
|
+
/** SHA-256 of the presented client certificate, when the mTLS profile is in play. */
|
|
28
|
+
clientCertificateSha256?: string;
|
|
29
|
+
};
|
|
30
|
+
/** The boundary this proof must be addressed to. */
|
|
31
|
+
expectedAudience: string;
|
|
32
|
+
/** Verifies `signature` over `digest` for `keyId`. Injected — could be ECDSA, ERC-1271, anything. */
|
|
33
|
+
verifySignature: (args: {
|
|
34
|
+
keyId: string;
|
|
35
|
+
digest: string;
|
|
36
|
+
signature: string;
|
|
37
|
+
}) => Promise<boolean>;
|
|
38
|
+
keyId: string;
|
|
39
|
+
replayStore: AtomicReplayStore;
|
|
40
|
+
replayNamespace: string;
|
|
41
|
+
now?: Date;
|
|
42
|
+
/** Tolerance for `issuedAt` in the future, in seconds. Default 60. */
|
|
43
|
+
clockSkewSeconds?: number;
|
|
44
|
+
}
|
|
45
|
+
export type VerifyRequestProofResult = {
|
|
46
|
+
ok: true;
|
|
47
|
+
proofDigest: string;
|
|
48
|
+
} | {
|
|
49
|
+
ok: false;
|
|
50
|
+
code: AdmissionReasonCode;
|
|
51
|
+
detail: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Verify a request proof against what actually arrived.
|
|
55
|
+
*
|
|
56
|
+
* Never throws. A rejected proof returns a precise reason code for the AUDIT LOG; the public response
|
|
57
|
+
* is a generic authentication failure (§26.2), because these codes are a map of exactly how to
|
|
58
|
+
* construct a valid proof.
|
|
59
|
+
*/
|
|
60
|
+
export declare function verifyRequestProof(input: VerifyRequestProofInput): Promise<VerifyRequestProofResult>;
|
|
61
|
+
//# sourceMappingURL=request-proof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-proof.d.ts","sourceRoot":"","sources":["../src/request-proof.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAU5D,qFAAqF;AACrF,wBAAsB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA8B3F;AAED,wCAAwC;AACxC,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,CAE3F;AAED,MAAM,WAAW,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