blue-js-sdk 2.0.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/CHANGELOG.md +446 -0
- package/LICENSE +21 -0
- package/README.md +75 -0
- package/ai-path/ADMIN-ELEVATION.md +116 -0
- package/ai-path/AI-MANIFESTO.md +185 -0
- package/ai-path/BREAKING.md +74 -0
- package/ai-path/CHECKLIST.md +619 -0
- package/ai-path/CONNECTION-STEPS.md +724 -0
- package/ai-path/DECISION-TREE.md +378 -0
- package/ai-path/DEPENDENCIES.md +459 -0
- package/ai-path/E2E-FLOW.md +1555 -0
- package/ai-path/FAILURES.md +403 -0
- package/ai-path/GUIDE.md +1217 -0
- package/ai-path/README.md +558 -0
- package/ai-path/SPLIT-TUNNEL.md +266 -0
- package/ai-path/cli.js +535 -0
- package/ai-path/connect.js +884 -0
- package/ai-path/discover.js +178 -0
- package/ai-path/environment.js +266 -0
- package/ai-path/errors.js +86 -0
- package/ai-path/examples/autonomous-agent.mjs +220 -0
- package/ai-path/examples/multi-region.mjs +174 -0
- package/ai-path/examples/one-shot.mjs +31 -0
- package/ai-path/index.js +60 -0
- package/ai-path/pricing.js +136 -0
- package/ai-path/recommend.js +413 -0
- package/ai-path/run-admin.vbs +25 -0
- package/ai-path/setup.js +291 -0
- package/ai-path/wallet.js +137 -0
- package/app-helpers.js +363 -0
- package/app-settings.js +95 -0
- package/app-types.js +267 -0
- package/audit.js +847 -0
- package/batch.js +293 -0
- package/bin/setup.js +376 -0
- package/chain/authz.js +109 -0
- package/chain/broadcast.js +472 -0
- package/chain/client.js +160 -0
- package/chain/fee-grants.js +305 -0
- package/chain/index.js +891 -0
- package/chain/lcd.js +313 -0
- package/chain/queries.js +547 -0
- package/chain/rpc.js +408 -0
- package/chain/wallet.js +141 -0
- package/cli/config.js +143 -0
- package/cli/index.js +463 -0
- package/cli/output.js +182 -0
- package/cli.js +491 -0
- package/client/index.js +251 -0
- package/client.js +271 -0
- package/config/index.js +255 -0
- package/connection/connect.js +849 -0
- package/connection/disconnect.js +180 -0
- package/connection/discovery.js +321 -0
- package/connection/index.js +76 -0
- package/connection/proxy.js +148 -0
- package/connection/resilience.js +428 -0
- package/connection/security.js +232 -0
- package/connection/state.js +369 -0
- package/connection/tunnel.js +691 -0
- package/consumer.js +132 -0
- package/cosmjs-setup.js +1884 -0
- package/defaults.js +366 -0
- package/disk-cache.js +107 -0
- package/dist/client.d.ts +108 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +400 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/errors/index.js +112 -0
- package/errors.js +218 -0
- package/examples/README.md +64 -0
- package/examples/connect-direct.mjs +106 -0
- package/examples/connect-plan.mjs +125 -0
- package/examples/error-handling.mjs +109 -0
- package/examples/query-nodes.mjs +94 -0
- package/examples/wallet-basics.mjs +61 -0
- package/generated/amino/amino.ts +9 -0
- package/generated/cosmos/base/v1beta1/coin.ts +365 -0
- package/generated/cosmos_proto/cosmos.ts +323 -0
- package/generated/gogoproto/gogo.ts +9 -0
- package/generated/google/protobuf/descriptor.ts +7601 -0
- package/generated/google/protobuf/duration.ts +208 -0
- package/generated/google/protobuf/timestamp.ts +238 -0
- package/generated/sentinel/lease/v1/events.ts +924 -0
- package/generated/sentinel/lease/v1/lease.ts +292 -0
- package/generated/sentinel/lease/v1/msg.ts +949 -0
- package/generated/sentinel/lease/v1/params.ts +164 -0
- package/generated/sentinel/node/v3/events.ts +881 -0
- package/generated/sentinel/node/v3/msg.ts +1002 -0
- package/generated/sentinel/node/v3/node.ts +263 -0
- package/generated/sentinel/node/v3/params.ts +183 -0
- package/generated/sentinel/plan/v3/events.ts +675 -0
- package/generated/sentinel/plan/v3/msg.ts +1191 -0
- package/generated/sentinel/plan/v3/plan.ts +283 -0
- package/generated/sentinel/provider/v2/events.ts +171 -0
- package/generated/sentinel/provider/v2/msg.ts +480 -0
- package/generated/sentinel/provider/v2/params.ts +131 -0
- package/generated/sentinel/provider/v2/provider.ts +246 -0
- package/generated/sentinel/session/v3/events.ts +480 -0
- package/generated/sentinel/session/v3/msg.ts +616 -0
- package/generated/sentinel/session/v3/params.ts +260 -0
- package/generated/sentinel/session/v3/proof.ts +180 -0
- package/generated/sentinel/session/v3/session.ts +384 -0
- package/generated/sentinel/subscription/v3/events.ts +1181 -0
- package/generated/sentinel/subscription/v3/msg.ts +1305 -0
- package/generated/sentinel/subscription/v3/params.ts +167 -0
- package/generated/sentinel/subscription/v3/subscription.ts +315 -0
- package/generated/sentinel/types/v1/bandwidth.ts +124 -0
- package/generated/sentinel/types/v1/price.ts +149 -0
- package/generated/sentinel/types/v1/renewal.ts +87 -0
- package/generated/sentinel/types/v1/status.ts +54 -0
- package/generated/typeRegistry.ts +27 -0
- package/index.js +486 -0
- package/node-connect.js +3015 -0
- package/operator.js +134 -0
- package/package.json +113 -0
- package/plan-operations.js +199 -0
- package/preflight.js +352 -0
- package/pricing/index.js +262 -0
- package/proto/amino/amino.proto +84 -0
- package/proto/cosmos/base/v1beta1/coin.proto +61 -0
- package/proto/cosmos_proto/cosmos.proto +112 -0
- package/proto/gogoproto/gogo.proto +145 -0
- package/proto/google/api/annotations.proto +31 -0
- package/proto/google/api/http.proto +370 -0
- package/proto/google/protobuf/any.proto +106 -0
- package/proto/google/protobuf/duration.proto +115 -0
- package/proto/google/protobuf/timestamp.proto +145 -0
- package/proto/sentinel/lease/v1/events.proto +52 -0
- package/proto/sentinel/lease/v1/genesis.proto +15 -0
- package/proto/sentinel/lease/v1/lease.proto +25 -0
- package/proto/sentinel/lease/v1/msg.proto +62 -0
- package/proto/sentinel/lease/v1/params.proto +17 -0
- package/proto/sentinel/node/v3/events.proto +50 -0
- package/proto/sentinel/node/v3/genesis.proto +15 -0
- package/proto/sentinel/node/v3/msg.proto +63 -0
- package/proto/sentinel/node/v3/node.proto +27 -0
- package/proto/sentinel/node/v3/params.proto +21 -0
- package/proto/sentinel/node/v3/querier.proto +63 -0
- package/proto/sentinel/plan/v3/events.proto +41 -0
- package/proto/sentinel/plan/v3/genesis.proto +21 -0
- package/proto/sentinel/plan/v3/msg.proto +83 -0
- package/proto/sentinel/plan/v3/plan.proto +32 -0
- package/proto/sentinel/plan/v3/querier.proto +53 -0
- package/proto/sentinel/provider/v2/events.proto +16 -0
- package/proto/sentinel/provider/v2/genesis.proto +15 -0
- package/proto/sentinel/provider/v2/msg.proto +35 -0
- package/proto/sentinel/provider/v2/params.proto +17 -0
- package/proto/sentinel/provider/v2/provider.proto +24 -0
- package/proto/sentinel/provider/v3/genesis.proto +15 -0
- package/proto/sentinel/provider/v3/params.proto +13 -0
- package/proto/sentinel/session/v3/events.proto +30 -0
- package/proto/sentinel/session/v3/genesis.proto +15 -0
- package/proto/sentinel/session/v3/msg.proto +50 -0
- package/proto/sentinel/session/v3/params.proto +25 -0
- package/proto/sentinel/session/v3/proof.proto +25 -0
- package/proto/sentinel/session/v3/querier.proto +100 -0
- package/proto/sentinel/session/v3/session.proto +50 -0
- package/proto/sentinel/subscription/v2/allocation.proto +21 -0
- package/proto/sentinel/subscription/v2/payout.proto +22 -0
- package/proto/sentinel/subscription/v3/events.proto +65 -0
- package/proto/sentinel/subscription/v3/genesis.proto +17 -0
- package/proto/sentinel/subscription/v3/msg.proto +83 -0
- package/proto/sentinel/subscription/v3/params.proto +21 -0
- package/proto/sentinel/subscription/v3/subscription.proto +33 -0
- package/proto/sentinel/types/v1/bandwidth.proto +19 -0
- package/proto/sentinel/types/v1/price.proto +21 -0
- package/proto/sentinel/types/v1/renewal.proto +21 -0
- package/proto/sentinel/types/v1/status.proto +16 -0
- package/protocol/encoding.js +341 -0
- package/protocol/events.js +361 -0
- package/protocol/handshake.js +297 -0
- package/protocol/index.js +15 -0
- package/protocol/messages.js +346 -0
- package/protocol/plans.js +199 -0
- package/protocol/v2ray.js +268 -0
- package/protocol/v3.js +723 -0
- package/protocol/wireguard.js +125 -0
- package/security/index.js +132 -0
- package/session-manager.js +329 -0
- package/session-tracker.js +80 -0
- package/setup.js +376 -0
- package/speedtest/index.js +528 -0
- package/speedtest.js +567 -0
- package/src/client.ts +502 -0
- package/src/index.ts +20 -0
- package/state/index.js +347 -0
- package/state.js +516 -0
- package/test-all-chain-ops.js +493 -0
- package/test-all-logic.js +199 -0
- package/test-all-msg-types.js +292 -0
- package/test-every-connection.js +208 -0
- package/test-feegrant-connect.js +98 -0
- package/test-logic.js +148 -0
- package/test-mainnet.js +176 -0
- package/test-plan-lifecycle.js +335 -0
- package/tls-trust.js +132 -0
- package/tsconfig.build.json +20 -0
- package/tsconfig.json +34 -0
- package/types/chain.d.ts +746 -0
- package/types/connection.d.ts +425 -0
- package/types/errors.d.ts +174 -0
- package/types/index.d.ts +1380 -0
- package/types/nodes.d.ts +187 -0
- package/types/pricing.d.ts +156 -0
- package/types/protocol.d.ts +332 -0
- package/types/session.d.ts +236 -0
- package/types/settings.d.ts +192 -0
- package/v3protocol.js +1053 -0
- package/wallet/index.js +153 -0
- package/wireguard.js +307 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,1380 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sentinel dVPN SDK — Comprehensive Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* 200+ exports across 14 modules. Every function parameter, return type,
|
|
5
|
+
* and option object is explicitly typed with named interfaces.
|
|
6
|
+
*
|
|
7
|
+
* Import types from the main package:
|
|
8
|
+
* import type { ConnectOptions, ConnectResult, ScoredNode } from 'sentinel-dvpn-sdk';
|
|
9
|
+
*
|
|
10
|
+
* Or from specific type modules:
|
|
11
|
+
* import type { ConnectOptions } from 'sentinel-dvpn-sdk/types/connection';
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// ─── Re-export all types ───────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
export type {
|
|
17
|
+
ErrorCode,
|
|
18
|
+
ErrorSeverity,
|
|
19
|
+
} from './errors.js';
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
SentinelError,
|
|
23
|
+
ValidationError,
|
|
24
|
+
NodeError,
|
|
25
|
+
ChainError,
|
|
26
|
+
TunnelError,
|
|
27
|
+
SecurityError,
|
|
28
|
+
ErrorCodes,
|
|
29
|
+
ERROR_SEVERITY,
|
|
30
|
+
isRetryable,
|
|
31
|
+
userMessage,
|
|
32
|
+
} from './errors.js';
|
|
33
|
+
|
|
34
|
+
export type {
|
|
35
|
+
ConnectOptions,
|
|
36
|
+
ConnectionTimeouts,
|
|
37
|
+
ConnectViaPlanOptions,
|
|
38
|
+
ConnectAutoOptions,
|
|
39
|
+
ConnectResult,
|
|
40
|
+
DisconnectResult,
|
|
41
|
+
ConnectionStatus,
|
|
42
|
+
VerifyResult,
|
|
43
|
+
AutoReconnectOptions,
|
|
44
|
+
AutoReconnectHandle,
|
|
45
|
+
CircuitBreakerConfig,
|
|
46
|
+
CircuitBreakerStatus,
|
|
47
|
+
ConnectionMetric,
|
|
48
|
+
ConnectionState,
|
|
49
|
+
ProgressEntry,
|
|
50
|
+
SDKEvents,
|
|
51
|
+
DependencyCheck,
|
|
52
|
+
PreflightIssue,
|
|
53
|
+
PreflightReport,
|
|
54
|
+
ConnectConfig,
|
|
55
|
+
} from './connection.js';
|
|
56
|
+
|
|
57
|
+
export type {
|
|
58
|
+
WalletResult,
|
|
59
|
+
GenerateWalletResult,
|
|
60
|
+
WalletBalance,
|
|
61
|
+
SafeBroadcaster,
|
|
62
|
+
TxResponseSummary,
|
|
63
|
+
EncodedMsg,
|
|
64
|
+
LcdQueryOptions,
|
|
65
|
+
LcdQueryAllOptions,
|
|
66
|
+
PaginatedResult,
|
|
67
|
+
LcdPaginatedSafeOptions,
|
|
68
|
+
PriceEntry,
|
|
69
|
+
ChainNode,
|
|
70
|
+
Subscription,
|
|
71
|
+
ChainSession,
|
|
72
|
+
FlatSession,
|
|
73
|
+
Provider,
|
|
74
|
+
FeeGrantAllowance,
|
|
75
|
+
DiscoveredPlan,
|
|
76
|
+
FeeGrantOptions,
|
|
77
|
+
ExpiringGrant,
|
|
78
|
+
PlanSubscriber,
|
|
79
|
+
PlanStats,
|
|
80
|
+
MsgStartSessionParams,
|
|
81
|
+
MsgEndSessionParams,
|
|
82
|
+
MsgStartSubscriptionParams,
|
|
83
|
+
MsgSubStartSessionParams,
|
|
84
|
+
MsgCancelSubscriptionParams,
|
|
85
|
+
MsgRenewSubscriptionParams,
|
|
86
|
+
MsgShareSubscriptionParams,
|
|
87
|
+
MsgUpdateSubscriptionParams,
|
|
88
|
+
MsgUpdateSessionParams,
|
|
89
|
+
MsgRegisterNodeParams,
|
|
90
|
+
MsgUpdateNodeDetailsParams,
|
|
91
|
+
MsgUpdateNodeStatusParams,
|
|
92
|
+
MsgUpdatePlanDetailsParams,
|
|
93
|
+
MsgRegisterProviderParams,
|
|
94
|
+
MsgUpdateProviderDetailsParams,
|
|
95
|
+
MsgUpdateProviderStatusParams,
|
|
96
|
+
MsgCreatePlanParams,
|
|
97
|
+
MsgUpdatePlanStatusParams,
|
|
98
|
+
MsgLinkNodeParams,
|
|
99
|
+
MsgUnlinkNodeParams,
|
|
100
|
+
MsgPlanStartSessionParams,
|
|
101
|
+
MsgStartLeaseParams,
|
|
102
|
+
MsgEndLeaseParams,
|
|
103
|
+
BatchStartSessionNode,
|
|
104
|
+
BatchSendRecipient,
|
|
105
|
+
BatchFeeEstimate,
|
|
106
|
+
SubscribeToPlanResult,
|
|
107
|
+
ParsedDuration,
|
|
108
|
+
SessionCostEstimate,
|
|
109
|
+
Endpoint,
|
|
110
|
+
FallbackResult,
|
|
111
|
+
EndpointHealth,
|
|
112
|
+
} from './chain.js';
|
|
113
|
+
|
|
114
|
+
export { MSG_TYPES } from './chain.js';
|
|
115
|
+
|
|
116
|
+
export type {
|
|
117
|
+
NodeStatus,
|
|
118
|
+
WgKeyPair,
|
|
119
|
+
WgConfigOptions,
|
|
120
|
+
HandshakeResult,
|
|
121
|
+
V2RayHandshakeResult,
|
|
122
|
+
V2RayConfigOptions,
|
|
123
|
+
V2RayConfig,
|
|
124
|
+
TransportSuccessRate,
|
|
125
|
+
DynamicTransportRate,
|
|
126
|
+
SpeedResult,
|
|
127
|
+
SpeedComparison,
|
|
128
|
+
SpeedtestDefaults,
|
|
129
|
+
WatchdogResult,
|
|
130
|
+
OrphanedTunnelCheck,
|
|
131
|
+
CleanOrphanedResult,
|
|
132
|
+
OrphanedV2RayCheck,
|
|
133
|
+
VpnConflictCheck,
|
|
134
|
+
PortConflictCheck,
|
|
135
|
+
} from './protocol.js';
|
|
136
|
+
|
|
137
|
+
export type {
|
|
138
|
+
ListNodesOptions,
|
|
139
|
+
NodeProbeProgress,
|
|
140
|
+
EnrichNodesOptions,
|
|
141
|
+
ScoredNode,
|
|
142
|
+
NodeFilter,
|
|
143
|
+
NodePrices,
|
|
144
|
+
NodeIndex,
|
|
145
|
+
NetworkOverview,
|
|
146
|
+
BrokenNode,
|
|
147
|
+
} from './nodes.js';
|
|
148
|
+
|
|
149
|
+
export type {
|
|
150
|
+
SDKState,
|
|
151
|
+
RecoverResult,
|
|
152
|
+
PidCheck,
|
|
153
|
+
SavedCredentials,
|
|
154
|
+
SessionManagerOptions,
|
|
155
|
+
SessionMapEntry,
|
|
156
|
+
SessionAllocation,
|
|
157
|
+
QuerySessionAllocationResult,
|
|
158
|
+
SessionPaymentMode,
|
|
159
|
+
SessionHistoryEntry,
|
|
160
|
+
BatchStartSessionsOptions,
|
|
161
|
+
BatchStartResult,
|
|
162
|
+
BatchSessionStatus,
|
|
163
|
+
WaitForBatchOptions,
|
|
164
|
+
WaitForSessionActiveOptions,
|
|
165
|
+
} from './session.js';
|
|
166
|
+
|
|
167
|
+
export type {
|
|
168
|
+
AppSettings,
|
|
169
|
+
DnsPreset,
|
|
170
|
+
DnsPresetName,
|
|
171
|
+
DnsPresets,
|
|
172
|
+
AppType,
|
|
173
|
+
AppTypeConstants,
|
|
174
|
+
AppTypeScreens,
|
|
175
|
+
AppTypeConfig,
|
|
176
|
+
AppConfigValidation,
|
|
177
|
+
VpnSettings,
|
|
178
|
+
CacheInfo,
|
|
179
|
+
DiskCacheEntry,
|
|
180
|
+
} from './settings.js';
|
|
181
|
+
|
|
182
|
+
export type {
|
|
183
|
+
NodePricingDisplay,
|
|
184
|
+
SessionPriceEstimate,
|
|
185
|
+
CountryMap,
|
|
186
|
+
NodeDisplay,
|
|
187
|
+
CountryGroup,
|
|
188
|
+
PricingReference,
|
|
189
|
+
HourOptions,
|
|
190
|
+
GbOptions,
|
|
191
|
+
} from './pricing.js';
|
|
192
|
+
|
|
193
|
+
// ─── Re-export CosmJS types for convenience ────────────────────────────────
|
|
194
|
+
|
|
195
|
+
import type { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
|
|
196
|
+
import type { SigningStargateClient, DeliverTxResponse } from '@cosmjs/stargate';
|
|
197
|
+
import type { StdFee } from '@cosmjs/amino';
|
|
198
|
+
import type { EventEmitter } from 'events';
|
|
199
|
+
|
|
200
|
+
// ─── High-level Connection API ─────────────────────────────────────────────
|
|
201
|
+
|
|
202
|
+
import type {
|
|
203
|
+
ConnectOptions,
|
|
204
|
+
ConnectViaPlanOptions,
|
|
205
|
+
ConnectAutoOptions,
|
|
206
|
+
ConnectResult,
|
|
207
|
+
ConnectionStatus,
|
|
208
|
+
VerifyResult,
|
|
209
|
+
AutoReconnectHandle,
|
|
210
|
+
CircuitBreakerConfig,
|
|
211
|
+
CircuitBreakerStatus,
|
|
212
|
+
ConnectionMetric,
|
|
213
|
+
DependencyCheck,
|
|
214
|
+
PreflightReport,
|
|
215
|
+
ConnectConfig,
|
|
216
|
+
SDKEvents,
|
|
217
|
+
ConnectionState,
|
|
218
|
+
} from './connection.js';
|
|
219
|
+
|
|
220
|
+
/** Connect to a Sentinel dVPN node (alias for connectDirect) */
|
|
221
|
+
export function connect(opts: ConnectOptions): Promise<ConnectResult>;
|
|
222
|
+
|
|
223
|
+
/** Connect directly to a Sentinel dVPN node — pay per GB or per hour */
|
|
224
|
+
export function connectDirect(opts: ConnectOptions): Promise<ConnectResult>;
|
|
225
|
+
|
|
226
|
+
/** Connect via a subscription plan — plan operator pays gas via fee grant */
|
|
227
|
+
export function connectViaPlan(opts: ConnectViaPlanOptions): Promise<ConnectResult>;
|
|
228
|
+
|
|
229
|
+
/** Connect via an existing subscription — reuse a subscription you already have */
|
|
230
|
+
export function connectViaSubscription(opts: ConnectOptions & { subscriptionId: number | string | bigint }): Promise<ConnectResult>;
|
|
231
|
+
|
|
232
|
+
/** Connect with auto-fallback: tries multiple nodes on failure */
|
|
233
|
+
export function connectAuto(opts: ConnectAutoOptions): Promise<ConnectResult>;
|
|
234
|
+
|
|
235
|
+
/** Disconnect current VPN tunnel and clean up all resources */
|
|
236
|
+
export function disconnect(): Promise<void>;
|
|
237
|
+
|
|
238
|
+
/** Check if a VPN tunnel is currently active */
|
|
239
|
+
export function isConnected(): boolean;
|
|
240
|
+
|
|
241
|
+
/** Check if a connection attempt is currently in progress (mutex held) */
|
|
242
|
+
export function isConnecting(): boolean;
|
|
243
|
+
|
|
244
|
+
/** Get current connection status (null if not connected) */
|
|
245
|
+
export function getStatus(): ConnectionStatus | null;
|
|
246
|
+
|
|
247
|
+
/** Register process exit handlers for clean tunnel shutdown. Call once at app startup. */
|
|
248
|
+
export function registerCleanupHandlers(): void;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* One-call VPN connection. Handles deps check, cleanup registration,
|
|
252
|
+
* node selection, connection, and IP verification.
|
|
253
|
+
*/
|
|
254
|
+
export function quickConnect(opts: ConnectOptions & {
|
|
255
|
+
countries?: string[];
|
|
256
|
+
serviceType?: 'wireguard' | 'v2ray';
|
|
257
|
+
maxAttempts?: number;
|
|
258
|
+
}): Promise<ConnectResult & { vpnIp?: string }>;
|
|
259
|
+
|
|
260
|
+
/** Auto-reconnect on connection loss. Returns handle with stop(). */
|
|
261
|
+
export function autoReconnect(opts: ConnectOptions & {
|
|
262
|
+
pollIntervalMs?: number;
|
|
263
|
+
maxRetries?: number;
|
|
264
|
+
backoffMs?: number[];
|
|
265
|
+
onReconnecting?: (attempt: number) => void;
|
|
266
|
+
onReconnected?: (result: ConnectResult) => void;
|
|
267
|
+
onGaveUp?: (errors: Error[]) => void;
|
|
268
|
+
}): AutoReconnectHandle;
|
|
269
|
+
|
|
270
|
+
/** Verify VPN is working by checking public IP through the tunnel */
|
|
271
|
+
export function verifyConnection(opts?: { timeoutMs?: number }): Promise<VerifyResult>;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Retry handshake on an already-paid session. Use when connect fails AFTER payment.
|
|
275
|
+
* Pass sessionId + nodeAddress from the error.details of the failed connect.
|
|
276
|
+
*/
|
|
277
|
+
export function recoverSession(opts: ConnectOptions & { sessionId: string | bigint }): Promise<ConnectResult>;
|
|
278
|
+
|
|
279
|
+
/** Attempt fast reconnect using saved credentials. Returns null if unavailable. */
|
|
280
|
+
export function tryFastReconnect(opts: ConnectOptions): Promise<ConnectResult | null>;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Create a reusable base config. Override per-call with .with().
|
|
284
|
+
* @example
|
|
285
|
+
* const cfg = createConnectConfig({ mnemonic, rpcUrl });
|
|
286
|
+
* await connectDirect(cfg.with({ nodeAddress: 'sentnode1...' }));
|
|
287
|
+
*/
|
|
288
|
+
export function createConnectConfig(baseOpts: Partial<ConnectOptions>): ConnectConfig;
|
|
289
|
+
|
|
290
|
+
/** Pre-flight dependency check: verify V2Ray and WireGuard availability */
|
|
291
|
+
export function verifyDependencies(opts?: { v2rayExePath?: string }): DependencyCheck;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Complete pre-flight system check. Run at app startup.
|
|
295
|
+
* Detects: missing binaries, admin permissions, orphaned tunnels,
|
|
296
|
+
* conflicting VPNs, port conflicts.
|
|
297
|
+
*/
|
|
298
|
+
export function preflight(opts?: { autoClean?: boolean; v2rayExePath?: string }): PreflightReport;
|
|
299
|
+
|
|
300
|
+
/** SDK lifecycle event emitter */
|
|
301
|
+
export const events: SDKEvents & EventEmitter;
|
|
302
|
+
|
|
303
|
+
/** Disconnect a specific connection state (used by SentinelClient internally) */
|
|
304
|
+
export function disconnectState(state: ConnectionState): Promise<void>;
|
|
305
|
+
|
|
306
|
+
// ─── Circuit Breaker ───────────────────────────────────────────────────────
|
|
307
|
+
|
|
308
|
+
/** Reset the circuit breaker for a node (or all nodes if no address given) */
|
|
309
|
+
export function resetCircuitBreaker(address?: string): void;
|
|
310
|
+
|
|
311
|
+
/** Configure circuit breaker thresholds globally */
|
|
312
|
+
export function configureCircuitBreaker(opts?: CircuitBreakerConfig): void;
|
|
313
|
+
|
|
314
|
+
/** Get circuit breaker status for a node or all nodes */
|
|
315
|
+
export function getCircuitBreakerStatus(address?: string):
|
|
316
|
+
Record<string, CircuitBreakerStatus> | CircuitBreakerStatus | null;
|
|
317
|
+
|
|
318
|
+
/** Get connection metrics for observability */
|
|
319
|
+
export function getConnectionMetrics(nodeAddress?: string):
|
|
320
|
+
Record<string, ConnectionMetric> | ConnectionMetric | null;
|
|
321
|
+
|
|
322
|
+
// ─── Kill Switch & System Proxy ────────────────────────────────────────────
|
|
323
|
+
|
|
324
|
+
/** Enable kill switch -- blocks all non-tunnel traffic (Windows only) */
|
|
325
|
+
export function enableKillSwitch(serverEndpoint: string, tunnelName?: string): void;
|
|
326
|
+
|
|
327
|
+
/** Disable kill switch -- restore normal routing */
|
|
328
|
+
export function disableKillSwitch(): void;
|
|
329
|
+
|
|
330
|
+
/** Check if kill switch is enabled */
|
|
331
|
+
export function isKillSwitchEnabled(): boolean;
|
|
332
|
+
|
|
333
|
+
/** Enable DNS leak prevention (forces DNS through tunnel) */
|
|
334
|
+
export function enableDnsLeakPrevention(dnsServer?: string): void;
|
|
335
|
+
|
|
336
|
+
/** Disable DNS leak prevention (restore original DNS settings) */
|
|
337
|
+
export function disableDnsLeakPrevention(): void;
|
|
338
|
+
|
|
339
|
+
/** Set system SOCKS proxy (Windows: registry, macOS: networksetup, Linux: gsettings) */
|
|
340
|
+
export function setSystemProxy(socksPort: number): void;
|
|
341
|
+
|
|
342
|
+
/** Clear system SOCKS proxy */
|
|
343
|
+
export function clearSystemProxy(): void;
|
|
344
|
+
|
|
345
|
+
/** Check if a TCP port is free */
|
|
346
|
+
export function checkPortFree(port: number): Promise<boolean>;
|
|
347
|
+
|
|
348
|
+
// ─── Node Discovery ────────────────────────────────────────────────────────
|
|
349
|
+
|
|
350
|
+
import type {
|
|
351
|
+
ListNodesOptions,
|
|
352
|
+
ScoredNode,
|
|
353
|
+
NodePrices,
|
|
354
|
+
NodeIndex,
|
|
355
|
+
NetworkOverview,
|
|
356
|
+
} from './nodes.js';
|
|
357
|
+
|
|
358
|
+
/** List online nodes, sorted by quality score. Uses 5-min cache. */
|
|
359
|
+
export function listNodes(options?: ListNodesOptions): Promise<ScoredNode[]>;
|
|
360
|
+
|
|
361
|
+
/** List online nodes (alias for listNodes) */
|
|
362
|
+
export function queryOnlineNodes(options?: ListNodesOptions): Promise<ScoredNode[]>;
|
|
363
|
+
|
|
364
|
+
/** Fetch ALL active nodes from LCD -- no per-node status checks, instant. Returns 900+ nodes. */
|
|
365
|
+
export function fetchAllNodes(options?: { lcdUrl?: string }): Promise<Array<{
|
|
366
|
+
address: string;
|
|
367
|
+
remote_url: string;
|
|
368
|
+
gigabyte_prices: Array<{ denom: string; base_value: string; quote_value: string }>;
|
|
369
|
+
hourly_prices: Array<{ denom: string; base_value: string; quote_value: string }>;
|
|
370
|
+
}>>;
|
|
371
|
+
|
|
372
|
+
/** Enrich LCD nodes with type/country/city by probing each node's status API */
|
|
373
|
+
export function enrichNodes(nodes: unknown[], options?: {
|
|
374
|
+
concurrency?: number;
|
|
375
|
+
timeout?: number;
|
|
376
|
+
onProgress?: (progress: { total: number; done: number; enriched: number }) => void;
|
|
377
|
+
}): Promise<ScoredNode[]>;
|
|
378
|
+
|
|
379
|
+
/** Build geographic index from enriched nodes for instant country/city lookups */
|
|
380
|
+
export function buildNodeIndex(nodes: ScoredNode[]): NodeIndex;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Filter a node list by country, service type, max price, or min quality score.
|
|
384
|
+
* Works with results from listNodes(), enrichNodes(), or fetchAllNodes().
|
|
385
|
+
*/
|
|
386
|
+
export function filterNodes(nodes: unknown[], criteria?: {
|
|
387
|
+
country?: string;
|
|
388
|
+
serviceType?: 'wireguard' | 'v2ray';
|
|
389
|
+
maxPriceDvpn?: number;
|
|
390
|
+
minScore?: number;
|
|
391
|
+
}): unknown[];
|
|
392
|
+
|
|
393
|
+
/** Get standardized prices for a node -- abstracts V3 LCD price parsing entirely */
|
|
394
|
+
export function getNodePrices(nodeAddress: string, lcdUrl?: string): Promise<NodePrices>;
|
|
395
|
+
|
|
396
|
+
/** Get a quick network overview -- total nodes, counts by country/type, average prices */
|
|
397
|
+
export function getNetworkOverview(lcdUrl?: string): Promise<NetworkOverview>;
|
|
398
|
+
|
|
399
|
+
/** Fetch a single node by address from LCD */
|
|
400
|
+
export function queryNode(nodeAddress: string, opts?: { lcdUrl?: string }): Promise<import('./chain.js').ChainNode>;
|
|
401
|
+
|
|
402
|
+
/** Clear the node list cache. Next queryOnlineNodes() call will fetch fresh data. */
|
|
403
|
+
export function flushNodeCache(): void;
|
|
404
|
+
|
|
405
|
+
// ─── Wallet & Chain ────────────────────────────────────────────────────────
|
|
406
|
+
|
|
407
|
+
import type {
|
|
408
|
+
WalletResult,
|
|
409
|
+
SafeBroadcaster,
|
|
410
|
+
EncodedMsg,
|
|
411
|
+
PriceEntry,
|
|
412
|
+
ChainNode,
|
|
413
|
+
Subscription,
|
|
414
|
+
ChainSession,
|
|
415
|
+
FlatSession,
|
|
416
|
+
Provider,
|
|
417
|
+
FeeGrantAllowance,
|
|
418
|
+
DiscoveredPlan,
|
|
419
|
+
FeeGrantOptions,
|
|
420
|
+
ExpiringGrant,
|
|
421
|
+
PlanSubscriber,
|
|
422
|
+
BatchFeeEstimate,
|
|
423
|
+
SessionCostEstimate,
|
|
424
|
+
Endpoint,
|
|
425
|
+
FallbackResult,
|
|
426
|
+
EndpointHealth,
|
|
427
|
+
PlanStats,
|
|
428
|
+
ParsedDuration,
|
|
429
|
+
SubscribeToPlanResult,
|
|
430
|
+
} from './chain.js';
|
|
431
|
+
|
|
432
|
+
/** Create a Cosmos wallet from BIP39 mnemonic */
|
|
433
|
+
export function createWallet(mnemonic: string): Promise<WalletResult>;
|
|
434
|
+
|
|
435
|
+
/** Generate a new wallet with a fresh random BIP39 mnemonic */
|
|
436
|
+
export function generateWallet(strength?: number): Promise<{
|
|
437
|
+
mnemonic: string;
|
|
438
|
+
wallet: DirectSecp256k1HdWallet;
|
|
439
|
+
account: { address: string };
|
|
440
|
+
}>;
|
|
441
|
+
|
|
442
|
+
/** Derive raw secp256k1 private key from mnemonic (32 bytes) */
|
|
443
|
+
export function privKeyFromMnemonic(mnemonic: string): Promise<Uint8Array>;
|
|
444
|
+
|
|
445
|
+
/** Create a SigningStargateClient connected to an RPC endpoint */
|
|
446
|
+
export function createClient(rpcUrl: string, wallet: DirectSecp256k1HdWallet): Promise<SigningStargateClient>;
|
|
447
|
+
|
|
448
|
+
/** Broadcast messages to the chain with automatic gas estimation */
|
|
449
|
+
export function broadcast(client: SigningStargateClient, signerAddress: string, msgs: EncodedMsg[], fee?: StdFee): Promise<DeliverTxResponse>;
|
|
450
|
+
|
|
451
|
+
/** Create a safe broadcaster with automatic sequence management */
|
|
452
|
+
export function createSafeBroadcaster(rpcUrl: string, wallet: DirectSecp256k1HdWallet, signerAddress: string): SafeBroadcaster;
|
|
453
|
+
|
|
454
|
+
/** Clear the wallet derivation cache. Call after disconnect to release key material. */
|
|
455
|
+
export function clearWalletCache(): void;
|
|
456
|
+
|
|
457
|
+
/** Extract an ID from TX result events using regex pattern */
|
|
458
|
+
export function extractId(txResult: DeliverTxResponse, eventPattern: RegExp, keyNames: string[]): string | null;
|
|
459
|
+
|
|
460
|
+
/** Parse chain error into human-readable message */
|
|
461
|
+
export function parseChainError(raw: string): string;
|
|
462
|
+
|
|
463
|
+
/** Get P2P balance for an address */
|
|
464
|
+
export function getBalance(client: SigningStargateClient, address: string): Promise<{ udvpn: number; dvpn: number }>;
|
|
465
|
+
|
|
466
|
+
/** Validate a BIP39 mnemonic without throwing. Returns true if valid. */
|
|
467
|
+
export function isMnemonicValid(mnemonic: string): boolean;
|
|
468
|
+
|
|
469
|
+
/** Get current P2P price in USD */
|
|
470
|
+
export function getDvpnPrice(): Promise<number>;
|
|
471
|
+
|
|
472
|
+
/** Find existing active session for wallet+node pair */
|
|
473
|
+
export function findExistingSession(lcdUrl: string, walletAddr: string, nodeAddr: string): Promise<bigint | null>;
|
|
474
|
+
|
|
475
|
+
/** Fetch active nodes from LCD with pagination */
|
|
476
|
+
export function fetchActiveNodes(lcdUrl: string, limit?: number, maxPages?: number): Promise<unknown[]>;
|
|
477
|
+
|
|
478
|
+
/** Discover plan IDs by probing LCD */
|
|
479
|
+
export function discoverPlanIds(lcdUrl: string, maxId?: number): Promise<number[]>;
|
|
480
|
+
|
|
481
|
+
/** Resolve node URL from LCD data (handles remote_addrs vs remote_url) */
|
|
482
|
+
export function resolveNodeUrl(node: { remote_url?: string; remote_addrs?: string[] }): string;
|
|
483
|
+
|
|
484
|
+
/** Convert sent1... address to sentprov1... */
|
|
485
|
+
export function sentToSentprov(sentAddr: string): string;
|
|
486
|
+
|
|
487
|
+
/** Convert sent1... address to sentnode1... */
|
|
488
|
+
export function sentToSentnode(sentAddr: string): string;
|
|
489
|
+
|
|
490
|
+
/** Convert sentprov1... address to sent1... */
|
|
491
|
+
export function sentprovToSent(provAddr: string): string;
|
|
492
|
+
|
|
493
|
+
/** Compare addresses across bech32 prefixes (sent1 vs sentprov1 vs sentnode1) */
|
|
494
|
+
export function isSameKey(addr1: string, addr2: string): boolean;
|
|
495
|
+
|
|
496
|
+
/** Build Sentinel protobuf type registry (for custom message handling) */
|
|
497
|
+
export function buildRegistry(): unknown;
|
|
498
|
+
|
|
499
|
+
/** Query LCD endpoint with timeout and error wrapping */
|
|
500
|
+
export function lcd(baseUrl: string, path: string): Promise<unknown>;
|
|
501
|
+
|
|
502
|
+
/** Extract TX response details into a simple object */
|
|
503
|
+
export function txResponse(result: DeliverTxResponse): { ok: boolean; txHash: string; gasUsed: number; gasWanted: number };
|
|
504
|
+
|
|
505
|
+
/** Single LCD query with timeout, retry, and ChainError wrapping */
|
|
506
|
+
export function lcdQuery(path: string, opts?: { lcdUrl?: string; timeout?: number }): Promise<unknown>;
|
|
507
|
+
|
|
508
|
+
/** Auto-paginating LCD query. Returns all items + chain total. */
|
|
509
|
+
export function lcdQueryAll(basePath: string, opts?: {
|
|
510
|
+
lcdUrl?: string;
|
|
511
|
+
limit?: number;
|
|
512
|
+
timeout?: number;
|
|
513
|
+
dataKey?: string;
|
|
514
|
+
}): Promise<{ items: unknown[]; total: number | null }>;
|
|
515
|
+
|
|
516
|
+
/** Paginated LCD query that handles Sentinel's broken pagination */
|
|
517
|
+
export function lcdPaginatedSafe(lcdUrl: string, path: string, itemsKey: string, opts?: {
|
|
518
|
+
limit?: number;
|
|
519
|
+
fallbackLimit?: number;
|
|
520
|
+
}): Promise<{ items: unknown[]; total: number }>;
|
|
521
|
+
|
|
522
|
+
// ─── Fee Grants ────────────────────────────────────────────────────────────
|
|
523
|
+
|
|
524
|
+
/** Build a MsgGrantAllowance -- granter pays gas for grantee */
|
|
525
|
+
export function buildFeeGrantMsg(granter: string, grantee: string, opts?: FeeGrantOptions): EncodedMsg;
|
|
526
|
+
|
|
527
|
+
/** Build a MsgRevokeAllowance */
|
|
528
|
+
export function buildRevokeFeeGrantMsg(granter: string, grantee: string): EncodedMsg;
|
|
529
|
+
|
|
530
|
+
/** Query fee grants given to a grantee */
|
|
531
|
+
export function queryFeeGrants(lcdUrl: string, grantee: string): Promise<FeeGrantAllowance[]>;
|
|
532
|
+
|
|
533
|
+
/** Query fee grants issued BY an address (granter lookup) */
|
|
534
|
+
export function queryFeeGrantsIssued(lcdUrl: string, granter: string): Promise<FeeGrantAllowance[]>;
|
|
535
|
+
|
|
536
|
+
/** Query a specific fee grant between granter and grantee */
|
|
537
|
+
export function queryFeeGrant(lcdUrl: string, granter: string, grantee: string): Promise<unknown | null>;
|
|
538
|
+
|
|
539
|
+
/** Broadcast with fee paid by a granter (fee grant) */
|
|
540
|
+
export function broadcastWithFeeGrant(client: SigningStargateClient, signerAddress: string, msgs: EncodedMsg[], granterAddress: string, memo?: string): Promise<DeliverTxResponse>;
|
|
541
|
+
|
|
542
|
+
/** Grant fee allowance to all plan subscribers who don't already have one */
|
|
543
|
+
export function grantPlanSubscribers(planId: number | string, opts: {
|
|
544
|
+
granterAddress: string;
|
|
545
|
+
lcdUrl?: string;
|
|
546
|
+
grantOpts?: FeeGrantOptions;
|
|
547
|
+
}): Promise<{ msgs: EncodedMsg[]; skipped: string[]; newGrants: string[] }>;
|
|
548
|
+
|
|
549
|
+
/** Find fee grants expiring within N days */
|
|
550
|
+
export function getExpiringGrants(
|
|
551
|
+
lcdUrl: string,
|
|
552
|
+
granteeOrGranter: string,
|
|
553
|
+
withinDays?: number,
|
|
554
|
+
role?: 'grantee' | 'granter',
|
|
555
|
+
): Promise<ExpiringGrant[]>;
|
|
556
|
+
|
|
557
|
+
/** Revoke and re-grant expiring fee grants. Returns messages ready for broadcast. */
|
|
558
|
+
export function renewExpiringGrants(
|
|
559
|
+
lcdUrl: string,
|
|
560
|
+
granterAddress: string,
|
|
561
|
+
withinDays?: number,
|
|
562
|
+
grantOpts?: FeeGrantOptions,
|
|
563
|
+
): Promise<{ msgs: EncodedMsg[]; renewed: string[] }>;
|
|
564
|
+
|
|
565
|
+
/** Monitor fee grants for expiry. Returns EventEmitter with .stop(). */
|
|
566
|
+
export function monitorFeeGrants(opts: {
|
|
567
|
+
lcdUrl: string;
|
|
568
|
+
address: string;
|
|
569
|
+
checkIntervalMs?: number;
|
|
570
|
+
warnDays?: number;
|
|
571
|
+
autoRenew?: boolean;
|
|
572
|
+
grantOpts?: FeeGrantOptions;
|
|
573
|
+
}): EventEmitter & {
|
|
574
|
+
stop(): void;
|
|
575
|
+
on(event: 'expiring', listener: (grant: ExpiringGrant) => void): EventEmitter;
|
|
576
|
+
on(event: 'expired', listener: (grant: ExpiringGrant) => void): EventEmitter;
|
|
577
|
+
on(event: 'renew', listener: (data: { msgs: EncodedMsg[]; renewed: string[] }) => void): EventEmitter;
|
|
578
|
+
on(event: 'error', listener: (err: Error) => void): EventEmitter;
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
// ─── Authz (cosmos.authz.v1beta1) ──────────────────────────────────────────
|
|
582
|
+
|
|
583
|
+
/** Build a MsgGrant for a specific message type */
|
|
584
|
+
export function buildAuthzGrantMsg(granter: string, grantee: string, msgTypeUrl: string, expiration?: Date | string): EncodedMsg;
|
|
585
|
+
|
|
586
|
+
/** Build a MsgRevoke to remove an authorization */
|
|
587
|
+
export function buildAuthzRevokeMsg(granter: string, grantee: string, msgTypeUrl: string): EncodedMsg;
|
|
588
|
+
|
|
589
|
+
/** Build a MsgExec to execute messages on behalf of a granter */
|
|
590
|
+
export function buildAuthzExecMsg(grantee: string, encodedMsgs: Array<{ typeUrl: string; value: Uint8Array }>): EncodedMsg;
|
|
591
|
+
|
|
592
|
+
/** Encode SDK message objects for use in MsgExec */
|
|
593
|
+
export function encodeForExec(msgs: EncodedMsg[]): Array<{ typeUrl: string; value: Uint8Array }>;
|
|
594
|
+
|
|
595
|
+
/** Query authz grants between granter and grantee */
|
|
596
|
+
export function queryAuthzGrants(lcdUrl: string, granter: string, grantee: string): Promise<unknown[]>;
|
|
597
|
+
|
|
598
|
+
// ─── Subscriptions & Plans ─────────────────────────────────────────────────
|
|
599
|
+
|
|
600
|
+
/** Query a wallet's active subscriptions */
|
|
601
|
+
export function querySubscriptions(lcdUrl: string, walletAddr: string, opts?: { status?: 'active' | 'inactive' }): Promise<{ items: Subscription[]; total: number | null }>;
|
|
602
|
+
|
|
603
|
+
/** Get a single subscription by ID */
|
|
604
|
+
export function querySubscription(id: string | number, lcdUrl?: string): Promise<Subscription | null>;
|
|
605
|
+
|
|
606
|
+
/** Check if wallet has active subscription for a plan */
|
|
607
|
+
export function hasActiveSubscription(address: string, planId: number | string, lcdUrl?: string): Promise<{ has: boolean; subscription?: Subscription }>;
|
|
608
|
+
|
|
609
|
+
/** Subscribe to a plan. Returns subscription ID from TX events. */
|
|
610
|
+
export function subscribeToPlan(client: SigningStargateClient, fromAddress: string, planId: number | string | bigint, denom?: string): Promise<SubscribeToPlanResult>;
|
|
611
|
+
|
|
612
|
+
/** Send P2P tokens to an address */
|
|
613
|
+
export function sendTokens(client: SigningStargateClient, fromAddress: string, toAddress: string, amountUdvpn: number | string, memo?: string): Promise<DeliverTxResponse>;
|
|
614
|
+
|
|
615
|
+
/** Query nodes linked to a plan */
|
|
616
|
+
export function queryPlanNodes(planId: number | string, lcdUrl?: string): Promise<{ items: ChainNode[]; total: number | null }>;
|
|
617
|
+
|
|
618
|
+
/** Discover all plans with metadata */
|
|
619
|
+
export function discoverPlans(lcdUrl?: string, opts?: {
|
|
620
|
+
maxId?: number;
|
|
621
|
+
batchSize?: number;
|
|
622
|
+
includeEmpty?: boolean;
|
|
623
|
+
}): Promise<DiscoveredPlan[]>;
|
|
624
|
+
|
|
625
|
+
/** Query all subscriptions for a plan */
|
|
626
|
+
export function queryPlanSubscribers(planId: number | string, opts?: {
|
|
627
|
+
lcdUrl?: string;
|
|
628
|
+
excludeAddress?: string;
|
|
629
|
+
}): Promise<{ subscribers: PlanSubscriber[]; total: number | null }>;
|
|
630
|
+
|
|
631
|
+
/** Get plan stats with self-subscription filtered out */
|
|
632
|
+
export function getPlanStats(planId: number | string, ownerAddress: string, opts?: {
|
|
633
|
+
lcdUrl?: string;
|
|
634
|
+
}): Promise<PlanStats>;
|
|
635
|
+
|
|
636
|
+
/** Get provider details by address */
|
|
637
|
+
export function getProviderByAddress(provAddress: string, opts?: { lcdUrl?: string }): Promise<Provider | null>;
|
|
638
|
+
|
|
639
|
+
// ─── Sessions ──────────────────────────────────────────────────────────────
|
|
640
|
+
|
|
641
|
+
/** Query session allocation (remaining bandwidth) */
|
|
642
|
+
export function querySessionAllocation(lcdUrl: string, sessionId: string | number | bigint): Promise<{
|
|
643
|
+
maxBytes: number;
|
|
644
|
+
usedBytes: number;
|
|
645
|
+
remainingBytes: number;
|
|
646
|
+
percentUsed: number;
|
|
647
|
+
} | null>;
|
|
648
|
+
|
|
649
|
+
/** List all sessions for a wallet */
|
|
650
|
+
export function querySessions(address: string, lcdUrl?: string, opts?: { status?: string }): Promise<{ items: ChainSession[]; total: number }>;
|
|
651
|
+
|
|
652
|
+
/** Flatten base_session nesting so session.id works (prevents the #1 footgun) */
|
|
653
|
+
export function flattenSession(session: ChainSession): FlatSession;
|
|
654
|
+
|
|
655
|
+
// ─── Batch Operations ──────────────────────────────────────────────────────
|
|
656
|
+
|
|
657
|
+
/** Build batch MsgStartSession messages for multiple nodes in one TX */
|
|
658
|
+
export function buildBatchStartSession(from: string, nodes: Array<{
|
|
659
|
+
nodeAddress: string;
|
|
660
|
+
gigabytes?: number;
|
|
661
|
+
maxPrice: PriceEntry;
|
|
662
|
+
}>): EncodedMsg[];
|
|
663
|
+
|
|
664
|
+
/** Build MsgEndSession to close a session early */
|
|
665
|
+
export function buildEndSessionMsg(from: string, sessionId: number | string | bigint): EncodedMsg;
|
|
666
|
+
|
|
667
|
+
/** Build batch MsgSend messages for token distribution */
|
|
668
|
+
export function buildBatchSend(fromAddress: string, recipients: Array<{ address: string; amountUdvpn: number | string }>): EncodedMsg[];
|
|
669
|
+
|
|
670
|
+
/** Build batch MsgLinkNode messages */
|
|
671
|
+
export function buildBatchLink(provAddress: string, planId: number | string | bigint, nodeAddresses: string[]): EncodedMsg[];
|
|
672
|
+
|
|
673
|
+
/** Decode base64-encoded TX events into readable key-value pairs */
|
|
674
|
+
export function decodeTxEvents(events: unknown[]): Array<{ type: string; attributes: Array<{ key: string; value: string }> }>;
|
|
675
|
+
|
|
676
|
+
/** Extract ALL session IDs from a batch TX result */
|
|
677
|
+
export function extractAllSessionIds(txResult: DeliverTxResponse): bigint[];
|
|
678
|
+
|
|
679
|
+
/** Estimate gas fee for a batch of messages */
|
|
680
|
+
export function estimateBatchFee(msgCount: number, msgType?: 'startSession' | 'feeGrant' | 'send' | 'link'): BatchFeeEstimate;
|
|
681
|
+
|
|
682
|
+
/** Estimate the cost of starting a session with a node */
|
|
683
|
+
export function estimateSessionCost(nodeInfo: unknown, gigabytes?: number, options?: {
|
|
684
|
+
preferHourly?: boolean;
|
|
685
|
+
hours?: number;
|
|
686
|
+
}): SessionCostEstimate;
|
|
687
|
+
|
|
688
|
+
/** Start sessions on multiple nodes in one batch TX (OPERATOR TOOL) */
|
|
689
|
+
export function batchStartSessions(opts: {
|
|
690
|
+
mnemonic: string;
|
|
691
|
+
rpcUrl?: string;
|
|
692
|
+
lcdUrl?: string;
|
|
693
|
+
nodes: Array<{ nodeAddress: string; gigabytes?: number; maxPrice?: PriceEntry }>;
|
|
694
|
+
}): Promise<{ txHash: string; sessionIds: bigint[] }>;
|
|
695
|
+
|
|
696
|
+
/** Wait for batch sessions to appear on LCD */
|
|
697
|
+
export function waitForBatchSessions(sessionIds: bigint[], opts?: {
|
|
698
|
+
lcdUrl?: string;
|
|
699
|
+
timeoutMs?: number;
|
|
700
|
+
pollIntervalMs?: number;
|
|
701
|
+
}): Promise<Array<{ sessionId: bigint; status: string }>>;
|
|
702
|
+
|
|
703
|
+
/** Wait for a single session to become active on LCD */
|
|
704
|
+
export function waitForSessionActive(sessionId: bigint | string | number, opts?: {
|
|
705
|
+
lcdUrl?: string;
|
|
706
|
+
timeoutMs?: number;
|
|
707
|
+
pollIntervalMs?: number;
|
|
708
|
+
}): Promise<boolean>;
|
|
709
|
+
|
|
710
|
+
// ─── Protocol ──────────────────────────────────────────────────────────────
|
|
711
|
+
|
|
712
|
+
import type {
|
|
713
|
+
NodeStatus,
|
|
714
|
+
WgKeyPair,
|
|
715
|
+
HandshakeResult,
|
|
716
|
+
V2RayHandshakeResult,
|
|
717
|
+
SpeedResult,
|
|
718
|
+
SpeedComparison,
|
|
719
|
+
SpeedtestDefaults,
|
|
720
|
+
WatchdogResult,
|
|
721
|
+
} from './protocol.js';
|
|
722
|
+
|
|
723
|
+
/** Query node status via its REST API */
|
|
724
|
+
export function nodeStatusV3(remoteUrl: string, agent?: import('https').Agent): Promise<NodeStatus>;
|
|
725
|
+
|
|
726
|
+
/** Generate WireGuard keypair (Curve25519) */
|
|
727
|
+
export function generateWgKeyPair(): WgKeyPair;
|
|
728
|
+
|
|
729
|
+
/** Perform WireGuard handshake with node */
|
|
730
|
+
export function initHandshakeV3(remoteUrl: string, sessionId: bigint | string | number, cosmosPrivKey: Uint8Array, wgPublicKey: Buffer, agent?: import('https').Agent): Promise<HandshakeResult>;
|
|
731
|
+
|
|
732
|
+
/** Perform V2Ray handshake with node */
|
|
733
|
+
export function initHandshakeV3V2Ray(remoteUrl: string, sessionId: bigint | string | number, cosmosPrivKey: Uint8Array, uuid: string, agent?: import('https').Agent): Promise<V2RayHandshakeResult>;
|
|
734
|
+
|
|
735
|
+
/** Write WireGuard config file and return the file path */
|
|
736
|
+
export function writeWgConfig(wgPrivKey: Buffer, assignedAddrs: string[], serverPubKey: string, serverEndpoint: string, splitIPs?: string[] | null, opts?: { dns?: string; mtu?: number; keepalive?: number }): string;
|
|
737
|
+
|
|
738
|
+
/** Build V2Ray client config JSON object */
|
|
739
|
+
export function buildV2RayClientConfig(serverHost: string, metadataJson: string, uuid: string, socksPort?: number, opts?: { dns?: string; dnsPreset?: string }): object;
|
|
740
|
+
|
|
741
|
+
/** Generate a V2Ray-compatible UUID */
|
|
742
|
+
export function generateV2RayUUID(): string;
|
|
743
|
+
|
|
744
|
+
/** Extract session ID from handshake response */
|
|
745
|
+
export function extractSessionId(hsResult: unknown): bigint | null;
|
|
746
|
+
|
|
747
|
+
/** Wait for a TCP port to become available */
|
|
748
|
+
export function waitForPort(port: number, timeoutMs?: number, host?: string, intervalMs?: number): Promise<boolean>;
|
|
749
|
+
|
|
750
|
+
/** Validate an IP/CIDR string (e.g. "10.8.0.2/24") */
|
|
751
|
+
export function validateCIDR(cidr: string): boolean;
|
|
752
|
+
|
|
753
|
+
// ─── Session Message Encoders ──────────────────────────────────────────────
|
|
754
|
+
|
|
755
|
+
/** Encode MsgStartSession (sentinel.session.v3) */
|
|
756
|
+
export function encodeMsgStartSession(params: { from: string; node_address: string; gigabytes?: number; hours?: number; max_price?: unknown }): Uint8Array;
|
|
757
|
+
|
|
758
|
+
/** Encode MsgEndSession (sentinel.session.v3) */
|
|
759
|
+
export function encodeMsgEndSession(params: { from: string; id: number | bigint; rating?: number }): Uint8Array;
|
|
760
|
+
|
|
761
|
+
/** Encode MsgStartSubscription (sentinel.subscription.v3) */
|
|
762
|
+
export function encodeMsgStartSubscription(params: { from: string; id: number | bigint; denom?: string; renewalPricePolicy?: number }): Uint8Array;
|
|
763
|
+
|
|
764
|
+
/** Encode MsgSubStartSession (sentinel.subscription.v3) */
|
|
765
|
+
export function encodeMsgSubStartSession(params: { from: string; id: number | bigint; nodeAddress: string }): Uint8Array;
|
|
766
|
+
|
|
767
|
+
/** Encode MsgCancelSubscription (sentinel.subscription.v3) */
|
|
768
|
+
export function encodeMsgCancelSubscription(params: { from: string; id: number | bigint }): Uint8Array;
|
|
769
|
+
|
|
770
|
+
/** Encode MsgRenewSubscription (sentinel.subscription.v3) */
|
|
771
|
+
export function encodeMsgRenewSubscription(params: { from: string; id: number | bigint; denom?: string }): Uint8Array;
|
|
772
|
+
|
|
773
|
+
/** Encode MsgShareSubscription (sentinel.subscription.v3) */
|
|
774
|
+
export function encodeMsgShareSubscription(params: { from: string; id: number | bigint; accAddress: string; bytes: string | number }): Uint8Array;
|
|
775
|
+
|
|
776
|
+
/** Encode MsgUpdateSubscription (sentinel.subscription.v3) */
|
|
777
|
+
export function encodeMsgUpdateSubscription(params: { from: string; id: number | bigint; renewalPricePolicy: number }): Uint8Array;
|
|
778
|
+
|
|
779
|
+
/** Encode MsgUpdateSession (sentinel.session.v3) */
|
|
780
|
+
export function encodeMsgUpdateSession(params: { from: string; id: number | bigint; downloadBytes: string | number; uploadBytes: string | number }): Uint8Array;
|
|
781
|
+
|
|
782
|
+
/** Encode MsgRegisterNode (sentinel.node.v3) */
|
|
783
|
+
export function encodeMsgRegisterNode(params: { from: string; gigabytePrices?: unknown[]; hourlyPrices?: unknown[]; remoteAddrs?: string[] }): Uint8Array;
|
|
784
|
+
|
|
785
|
+
/** Encode MsgUpdateNodeDetails (sentinel.node.v3) */
|
|
786
|
+
export function encodeMsgUpdateNodeDetails(params: { from: string; gigabytePrices?: unknown[]; hourlyPrices?: unknown[]; remoteAddrs?: string[] }): Uint8Array;
|
|
787
|
+
|
|
788
|
+
/** Encode MsgUpdateNodeStatus (sentinel.node.v3) */
|
|
789
|
+
export function encodeMsgUpdateNodeStatus(params: { from: string; status: number }): Uint8Array;
|
|
790
|
+
|
|
791
|
+
/** Encode MsgUpdatePlanDetails (sentinel.plan.v3) */
|
|
792
|
+
export function encodeMsgUpdatePlanDetails(params: { from: string; id: number | bigint; bytes?: string; duration?: number | { seconds: number; nanos?: number }; prices?: unknown[] }): Uint8Array;
|
|
793
|
+
|
|
794
|
+
// ─── Plan & Provider Message Encoders ──────────────────────────────────────
|
|
795
|
+
|
|
796
|
+
/** Encode MsgRegisterProviderRequest */
|
|
797
|
+
export function encodeMsgRegisterProvider(params: { from: string; name: string; identity?: string; website?: string; description?: string }): Uint8Array;
|
|
798
|
+
|
|
799
|
+
/** Encode MsgUpdateProviderDetailsRequest */
|
|
800
|
+
export function encodeMsgUpdateProviderDetails(params: { from: string; name?: string; identity?: string; website?: string; description?: string }): Uint8Array;
|
|
801
|
+
|
|
802
|
+
/** Encode MsgUpdateProviderStatusRequest */
|
|
803
|
+
export function encodeMsgUpdateProviderStatus(params: { from: string; status: number }): Uint8Array;
|
|
804
|
+
|
|
805
|
+
/** Encode MsgCreatePlanRequest */
|
|
806
|
+
export function encodeMsgCreatePlan(params: { from: string; bytes?: string; duration?: number | { seconds: number; nanos?: number }; prices?: PriceEntry[]; isPrivate?: boolean }): Uint8Array;
|
|
807
|
+
|
|
808
|
+
/** Encode MsgUpdatePlanStatusRequest */
|
|
809
|
+
export function encodeMsgUpdatePlanStatus(params: { from: string; id: number | bigint; status: number }): Uint8Array;
|
|
810
|
+
|
|
811
|
+
/** Encode MsgLinkNodeRequest */
|
|
812
|
+
export function encodeMsgLinkNode(params: { from: string; id: number | bigint; nodeAddress: string }): Uint8Array;
|
|
813
|
+
|
|
814
|
+
/** Encode MsgUnlinkNodeRequest */
|
|
815
|
+
export function encodeMsgUnlinkNode(params: { from: string; id: number | bigint; nodeAddress: string }): Uint8Array;
|
|
816
|
+
|
|
817
|
+
/** Encode MsgPlanStartSession (plan subscribe + session in one TX) */
|
|
818
|
+
export function encodeMsgPlanStartSession(params: { from: string; id: number | bigint; denom?: string; renewalPricePolicy?: number; nodeAddress?: string }): Uint8Array;
|
|
819
|
+
|
|
820
|
+
/** Encode MsgStartLeaseRequest */
|
|
821
|
+
export function encodeMsgStartLease(params: { from: string; nodeAddress: string; hours: number; maxPrice?: PriceEntry; renewalPricePolicy?: number }): Uint8Array;
|
|
822
|
+
|
|
823
|
+
/** Encode MsgEndLeaseRequest */
|
|
824
|
+
export function encodeMsgEndLease(params: { from: string; id: number | bigint }): Uint8Array;
|
|
825
|
+
|
|
826
|
+
/** Encode sentinel.types.v1.Price protobuf */
|
|
827
|
+
export function encodePrice(params: PriceEntry): Buffer;
|
|
828
|
+
|
|
829
|
+
/** Encode google.protobuf.Duration */
|
|
830
|
+
export function encodeDuration(params: { seconds: number; nanos?: number }): Buffer;
|
|
831
|
+
|
|
832
|
+
/** Convert sdk.Dec string to scaled integer string (multiply by 10^18) */
|
|
833
|
+
export function decToScaledInt(decStr: string): string;
|
|
834
|
+
|
|
835
|
+
// ─── WireGuard ─────────────────────────────────────────────────────────────
|
|
836
|
+
|
|
837
|
+
/** Install and activate a WireGuard tunnel */
|
|
838
|
+
export function installWgTunnel(confPath: string): Promise<string>;
|
|
839
|
+
|
|
840
|
+
/** Uninstall a WireGuard tunnel */
|
|
841
|
+
export function uninstallWgTunnel(tunnelName?: string): Promise<void>;
|
|
842
|
+
|
|
843
|
+
/** Legacy: connect WireGuard from instance */
|
|
844
|
+
export function connectWireGuard(wgInstance: unknown): Promise<string>;
|
|
845
|
+
|
|
846
|
+
/** Legacy: disconnect WireGuard */
|
|
847
|
+
export function disconnectWireGuard(): Promise<void>;
|
|
848
|
+
|
|
849
|
+
/** Emergency force-kill all sentinel WireGuard tunnels (sync, safe in exit handlers) */
|
|
850
|
+
export function emergencyCleanupSync(): void;
|
|
851
|
+
|
|
852
|
+
/** Check if a tunnel is currently active */
|
|
853
|
+
export function watchdogCheck(): WatchdogResult;
|
|
854
|
+
|
|
855
|
+
/** Whether the current process is running as admin/root */
|
|
856
|
+
export const IS_ADMIN: boolean;
|
|
857
|
+
|
|
858
|
+
/** Path to wireguard.exe (Windows) or null */
|
|
859
|
+
export const WG_EXE: string | null;
|
|
860
|
+
|
|
861
|
+
/** Path to wg-quick (Linux/macOS) or null */
|
|
862
|
+
export const WG_QUICK: string | null;
|
|
863
|
+
|
|
864
|
+
/** Whether WireGuard is available on this system */
|
|
865
|
+
export const WG_AVAILABLE: boolean;
|
|
866
|
+
|
|
867
|
+
// ─── Preflight Helpers ─────────────────────────────────────────────────────
|
|
868
|
+
|
|
869
|
+
/** Check for orphaned WireGuard tunnels from previous crashes */
|
|
870
|
+
export function checkOrphanedTunnels(): { found: boolean; tunnels: string[]; cleaned: boolean };
|
|
871
|
+
|
|
872
|
+
/** Remove orphaned WireGuard tunnels */
|
|
873
|
+
export function cleanOrphanedTunnels(): { cleaned: number; errors: string[] };
|
|
874
|
+
|
|
875
|
+
/** Check for orphaned V2Ray processes */
|
|
876
|
+
export function checkOrphanedV2Ray(): { found: boolean; pids: number[] };
|
|
877
|
+
|
|
878
|
+
/** Detect running VPN software that may conflict */
|
|
879
|
+
export function checkVpnConflicts(): { conflicts: Array<{ name: string; running: boolean }> };
|
|
880
|
+
|
|
881
|
+
/** Check if common V2Ray SOCKS5 ports are in use */
|
|
882
|
+
export function checkPortConflicts(): { conflicts: Array<{ port: number; inUse: boolean }> };
|
|
883
|
+
|
|
884
|
+
// ─── Speed Testing ─────────────────────────────────────────────────────────
|
|
885
|
+
|
|
886
|
+
/** Run speed test directly (no VPN) */
|
|
887
|
+
export function speedtestDirect(): Promise<SpeedResult>;
|
|
888
|
+
|
|
889
|
+
/** Run speed test through SOCKS5 proxy (V2Ray tunnel) */
|
|
890
|
+
export function speedtestViaSocks5(testMb?: number, proxyPort?: number, socksAuth?: { user: string; pass: string } | null): Promise<SpeedResult>;
|
|
891
|
+
|
|
892
|
+
/** Resolve Cloudflare speedtest IPs for split tunneling */
|
|
893
|
+
export function resolveSpeedtestIPs(): Promise<string[]>;
|
|
894
|
+
|
|
895
|
+
/** Flush cached DNS resolutions. Call when switching VPN connections. */
|
|
896
|
+
export function flushSpeedTestDnsCache(): void;
|
|
897
|
+
|
|
898
|
+
/** Compare two speed test results */
|
|
899
|
+
export function compareSpeedTests(before: SpeedResult, after: SpeedResult): SpeedComparison;
|
|
900
|
+
|
|
901
|
+
/** Speed test configuration constants */
|
|
902
|
+
export const SPEEDTEST_DEFAULTS: Readonly<SpeedtestDefaults>;
|
|
903
|
+
|
|
904
|
+
// ─── State Persistence ─────────────────────────────────────────────────────
|
|
905
|
+
|
|
906
|
+
import type { SDKState, RecoverResult, PidCheck, SavedCredentials } from './session.js';
|
|
907
|
+
|
|
908
|
+
/** Save current connection state for crash recovery */
|
|
909
|
+
export function saveState(state: SDKState): void;
|
|
910
|
+
|
|
911
|
+
/** Load saved state (null if none) */
|
|
912
|
+
export function loadState(): SDKState | null;
|
|
913
|
+
|
|
914
|
+
/** Clear saved state */
|
|
915
|
+
export function clearState(): void;
|
|
916
|
+
|
|
917
|
+
/** Recover orphaned tunnels/proxies from a previous crash */
|
|
918
|
+
export function recoverOrphans(): RecoverResult;
|
|
919
|
+
|
|
920
|
+
/** Mark a session as poisoned (failed, don't retry) */
|
|
921
|
+
export function markSessionPoisoned(sessionId: string, nodeAddress: string, error: string): void;
|
|
922
|
+
|
|
923
|
+
/** Mark a session as active */
|
|
924
|
+
export function markSessionActive(sessionId: string, nodeAddress: string): void;
|
|
925
|
+
|
|
926
|
+
/** Check if a session is poisoned */
|
|
927
|
+
export function isSessionPoisoned(sessionId: string): boolean;
|
|
928
|
+
|
|
929
|
+
/** Get session history (all sessions, active and poisoned) */
|
|
930
|
+
export function getSessionHistory(): Record<string, unknown>;
|
|
931
|
+
|
|
932
|
+
/** Write a PID file for process management */
|
|
933
|
+
export function writePidFile(name?: string): { pidFile: string };
|
|
934
|
+
|
|
935
|
+
/** Check if a process with a PID file is running */
|
|
936
|
+
export function checkPidFile(name?: string): PidCheck;
|
|
937
|
+
|
|
938
|
+
/** Clear a PID file */
|
|
939
|
+
export function clearPidFile(name?: string): void;
|
|
940
|
+
|
|
941
|
+
/** Save handshake credentials for a node+session pair (enables fast reconnect) */
|
|
942
|
+
export function saveCredentials(nodeAddress: string, sessionId: string, credentials: Record<string, unknown>): void;
|
|
943
|
+
|
|
944
|
+
/** Load saved credentials for a node (null if none) */
|
|
945
|
+
export function loadCredentials(nodeAddress: string): SavedCredentials | null;
|
|
946
|
+
|
|
947
|
+
/** Clear saved credentials for a specific node */
|
|
948
|
+
export function clearCredentials(nodeAddress: string): void;
|
|
949
|
+
|
|
950
|
+
/** Clear all saved credentials */
|
|
951
|
+
export function clearAllCredentials(): void;
|
|
952
|
+
|
|
953
|
+
// ─── VPN Settings Persistence ──────────────────────────────────────────────
|
|
954
|
+
|
|
955
|
+
/** Load persisted VPN settings from ~/.sentinel-sdk/settings.json */
|
|
956
|
+
export function loadVpnSettings(): Record<string, unknown>;
|
|
957
|
+
|
|
958
|
+
/** Save VPN settings to ~/.sentinel-sdk/settings.json */
|
|
959
|
+
export function saveVpnSettings(settings: Record<string, unknown>): void;
|
|
960
|
+
|
|
961
|
+
// ─── TLS Trust (TOFU) ─────────────────────────────────────────────────────
|
|
962
|
+
|
|
963
|
+
/** Create an HTTPS agent with TOFU certificate pinning for a node */
|
|
964
|
+
export function createNodeHttpsAgent(nodeAddress: string, mode?: 'tofu' | 'none'): import('https').Agent;
|
|
965
|
+
|
|
966
|
+
/** Clear stored certificate for a specific node */
|
|
967
|
+
export function clearKnownNode(nodeAddress: string): void;
|
|
968
|
+
|
|
969
|
+
/** Clear all stored node certificates */
|
|
970
|
+
export function clearAllKnownNodes(): void;
|
|
971
|
+
|
|
972
|
+
/** Get stored certificate info for a node (null if unknown) */
|
|
973
|
+
export function getKnownNode(nodeAddress: string): { fingerprint: string; firstSeen: string; lastSeen: string } | null;
|
|
974
|
+
|
|
975
|
+
/** CA-validated HTTPS agent for LCD/RPC public endpoints */
|
|
976
|
+
export const publicEndpointAgent: import('https').Agent;
|
|
977
|
+
|
|
978
|
+
// ─── Defaults & Constants ──────────────────────────────────────────────────
|
|
979
|
+
|
|
980
|
+
export const SDK_VERSION: string;
|
|
981
|
+
export const LAST_VERIFIED: string;
|
|
982
|
+
export const HARDCODED_NOTE: string;
|
|
983
|
+
export const CHAIN_ID: string;
|
|
984
|
+
export const CHAIN_VERSION: string;
|
|
985
|
+
export const COSMOS_SDK_VERSION: string;
|
|
986
|
+
export const DENOM: string;
|
|
987
|
+
export const GAS_PRICE: string;
|
|
988
|
+
export const DEFAULT_RPC: string;
|
|
989
|
+
export const DEFAULT_LCD: string;
|
|
990
|
+
export const RPC_ENDPOINTS: Endpoint[];
|
|
991
|
+
export const LCD_ENDPOINTS: Endpoint[];
|
|
992
|
+
export const V2RAY_VERSION: string;
|
|
993
|
+
export const TRANSPORT_SUCCESS_RATES: Record<string, import('./protocol.js').TransportSuccessRate>;
|
|
994
|
+
export const BROKEN_NODES: Array<import('./nodes.js').BrokenNode>;
|
|
995
|
+
export const PRICING_REFERENCE: import('./pricing.js').PricingReference;
|
|
996
|
+
export const DEFAULT_TIMEOUTS: Readonly<import('./connection.js').ConnectionTimeouts>;
|
|
997
|
+
|
|
998
|
+
/** Try an operation across multiple endpoints with fallback */
|
|
999
|
+
export function tryWithFallback<T>(
|
|
1000
|
+
endpoints: Endpoint[],
|
|
1001
|
+
operation: (url: string) => Promise<T>,
|
|
1002
|
+
label?: string,
|
|
1003
|
+
): Promise<FallbackResult<T>>;
|
|
1004
|
+
|
|
1005
|
+
/** Check endpoint health -- returns endpoints sorted by latency */
|
|
1006
|
+
export function checkEndpointHealth(
|
|
1007
|
+
endpoints: Array<{ url: string; name: string }>,
|
|
1008
|
+
timeoutMs?: number,
|
|
1009
|
+
): Promise<EndpointHealth[]>;
|
|
1010
|
+
|
|
1011
|
+
/** Promise-based delay (ms) */
|
|
1012
|
+
export function sleep(ms: number): Promise<void>;
|
|
1013
|
+
|
|
1014
|
+
/** Convert bytes transferred over seconds to Mbps */
|
|
1015
|
+
export function bytesToMbps(bytes: number, seconds: number, decimals?: number): number;
|
|
1016
|
+
|
|
1017
|
+
// ─── Dynamic Transport Rate Tracking ───────────────────────────────────────
|
|
1018
|
+
|
|
1019
|
+
/** Record a transport connection success/failure (called automatically by setupV2Ray) */
|
|
1020
|
+
export function recordTransportResult(transportKey: string, success: boolean): void;
|
|
1021
|
+
|
|
1022
|
+
/** Get dynamic success rate for a transport (null if < 2 samples) */
|
|
1023
|
+
export function getDynamicRate(transportKey: string): number | null;
|
|
1024
|
+
|
|
1025
|
+
/** Get all dynamic rates */
|
|
1026
|
+
export function getDynamicRates(): Record<string, import('./protocol.js').DynamicTransportRate>;
|
|
1027
|
+
|
|
1028
|
+
/** Clear all dynamic rate data. Pass true to also clear persisted data on disk. */
|
|
1029
|
+
export function resetDynamicRates(persist?: boolean): void;
|
|
1030
|
+
|
|
1031
|
+
// ─── DNS Presets ───────────────────────────────────────────────────────────
|
|
1032
|
+
|
|
1033
|
+
import type { DnsPreset } from './settings.js';
|
|
1034
|
+
|
|
1035
|
+
/** DNS server presets. Handshake is default (censorship-resistant). */
|
|
1036
|
+
export const DNS_PRESETS: Readonly<{
|
|
1037
|
+
handshake: DnsPreset;
|
|
1038
|
+
google: DnsPreset;
|
|
1039
|
+
cloudflare: DnsPreset;
|
|
1040
|
+
}>;
|
|
1041
|
+
|
|
1042
|
+
/** Default DNS preset name ('handshake') */
|
|
1043
|
+
export const DEFAULT_DNS_PRESET: string;
|
|
1044
|
+
|
|
1045
|
+
/** Fallback order when primary DNS fails */
|
|
1046
|
+
export const DNS_FALLBACK_ORDER: string[];
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* Resolve a DNS option into a comma-separated string for WireGuard/V2Ray config.
|
|
1050
|
+
* Includes fallback DNS servers.
|
|
1051
|
+
*/
|
|
1052
|
+
export function resolveDnsServers(dns?: string | string[]): string;
|
|
1053
|
+
|
|
1054
|
+
// ─── Display & Serialization Helpers ───────────────────────────────────────
|
|
1055
|
+
|
|
1056
|
+
/** Format micro-denom (udvpn) as human-readable P2P string. e.g. formatDvpn(40152030) -> "40.15 P2P" */
|
|
1057
|
+
export function formatDvpn(udvpn: number | string, decimals?: number): string;
|
|
1058
|
+
|
|
1059
|
+
/** Format micro-denom as P2P string (alias for formatDvpn) */
|
|
1060
|
+
export function formatP2P(udvpn: number | string, decimals?: number): string;
|
|
1061
|
+
|
|
1062
|
+
/** Serialize a ConnectResult for JSON APIs (converts BigInt -> string, strips functions) */
|
|
1063
|
+
export function serializeResult(result: ConnectResult): Record<string, unknown>;
|
|
1064
|
+
|
|
1065
|
+
/** Truncate an address for display (e.g. "sent1abc...xyz") */
|
|
1066
|
+
export function shortAddress(addr: string, prefixLen?: number, suffixLen?: number): string;
|
|
1067
|
+
|
|
1068
|
+
/** Format subscription expiry as relative time (e.g. "23d left", "expired") */
|
|
1069
|
+
export function formatSubscriptionExpiry(subscription: { inactive_at?: string; status_at?: string }): string;
|
|
1070
|
+
|
|
1071
|
+
/** Format byte count for display (e.g. "1.5 GB", "250 MB") */
|
|
1072
|
+
export function formatBytes(bytes: number | string): string;
|
|
1073
|
+
|
|
1074
|
+
/** Format milliseconds into human-readable uptime (e.g. "2h 15m") */
|
|
1075
|
+
export function formatUptime(ms: number): string;
|
|
1076
|
+
|
|
1077
|
+
/** Parse chain duration string ("557817.72s" -> structured object) */
|
|
1078
|
+
export function parseChainDuration(durationStr: string): ParsedDuration;
|
|
1079
|
+
|
|
1080
|
+
/** Compute session allocation stats from chain session data */
|
|
1081
|
+
export function computeSessionAllocation(session: {
|
|
1082
|
+
downloadBytes?: string;
|
|
1083
|
+
download_bytes?: string;
|
|
1084
|
+
uploadBytes?: string;
|
|
1085
|
+
upload_bytes?: string;
|
|
1086
|
+
maxBytes?: string;
|
|
1087
|
+
max_bytes?: string;
|
|
1088
|
+
maxDuration?: string;
|
|
1089
|
+
max_duration?: string;
|
|
1090
|
+
}): import('./session.js').SessionAllocation;
|
|
1091
|
+
|
|
1092
|
+
// ─── App Builder Helpers ───────────────────────────────────────────────────
|
|
1093
|
+
|
|
1094
|
+
import type { NodeDisplay, CountryGroup, NodePricingDisplay, SessionPriceEstimate } from './pricing.js';
|
|
1095
|
+
|
|
1096
|
+
/** Country name -> ISO code map (80+ countries, includes chain variants) */
|
|
1097
|
+
export const COUNTRY_MAP: Readonly<Record<string, string>>;
|
|
1098
|
+
|
|
1099
|
+
/** Convert country name to ISO 3166-1 alpha-2 code */
|
|
1100
|
+
export function countryNameToCode(name: string | null | undefined): string | null;
|
|
1101
|
+
|
|
1102
|
+
/** Get flag PNG URL from flagcdn.com (for native apps where emoji flags don't render) */
|
|
1103
|
+
export function getFlagUrl(code: string, width?: number): string;
|
|
1104
|
+
|
|
1105
|
+
/** Get emoji flag for web apps. Does NOT work in WPF. */
|
|
1106
|
+
export function getFlagEmoji(code: string): string;
|
|
1107
|
+
|
|
1108
|
+
/** Format raw udvpn amount to human-readable P2P price string */
|
|
1109
|
+
export function formatPriceP2P(udvpnAmount: string | number, decimals?: number): string;
|
|
1110
|
+
|
|
1111
|
+
/** Format both GB and hourly prices from a chain node for UI display */
|
|
1112
|
+
export function formatNodePricing(node: unknown): NodePricingDisplay;
|
|
1113
|
+
|
|
1114
|
+
/** Estimate session cost for a given duration/amount and pricing model */
|
|
1115
|
+
export function estimateSessionPrice(node: unknown, model: 'gb' | 'hour', amount: number): SessionPriceEstimate;
|
|
1116
|
+
|
|
1117
|
+
/** Build a display-ready node object combining chain data + status enrichment */
|
|
1118
|
+
export function buildNodeDisplay(chainNode: unknown, status?: unknown): NodeDisplay;
|
|
1119
|
+
|
|
1120
|
+
/** Group nodes by country for sidebar display */
|
|
1121
|
+
export function groupNodesByCountry(nodes: NodeDisplay[]): CountryGroup[];
|
|
1122
|
+
|
|
1123
|
+
/** Common hour options for hourly session selection UI: [1, 2, 4, 8, 12, 24] */
|
|
1124
|
+
export const HOUR_OPTIONS: number[];
|
|
1125
|
+
|
|
1126
|
+
/** Common GB options for per-GB session selection UI: [1, 2, 5, 10, 25, 50] */
|
|
1127
|
+
export const GB_OPTIONS: number[];
|
|
1128
|
+
|
|
1129
|
+
// ─── App Types ─────────────────────────────────────────────────────────────
|
|
1130
|
+
|
|
1131
|
+
import type { AppTypeConfig, AppConfigValidation } from './settings.js';
|
|
1132
|
+
|
|
1133
|
+
/** App type constants: WHITE_LABEL, DIRECT_P2P, ALL_IN_ONE */
|
|
1134
|
+
export const APP_TYPES: Readonly<{
|
|
1135
|
+
WHITE_LABEL: 'white_label';
|
|
1136
|
+
DIRECT_P2P: 'direct_p2p';
|
|
1137
|
+
ALL_IN_ONE: 'all_in_one';
|
|
1138
|
+
}>;
|
|
1139
|
+
|
|
1140
|
+
/** Per-type configuration, UI requirements, flows, and SDK function lists */
|
|
1141
|
+
export const APP_TYPE_CONFIG: Readonly<Record<string, AppTypeConfig>>;
|
|
1142
|
+
|
|
1143
|
+
/** Validate app config against type requirements. Call at startup. */
|
|
1144
|
+
export function validateAppConfig(appType: string, config?: Record<string, unknown>): AppConfigValidation;
|
|
1145
|
+
|
|
1146
|
+
/** Get recommended connect options for an app type */
|
|
1147
|
+
export function getConnectDefaults(appType: string, appConfig?: Record<string, unknown>): Record<string, unknown>;
|
|
1148
|
+
|
|
1149
|
+
// ─── App Settings ──────────────────────────────────────────────────────────
|
|
1150
|
+
|
|
1151
|
+
import type { AppSettings } from './settings.js';
|
|
1152
|
+
|
|
1153
|
+
/** Load app settings from disk. Returns defaults for missing/corrupt files. */
|
|
1154
|
+
export function loadAppSettings(): AppSettings;
|
|
1155
|
+
|
|
1156
|
+
/** Save app settings to disk (atomic write) */
|
|
1157
|
+
export function saveAppSettings(settings: AppSettings): void;
|
|
1158
|
+
|
|
1159
|
+
/** Reset all settings to defaults */
|
|
1160
|
+
export function resetAppSettings(): void;
|
|
1161
|
+
|
|
1162
|
+
/** All settings with their defaults (frozen object) */
|
|
1163
|
+
export const APP_SETTINGS_DEFAULTS: Readonly<AppSettings>;
|
|
1164
|
+
|
|
1165
|
+
// ─── Session Tracker ───────────────────────────────────────────────────────
|
|
1166
|
+
|
|
1167
|
+
import type { SessionPaymentMode } from './session.js';
|
|
1168
|
+
|
|
1169
|
+
/** Track payment mode for a session */
|
|
1170
|
+
export function trackSession(sessionId: string | number | bigint, mode: SessionPaymentMode): void;
|
|
1171
|
+
|
|
1172
|
+
/** Get payment mode for a session */
|
|
1173
|
+
export function getSessionMode(sessionId: string | number | bigint): SessionPaymentMode;
|
|
1174
|
+
|
|
1175
|
+
/** Get all tracked sessions */
|
|
1176
|
+
export function getAllTrackedSessions(): Record<string, SessionPaymentMode>;
|
|
1177
|
+
|
|
1178
|
+
/** Clear tracking for a session */
|
|
1179
|
+
export function clearSessionMode(sessionId: string | number | bigint): void;
|
|
1180
|
+
|
|
1181
|
+
// ─── Disk Cache ────────────────────────────────────────────────────────────
|
|
1182
|
+
|
|
1183
|
+
import type { CacheInfo, DiskCacheEntry } from './settings.js';
|
|
1184
|
+
|
|
1185
|
+
/** Fetch data with TTL caching + inflight deduplication + stale fallback */
|
|
1186
|
+
export function cached<T>(key: string, ttlMs: number, fetchFn: () => Promise<T>): Promise<T>;
|
|
1187
|
+
|
|
1188
|
+
/** Invalidate a single cache entry */
|
|
1189
|
+
export function cacheInvalidate(key: string): void;
|
|
1190
|
+
|
|
1191
|
+
/** Clear all cache entries */
|
|
1192
|
+
export function cacheClear(): void;
|
|
1193
|
+
|
|
1194
|
+
/** Get cache entry metadata (for debugging) */
|
|
1195
|
+
export function cacheInfo(key: string): CacheInfo | null;
|
|
1196
|
+
|
|
1197
|
+
/** Save data to disk cache */
|
|
1198
|
+
export function diskSave(key: string, data: unknown): void;
|
|
1199
|
+
|
|
1200
|
+
/** Load data from disk cache */
|
|
1201
|
+
export function diskLoad<T = unknown>(key: string, maxAgeMs: number): DiskCacheEntry<T> | null;
|
|
1202
|
+
|
|
1203
|
+
/** Clear a disk cache entry */
|
|
1204
|
+
export function diskClear(key: string): void;
|
|
1205
|
+
|
|
1206
|
+
// ─── Session Manager Class ─────────────────────────────────────────────────
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* Manages session lifecycle: session map, credential cache,
|
|
1210
|
+
* poisoning, and duplicate payment tracking.
|
|
1211
|
+
*/
|
|
1212
|
+
export class SessionManager {
|
|
1213
|
+
constructor(lcdUrl: string, walletAddress: string, options?: {
|
|
1214
|
+
mapTtl?: number;
|
|
1215
|
+
credentialPath?: string;
|
|
1216
|
+
logger?: (msg: string) => void;
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1219
|
+
/** Fetch all active sessions for the wallet with full pagination */
|
|
1220
|
+
buildSessionMap(): Promise<Map<string, { sessionId: bigint; maxBytes: number; usedBytes: number }>>;
|
|
1221
|
+
|
|
1222
|
+
/** Find existing session for a node (returns session ID or null) */
|
|
1223
|
+
findExistingSession(nodeAddress: string): Promise<bigint | null>;
|
|
1224
|
+
|
|
1225
|
+
/** Check if a session is poisoned */
|
|
1226
|
+
isPoisoned(nodeAddress: string, sessionId: bigint | string): boolean;
|
|
1227
|
+
|
|
1228
|
+
/** Mark a session as poisoned */
|
|
1229
|
+
poison(nodeAddress: string, sessionId: bigint | string, error: string): void;
|
|
1230
|
+
|
|
1231
|
+
/** Check if we already paid for a node this run */
|
|
1232
|
+
hasPaid(nodeAddress: string): boolean;
|
|
1233
|
+
|
|
1234
|
+
/** Mark a node as paid this run */
|
|
1235
|
+
markPaid(nodeAddress: string): void;
|
|
1236
|
+
|
|
1237
|
+
/** Save credentials for a session */
|
|
1238
|
+
saveCredentials(nodeAddress: string, sessionId: string, creds: Record<string, unknown>): void;
|
|
1239
|
+
|
|
1240
|
+
/** Load credentials for a node */
|
|
1241
|
+
loadCredentials(nodeAddress: string): SavedCredentials | null;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// ─── SentinelClient (Instantiable) ─────────────────────────────────────────
|
|
1245
|
+
|
|
1246
|
+
/** Options for SentinelClient constructor. */
|
|
1247
|
+
export interface SentinelClientOptions {
|
|
1248
|
+
/** Default RPC URL (overridable per-call) */
|
|
1249
|
+
rpcUrl?: string;
|
|
1250
|
+
/** Default LCD URL (overridable per-call) */
|
|
1251
|
+
lcdUrl?: string;
|
|
1252
|
+
/** Default mnemonic (overridable per-call) */
|
|
1253
|
+
mnemonic?: string;
|
|
1254
|
+
/** Default V2Ray binary path */
|
|
1255
|
+
v2rayExePath?: string;
|
|
1256
|
+
/** Logger function (default: console.log). Set to null to suppress. */
|
|
1257
|
+
logger?: ((msg: string) => void) | null;
|
|
1258
|
+
/** TLS trust mode (default: 'tofu') */
|
|
1259
|
+
tlsTrust?: 'tofu' | 'none';
|
|
1260
|
+
/** Default timeout overrides */
|
|
1261
|
+
timeouts?: import('./connection.js').ConnectionTimeouts;
|
|
1262
|
+
/** Default fullTunnel setting */
|
|
1263
|
+
fullTunnel?: boolean;
|
|
1264
|
+
/** Default systemProxy setting */
|
|
1265
|
+
systemProxy?: boolean;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Instantiable SDK client with per-instance state, DI, and EventEmitter.
|
|
1270
|
+
*
|
|
1271
|
+
* Each instance has its own EventEmitter, cached wallet/client, and
|
|
1272
|
+
* default options that merge with per-call overrides.
|
|
1273
|
+
*
|
|
1274
|
+
* LIMITATION: WireGuard and V2Ray tunnels are OS-level singletons.
|
|
1275
|
+
* Only one client can have an active tunnel at a time.
|
|
1276
|
+
*/
|
|
1277
|
+
export class SentinelClient extends EventEmitter {
|
|
1278
|
+
constructor(opts?: SentinelClientOptions);
|
|
1279
|
+
|
|
1280
|
+
/** Connect to a node (pay per GB). Options merged with constructor defaults. */
|
|
1281
|
+
connect(opts?: Partial<ConnectOptions>): Promise<ConnectResult>;
|
|
1282
|
+
|
|
1283
|
+
/** Connect with auto-fallback: picks best node, retries on failure */
|
|
1284
|
+
autoConnect(opts?: Partial<ConnectAutoOptions>): Promise<ConnectResult>;
|
|
1285
|
+
|
|
1286
|
+
/** Connect via plan subscription */
|
|
1287
|
+
connectPlan(opts?: Partial<ConnectViaPlanOptions>): Promise<ConnectResult>;
|
|
1288
|
+
|
|
1289
|
+
/** Disconnect current VPN tunnel */
|
|
1290
|
+
disconnect(): Promise<void>;
|
|
1291
|
+
|
|
1292
|
+
/** Check if a VPN tunnel is currently active */
|
|
1293
|
+
isConnected(): boolean;
|
|
1294
|
+
|
|
1295
|
+
/** Get current connection status (null if not connected) */
|
|
1296
|
+
getStatus(): ConnectionStatus | null;
|
|
1297
|
+
|
|
1298
|
+
/** List online nodes (uses 5min cache) */
|
|
1299
|
+
listNodes(options?: ListNodesOptions): Promise<ScoredNode[]>;
|
|
1300
|
+
|
|
1301
|
+
/** Get status of a specific node */
|
|
1302
|
+
nodeStatus(remoteUrl: string, nodeAddress?: string): Promise<NodeStatus>;
|
|
1303
|
+
|
|
1304
|
+
/** Create or return cached wallet from mnemonic */
|
|
1305
|
+
getWallet(mnemonic?: string): Promise<WalletResult>;
|
|
1306
|
+
|
|
1307
|
+
/** Get or create cached RPC client */
|
|
1308
|
+
getClient(rpcUrl?: string): Promise<SigningStargateClient>;
|
|
1309
|
+
|
|
1310
|
+
/** Get P2P balance for instance wallet */
|
|
1311
|
+
getBalance(): Promise<{ udvpn: number; dvpn: number }>;
|
|
1312
|
+
|
|
1313
|
+
/** Clear stored TLS fingerprint for a node */
|
|
1314
|
+
clearKnownNode(nodeAddress: string): void;
|
|
1315
|
+
|
|
1316
|
+
/** Clear all stored TLS fingerprints */
|
|
1317
|
+
clearAllKnownNodes(): void;
|
|
1318
|
+
|
|
1319
|
+
/** Get stored cert info for a node */
|
|
1320
|
+
getKnownNode(nodeAddress: string): { fingerprint: string; firstSeen: string; lastSeen: string } | null;
|
|
1321
|
+
|
|
1322
|
+
/** Register process exit handlers */
|
|
1323
|
+
registerCleanup(): void;
|
|
1324
|
+
|
|
1325
|
+
/** Clean up event forwarding. Call when discarding the instance. */
|
|
1326
|
+
destroy(): void;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
// ─── Network Audit & Node Testing (OPERATOR TOOLS) ─────────────────────────
|
|
1330
|
+
|
|
1331
|
+
/** Test a single node end-to-end */
|
|
1332
|
+
export function testNode(options: {
|
|
1333
|
+
mnemonic: string;
|
|
1334
|
+
nodeAddress: string;
|
|
1335
|
+
rpcUrl?: string;
|
|
1336
|
+
lcdUrl?: string;
|
|
1337
|
+
gigabytes?: number;
|
|
1338
|
+
speedtest?: boolean;
|
|
1339
|
+
log?: (msg: string) => void;
|
|
1340
|
+
}): Promise<{
|
|
1341
|
+
nodeAddress: string;
|
|
1342
|
+
success: boolean;
|
|
1343
|
+
serviceType?: string;
|
|
1344
|
+
speedMbps?: number;
|
|
1345
|
+
error?: string;
|
|
1346
|
+
durationMs: number;
|
|
1347
|
+
}>;
|
|
1348
|
+
|
|
1349
|
+
/** Audit the entire network (OPERATOR TOOL -- costs tokens) */
|
|
1350
|
+
export function auditNetwork(options: {
|
|
1351
|
+
mnemonic: string;
|
|
1352
|
+
rpcUrl?: string;
|
|
1353
|
+
lcdUrl?: string;
|
|
1354
|
+
concurrency?: number;
|
|
1355
|
+
maxNodes?: number;
|
|
1356
|
+
speedtest?: boolean;
|
|
1357
|
+
onProgress?: (result: unknown) => void;
|
|
1358
|
+
log?: (msg: string) => void;
|
|
1359
|
+
}): Promise<{
|
|
1360
|
+
results: unknown[];
|
|
1361
|
+
stats: { total: number; success: number; failed: number; skipped: number };
|
|
1362
|
+
}>;
|
|
1363
|
+
|
|
1364
|
+
/** Load transport cache from disk */
|
|
1365
|
+
export function loadTransportCache(cachePath?: string): void;
|
|
1366
|
+
|
|
1367
|
+
/** Save transport cache to disk */
|
|
1368
|
+
export function saveTransportCache(cachePath?: string): void;
|
|
1369
|
+
|
|
1370
|
+
/** Record a transport success for reordering */
|
|
1371
|
+
export function recordTransportSuccess(nodeAddr: string, transport: string): void;
|
|
1372
|
+
|
|
1373
|
+
/** Record a transport failure */
|
|
1374
|
+
export function recordTransportFailure(transport: string): void;
|
|
1375
|
+
|
|
1376
|
+
/** Reorder V2Ray outbounds based on cached transport success rates */
|
|
1377
|
+
export function reorderOutbounds(nodeAddr: string, outbounds: unknown[]): unknown[];
|
|
1378
|
+
|
|
1379
|
+
/** Get transport cache statistics */
|
|
1380
|
+
export function getCacheStats(): { totalEntries: number; totalSamples: number };
|