@onekeyfe/hd-web-sdk 0.1.10 → 0.1.13
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/data/config.ts +1 -0
- package/build/iframe.html +1 -1
- package/build/js/iframe.b96245cb401eda8e8824.js +3 -0
- package/build/js/{iframe.ec4e851a910de94e22e4.js.LICENSE.txt → iframe.b96245cb401eda8e8824.js.LICENSE.txt} +9 -0
- package/build/js/iframe.b96245cb401eda8e8824.js.map +1 -0
- package/build/onekey-js-sdk.js +738 -106
- package/build/onekey-js-sdk.js.map +1 -1
- package/build/onekey-js-sdk.min.js +1 -1
- package/build/onekey-js-sdk.min.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -1
- package/webpack/prod.webpack.config.ts +8 -0
- package/build/data/version.ts +0 -3
- package/build/js/iframe.ec4e851a910de94e22e4.js +0 -3
- package/build/js/iframe.ec4e851a910de94e22e4.js.map +0 -1
package/build/onekey-js-sdk.js
CHANGED
|
@@ -4031,6 +4031,8 @@ var axios = __webpack_require__(9644);
|
|
|
4031
4031
|
|
|
4032
4032
|
var BigNumber = __webpack_require__(6391);
|
|
4033
4033
|
|
|
4034
|
+
var sha256 = __webpack_require__(1965);
|
|
4035
|
+
|
|
4034
4036
|
var hdTransport = __webpack_require__(7495);
|
|
4035
4037
|
|
|
4036
4038
|
function _interopDefaultLegacy(e) {
|
|
@@ -4045,6 +4047,8 @@ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
|
4045
4047
|
|
|
4046
4048
|
var BigNumber__default = /*#__PURE__*/_interopDefaultLegacy(BigNumber);
|
|
4047
4049
|
|
|
4050
|
+
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
4051
|
+
|
|
4048
4052
|
const inject = ({
|
|
4049
4053
|
call,
|
|
4050
4054
|
cancel,
|
|
@@ -4086,6 +4090,9 @@ const inject = ({
|
|
|
4086
4090
|
checkTransportRelease: () => call({
|
|
4087
4091
|
method: 'checkTransportRelease'
|
|
4088
4092
|
}),
|
|
4093
|
+
checkBridgeStatus: () => call({
|
|
4094
|
+
method: 'checkBridgeStatus'
|
|
4095
|
+
}),
|
|
4089
4096
|
cipherKeyValue: (connectId, params) => call(Object.assign(Object.assign({}, params), {
|
|
4090
4097
|
connectId,
|
|
4091
4098
|
method: 'cipherKeyValue'
|
|
@@ -4778,92 +4785,6 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
|
|
|
4778
4785
|
}
|
|
4779
4786
|
}
|
|
4780
4787
|
|
|
4781
|
-
const colors = {
|
|
4782
|
-
'@onekey/connect': 'color: #f4a742; background: #000;',
|
|
4783
|
-
IFrame: 'color: #f4a742; background: #000;',
|
|
4784
|
-
Core: 'color: #f4a742; background: #000;',
|
|
4785
|
-
DescriptorStream: 'color: #77ab59; background: #000;',
|
|
4786
|
-
DeviceList: 'color: #77ab59; background: #000;',
|
|
4787
|
-
Device: 'color: #bada55; background: #000;',
|
|
4788
|
-
DeviceCommands: 'color: #bada55; background: #000;',
|
|
4789
|
-
DeviceConnector: 'color: #bada55; background: #000;',
|
|
4790
|
-
Transport: 'color: #ffb6c1; background: #000;'
|
|
4791
|
-
};
|
|
4792
|
-
const MAX_ENTRIES = 100;
|
|
4793
|
-
|
|
4794
|
-
class Log$6 {
|
|
4795
|
-
constructor(prefix, enabled) {
|
|
4796
|
-
this.prefix = prefix;
|
|
4797
|
-
this.enabled = enabled;
|
|
4798
|
-
this.messages = [];
|
|
4799
|
-
this.css = typeof window !== 'undefined' && colors[prefix] ? colors[prefix] : '';
|
|
4800
|
-
}
|
|
4801
|
-
|
|
4802
|
-
addMessage(level, prefix, ...args) {
|
|
4803
|
-
this.messages.push({
|
|
4804
|
-
level,
|
|
4805
|
-
prefix,
|
|
4806
|
-
message: args,
|
|
4807
|
-
timestamp: new Date().getTime()
|
|
4808
|
-
});
|
|
4809
|
-
|
|
4810
|
-
if (this.messages.length > MAX_ENTRIES) {
|
|
4811
|
-
this.messages.shift();
|
|
4812
|
-
}
|
|
4813
|
-
}
|
|
4814
|
-
|
|
4815
|
-
log(...args) {
|
|
4816
|
-
this.addMessage('log', this.prefix, ...args);
|
|
4817
|
-
|
|
4818
|
-
if (this.enabled) {
|
|
4819
|
-
console.log(this.prefix, ...args);
|
|
4820
|
-
}
|
|
4821
|
-
}
|
|
4822
|
-
|
|
4823
|
-
error(...args) {
|
|
4824
|
-
this.addMessage('error', this.prefix, ...args);
|
|
4825
|
-
|
|
4826
|
-
if (this.enabled) {
|
|
4827
|
-
console.error(this.prefix, ...args);
|
|
4828
|
-
}
|
|
4829
|
-
}
|
|
4830
|
-
|
|
4831
|
-
warn(...args) {
|
|
4832
|
-
this.addMessage('warn', this.prefix, ...args);
|
|
4833
|
-
|
|
4834
|
-
if (this.enabled) {
|
|
4835
|
-
console.warn(this.prefix, ...args);
|
|
4836
|
-
}
|
|
4837
|
-
}
|
|
4838
|
-
|
|
4839
|
-
debug(...args) {
|
|
4840
|
-
this.addMessage('debug', this.prefix, ...args);
|
|
4841
|
-
|
|
4842
|
-
if (this.enabled) {
|
|
4843
|
-
if (this.css) {
|
|
4844
|
-
console.log(`%c${this.prefix}`, this.css, ...args);
|
|
4845
|
-
} else {
|
|
4846
|
-
console.log(this.prefix, ...args);
|
|
4847
|
-
}
|
|
4848
|
-
}
|
|
4849
|
-
}
|
|
4850
|
-
|
|
4851
|
-
}
|
|
4852
|
-
|
|
4853
|
-
const _logs = {};
|
|
4854
|
-
|
|
4855
|
-
const initLog = (prefix, enabled) => {
|
|
4856
|
-
const instance = new Log$6(prefix, !!enabled);
|
|
4857
|
-
_logs[prefix] = instance;
|
|
4858
|
-
return instance;
|
|
4859
|
-
};
|
|
4860
|
-
|
|
4861
|
-
const enableLog = enabled => {
|
|
4862
|
-
Object.keys(_logs).forEach(key => {
|
|
4863
|
-
_logs[key].enabled = !!enabled;
|
|
4864
|
-
});
|
|
4865
|
-
};
|
|
4866
|
-
|
|
4867
4788
|
const httpRequest$1 = (url, type = 'text') => __awaiter(void 0, void 0, void 0, function* () {
|
|
4868
4789
|
const response = yield axios__default["default"].request({
|
|
4869
4790
|
url,
|
|
@@ -14027,7 +13948,7 @@ DataManager.getTransportStatus = localVersion => {
|
|
|
14027
13948
|
return isLatest ? 'valid' : 'outdated';
|
|
14028
13949
|
};
|
|
14029
13950
|
|
|
14030
|
-
const Log$5 = initLog('Transport');
|
|
13951
|
+
const Log$5 = hdShared.initLog('Transport');
|
|
14031
13952
|
|
|
14032
13953
|
class TransportManager {
|
|
14033
13954
|
static load() {
|
|
@@ -14233,11 +14154,11 @@ const assertType = (res, resType) => {
|
|
|
14233
14154
|
const splitResTypes = Array.isArray(resType) ? resType : resType.split('|');
|
|
14234
14155
|
|
|
14235
14156
|
if (!splitResTypes.includes(res.type)) {
|
|
14236
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.
|
|
14157
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.ResponseUnexpectTypeError, `assertType: Response of unexpected type: ${res.type}. Should be ${resType}`);
|
|
14237
14158
|
}
|
|
14238
14159
|
};
|
|
14239
14160
|
|
|
14240
|
-
const Log$4 = initLog('DeviceCommands');
|
|
14161
|
+
const Log$4 = hdShared.initLog('DeviceCommands');
|
|
14241
14162
|
|
|
14242
14163
|
class DeviceCommands {
|
|
14243
14164
|
constructor(device, mainId) {
|
|
@@ -14261,8 +14182,10 @@ class DeviceCommands {
|
|
|
14261
14182
|
}
|
|
14262
14183
|
|
|
14263
14184
|
call(type, msg = {}) {
|
|
14185
|
+
var _a, _b;
|
|
14186
|
+
|
|
14264
14187
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14265
|
-
console.log('[DeviceCommands] [call] Sending', type
|
|
14188
|
+
console.log('[DeviceCommands] [call] Sending', type);
|
|
14266
14189
|
|
|
14267
14190
|
try {
|
|
14268
14191
|
const promise = this.transport.call(this.mainId, type, msg);
|
|
@@ -14272,6 +14195,14 @@ class DeviceCommands {
|
|
|
14272
14195
|
return res;
|
|
14273
14196
|
} catch (error) {
|
|
14274
14197
|
Log$4.debug('[DeviceCommands] [call] Received error', error);
|
|
14198
|
+
|
|
14199
|
+
if (((_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === 'device disconnected during action') {
|
|
14200
|
+
return {
|
|
14201
|
+
type: 'BridgeNetworkError',
|
|
14202
|
+
message: {}
|
|
14203
|
+
};
|
|
14204
|
+
}
|
|
14205
|
+
|
|
14275
14206
|
throw error;
|
|
14276
14207
|
}
|
|
14277
14208
|
});
|
|
@@ -14289,7 +14220,16 @@ class DeviceCommands {
|
|
|
14289
14220
|
assertType(response, resType);
|
|
14290
14221
|
} catch (error) {
|
|
14291
14222
|
console.log('DeviceCommands typedcall error: ', error);
|
|
14292
|
-
|
|
14223
|
+
|
|
14224
|
+
if (error instanceof hdShared.HardwareError) {
|
|
14225
|
+
if (error.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError) {
|
|
14226
|
+
if (error.message.indexOf('BridgeNetworkError') > -1) {
|
|
14227
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeNetworkError);
|
|
14228
|
+
}
|
|
14229
|
+
}
|
|
14230
|
+
} else {
|
|
14231
|
+
throw error;
|
|
14232
|
+
}
|
|
14293
14233
|
}
|
|
14294
14234
|
|
|
14295
14235
|
return response;
|
|
@@ -14406,12 +14346,11 @@ const UI_REQUEST = {
|
|
|
14406
14346
|
FIRMWARE_NOT_INSTALLED: 'ui-device_firmware_not_installed',
|
|
14407
14347
|
NOT_USE_ONEKEY_DEVICE: 'ui-device_please_use_onekey_device'
|
|
14408
14348
|
};
|
|
14409
|
-
const
|
|
14410
|
-
const DEFAULT_DOMAIN = `https://hardware-sdk.onekey.so/`;
|
|
14349
|
+
const DEFAULT_DOMAIN = `https://jssdk.onekey.so/`;
|
|
14411
14350
|
const DEFAULT_PRIORITY = 2;
|
|
14412
14351
|
const initialSettings = {
|
|
14413
14352
|
configSrc: './data/config.json',
|
|
14414
|
-
version:
|
|
14353
|
+
version: '',
|
|
14415
14354
|
debug: false,
|
|
14416
14355
|
priority: DEFAULT_PRIORITY,
|
|
14417
14356
|
trustedHost: false,
|
|
@@ -14508,7 +14447,7 @@ const parseRunOptions = options => {
|
|
|
14508
14447
|
return options;
|
|
14509
14448
|
};
|
|
14510
14449
|
|
|
14511
|
-
const Log$3 = initLog('Device');
|
|
14450
|
+
const Log$3 = hdShared.initLog('Device');
|
|
14512
14451
|
|
|
14513
14452
|
class Device extends events.exports {
|
|
14514
14453
|
constructor(descriptor) {
|
|
@@ -14870,7 +14809,7 @@ class Device extends events.exports {
|
|
|
14870
14809
|
}
|
|
14871
14810
|
|
|
14872
14811
|
const cacheDeviceMap = new Map();
|
|
14873
|
-
const Log$2 = initLog('DeviceList');
|
|
14812
|
+
const Log$2 = hdShared.initLog('DeviceList');
|
|
14874
14813
|
|
|
14875
14814
|
class DeviceList extends events.exports {
|
|
14876
14815
|
constructor() {
|
|
@@ -16345,6 +16284,25 @@ class CheckTransportRelease extends BaseMethod {
|
|
|
16345
16284
|
|
|
16346
16285
|
}
|
|
16347
16286
|
|
|
16287
|
+
class CheckBridgeStatus extends BaseMethod {
|
|
16288
|
+
init() {
|
|
16289
|
+
this.useDevice = false;
|
|
16290
|
+
}
|
|
16291
|
+
|
|
16292
|
+
run() {
|
|
16293
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16294
|
+
return new Promise(resolve => {
|
|
16295
|
+
axios__default["default"].request({
|
|
16296
|
+
url: 'http://localhost:21320',
|
|
16297
|
+
method: 'POST',
|
|
16298
|
+
withCredentials: false
|
|
16299
|
+
}).then(() => resolve(true)).catch(() => resolve(false));
|
|
16300
|
+
});
|
|
16301
|
+
});
|
|
16302
|
+
}
|
|
16303
|
+
|
|
16304
|
+
}
|
|
16305
|
+
|
|
16348
16306
|
class DeviceBackup extends BaseMethod {
|
|
16349
16307
|
init() {}
|
|
16350
16308
|
|
|
@@ -16613,7 +16571,9 @@ class DeviceVerify extends BaseMethod {
|
|
|
16613
16571
|
let response;
|
|
16614
16572
|
|
|
16615
16573
|
if (deviceType === 'classic') {
|
|
16616
|
-
const res = yield this.device.commands.typedCall('BixinVerifyDeviceRequest', 'BixinVerifyDeviceAck', Object.assign({}, this.params)
|
|
16574
|
+
const res = yield this.device.commands.typedCall('BixinVerifyDeviceRequest', 'BixinVerifyDeviceAck', Object.assign(Object.assign({}, this.params), {
|
|
16575
|
+
data: sha256__default["default"].sha256(this.params.data)
|
|
16576
|
+
}));
|
|
16617
16577
|
response = res.message;
|
|
16618
16578
|
} else if (deviceType === 'mini') {
|
|
16619
16579
|
const signatureRes = yield this.device.commands.typedCall('SESignMessage', 'SEMessageSignature', {
|
|
@@ -18584,6 +18544,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
|
|
|
18584
18544
|
checkFirmwareRelease: CheckFirmwareRelease,
|
|
18585
18545
|
checkBLEFirmwareRelease: CheckBLEFirmwareRelease,
|
|
18586
18546
|
checkTransportRelease: CheckTransportRelease,
|
|
18547
|
+
checkBridgeStatus: CheckBridgeStatus,
|
|
18587
18548
|
deviceBackup: DeviceBackup,
|
|
18588
18549
|
deviceChangePin: DeviceChangePin,
|
|
18589
18550
|
deviceFlags: DeviceFlags,
|
|
@@ -18645,7 +18606,7 @@ const resolveAfter = (msec, value) => new Promise(resolve => {
|
|
|
18645
18606
|
setTimeout(resolve, msec, value);
|
|
18646
18607
|
});
|
|
18647
18608
|
|
|
18648
|
-
const Log$1 = initLog('DeviceConnector');
|
|
18609
|
+
const Log$1 = hdShared.initLog('DeviceConnector');
|
|
18649
18610
|
|
|
18650
18611
|
const getDiff = (current, descriptors) => {
|
|
18651
18612
|
const env = DataManager.getSettings('env');
|
|
@@ -18801,7 +18762,7 @@ class DeviceConnector {
|
|
|
18801
18762
|
|
|
18802
18763
|
}
|
|
18803
18764
|
|
|
18804
|
-
const Log = initLog('Core');
|
|
18765
|
+
const Log = hdShared.initLog('Core');
|
|
18805
18766
|
|
|
18806
18767
|
let _core;
|
|
18807
18768
|
|
|
@@ -18907,7 +18868,7 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
18907
18868
|
|
|
18908
18869
|
try {
|
|
18909
18870
|
const response = yield method.run();
|
|
18910
|
-
Log.debug('Call API - Inner Method Run: '
|
|
18871
|
+
Log.debug('Call API - Inner Method Run: ');
|
|
18911
18872
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
18912
18873
|
_callPromise === null || _callPromise === void 0 ? void 0 : _callPromise.resolve(messageResponse);
|
|
18913
18874
|
} catch (error) {
|
|
@@ -19166,7 +19127,7 @@ const init = (settings, Transport) => __awaiter(void 0, void 0, void 0, function
|
|
|
19166
19127
|
Log.error('DataManager.load error');
|
|
19167
19128
|
}
|
|
19168
19129
|
|
|
19169
|
-
enableLog(DataManager.getSettings('debug'));
|
|
19130
|
+
hdShared.enableLog(DataManager.getSettings('debug'));
|
|
19170
19131
|
initCore();
|
|
19171
19132
|
initConnector();
|
|
19172
19133
|
return _core;
|
|
@@ -19191,6 +19152,18 @@ const HardwareSdk = ({
|
|
|
19191
19152
|
cancel
|
|
19192
19153
|
});
|
|
19193
19154
|
|
|
19155
|
+
Object.defineProperty(exports, "yI", ({
|
|
19156
|
+
enumerable: true,
|
|
19157
|
+
get: function () {
|
|
19158
|
+
return hdShared.enableLog;
|
|
19159
|
+
}
|
|
19160
|
+
}));
|
|
19161
|
+
Object.defineProperty(exports, "KR", ({
|
|
19162
|
+
enumerable: true,
|
|
19163
|
+
get: function () {
|
|
19164
|
+
return hdShared.initLog;
|
|
19165
|
+
}
|
|
19166
|
+
}));
|
|
19194
19167
|
__webpack_unused_export__ = ({
|
|
19195
19168
|
enumerable: true,
|
|
19196
19169
|
get: function () {
|
|
@@ -19216,7 +19189,6 @@ __webpack_unused_export__ = createResponseMessage;
|
|
|
19216
19189
|
__webpack_unused_export__ = createUiMessage;
|
|
19217
19190
|
__webpack_unused_export__ = createUiResponse;
|
|
19218
19191
|
exports.ZP = HardwareSdk;
|
|
19219
|
-
exports.yI = enableLog;
|
|
19220
19192
|
__webpack_unused_export__ = getDeviceLabel;
|
|
19221
19193
|
__webpack_unused_export__ = getDeviceType;
|
|
19222
19194
|
__webpack_unused_export__ = getDeviceTypeByBleName;
|
|
@@ -19228,7 +19200,6 @@ __webpack_unused_export__ = getScriptType;
|
|
|
19228
19200
|
__webpack_unused_export__ = getTimeStamp;
|
|
19229
19201
|
__webpack_unused_export__ = httpRequest;
|
|
19230
19202
|
__webpack_unused_export__ = init;
|
|
19231
|
-
exports.KR = initLog;
|
|
19232
19203
|
__webpack_unused_export__ = isValidVersionArray;
|
|
19233
19204
|
__webpack_unused_export__ = isValidVersionString;
|
|
19234
19205
|
__webpack_unused_export__ = normalizeVersionArray;
|
|
@@ -20416,7 +20387,9 @@ const HardwareErrorCode = {
|
|
|
20416
20387
|
PinInvalid: 801,
|
|
20417
20388
|
PinCancelled: 802,
|
|
20418
20389
|
ActionCancelled: 803,
|
|
20419
|
-
FirmwareError: 804
|
|
20390
|
+
FirmwareError: 804,
|
|
20391
|
+
ResponseUnexpectTypeError: 805,
|
|
20392
|
+
BridgeNetworkError: 806
|
|
20420
20393
|
};
|
|
20421
20394
|
const HardwareErrorCodeMessage = {
|
|
20422
20395
|
[HardwareErrorCode.UnknownError]: 'Unknown error occurred. Check message property.',
|
|
@@ -20457,7 +20430,9 @@ const HardwareErrorCodeMessage = {
|
|
|
20457
20430
|
[HardwareErrorCode.PinInvalid]: 'Pin invalid',
|
|
20458
20431
|
[HardwareErrorCode.PinCancelled]: 'Pin cancelled',
|
|
20459
20432
|
[HardwareErrorCode.ActionCancelled]: 'Action cancelled by user',
|
|
20460
|
-
[HardwareErrorCode.FirmwareError]: 'Firmware installation failed'
|
|
20433
|
+
[HardwareErrorCode.FirmwareError]: 'Firmware installation failed',
|
|
20434
|
+
[HardwareErrorCode.ResponseUnexpectTypeError]: 'Response type is not expected',
|
|
20435
|
+
[HardwareErrorCode.BridgeNetworkError]: 'Bridge network error'
|
|
20461
20436
|
};
|
|
20462
20437
|
|
|
20463
20438
|
const TypedError = (hardwareError, message) => {
|
|
@@ -20497,13 +20472,137 @@ var HardwareError$1 = /*#__PURE__*/Object.freeze({
|
|
|
20497
20472
|
TypedError: TypedError,
|
|
20498
20473
|
serializeError: serializeError
|
|
20499
20474
|
});
|
|
20475
|
+
const MAX_ENTRIES = 100;
|
|
20476
|
+
|
|
20477
|
+
class Log {
|
|
20478
|
+
constructor(prefix, enabled, logger) {
|
|
20479
|
+
this.prefix = prefix;
|
|
20480
|
+
this.enabled = enabled;
|
|
20481
|
+
this.messages = [];
|
|
20482
|
+
|
|
20483
|
+
if (logger) {
|
|
20484
|
+
this.logger = logger;
|
|
20485
|
+
}
|
|
20486
|
+
}
|
|
20487
|
+
|
|
20488
|
+
addMessage(level, prefix, ...args) {
|
|
20489
|
+
this.messages.push({
|
|
20490
|
+
level,
|
|
20491
|
+
prefix,
|
|
20492
|
+
message: args,
|
|
20493
|
+
timestamp: new Date().getTime()
|
|
20494
|
+
});
|
|
20495
|
+
|
|
20496
|
+
if (this.messages.length > MAX_ENTRIES) {
|
|
20497
|
+
this.messages.shift();
|
|
20498
|
+
}
|
|
20499
|
+
}
|
|
20500
|
+
|
|
20501
|
+
log(...args) {
|
|
20502
|
+
this.addMessage('log', this.prefix, ...args);
|
|
20503
|
+
|
|
20504
|
+
if (!this.enabled) {
|
|
20505
|
+
return;
|
|
20506
|
+
}
|
|
20507
|
+
|
|
20508
|
+
if (this.logger) {
|
|
20509
|
+
this.logger.info(this.prefix, ...args);
|
|
20510
|
+
} else {
|
|
20511
|
+
console.log(this.prefix, ...args);
|
|
20512
|
+
}
|
|
20513
|
+
}
|
|
20514
|
+
|
|
20515
|
+
error(...args) {
|
|
20516
|
+
this.addMessage('error', this.prefix, ...args);
|
|
20517
|
+
|
|
20518
|
+
if (!this.enabled) {
|
|
20519
|
+
return;
|
|
20520
|
+
}
|
|
20521
|
+
|
|
20522
|
+
if (this.logger) {
|
|
20523
|
+
this.logger.error(this.prefix, ...args);
|
|
20524
|
+
} else {
|
|
20525
|
+
console.error(this.prefix, ...args);
|
|
20526
|
+
}
|
|
20527
|
+
}
|
|
20528
|
+
|
|
20529
|
+
warn(...args) {
|
|
20530
|
+
this.addMessage('warn', this.prefix, ...args);
|
|
20531
|
+
|
|
20532
|
+
if (!this.enabled) {
|
|
20533
|
+
return;
|
|
20534
|
+
}
|
|
20535
|
+
|
|
20536
|
+
if (this.logger) {
|
|
20537
|
+
this.logger.warn(this.prefix, ...args);
|
|
20538
|
+
} else {
|
|
20539
|
+
console.warn(this.prefix, ...args);
|
|
20540
|
+
}
|
|
20541
|
+
}
|
|
20542
|
+
|
|
20543
|
+
debug(...args) {
|
|
20544
|
+
this.addMessage('debug', this.prefix, ...args);
|
|
20545
|
+
|
|
20546
|
+
if (!this.enabled) {
|
|
20547
|
+
return;
|
|
20548
|
+
}
|
|
20549
|
+
|
|
20550
|
+
if (this.logger) {
|
|
20551
|
+
this.logger.debug(this.prefix, ...args);
|
|
20552
|
+
} else {
|
|
20553
|
+
console.log(this.prefix, ...args);
|
|
20554
|
+
}
|
|
20555
|
+
}
|
|
20556
|
+
|
|
20557
|
+
}
|
|
20558
|
+
|
|
20559
|
+
const _logs = {};
|
|
20560
|
+
|
|
20561
|
+
const initLog = (prefix, enabled, logger) => {
|
|
20562
|
+
const instance = new Log(prefix, !!enabled, logger);
|
|
20563
|
+
_logs[prefix] = instance;
|
|
20564
|
+
return instance;
|
|
20565
|
+
};
|
|
20566
|
+
|
|
20567
|
+
const enableLog = enabled => {
|
|
20568
|
+
Object.keys(_logs).forEach(key => {
|
|
20569
|
+
_logs[key].enabled = !!enabled;
|
|
20570
|
+
});
|
|
20571
|
+
};
|
|
20572
|
+
|
|
20573
|
+
const setOutsideLogger = logger => {
|
|
20574
|
+
Object.keys(_logs).forEach(key => {
|
|
20575
|
+
_logs[key].logger = logger;
|
|
20576
|
+
});
|
|
20577
|
+
};
|
|
20578
|
+
|
|
20579
|
+
const enableLogByPrefix = (prefix, enabled) => {
|
|
20580
|
+
if (_logs[prefix]) {
|
|
20581
|
+
_logs[prefix].enabled = enabled;
|
|
20582
|
+
}
|
|
20583
|
+
};
|
|
20584
|
+
|
|
20585
|
+
const getLog = () => {
|
|
20586
|
+
let logs = [];
|
|
20587
|
+
Object.keys(_logs).forEach(key => {
|
|
20588
|
+
logs = logs.concat(_logs[key].messages);
|
|
20589
|
+
});
|
|
20590
|
+
logs.sort((a, b) => a.timestamp - b.timestamp);
|
|
20591
|
+
return logs;
|
|
20592
|
+
};
|
|
20593
|
+
|
|
20500
20594
|
exports.ERRORS = HardwareError$1;
|
|
20501
20595
|
exports.HardwareError = HardwareError;
|
|
20502
20596
|
exports.HardwareErrorCode = HardwareErrorCode;
|
|
20503
20597
|
exports.HardwareErrorCodeMessage = HardwareErrorCodeMessage;
|
|
20504
20598
|
exports.TypedError = TypedError;
|
|
20505
20599
|
exports.createDeferred = createDeferred;
|
|
20600
|
+
exports.enableLog = enableLog;
|
|
20601
|
+
exports.enableLogByPrefix = enableLogByPrefix;
|
|
20602
|
+
exports.getLog = getLog;
|
|
20603
|
+
exports.initLog = initLog;
|
|
20506
20604
|
exports.serializeError = serializeError;
|
|
20605
|
+
exports.setOutsideLogger = setOutsideLogger;
|
|
20507
20606
|
|
|
20508
20607
|
/***/ }),
|
|
20509
20608
|
|
|
@@ -31189,6 +31288,532 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
|
31189
31288
|
}
|
|
31190
31289
|
|
|
31191
31290
|
|
|
31291
|
+
/***/ }),
|
|
31292
|
+
|
|
31293
|
+
/***/ 1965:
|
|
31294
|
+
/***/ ((module, exports, __webpack_require__) => {
|
|
31295
|
+
|
|
31296
|
+
var __WEBPACK_AMD_DEFINE_RESULT__;/**
|
|
31297
|
+
* [js-sha256]{@link https://github.com/emn178/js-sha256}
|
|
31298
|
+
*
|
|
31299
|
+
* @version 0.9.0
|
|
31300
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
31301
|
+
* @copyright Chen, Yi-Cyuan 2014-2017
|
|
31302
|
+
* @license MIT
|
|
31303
|
+
*/
|
|
31304
|
+
/*jslint bitwise: true */
|
|
31305
|
+
(function () {
|
|
31306
|
+
'use strict';
|
|
31307
|
+
|
|
31308
|
+
var ERROR = 'input is invalid type';
|
|
31309
|
+
var WINDOW = typeof window === 'object';
|
|
31310
|
+
var root = WINDOW ? window : {};
|
|
31311
|
+
if (root.JS_SHA256_NO_WINDOW) {
|
|
31312
|
+
WINDOW = false;
|
|
31313
|
+
}
|
|
31314
|
+
var WEB_WORKER = !WINDOW && typeof self === 'object';
|
|
31315
|
+
var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
|
|
31316
|
+
if (NODE_JS) {
|
|
31317
|
+
root = __webpack_require__.g;
|
|
31318
|
+
} else if (WEB_WORKER) {
|
|
31319
|
+
root = self;
|
|
31320
|
+
}
|
|
31321
|
+
var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && "object" === 'object' && module.exports;
|
|
31322
|
+
var AMD = true && __webpack_require__.amdO;
|
|
31323
|
+
var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
|
|
31324
|
+
var HEX_CHARS = '0123456789abcdef'.split('');
|
|
31325
|
+
var EXTRA = [-2147483648, 8388608, 32768, 128];
|
|
31326
|
+
var SHIFT = [24, 16, 8, 0];
|
|
31327
|
+
var K = [
|
|
31328
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
31329
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
31330
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
31331
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
31332
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
31333
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
31334
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
31335
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
31336
|
+
];
|
|
31337
|
+
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];
|
|
31338
|
+
|
|
31339
|
+
var blocks = [];
|
|
31340
|
+
|
|
31341
|
+
if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) {
|
|
31342
|
+
Array.isArray = function (obj) {
|
|
31343
|
+
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
31344
|
+
};
|
|
31345
|
+
}
|
|
31346
|
+
|
|
31347
|
+
if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
|
|
31348
|
+
ArrayBuffer.isView = function (obj) {
|
|
31349
|
+
return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
|
|
31350
|
+
};
|
|
31351
|
+
}
|
|
31352
|
+
|
|
31353
|
+
var createOutputMethod = function (outputType, is224) {
|
|
31354
|
+
return function (message) {
|
|
31355
|
+
return new Sha256(is224, true).update(message)[outputType]();
|
|
31356
|
+
};
|
|
31357
|
+
};
|
|
31358
|
+
|
|
31359
|
+
var createMethod = function (is224) {
|
|
31360
|
+
var method = createOutputMethod('hex', is224);
|
|
31361
|
+
if (NODE_JS) {
|
|
31362
|
+
method = nodeWrap(method, is224);
|
|
31363
|
+
}
|
|
31364
|
+
method.create = function () {
|
|
31365
|
+
return new Sha256(is224);
|
|
31366
|
+
};
|
|
31367
|
+
method.update = function (message) {
|
|
31368
|
+
return method.create().update(message);
|
|
31369
|
+
};
|
|
31370
|
+
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
|
31371
|
+
var type = OUTPUT_TYPES[i];
|
|
31372
|
+
method[type] = createOutputMethod(type, is224);
|
|
31373
|
+
}
|
|
31374
|
+
return method;
|
|
31375
|
+
};
|
|
31376
|
+
|
|
31377
|
+
var nodeWrap = function (method, is224) {
|
|
31378
|
+
var crypto = eval("require('crypto')");
|
|
31379
|
+
var Buffer = eval("require('buffer').Buffer");
|
|
31380
|
+
var algorithm = is224 ? 'sha224' : 'sha256';
|
|
31381
|
+
var nodeMethod = function (message) {
|
|
31382
|
+
if (typeof message === 'string') {
|
|
31383
|
+
return crypto.createHash(algorithm).update(message, 'utf8').digest('hex');
|
|
31384
|
+
} else {
|
|
31385
|
+
if (message === null || message === undefined) {
|
|
31386
|
+
throw new Error(ERROR);
|
|
31387
|
+
} else if (message.constructor === ArrayBuffer) {
|
|
31388
|
+
message = new Uint8Array(message);
|
|
31389
|
+
}
|
|
31390
|
+
}
|
|
31391
|
+
if (Array.isArray(message) || ArrayBuffer.isView(message) ||
|
|
31392
|
+
message.constructor === Buffer) {
|
|
31393
|
+
return crypto.createHash(algorithm).update(new Buffer(message)).digest('hex');
|
|
31394
|
+
} else {
|
|
31395
|
+
return method(message);
|
|
31396
|
+
}
|
|
31397
|
+
};
|
|
31398
|
+
return nodeMethod;
|
|
31399
|
+
};
|
|
31400
|
+
|
|
31401
|
+
var createHmacOutputMethod = function (outputType, is224) {
|
|
31402
|
+
return function (key, message) {
|
|
31403
|
+
return new HmacSha256(key, is224, true).update(message)[outputType]();
|
|
31404
|
+
};
|
|
31405
|
+
};
|
|
31406
|
+
|
|
31407
|
+
var createHmacMethod = function (is224) {
|
|
31408
|
+
var method = createHmacOutputMethod('hex', is224);
|
|
31409
|
+
method.create = function (key) {
|
|
31410
|
+
return new HmacSha256(key, is224);
|
|
31411
|
+
};
|
|
31412
|
+
method.update = function (key, message) {
|
|
31413
|
+
return method.create(key).update(message);
|
|
31414
|
+
};
|
|
31415
|
+
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
|
|
31416
|
+
var type = OUTPUT_TYPES[i];
|
|
31417
|
+
method[type] = createHmacOutputMethod(type, is224);
|
|
31418
|
+
}
|
|
31419
|
+
return method;
|
|
31420
|
+
};
|
|
31421
|
+
|
|
31422
|
+
function Sha256(is224, sharedMemory) {
|
|
31423
|
+
if (sharedMemory) {
|
|
31424
|
+
blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
31425
|
+
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
31426
|
+
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
31427
|
+
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
31428
|
+
this.blocks = blocks;
|
|
31429
|
+
} else {
|
|
31430
|
+
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
31431
|
+
}
|
|
31432
|
+
|
|
31433
|
+
if (is224) {
|
|
31434
|
+
this.h0 = 0xc1059ed8;
|
|
31435
|
+
this.h1 = 0x367cd507;
|
|
31436
|
+
this.h2 = 0x3070dd17;
|
|
31437
|
+
this.h3 = 0xf70e5939;
|
|
31438
|
+
this.h4 = 0xffc00b31;
|
|
31439
|
+
this.h5 = 0x68581511;
|
|
31440
|
+
this.h6 = 0x64f98fa7;
|
|
31441
|
+
this.h7 = 0xbefa4fa4;
|
|
31442
|
+
} else { // 256
|
|
31443
|
+
this.h0 = 0x6a09e667;
|
|
31444
|
+
this.h1 = 0xbb67ae85;
|
|
31445
|
+
this.h2 = 0x3c6ef372;
|
|
31446
|
+
this.h3 = 0xa54ff53a;
|
|
31447
|
+
this.h4 = 0x510e527f;
|
|
31448
|
+
this.h5 = 0x9b05688c;
|
|
31449
|
+
this.h6 = 0x1f83d9ab;
|
|
31450
|
+
this.h7 = 0x5be0cd19;
|
|
31451
|
+
}
|
|
31452
|
+
|
|
31453
|
+
this.block = this.start = this.bytes = this.hBytes = 0;
|
|
31454
|
+
this.finalized = this.hashed = false;
|
|
31455
|
+
this.first = true;
|
|
31456
|
+
this.is224 = is224;
|
|
31457
|
+
}
|
|
31458
|
+
|
|
31459
|
+
Sha256.prototype.update = function (message) {
|
|
31460
|
+
if (this.finalized) {
|
|
31461
|
+
return;
|
|
31462
|
+
}
|
|
31463
|
+
var notString, type = typeof message;
|
|
31464
|
+
if (type !== 'string') {
|
|
31465
|
+
if (type === 'object') {
|
|
31466
|
+
if (message === null) {
|
|
31467
|
+
throw new Error(ERROR);
|
|
31468
|
+
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
|
|
31469
|
+
message = new Uint8Array(message);
|
|
31470
|
+
} else if (!Array.isArray(message)) {
|
|
31471
|
+
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
|
|
31472
|
+
throw new Error(ERROR);
|
|
31473
|
+
}
|
|
31474
|
+
}
|
|
31475
|
+
} else {
|
|
31476
|
+
throw new Error(ERROR);
|
|
31477
|
+
}
|
|
31478
|
+
notString = true;
|
|
31479
|
+
}
|
|
31480
|
+
var code, index = 0, i, length = message.length, blocks = this.blocks;
|
|
31481
|
+
|
|
31482
|
+
while (index < length) {
|
|
31483
|
+
if (this.hashed) {
|
|
31484
|
+
this.hashed = false;
|
|
31485
|
+
blocks[0] = this.block;
|
|
31486
|
+
blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
31487
|
+
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
31488
|
+
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
31489
|
+
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
31490
|
+
}
|
|
31491
|
+
|
|
31492
|
+
if (notString) {
|
|
31493
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
31494
|
+
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
|
|
31495
|
+
}
|
|
31496
|
+
} else {
|
|
31497
|
+
for (i = this.start; index < length && i < 64; ++index) {
|
|
31498
|
+
code = message.charCodeAt(index);
|
|
31499
|
+
if (code < 0x80) {
|
|
31500
|
+
blocks[i >> 2] |= code << SHIFT[i++ & 3];
|
|
31501
|
+
} else if (code < 0x800) {
|
|
31502
|
+
blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
|
|
31503
|
+
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
31504
|
+
} else if (code < 0xd800 || code >= 0xe000) {
|
|
31505
|
+
blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
|
|
31506
|
+
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
31507
|
+
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
31508
|
+
} else {
|
|
31509
|
+
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
|
|
31510
|
+
blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
|
|
31511
|
+
blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
|
|
31512
|
+
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
|
31513
|
+
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
|
31514
|
+
}
|
|
31515
|
+
}
|
|
31516
|
+
}
|
|
31517
|
+
|
|
31518
|
+
this.lastByteIndex = i;
|
|
31519
|
+
this.bytes += i - this.start;
|
|
31520
|
+
if (i >= 64) {
|
|
31521
|
+
this.block = blocks[16];
|
|
31522
|
+
this.start = i - 64;
|
|
31523
|
+
this.hash();
|
|
31524
|
+
this.hashed = true;
|
|
31525
|
+
} else {
|
|
31526
|
+
this.start = i;
|
|
31527
|
+
}
|
|
31528
|
+
}
|
|
31529
|
+
if (this.bytes > 4294967295) {
|
|
31530
|
+
this.hBytes += this.bytes / 4294967296 << 0;
|
|
31531
|
+
this.bytes = this.bytes % 4294967296;
|
|
31532
|
+
}
|
|
31533
|
+
return this;
|
|
31534
|
+
};
|
|
31535
|
+
|
|
31536
|
+
Sha256.prototype.finalize = function () {
|
|
31537
|
+
if (this.finalized) {
|
|
31538
|
+
return;
|
|
31539
|
+
}
|
|
31540
|
+
this.finalized = true;
|
|
31541
|
+
var blocks = this.blocks, i = this.lastByteIndex;
|
|
31542
|
+
blocks[16] = this.block;
|
|
31543
|
+
blocks[i >> 2] |= EXTRA[i & 3];
|
|
31544
|
+
this.block = blocks[16];
|
|
31545
|
+
if (i >= 56) {
|
|
31546
|
+
if (!this.hashed) {
|
|
31547
|
+
this.hash();
|
|
31548
|
+
}
|
|
31549
|
+
blocks[0] = this.block;
|
|
31550
|
+
blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
|
31551
|
+
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
|
31552
|
+
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
|
31553
|
+
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
|
31554
|
+
}
|
|
31555
|
+
blocks[14] = this.hBytes << 3 | this.bytes >>> 29;
|
|
31556
|
+
blocks[15] = this.bytes << 3;
|
|
31557
|
+
this.hash();
|
|
31558
|
+
};
|
|
31559
|
+
|
|
31560
|
+
Sha256.prototype.hash = function () {
|
|
31561
|
+
var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6,
|
|
31562
|
+
h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc;
|
|
31563
|
+
|
|
31564
|
+
for (j = 16; j < 64; ++j) {
|
|
31565
|
+
// rightrotate
|
|
31566
|
+
t1 = blocks[j - 15];
|
|
31567
|
+
s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3);
|
|
31568
|
+
t1 = blocks[j - 2];
|
|
31569
|
+
s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10);
|
|
31570
|
+
blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0;
|
|
31571
|
+
}
|
|
31572
|
+
|
|
31573
|
+
bc = b & c;
|
|
31574
|
+
for (j = 0; j < 64; j += 4) {
|
|
31575
|
+
if (this.first) {
|
|
31576
|
+
if (this.is224) {
|
|
31577
|
+
ab = 300032;
|
|
31578
|
+
t1 = blocks[0] - 1413257819;
|
|
31579
|
+
h = t1 - 150054599 << 0;
|
|
31580
|
+
d = t1 + 24177077 << 0;
|
|
31581
|
+
} else {
|
|
31582
|
+
ab = 704751109;
|
|
31583
|
+
t1 = blocks[0] - 210244248;
|
|
31584
|
+
h = t1 - 1521486534 << 0;
|
|
31585
|
+
d = t1 + 143694565 << 0;
|
|
31586
|
+
}
|
|
31587
|
+
this.first = false;
|
|
31588
|
+
} else {
|
|
31589
|
+
s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
|
|
31590
|
+
s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
|
|
31591
|
+
ab = a & b;
|
|
31592
|
+
maj = ab ^ (a & c) ^ bc;
|
|
31593
|
+
ch = (e & f) ^ (~e & g);
|
|
31594
|
+
t1 = h + s1 + ch + K[j] + blocks[j];
|
|
31595
|
+
t2 = s0 + maj;
|
|
31596
|
+
h = d + t1 << 0;
|
|
31597
|
+
d = t1 + t2 << 0;
|
|
31598
|
+
}
|
|
31599
|
+
s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10));
|
|
31600
|
+
s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7));
|
|
31601
|
+
da = d & a;
|
|
31602
|
+
maj = da ^ (d & b) ^ ab;
|
|
31603
|
+
ch = (h & e) ^ (~h & f);
|
|
31604
|
+
t1 = g + s1 + ch + K[j + 1] + blocks[j + 1];
|
|
31605
|
+
t2 = s0 + maj;
|
|
31606
|
+
g = c + t1 << 0;
|
|
31607
|
+
c = t1 + t2 << 0;
|
|
31608
|
+
s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10));
|
|
31609
|
+
s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7));
|
|
31610
|
+
cd = c & d;
|
|
31611
|
+
maj = cd ^ (c & a) ^ da;
|
|
31612
|
+
ch = (g & h) ^ (~g & e);
|
|
31613
|
+
t1 = f + s1 + ch + K[j + 2] + blocks[j + 2];
|
|
31614
|
+
t2 = s0 + maj;
|
|
31615
|
+
f = b + t1 << 0;
|
|
31616
|
+
b = t1 + t2 << 0;
|
|
31617
|
+
s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10));
|
|
31618
|
+
s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7));
|
|
31619
|
+
bc = b & c;
|
|
31620
|
+
maj = bc ^ (b & d) ^ cd;
|
|
31621
|
+
ch = (f & g) ^ (~f & h);
|
|
31622
|
+
t1 = e + s1 + ch + K[j + 3] + blocks[j + 3];
|
|
31623
|
+
t2 = s0 + maj;
|
|
31624
|
+
e = a + t1 << 0;
|
|
31625
|
+
a = t1 + t2 << 0;
|
|
31626
|
+
}
|
|
31627
|
+
|
|
31628
|
+
this.h0 = this.h0 + a << 0;
|
|
31629
|
+
this.h1 = this.h1 + b << 0;
|
|
31630
|
+
this.h2 = this.h2 + c << 0;
|
|
31631
|
+
this.h3 = this.h3 + d << 0;
|
|
31632
|
+
this.h4 = this.h4 + e << 0;
|
|
31633
|
+
this.h5 = this.h5 + f << 0;
|
|
31634
|
+
this.h6 = this.h6 + g << 0;
|
|
31635
|
+
this.h7 = this.h7 + h << 0;
|
|
31636
|
+
};
|
|
31637
|
+
|
|
31638
|
+
Sha256.prototype.hex = function () {
|
|
31639
|
+
this.finalize();
|
|
31640
|
+
|
|
31641
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
|
|
31642
|
+
h6 = this.h6, h7 = this.h7;
|
|
31643
|
+
|
|
31644
|
+
var hex = HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] +
|
|
31645
|
+
HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] +
|
|
31646
|
+
HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] +
|
|
31647
|
+
HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
|
|
31648
|
+
HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] +
|
|
31649
|
+
HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] +
|
|
31650
|
+
HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] +
|
|
31651
|
+
HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
|
|
31652
|
+
HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] +
|
|
31653
|
+
HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] +
|
|
31654
|
+
HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] +
|
|
31655
|
+
HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
|
|
31656
|
+
HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] +
|
|
31657
|
+
HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] +
|
|
31658
|
+
HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] +
|
|
31659
|
+
HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
|
|
31660
|
+
HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] +
|
|
31661
|
+
HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] +
|
|
31662
|
+
HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] +
|
|
31663
|
+
HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] +
|
|
31664
|
+
HEX_CHARS[(h5 >> 28) & 0x0F] + HEX_CHARS[(h5 >> 24) & 0x0F] +
|
|
31665
|
+
HEX_CHARS[(h5 >> 20) & 0x0F] + HEX_CHARS[(h5 >> 16) & 0x0F] +
|
|
31666
|
+
HEX_CHARS[(h5 >> 12) & 0x0F] + HEX_CHARS[(h5 >> 8) & 0x0F] +
|
|
31667
|
+
HEX_CHARS[(h5 >> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] +
|
|
31668
|
+
HEX_CHARS[(h6 >> 28) & 0x0F] + HEX_CHARS[(h6 >> 24) & 0x0F] +
|
|
31669
|
+
HEX_CHARS[(h6 >> 20) & 0x0F] + HEX_CHARS[(h6 >> 16) & 0x0F] +
|
|
31670
|
+
HEX_CHARS[(h6 >> 12) & 0x0F] + HEX_CHARS[(h6 >> 8) & 0x0F] +
|
|
31671
|
+
HEX_CHARS[(h6 >> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F];
|
|
31672
|
+
if (!this.is224) {
|
|
31673
|
+
hex += HEX_CHARS[(h7 >> 28) & 0x0F] + HEX_CHARS[(h7 >> 24) & 0x0F] +
|
|
31674
|
+
HEX_CHARS[(h7 >> 20) & 0x0F] + HEX_CHARS[(h7 >> 16) & 0x0F] +
|
|
31675
|
+
HEX_CHARS[(h7 >> 12) & 0x0F] + HEX_CHARS[(h7 >> 8) & 0x0F] +
|
|
31676
|
+
HEX_CHARS[(h7 >> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F];
|
|
31677
|
+
}
|
|
31678
|
+
return hex;
|
|
31679
|
+
};
|
|
31680
|
+
|
|
31681
|
+
Sha256.prototype.toString = Sha256.prototype.hex;
|
|
31682
|
+
|
|
31683
|
+
Sha256.prototype.digest = function () {
|
|
31684
|
+
this.finalize();
|
|
31685
|
+
|
|
31686
|
+
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
|
|
31687
|
+
h6 = this.h6, h7 = this.h7;
|
|
31688
|
+
|
|
31689
|
+
var arr = [
|
|
31690
|
+
(h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF,
|
|
31691
|
+
(h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF,
|
|
31692
|
+
(h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF,
|
|
31693
|
+
(h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF,
|
|
31694
|
+
(h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF,
|
|
31695
|
+
(h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, h5 & 0xFF,
|
|
31696
|
+
(h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, h6 & 0xFF
|
|
31697
|
+
];
|
|
31698
|
+
if (!this.is224) {
|
|
31699
|
+
arr.push((h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, h7 & 0xFF);
|
|
31700
|
+
}
|
|
31701
|
+
return arr;
|
|
31702
|
+
};
|
|
31703
|
+
|
|
31704
|
+
Sha256.prototype.array = Sha256.prototype.digest;
|
|
31705
|
+
|
|
31706
|
+
Sha256.prototype.arrayBuffer = function () {
|
|
31707
|
+
this.finalize();
|
|
31708
|
+
|
|
31709
|
+
var buffer = new ArrayBuffer(this.is224 ? 28 : 32);
|
|
31710
|
+
var dataView = new DataView(buffer);
|
|
31711
|
+
dataView.setUint32(0, this.h0);
|
|
31712
|
+
dataView.setUint32(4, this.h1);
|
|
31713
|
+
dataView.setUint32(8, this.h2);
|
|
31714
|
+
dataView.setUint32(12, this.h3);
|
|
31715
|
+
dataView.setUint32(16, this.h4);
|
|
31716
|
+
dataView.setUint32(20, this.h5);
|
|
31717
|
+
dataView.setUint32(24, this.h6);
|
|
31718
|
+
if (!this.is224) {
|
|
31719
|
+
dataView.setUint32(28, this.h7);
|
|
31720
|
+
}
|
|
31721
|
+
return buffer;
|
|
31722
|
+
};
|
|
31723
|
+
|
|
31724
|
+
function HmacSha256(key, is224, sharedMemory) {
|
|
31725
|
+
var i, type = typeof key;
|
|
31726
|
+
if (type === 'string') {
|
|
31727
|
+
var bytes = [], length = key.length, index = 0, code;
|
|
31728
|
+
for (i = 0; i < length; ++i) {
|
|
31729
|
+
code = key.charCodeAt(i);
|
|
31730
|
+
if (code < 0x80) {
|
|
31731
|
+
bytes[index++] = code;
|
|
31732
|
+
} else if (code < 0x800) {
|
|
31733
|
+
bytes[index++] = (0xc0 | (code >> 6));
|
|
31734
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
31735
|
+
} else if (code < 0xd800 || code >= 0xe000) {
|
|
31736
|
+
bytes[index++] = (0xe0 | (code >> 12));
|
|
31737
|
+
bytes[index++] = (0x80 | ((code >> 6) & 0x3f));
|
|
31738
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
31739
|
+
} else {
|
|
31740
|
+
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));
|
|
31741
|
+
bytes[index++] = (0xf0 | (code >> 18));
|
|
31742
|
+
bytes[index++] = (0x80 | ((code >> 12) & 0x3f));
|
|
31743
|
+
bytes[index++] = (0x80 | ((code >> 6) & 0x3f));
|
|
31744
|
+
bytes[index++] = (0x80 | (code & 0x3f));
|
|
31745
|
+
}
|
|
31746
|
+
}
|
|
31747
|
+
key = bytes;
|
|
31748
|
+
} else {
|
|
31749
|
+
if (type === 'object') {
|
|
31750
|
+
if (key === null) {
|
|
31751
|
+
throw new Error(ERROR);
|
|
31752
|
+
} else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) {
|
|
31753
|
+
key = new Uint8Array(key);
|
|
31754
|
+
} else if (!Array.isArray(key)) {
|
|
31755
|
+
if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) {
|
|
31756
|
+
throw new Error(ERROR);
|
|
31757
|
+
}
|
|
31758
|
+
}
|
|
31759
|
+
} else {
|
|
31760
|
+
throw new Error(ERROR);
|
|
31761
|
+
}
|
|
31762
|
+
}
|
|
31763
|
+
|
|
31764
|
+
if (key.length > 64) {
|
|
31765
|
+
key = (new Sha256(is224, true)).update(key).array();
|
|
31766
|
+
}
|
|
31767
|
+
|
|
31768
|
+
var oKeyPad = [], iKeyPad = [];
|
|
31769
|
+
for (i = 0; i < 64; ++i) {
|
|
31770
|
+
var b = key[i] || 0;
|
|
31771
|
+
oKeyPad[i] = 0x5c ^ b;
|
|
31772
|
+
iKeyPad[i] = 0x36 ^ b;
|
|
31773
|
+
}
|
|
31774
|
+
|
|
31775
|
+
Sha256.call(this, is224, sharedMemory);
|
|
31776
|
+
|
|
31777
|
+
this.update(iKeyPad);
|
|
31778
|
+
this.oKeyPad = oKeyPad;
|
|
31779
|
+
this.inner = true;
|
|
31780
|
+
this.sharedMemory = sharedMemory;
|
|
31781
|
+
}
|
|
31782
|
+
HmacSha256.prototype = new Sha256();
|
|
31783
|
+
|
|
31784
|
+
HmacSha256.prototype.finalize = function () {
|
|
31785
|
+
Sha256.prototype.finalize.call(this);
|
|
31786
|
+
if (this.inner) {
|
|
31787
|
+
this.inner = false;
|
|
31788
|
+
var innerHash = this.array();
|
|
31789
|
+
Sha256.call(this, this.is224, this.sharedMemory);
|
|
31790
|
+
this.update(this.oKeyPad);
|
|
31791
|
+
this.update(innerHash);
|
|
31792
|
+
Sha256.prototype.finalize.call(this);
|
|
31793
|
+
}
|
|
31794
|
+
};
|
|
31795
|
+
|
|
31796
|
+
var exports = createMethod();
|
|
31797
|
+
exports.sha256 = exports;
|
|
31798
|
+
exports.sha224 = createMethod(true);
|
|
31799
|
+
exports.sha256.hmac = createHmacMethod();
|
|
31800
|
+
exports.sha224.hmac = createHmacMethod(true);
|
|
31801
|
+
|
|
31802
|
+
if (COMMON_JS) {
|
|
31803
|
+
module.exports = exports;
|
|
31804
|
+
} else {
|
|
31805
|
+
root.sha256 = exports.sha256;
|
|
31806
|
+
root.sha224 = exports.sha224;
|
|
31807
|
+
if (AMD) {
|
|
31808
|
+
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
|
|
31809
|
+
return exports;
|
|
31810
|
+
}).call(exports, __webpack_require__, exports, module),
|
|
31811
|
+
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
31812
|
+
}
|
|
31813
|
+
}
|
|
31814
|
+
})();
|
|
31815
|
+
|
|
31816
|
+
|
|
31192
31817
|
/***/ }),
|
|
31193
31818
|
|
|
31194
31819
|
/***/ 857:
|
|
@@ -42667,6 +43292,11 @@ try {
|
|
|
42667
43292
|
/******/ }
|
|
42668
43293
|
/******/
|
|
42669
43294
|
/************************************************************************/
|
|
43295
|
+
/******/ /* webpack/runtime/amd options */
|
|
43296
|
+
/******/ (() => {
|
|
43297
|
+
/******/ __webpack_require__.amdO = {};
|
|
43298
|
+
/******/ })();
|
|
43299
|
+
/******/
|
|
42670
43300
|
/******/ /* webpack/runtime/compat get default export */
|
|
42671
43301
|
/******/ (() => {
|
|
42672
43302
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
@@ -45115,7 +45745,9 @@ const src_init = async settings => {
|
|
|
45115
45745
|
window.addEventListener('unload', src_dispose);
|
|
45116
45746
|
|
|
45117
45747
|
try {
|
|
45118
|
-
await init(_settings
|
|
45748
|
+
await init({ ..._settings,
|
|
45749
|
+
version: "0.1.13"
|
|
45750
|
+
});
|
|
45119
45751
|
return true;
|
|
45120
45752
|
} catch (e) {
|
|
45121
45753
|
console.log('init error: ', e);
|