-
Notifications
You must be signed in to change notification settings - Fork 0
/
37.f609de513abc93d6b47a.js
1 lines (1 loc) · 14.9 KB
/
37.f609de513abc93d6b47a.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[37],{"1BiQ":function(e,t,n){"use strict";n.r(t),(function(e){n.d(t,"default",function(){return u});var r=n("1c9+"),o=n("9oXm"),i=n("vULT"),s=n("qPxQ");const a=e=>e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");let c=[];class u extends o.a{static async open(e,t=5e3){return new u}constructor(){super(),this.scrambleKey=void 0,this.unwrap=!0,c.push(this)}async exchange(t){try{return await function(t,n,o,s){const c=function(t,n){const r=e.alloc(t.length);for(let e=0;e<t.length;e++)r[e]=t[e]^n[e%n.length];return r}(t,o),u=e.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),d={version:"U2F_V2",keyHandle:a(c.toString("base64")),challenge:a(u.toString("base64")),appId:location.origin};return Object(i.a)("apdu","=> "+t.toString("hex")),Object(r.sign)(d,n/1e3).then(t=>{const{signatureData:n}=t;if("string"==typeof n){const t=e.from((r=n).replace(/-/g,"+").replace(/_/g,"/")+"==".substring(0,3*r.length%4),"base64");let o;return o=s?t.slice(5):t,Object(i.a)("apdu","<= "+o.toString("hex")),o}throw t;var r})}(t,this.exchangeTimeout,this.scrambleKey,this.unwrap)}catch(n){throw"object"==typeof n.metaData?(5===n.metaData.code&&(c.forEach(e=>e.emit("disconnect")),c=[]),function(e,t,n){const r=new s.b(t,n);return r.originalError=e,r}(n,"Failed to sign with Ledger device: U2F "+n.metaData.type,"U2F_"+n.metaData.code)):n}}setScrambleKey(t){this.scrambleKey=e.from(t,"ascii")}setUnwrap(e){this.unwrap=e}close(){return Promise.resolve()}}u.isSupported=r.isSupported,u.list=()=>Object(r.isSupported)().then(e=>e?[null]:[]),u.listen=e=>{let t=!1;return Object(r.isSupported)().then(n=>{t||(n?(e.next({type:"add",descriptor:null}),e.complete()):e.error(new s.b("U2F browser support is needed for Ledger. Please use Chrome, Opera or Firefox with a U2F extension. Also make sure you're on an HTTPS connection","U2FNotSupported")))}),{unsubscribe:()=>{t=!0}}}}).call(this,n("tjlA").Buffer)},"1c9+":function(e,t,n){"use strict";e.exports=n("d5mW")},"9oXm":function(e,t,n){"use strict";(function(e){n.d(t,"a",function(){return s});var r=n("+qE3"),o=n.n(r),i=n("qPxQ");class s{constructor(){this.exchangeTimeout=3e4,this.unresponsiveTimeout=15e3,this.deviceModel=null,this._events=new o.a,this.send=async(t,n,r,o,s=e.alloc(0),a=[i.a.OK])=>{if(s.length>=256)throw new i.b("data.length exceed 256 bytes limit. Got: "+s.length,"DataLengthTooBig");const c=await this.exchange(e.concat([e.from([t,n,r,o]),e.from([s.length]),s])),u=c.readUInt16BE(c.length-2);if(!a.some(e=>e===u))throw new i.d(u);return c},this.exchangeBusyPromise=void 0,this.exchangeAtomicImpl=async e=>{if(this.exchangeBusyPromise)throw new i.c("An action was already pending on the Ledger device. Please deny or reconnect.");let t;const n=new Promise(e=>{t=e});this.exchangeBusyPromise=n;let r=!1;const o=setTimeout(()=>{r=!0,this.emit("unresponsive")},this.unresponsiveTimeout);try{const n=await e();return r&&this.emit("responsive"),n}finally{clearTimeout(o),t&&t(),this.exchangeBusyPromise=null}},this._appAPIlock=null}exchange(e){throw new Error("exchange not implemented")}setScrambleKey(e){}close(){return Promise.resolve()}on(e,t){this._events.on(e,t)}off(e,t){this._events.removeListener(e,t)}emit(e,...t){this._events.emit(e,...t)}setDebugMode(){console.warn("setDebugMode is deprecated. use @ledgerhq/logs instead. No logs are emitted in this anymore.")}setExchangeTimeout(e){this.exchangeTimeout=e}setExchangeUnresponsiveTimeout(e){this.unresponsiveTimeout=e}static create(e=3e3,t){return new Promise((n,r)=>{let o=!1;const s=this.listen({next:t=>{o=!0,s&&s.unsubscribe(),a&&clearTimeout(a),this.open(t.descriptor,e).then(n,r)},error:e=>{a&&clearTimeout(a),r(e)},complete:()=>{a&&clearTimeout(a),o||r(new i.b(this.ErrorMessage_NoDeviceFound,"NoDeviceFound"))}}),a=t?setTimeout(()=>{s.unsubscribe(),r(new i.b(this.ErrorMessage_ListenTimeout,"ListenTimeout"))},t):null})}decorateAppAPIMethods(e,t,n){for(let r of t)e[r]=this.decorateAppAPIMethod(r,e[r],e,n)}decorateAppAPIMethod(e,t,n,r){return async(...o)=>{const{_appAPIlock:s}=this;if(s)return Promise.reject(new i.b("Ledger Device is busy (lock "+s+")","TransportLocked"));try{return this._appAPIlock=e,this.setScrambleKey(r),await t.apply(n,o)}finally{this._appAPIlock=null}}}}s.isSupported=void 0,s.list=void 0,s.listen=void 0,s.open=void 0,s.ErrorMessage_ListenTimeout="No Ledger device found (timeout)",s.ErrorMessage_NoDeviceFound="No Ledger device found"}).call(this,n("tjlA").Buffer)},adUY:function(e,t,n){"use strict";var r=r||{};e.exports=r,r.EXTENSION_ID="kmendfapggjehodndflmmgagdbamhnfd",r.MessageTypes={U2F_REGISTER_REQUEST:"u2f_register_request",U2F_SIGN_REQUEST:"u2f_sign_request",U2F_REGISTER_RESPONSE:"u2f_register_response",U2F_SIGN_RESPONSE:"u2f_sign_response"},r.ErrorCodes={OK:0,OTHER_ERROR:1,BAD_REQUEST:2,CONFIGURATION_UNSUPPORTED:3,DEVICE_INELIGIBLE:4,TIMEOUT:5},r.disconnect=function(){r.port_&&r.port_.port_&&(r.port_.port_.disconnect(),r.port_=null)},r.getMessagePort=function(e){"undefined"!=typeof chrome&&chrome.runtime?chrome.runtime.sendMessage(r.EXTENSION_ID,{type:r.MessageTypes.U2F_SIGN_REQUEST,signRequests:[]},function(){chrome.runtime.lastError?r.getIframePort_(e):r.getChromeRuntimePort_(e)}):r.getIframePort_(e)},r.getChromeRuntimePort_=function(e){var t=chrome.runtime.connect(r.EXTENSION_ID,{includeTlsChannelId:!0});setTimeout(function(){e(null,new r.WrappedChromeRuntimePort_(t))},0)},r.WrappedChromeRuntimePort_=function(e){this.port_=e},r.WrappedChromeRuntimePort_.prototype.postMessage=function(e){this.port_.postMessage(e)},r.WrappedChromeRuntimePort_.prototype.addEventListener=function(e,t){var n=e.toLowerCase();"message"==n||"onmessage"==n?this.port_.onMessage.addListener(function(e){t({data:e})}):console.error("WrappedChromeRuntimePort only supports onMessage")},r.getIframePort_=function(e){var t="chrome-extension://"+r.EXTENSION_ID,n=document.createElement("iframe");n.src=t+"/u2f-comms.html",n.setAttribute("style","display:none"),document.body.appendChild(n);var o=!1,i=new MessageChannel,s=function(t){"ready"==t.data?(i.port1.removeEventListener("message",s),o||(o=!0,e(null,i.port1))):console.error('First event on iframe port was not "ready"')};i.port1.addEventListener("message",s),i.port1.start(),n.addEventListener("load",function(){n.contentWindow.postMessage("init",t,[i.port2])}),setTimeout(function(){o||(o=!0,e(new Error("IFrame extension not supported")))},200)},r.EXTENSION_TIMEOUT_SEC=30,r.port_=null,r.waitingForPort_=[],r.reqCounter_=0,r.callbackMap_={},r.getPortSingleton_=function(e){r.port_?e(null,r.port_):(0==r.waitingForPort_.length&&r.getMessagePort(function(e,t){for(e||(r.port_=t,r.port_.addEventListener("message",r.responseHandler_));r.waitingForPort_.length;)r.waitingForPort_.shift()(e,t)}),r.waitingForPort_.push(e))},r.responseHandler_=function(e){var t=e.data,n=t.requestId;if(n&&r.callbackMap_[n]){var o=r.callbackMap_[n];delete r.callbackMap_[n],o(null,t.responseData)}else console.error("Unknown or missing requestId in response.")},r.isSupported=function(e){r.getPortSingleton_(function(t,n){e(!t)})},r.sign=function(e,t,n){r.getPortSingleton_(function(o,i){if(o)return t(o);var s=++r.reqCounter_;r.callbackMap_[s]=t,i.postMessage({type:r.MessageTypes.U2F_SIGN_REQUEST,signRequests:e,timeoutSeconds:void 0!==n?n:r.EXTENSION_TIMEOUT_SEC,requestId:s})})},r.register=function(e,t,n,o){r.getPortSingleton_(function(i,s){if(i)return n(i);var a=++r.reqCounter_;r.callbackMap_[a]=n,s.postMessage({type:r.MessageTypes.U2F_REGISTER_REQUEST,signRequests:t,registerRequests:e,timeoutSeconds:void 0!==o?o:r.EXTENSION_TIMEOUT_SEC,requestId:a})})}},d5mW:function(e,t,n){"use strict";(function(t){e.exports=u;var r=n("adUY"),o="undefined"!=typeof navigator&&!!navigator.userAgent,i=o&&navigator.userAgent.match(/Safari\//)&&!navigator.userAgent.match(/Chrome\//),s=o&&navigator.userAgent.match(/Edge\/1[2345]/),a=null;function c(e){return a||(a=new e(function(e,t){function n(){e({u2f:null,native:!0})}return o?i?n():(void 0!==window.u2f&&"function"==typeof window.u2f.sign&&e({u2f:window.u2f,native:!0}),s||"http:"===location.protocol||"undefined"==typeof MessageChannel?n():void r.isSupported(function(t){t?e({u2f:r,native:!1}):n()})):n()})),a}function u(e){return{isSupported:l.bind(e),ensureSupport:E.bind(e),register:h.bind(e),sign:f.bind(e),ErrorCodes:u.ErrorCodes,ErrorNames:u.ErrorNames}}function d(e,t){var n=null!=t?t.errorCode:1,r=u.ErrorNames[""+n],o=new Error(e);return o.metaData={type:r,code:n},o}function p(e,t){var n={};return n.promise=new e(function(e,r){n.resolve=e,n.reject=r,t.then(e,r)}),n.promise.cancel=function(t,r){c(e).then(function(e){r&&!e.native&&e.u2f.disconnect(),n.reject(d(t,{errorCode:-1}))})},n}function l(){return c(this).then(function(e){return!!e.u2f})}function g(e){if(!e.u2f){if("http:"===location.protocol)throw new Error("U2F isn't supported over http, only https");throw new Error("U2F not supported")}}function E(){return c(this).then(g)}function h(e,t,n){var r=this;return Array.isArray(e)||(e=[e]),"number"==typeof t&&void 0===n&&(n=t,t=null),t||(t=[]),p(r,c(r).then(function(o){g(o);var i=o.native,s=o.u2f;return new r(function(r,o){i?s.register(e[0].appId,e,t,function(e){e.errorCode?o(d("Registration failed",e)):(delete e.errorCode,r(e))},n):s.register(e,t,function(e,t){e?o(e):t.errorCode?o(d("Registration failed",t)):r(t)},n)})})).promise}function f(e,t){var n=this;return Array.isArray(e)||(e=[e]),p(n,c(n).then(function(r){g(r);var o=r.native,i=r.u2f;return new n(function(n,r){o?i.sign(e[0].appId,e[0].challenge,e,function(e){e.errorCode?r(d("Sign failed",e)):(delete e.errorCode,n(e))},t):i.sign(e,function(e,t){e?r(e):t.errorCode?r(d("Sign failed",t)):n(t)},t)})})).promise}function m(e){u[e]=function(){if(!t.Promise)throw new Error("The platform doesn't natively support promises");var n=[].slice.call(arguments);return u(t.Promise)[e].apply(null,n)}}u.ErrorCodes={CANCELLED:-1,OK:0,OTHER_ERROR:1,BAD_REQUEST:2,CONFIGURATION_UNSUPPORTED:3,DEVICE_INELIGIBLE:4,TIMEOUT:5},u.ErrorNames={"-1":"CANCELLED",0:"OK",1:"OTHER_ERROR",2:"BAD_REQUEST",3:"CONFIGURATION_UNSUPPORTED",4:"DEVICE_INELIGIBLE",5:"TIMEOUT"},m("isSupported"),m("ensureSupport"),m("register"),m("sign")}).call(this,n("yLpj"))},qPxQ:function(e,t,n){"use strict";n.d(t,"a",function(){return u}),n.d(t,"b",function(){return c}),n.d(t,"c",function(){return a}),n.d(t,"d",function(){return d});var r={},o={},i=function(e,t){o[e]=t},s=function(e){var t=function(t,n){Object.assign(this,n),this.name=e,this.message=t||e,this.stack=(new Error).stack};return t.prototype=new Error,r[e]=t,t};s("AccountNameRequired"),s("AccountNotSupported"),s("AmountRequired"),s("BluetoothRequired"),s("BtcUnmatchedApp"),s("CantOpenDevice"),s("CashAddrNotSupported"),s("CurrencyNotSupported"),s("DeviceAppVerifyNotSupported"),s("DeviceGenuineSocketEarlyClose"),s("DeviceNotGenuine"),s("DeviceOnDashboardExpected"),s("DeviceOnDashboardUnexpected"),s("DeviceInOSUExpected"),s("DeviceHalted"),s("DeviceNameInvalid"),s("DeviceSocketFail"),s("DeviceSocketNoBulkStatus"),s("DisconnectedDevice"),s("DisconnectedDeviceDuringOperation"),s("EnpointConfig"),s("EthAppPleaseEnableContractData"),s("FeeEstimationFailed"),s("FirmwareNotRecognized"),s("HardResetFail"),s("InvalidXRPTag"),s("InvalidAddress"),s("InvalidAddressBecauseDestinationIsAlsoSource"),s("LatestMCUInstalledError"),s("UnknownMCU"),s("LedgerAPIError"),s("LedgerAPIErrorWithMessage"),s("LedgerAPINotAvailable"),s("ManagerAppAlreadyInstalled"),s("ManagerAppRelyOnBTC"),s("ManagerAppDepInstallRequired"),s("ManagerAppDepUninstallRequired"),s("ManagerDeviceLocked"),s("ManagerFirmwareNotEnoughSpace"),s("ManagerNotEnoughSpace"),s("ManagerUninstallBTCDep"),s("NetworkDown"),s("NoAddressesFound"),s("NotEnoughBalance"),s("NotEnoughBalanceToDelegate"),s("NotEnoughBalanceInParentAccount"),s("NotEnoughSpendableBalance"),s("NotEnoughBalanceBecauseDestinationNotCreated"),s("NoAccessToCamera"),s("NotEnoughGas"),s("NotSupportedLegacyAddress"),s("GasLessThanEstimate"),s("PasswordsDontMatch"),s("PasswordIncorrect"),s("RecommendSubAccountsToEmpty"),s("RecommendUndelegation"),s("TimeoutTagged"),s("UnexpectedBootloader"),s("MCUNotGenuineToDashboard"),s("RecipientRequired"),s("UnavailableTezosOriginatedAccountReceive"),s("UnavailableTezosOriginatedAccountSend"),s("UpdateFetchFileFail"),s("UpdateIncorrectHash"),s("UpdateIncorrectSig"),s("UpdateYourApp"),s("UserRefusedDeviceNameChange"),s("UserRefusedAddress"),s("UserRefusedFirmwareUpdate"),s("UserRefusedAllowManager"),s("UserRefusedOnDevice"),s("TransportOpenUserCancelled"),s("TransportInterfaceNotAvailable");var a=s("TransportRaceCondition");function c(e,t){this.name="TransportError",this.message=e,this.stack=(new Error).stack,this.id=t}s("TransportWebUSBGestureRequired"),s("DeviceShouldStayInApp"),s("WebsocketConnectionError"),s("WebsocketConnectionFailed"),s("WrongDeviceForAccount"),s("WrongAppForCurrency"),s("ETHAddressNonEIP"),s("CantScanQRCode"),s("FeeNotLoaded"),s("FeeRequired"),s("FeeTooHigh"),s("SyncError"),s("PairingFailed"),s("GenuineCheckFailed"),s("LedgerAPI4xx"),s("LedgerAPI5xx"),s("FirmwareOrAppUpdateRequired"),s("NoDBPathGiven"),s("DBWrongPassword"),s("DBNotReset"),c.prototype=new Error,i("TransportError",function(e){return new c(e.message,e.id)});var u={PIN_REMAINING_ATTEMPTS:25536,INCORRECT_LENGTH:26368,MISSING_CRITICAL_PARAMETER:26624,COMMAND_INCOMPATIBLE_FILE_STRUCTURE:27009,SECURITY_STATUS_NOT_SATISFIED:27010,CONDITIONS_OF_USE_NOT_SATISFIED:27013,INCORRECT_DATA:27264,NOT_ENOUGH_MEMORY_SPACE:27268,REFERENCED_DATA_NOT_FOUND:27272,FILE_ALREADY_EXISTS:27273,INCORRECT_P1_P2:27392,INS_NOT_SUPPORTED:27904,CLA_NOT_SUPPORTED:28160,TECHNICAL_PROBLEM:28416,OK:36864,MEMORY_PROBLEM:37440,NO_EF_SELECTED:37888,INVALID_OFFSET:37890,FILE_NOT_FOUND:37892,INCONSISTENT_FILE:37896,ALGORITHM_NOT_SUPPORTED:38020,INVALID_KCV:38021,CODE_NOT_INITIALIZED:38914,ACCESS_CONDITION_NOT_FULFILLED:38916,CONTRADICTION_SECRET_CODE_STATUS:38920,CONTRADICTION_INVALIDATION:38928,CODE_BLOCKED:38976,MAX_VALUE_REACHED:38992,GP_AUTH_FAILED:25344,LICENSING:28482,HALTED:28586};function d(e){this.name="TransportStatusError";var t=Object.keys(u).find(function(t){return u[t]===e})||"UNKNOWN_ERROR",n=function(e){switch(e){case 26368:return"Incorrect length";case 26624:return"Missing critical parameter";case 27010:return"Security not satisfied (dongle locked or have invalid access rights)";case 27013:return"Condition of use not satisfied (denied by the user?)";case 27264:return"Invalid data received";case 27392:return"Invalid parameter received"}if(28416<=e&&e<=28671)return"Internal error, please report"}(e)||t,r=e.toString(16);this.message="Ledger device: "+n+" (0x"+r+")",this.stack=(new Error).stack,this.statusCode=e,this.statusText=t}d.prototype=new Error,i("TransportStatusError",function(e){return new d(e.statusCode)})},vULT:function(e,t,n){"use strict";n.d(t,"a",function(){return i});let r=0;const o=[],i=(e,t,n)=>{const i={type:e,id:String(++r),date:new Date};t&&(i.message=t),n&&(i.data=n),function(e){for(let n=0;n<o.length;n++)try{o[n](e)}catch(t){console.error(t)}}(i)};"undefined"!=typeof window&&(window.__ledgerLogsListen=e=>(o.push(e),()=>{const t=o.indexOf(e);-1!==t&&(o[t]=o[o.length-1],o.pop())}))}}]);