@decionis/agentsafe 0.1.0 → 0.2.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.
Files changed (48) hide show
  1. package/README.md +31 -2
  2. package/dist/Index.d.ts +3 -1
  3. package/dist/Index.d.ts.map +1 -1
  4. package/dist/Index.js +3 -1
  5. package/dist/Index.js.map +1 -1
  6. package/dist/adapters/AdapterActionHandler.d.ts +4 -0
  7. package/dist/adapters/AdapterActionHandler.d.ts.map +1 -1
  8. package/dist/adapters/AdapterActionHandler.js +12 -1
  9. package/dist/adapters/AdapterActionHandler.js.map +1 -1
  10. package/dist/adapters/EffectAdapter.d.ts +6 -0
  11. package/dist/adapters/EffectAdapter.d.ts.map +1 -1
  12. package/dist/adapters/EffectAdapter.js.map +1 -1
  13. package/dist/adapters/EffectComparison.d.ts +35 -0
  14. package/dist/adapters/EffectComparison.d.ts.map +1 -1
  15. package/dist/adapters/EffectComparison.js +58 -0
  16. package/dist/adapters/EffectComparison.js.map +1 -1
  17. package/dist/adapters/EffectEvidenceBuilder.d.ts +5 -3
  18. package/dist/adapters/EffectEvidenceBuilder.d.ts.map +1 -1
  19. package/dist/adapters/EffectEvidenceBuilder.js +29 -5
  20. package/dist/adapters/EffectEvidenceBuilder.js.map +1 -1
  21. package/dist/adapters/EffectEvidenceRegister.d.ts +7 -0
  22. package/dist/adapters/EffectEvidenceRegister.d.ts.map +1 -1
  23. package/dist/adapters/EffectEvidenceRegister.js.map +1 -1
  24. package/dist/adapters/banking/CoreBankingHttpAdapter.d.ts.map +1 -1
  25. package/dist/adapters/banking/CoreBankingHttpAdapter.js +7 -0
  26. package/dist/adapters/banking/CoreBankingHttpAdapter.js.map +1 -1
  27. package/dist/gateway/ForwardHandler.d.ts.map +1 -1
  28. package/dist/gateway/ForwardHandler.js +8 -0
  29. package/dist/gateway/ForwardHandler.js.map +1 -1
  30. package/dist/handlers/ForwardRequestHandler.d.ts.map +1 -1
  31. package/dist/handlers/ForwardRequestHandler.js +7 -0
  32. package/dist/handlers/ForwardRequestHandler.js.map +1 -1
  33. package/dist/incident/SecurityEvents.d.ts +10 -0
  34. package/dist/incident/SecurityEvents.d.ts.map +1 -1
  35. package/dist/incident/SecurityEvents.js +9 -0
  36. package/dist/incident/SecurityEvents.js.map +1 -1
  37. package/dist/service/TrustedExecutorService.d.ts.map +1 -1
  38. package/dist/service/TrustedExecutorService.js +18 -2
  39. package/dist/service/TrustedExecutorService.js.map +1 -1
  40. package/dist/verify/EffectReceipt.d.ts +78 -0
  41. package/dist/verify/EffectReceipt.d.ts.map +1 -0
  42. package/dist/verify/EffectReceipt.js +98 -0
  43. package/dist/verify/EffectReceipt.js.map +1 -0
  44. package/dist/verify/VerifyingProvider.d.ts +112 -0
  45. package/dist/verify/VerifyingProvider.d.ts.map +1 -0
  46. package/dist/verify/VerifyingProvider.js +266 -0
  47. package/dist/verify/VerifyingProvider.js.map +1 -0
  48. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectReceipt.d.ts","sourceRoot":"","sources":["../../src/verify/EffectReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,gCAAgC,CAAC;AACjE,kDAAkD;AAClD,eAAO,MAAM,qBAAqB,gCAAgC,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,CAAC;AAEpE,MAAM,WAAW,mBAAmB;IAClC,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,gFAAgF;IAChF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;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AC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAMnE"}
@@ -0,0 +1,98 @@
1
+ import { createPrivateKey, sign } from "node:crypto";
2
+ import { jcsCanonical } from "../adapters/JcsDigest.js";
3
+ /**
4
+ * The effect receipt: the provider's half of the evidence (the Verifying
5
+ * Provider Profile, VP-3).
6
+ *
7
+ * The attestation let this provider refuse what the authority never claimed.
8
+ * The receipt closes the other direction: after effecting, or refusing, the
9
+ * claimed request, the provider signs a compact JWS under its own key naming
10
+ * the grant it acted under, the claim it answered and what it did, and
11
+ * returns it in `x-agent-safe-effect-receipt`. The executor forwards it
12
+ * unread at finalization; the authority verifies it against the public key
13
+ * the organisation registered for this provider and records it with the
14
+ * commit evidence, so the dossier carries the provider's signature over the
15
+ * effect and not only the executor's report of it.
16
+ *
17
+ * Every field the receipt binds comes from the attestation the provider has
18
+ * already verified, which is the point: `sub` is the grant, `decision_id`
19
+ * and `dossier_id` are the decision's, and `claim_token_digest` is copied
20
+ * from the attestation of this very claim, which is how the authority ties
21
+ * the receipt to the claim being finalized without the claim token ever
22
+ * reaching the provider. The header and the payload are serialised in RFC
23
+ * 8785 canonical form, so every implementation of this profile signs the
24
+ * same bytes for the same receipt and the conformance vectors can say so.
25
+ */
26
+ export const EFFECT_RECEIPT_TYPE = "decionis-effect-receipt+jwt";
27
+ /** The response header the receipt travels in. */
28
+ export const EFFECT_RECEIPT_HEADER = "x-agent-safe-effect-receipt";
29
+ const SHA256 = /^sha256:[0-9a-f]{64}$/;
30
+ const STATUSES = ["EFFECTED", "REFUSED", "INDETERMINATE"];
31
+ export class EffectReceiptError extends Error {
32
+ code;
33
+ constructor(code) {
34
+ super(code);
35
+ this.code = code;
36
+ this.name = "EffectReceiptError";
37
+ }
38
+ }
39
+ /** The payload of the receipt, before it is signed; what the authority reads. */
40
+ export function effectReceiptClaims(input) {
41
+ if (!STATUSES.includes(input.effect.status))
42
+ throw new EffectReceiptError("EFFECT_STATUS_UNKNOWN");
43
+ if (input.effect.digest !== undefined && !SHA256.test(input.effect.digest)) {
44
+ throw new EffectReceiptError("EFFECT_DIGEST_MALFORMED");
45
+ }
46
+ if (Number.isNaN(Date.parse(input.effect.effected_at))) {
47
+ throw new EffectReceiptError("EFFECTED_AT_MALFORMED");
48
+ }
49
+ if (!Number.isInteger(input.issuedAt) || input.issuedAt < 0) {
50
+ throw new EffectReceiptError("ISSUED_AT_MALFORMED");
51
+ }
52
+ for (const [name, value] of [
53
+ ["KID", input.kid],
54
+ ["ISSUER", input.issuer],
55
+ ["AUDIENCE", input.audience],
56
+ ["JTI", input.jti],
57
+ ]) {
58
+ if (value.length === 0)
59
+ throw new EffectReceiptError(`${name}_EMPTY`);
60
+ }
61
+ return {
62
+ iss: input.issuer,
63
+ aud: input.audience,
64
+ sub: input.attestation.sub,
65
+ decision_id: input.attestation.decision_id,
66
+ dossier_id: input.attestation.dossier_id,
67
+ claim_token_digest: input.attestation.claim_token_digest,
68
+ attestation_jti: input.attestation.jti,
69
+ intent_hash: input.attestation.binding.intent_hash,
70
+ ...(input.idempotencyKey === undefined ? {} : { idempotency_key: input.idempotencyKey }),
71
+ effect: {
72
+ status: input.effect.status,
73
+ ...(input.effect.reference === undefined ? {} : { reference: input.effect.reference }),
74
+ ...(input.effect.digest === undefined ? {} : { digest: input.effect.digest }),
75
+ effected_at: input.effect.effected_at,
76
+ },
77
+ iat: input.issuedAt,
78
+ jti: input.jti,
79
+ };
80
+ }
81
+ /** The `header.payload` the signature covers: both segments RFC 8785 canonical, base64url. */
82
+ export function effectReceiptSigningInput(input) {
83
+ const header = { alg: "EdDSA", kid: input.kid, typ: EFFECT_RECEIPT_TYPE };
84
+ return `${base64url(jcsCanonical(header))}.${base64url(jcsCanonical(effectReceiptClaims(input)))}`;
85
+ }
86
+ /** The receipt: a compact EdDSA JWS the provider returns in `x-agent-safe-effect-receipt`. */
87
+ export function signEffectReceipt(input) {
88
+ const signingInput = effectReceiptSigningInput(input);
89
+ const key = typeof input.key === "string" ? createPrivateKey(input.key) : input.key;
90
+ if (key.asymmetricKeyType !== "ed25519")
91
+ throw new EffectReceiptError("KEY_NOT_ED25519");
92
+ const signature = sign(null, Buffer.from(signingInput), key);
93
+ return `${signingInput}.${signature.toString("base64url")}`;
94
+ }
95
+ function base64url(text) {
96
+ return Buffer.from(text).toString("base64url");
97
+ }
98
+ //# sourceMappingURL=EffectReceipt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectReceipt.js","sourceRoot":"","sources":["../../src/verify/EffectReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,6BAA6B,CAAC;AACjE,kDAAkD;AAClD,MAAM,CAAC,MAAM,qBAAqB,GAAG,6BAA6B,CAAC;AA6CnE,MAAM,MAAM,GAAG,uBAAuB,CAAC;AACvC,MAAM,QAAQ,GAA4B,CAAC,UAAU,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;AAEnF,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACR;IAAnC,YAAmC,IAAY;QAC7C,KAAK,CAAC,IAAI,CAAC,CAAC;QADqB,SAAI,GAAJ,IAAI,CAAQ;QAE7C,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,iFAAiF;AACjF,MAAM,UAAU,mBAAmB,CAAC,KAAyB;IAC3D,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QACzC,MAAM,IAAI,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;IACxD,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,E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CAAC,KAAK,CAAC,GAAG,CAAC;IACpF,IAAI,GAAG,CAAC,iBAAiB,KAAK,SAAS;QAAE,MAAM,IAAI,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;IACzF,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7D,OAAO,GAAG,YAAY,IAAI,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;AAC9D,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,112 @@
1
+ import type { JsonValue } from "@decionis/agent-safe-pipeline";
2
+ /**
3
+ * The Verifying Provider Profile (`docs/authority/verifying-provider.md`), as
4
+ * a provider runs it: the reference for VP-1 and VP-2. Everything the profile
5
+ * numbers is a step here, in the profile's order, and the first failing step
6
+ * names the refusal. The signature half is `SignedRequestCredential.verify`,
7
+ * unchanged; this adds what a provider does around it: the freshness window,
8
+ * the key registry, the attestation, the canonical body digest, and the
9
+ * single presentation of a grant. It is held to the same mutation gate,
10
+ * because a mutant that accepts what it should refuse is a provider that
11
+ * effects what the authority never claimed.
12
+ */
13
+ export type ProviderRefusalCode = "SIGNATURE_INVALID_OR_INCOMPLETE" | "ATTESTATION_INVALID" | "ATTESTATION_DOES_NOT_DESCRIBE_THIS_REQUEST" | "GRANT_REPLAYED";
14
+ export declare const ATTESTATION_TYPE = "decionis-claim-attestation+jwt";
15
+ export declare const JCS_PROFILE = "RFC8785/JCS";
16
+ /** A key the provider issued to, or registered for, the executor, by the `keyid` a signature names. */
17
+ export type ExecutorKey = {
18
+ readonly keyId: string;
19
+ readonly algorithm: "ed25519";
20
+ readonly publicKeyPem: string;
21
+ } | {
22
+ readonly keyId: string;
23
+ readonly algorithm: "hmac-sha256";
24
+ readonly secret: Uint8Array;
25
+ };
26
+ /**
27
+ * The claims of an attestation, as far as the provider reads them; the
28
+ * authority's schema has more. The dossier, the claim-token digest and the
29
+ * attestation's own id are what a receipt (VP-3) is built from, so a
30
+ * provider that effects has them in hand.
31
+ */
32
+ export interface ClaimAttestationClaims {
33
+ readonly iss: string;
34
+ readonly sub: string;
35
+ readonly decision_id: string;
36
+ readonly dossier_id: string;
37
+ readonly binding: {
38
+ readonly intent_hash: string;
39
+ readonly execution_payload_digest: string;
40
+ readonly execution_payload_canonicalization_profile: string;
41
+ };
42
+ readonly claim_token_digest: string;
43
+ readonly jti: string;
44
+ readonly exp: number;
45
+ }
46
+ /**
47
+ * Where a provider keeps the grants it accepted, until their attestation
48
+ * expires. `record` answers true when the grant was not there and is now,
49
+ * false when it was: the second presentation. Shared by every instance that
50
+ * can effect; the profile's step 8.
51
+ */
52
+ export interface ReplayStore {
53
+ record(grantId: string, expiresAtMs: number): boolean;
54
+ }
55
+ export interface VerifyingProviderOptions {
56
+ /** Whether this endpoint effects anything. An effecting provider requires all eight components. */
57
+ readonly effects: boolean;
58
+ /** Unique by `keyId`; the first match is the key. */
59
+ readonly executorKeys: readonly ExecutorKey[];
60
+ /** The authority's execution-grant JWKS, as its well-known path serves it. */
61
+ readonly authorityJwks: {
62
+ readonly keys: readonly Readonly<Record<string, unknown>>[];
63
+ };
64
+ /** The `iss` the provider trusts: `https://decionis.com` for Decionis. */
65
+ readonly authorityIssuer: string;
66
+ /** How far `created` may lie from `now`, each way. */
67
+ readonly clockWindowSeconds: number;
68
+ readonly replay: ReplayStore;
69
+ readonly now?: () => number;
70
+ }
71
+ export interface ReceivedRequest {
72
+ readonly method: string;
73
+ /** The request path, without its query. */
74
+ readonly path: string;
75
+ readonly body: string | null;
76
+ /** Header names in lower case. A covered header received more than once is a refusal; do not collapse it here. */
77
+ readonly headers: Readonly<Record<string, string>>;
78
+ }
79
+ export type ProviderVerdict = {
80
+ readonly accepted: true;
81
+ readonly reasonCode: null;
82
+ readonly attestation: ClaimAttestationClaims | null;
83
+ } | {
84
+ readonly accepted: false;
85
+ readonly reasonCode: ProviderRefusalCode;
86
+ readonly attestation: null;
87
+ };
88
+ /** The body as I-JSON, or null: not JSON, or a name repeated within one object. Lone surrogates are the canonicaliser's to refuse. */
89
+ export declare function parseIJson(body: string): JsonValue | null;
90
+ /**
91
+ * The whole procedure for one received request. An accepted verdict carries
92
+ * the attestation's claims for the provider's own record, or null for a read
93
+ * a non-effecting provider verified at VP-1 alone; a refusal carries the code
94
+ * the response body names.
95
+ */
96
+ export declare function verifyProviderRequest(received: ReceivedRequest, options: VerifyingProviderOptions): ProviderVerdict;
97
+ /** The refusal body the profile names; the status is the provider's, 409 in the references. */
98
+ export declare function refusalBody(reasonCode: ProviderRefusalCode): string;
99
+ /**
100
+ * A replay store for one process: enough for a single instance, and for the
101
+ * vectors. A provider with more than one instance that can effect shares one
102
+ * instead, keyed the same way. Expired grants are forgotten on the next
103
+ * record, which is why the store needs no life beyond the lease.
104
+ */
105
+ export declare class MemoryReplayStore implements ReplayStore {
106
+ private readonly clock;
107
+ private readonly seen;
108
+ constructor(clock?: () => number);
109
+ record(grantId: string, expiresAtMs: number): boolean;
110
+ get size(): number;
111
+ }
112
+ //# sourceMappingURL=VerifyingProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VerifyingProvider.d.ts","sourceRoot":"","sources":["../../src/verify/VerifyingProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAS/D;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAC3B,iCAAiC,GACjC,qBAAqB,GACrB,4CAA4C,GAC5C,gBAAgB,CAAC;AAErB,eAAO,MAAM,gBAAgB,mCAAmC,CAAC;AACjE,eAAO,MAAM,WAAW,gBAAgB,CAAC;AAEzC,uGAAuG;AACvG,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,KAAK,EAAE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,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;gBAEd,KAAK,GAAE,MAAM,MAAyB;IAEnE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAQ5D,IAAW,IAAI,IAAI,MAAM,CAExB;CACF"}
@@ -0,0 +1,266 @@
1
+ import { createPublicKey, verify as verifySignature } from "node:crypto";
2
+ import { z } from "zod";
3
+ import { jcsDigest } from "../adapters/JcsDigest.js";
4
+ import { BASE_COMPONENTS, SIGNED_COMPONENTS, SignedRequestCredential, } from "../credential/SignedRequestCredential.js";
5
+ export const ATTESTATION_TYPE = "decionis-claim-attestation+jwt";
6
+ export const JCS_PROFILE = "RFC8785/JCS";
7
+ // The executor writes its parameters in one order, `created`, `keyid`, `alg`
8
+ // last; the label and the components are the credential's to check.
9
+ const SIGNATURE_CREATED = /;created=(\d{1,12});/;
10
+ const SIGNATURE_KEY_ID = /;keyid="([^"]*)";/;
11
+ const ProtectedHeader = z.looseObject({
12
+ alg: z.literal("EdDSA"),
13
+ typ: z.literal(ATTESTATION_TYPE),
14
+ kid: z.string(),
15
+ });
16
+ // The claims an attestation must carry to be one at all: what step 7 compares
17
+ // and what a receipt (section 7) is built from. Their values are step 7's.
18
+ const Claims = z.looseObject({
19
+ iss: z.string(),
20
+ sub: z.string(),
21
+ decision_id: z.string(),
22
+ dossier_id: z.string(),
23
+ binding: z.looseObject({
24
+ intent_hash: z.string(),
25
+ execution_payload_digest: z.string(),
26
+ execution_payload_canonicalization_profile: z.string(),
27
+ }),
28
+ claim_token_digest: z.string(),
29
+ jti: z.string(),
30
+ exp: z.number(),
31
+ });
32
+ const REFUSE = (reasonCode) => ({
33
+ accepted: false,
34
+ reasonCode,
35
+ attestation: null,
36
+ });
37
+ /**
38
+ * Steps 0 to 5: the signature the executor made, under a key the provider
39
+ * knows, fresh, covering what this provider requires. Null on success.
40
+ */
41
+ function signatureRefusal(received, options, nowSeconds) {
42
+ const input = String(received.headers["signature-input"]);
43
+ const keyId = SIGNATURE_KEY_ID.exec(input)?.[1];
44
+ const key = options.executorKeys.find((candidate) => candidate.keyId === keyId);
45
+ if (key === undefined)
46
+ return "SIGNATURE_INVALID_OR_INCOMPLETE";
47
+ const created = Number(SIGNATURE_CREATED.exec(input)?.[1]);
48
+ if (!(Math.abs(nowSeconds - created) <= options.clockWindowSeconds)) {
49
+ return "SIGNATURE_INVALID_OR_INCOMPLETE";
50
+ }
51
+ const verified = SignedRequestCredential.verify(SignedRequestCredential.materialFrom(received), received.headers, key.algorithm === "ed25519" ? { publicKeyPem: key.publicKeyPem } : { secret: key.secret }, { require: options.effects ? SIGNED_COMPONENTS : BASE_COMPONENTS });
52
+ return verified ? null : "SIGNATURE_INVALID_OR_INCOMPLETE";
53
+ }
54
+ /**
55
+ * Step 6: the authority's attestation, by form, key, signature and issuer;
56
+ * its claims, or null when it is not one. Whatever throws on the way, a part
57
+ * that is not JSON, a kid that names no key, a key that is not one, is the
58
+ * same refusal, and the caller makes it so.
59
+ */
60
+ function attestationOf(compact, options) {
61
+ const parts = compact.split(".");
62
+ if (parts.length !== 3)
63
+ return null;
64
+ const [header, payload, signature] = parts;
65
+ const decode = (part) => JSON.parse(Buffer.from(part, "base64url").toString("utf8"));
66
+ const head = ProtectedHeader.parse(decode(header));
67
+ const jwk = options.authorityJwks.keys.find((candidate) => candidate["kid"] === head.kid);
68
+ const signed = verifySignature(null, Buffer.from(`${header}.${payload}`), createPublicKey({ key: jwk, format: "jwk" }), Buffer.from(signature, "base64url"));
69
+ if (!signed)
70
+ return null;
71
+ const claims = Claims.parse(decode(payload));
72
+ return claims.iss === options.authorityIssuer ? claims : null;
73
+ }
74
+ const DELIMITER = /[{}[\]:,"\s]/g;
75
+ /**
76
+ * The tokens of a JSON text that `JSON.parse` accepted, in order: strings
77
+ * with their escapes, punctuation, and a scalar as its first character,
78
+ * since nothing reads a scalar's text; whitespace is nothing. One pass over
79
+ * the text, no backtracking. The generator is pulled only as far as the
80
+ * top-level value reaches, which for valid JSON is the end of the text, so
81
+ * it needs no end of its own.
82
+ */
83
+ function* tokensOf(json) {
84
+ let index = 0;
85
+ for (;;) {
86
+ const char = json[index];
87
+ if (char === '"') {
88
+ const start = index;
89
+ index += 1;
90
+ while (json[index] !== '"')
91
+ index += json[index] === "\\" ? 2 : 1;
92
+ index += 1;
93
+ yield json.slice(start, index);
94
+ }
95
+ else if ("{}[]:,".includes(char)) {
96
+ index += 1;
97
+ yield char;
98
+ }
99
+ else if (" \n\r\t".includes(char)) {
100
+ index += 1;
101
+ }
102
+ else {
103
+ DELIMITER.lastIndex = index;
104
+ const delimiter = DELIMITER.exec(json);
105
+ index = delimiter === null ? json.length : delimiter.index;
106
+ yield char;
107
+ }
108
+ }
109
+ }
110
+ /**
111
+ * True when some object in a syntactically valid JSON text repeats a name.
112
+ * `JSON.parse` keeps the last of a repeated name, which is exactly the
113
+ * disagreement between parsers that makes such a body unsafe to digest, so
114
+ * the tokens are walked once more, after the grammar is known to hold, and
115
+ * each object's names are collected.
116
+ */
117
+ function hasRepeatedName(json) {
118
+ const tokens = tokensOf(json);
119
+ const next = () => tokens.next().value;
120
+ const value = (first) => {
121
+ if (first === "{") {
122
+ const names = new Set();
123
+ let token = next();
124
+ while (token !== "}") {
125
+ const name = JSON.parse(token);
126
+ if (names.has(name))
127
+ return true;
128
+ names.add(name);
129
+ next();
130
+ if (value(next()))
131
+ return true;
132
+ token = next();
133
+ if (token === ",")
134
+ token = next();
135
+ }
136
+ return false;
137
+ }
138
+ if (first === "[") {
139
+ // A comma between values is read as a value with nothing inside.
140
+ let token = next();
141
+ while (token !== "]") {
142
+ if (value(token))
143
+ return true;
144
+ token = next();
145
+ }
146
+ }
147
+ return false;
148
+ };
149
+ return value(next());
150
+ }
151
+ /** The body as I-JSON, or null: not JSON, or a name repeated within one object. Lone surrogates are the canonicaliser's to refuse. */
152
+ export function parseIJson(body) {
153
+ let value;
154
+ try {
155
+ value = JSON.parse(body);
156
+ }
157
+ catch {
158
+ return null;
159
+ }
160
+ return hasRepeatedName(body) ? null : value;
161
+ }
162
+ /**
163
+ * Step 7: whether the attestation describes this request; the claims when it
164
+ * does. A body that is not I-JSON throws, and the caller refuses.
165
+ */
166
+ function described(claims, received, nowSeconds) {
167
+ const { iss, sub, decision_id, dossier_id, binding, claim_token_digest, jti, exp } = claims;
168
+ // No body reads as the text `null`, which describes no parameters; nor
169
+ // does anything that is not an object, since parameters are one.
170
+ const value = parseIJson(String(received.body));
171
+ if (value === null || typeof value !== "object" || Array.isArray(value))
172
+ return null;
173
+ const digest = jcsDigest(value);
174
+ if (sub !== received.headers["x-agent-safe-grant-id"] ||
175
+ decision_id !== received.headers["x-agent-safe-decision-id"] ||
176
+ binding.intent_hash !== received.headers["x-agent-safe-intent-hash"] ||
177
+ binding.execution_payload_canonicalization_profile !== JCS_PROFILE ||
178
+ binding.execution_payload_digest !== digest ||
179
+ exp <= nowSeconds) {
180
+ return null;
181
+ }
182
+ return {
183
+ iss,
184
+ sub,
185
+ decision_id,
186
+ dossier_id,
187
+ binding: {
188
+ intent_hash: binding.intent_hash,
189
+ execution_payload_digest: binding.execution_payload_digest,
190
+ execution_payload_canonicalization_profile: binding.execution_payload_canonicalization_profile,
191
+ },
192
+ claim_token_digest,
193
+ jti,
194
+ exp,
195
+ };
196
+ }
197
+ /**
198
+ * The whole procedure for one received request. An accepted verdict carries
199
+ * the attestation's claims for the provider's own record, or null for a read
200
+ * a non-effecting provider verified at VP-1 alone; a refusal carries the code
201
+ * the response body names.
202
+ */
203
+ export function verifyProviderRequest(received, options) {
204
+ const nowSeconds = Math.floor((options.now ?? Date.now)() / 1_000);
205
+ const refusal = signatureRefusal(received, options, nowSeconds);
206
+ if (refusal !== null)
207
+ return REFUSE(refusal);
208
+ if (!options.effects)
209
+ return { accepted: true, reasonCode: null, attestation: null };
210
+ // An effecting provider required the attestation covered, and a covered
211
+ // header is present: the signature step proved it.
212
+ const compact = received.headers["x-agent-safe-claim-attestation"];
213
+ let claims;
214
+ try {
215
+ claims = attestationOf(compact, options);
216
+ }
217
+ catch {
218
+ claims = null;
219
+ }
220
+ if (claims === null)
221
+ return REFUSE("ATTESTATION_INVALID");
222
+ let attestation;
223
+ try {
224
+ attestation = described(claims, received, nowSeconds);
225
+ }
226
+ catch {
227
+ attestation = null;
228
+ }
229
+ if (attestation === null)
230
+ return REFUSE("ATTESTATION_DOES_NOT_DESCRIBE_THIS_REQUEST");
231
+ if (!options.replay.record(attestation.sub, attestation.exp * 1_000)) {
232
+ return REFUSE("GRANT_REPLAYED");
233
+ }
234
+ return { accepted: true, reasonCode: null, attestation };
235
+ }
236
+ /** The refusal body the profile names; the status is the provider's, 409 in the references. */
237
+ export function refusalBody(reasonCode) {
238
+ return JSON.stringify({ status: "REJECTED", reason_code: reasonCode });
239
+ }
240
+ /**
241
+ * A replay store for one process: enough for a single instance, and for the
242
+ * vectors. A provider with more than one instance that can effect shares one
243
+ * instead, keyed the same way. Expired grants are forgotten on the next
244
+ * record, which is why the store needs no life beyond the lease.
245
+ */
246
+ export class MemoryReplayStore {
247
+ clock;
248
+ seen = new Map();
249
+ constructor(clock = () => Date.now()) {
250
+ this.clock = clock;
251
+ }
252
+ record(grantId, expiresAtMs) {
253
+ const now = this.clock();
254
+ for (const [grant, expiry] of this.seen)
255
+ if (expiry <= now)
256
+ this.seen.delete(grant);
257
+ if (this.seen.has(grantId))
258
+ return false;
259
+ this.seen.set(grantId, expiresAtMs);
260
+ return true;
261
+ }
262
+ get size() {
263
+ return this.seen.size;
264
+ }
265
+ }
266
+ //# sourceMappingURL=VerifyingProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VerifyingProvider.js","sourceRoot":"","sources":["../../src/verify/VerifyingProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,E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,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAC3D,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,WAAW,CAAC,UAA+B;IACzD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;AACzE,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAGQ;IAFnB,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IAElD,YAAoC,QAAsB,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QAAtC,UAAK,GAAL,KAAK,CAAiC;IAAG,CAAC;IAEvE,MAAM,CAAC,OAAe,EAAE,WAAmB;QAChD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,MAAM,IAAI,GAAG;gBAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpF,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACxB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decionis/agentsafe",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "The trusted executor of the Execution Authority architecture as one deployable process: a proposal in over HTTP, a verdict from the authority, one execution on a claimed single-use grant, and the evidence of each.",
5
5
  "keywords": [
6
6
  "execution-authority",
@@ -58,7 +58,7 @@
58
58
  "jose": "^6.2.10",
59
59
  "yaml": "^2.9.0",
60
60
  "zod": "^4.5.4",
61
- "@decionis/agent-safe-pipeline": "^0.2.0"
61
+ "@decionis/agent-safe-pipeline": "^0.3.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@stryker-mutator/core": "10.0.0",