@coderifts/sdk 3.13.3 → 3.14.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 +49 -0
- package/dist/cjs/authorize.d.ts +46 -4
- package/dist/cjs/authorize.d.ts.map +1 -1
- package/dist/cjs/authorize.js +22 -1
- package/dist/cjs/authorize.js.map +1 -1
- package/dist/cjs/client.d.ts +31 -3
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +35 -5
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +13 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/vendor/package.json +1 -0
- package/dist/cjs/vendor/receipt-verifier/VENDOR.sha256 +20 -3
- package/dist/cjs/vendor/receipt-verifier/verified-execution-binding.js +202 -11
- package/dist/cjs/vendor/receipt-verifier/verify-grant.js +34 -1
- package/dist/cjs/vendor/receipt-verifier/verify.d.ts +31 -0
- package/dist/cjs/verify-receipt-local.d.ts +69 -0
- package/dist/cjs/verify-receipt-local.d.ts.map +1 -0
- package/dist/cjs/verify-receipt-local.js +103 -0
- package/dist/cjs/verify-receipt-local.js.map +1 -0
- package/dist/esm/authorize.d.ts +46 -4
- package/dist/esm/authorize.d.ts.map +1 -1
- package/dist/esm/authorize.js +22 -1
- package/dist/esm/authorize.js.map +1 -1
- package/dist/esm/client.d.ts +31 -3
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +35 -5
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/vendor/package.json +1 -0
- package/dist/esm/vendor/receipt-verifier/VENDOR.sha256 +20 -3
- package/dist/esm/vendor/receipt-verifier/verified-execution-binding.js +202 -11
- package/dist/esm/vendor/receipt-verifier/verify-grant.js +34 -1
- package/dist/esm/vendor/receipt-verifier/verify.d.ts +31 -0
- package/dist/esm/verify-receipt-local.d.ts +69 -0
- package/dist/esm/verify-receipt-local.d.ts.map +1 -0
- package/dist/esm/verify-receipt-local.js +97 -0
- package/dist/esm/verify-receipt-local.js.map +1 -0
- package/package.json +1 -1
|
@@ -43,6 +43,7 @@ const crypto = require('node:crypto');
|
|
|
43
43
|
|
|
44
44
|
const { verifyExecutionGrant } = require('./verify-grant.js');
|
|
45
45
|
const { verifyEvidenceRootBinding } = require('./verify-evidence.js');
|
|
46
|
+
const { verifyReceipt } = require('./verify.js');
|
|
46
47
|
|
|
47
48
|
const BINDING_V = 'cr.verified-execution-binding.v1';
|
|
48
49
|
|
|
@@ -57,6 +58,24 @@ const STATE = Object.freeze({
|
|
|
57
58
|
RECORDED_UNWITNESSED: 'RECORDED_UNWITNESSED',
|
|
58
59
|
NOT_COMMITTED: 'NOT_COMMITTED',
|
|
59
60
|
AUTHORIZED_AND_COMMITTED: 'AUTHORIZED_AND_COMMITTED',
|
|
61
|
+
/**
|
|
62
|
+
* A CUSTOM aggregation was satisfied — and it is NOT the global success token.
|
|
63
|
+
*
|
|
64
|
+
* ── THE HOLE THIS CLOSES, REPRODUCED BEFORE IT WAS WRITTEN ──────────────────────────────
|
|
65
|
+
*
|
|
66
|
+
* valid grant + committed + NO attestation + NO root, required: ['issuer_grant']
|
|
67
|
+
* -> AUTHORIZED_AND_COMMITTED, authorized_and_committed: true
|
|
68
|
+
*
|
|
69
|
+
* Nothing was forged. The caller simply asked for less, and the function handed back the token
|
|
70
|
+
* every consumer reads as "authorized and committed". `required[]` was a strictness dial that
|
|
71
|
+
* also selected the NAME of success, so narrowing the dial upgraded the verdict — the strongest
|
|
72
|
+
* word in the vocabulary, reachable by asking for the least.
|
|
73
|
+
*
|
|
74
|
+
* A caller may still choose its own authorities. What it may no longer do is call the result by
|
|
75
|
+
* the global name. `AUTHORIZED_AND_COMMITTED` is now reachable ONLY through a closed, versioned
|
|
76
|
+
* profile whose authority set the caller does not get to shorten.
|
|
77
|
+
*/
|
|
78
|
+
CUSTOM_REQUIREMENTS_SATISFIED: 'CUSTOM_REQUIREMENTS_SATISFIED',
|
|
60
79
|
});
|
|
61
80
|
|
|
62
81
|
/** What each authority is allowed to be missing for, so a caller can choose its own strictness. */
|
|
@@ -67,6 +86,36 @@ const AUTHORITY = Object.freeze({
|
|
|
67
86
|
PROVIDER_WITNESS: 'provider_witness',
|
|
68
87
|
});
|
|
69
88
|
|
|
89
|
+
/**
|
|
90
|
+
* CLOSED, VERSIONED ASSURANCE PROFILES.
|
|
91
|
+
*
|
|
92
|
+
* A profile fixes its authority set. The caller names the profile; it does not get to edit what
|
|
93
|
+
* the profile means, and the version in the name is what lets the set change later without
|
|
94
|
+
* silently changing what an older caller was promised.
|
|
95
|
+
*
|
|
96
|
+
* `TRUSTED_EXECUTOR_INTEGRITY_V1` is the honest ceiling of a single-machine chain: the decision
|
|
97
|
+
* receipt verified, the issuer's grant verified, the executor's attestation verified, and one
|
|
98
|
+
* signed root binding the set to one run. It says nothing about a third party, and the name is
|
|
99
|
+
* chosen so it cannot be read as one — `EXTERNALLY_WITNESSED_EXECUTION_V1` is a different profile
|
|
100
|
+
* and no producer can satisfy it today (no signed-witness format exists), which is why it is not
|
|
101
|
+
* declared here as an empty promise.
|
|
102
|
+
*/
|
|
103
|
+
const PROFILE = Object.freeze({
|
|
104
|
+
TRUSTED_EXECUTOR_INTEGRITY_V1: Object.freeze({
|
|
105
|
+
name: 'TRUSTED_EXECUTOR_INTEGRITY_V1',
|
|
106
|
+
authorities: Object.freeze([
|
|
107
|
+
AUTHORITY.ISSUER_GRANT,
|
|
108
|
+
AUTHORITY.EXECUTOR_ATTESTATION,
|
|
109
|
+
AUTHORITY.ONE_RUN_ROOT,
|
|
110
|
+
]),
|
|
111
|
+
// The receipt is mandatory in every profile and is not listed as an authority because it is
|
|
112
|
+
// not optional anywhere — it gates the whole predicate above the state machine.
|
|
113
|
+
proof_scope: 'TRUSTED_EXECUTOR',
|
|
114
|
+
externally_witnessed: false,
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
const PROFILE_NAMES = Object.freeze(Object.keys(PROFILE));
|
|
118
|
+
|
|
70
119
|
const sha256pref = (v) =>
|
|
71
120
|
`sha256:${crypto.createHash('sha256').update(String(v), 'utf8').digest('hex')}`;
|
|
72
121
|
|
|
@@ -116,12 +165,55 @@ function grantClaims(token) {
|
|
|
116
165
|
* @param {{artifact: object, executorKey}} [o.evidenceRoot]
|
|
117
166
|
* @param {{signed: boolean}} [o.providerReadback]
|
|
118
167
|
* @param {boolean} o.committed
|
|
119
|
-
* @param {string
|
|
168
|
+
* @param {string} [o.profile] a CLOSED profile name (see PROFILE). Its authority set cannot be
|
|
169
|
+
* edited by the caller, and only a profile can reach AUTHORIZED_AND_COMMITTED.
|
|
170
|
+
* @param {string[]} [o.required] a CUSTOM authority set. Legal, and it can never produce the
|
|
171
|
+
* global success token — a satisfied custom set reads CUSTOM_REQUIREMENTS_SATISFIED.
|
|
120
172
|
*/
|
|
121
173
|
function verifiedExecutionBinding(o = {}) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
174
|
+
// ── WHICH SET, AND WHO CHOSE IT ─────────────────────────────────────────────────────────
|
|
175
|
+
//
|
|
176
|
+
// A profile and a custom set are different KINDS of question, so they are answered separately
|
|
177
|
+
// and never merged. Passing both is refused rather than resolved by precedence: a caller that
|
|
178
|
+
// names a profile and then also lists authorities is asking two things at once, and picking one
|
|
179
|
+
// silently is how a caller ends up believing it got the other.
|
|
180
|
+
const profileName = typeof o.profile === 'string' && o.profile ? o.profile : null;
|
|
181
|
+
const customRequired = Array.isArray(o.required) && o.required.length ? o.required : null;
|
|
182
|
+
if (profileName && customRequired) {
|
|
183
|
+
return {
|
|
184
|
+
v: BINDING_V,
|
|
185
|
+
authorized_and_committed: false,
|
|
186
|
+
requirements_satisfied: false,
|
|
187
|
+
profile: null,
|
|
188
|
+
proof_scope: null,
|
|
189
|
+
externally_witnessed: false,
|
|
190
|
+
state: STATE.UNAUTHORIZED,
|
|
191
|
+
authorities: {},
|
|
192
|
+
shortfalls: ['profile: both `profile` and `required` were supplied — a closed profile\'s '
|
|
193
|
+
+ 'authority set is not editable, so this asks two different questions at once'],
|
|
194
|
+
does_not_prove: [],
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
if (profileName && !Object.prototype.hasOwnProperty.call(PROFILE, profileName)) {
|
|
198
|
+
// FAIL CLOSED on an unknown profile. Falling back to a default would let a typo — or a caller
|
|
199
|
+
// written against a future version — silently receive a weaker check than it named.
|
|
200
|
+
return {
|
|
201
|
+
v: BINDING_V,
|
|
202
|
+
authorized_and_committed: false,
|
|
203
|
+
requirements_satisfied: false,
|
|
204
|
+
profile: null,
|
|
205
|
+
proof_scope: null,
|
|
206
|
+
externally_witnessed: false,
|
|
207
|
+
state: STATE.UNAUTHORIZED,
|
|
208
|
+
authorities: {},
|
|
209
|
+
shortfalls: [`profile: unknown assurance profile "${profileName}"; known: ${PROFILE_NAMES.join(', ')}`],
|
|
210
|
+
does_not_prove: [],
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
const profile = profileName ? PROFILE[profileName] : null;
|
|
214
|
+
const required = new Set(profile
|
|
215
|
+
? profile.authorities
|
|
216
|
+
: (customRequired || [AUTHORITY.ISSUER_GRANT, AUTHORITY.EXECUTOR_ATTESTATION]));
|
|
125
217
|
const shortfalls = [];
|
|
126
218
|
const authorities = {};
|
|
127
219
|
const note = (name, ok, detail) => {
|
|
@@ -225,9 +317,31 @@ function verifiedExecutionBinding(o = {}) {
|
|
|
225
317
|
if (!er || !er.artifact) {
|
|
226
318
|
note(AUTHORITY.ONE_RUN_ROOT, false,
|
|
227
319
|
'no cr.evidence.root.v1 was supplied, so these bytes are not shown to be one run');
|
|
320
|
+
} else if (typeof verifyEvidenceRootBinding !== 'function') {
|
|
321
|
+
// ── A MISSING VERIFIER IS A REFUSAL, NEVER A CRASH ───────────────────────────────────
|
|
322
|
+
//
|
|
323
|
+
// MEASURED on a consumer: agent-guard vendors an OLDER `verify-evidence.js` that does not
|
|
324
|
+
// export `verifyEvidenceRootBinding` (true on its HEAD too), so this line threw a TypeError
|
|
325
|
+
// the moment anyone passed an `evidenceRoot`. Latent there — that guard holds no root — and
|
|
326
|
+
// the SHAPE is what matters: a crash is not an answer, and a caller cannot tell "the core
|
|
327
|
+
// blew up" from "the core is unavailable" from "the binding failed".
|
|
328
|
+
//
|
|
329
|
+
// Every OTHER dependency this file has is already used unconditionally, so this is the one
|
|
330
|
+
// place a mixed vendor pin can leave a hole. Refusing here is the fail-closed answer, and it
|
|
331
|
+
// names the cause rather than reporting a generic unbound root.
|
|
332
|
+
note(AUTHORITY.ONE_RUN_ROOT, false,
|
|
333
|
+
'the evidence-root verifier is not available in this build (the vendored verify-evidence.js '
|
|
334
|
+
+ 'does not export verifyEvidenceRootBinding) — the root was NOT checked, and an unchecked '
|
|
335
|
+
+ 'root is refused rather than reported as unbound');
|
|
228
336
|
} else {
|
|
229
|
-
|
|
230
|
-
|
|
337
|
+
let r;
|
|
338
|
+
try {
|
|
339
|
+
r = verifyEvidenceRootBinding(er.artifact, { executorKey: er.executorKey, sidecars: er.sidecars });
|
|
340
|
+
} catch (err) {
|
|
341
|
+
r = { ok: false, failures: [`the evidence-root verifier threw: ${(err && err.message) || 'error'}`] };
|
|
342
|
+
}
|
|
343
|
+
note(AUTHORITY.ONE_RUN_ROOT, r.ok === true,
|
|
344
|
+
r.ok ? 'bound' : ((r.failures && r.failures[0]) || 'unbound'));
|
|
231
345
|
}
|
|
232
346
|
|
|
233
347
|
// ── 4. THE PROVIDER WITNESS ────────────────────────────────────────────────────────────
|
|
@@ -273,11 +387,65 @@ function verifiedExecutionBinding(o = {}) {
|
|
|
273
387
|
// Left as-is deliberately: making a bare boolean insufficient would change the input shape of
|
|
274
388
|
// all five consumers at once, and that belongs with the closed-profile work (1465), not
|
|
275
389
|
// half-done in a round that would leave them broken. The gap is named, not narrowed in silence.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
390
|
+
// ── THE DECISION RECEIPT, VERIFIED HERE WHEN IT CAN BE ─────────────────────────────────
|
|
391
|
+
//
|
|
392
|
+
// ── THE FOURTH CALLER-BOOLEAN THIS REPOSITORY HAS MET ──────────────────────────────────
|
|
393
|
+
//
|
|
394
|
+
// providerReadback: { signed: true } believed because it was set (closed)
|
|
395
|
+
// attestation: { present: true } believed because it was set (closed)
|
|
396
|
+
// call_hash present == "tool-call bound" (pre-empted)
|
|
397
|
+
// receipt: { verified: true } believed because it was set (this)
|
|
398
|
+
//
|
|
399
|
+
// `receipt.verified` is the CALLER's word. With no token and no keyring, nothing was checked and
|
|
400
|
+
// this function had no way to check it — and a caller that simply set the flag reached a
|
|
401
|
+
// satisfied verdict. `receipt_caller_asserted` recorded it, which is honest reporting and not a
|
|
402
|
+
// gate: a field nobody branches on does not stop anything.
|
|
403
|
+
//
|
|
404
|
+
// Now: when a token AND a key source are supplied, THIS function verifies the receipt. When they
|
|
405
|
+
// are not, the assertion is accepted only for a CUSTOM aggregation — where the caller owns its
|
|
406
|
+
// own question — and can never reach AUTHORIZED_AND_COMMITTED, which is the word every consumer
|
|
407
|
+
// reads as the answer.
|
|
408
|
+
const rc = o.receipt || {};
|
|
409
|
+
let receiptOk = false;
|
|
410
|
+
let receiptAsserted = false;
|
|
411
|
+
let receiptDetail = 'the decision receipt did not verify';
|
|
412
|
+
const keySource = rc.keyring || rc.publicKey;
|
|
413
|
+
if (typeof rc.token === 'string' && rc.token.length > 0 && keySource) {
|
|
414
|
+
let rv;
|
|
415
|
+
try {
|
|
416
|
+
rv = verifyReceipt(rc.token, {
|
|
417
|
+
ctx: { ...(rc.keyring ? { keyring: rc.keyring } : { publicKey: rc.publicKey }),
|
|
418
|
+
expectedKid: rc.expectedKid === undefined ? null : rc.expectedKid },
|
|
419
|
+
...(Number.isFinite(rc.now) ? { now: rc.now } : {}),
|
|
420
|
+
});
|
|
421
|
+
} catch (err) {
|
|
422
|
+
rv = { valid: false, status: 'VERIFIER_ERROR', reason: (err && err.message) || 'error' };
|
|
423
|
+
}
|
|
424
|
+
receiptOk = rv.valid === true;
|
|
425
|
+
if (!receiptOk) receiptDetail = `the decision receipt did not verify (${rv.status}: ${rv.reason})`;
|
|
426
|
+
} else if (rc.verified === true) {
|
|
427
|
+
// Accepted, and MARKED. The state machine below refuses to hand this the global name.
|
|
428
|
+
receiptOk = true;
|
|
429
|
+
receiptAsserted = true;
|
|
430
|
+
} else if (rc.token || keySource) {
|
|
431
|
+
receiptDetail = 'the receipt was supplied without '
|
|
432
|
+
+ `${rc.token ? 'a keyring or public key' : 'its token'}, so it could not be verified here`;
|
|
433
|
+
} else {
|
|
434
|
+
receiptDetail = 'no decision receipt was supplied';
|
|
435
|
+
}
|
|
436
|
+
if (!receiptOk) shortfalls.unshift(`receipt: ${receiptDetail}`);
|
|
437
|
+
if (receiptAsserted) {
|
|
438
|
+
shortfalls.push('decision_receipt: `verified` was taken on the caller\'s word — no token and '
|
|
439
|
+
+ 'no keyring were supplied, so nothing was checked here');
|
|
440
|
+
}
|
|
279
441
|
|
|
280
|
-
|
|
442
|
+
// THE NAME OF SUCCESS DEPENDS ON WHO CHOSE THE SET, not on how much of it passed. A custom
|
|
443
|
+
// aggregation that meets everything it asked for is satisfied — and says so in its own words.
|
|
444
|
+
// A CALLER-ASSERTED RECEIPT CAN NEVER BE THE GLOBAL CLAIM. It is not downgraded to a failure —
|
|
445
|
+
// a custom aggregation may legitimately own that determination — but the strongest word in the
|
|
446
|
+
// vocabulary is not available to a run whose receipt nobody verified.
|
|
447
|
+
let state = (profile && !receiptAsserted)
|
|
448
|
+
? STATE.AUTHORIZED_AND_COMMITTED : STATE.CUSTOM_REQUIREMENTS_SATISFIED;
|
|
281
449
|
if (!receiptOk || (required.has(AUTHORITY.ISSUER_GRANT) && !grantOk)) state = STATE.UNAUTHORIZED;
|
|
282
450
|
else if (required.has(AUTHORITY.EXECUTOR_ATTESTATION) && !attOk) state = STATE.COMMIT_UNPROVEN;
|
|
283
451
|
else if (required.has(AUTHORITY.ONE_RUN_ROOT) && !authorities[AUTHORITY.ONE_RUN_ROOT].ok) {
|
|
@@ -285,11 +453,31 @@ function verifiedExecutionBinding(o = {}) {
|
|
|
285
453
|
} else if (required.has(AUTHORITY.PROVIDER_WITNESS) && !authorities[AUTHORITY.PROVIDER_WITNESS].ok) {
|
|
286
454
|
state = STATE.RECORDED_UNWITNESSED;
|
|
287
455
|
} else if (!committed) state = STATE.NOT_COMMITTED;
|
|
456
|
+
// The default set (no profile, no custom list) is the historical grant+attestation pair. It is
|
|
457
|
+
// an implicit choice by the caller, not a profile, so it lands in the custom lane too.
|
|
458
|
+
|
|
288
459
|
|
|
289
460
|
return {
|
|
290
461
|
v: BINDING_V,
|
|
291
462
|
authorized_and_committed: state === STATE.AUTHORIZED_AND_COMMITTED,
|
|
463
|
+
/**
|
|
464
|
+
* Did the set THIS CALLER ASKED FOR pass? True for a satisfied profile and for a satisfied
|
|
465
|
+
* custom aggregation alike.
|
|
466
|
+
*
|
|
467
|
+
* Separated from `authorized_and_committed` on purpose. A caller that only wants to know
|
|
468
|
+
* whether its own question was answered should not have to string-compare a state name, and
|
|
469
|
+
* — more importantly — should not be tempted to read the global claim because it was the only
|
|
470
|
+
* boolean available. That temptation is how `required: ['issuer_grant']` came to mean
|
|
471
|
+
* "authorized and committed" in the first place.
|
|
472
|
+
*/
|
|
473
|
+
requirements_satisfied: state === STATE.AUTHORIZED_AND_COMMITTED
|
|
474
|
+
|| state === STATE.CUSTOM_REQUIREMENTS_SATISFIED,
|
|
292
475
|
state,
|
|
476
|
+
/** Which closed profile answered this, or null when the caller aggregated its own set. */
|
|
477
|
+
profile: profile ? profile.name : null,
|
|
478
|
+
/** Stated on every result so a reader never has to infer it from the state name. */
|
|
479
|
+
proof_scope: profile ? profile.proof_scope : null,
|
|
480
|
+
externally_witnessed: profile ? profile.externally_witnessed : false,
|
|
293
481
|
authorities,
|
|
294
482
|
shortfalls,
|
|
295
483
|
/** True when `receipt.verified` was taken on the caller's word rather than established here. */
|
|
@@ -313,4 +501,7 @@ function verifiedExecutionBinding(o = {}) {
|
|
|
313
501
|
};
|
|
314
502
|
}
|
|
315
503
|
|
|
316
|
-
module.exports = {
|
|
504
|
+
module.exports = {
|
|
505
|
+
verifiedExecutionBinding, STATE, AUTHORITY, PROFILE, PROFILE_NAMES, BINDING_V,
|
|
506
|
+
grantClaims, attestationClaims,
|
|
507
|
+
};
|
|
@@ -58,6 +58,35 @@ const V2_REQUIRED_STRINGS = Object.freeze([
|
|
|
58
58
|
'operation', 'target_uri', 'expected_state_token', 'after_payload_hash',
|
|
59
59
|
'nonce_hash', 'policy_hash', 'audience_hash', 'not_before', 'expires_at',
|
|
60
60
|
]);
|
|
61
|
+
/**
|
|
62
|
+
* RESERVED, AND INERT. Optional v2 fields a grant MAY carry and this verifier reads as NOTHING.
|
|
63
|
+
*
|
|
64
|
+
* ── WHY THEY EXIST BEFORE THE GATE THAT USES THEM ───────────────────────────────────────────
|
|
65
|
+
*
|
|
66
|
+
* The admitted key set is closed: an unknown field is `MALFORMED/unknown_field`, which is the
|
|
67
|
+
* right default and also means a future field cannot be introduced without every deployed
|
|
68
|
+
* verifier refusing the grants that carry it. Reserving the two names now is what keeps that
|
|
69
|
+
* introduction from being a breaking change later.
|
|
70
|
+
*
|
|
71
|
+
* ── WHAT THEY DO NOT DO, WHICH IS THE POINT ─────────────────────────────────────────────────
|
|
72
|
+
*
|
|
73
|
+
* NOTHING. A grant carrying `call_hash` is graded EXACTLY as one without it. There is no check,
|
|
74
|
+
* no comparison, and no `intended` field they bind to.
|
|
75
|
+
*
|
|
76
|
+
* A VERIFIER THAT READS THEIR PRESENCE AS AUTHORIZATION IS WRONG. `call_hash` present does not
|
|
77
|
+
* mean a tool call was bound; `executor_image_digest` present does not mean an executor image was
|
|
78
|
+
* pinned. Nothing signs a promise that the value is true, nothing compares it to anything, and an
|
|
79
|
+
* attacker who can mint a grant can put any value in them. Presence is not proof — it is a slot.
|
|
80
|
+
*
|
|
81
|
+
* They are unsigned-by-default only in the sense that no separate signature covers them: the v2
|
|
82
|
+
* signing input is the canonical JSON of the WHOLE body, so a grant that carries them signs
|
|
83
|
+
* different bytes than one that does not, and neither can be edited into the other. That binds
|
|
84
|
+
* the VALUE to the issuer; it says nothing about whether the value means anything.
|
|
85
|
+
*
|
|
86
|
+
* When a gate for them lands it will be a NEW check with its own negative fixtures, and this
|
|
87
|
+
* comment is what a reader should be shown if anyone claims otherwise before then.
|
|
88
|
+
*/
|
|
89
|
+
const V2_RESERVED_INERT = Object.freeze(['call_hash', 'executor_image_digest']);
|
|
61
90
|
const TARGET_SCHEMES = Object.freeze(['fs', 'git', 'api', 'db', 'registry', 'deploy']);
|
|
62
91
|
const DEFAULT_FETCH_URL = 'https://app.coderifts.com/api/v1/attestation/public-key';
|
|
63
92
|
|
|
@@ -177,7 +206,9 @@ function verifyExecutionGrantV2(payload, sigB64, ctx, opts = {}) {
|
|
|
177
206
|
if (!Number.isInteger(payload.max_attempts) || payload.max_attempts < 1) {
|
|
178
207
|
return { valid: false, status: 'MALFORMED', reason: 'bad_max_attempts', payload };
|
|
179
208
|
}
|
|
180
|
-
|
|
209
|
+
// The reserved names are ADMITTED, never inspected. Everything below this line treats a payload
|
|
210
|
+
// carrying them identically to one that does not — verified by test, not by intent.
|
|
211
|
+
const allowed = new Set([...V2_REQUIRED_STRINGS, 'max_attempts', ...V2_RESERVED_INERT]);
|
|
181
212
|
for (const k of Object.keys(payload)) {
|
|
182
213
|
if (!allowed.has(k)) return { valid: false, status: 'MALFORMED', reason: 'unknown_field', payload };
|
|
183
214
|
}
|
|
@@ -555,6 +586,8 @@ module.exports = {
|
|
|
555
586
|
SIGNING_PREFIX_V2,
|
|
556
587
|
SIGNED_FIELDS,
|
|
557
588
|
V1_OPTIONAL_SIGNED_FIELDS,
|
|
589
|
+
V2_REQUIRED_STRINGS,
|
|
590
|
+
V2_RESERVED_INERT,
|
|
558
591
|
CLOCK_SKEW_LEEWAY_MS,
|
|
559
592
|
isIssuedInFuture,
|
|
560
593
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the vendored `verify.js`, written HERE rather than in the vendored file.
|
|
3
|
+
*
|
|
4
|
+
* The vendored bytes must stay byte-identical to receipt-verifier's — a pin that survives an edit
|
|
5
|
+
* is not a pin — so the declaration lives beside them instead of inside them.
|
|
6
|
+
*
|
|
7
|
+
* Only the two entry points this SDK uses are declared. Declaring the rest would invite callers to
|
|
8
|
+
* reach into the core through this package, and the core is vendored for internal use, not
|
|
9
|
+
* re-exported as an API this SDK then owns.
|
|
10
|
+
*/
|
|
11
|
+
export interface CoreReceiptVerdict {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
status: string;
|
|
14
|
+
reason?: string;
|
|
15
|
+
payload?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The DEFAULT export — `module.exports` whole.
|
|
19
|
+
*
|
|
20
|
+
* Declared this way because node's cjs-module-lexer does not surface every name on this module to
|
|
21
|
+
* an ESM importer (measured: `verifyReceipt` yes, `keyringFromDocument` no). Named declarations
|
|
22
|
+
* here would type-check and then fail at load in the ESM build.
|
|
23
|
+
*/
|
|
24
|
+
declare const core: {
|
|
25
|
+
verifyReceipt(
|
|
26
|
+
token: string,
|
|
27
|
+
opts: { ctx: { keyring: unknown; expectedKid: string | null }; now?: number },
|
|
28
|
+
): CoreReceiptVerdict;
|
|
29
|
+
keyringFromDocument(doc: unknown): Map<string, unknown> | { byKid: Map<string, unknown> };
|
|
30
|
+
};
|
|
31
|
+
export default core;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LOCAL receipt verification — the proof, and the only thing on this surface that is one.
|
|
3
|
+
*
|
|
4
|
+
* ── WHY THIS EXISTS ─────────────────────────────────────────────────────────────────────────
|
|
5
|
+
*
|
|
6
|
+
* MEASURED before it was written: this SDK's only `verifyReceipt` was
|
|
7
|
+
* `client.verifyReceipt()` — an HTTP POST to `/api/v1/verify-receipt`. It answers well and it is
|
|
8
|
+
* useful, and it is not an offline verification: the caller learns what CodeRifts says, over a
|
|
9
|
+
* network, about bytes CodeRifts was handed. A reader told "verify offline, without us" and given
|
|
10
|
+
* only that method has been told something the package could not do.
|
|
11
|
+
*
|
|
12
|
+
* This runs the SAME vendored core the public receipt-verifier and the conformance CLI run, in
|
|
13
|
+
* process, over bytes already in memory plus a keyring the CALLER supplies. No API key, no
|
|
14
|
+
* network, full Ed25519.
|
|
15
|
+
*
|
|
16
|
+
* ── WHAT IT IS NOT ──────────────────────────────────────────────────────────────────────────
|
|
17
|
+
*
|
|
18
|
+
* It is not authorization. A valid signature says a holder of the named key signed these bytes and
|
|
19
|
+
* that the receipt has not expired; it does not say the receipt permits the action you are about
|
|
20
|
+
* to take. `client.verifyReceipt(token, intended)` answers that second question, on the server,
|
|
21
|
+
* and `authorize()` answers the execution-binding one. Those are different questions and this
|
|
22
|
+
* module deliberately answers only the first.
|
|
23
|
+
*
|
|
24
|
+
* It also cannot see REVOCATION or the issuer's clock. A key compromised five minutes ago still
|
|
25
|
+
* verifies here, because nothing local can know. That is the whole reason
|
|
26
|
+
* `verifyReceiptViaServer` exists beside it — as a mirror, never as the proof.
|
|
27
|
+
*/
|
|
28
|
+
import type { PinnedKeyring } from './authorize.js';
|
|
29
|
+
/** The verdict, in the vocabulary the receipt-verifier and the conformance CLI already use. */
|
|
30
|
+
export interface LocalReceiptVerdict {
|
|
31
|
+
/** True only when the signature verified against the pinned key and the receipt is current. */
|
|
32
|
+
valid: boolean;
|
|
33
|
+
/** VERIFIED_CURRENT · INVALID_SIGNATURE · MALFORMED · UNKNOWN_KEY · EXPIRED · … */
|
|
34
|
+
status: string;
|
|
35
|
+
/** Present on a refusal; the specific cause, not a class. */
|
|
36
|
+
reason?: string;
|
|
37
|
+
/** The decoded body, when the token decoded at all. Never evidence on its own. */
|
|
38
|
+
payload?: Record<string, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Said on every result, so a caller cannot read this as more than it is.
|
|
41
|
+
*
|
|
42
|
+
* A verdict that travels without its ceiling gets quoted without it.
|
|
43
|
+
*/
|
|
44
|
+
does_not_prove: string[];
|
|
45
|
+
}
|
|
46
|
+
export interface VerifyReceiptLocalOptions {
|
|
47
|
+
/**
|
|
48
|
+
* THE KEYS YOU PIN, and the reason this is required rather than fetched.
|
|
49
|
+
*
|
|
50
|
+
* A verifier that downloads the key it is about to trust has not verified anything an attacker
|
|
51
|
+
* on the path could not arrange. Fetching the keyring is a deployment decision — make it once,
|
|
52
|
+
* pin the result, and hand it in.
|
|
53
|
+
*/
|
|
54
|
+
keyring: PinnedKeyring;
|
|
55
|
+
/** Refuse a token whose `kid` is not this one. Null (default) accepts any pinned kid. */
|
|
56
|
+
expectedKid?: string | null;
|
|
57
|
+
/** Clock injection. Absent = the host clock. */
|
|
58
|
+
now?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Verify a chain receipt LOCALLY. No network, no API key, full Ed25519.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* import { verifyReceipt } from '@coderifts/sdk';
|
|
65
|
+
* const r = verifyReceipt(token, { keyring: pinnedKeys });
|
|
66
|
+
* if (!r.valid) throw new Error(`${r.status}: ${r.reason}`);
|
|
67
|
+
*/
|
|
68
|
+
export declare function verifyReceipt(token: string, options: VerifyReceiptLocalOptions): LocalReceiptVerdict;
|
|
69
|
+
//# sourceMappingURL=verify-receipt-local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-receipt-local.d.ts","sourceRoot":"","sources":["../../src/verify-receipt-local.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAkBpD,+FAA+F;AAC/F,MAAM,WAAW,mBAAmB;IAChC,+FAA+F;IAC/F,KAAK,EAAE,OAAO,CAAC;IACf,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC;;;;OAIG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,yBAAyB;IACtC;;;;;;OAMG;IACH,OAAO,EAAE,aAAa,CAAC;IACvB,yFAAyF;IACzF,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAmCD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CACzB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,yBAAyB,GACnC,mBAAmB,CAarB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LOCAL receipt verification — the proof, and the only thing on this surface that is one.
|
|
4
|
+
*
|
|
5
|
+
* ── WHY THIS EXISTS ─────────────────────────────────────────────────────────────────────────
|
|
6
|
+
*
|
|
7
|
+
* MEASURED before it was written: this SDK's only `verifyReceipt` was
|
|
8
|
+
* `client.verifyReceipt()` — an HTTP POST to `/api/v1/verify-receipt`. It answers well and it is
|
|
9
|
+
* useful, and it is not an offline verification: the caller learns what CodeRifts says, over a
|
|
10
|
+
* network, about bytes CodeRifts was handed. A reader told "verify offline, without us" and given
|
|
11
|
+
* only that method has been told something the package could not do.
|
|
12
|
+
*
|
|
13
|
+
* This runs the SAME vendored core the public receipt-verifier and the conformance CLI run, in
|
|
14
|
+
* process, over bytes already in memory plus a keyring the CALLER supplies. No API key, no
|
|
15
|
+
* network, full Ed25519.
|
|
16
|
+
*
|
|
17
|
+
* ── WHAT IT IS NOT ──────────────────────────────────────────────────────────────────────────
|
|
18
|
+
*
|
|
19
|
+
* It is not authorization. A valid signature says a holder of the named key signed these bytes and
|
|
20
|
+
* that the receipt has not expired; it does not say the receipt permits the action you are about
|
|
21
|
+
* to take. `client.verifyReceipt(token, intended)` answers that second question, on the server,
|
|
22
|
+
* and `authorize()` answers the execution-binding one. Those are different questions and this
|
|
23
|
+
* module deliberately answers only the first.
|
|
24
|
+
*
|
|
25
|
+
* It also cannot see REVOCATION or the issuer's clock. A key compromised five minutes ago still
|
|
26
|
+
* verifies here, because nothing local can know. That is the whole reason
|
|
27
|
+
* `verifyReceiptViaServer` exists beside it — as a mirror, never as the proof.
|
|
28
|
+
*/
|
|
29
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.verifyReceipt = verifyReceipt;
|
|
34
|
+
// ── A STATIC IMPORT, AND THAT IS THE POINT ──────────────────────────────────────────────────
|
|
35
|
+
//
|
|
36
|
+
// MEASURED on the built package: `authorize()` loads the same core with a bare `require(...)`, and
|
|
37
|
+
// `dist/esm/authorize.js` therefore throws `require is not defined` for every ESM consumer. The
|
|
38
|
+
// tests never saw it because they load the CJS source. A call-time `require` is invisible to the
|
|
39
|
+
// compiler in exactly the build where it cannot work.
|
|
40
|
+
//
|
|
41
|
+
// A static import is compiled to `require` for the CJS output and left as an import for the ESM
|
|
42
|
+
// one, so this module works in both — and the compiler, not a runtime, is what checks it.
|
|
43
|
+
//
|
|
44
|
+
// The DEFAULT import, not named ones. MEASURED on the built ESM package: node's cjs-module-lexer
|
|
45
|
+
// resolved `verifyReceipt` from the vendored CommonJS and NOT `keyringFromDocument`, so a named
|
|
46
|
+
// import compiled fine and threw at load time — "does not provide an export named". Taking
|
|
47
|
+
// `module.exports` whole and destructuring at runtime is interop that does not depend on a lexer
|
|
48
|
+
// guessing right about bytes this package is forbidden to edit.
|
|
49
|
+
const verify_js_1 = __importDefault(require("./vendor/receipt-verifier/verify.js"));
|
|
50
|
+
const DOES_NOT_PROVE = Object.freeze([
|
|
51
|
+
'that the receipt AUTHORIZES the action you are about to take — a valid signature is '
|
|
52
|
+
+ 'authenticity, not authorization. Pass an intended context to the server verify, or use '
|
|
53
|
+
+ 'authorize() for the execution binding',
|
|
54
|
+
'that the signing key is still trusted — REVOCATION and the issuer\'s clock are not visible '
|
|
55
|
+
+ 'to any local verifier, including this one. A key compromised a minute ago still verifies here',
|
|
56
|
+
'that the bytes came from the run you think they did — this checks ONE token, and "these '
|
|
57
|
+
+ 'tokens are one run" is a property of a set (see cr.evidence.root.v1)',
|
|
58
|
+
]);
|
|
59
|
+
function toKeyringMap(keyring) {
|
|
60
|
+
if (!keyring || !Array.isArray(keyring.keys) || keyring.keys.length === 0) {
|
|
61
|
+
throw new TypeError('verifyReceipt: a keyring with at least one key is required — this '
|
|
62
|
+
+ 'verifier does not fetch keys, because a verifier that downloads the key it is about '
|
|
63
|
+
+ 'to trust has verified nothing an attacker on the path could not arrange');
|
|
64
|
+
}
|
|
65
|
+
// THE CORE'S OWN keyring parser, not a second one written here.
|
|
66
|
+
//
|
|
67
|
+
// `keyringFromDocument` is the function the receipt-verifier CLI and the conformance measure
|
|
68
|
+
// both use. Re-implementing the parse in this file would be a second idea of what a keyring
|
|
69
|
+
// is — the exact shape 1423 came from, where conformance had its own notion of checking and it
|
|
70
|
+
// was weaker than prove's.
|
|
71
|
+
const parsed = verify_js_1.default.keyringFromDocument(keyring);
|
|
72
|
+
// The core returns either a Map or a `{ byKid }` wrapper depending on the document shape it
|
|
73
|
+
// was handed. Both are accepted here rather than the caller being told which to produce.
|
|
74
|
+
const m = (parsed && parsed.byKid)
|
|
75
|
+
|| parsed;
|
|
76
|
+
if (!m || typeof m.get !== 'function' || m.size === 0) {
|
|
77
|
+
throw new TypeError('verifyReceipt: the keyring contained no usable {kid, public_key_pem}');
|
|
78
|
+
}
|
|
79
|
+
return m;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Verify a chain receipt LOCALLY. No network, no API key, full Ed25519.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* import { verifyReceipt } from '@coderifts/sdk';
|
|
86
|
+
* const r = verifyReceipt(token, { keyring: pinnedKeys });
|
|
87
|
+
* if (!r.valid) throw new Error(`${r.status}: ${r.reason}`);
|
|
88
|
+
*/
|
|
89
|
+
function verifyReceipt(token, options) {
|
|
90
|
+
const ring = toKeyringMap(options && options.keyring);
|
|
91
|
+
const r = verify_js_1.default.verifyReceipt(token, {
|
|
92
|
+
ctx: { keyring: ring, expectedKid: options.expectedKid ?? null },
|
|
93
|
+
...(Number.isFinite(options.now) ? { now: options.now } : {}),
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
valid: r.valid === true,
|
|
97
|
+
status: r.status,
|
|
98
|
+
...(r.reason ? { reason: r.reason } : {}),
|
|
99
|
+
...(r.payload ? { payload: r.payload } : {}),
|
|
100
|
+
does_not_prove: [...DOES_NOT_PROVE],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=verify-receipt-local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-receipt-local.js","sourceRoot":"","sources":["../../src/verify-receipt-local.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;AA8FH,sCAgBC;AA3GD,+FAA+F;AAC/F,EAAE;AACF,mGAAmG;AACnG,gGAAgG;AAChG,iGAAiG;AACjG,sDAAsD;AACtD,EAAE;AACF,gGAAgG;AAChG,0FAA0F;AAC1F,EAAE;AACF,iGAAiG;AACjG,gGAAgG;AAChG,2FAA2F;AAC3F,iGAAiG;AACjG,gEAAgE;AAChE,oFAAuD;AAmCvD,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IACjC,sFAAsF;UACp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AC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChE,CAAC,CAAC;IACH,OAAO;QACH,KAAK,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI;QACvB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,cAAc,EAAE,CAAC,GAAG,cAAc,CAAC;KACtC,CAAC;AACN,CAAC"}
|
package/dist/esm/authorize.d.ts
CHANGED
|
@@ -42,6 +42,14 @@ export type AuthorizationState = 'AUTHORIZED_AND_COMMITTED'
|
|
|
42
42
|
| 'ONE_RUN_UNPROVEN'
|
|
43
43
|
/** Everything above holds, and no provider signed a witness of it. */
|
|
44
44
|
| 'RECORDED_UNWITNESSED'
|
|
45
|
+
/**
|
|
46
|
+
* A CUSTOM authority set was satisfied — and this is deliberately NOT the global claim.
|
|
47
|
+
*
|
|
48
|
+
* A caller that names its own `required[]` asks a narrower question, and the core will not
|
|
49
|
+
* answer a narrower question with the widest word. Read `requirements_satisfied` for "my set
|
|
50
|
+
* passed"; read `authorized_and_committed` only for the closed-profile claim.
|
|
51
|
+
*/
|
|
52
|
+
| 'CUSTOM_REQUIREMENTS_SATISFIED'
|
|
45
53
|
/** The evidence is in order and the change was not committed. */
|
|
46
54
|
| 'NOT_COMMITTED';
|
|
47
55
|
/** The four independent authorities. Only their intersection yields success. */
|
|
@@ -55,6 +63,12 @@ export interface AuthorityResult {
|
|
|
55
63
|
export interface AuthorizeResult {
|
|
56
64
|
/** True only when every REQUIRED authority holds and the change was committed. */
|
|
57
65
|
authorized_and_committed: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Did the set THIS CALLER asked for pass? True for a satisfied closed profile and for a
|
|
68
|
+
* satisfied custom aggregation alike — so a caller that only wants its own answer never has
|
|
69
|
+
* to reach for the global one because it was the only boolean available.
|
|
70
|
+
*/
|
|
71
|
+
requirements_satisfied: boolean;
|
|
58
72
|
state: AuthorizationState;
|
|
59
73
|
authorities: Record<AuthorityName, AuthorityResult>;
|
|
60
74
|
/** One line per unmet required authority, in the core's words. */
|
|
@@ -77,8 +91,17 @@ export interface AuthorizeInput {
|
|
|
77
91
|
* this function lie for you.
|
|
78
92
|
*/
|
|
79
93
|
receipt: {
|
|
94
|
+
/**
|
|
95
|
+
* YOUR determination, accepted only as a custom caller's own. Supplying this alone can no
|
|
96
|
+
* longer produce `authorized_and_committed`: the core marks the result caller-asserted.
|
|
97
|
+
*/
|
|
80
98
|
verified: boolean;
|
|
99
|
+
/** The receipt's exact bytes. With a key source below, THE CORE verifies them. */
|
|
81
100
|
token?: string;
|
|
101
|
+
keyring?: PinnedKeyring | null;
|
|
102
|
+
publicKeyPem?: string;
|
|
103
|
+
expectedKid?: string | null;
|
|
104
|
+
now?: number;
|
|
82
105
|
};
|
|
83
106
|
/**
|
|
84
107
|
* THE EXACT BYTES THE ISSUER SIGNED. Not a grant read back out of a tool result: a caller who
|
|
@@ -109,10 +132,29 @@ export interface AuthorizeInput {
|
|
|
109
132
|
} | null;
|
|
110
133
|
committed: boolean;
|
|
111
134
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
135
|
+
* A CLOSED, VERSIONED assurance profile — the only way to reach `authorized_and_committed`.
|
|
136
|
+
*
|
|
137
|
+
* ── THE MEASURED GAP THIS CLOSES ────────────────────────────────────────────────────────
|
|
138
|
+
*
|
|
139
|
+
* The core reserves the global claim for a profile whose authority set the caller cannot
|
|
140
|
+
* shorten. This surface did not pass `profile` through AT ALL, so an SDK caller holding a
|
|
141
|
+
* complete capture — grant, attestation and a one-run evidence root — could not ask for that
|
|
142
|
+
* claim by any means. Every answer was `CUSTOM_REQUIREMENTS_SATISFIED`, which is the honest
|
|
143
|
+
* name for a narrower question, and here it was the only name available.
|
|
144
|
+
*
|
|
145
|
+
* A profile's set is NOT editable: passing `profile` and `required` together is refused by the
|
|
146
|
+
* core rather than resolved by precedence, because that asks two different questions at once.
|
|
147
|
+
*/
|
|
148
|
+
profile?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Which authorities this caller demands, when it is aggregating its own set. Defaults to
|
|
151
|
+
* issuer_grant + executor_attestation — the pair a holder of a grant and an attestation can
|
|
152
|
+
* actually establish. Ask for more only when you hold the evidence for it, or the answer will
|
|
153
|
+
* name a shortfall about evidence you were never going to supply.
|
|
154
|
+
*
|
|
155
|
+
* A satisfied custom set reads `CUSTOM_REQUIREMENTS_SATISFIED`, never the global claim. That
|
|
156
|
+
* is not a downgrade: it is the difference between "the set I chose passed" and "this run is
|
|
157
|
+
* authorized and committed", and only a closed profile can say the second.
|
|
116
158
|
*/
|
|
117
159
|
required?: AuthorityName[];
|
|
118
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.d.ts","sourceRoot":"","sources":["../../src/authorize.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GACxB,0BAA0B;AAC5B,4FAA4F;GAC1F,cAAc;AAChB,4EAA4E;GAC1E,iBAAiB;AACnB,mFAAmF;GACjF,kBAAkB;AACpB,sEAAsE;GACpE,sBAAsB;AACxB,iEAAiE;GAC/D,eAAe,CAAC;AAEtB,gFAAgF;AAChF,MAAM,MAAM,aAAa,GACnB,cAAc,GACd,sBAAsB,GACtB,cAAc,GACd,kBAAkB,CAAC;AAEzB,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,wFAAwF;IACxF,QAAQ,EAAE,OAAO,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