protect-mcp 0.5.5 → 0.6.2
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 +111 -3
- package/dist/{chunk-SPHLVRJ2.mjs → chunk-3YCKR72H.mjs} +223 -4
- package/dist/{ed25519-V7HDL2WC.mjs → chunk-LYKNULYU.mjs} +166 -10
- package/dist/{chunk-BYYWYSHM.mjs → chunk-PLKRTBDR.mjs} +15 -3
- package/dist/{chunk-GQWJCHQV.mjs → chunk-S4ICHNSP.mjs} +2 -2
- package/dist/{chunk-YTBC72JJ.mjs → chunk-UV53U6D4.mjs} +69 -25
- package/dist/cli.js +305 -31
- package/dist/cli.mjs +7 -7
- package/dist/ed25519-DZMMNNVE.mjs +38 -0
- package/dist/hook-server.js +283 -28
- package/dist/hook-server.mjs +2 -2
- package/dist/{http-transport-LNBENGXD.mjs → http-transport-MO32ESHZ.mjs} +2 -2
- package/dist/index.d.mts +223 -4
- package/dist/index.d.ts +223 -4
- package/dist/index.js +3057 -420
- package/dist/index.mjs +250 -11
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -95,6 +95,29 @@ interface SigningConfig {
|
|
|
95
95
|
issuer?: string;
|
|
96
96
|
/** Whether signing is enabled (default: true when key_path is set) */
|
|
97
97
|
enabled?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Commitment-mode signing.
|
|
100
|
+
*
|
|
101
|
+
* When enabled, listed fields are committed via SHA-256(salt || JCS({name, salt, value}))
|
|
102
|
+
* and the receipt payload carries a single committed_fields_root (Merkle root) instead
|
|
103
|
+
* of the cleartext field values. Per draft-farley-acta-signed-receipts-01 §commitment-mode.
|
|
104
|
+
*
|
|
105
|
+
* The receipt issuer keeps the openings (value + salt per field) for later selective
|
|
106
|
+
* disclosure. A receipt holder can prove a field's value to an auditor without
|
|
107
|
+
* revealing other committed fields.
|
|
108
|
+
*
|
|
109
|
+
* @since 0.6.0
|
|
110
|
+
*/
|
|
111
|
+
commitment_mode?: {
|
|
112
|
+
/** Whether commitment-mode signing is active. Default: false. */
|
|
113
|
+
enabled?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Names of payload fields to commit.
|
|
116
|
+
* Recommended defaults: tool, scope, payload_digest, swarm.
|
|
117
|
+
* Other fields remain cleartext.
|
|
118
|
+
*/
|
|
119
|
+
committed_field_names?: string[];
|
|
120
|
+
};
|
|
98
121
|
}
|
|
99
122
|
interface RateLimit {
|
|
100
123
|
count: number;
|
|
@@ -780,9 +803,9 @@ declare function validateCredentials(credentials: Record<string, CredentialConfi
|
|
|
780
803
|
* Produces signed v2 artifact receipts for tool call decisions.
|
|
781
804
|
* Uses @veritasacta/artifacts as a required dependency (Sprint 2+).
|
|
782
805
|
*
|
|
783
|
-
* If signing is configured, every decision
|
|
784
|
-
*
|
|
785
|
-
*
|
|
806
|
+
* If signing is configured, every decision must produce a signed artifact.
|
|
807
|
+
* Initialization and signing failures are returned as explicit errors so the
|
|
808
|
+
* enforce path can deny rather than silently proceeding without evidence.
|
|
786
809
|
*/
|
|
787
810
|
|
|
788
811
|
/**
|
|
@@ -804,9 +827,11 @@ declare function initSigning(config: SigningConfig | undefined): Promise<string[
|
|
|
804
827
|
* @standard RFC 8032 (Ed25519), RFC 8785 (JCS)
|
|
805
828
|
*/
|
|
806
829
|
declare function signDecision(entry: DecisionLog): {
|
|
830
|
+
ok: boolean;
|
|
807
831
|
signed: string | null;
|
|
808
832
|
artifact_type: string;
|
|
809
833
|
warning?: string;
|
|
834
|
+
error?: string;
|
|
810
835
|
};
|
|
811
836
|
/**
|
|
812
837
|
* Get the signer's public key info for discovery/verification.
|
|
@@ -825,6 +850,131 @@ declare function getSignerInfo(): {
|
|
|
825
850
|
*/
|
|
826
851
|
declare function isSigningEnabled(): boolean;
|
|
827
852
|
|
|
853
|
+
/**
|
|
854
|
+
* A Merkle inclusion proof for a single leaf.
|
|
855
|
+
*
|
|
856
|
+
* The siblings array lists the sibling hashes encountered while walking
|
|
857
|
+
* from the leaf up to the root. Each sibling is hex-encoded SHA-256.
|
|
858
|
+
* The (index, treeSize) pair determines whether the current node is
|
|
859
|
+
* left or right at each level during verification.
|
|
860
|
+
*/
|
|
861
|
+
interface MerkleProof {
|
|
862
|
+
/** Zero-based index of the leaf in the canonically-sorted leaf list. */
|
|
863
|
+
index: number;
|
|
864
|
+
/** Total number of leaves in the tree. */
|
|
865
|
+
treeSize: number;
|
|
866
|
+
/** Sibling hashes from leaf upward, hex-encoded SHA-256 (lowercase). */
|
|
867
|
+
siblings: string[];
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* @scopeblind/protect-mcp: Commitment-Mode Signing
|
|
872
|
+
*
|
|
873
|
+
* Produces commitment-mode signed receipts per draft-farley-acta-signed-receipts-01
|
|
874
|
+
* §commitment-mode. Each listed field is independently committed via
|
|
875
|
+
* SHA-256(0x00 || JCS({name, salt, value})), arranged into an RFC 6962-style
|
|
876
|
+
* Merkle tree with explicit one-byte domain separation, and the receipt payload
|
|
877
|
+
* carries a single committed_fields_root field instead of the cleartext values.
|
|
878
|
+
*
|
|
879
|
+
* The receipt holder retains openings (value + salt per field) and can selectively
|
|
880
|
+
* disclose any subset to auditors via Merkle inclusion proofs verifiable by
|
|
881
|
+
* @veritasacta/verify@>=0.6.0.
|
|
882
|
+
*
|
|
883
|
+
* This module sits alongside signing.ts (the legacy @veritasacta/artifacts-based
|
|
884
|
+
* cleartext path) and is invoked when SigningConfig.commitment_mode.enabled is
|
|
885
|
+
* true. The two paths are mutually exclusive on a per-receipt basis.
|
|
886
|
+
*
|
|
887
|
+
* @since 0.6.0
|
|
888
|
+
* @standard draft-farley-acta-signed-receipts-01 §commitment-mode
|
|
889
|
+
* @standard RFC 6962 (Certificate Transparency Merkle tree construction)
|
|
890
|
+
* @standard RFC 8032 (Ed25519)
|
|
891
|
+
* @standard RFC 8785 (JCS)
|
|
892
|
+
*/
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* The opening information for a single committed field. Held by the
|
|
896
|
+
* receipt issuer; never embedded in the published receipt. Required to
|
|
897
|
+
* later produce a selective-disclosure proof.
|
|
898
|
+
*/
|
|
899
|
+
interface CommittedFieldOpening {
|
|
900
|
+
/** Field name (matches one of committed_field_names). */
|
|
901
|
+
name: string;
|
|
902
|
+
/** Cleartext value of the field. */
|
|
903
|
+
value: unknown;
|
|
904
|
+
/** Salt bytes (32 random bytes per field per receipt). */
|
|
905
|
+
salt: Uint8Array;
|
|
906
|
+
/** Zero-based index of the field in the canonically-sorted leaf list. */
|
|
907
|
+
index: number;
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* The result of signing a decision in commitment mode.
|
|
911
|
+
*/
|
|
912
|
+
interface CommittedSignResult {
|
|
913
|
+
/** The signed receipt as a JSON string (canonical wire form). */
|
|
914
|
+
signed: string;
|
|
915
|
+
/** Receipt artifact type, e.g. "decision_receipt_committed_v1". */
|
|
916
|
+
artifact_type: string;
|
|
917
|
+
/**
|
|
918
|
+
* Per-field openings, indexed by field name. The issuer MUST persist
|
|
919
|
+
* these securely if it intends to support selective disclosure later.
|
|
920
|
+
* Storing them is the issuer's responsibility; this library does not
|
|
921
|
+
* write them to disk.
|
|
922
|
+
*/
|
|
923
|
+
openings: Record<string, CommittedFieldOpening>;
|
|
924
|
+
/** Lowercase hex SHA-256 of the canonical signed receipt. */
|
|
925
|
+
receipt_hash: string;
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* A minimal selective-disclosure envelope. Reveal a single committed field
|
|
929
|
+
* to an auditor by supplying its (name, value, salt, proof). The auditor
|
|
930
|
+
* recomputes the leaf hash and walks the proof to confirm it reconstructs
|
|
931
|
+
* the receipt's committed_fields_root.
|
|
932
|
+
*
|
|
933
|
+
* Compatible with @veritasacta/verify@>=0.6.0.
|
|
934
|
+
*/
|
|
935
|
+
interface MinimalDisclosure {
|
|
936
|
+
/** The receipt this disclosure targets, by canonical hash. */
|
|
937
|
+
parent_receipt_hash: string;
|
|
938
|
+
/** Disclosed field name. */
|
|
939
|
+
name: string;
|
|
940
|
+
/** Cleartext value of the disclosed field. */
|
|
941
|
+
value: unknown;
|
|
942
|
+
/** Salt as base64url (no padding). */
|
|
943
|
+
salt: string;
|
|
944
|
+
/** Merkle inclusion proof. */
|
|
945
|
+
proof: MerkleProof;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Sign a DecisionLog in commitment mode.
|
|
949
|
+
*
|
|
950
|
+
* @param entry - The decision log entry to sign.
|
|
951
|
+
* @param committedFieldNames - Names of fields to commit. Recommended:
|
|
952
|
+
* ["tool", "scope", "payload_digest", "swarm"]. Fields not listed
|
|
953
|
+
* remain cleartext in the signed payload.
|
|
954
|
+
* @param signingKey - Ed25519 private key (32 bytes hex or raw).
|
|
955
|
+
* @param publicKey - Ed25519 public key (32 bytes hex).
|
|
956
|
+
* @param kid - Key identifier (RFC 7638 JWK thumbprint or operator-chosen).
|
|
957
|
+
* @param issuer - Issuer identifier (e.g. "my-gateway.example.com").
|
|
958
|
+
*
|
|
959
|
+
* @returns Signed receipt JSON, openings (per field), and receipt hash.
|
|
960
|
+
*
|
|
961
|
+
* @standard draft-farley-acta-signed-receipts-01 §signature-scope
|
|
962
|
+
* The signature covers SHA-256(JCS(payload_minus_signature)).
|
|
963
|
+
*/
|
|
964
|
+
declare function signCommittedDecision(entry: DecisionLog, committedFieldNames: string[], signingKey: string, publicKey: string, kid: string, issuer: string): CommittedSignResult;
|
|
965
|
+
/**
|
|
966
|
+
* Build a minimal selective-disclosure envelope for a single committed
|
|
967
|
+
* field. The envelope can be verified offline by anyone who has the
|
|
968
|
+
* receipt's committed_fields_root (which the receipt itself carries).
|
|
969
|
+
*
|
|
970
|
+
* @param receiptHash - Canonical hash of the receipt the disclosure targets.
|
|
971
|
+
* @param fieldName - Which field to disclose.
|
|
972
|
+
* @param openings - The full openings map produced by signCommittedDecision.
|
|
973
|
+
*
|
|
974
|
+
* @standard draft-farley-acta-signed-receipts-01 §commitment-disclosure
|
|
975
|
+
*/
|
|
976
|
+
declare function discloseField(receiptHash: string, fieldName: string, openings: Record<string, CommittedFieldOpening>): MinimalDisclosure;
|
|
977
|
+
|
|
828
978
|
/**
|
|
829
979
|
* @scopeblind/protect-mcp — External PDP Adapter
|
|
830
980
|
*
|
|
@@ -2763,4 +2913,73 @@ declare function confidentialInference(_prompt: string, _config: ConfidentialInf
|
|
|
2763
2913
|
receipt: Record<string, unknown>;
|
|
2764
2914
|
}>;
|
|
2765
2915
|
|
|
2766
|
-
|
|
2916
|
+
/**
|
|
2917
|
+
* scopeblind-bridge.ts
|
|
2918
|
+
*
|
|
2919
|
+
* Optional bridge between protect-mcp (local, MIT) and a paid ScopeBlind
|
|
2920
|
+
* tenant. When SCOPEBLIND_TOKEN is set in the environment, every signed
|
|
2921
|
+
* receipt that protect-mcp emits also gets forwarded to the tenant's
|
|
2922
|
+
* dashboard at https://scopeblind.com/console/<slug>.
|
|
2923
|
+
*
|
|
2924
|
+
* Lifecycle:
|
|
2925
|
+
* 1. On first use, exchange SCOPEBLIND_TOKEN for a short-lived BRASS-v2
|
|
2926
|
+
* auth proof from /fn/brass/issue. Cache the proof in memory until
|
|
2927
|
+
* ~5 minutes before expiry, then refresh.
|
|
2928
|
+
* 2. As receipts are emitted by hook-server.ts, push them into an
|
|
2929
|
+
* in-memory batch queue.
|
|
2930
|
+
* 3. Flush the queue every 5s (or when it reaches 128 receipts) by POSTing
|
|
2931
|
+
* to /fn/console/<slug>/receipts with Bearer SCOPEBLIND_TOKEN.
|
|
2932
|
+
*
|
|
2933
|
+
* Failure mode: forward errors NEVER throw upstream. protect-mcp continues
|
|
2934
|
+
* to mint and persist receipts locally regardless of dashboard availability.
|
|
2935
|
+
* The bridge logs failures to stderr (best-effort) and retries on the next
|
|
2936
|
+
* flush.
|
|
2937
|
+
*
|
|
2938
|
+
* Configuration:
|
|
2939
|
+
* SCOPEBLIND_TOKEN Tenant bearer token (from welcome email).
|
|
2940
|
+
* SCOPEBLIND_TENANT Optional slug override. By default we discover
|
|
2941
|
+
* the slug from the BRASS proof's tenant_id.
|
|
2942
|
+
* SCOPEBLIND_BASE Defaults to https://scopeblind.com.
|
|
2943
|
+
*
|
|
2944
|
+
* @license MIT
|
|
2945
|
+
*/
|
|
2946
|
+
interface BridgeStats {
|
|
2947
|
+
enabled: boolean;
|
|
2948
|
+
tenant_slug: string | null;
|
|
2949
|
+
forwarded_total: number;
|
|
2950
|
+
rejected_total: number;
|
|
2951
|
+
last_flush_at: string | null;
|
|
2952
|
+
last_error: string | null;
|
|
2953
|
+
}
|
|
2954
|
+
declare class ScopeBlindBridge {
|
|
2955
|
+
private readonly token;
|
|
2956
|
+
private readonly base;
|
|
2957
|
+
private readonly tenantOverride;
|
|
2958
|
+
private cachedProof;
|
|
2959
|
+
private queue;
|
|
2960
|
+
private flushTimer;
|
|
2961
|
+
private stats;
|
|
2962
|
+
private shuttingDown;
|
|
2963
|
+
constructor(env?: Record<string, string | undefined>);
|
|
2964
|
+
enabled(): boolean;
|
|
2965
|
+
/** Push a signed receipt into the queue. Non-blocking. */
|
|
2966
|
+
forward(signedReceipt: any): void;
|
|
2967
|
+
/** Flush the queue. Safe to call concurrently. */
|
|
2968
|
+
flush(): Promise<void>;
|
|
2969
|
+
/** Exchange SCOPEBLIND_TOKEN for a BRASS-v2 proof; refresh near expiry. */
|
|
2970
|
+
private ensureBrassProof;
|
|
2971
|
+
/**
|
|
2972
|
+
* Return a snapshot of bridge stats. Useful for `protect-mcp scopeblind status`.
|
|
2973
|
+
*/
|
|
2974
|
+
getStats(): BridgeStats & {
|
|
2975
|
+
queued: number;
|
|
2976
|
+
brass_proof_expires_at: string | null;
|
|
2977
|
+
};
|
|
2978
|
+
/** Flush remaining receipts and stop the interval. Called on process exit. */
|
|
2979
|
+
shutdown(): Promise<void>;
|
|
2980
|
+
}
|
|
2981
|
+
declare function getScopeBlindBridge(): ScopeBlindBridge;
|
|
2982
|
+
/** Convenience: forward a signed receipt without instantiating yourself. */
|
|
2983
|
+
declare function forwardReceipt(signedReceipt: any): void;
|
|
2984
|
+
|
|
2985
|
+
export { type ActionReceipt, type AdmissionResult, type AgentId, type AgentManifest, type ApprovalAssertion, type ApprovalChallenge, type ApprovalNotification, type ApprovalResult, type ArenaPayload, type ArenaReceipt, type AttestationDocument, type AttestationPayload, type AttestationProvider, type AttestationReceipt, type AttestationResult, type AuditBundle, type AuditBundleOptions, type BenchmarkPayload, type BenchmarkReceipt, type BuilderId, type C2PAAssertion, type C2PAIngredient, type C2PAManifest, type C2PAOptions, type CCRConnectorConfig, type CCRSessionContext, type CalibrationScore, type CedarEvalRequest, type CedarPolicySet, type CedarSchema, type CedarSchemaResult, type CommittedFieldOpening, type CommittedSignResult, type ComplianceReport, ConfidentialGate, type ConfidentialGateConfig, type ConfidentialInferenceConfig, type CredentialConfig, type DecisionContext, type DecisionLog, type DelegationReceipt, type DisclosureMode, type Ed25519PublicKey, type EvidenceAttestation, type EvidenceAttestationInput, type EvidenceIssuer, type EvidenceReceipt, type EvidenceReceiptBase, type EvidenceSummary, type EvidenceSummaryEntry, type EvidenceType, type ExternalDecision, type ExternalPDPConfig, type HFDatasetMetadata, type HFReceiptRow, type HookEventName, type HookInput, type HookResponse, type IssuerType, type JsonRpcRequest, type JsonRpcResponse, type LeaseCompatibility, type ManifestBuilder, type ManifestCapabilities, type ManifestConfig, type ManifestIdentity, type ManifestPresentation, type ManifestSignature, type ManifestStatus, type McpToolDescription, type MinimalDisclosure, type NotificationConfig, type PassportTokenClaims, type PayloadDigest, type PlanReceipt, type PolicyEngineMode, type PredictionReceipt, type PredictionResolution, type PropagatorConfig, type ProtectConfig, ProtectGateway, type ProtectPolicy, type RateLimit, ReceiptPropagator, type RedactedResult, type RedactionSalt, type RekorAnchor, type RekorVerification, type RestraintPayload, type RestraintReceipt, type SHA256Hash, type SafetyTranscript, type Sandbox, type SandboxConfig, type SandboxReceipt, type SandboxResult, type SandboxToolCall, type SchemaGeneratorConfig, ScopeBlindBridge, type SigningConfig, type SimulationResult, type SimulationSummary, type SwarmContext, type TierOverrides, type TimingMetrics, type ToolPolicy, type TrustTier, type WorkPayload, type WorkReceipt, anchorToRekor, buildDecisionContext, checkRateLimit, collectSignedReceipts, computeCalibration, confidentialInference, createApprovalChallenge, createApprovalReceiptPayload, createAttestationField, createAuditBundle, createC2PAManifest, createDisclosurePackage, createEvidenceAttestation, createLogAnchorField, createReceiptChannel, createSandbox, destroySandbox, discloseField, ed25519ToDIDKey, evaluateCedar, evaluateTier, exportC2PAManifestJSON, exportJSONL, formatReportMarkdown, formatSimulation, forwardReceipt, generateC2PACommand, generateCedarSchema, generateDatasetCard, generateHFMetadata, generateReport, generateSafetyTranscript, generateSchemaStub, getScopeBlindBridge, getSignerInfo, getToolPolicy, hashReceipt, hashResponseBody, initSigning, isAgentId, isCedarAvailable, isDisclosureMode, isEvidenceType, isManifestStatus, isSigningEnabled, listCredentialLabels, loadCedarPolicies, loadPolicy, manifestToVC, meetsMinTier, parseLogFile, parseNotificationConfigFromEnv, parseRateLimit, queryExternalPDP, receiptToVP, receiptsToHFRows, redactFields, resolveCredential, revealField, runInSandbox, sendApprovalNotification, signCommittedDecision, signDecision, simulate, toCredentialRequestOptions, toManifoldFormat, toMetaculusFormat, validateCredentials, validateEvidenceReceipt, validateManifest, verifyActaC2PAAssertions, verifyAllCommitments, verifyApprovalAssertion, verifyCommitment, verifyEvidenceAttestation, verifyRekorAnchor };
|