@ledgerhq/device-signer-kit-bitcoin 0.0.0-20250120001116 → 0.0.0-signer-eth-20250122093657

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.
Files changed (116) hide show
  1. package/README.md +363 -0
  2. package/lib/cjs/api/SignerBtc.js +1 -1
  3. package/lib/cjs/api/SignerBtc.js.map +1 -1
  4. package/lib/cjs/api/app-binder/GetWalletAddressDeviceActionTypes.js +2 -0
  5. package/lib/cjs/api/app-binder/GetWalletAddressDeviceActionTypes.js.map +7 -0
  6. package/lib/cjs/api/index.js +1 -1
  7. package/lib/cjs/api/index.js.map +2 -2
  8. package/lib/cjs/api/model/Wallet.js +1 -1
  9. package/lib/cjs/api/model/Wallet.js.map +1 -1
  10. package/lib/cjs/api/model/WalletAddressOptions.js +2 -0
  11. package/lib/cjs/api/model/WalletAddressOptions.js.map +7 -0
  12. package/lib/cjs/internal/DefaultSignerBtc.js +1 -1
  13. package/lib/cjs/internal/DefaultSignerBtc.js.map +3 -3
  14. package/lib/cjs/internal/app-binder/BtcAppBinder.js +1 -1
  15. package/lib/cjs/internal/app-binder/BtcAppBinder.js.map +3 -3
  16. package/lib/cjs/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js +1 -1
  17. package/lib/cjs/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js.map +2 -2
  18. package/lib/cjs/internal/app-binder/command/GetWalletAddressCommand.js +1 -1
  19. package/lib/cjs/internal/app-binder/command/GetWalletAddressCommand.js.map +3 -3
  20. package/lib/cjs/internal/app-binder/command/GetWalletAddressCommand.test.js +1 -1
  21. package/lib/cjs/internal/app-binder/command/GetWalletAddressCommand.test.js.map +3 -3
  22. package/lib/cjs/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.js +2 -0
  23. package/lib/cjs/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.js.map +7 -0
  24. package/lib/cjs/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.test.js +2 -0
  25. package/lib/cjs/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.test.js.map +7 -0
  26. package/lib/cjs/internal/app-binder/task/GetWalletAddressTask.js +2 -0
  27. package/lib/cjs/internal/app-binder/task/GetWalletAddressTask.js.map +7 -0
  28. package/lib/cjs/internal/app-binder/task/GetWalletAddressTask.test.js +2 -0
  29. package/lib/cjs/internal/app-binder/task/GetWalletAddressTask.test.js.map +7 -0
  30. package/lib/cjs/internal/use-cases/di/useCasesModule.js +1 -1
  31. package/lib/cjs/internal/use-cases/di/useCasesModule.js.map +3 -3
  32. package/lib/cjs/internal/use-cases/di/useCasesModule.test.js +1 -1
  33. package/lib/cjs/internal/use-cases/di/useCasesModule.test.js.map +2 -2
  34. package/lib/cjs/internal/use-cases/di/useCasesTypes.js +1 -1
  35. package/lib/cjs/internal/use-cases/di/useCasesTypes.js.map +2 -2
  36. package/lib/cjs/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.js +2 -0
  37. package/lib/cjs/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.js.map +7 -0
  38. package/lib/cjs/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.test.js +2 -0
  39. package/lib/cjs/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.test.js.map +7 -0
  40. package/lib/cjs/internal/utils/BtcCommandUtils.js +1 -1
  41. package/lib/cjs/internal/utils/BtcCommandUtils.js.map +3 -3
  42. package/lib/cjs/package.json +1 -1
  43. package/lib/esm/api/app-binder/GetWalletAddressDeviceActionTypes.js +1 -0
  44. package/lib/esm/api/app-binder/GetWalletAddressDeviceActionTypes.js.map +7 -0
  45. package/lib/esm/api/index.js +1 -1
  46. package/lib/esm/api/index.js.map +2 -2
  47. package/lib/esm/api/model/Wallet.js +1 -1
  48. package/lib/esm/api/model/Wallet.js.map +1 -1
  49. package/lib/esm/api/model/WalletAddressOptions.js +1 -0
  50. package/lib/esm/api/model/WalletAddressOptions.js.map +7 -0
  51. package/lib/esm/internal/DefaultSignerBtc.js +1 -1
  52. package/lib/esm/internal/DefaultSignerBtc.js.map +3 -3
  53. package/lib/esm/internal/app-binder/BtcAppBinder.js +1 -1
  54. package/lib/esm/internal/app-binder/BtcAppBinder.js.map +3 -3
  55. package/lib/esm/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js +1 -1
  56. package/lib/esm/internal/app-binder/command/GetExtendedPublicKeyCommand.test.js.map +2 -2
  57. package/lib/esm/internal/app-binder/command/GetWalletAddressCommand.js +1 -1
  58. package/lib/esm/internal/app-binder/command/GetWalletAddressCommand.js.map +3 -3
  59. package/lib/esm/internal/app-binder/command/GetWalletAddressCommand.test.js +1 -1
  60. package/lib/esm/internal/app-binder/command/GetWalletAddressCommand.test.js.map +3 -3
  61. package/lib/esm/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.js +2 -0
  62. package/lib/esm/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.js.map +7 -0
  63. package/lib/esm/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.test.js +2 -0
  64. package/lib/esm/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.test.js.map +7 -0
  65. package/lib/esm/internal/app-binder/task/GetWalletAddressTask.js +2 -0
  66. package/lib/esm/internal/app-binder/task/GetWalletAddressTask.js.map +7 -0
  67. package/lib/esm/internal/app-binder/task/GetWalletAddressTask.test.js +2 -0
  68. package/lib/esm/internal/app-binder/task/GetWalletAddressTask.test.js.map +7 -0
  69. package/lib/esm/internal/use-cases/di/useCasesModule.js +1 -1
  70. package/lib/esm/internal/use-cases/di/useCasesModule.js.map +3 -3
  71. package/lib/esm/internal/use-cases/di/useCasesModule.test.js +1 -1
  72. package/lib/esm/internal/use-cases/di/useCasesModule.test.js.map +2 -2
  73. package/lib/esm/internal/use-cases/di/useCasesTypes.js +1 -1
  74. package/lib/esm/internal/use-cases/di/useCasesTypes.js.map +2 -2
  75. package/lib/esm/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.js +2 -0
  76. package/lib/esm/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.js.map +7 -0
  77. package/lib/esm/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.test.js +2 -0
  78. package/lib/esm/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.test.js.map +7 -0
  79. package/lib/esm/internal/utils/BtcCommandUtils.js +1 -1
  80. package/lib/esm/internal/utils/BtcCommandUtils.js.map +3 -3
  81. package/lib/esm/package.json +1 -1
  82. package/lib/types/api/SignerBtc.d.ts +3 -0
  83. package/lib/types/api/SignerBtc.d.ts.map +1 -1
  84. package/lib/types/api/app-binder/GetWalletAddressDeviceActionTypes.d.ts +32 -0
  85. package/lib/types/api/app-binder/GetWalletAddressDeviceActionTypes.d.ts.map +1 -0
  86. package/lib/types/api/index.d.ts +2 -1
  87. package/lib/types/api/index.d.ts.map +1 -1
  88. package/lib/types/api/model/Wallet.d.ts +3 -0
  89. package/lib/types/api/model/Wallet.d.ts.map +1 -1
  90. package/lib/types/api/model/WalletAddressOptions.d.ts +5 -0
  91. package/lib/types/api/model/WalletAddressOptions.d.ts.map +1 -0
  92. package/lib/types/internal/DefaultSignerBtc.d.ts +3 -1
  93. package/lib/types/internal/DefaultSignerBtc.d.ts.map +1 -1
  94. package/lib/types/internal/app-binder/BtcAppBinder.d.ts +7 -0
  95. package/lib/types/internal/app-binder/BtcAppBinder.d.ts.map +1 -1
  96. package/lib/types/internal/app-binder/command/GetWalletAddressCommand.d.ts +5 -7
  97. package/lib/types/internal/app-binder/command/GetWalletAddressCommand.d.ts.map +1 -1
  98. package/lib/types/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.d.ts +38 -0
  99. package/lib/types/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.d.ts.map +1 -0
  100. package/lib/types/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.test.d.ts +2 -0
  101. package/lib/types/internal/app-binder/device-action/GetWalletAddress/GetWalletAddressDeviceAction.test.d.ts.map +1 -0
  102. package/lib/types/internal/app-binder/task/GetWalletAddressTask.d.ts +27 -0
  103. package/lib/types/internal/app-binder/task/GetWalletAddressTask.d.ts.map +1 -0
  104. package/lib/types/internal/app-binder/task/GetWalletAddressTask.test.d.ts +2 -0
  105. package/lib/types/internal/app-binder/task/GetWalletAddressTask.test.d.ts.map +1 -0
  106. package/lib/types/internal/use-cases/di/useCasesModule.d.ts.map +1 -1
  107. package/lib/types/internal/use-cases/di/useCasesTypes.d.ts +1 -0
  108. package/lib/types/internal/use-cases/di/useCasesTypes.d.ts.map +1 -1
  109. package/lib/types/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.d.ts +9 -0
  110. package/lib/types/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.d.ts.map +1 -0
  111. package/lib/types/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.test.d.ts +2 -0
  112. package/lib/types/internal/use-cases/get-wallet-address/GetWalletAddressUseCase.test.d.ts.map +1 -0
  113. package/lib/types/internal/utils/BtcCommandUtils.d.ts +2 -0
  114. package/lib/types/internal/utils/BtcCommandUtils.d.ts.map +1 -1
  115. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  116. package/package.json +5 -5
package/README.md ADDED
@@ -0,0 +1,363 @@
1
+ # Ledger Bitcoin Signer
2
+
3
+ This module provides the implementation of the Ledger Bitcoin signer of the Device Management Kit. It enables interaction with the Bitcoin application on a Ledger device including:
4
+
5
+ - Retrieving the Bitcoin public key using a given address index;
6
+ - Signing a message displayed on a Ledger device;
7
+ - Signing a Bitcoin partially signed transaction (PSBT);
8
+ - Signing a Bitcoin transaction;
9
+
10
+ ## 🔹 Index
11
+
12
+ 1. [How it works](#how-it-works)
13
+ 2. [Installation](#installation)
14
+ 3. [Initialisation](#initialisation)
15
+ 4. [Use Cases](#use-cases)
16
+ - [Get Extended Public Key](#use-case-1-get-extended-public-key)
17
+ - [Sign Message](#use-case-2-sign-message)
18
+ - [Sign Partially Signed Transaction (PSBT)](#use-case-3-sign-psbt)
19
+ - [Sign Transaction](#use-case-4-sign-transaction)
20
+ 5. [Observable Behavior](#observable-behavior)
21
+ 6. [Example](#example)
22
+
23
+ ## 🔹 How it works
24
+
25
+ The Ledger Bitcoin Signer utilizes the advanced capabilities of the Ledger device to provide secure operations for end users. It takes advantage of the interface provided by the Device Management Kit to establish communication with the Ledger device and execute various operations. The communication with the Ledger device is performed using [APDU](https://en.wikipedia.org/wiki/Smart_card_application_protocol_data_unit)s (Application Protocol Data Units), which are encapsulated within the `Command` object. These commands are then organized into tasks, allowing for the execution of complex operations with one or more APDUs. The tasks are further encapsulated within `DeviceAction` objects to handle different real-world scenarios. Finally, the Signer exposes dedicated and independent use cases that can be directly utilized by end users.
26
+
27
+ ## 🔹 Installation
28
+
29
+ > **Note:** This module is not standalone; it depends on the [@ledgerhq/device-management-kit](https://github.com/LedgerHQ/device-sdk-ts/tree/develop/packages/device-management-kit) package, so you need to install it first.
30
+
31
+ To install the `device-signer-kit-bitcoin` package, run the following command:
32
+
33
+ ```sh
34
+ npm install @ledgerhq/device-signer-kit-bitcoin
35
+ ```
36
+
37
+ ## 🔹 Initialisation
38
+
39
+ To initialise a Bitcoin signer instance, you need a Ledger Device Management Kit instance and the ID of the session of the connected device. Use the `SignerBtcBuilder` along with the [Context Module](https://github.com/LedgerHQ/device-sdk-ts/tree/develop/packages/signer/context-module) by default developed by Ledger:
40
+
41
+ ```typescript
42
+ // Initialize a Bitcoin signer instance
43
+ const signerBitcoin = new SignerBtcBuilder({ sdk, sessionId }).build();
44
+ ```
45
+
46
+ ## 🔹 Use Cases
47
+
48
+ The `SignerBtcBuilder.build()` method will return a `SignerBitcoin` instance that exposes 5 dedicated methods, each of which calls an independent use case. Each use case will return an object that contains an observable and a method called `cancel`.
49
+
50
+ ---
51
+
52
+ ### Use Case 1: Get Extended Public Key
53
+
54
+ This method allows users to retrieve the Bitcoin extended public key based on a given `derivationPath`.
55
+
56
+ ```typescript
57
+ const { observable, cancel } = signerBitcoin.getExtendedPublicKey(
58
+ derivationPath,
59
+ options,
60
+ );
61
+ ```
62
+
63
+ #### **Parameters**
64
+
65
+ - `derivationPath`
66
+
67
+ - **Required**
68
+ - **Type:** `string` (e.g. `"84'/0'/0'"` for a Native Segwit wallet)
69
+ - The derivation path used for the Bitcoin address. See [here](https://www.ledger.com/blog/understanding-crypto-addresses-and-derivation-paths) for more information.
70
+
71
+ - `options`
72
+
73
+ - Optional
74
+ - Type: `AddressOptions`
75
+
76
+ ```typescript
77
+ type AddressOptions = {
78
+ checkOnDevice?: boolean;
79
+ };
80
+ ```
81
+
82
+ - `checkOnDevice`: An optional boolean indicating whether user confirmation on the device is required (`true`) or not (`false`).
83
+
84
+ #### **Returns**
85
+
86
+ - `observable` Emits DeviceActionState updates, including the following details::
87
+
88
+ ```typescript
89
+ type GetAddressCommandResponse = {
90
+ extendedPublicKey: string;
91
+ };
92
+ ```
93
+
94
+ - `cancel` A function to cancel the action on the Ledger device.
95
+
96
+ ---
97
+
98
+ ### Use Case 2: Sign Message
99
+
100
+ This method allows users to sign a text string that is displayed on Ledger devices.
101
+
102
+ ```typescript
103
+ const { observable, cancel } = signerBitcoin.signMessage(
104
+ derivationPath,
105
+ message,
106
+ );
107
+ ```
108
+
109
+ #### **Parameters**
110
+
111
+ - `derivationPath`
112
+
113
+ - **Required**
114
+ - **Type:** `string` (e.g. `"84'/0'/0'"` for a Native Segwit wallet)
115
+ - The derivation path used for the Bitcoin address. See [here](https://www.ledger.com/blog/understanding-crypto-addresses-and-derivation-paths) for more information.
116
+
117
+ - `message`
118
+
119
+ - **Required**
120
+ - **Type:**: `string`
121
+ - The message to be signed, which will be displayed on the Ledger device.
122
+
123
+ #### **Returns**
124
+
125
+ - `observable` Emits DeviceActionState updates, including the following details::
126
+
127
+ ```typescript
128
+ type Signature = {
129
+ r: `0x${string}`; // R component of the signature
130
+ s: `0x${string}`; // S component of the signature
131
+ v: number; // Recovery parameter
132
+ };
133
+ ```
134
+
135
+ - `cancel` A function to cancel the action on the Ledger device.
136
+
137
+ ---
138
+
139
+ ### Use Case 3: Sign PSBT
140
+
141
+ This method allows users to sign a partially signed transaction.
142
+
143
+ ```typescript
144
+ const { observable, cancel } = signerBitcoin.signPsbt(
145
+ new DefaultWallet(path, descriptorTemplate),
146
+ psbt,
147
+ );
148
+ ```
149
+
150
+ #### **Parameters**
151
+
152
+ - `wallet`
153
+
154
+ - **Required**
155
+ - **Type:** `Wallet`
156
+
157
+ ```typescript
158
+ type Wallet = DefaultWallet | RegisteredWallet;
159
+
160
+ class DefaultWallet {
161
+ constructor(
162
+ // Derivation path without master key respresentation.
163
+ // Format example: /44'/0'/0'
164
+ public derivationPath: string,
165
+ public template: DefaultDescriptorTemplate,
166
+ ) {}
167
+ }
168
+
169
+ class RegisteredWallet {
170
+ constructor(
171
+ public name: string,
172
+ public descriptorTemplate: string,
173
+ public keys: string[],
174
+ public hmac: Uint8Array,
175
+ ) {}
176
+ }
177
+ ```
178
+
179
+ - `psbt`
180
+ - **Required**
181
+ - **Type:** `string`
182
+ - The base64 psbt string
183
+
184
+ #### **Returns**
185
+
186
+ - `observable` Emits DeviceActionState updates, including the following details::
187
+
188
+ ```typescript
189
+ type Signature = {
190
+ r: `0x${string}`; // R component of the signature
191
+ s: `0x${string}`; // S component of the signature
192
+ v: number; // Recovery parameter
193
+ };
194
+ ```
195
+
196
+ - `cancel` A function to cancel the action on the Ledger device.
197
+
198
+ ---
199
+
200
+ ### Use Case 4: Sign transaction
201
+
202
+ This method allows users to sign a Bitcoin transaction.
203
+
204
+ ```typescript
205
+ const { observable, cancel } = signerBitcoin.signTransaction(
206
+ new DefaultWallet(path, descriptorTemplate),
207
+ psbt,
208
+ );
209
+ ```
210
+
211
+ #### **Parameters**
212
+
213
+ - `wallet`
214
+
215
+ - **Required**
216
+ - **Type:** `Wallet`
217
+
218
+ ```typescript
219
+ type Wallet = DefaultWallet | RegisteredWallet;
220
+
221
+ class DefaultWallet {
222
+ constructor(
223
+ // Derivation path without master key respresentation.
224
+ // Format example: /44'/0'/0'
225
+ public derivationPath: string,
226
+ public template: DefaultDescriptorTemplate,
227
+ ) {}
228
+ }
229
+
230
+ class RegisteredWallet {
231
+ constructor(
232
+ public name: string,
233
+ public descriptorTemplate: string,
234
+ public keys: string[],
235
+ public hmac: Uint8Array,
236
+ ) {}
237
+ }
238
+ ```
239
+
240
+ - `psbt`
241
+ - **Required**
242
+ - **Type:** `string`
243
+ - The base64 psbt string
244
+
245
+ #### **Returns**
246
+
247
+ - `observable` Emits DeviceActionState updates, including the following details::
248
+
249
+ ```typescript
250
+ type Signature = {
251
+ r: `0x${string}`; // R component of the signature
252
+ s: `0x${string}`; // S component of the signature
253
+ v: number; // Recovery parameter
254
+ };
255
+ ```
256
+
257
+ - `cancel` A function to cancel the action on the Ledger device.
258
+
259
+ ## 🔹 Observable Behavior
260
+
261
+ Each method returns an [Observable](https://rxjs.dev/guide/observable) emitting updates structured as [`DeviceActionState`](https://github.com/LedgerHQ/device-sdk-ts/blob/develop/packages/device-management-kit/src/api/device-action/model/DeviceActionState.ts). These updates reflect the operation’s progress and status:
262
+
263
+ - **NotStarted**: The operation hasn’t started.
264
+ - **Pending**: The operation is in progress and may require user interaction.
265
+ - **Stopped**: The operation was canceled or stopped.
266
+ - **Completed**: The operation completed successfully, with results available.
267
+ - **Error**: An error occurred.
268
+
269
+ **Example Observable Subscription:**
270
+
271
+ ```typescript
272
+ observable.subscribe({
273
+ next: (state: DeviceActionState) => {
274
+ switch (state.status) {
275
+ case DeviceActionStatus.NotStarted: {
276
+ console.log("The action is not started yet.");
277
+ break;
278
+ }
279
+ case DeviceActionStatus.Pending: {
280
+ const {
281
+ intermediateValue: { requiredUserInteraction },
282
+ } = state;
283
+ // Access the intermediate value here, explained below
284
+ console.log(
285
+ "The action is pending and the intermediate value is: ",
286
+ intermediateValue,
287
+ );
288
+ break;
289
+ }
290
+ case DeviceActionStatus.Stopped: {
291
+ console.log("The action has been stopped.");
292
+ break;
293
+ }
294
+ case DeviceActionStatus.Completed: {
295
+ const { output } = state;
296
+ // Access the output of the completed action here
297
+ console.log("The action has been completed: ", output);
298
+ break;
299
+ }
300
+ case DeviceActionStatus.Error: {
301
+ const { error } = state;
302
+ // Access the error here if occured
303
+ console.log("An error occured during the action: ", error);
304
+ break;
305
+ }
306
+ }
307
+ },
308
+ });
309
+ ```
310
+
311
+ **Intermediate Values in Pending Status:**
312
+
313
+ When the status is DeviceActionStatus.Pending, the state will include an `intermediateValue` object that provides useful information for interaction:
314
+
315
+ ```typescript
316
+ const { requiredUserInteraction } = intermediateValue;
317
+
318
+ switch (requiredUserInteraction) {
319
+ case UserInteractionRequired.VerifyAddress: {
320
+ // User needs to verify the address displayed on the device
321
+ console.log("User needs to verify the address displayed on the device.");
322
+ break;
323
+ }
324
+ case UserInteractionRequired.SignTransaction: {
325
+ // User needs to sign the transaction displayed on the device
326
+ console.log("User needs to sign the transaction displayed on the device.");
327
+ break;
328
+ }
329
+ case UserInteractionRequired.SignTypedData: {
330
+ // User needs to sign the typed data displayed on the device
331
+ console.log("User needs to sign the typed data displayed on the device.");
332
+ break;
333
+ }
334
+ case UserInteractionRequired.SignPersonalMessage: {
335
+ // User needs to sign the message displayed on the device
336
+ console.log("User needs to sign the message displayed on the device.");
337
+ break;
338
+ }
339
+ case UserInteractionRequired.None: {
340
+ // No user action required
341
+ console.log("No user action needed.");
342
+ break;
343
+ }
344
+ case UserInteractionRequired.UnlockDevice: {
345
+ // User needs to unlock the device
346
+ console.log("The user needs to unlock the device.");
347
+ break;
348
+ }
349
+ case UserInteractionRequired.ConfirmOpenApp: {
350
+ // User needs to confirm on the device to open the app
351
+ console.log("The user needs to confirm on the device to open the app.");
352
+ break;
353
+ }
354
+ default:
355
+ // Type guard to ensure all cases are handled
356
+ const uncaughtUserInteraction: never = requiredUserInteraction;
357
+ console.error("Unhandled user interaction case:", uncaughtUserInteraction);
358
+ }
359
+ ```
360
+
361
+ ## 🔹 Example
362
+
363
+ We encourage you to explore the Bitcoin Signer by trying it out in our online [sample application](https://app.devicesdk.ledger-test.com/). Experience how it works and see its capabilities in action. Of course, you will need a Ledger device connected.
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var g=(e,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of o(t))!a.call(e,n)&&n!==s&&i(e,n,{get:()=>t[n],enumerable:!(r=p(t,n))||r.enumerable});return e};var y=e=>g(i({},"__esModule",{value:!0}),e);var m={};module.exports=y(m);
1
+ "use strict";var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var l=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of o(e))!a.call(t,r)&&r!==i&&n(t,r,{get:()=>e[r],enumerable:!(s=p(e,r))||s.enumerable});return t};var d=t=>l(n({},"__esModule",{value:!0}),t);var y={};module.exports=d(y);
2
2
  //# sourceMappingURL=SignerBtc.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/api/SignerBtc.ts"],
4
- "sourcesContent": ["import { type GetExtendedPublicKeyDAReturnType } from \"@api/app-binder/GetExtendedPublicKeyDeviceActionTypes\";\nimport { type SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { type SignPsbtDAReturnType } from \"@api/app-binder/SignPsbtDeviceActionTypes\";\nimport { type SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOptions\";\nimport { type Psbt } from \"@api/model/Psbt\";\nimport { type Wallet } from \"@api/model/Wallet\";\n\nexport interface SignerBtc {\n getExtendedPublicKey: (\n derivationPath: string,\n options: AddressOptions,\n ) => GetExtendedPublicKeyDAReturnType;\n signMessage: (\n derivationPath: string,\n message: string,\n ) => SignMessageDAReturnType;\n signPsbt: (wallet: Wallet, psbt: Psbt) => SignPsbtDAReturnType;\n signTransaction: (wallet: Wallet, psbt: Psbt) => SignTransactionDAReturnType;\n // getAddress: (wallet: Wallet, options?: AddressOptions) => Promise<string>;\n}\n"],
4
+ "sourcesContent": ["import { type GetExtendedPublicKeyDAReturnType } from \"@api/app-binder/GetExtendedPublicKeyDeviceActionTypes\";\nimport { type SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { type SignPsbtDAReturnType } from \"@api/app-binder/SignPsbtDeviceActionTypes\";\nimport { type SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOptions\";\nimport { type Psbt } from \"@api/model/Psbt\";\nimport { type Wallet } from \"@api/model/Wallet\";\n\nimport { type GetWalletAddressDAReturnType } from \"./app-binder/GetWalletAddressDeviceActionTypes\";\nimport { type WalletAddressOptions } from \"./model/WalletAddressOptions\";\n\nexport interface SignerBtc {\n getExtendedPublicKey: (\n derivationPath: string,\n options: AddressOptions,\n ) => GetExtendedPublicKeyDAReturnType;\n signMessage: (\n derivationPath: string,\n message: string,\n ) => SignMessageDAReturnType;\n signPsbt: (wallet: Wallet, psbt: Psbt) => SignPsbtDAReturnType;\n signTransaction: (wallet: Wallet, psbt: Psbt) => SignTransactionDAReturnType;\n getWalletAddress: (\n wallet: Wallet,\n addressIndex: number,\n options: WalletAddressOptions,\n ) => GetWalletAddressDAReturnType;\n}\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["SignerBtc_exports", "__toCommonJS"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var s=(t,e,d,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!n.call(t,r)&&r!==d&&a(t,r,{get:()=>e[r],enumerable:!(l=o(e,r))||l.enumerable});return t};var A=t=>s(a({},"__esModule",{value:!0}),t);var i={};module.exports=A(i);
2
+ //# sourceMappingURL=GetWalletAddressDeviceActionTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/api/app-binder/GetWalletAddressDeviceActionTypes.ts"],
4
+ "sourcesContent": ["import {\n type CommandErrorResult,\n type DeviceActionState,\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type WalletAddress } from \"@api/model/Wallet\";\nimport { type Wallet as ApiWallet } from \"@api/model/Wallet\";\nimport { type BtcErrorCodes } from \"@internal/app-binder/command/utils/bitcoinAppErrors\";\nimport { type DataStoreService } from \"@internal/data-store/service/DataStoreService\";\nimport { type Wallet as InternalWallet } from \"@internal/wallet/model/Wallet\";\nimport { type WalletBuilder } from \"@internal/wallet/service/WalletBuilder\";\nimport { type WalletSerializer } from \"@internal/wallet/service/WalletSerializer\";\n\nexport type GetWalletAddressDAOutput = WalletAddress;\n\nexport type GetWalletAddressDAInput = {\n readonly checkOnDevice: boolean;\n readonly change: boolean;\n readonly addressIndex: number;\n readonly wallet: ApiWallet;\n readonly walletBuilder: WalletBuilder;\n readonly walletSerializer: WalletSerializer;\n readonly dataStoreService: DataStoreService;\n};\n\nexport type GetWalletAddressDAError =\n | OpenAppDAError\n | CommandErrorResult<BtcErrorCodes>[\"error\"];\n\ntype GetWalletAddressDARequiredInteraction =\n | OpenAppDARequiredInteraction\n | UserInteractionRequired.VerifyAddress;\n\nexport type GetWalletAddressDAIntermediateValue = {\n requiredUserInteraction: GetWalletAddressDARequiredInteraction;\n};\n\nexport type GetWalletAddressDAState = DeviceActionState<\n GetWalletAddressDAOutput,\n GetWalletAddressDAError,\n GetWalletAddressDAIntermediateValue\n>;\n\nexport type GetWalletAddressDAInternalState = {\n readonly error: GetWalletAddressDAError | null;\n readonly wallet: InternalWallet | null;\n readonly walletAddress: WalletAddress | null;\n};\n\nexport type GetWalletAddressDAReturnType = ExecuteDeviceActionReturnType<\n GetWalletAddressDAOutput,\n GetWalletAddressDAError,\n GetWalletAddressDAIntermediateValue\n>;\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["GetWalletAddressDeviceActionTypes_exports", "__toCommonJS"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var S=(o,t)=>{for(var p in t)s(o,p,{get:t[p],enumerable:!0})},g=(o,t,p,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of x(t))!D.call(o,a)&&a!==p&&s(o,a,{get:()=>t[a],enumerable:!(n=m(t,a))||n.enumerable});return o},r=(o,t,p)=>(g(o,t,"default"),p&&g(p,t,"default"));var l=o=>g(s({},"__esModule",{value:!0}),o);var e={};S(e,{DefaultDescriptorTemplate:()=>i.DefaultDescriptorTemplate,DefaultWallet:()=>i.DefaultWallet,SignerBtcBuilder:()=>f.SignerBtcBuilder});module.exports=l(e);var f=require("./SignerBtcBuilder");r(e,require("./app-binder/GetExtendedPublicKeyDeviceActionTypes"),module.exports);r(e,require("./app-binder/SignPsbtDeviceActionTypes"),module.exports);r(e,require("./app-binder/SignTransactionDeviceActionTypes"),module.exports);var i=require("./model/Wallet");r(e,require("./SignerBtc"),module.exports);r(e,require("./SignerBtcBuilder"),module.exports);0&&(module.exports={DefaultDescriptorTemplate,DefaultWallet,SignerBtcBuilder,...require("./app-binder/GetExtendedPublicKeyDeviceActionTypes"),...require("./app-binder/SignPsbtDeviceActionTypes"),...require("./app-binder/SignTransactionDeviceActionTypes"),...require("./SignerBtc"),...require("./SignerBtcBuilder")});
1
+ "use strict";var l=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var D=(t,e)=>{for(var p in e)l(t,p,{get:e[p],enumerable:!0})},x=(t,e,p,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let f of u(e))!B.call(t,f)&&f!==p&&l(t,f,{get:()=>e[f],enumerable:!(a=c(e,f))||a.enumerable});return t},o=(t,e,p)=>(x(t,e,"default"),p&&x(p,e,"default"));var g=t=>x(l({},"__esModule",{value:!0}),t);var r={};D(r,{DefaultDescriptorTemplate:()=>m.DefaultDescriptorTemplate,DefaultWallet:()=>m.DefaultWallet,SignerBtcBuilder:()=>i.SignerBtcBuilder});module.exports=g(r);var i=require("./SignerBtcBuilder");o(r,require("./app-binder/GetExtendedPublicKeyDeviceActionTypes"),module.exports);o(r,require("./app-binder/GetWalletAddressDeviceActionTypes"),module.exports);o(r,require("./app-binder/SignMessageDeviceActionTypes"),module.exports);o(r,require("./app-binder/SignPsbtDeviceActionTypes"),module.exports);o(r,require("./app-binder/SignTransactionDeviceActionTypes"),module.exports);var m=require("./model/Wallet");o(r,require("./SignerBtc"),module.exports);o(r,require("./SignerBtcBuilder"),module.exports);0&&(module.exports={DefaultDescriptorTemplate,DefaultWallet,SignerBtcBuilder,...require("./app-binder/GetExtendedPublicKeyDeviceActionTypes"),...require("./app-binder/GetWalletAddressDeviceActionTypes"),...require("./app-binder/SignMessageDeviceActionTypes"),...require("./app-binder/SignPsbtDeviceActionTypes"),...require("./app-binder/SignTransactionDeviceActionTypes"),...require("./SignerBtc"),...require("./SignerBtcBuilder")});
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/api/index.ts"],
4
- "sourcesContent": ["export { type SignerBtc } from \"./SignerBtc\";\nexport { SignerBtcBuilder } from \"./SignerBtcBuilder\";\nexport * from \"@api/app-binder/GetExtendedPublicKeyDeviceActionTypes\";\nexport type {\n SignMessageDAError,\n SignMessageDAInput,\n SignMessageDAIntermediateValue,\n SignMessageDAOutput,\n SignMessageDAState,\n} from \"@api/app-binder/SignMessageDeviceActionTypes\";\nexport * from \"@api/app-binder/SignPsbtDeviceActionTypes\";\nexport * from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nexport { DefaultDescriptorTemplate, DefaultWallet } from \"@api/model/Wallet\";\nexport * from \"@api/SignerBtc\";\nexport * from \"@api/SignerBtcBuilder\";\n"],
5
- "mappings": "2dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sJAAAE,EAAAF,GACA,IAAAG,EAAiC,8BACjCC,EAAAJ,EAAc,iEAFd,gBAUAI,EAAAJ,EAAc,qDAVd,gBAWAI,EAAAJ,EAAc,4DAXd,gBAYA,IAAAK,EAAyD,6BACzDD,EAAAJ,EAAc,0BAbd,gBAcAI,EAAAJ,EAAc,iCAdd",
4
+ "sourcesContent": ["export { type SignerBtc } from \"./SignerBtc\";\nexport { SignerBtcBuilder } from \"./SignerBtcBuilder\";\nexport * from \"@api/app-binder/GetExtendedPublicKeyDeviceActionTypes\";\nexport * from \"@api/app-binder/GetWalletAddressDeviceActionTypes\";\nexport * from \"@api/app-binder/SignMessageDeviceActionTypes\";\nexport * from \"@api/app-binder/SignPsbtDeviceActionTypes\";\nexport * from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nexport { DefaultDescriptorTemplate, DefaultWallet } from \"@api/model/Wallet\";\nexport * from \"@api/SignerBtc\";\nexport * from \"@api/SignerBtcBuilder\";\n"],
5
+ "mappings": "2dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sJAAAE,EAAAF,GACA,IAAAG,EAAiC,8BACjCC,EAAAJ,EAAc,iEAFd,gBAGAI,EAAAJ,EAAc,6DAHd,gBAIAI,EAAAJ,EAAc,wDAJd,gBAKAI,EAAAJ,EAAc,qDALd,gBAMAI,EAAAJ,EAAc,4DANd,gBAOA,IAAAK,EAAyD,6BACzDD,EAAAJ,EAAc,0BARd,gBASAI,EAAAJ,EAAc,iCATd",
6
6
  "names": ["api_exports", "__export", "__toCommonJS", "import_SignerBtcBuilder", "__reExport", "import_Wallet"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var o=(e,t)=>{for(var r in t)s(e,r,{get:t[r],enumerable:!0})},u=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of n(t))!a.call(e,l)&&l!==r&&s(e,l,{get:()=>t[l],enumerable:!(i=p(t,l))||i.enumerable});return e};var b=e=>u(s({},"__esModule",{value:!0}),e);var E={};o(E,{DefaultDescriptorTemplate:()=>c,DefaultWallet:()=>g,RegisteredWallet:()=>W,WalletPolicy:()=>h});module.exports=b(E);var c=(l=>(l.LEGACY="pkh(@0/**)",l.NESTED_SEGWIT="sh(wpkh(@0/**))",l.NATIVE_SEGWIT="wpkh(@0/**)",l.TAPROOT="tr(@0/**)",l))(c||{});class g{constructor(t,r){this.derivationPath=t;this.template=r}}class W{constructor(t,r,i,l){this.name=t;this.descriptorTemplate=r;this.keys=i;this.hmac=l}}class h{constructor(t,r,i){this.name=t;this.descriptorTemplate=r;this.keys=i}}0&&(module.exports={DefaultDescriptorTemplate,DefaultWallet,RegisteredWallet,WalletPolicy});
1
+ "use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var o=(l,t)=>{for(var r in t)i(l,r,{get:t[r],enumerable:!0})},u=(l,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of a(t))!n.call(l,e)&&e!==r&&i(l,e,{get:()=>t[e],enumerable:!(s=p(t,e))||s.enumerable});return l};var g=l=>u(i({},"__esModule",{value:!0}),l);var h={};o(h,{DefaultDescriptorTemplate:()=>c,DefaultWallet:()=>b,RegisteredWallet:()=>d,WalletPolicy:()=>W});module.exports=g(h);var c=(e=>(e.LEGACY="pkh(@0/**)",e.NESTED_SEGWIT="sh(wpkh(@0/**))",e.NATIVE_SEGWIT="wpkh(@0/**)",e.TAPROOT="tr(@0/**)",e))(c||{});class b{constructor(t,r){this.derivationPath=t;this.template=r}}class d{constructor(t,r,s,e){this.name=t;this.descriptorTemplate=r;this.keys=s;this.hmac=e}}class W{constructor(t,r,s){this.name=t;this.descriptorTemplate=r;this.keys=s}}0&&(module.exports={DefaultDescriptorTemplate,DefaultWallet,RegisteredWallet,WalletPolicy});
2
2
  //# sourceMappingURL=Wallet.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/api/model/Wallet.ts"],
4
- "sourcesContent": ["export enum DefaultDescriptorTemplate {\n LEGACY = \"pkh(@0/**)\",\n NESTED_SEGWIT = \"sh(wpkh(@0/**))\",\n NATIVE_SEGWIT = \"wpkh(@0/**)\",\n TAPROOT = \"tr(@0/**)\",\n}\n\n/**\n * Default wallets that can be used without registration in the device.\n */\nexport class DefaultWallet {\n constructor(\n // Derivation path without master key respresentation.\n // Format example: /44'/0'/0'\n public derivationPath: string,\n public template: DefaultDescriptorTemplate,\n ) {}\n}\n\n/**\n * Custom wallet registered in the device.\n * It must be stored on client side after registration for further usages.\n */\nexport class RegisteredWallet {\n constructor(\n public name: string,\n public descriptorTemplate: string,\n public keys: string[],\n public hmac: Uint8Array,\n ) {}\n}\n\n/**\n * The Bitcon hardware app uses a descriptors-like thing to describe\n * how to construct output scripts from keys. A \"Wallet Policy\" consists\n * of a \"Descriptor Template\" and a list of \"keys\". A key is basically\n * a serialized BIP32 extended public key with some added derivation path\n * information. This is documented at\n * https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/wallet.md\n */\nexport class WalletPolicy {\n constructor(\n public name: string,\n public descriptorTemplate: string,\n public keys: string[],\n ) {}\n}\n\nexport type Wallet = DefaultWallet | RegisteredWallet;\n"],
4
+ "sourcesContent": ["export enum DefaultDescriptorTemplate {\n LEGACY = \"pkh(@0/**)\",\n NESTED_SEGWIT = \"sh(wpkh(@0/**))\",\n NATIVE_SEGWIT = \"wpkh(@0/**)\",\n TAPROOT = \"tr(@0/**)\",\n}\n\n/**\n * Default wallets that can be used without registration in the device.\n */\nexport class DefaultWallet {\n constructor(\n // Derivation path without master key respresentation.\n // Format example: /44'/0'/0'\n public derivationPath: string,\n public template: DefaultDescriptorTemplate,\n ) {}\n}\n\n/**\n * Custom wallet registered in the device.\n * It must be stored on client side after registration for further usages.\n */\nexport class RegisteredWallet {\n constructor(\n public name: string,\n public descriptorTemplate: string,\n public keys: string[],\n public hmac: Uint8Array,\n ) {}\n}\n\n/**\n * The Bitcon hardware app uses a descriptors-like thing to describe\n * how to construct output scripts from keys. A \"Wallet Policy\" consists\n * of a \"Descriptor Template\" and a list of \"keys\". A key is basically\n * a serialized BIP32 extended public key with some added derivation path\n * information. This is documented at\n * https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/wallet.md\n */\nexport class WalletPolicy {\n constructor(\n public name: string,\n public descriptorTemplate: string,\n public keys: string[],\n ) {}\n}\n\nexport type Wallet = DefaultWallet | RegisteredWallet;\n\nexport type WalletAddress = {\n address: string;\n};\n"],
5
5
  "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,kBAAAC,EAAA,qBAAAC,EAAA,iBAAAC,IAAA,eAAAC,EAAAN,GAAO,IAAKE,OACVA,EAAA,OAAS,aACTA,EAAA,cAAgB,kBAChBA,EAAA,cAAgB,cAChBA,EAAA,QAAU,YAJAA,OAAA,IAUL,MAAMC,CAAc,CACzB,YAGSI,EACAC,EACP,CAFO,oBAAAD,EACA,cAAAC,CACN,CACL,CAMO,MAAMJ,CAAiB,CAC5B,YACSK,EACAC,EACAC,EACAC,EACP,CAJO,UAAAH,EACA,wBAAAC,EACA,UAAAC,EACA,UAAAC,CACN,CACL,CAUO,MAAMP,CAAa,CACxB,YACSI,EACAC,EACAC,EACP,CAHO,UAAAF,EACA,wBAAAC,EACA,UAAAC,CACN,CACL",
6
6
  "names": ["Wallet_exports", "__export", "DefaultDescriptorTemplate", "DefaultWallet", "RegisteredWallet", "WalletPolicy", "__toCommonJS", "derivationPath", "template", "name", "descriptorTemplate", "keys", "hmac"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";var c=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var b=(o,e,l,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p(e))!s.call(o,n)&&n!==l&&c(o,n,{get:()=>e[n],enumerable:!(a=t(e,n))||a.enumerable});return o};var d=o=>b(c({},"__esModule",{value:!0}),o);var h={};module.exports=d(h);
2
+ //# sourceMappingURL=WalletAddressOptions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/api/model/WalletAddressOptions.ts"],
4
+ "sourcesContent": ["export type WalletAddressOptions = {\n checkOnDevice?: boolean;\n change?: boolean;\n};\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["WalletAddressOptions_exports", "__toCommonJS"]
7
+ }
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var m=(s,e)=>{for(var t in e)r(s,t,{get:e[t],enumerable:!0})},u=(s,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p(e))!c.call(s,n)&&n!==t&&r(s,n,{get:()=>e[n],enumerable:!(o=g(e,n))||o.enumerable});return s};var y=s=>u(r({},"__esModule",{value:!0}),s);var S={};m(S,{DefaultSignerBtc:()=>C});module.exports=y(S);var i=require("./use-cases/di/useCasesTypes"),a=require("./di");class C{_container;constructor({dmk:e,sessionId:t}){this._container=(0,a.makeContainer)({dmk:e,sessionId:t})}signPsbt(e,t){return this._container.get(i.useCasesTypes.SignPsbtUseCase).execute(e,t)}getExtendedPublicKey(e,{checkOnDevice:t=!1}){return this._container.get(i.useCasesTypes.GetExtendedPublicKeyUseCase).execute(e,{checkOnDevice:t})}signMessage(e,t){return this._container.get(i.useCasesTypes.SignMessageUseCase).execute(e,t)}signTransaction(e,t){return this._container.get(i.useCasesTypes.SignTransactionUseCase).execute(e,t)}}0&&(module.exports={DefaultSignerBtc});
1
+ "use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var c=(s,e)=>{for(var t in e)a(s,t,{get:e[t],enumerable:!0})},l=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of g(e))!m.call(s,r)&&r!==t&&a(s,r,{get:()=>e[r],enumerable:!(i=p(e,r))||i.enumerable});return s};var d=s=>l(a({},"__esModule",{value:!0}),s);var y={};c(y,{DefaultSignerBtc:()=>u});module.exports=d(y);var n=require("./use-cases/di/useCasesTypes"),o=require("./di");class u{_container;constructor({dmk:e,sessionId:t}){this._container=(0,o.makeContainer)({dmk:e,sessionId:t})}getWalletAddress(e,t,{checkOnDevice:i=!1,change:r=!1}){return this._container.get(n.useCasesTypes.GetWalletAddressUseCase).execute(i,e,r,t)}signPsbt(e,t){return this._container.get(n.useCasesTypes.SignPsbtUseCase).execute(e,t)}getExtendedPublicKey(e,{checkOnDevice:t=!1}){return this._container.get(n.useCasesTypes.GetExtendedPublicKeyUseCase).execute(e,{checkOnDevice:t})}signMessage(e,t){return this._container.get(n.useCasesTypes.SignMessageUseCase).execute(e,t)}signTransaction(e,t){return this._container.get(n.useCasesTypes.SignTransactionUseCase).execute(e,t)}}0&&(module.exports={DefaultSignerBtc});
2
2
  //# sourceMappingURL=DefaultSignerBtc.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/internal/DefaultSignerBtc.ts"],
4
- "sourcesContent": ["import {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Container } from \"inversify\";\n\nimport { type SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOptions\";\nimport { type Psbt } from \"@api/model/Psbt\";\nimport { type Wallet } from \"@api/model/Wallet\";\nimport { type SignerBtc } from \"@api/SignerBtc\";\nimport { useCasesTypes } from \"@internal/use-cases/di/useCasesTypes\";\nimport { type GetExtendedPublicKeyUseCase } from \"@internal/use-cases/get-extended-public-key/GetExtendedPublicKeyUseCase\";\nimport { type SignPsbtUseCase } from \"@internal/use-cases/sign-psbt/SignPsbtUseCase\";\nimport { type SignTransactionUseCase } from \"@internal/use-cases/sign-transaction/SignTransactionUseCase\";\n\nimport { type SignMessageUseCase } from \"./use-cases/sign-message/SignMessageUseCase\";\nimport { makeContainer } from \"./di\";\n\ntype DefaultSignerBtcConstructorArgs = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n};\n\nexport class DefaultSignerBtc implements SignerBtc {\n private readonly _container: Container;\n\n constructor({ dmk, sessionId }: DefaultSignerBtcConstructorArgs) {\n this._container = makeContainer({ dmk, sessionId });\n }\n\n signPsbt(wallet: Wallet, psbt: Psbt) {\n return this._container\n .get<SignPsbtUseCase>(useCasesTypes.SignPsbtUseCase)\n .execute(wallet, psbt);\n }\n\n getExtendedPublicKey(\n derivationPath: string,\n { checkOnDevice = false }: AddressOptions,\n ) {\n return this._container\n .get<GetExtendedPublicKeyUseCase>(\n useCasesTypes.GetExtendedPublicKeyUseCase,\n )\n .execute(derivationPath, { checkOnDevice });\n }\n\n signMessage(\n _derivationPath: string,\n _message: string,\n ): SignMessageDAReturnType {\n return this._container\n .get<SignMessageUseCase>(useCasesTypes.SignMessageUseCase)\n .execute(_derivationPath, _message);\n }\n\n signTransaction(wallet: Wallet, psbt: Psbt) {\n return this._container\n .get<SignTransactionUseCase>(useCasesTypes.SignTransactionUseCase)\n .execute(wallet, psbt);\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAWA,IAAAI,EAA8B,gDAM9BC,EAA8B,gBAOvB,MAAMH,CAAsC,CAChC,WAEjB,YAAY,CAAE,IAAAI,EAAK,UAAAC,CAAU,EAAoC,CAC/D,KAAK,cAAa,iBAAc,CAAE,IAAAD,EAAK,UAAAC,CAAU,CAAC,CACpD,CAEA,SAASC,EAAgBC,EAAY,CACnC,OAAO,KAAK,WACT,IAAqB,gBAAc,eAAe,EAClD,QAAQD,EAAQC,CAAI,CACzB,CAEA,qBACEC,EACA,CAAE,cAAAC,EAAgB,EAAM,EACxB,CACA,OAAO,KAAK,WACT,IACC,gBAAc,2BAChB,EACC,QAAQD,EAAgB,CAAE,cAAAC,CAAc,CAAC,CAC9C,CAEA,YACEC,EACAC,EACyB,CACzB,OAAO,KAAK,WACT,IAAwB,gBAAc,kBAAkB,EACxD,QAAQD,EAAiBC,CAAQ,CACtC,CAEA,gBAAgBL,EAAgBC,EAAY,CAC1C,OAAO,KAAK,WACT,IAA4B,gBAAc,sBAAsB,EAChE,QAAQD,EAAQC,CAAI,CACzB,CACF",
6
- "names": ["DefaultSignerBtc_exports", "__export", "DefaultSignerBtc", "__toCommonJS", "import_useCasesTypes", "import_di", "dmk", "sessionId", "wallet", "psbt", "derivationPath", "checkOnDevice", "_derivationPath", "_message"]
4
+ "sourcesContent": ["import {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Container } from \"inversify\";\n\nimport { type SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOptions\";\nimport { type Psbt } from \"@api/model/Psbt\";\nimport { type Wallet } from \"@api/model/Wallet\";\nimport { type WalletAddressOptions } from \"@api/model/WalletAddressOptions\";\nimport { type SignerBtc } from \"@api/SignerBtc\";\nimport { useCasesTypes } from \"@internal/use-cases/di/useCasesTypes\";\nimport { type GetExtendedPublicKeyUseCase } from \"@internal/use-cases/get-extended-public-key/GetExtendedPublicKeyUseCase\";\nimport { type SignPsbtUseCase } from \"@internal/use-cases/sign-psbt/SignPsbtUseCase\";\nimport { type SignTransactionUseCase } from \"@internal/use-cases/sign-transaction/SignTransactionUseCase\";\n\nimport { type GetWalletAddressUseCase } from \"./use-cases/get-wallet-address/GetWalletAddressUseCase\";\nimport { type SignMessageUseCase } from \"./use-cases/sign-message/SignMessageUseCase\";\nimport { makeContainer } from \"./di\";\n\ntype DefaultSignerBtcConstructorArgs = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n};\n\nexport class DefaultSignerBtc implements SignerBtc {\n private readonly _container: Container;\n\n constructor({ dmk, sessionId }: DefaultSignerBtcConstructorArgs) {\n this._container = makeContainer({ dmk, sessionId });\n }\n\n getWalletAddress(\n wallet: Wallet,\n addressIndex: number,\n { checkOnDevice = false, change = false }: WalletAddressOptions,\n ) {\n return this._container\n .get<GetWalletAddressUseCase>(useCasesTypes.GetWalletAddressUseCase)\n .execute(checkOnDevice, wallet, change, addressIndex);\n }\n\n signPsbt(wallet: Wallet, psbt: Psbt) {\n return this._container\n .get<SignPsbtUseCase>(useCasesTypes.SignPsbtUseCase)\n .execute(wallet, psbt);\n }\n\n getExtendedPublicKey(\n derivationPath: string,\n { checkOnDevice = false }: AddressOptions,\n ) {\n return this._container\n .get<GetExtendedPublicKeyUseCase>(\n useCasesTypes.GetExtendedPublicKeyUseCase,\n )\n .execute(derivationPath, { checkOnDevice });\n }\n\n signMessage(\n derivationPath: string,\n message: string,\n ): SignMessageDAReturnType {\n return this._container\n .get<SignMessageUseCase>(useCasesTypes.SignMessageUseCase)\n .execute(derivationPath, message);\n }\n\n signTransaction(wallet: Wallet, psbt: Psbt) {\n return this._container\n .get<SignTransactionUseCase>(useCasesTypes.SignTransactionUseCase)\n .execute(wallet, psbt);\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAYA,IAAAI,EAA8B,gDAO9BC,EAA8B,gBAOvB,MAAMH,CAAsC,CAChC,WAEjB,YAAY,CAAE,IAAAI,EAAK,UAAAC,CAAU,EAAoC,CAC/D,KAAK,cAAa,iBAAc,CAAE,IAAAD,EAAK,UAAAC,CAAU,CAAC,CACpD,CAEA,iBACEC,EACAC,EACA,CAAE,cAAAC,EAAgB,GAAO,OAAAC,EAAS,EAAM,EACxC,CACA,OAAO,KAAK,WACT,IAA6B,gBAAc,uBAAuB,EAClE,QAAQD,EAAeF,EAAQG,EAAQF,CAAY,CACxD,CAEA,SAASD,EAAgBI,EAAY,CACnC,OAAO,KAAK,WACT,IAAqB,gBAAc,eAAe,EAClD,QAAQJ,EAAQI,CAAI,CACzB,CAEA,qBACEC,EACA,CAAE,cAAAH,EAAgB,EAAM,EACxB,CACA,OAAO,KAAK,WACT,IACC,gBAAc,2BAChB,EACC,QAAQG,EAAgB,CAAE,cAAAH,CAAc,CAAC,CAC9C,CAEA,YACEG,EACAC,EACyB,CACzB,OAAO,KAAK,WACT,IAAwB,gBAAc,kBAAkB,EACxD,QAAQD,EAAgBC,CAAO,CACpC,CAEA,gBAAgBN,EAAgBI,EAAY,CAC1C,OAAO,KAAK,WACT,IAA4B,gBAAc,sBAAsB,EAChE,QAAQJ,EAAQI,CAAI,CACzB,CACF",
6
+ "names": ["DefaultSignerBtc_exports", "__export", "DefaultSignerBtc", "__toCommonJS", "import_useCasesTypes", "import_di", "dmk", "sessionId", "wallet", "addressIndex", "checkOnDevice", "change", "psbt", "derivationPath", "message"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var d=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var A=(i,e)=>{for(var r in e)d(i,r,{get:e[r],enumerable:!0})},g=(i,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of h(e))!f.call(i,t)&&t!==r&&d(i,t,{get:()=>e[t],enumerable:!(a=S(e,t))||a.enumerable});return i};var I=i=>g(d({},"__esModule",{value:!0}),i),b=(i,e,r,a)=>{for(var t=a>1?void 0:a?S(e,r):e,p=i.length-1,c;p>=0;p--)(c=i[p])&&(t=(a?c(e,r,t):c(t))||t);return a&&t&&d(e,r,t),t},n=(i,e)=>(r,a)=>e(r,a,i);var T={};A(T,{BtcAppBinder:()=>l});module.exports=I(T);var o=require("@ledgerhq/device-management-kit"),s=require("inversify"),y=require("../app-binder/command/GetExtendedPublicKeyCommand"),P=require("../app-binder/device-action/SignPsbt/SignPsbtDeviceAction"),D=require("../app-binder/device-action/SignTransaction/SignTransactionDeviceAction"),_=require("../data-store/di/dataStoreTypes"),m=require("../externalTypes"),u=require("../psbt/di/psbtTypes"),v=require("../wallet/di/walletTypes"),w=require("./device-action/SignMessage/SignMessageDeviceAction");let l=class{constructor(e,r,a,t,p,c,M){this._dmk=e;this._sessionId=r;this._walletBuilder=a;this._walletSerializer=t;this._dataStoreService=p;this._psbtMapper=c;this._valueParser=M}getExtendedPublicKey(e){return this._dmk.executeDeviceAction({sessionId:this._sessionId,deviceAction:new o.SendCommandInAppDeviceAction({input:{command:new y.GetExtendedPublicKeyCommand(e),appName:"Bitcoin",requiredUserInteraction:e.checkOnDevice?o.UserInteractionRequired.VerifyAddress:o.UserInteractionRequired.None}})})}signMessage(e){return this._dmk.executeDeviceAction({sessionId:this._sessionId,deviceAction:new w.SignMessageDeviceAction({input:{derivationPath:e.derivationPath,message:e.message,dataStoreService:this._dataStoreService}})})}signPsbt(e){return this._dmk.executeDeviceAction({sessionId:this._sessionId,deviceAction:new P.SignPsbtDeviceAction({input:{psbt:e.psbt,wallet:e.wallet,walletBuilder:this._walletBuilder,walletSerializer:this._walletSerializer,dataStoreService:this._dataStoreService,psbtMapper:this._psbtMapper,valueParser:this._valueParser}})})}signTransaction(e){return this._dmk.executeDeviceAction({sessionId:this._sessionId,deviceAction:new D.SignTransactionDeviceAction({input:{psbt:e.psbt,wallet:e.wallet,walletBuilder:this._walletBuilder,walletSerializer:this._walletSerializer,dataStoreService:this._dataStoreService,psbtMapper:this._psbtMapper,valueParser:this._valueParser}})})}};l=b([(0,s.injectable)(),n(0,(0,s.inject)(m.externalTypes.Dmk)),n(1,(0,s.inject)(m.externalTypes.SessionId)),n(2,(0,s.inject)(v.walletTypes.WalletBuilder)),n(3,(0,s.inject)(v.walletTypes.WalletSerializer)),n(4,(0,s.inject)(_.dataStoreTypes.DataStoreService)),n(5,(0,s.inject)(u.psbtTypes.PsbtMapper)),n(6,(0,s.inject)(u.psbtTypes.ValueParser))],l);0&&(module.exports={BtcAppBinder});
1
+ "use strict";var c=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var I=(i,e)=>{for(var r in e)c(i,r,{get:e[r],enumerable:!0})},g=(i,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of P(e))!f.call(i,t)&&t!==r&&c(i,t,{get:()=>e[t],enumerable:!(a=S(e,t))||a.enumerable});return i};var T=i=>g(c({},"__esModule",{value:!0}),i),b=(i,e,r,a)=>{for(var t=a>1?void 0:a?S(e,r):e,d=i.length-1,p;d>=0;d--)(p=i[d])&&(t=(a?p(e,r,t):p(t))||t);return a&&t&&c(e,r,t),t},l=(i,e)=>(r,a)=>e(r,a,i);var x={};I(x,{BtcAppBinder:()=>n});module.exports=T(x);var o=require("@ledgerhq/device-management-kit"),s=require("inversify"),D=require("../app-binder/command/GetExtendedPublicKeyCommand"),h=require("../app-binder/device-action/SignPsbt/SignPsbtDeviceAction"),y=require("../app-binder/device-action/SignTransaction/SignTransactionDeviceAction"),w=require("../data-store/di/dataStoreTypes"),m=require("../externalTypes"),u=require("../psbt/di/psbtTypes"),v=require("../wallet/di/walletTypes"),_=require("./device-action/GetWalletAddress/GetWalletAddressDeviceAction"),A=require("./device-action/SignMessage/SignMessageDeviceAction");let n=class{constructor(e,r,a,t,d,p,W){this._dmk=e;this._sessionId=r;this._walletBuilder=a;this._walletSerializer=t;this._dataStoreService=d;this._psbtMapper=p;this._valueParser=W}getExtendedPublicKey(e){return this._dmk.executeDeviceAction({sessionId:this._sessionId,deviceAction:new o.SendCommandInAppDeviceAction({input:{command:new D.GetExtendedPublicKeyCommand(e),appName:"Bitcoin",requiredUserInteraction:e.checkOnDevice?o.UserInteractionRequired.VerifyAddress:o.UserInteractionRequired.None}})})}signMessage(e){return this._dmk.executeDeviceAction({sessionId:this._sessionId,deviceAction:new A.SignMessageDeviceAction({input:{derivationPath:e.derivationPath,message:e.message,dataStoreService:this._dataStoreService}})})}signPsbt(e){return this._dmk.executeDeviceAction({sessionId:this._sessionId,deviceAction:new h.SignPsbtDeviceAction({input:{psbt:e.psbt,wallet:e.wallet,walletBuilder:this._walletBuilder,walletSerializer:this._walletSerializer,dataStoreService:this._dataStoreService,psbtMapper:this._psbtMapper,valueParser:this._valueParser}})})}getWalletAddress(e){return this._dmk.executeDeviceAction({sessionId:this._sessionId,deviceAction:new _.GetWalletAddressDeviceAction({input:{wallet:e.wallet,checkOnDevice:e.checkOnDevice,change:e.change,addressIndex:e.addressIndex,walletBuilder:this._walletBuilder,walletSerializer:this._walletSerializer,dataStoreService:this._dataStoreService}})})}signTransaction(e){return this._dmk.executeDeviceAction({sessionId:this._sessionId,deviceAction:new y.SignTransactionDeviceAction({input:{psbt:e.psbt,wallet:e.wallet,walletBuilder:this._walletBuilder,walletSerializer:this._walletSerializer,dataStoreService:this._dataStoreService,psbtMapper:this._psbtMapper,valueParser:this._valueParser}})})}};n=b([(0,s.injectable)(),l(0,(0,s.inject)(m.externalTypes.Dmk)),l(1,(0,s.inject)(m.externalTypes.SessionId)),l(2,(0,s.inject)(v.walletTypes.WalletBuilder)),l(3,(0,s.inject)(v.walletTypes.WalletSerializer)),l(4,(0,s.inject)(w.dataStoreTypes.DataStoreService)),l(5,(0,s.inject)(u.psbtTypes.PsbtMapper)),l(6,(0,s.inject)(u.psbtTypes.ValueParser))],n);0&&(module.exports={BtcAppBinder});
2
2
  //# sourceMappingURL=BtcAppBinder.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/internal/app-binder/BtcAppBinder.ts"],
4
- "sourcesContent": ["import {\n DeviceManagementKit,\n type DeviceSessionId,\n SendCommandInAppDeviceAction,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport {\n GetExtendedPublicKeyDAInput,\n GetExtendedPublicKeyDAReturnType,\n} from \"@api/app-binder/GetExtendedPublicKeyDeviceActionTypes\";\nimport { SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { SignPsbtDAReturnType } from \"@api/app-binder/SignPsbtDeviceActionTypes\";\nimport { SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { Psbt } from \"@api/model/Psbt\";\nimport { Wallet } from \"@api/model/Wallet\";\nimport { GetExtendedPublicKeyCommand } from \"@internal/app-binder/command/GetExtendedPublicKeyCommand\";\nimport { SignPsbtDeviceAction } from \"@internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction\";\nimport { SignTransactionDeviceAction } from \"@internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction\";\nimport { dataStoreTypes } from \"@internal/data-store/di/dataStoreTypes\";\nimport type { DataStoreService } from \"@internal/data-store/service/DataStoreService\";\nimport { externalTypes } from \"@internal/externalTypes\";\nimport { psbtTypes } from \"@internal/psbt/di/psbtTypes\";\nimport type { PsbtMapper } from \"@internal/psbt/service/psbt/PsbtMapper\";\nimport type { ValueParser } from \"@internal/psbt/service/value/ValueParser\";\nimport { walletTypes } from \"@internal/wallet/di/walletTypes\";\nimport type { WalletBuilder } from \"@internal/wallet/service/WalletBuilder\";\nimport type { WalletSerializer } from \"@internal/wallet/service/WalletSerializer\";\n\nimport { SignMessageDeviceAction } from \"./device-action/SignMessage/SignMessageDeviceAction\";\n\n@injectable()\nexport class BtcAppBinder {\n constructor(\n @inject(externalTypes.Dmk)\n private readonly _dmk: DeviceManagementKit,\n @inject(externalTypes.SessionId)\n private readonly _sessionId: DeviceSessionId,\n @inject(walletTypes.WalletBuilder)\n private readonly _walletBuilder: WalletBuilder,\n @inject(walletTypes.WalletSerializer)\n private readonly _walletSerializer: WalletSerializer,\n @inject(dataStoreTypes.DataStoreService)\n private readonly _dataStoreService: DataStoreService,\n @inject(psbtTypes.PsbtMapper)\n private readonly _psbtMapper: PsbtMapper,\n @inject(psbtTypes.ValueParser)\n private readonly _valueParser: ValueParser,\n ) {}\n\n getExtendedPublicKey(\n args: GetExtendedPublicKeyDAInput,\n ): GetExtendedPublicKeyDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetExtendedPublicKeyCommand(args),\n appName: \"Bitcoin\",\n requiredUserInteraction: args.checkOnDevice\n ? UserInteractionRequired.VerifyAddress\n : UserInteractionRequired.None,\n },\n }),\n });\n }\n\n signMessage(args: {\n derivationPath: string;\n message: string;\n }): SignMessageDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SignMessageDeviceAction({\n input: {\n derivationPath: args.derivationPath,\n message: args.message,\n dataStoreService: this._dataStoreService,\n },\n }),\n });\n }\n\n signPsbt(args: { psbt: Psbt; wallet: Wallet }): SignPsbtDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SignPsbtDeviceAction({\n input: {\n psbt: args.psbt,\n wallet: args.wallet,\n walletBuilder: this._walletBuilder,\n walletSerializer: this._walletSerializer,\n dataStoreService: this._dataStoreService,\n psbtMapper: this._psbtMapper,\n valueParser: this._valueParser,\n },\n }),\n });\n }\n\n signTransaction(args: {\n psbt: Psbt;\n wallet: Wallet;\n }): SignTransactionDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SignTransactionDeviceAction({\n input: {\n psbt: args.psbt,\n wallet: args.wallet,\n walletBuilder: this._walletBuilder,\n walletSerializer: this._walletSerializer,\n dataStoreService: this._dataStoreService,\n psbtMapper: this._psbtMapper,\n valueParser: this._valueParser,\n },\n }),\n });\n }\n}\n"],
5
- "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAKO,2CACPC,EAAmC,qBAWnCC,EAA4C,oEAC5CC,EAAqC,4EACrCC,EAA4C,0FAC5CC,EAA+B,kDAE/BC,EAA8B,mCAC9BC,EAA0B,uCAG1BC,EAA4B,2CAI5BC,EAAwC,+DAGjC,IAAMC,EAAN,KAAmB,CACxB,YAEmBC,EAEAC,EAEAC,EAEAC,EAEAC,EAEAC,EAEAC,EACjB,CAbiB,UAAAN,EAEA,gBAAAC,EAEA,oBAAAC,EAEA,uBAAAC,EAEA,uBAAAC,EAEA,iBAAAC,EAEA,kBAAAC,CAChB,CAEH,qBACEC,EACkC,CAClC,OAAO,KAAK,KAAK,oBAAoB,CACnC,UAAW,KAAK,WAChB,aAAc,IAAI,+BAA6B,CAC7C,MAAO,CACL,QAAS,IAAI,8BAA4BA,CAAI,EAC7C,QAAS,UACT,wBAAyBA,EAAK,cAC1B,0BAAwB,cACxB,0BAAwB,IAC9B,CACF,CAAC,CACH,CAAC,CACH,CAEA,YAAYA,EAGgB,CAC1B,OAAO,KAAK,KAAK,oBAAoB,CACnC,UAAW,KAAK,WAChB,aAAc,IAAI,0BAAwB,CACxC,MAAO,CACL,eAAgBA,EAAK,eACrB,QAASA,EAAK,QACd,iBAAkB,KAAK,iBACzB,CACF,CAAC,CACH,CAAC,CACH,CAEA,SAASA,EAA4D,CACnE,OAAO,KAAK,KAAK,oBAAoB,CACnC,UAAW,KAAK,WAChB,aAAc,IAAI,uBAAqB,CACrC,MAAO,CACL,KAAMA,EAAK,KACX,OAAQA,EAAK,OACb,cAAe,KAAK,eACpB,iBAAkB,KAAK,kBACvB,iBAAkB,KAAK,kBACvB,WAAY,KAAK,YACjB,YAAa,KAAK,YACpB,CACF,CAAC,CACH,CAAC,CACH,CAEA,gBAAgBA,EAGgB,CAC9B,OAAO,KAAK,KAAK,oBAAoB,CACnC,UAAW,KAAK,WAChB,aAAc,IAAI,8BAA4B,CAC5C,MAAO,CACL,KAAMA,EAAK,KACX,OAAQA,EAAK,OACb,cAAe,KAAK,eACpB,iBAAkB,KAAK,kBACvB,iBAAkB,KAAK,kBACvB,WAAY,KAAK,YACjB,YAAa,KAAK,YACpB,CACF,CAAC,CACH,CAAC,CACH,CACF,EAvFaR,EAANS,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,gBAAc,GAAG,GAExBA,EAAA,eAAO,gBAAc,SAAS,GAE9BA,EAAA,eAAO,cAAY,aAAa,GAEhCA,EAAA,eAAO,cAAY,gBAAgB,GAEnCA,EAAA,eAAO,iBAAe,gBAAgB,GAEtCA,EAAA,eAAO,YAAU,UAAU,GAE3BA,EAAA,eAAO,YAAU,WAAW,IAdpBV",
6
- "names": ["BtcAppBinder_exports", "__export", "BtcAppBinder", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_GetExtendedPublicKeyCommand", "import_SignPsbtDeviceAction", "import_SignTransactionDeviceAction", "import_dataStoreTypes", "import_externalTypes", "import_psbtTypes", "import_walletTypes", "import_SignMessageDeviceAction", "BtcAppBinder", "_dmk", "_sessionId", "_walletBuilder", "_walletSerializer", "_dataStoreService", "_psbtMapper", "_valueParser", "args", "__decorateClass", "__decorateParam"]
4
+ "sourcesContent": ["import {\n DeviceManagementKit,\n type DeviceSessionId,\n SendCommandInAppDeviceAction,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport {\n GetExtendedPublicKeyDAInput,\n GetExtendedPublicKeyDAReturnType,\n} from \"@api/app-binder/GetExtendedPublicKeyDeviceActionTypes\";\nimport { SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { SignPsbtDAReturnType } from \"@api/app-binder/SignPsbtDeviceActionTypes\";\nimport { SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { GetWalletAddressDAReturnType } from \"@api/index\";\nimport { Psbt } from \"@api/model/Psbt\";\nimport { Wallet } from \"@api/model/Wallet\";\nimport { GetExtendedPublicKeyCommand } from \"@internal/app-binder/command/GetExtendedPublicKeyCommand\";\nimport { SignPsbtDeviceAction } from \"@internal/app-binder/device-action/SignPsbt/SignPsbtDeviceAction\";\nimport { SignTransactionDeviceAction } from \"@internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction\";\nimport { dataStoreTypes } from \"@internal/data-store/di/dataStoreTypes\";\nimport type { DataStoreService } from \"@internal/data-store/service/DataStoreService\";\nimport { externalTypes } from \"@internal/externalTypes\";\nimport { psbtTypes } from \"@internal/psbt/di/psbtTypes\";\nimport type { PsbtMapper } from \"@internal/psbt/service/psbt/PsbtMapper\";\nimport type { ValueParser } from \"@internal/psbt/service/value/ValueParser\";\nimport { walletTypes } from \"@internal/wallet/di/walletTypes\";\nimport type { WalletBuilder } from \"@internal/wallet/service/WalletBuilder\";\nimport type { WalletSerializer } from \"@internal/wallet/service/WalletSerializer\";\n\nimport { GetWalletAddressDeviceAction } from \"./device-action/GetWalletAddress/GetWalletAddressDeviceAction\";\nimport { SignMessageDeviceAction } from \"./device-action/SignMessage/SignMessageDeviceAction\";\n\n@injectable()\nexport class BtcAppBinder {\n constructor(\n @inject(externalTypes.Dmk)\n private readonly _dmk: DeviceManagementKit,\n @inject(externalTypes.SessionId)\n private readonly _sessionId: DeviceSessionId,\n @inject(walletTypes.WalletBuilder)\n private readonly _walletBuilder: WalletBuilder,\n @inject(walletTypes.WalletSerializer)\n private readonly _walletSerializer: WalletSerializer,\n @inject(dataStoreTypes.DataStoreService)\n private readonly _dataStoreService: DataStoreService,\n @inject(psbtTypes.PsbtMapper)\n private readonly _psbtMapper: PsbtMapper,\n @inject(psbtTypes.ValueParser)\n private readonly _valueParser: ValueParser,\n ) {}\n\n getExtendedPublicKey(\n args: GetExtendedPublicKeyDAInput,\n ): GetExtendedPublicKeyDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetExtendedPublicKeyCommand(args),\n appName: \"Bitcoin\",\n requiredUserInteraction: args.checkOnDevice\n ? UserInteractionRequired.VerifyAddress\n : UserInteractionRequired.None,\n },\n }),\n });\n }\n\n signMessage(args: {\n derivationPath: string;\n message: string;\n }): SignMessageDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SignMessageDeviceAction({\n input: {\n derivationPath: args.derivationPath,\n message: args.message,\n dataStoreService: this._dataStoreService,\n },\n }),\n });\n }\n\n signPsbt(args: { psbt: Psbt; wallet: Wallet }): SignPsbtDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SignPsbtDeviceAction({\n input: {\n psbt: args.psbt,\n wallet: args.wallet,\n walletBuilder: this._walletBuilder,\n walletSerializer: this._walletSerializer,\n dataStoreService: this._dataStoreService,\n psbtMapper: this._psbtMapper,\n valueParser: this._valueParser,\n },\n }),\n });\n }\n\n getWalletAddress(args: {\n checkOnDevice: boolean;\n wallet: Wallet;\n change: boolean;\n addressIndex: number;\n }): GetWalletAddressDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new GetWalletAddressDeviceAction({\n input: {\n wallet: args.wallet,\n checkOnDevice: args.checkOnDevice,\n change: args.change,\n addressIndex: args.addressIndex,\n walletBuilder: this._walletBuilder,\n walletSerializer: this._walletSerializer,\n dataStoreService: this._dataStoreService,\n },\n }),\n });\n }\n\n signTransaction(args: {\n psbt: Psbt;\n wallet: Wallet;\n }): SignTransactionDAReturnType {\n return this._dmk.executeDeviceAction({\n sessionId: this._sessionId,\n deviceAction: new SignTransactionDeviceAction({\n input: {\n psbt: args.psbt,\n wallet: args.wallet,\n walletBuilder: this._walletBuilder,\n walletSerializer: this._walletSerializer,\n dataStoreService: this._dataStoreService,\n psbtMapper: this._psbtMapper,\n valueParser: this._valueParser,\n },\n }),\n });\n }\n}\n"],
5
+ "mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAKO,2CACPC,EAAmC,qBAYnCC,EAA4C,oEAC5CC,EAAqC,4EACrCC,EAA4C,0FAC5CC,EAA+B,kDAE/BC,EAA8B,mCAC9BC,EAA0B,uCAG1BC,EAA4B,2CAI5BC,EAA6C,yEAC7CC,EAAwC,+DAGjC,IAAMC,EAAN,KAAmB,CACxB,YAEmBC,EAEAC,EAEAC,EAEAC,EAEAC,EAEAC,EAEAC,EACjB,CAbiB,UAAAN,EAEA,gBAAAC,EAEA,oBAAAC,EAEA,uBAAAC,EAEA,uBAAAC,EAEA,iBAAAC,EAEA,kBAAAC,CAChB,CAEH,qBACEC,EACkC,CAClC,OAAO,KAAK,KAAK,oBAAoB,CACnC,UAAW,KAAK,WAChB,aAAc,IAAI,+BAA6B,CAC7C,MAAO,CACL,QAAS,IAAI,8BAA4BA,CAAI,EAC7C,QAAS,UACT,wBAAyBA,EAAK,cAC1B,0BAAwB,cACxB,0BAAwB,IAC9B,CACF,CAAC,CACH,CAAC,CACH,CAEA,YAAYA,EAGgB,CAC1B,OAAO,KAAK,KAAK,oBAAoB,CACnC,UAAW,KAAK,WAChB,aAAc,IAAI,0BAAwB,CACxC,MAAO,CACL,eAAgBA,EAAK,eACrB,QAASA,EAAK,QACd,iBAAkB,KAAK,iBACzB,CACF,CAAC,CACH,CAAC,CACH,CAEA,SAASA,EAA4D,CACnE,OAAO,KAAK,KAAK,oBAAoB,CACnC,UAAW,KAAK,WAChB,aAAc,IAAI,uBAAqB,CACrC,MAAO,CACL,KAAMA,EAAK,KACX,OAAQA,EAAK,OACb,cAAe,KAAK,eACpB,iBAAkB,KAAK,kBACvB,iBAAkB,KAAK,kBACvB,WAAY,KAAK,YACjB,YAAa,KAAK,YACpB,CACF,CAAC,CACH,CAAC,CACH,CAEA,iBAAiBA,EAKgB,CAC/B,OAAO,KAAK,KAAK,oBAAoB,CACnC,UAAW,KAAK,WAChB,aAAc,IAAI,+BAA6B,CAC7C,MAAO,CACL,OAAQA,EAAK,OACb,cAAeA,EAAK,cACpB,OAAQA,EAAK,OACb,aAAcA,EAAK,aACnB,cAAe,KAAK,eACpB,iBAAkB,KAAK,kBACvB,iBAAkB,KAAK,iBACzB,CACF,CAAC,CACH,CAAC,CACH,CAEA,gBAAgBA,EAGgB,CAC9B,OAAO,KAAK,KAAK,oBAAoB,CACnC,UAAW,KAAK,WAChB,aAAc,IAAI,8BAA4B,CAC5C,MAAO,CACL,KAAMA,EAAK,KACX,OAAQA,EAAK,OACb,cAAe,KAAK,eACpB,iBAAkB,KAAK,kBACvB,iBAAkB,KAAK,kBACvB,WAAY,KAAK,YACjB,YAAa,KAAK,YACpB,CACF,CAAC,CACH,CAAC,CACH,CACF,EA7GaR,EAANS,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,gBAAc,GAAG,GAExBA,EAAA,eAAO,gBAAc,SAAS,GAE9BA,EAAA,eAAO,cAAY,aAAa,GAEhCA,EAAA,eAAO,cAAY,gBAAgB,GAEnCA,EAAA,eAAO,iBAAe,gBAAgB,GAEtCA,EAAA,eAAO,YAAU,UAAU,GAE3BA,EAAA,eAAO,YAAU,WAAW,IAdpBV",
6
+ "names": ["BtcAppBinder_exports", "__export", "BtcAppBinder", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_GetExtendedPublicKeyCommand", "import_SignPsbtDeviceAction", "import_SignTransactionDeviceAction", "import_dataStoreTypes", "import_externalTypes", "import_psbtTypes", "import_walletTypes", "import_GetWalletAddressDeviceAction", "import_SignMessageDeviceAction", "BtcAppBinder", "_dmk", "_sessionId", "_walletBuilder", "_walletSerializer", "_dataStoreService", "_psbtMapper", "_valueParser", "args", "__decorateClass", "__decorateParam"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@ledgerhq/device-management-kit"),a=require("../../app-binder/command/utils/bitcoinAppErrors"),r=require("./GetExtendedPublicKeyCommand");const s=new Uint8Array([225,0,0,0,14,1,3,128,0,0,84,128,0,0,0,128,0,0,0]),d=new Uint8Array([225,0,0,0,14,0,3,128,0,0,84,128,0,0,0,128,0,0,0]),c=new Uint8Array([225,0,0,0,18,1,4,128,0,0,49,128,0,0,0,128,0,0,0,0,0,0,0]),u=new Uint8Array([120,112,117,98,54,68,57,80,112,52,114,70,118,119,84,71,120,56,56,89,68,52,67,68,97,49,110,66,69,112,99,75,69,90,84,67,78,70,122,67,70,55,103,86,80,122,54,84,104,57,66,97,86,104,104,80,74,68,117,103,57,89,89,70,80,89,109,107,83,72,76,102,82,49,86,81,89,106,53,106,97,121,113,119,83,89,65,82,110,117,66,74,105,80,83,68,97,98,121,121,84,105,67,68,55,66,51,99,106,80,113]);describe("GetExtendedPublicKeyCommand",()=>{let x;const n={checkOnDevice:!0,derivationPath:"84'/0'/0'"};beforeEach(()=>{}),describe("getApdu",()=>{it("should return the correct APDU",()=>{x=new r.GetExtendedPublicKeyCommand(n);const e=x.getApdu();expect(e.getRawApdu()).toEqual(s)}),it("should return the correct APDU without display",()=>{x=new r.GetExtendedPublicKeyCommand({...n,checkOnDevice:!1});const e=x.getApdu();expect(e.getRawApdu()).toEqual(d)}),it("should return the correct APDU with different derivation path",()=>{x=new r.GetExtendedPublicKeyCommand({...n,derivationPath:"49'/0'/0'/0"});const e=x.getApdu();expect(e.getRawApdu()).toEqual(c)})}),describe("parseResponse",()=>{it("should return the extended public key",()=>{x=new r.GetExtendedPublicKeyCommand(n);const e=new t.ApduResponse({data:u,statusCode:new Uint8Array([144,0])}),o=x.parseResponse(e);expect(o).toEqual((0,t.CommandResultFactory)({data:{extendedPublicKey:"xpub6D9Pp4rFvwTGx88YD4CDa1nBEpcKEZTCNFzCF7gVPz6Th9BaVhhPJDug9YYFPYmkSHLfR1VQYj5jayqwSYARnuBJiPSDabyyTiCD7B3cjPq"}}))}),it("should return an error if the response is not successful",()=>{x=new r.GetExtendedPublicKeyCommand(n);const e=new t.ApduResponse({statusCode:Uint8Array.from([109,0]),data:new Uint8Array(0)}),o=x.parseResponse(e);expect(o).toStrictEqual((0,t.CommandResultFactory)({error:(0,a.BtcAppCommandErrorFactory)({...a.BTC_APP_ERRORS["6d00"],errorCode:"6d00"})}))}),it("should return an error if the response is too short",()=>{x=new r.GetExtendedPublicKeyCommand(n);const e=new t.ApduResponse({data:Uint8Array.from([]),statusCode:new Uint8Array([144,0])}),o=x.parseResponse(e);expect(o).toStrictEqual((0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Invalid response length")}))})})});
1
+ "use strict";var t=require("@ledgerhq/device-management-kit"),a=require("../../app-binder/command/utils/bitcoinAppErrors"),r=require("./GetExtendedPublicKeyCommand");const s=new Uint8Array([225,0,0,0,14,1,3,128,0,0,84,128,0,0,0,128,0,0,0]),d=new Uint8Array([225,0,0,0,14,0,3,128,0,0,84,128,0,0,0,128,0,0,0]),c=new Uint8Array([225,0,0,0,18,1,4,128,0,0,49,128,0,0,0,128,0,0,0,0,0,0,0]),u=new Uint8Array([120,112,117,98,54,68,57,80,112,52,114,70,118,119,84,71,120,56,56,89,68,52,67,68,97,49,110,66,69,112,99,75,69,90,84,67,78,70,122,67,70,55,103,86,80,122,54,84,104,57,66,97,86,104,104,80,74,68,117,103,57,89,89,70,80,89,109,107,83,72,76,102,82,49,86,81,89,106,53,106,97,121,113,119,83,89,65,82,110,117,66,74,105,80,83,68,97,98,121,121,84,105,67,68,55,66,51,99,106,80,113]);describe("GetExtendedPublicKeyCommand",()=>{let x;const n={checkOnDevice:!0,derivationPath:"84'/0'/0'"};beforeEach(()=>{}),describe("getApdu",()=>{it("should return the correct APDU",()=>{x=new r.GetExtendedPublicKeyCommand(n);const e=x.getApdu();expect(e.getRawApdu()).toEqual(s)}),it("should return the correct APDU without checkOnDevice",()=>{x=new r.GetExtendedPublicKeyCommand({...n,checkOnDevice:!1});const e=x.getApdu();expect(e.getRawApdu()).toEqual(d)}),it("should return the correct APDU with different derivation path",()=>{x=new r.GetExtendedPublicKeyCommand({...n,derivationPath:"49'/0'/0'/0"});const e=x.getApdu();expect(e.getRawApdu()).toEqual(c)})}),describe("parseResponse",()=>{it("should return the extended public key",()=>{x=new r.GetExtendedPublicKeyCommand(n);const e=new t.ApduResponse({data:u,statusCode:new Uint8Array([144,0])}),o=x.parseResponse(e);expect(o).toEqual((0,t.CommandResultFactory)({data:{extendedPublicKey:"xpub6D9Pp4rFvwTGx88YD4CDa1nBEpcKEZTCNFzCF7gVPz6Th9BaVhhPJDug9YYFPYmkSHLfR1VQYj5jayqwSYARnuBJiPSDabyyTiCD7B3cjPq"}}))}),it("should return an error if the response is not successful",()=>{x=new r.GetExtendedPublicKeyCommand(n);const e=new t.ApduResponse({statusCode:Uint8Array.from([109,0]),data:new Uint8Array(0)}),o=x.parseResponse(e);expect(o).toStrictEqual((0,t.CommandResultFactory)({error:(0,a.BtcAppCommandErrorFactory)({...a.BTC_APP_ERRORS["6d00"],errorCode:"6d00"})}))}),it("should return an error if the response is too short",()=>{x=new r.GetExtendedPublicKeyCommand(n);const e=new t.ApduResponse({data:Uint8Array.from([]),statusCode:new Uint8Array([144,0])}),o=x.parseResponse(e);expect(o).toStrictEqual((0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Invalid response length")}))})})});
2
2
  //# sourceMappingURL=GetExtendedPublicKeyCommand.test.js.map