@routedock/routedock 0.3.1 → 0.4.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 (58) hide show
  1. package/README.md +113 -12
  2. package/dist/{MppSessionHandler-1EL8QBAn.d.cts → MppSessionHandler-3QfCHI5x.d.ts} +40 -2
  3. package/dist/{MppSessionHandler-Bq4S-JTE.d.ts → MppSessionHandler-xu4Kxu6N.d.cts} +40 -2
  4. package/dist/{ProviderRegistry-w4_hkI_1.d.ts → ProviderRegistry-D9KqyuH-.d.cts} +16 -36
  5. package/dist/{ProviderRegistry-CyZ5eryO.d.cts → ProviderRegistry-DVi2uzgk.d.ts} +16 -36
  6. package/dist/{RouteDockClient-CjM2VyOd.d.ts → RouteDockClient-6rmgkbYb.d.cts} +124 -144
  7. package/dist/{RouteDockClient-CXvWXix5.d.cts → RouteDockClient-CnAkxwrW.d.ts} +124 -144
  8. package/dist/{SessionReconciler-Bw-PoBVl.d.ts → SessionReconciler-Cce9MXO1.d.ts} +10 -3
  9. package/dist/{SessionReconciler-Cz2nuOlJ.d.cts → SessionReconciler-Dpe9qXdD.d.cts} +10 -3
  10. package/dist/{SessionStore-BaYiegP0.d.ts → SessionStore-DkLBxFQu.d.cts} +28 -3
  11. package/dist/{SessionStore-B4-Hi4H8.d.cts → SessionStore-_ZkoBzFY.d.ts} +28 -3
  12. package/dist/SpendStore-BUclV02i.d.ts +73 -0
  13. package/dist/SpendStore-s_dfcemj.d.cts +73 -0
  14. package/dist/client.cjs +767 -482
  15. package/dist/client.d.cts +80 -10
  16. package/dist/client.d.ts +80 -10
  17. package/dist/client.js +733 -463
  18. package/dist/index.cjs +1295 -585
  19. package/dist/index.d.cts +13 -10
  20. package/dist/index.d.ts +13 -10
  21. package/dist/index.js +1247 -554
  22. package/dist/logger-DVa7VT4c.d.cts +41 -0
  23. package/dist/logger-DVa7VT4c.d.ts +41 -0
  24. package/dist/network.cjs +57 -0
  25. package/dist/network.d.cts +72 -0
  26. package/dist/network.d.ts +72 -0
  27. package/dist/network.js +49 -0
  28. package/dist/node.cjs +166 -0
  29. package/dist/node.d.cts +77 -0
  30. package/dist/node.d.ts +77 -0
  31. package/dist/node.js +159 -0
  32. package/dist/provider/fastify.cjs +847 -62
  33. package/dist/provider/fastify.d.cts +10 -3
  34. package/dist/provider/fastify.d.ts +10 -3
  35. package/dist/provider/fastify.js +848 -63
  36. package/dist/provider/hono.cjs +936 -60
  37. package/dist/provider/hono.d.cts +23 -8
  38. package/dist/provider/hono.d.ts +23 -8
  39. package/dist/provider/hono.js +937 -61
  40. package/dist/provider.cjs +894 -70
  41. package/dist/provider.d.cts +9 -8
  42. package/dist/provider.d.ts +9 -8
  43. package/dist/provider.js +895 -72
  44. package/dist/react.cjs +736 -431
  45. package/dist/react.d.cts +7 -5
  46. package/dist/react.d.ts +7 -5
  47. package/dist/react.js +725 -420
  48. package/dist/{routedockMiddleware-57gUaEMf.d.ts → routedockMiddleware-Cq9HOJEa.d.ts} +9 -2
  49. package/dist/{routedockMiddleware-DlyLrxp7.d.cts → routedockMiddleware-CxsWkSKa.d.cts} +9 -2
  50. package/dist/schema.cjs +7 -0
  51. package/dist/schema.js +7 -0
  52. package/dist/{sign-AKH67sft.d.cts → sign-Bq08SeFq.d.ts} +2 -2
  53. package/dist/{sign-BEq-OsSq.d.ts → sign-DqGE0Plv.d.cts} +2 -2
  54. package/dist/testing.d.cts +4 -3
  55. package/dist/testing.d.ts +4 -3
  56. package/dist/{logger-D8_Q2ytp.d.cts → types-DXaS5Wip.d.cts} +85 -47
  57. package/dist/{logger-D8_Q2ytp.d.ts → types-DXaS5Wip.d.ts} +85 -47
  58. package/package.json +50 -4
package/dist/client.d.cts CHANGED
@@ -1,15 +1,82 @@
1
- import { g as RouteDockLogger, h as RouteDockManifest, n as SessionOptions, m as SessionHandle } from './logger-D8_Q2ytp.cjs';
2
- export { A as AssetConfig, D as DEFAULT_MAX_SESSION_DURATION_MS, a as DisputeStatus, E as EndpointDescriptor, b as EstimateCostResult, P as PaymentMode, c as PaymentResult, d as PreflightResult, e as PricingConfig, R as RouteDockLogFields, f as RouteDockLogLevel, S as SLAConfig, i as SessionCloseFailedPayload, j as SessionCloseResult, k as SessionEvent, l as SessionEventPayloadMap, o as SessionPricingConfig, p as SessionState, q as SessionStats, r as SessionTimeoutPayload, s as StreamOptions, V as VaultMode, t as consoleLogger, u as createConsoleLogger, v as noopLogger, w as resolveLogger } from './logger-D8_Q2ytp.cjs';
3
- export { R as RouteDockChannelStateError, a as RouteDockClientVersionError, b as RouteDockDisputeError, c as RouteDockError, d as RouteDockErrorCode, e as RouteDockErrorOptions, f as RouteDockFacilitatorError, g as RouteDockManifestError, h as RouteDockManifestSunsetError, i as RouteDockManifestTimeoutError, j as RouteDockNetworkError, k as RouteDockNoSupportedModeError, l as RouteDockPolicyRejectError, m as RouteDockPolicyRejectedError, n as RouteDockRefundWindowError, o as RouteDockSessionError, p as RouteDockSignatureError, q as RouteDockTrustlineError, r as RouteDockVoucherMonotonicityError, S as SessionStore, s as SupabaseSessionStore, t as getEligibleAssets, u as httpStatusToError, v as isAssetEligible, w as normalizeManifestAssets, x as parseRetryAfterMs, y as resolveAssetContract, z as selectAsset, A as wrapFetchError, B as wrapMppError } from './SessionStore-B4-Hi4H8.cjs';
4
- import { R as RetryPolicy } from './RouteDockClient-CXvWXix5.cjs';
5
- export { D as DEFAULT_RETRY_POLICY, a as DailySpend, I as InMemorySpendStore, b as InMemorySpendStoreOptions, M as ModeSelectOptions, N as NulthAuthSignature, c as NulthClientConfig, d as NulthPolicyError, e as NulthPolicyState, f as NulthProof, g as NulthSignerConfig, h as NulthStellarSigner, i as NulthVaultConfig, P as PaymentAuthContext, j as RouteDockClient, k as RouteDockClientConfig, S as SpendCap, l as SpendStore, V as VaultConfig, m as assertEndpointActive, n as assertManifestValid, o as assertNulthVaultManifest, p as backoffDelayMs, q as configureManifestCache, r as createNulthSigner, s as createPolicyState, t as decodeAuthSignature, u as fetchLedgerSequence, v as fetchManifest, w as invalidateManifest, x as paymentContextFromManifest, y as prepareNulthSigner, z as rankProvidersByLatency, A as selectMode, B as setNulthPaymentContext, C as usdcToMicros, E as withRetry } from './RouteDockClient-CXvWXix5.cjs';
6
- export { F as FileSpendStore, M as MppChargeClient, O as OnChainProviderInfo, a as OnChainRegistry, P as ProviderRecord, b as ProviderRegistry, c as ProviderRegistryConfig, X as X402Client, u as usdcToUnits } from './ProviderRegistry-CyZ5eryO.cjs';
1
+ import { R as RouteDockManifest, n as SessionOptions, m as SessionHandle } from './types-DXaS5Wip.cjs';
2
+ export { A as AssetConfig, D as DEFAULT_MAX_SESSION_DURATION_MS, a as DisputeStatus, E as EndpointDescriptor, b as EstimateCostResult, P as PaymentMode, c as PaymentRequest, d as PaymentResult, e as PreflightComplianceFlags, f as PreflightModeCost, g as PreflightResult, h as PricingConfig, S as SLAConfig, i as SessionCloseFailedPayload, j as SessionCloseResult, k as SessionEvent, l as SessionEventPayloadMap, o as SessionPricingConfig, p as SessionState, q as SessionStats, r as SessionTimeoutPayload, s as StreamOptions, U as UrlPreflightResult, V as VaultMode } from './types-DXaS5Wip.cjs';
3
+ export { R as RouteDockChannelStateError, a as RouteDockClientVersionError, b as RouteDockDisputeError, c as RouteDockError, d as RouteDockErrorCode, e as RouteDockErrorOptions, f as RouteDockFacilitatorError, g as RouteDockManifestError, h as RouteDockManifestSunsetError, i as RouteDockManifestTimeoutError, j as RouteDockNetworkError, k as RouteDockNoSupportedModeError, l as RouteDockPaymentRejectedError, m as RouteDockPolicyRejectError, n as RouteDockPolicyRejectedError, o as RouteDockRefundWindowError, p as RouteDockSessionError, q as RouteDockSignatureError, r as RouteDockTrustlineError, s as RouteDockVoucherMonotonicityError, S as SessionStore, t as SupabaseSessionStore, u as getEligibleAssets, v as httpStatusToError, w as isAssetEligible, x as normalizeManifestAssets, y as parseRetryAfterMs, z as paymentRejectedError, A as resolveAssetContract, B as selectAsset, C as wrapFetchError, D as wrapMppError } from './SessionStore-DkLBxFQu.cjs';
4
+ import { R as RetryPolicy } from './RouteDockClient-6rmgkbYb.cjs';
5
+ export { D as DEFAULT_RETRY_POLICY, M as ModeSelectOptions, N as NulthVaultConfig, a as RouteDockClient, b as RouteDockClientConfig, S as SpendCap, V as VaultConfig, X as X402Client, c as X402PreSignContext, d as X402PreSignDecision, e as X402PreSignHook, f as assertEndpointActive, g as assertNulthVaultManifest, h as backoffDelayMs, i as configureManifestCache, j as createNulthSigner, k as fetchLedgerSequence, l as fetchManifest, m as invalidateManifest, p as prepareNulthSigner, r as rankProvidersByLatency, s as selectMode, u as usdcToMicros, w as withRetry } from './RouteDockClient-6rmgkbYb.cjs';
6
+ import { b as RouteDockLogger } from './logger-DVa7VT4c.cjs';
7
+ export { R as RouteDockLogFields, a as RouteDockLogLevel, c as consoleLogger, d as createConsoleLogger, n as noopLogger, r as resolveLogger } from './logger-DVa7VT4c.cjs';
8
+ export { M as MppChargeClient, O as OnChainProviderInfo, a as OnChainRegistry, P as ProviderRecord, b as ProviderRegistry, c as ProviderRegistryConfig, d as assertManifestValid, u as usdcToUnits } from './ProviderRegistry-D9KqyuH-.cjs';
9
+ import { AssembledTransaction } from '@stellar/stellar-sdk/contract';
10
+ import { handleSimulationResult, ClientStellarSigner } from '@x402/stellar';
11
+ import { Network, SchemeNetworkClient, PaymentRequirements, PaymentPayloadResult } from '@x402/core/types';
12
+ import { NulthStellarSigner } from '@routedock/nulth-sdk';
13
+ export { NulthAuthSignature, NulthClientConfig, NulthPolicyError, NulthPolicyState, NulthProof, NulthSignerConfig, NulthStellarSigner, PaymentAuthContext, USDC_DECIMALS, createPolicyState, decodeAuthSignature, paymentContextFromManifest, setNulthPaymentContext, usdcToStroops } from '@routedock/nulth-sdk';
7
14
  import { Keypair } from '@stellar/stellar-sdk';
8
- export { USDC_DECIMALS, usdcToStroops } from '@routedock/nulth-sdk';
15
+ export { D as DailySpend, I as InMemorySpendStore, a as InMemorySpendStoreOptions, S as SpendStore } from './SpendStore-s_dfcemj.cjs';
9
16
  import 'mppx';
10
17
  import '@supabase/supabase-js';
11
- import '@x402/stellar';
12
- import '@stellar/stellar-sdk/contract';
18
+
19
+ /**
20
+ * Nulth-aware x402 scheme for Stellar (#552).
21
+ *
22
+ * `ExactStellarScheme` builds the `transfer` transaction correctly for a Nulth
23
+ * payer but signs it with stellar-sdk's default `authorizeEntry`, which reads the
24
+ * credential address as an ed25519 key and therefore throws
25
+ * `invalid version byte. expected 48, got 16` for the `C...` account contract —
26
+ * the proof could never reach the network. Everything else here mirrors the
27
+ * upstream scheme: the transaction, the expiry window, the signer assertions and
28
+ * the re-simulation that widens the footprint to cover `__check_auth`.
29
+ */
30
+ /** The transfer the scheme assembles, one field per payment requirement. */
31
+ interface NulthTransfer {
32
+ /** SAC contract holding the funds */
33
+ asset: string;
34
+ /** Nulth account contract paying */
35
+ from: string;
36
+ payTo: string;
37
+ /** Stroops, as the accepted requirement reports them */
38
+ amount: string;
39
+ networkPassphrase: string;
40
+ rpcUrl: string;
41
+ }
42
+ /** The subset of `AssembledTransaction` the scheme drives. */
43
+ interface NulthPaymentTransaction {
44
+ /** The assembled envelope the payload carries. */
45
+ readonly built?: {
46
+ toXDR(): string;
47
+ };
48
+ /** The latest simulation, which the resource footprint is read from. */
49
+ readonly simulation?: Parameters<typeof handleSimulationResult>[0];
50
+ /** Accounts holding an address credential that is still unsigned. */
51
+ needsNonInvokerSigningBy(): string[];
52
+ signAuthEntries(options: NulthSignAuthEntriesOptions): Promise<void>;
53
+ simulate(): Promise<unknown>;
54
+ }
55
+ /** `AssembledTransaction.signAuthEntries`' options, as the scheme uses them. */
56
+ type NulthSignAuthEntriesOptions = NonNullable<Parameters<AssembledTransaction<unknown>['signAuthEntries']>[0]>;
57
+ /**
58
+ * The two steps that need a network. They are injectable because a unit test
59
+ * cannot reach Soroban RPC, and the proof-carrying part of the scheme is the
60
+ * credential write, not the round trip.
61
+ */
62
+ interface NulthSchemeIo {
63
+ expirationLedger(network: Network, maxTimeoutSeconds: number): Promise<number>;
64
+ assemble(transfer: NulthTransfer): Promise<NulthPaymentTransaction>;
65
+ }
66
+ declare class NulthStellarScheme implements SchemeNetworkClient {
67
+ private readonly signer;
68
+ private readonly io;
69
+ readonly scheme = "exact";
70
+ constructor(signer: NulthStellarSigner, io?: NulthSchemeIo);
71
+ createPaymentPayload(x402Version: number, paymentRequirements: PaymentRequirements): Promise<PaymentPayloadResult>;
72
+ private validateRequirements;
73
+ }
74
+ /**
75
+ * Choose the scheme for a signer. A signer from `createNulthSigner` carries the
76
+ * Nulth marker and pays from a contract account, so it must not be wrapped in the
77
+ * stock ed25519 scheme; every other signer keeps `ExactStellarScheme` unchanged.
78
+ */
79
+ declare function selectStellarScheme(signer: ClientStellarSigner): SchemeNetworkClient;
13
80
 
14
81
  /**
15
82
  * MppSessionClient — uses @stellar/mpp channel/client for off-chain
@@ -20,6 +87,9 @@ import '@stellar/stellar-sdk/contract';
20
87
  * @stellar/mpp library handles the 402 challenge-response cycle.
21
88
  */
22
89
 
90
+ /** Polling parameters for on-chain transaction confirmation. */
91
+ declare const TX_CONFIRM_INTERVAL_MS = 1000;
92
+ declare const TX_CONFIRM_TIMEOUT_MS = 30000;
23
93
  /** A WebSocket socket as consumed by the mpp-session-ws stream. */
24
94
  interface WebSocketLike {
25
95
  readyState: number;
@@ -65,4 +135,4 @@ declare class MppSessionClient {
65
135
  private streamWebSocket;
66
136
  }
67
137
 
68
- export { MppSessionClient, RetryPolicy, RouteDockLogger, RouteDockManifest, SessionHandle, SessionOptions, type WebSocketFactory, type WebSocketHandlers, type WebSocketLike };
138
+ export { MppSessionClient, type NulthPaymentTransaction, type NulthSchemeIo, type NulthSignAuthEntriesOptions, NulthStellarScheme, type NulthTransfer, RetryPolicy, RouteDockLogger, RouteDockManifest, SessionHandle, SessionOptions, TX_CONFIRM_INTERVAL_MS, TX_CONFIRM_TIMEOUT_MS, type WebSocketFactory, type WebSocketHandlers, type WebSocketLike, selectStellarScheme };
package/dist/client.d.ts CHANGED
@@ -1,15 +1,82 @@
1
- import { g as RouteDockLogger, h as RouteDockManifest, n as SessionOptions, m as SessionHandle } from './logger-D8_Q2ytp.js';
2
- export { A as AssetConfig, D as DEFAULT_MAX_SESSION_DURATION_MS, a as DisputeStatus, E as EndpointDescriptor, b as EstimateCostResult, P as PaymentMode, c as PaymentResult, d as PreflightResult, e as PricingConfig, R as RouteDockLogFields, f as RouteDockLogLevel, S as SLAConfig, i as SessionCloseFailedPayload, j as SessionCloseResult, k as SessionEvent, l as SessionEventPayloadMap, o as SessionPricingConfig, p as SessionState, q as SessionStats, r as SessionTimeoutPayload, s as StreamOptions, V as VaultMode, t as consoleLogger, u as createConsoleLogger, v as noopLogger, w as resolveLogger } from './logger-D8_Q2ytp.js';
3
- export { R as RouteDockChannelStateError, a as RouteDockClientVersionError, b as RouteDockDisputeError, c as RouteDockError, d as RouteDockErrorCode, e as RouteDockErrorOptions, f as RouteDockFacilitatorError, g as RouteDockManifestError, h as RouteDockManifestSunsetError, i as RouteDockManifestTimeoutError, j as RouteDockNetworkError, k as RouteDockNoSupportedModeError, l as RouteDockPolicyRejectError, m as RouteDockPolicyRejectedError, n as RouteDockRefundWindowError, o as RouteDockSessionError, p as RouteDockSignatureError, q as RouteDockTrustlineError, r as RouteDockVoucherMonotonicityError, S as SessionStore, s as SupabaseSessionStore, t as getEligibleAssets, u as httpStatusToError, v as isAssetEligible, w as normalizeManifestAssets, x as parseRetryAfterMs, y as resolveAssetContract, z as selectAsset, A as wrapFetchError, B as wrapMppError } from './SessionStore-BaYiegP0.js';
4
- import { R as RetryPolicy } from './RouteDockClient-CjM2VyOd.js';
5
- export { D as DEFAULT_RETRY_POLICY, a as DailySpend, I as InMemorySpendStore, b as InMemorySpendStoreOptions, M as ModeSelectOptions, N as NulthAuthSignature, c as NulthClientConfig, d as NulthPolicyError, e as NulthPolicyState, f as NulthProof, g as NulthSignerConfig, h as NulthStellarSigner, i as NulthVaultConfig, P as PaymentAuthContext, j as RouteDockClient, k as RouteDockClientConfig, S as SpendCap, l as SpendStore, V as VaultConfig, m as assertEndpointActive, n as assertManifestValid, o as assertNulthVaultManifest, p as backoffDelayMs, q as configureManifestCache, r as createNulthSigner, s as createPolicyState, t as decodeAuthSignature, u as fetchLedgerSequence, v as fetchManifest, w as invalidateManifest, x as paymentContextFromManifest, y as prepareNulthSigner, z as rankProvidersByLatency, A as selectMode, B as setNulthPaymentContext, C as usdcToMicros, E as withRetry } from './RouteDockClient-CjM2VyOd.js';
6
- export { F as FileSpendStore, M as MppChargeClient, O as OnChainProviderInfo, a as OnChainRegistry, P as ProviderRecord, b as ProviderRegistry, c as ProviderRegistryConfig, X as X402Client, u as usdcToUnits } from './ProviderRegistry-w4_hkI_1.js';
1
+ import { R as RouteDockManifest, n as SessionOptions, m as SessionHandle } from './types-DXaS5Wip.js';
2
+ export { A as AssetConfig, D as DEFAULT_MAX_SESSION_DURATION_MS, a as DisputeStatus, E as EndpointDescriptor, b as EstimateCostResult, P as PaymentMode, c as PaymentRequest, d as PaymentResult, e as PreflightComplianceFlags, f as PreflightModeCost, g as PreflightResult, h as PricingConfig, S as SLAConfig, i as SessionCloseFailedPayload, j as SessionCloseResult, k as SessionEvent, l as SessionEventPayloadMap, o as SessionPricingConfig, p as SessionState, q as SessionStats, r as SessionTimeoutPayload, s as StreamOptions, U as UrlPreflightResult, V as VaultMode } from './types-DXaS5Wip.js';
3
+ export { R as RouteDockChannelStateError, a as RouteDockClientVersionError, b as RouteDockDisputeError, c as RouteDockError, d as RouteDockErrorCode, e as RouteDockErrorOptions, f as RouteDockFacilitatorError, g as RouteDockManifestError, h as RouteDockManifestSunsetError, i as RouteDockManifestTimeoutError, j as RouteDockNetworkError, k as RouteDockNoSupportedModeError, l as RouteDockPaymentRejectedError, m as RouteDockPolicyRejectError, n as RouteDockPolicyRejectedError, o as RouteDockRefundWindowError, p as RouteDockSessionError, q as RouteDockSignatureError, r as RouteDockTrustlineError, s as RouteDockVoucherMonotonicityError, S as SessionStore, t as SupabaseSessionStore, u as getEligibleAssets, v as httpStatusToError, w as isAssetEligible, x as normalizeManifestAssets, y as parseRetryAfterMs, z as paymentRejectedError, A as resolveAssetContract, B as selectAsset, C as wrapFetchError, D as wrapMppError } from './SessionStore-_ZkoBzFY.js';
4
+ import { R as RetryPolicy } from './RouteDockClient-CnAkxwrW.js';
5
+ export { D as DEFAULT_RETRY_POLICY, M as ModeSelectOptions, N as NulthVaultConfig, a as RouteDockClient, b as RouteDockClientConfig, S as SpendCap, V as VaultConfig, X as X402Client, c as X402PreSignContext, d as X402PreSignDecision, e as X402PreSignHook, f as assertEndpointActive, g as assertNulthVaultManifest, h as backoffDelayMs, i as configureManifestCache, j as createNulthSigner, k as fetchLedgerSequence, l as fetchManifest, m as invalidateManifest, p as prepareNulthSigner, r as rankProvidersByLatency, s as selectMode, u as usdcToMicros, w as withRetry } from './RouteDockClient-CnAkxwrW.js';
6
+ import { b as RouteDockLogger } from './logger-DVa7VT4c.js';
7
+ export { R as RouteDockLogFields, a as RouteDockLogLevel, c as consoleLogger, d as createConsoleLogger, n as noopLogger, r as resolveLogger } from './logger-DVa7VT4c.js';
8
+ export { M as MppChargeClient, O as OnChainProviderInfo, a as OnChainRegistry, P as ProviderRecord, b as ProviderRegistry, c as ProviderRegistryConfig, d as assertManifestValid, u as usdcToUnits } from './ProviderRegistry-DVi2uzgk.js';
9
+ import { AssembledTransaction } from '@stellar/stellar-sdk/contract';
10
+ import { handleSimulationResult, ClientStellarSigner } from '@x402/stellar';
11
+ import { Network, SchemeNetworkClient, PaymentRequirements, PaymentPayloadResult } from '@x402/core/types';
12
+ import { NulthStellarSigner } from '@routedock/nulth-sdk';
13
+ export { NulthAuthSignature, NulthClientConfig, NulthPolicyError, NulthPolicyState, NulthProof, NulthSignerConfig, NulthStellarSigner, PaymentAuthContext, USDC_DECIMALS, createPolicyState, decodeAuthSignature, paymentContextFromManifest, setNulthPaymentContext, usdcToStroops } from '@routedock/nulth-sdk';
7
14
  import { Keypair } from '@stellar/stellar-sdk';
8
- export { USDC_DECIMALS, usdcToStroops } from '@routedock/nulth-sdk';
15
+ export { D as DailySpend, I as InMemorySpendStore, a as InMemorySpendStoreOptions, S as SpendStore } from './SpendStore-BUclV02i.js';
9
16
  import 'mppx';
10
17
  import '@supabase/supabase-js';
11
- import '@x402/stellar';
12
- import '@stellar/stellar-sdk/contract';
18
+
19
+ /**
20
+ * Nulth-aware x402 scheme for Stellar (#552).
21
+ *
22
+ * `ExactStellarScheme` builds the `transfer` transaction correctly for a Nulth
23
+ * payer but signs it with stellar-sdk's default `authorizeEntry`, which reads the
24
+ * credential address as an ed25519 key and therefore throws
25
+ * `invalid version byte. expected 48, got 16` for the `C...` account contract —
26
+ * the proof could never reach the network. Everything else here mirrors the
27
+ * upstream scheme: the transaction, the expiry window, the signer assertions and
28
+ * the re-simulation that widens the footprint to cover `__check_auth`.
29
+ */
30
+ /** The transfer the scheme assembles, one field per payment requirement. */
31
+ interface NulthTransfer {
32
+ /** SAC contract holding the funds */
33
+ asset: string;
34
+ /** Nulth account contract paying */
35
+ from: string;
36
+ payTo: string;
37
+ /** Stroops, as the accepted requirement reports them */
38
+ amount: string;
39
+ networkPassphrase: string;
40
+ rpcUrl: string;
41
+ }
42
+ /** The subset of `AssembledTransaction` the scheme drives. */
43
+ interface NulthPaymentTransaction {
44
+ /** The assembled envelope the payload carries. */
45
+ readonly built?: {
46
+ toXDR(): string;
47
+ };
48
+ /** The latest simulation, which the resource footprint is read from. */
49
+ readonly simulation?: Parameters<typeof handleSimulationResult>[0];
50
+ /** Accounts holding an address credential that is still unsigned. */
51
+ needsNonInvokerSigningBy(): string[];
52
+ signAuthEntries(options: NulthSignAuthEntriesOptions): Promise<void>;
53
+ simulate(): Promise<unknown>;
54
+ }
55
+ /** `AssembledTransaction.signAuthEntries`' options, as the scheme uses them. */
56
+ type NulthSignAuthEntriesOptions = NonNullable<Parameters<AssembledTransaction<unknown>['signAuthEntries']>[0]>;
57
+ /**
58
+ * The two steps that need a network. They are injectable because a unit test
59
+ * cannot reach Soroban RPC, and the proof-carrying part of the scheme is the
60
+ * credential write, not the round trip.
61
+ */
62
+ interface NulthSchemeIo {
63
+ expirationLedger(network: Network, maxTimeoutSeconds: number): Promise<number>;
64
+ assemble(transfer: NulthTransfer): Promise<NulthPaymentTransaction>;
65
+ }
66
+ declare class NulthStellarScheme implements SchemeNetworkClient {
67
+ private readonly signer;
68
+ private readonly io;
69
+ readonly scheme = "exact";
70
+ constructor(signer: NulthStellarSigner, io?: NulthSchemeIo);
71
+ createPaymentPayload(x402Version: number, paymentRequirements: PaymentRequirements): Promise<PaymentPayloadResult>;
72
+ private validateRequirements;
73
+ }
74
+ /**
75
+ * Choose the scheme for a signer. A signer from `createNulthSigner` carries the
76
+ * Nulth marker and pays from a contract account, so it must not be wrapped in the
77
+ * stock ed25519 scheme; every other signer keeps `ExactStellarScheme` unchanged.
78
+ */
79
+ declare function selectStellarScheme(signer: ClientStellarSigner): SchemeNetworkClient;
13
80
 
14
81
  /**
15
82
  * MppSessionClient — uses @stellar/mpp channel/client for off-chain
@@ -20,6 +87,9 @@ import '@stellar/stellar-sdk/contract';
20
87
  * @stellar/mpp library handles the 402 challenge-response cycle.
21
88
  */
22
89
 
90
+ /** Polling parameters for on-chain transaction confirmation. */
91
+ declare const TX_CONFIRM_INTERVAL_MS = 1000;
92
+ declare const TX_CONFIRM_TIMEOUT_MS = 30000;
23
93
  /** A WebSocket socket as consumed by the mpp-session-ws stream. */
24
94
  interface WebSocketLike {
25
95
  readyState: number;
@@ -65,4 +135,4 @@ declare class MppSessionClient {
65
135
  private streamWebSocket;
66
136
  }
67
137
 
68
- export { MppSessionClient, RetryPolicy, RouteDockLogger, RouteDockManifest, SessionHandle, SessionOptions, type WebSocketFactory, type WebSocketHandlers, type WebSocketLike };
138
+ export { MppSessionClient, type NulthPaymentTransaction, type NulthSchemeIo, type NulthSignAuthEntriesOptions, NulthStellarScheme, type NulthTransfer, RetryPolicy, RouteDockLogger, RouteDockManifest, SessionHandle, SessionOptions, TX_CONFIRM_INTERVAL_MS, TX_CONFIRM_TIMEOUT_MS, type WebSocketFactory, type WebSocketHandlers, type WebSocketLike, selectStellarScheme };