@pezkuwi/hw-ledger 14.0.7 → 14.0.11
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/build/LICENSE +201 -0
- package/build/Ledger.d.ts +43 -0
- package/build/Ledger.js +112 -0
- package/build/LedgerGeneric.d.ts +63 -0
- package/build/LedgerGeneric.js +211 -0
- package/build/README.md +2 -0
- package/build/bundle-pezkuwi-hw-ledger.js +9473 -0
- package/build/bundle.d.ts +2 -0
- package/build/bundle.js +2 -0
- package/build/cjs/Ledger.d.ts +43 -0
- package/build/cjs/Ledger.js +117 -0
- package/build/cjs/LedgerGeneric.d.ts +63 -0
- package/build/cjs/LedgerGeneric.js +216 -0
- package/build/cjs/bundle.d.ts +2 -0
- package/build/cjs/bundle.js +7 -0
- package/build/cjs/constants.d.ts +4 -0
- package/build/cjs/constants.js +7 -0
- package/build/cjs/defaults.d.ts +14 -0
- package/build/cjs/defaults.js +61 -0
- package/build/cjs/index.d.ts +2 -0
- package/build/cjs/index.js +5 -0
- package/build/cjs/package.json +3 -0
- package/build/cjs/packageDetect.d.ts +1 -0
- package/build/cjs/packageDetect.js +7 -0
- package/build/cjs/packageInfo.d.ts +6 -0
- package/build/cjs/packageInfo.js +4 -0
- package/build/cjs/types.d.ts +34 -0
- package/build/cjs/types.js +2 -0
- package/build/constants.d.ts +4 -0
- package/build/constants.js +4 -0
- package/build/defaults.d.ts +14 -0
- package/build/defaults.js +58 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/package.json +178 -0
- package/build/packageDetect.d.ts +1 -0
- package/build/packageDetect.js +5 -0
- package/build/packageInfo.d.ts +6 -0
- package/build/packageInfo.js +1 -0
- package/build/types.d.ts +34 -0
- package/build/types.js +1 -0
- package/build-deno/Ledger.ts +144 -0
- package/build-deno/LedgerGeneric.ts +271 -0
- package/build-deno/README.md +2 -0
- package/build-deno/bundle.ts +3 -0
- package/build-deno/constants.ts +8 -0
- package/build-deno/defaults.ts +61 -0
- package/build-deno/index.ts +4 -0
- package/build-deno/mod.ts +2 -0
- package/build-deno/packageDetect.ts +9 -0
- package/build-deno/packageInfo.ts +3 -0
- package/build-deno/types.ts +42 -0
- package/build-tsc/Ledger.d.ts +43 -0
- package/build-tsc/LedgerGeneric.d.ts +63 -0
- package/build-tsc/bundle.d.ts +2 -0
- package/build-tsc/constants.d.ts +4 -0
- package/build-tsc/defaults.d.ts +14 -0
- package/build-tsc/index.d.ts +2 -0
- package/build-tsc/packageDetect.d.ts +1 -0
- package/build-tsc/packageInfo.d.ts +6 -0
- package/build-tsc/types.d.ts +34 -0
- package/build-tsc-cjs/Ledger.js +117 -0
- package/build-tsc-cjs/LedgerGeneric.js +216 -0
- package/build-tsc-cjs/bundle.js +7 -0
- package/build-tsc-cjs/constants.js +7 -0
- package/build-tsc-cjs/defaults.js +61 -0
- package/build-tsc-cjs/index.js +5 -0
- package/build-tsc-cjs/packageDetect.js +7 -0
- package/build-tsc-cjs/packageInfo.js +4 -0
- package/build-tsc-cjs/types.js +2 -0
- package/build-tsc-esm/Ledger.js +112 -0
- package/build-tsc-esm/LedgerGeneric.js +211 -0
- package/build-tsc-esm/bundle.js +2 -0
- package/build-tsc-esm/constants.js +4 -0
- package/build-tsc-esm/defaults.js +58 -0
- package/build-tsc-esm/index.js +2 -0
- package/build-tsc-esm/packageDetect.js +5 -0
- package/build-tsc-esm/packageInfo.js +1 -0
- package/build-tsc-esm/types.js +1 -0
- package/bundle-pezkuwi-hw-ledger.js +1183 -1418
- package/cjs/packageInfo.js +1 -1
- package/package.json +4 -4
- package/packageInfo.js +1 -1
- package/src/Ledger.ts +144 -0
- package/src/LedgerGeneric.ts +275 -0
- package/src/bundle.ts +8 -0
- package/src/constants.ts +10 -0
- package/src/defaults.spec.ts +20 -0
- package/src/defaults.ts +69 -0
- package/src/index.ts +6 -0
- package/src/mod.ts +4 -0
- package/src/packageDetect.ts +13 -0
- package/src/packageInfo.ts +6 -0
- package/src/types.ts +42 -0
- package/tsconfig.build.json +16 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.spec.json +16 -0
- package/tsconfig.spec.tsbuildinfo +1 -0
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
|
|
48
48
|
var common$1 = {};
|
|
49
49
|
|
|
50
|
-
(function (exports) {
|
|
51
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
-
exports.ERROR_DESCRIPTION = exports.ECDSA_PUBKEY_LEN = exports.ED25519_PUBKEY_LEN = exports.CHUNK_SIZE = void 0;
|
|
53
|
-
exports.errorCodeToString = errorCodeToString;
|
|
54
|
-
exports.processErrorResponse = processErrorResponse;
|
|
55
|
-
exports.getVersion = getVersion;
|
|
56
|
-
exports.serializePath = serializePath;
|
|
57
|
-
exports.CHUNK_SIZE = 250;
|
|
58
|
-
exports.ED25519_PUBKEY_LEN = 32;
|
|
59
|
-
exports.ECDSA_PUBKEY_LEN = 33;
|
|
60
|
-
exports.ERROR_DESCRIPTION = {
|
|
50
|
+
(function (exports$1) {
|
|
51
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
52
|
+
exports$1.ERROR_DESCRIPTION = exports$1.ECDSA_PUBKEY_LEN = exports$1.ED25519_PUBKEY_LEN = exports$1.CHUNK_SIZE = void 0;
|
|
53
|
+
exports$1.errorCodeToString = errorCodeToString;
|
|
54
|
+
exports$1.processErrorResponse = processErrorResponse;
|
|
55
|
+
exports$1.getVersion = getVersion;
|
|
56
|
+
exports$1.serializePath = serializePath;
|
|
57
|
+
exports$1.CHUNK_SIZE = 250;
|
|
58
|
+
exports$1.ED25519_PUBKEY_LEN = 32;
|
|
59
|
+
exports$1.ECDSA_PUBKEY_LEN = 33;
|
|
60
|
+
exports$1.ERROR_DESCRIPTION = {
|
|
61
61
|
1: 'U2F: Unknown',
|
|
62
62
|
2: 'U2F: Bad request',
|
|
63
63
|
3: 'U2F: Configuration unsupported',
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
0x6f01: 'Sign/verify error',
|
|
83
83
|
};
|
|
84
84
|
function errorCodeToString(statusCode) {
|
|
85
|
-
if (statusCode in exports.ERROR_DESCRIPTION)
|
|
86
|
-
return exports.ERROR_DESCRIPTION[statusCode];
|
|
85
|
+
if (statusCode in exports$1.ERROR_DESCRIPTION)
|
|
86
|
+
return exports$1.ERROR_DESCRIPTION[statusCode];
|
|
87
87
|
return `Unknown Status Code: ${statusCode}`;
|
|
88
88
|
}
|
|
89
89
|
function isDict(v) {
|
|
@@ -440,14 +440,14 @@
|
|
|
440
440
|
}
|
|
441
441
|
substrate_app.SubstrateApp = SubstrateApp;
|
|
442
442
|
|
|
443
|
-
(function (exports) {
|
|
444
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
445
|
-
exports.supportedApps = void 0;
|
|
446
|
-
exports.newSubstrateApp = newSubstrateApp;
|
|
447
|
-
exports.getAppParams = getAppParams;
|
|
443
|
+
(function (exports$1) {
|
|
444
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
445
|
+
exports$1.supportedApps = void 0;
|
|
446
|
+
exports$1.newSubstrateApp = newSubstrateApp;
|
|
447
|
+
exports$1.getAppParams = getAppParams;
|
|
448
448
|
const substrate_app_1 = substrate_app;
|
|
449
449
|
function newSubstrateApp(transport, chainName) {
|
|
450
|
-
const requestedApp = exports.supportedApps.find((app) => {
|
|
450
|
+
const requestedApp = exports$1.supportedApps.find((app) => {
|
|
451
451
|
return app.name.toLowerCase() === chainName.toLowerCase();
|
|
452
452
|
});
|
|
453
453
|
if (requestedApp != null) {
|
|
@@ -456,12 +456,12 @@
|
|
|
456
456
|
throw new Error(`Error: ${chainName} not supported`);
|
|
457
457
|
}
|
|
458
458
|
function getAppParams(chainName) {
|
|
459
|
-
const params = exports.supportedApps.find((app) => {
|
|
459
|
+
const params = exports$1.supportedApps.find((app) => {
|
|
460
460
|
return app.name.toLowerCase() === chainName.toLowerCase();
|
|
461
461
|
});
|
|
462
462
|
return params;
|
|
463
463
|
}
|
|
464
|
-
exports.supportedApps = [
|
|
464
|
+
exports$1.supportedApps = [
|
|
465
465
|
{
|
|
466
466
|
name: 'Polkadot',
|
|
467
467
|
cla: 0x90,
|
|
@@ -857,8 +857,15 @@
|
|
|
857
857
|
|
|
858
858
|
var generic_app = {};
|
|
859
859
|
|
|
860
|
-
/*! Axios v1.
|
|
860
|
+
/*! Axios v1.13.2 Copyright (c) 2025 Matt Zabriskie and contributors */
|
|
861
861
|
|
|
862
|
+
/**
|
|
863
|
+
* Create a bound version of a function with a specified `this` context
|
|
864
|
+
*
|
|
865
|
+
* @param {Function} fn - The function to bind
|
|
866
|
+
* @param {*} thisArg - The value to be passed as the `this` parameter
|
|
867
|
+
* @returns {Function} A new function that will call the original function with the specified `this` context
|
|
868
|
+
*/
|
|
862
869
|
function bind(fn, thisArg) {
|
|
863
870
|
return function wrap() {
|
|
864
871
|
return fn.apply(thisArg, arguments);
|
|
@@ -869,7 +876,7 @@
|
|
|
869
876
|
|
|
870
877
|
const {toString} = Object.prototype;
|
|
871
878
|
const {getPrototypeOf} = Object;
|
|
872
|
-
const {iterator
|
|
879
|
+
const {iterator, toStringTag} = Symbol;
|
|
873
880
|
|
|
874
881
|
const kindOf = (cache => thing => {
|
|
875
882
|
const str = toString.call(thing);
|
|
@@ -910,7 +917,7 @@
|
|
|
910
917
|
*/
|
|
911
918
|
function isBuffer(val) {
|
|
912
919
|
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
|
913
|
-
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
920
|
+
&& isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
914
921
|
}
|
|
915
922
|
|
|
916
923
|
/**
|
|
@@ -955,7 +962,7 @@
|
|
|
955
962
|
* @param {*} val The value to test
|
|
956
963
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
957
964
|
*/
|
|
958
|
-
const isFunction = typeOfTest('function');
|
|
965
|
+
const isFunction$1 = typeOfTest('function');
|
|
959
966
|
|
|
960
967
|
/**
|
|
961
968
|
* Determine if a value is a Number
|
|
@@ -996,7 +1003,28 @@
|
|
|
996
1003
|
}
|
|
997
1004
|
|
|
998
1005
|
const prototype = getPrototypeOf(val);
|
|
999
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator
|
|
1006
|
+
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|
1007
|
+
};
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* Determine if a value is an empty object (safely handles Buffers)
|
|
1011
|
+
*
|
|
1012
|
+
* @param {*} val The value to test
|
|
1013
|
+
*
|
|
1014
|
+
* @returns {boolean} True if value is an empty object, otherwise false
|
|
1015
|
+
*/
|
|
1016
|
+
const isEmptyObject = (val) => {
|
|
1017
|
+
// Early return for non-objects or Buffers to prevent RangeError
|
|
1018
|
+
if (!isObject$1(val) || isBuffer(val)) {
|
|
1019
|
+
return false;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
try {
|
|
1023
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
1024
|
+
} catch (e) {
|
|
1025
|
+
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
1026
|
+
return false;
|
|
1027
|
+
}
|
|
1000
1028
|
};
|
|
1001
1029
|
|
|
1002
1030
|
/**
|
|
@@ -1042,7 +1070,7 @@
|
|
|
1042
1070
|
*
|
|
1043
1071
|
* @returns {boolean} True if value is a Stream, otherwise false
|
|
1044
1072
|
*/
|
|
1045
|
-
const isStream = (val) => isObject$1(val) && isFunction(val.pipe);
|
|
1073
|
+
const isStream = (val) => isObject$1(val) && isFunction$1(val.pipe);
|
|
1046
1074
|
|
|
1047
1075
|
/**
|
|
1048
1076
|
* Determine if a value is a FormData
|
|
@@ -1055,10 +1083,10 @@
|
|
|
1055
1083
|
let kind;
|
|
1056
1084
|
return thing && (
|
|
1057
1085
|
(typeof FormData === 'function' && thing instanceof FormData) || (
|
|
1058
|
-
isFunction(thing.append) && (
|
|
1086
|
+
isFunction$1(thing.append) && (
|
|
1059
1087
|
(kind = kindOf(thing)) === 'formdata' ||
|
|
1060
1088
|
// detect form-data instance
|
|
1061
|
-
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
|
1089
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
1062
1090
|
)
|
|
1063
1091
|
)
|
|
1064
1092
|
)
|
|
@@ -1121,6 +1149,11 @@
|
|
|
1121
1149
|
fn.call(null, obj[i], i, obj);
|
|
1122
1150
|
}
|
|
1123
1151
|
} else {
|
|
1152
|
+
// Buffer check
|
|
1153
|
+
if (isBuffer(obj)) {
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1124
1157
|
// Iterate over object keys
|
|
1125
1158
|
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
1126
1159
|
const len = keys.length;
|
|
@@ -1134,6 +1167,10 @@
|
|
|
1134
1167
|
}
|
|
1135
1168
|
|
|
1136
1169
|
function findKey(obj, key) {
|
|
1170
|
+
if (isBuffer(obj)){
|
|
1171
|
+
return null;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1137
1174
|
key = key.toLowerCase();
|
|
1138
1175
|
const keys = Object.keys(obj);
|
|
1139
1176
|
let i = keys.length;
|
|
@@ -1174,7 +1211,7 @@
|
|
|
1174
1211
|
* @returns {Object} Result of all merge properties
|
|
1175
1212
|
*/
|
|
1176
1213
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
1177
|
-
const {caseless} = isContextDefined(this) && this || {};
|
|
1214
|
+
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
|
|
1178
1215
|
const result = {};
|
|
1179
1216
|
const assignValue = (val, key) => {
|
|
1180
1217
|
const targetKey = caseless && findKey(result, key) || key;
|
|
@@ -1184,7 +1221,7 @@
|
|
|
1184
1221
|
result[targetKey] = merge({}, val);
|
|
1185
1222
|
} else if (isArray(val)) {
|
|
1186
1223
|
result[targetKey] = val.slice();
|
|
1187
|
-
} else {
|
|
1224
|
+
} else if (!skipUndefined || !isUndefined(val)) {
|
|
1188
1225
|
result[targetKey] = val;
|
|
1189
1226
|
}
|
|
1190
1227
|
};
|
|
@@ -1207,7 +1244,7 @@
|
|
|
1207
1244
|
*/
|
|
1208
1245
|
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
1209
1246
|
forEach(b, (val, key) => {
|
|
1210
|
-
if (thisArg && isFunction(val)) {
|
|
1247
|
+
if (thisArg && isFunction$1(val)) {
|
|
1211
1248
|
a[key] = bind(val, thisArg);
|
|
1212
1249
|
} else {
|
|
1213
1250
|
a[key] = val;
|
|
@@ -1347,7 +1384,7 @@
|
|
|
1347
1384
|
* @returns {void}
|
|
1348
1385
|
*/
|
|
1349
1386
|
const forEachEntry = (obj, fn) => {
|
|
1350
|
-
const generator = obj && obj[iterator
|
|
1387
|
+
const generator = obj && obj[iterator];
|
|
1351
1388
|
|
|
1352
1389
|
const _iterator = generator.call(obj);
|
|
1353
1390
|
|
|
@@ -1423,13 +1460,13 @@
|
|
|
1423
1460
|
const freezeMethods = (obj) => {
|
|
1424
1461
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
1425
1462
|
// skip restricted props in strict mode
|
|
1426
|
-
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
1463
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
1427
1464
|
return false;
|
|
1428
1465
|
}
|
|
1429
1466
|
|
|
1430
1467
|
const value = obj[name];
|
|
1431
1468
|
|
|
1432
|
-
if (!isFunction(value)) return;
|
|
1469
|
+
if (!isFunction$1(value)) return;
|
|
1433
1470
|
|
|
1434
1471
|
descriptor.enumerable = false;
|
|
1435
1472
|
|
|
@@ -1466,6 +1503,8 @@
|
|
|
1466
1503
|
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
1467
1504
|
};
|
|
1468
1505
|
|
|
1506
|
+
|
|
1507
|
+
|
|
1469
1508
|
/**
|
|
1470
1509
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
1471
1510
|
*
|
|
@@ -1474,7 +1513,7 @@
|
|
|
1474
1513
|
* @returns {boolean}
|
|
1475
1514
|
*/
|
|
1476
1515
|
function isSpecCompliantForm(thing) {
|
|
1477
|
-
return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator
|
|
1516
|
+
return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
1478
1517
|
}
|
|
1479
1518
|
|
|
1480
1519
|
const toJSONObject = (obj) => {
|
|
@@ -1487,6 +1526,11 @@
|
|
|
1487
1526
|
return;
|
|
1488
1527
|
}
|
|
1489
1528
|
|
|
1529
|
+
//Buffer check
|
|
1530
|
+
if (isBuffer(source)) {
|
|
1531
|
+
return source;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1490
1534
|
if(!('toJSON' in source)) {
|
|
1491
1535
|
stack[i] = source;
|
|
1492
1536
|
const target = isArray(source) ? [] : {};
|
|
@@ -1511,7 +1555,7 @@
|
|
|
1511
1555
|
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
1512
1556
|
|
|
1513
1557
|
const isThenable = (thing) =>
|
|
1514
|
-
thing && (isObject$1(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
1558
|
+
thing && (isObject$1(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
|
|
1515
1559
|
|
|
1516
1560
|
// original code
|
|
1517
1561
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
@@ -1535,7 +1579,7 @@
|
|
|
1535
1579
|
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
1536
1580
|
})(
|
|
1537
1581
|
typeof setImmediate === 'function',
|
|
1538
|
-
isFunction(_global.postMessage)
|
|
1582
|
+
isFunction$1(_global.postMessage)
|
|
1539
1583
|
);
|
|
1540
1584
|
|
|
1541
1585
|
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
@@ -1544,7 +1588,7 @@
|
|
|
1544
1588
|
// *********************
|
|
1545
1589
|
|
|
1546
1590
|
|
|
1547
|
-
const isIterable = (thing) => thing != null && isFunction(thing[iterator
|
|
1591
|
+
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
1548
1592
|
|
|
1549
1593
|
|
|
1550
1594
|
var utils$1 = {
|
|
@@ -1558,6 +1602,7 @@
|
|
|
1558
1602
|
isBoolean,
|
|
1559
1603
|
isObject: isObject$1,
|
|
1560
1604
|
isPlainObject,
|
|
1605
|
+
isEmptyObject,
|
|
1561
1606
|
isReadableStream,
|
|
1562
1607
|
isRequest,
|
|
1563
1608
|
isResponse,
|
|
@@ -1567,7 +1612,7 @@
|
|
|
1567
1612
|
isFile,
|
|
1568
1613
|
isBlob,
|
|
1569
1614
|
isRegExp,
|
|
1570
|
-
isFunction,
|
|
1615
|
+
isFunction: isFunction$1,
|
|
1571
1616
|
isStream,
|
|
1572
1617
|
isURLSearchParams,
|
|
1573
1618
|
isTypedArray,
|
|
@@ -1693,11 +1738,18 @@
|
|
|
1693
1738
|
return prop !== 'isAxiosError';
|
|
1694
1739
|
});
|
|
1695
1740
|
|
|
1696
|
-
|
|
1741
|
+
const msg = error && error.message ? error.message : 'Error';
|
|
1742
|
+
|
|
1743
|
+
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
1744
|
+
const errCode = code == null && error ? error.code : code;
|
|
1745
|
+
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
1697
1746
|
|
|
1698
|
-
|
|
1747
|
+
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
1748
|
+
if (error && axiosError.cause == null) {
|
|
1749
|
+
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
|
|
1750
|
+
}
|
|
1699
1751
|
|
|
1700
|
-
axiosError.name = error.name;
|
|
1752
|
+
axiosError.name = (error && error.name) || 'Error';
|
|
1701
1753
|
|
|
1702
1754
|
customProps && Object.assign(axiosError, customProps);
|
|
1703
1755
|
|
|
@@ -1822,6 +1874,10 @@
|
|
|
1822
1874
|
return value.toISOString();
|
|
1823
1875
|
}
|
|
1824
1876
|
|
|
1877
|
+
if (utils$1.isBoolean(value)) {
|
|
1878
|
+
return value.toString();
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1825
1881
|
if (!useBlob && utils$1.isBlob(value)) {
|
|
1826
1882
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1827
1883
|
}
|
|
@@ -1984,9 +2040,7 @@
|
|
|
1984
2040
|
replace(/%3A/gi, ':').
|
|
1985
2041
|
replace(/%24/g, '$').
|
|
1986
2042
|
replace(/%2C/gi, ',').
|
|
1987
|
-
replace(/%20/g, '+')
|
|
1988
|
-
replace(/%5B/gi, '[').
|
|
1989
|
-
replace(/%5D/gi, ']');
|
|
2043
|
+
replace(/%20/g, '+');
|
|
1990
2044
|
}
|
|
1991
2045
|
|
|
1992
2046
|
/**
|
|
@@ -2064,7 +2118,7 @@
|
|
|
2064
2118
|
*
|
|
2065
2119
|
* @param {Number} id The ID that was returned by `use`
|
|
2066
2120
|
*
|
|
2067
|
-
* @returns {
|
|
2121
|
+
* @returns {void}
|
|
2068
2122
|
*/
|
|
2069
2123
|
eject(id) {
|
|
2070
2124
|
if (this.handlers[id]) {
|
|
@@ -2185,7 +2239,7 @@
|
|
|
2185
2239
|
};
|
|
2186
2240
|
|
|
2187
2241
|
function toURLEncodedForm(data, options) {
|
|
2188
|
-
return toFormData(data, new platform.classes.URLSearchParams(),
|
|
2242
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
2189
2243
|
visitor: function(value, key, path, helpers) {
|
|
2190
2244
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
2191
2245
|
this.append(key, value.toString('base64'));
|
|
@@ -2193,8 +2247,9 @@
|
|
|
2193
2247
|
}
|
|
2194
2248
|
|
|
2195
2249
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
2196
|
-
}
|
|
2197
|
-
|
|
2250
|
+
},
|
|
2251
|
+
...options
|
|
2252
|
+
});
|
|
2198
2253
|
}
|
|
2199
2254
|
|
|
2200
2255
|
/**
|
|
@@ -2390,7 +2445,7 @@
|
|
|
2390
2445
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
2391
2446
|
|
|
2392
2447
|
try {
|
|
2393
|
-
return JSON.parse(data);
|
|
2448
|
+
return JSON.parse(data, this.parseReviver);
|
|
2394
2449
|
} catch (e) {
|
|
2395
2450
|
if (strictJSONParsing) {
|
|
2396
2451
|
if (e.name === 'SyntaxError') {
|
|
@@ -2947,7 +3002,7 @@
|
|
|
2947
3002
|
clearTimeout(timer);
|
|
2948
3003
|
timer = null;
|
|
2949
3004
|
}
|
|
2950
|
-
fn
|
|
3005
|
+
fn(...args);
|
|
2951
3006
|
};
|
|
2952
3007
|
|
|
2953
3008
|
const throttled = (...args) => {
|
|
@@ -3029,27 +3084,38 @@
|
|
|
3029
3084
|
|
|
3030
3085
|
// Standard browser envs support document.cookie
|
|
3031
3086
|
{
|
|
3032
|
-
write(name, value, expires, path, domain, secure) {
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
3087
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
3088
|
+
if (typeof document === 'undefined') return;
|
|
3036
3089
|
|
|
3037
|
-
|
|
3090
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
3038
3091
|
|
|
3039
|
-
utils$1.
|
|
3040
|
-
|
|
3041
|
-
|
|
3092
|
+
if (utils$1.isNumber(expires)) {
|
|
3093
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
3094
|
+
}
|
|
3095
|
+
if (utils$1.isString(path)) {
|
|
3096
|
+
cookie.push(`path=${path}`);
|
|
3097
|
+
}
|
|
3098
|
+
if (utils$1.isString(domain)) {
|
|
3099
|
+
cookie.push(`domain=${domain}`);
|
|
3100
|
+
}
|
|
3101
|
+
if (secure === true) {
|
|
3102
|
+
cookie.push('secure');
|
|
3103
|
+
}
|
|
3104
|
+
if (utils$1.isString(sameSite)) {
|
|
3105
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
3106
|
+
}
|
|
3042
3107
|
|
|
3043
3108
|
document.cookie = cookie.join('; ');
|
|
3044
3109
|
},
|
|
3045
3110
|
|
|
3046
3111
|
read(name) {
|
|
3047
|
-
|
|
3048
|
-
|
|
3112
|
+
if (typeof document === 'undefined') return null;
|
|
3113
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
3114
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
3049
3115
|
},
|
|
3050
3116
|
|
|
3051
3117
|
remove(name) {
|
|
3052
|
-
this.write(name, '', Date.now() - 86400000);
|
|
3118
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
3053
3119
|
}
|
|
3054
3120
|
}
|
|
3055
3121
|
|
|
@@ -3138,11 +3204,11 @@
|
|
|
3138
3204
|
}
|
|
3139
3205
|
|
|
3140
3206
|
// eslint-disable-next-line consistent-return
|
|
3141
|
-
function mergeDeepProperties(a, b, prop
|
|
3207
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
3142
3208
|
if (!utils$1.isUndefined(b)) {
|
|
3143
|
-
return getMergedValue(a, b, prop
|
|
3209
|
+
return getMergedValue(a, b, prop, caseless);
|
|
3144
3210
|
} else if (!utils$1.isUndefined(a)) {
|
|
3145
|
-
return getMergedValue(undefined, a, prop
|
|
3211
|
+
return getMergedValue(undefined, a, prop, caseless);
|
|
3146
3212
|
}
|
|
3147
3213
|
}
|
|
3148
3214
|
|
|
@@ -3200,10 +3266,10 @@
|
|
|
3200
3266
|
socketPath: defaultToConfig2,
|
|
3201
3267
|
responseEncoding: defaultToConfig2,
|
|
3202
3268
|
validateStatus: mergeDirectKeys,
|
|
3203
|
-
headers: (a, b
|
|
3269
|
+
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
3204
3270
|
};
|
|
3205
3271
|
|
|
3206
|
-
utils$1.forEach(Object.keys(
|
|
3272
|
+
utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
3207
3273
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
3208
3274
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
3209
3275
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
@@ -3215,7 +3281,7 @@
|
|
|
3215
3281
|
var resolveConfig = (config) => {
|
|
3216
3282
|
const newConfig = mergeConfig({}, config);
|
|
3217
3283
|
|
|
3218
|
-
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
3284
|
+
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
3219
3285
|
|
|
3220
3286
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
3221
3287
|
|
|
@@ -3228,17 +3294,21 @@
|
|
|
3228
3294
|
);
|
|
3229
3295
|
}
|
|
3230
3296
|
|
|
3231
|
-
let contentType;
|
|
3232
|
-
|
|
3233
3297
|
if (utils$1.isFormData(data)) {
|
|
3234
3298
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
3235
|
-
headers.setContentType(undefined); //
|
|
3236
|
-
} else if ((
|
|
3237
|
-
//
|
|
3238
|
-
const
|
|
3239
|
-
headers
|
|
3299
|
+
headers.setContentType(undefined); // browser handles it
|
|
3300
|
+
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
3301
|
+
// Node.js FormData (like form-data package)
|
|
3302
|
+
const formHeaders = data.getHeaders();
|
|
3303
|
+
// Only set safe headers to avoid overwriting security headers
|
|
3304
|
+
const allowedHeaders = ['content-type', 'content-length'];
|
|
3305
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
3306
|
+
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
3307
|
+
headers.set(key, val);
|
|
3308
|
+
}
|
|
3309
|
+
});
|
|
3240
3310
|
}
|
|
3241
|
-
}
|
|
3311
|
+
}
|
|
3242
3312
|
|
|
3243
3313
|
// Add xsrf header
|
|
3244
3314
|
// This is only done if running in a standard browser environment.
|
|
@@ -3355,15 +3425,18 @@
|
|
|
3355
3425
|
};
|
|
3356
3426
|
|
|
3357
3427
|
// Handle low level network errors
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3428
|
+
request.onerror = function handleError(event) {
|
|
3429
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
3430
|
+
// (message may be empty; when present, surface it)
|
|
3431
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
3432
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
3433
|
+
const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
|
|
3434
|
+
// attach the underlying event for consumers who want details
|
|
3435
|
+
err.event = event || null;
|
|
3436
|
+
reject(err);
|
|
3437
|
+
request = null;
|
|
3365
3438
|
};
|
|
3366
|
-
|
|
3439
|
+
|
|
3367
3440
|
// Handle timeout
|
|
3368
3441
|
request.ontimeout = function handleTimeout() {
|
|
3369
3442
|
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
@@ -3495,7 +3568,7 @@
|
|
|
3495
3568
|
const streamChunk = function* (chunk, chunkSize) {
|
|
3496
3569
|
let len = chunk.byteLength;
|
|
3497
3570
|
|
|
3498
|
-
if (
|
|
3571
|
+
if (len < chunkSize) {
|
|
3499
3572
|
yield chunk;
|
|
3500
3573
|
return;
|
|
3501
3574
|
}
|
|
@@ -3579,14 +3652,18 @@
|
|
|
3579
3652
|
})
|
|
3580
3653
|
};
|
|
3581
3654
|
|
|
3582
|
-
const
|
|
3583
|
-
|
|
3655
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3656
|
+
|
|
3657
|
+
const {isFunction} = utils$1;
|
|
3658
|
+
|
|
3659
|
+
const globalFetchAPI = (({Request, Response}) => ({
|
|
3660
|
+
Request, Response
|
|
3661
|
+
}))(utils$1.global);
|
|
3662
|
+
|
|
3663
|
+
const {
|
|
3664
|
+
ReadableStream: ReadableStream$1, TextEncoder
|
|
3665
|
+
} = utils$1.global;
|
|
3584
3666
|
|
|
3585
|
-
// used only inside the fetch adapter
|
|
3586
|
-
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
3587
|
-
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
3588
|
-
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
3589
|
-
);
|
|
3590
3667
|
|
|
3591
3668
|
const test = (fn, ...args) => {
|
|
3592
3669
|
try {
|
|
@@ -3596,278 +3673,380 @@
|
|
|
3596
3673
|
}
|
|
3597
3674
|
};
|
|
3598
3675
|
|
|
3599
|
-
const
|
|
3600
|
-
|
|
3676
|
+
const factory = (env) => {
|
|
3677
|
+
env = utils$1.merge.call({
|
|
3678
|
+
skipUndefined: true
|
|
3679
|
+
}, globalFetchAPI, env);
|
|
3601
3680
|
|
|
3602
|
-
const
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
duplexAccessed = true;
|
|
3607
|
-
return 'half';
|
|
3608
|
-
},
|
|
3609
|
-
}).headers.has('Content-Type');
|
|
3681
|
+
const {fetch: envFetch, Request, Response} = env;
|
|
3682
|
+
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
3683
|
+
const isRequestSupported = isFunction(Request);
|
|
3684
|
+
const isResponseSupported = isFunction(Response);
|
|
3610
3685
|
|
|
3611
|
-
|
|
3612
|
-
|
|
3686
|
+
if (!isFetchSupported) {
|
|
3687
|
+
return false;
|
|
3688
|
+
}
|
|
3613
3689
|
|
|
3614
|
-
|
|
3690
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
3615
3691
|
|
|
3616
|
-
|
|
3617
|
-
|
|
3692
|
+
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
3693
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
3694
|
+
async (str) => new Uint8Array(await new Request(str).arrayBuffer())
|
|
3695
|
+
);
|
|
3618
3696
|
|
|
3697
|
+
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
3698
|
+
let duplexAccessed = false;
|
|
3619
3699
|
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3700
|
+
const hasContentType = new Request(platform.origin, {
|
|
3701
|
+
body: new ReadableStream$1(),
|
|
3702
|
+
method: 'POST',
|
|
3703
|
+
get duplex() {
|
|
3704
|
+
duplexAccessed = true;
|
|
3705
|
+
return 'half';
|
|
3706
|
+
},
|
|
3707
|
+
}).headers.has('Content-Type');
|
|
3623
3708
|
|
|
3624
|
-
|
|
3625
|
-
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
3626
|
-
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
|
3627
|
-
(_, config) => {
|
|
3628
|
-
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
3629
|
-
});
|
|
3709
|
+
return duplexAccessed && !hasContentType;
|
|
3630
3710
|
});
|
|
3631
|
-
})(new Response));
|
|
3632
3711
|
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
return 0;
|
|
3636
|
-
}
|
|
3712
|
+
const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
|
|
3713
|
+
test(() => utils$1.isReadableStream(new Response('').body));
|
|
3637
3714
|
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
}
|
|
3715
|
+
const resolvers = {
|
|
3716
|
+
stream: supportsResponseStream && ((res) => res.body)
|
|
3717
|
+
};
|
|
3641
3718
|
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3719
|
+
isFetchSupported && ((() => {
|
|
3720
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
3721
|
+
!resolvers[type] && (resolvers[type] = (res, config) => {
|
|
3722
|
+
let method = res && res[type];
|
|
3723
|
+
|
|
3724
|
+
if (method) {
|
|
3725
|
+
return method.call(res);
|
|
3726
|
+
}
|
|
3727
|
+
|
|
3728
|
+
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
3729
|
+
});
|
|
3646
3730
|
});
|
|
3647
|
-
|
|
3648
|
-
}
|
|
3731
|
+
})());
|
|
3649
3732
|
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3733
|
+
const getBodyLength = async (body) => {
|
|
3734
|
+
if (body == null) {
|
|
3735
|
+
return 0;
|
|
3736
|
+
}
|
|
3653
3737
|
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3738
|
+
if (utils$1.isBlob(body)) {
|
|
3739
|
+
return body.size;
|
|
3740
|
+
}
|
|
3657
3741
|
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3742
|
+
if (utils$1.isSpecCompliantForm(body)) {
|
|
3743
|
+
const _request = new Request(platform.origin, {
|
|
3744
|
+
method: 'POST',
|
|
3745
|
+
body,
|
|
3746
|
+
});
|
|
3747
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
3748
|
+
}
|
|
3662
3749
|
|
|
3663
|
-
|
|
3664
|
-
|
|
3750
|
+
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
3751
|
+
return body.byteLength;
|
|
3752
|
+
}
|
|
3665
3753
|
|
|
3666
|
-
|
|
3667
|
-
|
|
3754
|
+
if (utils$1.isURLSearchParams(body)) {
|
|
3755
|
+
body = body + '';
|
|
3756
|
+
}
|
|
3757
|
+
|
|
3758
|
+
if (utils$1.isString(body)) {
|
|
3759
|
+
return (await encodeText(body)).byteLength;
|
|
3760
|
+
}
|
|
3761
|
+
};
|
|
3762
|
+
|
|
3763
|
+
const resolveBodyLength = async (headers, body) => {
|
|
3764
|
+
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
3765
|
+
|
|
3766
|
+
return length == null ? getBodyLength(body) : length;
|
|
3767
|
+
};
|
|
3768
|
+
|
|
3769
|
+
return async (config) => {
|
|
3770
|
+
let {
|
|
3771
|
+
url,
|
|
3772
|
+
method,
|
|
3773
|
+
data,
|
|
3774
|
+
signal,
|
|
3775
|
+
cancelToken,
|
|
3776
|
+
timeout,
|
|
3777
|
+
onDownloadProgress,
|
|
3778
|
+
onUploadProgress,
|
|
3779
|
+
responseType,
|
|
3780
|
+
headers,
|
|
3781
|
+
withCredentials = 'same-origin',
|
|
3782
|
+
fetchOptions
|
|
3783
|
+
} = resolveConfig(config);
|
|
3784
|
+
|
|
3785
|
+
let _fetch = envFetch || fetch;
|
|
3786
|
+
|
|
3787
|
+
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3788
|
+
|
|
3789
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
3668
3790
|
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
method,
|
|
3673
|
-
data,
|
|
3674
|
-
signal,
|
|
3675
|
-
cancelToken,
|
|
3676
|
-
timeout,
|
|
3677
|
-
onDownloadProgress,
|
|
3678
|
-
onUploadProgress,
|
|
3679
|
-
responseType,
|
|
3680
|
-
headers,
|
|
3681
|
-
withCredentials = 'same-origin',
|
|
3682
|
-
fetchOptions
|
|
3683
|
-
} = resolveConfig(config);
|
|
3684
|
-
|
|
3685
|
-
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3686
|
-
|
|
3687
|
-
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
3688
|
-
|
|
3689
|
-
let request;
|
|
3690
|
-
|
|
3691
|
-
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
3791
|
+
let request = null;
|
|
3792
|
+
|
|
3793
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
3692
3794
|
composedSignal.unsubscribe();
|
|
3693
|
-
|
|
3795
|
+
});
|
|
3694
3796
|
|
|
3695
|
-
|
|
3797
|
+
let requestContentLength;
|
|
3696
3798
|
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3799
|
+
try {
|
|
3800
|
+
if (
|
|
3801
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
|
3802
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
3803
|
+
) {
|
|
3804
|
+
let _request = new Request(url, {
|
|
3805
|
+
method: 'POST',
|
|
3806
|
+
body: data,
|
|
3807
|
+
duplex: "half"
|
|
3808
|
+
});
|
|
3707
3809
|
|
|
3708
|
-
|
|
3810
|
+
let contentTypeHeader;
|
|
3709
3811
|
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3812
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
3813
|
+
headers.setContentType(contentTypeHeader);
|
|
3814
|
+
}
|
|
3713
3815
|
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3816
|
+
if (_request.body) {
|
|
3817
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
3818
|
+
requestContentLength,
|
|
3819
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
3820
|
+
);
|
|
3719
3821
|
|
|
3720
|
-
|
|
3822
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
3823
|
+
}
|
|
3721
3824
|
}
|
|
3722
|
-
}
|
|
3723
3825
|
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3826
|
+
if (!utils$1.isString(withCredentials)) {
|
|
3827
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
3828
|
+
}
|
|
3727
3829
|
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
request = new Request(url, {
|
|
3732
|
-
...fetchOptions,
|
|
3733
|
-
signal: composedSignal,
|
|
3734
|
-
method: method.toUpperCase(),
|
|
3735
|
-
headers: headers.normalize().toJSON(),
|
|
3736
|
-
body: data,
|
|
3737
|
-
duplex: "half",
|
|
3738
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3739
|
-
});
|
|
3830
|
+
// Cloudflare Workers throws when credentials are defined
|
|
3831
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
3832
|
+
const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
|
|
3740
3833
|
|
|
3741
|
-
|
|
3834
|
+
const resolvedOptions = {
|
|
3835
|
+
...fetchOptions,
|
|
3836
|
+
signal: composedSignal,
|
|
3837
|
+
method: method.toUpperCase(),
|
|
3838
|
+
headers: headers.normalize().toJSON(),
|
|
3839
|
+
body: data,
|
|
3840
|
+
duplex: "half",
|
|
3841
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3842
|
+
};
|
|
3742
3843
|
|
|
3743
|
-
|
|
3844
|
+
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3744
3845
|
|
|
3745
|
-
|
|
3746
|
-
const options = {};
|
|
3846
|
+
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
|
|
3747
3847
|
|
|
3748
|
-
|
|
3749
|
-
options[prop] = response[prop];
|
|
3750
|
-
});
|
|
3848
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3751
3849
|
|
|
3752
|
-
|
|
3850
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
3851
|
+
const options = {};
|
|
3753
3852
|
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
) || [];
|
|
3853
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
|
3854
|
+
options[prop] = response[prop];
|
|
3855
|
+
});
|
|
3758
3856
|
|
|
3759
|
-
|
|
3760
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
3761
|
-
flush && flush();
|
|
3762
|
-
unsubscribe && unsubscribe();
|
|
3763
|
-
}),
|
|
3764
|
-
options
|
|
3765
|
-
);
|
|
3766
|
-
}
|
|
3857
|
+
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3767
3858
|
|
|
3768
|
-
|
|
3859
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
3860
|
+
responseContentLength,
|
|
3861
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
3862
|
+
) || [];
|
|
3769
3863
|
|
|
3770
|
-
|
|
3864
|
+
response = new Response(
|
|
3865
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
3866
|
+
flush && flush();
|
|
3867
|
+
unsubscribe && unsubscribe();
|
|
3868
|
+
}),
|
|
3869
|
+
options
|
|
3870
|
+
);
|
|
3871
|
+
}
|
|
3771
3872
|
|
|
3772
|
-
|
|
3873
|
+
responseType = responseType || 'text';
|
|
3773
3874
|
|
|
3774
|
-
|
|
3775
|
-
settle(resolve, reject, {
|
|
3776
|
-
data: responseData,
|
|
3777
|
-
headers: AxiosHeaders$1.from(response.headers),
|
|
3778
|
-
status: response.status,
|
|
3779
|
-
statusText: response.statusText,
|
|
3780
|
-
config,
|
|
3781
|
-
request
|
|
3782
|
-
});
|
|
3783
|
-
})
|
|
3784
|
-
} catch (err) {
|
|
3785
|
-
unsubscribe && unsubscribe();
|
|
3875
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
3786
3876
|
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
{
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3877
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3878
|
+
|
|
3879
|
+
return await new Promise((resolve, reject) => {
|
|
3880
|
+
settle(resolve, reject, {
|
|
3881
|
+
data: responseData,
|
|
3882
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
3883
|
+
status: response.status,
|
|
3884
|
+
statusText: response.statusText,
|
|
3885
|
+
config,
|
|
3886
|
+
request
|
|
3887
|
+
});
|
|
3888
|
+
})
|
|
3889
|
+
} catch (err) {
|
|
3890
|
+
unsubscribe && unsubscribe();
|
|
3891
|
+
|
|
3892
|
+
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3893
|
+
throw Object.assign(
|
|
3894
|
+
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
3895
|
+
{
|
|
3896
|
+
cause: err.cause || err
|
|
3897
|
+
}
|
|
3898
|
+
)
|
|
3899
|
+
}
|
|
3900
|
+
|
|
3901
|
+
throw AxiosError.from(err, err && err.code, config, request);
|
|
3794
3902
|
}
|
|
3903
|
+
}
|
|
3904
|
+
};
|
|
3795
3905
|
|
|
3796
|
-
|
|
3906
|
+
const seedCache = new Map();
|
|
3907
|
+
|
|
3908
|
+
const getFetch = (config) => {
|
|
3909
|
+
let env = (config && config.env) || {};
|
|
3910
|
+
const {fetch, Request, Response} = env;
|
|
3911
|
+
const seeds = [
|
|
3912
|
+
Request, Response, fetch
|
|
3913
|
+
];
|
|
3914
|
+
|
|
3915
|
+
let len = seeds.length, i = len,
|
|
3916
|
+
seed, target, map = seedCache;
|
|
3917
|
+
|
|
3918
|
+
while (i--) {
|
|
3919
|
+
seed = seeds[i];
|
|
3920
|
+
target = map.get(seed);
|
|
3921
|
+
|
|
3922
|
+
target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
|
|
3923
|
+
|
|
3924
|
+
map = target;
|
|
3797
3925
|
}
|
|
3798
|
-
});
|
|
3799
3926
|
|
|
3927
|
+
return target;
|
|
3928
|
+
};
|
|
3929
|
+
|
|
3930
|
+
getFetch();
|
|
3931
|
+
|
|
3932
|
+
/**
|
|
3933
|
+
* Known adapters mapping.
|
|
3934
|
+
* Provides environment-specific adapters for Axios:
|
|
3935
|
+
* - `http` for Node.js
|
|
3936
|
+
* - `xhr` for browsers
|
|
3937
|
+
* - `fetch` for fetch API-based requests
|
|
3938
|
+
*
|
|
3939
|
+
* @type {Object<string, Function|Object>}
|
|
3940
|
+
*/
|
|
3800
3941
|
const knownAdapters = {
|
|
3801
3942
|
http: httpAdapter,
|
|
3802
3943
|
xhr: xhrAdapter,
|
|
3803
|
-
fetch:
|
|
3944
|
+
fetch: {
|
|
3945
|
+
get: getFetch,
|
|
3946
|
+
}
|
|
3804
3947
|
};
|
|
3805
3948
|
|
|
3949
|
+
// Assign adapter names for easier debugging and identification
|
|
3806
3950
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
3807
3951
|
if (fn) {
|
|
3808
3952
|
try {
|
|
3809
|
-
Object.defineProperty(fn, 'name', {value});
|
|
3953
|
+
Object.defineProperty(fn, 'name', { value });
|
|
3810
3954
|
} catch (e) {
|
|
3811
3955
|
// eslint-disable-next-line no-empty
|
|
3812
3956
|
}
|
|
3813
|
-
Object.defineProperty(fn, 'adapterName', {value});
|
|
3957
|
+
Object.defineProperty(fn, 'adapterName', { value });
|
|
3814
3958
|
}
|
|
3815
3959
|
});
|
|
3816
3960
|
|
|
3961
|
+
/**
|
|
3962
|
+
* Render a rejection reason string for unknown or unsupported adapters
|
|
3963
|
+
*
|
|
3964
|
+
* @param {string} reason
|
|
3965
|
+
* @returns {string}
|
|
3966
|
+
*/
|
|
3817
3967
|
const renderReason = (reason) => `- ${reason}`;
|
|
3818
3968
|
|
|
3969
|
+
/**
|
|
3970
|
+
* Check if the adapter is resolved (function, null, or false)
|
|
3971
|
+
*
|
|
3972
|
+
* @param {Function|null|false} adapter
|
|
3973
|
+
* @returns {boolean}
|
|
3974
|
+
*/
|
|
3819
3975
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3820
3976
|
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3977
|
+
/**
|
|
3978
|
+
* Get the first suitable adapter from the provided list.
|
|
3979
|
+
* Tries each adapter in order until a supported one is found.
|
|
3980
|
+
* Throws an AxiosError if no adapter is suitable.
|
|
3981
|
+
*
|
|
3982
|
+
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
3983
|
+
* @param {Object} config - Axios request configuration
|
|
3984
|
+
* @throws {AxiosError} If no suitable adapter is available
|
|
3985
|
+
* @returns {Function} The resolved adapter function
|
|
3986
|
+
*/
|
|
3987
|
+
function getAdapter(adapters, config) {
|
|
3988
|
+
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
3828
3989
|
|
|
3829
|
-
|
|
3990
|
+
const { length } = adapters;
|
|
3991
|
+
let nameOrAdapter;
|
|
3992
|
+
let adapter;
|
|
3830
3993
|
|
|
3831
|
-
|
|
3832
|
-
nameOrAdapter = adapters[i];
|
|
3833
|
-
let id;
|
|
3994
|
+
const rejectedReasons = {};
|
|
3834
3995
|
|
|
3835
|
-
|
|
3996
|
+
for (let i = 0; i < length; i++) {
|
|
3997
|
+
nameOrAdapter = adapters[i];
|
|
3998
|
+
let id;
|
|
3836
3999
|
|
|
3837
|
-
|
|
3838
|
-
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
4000
|
+
adapter = nameOrAdapter;
|
|
3839
4001
|
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
}
|
|
3843
|
-
}
|
|
4002
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
|
4003
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
3844
4004
|
|
|
3845
|
-
if (adapter) {
|
|
3846
|
-
|
|
4005
|
+
if (adapter === undefined) {
|
|
4006
|
+
throw new AxiosError(`Unknown adapter '${id}'`);
|
|
3847
4007
|
}
|
|
4008
|
+
}
|
|
3848
4009
|
|
|
3849
|
-
|
|
4010
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
4011
|
+
break;
|
|
3850
4012
|
}
|
|
3851
4013
|
|
|
3852
|
-
|
|
4014
|
+
rejectedReasons[id || '#' + i] = adapter;
|
|
4015
|
+
}
|
|
3853
4016
|
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
)
|
|
4017
|
+
if (!adapter) {
|
|
4018
|
+
const reasons = Object.entries(rejectedReasons)
|
|
4019
|
+
.map(([id, state]) => `adapter ${id} ` +
|
|
4020
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
4021
|
+
);
|
|
3858
4022
|
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
4023
|
+
let s = length ?
|
|
4024
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
4025
|
+
'as no adapter specified';
|
|
3862
4026
|
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
4027
|
+
throw new AxiosError(
|
|
4028
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
|
4029
|
+
'ERR_NOT_SUPPORT'
|
|
4030
|
+
);
|
|
4031
|
+
}
|
|
3868
4032
|
|
|
3869
|
-
|
|
3870
|
-
|
|
4033
|
+
return adapter;
|
|
4034
|
+
}
|
|
4035
|
+
|
|
4036
|
+
/**
|
|
4037
|
+
* Exports Axios adapters and utility to resolve an adapter
|
|
4038
|
+
*/
|
|
4039
|
+
var adapters = {
|
|
4040
|
+
/**
|
|
4041
|
+
* Resolve an adapter from a list of adapter names or functions.
|
|
4042
|
+
* @type {Function}
|
|
4043
|
+
*/
|
|
4044
|
+
getAdapter,
|
|
4045
|
+
|
|
4046
|
+
/**
|
|
4047
|
+
* Exposes all known adapters
|
|
4048
|
+
* @type {Object<string, Function|Object>}
|
|
4049
|
+
*/
|
|
3871
4050
|
adapters: knownAdapters
|
|
3872
4051
|
};
|
|
3873
4052
|
|
|
@@ -3910,7 +4089,7 @@
|
|
|
3910
4089
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
3911
4090
|
}
|
|
3912
4091
|
|
|
3913
|
-
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
|
4092
|
+
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter, config);
|
|
3914
4093
|
|
|
3915
4094
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
3916
4095
|
throwIfCancellationRequested(config);
|
|
@@ -3944,7 +4123,7 @@
|
|
|
3944
4123
|
});
|
|
3945
4124
|
}
|
|
3946
4125
|
|
|
3947
|
-
const VERSION = "1.
|
|
4126
|
+
const VERSION = "1.13.2";
|
|
3948
4127
|
|
|
3949
4128
|
const validators$1 = {};
|
|
3950
4129
|
|
|
@@ -4183,8 +4362,8 @@
|
|
|
4183
4362
|
|
|
4184
4363
|
if (!synchronousRequestInterceptors) {
|
|
4185
4364
|
const chain = [dispatchRequest.bind(this), undefined];
|
|
4186
|
-
chain.unshift
|
|
4187
|
-
chain.push
|
|
4365
|
+
chain.unshift(...requestInterceptorChain);
|
|
4366
|
+
chain.push(...responseInterceptorChain);
|
|
4188
4367
|
len = chain.length;
|
|
4189
4368
|
|
|
4190
4369
|
promise = Promise.resolve(config);
|
|
@@ -4200,8 +4379,6 @@
|
|
|
4200
4379
|
|
|
4201
4380
|
let newConfig = config;
|
|
4202
4381
|
|
|
4203
|
-
i = 0;
|
|
4204
|
-
|
|
4205
4382
|
while (i < len) {
|
|
4206
4383
|
const onFulfilled = requestInterceptorChain[i++];
|
|
4207
4384
|
const onRejected = requestInterceptorChain[i++];
|
|
@@ -4505,6 +4682,12 @@
|
|
|
4505
4682
|
LoopDetected: 508,
|
|
4506
4683
|
NotExtended: 510,
|
|
4507
4684
|
NetworkAuthenticationRequired: 511,
|
|
4685
|
+
WebServerIsDown: 521,
|
|
4686
|
+
ConnectionTimedOut: 522,
|
|
4687
|
+
OriginIsUnreachable: 523,
|
|
4688
|
+
TimeoutOccurred: 524,
|
|
4689
|
+
SslHandshakeFailed: 525,
|
|
4690
|
+
InvalidSslCertificate: 526,
|
|
4508
4691
|
};
|
|
4509
4692
|
|
|
4510
4693
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
@@ -4726,7 +4909,7 @@
|
|
|
4726
4909
|
var errors = {};
|
|
4727
4910
|
|
|
4728
4911
|
Object.defineProperty(errors, "__esModule", { value: true });
|
|
4729
|
-
errors.errorCodeToString =
|
|
4912
|
+
errors.errorCodeToString = errorCodeToString;
|
|
4730
4913
|
const consts_1$4 = consts;
|
|
4731
4914
|
function errorCodeToString(returnCode, customErrorList) {
|
|
4732
4915
|
const returnCodeStr = returnCode.toString(16).toUpperCase();
|
|
@@ -4739,7 +4922,6 @@
|
|
|
4739
4922
|
}
|
|
4740
4923
|
return errDescription;
|
|
4741
4924
|
}
|
|
4742
|
-
errors.errorCodeToString = errorCodeToString;
|
|
4743
4925
|
|
|
4744
4926
|
Object.defineProperty(responseError, "__esModule", { value: true });
|
|
4745
4927
|
responseError.ResponseError = void 0;
|
|
@@ -4757,7 +4939,9 @@
|
|
|
4757
4939
|
responseError.ResponseError = ResponseError;
|
|
4758
4940
|
|
|
4759
4941
|
Object.defineProperty(bip32, "__esModule", { value: true });
|
|
4760
|
-
bip32.
|
|
4942
|
+
bip32.serializePath = serializePath;
|
|
4943
|
+
bip32.numbersToBip32Path = numbersToBip32Path;
|
|
4944
|
+
bip32.bufferToBip32Path = bufferToBip32Path;
|
|
4761
4945
|
const consts_1$3 = consts;
|
|
4762
4946
|
const responseError_1$3 = responseError;
|
|
4763
4947
|
function serializePath(path, requiredPathLengths) {
|
|
@@ -4791,7 +4975,6 @@
|
|
|
4791
4975
|
});
|
|
4792
4976
|
return buf;
|
|
4793
4977
|
}
|
|
4794
|
-
bip32.serializePath = serializePath;
|
|
4795
4978
|
function numbersToBip32Path(items) {
|
|
4796
4979
|
if (items.length === 0) {
|
|
4797
4980
|
throw new responseError_1$3.ResponseError(consts_1$3.LedgerError.GenericError, 'The items array cannot be empty.');
|
|
@@ -4812,7 +4995,6 @@
|
|
|
4812
4995
|
}
|
|
4813
4996
|
return 'm/' + pathArray.join('/');
|
|
4814
4997
|
}
|
|
4815
|
-
bip32.numbersToBip32Path = numbersToBip32Path;
|
|
4816
4998
|
function bufferToBip32Path(buffer) {
|
|
4817
4999
|
if (buffer.length % 4 !== 0) {
|
|
4818
5000
|
throw new responseError_1$3.ResponseError(consts_1$3.LedgerError.GenericError, 'The buffer length must be a multiple of 4.');
|
|
@@ -4823,7 +5005,6 @@
|
|
|
4823
5005
|
}
|
|
4824
5006
|
return numbersToBip32Path(items);
|
|
4825
5007
|
}
|
|
4826
|
-
bip32.bufferToBip32Path = bufferToBip32Path;
|
|
4827
5008
|
|
|
4828
5009
|
var common = {};
|
|
4829
5010
|
|
|
@@ -4964,7 +5145,8 @@
|
|
|
4964
5145
|
payload.ResponsePayload = ResponsePayload;
|
|
4965
5146
|
|
|
4966
5147
|
Object.defineProperty(common, "__esModule", { value: true });
|
|
4967
|
-
common.
|
|
5148
|
+
common.processResponse = processResponse;
|
|
5149
|
+
common.processErrorResponse = processErrorResponse;
|
|
4968
5150
|
const consts_1$1 = consts;
|
|
4969
5151
|
const errors_1 = errors;
|
|
4970
5152
|
const payload_1 = payload;
|
|
@@ -4983,11 +5165,16 @@
|
|
|
4983
5165
|
return new payload_1.ResponsePayload(payload);
|
|
4984
5166
|
}
|
|
4985
5167
|
if (payload.length > 0) {
|
|
4986
|
-
|
|
5168
|
+
const payloadString = payload.toString('utf8');
|
|
5169
|
+
if (!payloadString.includes(errorMessage)) {
|
|
5170
|
+
errorMessage += ` : ${payloadString}`;
|
|
5171
|
+
}
|
|
5172
|
+
else {
|
|
5173
|
+
errorMessage = payloadString;
|
|
5174
|
+
}
|
|
4987
5175
|
}
|
|
4988
5176
|
throw new responseError_1$1.ResponseError(returnCode, errorMessage);
|
|
4989
5177
|
}
|
|
4990
|
-
common.processResponse = processResponse;
|
|
4991
5178
|
function processErrorResponse(response, customErrorList) {
|
|
4992
5179
|
if (isDict(response)) {
|
|
4993
5180
|
if (Object.prototype.hasOwnProperty.call(response, 'statusCode')) {
|
|
@@ -4999,7 +5186,6 @@
|
|
|
4999
5186
|
}
|
|
5000
5187
|
return responseError_1$1.ResponseError.fromReturnCode(consts_1$1.LedgerError.UnknownTransportError);
|
|
5001
5188
|
}
|
|
5002
|
-
common.processErrorResponse = processErrorResponse;
|
|
5003
5189
|
|
|
5004
5190
|
Object.defineProperty(app, "__esModule", { value: true });
|
|
5005
5191
|
const bip32_1 = bip32;
|
|
@@ -5046,9 +5232,25 @@
|
|
|
5046
5232
|
payloadType = consts_1.PAYLOAD_TYPE.LAST;
|
|
5047
5233
|
}
|
|
5048
5234
|
const statusList = [consts_1.LedgerError.NoErrors, consts_1.LedgerError.DataIsInvalid, consts_1.LedgerError.BadKeyHandle];
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5235
|
+
try {
|
|
5236
|
+
const responseBuffer = await this.transport.send(this.CLA, ins, payloadType, p2, chunk, statusList);
|
|
5237
|
+
return (0, common_1$1.processResponse)(responseBuffer, this.CUSTOM_APP_ERROR_DESCRIPTION);
|
|
5238
|
+
}
|
|
5239
|
+
catch (e) {
|
|
5240
|
+
const statusCode = e.statusCode || e.returnCode || consts_1.LedgerError.UnknownTransportError;
|
|
5241
|
+
const message = e.message;
|
|
5242
|
+
let buffer;
|
|
5243
|
+
if (message?.length > 0) {
|
|
5244
|
+
const messageBytes = Buffer.from(message, 'utf8');
|
|
5245
|
+
buffer = Buffer.concat([messageBytes, Buffer.allocUnsafe(2)]);
|
|
5246
|
+
buffer.writeUInt16BE(statusCode, buffer.length - 2);
|
|
5247
|
+
}
|
|
5248
|
+
else {
|
|
5249
|
+
buffer = Buffer.allocUnsafe(2);
|
|
5250
|
+
buffer.writeUInt16BE(statusCode, 0);
|
|
5251
|
+
}
|
|
5252
|
+
return (0, common_1$1.processResponse)(buffer, this.CUSTOM_APP_ERROR_DESCRIPTION);
|
|
5253
|
+
}
|
|
5052
5254
|
}
|
|
5053
5255
|
async signSendChunk(ins, chunkIdx, chunkNum, chunk) {
|
|
5054
5256
|
return this.sendGenericChunk(ins, 0, chunkIdx, chunkNum, chunk);
|
|
@@ -5161,7 +5363,7 @@
|
|
|
5161
5363
|
|
|
5162
5364
|
Object.defineProperty(types, "__esModule", { value: true });
|
|
5163
5365
|
|
|
5164
|
-
(function (exports) {
|
|
5366
|
+
(function (exports$1) {
|
|
5165
5367
|
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5166
5368
|
if (k2 === undefined) k2 = k;
|
|
5167
5369
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -5173,21 +5375,21 @@
|
|
|
5173
5375
|
if (k2 === undefined) k2 = k;
|
|
5174
5376
|
o[k2] = m[k];
|
|
5175
5377
|
}));
|
|
5176
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
5177
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
5378
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports$1) {
|
|
5379
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
5178
5380
|
};
|
|
5179
5381
|
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
5180
5382
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5181
5383
|
};
|
|
5182
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5384
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
5183
5385
|
const app_1 = __importDefault(app);
|
|
5184
|
-
exports.default = app_1.default;
|
|
5185
|
-
__exportStar(common, exports);
|
|
5186
|
-
__exportStar(consts, exports);
|
|
5187
|
-
__exportStar(types, exports);
|
|
5188
|
-
__exportStar(bip32, exports);
|
|
5189
|
-
__exportStar(responseError, exports);
|
|
5190
|
-
__exportStar(payload, exports);
|
|
5386
|
+
exports$1.default = app_1.default;
|
|
5387
|
+
__exportStar(common, exports$1);
|
|
5388
|
+
__exportStar(consts, exports$1);
|
|
5389
|
+
__exportStar(types, exports$1);
|
|
5390
|
+
__exportStar(bip32, exports$1);
|
|
5391
|
+
__exportStar(responseError, exports$1);
|
|
5392
|
+
__exportStar(payload, exports$1);
|
|
5191
5393
|
} (dist));
|
|
5192
5394
|
getDefaultExportFromCjs(dist);
|
|
5193
5395
|
|
|
@@ -5574,7 +5776,7 @@
|
|
|
5574
5776
|
}
|
|
5575
5777
|
generic_legacy.PolkadotGenericAppLegacy = PolkadotGenericAppLegacy;
|
|
5576
5778
|
|
|
5577
|
-
(function (exports) {
|
|
5779
|
+
(function (exports$1) {
|
|
5578
5780
|
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5579
5781
|
if (k2 === undefined) k2 = k;
|
|
5580
5782
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -5586,19 +5788,19 @@
|
|
|
5586
5788
|
if (k2 === undefined) k2 = k;
|
|
5587
5789
|
o[k2] = m[k];
|
|
5588
5790
|
}));
|
|
5589
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
5590
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
5791
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports$1) {
|
|
5792
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
5591
5793
|
};
|
|
5592
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5593
|
-
exports.supportedApps = exports.newSubstrateApp = exports.SubstrateApp = void 0;
|
|
5594
|
-
__exportStar(legacy_apps, exports);
|
|
5595
|
-
__exportStar(generic_app, exports);
|
|
5596
|
-
__exportStar(generic_legacy, exports);
|
|
5794
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
5795
|
+
exports$1.supportedApps = exports$1.newSubstrateApp = exports$1.SubstrateApp = void 0;
|
|
5796
|
+
__exportStar(legacy_apps, exports$1);
|
|
5797
|
+
__exportStar(generic_app, exports$1);
|
|
5798
|
+
__exportStar(generic_legacy, exports$1);
|
|
5597
5799
|
var substrate_app_1 = substrate_app;
|
|
5598
|
-
Object.defineProperty(exports, "SubstrateApp", { enumerable: true, get: function () { return substrate_app_1.SubstrateApp; } });
|
|
5800
|
+
Object.defineProperty(exports$1, "SubstrateApp", { enumerable: true, get: function () { return substrate_app_1.SubstrateApp; } });
|
|
5599
5801
|
var supported_apps_1 = supported_apps;
|
|
5600
|
-
Object.defineProperty(exports, "newSubstrateApp", { enumerable: true, get: function () { return supported_apps_1.newSubstrateApp; } });
|
|
5601
|
-
Object.defineProperty(exports, "supportedApps", { enumerable: true, get: function () { return supported_apps_1.supportedApps; } });
|
|
5802
|
+
Object.defineProperty(exports$1, "newSubstrateApp", { enumerable: true, get: function () { return supported_apps_1.newSubstrateApp; } });
|
|
5803
|
+
Object.defineProperty(exports$1, "supportedApps", { enumerable: true, get: function () { return supported_apps_1.supportedApps; } });
|
|
5602
5804
|
} (dist$1));
|
|
5603
5805
|
getDefaultExportFromCjs(dist$1);
|
|
5604
5806
|
|
|
@@ -5687,7 +5889,7 @@
|
|
|
5687
5889
|
}function __metadata(metadataKey, metadataValue) {
|
|
5688
5890
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
5689
5891
|
}
|
|
5690
|
-
function __awaiter
|
|
5892
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
5691
5893
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5692
5894
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5693
5895
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
@@ -5820,10 +6022,18 @@
|
|
|
5820
6022
|
}) : function(o, v) {
|
|
5821
6023
|
o["default"] = v;
|
|
5822
6024
|
};
|
|
6025
|
+
var ownKeys = function(o) {
|
|
6026
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
6027
|
+
var ar = [];
|
|
6028
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
6029
|
+
return ar;
|
|
6030
|
+
};
|
|
6031
|
+
return ownKeys(o);
|
|
6032
|
+
};
|
|
5823
6033
|
function __importStar(mod) {
|
|
5824
6034
|
if (mod && mod.__esModule) return mod;
|
|
5825
6035
|
var result = {};
|
|
5826
|
-
if (mod != null) for (var k
|
|
6036
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
5827
6037
|
__setModuleDefault(result, mod);
|
|
5828
6038
|
return result;
|
|
5829
6039
|
}
|
|
@@ -5915,7 +6125,7 @@
|
|
|
5915
6125
|
__propKey,
|
|
5916
6126
|
__setFunctionName,
|
|
5917
6127
|
__metadata,
|
|
5918
|
-
__awaiter
|
|
6128
|
+
__awaiter,
|
|
5919
6129
|
__generator,
|
|
5920
6130
|
__createBinding,
|
|
5921
6131
|
__exportStar,
|
|
@@ -5947,7 +6157,7 @@
|
|
|
5947
6157
|
__asyncGenerator: __asyncGenerator,
|
|
5948
6158
|
__asyncValues: __asyncValues,
|
|
5949
6159
|
__await: __await,
|
|
5950
|
-
__awaiter: __awaiter
|
|
6160
|
+
__awaiter: __awaiter,
|
|
5951
6161
|
__classPrivateFieldGet: __classPrivateFieldGet,
|
|
5952
6162
|
__classPrivateFieldIn: __classPrivateFieldIn,
|
|
5953
6163
|
__classPrivateFieldSet: __classPrivateFieldSet,
|
|
@@ -5980,8 +6190,14 @@
|
|
|
5980
6190
|
|
|
5981
6191
|
const EventEmitter = {};
|
|
5982
6192
|
|
|
6193
|
+
const errorClasses = {};
|
|
6194
|
+
const deserializers = {};
|
|
6195
|
+
const addCustomErrorDeserializer = (name, deserializer) => {
|
|
6196
|
+
deserializers[name] = deserializer;
|
|
6197
|
+
};
|
|
5983
6198
|
const createCustomErrorClass = (name) => {
|
|
5984
6199
|
class CustomErrorClass extends Error {
|
|
6200
|
+
cause;
|
|
5985
6201
|
constructor(message, fields, options) {
|
|
5986
6202
|
super(message || name, options);
|
|
5987
6203
|
Object.setPrototypeOf(this, CustomErrorClass.prototype);
|
|
@@ -5991,7 +6207,7 @@
|
|
|
5991
6207
|
this[k] = fields[k];
|
|
5992
6208
|
}
|
|
5993
6209
|
}
|
|
5994
|
-
if (options && isObject(options) && "cause" in options && !
|
|
6210
|
+
if (options && isObject(options) && "cause" in options && !this.cause) {
|
|
5995
6211
|
const cause = options.cause;
|
|
5996
6212
|
this.cause = cause;
|
|
5997
6213
|
if ("stack" in cause) {
|
|
@@ -6000,18 +6216,150 @@
|
|
|
6000
6216
|
}
|
|
6001
6217
|
}
|
|
6002
6218
|
}
|
|
6219
|
+
errorClasses[name] = CustomErrorClass;
|
|
6003
6220
|
return CustomErrorClass;
|
|
6004
6221
|
};
|
|
6005
6222
|
function isObject(value) {
|
|
6006
6223
|
return typeof value === "object";
|
|
6007
6224
|
}
|
|
6008
6225
|
|
|
6226
|
+
createCustomErrorClass("AccountNameRequired");
|
|
6227
|
+
createCustomErrorClass("AccountNotSupported");
|
|
6228
|
+
createCustomErrorClass("AccountAwaitingSendPendingOperations");
|
|
6229
|
+
createCustomErrorClass("AmountRequired");
|
|
6230
|
+
createCustomErrorClass("BluetoothRequired");
|
|
6231
|
+
createCustomErrorClass("BtcUnmatchedApp");
|
|
6232
|
+
createCustomErrorClass("CantOpenDevice");
|
|
6233
|
+
createCustomErrorClass("CashAddrNotSupported");
|
|
6234
|
+
createCustomErrorClass("ClaimRewardsFeesWarning");
|
|
6235
|
+
createCustomErrorClass("CurrencyNotSupported");
|
|
6236
|
+
createCustomErrorClass("DeviceAppVerifyNotSupported");
|
|
6237
|
+
createCustomErrorClass("DeviceGenuineSocketEarlyClose");
|
|
6238
|
+
createCustomErrorClass("DeviceNotGenuine");
|
|
6239
|
+
createCustomErrorClass("DeviceOnDashboardExpected");
|
|
6240
|
+
createCustomErrorClass("DeviceOnDashboardUnexpected");
|
|
6241
|
+
createCustomErrorClass("DeviceInOSUExpected");
|
|
6242
|
+
createCustomErrorClass("DeviceHalted");
|
|
6243
|
+
createCustomErrorClass("DeviceNameInvalid");
|
|
6244
|
+
createCustomErrorClass("DeviceSocketFail");
|
|
6245
|
+
createCustomErrorClass("DeviceSocketNoBulkStatus");
|
|
6246
|
+
createCustomErrorClass("DeviceSocketNoBulkStatus");
|
|
6247
|
+
createCustomErrorClass("UnresponsiveDeviceError");
|
|
6009
6248
|
const DisconnectedDevice = createCustomErrorClass("DisconnectedDevice");
|
|
6010
6249
|
const DisconnectedDeviceDuringOperation = createCustomErrorClass("DisconnectedDeviceDuringOperation");
|
|
6250
|
+
createCustomErrorClass("DeviceExtractOnboardingStateError");
|
|
6251
|
+
createCustomErrorClass("DeviceOnboardingStatePollingError");
|
|
6252
|
+
createCustomErrorClass("EnpointConfig");
|
|
6253
|
+
createCustomErrorClass("EthAppPleaseEnableContractData");
|
|
6254
|
+
createCustomErrorClass("SolAppPleaseEnableContractData");
|
|
6255
|
+
createCustomErrorClass("CeloAppPleaseEnableContractData");
|
|
6256
|
+
createCustomErrorClass("FeeEstimationFailed");
|
|
6257
|
+
createCustomErrorClass("FirmwareNotRecognized");
|
|
6258
|
+
createCustomErrorClass("HardResetFail");
|
|
6259
|
+
createCustomErrorClass("InvalidXRPTag");
|
|
6260
|
+
createCustomErrorClass("InvalidAddress");
|
|
6261
|
+
createCustomErrorClass("InvalidNonce");
|
|
6262
|
+
createCustomErrorClass("InvalidAddressBecauseDestinationIsAlsoSource");
|
|
6263
|
+
createCustomErrorClass("LatestMCUInstalledError");
|
|
6264
|
+
createCustomErrorClass("LatestFirmwareVersionRequired");
|
|
6265
|
+
createCustomErrorClass("UnsupportedFeatureError");
|
|
6266
|
+
createCustomErrorClass("NanoSNotSupported");
|
|
6267
|
+
createCustomErrorClass("UnknownMCU");
|
|
6268
|
+
createCustomErrorClass("LedgerAPIError");
|
|
6269
|
+
createCustomErrorClass("LedgerAPIErrorWithMessage");
|
|
6270
|
+
createCustomErrorClass("LedgerAPINotAvailable");
|
|
6271
|
+
createCustomErrorClass("ManagerAppAlreadyInstalled");
|
|
6272
|
+
createCustomErrorClass("ManagerAppRelyOnBTC");
|
|
6273
|
+
createCustomErrorClass("ManagerAppDepInstallRequired");
|
|
6274
|
+
createCustomErrorClass("ManagerAppDepUninstallRequired");
|
|
6275
|
+
createCustomErrorClass("ManagerDeviceLocked");
|
|
6276
|
+
createCustomErrorClass("ManagerFirmwareNotEnoughSpace");
|
|
6277
|
+
createCustomErrorClass("ManagerNotEnoughSpace");
|
|
6278
|
+
createCustomErrorClass("ManagerUninstallBTCDep");
|
|
6279
|
+
createCustomErrorClass("NetworkDown");
|
|
6280
|
+
createCustomErrorClass("NetworkError");
|
|
6281
|
+
createCustomErrorClass("NoAddressesFound");
|
|
6282
|
+
createCustomErrorClass("NotEnoughBalance");
|
|
6283
|
+
createCustomErrorClass("NotEnoughBalanceFees");
|
|
6284
|
+
createCustomErrorClass("NotEnoughBalanceSwap");
|
|
6285
|
+
createCustomErrorClass("NotEnoughBalanceToDelegate");
|
|
6286
|
+
createCustomErrorClass("UnstakeNotEnoughStakedBalanceLeft");
|
|
6287
|
+
createCustomErrorClass("RestakeNotEnoughStakedBalanceLeft");
|
|
6288
|
+
createCustomErrorClass("NotEnoughToRestake");
|
|
6289
|
+
createCustomErrorClass("NotEnoughToUnstake");
|
|
6290
|
+
createCustomErrorClass("NotEnoughBalanceInParentAccount");
|
|
6291
|
+
createCustomErrorClass("NotEnoughSpendableBalance");
|
|
6292
|
+
createCustomErrorClass("NotEnoughBalanceBecauseDestinationNotCreated");
|
|
6293
|
+
createCustomErrorClass("NotEnoughToStake");
|
|
6294
|
+
createCustomErrorClass("NoAccessToCamera");
|
|
6295
|
+
createCustomErrorClass("NotEnoughGas");
|
|
6296
|
+
createCustomErrorClass("NotEnoughGasSwap");
|
|
6297
|
+
createCustomErrorClass("TronEmptyAccount");
|
|
6298
|
+
createCustomErrorClass("MaybeKeepTronAccountAlive");
|
|
6299
|
+
createCustomErrorClass("NotSupportedLegacyAddress");
|
|
6300
|
+
createCustomErrorClass("GasLessThanEstimate");
|
|
6301
|
+
createCustomErrorClass("PriorityFeeTooLow");
|
|
6302
|
+
createCustomErrorClass("PriorityFeeTooHigh");
|
|
6303
|
+
createCustomErrorClass("PriorityFeeHigherThanMaxFee");
|
|
6304
|
+
createCustomErrorClass("MaxFeeTooLow");
|
|
6305
|
+
createCustomErrorClass("PasswordsDontMatch");
|
|
6306
|
+
createCustomErrorClass("PasswordIncorrect");
|
|
6307
|
+
createCustomErrorClass("RecommendSubAccountsToEmpty");
|
|
6308
|
+
createCustomErrorClass("RecommendUndelegation");
|
|
6309
|
+
createCustomErrorClass("TimeoutTagged");
|
|
6310
|
+
createCustomErrorClass("UnexpectedBootloader");
|
|
6311
|
+
createCustomErrorClass("MCUNotGenuineToDashboard");
|
|
6312
|
+
createCustomErrorClass("RecipientRequired");
|
|
6313
|
+
createCustomErrorClass("UnavailableTezosOriginatedAccountReceive");
|
|
6314
|
+
createCustomErrorClass("UnavailableTezosOriginatedAccountSend");
|
|
6315
|
+
createCustomErrorClass("UpdateFetchFileFail");
|
|
6316
|
+
createCustomErrorClass("UpdateIncorrectHash");
|
|
6317
|
+
createCustomErrorClass("UpdateIncorrectSig");
|
|
6318
|
+
createCustomErrorClass("UpdateYourApp");
|
|
6319
|
+
createCustomErrorClass("UserRefusedDeviceNameChange");
|
|
6320
|
+
createCustomErrorClass("UserRefusedAddress");
|
|
6321
|
+
createCustomErrorClass("UserRefusedFirmwareUpdate");
|
|
6322
|
+
createCustomErrorClass("UserRefusedAllowManager");
|
|
6323
|
+
createCustomErrorClass("UserRefusedOnDevice");
|
|
6324
|
+
createCustomErrorClass("PinNotSet");
|
|
6325
|
+
createCustomErrorClass("ExpertModeRequired");
|
|
6011
6326
|
const TransportOpenUserCancelled = createCustomErrorClass("TransportOpenUserCancelled");
|
|
6012
6327
|
const TransportInterfaceNotAvailable = createCustomErrorClass("TransportInterfaceNotAvailable");
|
|
6013
6328
|
const TransportRaceCondition = createCustomErrorClass("TransportRaceCondition");
|
|
6014
6329
|
const TransportWebUSBGestureRequired = createCustomErrorClass("TransportWebUSBGestureRequired");
|
|
6330
|
+
createCustomErrorClass("TransactionHasBeenValidatedError");
|
|
6331
|
+
createCustomErrorClass("TransportExchangeTimeoutError");
|
|
6332
|
+
createCustomErrorClass("DeviceShouldStayInApp");
|
|
6333
|
+
createCustomErrorClass("WebsocketConnectionError");
|
|
6334
|
+
createCustomErrorClass("WebsocketConnectionFailed");
|
|
6335
|
+
createCustomErrorClass("WrongDeviceForAccount");
|
|
6336
|
+
createCustomErrorClass("WrongDeviceForAccountPayout");
|
|
6337
|
+
createCustomErrorClass("MissingSwapPayloadParamaters");
|
|
6338
|
+
createCustomErrorClass("WrongDeviceForAccountRefund");
|
|
6339
|
+
createCustomErrorClass("WrongAppForCurrency");
|
|
6340
|
+
createCustomErrorClass("ETHAddressNonEIP");
|
|
6341
|
+
createCustomErrorClass("CantScanQRCode");
|
|
6342
|
+
createCustomErrorClass("FeeNotLoaded");
|
|
6343
|
+
createCustomErrorClass("FeeNotLoadedSwap");
|
|
6344
|
+
createCustomErrorClass("FeeRequired");
|
|
6345
|
+
createCustomErrorClass("FeeTooHigh");
|
|
6346
|
+
createCustomErrorClass("PendingOperation");
|
|
6347
|
+
createCustomErrorClass("SyncError");
|
|
6348
|
+
createCustomErrorClass("PairingFailed");
|
|
6349
|
+
createCustomErrorClass("PeerRemovedPairing");
|
|
6350
|
+
createCustomErrorClass("GenuineCheckFailed");
|
|
6351
|
+
createCustomErrorClass("LedgerAPI4xx");
|
|
6352
|
+
createCustomErrorClass("LedgerAPI5xx");
|
|
6353
|
+
createCustomErrorClass("FirmwareOrAppUpdateRequired");
|
|
6354
|
+
createCustomErrorClass("ReplacementTransactionUnderpriced");
|
|
6355
|
+
createCustomErrorClass("OpReturnSizeLimit");
|
|
6356
|
+
createCustomErrorClass("DustLimit");
|
|
6357
|
+
createCustomErrorClass("LanguageNotFound");
|
|
6358
|
+
createCustomErrorClass("NoDBPathGiven");
|
|
6359
|
+
createCustomErrorClass("DBWrongPassword");
|
|
6360
|
+
createCustomErrorClass("DBNotReset");
|
|
6361
|
+
createCustomErrorClass("SequenceNumberError");
|
|
6362
|
+
createCustomErrorClass("DisabledTransactionBroadcastError");
|
|
6015
6363
|
var HwTransportErrorType;
|
|
6016
6364
|
(function (HwTransportErrorType) {
|
|
6017
6365
|
HwTransportErrorType["Unknown"] = "Unknown";
|
|
@@ -6020,6 +6368,7 @@
|
|
|
6020
6368
|
HwTransportErrorType["BluetoothScanStartFailed"] = "BluetoothScanStartFailed";
|
|
6021
6369
|
})(HwTransportErrorType || (HwTransportErrorType = {}));
|
|
6022
6370
|
class TransportError extends Error {
|
|
6371
|
+
id;
|
|
6023
6372
|
constructor(message, id) {
|
|
6024
6373
|
const name = "TransportError";
|
|
6025
6374
|
super(message || name);
|
|
@@ -6029,6 +6378,7 @@
|
|
|
6029
6378
|
this.id = id;
|
|
6030
6379
|
}
|
|
6031
6380
|
}
|
|
6381
|
+
addCustomErrorDeserializer("TransportError", e => new TransportError(e.message, e.id));
|
|
6032
6382
|
const StatusCodes = {
|
|
6033
6383
|
ACCESS_CONDITION_NOT_FULFILLED: 0x9804,
|
|
6034
6384
|
ALGORITHM_NOT_SUPPORTED: 0x9484,
|
|
@@ -6105,6 +6455,8 @@
|
|
|
6105
6455
|
}
|
|
6106
6456
|
}
|
|
6107
6457
|
class TransportStatusError extends Error {
|
|
6458
|
+
statusCode;
|
|
6459
|
+
statusText;
|
|
6108
6460
|
constructor(statusCode, { canBeMappedToChildError = true } = {}) {
|
|
6109
6461
|
const statusText = Object.keys(StatusCodes).find(k => StatusCodes[k] === statusCode) || "UNKNOWN_ERROR";
|
|
6110
6462
|
const smsg = getAltStatusMessage(statusCode) || statusText;
|
|
@@ -6130,6 +6482,7 @@
|
|
|
6130
6482
|
Object.setPrototypeOf(this, LockedDeviceError.prototype);
|
|
6131
6483
|
}
|
|
6132
6484
|
}
|
|
6485
|
+
addCustomErrorDeserializer("TransportStatusError", e => new TransportStatusError(e.statusCode));
|
|
6133
6486
|
|
|
6134
6487
|
let id = 0;
|
|
6135
6488
|
const subscribers = [];
|
|
@@ -6141,8 +6494,6 @@
|
|
|
6141
6494
|
};
|
|
6142
6495
|
if (message)
|
|
6143
6496
|
obj.message = message;
|
|
6144
|
-
if (data)
|
|
6145
|
-
obj.data = data;
|
|
6146
6497
|
dispatch(obj);
|
|
6147
6498
|
};
|
|
6148
6499
|
const trace = ({ type, message, data, context, }) => {
|
|
@@ -6160,6 +6511,8 @@
|
|
|
6160
6511
|
dispatch(obj);
|
|
6161
6512
|
};
|
|
6162
6513
|
class LocalTracer {
|
|
6514
|
+
type;
|
|
6515
|
+
context;
|
|
6163
6516
|
constructor(type, context) {
|
|
6164
6517
|
this.type = type;
|
|
6165
6518
|
this.context = context;
|
|
@@ -6179,7 +6532,7 @@
|
|
|
6179
6532
|
this.context = context;
|
|
6180
6533
|
}
|
|
6181
6534
|
updateContext(contextToAdd) {
|
|
6182
|
-
this.context =
|
|
6535
|
+
this.context = { ...this.context, ...contextToAdd };
|
|
6183
6536
|
}
|
|
6184
6537
|
getType() {
|
|
6185
6538
|
return this.type;
|
|
@@ -6194,7 +6547,7 @@
|
|
|
6194
6547
|
return new LocalTracer(this.type, context);
|
|
6195
6548
|
}
|
|
6196
6549
|
withUpdatedContext(contextToAdd) {
|
|
6197
|
-
return new LocalTracer(this.type,
|
|
6550
|
+
return new LocalTracer(this.type, { ...this.context, ...contextToAdd });
|
|
6198
6551
|
}
|
|
6199
6552
|
}
|
|
6200
6553
|
const listen = (cb) => {
|
|
@@ -6221,41 +6574,19 @@
|
|
|
6221
6574
|
window.__ledgerLogsListen = listen;
|
|
6222
6575
|
}
|
|
6223
6576
|
|
|
6224
|
-
var __awaiter$3 = (global && global.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6225
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6226
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6227
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6228
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6229
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
6230
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
6231
|
-
});
|
|
6232
|
-
};
|
|
6233
6577
|
const DEFAULT_LOG_TYPE = "transport";
|
|
6234
6578
|
class Transport {
|
|
6579
|
+
exchangeTimeout = 30000;
|
|
6580
|
+
unresponsiveTimeout = 15000;
|
|
6581
|
+
deviceModel = null;
|
|
6582
|
+
tracer;
|
|
6235
6583
|
constructor({ context, logType } = {}) {
|
|
6236
|
-
this.
|
|
6237
|
-
this.unresponsiveTimeout = 15000;
|
|
6238
|
-
this.deviceModel = null;
|
|
6239
|
-
this._events = new EventEmitter();
|
|
6240
|
-
this.send = (cla_1, ins_1, p1_1, p2_1, ...args_1) => __awaiter$3(this, [cla_1, ins_1, p1_1, p2_1, ...args_1], void 0, function* (cla, ins, p1, p2, data = Buffer.alloc(0), statusList = [StatusCodes.OK], { abortTimeoutMs } = {}) {
|
|
6241
|
-
const tracer = this.tracer.withUpdatedContext({ function: "send" });
|
|
6242
|
-
if (data.length >= 256) {
|
|
6243
|
-
tracer.trace("data.length exceeded 256 bytes limit", { dataLength: data.length });
|
|
6244
|
-
throw new TransportError("data.length exceed 256 bytes limit. Got: " + data.length, "DataLengthTooBig");
|
|
6245
|
-
}
|
|
6246
|
-
tracer.trace("Starting an exchange", { abortTimeoutMs });
|
|
6247
|
-
const response = yield this.exchange(
|
|
6248
|
-
Buffer.concat([Buffer.from([cla, ins, p1, p2]), Buffer.from([data.length]), data]), { abortTimeoutMs });
|
|
6249
|
-
tracer.trace("Received response from exchange");
|
|
6250
|
-
const sw = response.readUInt16BE(response.length - 2);
|
|
6251
|
-
if (!statusList.some(s => s === sw)) {
|
|
6252
|
-
throw new TransportStatusError(sw);
|
|
6253
|
-
}
|
|
6254
|
-
return response;
|
|
6255
|
-
});
|
|
6256
|
-
this._appAPIlock = null;
|
|
6257
|
-
this.tracer = new LocalTracer(logType !== null && logType !== void 0 ? logType : DEFAULT_LOG_TYPE, context);
|
|
6584
|
+
this.tracer = new LocalTracer(logType ?? DEFAULT_LOG_TYPE, context);
|
|
6258
6585
|
}
|
|
6586
|
+
static isSupported;
|
|
6587
|
+
static list;
|
|
6588
|
+
static listen;
|
|
6589
|
+
static open;
|
|
6259
6590
|
exchange(_apdu, { abortTimeoutMs: _abortTimeoutMs } = {}) {
|
|
6260
6591
|
throw new Error("exchange not implemented");
|
|
6261
6592
|
}
|
|
@@ -6264,11 +6595,11 @@
|
|
|
6264
6595
|
const unsubscribe = () => {
|
|
6265
6596
|
unsubscribed = true;
|
|
6266
6597
|
};
|
|
6267
|
-
const main = () =>
|
|
6598
|
+
const main = async () => {
|
|
6268
6599
|
if (unsubscribed)
|
|
6269
6600
|
return;
|
|
6270
6601
|
for (const apdu of apdus) {
|
|
6271
|
-
const r =
|
|
6602
|
+
const r = await this.exchange(apdu);
|
|
6272
6603
|
if (unsubscribed)
|
|
6273
6604
|
return;
|
|
6274
6605
|
const status = r.readUInt16BE(r.length - 2);
|
|
@@ -6277,7 +6608,7 @@
|
|
|
6277
6608
|
}
|
|
6278
6609
|
observer.next(r);
|
|
6279
6610
|
}
|
|
6280
|
-
}
|
|
6611
|
+
};
|
|
6281
6612
|
main().then(() => !unsubscribed && observer.complete(), e => !unsubscribed && observer.error(e));
|
|
6282
6613
|
return { unsubscribe };
|
|
6283
6614
|
}
|
|
@@ -6285,6 +6616,7 @@
|
|
|
6285
6616
|
close() {
|
|
6286
6617
|
return Promise.resolve();
|
|
6287
6618
|
}
|
|
6619
|
+
_events = new EventEmitter();
|
|
6288
6620
|
on(eventName, cb) {
|
|
6289
6621
|
this._events.on(eventName, cb);
|
|
6290
6622
|
}
|
|
@@ -6303,6 +6635,20 @@
|
|
|
6303
6635
|
setExchangeUnresponsiveTimeout(unresponsiveTimeout) {
|
|
6304
6636
|
this.unresponsiveTimeout = unresponsiveTimeout;
|
|
6305
6637
|
}
|
|
6638
|
+
send = async (cla, ins, p1, p2, data = Buffer.alloc(0), statusList = [StatusCodes.OK], { abortTimeoutMs } = {}) => {
|
|
6639
|
+
const tracer = this.tracer.withUpdatedContext({ function: "send" });
|
|
6640
|
+
if (data.length >= 256) {
|
|
6641
|
+
tracer.trace("data.length exceeded 256 bytes limit", { dataLength: data.length });
|
|
6642
|
+
throw new TransportError("data.length exceed 256 bytes limit. Got: " + data.length, "DataLengthTooBig");
|
|
6643
|
+
}
|
|
6644
|
+
const response = await this.exchange(
|
|
6645
|
+
Buffer.concat([Buffer.from([cla, ins, p1, p2]), Buffer.from([data.length]), data]), { abortTimeoutMs });
|
|
6646
|
+
const sw = response.readUInt16BE(response.length - 2);
|
|
6647
|
+
if (!statusList.some(s => s === sw)) {
|
|
6648
|
+
throw new TransportStatusError(sw);
|
|
6649
|
+
}
|
|
6650
|
+
return response;
|
|
6651
|
+
};
|
|
6306
6652
|
static create(openTimeout = 3000, listenTimeout) {
|
|
6307
6653
|
return new Promise((resolve, reject) => {
|
|
6308
6654
|
let found = false;
|
|
@@ -6336,53 +6682,53 @@
|
|
|
6336
6682
|
: null;
|
|
6337
6683
|
});
|
|
6338
6684
|
}
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6685
|
+
exchangeBusyPromise;
|
|
6686
|
+
async exchangeAtomicImpl(f) {
|
|
6687
|
+
const tracer = this.tracer.withUpdatedContext({
|
|
6688
|
+
function: "exchangeAtomicImpl",
|
|
6689
|
+
unresponsiveTimeout: this.unresponsiveTimeout,
|
|
6690
|
+
});
|
|
6691
|
+
if (this.exchangeBusyPromise) {
|
|
6692
|
+
tracer.trace("Atomic exchange is already busy");
|
|
6693
|
+
throw new TransportRaceCondition("An action was already pending on the Ledger device. Please deny or reconnect.");
|
|
6694
|
+
}
|
|
6695
|
+
let resolveBusy;
|
|
6696
|
+
const busyPromise = new Promise(r => {
|
|
6697
|
+
resolveBusy = r;
|
|
6698
|
+
});
|
|
6699
|
+
this.exchangeBusyPromise = busyPromise;
|
|
6700
|
+
let unresponsiveReached = false;
|
|
6701
|
+
const timeout = setTimeout(() => {
|
|
6702
|
+
tracer.trace(`Timeout reached, emitting Transport event "unresponsive"`, {
|
|
6343
6703
|
unresponsiveTimeout: this.unresponsiveTimeout,
|
|
6344
6704
|
});
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
this.exchangeBusyPromise = busyPromise;
|
|
6354
|
-
let unresponsiveReached = false;
|
|
6355
|
-
const timeout = setTimeout(() => {
|
|
6356
|
-
tracer.trace(`Timeout reached, emitting Transport event "unresponsive"`, {
|
|
6357
|
-
unresponsiveTimeout: this.unresponsiveTimeout,
|
|
6358
|
-
});
|
|
6359
|
-
unresponsiveReached = true;
|
|
6360
|
-
this.emit("unresponsive");
|
|
6361
|
-
}, this.unresponsiveTimeout);
|
|
6362
|
-
try {
|
|
6363
|
-
const res = yield f();
|
|
6364
|
-
if (unresponsiveReached) {
|
|
6365
|
-
tracer.trace("Device was unresponsive, emitting responsive");
|
|
6366
|
-
this.emit("responsive");
|
|
6367
|
-
}
|
|
6368
|
-
return res;
|
|
6369
|
-
}
|
|
6370
|
-
finally {
|
|
6371
|
-
tracer.trace("Finalize, clearing busy guard");
|
|
6372
|
-
clearTimeout(timeout);
|
|
6373
|
-
if (resolveBusy)
|
|
6374
|
-
resolveBusy();
|
|
6375
|
-
this.exchangeBusyPromise = null;
|
|
6705
|
+
unresponsiveReached = true;
|
|
6706
|
+
this.emit("unresponsive");
|
|
6707
|
+
}, this.unresponsiveTimeout);
|
|
6708
|
+
try {
|
|
6709
|
+
const res = await f();
|
|
6710
|
+
if (unresponsiveReached) {
|
|
6711
|
+
tracer.trace("Device was unresponsive, emitting responsive");
|
|
6712
|
+
this.emit("responsive");
|
|
6376
6713
|
}
|
|
6377
|
-
|
|
6714
|
+
return res;
|
|
6715
|
+
}
|
|
6716
|
+
finally {
|
|
6717
|
+
tracer.trace("Finalize, clearing busy guard");
|
|
6718
|
+
clearTimeout(timeout);
|
|
6719
|
+
if (resolveBusy)
|
|
6720
|
+
resolveBusy();
|
|
6721
|
+
this.exchangeBusyPromise = null;
|
|
6722
|
+
}
|
|
6378
6723
|
}
|
|
6379
6724
|
decorateAppAPIMethods(self, methods, scrambleKey) {
|
|
6380
6725
|
for (const methodName of methods) {
|
|
6381
6726
|
self[methodName] = this.decorateAppAPIMethod(methodName, self[methodName], self, scrambleKey);
|
|
6382
6727
|
}
|
|
6383
6728
|
}
|
|
6729
|
+
_appAPIlock = null;
|
|
6384
6730
|
decorateAppAPIMethod(methodName, f, ctx, scrambleKey) {
|
|
6385
|
-
return (...args) =>
|
|
6731
|
+
return async (...args) => {
|
|
6386
6732
|
const { _appAPIlock } = this;
|
|
6387
6733
|
if (_appAPIlock) {
|
|
6388
6734
|
return Promise.reject(new TransportError("Ledger Device is busy (lock " + _appAPIlock + ")", "TransportLocked"));
|
|
@@ -6390,12 +6736,12 @@
|
|
|
6390
6736
|
try {
|
|
6391
6737
|
this._appAPIlock = methodName;
|
|
6392
6738
|
this.setScrambleKey(scrambleKey);
|
|
6393
|
-
return
|
|
6739
|
+
return await f.apply(ctx, args);
|
|
6394
6740
|
}
|
|
6395
6741
|
finally {
|
|
6396
6742
|
this._appAPIlock = null;
|
|
6397
6743
|
}
|
|
6398
|
-
}
|
|
6744
|
+
};
|
|
6399
6745
|
}
|
|
6400
6746
|
setTraceContext(context) {
|
|
6401
6747
|
this.tracer = this.tracer.withContext(context);
|
|
@@ -6406,9 +6752,9 @@
|
|
|
6406
6752
|
getTraceContext() {
|
|
6407
6753
|
return this.tracer.getContext();
|
|
6408
6754
|
}
|
|
6755
|
+
static ErrorMessage_ListenTimeout = "No Ledger device found (timeout)";
|
|
6756
|
+
static ErrorMessage_NoDeviceFound = "No Ledger device found";
|
|
6409
6757
|
}
|
|
6410
|
-
Transport.ErrorMessage_ListenTimeout = "No Ledger device found (timeout)";
|
|
6411
|
-
Transport.ErrorMessage_NoDeviceFound = "No Ledger device found";
|
|
6412
6758
|
|
|
6413
6759
|
const Tag = 0x05;
|
|
6414
6760
|
function asUInt16BE(value) {
|
|
@@ -6512,18 +6858,19 @@
|
|
|
6512
6858
|
var debug_1 = debug$1;
|
|
6513
6859
|
getDefaultExportFromCjs(debug_1);
|
|
6514
6860
|
|
|
6515
|
-
(function (module, exports) {
|
|
6861
|
+
(function (module, exports$1) {
|
|
6516
6862
|
const {
|
|
6517
6863
|
MAX_SAFE_COMPONENT_LENGTH,
|
|
6518
6864
|
MAX_SAFE_BUILD_LENGTH,
|
|
6519
6865
|
MAX_LENGTH,
|
|
6520
6866
|
} = constants$1;
|
|
6521
6867
|
const debug = debug_1;
|
|
6522
|
-
exports = module.exports = {};
|
|
6523
|
-
const re = exports.re = [];
|
|
6524
|
-
const safeRe = exports.safeRe = [];
|
|
6525
|
-
const src = exports.src = [];
|
|
6526
|
-
const
|
|
6868
|
+
exports$1 = module.exports = {};
|
|
6869
|
+
const re = exports$1.re = [];
|
|
6870
|
+
const safeRe = exports$1.safeRe = [];
|
|
6871
|
+
const src = exports$1.src = [];
|
|
6872
|
+
const safeSrc = exports$1.safeSrc = [];
|
|
6873
|
+
const t = exports$1.t = {};
|
|
6527
6874
|
let R = 0;
|
|
6528
6875
|
const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
|
|
6529
6876
|
const safeRegexReplacements = [
|
|
@@ -6545,6 +6892,7 @@
|
|
|
6545
6892
|
debug(name, index, value);
|
|
6546
6893
|
t[name] = index;
|
|
6547
6894
|
src[index] = value;
|
|
6895
|
+
safeSrc[index] = safe;
|
|
6548
6896
|
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
|
6549
6897
|
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
|
|
6550
6898
|
};
|
|
@@ -6557,10 +6905,10 @@
|
|
|
6557
6905
|
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
6558
6906
|
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
6559
6907
|
`(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
6560
|
-
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.
|
|
6561
|
-
}|${src[t.
|
|
6562
|
-
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.
|
|
6563
|
-
}|${src[t.
|
|
6908
|
+
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
|
|
6909
|
+
}|${src[t.NUMERICIDENTIFIER]})`);
|
|
6910
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]
|
|
6911
|
+
}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
6564
6912
|
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
|
|
6565
6913
|
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
6566
6914
|
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
|
@@ -6593,27 +6941,32 @@
|
|
|
6593
6941
|
`)?)?`);
|
|
6594
6942
|
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
6595
6943
|
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
6596
|
-
createToken('
|
|
6944
|
+
createToken('COERCEPLAIN', `${'(^|[^\\d])' +
|
|
6597
6945
|
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
|
6598
6946
|
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
|
6599
|
-
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`
|
|
6947
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
6948
|
+
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
6949
|
+
createToken('COERCEFULL', src[t.COERCEPLAIN] +
|
|
6950
|
+
`(?:${src[t.PRERELEASE]})?` +
|
|
6951
|
+
`(?:${src[t.BUILD]})?` +
|
|
6600
6952
|
`(?:$|[^\\d])`);
|
|
6601
6953
|
createToken('COERCERTL', src[t.COERCE], true);
|
|
6954
|
+
createToken('COERCERTLFULL', src[t.COERCEFULL], true);
|
|
6602
6955
|
createToken('LONETILDE', '(?:~>?)');
|
|
6603
6956
|
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
6604
|
-
exports.tildeTrimReplace = '$1~';
|
|
6957
|
+
exports$1.tildeTrimReplace = '$1~';
|
|
6605
6958
|
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
6606
6959
|
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
6607
6960
|
createToken('LONECARET', '(?:\\^)');
|
|
6608
6961
|
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
6609
|
-
exports.caretTrimReplace = '$1^';
|
|
6962
|
+
exports$1.caretTrimReplace = '$1^';
|
|
6610
6963
|
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
6611
6964
|
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
6612
6965
|
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
6613
6966
|
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
6614
6967
|
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
|
6615
6968
|
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
6616
|
-
exports.comparatorTrimReplace = '$1$2$3';
|
|
6969
|
+
exports$1.comparatorTrimReplace = '$1$2$3';
|
|
6617
6970
|
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
|
6618
6971
|
`\\s+-\\s+` +
|
|
6619
6972
|
`(${src[t.XRANGEPLAIN]})` +
|
|
@@ -6645,6 +6998,9 @@
|
|
|
6645
6998
|
|
|
6646
6999
|
const numeric = /^[0-9]+$/;
|
|
6647
7000
|
const compareIdentifiers$1 = (a, b) => {
|
|
7001
|
+
if (typeof a === 'number' && typeof b === 'number') {
|
|
7002
|
+
return a === b ? 0 : a < b ? -1 : 1
|
|
7003
|
+
}
|
|
6648
7004
|
const anum = numeric.test(a);
|
|
6649
7005
|
const bnum = numeric.test(b);
|
|
6650
7006
|
if (anum && bnum) {
|
|
@@ -6674,7 +7030,7 @@
|
|
|
6674
7030
|
options = parseOptions(options);
|
|
6675
7031
|
if (version instanceof SemVer) {
|
|
6676
7032
|
if (version.loose === !!options.loose &&
|
|
6677
|
-
|
|
7033
|
+
version.includePrerelease === !!options.includePrerelease) {
|
|
6678
7034
|
return version
|
|
6679
7035
|
} else {
|
|
6680
7036
|
version = version.version;
|
|
@@ -6751,19 +7107,33 @@
|
|
|
6751
7107
|
if (!(other instanceof SemVer)) {
|
|
6752
7108
|
other = new SemVer(other, this.options);
|
|
6753
7109
|
}
|
|
6754
|
-
|
|
6755
|
-
compareIdentifiers(this.major, other.major) ||
|
|
6756
|
-
compareIdentifiers(this.minor, other.minor) ||
|
|
6757
|
-
compareIdentifiers(this.patch, other.patch)
|
|
6758
|
-
)
|
|
6759
|
-
}
|
|
6760
|
-
comparePre (other) {
|
|
6761
|
-
if (!(other instanceof SemVer)) {
|
|
6762
|
-
other = new SemVer(other, this.options);
|
|
6763
|
-
}
|
|
6764
|
-
if (this.prerelease.length && !other.prerelease.length) {
|
|
7110
|
+
if (this.major < other.major) {
|
|
6765
7111
|
return -1
|
|
6766
|
-
}
|
|
7112
|
+
}
|
|
7113
|
+
if (this.major > other.major) {
|
|
7114
|
+
return 1
|
|
7115
|
+
}
|
|
7116
|
+
if (this.minor < other.minor) {
|
|
7117
|
+
return -1
|
|
7118
|
+
}
|
|
7119
|
+
if (this.minor > other.minor) {
|
|
7120
|
+
return 1
|
|
7121
|
+
}
|
|
7122
|
+
if (this.patch < other.patch) {
|
|
7123
|
+
return -1
|
|
7124
|
+
}
|
|
7125
|
+
if (this.patch > other.patch) {
|
|
7126
|
+
return 1
|
|
7127
|
+
}
|
|
7128
|
+
return 0
|
|
7129
|
+
}
|
|
7130
|
+
comparePre (other) {
|
|
7131
|
+
if (!(other instanceof SemVer)) {
|
|
7132
|
+
other = new SemVer(other, this.options);
|
|
7133
|
+
}
|
|
7134
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
7135
|
+
return -1
|
|
7136
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
6767
7137
|
return 1
|
|
6768
7138
|
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
6769
7139
|
return 0
|
|
@@ -6794,7 +7164,7 @@
|
|
|
6794
7164
|
do {
|
|
6795
7165
|
const a = this.build[i];
|
|
6796
7166
|
const b = other.build[i];
|
|
6797
|
-
debug('
|
|
7167
|
+
debug('build compare', i, a, b);
|
|
6798
7168
|
if (a === undefined && b === undefined) {
|
|
6799
7169
|
return 0
|
|
6800
7170
|
} else if (b === undefined) {
|
|
@@ -6809,6 +7179,17 @@
|
|
|
6809
7179
|
} while (++i)
|
|
6810
7180
|
}
|
|
6811
7181
|
inc (release, identifier, identifierBase) {
|
|
7182
|
+
if (release.startsWith('pre')) {
|
|
7183
|
+
if (!identifier && identifierBase === false) {
|
|
7184
|
+
throw new Error('invalid increment argument: identifier is empty')
|
|
7185
|
+
}
|
|
7186
|
+
if (identifier) {
|
|
7187
|
+
const match = `-${identifier}`.match(this.options.loose ? re$1[t$1.PRERELEASELOOSE] : re$1[t$1.PRERELEASE]);
|
|
7188
|
+
if (!match || match[1] !== identifier) {
|
|
7189
|
+
throw new Error(`invalid identifier: ${identifier}`)
|
|
7190
|
+
}
|
|
7191
|
+
}
|
|
7192
|
+
}
|
|
6812
7193
|
switch (release) {
|
|
6813
7194
|
case 'premajor':
|
|
6814
7195
|
this.prerelease.length = 0;
|
|
@@ -6834,6 +7215,12 @@
|
|
|
6834
7215
|
}
|
|
6835
7216
|
this.inc('pre', identifier, identifierBase);
|
|
6836
7217
|
break
|
|
7218
|
+
case 'release':
|
|
7219
|
+
if (this.prerelease.length === 0) {
|
|
7220
|
+
throw new Error(`version ${this.raw} is not a prerelease`)
|
|
7221
|
+
}
|
|
7222
|
+
this.prerelease.length = 0;
|
|
7223
|
+
break
|
|
6837
7224
|
case 'major':
|
|
6838
7225
|
if (
|
|
6839
7226
|
this.minor !== 0 ||
|
|
@@ -6861,9 +7248,6 @@
|
|
|
6861
7248
|
break
|
|
6862
7249
|
case 'pre': {
|
|
6863
7250
|
const base = Number(identifierBase) ? 1 : 0;
|
|
6864
|
-
if (!identifier && identifierBase === false) {
|
|
6865
|
-
throw new Error('invalid increment argument: identifier is empty')
|
|
6866
|
-
}
|
|
6867
7251
|
if (this.prerelease.length === 0) {
|
|
6868
7252
|
this.prerelease = [base];
|
|
6869
7253
|
} else {
|
|
@@ -6978,13 +7362,12 @@
|
|
|
6978
7362
|
if (!lowVersion.patch && !lowVersion.minor) {
|
|
6979
7363
|
return 'major'
|
|
6980
7364
|
}
|
|
6981
|
-
if (highVersion
|
|
7365
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
7366
|
+
if (lowVersion.minor && !lowVersion.patch) {
|
|
7367
|
+
return 'minor'
|
|
7368
|
+
}
|
|
6982
7369
|
return 'patch'
|
|
6983
7370
|
}
|
|
6984
|
-
if (highVersion.minor) {
|
|
6985
|
-
return 'minor'
|
|
6986
|
-
}
|
|
6987
|
-
return 'major'
|
|
6988
7371
|
}
|
|
6989
7372
|
const prefix = highHasPre ? 'pre' : '';
|
|
6990
7373
|
if (v1.major !== v2.major) {
|
|
@@ -7150,679 +7533,71 @@
|
|
|
7150
7533
|
options = options || {};
|
|
7151
7534
|
let match = null;
|
|
7152
7535
|
if (!options.rtl) {
|
|
7153
|
-
match = version.match(re[t.COERCE]);
|
|
7536
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
7154
7537
|
} else {
|
|
7538
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
7155
7539
|
let next;
|
|
7156
|
-
while ((next =
|
|
7540
|
+
while ((next = coerceRtlRegex.exec(version)) &&
|
|
7157
7541
|
(!match || match.index + match[0].length !== version.length)
|
|
7158
7542
|
) {
|
|
7159
7543
|
if (!match ||
|
|
7160
7544
|
next.index + next[0].length !== match.index + match[0].length) {
|
|
7161
7545
|
match = next;
|
|
7162
7546
|
}
|
|
7163
|
-
|
|
7547
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
7164
7548
|
}
|
|
7165
|
-
|
|
7549
|
+
coerceRtlRegex.lastIndex = -1;
|
|
7166
7550
|
}
|
|
7167
7551
|
if (match === null) {
|
|
7168
7552
|
return null
|
|
7169
7553
|
}
|
|
7170
|
-
|
|
7554
|
+
const major = match[2];
|
|
7555
|
+
const minor = match[3] || '0';
|
|
7556
|
+
const patch = match[4] || '0';
|
|
7557
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '';
|
|
7558
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : '';
|
|
7559
|
+
return parse$1(`${major}.${minor}.${patch}${prerelease}${build}`, options)
|
|
7171
7560
|
};
|
|
7172
7561
|
var coerce_1 = coerce$1;
|
|
7173
7562
|
getDefaultExportFromCjs(coerce_1);
|
|
7174
7563
|
|
|
7175
|
-
var
|
|
7176
|
-
var
|
|
7177
|
-
function
|
|
7178
|
-
if (
|
|
7179
|
-
|
|
7180
|
-
iterator = function (Yallist) {
|
|
7181
|
-
Yallist.prototype[Symbol.iterator] = function* () {
|
|
7182
|
-
for (let walker = this.head; walker; walker = walker.next) {
|
|
7183
|
-
yield walker.value;
|
|
7184
|
-
}
|
|
7185
|
-
};
|
|
7186
|
-
};
|
|
7187
|
-
return iterator;
|
|
7188
|
-
}
|
|
7189
|
-
|
|
7190
|
-
var yallist;
|
|
7191
|
-
var hasRequiredYallist;
|
|
7192
|
-
function requireYallist () {
|
|
7193
|
-
if (hasRequiredYallist) return yallist;
|
|
7194
|
-
hasRequiredYallist = 1;
|
|
7195
|
-
yallist = Yallist;
|
|
7196
|
-
Yallist.Node = Node;
|
|
7197
|
-
Yallist.create = Yallist;
|
|
7198
|
-
function Yallist (list) {
|
|
7199
|
-
var self = this;
|
|
7200
|
-
if (!(self instanceof Yallist)) {
|
|
7201
|
-
self = new Yallist();
|
|
7202
|
-
}
|
|
7203
|
-
self.tail = null;
|
|
7204
|
-
self.head = null;
|
|
7205
|
-
self.length = 0;
|
|
7206
|
-
if (list && typeof list.forEach === 'function') {
|
|
7207
|
-
list.forEach(function (item) {
|
|
7208
|
-
self.push(item);
|
|
7209
|
-
});
|
|
7210
|
-
} else if (arguments.length > 0) {
|
|
7211
|
-
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
7212
|
-
self.push(arguments[i]);
|
|
7213
|
-
}
|
|
7214
|
-
}
|
|
7215
|
-
return self
|
|
7216
|
-
}
|
|
7217
|
-
Yallist.prototype.removeNode = function (node) {
|
|
7218
|
-
if (node.list !== this) {
|
|
7219
|
-
throw new Error('removing node which does not belong to this list')
|
|
7220
|
-
}
|
|
7221
|
-
var next = node.next;
|
|
7222
|
-
var prev = node.prev;
|
|
7223
|
-
if (next) {
|
|
7224
|
-
next.prev = prev;
|
|
7225
|
-
}
|
|
7226
|
-
if (prev) {
|
|
7227
|
-
prev.next = next;
|
|
7228
|
-
}
|
|
7229
|
-
if (node === this.head) {
|
|
7230
|
-
this.head = next;
|
|
7231
|
-
}
|
|
7232
|
-
if (node === this.tail) {
|
|
7233
|
-
this.tail = prev;
|
|
7234
|
-
}
|
|
7235
|
-
node.list.length--;
|
|
7236
|
-
node.next = null;
|
|
7237
|
-
node.prev = null;
|
|
7238
|
-
node.list = null;
|
|
7239
|
-
return next
|
|
7240
|
-
};
|
|
7241
|
-
Yallist.prototype.unshiftNode = function (node) {
|
|
7242
|
-
if (node === this.head) {
|
|
7243
|
-
return
|
|
7244
|
-
}
|
|
7245
|
-
if (node.list) {
|
|
7246
|
-
node.list.removeNode(node);
|
|
7247
|
-
}
|
|
7248
|
-
var head = this.head;
|
|
7249
|
-
node.list = this;
|
|
7250
|
-
node.next = head;
|
|
7251
|
-
if (head) {
|
|
7252
|
-
head.prev = node;
|
|
7253
|
-
}
|
|
7254
|
-
this.head = node;
|
|
7255
|
-
if (!this.tail) {
|
|
7256
|
-
this.tail = node;
|
|
7257
|
-
}
|
|
7258
|
-
this.length++;
|
|
7259
|
-
};
|
|
7260
|
-
Yallist.prototype.pushNode = function (node) {
|
|
7261
|
-
if (node === this.tail) {
|
|
7262
|
-
return
|
|
7263
|
-
}
|
|
7264
|
-
if (node.list) {
|
|
7265
|
-
node.list.removeNode(node);
|
|
7266
|
-
}
|
|
7267
|
-
var tail = this.tail;
|
|
7268
|
-
node.list = this;
|
|
7269
|
-
node.prev = tail;
|
|
7270
|
-
if (tail) {
|
|
7271
|
-
tail.next = node;
|
|
7272
|
-
}
|
|
7273
|
-
this.tail = node;
|
|
7274
|
-
if (!this.head) {
|
|
7275
|
-
this.head = node;
|
|
7276
|
-
}
|
|
7277
|
-
this.length++;
|
|
7278
|
-
};
|
|
7279
|
-
Yallist.prototype.push = function () {
|
|
7280
|
-
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
7281
|
-
push(this, arguments[i]);
|
|
7282
|
-
}
|
|
7283
|
-
return this.length
|
|
7284
|
-
};
|
|
7285
|
-
Yallist.prototype.unshift = function () {
|
|
7286
|
-
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
7287
|
-
unshift(this, arguments[i]);
|
|
7288
|
-
}
|
|
7289
|
-
return this.length
|
|
7290
|
-
};
|
|
7291
|
-
Yallist.prototype.pop = function () {
|
|
7292
|
-
if (!this.tail) {
|
|
7293
|
-
return undefined
|
|
7294
|
-
}
|
|
7295
|
-
var res = this.tail.value;
|
|
7296
|
-
this.tail = this.tail.prev;
|
|
7297
|
-
if (this.tail) {
|
|
7298
|
-
this.tail.next = null;
|
|
7299
|
-
} else {
|
|
7300
|
-
this.head = null;
|
|
7301
|
-
}
|
|
7302
|
-
this.length--;
|
|
7303
|
-
return res
|
|
7304
|
-
};
|
|
7305
|
-
Yallist.prototype.shift = function () {
|
|
7306
|
-
if (!this.head) {
|
|
7307
|
-
return undefined
|
|
7308
|
-
}
|
|
7309
|
-
var res = this.head.value;
|
|
7310
|
-
this.head = this.head.next;
|
|
7311
|
-
if (this.head) {
|
|
7312
|
-
this.head.prev = null;
|
|
7313
|
-
} else {
|
|
7314
|
-
this.tail = null;
|
|
7315
|
-
}
|
|
7316
|
-
this.length--;
|
|
7317
|
-
return res
|
|
7318
|
-
};
|
|
7319
|
-
Yallist.prototype.forEach = function (fn, thisp) {
|
|
7320
|
-
thisp = thisp || this;
|
|
7321
|
-
for (var walker = this.head, i = 0; walker !== null; i++) {
|
|
7322
|
-
fn.call(thisp, walker.value, i, this);
|
|
7323
|
-
walker = walker.next;
|
|
7324
|
-
}
|
|
7325
|
-
};
|
|
7326
|
-
Yallist.prototype.forEachReverse = function (fn, thisp) {
|
|
7327
|
-
thisp = thisp || this;
|
|
7328
|
-
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
|
7329
|
-
fn.call(thisp, walker.value, i, this);
|
|
7330
|
-
walker = walker.prev;
|
|
7331
|
-
}
|
|
7332
|
-
};
|
|
7333
|
-
Yallist.prototype.get = function (n) {
|
|
7334
|
-
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
|
7335
|
-
walker = walker.next;
|
|
7336
|
-
}
|
|
7337
|
-
if (i === n && walker !== null) {
|
|
7338
|
-
return walker.value
|
|
7339
|
-
}
|
|
7340
|
-
};
|
|
7341
|
-
Yallist.prototype.getReverse = function (n) {
|
|
7342
|
-
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
|
7343
|
-
walker = walker.prev;
|
|
7344
|
-
}
|
|
7345
|
-
if (i === n && walker !== null) {
|
|
7346
|
-
return walker.value
|
|
7347
|
-
}
|
|
7348
|
-
};
|
|
7349
|
-
Yallist.prototype.map = function (fn, thisp) {
|
|
7350
|
-
thisp = thisp || this;
|
|
7351
|
-
var res = new Yallist();
|
|
7352
|
-
for (var walker = this.head; walker !== null;) {
|
|
7353
|
-
res.push(fn.call(thisp, walker.value, this));
|
|
7354
|
-
walker = walker.next;
|
|
7355
|
-
}
|
|
7356
|
-
return res
|
|
7357
|
-
};
|
|
7358
|
-
Yallist.prototype.mapReverse = function (fn, thisp) {
|
|
7359
|
-
thisp = thisp || this;
|
|
7360
|
-
var res = new Yallist();
|
|
7361
|
-
for (var walker = this.tail; walker !== null;) {
|
|
7362
|
-
res.push(fn.call(thisp, walker.value, this));
|
|
7363
|
-
walker = walker.prev;
|
|
7364
|
-
}
|
|
7365
|
-
return res
|
|
7366
|
-
};
|
|
7367
|
-
Yallist.prototype.reduce = function (fn, initial) {
|
|
7368
|
-
var acc;
|
|
7369
|
-
var walker = this.head;
|
|
7370
|
-
if (arguments.length > 1) {
|
|
7371
|
-
acc = initial;
|
|
7372
|
-
} else if (this.head) {
|
|
7373
|
-
walker = this.head.next;
|
|
7374
|
-
acc = this.head.value;
|
|
7375
|
-
} else {
|
|
7376
|
-
throw new TypeError('Reduce of empty list with no initial value')
|
|
7377
|
-
}
|
|
7378
|
-
for (var i = 0; walker !== null; i++) {
|
|
7379
|
-
acc = fn(acc, walker.value, i);
|
|
7380
|
-
walker = walker.next;
|
|
7381
|
-
}
|
|
7382
|
-
return acc
|
|
7383
|
-
};
|
|
7384
|
-
Yallist.prototype.reduceReverse = function (fn, initial) {
|
|
7385
|
-
var acc;
|
|
7386
|
-
var walker = this.tail;
|
|
7387
|
-
if (arguments.length > 1) {
|
|
7388
|
-
acc = initial;
|
|
7389
|
-
} else if (this.tail) {
|
|
7390
|
-
walker = this.tail.prev;
|
|
7391
|
-
acc = this.tail.value;
|
|
7392
|
-
} else {
|
|
7393
|
-
throw new TypeError('Reduce of empty list with no initial value')
|
|
7394
|
-
}
|
|
7395
|
-
for (var i = this.length - 1; walker !== null; i--) {
|
|
7396
|
-
acc = fn(acc, walker.value, i);
|
|
7397
|
-
walker = walker.prev;
|
|
7398
|
-
}
|
|
7399
|
-
return acc
|
|
7400
|
-
};
|
|
7401
|
-
Yallist.prototype.toArray = function () {
|
|
7402
|
-
var arr = new Array(this.length);
|
|
7403
|
-
for (var i = 0, walker = this.head; walker !== null; i++) {
|
|
7404
|
-
arr[i] = walker.value;
|
|
7405
|
-
walker = walker.next;
|
|
7406
|
-
}
|
|
7407
|
-
return arr
|
|
7408
|
-
};
|
|
7409
|
-
Yallist.prototype.toArrayReverse = function () {
|
|
7410
|
-
var arr = new Array(this.length);
|
|
7411
|
-
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
|
7412
|
-
arr[i] = walker.value;
|
|
7413
|
-
walker = walker.prev;
|
|
7414
|
-
}
|
|
7415
|
-
return arr
|
|
7416
|
-
};
|
|
7417
|
-
Yallist.prototype.slice = function (from, to) {
|
|
7418
|
-
to = to || this.length;
|
|
7419
|
-
if (to < 0) {
|
|
7420
|
-
to += this.length;
|
|
7421
|
-
}
|
|
7422
|
-
from = from || 0;
|
|
7423
|
-
if (from < 0) {
|
|
7424
|
-
from += this.length;
|
|
7425
|
-
}
|
|
7426
|
-
var ret = new Yallist();
|
|
7427
|
-
if (to < from || to < 0) {
|
|
7428
|
-
return ret
|
|
7429
|
-
}
|
|
7430
|
-
if (from < 0) {
|
|
7431
|
-
from = 0;
|
|
7432
|
-
}
|
|
7433
|
-
if (to > this.length) {
|
|
7434
|
-
to = this.length;
|
|
7435
|
-
}
|
|
7436
|
-
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
|
7437
|
-
walker = walker.next;
|
|
7438
|
-
}
|
|
7439
|
-
for (; walker !== null && i < to; i++, walker = walker.next) {
|
|
7440
|
-
ret.push(walker.value);
|
|
7441
|
-
}
|
|
7442
|
-
return ret
|
|
7443
|
-
};
|
|
7444
|
-
Yallist.prototype.sliceReverse = function (from, to) {
|
|
7445
|
-
to = to || this.length;
|
|
7446
|
-
if (to < 0) {
|
|
7447
|
-
to += this.length;
|
|
7448
|
-
}
|
|
7449
|
-
from = from || 0;
|
|
7450
|
-
if (from < 0) {
|
|
7451
|
-
from += this.length;
|
|
7452
|
-
}
|
|
7453
|
-
var ret = new Yallist();
|
|
7454
|
-
if (to < from || to < 0) {
|
|
7455
|
-
return ret
|
|
7456
|
-
}
|
|
7457
|
-
if (from < 0) {
|
|
7458
|
-
from = 0;
|
|
7459
|
-
}
|
|
7460
|
-
if (to > this.length) {
|
|
7461
|
-
to = this.length;
|
|
7462
|
-
}
|
|
7463
|
-
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
|
7464
|
-
walker = walker.prev;
|
|
7465
|
-
}
|
|
7466
|
-
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
|
7467
|
-
ret.push(walker.value);
|
|
7468
|
-
}
|
|
7469
|
-
return ret
|
|
7470
|
-
};
|
|
7471
|
-
Yallist.prototype.splice = function (start, deleteCount, ...nodes) {
|
|
7472
|
-
if (start > this.length) {
|
|
7473
|
-
start = this.length - 1;
|
|
7474
|
-
}
|
|
7475
|
-
if (start < 0) {
|
|
7476
|
-
start = this.length + start;
|
|
7477
|
-
}
|
|
7478
|
-
for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
|
|
7479
|
-
walker = walker.next;
|
|
7480
|
-
}
|
|
7481
|
-
var ret = [];
|
|
7482
|
-
for (var i = 0; walker && i < deleteCount; i++) {
|
|
7483
|
-
ret.push(walker.value);
|
|
7484
|
-
walker = this.removeNode(walker);
|
|
7485
|
-
}
|
|
7486
|
-
if (walker === null) {
|
|
7487
|
-
walker = this.tail;
|
|
7488
|
-
}
|
|
7489
|
-
if (walker !== this.head && walker !== this.tail) {
|
|
7490
|
-
walker = walker.prev;
|
|
7491
|
-
}
|
|
7492
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
7493
|
-
walker = insert(this, walker, nodes[i]);
|
|
7494
|
-
}
|
|
7495
|
-
return ret;
|
|
7496
|
-
};
|
|
7497
|
-
Yallist.prototype.reverse = function () {
|
|
7498
|
-
var head = this.head;
|
|
7499
|
-
var tail = this.tail;
|
|
7500
|
-
for (var walker = head; walker !== null; walker = walker.prev) {
|
|
7501
|
-
var p = walker.prev;
|
|
7502
|
-
walker.prev = walker.next;
|
|
7503
|
-
walker.next = p;
|
|
7504
|
-
}
|
|
7505
|
-
this.head = tail;
|
|
7506
|
-
this.tail = head;
|
|
7507
|
-
return this
|
|
7508
|
-
};
|
|
7509
|
-
function insert (self, node, value) {
|
|
7510
|
-
var inserted = node === self.head ?
|
|
7511
|
-
new Node(value, null, node, self) :
|
|
7512
|
-
new Node(value, node, node.next, self);
|
|
7513
|
-
if (inserted.next === null) {
|
|
7514
|
-
self.tail = inserted;
|
|
7515
|
-
}
|
|
7516
|
-
if (inserted.prev === null) {
|
|
7517
|
-
self.head = inserted;
|
|
7518
|
-
}
|
|
7519
|
-
self.length++;
|
|
7520
|
-
return inserted
|
|
7521
|
-
}
|
|
7522
|
-
function push (self, item) {
|
|
7523
|
-
self.tail = new Node(item, self.tail, null, self);
|
|
7524
|
-
if (!self.head) {
|
|
7525
|
-
self.head = self.tail;
|
|
7526
|
-
}
|
|
7527
|
-
self.length++;
|
|
7528
|
-
}
|
|
7529
|
-
function unshift (self, item) {
|
|
7530
|
-
self.head = new Node(item, null, self.head, self);
|
|
7531
|
-
if (!self.tail) {
|
|
7532
|
-
self.tail = self.head;
|
|
7533
|
-
}
|
|
7534
|
-
self.length++;
|
|
7535
|
-
}
|
|
7536
|
-
function Node (value, prev, next, list) {
|
|
7537
|
-
if (!(this instanceof Node)) {
|
|
7538
|
-
return new Node(value, prev, next, list)
|
|
7539
|
-
}
|
|
7540
|
-
this.list = list;
|
|
7541
|
-
this.value = value;
|
|
7542
|
-
if (prev) {
|
|
7543
|
-
prev.next = this;
|
|
7544
|
-
this.prev = prev;
|
|
7545
|
-
} else {
|
|
7546
|
-
this.prev = null;
|
|
7547
|
-
}
|
|
7548
|
-
if (next) {
|
|
7549
|
-
next.prev = this;
|
|
7550
|
-
this.next = next;
|
|
7551
|
-
} else {
|
|
7552
|
-
this.next = null;
|
|
7553
|
-
}
|
|
7554
|
-
}
|
|
7555
|
-
try {
|
|
7556
|
-
requireIterator()(Yallist);
|
|
7557
|
-
} catch (er) {}
|
|
7558
|
-
return yallist;
|
|
7559
|
-
}
|
|
7560
|
-
|
|
7561
|
-
var lruCache;
|
|
7562
|
-
var hasRequiredLruCache;
|
|
7563
|
-
function requireLruCache () {
|
|
7564
|
-
if (hasRequiredLruCache) return lruCache;
|
|
7565
|
-
hasRequiredLruCache = 1;
|
|
7566
|
-
const Yallist = requireYallist();
|
|
7567
|
-
const MAX = Symbol('max');
|
|
7568
|
-
const LENGTH = Symbol('length');
|
|
7569
|
-
const LENGTH_CALCULATOR = Symbol('lengthCalculator');
|
|
7570
|
-
const ALLOW_STALE = Symbol('allowStale');
|
|
7571
|
-
const MAX_AGE = Symbol('maxAge');
|
|
7572
|
-
const DISPOSE = Symbol('dispose');
|
|
7573
|
-
const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
|
|
7574
|
-
const LRU_LIST = Symbol('lruList');
|
|
7575
|
-
const CACHE = Symbol('cache');
|
|
7576
|
-
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
|
|
7577
|
-
const naiveLength = () => 1;
|
|
7564
|
+
var lrucache;
|
|
7565
|
+
var hasRequiredLrucache;
|
|
7566
|
+
function requireLrucache () {
|
|
7567
|
+
if (hasRequiredLrucache) return lrucache;
|
|
7568
|
+
hasRequiredLrucache = 1;
|
|
7578
7569
|
class LRUCache {
|
|
7579
|
-
constructor (
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
if (!options)
|
|
7583
|
-
options = {};
|
|
7584
|
-
if (options.max && (typeof options.max !== 'number' || options.max < 0))
|
|
7585
|
-
throw new TypeError('max must be a non-negative number')
|
|
7586
|
-
this[MAX] = options.max || Infinity;
|
|
7587
|
-
const lc = options.length || naiveLength;
|
|
7588
|
-
this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
|
|
7589
|
-
this[ALLOW_STALE] = options.stale || false;
|
|
7590
|
-
if (options.maxAge && typeof options.maxAge !== 'number')
|
|
7591
|
-
throw new TypeError('maxAge must be a number')
|
|
7592
|
-
this[MAX_AGE] = options.maxAge || 0;
|
|
7593
|
-
this[DISPOSE] = options.dispose;
|
|
7594
|
-
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
|
|
7595
|
-
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
|
|
7596
|
-
this.reset();
|
|
7597
|
-
}
|
|
7598
|
-
set max (mL) {
|
|
7599
|
-
if (typeof mL !== 'number' || mL < 0)
|
|
7600
|
-
throw new TypeError('max must be a non-negative number')
|
|
7601
|
-
this[MAX] = mL || Infinity;
|
|
7602
|
-
trim(this);
|
|
7603
|
-
}
|
|
7604
|
-
get max () {
|
|
7605
|
-
return this[MAX]
|
|
7606
|
-
}
|
|
7607
|
-
set allowStale (allowStale) {
|
|
7608
|
-
this[ALLOW_STALE] = !!allowStale;
|
|
7609
|
-
}
|
|
7610
|
-
get allowStale () {
|
|
7611
|
-
return this[ALLOW_STALE]
|
|
7612
|
-
}
|
|
7613
|
-
set maxAge (mA) {
|
|
7614
|
-
if (typeof mA !== 'number')
|
|
7615
|
-
throw new TypeError('maxAge must be a non-negative number')
|
|
7616
|
-
this[MAX_AGE] = mA;
|
|
7617
|
-
trim(this);
|
|
7618
|
-
}
|
|
7619
|
-
get maxAge () {
|
|
7620
|
-
return this[MAX_AGE]
|
|
7621
|
-
}
|
|
7622
|
-
set lengthCalculator (lC) {
|
|
7623
|
-
if (typeof lC !== 'function')
|
|
7624
|
-
lC = naiveLength;
|
|
7625
|
-
if (lC !== this[LENGTH_CALCULATOR]) {
|
|
7626
|
-
this[LENGTH_CALCULATOR] = lC;
|
|
7627
|
-
this[LENGTH] = 0;
|
|
7628
|
-
this[LRU_LIST].forEach(hit => {
|
|
7629
|
-
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
|
|
7630
|
-
this[LENGTH] += hit.length;
|
|
7631
|
-
});
|
|
7632
|
-
}
|
|
7633
|
-
trim(this);
|
|
7634
|
-
}
|
|
7635
|
-
get lengthCalculator () { return this[LENGTH_CALCULATOR] }
|
|
7636
|
-
get length () { return this[LENGTH] }
|
|
7637
|
-
get itemCount () { return this[LRU_LIST].length }
|
|
7638
|
-
rforEach (fn, thisp) {
|
|
7639
|
-
thisp = thisp || this;
|
|
7640
|
-
for (let walker = this[LRU_LIST].tail; walker !== null;) {
|
|
7641
|
-
const prev = walker.prev;
|
|
7642
|
-
forEachStep(this, fn, walker, thisp);
|
|
7643
|
-
walker = prev;
|
|
7644
|
-
}
|
|
7645
|
-
}
|
|
7646
|
-
forEach (fn, thisp) {
|
|
7647
|
-
thisp = thisp || this;
|
|
7648
|
-
for (let walker = this[LRU_LIST].head; walker !== null;) {
|
|
7649
|
-
const next = walker.next;
|
|
7650
|
-
forEachStep(this, fn, walker, thisp);
|
|
7651
|
-
walker = next;
|
|
7652
|
-
}
|
|
7653
|
-
}
|
|
7654
|
-
keys () {
|
|
7655
|
-
return this[LRU_LIST].toArray().map(k => k.key)
|
|
7656
|
-
}
|
|
7657
|
-
values () {
|
|
7658
|
-
return this[LRU_LIST].toArray().map(k => k.value)
|
|
7659
|
-
}
|
|
7660
|
-
reset () {
|
|
7661
|
-
if (this[DISPOSE] &&
|
|
7662
|
-
this[LRU_LIST] &&
|
|
7663
|
-
this[LRU_LIST].length) {
|
|
7664
|
-
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
|
|
7665
|
-
}
|
|
7666
|
-
this[CACHE] = new Map();
|
|
7667
|
-
this[LRU_LIST] = new Yallist();
|
|
7668
|
-
this[LENGTH] = 0;
|
|
7669
|
-
}
|
|
7670
|
-
dump () {
|
|
7671
|
-
return this[LRU_LIST].map(hit =>
|
|
7672
|
-
isStale(this, hit) ? false : {
|
|
7673
|
-
k: hit.key,
|
|
7674
|
-
v: hit.value,
|
|
7675
|
-
e: hit.now + (hit.maxAge || 0)
|
|
7676
|
-
}).toArray().filter(h => h)
|
|
7677
|
-
}
|
|
7678
|
-
dumpLru () {
|
|
7679
|
-
return this[LRU_LIST]
|
|
7680
|
-
}
|
|
7681
|
-
set (key, value, maxAge) {
|
|
7682
|
-
maxAge = maxAge || this[MAX_AGE];
|
|
7683
|
-
if (maxAge && typeof maxAge !== 'number')
|
|
7684
|
-
throw new TypeError('maxAge must be a number')
|
|
7685
|
-
const now = maxAge ? Date.now() : 0;
|
|
7686
|
-
const len = this[LENGTH_CALCULATOR](value, key);
|
|
7687
|
-
if (this[CACHE].has(key)) {
|
|
7688
|
-
if (len > this[MAX]) {
|
|
7689
|
-
del(this, this[CACHE].get(key));
|
|
7690
|
-
return false
|
|
7691
|
-
}
|
|
7692
|
-
const node = this[CACHE].get(key);
|
|
7693
|
-
const item = node.value;
|
|
7694
|
-
if (this[DISPOSE]) {
|
|
7695
|
-
if (!this[NO_DISPOSE_ON_SET])
|
|
7696
|
-
this[DISPOSE](key, item.value);
|
|
7697
|
-
}
|
|
7698
|
-
item.now = now;
|
|
7699
|
-
item.maxAge = maxAge;
|
|
7700
|
-
item.value = value;
|
|
7701
|
-
this[LENGTH] += len - item.length;
|
|
7702
|
-
item.length = len;
|
|
7703
|
-
this.get(key);
|
|
7704
|
-
trim(this);
|
|
7705
|
-
return true
|
|
7706
|
-
}
|
|
7707
|
-
const hit = new Entry(key, value, len, now, maxAge);
|
|
7708
|
-
if (hit.length > this[MAX]) {
|
|
7709
|
-
if (this[DISPOSE])
|
|
7710
|
-
this[DISPOSE](key, value);
|
|
7711
|
-
return false
|
|
7712
|
-
}
|
|
7713
|
-
this[LENGTH] += hit.length;
|
|
7714
|
-
this[LRU_LIST].unshift(hit);
|
|
7715
|
-
this[CACHE].set(key, this[LRU_LIST].head);
|
|
7716
|
-
trim(this);
|
|
7717
|
-
return true
|
|
7718
|
-
}
|
|
7719
|
-
has (key) {
|
|
7720
|
-
if (!this[CACHE].has(key)) return false
|
|
7721
|
-
const hit = this[CACHE].get(key).value;
|
|
7722
|
-
return !isStale(this, hit)
|
|
7570
|
+
constructor () {
|
|
7571
|
+
this.max = 1000;
|
|
7572
|
+
this.map = new Map();
|
|
7723
7573
|
}
|
|
7724
7574
|
get (key) {
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
if (!node)
|
|
7733
|
-
return null
|
|
7734
|
-
del(this, node);
|
|
7735
|
-
return node.value
|
|
7736
|
-
}
|
|
7737
|
-
del (key) {
|
|
7738
|
-
del(this, this[CACHE].get(key));
|
|
7739
|
-
}
|
|
7740
|
-
load (arr) {
|
|
7741
|
-
this.reset();
|
|
7742
|
-
const now = Date.now();
|
|
7743
|
-
for (let l = arr.length - 1; l >= 0; l--) {
|
|
7744
|
-
const hit = arr[l];
|
|
7745
|
-
const expiresAt = hit.e || 0;
|
|
7746
|
-
if (expiresAt === 0)
|
|
7747
|
-
this.set(hit.k, hit.v);
|
|
7748
|
-
else {
|
|
7749
|
-
const maxAge = expiresAt - now;
|
|
7750
|
-
if (maxAge > 0) {
|
|
7751
|
-
this.set(hit.k, hit.v, maxAge);
|
|
7752
|
-
}
|
|
7753
|
-
}
|
|
7575
|
+
const value = this.map.get(key);
|
|
7576
|
+
if (value === undefined) {
|
|
7577
|
+
return undefined
|
|
7578
|
+
} else {
|
|
7579
|
+
this.map.delete(key);
|
|
7580
|
+
this.map.set(key, value);
|
|
7581
|
+
return value
|
|
7754
7582
|
}
|
|
7755
7583
|
}
|
|
7756
|
-
|
|
7757
|
-
this
|
|
7584
|
+
delete (key) {
|
|
7585
|
+
return this.map.delete(key)
|
|
7758
7586
|
}
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
del(self, node);
|
|
7766
|
-
if (!self[ALLOW_STALE])
|
|
7767
|
-
return undefined
|
|
7768
|
-
} else {
|
|
7769
|
-
if (doUse) {
|
|
7770
|
-
if (self[UPDATE_AGE_ON_GET])
|
|
7771
|
-
node.value.now = Date.now();
|
|
7772
|
-
self[LRU_LIST].unshiftNode(node);
|
|
7587
|
+
set (key, value) {
|
|
7588
|
+
const deleted = this.delete(key);
|
|
7589
|
+
if (!deleted && value !== undefined) {
|
|
7590
|
+
if (this.map.size >= this.max) {
|
|
7591
|
+
const firstKey = this.map.keys().next().value;
|
|
7592
|
+
this.delete(firstKey);
|
|
7773
7593
|
}
|
|
7594
|
+
this.map.set(key, value);
|
|
7774
7595
|
}
|
|
7775
|
-
return
|
|
7776
|
-
}
|
|
7777
|
-
};
|
|
7778
|
-
const isStale = (self, hit) => {
|
|
7779
|
-
if (!hit || (!hit.maxAge && !self[MAX_AGE]))
|
|
7780
|
-
return false
|
|
7781
|
-
const diff = Date.now() - hit.now;
|
|
7782
|
-
return hit.maxAge ? diff > hit.maxAge
|
|
7783
|
-
: self[MAX_AGE] && (diff > self[MAX_AGE])
|
|
7784
|
-
};
|
|
7785
|
-
const trim = self => {
|
|
7786
|
-
if (self[LENGTH] > self[MAX]) {
|
|
7787
|
-
for (let walker = self[LRU_LIST].tail;
|
|
7788
|
-
self[LENGTH] > self[MAX] && walker !== null;) {
|
|
7789
|
-
const prev = walker.prev;
|
|
7790
|
-
del(self, walker);
|
|
7791
|
-
walker = prev;
|
|
7792
|
-
}
|
|
7793
|
-
}
|
|
7794
|
-
};
|
|
7795
|
-
const del = (self, node) => {
|
|
7796
|
-
if (node) {
|
|
7797
|
-
const hit = node.value;
|
|
7798
|
-
if (self[DISPOSE])
|
|
7799
|
-
self[DISPOSE](hit.key, hit.value);
|
|
7800
|
-
self[LENGTH] -= hit.length;
|
|
7801
|
-
self[CACHE].delete(hit.key);
|
|
7802
|
-
self[LRU_LIST].removeNode(node);
|
|
7803
|
-
}
|
|
7804
|
-
};
|
|
7805
|
-
class Entry {
|
|
7806
|
-
constructor (key, value, length, now, maxAge) {
|
|
7807
|
-
this.key = key;
|
|
7808
|
-
this.value = value;
|
|
7809
|
-
this.length = length;
|
|
7810
|
-
this.now = now;
|
|
7811
|
-
this.maxAge = maxAge || 0;
|
|
7596
|
+
return this
|
|
7812
7597
|
}
|
|
7813
7598
|
}
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
if (isStale(self, hit)) {
|
|
7817
|
-
del(self, node);
|
|
7818
|
-
if (!self[ALLOW_STALE])
|
|
7819
|
-
hit = undefined;
|
|
7820
|
-
}
|
|
7821
|
-
if (hit)
|
|
7822
|
-
fn.call(thisp, hit.value, hit.key, self);
|
|
7823
|
-
};
|
|
7824
|
-
lruCache = LRUCache;
|
|
7825
|
-
return lruCache;
|
|
7599
|
+
lrucache = LRUCache;
|
|
7600
|
+
return lrucache;
|
|
7826
7601
|
}
|
|
7827
7602
|
|
|
7828
7603
|
var range;
|
|
@@ -7830,6 +7605,7 @@
|
|
|
7830
7605
|
function requireRange () {
|
|
7831
7606
|
if (hasRequiredRange) return range;
|
|
7832
7607
|
hasRequiredRange = 1;
|
|
7608
|
+
const SPACE_CHARACTERS = /\s+/g;
|
|
7833
7609
|
class Range {
|
|
7834
7610
|
constructor (range, options) {
|
|
7835
7611
|
options = parseOptions(options);
|
|
@@ -7846,16 +7622,13 @@
|
|
|
7846
7622
|
if (range instanceof Comparator) {
|
|
7847
7623
|
this.raw = range.value;
|
|
7848
7624
|
this.set = [[range]];
|
|
7849
|
-
this.
|
|
7625
|
+
this.formatted = undefined;
|
|
7850
7626
|
return this
|
|
7851
7627
|
}
|
|
7852
7628
|
this.options = options;
|
|
7853
7629
|
this.loose = !!options.loose;
|
|
7854
7630
|
this.includePrerelease = !!options.includePrerelease;
|
|
7855
|
-
this.raw = range
|
|
7856
|
-
.trim()
|
|
7857
|
-
.split(/\s+/)
|
|
7858
|
-
.join(' ');
|
|
7631
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, ' ');
|
|
7859
7632
|
this.set = this.raw
|
|
7860
7633
|
.split('||')
|
|
7861
7634
|
.map(r => this.parseRange(r.trim()))
|
|
@@ -7877,13 +7650,27 @@
|
|
|
7877
7650
|
}
|
|
7878
7651
|
}
|
|
7879
7652
|
}
|
|
7880
|
-
this.
|
|
7653
|
+
this.formatted = undefined;
|
|
7654
|
+
}
|
|
7655
|
+
get range () {
|
|
7656
|
+
if (this.formatted === undefined) {
|
|
7657
|
+
this.formatted = '';
|
|
7658
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
7659
|
+
if (i > 0) {
|
|
7660
|
+
this.formatted += '||';
|
|
7661
|
+
}
|
|
7662
|
+
const comps = this.set[i];
|
|
7663
|
+
for (let k = 0; k < comps.length; k++) {
|
|
7664
|
+
if (k > 0) {
|
|
7665
|
+
this.formatted += ' ';
|
|
7666
|
+
}
|
|
7667
|
+
this.formatted += comps[k].toString().trim();
|
|
7668
|
+
}
|
|
7669
|
+
}
|
|
7670
|
+
}
|
|
7671
|
+
return this.formatted
|
|
7881
7672
|
}
|
|
7882
7673
|
format () {
|
|
7883
|
-
this.range = this.set
|
|
7884
|
-
.map((comps) => comps.join(' ').trim())
|
|
7885
|
-
.join('||')
|
|
7886
|
-
.trim();
|
|
7887
7674
|
return this.range
|
|
7888
7675
|
}
|
|
7889
7676
|
toString () {
|
|
@@ -7976,8 +7763,8 @@
|
|
|
7976
7763
|
}
|
|
7977
7764
|
}
|
|
7978
7765
|
range = Range;
|
|
7979
|
-
const LRU =
|
|
7980
|
-
const cache = new LRU(
|
|
7766
|
+
const LRU = requireLrucache();
|
|
7767
|
+
const cache = new LRU();
|
|
7981
7768
|
const parseOptions = parseOptions_1;
|
|
7982
7769
|
const Comparator = requireComparator();
|
|
7983
7770
|
const debug = debug_1;
|
|
@@ -8005,6 +7792,7 @@
|
|
|
8005
7792
|
return result
|
|
8006
7793
|
};
|
|
8007
7794
|
const parseComparator = (comp, options) => {
|
|
7795
|
+
comp = comp.replace(re[t.BUILD], '');
|
|
8008
7796
|
debug('comp', comp, options);
|
|
8009
7797
|
comp = replaceCarets(comp, options);
|
|
8010
7798
|
debug('caret', comp);
|
|
@@ -8181,7 +7969,7 @@
|
|
|
8181
7969
|
};
|
|
8182
7970
|
const hyphenReplace = incPr => ($0,
|
|
8183
7971
|
from, fM, fm, fp, fpr, fb,
|
|
8184
|
-
to, tM, tm, tp, tpr
|
|
7972
|
+
to, tM, tm, tp, tpr) => {
|
|
8185
7973
|
if (isX(fM)) {
|
|
8186
7974
|
from = '';
|
|
8187
7975
|
} else if (isX(fm)) {
|
|
@@ -8887,6 +8675,7 @@
|
|
|
8887
8675
|
DeviceModelId["nanoX"] = "nanoX";
|
|
8888
8676
|
DeviceModelId["stax"] = "stax";
|
|
8889
8677
|
DeviceModelId["europa"] = "europa";
|
|
8678
|
+
DeviceModelId["apex"] = "apex";
|
|
8890
8679
|
})(DeviceModelId || (DeviceModelId = {}));
|
|
8891
8680
|
const devices = {
|
|
8892
8681
|
[DeviceModelId.blue]: {
|
|
@@ -8907,7 +8696,7 @@
|
|
|
8907
8696
|
usbOnly: true,
|
|
8908
8697
|
memorySize: 320 * 1024,
|
|
8909
8698
|
masks: [0x31100000],
|
|
8910
|
-
getBlockSize: (firmwareVersion) =>
|
|
8699
|
+
getBlockSize: (firmwareVersion) => semver$1.lt(semver$1.coerce(firmwareVersion) ?? "", "2.0.0") ? 4 * 1024 : 2 * 1024,
|
|
8911
8700
|
},
|
|
8912
8701
|
[DeviceModelId.nanoX]: {
|
|
8913
8702
|
id: DeviceModelId.nanoX,
|
|
@@ -8937,6 +8726,24 @@
|
|
|
8937
8726
|
masks: [0x33100000],
|
|
8938
8727
|
getBlockSize: (_firmwareVersion) => 32,
|
|
8939
8728
|
},
|
|
8729
|
+
[DeviceModelId.apex]: {
|
|
8730
|
+
id: DeviceModelId.apex,
|
|
8731
|
+
productName: "Ledger Nano Gen5",
|
|
8732
|
+
productIdMM: 0x80,
|
|
8733
|
+
legacyUsbProductId: 0x0008,
|
|
8734
|
+
usbOnly: false,
|
|
8735
|
+
memorySize: 1533 * 1024,
|
|
8736
|
+
masks: [0x33400000],
|
|
8737
|
+
getBlockSize: (_firmwareVersion) => 32,
|
|
8738
|
+
bluetoothSpec: [
|
|
8739
|
+
{
|
|
8740
|
+
serviceUuid: "13d63400-2c97-8004-0000-4c6564676572",
|
|
8741
|
+
notifyUuid: "13d63400-2c97-8004-0001-4c6564676572",
|
|
8742
|
+
writeUuid: "13d63400-2c97-8004-0002-4c6564676572",
|
|
8743
|
+
writeCmdUuid: "13d63400-2c97-8004-0003-4c6564676572",
|
|
8744
|
+
},
|
|
8745
|
+
],
|
|
8746
|
+
},
|
|
8940
8747
|
[DeviceModelId.stax]: {
|
|
8941
8748
|
id: DeviceModelId.stax,
|
|
8942
8749
|
productName: "Ledger Stax",
|
|
@@ -9001,20 +8808,14 @@
|
|
|
9001
8808
|
for (let i = 0; i < bluetoothSpec.length; i++) {
|
|
9002
8809
|
const spec = bluetoothSpec[i];
|
|
9003
8810
|
bluetoothServices.push(spec.serviceUuid);
|
|
9004
|
-
serviceUuidToInfos[spec.serviceUuid] = serviceUuidToInfos[spec.serviceUuid.replace(/-/g, "")] =
|
|
8811
|
+
serviceUuidToInfos[spec.serviceUuid] = serviceUuidToInfos[spec.serviceUuid.replace(/-/g, "")] = {
|
|
8812
|
+
deviceModel,
|
|
8813
|
+
...spec,
|
|
8814
|
+
};
|
|
9005
8815
|
}
|
|
9006
8816
|
}
|
|
9007
8817
|
}
|
|
9008
8818
|
|
|
9009
|
-
var __awaiter$2 = (global && global.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9010
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9011
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9012
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9013
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9014
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9015
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9016
|
-
});
|
|
9017
|
-
};
|
|
9018
8819
|
const ledgerDevices$1 = [
|
|
9019
8820
|
{
|
|
9020
8821
|
vendorId: ledgerUSBVendorId,
|
|
@@ -9027,159 +8828,156 @@
|
|
|
9027
8828
|
throw new TransportError("navigator.hid is not supported", "HIDNotSupported");
|
|
9028
8829
|
return hid;
|
|
9029
8830
|
};
|
|
9030
|
-
function requestLedgerDevices() {
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
filters: ledgerDevices$1,
|
|
9034
|
-
});
|
|
9035
|
-
if (Array.isArray(device))
|
|
9036
|
-
return device;
|
|
9037
|
-
return [device];
|
|
8831
|
+
async function requestLedgerDevices() {
|
|
8832
|
+
const device = await getHID().requestDevice({
|
|
8833
|
+
filters: ledgerDevices$1,
|
|
9038
8834
|
});
|
|
8835
|
+
if (Array.isArray(device))
|
|
8836
|
+
return device;
|
|
8837
|
+
return [device];
|
|
9039
8838
|
}
|
|
9040
|
-
function getLedgerDevices$1() {
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
return devices.filter(d => d.vendorId === ledgerUSBVendorId);
|
|
9044
|
-
});
|
|
8839
|
+
async function getLedgerDevices$1() {
|
|
8840
|
+
const devices = await getHID().getDevices();
|
|
8841
|
+
return devices.filter(d => d.vendorId === ledgerUSBVendorId);
|
|
9045
8842
|
}
|
|
9046
|
-
function getFirstLedgerDevice$1() {
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
return devices[0];
|
|
9053
|
-
});
|
|
8843
|
+
async function getFirstLedgerDevice$1() {
|
|
8844
|
+
const existingDevices = await getLedgerDevices$1();
|
|
8845
|
+
if (existingDevices.length > 0)
|
|
8846
|
+
return existingDevices[0];
|
|
8847
|
+
const devices = await requestLedgerDevices();
|
|
8848
|
+
return devices[0];
|
|
9054
8849
|
}
|
|
9055
8850
|
class TransportWebHID extends Transport {
|
|
8851
|
+
device;
|
|
8852
|
+
deviceModel;
|
|
8853
|
+
channel = Math.floor(Math.random() * 0xffff);
|
|
8854
|
+
packetSize = 64;
|
|
9056
8855
|
constructor(device) {
|
|
9057
8856
|
super();
|
|
9058
|
-
this.channel = Math.floor(Math.random() * 0xffff);
|
|
9059
|
-
this.packetSize = 64;
|
|
9060
|
-
this.inputs = [];
|
|
9061
|
-
this.read = () => {
|
|
9062
|
-
if (this.inputs.length) {
|
|
9063
|
-
return Promise.resolve(this.inputs.shift());
|
|
9064
|
-
}
|
|
9065
|
-
return new Promise(success => {
|
|
9066
|
-
this.inputCallback = success;
|
|
9067
|
-
});
|
|
9068
|
-
};
|
|
9069
|
-
this.onInputReport = (e) => {
|
|
9070
|
-
const buffer = Buffer.from(e.data.buffer);
|
|
9071
|
-
if (this.inputCallback) {
|
|
9072
|
-
this.inputCallback(buffer);
|
|
9073
|
-
this.inputCallback = null;
|
|
9074
|
-
}
|
|
9075
|
-
else {
|
|
9076
|
-
this.inputs.push(buffer);
|
|
9077
|
-
}
|
|
9078
|
-
};
|
|
9079
|
-
this._disconnectEmitted = false;
|
|
9080
|
-
this._emitDisconnect = (e) => {
|
|
9081
|
-
if (this._disconnectEmitted)
|
|
9082
|
-
return;
|
|
9083
|
-
this._disconnectEmitted = true;
|
|
9084
|
-
this.emit("disconnect", e);
|
|
9085
|
-
};
|
|
9086
|
-
this.exchange = (apdu) => __awaiter$2(this, void 0, void 0, function* () {
|
|
9087
|
-
const b = yield this.exchangeAtomicImpl(() => __awaiter$2(this, void 0, void 0, function* () {
|
|
9088
|
-
const { channel, packetSize } = this;
|
|
9089
|
-
log("apdu", "=> " + apdu.toString("hex"));
|
|
9090
|
-
const framing = createHIDframing(channel, packetSize);
|
|
9091
|
-
const blocks = framing.makeBlocks(apdu);
|
|
9092
|
-
for (let i = 0; i < blocks.length; i++) {
|
|
9093
|
-
yield this.device.sendReport(0, blocks[i]);
|
|
9094
|
-
}
|
|
9095
|
-
let result;
|
|
9096
|
-
let acc;
|
|
9097
|
-
while (!(result = framing.getReducedResult(acc))) {
|
|
9098
|
-
const buffer = yield this.read();
|
|
9099
|
-
acc = framing.reduceResponse(acc, buffer);
|
|
9100
|
-
}
|
|
9101
|
-
log("apdu", "<= " + result.toString("hex"));
|
|
9102
|
-
return result;
|
|
9103
|
-
})).catch(e => {
|
|
9104
|
-
if (e && e.message && e.message.includes("write")) {
|
|
9105
|
-
this._emitDisconnect(e);
|
|
9106
|
-
throw new DisconnectedDeviceDuringOperation(e.message);
|
|
9107
|
-
}
|
|
9108
|
-
throw e;
|
|
9109
|
-
});
|
|
9110
|
-
return b;
|
|
9111
|
-
});
|
|
9112
8857
|
this.device = device;
|
|
9113
8858
|
this.deviceModel =
|
|
9114
8859
|
typeof device.productId === "number" ? identifyUSBProductId(device.productId) : undefined;
|
|
9115
8860
|
device.addEventListener("inputreport", this.onInputReport);
|
|
9116
8861
|
}
|
|
9117
|
-
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
8862
|
+
inputs = [];
|
|
8863
|
+
inputCallback;
|
|
8864
|
+
read = () => {
|
|
8865
|
+
if (this.inputs.length) {
|
|
8866
|
+
return Promise.resolve(this.inputs.shift());
|
|
8867
|
+
}
|
|
8868
|
+
return new Promise(success => {
|
|
8869
|
+
this.inputCallback = success;
|
|
9121
8870
|
});
|
|
9122
|
-
}
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
8871
|
+
};
|
|
8872
|
+
onInputReport = (e) => {
|
|
8873
|
+
const buffer = Buffer.from(e.data.buffer);
|
|
8874
|
+
if (this.inputCallback) {
|
|
8875
|
+
this.inputCallback(buffer);
|
|
8876
|
+
this.inputCallback = null;
|
|
8877
|
+
}
|
|
8878
|
+
else {
|
|
8879
|
+
this.inputs.push(buffer);
|
|
8880
|
+
}
|
|
8881
|
+
};
|
|
8882
|
+
static isSupported = isSupported$1;
|
|
8883
|
+
static list = getLedgerDevices$1;
|
|
8884
|
+
static listen = (observer) => {
|
|
8885
|
+
let unsubscribed = false;
|
|
8886
|
+
getFirstLedgerDevice$1().then(device => {
|
|
8887
|
+
if (!device) {
|
|
8888
|
+
observer.error(new TransportOpenUserCancelled("Access denied to use Ledger device"));
|
|
8889
|
+
}
|
|
8890
|
+
else if (!unsubscribed) {
|
|
8891
|
+
const deviceModel = typeof device.productId === "number"
|
|
8892
|
+
? identifyUSBProductId(device.productId)
|
|
8893
|
+
: undefined;
|
|
8894
|
+
observer.next({
|
|
8895
|
+
type: "add",
|
|
8896
|
+
descriptor: device,
|
|
8897
|
+
deviceModel,
|
|
8898
|
+
});
|
|
8899
|
+
observer.complete();
|
|
8900
|
+
}
|
|
8901
|
+
}, error => {
|
|
8902
|
+
observer.error(new TransportOpenUserCancelled(error.message));
|
|
9129
8903
|
});
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
8904
|
+
function unsubscribe() {
|
|
8905
|
+
unsubscribed = true;
|
|
8906
|
+
}
|
|
8907
|
+
return {
|
|
8908
|
+
unsubscribe,
|
|
8909
|
+
};
|
|
8910
|
+
};
|
|
8911
|
+
static async request() {
|
|
8912
|
+
const [device] = await requestLedgerDevices();
|
|
8913
|
+
return TransportWebHID.open(device);
|
|
8914
|
+
}
|
|
8915
|
+
static async openConnected() {
|
|
8916
|
+
const devices = await getLedgerDevices$1();
|
|
8917
|
+
if (devices.length === 0)
|
|
8918
|
+
return null;
|
|
8919
|
+
return TransportWebHID.open(devices[0]);
|
|
8920
|
+
}
|
|
8921
|
+
static async open(device) {
|
|
8922
|
+
await device.open();
|
|
8923
|
+
const transport = new TransportWebHID(device);
|
|
8924
|
+
const onDisconnect = e => {
|
|
8925
|
+
if (device === e.device) {
|
|
8926
|
+
getHID().removeEventListener("disconnect", onDisconnect);
|
|
8927
|
+
transport._emitDisconnect(new DisconnectedDevice());
|
|
8928
|
+
}
|
|
8929
|
+
};
|
|
8930
|
+
getHID().addEventListener("disconnect", onDisconnect);
|
|
8931
|
+
return transport;
|
|
8932
|
+
}
|
|
8933
|
+
_disconnectEmitted = false;
|
|
8934
|
+
_emitDisconnect = (e) => {
|
|
8935
|
+
if (this._disconnectEmitted)
|
|
8936
|
+
return;
|
|
8937
|
+
this._disconnectEmitted = true;
|
|
8938
|
+
this.emit("disconnect", e);
|
|
8939
|
+
};
|
|
8940
|
+
async close() {
|
|
8941
|
+
await this.exchangeBusyPromise;
|
|
8942
|
+
this.device.removeEventListener("inputreport", this.onInputReport);
|
|
8943
|
+
await this.device.close();
|
|
8944
|
+
}
|
|
8945
|
+
exchange = async (apdu) => {
|
|
8946
|
+
const b = await this.exchangeAtomicImpl(async () => {
|
|
8947
|
+
const { channel, packetSize } = this;
|
|
8948
|
+
log("apdu", "=> " + apdu.toString("hex"));
|
|
8949
|
+
const framing = createHIDframing(channel, packetSize);
|
|
8950
|
+
const blocks = framing.makeBlocks(apdu);
|
|
8951
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
8952
|
+
await this.device.sendReport(0, blocks[i]);
|
|
8953
|
+
}
|
|
8954
|
+
let result;
|
|
8955
|
+
let acc;
|
|
8956
|
+
while (!(result = framing.getReducedResult(acc))) {
|
|
8957
|
+
try {
|
|
8958
|
+
const buffer = await this.read();
|
|
8959
|
+
acc = framing.reduceResponse(acc, buffer);
|
|
9139
8960
|
}
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
|
|
9145
|
-
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
|
|
8961
|
+
catch (e) {
|
|
8962
|
+
if (e instanceof TransportError && e.id === "InvalidChannel") {
|
|
8963
|
+
continue;
|
|
8964
|
+
}
|
|
8965
|
+
throw e;
|
|
8966
|
+
}
|
|
8967
|
+
}
|
|
8968
|
+
log("apdu", "<= " + result.toString("hex"));
|
|
8969
|
+
return result;
|
|
8970
|
+
}).catch(e => {
|
|
8971
|
+
if (e && e.message && e.message.includes("write")) {
|
|
8972
|
+
this._emitDisconnect(e);
|
|
8973
|
+
throw new DisconnectedDeviceDuringOperation(e.message);
|
|
8974
|
+
}
|
|
8975
|
+
throw e;
|
|
9150
8976
|
});
|
|
9151
|
-
|
|
8977
|
+
return b;
|
|
8978
|
+
};
|
|
9152
8979
|
setScrambleKey() { }
|
|
9153
8980
|
}
|
|
9154
|
-
TransportWebHID.isSupported = isSupported$1;
|
|
9155
|
-
TransportWebHID.list = getLedgerDevices$1;
|
|
9156
|
-
TransportWebHID.listen = (observer) => {
|
|
9157
|
-
let unsubscribed = false;
|
|
9158
|
-
getFirstLedgerDevice$1().then(device => {
|
|
9159
|
-
if (!device) {
|
|
9160
|
-
observer.error(new TransportOpenUserCancelled("Access denied to use Ledger device"));
|
|
9161
|
-
}
|
|
9162
|
-
else if (!unsubscribed) {
|
|
9163
|
-
const deviceModel = typeof device.productId === "number"
|
|
9164
|
-
? identifyUSBProductId(device.productId)
|
|
9165
|
-
: undefined;
|
|
9166
|
-
observer.next({
|
|
9167
|
-
type: "add",
|
|
9168
|
-
descriptor: device,
|
|
9169
|
-
deviceModel,
|
|
9170
|
-
});
|
|
9171
|
-
observer.complete();
|
|
9172
|
-
}
|
|
9173
|
-
}, error => {
|
|
9174
|
-
observer.error(new TransportOpenUserCancelled(error.message));
|
|
9175
|
-
});
|
|
9176
|
-
function unsubscribe() {
|
|
9177
|
-
unsubscribed = true;
|
|
9178
|
-
}
|
|
9179
|
-
return {
|
|
9180
|
-
unsubscribe,
|
|
9181
|
-
};
|
|
9182
|
-
};
|
|
9183
8981
|
|
|
9184
8982
|
const TransportWebHID$1 = /*#__PURE__*/Object.freeze({
|
|
9185
8983
|
__proto__: null,
|
|
@@ -9188,192 +8986,159 @@
|
|
|
9188
8986
|
|
|
9189
8987
|
const require$$1 = /*@__PURE__*/getAugmentedNamespace(TransportWebHID$1);
|
|
9190
8988
|
|
|
9191
|
-
var __awaiter$1 = (global && global.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9192
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9193
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9194
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9195
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9196
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9197
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9198
|
-
});
|
|
9199
|
-
};
|
|
9200
8989
|
const ledgerDevices = [
|
|
9201
8990
|
{
|
|
9202
8991
|
vendorId: ledgerUSBVendorId,
|
|
9203
8992
|
},
|
|
9204
8993
|
];
|
|
9205
|
-
function requestLedgerDevice() {
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
filters: ledgerDevices,
|
|
9209
|
-
});
|
|
9210
|
-
return device;
|
|
8994
|
+
async function requestLedgerDevice() {
|
|
8995
|
+
const device = await navigator.usb.requestDevice({
|
|
8996
|
+
filters: ledgerDevices,
|
|
9211
8997
|
});
|
|
8998
|
+
return device;
|
|
9212
8999
|
}
|
|
9213
|
-
function getLedgerDevices() {
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
return devices.filter(d => d.vendorId === ledgerUSBVendorId);
|
|
9217
|
-
});
|
|
9000
|
+
async function getLedgerDevices() {
|
|
9001
|
+
const devices = await navigator.usb.getDevices();
|
|
9002
|
+
return devices.filter(d => d.vendorId === ledgerUSBVendorId);
|
|
9218
9003
|
}
|
|
9219
|
-
function getFirstLedgerDevice() {
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
return requestLedgerDevice();
|
|
9225
|
-
});
|
|
9004
|
+
async function getFirstLedgerDevice() {
|
|
9005
|
+
const existingDevices = await getLedgerDevices();
|
|
9006
|
+
if (existingDevices.length > 0)
|
|
9007
|
+
return existingDevices[0];
|
|
9008
|
+
return requestLedgerDevice();
|
|
9226
9009
|
}
|
|
9227
9010
|
const isSupported = () => Promise.resolve(!!navigator && !!navigator.usb && typeof navigator.usb.getDevices === "function");
|
|
9228
9011
|
|
|
9229
|
-
var __awaiter = (global && global.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9230
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9231
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9232
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9233
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9234
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9235
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9236
|
-
});
|
|
9237
|
-
};
|
|
9238
9012
|
const configurationValue = 1;
|
|
9239
9013
|
const endpointNumber = 3;
|
|
9240
9014
|
class TransportWebUSB extends Transport {
|
|
9015
|
+
device;
|
|
9016
|
+
deviceModel;
|
|
9017
|
+
channel = Math.floor(Math.random() * 0xffff);
|
|
9018
|
+
packetSize = 64;
|
|
9019
|
+
interfaceNumber;
|
|
9241
9020
|
constructor(device, interfaceNumber) {
|
|
9242
9021
|
super();
|
|
9243
|
-
this.channel = Math.floor(Math.random() * 0xffff);
|
|
9244
|
-
this.packetSize = 64;
|
|
9245
|
-
this._disconnectEmitted = false;
|
|
9246
|
-
this._emitDisconnect = (e) => {
|
|
9247
|
-
if (this._disconnectEmitted)
|
|
9248
|
-
return;
|
|
9249
|
-
this._disconnectEmitted = true;
|
|
9250
|
-
this.emit("disconnect", e);
|
|
9251
|
-
};
|
|
9252
9022
|
this.device = device;
|
|
9253
9023
|
this.interfaceNumber = interfaceNumber;
|
|
9254
9024
|
this.deviceModel = identifyUSBProductId(device.productId);
|
|
9255
9025
|
}
|
|
9256
|
-
static
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
|
|
9260
|
-
|
|
9261
|
-
|
|
9262
|
-
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
|
|
9026
|
+
static isSupported = isSupported;
|
|
9027
|
+
static list = getLedgerDevices;
|
|
9028
|
+
static listen = (observer) => {
|
|
9029
|
+
let unsubscribed = false;
|
|
9030
|
+
getFirstLedgerDevice().then(device => {
|
|
9031
|
+
if (!unsubscribed) {
|
|
9032
|
+
const deviceModel = identifyUSBProductId(device.productId);
|
|
9033
|
+
observer.next({
|
|
9034
|
+
type: "add",
|
|
9035
|
+
descriptor: device,
|
|
9036
|
+
deviceModel,
|
|
9037
|
+
});
|
|
9038
|
+
observer.complete();
|
|
9039
|
+
}
|
|
9040
|
+
}, error => {
|
|
9041
|
+
if (window.DOMException && error instanceof window.DOMException && error.code === 18) {
|
|
9042
|
+
observer.error(new TransportWebUSBGestureRequired(error.message));
|
|
9043
|
+
}
|
|
9044
|
+
else {
|
|
9045
|
+
observer.error(new TransportOpenUserCancelled(error.message));
|
|
9046
|
+
}
|
|
9268
9047
|
});
|
|
9269
|
-
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9048
|
+
function unsubscribe() {
|
|
9049
|
+
unsubscribed = true;
|
|
9050
|
+
}
|
|
9051
|
+
return {
|
|
9052
|
+
unsubscribe,
|
|
9053
|
+
};
|
|
9054
|
+
};
|
|
9055
|
+
static async request() {
|
|
9056
|
+
const device = await requestLedgerDevice();
|
|
9057
|
+
return TransportWebUSB.open(device);
|
|
9058
|
+
}
|
|
9059
|
+
static async openConnected() {
|
|
9060
|
+
const devices = await getLedgerDevices();
|
|
9061
|
+
if (devices.length === 0)
|
|
9062
|
+
return null;
|
|
9063
|
+
return TransportWebUSB.open(devices[0]);
|
|
9064
|
+
}
|
|
9065
|
+
static async open(device) {
|
|
9066
|
+
await device.open();
|
|
9067
|
+
if (device.configuration === null) {
|
|
9068
|
+
await device.selectConfiguration(configurationValue);
|
|
9069
|
+
}
|
|
9070
|
+
await gracefullyResetDevice(device);
|
|
9071
|
+
const iface = device.configurations[0].interfaces.find(({ alternates }) => alternates.some(a => a.interfaceClass === 255));
|
|
9072
|
+
if (!iface) {
|
|
9073
|
+
throw new TransportInterfaceNotAvailable("No WebUSB interface found for your Ledger device. Please upgrade firmware or contact techsupport.");
|
|
9074
|
+
}
|
|
9075
|
+
const interfaceNumber = iface.interfaceNumber;
|
|
9076
|
+
try {
|
|
9077
|
+
await device.claimInterface(interfaceNumber);
|
|
9078
|
+
}
|
|
9079
|
+
catch (e) {
|
|
9080
|
+
await device.close();
|
|
9081
|
+
throw new TransportInterfaceNotAvailable(e.message);
|
|
9082
|
+
}
|
|
9083
|
+
const transport = new TransportWebUSB(device, interfaceNumber);
|
|
9084
|
+
const onDisconnect = e => {
|
|
9085
|
+
if (device === e.device) {
|
|
9086
|
+
navigator.usb.removeEventListener("disconnect", onDisconnect);
|
|
9087
|
+
transport._emitDisconnect(new DisconnectedDevice());
|
|
9275
9088
|
}
|
|
9276
|
-
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9089
|
+
};
|
|
9090
|
+
navigator.usb.addEventListener("disconnect", onDisconnect);
|
|
9091
|
+
return transport;
|
|
9092
|
+
}
|
|
9093
|
+
_disconnectEmitted = false;
|
|
9094
|
+
_emitDisconnect = (e) => {
|
|
9095
|
+
if (this._disconnectEmitted)
|
|
9096
|
+
return;
|
|
9097
|
+
this._disconnectEmitted = true;
|
|
9098
|
+
this.emit("disconnect", e);
|
|
9099
|
+
};
|
|
9100
|
+
async close() {
|
|
9101
|
+
await this.exchangeBusyPromise;
|
|
9102
|
+
await this.device.releaseInterface(this.interfaceNumber);
|
|
9103
|
+
await gracefullyResetDevice(this.device);
|
|
9104
|
+
await this.device.close();
|
|
9105
|
+
}
|
|
9106
|
+
async exchange(apdu) {
|
|
9107
|
+
const b = await this.exchangeAtomicImpl(async () => {
|
|
9108
|
+
const { channel, packetSize } = this;
|
|
9109
|
+
log("apdu", "=> " + apdu.toString("hex"));
|
|
9110
|
+
const framing = createHIDframing(channel, packetSize);
|
|
9111
|
+
const blocks = framing.makeBlocks(apdu);
|
|
9112
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
9113
|
+
await this.device.transferOut(endpointNumber, blocks[i]);
|
|
9280
9114
|
}
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9115
|
+
let result;
|
|
9116
|
+
let acc;
|
|
9117
|
+
while (!(result = framing.getReducedResult(acc))) {
|
|
9118
|
+
const r = await this.device.transferIn(endpointNumber, packetSize);
|
|
9119
|
+
const buffer = Buffer.from(r.data.buffer);
|
|
9120
|
+
acc = framing.reduceResponse(acc, buffer);
|
|
9284
9121
|
}
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9122
|
+
log("apdu", "<= " + result.toString("hex"));
|
|
9123
|
+
return result;
|
|
9124
|
+
}).catch(e => {
|
|
9125
|
+
if (e && e.message && e.message.includes("disconnected")) {
|
|
9126
|
+
this._emitDisconnect(e);
|
|
9127
|
+
throw new DisconnectedDeviceDuringOperation(e.message);
|
|
9288
9128
|
}
|
|
9289
|
-
|
|
9290
|
-
const onDisconnect = e => {
|
|
9291
|
-
if (device === e.device) {
|
|
9292
|
-
navigator.usb.removeEventListener("disconnect", onDisconnect);
|
|
9293
|
-
transport._emitDisconnect(new DisconnectedDevice());
|
|
9294
|
-
}
|
|
9295
|
-
};
|
|
9296
|
-
navigator.usb.addEventListener("disconnect", onDisconnect);
|
|
9297
|
-
return transport;
|
|
9298
|
-
});
|
|
9299
|
-
}
|
|
9300
|
-
close() {
|
|
9301
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9302
|
-
yield this.exchangeBusyPromise;
|
|
9303
|
-
yield this.device.releaseInterface(this.interfaceNumber);
|
|
9304
|
-
yield gracefullyResetDevice(this.device);
|
|
9305
|
-
yield this.device.close();
|
|
9306
|
-
});
|
|
9307
|
-
}
|
|
9308
|
-
exchange(apdu) {
|
|
9309
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9310
|
-
const b = yield this.exchangeAtomicImpl(() => __awaiter(this, void 0, void 0, function* () {
|
|
9311
|
-
const { channel, packetSize } = this;
|
|
9312
|
-
log("apdu", "=> " + apdu.toString("hex"));
|
|
9313
|
-
const framing = createHIDframing(channel, packetSize);
|
|
9314
|
-
const blocks = framing.makeBlocks(apdu);
|
|
9315
|
-
for (let i = 0; i < blocks.length; i++) {
|
|
9316
|
-
yield this.device.transferOut(endpointNumber, blocks[i]);
|
|
9317
|
-
}
|
|
9318
|
-
let result;
|
|
9319
|
-
let acc;
|
|
9320
|
-
while (!(result = framing.getReducedResult(acc))) {
|
|
9321
|
-
const r = yield this.device.transferIn(endpointNumber, packetSize);
|
|
9322
|
-
const buffer = Buffer.from(r.data.buffer);
|
|
9323
|
-
acc = framing.reduceResponse(acc, buffer);
|
|
9324
|
-
}
|
|
9325
|
-
log("apdu", "<= " + result.toString("hex"));
|
|
9326
|
-
return result;
|
|
9327
|
-
})).catch(e => {
|
|
9328
|
-
if (e && e.message && e.message.includes("disconnected")) {
|
|
9329
|
-
this._emitDisconnect(e);
|
|
9330
|
-
throw new DisconnectedDeviceDuringOperation(e.message);
|
|
9331
|
-
}
|
|
9332
|
-
throw e;
|
|
9333
|
-
});
|
|
9334
|
-
return b;
|
|
9129
|
+
throw e;
|
|
9335
9130
|
});
|
|
9131
|
+
return b;
|
|
9336
9132
|
}
|
|
9337
9133
|
setScrambleKey() { }
|
|
9338
9134
|
}
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9345
|
-
const deviceModel = identifyUSBProductId(device.productId);
|
|
9346
|
-
observer.next({
|
|
9347
|
-
type: "add",
|
|
9348
|
-
descriptor: device,
|
|
9349
|
-
deviceModel,
|
|
9350
|
-
});
|
|
9351
|
-
observer.complete();
|
|
9352
|
-
}
|
|
9353
|
-
}, error => {
|
|
9354
|
-
if (window.DOMException && error instanceof window.DOMException && error.code === 18) {
|
|
9355
|
-
observer.error(new TransportWebUSBGestureRequired(error.message));
|
|
9356
|
-
}
|
|
9357
|
-
else {
|
|
9358
|
-
observer.error(new TransportOpenUserCancelled(error.message));
|
|
9359
|
-
}
|
|
9360
|
-
});
|
|
9361
|
-
function unsubscribe() {
|
|
9362
|
-
unsubscribed = true;
|
|
9135
|
+
async function gracefullyResetDevice(device) {
|
|
9136
|
+
try {
|
|
9137
|
+
await device.reset();
|
|
9138
|
+
}
|
|
9139
|
+
catch (err) {
|
|
9140
|
+
console.warn(err);
|
|
9363
9141
|
}
|
|
9364
|
-
return {
|
|
9365
|
-
unsubscribe,
|
|
9366
|
-
};
|
|
9367
|
-
};
|
|
9368
|
-
function gracefullyResetDevice(device) {
|
|
9369
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9370
|
-
try {
|
|
9371
|
-
yield device.reset();
|
|
9372
|
-
}
|
|
9373
|
-
catch (err) {
|
|
9374
|
-
console.warn(err);
|
|
9375
|
-
}
|
|
9376
|
-
});
|
|
9377
9142
|
}
|
|
9378
9143
|
|
|
9379
9144
|
const TransportWebUSB$1 = /*#__PURE__*/Object.freeze({
|
|
@@ -9408,20 +9173,20 @@
|
|
|
9408
9173
|
hasRequiredPackageInfo = 1;
|
|
9409
9174
|
Object.defineProperty(packageInfo, "__esModule", { value: true });
|
|
9410
9175
|
packageInfo.packageInfo = void 0;
|
|
9411
|
-
packageInfo.packageInfo = { name: '@pezkuwi/hw-ledger-transports', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '14.0.
|
|
9176
|
+
packageInfo.packageInfo = { name: '@pezkuwi/hw-ledger-transports', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '14.0.10' };
|
|
9412
9177
|
return packageInfo;
|
|
9413
9178
|
}
|
|
9414
9179
|
|
|
9415
|
-
(function (exports) {
|
|
9416
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9417
|
-
exports.transports = exports.packageInfo = void 0;
|
|
9180
|
+
(function (exports$1) {
|
|
9181
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
9182
|
+
exports$1.transports = exports$1.packageInfo = void 0;
|
|
9418
9183
|
const tslib_1 = require$$0;
|
|
9419
9184
|
const hw_transport_webhid_1 = tslib_1.__importDefault(require$$1);
|
|
9420
9185
|
const hw_transport_webusb_1 = tslib_1.__importDefault(require$$2);
|
|
9421
9186
|
const util_js_1 = requireUtil();
|
|
9422
9187
|
var packageInfo_js_1 = requirePackageInfo();
|
|
9423
|
-
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
|
|
9424
|
-
exports.transports = (0, util_js_1.createDefs)(['webusb', hw_transport_webusb_1.default], ['hid', hw_transport_webhid_1.default]);
|
|
9188
|
+
Object.defineProperty(exports$1, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
|
|
9189
|
+
exports$1.transports = (0, util_js_1.createDefs)(['webusb', hw_transport_webusb_1.default], ['hid', hw_transport_webhid_1.default]);
|
|
9425
9190
|
} (browser));
|
|
9426
9191
|
getDefaultExportFromCjs(browser);
|
|
9427
9192
|
|