@ledgerhq/hw-transport-http 6.26.0 → 6.26.1-monorepo.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 -0
- package/CHANGELOG.md +11 -0
- package/jest.config.ts +6 -0
- package/package.json +11 -8
- package/tsconfig.json +2 -1
- package/LICENSE +0 -202
- package/lib/HttpTransport.d.ts +0 -20
- package/lib/HttpTransport.d.ts.map +0 -1
- package/lib/HttpTransport.js +0 -158
- package/lib/HttpTransport.js.map +0 -1
- package/lib/WebSocketTransport.d.ts +0 -27
- package/lib/WebSocketTransport.d.ts.map +0 -1
- package/lib/WebSocketTransport.js +0 -203
- package/lib/WebSocketTransport.js.map +0 -1
- package/lib/withStaticURLs.d.ts +0 -7
- package/lib/withStaticURLs.d.ts.map +0 -1
- package/lib/withStaticURLs.js +0 -157
- package/lib/withStaticURLs.js.map +0 -1
- package/lib-es/HttpTransport.d.ts +0 -20
- package/lib-es/HttpTransport.d.ts.map +0 -1
- package/lib-es/HttpTransport.js +0 -153
- package/lib-es/HttpTransport.js.map +0 -1
- package/lib-es/WebSocketTransport.d.ts +0 -27
- package/lib-es/WebSocketTransport.d.ts.map +0 -1
- package/lib-es/WebSocketTransport.js +0 -198
- package/lib-es/WebSocketTransport.js.map +0 -1
- package/lib-es/withStaticURLs.d.ts +0 -7
- package/lib-es/withStaticURLs.d.ts.map +0 -1
- package/lib-es/withStaticURLs.js +0 -152
- package/lib-es/withStaticURLs.js.map +0 -1
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
-
};
|
|
56
|
-
exports.__esModule = true;
|
|
57
|
-
var hw_transport_1 = __importDefault(require("@ledgerhq/hw-transport"));
|
|
58
|
-
var errors_1 = require("@ledgerhq/errors");
|
|
59
|
-
var logs_1 = require("@ledgerhq/logs");
|
|
60
|
-
var WebSocket = global.WebSocket || require("ws");
|
|
61
|
-
/**
|
|
62
|
-
* WebSocket transport implementation
|
|
63
|
-
*/
|
|
64
|
-
var WebSocketTransport = /** @class */ (function (_super) {
|
|
65
|
-
__extends(WebSocketTransport, _super);
|
|
66
|
-
function WebSocketTransport(hook) {
|
|
67
|
-
var _this = _super.call(this) || this;
|
|
68
|
-
_this.hook = hook;
|
|
69
|
-
hook.onDisconnect = function () {
|
|
70
|
-
_this.emit("disconnect");
|
|
71
|
-
_this.hook.rejectExchange(new errors_1.TransportError("WebSocket disconnected", "WSDisconnect"));
|
|
72
|
-
};
|
|
73
|
-
return _this;
|
|
74
|
-
}
|
|
75
|
-
WebSocketTransport.open = function (url) {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
-
var exchangeMethods;
|
|
78
|
-
return __generator(this, function (_c) {
|
|
79
|
-
switch (_c.label) {
|
|
80
|
-
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
81
|
-
try {
|
|
82
|
-
var socket_1 = new WebSocket(url);
|
|
83
|
-
var exchangeMethods_1 = {
|
|
84
|
-
resolveExchange: function (_b) { },
|
|
85
|
-
rejectExchange: function (_e) { },
|
|
86
|
-
onDisconnect: function () { },
|
|
87
|
-
close: function () { return socket_1.close(); },
|
|
88
|
-
send: function (msg) { return socket_1.send(msg); }
|
|
89
|
-
};
|
|
90
|
-
socket_1.onopen = function () {
|
|
91
|
-
socket_1.send("open");
|
|
92
|
-
};
|
|
93
|
-
socket_1.onerror = function (e) {
|
|
94
|
-
exchangeMethods_1.onDisconnect();
|
|
95
|
-
reject(e);
|
|
96
|
-
};
|
|
97
|
-
socket_1.onclose = function () {
|
|
98
|
-
exchangeMethods_1.onDisconnect();
|
|
99
|
-
reject(new errors_1.TransportError("OpenFailed", "OpenFailed"));
|
|
100
|
-
};
|
|
101
|
-
socket_1.onmessage = function (e) {
|
|
102
|
-
if (typeof e.data !== "string")
|
|
103
|
-
return;
|
|
104
|
-
var data = JSON.parse(e.data);
|
|
105
|
-
switch (data.type) {
|
|
106
|
-
case "opened":
|
|
107
|
-
return resolve(exchangeMethods_1);
|
|
108
|
-
case "error":
|
|
109
|
-
reject(new Error(data.error));
|
|
110
|
-
return exchangeMethods_1.rejectExchange(new errors_1.TransportError(data.error, "WSError"));
|
|
111
|
-
case "response":
|
|
112
|
-
return exchangeMethods_1.resolveExchange(Buffer.from(data.data, "hex"));
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
catch (e) {
|
|
117
|
-
reject(e);
|
|
118
|
-
}
|
|
119
|
-
})];
|
|
120
|
-
case 1:
|
|
121
|
-
exchangeMethods = _c.sent();
|
|
122
|
-
return [2 /*return*/, new WebSocketTransport(exchangeMethods)];
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
WebSocketTransport.prototype.exchange = function (apdu) {
|
|
128
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
-
var hex, res;
|
|
130
|
-
var _this = this;
|
|
131
|
-
return __generator(this, function (_c) {
|
|
132
|
-
switch (_c.label) {
|
|
133
|
-
case 0:
|
|
134
|
-
hex = apdu.toString("hex");
|
|
135
|
-
(0, logs_1.log)("apdu", "=> " + hex);
|
|
136
|
-
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
137
|
-
_this.hook.rejectExchange = function (e) { return reject(e); };
|
|
138
|
-
_this.hook.resolveExchange = function (b) { return resolve(b); };
|
|
139
|
-
_this.hook.send(hex);
|
|
140
|
-
})];
|
|
141
|
-
case 1:
|
|
142
|
-
res = _c.sent();
|
|
143
|
-
(0, logs_1.log)("apdu", "<= " + res.toString("hex"));
|
|
144
|
-
return [2 /*return*/, res];
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
WebSocketTransport.prototype.setScrambleKey = function () { };
|
|
150
|
-
WebSocketTransport.prototype.close = function () {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
-
return __generator(this, function (_c) {
|
|
153
|
-
this.hook.close();
|
|
154
|
-
return [2 /*return*/, new Promise(function (success) {
|
|
155
|
-
setTimeout(function () {
|
|
156
|
-
success(undefined);
|
|
157
|
-
}, 200);
|
|
158
|
-
})];
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
};
|
|
162
|
-
var _a;
|
|
163
|
-
_a = WebSocketTransport;
|
|
164
|
-
WebSocketTransport.isSupported = function () {
|
|
165
|
-
return Promise.resolve(typeof WebSocket === "function");
|
|
166
|
-
};
|
|
167
|
-
// this transport is not discoverable
|
|
168
|
-
WebSocketTransport.list = function () { return Promise.resolve([]); };
|
|
169
|
-
WebSocketTransport.listen = function (_observer) { return ({
|
|
170
|
-
unsubscribe: function () { }
|
|
171
|
-
}); };
|
|
172
|
-
WebSocketTransport.check = function (url, timeout) {
|
|
173
|
-
if (timeout === void 0) { timeout = 5000; }
|
|
174
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
175
|
-
return __generator(_a, function (_c) {
|
|
176
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
177
|
-
var socket = new WebSocket(url);
|
|
178
|
-
var success = false;
|
|
179
|
-
setTimeout(function () {
|
|
180
|
-
socket.close();
|
|
181
|
-
}, timeout);
|
|
182
|
-
socket.onopen = function () {
|
|
183
|
-
success = true;
|
|
184
|
-
socket.close();
|
|
185
|
-
};
|
|
186
|
-
socket.onclose = function () {
|
|
187
|
-
if (success)
|
|
188
|
-
resolve(undefined);
|
|
189
|
-
else {
|
|
190
|
-
reject(new errors_1.TransportError("failed to access WebSocketTransport(" + url + ")", "WebSocketTransportNotAccessible"));
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
socket.onerror = function () {
|
|
194
|
-
reject(new errors_1.TransportError("failed to access WebSocketTransport(" + url + "): error", "WebSocketTransportNotAccessible"));
|
|
195
|
-
};
|
|
196
|
-
})];
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
};
|
|
200
|
-
return WebSocketTransport;
|
|
201
|
-
}(hw_transport_1["default"]));
|
|
202
|
-
exports["default"] = WebSocketTransport;
|
|
203
|
-
//# sourceMappingURL=WebSocketTransport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebSocketTransport.js","sourceRoot":"","sources":["../src/WebSocketTransport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;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AAC;wBAClC,IAAI,OAAO,GAAG,KAAK,CAAC;wBACpB,UAAU,CAAC;4BACT,MAAM,CAAC,KAAK,EAAE,CAAC;wBACjB,CAAC,EAAE,OAAO,CAAC,CAAC;wBAEZ,MAAM,CAAC,MAAM,GAAG;4BACd,OAAO,GAAG,IAAI,CAAC;4BACf,MAAM,CAAC,KAAK,EAAE,CAAC;wBACjB,CAAC,CAAC;wBAEF,MAAM,CAAC,OAAO,GAAG;4BACf,IAAI,OAAO;gCAAE,OAAO,CAAC,SAAS,CAAC,CAAC;iCAC3B;gCACH,MAAM,CACJ,IAAI,uBAAc,CAChB,sCAAsC,GAAG,GAAG,GAAG,GAAG,EAClD,iCAAiC,CAClC,CACF,CAAC;6BACH;wBACH,CAAC,CAAC;wBAEF,MAAM,CAAC,OAAO,GAAG;4BACf,MAAM,CACJ,IAAI,uBAAc,CAChB,sCAAsC,GAAG,GAAG,GAAG,UAAU,EACzD,iCAAiC,CAClC,CACF,CAAC;wBACJ,CAAC,CAAC;oBACJ,CAAC,CAAC,EAAA;;;KAAC,CAAA;IA6FP,yBAAC;CAAA,AAtID,CAAgD,yBAAS,GAsIxD;qBAtIoB,kBAAkB"}
|
package/lib/withStaticURLs.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import Transport from "@ledgerhq/hw-transport";
|
|
2
|
-
declare type InS = string | string[];
|
|
3
|
-
declare type InP = Promise<InS> | InS;
|
|
4
|
-
declare type In = InP | (() => InP);
|
|
5
|
-
declare const _default: (urls: In) => new () => Transport;
|
|
6
|
-
export default _default;
|
|
7
|
-
//# sourceMappingURL=withStaticURLs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withStaticURLs.d.ts","sourceRoot":"","sources":["../src/withStaticURLs.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAU/C,aAAK,GAAG,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAC7B,aAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AAC9B,aAAK,EAAE,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;+BAON,EAAE,KAAG,UAAU,SAAS;AAA9C,wBAuEE"}
|
package/lib/withStaticURLs.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
-
};
|
|
56
|
-
exports.__esModule = true;
|
|
57
|
-
var HttpTransport_1 = __importDefault(require("./HttpTransport"));
|
|
58
|
-
var WebSocketTransport_1 = __importDefault(require("./WebSocketTransport"));
|
|
59
|
-
var hw_transport_1 = __importDefault(require("@ledgerhq/hw-transport"));
|
|
60
|
-
var getTransport = function (url) {
|
|
61
|
-
return !url.startsWith("ws") ? HttpTransport_1["default"] : WebSocketTransport_1["default"];
|
|
62
|
-
};
|
|
63
|
-
var inferURLs = function (urls) { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
-
var r;
|
|
65
|
-
return __generator(this, function (_a) {
|
|
66
|
-
switch (_a.label) {
|
|
67
|
-
case 0: return [4 /*yield*/, (typeof urls === "function" ? urls() : urls)];
|
|
68
|
-
case 1:
|
|
69
|
-
r = _a.sent();
|
|
70
|
-
return [2 /*return*/, typeof r === "string" ? [r] : r];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}); };
|
|
74
|
-
exports["default"] = (function (urls) {
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
76
|
-
// @ts-ignore
|
|
77
|
-
var StaticTransport = /** @class */ (function (_super) {
|
|
78
|
-
__extends(StaticTransport, _super);
|
|
79
|
-
function StaticTransport() {
|
|
80
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
81
|
-
}
|
|
82
|
-
StaticTransport.isSupported = HttpTransport_1["default"].isSupported;
|
|
83
|
-
StaticTransport.list = function () {
|
|
84
|
-
return inferURLs(urls)
|
|
85
|
-
.then(function (urls) {
|
|
86
|
-
return Promise.all(urls.map(function (url) {
|
|
87
|
-
return getTransport(url)
|
|
88
|
-
.check(url)
|
|
89
|
-
.then(function () { return [url]; })["catch"](function () { return []; });
|
|
90
|
-
}));
|
|
91
|
-
})
|
|
92
|
-
.then(function (arrs) { return arrs.reduce(function (acc, a) { return acc.concat(a); }, []); });
|
|
93
|
-
};
|
|
94
|
-
StaticTransport.listen = function (observer) {
|
|
95
|
-
var unsubscribed = false;
|
|
96
|
-
var seen = {};
|
|
97
|
-
function checkLoop() {
|
|
98
|
-
var _this = this;
|
|
99
|
-
if (unsubscribed)
|
|
100
|
-
return;
|
|
101
|
-
inferURLs(urls)
|
|
102
|
-
.then(function (urls) {
|
|
103
|
-
return Promise.all(urls.map(function (url) { return __awaiter(_this, void 0, void 0, function () {
|
|
104
|
-
var e_1;
|
|
105
|
-
return __generator(this, function (_a) {
|
|
106
|
-
switch (_a.label) {
|
|
107
|
-
case 0:
|
|
108
|
-
if (unsubscribed)
|
|
109
|
-
return [2 /*return*/];
|
|
110
|
-
_a.label = 1;
|
|
111
|
-
case 1:
|
|
112
|
-
_a.trys.push([1, 3, , 4]);
|
|
113
|
-
return [4 /*yield*/, getTransport(url).check(url)];
|
|
114
|
-
case 2:
|
|
115
|
-
_a.sent();
|
|
116
|
-
if (unsubscribed)
|
|
117
|
-
return [2 /*return*/];
|
|
118
|
-
if (!seen[url]) {
|
|
119
|
-
seen[url] = 1;
|
|
120
|
-
observer.next({
|
|
121
|
-
type: "add",
|
|
122
|
-
descriptor: url
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
return [3 /*break*/, 4];
|
|
126
|
-
case 3:
|
|
127
|
-
e_1 = _a.sent();
|
|
128
|
-
// nothing
|
|
129
|
-
if (seen[url]) {
|
|
130
|
-
delete seen[url];
|
|
131
|
-
observer.next({
|
|
132
|
-
type: "remove",
|
|
133
|
-
descriptor: url
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
return [3 /*break*/, 4];
|
|
137
|
-
case 4: return [2 /*return*/];
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}); }));
|
|
141
|
-
})
|
|
142
|
-
.then(function () { return new Promise(function (success) { return setTimeout(success, 5000); }); })
|
|
143
|
-
.then(checkLoop);
|
|
144
|
-
}
|
|
145
|
-
checkLoop();
|
|
146
|
-
return {
|
|
147
|
-
unsubscribe: function () {
|
|
148
|
-
unsubscribed = true;
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
StaticTransport.open = function (url) { return getTransport(url).open(url); };
|
|
153
|
-
return StaticTransport;
|
|
154
|
-
}(hw_transport_1["default"]));
|
|
155
|
-
return StaticTransport;
|
|
156
|
-
});
|
|
157
|
-
//# sourceMappingURL=withStaticURLs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withStaticURLs.js","sourceRoot":"","sources":["../src/withStaticURLs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAA4C;AAC5C,4EAAsD;AACtD,wEAA+C;AAO/C,IAAM,YAAY,GAAG,UAAC,GAAG;IACvB,OAAA,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,0BAAa,CAAC,CAAC,CAAC,+BAAkB;AAA1D,CAA0D,CAAC;AAM7D,IAAM,SAAS,GAAG,UAAO,IAAQ;;;;oBACrB,qBAAM,CAAC,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAA;;gBAAtD,CAAC,GAAG,SAAkD;gBAC5D,sBAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC;;;KACxC,CAAC;AAEF,sBAAe,UAAC,IAAQ;IACtB,6DAA6D;IAC7D,aAAa;IACb;QAA8B,mCAAS;QAAvC;;QAiEA,CAAC;QAhEQ,2BAAW,GAAG,0BAAa,CAAC,WAAW,CAAC;QACxC,oBAAI,GAAG;YACZ,OAAA,SAAS,CAAC,IAAI,CAAC;iBACZ,IAAI,CAAC,UAAC,IAAI;gBACT,OAAA,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,GAAG,CAAC,UAAC,GAAG;oBACX,O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AAQ,CAAC,IAAI,CAAC;4CACZ,IAAI,EAAE,QAAQ;4CACd,UAAU,EAAE,GAAG;yCAChB,CAAC,CAAC;qCACJ;;;;;yBAEJ,CAAC,CACH;gBA1BD,CA0BC,CACF;qBACA,IAAI,CAAC,cAAM,OAAA,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,EAAzB,CAAyB,CAAC,EAAnD,CAAmD,CAAC;qBAC/D,IAAI,CAAC,SAAS,CAAC,CAAC;YACrB,CAAC;YAED,SAAS,EAAE,CAAC;YACZ,OAAO;gBACL,WAAW,EAAE;oBACX,YAAY,GAAG,IAAI,CAAC;gBACtB,CAAC;aACF,CAAC;QACJ,CAAC,CAAC;QACK,oBAAI,GAAG,UAAC,GAAG,IAAK,OAAA,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAA3B,CAA2B,CAAC;QACrD,sBAAC;KAAA,AAjED,CAA8B,yBAAS,GAiEtC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC,EAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import Transport from "@ledgerhq/hw-transport";
|
|
3
|
-
/**
|
|
4
|
-
* HTTP transport implementation
|
|
5
|
-
*/
|
|
6
|
-
export default class HttpTransport extends Transport {
|
|
7
|
-
static isSupported: () => Promise<boolean>;
|
|
8
|
-
static list: () => any;
|
|
9
|
-
static listen: (_observer: any) => {
|
|
10
|
-
unsubscribe: () => void;
|
|
11
|
-
};
|
|
12
|
-
static check: (url: string, timeout?: number) => Promise<void>;
|
|
13
|
-
static open(url: string, timeout?: number): Promise<Transport>;
|
|
14
|
-
url: string;
|
|
15
|
-
constructor(url: string);
|
|
16
|
-
exchange(apdu: Buffer): Promise<Buffer>;
|
|
17
|
-
setScrambleKey(): void;
|
|
18
|
-
close(): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=HttpTransport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpTransport.d.ts","sourceRoot":"","sources":["../src/HttpTransport.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAI/C;;GAEG;AAEH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAS;IAClD,MAAM,CAAC,WAAW,QAAO,QAAQ,OAAO,CAAC,CACM;IAE/C,MAAM,CAAC,IAAI,QAAO,GAAG,CAAwB;IAC7C,MAAM,CAAC,MAAM,cAAe,GAAG;;MAE5B;IACH,MAAM,CAAC,KAAK,QAAe,MAAM,qCAe/B;WAEW,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAKpE,GAAG,EAAE,MAAM,CAAC;gBAEA,GAAG,EAAE,MAAM;IAKjB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA4B7C,cAAc;IAEd,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAGvB"}
|
package/lib-es/HttpTransport.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
-
function step(op) {
|
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (_) try {
|
|
32
|
-
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;
|
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
-
switch (op[0]) {
|
|
35
|
-
case 0: case 1: t = op; break;
|
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
46
|
-
}
|
|
47
|
-
op = body.call(thisArg, _);
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
import Transport from "@ledgerhq/hw-transport";
|
|
53
|
-
import { TransportError } from "@ledgerhq/errors";
|
|
54
|
-
import axios from "axios";
|
|
55
|
-
import { log } from "@ledgerhq/logs";
|
|
56
|
-
/**
|
|
57
|
-
* HTTP transport implementation
|
|
58
|
-
*/
|
|
59
|
-
var HttpTransport = /** @class */ (function (_super) {
|
|
60
|
-
__extends(HttpTransport, _super);
|
|
61
|
-
function HttpTransport(url) {
|
|
62
|
-
var _this = _super.call(this) || this;
|
|
63
|
-
_this.url = url;
|
|
64
|
-
return _this;
|
|
65
|
-
}
|
|
66
|
-
HttpTransport.open = function (url, timeout) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
-
return __generator(this, function (_b) {
|
|
69
|
-
switch (_b.label) {
|
|
70
|
-
case 0: return [4 /*yield*/, HttpTransport.check(url, timeout)];
|
|
71
|
-
case 1:
|
|
72
|
-
_b.sent();
|
|
73
|
-
return [2 /*return*/, new HttpTransport(url)];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
HttpTransport.prototype.exchange = function (apdu) {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
-
var apduHex, response, body;
|
|
81
|
-
return __generator(this, function (_b) {
|
|
82
|
-
switch (_b.label) {
|
|
83
|
-
case 0:
|
|
84
|
-
apduHex = apdu.toString("hex");
|
|
85
|
-
log("apdu", "=> " + apduHex);
|
|
86
|
-
return [4 /*yield*/, axios({
|
|
87
|
-
method: "POST",
|
|
88
|
-
url: this.url,
|
|
89
|
-
headers: {
|
|
90
|
-
Accept: "application/json",
|
|
91
|
-
"Content-Type": "application/json"
|
|
92
|
-
},
|
|
93
|
-
data: JSON.stringify({
|
|
94
|
-
apduHex: apduHex
|
|
95
|
-
})
|
|
96
|
-
})];
|
|
97
|
-
case 1:
|
|
98
|
-
response = _b.sent();
|
|
99
|
-
if (response.status !== 200) {
|
|
100
|
-
throw new TransportError("failed to communicate to server. code=" + response.status, "HttpTransportStatus" + response.status);
|
|
101
|
-
}
|
|
102
|
-
return [4 /*yield*/, response.data];
|
|
103
|
-
case 2:
|
|
104
|
-
body = _b.sent();
|
|
105
|
-
if (body.error)
|
|
106
|
-
throw body.error;
|
|
107
|
-
log("apdu", "<= " + body.data);
|
|
108
|
-
return [2 /*return*/, Buffer.from(body.data, "hex")];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
HttpTransport.prototype.setScrambleKey = function () { };
|
|
114
|
-
HttpTransport.prototype.close = function () {
|
|
115
|
-
return Promise.resolve();
|
|
116
|
-
};
|
|
117
|
-
var _a;
|
|
118
|
-
_a = HttpTransport;
|
|
119
|
-
HttpTransport.isSupported = function () {
|
|
120
|
-
return Promise.resolve(typeof fetch === "function");
|
|
121
|
-
};
|
|
122
|
-
// this transport is not discoverable
|
|
123
|
-
HttpTransport.list = function () { return Promise.resolve([]); };
|
|
124
|
-
HttpTransport.listen = function (_observer) { return ({
|
|
125
|
-
unsubscribe: function () { }
|
|
126
|
-
}); };
|
|
127
|
-
HttpTransport.check = function (url, timeout) {
|
|
128
|
-
if (timeout === void 0) { timeout = 5000; }
|
|
129
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
130
|
-
var response;
|
|
131
|
-
return __generator(_a, function (_b) {
|
|
132
|
-
switch (_b.label) {
|
|
133
|
-
case 0: return [4 /*yield*/, axios({
|
|
134
|
-
url: url,
|
|
135
|
-
timeout: timeout
|
|
136
|
-
})];
|
|
137
|
-
case 1:
|
|
138
|
-
response = _b.sent();
|
|
139
|
-
if (response.status !== 200) {
|
|
140
|
-
throw new TransportError("failed to access HttpTransport(" +
|
|
141
|
-
url +
|
|
142
|
-
"): status " +
|
|
143
|
-
response.status, "HttpTransportNotAccessible");
|
|
144
|
-
}
|
|
145
|
-
return [2 /*return*/];
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
return HttpTransport;
|
|
151
|
-
}(Transport));
|
|
152
|
-
export default HttpTransport;
|
|
153
|
-
//# sourceMappingURL=HttpTransport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpTransport.js","sourceRoot":"","sources":["../src/HttpTransport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC;;GAEG;AAEH;IAA2C,iCAAS;IAgClD,uBAAY,GAAW;QAAvB,YACE,iBAAO,SAER;QADC,KAAI,CAAC,GAAG,GAAG,GAAG,CAAC;;IACjB,CAAC;IAVY,kBAAI,GAAjB,UAAkB,GAAW,EAAE,OAAgB;;;;4BAC7C,qBAAM,aAAa,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,EAAA;;wBAAvC,SAAuC,CAAC;wBACxC,sBAAO,IAAI,aAAa,CAAC,GAAG,CAAC,EAAC;;;;KAC/B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AnB,CAAoB,CAAA;IACtC,oBAAM,GAAG,UAAC,SAAc,IAAK,OAAA,CAAC;QACnC,WAAW,EAAE,cAAO,CAAC;KACtB,CAAC,EAFkC,CAEjC,CAAA;IACI,mBAAK,GAAG,UAAO,GAAW,EAAE,OAAc;QAAd,wBAAA,EAAA,cAAc;;;;;4BAC9B,qBAAM,KAAK,CAAC;4BAC3B,GAAG,KAAA;4BACH,OAAO,SAAA;yBACR,CAAC,EAAA;;wBAHI,QAAQ,GAAG,SAGf;wBAEF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;4BAC3B,MAAM,IAAI,cAAc,CACtB,iCAAiC;gCAC/B,GAAG;gCACH,YAAY;gCACZ,QAAQ,CAAC,MAAM,EACjB,4BAA4B,CAC7B,CAAC;yBACH;;;;;KACD,CAAA;IA+CJ,oBAAC;CAAA,AAtED,CAA2C,SAAS,GAsEnD;eAtEoB,aAAa"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import Transport from "@ledgerhq/hw-transport";
|
|
3
|
-
declare global {
|
|
4
|
-
namespace NodeJS {
|
|
5
|
-
interface Global {
|
|
6
|
-
WebSocket?: WebSocket;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* WebSocket transport implementation
|
|
12
|
-
*/
|
|
13
|
-
export default class WebSocketTransport extends Transport {
|
|
14
|
-
static isSupported: () => Promise<boolean>;
|
|
15
|
-
static list: () => any;
|
|
16
|
-
static listen: (_observer: any) => {
|
|
17
|
-
unsubscribe: () => void;
|
|
18
|
-
};
|
|
19
|
-
static check: (url: string, timeout?: number) => Promise<unknown>;
|
|
20
|
-
static open(url: string): Promise<WebSocketTransport>;
|
|
21
|
-
hook: any;
|
|
22
|
-
constructor(hook: any);
|
|
23
|
-
exchange(apdu: Buffer): Promise<Buffer>;
|
|
24
|
-
setScrambleKey(): void;
|
|
25
|
-
close(): Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=WebSocketTransport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebSocketTransport.d.ts","sourceRoot":"","sources":["../src/WebSocketTransport.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAI/C,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,MAAM,CAAC;QACf,UAAU,MAAM;YACd,SAAS,CAAC,EAAE,SAAS,CAAC;SACvB;KACF;CACF;AAGD;;GAEG;AAEH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,SAAS;IACvD,MAAM,CAAC,WAAW,QAAO,QAAQ,OAAO,CAAC,CACU;IAEnD,MAAM,CAAC,IAAI,QAAO,GAAG,CAAwB;IAC7C,MAAM,CAAC,MAAM,cAAe,GAAG;;MAE5B;IACH,MAAM,CAAC,KAAK,QAAe,MAAM,wCAiC5B;WAEQ,IAAI,CAAC,GAAG,EAAE,MAAM;IAqD7B,IAAI,EAAE,GAAG,CAAC;gBAEE,IAAI,EAAE,GAAG;IAYf,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAc7C,cAAc;IAER,KAAK;CAQZ"}
|