/** * Library core — thin wrapper over `@motebit/crypto`'s unified `verify()` * dispatcher with file-reading + human-rendering helpers. No state, no * side effects beyond filesystem reads you requested. * * Supported artifact kinds (auto-detected by `@motebit/crypto`): * - `identity` — `motebit.md` identity file with YAML frontmatter * - `receipt` — signed `ExecutionReceipt` JSON * - `credential` — W3C-style `VerifiableCredential` JSON * - `presentation`— `VerifiablePresentation` JSON * - `skill` — directory containing `SKILL.md` + `skill-envelope.json` * plus any auxiliary `files[]` declared in the envelope * * Error handling: file I/O errors throw (caller decides how to surface). * Parse / signature errors are returned as `valid: false` results so the * caller can render a structured reason instead of catching exceptions. */ import { type ArtifactType, type HardwareAttestationVerifiers, type SkillVerifyResult, type VerifyResult } from "@motebit/crypto"; /** * A {@link VerifyResult} augmented with the binding rung for receipts. The * `sovereign` flag is computed offline from the receipt alone — `motebit_id` * IS the commitment to `public_key` (`deriveSovereignMotebitId`), so the CLI * reports the strongest binding with no relay and no identity file, matching * receipt.computer's `sovereign` rung. Absent for non-receipt artifacts. */ export type VerifyResultWithBinding = VerifyResult & { readonly sovereign?: boolean; }; export interface VerifyFileOptions { /** * Pin the expected artifact type. When set, detection must match or * the result is `valid: false` with an explanatory error. Useful in * CI where you want to reject a credential passed into a * receipt-verification step. */ readonly expectedType?: ArtifactType; /** * Clock skew allowance (seconds) for credential / presentation * time-bounded fields (`issuanceDate`, `expirationDate`, etc.). * Forwarded to `@motebit/crypto`. Defaults to the crypto package's * default. */ readonly clockSkewSeconds?: number; /** * Optional platform-specific hardware-attestation verifiers. Forwarded * through to `@motebit/crypto::verify` so credentials carrying a * `hardware_attestation` claim for `device_check` / `tpm` / * `play_integrity` / `webauthn` can be verified end-to-end. Leaving * this unset keeps the permissive-floor path fail-closed — * hardware-attested credentials still verify their Ed25519 proof, but the * `hardware_attestation` channel reports `adapter not yet shipped` * (the expected permissive-floor-only behavior). The BSL companion CLI * `@motebit/verify` wires all four leaves automatically. */ readonly hardwareAttestation?: HardwareAttestationVerifiers; /** * When `true`, additionally verify an `ExecutionReceipt`'s `result_hash` * equals `hex(SHA-256(UTF-8(result)))` (the spec formula). A valid signature * proves the bytes are authentic but NOT that `result_hash` binds the * `result` field; strict mode rejects a self-inconsistent receipt — one whose * committed hash a third party can't reproduce from its own `result`. * Forwarded to `@motebit/crypto::verify`. Default `false`. */ readonly strictHashBinding?: boolean; } /** * Verify an artifact read from disk. Auto-detects type via content * inspection in `@motebit/crypto`. * * Path-shape dispatch: * - Directory → routed to `verifySkillDirectory` (a skill ships as * `