@shapeshiftoss/hdwallet-core
Advanced tools
Comparing version 0.17.1 to 0.18.0
@@ -6,2 +6,3 @@ export * from './event'; | ||
export * from './bitcoin'; | ||
export * from './cosmos'; | ||
export * from './ethereum'; | ||
@@ -8,0 +9,0 @@ export * from './debuglink'; |
@@ -1,2 +0,2 @@ | ||
var t,e=require("rxjs"),r=require("rxjs/operators"),o=require("lodash"),n=require("eventemitter2");(t=exports.Events||(exports.Events={})).BUTTON_REQUEST="BUTTON_REQUEST",t.CANCEL="CANCEL",t.CHARACTER_REQUEST="CHARACTER_REQUEST",t.CONNECT="CONNECT",t.DISCONNECT="DISCONNECT",t.FAILURE="FAILURE",t.PASSPHRASE_REQUEST="PASSPHRASE_REQUEST",t.PIN_REQUEST="PIN_REQUEST",t.SUCCESS="SUCCESS",t.WORD_REQUEST="WORD_REQUEST";var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function c(t){return"m/"==t||/^m(((\/[0-9]+h)+|(\/[0-9]+H)+|(\/[0-9]+')*)((\/[0-9]+)*))$/.test(t)}function s(t){return t.replace("0x","")}var p,a,u,l=function(t){function e(e){t.call(this),this.keyring=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.connect=function(){},e.prototype.listen=function(){},e.prototype.disconnect=function(){},e}(n.EventEmitter2);(p=exports.BTCInputScriptType||(exports.BTCInputScriptType={})).CashAddr="cashaddr",p.SpendAddress="p2pkh",p.SpendMultisig="p2sh",p.External="external",p.SpendWitness="p2wpkh",p.SpendP2SHWitness="p2sh-p2wpkh",(a=exports.BTCOutputScriptType||(exports.BTCOutputScriptType={})).PayToAddress="p2pkh",a.PayToMultisig="p2sh",a.PayToWitness="p2wpkh",a.PayToP2SHWitness="p2sh-p2wpkh",(u=exports.BTCOutputAddressType||(exports.BTCOutputAddressType={})).Spend="spend",u.Transfer="transfer",u.Change="change",u.Exchange="exchange";var f=function(){function t(){}return t.prototype.then=function(e,r){var o=new t,n=this.s;if(n){var i=1&n?e:r;if(i){try{h(o,1,i(this.v))}catch(t){h(o,2,t)}return o}return this}return this.o=function(t){try{var n=t.v;1&t.s?h(o,1,e?e(n):n):r?h(o,1,r(n)):h(o,2,n)}catch(t){h(o,2,t)}},o},t}();function h(t,e,r){if(!t.s){if(r instanceof f){if(!r.s)return void(r.o=h.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(h.bind(null,t,e),h.bind(null,t,2));t.s=e,t.v=r;var o=t.o;o&&o(t)}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var d,y=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.add=function(t,e){var r=e||(new Date).toString();return!this.wallets[r]&&(this.wallets[r]=t,this.decorateEvents(e,t.transport),!0)},e.prototype.addAlias=function(t,e){this.aliases[e]=t},e.prototype.getAlias=function(t){var e=Object.keys(this.aliases),r=Object.values(this.aliases).indexOf(t);return-1!==r?e[r]:t},e.prototype.exec=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];try{var o=this;return Promise.all(Object.values(o.wallets).map(function(r){return r[t].apply(r,e)})).then(function(t){return t.reduce(function(t,e,r){return t[Object.keys(o.wallets)[r]]=e,t},{})})}catch(t){return Promise.reject(t)}},e.prototype.get=function(t){return this.aliases[t]&&this.wallets[this.aliases[t]]?this.wallets[this.aliases[t]]:this.wallets[t]?this.wallets[t]:Object.keys(this.wallets).length&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this,r=e.get(t);if(!r)return;var o=function(t,e){try{var o=function(t,e){try{var o=Promise.resolve(r.disconnect()).then(function(){})}catch(t){return e(t)}return o&&o.then?o.then(void 0,e):o}(0,function(t){console.error(t)})}catch(t){return e(!0,t)}return o&&o.then?o.then(e.bind(null,!1),e.bind(null,!0)):e(!1,value)}(0,function(r,o){var n=e.aliases[t];if(n?(delete e.aliases[t],delete e.wallets[n]):delete e.wallets[t],r)throw o;return o});return o&&o.then?o.then(function(){}):void 0}catch(t){return Promise.reject(t)}},e.prototype.removeAll=function(){try{var t=this;return Promise.resolve(Promise.all(Object.keys(t.wallets).map(t.remove.bind(t)))).then(function(){t.aliases={}})}catch(t){return Promise.reject(t)}},e.prototype.disconnectAll=function(){try{var t=Object.values(this.wallets),e=(r=t,o=function(e){return Promise.resolve(t[e].disconnect()).then(function(){})},c=-1,function t(e){try{for(;++c<r.length;)if((e=o(c))&&e.then){if(!((s=e)instanceof f&&1&s.s))return void e.then(t,i||(i=h.bind(null,n=new f,2)));e=e.v}n?h(n,1,e):n=e}catch(t){h(n||(n=new f),2,t)}var s}(),n);return e&&e.then?e.then(function(){}):void 0}catch(t){return Promise.reject(t)}var r,o,n,i,c},e.prototype.decorateEvents=function(t,e){try{var r=this,o=r.get(t).getVendor();e.onAny(function(e){for(var n=[],i=arguments.length-1;i-- >0;)n[i]=arguments[i+1];return r.emit([o,t,e],[t].concat(n))})}catch(t){return Promise.reject(t)}},e}(n.EventEmitter2);(d=exports.HDWalletErrorType||(exports.HDWalletErrorType={})).ActionCancelled="ActionCancelled",d.DeviceDisconnected="DeviceDisconnected",d.DisconnectedDeviceDuringOperation="DisconnectedDeviceDuringOperation",d.DeviceLocked="DeviceLocked",d.PopupClosedError="PopupClosedError",d.ConflictingApp="ConflictingApp",d.SelectApp="SelectApp",d.WrongApp="WrongApp",d.FirmwareUpdateRequired="FirmwareUpdateRequired",d.WebUSBNotAvailable="WebUSBNotAvailable",d.WebUSBCouldNotInitialize="WebUSBCouldNotInitialize",d.WebUSBCouldNotPair="WebUSBCouldNotPair",d.NavigateToDashboard="NavigateToDashboard";var v=function(t){function e(e,r){t.call(this,e),this.name=r,this.type=r,this.message=e,"function"==typeof t.captureStackTrace?t.captureStackTrace(this,this.constructor):this.stack=new t(e).stack}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Error),x=function(t){function e(){t.call(this,"Action cancelled",exports.HDWalletErrorType.ActionCancelled)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),E=function(t){function e(){t.call(this,"Device disconnected",exports.HDWalletErrorType.DeviceDisconnected)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),b=function(t){function e(){t.call(this,"Ledger device disconnected during operation",exports.HDWalletErrorType.DisconnectedDeviceDuringOperation)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),_=function(t){function e(){t.call(this,"Device locked",exports.HDWalletErrorType.DeviceLocked)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),T=function(t){function e(){t.call(this,"TrezorConnect popup closed",exports.HDWalletErrorType.PopupClosedError)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),S=function(t){function e(e){t.call(this,"Conflicting Application: Another wallet is trying to connect with your "+e+".",exports.HDWalletErrorType.ConflictingApp),this.model=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),g=function(t){function e(e,r){t.call(this,"Please open the "+r+" app on your "+e+".",exports.HDWalletErrorType.SelectApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),C=function(t){function e(e,r){t.call(this,"Wrong app open. Please open the "+r+" app on your "+e+" and try again.",exports.HDWalletErrorType.WrongApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),m=function(t){function e(e,r){t.call(this,"Firmware "+r+" or later is required to use your "+e+" with this client. Please update your device.",exports.HDWalletErrorType.FirmwareUpdateRequired)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),A=function(t){function e(){t.call(this,"WebUSB is not available in this browser. We recommend trying Chrome.",exports.HDWalletErrorType.WebUSBNotAvailable)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),D=function(t){function e(e,r){t.call(this,"Could not initialize "+e+": "+r,exports.HDWalletErrorType.WebUSBCouldNotInitialize)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),w=function(t){function e(e,r){t.call(this,"Could not pair "+e+": "+r,exports.HDWalletErrorType.WebUSBCouldNotPair)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),O=function(t){function e(e){t.call(this,"Please navigate to the dashboard of your "+e+".",exports.HDWalletErrorType.NavigateToDashboard)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v);exports.makeEvent=function(t){return Object.assign({},{date:Date.now()},t)},exports.DEFAULT_TIMEOUT=5e3,exports.LONG_TIMEOUT=3e5,exports.isArray=i,exports.fromHexString=function(t){var e=t.match(/.{1,2}/g)||[];return new Uint8Array(e.map(function(t){return parseInt(t,16)}))},exports.toHexString=function(t){return Array.prototype.map.call(t,function(t){return("00"+t.toString(16)).slice(-2)}).join("")},exports.arrayify=function(t){if(null==t)throw new Error("cannot convert null value to array");if("string"==typeof t){var e=t.match(/^(0x)?[0-9a-fA-F]*$/);if(!e)throw new Error("invalid hexidecimal string");if("0x"!==e[1])throw new Error("hex string must have 0x prefix");(t=t.substring(2)).length%2&&(t="0"+t);for(var r=[],o=0;o<t.length;o+=2)r.push(parseInt(t.substr(o,2),16));return new Uint8Array(r)}},exports.bip32ToAddressNList=function(t){if(!c(t))throw new Error("Not a bip32 path: '"+t+"'");/^m\//i.test(t)&&(t=t.slice(2));var e=t.split("/");if(1===e.length&&""===e[0])return[];for(var r=new Array(e.length),o=0;o<e.length;o++){var n=/(\d+)([hH\']?)/.exec(e[o]);if(null===n)throw new Error("Invalid input");if(r[o]=parseInt(n[1],10),r[o]>=2147483648)throw new Error("Invalid child index");if("h"===n[2]||"H"===n[2]||"'"===n[2])r[o]+=2147483648;else if(0!==n[2].length)throw new Error("Invalid modifier")}return r},exports.addressNListToBIP32=function(t){return"m/"+t.map(function(t){return t>=2147483648?t-2147483648+"'":t}).join("/")},exports.bip32Like=c,exports.takeFirstOfManyEvents=function(t,o){return e.merge.apply(void 0,o.map(function(r){return e.fromEvent(t,r)})).pipe(r.first())},exports.stripHexPrefix=s,exports.stripHexPrefixAndLower=function(t){return s(t).toLowerCase()},exports.base64toHEX=function(t){for(var e=atob(t),r="",o=0;o<e.length;o++){var n=e.charCodeAt(o).toString(16);r+=2==n.length?n:"0"+n}return"0x"+r.toUpperCase()},exports.slip44ByCoin=function(t){return{Bitcoin:0,Testnet:1,BitcoinCash:145,BitcoinGold:156,Litecoin:2,Dash:5,DigiByte:20,Dogecoin:3,BitcoinSV:236,Ethereum:60}[t]},exports.satsFromStr=function(t){var e=t.indexOf("."),r=e>0?8-(t.length-e-1):8;return Number(t.replace(/\./g,""))*Math.pow(10,r)},exports.hardenedPath=function(t){return t.filter(function(t){return t>=2147483648})},exports.relativePath=function(t){return t.filter(function(t){return t<2147483648})},exports.Transport=l,exports.supportsBTC=function(t){return o.isObject(t)&&t._supportsBTC},exports.infoBTC=function(t){return o.isObject(t)&&t._supportsBTCInfo},exports.supportsETH=function(t){return o.isObject(t)&&t._supportsETH},exports.infoETH=function(t){return o.isObject(t)&&t._supportsETHInfo},exports.supportsDebugLink=function(t){return o.isObject(t)&&t._supportsDebugLink},exports.Keyring=y,exports.HDWalletError=v,exports.ActionCancelled=x,exports.DeviceDisconnected=E,exports.DisconnectedDeviceDuringOperation=b,exports.DeviceLocked=_,exports.PopupClosedError=T,exports.ConflictingApp=S,exports.SelectApp=g,exports.WrongApp=C,exports.FirmwareUpdateRequired=m,exports.WebUSBNotAvailable=A,exports.WebUSBCouldNotInitialize=D,exports.WebUSBCouldNotPair=w,exports.NavigateToDashboard=O; | ||
var t,e=require("rxjs"),r=require("rxjs/operators"),o=require("lodash"),n=require("eventemitter2");(t=exports.Events||(exports.Events={})).BUTTON_REQUEST="BUTTON_REQUEST",t.CANCEL="CANCEL",t.CHARACTER_REQUEST="CHARACTER_REQUEST",t.CONNECT="CONNECT",t.DISCONNECT="DISCONNECT",t.FAILURE="FAILURE",t.PASSPHRASE_REQUEST="PASSPHRASE_REQUEST",t.PIN_REQUEST="PIN_REQUEST",t.SUCCESS="SUCCESS",t.WORD_REQUEST="WORD_REQUEST";var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function s(t){return"m/"==t||/^m(((\/[0-9]+h)+|(\/[0-9]+H)+|(\/[0-9]+')*)((\/[0-9]+)*))$/.test(t)}function p(t){return t.replace("0x","")}var c,a,u,l=function(t){function e(e){t.call(this),this.keyring=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.connect=function(){},e.prototype.listen=function(){},e.prototype.disconnect=function(){},e}(n.EventEmitter2);(c=exports.BTCInputScriptType||(exports.BTCInputScriptType={})).CashAddr="cashaddr",c.SpendAddress="p2pkh",c.SpendMultisig="p2sh",c.External="external",c.SpendWitness="p2wpkh",c.SpendP2SHWitness="p2sh-p2wpkh",(a=exports.BTCOutputScriptType||(exports.BTCOutputScriptType={})).PayToAddress="p2pkh",a.PayToMultisig="p2sh",a.PayToWitness="p2wpkh",a.PayToP2SHWitness="p2sh-p2wpkh",(u=exports.BTCOutputAddressType||(exports.BTCOutputAddressType={})).Spend="spend",u.Transfer="transfer",u.Change="change",u.Exchange="exchange";var f=function(){function t(){}return t.prototype.then=function(e,r){var o=new t,n=this.s;if(n){var i=1&n?e:r;if(i){try{h(o,1,i(this.v))}catch(t){h(o,2,t)}return o}return this}return this.o=function(t){try{var n=t.v;1&t.s?h(o,1,e?e(n):n):r?h(o,1,r(n)):h(o,2,n)}catch(t){h(o,2,t)}},o},t}();function h(t,e,r){if(!t.s){if(r instanceof f){if(!r.s)return void(r.o=h.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(h.bind(null,t,e),h.bind(null,t,2));t.s=e,t.v=r;var o=t.o;o&&o(t)}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var d,y=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.add=function(t,e){var r=e||(new Date).toString();return!this.wallets[r]&&(this.wallets[r]=t,this.decorateEvents(e,t.transport),!0)},e.prototype.addAlias=function(t,e){this.aliases[e]=t},e.prototype.getAlias=function(t){var e=Object.keys(this.aliases),r=Object.values(this.aliases).indexOf(t);return-1!==r?e[r]:t},e.prototype.exec=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];try{var o=this;return Promise.all(Object.values(o.wallets).map(function(r){return r[t].apply(r,e)})).then(function(t){return t.reduce(function(t,e,r){return t[Object.keys(o.wallets)[r]]=e,t},{})})}catch(t){return Promise.reject(t)}},e.prototype.get=function(t){return this.aliases[t]&&this.wallets[this.aliases[t]]?this.wallets[this.aliases[t]]:this.wallets[t]?this.wallets[t]:Object.keys(this.wallets).length&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this,r=e.get(t);if(!r)return;var o=function(t,e){try{var o=function(t,e){try{var o=Promise.resolve(r.disconnect()).then(function(){})}catch(t){return e(t)}return o&&o.then?o.then(void 0,e):o}(0,function(t){console.error(t)})}catch(t){return e(!0,t)}return o&&o.then?o.then(e.bind(null,!1),e.bind(null,!0)):e(!1,value)}(0,function(r,o){var n=e.aliases[t];if(n?(delete e.aliases[t],delete e.wallets[n]):delete e.wallets[t],r)throw o;return o});return o&&o.then?o.then(function(){}):void 0}catch(t){return Promise.reject(t)}},e.prototype.removeAll=function(){try{var t=this;return Promise.resolve(Promise.all(Object.keys(t.wallets).map(t.remove.bind(t)))).then(function(){t.aliases={}})}catch(t){return Promise.reject(t)}},e.prototype.disconnectAll=function(){try{var t=Object.values(this.wallets),e=(r=t,o=function(e){return Promise.resolve(t[e].disconnect()).then(function(){})},s=-1,function t(e){try{for(;++s<r.length;)if((e=o(s))&&e.then){if(!((p=e)instanceof f&&1&p.s))return void e.then(t,i||(i=h.bind(null,n=new f,2)));e=e.v}n?h(n,1,e):n=e}catch(t){h(n||(n=new f),2,t)}var p}(),n);return e&&e.then?e.then(function(){}):void 0}catch(t){return Promise.reject(t)}var r,o,n,i,s},e.prototype.decorateEvents=function(t,e){try{var r=this,o=r.get(t).getVendor();e.onAny(function(e){for(var n=[],i=arguments.length-1;i-- >0;)n[i]=arguments[i+1];return r.emit([o,t,e],[t].concat(n))})}catch(t){return Promise.reject(t)}},e}(n.EventEmitter2);(d=exports.HDWalletErrorType||(exports.HDWalletErrorType={})).ActionCancelled="ActionCancelled",d.DeviceDisconnected="DeviceDisconnected",d.DisconnectedDeviceDuringOperation="DisconnectedDeviceDuringOperation",d.DeviceLocked="DeviceLocked",d.PopupClosedError="PopupClosedError",d.ConflictingApp="ConflictingApp",d.SelectApp="SelectApp",d.WrongApp="WrongApp",d.FirmwareUpdateRequired="FirmwareUpdateRequired",d.WebUSBNotAvailable="WebUSBNotAvailable",d.WebUSBCouldNotInitialize="WebUSBCouldNotInitialize",d.WebUSBCouldNotPair="WebUSBCouldNotPair",d.NavigateToDashboard="NavigateToDashboard";var v=function(t){function e(e,r){t.call(this,e),this.name=r,this.type=r,this.message=e,"function"==typeof t.captureStackTrace?t.captureStackTrace(this,this.constructor):this.stack=new t(e).stack}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Error),x=function(t){function e(){t.call(this,"Action cancelled",exports.HDWalletErrorType.ActionCancelled)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),b=function(t){function e(){t.call(this,"Device disconnected",exports.HDWalletErrorType.DeviceDisconnected)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),E=function(t){function e(){t.call(this,"Ledger device disconnected during operation",exports.HDWalletErrorType.DisconnectedDeviceDuringOperation)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),_=function(t){function e(){t.call(this,"Device locked",exports.HDWalletErrorType.DeviceLocked)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),T=function(t){function e(){t.call(this,"TrezorConnect popup closed",exports.HDWalletErrorType.PopupClosedError)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),S=function(t){function e(e){t.call(this,"Conflicting Application: Another wallet is trying to connect with your "+e+".",exports.HDWalletErrorType.ConflictingApp),this.model=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),g=function(t){function e(e,r){t.call(this,"Please open the "+r+" app on your "+e+".",exports.HDWalletErrorType.SelectApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),C=function(t){function e(e,r){t.call(this,"Wrong app open. Please open the "+r+" app on your "+e+" and try again.",exports.HDWalletErrorType.WrongApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),m=function(t){function e(e,r){t.call(this,"Firmware "+r+" or later is required to use your "+e+" with this client. Please update your device.",exports.HDWalletErrorType.FirmwareUpdateRequired)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),A=function(t){function e(){t.call(this,"WebUSB is not available in this browser. We recommend trying Chrome.",exports.HDWalletErrorType.WebUSBNotAvailable)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),D=function(t){function e(e,r){t.call(this,"Could not initialize "+e+": "+r,exports.HDWalletErrorType.WebUSBCouldNotInitialize)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),w=function(t){function e(e,r){t.call(this,"Could not pair "+e+": "+r,exports.HDWalletErrorType.WebUSBCouldNotPair)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v),O=function(t){function e(e){t.call(this,"Please navigate to the dashboard of your "+e+".",exports.HDWalletErrorType.NavigateToDashboard)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(v);exports.makeEvent=function(t){return Object.assign({},{date:Date.now()},t)},exports.DEFAULT_TIMEOUT=5e3,exports.LONG_TIMEOUT=3e5,exports.isArray=i,exports.fromHexString=function(t){var e=t.match(/.{1,2}/g)||[];return new Uint8Array(e.map(function(t){return parseInt(t,16)}))},exports.toHexString=function(t){return Array.prototype.map.call(t,function(t){return("00"+t.toString(16)).slice(-2)}).join("")},exports.arrayify=function(t){if(null==t)throw new Error("cannot convert null value to array");if("string"==typeof t){var e=t.match(/^(0x)?[0-9a-fA-F]*$/);if(!e)throw new Error("invalid hexidecimal string");if("0x"!==e[1])throw new Error("hex string must have 0x prefix");(t=t.substring(2)).length%2&&(t="0"+t);for(var r=[],o=0;o<t.length;o+=2)r.push(parseInt(t.substr(o,2),16));return new Uint8Array(r)}},exports.bip32ToAddressNList=function(t){if(!s(t))throw new Error("Not a bip32 path: '"+t+"'");/^m\//i.test(t)&&(t=t.slice(2));var e=t.split("/");if(1===e.length&&""===e[0])return[];for(var r=new Array(e.length),o=0;o<e.length;o++){var n=/(\d+)([hH\']?)/.exec(e[o]);if(null===n)throw new Error("Invalid input");if(r[o]=parseInt(n[1],10),r[o]>=2147483648)throw new Error("Invalid child index");if("h"===n[2]||"H"===n[2]||"'"===n[2])r[o]+=2147483648;else if(0!==n[2].length)throw new Error("Invalid modifier")}return r},exports.addressNListToBIP32=function(t){return"m/"+t.map(function(t){return t>=2147483648?t-2147483648+"'":t}).join("/")},exports.bip32Like=s,exports.takeFirstOfManyEvents=function(t,o){return e.merge.apply(void 0,o.map(function(r){return e.fromEvent(t,r)})).pipe(r.first())},exports.stripHexPrefix=p,exports.stripHexPrefixAndLower=function(t){return p(t).toLowerCase()},exports.base64toHEX=function(t){for(var e=atob(t),r="",o=0;o<e.length;o++){var n=e.charCodeAt(o).toString(16);r+=2==n.length?n:"0"+n}return"0x"+r.toUpperCase()},exports.slip44ByCoin=function(t){return{Bitcoin:0,Testnet:1,BitcoinCash:145,BitcoinGold:156,Litecoin:2,Dash:5,DigiByte:20,Dogecoin:3,BitcoinSV:236,Ethereum:60,Atom:118}[t]},exports.satsFromStr=function(t){var e=t.indexOf("."),r=e>0?8-(t.length-e-1):8;return Number(t.replace(/\./g,""))*Math.pow(10,r)},exports.hardenedPath=function(t){return t.filter(function(t){return t>=2147483648})},exports.relativePath=function(t){return t.filter(function(t){return t<2147483648})},exports.Transport=l,exports.supportsBTC=function(t){return o.isObject(t)&&t._supportsBTC},exports.infoBTC=function(t){return o.isObject(t)&&t._supportsBTCInfo},exports.supportsETH=function(t){return o.isObject(t)&&t._supportsETH},exports.infoETH=function(t){return o.isObject(t)&&t._supportsETHInfo},exports.supportsCosmos=function(t){return o.isObject(t)&&t._supportsCosmos},exports.infoCosmos=function(t){return o.isObject(t)&&t._supportsCosmosInfo},exports.supportsDebugLink=function(t){return o.isObject(t)&&t._supportsDebugLink},exports.Keyring=y,exports.HDWalletError=v,exports.ActionCancelled=x,exports.DeviceDisconnected=b,exports.DisconnectedDeviceDuringOperation=E,exports.DeviceLocked=_,exports.PopupClosedError=T,exports.ConflictingApp=S,exports.SelectApp=g,exports.WrongApp=C,exports.FirmwareUpdateRequired=m,exports.WebUSBNotAvailable=A,exports.WebUSBCouldNotInitialize=D,exports.WebUSBCouldNotPair=w,exports.NavigateToDashboard=O; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{fromEvent as t,merge as e}from"rxjs";import{first as r}from"rxjs/operators";import{isObject as n}from"lodash";import{EventEmitter2 as o}from"eventemitter2";var i;function c(t){return Object.assign({},{date:Date.now()},t)}!function(t){t.BUTTON_REQUEST="BUTTON_REQUEST",t.CANCEL="CANCEL",t.CHARACTER_REQUEST="CHARACTER_REQUEST",t.CONNECT="CONNECT",t.DISCONNECT="DISCONNECT",t.FAILURE="FAILURE",t.PASSPHRASE_REQUEST="PASSPHRASE_REQUEST",t.PIN_REQUEST="PIN_REQUEST",t.SUCCESS="SUCCESS",t.WORD_REQUEST="WORD_REQUEST"}(i||(i={}));var a=5e3,u=3e5,s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},p=function(t){var e=t.match(/.{1,2}/g)||[];return new Uint8Array(e.map(function(t){return parseInt(t,16)}))};function l(t){return Array.prototype.map.call(t,function(t){return("00"+t.toString(16)).slice(-2)}).join("")}function f(t){if(null==t)throw new Error("cannot convert null value to array");if("string"==typeof t){var e=t.match(/^(0x)?[0-9a-fA-F]*$/);if(!e)throw new Error("invalid hexidecimal string");if("0x"!==e[1])throw new Error("hex string must have 0x prefix");(t=t.substring(2)).length%2&&(t="0"+t);for(var r=[],n=0;n<t.length;n+=2)r.push(parseInt(t.substr(n,2),16));return new Uint8Array(r)}}var h=2147483648;function d(t){if(!v(t))throw new Error("Not a bip32 path: '"+t+"'");/^m\//i.test(t)&&(t=t.slice(2));var e=t.split("/");if(1===e.length&&""===e[0])return[];for(var r=new Array(e.length),n=0;n<e.length;n++){var o=/(\d+)([hH\']?)/.exec(e[n]);if(null===o)throw new Error("Invalid input");if(r[n]=parseInt(o[1],10),r[n]>=h)throw new Error("Invalid child index");if("h"===o[2]||"H"===o[2]||"'"===o[2])r[n]+=h;else if(0!==o[2].length)throw new Error("Invalid modifier")}return r}function y(t){return"m/"+t.map(function(t){return t>=h?t-h+"'":t}).join("/")}function v(t){return"m/"==t||/^m(((\/[0-9]+h)+|(\/[0-9]+H)+|(\/[0-9]+')*)((\/[0-9]+)*))$/.test(t)}function _(n,o){return e.apply(void 0,o.map(function(e){return t(n,e)})).pipe(r())}function b(t){return t.replace("0x","")}function S(t){return b(t).toLowerCase()}function g(t){for(var e=atob(t),r="",n=0;n<e.length;n++){var o=e.charCodeAt(n).toString(16);r+=2==o.length?o:"0"+o}return"0x"+r.toUpperCase()}function m(t){return{Bitcoin:0,Testnet:1,BitcoinCash:145,BitcoinGold:156,Litecoin:2,Dash:5,DigiByte:20,Dogecoin:3,BitcoinSV:236,Ethereum:60}[t]}function w(t){var e=t.indexOf("."),r=e>0?8-(t.length-e-1):8;return Number(t.replace(/\./g,""))*Math.pow(10,r)}function E(t){return t.filter(function(t){return t>=2147483648})}function C(t){return t.filter(function(t){return t<2147483648})}var A,O,j,T=function(t){function e(e){t.call(this),this.keyring=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.connect=function(){},e.prototype.listen=function(){},e.prototype.disconnect=function(){},e}(o);function D(t){return n(t)&&t._supportsBTC}function P(t){return n(t)&&t._supportsBTCInfo}function U(t){return n(t)&&t._supportsETH}function N(t){return n(t)&&t._supportsETHInfo}function R(t){return n(t)&&t._supportsDebugLink}!function(t){t.CashAddr="cashaddr",t.SpendAddress="p2pkh",t.SpendMultisig="p2sh",t.External="external",t.SpendWitness="p2wpkh",t.SpendP2SHWitness="p2sh-p2wpkh"}(A||(A={})),function(t){t.PayToAddress="p2pkh",t.PayToMultisig="p2sh",t.PayToWitness="p2wpkh",t.PayToP2SHWitness="p2sh-p2wpkh"}(O||(O={})),function(t){t.Spend="spend",t.Transfer="transfer",t.Change="change",t.Exchange="exchange"}(j||(j={}));var W=function(){function t(){}return t.prototype.then=function(e,r){var n=new t,o=this.s;if(o){var i=1&o?e:r;if(i){try{k(n,1,i(this.v))}catch(t){k(n,2,t)}return n}return this}return this.o=function(t){try{var o=t.v;1&t.s?k(n,1,e?e(o):o):r?k(n,1,r(o)):k(n,2,o)}catch(t){k(n,2,t)}},n},t}();function k(t,e,r){if(!t.s){if(r instanceof W){if(!r.s)return void(r.o=k.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(k.bind(null,t,e),k.bind(null,t,2));t.s=e,t.v=r;var n=t.o;n&&n(t)}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var x,I=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.add=function(t,e){var r=e||(new Date).toString();return!this.wallets[r]&&(this.wallets[r]=t,this.decorateEvents(e,t.transport),!0)},e.prototype.addAlias=function(t,e){this.aliases[e]=t},e.prototype.getAlias=function(t){var e=Object.keys(this.aliases),r=Object.values(this.aliases).indexOf(t);return-1!==r?e[r]:t},e.prototype.exec=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];try{var n=this;return Promise.all(Object.values(n.wallets).map(function(r){return r[t].apply(r,e)})).then(function(t){return t.reduce(function(t,e,r){return t[Object.keys(n.wallets)[r]]=e,t},{})})}catch(t){return Promise.reject(t)}},e.prototype.get=function(t){return this.aliases[t]&&this.wallets[this.aliases[t]]?this.wallets[this.aliases[t]]:this.wallets[t]?this.wallets[t]:Object.keys(this.wallets).length&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this,r=e.get(t);if(!r)return;var n=function(t,e){try{var n=function(t,e){try{var n=Promise.resolve(r.disconnect()).then(function(){})}catch(t){return e(t)}return n&&n.then?n.then(void 0,e):n}(0,function(t){console.error(t)})}catch(t){return e(!0,t)}return n&&n.then?n.then(e.bind(null,!1),e.bind(null,!0)):e(!1,value)}(0,function(r,n){var o=e.aliases[t];if(o?(delete e.aliases[t],delete e.wallets[o]):delete e.wallets[t],r)throw n;return n});return n&&n.then?n.then(function(){}):void 0}catch(t){return Promise.reject(t)}},e.prototype.removeAll=function(){try{var t=this;return Promise.resolve(Promise.all(Object.keys(t.wallets).map(t.remove.bind(t)))).then(function(){t.aliases={}})}catch(t){return Promise.reject(t)}},e.prototype.disconnectAll=function(){try{var t=Object.values(this.wallets),e=(r=t,n=function(e){return Promise.resolve(t[e].disconnect()).then(function(){})},c=-1,function t(e){try{for(;++c<r.length;)if((e=n(c))&&e.then){if(!((a=e)instanceof W&&1&a.s))return void e.then(t,i||(i=k.bind(null,o=new W,2)));e=e.v}o?k(o,1,e):o=e}catch(t){k(o||(o=new W),2,t)}var a}(),o);return e&&e.then?e.then(function(){}):void 0}catch(t){return Promise.reject(t)}var r,n,o,i,c},e.prototype.decorateEvents=function(t,e){try{var r=this,n=r.get(t).getVendor();e.onAny(function(e){for(var o=[],i=arguments.length-1;i-- >0;)o[i]=arguments[i+1];return r.emit([n,t,e],[t].concat(o))})}catch(t){return Promise.reject(t)}},e}(o);!function(t){t.ActionCancelled="ActionCancelled",t.DeviceDisconnected="DeviceDisconnected",t.DisconnectedDeviceDuringOperation="DisconnectedDeviceDuringOperation",t.DeviceLocked="DeviceLocked",t.PopupClosedError="PopupClosedError",t.ConflictingApp="ConflictingApp",t.SelectApp="SelectApp",t.WrongApp="WrongApp",t.FirmwareUpdateRequired="FirmwareUpdateRequired",t.WebUSBNotAvailable="WebUSBNotAvailable",t.WebUSBCouldNotInitialize="WebUSBCouldNotInitialize",t.WebUSBCouldNotPair="WebUSBCouldNotPair",t.NavigateToDashboard="NavigateToDashboard"}(x||(x={}));var B=function(t){function e(e,r){t.call(this,e),this.name=r,this.type=r,this.message=e,"function"==typeof t.captureStackTrace?t.captureStackTrace(this,this.constructor):this.stack=new t(e).stack}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Error),H=function(t){function e(){t.call(this,"Action cancelled",x.ActionCancelled)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),L=function(t){function e(){t.call(this,"Device disconnected",x.DeviceDisconnected)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),Q=function(t){function e(){t.call(this,"Ledger device disconnected during operation",x.DisconnectedDeviceDuringOperation)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),F=function(t){function e(){t.call(this,"Device locked",x.DeviceLocked)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),z=function(t){function e(){t.call(this,"TrezorConnect popup closed",x.PopupClosedError)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),q=function(t){function e(e){t.call(this,"Conflicting Application: Another wallet is trying to connect with your "+e+".",x.ConflictingApp),this.model=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),M=function(t){function e(e,r){t.call(this,"Please open the "+r+" app on your "+e+".",x.SelectApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),V=function(t){function e(e,r){t.call(this,"Wrong app open. Please open the "+r+" app on your "+e+" and try again.",x.WrongApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),$=function(t){function e(e,r){t.call(this,"Firmware "+r+" or later is required to use your "+e+" with this client. Please update your device.",x.FirmwareUpdateRequired)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),G=function(t){function e(){t.call(this,"WebUSB is not available in this browser. We recommend trying Chrome.",x.WebUSBNotAvailable)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),J=function(t){function e(e,r){t.call(this,"Could not initialize "+e+": "+r,x.WebUSBCouldNotInitialize)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),K=function(t){function e(e,r){t.call(this,"Could not pair "+e+": "+r,x.WebUSBCouldNotPair)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B),X=function(t){function e(e){t.call(this,"Please navigate to the dashboard of your "+e+".",x.NavigateToDashboard)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(B);export{i as Events,c as makeEvent,a as DEFAULT_TIMEOUT,u as LONG_TIMEOUT,s as isArray,p as fromHexString,l as toHexString,f as arrayify,d as bip32ToAddressNList,y as addressNListToBIP32,v as bip32Like,_ as takeFirstOfManyEvents,b as stripHexPrefix,S as stripHexPrefixAndLower,g as base64toHEX,m as slip44ByCoin,w as satsFromStr,E as hardenedPath,C as relativePath,T as Transport,D as supportsBTC,P as infoBTC,U as supportsETH,N as infoETH,R as supportsDebugLink,A as BTCInputScriptType,O as BTCOutputScriptType,j as BTCOutputAddressType,I as Keyring,x as HDWalletErrorType,B as HDWalletError,H as ActionCancelled,L as DeviceDisconnected,Q as DisconnectedDeviceDuringOperation,F as DeviceLocked,z as PopupClosedError,q as ConflictingApp,M as SelectApp,V as WrongApp,$ as FirmwareUpdateRequired,G as WebUSBNotAvailable,J as WebUSBCouldNotInitialize,K as WebUSBCouldNotPair,X as NavigateToDashboard}; | ||
import{fromEvent as t,merge as e}from"rxjs";import{first as r}from"rxjs/operators";import{isObject as n}from"lodash";import{EventEmitter2 as o}from"eventemitter2";var i;function c(t){return Object.assign({},{date:Date.now()},t)}!function(t){t.BUTTON_REQUEST="BUTTON_REQUEST",t.CANCEL="CANCEL",t.CHARACTER_REQUEST="CHARACTER_REQUEST",t.CONNECT="CONNECT",t.DISCONNECT="DISCONNECT",t.FAILURE="FAILURE",t.PASSPHRASE_REQUEST="PASSPHRASE_REQUEST",t.PIN_REQUEST="PIN_REQUEST",t.SUCCESS="SUCCESS",t.WORD_REQUEST="WORD_REQUEST"}(i||(i={}));var a=5e3,u=3e5,s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},p=function(t){var e=t.match(/.{1,2}/g)||[];return new Uint8Array(e.map(function(t){return parseInt(t,16)}))};function l(t){return Array.prototype.map.call(t,function(t){return("00"+t.toString(16)).slice(-2)}).join("")}function f(t){if(null==t)throw new Error("cannot convert null value to array");if("string"==typeof t){var e=t.match(/^(0x)?[0-9a-fA-F]*$/);if(!e)throw new Error("invalid hexidecimal string");if("0x"!==e[1])throw new Error("hex string must have 0x prefix");(t=t.substring(2)).length%2&&(t="0"+t);for(var r=[],n=0;n<t.length;n+=2)r.push(parseInt(t.substr(n,2),16));return new Uint8Array(r)}}var h=2147483648;function d(t){if(!v(t))throw new Error("Not a bip32 path: '"+t+"'");/^m\//i.test(t)&&(t=t.slice(2));var e=t.split("/");if(1===e.length&&""===e[0])return[];for(var r=new Array(e.length),n=0;n<e.length;n++){var o=/(\d+)([hH\']?)/.exec(e[n]);if(null===o)throw new Error("Invalid input");if(r[n]=parseInt(o[1],10),r[n]>=h)throw new Error("Invalid child index");if("h"===o[2]||"H"===o[2]||"'"===o[2])r[n]+=h;else if(0!==o[2].length)throw new Error("Invalid modifier")}return r}function y(t){return"m/"+t.map(function(t){return t>=h?t-h+"'":t}).join("/")}function v(t){return"m/"==t||/^m(((\/[0-9]+h)+|(\/[0-9]+H)+|(\/[0-9]+')*)((\/[0-9]+)*))$/.test(t)}function _(n,o){return e.apply(void 0,o.map(function(e){return t(n,e)})).pipe(r())}function b(t){return t.replace("0x","")}function m(t){return b(t).toLowerCase()}function S(t){for(var e=atob(t),r="",n=0;n<e.length;n++){var o=e.charCodeAt(n).toString(16);r+=2==o.length?o:"0"+o}return"0x"+r.toUpperCase()}function g(t){return{Bitcoin:0,Testnet:1,BitcoinCash:145,BitcoinGold:156,Litecoin:2,Dash:5,DigiByte:20,Dogecoin:3,BitcoinSV:236,Ethereum:60,Atom:118}[t]}function w(t){var e=t.indexOf("."),r=e>0?8-(t.length-e-1):8;return Number(t.replace(/\./g,""))*Math.pow(10,r)}function E(t){return t.filter(function(t){return t>=2147483648})}function C(t){return t.filter(function(t){return t<2147483648})}var A,O,j,T=function(t){function e(e){t.call(this),this.keyring=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.connect=function(){},e.prototype.listen=function(){},e.prototype.disconnect=function(){},e}(o);function D(t){return n(t)&&t._supportsBTC}function P(t){return n(t)&&t._supportsBTCInfo}function U(t){return n(t)&&t._supportsETH}function N(t){return n(t)&&t._supportsETHInfo}function R(t){return n(t)&&t._supportsCosmos}function I(t){return n(t)&&t._supportsCosmosInfo}function W(t){return n(t)&&t._supportsDebugLink}!function(t){t.CashAddr="cashaddr",t.SpendAddress="p2pkh",t.SpendMultisig="p2sh",t.External="external",t.SpendWitness="p2wpkh",t.SpendP2SHWitness="p2sh-p2wpkh"}(A||(A={})),function(t){t.PayToAddress="p2pkh",t.PayToMultisig="p2sh",t.PayToWitness="p2wpkh",t.PayToP2SHWitness="p2sh-p2wpkh"}(O||(O={})),function(t){t.Spend="spend",t.Transfer="transfer",t.Change="change",t.Exchange="exchange"}(j||(j={}));var k=function(){function t(){}return t.prototype.then=function(e,r){var n=new t,o=this.s;if(o){var i=1&o?e:r;if(i){try{x(n,1,i(this.v))}catch(t){x(n,2,t)}return n}return this}return this.o=function(t){try{var o=t.v;1&t.s?x(n,1,e?e(o):o):r?x(n,1,r(o)):x(n,2,o)}catch(t){x(n,2,t)}},n},t}();function x(t,e,r){if(!t.s){if(r instanceof k){if(!r.s)return void(r.o=x.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(x.bind(null,t,e),x.bind(null,t,2));t.s=e,t.v=r;var n=t.o;n&&n(t)}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var B,H=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.add=function(t,e){var r=e||(new Date).toString();return!this.wallets[r]&&(this.wallets[r]=t,this.decorateEvents(e,t.transport),!0)},e.prototype.addAlias=function(t,e){this.aliases[e]=t},e.prototype.getAlias=function(t){var e=Object.keys(this.aliases),r=Object.values(this.aliases).indexOf(t);return-1!==r?e[r]:t},e.prototype.exec=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];try{var n=this;return Promise.all(Object.values(n.wallets).map(function(r){return r[t].apply(r,e)})).then(function(t){return t.reduce(function(t,e,r){return t[Object.keys(n.wallets)[r]]=e,t},{})})}catch(t){return Promise.reject(t)}},e.prototype.get=function(t){return this.aliases[t]&&this.wallets[this.aliases[t]]?this.wallets[this.aliases[t]]:this.wallets[t]?this.wallets[t]:Object.keys(this.wallets).length&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this,r=e.get(t);if(!r)return;var n=function(t,e){try{var n=function(t,e){try{var n=Promise.resolve(r.disconnect()).then(function(){})}catch(t){return e(t)}return n&&n.then?n.then(void 0,e):n}(0,function(t){console.error(t)})}catch(t){return e(!0,t)}return n&&n.then?n.then(e.bind(null,!1),e.bind(null,!0)):e(!1,value)}(0,function(r,n){var o=e.aliases[t];if(o?(delete e.aliases[t],delete e.wallets[o]):delete e.wallets[t],r)throw n;return n});return n&&n.then?n.then(function(){}):void 0}catch(t){return Promise.reject(t)}},e.prototype.removeAll=function(){try{var t=this;return Promise.resolve(Promise.all(Object.keys(t.wallets).map(t.remove.bind(t)))).then(function(){t.aliases={}})}catch(t){return Promise.reject(t)}},e.prototype.disconnectAll=function(){try{var t=Object.values(this.wallets),e=(r=t,n=function(e){return Promise.resolve(t[e].disconnect()).then(function(){})},c=-1,function t(e){try{for(;++c<r.length;)if((e=n(c))&&e.then){if(!((a=e)instanceof k&&1&a.s))return void e.then(t,i||(i=x.bind(null,o=new k,2)));e=e.v}o?x(o,1,e):o=e}catch(t){x(o||(o=new k),2,t)}var a}(),o);return e&&e.then?e.then(function(){}):void 0}catch(t){return Promise.reject(t)}var r,n,o,i,c},e.prototype.decorateEvents=function(t,e){try{var r=this,n=r.get(t).getVendor();e.onAny(function(e){for(var o=[],i=arguments.length-1;i-- >0;)o[i]=arguments[i+1];return r.emit([n,t,e],[t].concat(o))})}catch(t){return Promise.reject(t)}},e}(o);!function(t){t.ActionCancelled="ActionCancelled",t.DeviceDisconnected="DeviceDisconnected",t.DisconnectedDeviceDuringOperation="DisconnectedDeviceDuringOperation",t.DeviceLocked="DeviceLocked",t.PopupClosedError="PopupClosedError",t.ConflictingApp="ConflictingApp",t.SelectApp="SelectApp",t.WrongApp="WrongApp",t.FirmwareUpdateRequired="FirmwareUpdateRequired",t.WebUSBNotAvailable="WebUSBNotAvailable",t.WebUSBCouldNotInitialize="WebUSBCouldNotInitialize",t.WebUSBCouldNotPair="WebUSBCouldNotPair",t.NavigateToDashboard="NavigateToDashboard"}(B||(B={}));var L=function(t){function e(e,r){t.call(this,e),this.name=r,this.type=r,this.message=e,"function"==typeof t.captureStackTrace?t.captureStackTrace(this,this.constructor):this.stack=new t(e).stack}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Error),Q=function(t){function e(){t.call(this,"Action cancelled",B.ActionCancelled)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),F=function(t){function e(){t.call(this,"Device disconnected",B.DeviceDisconnected)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),z=function(t){function e(){t.call(this,"Ledger device disconnected during operation",B.DisconnectedDeviceDuringOperation)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),q=function(t){function e(){t.call(this,"Device locked",B.DeviceLocked)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),M=function(t){function e(){t.call(this,"TrezorConnect popup closed",B.PopupClosedError)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),V=function(t){function e(e){t.call(this,"Conflicting Application: Another wallet is trying to connect with your "+e+".",B.ConflictingApp),this.model=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),$=function(t){function e(e,r){t.call(this,"Please open the "+r+" app on your "+e+".",B.SelectApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),G=function(t){function e(e,r){t.call(this,"Wrong app open. Please open the "+r+" app on your "+e+" and try again.",B.WrongApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),J=function(t){function e(e,r){t.call(this,"Firmware "+r+" or later is required to use your "+e+" with this client. Please update your device.",B.FirmwareUpdateRequired)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),K=function(t){function e(){t.call(this,"WebUSB is not available in this browser. We recommend trying Chrome.",B.WebUSBNotAvailable)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),X=function(t){function e(e,r){t.call(this,"Could not initialize "+e+": "+r,B.WebUSBCouldNotInitialize)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),Y=function(t){function e(e,r){t.call(this,"Could not pair "+e+": "+r,B.WebUSBCouldNotPair)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L),Z=function(t){function e(e){t.call(this,"Please navigate to the dashboard of your "+e+".",B.NavigateToDashboard)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(L);export{i as Events,c as makeEvent,a as DEFAULT_TIMEOUT,u as LONG_TIMEOUT,s as isArray,p as fromHexString,l as toHexString,f as arrayify,d as bip32ToAddressNList,y as addressNListToBIP32,v as bip32Like,_ as takeFirstOfManyEvents,b as stripHexPrefix,m as stripHexPrefixAndLower,S as base64toHEX,g as slip44ByCoin,w as satsFromStr,E as hardenedPath,C as relativePath,T as Transport,D as supportsBTC,P as infoBTC,U as supportsETH,N as infoETH,R as supportsCosmos,I as infoCosmos,W as supportsDebugLink,A as BTCInputScriptType,O as BTCOutputScriptType,j as BTCOutputAddressType,H as Keyring,B as HDWalletErrorType,L as HDWalletError,Q as ActionCancelled,F as DeviceDisconnected,z as DisconnectedDeviceDuringOperation,q as DeviceLocked,M as PopupClosedError,V as ConflictingApp,$ as SelectApp,G as WrongApp,J as FirmwareUpdateRequired,K as WebUSBNotAvailable,X as WebUSBCouldNotInitialize,Y as WebUSBCouldNotPair,Z as NavigateToDashboard}; | ||
//# sourceMappingURL=index.m.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rxjs"),require("rxjs/operators"),require("lodash"),require("eventemitter2")):"function"==typeof define&&define.amd?define(["exports","rxjs","rxjs/operators","lodash","eventemitter2"],e):e(t.core={},t.rxjs,t.operators,t.lodash,t.eventemitter2)}(this,function(t,e,r,n,o){var i;(i=t.Events||(t.Events={})).BUTTON_REQUEST="BUTTON_REQUEST",i.CANCEL="CANCEL",i.CHARACTER_REQUEST="CHARACTER_REQUEST",i.CONNECT="CONNECT",i.DISCONNECT="DISCONNECT",i.FAILURE="FAILURE",i.PASSPHRASE_REQUEST="PASSPHRASE_REQUEST",i.PIN_REQUEST="PIN_REQUEST",i.SUCCESS="SUCCESS",i.WORD_REQUEST="WORD_REQUEST";var c=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function a(t){return"m/"==t||/^m(((\/[0-9]+h)+|(\/[0-9]+H)+|(\/[0-9]+')*)((\/[0-9]+)*))$/.test(t)}function s(t){return t.replace("0x","")}var p,u,l,f=function(t){function e(e){t.call(this),this.keyring=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.connect=function(){},e.prototype.listen=function(){},e.prototype.disconnect=function(){},e}(o.EventEmitter2);(p=t.BTCInputScriptType||(t.BTCInputScriptType={})).CashAddr="cashaddr",p.SpendAddress="p2pkh",p.SpendMultisig="p2sh",p.External="external",p.SpendWitness="p2wpkh",p.SpendP2SHWitness="p2sh-p2wpkh",(u=t.BTCOutputScriptType||(t.BTCOutputScriptType={})).PayToAddress="p2pkh",u.PayToMultisig="p2sh",u.PayToWitness="p2wpkh",u.PayToP2SHWitness="p2sh-p2wpkh",(l=t.BTCOutputAddressType||(t.BTCOutputAddressType={})).Spend="spend",l.Transfer="transfer",l.Change="change",l.Exchange="exchange";var h=function(){function t(){}return t.prototype.then=function(e,r){var n=new t,o=this.s;if(o){var i=1&o?e:r;if(i){try{d(n,1,i(this.v))}catch(t){d(n,2,t)}return n}return this}return this.o=function(t){try{var o=t.v;1&t.s?d(n,1,e?e(o):o):r?d(n,1,r(o)):d(n,2,o)}catch(t){d(n,2,t)}},n},t}();function d(t,e,r){if(!t.s){if(r instanceof h){if(!r.s)return void(r.o=d.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(d.bind(null,t,e),d.bind(null,t,2));t.s=e,t.v=r;var n=t.o;n&&n(t)}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var y,v=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.add=function(t,e){var r=e||(new Date).toString();return!this.wallets[r]&&(this.wallets[r]=t,this.decorateEvents(e,t.transport),!0)},e.prototype.addAlias=function(t,e){this.aliases[e]=t},e.prototype.getAlias=function(t){var e=Object.keys(this.aliases),r=Object.values(this.aliases).indexOf(t);return-1!==r?e[r]:t},e.prototype.exec=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];try{var n=this;return Promise.all(Object.values(n.wallets).map(function(r){return r[t].apply(r,e)})).then(function(t){return t.reduce(function(t,e,r){return t[Object.keys(n.wallets)[r]]=e,t},{})})}catch(t){return Promise.reject(t)}},e.prototype.get=function(t){return this.aliases[t]&&this.wallets[this.aliases[t]]?this.wallets[this.aliases[t]]:this.wallets[t]?this.wallets[t]:Object.keys(this.wallets).length&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this,r=e.get(t);if(!r)return;var n=function(t,e){try{var n=function(t,e){try{var n=Promise.resolve(r.disconnect()).then(function(){})}catch(t){return e(t)}return n&&n.then?n.then(void 0,e):n}(0,function(t){console.error(t)})}catch(t){return e(!0,t)}return n&&n.then?n.then(e.bind(null,!1),e.bind(null,!0)):e(!1,value)}(0,function(r,n){var o=e.aliases[t];if(o?(delete e.aliases[t],delete e.wallets[o]):delete e.wallets[t],r)throw n;return n});return n&&n.then?n.then(function(){}):void 0}catch(t){return Promise.reject(t)}},e.prototype.removeAll=function(){try{var t=this;return Promise.resolve(Promise.all(Object.keys(t.wallets).map(t.remove.bind(t)))).then(function(){t.aliases={}})}catch(t){return Promise.reject(t)}},e.prototype.disconnectAll=function(){try{var t=Object.values(this.wallets),e=(r=t,n=function(e){return Promise.resolve(t[e].disconnect()).then(function(){})},c=-1,function t(e){try{for(;++c<r.length;)if((e=n(c))&&e.then){if(!((a=e)instanceof h&&1&a.s))return void e.then(t,i||(i=d.bind(null,o=new h,2)));e=e.v}o?d(o,1,e):o=e}catch(t){d(o||(o=new h),2,t)}var a}(),o);return e&&e.then?e.then(function(){}):void 0}catch(t){return Promise.reject(t)}var r,n,o,i,c},e.prototype.decorateEvents=function(t,e){try{var r=this,n=r.get(t).getVendor();e.onAny(function(e){for(var o=[],i=arguments.length-1;i-- >0;)o[i]=arguments[i+1];return r.emit([n,t,e],[t].concat(o))})}catch(t){return Promise.reject(t)}},e}(o.EventEmitter2);(y=t.HDWalletErrorType||(t.HDWalletErrorType={})).ActionCancelled="ActionCancelled",y.DeviceDisconnected="DeviceDisconnected",y.DisconnectedDeviceDuringOperation="DisconnectedDeviceDuringOperation",y.DeviceLocked="DeviceLocked",y.PopupClosedError="PopupClosedError",y.ConflictingApp="ConflictingApp",y.SelectApp="SelectApp",y.WrongApp="WrongApp",y.FirmwareUpdateRequired="FirmwareUpdateRequired",y.WebUSBNotAvailable="WebUSBNotAvailable",y.WebUSBCouldNotInitialize="WebUSBCouldNotInitialize",y.WebUSBCouldNotPair="WebUSBCouldNotPair",y.NavigateToDashboard="NavigateToDashboard";var b=function(t){function e(e,r){t.call(this,e),this.name=r,this.type=r,this.message=e,"function"==typeof t.captureStackTrace?t.captureStackTrace(this,this.constructor):this.stack=new t(e).stack}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Error),E=function(e){function r(){e.call(this,"Action cancelled",t.HDWalletErrorType.ActionCancelled)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),_=function(e){function r(){e.call(this,"Device disconnected",t.HDWalletErrorType.DeviceDisconnected)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),T=function(e){function r(){e.call(this,"Ledger device disconnected during operation",t.HDWalletErrorType.DisconnectedDeviceDuringOperation)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),S=function(e){function r(){e.call(this,"Device locked",t.HDWalletErrorType.DeviceLocked)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),g=function(e){function r(){e.call(this,"TrezorConnect popup closed",t.HDWalletErrorType.PopupClosedError)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),m=function(e){function r(r){e.call(this,"Conflicting Application: Another wallet is trying to connect with your "+r+".",t.HDWalletErrorType.ConflictingApp),this.model=r}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),C=function(e){function r(r,n){e.call(this,"Please open the "+n+" app on your "+r+".",t.HDWalletErrorType.SelectApp)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),A=function(e){function r(r,n){e.call(this,"Wrong app open. Please open the "+n+" app on your "+r+" and try again.",t.HDWalletErrorType.WrongApp)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),D=function(e){function r(r,n){e.call(this,"Firmware "+n+" or later is required to use your "+r+" with this client. Please update your device.",t.HDWalletErrorType.FirmwareUpdateRequired)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),w=function(e){function r(){e.call(this,"WebUSB is not available in this browser. We recommend trying Chrome.",t.HDWalletErrorType.WebUSBNotAvailable)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),O=function(e){function r(r,n){e.call(this,"Could not initialize "+r+": "+n,t.HDWalletErrorType.WebUSBCouldNotInitialize)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),j=function(e){function r(r,n){e.call(this,"Could not pair "+r+": "+n,t.HDWalletErrorType.WebUSBCouldNotPair)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),W=function(e){function r(r){e.call(this,"Please navigate to the dashboard of your "+r+".",t.HDWalletErrorType.NavigateToDashboard)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b);t.makeEvent=function(t){return Object.assign({},{date:Date.now()},t)},t.DEFAULT_TIMEOUT=5e3,t.LONG_TIMEOUT=3e5,t.isArray=c,t.fromHexString=function(t){var e=t.match(/.{1,2}/g)||[];return new Uint8Array(e.map(function(t){return parseInt(t,16)}))},t.toHexString=function(t){return Array.prototype.map.call(t,function(t){return("00"+t.toString(16)).slice(-2)}).join("")},t.arrayify=function(t){if(null==t)throw new Error("cannot convert null value to array");if("string"==typeof t){var e=t.match(/^(0x)?[0-9a-fA-F]*$/);if(!e)throw new Error("invalid hexidecimal string");if("0x"!==e[1])throw new Error("hex string must have 0x prefix");(t=t.substring(2)).length%2&&(t="0"+t);for(var r=[],n=0;n<t.length;n+=2)r.push(parseInt(t.substr(n,2),16));return new Uint8Array(r)}},t.bip32ToAddressNList=function(t){if(!a(t))throw new Error("Not a bip32 path: '"+t+"'");/^m\//i.test(t)&&(t=t.slice(2));var e=t.split("/");if(1===e.length&&""===e[0])return[];for(var r=new Array(e.length),n=0;n<e.length;n++){var o=/(\d+)([hH\']?)/.exec(e[n]);if(null===o)throw new Error("Invalid input");if(r[n]=parseInt(o[1],10),r[n]>=2147483648)throw new Error("Invalid child index");if("h"===o[2]||"H"===o[2]||"'"===o[2])r[n]+=2147483648;else if(0!==o[2].length)throw new Error("Invalid modifier")}return r},t.addressNListToBIP32=function(t){return"m/"+t.map(function(t){return t>=2147483648?t-2147483648+"'":t}).join("/")},t.bip32Like=a,t.takeFirstOfManyEvents=function(t,n){return e.merge.apply(void 0,n.map(function(r){return e.fromEvent(t,r)})).pipe(r.first())},t.stripHexPrefix=s,t.stripHexPrefixAndLower=function(t){return s(t).toLowerCase()},t.base64toHEX=function(t){for(var e=atob(t),r="",n=0;n<e.length;n++){var o=e.charCodeAt(n).toString(16);r+=2==o.length?o:"0"+o}return"0x"+r.toUpperCase()},t.slip44ByCoin=function(t){return{Bitcoin:0,Testnet:1,BitcoinCash:145,BitcoinGold:156,Litecoin:2,Dash:5,DigiByte:20,Dogecoin:3,BitcoinSV:236,Ethereum:60}[t]},t.satsFromStr=function(t){var e=t.indexOf("."),r=e>0?8-(t.length-e-1):8;return Number(t.replace(/\./g,""))*Math.pow(10,r)},t.hardenedPath=function(t){return t.filter(function(t){return t>=2147483648})},t.relativePath=function(t){return t.filter(function(t){return t<2147483648})},t.Transport=f,t.supportsBTC=function(t){return n.isObject(t)&&t._supportsBTC},t.infoBTC=function(t){return n.isObject(t)&&t._supportsBTCInfo},t.supportsETH=function(t){return n.isObject(t)&&t._supportsETH},t.infoETH=function(t){return n.isObject(t)&&t._supportsETHInfo},t.supportsDebugLink=function(t){return n.isObject(t)&&t._supportsDebugLink},t.Keyring=v,t.HDWalletError=b,t.ActionCancelled=E,t.DeviceDisconnected=_,t.DisconnectedDeviceDuringOperation=T,t.DeviceLocked=S,t.PopupClosedError=g,t.ConflictingApp=m,t.SelectApp=C,t.WrongApp=A,t.FirmwareUpdateRequired=D,t.WebUSBNotAvailable=w,t.WebUSBCouldNotInitialize=O,t.WebUSBCouldNotPair=j,t.NavigateToDashboard=W}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rxjs"),require("rxjs/operators"),require("lodash"),require("eventemitter2")):"function"==typeof define&&define.amd?define(["exports","rxjs","rxjs/operators","lodash","eventemitter2"],e):e(t.core={},t.rxjs,t.operators,t.lodash,t.eventemitter2)}(this,function(t,e,r,o,n){var i;(i=t.Events||(t.Events={})).BUTTON_REQUEST="BUTTON_REQUEST",i.CANCEL="CANCEL",i.CHARACTER_REQUEST="CHARACTER_REQUEST",i.CONNECT="CONNECT",i.DISCONNECT="DISCONNECT",i.FAILURE="FAILURE",i.PASSPHRASE_REQUEST="PASSPHRASE_REQUEST",i.PIN_REQUEST="PIN_REQUEST",i.SUCCESS="SUCCESS",i.WORD_REQUEST="WORD_REQUEST";var c=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function a(t){return"m/"==t||/^m(((\/[0-9]+h)+|(\/[0-9]+H)+|(\/[0-9]+')*)((\/[0-9]+)*))$/.test(t)}function s(t){return t.replace("0x","")}var p,u,l,f=function(t){function e(e){t.call(this),this.keyring=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.connect=function(){},e.prototype.listen=function(){},e.prototype.disconnect=function(){},e}(n.EventEmitter2);(p=t.BTCInputScriptType||(t.BTCInputScriptType={})).CashAddr="cashaddr",p.SpendAddress="p2pkh",p.SpendMultisig="p2sh",p.External="external",p.SpendWitness="p2wpkh",p.SpendP2SHWitness="p2sh-p2wpkh",(u=t.BTCOutputScriptType||(t.BTCOutputScriptType={})).PayToAddress="p2pkh",u.PayToMultisig="p2sh",u.PayToWitness="p2wpkh",u.PayToP2SHWitness="p2sh-p2wpkh",(l=t.BTCOutputAddressType||(t.BTCOutputAddressType={})).Spend="spend",l.Transfer="transfer",l.Change="change",l.Exchange="exchange";var h=function(){function t(){}return t.prototype.then=function(e,r){var o=new t,n=this.s;if(n){var i=1&n?e:r;if(i){try{d(o,1,i(this.v))}catch(t){d(o,2,t)}return o}return this}return this.o=function(t){try{var n=t.v;1&t.s?d(o,1,e?e(n):n):r?d(o,1,r(n)):d(o,2,n)}catch(t){d(o,2,t)}},o},t}();function d(t,e,r){if(!t.s){if(r instanceof h){if(!r.s)return void(r.o=d.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(d.bind(null,t,e),d.bind(null,t,2));t.s=e,t.v=r;var o=t.o;o&&o(t)}}"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var y,v=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.add=function(t,e){var r=e||(new Date).toString();return!this.wallets[r]&&(this.wallets[r]=t,this.decorateEvents(e,t.transport),!0)},e.prototype.addAlias=function(t,e){this.aliases[e]=t},e.prototype.getAlias=function(t){var e=Object.keys(this.aliases),r=Object.values(this.aliases).indexOf(t);return-1!==r?e[r]:t},e.prototype.exec=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];try{var o=this;return Promise.all(Object.values(o.wallets).map(function(r){return r[t].apply(r,e)})).then(function(t){return t.reduce(function(t,e,r){return t[Object.keys(o.wallets)[r]]=e,t},{})})}catch(t){return Promise.reject(t)}},e.prototype.get=function(t){return this.aliases[t]&&this.wallets[this.aliases[t]]?this.wallets[this.aliases[t]]:this.wallets[t]?this.wallets[t]:Object.keys(this.wallets).length&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this,r=e.get(t);if(!r)return;var o=function(t,e){try{var o=function(t,e){try{var o=Promise.resolve(r.disconnect()).then(function(){})}catch(t){return e(t)}return o&&o.then?o.then(void 0,e):o}(0,function(t){console.error(t)})}catch(t){return e(!0,t)}return o&&o.then?o.then(e.bind(null,!1),e.bind(null,!0)):e(!1,value)}(0,function(r,o){var n=e.aliases[t];if(n?(delete e.aliases[t],delete e.wallets[n]):delete e.wallets[t],r)throw o;return o});return o&&o.then?o.then(function(){}):void 0}catch(t){return Promise.reject(t)}},e.prototype.removeAll=function(){try{var t=this;return Promise.resolve(Promise.all(Object.keys(t.wallets).map(t.remove.bind(t)))).then(function(){t.aliases={}})}catch(t){return Promise.reject(t)}},e.prototype.disconnectAll=function(){try{var t=Object.values(this.wallets),e=(r=t,o=function(e){return Promise.resolve(t[e].disconnect()).then(function(){})},c=-1,function t(e){try{for(;++c<r.length;)if((e=o(c))&&e.then){if(!((a=e)instanceof h&&1&a.s))return void e.then(t,i||(i=d.bind(null,n=new h,2)));e=e.v}n?d(n,1,e):n=e}catch(t){d(n||(n=new h),2,t)}var a}(),n);return e&&e.then?e.then(function(){}):void 0}catch(t){return Promise.reject(t)}var r,o,n,i,c},e.prototype.decorateEvents=function(t,e){try{var r=this,o=r.get(t).getVendor();e.onAny(function(e){for(var n=[],i=arguments.length-1;i-- >0;)n[i]=arguments[i+1];return r.emit([o,t,e],[t].concat(n))})}catch(t){return Promise.reject(t)}},e}(n.EventEmitter2);(y=t.HDWalletErrorType||(t.HDWalletErrorType={})).ActionCancelled="ActionCancelled",y.DeviceDisconnected="DeviceDisconnected",y.DisconnectedDeviceDuringOperation="DisconnectedDeviceDuringOperation",y.DeviceLocked="DeviceLocked",y.PopupClosedError="PopupClosedError",y.ConflictingApp="ConflictingApp",y.SelectApp="SelectApp",y.WrongApp="WrongApp",y.FirmwareUpdateRequired="FirmwareUpdateRequired",y.WebUSBNotAvailable="WebUSBNotAvailable",y.WebUSBCouldNotInitialize="WebUSBCouldNotInitialize",y.WebUSBCouldNotPair="WebUSBCouldNotPair",y.NavigateToDashboard="NavigateToDashboard";var b=function(t){function e(e,r){t.call(this,e),this.name=r,this.type=r,this.message=e,"function"==typeof t.captureStackTrace?t.captureStackTrace(this,this.constructor):this.stack=new t(e).stack}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Error),E=function(e){function r(){e.call(this,"Action cancelled",t.HDWalletErrorType.ActionCancelled)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),_=function(e){function r(){e.call(this,"Device disconnected",t.HDWalletErrorType.DeviceDisconnected)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),T=function(e){function r(){e.call(this,"Ledger device disconnected during operation",t.HDWalletErrorType.DisconnectedDeviceDuringOperation)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),S=function(e){function r(){e.call(this,"Device locked",t.HDWalletErrorType.DeviceLocked)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),g=function(e){function r(){e.call(this,"TrezorConnect popup closed",t.HDWalletErrorType.PopupClosedError)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),m=function(e){function r(r){e.call(this,"Conflicting Application: Another wallet is trying to connect with your "+r+".",t.HDWalletErrorType.ConflictingApp),this.model=r}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),C=function(e){function r(r,o){e.call(this,"Please open the "+o+" app on your "+r+".",t.HDWalletErrorType.SelectApp)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),A=function(e){function r(r,o){e.call(this,"Wrong app open. Please open the "+o+" app on your "+r+" and try again.",t.HDWalletErrorType.WrongApp)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),D=function(e){function r(r,o){e.call(this,"Firmware "+o+" or later is required to use your "+r+" with this client. Please update your device.",t.HDWalletErrorType.FirmwareUpdateRequired)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),w=function(e){function r(){e.call(this,"WebUSB is not available in this browser. We recommend trying Chrome.",t.HDWalletErrorType.WebUSBNotAvailable)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),O=function(e){function r(r,o){e.call(this,"Could not initialize "+r+": "+o,t.HDWalletErrorType.WebUSBCouldNotInitialize)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),j=function(e){function r(r,o){e.call(this,"Could not pair "+r+": "+o,t.HDWalletErrorType.WebUSBCouldNotPair)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b),W=function(e){function r(r){e.call(this,"Please navigate to the dashboard of your "+r+".",t.HDWalletErrorType.NavigateToDashboard)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(b);t.makeEvent=function(t){return Object.assign({},{date:Date.now()},t)},t.DEFAULT_TIMEOUT=5e3,t.LONG_TIMEOUT=3e5,t.isArray=c,t.fromHexString=function(t){var e=t.match(/.{1,2}/g)||[];return new Uint8Array(e.map(function(t){return parseInt(t,16)}))},t.toHexString=function(t){return Array.prototype.map.call(t,function(t){return("00"+t.toString(16)).slice(-2)}).join("")},t.arrayify=function(t){if(null==t)throw new Error("cannot convert null value to array");if("string"==typeof t){var e=t.match(/^(0x)?[0-9a-fA-F]*$/);if(!e)throw new Error("invalid hexidecimal string");if("0x"!==e[1])throw new Error("hex string must have 0x prefix");(t=t.substring(2)).length%2&&(t="0"+t);for(var r=[],o=0;o<t.length;o+=2)r.push(parseInt(t.substr(o,2),16));return new Uint8Array(r)}},t.bip32ToAddressNList=function(t){if(!a(t))throw new Error("Not a bip32 path: '"+t+"'");/^m\//i.test(t)&&(t=t.slice(2));var e=t.split("/");if(1===e.length&&""===e[0])return[];for(var r=new Array(e.length),o=0;o<e.length;o++){var n=/(\d+)([hH\']?)/.exec(e[o]);if(null===n)throw new Error("Invalid input");if(r[o]=parseInt(n[1],10),r[o]>=2147483648)throw new Error("Invalid child index");if("h"===n[2]||"H"===n[2]||"'"===n[2])r[o]+=2147483648;else if(0!==n[2].length)throw new Error("Invalid modifier")}return r},t.addressNListToBIP32=function(t){return"m/"+t.map(function(t){return t>=2147483648?t-2147483648+"'":t}).join("/")},t.bip32Like=a,t.takeFirstOfManyEvents=function(t,o){return e.merge.apply(void 0,o.map(function(r){return e.fromEvent(t,r)})).pipe(r.first())},t.stripHexPrefix=s,t.stripHexPrefixAndLower=function(t){return s(t).toLowerCase()},t.base64toHEX=function(t){for(var e=atob(t),r="",o=0;o<e.length;o++){var n=e.charCodeAt(o).toString(16);r+=2==n.length?n:"0"+n}return"0x"+r.toUpperCase()},t.slip44ByCoin=function(t){return{Bitcoin:0,Testnet:1,BitcoinCash:145,BitcoinGold:156,Litecoin:2,Dash:5,DigiByte:20,Dogecoin:3,BitcoinSV:236,Ethereum:60,Atom:118}[t]},t.satsFromStr=function(t){var e=t.indexOf("."),r=e>0?8-(t.length-e-1):8;return Number(t.replace(/\./g,""))*Math.pow(10,r)},t.hardenedPath=function(t){return t.filter(function(t){return t>=2147483648})},t.relativePath=function(t){return t.filter(function(t){return t<2147483648})},t.Transport=f,t.supportsBTC=function(t){return o.isObject(t)&&t._supportsBTC},t.infoBTC=function(t){return o.isObject(t)&&t._supportsBTCInfo},t.supportsETH=function(t){return o.isObject(t)&&t._supportsETH},t.infoETH=function(t){return o.isObject(t)&&t._supportsETHInfo},t.supportsCosmos=function(t){return o.isObject(t)&&t._supportsCosmos},t.infoCosmos=function(t){return o.isObject(t)&&t._supportsCosmosInfo},t.supportsDebugLink=function(t){return o.isObject(t)&&t._supportsDebugLink},t.Keyring=v,t.HDWalletError=b,t.ActionCancelled=E,t.DeviceDisconnected=_,t.DisconnectedDeviceDuringOperation=T,t.DeviceLocked=S,t.PopupClosedError=g,t.ConflictingApp=m,t.SelectApp=C,t.WrongApp=A,t.FirmwareUpdateRequired=D,t.WebUSBNotAvailable=w,t.WebUSBCouldNotInitialize=O,t.WebUSBCouldNotPair=j,t.NavigateToDashboard=W}); | ||
//# sourceMappingURL=index.umd.js.map |
import { BTCInputScriptType, BTCWallet, BTCWalletInfo } from './bitcoin'; | ||
import { ETHWallet, ETHWalletInfo } from './ethereum'; | ||
import { CosmosWallet, CosmosWalletInfo } from './cosmos'; | ||
import { DebugLinkWallet } from './debuglink'; | ||
@@ -107,2 +108,4 @@ import { Transport } from './transport'; | ||
export declare function infoETH(info: any): info is ETHWalletInfo; | ||
export declare function supportsCosmos(wallet: any): wallet is CosmosWallet; | ||
export declare function infoCosmos(info: any): info is CosmosWalletInfo; | ||
export declare function supportsDebugLink(wallet: any): wallet is DebugLinkWallet; | ||
@@ -112,2 +115,3 @@ export interface HDWalletInfo { | ||
_supportsBTCInfo: boolean; | ||
_supportsCosmosInfo: boolean; | ||
/** | ||
@@ -151,2 +155,3 @@ * Retrieve the wallet's vendor string. | ||
_supportsETH: boolean; | ||
_supportsCosmos: boolean; | ||
_supportsDebugLink: boolean; | ||
@@ -153,0 +158,0 @@ transport: Transport; |
{ | ||
"name": "@shapeshiftoss/hdwallet-core", | ||
"version": "0.17.1", | ||
"version": "0.18.0", | ||
"license": "MIT", | ||
@@ -30,3 +30,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "7e56ad2a2cfe892ba04f324a486f6ef5e35fc003" | ||
"gitHead": "b4d4ddc242db911c9f98bed7c54f737a71c35172" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
232116
21
918