protect-mcp 0.6.3 → 0.7.1

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/index.d.ts CHANGED
@@ -595,19 +595,52 @@ interface CedarSchema {
595
595
  * Throws if the directory doesn't exist or contains no .cedar files.
596
596
  */
597
597
  declare function loadCedarPolicies(dirPath: string): CedarPolicySet;
598
+ interface CedarEvalOptions {
599
+ /**
600
+ * Default true (0.7.0+). When true, ANY evaluation error, engine
601
+ * unavailability, malformed result, or per-policy error DENIES. When false
602
+ * (explicit observe/shadow use only), those paths ALLOW but are flagged
603
+ * would_deny:true in the decision metadata so the failure is never silent.
604
+ */
605
+ failClosed?: boolean;
606
+ }
598
607
  /**
599
608
  * Evaluate a Cedar policy set against a tool call.
600
609
  *
601
- * Returns a standard ExternalDecision compatible with the gateway's
602
- * decision pipeline. If Cedar WASM is not available, returns a
603
- * fallback allow decision (fail-open, logged).
610
+ * FAIL-CLOSED by default (0.7.0+): if Cedar is unavailable, the engine API is
611
+ * unsupported, evaluation throws, the result is malformed, or ANY policy errored
612
+ * during evaluation (which Cedar otherwise silently discards, leaving a residual
613
+ * permit standing), this returns DENY. The allow-on-error behavior is reachable
614
+ * only by explicitly passing { failClosed: false }, and even then it is flagged.
604
615
  */
605
- declare function evaluateCedar(policySet: CedarPolicySet, req: CedarEvalRequest, schema?: CedarSchema): Promise<ExternalDecision>;
616
+ declare function evaluateCedar(policySet: CedarPolicySet, req: CedarEvalRequest, schema?: CedarSchema, options?: CedarEvalOptions): Promise<ExternalDecision>;
606
617
  /**
607
618
  * Validate that Cedar WASM is available.
608
619
  * Useful for CLI startup diagnostics.
609
620
  */
610
621
  declare function isCedarAvailable(): Promise<boolean>;
622
+ /** Build a CedarPolicySet from inline source (for the self-test). */
623
+ declare function policySetFromSource(source: string, name?: string): CedarPolicySet;
624
+ interface SelfTestCase {
625
+ name: string;
626
+ expected: 'ALLOW' | 'DENY';
627
+ actual: 'ALLOW' | 'DENY';
628
+ pass: boolean;
629
+ reason?: string;
630
+ }
631
+ interface SelfTestReport {
632
+ wasmAvailable: boolean;
633
+ passed: boolean;
634
+ cases: SelfTestCase[];
635
+ }
636
+ /**
637
+ * Run known deny/allow vectors through the LIVE evaluator before the gate is
638
+ * trusted. Always proves the fail-closed invariant (the engine being unable to
639
+ * decide must DENY). When Cedar WASM is present it also proves a real forbid
640
+ * denies, a permit allows, and a policy using the silently-discarded
641
+ * `in`-on-String pattern DENIES rather than permit-all (the 0.6.x regression).
642
+ */
643
+ declare function runEvaluatorSelfTest(): Promise<SelfTestReport>;
611
644
 
612
645
  /**
613
646
  * MCP tool-calling gateway that intercepts JSON-RPC requests,
@@ -2019,29 +2052,6 @@ interface ApprovalResult {
2019
2052
  contextHash: string;
2020
2053
  /** Timestamp of approval */
2021
2054
  approvedAt: string;
2022
- /** On failure, a machine-readable reason (e.g. 'invalid_signature'). */
2023
- reason?: string;
2024
- }
2025
- /**
2026
- * The registered credential public key, extracted from the COSE_Key at
2027
- * registration. ES256 keys are an uncompressed P-256 point; EdDSA keys are a
2028
- * 32-byte Ed25519 public key.
2029
- */
2030
- interface CredentialPublicKey {
2031
- /** COSE algorithm: -7 = ES256 (P-256 / ECDSA), -8 = EdDSA (Ed25519). */
2032
- alg: -7 | -8;
2033
- /** Public key, hex. ES256: 65-byte uncompressed point (0x04 || x || y). EdDSA: 32-byte key. */
2034
- publicKeyHex: string;
2035
- }
2036
- interface VerifyAssertionOptions {
2037
- /** Allowed origin(s) the assertion must come from, e.g. 'https://app.scopeblind.com'. Defaults to https://<rpId>. */
2038
- expectedOrigin?: string | string[];
2039
- /** Require the UV (user-verified / biometric or PIN) flag. Default true. */
2040
- requireUserVerification?: boolean;
2041
- /** The signCount stored from the previous assertion; a non-increasing counter signals a cloned authenticator. */
2042
- prevSignCount?: number;
2043
- /** Override 'now' (ms) for testing. */
2044
- now?: number;
2045
2055
  }
2046
2056
  /**
2047
2057
  * Create a WebAuthn challenge for approving a tool call.
@@ -2078,22 +2088,17 @@ declare function toCredentialRequestOptions(challenge: ApprovalChallenge, allowC
2078
2088
  };
2079
2089
  };
2080
2090
  /**
2081
- * Verify a WebAuthn assertion: full, fail-closed verification of a passkey or
2082
- * security-key co-sign. This proves a SPECIFIC human authorized a SPECIFIC
2083
- * action with a hardware-held key the host operator cannot exfiltrate. It
2084
- * checks, in order: challenge freshness; clientDataJSON type, challenge, and
2085
- * origin; the rpIdHash; the UP (and, by default, UV) flags; the authenticator
2086
- * signature over authenticatorData || SHA-256(clientDataJSON) using the
2087
- * registered credential public key (ES256 or EdDSA); and signCount monotonicity
2088
- * (clone detection) when a previous count is supplied. Any failure returns
2089
- * valid:false with a reason; nothing is trusted on a partial check.
2091
+ * Verify a WebAuthn assertion from the client.
2092
+ *
2093
+ * This is a simplified verification that checks the structure
2094
+ * and extracts the authenticator data. For production use with
2095
+ * full signature verification, use the @simplewebauthn/server package.
2090
2096
  *
2091
- * @param challenge - the original challenge
2092
- * @param assertion - the assertion from navigator.credentials.get()
2093
- * @param credentialPublicKey - the registered public key for assertion.credentialId
2094
- * @param opts - origin / UV / signCount / clock options
2097
+ * @param challenge - The original challenge
2098
+ * @param assertion - The assertion from navigator.credentials.get()
2099
+ * @returns ApprovalResult with verification details
2095
2100
  */
2096
- declare function verifyApprovalAssertion(challenge: ApprovalChallenge, assertion: ApprovalAssertion, credentialPublicKey?: CredentialPublicKey, opts?: VerifyAssertionOptions): ApprovalResult;
2101
+ declare function verifyApprovalAssertion(challenge: ApprovalChallenge, assertion: ApprovalAssertion): ApprovalResult;
2097
2102
  /**
2098
2103
  * Create the approval receipt payload for embedding in an Acta receipt.
2099
2104
  *
@@ -3010,4 +3015,4 @@ declare function getScopeBlindBridge(): ScopeBlindBridge;
3010
3015
  /** Convenience: forward a signed receipt without instantiating yourself. */
3011
3016
  declare function forwardReceipt(signedReceipt: any): void;
3012
3017
 
3013
- 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 };
3018
+ 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 CedarEvalOptions, 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 SelfTestCase, type SelfTestReport, 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, policySetFromSource, queryExternalPDP, receiptToVP, receiptsToHFRows, redactFields, resolveCredential, revealField, runEvaluatorSelfTest, runInSandbox, sendApprovalNotification, signCommittedDecision, signDecision, simulate, toCredentialRequestOptions, toManifoldFormat, toMetaculusFormat, validateCredentials, validateEvidenceReceipt, validateManifest, verifyActaC2PAAssertions, verifyAllCommitments, verifyApprovalAssertion, verifyCommitment, verifyEvidenceAttestation, verifyRekorAnchor };