@zondax/ledger-cosmos-js 3.0.2 → 4.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.
package/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2018 - 2022 ZondaX AG
189
+ Copyright 2018 - 2023 Zondax AG
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -3,31 +3,27 @@
3
3
  ![zondax](docs/zondax_light.png)
4
4
 
5
5
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6
- [![Main](https://github.com/Zondax/ledger-cosmos-js/workflows/Main/badge.svg)](https://github.com/Zondax/ledger-cosmos-js/actions?query=workflow%3AMain)
7
- [![npm version](https://badge.fury.io/js/%40zondax%2Fledger-cosmos-js.svg)](https://badge.fury.io/js/%40zondax%2Fledger-cosmos-js)
8
-
6
+ [![Main](https://github.com/cosmos/ledger-cosmos-js/workflows/Main/badge.svg)](https://github.com/cosmos/ledger-cosmos-js/actions?query=workflow%3AMain)
7
+ [![npm version](https://badge.fury.io/js/%40cosmos%2Fledger-cosmos-js.svg)](https://badge.fury.io/js/%40cosmos%2Fledger-cosmos-js)
9
8
 
10
9
  This package provides a basic client library to communicate with a Tendermint/Cosmos App running in a Ledger Nano S/S+/X devices
11
10
 
12
11
  We recommend using the npmjs package in order to receive updates/fixes.
13
12
 
14
-
15
13
  # Available commands
16
14
 
17
- | Operation | Response | Command |
18
- | ---------- | ---------------- | ----------------------- |
19
- | getVersion | app version | --------------- |
20
- | publicKey | pubkey | path (legacy command) |
21
- | getAddressAndPubKey | pubkey + address | path + ( showInDevice ) |
22
- | showAddressAndPubKey | signed message | path |
23
- | appInfo | name, version, flags, etc | --------------- |
24
- | deviceInfo | fw and mcu version, id, etc | Only available in dashboard |
25
- | sign | signed message | path + transaction type + message |
15
+ | Operation | Response | Command |
16
+ | -------------------- | --------------------------- | --------------------------- |
17
+ | getVersion | app version | --------------- |
18
+ | publicKey | pubkey | path (legacy command) |
19
+ | getAddressAndPubKey | pubkey + address | path + ( showInDevice ) |
20
+ | showAddressAndPubKey | signed message | path |
21
+ | appInfo | name, version, flags, etc | --------------- |
22
+ | deviceInfo | fw and mcu version, id, etc | Only available in dashboard |
23
+ | sign | signed message | path + message + (HRP) |
26
24
 
27
25
  getAddress command requires that you set the derivation path (account, change, index) and has an option parameter to display the address on the device. By default, it will retrieve the information without user confirmation.
28
26
 
29
- sign command requires that you specify the transaction type, with one of the available types: 0 for json transaction or 1 for textual transaction.
30
-
31
27
  # Testing with real devices
32
28
 
33
29
  It is possible to test this package with a real Ledger Nano device. To accomplish that, you will need to follow these steps:
@@ -0,0 +1,25 @@
1
+ /** ******************************************************************************
2
+ * (c) 2018 - 2023 Zondax AG
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ ******************************************************************************* */
16
+ export declare const CLA = 85;
17
+ export declare const enum P1_VALUES {
18
+ ONLY_RETRIEVE = 0,
19
+ SHOW_ADDRESS_IN_DEVICE = 1
20
+ }
21
+ export declare const enum P2_VALUES {
22
+ JSON = 0,
23
+ TEXTUAL = 1
24
+ }
25
+ export declare const PKLEN = 33;
package/dist/consts.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PKLEN = exports.CLA = void 0;
4
+ /** ******************************************************************************
5
+ * (c) 2018 - 2023 Zondax AG
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ ******************************************************************************* */
19
+ exports.CLA = 0x55;
20
+ exports.PKLEN = 33;
21
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;mFAcmF;AACtE,QAAA,GAAG,GAAG,IAAI,CAAC;AAYX,QAAA,KAAK,GAAG,EAAE,CAAC","sourcesContent":["/** ******************************************************************************\n * (c) 2018 - 2023 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 ******************************************************************************* */\nexport const CLA = 0x55;\n\nexport const enum P1_VALUES {\n ONLY_RETRIEVE = 0x00,\n SHOW_ADDRESS_IN_DEVICE = 0x01,\n}\n\nexport const enum P2_VALUES {\n JSON = 0x0,\n TEXTUAL = 0x1,\n}\n\nexport const PKLEN = 33;\n"]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** ******************************************************************************
2
- * (c) 2018 - 2022 Zondax AG
2
+ * (c) 2018 - 2023 Zondax AG
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -13,4 +13,40 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  ******************************************************************************* */
16
- export * from './cosmosApp';
16
+ import { ResponseSign, type ResponseAddress, type ResponsePubkey } from "./types";
17
+ import { P2_VALUES } from "./consts";
18
+ import type Transport from "@ledgerhq/hw-transport";
19
+ import BaseApp, { INSGeneric, ResponsePayload } from "@zondax/ledger-js";
20
+ export default class CosmosApp extends BaseApp {
21
+ static _INS: {
22
+ GET_VERSION: number;
23
+ SIGN_SECP256K1: number;
24
+ GET_ADDR_SECP256K1: number;
25
+ };
26
+ static _params: {
27
+ cla: number;
28
+ ins: INSGeneric;
29
+ p1Values: {
30
+ ONLY_RETRIEVE: 0;
31
+ SHOW_ADDRESS_IN_DEVICE: 1;
32
+ };
33
+ chunkSize: number;
34
+ requiredPathLengths: number[];
35
+ };
36
+ /**
37
+ * Constructs a new CosmosApp instance.
38
+ * @param transport - The transport instance.
39
+ * @throws {Error} - If the transport is not defined.
40
+ */
41
+ constructor(transport: Transport);
42
+ private serializeHRP;
43
+ private serializeCosmosPath;
44
+ publicKey(path: string): Promise<ResponsePubkey>;
45
+ getAddressAndPubKey(path: string, hrp: string): Promise<ResponseAddress>;
46
+ showAddressAndPubKey(path: string, hrp: string): Promise<ResponseAddress>;
47
+ static getBech32FromPK(hrp: string, pk: Buffer): any;
48
+ prepareChunks_hrp(path: string, buffer: Buffer, hrp: string | undefined): Promise<Buffer[]>;
49
+ signSendCosmosChunk(chunkIdx: number, chunkNum: number, chunk: Buffer, txtype?: P2_VALUES): Promise<ResponsePayload>;
50
+ private signImpl;
51
+ sign(path: string, buffer: Buffer, hrp: string | undefined, txtype?: P2_VALUES): Promise<ResponseSign>;
52
+ }
package/dist/index.js CHANGED
@@ -1,19 +1,4 @@
1
1
  "use strict";
2
- /** ******************************************************************************
3
- * (c) 2018 - 2022 Zondax AG
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- ******************************************************************************* */
17
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
3
  if (k2 === undefined) k2 = k;
19
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -25,9 +10,191 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
25
10
  if (k2 === undefined) k2 = k;
26
11
  o[k2] = m[k];
27
12
  }));
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);
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
30
24
  };
31
- exports.__esModule = true;
32
- __exportStar(require("./cosmosApp"), exports);
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const consts_1 = require("./consts");
27
+ const ledger_js_1 = __importStar(require("@zondax/ledger-js"));
28
+ const byteStream_1 = require("@zondax/ledger-js/dist/byteStream");
29
+ const crypto = require("crypto");
30
+ const bech32 = require("bech32");
31
+ const Ripemd160 = require("ripemd160");
32
+ class CosmosApp extends ledger_js_1.default {
33
+ /**
34
+ * Constructs a new CosmosApp instance.
35
+ * @param transport - The transport instance.
36
+ * @throws {Error} - If the transport is not defined.
37
+ */
38
+ constructor(transport) {
39
+ super(transport, CosmosApp._params);
40
+ if (!this.transport) {
41
+ throw new Error("Transport has not been defined");
42
+ }
43
+ }
44
+ serializeHRP(hrp) {
45
+ if (hrp == null || hrp.length < 3 || hrp.length > 83) {
46
+ throw new Error("Invalid HRP");
47
+ }
48
+ const buf = new byteStream_1.ByteStream();
49
+ buf.appendUint8(hrp.length);
50
+ buf.appendBytes(Buffer.from(hrp));
51
+ return buf.getCompleteBuffer();
52
+ }
53
+ serializeCosmosPath(path) {
54
+ if (typeof path !== "string") {
55
+ // NOTE: this is probably unnecessary
56
+ throw new ledger_js_1.ResponseError(ledger_js_1.LedgerError.GenericError, "Path should be a string (e.g \"m/44'/461'/5'/0/3\")");
57
+ }
58
+ if (!path.startsWith("m/")) {
59
+ throw new ledger_js_1.ResponseError(ledger_js_1.LedgerError.GenericError, 'Path should start with "m/" (e.g "m/44\'/461\'/5\'/0/3")');
60
+ }
61
+ const pathArray = path.split("/");
62
+ pathArray.shift(); // remove "m"
63
+ if (this.REQUIRED_PATH_LENGTHS &&
64
+ this.REQUIRED_PATH_LENGTHS.length > 0 &&
65
+ !this.REQUIRED_PATH_LENGTHS.includes(pathArray.length)) {
66
+ throw new ledger_js_1.ResponseError(ledger_js_1.LedgerError.GenericError, "Invalid path length. (e.g \"m/44'/5757'/5'/0/3\")");
67
+ }
68
+ const buf = new byteStream_1.ByteStream();
69
+ pathArray.forEach((child, i) => {
70
+ let value = 0;
71
+ if (child.endsWith("'")) {
72
+ value += ledger_js_1.HARDENED;
73
+ child = child.slice(0, -1);
74
+ }
75
+ const numChild = Number(child);
76
+ if (Number.isNaN(numChild)) {
77
+ throw new ledger_js_1.ResponseError(ledger_js_1.LedgerError.GenericError, `Invalid path : ${child} is not a number. (e.g "m/44'/461'/5'/0/3")`);
78
+ }
79
+ value += numChild;
80
+ buf.appendUint32(value);
81
+ });
82
+ return buf.getCompleteBuffer();
83
+ }
84
+ async publicKey(path) {
85
+ const serializedPath = await this.serializeCosmosPath(path);
86
+ const data = Buffer.concat([this.serializeHRP("cosmos"), serializedPath]);
87
+ try {
88
+ const responseBuffer = await this.transport.send(this.CLA, this.INS.GET_ADDR_SECP256K1, 0, 0, data);
89
+ const response = (0, ledger_js_1.processResponse)(responseBuffer);
90
+ const compressed_pk = Buffer.from(response.readBytes(consts_1.PKLEN));
91
+ return {
92
+ compressed_pk,
93
+ };
94
+ }
95
+ catch (e) {
96
+ throw (0, ledger_js_1.processErrorResponse)(e);
97
+ }
98
+ }
99
+ async getAddressAndPubKey(path, hrp) {
100
+ const serializedPath = await this.serializeCosmosPath(path);
101
+ const data = Buffer.concat([this.serializeHRP(hrp), serializedPath]);
102
+ try {
103
+ const responseBuffer = await this.transport.send(this.CLA, this.INS.GET_ADDR_SECP256K1, 0 /* P1_VALUES.ONLY_RETRIEVE */, 0, data);
104
+ const response = (0, ledger_js_1.processResponse)(responseBuffer);
105
+ const compressed_pk = response.readBytes(consts_1.PKLEN);
106
+ const bech32_address = response.readBytes(response.length()).toString();
107
+ return {
108
+ compressed_pk,
109
+ bech32_address,
110
+ };
111
+ }
112
+ catch (e) {
113
+ throw (0, ledger_js_1.processErrorResponse)(e);
114
+ }
115
+ }
116
+ async showAddressAndPubKey(path, hrp) {
117
+ const serializedPath = await this.serializeCosmosPath(path);
118
+ const data = Buffer.concat([this.serializeHRP(hrp), serializedPath]);
119
+ try {
120
+ const responseBuffer = await this.transport.send(this.CLA, this.INS.GET_ADDR_SECP256K1, 1 /* P1_VALUES.SHOW_ADDRESS_IN_DEVICE */, 0, data);
121
+ const response = (0, ledger_js_1.processResponse)(responseBuffer);
122
+ const compressed_pk = response.readBytes(consts_1.PKLEN);
123
+ const bech32_address = response.readBytes(response.length()).toString();
124
+ return {
125
+ compressed_pk,
126
+ bech32_address,
127
+ };
128
+ }
129
+ catch (e) {
130
+ throw (0, ledger_js_1.processErrorResponse)(e);
131
+ }
132
+ }
133
+ static getBech32FromPK(hrp, pk) {
134
+ if (pk.length !== 33) {
135
+ throw new Error("expected compressed public key [31 bytes]");
136
+ }
137
+ const hashSha256 = crypto.createHash("sha256").update(pk).digest();
138
+ const hashRip = new Ripemd160().update(hashSha256).digest();
139
+ return bech32.encode(hrp, bech32.toWords(hashRip));
140
+ }
141
+ async prepareChunks_hrp(path, buffer, hrp) {
142
+ const serializedPath = await this.serializeCosmosPath(path);
143
+ const firstChunk = hrp === undefined ? serializedPath : Buffer.concat([serializedPath, this.serializeHRP(hrp)]);
144
+ const chunks = [];
145
+ chunks.push(firstChunk);
146
+ for (let i = 0; i < buffer.length; i += this.CHUNK_SIZE) {
147
+ let end = i + this.CHUNK_SIZE;
148
+ if (i > buffer.length) {
149
+ end = buffer.length;
150
+ }
151
+ chunks.push(buffer.subarray(i, end));
152
+ }
153
+ return chunks;
154
+ }
155
+ async signSendCosmosChunk(chunkIdx, chunkNum, chunk, txtype = 0 /* P2_VALUES.JSON */) {
156
+ let payloadType = ledger_js_1.PAYLOAD_TYPE.ADD;
157
+ if (chunkIdx === 1) {
158
+ payloadType = ledger_js_1.PAYLOAD_TYPE.INIT;
159
+ }
160
+ if (chunkIdx === chunkNum) {
161
+ payloadType = ledger_js_1.PAYLOAD_TYPE.LAST;
162
+ }
163
+ const statusList = [ledger_js_1.LedgerError.NoErrors, ledger_js_1.LedgerError.DataIsInvalid, ledger_js_1.LedgerError.BadKeyHandle];
164
+ const responseBuffer = await this.transport.send(this.CLA, this.INS.SIGN_SECP256K1, payloadType, txtype, chunk, statusList);
165
+ const response = (0, ledger_js_1.processResponse)(responseBuffer);
166
+ return response;
167
+ }
168
+ async signImpl(path, buffer, hrp, txtype) {
169
+ const chunks = await this.prepareChunks_hrp(path, buffer, hrp);
170
+ try {
171
+ let result = await this.signSendCosmosChunk(1, chunks.length, chunks[0], txtype);
172
+ for (let i = 1; i < chunks.length; i += 1) {
173
+ result = await this.signSendCosmosChunk(1 + i, chunks.length, chunks[i], txtype);
174
+ }
175
+ return {
176
+ signature: result.readBytes(result.length()),
177
+ };
178
+ }
179
+ catch (e) {
180
+ throw (0, ledger_js_1.processErrorResponse)(e);
181
+ }
182
+ }
183
+ async sign(path, buffer, hrp, txtype = 0 /* P2_VALUES.JSON */) {
184
+ return await this.signImpl(path, buffer, hrp, txtype);
185
+ }
186
+ }
187
+ CosmosApp._INS = {
188
+ GET_VERSION: 0x00,
189
+ SIGN_SECP256K1: 0x02,
190
+ GET_ADDR_SECP256K1: 0x04,
191
+ };
192
+ CosmosApp._params = {
193
+ cla: consts_1.CLA,
194
+ ins: { ...CosmosApp._INS },
195
+ p1Values: { ONLY_RETRIEVE: 0x00, SHOW_ADDRESS_IN_DEVICE: 0x01 },
196
+ chunkSize: 250,
197
+ requiredPathLengths: [5],
198
+ };
199
+ exports.default = CosmosApp;
33
200
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,qCAA4D;AAE5D,+DAS2B;AAC3B,kEAA+D;AAE/D,MAAM,MAAM,GAAG,OAAO,CAAC,QAA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,EAAE,CAAC;YACX,MAAM,IAAA,gCAAoB,EAAC,CAAC,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CACR,IAAY,EACZ,MAAc,EACd,GAAuB,EACvB,MAAM,yBAAiB;QAEvB,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;;AAtPM,cAAI,GAAG;IACZ,WAAW,EAAE,IAAc;IAC3B,cAAc,EAAE,IAAc;IAC9B,kBAAkB,EAAE,IAAc;CACnC,CAAC;AAEK,iBAAO,GAAG;IACf,GAAG,EAAE,YAAG;IACR,GAAG,EAAE,EAAE,GAAG,SAAS,CAAC,IAAI,EAAgB;IACxC,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAS,EAAE,sBAAsB,EAAE,IAAS,EAAE;IACzE,SAAS,EAAE,GAAG;IACd,mBAAmB,EAAE,CAAC,CAAC,CAAC;CACzB,CAAC;kBAbiB,SAAS","sourcesContent":["/** ******************************************************************************\n * (c) 2018 - 2023 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 ******************************************************************************* */\nimport { ResponseSign, type ResponseAddress, type ResponsePubkey } from \"./types\";\nimport { CLA, P1_VALUES, P2_VALUES, PKLEN } from \"./consts\";\nimport type Transport from \"@ledgerhq/hw-transport\";\nimport BaseApp, {\n HARDENED,\n INSGeneric,\n LedgerError,\n PAYLOAD_TYPE,\n ResponseError,\n ResponsePayload,\n processErrorResponse,\n processResponse,\n} from \"@zondax/ledger-js\";\nimport { ByteStream } from \"@zondax/ledger-js/dist/byteStream\";\n\nconst crypto = require(\"crypto\");\nconst bech32 = require(\"bech32\");\nconst Ripemd160 = require(\"ripemd160\");\n\nexport default class CosmosApp extends BaseApp {\n static _INS = {\n GET_VERSION: 0x00 as number,\n SIGN_SECP256K1: 0x02 as number,\n GET_ADDR_SECP256K1: 0x04 as number,\n };\n\n static _params = {\n cla: CLA,\n ins: { ...CosmosApp._INS } as INSGeneric,\n p1Values: { ONLY_RETRIEVE: 0x00 as 0, SHOW_ADDRESS_IN_DEVICE: 0x01 as 1 },\n chunkSize: 250,\n requiredPathLengths: [5],\n };\n\n /**\n * Constructs a new CosmosApp instance.\n * @param transport - The transport instance.\n * @throws {Error} - If the transport is not defined.\n */\n constructor(transport: Transport) {\n super(transport, CosmosApp._params);\n\n if (!this.transport) {\n throw new Error(\"Transport has not been defined\");\n }\n }\n\n private serializeHRP(hrp: string) {\n if (hrp == null || hrp.length < 3 || hrp.length > 83) {\n throw new Error(\"Invalid HRP\");\n }\n\n const buf = new ByteStream();\n buf.appendUint8(hrp.length);\n buf.appendBytes(Buffer.from(hrp));\n\n return buf.getCompleteBuffer();\n }\n\n private serializeCosmosPath(path: string) {\n if (typeof path !== \"string\") {\n // NOTE: this is probably unnecessary\n throw new ResponseError(\n LedgerError.GenericError,\n \"Path should be a string (e.g \\\"m/44'/461'/5'/0/3\\\")\",\n );\n }\n\n if (!path.startsWith(\"m/\")) {\n throw new ResponseError(\n LedgerError.GenericError,\n 'Path should start with \"m/\" (e.g \"m/44\\'/461\\'/5\\'/0/3\")',\n );\n }\n\n const pathArray = path.split(\"/\");\n pathArray.shift(); // remove \"m\"\n\n if (\n this.REQUIRED_PATH_LENGTHS &&\n this.REQUIRED_PATH_LENGTHS.length > 0 &&\n !this.REQUIRED_PATH_LENGTHS.includes(pathArray.length)\n ) {\n throw new ResponseError(LedgerError.GenericError, \"Invalid path length. (e.g \\\"m/44'/5757'/5'/0/3\\\")\");\n }\n\n const buf = new ByteStream();\n pathArray.forEach((child: string, i: number) => {\n let value = 0;\n\n if (child.endsWith(\"'\")) {\n value += HARDENED;\n child = child.slice(0, -1);\n }\n\n const numChild = Number(child);\n\n if (Number.isNaN(numChild)) {\n throw new ResponseError(\n LedgerError.GenericError,\n `Invalid path : ${child} is not a number. (e.g \"m/44'/461'/5'/0/3\")`,\n );\n }\n value += numChild;\n buf.appendUint32(value);\n });\n\n return buf.getCompleteBuffer();\n }\n\n async publicKey(path: string): Promise<ResponsePubkey> {\n const serializedPath = await this.serializeCosmosPath(path);\n const data = Buffer.concat([this.serializeHRP(\"cosmos\"), serializedPath]);\n\n try {\n const responseBuffer = await this.transport.send(this.CLA, this.INS.GET_ADDR_SECP256K1, 0, 0, data);\n const response = processResponse(responseBuffer);\n const compressed_pk = Buffer.from(response.readBytes(PKLEN));\n\n return {\n compressed_pk,\n } as ResponsePubkey;\n } catch (e) {\n throw processErrorResponse(e);\n }\n }\n\n async getAddressAndPubKey(path: string, hrp: string): Promise<ResponseAddress> {\n const serializedPath = await this.serializeCosmosPath(path);\n const data = Buffer.concat([this.serializeHRP(hrp), serializedPath]);\n\n try {\n const responseBuffer = await this.transport.send(\n this.CLA,\n this.INS.GET_ADDR_SECP256K1,\n P1_VALUES.ONLY_RETRIEVE,\n 0,\n data,\n );\n\n const response = processResponse(responseBuffer);\n const compressed_pk = response.readBytes(PKLEN);\n const bech32_address = response.readBytes(response.length()).toString();\n\n return {\n compressed_pk,\n bech32_address,\n } as ResponseAddress;\n } catch (e) {\n throw processErrorResponse(e);\n }\n }\n\n async showAddressAndPubKey(path: string, hrp: string): Promise<ResponseAddress> {\n const serializedPath = await this.serializeCosmosPath(path);\n const data = Buffer.concat([this.serializeHRP(hrp), serializedPath]);\n\n try {\n const responseBuffer = await this.transport.send(\n this.CLA,\n this.INS.GET_ADDR_SECP256K1,\n P1_VALUES.SHOW_ADDRESS_IN_DEVICE,\n 0,\n data,\n );\n\n const response = processResponse(responseBuffer);\n const compressed_pk = response.readBytes(PKLEN);\n const bech32_address = response.readBytes(response.length()).toString();\n\n return {\n compressed_pk,\n bech32_address,\n } as ResponseAddress;\n } catch (e) {\n throw processErrorResponse(e);\n }\n }\n\n static getBech32FromPK(hrp: string, pk: Buffer) {\n if (pk.length !== 33) {\n throw new Error(\"expected compressed public key [31 bytes]\");\n }\n const hashSha256 = crypto.createHash(\"sha256\").update(pk).digest();\n const hashRip = new Ripemd160().update(hashSha256).digest();\n return bech32.encode(hrp, bech32.toWords(hashRip));\n }\n\n async prepareChunks_hrp(path: string, buffer: Buffer, hrp: string | undefined) {\n const serializedPath = await this.serializeCosmosPath(path);\n const firstChunk =\n hrp === undefined ? serializedPath : Buffer.concat([serializedPath, this.serializeHRP(hrp)]);\n\n const chunks = [];\n chunks.push(firstChunk);\n\n for (let i = 0; i < buffer.length; i += this.CHUNK_SIZE) {\n let end = i + this.CHUNK_SIZE;\n if (i > buffer.length) {\n end = buffer.length;\n }\n chunks.push(buffer.subarray(i, end));\n }\n\n return chunks;\n }\n\n async signSendCosmosChunk(\n chunkIdx: number,\n chunkNum: number,\n chunk: Buffer,\n txtype = P2_VALUES.JSON,\n ): Promise<ResponsePayload> {\n let payloadType = PAYLOAD_TYPE.ADD;\n if (chunkIdx === 1) {\n payloadType = PAYLOAD_TYPE.INIT;\n }\n if (chunkIdx === chunkNum) {\n payloadType = PAYLOAD_TYPE.LAST;\n }\n\n const statusList = [LedgerError.NoErrors, LedgerError.DataIsInvalid, LedgerError.BadKeyHandle];\n\n const responseBuffer = await this.transport.send(\n this.CLA,\n this.INS.SIGN_SECP256K1,\n payloadType,\n txtype,\n chunk,\n statusList,\n );\n const response = processResponse(responseBuffer);\n\n return response;\n }\n\n private async signImpl(\n path: string,\n buffer: Buffer,\n hrp: string | undefined,\n txtype: number,\n ): Promise<ResponseSign> {\n const chunks = await this.prepareChunks_hrp(path, buffer, hrp);\n\n try {\n let result = await this.signSendCosmosChunk(1, chunks.length, chunks[0], txtype);\n\n for (let i = 1; i < chunks.length; i += 1) {\n result = await this.signSendCosmosChunk(1 + i, chunks.length, chunks[i], txtype);\n }\n\n return {\n signature: result.readBytes(result.length()),\n };\n } catch (e) {\n throw processErrorResponse(e);\n }\n }\n\n async sign(\n path: string,\n buffer: Buffer,\n hrp: string | undefined,\n txtype = P2_VALUES.JSON,\n ): Promise<ResponseSign> {\n return await this.signImpl(path, buffer, hrp, txtype);\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ export interface ResponseAddress {
2
+ bech32_address: string;
3
+ compressed_pk: Buffer;
4
+ }
5
+ export interface ResponsePubkey {
6
+ bech32_address: string;
7
+ compressed_pk: Buffer;
8
+ }
9
+ export interface ResponseSign {
10
+ signature: Buffer;
11
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface ResponseAddress {\n bech32_address: string;\n compressed_pk: Buffer;\n}\n\nexport interface ResponsePubkey {\n bech32_address: string;\n compressed_pk: Buffer;\n}\n\nexport interface ResponseSign {\n signature: Buffer;\n}\n"]}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@zondax/ledger-cosmos-js",
3
- "author": "ZondaX AG",
3
+ "author": "Zondax AG",
4
4
  "license": "Apache-2.0",
5
- "version": "3.0.2",
5
+ "version": "4.0.0",
6
6
  "description": "Node API for Cosmos App (Ledger Nano S/S+/X)",
7
7
  "main": "./dist/index.js",
8
8
  "typings": "./dist/index.d.ts",
@@ -28,44 +28,45 @@
28
28
  "@ledgerhq/hw-transport-node-hid-noevents": "6.27.1"
29
29
  },
30
30
  "dependencies": {
31
- "@babel/runtime": "^7.14.8",
32
- "@ledgerhq/hw-transport": "6.27.1",
33
- "bech32": "^1.1.4",
34
- "ripemd160": "^2.0.2"
31
+ "@ledgerhq/hw-transport": "6.30.6",
32
+ "@zondax/ledger-js": "^0.10.0",
33
+ "bech32": "^2.0.0",
34
+ "buffer": "^6.0.3",
35
+ "crypto": "^1.0.1",
36
+ "crypto-browserify": "^3.12.0",
37
+ "ripemd160": "^2.0.2",
38
+ "stream-browserify": "^3.0.0"
35
39
  },
36
40
  "devDependencies": {
37
- "@babel/cli": "^7.18.10",
38
- "@babel/core": "^7.18.10",
39
- "@babel/node": "^7.18.10",
40
- "@babel/plugin-transform-runtime": "^7.18.9",
41
- "@babel/preset-env": "^7.18.9",
42
- "@ledgerhq/hw-transport-node-hid": "6.27.1",
43
- "@ledgerhq/hw-transport-webusb": "6.27.1",
44
- "@swc/core": "^1.2.237",
45
- "@types/jest": "^26.0.24",
46
- "@types/ledgerhq__hw-transport": "4.21.4",
47
- "@types/node": "^18.11.9",
48
- "@typescript-eslint/eslint-plugin": "^5.33.1",
49
- "@typescript-eslint/parser": "^5.33.1",
50
- "bip32": "2.0.6",
51
- "bip39": "3.0.2",
41
+ "@ledgerhq/hw-transport-node-hid": "6.28.6",
42
+ "@ledgerhq/hw-transport-webusb": "6.28.6",
43
+ "@ledgerhq/hw-transport-mocker": "^6.28.6",
44
+ "@swc/core": "^1.6.1",
45
+ "@types/jest": "^29.5.12",
46
+ "@types/ledgerhq__hw-transport": "4.21.8",
47
+ "@types/node": "^20.14.2",
48
+ "@typescript-eslint/eslint-plugin": "^7.13.0",
49
+ "@typescript-eslint/parser": "^7.13.0",
50
+ "bip32": "4.0.0",
51
+ "bip39": "3.1.0",
52
52
  "copyfiles": "^2.4.1",
53
- "babel-eslint": "^10.1.0",
54
- "babel-jest": "^28.1.3",
55
- "core-js": "^3.15.2",
56
- "crypto-js": "4.1.1",
57
- "eslint": "^8.22.0",
58
- "eslint-config-prettier": "^8.5.0",
59
- "eslint-plugin-import": "^2.26.0",
60
- "eslint-plugin-jest": "^26.8.3",
61
- "eslint-plugin-prettier": "^3.4.0",
62
- "jest": "^26",
53
+ "core-js": "^3.37.1",
54
+ "crypto-js": "4.2.0",
55
+ "eslint": "^9.5.0",
56
+ "eslint-config-prettier": "^9.1.0",
57
+ "eslint-plugin-import": "^2.29.1",
58
+ "eslint-plugin-jest": "^28.6.0",
59
+ "eslint-plugin-prettier": "^5.1.3",
60
+ "eslint-plugin-unused-imports": "^3.2.0",
61
+ "eslint-plugin-tsdoc": "^0.2.17",
62
+ "jest": "^29.7.0",
63
63
  "jest-serial-runner": "^1.2.0",
64
- "prettier": "^2.3.2",
65
- "secp256k1": "^4.0.2",
66
- "ts-jest": "26",
67
- "ts-node": "^10.8.1",
68
- "typescript": "^4.7.4"
64
+ "prettier": "^3.3.2",
65
+ "secp256k1": "^5.0.0",
66
+ "ts-jest": "29.1.5",
67
+ "ts-node": "^10.9.2",
68
+ "typescript": "^5.4.5",
69
+ "webpack": "^5.92.0"
69
70
  },
70
71
  "moduleDirectories": [
71
72
  "node_modules",
@@ -88,12 +89,10 @@
88
89
  "@types/node": "^17.0.21"
89
90
  },
90
91
  "scripts": {
91
- "build": "tsc && yarn copy-files",
92
- "copy-files": "copyfiles -u 0 src/**/*.proto dist/",
93
- "test:integration": "yarn build && jest -t 'Integration'",
94
- "test:unit": "yarn build && jest tests/basic_unit.test.ts",
95
- "serve": "openssl req -nodes -new -x509 -config certs/openssl.cnf -keyout certs/server.key -out certs/server.cert; openssl x509 -in certs/server.cert -out certs/cert.pem -outform PEM; vue-cli-service serve vue_example/main.js",
96
- "linter": "eslint --ext .ts,.tsx,.js,.jsx --ignore-path .eslintignore . --max-warnings 0",
97
- "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\""
92
+ "build": "tsc",
93
+ "lint": "eslint .",
94
+ "lint:fix": "eslint --fix .",
95
+ "format": "prettier --write .",
96
+ "test": "yarn build && jest"
98
97
  }
99
98
  }
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- export declare function serializePathv1(path: number[]): Buffer;
3
- export declare function signSendChunkv1(app: any, chunkIdx: number, chunkNum: number, chunk: Buffer, txType?: number): Promise<any>;
4
- export declare function publicKeyv1(app: any, data: Buffer): Promise<any>;