@daski/pay 0.1.2 → 0.3.0

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.
Files changed (52) hide show
  1. package/README.md +35 -80
  2. package/dist/bin/daski.js +34 -12
  3. package/dist/bin/daski.js.map +1 -1
  4. package/dist/commands/approval.d.ts +52 -0
  5. package/dist/commands/approval.d.ts.map +1 -0
  6. package/dist/commands/approval.js +59 -0
  7. package/dist/commands/approval.js.map +1 -0
  8. package/dist/commands/buy.d.ts +4 -4
  9. package/dist/commands/buy.d.ts.map +1 -1
  10. package/dist/commands/buy.js +50 -67
  11. package/dist/commands/buy.js.map +1 -1
  12. package/dist/commands/confirmation.d.ts +29 -0
  13. package/dist/commands/confirmation.d.ts.map +1 -0
  14. package/dist/commands/confirmation.js +123 -0
  15. package/dist/commands/confirmation.js.map +1 -0
  16. package/dist/commands/doctor.d.ts.map +1 -1
  17. package/dist/commands/doctor.js +27 -2
  18. package/dist/commands/doctor.js.map +1 -1
  19. package/dist/commands/order.d.ts +24 -2
  20. package/dist/commands/order.d.ts.map +1 -1
  21. package/dist/commands/order.js +68 -14
  22. package/dist/commands/order.js.map +1 -1
  23. package/dist/commands/signPayment.d.ts +1 -0
  24. package/dist/commands/signPayment.d.ts.map +1 -1
  25. package/dist/commands/signPayment.js +9 -4
  26. package/dist/commands/signPayment.js.map +1 -1
  27. package/dist/commands/wallet.d.ts.map +1 -1
  28. package/dist/commands/wallet.js +5 -17
  29. package/dist/commands/wallet.js.map +1 -1
  30. package/dist/config.d.ts +15 -11
  31. package/dist/config.d.ts.map +1 -1
  32. package/dist/config.js +59 -33
  33. package/dist/config.js.map +1 -1
  34. package/dist/context.js +2 -2
  35. package/dist/context.js.map +1 -1
  36. package/dist/gateway/client.d.ts +20 -0
  37. package/dist/gateway/client.d.ts.map +1 -1
  38. package/dist/gateway/client.js +55 -0
  39. package/dist/gateway/client.js.map +1 -1
  40. package/dist/gateway/purchase.d.ts +53 -5
  41. package/dist/gateway/purchase.d.ts.map +1 -1
  42. package/dist/gateway/purchase.js +131 -67
  43. package/dist/gateway/purchase.js.map +1 -1
  44. package/dist/index.d.ts +3 -3
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +3 -3
  47. package/dist/index.js.map +1 -1
  48. package/dist/store/orders.d.ts +16 -1
  49. package/dist/store/orders.d.ts.map +1 -1
  50. package/dist/store/orders.js +7 -1
  51. package/dist/store/orders.js.map +1 -1
  52. package/package.json +2 -2
package/README.md CHANGED
@@ -1,101 +1,56 @@
1
- # `@daski/pay`
1
+ # @daski/pay
2
2
 
3
- The Daski buyer bridge. A CLI that buys outcomes, tracks orders across
4
- processes, and refuses to sign anything it has not independently checked.
3
+ The Daski buyer CLI obtains a quote, validates and signs an approved payment, and tracks the order across processes. Wallet keys stay in their protected store.
4
+
5
+ ## Setup and purchase
5
6
 
6
7
  ```bash
7
- npx @daski/pay@0.1.2 doctor --json
8
+ npm install -g @daski/pay@0.3.0
9
+ daski doctor --json
8
10
  ```
9
11
 
10
- > Server proposes; buyer bridge validates against its own expectations and
11
- > recomputes; wallet signs; the gateway never sees the key.
12
-
13
- ## Commands
14
-
15
- | Command | What it does |
16
- |---|---|
17
- | `daski doctor` | Readiness report; exits 0 only when nothing blocks, including one read-only MCP round trip that proves this CLI can read the gateway's results. Every issue carries a remediation |
18
- | `daski wallet create` | Generate a local EOA — interactive human confirmation required |
19
- | `daski wallet address` / `balance` | The active payer address; native + USDC balances |
20
- | `daski buy --provider <id> --outcome <id> --request <file.json>` | Challenge → approve → validate → sign → submit → record |
21
- | `daski order status <handle>` | Read an order's state |
22
- | `daski order artifact <handle>` | Write the result **to a file**, never to stdout |
23
- | `daski order confirm/input/cancel <handle>` | Mutating lifecycle actions |
24
- | `daski sign-payment --challenge <file.json>` | Validate, recompute, sign; print the exact `paymentPayload` |
25
-
26
- All support `--json`. Global flags: `--profile`, `--signer <local|cdp|circle>`,
27
- `--cdp-account`, `--circle-wallet`, `--max-per-order`, `--session-cap`.
28
-
29
- ## Spend caps are yours, not the agent's
30
-
31
- `maxPerOrderUsdc`, `sessionCapUsdc` and `requireApprovalAboveUsdc` live only
32
- in `~/.daski/config.json`. **No flag and no environment variable can raise
33
- them.** `--max-per-order` and `--session-cap` may lower a cap for a single
34
- invocation; a value above the configured one is refused.
35
-
36
- Above `requireApprovalAboveUsdc`, `daski buy` shows the approval summary and
37
- waits for a human. In `--json` or non-TTY mode it does not quietly proceed —
38
- it exits `2` and explains how a human can approve.
12
+ Doctor reports the configured signer, its self-test, native state paths, network, balances, spending settings, and gateway compatibility. Reuse a healthy signer. Create a wallet only if one is missing: `daski wallet create` prompts interactively; authorized agent setup uses `daski wallet create --yes-human-approved`.
39
13
 
40
- The running session total is read from `~/.daski/orders.json`, so the cap
41
- holds across processes rather than resetting whenever an agent restarts.
14
+ Complete the request using gateway discovery and `daski_get_outcome_requirements`, then run:
42
15
 
43
- ## Orders survive the process that placed them
44
-
45
- Every order is recorded in `~/.daski/orders.json` — handle, intent id,
46
- provider/outcome, amount, state, read capability and expiry. `daski order
47
- status` works from a cold start with nothing but the handle.
48
-
49
- The intent is recorded **before** the signature goes out, which is what makes
50
- an interrupted purchase recoverable.
51
-
52
- ## Interrupted purchases are reconciled, never re-signed
53
-
54
- On a timeout, a `PAYMENT_PENDING_RECONCILIATION`, or a transport drop after
55
- submit, the CLI replays the *identical* signed authorization — idempotent by
56
- the gateway's own published retry policy — and corroborates against the
57
- payer's own order history. Only when both agree no order exists does it report
58
- the purchase as safely retryable.
59
-
60
- A second signature over a fresh challenge is a second order, and a second
61
- charge. See [reconciliation](../../docs/policy.md#reconciliation).
16
+ ```bash
17
+ daski buy --provider <id> --outcome <id> --request <file.json> --json
18
+ ```
62
19
 
63
- ## Artifacts are written, not printed
20
+ The command returns the actual quote and an approval identifier. After the user approves, repeat with `--approve <approval.id>`. Interactive use prompts directly. New profiles approve each paid quote and have no extra default budget. Existing settings remain in place on upgrade.
64
21
 
65
- `daski order artifact` writes the provider's bytes to a file and prints only
66
- the envelope metadata. Provider results are validated but untrusted, and both
67
- a terminal and an agent's context window are interpreters: dumping untrusted
68
- content into one is how "here is your result" becomes "here are your
69
- instructions".
22
+ ## Commands
70
23
 
71
- ## Signers
24
+ | Command | Behavior |
25
+ |---|---|
26
+ | `doctor --json` | Diagnose signer, paths, settings, funds, and gateway |
27
+ | `wallet create` | Create a local signer when missing |
28
+ | `wallet address` / `wallet balance` | Read the active payer and balances |
29
+ | `budget [--per-order <usdc\|none>] [--total <usdc\|none>] [--approval-above <usdc>]` | View or explicitly change spending settings |
30
+ | `buy --provider <id> --outcome <id> --request <file.json>` | Quote, approve, validate, sign, submit, and record |
31
+ | `order status <handle>` | Read order state using cached read access or a fresh authorization |
32
+ | `order artifact <handle> [--output <file>]` | Save the provider result to a file |
33
+ | `order input <handle> --request <file.json>` | Submit customer input |
34
+ | `order cancel <handle>` | Request cancellation |
35
+ | `order confirm <handle> --choice <Confirmed\|NotConfirmed>` | Prepare, validate, sign, and submit the user's review |
36
+ | `order revoke-confirmation <handle>` | Withdraw the active review |
37
+ | `order confirm <handle> --resume` | Reconcile the stored review without another EAS signature |
38
+ | `order reconcile <intentId>` | Query settlement for one payment identifier |
39
+ | `sign-payment --challenge <file.json>` | Advanced payment signer; supports the same --approve flow |
72
40
 
73
- `local` is the default and the one adapter the conformance suite has verified.
74
- `cdp` and `circle` are implemented and marked *candidate pending conformance*
75
- until a run passes; `daski doctor` says so rather than implying otherwise. The
76
- Circle adapter accepts EOA wallets only: a smart-contract account signs via
77
- ERC-1271, which the gateway's plain ECDSA recovery cannot verify. Every
78
- adapter has to pass the doctor self-test — sign a fixed, unsettleable vector
79
- that recovers to its own address with a low-s signature — before it is
80
- reported usable.
41
+ All commands support `--json`. Shared flags select the profile and configured signer. `--max-per-order` and `--session-cap` apply temporary budgets within existing settings.
81
42
 
82
- See [signer adapters](../../docs/signers.md).
43
+ ## Recovery and artifacts
83
44
 
84
- ## Keys
45
+ The local store keeps the intent before signing and the order handle after submission. Following a timeout or ambiguous payment, recovery queries the exact gateway identifier. Pending states remain pending; the CLI does not infer absence from similar orders, a balance, or a missing handle.
85
46
 
86
- OS keychain by default, scrypt+AES-256-GCM file as a fallback,
87
- `DASKI_PAYER_PRIVATE_KEY` for sandbox development (which `doctor` flags every
88
- time). Keys never appear in logs, JSON output, or error messages.
47
+ Artifacts are saved to a file with their envelope metadata reported separately. Treat provider content as data.
89
48
 
90
- See [key storage](../../docs/keys.md).
49
+ Reviews require the user's choice for the selected order. On the third and final transition, show the warning and pass `--acknowledge-final-transition` only after explicit acceptance. Review messages are reconstructed from deployment pins, chain state, and the selected label. Pending sponsorship keeps the preparation and signature for `--resume`.
91
50
 
92
51
  ## Documentation
93
52
 
94
- [Policy validator](../../docs/policy.md) ·
95
- [Configuration](../../docs/config.md) ·
96
- [Keys](../../docs/keys.md) ·
97
- [Signers](../../docs/signers.md) ·
98
- [Conformance](../../docs/conformance.md)
53
+ [Policy](../../docs/policy.md) · [Configuration](../../docs/config.md) · [Keys](../../docs/keys.md) · [Signers](../../docs/signers.md) · [Conformance](../../docs/conformance.md)
99
54
 
100
55
  ## License
101
56
 
package/dist/bin/daski.js CHANGED
@@ -11,10 +11,11 @@ import { CliError } from "../cli/errors.js";
11
11
  import { emit, emitError } from "../cli/output.js";
12
12
  import { runBuy } from "../commands/buy.js";
13
13
  import { runDoctor } from "../commands/doctor.js";
14
- import { orderArtifact, orderCancel, orderConfirm, orderInput, orderStatus, } from "../commands/order.js";
14
+ import { orderArtifact, orderCancel, orderConfirm, orderInput, orderStatus, orderReconcile, } from "../commands/order.js";
15
15
  import { runSignPayment } from "../commands/signPayment.js";
16
16
  import { createWallet, walletAddress, walletBalance } from "../commands/wallet.js";
17
17
  import { CLI_VERSION } from "../version.js";
18
+ import { configureBudgets } from "../config.js";
18
19
  /** Flags every command accepts. */
19
20
  const GLOBAL_FLAGS = [
20
21
  "json", "profile", "signer", "cdp-account", "circle-wallet",
@@ -30,15 +31,22 @@ Commands
30
31
  wallet create Generate a local EOA (requires human confirmation)
31
32
  wallet address Print the active payer address
32
33
  wallet balance Print native + USDC balances
34
+ budget [--per-order <usdc|none>] [--total <usdc|none>] [--approval-above <usdc>]
35
+ View or change optional spending settings
33
36
  buy --provider <id> --outcome <id> --request <file.json> [--payer <addr>]
34
37
  Challenge, approve, validate, sign, submit, record
38
+ After quote approval: repeat with --approve <approval.id>
35
39
  order status <handle> Read an order's state
36
40
  order artifact <handle> [--output <file>]
37
41
  Write the result bytes to a file (never to stdout)
38
- order confirm <handle> Confirm delivery
42
+ order confirm <handle> --choice <Confirmed|NotConfirmed>
43
+ Record the user's delivery review
44
+ order revoke-confirmation <handle> Withdraw the active review
45
+ order confirm <handle> --resume Reconcile a pending review submission
39
46
  order input <handle> --request <file.json>
40
47
  Submit requested customer input
41
48
  order cancel <handle> Request cancellation
49
+ order reconcile <handle|intentId> Ask the gateway whether a payment settled; never re-signs
42
50
  sign-payment --challenge <file.json> [--provider <id> --outcome <id>]
43
51
  Validate, recompute, sign; print the paymentPayload
44
52
 
@@ -48,11 +56,11 @@ Global flags
48
56
  --signer <local|cdp|circle> Override the profile's signer
49
57
  --cdp-account <name> CDP account for --signer cdp (or DASKI_CDP_ACCOUNT)
50
58
  --circle-wallet <id> Circle wallet id for --signer circle (or DASKI_CIRCLE_WALLET)
51
- --max-per-order <usdc> Lower the per-order cap for this run only
52
- --session-cap <usdc> Lower the session cap for this run only
59
+ --max-per-order <usdc> Apply a temporary per-order budget
60
+ --session-cap <usdc> Apply a temporary total budget
53
61
 
54
- Caps live in ~/.daski/config.json and are human-owned: a flag may lower one,
55
- never raise it. See https://github.com/daski-io/buyer#readme
62
+ New profiles use quote approval, with optional budgets. Doctor reports the
63
+ active configuration path. See https://github.com/daski-io/buyer#readme
56
64
  `;
57
65
  async function main(argv) {
58
66
  const { command, flags } = parseArgs(argv);
@@ -75,6 +83,12 @@ async function main(argv) {
75
83
  sessionCapUsdc: stringFlag(flags, "session-cap"),
76
84
  };
77
85
  switch (command[0]) {
86
+ case "budget": {
87
+ assertKnownFlags(flags, ["json", "profile", "per-order", "total", "approval-above"]);
88
+ emit(configureBudgets({ profile: shared.profile, perOrder: stringFlag(flags, "per-order"),
89
+ total: stringFlag(flags, "total"), approvalAbove: stringFlag(flags, "approval-above") }), output);
90
+ return 0;
91
+ }
78
92
  case "doctor": {
79
93
  assertKnownFlags(flags, GLOBAL_FLAGS);
80
94
  const report = await runDoctor(shared);
@@ -105,7 +119,7 @@ async function main(argv) {
105
119
  }
106
120
  }
107
121
  case "buy": {
108
- assertKnownFlags(flags, [...GLOBAL_FLAGS, "provider", "outcome", "request", "payer", "legacy-arg", "yes"]);
122
+ assertKnownFlags(flags, [...GLOBAL_FLAGS, "provider", "outcome", "request", "payer", "legacy-arg", "approve"]);
109
123
  const result = await runBuy({
110
124
  ...shared,
111
125
  providerAgentId: requireFlag(flags, "provider"),
@@ -113,7 +127,7 @@ async function main(argv) {
113
127
  requestFile: requireFlag(flags, "request"),
114
128
  payer: stringFlag(flags, "payer"),
115
129
  legacyArg: boolFlag(flags, "legacy-arg"),
116
- yes: boolFlag(flags, "yes"),
130
+ approved: stringFlag(flags, "approve"),
117
131
  json,
118
132
  });
119
133
  emit(result, output);
@@ -139,8 +153,11 @@ async function main(argv) {
139
153
  emit(await orderArtifact({ ...base, output: stringFlag(flags, "output") }), output);
140
154
  return 0;
141
155
  case "confirm":
142
- assertKnownFlags(flags, GLOBAL_FLAGS);
143
- emit(await orderConfirm(base), output);
156
+ case "revoke-confirmation":
157
+ assertKnownFlags(flags, [...GLOBAL_FLAGS, "choice", "resume", "acknowledge-final-transition"]);
158
+ emit(await orderConfirm({ ...base, confirmation: stringFlag(flags, "choice"),
159
+ revoke: command[1] === "revoke-confirmation", resume: boolFlag(flags, "resume"),
160
+ acknowledgeFinalTransition: boolFlag(flags, "acknowledge-final-transition") }), output);
144
161
  return 0;
145
162
  case "cancel":
146
163
  assertKnownFlags(flags, GLOBAL_FLAGS);
@@ -150,17 +167,22 @@ async function main(argv) {
150
167
  assertKnownFlags(flags, [...GLOBAL_FLAGS, "request"]);
151
168
  emit(await orderInput({ ...base, requestFile: requireFlag(flags, "request") }), output);
152
169
  return 0;
170
+ case "reconcile":
171
+ assertKnownFlags(flags, GLOBAL_FLAGS);
172
+ emit(await orderReconcile(base), output);
173
+ return 0;
153
174
  default:
154
- throw unknownSubcommand("order", command[1], ["status", "artifact", "confirm", "input", "cancel"]);
175
+ throw unknownSubcommand("order", command[1], ["status", "artifact", "confirm", "revoke-confirmation", "input", "cancel", "reconcile"]);
155
176
  }
156
177
  }
157
178
  case "sign-payment": {
158
- assertKnownFlags(flags, [...GLOBAL_FLAGS, "challenge", "provider", "outcome"]);
179
+ assertKnownFlags(flags, [...GLOBAL_FLAGS, "challenge", "provider", "outcome", "approve"]);
159
180
  emit(await runSignPayment({
160
181
  ...shared,
161
182
  challengeFile: requireFlag(flags, "challenge"),
162
183
  providerAgentId: stringFlag(flags, "provider"),
163
184
  outcomeId: stringFlag(flags, "outcome"),
185
+ approved: stringFlag(flags, "approve"),
164
186
  json,
165
187
  }), output);
166
188
  return 0;
@@ -1 +1 @@
1
- {"version":3,"file":"daski.js","sourceRoot":"","sources":["../../src/bin/daski.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AACH,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EACL,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,GAClE,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EA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,CAAC;gBACtC,IAAI;aACL,CAAC,EAAE,MAAM,CAAC,CAAC;YACZ,OAAO,CAAC,CAAC;QACX,CAAC;QAED;YACE,MAAM,IAAI,QAAQ,CAAC;gBACjB,IAAI,EAAE,uBAAuB;gBAC7B,OAAO,EAAE,oBAAoB,OAAO,CAAC,CAAC,CAAC,IAAI;gBAC3C,WAAW,EAAE,iDAAiD;aAC/D,CAAC,CAAC;IACP,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa,EAAE,KAAyB,EAAE,KAAe;IAClF,OAAO,IAAI,QAAQ,CAAC;QAClB,IAAI,EAAE,0BAA0B;QAChC,OAAO,EAAE,mBAAmB,KAAK,kBAAkB,KAAK,IAAI,QAAQ,EAAE;QACtE,WAAW,EAAE,eAAe,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,KAAK,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;KACvF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC7C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACxB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;KAC5C,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { type OrderBinding } from "@daski/x402-scheme";
2
+ import type { PaymentRequirement } from "../gateway/client.js";
3
+ /** Approval survives quote expiry only while all purchase terms stay the same. */
4
+ export declare function purchaseApproval(args: {
5
+ gatewayUrl: string;
6
+ payer: string;
7
+ providerAgentId: string;
8
+ outcomeId: string;
9
+ requirement: PaymentRequirement;
10
+ binding: OrderBinding;
11
+ purchaseNumber?: number;
12
+ }): {
13
+ gateway: string;
14
+ payer: `0x${string}`;
15
+ providerAgentId: string;
16
+ outcomeId: string;
17
+ network: string;
18
+ token: `0x${string}`;
19
+ payTo: `0x${string}`;
20
+ amount: string;
21
+ requestHash: `0x${string}`;
22
+ listing: `0x${string}`;
23
+ providerTerms: `0x${string}`;
24
+ id: `0x${string}`;
25
+ termsHash: `0x${string}`;
26
+ purchaseNumber: number;
27
+ };
28
+ /** A consumed approval cannot authorize another purchase with identical terms. */
29
+ export declare function nextPurchaseApproval(args: Parameters<typeof purchaseApproval>[0], profile: string): {
30
+ gateway: string;
31
+ payer: `0x${string}`;
32
+ providerAgentId: string;
33
+ outcomeId: string;
34
+ network: string;
35
+ token: `0x${string}`;
36
+ payTo: `0x${string}`;
37
+ amount: string;
38
+ requestHash: `0x${string}`;
39
+ listing: `0x${string}`;
40
+ providerTerms: `0x${string}`;
41
+ id: `0x${string}`;
42
+ termsHash: `0x${string}`;
43
+ purchaseNumber: number;
44
+ };
45
+ export declare function approvePurchase(args: {
46
+ approval: ReturnType<typeof purchaseApproval>;
47
+ approved?: string | undefined;
48
+ threshold: string;
49
+ json: boolean;
50
+ summary?: unknown;
51
+ }): Promise<void>;
52
+ //# sourceMappingURL=approval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../src/commands/approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMlF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAC9E,WAAW,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,YAAY,CAAC;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;;;;;;;;;;;;;;;EAcA;AAED,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;EASjG;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,QAAQ,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7E,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CACrD,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhB"}
@@ -0,0 +1,59 @@
1
+ import { canonicalHash, formatUsdc } from "@daski/x402-scheme";
2
+ import { getAddress } from "viem";
3
+ import { atomicUsdc } from "../config.js";
4
+ import { CliError } from "../cli/errors.js";
5
+ import { confirm, isInteractive } from "../cli/prompt.js";
6
+ import { note } from "../cli/output.js";
7
+ import { isUnspent, listOrders } from "../store/orders.js";
8
+ /** Approval survives quote expiry only while all purchase terms stay the same. */
9
+ export function purchaseApproval(args) {
10
+ const binding = args.binding;
11
+ const terms = {
12
+ gateway: args.gatewayUrl.replace(/\/$/, ""), payer: getAddress(args.payer),
13
+ providerAgentId: args.providerAgentId, outcomeId: args.outcomeId,
14
+ network: args.requirement.network, token: getAddress(args.requirement.asset),
15
+ payTo: getAddress(args.requirement.payTo), amount: BigInt(args.requirement.amount).toString(),
16
+ requestHash: binding.canonicalRequestHash,
17
+ listing: binding.version === 2 ? binding.runtimeCommitmentHash : binding.listingManifestHash,
18
+ providerTerms: binding.version === 2 ? binding.providerIntentHash : binding.providerOfferHash,
19
+ };
20
+ const termsHash = canonicalHash(terms);
21
+ const purchaseNumber = args.purchaseNumber ?? 1;
22
+ return { id: canonicalHash({ termsHash, purchaseNumber }), termsHash, purchaseNumber, ...terms };
23
+ }
24
+ /** A consumed approval cannot authorize another purchase with identical terms. */
25
+ export function nextPurchaseApproval(args, profile) {
26
+ const first = purchaseApproval(args);
27
+ const prior = listOrders(profile).filter((order) => order.approvalTermsHash === first.termsHash && !isUnspent(order));
28
+ const pending = prior.find((order) => ["AUTHORIZED", "SUBMITTED", "PENDING_RECONCILIATION"].includes(order.state));
29
+ if (pending)
30
+ throw new CliError({ code: "DASKI_PAYMENT_PENDING_RECONCILIATION",
31
+ message: "This purchase already has an authorized or pending order.",
32
+ remediation: `Continue with daski order reconcile ${pending.intentId}.`,
33
+ details: { intentId: pending.intentId, orderHandle: pending.handle ?? null } });
34
+ return purchaseApproval({ ...args, purchaseNumber: prior.length + 1 });
35
+ }
36
+ export async function approvePurchase(args) {
37
+ if (args.approved !== undefined) {
38
+ if (args.approved === args.approval.id)
39
+ return;
40
+ throw new CliError({ code: "DASKI_QUOTE_CHANGED",
41
+ message: "The quote or purchase differs from the approved one.",
42
+ remediation: "Show the new quote to the user, then pass its approval.id with --approve.",
43
+ details: { approval: args.approval, approvalSummary: args.summary }, exitCode: 2 });
44
+ }
45
+ if (BigInt(args.approval.amount) <= atomicUsdc(args.threshold))
46
+ return;
47
+ if (args.json || !isInteractive()) {
48
+ throw new CliError({ code: "DASKI_HUMAN_APPROVAL_REQUIRED",
49
+ message: `Approve this purchase for ${formatUsdc(BigInt(args.approval.amount))}.`,
50
+ remediation: "Show the quote to the user. After approval, repeat the command with --approve <approval.id>.",
51
+ details: { approval: args.approval, approvalSummary: args.summary }, exitCode: 2 });
52
+ }
53
+ note(JSON.stringify(args.summary ?? args.approval, null, 2));
54
+ if (!await confirm(`Pay ${formatUsdc(BigInt(args.approval.amount))} on ${args.approval.network}?`)) {
55
+ throw new CliError({ code: "DASKI_PURCHASE_DECLINED", message: "The purchase was declined.",
56
+ remediation: "Run the command again when ready.", exitCode: 2 });
57
+ }
58
+ }
59
+ //# sourceMappingURL=approval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.js","sourceRoot":"","sources":["../../src/commands/approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAqB,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE3D,kFAAkF;AAClF,MAAM,UAAU,gBAAgB,CAAC,IAIhC;IACC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC7B,MAAM,KAAK,GAAG;QACZ,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;QAC1E,eAAe,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS;QAChE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAC5E,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;QAC7F,WAAW,EAAE,OAAO,CAAC,oBAAoB;QACzC,OAAO,EAAE,OAAO,CAAC,OAAO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AC,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,OAAO,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;QACnG,MAAM,IAAI,QAAQ,CAAC,EAAE,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,4BAA4B;YACzF,WAAW,EAAE,mCAAmC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC;AACH,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { PolicyRefusal } from "@daski/x402-scheme";
2
- import { type ContextOptions } from "../context.js";
2
+ import { type ContextOptions, type CommandContext } from "../context.js";
3
3
  export interface BuyOptions extends ContextOptions {
4
4
  providerAgentId: string;
5
5
  outcomeId: string;
@@ -7,9 +7,9 @@ export interface BuyOptions extends ContextOptions {
7
7
  payer?: string | undefined;
8
8
  json: boolean;
9
9
  legacyArg?: boolean;
10
- /** Skips only the interactive prompt, never the policy validator. */
11
- yes?: boolean;
10
+ /** The identifier of the quote the user approved. */
11
+ approved?: string | undefined;
12
12
  }
13
- export declare function runBuy(options: BuyOptions): Promise<Record<string, unknown>>;
13
+ export declare function runBuy(options: BuyOptions, contextFactory?: (options: ContextOptions) => Promise<CommandContext>): Promise<Record<string, unknown>>;
14
14
  export { PolicyRefusal };
15
15
  //# sourceMappingURL=buy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buy.d.ts","sourceRoot":"","sources":["../../src/commands/buy.ts"],"names":[],"mappings":"AAQA,OAAO,EAAc,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAK/D,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAYnE,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,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