@ledgerhq/hw-app-str 6.29.0 → 6.29.1-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +161 -57
- package/lib/Str.d.ts +43 -18
- package/lib/Str.d.ts.map +1 -1
- package/lib/Str.js +166 -175
- package/lib/Str.js.map +1 -1
- package/lib/errors.d.ts +27 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +23 -0
- package/lib/errors.js.map +1 -0
- package/lib-es/Str.d.ts +43 -18
- package/lib-es/Str.d.ts.map +1 -1
- package/lib-es/Str.js +149 -175
- package/lib-es/Str.js.map +1 -1
- package/lib-es/errors.d.ts +27 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +20 -0
- package/lib-es/errors.js.map +1 -0
- package/package.json +6 -6
- package/src/Str.ts +168 -234
- package/src/errors.ts +27 -0
- package/tests/Str.test.ts +322 -17
- package/lib/utils.d.ts +0 -9
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js +0 -106
- package/lib/utils.js.map +0 -1
- package/lib-es/utils.d.ts +0 -9
- package/lib-es/utils.d.ts.map +0 -1
- package/lib-es/utils.js +0 -93
- package/lib-es/utils.js.map +0 -1
- package/src/utils.ts +0 -111
package/lib-es/Str.js
CHANGED
|
@@ -1,26 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import BIPPath from "bip32-path";
|
|
11
|
+
import { StellarHashSigningNotEnabledError, StellarDataParsingFailedError, StellarUserRefusedError, StellarDataTooLargeError, } from "./errors";
|
|
2
12
|
const CLA = 0xe0;
|
|
13
|
+
const P1_FIRST = 0x00;
|
|
14
|
+
const P1_MORE = 0x80;
|
|
15
|
+
const P2_LAST = 0x00;
|
|
16
|
+
const P2_MORE = 0x80;
|
|
17
|
+
const P2_NON_CONFIRM = 0x00; // for getPublicKey
|
|
18
|
+
const P2_CONFIRM = 0x01; // for getPublicKey
|
|
3
19
|
const INS_GET_PK = 0x02;
|
|
4
20
|
const INS_SIGN_TX = 0x04;
|
|
5
21
|
const INS_GET_CONF = 0x06;
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const SW_OK = 0x9000;
|
|
14
|
-
const SW_CANCEL = 0x6985;
|
|
15
|
-
const SW_UNKNOWN_OP = 0x6c24;
|
|
16
|
-
const SW_MULTI_OP = 0x6c25;
|
|
17
|
-
const SW_NOT_ALLOWED = 0x6c66;
|
|
18
|
-
const SW_UNSUPPORTED = 0x6d00;
|
|
19
|
-
const SW_KEEP_ALIVE = 0x6e02;
|
|
20
|
-
const TX_MAX_SIZE = 1540;
|
|
22
|
+
const INS_SIGN_HASH = 0x08;
|
|
23
|
+
const INS_SIGN_SOROBAN_AUTHORIZATION = 0x0a;
|
|
24
|
+
const APDU_MAX_PAYLOAD = 255;
|
|
25
|
+
const SW_DENY = 0x6985;
|
|
26
|
+
const SW_HASH_SIGNING_MODE_NOT_ENABLED = 0x6c66;
|
|
27
|
+
const SW_DATA_TOO_LARGE = 0xb004;
|
|
28
|
+
const SW_DATA_PARSING_FAIL = 0xb005;
|
|
21
29
|
/**
|
|
22
30
|
* Stellar API
|
|
23
31
|
*
|
|
32
|
+
* @param transport a transport for sending commands to a device
|
|
33
|
+
* @param scrambleKey a scramble key
|
|
34
|
+
*
|
|
24
35
|
* @example
|
|
25
36
|
* import Str from "@ledgerhq/hw-app-str";
|
|
26
37
|
* const str = new Str(transport)
|
|
@@ -28,198 +39,161 @@ const TX_MAX_SIZE = 1540;
|
|
|
28
39
|
export default class Str {
|
|
29
40
|
constructor(transport, scrambleKey = "l0v") {
|
|
30
41
|
this.transport = transport;
|
|
31
|
-
transport.decorateAppAPIMethods(this, [
|
|
42
|
+
transport.decorateAppAPIMethods(this, [
|
|
43
|
+
"getAppConfiguration",
|
|
44
|
+
"getPublicKey",
|
|
45
|
+
"signTransaction",
|
|
46
|
+
"signSorobanAuthorization",
|
|
47
|
+
"signHash",
|
|
48
|
+
], scrambleKey);
|
|
32
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Get Stellar application configuration.
|
|
52
|
+
*
|
|
53
|
+
* @returns an object with the application configuration, including the version,
|
|
54
|
+
* whether hash signing is enabled, and the maximum data size in bytes that the device can sign.
|
|
55
|
+
* @example
|
|
56
|
+
* str.getAppConfiguration().then(o => o.version)
|
|
57
|
+
*/
|
|
33
58
|
getAppConfiguration() {
|
|
34
|
-
return this
|
|
35
|
-
const
|
|
36
|
-
const
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const resp = yield this.sendToDevice(INS_GET_CONF, Buffer.alloc(0));
|
|
61
|
+
const [hashSigningEnabled, major, minor, patch, maxDataSizeHi, maxDataSizeLo] = resp;
|
|
37
62
|
return {
|
|
38
|
-
|
|
39
|
-
|
|
63
|
+
hashSigningEnabled: hashSigningEnabled === 0x01,
|
|
64
|
+
version: `${major}.${minor}.${patch}`,
|
|
65
|
+
maxDataSize: resp.length > 4 ? (maxDataSizeHi << 8) | maxDataSizeLo : undefined, // For compatibility with older app, let's remove this in the future
|
|
40
66
|
};
|
|
41
67
|
});
|
|
42
68
|
}
|
|
43
69
|
/**
|
|
44
|
-
*
|
|
70
|
+
* Get Stellar raw public key for a given BIP 32 path.
|
|
71
|
+
*
|
|
45
72
|
* @param path a path in BIP 32 format
|
|
46
|
-
* @
|
|
47
|
-
* @
|
|
48
|
-
*
|
|
49
|
-
* the raw ed25519 public key.
|
|
73
|
+
* @param display if true, the device will ask the user to confirm the address on the device, if false, it will return the raw public key directly
|
|
74
|
+
* @return an object with the raw ed25519 public key.
|
|
75
|
+
* If you want to convert it to string, you can use {@link https://stellar.github.io/js-stellar-base/StrKey.html#.encodeEd25519PublicKey StrKey.encodeEd25519PublicKey}
|
|
50
76
|
* @example
|
|
51
|
-
* str.getPublicKey("44'/148'/0'").then(o => o.
|
|
77
|
+
* str.getPublicKey("44'/148'/0'").then(o => o.rawPublicKey)
|
|
52
78
|
*/
|
|
53
|
-
getPublicKey(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
pathElts.forEach((element, index) => {
|
|
61
|
-
buffer.writeUInt32BE(element, 1 + 4 * index);
|
|
62
|
-
});
|
|
63
|
-
const verifyMsg = Buffer.from("via lumina", "ascii");
|
|
64
|
-
apdus.push(Buffer.concat([buffer, verifyMsg]));
|
|
65
|
-
let keepAlive = false;
|
|
66
|
-
return foreach(apdus, data => this.transport
|
|
67
|
-
.send(CLA, keepAlive ? INS_KEEP_ALIVE : INS_GET_PK, boolValidate ? 0x01 : 0x00, boolDisplay ? 0x01 : 0x00, data, [SW_OK, SW_KEEP_ALIVE])
|
|
68
|
-
.then(apduResponse => {
|
|
69
|
-
const status = Buffer.from(apduResponse.slice(apduResponse.length - 2)).readUInt16BE(0);
|
|
70
|
-
if (status === SW_KEEP_ALIVE) {
|
|
71
|
-
keepAlive = true;
|
|
72
|
-
apdus.push(Buffer.alloc(0));
|
|
79
|
+
getPublicKey(path_1) {
|
|
80
|
+
return __awaiter(this, arguments, void 0, function* (path, display = false) {
|
|
81
|
+
const pathBuffer = pathToBuffer(path);
|
|
82
|
+
const p2 = display ? P2_CONFIRM : P2_NON_CONFIRM;
|
|
83
|
+
try {
|
|
84
|
+
const data = yield this.transport.send(CLA, INS_GET_PK, P1_FIRST, p2, pathBuffer);
|
|
85
|
+
return { rawPublicKey: data.slice(0, -2) };
|
|
73
86
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// response = Buffer.from(response, 'hex');
|
|
77
|
-
let offset = 0;
|
|
78
|
-
const rawPublicKey = response.slice(offset, offset + 32);
|
|
79
|
-
offset += 32;
|
|
80
|
-
const publicKey = encodeEd25519PublicKey(rawPublicKey);
|
|
81
|
-
if (boolValidate) {
|
|
82
|
-
const signature = response.slice(offset, offset + 64);
|
|
83
|
-
if (!verifyEd25519Signature(verifyMsg, signature, rawPublicKey)) {
|
|
84
|
-
throw new Error("Bad signature. Keypair is invalid. Please report this.");
|
|
85
|
-
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
throw remapErrors(e);
|
|
86
89
|
}
|
|
87
|
-
return {
|
|
88
|
-
publicKey: publicKey,
|
|
89
|
-
raw: rawPublicKey,
|
|
90
|
-
};
|
|
91
90
|
});
|
|
92
91
|
}
|
|
93
92
|
/**
|
|
94
|
-
*
|
|
93
|
+
* Sign a Stellar transaction.
|
|
94
|
+
*
|
|
95
95
|
* @param path a path in BIP 32 format
|
|
96
|
-
* @param transaction signature base of the transaction to sign
|
|
97
|
-
* @return an object with the signature
|
|
96
|
+
* @param transaction {@link https://stellar.github.io/js-stellar-base/Transaction.html#signatureBase signature base} of the transaction to sign
|
|
97
|
+
* @return an object with the signature
|
|
98
98
|
* @example
|
|
99
99
|
* str.signTransaction("44'/148'/0'", signatureBase).then(o => o.signature)
|
|
100
100
|
*/
|
|
101
101
|
signTransaction(path, transaction) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
let response;
|
|
108
|
-
const pathElts = splitPath(path);
|
|
109
|
-
const bufferSize = 1 + pathElts.length * 4;
|
|
110
|
-
const buffer = Buffer.alloc(bufferSize);
|
|
111
|
-
buffer[0] = pathElts.length;
|
|
112
|
-
pathElts.forEach(function (element, index) {
|
|
113
|
-
buffer.writeUInt32BE(element, 1 + 4 * index);
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const pathBuffer = pathToBuffer(path);
|
|
104
|
+
const payload = Buffer.concat([pathBuffer, transaction]);
|
|
105
|
+
const resp = yield this.sendToDevice(INS_SIGN_TX, payload);
|
|
106
|
+
return { signature: resp };
|
|
114
107
|
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
transaction.copy(chunk, 0, offset, offset + chunkSize);
|
|
132
|
-
offset += chunkSize;
|
|
133
|
-
apdus.push(chunk);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
let keepAlive = false;
|
|
137
|
-
return foreach(apdus, (data, i) => this.transport
|
|
138
|
-
.send(CLA, keepAlive ? INS_KEEP_ALIVE : INS_SIGN_TX, i === 0 ? P1_FIRST_APDU : P1_MORE_APDU, i === apdus.length - 1 ? P2_LAST_APDU : P2_MORE_APDU, data, [SW_OK, SW_CANCEL, SW_UNKNOWN_OP, SW_MULTI_OP, SW_KEEP_ALIVE])
|
|
139
|
-
.then(apduResponse => {
|
|
140
|
-
const status = Buffer.from(apduResponse.slice(apduResponse.length - 2)).readUInt16BE(0);
|
|
141
|
-
if (status === SW_KEEP_ALIVE) {
|
|
142
|
-
keepAlive = true;
|
|
143
|
-
apdus.push(Buffer.alloc(0));
|
|
144
|
-
}
|
|
145
|
-
response = apduResponse;
|
|
146
|
-
})).then(() => {
|
|
147
|
-
const status = Buffer.from(response.slice(response.length - 2)).readUInt16BE(0);
|
|
148
|
-
if (status === SW_OK) {
|
|
149
|
-
const signature = Buffer.from(response.slice(0, response.length - 2));
|
|
150
|
-
return {
|
|
151
|
-
signature: signature,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
else if (status === SW_UNKNOWN_OP) {
|
|
155
|
-
// pre-v2 app version: fall back on hash signing
|
|
156
|
-
return this.signHash_private(path, hash(transaction));
|
|
157
|
-
}
|
|
158
|
-
else if (status === SW_MULTI_OP) {
|
|
159
|
-
// multi-operation transaction: attempt hash signing
|
|
160
|
-
return this.signHash_private(path, hash(transaction));
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
throw new Error("Transaction approval request was rejected");
|
|
164
|
-
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Sign a Stellar Soroban authorization.
|
|
111
|
+
*
|
|
112
|
+
* @param path a path in BIP 32 format
|
|
113
|
+
* @param hashIdPreimage the {@link https://github.com/stellar/stellar-xdr/blob/1a04392432dacc0092caaeae22a600ea1af3c6a5/Stellar-transaction.x#L702-L709 Soroban authorization hashIdPreimage} to sign
|
|
114
|
+
* @return an object with the signature
|
|
115
|
+
* @example
|
|
116
|
+
* str.signSorobanAuthorization("44'/148'/0'", hashIdPreimage).then(o => o.signature)
|
|
117
|
+
*/
|
|
118
|
+
signSorobanAuthorization(path, hashIdPreimage) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const pathBuffer = pathToBuffer(path);
|
|
121
|
+
const payload = Buffer.concat([pathBuffer, hashIdPreimage]);
|
|
122
|
+
const resp = yield this.sendToDevice(INS_SIGN_SOROBAN_AUTHORIZATION, payload);
|
|
123
|
+
return { signature: resp };
|
|
165
124
|
});
|
|
166
125
|
}
|
|
167
126
|
/**
|
|
168
|
-
*
|
|
127
|
+
* Sign a hash.
|
|
128
|
+
*
|
|
169
129
|
* @param path a path in BIP 32 format
|
|
170
|
-
* @param hash
|
|
130
|
+
* @param hash the hash to sign
|
|
171
131
|
* @return an object with the signature
|
|
172
132
|
* @example
|
|
173
133
|
* str.signHash("44'/148'/0'", hash).then(o => o.signature)
|
|
174
134
|
*/
|
|
175
135
|
signHash(path, hash) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
let response;
|
|
182
|
-
const pathElts = splitPath(path);
|
|
183
|
-
const buffer = Buffer.alloc(1 + pathElts.length * 4);
|
|
184
|
-
buffer[0] = pathElts.length;
|
|
185
|
-
pathElts.forEach(function (element, index) {
|
|
186
|
-
buffer.writeUInt32BE(element, 1 + 4 * index);
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
const pathBuffer = pathToBuffer(path);
|
|
138
|
+
const payload = Buffer.concat([pathBuffer, hash]);
|
|
139
|
+
const resp = yield this.sendToDevice(INS_SIGN_HASH, payload);
|
|
140
|
+
return { signature: resp };
|
|
187
141
|
});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const status = Buffer.from(response.slice(response.length - 2)).readUInt16BE(0);
|
|
207
|
-
if (status === SW_OK) {
|
|
208
|
-
const signature = Buffer.from(response.slice(0, response.length - 2));
|
|
209
|
-
return {
|
|
210
|
-
signature: signature,
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
else if (status === SW_CANCEL) {
|
|
214
|
-
throw new Error("Transaction approval request was rejected");
|
|
215
|
-
}
|
|
216
|
-
else if (status === SW_UNSUPPORTED) {
|
|
217
|
-
throw new Error("Hash signing is not supported");
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
throw new Error("Hash signing not allowed. Have you enabled it in the app settings?");
|
|
142
|
+
}
|
|
143
|
+
sendToDevice(instruction, payload) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
let response = Buffer.alloc(0);
|
|
146
|
+
let remaining = payload.length;
|
|
147
|
+
// eslint-disable-next-line no-constant-condition
|
|
148
|
+
while (true) {
|
|
149
|
+
const chunkSize = remaining > APDU_MAX_PAYLOAD ? APDU_MAX_PAYLOAD : remaining;
|
|
150
|
+
const p1 = remaining === payload.length ? P1_FIRST : P1_MORE;
|
|
151
|
+
const p2 = remaining - chunkSize === 0 ? P2_LAST : P2_MORE;
|
|
152
|
+
const chunk = payload.slice(payload.length - remaining, payload.length - remaining + chunkSize);
|
|
153
|
+
response = yield this.transport.send(CLA, instruction, p1, p2, chunk).catch(e => {
|
|
154
|
+
throw remapErrors(e);
|
|
155
|
+
});
|
|
156
|
+
remaining -= chunkSize;
|
|
157
|
+
if (remaining === 0) {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
221
160
|
}
|
|
161
|
+
return response.slice(0, -2);
|
|
222
162
|
});
|
|
223
163
|
}
|
|
224
164
|
}
|
|
165
|
+
const remapErrors = e => {
|
|
166
|
+
if (e) {
|
|
167
|
+
switch (e.statusCode) {
|
|
168
|
+
case SW_DENY:
|
|
169
|
+
return new StellarUserRefusedError("User refused the request", undefined, { cause: e });
|
|
170
|
+
case SW_DATA_PARSING_FAIL:
|
|
171
|
+
return new StellarDataParsingFailedError("Unable to parse the provided data", undefined, {
|
|
172
|
+
cause: e,
|
|
173
|
+
});
|
|
174
|
+
case SW_HASH_SIGNING_MODE_NOT_ENABLED:
|
|
175
|
+
return new StellarHashSigningNotEnabledError("Hash signing not allowed. Have you enabled it in the app settings?", undefined, { cause: e });
|
|
176
|
+
case SW_DATA_TOO_LARGE:
|
|
177
|
+
return new StellarDataTooLargeError("The provided data is too large for the device to process", undefined, { cause: e });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return e;
|
|
181
|
+
};
|
|
182
|
+
const pathToBuffer = (originalPath) => {
|
|
183
|
+
const path = originalPath
|
|
184
|
+
.split("/")
|
|
185
|
+
.map(value => (value.endsWith("'") || value.endsWith("h") ? value : `${value}'`))
|
|
186
|
+
.join("/");
|
|
187
|
+
const pathNums = BIPPath.fromString(path).toPathArray();
|
|
188
|
+
return serializePath(pathNums);
|
|
189
|
+
};
|
|
190
|
+
const serializePath = (path) => {
|
|
191
|
+
const buf = Buffer.alloc(1 + path.length * 4);
|
|
192
|
+
buf.writeUInt8(path.length, 0);
|
|
193
|
+
for (const [i, num] of path.entries()) {
|
|
194
|
+
buf.writeUInt32BE(num, 1 + i * 4);
|
|
195
|
+
}
|
|
196
|
+
return buf;
|
|
197
|
+
};
|
|
198
|
+
export * from "./errors";
|
|
225
199
|
//# sourceMappingURL=Str.js.map
|
package/lib-es/Str.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Str.js","sourceRoot":"","sources":["../src/Str.ts"],"names":[],"mappings":"AAiBA,OAAO,
|
|
1
|
+
{"version":3,"file":"Str.js","sourceRoot":"","sources":["../src/Str.ts"],"names":[],"mappings":";;;;;;;;;AAiBA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EACL,iCAAiC,EACjC,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAElB,MAAM,GAAG,GAAG,IAAI,CAAC;AACjB,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,cAAc,GAAG,IAAI,CAAC,CAAC,mBAAmB;AAChD,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,mBAAmB;AAE5C,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,aAAa,GAAG,IAAI,CAAC;AA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,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,IAAc,EAAE,EAAE;IACvC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC9C,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC/B,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACtC,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when hash signing is not enabled on the device.
|
|
3
|
+
*/
|
|
4
|
+
export declare const StellarHashSigningNotEnabledError: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when data parsing fails.
|
|
9
|
+
*
|
|
10
|
+
* For example, when parsing the transaction fails, this error is thrown.
|
|
11
|
+
*/
|
|
12
|
+
export declare const StellarDataParsingFailedError: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Error thrown when the user refuses the request on the device.
|
|
17
|
+
*/
|
|
18
|
+
export declare const StellarUserRefusedError: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Error thrown when the data is too large to be processed by the device.
|
|
23
|
+
*/
|
|
24
|
+
export declare const StellarDataTooLargeError: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}>;
|
|
27
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,iCAAiC;;EAE7C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B;;EAEzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB;;EAAoD,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;EAAqD,CAAC"}
|
package/lib-es/errors.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createCustomErrorClass } from "@ledgerhq/errors";
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when hash signing is not enabled on the device.
|
|
4
|
+
*/
|
|
5
|
+
export const StellarHashSigningNotEnabledError = createCustomErrorClass("StellarHashSigningNotEnabledError");
|
|
6
|
+
/**
|
|
7
|
+
* Error thrown when data parsing fails.
|
|
8
|
+
*
|
|
9
|
+
* For example, when parsing the transaction fails, this error is thrown.
|
|
10
|
+
*/
|
|
11
|
+
export const StellarDataParsingFailedError = createCustomErrorClass("StellarDataParsingFailedError");
|
|
12
|
+
/**
|
|
13
|
+
* Error thrown when the user refuses the request on the device.
|
|
14
|
+
*/
|
|
15
|
+
export const StellarUserRefusedError = createCustomErrorClass("StellarUserRefusedError");
|
|
16
|
+
/**
|
|
17
|
+
* Error thrown when the data is too large to be processed by the device.
|
|
18
|
+
*/
|
|
19
|
+
export const StellarDataTooLargeError = createCustomErrorClass("StellarDataTooLargeError");
|
|
20
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,sBAAsB,CACrE,mCAAmC,CACpC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,sBAAsB,CACjE,+BAA+B,CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAC,yBAAyB,CAAC,CAAC;AAEzF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC,0BAA0B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/hw-app-str",
|
|
3
|
-
"version": "6.29.0",
|
|
3
|
+
"version": "6.29.1-nightly.0",
|
|
4
4
|
"description": "Ledger Hardware Wallet Stellar Application API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -27,10 +27,9 @@
|
|
|
27
27
|
"types": "lib/Str.d.ts",
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"@ledgerhq/hw-transport": "^6.31.0"
|
|
30
|
+
"bip32-path": "^0.4.2",
|
|
31
|
+
"@ledgerhq/hw-transport": "^6.31.1-nightly.0",
|
|
32
|
+
"@ledgerhq/errors": "^6.18.0-nightly.0"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@types/jest": "^29.5.10",
|
|
@@ -41,7 +40,7 @@
|
|
|
41
40
|
"source-map-support": "^0.5.21",
|
|
42
41
|
"ts-jest": "^29.1.1",
|
|
43
42
|
"ts-node": "^10.4.0",
|
|
44
|
-
"@ledgerhq/hw-transport-mocker": "^6.29.0"
|
|
43
|
+
"@ledgerhq/hw-transport-mocker": "^6.29.1-nightly.0"
|
|
45
44
|
},
|
|
46
45
|
"gitHead": "dd0dea64b58e5a9125c8a422dcffd29e5ef6abec",
|
|
47
46
|
"scripts": {
|
|
@@ -49,6 +48,7 @@
|
|
|
49
48
|
"build": "tsc && tsc -m ES6 --outDir lib-es",
|
|
50
49
|
"prewatch": "pnpm build",
|
|
51
50
|
"watch": "tsc --watch",
|
|
51
|
+
"doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
|
|
52
52
|
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
|
|
53
53
|
"lint:fix": "pnpm lint --fix",
|
|
54
54
|
"test": "jest",
|