owallet.js
Version:
Very lightweight Obyte wallet. It works everywhere where you can run JS.
1 lines • 436 kB
JavaScript
!function e(t,r,n){function i(a,s){if(!r[a]){if(!t[a]){var f="function"==typeof require&&require;if(!s&&f)return f(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[a]={exports:{}};t[a][0].call(u.exports,(function(e){return i(t[a][1][e]||e)}),u,u.exports,e,t,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a<n.length;a++)i(n[a]);return i}({1:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.DEFAULT_NODE="wss://obyte.org/bb",r.VERSION="1.0",r.VERSION_TESTNET="2.0t",r.VERSION_WITHOUT_TIMESTAMP="1.0",r.ALT="1",r.ALT_TESTNET="2"},{}],2:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.toPublicKey=r.sign=r.mapAPI=r.createPaymentMessage=r.repeatString=r.camelCase=void 0;var n,i=y(e("babel-runtime/helpers/typeof")),o=y(e("babel-runtime/core-js/json/stringify")),a=y(e("babel-runtime/helpers/defineProperty")),s=y(e("babel-runtime/helpers/extends")),f=y(e("babel-runtime/core-js/object/keys")),c=y(e("babel-runtime/regenerator")),u=y(e("babel-runtime/helpers/toConsumableArray")),h=y(e("babel-runtime/helpers/asyncToGenerator"));r.createPaymentMessage=(n=(0,h.default)(c.default.mark((function e(t,r,n,i,o){var a,s,f,h,d;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=n.reduce((function(e,t){return e+t.amount}),0),s=r?a:1e3+a,e.next=4,t.api.pickDivisibleCoinsForAmount({addresses:[i],last_ball_mci:1e15,amount:s,spend_unconfirmed:o||"own",asset:r});case 4:return f=e.sent,h=f.inputs_with_proofs.map((function(e){return e.input})),d={inputs:h,outputs:[{address:i,amount:f.total_amount-a}].concat((0,u.default)(n))},r&&(d.asset=r),e.abrupt("return",{app:"payment",payload_hash:"--------------------------------------------",payload_location:"inline",payload:d});case 9:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,o){return n.apply(this,arguments)});r.sortOutputs=function(e,t){return e.address.localeCompare(t.address)||e.amount-t.amount},r.getSourceString=k,r.getJsonSourceString=A,r.isChashValid=function(e){var r=e.length,n=void 0;if(32!==r&&48!==r)throw Error("wrong encoded length: "+r);try{n=32===r?p.default.decode(e):t.from(e,"base64")}catch(e){return console.log(e),!1}var i=function(e){var t=e.length,r=void 0;if(160===t)r=x;else{if(288!==t)throw Error("bad length="+t+", bin = "+e);r=M}for(var n=[],i=[],o=0,a=0;a<r.length;a+=1)n.push(e.substring(o,r[a])),i.push(e.substr(r[a],1)),o=r[a]+1;o<e.length&&n.push(e.substring(o));var s=n.join(""),f=i.join("");return{cleanData:s,checksum:f}}(v(n)),o=_(i.cleanData);return _(i.checksum).equals(E(o))},r.chashGetChash160=function(e){return function(e,t){w(t);var r=(0,l.default)(160===t?"ripemd160":"sha256").update(e,"utf8").digest(),n=160===t?r.slice(4):r,i=E(n),o=v(n),a=v(i),s=_(function(e,t){if(32!==t.length)throw Error("bad checksum length");var r=e.length+t.length,n=void 0;if(160===r)n=x;else{if(288!==r)throw Error("bad length="+r+", clean data = "+e+", checksum = "+t);n=M}for(var i=[],o=t.split(""),a=0,s=0;s<n.length;s+=1){var f=n[s]-s;i.push(e.substring(a,f)),i.push(o[s]),a=f}a<e.length&&i.push(e.substring(a));return i.join("")}(o,a));return 160===t?p.default.encode(s).toString():s.toString("base64")}(e,160)},r.getHeadersSize=function(e){if(e.content_hash)throw Error("trying to get headers size of stripped unit");var t=JSON.parse((0,o.default)(e));delete t.unit,delete t.headers_commission,delete t.payload_commission,delete t.main_chain_index,e.version===b.VERSION_WITHOUT_TIMESTAMP&&delete t.timestamp;return delete t.messages,delete t.parent_units,j(t)+88},r.getTotalPayloadSize=function(e){if(e.content_hash)throw Error("trying to get payload size of stripped unit");return j(e.messages)},r.getBase64Hash=T,r.getUnitHashToSign=function(e){for(var t=S(e),r=0;r<t.authors.length;r+=1)delete t.authors[r].authentifiers;var n=e.version===b.VERSION_WITHOUT_TIMESTAMP?k(t):A(t);return(0,l.default)("sha256").update(n,"utf8").digest()},r.getUnitHash=function(e){var t=e.version!==b.VERSION_WITHOUT_TIMESTAMP;if(e.content_hash)return T(S(e),t);var r={content_hash:B(e),version:e.version,alt:e.alt,authors:e.authors.map((function(e){return{address:e.address}}))};e.witness_list_unit?r.witness_list_unit=e.witness_list_unit:r.witnesses=e.witnesses;e.parent_units&&(r.parent_units=e.parent_units,r.last_ball=e.last_ball,r.last_ball_unit=e.last_ball_unit);t&&(r.timestamp=e.timestamp);return T(r,t)};var d=y(e("secp256k1")),l=y(e("create-hash")),p=y(e("thirty-two")),b=e("./constants");function y(e){return e&&e.__esModule?e:{default:e}}var m="14159265358979323846264338327950288419716939937510".split(""),g=r.camelCase=function(e){return e.split("/").pop().split("_").map((function(e){return e.charAt(0).toUpperCase()+e.slice(1)})).join("").replace(/^\w/,(function(e){return e.toLowerCase()}))};r.repeatString=function(e,t){return e.repeat?e.repeat(t):new Array(t+1).join(e)};r.mapAPI=function(e,t){return(0,f.default)(e).reduce((function(e,r){return(0,s.default)({},e,(0,a.default)({},g(r),(function(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];var o=0!==n.length?n[n.length-1]:null;"function"==typeof o?n=n.slice(0,-1):o=null;var a=t.apply(void 0,[r].concat((0,u.default)(n)));return o?a.then((function(e){return o(null,e)})).catch((function(e){return o(e,null)})):a})))}),{})},r.sign=function(e,t){return d.default.sign(e,t).signature.toString("base64")};function v(e){for(var t=[],r=0;r<e.length;r+=1){var n=e[r].toString(2);n.length<8&&(n="00000000".substring(n.length,8)+n),t.push(n)}return t.join("")}function _(e){for(var r=e.length/8,n=t.alloc(r),i=0;i<r;i+=1)n[i]=parseInt(e.substr(8*i,8),2);return n}function w(e){if(160!==e&&288!==e)throw Error("unsupported c-hash length: "+e)}function E(e){var r=(0,l.default)("sha256").update(e).digest();return t.from([r[5],r[13],r[21],r[29]])}function S(e){var t=JSON.parse((0,o.default)(e));if(delete t.unit,delete t.headers_commission,delete t.payload_commission,delete t.main_chain_index,e.version===b.VERSION_WITHOUT_TIMESTAMP&&delete t.timestamp,t.messages)for(var r=0;r<t.messages.length;r+=1)delete t.messages[r].payload,delete t.messages[r].payload_uri;return t}function k(e){var t=[];return function r(n){if(null===n)throw Error("null value in "+(0,o.default)(e));switch(void 0===n?"undefined":(0,i.default)(n)){case"string":t.push("s",n);break;case"number":t.push("n",n.toString());break;case"boolean":t.push("b",n.toString());break;case"object":if(Array.isArray(n)){if(0===n.length)throw Error("empty array in "+(0,o.default)(e));t.push("[");for(var a=0;a<n.length;a+=1)r(n[a]);t.push("]")}else{var s=(0,f.default)(n).sort();if(0===s.length)throw Error("empty object in "+(0,o.default)(e));s.forEach((function(i){if(void 0===n[i])throw Error("undefined at "+i+" of "+(0,o.default)(e));t.push(i),r(n[i])}))}break;default:throw Error("hash: unknown type="+(void 0===n?"undefined":(0,i.default)(n))+" of "+n+", object: "+(0,o.default)(e))}}(e),t.join("\0")}function A(e){return function t(r){if(null===r)throw Error("null value in "+(0,o.default)(e));switch(void 0===r?"undefined":(0,i.default)(r)){case"string":return(0,o.default)(r);case"number":case"boolean":return r.toString();case"object":if(Array.isArray(r)){if(0===r.length)throw Error("empty array in "+(0,o.default)(e));return"["+r.map(t).join(",")+"]"}var n=(0,f.default)(r).sort();if(0===n.length)throw Error("empty object in "+(0,o.default)(e));return"{"+n.map((function(e){return(0,o.default)(e)+":"+t(r[e])})).join(",")+"}";default:throw Error("hash: unknown type="+(void 0===r?"undefined":(0,i.default)(r))+" of "+r+", object: "+(0,o.default)(e))}}(e)}function I(e){w(e);for(var t=[],r=0,n=0,i=0;r<e;i+=1){var o=parseInt(m[i],10);if(0!==o){if(r+=o,288===e&&(r+=4),r>=e)break;t.push(r),n+=1}}if(32!==n)throw Error("wrong number of checksum bits");return t}var x=I(160),M=I(288);r.toPublicKey=function(e){return d.default.publicKeyCreate(e).toString("base64")};function j(e){if(null===e)return 0;switch(void 0===e?"undefined":(0,i.default)(e)){case"string":return e.length;case"number":return 8;case"object":var t=0;return Array.isArray(e)?e.forEach((function(e){t+=j(e)})):(0,f.default)(e).forEach((function(r){if(void 0===e[r])throw Error("undefined at "+r+" of "+(0,o.default)(e));t+=j(e[r])})),t;case"boolean":return 1;default:throw Error("unknown type="+(void 0===e?"undefined":(0,i.default)(e))+" of "+e)}}function T(e,t){var r=t?A(e):k(e);return(0,l.default)("sha256").update(r,"utf8").digest("base64")}function B(e){return T(S(e),e.version!==b.VERSION_WITHOUT_TIMESTAMP)}}).call(this,e("buffer").Buffer)},{"./constants":1,"babel-runtime/core-js/json/stringify":19,"babel-runtime/core-js/object/keys":22,"babel-runtime/helpers/asyncToGenerator":26,"babel-runtime/helpers/defineProperty":27,"babel-runtime/helpers/extends":28,"babel-runtime/helpers/toConsumableArray":29,"babel-runtime/helpers/typeof":30,"babel-runtime/regenerator":33,buffer:77,"create-hash":178,secp256k1:271,"thirty-two":287}],3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./internal");r.default={getChash160:function(e){var t=Array.isArray(e)&&2===e.length&&"autonomous agent"===e[0]?(0,n.getJsonSourceString)(e):(0,n.getSourceString)(e);return(0,n.chashGetChash160)(t)},isValidAddress:function(e){return"string"==typeof e&&e===e.toUpperCase()&&32===e.length&&(0,n.isChashValid)(e)}},t.exports=r.default},{"./internal":2}],4:[function(e,t,r){var n=r;n.bignum=e("bn.js"),n.define=e("./asn1/api").define,n.base=e("./asn1/base"),n.constants=e("./asn1/constants"),n.decoders=e("./asn1/decoders"),n.encoders=e("./asn1/encoders")},{"./asn1/api":5,"./asn1/base":7,"./asn1/constants":11,"./asn1/decoders":13,"./asn1/encoders":16,"bn.js":43}],5:[function(e,t,r){var n=e("../asn1"),i=e("inherits");function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}r.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(t){var r;try{r=e("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){r=function(e){this._initNamed(e)}}return i(r,t),r.prototype._initNamed=function(e){t.call(this,e)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},{"../asn1":4,inherits:226,vm:297}],6:[function(e,t,r){var n=e("inherits"),i=e("../base").Reporter,o=e("buffer").Buffer;function a(e,t){i.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(a,i),r.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},r.EncoderBuffer=s,s.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e}},{"../base":7,buffer:77,inherits:226}],7:[function(e,t,r){var n=r;n.Reporter=e("./reporter").Reporter,n.DecoderBuffer=e("./buffer").DecoderBuffer,n.EncoderBuffer=e("./buffer").EncoderBuffer,n.Node=e("./node")},{"./buffer":6,"./node":8,"./reporter":9}],8:[function(e,t,r){var n=e("../base").Reporter,i=e("../base").EncoderBuffer,o=e("../base").DecoderBuffer,a=e("minimalistic-assert"),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],f=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}t.exports=c;var u=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};u.forEach((function(r){t[r]=e[r]}));var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;f.forEach((function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},c.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);var n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),s.forEach((function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}})),c.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},c.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){var f=null;if(null!==r.explicit?f=r.explicit:null!==r.implicit?f=r.implicit:null!==r.tag&&(f=r.tag),null!==f||r.any){if(a=this._peekTag(e,f,r.any),e.isError(a))return a}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(c)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){var u=this._decodeTag(e,r.explicit);if(e.isError(u))return u;e=u}var h=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var d=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(d))return d;r.any?i=e.raw(c):e=d}if(t&&t.track&&null!==r.tag&&t.track(e.path(),h,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),i=r.any?i:null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach((function(r){r._decode(e,t)})),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var l=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(l,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},c.prototype._decodeGeneric=function(e,t,r){var n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some((function(o){var a=e.save(),s=r.choice[o];try{var f=s._decode(e,t);if(e.isError(f))return!1;n={type:o,value:f},i=!0}catch(t){return e.restore(a),!1}return!0}),this),i?n:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},c.prototype._encode=function(e,t,r){var n=this._baseState;if(null===n.default||n.default!==e){var i=this._encodeValue(e,t,r);if(void 0!==i&&!this._skipDefault(i,t,r))return i}},c.prototype._encodeValue=function(e,t,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);var o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}var a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map((function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i}),this).filter((function(e){return e})),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var f=this.clone();f._baseState.implicit=null,a=this._createEncoderBuffer(e.map((function(r){var n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)}),f))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){var c=null!==i.implicit?i.implicit:i.tag,u=null===i.implicit?"universal":"context";null===c?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(c,s,u,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},{"../base":7,"minimalistic-assert":231}],9:[function(e,t,r){var n=e("inherits");function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}r.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){var n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){var t,r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},{inherits:226}],10:[function(e,t,r){var n=e("../constants");r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag)},{"../constants":11}],11:[function(e,t,r){var n=r;n._reverse=function(e){var t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);var n=e[r];t[n]=r})),t},n.der=e("./der")},{"./der":10}],12:[function(e,t,r){var n=e("inherits"),i=e("../../asn1"),o=i.base,a=i.bignum,s=i.constants.der;function f(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function u(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var n=s.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(var o=0;o<i;o++){n<<=8;var a=e.readUInt8(r);if(e.isError(a))return a;n|=a}return n}t.exports=f,f.prototype.decode=function(e,t){return e instanceof o.DecoderBuffer||(e=new o.DecoderBuffer(e,t)),this.tree._decode(e,t)},n(c,o.Node),c.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;var n=e.save(),i=u(e,'Failed to peek tag: "'+t+'"');return e.isError(i)?i:(e.restore(n),i.tag===t||i.tagStr===t||i.tagStr+"of"===t||r)},c.prototype._decodeTag=function(e,t,r){var n=u(e,'Failed to decode tag of "'+t+'"');if(e.isError(n))return n;var i=h(e,n.primitive,'Failed to get length of "'+t+'"');if(e.isError(i))return i;if(!r&&n.tag!==t&&n.tagStr!==t&&n.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(n.primitive||null!==i)return e.skip(i,'Failed to match body of: "'+t+'"');var o=e.save(),a=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(a)?a:(i=e.offset-o.offset,e.restore(o),e.skip(i,'Failed to match body of: "'+t+'"'))},c.prototype._skipUntilEnd=function(e,t){for(;;){var r=u(e,t);if(e.isError(r))return r;var n,i=h(e,r.primitive,t);if(e.isError(i))return i;if(n=r.primitive||null!==i?e.skip(i):this._skipUntilEnd(e,t),e.isError(n))return n;if("end"===r.tagStr)break}},c.prototype._decodeList=function(e,t,r,n){for(var i=[];!e.isEmpty();){var o=this._peekTag(e,"end");if(e.isError(o))return o;var a=r.decode(e,"der",n);if(e.isError(a)&&o)break;i.push(a)}return i},c.prototype._decodeStr=function(e,t){if("bitstr"===t){var r=e.readUInt8();return e.isError(r)?r:{unused:r,data:e.raw()}}if("bmpstr"===t){var n=e.raw();if(n.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");for(var i="",o=0;o<n.length/2;o++)i+=String.fromCharCode(n.readUInt16BE(2*o));return i}if("numstr"===t){var a=e.raw().toString("ascii");return this._isNumstr(a)?a:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){var s=e.raw().toString("ascii");return this._isPrintstr(s)?s:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},c.prototype._decodeObjid=function(e,t,r){for(var n,i=[],o=0;!e.isEmpty();){var a=e.readUInt8();o<<=7,o|=127&a,0==(128&a)&&(i.push(o),o=0)}128&a&&i.push(o);var s=i[0]/40|0,f=i[0]%40;if(n=r?i:[s,f].concat(i.slice(1)),t){var c=t[n.join(" ")];void 0===c&&(c=t[n.join(".")]),void 0!==c&&(n=c)}return n},c.prototype._decodeTime=function(e,t){var r=e.raw().toString();if("gentime"===t)var n=0|r.slice(0,4),i=0|r.slice(4,6),o=0|r.slice(6,8),a=0|r.slice(8,10),s=0|r.slice(10,12),f=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");n=0|r.slice(0,2),i=0|r.slice(2,4),o=0|r.slice(4,6),a=0|r.slice(6,8),s=0|r.slice(8,10),f=0|r.slice(10,12);n=n<70?2e3+n:1900+n}return Date.UTC(n,i-1,o,a,s,f,0)},c.prototype._decodeNull=function(e){return null},c.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},c.prototype._decodeInt=function(e,t){var r=e.raw(),n=new a(r);return t&&(n=t[n.toString(10)]||n),n},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree}},{"../../asn1":4,inherits:226}],13:[function(e,t,r){var n=r;n.der=e("./der"),n.pem=e("./pem")},{"./der":12,"./pem":14}],14:[function(e,t,r){var n=e("inherits"),i=e("buffer").Buffer,o=e("./der");function a(e){o.call(this,e),this.enc="pem"}n(a,o),t.exports=a,a.prototype.decode=function(e,t){for(var r=e.toString().split(/[\r\n]+/g),n=t.label.toUpperCase(),a=/^-----(BEGIN|END) ([^-]+)-----$/,s=-1,f=-1,c=0;c<r.length;c++){var u=r[c].match(a);if(null!==u&&u[2]===n){if(-1!==s){if("END"!==u[1])break;f=c;break}if("BEGIN"!==u[1])break;s=c}}if(-1===s||-1===f)throw new Error("PEM section not found for: "+n);var h=r.slice(s+1,f).join("");h.replace(/[^a-z0-9\+\/=]+/gi,"");var d=new i(h,"base64");return o.prototype.decode.call(this,d,t)}},{"./der":12,buffer:77,inherits:226}],15:[function(e,t,r){var n=e("inherits"),i=e("buffer").Buffer,o=e("../../asn1"),a=o.base,s=o.constants.der;function f(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){a.Node.call(this,"der",e)}function u(e){return e<10?"0"+e:e}t.exports=f,f.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},n(c,a.Node),c.prototype._encodeComposite=function(e,t,r,n){var o,a=function(e,t,r,n){var i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(s.tagByName.hasOwnProperty(e))i=s.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return n.error("Unknown tag: "+e);i=e}if(i>=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(o=new i(2))[0]=a,o[1]=n.length,this._createEncoderBuffer([o,n]);for(var f=1,c=n.length;c>=256;c>>=8)f++;(o=new i(2+f))[0]=a,o[1]=128|f;c=1+f;for(var u=n.length;u>0;c--,u>>=8)o[c]=255&u;return this._createEncoderBuffer([o,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new i(2*e.length),n=0;n<e.length;n++)r.writeUInt16BE(e.charCodeAt(n),2*n);return this._createEncoderBuffer(r)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)||"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported")},c.prototype._encodeObjid=function(e,t,r){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!t.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=t[e].split(/[\s\.]+/g);for(var n=0;n<e.length;n++)e[n]|=0}else if(Array.isArray(e)){e=e.slice();for(n=0;n<e.length;n++)e[n]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!r){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(n=0;n<e.length;n++){var a=e[n];for(o++;a>=128;a>>=7)o++}var s=new i(o),f=s.length-1;for(n=e.length-1;n>=0;n--){a=e[n];for(s[f--]=127&a;(a>>=7)>0;)s[f--]=128|127&a}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[u(n.getFullYear()),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[u(n.getFullYear()%100),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!i.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new i(r)}if(i.isBuffer(e)){var n=e.length;0===e.length&&n++;var o=new i(n);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var a=e;a>=256;a>>=8)n++;for(a=(o=new Array(n)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n<o.length;n++)if(o[n]!==i.defaultBuffer[n])return!1;return!0}},{"../../asn1":4,buffer:77,inherits:226}],16:[function(e,t,r){var n=r;n.der=e("./der"),n.pem=e("./pem")},{"./der":15,"./pem":17}],17:[function(e,t,r){var n=e("inherits"),i=e("./der");function o(e){i.call(this,e),this.enc="pem"}n(o,i),t.exports=o,o.prototype.encode=function(e,t){for(var r=i.prototype.encode.call(this,e).toString("base64"),n=["-----BEGIN "+t.label+"-----"],o=0;o<r.length;o+=64)n.push(r.slice(o,o+64));return n.push("-----END "+t.label+"-----"),n.join("\n")}},{"./der":15,inherits:226}],18:[function(e,t,r){t.exports={default:e("core-js/library/fn/array/from"),__esModule:!0}},{"core-js/library/fn/array/from":79}],19:[function(e,t,r){t.exports={default:e("core-js/library/fn/json/stringify"),__esModule:!0}},{"core-js/library/fn/json/stringify":80}],20:[function(e,t,r){t.exports={default:e("core-js/library/fn/object/assign"),__esModule:!0}},{"core-js/library/fn/object/assign":81}],21:[function(e,t,r){t.exports={default:e("core-js/library/fn/object/define-property"),__esModule:!0}},{"core-js/library/fn/object/define-property":82}],22:[function(e,t,r){t.exports={default:e("core-js/library/fn/object/keys"),__esModule:!0}},{"core-js/library/fn/object/keys":83}],23:[function(e,t,r){t.exports={default:e("core-js/library/fn/promise"),__esModule:!0}},{"core-js/library/fn/promise":84}],24:[function(e,t,r){t.exports={default:e("core-js/library/fn/symbol"),__esModule:!0}},{"core-js/library/fn/symbol":85}],25:[function(e,t,r){t.exports={default:e("core-js/library/fn/symbol/iterator"),__esModule:!0}},{"core-js/library/fn/symbol/iterator":86}],26:[function(e,t,r){"use strict";r.__esModule=!0;var n,i=e("../core-js/promise"),o=(n=i)&&n.__esModule?n:{default:n};r.default=function(e){return function(){var t=e.apply(this,arguments);return new o.default((function(e,r){return function n(i,a){try{var s=t[i](a),f=s.value}catch(e){return void r(e)}if(!s.done)return o.default.resolve(f).then((function(e){n("next",e)}),(function(e){n("throw",e)}));e(f)}("next")}))}}},{"../core-js/promise":23}],27:[function(e,t,r){"use strict";r.__esModule=!0;var n,i=e("../core-js/object/define-property"),o=(n=i)&&n.__esModule?n:{default:n};r.default=function(e,t,r){return t in e?(0,o.default)(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}},{"../core-js/object/define-property":21}],28:[function(e,t,r){"use strict";r.__esModule=!0;var n,i=e("../core-js/object/assign"),o=(n=i)&&n.__esModule?n:{default:n};r.default=o.default||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}},{"../core-js/object/assign":20}],29:[function(e,t,r){"use strict";r.__esModule=!0;var n,i=e("../core-js/array/from"),o=(n=i)&&n.__esModule?n:{default:n};r.default=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return(0,o.default)(e)}},{"../core-js/array/from":18}],30:[function(e,t,r){"use strict";r.__esModule=!0;var n=a(e("../core-js/symbol/iterator")),i=a(e("../core-js/symbol")),o="function"==typeof i.default&&"symbol"==typeof n.default?function(e){return typeof e}:function(e){return e&&"function"==typeof i.default&&e.constructor===i.default&&e!==i.default.prototype?"symbol":typeof e};function a(e){return e&&e.__esModule?e:{default:e}}r.default="function"==typeof i.default&&"symbol"===o(n.default)?function(e){return void 0===e?"undefined":o(e)}:function(e){return e&&"function"==typeof i.default&&e.constructor===i.default&&e!==i.default.prototype?"symbol":void 0===e?"undefined":o(e)}},{"../core-js/symbol":24,"../core-js/symbol/iterator":25}],31:[function(e,t,r){var n=function(){return this}()||Function("return this")(),i=n.regeneratorRuntime&&Object.getOwnPropertyNames(n).indexOf("regeneratorRuntime")>=0,o=i&&n.regeneratorRuntime;if(n.regeneratorRuntime=void 0,t.exports=e("./runtime"),i)n.regeneratorRuntime=o;else try{delete n.regeneratorRuntime}catch(e){n.regeneratorRuntime=void 0}},{"./runtime":32}],32:[function(e,t,r){!function(e){"use strict";var r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag",f="object"==typeof t,c=e.regeneratorRuntime;if(c)f&&(t.exports=c);else{(c=e.regeneratorRuntime=f?t.exports:{}).wrap=b;var u={},h={};h[o]=function(){return this};var d=Object.getPrototypeOf,l=d&&d(d(I([])));l&&l!==r&&n.call(l,o)&&(h=l);var p=v.prototype=m.prototype=Object.create(h);g.prototype=p.constructor=v,v.constructor=g,v[s]=g.displayName="GeneratorFunction",c.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},c.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,s in e||(e[s]="GeneratorFunction")),e.prototype=Object.create(p),e},c.awrap=function(e){return{__await:e}},_(w.prototype),w.prototype[a]=function(){return this},c.AsyncIterator=w,c.async=function(e,t,r,n){var i=new w(b(e,t,r,n));return c.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},_(p),p[s]="Generator",p[o]=function(){return this},p.toString=function(){return"[object Generator]"},c.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},c.values=I,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),f=n.call(o,"finallyLoc");if(s&&f){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!f)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}}}function b(e,t,r,n){var i=t&&t.prototype instanceof m?t:m,o=Object.create(i.prototype),a=new A(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return x()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===u)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var f=y(e,t,r);if("normal"===f.type){if(n=r.done?"completed":"suspendedYield",f.arg===u)continue;return{value:f.arg,done:r.done}}"throw"===f.type&&(n="completed",r.method="throw",r.arg=f.arg)}}}(e,r,a),o}function y(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}function m(){}function g(){}function v(){}function _(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function w(e){var t;this._invoke=function(r,i){function o(){return new Promise((function(t,o){!function t(r,i,o,a){var s=y(e[r],e,i);if("throw"!==s.type){var f=s.arg,c=f.value;return c&&"object"==typeof c&&n.call(c,"__await")?Promise.resolve(c.__await).then((function(e){t("next",e,o,a)}),(function(e){t("throw",e,o,a)})):Promise.resolve(c).then((function(e){f.value=e,o(f)}),a)}a(s.arg)}(r,i,t,o)}))}return t=t?t.then(o,o):o()}}function E(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,E(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var n=y(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,u;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function I(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:x}}function x(){return{value:void 0,done:!0}}}(function(){return this}()||Function("return this")())},{}],33:[function(e,t,r){t.exports=e("regenerator-runtime")},{"regenerator-runtime":31}],34:[function(e,t,r){"use strict";var n=e("safe-buffer").Buffer;t.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),a=o.charCodeAt(0);if(255!==t[a])throw new TypeError(o+" is ambiguous");t[a]=i}var s=e.length,f=e.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function h(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return n.alloc(0);var r=0;if(" "!==e[r]){for(var i=0,o=0;e[r]===f;)i++,r++;for(var a=(e.length-r)*c+1>>>0,u=new Uint8Array(a);e[r];){var h=t[e.charCodeAt(r)];if(255===h)return;for(var d=0,l=a-1;(0!==h||d<o)&&-1!==l;l--,d++)h+=s*u[l]>>>0,u[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=d,r++}if(" "!==e[r]){for(var p=a-o;p!==a&&0===u[p];)p++;var b=n.allocUnsafe(i+(a-p));b.fill(0,0,i);for(var y=i;p!==a;)b[y++]=u[p++];return b}}}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,i=0,o=0,a=t.length;o!==a&&0===t[o];)o++,r++;for(var c=(a-o)*u+1>>>0,h=new Uint8Array(c);o!==a;){for(var d=t[o],l=0,p=c-1;(0!==d||l<i)&&-1!==p;p--,l++)d+=256*h[p]>>>0,h[p]=d%s>>>0,d=d/s>>>0;if(0!==d)throw new Error("Non-zero carry");i=l,o++}for(var b=c-i;b!==c&&0===h[b];)b++;for(var y=f.repeat(r);b<c;++b)y+=e.charAt(h[b]);return y},decodeUnsafe:h,decode:function(e){var t=h(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}},{"safe-buffer":270}],35:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){var t,r,n=c(e),a=n[0],s=n[1],f=new o(function(e,t,r){return 3*(t+r)/4-r}(0,a,s)),u=0,h=s>0?a-4:a;for(r=0;r<h;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],f[u++]=t>>16&255,f[u++]=t>>8&255,f[u++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,f[u++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,f[u++]=t>>8&255,f[u++]=255&t);return f},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],a=0,s=r-i;a<s;a+=16383)o.push(u(e,a,a+16383>s?s:a+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,f=a.length;s<f;++s)n[s]=a[s],i[a.charCodeAt(s)]=s;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,o,a=[],s=t;s<r;s+=3)i=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),a.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],36:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const n=e("./crypto"),i=e("bs58check"),o=e("tiny-secp256k1"),a=e("typeforce"),s=e("wif"),f=a.BufferN(32),c=a.compile({wif:a.UInt8,bip32:{public:a.UInt32,private:a.UInt32}}),u={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},h=Math.pow(2,31)-1;function d(e){return a.String(e)&&null!==e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}function l(e){return a.UInt32(e)&&e<=h}class p{constructor(e,t,r,n,i=0,o=0,s=0){this.__D=e,this.__Q=t,this.chainCode=r,this.network=n,this.__DEPTH=i,this.__INDEX=o,this.__PARENT_FINGERPRINT=s,a(c,n),this.lowR=!1}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get publicKey(){return void 0===this.__Q&&(this.__Q=o.pointFromScalar(this.__D,!0)),this.__Q}get privateKey(){return this.__D}get identifier(){return n.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}isNeutered(){return void 0===this.__D}neutered(){return m(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const e=this.network,r=this.isNeutered()?e.bip32.public:e.bip32.private,n=t.allocUnsafe(78);return n.writeUInt32BE(r,0),n.writeUInt8(this.depth,4),n.writeUInt32BE(this.parentFingerprint,5),n.writeUInt32BE(this.index,9),this.chainCode.copy(n,13),this.isNeutered()?this.publicKey.copy(n,45):(n.writeUInt8(0,45),this.privateKey.copy(n,46)),i.encode(n)}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return s.encode(this.network.wif,this.privateKey,!0)}derive(e){a(a.UInt32,e);const r=e>=2147483648,i=t.allocUnsafe(37);if(r){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");i[0]=0,this.privateKey.copy(i,1),i.writeUInt32BE(e,33)}else this.publicKey.copy(i,0),i.writeUInt32BE(e,33);const s=n.hmacSHA512(this.chainCode,i),f=s.slice(0,32),c=s.slice(32);if(!o.isPrivate(f))return this.derive(e+1);let u;if(this.isNeutered()){const t=o.pointAddScalar(this.publicKey,f,!0);if(null===t)return this.derive(e+1);u=m(t,c,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}else{const t=o.privateAdd(this.privateKey,f);if(null==t)return this.derive(e+1);u=y(t,c,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}return u}deriveHardened(e){return a(l,e),this.derive(e+2147483648)}derivePath(e){a(d,e);let t=e.split("/");if("m"===t[0]){if(this.parentFingerprint)throw new TypeError("Expected master, got child");t=t.slice(1)}return t.reduce((e,t)=>{let r;return"'"===t.slice(-1)?(r=parseInt(t.slice(0,-1),10),e.deriveHardened(r)):(r=parseInt(t,10),e.derive(r))},this)}sign(e,r){if(!this.privateKey)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return o.sign(e,this.privateKey);{let r=o.sign(e,this.privateKey);const n=t.alloc(32,0);let i=0;for(;r[0]>127;)i++,n.writeUIntLE(i,0,6),r=o.signWithEntropy(e,this.privateKey,n);return r}}verify(e,t){return o.verify(e,this.publicKey,t)}}function b(e,t,r){return y(e,t,r)}function y(e,t,r,n,i,s){if(a({privateKey:f,chainCode:f},{privateKey:e,chainCode:t}),r=r||u,!o.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return new p(e,void 0,t,r,n,i,s)}function m(e,t,r,n,i,s){if(a({publicKey:a.BufferN(33),