@wasit-dev/core 0.8.0-beta.2 → 0.8.0-beta.3

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
@@ -4,7 +4,7 @@ The check suite behind [`@wasit-dev/cli`](https://www.npmjs.com/package/@wasit-d
4
4
 
5
5
  This package holds the actual check logic. The CLI and the MCP server are thin adapters over these same functions, so a CLI run and an agent's run can never disagree about the same target — there is only one implementation of each check.
6
6
 
7
- **Testnet only.** Several checks settle real transactions on-chain. In 0.8.0-beta.2 (npm tag `beta`; `latest` is 0.7.0) every payment check pays on test networks only: any other network, `stellar:pubnet` included, is refused before a key is read. The mainnet opt-in (beta) is the one exception: x402 on `stellar:pubnet` through `openMainnetOptIn`, which every front end calls.
7
+ **Testnet only.** Several checks settle real transactions on-chain. In 0.8.0-beta.3 (npm tag `beta`; `latest` is 0.7.0) every payment check pays on test networks only: any other network, `stellar:pubnet` included, is refused before a key is read. The mainnet opt-in (beta) is the one exception: x402 on `stellar:pubnet` through `openMainnetOptIn`, which every front end calls.
8
8
 
9
9
  Most people should reach for [`@wasit-dev/cli`](https://www.npmjs.com/package/@wasit-dev/cli) (terminal) or [`@wasit-dev/server`](https://www.npmjs.com/package/@wasit-dev/server) (MCP / agents) instead of this package directly. Install `@wasit-dev/core` yourself only if you're building your own tooling on top of the check suite.
10
10
 
@@ -42,10 +42,12 @@ export interface RecentFailure {
42
42
  readonly check: string;
43
43
  /** Runs in which the check failed. */
44
44
  readonly failed: number;
45
+ /** Runs in which the check could not run (ERROR), so no verdict was given. */
46
+ readonly errored: number;
45
47
  /** Runs the history holds for it. */
46
48
  readonly runs: number;
47
49
  }
48
- /** The checks that failed in at least one run of the history, most failures first. */
50
+ /** The checks that failed or could not run in at least one run of the history, most first. */
49
51
  export declare function recentFailures(history: History): RecentFailure[];
50
52
  export interface Baseline {
51
53
  readonly report: RunReport;
package/dist/baseline.js CHANGED
@@ -210,17 +210,18 @@ export function updateHistory(previous, report) {
210
210
  ];
211
211
  }));
212
212
  }
213
- /** The checks that failed in at least one run of the history, most failures first. */
213
+ /** The checks that failed or could not run in at least one run of the history, most first. */
214
214
  export function recentFailures(history) {
215
215
  const failures = [];
216
216
  for (const [endpoint, checks] of Object.entries(history)) {
217
217
  for (const [check, letters] of Object.entries(checks)) {
218
218
  const failed = [...letters].filter((letter) => letter === "F").length;
219
- if (failed > 0)
220
- failures.push({ endpoint, check, failed, runs: letters.length });
219
+ const errored = [...letters].filter((letter) => letter === "E").length;
220
+ if (failed + errored > 0)
221
+ failures.push({ endpoint, check, failed, errored, runs: letters.length });
221
222
  }
222
223
  }
223
- return failures.sort((a, b) => b.failed - a.failed);
224
+ return failures.sort((a, b) => b.failed + b.errored - (a.failed + a.errored));
224
225
  }
225
226
  /**
226
227
  * Reads a baseline file. Never throws: a file that is too large, is not JSON, is
@@ -291,11 +292,20 @@ function statuses(endpoint) {
291
292
  }
292
293
  return map;
293
294
  }
295
+ function skippedByTier(result) {
296
+ return result.status === "SKIP" && (result.skipKind === "read-only" || result.skipKind === "needs-payer");
297
+ }
294
298
  /** The checks of an endpoint that its run skipped because of the tier: read-only, or no payer key. */
295
299
  function notRunByTier(endpoint) {
296
- return new Set(endpoint.results
297
- .filter((result) => result.status === "SKIP" && (result.skipKind === "read-only" || result.skipKind === "needs-payer"))
298
- .map((result) => result.id));
300
+ return new Set(endpoint.results.filter(skippedByTier).map((result) => result.id));
301
+ }
302
+ /**
303
+ * Whether the run skipped every check of the endpoint for its tier, so it says
304
+ * nothing about the service: an MPP endpoint on a pull request (no MPP check is
305
+ * read-only), or a run without the key. An endpoint with no results is not.
306
+ */
307
+ function onlyNotRunByTier(endpoint) {
308
+ return endpoint.results.length > 0 && endpoint.results.every(skippedByTier);
299
309
  }
300
310
  /**
301
311
  * What changed against the baseline, by endpoint name: new and removed
@@ -315,7 +325,9 @@ export function diffReports(report, baseline) {
315
325
  }
316
326
  const wasGraded = GRADED.includes(earlier.outcome);
317
327
  const isGraded = GRADED.includes(endpoint.outcome);
318
- if (wasGraded && !isGraded) {
328
+ // Not graded now only because the tier skipped every check of it: no regression (D-021 as amended by
329
+ // Najmi, 2026-11-29). The checks are then all "not run by the tier" below, so no change is listed for it.
330
+ if (wasGraded && !isGraded && !onlyNotRunByTier(endpoint)) {
319
331
  changes.push({ kind: "regression", endpoint: endpoint.name, from: earlier.outcome, to: endpoint.outcome });
320
332
  }
321
333
  else if (!wasGraded && isGraded) {
package/dist/ci-report.js CHANGED
@@ -253,7 +253,11 @@ function renderBody(input) {
253
253
  if (recent.length > 0) {
254
254
  out.push("", "### Recent failures on main");
255
255
  for (const item of recent.slice(0, MAX_RECENT_SHOWN)) {
256
- out.push(`- ${md(item.endpoint)} ${md(item.check)}: failed in ${item.failed} of the last ${item.runs} runs on main`);
256
+ const what = [
257
+ ...(item.failed > 0 ? [`failed in ${item.failed}`] : []),
258
+ ...(item.errored > 0 ? [`could not run in ${item.errored}`] : []),
259
+ ].join(" and ");
260
+ out.push(`- ${md(item.endpoint)} ${md(item.check)}: ${what} of the last ${item.runs} runs on main`);
257
261
  }
258
262
  }
259
263
  if (report.notes.length > 0) {
@@ -27,7 +27,7 @@ export interface UsdAsset {
27
27
  readonly symbol: string;
28
28
  }
29
29
  /**
30
- * USDC on each test network. Sources (read 2026-11-16): `@x402/stellar` 2.28.0
30
+ * USDC on each test network. Sources (read 2026-11-16, the same in 2.32.0 on 2026-11-29): `@x402/stellar` 2.28.0
31
31
  * `USDC_TESTNET_ADDRESS`, `DEFAULT_TOKEN_DECIMALS = 7`; `@x402/evm` 2.28.0 default
32
32
  * asset of `eip155:84532`, decimals 6; Circle's USDC on Ethereum Sepolia as
33
33
  * `chains/evm.ts` (`ETHEREUM_SEPOLIA_USDC`, 6 decimals read from the contract
@@ -24,7 +24,7 @@ export const PER_RUN_CAP_USD = 5;
24
24
  /** A dollar, in the units this module counts in. */
25
25
  const DOLLAR = 10n ** 18n;
26
26
  /**
27
- * USDC on each test network. Sources (read 2026-11-16): `@x402/stellar` 2.28.0
27
+ * USDC on each test network. Sources (read 2026-11-16, the same in 2.32.0 on 2026-11-29): `@x402/stellar` 2.28.0
28
28
  * `USDC_TESTNET_ADDRESS`, `DEFAULT_TOKEN_DECIMALS = 7`; `@x402/evm` 2.28.0 default
29
29
  * asset of `eip155:84532`, decimals 6; Circle's USDC on Ethereum Sepolia as
30
30
  * `chains/evm.ts` (`ETHEREUM_SEPOLIA_USDC`, 6 decimals read from the contract
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The mainnet opt-in switches (spec B5), as this version has them: switches
3
+ * that always refuse (spec B12).
4
+ *
5
+ * A later version may let an x402 run pay on `stellar:pubnet` behind an
6
+ * explicit opt-in. This one does not, and it has no code path that answers
7
+ * "allowed" for it. The switches that opt-in would read exist here only so
8
+ * that a run, a workflow or a server that asks for mainnet is stopped and told
9
+ * why, instead of being run on whatever else it was given:
10
+ *
11
+ * - `--mainnet` on `wasit run` (never read from the config or the environment);
12
+ * - `WASIT_MAINNET_OPT_IN` and `WASIT_MAINNET_CONFIG`, the MCP server's
13
+ * start-up variables, and `--mainnet` among its arguments: the server does
14
+ * not start.
15
+ *
16
+ * The Action's `mainnet` input is refused by the Action's own input check,
17
+ * which runs before Wasit is installed and so cannot import this module.
18
+ *
19
+ * Every function here throws, or only says which switches are set.
20
+ */
21
+ import { ConfigurationError } from "../errors.js";
22
+ /** The sentence of spec B12. */
23
+ export declare const MAINNET_OPT_IN_ABSENT = "the mainnet opt-in is not part of this version";
24
+ /** A switch that asks for mainnet: the CLI's flag, or one of the MCP server's start-up settings. */
25
+ export type MainnetSwitch = "--mainnet" | "WASIT_MAINNET_OPT_IN" | "WASIT_MAINNET_CONFIG";
26
+ /**
27
+ * A switch asked for mainnet, and this version has no mainnet opt-in. A
28
+ * `ConfigurationError`: it says nothing about any service. Nothing was read,
29
+ * sent or signed when it is thrown.
30
+ */
31
+ export declare class MainnetOptInRefusedError extends ConfigurationError {
32
+ readonly switchName: MainnetSwitch;
33
+ constructor(switchName: MainnetSwitch, message: string);
34
+ }
35
+ /**
36
+ * Refuses a switch that asks for mainnet. Always throws.
37
+ *
38
+ * For `--mainnet`, `context.event` is the GitHub event of the run when it runs
39
+ * in GitHub Actions: on any event but `workflow_dispatch` the message says that
40
+ * rule as well, so a push or a schedule with the switch set reads as refused for
41
+ * that reason too. `context.runner` is `RUNNER_ENVIRONMENT` there: on a runner
42
+ * that is not GitHub-hosted the message says that rule too.
43
+ *
44
+ * @throws {MainnetOptInRefusedError} Always.
45
+ */
46
+ export declare function refuseMainnetSwitch(switchName: MainnetSwitch, context?: {
47
+ readonly event?: string;
48
+ readonly runner?: string;
49
+ }): never;
50
+ /**
51
+ * The switches that ask the MCP server for mainnet at start-up: `--mainnet`
52
+ * among its arguments (with or without a value), and each start-up variable
53
+ * that holds a value that is not blank. Any value counts, "0" included: the
54
+ * variable is there to be removed. Names are compared in upper case, as a
55
+ * Windows environment does.
56
+ *
57
+ * @param env the server's environment
58
+ * @param args the server's arguments, after the script (`process.argv.slice(2)`)
59
+ */
60
+ export declare function mainnetStartupSwitches(env: Readonly<Record<string, string | undefined>>, args: readonly string[]): MainnetSwitch[];
@@ -0,0 +1,101 @@
1
+ /**
2
+ * The mainnet opt-in switches (spec B5), as this version has them: switches
3
+ * that always refuse (spec B12).
4
+ *
5
+ * A later version may let an x402 run pay on `stellar:pubnet` behind an
6
+ * explicit opt-in. This one does not, and it has no code path that answers
7
+ * "allowed" for it. The switches that opt-in would read exist here only so
8
+ * that a run, a workflow or a server that asks for mainnet is stopped and told
9
+ * why, instead of being run on whatever else it was given:
10
+ *
11
+ * - `--mainnet` on `wasit run` (never read from the config or the environment);
12
+ * - `WASIT_MAINNET_OPT_IN` and `WASIT_MAINNET_CONFIG`, the MCP server's
13
+ * start-up variables, and `--mainnet` among its arguments: the server does
14
+ * not start.
15
+ *
16
+ * The Action's `mainnet` input is refused by the Action's own input check,
17
+ * which runs before Wasit is installed and so cannot import this module.
18
+ *
19
+ * Every function here throws, or only says which switches are set.
20
+ */
21
+ import { ConfigurationError } from "../errors.js";
22
+ import { NETWORK_CLASSES } from "./networks.js";
23
+ /** The sentence of spec B12. */
24
+ export const MAINNET_OPT_IN_ABSENT = "the mainnet opt-in is not part of this version";
25
+ /** The MCP server's start-up variables that ask for mainnet. */
26
+ const STARTUP_VARIABLES = ["WASIT_MAINNET_OPT_IN", "WASIT_MAINNET_CONFIG"];
27
+ /** An event name as GitHub writes them; anything else is never echoed. */
28
+ const EVENT_NAME = /^[a-z_]{1,64}$/;
29
+ /**
30
+ * A switch asked for mainnet, and this version has no mainnet opt-in. A
31
+ * `ConfigurationError`: it says nothing about any service. Nothing was read,
32
+ * sent or signed when it is thrown.
33
+ */
34
+ export class MainnetOptInRefusedError extends ConfigurationError {
35
+ switchName;
36
+ constructor(switchName, message) {
37
+ super(message);
38
+ this.name = "MainnetOptInRefusedError";
39
+ this.switchName = switchName;
40
+ }
41
+ }
42
+ function testNetworks() {
43
+ return [...NETWORK_CLASSES]
44
+ .filter(([, kind]) => kind === "test")
45
+ .map(([network]) => network)
46
+ .join(", ");
47
+ }
48
+ /**
49
+ * Refuses a switch that asks for mainnet. Always throws.
50
+ *
51
+ * For `--mainnet`, `context.event` is the GitHub event of the run when it runs
52
+ * in GitHub Actions: on any event but `workflow_dispatch` the message says that
53
+ * rule as well, so a push or a schedule with the switch set reads as refused for
54
+ * that reason too. `context.runner` is `RUNNER_ENVIRONMENT` there: on a runner
55
+ * that is not GitHub-hosted the message says that rule too.
56
+ *
57
+ * @throws {MainnetOptInRefusedError} Always.
58
+ */
59
+ export function refuseMainnetSwitch(switchName, context = {}) {
60
+ const networks = `Wasit pays on test networks only (${testNetworks()}).`;
61
+ if (switchName === "--mainnet") {
62
+ const event = context.event;
63
+ const eventRule = event === undefined || event === "workflow_dispatch"
64
+ ? ""
65
+ : ` --mainnet is also refused on every GitHub event but workflow_dispatch, and this run's event is ` +
66
+ `${EVENT_NAME.test(event) ? event : "another event"}.`;
67
+ // Spec B17.4: a self-hosted runner keeps files and processes between jobs.
68
+ const runnerRule = context.runner === undefined || context.runner === "github-hosted"
69
+ ? ""
70
+ : " --mainnet is also refused on a runner that is not GitHub-hosted: a self-hosted runner keeps files and " +
71
+ "processes between jobs.";
72
+ throw new MainnetOptInRefusedError(switchName, `--mainnet is refused: ${MAINNET_OPT_IN_ABSENT}. ${networks}${eventRule}${runnerRule} ` +
73
+ `The config was not read, and nothing was started, sent or signed.`);
74
+ }
75
+ throw new MainnetOptInRefusedError(switchName, `${switchName} is set: ${MAINNET_OPT_IN_ABSENT}, so this server does not start. ${networks} ` +
76
+ `Nothing was read, sent or signed. Remove ${switchName} from the server's environment to start it.`);
77
+ }
78
+ /**
79
+ * The switches that ask the MCP server for mainnet at start-up: `--mainnet`
80
+ * among its arguments (with or without a value), and each start-up variable
81
+ * that holds a value that is not blank. Any value counts, "0" included: the
82
+ * variable is there to be removed. Names are compared in upper case, as a
83
+ * Windows environment does.
84
+ *
85
+ * @param env the server's environment
86
+ * @param args the server's arguments, after the script (`process.argv.slice(2)`)
87
+ */
88
+ export function mainnetStartupSwitches(env, args) {
89
+ const found = [];
90
+ if (args.some((arg) => arg === "--mainnet" || arg.startsWith("--mainnet=")))
91
+ found.push("--mainnet");
92
+ const set = new Set();
93
+ for (const [name, value] of Object.entries(env)) {
94
+ if (typeof value === "string" && value.trim() !== "")
95
+ set.add(name.toUpperCase());
96
+ }
97
+ for (const name of STARTUP_VARIABLES)
98
+ if (set.has(name))
99
+ found.push(name);
100
+ return found;
101
+ }
@@ -23,7 +23,7 @@ import { type PinTerms } from "./budget.js";
23
23
  * "USDC-GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN"); the
24
24
  * contract derived from that issuer with the SDK
25
25
  * (`new Asset("USDC", issuer).contractId(Networks.PUBLIC)`); and
26
- * `USDC_PUBNET_ADDRESS` of `@x402/stellar` 2.28.0. A test asserts all three.
26
+ * `USDC_PUBNET_ADDRESS` of `@x402/stellar` 2.28.0 (the same in 2.32.0, read 2026-11-29). A test asserts all three.
27
27
  */
28
28
  export declare const MAINNET_USDC: {
29
29
  readonly network: "stellar:pubnet";
@@ -26,7 +26,7 @@ const STELLAR_PUBNET = "stellar:pubnet";
26
26
  * "USDC-GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN"); the
27
27
  * contract derived from that issuer with the SDK
28
28
  * (`new Asset("USDC", issuer).contractId(Networks.PUBLIC)`); and
29
- * `USDC_PUBNET_ADDRESS` of `@x402/stellar` 2.28.0. A test asserts all three.
29
+ * `USDC_PUBNET_ADDRESS` of `@x402/stellar` 2.28.0 (the same in 2.32.0, read 2026-11-29). A test asserts all three.
30
30
  */
31
31
  export const MAINNET_USDC = {
32
32
  network: STELLAR_PUBNET,
@@ -19,6 +19,7 @@
19
19
  * (its nonce), whoever submits it. The expiration bound keeps a signature from
20
20
  * outliving the run; the cap does not depend on it.
21
21
  */
22
+ import { xdr } from "@stellar/stellar-sdk";
22
23
  /** What one payment may be signed for: the terms L2 checked and charged. */
23
24
  export interface SigningTerms {
24
25
  /** The run's CAIP-2 network. */
@@ -57,10 +58,47 @@ export declare class SigningGate {
57
58
  /** The signature it let through, if any. */
58
59
  get signed(): SignedRecord | undefined;
59
60
  }
61
+ /**
62
+ * The two forms of Soroban authorization preimage Wasit signs (CAP-71-02,
63
+ * final, protocol 27):
64
+ *
65
+ * - `address`: `ENVELOPE_TYPE_SOROBAN_AUTHORIZATION`, the payload of the
66
+ * legacy address credential (`SOROBAN_CREDENTIALS_ADDRESS`);
67
+ * - `address-v2`: `ENVELOPE_TYPE_SOROBAN_AUTHORIZATION_WITH_ADDRESS`, the same
68
+ * fields plus the signer's address, the payload of
69
+ * `SOROBAN_CREDENTIALS_ADDRESS_V2`. The CAP gives V2 the same semantics as
70
+ * the legacy credential; only the payload differs, and it binds the address.
71
+ * `@stellar/stellar-sdk` 17 simulates with V2 by default (`useUpgradedAuth`).
72
+ *
73
+ * The delegated form (`SOROBAN_CREDENTIALS_ADDRESS_WITH_DELEGATES`) signs the
74
+ * same `address-v2` payload, and the preimage alone does not tell the two
75
+ * apart. So when the RPC's simulation hands the payer a delegated entry, the
76
+ * key does sign: the signature is the one an honest V2 entry for that same
77
+ * transfer would carry (one transfer of the checked amount to the checked
78
+ * payee, once by its nonce, within the expiry, and counted in the cap like
79
+ * every signature). What is sent is then held to the form the preimage names
80
+ * (`stellar.ts`, `bind`), and a delegated credential is refused there as
81
+ * signed and not sent.
82
+ */
83
+ export type StellarPreimageForm = "address" | "address-v2";
84
+ export interface StellarPreimage {
85
+ readonly form: StellarPreimageForm;
86
+ readonly networkId: Buffer;
87
+ readonly nonce: string;
88
+ readonly signatureExpirationLedger: number;
89
+ readonly invocation: xdr.SorobanAuthorizedInvocation;
90
+ /** The signer's address the payload binds: only in the `address-v2` form; undefined if it does not decode. */
91
+ readonly address?: string | undefined;
92
+ }
93
+ /**
94
+ * The preimage `preimage` (base64 XDR), read in one of the two forms Wasit
95
+ * signs; undefined when it does not decode or is another form.
96
+ */
97
+ export declare function readStellarPreimage(preimage: string): StellarPreimage | undefined;
60
98
  /**
61
99
  * The ledger a signature the gate let through expires at, decoded from the
62
100
  * preimage the key signed (spec B5: the expiry is read, never computed);
63
- * undefined when it does not decode as the address credential's preimage.
101
+ * undefined when it does not decode as one of the two forms Wasit signs.
64
102
  */
65
103
  export declare function expirationOfSigned(record: SignedRecord): number | undefined;
66
104
  /**
@@ -90,7 +128,8 @@ export declare class SigningAnchor {
90
128
  * `transfer(payer, payTo, amount)` on `asset`, on the run's network, with no
91
129
  * sub-invocation, expiring no later than `maxExpiration`.
92
130
  *
93
- * Only the address credential's preimage is signed: the address-bound form
94
- * (`AddressV2`, delegates) is refused, as is anything that does not decode.
131
+ * Two forms are signed (see {@link StellarPreimageForm}): the address
132
+ * credential's and the address-bound one, whose address must be the payer's.
133
+ * Any other form is refused, as is anything that does not decode.
95
134
  */
96
- export declare function checkStellarPreimage(preimage: string, terms: SigningTerms): void;
135
+ export declare function checkStellarPreimage(preimage: string, terms: SigningTerms): StellarPreimageForm;
@@ -51,7 +51,8 @@ export class SigningGate {
51
51
  throw refuse("The payer's key was asked to sign when Wasit expected no signature.");
52
52
  }
53
53
  if (this.#taken) {
54
- throw refuse("The x402 client asked the payer's key for a second signature in one payment; Wasit signs one per payment.");
54
+ // The first signature was made: the refusal must not say nothing was signed.
55
+ throw refuse("The x402 client asked the payer's key for a second signature in one payment; Wasit signs one per payment.", { signed: true });
55
56
  }
56
57
  this.#taken = true;
57
58
  return this.#terms;
@@ -68,20 +69,57 @@ export class SigningGate {
68
69
  }
69
70
  }
70
71
  /**
71
- * The ledger a signature the gate let through expires at, decoded from the
72
- * preimage the key signed (spec B5: the expiry is read, never computed);
73
- * undefined when it does not decode as the address credential's preimage.
72
+ * The preimage `preimage` (base64 XDR), read in one of the two forms Wasit
73
+ * signs; undefined when it does not decode or is another form.
74
74
  */
75
- export function expirationOfSigned(record) {
75
+ export function readStellarPreimage(preimage) {
76
+ let decoded;
76
77
  try {
77
- const decoded = xdr.HashIdPreimage.fromXDR(record.preimage, "base64");
78
- if (decoded.switch().name !== "envelopeTypeSorobanAuthorization")
79
- return undefined;
80
- return decoded.sorobanAuthorization().signatureExpirationLedger();
78
+ decoded = xdr.HashIdPreimage.fromXDR(preimage, "base64");
81
79
  }
82
80
  catch {
83
81
  return undefined;
84
82
  }
83
+ switch (decoded.switch().name) {
84
+ case "envelopeTypeSorobanAuthorization": {
85
+ const value = decoded.sorobanAuthorization();
86
+ return {
87
+ form: "address",
88
+ networkId: Buffer.from(value.networkId()),
89
+ nonce: value.nonce().toString(),
90
+ signatureExpirationLedger: value.signatureExpirationLedger(),
91
+ invocation: value.invocation(),
92
+ };
93
+ }
94
+ case "envelopeTypeSorobanAuthorizationWithAddress": {
95
+ const value = decoded.sorobanAuthorizationWithAddress();
96
+ let address;
97
+ try {
98
+ address = Address.fromScAddress(value.address()).toString();
99
+ }
100
+ catch {
101
+ address = undefined;
102
+ }
103
+ return {
104
+ form: "address-v2",
105
+ networkId: Buffer.from(value.networkId()),
106
+ nonce: value.nonce().toString(),
107
+ signatureExpirationLedger: value.signatureExpirationLedger(),
108
+ invocation: value.invocation(),
109
+ address,
110
+ };
111
+ }
112
+ default:
113
+ return undefined;
114
+ }
115
+ }
116
+ /**
117
+ * The ledger a signature the gate let through expires at, decoded from the
118
+ * preimage the key signed (spec B5: the expiry is read, never computed);
119
+ * undefined when it does not decode as one of the two forms Wasit signs.
120
+ */
121
+ export function expirationOfSigned(record) {
122
+ return readStellarPreimage(record.preimage)?.signatureExpirationLedger;
85
123
  }
86
124
  /**
87
125
  * The run's first reading of the chain's latest unit (a ledger on Stellar),
@@ -133,8 +171,9 @@ function addressOf(value) {
133
171
  * `transfer(payer, payTo, amount)` on `asset`, on the run's network, with no
134
172
  * sub-invocation, expiring no later than `maxExpiration`.
135
173
  *
136
- * Only the address credential's preimage is signed: the address-bound form
137
- * (`AddressV2`, delegates) is refused, as is anything that does not decode.
174
+ * Two forms are signed (see {@link StellarPreimageForm}): the address
175
+ * credential's and the address-bound one, whose address must be the payer's.
176
+ * Any other form is refused, as is anything that does not decode.
138
177
  */
139
178
  export function checkStellarPreimage(preimage, terms) {
140
179
  let decoded;
@@ -144,15 +183,20 @@ export function checkStellarPreimage(preimage, terms) {
144
183
  catch {
145
184
  throw refuse(`${ASKED} does not decode as a Soroban authorization.`);
146
185
  }
147
- if (decoded.switch().name !== "envelopeTypeSorobanAuthorization") {
148
- throw refuse(`${ASKED} is a form of authorization Wasit does not sign (it signs the address credential only).`);
186
+ const authorization = readStellarPreimage(preimage);
187
+ if (authorization === undefined) {
188
+ throw refuse(`${ASKED} is a form of authorization Wasit does not sign (${decoded.switch().name}; it signs the address ` +
189
+ `credential and the address-bound one only).`);
190
+ }
191
+ if (authorization.form === "address-v2" && authorization.address !== terms.payer) {
192
+ throw refuse(`${ASKED} binds the signature to ${authorization.address === undefined ? "an address that does not decode" : shown(authorization.address)}, ` +
193
+ `not to the payer.`);
149
194
  }
150
- const authorization = decoded.sorobanAuthorization();
151
195
  const networkId = hash(Buffer.from(networkPassphrase(terms.network)));
152
- if (!Buffer.from(authorization.networkId()).equals(networkId)) {
196
+ if (!authorization.networkId.equals(networkId)) {
153
197
  throw refuse(`${ASKED} is for another network than this run's (${terms.network}).`);
154
198
  }
155
- const invocation = authorization.invocation();
199
+ const invocation = authorization.invocation;
156
200
  const fn = invocation.function();
157
201
  if (fn.switch().name !== "sorobanAuthorizedFunctionTypeContractFn") {
158
202
  throw refuse(`${ASKED} is not a contract call.`);
@@ -199,9 +243,10 @@ export function checkStellarPreimage(preimage, terms) {
199
243
  if (further !== 0) {
200
244
  throw refuse(`${ASKED} also authorizes ${further} further call${further === 1 ? "" : "s"} beside the transfer.`);
201
245
  }
202
- const expiration = authorization.signatureExpirationLedger();
246
+ const expiration = authorization.signatureExpirationLedger;
203
247
  if (expiration > terms.maxExpiration) {
204
248
  throw refuse(`${ASKED} stays valid until ledger ${expiration}, past ledger ${terms.maxExpiration}, the latest this ` +
205
249
  `payment's lifetime allows.`);
206
250
  }
251
+ return authorization.form;
207
252
  }
@@ -12,7 +12,7 @@ import type { PaymentChain, SignedAuthorization } from "./types.js";
12
12
  * In the `exact` scheme on Stellar the client signs a Soroban authorization
13
13
  * entry, not the envelope: the facilitator signs the envelope later. So the
14
14
  * signature that proves the payer consented is the address credential's
15
- * `signature`, a `Vec<{ public_key, signature }>`. Flipping one byte of it
15
+ * `signature` (legacy or V2), a `Vec<{ public_key, signature }>`. Flipping one byte of it
16
16
  * leaves a transaction that still decodes, carries the same amount, payer and
17
17
  * recipient, and fails only signature verification. A target can refuse it
18
18
  * only by verifying the signature.
@@ -30,9 +30,44 @@ export declare function corruptAuthSignature(transaction: string): string;
30
30
  export declare function sacAssetFromName(name: unknown, contractId: string, passphrase: string): Asset | undefined;
31
31
  /**
32
32
  * X402-11 reads (D-032, spec B16.4): the authorization a payment carries, as
33
- * the payer signed it. Only an address credential is read; another form (the
34
- * newer `AddressV2`, one with delegates) is not, and gives no reading rather
35
- * than a guess, since its nonce handling was not read.
33
+ * the payer signed it. An address credential is read, legacy or V2: CAP-71-02
34
+ * gives V2 the same semantics as the legacy credential, with only the signed
35
+ * payload different, and the host stores and consumes the nonce of both the
36
+ * same way, as a TEMPORARY entry keyed by the credential's address and
37
+ * `LedgerKeyNonce { nonce }` (rs-soroban-env v27.0.1,
38
+ * `soroban-env-host/src/auth.rs`, `from_authorization_entry` and
39
+ * `consume_nonce`; read 2026-11-29), which is `nonceKey` below. A PASS of
40
+ * X402-11 also needs the second readings (no transfer to payTo, the payer's
41
+ * balance not fallen by it), so a nonce read the wrong way cannot pass on its
42
+ * own. A delegated credential is not read, and gives no reading rather than a
43
+ * guess.
36
44
  */
37
45
  export declare function decodeStellarAuthorization(payload: Record<string, unknown>): SignedAuthorization;
46
+ /**
47
+ * X402-10's lifetime on Stellar, in seconds. The x402 client reads the latest
48
+ * ledger, signs for `maxTimeoutSeconds` past it, and simulates the payment
49
+ * again after signing. With a one-second lifetime (one ledger), a ledger that
50
+ * closed while the client built the payment ended that second simulation with
51
+ * `HostError: Error(Auth, InvalidInput)`, and X402-10 had no verdict: 3 of 5
52
+ * runs with @x402/stellar 2.32.0 on testnet (2026-11-29); the failing runs
53
+ * stopped 9 to 17 s in. 30 s is about five ledgers. The signature stays valid
54
+ * that long, as any payment's does (the RPC that simulates it sees it): it is
55
+ * counted in the run's cap like every signature, for the advertised amount to
56
+ * the checked payee, and Wasit holds it unsent until the chain is past it.
57
+ */
58
+ export declare const EXPIRED_LIFETIME_SECONDS = 30;
59
+ /** How long X402-10 waits for the chain to pass the payment's expiry: the lifetime and a minute more. */
60
+ export declare const EXPIRED_WAIT_MS: number;
61
+ /**
62
+ * Resolves once `latest()` reads a ledger past `expiresAt`, where an
63
+ * authorization that expires at `expiresAt` can no longer be used. Throws a
64
+ * CheckSetupError (no verdict) if the chain is not there by `maxWaitMs`: the
65
+ * payment is then not sent, since it might still be valid.
66
+ */
67
+ export declare function waitPastLedger(expiresAt: number, latest: () => Promise<number>, options?: {
68
+ readonly maxWaitMs?: number;
69
+ readonly pollMs?: number;
70
+ readonly now?: () => number;
71
+ readonly sleep?: (ms: number) => Promise<void>;
72
+ }): Promise<void>;
38
73
  export declare const stellarChain: PaymentChain;
@@ -10,18 +10,35 @@ import { Account, Address, Asset, Contract, Keypair, StrKey, TransactionBuilder,
10
10
  import { CheckSetupError } from "../../errors.js";
11
11
  import { PaymentGuardRefusedError } from "../../guard/budget.js";
12
12
  import { isLiveOptIn } from "../../guard/optin.js";
13
- import { checkStellarPreimage } from "../../guard/signed-terms.js";
13
+ import { checkStellarPreimage, readStellarPreimage, } from "../../guard/signed-terms.js";
14
14
  import { networkPassphrase, resolveRpcUrl } from "../../mpp/network.js";
15
15
  import { readTransferData, verifySettlement } from "../../settlement.js";
16
16
  /** A Stellar transaction hash: 64 hex characters. */
17
17
  const TRANSACTION_HASH = /^[0-9a-f]{64}$/i;
18
+ /**
19
+ * The address credentials of an authorization entry, in the two forms Wasit
20
+ * signs (CAP-71-02): the legacy `SOROBAN_CREDENTIALS_ADDRESS` and
21
+ * `SOROBAN_CREDENTIALS_ADDRESS_V2`, which carries the same fields and differs
22
+ * only in the payload it is signed over. Undefined for any other form (the
23
+ * source account, and the delegated `..._WITH_DELEGATES`, which is not read).
24
+ */
25
+ function addressCredentials(credentials) {
26
+ switch (credentials.switch().name) {
27
+ case "sorobanCredentialsAddress":
28
+ return { form: "address", value: credentials.address() };
29
+ case "sorobanCredentialsAddressV2":
30
+ return { form: "address-v2", value: credentials.addressV2() };
31
+ default:
32
+ return undefined;
33
+ }
34
+ }
18
35
  /**
19
36
  * Corrupts the client's authorization signature, and nothing else.
20
37
  *
21
38
  * In the `exact` scheme on Stellar the client signs a Soroban authorization
22
39
  * entry, not the envelope: the facilitator signs the envelope later. So the
23
40
  * signature that proves the payer consented is the address credential's
24
- * `signature`, a `Vec<{ public_key, signature }>`. Flipping one byte of it
41
+ * `signature` (legacy or V2), a `Vec<{ public_key, signature }>`. Flipping one byte of it
25
42
  * leaves a transaction that still decodes, carries the same amount, payer and
26
43
  * recipient, and fails only signature verification. A target can refuse it
27
44
  * only by verifying the signature.
@@ -37,10 +54,10 @@ export function corruptAuthSignature(transaction) {
37
54
  if (operation.body().switch().name !== "invokeHostFunction")
38
55
  continue;
39
56
  for (const entry of operation.body().invokeHostFunctionOp().auth()) {
40
- const credentials = entry.credentials();
41
- if (credentials.switch().name !== "sorobanCredentialsAddress")
57
+ const credentials = addressCredentials(entry.credentials());
58
+ if (credentials === undefined)
42
59
  continue;
43
- const signature = credentials.address().signature();
60
+ const signature = credentials.value.signature();
44
61
  if (signature.switch().name !== "scvVec")
45
62
  continue;
46
63
  for (const item of signature.vec() ?? []) {
@@ -133,9 +150,17 @@ async function stellarTokenBalance(network, rpcUrl, payer, asset) {
133
150
  }
134
151
  /**
135
152
  * X402-11 reads (D-032, spec B16.4): the authorization a payment carries, as
136
- * the payer signed it. Only an address credential is read; another form (the
137
- * newer `AddressV2`, one with delegates) is not, and gives no reading rather
138
- * than a guess, since its nonce handling was not read.
153
+ * the payer signed it. An address credential is read, legacy or V2: CAP-71-02
154
+ * gives V2 the same semantics as the legacy credential, with only the signed
155
+ * payload different, and the host stores and consumes the nonce of both the
156
+ * same way, as a TEMPORARY entry keyed by the credential's address and
157
+ * `LedgerKeyNonce { nonce }` (rs-soroban-env v27.0.1,
158
+ * `soroban-env-host/src/auth.rs`, `from_authorization_entry` and
159
+ * `consume_nonce`; read 2026-11-29), which is `nonceKey` below. A PASS of
160
+ * X402-11 also needs the second readings (no transfer to payTo, the payer's
161
+ * balance not fallen by it), so a nonce read the wrong way cannot pass on its
162
+ * own. A delegated credential is not read, and gives no reading rather than a
163
+ * guess.
139
164
  */
140
165
  export function decodeStellarAuthorization(payload) {
141
166
  const transaction = payload["transaction"];
@@ -157,14 +182,14 @@ export function decodeStellarAuthorization(payload) {
157
182
  continue;
158
183
  for (const entry of operation.body().invokeHostFunctionOp().auth()) {
159
184
  const credentials = entry.credentials();
160
- const kind = credentials.switch().name;
161
- if (kind === "sorobanCredentialsSourceAccount")
185
+ if (credentials.switch().name === "sorobanCredentialsSourceAccount")
162
186
  continue;
163
- if (kind !== "sorobanCredentialsAddress") {
187
+ const read = addressCredentials(credentials);
188
+ if (read === undefined) {
164
189
  otherForms += 1;
165
190
  continue;
166
191
  }
167
- const address = credentials.address();
192
+ const address = read.value;
168
193
  found.push({
169
194
  payer: Address.fromScAddress(address.address()).toString(),
170
195
  nonce: address.nonce().toString(),
@@ -173,7 +198,7 @@ export function decodeStellarAuthorization(payload) {
173
198
  }
174
199
  }
175
200
  if (otherForms > 0) {
176
- throw new CheckSetupError("The payment's authorization uses a credential form this check does not read (it reads address credentials), " +
201
+ throw new CheckSetupError("The payment's authorization uses a credential form this check does not read (it reads address credentials, legacy and V2), " +
177
202
  "so whether it was used cannot be read.");
178
203
  }
179
204
  if (found.length !== 1) {
@@ -192,6 +217,43 @@ function nonceKey(authorization) {
192
217
  function rpcServer(rpcUrl) {
193
218
  return new rpc.Server(rpcUrl, { allowHttp: rpcUrl.startsWith("http://") });
194
219
  }
220
+ /**
221
+ * X402-10's lifetime on Stellar, in seconds. The x402 client reads the latest
222
+ * ledger, signs for `maxTimeoutSeconds` past it, and simulates the payment
223
+ * again after signing. With a one-second lifetime (one ledger), a ledger that
224
+ * closed while the client built the payment ended that second simulation with
225
+ * `HostError: Error(Auth, InvalidInput)`, and X402-10 had no verdict: 3 of 5
226
+ * runs with @x402/stellar 2.32.0 on testnet (2026-11-29); the failing runs
227
+ * stopped 9 to 17 s in. 30 s is about five ledgers. The signature stays valid
228
+ * that long, as any payment's does (the RPC that simulates it sees it): it is
229
+ * counted in the run's cap like every signature, for the advertised amount to
230
+ * the checked payee, and Wasit holds it unsent until the chain is past it.
231
+ */
232
+ export const EXPIRED_LIFETIME_SECONDS = 30;
233
+ /** How long X402-10 waits for the chain to pass the payment's expiry: the lifetime and a minute more. */
234
+ export const EXPIRED_WAIT_MS = (EXPIRED_LIFETIME_SECONDS + 60) * 1000;
235
+ /**
236
+ * Resolves once `latest()` reads a ledger past `expiresAt`, where an
237
+ * authorization that expires at `expiresAt` can no longer be used. Throws a
238
+ * CheckSetupError (no verdict) if the chain is not there by `maxWaitMs`: the
239
+ * payment is then not sent, since it might still be valid.
240
+ */
241
+ export async function waitPastLedger(expiresAt, latest, options = {}) {
242
+ const now = options.now ?? Date.now;
243
+ const sleep = options.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms)));
244
+ const maxWaitMs = options.maxWaitMs ?? EXPIRED_WAIT_MS;
245
+ const started = now();
246
+ for (;;) {
247
+ const ledger = await latest();
248
+ if (ledger > expiresAt)
249
+ return;
250
+ if (now() - started >= maxWaitMs) {
251
+ throw new CheckSetupError(`The chain was at ledger ${ledger} after ${Math.round(maxWaitMs / 1000)} s, not yet past ledger ${expiresAt}, ` +
252
+ `where the payment's authorization expires, so it was not sent: it might still have been valid.`);
253
+ }
254
+ await sleep(options.pollMs ?? 2_000);
255
+ }
256
+ }
195
257
  /** The most events read for one X402-11 window: far more than one run makes. */
196
258
  const EVENTS_PAGE = 100;
197
259
  const EVENTS_MAX_PAGES = 20;
@@ -199,7 +261,7 @@ const stellarAuthorizations = {
199
261
  unit: "ledger",
200
262
  unitMs: 5_000,
201
263
  // The x402 Stellar client's own default (DEFAULT_ESTIMATED_LEDGER_SECONDS in
202
- // @x402/stellar 2.28.0); it estimates from recent ledgers when it can.
264
+ // @x402/stellar 2.28.0, and still in 2.32.0); it estimates from recent ledgers when it can.
203
265
  unitSeconds: 5,
204
266
  decode: decodeStellarAuthorization,
205
267
  async read(_network, rpcUrl, authorizations) {
@@ -305,7 +367,7 @@ function notSent(message) {
305
367
  }
306
368
  const stellarSignedTerms = {
307
369
  // The x402 Stellar client's fallback ledger close time (DEFAULT_ESTIMATED_LEDGER_SECONDS in
308
- // @x402/stellar 2.28.0), and the shortest it assumes: a faster close only tightens the bound.
370
+ // @x402/stellar 2.28.0, and still in 2.32.0), and the shortest it assumes: a faster close only tightens the bound.
309
371
  unitSeconds: 5,
310
372
  async latestUnit(_network, rpcUrl) {
311
373
  return (await rpcServer(rpcUrl).getLatestLedger()).sequence;
@@ -315,7 +377,10 @@ const stellarSignedTerms = {
315
377
  if (signed === undefined) {
316
378
  throw new PaymentGuardRefusedError("signed-terms", "The x402 client built a payment without the signature Wasit checked.");
317
379
  }
318
- const checked = xdr.HashIdPreimage.fromXDR(signed.preimage, "base64").sorobanAuthorization();
380
+ const checked = readStellarPreimage(signed.preimage);
381
+ if (checked === undefined) {
382
+ throw notSent("The signature Wasit recorded covers a preimage it cannot read back.");
383
+ }
319
384
  const transaction = payload["transaction"];
320
385
  let envelope;
321
386
  try {
@@ -333,28 +398,33 @@ const stellarSignedTerms = {
333
398
  if (operation.body().switch().name !== "invokeHostFunction")
334
399
  continue;
335
400
  for (const entry of operation.body().invokeHostFunctionOp().auth()) {
336
- const kind = entry.credentials().switch().name;
337
- if (kind === "sorobanCredentialsSourceAccount")
401
+ if (entry.credentials().switch().name === "sorobanCredentialsSourceAccount")
338
402
  continue;
339
- if (kind !== "sorobanCredentialsAddress") {
403
+ const read = addressCredentials(entry.credentials());
404
+ if (read === undefined) {
340
405
  throw notSent("The payment the x402 client built carries an authorization in a form Wasit did not sign.");
341
406
  }
342
- if (Address.fromScAddress(entry.credentials().address().address()).toString() === payer)
343
- ours.push(entry);
407
+ if (Address.fromScAddress(read.value.address()).toString() === payer)
408
+ ours.push({ entry, ...read });
344
409
  }
345
410
  }
346
411
  if (ours.length !== 1) {
347
412
  throw notSent(`The payment the x402 client built carries ${ours.length} authorizations for the payer; Wasit signed one.`);
348
413
  }
349
- const entry = ours[0];
350
- const credentials = entry.credentials().address();
351
- if (entry.rootInvocation().toXDR("base64") !== checked.invocation().toXDR("base64")) {
414
+ const { entry, form, value: credentials } = ours[0];
415
+ // The credential must be the one the signed payload belongs to: a V2 payload
416
+ // under a legacy credential (or the reverse) is a signature the network
417
+ // would check against another payload than the one Wasit signed.
418
+ if (form !== checked.form) {
419
+ throw notSent("The payment the x402 client built carries an authorization in a form Wasit did not sign.");
420
+ }
421
+ if (entry.rootInvocation().toXDR("base64") !== checked.invocation.toXDR("base64")) {
352
422
  throw notSent("The payment the x402 client built names another invocation than the one Wasit checked and signed.");
353
423
  }
354
- if (credentials.signatureExpirationLedger() !== checked.signatureExpirationLedger()) {
424
+ if (credentials.signatureExpirationLedger() !== checked.signatureExpirationLedger) {
355
425
  throw notSent("The payment the x402 client built carries another expiration ledger than the one signed.");
356
426
  }
357
- if (credentials.nonce().toString() !== checked.nonce().toString()) {
427
+ if (credentials.nonce().toString() !== checked.nonce) {
358
428
  throw notSent("The payment the x402 client built carries another nonce than the one signed.");
359
429
  }
360
430
  const sent = credentialSignature(credentials.signature());
@@ -386,9 +456,13 @@ export const stellarChain = {
386
456
  client.register("stellar:*", new ExactStellarClientScheme(gatedSigner(payerKey, network, gate), rpcConfig));
387
457
  },
388
458
  signedTerms: stellarSignedTerms,
389
- // A one-second lifetime is one ledger (ceil(1 / 5)); ledgers close about
390
- // every 5 to 6 seconds, so 20 seconds is three or more ledgers past it.
391
- expiredSigning: async () => ({ terms: { maxTimeoutSeconds: 1 }, holdMs: 20_000 }),
459
+ // See EXPIRED_LIFETIME_SECONDS: signed to live long enough for the client to finish building it, then
460
+ // sent once the chain is past the ledger it expires at, read from the payload.
461
+ expiredSigning: async () => ({
462
+ terms: { maxTimeoutSeconds: EXPIRED_LIFETIME_SECONDS },
463
+ holdMs: 0,
464
+ untilExpired: async (payload, rpcUrl) => waitPastLedger(decodeStellarAuthorization(payload).expiresAt, async () => (await rpcServer(rpcUrl).getLatestLedger()).sequence),
465
+ }),
392
466
  payerAddress: (payerKey) => Keypair.fromSecret(payerKey).publicKey(),
393
467
  payerBalance: stellarTokenBalance,
394
468
  async assetDecimals(network, rpcUrl, asset) {
@@ -171,7 +171,10 @@ async function verifySvmSettlement(rpcUrl, reference, expected) {
171
171
  const lookup = await waitForReceipt(async () => (await rpc
172
172
  .getTransaction(signature(reference), {
173
173
  encoding: "jsonParsed",
174
- maxSupportedTransactionVersion: 0,
174
+ // Version 1 transactions exist since @x402/svm 2.29 (@solana/kit 8): with 0 the RPC refuses
175
+ // to return one ("Transaction version (1) is not supported by the requesting client"), and
176
+ // a compliant settlement had no verdict (issue #22; seen on Solana devnet 2026-11-29).
177
+ maxSupportedTransactionVersion: 1,
175
178
  commitment: "confirmed",
176
179
  })
177
180
  .send()) ?? undefined, () => rpc.getSlot({ commitment: "confirmed" }).send(), { blocks: SLOTS_BEFORE_MISSING });
@@ -214,7 +217,8 @@ async function expiredBlockhash(rpcUrl) {
214
217
  : await rpc
215
218
  .getBlock(old, {
216
219
  commitment: "finalized",
217
- maxSupportedTransactionVersion: 0,
220
+ // The same limit as the settlement read: a block that holds a version 1 transaction is read too.
221
+ maxSupportedTransactionVersion: 1,
218
222
  rewards: false,
219
223
  transactionDetails: "none",
220
224
  })
@@ -28,6 +28,14 @@ export interface ExpiredSigning {
28
28
  readonly terms: AlteredSigning;
29
29
  /** How long to hold the signed payment before sending it. */
30
30
  readonly holdMs: number;
31
+ /**
32
+ * After the hold, waits until the chain is past the payment's own expiry,
33
+ * read from the signed payload (`payload` is its `payload` field), and throws
34
+ * a CheckSetupError (no verdict) if it does not get there in time. Where a
35
+ * chain gives it, the lifetime can be long enough for the client to finish
36
+ * building the payment, and the check still sends it expired.
37
+ */
38
+ readonly untilExpired?: (payload: Record<string, unknown>, rpcUrl: string) => Promise<void>;
31
39
  }
32
40
  /**
33
41
  * One signed authorization of a payment, as the chain records its use
@@ -1166,22 +1166,27 @@ export function underpaymentVerdict(status, offered, advertised, reason) {
1166
1166
  * rejected.
1167
1167
  *
1168
1168
  * Each chain says how the payment is made to expire (`expiredSigning`): on
1169
- * Stellar and EVM it is signed with a one-second lifetime (the auth entry's
1170
- * expiration ledger, or `validBefore`, both derived from `maxTimeoutSeconds`)
1171
- * and held until that has passed; on Solana it is built on a blockhash already
1172
- * past its lifetime. It is sent claiming the advertised terms. An expired
1169
+ * EVM it is signed with a one-second lifetime (`validBefore`, derived from
1170
+ * `maxTimeoutSeconds`) and held until that has passed; on Stellar with a
1171
+ * lifetime long enough for the client to finish building it (the auth entry's
1172
+ * expiration ledger), then held until the chain is past that ledger; on Solana
1173
+ * it is built on a blockhash already past its lifetime. It is sent claiming the advertised terms. An expired
1173
1174
  * authorization cannot settle, so a target that serves it serves for nothing.
1174
1175
  */
1175
1176
  async function checkExpiredRejected(options) {
1176
1177
  const chain = chainFor(options.network);
1177
1178
  const rpcUrl = chain.resolveRpcUrl(options.network, options.rpcUrl);
1178
1179
  let holdMs = 0;
1180
+ let untilExpired;
1179
1181
  const { httpClient, paymentPayload, payUrl, entry } = await preparePayment(options, "X402-10", async (selected) => {
1180
1182
  const expired = await chain.expiredSigning(selected, rpcUrl);
1181
1183
  holdMs = expired.holdMs;
1184
+ untilExpired = expired.untilExpired;
1182
1185
  return expired.terms;
1183
1186
  });
1184
1187
  await new Promise((done) => setTimeout(done, holdMs));
1188
+ if (untilExpired !== undefined)
1189
+ await untilExpired(paymentPayload.payload, rpcUrl);
1185
1190
  const response = await sendPayment(entry, payUrl, withPaymentHeaders(options, httpClient.encodePaymentSignatureHeader(paymentPayload)));
1186
1191
  return expiredVerdict(response.status, await refusalReason(response));
1187
1192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wasit-dev/core",
3
- "version": "0.8.0-beta.2",
3
+ "version": "0.8.0-beta.3",
4
4
  "description": "Check suite for x402/MPP protocol-conformance testing on Stellar. Powers the wasit CLI and wasit-mcp server.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -39,22 +39,22 @@
39
39
  "typecheck": "tsc -p test/tsconfig.json"
40
40
  },
41
41
  "dependencies": {
42
- "@solana/kit": "^5.5.1",
42
+ "@solana/kit": "8.6.0",
43
43
  "@stellar/mpp": "^0.7.1",
44
44
  "@stellar/stellar-sdk": "^16.1.0",
45
- "@x402/evm": "^2.28.0",
46
- "@x402/fetch": "^2.28.0",
47
- "@x402/stellar": "^2.28.0",
48
- "@x402/svm": "^2.28.0",
45
+ "@x402/evm": "2.32.0",
46
+ "@x402/fetch": "2.32.0",
47
+ "@x402/stellar": "2.32.0",
48
+ "@x402/svm": "2.32.0",
49
49
  "mppx": "^0.8.14",
50
50
  "viem": "^2.57.3"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/express": "^5.0.6",
54
54
  "@types/node": "^26.1.1",
55
- "@x402/core": "^2.28.0",
56
- "@x402/express": "^2.28.0",
57
- "@x402/extensions": "^2.28.0",
55
+ "@x402/core": "2.32.0",
56
+ "@x402/express": "2.32.0",
57
+ "@x402/extensions": "2.32.0",
58
58
  "dotenv": "^17.4.2",
59
59
  "express": "^5.2.1",
60
60
  "tsx": "^4.23.1"