@ledgerhq/hw-app-eth 6.28.2 → 6.29.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/.turbo/turbo-build.log +5 -2
- package/CHANGELOG.md +13 -0
- package/README.md +58 -16
- package/jest.config.ts +6 -0
- package/lib/Eth.d.ts +37 -0
- package/lib/Eth.d.ts.map +1 -1
- package/lib/Eth.js +66 -72
- package/lib/Eth.js.map +1 -1
- package/lib/modules/EIP712/EIP712.types.d.ts +44 -0
- package/lib/modules/EIP712/EIP712.types.d.ts.map +1 -0
- package/lib/modules/EIP712/EIP712.types.js +3 -0
- package/lib/modules/EIP712/EIP712.types.js.map +1 -0
- package/lib/modules/EIP712/EIP712.utils.d.ts +65 -0
- package/lib/modules/EIP712/EIP712.utils.d.ts.map +1 -0
- package/lib/modules/EIP712/EIP712.utils.js +217 -0
- package/lib/modules/EIP712/EIP712.utils.js.map +1 -0
- package/lib/modules/EIP712/index.d.ts +60 -0
- package/lib/modules/EIP712/index.d.ts.map +1 -0
- package/lib/modules/EIP712/index.js +554 -0
- package/lib/modules/EIP712/index.js.map +1 -0
- package/lib/utils.d.ts +15 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +43 -3
- package/lib/utils.js.map +1 -1
- package/lib-es/Eth.d.ts +37 -0
- package/lib-es/Eth.d.ts.map +1 -1
- package/lib-es/Eth.js +42 -48
- package/lib-es/Eth.js.map +1 -1
- package/lib-es/modules/EIP712/EIP712.types.d.ts +44 -0
- package/lib-es/modules/EIP712/EIP712.types.d.ts.map +1 -0
- package/lib-es/modules/EIP712/EIP712.types.js +2 -0
- package/lib-es/modules/EIP712/EIP712.types.js.map +1 -0
- package/lib-es/modules/EIP712/EIP712.utils.d.ts +65 -0
- package/lib-es/modules/EIP712/EIP712.utils.d.ts.map +1 -0
- package/lib-es/modules/EIP712/EIP712.utils.js +211 -0
- package/lib-es/modules/EIP712/EIP712.utils.js.map +1 -0
- package/lib-es/modules/EIP712/index.d.ts +60 -0
- package/lib-es/modules/EIP712/index.d.ts.map +1 -0
- package/lib-es/modules/EIP712/index.js +549 -0
- package/lib-es/modules/EIP712/index.js.map +1 -0
- package/lib-es/services/ledger/contracts.d.ts +0 -0
- package/lib-es/services/ledger/contracts.d.ts.map +0 -0
- package/lib-es/services/ledger/contracts.js +0 -0
- package/lib-es/services/ledger/contracts.js.map +0 -0
- package/lib-es/services/ledger/erc20.d.ts +0 -0
- package/lib-es/services/ledger/erc20.d.ts.map +0 -0
- package/lib-es/services/ledger/erc20.js +0 -0
- package/lib-es/services/ledger/erc20.js.map +0 -0
- package/lib-es/services/ledger/index.d.ts +0 -0
- package/lib-es/services/ledger/index.d.ts.map +0 -0
- package/lib-es/services/ledger/index.js +0 -0
- package/lib-es/services/ledger/index.js.map +0 -0
- package/lib-es/services/ledger/loadConfig.d.ts +0 -0
- package/lib-es/services/ledger/loadConfig.d.ts.map +0 -0
- package/lib-es/services/ledger/loadConfig.js +0 -0
- package/lib-es/services/ledger/loadConfig.js.map +0 -0
- package/lib-es/services/ledger/nfts.d.ts +0 -0
- package/lib-es/services/ledger/nfts.d.ts.map +0 -0
- package/lib-es/services/ledger/nfts.js +0 -0
- package/lib-es/services/ledger/nfts.js.map +0 -0
- package/lib-es/services/types.d.ts +0 -0
- package/lib-es/services/types.d.ts.map +0 -0
- package/lib-es/services/types.js +0 -0
- package/lib-es/services/types.js.map +0 -0
- package/lib-es/utils.d.ts +15 -1
- package/lib-es/utils.d.ts.map +1 -1
- package/lib-es/utils.js +38 -2
- package/lib-es/utils.js.map +1 -1
- package/package.json +13 -8
- package/src/Eth.ts +59 -56
- package/src/modules/EIP712/EIP712.types.ts +54 -0
- package/src/modules/EIP712/EIP712.utils.ts +251 -0
- package/src/modules/EIP712/index.ts +409 -0
- package/src/utils.ts +42 -2
- package/tests/EIP712.unit.test.ts +760 -0
- package/tests/sample-messages/0.apdus +58 -0
- package/tests/sample-messages/0.json +44 -0
- package/tests/sample-messages/1.apdus +66 -0
- package/tests/sample-messages/1.json +50 -0
- package/tests/sample-messages/10.apdus +30 -0
- package/tests/sample-messages/10.json +23 -0
- package/tests/sample-messages/2.apdus +126 -0
- package/tests/sample-messages/2.json +153 -0
- package/tests/sample-messages/3.apdus +42 -0
- package/tests/sample-messages/3.json +31 -0
- package/tests/sample-messages/4.apdus +84 -0
- package/tests/sample-messages/4.json +110 -0
- package/tests/sample-messages/5.apdus +112 -0
- package/tests/sample-messages/5.json +92 -0
- package/tests/sample-messages/6.apdus +94 -0
- package/tests/sample-messages/6.json +78 -0
- package/tests/sample-messages/7.apdus +70 -0
- package/tests/sample-messages/7.json +55 -0
- package/tests/sample-messages/8.apdus +68 -0
- package/tests/sample-messages/8.json +50 -0
- package/tests/sample-messages/9.apdus +68 -0
- package/tests/sample-messages/9.json +50 -0
- package/LICENSE +0 -202
- package/lib-es/contracts.d.ts +0 -17
- package/lib-es/contracts.d.ts.map +0 -1
- package/lib-es/contracts.js +0 -103
- package/lib-es/contracts.js.map +0 -1
- package/lib-es/erc20.d.ts +0 -22
- package/lib-es/erc20.d.ts.map +0 -1
- package/lib-es/erc20.js +0 -64
- package/lib-es/erc20.js.map +0 -1
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
49
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50
|
+
if (!m) return o;
|
|
51
|
+
var i = m.call(o), r, ar = [], e;
|
|
52
|
+
try {
|
|
53
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
54
|
+
}
|
|
55
|
+
catch (error) { e = { error: error }; }
|
|
56
|
+
finally {
|
|
57
|
+
try {
|
|
58
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
59
|
+
}
|
|
60
|
+
finally { if (e) throw e.error; }
|
|
61
|
+
}
|
|
62
|
+
return ar;
|
|
63
|
+
};
|
|
64
|
+
var __values = (this && this.__values) || function(o) {
|
|
65
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
66
|
+
if (m) return m.call(o);
|
|
67
|
+
if (o && typeof o.length === "number") return {
|
|
68
|
+
next: function () {
|
|
69
|
+
if (o && i >= o.length) o = void 0;
|
|
70
|
+
return { value: o && o[i++], done: !o };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
74
|
+
};
|
|
75
|
+
import { hexBuffer, intAsHexBytes, splitPath } from "../../utils";
|
|
76
|
+
import { destructTypeFromString, EIP712_TYPE_ENCODERS, EIP712_TYPE_PROPERTIES, makeTypeEntryStructBuffer, } from "./EIP712.utils";
|
|
77
|
+
/**
|
|
78
|
+
* @ignore for the README
|
|
79
|
+
*
|
|
80
|
+
* Factory to create the recursive function that will pass on each
|
|
81
|
+
* field level and APDUs to describe its structure implementation
|
|
82
|
+
*
|
|
83
|
+
* @param {Eth["EIP712SendStructImplem"]} EIP712SendStructImplem
|
|
84
|
+
* @param {EIP712MessageTypes} types
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
87
|
+
var makeRecursiveFieldStructImplem = function (transport, types) {
|
|
88
|
+
var _a;
|
|
89
|
+
var typesMap = {};
|
|
90
|
+
for (var type in types) {
|
|
91
|
+
typesMap[type] = (_a = types[type]) === null || _a === void 0 ? void 0 : _a.reduce(function (acc, curr) {
|
|
92
|
+
var _a;
|
|
93
|
+
return (__assign(__assign({}, acc), (_a = {}, _a[curr.name] = curr.type, _a)));
|
|
94
|
+
}, {});
|
|
95
|
+
}
|
|
96
|
+
// This recursion will call itself to handle each level of each field
|
|
97
|
+
// in order to send APDUs for each of them
|
|
98
|
+
var recursiveFieldStructImplem = function (destructedType, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
+
var _a, typeDescription, arrSizes, _b, currSize, restSizes, isCustomType, data_1, data_1_1, entry, e_1_1, _c, _d, _e, fieldName, fieldValue, fieldType, e_2_1;
|
|
100
|
+
var e_1, _f, e_2, _g;
|
|
101
|
+
var _h;
|
|
102
|
+
return __generator(this, function (_j) {
|
|
103
|
+
switch (_j.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
_a = __read(destructedType, 2), typeDescription = _a[0], arrSizes = _a[1];
|
|
106
|
+
_b = __read(arrSizes), currSize = _b[0], restSizes = _b.slice(1);
|
|
107
|
+
isCustomType = !EIP712_TYPE_PROPERTIES[((_h = typeDescription === null || typeDescription === void 0 ? void 0 : typeDescription.name) === null || _h === void 0 ? void 0 : _h.toUpperCase()) || ""];
|
|
108
|
+
if (!(Array.isArray(data) && typeof currSize !== "undefined")) return [3 /*break*/, 10];
|
|
109
|
+
return [4 /*yield*/, EIP712SendStructImplem(transport, {
|
|
110
|
+
structType: "array",
|
|
111
|
+
value: data.length
|
|
112
|
+
})];
|
|
113
|
+
case 1:
|
|
114
|
+
_j.sent();
|
|
115
|
+
_j.label = 2;
|
|
116
|
+
case 2:
|
|
117
|
+
_j.trys.push([2, 7, 8, 9]);
|
|
118
|
+
data_1 = __values(data), data_1_1 = data_1.next();
|
|
119
|
+
_j.label = 3;
|
|
120
|
+
case 3:
|
|
121
|
+
if (!!data_1_1.done) return [3 /*break*/, 6];
|
|
122
|
+
entry = data_1_1.value;
|
|
123
|
+
return [4 /*yield*/, recursiveFieldStructImplem([typeDescription, restSizes], entry)];
|
|
124
|
+
case 4:
|
|
125
|
+
_j.sent();
|
|
126
|
+
_j.label = 5;
|
|
127
|
+
case 5:
|
|
128
|
+
data_1_1 = data_1.next();
|
|
129
|
+
return [3 /*break*/, 3];
|
|
130
|
+
case 6: return [3 /*break*/, 9];
|
|
131
|
+
case 7:
|
|
132
|
+
e_1_1 = _j.sent();
|
|
133
|
+
e_1 = { error: e_1_1 };
|
|
134
|
+
return [3 /*break*/, 9];
|
|
135
|
+
case 8:
|
|
136
|
+
try {
|
|
137
|
+
if (data_1_1 && !data_1_1.done && (_f = data_1["return"])) _f.call(data_1);
|
|
138
|
+
}
|
|
139
|
+
finally { if (e_1) throw e_1.error; }
|
|
140
|
+
return [7 /*endfinally*/];
|
|
141
|
+
case 9: return [3 /*break*/, 21];
|
|
142
|
+
case 10:
|
|
143
|
+
if (!isCustomType) return [3 /*break*/, 19];
|
|
144
|
+
_j.label = 11;
|
|
145
|
+
case 11:
|
|
146
|
+
_j.trys.push([11, 16, 17, 18]);
|
|
147
|
+
_c = __values(Object.entries(data)), _d = _c.next();
|
|
148
|
+
_j.label = 12;
|
|
149
|
+
case 12:
|
|
150
|
+
if (!!_d.done) return [3 /*break*/, 15];
|
|
151
|
+
_e = __read(_d.value, 2), fieldName = _e[0], fieldValue = _e[1];
|
|
152
|
+
fieldType = typesMap === null || typesMap === void 0 ? void 0 : typesMap[(typeDescription === null || typeDescription === void 0 ? void 0 : typeDescription.name) || ""][fieldName];
|
|
153
|
+
if (!fieldType) return [3 /*break*/, 14];
|
|
154
|
+
return [4 /*yield*/, recursiveFieldStructImplem(destructTypeFromString(fieldType), fieldValue)];
|
|
155
|
+
case 13:
|
|
156
|
+
_j.sent();
|
|
157
|
+
_j.label = 14;
|
|
158
|
+
case 14:
|
|
159
|
+
_d = _c.next();
|
|
160
|
+
return [3 /*break*/, 12];
|
|
161
|
+
case 15: return [3 /*break*/, 18];
|
|
162
|
+
case 16:
|
|
163
|
+
e_2_1 = _j.sent();
|
|
164
|
+
e_2 = { error: e_2_1 };
|
|
165
|
+
return [3 /*break*/, 18];
|
|
166
|
+
case 17:
|
|
167
|
+
try {
|
|
168
|
+
if (_d && !_d.done && (_g = _c["return"])) _g.call(_c);
|
|
169
|
+
}
|
|
170
|
+
finally { if (e_2) throw e_2.error; }
|
|
171
|
+
return [7 /*endfinally*/];
|
|
172
|
+
case 18: return [3 /*break*/, 21];
|
|
173
|
+
case 19: return [4 /*yield*/, EIP712SendStructImplem(transport, {
|
|
174
|
+
structType: "field",
|
|
175
|
+
value: {
|
|
176
|
+
data: data,
|
|
177
|
+
type: (typeDescription === null || typeDescription === void 0 ? void 0 : typeDescription.name) || "",
|
|
178
|
+
sizeInBits: typeDescription === null || typeDescription === void 0 ? void 0 : typeDescription.bits
|
|
179
|
+
}
|
|
180
|
+
})];
|
|
181
|
+
case 20:
|
|
182
|
+
_j.sent();
|
|
183
|
+
_j.label = 21;
|
|
184
|
+
case 21: return [2 /*return*/];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}); };
|
|
188
|
+
return recursiveFieldStructImplem;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* @ignore for the README
|
|
192
|
+
*
|
|
193
|
+
* This method is used to send the message definition with all its types.
|
|
194
|
+
* This method should be used before the EIP712SendStructImplem one
|
|
195
|
+
*
|
|
196
|
+
* @param {String} structType
|
|
197
|
+
* @param {String|Buffer} value
|
|
198
|
+
* @returns {Promise<void>}
|
|
199
|
+
*/
|
|
200
|
+
var EIP712SendStructDef = function (transport, structDef) {
|
|
201
|
+
var APDU_FIELDS;
|
|
202
|
+
(function (APDU_FIELDS) {
|
|
203
|
+
APDU_FIELDS[APDU_FIELDS["CLA"] = 224] = "CLA";
|
|
204
|
+
APDU_FIELDS[APDU_FIELDS["INS"] = 26] = "INS";
|
|
205
|
+
APDU_FIELDS[APDU_FIELDS["P1_complete"] = 0] = "P1_complete";
|
|
206
|
+
APDU_FIELDS[APDU_FIELDS["P1_partial"] = 1] = "P1_partial";
|
|
207
|
+
APDU_FIELDS[APDU_FIELDS["P2_name"] = 0] = "P2_name";
|
|
208
|
+
APDU_FIELDS[APDU_FIELDS["P2_field"] = 255] = "P2_field";
|
|
209
|
+
})(APDU_FIELDS || (APDU_FIELDS = {}));
|
|
210
|
+
var structType = structDef.structType, value = structDef.value;
|
|
211
|
+
var data = structType === "name" && typeof value === "string"
|
|
212
|
+
? Buffer.from(value, "utf-8")
|
|
213
|
+
: value;
|
|
214
|
+
return transport.send(APDU_FIELDS.CLA, APDU_FIELDS.INS, APDU_FIELDS.P1_complete, structType === "name" ? APDU_FIELDS.P2_name : APDU_FIELDS.P2_field, data);
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* @ignore for the README
|
|
218
|
+
*
|
|
219
|
+
* This method provides a trusted new display name to use for the upcoming field.
|
|
220
|
+
* This method should be used after the EIP712SendStructDef one.
|
|
221
|
+
*
|
|
222
|
+
* If the method describes an empty name (length of 0), the upcoming field will be taken
|
|
223
|
+
* into account but won’t be shown on the device.
|
|
224
|
+
*
|
|
225
|
+
* The signature is computed on :
|
|
226
|
+
* json key length || json key || display name length || display name
|
|
227
|
+
*
|
|
228
|
+
* signed by the following secp256k1 public key:
|
|
229
|
+
* 0482bbf2f34f367b2e5bc21847b6566f21f0976b22d3388a9a5e446ac62d25cf725b62a2555b2dd464a4da0ab2f4d506820543af1d242470b1b1a969a27578f353
|
|
230
|
+
*
|
|
231
|
+
* @param {String} structType "root" | "array" | "field"
|
|
232
|
+
* @param {string | number | StructFieldData} value
|
|
233
|
+
* @returns {Promise<Buffer | void>}
|
|
234
|
+
*/
|
|
235
|
+
var EIP712SendStructImplem = function (transport, structImplem) { return __awaiter(void 0, void 0, void 0, function () {
|
|
236
|
+
var APDU_FIELDS, structType, value, rawData, type, sizeInBits, encodedData, dataLengthPer16Bits, dataLengthModulo16Bits, data_2, bufferSlices, bufferSlices_1, bufferSlices_1_1, bufferSlice, e_3_1;
|
|
237
|
+
var e_3, _a;
|
|
238
|
+
var _b;
|
|
239
|
+
return __generator(this, function (_c) {
|
|
240
|
+
switch (_c.label) {
|
|
241
|
+
case 0:
|
|
242
|
+
(function (APDU_FIELDS) {
|
|
243
|
+
APDU_FIELDS[APDU_FIELDS["CLA"] = 224] = "CLA";
|
|
244
|
+
APDU_FIELDS[APDU_FIELDS["INS"] = 28] = "INS";
|
|
245
|
+
APDU_FIELDS[APDU_FIELDS["P1_complete"] = 0] = "P1_complete";
|
|
246
|
+
APDU_FIELDS[APDU_FIELDS["P1_partial"] = 1] = "P1_partial";
|
|
247
|
+
APDU_FIELDS[APDU_FIELDS["P2_root"] = 0] = "P2_root";
|
|
248
|
+
APDU_FIELDS[APDU_FIELDS["P2_array"] = 15] = "P2_array";
|
|
249
|
+
APDU_FIELDS[APDU_FIELDS["P2_field"] = 255] = "P2_field";
|
|
250
|
+
})(APDU_FIELDS || (APDU_FIELDS = {}));
|
|
251
|
+
structType = structImplem.structType, value = structImplem.value;
|
|
252
|
+
if (structType === "root") {
|
|
253
|
+
return [2 /*return*/, transport.send(APDU_FIELDS.CLA, APDU_FIELDS.INS, APDU_FIELDS.P1_complete, APDU_FIELDS.P2_root, Buffer.from(value, "utf-8"))];
|
|
254
|
+
}
|
|
255
|
+
if (structType === "array") {
|
|
256
|
+
return [2 /*return*/, transport.send(APDU_FIELDS.CLA, APDU_FIELDS.INS, APDU_FIELDS.P1_complete, APDU_FIELDS.P2_array, Buffer.from(intAsHexBytes(value, 1), "hex"))];
|
|
257
|
+
}
|
|
258
|
+
if (!(structType === "field")) return [3 /*break*/, 8];
|
|
259
|
+
rawData = value.data, type = value.type, sizeInBits = value.sizeInBits;
|
|
260
|
+
encodedData = (_b = EIP712_TYPE_ENCODERS[type.toUpperCase()]) === null || _b === void 0 ? void 0 : _b.call(EIP712_TYPE_ENCODERS, rawData, sizeInBits);
|
|
261
|
+
if (!encodedData) return [3 /*break*/, 8];
|
|
262
|
+
dataLengthPer16Bits = Math.floor(encodedData.length / 256);
|
|
263
|
+
dataLengthModulo16Bits = encodedData.length % 256;
|
|
264
|
+
data_2 = Buffer.concat([
|
|
265
|
+
Buffer.from(intAsHexBytes(dataLengthPer16Bits, 1), "hex"),
|
|
266
|
+
Buffer.from(intAsHexBytes(dataLengthModulo16Bits, 1), "hex"),
|
|
267
|
+
encodedData,
|
|
268
|
+
]);
|
|
269
|
+
bufferSlices = new Array(Math.ceil(data_2.length / 256))
|
|
270
|
+
.fill(null)
|
|
271
|
+
.map(function (_, i) { return data_2.slice(i * 255, (i + 1) * 255); });
|
|
272
|
+
_c.label = 1;
|
|
273
|
+
case 1:
|
|
274
|
+
_c.trys.push([1, 6, 7, 8]);
|
|
275
|
+
bufferSlices_1 = __values(bufferSlices), bufferSlices_1_1 = bufferSlices_1.next();
|
|
276
|
+
_c.label = 2;
|
|
277
|
+
case 2:
|
|
278
|
+
if (!!bufferSlices_1_1.done) return [3 /*break*/, 5];
|
|
279
|
+
bufferSlice = bufferSlices_1_1.value;
|
|
280
|
+
return [4 /*yield*/, transport.send(APDU_FIELDS.CLA, APDU_FIELDS.INS, bufferSlice !== bufferSlices[bufferSlices.length - 1]
|
|
281
|
+
? APDU_FIELDS.P1_partial
|
|
282
|
+
: APDU_FIELDS.P1_complete, APDU_FIELDS.P2_field, bufferSlice)];
|
|
283
|
+
case 3:
|
|
284
|
+
_c.sent();
|
|
285
|
+
_c.label = 4;
|
|
286
|
+
case 4:
|
|
287
|
+
bufferSlices_1_1 = bufferSlices_1.next();
|
|
288
|
+
return [3 /*break*/, 2];
|
|
289
|
+
case 5: return [3 /*break*/, 8];
|
|
290
|
+
case 6:
|
|
291
|
+
e_3_1 = _c.sent();
|
|
292
|
+
e_3 = { error: e_3_1 };
|
|
293
|
+
return [3 /*break*/, 8];
|
|
294
|
+
case 7:
|
|
295
|
+
try {
|
|
296
|
+
if (bufferSlices_1_1 && !bufferSlices_1_1.done && (_a = bufferSlices_1["return"])) _a.call(bufferSlices_1);
|
|
297
|
+
}
|
|
298
|
+
finally { if (e_3) throw e_3.error; }
|
|
299
|
+
return [7 /*endfinally*/];
|
|
300
|
+
case 8: return [2 /*return*/, Promise.resolve()];
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}); };
|
|
304
|
+
/**
|
|
305
|
+
* @ignore for the README
|
|
306
|
+
*
|
|
307
|
+
* Sign an EIP-721 formatted message following the specification here:
|
|
308
|
+
* https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.asc#sign-eth-eip-712
|
|
309
|
+
* @example
|
|
310
|
+
eth.signEIP721Message("44'/60'/0'/0/0", {
|
|
311
|
+
domain: {
|
|
312
|
+
chainId: 69,
|
|
313
|
+
name: "Da Domain",
|
|
314
|
+
verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
|
|
315
|
+
version: "1"
|
|
316
|
+
},
|
|
317
|
+
types: {
|
|
318
|
+
"EIP712Domain": [
|
|
319
|
+
{ name: "name", type: "string" },
|
|
320
|
+
{ name: "version", type: "string" },
|
|
321
|
+
{ name: "chainId", type: "uint256" },
|
|
322
|
+
{ name: "verifyingContract", type: "address" }
|
|
323
|
+
],
|
|
324
|
+
"Test": [
|
|
325
|
+
{ name: "contents", type: "string" }
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
primaryType: "Test",
|
|
329
|
+
message: {contents: "Hello, Bob!"},
|
|
330
|
+
})
|
|
331
|
+
*
|
|
332
|
+
* @param {String} path derivationPath
|
|
333
|
+
* @param {Object} jsonMessage message to sign
|
|
334
|
+
* @param {Boolean} fullImplem use the legacy implementation
|
|
335
|
+
* @returns {Promise}
|
|
336
|
+
*/
|
|
337
|
+
export var signEIP712Message = function (transport, path, jsonMessage, fullImplem) {
|
|
338
|
+
if (fullImplem === void 0) { fullImplem = false; }
|
|
339
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
340
|
+
var APDU_FIELDS, primaryType, types, domain, message, typeEntries, typeEntries_1, typeEntries_1_1, _a, typeName, entries, entries_1, entries_1_1, _b, name_1, type, typeEntryBuffer, e_4_1, e_5_1, recursiveFieldStructImplem, domainName, domainTypeFields, domainTypeFields_1, domainTypeFields_1_1, _c, name_2, type, domainFieldValue, e_6_1, primaryTypeFields, primaryTypeFields_1, primaryTypeFields_1_1, _d, name_3, type, primaryTypeValue, e_7_1, paths, signatureBuffer;
|
|
341
|
+
var e_5, _e, e_4, _f, e_6, _g, e_7, _h;
|
|
342
|
+
return __generator(this, function (_j) {
|
|
343
|
+
switch (_j.label) {
|
|
344
|
+
case 0:
|
|
345
|
+
(function (APDU_FIELDS) {
|
|
346
|
+
APDU_FIELDS[APDU_FIELDS["CLA"] = 224] = "CLA";
|
|
347
|
+
APDU_FIELDS[APDU_FIELDS["INS"] = 12] = "INS";
|
|
348
|
+
APDU_FIELDS[APDU_FIELDS["P1"] = 0] = "P1";
|
|
349
|
+
APDU_FIELDS[APDU_FIELDS["P2_v0"] = 0] = "P2_v0";
|
|
350
|
+
APDU_FIELDS[APDU_FIELDS["P2_full"] = 1] = "P2_full";
|
|
351
|
+
})(APDU_FIELDS || (APDU_FIELDS = {}));
|
|
352
|
+
primaryType = jsonMessage.primaryType, types = jsonMessage.types, domain = jsonMessage.domain, message = jsonMessage.message;
|
|
353
|
+
typeEntries = Object.entries(types);
|
|
354
|
+
_j.label = 1;
|
|
355
|
+
case 1:
|
|
356
|
+
_j.trys.push([1, 13, 14, 15]);
|
|
357
|
+
typeEntries_1 = __values(typeEntries), typeEntries_1_1 = typeEntries_1.next();
|
|
358
|
+
_j.label = 2;
|
|
359
|
+
case 2:
|
|
360
|
+
if (!!typeEntries_1_1.done) return [3 /*break*/, 12];
|
|
361
|
+
_a = __read(typeEntries_1_1.value, 2), typeName = _a[0], entries = _a[1];
|
|
362
|
+
return [4 /*yield*/, EIP712SendStructDef(transport, {
|
|
363
|
+
structType: "name",
|
|
364
|
+
value: typeName
|
|
365
|
+
})];
|
|
366
|
+
case 3:
|
|
367
|
+
_j.sent();
|
|
368
|
+
_j.label = 4;
|
|
369
|
+
case 4:
|
|
370
|
+
_j.trys.push([4, 9, 10, 11]);
|
|
371
|
+
entries_1 = (e_4 = void 0, __values(entries)), entries_1_1 = entries_1.next();
|
|
372
|
+
_j.label = 5;
|
|
373
|
+
case 5:
|
|
374
|
+
if (!!entries_1_1.done) return [3 /*break*/, 8];
|
|
375
|
+
_b = entries_1_1.value, name_1 = _b.name, type = _b.type;
|
|
376
|
+
typeEntryBuffer = makeTypeEntryStructBuffer({ name: name_1, type: type });
|
|
377
|
+
return [4 /*yield*/, EIP712SendStructDef(transport, {
|
|
378
|
+
structType: "field",
|
|
379
|
+
value: typeEntryBuffer
|
|
380
|
+
})];
|
|
381
|
+
case 6:
|
|
382
|
+
_j.sent();
|
|
383
|
+
_j.label = 7;
|
|
384
|
+
case 7:
|
|
385
|
+
entries_1_1 = entries_1.next();
|
|
386
|
+
return [3 /*break*/, 5];
|
|
387
|
+
case 8: return [3 /*break*/, 11];
|
|
388
|
+
case 9:
|
|
389
|
+
e_4_1 = _j.sent();
|
|
390
|
+
e_4 = { error: e_4_1 };
|
|
391
|
+
return [3 /*break*/, 11];
|
|
392
|
+
case 10:
|
|
393
|
+
try {
|
|
394
|
+
if (entries_1_1 && !entries_1_1.done && (_f = entries_1["return"])) _f.call(entries_1);
|
|
395
|
+
}
|
|
396
|
+
finally { if (e_4) throw e_4.error; }
|
|
397
|
+
return [7 /*endfinally*/];
|
|
398
|
+
case 11:
|
|
399
|
+
typeEntries_1_1 = typeEntries_1.next();
|
|
400
|
+
return [3 /*break*/, 2];
|
|
401
|
+
case 12: return [3 /*break*/, 15];
|
|
402
|
+
case 13:
|
|
403
|
+
e_5_1 = _j.sent();
|
|
404
|
+
e_5 = { error: e_5_1 };
|
|
405
|
+
return [3 /*break*/, 15];
|
|
406
|
+
case 14:
|
|
407
|
+
try {
|
|
408
|
+
if (typeEntries_1_1 && !typeEntries_1_1.done && (_e = typeEntries_1["return"])) _e.call(typeEntries_1);
|
|
409
|
+
}
|
|
410
|
+
finally { if (e_5) throw e_5.error; }
|
|
411
|
+
return [7 /*endfinally*/];
|
|
412
|
+
case 15:
|
|
413
|
+
recursiveFieldStructImplem = makeRecursiveFieldStructImplem(transport, types);
|
|
414
|
+
domainName = "EIP712Domain";
|
|
415
|
+
return [4 /*yield*/, EIP712SendStructImplem(transport, {
|
|
416
|
+
structType: "root",
|
|
417
|
+
value: domainName
|
|
418
|
+
})];
|
|
419
|
+
case 16:
|
|
420
|
+
_j.sent();
|
|
421
|
+
domainTypeFields = types[domainName];
|
|
422
|
+
_j.label = 17;
|
|
423
|
+
case 17:
|
|
424
|
+
_j.trys.push([17, 22, 23, 24]);
|
|
425
|
+
domainTypeFields_1 = __values(domainTypeFields), domainTypeFields_1_1 = domainTypeFields_1.next();
|
|
426
|
+
_j.label = 18;
|
|
427
|
+
case 18:
|
|
428
|
+
if (!!domainTypeFields_1_1.done) return [3 /*break*/, 21];
|
|
429
|
+
_c = domainTypeFields_1_1.value, name_2 = _c.name, type = _c.type;
|
|
430
|
+
domainFieldValue = domain[name_2];
|
|
431
|
+
return [4 /*yield*/, recursiveFieldStructImplem(destructTypeFromString(type), domainFieldValue)];
|
|
432
|
+
case 19:
|
|
433
|
+
_j.sent();
|
|
434
|
+
_j.label = 20;
|
|
435
|
+
case 20:
|
|
436
|
+
domainTypeFields_1_1 = domainTypeFields_1.next();
|
|
437
|
+
return [3 /*break*/, 18];
|
|
438
|
+
case 21: return [3 /*break*/, 24];
|
|
439
|
+
case 22:
|
|
440
|
+
e_6_1 = _j.sent();
|
|
441
|
+
e_6 = { error: e_6_1 };
|
|
442
|
+
return [3 /*break*/, 24];
|
|
443
|
+
case 23:
|
|
444
|
+
try {
|
|
445
|
+
if (domainTypeFields_1_1 && !domainTypeFields_1_1.done && (_g = domainTypeFields_1["return"])) _g.call(domainTypeFields_1);
|
|
446
|
+
}
|
|
447
|
+
finally { if (e_6) throw e_6.error; }
|
|
448
|
+
return [7 /*endfinally*/];
|
|
449
|
+
case 24:
|
|
450
|
+
// Looping on all primaryType type entries and fields to send
|
|
451
|
+
// structures' implementations
|
|
452
|
+
return [4 /*yield*/, EIP712SendStructImplem(transport, {
|
|
453
|
+
structType: "root",
|
|
454
|
+
value: primaryType
|
|
455
|
+
})];
|
|
456
|
+
case 25:
|
|
457
|
+
// Looping on all primaryType type entries and fields to send
|
|
458
|
+
// structures' implementations
|
|
459
|
+
_j.sent();
|
|
460
|
+
primaryTypeFields = types[primaryType];
|
|
461
|
+
_j.label = 26;
|
|
462
|
+
case 26:
|
|
463
|
+
_j.trys.push([26, 31, 32, 33]);
|
|
464
|
+
primaryTypeFields_1 = __values(primaryTypeFields), primaryTypeFields_1_1 = primaryTypeFields_1.next();
|
|
465
|
+
_j.label = 27;
|
|
466
|
+
case 27:
|
|
467
|
+
if (!!primaryTypeFields_1_1.done) return [3 /*break*/, 30];
|
|
468
|
+
_d = primaryTypeFields_1_1.value, name_3 = _d.name, type = _d.type;
|
|
469
|
+
primaryTypeValue = message[name_3];
|
|
470
|
+
return [4 /*yield*/, recursiveFieldStructImplem(destructTypeFromString(type), primaryTypeValue)];
|
|
471
|
+
case 28:
|
|
472
|
+
_j.sent();
|
|
473
|
+
_j.label = 29;
|
|
474
|
+
case 29:
|
|
475
|
+
primaryTypeFields_1_1 = primaryTypeFields_1.next();
|
|
476
|
+
return [3 /*break*/, 27];
|
|
477
|
+
case 30: return [3 /*break*/, 33];
|
|
478
|
+
case 31:
|
|
479
|
+
e_7_1 = _j.sent();
|
|
480
|
+
e_7 = { error: e_7_1 };
|
|
481
|
+
return [3 /*break*/, 33];
|
|
482
|
+
case 32:
|
|
483
|
+
try {
|
|
484
|
+
if (primaryTypeFields_1_1 && !primaryTypeFields_1_1.done && (_h = primaryTypeFields_1["return"])) _h.call(primaryTypeFields_1);
|
|
485
|
+
}
|
|
486
|
+
finally { if (e_7) throw e_7.error; }
|
|
487
|
+
return [7 /*endfinally*/];
|
|
488
|
+
case 33:
|
|
489
|
+
paths = splitPath(path);
|
|
490
|
+
signatureBuffer = Buffer.alloc(1 + paths.length * 4);
|
|
491
|
+
signatureBuffer[0] = paths.length;
|
|
492
|
+
paths.forEach(function (element, index) {
|
|
493
|
+
signatureBuffer.writeUInt32BE(element, 1 + 4 * index);
|
|
494
|
+
});
|
|
495
|
+
return [2 /*return*/, transport
|
|
496
|
+
.send(APDU_FIELDS.CLA, APDU_FIELDS.INS, APDU_FIELDS.P1, fullImplem ? APDU_FIELDS.P2_v0 : APDU_FIELDS.P2_full, signatureBuffer)
|
|
497
|
+
.then(function (response) {
|
|
498
|
+
var v = response[0];
|
|
499
|
+
var r = response.slice(1, 1 + 32).toString("hex");
|
|
500
|
+
var s = response.slice(1 + 32, 1 + 32 + 32).toString("hex");
|
|
501
|
+
return {
|
|
502
|
+
v: v,
|
|
503
|
+
r: r,
|
|
504
|
+
s: s
|
|
505
|
+
};
|
|
506
|
+
})];
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
};
|
|
511
|
+
/**
|
|
512
|
+
* @ignore for the README
|
|
513
|
+
* Sign a prepared message following web3.eth.signTypedData specification. The host computes the domain separator and hashStruct(message)
|
|
514
|
+
* @example
|
|
515
|
+
eth.signEIP712HashedMessage("44'/60'/0'/0/0", Buffer.from("0101010101010101010101010101010101010101010101010101010101010101").toString("hex"), Buffer.from("0202020202020202020202020202020202020202020202020202020202020202").toString("hex")).then(result => {
|
|
516
|
+
var v = result['v'] - 27;
|
|
517
|
+
v = v.toString(16);
|
|
518
|
+
if (v.length < 2) {
|
|
519
|
+
v = "0" + v;
|
|
520
|
+
}
|
|
521
|
+
console.log("Signature 0x" + result['r'] + result['s'] + v);
|
|
522
|
+
})
|
|
523
|
+
*/
|
|
524
|
+
export var signEIP712HashedMessage = function (transport, path, domainSeparatorHex, hashStructMessageHex) {
|
|
525
|
+
var domainSeparator = hexBuffer(domainSeparatorHex);
|
|
526
|
+
var hashStruct = hexBuffer(hashStructMessageHex);
|
|
527
|
+
var paths = splitPath(path);
|
|
528
|
+
var buffer = Buffer.alloc(1 + paths.length * 4 + 32 + 32, 0);
|
|
529
|
+
var offset = 0;
|
|
530
|
+
buffer[0] = paths.length;
|
|
531
|
+
paths.forEach(function (element, index) {
|
|
532
|
+
buffer.writeUInt32BE(element, 1 + 4 * index);
|
|
533
|
+
});
|
|
534
|
+
offset = 1 + 4 * paths.length;
|
|
535
|
+
domainSeparator.copy(buffer, offset);
|
|
536
|
+
offset += 32;
|
|
537
|
+
hashStruct.copy(buffer, offset);
|
|
538
|
+
return transport.send(0xe0, 0x0c, 0x00, 0x00, buffer).then(function (response) {
|
|
539
|
+
var v = response[0];
|
|
540
|
+
var r = response.slice(1, 1 + 32).toString("hex");
|
|
541
|
+
var s = response.slice(1 + 32, 1 + 32 + 32).toString("hex");
|
|
542
|
+
return {
|
|
543
|
+
v: v,
|
|
544
|
+
r: r,
|
|
545
|
+
s: s
|
|
546
|
+
};
|
|
547
|
+
});
|
|
548
|
+
};
|
|
549
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/EIP712/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO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changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/lib-es/services/types.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib-es/utils.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { BigNumber } from "bignumber.js";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function splitPath(path: string): number[];
|
|
4
|
+
export declare function hexBuffer(str: string): Buffer;
|
|
5
|
+
export declare function maybeHexBuffer(str: string | null | undefined): Buffer | null | undefined;
|
|
6
|
+
export declare const decodeTxInfo: (rawTx: Buffer) => {
|
|
4
7
|
decodedTx: any;
|
|
5
8
|
txType: number | null;
|
|
6
9
|
chainId: BigNumber;
|
|
7
10
|
chainIdTruncated: number;
|
|
8
11
|
vrsOffset: number;
|
|
9
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* @ignore for the README
|
|
15
|
+
*
|
|
16
|
+
* Helper to convert an integer as a hexadecimal string with the right amount of digits
|
|
17
|
+
* to respect the number of bytes given as parameter
|
|
18
|
+
*
|
|
19
|
+
* @param int Integer
|
|
20
|
+
* @param bytes Number of bytes it should be represented as (1 byte = 2 caraters)
|
|
21
|
+
* @returns The given integer as an hexa string padded with the right number of 0
|
|
22
|
+
*/
|
|
23
|
+
export declare const intAsHexBytes: (int: number, bytes: number) => string;
|
|
10
24
|
//# sourceMappingURL=utils.d.ts.map
|
package/lib-es/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,wBAAgB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAchD;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC7B,MAAM,GAAG,IAAI,GAAG,SAAS,CAG3B;AAED,eAAO,MAAM,YAAY,UAAW,MAAM;;;;;;CAyEzC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,QAAS,MAAM,SAAS,MAAM,KAAG,MAChB,CAAC"}
|