@coderifts/sdk 3.13.1 → 3.13.3
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/dist/cjs/authorize.d.ts +134 -0
- package/dist/cjs/authorize.d.ts.map +1 -0
- package/dist/cjs/authorize.js +118 -0
- package/dist/cjs/authorize.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +10 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/vendor/receipt-verifier/VENDOR.sha256 +24 -0
- package/dist/cjs/vendor/receipt-verifier/arity.js +53 -0
- package/dist/cjs/vendor/receipt-verifier/evidence-root.js +188 -0
- package/dist/cjs/vendor/receipt-verifier/verified-execution-binding.js +316 -0
- package/dist/cjs/vendor/receipt-verifier/verify-evidence.js +410 -0
- package/dist/cjs/vendor/receipt-verifier/verify-grant.js +564 -0
- package/dist/cjs/vendor/receipt-verifier/verify-prove-transcript.js +72 -0
- package/dist/cjs/vendor/receipt-verifier/verify.js +454 -0
- package/dist/esm/authorize.d.ts +134 -0
- package/dist/esm/authorize.d.ts.map +1 -0
- package/dist/esm/authorize.js +114 -0
- package/dist/esm/authorize.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/vendor/receipt-verifier/VENDOR.sha256 +24 -0
- package/dist/esm/vendor/receipt-verifier/arity.js +53 -0
- package/dist/esm/vendor/receipt-verifier/evidence-root.js +188 -0
- package/dist/esm/vendor/receipt-verifier/verified-execution-binding.js +316 -0
- package/dist/esm/vendor/receipt-verifier/verify-evidence.js +410 -0
- package/dist/esm/vendor/receipt-verifier/verify-grant.js +564 -0
- package/dist/esm/vendor/receipt-verifier/verify-prove-transcript.js +72 -0
- package/dist/esm/vendor/receipt-verifier/verify.js +454 -0
- package/package.json +5 -4
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* authorize() — the AUTHORIZATION question, as a first-class SDK surface (1463).
|
|
3
|
+
*
|
|
4
|
+
* ── WHY THIS IS NOT verifyExecutionGrant ────────────────────────────────────────────────────
|
|
5
|
+
*
|
|
6
|
+
* They answer different questions, and conflating them is how a caller ends up treating a verified
|
|
7
|
+
* token as permission:
|
|
8
|
+
*
|
|
9
|
+
* verifyExecutionGrant is THIS TOKEN authentic, current and bound to what I intended?
|
|
10
|
+
* One signature, one answer. Unchanged by this file.
|
|
11
|
+
* authorize() may this change be treated as authorized AND committed?
|
|
12
|
+
* Four independent authorities, and only their INTERSECTION.
|
|
13
|
+
*
|
|
14
|
+
* A grant can verify perfectly and still not authorize a commit: nothing attested that the commit
|
|
15
|
+
* happened, or the tokens are not shown to be one run, or the provider never witnessed it. Those
|
|
16
|
+
* are different facts with different remedies, and a boolean loses all of them — which is why the
|
|
17
|
+
* result carries a NAMED state.
|
|
18
|
+
*
|
|
19
|
+
* ── IT QUOTES, IT DOES NOT RECOMPUTE ────────────────────────────────────────────────────────
|
|
20
|
+
*
|
|
21
|
+
* The verdict comes from the vendored `verifiedExecutionBinding` (receipt-verifier ce5fd34), the
|
|
22
|
+
* same predicate the guard, Prove, conformance and the contract-gate quote. A TS caller therefore
|
|
23
|
+
* reads the same vocabulary those four print. This file only SHAPES inputs: PEM strings and plain
|
|
24
|
+
* objects in, the core's decision out.
|
|
25
|
+
*
|
|
26
|
+
* ── WHAT IT DOES NOT DO ─────────────────────────────────────────────────────────────────────
|
|
27
|
+
*
|
|
28
|
+
* No network, no key discovery, no clock beyond the one you pass. Every input is supplied by the
|
|
29
|
+
* caller. And a `true` here is not a claim that the provider merged anything: `provider_witness`
|
|
30
|
+
* is an unsigned readback unless you say otherwise, which is what RECORDED_UNWITNESSED names.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* The shortfall vocabulary, shared with the guard, Prove, conformance and the contract-gate.
|
|
34
|
+
* Ordered by severity: the state returned is the MOST serious thing that is wrong.
|
|
35
|
+
*/
|
|
36
|
+
export type AuthorizationState = 'AUTHORIZED_AND_COMMITTED'
|
|
37
|
+
/** The receipt or the issuer grant did not verify — nothing downstream is worth reading. */
|
|
38
|
+
| 'UNAUTHORIZED'
|
|
39
|
+
/** Authorized, but no executor attestation binds this grant to a commit. */
|
|
40
|
+
| 'COMMIT_UNPROVEN'
|
|
41
|
+
/** Authorized and committed, but the tokens are not shown to come from ONE run. */
|
|
42
|
+
| 'ONE_RUN_UNPROVEN'
|
|
43
|
+
/** Everything above holds, and no provider signed a witness of it. */
|
|
44
|
+
| 'RECORDED_UNWITNESSED'
|
|
45
|
+
/** The evidence is in order and the change was not committed. */
|
|
46
|
+
| 'NOT_COMMITTED';
|
|
47
|
+
/** The four independent authorities. Only their intersection yields success. */
|
|
48
|
+
export type AuthorityName = 'issuer_grant' | 'executor_attestation' | 'one_run_root' | 'provider_witness';
|
|
49
|
+
export interface AuthorityResult {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
/** Whether THIS call demanded it — an authority you did not require cannot fail you. */
|
|
52
|
+
required: boolean;
|
|
53
|
+
detail: string;
|
|
54
|
+
}
|
|
55
|
+
export interface AuthorizeResult {
|
|
56
|
+
/** True only when every REQUIRED authority holds and the change was committed. */
|
|
57
|
+
authorized_and_committed: boolean;
|
|
58
|
+
state: AuthorizationState;
|
|
59
|
+
authorities: Record<AuthorityName, AuthorityResult>;
|
|
60
|
+
/** One line per unmet required authority, in the core's words. */
|
|
61
|
+
shortfalls: string[];
|
|
62
|
+
/** Carried verbatim from the core, so a caller cannot read success as more than it is. */
|
|
63
|
+
does_not_prove: string[];
|
|
64
|
+
}
|
|
65
|
+
/** A pinned issuer key registry, in the shape `.well-known/coderifts-keys.json` uses. */
|
|
66
|
+
export interface PinnedKeyring {
|
|
67
|
+
keys: Array<{
|
|
68
|
+
kid: string;
|
|
69
|
+
public_key_pem: string;
|
|
70
|
+
status?: string;
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
73
|
+
export interface AuthorizeInput {
|
|
74
|
+
/**
|
|
75
|
+
* The decision receipt's verification result. `verified` is YOUR determination — this call
|
|
76
|
+
* does not re-verify it, and passing `true` for an unverified receipt is the one way to make
|
|
77
|
+
* this function lie for you.
|
|
78
|
+
*/
|
|
79
|
+
receipt: {
|
|
80
|
+
verified: boolean;
|
|
81
|
+
token?: string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* THE EXACT BYTES THE ISSUER SIGNED. Not a grant read back out of a tool result: a caller who
|
|
85
|
+
* lets the executed tool hand back its own authorization has already lost.
|
|
86
|
+
*/
|
|
87
|
+
grant: {
|
|
88
|
+
token: string;
|
|
89
|
+
keyring?: PinnedKeyring | null;
|
|
90
|
+
publicKeyPem?: string;
|
|
91
|
+
expectedKid?: string | null;
|
|
92
|
+
intended?: Record<string, unknown>;
|
|
93
|
+
now?: number;
|
|
94
|
+
};
|
|
95
|
+
/** The executor's commit attestation, and the customer-pinned executor registry. */
|
|
96
|
+
attestation?: {
|
|
97
|
+
token: string | null;
|
|
98
|
+
registry?: unknown;
|
|
99
|
+
};
|
|
100
|
+
/** A cr.prove.artifact.v1 carrying a cr.evidence.root.v1, and the executor key it is signed with. */
|
|
101
|
+
evidenceRoot?: {
|
|
102
|
+
artifact: Record<string, unknown>;
|
|
103
|
+
executorPublicKeyPem: string;
|
|
104
|
+
sidecars?: Record<string, string>;
|
|
105
|
+
} | null;
|
|
106
|
+
/** Only `signed: true` makes this authority hold; an unsigned readback never does. */
|
|
107
|
+
providerReadback?: {
|
|
108
|
+
signed: boolean;
|
|
109
|
+
} | null;
|
|
110
|
+
committed: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Which authorities this caller demands. Defaults to issuer_grant + executor_attestation —
|
|
113
|
+
* the pair a holder of a grant and an attestation can actually establish. Ask for more only
|
|
114
|
+
* when you hold the evidence for it, or the answer will name a shortfall about evidence you
|
|
115
|
+
* were never going to supply.
|
|
116
|
+
*/
|
|
117
|
+
required?: AuthorityName[];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Decide whether a change may be treated as authorized and committed.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* const r = authorize({
|
|
124
|
+
* receipt: { verified: true },
|
|
125
|
+
* grant: { token: grantToken, keyring: issuerKeys },
|
|
126
|
+
* attestation: { token: attestToken, registry: executorKeys },
|
|
127
|
+
* committed: true,
|
|
128
|
+
* });
|
|
129
|
+
* if (!r.authorized_and_committed) throw new Error(`${r.state}: ${r.shortfalls.join('; ')}`);
|
|
130
|
+
*/
|
|
131
|
+
export declare function authorize(input: AuthorizeInput): AuthorizeResult;
|
|
132
|
+
/** The states, as values, for callers that switch on them. */
|
|
133
|
+
export declare const AUTHORIZATION_STATE: Record<string, AuthorizationState>;
|
|
134
|
+
//# sourceMappingURL=authorize.d.ts.map
|
|
@@ -0,0 +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,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC5B,kFAAkF;IAClF,wBAAwB,EAAE,OAAO,CAAC;IAClC,KAAK,EA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AO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC9B;AAiBD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CA4ChE;AAED,8DAA8D;AAC9D,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAOjE,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck — this package does not ship @types/node; crypto/Buffer are Node 18+ globals.
|
|
3
|
+
/**
|
|
4
|
+
* authorize() — the AUTHORIZATION question, as a first-class SDK surface (1463).
|
|
5
|
+
*
|
|
6
|
+
* ── WHY THIS IS NOT verifyExecutionGrant ────────────────────────────────────────────────────
|
|
7
|
+
*
|
|
8
|
+
* They answer different questions, and conflating them is how a caller ends up treating a verified
|
|
9
|
+
* token as permission:
|
|
10
|
+
*
|
|
11
|
+
* verifyExecutionGrant is THIS TOKEN authentic, current and bound to what I intended?
|
|
12
|
+
* One signature, one answer. Unchanged by this file.
|
|
13
|
+
* authorize() may this change be treated as authorized AND committed?
|
|
14
|
+
* Four independent authorities, and only their INTERSECTION.
|
|
15
|
+
*
|
|
16
|
+
* A grant can verify perfectly and still not authorize a commit: nothing attested that the commit
|
|
17
|
+
* happened, or the tokens are not shown to be one run, or the provider never witnessed it. Those
|
|
18
|
+
* are different facts with different remedies, and a boolean loses all of them — which is why the
|
|
19
|
+
* result carries a NAMED state.
|
|
20
|
+
*
|
|
21
|
+
* ── IT QUOTES, IT DOES NOT RECOMPUTE ────────────────────────────────────────────────────────
|
|
22
|
+
*
|
|
23
|
+
* The verdict comes from the vendored `verifiedExecutionBinding` (receipt-verifier ce5fd34), the
|
|
24
|
+
* same predicate the guard, Prove, conformance and the contract-gate quote. A TS caller therefore
|
|
25
|
+
* reads the same vocabulary those four print. This file only SHAPES inputs: PEM strings and plain
|
|
26
|
+
* objects in, the core's decision out.
|
|
27
|
+
*
|
|
28
|
+
* ── WHAT IT DOES NOT DO ─────────────────────────────────────────────────────────────────────
|
|
29
|
+
*
|
|
30
|
+
* No network, no key discovery, no clock beyond the one you pass. Every input is supplied by the
|
|
31
|
+
* caller. And a `true` here is not a claim that the provider merged anything: `provider_witness`
|
|
32
|
+
* is an unsigned readback unless you say otherwise, which is what RECORDED_UNWITNESSED names.
|
|
33
|
+
*/
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.AUTHORIZATION_STATE = void 0;
|
|
36
|
+
exports.authorize = authorize;
|
|
37
|
+
const crypto_1 = require("crypto");
|
|
38
|
+
function toKeyringMap(keyring) {
|
|
39
|
+
if (!keyring || !Array.isArray(keyring.keys) || keyring.keys.length === 0)
|
|
40
|
+
return null;
|
|
41
|
+
const m = new Map();
|
|
42
|
+
for (const k of keyring.keys) {
|
|
43
|
+
if (!k || typeof k.kid !== 'string' || typeof k.public_key_pem !== 'string')
|
|
44
|
+
continue;
|
|
45
|
+
m.set(k.kid, {
|
|
46
|
+
publicKey: (0, crypto_1.createPublicKey)(k.public_key_pem),
|
|
47
|
+
status: k.status || 'active',
|
|
48
|
+
retired_at: null,
|
|
49
|
+
compromised_at: null,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return m.size > 0 ? m : null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Decide whether a change may be treated as authorized and committed.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* const r = authorize({
|
|
59
|
+
* receipt: { verified: true },
|
|
60
|
+
* grant: { token: grantToken, keyring: issuerKeys },
|
|
61
|
+
* attestation: { token: attestToken, registry: executorKeys },
|
|
62
|
+
* committed: true,
|
|
63
|
+
* });
|
|
64
|
+
* if (!r.authorized_and_committed) throw new Error(`${r.state}: ${r.shortfalls.join('; ')}`);
|
|
65
|
+
*/
|
|
66
|
+
function authorize(input) {
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
68
|
+
const { verifiedExecutionBinding } = require('./vendor/receipt-verifier/verified-execution-binding.js');
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
70
|
+
const { verifyExecutionAttestation } = require('./execution-attestation.js');
|
|
71
|
+
const g = input.grant || {};
|
|
72
|
+
const att = input.attestation;
|
|
73
|
+
const root = input.evidenceRoot;
|
|
74
|
+
return verifiedExecutionBinding({
|
|
75
|
+
receipt: { verified: input.receipt && input.receipt.verified === true },
|
|
76
|
+
grant: {
|
|
77
|
+
token: g.token || '',
|
|
78
|
+
keyring: toKeyringMap(g.keyring),
|
|
79
|
+
...(g.publicKeyPem ? { publicKey: (0, crypto_1.createPublicKey)(g.publicKeyPem) } : {}),
|
|
80
|
+
expectedKid: g.expectedKid ?? null,
|
|
81
|
+
...(g.intended ? { intended: g.intended } : {}),
|
|
82
|
+
...(Number.isFinite(g.now) ? { now: g.now } : {}),
|
|
83
|
+
},
|
|
84
|
+
...(att
|
|
85
|
+
? {
|
|
86
|
+
attestation: {
|
|
87
|
+
token: att.token,
|
|
88
|
+
registry: att.registry,
|
|
89
|
+
// Handed in rather than reimplemented: the core holds no attestation format
|
|
90
|
+
// knowledge of its own, and this SDK already owns that verifier.
|
|
91
|
+
verify: verifyExecutionAttestation,
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
: {}),
|
|
95
|
+
...(root
|
|
96
|
+
? {
|
|
97
|
+
evidenceRoot: {
|
|
98
|
+
artifact: root.artifact,
|
|
99
|
+
executorKey: (0, crypto_1.createPublicKey)(root.executorPublicKeyPem),
|
|
100
|
+
sidecars: root.sidecars,
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
: {}),
|
|
104
|
+
...(input.providerReadback ? { providerReadback: input.providerReadback } : {}),
|
|
105
|
+
committed: input.committed === true,
|
|
106
|
+
...(input.required ? { required: input.required } : {}),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/** The states, as values, for callers that switch on them. */
|
|
110
|
+
exports.AUTHORIZATION_STATE = Object.freeze({
|
|
111
|
+
AUTHORIZED_AND_COMMITTED: 'AUTHORIZED_AND_COMMITTED',
|
|
112
|
+
UNAUTHORIZED: 'UNAUTHORIZED',
|
|
113
|
+
COMMIT_UNPROVEN: 'COMMIT_UNPROVEN',
|
|
114
|
+
ONE_RUN_UNPROVEN: 'ONE_RUN_UNPROVEN',
|
|
115
|
+
RECORDED_UNWITNESSED: 'RECORDED_UNWITNESSED',
|
|
116
|
+
NOT_COMMITTED: 'NOT_COMMITTED',
|
|
117
|
+
});
|
|
118
|
+
//# sourceMappingURL=authorize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../src/authorize.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;AA4HH,8BA4CC;AAtKD,mCAAyC;AA+FzC,SAAS,YAAY,CAAC,OAAyC;IAC3D,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACvF,MAAM,CAAC,GAAG,IAAI,GAAG,EAAmB,CAAC;IACrC,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,cAAc,KAAK,QAAQ;YAAE,SAAS;QACtF,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE;YACT,SAAS,EAAE,IAAA,wBAAe,EAAC,CAAC,CAAC,cAAc,CAAC;YAC5C,MAAM,EAAE,CAAC,CAAC,MAAM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@@ export { readDecision } from './decision.js';
|
|
|
20
20
|
export type { ReadDecisionResult } from './decision.js';
|
|
21
21
|
export { CLOCK_SKEW_LEEWAY_MS, expiryLeewayMs, declaresDestructiveProduction, isReceiptExpired, isIssuedInFuture, } from './leeway.js';
|
|
22
22
|
export type { ExpiryLeewayContext } from './leeway.js';
|
|
23
|
+
export { authorize, AUTHORIZATION_STATE } from './authorize.js';
|
|
24
|
+
export type { AuthorizeInput, AuthorizeResult, AuthorizationState, AuthorityName, AuthorityResult, PinnedKeyring, } from './authorize.js';
|
|
23
25
|
export { verifyExecutionGrant, computeScopeHash, afterPayloadCanonical, receiptDigest, GRANT_VERSION, GRANT_VERSION_V2, GRANT_SIGNING_PREFIX, } from './execution-grant.js';
|
|
24
26
|
export type { ExecutionGrantIntended, VerifyExecutionGrantResult, GrantStatus, ExecutionGrantV2, } from './execution-grant.js';
|
|
25
27
|
export { verifyExecutionAttestation, attestSigningInput, ATTEST_VERSION, ATTEST_SIGNING_PREFIX, ATTEST_ENVELOPE_TAG, } from './execution-attestation.js';
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACH,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,GAC1B,MAAM,aAAa,CAAC;AACrB,YAAY,EACR,cAAc,EACd,aAAa,EACb,iBAAiB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7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AA4B,EAC5B,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,GACzB,MAAM,YAAY,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.MONITOR_ATTEST_ENVELOPE_TAG = exports.MONITOR_ATTEST_SIGNING_PREFIX = exports.MONITOR_ATTEST_VERSION = exports.monitorAttestSigningInput = exports.verifyMonitoringAttestation = exports.ATTEST_ENVELOPE_TAG = exports.ATTEST_SIGNING_PREFIX = exports.ATTEST_VERSION = exports.attestSigningInput = exports.verifyExecutionAttestation = exports.GRANT_SIGNING_PREFIX = exports.GRANT_VERSION_V2 = exports.GRANT_VERSION = exports.receiptDigest = exports.afterPayloadCanonical = exports.computeScopeHash = exports.verifyExecutionGrant = exports.isIssuedInFuture = exports.isReceiptExpired = exports.declaresDestructiveProduction = exports.expiryLeewayMs = exports.CLOCK_SKEW_LEEWAY_MS = exports.readDecision = exports.AuthError = exports.RateLimitError = exports.TimeoutError = exports.ApiError = exports.CodeRiftsError = exports.resetPolicyWarnForTests = exports.warnPolicyAbsentOnce = exports.observePolicyPresence = exports.detectPolicyPresence = exports.policyPresenceOf = exports.withPolicy = exports.POLICY_ABSENT_WARN = exports.POLICY_MARKER = exports.CODERIFTS_POLICY = exports.CodeRifts = void 0;
|
|
17
|
+
exports.MONITOR_ATTEST_ENVELOPE_TAG = exports.MONITOR_ATTEST_SIGNING_PREFIX = exports.MONITOR_ATTEST_VERSION = exports.monitorAttestSigningInput = exports.verifyMonitoringAttestation = exports.ATTEST_ENVELOPE_TAG = exports.ATTEST_SIGNING_PREFIX = exports.ATTEST_VERSION = exports.attestSigningInput = exports.verifyExecutionAttestation = exports.GRANT_SIGNING_PREFIX = exports.GRANT_VERSION_V2 = exports.GRANT_VERSION = exports.receiptDigest = exports.afterPayloadCanonical = exports.computeScopeHash = exports.verifyExecutionGrant = exports.AUTHORIZATION_STATE = exports.authorize = exports.isIssuedInFuture = exports.isReceiptExpired = exports.declaresDestructiveProduction = exports.expiryLeewayMs = exports.CLOCK_SKEW_LEEWAY_MS = exports.readDecision = exports.AuthError = exports.RateLimitError = exports.TimeoutError = exports.ApiError = exports.CodeRiftsError = exports.resetPolicyWarnForTests = exports.warnPolicyAbsentOnce = exports.observePolicyPresence = exports.detectPolicyPresence = exports.policyPresenceOf = exports.withPolicy = exports.POLICY_ABSENT_WARN = exports.POLICY_MARKER = exports.CODERIFTS_POLICY = exports.CodeRifts = void 0;
|
|
18
18
|
var client_js_1 = require("./client.js");
|
|
19
19
|
Object.defineProperty(exports, "CodeRifts", { enumerable: true, get: function () { return client_js_1.CodeRifts; } });
|
|
20
20
|
var policy_js_1 = require("./policy.js");
|
|
@@ -41,6 +41,15 @@ Object.defineProperty(exports, "expiryLeewayMs", { enumerable: true, get: functi
|
|
|
41
41
|
Object.defineProperty(exports, "declaresDestructiveProduction", { enumerable: true, get: function () { return leeway_js_1.declaresDestructiveProduction; } });
|
|
42
42
|
Object.defineProperty(exports, "isReceiptExpired", { enumerable: true, get: function () { return leeway_js_1.isReceiptExpired; } });
|
|
43
43
|
Object.defineProperty(exports, "isIssuedInFuture", { enumerable: true, get: function () { return leeway_js_1.isIssuedInFuture; } });
|
|
44
|
+
// ── THE AUTHORIZATION QUESTION (1463) ────────────────────────────────────────────────────────
|
|
45
|
+
//
|
|
46
|
+
// ADDITIVE. `verifyExecutionGrant` below is unchanged and still answers "is this token authentic,
|
|
47
|
+
// current and bound to what I intended". `authorize` answers a different question — "may this be
|
|
48
|
+
// treated as authorized AND committed" — by quoting the shared core predicate, so a TS caller
|
|
49
|
+
// reads the same named states the guard, Prove, conformance and the contract-gate print.
|
|
50
|
+
var authorize_js_1 = require("./authorize.js");
|
|
51
|
+
Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorize_js_1.authorize; } });
|
|
52
|
+
Object.defineProperty(exports, "AUTHORIZATION_STATE", { enumerable: true, get: function () { return authorize_js_1.AUTHORIZATION_STATE; } });
|
|
44
53
|
var execution_grant_js_1 = require("./execution-grant.js");
|
|
45
54
|
Object.defineProperty(exports, "verifyExecutionGrant", { enumerable: true, get: function () { return execution_grant_js_1.verifyExecutionGrant; } });
|
|
46
55
|
Object.defineProperty(exports, "computeScopeHash", { enumerable: true, get: function () { return execution_grant_js_1.computeScopeHash; } });
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,yCAUqB;AATjB,6GAAA,gBAAgB,OAAA;AAChB,0GAAA,aAAa,OAAA;AACb,+GAAA,kBAAkB,OAAA;AAClB,uGAAA,UAAU,OAAA;AACV,6GAAA,gBAAgB,OAAA;AAChB,iHAAA,oBAAoB,OAAA;AACpB,kHAAA,qBAAqB,OAAA;AACrB,iHAAA,oBAAoB,OAAA;AACpB,oHAAA,uBAAuB,OAAA;AAO3B,yCAAgG;AAAvF,2GAAA,cAAc,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAAE,yGAAA,YAAY,OAAA;AAAE,2GAAA,cAAc,OAAA;AAAE,sGAAA,SAAS,OAAA;AAC1E,6CAA6C;AAApC,2GAAA,YAAY,OAAA;AAErB,yCAMqB;AALjB,iHAAA,oBAAoB,OAAA;AACpB,2GAAA,cAAc,OAAA;AACd,0HAAA,6BAA6B,OAAA;AAC7B,6GAAA,gBAAgB,OAAA;AAChB,6GAAA,gBAAgB,OAAA;AAGpB,2DAQ8B;AAP1B,0HAAA,oBAAoB,OAAA;AACpB,sHAAA,gBAAgB,OAAA;AAChB,2HAAA,qBAAqB,OAAA;AACrB,mHAAA,aAAa,OAAA;AACb,mHAAA,aAAa,OAAA;AACb,sHAAA,gBAAgB,OAAA;AAChB,0HA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P1B,0HAAA,oBAAoB,OAAA;AACpB,sHAAA,gBAAgB,OAAA;AAChB,2HAAA,qBAAqB,OAAA;AACrB,mHAAA,aAAa,OAAA;AACb,mHAAA,aAAa,OAAA;AACb,sHAAA,gBAAgB,OAAA;AAChB,0HAAA,oBAAoB,OAAA;AAQxB,uEAMoC;AALhC,sIAAA,0BAA0B,OAAA;AAC1B,8HAAA,kBAAkB,OAAA;AAClB,0HAAA,cAAc,OAAA;AACd,iIAAA,qBAAqB,OAAA;AACrB,+HAAA,mBAAmB,OAAA;AASvB,yEAMqC;AALjC,wIAAA,2BAA2B,OAAA;AAC3B,sIAAA,yBAAyB,OAAA;AACzB,mIAAA,sBAAsB,OAAA;AACtB,0IAAA,6BAA6B,OAAA;AAC7B,wIAAA,2BAA2B,OAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# VENDORED FROM receipt-verifier — DO NOT EDIT IN PLACE.
|
|
2
|
+
#
|
|
3
|
+
# The SDK's authorize() QUOTES the shared predicate rather than reimplementing it. A local edit
|
|
4
|
+
# here would be a second implementation wearing the first one's name, which is the failure the
|
|
5
|
+
# whole 1459 consolidation removed: one question, several formulas, disagreeing answers.
|
|
6
|
+
#
|
|
7
|
+
# PER-FILE PROVENANCE. The closure is vendored at each file's own revision — a single
|
|
8
|
+
# source-commit line would be tidier and untrue.
|
|
9
|
+
#
|
|
10
|
+
# arity.js 5ef4dfb19d0ef60d93fe4282f28e38182fc237f5
|
|
11
|
+
# verify.js e0806f31a9db11ba5ad7a6075ff2b5d0e517eb83
|
|
12
|
+
# verify-grant.js a472bf9073781cba25d83c7d1406b1a7c4af0b94
|
|
13
|
+
# verify-prove-transcript.js 724aa9ae8171f1acf629c3c6b4879dc056575f20
|
|
14
|
+
# verify-evidence.js 16cf6654ff3fa6d6293eb4a425bbe7fb6999ee26
|
|
15
|
+
# evidence-root.js 16cf6654ff3fa6d6293eb4a425bbe7fb6999ee26
|
|
16
|
+
# verified-execution-binding.js 1e41542296551139c41e2d4b4cff2e67bc42aa06
|
|
17
|
+
|
|
18
|
+
721fcac58b960b5e2aa1af91edb6cfc87ebe828a6da73879967ef79a1ca474e8 arity.js
|
|
19
|
+
348d3f851cd79bf63298b51da422d11be980820576ab0bf0a2990b9f007d6249 verify.js
|
|
20
|
+
127b53de3be77196862c10a8812221de0a5112cf1d3feae12d347a6021852df7 verify-grant.js
|
|
21
|
+
3bb17bd4f16d5ee3cf3fbb754b4df9aa570a615ca94ff2a97b751c4fabd3bd0d verify-prove-transcript.js
|
|
22
|
+
98cd9b989a25095e0442f91f68a1adecd6e6a2a5b05902bf2580b8cba973c5e2 verify-evidence.js
|
|
23
|
+
4d5476fc44bbfc2a847feeb313a1c6c08ef7fd832a2348ef3c244bd8d3f03fcd evidence-root.js
|
|
24
|
+
e48ea29b9f8b0c5b1754187788cbaf78cdaf0b505848c05d1ae3ffebb30218f2 verified-execution-binding.js
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 1129 — unified (token, opts) with opts.ctx / opts.intended.
|
|
5
|
+
* 3-ary (token, ctx, opts) wrappers warn once and forward.
|
|
6
|
+
* 2-ary verifiers keep the 1128 throw on a third argument.
|
|
7
|
+
*/
|
|
8
|
+
const warned = new Set();
|
|
9
|
+
|
|
10
|
+
function warnOnce(name) {
|
|
11
|
+
if (warned.has(name)) return;
|
|
12
|
+
warned.add(name);
|
|
13
|
+
const msg = `DEPRECATION: ${name}(token, ctx, opts) is deprecated; use ${name}(token, { ctx, intended }). This warning is emitted once.`;
|
|
14
|
+
if (typeof process !== 'undefined' && typeof process.emitWarning === 'function') {
|
|
15
|
+
process.emitWarning(msg, 'DeprecationWarning');
|
|
16
|
+
} else {
|
|
17
|
+
console.warn(msg);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function throw1128(name, n, consequence) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`${name}(token, opts) — pass intended via opts.intended. `
|
|
24
|
+
+ `Received ${n} arguments; the third would be ignored and the cross-check `
|
|
25
|
+
+ `would silently not run, grading a mismatched artifact ${consequence}.`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function looksUnified(obj) {
|
|
30
|
+
if (!obj || typeof obj !== 'object' || Array.isArray(obj)) return false;
|
|
31
|
+
// perSlot is the bundle-dispatch unified shape: verifyBundle(bundle, { ctx, perSlot }).
|
|
32
|
+
// Without it, `{ perSlot }` was treated as a bare ctx and opts.perSlot vanished.
|
|
33
|
+
return obj.ctx != null || obj.intended != null || obj.envelope != null || obj.perSlot != null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function split3ary(name, nArgs, second, third) {
|
|
37
|
+
if (nArgs > 3) throw1128(name, nArgs, 'VALID');
|
|
38
|
+
if (nArgs === 3) {
|
|
39
|
+
warnOnce(name);
|
|
40
|
+
return { ctx: second || {}, opts: third && typeof third === 'object' ? third : {} };
|
|
41
|
+
}
|
|
42
|
+
const o = second && typeof second === 'object' ? second : {};
|
|
43
|
+
if (looksUnified(o)) {
|
|
44
|
+
return { ctx: o.ctx || {}, opts: o };
|
|
45
|
+
}
|
|
46
|
+
return { ctx: o, opts: {} };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function _resetWarnedForTest() {
|
|
50
|
+
warned.clear();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = { warnOnce, throw1128, split3ary, looksUnified, _resetWarnedForTest };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* cr.evidence.root.v1 — ONE signed manifest that binds a set of tokens to ONE run.
|
|
5
|
+
*
|
|
6
|
+
* ── THE ATTACK THIS EXISTS FOR (1432) ───────────────────────────────────────────────────────
|
|
7
|
+
*
|
|
8
|
+
* 1423 made every token in a prove artifact authenticate against its issuer's key. That closed
|
|
9
|
+
* forgery and left something open, which the second auditor found and which was reproduced three
|
|
10
|
+
* ways before this file existed: take a REAL second run of the same producer, at the same commit,
|
|
11
|
+
* and move one of ITS tokens into the first run's artifact. Recompute the pin. Everything still
|
|
12
|
+
* verifies — because nothing was forged. Each token really was issued, really is signed, and
|
|
13
|
+
* really says what it says.
|
|
14
|
+
*
|
|
15
|
+
* transcript_token from run B → graded COVERED
|
|
16
|
+
* execution_grant from run B → graded COVERED
|
|
17
|
+
* chain_receipt from run B → graded COVERED
|
|
18
|
+
*
|
|
19
|
+
* Authenticity is a property of a TOKEN. "These tokens are one run" is a property of a SET, and no
|
|
20
|
+
* per-token signature can carry it. So a set needs its own signature.
|
|
21
|
+
*
|
|
22
|
+
* ── WHAT THE ROOT IS, AND WHAT IT IS NOT ────────────────────────────────────────────────────
|
|
23
|
+
*
|
|
24
|
+
* It is the producer saying, under its own key: "this run emitted exactly these bytes". The
|
|
25
|
+
* binding is the sha256 of each token's EXACT bytes, not a claim copied out of it — a substituted
|
|
26
|
+
* token has different bytes, so its digest cannot match, whatever it says inside.
|
|
27
|
+
*
|
|
28
|
+
* It is NOT a second opinion on any token's validity. A root cannot make an expired grant current
|
|
29
|
+
* or a bad signature good; every per-token check still runs and still decides. The root adds one
|
|
30
|
+
* sentence the others could not say.
|
|
31
|
+
*
|
|
32
|
+
* ── WHY IT IS SIGNED BY THE EXECUTOR ────────────────────────────────────────────────────────
|
|
33
|
+
*
|
|
34
|
+
* The executor is the only party present for the whole run: it mints the challenge, consumes the
|
|
35
|
+
* grant, seals the attestation and signs the transcript. The issuer sees one authorize; the
|
|
36
|
+
* provider sees one merge. A manifest of the run has to be signed by whoever witnessed the run,
|
|
37
|
+
* and that is the executor — the same key the correlation already uses, deliberately, so a reader
|
|
38
|
+
* verifying one is verifying the other's signer too.
|
|
39
|
+
*
|
|
40
|
+
* The residual is stated rather than hidden: this is the EXECUTOR's account of its own run. It
|
|
41
|
+
* makes splicing detectable, not impossible for the executor itself. An executor that lies about
|
|
42
|
+
* its own run was never constrained by its own signature — what the root removes is the ability of
|
|
43
|
+
* a THIRD party (anyone who can edit a vendored artifact) to assemble two honest runs into one.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
const crypto = require('node:crypto');
|
|
47
|
+
|
|
48
|
+
const ROOT_V = 'cr.evidence.root.v1';
|
|
49
|
+
const ROOT_SIGNING_PREFIX = 'crevidenceroot.v1';
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The slots a root accounts for. MANDATORY ones must be present and non-null: a root that simply
|
|
53
|
+
* omits a token would let deletion — the strongest tamper there is — read as "not applicable".
|
|
54
|
+
*/
|
|
55
|
+
const SLOTS = Object.freeze({
|
|
56
|
+
chain_receipt: { mandatory: true },
|
|
57
|
+
execution_grant: { mandatory: true },
|
|
58
|
+
transcript_token: { mandatory: true },
|
|
59
|
+
correlation: { mandatory: true },
|
|
60
|
+
atomic_attestation: { mandatory: false },
|
|
61
|
+
provider_readback: { mandatory: false },
|
|
62
|
+
});
|
|
63
|
+
const SLOT_NAMES = Object.freeze(Object.keys(SLOTS));
|
|
64
|
+
|
|
65
|
+
const sha256pref = (bytes) =>
|
|
66
|
+
`sha256:${crypto.createHash('sha256').update(bytes).digest('hex')}`;
|
|
67
|
+
|
|
68
|
+
/** RFC 8785-shaped canonical JSON: sorted keys, no whitespace, no invented values. */
|
|
69
|
+
function canonicalJson(value) {
|
|
70
|
+
if (value === null) return 'null';
|
|
71
|
+
const t = typeof value;
|
|
72
|
+
if (t === 'boolean' || t === 'string') return JSON.stringify(value);
|
|
73
|
+
if (t === 'number') {
|
|
74
|
+
if (!Number.isFinite(value)) throw new TypeError('canonicalJson: non-finite number');
|
|
75
|
+
return JSON.stringify(value);
|
|
76
|
+
}
|
|
77
|
+
if (t === 'undefined') throw new TypeError('canonicalJson: undefined');
|
|
78
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(',')}]`;
|
|
79
|
+
const keys = Object.keys(value).sort();
|
|
80
|
+
return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalJson(value[k])}`).join(',')}}`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The exact bytes signed. The WHOLE body under canonical JSON, so every field is covered and a
|
|
85
|
+
* future field cannot be added without breaking the signature.
|
|
86
|
+
*/
|
|
87
|
+
function rootSigningInput(body) {
|
|
88
|
+
return `${ROOT_SIGNING_PREFIX}|${canonicalJson(body)}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Digest a token exactly as it travels.
|
|
93
|
+
*
|
|
94
|
+
* A STRING is hashed as utf8 bytes. An OBJECT — the correlation is one — is hashed as canonical
|
|
95
|
+
* JSON, so key order in a re-serialised artifact cannot change the digest of a value nobody
|
|
96
|
+
* edited. Absent is null, never the empty-string hash: `sha256('')` is a real value and would
|
|
97
|
+
* make "no token" indistinguishable from "a token that happens to be empty".
|
|
98
|
+
*/
|
|
99
|
+
function digestToken(token) {
|
|
100
|
+
if (token == null) return null;
|
|
101
|
+
if (typeof token === 'string') return token.length === 0 ? null : sha256pref(Buffer.from(token, 'utf8'));
|
|
102
|
+
return sha256pref(Buffer.from(canonicalJson(token), 'utf8'));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Build and sign a root.
|
|
107
|
+
*
|
|
108
|
+
* @param {object} o
|
|
109
|
+
* @param {string} o.run_id
|
|
110
|
+
* @param {{name: string, version: string, commit: string|null}} o.producer
|
|
111
|
+
* @param {string} o.operation
|
|
112
|
+
* @param {string} o.target_uri
|
|
113
|
+
* @param {string|null} o.contract_commit
|
|
114
|
+
* @param {object} o.tokens slot name → the token as it travels (string or object)
|
|
115
|
+
* @param {object} o.claims { grant_id, receipt_hash, scope_hash, policy_hash, state_token_hash }
|
|
116
|
+
* @param {import('crypto').KeyObject} o.privateKey
|
|
117
|
+
* @param {string} o.executor_kid
|
|
118
|
+
*/
|
|
119
|
+
function buildEvidenceRoot(o) {
|
|
120
|
+
const artifact_digests = {};
|
|
121
|
+
for (const name of SLOT_NAMES) {
|
|
122
|
+
artifact_digests[name] = digestToken(o.tokens ? o.tokens[name] : null);
|
|
123
|
+
}
|
|
124
|
+
const c = o.claims || {};
|
|
125
|
+
const body = {
|
|
126
|
+
v: ROOT_V,
|
|
127
|
+
run_id: String(o.run_id),
|
|
128
|
+
executor_kid: String(o.executor_kid),
|
|
129
|
+
producer: {
|
|
130
|
+
name: String(o.producer.name),
|
|
131
|
+
version: String(o.producer.version),
|
|
132
|
+
commit: o.producer.commit == null ? null : String(o.producer.commit),
|
|
133
|
+
},
|
|
134
|
+
operation: o.operation == null ? null : String(o.operation),
|
|
135
|
+
target_uri: o.target_uri == null ? null : String(o.target_uri),
|
|
136
|
+
contract_commit: o.contract_commit == null ? null : String(o.contract_commit),
|
|
137
|
+
artifact_digests,
|
|
138
|
+
// The CLAIMS the run asserts. They are ALSO inside the tokens; carrying them here is what
|
|
139
|
+
// lets a verifier compare the two and refuse a manifest that agrees with itself but not with
|
|
140
|
+
// its own evidence.
|
|
141
|
+
grant_id: c.grant_id == null ? null : String(c.grant_id),
|
|
142
|
+
receipt_hash: c.receipt_hash == null ? null : String(c.receipt_hash),
|
|
143
|
+
scope_hash: c.scope_hash == null ? null : String(c.scope_hash),
|
|
144
|
+
policy_hash: c.policy_hash == null ? null : String(c.policy_hash),
|
|
145
|
+
state_token_hash: c.state_token_hash == null ? null : String(c.state_token_hash),
|
|
146
|
+
};
|
|
147
|
+
const signature = crypto.sign(null, Buffer.from(rootSigningInput(body), 'utf8'), o.privateKey);
|
|
148
|
+
return { ...body, signature: signature.toString('base64url') };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Verify a root's own signature. Says nothing about the tokens — that is verifyEvidenceEnvelope. */
|
|
152
|
+
function verifyEvidenceRoot(root, publicKey) {
|
|
153
|
+
if (!root || root.v !== ROOT_V) {
|
|
154
|
+
return { valid: false, status: 'ROOT_MALFORMED', reason: 'not_an_evidence_root' };
|
|
155
|
+
}
|
|
156
|
+
if (typeof root.signature !== 'string' || root.signature.length === 0) {
|
|
157
|
+
return { valid: false, status: 'ROOT_MALFORMED', reason: 'no_signature' };
|
|
158
|
+
}
|
|
159
|
+
if (!publicKey) {
|
|
160
|
+
return { valid: false, status: 'ROOT_UNKNOWN_KEY', reason: 'unknown_kid' };
|
|
161
|
+
}
|
|
162
|
+
const { signature, ...body } = root;
|
|
163
|
+
let ok = false;
|
|
164
|
+
try {
|
|
165
|
+
ok = crypto.verify(
|
|
166
|
+
null, Buffer.from(rootSigningInput(body), 'utf8'), publicKey,
|
|
167
|
+
Buffer.from(signature, 'base64url'),
|
|
168
|
+
);
|
|
169
|
+
} catch (_) {
|
|
170
|
+
return { valid: false, status: 'ROOT_INVALID_SIGNATURE', reason: 'signature_error' };
|
|
171
|
+
}
|
|
172
|
+
return ok
|
|
173
|
+
? { valid: true, status: 'ROOT_VALID' }
|
|
174
|
+
: { valid: false, status: 'ROOT_INVALID_SIGNATURE', reason: 'signature_mismatch' };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
module.exports = {
|
|
178
|
+
ROOT_V,
|
|
179
|
+
ROOT_SIGNING_PREFIX,
|
|
180
|
+
SLOTS,
|
|
181
|
+
SLOT_NAMES,
|
|
182
|
+
canonicalJson,
|
|
183
|
+
rootSigningInput,
|
|
184
|
+
digestToken,
|
|
185
|
+
buildEvidenceRoot,
|
|
186
|
+
verifyEvidenceRoot,
|
|
187
|
+
sha256pref,
|
|
188
|
+
};
|