@ledgerhq/hw-app-cosmos 6.27.13 → 6.28.0-next.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 +12 -0
- package/lib/Cosmos.js +77 -112
- package/lib/Cosmos.js.map +1 -1
- package/lib-es/Cosmos.js +73 -109
- package/lib-es/Cosmos.js.map +1 -1
- package/package.json +5 -6
- package/src/Cosmos.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ledgerhq/hw-app-cosmos
|
|
2
2
|
|
|
3
|
+
## 6.28.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2809](https://github.com/LedgerHQ/ledger-live/pull/2809) [`51c01541df`](https://github.com/LedgerHQ/ledger-live/commit/51c01541df8a414851ea4ef493dc9045272ef949) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Add Quicksilver, Persistence, Onomy, Axelar to Cosmos family
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`87d2349fd8`](https://github.com/LedgerHQ/ledger-live/commit/87d2349fd835e5deb39d1ee8dfcf3539f4195472)]:
|
|
12
|
+
- @ledgerhq/errors@6.12.5-next.0
|
|
13
|
+
- @ledgerhq/hw-transport@6.28.3-next.0
|
|
14
|
+
|
|
3
15
|
## 6.27.13
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/lib/Cosmos.js
CHANGED
|
@@ -8,50 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
|
-
exports
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const bip32_path_1 = __importDefault(require("bip32-path"));
|
|
16
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
17
|
+
const CHUNK_SIZE = 250;
|
|
18
|
+
const CLA = 0x55;
|
|
19
|
+
const APP_KEY = "CSM";
|
|
20
|
+
const INS_GET_VERSION = 0x00;
|
|
21
|
+
const INS_SIGN_SECP256K1 = 0x02;
|
|
22
|
+
const INS_GET_ADDR_SECP256K1 = 0x04;
|
|
23
|
+
const PAYLOAD_TYPE_INIT = 0x00;
|
|
24
|
+
const PAYLOAD_TYPE_ADD = 0x01;
|
|
25
|
+
const PAYLOAD_TYPE_LAST = 0x02;
|
|
26
|
+
const SW_OK = 0x9000;
|
|
27
|
+
const SW_CANCEL = 0x6986;
|
|
55
28
|
/**
|
|
56
29
|
* Cosmos API
|
|
57
30
|
*
|
|
@@ -59,25 +32,24 @@ var SW_CANCEL = 0x6986;
|
|
|
59
32
|
* import Cosmos from "@ledgerhq/hw-app-cosmos";
|
|
60
33
|
* const cosmos = new Cosmos(transport)
|
|
61
34
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (scrambleKey === void 0) { scrambleKey = APP_KEY; }
|
|
35
|
+
class Cosmos {
|
|
36
|
+
constructor(transport, scrambleKey = APP_KEY) {
|
|
65
37
|
this.transport = transport;
|
|
66
38
|
transport.decorateAppAPIMethods(this, ["getAddress", "sign", "getAppConfiguration"], scrambleKey);
|
|
67
39
|
}
|
|
68
40
|
// FIXME: understand what is going on with the return type here
|
|
69
|
-
|
|
70
|
-
return this.transport.send(CLA, INS_GET_VERSION, 0, 0).then(
|
|
41
|
+
getAppConfiguration() {
|
|
42
|
+
return this.transport.send(CLA, INS_GET_VERSION, 0, 0).then((response) => {
|
|
71
43
|
return {
|
|
72
44
|
test_mode: response[0] !== 0,
|
|
73
45
|
version: "" + response[1] + "." + response[2] + "." + response[3],
|
|
74
46
|
device_locked: response[4] === 1,
|
|
75
|
-
major: response[1]
|
|
47
|
+
major: response[1],
|
|
76
48
|
};
|
|
77
49
|
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
50
|
+
}
|
|
51
|
+
serializePath(path) {
|
|
52
|
+
const buf = Buffer.alloc(20);
|
|
81
53
|
// HACK : without the >>>,
|
|
82
54
|
// the bitwise implicitly casts the result to be a signed int32,
|
|
83
55
|
// which fails the internal type check of Buffer in case of overload.
|
|
@@ -87,16 +59,16 @@ var Cosmos = /** @class */ (function () {
|
|
|
87
59
|
buf.writeUInt32LE(path[3], 12);
|
|
88
60
|
buf.writeUInt32LE(path[4], 16);
|
|
89
61
|
return buf;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (hrp == null || hrp.length
|
|
62
|
+
}
|
|
63
|
+
serializeHRP(hrp) {
|
|
64
|
+
if (hrp == null || hrp.length === 0 || hrp.length > 83) {
|
|
93
65
|
throw new Error("Invalid HRP");
|
|
94
66
|
}
|
|
95
|
-
|
|
67
|
+
const buf = Buffer.alloc(1 + hrp.length);
|
|
96
68
|
buf.writeUInt8(hrp.length, 0);
|
|
97
69
|
buf.write(hrp, 1);
|
|
98
70
|
return buf;
|
|
99
|
-
}
|
|
71
|
+
}
|
|
100
72
|
/**
|
|
101
73
|
* get Cosmos address for a given BIP 32 path.
|
|
102
74
|
* @param path a path in BIP 32 format
|
|
@@ -106,22 +78,22 @@ var Cosmos = /** @class */ (function () {
|
|
|
106
78
|
* @example
|
|
107
79
|
* cosmos.getAddress("44'/60'/0'/0/0", "cosmos").then(o => o.address)
|
|
108
80
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
81
|
+
getAddress(path, hrp, boolDisplay) {
|
|
82
|
+
const bipPath = bip32_path_1.default.fromString(path).toPathArray();
|
|
83
|
+
const serializedPath = this.serializePath(bipPath);
|
|
84
|
+
const data = Buffer.concat([this.serializeHRP(hrp), serializedPath]);
|
|
113
85
|
return this.transport
|
|
114
86
|
.send(CLA, INS_GET_ADDR_SECP256K1, boolDisplay ? 1 : 0, 0, data, [SW_OK])
|
|
115
|
-
.then(
|
|
116
|
-
|
|
117
|
-
|
|
87
|
+
.then((response) => {
|
|
88
|
+
const address = Buffer.from(response.slice(33, -2)).toString();
|
|
89
|
+
const publicKey = Buffer.from(response.slice(0, 33)).toString("hex");
|
|
118
90
|
return {
|
|
119
|
-
address
|
|
120
|
-
publicKey
|
|
91
|
+
address,
|
|
92
|
+
publicKey,
|
|
121
93
|
};
|
|
122
94
|
});
|
|
123
|
-
}
|
|
124
|
-
|
|
95
|
+
}
|
|
96
|
+
foreach(arr, callback) {
|
|
125
97
|
function iterate(index, array, result) {
|
|
126
98
|
if (index >= array.length) {
|
|
127
99
|
return result;
|
|
@@ -132,53 +104,46 @@ var Cosmos = /** @class */ (function () {
|
|
|
132
104
|
return iterate(index + 1, array, result);
|
|
133
105
|
});
|
|
134
106
|
}
|
|
135
|
-
return Promise.resolve().then(
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
107
|
+
return Promise.resolve().then(() => iterate(0, arr, []));
|
|
108
|
+
}
|
|
109
|
+
sign(path, message) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const bipPath = bip32_path_1.default.fromString(path).toPathArray();
|
|
112
|
+
const serializedPath = this.serializePath(bipPath);
|
|
113
|
+
const chunks = [];
|
|
114
|
+
chunks.push(serializedPath);
|
|
115
|
+
const buffer = Buffer.from(message);
|
|
116
|
+
for (let i = 0; i < buffer.length; i += CHUNK_SIZE) {
|
|
117
|
+
let end = i + CHUNK_SIZE;
|
|
118
|
+
if (i > buffer.length) {
|
|
119
|
+
end = buffer.length;
|
|
120
|
+
}
|
|
121
|
+
chunks.push(buffer.slice(i, end));
|
|
122
|
+
}
|
|
123
|
+
let response = {};
|
|
124
|
+
return this.foreach(chunks, (data, j) => this.transport
|
|
125
|
+
.send(CLA, INS_SIGN_SECP256K1, j === 0
|
|
126
|
+
? PAYLOAD_TYPE_INIT
|
|
127
|
+
: j + 1 === chunks.length
|
|
128
|
+
? PAYLOAD_TYPE_LAST
|
|
129
|
+
: PAYLOAD_TYPE_ADD, 0, data, [SW_OK, SW_CANCEL])
|
|
130
|
+
.then((apduResponse) => (response = apduResponse))).then(() => {
|
|
131
|
+
const errorCodeData = response.slice(-2);
|
|
132
|
+
const returnCode = errorCodeData[0] * 256 + errorCodeData[1];
|
|
133
|
+
let signature = null;
|
|
134
|
+
if (response.length > 2) {
|
|
135
|
+
signature = response.slice(0, response.length - 2);
|
|
136
|
+
}
|
|
137
|
+
if (returnCode === 0x6986) {
|
|
138
|
+
throw new errors_1.UserRefusedOnDevice();
|
|
153
139
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
? PAYLOAD_TYPE_INIT
|
|
159
|
-
: j + 1 === chunks.length
|
|
160
|
-
? PAYLOAD_TYPE_LAST
|
|
161
|
-
: PAYLOAD_TYPE_ADD, 0, data, [SW_OK, SW_CANCEL])
|
|
162
|
-
.then(function (apduResponse) { return (response = apduResponse); });
|
|
163
|
-
}).then(function () {
|
|
164
|
-
var errorCodeData = response.slice(-2);
|
|
165
|
-
var returnCode = errorCodeData[0] * 256 + errorCodeData[1];
|
|
166
|
-
var signature = null;
|
|
167
|
-
if (response.length > 2) {
|
|
168
|
-
signature = response.slice(0, response.length - 2);
|
|
169
|
-
}
|
|
170
|
-
if (returnCode === 0x6986) {
|
|
171
|
-
throw new errors_1.UserRefusedOnDevice();
|
|
172
|
-
}
|
|
173
|
-
return {
|
|
174
|
-
signature: signature,
|
|
175
|
-
return_code: returnCode
|
|
176
|
-
};
|
|
177
|
-
})];
|
|
140
|
+
return {
|
|
141
|
+
signature,
|
|
142
|
+
return_code: returnCode,
|
|
143
|
+
};
|
|
178
144
|
});
|
|
179
145
|
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
exports["default"] = Cosmos;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.default = Cosmos;
|
|
184
149
|
//# sourceMappingURL=Cosmos.js.map
|
package/lib/Cosmos.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cosmos.js","sourceRoot":"","sources":["../src/Cosmos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Cosmos.js","sourceRoot":"","sources":["../src/Cosmos.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAiBA,4DAAiC;AACjC,6CAAuD;AACvD,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,GAAG,GAAG,IAAI,CAAC;AACjB,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,KAAK,GAAG,MAAM,CAAC;AACrB,MAAM,SAAS,GAAG,MAAM,CAAC;AACzB;;;;;;GAMG;AAEH,MAAqB,MAAM;IAGzB,YAAY,SAAoB,EAAE,cAAsB,OAAO;QAC7D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,SAAS,CAAC,qBAAqB,C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OAAO;oBACL,SAAS;oBACT,WAAW,EAAE,UAAU;iBACxB,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAhKD,yBAgKC"}
|
package/lib-es/Cosmos.js
CHANGED
|
@@ -7,46 +7,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
10
|
import BIPPath from "bip32-path";
|
|
38
11
|
import { UserRefusedOnDevice } from "@ledgerhq/errors";
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
12
|
+
const CHUNK_SIZE = 250;
|
|
13
|
+
const CLA = 0x55;
|
|
14
|
+
const APP_KEY = "CSM";
|
|
15
|
+
const INS_GET_VERSION = 0x00;
|
|
16
|
+
const INS_SIGN_SECP256K1 = 0x02;
|
|
17
|
+
const INS_GET_ADDR_SECP256K1 = 0x04;
|
|
18
|
+
const PAYLOAD_TYPE_INIT = 0x00;
|
|
19
|
+
const PAYLOAD_TYPE_ADD = 0x01;
|
|
20
|
+
const PAYLOAD_TYPE_LAST = 0x02;
|
|
21
|
+
const SW_OK = 0x9000;
|
|
22
|
+
const SW_CANCEL = 0x6986;
|
|
50
23
|
/**
|
|
51
24
|
* Cosmos API
|
|
52
25
|
*
|
|
@@ -54,25 +27,24 @@ var SW_CANCEL = 0x6986;
|
|
|
54
27
|
* import Cosmos from "@ledgerhq/hw-app-cosmos";
|
|
55
28
|
* const cosmos = new Cosmos(transport)
|
|
56
29
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (scrambleKey === void 0) { scrambleKey = APP_KEY; }
|
|
30
|
+
export default class Cosmos {
|
|
31
|
+
constructor(transport, scrambleKey = APP_KEY) {
|
|
60
32
|
this.transport = transport;
|
|
61
33
|
transport.decorateAppAPIMethods(this, ["getAddress", "sign", "getAppConfiguration"], scrambleKey);
|
|
62
34
|
}
|
|
63
35
|
// FIXME: understand what is going on with the return type here
|
|
64
|
-
|
|
65
|
-
return this.transport.send(CLA, INS_GET_VERSION, 0, 0).then(
|
|
36
|
+
getAppConfiguration() {
|
|
37
|
+
return this.transport.send(CLA, INS_GET_VERSION, 0, 0).then((response) => {
|
|
66
38
|
return {
|
|
67
39
|
test_mode: response[0] !== 0,
|
|
68
40
|
version: "" + response[1] + "." + response[2] + "." + response[3],
|
|
69
41
|
device_locked: response[4] === 1,
|
|
70
|
-
major: response[1]
|
|
42
|
+
major: response[1],
|
|
71
43
|
};
|
|
72
44
|
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
45
|
+
}
|
|
46
|
+
serializePath(path) {
|
|
47
|
+
const buf = Buffer.alloc(20);
|
|
76
48
|
// HACK : without the >>>,
|
|
77
49
|
// the bitwise implicitly casts the result to be a signed int32,
|
|
78
50
|
// which fails the internal type check of Buffer in case of overload.
|
|
@@ -82,16 +54,16 @@ var Cosmos = /** @class */ (function () {
|
|
|
82
54
|
buf.writeUInt32LE(path[3], 12);
|
|
83
55
|
buf.writeUInt32LE(path[4], 16);
|
|
84
56
|
return buf;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (hrp == null || hrp.length
|
|
57
|
+
}
|
|
58
|
+
serializeHRP(hrp) {
|
|
59
|
+
if (hrp == null || hrp.length === 0 || hrp.length > 83) {
|
|
88
60
|
throw new Error("Invalid HRP");
|
|
89
61
|
}
|
|
90
|
-
|
|
62
|
+
const buf = Buffer.alloc(1 + hrp.length);
|
|
91
63
|
buf.writeUInt8(hrp.length, 0);
|
|
92
64
|
buf.write(hrp, 1);
|
|
93
65
|
return buf;
|
|
94
|
-
}
|
|
66
|
+
}
|
|
95
67
|
/**
|
|
96
68
|
* get Cosmos address for a given BIP 32 path.
|
|
97
69
|
* @param path a path in BIP 32 format
|
|
@@ -101,22 +73,22 @@ var Cosmos = /** @class */ (function () {
|
|
|
101
73
|
* @example
|
|
102
74
|
* cosmos.getAddress("44'/60'/0'/0/0", "cosmos").then(o => o.address)
|
|
103
75
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
76
|
+
getAddress(path, hrp, boolDisplay) {
|
|
77
|
+
const bipPath = BIPPath.fromString(path).toPathArray();
|
|
78
|
+
const serializedPath = this.serializePath(bipPath);
|
|
79
|
+
const data = Buffer.concat([this.serializeHRP(hrp), serializedPath]);
|
|
108
80
|
return this.transport
|
|
109
81
|
.send(CLA, INS_GET_ADDR_SECP256K1, boolDisplay ? 1 : 0, 0, data, [SW_OK])
|
|
110
|
-
.then(
|
|
111
|
-
|
|
112
|
-
|
|
82
|
+
.then((response) => {
|
|
83
|
+
const address = Buffer.from(response.slice(33, -2)).toString();
|
|
84
|
+
const publicKey = Buffer.from(response.slice(0, 33)).toString("hex");
|
|
113
85
|
return {
|
|
114
|
-
address
|
|
115
|
-
publicKey
|
|
86
|
+
address,
|
|
87
|
+
publicKey,
|
|
116
88
|
};
|
|
117
89
|
});
|
|
118
|
-
}
|
|
119
|
-
|
|
90
|
+
}
|
|
91
|
+
foreach(arr, callback) {
|
|
120
92
|
function iterate(index, array, result) {
|
|
121
93
|
if (index >= array.length) {
|
|
122
94
|
return result;
|
|
@@ -127,53 +99,45 @@ var Cosmos = /** @class */ (function () {
|
|
|
127
99
|
return iterate(index + 1, array, result);
|
|
128
100
|
});
|
|
129
101
|
}
|
|
130
|
-
return Promise.resolve().then(
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
102
|
+
return Promise.resolve().then(() => iterate(0, arr, []));
|
|
103
|
+
}
|
|
104
|
+
sign(path, message) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const bipPath = BIPPath.fromString(path).toPathArray();
|
|
107
|
+
const serializedPath = this.serializePath(bipPath);
|
|
108
|
+
const chunks = [];
|
|
109
|
+
chunks.push(serializedPath);
|
|
110
|
+
const buffer = Buffer.from(message);
|
|
111
|
+
for (let i = 0; i < buffer.length; i += CHUNK_SIZE) {
|
|
112
|
+
let end = i + CHUNK_SIZE;
|
|
113
|
+
if (i > buffer.length) {
|
|
114
|
+
end = buffer.length;
|
|
115
|
+
}
|
|
116
|
+
chunks.push(buffer.slice(i, end));
|
|
117
|
+
}
|
|
118
|
+
let response = {};
|
|
119
|
+
return this.foreach(chunks, (data, j) => this.transport
|
|
120
|
+
.send(CLA, INS_SIGN_SECP256K1, j === 0
|
|
121
|
+
? PAYLOAD_TYPE_INIT
|
|
122
|
+
: j + 1 === chunks.length
|
|
123
|
+
? PAYLOAD_TYPE_LAST
|
|
124
|
+
: PAYLOAD_TYPE_ADD, 0, data, [SW_OK, SW_CANCEL])
|
|
125
|
+
.then((apduResponse) => (response = apduResponse))).then(() => {
|
|
126
|
+
const errorCodeData = response.slice(-2);
|
|
127
|
+
const returnCode = errorCodeData[0] * 256 + errorCodeData[1];
|
|
128
|
+
let signature = null;
|
|
129
|
+
if (response.length > 2) {
|
|
130
|
+
signature = response.slice(0, response.length - 2);
|
|
131
|
+
}
|
|
132
|
+
if (returnCode === 0x6986) {
|
|
133
|
+
throw new UserRefusedOnDevice();
|
|
148
134
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
? PAYLOAD_TYPE_INIT
|
|
154
|
-
: j + 1 === chunks.length
|
|
155
|
-
? PAYLOAD_TYPE_LAST
|
|
156
|
-
: PAYLOAD_TYPE_ADD, 0, data, [SW_OK, SW_CANCEL])
|
|
157
|
-
.then(function (apduResponse) { return (response = apduResponse); });
|
|
158
|
-
}).then(function () {
|
|
159
|
-
var errorCodeData = response.slice(-2);
|
|
160
|
-
var returnCode = errorCodeData[0] * 256 + errorCodeData[1];
|
|
161
|
-
var signature = null;
|
|
162
|
-
if (response.length > 2) {
|
|
163
|
-
signature = response.slice(0, response.length - 2);
|
|
164
|
-
}
|
|
165
|
-
if (returnCode === 0x6986) {
|
|
166
|
-
throw new UserRefusedOnDevice();
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
signature: signature,
|
|
170
|
-
return_code: returnCode
|
|
171
|
-
};
|
|
172
|
-
})];
|
|
135
|
+
return {
|
|
136
|
+
signature,
|
|
137
|
+
return_code: returnCode,
|
|
138
|
+
};
|
|
173
139
|
});
|
|
174
140
|
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
}());
|
|
178
|
-
export default Cosmos;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
179
143
|
//# sourceMappingURL=Cosmos.js.map
|
package/lib-es/Cosmos.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cosmos.js","sourceRoot":"","sources":["../src/Cosmos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Cosmos.js","sourceRoot":"","sources":["../src/Cosmos.ts"],"names":[],"mappings":";;;;;;;;;AAiBA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,GAAG,GAAG,IAAI,CAAC;AACjB,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,iBAAiB,GAAG,I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gBAEpC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;oBACvB,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;iBACpD;gBAED,IAAI,UAAU,KAAK,MAAM,EAAE;oBACzB,MAAM,IAAI,mBAAmB,EAAE,CAAC;iBACjC;gBAED,OAAO;oBACL,SAAS;oBACT,WAAW,EAAE,UAAU;iBACxB,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/hw-app-cosmos",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.28.0-next.0",
|
|
4
4
|
"description": "Ledger Hardware Wallet Cosmos Application API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -28,20 +28,19 @@
|
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"bip32-path": "^0.4.2",
|
|
31
|
-
"@ledgerhq/errors": "^6.12.
|
|
32
|
-
"@ledgerhq/hw-transport": "^6.28.
|
|
31
|
+
"@ledgerhq/errors": "^6.12.5-next.0",
|
|
32
|
+
"@ledgerhq/hw-transport": "^6.28.3-next.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/jest": "^29.5.0",
|
|
36
36
|
"@types/node": "^18.15.3",
|
|
37
37
|
"documentation": "13.2.4",
|
|
38
38
|
"jest": "^28.1.1",
|
|
39
|
-
"rimraf": "^4.1
|
|
39
|
+
"rimraf": "^4.4.1",
|
|
40
40
|
"source-map-support": "^0.5.21",
|
|
41
41
|
"ts-jest": "^28.0.5",
|
|
42
42
|
"ts-node": "^10.4.0",
|
|
43
|
-
"
|
|
44
|
-
"@ledgerhq/hw-transport-mocker": "^6.27.13"
|
|
43
|
+
"@ledgerhq/hw-transport-mocker": "^6.27.14-next.0"
|
|
45
44
|
},
|
|
46
45
|
"gitHead": "dd0dea64b58e5a9125c8a422dcffd29e5ef6abec",
|
|
47
46
|
"scripts": {
|
package/src/Cosmos.ts
CHANGED