@zondax/ledger-cosmos-js 2.1.8 → 3.0.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.
Files changed (54) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +39 -7
  3. package/dist/commandsV1.d.ts +4 -0
  4. package/dist/commandsV1.js +129 -0
  5. package/dist/commandsV1.js.map +1 -0
  6. package/dist/commandsV2.d.ts +4 -0
  7. package/dist/commandsV2.js +104 -0
  8. package/dist/commandsV2.js.map +1 -0
  9. package/dist/common.d.ts +39 -0
  10. package/dist/common.js +143 -132
  11. package/dist/common.js.map +1 -0
  12. package/dist/cosmosApp.d.ts +19 -0
  13. package/dist/cosmosApp.js +377 -0
  14. package/dist/cosmosApp.js.map +1 -0
  15. package/dist/index.d.ts +16 -0
  16. package/dist/index.js +17 -608
  17. package/dist/index.js.map +1 -0
  18. package/package.json +64 -50
  19. package/yarn.lock +6661 -0
  20. package/.babelrc +0 -13
  21. package/.circleci/config.yml +0 -62
  22. package/.editorconfig +0 -14
  23. package/.eslintrc.json +0 -31
  24. package/.idea/codeStyles/Project.xml +0 -57
  25. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  26. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  27. package/.idea/jsLibraryMappings.xml +0 -6
  28. package/.idea/ledger-cosmos-js.iml +0 -12
  29. package/.idea/modules.xml +0 -8
  30. package/.idea/vcs.xml +0 -6
  31. package/.idea/workspace.xml +0 -57
  32. package/.prettierrc.json +0 -4
  33. package/certs/.gitkeep +0 -0
  34. package/certs/openssl.cnf +0 -12
  35. package/dist/helperV1.js +0 -127
  36. package/dist/helperV2.js +0 -97
  37. package/docs/example.png +0 -0
  38. package/jest.config.integration.js +0 -9
  39. package/jest.config.js +0 -32
  40. package/jest.config.unit.js +0 -9
  41. package/public/favicon.ico +0 -0
  42. package/public/index.html +0 -17
  43. package/src/common.js +0 -114
  44. package/src/helperV1.js +0 -73
  45. package/src/helperV2.js +0 -44
  46. package/src/index.js +0 -336
  47. package/tests/basic.ispec.js +0 -390
  48. package/tests/basic.spec.js +0 -8
  49. package/tests/jest.js +0 -2
  50. package/vue.config.js +0 -11
  51. package/vue_example/App.vue +0 -29
  52. package/vue_example/assets/logo.png +0 -0
  53. package/vue_example/components/LedgerExample.vue +0 -252
  54. package/vue_example/main.js +0 -9
package/dist/index.js CHANGED
@@ -1,35 +1,6 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _crypto = _interopRequireDefault(require("crypto"));
19
-
20
- var _ripemd = _interopRequireDefault(require("ripemd160"));
21
-
22
- var _bech = _interopRequireDefault(require("bech32"));
23
-
24
- var _helperV = require("./helperV1");
25
-
26
- var _helperV2 = require("./helperV2");
27
-
28
- var _common = require("./common");
29
-
30
2
  /** ******************************************************************************
31
- * (c) 2019 ZondaX GmbH
32
- * (c) 2016-2017 Ledger
3
+ * (c) 2018 - 2022 Zondax AG
33
4
  *
34
5
  * Licensed under the Apache License, Version 2.0 (the "License");
35
6
  * you may not use this file except in compliance with the License.
@@ -43,582 +14,20 @@ var _common = require("./common");
43
14
  * See the License for the specific language governing permissions and
44
15
  * limitations under the License.
45
16
  ******************************************************************************* */
46
- var CosmosApp = /*#__PURE__*/function () {
47
- function CosmosApp(transport) {
48
- var scrambleKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _common.APP_KEY;
49
- (0, _classCallCheck2.default)(this, CosmosApp);
50
-
51
- if (!transport) {
52
- throw new Error("Transport has not been defined");
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
53
22
  }
54
-
55
- this.transport = transport;
56
- transport.decorateAppAPIMethods(this, ["getVersion", "sign", "getAddressAndPubKey", "appInfo", "deviceInfo", "getBech32FromPK"], scrambleKey);
57
- }
58
-
59
- (0, _createClass2.default)(CosmosApp, [{
60
- key: "serializePath",
61
- value: function () {
62
- var _serializePath = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(path) {
63
- return _regenerator.default.wrap(function _callee$(_context) {
64
- while (1) {
65
- switch (_context.prev = _context.next) {
66
- case 0:
67
- _context.next = 2;
68
- return (0, _common.getVersion)(this.transport);
69
-
70
- case 2:
71
- this.versionResponse = _context.sent;
72
-
73
- if (!(this.versionResponse.return_code !== _common.ERROR_CODE.NoError)) {
74
- _context.next = 5;
75
- break;
76
- }
77
-
78
- throw this.versionResponse;
79
-
80
- case 5:
81
- _context.t0 = this.versionResponse.major;
82
- _context.next = _context.t0 === 1 ? 8 : _context.t0 === 2 ? 9 : 10;
83
- break;
84
-
85
- case 8:
86
- return _context.abrupt("return", (0, _helperV.serializePathv1)(path));
87
-
88
- case 9:
89
- return _context.abrupt("return", (0, _helperV2.serializePathv2)(path));
90
-
91
- case 10:
92
- return _context.abrupt("return", {
93
- return_code: 0x6400,
94
- error_message: "App Version is not supported"
95
- });
96
-
97
- case 11:
98
- case "end":
99
- return _context.stop();
100
- }
101
- }
102
- }, _callee, this);
103
- }));
104
-
105
- function serializePath(_x) {
106
- return _serializePath.apply(this, arguments);
107
- }
108
-
109
- return serializePath;
110
- }()
111
- }, {
112
- key: "signGetChunks",
113
- value: function () {
114
- var _signGetChunks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(path, message) {
115
- var serializedPath, chunks, buffer, i, end;
116
- return _regenerator.default.wrap(function _callee2$(_context2) {
117
- while (1) {
118
- switch (_context2.prev = _context2.next) {
119
- case 0:
120
- _context2.next = 2;
121
- return this.serializePath(path);
122
-
123
- case 2:
124
- serializedPath = _context2.sent;
125
- chunks = [];
126
- chunks.push(serializedPath);
127
- buffer = Buffer.from(message);
128
-
129
- for (i = 0; i < buffer.length; i += _common.CHUNK_SIZE) {
130
- end = i + _common.CHUNK_SIZE;
131
-
132
- if (i > buffer.length) {
133
- end = buffer.length;
134
- }
135
-
136
- chunks.push(buffer.slice(i, end));
137
- }
138
-
139
- return _context2.abrupt("return", chunks);
140
-
141
- case 8:
142
- case "end":
143
- return _context2.stop();
144
- }
145
- }
146
- }, _callee2, this);
147
- }));
148
-
149
- function signGetChunks(_x2, _x3) {
150
- return _signGetChunks.apply(this, arguments);
151
- }
152
-
153
- return signGetChunks;
154
- }()
155
- }, {
156
- key: "getVersion",
157
- value: function () {
158
- var _getVersion2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
159
- return _regenerator.default.wrap(function _callee3$(_context3) {
160
- while (1) {
161
- switch (_context3.prev = _context3.next) {
162
- case 0:
163
- _context3.prev = 0;
164
- _context3.next = 3;
165
- return (0, _common.getVersion)(this.transport);
166
-
167
- case 3:
168
- this.versionResponse = _context3.sent;
169
- return _context3.abrupt("return", this.versionResponse);
170
-
171
- case 7:
172
- _context3.prev = 7;
173
- _context3.t0 = _context3["catch"](0);
174
- return _context3.abrupt("return", (0, _common.processErrorResponse)(_context3.t0));
175
-
176
- case 10:
177
- case "end":
178
- return _context3.stop();
179
- }
180
- }
181
- }, _callee3, this, [[0, 7]]);
182
- }));
183
-
184
- function getVersion() {
185
- return _getVersion2.apply(this, arguments);
186
- }
187
-
188
- return getVersion;
189
- }()
190
- }, {
191
- key: "appInfo",
192
- value: function () {
193
- var _appInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
194
- return _regenerator.default.wrap(function _callee4$(_context4) {
195
- while (1) {
196
- switch (_context4.prev = _context4.next) {
197
- case 0:
198
- return _context4.abrupt("return", this.transport.send(0xb0, 0x01, 0, 0).then(function (response) {
199
- var errorCodeData = response.slice(-2);
200
- var returnCode = errorCodeData[0] * 256 + errorCodeData[1];
201
- var result = {};
202
- var appName = "err";
203
- var appVersion = "err";
204
- var flagLen = 0;
205
- var flagsValue = 0;
206
-
207
- if (response[0] !== 1) {
208
- // Ledger responds with format ID 1. There is no spec for any format != 1
209
- result.error_message = "response format ID not recognized";
210
- result.return_code = 0x9001;
211
- } else {
212
- var appNameLen = response[1];
213
- appName = response.slice(2, 2 + appNameLen).toString("ascii");
214
- var idx = 2 + appNameLen;
215
- var appVersionLen = response[idx];
216
- idx += 1;
217
- appVersion = response.slice(idx, idx + appVersionLen).toString("ascii");
218
- idx += appVersionLen;
219
- var appFlagsLen = response[idx];
220
- idx += 1;
221
- flagLen = appFlagsLen;
222
- flagsValue = response[idx];
223
- }
224
-
225
- return {
226
- return_code: returnCode,
227
- error_message: (0, _common.errorCodeToString)(returnCode),
228
- // //
229
- appName: appName,
230
- appVersion: appVersion,
231
- flagLen: flagLen,
232
- flagsValue: flagsValue,
233
- // eslint-disable-next-line no-bitwise
234
- flag_recovery: (flagsValue & 1) !== 0,
235
- // eslint-disable-next-line no-bitwise
236
- flag_signed_mcu_code: (flagsValue & 2) !== 0,
237
- // eslint-disable-next-line no-bitwise
238
- flag_onboarded: (flagsValue & 4) !== 0,
239
- // eslint-disable-next-line no-bitwise
240
- flag_pin_validated: (flagsValue & 128) !== 0
241
- };
242
- }, _common.processErrorResponse));
243
-
244
- case 1:
245
- case "end":
246
- return _context4.stop();
247
- }
248
- }
249
- }, _callee4, this);
250
- }));
251
-
252
- function appInfo() {
253
- return _appInfo.apply(this, arguments);
254
- }
255
-
256
- return appInfo;
257
- }()
258
- }, {
259
- key: "deviceInfo",
260
- value: function () {
261
- var _deviceInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
262
- return _regenerator.default.wrap(function _callee5$(_context5) {
263
- while (1) {
264
- switch (_context5.prev = _context5.next) {
265
- case 0:
266
- return _context5.abrupt("return", this.transport.send(0xe0, 0x01, 0, 0, Buffer.from([]), [_common.ERROR_CODE.NoError, 0x6e00]).then(function (response) {
267
- var errorCodeData = response.slice(-2);
268
- var returnCode = errorCodeData[0] * 256 + errorCodeData[1];
269
-
270
- if (returnCode === 0x6e00) {
271
- return {
272
- return_code: returnCode,
273
- error_message: "This command is only available in the Dashboard"
274
- };
275
- }
276
-
277
- var targetId = response.slice(0, 4).toString("hex");
278
- var pos = 4;
279
- var secureElementVersionLen = response[pos];
280
- pos += 1;
281
- var seVersion = response.slice(pos, pos + secureElementVersionLen).toString();
282
- pos += secureElementVersionLen;
283
- var flagsLen = response[pos];
284
- pos += 1;
285
- var flag = response.slice(pos, pos + flagsLen).toString("hex");
286
- pos += flagsLen;
287
- var mcuVersionLen = response[pos];
288
- pos += 1; // Patch issue in mcu version
289
-
290
- var tmp = response.slice(pos, pos + mcuVersionLen);
291
-
292
- if (tmp[mcuVersionLen - 1] === 0) {
293
- tmp = response.slice(pos, pos + mcuVersionLen - 1);
294
- }
295
-
296
- var mcuVersion = tmp.toString();
297
- return {
298
- return_code: returnCode,
299
- error_message: (0, _common.errorCodeToString)(returnCode),
300
- // //
301
- targetId: targetId,
302
- seVersion: seVersion,
303
- flag: flag,
304
- mcuVersion: mcuVersion
305
- };
306
- }, _common.processErrorResponse));
307
-
308
- case 1:
309
- case "end":
310
- return _context5.stop();
311
- }
312
- }
313
- }, _callee5, this);
314
- }));
315
-
316
- function deviceInfo() {
317
- return _deviceInfo.apply(this, arguments);
318
- }
319
-
320
- return deviceInfo;
321
- }()
322
- }, {
323
- key: "publicKey",
324
- value: function () {
325
- var _publicKey = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(path) {
326
- var serializedPath, data;
327
- return _regenerator.default.wrap(function _callee6$(_context6) {
328
- while (1) {
329
- switch (_context6.prev = _context6.next) {
330
- case 0:
331
- _context6.prev = 0;
332
- _context6.next = 3;
333
- return this.serializePath(path);
334
-
335
- case 3:
336
- serializedPath = _context6.sent;
337
- _context6.t0 = this.versionResponse.major;
338
- _context6.next = _context6.t0 === 1 ? 7 : _context6.t0 === 2 ? 8 : 10;
339
- break;
340
-
341
- case 7:
342
- return _context6.abrupt("return", (0, _helperV.publicKeyv1)(this, serializedPath));
343
-
344
- case 8:
345
- data = Buffer.concat([CosmosApp.serializeHRP("cosmos"), serializedPath]);
346
- return _context6.abrupt("return", (0, _helperV2.publicKeyv2)(this, data));
347
-
348
- case 10:
349
- return _context6.abrupt("return", {
350
- return_code: 0x6400,
351
- error_message: "App Version is not supported"
352
- });
353
-
354
- case 11:
355
- _context6.next = 16;
356
- break;
357
-
358
- case 13:
359
- _context6.prev = 13;
360
- _context6.t1 = _context6["catch"](0);
361
- return _context6.abrupt("return", (0, _common.processErrorResponse)(_context6.t1));
362
-
363
- case 16:
364
- case "end":
365
- return _context6.stop();
366
- }
367
- }
368
- }, _callee6, this, [[0, 13]]);
369
- }));
370
-
371
- function publicKey(_x4) {
372
- return _publicKey.apply(this, arguments);
373
- }
374
-
375
- return publicKey;
376
- }()
377
- }, {
378
- key: "getAddressAndPubKey",
379
- value: function () {
380
- var _getAddressAndPubKey = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(path, hrp) {
381
- var _this = this;
382
-
383
- return _regenerator.default.wrap(function _callee7$(_context7) {
384
- while (1) {
385
- switch (_context7.prev = _context7.next) {
386
- case 0:
387
- _context7.prev = 0;
388
- return _context7.abrupt("return", this.serializePath(path).then(function (serializedPath) {
389
- var data = Buffer.concat([CosmosApp.serializeHRP(hrp), serializedPath]);
390
- return _this.transport.send(_common.CLA, _common.INS.GET_ADDR_SECP256K1, _common.P1_VALUES.ONLY_RETRIEVE, 0, data, [_common.ERROR_CODE.NoError]).then(function (response) {
391
- var errorCodeData = response.slice(-2);
392
- var returnCode = errorCodeData[0] * 256 + errorCodeData[1];
393
- var compressedPk = Buffer.from(response.slice(0, 33));
394
- var bech32Address = Buffer.from(response.slice(33, -2)).toString();
395
- return {
396
- bech32_address: bech32Address,
397
- compressed_pk: compressedPk,
398
- return_code: returnCode,
399
- error_message: (0, _common.errorCodeToString)(returnCode)
400
- };
401
- }, _common.processErrorResponse);
402
- }).catch(function (err) {
403
- return (0, _common.processErrorResponse)(err);
404
- }));
405
-
406
- case 4:
407
- _context7.prev = 4;
408
- _context7.t0 = _context7["catch"](0);
409
- return _context7.abrupt("return", (0, _common.processErrorResponse)(_context7.t0));
410
-
411
- case 7:
412
- case "end":
413
- return _context7.stop();
414
- }
415
- }
416
- }, _callee7, this, [[0, 4]]);
417
- }));
418
-
419
- function getAddressAndPubKey(_x5, _x6) {
420
- return _getAddressAndPubKey.apply(this, arguments);
421
- }
422
-
423
- return getAddressAndPubKey;
424
- }()
425
- }, {
426
- key: "showAddressAndPubKey",
427
- value: function () {
428
- var _showAddressAndPubKey = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(path, hrp) {
429
- var _this2 = this;
430
-
431
- return _regenerator.default.wrap(function _callee8$(_context8) {
432
- while (1) {
433
- switch (_context8.prev = _context8.next) {
434
- case 0:
435
- _context8.prev = 0;
436
- return _context8.abrupt("return", this.serializePath(path).then(function (serializedPath) {
437
- var data = Buffer.concat([CosmosApp.serializeHRP(hrp), serializedPath]);
438
- return _this2.transport.send(_common.CLA, _common.INS.GET_ADDR_SECP256K1, _common.P1_VALUES.SHOW_ADDRESS_IN_DEVICE, 0, data, [_common.ERROR_CODE.NoError]).then(function (response) {
439
- var errorCodeData = response.slice(-2);
440
- var returnCode = errorCodeData[0] * 256 + errorCodeData[1];
441
- var compressedPk = Buffer.from(response.slice(0, 33));
442
- var bech32Address = Buffer.from(response.slice(33, -2)).toString();
443
- return {
444
- bech32_address: bech32Address,
445
- compressed_pk: compressedPk,
446
- return_code: returnCode,
447
- error_message: (0, _common.errorCodeToString)(returnCode)
448
- };
449
- }, _common.processErrorResponse);
450
- }).catch(function (err) {
451
- return (0, _common.processErrorResponse)(err);
452
- }));
453
-
454
- case 4:
455
- _context8.prev = 4;
456
- _context8.t0 = _context8["catch"](0);
457
- return _context8.abrupt("return", (0, _common.processErrorResponse)(_context8.t0));
458
-
459
- case 7:
460
- case "end":
461
- return _context8.stop();
462
- }
463
- }
464
- }, _callee8, this, [[0, 4]]);
465
- }));
466
-
467
- function showAddressAndPubKey(_x7, _x8) {
468
- return _showAddressAndPubKey.apply(this, arguments);
469
- }
470
-
471
- return showAddressAndPubKey;
472
- }()
473
- }, {
474
- key: "signSendChunk",
475
- value: function () {
476
- var _signSendChunk = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(chunkIdx, chunkNum, chunk) {
477
- return _regenerator.default.wrap(function _callee9$(_context9) {
478
- while (1) {
479
- switch (_context9.prev = _context9.next) {
480
- case 0:
481
- _context9.t0 = this.versionResponse.major;
482
- _context9.next = _context9.t0 === 1 ? 3 : _context9.t0 === 2 ? 4 : 5;
483
- break;
484
-
485
- case 3:
486
- return _context9.abrupt("return", (0, _helperV.signSendChunkv1)(this, chunkIdx, chunkNum, chunk));
487
-
488
- case 4:
489
- return _context9.abrupt("return", (0, _helperV2.signSendChunkv2)(this, chunkIdx, chunkNum, chunk));
490
-
491
- case 5:
492
- return _context9.abrupt("return", {
493
- return_code: 0x6400,
494
- error_message: "App Version is not supported"
495
- });
496
-
497
- case 6:
498
- case "end":
499
- return _context9.stop();
500
- }
501
- }
502
- }, _callee9, this);
503
- }));
504
-
505
- function signSendChunk(_x9, _x10, _x11) {
506
- return _signSendChunk.apply(this, arguments);
507
- }
508
-
509
- return signSendChunk;
510
- }()
511
- }, {
512
- key: "sign",
513
- value: function () {
514
- var _sign = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(path, message) {
515
- var _this3 = this;
516
-
517
- return _regenerator.default.wrap(function _callee11$(_context11) {
518
- while (1) {
519
- switch (_context11.prev = _context11.next) {
520
- case 0:
521
- return _context11.abrupt("return", this.signGetChunks(path, message).then(function (chunks) {
522
- return _this3.signSendChunk(1, chunks.length, chunks[0], [_common.ERROR_CODE.NoError]).then( /*#__PURE__*/function () {
523
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(response) {
524
- var result, i;
525
- return _regenerator.default.wrap(function _callee10$(_context10) {
526
- while (1) {
527
- switch (_context10.prev = _context10.next) {
528
- case 0:
529
- result = {
530
- return_code: response.return_code,
531
- error_message: response.error_message,
532
- signature: null
533
- };
534
- i = 1;
535
-
536
- case 2:
537
- if (!(i < chunks.length)) {
538
- _context10.next = 11;
539
- break;
540
- }
541
-
542
- _context10.next = 5;
543
- return _this3.signSendChunk(1 + i, chunks.length, chunks[i]);
544
-
545
- case 5:
546
- result = _context10.sent;
547
-
548
- if (!(result.return_code !== _common.ERROR_CODE.NoError)) {
549
- _context10.next = 8;
550
- break;
551
- }
552
-
553
- return _context10.abrupt("break", 11);
554
-
555
- case 8:
556
- i += 1;
557
- _context10.next = 2;
558
- break;
559
-
560
- case 11:
561
- return _context10.abrupt("return", {
562
- return_code: result.return_code,
563
- error_message: result.error_message,
564
- // ///
565
- signature: result.signature
566
- });
567
-
568
- case 12:
569
- case "end":
570
- return _context10.stop();
571
- }
572
- }
573
- }, _callee10);
574
- }));
575
-
576
- return function (_x14) {
577
- return _ref.apply(this, arguments);
578
- };
579
- }(), _common.processErrorResponse);
580
- }, _common.processErrorResponse));
581
-
582
- case 1:
583
- case "end":
584
- return _context11.stop();
585
- }
586
- }
587
- }, _callee11, this);
588
- }));
589
-
590
- function sign(_x12, _x13) {
591
- return _sign.apply(this, arguments);
592
- }
593
-
594
- return sign;
595
- }()
596
- }], [{
597
- key: "serializeHRP",
598
- value: function serializeHRP(hrp) {
599
- if (hrp == null || hrp.length < 3 || hrp.length > 83) {
600
- throw new Error("Invalid HRP");
601
- }
602
-
603
- var buf = Buffer.alloc(1 + hrp.length);
604
- buf.writeUInt8(hrp.length, 0);
605
- buf.write(hrp, 1);
606
- return buf;
607
- }
608
- }, {
609
- key: "getBech32FromPK",
610
- value: function getBech32FromPK(hrp, pk) {
611
- if (pk.length !== 33) {
612
- throw new Error("expected compressed public key [31 bytes]");
613
- }
614
-
615
- var hashSha256 = _crypto.default.createHash("sha256").update(pk).digest();
616
-
617
- var hashRip = new _ripemd.default().update(hashSha256).digest();
618
- return _bech.default.encode(hrp, _bech.default.toWords(hashRip));
619
- }
620
- }]);
621
- return CosmosApp;
622
- }();
623
-
624
- exports.default = CosmosApp;
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
+ };
31
+ exports.__esModule = true;
32
+ __exportStar(require("./cosmosApp"), exports);
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;mFAcmF;;;;;;;;;;;;;;;;AAEnF,8CAA2B","sourcesContent":["/** ******************************************************************************\n * (c) 2018 - 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ******************************************************************************* */\n\nexport * from './cosmosApp'\n"]}