@shapeshiftoss/hdwallet-core
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -1,2 +0,2 @@ | ||
var t,e=require("rxjs"),r=require("rxjs/operators"),o=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 n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(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,c,a,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}(o.EventEmitter2);(p=exports.BTCInputScriptType||(exports.BTCInputScriptType={}))[p.CashAddr=0]="CashAddr",p[p.SpendAddress=1]="SpendAddress",p[p.SpendMultisig=2]="SpendMultisig",p[p.External=3]="External",p[p.SpendWitness=4]="SpendWitness",p[p.SpendP2SHWitness=5]="SpendP2SHWitness",(c=exports.BTCOutputScriptType||(exports.BTCOutputScriptType={}))[c.PayToAddress=0]="PayToAddress",c[c.PayToMultisig=1]="PayToMultisig",c[c.PayToWitness=2]="PayToWitness",c[c.PayToP2SHWitness=3]="PayToP2SHWitness",(a=exports.BTCOutputAddressType||(exports.BTCOutputAddressType={}))[a.Spend=0]="Spend",a[a.Transfer=1]="Transfer",a[a.Change=2]="Change",a[a.Exchange=3]="Exchange";var u=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{f(o,1,i(this.v))}catch(t){f(o,2,t)}return o}return this}return this.o=function(t){try{var n=t.v;1&t.s?f(o,1,e?e(n):n):r?f(o,1,r(n)):f(o,2,n)}catch(t){f(o,2,t)}},o},t}();function f(t,e,r){if(!t.s){if(r instanceof u){if(!r.s)return void(r.o=f.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(f.bind(null,t,e),f.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 h,d=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={initializedCount:{configurable:!0}};return r.initializedCount.get=function(){return Object.keys(this.wallets).length},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]:this.initializedCount&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this;if(!e.get(t))return;var r=function(r,o){try{var n=function(r,o){try{var n=(i=e.get(t),Promise.resolve(i.transport.disconnect()).then(function(){}))}catch(t){return o(t)}var i;return n&&n.then?n.then(void 0,o):n}(0,function(t){console.error(t)})}catch(t){return o(!0,t)}return n&&n.then?n.then(o.bind(null,!1),o.bind(null,!0)):o(!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 r&&r.then?r.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].transport.disconnect()).then(function(){})},s=-1,function t(e){try{for(;++s<r.length;)if((e=o(s))&&e.then){if(!((p=e)instanceof u&&1&p.s))return void e.then(t,i||(i=f.bind(null,n=new u,2)));e=e.v}n?f(n,1,e):n=e}catch(t){f(n||(n=new u),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)}},Object.defineProperties(e.prototype,r),e}(o.EventEmitter2);(h=exports.HDWalletErrorType||(exports.HDWalletErrorType={})).ActionCancelled="ActionCancelled",h.DeviceDisconnected="DeviceDisconnected",h.PopupClosedError="PopupClosedError",h.ConflictingApp="ConflictingApp",h.SelectApp="SelectApp",h.WrongApp="WrongApp",h.FirmwareUpdateRequired="FirmwareUpdateRequired",h.WebUSBNotAvailable="WebUSBNotAvailable",h.WebUSBCouldNotPair="WebUSBCouldNotPair";var y=function(t){function e(e,r){t.call(this,e),t.captureStackTrace(this,this.constructor),this.name=r,this.type=r}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Error),v=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}(y),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}(y),x=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}(y),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}(y),T=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}(y),b=function(t){function e(e,r){t.call(this,"Wrong app selected. Please open the "+r+" app on your "+e+".",exports.HDWalletErrorType.WrongApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(y),_=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}(y),g=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}(y),C=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}(y);exports.makeEvent=function(t){return Object.assign({},{date:Date.now()},t)},exports.DEFAULT_TIMEOUT=5e3,exports.LONG_TIMEOUT=3e5,exports.isArray=n,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(!i(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=i,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,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.Transport=l,exports.supportsBTC=function(t){return void 0!==t._supportsBTC},exports.supportsETH=function(t){return void 0!==t._supportsETH},exports.supportsDebugLink=function(t){return void 0!==t._supportsDebugLink},exports.HDWallet=function(){},exports.BTCWallet=function(){this._supportsBTC=!0},exports.ETHWallet=function(){this._supportsETH=!0},exports.DebugLinkWallet=function(){this._supportsDebugLink=!0},exports.Keyring=d,exports.HDWalletError=y,exports.ActionCancelled=v,exports.DeviceDisconnected=E,exports.PopupClosedError=x,exports.ConflictingApp=S,exports.SelectApp=T,exports.WrongApp=b,exports.FirmwareUpdateRequired=_,exports.WebUSBNotAvailable=g,exports.WebUSBCouldNotPair=C; | ||
var t,e=require("rxjs"),r=require("rxjs/operators"),o=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 n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(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,c,a,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}(o.EventEmitter2);(p=exports.BTCInputScriptType||(exports.BTCInputScriptType={}))[p.CashAddr=0]="CashAddr",p[p.SpendAddress=1]="SpendAddress",p[p.SpendMultisig=2]="SpendMultisig",p[p.External=3]="External",p[p.SpendWitness=4]="SpendWitness",p[p.SpendP2SHWitness=5]="SpendP2SHWitness",(c=exports.BTCOutputScriptType||(exports.BTCOutputScriptType={}))[c.PayToAddress=0]="PayToAddress",c[c.PayToMultisig=1]="PayToMultisig",c[c.PayToWitness=2]="PayToWitness",c[c.PayToP2SHWitness=3]="PayToP2SHWitness",(a=exports.BTCOutputAddressType||(exports.BTCOutputAddressType={}))[a.Spend=0]="Spend",a[a.Transfer=1]="Transfer",a[a.Change=2]="Change",a[a.Exchange=3]="Exchange";var u=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{f(o,1,i(this.v))}catch(t){f(o,2,t)}return o}return this}return this.o=function(t){try{var n=t.v;1&t.s?f(o,1,e?e(n):n):r?f(o,1,r(n)):f(o,2,n)}catch(t){f(o,2,t)}},o},t}();function f(t,e,r){if(!t.s){if(r instanceof u){if(!r.s)return void(r.o=f.bind(null,t,e));1&e&&(e=r.s),r=r.v}if(r&&r.then)return void r.then(f.bind(null,t,e),f.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 h,d=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={initializedCount:{configurable:!0}};return r.initializedCount.get=function(){return Object.keys(this.wallets).length},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]:this.initializedCount&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this;if(!e.get(t))return;var r=function(r,o){try{var n=function(r,o){try{var n=(i=e.get(t),Promise.resolve(i.transport.disconnect()).then(function(){}))}catch(t){return o(t)}var i;return n&&n.then?n.then(void 0,o):n}(0,function(t){console.error(t)})}catch(t){return o(!0,t)}return n&&n.then?n.then(o.bind(null,!1),o.bind(null,!0)):o(!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 r&&r.then?r.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].transport.disconnect()).then(function(){})},s=-1,function t(e){try{for(;++s<r.length;)if((e=o(s))&&e.then){if(!((p=e)instanceof u&&1&p.s))return void e.then(t,i||(i=f.bind(null,n=new u,2)));e=e.v}n?f(n,1,e):n=e}catch(t){f(n||(n=new u),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)}},Object.defineProperties(e.prototype,r),e}(o.EventEmitter2);(h=exports.HDWalletErrorType||(exports.HDWalletErrorType={})).ActionCancelled="ActionCancelled",h.DeviceDisconnected="DeviceDisconnected",h.PopupClosedError="PopupClosedError",h.ConflictingApp="ConflictingApp",h.SelectApp="SelectApp",h.WrongApp="WrongApp",h.FirmwareUpdateRequired="FirmwareUpdateRequired",h.WebUSBNotAvailable="WebUSBNotAvailable",h.WebUSBCouldNotPair="WebUSBCouldNotPair";var y=function(t){function e(e,r){t.call(this,e),t.captureStackTrace(this,this.constructor),this.name=r,this.type=r}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Error),v=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}(y),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}(y),x=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}(y),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}(y),T=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}(y),b=function(t){function e(e,r){t.call(this,"Wrong app selected. Please open the "+r+" app on your "+e+".",exports.HDWalletErrorType.WrongApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(y),_=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}(y),g=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}(y),C=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}(y);exports.makeEvent=function(t){return Object.assign({},{date:Date.now()},t)},exports.DEFAULT_TIMEOUT=5e3,exports.LONG_TIMEOUT=3e5,exports.isArray=n,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(!i(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=i,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.Transport=l,exports.supportsBTC=function(t){return void 0!==t._supportsBTC},exports.supportsETH=function(t){return void 0!==t._supportsETH},exports.supportsDebugLink=function(t){return void 0!==t._supportsDebugLink},exports.HDWallet=function(){},exports.BTCWallet=function(){this._supportsBTC=!0},exports.ETHWallet=function(){this._supportsETH=!0},exports.DebugLinkWallet=function(){this._supportsDebugLink=!0},exports.Keyring=d,exports.HDWalletError=y,exports.ActionCancelled=v,exports.DeviceDisconnected=E,exports.PopupClosedError=x,exports.ConflictingApp=S,exports.SelectApp=T,exports.WrongApp=b,exports.FirmwareUpdateRequired=_,exports.WebUSBNotAvailable=g,exports.WebUSBCouldNotPair=C; | ||
//# 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{EventEmitter2 as n}from"eventemitter2";var o;function i(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"}(o||(o={}));var c=5e3,a=3e5,s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},u=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 p(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 f=2147483648;function h(t){if(!y(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]>=f)throw new Error("Invalid child index");if("h"===o[2]||"H"===o[2]||"'"===o[2])r[n]+=f;else if(0!==o[2].length)throw new Error("Invalid modifier")}return r}function d(t){return"m/"+t.map(function(t){return t>=f?t-f+"'":t}).join("/")}function y(t){return"m/"==t||/^m(((\/[0-9]+h)+|(\/[0-9]+H)+|(\/[0-9]+')*)((\/[0-9]+)*))$/.test(t)}function v(n,o){return e.apply(void 0,o.map(function(e){return t(n,e)})).pipe(r())}function S(t){return t.replace("0x","")}function _(t){return S(t).toLowerCase()}function b(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,Dogecoin:3,BitcoinSV:236,Ethereum:60}[t]}function g(t){var e=t.indexOf("."),r=e>0?8-(t.length-e-1):8;return Number(t.replace(/\./g,""))*Math.pow(10,r)}var E=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);function A(t){return void 0!==t._supportsBTC}function w(t){return void 0!==t._supportsETH}function C(t){return void 0!==t._supportsDebugLink}var P,T,j,O=function(){};!function(t){t[t.CashAddr=0]="CashAddr",t[t.SpendAddress=1]="SpendAddress",t[t.SpendMultisig=2]="SpendMultisig",t[t.External=3]="External",t[t.SpendWitness=4]="SpendWitness",t[t.SpendP2SHWitness=5]="SpendP2SHWitness"}(P||(P={})),function(t){t[t.PayToAddress=0]="PayToAddress",t[t.PayToMultisig=1]="PayToMultisig",t[t.PayToWitness=2]="PayToWitness",t[t.PayToP2SHWitness=3]="PayToP2SHWitness"}(T||(T={})),function(t){t[t.Spend=0]="Spend",t[t.Transfer=1]="Transfer",t[t.Change=2]="Change",t[t.Exchange=3]="Exchange"}(j||(j={}));var U=function(){this._supportsBTC=!0},R=function(){this._supportsETH=!0},N=function(){this._supportsDebugLink=!0},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{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 W){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 D,B=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={initializedCount:{configurable:!0}};return r.initializedCount.get=function(){return Object.keys(this.wallets).length},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]:this.initializedCount&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this;if(!e.get(t))return;var r=function(r,n){try{var o=function(r,n){try{var o=(i=e.get(t),Promise.resolve(i.transport.disconnect()).then(function(){}))}catch(t){return n(t)}var i;return o&&o.then?o.then(void 0,n):o}(0,function(t){console.error(t)})}catch(t){return n(!0,t)}return o&&o.then?o.then(n.bind(null,!1),n.bind(null,!0)):n(!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 r&&r.then?r.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].transport.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=x.bind(null,o=new W,2)));e=e.v}o?x(o,1,e):o=e}catch(t){x(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)}},Object.defineProperties(e.prototype,r),e}(n);!function(t){t.ActionCancelled="ActionCancelled",t.DeviceDisconnected="DeviceDisconnected",t.PopupClosedError="PopupClosedError",t.ConflictingApp="ConflictingApp",t.SelectApp="SelectApp",t.WrongApp="WrongApp",t.FirmwareUpdateRequired="FirmwareUpdateRequired",t.WebUSBNotAvailable="WebUSBNotAvailable",t.WebUSBCouldNotPair="WebUSBCouldNotPair"}(D||(D={}));var I=function(t){function e(e,r){t.call(this,e),t.captureStackTrace(this,this.constructor),this.name=r,this.type=r}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",D.ActionCancelled)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),Q=function(t){function e(){t.call(this,"Device disconnected",D.DeviceDisconnected)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),k=function(t){function e(){t.call(this,"TrezorConnect popup closed",D.PopupClosedError)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),L=function(t){function e(e){t.call(this,"Conflicting Application: Another wallet is trying to connect with your "+e+".",D.ConflictingApp),this.model=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),F=function(t){function e(e,r){t.call(this,"Please open the "+r+" app on your "+e+".",D.SelectApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),M=function(t){function e(e,r){t.call(this,"Wrong app selected. Please open the "+r+" app on your "+e+".",D.WrongApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),q=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.",D.FirmwareUpdateRequired)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),z=function(t){function e(){t.call(this,"WebUSB is not available in this browser. We recommend trying Chrome.",D.WebUSBNotAvailable)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),V=function(t){function e(e,r){t.call(this,"Could not pair "+e+": "+r,D.WebUSBCouldNotPair)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I);export{o as Events,i as makeEvent,c as DEFAULT_TIMEOUT,a as LONG_TIMEOUT,s as isArray,u as fromHexString,l as toHexString,p as arrayify,h as bip32ToAddressNList,d as addressNListToBIP32,y as bip32Like,v as takeFirstOfManyEvents,S as stripHexPrefix,_ as stripHexPrefixAndLower,b as base64toHEX,m as slip44ByCoin,g as satsFromStr,E as Transport,A as supportsBTC,w as supportsETH,C as supportsDebugLink,O as HDWallet,P as BTCInputScriptType,T as BTCOutputScriptType,j as BTCOutputAddressType,U as BTCWallet,R as ETHWallet,N as DebugLinkWallet,B as Keyring,D as HDWalletErrorType,I as HDWalletError,H as ActionCancelled,Q as DeviceDisconnected,k as PopupClosedError,L as ConflictingApp,F as SelectApp,M as WrongApp,q as FirmwareUpdateRequired,z as WebUSBNotAvailable,V as WebUSBCouldNotPair}; | ||
import{fromEvent as t,merge as e}from"rxjs";import{first as r}from"rxjs/operators";import{EventEmitter2 as n}from"eventemitter2";var o;function i(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"}(o||(o={}));var c=5e3,a=3e5,s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},u=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 p(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 f=2147483648;function h(t){if(!y(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]>=f)throw new Error("Invalid child index");if("h"===o[2]||"H"===o[2]||"'"===o[2])r[n]+=f;else if(0!==o[2].length)throw new Error("Invalid modifier")}return r}function d(t){return"m/"+t.map(function(t){return t>=f?t-f+"'":t}).join("/")}function y(t){return"m/"==t||/^m(((\/[0-9]+h)+|(\/[0-9]+H)+|(\/[0-9]+')*)((\/[0-9]+)*))$/.test(t)}function v(n,o){return e.apply(void 0,o.map(function(e){return t(n,e)})).pipe(r())}function S(t){return t.replace("0x","")}function _(t){return S(t).toLowerCase()}function b(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 g(t){var e=t.indexOf("."),r=e>0?8-(t.length-e-1):8;return Number(t.replace(/\./g,""))*Math.pow(10,r)}var E=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);function A(t){return void 0!==t._supportsBTC}function w(t){return void 0!==t._supportsETH}function C(t){return void 0!==t._supportsDebugLink}var P,T,j,O=function(){};!function(t){t[t.CashAddr=0]="CashAddr",t[t.SpendAddress=1]="SpendAddress",t[t.SpendMultisig=2]="SpendMultisig",t[t.External=3]="External",t[t.SpendWitness=4]="SpendWitness",t[t.SpendP2SHWitness=5]="SpendP2SHWitness"}(P||(P={})),function(t){t[t.PayToAddress=0]="PayToAddress",t[t.PayToMultisig=1]="PayToMultisig",t[t.PayToWitness=2]="PayToWitness",t[t.PayToP2SHWitness=3]="PayToP2SHWitness"}(T||(T={})),function(t){t[t.Spend=0]="Spend",t[t.Transfer=1]="Transfer",t[t.Change=2]="Change",t[t.Exchange=3]="Exchange"}(j||(j={}));var U=function(){this._supportsBTC=!0},R=function(){this._supportsETH=!0},N=function(){this._supportsDebugLink=!0},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{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 W){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 D,B=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={initializedCount:{configurable:!0}};return r.initializedCount.get=function(){return Object.keys(this.wallets).length},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]:this.initializedCount&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this;if(!e.get(t))return;var r=function(r,n){try{var o=function(r,n){try{var o=(i=e.get(t),Promise.resolve(i.transport.disconnect()).then(function(){}))}catch(t){return n(t)}var i;return o&&o.then?o.then(void 0,n):o}(0,function(t){console.error(t)})}catch(t){return n(!0,t)}return o&&o.then?o.then(n.bind(null,!1),n.bind(null,!0)):n(!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 r&&r.then?r.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].transport.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=x.bind(null,o=new W,2)));e=e.v}o?x(o,1,e):o=e}catch(t){x(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)}},Object.defineProperties(e.prototype,r),e}(n);!function(t){t.ActionCancelled="ActionCancelled",t.DeviceDisconnected="DeviceDisconnected",t.PopupClosedError="PopupClosedError",t.ConflictingApp="ConflictingApp",t.SelectApp="SelectApp",t.WrongApp="WrongApp",t.FirmwareUpdateRequired="FirmwareUpdateRequired",t.WebUSBNotAvailable="WebUSBNotAvailable",t.WebUSBCouldNotPair="WebUSBCouldNotPair"}(D||(D={}));var I=function(t){function e(e,r){t.call(this,e),t.captureStackTrace(this,this.constructor),this.name=r,this.type=r}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",D.ActionCancelled)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),Q=function(t){function e(){t.call(this,"Device disconnected",D.DeviceDisconnected)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),k=function(t){function e(){t.call(this,"TrezorConnect popup closed",D.PopupClosedError)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),L=function(t){function e(e){t.call(this,"Conflicting Application: Another wallet is trying to connect with your "+e+".",D.ConflictingApp),this.model=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),F=function(t){function e(e,r){t.call(this,"Please open the "+r+" app on your "+e+".",D.SelectApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),M=function(t){function e(e,r){t.call(this,"Wrong app selected. Please open the "+r+" app on your "+e+".",D.WrongApp)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),q=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.",D.FirmwareUpdateRequired)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),z=function(t){function e(){t.call(this,"WebUSB is not available in this browser. We recommend trying Chrome.",D.WebUSBNotAvailable)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I),V=function(t){function e(e,r){t.call(this,"Could not pair "+e+": "+r,D.WebUSBCouldNotPair)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(I);export{o as Events,i as makeEvent,c as DEFAULT_TIMEOUT,a as LONG_TIMEOUT,s as isArray,u as fromHexString,l as toHexString,p as arrayify,h as bip32ToAddressNList,d as addressNListToBIP32,y as bip32Like,v as takeFirstOfManyEvents,S as stripHexPrefix,_ as stripHexPrefixAndLower,b as base64toHEX,m as slip44ByCoin,g as satsFromStr,E as Transport,A as supportsBTC,w as supportsETH,C as supportsDebugLink,O as HDWallet,P as BTCInputScriptType,T as BTCOutputScriptType,j as BTCOutputAddressType,U as BTCWallet,R as ETHWallet,N as DebugLinkWallet,B as Keyring,D as HDWalletErrorType,I as HDWalletError,H as ActionCancelled,Q as DeviceDisconnected,k as PopupClosedError,L as ConflictingApp,F as SelectApp,M as WrongApp,q as FirmwareUpdateRequired,z as WebUSBNotAvailable,V as WebUSBCouldNotPair}; | ||
//# 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("eventemitter2")):"function"==typeof define&&define.amd?define(["exports","rxjs","rxjs/operators","eventemitter2"],e):e(t.core={},t.rxjs,t.operators,t.eventemitter2)}(this,function(t,e,r,n){var o;(o=t.Events||(t.Events={})).BUTTON_REQUEST="BUTTON_REQUEST",o.CANCEL="CANCEL",o.CHARACTER_REQUEST="CHARACTER_REQUEST",o.CONNECT="CONNECT",o.DISCONNECT="DISCONNECT",o.FAILURE="FAILURE",o.PASSPHRASE_REQUEST="PASSPHRASE_REQUEST",o.PIN_REQUEST="PIN_REQUEST",o.SUCCESS="SUCCESS",o.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 a(t){return t.replace("0x","")}var s,p,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);(s=t.BTCInputScriptType||(t.BTCInputScriptType={}))[s.CashAddr=0]="CashAddr",s[s.SpendAddress=1]="SpendAddress",s[s.SpendMultisig=2]="SpendMultisig",s[s.External=3]="External",s[s.SpendWitness=4]="SpendWitness",s[s.SpendP2SHWitness=5]="SpendP2SHWitness",(p=t.BTCOutputScriptType||(t.BTCOutputScriptType={}))[p.PayToAddress=0]="PayToAddress",p[p.PayToMultisig=1]="PayToMultisig",p[p.PayToWitness=2]="PayToWitness",p[p.PayToP2SHWitness=3]="PayToP2SHWitness",(u=t.BTCOutputAddressType||(t.BTCOutputAddressType={}))[u.Spend=0]="Spend",u[u.Transfer=1]="Transfer",u[u.Change=2]="Change",u[u.Exchange=3]="Exchange";var f=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 f){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 h,y=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={initializedCount:{configurable:!0}};return r.initializedCount.get=function(){return Object.keys(this.wallets).length},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]:this.initializedCount&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this;if(!e.get(t))return;var r=function(r,n){try{var o=function(r,n){try{var o=(i=e.get(t),Promise.resolve(i.transport.disconnect()).then(function(){}))}catch(t){return n(t)}var i;return o&&o.then?o.then(void 0,n):o}(0,function(t){console.error(t)})}catch(t){return n(!0,t)}return o&&o.then?o.then(n.bind(null,!1),n.bind(null,!0)):n(!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 r&&r.then?r.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].transport.disconnect()).then(function(){})},c=-1,function t(e){try{for(;++c<r.length;)if((e=n(c))&&e.then){if(!((a=e)instanceof f&&1&a.s))return void e.then(t,i||(i=d.bind(null,o=new f,2)));e=e.v}o?d(o,1,e):o=e}catch(t){d(o||(o=new f),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)}},Object.defineProperties(e.prototype,r),e}(n.EventEmitter2);(h=t.HDWalletErrorType||(t.HDWalletErrorType={})).ActionCancelled="ActionCancelled",h.DeviceDisconnected="DeviceDisconnected",h.PopupClosedError="PopupClosedError",h.ConflictingApp="ConflictingApp",h.SelectApp="SelectApp",h.WrongApp="WrongApp",h.FirmwareUpdateRequired="FirmwareUpdateRequired",h.WebUSBNotAvailable="WebUSBNotAvailable",h.WebUSBCouldNotPair="WebUSBCouldNotPair";var v=function(t){function e(e,r){t.call(this,e),t.captureStackTrace(this,this.constructor),this.name=r,this.type=r}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}(v),S=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}(v),T=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}(v),b=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}(v),_=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}(v),m=function(e){function r(r,n){e.call(this,"Wrong app selected. Please open the "+n+" app on your "+r+".",t.HDWalletErrorType.WrongApp)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(v),g=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}(v),C=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}(v),A=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}(v);t.makeEvent=function(t){return Object.assign({},{date:Date.now()},t)},t.DEFAULT_TIMEOUT=5e3,t.LONG_TIMEOUT=3e5,t.isArray=i,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(!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),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=c,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=a,t.stripHexPrefixAndLower=function(t){return a(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,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.Transport=l,t.supportsBTC=function(t){return void 0!==t._supportsBTC},t.supportsETH=function(t){return void 0!==t._supportsETH},t.supportsDebugLink=function(t){return void 0!==t._supportsDebugLink},t.HDWallet=function(){},t.BTCWallet=function(){this._supportsBTC=!0},t.ETHWallet=function(){this._supportsETH=!0},t.DebugLinkWallet=function(){this._supportsDebugLink=!0},t.Keyring=y,t.HDWalletError=v,t.ActionCancelled=E,t.DeviceDisconnected=S,t.PopupClosedError=T,t.ConflictingApp=b,t.SelectApp=_,t.WrongApp=m,t.FirmwareUpdateRequired=g,t.WebUSBNotAvailable=C,t.WebUSBCouldNotPair=A}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rxjs"),require("rxjs/operators"),require("eventemitter2")):"function"==typeof define&&define.amd?define(["exports","rxjs","rxjs/operators","eventemitter2"],e):e(t.core={},t.rxjs,t.operators,t.eventemitter2)}(this,function(t,e,r,n){var o;(o=t.Events||(t.Events={})).BUTTON_REQUEST="BUTTON_REQUEST",o.CANCEL="CANCEL",o.CHARACTER_REQUEST="CHARACTER_REQUEST",o.CONNECT="CONNECT",o.DISCONNECT="DISCONNECT",o.FAILURE="FAILURE",o.PASSPHRASE_REQUEST="PASSPHRASE_REQUEST",o.PIN_REQUEST="PIN_REQUEST",o.SUCCESS="SUCCESS",o.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 a(t){return t.replace("0x","")}var s,p,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);(s=t.BTCInputScriptType||(t.BTCInputScriptType={}))[s.CashAddr=0]="CashAddr",s[s.SpendAddress=1]="SpendAddress",s[s.SpendMultisig=2]="SpendMultisig",s[s.External=3]="External",s[s.SpendWitness=4]="SpendWitness",s[s.SpendP2SHWitness=5]="SpendP2SHWitness",(p=t.BTCOutputScriptType||(t.BTCOutputScriptType={}))[p.PayToAddress=0]="PayToAddress",p[p.PayToMultisig=1]="PayToMultisig",p[p.PayToWitness=2]="PayToWitness",p[p.PayToP2SHWitness=3]="PayToP2SHWitness",(u=t.BTCOutputAddressType||(t.BTCOutputAddressType={}))[u.Spend=0]="Spend",u[u.Transfer=1]="Transfer",u[u.Change=2]="Change",u[u.Exchange=3]="Exchange";var f=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 f){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 h,y=function(t){function e(){t.call(this,{wildcard:!0}),this.wallets={},this.aliases={}}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var r={initializedCount:{configurable:!0}};return r.initializedCount.get=function(){return Object.keys(this.wallets).length},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]:this.initializedCount&&!t?Object.values(this.wallets)[0]:null},e.prototype.remove=function(t){try{var e=this;if(!e.get(t))return;var r=function(r,n){try{var o=function(r,n){try{var o=(i=e.get(t),Promise.resolve(i.transport.disconnect()).then(function(){}))}catch(t){return n(t)}var i;return o&&o.then?o.then(void 0,n):o}(0,function(t){console.error(t)})}catch(t){return n(!0,t)}return o&&o.then?o.then(n.bind(null,!1),n.bind(null,!0)):n(!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 r&&r.then?r.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].transport.disconnect()).then(function(){})},c=-1,function t(e){try{for(;++c<r.length;)if((e=n(c))&&e.then){if(!((a=e)instanceof f&&1&a.s))return void e.then(t,i||(i=d.bind(null,o=new f,2)));e=e.v}o?d(o,1,e):o=e}catch(t){d(o||(o=new f),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)}},Object.defineProperties(e.prototype,r),e}(n.EventEmitter2);(h=t.HDWalletErrorType||(t.HDWalletErrorType={})).ActionCancelled="ActionCancelled",h.DeviceDisconnected="DeviceDisconnected",h.PopupClosedError="PopupClosedError",h.ConflictingApp="ConflictingApp",h.SelectApp="SelectApp",h.WrongApp="WrongApp",h.FirmwareUpdateRequired="FirmwareUpdateRequired",h.WebUSBNotAvailable="WebUSBNotAvailable",h.WebUSBCouldNotPair="WebUSBCouldNotPair";var v=function(t){function e(e,r){t.call(this,e),t.captureStackTrace(this,this.constructor),this.name=r,this.type=r}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}(v),S=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}(v),T=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}(v),b=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}(v),_=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}(v),g=function(e){function r(r,n){e.call(this,"Wrong app selected. Please open the "+n+" app on your "+r+".",t.HDWalletErrorType.WrongApp)}return e&&(r.__proto__=e),(r.prototype=Object.create(e&&e.prototype)).constructor=r,r}(v),m=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}(v),C=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}(v),A=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}(v);t.makeEvent=function(t){return Object.assign({},{date:Date.now()},t)},t.DEFAULT_TIMEOUT=5e3,t.LONG_TIMEOUT=3e5,t.isArray=i,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(!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),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=c,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=a,t.stripHexPrefixAndLower=function(t){return a(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.Transport=l,t.supportsBTC=function(t){return void 0!==t._supportsBTC},t.supportsETH=function(t){return void 0!==t._supportsETH},t.supportsDebugLink=function(t){return void 0!==t._supportsDebugLink},t.HDWallet=function(){},t.BTCWallet=function(){this._supportsBTC=!0},t.ETHWallet=function(){this._supportsETH=!0},t.DebugLinkWallet=function(){this._supportsDebugLink=!0},t.Keyring=y,t.HDWalletError=v,t.ActionCancelled=E,t.DeviceDisconnected=S,t.PopupClosedError=T,t.ConflictingApp=b,t.SelectApp=_,t.WrongApp=g,t.FirmwareUpdateRequired=m,t.WebUSBNotAvailable=C,t.WebUSBCouldNotPair=A}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@shapeshiftoss/hdwallet-core", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"license": "MIT", | ||
@@ -29,3 +29,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "8b994454836409ee20cefb6e8be2388f83a8a016" | ||
"gitHead": "a63fdfd14d8b808746f001f24a5e8dbec4866ee0" | ||
} |
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
223293