@qntx/wallet 0.12.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 +145 -22
- package/dist/backup-CLzMs8DP.mjs +51 -0
- package/dist/backup-CLzMs8DP.mjs.map +1 -0
- package/dist/card.d.mts +12 -0
- package/dist/card.mjs +119 -0
- package/dist/card.mjs.map +1 -0
- package/dist/{chains-BSP0x9RI.d.mts → chains-u1M0CWkT.d.mts} +175 -26
- package/dist/chains.d.mts +11 -4
- package/dist/chains.mjs +19 -62
- package/dist/chains.mjs.map +1 -1
- package/dist/{channel-BQg--l_3.mjs → channel-BCZXU3pt.mjs} +105 -44
- package/dist/channel-BCZXU3pt.mjs.map +1 -0
- package/dist/check-C1fUpgva.mjs +193 -0
- package/dist/check-C1fUpgva.mjs.map +1 -0
- package/dist/{core-DDfzuSIa.mjs → core-Cx7p-0nG.mjs} +136 -15
- package/dist/core-Cx7p-0nG.mjs.map +1 -0
- package/dist/hardware-BL6zvhQh.d.mts +107 -0
- package/dist/hardware.d.mts +81 -0
- package/dist/hardware.mjs +446 -0
- package/dist/hardware.mjs.map +1 -0
- package/dist/host.d.mts +27 -19
- package/dist/host.mjs +471 -144
- package/dist/host.mjs.map +1 -1
- package/dist/{index-DDyJ9KqA.d.mts → index-UclKfprm.d.mts} +274 -18
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +3 -33
- package/dist/{internal-CAKfHjIg.mjs → internal-DwCus_Ws.mjs} +1 -6
- package/dist/internal-DwCus_Ws.mjs.map +1 -0
- package/dist/nostr.d.mts +2 -2
- package/dist/nostr.mjs +14 -14
- package/dist/nostr.mjs.map +1 -1
- package/dist/{protocol-C8x0H3Rr.mjs → protocol-DLE6lHmP.mjs} +493 -52
- package/dist/protocol-DLE6lHmP.mjs.map +1 -0
- package/dist/protocol.d.mts +5 -4
- package/dist/protocol.mjs +3 -3
- package/dist/secret-CbjbY5-f.mjs +25 -0
- package/dist/secret-CbjbY5-f.mjs.map +1 -0
- package/dist/sessions.d.mts +52 -0
- package/dist/sessions.mjs +71 -0
- package/dist/sessions.mjs.map +1 -0
- package/dist/spark.d.mts +3 -3
- package/dist/spark.mjs +5 -8
- package/dist/spark.mjs.map +1 -1
- package/dist/types-CRnacSqJ.d.mts +390 -0
- package/dist/types.d.mts +2 -2
- package/dist/types.mjs +7 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +27 -13
- package/dist/channel-BQg--l_3.mjs.map +0 -1
- package/dist/core-DDfzuSIa.mjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/internal-CAKfHjIg.mjs.map +0 -1
- package/dist/protocol-C8x0H3Rr.mjs.map +0 -1
- package/dist/secret-CcjyF8D3.mjs +0 -205
- package/dist/secret-CcjyF8D3.mjs.map +0 -1
- package/dist/types-Dub5eUl3.d.mts +0 -239
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { N as WalletErrorCode, d as FactorInfo, k as VaultWalletInfo } from "./types-CRnacSqJ.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Strict validator combinators for the secret-area protocol. Both sides share them: the kernel
|
|
4
4
|
* validates every request, the host validates every response. Anything that does not match is a
|
|
@@ -9,6 +9,9 @@ declare class ValidationError extends Error {
|
|
|
9
9
|
}
|
|
10
10
|
type Validator<T> = (value: unknown) => T;
|
|
11
11
|
type NullValue = null;
|
|
12
|
+
type ProtocolValue = NullValue | boolean | number | string | Uint8Array | ReadonlyArray<ProtocolValue> | {
|
|
13
|
+
readonly [key: string]: ProtocolValue;
|
|
14
|
+
};
|
|
12
15
|
declare function literal<T extends NullValue | boolean | number | string>(expected: T): Validator<T>;
|
|
13
16
|
declare const nullValue: Validator<NullValue>;
|
|
14
17
|
declare const bool: Validator<boolean>;
|
|
@@ -40,16 +43,23 @@ declare function union<Vs extends ReadonlyArray<Validator<unknown>>>(...branches
|
|
|
40
43
|
declare function validate<T>(validator: Validator<T>, value: unknown): T | undefined;
|
|
41
44
|
type MethodSpec<P, R> = {
|
|
42
45
|
readonly session: boolean;
|
|
43
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Whether a successful call counts as user presence for the idle timer. It refreshes the deadline
|
|
48
|
+
* only on a host without a platform keystore (Web, Node); on a keystore host only a successful
|
|
49
|
+
* factor verification does.
|
|
50
|
+
*/
|
|
44
51
|
readonly presence: boolean;
|
|
45
52
|
readonly params: Validator<P>;
|
|
46
53
|
readonly result: Validator<R>;
|
|
47
54
|
};
|
|
48
55
|
/**
|
|
49
|
-
* Vault factor material on the wire. `hardware`
|
|
50
|
-
* keystore
|
|
56
|
+
* Vault factor material on the wire. `device` and `hardware` carry nothing: the kernel runs the
|
|
57
|
+
* platform keystore operations itself, so the main runtime never touches the KEK. `device` opens a
|
|
58
|
+
* session without user presence — it can never appear in a `verify` field.
|
|
51
59
|
*/
|
|
52
60
|
type Factor = {
|
|
61
|
+
readonly kind: "device";
|
|
62
|
+
} | {
|
|
53
63
|
readonly kind: "hardware";
|
|
54
64
|
} | {
|
|
55
65
|
readonly kind: "password";
|
|
@@ -59,6 +69,14 @@ type Factor = {
|
|
|
59
69
|
readonly credentialId: Uint8Array;
|
|
60
70
|
readonly prf: Uint8Array;
|
|
61
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* A factor that may prove user presence — every `verify` field uses this validator, so a device
|
|
74
|
+
* factor never reaches `verifyFactor` through the protocol (the kernel rejects it again anyway).
|
|
75
|
+
*/
|
|
76
|
+
type VerifyFactor = Exclude<Factor, {
|
|
77
|
+
readonly kind: "device";
|
|
78
|
+
}>;
|
|
79
|
+
declare const verifier: Validator<VerifyFactor>;
|
|
62
80
|
/** A host-run backup passkey ceremony's evidence: the PRF over `backupSalt` (web). */
|
|
63
81
|
type HostBackupPasskey = {
|
|
64
82
|
readonly kind: "passkey";
|
|
@@ -66,15 +84,24 @@ type HostBackupPasskey = {
|
|
|
66
84
|
readonly credentialId: Uint8Array;
|
|
67
85
|
readonly prfBackup: Uint8Array;
|
|
68
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* The backup password arm: the wire carries the bytes only on hosts without a keystore — on React
|
|
89
|
+
* Native the kernel collects the password through its secure input (`kernel`), so the main runtime
|
|
90
|
+
* never holds it.
|
|
91
|
+
*/
|
|
92
|
+
type BackupPasswordFactor = {
|
|
93
|
+
readonly kind: "password";
|
|
94
|
+
readonly password: Uint8Array;
|
|
95
|
+
} | {
|
|
96
|
+
readonly kind: "password";
|
|
97
|
+
readonly ceremony: "kernel";
|
|
98
|
+
};
|
|
69
99
|
/**
|
|
70
100
|
* A factor that seals a new backup key. On React Native the kernel registers a protection
|
|
71
101
|
* credential (`kernel`) itself and names it; on the web the host hands over its ceremony's
|
|
72
102
|
* evidence.
|
|
73
103
|
*/
|
|
74
|
-
type BackupFactor = {
|
|
75
|
-
readonly kind: "password";
|
|
76
|
-
readonly password: Uint8Array;
|
|
77
|
-
} | HostBackupPasskey | {
|
|
104
|
+
type BackupFactor = BackupPasswordFactor | HostBackupPasskey | {
|
|
78
105
|
readonly kind: "passkey";
|
|
79
106
|
readonly ceremony: "kernel";
|
|
80
107
|
readonly rpId: string;
|
|
@@ -85,10 +112,7 @@ type BackupFactor = {
|
|
|
85
112
|
* A factor that opens a backup envelope. The `kernel` passkey arm asserts one of the envelope's own
|
|
86
113
|
* credentials.
|
|
87
114
|
*/
|
|
88
|
-
type BackupUnlockFactor = {
|
|
89
|
-
readonly kind: "password";
|
|
90
|
-
readonly password: Uint8Array;
|
|
91
|
-
} | HostBackupPasskey | {
|
|
115
|
+
type BackupUnlockFactor = BackupPasswordFactor | HostBackupPasskey | {
|
|
92
116
|
readonly kind: "passkey";
|
|
93
117
|
readonly ceremony: "kernel";
|
|
94
118
|
readonly rpId: string;
|
|
@@ -131,7 +155,7 @@ declare const walletErrorCode: Validator<WalletErrorCode>;
|
|
|
131
155
|
* session it opened. Creating a wallet derives no protocol keys — modules add keys separately.
|
|
132
156
|
*/
|
|
133
157
|
type CreatedResult = {
|
|
134
|
-
readonly wallet:
|
|
158
|
+
readonly wallet: VaultWalletInfo;
|
|
135
159
|
readonly session: string;
|
|
136
160
|
};
|
|
137
161
|
declare const CORE_METHODS: {
|
|
@@ -142,13 +166,22 @@ declare const CORE_METHODS: {
|
|
|
142
166
|
}>;
|
|
143
167
|
readonly "vault.reset": MethodSpec<NullValue, NullValue>;
|
|
144
168
|
readonly "vault.addFactor": MethodSpec<{
|
|
145
|
-
readonly verify:
|
|
169
|
+
readonly verify: VerifyFactor;
|
|
146
170
|
readonly factor: Factor;
|
|
147
171
|
}, FactorInfo>;
|
|
148
172
|
readonly "vault.removeFactor": MethodSpec<{
|
|
149
|
-
readonly verify:
|
|
173
|
+
readonly verify: VerifyFactor;
|
|
150
174
|
readonly id: string;
|
|
151
175
|
}, NullValue>;
|
|
176
|
+
readonly "vault.enrolVerification": MethodSpec<NullValue, NullValue>;
|
|
177
|
+
readonly "vault.setAppLock": MethodSpec<{
|
|
178
|
+
readonly enabled: boolean;
|
|
179
|
+
readonly verify: VerifyFactor;
|
|
180
|
+
}, NullValue>;
|
|
181
|
+
readonly "vault.setBlindSigning": MethodSpec<{
|
|
182
|
+
readonly enabled: boolean;
|
|
183
|
+
readonly verify: VerifyFactor;
|
|
184
|
+
}, NullValue>;
|
|
152
185
|
readonly "session.touch": MethodSpec<NullValue, NullValue>;
|
|
153
186
|
readonly "wallet.createWithPasskey": MethodSpec<CreateWithPasskeyParams, CreatedResult>;
|
|
154
187
|
readonly "wallet.restoreWithPasskey": MethodSpec<RestoreWithPasskeyParams, CreatedResult>;
|
|
@@ -169,13 +202,15 @@ declare const CORE_METHODS: {
|
|
|
169
202
|
readonly draft: string;
|
|
170
203
|
}, NullValue>;
|
|
171
204
|
readonly "backup.enable": MethodSpec<{
|
|
172
|
-
readonly verify:
|
|
205
|
+
readonly verify: VerifyFactor;
|
|
173
206
|
readonly factors: ReadonlyArray<BackupFactor>;
|
|
174
207
|
}, NullValue>;
|
|
175
208
|
readonly "backup.update": MethodSpec<NullValue, {
|
|
176
209
|
readonly envelope: string;
|
|
177
210
|
}>;
|
|
178
|
-
readonly "backup.disable": MethodSpec<
|
|
211
|
+
readonly "backup.disable": MethodSpec<{
|
|
212
|
+
readonly verify: VerifyFactor;
|
|
213
|
+
}, NullValue>;
|
|
179
214
|
readonly "backup.restore": MethodSpec<{
|
|
180
215
|
readonly envelope: string;
|
|
181
216
|
readonly backupFactor: BackupUnlockFactor;
|
|
@@ -185,7 +220,7 @@ declare const CORE_METHODS: {
|
|
|
185
220
|
}>;
|
|
186
221
|
readonly factor?: Factor;
|
|
187
222
|
}, {
|
|
188
|
-
readonly wallets: ReadonlyArray<
|
|
223
|
+
readonly wallets: ReadonlyArray<VaultWalletInfo>;
|
|
189
224
|
readonly passphraseRequired: ReadonlyArray<string>;
|
|
190
225
|
readonly session: string;
|
|
191
226
|
}>;
|
|
@@ -195,21 +230,44 @@ declare const CORE_METHODS: {
|
|
|
195
230
|
readonly factor?: Factor;
|
|
196
231
|
}, CreatedResult>;
|
|
197
232
|
readonly "wallet.exportMnemonic": MethodSpec<{
|
|
198
|
-
readonly verify:
|
|
233
|
+
readonly verify: VerifyFactor;
|
|
199
234
|
readonly walletId: string;
|
|
200
235
|
}, {
|
|
201
236
|
readonly mnemonic: Uint8Array;
|
|
202
237
|
readonly passphrase?: Uint8Array;
|
|
203
238
|
}>;
|
|
204
239
|
readonly "wallet.delete": MethodSpec<{
|
|
205
|
-
readonly verify:
|
|
240
|
+
readonly verify: VerifyFactor;
|
|
206
241
|
readonly walletId: string;
|
|
207
242
|
}, NullValue>;
|
|
208
243
|
readonly "dataKeys.get": MethodSpec<{
|
|
209
244
|
readonly purpose: string;
|
|
210
245
|
}, Uint8Array>;
|
|
246
|
+
readonly "keys.import": MethodSpec<{
|
|
247
|
+
readonly family: "evm" | "solana" | "bitcoin" | "tron";
|
|
248
|
+
readonly secret: Uint8Array;
|
|
249
|
+
}, {
|
|
250
|
+
readonly keyId: string;
|
|
251
|
+
readonly family: "evm" | "solana" | "bitcoin" | "tron";
|
|
252
|
+
readonly address: string;
|
|
253
|
+
readonly createdAt: number;
|
|
254
|
+
}>;
|
|
255
|
+
readonly "keys.list": MethodSpec<NullValue, ReadonlyArray<{
|
|
256
|
+
readonly keyId: string;
|
|
257
|
+
readonly family: "evm" | "solana" | "bitcoin" | "tron";
|
|
258
|
+
readonly address: string;
|
|
259
|
+
readonly createdAt: number;
|
|
260
|
+
}>>;
|
|
261
|
+
readonly "keys.remove": MethodSpec<{
|
|
262
|
+
readonly verify: VerifyFactor;
|
|
263
|
+
readonly keyId: string;
|
|
264
|
+
}, NullValue>;
|
|
265
|
+
readonly "keys.export": MethodSpec<{
|
|
266
|
+
readonly verify: VerifyFactor;
|
|
267
|
+
readonly keyId: string;
|
|
268
|
+
}, Uint8Array>;
|
|
211
269
|
};
|
|
212
|
-
type ChainTemplate = "evm.bip44" | "solana.bip44-change" | "btc.bip44" | "btc.bip49" | "btc.bip84" | "btc.bip86";
|
|
270
|
+
type ChainTemplate = "evm.bip44" | "solana.bip44-change" | "tron.bip44" | "btc.bip44" | "btc.bip49" | "btc.bip84" | "btc.bip86";
|
|
213
271
|
type ChainAccountsParams = {
|
|
214
272
|
readonly walletId: string;
|
|
215
273
|
readonly groupIndex: number;
|
|
@@ -220,10 +278,18 @@ type ChainAccount = {
|
|
|
220
278
|
readonly template: "evm.bip44";
|
|
221
279
|
readonly network: string;
|
|
222
280
|
readonly address: string;
|
|
281
|
+
/** The serving entry passed an on-device check — always true for seed-custody wallets. */
|
|
282
|
+
readonly confirmed: boolean;
|
|
223
283
|
} | {
|
|
224
284
|
readonly template: "solana.bip44-change";
|
|
225
285
|
readonly network: string;
|
|
226
286
|
readonly address: string;
|
|
287
|
+
readonly confirmed: boolean;
|
|
288
|
+
} | {
|
|
289
|
+
readonly template: "tron.bip44";
|
|
290
|
+
readonly network: string;
|
|
291
|
+
readonly address: string;
|
|
292
|
+
readonly confirmed: boolean;
|
|
227
293
|
} | {
|
|
228
294
|
readonly template: "btc.bip44" | "btc.bip49" | "btc.bip84" | "btc.bip86";
|
|
229
295
|
readonly network: string;
|
|
@@ -232,6 +298,9 @@ type ChainAccount = {
|
|
|
232
298
|
readonly fingerprint: string;
|
|
233
299
|
/** Account derivation path, e.g. "m/84'/0'/0'". */
|
|
234
300
|
readonly path: string;
|
|
301
|
+
/** Highest proven change-chain index — the sealed mark the change scan reaches beyond. */
|
|
302
|
+
readonly changeMark: number;
|
|
303
|
+
readonly confirmed: boolean;
|
|
235
304
|
};
|
|
236
305
|
type AccountRef = {
|
|
237
306
|
readonly kind: "hd";
|
|
@@ -241,7 +310,7 @@ type AccountRef = {
|
|
|
241
310
|
} | {
|
|
242
311
|
readonly kind: "imported";
|
|
243
312
|
readonly keyId: string;
|
|
244
|
-
readonly family: "evm" | "solana" | "bitcoin";
|
|
313
|
+
readonly family: "evm" | "solana" | "bitcoin" | "tron";
|
|
245
314
|
};
|
|
246
315
|
type EvmAccessListEntryWire = {
|
|
247
316
|
readonly address: string;
|
|
@@ -267,6 +336,15 @@ type EvmTransactionWire = (EvmTransactionBase & {
|
|
|
267
336
|
readonly maxFeePerGas: string;
|
|
268
337
|
readonly maxPriorityFeePerGas: string;
|
|
269
338
|
readonly accessList: ReadonlyArray<EvmAccessListEntryWire>;
|
|
339
|
+
}) | (EvmTransactionBase & {
|
|
340
|
+
readonly type: "eip7702";
|
|
341
|
+
readonly to: string;
|
|
342
|
+
readonly maxFeePerGas: string;
|
|
343
|
+
readonly maxPriorityFeePerGas: string;
|
|
344
|
+
readonly accessList: ReadonlyArray<EvmAccessListEntryWire>;
|
|
345
|
+
readonly authorization: {
|
|
346
|
+
readonly address: string;
|
|
347
|
+
};
|
|
270
348
|
});
|
|
271
349
|
/** `chain.sign`'s request — the wire mirror of @qntx/wallet-chains `SignRequest`. */
|
|
272
350
|
type ChainSignRequest = {
|
|
@@ -279,6 +357,14 @@ type ChainSignRequest = {
|
|
|
279
357
|
readonly network: string;
|
|
280
358
|
readonly account: AccountRef;
|
|
281
359
|
readonly message: Uint8Array;
|
|
360
|
+
} | {
|
|
361
|
+
readonly kind: "evm.fiat24-session";
|
|
362
|
+
readonly network: string;
|
|
363
|
+
readonly account: AccountRef;
|
|
364
|
+
/** The Fiat24 account token's decimal id. */
|
|
365
|
+
readonly tokenId: string;
|
|
366
|
+
/** Session expiry, Unix seconds. */
|
|
367
|
+
readonly deadline: number;
|
|
282
368
|
} | {
|
|
283
369
|
readonly kind: "evm.typed-data";
|
|
284
370
|
readonly network: string;
|
|
@@ -308,6 +394,8 @@ type ChainSignRequest = {
|
|
|
308
394
|
readonly walletId: string;
|
|
309
395
|
readonly groupIndex: number;
|
|
310
396
|
};
|
|
397
|
+
/** Who built this request — only "internal" requests may raise the change mark. */
|
|
398
|
+
readonly origin: "internal" | "external";
|
|
311
399
|
readonly psbt: Uint8Array;
|
|
312
400
|
readonly sign: ReadonlyArray<{
|
|
313
401
|
readonly index: number;
|
|
@@ -322,12 +410,28 @@ type ChainSignRequest = {
|
|
|
322
410
|
readonly format: "bip322-simple" | "legacy";
|
|
323
411
|
readonly change: 0 | 1;
|
|
324
412
|
readonly index: number;
|
|
413
|
+
} | {
|
|
414
|
+
readonly kind: "tron.transaction";
|
|
415
|
+
readonly network: string;
|
|
416
|
+
readonly account: AccountRef;
|
|
417
|
+
readonly rawData: Uint8Array;
|
|
418
|
+
} | {
|
|
419
|
+
readonly kind: "tron.message";
|
|
420
|
+
readonly network: string;
|
|
421
|
+
readonly account: AccountRef;
|
|
422
|
+
readonly message: Uint8Array;
|
|
423
|
+
} | {
|
|
424
|
+
readonly kind: "tron.typed-data";
|
|
425
|
+
readonly network: string;
|
|
426
|
+
readonly account: AccountRef;
|
|
427
|
+
/** The canonical TIP-712 document, as JSON text. */
|
|
428
|
+
readonly typedData: string;
|
|
325
429
|
};
|
|
326
430
|
type ChainSignResult = {
|
|
327
431
|
readonly kind: "evm.transaction";
|
|
328
432
|
readonly signedTransaction: Uint8Array;
|
|
329
433
|
} | {
|
|
330
|
-
readonly kind: "evm.personal-message" | "evm.typed-data";
|
|
434
|
+
readonly kind: "evm.personal-message" | "evm.fiat24-session" | "evm.typed-data";
|
|
331
435
|
readonly signature: Uint8Array;
|
|
332
436
|
} | {
|
|
333
437
|
readonly kind: "solana.transaction" | "solana.message";
|
|
@@ -338,14 +442,59 @@ type ChainSignResult = {
|
|
|
338
442
|
} | {
|
|
339
443
|
readonly kind: "bitcoin.message";
|
|
340
444
|
readonly signature: string;
|
|
445
|
+
} | {
|
|
446
|
+
readonly kind: "tron.transaction" | "tron.message" | "tron.typed-data";
|
|
447
|
+
readonly signature: Uint8Array;
|
|
341
448
|
};
|
|
342
449
|
type ChainSignParams = {
|
|
343
450
|
readonly request: ChainSignRequest;
|
|
344
|
-
readonly verify:
|
|
451
|
+
readonly verify: VerifyFactor;
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* A node `chain.exportAccount` can serve: the EVM account xpub (`m/44'/60'/0'`, MetaMask's
|
|
455
|
+
* crypto-hdkey), a group's signing leaf, or a Bitcoin account xpub (`m/p'/coin'/group'`).
|
|
456
|
+
*/
|
|
457
|
+
type ChainExportNode = {
|
|
458
|
+
readonly kind: "evm.account";
|
|
459
|
+
} | {
|
|
460
|
+
readonly kind: "leaf";
|
|
461
|
+
readonly template: "evm.bip44" | "tron.bip44" | "solana.bip44-change";
|
|
462
|
+
} | {
|
|
463
|
+
readonly kind: "btc.account";
|
|
464
|
+
readonly template: "btc.bip44" | "btc.bip49" | "btc.bip84" | "btc.bip86";
|
|
465
|
+
readonly network: string;
|
|
466
|
+
};
|
|
467
|
+
type ChainExportParams = {
|
|
468
|
+
readonly walletId: string;
|
|
469
|
+
readonly groupIndex: number;
|
|
470
|
+
readonly nodes: ReadonlyArray<ChainExportNode>;
|
|
471
|
+
readonly verify: VerifyFactor;
|
|
472
|
+
/**
|
|
473
|
+
* Acknowledge exporting nodes a device never confirmed on-screen — the prompt shows one danger
|
|
474
|
+
* row per unconfirmed node. Absent, an unconfirmed node refuses with `approval-required`.
|
|
475
|
+
*/
|
|
476
|
+
readonly acknowledgeUnconfirmed?: true;
|
|
477
|
+
};
|
|
478
|
+
type ChainExportedKey = {
|
|
479
|
+
readonly node: ChainExportNode;
|
|
480
|
+
readonly path: string;
|
|
481
|
+
readonly curve: "secp256k1" | "ed25519";
|
|
482
|
+
readonly publicKey: Uint8Array;
|
|
483
|
+
/** 32 bytes — present iff the node is an account (evm.account / btc.account). */
|
|
484
|
+
readonly chainCode?: Uint8Array;
|
|
485
|
+
/** 8 lowercase hex chars — present iff `chainCode` is. */
|
|
486
|
+
readonly parentFingerprint?: string;
|
|
487
|
+
};
|
|
488
|
+
type ChainExportResult = {
|
|
489
|
+
/** Master-key fingerprint as 8 lowercase hex chars. */
|
|
490
|
+
readonly fingerprint: string;
|
|
491
|
+
/** One key per requested node, in the same order. */
|
|
492
|
+
readonly keys: ReadonlyArray<ChainExportedKey>;
|
|
345
493
|
};
|
|
346
494
|
declare const CHAINS_METHODS: {
|
|
347
495
|
readonly "wallet.accounts": MethodSpec<ChainAccountsParams, ChainAccount>;
|
|
348
496
|
readonly "chain.sign": MethodSpec<ChainSignParams, ChainSignResult>;
|
|
497
|
+
readonly "chain.exportAccount": MethodSpec<ChainExportParams, ChainExportResult>;
|
|
349
498
|
};
|
|
350
|
-
export {
|
|
351
|
-
//# sourceMappingURL=chains-
|
|
499
|
+
export { literal as A, ProtocolValue as C, bool as D, arr as E, str as F, union as I, validate as L, obj as M, opt as N, bytes as O, record as P, NullValue as S, Validator as T, MethodSpec as _, ChainExportParams as a, verifier as b, ChainSignRequest as c, BackupFactor as d, BackupUnlockFactor as f, Factor as g, CreatedResult as h, ChainExportNode as i, nullValue as j, int as k, ChainSignResult as l, CreateWithPasskeyParams as m, ChainAccount as n, ChainExportResult as o, CORE_METHODS as p, ChainAccountsParams as r, ChainExportedKey as s, CHAINS_METHODS as t, ChainTemplate as u, RestoreWithPasskeyParams as v, ValidationError as w, walletErrorCode as x, VerifyFactor as y };
|
|
500
|
+
//# sourceMappingURL=chains-u1M0CWkT.d.mts.map
|
package/dist/chains.d.mts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
1
|
+
import { A as VerifyFactor, j as Wallet } from "./types-CRnacSqJ.mjs";
|
|
2
|
+
import { a as ChainExportParams, c as ChainSignRequest, i as ChainExportNode, l as ChainSignResult, n as ChainAccount, o as ChainExportResult, r as ChainAccountsParams, s as ChainExportedKey, u as ChainTemplate } from "./chains-u1M0CWkT.mjs";
|
|
3
3
|
export type ChainsApi = {
|
|
4
4
|
readonly account: (params: ChainAccountsParams) => Promise<ChainAccount>;
|
|
5
5
|
readonly sign: (params: {
|
|
6
6
|
readonly request: ChainSignRequest;
|
|
7
|
-
readonly verify:
|
|
7
|
+
readonly verify: VerifyFactor;
|
|
8
8
|
}) => Promise<ChainSignResult>;
|
|
9
|
+
readonly exportAccount: (params: {
|
|
10
|
+
readonly walletId: string;
|
|
11
|
+
readonly groupIndex: number;
|
|
12
|
+
readonly nodes: ReadonlyArray<ChainExportNode>;
|
|
13
|
+
readonly verify: VerifyFactor;
|
|
14
|
+
readonly acknowledgeUnconfirmed?: true;
|
|
15
|
+
}) => Promise<ChainExportResult>;
|
|
9
16
|
};
|
|
10
17
|
export declare function chains(wallet: Wallet): ChainsApi;
|
|
11
|
-
export type { ChainAccount, ChainAccountsParams, ChainSignRequest, ChainSignResult, ChainTemplate };
|
|
18
|
+
export type { ChainAccount, ChainAccountsParams, ChainExportNode, ChainExportParams, ChainExportResult, ChainExportedKey, ChainSignRequest, ChainSignResult, ChainTemplate };
|
|
12
19
|
//# sourceMappingURL=chains.d.mts.map
|
package/dist/chains.mjs
CHANGED
|
@@ -1,75 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { bitcoinAddressFromXpub, verifyBitcoinMessage, verifyBitcoinPsbtSignatures } from "@qntx/wallet-chains/bitcoin";
|
|
4
|
-
import { recoverEvmSigner } from "@qntx/wallet-chains/evm";
|
|
5
|
-
import { verifySolanaSignature } from "@qntx/wallet-chains/solana";
|
|
1
|
+
import { t as internalsOf } from "./internal-DwCus_Ws.mjs";
|
|
2
|
+
import { n as checkSignResult, t as checkExportResult } from "./check-C1fUpgva.mjs";
|
|
6
3
|
// src/chains/index.ts
|
|
7
4
|
/**
|
|
8
5
|
* The chains module of @qntx/wallet: `chains(wallet)` returns the wallet's chain API. `account`
|
|
9
6
|
* calls the kernel's `wallet.accounts`; `sign` calls `chain.sign` and then verifies the returned
|
|
10
|
-
* signature against the account address — a kernel that answers with someone else's
|
|
11
|
-
* closed with `integrity`.
|
|
7
|
+
* signature against the request and the account address — a kernel that answers with someone else's
|
|
8
|
+
* signature, or a signature over other content, fails closed with `integrity`.
|
|
12
9
|
*/
|
|
13
|
-
/**
|
|
14
|
-
* The PSBT check: each sign entry names its template, so the account is fetched once per distinct
|
|
15
|
-
* template and each group's signatures verify against that template's xpub.
|
|
16
|
-
*/
|
|
17
|
-
const checkPsbt = async (internals, request, result) => {
|
|
18
|
-
if (result.kind !== "bitcoin.psbt") throw integrity("result kind does not match the request");
|
|
19
|
-
const byTemplate = /* @__PURE__ */ new Map();
|
|
20
|
-
for (const { index, template } of request.sign) {
|
|
21
|
-
const group = byTemplate.get(template) ?? [];
|
|
22
|
-
group.push(index);
|
|
23
|
-
byTemplate.set(template, group);
|
|
24
|
-
}
|
|
25
|
-
for (const [template, indices] of byTemplate) {
|
|
26
|
-
const account = await internals.call("wallet.accounts", {
|
|
27
|
-
walletId: request.account.walletId,
|
|
28
|
-
groupIndex: request.account.groupIndex,
|
|
29
|
-
template,
|
|
30
|
-
network: request.network
|
|
31
|
-
});
|
|
32
|
-
if (!("xpub" in account)) throw integrity("chain account has no xpub");
|
|
33
|
-
if (!verifyBitcoinPsbtSignatures(result.signedPsbt, indices, account.xpub, template, request.network)) throw integrity("psbt signatures do not verify for the account");
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
/** Whether the kernel's signature belongs to the account it was asked to sign for. */
|
|
37
|
-
const checkSigner = (request, result, account) => {
|
|
38
|
-
if (request.kind === "bitcoin.message") {
|
|
39
|
-
if (!("xpub" in account)) throw integrity("chain account has no xpub");
|
|
40
|
-
if (request.kind === "bitcoin.message" && result.kind === "bitcoin.message") {
|
|
41
|
-
if (bitcoinAddressFromXpub(account.xpub, account.template, request.network, request.change, request.index) !== request.address || !verifyBitcoinMessage(request.address, request.message, result.signature, request.network)) throw integrity("message signature does not verify for the account");
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
throw integrity("result kind does not match the request");
|
|
45
|
-
}
|
|
46
|
-
if (!("address" in account)) throw integrity("chain account has no address");
|
|
47
|
-
if (request.kind.startsWith("evm.")) {
|
|
48
|
-
if (result.kind !== "evm.transaction" && result.kind !== "evm.personal-message" && result.kind !== "evm.typed-data") throw integrity("result kind does not match the request");
|
|
49
|
-
if (recoverEvmSigner(request, result).toLowerCase() !== account.address.toLowerCase()) throw integrity("signer does not match the account");
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if ((request.kind === "solana.transaction" || request.kind === "solana.message") && (result.kind === "solana.transaction" || result.kind === "solana.message") && !verifySolanaSignature(request.message, result.signature, account.address)) throw integrity("signature does not verify for the account");
|
|
53
|
-
};
|
|
54
10
|
function createChainsApi(internals) {
|
|
55
11
|
return {
|
|
56
12
|
account: async (params) => internals.call("wallet.accounts", params),
|
|
57
13
|
sign: async (params) => internals.withVerifying(async () => {
|
|
58
|
-
const
|
|
59
|
-
const result = await internals.call("chain.sign", {
|
|
14
|
+
const result = await internals.secretCall("chain.sign", async (wire) => ({
|
|
60
15
|
request: params.request,
|
|
61
|
-
verify
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
16
|
+
verify: await internals.resolveVerifyFactor(params.verify, wire)
|
|
17
|
+
}));
|
|
18
|
+
await checkSignResult(internals, params.request, result);
|
|
19
|
+
return result;
|
|
20
|
+
}),
|
|
21
|
+
exportAccount: async (params) => internals.withVerifying(async () => {
|
|
22
|
+
const result = await internals.secretCall("chain.exportAccount", async (wire) => ({
|
|
23
|
+
walletId: params.walletId,
|
|
24
|
+
groupIndex: params.groupIndex,
|
|
25
|
+
nodes: params.nodes,
|
|
26
|
+
verify: await internals.resolveVerifyFactor(params.verify, wire),
|
|
27
|
+
...params.acknowledgeUnconfirmed === void 0 ? {} : { acknowledgeUnconfirmed: params.acknowledgeUnconfirmed }
|
|
28
|
+
}));
|
|
29
|
+
await checkExportResult(internals, params, result);
|
|
73
30
|
return result;
|
|
74
31
|
})
|
|
75
32
|
};
|
package/dist/chains.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chains.mjs","names":[],"sources":["../src/chains/index.ts"],"sourcesContent":["/**\n * The chains module of @qntx/wallet: `chains(wallet)` returns the wallet's chain API. `account`\n * calls the kernel's `wallet.accounts`; `sign` calls `chain.sign` and then verifies the returned\n * signature against the account address — a kernel that answers with someone else's
|
|
1
|
+
{"version":3,"file":"chains.mjs","names":[],"sources":["../src/chains/index.ts"],"sourcesContent":["/**\n * The chains module of @qntx/wallet: `chains(wallet)` returns the wallet's chain API. `account`\n * calls the kernel's `wallet.accounts`; `sign` calls `chain.sign` and then verifies the returned\n * signature against the request and the account address — a kernel that answers with someone else's\n * signature, or a signature over other content, fails closed with `integrity`.\n */\nimport { internalsOf } from \"../internal.ts\";\nimport type { WalletInternals } from \"../internal.ts\";\nimport type {\n ChainAccount,\n ChainAccountsParams,\n ChainExportNode,\n ChainExportResult,\n ChainSignRequest,\n ChainSignResult,\n} from \"../protocol/chains.ts\";\nimport type { VerifyFactor, Wallet } from \"../types.ts\";\nimport { checkExportResult, checkSignResult } from \"./check.ts\";\n\nexport type {\n ChainAccount,\n ChainAccountsParams,\n ChainExportedKey,\n ChainExportNode,\n ChainExportParams,\n ChainExportResult,\n ChainSignRequest,\n ChainSignResult,\n ChainTemplate,\n} from \"../protocol/chains.ts\";\n\nexport type ChainsApi = {\n readonly account: (params: ChainAccountsParams) => Promise<ChainAccount>;\n readonly sign: (params: {\n readonly request: ChainSignRequest;\n readonly verify: VerifyFactor;\n }) => Promise<ChainSignResult>;\n readonly exportAccount: (params: {\n readonly walletId: string;\n readonly groupIndex: number;\n readonly nodes: ReadonlyArray<ChainExportNode>;\n readonly verify: VerifyFactor;\n /* A node served by device material never confirmed on the device refuses with\n `approval-required` unless the host acknowledged the danger-row warning. */\n readonly acknowledgeUnconfirmed?: true;\n }) => Promise<ChainExportResult>;\n};\n\nfunction createChainsApi(internals: WalletInternals): ChainsApi {\n return {\n account: async (params) => internals.call(\"wallet.accounts\", params),\n sign: async (params) =>\n internals.withVerifying(async () => {\n const result = await internals.secretCall(\"chain.sign\", async (wire) => ({\n request: params.request,\n verify: await internals.resolveVerifyFactor(params.verify, wire),\n }));\n await checkSignResult(internals, params.request, result);\n return result;\n }),\n exportAccount: async (params) =>\n internals.withVerifying(async () => {\n const result = await internals.secretCall(\"chain.exportAccount\", async (wire) => ({\n walletId: params.walletId,\n groupIndex: params.groupIndex,\n nodes: params.nodes,\n verify: await internals.resolveVerifyFactor(params.verify, wire),\n ...(params.acknowledgeUnconfirmed === undefined\n ? {}\n : { acknowledgeUnconfirmed: params.acknowledgeUnconfirmed }),\n }));\n await checkExportResult(internals, params, result);\n return result;\n }),\n };\n}\n\nconst apis = new WeakMap<Wallet, ChainsApi>();\n\nexport function chains(wallet: Wallet): ChainsApi {\n const internals = internalsOf(wallet);\n let api = apis.get(wallet);\n if (api === undefined) {\n api = createChainsApi(internals);\n apis.set(wallet, api);\n }\n return api;\n}\n"],"mappings":";;;;;;;;;AAgDA,SAAS,gBAAgB,WAAuC;CAC9D,OAAO;EACL,SAAS,OAAO,WAAW,UAAU,KAAK,mBAAmB,MAAM;EACnE,MAAM,OAAO,WACX,UAAU,cAAc,YAAY;GAClC,MAAM,SAAS,MAAM,UAAU,WAAW,cAAc,OAAO,UAAU;IACvE,SAAS,OAAO;IAChB,QAAQ,MAAM,UAAU,oBAAoB,OAAO,QAAQ,IAAI;GACjE,EAAE;GACF,MAAM,gBAAgB,WAAW,OAAO,SAAS,MAAM;GACvD,OAAO;EACT,CAAC;EACH,eAAe,OAAO,WACpB,UAAU,cAAc,YAAY;GAClC,MAAM,SAAS,MAAM,UAAU,WAAW,uBAAuB,OAAO,UAAU;IAChF,UAAU,OAAO;IACjB,YAAY,OAAO;IACnB,OAAO,OAAO;IACd,QAAQ,MAAM,UAAU,oBAAoB,OAAO,QAAQ,IAAI;IAC/D,GAAI,OAAO,2BAA2B,KAAA,IAClC,CAAC,IACD,EAAE,wBAAwB,OAAO,uBAAuB;GAC9D,EAAE;GACF,MAAM,kBAAkB,WAAW,QAAQ,MAAM;GACjD,OAAO;EACT,CAAC;CACL;AACF;AAEA,MAAM,uBAAO,IAAI,QAA2B;AAE5C,SAAgB,OAAO,QAA2B;CAChD,MAAM,YAAY,YAAY,MAAM;CACpC,IAAI,MAAM,KAAK,IAAI,MAAM;CACzB,IAAI,QAAQ,KAAA,GAAW;EACrB,MAAM,gBAAgB,SAAS;EAC/B,KAAK,IAAI,QAAQ,GAAG;CACtB;CACA,OAAO;AACT"}
|