@wasit-dev/core 0.7.0 → 0.8.0-beta.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.
Files changed (88) hide show
  1. package/README.md +13 -2
  2. package/dist/baseline.d.ts +109 -0
  3. package/dist/baseline.js +353 -0
  4. package/dist/catalogue.js +10 -0
  5. package/dist/check.d.ts +57 -2
  6. package/dist/check.js +46 -6
  7. package/dist/ci-report.d.ts +74 -0
  8. package/dist/ci-report.js +399 -0
  9. package/dist/config-writer.d.ts +96 -0
  10. package/dist/config-writer.js +281 -0
  11. package/dist/config.d.ts +205 -0
  12. package/dist/config.js +1011 -0
  13. package/dist/denied-env.d.ts +33 -0
  14. package/dist/denied-env.js +86 -0
  15. package/dist/errors.d.ts +44 -1
  16. package/dist/errors.js +151 -2
  17. package/dist/guard/budget.d.ts +138 -0
  18. package/dist/guard/budget.js +206 -0
  19. package/dist/guard/ci-event.d.ts +56 -0
  20. package/dist/guard/ci-event.js +129 -0
  21. package/dist/guard/ci-mainnet.d.ts +59 -0
  22. package/dist/guard/ci-mainnet.js +149 -0
  23. package/dist/guard/horizon.d.ts +30 -0
  24. package/dist/guard/horizon.js +107 -0
  25. package/dist/guard/mainnet-payer.d.ts +66 -0
  26. package/dist/guard/mainnet-payer.js +92 -0
  27. package/dist/guard/mainnet-plan.d.ts +133 -0
  28. package/dist/guard/mainnet-plan.js +208 -0
  29. package/dist/guard/mainnet-run.d.ts +87 -0
  30. package/dist/guard/mainnet-run.js +225 -0
  31. package/dist/guard/networks.d.ts +51 -0
  32. package/dist/guard/networks.js +91 -0
  33. package/dist/guard/optin.d.ts +106 -0
  34. package/dist/guard/optin.js +202 -0
  35. package/dist/guard/rpc-identity.d.ts +45 -0
  36. package/dist/guard/rpc-identity.js +156 -0
  37. package/dist/guard/rpc-in-use.d.ts +48 -0
  38. package/dist/guard/rpc-in-use.js +84 -0
  39. package/dist/guard/run-ledger.d.ts +212 -0
  40. package/dist/guard/run-ledger.js +426 -0
  41. package/dist/guard/run-lock.d.ts +62 -0
  42. package/dist/guard/run-lock.js +172 -0
  43. package/dist/guard/signed-terms.d.ts +96 -0
  44. package/dist/guard/signed-terms.js +207 -0
  45. package/dist/index.d.ts +44 -4
  46. package/dist/index.js +42 -2
  47. package/dist/mpp/channel-commitment.d.ts +48 -2
  48. package/dist/mpp/channel-commitment.js +80 -4
  49. package/dist/mpp/channel-credential.d.ts +13 -1
  50. package/dist/mpp/channel-credential.js +21 -2
  51. package/dist/mpp/channel.d.ts +6 -0
  52. package/dist/mpp/channel.js +36 -3
  53. package/dist/mpp/charge.d.ts +33 -1
  54. package/dist/mpp/charge.js +90 -20
  55. package/dist/mpp/network.js +4 -1
  56. package/dist/mpp/plan.d.ts +77 -0
  57. package/dist/mpp/plan.js +188 -0
  58. package/dist/mpp/suite.d.ts +6 -0
  59. package/dist/mpp/suite.js +12 -3
  60. package/dist/report.d.ts +163 -0
  61. package/dist/report.js +282 -0
  62. package/dist/route-reader.d.ts +124 -0
  63. package/dist/route-reader.js +349 -0
  64. package/dist/sanitize.d.ts +52 -0
  65. package/dist/sanitize.js +106 -0
  66. package/dist/settlement.d.ts +14 -0
  67. package/dist/settlement.js +1 -1
  68. package/dist/verdict.d.ts +24 -0
  69. package/dist/verdict.js +46 -0
  70. package/dist/versions.d.ts +50 -0
  71. package/dist/versions.js +123 -0
  72. package/dist/wallet.d.ts +58 -1
  73. package/dist/wallet.js +128 -0
  74. package/dist/x402/chains/evm.js +3 -0
  75. package/dist/x402/chains/index.d.ts +8 -0
  76. package/dist/x402/chains/index.js +13 -2
  77. package/dist/x402/chains/stellar.d.ts +8 -1
  78. package/dist/x402/chains/stellar.js +259 -4
  79. package/dist/x402/chains/types.d.ts +104 -2
  80. package/dist/x402/plan.d.ts +184 -0
  81. package/dist/x402/plan.js +520 -0
  82. package/dist/x402/rejected-request.d.ts +156 -0
  83. package/dist/x402/rejected-request.js +287 -0
  84. package/dist/x402/requirements.d.ts +1 -0
  85. package/dist/x402/requirements.js +37 -4
  86. package/dist/x402/simulator.d.ts +86 -1
  87. package/dist/x402/simulator.js +863 -87
  88. package/package.json +1 -1
package/dist/report.js ADDED
@@ -0,0 +1,282 @@
1
+ /**
2
+ * The run report: what `wasit run` produces for the CLI's `--json`, the Action
3
+ * and the pull request comment, one shape (spec A2).
4
+ *
5
+ * The central rule is the endpoint outcome. An endpoint counts as graded only
6
+ * when it is `conformant` or `non-conformant` (spec A8 #3, D-021). A service
7
+ * Wasit cannot grade is `unsupported`; one that gave no verdict is
8
+ * `no-verdict`. Neither is a FAIL, and neither is a pass: the totals say how
9
+ * many endpoints were graded, so a run where nothing was cannot be read as
10
+ * green.
11
+ */
12
+ import { catalogueEntry } from "./catalogue.js";
13
+ import { checkStatus, skipped, summarize, toStructuredRun, } from "./check.js";
14
+ import { networkClass } from "./guard/networks.js";
15
+ import { sanitizeText } from "./sanitize.js";
16
+ /** The group whose result decides whether an endpoint can be graded at all. */
17
+ const GATING_GROUP = {
18
+ x402: "challenge",
19
+ "mpp-charge": "mppCharge",
20
+ "mpp-channel": "mppChannel",
21
+ };
22
+ /**
23
+ * The group of a check id. X402-01..05 read the challenge, X402-06..10 pay;
24
+ * the MPP checks follow their mode. An id with no catalogue entry (PREFLIGHT)
25
+ * belongs to the group of the endpoint it was raised for.
26
+ */
27
+ export function checkGroup(id, protocol) {
28
+ const entry = catalogueEntry(id);
29
+ if (entry === undefined)
30
+ return GATING_GROUP[protocol];
31
+ if (entry.protocol === "x402")
32
+ return Number(id.slice("X402-".length)) <= 5 ? "challenge" : "payment";
33
+ return GATING_GROUP[entry.protocol];
34
+ }
35
+ /**
36
+ * True when an x402 payment check (X402-06..11) was skipped as `unsupported`:
37
+ * the run asked to pay and Wasit cannot pay on that network. A read-only or
38
+ * no-payer skip is not this, and neither is a result of another protocol. An MPP
39
+ * endpoint has no group besides its gating one, so for it this is always false.
40
+ * Works on the results of a fresh run and on the structured results of a report.
41
+ */
42
+ export function paymentGroupUnsupported(results, protocol) {
43
+ return protocol === "x402" && results.some((result) => result.skipKind === "unsupported" && checkGroup(result.id, protocol) === "payment");
44
+ }
45
+ /**
46
+ * The outcome of one endpoint from its results.
47
+ *
48
+ * - any FAIL: `non-conformant`. A real finding outranks a missing one.
49
+ * - else an `unsupported` skip in the endpoint's gating group (the challenge
50
+ * checks for x402): `unsupported`. X402-01 may have passed on an x402 v1
51
+ * service; one passing check does not grade a paywall Wasit cannot read. An
52
+ * `unsupported` payment group alone does not make the endpoint unsupported:
53
+ * the challenge was graded.
54
+ * - else an `unsupported` skip in the payment group (payment checks were asked
55
+ * for and none could be graded on this network): `no-verdict`, so it is not
56
+ * green (Najmi, 2026-11-15).
57
+ * - else any ERROR: `no-verdict`.
58
+ * - else at least one PASS: `conformant`.
59
+ * - else (nothing ran, or everything was skipped): `no-verdict`.
60
+ */
61
+ export function endpointOutcome(results, protocol) {
62
+ const gating = GATING_GROUP[protocol];
63
+ let passed = 0;
64
+ let errored = 0;
65
+ let unsupported = false;
66
+ for (const result of results) {
67
+ const status = checkStatus(result);
68
+ if (status === "FAIL")
69
+ return "non-conformant";
70
+ if (status === "PASS")
71
+ passed += 1;
72
+ else if (status === "ERROR")
73
+ errored += 1;
74
+ else if (result.skipKind === "unsupported" && checkGroup(result.id, protocol) === gating)
75
+ unsupported = true;
76
+ }
77
+ if (unsupported)
78
+ return "unsupported";
79
+ // Payment checks were asked for and none could be graded here (a typo in the network, a chain
80
+ // with no adapter): the challenge was graded, but the run did not do what it was asked.
81
+ // Najmi, 2026-11-15: not green, exit 2, like 0.7.0.
82
+ if (paymentGroupUnsupported(results, protocol))
83
+ return "no-verdict";
84
+ if (errored > 0)
85
+ return "no-verdict";
86
+ return passed > 0 ? "conformant" : "no-verdict";
87
+ }
88
+ /** The key a protocol's payment group needs, for the words of a skip reason. */
89
+ const KEY_LABEL = {
90
+ x402: "a payer key",
91
+ "mpp-charge": "a payer key",
92
+ "mpp-channel": "a commitment key",
93
+ };
94
+ /** The checks of a protocol that pay or sign. MPP-13 closes a channel for good and is never listed. */
95
+ const PAYMENT_CHECK_IDS = {
96
+ x402: ["X402-06", "X402-07", "X402-08", "X402-09", "X402-10", "X402-11"],
97
+ "mpp-charge": ["MPP-01"],
98
+ "mpp-channel": ["MPP-10", "MPP-11", "MPP-12", "MPP-14"],
99
+ };
100
+ /**
101
+ * The checks of an endpoint that pay or sign, as SKIPs the report can count and
102
+ * name (spec A2: the report says which checks need a payer).
103
+ *
104
+ * `read-only`: the run was asked not to pay. `needs-payer`: the run could have
105
+ * paid and had no key. The names come from the catalogue, so a rename there is
106
+ * the only place to change.
107
+ */
108
+ export function skippedPaymentChecks(protocol, kind) {
109
+ const key = KEY_LABEL[protocol];
110
+ const reason = kind === "read-only"
111
+ ? `the read-only tier makes no payment and signs nothing; this check needs ${key} and the payment tier`
112
+ : `this check pays or signs and no ${key.replace(/^a /, "")} was given`;
113
+ return PAYMENT_CHECK_IDS[protocol].map((id) => skipped(id, catalogueEntry(id)?.name ?? id, reason, kind));
114
+ }
115
+ /**
116
+ * The same checks, skipped with a reason the caller words: the run asked to pay
117
+ * and a rule of the run stopped it (the GitHub event, `operatedByMe`, a key
118
+ * variable that is not set), or the front end does not run them.
119
+ */
120
+ export function paymentChecksSkipped(protocol, kind, reason) {
121
+ return PAYMENT_CHECK_IDS[protocol].map((id) => skipped(id, catalogueEntry(id)?.name ?? id, reason, kind));
122
+ }
123
+ /**
124
+ * The exit code of one endpoint's checks (spec A8 #3, D-021): 1 on any FAIL; 2
125
+ * when the endpoint was not graded (`unsupported` or `no-verdict`) or a check
126
+ * could not run; else 0. Used where there is one endpoint, `wasit test` and the
127
+ * MCP x402 tool; a run of several endpoints uses {@link runExitCode}.
128
+ */
129
+ export function exitCodeForEndpoint(results, protocol) {
130
+ const base = summarize([...results]).exitCode;
131
+ if (base !== 0)
132
+ return base;
133
+ const outcome = endpointOutcome(results, protocol);
134
+ return outcome === "unsupported" || outcome === "no-verdict" ? 2 : 0;
135
+ }
136
+ /**
137
+ * `toStructuredRun` with the outcome the exit rule gives: a service that was
138
+ * never graded is `no-verdict`, never `conformant`, for the MCP agent as for the
139
+ * shell. The counts are the same.
140
+ */
141
+ export function toGradedRun(results, protocol) {
142
+ const run = toStructuredRun([...results]);
143
+ const code = exitCodeForEndpoint(results, protocol);
144
+ const outcome = code === 0 ? "conformant" : code === 1 ? "non-conformant" : "no-verdict";
145
+ return { ...run, outcome };
146
+ }
147
+ function reasonFor(results, protocol, outcome) {
148
+ if (outcome === "unsupported") {
149
+ const skip = results.find((result) => result.skipKind === "unsupported" && checkGroup(result.id, protocol) === GATING_GROUP[protocol]);
150
+ return skip?.skipReason === undefined ? undefined : sanitizeText(skip.skipReason);
151
+ }
152
+ if (outcome === "no-verdict") {
153
+ const error = results.find((result) => checkStatus(result) === "ERROR");
154
+ if (error !== undefined)
155
+ return sanitizeText(error.error?.message ?? "a check could not run");
156
+ const unsupportedPayment = results.find((result) => result.skipKind === "unsupported" && paymentGroupUnsupported([result], protocol));
157
+ if (unsupportedPayment?.skipReason !== undefined)
158
+ return sanitizeText(unsupportedPayment.skipReason);
159
+ // Skipped only because the run was asked not to pay: say so, not "nothing ran".
160
+ const readOnly = results.find((result) => result.skipKind === "read-only");
161
+ if (readOnly?.skipReason !== undefined)
162
+ return sanitizeText(readOnly.skipReason);
163
+ return "no check passed: every check was skipped or none ran";
164
+ }
165
+ return undefined;
166
+ }
167
+ /**
168
+ * Counts per group from any list of results that have an id and a status: the
169
+ * CheckResults of a fresh run, or the structured results of a report read back.
170
+ */
171
+ export function groupCounts(results, protocol) {
172
+ const counts = new Map();
173
+ for (const result of results) {
174
+ const group = checkGroup(result.id, protocol);
175
+ const entry = counts.get(group) ?? { passed: 0, failed: 0, errored: 0, skipped: 0 };
176
+ if (result.status === "PASS")
177
+ entry.passed += 1;
178
+ else if (result.status === "FAIL")
179
+ entry.failed += 1;
180
+ else if (result.status === "ERROR")
181
+ entry.errored += 1;
182
+ else
183
+ entry.skipped += 1;
184
+ counts.set(group, entry);
185
+ }
186
+ return Object.fromEntries(counts);
187
+ }
188
+ /** Builds the report of one endpoint. Every text in it has passed through the sanitiser. */
189
+ export function buildEndpointReport(input) {
190
+ const outcome = endpointOutcome(input.results, input.protocol);
191
+ const reason = reasonFor(input.results, input.protocol, outcome);
192
+ return {
193
+ name: sanitizeText(input.name),
194
+ protocol: input.protocol,
195
+ method: sanitizeText(input.method),
196
+ path: sanitizeText(input.path),
197
+ outcome,
198
+ ...(reason === undefined ? {} : { reason }),
199
+ groups: groupCounts(input.results.map((result) => ({ id: result.id, status: checkStatus(result) })), input.protocol),
200
+ results: toStructuredRun([...input.results]).results,
201
+ };
202
+ }
203
+ export function reportTotals(endpoints) {
204
+ const count = (outcome) => endpoints.filter((endpoint) => endpoint.outcome === outcome).length;
205
+ const conformant = count("conformant");
206
+ const nonConformant = count("non-conformant");
207
+ return {
208
+ endpoints: endpoints.length,
209
+ graded: conformant + nonConformant,
210
+ conformant,
211
+ nonConformant,
212
+ noVerdict: count("no-verdict"),
213
+ unsupported: count("unsupported"),
214
+ };
215
+ }
216
+ /**
217
+ * The summary line: "0 graded, 1 unsupported". Says how many endpoints were
218
+ * graded first, so a run in which nothing was cannot be read as a pass.
219
+ */
220
+ export function describeTotals(totals) {
221
+ return [
222
+ `${totals.graded} graded${totals.nonConformant > 0 ? ` (${totals.nonConformant} non-conformant)` : ""}`,
223
+ ...(totals.unsupported > 0 ? [`${totals.unsupported} unsupported`] : []),
224
+ ...(totals.noVerdict > 0 ? [`${totals.noVerdict} no verdict`] : []),
225
+ ].join(", ");
226
+ }
227
+ /** Builds the run report. Pure: the clock and the installed versions are inputs. */
228
+ export function buildRunReport(input) {
229
+ return {
230
+ schema: 1,
231
+ wasit: input.versions.wasit,
232
+ sdk: input.versions.sdk,
233
+ environment: sanitizeText(input.environment),
234
+ network: sanitizeText(input.network),
235
+ networkClass: networkClass(input.network),
236
+ startedAt: input.startedAt,
237
+ endpoints: input.endpoints,
238
+ totals: reportTotals(input.endpoints),
239
+ notes: (input.notes ?? []).map((note) => sanitizeText(note)),
240
+ };
241
+ }
242
+ /** The keys whose value is a short quote of what the service sent. */
243
+ const SHORT_VALUE_KEYS = new Set(["expected", "actual"]);
244
+ /** The longest `expected` or `actual` in an output. */
245
+ const SHORT_VALUE_MAX = 200;
246
+ function clipValue(text) {
247
+ const characters = Array.from(text);
248
+ return characters.length <= SHORT_VALUE_MAX ? text : `${characters.slice(0, SHORT_VALUE_MAX - 1).join("")}…`;
249
+ }
250
+ /**
251
+ * Applies `change` to every string in a JSON-shaped value; numbers, booleans and
252
+ * null stay. The string under an `expected` or `actual` key is changed first and
253
+ * cut to {@link SHORT_VALUE_MAX} after: a cut made before the secrets are removed
254
+ * could leave the start of one in the output.
255
+ */
256
+ function mapStrings(value, change) {
257
+ if (typeof value === "string")
258
+ return change(value);
259
+ if (Array.isArray(value))
260
+ return value.map((item) => mapStrings(item, change));
261
+ if (typeof value === "object" && value !== null) {
262
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
263
+ key,
264
+ typeof item === "string" && SHORT_VALUE_KEYS.has(key) ? clipValue(change(item)) : mapStrings(item, change),
265
+ ]));
266
+ }
267
+ return value;
268
+ }
269
+ /**
270
+ * A copy of a JSON-shaped value with `secrets` removed from every string in it
271
+ * (and control characters, `::` lines and Stellar keys dealt with, as
272
+ * everywhere), and every `expected` and `actual` cut to a short length. The
273
+ * report is built from text a service sent, and a service can echo a header it
274
+ * was sent; this is the last pass before it is printed or written.
275
+ */
276
+ export function redactValue(value, secrets) {
277
+ return mapStrings(value, (text) => sanitizeText(text, { redact: secrets }));
278
+ }
279
+ /** {@link redactValue} for a run report. */
280
+ export function redactReport(report, secrets) {
281
+ return redactValue(report, secrets);
282
+ }
@@ -0,0 +1,124 @@
1
+ /**
2
+ * What `wasit init` reads from a route (spec C2, C7 row 4; W3-2 slice 3).
3
+ *
4
+ * One unpaid request with the method and body the route takes: no payment,
5
+ * no signature, no key. A redirect is followed once inside the origin, and
6
+ * only when it keeps the request, the rule of the unpaid request a payment
7
+ * check reads (`fetchPaymentChallenge`, spec A8 row 5); any other redirect is
8
+ * reported and nothing is sent to its Location. The answer is data: read,
9
+ * never followed or run (rule 3). What a message takes from it passes through
10
+ * the sanitiser (A8 row 6), on one line and bounded; what the config takes
11
+ * from it is held to the config's own rules before it is written.
12
+ *
13
+ * Reading. A `PAYMENT-REQUIRED` header (or `X-Payment`, which the read checks
14
+ * also accept) is x402, one offer per payment option. A `WWW-Authenticate`
15
+ * header with `Payment` challenges is MPP: the intent tells charge from
16
+ * channel, and a channel challenge names its channel. MPP's network is read
17
+ * the way the Stellar MPP client reads it, so a challenge that names none is
18
+ * stellar:testnet (`@stellar/mpp` 0.7.1 `resolveNetworkId`,
19
+ * dist/shared/validation.js; the charge and the channel client both call it).
20
+ * An x402 v1 challenge in the body is reported as v1.
21
+ *
22
+ * Choosing. init writes one protocol on one network per route, and only what
23
+ * is certain (Najmi, 2026-11-15): with several ways to pay on test networks
24
+ * and no flag to choose, it does not choose; a network that is mainnet or
25
+ * that Wasit does not know is not written in this version.
26
+ */
27
+ import type { PinConfig } from "./config.js";
28
+ import { type RequestShape } from "./x402/simulator.js";
29
+ /** How long init waits for the route's answer. */
30
+ export declare const ROUTE_READ_TIMEOUT_MS = 15000;
31
+ export type RouteProtocol = "x402" | "mpp-charge" | "mpp-channel";
32
+ /** One way the route asks to be paid, as its challenge writes it. Every value is the service's: not trusted. */
33
+ export interface RouteOffer {
34
+ readonly protocol: RouteProtocol;
35
+ /** A CAIP-2 id, as the challenge names it; MPP: as the Stellar MPP client reads it. */
36
+ readonly network: string;
37
+ /** False for an MPP challenge that names no network (read as stellar:testnet). */
38
+ readonly networkNamed: boolean;
39
+ /** The price in base units. */
40
+ readonly amount?: string;
41
+ /** x402 `asset`; MPP charge `currency`. */
42
+ readonly asset?: string;
43
+ /** x402 `payTo`; MPP charge `recipient`. */
44
+ readonly payTo?: string;
45
+ /** MPP channel: the channel contract it bills through. */
46
+ readonly channel?: string;
47
+ }
48
+ /** What the route answered. `url` is where the answer came from: the route's own URL, or the one redirect inside its origin. */
49
+ export type RouteReading = {
50
+ readonly kind: "challenge";
51
+ readonly url: string;
52
+ readonly offers: readonly RouteOffer[];
53
+ readonly notes: readonly string[];
54
+ } | {
55
+ readonly kind: "x402-v1";
56
+ readonly url: string;
57
+ } | {
58
+ readonly kind: "unreadable";
59
+ readonly url: string;
60
+ readonly notes: readonly string[];
61
+ } | {
62
+ readonly kind: "status";
63
+ readonly url: string;
64
+ readonly status: number;
65
+ } | {
66
+ readonly kind: "unreachable";
67
+ readonly message: string;
68
+ } | {
69
+ readonly kind: "redirect";
70
+ readonly message: string;
71
+ };
72
+ /** The answer as received, for {@link interpretRouteAnswer}. */
73
+ export interface RouteAnswer {
74
+ readonly status: number;
75
+ readonly headers: Headers;
76
+ /** The body, read only for a 402 without a payment header; otherwise "". */
77
+ readonly body: string;
78
+ readonly url: string;
79
+ }
80
+ /**
81
+ * What an answer says, without a network: the recorded answers of the tests
82
+ * go through the same reading as a live one.
83
+ */
84
+ export declare function interpretRouteAnswer(answer: RouteAnswer): RouteReading;
85
+ export interface ReadRouteOptions {
86
+ /** Default {@link ROUTE_READ_TIMEOUT_MS}. */
87
+ readonly timeoutMs?: number;
88
+ }
89
+ /**
90
+ * Sends the route one unpaid request and reads its answer.
91
+ *
92
+ * @throws {ConfigurationError} For a URL or a request shape that cannot be sent (checked before anything is sent).
93
+ */
94
+ export declare function readRoute(url: string, shape: RequestShape, options?: ReadRouteOptions): Promise<RouteReading>;
95
+ /** One offer for a line of output. Sanitised. */
96
+ export declare function describeOffer(offer: RouteOffer): string;
97
+ /** What init may choose: a protocol, a network, or both (`--protocol`, `--network`). */
98
+ export interface OfferWanted {
99
+ readonly protocol?: RouteProtocol;
100
+ readonly network?: string;
101
+ }
102
+ export type OfferChoice = {
103
+ readonly ok: true;
104
+ readonly protocol: RouteProtocol;
105
+ readonly network: string;
106
+ /** The offers of that protocol on that network. */
107
+ readonly offers: readonly RouteOffer[];
108
+ /** The other offers, not written. */
109
+ readonly left: readonly RouteOffer[];
110
+ /** x402 and MPP charge: the receiving address and asset, when the offers agree on one of each. */
111
+ readonly pin?: PinConfig;
112
+ /** Why there is no pin, when there could have been one. */
113
+ readonly noPin?: string;
114
+ /** MPP channel: the channel contract. */
115
+ readonly channel?: string;
116
+ } | {
117
+ readonly ok: false;
118
+ readonly reason: string;
119
+ };
120
+ /**
121
+ * The one way to pay init writes for this route, or why it writes none.
122
+ * Pure: the same offers and flags always give the same answer.
123
+ */
124
+ export declare function chooseOffer(offers: readonly RouteOffer[], wanted?: OfferWanted): OfferChoice;