@routedock/routedock 0.1.1 → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +281 -19
- package/dist/MppSessionHandler-B4TyD7Xg.d.cts +121 -0
- package/dist/MppSessionHandler-CLB5SzgN.d.ts +121 -0
- package/dist/ProviderRegistry-BJ9oJLVz.d.cts +142 -0
- package/dist/ProviderRegistry-C50nyhaF.d.ts +142 -0
- package/dist/RouteDockClient-B1roCa8h.d.cts +455 -0
- package/dist/RouteDockClient-BbkqjhMG.d.ts +455 -0
- package/dist/SessionReconciler-Dscw43F3.d.ts +125 -0
- package/dist/SessionReconciler-bi0z2qtN.d.cts +125 -0
- package/dist/SessionStore-BpK8vv0L.d.cts +111 -0
- package/dist/SessionStore-DvkZv8-E.d.ts +111 -0
- package/dist/client.cjs +2419 -202
- package/dist/client.d.cts +50 -81
- package/dist/client.d.ts +50 -81
- package/dist/client.js +2373 -203
- package/dist/index.cjs +3080 -298
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +3026 -298
- package/dist/provider/fastify.cjs +882 -0
- package/dist/provider/fastify.d.cts +35 -0
- package/dist/provider/fastify.d.ts +35 -0
- package/dist/provider/fastify.js +880 -0
- package/dist/provider/hono.cjs +948 -0
- package/dist/provider/hono.d.cts +99 -0
- package/dist/provider/hono.d.ts +99 -0
- package/dist/provider/hono.js +938 -0
- package/dist/provider.cjs +827 -97
- package/dist/provider.d.cts +32 -25
- package/dist/provider.d.ts +32 -25
- package/dist/provider.js +810 -99
- package/dist/react.cjs +2641 -0
- package/dist/react.d.cts +107 -0
- package/dist/react.d.ts +107 -0
- package/dist/react.js +2634 -0
- package/dist/routedockMiddleware-BlDsHuPl.d.ts +59 -0
- package/dist/routedockMiddleware-D97A5ptQ.d.cts +59 -0
- package/dist/schema.cjs +364 -0
- package/dist/schema.d.cts +3 -0
- package/dist/schema.d.ts +3 -0
- package/dist/schema.js +359 -0
- package/dist/sign-CUf3rhTx.d.cts +53 -0
- package/dist/sign-Dpj2Mp7k.d.ts +53 -0
- package/dist/testing.cjs +57 -0
- package/dist/testing.d.cts +95 -0
- package/dist/testing.d.ts +95 -0
- package/dist/testing.js +54 -0
- package/dist/types-DmhmfLzP.d.cts +410 -0
- package/dist/types-DmhmfLzP.d.ts +410 -0
- package/package.json +143 -23
- package/PUBLISH_CHECKLIST.md +0 -70
- package/dist/SessionStore-CCVO0PHM.d.cts +0 -152
- package/dist/SessionStore-CCVO0PHM.d.ts +0 -152
- package/dist/routedockMiddleware-B7WTB3LT.d.cts +0 -53
- package/dist/routedockMiddleware-DRgdrycG.d.ts +0 -53
- package/src/client/ModeRouter.ts +0 -104
- package/src/client/MppChargeClient.ts +0 -44
- package/src/client/MppSessionClient.ts +0 -144
- package/src/client/RouteDockClient.ts +0 -124
- package/src/client/index.ts +0 -8
- package/src/client/x402Client.ts +0 -84
- package/src/index.ts +0 -9
- package/src/provider/MppChargeHandler.ts +0 -90
- package/src/provider/MppSessionHandler.ts +0 -157
- package/src/provider/index.ts +0 -7
- package/src/provider/routedockMiddleware.ts +0 -154
- package/src/provider/x402Handler.ts +0 -164
- package/src/schemas/routedock.schema.json +0 -159
- package/src/store/SessionStore.ts +0 -90
- package/src/tests/smoke.test.ts +0 -228
- package/src/types.ts +0 -165
- package/tsconfig.json +0 -14
- package/tsup.config.ts +0 -15
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { S as SeenTxStore, a as SettlementRecord } from './MppSessionHandler-B4TyD7Xg.cjs';
|
|
3
|
+
import { R as RouteDockManifest } from './types-DmhmfLzP.cjs';
|
|
4
|
+
import { Keypair } from '@stellar/stellar-sdk';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Settlement idempotency backed by Postgres via Supabase.
|
|
8
|
+
*
|
|
9
|
+
* The in-memory default {@link InMemorySeenTxStore} is per-handler and
|
|
10
|
+
* per-process. On serverless/edge runtimes (Cloudflare Workers, Deno Deploy,
|
|
11
|
+
* Lambda@Edge) each request may land in a fresh isolate with an empty cache.
|
|
12
|
+
* An agent retrying after a post-settlement timeout would miss the cache and
|
|
13
|
+
* settle a second time, charging twice on-chain.
|
|
14
|
+
*
|
|
15
|
+
* Postgres gives the read-your-writes consistency this needs; Workers KV
|
|
16
|
+
* would not, since a retry can outrun propagation and reintroduce the double
|
|
17
|
+
* settle.
|
|
18
|
+
*
|
|
19
|
+
* Requires the `settlements` table from migration `003_settlement_idempotency`:
|
|
20
|
+
*
|
|
21
|
+
* ```sql
|
|
22
|
+
* CREATE TABLE settlements (
|
|
23
|
+
* key TEXT PRIMARY KEY,
|
|
24
|
+
* tx_hash TEXT,
|
|
25
|
+
* headers JSONB,
|
|
26
|
+
* created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
27
|
+
* );
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { SupabaseSeenTxStore } from '@routedock/routedock/store'
|
|
33
|
+
* import { createClient } from '@supabase/supabase-js'
|
|
34
|
+
*
|
|
35
|
+
* const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_KEY!)
|
|
36
|
+
* const seenTxStore = new SupabaseSeenTxStore(supabase)
|
|
37
|
+
*
|
|
38
|
+
* routedockHono({ ..., seenTxStore })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare class SupabaseSeenTxStore implements SeenTxStore {
|
|
42
|
+
private readonly supabase;
|
|
43
|
+
constructor(supabase: SupabaseClient);
|
|
44
|
+
get(key: string): Promise<SettlementRecord | undefined>;
|
|
45
|
+
set(key: string, record: SettlementRecord): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface RegisterProviderOptions {
|
|
49
|
+
supabase: SupabaseClient;
|
|
50
|
+
manifest: RouteDockManifest & {
|
|
51
|
+
signature?: string;
|
|
52
|
+
signature_version?: string;
|
|
53
|
+
};
|
|
54
|
+
baseUrl: string;
|
|
55
|
+
/**
|
|
56
|
+
* Whether to flag the provider record as verified in Supabase.
|
|
57
|
+
* Defaults to true (since signature is verified before writing).
|
|
58
|
+
*/
|
|
59
|
+
verified?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Register a provider in the Supabase `providers` table.
|
|
63
|
+
*
|
|
64
|
+
* Verifies the manifest's Ed25519 signature before upserting into the
|
|
65
|
+
* database keyed on `base_url`.
|
|
66
|
+
*
|
|
67
|
+
* Throws `RouteDockSignatureError` if the manifest is unsigned or invalid,
|
|
68
|
+
* and `Error` if the database upsert fails.
|
|
69
|
+
*/
|
|
70
|
+
declare function registerProvider(optionsOrSupabase: RegisterProviderOptions | SupabaseClient, manifestArg?: RouteDockManifest & {
|
|
71
|
+
signature?: string;
|
|
72
|
+
}, baseUrlArg?: string, verifiedArg?: boolean): Promise<void>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Session Reconciler — Recovery mechanism for orphaned MPP sessions
|
|
76
|
+
*
|
|
77
|
+
* Scans Supabase for sessions marked as "closing" (client initiated close but
|
|
78
|
+
* provider crashed before broadcasting settlement). Recovers abandoned funds by
|
|
79
|
+
* broadcasting the channel close transaction with the latest signed commitment.
|
|
80
|
+
*
|
|
81
|
+
* Idempotent: Safe to run multiple times on the same session (settlement_tx_hash
|
|
82
|
+
* acts as deduplication key).
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
type Network = 'testnet' | 'mainnet';
|
|
86
|
+
type ChannelCloseFn = (args: {
|
|
87
|
+
channel: string;
|
|
88
|
+
amount: bigint;
|
|
89
|
+
signature: Buffer;
|
|
90
|
+
feePayer: {
|
|
91
|
+
envelopeSigner: Keypair;
|
|
92
|
+
};
|
|
93
|
+
network: 'stellar:testnet' | 'stellar:pubnet';
|
|
94
|
+
}) => Promise<string>;
|
|
95
|
+
interface SessionReconcilerOptions {
|
|
96
|
+
supabase: SupabaseClient;
|
|
97
|
+
network: Network;
|
|
98
|
+
payeeSecretKey: string;
|
|
99
|
+
onRecovered?: (channelId: string, txHash: string, totalPaid: string) => Promise<void>;
|
|
100
|
+
/** Injectable for testing. Defaults to @stellar/mpp/channel/server close() */
|
|
101
|
+
channelClose?: ChannelCloseFn;
|
|
102
|
+
}
|
|
103
|
+
interface ReconciliationStats {
|
|
104
|
+
orphanedCount: number;
|
|
105
|
+
recoveredCount: number;
|
|
106
|
+
skippedCount: number;
|
|
107
|
+
failedCount: number;
|
|
108
|
+
errors: Array<{
|
|
109
|
+
channelId: string;
|
|
110
|
+
reason: string;
|
|
111
|
+
}>;
|
|
112
|
+
}
|
|
113
|
+
declare function decimalToStroops(amountStr: string): bigint;
|
|
114
|
+
/**
|
|
115
|
+
* Scan for abandoned sessions and attempt recovery.
|
|
116
|
+
* Idempotent: sessions with settlement_tx_hash are skipped (already recovered).
|
|
117
|
+
*/
|
|
118
|
+
declare function reconcileAbandonedSessions(opts: SessionReconcilerOptions): Promise<ReconciliationStats>;
|
|
119
|
+
/**
|
|
120
|
+
* Run reconciliation on provider startup.
|
|
121
|
+
* Logs results and recovers orphaned sessions before accepting new connections.
|
|
122
|
+
*/
|
|
123
|
+
declare function runStartupReconciliation(opts: SessionReconcilerOptions, logger?: (msg: string) => void): Promise<void>;
|
|
124
|
+
|
|
125
|
+
export { type ReconciliationStats as R, type SessionReconcilerOptions as S, type RegisterProviderOptions as a, SupabaseSeenTxStore as b, registerProvider as c, decimalToStroops as d, runStartupReconciliation as e, reconcileAbandonedSessions as r };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { m as SessionState } from './types-DmhmfLzP.cjs';
|
|
3
|
+
|
|
4
|
+
/** Stable error codes for programmatic handling. */
|
|
5
|
+
type RouteDockErrorCode = 'MANIFEST' | 'MANIFEST_TIMEOUT' | 'MANIFEST_SUNSET' | 'NO_SUPPORTED_MODE' | 'FACILITATOR' | 'NETWORK' | 'SIGNATURE' | 'VOUCHER_MONOTONICITY' | 'POLICY_REJECT' | 'CHANNEL_STATE' | 'DISPUTE' | 'REFUND_WINDOW' | 'CLIENT_VERSION_TOO_OLD' | 'TRUSTLINE';
|
|
6
|
+
interface RouteDockErrorOptions {
|
|
7
|
+
cause?: unknown;
|
|
8
|
+
/** Milliseconds to wait before retry (e.g. from Retry-After header). */
|
|
9
|
+
retryAfterMs?: number;
|
|
10
|
+
}
|
|
11
|
+
/** Base error for all RouteDock SDK failures. */
|
|
12
|
+
declare class RouteDockError extends Error {
|
|
13
|
+
readonly code: RouteDockErrorCode;
|
|
14
|
+
readonly retryable: boolean;
|
|
15
|
+
readonly retryAfterMs?: number;
|
|
16
|
+
constructor(message: string, code: RouteDockErrorCode, retryable: boolean, options?: RouteDockErrorOptions);
|
|
17
|
+
}
|
|
18
|
+
/** Manifest fetch failed, schema invalid, or required fields missing. */
|
|
19
|
+
declare class RouteDockManifestError extends RouteDockError {
|
|
20
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
21
|
+
}
|
|
22
|
+
/** Manifest fetch exceeded the configured timeout without receiving a response. */
|
|
23
|
+
declare class RouteDockManifestTimeoutError extends RouteDockError {
|
|
24
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
25
|
+
}
|
|
26
|
+
/** The provider's signed manifest has reached its declared sunset timestamp. */
|
|
27
|
+
declare class RouteDockManifestSunsetError extends RouteDockError {
|
|
28
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
29
|
+
}
|
|
30
|
+
/** No payment mode in the manifest is supported by this client. */
|
|
31
|
+
declare class RouteDockNoSupportedModeError extends RouteDockError {
|
|
32
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
33
|
+
}
|
|
34
|
+
/** This client's SDK version is below the manifest's min_client_version. Upgrade the SDK to proceed. */
|
|
35
|
+
declare class RouteDockClientVersionError extends RouteDockError {
|
|
36
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Account is missing a trustline for the payment asset.
|
|
40
|
+
* Thrown preflight — before any payment transaction is submitted —
|
|
41
|
+
* so the caller can establish the trustline first.
|
|
42
|
+
*/
|
|
43
|
+
declare class RouteDockTrustlineError extends RouteDockError {
|
|
44
|
+
readonly asset: string;
|
|
45
|
+
readonly issuer: string;
|
|
46
|
+
readonly remediation: string;
|
|
47
|
+
constructor(asset: string, issuer: string, remediation: string, options?: RouteDockErrorOptions);
|
|
48
|
+
}
|
|
49
|
+
/** x402 facilitator or provider returned a retryable HTTP failure (5xx, 429). */
|
|
50
|
+
declare class RouteDockFacilitatorError extends RouteDockError {
|
|
51
|
+
readonly status: number;
|
|
52
|
+
constructor(message: string, status: number, options?: RouteDockErrorOptions);
|
|
53
|
+
}
|
|
54
|
+
/** Transient network failure (timeouts, connection reset, unreachable host). */
|
|
55
|
+
declare class RouteDockNetworkError extends RouteDockError {
|
|
56
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
57
|
+
}
|
|
58
|
+
/** Payment or commitment signature could not be produced or verified. */
|
|
59
|
+
declare class RouteDockSignatureError extends RouteDockError {
|
|
60
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
61
|
+
}
|
|
62
|
+
/** Voucher cumulative amount did not increase monotonically. */
|
|
63
|
+
declare class RouteDockVoucherMonotonicityError extends RouteDockError {
|
|
64
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
65
|
+
}
|
|
66
|
+
/** Local spend cap or on-chain policy rejected the payment. */
|
|
67
|
+
declare class RouteDockPolicyRejectError extends RouteDockError {
|
|
68
|
+
readonly reason: string;
|
|
69
|
+
constructor(reason: string, options?: RouteDockErrorOptions);
|
|
70
|
+
}
|
|
71
|
+
/** Channel lifecycle failure (open, simulate, close, missing settlement fields). */
|
|
72
|
+
declare class RouteDockChannelStateError extends RouteDockError {
|
|
73
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
74
|
+
}
|
|
75
|
+
/** Channel dispute operation failed (refund request, settlement, or contract invariant). */
|
|
76
|
+
declare class RouteDockDisputeError extends RouteDockError {
|
|
77
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
78
|
+
}
|
|
79
|
+
/** Refund window has not yet opened or has already expired. */
|
|
80
|
+
declare class RouteDockRefundWindowError extends RouteDockError {
|
|
81
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
82
|
+
}
|
|
83
|
+
/** @deprecated Use {@link RouteDockPolicyRejectError} */
|
|
84
|
+
declare const RouteDockPolicyRejectedError: typeof RouteDockPolicyRejectError;
|
|
85
|
+
/** @deprecated Use {@link RouteDockVoucherMonotonicityError} or {@link RouteDockChannelStateError} */
|
|
86
|
+
declare const RouteDockSessionError: typeof RouteDockVoucherMonotonicityError;
|
|
87
|
+
/** Parse Retry-After from a Response (seconds or HTTP-date). */
|
|
88
|
+
declare function parseRetryAfterMs(response: Response): number | undefined;
|
|
89
|
+
/** Map an HTTP status to a typed, retryable-aware RouteDock error. */
|
|
90
|
+
declare function httpStatusToError(message: string, status: number, response?: Response): RouteDockError;
|
|
91
|
+
/** Wrap a low-level fetch failure; preserves existing RouteDockErrors. */
|
|
92
|
+
declare function wrapFetchError(err: unknown, context: string): RouteDockError;
|
|
93
|
+
|
|
94
|
+
interface SessionStore {
|
|
95
|
+
get(channelId: string): Promise<SessionState | null>;
|
|
96
|
+
/** Enforce monotonic invariant at application level before writing (used for voucher amount advances) */
|
|
97
|
+
upsert(channelId: string, state: SessionState): Promise<void>;
|
|
98
|
+
/** Update session status without altering cumulative_amount */
|
|
99
|
+
setStatus(channelId: string, status: SessionState['status'], settlementTxHash?: string | null): Promise<void>;
|
|
100
|
+
close(channelId: string): Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
declare class SupabaseSessionStore implements SessionStore {
|
|
103
|
+
private readonly supabase;
|
|
104
|
+
constructor(supabase: SupabaseClient);
|
|
105
|
+
get(channelId: string): Promise<SessionState | null>;
|
|
106
|
+
upsert(channelId: string, state: SessionState): Promise<void>;
|
|
107
|
+
setStatus(channelId: string, status: SessionState['status'], settlementTxHash?: string | null): Promise<void>;
|
|
108
|
+
close(channelId: string): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { RouteDockChannelStateError as R, type SessionStore as S, RouteDockClientVersionError as a, RouteDockDisputeError as b, RouteDockError as c, type RouteDockErrorCode as d, type RouteDockErrorOptions as e, RouteDockFacilitatorError as f, RouteDockManifestError as g, RouteDockManifestSunsetError as h, RouteDockManifestTimeoutError as i, RouteDockNetworkError as j, RouteDockNoSupportedModeError as k, RouteDockPolicyRejectError as l, RouteDockPolicyRejectedError as m, RouteDockRefundWindowError as n, RouteDockSessionError as o, RouteDockSignatureError as p, RouteDockTrustlineError as q, RouteDockVoucherMonotonicityError as r, SupabaseSessionStore as s, httpStatusToError as t, parseRetryAfterMs as u, wrapFetchError as w };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { m as SessionState } from './types-DmhmfLzP.js';
|
|
3
|
+
|
|
4
|
+
/** Stable error codes for programmatic handling. */
|
|
5
|
+
type RouteDockErrorCode = 'MANIFEST' | 'MANIFEST_TIMEOUT' | 'MANIFEST_SUNSET' | 'NO_SUPPORTED_MODE' | 'FACILITATOR' | 'NETWORK' | 'SIGNATURE' | 'VOUCHER_MONOTONICITY' | 'POLICY_REJECT' | 'CHANNEL_STATE' | 'DISPUTE' | 'REFUND_WINDOW' | 'CLIENT_VERSION_TOO_OLD' | 'TRUSTLINE';
|
|
6
|
+
interface RouteDockErrorOptions {
|
|
7
|
+
cause?: unknown;
|
|
8
|
+
/** Milliseconds to wait before retry (e.g. from Retry-After header). */
|
|
9
|
+
retryAfterMs?: number;
|
|
10
|
+
}
|
|
11
|
+
/** Base error for all RouteDock SDK failures. */
|
|
12
|
+
declare class RouteDockError extends Error {
|
|
13
|
+
readonly code: RouteDockErrorCode;
|
|
14
|
+
readonly retryable: boolean;
|
|
15
|
+
readonly retryAfterMs?: number;
|
|
16
|
+
constructor(message: string, code: RouteDockErrorCode, retryable: boolean, options?: RouteDockErrorOptions);
|
|
17
|
+
}
|
|
18
|
+
/** Manifest fetch failed, schema invalid, or required fields missing. */
|
|
19
|
+
declare class RouteDockManifestError extends RouteDockError {
|
|
20
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
21
|
+
}
|
|
22
|
+
/** Manifest fetch exceeded the configured timeout without receiving a response. */
|
|
23
|
+
declare class RouteDockManifestTimeoutError extends RouteDockError {
|
|
24
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
25
|
+
}
|
|
26
|
+
/** The provider's signed manifest has reached its declared sunset timestamp. */
|
|
27
|
+
declare class RouteDockManifestSunsetError extends RouteDockError {
|
|
28
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
29
|
+
}
|
|
30
|
+
/** No payment mode in the manifest is supported by this client. */
|
|
31
|
+
declare class RouteDockNoSupportedModeError extends RouteDockError {
|
|
32
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
33
|
+
}
|
|
34
|
+
/** This client's SDK version is below the manifest's min_client_version. Upgrade the SDK to proceed. */
|
|
35
|
+
declare class RouteDockClientVersionError extends RouteDockError {
|
|
36
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Account is missing a trustline for the payment asset.
|
|
40
|
+
* Thrown preflight — before any payment transaction is submitted —
|
|
41
|
+
* so the caller can establish the trustline first.
|
|
42
|
+
*/
|
|
43
|
+
declare class RouteDockTrustlineError extends RouteDockError {
|
|
44
|
+
readonly asset: string;
|
|
45
|
+
readonly issuer: string;
|
|
46
|
+
readonly remediation: string;
|
|
47
|
+
constructor(asset: string, issuer: string, remediation: string, options?: RouteDockErrorOptions);
|
|
48
|
+
}
|
|
49
|
+
/** x402 facilitator or provider returned a retryable HTTP failure (5xx, 429). */
|
|
50
|
+
declare class RouteDockFacilitatorError extends RouteDockError {
|
|
51
|
+
readonly status: number;
|
|
52
|
+
constructor(message: string, status: number, options?: RouteDockErrorOptions);
|
|
53
|
+
}
|
|
54
|
+
/** Transient network failure (timeouts, connection reset, unreachable host). */
|
|
55
|
+
declare class RouteDockNetworkError extends RouteDockError {
|
|
56
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
57
|
+
}
|
|
58
|
+
/** Payment or commitment signature could not be produced or verified. */
|
|
59
|
+
declare class RouteDockSignatureError extends RouteDockError {
|
|
60
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
61
|
+
}
|
|
62
|
+
/** Voucher cumulative amount did not increase monotonically. */
|
|
63
|
+
declare class RouteDockVoucherMonotonicityError extends RouteDockError {
|
|
64
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
65
|
+
}
|
|
66
|
+
/** Local spend cap or on-chain policy rejected the payment. */
|
|
67
|
+
declare class RouteDockPolicyRejectError extends RouteDockError {
|
|
68
|
+
readonly reason: string;
|
|
69
|
+
constructor(reason: string, options?: RouteDockErrorOptions);
|
|
70
|
+
}
|
|
71
|
+
/** Channel lifecycle failure (open, simulate, close, missing settlement fields). */
|
|
72
|
+
declare class RouteDockChannelStateError extends RouteDockError {
|
|
73
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
74
|
+
}
|
|
75
|
+
/** Channel dispute operation failed (refund request, settlement, or contract invariant). */
|
|
76
|
+
declare class RouteDockDisputeError extends RouteDockError {
|
|
77
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
78
|
+
}
|
|
79
|
+
/** Refund window has not yet opened or has already expired. */
|
|
80
|
+
declare class RouteDockRefundWindowError extends RouteDockError {
|
|
81
|
+
constructor(message: string, options?: RouteDockErrorOptions);
|
|
82
|
+
}
|
|
83
|
+
/** @deprecated Use {@link RouteDockPolicyRejectError} */
|
|
84
|
+
declare const RouteDockPolicyRejectedError: typeof RouteDockPolicyRejectError;
|
|
85
|
+
/** @deprecated Use {@link RouteDockVoucherMonotonicityError} or {@link RouteDockChannelStateError} */
|
|
86
|
+
declare const RouteDockSessionError: typeof RouteDockVoucherMonotonicityError;
|
|
87
|
+
/** Parse Retry-After from a Response (seconds or HTTP-date). */
|
|
88
|
+
declare function parseRetryAfterMs(response: Response): number | undefined;
|
|
89
|
+
/** Map an HTTP status to a typed, retryable-aware RouteDock error. */
|
|
90
|
+
declare function httpStatusToError(message: string, status: number, response?: Response): RouteDockError;
|
|
91
|
+
/** Wrap a low-level fetch failure; preserves existing RouteDockErrors. */
|
|
92
|
+
declare function wrapFetchError(err: unknown, context: string): RouteDockError;
|
|
93
|
+
|
|
94
|
+
interface SessionStore {
|
|
95
|
+
get(channelId: string): Promise<SessionState | null>;
|
|
96
|
+
/** Enforce monotonic invariant at application level before writing (used for voucher amount advances) */
|
|
97
|
+
upsert(channelId: string, state: SessionState): Promise<void>;
|
|
98
|
+
/** Update session status without altering cumulative_amount */
|
|
99
|
+
setStatus(channelId: string, status: SessionState['status'], settlementTxHash?: string | null): Promise<void>;
|
|
100
|
+
close(channelId: string): Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
declare class SupabaseSessionStore implements SessionStore {
|
|
103
|
+
private readonly supabase;
|
|
104
|
+
constructor(supabase: SupabaseClient);
|
|
105
|
+
get(channelId: string): Promise<SessionState | null>;
|
|
106
|
+
upsert(channelId: string, state: SessionState): Promise<void>;
|
|
107
|
+
setStatus(channelId: string, status: SessionState['status'], settlementTxHash?: string | null): Promise<void>;
|
|
108
|
+
close(channelId: string): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { RouteDockChannelStateError as R, type SessionStore as S, RouteDockClientVersionError as a, RouteDockDisputeError as b, RouteDockError as c, type RouteDockErrorCode as d, type RouteDockErrorOptions as e, RouteDockFacilitatorError as f, RouteDockManifestError as g, RouteDockManifestSunsetError as h, RouteDockManifestTimeoutError as i, RouteDockNetworkError as j, RouteDockNoSupportedModeError as k, RouteDockPolicyRejectError as l, RouteDockPolicyRejectedError as m, RouteDockRefundWindowError as n, RouteDockSessionError as o, RouteDockSignatureError as p, RouteDockTrustlineError as q, RouteDockVoucherMonotonicityError as r, SupabaseSessionStore as s, httpStatusToError as t, parseRetryAfterMs as u, wrapFetchError as w };
|