@fiderail/guard 2.3.1 → 2.3.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 CHANGED
@@ -34,6 +34,12 @@ console.log(result.decision, result.readyToSign);
34
34
  - **Ed25519 Capability Mandates**: `generateMandateKeypair`, `issueRootMandate`, `delegateChildMandate`, `verifyEd25519MandateSignature`, `verifySignedMandateChain`, `encodeEd25519Identity`, `decodeEd25519Identity`
35
35
  - **Policy & Digest Helpers**: `CANONICAL_USDC_ASSETS`, `clampPolicy`, `scanOutboundSecrets`, `computeQuoteDigest`, `computePaymentFingerprint`, `computeDeliveryReceipt`, `isAssetAllowed`
36
36
 
37
+ ## Important Integration Semantics
38
+
39
+ - **Strict blocking of unknown / low-trust addresses (including micro-payments)**: By default, `DEFAULT_FIREWALL_POLICY` sets `allowUnknownMaxUsdc: 0.05` so unknown or low-score counterparties pass micro-probes `<= $0.05 USDC` with `WARN`. **To hard-block all unknown or low-trust counterparties including micro-payments, explicitly pass `allowUnknownMaxUsdc: 0` alongside `minTrustScore`.**
40
+ - **`onOutage` scope**: **`onOutage` (`"fail-closed"` / `"fail-open-micro"`) applies only to `preflightPaymentGuard` and `guardedX402Fetch`; direct `getAgentTrust` calls always throw when the cloud oracle is unreachable and no stale cache entry exists.**
41
+ - **`RemoteTrustClient.getPayerActivity` remote default**: **Remote `RemoteTrustClient.getPayerActivity` returns `null` by default; for remote seller-side buyer screening, use `POST /v1/trust-provider/before-settle` (or `@fiderail/seller`).**
42
+
37
43
  ## Runtime Requirements
38
44
 
39
45
  Requires **Node.js `>= 22.13.0`** (uses built-in `node:sqlite` and `node:crypto`). Keys and funds remain 100% local on the buyer's machine.
@@ -43,7 +49,7 @@ Requires **Node.js `>= 22.13.0`** (uses built-in `node:sqlite` and `node:crypto`
43
49
  - Portal: [https://fiderail.com](https://fiderail.com)
44
50
  - Documentation: [https://fiderail.com/docs](https://fiderail.com/docs)
45
51
  - Source (GitLab): [https://gitlab.com/fiderail/fiderail](https://gitlab.com/fiderail/fiderail)
46
- - Mirror (GitHub): [https://github.com/fiderail/fiderail](https://github.com/fiderail/fiderail)
52
+ - Mirror (GitHub — pending reinstatement): [https://github.com/fiderail/fiderail](https://github.com/fiderail/fiderail)
47
53
 
48
54
  ## License
49
55
 
package/dist/index.d.ts CHANGED
@@ -114,6 +114,8 @@ export interface GuardedX402FetchOptions {
114
114
  }, guard: any) => Promise<string | {
115
115
  xPayment?: string;
116
116
  headerValue?: string;
117
+ paymentHeader?: string;
118
+ quoteDigest?: string;
117
119
  boundQuote?: any;
118
120
  }>) | null;
119
121
  onApprovalRequired?: ((ctx: any) => Promise<boolean | {
package/dist/index.js CHANGED
@@ -675,6 +675,22 @@ export async function guardedX402Fetch({ url, method = "GET", headers = {}, body
675
675
  }
676
676
  }
677
677
  const signed = await signer({ ...frozenQuote }, guard);
678
+ if (signed &&
679
+ typeof signed === "object" &&
680
+ signed.quoteDigest &&
681
+ signed.quoteDigest !== quoteDigest) {
682
+ return {
683
+ paid: false,
684
+ blocked: true,
685
+ readyToSign: false,
686
+ decision: "BLOCK",
687
+ reason: "QUOTE_TAMPERING_DETECTED",
688
+ quoteDigest,
689
+ paymentOption: frozenQuote,
690
+ guard,
691
+ spentTodayUsdc: ledger.getSpentTodayUsdc(),
692
+ };
693
+ }
678
694
  if (signed && typeof signed === "object" && signed.boundQuote) {
679
695
  const bq = signed.boundQuote;
680
696
  const mismatch = normalizeChainAddress(chosen.chain, bq.payTo || "") !== frozenQuote.payTo ||
@@ -698,7 +714,7 @@ export async function guardedX402Fetch({ url, method = "GET", headers = {}, body
698
714
  proofValue =
699
715
  typeof signed === "string"
700
716
  ? signed
701
- : signed?.xPayment || signed?.headerValue || null;
717
+ : signed?.xPayment || signed?.headerValue || signed?.paymentHeader || null;
702
718
  if (!proofValue) {
703
719
  throw new Error("Local signer did not return a payment proof header value.");
704
720
  }
package/dist/mandate.d.ts CHANGED
@@ -50,8 +50,11 @@ export declare function delegateChildMandate(params: {
50
50
  }): AttenuatedMandate;
51
51
  /**
52
52
  * Verifies an Ed25519 signature over a mandate's canonical JCS payload against `expectedSigner`.
53
+ * `signingPayload` may be omitted (auto-computed from `mandate`); when supplied, it MUST match
54
+ * `createMandateSigningPayload(mandate)` exactly or verification returns `false`.
53
55
  */
54
- export declare function verifyEd25519MandateSignature(mandate: AttenuatedMandate, signingPayload: string, expectedSigner: string): boolean;
56
+ export declare function verifyEd25519MandateSignature(mandate: AttenuatedMandate, expectedSigner?: string): boolean;
57
+ export declare function verifyEd25519MandateSignature(mandate: AttenuatedMandate, signingPayload: string | undefined, expectedSigner: string): boolean;
55
58
  /**
56
59
  * Offline cryptographic verification of a complete Attenuated Capability Mandate chain.
57
60
  */
package/dist/mandate.js CHANGED
@@ -185,17 +185,31 @@ export function delegateChildMandate(params) {
185
185
  .toString("base64");
186
186
  return { ...unsigned, proof };
187
187
  }
188
- /**
189
- * Verifies an Ed25519 signature over a mandate's canonical JCS payload against `expectedSigner`.
190
- */
191
- export function verifyEd25519MandateSignature(mandate, signingPayload, expectedSigner) {
192
- if (!mandate.proof || mandate.proofType !== "ed25519")
188
+ export function verifyEd25519MandateSignature(mandate, signingPayloadOrExpectedSigner, expectedSignerArg) {
189
+ if (!mandate || !mandate.proof || mandate.proofType !== "ed25519")
193
190
  return false;
191
+ const canonicalPayload = createMandateSigningPayload(mandate);
192
+ let expectedSigner;
193
+ if (expectedSignerArg !== undefined) {
194
+ if (signingPayloadOrExpectedSigner !== undefined &&
195
+ signingPayloadOrExpectedSigner !== canonicalPayload) {
196
+ return false;
197
+ }
198
+ expectedSigner = expectedSignerArg;
199
+ }
200
+ else if (signingPayloadOrExpectedSigner !== undefined) {
201
+ expectedSigner = signingPayloadOrExpectedSigner;
202
+ }
203
+ else {
204
+ if (mandate.parentMandateId)
205
+ return false;
206
+ expectedSigner = mandate.rootIssuer;
207
+ }
194
208
  const pubKey = decodeEd25519Identity(expectedSigner);
195
209
  if (!pubKey)
196
210
  return false;
197
211
  try {
198
- return crypto.verify(null, Buffer.from(signingPayload, "utf8"), pubKey, Buffer.from(mandate.proof, "base64"));
212
+ return crypto.verify(null, Buffer.from(canonicalPayload, "utf8"), pubKey, Buffer.from(mandate.proof, "base64"));
199
213
  }
200
214
  catch {
201
215
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiderail/guard",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Non-custodial buyer-side Guard-and-Pay x402 adapter with atomic budget holds, outbound secret scrubber, quote binding, circuit breaker, and SAR receipts.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "homepage": "https://fiderail.com",
31
31
  "repository": {
32
32
  "type": "git",
33
- "url": "https://gitlab.com/fiderail/fiderail.git",
33
+ "url": "git+https://gitlab.com/fiderail/fiderail.git",
34
34
  "directory": "packages/guard"
35
35
  },
36
36
  "bugs": {
@@ -49,9 +49,9 @@
49
49
  "capability-mandate"
50
50
  ],
51
51
  "dependencies": {
52
- "@fiderail/core": "2.3.1",
53
- "@fiderail/spec": "2.3.1",
54
- "@fiderail/zk-types": "2.3.1"
52
+ "@fiderail/core": "2.3.2",
53
+ "@fiderail/spec": "2.3.2",
54
+ "@fiderail/zk-types": "2.3.2"
55
55
  },
56
56
  "license": "MIT"
57
57
  }