@siacentral/ledgerjs-sia 1.2.9 → 2.0.1
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 +18 -10
- package/lib/sia.d.ts +57 -26
- package/lib/sia.d.ts.map +1 -1
- package/lib/sia.js +182 -231
- package/lib/sia.js.map +1 -1
- package/package.json +58 -59
package/README.md
CHANGED
|
@@ -13,19 +13,24 @@ Static javascript builds are available on the releases page.
|
|
|
13
13
|
## Package Usage
|
|
14
14
|
```js
|
|
15
15
|
import Sia from '@siacentral/ledgerjs-sia';
|
|
16
|
-
import TransportWebHID from '@ledgerhq/hw-transport-webhid';
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
|
-
* connect connects to the plugged in Ledger
|
|
20
|
-
*
|
|
18
|
+
* connect connects to the plugged in Ledger and returns the first Sia address
|
|
19
|
+
* of the ledger wallet. connectWebHID / connectBLE launch the Sia app from the
|
|
20
|
+
* dashboard if it isn't already open and return a ready instance.
|
|
21
21
|
*/
|
|
22
22
|
async function connect() {
|
|
23
23
|
let sia;
|
|
24
24
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
// supportedTransports reports which transports work in this environment;
|
|
26
|
+
// offer the user a choice between USB (hid) and Bluetooth (ble).
|
|
27
|
+
const transports = await Sia.supportedTransports(); // e.g. ['hid', 'ble']
|
|
28
|
+
|
|
29
|
+
sia = transports.includes('hid')
|
|
30
|
+
? await Sia.connectWebHID()
|
|
31
|
+
: await Sia.connectBLE();
|
|
32
|
+
|
|
33
|
+
const { address } = await sia.getAddress(0);
|
|
29
34
|
console.log(address);
|
|
30
35
|
} catch (ex) {
|
|
31
36
|
// TODO: handle error
|
|
@@ -38,6 +43,10 @@ async function connect() {
|
|
|
38
43
|
connect();
|
|
39
44
|
```
|
|
40
45
|
|
|
46
|
+
A transport may also be supplied directly via `new Sia(transport)` (e.g. a
|
|
47
|
+
Speculos transport for testing), or `Sia.open(createTransport)` to launch the
|
|
48
|
+
app using a custom transport factory.
|
|
49
|
+
|
|
41
50
|
## Static Usage
|
|
42
51
|
```html
|
|
43
52
|
<script type="text/javascript" src="/js/sia.js"></script>
|
|
@@ -48,9 +57,8 @@ connect();
|
|
|
48
57
|
*/
|
|
49
58
|
async function connect() {
|
|
50
59
|
try {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
address = await sia.getAddress(0);
|
|
60
|
+
const sia = await Sia.connectWebHID(),
|
|
61
|
+
{ address } = await sia.getAddress(0);
|
|
54
62
|
|
|
55
63
|
console.log(address);
|
|
56
64
|
} catch (ex) {
|
package/lib/sia.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import type Transport from "@ledgerhq/hw-transport";
|
|
4
2
|
import { Buffer } from 'buffer';
|
|
3
|
+
type TransportFactory = () => Promise<Transport>;
|
|
5
4
|
interface VerifyResponse {
|
|
6
5
|
address: string;
|
|
7
6
|
publicKey: string;
|
|
@@ -16,6 +15,50 @@ interface VerifyResponse {
|
|
|
16
15
|
export default class Sia {
|
|
17
16
|
transport: Transport;
|
|
18
17
|
constructor(transport: Transport, scrambleKey?: string);
|
|
18
|
+
/**
|
|
19
|
+
* open connects a transport, ensures the Sia app is running, and returns a
|
|
20
|
+
* ready Sia instance. If the app is not already open it is launched from the
|
|
21
|
+
* dashboard; the device disconnects and reconnects when an app opens, so the
|
|
22
|
+
* transport is recreated via the provided factory until the app is ready.
|
|
23
|
+
* @param createTransport {TransportFactory} creates a transport, e.g. () => TransportWebHID.create()
|
|
24
|
+
* @param scrambleKey {string} the scramble key for the Sia app
|
|
25
|
+
* @returns {Sia} a Sia instance bound to a transport with the Sia app open
|
|
26
|
+
*/
|
|
27
|
+
static open(createTransport: TransportFactory, scrambleKey?: string): Promise<Sia>;
|
|
28
|
+
/**
|
|
29
|
+
* connectWebHID connects to a Ledger over WebHID (USB), launching the Sia
|
|
30
|
+
* app from the dashboard if it isn't already open, and returns a ready Sia
|
|
31
|
+
* instance.
|
|
32
|
+
* @param scrambleKey {string} the scramble key for the Sia app
|
|
33
|
+
* @returns {Sia} a Sia instance with the Sia app open
|
|
34
|
+
*/
|
|
35
|
+
static connectWebHID(scrambleKey?: string): Promise<Sia>;
|
|
36
|
+
/**
|
|
37
|
+
* connectBLE connects to a Ledger over Web Bluetooth, launching the Sia app
|
|
38
|
+
* from the dashboard if it isn't already open, and returns a ready Sia
|
|
39
|
+
* instance.
|
|
40
|
+
* @param scrambleKey {string} the scramble key for the Sia app
|
|
41
|
+
* @returns {Sia} a Sia instance with the Sia app open
|
|
42
|
+
*/
|
|
43
|
+
static connectBLE(scrambleKey?: string): Promise<Sia>;
|
|
44
|
+
/**
|
|
45
|
+
* supportedTransports returns the transport methods available in the current
|
|
46
|
+
* environment. Web Bluetooth is excluded on Brave, which does not reliably
|
|
47
|
+
* support it.
|
|
48
|
+
* @returns {Array<'hid' | 'ble'>} the supported transport methods
|
|
49
|
+
*/
|
|
50
|
+
static supportedTransports(): Promise<Array<'hid' | 'ble'>>;
|
|
51
|
+
/**
|
|
52
|
+
* exchangeTxnHash sends an encoded transaction to the device in 255-byte
|
|
53
|
+
* chunks and returns the response with the trailing status word stripped.
|
|
54
|
+
*/
|
|
55
|
+
private exchangeTxnHash;
|
|
56
|
+
/**
|
|
57
|
+
* openApp launches the Sia app from the device's dashboard. The device
|
|
58
|
+
* disconnects and reconnects when the app opens, so the transport must be
|
|
59
|
+
* re-created before issuing further commands.
|
|
60
|
+
*/
|
|
61
|
+
openApp(): Promise<void>;
|
|
19
62
|
/**
|
|
20
63
|
* getVersion returns the version of the Sia app
|
|
21
64
|
*
|
|
@@ -23,51 +66,39 @@ export default class Sia {
|
|
|
23
66
|
*/
|
|
24
67
|
getVersion(): Promise<string>;
|
|
25
68
|
/**
|
|
26
|
-
*
|
|
69
|
+
* getPublicKey returns the public key and standard Sia address for
|
|
27
70
|
* the provided public key index. The user will be asked to verify the
|
|
28
71
|
* public key on the display. A standard address is defined as an address
|
|
29
72
|
* having 1 public key, requiring 1 signature, and no timelock.
|
|
30
73
|
* @param index {number} the index of the public key
|
|
31
74
|
* @returns {VerifyResponse} the public key and standard address
|
|
32
75
|
*/
|
|
33
|
-
|
|
76
|
+
getPublicKey(index: number): Promise<VerifyResponse>;
|
|
34
77
|
/**
|
|
35
|
-
*
|
|
78
|
+
* getAddress returns the public key and standard Sia address for
|
|
36
79
|
* the provided public key index. The user will be asked to verify the
|
|
37
80
|
* address on the display. A standard address is defined as an address
|
|
38
81
|
* having 1 public key, requiring 1 signature, and no timelock.
|
|
39
82
|
* @param index {number} the index of the public key
|
|
40
83
|
* @returns {VerifyResponse} the public key and standard address
|
|
41
84
|
*/
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* signTransactionV044 signs the transaction with the provided key
|
|
45
|
-
* @deprecated deprecated in v0.4.5
|
|
46
|
-
* @param encodedTxn {Buffer} a sia encoded transaction
|
|
47
|
-
* @param sigIndex {number} the index of the signature to sign
|
|
48
|
-
* @param keyIndex {number} the index of the key to sign with
|
|
49
|
-
* @returns {string} the base64 encoded signature
|
|
50
|
-
*/
|
|
51
|
-
signTransactionV044(encodedTxn: Buffer, sigIndex: number, keyIndex: number): Promise<string>;
|
|
52
|
-
/**
|
|
53
|
-
* signTransaction signs the transaction with the provided key
|
|
54
|
-
* @param encodedTxn {Buffer} a sia encoded transaction
|
|
55
|
-
* @param sigIndex {number} the index of the signature to sign
|
|
56
|
-
* @param keyIndex {number} the index of the key to sign with
|
|
57
|
-
* @param changeIndex {number} the index of the key used for the change output
|
|
58
|
-
* @returns {string} the base64 encoded signature
|
|
59
|
-
*/
|
|
60
|
-
signTransaction(encodedTxn: Buffer, sigIndex: number, keyIndex: number, changeIndex: number): Promise<string>;
|
|
85
|
+
getAddress(index: number): Promise<VerifyResponse>;
|
|
61
86
|
/**
|
|
62
87
|
* signV2Transaction signs the v2 transaction with the provided key
|
|
63
88
|
* @param encodedTxn {Buffer} a sia encoded (V2TransactionSemantics) v2 transaction
|
|
64
89
|
* @param sigIndex {number} the index of the signature to sign
|
|
65
90
|
* @param keyIndex {number} the index of the key to sign with
|
|
66
91
|
* @param changeIndex {number} the index of the key used for the change output
|
|
67
|
-
* @returns {string} the
|
|
92
|
+
* @returns {string} the hex encoded signature
|
|
68
93
|
*/
|
|
69
94
|
signV2Transaction(encodedTxn: Buffer, sigIndex: number, keyIndex: number, changeIndex: number): Promise<string>;
|
|
70
|
-
|
|
95
|
+
/**
|
|
96
|
+
* signHash signs a 32-byte hash with the private key at the provided index
|
|
97
|
+
* @param sigHash {Buffer} the 32-byte hash to sign
|
|
98
|
+
* @param keyIndex {number} the index of the key to sign with
|
|
99
|
+
* @returns {string} the hex encoded signature
|
|
100
|
+
*/
|
|
101
|
+
signHash(sigHash: Buffer, keyIndex: number): Promise<string>;
|
|
71
102
|
close(): Promise<void>;
|
|
72
103
|
}
|
|
73
104
|
export {};
|
package/lib/sia.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sia.d.ts","sourceRoot":"","sources":["../src/sia.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sia.d.ts","sourceRoot":"","sources":["../src/sia.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAiChC,KAAK,gBAAgB,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;AAEjD,UAAU,cAAc;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,GAAG;IACvB,SAAS,EAAE,SAAS,CAAC;gBAET,SAAS,EAAE,SAAS,EAAE,WAAW,SAAQ;IAUrD;;;;;;;;OAQG;WACU,IAAI,CAAC,eAAe,EAAE,gBAAgB,EAAE,WAAW,SAAQ,GAAI,OAAO,CAAC,GAAG,CAAC;IAwCxF;;;;;;OAMG;WACU,aAAa,CAAC,WAAW,SAAQ,GAAI,OAAO,CAAC,GAAG,CAAC;IAI9D;;;;;;OAMG;WACU,UAAU,CAAC,WAAW,SAAQ,GAAI,OAAO,CAAC,GAAG,CAAC;IAI3D;;;;;OAKG;WACU,mBAAmB,IAAK,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;IAWlE;;;OAGG;YACW,eAAe;IAwB7B;;;;OAIG;IACG,OAAO,IAAK,OAAO,CAAC,IAAI,CAAC;IAI/B;;;;OAIG;IACG,UAAU,IAAK,OAAO,CAAC,MAAM,CAAC;IAMpC;;;;;;;OAOG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAI,OAAO,CAAC,cAAc,CAAC;IAW3D;;;;;;;OAOG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,GAAI,OAAO,CAAC,cAAc,CAAC;IAWzD;;;;;;;OAOG;IACG,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAI,OAAO,CAAC,MAAM,CAAC;IAMtH;;;;;OAKG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAI,OAAO,CAAC,MAAM,CAAC;IAWnE,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;CAGvB"}
|
package/lib/sia.js
CHANGED
|
@@ -1,48 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
4
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.__esModule = true;
|
|
39
|
-
var buffer_1 = require("buffer");
|
|
40
|
-
var base64_1 = require("@stablelib/base64");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const hw_transport_webhid_1 = __importDefault(require("@ledgerhq/hw-transport-webhid"));
|
|
7
|
+
const hw_transport_web_ble_1 = __importDefault(require("@ledgerhq/hw-transport-web-ble"));
|
|
8
|
+
const buffer_1 = require("buffer");
|
|
9
|
+
const CLA = 0xe0;
|
|
10
|
+
const APP_NAME = 'Sia';
|
|
11
|
+
const INS_OPEN_APP = 0xd8;
|
|
12
|
+
const INS_GET_VERSION = 0x01;
|
|
13
|
+
const INS_GET_PUBLIC_KEY = 0x02;
|
|
14
|
+
const INS_SIGN_HASH = 0x04;
|
|
15
|
+
const INS_CALC_V2TXN_HASH = 0x10;
|
|
16
|
+
const P1_FIRST = 0x00;
|
|
17
|
+
const P1_MORE = 0x80;
|
|
18
|
+
const P2_DISPLAY_ADDRESS = 0x00;
|
|
19
|
+
const P2_DISPLAY_PUBKEY = 0x01;
|
|
20
|
+
const P2_SIGN_HASH = 0x01;
|
|
41
21
|
function uint32ToBuffer(val) {
|
|
42
|
-
|
|
22
|
+
const buf = buffer_1.Buffer.alloc(4);
|
|
43
23
|
buf.writeUInt32LE(val, 0);
|
|
44
24
|
return buf;
|
|
45
25
|
}
|
|
26
|
+
function bytesToHex(bytes) {
|
|
27
|
+
return bytes.reduce((v, b) => v + ('0' + b.toString(16)).slice(-2), '');
|
|
28
|
+
}
|
|
29
|
+
function delay(ms) {
|
|
30
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
31
|
+
}
|
|
46
32
|
/**
|
|
47
33
|
* Sia
|
|
48
34
|
*
|
|
@@ -50,230 +36,195 @@ function uint32ToBuffer(val) {
|
|
|
50
36
|
* import Sia from '@siacentral/ledgerjs-sia';
|
|
51
37
|
* const sia = new Sia(transport)
|
|
52
38
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (scrambleKey === void 0) { scrambleKey = 'Sia'; }
|
|
39
|
+
class Sia {
|
|
40
|
+
constructor(transport, scrambleKey = 'Sia') {
|
|
56
41
|
this.transport = transport;
|
|
57
42
|
transport.decorateAppAPIMethods(this, [
|
|
58
|
-
'signTransactionV044',
|
|
59
|
-
'signTransaction',
|
|
60
43
|
'signV2Transaction',
|
|
61
|
-
'
|
|
62
|
-
'
|
|
44
|
+
'getPublicKey',
|
|
45
|
+
'getAddress',
|
|
63
46
|
'signHash',
|
|
64
47
|
], scrambleKey);
|
|
65
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* open connects a transport, ensures the Sia app is running, and returns a
|
|
51
|
+
* ready Sia instance. If the app is not already open it is launched from the
|
|
52
|
+
* dashboard; the device disconnects and reconnects when an app opens, so the
|
|
53
|
+
* transport is recreated via the provided factory until the app is ready.
|
|
54
|
+
* @param createTransport {TransportFactory} creates a transport, e.g. () => TransportWebHID.create()
|
|
55
|
+
* @param scrambleKey {string} the scramble key for the Sia app
|
|
56
|
+
* @returns {Sia} a Sia instance bound to a transport with the Sia app open
|
|
57
|
+
*/
|
|
58
|
+
static async open(createTransport, scrambleKey = 'Sia') {
|
|
59
|
+
let sia = new Sia(await createTransport(), scrambleKey);
|
|
60
|
+
// if the Sia app is already running, return immediately
|
|
61
|
+
try {
|
|
62
|
+
await sia.getVersion();
|
|
63
|
+
return sia;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// the app is not open yet
|
|
67
|
+
}
|
|
68
|
+
// open the Sia app; the device disconnects and reconnects
|
|
69
|
+
try {
|
|
70
|
+
await sia.openApp();
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// the device disconnects as the app opens
|
|
74
|
+
}
|
|
75
|
+
await sia.close().catch(() => undefined);
|
|
76
|
+
// the device reconnects when an app is opened; poll until the Sia app is ready
|
|
77
|
+
for (let i = 0; i < 10; i++) {
|
|
78
|
+
await delay(500);
|
|
79
|
+
try {
|
|
80
|
+
sia = new Sia(await createTransport(), scrambleKey);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
await sia.getVersion();
|
|
87
|
+
return sia;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
await sia.close().catch(() => undefined);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
throw new Error('Sia app did not become ready');
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* connectWebHID connects to a Ledger over WebHID (USB), launching the Sia
|
|
97
|
+
* app from the dashboard if it isn't already open, and returns a ready Sia
|
|
98
|
+
* instance.
|
|
99
|
+
* @param scrambleKey {string} the scramble key for the Sia app
|
|
100
|
+
* @returns {Sia} a Sia instance with the Sia app open
|
|
101
|
+
*/
|
|
102
|
+
static async connectWebHID(scrambleKey = 'Sia') {
|
|
103
|
+
return Sia.open(() => hw_transport_webhid_1.default.create(), scrambleKey);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* connectBLE connects to a Ledger over Web Bluetooth, launching the Sia app
|
|
107
|
+
* from the dashboard if it isn't already open, and returns a ready Sia
|
|
108
|
+
* instance.
|
|
109
|
+
* @param scrambleKey {string} the scramble key for the Sia app
|
|
110
|
+
* @returns {Sia} a Sia instance with the Sia app open
|
|
111
|
+
*/
|
|
112
|
+
static async connectBLE(scrambleKey = 'Sia') {
|
|
113
|
+
return Sia.open(() => hw_transport_web_ble_1.default.create(), scrambleKey);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* supportedTransports returns the transport methods available in the current
|
|
117
|
+
* environment. Web Bluetooth is excluded on Brave, which does not reliably
|
|
118
|
+
* support it.
|
|
119
|
+
* @returns {Array<'hid' | 'ble'>} the supported transport methods
|
|
120
|
+
*/
|
|
121
|
+
static async supportedTransports() {
|
|
122
|
+
const nav = navigator;
|
|
123
|
+
const support = await Promise.all([
|
|
124
|
+
hw_transport_webhid_1.default.isSupported().then(supported => supported ? 'hid' : null),
|
|
125
|
+
hw_transport_web_ble_1.default.isSupported().then(async (supported) => supported && !(nav.brave && await nav.brave.isBrave()) ? 'ble' : null)
|
|
126
|
+
]);
|
|
127
|
+
return support.filter((t) => t !== null);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* exchangeTxnHash sends an encoded transaction to the device in 255-byte
|
|
131
|
+
* chunks and returns the response with the trailing status word stripped.
|
|
132
|
+
*/
|
|
133
|
+
async exchangeTxnHash(ins, encodedTxn, p2, sigIndex, keyIndex, changeIndex) {
|
|
134
|
+
if (encodedTxn.length === 0)
|
|
135
|
+
throw new Error('empty transaction');
|
|
136
|
+
const buf = buffer_1.Buffer.alloc(encodedTxn.length + 10);
|
|
137
|
+
buf.writeUInt32LE(keyIndex, 0);
|
|
138
|
+
buf.writeUInt16LE(sigIndex, 4);
|
|
139
|
+
buf.writeUInt32LE(changeIndex, 6);
|
|
140
|
+
buf.set(encodedTxn, 10);
|
|
141
|
+
let resp = buffer_1.Buffer.alloc(0);
|
|
142
|
+
for (let i = 0; i < buf.length; i += 255) {
|
|
143
|
+
resp = await this.transport.send(CLA, ins, i === 0 ? P1_FIRST : P1_MORE, p2, buffer_1.Buffer.from(buf.subarray(i, i + 255)));
|
|
144
|
+
}
|
|
145
|
+
// the status code is appended as the last 2 bytes of the response, but
|
|
146
|
+
// the transport already handles invalid codes.
|
|
147
|
+
return buffer_1.Buffer.from(resp.subarray(0, resp.length - 2));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* openApp launches the Sia app from the device's dashboard. The device
|
|
151
|
+
* disconnects and reconnects when the app opens, so the transport must be
|
|
152
|
+
* re-created before issuing further commands.
|
|
153
|
+
*/
|
|
154
|
+
async openApp() {
|
|
155
|
+
await this.transport.send(CLA, INS_OPEN_APP, 0x00, 0x00, buffer_1.Buffer.from(APP_NAME, 'ascii'));
|
|
156
|
+
}
|
|
66
157
|
/**
|
|
67
158
|
* getVersion returns the version of the Sia app
|
|
68
159
|
*
|
|
69
160
|
* @returns {string} the current version of the Sia app.
|
|
70
161
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
switch (_a.label) {
|
|
76
|
-
case 0: return [4 /*yield*/, this.transport.send(0xe0, 0x01, 0x00, 0x00, buffer_1.Buffer.alloc(0))];
|
|
77
|
-
case 1:
|
|
78
|
-
resp = _a.sent();
|
|
79
|
-
return [2 /*return*/, "v".concat(resp[0], ".").concat(resp[1], ".").concat(resp[2])];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
162
|
+
async getVersion() {
|
|
163
|
+
const resp = await this.transport.send(CLA, INS_GET_VERSION, 0x00, 0x00, buffer_1.Buffer.alloc(0));
|
|
164
|
+
return `v${resp[0]}.${resp[1]}.${resp[2]}`;
|
|
165
|
+
}
|
|
84
166
|
/**
|
|
85
|
-
*
|
|
167
|
+
* getPublicKey returns the public key and standard Sia address for
|
|
86
168
|
* the provided public key index. The user will be asked to verify the
|
|
87
169
|
* public key on the display. A standard address is defined as an address
|
|
88
170
|
* having 1 public key, requiring 1 signature, and no timelock.
|
|
89
171
|
* @param index {number} the index of the public key
|
|
90
172
|
* @returns {VerifyResponse} the public key and standard address
|
|
91
173
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// the transport already handles invalid codes.
|
|
102
|
-
return [2 /*return*/, {
|
|
103
|
-
publicKey: "ed25519:".concat(resp.slice(0, 32).reduce(function (v, b) { return v + ('0' + b.toString(16)).slice(-2); }, '')),
|
|
104
|
-
address: resp.slice(32, resp.length - 2).toString()
|
|
105
|
-
}];
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
};
|
|
174
|
+
async getPublicKey(index) {
|
|
175
|
+
const resp = await this.transport.send(CLA, INS_GET_PUBLIC_KEY, 0x00, P2_DISPLAY_PUBKEY, uint32ToBuffer(index));
|
|
176
|
+
// the status code is appended as the last 2 bytes of the response, but
|
|
177
|
+
// the transport already handles invalid codes.
|
|
178
|
+
return {
|
|
179
|
+
publicKey: `ed25519:${bytesToHex(resp.subarray(0, 32))}`,
|
|
180
|
+
address: resp.subarray(32, resp.length - 2).toString()
|
|
181
|
+
};
|
|
182
|
+
}
|
|
110
183
|
/**
|
|
111
|
-
*
|
|
184
|
+
* getAddress returns the public key and standard Sia address for
|
|
112
185
|
* the provided public key index. The user will be asked to verify the
|
|
113
186
|
* address on the display. A standard address is defined as an address
|
|
114
187
|
* having 1 public key, requiring 1 signature, and no timelock.
|
|
115
188
|
* @param index {number} the index of the public key
|
|
116
189
|
* @returns {VerifyResponse} the public key and standard address
|
|
117
190
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// the transport already handles invalid codes.
|
|
128
|
-
return [2 /*return*/, {
|
|
129
|
-
publicKey: "ed25519:".concat(resp.slice(0, 32).reduce(function (v, b) { return v + ('0' + b.toString(16)).slice(-2); }, '')),
|
|
130
|
-
address: resp.slice(32, resp.length - 2).toString()
|
|
131
|
-
}];
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* signTransactionV044 signs the transaction with the provided key
|
|
138
|
-
* @deprecated deprecated in v0.4.5
|
|
139
|
-
* @param encodedTxn {Buffer} a sia encoded transaction
|
|
140
|
-
* @param sigIndex {number} the index of the signature to sign
|
|
141
|
-
* @param keyIndex {number} the index of the key to sign with
|
|
142
|
-
* @returns {string} the base64 encoded signature
|
|
143
|
-
*/
|
|
144
|
-
Sia.prototype.signTransactionV044 = function (encodedTxn, sigIndex, keyIndex) {
|
|
145
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
146
|
-
var buf, resp, i;
|
|
147
|
-
return __generator(this, function (_a) {
|
|
148
|
-
switch (_a.label) {
|
|
149
|
-
case 0:
|
|
150
|
-
buf = buffer_1.Buffer.alloc(encodedTxn.length + 6);
|
|
151
|
-
resp = buffer_1.Buffer.alloc(0);
|
|
152
|
-
if (encodedTxn.length === 0)
|
|
153
|
-
throw new Error('empty transaction');
|
|
154
|
-
buf.writeUInt32LE(keyIndex, 0);
|
|
155
|
-
buf.writeUInt16LE(sigIndex, 4);
|
|
156
|
-
buf.set(encodedTxn, 6);
|
|
157
|
-
i = 0;
|
|
158
|
-
_a.label = 1;
|
|
159
|
-
case 1:
|
|
160
|
-
if (!(i < buf.length)) return [3 /*break*/, 4];
|
|
161
|
-
return [4 /*yield*/, this.transport.send(0xe0, 0x08, i === 0 ? 0x00 : 0x80, 0x01, buffer_1.Buffer.from(buf.subarray(i, i + 255)))];
|
|
162
|
-
case 2:
|
|
163
|
-
// INS_GET_TXN_HASH = 0x08
|
|
164
|
-
resp = _a.sent();
|
|
165
|
-
_a.label = 3;
|
|
166
|
-
case 3:
|
|
167
|
-
i += 255;
|
|
168
|
-
return [3 /*break*/, 1];
|
|
169
|
-
case 4:
|
|
170
|
-
console.log(resp);
|
|
171
|
-
console.log(resp.length);
|
|
172
|
-
return [2 /*return*/, (0, base64_1.encode)(resp.slice(0, resp.length - 2))];
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
};
|
|
191
|
+
async getAddress(index) {
|
|
192
|
+
const resp = await this.transport.send(CLA, INS_GET_PUBLIC_KEY, 0x00, P2_DISPLAY_ADDRESS, uint32ToBuffer(index));
|
|
193
|
+
// the status code is appended as the last 2 bytes of the response, but
|
|
194
|
+
// the transport already handles invalid codes.
|
|
195
|
+
return {
|
|
196
|
+
publicKey: `ed25519:${bytesToHex(resp.subarray(0, 32))}`,
|
|
197
|
+
address: resp.subarray(32, resp.length - 2).toString()
|
|
198
|
+
};
|
|
199
|
+
}
|
|
177
200
|
/**
|
|
178
|
-
*
|
|
179
|
-
* @param encodedTxn {Buffer} a sia encoded transaction
|
|
201
|
+
* signV2Transaction signs the v2 transaction with the provided key
|
|
202
|
+
* @param encodedTxn {Buffer} a sia encoded (V2TransactionSemantics) v2 transaction
|
|
180
203
|
* @param sigIndex {number} the index of the signature to sign
|
|
181
204
|
* @param keyIndex {number} the index of the key to sign with
|
|
182
205
|
* @param changeIndex {number} the index of the key used for the change output
|
|
183
|
-
* @returns {string} the
|
|
206
|
+
* @returns {string} the hex encoded signature
|
|
184
207
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
switch (_a.label) {
|
|
190
|
-
case 0:
|
|
191
|
-
buf = buffer_1.Buffer.alloc(encodedTxn.length + 10);
|
|
192
|
-
resp = buffer_1.Buffer.alloc(0);
|
|
193
|
-
if (encodedTxn.length === 0)
|
|
194
|
-
throw new Error('empty transaction');
|
|
195
|
-
buf.writeUInt32LE(keyIndex, 0);
|
|
196
|
-
buf.writeUInt16LE(sigIndex, 4);
|
|
197
|
-
buf.writeUInt32LE(changeIndex, 6);
|
|
198
|
-
buf.set(encodedTxn, 10);
|
|
199
|
-
i = 0;
|
|
200
|
-
_a.label = 1;
|
|
201
|
-
case 1:
|
|
202
|
-
if (!(i < buf.length)) return [3 /*break*/, 4];
|
|
203
|
-
return [4 /*yield*/, this.transport.send(0xe0, 0x08, i === 0 ? 0x00 : 0x80, 0x01, buffer_1.Buffer.from(buf.subarray(i, i + 255)))];
|
|
204
|
-
case 2:
|
|
205
|
-
// INS_GET_TXN_HASH = 0x08
|
|
206
|
-
resp = _a.sent();
|
|
207
|
-
_a.label = 3;
|
|
208
|
-
case 3:
|
|
209
|
-
i += 255;
|
|
210
|
-
return [3 /*break*/, 1];
|
|
211
|
-
case 4: return [2 /*return*/, (0, base64_1.encode)(resp)];
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
};
|
|
208
|
+
async signV2Transaction(encodedTxn, sigIndex, keyIndex, changeIndex) {
|
|
209
|
+
const resp = await this.exchangeTxnHash(INS_CALC_V2TXN_HASH, encodedTxn, P2_SIGN_HASH, sigIndex, keyIndex, changeIndex);
|
|
210
|
+
return bytesToHex(resp);
|
|
211
|
+
}
|
|
216
212
|
/**
|
|
217
|
-
*
|
|
218
|
-
* @param
|
|
219
|
-
* @param sigIndex {number} the index of the signature to sign
|
|
213
|
+
* signHash signs a 32-byte hash with the private key at the provided index
|
|
214
|
+
* @param sigHash {Buffer} the 32-byte hash to sign
|
|
220
215
|
* @param keyIndex {number} the index of the key to sign with
|
|
221
|
-
* @
|
|
222
|
-
* @returns {string} the base64 encoded signature
|
|
216
|
+
* @returns {string} the hex encoded signature
|
|
223
217
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (encodedTxn.length === 0)
|
|
233
|
-
throw new Error('empty transaction');
|
|
234
|
-
buf.writeUInt32LE(keyIndex, 0);
|
|
235
|
-
buf.writeUInt16LE(sigIndex, 4);
|
|
236
|
-
buf.writeUInt32LE(changeIndex, 6);
|
|
237
|
-
buf.set(encodedTxn, 10);
|
|
238
|
-
i = 0;
|
|
239
|
-
_a.label = 1;
|
|
240
|
-
case 1:
|
|
241
|
-
if (!(i < buf.length)) return [3 /*break*/, 4];
|
|
242
|
-
return [4 /*yield*/, this.transport.send(0xe0, 0x10, i === 0 ? 0x00 : 0x80, 0x01, buffer_1.Buffer.from(buf.subarray(i, i + 255)))];
|
|
243
|
-
case 2:
|
|
244
|
-
// INS_GET_V2TXN_HASH = 0x10
|
|
245
|
-
resp = _a.sent();
|
|
246
|
-
_a.label = 3;
|
|
247
|
-
case 3:
|
|
248
|
-
i += 255;
|
|
249
|
-
return [3 /*break*/, 1];
|
|
250
|
-
case 4: return [2 /*return*/, resp.reduce(function (v, b) { return v + ('0' + b.toString(16)).slice(-2); }, '')];
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
};
|
|
255
|
-
Sia.prototype.blindSign = function (sigHash, keyIndex) {
|
|
256
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
257
|
-
var buf, resp;
|
|
258
|
-
return __generator(this, function (_a) {
|
|
259
|
-
switch (_a.label) {
|
|
260
|
-
case 0:
|
|
261
|
-
buf = buffer_1.Buffer.alloc(sigHash.length + 4);
|
|
262
|
-
resp = buffer_1.Buffer.alloc(0);
|
|
263
|
-
buf.writeUInt32LE(keyIndex);
|
|
264
|
-
buf.set(sigHash, 4);
|
|
265
|
-
return [4 /*yield*/, this.transport.send(0xe0, 0x04, 0x00, 0x00, buf)];
|
|
266
|
-
case 1:
|
|
267
|
-
resp = _a.sent();
|
|
268
|
-
return [2 /*return*/, resp.slice(0, resp.length - 2).reduce(function (v, b) { return v + ('0' + b.toString(16)).slice(-2); }, '')];
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
};
|
|
273
|
-
Sia.prototype.close = function () {
|
|
218
|
+
async signHash(sigHash, keyIndex) {
|
|
219
|
+
const buf = buffer_1.Buffer.alloc(sigHash.length + 4);
|
|
220
|
+
buf.writeUInt32LE(keyIndex, 0);
|
|
221
|
+
buf.set(sigHash, 4);
|
|
222
|
+
const resp = await this.transport.send(CLA, INS_SIGN_HASH, 0x00, 0x00, buf);
|
|
223
|
+
return bytesToHex(resp.subarray(0, resp.length - 2));
|
|
224
|
+
}
|
|
225
|
+
close() {
|
|
274
226
|
return this.transport.close();
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
exports["default"] = Sia;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.default = Sia;
|
|
279
230
|
//# sourceMappingURL=sia.js.map
|
package/lib/sia.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sia.js","sourceRoot":"","sources":["../src/sia.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sia.js","sourceRoot":"","sources":["../src/sia.ts"],"names":[],"mappings":";;;;;AACA,wFAA4D;AAC5D,0FAA6D;AAC7D,mCAAgC;AAEhC,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB,MAAM,QAAQ,GAAG,KAAK,CAAC;AAEvB,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,mBAAmB,GAA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-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
2
|
+
"name": "@siacentral/ledgerjs-sia",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Ledger hardware wallet Siacoin API.",
|
|
5
|
+
"main": "lib/sia.js",
|
|
6
|
+
"types": "lib/sia.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"test": "jest",
|
|
10
|
+
"lint": "eslint src",
|
|
11
|
+
"prepare": "npm run build",
|
|
12
|
+
"prepublishOnly": "npm run lint && npm run test",
|
|
13
|
+
"preversion": "npm run lint"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"Ledger",
|
|
17
|
+
"LedgerWallet",
|
|
18
|
+
"sc",
|
|
19
|
+
"Siacoin",
|
|
20
|
+
"sf",
|
|
21
|
+
"Siafund",
|
|
22
|
+
"NanoS",
|
|
23
|
+
"NanoX",
|
|
24
|
+
"Hardware Wallet"
|
|
25
|
+
],
|
|
26
|
+
"author": "Nate Maninger <me@n8m.us>",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/siacentral/ledgerjs-sia"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/siacentral/ledgerjs-sia/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/siacentral/ledgerjs-sia",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@eslint/js": "^10.0.1",
|
|
41
|
+
"@ledgerhq/hw-transport-mocker": "^6.34.2",
|
|
42
|
+
"@types/jest": "^30.0.0",
|
|
43
|
+
"eslint": "^10.4.1",
|
|
44
|
+
"jest": "^30.4.2",
|
|
45
|
+
"ts-jest": "^29.4.11",
|
|
46
|
+
"ts-node": "^10.9.2",
|
|
47
|
+
"typescript": "^6.0.3",
|
|
48
|
+
"typescript-eslint": "^8.60.0"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@ledgerhq/hw-transport": "^6.35.2",
|
|
52
|
+
"@ledgerhq/hw-transport-web-ble": "^6.34.2",
|
|
53
|
+
"@ledgerhq/hw-transport-webhid": "^6.35.2",
|
|
54
|
+
"buffer": "^6.0.3"
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"lib/**/*"
|
|
58
|
+
]
|
|
59
|
+
}
|