aqta-verify-receipt 1.2.6 → 1.3.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 CHANGED
@@ -34,7 +34,7 @@ Invalid:
34
34
  ✕ invalid signature mismatch 2d41…871e94c
35
35
  ```
36
36
 
37
- Optional flourish (never the proof):
37
+ Optional human-readable summary (the compact line and exit code are the result):
38
38
 
39
39
  ```bash
40
40
  npx aqta-verify-receipt receipt.json --key <pinned> --pretty
@@ -110,11 +110,11 @@ aqta-verify-receipt <file|-> --integrity-only [options]
110
110
 
111
111
  | Flag | Meaning |
112
112
  |------|---------|
113
- | `--key` | Pin issuer identity (required for counsel-grade). |
113
+ | `--key` | Pin the issuer key. Required unless `--integrity-only`. |
114
114
  | `--integrity-only` | Signature vs embedded key only; returns untrusted. Anyone can self-sign. |
115
115
  | `--no-strict` | Allow unknown top-level fields |
116
116
  | `--json` | One JSON object on stdout |
117
- | `--pretty` | Optional human flourish after the compact line (not the proof) |
117
+ | `--pretty` | Optional human-readable summary after the compact line |
118
118
  | `-q` | Silent; exit code only |
119
119
 
120
120
  `NO_COLOR=1` disables colour. Meaning never depends on colour alone.
@@ -138,6 +138,26 @@ Default: `https://app.aqta.ai/security/pubkey.txt`. Same material as
138
138
  Conformance suite, covering receipts, agent action records and transparency proofs:
139
139
  [`test-vectors/`](https://github.com/Aqta-ai/attestation-spec/tree/main/test-vectors).
140
140
 
141
+ ## Chain profile (draft)
142
+
143
+ GRANT-v1 and USE-v1 are **draft specifications, not frozen**; their wire
144
+ formats may change. `--profile chain` checks a bundle of GRANT-v1 approvals,
145
+ USE-v1 records and the ACTION-v1 records they authorised, and returns `PASS`,
146
+ `FAIL` or `INCOMPLETE`. Missing evidence is `INCOMPLETE`, never `PASS`, and
147
+ without `--approver-keys` an authorised action is `INCOMPLETE`.
148
+
149
+ ```bash
150
+ npx aqta-verify-receipt bundle.json --profile chain --key <issuer key> --approver-keys <k1,k2>
151
+ ```
152
+
153
+ Exit 0 `PASS`, 1 `FAIL`, 3 `INCOMPLETE`, 2 usage or IO. `--key` is required;
154
+ `--integrity-only` and `--no-strict` are refused. Library:
155
+ `require('aqta-verify-receipt/dist/chain.js').verifyChain(bundle, { trustedPublicKey, approverKeys })`.
156
+ Opt-in only: nothing selects this profile from a record's shape. The two
157
+ separately written verifiers, this one and the Python one, must return the
158
+ same verdict and reason on every vector in
159
+ [`test-vectors/chain/`](https://github.com/Aqta-ai/attestation-spec/tree/main/test-vectors/chain).
160
+
141
161
  ## Transparency proofs
142
162
 
143
163
  A receipt signature answers what the issuer asserted. It cannot answer whether
@@ -166,11 +186,10 @@ An inclusion proof establishes that what you were shown is genuinely in the
166
186
  log. It does not establish that what you were **not** shown is irrelevant.
167
187
  That is omission, and it is open.
168
188
 
169
- ## What this is not
189
+ ## Scope
170
190
 
171
- Not a governance dashboard. Not a cost router. Not a chain explorer.
172
- A small verifier for signed decision records and the log proofs that accompany them. The novel part is the
173
- receipt format and offline verification model, not ASCII theatre.
191
+ A small offline verifier for signed decision records and the log proofs that accompany them. It reads a
192
+ record and a key, and reports a verdict. It does not store, send or host records, and it never contacts Aqta.
174
193
 
175
194
  ## Security
176
195
 
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The `chain` profile (spec/USE-v1.md section 9), GRANT-v1 (spec/GRANT-v1.md)
3
+ * and USE-v1 (spec/USE-v1.md). DRAFT: both record formats are drafts, not
4
+ * frozen.
5
+ *
6
+ * Three verdicts, never two: PASS, FAIL, INCOMPLETE. Missing evidence is never
7
+ * a pass. The check order and every reason string are a cross-implementation
8
+ * contract with the Python verifier (aqta_verify_receipt/chain.py): first FAIL
9
+ * wins, and the two must return the same verdict and reason on the same bytes.
10
+ *
11
+ * Explicit opt-in only. Nothing here is reached by inspecting input shape.
12
+ * Node-only, like transparency.ts: it needs SHA-256.
13
+ */
14
+ export type ChainVerdict = 'PASS' | 'FAIL' | 'INCOMPLETE';
15
+ export interface ChainResult {
16
+ verdict: ChainVerdict;
17
+ reason: string | null;
18
+ }
19
+ export interface ChainOptions {
20
+ trustedPublicKey?: string;
21
+ /** The relying party's designated approver keys. Absent: authorised actions are INCOMPLETE. */
22
+ approverKeys?: string[] | null;
23
+ }
24
+ type Obj = Record<string, unknown>;
25
+ declare function cmpInstant(a: string, b: string): number;
26
+ /** Integrity of one grant: null when it holds, else the reason. Says nothing about authority. */
27
+ export declare function checkGrantRecord(grant: unknown): string | null;
28
+ export declare function grantHash(grant: Obj): string;
29
+ export declare function checkUseRecord(use: unknown, trustedPublicKey: string | undefined): string | null;
30
+ /** Verify a chain bundle. Never throws. */
31
+ export declare function verifyChain(bundle: unknown, options?: ChainOptions): ChainResult;
32
+ /** Internal, for the interop sweep only: the exact-instant comparator. */
33
+ export declare const _chainInternal: {
34
+ cmpInstant: typeof cmpInstant;
35
+ };
36
+ export {};
37
+ //# sourceMappingURL=chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;AAC1D,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AACD,MAAM,WAAW,YAAY;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+FAA+F;IAC/F,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAChC;AAqBD,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA6FnC,iBAAS,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAQhD;AASD,iGAAiG;AACjG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAgD9D;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAE5C;AAID,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAqBhG;AAwDD,2CAA2C;AAC3C,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,GAAE,YAAiB,GAAG,WAAW,CAOpF;AAkKD,0EAA0E;AAC1E,eAAO,MAAM,cAAc;;CAAiB,CAAC"}
package/dist/chain.js ADDED
@@ -0,0 +1,521 @@
1
+ "use strict";
2
+ /**
3
+ * The `chain` profile (spec/USE-v1.md section 9), GRANT-v1 (spec/GRANT-v1.md)
4
+ * and USE-v1 (spec/USE-v1.md). DRAFT: both record formats are drafts, not
5
+ * frozen.
6
+ *
7
+ * Three verdicts, never two: PASS, FAIL, INCOMPLETE. Missing evidence is never
8
+ * a pass. The check order and every reason string are a cross-implementation
9
+ * contract with the Python verifier (aqta_verify_receipt/chain.py): first FAIL
10
+ * wins, and the two must return the same verdict and reason on the same bytes.
11
+ *
12
+ * Explicit opt-in only. Nothing here is reached by inspecting input shape.
13
+ * Node-only, like transparency.ts: it needs SHA-256.
14
+ */
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports._chainInternal = void 0;
20
+ exports.checkGrantRecord = checkGrantRecord;
21
+ exports.grantHash = grantHash;
22
+ exports.checkUseRecord = checkUseRecord;
23
+ exports.verifyChain = verifyChain;
24
+ const tweetnacl_1 = __importDefault(require("tweetnacl"));
25
+ const node_crypto_1 = require("node:crypto");
26
+ const index_js_1 = require("./index.js");
27
+ const { canonicalValue, RFC3339_OFFSET, B64URL_STRICT, base64urlDecode, canonicalScalar } = index_js_1._internal;
28
+ const GRANT_FIELDS = [
29
+ 'v', 'grant_id', 'intent_ref', 'org_id', 'approver', 'signing_mode', 'scope_tool', 'scope_resource',
30
+ 'scope_environment', 'max_uses', 'not_before', 'not_after', 'require_args', 'public_key', 'signature',
31
+ ];
32
+ const GRANT_OPTIONAL = ['scope_args', 'agent_key_id'];
33
+ const USE_FIELDS = [
34
+ 'v', 'use_id', 'org_id', 'action_id', 'args_hash', 'grant_id', 'grant_hash', 'approver_public_key',
35
+ 'consumption_key', 'use_index', 'max_uses', 'timestamp', 'public_key', 'signature',
36
+ ];
37
+ const BUNDLE_MEMBERS = ['v', 'grants', 'uses', 'actions'];
38
+ const DECIMAL = /^(0|[1-9][0-9]*)$/;
39
+ const DECIMAL_POSITIVE = /^[1-9][0-9]*$/;
40
+ const HEX64 = /^[0-9a-f]{64}$/;
41
+ const ARG_NAME = /^[A-Za-z0-9_.-]{1,64}$/;
42
+ const KEY_ID = /^[A-Za-z0-9_.:-]{1,128}$/;
43
+ const UNBINDABLE = new Set(['aqta_grant', 'aqta_grant_id', 'aqta_grant_hash']);
44
+ const TS = /^(\d{4})-(\d{2})-(\d{2})[Tt ](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(?:[Zz]|([+-])(\d{2}):(\d{2}))$/;
45
+ class Fail extends Error {
46
+ }
47
+ function isObject(v) {
48
+ return typeof v === 'object' && v !== null && !Array.isArray(v);
49
+ }
50
+ function has(o, k) {
51
+ return Object.prototype.hasOwnProperty.call(o, k);
52
+ }
53
+ /** Own-property read: `args.constructor` must not reach Object.prototype. */
54
+ function own(o, k) {
55
+ return has(o, k) ? o[k] : undefined;
56
+ }
57
+ function firstUnknown(o, allowed) {
58
+ const unknown = Object.keys(o).filter((k) => !allowed.has(k)).sort();
59
+ return unknown.length ? unknown[0] : null;
60
+ }
61
+ function canonicalBytes(o) {
62
+ return new TextEncoder().encode(canonicalValue(o));
63
+ }
64
+ function withoutSignature(o) {
65
+ const p = { ...o };
66
+ delete p.signature;
67
+ return p;
68
+ }
69
+ function signatureReason(payload, signature, publicKey) {
70
+ let canonical;
71
+ try {
72
+ canonical = canonicalBytes(payload);
73
+ }
74
+ catch {
75
+ return 'record is not canonicalisable';
76
+ }
77
+ if (typeof signature !== 'string' || !B64URL_STRICT.test(signature) ||
78
+ typeof publicKey !== 'string' || !B64URL_STRICT.test(publicKey)) {
79
+ return 'signature decode error: not base64url';
80
+ }
81
+ let sig;
82
+ let pub;
83
+ try {
84
+ sig = base64urlDecode(signature);
85
+ pub = base64urlDecode(publicKey);
86
+ }
87
+ catch {
88
+ return 'signature decode error: not base64url';
89
+ }
90
+ if (sig.length !== 64)
91
+ return 'signature length != 64 bytes';
92
+ if (pub.length !== 32)
93
+ return 'public key length != 32 bytes';
94
+ if (!canonicalScalar(sig))
95
+ return 'signature check failed';
96
+ try {
97
+ if (!tweetnacl_1.default.sign.detached.verify(canonical, sig, pub))
98
+ return 'signature check failed';
99
+ }
100
+ catch {
101
+ return 'signature check failed';
102
+ }
103
+ return null;
104
+ }
105
+ function isKey(v) {
106
+ if (typeof v !== 'string' || !B64URL_STRICT.test(v))
107
+ return false;
108
+ try {
109
+ return base64urlDecode(v).length === 32;
110
+ }
111
+ catch {
112
+ return false;
113
+ }
114
+ }
115
+ // --- Times: exact instants without a date library (spec/GRANT-v1.md section 6.1) ------------------------------
116
+ function daysFromCivil(y0, m, d) {
117
+ const y = m <= 2 ? y0 - 1 : y0;
118
+ const era = Math.floor(y / 400);
119
+ const yoe = y - era * 400;
120
+ const doy = Math.floor((153 * (m + (m > 2 ? -3 : 9)) + 2) / 5) + d - 1;
121
+ const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
122
+ return era * 146097 + doe - 719468;
123
+ }
124
+ function instant(ts) {
125
+ const m = TS.exec(ts);
126
+ const n = (i) => parseInt(m[i], 10);
127
+ let secs = daysFromCivil(n(1), n(2), n(3)) * 86400 + n(4) * 3600 + n(5) * 60 + n(6);
128
+ if (m[8]) {
129
+ const off = n(9) * 3600 + n(10) * 60;
130
+ secs -= m[8] === '+' ? off : -off;
131
+ }
132
+ return [secs, m[7] ?? ''];
133
+ }
134
+ function cmpInstant(a, b) {
135
+ const [sa, fa0] = instant(a);
136
+ const [sb, fb0] = instant(b);
137
+ if (sa !== sb)
138
+ return sa < sb ? -1 : 1;
139
+ const len = Math.max(fa0.length, fb0.length);
140
+ const fa = fa0.padEnd(len, '0');
141
+ const fb = fb0.padEnd(len, '0');
142
+ return fa === fb ? 0 : fa < fb ? -1 : 1;
143
+ }
144
+ function decLe(a, b) {
145
+ if (a.length !== b.length)
146
+ return a.length < b.length;
147
+ return a <= b;
148
+ }
149
+ // --- GRANT-v1 (spec/GRANT-v1.md section 7.1) -------------------------------------------------------------------
150
+ /** Integrity of one grant: null when it holds, else the reason. Says nothing about authority. */
151
+ function checkGrantRecord(grant) {
152
+ if (!isObject(grant))
153
+ return 'grant must be an object';
154
+ for (const f of GRANT_FIELDS)
155
+ if (!has(grant, f))
156
+ return `missing required field: ${f}`;
157
+ const unknown = firstUnknown(grant, new Set([...GRANT_FIELDS, ...GRANT_OPTIONAL]));
158
+ if (unknown !== null)
159
+ return `unknown top-level field: ${unknown}`;
160
+ if (grant.v !== 'grant-1')
161
+ return "v must be the string 'grant-1'";
162
+ for (const f of [...GRANT_FIELDS, ...GRANT_OPTIONAL]) {
163
+ if (!has(grant, f))
164
+ continue;
165
+ if (f === 'require_args' || f === 'scope_args') {
166
+ if (!Array.isArray(grant[f]))
167
+ return `${f} must be an array`;
168
+ }
169
+ else if (typeof grant[f] !== 'string') {
170
+ return `${f} must be a string`;
171
+ }
172
+ }
173
+ const g = grant;
174
+ if (g.signing_mode !== 'approver-signed')
175
+ return "signing_mode must be 'approver-signed'";
176
+ for (const f of ['grant_id', 'org_id', 'approver', 'scope_tool']) {
177
+ if (g[f] === '')
178
+ return `${f} must be a non-empty string`;
179
+ }
180
+ if (g.max_uses !== '' && !DECIMAL.test(g.max_uses))
181
+ return "max_uses must be '' or a canonical decimal string";
182
+ if (g.not_before !== '' && !RFC3339_OFFSET.test(g.not_before)) {
183
+ return "not_before must be '' or an RFC 3339 datetime with an explicit offset";
184
+ }
185
+ if (!RFC3339_OFFSET.test(g.not_after))
186
+ return 'not_after must be an RFC 3339 datetime with an explicit offset';
187
+ const req = grant.require_args;
188
+ if (!req.every((x) => typeof x === 'string'))
189
+ return 'require_args must contain only strings';
190
+ const reqSorted = [...req].sort();
191
+ if (req.some((x, i) => x !== reqSorted[i]))
192
+ return 'require_args must be in lexicographic order';
193
+ if (has(grant, 'scope_args')) {
194
+ const entries = grant.scope_args;
195
+ if (entries.length === 0)
196
+ return 'scope_args must be a non-empty list of name=value strings';
197
+ const names = new Set();
198
+ for (const e of entries) {
199
+ if (typeof e !== 'string' || !e.includes('='))
200
+ return 'scope_args entries must be name=value strings';
201
+ const at = e.indexOf('=');
202
+ const name = e.slice(0, at);
203
+ const value = e.slice(at + 1);
204
+ if (!ARG_NAME.test(name) || UNBINDABLE.has(name) || value === '') {
205
+ return 'scope_args entry has an invalid name or an empty value';
206
+ }
207
+ if (names.has(name))
208
+ return `scope_args names ${name} twice`;
209
+ names.add(name);
210
+ }
211
+ const sorted = [...entries].sort();
212
+ if (entries.some((x, i) => x !== sorted[i]))
213
+ return 'scope_args must be sorted';
214
+ }
215
+ if (has(grant, 'agent_key_id') && !KEY_ID.test(g.agent_key_id))
216
+ return 'agent_key_id must be an API key id';
217
+ return signatureReason(withoutSignature(grant), grant.signature, grant.public_key);
218
+ }
219
+ function grantHash(grant) {
220
+ return (0, node_crypto_1.createHash)('sha256').update(canonicalBytes(withoutSignature(grant))).digest('hex');
221
+ }
222
+ // --- USE-v1 (spec/USE-v1.md section 7) -------------------------------------------------------------------------
223
+ function checkUseRecord(use, trustedPublicKey) {
224
+ if (!isObject(use))
225
+ return 'use must be an object';
226
+ for (const f of USE_FIELDS)
227
+ if (!has(use, f))
228
+ return `missing required field: ${f}`;
229
+ const unknown = firstUnknown(use, new Set(USE_FIELDS));
230
+ if (unknown !== null)
231
+ return `unknown top-level field: ${unknown}`;
232
+ if (use.v !== 'use-1')
233
+ return "v must be the string 'use-1'";
234
+ for (const f of USE_FIELDS)
235
+ if (typeof use[f] !== 'string')
236
+ return `${f} must be a string`;
237
+ const u = use;
238
+ for (const f of ['use_id', 'org_id', 'action_id', 'grant_id', 'consumption_key']) {
239
+ if (u[f] === '')
240
+ return `${f} must be a non-empty string`;
241
+ }
242
+ for (const f of ['args_hash', 'grant_hash']) {
243
+ if (!HEX64.test(u[f]))
244
+ return `${f} must be 64 lowercase hex characters`;
245
+ }
246
+ if (!isKey(u.approver_public_key))
247
+ return 'approver_public_key must be a base64url Ed25519 key';
248
+ if (!DECIMAL_POSITIVE.test(u.use_index))
249
+ return 'use_index must be a canonical decimal string of at least 1';
250
+ if (!DECIMAL.test(u.max_uses))
251
+ return 'max_uses must be a canonical decimal string';
252
+ if (!RFC3339_OFFSET.test(u.timestamp))
253
+ return 'timestamp must be an RFC 3339 datetime with an explicit offset';
254
+ if (trustedPublicKey === undefined)
255
+ return 'trusted_public_key required';
256
+ if (u.public_key !== trustedPublicKey)
257
+ return 'public_key does not match trusted key';
258
+ return signatureReason(withoutSignature(use), use.signature, use.public_key);
259
+ }
260
+ // --- Scope (spec/GRANT-v1.md section 6) ------------------------------------------------------------------------
261
+ function matches(pattern, value) {
262
+ if (pattern.endsWith('*'))
263
+ return value.startsWith(pattern.slice(0, -1));
264
+ return pattern === value;
265
+ }
266
+ function isEmptyEvidence(v) {
267
+ if (v === null || v === undefined || v === '')
268
+ return true;
269
+ if (Array.isArray(v))
270
+ return v.length === 0;
271
+ if (isObject(v))
272
+ return Object.keys(v).length === 0;
273
+ return false;
274
+ }
275
+ function scopeReason(g, rec, args) {
276
+ if (g.org_id !== rec.org_id)
277
+ return 'the grant was issued for a different organisation';
278
+ if (!matches(g.scope_tool, rec.tool))
279
+ return "the tool is outside the grant's scope_tool";
280
+ const res = g.scope_resource;
281
+ if (res !== '') {
282
+ const declared = ['device_id', 'resource'].filter((k) => has(args, k) && args[k] !== null && args[k] !== '');
283
+ if (declared.length === 0)
284
+ return 'the action declares no resource and the grant names one';
285
+ for (const k of declared) {
286
+ if (typeof args[k] !== 'string' || args[k] !== res)
287
+ return `the action's ${k} is not the grant's resource`;
288
+ }
289
+ }
290
+ const env = g.scope_environment;
291
+ if (env !== '') {
292
+ const e = own(args, 'environment');
293
+ if (typeof e !== 'string' || e !== env)
294
+ return "the action's environment is not the grant's";
295
+ }
296
+ for (const entry of (has(g, 'scope_args') ? g.scope_args : [])) {
297
+ const at = entry.indexOf('=');
298
+ const name = entry.slice(0, at);
299
+ const value = entry.slice(at + 1);
300
+ const v = own(args, name);
301
+ if (typeof v !== 'string' || v !== value)
302
+ return `the action does not match the value the grant fixes for ${name}`;
303
+ }
304
+ for (const name of g.require_args) {
305
+ if (!has(args, name) || isEmptyEvidence(args[name]))
306
+ return `the action lacks evidence the grant requires: ${name}`;
307
+ }
308
+ return null;
309
+ }
310
+ function inWindow(g, ts) {
311
+ if (g.not_before !== '' && cmpInstant(ts, g.not_before) < 0)
312
+ return false;
313
+ return cmpInstant(ts, g.not_after) <= 0;
314
+ }
315
+ function ckey(g, orgId) {
316
+ return g.intent_ref !== '' ? `org:${orgId}|intent:${g.intent_ref}` : `org:${orgId}|grant:${g.grant_id}`;
317
+ }
318
+ // --- The chain (spec/USE-v1.md section 9.3) --------------------------------------------------------------------
319
+ /** Verify a chain bundle. Never throws. */
320
+ function verifyChain(bundle, options = {}) {
321
+ try {
322
+ return verifyChainInner(bundle, options);
323
+ }
324
+ catch (e) {
325
+ if (e instanceof Fail)
326
+ return { verdict: 'FAIL', reason: e.message };
327
+ return { verdict: 'FAIL', reason: 'verification error' };
328
+ }
329
+ }
330
+ function verifyChainInner(bundle, options) {
331
+ const incomplete = [];
332
+ const fail = (reason) => {
333
+ throw new Fail(reason);
334
+ };
335
+ const pinned = options.trustedPublicKey;
336
+ // 1. Inputs.
337
+ if (typeof pinned !== 'string' || !isKey(pinned))
338
+ fail('a pinned issuer key is required');
339
+ let trusted = null;
340
+ if (options.approverKeys !== undefined && options.approverKeys !== null) {
341
+ if (!Array.isArray(options.approverKeys) || !options.approverKeys.every(isKey)) {
342
+ fail('approver_keys must be base64url Ed25519 keys');
343
+ }
344
+ trusted = new Set(options.approverKeys);
345
+ }
346
+ // 2. Bundle.
347
+ if (!isObject(bundle))
348
+ fail('bundle must be an object');
349
+ const b = bundle;
350
+ for (const m of BUNDLE_MEMBERS)
351
+ if (!has(b, m))
352
+ fail(`bundle missing member: ${m}`);
353
+ const unknown = firstUnknown(b, new Set(BUNDLE_MEMBERS));
354
+ if (unknown !== null)
355
+ fail(`bundle has unknown member: ${unknown}`);
356
+ if (b.v !== 'chain-1')
357
+ fail("bundle v must be the string 'chain-1'");
358
+ for (const m of ['grants', 'uses', 'actions'])
359
+ if (!Array.isArray(b[m]))
360
+ fail(`bundle ${m} must be an array`);
361
+ // 3. Actions.
362
+ const actions = b.actions;
363
+ const byAction = new Map();
364
+ actions.forEach((a, i) => {
365
+ if (!isObject(a) || Object.keys(a).length !== 2 || !has(a, 'record') || !has(a, 'args')) {
366
+ fail(`actions[${i}] must be an object with record and args`);
367
+ }
368
+ const item = a;
369
+ if (!isObject(item.args))
370
+ fail(`actions[${i}].args must be an object`);
371
+ const r = (0, index_js_1.verifyActionRecord)(item.record, { trustedPublicKey: pinned });
372
+ if (!r.valid) {
373
+ // The published ACTION-v1 paths word a canonicalisation failure
374
+ // differently in each language (same verdict). The chain reason is one
375
+ // string in both.
376
+ const reason = (r.reason ?? '').startsWith('failed to canonicalise') ? 'record is not canonicalisable' : r.reason;
377
+ fail(`actions[${i}]: ${reason}`);
378
+ }
379
+ let h = '';
380
+ try {
381
+ h = (0, node_crypto_1.createHash)('sha256').update(canonicalBytes(item.args)).digest('hex');
382
+ }
383
+ catch {
384
+ fail(`actions[${i}].args is not canonicalisable`);
385
+ }
386
+ const rec = item.record;
387
+ if (h !== rec.args_hash)
388
+ fail(`actions[${i}].args do not match the record's args_hash`);
389
+ const aid = rec.action_id;
390
+ if (byAction.has(aid))
391
+ fail(`actions[${i}] repeats an action_id`);
392
+ byAction.set(aid, { record: rec, args: item.args });
393
+ });
394
+ // 4. Grants.
395
+ const byHash = new Map();
396
+ b.grants.forEach((g, i) => {
397
+ const why = checkGrantRecord(g);
398
+ if (why !== null)
399
+ fail(`grants[${i}]: ${why}`);
400
+ const h = grantHash(g);
401
+ if (byHash.has(h))
402
+ fail(`grants[${i}] repeats an earlier grant`);
403
+ byHash.set(h, g);
404
+ });
405
+ const ids = new Set([...byHash.values()].map((g) => g.grant_id));
406
+ // 5. Uses.
407
+ const uses = b.uses;
408
+ const seenUseIds = new Set();
409
+ uses.forEach((u, i) => {
410
+ const why = checkUseRecord(u, pinned);
411
+ if (why !== null)
412
+ fail(`uses[${i}]: ${why}`);
413
+ const id = u.use_id;
414
+ if (seenUseIds.has(id))
415
+ fail(`uses[${i}] repeats a use_id`);
416
+ seenUseIds.add(id);
417
+ });
418
+ const U = uses;
419
+ // 6. Conflicts.
420
+ const claims = new Set();
421
+ const named = new Set();
422
+ U.forEach((u, i) => {
423
+ const c = JSON.stringify([u.consumption_key, u.use_index]);
424
+ if (claims.has(c))
425
+ fail(`uses[${i}] claims a use another USE record already claims`);
426
+ claims.add(c);
427
+ if (named.has(u.action_id))
428
+ fail(`uses[${i}] names an action another USE record already names`);
429
+ named.add(u.action_id);
430
+ });
431
+ // 7. Each USE.
432
+ U.forEach((u, i) => {
433
+ const g = byHash.get(u.grant_hash);
434
+ if (g === undefined) {
435
+ if (ids.has(u.grant_id))
436
+ fail(`uses[${i}].grant_hash does not match the grant presented`);
437
+ incomplete.push(`uses[${i}] names a grant that is not in the bundle`);
438
+ return;
439
+ }
440
+ if (u.grant_id !== g.grant_id)
441
+ fail(`uses[${i}].grant_id differs from the grant's`);
442
+ if (u.org_id !== g.org_id)
443
+ fail(`uses[${i}].org_id differs from the grant's`);
444
+ if (u.approver_public_key !== g.public_key)
445
+ fail(`uses[${i}].approver_public_key differs from the grant's key`);
446
+ if (u.max_uses !== g.max_uses)
447
+ fail(`uses[${i}].max_uses differs from the grant's`);
448
+ if (g.max_uses === '')
449
+ fail(`uses[${i}] consumes a grant with no use limit`);
450
+ if (!decLe(u.use_index, g.max_uses))
451
+ fail(`uses[${i}] is use ${u.use_index} of ${g.max_uses}`);
452
+ if (u.consumption_key !== ckey(g, u.org_id)) {
453
+ fail(`uses[${i}].consumption_key is not the key the grant is counted against`);
454
+ }
455
+ if (!inWindow(g, u.timestamp))
456
+ fail(`uses[${i}] was recorded outside the grant's validity window`);
457
+ const a = byAction.get(u.action_id);
458
+ if (a === undefined) {
459
+ incomplete.push(`uses[${i}] names an action that is not in the bundle`);
460
+ return;
461
+ }
462
+ if (a.record.outcome !== 'ALLOWED')
463
+ fail(`uses[${i}] names an action that was not ALLOWED`);
464
+ if (a.record.org_id !== u.org_id)
465
+ fail(`uses[${i}].org_id differs from the action's`);
466
+ if (a.record.args_hash !== u.args_hash)
467
+ fail(`uses[${i}].args_hash differs from the action's`);
468
+ if (own(a.args, 'aqta_grant_hash') !== u.grant_hash) {
469
+ fail(`uses[${i}] names an action whose arguments do not reference its grant`);
470
+ }
471
+ });
472
+ // 8. Each action that references a grant.
473
+ actions.forEach((item, i) => {
474
+ const args = item.args;
475
+ const rec = item.record;
476
+ if (!has(args, 'aqta_grant_id') && !has(args, 'aqta_grant_hash'))
477
+ return;
478
+ const gid = own(args, 'aqta_grant_id');
479
+ const gh = own(args, 'aqta_grant_hash');
480
+ if (typeof gid !== 'string' || typeof gh !== 'string')
481
+ fail(`actions[${i}].args carry a partial grant reference`);
482
+ const g = byHash.get(gh);
483
+ if (g === undefined) {
484
+ if (ids.has(gid))
485
+ fail(`actions[${i}] names a grant whose content differs from the grant presented`);
486
+ if (rec.outcome === 'ALLOWED')
487
+ incomplete.push(`actions[${i}] names a grant that is not in the bundle`);
488
+ return;
489
+ }
490
+ if (gid !== g.grant_id)
491
+ fail(`actions[${i}].aqta_grant_id differs from the grant's`);
492
+ if (rec.outcome !== 'ALLOWED')
493
+ return;
494
+ const why = scopeReason(g, rec, args);
495
+ if (why !== null)
496
+ fail(`actions[${i}] is outside its grant: ${why}`);
497
+ if (trusted === null) {
498
+ incomplete.push('no approver key set was supplied');
499
+ }
500
+ else if (!trusted.has(g.public_key)) {
501
+ fail(`actions[${i}] was authorised by a grant whose key is not a designated approver`);
502
+ }
503
+ if (g.max_uses !== '') {
504
+ if (!U.some((u) => u.action_id === rec.action_id)) {
505
+ incomplete.push(`actions[${i}] consumed a counted grant and its USE record is not in the bundle`);
506
+ }
507
+ }
508
+ else if (!inWindow(g, rec.timestamp)) {
509
+ fail(`actions[${i}] is outside its grant's validity window`);
510
+ }
511
+ });
512
+ // 9. Empty.
513
+ if (actions.length === 0)
514
+ incomplete.push('the bundle carries no action');
515
+ if (incomplete.length)
516
+ return { verdict: 'INCOMPLETE', reason: incomplete[0] };
517
+ return { verdict: 'PASS', reason: null };
518
+ }
519
+ /** Internal, for the interop sweep only: the exact-instant comparator. */
520
+ exports._chainInternal = { cmpInstant };
521
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.js","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;AAqJH,4CAgDC;AAED,8BAEC;AAID,wCAqBC;AAyDD,kCAOC;AAhSD,0DAA6B;AAC7B,6CAAyC;AACzC,yCAA2D;AAE3D,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG,oBAAS,CAAC;AAatG,MAAM,YAAY,GAAG;IACnB,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB;IACnG,mBAAmB,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW;CACtG,CAAC;AACF,MAAM,cAAc,GAAG,CAAC,YA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