@ledgerhq/hw-app-str 6.29.0-windows-certificate.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/lib/Str.js CHANGED
@@ -1,28 +1,56 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
2
28
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("./utils");
29
+ const bip32_path_1 = __importDefault(require("bip32-path"));
30
+ const errors_1 = require("./errors");
4
31
  const CLA = 0xe0;
32
+ const P1_FIRST = 0x00;
33
+ const P1_MORE = 0x80;
34
+ const P2_LAST = 0x00;
35
+ const P2_MORE = 0x80;
36
+ const P2_NON_CONFIRM = 0x00; // for getPublicKey
37
+ const P2_CONFIRM = 0x01; // for getPublicKey
5
38
  const INS_GET_PK = 0x02;
6
39
  const INS_SIGN_TX = 0x04;
7
40
  const INS_GET_CONF = 0x06;
8
- const INS_SIGN_TX_HASH = 0x08;
9
- const INS_KEEP_ALIVE = 0x10;
10
- const APDU_MAX_SIZE = 150;
11
- const P1_FIRST_APDU = 0x00;
12
- const P1_MORE_APDU = 0x80;
13
- const P2_LAST_APDU = 0x00;
14
- const P2_MORE_APDU = 0x80;
15
- const SW_OK = 0x9000;
16
- const SW_CANCEL = 0x6985;
17
- const SW_UNKNOWN_OP = 0x6c24;
18
- const SW_MULTI_OP = 0x6c25;
19
- const SW_NOT_ALLOWED = 0x6c66;
20
- const SW_UNSUPPORTED = 0x6d00;
21
- const SW_KEEP_ALIVE = 0x6e02;
22
- const TX_MAX_SIZE = 1540;
41
+ const INS_SIGN_HASH = 0x08;
42
+ const INS_SIGN_SOROBAN_AUTHORIZATION = 0x0a;
43
+ const APDU_MAX_PAYLOAD = 255;
44
+ const SW_DENY = 0x6985;
45
+ const SW_HASH_SIGNING_MODE_NOT_ENABLED = 0x6c66;
46
+ const SW_DATA_TOO_LARGE = 0xb004;
47
+ const SW_DATA_PARSING_FAIL = 0xb005;
23
48
  /**
24
49
  * Stellar API
25
50
  *
51
+ * @param transport a transport for sending commands to a device
52
+ * @param scrambleKey a scramble key
53
+ *
26
54
  * @example
27
55
  * import Str from "@ledgerhq/hw-app-str";
28
56
  * const str = new Str(transport)
@@ -30,199 +58,162 @@ const TX_MAX_SIZE = 1540;
30
58
  class Str {
31
59
  constructor(transport, scrambleKey = "l0v") {
32
60
  this.transport = transport;
33
- transport.decorateAppAPIMethods(this, ["getAppConfiguration", "getPublicKey", "signTransaction", "signHash"], scrambleKey);
61
+ transport.decorateAppAPIMethods(this, [
62
+ "getAppConfiguration",
63
+ "getPublicKey",
64
+ "signTransaction",
65
+ "signSorobanAuthorization",
66
+ "signHash",
67
+ ], scrambleKey);
34
68
  }
69
+ /**
70
+ * Get Stellar application configuration.
71
+ *
72
+ * @returns an object with the application configuration, including the version,
73
+ * whether hash signing is enabled, and the maximum data size in bytes that the device can sign.
74
+ * @example
75
+ * str.getAppConfiguration().then(o => o.version)
76
+ */
35
77
  getAppConfiguration() {
36
- return this.transport.send(CLA, INS_GET_CONF, 0x00, 0x00).then(response => {
37
- const multiOpsEnabled = response[0] === 0x01 || response[1] < 0x02;
38
- const version = "" + response[1] + "." + response[2] + "." + response[3];
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const resp = yield this.sendToDevice(INS_GET_CONF, Buffer.alloc(0));
80
+ const [hashSigningEnabled, major, minor, patch, maxDataSizeHi, maxDataSizeLo] = resp;
39
81
  return {
40
- version: version,
41
- multiOpsEnabled: multiOpsEnabled,
82
+ hashSigningEnabled: hashSigningEnabled === 0x01,
83
+ version: `${major}.${minor}.${patch}`,
84
+ maxDataSize: resp.length > 4 ? (maxDataSizeHi << 8) | maxDataSizeLo : undefined, // For compatibility with older app, let's remove this in the future
42
85
  };
43
86
  });
44
87
  }
45
88
  /**
46
- * get Stellar public key for a given BIP 32 path.
89
+ * Get Stellar raw public key for a given BIP 32 path.
90
+ *
47
91
  * @param path a path in BIP 32 format
48
- * @option boolValidate optionally enable key pair validation
49
- * @option boolDisplay optionally enable or not the display
50
- * @return an object with the publicKey (using XLM public key format) and
51
- * the raw ed25519 public key.
92
+ * @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
93
+ * @return an object with the raw ed25519 public key.
94
+ * If you want to convert it to string, you can use {@link https://stellar.github.io/js-stellar-base/StrKey.html#.encodeEd25519PublicKey StrKey.encodeEd25519PublicKey}
52
95
  * @example
53
- * str.getPublicKey("44'/148'/0'").then(o => o.publicKey)
96
+ * str.getPublicKey("44'/148'/0'").then(o => o.rawPublicKey)
54
97
  */
55
- getPublicKey(path, boolValidate, boolDisplay) {
56
- (0, utils_1.checkStellarBip32Path)(path);
57
- const apdus = [];
58
- let response;
59
- const pathElts = (0, utils_1.splitPath)(path);
60
- const buffer = Buffer.alloc(1 + pathElts.length * 4);
61
- buffer[0] = pathElts.length;
62
- pathElts.forEach((element, index) => {
63
- buffer.writeUInt32BE(element, 1 + 4 * index);
64
- });
65
- const verifyMsg = Buffer.from("via lumina", "ascii");
66
- apdus.push(Buffer.concat([buffer, verifyMsg]));
67
- let keepAlive = false;
68
- return (0, utils_1.foreach)(apdus, data => this.transport
69
- .send(CLA, keepAlive ? INS_KEEP_ALIVE : INS_GET_PK, boolValidate ? 0x01 : 0x00, boolDisplay ? 0x01 : 0x00, data, [SW_OK, SW_KEEP_ALIVE])
70
- .then(apduResponse => {
71
- const status = Buffer.from(apduResponse.slice(apduResponse.length - 2)).readUInt16BE(0);
72
- if (status === SW_KEEP_ALIVE) {
73
- keepAlive = true;
74
- apdus.push(Buffer.alloc(0));
98
+ getPublicKey(path_1) {
99
+ return __awaiter(this, arguments, void 0, function* (path, display = false) {
100
+ const pathBuffer = pathToBuffer(path);
101
+ const p2 = display ? P2_CONFIRM : P2_NON_CONFIRM;
102
+ try {
103
+ const data = yield this.transport.send(CLA, INS_GET_PK, P1_FIRST, p2, pathBuffer);
104
+ return { rawPublicKey: data.slice(0, -2) };
75
105
  }
76
- response = apduResponse;
77
- })).then(() => {
78
- // response = Buffer.from(response, 'hex');
79
- let offset = 0;
80
- const rawPublicKey = response.slice(offset, offset + 32);
81
- offset += 32;
82
- const publicKey = (0, utils_1.encodeEd25519PublicKey)(rawPublicKey);
83
- if (boolValidate) {
84
- const signature = response.slice(offset, offset + 64);
85
- if (!(0, utils_1.verifyEd25519Signature)(verifyMsg, signature, rawPublicKey)) {
86
- throw new Error("Bad signature. Keypair is invalid. Please report this.");
87
- }
106
+ catch (e) {
107
+ throw remapErrors(e);
88
108
  }
89
- return {
90
- publicKey: publicKey,
91
- raw: rawPublicKey,
92
- };
93
109
  });
94
110
  }
95
111
  /**
96
- * sign a Stellar transaction.
112
+ * Sign a Stellar transaction.
113
+ *
97
114
  * @param path a path in BIP 32 format
98
- * @param transaction signature base of the transaction to sign
99
- * @return an object with the signature and the status
115
+ * @param transaction {@link https://stellar.github.io/js-stellar-base/Transaction.html#signatureBase signature base} of the transaction to sign
116
+ * @return an object with the signature
100
117
  * @example
101
118
  * str.signTransaction("44'/148'/0'", signatureBase).then(o => o.signature)
102
119
  */
103
120
  signTransaction(path, transaction) {
104
- (0, utils_1.checkStellarBip32Path)(path);
105
- if (transaction.length > TX_MAX_SIZE) {
106
- throw new Error("Transaction too large: max = " + TX_MAX_SIZE + "; actual = " + transaction.length);
107
- }
108
- const apdus = [];
109
- let response;
110
- const pathElts = (0, utils_1.splitPath)(path);
111
- const bufferSize = 1 + pathElts.length * 4;
112
- const buffer = Buffer.alloc(bufferSize);
113
- buffer[0] = pathElts.length;
114
- pathElts.forEach(function (element, index) {
115
- buffer.writeUInt32BE(element, 1 + 4 * index);
121
+ return __awaiter(this, void 0, void 0, function* () {
122
+ const pathBuffer = pathToBuffer(path);
123
+ const payload = Buffer.concat([pathBuffer, transaction]);
124
+ const resp = yield this.sendToDevice(INS_SIGN_TX, payload);
125
+ return { signature: resp };
116
126
  });
117
- let chunkSize = APDU_MAX_SIZE - bufferSize;
118
- if (transaction.length <= chunkSize) {
119
- // it fits in a single apdu
120
- apdus.push(Buffer.concat([buffer, transaction]));
121
- }
122
- else {
123
- // we need to send multiple apdus to transmit the entire transaction
124
- let chunk = Buffer.alloc(chunkSize);
125
- let offset = 0;
126
- transaction.copy(chunk, 0, offset, chunkSize);
127
- apdus.push(Buffer.concat([buffer, chunk]));
128
- offset += chunkSize;
129
- while (offset < transaction.length) {
130
- const remaining = transaction.length - offset;
131
- chunkSize = remaining < APDU_MAX_SIZE ? remaining : APDU_MAX_SIZE;
132
- chunk = Buffer.alloc(chunkSize);
133
- transaction.copy(chunk, 0, offset, offset + chunkSize);
134
- offset += chunkSize;
135
- apdus.push(chunk);
136
- }
137
- }
138
- let keepAlive = false;
139
- return (0, utils_1.foreach)(apdus, (data, i) => this.transport
140
- .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])
141
- .then(apduResponse => {
142
- const status = Buffer.from(apduResponse.slice(apduResponse.length - 2)).readUInt16BE(0);
143
- if (status === SW_KEEP_ALIVE) {
144
- keepAlive = true;
145
- apdus.push(Buffer.alloc(0));
146
- }
147
- response = apduResponse;
148
- })).then(() => {
149
- const status = Buffer.from(response.slice(response.length - 2)).readUInt16BE(0);
150
- if (status === SW_OK) {
151
- const signature = Buffer.from(response.slice(0, response.length - 2));
152
- return {
153
- signature: signature,
154
- };
155
- }
156
- else if (status === SW_UNKNOWN_OP) {
157
- // pre-v2 app version: fall back on hash signing
158
- return this.signHash_private(path, (0, utils_1.hash)(transaction));
159
- }
160
- else if (status === SW_MULTI_OP) {
161
- // multi-operation transaction: attempt hash signing
162
- return this.signHash_private(path, (0, utils_1.hash)(transaction));
163
- }
164
- else {
165
- throw new Error("Transaction approval request was rejected");
166
- }
127
+ }
128
+ /**
129
+ * Sign a Stellar Soroban authorization.
130
+ *
131
+ * @param path a path in BIP 32 format
132
+ * @param hashIdPreimage the {@link https://github.com/stellar/stellar-xdr/blob/1a04392432dacc0092caaeae22a600ea1af3c6a5/Stellar-transaction.x#L702-L709 Soroban authorization hashIdPreimage} to sign
133
+ * @return an object with the signature
134
+ * @example
135
+ * str.signSorobanAuthorization("44'/148'/0'", hashIdPreimage).then(o => o.signature)
136
+ */
137
+ signSorobanAuthorization(path, hashIdPreimage) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ const pathBuffer = pathToBuffer(path);
140
+ const payload = Buffer.concat([pathBuffer, hashIdPreimage]);
141
+ const resp = yield this.sendToDevice(INS_SIGN_SOROBAN_AUTHORIZATION, payload);
142
+ return { signature: resp };
167
143
  });
168
144
  }
169
145
  /**
170
- * sign a Stellar transaction hash.
146
+ * Sign a hash.
147
+ *
171
148
  * @param path a path in BIP 32 format
172
- * @param hash hash of the transaction to sign
149
+ * @param hash the hash to sign
173
150
  * @return an object with the signature
174
151
  * @example
175
152
  * str.signHash("44'/148'/0'", hash).then(o => o.signature)
176
153
  */
177
154
  signHash(path, hash) {
178
- (0, utils_1.checkStellarBip32Path)(path);
179
- return this.signHash_private(path, hash);
180
- }
181
- signHash_private(path, hash) {
182
- const apdus = [];
183
- let response;
184
- const pathElts = (0, utils_1.splitPath)(path);
185
- const buffer = Buffer.alloc(1 + pathElts.length * 4);
186
- buffer[0] = pathElts.length;
187
- pathElts.forEach(function (element, index) {
188
- buffer.writeUInt32BE(element, 1 + 4 * index);
155
+ return __awaiter(this, void 0, void 0, function* () {
156
+ const pathBuffer = pathToBuffer(path);
157
+ const payload = Buffer.concat([pathBuffer, hash]);
158
+ const resp = yield this.sendToDevice(INS_SIGN_HASH, payload);
159
+ return { signature: resp };
189
160
  });
190
- apdus.push(Buffer.concat([buffer, hash]));
191
- let keepAlive = false;
192
- return (0, utils_1.foreach)(apdus, data => this.transport
193
- .send(CLA, keepAlive ? INS_KEEP_ALIVE : INS_SIGN_TX_HASH, 0x00, 0x00, data, [
194
- SW_OK,
195
- SW_CANCEL,
196
- SW_NOT_ALLOWED,
197
- SW_UNSUPPORTED,
198
- SW_KEEP_ALIVE,
199
- ])
200
- .then(apduResponse => {
201
- const status = Buffer.from(apduResponse.slice(apduResponse.length - 2)).readUInt16BE(0);
202
- if (status === SW_KEEP_ALIVE) {
203
- keepAlive = true;
204
- apdus.push(Buffer.alloc(0));
205
- }
206
- response = apduResponse;
207
- })).then(() => {
208
- const status = Buffer.from(response.slice(response.length - 2)).readUInt16BE(0);
209
- if (status === SW_OK) {
210
- const signature = Buffer.from(response.slice(0, response.length - 2));
211
- return {
212
- signature: signature,
213
- };
214
- }
215
- else if (status === SW_CANCEL) {
216
- throw new Error("Transaction approval request was rejected");
217
- }
218
- else if (status === SW_UNSUPPORTED) {
219
- throw new Error("Hash signing is not supported");
220
- }
221
- else {
222
- throw new Error("Hash signing not allowed. Have you enabled it in the app settings?");
161
+ }
162
+ sendToDevice(instruction, payload) {
163
+ return __awaiter(this, void 0, void 0, function* () {
164
+ let response = Buffer.alloc(0);
165
+ let remaining = payload.length;
166
+ // eslint-disable-next-line no-constant-condition
167
+ while (true) {
168
+ const chunkSize = remaining > APDU_MAX_PAYLOAD ? APDU_MAX_PAYLOAD : remaining;
169
+ const p1 = remaining === payload.length ? P1_FIRST : P1_MORE;
170
+ const p2 = remaining - chunkSize === 0 ? P2_LAST : P2_MORE;
171
+ const chunk = payload.slice(payload.length - remaining, payload.length - remaining + chunkSize);
172
+ response = yield this.transport.send(CLA, instruction, p1, p2, chunk).catch(e => {
173
+ throw remapErrors(e);
174
+ });
175
+ remaining -= chunkSize;
176
+ if (remaining === 0) {
177
+ break;
178
+ }
223
179
  }
180
+ return response.slice(0, -2);
224
181
  });
225
182
  }
226
183
  }
227
184
  exports.default = Str;
185
+ const remapErrors = e => {
186
+ if (e) {
187
+ switch (e.statusCode) {
188
+ case SW_DENY:
189
+ return new errors_1.StellarUserRefusedError("User refused the request", undefined, { cause: e });
190
+ case SW_DATA_PARSING_FAIL:
191
+ return new errors_1.StellarDataParsingFailedError("Unable to parse the provided data", undefined, {
192
+ cause: e,
193
+ });
194
+ case SW_HASH_SIGNING_MODE_NOT_ENABLED:
195
+ return new errors_1.StellarHashSigningNotEnabledError("Hash signing not allowed. Have you enabled it in the app settings?", undefined, { cause: e });
196
+ case SW_DATA_TOO_LARGE:
197
+ return new errors_1.StellarDataTooLargeError("The provided data is too large for the device to process", undefined, { cause: e });
198
+ }
199
+ }
200
+ return e;
201
+ };
202
+ const pathToBuffer = (originalPath) => {
203
+ const path = originalPath
204
+ .split("/")
205
+ .map(value => (value.endsWith("'") || value.endsWith("h") ? value : `${value}'`))
206
+ .join("/");
207
+ const pathNums = bip32_path_1.default.fromString(path).toPathArray();
208
+ return serializePath(pathNums);
209
+ };
210
+ const serializePath = (path) => {
211
+ const buf = Buffer.alloc(1 + path.length * 4);
212
+ buf.writeUInt8(path.length, 0);
213
+ for (const [i, num] of path.entries()) {
214
+ buf.writeUInt32BE(num, 1 + i * 4);
215
+ }
216
+ return buf;
217
+ };
218
+ __exportStar(require("./errors"), exports);
228
219
  //# sourceMappingURL=Str.js.map
package/lib/Str.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Str.js","sourceRoot":"","sources":["../src/Str.ts"],"names":[],"mappings":";;AAiBA,mCAOiB;AACjB,MAAM,GAAG,GAAG,IAAI,CAAC;AACjB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,KAAK,GAAG,MAAM,CAAC;AACrB,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB;;;;;;GAMG;AAEH,MAAqB,GAAG;IAGtB,YAAY,SAAoB,EAAE,WAAW,GAAG,KAAK;QACnD,IA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*/
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/errors.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StellarDataTooLargeError = exports.StellarUserRefusedError = exports.StellarDataParsingFailedError = exports.StellarHashSigningNotEnabledError = void 0;
4
+ const errors_1 = require("@ledgerhq/errors");
5
+ /**
6
+ * Error thrown when hash signing is not enabled on the device.
7
+ */
8
+ exports.StellarHashSigningNotEnabledError = (0, errors_1.createCustomErrorClass)("StellarHashSigningNotEnabledError");
9
+ /**
10
+ * Error thrown when data parsing fails.
11
+ *
12
+ * For example, when parsing the transaction fails, this error is thrown.
13
+ */
14
+ exports.StellarDataParsingFailedError = (0, errors_1.createCustomErrorClass)("StellarDataParsingFailedError");
15
+ /**
16
+ * Error thrown when the user refuses the request on the device.
17
+ */
18
+ exports.StellarUserRefusedError = (0, errors_1.createCustomErrorClass)("StellarUserRefusedError");
19
+ /**
20
+ * Error thrown when the data is too large to be processed by the device.
21
+ */
22
+ exports.StellarDataTooLargeError = (0, errors_1.createCustomErrorClass)("StellarDataTooLargeError");
23
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,6CAA0D;AAE1D;;GAEG;AACU,QAAA,iCAAiC,GAAG,IAAA,+BAAsB,EACrE,mCAAmC,CACpC,CAAC;AAEF;;;;GAIG;AACU,QAAA,6BAA6B,GAAG,IAAA,+BAAsB,EACjE,+BAA+B,CAChC,CAAC;AAEF;;GAEG;AACU,QAAA,uBAAuB,GAAG,IAAA,+BAAsB,EAAC,yBAAyB,CAAC,CAAC;AAEzF;;GAEG;AACU,QAAA,wBAAwB,GAAG,IAAA,+BAAsB,EAAC,0BAA0B,CAAC,CAAC"}
package/lib-es/Str.d.ts CHANGED
@@ -19,35 +19,48 @@ import type Transport from "@ledgerhq/hw-transport";
19
19
  /**
20
20
  * Stellar API
21
21
  *
22
+ * @param transport a transport for sending commands to a device
23
+ * @param scrambleKey a scramble key
24
+ *
22
25
  * @example
23
26
  * import Str from "@ledgerhq/hw-app-str";
24
27
  * const str = new Str(transport)
25
28
  */
26
29
  export default class Str {
27
- transport: Transport;
30
+ private transport;
28
31
  constructor(transport: Transport, scrambleKey?: string);
32
+ /**
33
+ * Get Stellar application configuration.
34
+ *
35
+ * @returns an object with the application configuration, including the version,
36
+ * whether hash signing is enabled, and the maximum data size in bytes that the device can sign.
37
+ * @example
38
+ * str.getAppConfiguration().then(o => o.version)
39
+ */
29
40
  getAppConfiguration(): Promise<{
30
41
  version: string;
42
+ hashSigningEnabled: boolean;
43
+ maxDataSize?: number;
31
44
  }>;
32
45
  /**
33
- * get Stellar public key for a given BIP 32 path.
46
+ * Get Stellar raw public key for a given BIP 32 path.
47
+ *
34
48
  * @param path a path in BIP 32 format
35
- * @option boolValidate optionally enable key pair validation
36
- * @option boolDisplay optionally enable or not the display
37
- * @return an object with the publicKey (using XLM public key format) and
38
- * the raw ed25519 public key.
49
+ * @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
50
+ * @return an object with the raw ed25519 public key.
51
+ * If you want to convert it to string, you can use {@link https://stellar.github.io/js-stellar-base/StrKey.html#.encodeEd25519PublicKey StrKey.encodeEd25519PublicKey}
39
52
  * @example
40
- * str.getPublicKey("44'/148'/0'").then(o => o.publicKey)
53
+ * str.getPublicKey("44'/148'/0'").then(o => o.rawPublicKey)
41
54
  */
42
- getPublicKey(path: string, boolValidate?: boolean, boolDisplay?: boolean): Promise<{
43
- publicKey: string;
44
- raw: Buffer;
55
+ getPublicKey(path: string, display?: boolean): Promise<{
56
+ rawPublicKey: Buffer;
45
57
  }>;
46
58
  /**
47
- * sign a Stellar transaction.
59
+ * Sign a Stellar transaction.
60
+ *
48
61
  * @param path a path in BIP 32 format
49
- * @param transaction signature base of the transaction to sign
50
- * @return an object with the signature and the status
62
+ * @param transaction {@link https://stellar.github.io/js-stellar-base/Transaction.html#signatureBase signature base} of the transaction to sign
63
+ * @return an object with the signature
51
64
  * @example
52
65
  * str.signTransaction("44'/148'/0'", signatureBase).then(o => o.signature)
53
66
  */
@@ -55,18 +68,30 @@ export default class Str {
55
68
  signature: Buffer;
56
69
  }>;
57
70
  /**
58
- * sign a Stellar transaction hash.
71
+ * Sign a Stellar Soroban authorization.
72
+ *
59
73
  * @param path a path in BIP 32 format
60
- * @param hash hash of the transaction to sign
74
+ * @param hashIdPreimage the {@link https://github.com/stellar/stellar-xdr/blob/1a04392432dacc0092caaeae22a600ea1af3c6a5/Stellar-transaction.x#L702-L709 Soroban authorization hashIdPreimage} to sign
61
75
  * @return an object with the signature
62
76
  * @example
63
- * str.signHash("44'/148'/0'", hash).then(o => o.signature)
77
+ * str.signSorobanAuthorization("44'/148'/0'", hashIdPreimage).then(o => o.signature)
64
78
  */
65
- signHash(path: string, hash: Buffer): Promise<{
79
+ signSorobanAuthorization(path: string, hashIdPreimage: Buffer): Promise<{
66
80
  signature: Buffer;
67
81
  }>;
68
- signHash_private(path: string, hash: Buffer): Promise<{
82
+ /**
83
+ * Sign a hash.
84
+ *
85
+ * @param path a path in BIP 32 format
86
+ * @param hash the hash to sign
87
+ * @return an object with the signature
88
+ * @example
89
+ * str.signHash("44'/148'/0'", hash).then(o => o.signature)
90
+ */
91
+ signHash(path: string, hash: Buffer): Promise<{
69
92
  signature: Buffer;
70
93
  }>;
94
+ private sendToDevice;
71
95
  }
96
+ export * from "./errors";
72
97
  //# sourceMappingURL=Str.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Str.d.ts","sourceRoot":"","sources":["../src/Str.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;kFAekF;AAClF,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AA4BpD;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,SAAS,EAAE,SAAS,CAAC;gBAET,SAAS,EAAE,SAAS,EAAE,WAAW,SAAQ;IASrD,mBAAmB,IAAI,OAAO,CAAC;QAC7B,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAWF;;;;;;;;;OASG;IACH,YAAY,CACV,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,OAAO,EACtB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IAuDF;;;;;;;OAOG;IACH,eAAe,CACb,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,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