twzrd-x402-gate 0.7.1 → 0.8.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 +109 -5
- package/dist/adoption-proof.d.ts +101 -0
- package/dist/adoption-proof.d.ts.map +1 -0
- package/dist/adoption-proof.js +290 -0
- package/dist/adoption-proof.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/seller-hook.d.ts +161 -0
- package/dist/seller-hook.d.ts.map +1 -0
- package/dist/seller-hook.js +300 -0
- package/dist/seller-hook.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -5
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +7 -2
- package/dist/version.js.map +1 -1
- package/dist/x402-client-hook.d.ts +19 -1
- package/dist/x402-client-hook.d.ts.map +1 -1
- package/dist/x402-client-hook.js +122 -119
- package/dist/x402-client-hook.js.map +1 -1
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -2,9 +2,91 @@
|
|
|
2
2
|
|
|
3
3
|
**TWZRD is the default `onBeforePaymentCreation` policy engine for official x402 clients.**
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
payment payload creation / wallet signing — free preflight + merchant_card wash
|
|
7
|
-
|
|
5
|
+
**Core product (buyer gate):** after the client selects the exact payment requirement and
|
|
6
|
+
**before** payment payload creation / wallet signing — free preflight + merchant_card wash
|
|
7
|
+
refuse. Protects the **payer** from a risky **merchant** (`payTo`). Chain-neutral envelope;
|
|
8
|
+
**Solana-deep** reputation only (Base/EVM = explicit `unknown`).
|
|
9
|
+
|
|
10
|
+
**Optional (0.8.1):** a resource-server settle hook so merchants can apply **customer policy**
|
|
11
|
+
before they settle and serve (abuse, sanctions, bots, “don’t serve this payer”). Not an equal
|
|
12
|
+
mirror of the buyer problem — settled USDC is final; wash resistance is mainly TWZRD scoring.
|
|
13
|
+
|
|
14
|
+
## Seller settle guard (`onBeforeSettle`) — optional 0.8.1
|
|
15
|
+
|
|
16
|
+
Resource servers can screen the **payer** before *they* settle an inbound payment and serve
|
|
17
|
+
the resource. Use for merchant policy (abuse / sanctions / bots / customer selection). TWZRD is
|
|
18
|
+
not in the settlement path: advisory + fail-open by default. Attaches to official
|
|
19
|
+
`x402ResourceServer.onBeforeSettle` (inherited by `@x402/express|hono|next|fastify` and Python x402).
|
|
20
|
+
|
|
21
|
+
Do **not** treat this as “protect merchant reputation by rejecting USDC” — anyone can still
|
|
22
|
+
transfer on-chain. Wash/sybil edges are primarily discounted in TWZRD scoring, not forced
|
|
23
|
+
revenue refusal.
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install twzrd-x402-gate@0.8.2
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { x402ResourceServer } from "@x402/core/server";
|
|
31
|
+
import { createTwzrdSettleGuard, twzrdPayerScreen } from "twzrd-x402-gate";
|
|
32
|
+
|
|
33
|
+
const server = new x402ResourceServer(facilitator);
|
|
34
|
+
server.onBeforeSettle(
|
|
35
|
+
createTwzrdSettleGuard({ screen: twzrdPayerScreen() }),
|
|
36
|
+
);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Defaults (fail-open / advisory):**
|
|
40
|
+
|
|
41
|
+
| Behavior | Default |
|
|
42
|
+
|----------|---------|
|
|
43
|
+
| Abort settlement | `decision=block` **or** `wash_flagged=true` |
|
|
44
|
+
| `warn` | **allowed** (continues) unless you set `abortOn.warn` |
|
|
45
|
+
| Default screen | free `GET /v1/intel/merchant_card/{payer}` via `twzrdPayerScreen()` |
|
|
46
|
+
| Screen/extract timeout | `timeoutMs: 3000` — on timeout, **continue** (fail-open) |
|
|
47
|
+
| Unresolved payer / null screen / screen error | **continue** unless `failOpen: false` |
|
|
48
|
+
| Paid `/v1/intel/trust` | **not** default — inject a custom `screen` if you want it |
|
|
49
|
+
|
|
50
|
+
Payer identity prefers signed/encoded scheme fields (EIP-3009 `authorization.from`, Permit2
|
|
51
|
+
`permit2Authorization.from`, exact-SVM `payload.transaction` via optional peer `@x402/svm`)
|
|
52
|
+
over client-supplied loose aliases — so a spoofed `payload.payer` cannot bypass screening.
|
|
53
|
+
|
|
54
|
+
Offline demo: `npx tsx examples/seller-settle-guard.ts`
|
|
55
|
+
Fixture-backed SVM extract tests live in `test/seller-hook.test.ts` +
|
|
56
|
+
`test/fixtures/exact-svm-transfer-checked.ts`.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## Demonstrable refuse mechanism (free, fail-open, reproducible)
|
|
60
|
+
|
|
61
|
+
**Status (2026-07-16):** mechanism proof — not adoption or demand.
|
|
62
|
+
|
|
63
|
+
Install the published gate and run against wash fixtures:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install twzrd-x402-gate@0.8.2
|
|
67
|
+
# from package root after install, or from a checkout:
|
|
68
|
+
npm run wash-dogfood
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Verified live (2026-07-16):**
|
|
72
|
+
|
|
73
|
+
| Fixture | preflight_id | decision | note |
|
|
74
|
+
|---------|--------------|----------|------|
|
|
75
|
+
| `7G73PL…` wash dogfood | 378468 | **block** | wash_flagged=true |
|
|
76
|
+
| `HuSiSpc…` | 378469 | **block** | wash_flagged=true, fleet≈98% |
|
|
77
|
+
| `BJGds…` alt wash | 378470 | warn | wash_flagged=true (nuance — not all wash is hard-block) |
|
|
78
|
+
| `4LkEF…` clean control | 378471 | warn | not wash |
|
|
79
|
+
|
|
80
|
+
Gate dogfood: `approved=false` `reason=twzrd_decision_block`, **USDC spent = 0**, **tx broadcast = none**, ALL PASS.
|
|
81
|
+
|
|
82
|
+
**Public transcript:** https://gist.github.com/twzrd-sol/2882bddee912f89e99061f3bc1da8227
|
|
83
|
+
|
|
84
|
+
**Accurate paste line:**
|
|
85
|
+
|
|
86
|
+
> Preflight returned decision=block on wash seller 7G73PL… / HuSiSpc… (preflight_id 378468 / 378469, wash_flagged=true). Gate approved=false reason=twzrd_decision_block. No USDC spent. No tx broadcast. Repro: `npm i twzrd-x402-gate@0.8.1 && npm run wash-dogfood` or gist above.
|
|
87
|
+
|
|
88
|
+
This is a **reproducible demonstration** that the free gate blocks known wash sellers with stamped `preflight_id`s and zero spend. It is **not** proof that external agents already default to this path at scale.
|
|
89
|
+
|
|
8
90
|
|
|
9
91
|
## Canonical integration (official x402 client)
|
|
10
92
|
|
|
@@ -83,16 +165,28 @@ Canonical path for every agent that spends USDC on Solana x402:
|
|
|
83
165
|
|
|
84
166
|
**Order note:** `onWarnUpsell` (points at paid `/trust`) fires on preflight `warn` **before** the merchant_card wash check. A wash-flagged seller that preflighted as `warn` may still get the upsell hook, then be refused on step 2.
|
|
85
167
|
|
|
86
|
-
Dogfood:
|
|
168
|
+
Dogfood (one public live proof path):
|
|
87
169
|
- Free only (wash refuse): `npm run wash-dogfood` → [`examples/wash-refuse-dogfood.ts`](./examples/wash-refuse-dogfood.ts)
|
|
88
170
|
- Official client + Path E hook (live Solana ≤$0.001): `npm run official-dogfood` → [`examples/official-x402-dogfood.ts`](./examples/official-x402-dogfood.ts). Needs `@x402/fetch` `@x402/svm` `@x402/core` `@solana/kit` `@scure/base` and a funded Solana key (`SVM_KEYPAIR_PATH` or `~/.agentcash/solana-wallet.json`). `--block` exercises hard `gateOnCanSpend` abort with $0 spend.
|
|
171
|
+
- Multi-hook composition (amount cap then TWZRD, abort short-circuit) is proven offline against the real `x402Client` in `test/x402-official-compat.test.ts`.
|
|
172
|
+
- Release identity: `CLIENT_VERSION` is read from `package.json` (single source of truth); `npm test` includes `version-identity`; `npm run pack-smoke` packs the tarball and checks the installed header.
|
|
89
173
|
|
|
90
174
|
## Install
|
|
91
175
|
|
|
92
176
|
```bash
|
|
93
|
-
npm install twzrd-x402-gate
|
|
177
|
+
npm install twzrd-x402-gate@0.8.2
|
|
94
178
|
```
|
|
95
179
|
|
|
180
|
+
Current npm truth: `0.8.2` (buyer gate + optional seller settle guard + payer-extract hardening).
|
|
181
|
+
Check `npm view twzrd-x402-gate version` if in doubt (do not pin stale **0.5.4** / **0.7.1**).
|
|
182
|
+
|
|
183
|
+
Optional settle guard (resource-server **payer** policy): see **Seller settle guard
|
|
184
|
+
(`onBeforeSettle`) — optional 0.8.1** above. Do not confuse with facilitator
|
|
185
|
+
`createOnBeforeSettleHook` in `@wzrd_sol/plugin-trustgate/facilitator` — that screens
|
|
186
|
+
the **merchant/payTo** on a brokered settle (buyer-side counterparty check at the rail).
|
|
187
|
+
|
|
188
|
+
Live card screen: `npx tsx examples/seller-settle-guard.ts --live <payerWallet>`
|
|
189
|
+
|
|
96
190
|
## TWZRD Payment Control (protocol-neutral authorization core)
|
|
97
191
|
|
|
98
192
|
The gate now ships a protocol-neutral policy runtime underneath the x402 surface.
|
|
@@ -557,6 +651,16 @@ A 402 whose payment requirements yield **no identifiable seller wallet** (missin
|
|
|
557
651
|
| `disabled` (`installTwzrdAutoGate` only) | `TWZRD_AUTO_GATE=0`/`false` | `false` | Bypass the guard entirely — `payWrap` gets the raw, unguarded fetch |
|
|
558
652
|
| `attribution` | `TWZRD_ATTRIBUTION_INTEGRATION` + `TWZRD_ATTRIBUTION_RUN_ID` | — | Opt-in run attribution (see below) |
|
|
559
653
|
|
|
654
|
+
## Gate adoption proof (no-spend harness)
|
|
655
|
+
|
|
656
|
+
Deterministic install→transcript path for operators (no wallet, no USDC):
|
|
657
|
+
|
|
658
|
+
```bash
|
|
659
|
+
npm run adoption-proof -- --integration <YOUR_ID> --run-id <UUID>
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
Emits `twzrd.gate_adoption_transcript.v1` JSON: block path aborts with `signerInvocations: 0`, allow path emits decision, attribution headers stamped on mocked preflight. Full acceptance criteria (what counts as `EXTERNAL_RUN` vs dogfood): monorepo `docs/strategy/gate-adoption-operator-proof.md`.
|
|
663
|
+
|
|
560
664
|
## Run attribution (optional, for integration correlation)
|
|
561
665
|
|
|
562
666
|
When you set `attribution`, the gate stamps **only the TWZRD preflight request** (never the
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate Adoption Proof Harness — deterministic, no-spend, package-local.
|
|
3
|
+
*
|
|
4
|
+
* Closes the install→transcript gap for operators who already installed
|
|
5
|
+
* installTwzrdX402ClientHook / installTwzrdAutoGate:
|
|
6
|
+
* 1) exact selectedRequirements reach the pre-sign hook
|
|
7
|
+
* 2) onDecision emits a verdict
|
|
8
|
+
* 3) block path aborts and never invokes a wallet/signer stub
|
|
9
|
+
* 4) attribution (integration + runId + client) is stamped on preflight only
|
|
10
|
+
*
|
|
11
|
+
* This harness is correlation / integration evidence. It is NOT EXTERNAL_RUN
|
|
12
|
+
* by itself (see docs/strategy/gate-adoption-operator-proof.md).
|
|
13
|
+
*/
|
|
14
|
+
import { type X402SelectedRequirements } from "./x402-client-hook.js";
|
|
15
|
+
export declare const ADOPTION_TRANSCRIPT_SCHEMA: "twzrd.gate_adoption_transcript.v1";
|
|
16
|
+
/** Fixture merchant pubkey (base58-shaped); not a live spend target. */
|
|
17
|
+
export declare const ADOPTION_PROOF_SELLER = "sLJ4uneGcD1mg6hKtkLYsY5HCw1nJ8GpNAmbzBWPBgk";
|
|
18
|
+
export declare const ADOPTION_PROOF_NETWORK = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
19
|
+
export declare const ADOPTION_PROOF_RESOURCE = "https://merchant.example/twzrd-adoption-proof";
|
|
20
|
+
export type GateAdoptionStepName = "block_path" | "allow_path";
|
|
21
|
+
export type GateAdoptionStep = {
|
|
22
|
+
name: GateAdoptionStepName;
|
|
23
|
+
selectedRequirements: X402SelectedRequirements;
|
|
24
|
+
abort: boolean;
|
|
25
|
+
reason?: string;
|
|
26
|
+
decisionEmitted: boolean;
|
|
27
|
+
verdict: string;
|
|
28
|
+
approved: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* payTo as reported by the hook's onDecision callback (hook-derived).
|
|
31
|
+
* Used to prove selectedRequirements reached the real hook path — not
|
|
32
|
+
* merely echoed from harness-local selectedRequirements.
|
|
33
|
+
*/
|
|
34
|
+
hookPayTo?: string;
|
|
35
|
+
/**
|
|
36
|
+
* seller_wallet from the preflight JSON body the hook actually POSTed
|
|
37
|
+
* (hook-derived via mocked fetch recorder).
|
|
38
|
+
*/
|
|
39
|
+
preflightSellerWallet?: string | null;
|
|
40
|
+
/** Count of wallet/signer stub invocations during this step (must be 0). */
|
|
41
|
+
signerInvocations: number;
|
|
42
|
+
/** Headers observed on the mocked preflight fetch for this step. */
|
|
43
|
+
preflightAttribution: {
|
|
44
|
+
integration: string | null;
|
|
45
|
+
runId: string | null;
|
|
46
|
+
client: string | null;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export type GateAdoptionAssertions = {
|
|
50
|
+
selectedRequirementReachedHook: boolean;
|
|
51
|
+
decisionEmitted: boolean;
|
|
52
|
+
blockedPathNeverInvokesSigner: boolean;
|
|
53
|
+
allowPathNeverInvokesSigner: boolean;
|
|
54
|
+
attributionSurfaced: boolean;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Lineage of this transcript.
|
|
58
|
+
* - dogfood: package harness, CI, or TWZRD-authored run
|
|
59
|
+
* - external_candidate: operator-supplied integration id (still needs server-side join for EXTERNAL_RUN)
|
|
60
|
+
*/
|
|
61
|
+
export type GateAdoptionLineage = "dogfood" | "external_candidate";
|
|
62
|
+
export type GateAdoptionTranscript = {
|
|
63
|
+
schema: typeof ADOPTION_TRANSCRIPT_SCHEMA;
|
|
64
|
+
package: "twzrd-x402-gate";
|
|
65
|
+
packageVersion: string;
|
|
66
|
+
proofKind: "local_deterministic_harness";
|
|
67
|
+
mode: "no_spend";
|
|
68
|
+
integration: string;
|
|
69
|
+
runId: string;
|
|
70
|
+
lineage: GateAdoptionLineage;
|
|
71
|
+
clientHeader: string;
|
|
72
|
+
steps: GateAdoptionStep[];
|
|
73
|
+
assertions: GateAdoptionAssertions;
|
|
74
|
+
ok: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* What this transcript is NOT. Operators must not treat package downloads,
|
|
77
|
+
* free preflight hits alone, or self-authored runIds as EXTERNAL_RUN.
|
|
78
|
+
*/
|
|
79
|
+
notExternalRunProof: string[];
|
|
80
|
+
/** Human pointer to the acceptance contract. */
|
|
81
|
+
acceptanceDoc: "docs/strategy/gate-adoption-operator-proof.md";
|
|
82
|
+
};
|
|
83
|
+
export type RunGateAdoptionProofOptions = {
|
|
84
|
+
/** Stable integration label (e.g. "acme-agent-v1"). Default dogfood label. */
|
|
85
|
+
integration?: string;
|
|
86
|
+
/** Per-run id. Default random UUID. Echo in your issue / transcript. */
|
|
87
|
+
runId?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Mark lineage external_candidate when the operator sets a non-internal integration id.
|
|
90
|
+
* Still not EXTERNAL_RUN without server-side observation (see acceptance doc).
|
|
91
|
+
*/
|
|
92
|
+
lineage?: GateAdoptionLineage;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Run the deterministic no-spend adoption proof.
|
|
96
|
+
* Never contacts a wallet; never spends USDC. Preflight is mocked.
|
|
97
|
+
*/
|
|
98
|
+
export declare function runGateAdoptionProof(opts?: RunGateAdoptionProofOptions): Promise<GateAdoptionTranscript>;
|
|
99
|
+
/** CLI entry: print one JSON transcript to stdout; exit 0 if ok else 1. */
|
|
100
|
+
export declare function main(argv?: string[]): Promise<number>;
|
|
101
|
+
//# sourceMappingURL=adoption-proof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adoption-proof.d.ts","sourceRoot":"","sources":["../src/adoption-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAKL,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,0BAA0B,EAAG,mCAA4C,CAAC;AAEvF,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,6BAA6B,CAAC;IACzC,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,mBAAmB,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,UAAU,EAAE,sBAAsB,CAAC;IACnC,EAAE,EAAE,OAAO,CAAC;IACZ;;;OAGG;IACH,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,gDAAgD;IAChD,aAAa,EAAE,+CAA+C,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B,CAAC;AA8FF;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,GAAE,2BAAgC,GACrC,OAAO,CAAC,sBAAsB,CAAC,CAsLjC;AAED,2EAA2E;AAC3E,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBlF"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate Adoption Proof Harness — deterministic, no-spend, package-local.
|
|
3
|
+
*
|
|
4
|
+
* Closes the install→transcript gap for operators who already installed
|
|
5
|
+
* installTwzrdX402ClientHook / installTwzrdAutoGate:
|
|
6
|
+
* 1) exact selectedRequirements reach the pre-sign hook
|
|
7
|
+
* 2) onDecision emits a verdict
|
|
8
|
+
* 3) block path aborts and never invokes a wallet/signer stub
|
|
9
|
+
* 4) attribution (integration + runId + client) is stamped on preflight only
|
|
10
|
+
*
|
|
11
|
+
* This harness is correlation / integration evidence. It is NOT EXTERNAL_RUN
|
|
12
|
+
* by itself (see docs/strategy/gate-adoption-operator-proof.md).
|
|
13
|
+
*/
|
|
14
|
+
import { CLIENT_VERSION } from "./version.js";
|
|
15
|
+
import { installTwzrdX402ClientHook, } from "./x402-client-hook.js";
|
|
16
|
+
export const ADOPTION_TRANSCRIPT_SCHEMA = "twzrd.gate_adoption_transcript.v1";
|
|
17
|
+
/** Fixture merchant pubkey (base58-shaped); not a live spend target. */
|
|
18
|
+
export const ADOPTION_PROOF_SELLER = "sLJ4uneGcD1mg6hKtkLYsY5HCw1nJ8GpNAmbzBWPBgk";
|
|
19
|
+
export const ADOPTION_PROOF_NETWORK = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
20
|
+
export const ADOPTION_PROOF_RESOURCE = "https://merchant.example/twzrd-adoption-proof";
|
|
21
|
+
function mockClient() {
|
|
22
|
+
let hook;
|
|
23
|
+
const client = {
|
|
24
|
+
onBeforePaymentCreation(h) {
|
|
25
|
+
hook = h;
|
|
26
|
+
return client;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
client,
|
|
31
|
+
async fire(ctx) {
|
|
32
|
+
if (!hook)
|
|
33
|
+
throw new Error("adoption-proof: hook not installed");
|
|
34
|
+
return hook(ctx);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function preflightCard(decision, canSpend) {
|
|
39
|
+
return {
|
|
40
|
+
readiness_card: {
|
|
41
|
+
decision,
|
|
42
|
+
can_spend: canSpend,
|
|
43
|
+
trust_score: decision === "block" || !canSpend ? 10 : 90,
|
|
44
|
+
seller_wallet: ADOPTION_PROOF_SELLER,
|
|
45
|
+
},
|
|
46
|
+
preflight_id: decision === "block" || !canSpend ? 1 : 2,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function recordingPreflightFetch(body) {
|
|
50
|
+
let last = null;
|
|
51
|
+
let lastSeller = null;
|
|
52
|
+
const fetchImpl = (async (_url, init) => {
|
|
53
|
+
last = new Headers(init?.headers);
|
|
54
|
+
lastSeller = null;
|
|
55
|
+
if (typeof init?.body === "string") {
|
|
56
|
+
try {
|
|
57
|
+
const parsed = JSON.parse(init.body);
|
|
58
|
+
if (typeof parsed.seller_wallet === "string")
|
|
59
|
+
lastSeller = parsed.seller_wallet;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// ignore non-JSON bodies
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return new Response(JSON.stringify(body), {
|
|
66
|
+
status: 200,
|
|
67
|
+
headers: { "content-type": "application/json" },
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
fetch: fetchImpl,
|
|
72
|
+
lastHeaders: () => last,
|
|
73
|
+
lastSellerWallet: () => lastSeller,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function baseRequirements(amount) {
|
|
77
|
+
return {
|
|
78
|
+
payTo: ADOPTION_PROOF_SELLER,
|
|
79
|
+
network: ADOPTION_PROOF_NETWORK,
|
|
80
|
+
amount,
|
|
81
|
+
asset: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
82
|
+
resource: ADOPTION_PROOF_RESOURCE,
|
|
83
|
+
scheme: "exact",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function isInternalIntegration(integration) {
|
|
87
|
+
const i = integration.toLowerCase();
|
|
88
|
+
return (i.startsWith("twzrd-") ||
|
|
89
|
+
i.startsWith("twzrd/") ||
|
|
90
|
+
i.startsWith("ops-") ||
|
|
91
|
+
i.startsWith("test-") ||
|
|
92
|
+
i === "dogfood" ||
|
|
93
|
+
i.includes("dogfood") ||
|
|
94
|
+
i.includes("internal") ||
|
|
95
|
+
i.includes("ci-") ||
|
|
96
|
+
i === "gate-adoption-proof");
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Run the deterministic no-spend adoption proof.
|
|
100
|
+
* Never contacts a wallet; never spends USDC. Preflight is mocked.
|
|
101
|
+
*/
|
|
102
|
+
export async function runGateAdoptionProof(opts = {}) {
|
|
103
|
+
const integration = opts.integration?.trim() || "gate-adoption-proof";
|
|
104
|
+
const runId = opts.runId?.trim() ||
|
|
105
|
+
(typeof crypto !== "undefined" && "randomUUID" in crypto
|
|
106
|
+
? crypto.randomUUID()
|
|
107
|
+
: `run-${Date.now()}`);
|
|
108
|
+
const lineage = opts.lineage ??
|
|
109
|
+
(isInternalIntegration(integration) ? "dogfood" : "external_candidate");
|
|
110
|
+
const clientHeader = `twzrd-x402-gate/${CLIENT_VERSION}`;
|
|
111
|
+
const steps = [];
|
|
112
|
+
// ── block path: can_spend false → abort, signer must stay 0 ─────────────
|
|
113
|
+
{
|
|
114
|
+
const signerInvocations = { n: 0 };
|
|
115
|
+
const signer = {
|
|
116
|
+
async sign() {
|
|
117
|
+
signerInvocations.n += 1;
|
|
118
|
+
throw new Error("adoption-proof: signer must not be called");
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
const { fetch, lastHeaders, lastSellerWallet } = recordingPreflightFetch(preflightCard("warn", false));
|
|
122
|
+
const { client, fire } = mockClient();
|
|
123
|
+
let decisionDetail;
|
|
124
|
+
installTwzrdX402ClientHook(client, {
|
|
125
|
+
gateOnCanSpend: true,
|
|
126
|
+
refuseWashFlagged: false,
|
|
127
|
+
fetch,
|
|
128
|
+
attribution: { integration, runId },
|
|
129
|
+
onDecision: (d) => {
|
|
130
|
+
decisionDetail = {
|
|
131
|
+
approved: d.approved,
|
|
132
|
+
verdict: d.verdict,
|
|
133
|
+
reason: d.reason,
|
|
134
|
+
payTo: d.payTo,
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
// Operator would call wallet.signMessage only after hook returns non-abort.
|
|
139
|
+
// We only invoke signer if the hook allows — proving block never reaches it.
|
|
140
|
+
const req = baseRequirements("1000");
|
|
141
|
+
const result = await fire({ selectedRequirements: req });
|
|
142
|
+
const abort = Boolean(result && typeof result === "object" && "abort" in result && result.abort);
|
|
143
|
+
if (!abort) {
|
|
144
|
+
await signer.sign();
|
|
145
|
+
}
|
|
146
|
+
const h = lastHeaders();
|
|
147
|
+
const abortReason = abort && result && typeof result === "object" && "reason" in result
|
|
148
|
+
? String(result.reason)
|
|
149
|
+
: undefined;
|
|
150
|
+
steps.push({
|
|
151
|
+
name: "block_path",
|
|
152
|
+
selectedRequirements: req,
|
|
153
|
+
abort,
|
|
154
|
+
reason: abortReason,
|
|
155
|
+
decisionEmitted: decisionDetail != null,
|
|
156
|
+
verdict: decisionDetail?.verdict ?? "missing",
|
|
157
|
+
approved: decisionDetail?.approved ?? false,
|
|
158
|
+
hookPayTo: decisionDetail?.payTo,
|
|
159
|
+
preflightSellerWallet: lastSellerWallet(),
|
|
160
|
+
signerInvocations: signerInvocations.n,
|
|
161
|
+
preflightAttribution: {
|
|
162
|
+
integration: h?.get("x-twzrd-integration") ?? null,
|
|
163
|
+
runId: h?.get("x-twzrd-run-id") ?? null,
|
|
164
|
+
client: h?.get("x-twzrd-client") ?? null,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
// ── allow path: decision allow, still no real wallet spend ──────────────
|
|
169
|
+
{
|
|
170
|
+
const signerInvocations = { n: 0 };
|
|
171
|
+
const { fetch, lastHeaders, lastSellerWallet } = recordingPreflightFetch(preflightCard("allow", true));
|
|
172
|
+
const { client, fire } = mockClient();
|
|
173
|
+
let decisionDetail;
|
|
174
|
+
installTwzrdX402ClientHook(client, {
|
|
175
|
+
gateOnCanSpend: true,
|
|
176
|
+
refuseWashFlagged: false,
|
|
177
|
+
preflightMinScore: 40,
|
|
178
|
+
fetch,
|
|
179
|
+
attribution: { integration, runId },
|
|
180
|
+
onDecision: (d) => {
|
|
181
|
+
decisionDetail = {
|
|
182
|
+
approved: d.approved,
|
|
183
|
+
verdict: d.verdict,
|
|
184
|
+
reason: d.reason,
|
|
185
|
+
payTo: d.payTo,
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
const req = baseRequirements("1000");
|
|
190
|
+
const result = await fire({ selectedRequirements: req });
|
|
191
|
+
const abort = Boolean(result && typeof result === "object" && "abort" in result && result.abort);
|
|
192
|
+
// Allow path: payload construction would run next — we do not call a wallet signer
|
|
193
|
+
// in this no_spend harness (proves allow decision without spend).
|
|
194
|
+
void signerInvocations;
|
|
195
|
+
const h = lastHeaders();
|
|
196
|
+
steps.push({
|
|
197
|
+
name: "allow_path",
|
|
198
|
+
selectedRequirements: req,
|
|
199
|
+
abort,
|
|
200
|
+
reason: abort && result && typeof result === "object" && "reason" in result
|
|
201
|
+
? String(result.reason)
|
|
202
|
+
: undefined,
|
|
203
|
+
decisionEmitted: decisionDetail != null,
|
|
204
|
+
verdict: decisionDetail?.verdict ?? "missing",
|
|
205
|
+
approved: decisionDetail?.approved ?? false,
|
|
206
|
+
hookPayTo: decisionDetail?.payTo,
|
|
207
|
+
preflightSellerWallet: lastSellerWallet(),
|
|
208
|
+
signerInvocations: signerInvocations.n,
|
|
209
|
+
preflightAttribution: {
|
|
210
|
+
integration: h?.get("x-twzrd-integration") ?? null,
|
|
211
|
+
runId: h?.get("x-twzrd-run-id") ?? null,
|
|
212
|
+
client: h?.get("x-twzrd-client") ?? null,
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const block = steps.find((s) => s.name === "block_path");
|
|
217
|
+
const allow = steps.find((s) => s.name === "allow_path");
|
|
218
|
+
// Hook-derived only: onDecision.payTo, abort reason, and preflight POST body.
|
|
219
|
+
// Do NOT use step.selectedRequirements (harness-echo) for this flag.
|
|
220
|
+
const blockHookSawSeller = block.hookPayTo === ADOPTION_PROOF_SELLER ||
|
|
221
|
+
(typeof block.reason === "string" && block.reason.includes(ADOPTION_PROOF_SELLER)) ||
|
|
222
|
+
block.preflightSellerWallet === ADOPTION_PROOF_SELLER;
|
|
223
|
+
const allowHookSawSeller = allow.hookPayTo === ADOPTION_PROOF_SELLER ||
|
|
224
|
+
allow.preflightSellerWallet === ADOPTION_PROOF_SELLER;
|
|
225
|
+
const assertions = {
|
|
226
|
+
selectedRequirementReachedHook: blockHookSawSeller && allowHookSawSeller,
|
|
227
|
+
decisionEmitted: block.decisionEmitted && allow.decisionEmitted,
|
|
228
|
+
blockedPathNeverInvokesSigner: block.abort === true && block.signerInvocations === 0,
|
|
229
|
+
allowPathNeverInvokesSigner: allow.signerInvocations === 0 && allow.abort === false,
|
|
230
|
+
attributionSurfaced: block.preflightAttribution.integration === integration &&
|
|
231
|
+
block.preflightAttribution.runId === runId &&
|
|
232
|
+
block.preflightAttribution.client === clientHeader &&
|
|
233
|
+
allow.preflightAttribution.integration === integration &&
|
|
234
|
+
allow.preflightAttribution.runId === runId,
|
|
235
|
+
};
|
|
236
|
+
const ok = Object.values(assertions).every(Boolean);
|
|
237
|
+
return {
|
|
238
|
+
schema: ADOPTION_TRANSCRIPT_SCHEMA,
|
|
239
|
+
package: "twzrd-x402-gate",
|
|
240
|
+
packageVersion: CLIENT_VERSION,
|
|
241
|
+
proofKind: "local_deterministic_harness",
|
|
242
|
+
mode: "no_spend",
|
|
243
|
+
integration,
|
|
244
|
+
runId,
|
|
245
|
+
lineage,
|
|
246
|
+
clientHeader,
|
|
247
|
+
steps,
|
|
248
|
+
assertions,
|
|
249
|
+
ok,
|
|
250
|
+
notExternalRunProof: [
|
|
251
|
+
"package_download_counts",
|
|
252
|
+
"preflight_hits_alone",
|
|
253
|
+
"self_authored_run_id_without_operator_transcript",
|
|
254
|
+
"this_harness_alone_without_server_side_join",
|
|
255
|
+
],
|
|
256
|
+
acceptanceDoc: "docs/strategy/gate-adoption-operator-proof.md",
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/** CLI entry: print one JSON transcript to stdout; exit 0 if ok else 1. */
|
|
260
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
261
|
+
let integration;
|
|
262
|
+
let runId;
|
|
263
|
+
for (let i = 0; i < argv.length; i++) {
|
|
264
|
+
const a = argv[i];
|
|
265
|
+
if (a === "--integration" && argv[i + 1])
|
|
266
|
+
integration = argv[++i];
|
|
267
|
+
else if (a === "--run-id" && argv[i + 1])
|
|
268
|
+
runId = argv[++i];
|
|
269
|
+
else if (a === "--help" || a === "-h") {
|
|
270
|
+
process.stdout.write("Usage: npm run adoption-proof -- [--integration <id>] [--run-id <uuid>]\n" +
|
|
271
|
+
"Deterministic no-spend gate adoption transcript (JSON on stdout).\n" +
|
|
272
|
+
"See docs/strategy/gate-adoption-operator-proof.md\n");
|
|
273
|
+
return 0;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const transcript = await runGateAdoptionProof({ integration, runId });
|
|
277
|
+
process.stdout.write(`${JSON.stringify(transcript, null, 2)}\n`);
|
|
278
|
+
return transcript.ok ? 0 : 1;
|
|
279
|
+
}
|
|
280
|
+
const isDirect = typeof process !== "undefined" &&
|
|
281
|
+
process.argv[1] &&
|
|
282
|
+
(process.argv[1].endsWith("adoption-proof.ts") ||
|
|
283
|
+
process.argv[1].endsWith("adoption-proof.js"));
|
|
284
|
+
if (isDirect) {
|
|
285
|
+
main().then((code) => process.exit(code), (err) => {
|
|
286
|
+
console.error(err);
|
|
287
|
+
process.exit(1);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=adoption-proof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adoption-proof.js","sourceRoot":"","sources":["../src/adoption-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,0BAA0B,GAK3B,MAAM,uBAAuB,CAAC;AAE/B,MAAM,CAAC,MAAM,0BAA0B,GAAG,mCAA4C,CAAC;AAEvF,wEAAwE;AACxE,MAAM,CAAC,MAAM,qBAAqB,GAAG,6CAA6C,CAAC;AACnF,MAAM,CAAC,MAAM,sBAAsB,GAAG,yCAAyC,CAAC;A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AAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAEnD,IAAI,QAAQ,EAAE,CAAC;IACb,IAAI,EAAE,CAAC,IAAI,CACT,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5B,CAAC,GAAG,EAAE,EAAE;QACN,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { CLIENT_VERSION } from "./version.js";
|
|
1
2
|
export { createTwzrdGate, defaultGate, type TwzrdGate } from "./gate.js";
|
|
2
3
|
export { resolveConfig, type ResolvedTwzrdGateConfig } from "./config.js";
|
|
3
4
|
export { evaluateReadinessCard, buildPreflightInput, twzrdPreflight, twzrdApprovePayment, type PolicyEvaluateInput, } from "./policy.js";
|
|
@@ -12,6 +13,7 @@ export { withTwzrdGuard, type TwzrdGuardOptions } from "./with-guard.js";
|
|
|
12
13
|
export { installTwzrdAutoGate, type PayWrap, type InstallAutoGateOptions, } from "./auto-gate.js";
|
|
13
14
|
export { safeFetch, runAgentcashFetch, main as safeFetchMain, type SafeFetchOptions, type SafeFetchResult, } from "./safe-fetch.js";
|
|
14
15
|
export { installTwzrdX402ClientHook, twzrdBeforePaymentCreation, type X402ClientLike, type X402SelectedRequirements, type BeforePaymentCreationContext, type BeforePaymentCreationResult, type InstallX402ClientHookOptions, type X402PaymentControlOptions, } from "./x402-client-hook.js";
|
|
16
|
+
export { runGateAdoptionProof, main as adoptionProofMain, ADOPTION_TRANSCRIPT_SCHEMA, ADOPTION_PROOF_SELLER, ADOPTION_PROOF_NETWORK, ADOPTION_PROOF_RESOURCE, type GateAdoptionTranscript, type GateAdoptionStep, type GateAdoptionAssertions, type GateAdoptionLineage, type RunGateAdoptionProofOptions, } from "./adoption-proof.js";
|
|
15
17
|
export { quickCheck, QUICK_PRICE_USDC, type QuickCheckResult, type QuickCheckOptions, type TwzrdTier, } from "./quick.js";
|
|
16
18
|
export { createSponsoredX402Fetch, type SponsorSettle, type SponsoredX402Options, } from "./sponsored.js";
|
|
17
19
|
export type { TwzrdDecision, TwzrdReadinessCard, TwzrdPreflightInput, TwzrdGateConfig, TwzrdApproveContext, TwzrdApprovalResult, TwzrdUpsellContext, X402PaymentRequirements, X402PaymentRequiredBody, X402McpPaymentRequest, X402McpPaymentRequestedContext, } from "./types.js";
|
|
@@ -21,4 +23,5 @@ export { createMemorySpendLedger, evaluateIntent, POLICY_VERSION, type Counterpa
|
|
|
21
23
|
export { ap2CheckoutToIntent, x402RequirementsToIntent, type Ap2Cart, type Ap2UserMandate, type X402IntentContext, } from "./intent-adapters.js";
|
|
22
24
|
export { createTwzrdMppOnChallenge, mppChallengeToIntent, mppChallengeDigest, NATIVE_SOL_CURRENCY, TwzrdMppBlockError, type MppChallenge, type MppIntentContext, type MppOnChallengeHelpers, type MppOnChallengeOptions, type MppSolanaChargeRequest, } from "./mpp-hook.js";
|
|
23
25
|
export { approvalToIntelligence, counterpartyKnownFromApproval, createTwzrdIntelligenceProvider, intentAmountToPriceUsd, type TwzrdIntelligenceOptions, } from "./intelligence.js";
|
|
26
|
+
export { createTwzrdSettleGuard, defaultExtractPayer, extractSvmPayerFromTransaction, twzrdPayerScreen, toPayaiVerifyResult, type SettleGuardContext, type SettleGuardAbort, type SettleGuardResult, type PayerScreen, type ScreenFn, type GetPayerFn, type SettleGuardOptions, } from "./seller-hook.js";
|
|
24
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["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AAW,EAChB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,kBAAkB,GACxB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// gate.ts also defines a generic-fn wrapper of the same name; re-exporting both here
|
|
3
3
|
// is a duplicate-export collision that esbuild/tsx/Vite reject (tsc silently keeps the
|
|
4
4
|
// last one). The fetch wrapper is the documented public API, so we export only that.
|
|
5
|
+
export { CLIENT_VERSION } from "./version.js";
|
|
5
6
|
export { createTwzrdGate, defaultGate } from "./gate.js";
|
|
6
7
|
export { resolveConfig } from "./config.js";
|
|
7
8
|
export { evaluateReadinessCard, buildPreflightInput, twzrdPreflight, twzrdApprovePayment, } from "./policy.js";
|
|
@@ -15,6 +16,7 @@ export { withTwzrdGuard } from "./with-guard.js";
|
|
|
15
16
|
export { installTwzrdAutoGate, } from "./auto-gate.js";
|
|
16
17
|
export { safeFetch, runAgentcashFetch, main as safeFetchMain, } from "./safe-fetch.js";
|
|
17
18
|
export { installTwzrdX402ClientHook, twzrdBeforePaymentCreation, } from "./x402-client-hook.js";
|
|
19
|
+
export { runGateAdoptionProof, main as adoptionProofMain, ADOPTION_TRANSCRIPT_SCHEMA, ADOPTION_PROOF_SELLER, ADOPTION_PROOF_NETWORK, ADOPTION_PROOF_RESOURCE, } from "./adoption-proof.js";
|
|
18
20
|
export { quickCheck, QUICK_PRICE_USDC, } from "./quick.js";
|
|
19
21
|
export { createSponsoredX402Fetch, } from "./sponsored.js";
|
|
20
22
|
/* ── TWZRD Payment Control (protocol-neutral authorization core) ── */
|
|
@@ -24,4 +26,7 @@ export { createMemorySpendLedger, evaluateIntent, POLICY_VERSION, } from "./poli
|
|
|
24
26
|
export { ap2CheckoutToIntent, x402RequirementsToIntent, } from "./intent-adapters.js";
|
|
25
27
|
export { createTwzrdMppOnChallenge, mppChallengeToIntent, mppChallengeDigest, NATIVE_SOL_CURRENCY, TwzrdMppBlockError, } from "./mpp-hook.js";
|
|
26
28
|
export { approvalToIntelligence, counterpartyKnownFromApproval, createTwzrdIntelligenceProvider, intentAmountToPriceUsd, } from "./intelligence.js";
|
|
29
|
+
// Optional resource-server settle guard (merchant policy on the payer).
|
|
30
|
+
// Core product remains the buyer gate. Attaches to onBeforeSettle; advisory + fail-open.
|
|
31
|
+
export { createTwzrdSettleGuard, defaultExtractPayer, extractSvmPayerFromTransaction, twzrdPayerScreen, toPayaiVerifyResult, } from "./seller-hook.js";
|
|
27
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,qFAAqF;AACrF,uFAAuF;AACvF,qFAAqF;AACrF,OAAO,EAAE,eAAe,EAAE,WAAW,EAAkB,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,aAAa,EAAgC,MAAM,aAAa,CAAC;AAC1E,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,GAEpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,YAAY,GAKb,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GAIvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,sBAAsB,GAGvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAA0B,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,oBAAoB,GAGrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,IAAI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