From 0560bd7dfce3c6f99fab22f8bc56d5cac5231c58 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Thu, 21 Dec 2023 21:17:47 +0300 Subject: [PATCH 01/19] add rpc internal safari request --- Safari Shared/Models/Requests/InternalSafariRequest.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Safari Shared/Models/Requests/InternalSafariRequest.swift b/Safari Shared/Models/Requests/InternalSafariRequest.swift index 91ba9bf2..ab058ab2 100644 --- a/Safari Shared/Models/Requests/InternalSafariRequest.swift +++ b/Safari Shared/Models/Requests/InternalSafariRequest.swift @@ -7,6 +7,6 @@ struct InternalSafariRequest: Codable { let subject: Subject enum Subject: String, Codable { - case getResponse, cancelRequest + case getResponse, cancelRequest, rpc } } From 943c7c422063c01c58e6b48842361ffc7b9f388f Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Thu, 21 Dec 2023 21:38:49 +0300 Subject: [PATCH 02/19] pass rpc requests through service worker --- Safari Shared/Resources/service_worker.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Safari Shared/Resources/service_worker.js b/Safari Shared/Resources/service_worker.js index 37b350cb..1453db56 100644 --- a/Safari Shared/Resources/service_worker.js +++ b/Safari Shared/Resources/service_worker.js @@ -1,7 +1,13 @@ // Copyright © 2023 Tokenary. All rights reserved. function handleOnMessage(request, sender, sendResponse) { - if (request.subject === "message-to-wallet") { + if (request.subject === "rpc") { + browser.runtime.sendNativeMessage("mac.tokenary.io", request).then(response => { + if (typeof response !== "undefined") { + sendResponse(response); + } else { sendResponse(); } + }).catch(() => { sendResponse(); }); + } else if (request.subject === "message-to-wallet") { browser.runtime.sendNativeMessage("mac.tokenary.io", request.message).then(response => { if (typeof response !== "undefined") { sendResponse(response); From d25d2e5bbacea5fc06543147dc63227793d8cddc Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Thu, 21 Dec 2023 21:41:52 +0300 Subject: [PATCH 03/19] pass rpc requests through content script --- Safari Shared/Resources/content.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Safari Shared/Resources/content.js b/Safari Shared/Resources/content.js index 70fa3471..21022362 100644 --- a/Safari Shared/Resources/content.js +++ b/Safari Shared/Resources/content.js @@ -37,7 +37,11 @@ function setup() { // Receive from inpage window.addEventListener("message", event => { if (event.source == window && event.data) { - if (event.data.direction == "from-page-script") { + if (event.data.direction == "rpc") { + browser.runtime.sendMessage(event.data.message).then(response => { + window.postMessage({direction: "rpc-back", response: response}, "*"); + }).catch(() => {}); + } else if (event.data.direction == "from-page-script") { sendMessageToNativeApp(event.data.message, false); } else if (event.data.subject == "disconnect") { const disconnectRequest = event.data; From aea06deebce1b1da218aa3fc804d686717636f57 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Thu, 21 Dec 2023 21:44:15 +0300 Subject: [PATCH 04/19] receive rpc response back inpage --- Safari Shared/Inpage Provider/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Safari Shared/Inpage Provider/index.js b/Safari Shared/Inpage Provider/index.js index 96f73b6e..22598a09 100644 --- a/Safari Shared/Inpage Provider/index.js +++ b/Safari Shared/Inpage Provider/index.js @@ -44,7 +44,9 @@ announceProvider(); // - MARK: Process content script messages window.addEventListener("message", function(event) { - if (event.source == window && event.data && event.data.direction == "from-content-script") { + if (event.source == window && event.data && event.data.direction == "rpc-back") { + console.log("got it back inpage", event.data); // TODO: respond via rpc server + } else if (event.source == window && event.data && event.data.direction == "from-content-script") { const response = event.data.response; const id = event.data.id; From 7860f51c6ec4f863e176f681c39a54269b40dfc6 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Fri, 22 Dec 2023 16:56:02 +0300 Subject: [PATCH 05/19] access rpc request body in extension handler --- Safari Shared/Models/Requests/InternalSafariRequest.swift | 1 + Safari Shared/SafariWebExtensionHandler.swift | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Safari Shared/Models/Requests/InternalSafariRequest.swift b/Safari Shared/Models/Requests/InternalSafariRequest.swift index ab058ab2..4682fbb3 100644 --- a/Safari Shared/Models/Requests/InternalSafariRequest.swift +++ b/Safari Shared/Models/Requests/InternalSafariRequest.swift @@ -5,6 +5,7 @@ import Foundation struct InternalSafariRequest: Codable { let id: Int let subject: Subject + let body: String? enum Subject: String, Codable { case getResponse, cancelRequest, rpc diff --git a/Safari Shared/SafariWebExtensionHandler.swift b/Safari Shared/SafariWebExtensionHandler.swift index ea329f4c..5218fe4b 100644 --- a/Safari Shared/SafariWebExtensionHandler.swift +++ b/Safari Shared/SafariWebExtensionHandler.swift @@ -21,6 +21,12 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { if let internalSafariRequest = try? jsonDecoder.decode(InternalSafariRequest.self, from: data) { let id = internalSafariRequest.id switch internalSafariRequest.subject { + case .rpc: + if let body = internalSafariRequest.body { + respond(with: ["yo": body], context: context) // TODO: make rpc request + } else { + context.cancelRequest(withError: HandlerError.empty) + } case .getResponse: if let response = ExtensionBridge.getResponse(id: id) { ExtensionBridge.removeResponse(id: id) From 253120edae1609fb1412a8647442bf919829c2ad Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Sun, 24 Dec 2023 18:35:17 +0300 Subject: [PATCH 06/19] add rpcRequest stub to extension handler --- Safari Shared/SafariWebExtensionHandler.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Safari Shared/SafariWebExtensionHandler.swift b/Safari Shared/SafariWebExtensionHandler.swift index 5218fe4b..83b0d700 100644 --- a/Safari Shared/SafariWebExtensionHandler.swift +++ b/Safari Shared/SafariWebExtensionHandler.swift @@ -23,7 +23,7 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { switch internalSafariRequest.subject { case .rpc: if let body = internalSafariRequest.body { - respond(with: ["yo": body], context: context) // TODO: make rpc request + rpcRequest(body: body, context: context) } else { context.cancelRequest(withError: HandlerError.empty) } @@ -64,6 +64,11 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { } } + private func rpcRequest(body: String, context: NSExtensionContext) { + // TODO: make rpc request + respond(with: ["yo": body], context: context) + } + private func respond(with response: [String: Any], context: NSExtensionContext) { let item = NSExtensionItem() item.userInfo = [SFExtensionMessageKey: response] From 219571b2996ef0785a56ae34c48edc63e499badf Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Tue, 26 Dec 2023 20:09:48 +0300 Subject: [PATCH 07/19] setup inpage rpc service with chain id --- Safari Shared/Inpage Provider/ethereum.js | 6 +++--- Safari Shared/Models/Requests/InternalSafariRequest.swift | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Safari Shared/Inpage Provider/ethereum.js b/Safari Shared/Inpage Provider/ethereum.js index e03bb543..727e809f 100644 --- a/Safari Shared/Inpage Provider/ethereum.js +++ b/Safari Shared/Inpage Provider/ethereum.js @@ -73,8 +73,8 @@ class TokenaryEthereum extends EventEmitter { window.tokenary.eth.emit("accountsChanged", addresses); } - if (window.tokenary.eth.rpc.rpcUrl != rpcUrl) { - this.rpc = new RPCServer(rpcUrl); + if (window.tokenary.eth.rpc.chainId != chainId) { + this.rpc = new RPCServer(chainId); } if (window.tokenary.eth.chainId != chainId) { @@ -89,7 +89,7 @@ class TokenaryEthereum extends EventEmitter { setConfig(config) { this.chainId = config.chainId; - this.rpc = new RPCServer(config.rpcUrl); + this.rpc = new RPCServer(config.chainId); this.setAddress(config.address); this.networkVersion = this.net_version(); } diff --git a/Safari Shared/Models/Requests/InternalSafariRequest.swift b/Safari Shared/Models/Requests/InternalSafariRequest.swift index 4682fbb3..9393debb 100644 --- a/Safari Shared/Models/Requests/InternalSafariRequest.swift +++ b/Safari Shared/Models/Requests/InternalSafariRequest.swift @@ -6,6 +6,7 @@ struct InternalSafariRequest: Codable { let id: Int let subject: Subject let body: String? + let chainId: String? enum Subject: String, Codable { case getResponse, cancelRequest, rpc From 1caddc478740c7c85125e3536ef04773b6e69da9 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Mon, 22 Jan 2024 19:01:28 +0300 Subject: [PATCH 08/19] pass rpc requests from inpage to extension --- Safari Shared/Inpage Provider/rpc.js | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/Safari Shared/Inpage Provider/rpc.js b/Safari Shared/Inpage Provider/rpc.js index ee6b016f..0d45d041 100644 --- a/Safari Shared/Inpage Provider/rpc.js +++ b/Safari Shared/Inpage Provider/rpc.js @@ -4,27 +4,14 @@ "use strict"; class RPCServer { - constructor(rpcUrl) { - this.rpcUrl = rpcUrl; + + constructor(chainId) { + this.chainId = chainId; } call(payload) { - return fetch(this.rpcUrl, { - method: "POST", - headers: { - "Accept": "application/json", - "Content-Type": "application/json" - }, - body: JSON.stringify(payload) - }) - .then(response => response.json()) - .then(json => { - if (!json.result && json.error) { - console.log("<== rpc error", json.error); - throw new Error(json.error.message || "rpc error"); - } - return json; - }); + window.postMessage({direction: "rpc", message: {id: payload.id, subject: "rpc", chainId: this.chainId, body: JSON.stringify(payload)}}, "*"); + return true; } } From 912008c21374c39fa43e25ec7cf03e1700cc55a2 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Mon, 22 Jan 2024 19:12:48 +0300 Subject: [PATCH 09/19] stop using rpc inpage --- Safari Shared/Inpage Provider/ethereum.js | 10 +++++----- Safari Shared/Resources/inpage.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Safari Shared/Inpage Provider/ethereum.js b/Safari Shared/Inpage Provider/ethereum.js index 727e809f..5e8dac98 100644 --- a/Safari Shared/Inpage Provider/ethereum.js +++ b/Safari Shared/Inpage Provider/ethereum.js @@ -22,7 +22,7 @@ class TokenaryEthereum extends EventEmitter { constructor() { super(); - const config = {address: "", chainId: "0x1", rpcUrl: "https://eth.llamarpc.com"}; + const config = {address: "", chainId: "0x1"}; this.setConfig(config); this.idMapping = new IdMapping(); this.callbacks = new Map(); @@ -66,7 +66,7 @@ class TokenaryEthereum extends EventEmitter { this.ready = !!address; } - updateAccount(eventName, addresses, chainId, rpcUrl) { + updateAccount(eventName, addresses, chainId) { window.tokenary.eth.setAddress(addresses[0]); if (eventName == "switchAccount") { @@ -346,7 +346,7 @@ class TokenaryEthereum extends EventEmitter { if (response.name == "didLoadLatestConfiguration") { this.didGetLatestConfiguration = true; if (response.chainId) { - this.updateAccount(response.name, response.results, response.chainId, response.rpcURL); + this.updateAccount(response.name, response.results, response.chainId); } for(let payload of this.pendingPayloads) { @@ -362,14 +362,14 @@ class TokenaryEthereum extends EventEmitter { } else if ("results" in response) { if (response.name == "switchEthereumChain" || response.name == "addEthereumChain") { // Calling it before sending response matters for some dapps - this.updateAccount(response.name, response.results, response.chainId, response.rpcURL); + this.updateAccount(response.name, response.results, response.chainId); } if (response.name != "switchAccount") { this.sendResponse(id, response.results); } if (response.name == "requestAccounts" || response.name == "switchAccount") { // Calling it after sending response matters for some dapps - this.updateAccount(response.name, response.results, response.chainId, response.rpcURL); + this.updateAccount(response.name, response.results, response.chainId); } } else if ("error" in response) { this.sendError(id, response.error); diff --git a/Safari Shared/Resources/inpage.js b/Safari Shared/Resources/inpage.js index a7bb1dcb..33dd2075 100644 --- a/Safari Shared/Resources/inpage.js +++ b/Safari Shared/Resources/inpage.js @@ -1 +1 @@ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i1&&arguments[1]!==undefined?arguments[1]:true;this.idMapping.tryFixId(payload);return new Promise(function(resolve,reject){if(!payload.id){payload.id=_utils["default"].genId()}_this2.callbacks.set(payload.id,function(error,data){setTimeout(function(){if(error){reject(error)}else{resolve(data)}},1)});_this2.wrapResults.set(payload.id,wrapResult);switch(payload.method){case"eth_accounts":case"eth_coinbase":case"net_version":case"eth_chainId":case"eth_sign":case"personal_sign":case"personal_ecRecover":case"eth_signTypedData_v3":case"eth_signTypedData":case"eth_signTypedData_v4":case"eth_sendTransaction":case"eth_requestAccounts":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":case"wallet_requestPermissions":case"wallet_getPermissions":return _this2._processPayload(payload);case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_subscribe":throw new _error["default"](4200,"Tokenary does not support calling ".concat(payload.method,". Please use your own solution"));default:_this2.callbacks["delete"](payload.id);_this2.wrapResults["delete"](payload.id);return _this2.rpc.call(payload).then(function(response){wrapResult?resolve(response):resolve(response.result)})["catch"](reject)}})}},{key:"_processPayload",value:function _processPayload(payload){if(!this.didGetLatestConfiguration){this.pendingPayloads.push(payload);return}switch(payload.method){case"eth_accounts":return this.sendResponse(payload.id,this.eth_accounts());case"eth_coinbase":return this.sendResponse(payload.id,this.eth_coinbase());case"net_version":return this.sendResponse(payload.id,this.net_version());case"eth_chainId":return this.sendResponse(payload.id,this.eth_chainId());case"eth_sign":return this.eth_sign(payload);case"personal_sign":return this.personal_sign(payload);case"personal_ecRecover":return this.personal_ecRecover(payload);case"eth_signTypedData_v3":return this.eth_signTypedData(payload,false);case"eth_signTypedData":case"eth_signTypedData_v4":return this.eth_signTypedData(payload,true);case"eth_sendTransaction":return this.eth_sendTransaction(payload);case"eth_requestAccounts":if(!this.address){return this.eth_requestAccounts(payload)}else{return this.sendResponse(payload.id,this.eth_accounts())}case"wallet_addEthereumChain":return this.wallet_addEthereumChain(payload);case"wallet_switchEthereumChain":return this.wallet_switchEthereumChain(payload);case"wallet_requestPermissions":case"wallet_getPermissions":var permissions=[{parentCapability:"eth_accounts"}];return this.sendResponse(payload.id,permissions)}}},{key:"emitConnect",value:function emitConnect(chainId){this.emit("connect",{chainId:chainId})}},{key:"eth_accounts",value:function eth_accounts(){return this.address?[this.address]:[]}},{key:"eth_coinbase",value:function eth_coinbase(){return this.address}},{key:"net_version",value:function net_version(){return parseInt(this.chainId,16).toString(10)||null}},{key:"eth_chainId",value:function eth_chainId(){return this.chainId}},{key:"eth_sign",value:function eth_sign(payload){var buffer=_utils["default"].messageToBuffer(payload.params[1]);var hex=_utils["default"].bufferToHex(buffer);if((0,_isutf["default"])(buffer)){this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signMessage",payload.id,{data:hex})}}},{key:"personal_sign",value:function personal_sign(payload){var message=payload.params[0];var buffer=_utils["default"].messageToBuffer(message);if(buffer.length===0){var hex=_utils["default"].bufferToHex(message);this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signPersonalMessage",payload.id,{data:message})}}},{key:"personal_ecRecover",value:function personal_ecRecover(payload){this.postMessage("ecRecover",payload.id,{signature:payload.params[1],message:payload.params[0]})}},{key:"eth_signTypedData",value:function eth_signTypedData(payload,useV4){this.postMessage("signTypedMessage",payload.id,{raw:payload.params[1]})}},{key:"eth_sendTransaction",value:function eth_sendTransaction(payload){this.postMessage("signTransaction",payload.id,payload.params[0])}},{key:"eth_requestAccounts",value:function eth_requestAccounts(payload){this.postMessage("requestAccounts",payload.id,{})}},{key:"wallet_watchAsset",value:function wallet_watchAsset(payload){var options=payload.params.options;this.postMessage("watchAsset",payload.id,{type:payload.type,contract:options.address,symbol:options.symbol,decimals:options.decimals||0})}},{key:"wallet_switchEthereumChain",value:function wallet_switchEthereumChain(payload){if(this.chainId!=payload.params[0].chainId){this.postMessage("switchEthereumChain",payload.id,payload.params[0])}else{this.sendResponse(payload.id,[this.address])}}},{key:"wallet_addEthereumChain",value:function wallet_addEthereumChain(payload){this.postMessage("addEthereumChain",payload.id,payload.params[0])}},{key:"processTokenaryResponse",value:function processTokenaryResponse(id,response){if(response.name=="didLoadLatestConfiguration"){this.didGetLatestConfiguration=true;if(response.chainId){this.updateAccount(response.name,response.results,response.chainId,response.rpcURL)}var _iterator=_createForOfIteratorHelper(this.pendingPayloads),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var payload=_step.value;this._processPayload(payload)}}catch(err){_iterator.e(err)}finally{_iterator.f()}this.pendingPayloads=[];return}if("result"in response){this.sendResponse(id,response.result)}else if("results"in response){if(response.name=="switchEthereumChain"||response.name=="addEthereumChain"){this.updateAccount(response.name,response.results,response.chainId,response.rpcURL)}if(response.name!="switchAccount"){this.sendResponse(id,response.results)}if(response.name=="requestAccounts"||response.name=="switchAccount"){this.updateAccount(response.name,response.results,response.chainId,response.rpcURL)}}else if("error"in response){this.sendError(id,response.error)}}},{key:"postMessage",value:function postMessage(handler,id,data){if(this.ready||handler==="requestAccounts"||handler==="switchEthereumChain"||handler==="addEthereumChain"){var object={object:data,address:this.address,chainId:this.chainId};window.tokenary.postMessage(handler,id,object,"ethereum")}else{this.sendError(id,new _error["default"](4100,"provider is not ready"))}}},{key:"sendResponse",value:function sendResponse(id,result){var originId=this.idMapping.tryPopId(id)||id;var callback=this.callbacks.get(id);var wrapResult=this.wrapResults.get(id);var data={jsonrpc:"2.0",id:originId};if(result!==null&&result.jsonrpc&&result.result){data.result=result.result}else{data.result=result}if(callback){wrapResult?callback(null,data):callback(null,result);this.callbacks["delete"](id)}else{console.log("callback id: ".concat(id," not found"))}}},{key:"sendError",value:function sendError(id,error){console.log("<== ".concat(id," sendError ").concat(error));var callback=this.callbacks.get(id);if(callback){callback(error instanceof Error?error:new Error(error),null);this.callbacks["delete"](id)}}}]);return TokenaryEthereum}(_events.EventEmitter);module.exports=TokenaryEthereum},{"./error":1,"./id_mapping":3,"./rpc":10,"./utils":11,events:7,isutf8:9}],3:[function(require,module,exports){"use strict";var _utils=_interopRequireDefault(require("./utils"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;var i;for(i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],6:[function(require,module,exports){(function(Buffer){(function(){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH;Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport();if(!Buffer.TYPED_ARRAY_SUPPORT&&typeof console!=="undefined"&&typeof console.error==="function"){console.error("This browser lacks typed array (Uint8Array) support which is required by "+"`buffer` v5.x. Use `buffer` v4.x if you require old browser support.")}function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42}catch(e){return false}}Object.defineProperty(Buffer.prototype,"parent",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.buffer}});Object.defineProperty(Buffer.prototype,"offset",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.byteOffset}});function createBuffer(length){if(length>K_MAX_LENGTH){throw new RangeError('The value "'+length+'" is invalid for option "size"')}var buf=new Uint8Array(length);buf.__proto__=Buffer.prototype;return buf}function Buffer(arg,encodingOrOffset,length){if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new TypeError('The "string" argument must be of type string. Received type number')}return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}if(typeof Symbol!=="undefined"&&Symbol.species!=null&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true,enumerable:false,writable:false})}Buffer.poolSize=8192;function from(value,encodingOrOffset,length){if(typeof value==="string"){return fromString(value,encodingOrOffset)}if(ArrayBuffer.isView(value)){return fromArrayLike(value)}if(value==null){throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer)){return fromArrayBuffer(value,encodingOrOffset,length)}if(typeof value==="number"){throw new TypeError('The "value" argument must not be of type number. Received type number')}var valueOf=value.valueOf&&value.valueOf();if(valueOf!=null&&valueOf!==value){return Buffer.from(valueOf,encodingOrOffset,length)}var b=fromObject(value);if(b)return b;if(typeof Symbol!=="undefined"&&Symbol.toPrimitive!=null&&typeof value[Symbol.toPrimitive]==="function"){return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)};Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be of type number')}else if(size<0){throw new RangeError('The value "'+size+'" is invalid for option "size"')}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill)}return createBuffer(size)}Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding)};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0)}Buffer.allocUnsafe=function(size){return allocUnsafe(size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)};function fromString(string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}var length=byteLength(string,encoding)|0;var buf=createBuffer(length);var actual=buf.write(string,encoding);if(actual!==length){buf=buf.slice(0,actual)}return buf}function fromArrayLike(array){var length=array.length<0?0:checked(array.length)|0;var buf=createBuffer(length);for(var i=0;i=K_MAX_LENGTH){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+K_MAX_LENGTH.toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true&&b!==Buffer.prototype};Buffer.compare=function compare(a,b){if(isInstance(a,Uint8Array))a=Buffer.from(a,a.offset,a.byteLength);if(isInstance(b,Uint8Array))b=Buffer.from(b,b.offset,b.byteLength);if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array')}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i2&&arguments[2]===true;if(!mustMatch&&len===0)return 0;var loweredCase=false;for(;;){switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return len*2;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase){return mustMatch?-1:utf8ToBytes(string).length}encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;imax)str+=" ... ";return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)){target=Buffer.from(target,target.offset,target.byteLength)}if(!Buffer.isBuffer(target)){throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. '+"Received type "+typeof target)}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(numberIsNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(length>strLen/2){length=strLen/2}for(var i=0;i>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);this[offset]=value&255;return offset+1};Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255;return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}if(val.length===1){var code=val.charCodeAt(0);if(encoding==="utf8"&&code<128||encoding==="latin1"){val=code}}}else if(typeof val==="number"){val=val&255}if(start<0||this.length>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isInstance(obj,type){return obj instanceof type||obj!=null&&obj.constructor!=null&&obj.constructor.name!=null&&obj.constructor.name===type.name}function numberIsNaN(obj){return obj!==obj}}).call(this)}).call(this,require("buffer").Buffer)},{"base64-js":5,buffer:6,ieee754:8}],7:[function(require,module,exports){"use strict";var R=typeof Reflect==="object"?Reflect:null;var ReflectApply=R&&typeof R.apply==="function"?R.apply:function ReflectApply(target,receiver,args){return Function.prototype.apply.call(target,receiver,args)};var ReflectOwnKeys;if(R&&typeof R.ownKeys==="function"){ReflectOwnKeys=R.ownKeys}else if(Object.getOwnPropertySymbols){ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target))}}else{ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target)}}function ProcessEmitWarning(warning){if(console&&console.warn)console.warn(warning)}var NumberIsNaN=Number.isNaN||function NumberIsNaN(value){return value!==value};function EventEmitter(){EventEmitter.init.call(this)}module.exports=EventEmitter;module.exports.once=once;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=undefined;var defaultMaxListeners=10;function checkListener(listener){if(typeof listener!=="function"){throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof listener)}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:true,get:function(){return defaultMaxListeners},set:function(arg){if(typeof arg!=="number"||arg<0||NumberIsNaN(arg)){throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+arg+".")}defaultMaxListeners=arg}});EventEmitter.init=function(){if(this._events===undefined||this._events===Object.getPrototypeOf(this)._events){this._events=Object.create(null);this._eventsCount=0}this._maxListeners=this._maxListeners||undefined};EventEmitter.prototype.setMaxListeners=function setMaxListeners(n){if(typeof n!=="number"||n<0||NumberIsNaN(n)){throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".")}this._maxListeners=n;return this};function _getMaxListeners(that){if(that._maxListeners===undefined)return EventEmitter.defaultMaxListeners;return that._maxListeners}EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function emit(type){var args=[];for(var i=1;i0)er=args[0];if(er instanceof Error){throw er}var err=new Error("Unhandled error."+(er?" ("+er.message+")":""));err.context=er;throw err}var handler=events[type];if(handler===undefined)return false;if(typeof handler==="function"){ReflectApply(handler,this,args)}else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i0&&existing.length>m&&!existing.warned){existing.warned=true;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+" "+String(type)+" listeners "+"added. Use emitter.setMaxListeners() to "+"increase limit");w.name="MaxListenersExceededWarning";w.emitter=target;w.type=type;w.count=existing.length;ProcessEmitWarning(w)}}return target}EventEmitter.prototype.addListener=function addListener(type,listener){return _addListener(this,type,listener,false)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function prependListener(type,listener){return _addListener(this,type,listener,true)};function onceWrapper(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;if(arguments.length===0)return this.listener.call(this.target);return this.listener.apply(this.target,arguments)}}function _onceWrap(target,type,listener){var state={fired:false,wrapFn:undefined,target:target,type:type,listener:listener};var wrapped=onceWrapper.bind(state);wrapped.listener=listener;state.wrapFn=wrapped;return wrapped}EventEmitter.prototype.once=function once(type,listener){checkListener(listener);this.on(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.prependOnceListener=function prependOnceListener(type,listener){checkListener(listener);this.prependListener(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.removeListener=function removeListener(type,listener){var list,events,position,i,originalListener;checkListener(listener);events=this._events;if(events===undefined)return this;list=events[type];if(list===undefined)return this;if(list===listener||list.listener===listener){if(--this._eventsCount===0)this._events=Object.create(null);else{delete events[type];if(events.removeListener)this.emit("removeListener",type,list.listener||listener)}}else if(typeof list!=="function"){position=-1;for(i=list.length-1;i>=0;i--){if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener;position=i;break}}if(position<0)return this;if(position===0)list.shift();else{spliceOne(list,position)}if(list.length===1)events[type]=list[0];if(events.removeListener!==undefined)this.emit("removeListener",type,originalListener||listener)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function removeAllListeners(type){var listeners,events,i;events=this._events;if(events===undefined)return this;if(events.removeListener===undefined){if(arguments.length===0){this._events=Object.create(null);this._eventsCount=0}else if(events[type]!==undefined){if(--this._eventsCount===0)this._events=Object.create(null);else delete events[type]}return this}if(arguments.length===0){var keys=Object.keys(events);var key;for(i=0;i=0;i--){this.removeListener(type,listeners[i])}}return this};function _listeners(target,type,unwrap){var events=target._events;if(events===undefined)return[];var evlistener=events[type];if(evlistener===undefined)return[];if(typeof evlistener==="function")return unwrap?[evlistener.listener||evlistener]:[evlistener];return unwrap?unwrapListeners(evlistener):arrayClone(evlistener,evlistener.length)}EventEmitter.prototype.listeners=function listeners(type){return _listeners(this,type,true)};EventEmitter.prototype.rawListeners=function rawListeners(type){return _listeners(this,type,false)};EventEmitter.listenerCount=function(emitter,type){if(typeof emitter.listenerCount==="function"){return emitter.listenerCount(type)}else{return listenerCount.call(emitter,type)}};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(type){var events=this._events;if(events!==undefined){var evlistener=events[type];if(typeof evlistener==="function"){return 1}else if(evlistener!==undefined){return evlistener.length}}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(arr,n){var copy=new Array(n);for(var i=0;i>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],9:[function(require,module,exports){"use strict";function isUtf8(buf){if(!buf){return false}let i=0;const len=buf.length;while(i=194&&buf[i]<=223){if(buf[i+1]>>6===2){i+=2;continue}else{return false}}if((buf[i]===224&&buf[i+1]>=160&&buf[i+1]<=191||buf[i]===237&&buf[i+1]>=128&&buf[i+1]<=159)&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]>=225&&buf[i]<=236||buf[i]>=238&&buf[i]<=239)&&buf[i+1]>>6===2&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]===240&&buf[i+1]>=144&&buf[i+1]<=191||buf[i]>=241&&buf[i]<=243&&buf[i+1]>>6===2||buf[i]===244&&buf[i+1]>=128&&buf[i+1]<=143)&&buf[i+2]>>6===2&&buf[i+3]>>6===2){i+=4;continue}return false}return true}module.exports=isUtf8},{}],10:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i=to){return[]}return new Array(to-from).fill().map(function(_,i){return i+from})}},{key:"hexToInt",value:function hexToInt(hexString){if(hexString===undefined||hexString===null){return hexString}return Number.parseInt(hexString,16)}},{key:"intToHex",value:function intToHex(_int){if(_int===undefined||_int===null){return _int}var hexString=_int.toString(16);return"0x"+hexString}},{key:"messageToBuffer",value:function messageToBuffer(message){var buffer=_buffer.Buffer.from([]);try{if(typeof message==="string"){buffer=_buffer.Buffer.from(message.replace("0x",""),"hex")}else{buffer=_buffer.Buffer.from(message)}}catch(err){console.log("messageToBuffer error: ".concat(err))}return buffer}},{key:"bufferToHex",value:function bufferToHex(buf){return"0x"+_buffer.Buffer.from(buf).toString("hex")}}]);return Utils}();module.exports=Utils},{buffer:6}]},{},[4]); \ No newline at end of file +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i1&&arguments[1]!==undefined?arguments[1]:true;this.idMapping.tryFixId(payload);return new Promise(function(resolve,reject){if(!payload.id){payload.id=_utils["default"].genId()}_this2.callbacks.set(payload.id,function(error,data){setTimeout(function(){if(error){reject(error)}else{resolve(data)}},1)});_this2.wrapResults.set(payload.id,wrapResult);switch(payload.method){case"eth_accounts":case"eth_coinbase":case"net_version":case"eth_chainId":case"eth_sign":case"personal_sign":case"personal_ecRecover":case"eth_signTypedData_v3":case"eth_signTypedData":case"eth_signTypedData_v4":case"eth_sendTransaction":case"eth_requestAccounts":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":case"wallet_requestPermissions":case"wallet_getPermissions":return _this2._processPayload(payload);case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_subscribe":throw new _error["default"](4200,"Tokenary does not support calling ".concat(payload.method,". Please use your own solution"));default:_this2.callbacks["delete"](payload.id);_this2.wrapResults["delete"](payload.id);return _this2.rpc.call(payload).then(function(response){wrapResult?resolve(response):resolve(response.result)})["catch"](reject)}})}},{key:"_processPayload",value:function _processPayload(payload){if(!this.didGetLatestConfiguration){this.pendingPayloads.push(payload);return}switch(payload.method){case"eth_accounts":return this.sendResponse(payload.id,this.eth_accounts());case"eth_coinbase":return this.sendResponse(payload.id,this.eth_coinbase());case"net_version":return this.sendResponse(payload.id,this.net_version());case"eth_chainId":return this.sendResponse(payload.id,this.eth_chainId());case"eth_sign":return this.eth_sign(payload);case"personal_sign":return this.personal_sign(payload);case"personal_ecRecover":return this.personal_ecRecover(payload);case"eth_signTypedData_v3":return this.eth_signTypedData(payload,false);case"eth_signTypedData":case"eth_signTypedData_v4":return this.eth_signTypedData(payload,true);case"eth_sendTransaction":return this.eth_sendTransaction(payload);case"eth_requestAccounts":if(!this.address){return this.eth_requestAccounts(payload)}else{return this.sendResponse(payload.id,this.eth_accounts())}case"wallet_addEthereumChain":return this.wallet_addEthereumChain(payload);case"wallet_switchEthereumChain":return this.wallet_switchEthereumChain(payload);case"wallet_requestPermissions":case"wallet_getPermissions":var permissions=[{parentCapability:"eth_accounts"}];return this.sendResponse(payload.id,permissions)}}},{key:"emitConnect",value:function emitConnect(chainId){this.emit("connect",{chainId:chainId})}},{key:"eth_accounts",value:function eth_accounts(){return this.address?[this.address]:[]}},{key:"eth_coinbase",value:function eth_coinbase(){return this.address}},{key:"net_version",value:function net_version(){return parseInt(this.chainId,16).toString(10)||null}},{key:"eth_chainId",value:function eth_chainId(){return this.chainId}},{key:"eth_sign",value:function eth_sign(payload){var buffer=_utils["default"].messageToBuffer(payload.params[1]);var hex=_utils["default"].bufferToHex(buffer);if((0,_isutf["default"])(buffer)){this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signMessage",payload.id,{data:hex})}}},{key:"personal_sign",value:function personal_sign(payload){var message=payload.params[0];var buffer=_utils["default"].messageToBuffer(message);if(buffer.length===0){var hex=_utils["default"].bufferToHex(message);this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signPersonalMessage",payload.id,{data:message})}}},{key:"personal_ecRecover",value:function personal_ecRecover(payload){this.postMessage("ecRecover",payload.id,{signature:payload.params[1],message:payload.params[0]})}},{key:"eth_signTypedData",value:function eth_signTypedData(payload,useV4){this.postMessage("signTypedMessage",payload.id,{raw:payload.params[1]})}},{key:"eth_sendTransaction",value:function eth_sendTransaction(payload){this.postMessage("signTransaction",payload.id,payload.params[0])}},{key:"eth_requestAccounts",value:function eth_requestAccounts(payload){this.postMessage("requestAccounts",payload.id,{})}},{key:"wallet_watchAsset",value:function wallet_watchAsset(payload){var options=payload.params.options;this.postMessage("watchAsset",payload.id,{type:payload.type,contract:options.address,symbol:options.symbol,decimals:options.decimals||0})}},{key:"wallet_switchEthereumChain",value:function wallet_switchEthereumChain(payload){if(this.chainId!=payload.params[0].chainId){this.postMessage("switchEthereumChain",payload.id,payload.params[0])}else{this.sendResponse(payload.id,[this.address])}}},{key:"wallet_addEthereumChain",value:function wallet_addEthereumChain(payload){this.postMessage("addEthereumChain",payload.id,payload.params[0])}},{key:"processTokenaryResponse",value:function processTokenaryResponse(id,response){if(response.name=="didLoadLatestConfiguration"){this.didGetLatestConfiguration=true;if(response.chainId){this.updateAccount(response.name,response.results,response.chainId)}var _iterator=_createForOfIteratorHelper(this.pendingPayloads),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var payload=_step.value;this._processPayload(payload)}}catch(err){_iterator.e(err)}finally{_iterator.f()}this.pendingPayloads=[];return}if("result"in response){this.sendResponse(id,response.result)}else if("results"in response){if(response.name=="switchEthereumChain"||response.name=="addEthereumChain"){this.updateAccount(response.name,response.results,response.chainId)}if(response.name!="switchAccount"){this.sendResponse(id,response.results)}if(response.name=="requestAccounts"||response.name=="switchAccount"){this.updateAccount(response.name,response.results,response.chainId)}}else if("error"in response){this.sendError(id,response.error)}}},{key:"postMessage",value:function postMessage(handler,id,data){if(this.ready||handler==="requestAccounts"||handler==="switchEthereumChain"||handler==="addEthereumChain"){var object={object:data,address:this.address,chainId:this.chainId};window.tokenary.postMessage(handler,id,object,"ethereum")}else{this.sendError(id,new _error["default"](4100,"provider is not ready"))}}},{key:"sendResponse",value:function sendResponse(id,result){var originId=this.idMapping.tryPopId(id)||id;var callback=this.callbacks.get(id);var wrapResult=this.wrapResults.get(id);var data={jsonrpc:"2.0",id:originId};if(result!==null&&result.jsonrpc&&result.result){data.result=result.result}else{data.result=result}if(callback){wrapResult?callback(null,data):callback(null,result);this.callbacks["delete"](id)}else{console.log("callback id: ".concat(id," not found"))}}},{key:"sendError",value:function sendError(id,error){console.log("<== ".concat(id," sendError ").concat(error));var callback=this.callbacks.get(id);if(callback){callback(error instanceof Error?error:new Error(error),null);this.callbacks["delete"](id)}}}]);return TokenaryEthereum}(_events.EventEmitter);module.exports=TokenaryEthereum},{"./error":1,"./id_mapping":3,"./rpc":10,"./utils":11,events:7,isutf8:9}],3:[function(require,module,exports){"use strict";var _utils=_interopRequireDefault(require("./utils"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;var i;for(i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],6:[function(require,module,exports){(function(Buffer){(function(){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH;Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport();if(!Buffer.TYPED_ARRAY_SUPPORT&&typeof console!=="undefined"&&typeof console.error==="function"){console.error("This browser lacks typed array (Uint8Array) support which is required by "+"`buffer` v5.x. Use `buffer` v4.x if you require old browser support.")}function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42}catch(e){return false}}Object.defineProperty(Buffer.prototype,"parent",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.buffer}});Object.defineProperty(Buffer.prototype,"offset",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.byteOffset}});function createBuffer(length){if(length>K_MAX_LENGTH){throw new RangeError('The value "'+length+'" is invalid for option "size"')}var buf=new Uint8Array(length);buf.__proto__=Buffer.prototype;return buf}function Buffer(arg,encodingOrOffset,length){if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new TypeError('The "string" argument must be of type string. Received type number')}return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}if(typeof Symbol!=="undefined"&&Symbol.species!=null&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true,enumerable:false,writable:false})}Buffer.poolSize=8192;function from(value,encodingOrOffset,length){if(typeof value==="string"){return fromString(value,encodingOrOffset)}if(ArrayBuffer.isView(value)){return fromArrayLike(value)}if(value==null){throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer)){return fromArrayBuffer(value,encodingOrOffset,length)}if(typeof value==="number"){throw new TypeError('The "value" argument must not be of type number. Received type number')}var valueOf=value.valueOf&&value.valueOf();if(valueOf!=null&&valueOf!==value){return Buffer.from(valueOf,encodingOrOffset,length)}var b=fromObject(value);if(b)return b;if(typeof Symbol!=="undefined"&&Symbol.toPrimitive!=null&&typeof value[Symbol.toPrimitive]==="function"){return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)};Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be of type number')}else if(size<0){throw new RangeError('The value "'+size+'" is invalid for option "size"')}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill)}return createBuffer(size)}Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding)};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0)}Buffer.allocUnsafe=function(size){return allocUnsafe(size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)};function fromString(string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}var length=byteLength(string,encoding)|0;var buf=createBuffer(length);var actual=buf.write(string,encoding);if(actual!==length){buf=buf.slice(0,actual)}return buf}function fromArrayLike(array){var length=array.length<0?0:checked(array.length)|0;var buf=createBuffer(length);for(var i=0;i=K_MAX_LENGTH){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+K_MAX_LENGTH.toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true&&b!==Buffer.prototype};Buffer.compare=function compare(a,b){if(isInstance(a,Uint8Array))a=Buffer.from(a,a.offset,a.byteLength);if(isInstance(b,Uint8Array))b=Buffer.from(b,b.offset,b.byteLength);if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array')}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i2&&arguments[2]===true;if(!mustMatch&&len===0)return 0;var loweredCase=false;for(;;){switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return len*2;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase){return mustMatch?-1:utf8ToBytes(string).length}encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;imax)str+=" ... ";return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)){target=Buffer.from(target,target.offset,target.byteLength)}if(!Buffer.isBuffer(target)){throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. '+"Received type "+typeof target)}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(numberIsNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(length>strLen/2){length=strLen/2}for(var i=0;i>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);this[offset]=value&255;return offset+1};Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255;return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}if(val.length===1){var code=val.charCodeAt(0);if(encoding==="utf8"&&code<128||encoding==="latin1"){val=code}}}else if(typeof val==="number"){val=val&255}if(start<0||this.length>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isInstance(obj,type){return obj instanceof type||obj!=null&&obj.constructor!=null&&obj.constructor.name!=null&&obj.constructor.name===type.name}function numberIsNaN(obj){return obj!==obj}}).call(this)}).call(this,require("buffer").Buffer)},{"base64-js":5,buffer:6,ieee754:8}],7:[function(require,module,exports){"use strict";var R=typeof Reflect==="object"?Reflect:null;var ReflectApply=R&&typeof R.apply==="function"?R.apply:function ReflectApply(target,receiver,args){return Function.prototype.apply.call(target,receiver,args)};var ReflectOwnKeys;if(R&&typeof R.ownKeys==="function"){ReflectOwnKeys=R.ownKeys}else if(Object.getOwnPropertySymbols){ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target))}}else{ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target)}}function ProcessEmitWarning(warning){if(console&&console.warn)console.warn(warning)}var NumberIsNaN=Number.isNaN||function NumberIsNaN(value){return value!==value};function EventEmitter(){EventEmitter.init.call(this)}module.exports=EventEmitter;module.exports.once=once;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=undefined;var defaultMaxListeners=10;function checkListener(listener){if(typeof listener!=="function"){throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof listener)}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:true,get:function(){return defaultMaxListeners},set:function(arg){if(typeof arg!=="number"||arg<0||NumberIsNaN(arg)){throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+arg+".")}defaultMaxListeners=arg}});EventEmitter.init=function(){if(this._events===undefined||this._events===Object.getPrototypeOf(this)._events){this._events=Object.create(null);this._eventsCount=0}this._maxListeners=this._maxListeners||undefined};EventEmitter.prototype.setMaxListeners=function setMaxListeners(n){if(typeof n!=="number"||n<0||NumberIsNaN(n)){throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".")}this._maxListeners=n;return this};function _getMaxListeners(that){if(that._maxListeners===undefined)return EventEmitter.defaultMaxListeners;return that._maxListeners}EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function emit(type){var args=[];for(var i=1;i0)er=args[0];if(er instanceof Error){throw er}var err=new Error("Unhandled error."+(er?" ("+er.message+")":""));err.context=er;throw err}var handler=events[type];if(handler===undefined)return false;if(typeof handler==="function"){ReflectApply(handler,this,args)}else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i0&&existing.length>m&&!existing.warned){existing.warned=true;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+" "+String(type)+" listeners "+"added. Use emitter.setMaxListeners() to "+"increase limit");w.name="MaxListenersExceededWarning";w.emitter=target;w.type=type;w.count=existing.length;ProcessEmitWarning(w)}}return target}EventEmitter.prototype.addListener=function addListener(type,listener){return _addListener(this,type,listener,false)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function prependListener(type,listener){return _addListener(this,type,listener,true)};function onceWrapper(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;if(arguments.length===0)return this.listener.call(this.target);return this.listener.apply(this.target,arguments)}}function _onceWrap(target,type,listener){var state={fired:false,wrapFn:undefined,target:target,type:type,listener:listener};var wrapped=onceWrapper.bind(state);wrapped.listener=listener;state.wrapFn=wrapped;return wrapped}EventEmitter.prototype.once=function once(type,listener){checkListener(listener);this.on(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.prependOnceListener=function prependOnceListener(type,listener){checkListener(listener);this.prependListener(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.removeListener=function removeListener(type,listener){var list,events,position,i,originalListener;checkListener(listener);events=this._events;if(events===undefined)return this;list=events[type];if(list===undefined)return this;if(list===listener||list.listener===listener){if(--this._eventsCount===0)this._events=Object.create(null);else{delete events[type];if(events.removeListener)this.emit("removeListener",type,list.listener||listener)}}else if(typeof list!=="function"){position=-1;for(i=list.length-1;i>=0;i--){if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener;position=i;break}}if(position<0)return this;if(position===0)list.shift();else{spliceOne(list,position)}if(list.length===1)events[type]=list[0];if(events.removeListener!==undefined)this.emit("removeListener",type,originalListener||listener)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function removeAllListeners(type){var listeners,events,i;events=this._events;if(events===undefined)return this;if(events.removeListener===undefined){if(arguments.length===0){this._events=Object.create(null);this._eventsCount=0}else if(events[type]!==undefined){if(--this._eventsCount===0)this._events=Object.create(null);else delete events[type]}return this}if(arguments.length===0){var keys=Object.keys(events);var key;for(i=0;i=0;i--){this.removeListener(type,listeners[i])}}return this};function _listeners(target,type,unwrap){var events=target._events;if(events===undefined)return[];var evlistener=events[type];if(evlistener===undefined)return[];if(typeof evlistener==="function")return unwrap?[evlistener.listener||evlistener]:[evlistener];return unwrap?unwrapListeners(evlistener):arrayClone(evlistener,evlistener.length)}EventEmitter.prototype.listeners=function listeners(type){return _listeners(this,type,true)};EventEmitter.prototype.rawListeners=function rawListeners(type){return _listeners(this,type,false)};EventEmitter.listenerCount=function(emitter,type){if(typeof emitter.listenerCount==="function"){return emitter.listenerCount(type)}else{return listenerCount.call(emitter,type)}};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(type){var events=this._events;if(events!==undefined){var evlistener=events[type];if(typeof evlistener==="function"){return 1}else if(evlistener!==undefined){return evlistener.length}}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(arr,n){var copy=new Array(n);for(var i=0;i>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],9:[function(require,module,exports){"use strict";function isUtf8(buf){if(!buf){return false}let i=0;const len=buf.length;while(i=194&&buf[i]<=223){if(buf[i+1]>>6===2){i+=2;continue}else{return false}}if((buf[i]===224&&buf[i+1]>=160&&buf[i+1]<=191||buf[i]===237&&buf[i+1]>=128&&buf[i+1]<=159)&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]>=225&&buf[i]<=236||buf[i]>=238&&buf[i]<=239)&&buf[i+1]>>6===2&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]===240&&buf[i+1]>=144&&buf[i+1]<=191||buf[i]>=241&&buf[i]<=243&&buf[i+1]>>6===2||buf[i]===244&&buf[i+1]>=128&&buf[i+1]<=143)&&buf[i+2]>>6===2&&buf[i+3]>>6===2){i+=4;continue}return false}return true}module.exports=isUtf8},{}],10:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i=to){return[]}return new Array(to-from).fill().map(function(_,i){return i+from})}},{key:"hexToInt",value:function hexToInt(hexString){if(hexString===undefined||hexString===null){return hexString}return Number.parseInt(hexString,16)}},{key:"intToHex",value:function intToHex(_int){if(_int===undefined||_int===null){return _int}var hexString=_int.toString(16);return"0x"+hexString}},{key:"messageToBuffer",value:function messageToBuffer(message){var buffer=_buffer.Buffer.from([]);try{if(typeof message==="string"){buffer=_buffer.Buffer.from(message.replace("0x",""),"hex")}else{buffer=_buffer.Buffer.from(message)}}catch(err){console.log("messageToBuffer error: ".concat(err))}return buffer}},{key:"bufferToHex",value:function bufferToHex(buf){return"0x"+_buffer.Buffer.from(buf).toString("hex")}}]);return Utils}();module.exports=Utils},{buffer:6}]},{},[4]); \ No newline at end of file From 76c8fcea95adc9f5343d35e3ef42bcf678184e4b Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Mon, 22 Jan 2024 20:03:32 +0300 Subject: [PATCH 10/19] fix vision pro crash --- Tokenary iOS/Screens/PasswordViewController.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Tokenary iOS/Screens/PasswordViewController.swift b/Tokenary iOS/Screens/PasswordViewController.swift index 0435368f..de6c0b8e 100644 --- a/Tokenary iOS/Screens/PasswordViewController.swift +++ b/Tokenary iOS/Screens/PasswordViewController.swift @@ -48,7 +48,7 @@ class PasswordViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if mode != .enter { - passwordTextField.becomeFirstResponder() + focusOnPasswordTextField() } } @@ -89,7 +89,14 @@ class PasswordViewController: UIViewController { private func didFailLocalAuthentication() { navigationController?.setNavigationBarHidden(false, animated: false) initialOverlayView.isHidden = true - passwordTextField.becomeFirstResponder() + focusOnPasswordTextField() + } + + func focusOnPasswordTextField() { + // TODO: remove temporary delay used to fix vision pro crash + DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1000)) { [weak self] in + self?.passwordTextField.becomeFirstResponder() + } } @IBAction func okButtonTapped(_ sender: Any) { From 1cacd1e3c641fa3fae621aa80f38fdfbf8b2c3d5 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Mon, 22 Jan 2024 20:52:24 +0300 Subject: [PATCH 11/19] make rpc requests in extension handler --- Safari Shared/SafariWebExtensionHandler.swift | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/Safari Shared/SafariWebExtensionHandler.swift b/Safari Shared/SafariWebExtensionHandler.swift index 83b0d700..d9dff56e 100644 --- a/Safari Shared/SafariWebExtensionHandler.swift +++ b/Safari Shared/SafariWebExtensionHandler.swift @@ -22,8 +22,8 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { let id = internalSafariRequest.id switch internalSafariRequest.subject { case .rpc: - if let body = internalSafariRequest.body { - rpcRequest(body: body, context: context) + if let body = internalSafariRequest.body, let chainId = internalSafariRequest.chainId { + rpcRequest(chainId: chainId, body: body, context: context) } else { context.cancelRequest(withError: HandlerError.empty) } @@ -64,9 +64,30 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { } } - private func rpcRequest(body: String, context: NSExtensionContext) { - // TODO: make rpc request - respond(with: ["yo": body], context: context) + private func rpcRequest(chainId: String, body: String, context: NSExtensionContext) { + guard let chainIdNumber = Int(hexString: chainId), + let rpcURLString = Nodes.getNode(chainId: chainIdNumber), + let url = URL(string: rpcURLString), + let httpBody = body.data(using: .utf8) else { + // TODO: respond with error + return + } + + var request = URLRequest(url: url) + request.httpMethod = "POST" + request.setValue("application/json", forHTTPHeaderField: "Accept") + request.setValue("application/json", forHTTPHeaderField: "Content-Type") + request.httpBody = body.data(using: .utf8) + + let task = URLSession.shared.dataTask(with: request) { [weak self] data, response, error in + if let data = data, let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] { + self?.respond(with: json, context: context) + } else { + // TODO: respond with error + self?.respond(with: ["yo": "body", "chainId": chainId, "result": "gg"], context: context) + } + } + task.resume() } private func respond(with response: [String: Any], context: NSExtensionContext) { From 1e48baeea5e081df72ffd084ea8eb4bb608e70a6 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Tue, 23 Jan 2024 14:02:43 +0300 Subject: [PATCH 12/19] update fileheader --- Safari Shared/ExtensionBridge.swift | 2 +- Safari Shared/Inpage Provider/error.js | 2 +- Safari Shared/Inpage Provider/ethereum.js | 2 +- Safari Shared/Inpage Provider/id_mapping.js | 2 +- Safari Shared/Inpage Provider/index.js | 2 +- Safari Shared/Inpage Provider/rpc.js | 2 +- Safari Shared/Inpage Provider/utils.js | 2 +- Safari Shared/Models/InpageProvider.swift | 2 +- Safari Shared/Models/Requests/EthereumSafariRequest.swift | 2 +- Safari Shared/Models/Requests/InternalSafariRequest.swift | 2 +- Safari Shared/Models/Requests/SafariRequest.swift | 2 +- Safari Shared/Models/Requests/UnknownSafariRequest.swift | 2 +- .../Models/Responses/EthereumResponseToExtension.swift | 2 +- .../Models/Responses/MultipleResponseToExtension.swift | 2 +- Safari Shared/Models/Responses/ResponseToExtension.swift | 2 +- Safari Shared/Resources/content.js | 2 +- Safari Shared/Resources/service_worker.js | 2 +- Safari Shared/SafariWebExtensionHandler.swift | 2 +- Safari iOS/Resources/ios_specific_content.js | 2 +- Safari macOS/Resources/macos_specific_content.js | 2 +- Shared/Defaults.swift | 2 +- Shared/Ethereum/Ethereum.swift | 2 +- Shared/Ethereum/EthereumNetwork.swift | 2 +- Shared/Ethereum/EthereumRPC.swift | 2 +- Shared/Ethereum/Networks.swift | 2 +- Shared/Ethereum/Nodes.swift | 2 +- Shared/Ethereum/Transaction.swift | 2 +- Shared/Extensions/BigInt.swift | 2 +- Shared/Extensions/Bundle.swift | 2 +- Shared/Extensions/CoinType.swift | 2 +- Shared/Extensions/FixedWidthInteger.swift | 2 +- Shared/Extensions/Image.swift | 2 +- Shared/Extensions/Notification.swift | 2 +- Shared/Extensions/String.swift | 2 +- Shared/Extensions/URL.swift | 2 +- Shared/Extensions/UserDefaults.swift | 2 +- Shared/Models/ApprovalSubject.swift | 2 +- Shared/Models/AuthenticationReason.swift | 2 +- Shared/Models/DappRequestAction.swift | 2 +- Shared/Models/PeerMeta.swift | 2 +- Shared/Models/PlatformSpecificImage.swift | 2 +- Shared/Models/SafariRequest+Helpers.swift | 2 +- Shared/Models/SpecificWalletAccount.swift | 2 +- Shared/Services/ConfigurationService.swift | 2 +- Shared/Services/DappRequestProcessor.swift | 2 +- Shared/Services/GasService.swift | 2 +- Shared/Services/Keychain.swift | 2 +- Shared/Services/NetworkMonitor.swift | 2 +- Shared/Services/PriceService.swift | 2 +- Shared/Services/ReviewRequester.swift | 2 +- Shared/Services/TransactionInspector.swift | 2 +- Shared/Strings.swift | 2 +- Shared/Supporting Files/Secrets.swift | 2 +- Shared/Views/EditTransactionView.swift | 2 +- Shared/Views/NetworksListView.swift | 2 +- Shared/Wallets/TokenaryAccount.swift | 2 +- Shared/Wallets/TokenaryWallet.swift | 2 +- Shared/Wallets/WalletsManager.swift | 2 +- Tests iOS/Tests_iOS.swift | 2 +- Tests macOS/Tests_macOS.swift | 2 +- Tests/TransactionInspectorTests.swift | 2 +- Tokenary iOS/AppDelegate.swift | 2 +- Tokenary iOS/Content/Images.swift | 2 +- Tokenary iOS/Content/Storyboard.swift | 2 +- Tokenary iOS/Extensions/CGFloat.swift | 2 +- Tokenary iOS/Extensions/UIApplication.swift | 2 +- Tokenary iOS/Extensions/UITableView.swift | 2 +- Tokenary iOS/Extensions/UIView.swift | 2 +- Tokenary iOS/Extensions/UIViewController.swift | 2 +- Tokenary iOS/Library/ButtonWithExtendedArea.swift | 2 +- Tokenary iOS/Library/DataStateView.swift | 2 +- Tokenary iOS/Library/Haptic.swift | 2 +- Tokenary iOS/Library/KeyboardObserver.swift | 2 +- Tokenary iOS/Library/LocalAuthentication.swift | 2 +- Tokenary iOS/SceneDelegate.swift | 2 +- Tokenary iOS/Screens/Accounts/AccountsListViewController.swift | 2 +- Tokenary iOS/Screens/Accounts/EditAccountsViewController.swift | 2 +- Tokenary iOS/Screens/Accounts/Views/AccountTableViewCell.swift | 2 +- Tokenary iOS/Screens/Accounts/Views/AccountsHeaderView.swift | 2 +- .../Screens/Accounts/Views/PreviewAccountTableViewCell.swift | 2 +- .../Screens/Approve/ApproveTransactionViewController.swift | 2 +- Tokenary iOS/Screens/Approve/ApproveViewController.swift | 2 +- Tokenary iOS/Screens/Approve/GasPriceSliderTableViewCell.swift | 2 +- Tokenary iOS/Screens/Approve/ImageWithLabelTableViewCell.swift | 2 +- Tokenary iOS/Screens/Approve/MultilineLabelTableViewCell.swift | 2 +- Tokenary iOS/Screens/ImportViewController.swift | 2 +- Tokenary iOS/Screens/PasswordViewController.swift | 2 +- Tokenary macOS/Agent.swift | 2 +- Tokenary macOS/AppDelegate.swift | 2 +- Tokenary macOS/Content/Images.swift | 2 +- Tokenary macOS/Extensions/NSColor.swift | 2 +- Tokenary macOS/Extensions/NSImage.swift | 2 +- Tokenary macOS/Extensions/NSPasteboard.swift | 2 +- Tokenary macOS/Extensions/NSTableView.swift | 2 +- Tokenary macOS/Extensions/NSViewController.swift | 2 +- Tokenary macOS/Identifiers.swift | 2 +- Tokenary macOS/Models/Browser.swift | 2 +- Tokenary macOS/Screens/AccountsListViewController.swift | 2 +- Tokenary macOS/Screens/ApproveTransactionViewController.swift | 2 +- Tokenary macOS/Screens/ApproveViewController.swift | 2 +- Tokenary macOS/Screens/EditAccountsViewController.swift | 2 +- Tokenary macOS/Screens/ImportViewController.swift | 2 +- Tokenary macOS/Screens/PasswordViewController.swift | 2 +- Tokenary macOS/Screens/WaitingViewController.swift | 2 +- Tokenary macOS/Screens/WelcomeViewController.swift | 2 +- Tokenary macOS/Views/AccountCellView.swift | 2 +- Tokenary macOS/Views/AccountsHeaderRowView.swift | 2 +- Tokenary macOS/Views/AddAccountOptionCellView.swift | 2 +- Tokenary macOS/Views/Alert.swift | 2 +- Tokenary macOS/Views/PreviewAccountCellView.swift | 2 +- Tokenary macOS/Views/RightClickTableView.swift | 2 +- Tokenary macOS/Window.swift | 2 +- Tokenary.xcodeproj/xcshareddata/IDETemplateMacros.plist | 2 +- Tools/Bundled/Infura.swift | 2 +- Tools/Models/BundledNetwork.swift | 2 +- Tools/Models/EIP155ChainData.swift | 2 +- Tools/main.swift | 2 +- 117 files changed, 117 insertions(+), 117 deletions(-) diff --git a/Safari Shared/ExtensionBridge.swift b/Safari Shared/ExtensionBridge.swift index b3c1161a..d97acdfb 100644 --- a/Safari Shared/ExtensionBridge.swift +++ b/Safari Shared/ExtensionBridge.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Safari Shared/Inpage Provider/error.js b/Safari Shared/Inpage Provider/error.js index a3ecba7d..9173aa1f 100644 --- a/Safari Shared/Inpage Provider/error.js +++ b/Safari Shared/Inpage Provider/error.js @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org // Rewrite of error.js from trust-web3-provider. "use strict"; diff --git a/Safari Shared/Inpage Provider/ethereum.js b/Safari Shared/Inpage Provider/ethereum.js index 5e8dac98..f9c620a7 100644 --- a/Safari Shared/Inpage Provider/ethereum.js +++ b/Safari Shared/Inpage Provider/ethereum.js @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org // Rewrite of index.js from trust-web3-provider. "use strict"; diff --git a/Safari Shared/Inpage Provider/id_mapping.js b/Safari Shared/Inpage Provider/id_mapping.js index 94a4af06..bc133444 100644 --- a/Safari Shared/Inpage Provider/id_mapping.js +++ b/Safari Shared/Inpage Provider/id_mapping.js @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org // Rewrite of id_mapping.js from trust-web3-provider. "use strict"; diff --git a/Safari Shared/Inpage Provider/index.js b/Safari Shared/Inpage Provider/index.js index 22598a09..3756de86 100644 --- a/Safari Shared/Inpage Provider/index.js +++ b/Safari Shared/Inpage Provider/index.js @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org // Rewrite of index.js from trust-web3-provider. "use strict"; diff --git a/Safari Shared/Inpage Provider/rpc.js b/Safari Shared/Inpage Provider/rpc.js index 0d45d041..ba5d8b61 100644 --- a/Safari Shared/Inpage Provider/rpc.js +++ b/Safari Shared/Inpage Provider/rpc.js @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org // Rewrite of rpc.js from trust-web3-provider. "use strict"; diff --git a/Safari Shared/Inpage Provider/utils.js b/Safari Shared/Inpage Provider/utils.js index fba3c9f4..aa0e3c14 100644 --- a/Safari Shared/Inpage Provider/utils.js +++ b/Safari Shared/Inpage Provider/utils.js @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org // Rewrite of utils.js from trust-web3-provider. "use strict"; diff --git a/Safari Shared/Models/InpageProvider.swift b/Safari Shared/Models/InpageProvider.swift index e16704bb..587bcb30 100644 --- a/Safari Shared/Models/InpageProvider.swift +++ b/Safari Shared/Models/InpageProvider.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Safari Shared/Models/Requests/EthereumSafariRequest.swift b/Safari Shared/Models/Requests/EthereumSafariRequest.swift index f472bb6a..80b50356 100644 --- a/Safari Shared/Models/Requests/EthereumSafariRequest.swift +++ b/Safari Shared/Models/Requests/EthereumSafariRequest.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Safari Shared/Models/Requests/InternalSafariRequest.swift b/Safari Shared/Models/Requests/InternalSafariRequest.swift index 9393debb..af012bac 100644 --- a/Safari Shared/Models/Requests/InternalSafariRequest.swift +++ b/Safari Shared/Models/Requests/InternalSafariRequest.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Safari Shared/Models/Requests/SafariRequest.swift b/Safari Shared/Models/Requests/SafariRequest.swift index 22852466..2ce6bc2b 100644 --- a/Safari Shared/Models/Requests/SafariRequest.swift +++ b/Safari Shared/Models/Requests/SafariRequest.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Safari Shared/Models/Requests/UnknownSafariRequest.swift b/Safari Shared/Models/Requests/UnknownSafariRequest.swift index 0a965070..9b78c784 100644 --- a/Safari Shared/Models/Requests/UnknownSafariRequest.swift +++ b/Safari Shared/Models/Requests/UnknownSafariRequest.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Safari Shared/Models/Responses/EthereumResponseToExtension.swift b/Safari Shared/Models/Responses/EthereumResponseToExtension.swift index 0e7f096b..8fde5529 100644 --- a/Safari Shared/Models/Responses/EthereumResponseToExtension.swift +++ b/Safari Shared/Models/Responses/EthereumResponseToExtension.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Safari Shared/Models/Responses/MultipleResponseToExtension.swift b/Safari Shared/Models/Responses/MultipleResponseToExtension.swift index 2ef1c66e..42844966 100644 --- a/Safari Shared/Models/Responses/MultipleResponseToExtension.swift +++ b/Safari Shared/Models/Responses/MultipleResponseToExtension.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Safari Shared/Models/Responses/ResponseToExtension.swift b/Safari Shared/Models/Responses/ResponseToExtension.swift index 39656680..151a6e2e 100644 --- a/Safari Shared/Models/Responses/ResponseToExtension.swift +++ b/Safari Shared/Models/Responses/ResponseToExtension.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Safari Shared/Resources/content.js b/Safari Shared/Resources/content.js index 21022362..bc66e8ff 100644 --- a/Safari Shared/Resources/content.js +++ b/Safari Shared/Resources/content.js @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org if (!("pendingRequestsIds" in document)) { document.pendingRequestsIds = new Set(); diff --git a/Safari Shared/Resources/service_worker.js b/Safari Shared/Resources/service_worker.js index 1453db56..4a7c41ea 100644 --- a/Safari Shared/Resources/service_worker.js +++ b/Safari Shared/Resources/service_worker.js @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org function handleOnMessage(request, sender, sendResponse) { if (request.subject === "rpc") { diff --git a/Safari Shared/SafariWebExtensionHandler.swift b/Safari Shared/SafariWebExtensionHandler.swift index d9dff56e..fb3ccf3a 100644 --- a/Safari Shared/SafariWebExtensionHandler.swift +++ b/Safari Shared/SafariWebExtensionHandler.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import SafariServices diff --git a/Safari iOS/Resources/ios_specific_content.js b/Safari iOS/Resources/ios_specific_content.js index 2a4252d3..6772a822 100644 --- a/Safari iOS/Resources/ios_specific_content.js +++ b/Safari iOS/Resources/ios_specific_content.js @@ -1,3 +1,3 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org const isMobile = true; diff --git a/Safari macOS/Resources/macos_specific_content.js b/Safari macOS/Resources/macos_specific_content.js index 1edeff4f..c75de37d 100644 --- a/Safari macOS/Resources/macos_specific_content.js +++ b/Safari macOS/Resources/macos_specific_content.js @@ -1,3 +1,3 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org const isMobile = false; diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index 4c85459b..1029cd40 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Ethereum/Ethereum.swift b/Shared/Ethereum/Ethereum.swift index c163b235..89ce9563 100644 --- a/Shared/Ethereum/Ethereum.swift +++ b/Shared/Ethereum/Ethereum.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation import WalletCore diff --git a/Shared/Ethereum/EthereumNetwork.swift b/Shared/Ethereum/EthereumNetwork.swift index e639902e..beb074c1 100644 --- a/Shared/Ethereum/EthereumNetwork.swift +++ b/Shared/Ethereum/EthereumNetwork.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Ethereum/EthereumRPC.swift b/Shared/Ethereum/EthereumRPC.swift index 2c06288e..f0979dd1 100644 --- a/Shared/Ethereum/EthereumRPC.swift +++ b/Shared/Ethereum/EthereumRPC.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation import WalletCore diff --git a/Shared/Ethereum/Networks.swift b/Shared/Ethereum/Networks.swift index cd64f92c..571a10ad 100644 --- a/Shared/Ethereum/Networks.swift +++ b/Shared/Ethereum/Networks.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Ethereum/Nodes.swift b/Shared/Ethereum/Nodes.swift index c9838302..743f2633 100644 --- a/Shared/Ethereum/Nodes.swift +++ b/Shared/Ethereum/Nodes.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Ethereum/Transaction.swift b/Shared/Ethereum/Transaction.swift index adc1c8aa..0895179b 100644 --- a/Shared/Ethereum/Transaction.swift +++ b/Shared/Ethereum/Transaction.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation import BigInt diff --git a/Shared/Extensions/BigInt.swift b/Shared/Extensions/BigInt.swift index c7ed352e..4e031d50 100644 --- a/Shared/Extensions/BigInt.swift +++ b/Shared/Extensions/BigInt.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation import BigInt diff --git a/Shared/Extensions/Bundle.swift b/Shared/Extensions/Bundle.swift index 8bd60c00..50d8ed5d 100644 --- a/Shared/Extensions/Bundle.swift +++ b/Shared/Extensions/Bundle.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Extensions/CoinType.swift b/Shared/Extensions/CoinType.swift index 286d1d71..44d665a0 100644 --- a/Shared/Extensions/CoinType.swift +++ b/Shared/Extensions/CoinType.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import WalletCore diff --git a/Shared/Extensions/FixedWidthInteger.swift b/Shared/Extensions/FixedWidthInteger.swift index 6a9974e7..b9c835e4 100644 --- a/Shared/Extensions/FixedWidthInteger.swift +++ b/Shared/Extensions/FixedWidthInteger.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Extensions/Image.swift b/Shared/Extensions/Image.swift index 7839167b..cc2dfb45 100644 --- a/Shared/Extensions/Image.swift +++ b/Shared/Extensions/Image.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import SwiftUI diff --git a/Shared/Extensions/Notification.swift b/Shared/Extensions/Notification.swift index 444c6692..f74db800 100644 --- a/Shared/Extensions/Notification.swift +++ b/Shared/Extensions/Notification.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Extensions/String.swift b/Shared/Extensions/String.swift index 1db14bf6..8cee031d 100644 --- a/Shared/Extensions/String.swift +++ b/Shared/Extensions/String.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Extensions/URL.swift b/Shared/Extensions/URL.swift index dc4b22f4..ca99afc2 100644 --- a/Shared/Extensions/URL.swift +++ b/Shared/Extensions/URL.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Extensions/UserDefaults.swift b/Shared/Extensions/UserDefaults.swift index 5c9ec1e9..6fe22d70 100644 --- a/Shared/Extensions/UserDefaults.swift +++ b/Shared/Extensions/UserDefaults.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Models/ApprovalSubject.swift b/Shared/Models/ApprovalSubject.swift index 429639c8..2221ac46 100644 --- a/Shared/Models/ApprovalSubject.swift +++ b/Shared/Models/ApprovalSubject.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org enum ApprovalSubject { case signMessage diff --git a/Shared/Models/AuthenticationReason.swift b/Shared/Models/AuthenticationReason.swift index 29435bf3..94378e35 100644 --- a/Shared/Models/AuthenticationReason.swift +++ b/Shared/Models/AuthenticationReason.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org enum AuthenticationReason { case start diff --git a/Shared/Models/DappRequestAction.swift b/Shared/Models/DappRequestAction.swift index fd32bd77..d62d698f 100644 --- a/Shared/Models/DappRequestAction.swift +++ b/Shared/Models/DappRequestAction.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation import WalletCore diff --git a/Shared/Models/PeerMeta.swift b/Shared/Models/PeerMeta.swift index 7009149c..e5c5daa5 100644 --- a/Shared/Models/PeerMeta.swift +++ b/Shared/Models/PeerMeta.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Models/PlatformSpecificImage.swift b/Shared/Models/PlatformSpecificImage.swift index 09e0164e..a28e85c3 100644 --- a/Shared/Models/PlatformSpecificImage.swift +++ b/Shared/Models/PlatformSpecificImage.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Models/SafariRequest+Helpers.swift b/Shared/Models/SafariRequest+Helpers.swift index fc37bd48..13c96a71 100644 --- a/Shared/Models/SafariRequest+Helpers.swift +++ b/Shared/Models/SafariRequest+Helpers.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Models/SpecificWalletAccount.swift b/Shared/Models/SpecificWalletAccount.swift index 56237068..deaba5bd 100644 --- a/Shared/Models/SpecificWalletAccount.swift +++ b/Shared/Models/SpecificWalletAccount.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation import WalletCore diff --git a/Shared/Services/ConfigurationService.swift b/Shared/Services/ConfigurationService.swift index f56fa775..8ea7f4aa 100644 --- a/Shared/Services/ConfigurationService.swift +++ b/Shared/Services/ConfigurationService.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation import CloudKit diff --git a/Shared/Services/DappRequestProcessor.swift b/Shared/Services/DappRequestProcessor.swift index d8e492a0..be3a86f5 100644 --- a/Shared/Services/DappRequestProcessor.swift +++ b/Shared/Services/DappRequestProcessor.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation import WalletCore diff --git a/Shared/Services/GasService.swift b/Shared/Services/GasService.swift index a1c68af8..9398607d 100644 --- a/Shared/Services/GasService.swift +++ b/Shared/Services/GasService.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Services/Keychain.swift b/Shared/Services/Keychain.swift index af810cd7..bfc1251d 100644 --- a/Shared/Services/Keychain.swift +++ b/Shared/Services/Keychain.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Services/NetworkMonitor.swift b/Shared/Services/NetworkMonitor.swift index 6b007c2b..1af82c91 100644 --- a/Shared/Services/NetworkMonitor.swift +++ b/Shared/Services/NetworkMonitor.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation import CoreTelephony diff --git a/Shared/Services/PriceService.swift b/Shared/Services/PriceService.swift index ec1acc37..9450ed5c 100644 --- a/Shared/Services/PriceService.swift +++ b/Shared/Services/PriceService.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Services/ReviewRequester.swift b/Shared/Services/ReviewRequester.swift index f7104dff..0584c4fa 100644 --- a/Shared/Services/ReviewRequester.swift +++ b/Shared/Services/ReviewRequester.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import StoreKit diff --git a/Shared/Services/TransactionInspector.swift b/Shared/Services/TransactionInspector.swift index f52a5bd4..f7134db8 100644 --- a/Shared/Services/TransactionInspector.swift +++ b/Shared/Services/TransactionInspector.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation import WalletCore diff --git a/Shared/Strings.swift b/Shared/Strings.swift index 92d891b3..9de3caba 100644 --- a/Shared/Strings.swift +++ b/Shared/Strings.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Supporting Files/Secrets.swift b/Shared/Supporting Files/Secrets.swift index a91288af..16b0731d 100644 --- a/Shared/Supporting Files/Secrets.swift +++ b/Shared/Supporting Files/Secrets.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Shared/Views/EditTransactionView.swift b/Shared/Views/EditTransactionView.swift index 109a3dcb..ed70467a 100644 --- a/Shared/Views/EditTransactionView.swift +++ b/Shared/Views/EditTransactionView.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import SwiftUI diff --git a/Shared/Views/NetworksListView.swift b/Shared/Views/NetworksListView.swift index 85cee8bd..1f763ed8 100644 --- a/Shared/Views/NetworksListView.swift +++ b/Shared/Views/NetworksListView.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import SwiftUI diff --git a/Shared/Wallets/TokenaryAccount.swift b/Shared/Wallets/TokenaryAccount.swift index ab5cfc46..9d86ce1b 100644 --- a/Shared/Wallets/TokenaryAccount.swift +++ b/Shared/Wallets/TokenaryAccount.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import WalletCore diff --git a/Shared/Wallets/TokenaryWallet.swift b/Shared/Wallets/TokenaryWallet.swift index 2d4864e6..bd7d2b8c 100644 --- a/Shared/Wallets/TokenaryWallet.swift +++ b/Shared/Wallets/TokenaryWallet.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org // Rewrite of Wallet.swift from Trust Wallet Core. import Foundation diff --git a/Shared/Wallets/WalletsManager.swift b/Shared/Wallets/WalletsManager.swift index fa30672d..e568da06 100644 --- a/Shared/Wallets/WalletsManager.swift +++ b/Shared/Wallets/WalletsManager.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org // Rewrite of KeyStore.swift from Trust Wallet Core. import Foundation diff --git a/Tests iOS/Tests_iOS.swift b/Tests iOS/Tests_iOS.swift index bb6dcf42..47917b61 100644 --- a/Tests iOS/Tests_iOS.swift +++ b/Tests iOS/Tests_iOS.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import XCTest diff --git a/Tests macOS/Tests_macOS.swift b/Tests macOS/Tests_macOS.swift index 9c32c1a2..80e328df 100644 --- a/Tests macOS/Tests_macOS.swift +++ b/Tests macOS/Tests_macOS.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import XCTest diff --git a/Tests/TransactionInspectorTests.swift b/Tests/TransactionInspectorTests.swift index babbc2b4..6f26b51d 100644 --- a/Tests/TransactionInspectorTests.swift +++ b/Tests/TransactionInspectorTests.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import XCTest #if os(iOS) diff --git a/Tokenary iOS/AppDelegate.swift b/Tokenary iOS/AppDelegate.swift index ac7e3d0b..e046b93e 100644 --- a/Tokenary iOS/AppDelegate.swift +++ b/Tokenary iOS/AppDelegate.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Content/Images.swift b/Tokenary iOS/Content/Images.swift index 954bdf82..8a68bbca 100644 --- a/Tokenary iOS/Content/Images.swift +++ b/Tokenary iOS/Content/Images.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit import WalletCore diff --git a/Tokenary iOS/Content/Storyboard.swift b/Tokenary iOS/Content/Storyboard.swift index d5c6c4a8..1070eb7f 100644 --- a/Tokenary iOS/Content/Storyboard.swift +++ b/Tokenary iOS/Content/Storyboard.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Extensions/CGFloat.swift b/Tokenary iOS/Extensions/CGFloat.swift index 80026174..83c95bfa 100644 --- a/Tokenary iOS/Extensions/CGFloat.swift +++ b/Tokenary iOS/Extensions/CGFloat.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Extensions/UIApplication.swift b/Tokenary iOS/Extensions/UIApplication.swift index bd4ff297..5b844966 100644 --- a/Tokenary iOS/Extensions/UIApplication.swift +++ b/Tokenary iOS/Extensions/UIApplication.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Extensions/UITableView.swift b/Tokenary iOS/Extensions/UITableView.swift index 580db332..f523b3d4 100644 --- a/Tokenary iOS/Extensions/UITableView.swift +++ b/Tokenary iOS/Extensions/UITableView.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Extensions/UIView.swift b/Tokenary iOS/Extensions/UIView.swift index b3b189ec..92d580a7 100644 --- a/Tokenary iOS/Extensions/UIView.swift +++ b/Tokenary iOS/Extensions/UIView.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Extensions/UIViewController.swift b/Tokenary iOS/Extensions/UIViewController.swift index d66be3b6..88fdf118 100644 --- a/Tokenary iOS/Extensions/UIViewController.swift +++ b/Tokenary iOS/Extensions/UIViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Library/ButtonWithExtendedArea.swift b/Tokenary iOS/Library/ButtonWithExtendedArea.swift index fe260847..50b561cb 100644 --- a/Tokenary iOS/Library/ButtonWithExtendedArea.swift +++ b/Tokenary iOS/Library/ButtonWithExtendedArea.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Library/DataStateView.swift b/Tokenary iOS/Library/DataStateView.swift index 75801775..df57e06d 100644 --- a/Tokenary iOS/Library/DataStateView.swift +++ b/Tokenary iOS/Library/DataStateView.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Library/Haptic.swift b/Tokenary iOS/Library/Haptic.swift index c08ea886..609f600e 100644 --- a/Tokenary iOS/Library/Haptic.swift +++ b/Tokenary iOS/Library/Haptic.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Library/KeyboardObserver.swift b/Tokenary iOS/Library/KeyboardObserver.swift index 38651dd7..deb70f8c 100644 --- a/Tokenary iOS/Library/KeyboardObserver.swift +++ b/Tokenary iOS/Library/KeyboardObserver.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Library/LocalAuthentication.swift b/Tokenary iOS/Library/LocalAuthentication.swift index 41043c0b..ea612a17 100644 --- a/Tokenary iOS/Library/LocalAuthentication.swift +++ b/Tokenary iOS/Library/LocalAuthentication.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit import LocalAuthentication diff --git a/Tokenary iOS/SceneDelegate.swift b/Tokenary iOS/SceneDelegate.swift index a52e13f3..7faf452b 100644 --- a/Tokenary iOS/SceneDelegate.swift +++ b/Tokenary iOS/SceneDelegate.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Screens/Accounts/AccountsListViewController.swift b/Tokenary iOS/Screens/Accounts/AccountsListViewController.swift index aed0077d..5d2dcbc7 100644 --- a/Tokenary iOS/Screens/Accounts/AccountsListViewController.swift +++ b/Tokenary iOS/Screens/Accounts/AccountsListViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit import SwiftUI diff --git a/Tokenary iOS/Screens/Accounts/EditAccountsViewController.swift b/Tokenary iOS/Screens/Accounts/EditAccountsViewController.swift index eaba58c6..002f58c1 100644 --- a/Tokenary iOS/Screens/Accounts/EditAccountsViewController.swift +++ b/Tokenary iOS/Screens/Accounts/EditAccountsViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit import WalletCore diff --git a/Tokenary iOS/Screens/Accounts/Views/AccountTableViewCell.swift b/Tokenary iOS/Screens/Accounts/Views/AccountTableViewCell.swift index 828d0f16..b46b7bb0 100644 --- a/Tokenary iOS/Screens/Accounts/Views/AccountTableViewCell.swift +++ b/Tokenary iOS/Screens/Accounts/Views/AccountTableViewCell.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Screens/Accounts/Views/AccountsHeaderView.swift b/Tokenary iOS/Screens/Accounts/Views/AccountsHeaderView.swift index 2cf61146..ed88b054 100644 --- a/Tokenary iOS/Screens/Accounts/Views/AccountsHeaderView.swift +++ b/Tokenary iOS/Screens/Accounts/Views/AccountsHeaderView.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Screens/Accounts/Views/PreviewAccountTableViewCell.swift b/Tokenary iOS/Screens/Accounts/Views/PreviewAccountTableViewCell.swift index 42ab16b0..489bac9a 100644 --- a/Tokenary iOS/Screens/Accounts/Views/PreviewAccountTableViewCell.swift +++ b/Tokenary iOS/Screens/Accounts/Views/PreviewAccountTableViewCell.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Screens/Approve/ApproveTransactionViewController.swift b/Tokenary iOS/Screens/Approve/ApproveTransactionViewController.swift index fa536264..7c4b123d 100644 --- a/Tokenary iOS/Screens/Approve/ApproveTransactionViewController.swift +++ b/Tokenary iOS/Screens/Approve/ApproveTransactionViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit import WalletCore diff --git a/Tokenary iOS/Screens/Approve/ApproveViewController.swift b/Tokenary iOS/Screens/Approve/ApproveViewController.swift index 5d1acfad..8540139c 100644 --- a/Tokenary iOS/Screens/Approve/ApproveViewController.swift +++ b/Tokenary iOS/Screens/Approve/ApproveViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit import WalletCore diff --git a/Tokenary iOS/Screens/Approve/GasPriceSliderTableViewCell.swift b/Tokenary iOS/Screens/Approve/GasPriceSliderTableViewCell.swift index 692d9a57..982defe7 100644 --- a/Tokenary iOS/Screens/Approve/GasPriceSliderTableViewCell.swift +++ b/Tokenary iOS/Screens/Approve/GasPriceSliderTableViewCell.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Screens/Approve/ImageWithLabelTableViewCell.swift b/Tokenary iOS/Screens/Approve/ImageWithLabelTableViewCell.swift index eaefee46..b729e58f 100644 --- a/Tokenary iOS/Screens/Approve/ImageWithLabelTableViewCell.swift +++ b/Tokenary iOS/Screens/Approve/ImageWithLabelTableViewCell.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit import Kingfisher diff --git a/Tokenary iOS/Screens/Approve/MultilineLabelTableViewCell.swift b/Tokenary iOS/Screens/Approve/MultilineLabelTableViewCell.swift index 0df316c1..3da5e353 100644 --- a/Tokenary iOS/Screens/Approve/MultilineLabelTableViewCell.swift +++ b/Tokenary iOS/Screens/Approve/MultilineLabelTableViewCell.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Screens/ImportViewController.swift b/Tokenary iOS/Screens/ImportViewController.swift index 41e7b430..8a083f13 100644 --- a/Tokenary iOS/Screens/ImportViewController.swift +++ b/Tokenary iOS/Screens/ImportViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary iOS/Screens/PasswordViewController.swift b/Tokenary iOS/Screens/PasswordViewController.swift index de6c0b8e..84117718 100644 --- a/Tokenary iOS/Screens/PasswordViewController.swift +++ b/Tokenary iOS/Screens/PasswordViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import UIKit diff --git a/Tokenary macOS/Agent.swift b/Tokenary macOS/Agent.swift index 1f364b20..c6af9b82 100644 --- a/Tokenary macOS/Agent.swift +++ b/Tokenary macOS/Agent.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa import SafariServices diff --git a/Tokenary macOS/AppDelegate.swift b/Tokenary macOS/AppDelegate.swift index 78e566d1..8cbbca67 100644 --- a/Tokenary macOS/AppDelegate.swift +++ b/Tokenary macOS/AppDelegate.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Content/Images.swift b/Tokenary macOS/Content/Images.swift index 8f2d9405..621eb5c0 100644 --- a/Tokenary macOS/Content/Images.swift +++ b/Tokenary macOS/Content/Images.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa import WalletCore diff --git a/Tokenary macOS/Extensions/NSColor.swift b/Tokenary macOS/Extensions/NSColor.swift index d839ed94..f928c2b7 100644 --- a/Tokenary macOS/Extensions/NSColor.swift +++ b/Tokenary macOS/Extensions/NSColor.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Extensions/NSImage.swift b/Tokenary macOS/Extensions/NSImage.swift index 532d4c3a..26facc73 100644 --- a/Tokenary macOS/Extensions/NSImage.swift +++ b/Tokenary macOS/Extensions/NSImage.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Extensions/NSPasteboard.swift b/Tokenary macOS/Extensions/NSPasteboard.swift index d69e56e8..5ffb27a0 100644 --- a/Tokenary macOS/Extensions/NSPasteboard.swift +++ b/Tokenary macOS/Extensions/NSPasteboard.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Extensions/NSTableView.swift b/Tokenary macOS/Extensions/NSTableView.swift index af19d993..5016572d 100644 --- a/Tokenary macOS/Extensions/NSTableView.swift +++ b/Tokenary macOS/Extensions/NSTableView.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Extensions/NSViewController.swift b/Tokenary macOS/Extensions/NSViewController.swift index b90da4d1..f36ba70c 100644 --- a/Tokenary macOS/Extensions/NSViewController.swift +++ b/Tokenary macOS/Extensions/NSViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import SwiftUI diff --git a/Tokenary macOS/Identifiers.swift b/Tokenary macOS/Identifiers.swift index 98a52870..9a76f4cf 100644 --- a/Tokenary macOS/Identifiers.swift +++ b/Tokenary macOS/Identifiers.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Tokenary macOS/Models/Browser.swift b/Tokenary macOS/Models/Browser.swift index 5ee4cb7e..017ce4c4 100644 --- a/Tokenary macOS/Models/Browser.swift +++ b/Tokenary macOS/Models/Browser.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Tokenary macOS/Screens/AccountsListViewController.swift b/Tokenary macOS/Screens/AccountsListViewController.swift index c5489395..2d146a94 100644 --- a/Tokenary macOS/Screens/AccountsListViewController.swift +++ b/Tokenary macOS/Screens/AccountsListViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa import WalletCore diff --git a/Tokenary macOS/Screens/ApproveTransactionViewController.swift b/Tokenary macOS/Screens/ApproveTransactionViewController.swift index 1e2dca03..9456d4ad 100644 --- a/Tokenary macOS/Screens/ApproveTransactionViewController.swift +++ b/Tokenary macOS/Screens/ApproveTransactionViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa import WalletCore diff --git a/Tokenary macOS/Screens/ApproveViewController.swift b/Tokenary macOS/Screens/ApproveViewController.swift index 5719f611..d8d1f243 100644 --- a/Tokenary macOS/Screens/ApproveViewController.swift +++ b/Tokenary macOS/Screens/ApproveViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Screens/EditAccountsViewController.swift b/Tokenary macOS/Screens/EditAccountsViewController.swift index 9c42f017..5337ec86 100644 --- a/Tokenary macOS/Screens/EditAccountsViewController.swift +++ b/Tokenary macOS/Screens/EditAccountsViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa import WalletCore diff --git a/Tokenary macOS/Screens/ImportViewController.swift b/Tokenary macOS/Screens/ImportViewController.swift index 2875cb89..b0fd1f2b 100644 --- a/Tokenary macOS/Screens/ImportViewController.swift +++ b/Tokenary macOS/Screens/ImportViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa import WalletCore diff --git a/Tokenary macOS/Screens/PasswordViewController.swift b/Tokenary macOS/Screens/PasswordViewController.swift index aa83075b..c9ca31ab 100644 --- a/Tokenary macOS/Screens/PasswordViewController.swift +++ b/Tokenary macOS/Screens/PasswordViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Screens/WaitingViewController.swift b/Tokenary macOS/Screens/WaitingViewController.swift index b675d6b4..86d63a25 100644 --- a/Tokenary macOS/Screens/WaitingViewController.swift +++ b/Tokenary macOS/Screens/WaitingViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Screens/WelcomeViewController.swift b/Tokenary macOS/Screens/WelcomeViewController.swift index e4206fd0..393fc0f9 100644 --- a/Tokenary macOS/Screens/WelcomeViewController.swift +++ b/Tokenary macOS/Screens/WelcomeViewController.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Views/AccountCellView.swift b/Tokenary macOS/Views/AccountCellView.swift index 8ecc5a70..5803277f 100644 --- a/Tokenary macOS/Views/AccountCellView.swift +++ b/Tokenary macOS/Views/AccountCellView.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa import WalletCore diff --git a/Tokenary macOS/Views/AccountsHeaderRowView.swift b/Tokenary macOS/Views/AccountsHeaderRowView.swift index a86d8090..388a3a7f 100644 --- a/Tokenary macOS/Views/AccountsHeaderRowView.swift +++ b/Tokenary macOS/Views/AccountsHeaderRowView.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Views/AddAccountOptionCellView.swift b/Tokenary macOS/Views/AddAccountOptionCellView.swift index 52ba76c4..8c5d1601 100644 --- a/Tokenary macOS/Views/AddAccountOptionCellView.swift +++ b/Tokenary macOS/Views/AddAccountOptionCellView.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Views/Alert.swift b/Tokenary macOS/Views/Alert.swift index 2544df61..af84cca1 100644 --- a/Tokenary macOS/Views/Alert.swift +++ b/Tokenary macOS/Views/Alert.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Views/PreviewAccountCellView.swift b/Tokenary macOS/Views/PreviewAccountCellView.swift index 7595a0ac..2e8515dd 100644 --- a/Tokenary macOS/Views/PreviewAccountCellView.swift +++ b/Tokenary macOS/Views/PreviewAccountCellView.swift @@ -1,4 +1,4 @@ -// Copyright © 2022 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Views/RightClickTableView.swift b/Tokenary macOS/Views/RightClickTableView.swift index ffa430c0..e6c91b91 100644 --- a/Tokenary macOS/Views/RightClickTableView.swift +++ b/Tokenary macOS/Views/RightClickTableView.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary macOS/Window.swift b/Tokenary macOS/Window.swift index ffa56d23..a4852ec7 100644 --- a/Tokenary macOS/Window.swift +++ b/Tokenary macOS/Window.swift @@ -1,4 +1,4 @@ -// Copyright © 2021 Tokenary. All rights reserved. +// ∅ 2024 lil org import Cocoa diff --git a/Tokenary.xcodeproj/xcshareddata/IDETemplateMacros.plist b/Tokenary.xcodeproj/xcshareddata/IDETemplateMacros.plist index 51447aec..2cf015e4 100644 --- a/Tokenary.xcodeproj/xcshareddata/IDETemplateMacros.plist +++ b/Tokenary.xcodeproj/xcshareddata/IDETemplateMacros.plist @@ -3,6 +3,6 @@ FILEHEADER - Copyright © ___YEAR___ Tokenary. All rights reserved. + ∅ ___YEAR___ lil org diff --git a/Tools/Bundled/Infura.swift b/Tools/Bundled/Infura.swift index 996a4307..6b86bdeb 100644 --- a/Tools/Bundled/Infura.swift +++ b/Tools/Bundled/Infura.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Tools/Models/BundledNetwork.swift b/Tools/Models/BundledNetwork.swift index 04e66379..ad9dbee3 100644 --- a/Tools/Models/BundledNetwork.swift +++ b/Tools/Models/BundledNetwork.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Tools/Models/EIP155ChainData.swift b/Tools/Models/EIP155ChainData.swift index ea9fdc26..5035ccd4 100644 --- a/Tools/Models/EIP155ChainData.swift +++ b/Tools/Models/EIP155ChainData.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation diff --git a/Tools/main.swift b/Tools/main.swift index 56505d2eb..71be2b74 100644 --- a/Tools/main.swift +++ b/Tools/main.swift @@ -1,4 +1,4 @@ -// Copyright © 2023 Tokenary. All rights reserved. +// ∅ 2024 lil org import Foundation From 517adbeb82a03a554b5509936eb6a9ef26c8c226 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Tue, 23 Jan 2024 17:22:26 +0300 Subject: [PATCH 13/19] use non-optional data for rpc request --- Safari Shared/SafariWebExtensionHandler.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Safari Shared/SafariWebExtensionHandler.swift b/Safari Shared/SafariWebExtensionHandler.swift index fb3ccf3a..02dcccf0 100644 --- a/Safari Shared/SafariWebExtensionHandler.swift +++ b/Safari Shared/SafariWebExtensionHandler.swift @@ -77,7 +77,7 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { request.httpMethod = "POST" request.setValue("application/json", forHTTPHeaderField: "Accept") request.setValue("application/json", forHTTPHeaderField: "Content-Type") - request.httpBody = body.data(using: .utf8) + request.httpBody = httpBody let task = URLSession.shared.dataTask(with: request) { [weak self] data, response, error in if let data = data, let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] { From 280590ad6f2a6392c8d0bd36bf555e34df040c08 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Tue, 23 Jan 2024 19:32:35 +0300 Subject: [PATCH 14/19] resolve rpc responses back inpage --- Safari Shared/Inpage Provider/ethereum.js | 15 ++++----------- Safari Shared/Inpage Provider/index.js | 5 ++++- Safari Shared/Inpage Provider/rpc.js | 1 + Safari Shared/Resources/inpage.js | 2 +- Safari Shared/SafariWebExtensionHandler.swift | 1 + Safari macOS/Safari.entitlements | 2 ++ 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Safari Shared/Inpage Provider/ethereum.js b/Safari Shared/Inpage Provider/ethereum.js index f9c620a7..8605dc0f 100644 --- a/Safari Shared/Inpage Provider/ethereum.js +++ b/Safari Shared/Inpage Provider/ethereum.js @@ -199,16 +199,9 @@ class TokenaryEthereum extends EventEmitter { case "eth_newPendingTransactionFilter": case "eth_uninstallFilter": case "eth_subscribe": - throw new ProviderRpcError(4200, `Tokenary does not support calling ${payload.method}. Please use your own solution`); + throw new ProviderRpcError(4200, `tiny wallet does not support ${payload.method}`); default: - this.callbacks.delete(payload.id); - this.wrapResults.delete(payload.id); - return this.rpc - .call(payload) - .then((response) => { - wrapResult ? resolve(response) : resolve(response.result); - }) - .catch(reject); + return this.rpc.call(payload); } }); } @@ -394,13 +387,13 @@ class TokenaryEthereum extends EventEmitter { let callback = this.callbacks.get(id); let wrapResult = this.wrapResults.get(id); let data = { jsonrpc: "2.0", id: originId }; - if (result !== null && result.jsonrpc && result.result) { + if (result !== null && result.result) { data.result = result.result; } else { data.result = result; } if (callback) { - wrapResult ? callback(null, data) : callback(null, result); + wrapResult ? callback(null, data) : callback(null, data.result); this.callbacks.delete(id); } else { console.log(`callback id: ${id} not found`); diff --git a/Safari Shared/Inpage Provider/index.js b/Safari Shared/Inpage Provider/index.js index 3756de86..49e90202 100644 --- a/Safari Shared/Inpage Provider/index.js +++ b/Safari Shared/Inpage Provider/index.js @@ -45,7 +45,10 @@ announceProvider(); window.addEventListener("message", function(event) { if (event.source == window && event.data && event.data.direction == "rpc-back") { - console.log("got it back inpage", event.data); // TODO: respond via rpc server + // TODO: check event.data.response is there + // TODO: make sure error is delivered as well + console.log("rpc back", event.data.response); + provider.sendResponse(event.data.response.id, event.data.response); } else if (event.source == window && event.data && event.data.direction == "from-content-script") { const response = event.data.response; const id = event.data.id; diff --git a/Safari Shared/Inpage Provider/rpc.js b/Safari Shared/Inpage Provider/rpc.js index ba5d8b61..aeb99c78 100644 --- a/Safari Shared/Inpage Provider/rpc.js +++ b/Safari Shared/Inpage Provider/rpc.js @@ -10,6 +10,7 @@ class RPCServer { } call(payload) { + payload.jsonrpc = "2.0"; window.postMessage({direction: "rpc", message: {id: payload.id, subject: "rpc", chainId: this.chainId, body: JSON.stringify(payload)}}, "*"); return true; } diff --git a/Safari Shared/Resources/inpage.js b/Safari Shared/Resources/inpage.js index 33dd2075..23656808 100644 --- a/Safari Shared/Resources/inpage.js +++ b/Safari Shared/Resources/inpage.js @@ -1 +1 @@ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i1&&arguments[1]!==undefined?arguments[1]:true;this.idMapping.tryFixId(payload);return new Promise(function(resolve,reject){if(!payload.id){payload.id=_utils["default"].genId()}_this2.callbacks.set(payload.id,function(error,data){setTimeout(function(){if(error){reject(error)}else{resolve(data)}},1)});_this2.wrapResults.set(payload.id,wrapResult);switch(payload.method){case"eth_accounts":case"eth_coinbase":case"net_version":case"eth_chainId":case"eth_sign":case"personal_sign":case"personal_ecRecover":case"eth_signTypedData_v3":case"eth_signTypedData":case"eth_signTypedData_v4":case"eth_sendTransaction":case"eth_requestAccounts":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":case"wallet_requestPermissions":case"wallet_getPermissions":return _this2._processPayload(payload);case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_subscribe":throw new _error["default"](4200,"Tokenary does not support calling ".concat(payload.method,". Please use your own solution"));default:_this2.callbacks["delete"](payload.id);_this2.wrapResults["delete"](payload.id);return _this2.rpc.call(payload).then(function(response){wrapResult?resolve(response):resolve(response.result)})["catch"](reject)}})}},{key:"_processPayload",value:function _processPayload(payload){if(!this.didGetLatestConfiguration){this.pendingPayloads.push(payload);return}switch(payload.method){case"eth_accounts":return this.sendResponse(payload.id,this.eth_accounts());case"eth_coinbase":return this.sendResponse(payload.id,this.eth_coinbase());case"net_version":return this.sendResponse(payload.id,this.net_version());case"eth_chainId":return this.sendResponse(payload.id,this.eth_chainId());case"eth_sign":return this.eth_sign(payload);case"personal_sign":return this.personal_sign(payload);case"personal_ecRecover":return this.personal_ecRecover(payload);case"eth_signTypedData_v3":return this.eth_signTypedData(payload,false);case"eth_signTypedData":case"eth_signTypedData_v4":return this.eth_signTypedData(payload,true);case"eth_sendTransaction":return this.eth_sendTransaction(payload);case"eth_requestAccounts":if(!this.address){return this.eth_requestAccounts(payload)}else{return this.sendResponse(payload.id,this.eth_accounts())}case"wallet_addEthereumChain":return this.wallet_addEthereumChain(payload);case"wallet_switchEthereumChain":return this.wallet_switchEthereumChain(payload);case"wallet_requestPermissions":case"wallet_getPermissions":var permissions=[{parentCapability:"eth_accounts"}];return this.sendResponse(payload.id,permissions)}}},{key:"emitConnect",value:function emitConnect(chainId){this.emit("connect",{chainId:chainId})}},{key:"eth_accounts",value:function eth_accounts(){return this.address?[this.address]:[]}},{key:"eth_coinbase",value:function eth_coinbase(){return this.address}},{key:"net_version",value:function net_version(){return parseInt(this.chainId,16).toString(10)||null}},{key:"eth_chainId",value:function eth_chainId(){return this.chainId}},{key:"eth_sign",value:function eth_sign(payload){var buffer=_utils["default"].messageToBuffer(payload.params[1]);var hex=_utils["default"].bufferToHex(buffer);if((0,_isutf["default"])(buffer)){this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signMessage",payload.id,{data:hex})}}},{key:"personal_sign",value:function personal_sign(payload){var message=payload.params[0];var buffer=_utils["default"].messageToBuffer(message);if(buffer.length===0){var hex=_utils["default"].bufferToHex(message);this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signPersonalMessage",payload.id,{data:message})}}},{key:"personal_ecRecover",value:function personal_ecRecover(payload){this.postMessage("ecRecover",payload.id,{signature:payload.params[1],message:payload.params[0]})}},{key:"eth_signTypedData",value:function eth_signTypedData(payload,useV4){this.postMessage("signTypedMessage",payload.id,{raw:payload.params[1]})}},{key:"eth_sendTransaction",value:function eth_sendTransaction(payload){this.postMessage("signTransaction",payload.id,payload.params[0])}},{key:"eth_requestAccounts",value:function eth_requestAccounts(payload){this.postMessage("requestAccounts",payload.id,{})}},{key:"wallet_watchAsset",value:function wallet_watchAsset(payload){var options=payload.params.options;this.postMessage("watchAsset",payload.id,{type:payload.type,contract:options.address,symbol:options.symbol,decimals:options.decimals||0})}},{key:"wallet_switchEthereumChain",value:function wallet_switchEthereumChain(payload){if(this.chainId!=payload.params[0].chainId){this.postMessage("switchEthereumChain",payload.id,payload.params[0])}else{this.sendResponse(payload.id,[this.address])}}},{key:"wallet_addEthereumChain",value:function wallet_addEthereumChain(payload){this.postMessage("addEthereumChain",payload.id,payload.params[0])}},{key:"processTokenaryResponse",value:function processTokenaryResponse(id,response){if(response.name=="didLoadLatestConfiguration"){this.didGetLatestConfiguration=true;if(response.chainId){this.updateAccount(response.name,response.results,response.chainId)}var _iterator=_createForOfIteratorHelper(this.pendingPayloads),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var payload=_step.value;this._processPayload(payload)}}catch(err){_iterator.e(err)}finally{_iterator.f()}this.pendingPayloads=[];return}if("result"in response){this.sendResponse(id,response.result)}else if("results"in response){if(response.name=="switchEthereumChain"||response.name=="addEthereumChain"){this.updateAccount(response.name,response.results,response.chainId)}if(response.name!="switchAccount"){this.sendResponse(id,response.results)}if(response.name=="requestAccounts"||response.name=="switchAccount"){this.updateAccount(response.name,response.results,response.chainId)}}else if("error"in response){this.sendError(id,response.error)}}},{key:"postMessage",value:function postMessage(handler,id,data){if(this.ready||handler==="requestAccounts"||handler==="switchEthereumChain"||handler==="addEthereumChain"){var object={object:data,address:this.address,chainId:this.chainId};window.tokenary.postMessage(handler,id,object,"ethereum")}else{this.sendError(id,new _error["default"](4100,"provider is not ready"))}}},{key:"sendResponse",value:function sendResponse(id,result){var originId=this.idMapping.tryPopId(id)||id;var callback=this.callbacks.get(id);var wrapResult=this.wrapResults.get(id);var data={jsonrpc:"2.0",id:originId};if(result!==null&&result.jsonrpc&&result.result){data.result=result.result}else{data.result=result}if(callback){wrapResult?callback(null,data):callback(null,result);this.callbacks["delete"](id)}else{console.log("callback id: ".concat(id," not found"))}}},{key:"sendError",value:function sendError(id,error){console.log("<== ".concat(id," sendError ").concat(error));var callback=this.callbacks.get(id);if(callback){callback(error instanceof Error?error:new Error(error),null);this.callbacks["delete"](id)}}}]);return TokenaryEthereum}(_events.EventEmitter);module.exports=TokenaryEthereum},{"./error":1,"./id_mapping":3,"./rpc":10,"./utils":11,events:7,isutf8:9}],3:[function(require,module,exports){"use strict";var _utils=_interopRequireDefault(require("./utils"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;var i;for(i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],6:[function(require,module,exports){(function(Buffer){(function(){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH;Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport();if(!Buffer.TYPED_ARRAY_SUPPORT&&typeof console!=="undefined"&&typeof console.error==="function"){console.error("This browser lacks typed array (Uint8Array) support which is required by "+"`buffer` v5.x. Use `buffer` v4.x if you require old browser support.")}function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42}catch(e){return false}}Object.defineProperty(Buffer.prototype,"parent",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.buffer}});Object.defineProperty(Buffer.prototype,"offset",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.byteOffset}});function createBuffer(length){if(length>K_MAX_LENGTH){throw new RangeError('The value "'+length+'" is invalid for option "size"')}var buf=new Uint8Array(length);buf.__proto__=Buffer.prototype;return buf}function Buffer(arg,encodingOrOffset,length){if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new TypeError('The "string" argument must be of type string. Received type number')}return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}if(typeof Symbol!=="undefined"&&Symbol.species!=null&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true,enumerable:false,writable:false})}Buffer.poolSize=8192;function from(value,encodingOrOffset,length){if(typeof value==="string"){return fromString(value,encodingOrOffset)}if(ArrayBuffer.isView(value)){return fromArrayLike(value)}if(value==null){throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer)){return fromArrayBuffer(value,encodingOrOffset,length)}if(typeof value==="number"){throw new TypeError('The "value" argument must not be of type number. Received type number')}var valueOf=value.valueOf&&value.valueOf();if(valueOf!=null&&valueOf!==value){return Buffer.from(valueOf,encodingOrOffset,length)}var b=fromObject(value);if(b)return b;if(typeof Symbol!=="undefined"&&Symbol.toPrimitive!=null&&typeof value[Symbol.toPrimitive]==="function"){return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)};Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be of type number')}else if(size<0){throw new RangeError('The value "'+size+'" is invalid for option "size"')}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill)}return createBuffer(size)}Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding)};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0)}Buffer.allocUnsafe=function(size){return allocUnsafe(size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)};function fromString(string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}var length=byteLength(string,encoding)|0;var buf=createBuffer(length);var actual=buf.write(string,encoding);if(actual!==length){buf=buf.slice(0,actual)}return buf}function fromArrayLike(array){var length=array.length<0?0:checked(array.length)|0;var buf=createBuffer(length);for(var i=0;i=K_MAX_LENGTH){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+K_MAX_LENGTH.toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true&&b!==Buffer.prototype};Buffer.compare=function compare(a,b){if(isInstance(a,Uint8Array))a=Buffer.from(a,a.offset,a.byteLength);if(isInstance(b,Uint8Array))b=Buffer.from(b,b.offset,b.byteLength);if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array')}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i2&&arguments[2]===true;if(!mustMatch&&len===0)return 0;var loweredCase=false;for(;;){switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return len*2;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase){return mustMatch?-1:utf8ToBytes(string).length}encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;imax)str+=" ... ";return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)){target=Buffer.from(target,target.offset,target.byteLength)}if(!Buffer.isBuffer(target)){throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. '+"Received type "+typeof target)}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(numberIsNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(length>strLen/2){length=strLen/2}for(var i=0;i>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);this[offset]=value&255;return offset+1};Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255;return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}if(val.length===1){var code=val.charCodeAt(0);if(encoding==="utf8"&&code<128||encoding==="latin1"){val=code}}}else if(typeof val==="number"){val=val&255}if(start<0||this.length>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isInstance(obj,type){return obj instanceof type||obj!=null&&obj.constructor!=null&&obj.constructor.name!=null&&obj.constructor.name===type.name}function numberIsNaN(obj){return obj!==obj}}).call(this)}).call(this,require("buffer").Buffer)},{"base64-js":5,buffer:6,ieee754:8}],7:[function(require,module,exports){"use strict";var R=typeof Reflect==="object"?Reflect:null;var ReflectApply=R&&typeof R.apply==="function"?R.apply:function ReflectApply(target,receiver,args){return Function.prototype.apply.call(target,receiver,args)};var ReflectOwnKeys;if(R&&typeof R.ownKeys==="function"){ReflectOwnKeys=R.ownKeys}else if(Object.getOwnPropertySymbols){ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target))}}else{ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target)}}function ProcessEmitWarning(warning){if(console&&console.warn)console.warn(warning)}var NumberIsNaN=Number.isNaN||function NumberIsNaN(value){return value!==value};function EventEmitter(){EventEmitter.init.call(this)}module.exports=EventEmitter;module.exports.once=once;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=undefined;var defaultMaxListeners=10;function checkListener(listener){if(typeof listener!=="function"){throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof listener)}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:true,get:function(){return defaultMaxListeners},set:function(arg){if(typeof arg!=="number"||arg<0||NumberIsNaN(arg)){throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+arg+".")}defaultMaxListeners=arg}});EventEmitter.init=function(){if(this._events===undefined||this._events===Object.getPrototypeOf(this)._events){this._events=Object.create(null);this._eventsCount=0}this._maxListeners=this._maxListeners||undefined};EventEmitter.prototype.setMaxListeners=function setMaxListeners(n){if(typeof n!=="number"||n<0||NumberIsNaN(n)){throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".")}this._maxListeners=n;return this};function _getMaxListeners(that){if(that._maxListeners===undefined)return EventEmitter.defaultMaxListeners;return that._maxListeners}EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function emit(type){var args=[];for(var i=1;i0)er=args[0];if(er instanceof Error){throw er}var err=new Error("Unhandled error."+(er?" ("+er.message+")":""));err.context=er;throw err}var handler=events[type];if(handler===undefined)return false;if(typeof handler==="function"){ReflectApply(handler,this,args)}else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i0&&existing.length>m&&!existing.warned){existing.warned=true;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+" "+String(type)+" listeners "+"added. Use emitter.setMaxListeners() to "+"increase limit");w.name="MaxListenersExceededWarning";w.emitter=target;w.type=type;w.count=existing.length;ProcessEmitWarning(w)}}return target}EventEmitter.prototype.addListener=function addListener(type,listener){return _addListener(this,type,listener,false)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function prependListener(type,listener){return _addListener(this,type,listener,true)};function onceWrapper(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;if(arguments.length===0)return this.listener.call(this.target);return this.listener.apply(this.target,arguments)}}function _onceWrap(target,type,listener){var state={fired:false,wrapFn:undefined,target:target,type:type,listener:listener};var wrapped=onceWrapper.bind(state);wrapped.listener=listener;state.wrapFn=wrapped;return wrapped}EventEmitter.prototype.once=function once(type,listener){checkListener(listener);this.on(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.prependOnceListener=function prependOnceListener(type,listener){checkListener(listener);this.prependListener(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.removeListener=function removeListener(type,listener){var list,events,position,i,originalListener;checkListener(listener);events=this._events;if(events===undefined)return this;list=events[type];if(list===undefined)return this;if(list===listener||list.listener===listener){if(--this._eventsCount===0)this._events=Object.create(null);else{delete events[type];if(events.removeListener)this.emit("removeListener",type,list.listener||listener)}}else if(typeof list!=="function"){position=-1;for(i=list.length-1;i>=0;i--){if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener;position=i;break}}if(position<0)return this;if(position===0)list.shift();else{spliceOne(list,position)}if(list.length===1)events[type]=list[0];if(events.removeListener!==undefined)this.emit("removeListener",type,originalListener||listener)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function removeAllListeners(type){var listeners,events,i;events=this._events;if(events===undefined)return this;if(events.removeListener===undefined){if(arguments.length===0){this._events=Object.create(null);this._eventsCount=0}else if(events[type]!==undefined){if(--this._eventsCount===0)this._events=Object.create(null);else delete events[type]}return this}if(arguments.length===0){var keys=Object.keys(events);var key;for(i=0;i=0;i--){this.removeListener(type,listeners[i])}}return this};function _listeners(target,type,unwrap){var events=target._events;if(events===undefined)return[];var evlistener=events[type];if(evlistener===undefined)return[];if(typeof evlistener==="function")return unwrap?[evlistener.listener||evlistener]:[evlistener];return unwrap?unwrapListeners(evlistener):arrayClone(evlistener,evlistener.length)}EventEmitter.prototype.listeners=function listeners(type){return _listeners(this,type,true)};EventEmitter.prototype.rawListeners=function rawListeners(type){return _listeners(this,type,false)};EventEmitter.listenerCount=function(emitter,type){if(typeof emitter.listenerCount==="function"){return emitter.listenerCount(type)}else{return listenerCount.call(emitter,type)}};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(type){var events=this._events;if(events!==undefined){var evlistener=events[type];if(typeof evlistener==="function"){return 1}else if(evlistener!==undefined){return evlistener.length}}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(arr,n){var copy=new Array(n);for(var i=0;i>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],9:[function(require,module,exports){"use strict";function isUtf8(buf){if(!buf){return false}let i=0;const len=buf.length;while(i=194&&buf[i]<=223){if(buf[i+1]>>6===2){i+=2;continue}else{return false}}if((buf[i]===224&&buf[i+1]>=160&&buf[i+1]<=191||buf[i]===237&&buf[i+1]>=128&&buf[i+1]<=159)&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]>=225&&buf[i]<=236||buf[i]>=238&&buf[i]<=239)&&buf[i+1]>>6===2&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]===240&&buf[i+1]>=144&&buf[i+1]<=191||buf[i]>=241&&buf[i]<=243&&buf[i+1]>>6===2||buf[i]===244&&buf[i+1]>=128&&buf[i+1]<=143)&&buf[i+2]>>6===2&&buf[i+3]>>6===2){i+=4;continue}return false}return true}module.exports=isUtf8},{}],10:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i=to){return[]}return new Array(to-from).fill().map(function(_,i){return i+from})}},{key:"hexToInt",value:function hexToInt(hexString){if(hexString===undefined||hexString===null){return hexString}return Number.parseInt(hexString,16)}},{key:"intToHex",value:function intToHex(_int){if(_int===undefined||_int===null){return _int}var hexString=_int.toString(16);return"0x"+hexString}},{key:"messageToBuffer",value:function messageToBuffer(message){var buffer=_buffer.Buffer.from([]);try{if(typeof message==="string"){buffer=_buffer.Buffer.from(message.replace("0x",""),"hex")}else{buffer=_buffer.Buffer.from(message)}}catch(err){console.log("messageToBuffer error: ".concat(err))}return buffer}},{key:"bufferToHex",value:function bufferToHex(buf){return"0x"+_buffer.Buffer.from(buf).toString("hex")}}]);return Utils}();module.exports=Utils},{buffer:6}]},{},[4]); \ No newline at end of file +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i1&&arguments[1]!==undefined?arguments[1]:true;this.idMapping.tryFixId(payload);return new Promise(function(resolve,reject){if(!payload.id){payload.id=_utils["default"].genId()}_this2.callbacks.set(payload.id,function(error,data){setTimeout(function(){if(error){reject(error)}else{resolve(data)}},1)});_this2.wrapResults.set(payload.id,wrapResult);switch(payload.method){case"eth_accounts":case"eth_coinbase":case"net_version":case"eth_chainId":case"eth_sign":case"personal_sign":case"personal_ecRecover":case"eth_signTypedData_v3":case"eth_signTypedData":case"eth_signTypedData_v4":case"eth_sendTransaction":case"eth_requestAccounts":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":case"wallet_requestPermissions":case"wallet_getPermissions":return _this2._processPayload(payload);case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_subscribe":throw new _error["default"](4200,"tiny wallet does not support ".concat(payload.method));default:return _this2.rpc.call(payload)}})}},{key:"_processPayload",value:function _processPayload(payload){if(!this.didGetLatestConfiguration){this.pendingPayloads.push(payload);return}switch(payload.method){case"eth_accounts":return this.sendResponse(payload.id,this.eth_accounts());case"eth_coinbase":return this.sendResponse(payload.id,this.eth_coinbase());case"net_version":return this.sendResponse(payload.id,this.net_version());case"eth_chainId":return this.sendResponse(payload.id,this.eth_chainId());case"eth_sign":return this.eth_sign(payload);case"personal_sign":return this.personal_sign(payload);case"personal_ecRecover":return this.personal_ecRecover(payload);case"eth_signTypedData_v3":return this.eth_signTypedData(payload,false);case"eth_signTypedData":case"eth_signTypedData_v4":return this.eth_signTypedData(payload,true);case"eth_sendTransaction":return this.eth_sendTransaction(payload);case"eth_requestAccounts":if(!this.address){return this.eth_requestAccounts(payload)}else{return this.sendResponse(payload.id,this.eth_accounts())}case"wallet_addEthereumChain":return this.wallet_addEthereumChain(payload);case"wallet_switchEthereumChain":return this.wallet_switchEthereumChain(payload);case"wallet_requestPermissions":case"wallet_getPermissions":var permissions=[{parentCapability:"eth_accounts"}];return this.sendResponse(payload.id,permissions)}}},{key:"emitConnect",value:function emitConnect(chainId){this.emit("connect",{chainId:chainId})}},{key:"eth_accounts",value:function eth_accounts(){return this.address?[this.address]:[]}},{key:"eth_coinbase",value:function eth_coinbase(){return this.address}},{key:"net_version",value:function net_version(){return parseInt(this.chainId,16).toString(10)||null}},{key:"eth_chainId",value:function eth_chainId(){return this.chainId}},{key:"eth_sign",value:function eth_sign(payload){var buffer=_utils["default"].messageToBuffer(payload.params[1]);var hex=_utils["default"].bufferToHex(buffer);if((0,_isutf["default"])(buffer)){this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signMessage",payload.id,{data:hex})}}},{key:"personal_sign",value:function personal_sign(payload){var message=payload.params[0];var buffer=_utils["default"].messageToBuffer(message);if(buffer.length===0){var hex=_utils["default"].bufferToHex(message);this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signPersonalMessage",payload.id,{data:message})}}},{key:"personal_ecRecover",value:function personal_ecRecover(payload){this.postMessage("ecRecover",payload.id,{signature:payload.params[1],message:payload.params[0]})}},{key:"eth_signTypedData",value:function eth_signTypedData(payload,useV4){this.postMessage("signTypedMessage",payload.id,{raw:payload.params[1]})}},{key:"eth_sendTransaction",value:function eth_sendTransaction(payload){this.postMessage("signTransaction",payload.id,payload.params[0])}},{key:"eth_requestAccounts",value:function eth_requestAccounts(payload){this.postMessage("requestAccounts",payload.id,{})}},{key:"wallet_watchAsset",value:function wallet_watchAsset(payload){var options=payload.params.options;this.postMessage("watchAsset",payload.id,{type:payload.type,contract:options.address,symbol:options.symbol,decimals:options.decimals||0})}},{key:"wallet_switchEthereumChain",value:function wallet_switchEthereumChain(payload){if(this.chainId!=payload.params[0].chainId){this.postMessage("switchEthereumChain",payload.id,payload.params[0])}else{this.sendResponse(payload.id,[this.address])}}},{key:"wallet_addEthereumChain",value:function wallet_addEthereumChain(payload){this.postMessage("addEthereumChain",payload.id,payload.params[0])}},{key:"processTokenaryResponse",value:function processTokenaryResponse(id,response){if(response.name=="didLoadLatestConfiguration"){this.didGetLatestConfiguration=true;if(response.chainId){this.updateAccount(response.name,response.results,response.chainId)}var _iterator=_createForOfIteratorHelper(this.pendingPayloads),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var payload=_step.value;this._processPayload(payload)}}catch(err){_iterator.e(err)}finally{_iterator.f()}this.pendingPayloads=[];return}if("result"in response){this.sendResponse(id,response.result)}else if("results"in response){if(response.name=="switchEthereumChain"||response.name=="addEthereumChain"){this.updateAccount(response.name,response.results,response.chainId)}if(response.name!="switchAccount"){this.sendResponse(id,response.results)}if(response.name=="requestAccounts"||response.name=="switchAccount"){this.updateAccount(response.name,response.results,response.chainId)}}else if("error"in response){this.sendError(id,response.error)}}},{key:"postMessage",value:function postMessage(handler,id,data){if(this.ready||handler==="requestAccounts"||handler==="switchEthereumChain"||handler==="addEthereumChain"){var object={object:data,address:this.address,chainId:this.chainId};window.tokenary.postMessage(handler,id,object,"ethereum")}else{this.sendError(id,new _error["default"](4100,"provider is not ready"))}}},{key:"sendResponse",value:function sendResponse(id,result){var originId=this.idMapping.tryPopId(id)||id;var callback=this.callbacks.get(id);var wrapResult=this.wrapResults.get(id);var data={jsonrpc:"2.0",id:originId};if(result!==null&&result.result){data.result=result.result}else{data.result=result}if(callback){wrapResult?callback(null,data):callback(null,data.result);this.callbacks["delete"](id)}else{console.log("callback id: ".concat(id," not found"))}}},{key:"sendError",value:function sendError(id,error){console.log("<== ".concat(id," sendError ").concat(error));var callback=this.callbacks.get(id);if(callback){callback(error instanceof Error?error:new Error(error),null);this.callbacks["delete"](id)}}}]);return TokenaryEthereum}(_events.EventEmitter);module.exports=TokenaryEthereum},{"./error":1,"./id_mapping":3,"./rpc":10,"./utils":11,events:7,isutf8:9}],3:[function(require,module,exports){"use strict";var _utils=_interopRequireDefault(require("./utils"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;var i;for(i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],6:[function(require,module,exports){(function(Buffer){(function(){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH;Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport();if(!Buffer.TYPED_ARRAY_SUPPORT&&typeof console!=="undefined"&&typeof console.error==="function"){console.error("This browser lacks typed array (Uint8Array) support which is required by "+"`buffer` v5.x. Use `buffer` v4.x if you require old browser support.")}function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42}catch(e){return false}}Object.defineProperty(Buffer.prototype,"parent",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.buffer}});Object.defineProperty(Buffer.prototype,"offset",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.byteOffset}});function createBuffer(length){if(length>K_MAX_LENGTH){throw new RangeError('The value "'+length+'" is invalid for option "size"')}var buf=new Uint8Array(length);buf.__proto__=Buffer.prototype;return buf}function Buffer(arg,encodingOrOffset,length){if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new TypeError('The "string" argument must be of type string. Received type number')}return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}if(typeof Symbol!=="undefined"&&Symbol.species!=null&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true,enumerable:false,writable:false})}Buffer.poolSize=8192;function from(value,encodingOrOffset,length){if(typeof value==="string"){return fromString(value,encodingOrOffset)}if(ArrayBuffer.isView(value)){return fromArrayLike(value)}if(value==null){throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer)){return fromArrayBuffer(value,encodingOrOffset,length)}if(typeof value==="number"){throw new TypeError('The "value" argument must not be of type number. Received type number')}var valueOf=value.valueOf&&value.valueOf();if(valueOf!=null&&valueOf!==value){return Buffer.from(valueOf,encodingOrOffset,length)}var b=fromObject(value);if(b)return b;if(typeof Symbol!=="undefined"&&Symbol.toPrimitive!=null&&typeof value[Symbol.toPrimitive]==="function"){return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)};Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be of type number')}else if(size<0){throw new RangeError('The value "'+size+'" is invalid for option "size"')}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill)}return createBuffer(size)}Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding)};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0)}Buffer.allocUnsafe=function(size){return allocUnsafe(size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)};function fromString(string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}var length=byteLength(string,encoding)|0;var buf=createBuffer(length);var actual=buf.write(string,encoding);if(actual!==length){buf=buf.slice(0,actual)}return buf}function fromArrayLike(array){var length=array.length<0?0:checked(array.length)|0;var buf=createBuffer(length);for(var i=0;i=K_MAX_LENGTH){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+K_MAX_LENGTH.toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true&&b!==Buffer.prototype};Buffer.compare=function compare(a,b){if(isInstance(a,Uint8Array))a=Buffer.from(a,a.offset,a.byteLength);if(isInstance(b,Uint8Array))b=Buffer.from(b,b.offset,b.byteLength);if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array')}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i2&&arguments[2]===true;if(!mustMatch&&len===0)return 0;var loweredCase=false;for(;;){switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return len*2;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase){return mustMatch?-1:utf8ToBytes(string).length}encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;imax)str+=" ... ";return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)){target=Buffer.from(target,target.offset,target.byteLength)}if(!Buffer.isBuffer(target)){throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. '+"Received type "+typeof target)}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(numberIsNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(length>strLen/2){length=strLen/2}for(var i=0;i>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);this[offset]=value&255;return offset+1};Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255;return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}if(val.length===1){var code=val.charCodeAt(0);if(encoding==="utf8"&&code<128||encoding==="latin1"){val=code}}}else if(typeof val==="number"){val=val&255}if(start<0||this.length>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isInstance(obj,type){return obj instanceof type||obj!=null&&obj.constructor!=null&&obj.constructor.name!=null&&obj.constructor.name===type.name}function numberIsNaN(obj){return obj!==obj}}).call(this)}).call(this,require("buffer").Buffer)},{"base64-js":5,buffer:6,ieee754:8}],7:[function(require,module,exports){"use strict";var R=typeof Reflect==="object"?Reflect:null;var ReflectApply=R&&typeof R.apply==="function"?R.apply:function ReflectApply(target,receiver,args){return Function.prototype.apply.call(target,receiver,args)};var ReflectOwnKeys;if(R&&typeof R.ownKeys==="function"){ReflectOwnKeys=R.ownKeys}else if(Object.getOwnPropertySymbols){ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target))}}else{ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target)}}function ProcessEmitWarning(warning){if(console&&console.warn)console.warn(warning)}var NumberIsNaN=Number.isNaN||function NumberIsNaN(value){return value!==value};function EventEmitter(){EventEmitter.init.call(this)}module.exports=EventEmitter;module.exports.once=once;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=undefined;var defaultMaxListeners=10;function checkListener(listener){if(typeof listener!=="function"){throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof listener)}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:true,get:function(){return defaultMaxListeners},set:function(arg){if(typeof arg!=="number"||arg<0||NumberIsNaN(arg)){throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+arg+".")}defaultMaxListeners=arg}});EventEmitter.init=function(){if(this._events===undefined||this._events===Object.getPrototypeOf(this)._events){this._events=Object.create(null);this._eventsCount=0}this._maxListeners=this._maxListeners||undefined};EventEmitter.prototype.setMaxListeners=function setMaxListeners(n){if(typeof n!=="number"||n<0||NumberIsNaN(n)){throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".")}this._maxListeners=n;return this};function _getMaxListeners(that){if(that._maxListeners===undefined)return EventEmitter.defaultMaxListeners;return that._maxListeners}EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function emit(type){var args=[];for(var i=1;i0)er=args[0];if(er instanceof Error){throw er}var err=new Error("Unhandled error."+(er?" ("+er.message+")":""));err.context=er;throw err}var handler=events[type];if(handler===undefined)return false;if(typeof handler==="function"){ReflectApply(handler,this,args)}else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i0&&existing.length>m&&!existing.warned){existing.warned=true;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+" "+String(type)+" listeners "+"added. Use emitter.setMaxListeners() to "+"increase limit");w.name="MaxListenersExceededWarning";w.emitter=target;w.type=type;w.count=existing.length;ProcessEmitWarning(w)}}return target}EventEmitter.prototype.addListener=function addListener(type,listener){return _addListener(this,type,listener,false)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function prependListener(type,listener){return _addListener(this,type,listener,true)};function onceWrapper(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;if(arguments.length===0)return this.listener.call(this.target);return this.listener.apply(this.target,arguments)}}function _onceWrap(target,type,listener){var state={fired:false,wrapFn:undefined,target:target,type:type,listener:listener};var wrapped=onceWrapper.bind(state);wrapped.listener=listener;state.wrapFn=wrapped;return wrapped}EventEmitter.prototype.once=function once(type,listener){checkListener(listener);this.on(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.prependOnceListener=function prependOnceListener(type,listener){checkListener(listener);this.prependListener(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.removeListener=function removeListener(type,listener){var list,events,position,i,originalListener;checkListener(listener);events=this._events;if(events===undefined)return this;list=events[type];if(list===undefined)return this;if(list===listener||list.listener===listener){if(--this._eventsCount===0)this._events=Object.create(null);else{delete events[type];if(events.removeListener)this.emit("removeListener",type,list.listener||listener)}}else if(typeof list!=="function"){position=-1;for(i=list.length-1;i>=0;i--){if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener;position=i;break}}if(position<0)return this;if(position===0)list.shift();else{spliceOne(list,position)}if(list.length===1)events[type]=list[0];if(events.removeListener!==undefined)this.emit("removeListener",type,originalListener||listener)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function removeAllListeners(type){var listeners,events,i;events=this._events;if(events===undefined)return this;if(events.removeListener===undefined){if(arguments.length===0){this._events=Object.create(null);this._eventsCount=0}else if(events[type]!==undefined){if(--this._eventsCount===0)this._events=Object.create(null);else delete events[type]}return this}if(arguments.length===0){var keys=Object.keys(events);var key;for(i=0;i=0;i--){this.removeListener(type,listeners[i])}}return this};function _listeners(target,type,unwrap){var events=target._events;if(events===undefined)return[];var evlistener=events[type];if(evlistener===undefined)return[];if(typeof evlistener==="function")return unwrap?[evlistener.listener||evlistener]:[evlistener];return unwrap?unwrapListeners(evlistener):arrayClone(evlistener,evlistener.length)}EventEmitter.prototype.listeners=function listeners(type){return _listeners(this,type,true)};EventEmitter.prototype.rawListeners=function rawListeners(type){return _listeners(this,type,false)};EventEmitter.listenerCount=function(emitter,type){if(typeof emitter.listenerCount==="function"){return emitter.listenerCount(type)}else{return listenerCount.call(emitter,type)}};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(type){var events=this._events;if(events!==undefined){var evlistener=events[type];if(typeof evlistener==="function"){return 1}else if(evlistener!==undefined){return evlistener.length}}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(arr,n){var copy=new Array(n);for(var i=0;i>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],9:[function(require,module,exports){"use strict";function isUtf8(buf){if(!buf){return false}let i=0;const len=buf.length;while(i=194&&buf[i]<=223){if(buf[i+1]>>6===2){i+=2;continue}else{return false}}if((buf[i]===224&&buf[i+1]>=160&&buf[i+1]<=191||buf[i]===237&&buf[i+1]>=128&&buf[i+1]<=159)&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]>=225&&buf[i]<=236||buf[i]>=238&&buf[i]<=239)&&buf[i+1]>>6===2&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]===240&&buf[i+1]>=144&&buf[i+1]<=191||buf[i]>=241&&buf[i]<=243&&buf[i+1]>>6===2||buf[i]===244&&buf[i+1]>=128&&buf[i+1]<=143)&&buf[i+2]>>6===2&&buf[i+3]>>6===2){i+=4;continue}return false}return true}module.exports=isUtf8},{}],10:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i=to){return[]}return new Array(to-from).fill().map(function(_,i){return i+from})}},{key:"hexToInt",value:function hexToInt(hexString){if(hexString===undefined||hexString===null){return hexString}return Number.parseInt(hexString,16)}},{key:"intToHex",value:function intToHex(_int){if(_int===undefined||_int===null){return _int}var hexString=_int.toString(16);return"0x"+hexString}},{key:"messageToBuffer",value:function messageToBuffer(message){var buffer=_buffer.Buffer.from([]);try{if(typeof message==="string"){buffer=_buffer.Buffer.from(message.replace("0x",""),"hex")}else{buffer=_buffer.Buffer.from(message)}}catch(err){console.log("messageToBuffer error: ".concat(err))}return buffer}},{key:"bufferToHex",value:function bufferToHex(buf){return"0x"+_buffer.Buffer.from(buf).toString("hex")}}]);return Utils}();module.exports=Utils},{buffer:6}]},{},[4]); \ No newline at end of file diff --git a/Safari Shared/SafariWebExtensionHandler.swift b/Safari Shared/SafariWebExtensionHandler.swift index 02dcccf0..1ec1ea35 100644 --- a/Safari Shared/SafariWebExtensionHandler.swift +++ b/Safari Shared/SafariWebExtensionHandler.swift @@ -82,6 +82,7 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { let task = URLSession.shared.dataTask(with: request) { [weak self] data, response, error in if let data = data, let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] { self?.respond(with: json, context: context) + // TODO: id is missing when there is an error } else { // TODO: respond with error self?.respond(with: ["yo": "body", "chainId": chainId, "result": "gg"], context: context) diff --git a/Safari macOS/Safari.entitlements b/Safari macOS/Safari.entitlements index 115724cd..552c8cfd 100644 --- a/Safari macOS/Safari.entitlements +++ b/Safari macOS/Safari.entitlements @@ -8,5 +8,7 @@ group.io.tokenary + com.apple.security.network.client + From f780dfeda1cf0fd58f8686e22c60d39b048a0ef0 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Tue, 23 Jan 2024 19:47:48 +0300 Subject: [PATCH 15/19] no more host permissions --- Safari iOS/Resources/manifest.json | 7 ------- Safari macOS/Resources/manifest.json | 6 ------ 2 files changed, 13 deletions(-) diff --git a/Safari iOS/Resources/manifest.json b/Safari iOS/Resources/manifest.json index 234ec182..3af4c5fb 100644 --- a/Safari iOS/Resources/manifest.json +++ b/Safari iOS/Resources/manifest.json @@ -42,13 +42,6 @@ "activeTab", "tabs" ], - - "host_permissions": [ - "https://*.llamarpc.com/", - "https://*.infura.io/*", - "https://tokenary.io/*", - "tokenary://*" - ], "web_accessible_resources": [ "inpage.js" ] } diff --git a/Safari macOS/Resources/manifest.json b/Safari macOS/Resources/manifest.json index e11124ed..2ce4e719 100644 --- a/Safari macOS/Resources/manifest.json +++ b/Safari macOS/Resources/manifest.json @@ -43,11 +43,5 @@ "tabs" ], - "host_permissions": [ - "https://*.llamarpc.com/", - "https://*.infura.io/*", - "https://tokenary.io/*" - ], - "web_accessible_resources": [ "inpage.js" ] } From 8b1afb6021faf66801f4732f7cfa313c62136e4f Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Tue, 23 Jan 2024 19:57:29 +0300 Subject: [PATCH 16/19] proper inpage clean up on extension response --- Safari Shared/Inpage Provider/ethereum.js | 2 ++ Safari Shared/Resources/inpage.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Safari Shared/Inpage Provider/ethereum.js b/Safari Shared/Inpage Provider/ethereum.js index 8605dc0f..d2ca8b33 100644 --- a/Safari Shared/Inpage Provider/ethereum.js +++ b/Safari Shared/Inpage Provider/ethereum.js @@ -395,6 +395,7 @@ class TokenaryEthereum extends EventEmitter { if (callback) { wrapResult ? callback(null, data) : callback(null, data.result); this.callbacks.delete(id); + this.wrapResults.delete(id); } else { console.log(`callback id: ${id} not found`); } @@ -406,6 +407,7 @@ class TokenaryEthereum extends EventEmitter { if (callback) { callback(error instanceof Error ? error : new Error(error), null); this.callbacks.delete(id); + this.wrapResults.delete(id); } } } diff --git a/Safari Shared/Resources/inpage.js b/Safari Shared/Resources/inpage.js index 23656808..c2bb3f80 100644 --- a/Safari Shared/Resources/inpage.js +++ b/Safari Shared/Resources/inpage.js @@ -1 +1 @@ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i1&&arguments[1]!==undefined?arguments[1]:true;this.idMapping.tryFixId(payload);return new Promise(function(resolve,reject){if(!payload.id){payload.id=_utils["default"].genId()}_this2.callbacks.set(payload.id,function(error,data){setTimeout(function(){if(error){reject(error)}else{resolve(data)}},1)});_this2.wrapResults.set(payload.id,wrapResult);switch(payload.method){case"eth_accounts":case"eth_coinbase":case"net_version":case"eth_chainId":case"eth_sign":case"personal_sign":case"personal_ecRecover":case"eth_signTypedData_v3":case"eth_signTypedData":case"eth_signTypedData_v4":case"eth_sendTransaction":case"eth_requestAccounts":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":case"wallet_requestPermissions":case"wallet_getPermissions":return _this2._processPayload(payload);case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_subscribe":throw new _error["default"](4200,"tiny wallet does not support ".concat(payload.method));default:return _this2.rpc.call(payload)}})}},{key:"_processPayload",value:function _processPayload(payload){if(!this.didGetLatestConfiguration){this.pendingPayloads.push(payload);return}switch(payload.method){case"eth_accounts":return this.sendResponse(payload.id,this.eth_accounts());case"eth_coinbase":return this.sendResponse(payload.id,this.eth_coinbase());case"net_version":return this.sendResponse(payload.id,this.net_version());case"eth_chainId":return this.sendResponse(payload.id,this.eth_chainId());case"eth_sign":return this.eth_sign(payload);case"personal_sign":return this.personal_sign(payload);case"personal_ecRecover":return this.personal_ecRecover(payload);case"eth_signTypedData_v3":return this.eth_signTypedData(payload,false);case"eth_signTypedData":case"eth_signTypedData_v4":return this.eth_signTypedData(payload,true);case"eth_sendTransaction":return this.eth_sendTransaction(payload);case"eth_requestAccounts":if(!this.address){return this.eth_requestAccounts(payload)}else{return this.sendResponse(payload.id,this.eth_accounts())}case"wallet_addEthereumChain":return this.wallet_addEthereumChain(payload);case"wallet_switchEthereumChain":return this.wallet_switchEthereumChain(payload);case"wallet_requestPermissions":case"wallet_getPermissions":var permissions=[{parentCapability:"eth_accounts"}];return this.sendResponse(payload.id,permissions)}}},{key:"emitConnect",value:function emitConnect(chainId){this.emit("connect",{chainId:chainId})}},{key:"eth_accounts",value:function eth_accounts(){return this.address?[this.address]:[]}},{key:"eth_coinbase",value:function eth_coinbase(){return this.address}},{key:"net_version",value:function net_version(){return parseInt(this.chainId,16).toString(10)||null}},{key:"eth_chainId",value:function eth_chainId(){return this.chainId}},{key:"eth_sign",value:function eth_sign(payload){var buffer=_utils["default"].messageToBuffer(payload.params[1]);var hex=_utils["default"].bufferToHex(buffer);if((0,_isutf["default"])(buffer)){this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signMessage",payload.id,{data:hex})}}},{key:"personal_sign",value:function personal_sign(payload){var message=payload.params[0];var buffer=_utils["default"].messageToBuffer(message);if(buffer.length===0){var hex=_utils["default"].bufferToHex(message);this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signPersonalMessage",payload.id,{data:message})}}},{key:"personal_ecRecover",value:function personal_ecRecover(payload){this.postMessage("ecRecover",payload.id,{signature:payload.params[1],message:payload.params[0]})}},{key:"eth_signTypedData",value:function eth_signTypedData(payload,useV4){this.postMessage("signTypedMessage",payload.id,{raw:payload.params[1]})}},{key:"eth_sendTransaction",value:function eth_sendTransaction(payload){this.postMessage("signTransaction",payload.id,payload.params[0])}},{key:"eth_requestAccounts",value:function eth_requestAccounts(payload){this.postMessage("requestAccounts",payload.id,{})}},{key:"wallet_watchAsset",value:function wallet_watchAsset(payload){var options=payload.params.options;this.postMessage("watchAsset",payload.id,{type:payload.type,contract:options.address,symbol:options.symbol,decimals:options.decimals||0})}},{key:"wallet_switchEthereumChain",value:function wallet_switchEthereumChain(payload){if(this.chainId!=payload.params[0].chainId){this.postMessage("switchEthereumChain",payload.id,payload.params[0])}else{this.sendResponse(payload.id,[this.address])}}},{key:"wallet_addEthereumChain",value:function wallet_addEthereumChain(payload){this.postMessage("addEthereumChain",payload.id,payload.params[0])}},{key:"processTokenaryResponse",value:function processTokenaryResponse(id,response){if(response.name=="didLoadLatestConfiguration"){this.didGetLatestConfiguration=true;if(response.chainId){this.updateAccount(response.name,response.results,response.chainId)}var _iterator=_createForOfIteratorHelper(this.pendingPayloads),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var payload=_step.value;this._processPayload(payload)}}catch(err){_iterator.e(err)}finally{_iterator.f()}this.pendingPayloads=[];return}if("result"in response){this.sendResponse(id,response.result)}else if("results"in response){if(response.name=="switchEthereumChain"||response.name=="addEthereumChain"){this.updateAccount(response.name,response.results,response.chainId)}if(response.name!="switchAccount"){this.sendResponse(id,response.results)}if(response.name=="requestAccounts"||response.name=="switchAccount"){this.updateAccount(response.name,response.results,response.chainId)}}else if("error"in response){this.sendError(id,response.error)}}},{key:"postMessage",value:function postMessage(handler,id,data){if(this.ready||handler==="requestAccounts"||handler==="switchEthereumChain"||handler==="addEthereumChain"){var object={object:data,address:this.address,chainId:this.chainId};window.tokenary.postMessage(handler,id,object,"ethereum")}else{this.sendError(id,new _error["default"](4100,"provider is not ready"))}}},{key:"sendResponse",value:function sendResponse(id,result){var originId=this.idMapping.tryPopId(id)||id;var callback=this.callbacks.get(id);var wrapResult=this.wrapResults.get(id);var data={jsonrpc:"2.0",id:originId};if(result!==null&&result.result){data.result=result.result}else{data.result=result}if(callback){wrapResult?callback(null,data):callback(null,data.result);this.callbacks["delete"](id)}else{console.log("callback id: ".concat(id," not found"))}}},{key:"sendError",value:function sendError(id,error){console.log("<== ".concat(id," sendError ").concat(error));var callback=this.callbacks.get(id);if(callback){callback(error instanceof Error?error:new Error(error),null);this.callbacks["delete"](id)}}}]);return TokenaryEthereum}(_events.EventEmitter);module.exports=TokenaryEthereum},{"./error":1,"./id_mapping":3,"./rpc":10,"./utils":11,events:7,isutf8:9}],3:[function(require,module,exports){"use strict";var _utils=_interopRequireDefault(require("./utils"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;var i;for(i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],6:[function(require,module,exports){(function(Buffer){(function(){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH;Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport();if(!Buffer.TYPED_ARRAY_SUPPORT&&typeof console!=="undefined"&&typeof console.error==="function"){console.error("This browser lacks typed array (Uint8Array) support which is required by "+"`buffer` v5.x. Use `buffer` v4.x if you require old browser support.")}function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42}catch(e){return false}}Object.defineProperty(Buffer.prototype,"parent",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.buffer}});Object.defineProperty(Buffer.prototype,"offset",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.byteOffset}});function createBuffer(length){if(length>K_MAX_LENGTH){throw new RangeError('The value "'+length+'" is invalid for option "size"')}var buf=new Uint8Array(length);buf.__proto__=Buffer.prototype;return buf}function Buffer(arg,encodingOrOffset,length){if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new TypeError('The "string" argument must be of type string. Received type number')}return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}if(typeof Symbol!=="undefined"&&Symbol.species!=null&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true,enumerable:false,writable:false})}Buffer.poolSize=8192;function from(value,encodingOrOffset,length){if(typeof value==="string"){return fromString(value,encodingOrOffset)}if(ArrayBuffer.isView(value)){return fromArrayLike(value)}if(value==null){throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer)){return fromArrayBuffer(value,encodingOrOffset,length)}if(typeof value==="number"){throw new TypeError('The "value" argument must not be of type number. Received type number')}var valueOf=value.valueOf&&value.valueOf();if(valueOf!=null&&valueOf!==value){return Buffer.from(valueOf,encodingOrOffset,length)}var b=fromObject(value);if(b)return b;if(typeof Symbol!=="undefined"&&Symbol.toPrimitive!=null&&typeof value[Symbol.toPrimitive]==="function"){return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)};Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be of type number')}else if(size<0){throw new RangeError('The value "'+size+'" is invalid for option "size"')}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill)}return createBuffer(size)}Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding)};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0)}Buffer.allocUnsafe=function(size){return allocUnsafe(size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)};function fromString(string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}var length=byteLength(string,encoding)|0;var buf=createBuffer(length);var actual=buf.write(string,encoding);if(actual!==length){buf=buf.slice(0,actual)}return buf}function fromArrayLike(array){var length=array.length<0?0:checked(array.length)|0;var buf=createBuffer(length);for(var i=0;i=K_MAX_LENGTH){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+K_MAX_LENGTH.toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true&&b!==Buffer.prototype};Buffer.compare=function compare(a,b){if(isInstance(a,Uint8Array))a=Buffer.from(a,a.offset,a.byteLength);if(isInstance(b,Uint8Array))b=Buffer.from(b,b.offset,b.byteLength);if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array')}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i2&&arguments[2]===true;if(!mustMatch&&len===0)return 0;var loweredCase=false;for(;;){switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return len*2;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase){return mustMatch?-1:utf8ToBytes(string).length}encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;imax)str+=" ... ";return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)){target=Buffer.from(target,target.offset,target.byteLength)}if(!Buffer.isBuffer(target)){throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. '+"Received type "+typeof target)}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(numberIsNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(length>strLen/2){length=strLen/2}for(var i=0;i>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);this[offset]=value&255;return offset+1};Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255;return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}if(val.length===1){var code=val.charCodeAt(0);if(encoding==="utf8"&&code<128||encoding==="latin1"){val=code}}}else if(typeof val==="number"){val=val&255}if(start<0||this.length>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isInstance(obj,type){return obj instanceof type||obj!=null&&obj.constructor!=null&&obj.constructor.name!=null&&obj.constructor.name===type.name}function numberIsNaN(obj){return obj!==obj}}).call(this)}).call(this,require("buffer").Buffer)},{"base64-js":5,buffer:6,ieee754:8}],7:[function(require,module,exports){"use strict";var R=typeof Reflect==="object"?Reflect:null;var ReflectApply=R&&typeof R.apply==="function"?R.apply:function ReflectApply(target,receiver,args){return Function.prototype.apply.call(target,receiver,args)};var ReflectOwnKeys;if(R&&typeof R.ownKeys==="function"){ReflectOwnKeys=R.ownKeys}else if(Object.getOwnPropertySymbols){ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target))}}else{ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target)}}function ProcessEmitWarning(warning){if(console&&console.warn)console.warn(warning)}var NumberIsNaN=Number.isNaN||function NumberIsNaN(value){return value!==value};function EventEmitter(){EventEmitter.init.call(this)}module.exports=EventEmitter;module.exports.once=once;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=undefined;var defaultMaxListeners=10;function checkListener(listener){if(typeof listener!=="function"){throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof listener)}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:true,get:function(){return defaultMaxListeners},set:function(arg){if(typeof arg!=="number"||arg<0||NumberIsNaN(arg)){throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+arg+".")}defaultMaxListeners=arg}});EventEmitter.init=function(){if(this._events===undefined||this._events===Object.getPrototypeOf(this)._events){this._events=Object.create(null);this._eventsCount=0}this._maxListeners=this._maxListeners||undefined};EventEmitter.prototype.setMaxListeners=function setMaxListeners(n){if(typeof n!=="number"||n<0||NumberIsNaN(n)){throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".")}this._maxListeners=n;return this};function _getMaxListeners(that){if(that._maxListeners===undefined)return EventEmitter.defaultMaxListeners;return that._maxListeners}EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function emit(type){var args=[];for(var i=1;i0)er=args[0];if(er instanceof Error){throw er}var err=new Error("Unhandled error."+(er?" ("+er.message+")":""));err.context=er;throw err}var handler=events[type];if(handler===undefined)return false;if(typeof handler==="function"){ReflectApply(handler,this,args)}else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i0&&existing.length>m&&!existing.warned){existing.warned=true;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+" "+String(type)+" listeners "+"added. Use emitter.setMaxListeners() to "+"increase limit");w.name="MaxListenersExceededWarning";w.emitter=target;w.type=type;w.count=existing.length;ProcessEmitWarning(w)}}return target}EventEmitter.prototype.addListener=function addListener(type,listener){return _addListener(this,type,listener,false)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function prependListener(type,listener){return _addListener(this,type,listener,true)};function onceWrapper(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;if(arguments.length===0)return this.listener.call(this.target);return this.listener.apply(this.target,arguments)}}function _onceWrap(target,type,listener){var state={fired:false,wrapFn:undefined,target:target,type:type,listener:listener};var wrapped=onceWrapper.bind(state);wrapped.listener=listener;state.wrapFn=wrapped;return wrapped}EventEmitter.prototype.once=function once(type,listener){checkListener(listener);this.on(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.prependOnceListener=function prependOnceListener(type,listener){checkListener(listener);this.prependListener(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.removeListener=function removeListener(type,listener){var list,events,position,i,originalListener;checkListener(listener);events=this._events;if(events===undefined)return this;list=events[type];if(list===undefined)return this;if(list===listener||list.listener===listener){if(--this._eventsCount===0)this._events=Object.create(null);else{delete events[type];if(events.removeListener)this.emit("removeListener",type,list.listener||listener)}}else if(typeof list!=="function"){position=-1;for(i=list.length-1;i>=0;i--){if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener;position=i;break}}if(position<0)return this;if(position===0)list.shift();else{spliceOne(list,position)}if(list.length===1)events[type]=list[0];if(events.removeListener!==undefined)this.emit("removeListener",type,originalListener||listener)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function removeAllListeners(type){var listeners,events,i;events=this._events;if(events===undefined)return this;if(events.removeListener===undefined){if(arguments.length===0){this._events=Object.create(null);this._eventsCount=0}else if(events[type]!==undefined){if(--this._eventsCount===0)this._events=Object.create(null);else delete events[type]}return this}if(arguments.length===0){var keys=Object.keys(events);var key;for(i=0;i=0;i--){this.removeListener(type,listeners[i])}}return this};function _listeners(target,type,unwrap){var events=target._events;if(events===undefined)return[];var evlistener=events[type];if(evlistener===undefined)return[];if(typeof evlistener==="function")return unwrap?[evlistener.listener||evlistener]:[evlistener];return unwrap?unwrapListeners(evlistener):arrayClone(evlistener,evlistener.length)}EventEmitter.prototype.listeners=function listeners(type){return _listeners(this,type,true)};EventEmitter.prototype.rawListeners=function rawListeners(type){return _listeners(this,type,false)};EventEmitter.listenerCount=function(emitter,type){if(typeof emitter.listenerCount==="function"){return emitter.listenerCount(type)}else{return listenerCount.call(emitter,type)}};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(type){var events=this._events;if(events!==undefined){var evlistener=events[type];if(typeof evlistener==="function"){return 1}else if(evlistener!==undefined){return evlistener.length}}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(arr,n){var copy=new Array(n);for(var i=0;i>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],9:[function(require,module,exports){"use strict";function isUtf8(buf){if(!buf){return false}let i=0;const len=buf.length;while(i=194&&buf[i]<=223){if(buf[i+1]>>6===2){i+=2;continue}else{return false}}if((buf[i]===224&&buf[i+1]>=160&&buf[i+1]<=191||buf[i]===237&&buf[i+1]>=128&&buf[i+1]<=159)&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]>=225&&buf[i]<=236||buf[i]>=238&&buf[i]<=239)&&buf[i+1]>>6===2&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]===240&&buf[i+1]>=144&&buf[i+1]<=191||buf[i]>=241&&buf[i]<=243&&buf[i+1]>>6===2||buf[i]===244&&buf[i+1]>=128&&buf[i+1]<=143)&&buf[i+2]>>6===2&&buf[i+3]>>6===2){i+=4;continue}return false}return true}module.exports=isUtf8},{}],10:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i=to){return[]}return new Array(to-from).fill().map(function(_,i){return i+from})}},{key:"hexToInt",value:function hexToInt(hexString){if(hexString===undefined||hexString===null){return hexString}return Number.parseInt(hexString,16)}},{key:"intToHex",value:function intToHex(_int){if(_int===undefined||_int===null){return _int}var hexString=_int.toString(16);return"0x"+hexString}},{key:"messageToBuffer",value:function messageToBuffer(message){var buffer=_buffer.Buffer.from([]);try{if(typeof message==="string"){buffer=_buffer.Buffer.from(message.replace("0x",""),"hex")}else{buffer=_buffer.Buffer.from(message)}}catch(err){console.log("messageToBuffer error: ".concat(err))}return buffer}},{key:"bufferToHex",value:function bufferToHex(buf){return"0x"+_buffer.Buffer.from(buf).toString("hex")}}]);return Utils}();module.exports=Utils},{buffer:6}]},{},[4]); \ No newline at end of file +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i1&&arguments[1]!==undefined?arguments[1]:true;this.idMapping.tryFixId(payload);return new Promise(function(resolve,reject){if(!payload.id){payload.id=_utils["default"].genId()}_this2.callbacks.set(payload.id,function(error,data){setTimeout(function(){if(error){reject(error)}else{resolve(data)}},1)});_this2.wrapResults.set(payload.id,wrapResult);switch(payload.method){case"eth_accounts":case"eth_coinbase":case"net_version":case"eth_chainId":case"eth_sign":case"personal_sign":case"personal_ecRecover":case"eth_signTypedData_v3":case"eth_signTypedData":case"eth_signTypedData_v4":case"eth_sendTransaction":case"eth_requestAccounts":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":case"wallet_requestPermissions":case"wallet_getPermissions":return _this2._processPayload(payload);case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_subscribe":throw new _error["default"](4200,"tiny wallet does not support ".concat(payload.method));default:return _this2.rpc.call(payload)}})}},{key:"_processPayload",value:function _processPayload(payload){if(!this.didGetLatestConfiguration){this.pendingPayloads.push(payload);return}switch(payload.method){case"eth_accounts":return this.sendResponse(payload.id,this.eth_accounts());case"eth_coinbase":return this.sendResponse(payload.id,this.eth_coinbase());case"net_version":return this.sendResponse(payload.id,this.net_version());case"eth_chainId":return this.sendResponse(payload.id,this.eth_chainId());case"eth_sign":return this.eth_sign(payload);case"personal_sign":return this.personal_sign(payload);case"personal_ecRecover":return this.personal_ecRecover(payload);case"eth_signTypedData_v3":return this.eth_signTypedData(payload,false);case"eth_signTypedData":case"eth_signTypedData_v4":return this.eth_signTypedData(payload,true);case"eth_sendTransaction":return this.eth_sendTransaction(payload);case"eth_requestAccounts":if(!this.address){return this.eth_requestAccounts(payload)}else{return this.sendResponse(payload.id,this.eth_accounts())}case"wallet_addEthereumChain":return this.wallet_addEthereumChain(payload);case"wallet_switchEthereumChain":return this.wallet_switchEthereumChain(payload);case"wallet_requestPermissions":case"wallet_getPermissions":var permissions=[{parentCapability:"eth_accounts"}];return this.sendResponse(payload.id,permissions)}}},{key:"emitConnect",value:function emitConnect(chainId){this.emit("connect",{chainId:chainId})}},{key:"eth_accounts",value:function eth_accounts(){return this.address?[this.address]:[]}},{key:"eth_coinbase",value:function eth_coinbase(){return this.address}},{key:"net_version",value:function net_version(){return parseInt(this.chainId,16).toString(10)||null}},{key:"eth_chainId",value:function eth_chainId(){return this.chainId}},{key:"eth_sign",value:function eth_sign(payload){var buffer=_utils["default"].messageToBuffer(payload.params[1]);var hex=_utils["default"].bufferToHex(buffer);if((0,_isutf["default"])(buffer)){this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signMessage",payload.id,{data:hex})}}},{key:"personal_sign",value:function personal_sign(payload){var message=payload.params[0];var buffer=_utils["default"].messageToBuffer(message);if(buffer.length===0){var hex=_utils["default"].bufferToHex(message);this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signPersonalMessage",payload.id,{data:message})}}},{key:"personal_ecRecover",value:function personal_ecRecover(payload){this.postMessage("ecRecover",payload.id,{signature:payload.params[1],message:payload.params[0]})}},{key:"eth_signTypedData",value:function eth_signTypedData(payload,useV4){this.postMessage("signTypedMessage",payload.id,{raw:payload.params[1]})}},{key:"eth_sendTransaction",value:function eth_sendTransaction(payload){this.postMessage("signTransaction",payload.id,payload.params[0])}},{key:"eth_requestAccounts",value:function eth_requestAccounts(payload){this.postMessage("requestAccounts",payload.id,{})}},{key:"wallet_watchAsset",value:function wallet_watchAsset(payload){var options=payload.params.options;this.postMessage("watchAsset",payload.id,{type:payload.type,contract:options.address,symbol:options.symbol,decimals:options.decimals||0})}},{key:"wallet_switchEthereumChain",value:function wallet_switchEthereumChain(payload){if(this.chainId!=payload.params[0].chainId){this.postMessage("switchEthereumChain",payload.id,payload.params[0])}else{this.sendResponse(payload.id,[this.address])}}},{key:"wallet_addEthereumChain",value:function wallet_addEthereumChain(payload){this.postMessage("addEthereumChain",payload.id,payload.params[0])}},{key:"processTokenaryResponse",value:function processTokenaryResponse(id,response){if(response.name=="didLoadLatestConfiguration"){this.didGetLatestConfiguration=true;if(response.chainId){this.updateAccount(response.name,response.results,response.chainId)}var _iterator=_createForOfIteratorHelper(this.pendingPayloads),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var payload=_step.value;this._processPayload(payload)}}catch(err){_iterator.e(err)}finally{_iterator.f()}this.pendingPayloads=[];return}if("result"in response){this.sendResponse(id,response.result)}else if("results"in response){if(response.name=="switchEthereumChain"||response.name=="addEthereumChain"){this.updateAccount(response.name,response.results,response.chainId)}if(response.name!="switchAccount"){this.sendResponse(id,response.results)}if(response.name=="requestAccounts"||response.name=="switchAccount"){this.updateAccount(response.name,response.results,response.chainId)}}else if("error"in response){this.sendError(id,response.error)}}},{key:"postMessage",value:function postMessage(handler,id,data){if(this.ready||handler==="requestAccounts"||handler==="switchEthereumChain"||handler==="addEthereumChain"){var object={object:data,address:this.address,chainId:this.chainId};window.tokenary.postMessage(handler,id,object,"ethereum")}else{this.sendError(id,new _error["default"](4100,"provider is not ready"))}}},{key:"sendResponse",value:function sendResponse(id,result){var originId=this.idMapping.tryPopId(id)||id;var callback=this.callbacks.get(id);var wrapResult=this.wrapResults.get(id);var data={jsonrpc:"2.0",id:originId};if(result!==null&&result.result){data.result=result.result}else{data.result=result}if(callback){wrapResult?callback(null,data):callback(null,data.result);this.callbacks["delete"](id);this.wrapResults["delete"](id)}else{console.log("callback id: ".concat(id," not found"))}}},{key:"sendError",value:function sendError(id,error){console.log("<== ".concat(id," sendError ").concat(error));var callback=this.callbacks.get(id);if(callback){callback(error instanceof Error?error:new Error(error),null);this.callbacks["delete"](id);this.wrapResults["delete"](id)}}}]);return TokenaryEthereum}(_events.EventEmitter);module.exports=TokenaryEthereum},{"./error":1,"./id_mapping":3,"./rpc":10,"./utils":11,events:7,isutf8:9}],3:[function(require,module,exports){"use strict";var _utils=_interopRequireDefault(require("./utils"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;var i;for(i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],6:[function(require,module,exports){(function(Buffer){(function(){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH;Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport();if(!Buffer.TYPED_ARRAY_SUPPORT&&typeof console!=="undefined"&&typeof console.error==="function"){console.error("This browser lacks typed array (Uint8Array) support which is required by "+"`buffer` v5.x. Use `buffer` v4.x if you require old browser support.")}function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42}catch(e){return false}}Object.defineProperty(Buffer.prototype,"parent",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.buffer}});Object.defineProperty(Buffer.prototype,"offset",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.byteOffset}});function createBuffer(length){if(length>K_MAX_LENGTH){throw new RangeError('The value "'+length+'" is invalid for option "size"')}var buf=new Uint8Array(length);buf.__proto__=Buffer.prototype;return buf}function Buffer(arg,encodingOrOffset,length){if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new TypeError('The "string" argument must be of type string. Received type number')}return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}if(typeof Symbol!=="undefined"&&Symbol.species!=null&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true,enumerable:false,writable:false})}Buffer.poolSize=8192;function from(value,encodingOrOffset,length){if(typeof value==="string"){return fromString(value,encodingOrOffset)}if(ArrayBuffer.isView(value)){return fromArrayLike(value)}if(value==null){throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer)){return fromArrayBuffer(value,encodingOrOffset,length)}if(typeof value==="number"){throw new TypeError('The "value" argument must not be of type number. Received type number')}var valueOf=value.valueOf&&value.valueOf();if(valueOf!=null&&valueOf!==value){return Buffer.from(valueOf,encodingOrOffset,length)}var b=fromObject(value);if(b)return b;if(typeof Symbol!=="undefined"&&Symbol.toPrimitive!=null&&typeof value[Symbol.toPrimitive]==="function"){return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)};Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be of type number')}else if(size<0){throw new RangeError('The value "'+size+'" is invalid for option "size"')}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill)}return createBuffer(size)}Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding)};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0)}Buffer.allocUnsafe=function(size){return allocUnsafe(size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)};function fromString(string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}var length=byteLength(string,encoding)|0;var buf=createBuffer(length);var actual=buf.write(string,encoding);if(actual!==length){buf=buf.slice(0,actual)}return buf}function fromArrayLike(array){var length=array.length<0?0:checked(array.length)|0;var buf=createBuffer(length);for(var i=0;i=K_MAX_LENGTH){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+K_MAX_LENGTH.toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true&&b!==Buffer.prototype};Buffer.compare=function compare(a,b){if(isInstance(a,Uint8Array))a=Buffer.from(a,a.offset,a.byteLength);if(isInstance(b,Uint8Array))b=Buffer.from(b,b.offset,b.byteLength);if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array')}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i2&&arguments[2]===true;if(!mustMatch&&len===0)return 0;var loweredCase=false;for(;;){switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return len*2;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase){return mustMatch?-1:utf8ToBytes(string).length}encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;imax)str+=" ... ";return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)){target=Buffer.from(target,target.offset,target.byteLength)}if(!Buffer.isBuffer(target)){throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. '+"Received type "+typeof target)}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(numberIsNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(length>strLen/2){length=strLen/2}for(var i=0;i>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);this[offset]=value&255;return offset+1};Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255;return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}if(val.length===1){var code=val.charCodeAt(0);if(encoding==="utf8"&&code<128||encoding==="latin1"){val=code}}}else if(typeof val==="number"){val=val&255}if(start<0||this.length>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isInstance(obj,type){return obj instanceof type||obj!=null&&obj.constructor!=null&&obj.constructor.name!=null&&obj.constructor.name===type.name}function numberIsNaN(obj){return obj!==obj}}).call(this)}).call(this,require("buffer").Buffer)},{"base64-js":5,buffer:6,ieee754:8}],7:[function(require,module,exports){"use strict";var R=typeof Reflect==="object"?Reflect:null;var ReflectApply=R&&typeof R.apply==="function"?R.apply:function ReflectApply(target,receiver,args){return Function.prototype.apply.call(target,receiver,args)};var ReflectOwnKeys;if(R&&typeof R.ownKeys==="function"){ReflectOwnKeys=R.ownKeys}else if(Object.getOwnPropertySymbols){ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target))}}else{ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target)}}function ProcessEmitWarning(warning){if(console&&console.warn)console.warn(warning)}var NumberIsNaN=Number.isNaN||function NumberIsNaN(value){return value!==value};function EventEmitter(){EventEmitter.init.call(this)}module.exports=EventEmitter;module.exports.once=once;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=undefined;var defaultMaxListeners=10;function checkListener(listener){if(typeof listener!=="function"){throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof listener)}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:true,get:function(){return defaultMaxListeners},set:function(arg){if(typeof arg!=="number"||arg<0||NumberIsNaN(arg)){throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+arg+".")}defaultMaxListeners=arg}});EventEmitter.init=function(){if(this._events===undefined||this._events===Object.getPrototypeOf(this)._events){this._events=Object.create(null);this._eventsCount=0}this._maxListeners=this._maxListeners||undefined};EventEmitter.prototype.setMaxListeners=function setMaxListeners(n){if(typeof n!=="number"||n<0||NumberIsNaN(n)){throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".")}this._maxListeners=n;return this};function _getMaxListeners(that){if(that._maxListeners===undefined)return EventEmitter.defaultMaxListeners;return that._maxListeners}EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function emit(type){var args=[];for(var i=1;i0)er=args[0];if(er instanceof Error){throw er}var err=new Error("Unhandled error."+(er?" ("+er.message+")":""));err.context=er;throw err}var handler=events[type];if(handler===undefined)return false;if(typeof handler==="function"){ReflectApply(handler,this,args)}else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i0&&existing.length>m&&!existing.warned){existing.warned=true;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+" "+String(type)+" listeners "+"added. Use emitter.setMaxListeners() to "+"increase limit");w.name="MaxListenersExceededWarning";w.emitter=target;w.type=type;w.count=existing.length;ProcessEmitWarning(w)}}return target}EventEmitter.prototype.addListener=function addListener(type,listener){return _addListener(this,type,listener,false)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function prependListener(type,listener){return _addListener(this,type,listener,true)};function onceWrapper(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;if(arguments.length===0)return this.listener.call(this.target);return this.listener.apply(this.target,arguments)}}function _onceWrap(target,type,listener){var state={fired:false,wrapFn:undefined,target:target,type:type,listener:listener};var wrapped=onceWrapper.bind(state);wrapped.listener=listener;state.wrapFn=wrapped;return wrapped}EventEmitter.prototype.once=function once(type,listener){checkListener(listener);this.on(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.prependOnceListener=function prependOnceListener(type,listener){checkListener(listener);this.prependListener(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.removeListener=function removeListener(type,listener){var list,events,position,i,originalListener;checkListener(listener);events=this._events;if(events===undefined)return this;list=events[type];if(list===undefined)return this;if(list===listener||list.listener===listener){if(--this._eventsCount===0)this._events=Object.create(null);else{delete events[type];if(events.removeListener)this.emit("removeListener",type,list.listener||listener)}}else if(typeof list!=="function"){position=-1;for(i=list.length-1;i>=0;i--){if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener;position=i;break}}if(position<0)return this;if(position===0)list.shift();else{spliceOne(list,position)}if(list.length===1)events[type]=list[0];if(events.removeListener!==undefined)this.emit("removeListener",type,originalListener||listener)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function removeAllListeners(type){var listeners,events,i;events=this._events;if(events===undefined)return this;if(events.removeListener===undefined){if(arguments.length===0){this._events=Object.create(null);this._eventsCount=0}else if(events[type]!==undefined){if(--this._eventsCount===0)this._events=Object.create(null);else delete events[type]}return this}if(arguments.length===0){var keys=Object.keys(events);var key;for(i=0;i=0;i--){this.removeListener(type,listeners[i])}}return this};function _listeners(target,type,unwrap){var events=target._events;if(events===undefined)return[];var evlistener=events[type];if(evlistener===undefined)return[];if(typeof evlistener==="function")return unwrap?[evlistener.listener||evlistener]:[evlistener];return unwrap?unwrapListeners(evlistener):arrayClone(evlistener,evlistener.length)}EventEmitter.prototype.listeners=function listeners(type){return _listeners(this,type,true)};EventEmitter.prototype.rawListeners=function rawListeners(type){return _listeners(this,type,false)};EventEmitter.listenerCount=function(emitter,type){if(typeof emitter.listenerCount==="function"){return emitter.listenerCount(type)}else{return listenerCount.call(emitter,type)}};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(type){var events=this._events;if(events!==undefined){var evlistener=events[type];if(typeof evlistener==="function"){return 1}else if(evlistener!==undefined){return evlistener.length}}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(arr,n){var copy=new Array(n);for(var i=0;i>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],9:[function(require,module,exports){"use strict";function isUtf8(buf){if(!buf){return false}let i=0;const len=buf.length;while(i=194&&buf[i]<=223){if(buf[i+1]>>6===2){i+=2;continue}else{return false}}if((buf[i]===224&&buf[i+1]>=160&&buf[i+1]<=191||buf[i]===237&&buf[i+1]>=128&&buf[i+1]<=159)&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]>=225&&buf[i]<=236||buf[i]>=238&&buf[i]<=239)&&buf[i+1]>>6===2&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]===240&&buf[i+1]>=144&&buf[i+1]<=191||buf[i]>=241&&buf[i]<=243&&buf[i+1]>>6===2||buf[i]===244&&buf[i+1]>=128&&buf[i+1]<=143)&&buf[i+2]>>6===2&&buf[i+3]>>6===2){i+=4;continue}return false}return true}module.exports=isUtf8},{}],10:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i=to){return[]}return new Array(to-from).fill().map(function(_,i){return i+from})}},{key:"hexToInt",value:function hexToInt(hexString){if(hexString===undefined||hexString===null){return hexString}return Number.parseInt(hexString,16)}},{key:"intToHex",value:function intToHex(_int){if(_int===undefined||_int===null){return _int}var hexString=_int.toString(16);return"0x"+hexString}},{key:"messageToBuffer",value:function messageToBuffer(message){var buffer=_buffer.Buffer.from([]);try{if(typeof message==="string"){buffer=_buffer.Buffer.from(message.replace("0x",""),"hex")}else{buffer=_buffer.Buffer.from(message)}}catch(err){console.log("messageToBuffer error: ".concat(err))}return buffer}},{key:"bufferToHex",value:function bufferToHex(buf){return"0x"+_buffer.Buffer.from(buf).toString("hex")}}]);return Utils}();module.exports=Utils},{buffer:6}]},{},[4]); \ No newline at end of file From 2d5bc9e5c96344411d49dab6edd35a33702ebc19 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Tue, 23 Jan 2024 20:29:40 +0300 Subject: [PATCH 17/19] make sure there is id in rpc response --- Safari Shared/Inpage Provider/index.js | 2 +- Safari Shared/SafariWebExtensionHandler.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Safari Shared/Inpage Provider/index.js b/Safari Shared/Inpage Provider/index.js index 49e90202..f9820612 100644 --- a/Safari Shared/Inpage Provider/index.js +++ b/Safari Shared/Inpage Provider/index.js @@ -45,8 +45,8 @@ announceProvider(); window.addEventListener("message", function(event) { if (event.source == window && event.data && event.data.direction == "rpc-back") { - // TODO: check event.data.response is there // TODO: make sure error is delivered as well + console.log("rpc back", event.data.response); provider.sendResponse(event.data.response.id, event.data.response); } else if (event.source == window && event.data && event.data.direction == "from-content-script") { diff --git a/Safari Shared/SafariWebExtensionHandler.swift b/Safari Shared/SafariWebExtensionHandler.swift index 1ec1ea35..4005ba93 100644 --- a/Safari Shared/SafariWebExtensionHandler.swift +++ b/Safari Shared/SafariWebExtensionHandler.swift @@ -23,7 +23,7 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { switch internalSafariRequest.subject { case .rpc: if let body = internalSafariRequest.body, let chainId = internalSafariRequest.chainId { - rpcRequest(chainId: chainId, body: body, context: context) + rpcRequest(id: id, chainId: chainId, body: body, context: context) } else { context.cancelRequest(withError: HandlerError.empty) } @@ -64,7 +64,7 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { } } - private func rpcRequest(chainId: String, body: String, context: NSExtensionContext) { + private func rpcRequest(id: Int, chainId: String, body: String, context: NSExtensionContext) { guard let chainIdNumber = Int(hexString: chainId), let rpcURLString = Nodes.getNode(chainId: chainIdNumber), let url = URL(string: rpcURLString), @@ -80,9 +80,9 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { request.httpBody = httpBody let task = URLSession.shared.dataTask(with: request) { [weak self] data, response, error in - if let data = data, let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] { + if let data = data, var json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] { + if json["id"] == nil { json["id"] = id } self?.respond(with: json, context: context) - // TODO: id is missing when there is an error } else { // TODO: respond with error self?.respond(with: ["yo": "body", "chainId": chainId, "result": "gg"], context: context) From 060a0675192e57e150a26893ed626d6fc398be42 Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Tue, 23 Jan 2024 20:36:11 +0300 Subject: [PATCH 18/19] extension handler can respond to rpc request with an error --- Safari Shared/SafariWebExtensionHandler.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Safari Shared/SafariWebExtensionHandler.swift b/Safari Shared/SafariWebExtensionHandler.swift index 4005ba93..fc8040bc 100644 --- a/Safari Shared/SafariWebExtensionHandler.swift +++ b/Safari Shared/SafariWebExtensionHandler.swift @@ -69,7 +69,7 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { let rpcURLString = Nodes.getNode(chainId: chainIdNumber), let url = URL(string: rpcURLString), let httpBody = body.data(using: .utf8) else { - // TODO: respond with error + respond(with: ["id": id, "error": "something went wrong"], context: context) return } @@ -84,8 +84,7 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { if json["id"] == nil { json["id"] = id } self?.respond(with: json, context: context) } else { - // TODO: respond with error - self?.respond(with: ["yo": "body", "chainId": chainId, "result": "gg"], context: context) + self?.respond(with: ["id": id, "error": "something went wrong"], context: context) } } task.resume() From 483b8cc768b2000076910471ed65c1a4e61848bc Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Tue, 23 Jan 2024 22:02:42 +0300 Subject: [PATCH 19/19] clean up rpc response delivery --- Safari Shared/Inpage Provider/index.js | 5 +---- Safari Shared/Resources/inpage.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Safari Shared/Inpage Provider/index.js b/Safari Shared/Inpage Provider/index.js index f9820612..618863c1 100644 --- a/Safari Shared/Inpage Provider/index.js +++ b/Safari Shared/Inpage Provider/index.js @@ -45,10 +45,7 @@ announceProvider(); window.addEventListener("message", function(event) { if (event.source == window && event.data && event.data.direction == "rpc-back") { - // TODO: make sure error is delivered as well - - console.log("rpc back", event.data.response); - provider.sendResponse(event.data.response.id, event.data.response); + provider.processTokenaryResponse(event.data.response.id, event.data.response); } else if (event.source == window && event.data && event.data.direction == "from-content-script") { const response = event.data.response; const id = event.data.id; diff --git a/Safari Shared/Resources/inpage.js b/Safari Shared/Resources/inpage.js index c2bb3f80..c97052af 100644 --- a/Safari Shared/Resources/inpage.js +++ b/Safari Shared/Resources/inpage.js @@ -1 +1 @@ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i1&&arguments[1]!==undefined?arguments[1]:true;this.idMapping.tryFixId(payload);return new Promise(function(resolve,reject){if(!payload.id){payload.id=_utils["default"].genId()}_this2.callbacks.set(payload.id,function(error,data){setTimeout(function(){if(error){reject(error)}else{resolve(data)}},1)});_this2.wrapResults.set(payload.id,wrapResult);switch(payload.method){case"eth_accounts":case"eth_coinbase":case"net_version":case"eth_chainId":case"eth_sign":case"personal_sign":case"personal_ecRecover":case"eth_signTypedData_v3":case"eth_signTypedData":case"eth_signTypedData_v4":case"eth_sendTransaction":case"eth_requestAccounts":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":case"wallet_requestPermissions":case"wallet_getPermissions":return _this2._processPayload(payload);case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_subscribe":throw new _error["default"](4200,"tiny wallet does not support ".concat(payload.method));default:return _this2.rpc.call(payload)}})}},{key:"_processPayload",value:function _processPayload(payload){if(!this.didGetLatestConfiguration){this.pendingPayloads.push(payload);return}switch(payload.method){case"eth_accounts":return this.sendResponse(payload.id,this.eth_accounts());case"eth_coinbase":return this.sendResponse(payload.id,this.eth_coinbase());case"net_version":return this.sendResponse(payload.id,this.net_version());case"eth_chainId":return this.sendResponse(payload.id,this.eth_chainId());case"eth_sign":return this.eth_sign(payload);case"personal_sign":return this.personal_sign(payload);case"personal_ecRecover":return this.personal_ecRecover(payload);case"eth_signTypedData_v3":return this.eth_signTypedData(payload,false);case"eth_signTypedData":case"eth_signTypedData_v4":return this.eth_signTypedData(payload,true);case"eth_sendTransaction":return this.eth_sendTransaction(payload);case"eth_requestAccounts":if(!this.address){return this.eth_requestAccounts(payload)}else{return this.sendResponse(payload.id,this.eth_accounts())}case"wallet_addEthereumChain":return this.wallet_addEthereumChain(payload);case"wallet_switchEthereumChain":return this.wallet_switchEthereumChain(payload);case"wallet_requestPermissions":case"wallet_getPermissions":var permissions=[{parentCapability:"eth_accounts"}];return this.sendResponse(payload.id,permissions)}}},{key:"emitConnect",value:function emitConnect(chainId){this.emit("connect",{chainId:chainId})}},{key:"eth_accounts",value:function eth_accounts(){return this.address?[this.address]:[]}},{key:"eth_coinbase",value:function eth_coinbase(){return this.address}},{key:"net_version",value:function net_version(){return parseInt(this.chainId,16).toString(10)||null}},{key:"eth_chainId",value:function eth_chainId(){return this.chainId}},{key:"eth_sign",value:function eth_sign(payload){var buffer=_utils["default"].messageToBuffer(payload.params[1]);var hex=_utils["default"].bufferToHex(buffer);if((0,_isutf["default"])(buffer)){this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signMessage",payload.id,{data:hex})}}},{key:"personal_sign",value:function personal_sign(payload){var message=payload.params[0];var buffer=_utils["default"].messageToBuffer(message);if(buffer.length===0){var hex=_utils["default"].bufferToHex(message);this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signPersonalMessage",payload.id,{data:message})}}},{key:"personal_ecRecover",value:function personal_ecRecover(payload){this.postMessage("ecRecover",payload.id,{signature:payload.params[1],message:payload.params[0]})}},{key:"eth_signTypedData",value:function eth_signTypedData(payload,useV4){this.postMessage("signTypedMessage",payload.id,{raw:payload.params[1]})}},{key:"eth_sendTransaction",value:function eth_sendTransaction(payload){this.postMessage("signTransaction",payload.id,payload.params[0])}},{key:"eth_requestAccounts",value:function eth_requestAccounts(payload){this.postMessage("requestAccounts",payload.id,{})}},{key:"wallet_watchAsset",value:function wallet_watchAsset(payload){var options=payload.params.options;this.postMessage("watchAsset",payload.id,{type:payload.type,contract:options.address,symbol:options.symbol,decimals:options.decimals||0})}},{key:"wallet_switchEthereumChain",value:function wallet_switchEthereumChain(payload){if(this.chainId!=payload.params[0].chainId){this.postMessage("switchEthereumChain",payload.id,payload.params[0])}else{this.sendResponse(payload.id,[this.address])}}},{key:"wallet_addEthereumChain",value:function wallet_addEthereumChain(payload){this.postMessage("addEthereumChain",payload.id,payload.params[0])}},{key:"processTokenaryResponse",value:function processTokenaryResponse(id,response){if(response.name=="didLoadLatestConfiguration"){this.didGetLatestConfiguration=true;if(response.chainId){this.updateAccount(response.name,response.results,response.chainId)}var _iterator=_createForOfIteratorHelper(this.pendingPayloads),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var payload=_step.value;this._processPayload(payload)}}catch(err){_iterator.e(err)}finally{_iterator.f()}this.pendingPayloads=[];return}if("result"in response){this.sendResponse(id,response.result)}else if("results"in response){if(response.name=="switchEthereumChain"||response.name=="addEthereumChain"){this.updateAccount(response.name,response.results,response.chainId)}if(response.name!="switchAccount"){this.sendResponse(id,response.results)}if(response.name=="requestAccounts"||response.name=="switchAccount"){this.updateAccount(response.name,response.results,response.chainId)}}else if("error"in response){this.sendError(id,response.error)}}},{key:"postMessage",value:function postMessage(handler,id,data){if(this.ready||handler==="requestAccounts"||handler==="switchEthereumChain"||handler==="addEthereumChain"){var object={object:data,address:this.address,chainId:this.chainId};window.tokenary.postMessage(handler,id,object,"ethereum")}else{this.sendError(id,new _error["default"](4100,"provider is not ready"))}}},{key:"sendResponse",value:function sendResponse(id,result){var originId=this.idMapping.tryPopId(id)||id;var callback=this.callbacks.get(id);var wrapResult=this.wrapResults.get(id);var data={jsonrpc:"2.0",id:originId};if(result!==null&&result.result){data.result=result.result}else{data.result=result}if(callback){wrapResult?callback(null,data):callback(null,data.result);this.callbacks["delete"](id);this.wrapResults["delete"](id)}else{console.log("callback id: ".concat(id," not found"))}}},{key:"sendError",value:function sendError(id,error){console.log("<== ".concat(id," sendError ").concat(error));var callback=this.callbacks.get(id);if(callback){callback(error instanceof Error?error:new Error(error),null);this.callbacks["delete"](id);this.wrapResults["delete"](id)}}}]);return TokenaryEthereum}(_events.EventEmitter);module.exports=TokenaryEthereum},{"./error":1,"./id_mapping":3,"./rpc":10,"./utils":11,events:7,isutf8:9}],3:[function(require,module,exports){"use strict";var _utils=_interopRequireDefault(require("./utils"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;var i;for(i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],6:[function(require,module,exports){(function(Buffer){(function(){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH;Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport();if(!Buffer.TYPED_ARRAY_SUPPORT&&typeof console!=="undefined"&&typeof console.error==="function"){console.error("This browser lacks typed array (Uint8Array) support which is required by "+"`buffer` v5.x. Use `buffer` v4.x if you require old browser support.")}function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42}catch(e){return false}}Object.defineProperty(Buffer.prototype,"parent",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.buffer}});Object.defineProperty(Buffer.prototype,"offset",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.byteOffset}});function createBuffer(length){if(length>K_MAX_LENGTH){throw new RangeError('The value "'+length+'" is invalid for option "size"')}var buf=new Uint8Array(length);buf.__proto__=Buffer.prototype;return buf}function Buffer(arg,encodingOrOffset,length){if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new TypeError('The "string" argument must be of type string. Received type number')}return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}if(typeof Symbol!=="undefined"&&Symbol.species!=null&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true,enumerable:false,writable:false})}Buffer.poolSize=8192;function from(value,encodingOrOffset,length){if(typeof value==="string"){return fromString(value,encodingOrOffset)}if(ArrayBuffer.isView(value)){return fromArrayLike(value)}if(value==null){throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer)){return fromArrayBuffer(value,encodingOrOffset,length)}if(typeof value==="number"){throw new TypeError('The "value" argument must not be of type number. Received type number')}var valueOf=value.valueOf&&value.valueOf();if(valueOf!=null&&valueOf!==value){return Buffer.from(valueOf,encodingOrOffset,length)}var b=fromObject(value);if(b)return b;if(typeof Symbol!=="undefined"&&Symbol.toPrimitive!=null&&typeof value[Symbol.toPrimitive]==="function"){return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)};Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be of type number')}else if(size<0){throw new RangeError('The value "'+size+'" is invalid for option "size"')}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill)}return createBuffer(size)}Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding)};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0)}Buffer.allocUnsafe=function(size){return allocUnsafe(size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)};function fromString(string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}var length=byteLength(string,encoding)|0;var buf=createBuffer(length);var actual=buf.write(string,encoding);if(actual!==length){buf=buf.slice(0,actual)}return buf}function fromArrayLike(array){var length=array.length<0?0:checked(array.length)|0;var buf=createBuffer(length);for(var i=0;i=K_MAX_LENGTH){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+K_MAX_LENGTH.toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true&&b!==Buffer.prototype};Buffer.compare=function compare(a,b){if(isInstance(a,Uint8Array))a=Buffer.from(a,a.offset,a.byteLength);if(isInstance(b,Uint8Array))b=Buffer.from(b,b.offset,b.byteLength);if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array')}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i2&&arguments[2]===true;if(!mustMatch&&len===0)return 0;var loweredCase=false;for(;;){switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return len*2;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase){return mustMatch?-1:utf8ToBytes(string).length}encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;imax)str+=" ... ";return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)){target=Buffer.from(target,target.offset,target.byteLength)}if(!Buffer.isBuffer(target)){throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. '+"Received type "+typeof target)}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(numberIsNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(length>strLen/2){length=strLen/2}for(var i=0;i>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);this[offset]=value&255;return offset+1};Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255;return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}if(val.length===1){var code=val.charCodeAt(0);if(encoding==="utf8"&&code<128||encoding==="latin1"){val=code}}}else if(typeof val==="number"){val=val&255}if(start<0||this.length>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isInstance(obj,type){return obj instanceof type||obj!=null&&obj.constructor!=null&&obj.constructor.name!=null&&obj.constructor.name===type.name}function numberIsNaN(obj){return obj!==obj}}).call(this)}).call(this,require("buffer").Buffer)},{"base64-js":5,buffer:6,ieee754:8}],7:[function(require,module,exports){"use strict";var R=typeof Reflect==="object"?Reflect:null;var ReflectApply=R&&typeof R.apply==="function"?R.apply:function ReflectApply(target,receiver,args){return Function.prototype.apply.call(target,receiver,args)};var ReflectOwnKeys;if(R&&typeof R.ownKeys==="function"){ReflectOwnKeys=R.ownKeys}else if(Object.getOwnPropertySymbols){ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target))}}else{ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target)}}function ProcessEmitWarning(warning){if(console&&console.warn)console.warn(warning)}var NumberIsNaN=Number.isNaN||function NumberIsNaN(value){return value!==value};function EventEmitter(){EventEmitter.init.call(this)}module.exports=EventEmitter;module.exports.once=once;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=undefined;var defaultMaxListeners=10;function checkListener(listener){if(typeof listener!=="function"){throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof listener)}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:true,get:function(){return defaultMaxListeners},set:function(arg){if(typeof arg!=="number"||arg<0||NumberIsNaN(arg)){throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+arg+".")}defaultMaxListeners=arg}});EventEmitter.init=function(){if(this._events===undefined||this._events===Object.getPrototypeOf(this)._events){this._events=Object.create(null);this._eventsCount=0}this._maxListeners=this._maxListeners||undefined};EventEmitter.prototype.setMaxListeners=function setMaxListeners(n){if(typeof n!=="number"||n<0||NumberIsNaN(n)){throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".")}this._maxListeners=n;return this};function _getMaxListeners(that){if(that._maxListeners===undefined)return EventEmitter.defaultMaxListeners;return that._maxListeners}EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function emit(type){var args=[];for(var i=1;i0)er=args[0];if(er instanceof Error){throw er}var err=new Error("Unhandled error."+(er?" ("+er.message+")":""));err.context=er;throw err}var handler=events[type];if(handler===undefined)return false;if(typeof handler==="function"){ReflectApply(handler,this,args)}else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i0&&existing.length>m&&!existing.warned){existing.warned=true;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+" "+String(type)+" listeners "+"added. Use emitter.setMaxListeners() to "+"increase limit");w.name="MaxListenersExceededWarning";w.emitter=target;w.type=type;w.count=existing.length;ProcessEmitWarning(w)}}return target}EventEmitter.prototype.addListener=function addListener(type,listener){return _addListener(this,type,listener,false)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function prependListener(type,listener){return _addListener(this,type,listener,true)};function onceWrapper(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;if(arguments.length===0)return this.listener.call(this.target);return this.listener.apply(this.target,arguments)}}function _onceWrap(target,type,listener){var state={fired:false,wrapFn:undefined,target:target,type:type,listener:listener};var wrapped=onceWrapper.bind(state);wrapped.listener=listener;state.wrapFn=wrapped;return wrapped}EventEmitter.prototype.once=function once(type,listener){checkListener(listener);this.on(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.prependOnceListener=function prependOnceListener(type,listener){checkListener(listener);this.prependListener(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.removeListener=function removeListener(type,listener){var list,events,position,i,originalListener;checkListener(listener);events=this._events;if(events===undefined)return this;list=events[type];if(list===undefined)return this;if(list===listener||list.listener===listener){if(--this._eventsCount===0)this._events=Object.create(null);else{delete events[type];if(events.removeListener)this.emit("removeListener",type,list.listener||listener)}}else if(typeof list!=="function"){position=-1;for(i=list.length-1;i>=0;i--){if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener;position=i;break}}if(position<0)return this;if(position===0)list.shift();else{spliceOne(list,position)}if(list.length===1)events[type]=list[0];if(events.removeListener!==undefined)this.emit("removeListener",type,originalListener||listener)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function removeAllListeners(type){var listeners,events,i;events=this._events;if(events===undefined)return this;if(events.removeListener===undefined){if(arguments.length===0){this._events=Object.create(null);this._eventsCount=0}else if(events[type]!==undefined){if(--this._eventsCount===0)this._events=Object.create(null);else delete events[type]}return this}if(arguments.length===0){var keys=Object.keys(events);var key;for(i=0;i=0;i--){this.removeListener(type,listeners[i])}}return this};function _listeners(target,type,unwrap){var events=target._events;if(events===undefined)return[];var evlistener=events[type];if(evlistener===undefined)return[];if(typeof evlistener==="function")return unwrap?[evlistener.listener||evlistener]:[evlistener];return unwrap?unwrapListeners(evlistener):arrayClone(evlistener,evlistener.length)}EventEmitter.prototype.listeners=function listeners(type){return _listeners(this,type,true)};EventEmitter.prototype.rawListeners=function rawListeners(type){return _listeners(this,type,false)};EventEmitter.listenerCount=function(emitter,type){if(typeof emitter.listenerCount==="function"){return emitter.listenerCount(type)}else{return listenerCount.call(emitter,type)}};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(type){var events=this._events;if(events!==undefined){var evlistener=events[type];if(typeof evlistener==="function"){return 1}else if(evlistener!==undefined){return evlistener.length}}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(arr,n){var copy=new Array(n);for(var i=0;i>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],9:[function(require,module,exports){"use strict";function isUtf8(buf){if(!buf){return false}let i=0;const len=buf.length;while(i=194&&buf[i]<=223){if(buf[i+1]>>6===2){i+=2;continue}else{return false}}if((buf[i]===224&&buf[i+1]>=160&&buf[i+1]<=191||buf[i]===237&&buf[i+1]>=128&&buf[i+1]<=159)&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]>=225&&buf[i]<=236||buf[i]>=238&&buf[i]<=239)&&buf[i+1]>>6===2&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]===240&&buf[i+1]>=144&&buf[i+1]<=191||buf[i]>=241&&buf[i]<=243&&buf[i+1]>>6===2||buf[i]===244&&buf[i+1]>=128&&buf[i+1]<=143)&&buf[i+2]>>6===2&&buf[i+3]>>6===2){i+=4;continue}return false}return true}module.exports=isUtf8},{}],10:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i=to){return[]}return new Array(to-from).fill().map(function(_,i){return i+from})}},{key:"hexToInt",value:function hexToInt(hexString){if(hexString===undefined||hexString===null){return hexString}return Number.parseInt(hexString,16)}},{key:"intToHex",value:function intToHex(_int){if(_int===undefined||_int===null){return _int}var hexString=_int.toString(16);return"0x"+hexString}},{key:"messageToBuffer",value:function messageToBuffer(message){var buffer=_buffer.Buffer.from([]);try{if(typeof message==="string"){buffer=_buffer.Buffer.from(message.replace("0x",""),"hex")}else{buffer=_buffer.Buffer.from(message)}}catch(err){console.log("messageToBuffer error: ".concat(err))}return buffer}},{key:"bufferToHex",value:function bufferToHex(buf){return"0x"+_buffer.Buffer.from(buf).toString("hex")}}]);return Utils}();module.exports=Utils},{buffer:6}]},{},[4]); \ No newline at end of file +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i1&&arguments[1]!==undefined?arguments[1]:true;this.idMapping.tryFixId(payload);return new Promise(function(resolve,reject){if(!payload.id){payload.id=_utils["default"].genId()}_this2.callbacks.set(payload.id,function(error,data){setTimeout(function(){if(error){reject(error)}else{resolve(data)}},1)});_this2.wrapResults.set(payload.id,wrapResult);switch(payload.method){case"eth_accounts":case"eth_coinbase":case"net_version":case"eth_chainId":case"eth_sign":case"personal_sign":case"personal_ecRecover":case"eth_signTypedData_v3":case"eth_signTypedData":case"eth_signTypedData_v4":case"eth_sendTransaction":case"eth_requestAccounts":case"wallet_addEthereumChain":case"wallet_switchEthereumChain":case"wallet_requestPermissions":case"wallet_getPermissions":return _this2._processPayload(payload);case"eth_newFilter":case"eth_newBlockFilter":case"eth_newPendingTransactionFilter":case"eth_uninstallFilter":case"eth_subscribe":throw new _error["default"](4200,"tiny wallet does not support ".concat(payload.method));default:return _this2.rpc.call(payload)}})}},{key:"_processPayload",value:function _processPayload(payload){if(!this.didGetLatestConfiguration){this.pendingPayloads.push(payload);return}switch(payload.method){case"eth_accounts":return this.sendResponse(payload.id,this.eth_accounts());case"eth_coinbase":return this.sendResponse(payload.id,this.eth_coinbase());case"net_version":return this.sendResponse(payload.id,this.net_version());case"eth_chainId":return this.sendResponse(payload.id,this.eth_chainId());case"eth_sign":return this.eth_sign(payload);case"personal_sign":return this.personal_sign(payload);case"personal_ecRecover":return this.personal_ecRecover(payload);case"eth_signTypedData_v3":return this.eth_signTypedData(payload,false);case"eth_signTypedData":case"eth_signTypedData_v4":return this.eth_signTypedData(payload,true);case"eth_sendTransaction":return this.eth_sendTransaction(payload);case"eth_requestAccounts":if(!this.address){return this.eth_requestAccounts(payload)}else{return this.sendResponse(payload.id,this.eth_accounts())}case"wallet_addEthereumChain":return this.wallet_addEthereumChain(payload);case"wallet_switchEthereumChain":return this.wallet_switchEthereumChain(payload);case"wallet_requestPermissions":case"wallet_getPermissions":var permissions=[{parentCapability:"eth_accounts"}];return this.sendResponse(payload.id,permissions)}}},{key:"emitConnect",value:function emitConnect(chainId){this.emit("connect",{chainId:chainId})}},{key:"eth_accounts",value:function eth_accounts(){return this.address?[this.address]:[]}},{key:"eth_coinbase",value:function eth_coinbase(){return this.address}},{key:"net_version",value:function net_version(){return parseInt(this.chainId,16).toString(10)||null}},{key:"eth_chainId",value:function eth_chainId(){return this.chainId}},{key:"eth_sign",value:function eth_sign(payload){var buffer=_utils["default"].messageToBuffer(payload.params[1]);var hex=_utils["default"].bufferToHex(buffer);if((0,_isutf["default"])(buffer)){this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signMessage",payload.id,{data:hex})}}},{key:"personal_sign",value:function personal_sign(payload){var message=payload.params[0];var buffer=_utils["default"].messageToBuffer(message);if(buffer.length===0){var hex=_utils["default"].bufferToHex(message);this.postMessage("signPersonalMessage",payload.id,{data:hex})}else{this.postMessage("signPersonalMessage",payload.id,{data:message})}}},{key:"personal_ecRecover",value:function personal_ecRecover(payload){this.postMessage("ecRecover",payload.id,{signature:payload.params[1],message:payload.params[0]})}},{key:"eth_signTypedData",value:function eth_signTypedData(payload,useV4){this.postMessage("signTypedMessage",payload.id,{raw:payload.params[1]})}},{key:"eth_sendTransaction",value:function eth_sendTransaction(payload){this.postMessage("signTransaction",payload.id,payload.params[0])}},{key:"eth_requestAccounts",value:function eth_requestAccounts(payload){this.postMessage("requestAccounts",payload.id,{})}},{key:"wallet_watchAsset",value:function wallet_watchAsset(payload){var options=payload.params.options;this.postMessage("watchAsset",payload.id,{type:payload.type,contract:options.address,symbol:options.symbol,decimals:options.decimals||0})}},{key:"wallet_switchEthereumChain",value:function wallet_switchEthereumChain(payload){if(this.chainId!=payload.params[0].chainId){this.postMessage("switchEthereumChain",payload.id,payload.params[0])}else{this.sendResponse(payload.id,[this.address])}}},{key:"wallet_addEthereumChain",value:function wallet_addEthereumChain(payload){this.postMessage("addEthereumChain",payload.id,payload.params[0])}},{key:"processTokenaryResponse",value:function processTokenaryResponse(id,response){if(response.name=="didLoadLatestConfiguration"){this.didGetLatestConfiguration=true;if(response.chainId){this.updateAccount(response.name,response.results,response.chainId)}var _iterator=_createForOfIteratorHelper(this.pendingPayloads),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var payload=_step.value;this._processPayload(payload)}}catch(err){_iterator.e(err)}finally{_iterator.f()}this.pendingPayloads=[];return}if("result"in response){this.sendResponse(id,response.result)}else if("results"in response){if(response.name=="switchEthereumChain"||response.name=="addEthereumChain"){this.updateAccount(response.name,response.results,response.chainId)}if(response.name!="switchAccount"){this.sendResponse(id,response.results)}if(response.name=="requestAccounts"||response.name=="switchAccount"){this.updateAccount(response.name,response.results,response.chainId)}}else if("error"in response){this.sendError(id,response.error)}}},{key:"postMessage",value:function postMessage(handler,id,data){if(this.ready||handler==="requestAccounts"||handler==="switchEthereumChain"||handler==="addEthereumChain"){var object={object:data,address:this.address,chainId:this.chainId};window.tokenary.postMessage(handler,id,object,"ethereum")}else{this.sendError(id,new _error["default"](4100,"provider is not ready"))}}},{key:"sendResponse",value:function sendResponse(id,result){var originId=this.idMapping.tryPopId(id)||id;var callback=this.callbacks.get(id);var wrapResult=this.wrapResults.get(id);var data={jsonrpc:"2.0",id:originId};if(result!==null&&result.result){data.result=result.result}else{data.result=result}if(callback){wrapResult?callback(null,data):callback(null,data.result);this.callbacks["delete"](id);this.wrapResults["delete"](id)}else{console.log("callback id: ".concat(id," not found"))}}},{key:"sendError",value:function sendError(id,error){console.log("<== ".concat(id," sendError ").concat(error));var callback=this.callbacks.get(id);if(callback){callback(error instanceof Error?error:new Error(error),null);this.callbacks["delete"](id);this.wrapResults["delete"](id)}}}]);return TokenaryEthereum}(_events.EventEmitter);module.exports=TokenaryEthereum},{"./error":1,"./id_mapping":3,"./rpc":10,"./utils":11,events:7,isutf8:9}],3:[function(require,module,exports){"use strict";var _utils=_interopRequireDefault(require("./utils"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;var i;for(i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],6:[function(require,module,exports){(function(Buffer){(function(){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;exports.kMaxLength=K_MAX_LENGTH;Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport();if(!Buffer.TYPED_ARRAY_SUPPORT&&typeof console!=="undefined"&&typeof console.error==="function"){console.error("This browser lacks typed array (Uint8Array) support which is required by "+"`buffer` v5.x. Use `buffer` v4.x if you require old browser support.")}function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42}catch(e){return false}}Object.defineProperty(Buffer.prototype,"parent",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.buffer}});Object.defineProperty(Buffer.prototype,"offset",{enumerable:true,get:function(){if(!Buffer.isBuffer(this))return undefined;return this.byteOffset}});function createBuffer(length){if(length>K_MAX_LENGTH){throw new RangeError('The value "'+length+'" is invalid for option "size"')}var buf=new Uint8Array(length);buf.__proto__=Buffer.prototype;return buf}function Buffer(arg,encodingOrOffset,length){if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new TypeError('The "string" argument must be of type string. Received type number')}return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}if(typeof Symbol!=="undefined"&&Symbol.species!=null&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true,enumerable:false,writable:false})}Buffer.poolSize=8192;function from(value,encodingOrOffset,length){if(typeof value==="string"){return fromString(value,encodingOrOffset)}if(ArrayBuffer.isView(value)){return fromArrayLike(value)}if(value==null){throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer)){return fromArrayBuffer(value,encodingOrOffset,length)}if(typeof value==="number"){throw new TypeError('The "value" argument must not be of type number. Received type number')}var valueOf=value.valueOf&&value.valueOf();if(valueOf!=null&&valueOf!==value){return Buffer.from(valueOf,encodingOrOffset,length)}var b=fromObject(value);if(b)return b;if(typeof Symbol!=="undefined"&&Symbol.toPrimitive!=null&&typeof value[Symbol.toPrimitive]==="function"){return Buffer.from(value[Symbol.toPrimitive]("string"),encodingOrOffset,length)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, "+"or Array-like Object. Received type "+typeof value)}Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)};Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be of type number')}else if(size<0){throw new RangeError('The value "'+size+'" is invalid for option "size"')}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill)}return createBuffer(size)}Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding)};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0)}Buffer.allocUnsafe=function(size){return allocUnsafe(size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)};function fromString(string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}var length=byteLength(string,encoding)|0;var buf=createBuffer(length);var actual=buf.write(string,encoding);if(actual!==length){buf=buf.slice(0,actual)}return buf}function fromArrayLike(array){var length=array.length<0?0:checked(array.length)|0;var buf=createBuffer(length);for(var i=0;i=K_MAX_LENGTH){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+K_MAX_LENGTH.toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true&&b!==Buffer.prototype};Buffer.compare=function compare(a,b){if(isInstance(a,Uint8Array))a=Buffer.from(a,a.offset,a.byteLength);if(isInstance(b,Uint8Array))b=Buffer.from(b,b.offset,b.byteLength);if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array')}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i2&&arguments[2]===true;if(!mustMatch&&len===0)return 0;var loweredCase=false;for(;;){switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return len*2;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase){return mustMatch?-1:utf8ToBytes(string).length}encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;imax)str+=" ... ";return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)){target=Buffer.from(target,target.offset,target.byteLength)}if(!Buffer.isBuffer(target)){throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. '+"Received type "+typeof target)}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(numberIsNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(length>strLen/2){length=strLen/2}for(var i=0;i>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);this[offset]=value&255;return offset+1};Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255;return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}if(val.length===1){var code=val.charCodeAt(0);if(encoding==="utf8"&&code<128||encoding==="latin1"){val=code}}}else if(typeof val==="number"){val=val&255}if(start<0||this.length>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isInstance(obj,type){return obj instanceof type||obj!=null&&obj.constructor!=null&&obj.constructor.name!=null&&obj.constructor.name===type.name}function numberIsNaN(obj){return obj!==obj}}).call(this)}).call(this,require("buffer").Buffer)},{"base64-js":5,buffer:6,ieee754:8}],7:[function(require,module,exports){"use strict";var R=typeof Reflect==="object"?Reflect:null;var ReflectApply=R&&typeof R.apply==="function"?R.apply:function ReflectApply(target,receiver,args){return Function.prototype.apply.call(target,receiver,args)};var ReflectOwnKeys;if(R&&typeof R.ownKeys==="function"){ReflectOwnKeys=R.ownKeys}else if(Object.getOwnPropertySymbols){ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target))}}else{ReflectOwnKeys=function ReflectOwnKeys(target){return Object.getOwnPropertyNames(target)}}function ProcessEmitWarning(warning){if(console&&console.warn)console.warn(warning)}var NumberIsNaN=Number.isNaN||function NumberIsNaN(value){return value!==value};function EventEmitter(){EventEmitter.init.call(this)}module.exports=EventEmitter;module.exports.once=once;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._eventsCount=0;EventEmitter.prototype._maxListeners=undefined;var defaultMaxListeners=10;function checkListener(listener){if(typeof listener!=="function"){throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof listener)}}Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:true,get:function(){return defaultMaxListeners},set:function(arg){if(typeof arg!=="number"||arg<0||NumberIsNaN(arg)){throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+arg+".")}defaultMaxListeners=arg}});EventEmitter.init=function(){if(this._events===undefined||this._events===Object.getPrototypeOf(this)._events){this._events=Object.create(null);this._eventsCount=0}this._maxListeners=this._maxListeners||undefined};EventEmitter.prototype.setMaxListeners=function setMaxListeners(n){if(typeof n!=="number"||n<0||NumberIsNaN(n)){throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".")}this._maxListeners=n;return this};function _getMaxListeners(that){if(that._maxListeners===undefined)return EventEmitter.defaultMaxListeners;return that._maxListeners}EventEmitter.prototype.getMaxListeners=function getMaxListeners(){return _getMaxListeners(this)};EventEmitter.prototype.emit=function emit(type){var args=[];for(var i=1;i0)er=args[0];if(er instanceof Error){throw er}var err=new Error("Unhandled error."+(er?" ("+er.message+")":""));err.context=er;throw err}var handler=events[type];if(handler===undefined)return false;if(typeof handler==="function"){ReflectApply(handler,this,args)}else{var len=handler.length;var listeners=arrayClone(handler,len);for(var i=0;i0&&existing.length>m&&!existing.warned){existing.warned=true;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+" "+String(type)+" listeners "+"added. Use emitter.setMaxListeners() to "+"increase limit");w.name="MaxListenersExceededWarning";w.emitter=target;w.type=type;w.count=existing.length;ProcessEmitWarning(w)}}return target}EventEmitter.prototype.addListener=function addListener(type,listener){return _addListener(this,type,listener,false)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function prependListener(type,listener){return _addListener(this,type,listener,true)};function onceWrapper(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;if(arguments.length===0)return this.listener.call(this.target);return this.listener.apply(this.target,arguments)}}function _onceWrap(target,type,listener){var state={fired:false,wrapFn:undefined,target:target,type:type,listener:listener};var wrapped=onceWrapper.bind(state);wrapped.listener=listener;state.wrapFn=wrapped;return wrapped}EventEmitter.prototype.once=function once(type,listener){checkListener(listener);this.on(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.prependOnceListener=function prependOnceListener(type,listener){checkListener(listener);this.prependListener(type,_onceWrap(this,type,listener));return this};EventEmitter.prototype.removeListener=function removeListener(type,listener){var list,events,position,i,originalListener;checkListener(listener);events=this._events;if(events===undefined)return this;list=events[type];if(list===undefined)return this;if(list===listener||list.listener===listener){if(--this._eventsCount===0)this._events=Object.create(null);else{delete events[type];if(events.removeListener)this.emit("removeListener",type,list.listener||listener)}}else if(typeof list!=="function"){position=-1;for(i=list.length-1;i>=0;i--){if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener;position=i;break}}if(position<0)return this;if(position===0)list.shift();else{spliceOne(list,position)}if(list.length===1)events[type]=list[0];if(events.removeListener!==undefined)this.emit("removeListener",type,originalListener||listener)}return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.removeAllListeners=function removeAllListeners(type){var listeners,events,i;events=this._events;if(events===undefined)return this;if(events.removeListener===undefined){if(arguments.length===0){this._events=Object.create(null);this._eventsCount=0}else if(events[type]!==undefined){if(--this._eventsCount===0)this._events=Object.create(null);else delete events[type]}return this}if(arguments.length===0){var keys=Object.keys(events);var key;for(i=0;i=0;i--){this.removeListener(type,listeners[i])}}return this};function _listeners(target,type,unwrap){var events=target._events;if(events===undefined)return[];var evlistener=events[type];if(evlistener===undefined)return[];if(typeof evlistener==="function")return unwrap?[evlistener.listener||evlistener]:[evlistener];return unwrap?unwrapListeners(evlistener):arrayClone(evlistener,evlistener.length)}EventEmitter.prototype.listeners=function listeners(type){return _listeners(this,type,true)};EventEmitter.prototype.rawListeners=function rawListeners(type){return _listeners(this,type,false)};EventEmitter.listenerCount=function(emitter,type){if(typeof emitter.listenerCount==="function"){return emitter.listenerCount(type)}else{return listenerCount.call(emitter,type)}};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(type){var events=this._events;if(events!==undefined){var evlistener=events[type];if(typeof evlistener==="function"){return 1}else if(evlistener!==undefined){return evlistener.length}}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(arr,n){var copy=new Array(n);for(var i=0;i>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],9:[function(require,module,exports){"use strict";function isUtf8(buf){if(!buf){return false}let i=0;const len=buf.length;while(i=194&&buf[i]<=223){if(buf[i+1]>>6===2){i+=2;continue}else{return false}}if((buf[i]===224&&buf[i+1]>=160&&buf[i+1]<=191||buf[i]===237&&buf[i+1]>=128&&buf[i+1]<=159)&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]>=225&&buf[i]<=236||buf[i]>=238&&buf[i]<=239)&&buf[i+1]>>6===2&&buf[i+2]>>6===2){i+=3;continue}if((buf[i]===240&&buf[i+1]>=144&&buf[i+1]<=191||buf[i]>=241&&buf[i]<=243&&buf[i+1]>>6===2||buf[i]===244&&buf[i+1]>=128&&buf[i+1]<=143)&&buf[i+2]>>6===2&&buf[i+3]>>6===2){i+=4;continue}return false}return true}module.exports=isUtf8},{}],10:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i=to){return[]}return new Array(to-from).fill().map(function(_,i){return i+from})}},{key:"hexToInt",value:function hexToInt(hexString){if(hexString===undefined||hexString===null){return hexString}return Number.parseInt(hexString,16)}},{key:"intToHex",value:function intToHex(_int){if(_int===undefined||_int===null){return _int}var hexString=_int.toString(16);return"0x"+hexString}},{key:"messageToBuffer",value:function messageToBuffer(message){var buffer=_buffer.Buffer.from([]);try{if(typeof message==="string"){buffer=_buffer.Buffer.from(message.replace("0x",""),"hex")}else{buffer=_buffer.Buffer.from(message)}}catch(err){console.log("messageToBuffer error: ".concat(err))}return buffer}},{key:"bufferToHex",value:function bufferToHex(buf){return"0x"+_buffer.Buffer.from(buf).toString("hex")}}]);return Utils}();module.exports=Utils},{buffer:6}]},{},[4]); \ No newline at end of file