@onekeyfe/hd-web-sdk 0.1.11 → 0.1.14

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.
@@ -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,
@@ -4781,92 +4785,6 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
4781
4785
  }
4782
4786
  }
4783
4787
 
4784
- const colors = {
4785
- '@onekey/connect': 'color: #f4a742; background: #000;',
4786
- IFrame: 'color: #f4a742; background: #000;',
4787
- Core: 'color: #f4a742; background: #000;',
4788
- DescriptorStream: 'color: #77ab59; background: #000;',
4789
- DeviceList: 'color: #77ab59; background: #000;',
4790
- Device: 'color: #bada55; background: #000;',
4791
- DeviceCommands: 'color: #bada55; background: #000;',
4792
- DeviceConnector: 'color: #bada55; background: #000;',
4793
- Transport: 'color: #ffb6c1; background: #000;'
4794
- };
4795
- const MAX_ENTRIES = 100;
4796
-
4797
- class Log$6 {
4798
- constructor(prefix, enabled) {
4799
- this.prefix = prefix;
4800
- this.enabled = enabled;
4801
- this.messages = [];
4802
- this.css = typeof window !== 'undefined' && colors[prefix] ? colors[prefix] : '';
4803
- }
4804
-
4805
- addMessage(level, prefix, ...args) {
4806
- this.messages.push({
4807
- level,
4808
- prefix,
4809
- message: args,
4810
- timestamp: new Date().getTime()
4811
- });
4812
-
4813
- if (this.messages.length > MAX_ENTRIES) {
4814
- this.messages.shift();
4815
- }
4816
- }
4817
-
4818
- log(...args) {
4819
- this.addMessage('log', this.prefix, ...args);
4820
-
4821
- if (this.enabled) {
4822
- console.log(this.prefix, ...args);
4823
- }
4824
- }
4825
-
4826
- error(...args) {
4827
- this.addMessage('error', this.prefix, ...args);
4828
-
4829
- if (this.enabled) {
4830
- console.error(this.prefix, ...args);
4831
- }
4832
- }
4833
-
4834
- warn(...args) {
4835
- this.addMessage('warn', this.prefix, ...args);
4836
-
4837
- if (this.enabled) {
4838
- console.warn(this.prefix, ...args);
4839
- }
4840
- }
4841
-
4842
- debug(...args) {
4843
- this.addMessage('debug', this.prefix, ...args);
4844
-
4845
- if (this.enabled) {
4846
- if (this.css) {
4847
- console.log(`%c${this.prefix}`, this.css, ...args);
4848
- } else {
4849
- console.log(this.prefix, ...args);
4850
- }
4851
- }
4852
- }
4853
-
4854
- }
4855
-
4856
- const _logs = {};
4857
-
4858
- const initLog = (prefix, enabled) => {
4859
- const instance = new Log$6(prefix, !!enabled);
4860
- _logs[prefix] = instance;
4861
- return instance;
4862
- };
4863
-
4864
- const enableLog = enabled => {
4865
- Object.keys(_logs).forEach(key => {
4866
- _logs[key].enabled = !!enabled;
4867
- });
4868
- };
4869
-
4870
4788
  const httpRequest$1 = (url, type = 'text') => __awaiter(void 0, void 0, void 0, function* () {
4871
4789
  const response = yield axios__default["default"].request({
4872
4790
  url,
@@ -14030,7 +13948,7 @@ DataManager.getTransportStatus = localVersion => {
14030
13948
  return isLatest ? 'valid' : 'outdated';
14031
13949
  };
14032
13950
 
14033
- const Log$5 = initLog('Transport');
13951
+ const Log$5 = hdShared.initLog('Transport');
14034
13952
 
14035
13953
  class TransportManager {
14036
13954
  static load() {
@@ -14061,6 +13979,10 @@ class TransportManager {
14061
13979
  Log$5.debug('Configuring transports done');
14062
13980
  } catch (error) {
14063
13981
  Log$5.debug('Initializing transports error: ', error);
13982
+
13983
+ if (error.code === 'ECONNABORTED') {
13984
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeTimeoutError);
13985
+ }
14064
13986
  }
14065
13987
  });
14066
13988
  }
@@ -14236,11 +14158,11 @@ const assertType = (res, resType) => {
14236
14158
  const splitResTypes = Array.isArray(resType) ? resType : resType.split('|');
14237
14159
 
14238
14160
  if (!splitResTypes.includes(res.type)) {
14239
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `assertType: Response of unexpected type: ${res.type}. Should be ${resType}`);
14161
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.ResponseUnexpectTypeError, `assertType: Response of unexpected type: ${res.type}. Should be ${resType}`);
14240
14162
  }
14241
14163
  };
14242
14164
 
14243
- const Log$4 = initLog('DeviceCommands');
14165
+ const Log$4 = hdShared.initLog('DeviceCommands');
14244
14166
 
14245
14167
  class DeviceCommands {
14246
14168
  constructor(device, mainId) {
@@ -14264,8 +14186,10 @@ class DeviceCommands {
14264
14186
  }
14265
14187
 
14266
14188
  call(type, msg = {}) {
14189
+ var _a, _b;
14190
+
14267
14191
  return __awaiter(this, void 0, void 0, function* () {
14268
- console.log('[DeviceCommands] [call] Sending', type, this.transport);
14192
+ console.log('[DeviceCommands] [call] Sending', type);
14269
14193
 
14270
14194
  try {
14271
14195
  const promise = this.transport.call(this.mainId, type, msg);
@@ -14275,6 +14199,14 @@ class DeviceCommands {
14275
14199
  return res;
14276
14200
  } catch (error) {
14277
14201
  Log$4.debug('[DeviceCommands] [call] Received error', error);
14202
+
14203
+ 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') {
14204
+ return {
14205
+ type: 'BridgeNetworkError',
14206
+ message: {}
14207
+ };
14208
+ }
14209
+
14278
14210
  throw error;
14279
14211
  }
14280
14212
  });
@@ -14292,7 +14224,16 @@ class DeviceCommands {
14292
14224
  assertType(response, resType);
14293
14225
  } catch (error) {
14294
14226
  console.log('DeviceCommands typedcall error: ', error);
14295
- throw error;
14227
+
14228
+ if (error instanceof hdShared.HardwareError) {
14229
+ if (error.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError) {
14230
+ if (error.message.indexOf('BridgeNetworkError') > -1) {
14231
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeNetworkError);
14232
+ }
14233
+ }
14234
+ } else {
14235
+ throw error;
14236
+ }
14296
14237
  }
14297
14238
 
14298
14239
  return response;
@@ -14409,12 +14350,11 @@ const UI_REQUEST = {
14409
14350
  FIRMWARE_NOT_INSTALLED: 'ui-device_firmware_not_installed',
14410
14351
  NOT_USE_ONEKEY_DEVICE: 'ui-device_please_use_onekey_device'
14411
14352
  };
14412
- const VERSION = '1.0.0-alpha.1';
14413
- const DEFAULT_DOMAIN = `https://hardware-sdk.onekey.so/`;
14353
+ const DEFAULT_DOMAIN = `https://jssdk.onekey.so/`;
14414
14354
  const DEFAULT_PRIORITY = 2;
14415
14355
  const initialSettings = {
14416
14356
  configSrc: './data/config.json',
14417
- version: VERSION,
14357
+ version: '',
14418
14358
  debug: false,
14419
14359
  priority: DEFAULT_PRIORITY,
14420
14360
  trustedHost: false,
@@ -14511,7 +14451,7 @@ const parseRunOptions = options => {
14511
14451
  return options;
14512
14452
  };
14513
14453
 
14514
- const Log$3 = initLog('Device');
14454
+ const Log$3 = hdShared.initLog('Device');
14515
14455
 
14516
14456
  class Device extends events.exports {
14517
14457
  constructor(descriptor) {
@@ -14873,7 +14813,7 @@ class Device extends events.exports {
14873
14813
  }
14874
14814
 
14875
14815
  const cacheDeviceMap = new Map();
14876
- const Log$2 = initLog('DeviceList');
14816
+ const Log$2 = hdShared.initLog('DeviceList');
14877
14817
 
14878
14818
  class DeviceList extends events.exports {
14879
14819
  constructor() {
@@ -16355,12 +16295,19 @@ class CheckBridgeStatus extends BaseMethod {
16355
16295
 
16356
16296
  run() {
16357
16297
  return __awaiter(this, void 0, void 0, function* () {
16358
- return new Promise(resolve => {
16298
+ return new Promise((resolve, reject) => {
16359
16299
  axios__default["default"].request({
16360
16300
  url: 'http://localhost:21320',
16361
16301
  method: 'POST',
16362
- withCredentials: false
16363
- }).then(() => resolve(true)).catch(() => resolve(false));
16302
+ withCredentials: false,
16303
+ timeout: 3000
16304
+ }).then(() => resolve(true)).catch(e => {
16305
+ if (e.code === 'ECONNABORTED') {
16306
+ reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeTimeoutError));
16307
+ } else {
16308
+ resolve(false);
16309
+ }
16310
+ });
16364
16311
  });
16365
16312
  });
16366
16313
  }
@@ -16635,7 +16582,9 @@ class DeviceVerify extends BaseMethod {
16635
16582
  let response;
16636
16583
 
16637
16584
  if (deviceType === 'classic') {
16638
- const res = yield this.device.commands.typedCall('BixinVerifyDeviceRequest', 'BixinVerifyDeviceAck', Object.assign({}, this.params));
16585
+ const res = yield this.device.commands.typedCall('BixinVerifyDeviceRequest', 'BixinVerifyDeviceAck', Object.assign(Object.assign({}, this.params), {
16586
+ data: sha256__default["default"].sha256(this.params.data)
16587
+ }));
16639
16588
  response = res.message;
16640
16589
  } else if (deviceType === 'mini') {
16641
16590
  const signatureRes = yield this.device.commands.typedCall('SESignMessage', 'SEMessageSignature', {
@@ -18668,7 +18617,7 @@ const resolveAfter = (msec, value) => new Promise(resolve => {
18668
18617
  setTimeout(resolve, msec, value);
18669
18618
  });
18670
18619
 
18671
- const Log$1 = initLog('DeviceConnector');
18620
+ const Log$1 = hdShared.initLog('DeviceConnector');
18672
18621
 
18673
18622
  const getDiff = (current, descriptors) => {
18674
18623
  const env = DataManager.getSettings('env');
@@ -18824,7 +18773,7 @@ class DeviceConnector {
18824
18773
 
18825
18774
  }
18826
18775
 
18827
- const Log = initLog('Core');
18776
+ const Log = hdShared.initLog('Core');
18828
18777
 
18829
18778
  let _core;
18830
18779
 
@@ -18930,7 +18879,7 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
18930
18879
 
18931
18880
  try {
18932
18881
  const response = yield method.run();
18933
- Log.debug('Call API - Inner Method Run: ', device);
18882
+ Log.debug('Call API - Inner Method Run: ');
18934
18883
  messageResponse = createResponseMessage(method.responseID, true, response);
18935
18884
  _callPromise === null || _callPromise === void 0 ? void 0 : _callPromise.resolve(messageResponse);
18936
18885
  } catch (error) {
@@ -19189,7 +19138,7 @@ const init = (settings, Transport) => __awaiter(void 0, void 0, void 0, function
19189
19138
  Log.error('DataManager.load error');
19190
19139
  }
19191
19140
 
19192
- enableLog(DataManager.getSettings('debug'));
19141
+ hdShared.enableLog(DataManager.getSettings('debug'));
19193
19142
  initCore();
19194
19143
  initConnector();
19195
19144
  return _core;
@@ -19214,6 +19163,18 @@ const HardwareSdk = ({
19214
19163
  cancel
19215
19164
  });
19216
19165
 
19166
+ Object.defineProperty(exports, "yI", ({
19167
+ enumerable: true,
19168
+ get: function () {
19169
+ return hdShared.enableLog;
19170
+ }
19171
+ }));
19172
+ Object.defineProperty(exports, "KR", ({
19173
+ enumerable: true,
19174
+ get: function () {
19175
+ return hdShared.initLog;
19176
+ }
19177
+ }));
19217
19178
  __webpack_unused_export__ = ({
19218
19179
  enumerable: true,
19219
19180
  get: function () {
@@ -19239,7 +19200,6 @@ __webpack_unused_export__ = createResponseMessage;
19239
19200
  __webpack_unused_export__ = createUiMessage;
19240
19201
  __webpack_unused_export__ = createUiResponse;
19241
19202
  exports.ZP = HardwareSdk;
19242
- exports.yI = enableLog;
19243
19203
  __webpack_unused_export__ = getDeviceLabel;
19244
19204
  __webpack_unused_export__ = getDeviceType;
19245
19205
  __webpack_unused_export__ = getDeviceTypeByBleName;
@@ -19251,7 +19211,6 @@ __webpack_unused_export__ = getScriptType;
19251
19211
  __webpack_unused_export__ = getTimeStamp;
19252
19212
  __webpack_unused_export__ = httpRequest;
19253
19213
  __webpack_unused_export__ = init;
19254
- exports.KR = initLog;
19255
19214
  __webpack_unused_export__ = isValidVersionArray;
19256
19215
  __webpack_unused_export__ = isValidVersionString;
19257
19216
  __webpack_unused_export__ = normalizeVersionArray;
@@ -20439,7 +20398,10 @@ const HardwareErrorCode = {
20439
20398
  PinInvalid: 801,
20440
20399
  PinCancelled: 802,
20441
20400
  ActionCancelled: 803,
20442
- FirmwareError: 804
20401
+ FirmwareError: 804,
20402
+ ResponseUnexpectTypeError: 805,
20403
+ BridgeNetworkError: 806,
20404
+ BridgeTimeoutError: 807
20443
20405
  };
20444
20406
  const HardwareErrorCodeMessage = {
20445
20407
  [HardwareErrorCode.UnknownError]: 'Unknown error occurred. Check message property.',
@@ -20480,7 +20442,10 @@ const HardwareErrorCodeMessage = {
20480
20442
  [HardwareErrorCode.PinInvalid]: 'Pin invalid',
20481
20443
  [HardwareErrorCode.PinCancelled]: 'Pin cancelled',
20482
20444
  [HardwareErrorCode.ActionCancelled]: 'Action cancelled by user',
20483
- [HardwareErrorCode.FirmwareError]: 'Firmware installation failed'
20445
+ [HardwareErrorCode.FirmwareError]: 'Firmware installation failed',
20446
+ [HardwareErrorCode.ResponseUnexpectTypeError]: 'Response type is not expected',
20447
+ [HardwareErrorCode.BridgeNetworkError]: 'Bridge network error',
20448
+ [HardwareErrorCode.BridgeTimeoutError]: 'Bridge network timeout'
20484
20449
  };
20485
20450
 
20486
20451
  const TypedError = (hardwareError, message) => {
@@ -20512,21 +20477,157 @@ const serializeError = payload => {
20512
20477
  return payload;
20513
20478
  };
20514
20479
 
20480
+ const CreateErrorByMessage = message => {
20481
+ for (const code of Object.values(HardwareErrorCode)) {
20482
+ if (HardwareErrorCodeMessage[code] === message) {
20483
+ return TypedError(code);
20484
+ }
20485
+ }
20486
+
20487
+ return new HardwareError(message);
20488
+ };
20489
+
20515
20490
  var HardwareError$1 = /*#__PURE__*/Object.freeze({
20516
20491
  __proto__: null,
20517
20492
  HardwareError: HardwareError,
20518
20493
  HardwareErrorCode: HardwareErrorCode,
20519
20494
  HardwareErrorCodeMessage: HardwareErrorCodeMessage,
20520
20495
  TypedError: TypedError,
20521
- serializeError: serializeError
20496
+ serializeError: serializeError,
20497
+ CreateErrorByMessage: CreateErrorByMessage
20522
20498
  });
20499
+ const MAX_ENTRIES = 100;
20500
+
20501
+ class Log {
20502
+ constructor(prefix, enabled, logger) {
20503
+ this.prefix = prefix;
20504
+ this.enabled = enabled;
20505
+ this.messages = [];
20506
+
20507
+ if (logger) {
20508
+ this.logger = logger;
20509
+ }
20510
+ }
20511
+
20512
+ addMessage(level, prefix, ...args) {
20513
+ this.messages.push({
20514
+ level,
20515
+ prefix,
20516
+ message: args,
20517
+ timestamp: new Date().getTime()
20518
+ });
20519
+
20520
+ if (this.messages.length > MAX_ENTRIES) {
20521
+ this.messages.shift();
20522
+ }
20523
+ }
20524
+
20525
+ log(...args) {
20526
+ this.addMessage('log', this.prefix, ...args);
20527
+
20528
+ if (!this.enabled) {
20529
+ return;
20530
+ }
20531
+
20532
+ if (this.logger) {
20533
+ this.logger.info(this.prefix, ...args);
20534
+ } else {
20535
+ console.log(this.prefix, ...args);
20536
+ }
20537
+ }
20538
+
20539
+ error(...args) {
20540
+ this.addMessage('error', this.prefix, ...args);
20541
+
20542
+ if (!this.enabled) {
20543
+ return;
20544
+ }
20545
+
20546
+ if (this.logger) {
20547
+ this.logger.error(this.prefix, ...args);
20548
+ } else {
20549
+ console.error(this.prefix, ...args);
20550
+ }
20551
+ }
20552
+
20553
+ warn(...args) {
20554
+ this.addMessage('warn', this.prefix, ...args);
20555
+
20556
+ if (!this.enabled) {
20557
+ return;
20558
+ }
20559
+
20560
+ if (this.logger) {
20561
+ this.logger.warn(this.prefix, ...args);
20562
+ } else {
20563
+ console.warn(this.prefix, ...args);
20564
+ }
20565
+ }
20566
+
20567
+ debug(...args) {
20568
+ this.addMessage('debug', this.prefix, ...args);
20569
+
20570
+ if (!this.enabled) {
20571
+ return;
20572
+ }
20573
+
20574
+ if (this.logger) {
20575
+ this.logger.debug(this.prefix, ...args);
20576
+ } else {
20577
+ console.log(this.prefix, ...args);
20578
+ }
20579
+ }
20580
+
20581
+ }
20582
+
20583
+ const _logs = {};
20584
+
20585
+ const initLog = (prefix, enabled, logger) => {
20586
+ const instance = new Log(prefix, !!enabled, logger);
20587
+ _logs[prefix] = instance;
20588
+ return instance;
20589
+ };
20590
+
20591
+ const enableLog = enabled => {
20592
+ Object.keys(_logs).forEach(key => {
20593
+ _logs[key].enabled = !!enabled;
20594
+ });
20595
+ };
20596
+
20597
+ const setOutsideLogger = logger => {
20598
+ Object.keys(_logs).forEach(key => {
20599
+ _logs[key].logger = logger;
20600
+ });
20601
+ };
20602
+
20603
+ const enableLogByPrefix = (prefix, enabled) => {
20604
+ if (_logs[prefix]) {
20605
+ _logs[prefix].enabled = enabled;
20606
+ }
20607
+ };
20608
+
20609
+ const getLog = () => {
20610
+ let logs = [];
20611
+ Object.keys(_logs).forEach(key => {
20612
+ logs = logs.concat(_logs[key].messages);
20613
+ });
20614
+ logs.sort((a, b) => a.timestamp - b.timestamp);
20615
+ return logs;
20616
+ };
20617
+
20618
+ exports.CreateErrorByMessage = CreateErrorByMessage;
20523
20619
  exports.ERRORS = HardwareError$1;
20524
20620
  exports.HardwareError = HardwareError;
20525
20621
  exports.HardwareErrorCode = HardwareErrorCode;
20526
20622
  exports.HardwareErrorCodeMessage = HardwareErrorCodeMessage;
20527
20623
  exports.TypedError = TypedError;
20528
20624
  exports.createDeferred = createDeferred;
20625
+ exports.enableLog = enableLog;
20626
+ exports.enableLogByPrefix = enableLogByPrefix;
20627
+ exports.getLog = getLog;
20628
+ exports.initLog = initLog;
20529
20629
  exports.serializeError = serializeError;
20630
+ exports.setOutsideLogger = setOutsideLogger;
20530
20631
 
20531
20632
  /***/ }),
20532
20633
 
@@ -31212,6 +31313,532 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
31212
31313
  }
31213
31314
 
31214
31315
 
31316
+ /***/ }),
31317
+
31318
+ /***/ 1965:
31319
+ /***/ ((module, exports, __webpack_require__) => {
31320
+
31321
+ var __WEBPACK_AMD_DEFINE_RESULT__;/**
31322
+ * [js-sha256]{@link https://github.com/emn178/js-sha256}
31323
+ *
31324
+ * @version 0.9.0
31325
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
31326
+ * @copyright Chen, Yi-Cyuan 2014-2017
31327
+ * @license MIT
31328
+ */
31329
+ /*jslint bitwise: true */
31330
+ (function () {
31331
+ 'use strict';
31332
+
31333
+ var ERROR = 'input is invalid type';
31334
+ var WINDOW = typeof window === 'object';
31335
+ var root = WINDOW ? window : {};
31336
+ if (root.JS_SHA256_NO_WINDOW) {
31337
+ WINDOW = false;
31338
+ }
31339
+ var WEB_WORKER = !WINDOW && typeof self === 'object';
31340
+ var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
31341
+ if (NODE_JS) {
31342
+ root = __webpack_require__.g;
31343
+ } else if (WEB_WORKER) {
31344
+ root = self;
31345
+ }
31346
+ var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && "object" === 'object' && module.exports;
31347
+ var AMD = true && __webpack_require__.amdO;
31348
+ var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
31349
+ var HEX_CHARS = '0123456789abcdef'.split('');
31350
+ var EXTRA = [-2147483648, 8388608, 32768, 128];
31351
+ var SHIFT = [24, 16, 8, 0];
31352
+ var K = [
31353
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
31354
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
31355
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
31356
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
31357
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
31358
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
31359
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
31360
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
31361
+ ];
31362
+ var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];
31363
+
31364
+ var blocks = [];
31365
+
31366
+ if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) {
31367
+ Array.isArray = function (obj) {
31368
+ return Object.prototype.toString.call(obj) === '[object Array]';
31369
+ };
31370
+ }
31371
+
31372
+ if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
31373
+ ArrayBuffer.isView = function (obj) {
31374
+ return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
31375
+ };
31376
+ }
31377
+
31378
+ var createOutputMethod = function (outputType, is224) {
31379
+ return function (message) {
31380
+ return new Sha256(is224, true).update(message)[outputType]();
31381
+ };
31382
+ };
31383
+
31384
+ var createMethod = function (is224) {
31385
+ var method = createOutputMethod('hex', is224);
31386
+ if (NODE_JS) {
31387
+ method = nodeWrap(method, is224);
31388
+ }
31389
+ method.create = function () {
31390
+ return new Sha256(is224);
31391
+ };
31392
+ method.update = function (message) {
31393
+ return method.create().update(message);
31394
+ };
31395
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
31396
+ var type = OUTPUT_TYPES[i];
31397
+ method[type] = createOutputMethod(type, is224);
31398
+ }
31399
+ return method;
31400
+ };
31401
+
31402
+ var nodeWrap = function (method, is224) {
31403
+ var crypto = eval("require('crypto')");
31404
+ var Buffer = eval("require('buffer').Buffer");
31405
+ var algorithm = is224 ? 'sha224' : 'sha256';
31406
+ var nodeMethod = function (message) {
31407
+ if (typeof message === 'string') {
31408
+ return crypto.createHash(algorithm).update(message, 'utf8').digest('hex');
31409
+ } else {
31410
+ if (message === null || message === undefined) {
31411
+ throw new Error(ERROR);
31412
+ } else if (message.constructor === ArrayBuffer) {
31413
+ message = new Uint8Array(message);
31414
+ }
31415
+ }
31416
+ if (Array.isArray(message) || ArrayBuffer.isView(message) ||
31417
+ message.constructor === Buffer) {
31418
+ return crypto.createHash(algorithm).update(new Buffer(message)).digest('hex');
31419
+ } else {
31420
+ return method(message);
31421
+ }
31422
+ };
31423
+ return nodeMethod;
31424
+ };
31425
+
31426
+ var createHmacOutputMethod = function (outputType, is224) {
31427
+ return function (key, message) {
31428
+ return new HmacSha256(key, is224, true).update(message)[outputType]();
31429
+ };
31430
+ };
31431
+
31432
+ var createHmacMethod = function (is224) {
31433
+ var method = createHmacOutputMethod('hex', is224);
31434
+ method.create = function (key) {
31435
+ return new HmacSha256(key, is224);
31436
+ };
31437
+ method.update = function (key, message) {
31438
+ return method.create(key).update(message);
31439
+ };
31440
+ for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
31441
+ var type = OUTPUT_TYPES[i];
31442
+ method[type] = createHmacOutputMethod(type, is224);
31443
+ }
31444
+ return method;
31445
+ };
31446
+
31447
+ function Sha256(is224, sharedMemory) {
31448
+ if (sharedMemory) {
31449
+ blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
31450
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
31451
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
31452
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
31453
+ this.blocks = blocks;
31454
+ } else {
31455
+ this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
31456
+ }
31457
+
31458
+ if (is224) {
31459
+ this.h0 = 0xc1059ed8;
31460
+ this.h1 = 0x367cd507;
31461
+ this.h2 = 0x3070dd17;
31462
+ this.h3 = 0xf70e5939;
31463
+ this.h4 = 0xffc00b31;
31464
+ this.h5 = 0x68581511;
31465
+ this.h6 = 0x64f98fa7;
31466
+ this.h7 = 0xbefa4fa4;
31467
+ } else { // 256
31468
+ this.h0 = 0x6a09e667;
31469
+ this.h1 = 0xbb67ae85;
31470
+ this.h2 = 0x3c6ef372;
31471
+ this.h3 = 0xa54ff53a;
31472
+ this.h4 = 0x510e527f;
31473
+ this.h5 = 0x9b05688c;
31474
+ this.h6 = 0x1f83d9ab;
31475
+ this.h7 = 0x5be0cd19;
31476
+ }
31477
+
31478
+ this.block = this.start = this.bytes = this.hBytes = 0;
31479
+ this.finalized = this.hashed = false;
31480
+ this.first = true;
31481
+ this.is224 = is224;
31482
+ }
31483
+
31484
+ Sha256.prototype.update = function (message) {
31485
+ if (this.finalized) {
31486
+ return;
31487
+ }
31488
+ var notString, type = typeof message;
31489
+ if (type !== 'string') {
31490
+ if (type === 'object') {
31491
+ if (message === null) {
31492
+ throw new Error(ERROR);
31493
+ } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
31494
+ message = new Uint8Array(message);
31495
+ } else if (!Array.isArray(message)) {
31496
+ if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
31497
+ throw new Error(ERROR);
31498
+ }
31499
+ }
31500
+ } else {
31501
+ throw new Error(ERROR);
31502
+ }
31503
+ notString = true;
31504
+ }
31505
+ var code, index = 0, i, length = message.length, blocks = this.blocks;
31506
+
31507
+ while (index < length) {
31508
+ if (this.hashed) {
31509
+ this.hashed = false;
31510
+ blocks[0] = this.block;
31511
+ blocks[16] = blocks[1] = blocks[2] = blocks[3] =
31512
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
31513
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
31514
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
31515
+ }
31516
+
31517
+ if (notString) {
31518
+ for (i = this.start; index < length && i < 64; ++index) {
31519
+ blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
31520
+ }
31521
+ } else {
31522
+ for (i = this.start; index < length && i < 64; ++index) {
31523
+ code = message.charCodeAt(index);
31524
+ if (code < 0x80) {
31525
+ blocks[i >> 2] |= code << SHIFT[i++ & 3];
31526
+ } else if (code < 0x800) {
31527
+ blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
31528
+ blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
31529
+ } else if (code < 0xd800 || code >= 0xe000) {
31530
+ blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
31531
+ blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
31532
+ blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
31533
+ } else {
31534
+ code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
31535
+ blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
31536
+ blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
31537
+ blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
31538
+ blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
31539
+ }
31540
+ }
31541
+ }
31542
+
31543
+ this.lastByteIndex = i;
31544
+ this.bytes += i - this.start;
31545
+ if (i >= 64) {
31546
+ this.block = blocks[16];
31547
+ this.start = i - 64;
31548
+ this.hash();
31549
+ this.hashed = true;
31550
+ } else {
31551
+ this.start = i;
31552
+ }
31553
+ }
31554
+ if (this.bytes > 4294967295) {
31555
+ this.hBytes += this.bytes / 4294967296 << 0;
31556
+ this.bytes = this.bytes % 4294967296;
31557
+ }
31558
+ return this;
31559
+ };
31560
+
31561
+ Sha256.prototype.finalize = function () {
31562
+ if (this.finalized) {
31563
+ return;
31564
+ }
31565
+ this.finalized = true;
31566
+ var blocks = this.blocks, i = this.lastByteIndex;
31567
+ blocks[16] = this.block;
31568
+ blocks[i >> 2] |= EXTRA[i & 3];
31569
+ this.block = blocks[16];
31570
+ if (i >= 56) {
31571
+ if (!this.hashed) {
31572
+ this.hash();
31573
+ }
31574
+ blocks[0] = this.block;
31575
+ blocks[16] = blocks[1] = blocks[2] = blocks[3] =
31576
+ blocks[4] = blocks[5] = blocks[6] = blocks[7] =
31577
+ blocks[8] = blocks[9] = blocks[10] = blocks[11] =
31578
+ blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
31579
+ }
31580
+ blocks[14] = this.hBytes << 3 | this.bytes >>> 29;
31581
+ blocks[15] = this.bytes << 3;
31582
+ this.hash();
31583
+ };
31584
+
31585
+ Sha256.prototype.hash = function () {
31586
+ var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6,
31587
+ h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc;
31588
+
31589
+ for (j = 16; j < 64; ++j) {
31590
+ // rightrotate
31591
+ t1 = blocks[j - 15];
31592
+ s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3);
31593
+ t1 = blocks[j - 2];
31594
+ s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10);
31595
+ blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0;
31596
+ }
31597
+
31598
+ bc = b & c;
31599
+ for (j = 0; j < 64; j += 4) {
31600
+ if (this.first) {
31601
+ if (this.is224) {
31602
+ ab = 300032;
31603
+ t1 = blocks[0] - 1413257819;
31604
+ h = t1 - 150054599 << 0;
31605
+ d = t1 + 24177077 << 0;
31606
+ } else {
31607
+ ab = 704751109;
31608
+ t1 = blocks[0] - 210244248;
31609
+ h = t1 - 1521486534 << 0;
31610
+ d = t1 + 143694565 << 0;
31611
+ }
31612
+ this.first = false;
31613
+ } else {
31614
+ s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
31615
+ s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
31616
+ ab = a & b;
31617
+ maj = ab ^ (a & c) ^ bc;
31618
+ ch = (e & f) ^ (~e & g);
31619
+ t1 = h + s1 + ch + K[j] + blocks[j];
31620
+ t2 = s0 + maj;
31621
+ h = d + t1 << 0;
31622
+ d = t1 + t2 << 0;
31623
+ }
31624
+ s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10));
31625
+ s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7));
31626
+ da = d & a;
31627
+ maj = da ^ (d & b) ^ ab;
31628
+ ch = (h & e) ^ (~h & f);
31629
+ t1 = g + s1 + ch + K[j + 1] + blocks[j + 1];
31630
+ t2 = s0 + maj;
31631
+ g = c + t1 << 0;
31632
+ c = t1 + t2 << 0;
31633
+ s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10));
31634
+ s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7));
31635
+ cd = c & d;
31636
+ maj = cd ^ (c & a) ^ da;
31637
+ ch = (g & h) ^ (~g & e);
31638
+ t1 = f + s1 + ch + K[j + 2] + blocks[j + 2];
31639
+ t2 = s0 + maj;
31640
+ f = b + t1 << 0;
31641
+ b = t1 + t2 << 0;
31642
+ s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10));
31643
+ s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7));
31644
+ bc = b & c;
31645
+ maj = bc ^ (b & d) ^ cd;
31646
+ ch = (f & g) ^ (~f & h);
31647
+ t1 = e + s1 + ch + K[j + 3] + blocks[j + 3];
31648
+ t2 = s0 + maj;
31649
+ e = a + t1 << 0;
31650
+ a = t1 + t2 << 0;
31651
+ }
31652
+
31653
+ this.h0 = this.h0 + a << 0;
31654
+ this.h1 = this.h1 + b << 0;
31655
+ this.h2 = this.h2 + c << 0;
31656
+ this.h3 = this.h3 + d << 0;
31657
+ this.h4 = this.h4 + e << 0;
31658
+ this.h5 = this.h5 + f << 0;
31659
+ this.h6 = this.h6 + g << 0;
31660
+ this.h7 = this.h7 + h << 0;
31661
+ };
31662
+
31663
+ Sha256.prototype.hex = function () {
31664
+ this.finalize();
31665
+
31666
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
31667
+ h6 = this.h6, h7 = this.h7;
31668
+
31669
+ var hex = HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] +
31670
+ HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] +
31671
+ HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] +
31672
+ HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
31673
+ HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] +
31674
+ HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] +
31675
+ HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] +
31676
+ HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
31677
+ HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] +
31678
+ HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] +
31679
+ HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] +
31680
+ HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
31681
+ HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] +
31682
+ HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] +
31683
+ HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] +
31684
+ HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
31685
+ HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] +
31686
+ HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] +
31687
+ HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] +
31688
+ HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] +
31689
+ HEX_CHARS[(h5 >> 28) & 0x0F] + HEX_CHARS[(h5 >> 24) & 0x0F] +
31690
+ HEX_CHARS[(h5 >> 20) & 0x0F] + HEX_CHARS[(h5 >> 16) & 0x0F] +
31691
+ HEX_CHARS[(h5 >> 12) & 0x0F] + HEX_CHARS[(h5 >> 8) & 0x0F] +
31692
+ HEX_CHARS[(h5 >> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] +
31693
+ HEX_CHARS[(h6 >> 28) & 0x0F] + HEX_CHARS[(h6 >> 24) & 0x0F] +
31694
+ HEX_CHARS[(h6 >> 20) & 0x0F] + HEX_CHARS[(h6 >> 16) & 0x0F] +
31695
+ HEX_CHARS[(h6 >> 12) & 0x0F] + HEX_CHARS[(h6 >> 8) & 0x0F] +
31696
+ HEX_CHARS[(h6 >> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F];
31697
+ if (!this.is224) {
31698
+ hex += HEX_CHARS[(h7 >> 28) & 0x0F] + HEX_CHARS[(h7 >> 24) & 0x0F] +
31699
+ HEX_CHARS[(h7 >> 20) & 0x0F] + HEX_CHARS[(h7 >> 16) & 0x0F] +
31700
+ HEX_CHARS[(h7 >> 12) & 0x0F] + HEX_CHARS[(h7 >> 8) & 0x0F] +
31701
+ HEX_CHARS[(h7 >> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F];
31702
+ }
31703
+ return hex;
31704
+ };
31705
+
31706
+ Sha256.prototype.toString = Sha256.prototype.hex;
31707
+
31708
+ Sha256.prototype.digest = function () {
31709
+ this.finalize();
31710
+
31711
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
31712
+ h6 = this.h6, h7 = this.h7;
31713
+
31714
+ var arr = [
31715
+ (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF,
31716
+ (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF,
31717
+ (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF,
31718
+ (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF,
31719
+ (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF,
31720
+ (h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, h5 & 0xFF,
31721
+ (h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, h6 & 0xFF
31722
+ ];
31723
+ if (!this.is224) {
31724
+ arr.push((h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, h7 & 0xFF);
31725
+ }
31726
+ return arr;
31727
+ };
31728
+
31729
+ Sha256.prototype.array = Sha256.prototype.digest;
31730
+
31731
+ Sha256.prototype.arrayBuffer = function () {
31732
+ this.finalize();
31733
+
31734
+ var buffer = new ArrayBuffer(this.is224 ? 28 : 32);
31735
+ var dataView = new DataView(buffer);
31736
+ dataView.setUint32(0, this.h0);
31737
+ dataView.setUint32(4, this.h1);
31738
+ dataView.setUint32(8, this.h2);
31739
+ dataView.setUint32(12, this.h3);
31740
+ dataView.setUint32(16, this.h4);
31741
+ dataView.setUint32(20, this.h5);
31742
+ dataView.setUint32(24, this.h6);
31743
+ if (!this.is224) {
31744
+ dataView.setUint32(28, this.h7);
31745
+ }
31746
+ return buffer;
31747
+ };
31748
+
31749
+ function HmacSha256(key, is224, sharedMemory) {
31750
+ var i, type = typeof key;
31751
+ if (type === 'string') {
31752
+ var bytes = [], length = key.length, index = 0, code;
31753
+ for (i = 0; i < length; ++i) {
31754
+ code = key.charCodeAt(i);
31755
+ if (code < 0x80) {
31756
+ bytes[index++] = code;
31757
+ } else if (code < 0x800) {
31758
+ bytes[index++] = (0xc0 | (code >> 6));
31759
+ bytes[index++] = (0x80 | (code & 0x3f));
31760
+ } else if (code < 0xd800 || code >= 0xe000) {
31761
+ bytes[index++] = (0xe0 | (code >> 12));
31762
+ bytes[index++] = (0x80 | ((code >> 6) & 0x3f));
31763
+ bytes[index++] = (0x80 | (code & 0x3f));
31764
+ } else {
31765
+ code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));
31766
+ bytes[index++] = (0xf0 | (code >> 18));
31767
+ bytes[index++] = (0x80 | ((code >> 12) & 0x3f));
31768
+ bytes[index++] = (0x80 | ((code >> 6) & 0x3f));
31769
+ bytes[index++] = (0x80 | (code & 0x3f));
31770
+ }
31771
+ }
31772
+ key = bytes;
31773
+ } else {
31774
+ if (type === 'object') {
31775
+ if (key === null) {
31776
+ throw new Error(ERROR);
31777
+ } else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) {
31778
+ key = new Uint8Array(key);
31779
+ } else if (!Array.isArray(key)) {
31780
+ if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) {
31781
+ throw new Error(ERROR);
31782
+ }
31783
+ }
31784
+ } else {
31785
+ throw new Error(ERROR);
31786
+ }
31787
+ }
31788
+
31789
+ if (key.length > 64) {
31790
+ key = (new Sha256(is224, true)).update(key).array();
31791
+ }
31792
+
31793
+ var oKeyPad = [], iKeyPad = [];
31794
+ for (i = 0; i < 64; ++i) {
31795
+ var b = key[i] || 0;
31796
+ oKeyPad[i] = 0x5c ^ b;
31797
+ iKeyPad[i] = 0x36 ^ b;
31798
+ }
31799
+
31800
+ Sha256.call(this, is224, sharedMemory);
31801
+
31802
+ this.update(iKeyPad);
31803
+ this.oKeyPad = oKeyPad;
31804
+ this.inner = true;
31805
+ this.sharedMemory = sharedMemory;
31806
+ }
31807
+ HmacSha256.prototype = new Sha256();
31808
+
31809
+ HmacSha256.prototype.finalize = function () {
31810
+ Sha256.prototype.finalize.call(this);
31811
+ if (this.inner) {
31812
+ this.inner = false;
31813
+ var innerHash = this.array();
31814
+ Sha256.call(this, this.is224, this.sharedMemory);
31815
+ this.update(this.oKeyPad);
31816
+ this.update(innerHash);
31817
+ Sha256.prototype.finalize.call(this);
31818
+ }
31819
+ };
31820
+
31821
+ var exports = createMethod();
31822
+ exports.sha256 = exports;
31823
+ exports.sha224 = createMethod(true);
31824
+ exports.sha256.hmac = createHmacMethod();
31825
+ exports.sha224.hmac = createHmacMethod(true);
31826
+
31827
+ if (COMMON_JS) {
31828
+ module.exports = exports;
31829
+ } else {
31830
+ root.sha256 = exports.sha256;
31831
+ root.sha224 = exports.sha224;
31832
+ if (AMD) {
31833
+ !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
31834
+ return exports;
31835
+ }).call(exports, __webpack_require__, exports, module),
31836
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
31837
+ }
31838
+ }
31839
+ })();
31840
+
31841
+
31215
31842
  /***/ }),
31216
31843
 
31217
31844
  /***/ 857:
@@ -42690,6 +43317,11 @@ try {
42690
43317
  /******/ }
42691
43318
  /******/
42692
43319
  /************************************************************************/
43320
+ /******/ /* webpack/runtime/amd options */
43321
+ /******/ (() => {
43322
+ /******/ __webpack_require__.amdO = {};
43323
+ /******/ })();
43324
+ /******/
42693
43325
  /******/ /* webpack/runtime/compat get default export */
42694
43326
  /******/ (() => {
42695
43327
  /******/ // getDefaultExport function for compatibility with non-harmony modules
@@ -44999,6 +45631,7 @@ function createCodeJsBridgeReceive(payloadStr) {
44999
45631
  ;// CONCATENATED MODULE: ./src/utils/bridgeUtils.ts
45000
45632
 
45001
45633
 
45634
+
45002
45635
  // eslint-disable-next-line import/no-mutable-exports
45003
45636
 
45004
45637
  let frameBridge; // eslint-disable-next-line import/no-mutable-exports
@@ -45028,7 +45661,7 @@ const sendMessage = async (messages, isHost = true) => {
45028
45661
  return result;
45029
45662
  } catch (error) {
45030
45663
  Log.error(error);
45031
- throw error;
45664
+ throw shared_dist.ERRORS.CreateErrorByMessage(error.message);
45032
45665
  }
45033
45666
  };
45034
45667
 
@@ -45138,7 +45771,9 @@ const src_init = async settings => {
45138
45771
  window.addEventListener('unload', src_dispose);
45139
45772
 
45140
45773
  try {
45141
- await init(_settings);
45774
+ await init({ ..._settings,
45775
+ version: "0.1.14"
45776
+ });
45142
45777
  return true;
45143
45778
  } catch (e) {
45144
45779
  console.log('init error: ', e);
@@ -45177,7 +45812,13 @@ const call = async params => {
45177
45812
  return (0,dist/* createErrorMessage */.xG)(shared_dist.ERRORS.TypedError(shared_dist.HardwareErrorCode.CallMethodNotResponse));
45178
45813
  } catch (error) {
45179
45814
  src_Log.error('__call error: ', error);
45180
- return (0,dist/* createErrorMessage */.xG)(error);
45815
+ let err = error;
45816
+
45817
+ if (!(err instanceof shared_dist.HardwareError)) {
45818
+ err = shared_dist.ERRORS.CreateErrorByMessage(error.message);
45819
+ }
45820
+
45821
+ return (0,dist/* createErrorMessage */.xG)(err);
45181
45822
  }
45182
45823
  };
45183
45824