@qntx/wallet-engine 0.13.0 → 0.14.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/README.md +1057 -20
- package/dist/apps-fiat24.d.mts +202 -0
- package/dist/apps-fiat24.mjs +1378 -0
- package/dist/apps-fiat24.mjs.map +1 -0
- package/dist/apps-hyperliquid.d.mts +549 -0
- package/dist/apps-hyperliquid.mjs +2742 -0
- package/dist/apps-hyperliquid.mjs.map +1 -0
- package/dist/apps-polymarket.d.mts +729 -0
- package/dist/apps-polymarket.mjs +3786 -0
- package/dist/apps-polymarket.mjs.map +1 -0
- package/dist/apps.d.mts +136 -0
- package/dist/apps.mjs +535 -0
- package/dist/apps.mjs.map +1 -0
- package/dist/connect-BY1C5ZRI.mjs +210 -0
- package/dist/connect-BY1C5ZRI.mjs.map +1 -0
- package/dist/connect.d.mts +17 -9
- package/dist/connect.mjs +3 -185
- package/dist/{errors-CQnlTc1i.d.mts → controller-DpNVHVsj.d.mts} +1093 -758
- package/dist/controller-rMnaxKAH.mjs +46 -0
- package/dist/controller-rMnaxKAH.mjs.map +1 -0
- package/dist/decimal-COJ4g8qy.mjs +38 -0
- package/dist/decimal-COJ4g8qy.mjs.map +1 -0
- package/dist/eligibility-BfM9ybYZ.mjs +48 -0
- package/dist/eligibility-BfM9ybYZ.mjs.map +1 -0
- package/dist/engine-Dic_kkEr.d.mts +1829 -0
- package/dist/errors-B8W-hoYW.d.mts +7 -0
- package/dist/errors-horUy5k1.mjs +24 -0
- package/dist/errors-horUy5k1.mjs.map +1 -0
- package/dist/gateway-contract.d.mts +3 -608
- package/dist/gateway-contract.mjs +1467 -161
- package/dist/gateway-contract.mjs.map +1 -1
- package/dist/idb.d.mts +5 -0
- package/dist/idb.mjs +122 -46
- package/dist/idb.mjs.map +1 -1
- package/dist/index-vBgfOFIh.d.mts +2227 -0
- package/dist/index.d.mts +58 -618
- package/dist/index.mjs +21963 -6836
- package/dist/index.mjs.map +1 -1
- package/dist/json-BDwV38cj.mjs +15 -0
- package/dist/json-BDwV38cj.mjs.map +1 -0
- package/dist/link-Ceq8Dggp.mjs +139 -0
- package/dist/link-Ceq8Dggp.mjs.map +1 -0
- package/dist/primitives-DbSHLZKq.mjs +31 -0
- package/dist/primitives-DbSHLZKq.mjs.map +1 -0
- package/dist/push-message-AQuzoNFY.d.mts +84 -0
- package/dist/push-message-kbnH1A5w.mjs +142 -0
- package/dist/push-message-kbnH1A5w.mjs.map +1 -0
- package/dist/push.d.mts +13 -0
- package/dist/push.mjs +70 -0
- package/dist/push.mjs.map +1 -0
- package/dist/qr.d.mts +292 -0
- package/dist/qr.mjs +1725 -0
- package/dist/qr.mjs.map +1 -0
- package/dist/registry-CbtwcxkX.mjs +374 -0
- package/dist/registry-CbtwcxkX.mjs.map +1 -0
- package/dist/risk-DyABgg4W.mjs +757 -0
- package/dist/risk-DyABgg4W.mjs.map +1 -0
- package/dist/session-CNJFLarP.mjs +18 -0
- package/dist/session-CNJFLarP.mjs.map +1 -0
- package/dist/socket-ChG9JRT_.mjs +110 -0
- package/dist/socket-ChG9JRT_.mjs.map +1 -0
- package/dist/spi-BrTw5s98.d.mts +3 -0
- package/dist/timer-Cdk5rGM2.mjs +43 -0
- package/dist/timer-Cdk5rGM2.mjs.map +1 -0
- package/dist/types-BpvioFGo.d.mts +258 -0
- package/dist/types-DbftVZ3I.mjs +90 -0
- package/dist/types-DbftVZ3I.mjs.map +1 -0
- package/dist/walletconnect.d.mts +86 -0
- package/dist/walletconnect.mjs +1507 -0
- package/dist/walletconnect.mjs.map +1 -0
- package/dist/webln-BgrtPXpG.mjs +2593 -0
- package/dist/webln-BgrtPXpG.mjs.map +1 -0
- package/dist/webln-Bllk_xJ2.d.mts +666 -0
- package/package.json +92 -19
- package/dist/connect.mjs.map +0 -1
- package/dist/registry-DwguKWvt.d.mts +0 -27
- package/dist/registry-oorLoGtz.mjs +0 -120
- package/dist/registry-oorLoGtz.mjs.map +0 -1
- package/dist/webln-DKqCnqx1.mjs +0 -3677
- package/dist/webln-DKqCnqx1.mjs.map +0 -1
package/dist/qr.d.mts
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { C as SolanaSignInput, _ as RequestController, i as BitcoinSignInput, k as TronSignInput, p as PendingRequest, s as EvmSignInput, vn as NetworkController } from "./controller-DpNVHVsj.mjs";
|
|
2
|
+
import { BitcoinTemplate, DisplayIntent, EvmTransaction, KeyPath, SignRequest } from "@qntx/wallet-chains";
|
|
3
|
+
import { VerifyFactor, Wallet } from "@qntx/wallet";
|
|
4
|
+
import { ChainsApi } from "@qntx/wallet/chains";
|
|
5
|
+
import { QrPayload, QrPayload as QrPayload$1, qrParts as qrFrames } from "@qntx/wallet/hardware";
|
|
6
|
+
import "@qntx/ur/interop";
|
|
7
|
+
import { ChainExportResult, ChainSignResult } from "@qntx/wallet/protocol";
|
|
8
|
+
type QrErrorCode = "scan-failed" | "scan-timeout" | "scan-exhausted" | "malformed" | "unsupported" | "fingerprint-missing" | "result-mismatch" | "account-mismatch" | "network-unknown" | "chain-mismatch" | "network-ambiguous" | "unbound" | "contract-creation" | "self-call" | "multisig-unsupported" | "nothing-to-sign" | "sighash-unsupported" | "wallet-unsupported";
|
|
9
|
+
/** Every failure the qr layer reports; nothing else may escape a public entry point. */
|
|
10
|
+
export declare class QrError extends Error {
|
|
11
|
+
readonly code: QrErrorCode;
|
|
12
|
+
constructor(code: QrErrorCode, message: string);
|
|
13
|
+
}
|
|
14
|
+
/** Fold any foreign throw (dcbor, UrError, viem/ox, RangeError) into `code`. */
|
|
15
|
+
export declare const qrGuard: <T>(code: QrErrorCode, run: () => T) => T;
|
|
16
|
+
type QrScanLimits = {
|
|
17
|
+
readonly maxMessageBytes: number;
|
|
18
|
+
readonly maxFragments: number;
|
|
19
|
+
readonly maxFragmentBytes: number;
|
|
20
|
+
readonly maxUriBytes: number;
|
|
21
|
+
readonly maxFrames: number;
|
|
22
|
+
readonly timeoutMs: number;
|
|
23
|
+
};
|
|
24
|
+
export declare const QR_SCAN_LIMITS: QrScanLimits;
|
|
25
|
+
type QrScanOutcome = {
|
|
26
|
+
readonly status: "progress";
|
|
27
|
+
readonly ratio: number;
|
|
28
|
+
} | {
|
|
29
|
+
readonly status: "complete";
|
|
30
|
+
readonly payload: QrPayload$1;
|
|
31
|
+
};
|
|
32
|
+
type QrScanner = {
|
|
33
|
+
readonly receive: (text: string) => QrScanOutcome;
|
|
34
|
+
};
|
|
35
|
+
export declare const createQrScanner: (options: {
|
|
36
|
+
readonly kind: "request" | "export" | "response";
|
|
37
|
+
readonly now: () => number;
|
|
38
|
+
readonly limits?: Partial<QrScanLimits>;
|
|
39
|
+
}) => QrScanner;
|
|
40
|
+
type QrBase = {
|
|
41
|
+
readonly requestId?: Uint8Array;
|
|
42
|
+
readonly path: KeyPath;
|
|
43
|
+
readonly xfp: number;
|
|
44
|
+
readonly declared?: string;
|
|
45
|
+
};
|
|
46
|
+
type QrRequest = (QrBase & {
|
|
47
|
+
readonly family: "evm";
|
|
48
|
+
readonly kind: "transaction";
|
|
49
|
+
readonly chainId?: number;
|
|
50
|
+
readonly address?: string;
|
|
51
|
+
readonly tx: EvmTransaction;
|
|
52
|
+
readonly data: Uint8Array;
|
|
53
|
+
}) | (QrBase & {
|
|
54
|
+
readonly family: "evm";
|
|
55
|
+
readonly kind: "typed-data";
|
|
56
|
+
readonly chainId?: number;
|
|
57
|
+
readonly address?: string;
|
|
58
|
+
readonly typedData: string;
|
|
59
|
+
}) | (QrBase & {
|
|
60
|
+
readonly family: "evm";
|
|
61
|
+
readonly kind: "personal-message";
|
|
62
|
+
readonly chainId?: number;
|
|
63
|
+
readonly address?: string;
|
|
64
|
+
readonly message: Uint8Array;
|
|
65
|
+
}) | (QrBase & {
|
|
66
|
+
readonly family: "solana";
|
|
67
|
+
readonly kind: "transaction" | "message";
|
|
68
|
+
readonly address?: string;
|
|
69
|
+
readonly data: Uint8Array;
|
|
70
|
+
}) | (QrBase & {
|
|
71
|
+
readonly family: "tron";
|
|
72
|
+
readonly kind: "transaction" | "message";
|
|
73
|
+
readonly address?: string;
|
|
74
|
+
readonly data: Uint8Array;
|
|
75
|
+
}) | {
|
|
76
|
+
readonly family: "bitcoin";
|
|
77
|
+
readonly kind: "psbt";
|
|
78
|
+
readonly urType: "crypto-psbt" | "psbt";
|
|
79
|
+
readonly psbt: Uint8Array;
|
|
80
|
+
};
|
|
81
|
+
export declare const readQrRequest: (payload: QrPayload$1) => QrRequest;
|
|
82
|
+
/** The account the response claims — the request's address is untrusted, the caller's is not. */
|
|
83
|
+
type QrSigner = {
|
|
84
|
+
readonly address: string;
|
|
85
|
+
};
|
|
86
|
+
export declare const qrResponse: (request: QrRequest, result: ChainSignResult, signer: QrSigner | undefined) => QrPayload$1;
|
|
87
|
+
type QrExportForm = "crypto-hdkey" | "crypto-account" | "crypto-multi-accounts";
|
|
88
|
+
type QrExport = {
|
|
89
|
+
readonly payload: QrPayload$1;
|
|
90
|
+
readonly discloses: "evm-all-addresses" | "account-addresses" | "single-addresses";
|
|
91
|
+
};
|
|
92
|
+
export declare const qrExport: (result: ChainExportResult, form: QrExportForm) => QrExport;
|
|
93
|
+
type QrDigestKind = "evm-transaction-hash" | "eip712-domain-hash" | "eip712-message-hash" | "eip712-digest" | "eip191-digest" | "solana-message-hash" | "tron-txid" | "tron-message-digest";
|
|
94
|
+
type QrDigest = {
|
|
95
|
+
readonly kind: QrDigestKind;
|
|
96
|
+
readonly value: string;
|
|
97
|
+
readonly shownBy: ReadonlyArray<"ledger-ethereum" | "ledger-solana">;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* One decoded view of the request: `networks` names every network the address encoding serves —
|
|
101
|
+
* several when one bech32 prefix covers them (a coin-type-1' PSBT shows its `tb1…` outputs for
|
|
102
|
+
* testnet and signet alike, so one intent is labelled by both; regtest's `bcrt1…` is a separate
|
|
103
|
+
* entry). `intent.network` is the id the decode ran under — always a member of `networks`.
|
|
104
|
+
*/
|
|
105
|
+
type QrDisplay = {
|
|
106
|
+
readonly networks: ReadonlyArray<string>;
|
|
107
|
+
readonly intent: DisplayIntent;
|
|
108
|
+
};
|
|
109
|
+
type QrInspection = {
|
|
110
|
+
readonly request: QrRequest;
|
|
111
|
+
/**
|
|
112
|
+
* One decoded intent per output encoding the request permits — a single entry for every request
|
|
113
|
+
* but a coin-type-1' PSBT, which carries both the `tb1…` and `bcrt1…` decodings. Absent when the
|
|
114
|
+
* request lacks what a decoder needs (a missing counterpart address) or every decode failed.
|
|
115
|
+
*/
|
|
116
|
+
readonly displays?: ReadonlyArray<QrDisplay>;
|
|
117
|
+
readonly digests: ReadonlyArray<QrDigest>;
|
|
118
|
+
};
|
|
119
|
+
export declare const inspectQrRequest: (request: QrRequest) => QrInspection;
|
|
120
|
+
/** The Bitcoin mainnet CAIP-2 id — the only network a QR PSBT maps deterministically. */
|
|
121
|
+
export declare const BITCOIN_MAINNET = "bip122:000000000019d6689c085ae165831e93";
|
|
122
|
+
/**
|
|
123
|
+
* Everything binding checks against: the selected account's facts — the resolved leaf addresses per
|
|
124
|
+
* family and the enabled networks per family. The master fingerprint is a public value the
|
|
125
|
+
* transport reports: nothing authenticates it, and a hostile reader can claim any value — matching
|
|
126
|
+
* it here is a consistency check for the user's benefit, not what makes the binding safe. Safety
|
|
127
|
+
* rests on the kernel verifying every input of the transaction the request carries.
|
|
128
|
+
*/
|
|
129
|
+
type QrAccountFacts = {
|
|
130
|
+
readonly walletId: string;
|
|
131
|
+
readonly groupIndex: number;
|
|
132
|
+
/** The master key fingerprint as a number — what a UR request's `sourceFingerprint` carries. */
|
|
133
|
+
readonly fingerprint: number;
|
|
134
|
+
/** The resolved leaf address per family — only the request's own family is guaranteed present. */
|
|
135
|
+
readonly addresses: {
|
|
136
|
+
readonly evm?: string;
|
|
137
|
+
readonly tron?: string;
|
|
138
|
+
readonly solana?: string;
|
|
139
|
+
};
|
|
140
|
+
/** Enabled CAIP-2 ids per family; `solana`/`tron` are ordered mainnet first. */
|
|
141
|
+
readonly networks: {
|
|
142
|
+
readonly evm: ReadonlyArray<string>;
|
|
143
|
+
readonly solana: ReadonlyArray<string>;
|
|
144
|
+
readonly tron: ReadonlyArray<string>;
|
|
145
|
+
readonly bitcoin: ReadonlyArray<string>;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* The candidate request inputs for a decoded QR request, in try order — one, except Solana and TRON
|
|
150
|
+
* transactions which produce one per enabled network for the facade to try in order. All
|
|
151
|
+
* account/chain/network checks happen here; the pipeline repeats the semantic ones.
|
|
152
|
+
*/
|
|
153
|
+
export declare const bindQrRequest: (request: QrRequest, facts: QrAccountFacts) => ReadonlyArray<EvmSignInput | SolanaSignInput | TronSignInput | BitcoinSignInput>;
|
|
154
|
+
/** The account a QR request is bound to: a wallet group the request must have been built for. */
|
|
155
|
+
type QrAccount = {
|
|
156
|
+
readonly walletId: string;
|
|
157
|
+
readonly groupIndex: number;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* The slice of the engine a QR signer drives: the request pipeline every origin feeds and the
|
|
161
|
+
* enabled networks a request may be bound to. A `WalletEngine` satisfies it structurally.
|
|
162
|
+
*/
|
|
163
|
+
type QrEngineSurface = {
|
|
164
|
+
readonly requests: Pick<RequestController, "prepare" | "outcome">;
|
|
165
|
+
readonly networks: Pick<NetworkController, "enabled">;
|
|
166
|
+
/**
|
|
167
|
+
* The one account seam — the engine's `signers.apis`: vault material derives in the kernel, card
|
|
168
|
+
* and hardware wallets read their pinned material.
|
|
169
|
+
*/
|
|
170
|
+
readonly signers: {
|
|
171
|
+
readonly apis: Pick<ChainsApi, "account" | "exportAccount">;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* The QR signing surface: `prepare` feeds the pipeline, `respond` encodes the result back into the
|
|
176
|
+
* counterpart's UR, `exportAccount` encodes public account material for a watch-only wallet.
|
|
177
|
+
*/
|
|
178
|
+
export declare const qrSigner: (deps: {
|
|
179
|
+
readonly engine: QrEngineSurface;
|
|
180
|
+
readonly wallet: Wallet;
|
|
181
|
+
}) => {
|
|
182
|
+
readonly prepare: (request: QrRequest, account: QrAccount) => Promise<PendingRequest>;
|
|
183
|
+
readonly respond: (id: string) => Promise<QrPayload$1>;
|
|
184
|
+
readonly exportAccount: (params: QrExportParams) => Promise<QrExport>;
|
|
185
|
+
};
|
|
186
|
+
/** The export forms the facade maps onto `chain.exportAccount` nodes. */
|
|
187
|
+
type QrExportParams = {
|
|
188
|
+
readonly account: QrAccount;
|
|
189
|
+
readonly form: "crypto-hdkey";
|
|
190
|
+
readonly verify: VerifyFactor;
|
|
191
|
+
/** Export nodes a device never confirmed — the prompt shows a danger row per node. */
|
|
192
|
+
readonly acknowledgeUnconfirmed?: true;
|
|
193
|
+
} | {
|
|
194
|
+
readonly account: QrAccount;
|
|
195
|
+
readonly form: "crypto-account";
|
|
196
|
+
readonly bitcoin: {
|
|
197
|
+
readonly template: "btc.bip44" | "btc.bip49" | "btc.bip84" | "btc.bip86";
|
|
198
|
+
readonly network: string;
|
|
199
|
+
};
|
|
200
|
+
readonly verify: VerifyFactor;
|
|
201
|
+
readonly acknowledgeUnconfirmed?: true;
|
|
202
|
+
} | {
|
|
203
|
+
readonly account: QrAccount;
|
|
204
|
+
readonly form: "crypto-multi-accounts";
|
|
205
|
+
readonly families: ReadonlyArray<"evm" | "tron" | "solana">;
|
|
206
|
+
readonly bitcoin?: {
|
|
207
|
+
readonly template: "btc.bip44" | "btc.bip49" | "btc.bip84" | "btc.bip86";
|
|
208
|
+
readonly network: string;
|
|
209
|
+
};
|
|
210
|
+
readonly verify: VerifyFactor;
|
|
211
|
+
readonly acknowledgeUnconfirmed?: true;
|
|
212
|
+
};
|
|
213
|
+
/** One phone account a watch-only wallet signs through, read from the phone's export. */
|
|
214
|
+
type QrLink = {
|
|
215
|
+
readonly family: "evm" | "solana" | "tron" | "bitcoin";
|
|
216
|
+
/** Master fingerprint, 8 lowercase hex. */
|
|
217
|
+
readonly fingerprint: string;
|
|
218
|
+
/** The signing key's path: the leaf for evm/tron/solana, the account for bitcoin. */
|
|
219
|
+
readonly path: string;
|
|
220
|
+
/** Evm/tron/solana: the leaf's address; bitcoin: the account's first receive address (0/0). */
|
|
221
|
+
readonly address: string;
|
|
222
|
+
/** Bitcoin only: the account xpub (version bytes for its network/purpose). */
|
|
223
|
+
readonly xpub?: string;
|
|
224
|
+
};
|
|
225
|
+
type QrSignInput = {
|
|
226
|
+
readonly family: "evm";
|
|
227
|
+
readonly kind: "transaction";
|
|
228
|
+
readonly tx: EvmTransaction;
|
|
229
|
+
} | {
|
|
230
|
+
readonly family: "evm";
|
|
231
|
+
readonly kind: "typed-data";
|
|
232
|
+
readonly typedData: string;
|
|
233
|
+
readonly chainId?: number;
|
|
234
|
+
} | {
|
|
235
|
+
readonly family: "evm";
|
|
236
|
+
readonly kind: "personal-message";
|
|
237
|
+
readonly message: Uint8Array;
|
|
238
|
+
readonly chainId?: number;
|
|
239
|
+
} | {
|
|
240
|
+
readonly family: "solana";
|
|
241
|
+
readonly kind: "transaction" | "message";
|
|
242
|
+
readonly data: Uint8Array;
|
|
243
|
+
} | {
|
|
244
|
+
readonly family: "tron";
|
|
245
|
+
readonly kind: "transaction" | "message";
|
|
246
|
+
readonly data: Uint8Array;
|
|
247
|
+
} | {
|
|
248
|
+
readonly family: "bitcoin";
|
|
249
|
+
readonly kind: "psbt";
|
|
250
|
+
readonly psbt: Uint8Array;
|
|
251
|
+
};
|
|
252
|
+
type QrSentRequest = {
|
|
253
|
+
readonly link: QrLink;
|
|
254
|
+
readonly input: QrSignInput;
|
|
255
|
+
readonly requestId?: Uint8Array;
|
|
256
|
+
readonly payload: QrPayload$1;
|
|
257
|
+
};
|
|
258
|
+
type QrSignature = {
|
|
259
|
+
readonly kind: "evm.transaction";
|
|
260
|
+
readonly signedTransaction: Uint8Array;
|
|
261
|
+
} | {
|
|
262
|
+
readonly kind: "evm.signature";
|
|
263
|
+
readonly signature: Uint8Array;
|
|
264
|
+
} | {
|
|
265
|
+
readonly kind: "solana.signature";
|
|
266
|
+
readonly signature: Uint8Array;
|
|
267
|
+
} | {
|
|
268
|
+
readonly kind: "tron.signature";
|
|
269
|
+
readonly signature: Uint8Array;
|
|
270
|
+
} | {
|
|
271
|
+
readonly kind: "bitcoin.psbt";
|
|
272
|
+
readonly psbt: Uint8Array;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* The phone's `crypto-multi-accounts` export as one link per family. Strict: the fingerprint is
|
|
276
|
+
* required, every key's path must be one of the shapes a `QrLink` declares, all keys share the
|
|
277
|
+
* master fingerprint, and at most one key per family is accepted.
|
|
278
|
+
*/
|
|
279
|
+
export declare const readQrExport: (payload: QrPayload$1) => ReadonlyArray<QrLink>;
|
|
280
|
+
/**
|
|
281
|
+
* The watch-only wallet's sign request, encoded as the exact UR the phone accepts: Keystone layouts
|
|
282
|
+
* (`eth`/`sol`/`tron` sign request, `crypto-psbt` for Bitcoin), the link's fingerprint and path, a
|
|
283
|
+
* random 16-byte request id and — only when given — an origin. Inputs the phone would refuse anyway
|
|
284
|
+
* are refused here with the same codes `bindQrRequest` raises.
|
|
285
|
+
*/
|
|
286
|
+
export declare const qrSignRequest: (link: QrLink, input: QrSignInput, options: {
|
|
287
|
+
readonly random: (n: number) => Uint8Array;
|
|
288
|
+
readonly origin?: string;
|
|
289
|
+
}) => QrSentRequest;
|
|
290
|
+
export declare const readQrSignature: (sent: QrSentRequest, payload: QrPayload$1) => QrSignature;
|
|
291
|
+
export { type QrAccount, type QrAccountFacts, type QrDigest, type QrDigestKind, type QrDisplay, type QrEngineSurface, type QrErrorCode, type QrExport, type QrExportForm, type QrExportParams, type QrInspection, type QrLink, type QrPayload, type QrRequest, type QrScanLimits, type QrScanOutcome, type QrScanner, type QrSentRequest, type QrSignInput, type QrSignature, type QrSigner, qrFrames };
|
|
292
|
+
//# sourceMappingURL=qr.d.mts.map
|