@qntx/wallet-engine 0.8.1 → 0.9.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.
@@ -2,9 +2,9 @@ import { r as NetworkInfo } from "./registry-LcFSPrE1.mjs";
2
2
  import { StoreApi } from "zustand/vanilla";
3
3
  import { SignRequest } from "@qntx/wallet-chains";
4
4
  import { NostrKeyRef, UnlockFactor, Wallet } from "@qntx/wallet";
5
+ import { decodeEvm } from "@qntx/wallet-chains/evm";
5
6
  import "@scure/btc-signer";
6
7
  import { CooperativeExitResult, LightningInvoice, LightningPayment, LightningSendStatus, SparkClient, SparkNetwork, SparkPayment, SparkStore, SparkTransfer } from "@qntx/spark";
7
- import { decodeEvm } from "@qntx/wallet-chains/evm";
8
8
  import { LnurlPayRequest, LnurlWithdrawRequest } from "@qntx/spark/lnurl";
9
9
  import { Event, NostrSigner, UnsignedEvent } from "@qntx/nostr";
10
10
  import { chains } from "@qntx/wallet/chains";
@@ -42,6 +42,10 @@ type EventBus<E> = {
42
42
  on: <K extends keyof E>(type: K, listener: (payload: E[K]) => void) => () => void;
43
43
  };
44
44
  declare function createEventBus<E>(logger: EngineLogger): EventBus<E>;
45
+ type GatewayConfig = {
46
+ readonly url: string;
47
+ readonly installId: string;
48
+ };
45
49
  /**
46
50
  * Engine storage port: named collections of byte values. `collection` is synchronous and cheap —
47
51
  * the same collection object backs every call, so guards (closed) live on the store.
@@ -57,6 +61,62 @@ type EngineStore = {
57
61
  readonly collection: (name: string) => EngineCollection;
58
62
  readonly close: () => Promise<void>;
59
63
  };
64
+ /**
65
+ * Non-secret device data (the phishing list, the origins the user trusts): available while the
66
+ * wallet is locked, and the host may keep it unencrypted. Never put anything secret in it.
67
+ */
68
+ type PublicStore = {
69
+ readonly get: (key: string) => Promise<Uint8Array | undefined>;
70
+ readonly put: (key: string, bytes: Uint8Array) => Promise<void>;
71
+ };
72
+ /**
73
+ * `blocked`: on the list. `trusted`: on the list, but the user trusts that origin. `clear`: not on
74
+ * the list, or not a web page. `unchecked`: no list has been loaded yet.
75
+ */
76
+ type PhishingStatus = "blocked" | "trusted" | "clear" | "unchecked";
77
+ declare const PHISHING_REFRESH_MS = 3600000;
78
+ type PhishingState = {
79
+ readonly version: number | null;
80
+ /** Last successful sync in this process, or the stored list's time after a restart. */
81
+ readonly updatedAt: number | null;
82
+ readonly trusted: ReadonlyArray<string>;
83
+ };
84
+ type PhishingControllerOptions = {
85
+ readonly publicStore: PublicStore;
86
+ readonly gateway?: GatewayConfig | undefined;
87
+ readonly fetch: typeof globalThis.fetch;
88
+ readonly now: () => number;
89
+ readonly setTimer: (ms: number, fn: () => void) => () => void;
90
+ readonly logger: EngineLogger;
91
+ };
92
+ declare class PhishingController extends Controller<PhishingState> {
93
+ private readonly options;
94
+ private readonly fetchGateway;
95
+ private deny;
96
+ private allow;
97
+ private inflight;
98
+ private abort;
99
+ private cancelTimer;
100
+ private epoch;
101
+ private destroyed;
102
+ constructor(options: PhishingControllerOptions);
103
+ init(): Promise<void>;
104
+ destroy(): Promise<void>;
105
+ check(url: string): PhishingStatus;
106
+ /** Fetches a snapshot or diff from the gateway; one request at a time, never throws. */
107
+ sync(): Promise<void>;
108
+ trust(origin: string): Promise<void>;
109
+ untrust(origin: string): Promise<void>;
110
+ private assertOrigin;
111
+ private saveTrusted;
112
+ private arm;
113
+ private refresh;
114
+ private load;
115
+ private restoreList;
116
+ private fetchAndApply;
117
+ private apply;
118
+ private persist;
119
+ }
60
120
  type ConnectionOrigin = {
61
121
  readonly kind: "browser";
62
122
  readonly origin: string;
@@ -111,8 +171,17 @@ type PendingConnection = {
111
171
  */
112
172
  readonly namespace: "eip155" | "nostr" | "lightning" | "solana";
113
173
  readonly network?: string;
174
+ /** `false` for a `network` request that adds the network without making it current. */
175
+ readonly activate?: boolean;
114
176
  readonly createdAt: number;
115
177
  };
178
+ /** What a connection request asks for; `namespace` defaults to `eip155`, `activate` to `true`. */
179
+ type ConnectionRequest = {
180
+ readonly kind: PendingConnection["kind"];
181
+ readonly namespace?: PendingConnection["namespace"];
182
+ readonly network?: string;
183
+ readonly activate?: boolean;
184
+ };
116
185
  type AccountGroup = {
117
186
  readonly walletId: string;
118
187
  readonly groupIndex: number;
@@ -139,11 +208,14 @@ type ConnectionControllerOptions = {
139
208
  readonly nostrPubkey: (ref: NostrKeyRef) => Promise<string>;
140
209
  /** Voids a page's unfinished requests (revoked, or its network changed). */
141
210
  readonly invalidate: (origin: string) => void;
211
+ readonly phishing: Pick<PhishingController, "check">;
212
+ readonly setTimer: (ms: number, fn: () => unknown) => () => void;
142
213
  };
143
214
  declare class ConnectionController extends Controller<ConnectionState> {
144
215
  private readonly options;
145
216
  private engineStore;
146
217
  private readonly waiters;
218
+ private readonly expiries;
147
219
  private group;
148
220
  private identity;
149
221
  constructor(options: ConnectionControllerOptions);
@@ -157,7 +229,10 @@ declare class ConnectionController extends Controller<ConnectionState> {
157
229
  * (a refresh is not a revocation).
158
230
  */
159
231
  invalidateOrigin(origin: string): void;
160
- /** Throws `4100` unless `origin` is `https://host[:port]` (or localhost in development). */
232
+ /**
233
+ * Throws `4100` unless `origin` is `https://host[:port]` (or localhost in development) and not on
234
+ * the phishing list.
235
+ */
161
236
  checkOrigin(origin: string): ConnectionOrigin;
162
237
  session(origin: string): ConnectionSession | undefined;
163
238
  pending(): ReadonlyArray<PendingConnection>;
@@ -170,7 +245,7 @@ declare class ConnectionController extends Controller<ConnectionState> {
170
245
  /** Throws `4100` unless the origin's session covers `method` on `network`. */
171
246
  authorize(origin: string, network: string, method: string): ConnectionSession;
172
247
  /** Resolves with the session once the host approves; rejects with `4001` when it refuses. */
173
- request(origin: string, kind: PendingConnection["kind"], network?: string, namespace?: PendingConnection["namespace"]): Promise<ConnectionSession>;
248
+ request(origin: string, { kind, namespace, network, activate }: ConnectionRequest): Promise<ConnectionSession>;
174
249
  /**
175
250
  * The host's approval, by id: the accounts granted (EVM addresses of the active group) and the
176
251
  * network.
@@ -219,6 +294,7 @@ declare class ConnectionController extends Controller<ConnectionState> {
219
294
  private persist;
220
295
  private requireStore;
221
296
  }
297
+ type SetTimer = (ms: number, fn: () => unknown) => () => void;
222
298
  type Esplora = {
223
299
  readonly get: (path: string) => Promise<unknown>;
224
300
  readonly post: (path: string, body: string) => Promise<unknown>;
@@ -247,17 +323,16 @@ type Options$2 = {
247
323
  readonly rpc: Readonly<Record<string, ReadonlyArray<string>>>;
248
324
  readonly openStore: () => Promise<EngineStore>;
249
325
  readonly logger: EngineLogger;
250
- readonly gateway?: {
251
- readonly url: string;
252
- readonly installId: string;
253
- } | undefined;
326
+ readonly gateway?: GatewayConfig | undefined;
327
+ readonly setTimer: SetTimer;
328
+ readonly random: (length: number) => Uint8Array;
254
329
  };
255
330
  declare class NetworkController extends Controller<NetworkControllerState> {
256
331
  private readonly options;
257
332
  private engineStore?;
258
333
  private readonly clients;
259
334
  private readonly gatewayBase;
260
- private readonly gatewayOrigin;
335
+ private readonly gatewayFetch;
261
336
  /** Networks the gateway reported at unlock; empty while locked or when the read failed. */
262
337
  private gatewayServed;
263
338
  constructor(options: Options$2);
@@ -265,8 +340,6 @@ declare class NetworkController extends Controller<NetworkControllerState> {
265
340
  private loadCustomRpc;
266
341
  /** Reads the gateway's served networks; any failure leaves the gateway unused until next unlock. */
267
342
  private loadGatewayNetworks;
268
- /** `fetch` that adds the install id to requests bound for the gateway's origin only. */
269
- private readonly gatewayFetch;
270
343
  destroy(): Promise<void>;
271
344
  lock(): void;
272
345
  /**
@@ -354,9 +427,45 @@ declare class AddressBookController extends Controller<AddressBookState> {
354
427
  private persist;
355
428
  private requireStore;
356
429
  }
430
+ /** A Sign In With Solana request after validation: `domain` and `address` are resolved. */
431
+ type SignInFields = {
432
+ readonly domain: string;
433
+ readonly address: string;
434
+ readonly statement?: string;
435
+ readonly uri?: string;
436
+ readonly version?: string;
437
+ readonly chainId?: string;
438
+ readonly nonce?: string;
439
+ readonly issuedAt?: string;
440
+ readonly expirationTime?: string;
441
+ readonly notBefore?: string;
442
+ readonly requestId?: string;
443
+ readonly resources?: ReadonlyArray<string>;
444
+ };
445
+ /** Simulation result shapes, in a leaf module so routes and the request controller share them. */
446
+ type AssetChange = {
447
+ /** Same ids as `DisplayIntent`: EVM `native` or a token address; Solana `lamports` or a mint. */
448
+ readonly asset: string;
449
+ /** Signed decimal in the smallest unit; negative is an outflow. */
450
+ readonly amount: string;
451
+ readonly decimals?: number;
452
+ readonly symbol?: string;
453
+ /** True only when `decimals` and `symbol` come from the built-in token table. */
454
+ readonly verified: boolean;
455
+ };
456
+ type SimulationOutcome = {
457
+ readonly status: "success";
458
+ readonly changes: ReadonlyArray<AssetChange>;
459
+ } | {
460
+ readonly status: "reverted";
461
+ readonly error: string;
462
+ } | {
463
+ readonly status: "unavailable";
464
+ readonly error: string;
465
+ };
357
466
  type EvmFeeTier = "slow" | "normal" | "fast";
358
467
  type SolanaFeeTier = "slow" | "normal" | "fast";
359
- type RequestCheckCode = "decode-partial" | "nonce-mismatch" | "fee-mismatch" | "reads-unverified" | "fee-above-network" | "fee-exceeds-amount";
468
+ type RequestCheckCode = "decode-partial" | "nonce-mismatch" | "fee-mismatch" | "reads-unverified" | "fee-above-network" | "fee-exceeds-amount" | "simulation-unavailable";
360
469
  /**
361
470
  * Local, engine-side metadata pinned to a history entry by transfer id. Written after the payment
362
471
  * it annotates has already succeeded — a missing or malformed note must never affect the payment
@@ -771,6 +880,8 @@ type PreparedRequest = {
771
880
  readonly target?: string;
772
881
  readonly intent: DisplayIntent;
773
882
  readonly checks: ReadonlyArray<RequestCheckCode>;
883
+ /** Absent when the request is not simulated (replacements, Bitcoin). */
884
+ readonly simulation?: SimulationOutcome;
774
885
  /** Why the build can no longer be signed (nonce taken, blockhash expired), if so. */
775
886
  readonly staleReason: () => string | undefined | Promise<string | undefined>;
776
887
  /** Signs, finalizes, broadcasts and hands the transaction to tracking. */
@@ -841,12 +952,13 @@ declare class TransactionController extends Controller<TransactionControllerStat
841
952
  private track;
842
953
  }
843
954
  /**
844
- * Recipient risk, pure: a recipient the wallet has never paid or saved is a `warning`; one that
845
- * looks like a known address (same first and last four characters, different address) is a `danger`
846
- * — the shape of an address-poisoning lookalike. Both can apply to one recipient.
955
+ * Request risk, pure. A recipient the wallet has never paid or saved is a `warning`; one that looks
956
+ * like a known address (same first and last four characters, different address) is a `danger` — the
957
+ * shape of an address-poisoning lookalike. Both can apply to one recipient. A page the user trusts
958
+ * despite the phishing list is a `danger`; one that could not be checked is a `warning`.
847
959
  */
848
960
  type RiskFinding = {
849
- readonly code: "first-recipient" | "address-poisoning";
961
+ readonly code: "first-recipient" | "address-poisoning" | "phishing-origin" | "phishing-unchecked" | "token-impersonation" | "token-symbol-unicode" | "simulation-reverted" | "simulation-mismatch";
850
962
  readonly level: "warning" | "danger";
851
963
  };
852
964
  /** A web page; `origin` is `scheme://host[:port]`, computed by the host from the top-level URL. */
@@ -857,7 +969,7 @@ type BrowserOrigin = {
857
969
  type RequestOrigin = {
858
970
  readonly kind: "internal";
859
971
  } | BrowserOrigin;
860
- type RequestMethod = ChainRequestMethod | "pay" | "zap" | "evm-sign" | "nostr-sign" | "webln-invoice" | "solana-sign" | "spark-deposit" | "spark-exit";
972
+ type RequestMethod = ChainRequestMethod | "pay" | "zap" | "evm-sign" | "nostr-sign" | "webln-invoice" | "watch-asset" | "solana-sign" | "spark-deposit" | "spark-exit";
861
973
  /** A Solana chain account the `solana-sign` request signs for. */
862
974
  type SolanaAccount = {
863
975
  readonly walletId: string;
@@ -945,6 +1057,17 @@ type WeblnInvoiceInput = {
945
1057
  readonly amountSats: number;
946
1058
  readonly memo?: string;
947
1059
  };
1060
+ /**
1061
+ * A dApp's `wallet_watchAsset`: confirm adding an ERC-20 token to the tracked list. No factor;
1062
+ * `symbol` and `decimals` are read on-chain by the pipeline, never taken from the page.
1063
+ */
1064
+ type WatchAssetInput = {
1065
+ readonly method: "watch-asset";
1066
+ readonly origin: BrowserOrigin;
1067
+ readonly account: AccountRef;
1068
+ readonly network: string;
1069
+ readonly address: string;
1070
+ };
948
1071
  /**
949
1072
  * A dApp's Solana request: one `solana-sign` covers a batch of transactions (signed sequentially —
950
1073
  * each prompts) or a `solana.message` raw-message signature.
@@ -961,9 +1084,11 @@ type SolanaSignInput = {
961
1084
  } | {
962
1085
  readonly kind: "message";
963
1086
  readonly message: Uint8Array;
1087
+ /** Set for a Sign In With Solana request; `message` is its text. */
1088
+ readonly signIn?: SignInFields;
964
1089
  };
965
1090
  };
966
- type RequestInput = ChainRequestInput | PayInput | ZapInput | EvmSignInput | NostrSignInput | WeblnInvoiceInput | SolanaSignInput | SparkDepositInput | SparkExitInput;
1091
+ type RequestInput = ChainRequestInput | PayInput | ZapInput | EvmSignInput | NostrSignInput | WeblnInvoiceInput | WatchAssetInput | SolanaSignInput | SparkDepositInput | SparkExitInput;
967
1092
  /** `approve` of a `nostr-sign` request: the signed event. */
968
1093
  type NostrSignResult = {
969
1094
  readonly kind: "nostr.event";
@@ -987,6 +1112,11 @@ type SolanaDisplay = {
987
1112
  readonly send: boolean;
988
1113
  readonly count: number;
989
1114
  readonly transactions: ReadonlyArray<unknown>;
1115
+ /** A message request's text (always valid UTF-8). */
1116
+ readonly message?: {
1117
+ readonly text: string;
1118
+ };
1119
+ readonly signIn?: SignInFields;
990
1120
  };
991
1121
  /** `approve` of a `solana-sign` request: the signatures (or signed transactions) per input. */
992
1122
  type SolanaSignResult = {
@@ -998,6 +1128,19 @@ type SolanaSignResult = {
998
1128
  readonly kind: "solana.message";
999
1129
  readonly signature: Uint8Array;
1000
1130
  };
1131
+ /** `approve` of a `watch-asset` request: the token was added. */
1132
+ type TokenWatchResult = {
1133
+ readonly kind: "token.watch";
1134
+ };
1135
+ /** `watch-asset` display: the token as read on-chain; `verified` means it is in the built-in table. */
1136
+ type TokenWatchDisplay = {
1137
+ readonly kind: "token.watch";
1138
+ readonly network: string;
1139
+ readonly address: string;
1140
+ readonly symbol: string;
1141
+ readonly decimals: number;
1142
+ readonly verified: boolean;
1143
+ };
1001
1144
  /** `webln-invoice` display: the requested amount and memo. */
1002
1145
  type LightningInvoiceDisplay = {
1003
1146
  readonly kind: "lightning.invoice";
@@ -1013,7 +1156,7 @@ type PendingRequest = {
1013
1156
  readonly network: string;
1014
1157
  readonly stage: RequestStage;
1015
1158
  /** Decoded locally from the exact content that will be signed; `family` tells the shapes apart. */
1016
- readonly display: DisplayIntent | SparkDisplay | NostrDisplay | LightningInvoiceDisplay | SolanaDisplay;
1159
+ readonly display: DisplayIntent | SparkDisplay | NostrDisplay | LightningInvoiceDisplay | TokenWatchDisplay | SolanaDisplay;
1017
1160
  /** `unverifiable` as soon as any check is recorded; the host must ask for explicit confirmation. */
1018
1161
  readonly verification: "verified" | "unverifiable";
1019
1162
  readonly checks: ReadonlyArray<RequestCheckCode>;
@@ -1022,6 +1165,8 @@ type PendingRequest = {
1022
1165
  * acknowledgement.
1023
1166
  */
1024
1167
  readonly risk: ReadonlyArray<RiskFinding>;
1168
+ /** Present for simulated requests: sends and dApp transactions; absent otherwise. */
1169
+ readonly simulation?: SimulationOutcome;
1025
1170
  readonly createdAt: number;
1026
1171
  readonly expiresAt: number;
1027
1172
  /** The transaction being replaced or accelerated; absent for a plain send. */
@@ -1046,6 +1191,17 @@ type RequestControllerOptions = {
1046
1191
  readonly logger: EngineLogger;
1047
1192
  /** Signs a Nostr event for `nostr-sign` — `nostr(wallet).signer(ref).signEvent`. */
1048
1193
  readonly nostrSign: (ref: NostrKeyRef, event: UnsignedEvent) => Promise<Event>;
1194
+ readonly phishing: Pick<PhishingController, "check">;
1195
+ /** Reads a token's metadata and adds it to the tracked list, for `watch-asset`. */
1196
+ readonly tokens: {
1197
+ readonly metadata: (network: string, address: string) => Promise<{
1198
+ readonly symbol: string;
1199
+ readonly decimals: number;
1200
+ }>;
1201
+ readonly add: (network: string, address: string) => Promise<void>;
1202
+ };
1203
+ /** Simulates one `solana-sign` transaction for display; failures are the caller's `unavailable`. */
1204
+ readonly simulateSolana: (account: SolanaAccount, network: string, message: Uint8Array) => Promise<SimulationOutcome>;
1049
1205
  /** Signs/broadcasts a `solana-sign` request — `chains.sign` per tx, then the Solana adapter. */
1050
1206
  readonly solanaSign: (account: {
1051
1207
  readonly walletId: string;
@@ -1055,6 +1211,8 @@ type RequestControllerOptions = {
1055
1211
  };
1056
1212
  /** Requests expire this long after creation. */
1057
1213
  declare const REQUEST_TTL_MS: number;
1214
+ /** What an approved request resolves with, whichever kind it is. */
1215
+ type RequestResult = TrackedTransaction | SparkResult | SignatureResult | NostrSignResult | WeblnInvoiceResult | TokenWatchResult | SolanaSignResult;
1058
1216
  declare class RequestController extends Controller<RequestControllerState> {
1059
1217
  private readonly options;
1060
1218
  private readonly entries;
@@ -1080,12 +1238,13 @@ declare class RequestController extends Controller<RequestControllerState> {
1080
1238
  * Resolves with what `approve` returned, or rejects with `RequestEndedError` when the request
1081
1239
  * ends any other way — how a dApp's pending call learns the outcome.
1082
1240
  */
1083
- outcome(id: string): Promise<TrackedTransaction | SparkResult | SignatureResult | NostrSignResult | WeblnInvoiceResult | SolanaSignResult>;
1241
+ outcome(id: string): Promise<RequestResult>;
1084
1242
  private openSettler;
1085
1243
  private settle;
1086
1244
  /** The bitcoin network `account`'s Spark network settles on; any other pairing is refused. */
1087
1245
  private l1Network;
1088
1246
  private sparkBuilt;
1247
+ private simulateOne;
1089
1248
  private build;
1090
1249
  /**
1091
1250
  * Signs and submits a request. Anything but a live, unexpired `send` request with this id throws
@@ -1096,6 +1255,7 @@ declare class RequestController extends Controller<RequestControllerState> {
1096
1255
  approve(id: string, method: "evm-sign", verify?: SendParams["verify"]): Promise<TrackedTransaction | SignatureResult>;
1097
1256
  approve(id: string, method: "nostr-sign"): Promise<NostrSignResult>;
1098
1257
  approve(id: string, method: "webln-invoice"): Promise<WeblnInvoiceResult>;
1258
+ approve(id: string, method: "watch-asset"): Promise<TokenWatchResult>;
1099
1259
  approve(id: string, method: "solana-sign", verify?: SendParams["verify"]): Promise<SolanaSignResult>;
1100
1260
  /**
1101
1261
  * A cancelled or refused verification is `rejected`; anything after it is `failed`. Chain
@@ -1149,11 +1309,12 @@ type Eip1193HandlerOptions = {
1149
1309
  readonly networks: NetworkController;
1150
1310
  /** The network an unconnected page sees. */
1151
1311
  readonly defaultNetwork: () => string;
1312
+ /** Whether a token is already in the built-in table or the user's custom tokens. */
1313
+ readonly isTracked: (network: string, address: string) => boolean;
1152
1314
  };
1153
1315
  declare class Eip1193Handler {
1154
1316
  private readonly options;
1155
- private readonly listeners;
1156
- private unsubscribe;
1317
+ private readonly events;
1157
1318
  constructor(options: Eip1193HandlerOptions);
1158
1319
  /** Events for the host to forward to pages; derived from changes to the sessions. */
1159
1320
  subscribe(listener: (event: Eip1193Event) => void): () => void;
@@ -1161,6 +1322,13 @@ declare class Eip1193Handler {
1161
1322
  private requestAccounts;
1162
1323
  private permissions;
1163
1324
  private switchChain;
1325
+ /**
1326
+ * EIP-3085. The chain must already be a network the wallet enables; the page's `rpcUrls` are
1327
+ * validated for shape and never read or used — custom endpoints are the user's setting.
1328
+ */
1329
+ private addChain;
1330
+ /** EIP-747 (ERC-20 only): `symbol`, `decimals` and `image` from the page are never used. */
1331
+ private watchAsset;
1164
1332
  private authorizedAccount;
1165
1333
  private personalSign;
1166
1334
  private typedData;
@@ -1220,9 +1388,10 @@ type SolanaEvent = {
1220
1388
  readonly accounts: ReadonlyArray<SolanaWalletAccount>;
1221
1389
  };
1222
1390
  type SolanaConnections = Pick<ConnectionController, "checkOrigin" | "session" | "authorize" | "solanaAccount" | "request" | "touch" | "revoke" | "getState" | "store">;
1391
+ type SolanaRequests = Pick<RequestController, "prepare" | "outcome">;
1223
1392
  type Options = {
1224
1393
  readonly connections: SolanaConnections;
1225
- readonly requests: Pick<RequestController, "prepare" | "outcome">;
1394
+ readonly requests: SolanaRequests;
1226
1395
  /** The group's Solana address + public key on `network` (the `solana.bip44-change` account). */
1227
1396
  readonly solanaAccount: (group: {
1228
1397
  readonly walletId: string;
@@ -1244,8 +1413,7 @@ type Options = {
1244
1413
  */
1245
1414
  declare class SolanaWalletHandler implements SolanaHandler {
1246
1415
  readonly options: Options;
1247
- private readonly listeners;
1248
- private unsubscribe;
1416
+ private readonly events;
1249
1417
  constructor(options: Options);
1250
1418
  /** `standard:events` `change` per origin — derived from changes to the sessions. */
1251
1419
  subscribe(listener: (event: SolanaEvent) => void): () => void;
@@ -1253,7 +1421,20 @@ declare class SolanaWalletHandler implements SolanaHandler {
1253
1421
  private connect;
1254
1422
  private walletAccount;
1255
1423
  private signTransactions;
1424
+ /**
1425
+ * The network a transaction call targets: the wallet's default when no input names a chain,
1426
+ * otherwise the one chain every input agrees on (`chain` is required for sign-and-send).
1427
+ */
1428
+ private networkOf;
1256
1429
  private signMessage;
1430
+ /**
1431
+ * Sign In With Solana: connects first when needed, binds the message to the page's host and the
1432
+ * session's account, and signs the exact text the user is shown.
1433
+ */
1434
+ private signIn;
1435
+ private signMessageRequest;
1436
+ /** One `solana-sign` request for the active group, resolved to its outcome. */
1437
+ private signRequest;
1257
1438
  /** The `setActiveGroup` re-point: the solana session's new `WalletAccount[]` for `change`. */
1258
1439
  solanaAccountsChanged(_origin: string): Promise<SolanaWalletAccount[]>;
1259
1440
  }
@@ -1268,6 +1449,7 @@ type WeblnHandlerOptions = {
1268
1449
  readonly spark: Pick<SparkController, "accountBalance" | "paymentStatus">;
1269
1450
  /** The active group's Spark account — `undefined` when no group is selected. */
1270
1451
  readonly sparkAccount: () => SparkAccountRef | undefined;
1452
+ readonly now: () => number;
1271
1453
  /** The node's display alias — host-configured, never a pubkey. */
1272
1454
  readonly alias: string;
1273
1455
  /** The host's lightning fee cap — `pay`'s `maxFeeSats` comes from here. */
@@ -1292,5 +1474,5 @@ declare class ProviderError extends Error {
1292
1474
  readonly code: number;
1293
1475
  constructor(code: number, message: string);
1294
1476
  }
1295
- export { sparkStore as $, RiskFinding as A, ParseOptions as B, SparkDepositInput as C, Controller as Ct, BrowserOrigin as D, SignLogOutcome as E, PreparedZap as F, PreparedSparkAction as G, PaymentParse as H, ZapRecipient as I, SparkAccountState as J, SparkDisplay as K, prepareZap as L, SignatureResult as M, PrepareZapContext as N, RequestMethod as O, PrepareZapParams as P, SparkControllerState as Q, PayParams as R, RequestStage as S, createEventBus as St, SignLogEntry as T, PaymentRequest as U, PaymentOption as V, parsePayment as W, SparkController as X, SparkClientFactory as Y, SparkControllerOptions as Z, PendingRequest as _, PendingConnection as _t, SolanaEvent as a, AddressBookEntry as at, RequestControllerState as b, EngineLogger as bt, SolanaWalletAccount as c, NetworkController as ct, Nip07Request as d, ConnectionController as dt, PaymentNote as et, Eip1193Event as f, ConnectionOrigin as ft, PayInput as g, NostrPolicy as gt, EvmSignInput as h, ConnectionState as ht, SOLANA_CHAIN_IDS as i, AddressBookState as it, TransactionController as j, RequestOrigin as k, SolanaWalletHandler as l, Esplora as lt, Eip1193Request as m, ConnectionSession as mt, WeblnHandler as n, RequestCheckCode as nt, SolanaHandler as o, AddressBookRecord as ot, Eip1193Handler as p, ConnectionScope as pt, SparkResult as q, WeblnRequest as r, AddressBookController as rt, SolanaRequest as s, AddressFamily as st, ProviderError as t, SparkActivity as tt, Nip07Handler as u, AccountGroup as ut, REQUEST_TTL_MS as v, EngineCollection as vt, SparkExitInput as w, ControllerOptions as wt, RequestInput as x, EventBus as xt, RequestController as y, EngineStore as yt, WithdrawLnurlParams as z };
1296
- //# sourceMappingURL=errors-CW_XXGL9.d.mts.map
1477
+ export { sparkStore as $, RiskFinding as A, ControllerOptions as At, ParseOptions as B, SparkDepositInput as C, EngineCollection as Ct, BrowserOrigin as D, EventBus as Dt, SignLogOutcome as E, EngineLogger as Et, PreparedZap as F, PreparedSparkAction as G, PaymentParse as H, ZapRecipient as I, SparkAccountState as J, SparkDisplay as K, prepareZap as L, SignatureResult as M, PrepareZapContext as N, RequestMethod as O, createEventBus as Ot, PrepareZapParams as P, SparkControllerState as Q, PayParams as R, RequestStage as S, PhishingStatus as St, SignLogEntry as T, PublicStore as Tt, PaymentRequest as U, PaymentOption as V, parsePayment as W, SparkController as X, SparkClientFactory as Y, SparkControllerOptions as Z, PendingRequest as _, PendingConnection as _t, SolanaEvent as a, AddressBookEntry as at, RequestControllerState as b, PhishingControllerOptions as bt, SolanaWalletAccount as c, NetworkController as ct, Nip07Request as d, ConnectionController as dt, PaymentNote as et, Eip1193Event as f, ConnectionOrigin as ft, PayInput as g, NostrPolicy as gt, EvmSignInput as h, ConnectionState as ht, SOLANA_CHAIN_IDS as i, AddressBookState as it, TransactionController as j, RequestOrigin as k, Controller as kt, SolanaWalletHandler as l, Esplora as lt, Eip1193Request as m, ConnectionSession as mt, WeblnHandler as n, RequestCheckCode as nt, SolanaHandler as o, AddressBookRecord as ot, Eip1193Handler as p, ConnectionScope as pt, SparkResult as q, WeblnRequest as r, AddressBookController as rt, SolanaRequest as s, AddressFamily as st, ProviderError as t, SparkActivity as tt, Nip07Handler as u, AccountGroup as ut, REQUEST_TTL_MS as v, PHISHING_REFRESH_MS as vt, SparkExitInput as w, EngineStore as wt, RequestInput as x, PhishingState as xt, RequestController as y, PhishingController as yt, WithdrawLnurlParams as z };
1478
+ //# sourceMappingURL=errors-CP1G6KCc.d.mts.map
@@ -43,7 +43,7 @@ export declare const health: Endpoint<z.ZodMiniUndefined, z.ZodMiniObject<{
43
43
  /** One JSON-RPC call plus nothing else: batches may carry at most this many entries. */
44
44
  export declare const RPC_BATCH_MAX = 20;
45
45
  /** Read-only EVM methods plus `eth_sendRawTransaction`. Anything not listed is rejected. */
46
- export declare const EVM_RPC_METHODS: readonly ["eth_blobBaseFee", "eth_blockNumber", "eth_call", "eth_chainId", "eth_createAccessList", "eth_estimateGas", "eth_feeHistory", "eth_gasPrice", "eth_getBalance", "eth_getBlockByHash", "eth_getBlockByNumber", "eth_getBlockReceipts", "eth_getBlockTransactionCountByHash", "eth_getBlockTransactionCountByNumber", "eth_getCode", "eth_getProof", "eth_getStorageAt", "eth_getTransactionByBlockHashAndIndex", "eth_getTransactionByBlockNumberAndIndex", "eth_getTransactionByHash", "eth_getTransactionCount", "eth_getTransactionReceipt", "eth_maxPriorityFeePerGas", "eth_sendRawTransaction", "net_version", "web3_clientVersion"];
46
+ export declare const EVM_RPC_METHODS: readonly ["eth_blobBaseFee", "eth_blockNumber", "eth_call", "eth_chainId", "eth_createAccessList", "eth_estimateGas", "eth_feeHistory", "eth_gasPrice", "eth_getBalance", "eth_getBlockByHash", "eth_getBlockByNumber", "eth_getBlockReceipts", "eth_getBlockTransactionCountByHash", "eth_getBlockTransactionCountByNumber", "eth_getCode", "eth_getProof", "eth_getStorageAt", "eth_getTransactionByBlockHashAndIndex", "eth_getTransactionByBlockNumberAndIndex", "eth_getTransactionByHash", "eth_getTransactionCount", "eth_getTransactionReceipt", "eth_maxPriorityFeePerGas", "eth_sendRawTransaction", "eth_simulateV1", "net_version", "web3_clientVersion"];
47
47
  /** Read-only Solana methods plus `sendTransaction`. Anything not listed is rejected. */
48
48
  export declare const SOLANA_RPC_METHODS: readonly ["getAccountInfo", "getBalance", "getBlock", "getBlockHeight", "getBlockTime", "getEpochInfo", "getFeeForMessage", "getGenesisHash", "getLatestBlockhash", "getMinimumBalanceForRentExemption", "getMultipleAccounts", "getRecentPrioritizationFees", "getSignatureStatuses", "getSignaturesForAddress", "getSlot", "getTokenAccountBalance", "getTokenAccountsByOwner", "getTokenSupply", "getTransaction", "getVersion", "isBlockhashValid", "sendTransaction", "simulateTransaction"];
49
49
  export type EvmRpcMethod = (typeof EVM_RPC_METHODS)[number];
@@ -89,6 +89,7 @@ export declare const evmRpcRequest: z.ZodMiniUnion<readonly [z.ZodMiniObject<{
89
89
  eth_getTransactionReceipt: "eth_getTransactionReceipt";
90
90
  eth_maxPriorityFeePerGas: "eth_maxPriorityFeePerGas";
91
91
  eth_sendRawTransaction: "eth_sendRawTransaction";
92
+ eth_simulateV1: "eth_simulateV1";
92
93
  net_version: "net_version";
93
94
  web3_clientVersion: "web3_clientVersion";
94
95
  }>;
@@ -121,6 +122,7 @@ export declare const evmRpcRequest: z.ZodMiniUnion<readonly [z.ZodMiniObject<{
121
122
  eth_getTransactionReceipt: "eth_getTransactionReceipt";
122
123
  eth_maxPriorityFeePerGas: "eth_maxPriorityFeePerGas";
123
124
  eth_sendRawTransaction: "eth_sendRawTransaction";
125
+ eth_simulateV1: "eth_simulateV1";
124
126
  net_version: "net_version";
125
127
  web3_clientVersion: "web3_clientVersion";
126
128
  }>;
@@ -281,5 +283,80 @@ export declare const servedNetworks: Endpoint<z.ZodMiniUndefined, z.ZodMiniObjec
281
283
  networks: z.ZodMiniArray<z.ZodMiniString<string>>;
282
284
  }, z.core.$strip>>;
283
285
  export declare const networksPath: string;
286
+ export declare const PHISHING_HASH_BYTES = 8;
287
+ export declare const PHISHING_MAX_PATH_SEGMENTS = 8;
288
+ /** One list entry as its lookup key, or `undefined` when the entry is not a usable host or path. */
289
+ export declare function phishingKey(entry: string): string | undefined;
290
+ /** The first 8 bytes of SHA-256 over the UTF-8 key. */
291
+ export declare function phishingHash(key: string): Uint8Array;
292
+ /** Lookup keys for a page URL, most specific first; empty for anything but http(s). */
293
+ export declare function phishingCandidates(url: string): ReadonlyArray<string>;
294
+ export declare const phishingListRequest: z.ZodMiniObject<{
295
+ since: z.ZodMiniOptional<z.ZodMiniString<string>>;
296
+ }, z.core.$strip>;
297
+ export declare const phishingListResponse: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
298
+ kind: z.ZodMiniLiteral<"current">;
299
+ version: z.ZodMiniNumber<number>;
300
+ }, z.core.$strip>, z.ZodMiniObject<{
301
+ kind: z.ZodMiniLiteral<"diff">;
302
+ from: z.ZodMiniNumber<number>;
303
+ version: z.ZodMiniNumber<number>;
304
+ deny: z.ZodMiniObject<{
305
+ add: z.ZodMiniString<string>;
306
+ remove: z.ZodMiniString<string>;
307
+ }, z.core.$strip>;
308
+ allow: z.ZodMiniObject<{
309
+ add: z.ZodMiniString<string>;
310
+ remove: z.ZodMiniString<string>;
311
+ }, z.core.$strip>;
312
+ }, z.core.$strip>, z.ZodMiniObject<{
313
+ kind: z.ZodMiniLiteral<"snapshot">;
314
+ version: z.ZodMiniNumber<number>;
315
+ deny: z.ZodMiniString<string>;
316
+ allow: z.ZodMiniString<string>;
317
+ }, z.core.$strip>], "kind">;
318
+ export type PhishingListResponse = z.infer<typeof phishingListResponse>;
319
+ export declare const phishingList: Endpoint<z.ZodMiniObject<{
320
+ since: z.ZodMiniOptional<z.ZodMiniString<string>>;
321
+ }, z.core.$strip>, z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
322
+ kind: z.ZodMiniLiteral<"current">;
323
+ version: z.ZodMiniNumber<number>;
324
+ }, z.core.$strip>, z.ZodMiniObject<{
325
+ kind: z.ZodMiniLiteral<"diff">;
326
+ from: z.ZodMiniNumber<number>;
327
+ version: z.ZodMiniNumber<number>;
328
+ deny: z.ZodMiniObject<{
329
+ add: z.ZodMiniString<string>;
330
+ remove: z.ZodMiniString<string>;
331
+ }, z.core.$strip>;
332
+ allow: z.ZodMiniObject<{
333
+ add: z.ZodMiniString<string>;
334
+ remove: z.ZodMiniString<string>;
335
+ }, z.core.$strip>;
336
+ }, z.core.$strip>, z.ZodMiniObject<{
337
+ kind: z.ZodMiniLiteral<"snapshot">;
338
+ version: z.ZodMiniNumber<number>;
339
+ deny: z.ZodMiniString<string>;
340
+ allow: z.ZodMiniString<string>;
341
+ }, z.core.$strip>], "kind">>;
342
+ export declare const phishingListPath: string;
343
+ /** Strictly ascending 8-byte hashes, concatenated: a sorted set. */
344
+ export type HashList = Uint8Array;
345
+ declare const size: (list: HashList) => number;
346
+ export declare const hashCount: typeof size;
347
+ /**
348
+ * A base64 hash list, or `undefined` when it is not whole 8-byte hashes in strictly ascending
349
+ * order.
350
+ */
351
+ export declare function decodeHashList(encoded: string): HashList | undefined;
352
+ /** The sorted set of `hashes`, duplicates removed. */
353
+ export declare function hashList(hashes: Iterable<Uint8Array>): HashList;
354
+ export declare const encodeHashList: (list: HashList) => string;
355
+ export declare function contains(list: HashList, hash: Uint8Array): boolean;
356
+ export declare const union: (a: HashList, b: HashList) => HashList;
357
+ /** The hashes of `a` that are not in `b`. */
358
+ export declare const difference: (a: HashList, b: HashList) => HashList;
359
+ /** `(list − remove) ∪ add`. */
360
+ export declare const applyDiff: (list: HashList, add: HashList, remove: HashList) => HashList;
284
361
  export { BITCOIN_NETWORKS, NETWORKS, type NetworkInfo, SOLANA_NETWORKS, networkById };
285
362
  //# sourceMappingURL=gateway-contract.d.mts.map