@coreguard/sdk
v0.1.0
Published
CGEP/1 signed-intent SDK — verifyBinding* recomputation surface (WS-2) + guard.* intent lifecycle (Phase 1)
Readme
@coreguard/sdk — Signed Intent SDK (WS-2)
Consumer surface for the CoreGuard signed-intent authorization binding
(spec/signed-intent-sdk.md). It is NOT a source of truth and it NEVER
decides. The decision stays the Firewall's (decideFirewall); the SDK
re-derives and verifies the authorization binding so an integrator can consume
it without ever trusting a caller-supplied claim.
The red line (§4.0)
verifyBinding is NOT an API that takes
{ bindingRef, executionScope, authorized=true, from, relayer } and ratifies
them. It runs the full recompute pipeline every call:
intentRef (H(CGEP/1:INTENT, intent))
→ manifestId (H(CGEP/1:AGENT-PROVENANCE, declarationCore(declaration)))
→ bindingRef (H(CGEP/1:FW-BINDING, {intentRef, manifestId, signature}))
→ executionScope (ONLY from the authoritative frozen decision record, FSR-1)
→ authority probe (EOA recover / EIP-1271 magic, injected adapters only)
→ independently derived resultHard rules you cannot opt out of:
- Caller-supplied
bindingRef/executionScope/authorized/relayerare never honored and never appear in the result. A caller-suppliedbindingRef, if given viacallerBindingRef, is comparison metadata only: a mismatch ⇒ deterministicNOT_PROVEN/BINDING_REFERENCE_MISMATCH, never OK/BOUND. executionScopeis read only from the frozen DECISION record —record.binding.executionScope, whosedecisionRef = H("CGEP/1:FW-DECISION", record)is independently recomputed (content address). No record ⇒NOT_RUN/DECISION_RECORD_MISSING.- Execution evidence (
executionRef,txHash,receipt,CONTRACT_AUTHORIZATION,CONTRACT_EXECUTION_BINDING,executionBlock) into any PRE binding call is aTypeError(Q-FW10 seam). from/ relayer never authorizes. For EIP-1271,fromis the expliciteth_callcaller context — it MAY affect the probe result (probe semantics only); it never redefinessignerBinding.address.- Anything missing/absent fails closed:
NOT_RUN/NOT_PROVEN, never an implicit OK.
Usage
import { verifyBinding } from "@coreguard/sdk";
// or, in-repo: import { verifyBinding } from "../../packages/sdk/index.js";
const result = await verifyBinding({
intent, // canonical intent
declaration, // signed CGEP/1 INTENT_DECLARATION
frozenRecord, // authoritative frozen FW-DECISION record (from decideFirewall)
callerBindingRef, // OPTIONAL reference-only (FSR-2 comparison)
authorityAtState, // decimal block string at which the authority probe runs
evm, // injected EOA adapter (recoverSignerAddress, typedDataDigest)
contractAuth, // injected { ethCall, getCode } for EIP-1271
from, // OPTIONAL EIP-1271 eth_call caller context
});Result contract
{
status: "OK" | "NOT_PROVEN" | "NOT_RUN",
label: // failure label, or "BOUND" on OK
reason?, // failure detail
stage?, // "binding" | "reference" | "scope" | "authority" (null on OK)
recomputed: { intentRef, manifestId, bindingRef }, // always independently re-derived
semantics, // { intentRef, manifestId, scope, chainId, nonce, signer } (WS-1)
instance, // { bindingRef, signature } (WS-1)
executionScope, // ONLY when OK — byte-identical to the frozen record's scope
decisionRef, // content-derived decisionRef of the verified record
authority, // { status, label, path, atState, reason? } probe sub-result
}Integration: forward an OK result's { intent, declaration } to
authorizeForDecision / the Firewall — the SDK verifies the binding, it does
not decide.
