natuscommodi
Version:
ASN.1 encoding and decoding
8 lines • 49.7 kB
JavaScript
var asn1=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=6)}([function(t,e,n){"use strict";n.d(e,"c",function(){return r}),n.d(e,"d",function(){return i}),n.d(e,"g",function(){return o}),n.d(e,"i",function(){return u}),n.d(e,"e",function(){return s}),n.d(e,"h",function(){return a}),n.d(e,"f",function(){return c}),n.d(e,"j",function(){return h}),n.d(e,"a",function(){return f}),n.d(e,"b",function(){return l});class r extends Error{constructor(t){super(t),Object.setPrototypeOf(this,r.prototype)}}class i extends r{constructor(){super("Not yet implemented."),Object.setPrototypeOf(this,r.prototype)}}class o extends r{constructor(){super("Recursion was too deep."),Object.setPrototypeOf(this,r.prototype)}}class u extends r{constructor(t){super(t),Object.setPrototypeOf(this,r.prototype)}}class s extends r{constructor(t){super(t),Object.setPrototypeOf(this,r.prototype)}}class a extends r{constructor(t){super(t),Object.setPrototypeOf(this,r.prototype)}}class c extends r{constructor(t){super(t),Object.setPrototypeOf(this,r.prototype)}}class h extends r{constructor(t){super(t),Object.setPrototypeOf(this,r.prototype)}}class f extends r{constructor(t){super(t),Object.setPrototypeOf(this,r.prototype)}}class l extends r{constructor(t){super(t),Object.setPrototypeOf(this,r.prototype)}}},function(t,e,n){"use strict";n.d(e,"i",function(){return r}),n.d(e,"k",function(){return i}),n.d(e,"h",function(){return o}),n.d(e,"j",function(){return u}),n.d(e,"e",function(){return s}),n.d(e,"a",function(){return a}),n.d(e,"g",function(){return c}),n.d(e,"d",function(){return h}),n.d(e,"b",function(){return f}),n.d(e,"c",function(){return l}),n.d(e,"f",function(){return d}),n.d(e,"t",function(){return g}),n.d(e,"u",function(){return w}),n.d(e,"o",function(){return p}),n.d(e,"p",function(){return v}),n.d(e,"m",function(){return y}),n.d(e,"q",function(){return b}),n.d(e,"r",function(){return m}),n.d(e,"s",function(){return E}),n.d(e,"l",function(){return S}),n.d(e,"n",function(){return T});const r=4294967295,i=0,o=2147483647,u=-2147483648;var s,a,c,h,f,l,d;!function(t){t[t.universal=0]="universal",t[t.application=1]="application",t[t.context=3]="context",t[t.private=4]="private"}(s||(s={})),function(t){t[t.primitive=0]="primitive",t[t.constructed=1]="constructed"}(a||(a={})),function(t){t[t.definite=0]="definite",t[t.indefinite=1]="indefinite"}(c||(c={})),function(t){t[t.plusInfinity=64]="plusInfinity",t[t.minusInfinity=65]="minusInfinity",t[t.notANumber=66]="notANumber",t[t.minusZero=67]="minusZero"}(h||(h={})),function(t){t[t.base2=0]="base2",t[t.base8=16]="base8",t[t.base16=32]="base16"}(f||(f={})),function(t){t[t.scale0=0]="scale0",t[t.scale1=4]="scale1",t[t.scale2=8]="scale2",t[t.scale3=12]="scale3"}(l||(l={})),function(t){t[t.endOfContent=0]="endOfContent",t[t.boolean=1]="boolean",t[t.integer=2]="integer",t[t.bitString=3]="bitString",t[t.octetString=4]="octetString",t[t.nill=5]="nill",t[t.objectIdentifier=6]="objectIdentifier",t[t.objectDescriptor=7]="objectDescriptor",t[t.external=8]="external",t[t.realNumber=9]="realNumber",t[t.enumerated=10]="enumerated",t[t.embeddedPDV=11]="embeddedPDV",t[t.utf8String=12]="utf8String",t[t.relativeOID=13]="relativeOID",t[t.reserved14=14]="reserved14",t[t.reserved15=15]="reserved15",t[t.sequence=16]="sequence",t[t.set=17]="set",t[t.numericString=18]="numericString",t[t.printableString=19]="printableString",t[t.teletexString=20]="teletexString",t[t.videotexString=21]="videotexString",t[t.ia5String=22]="ia5String",t[t.utcTime=23]="utcTime",t[t.generalizedTime=24]="generalizedTime",t[t.graphicString=25]="graphicString",t[t.visibleString=26]="visibleString",t[t.generalString=27]="generalString",t[t.universalString=28]="universalString",t[t.characterString=29]="characterString",t[t.bmpString=30]="bmpString"}(d||(d={}));const g="etaoinsrhdlucmfywgpbvkxqjzETAOINSRHDLUCMFYWGPBVKXQJZ0123456789 '()+,-./:=?",w=/^(?<year>\d{2})(?<month>(?:1[0-2])|(?:0\d))(?<date>(?:3[01])|(?:[0-2]\d))(?<hour>(?:2[0-3])|(?:[01]\d))(?<minute>[0-5]\d)(?<second>[0-5]\d)?(?<offset>(?:(\+|\-)((?:2[0-3])|(?:[01]\d))[0-5]\d)|Z)$/,p=/^(?<year>\d{2})(?<month>(?:1[0-2])|(?:0\d))(?<date>(?:3[01])|(?:[0-2]\d))(?<hour>(?:2[0-3])|(?:[01]\d))(?<minute>[0-5]\d)(?<second>[0-5]\d)?Z$/,v=/^(?<year>\d{4})(?<month>(?:1[0-2])|(?:0\d))(?<date>(?:3[01])|(?:[0-2]\d))(?<hour>(?:2[0-3])|(?:[01]\d))(?<minute>[0-5]\d)?(?<second>[0-5]\d)?(?:(\.|,)(?<fraction>\d+))?(?<offset>(?:(\+|\-)((?:2[0-3])|(?:[01]\d))[0-5]\d)|Z)?$/,y=/^(?<year>\d{4})(?<month>(?:1[0-2])|(?:0\d))(?<date>(?:3[01])|(?:[0-2]\d))(?<hour>(?:2[0-3])|(?:[01]\d))(?<minute>[0-5]\d)(?<second>[0-5]\d)(?:(\.|,)(?<fraction>\d*[1-9]))?Z$/,b=/^\ *(\+|\-)?\d+$/,m=/^\ *(\+|\-)?(?:\d+(\.|,)\d*)|(?:\d*(\.|,)\d+)$/,E=/^\ *(\+|\-)?(?:\d+(\.|,)\d*)|(?:\d*(\.|,)\d+)(e|E)(\+|\-)?\d+$/,S=/^\ *\-?(?:[1-9]\d*)?[1-9]\.E(?:\+0)|(?:\-?[1-9]\d*)$/,T=/^\ *\-?(?:[1-9]\d*)?[1-9]\.E(?:\+0)|(?:\-?[1-9]\d*)$/},function(t,e,n){"use strict";n.d(e,"a",function(){return i});var r=n(0);class i{constructor(){this.recursionCount=0,this.tagClass=0,this.construction=0,this.tagNumber=0,this.value=new Uint8Array(0)}get length(){return this.value.length}static validateDateTime(t,e,n,i,o,u,s){switch(n){case 0:case 2:case 4:case 6:case 7:case 9:case 11:if(i>31)throw new r.c(`Day > 31 encountered in ${t} with 31-day month.`);break;case 3:case 5:case 8:case 10:if(i>30)throw new r.c(`Day > 31 encountered in ${t} with 30-day month.`);break;case 1:if(e%4==0&&e%100!=0||e%400==0){if(i>29)throw new r.c(`Day > 29 encountered in ${t} with month of February in leap year.`)}else if(i>28)throw new r.c(`Day > 28 encountered in ${t} with month of February and non leap year.`);break;default:throw new r.c(`Month greater than 12 encountered in ${t}.`)}if(o>23)throw new r.c(`Hours > 23 encountered in ${t}.`);if(u>59)throw new r.c(`Minutes > 60 encountered in ${t}.`);if(s>59)throw new r.c(`Seconds > 60 encountered in ${t}.`)}static decodeUnsignedBigEndianInteger(t){if(0===t.length)return 0;if(t.length>4)throw new r.e("Number too long to decode.");const e=new Uint8Array(4);return e.set(t,4-t.length),new Uint32Array(e.reverse().buffer)[0]}static decodeSignedBigEndianInteger(t){if(0===t.length)return 0;if(t.length>4)throw new r.e("Number too long to decode.");const e=new Uint8Array(4);return t[0]>=128&&e.fill(255),e.set(t,4-t.length),new Int32Array(e.reverse().buffer)[0]}}i.nestingRecursionLimit=5},function(t,e,n){"use strict";n.d(e,"a",function(){return r});class r{constructor(t){if(t.length<2)throw new Error("Cannot construct an OID with less than two nodes!");if(t.length>=1&&!(t[0]in[0,1,2]))throw new Error("OIDs first node must be 0, 1, or 2!");if(t[0]<2&&t[1]>39||2===t[0]&&t[1]>175)throw new Error(`OID Node #2 cannot exceed 39 if node #1 is 0 or 1, and 175 if node #1 is 2. Received these nodes: ${t}.`);t.forEach(t=>{if(t<0)throw new Error("OID node numbers cannot be negative!");if(t>Number.MAX_SAFE_INTEGER)throw new Error("OID number was too big!")}),this._nodes=t.slice(0)}get nodes(){return this._nodes.slice(0)}get dotDelimitedNotation(){return this._nodes.join(".")}toString(){return this.dotDelimitedNotation}}},function(t,e,n){"use strict";(function(t){n.d(e,"a",function(){return s});var r=n(2),i=n(0),o=n(1),u=n(5);class s extends u.a{set boolean(t){this.value=new Uint8Array(1),this.value[0]=t?255:0}get boolean(){if(0!==this.construction)throw new i.b("BOOLEAN cannot be constructed.");if(1!==this.value.length)throw new i.h("BOOLEAN not one byte");if(0!==this.value[0]&&255!==this.value[0])throw new i.c("BOOLEAN must be encoded as 0xFF or 0x00.");return 0!==this.value[0]}set bitString(t){0===t.length&&(this.value=new Uint8Array(0));let e=[];e.length=(t.length>>>3)+(t.length%8?1:0)+1;for(let n=0;n<t.length;n++)!1!==t[n]&&(e[1+(n>>>3)]|=128>>>n%8);e[0]=8-t.length%8,8===e[0]&&(e[0]=0),this.value=new Uint8Array(e)}get bitString(){if(0!==this.construction)throw new i.b("BIT STRING cannot be constructed.");if(0===this.value.length)throw new i.c("ASN.1 BIT STRING cannot be encoded on zero bytes!");if(1===this.value.length&&0!==this.value[0])throw new i.c("ASN.1 BIT STRING encoded with deceptive first byte!");if(this.value[0]>7)throw new i.c("First byte of an ASN.1 BIT STRING must be <= 7!");let t=[];for(let e=1;e<this.value.length;e++)t=t.concat([!!(128&this.value[e]),!!(64&this.value[e]),!!(32&this.value[e]),!!(16&this.value[e]),!!(8&this.value[e]),!!(4&this.value[e]),!!(2&this.value[e]),!!(1&this.value[e])]);return t.slice(t.length-this.value[0]).forEach(t=>{if(t)throw new i.c("BIT STRING had a trailing set bit.")}),t.length-=this.value[0],t}set octetString(t){this.value=t.subarray(0)}get octetString(){if(0!==this.construction)throw new i.b("OCTET STRING cannot be constructed.");return this.value.subarray(0)}set objectDescriptor(t){this.graphicString=t}get objectDescriptor(){return this.graphicString}set real(t){if(0===t)return void(this.value=new Uint8Array(0));if(isNaN(t))return void(this.value=new Uint8Array([66]));if(-0===t)return void(this.value=new Uint8Array([67]));if(t===1/0)return void(this.value=new Uint8Array([64]));if(t===-1/0)return void(this.value=new Uint8Array([65]));let e=t.toFixed(7);e=String.fromCharCode(3)+e,this.value=(new TextEncoder).encode(e)}get real(){if(0!==this.construction)throw new i.b("REAL cannot be constructed.");if(0===this.value.length)return 0;switch(192&this.value[0]){case 64:if(66===this.value[0])return NaN;if(67===this.value[0])return-0;if(64===this.value[0])return 1/0;if(65===this.value[0])return-1/0;throw new i.j("Unrecognized special REAL value!");case 0:{let e;if("undefined"!=typeof TextEncoder)e=new TextDecoder("utf-8").decode(this.value.slice(1));else{if(void 0===t)throw new i.c("No ability to decode bytes to string!");e=new t(this.value.slice(1)).toString("utf-8")}switch(63&this.value[0]){case 1:case 2:throw new i.c("DER prohibits NR1 and NR2 Base-10 REAL");case 3:if(!o.s.test(e))throw new i.c("Malformed NR3 Base-10 REAL");return parseFloat(e.replace(",","."));default:throw new i.j("Undefined Base-10 REAL encoding.")}}case 128:case 192:{const t=64&this.value[0]?-1:1,e=(t=>{switch(this.value[0]&48){case 0:return 2;case 16:return 8;case 32:return 16;default:throw new i.c("Impossible REAL encoding base encountered.")}})(),n=(t=>{switch(this.value[0]&12){case 0:return 0;case 4:return 1;case 8:return 2;case 12:return 3;default:throw new i.c("Impossible REAL encoding scale encountered.")}})();let o,u;switch(3&this.value[0]){case 0:if(this.value.length<3)throw new i.i("Binary-encoded REAL truncated.");o=r.a.decodeSignedBigEndianInteger(this.value.subarray(1,2)),u=r.a.decodeUnsignedBigEndianInteger(this.value.subarray(2));break;case 1:if(this.value.length<4)throw new i.i("Binary-encoded REAL truncated.");if(o=r.a.decodeSignedBigEndianInteger(this.value.subarray(1,3)),u=r.a.decodeUnsignedBigEndianInteger(this.value.subarray(3)),o<=127&&o>=-128)throw new i.c("DER-encoded binary-encoded REAL could have encoded exponent on fewer octets.");break;case 2:case 3:throw new i.c("DER-encoded binary REAL encoded in a way that would either overflow or encode on too many octets.");default:throw new i.c("Impossible binary REAL exponent encoding encountered.")}if(0!==u&&!(u%2))throw new i.c("DER-encoded REAL may not have an even non-zero mantissa.");return t*u*Math.pow(2,n)*Math.pow(e,o)}default:throw new i.c("Impossible REAL format encountered.")}}set utf8String(e){"undefined"!=typeof TextEncoder?this.value=(new TextEncoder).encode(e):void 0!==t&&(this.value=t.from(e,"utf-8"))}get utf8String(){if(0!==this.construction)throw new i.b("UTF8String cannot be constructed.");let e="";return"undefined"!=typeof TextEncoder?e=new TextDecoder("utf-8").decode(this.value.subarray(0).buffer):void 0!==t&&(e=new t(this.value).toString("utf-8")),e}set sequence(t){let e=[];t.forEach(t=>{e.push(t.toBytes())});let n=0;e.forEach(t=>{n+=t.length});const r=new Uint8Array(n);let i=0;e.forEach(t=>{r.set(t,i),i+=t.length}),this.value=r,this.construction=1}get sequence(){if(1!==this.construction)throw new i.b("SET or SEQUENCE cannot be primitively constructed.");let t=[];if(0===this.value.length)return[];let e=0;for(;e<this.value.length;){const n=new s;e+=n.fromBytes(this.value.slice(e)),t.push(n)}return t}set set(t){this.sequence=t}get set(){return this.sequence}set numericString(e){for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(!(n>=48&&n<=57||32===n))throw new i.a("NumericString can only contain characters 0 - 9 and space.")}"undefined"!=typeof TextEncoder?this.value=(new TextEncoder).encode(e):void 0!==t&&(this.value=t.from(e,"utf-8"))}get numericString(){if(0!==this.construction)throw new i.b("NumericString cannot be constructed.");let e="";"undefined"!=typeof TextEncoder?e=new TextDecoder("utf-8").decode(this.value.subarray(0).buffer):void 0!==t&&(e=new t(this.value).toString("utf-8"));for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(!(n>=48&&n<=57||32===n))throw new i.a("NumericString can only contain characters 0 - 9 and space.")}return e}set printableString(e){for(let t=0;t<e.length;t++)if(-1===o.t.indexOf(e.charAt(t)))throw new i.a(`PrintableString can only contain these characters: ${o.t}`);"undefined"!=typeof TextEncoder?this.value=(new TextEncoder).encode(e):void 0!==t&&(this.value=t.from(e,"utf-8"))}get printableString(){if(0!==this.construction)throw new i.b("PrintableString cannot be constructed.");let e="";"undefined"!=typeof TextEncoder?e=new TextDecoder("utf-8").decode(this.value.subarray(0).buffer):void 0!==t&&(e=new t(this.value).toString("utf-8"));for(let t=0;t<e.length;t++)if(-1===o.t.indexOf(e.charAt(t)))throw new i.a(`PrintableString can only contain these characters: ${o.t}`);return e}set teletexString(t){this.value=t.subarray(0)}get teletexString(){return this.octetString}set videotexString(t){this.value=t.subarray(0)}get videotexString(){return this.octetString}set ia5String(e){"undefined"!=typeof TextEncoder?this.value=(new TextEncoder).encode(e):void 0!==t&&(this.value=t.from(e,"utf-8"))}get ia5String(){if(0!==this.construction)throw new i.b("IA5String cannot be constructed.");let e="";return"undefined"!=typeof TextEncoder?e=new TextDecoder("utf-8").decode(this.value.subarray(0).buffer):void 0!==t&&(e=new t(this.value).toString("utf-8")),e}set utcTime(e){let n=e.getUTCFullYear().toString();const r=`${n=n.substring(n.length-2,n.length)}${e.getUTCMonth()<9?`0${e.getUTCMonth()+1}`:`${e.getUTCMonth()+1}`}${e.getUTCDate()<10?`0${e.getUTCDate()}`:`${e.getUTCDate()}`}${e.getUTCHours()<10?`0${e.getUTCHours()}`:`${e.getUTCHours()}`}${e.getUTCMinutes()<10?`0${e.getUTCMinutes()}`:`${e.getUTCMinutes()}`}${e.getUTCSeconds()<10?`0${e.getUTCSeconds()}`:`${e.getUTCSeconds()}`}Z`;"undefined"!=typeof TextEncoder?this.value=(new TextEncoder).encode(r):void 0!==t&&(this.value=t.from(r,"utf-8"))}get utcTime(){if(0!==this.construction)throw new i.b("UTCTime cannot be constructed.");let e="";"undefined"!=typeof TextEncoder?e=new TextDecoder("utf-8").decode(this.value.subarray(0).buffer):void 0!==t&&(e=new t(this.value).toString("utf-8"));const n=o.u.exec(e);if(null===n)throw new i.c("Malformed UTCTime string.");if(void 0===n.groups)throw new i.c("Malformed UTCTime string.");const r=new Date;let u=Number(n.groups.year);u=u<70?2e3+u:1900+u;const a=Number(n.groups.month)-1,c=Number(n.groups.date),h=Number(n.groups.hour),f=Number(n.groups.minute),l=Number(n.groups.second);return s.validateDateTime("UTCTime",u,a,c,h,f,l),r.setUTCFullYear(u),r.setUTCMonth(a),r.setUTCDate(c),r.setUTCHours(h),r.setUTCMinutes(f),r.setUTCSeconds(l),r}set generalizedTime(e){const n=`${e.getUTCFullYear().toString()}${e.getUTCMonth()<9?`0${e.getUTCMonth()+1}`:`${e.getUTCMonth()+1}`}${e.getUTCDate()<10?`0${e.getUTCDate()}`:`${e.getUTCDate()}`}${e.getUTCHours()<10?`0${e.getUTCHours()}`:`${e.getUTCHours()}`}${e.getUTCMinutes()<10?`0${e.getUTCMinutes()}`:`${e.getUTCMinutes()}`}${e.getUTCSeconds()<10?`0${e.getUTCSeconds()}`:`${e.getUTCSeconds()}`}Z`;"undefined"!=typeof TextEncoder?this.value=(new TextEncoder).encode(n):void 0!==t&&(this.value=t.from(n,"utf-8"))}get generalizedTime(){if(0!==this.construction)throw new i.b("GeneralizedTime cannot be constructed.");let e="";"undefined"!=typeof TextEncoder?e=new TextDecoder("utf-8").decode(this.value.subarray(0).buffer):void 0!==t&&(e=new t(this.value).toString("utf-8"));const n=o.p.exec(e);if(null===n)throw new i.c("Malformed GeneralizedTime string.");if(void 0===n.groups)throw new i.c("Malformed GeneralizedTime string.");const r=new Date,u=Number(n.groups.year),a=Number(n.groups.month)-1,c=Number(n.groups.date),h=Number(n.groups.hour),f=Number(n.groups.minute),l=Number(n.groups.second);return s.validateDateTime("GeneralizedTime",u,a,c,h,f,l),r.setUTCFullYear(u),r.setUTCMonth(a),r.setUTCDate(c),r.setUTCHours(h),r.setUTCMinutes(f),r.setUTCSeconds(l),r}set graphicString(e){for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<32||n>126)throw new i.a("GraphicString, VisibleString, or ObjectDescriptor can only contain characters between 0x20 and 0x7E.")}"undefined"!=typeof TextEncoder?this.value=(new TextEncoder).encode(e):void 0!==t&&(this.value=t.from(e,"utf-8"))}get graphicString(){if(0!==this.construction)throw new i.b("GraphicString cannot be constructed.");let e="";"undefined"!=typeof TextEncoder?e=new TextDecoder("utf-8").decode(this.value.subarray(0).buffer):void 0!==t&&(e=new t(this.value).toString("utf-8"));for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<32||n>126)throw new i.a("GraphicString, VisibleString, or ObjectDescriptor can only contain characters between 0x20 and 0x7E.")}return e}set visibleString(t){this.graphicString=t}get visibleString(){return this.graphicString}set generalString(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)throw new i.a("GeneralString can only contain ASCII characters.");"undefined"!=typeof TextEncoder?this.value=(new TextEncoder).encode(e):void 0!==t&&(this.value=t.from(e,"ascii"))}get generalString(){if(0!==this.construction)throw new i.b("GeneralString cannot be constructed.");let e="";"undefined"!=typeof TextEncoder?e=new TextDecoder("windows-1252").decode(this.value.subarray(0).buffer):void 0!==t&&(e=new t(this.value).toString("ascii"));for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)throw new i.a("GeneralString can only contain ASCII characters.");return e}set universalString(t){const e=new Uint8Array(t.length<<2);for(let n=0;n<t.length;n++)e[n<<2]=t.charCodeAt(n)>>>24,e[1+(n<<2)]=t.charCodeAt(n)>>>16,e[2+(n<<2)]=t.charCodeAt(n)>>>8,e[3+(n<<2)]=t.charCodeAt(n);this.value=e}get universalString(){if(0!==this.construction)throw new i.b("UniversalString cannot be constructed.");if(this.value.length%4)throw new i.c("UniversalString encoded on non-mulitple of four bytes.");let t="";for(let e=0;e<this.value.length;e+=4)t+=String.fromCharCode((this.value[e+0]<<24)+(this.value[e+1]<<16)+(this.value[e+2]<<8)+(this.value[e+3]<<0));return t}set bmpString(t){const e=new Uint8Array(t.length<<1);for(let n=0,r=t.length;n<r;n++)e[n<<1]=t.charCodeAt(n)>>>8,e[1+(n<<1)]=t.charCodeAt(n);this.value=e}get bmpString(){if(0!==this.construction)throw new i.b("BMPString cannot be constructed.");if(this.value.length%2)throw new i.c("BMPString encoded on non-mulitple of two bytes.");let e="";if("undefined"!=typeof TextEncoder)e=new TextDecoder("utf-16be").decode(this.value.subarray(0).buffer);else if(void 0!==t){const n=new Uint8Array(this.value.length);for(let t=0;t<this.value.length;t+=2)n[t]=this.value[t+1],n[t+1]=this.value[t];e=new t(n).toString("utf-16le")}return e}constructor(t=0,e=0,n=0){super(),this.tagClass=t,this.construction=e,this.tagNumber=n,this.value=new Uint8Array(0)}fromBytes(t){if(t.length<2)throw new i.i("Tried to decode a DER element that is less than two bytes.");if(this.recursionCount+1>s.nestingRecursionLimit)throw new i.g;let e=0;switch(192&t[e]){case 0:this.tagClass=0;break;case 64:this.tagClass=1;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:this.tagClass=0}if(this.construction=32&t[e]?1:0,this.tagNumber=31&t[e],e++,this.tagNumber>=31){if(128===t[e])throw new i.f("Leading padding byte on long tag number encoding.");this.tagNumber=0;const n=t.length-1>=4?4:t.length-1;for(;e<n&&128&t[e++];);if(128&t[e-1])throw n===t.length-1?new i.i("ASN.1 tag number appears to have been truncated."):new i.e("ASN.1 tag number too large.");for(let n=1;n<e;n++)this.tagNumber<<=7,this.tagNumber|=127&t[n];if(this.tagNumber<=31)throw new i.c("ASN.1 tag number could have been encoded in short form.")}if(128==(128&t[e])){const n=127&t[e];if(127===n)throw new i.j("Length byte with undefined meaning encountered.");if(n>4)throw new i.e("Element length too long to decode to an integer.");if(e+n>=t.length)throw new i.i("Element length bytes appear to have been truncated.");e++;const r=new Uint8Array(4);for(let i=n;i>0;i--)r[4-i]=t[e+n-i];let o=0;if(r.forEach(t=>{o<<=8,o+=t}),e+o<e)throw new i.e("ASN.1 element too large.");if((e+=n)+o>t.length)throw new i.i("ASN.1 element truncated.");if(o<=127&&o>=-128&&n>1||o<=32767&&o>=-32768&&n>2||o<=8388607&&o>=-8388608&&n>3)throw new i.f("DER-encoded long-form length encoded on more octets than necessary");return this.value=t.slice(e,e+o),e+o}{const n=127&t[e++];if(e+n>t.length)throw new i.i("ASN.1 element was truncated.");return this.value=t.slice(e,e+n),e+n}}toBytes(){let t=[0];if(t[0]|=this.tagClass<<6,t[0]|=this.construction<<5,this.tagNumber<31)t[0]|=this.tagNumber;else{t[0]|=31;let e=this.tagNumber,n=[];for(;0!==e;)n.unshift(127&e),e>>>=7,n[0]|=128;n[n.length-1]&=127,t=t.concat(n)}let e=[0];if(this.value.length<127)e=[this.value.length];else{let t=this.value.length;e=[0,0,0,0];for(let n=0;n<4;n++)e[n]=t>>>(3-n<<3)&255;let n=0;for(let t=0;t<e.length-1;t++)0===e[t]&&n++;(e=e.slice(n)).unshift(128|e.length)}const n=new Uint8Array(t.length+e.length+this.value.length);return n.set(t,0),n.set(e,t.length),n.set(this.value,t.length+e.length),n}}}).call(this,n(8).Buffer)},function(t,e,n){"use strict";n.d(e,"a",function(){return s});var r=n(2),i=n(0),o=n(3),u=n(1);class s extends r.a{validateTag(t,e,n){return t.includes(this.tagClass)?e.includes(this.construction)?n.includes(this.tagNumber)?0:-3:-2:-1}set integer(t){if(t<u.j)throw new i.e(`Number ${t} too small to be converted.`);if(t>u.h)throw new i.e(`Number ${t} too big to be converted.`);return t<=127&&t>=-128?void(this.value=new Uint8Array([255&t])):t<=32767&&t>=-32768?void(this.value=new Uint8Array([t>>8&255,255&t])):t<=8388607&&t>=-8388608?void(this.value=new Uint8Array([t>>16&255,t>>8&255,255&t])):void(this.value=new Uint8Array([t>>24&255,t>>16&255,t>>8&255,255&t]))}get integer(){if(0!==this.construction)throw new i.b("INTEGER cannot be constructed.");if(0===this.value.length)throw new i.h("Number encoded on zero bytes!");if(this.value.length>4)throw new i.e("Number too long to decode.");if(this.value.length>2&&(255===this.value[0]&&this.value[1]>=128||0===this.value[0]&&this.value[1]<128))throw new i.f("Unnecessary padding bytes on INTEGER or ENUMERATED.");return r.a.decodeSignedBigEndianInteger(this.value.subarray(0))}set objectIdentifier(t){const e=t.nodes;let n=[40*e[0]+e[1]],r=s.encodeObjectIdentifierNodes(e.slice(2));this.value=new Uint8Array(n.concat(r))}get objectIdentifier(){if(0!==this.construction)throw new i.b("OBJECT IDENTIFIER cannot be constructed.");if(0===this.value.length)throw new i.i("Encoded value was too short to be an OBJECT IDENTIFIER!");let t=[0,0];return this.value[0]>=80?(t[0]=2,t[1]=this.value[0]-80):this.value[0]>=40?(t[0]=1,t[1]=this.value[0]-40):(t[0]=0,t[1]=this.value[0]),1===this.value.length?new o.a(t):(t=t.concat(s.decodeObjectIdentifierNodes(this.value.slice(1))),new o.a(t))}set enumerated(t){this.integer=t}get enumerated(){return this.integer}set relativeObjectIdentifier(t){this.value=new Uint8Array(s.encodeObjectIdentifierNodes(t))}get relativeObjectIdentifier(){if(0!==this.construction)throw new i.b("Relative OID cannot be constructed.");return s.decodeObjectIdentifierNodes(this.value.slice(0))}static decodeObjectIdentifierNodes(t){if(0===t.length)return[];let e=[];if(t.length>0&&128==(128&t[t.length-1]))throw new i.i("OID truncated");let n=0;t.forEach(t=>{128&t||n++}),e.length=n;let r=0,o=0;return t.forEach(t=>{if(0===o&&128===t)throw new i.f("OID had invalid padding byte.");if(e[r]>Number.MAX_SAFE_INTEGER>>>7)throw new i.e("OID node too big");e[r]<<=7,e[r]|=127&t,128&t?o++:(r++,o=0)}),e}static encodeObjectIdentifierNodes(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r<128){e.push(r);continue}let i=[];for(;0!==r;){let t=[255&r,r>>>8&255,r>>>16&255,r>>>24&255];0==(128&t[0])&&(t[0]|=128),i.unshift(t[0]),r>>=7}i[i.length-1]&=127,e=e.concat(i)}return e}}},function(t,e,n){t.exports=n(7)},function(t,e,n){"use strict";n.r(e);var r=n(2);n.d(e,"ASN1Element",function(){return r.a});var i=n(4);n.d(e,"DERElement",function(){return i.a});var o=n(0);n.d(e,"ASN1Error",function(){return o.c}),n.d(e,"ASN1NotImplementedError",function(){return o.d}),n.d(e,"ASN1RecursionError",function(){return o.g}),n.d(e,"ASN1TruncationError",function(){return o.i}),n.d(e,"ASN1OverflowError",function(){return o.e}),n.d(e,"ASN1SizeError",function(){return o.h}),n.d(e,"ASN1PaddingError",function(){return o.f}),n.d(e,"ASN1UndefinedError",function(){return o.j}),n.d(e,"ASN1CharactersError",function(){return o.a}),n.d(e,"ASN1ConstructionError",function(){return o.b});var u=n(3);n.d(e,"ObjectIdentifier",function(){return u.a});var s=n(1);n.d(e,"MAX_UINT_32",function(){return s.i}),n.d(e,"MIN_UINT_32",function(){return s.k}),n.d(e,"MAX_SINT_32",function(){return s.h}),n.d(e,"MIN_SINT_32",function(){return s.j}),n.d(e,"ASN1TagClass",function(){return s.e}),n.d(e,"ASN1Construction",function(){return s.a}),n.d(e,"LengthEncodingPreference",function(){return s.g}),n.d(e,"ASN1SpecialRealValue",function(){return s.d}),n.d(e,"ASN1RealEncodingBase",function(){return s.b}),n.d(e,"ASN1RealEncodingScale",function(){return s.c}),n.d(e,"ASN1UniversalType",function(){return s.f}),n.d(e,"printableStringCharacters",function(){return s.t}),n.d(e,"utcTimeRegex",function(){return s.u}),n.d(e,"distinguishedUTCTimeRegex",function(){return s.o}),n.d(e,"generalizedTimeRegex",function(){return s.p}),n.d(e,"distinguishedGeneralizedTimeRegex",function(){return s.m}),n.d(e,"nr1Regex",function(){return s.q}),n.d(e,"nr2Regex",function(){return s.r}),n.d(e,"nr3Regex",function(){return s.s}),n.d(e,"canonicalNR3Regex",function(){return s.l}),n.d(e,"distinguishedNR3Regex",function(){return s.n})},function(t,e,n){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
var r=n(10),i=n(11),o=n(12);function u(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t,e){if(u()<e)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=a.prototype:(null===t&&(t=new a(e)),t.length=e),t}function a(t,e,n){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return c(this,t,e,n)}function c(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);a.TYPED_ARRAY_SUPPORT?(t=e).__proto__=a.prototype:t=l(t,e);return t}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!a.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|g(e,n),i=(t=s(t,r)).write(e,n);i!==r&&(t=t.slice(0,i));return t}(t,e,n):function(t,e){if(a.isBuffer(e)){var n=0|d(e.length);return 0===(t=s(t,n)).length?t:(e.copy(t,0,0,n),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||function(t){return t!=t}(e.length)?s(t,0):l(t,e);if("Buffer"===e.type&&o(e.data))return l(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(h(e),t=s(t,e<0?0:0|d(e)),!a.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function l(t,e){var n=e.length<0?0:0|d(e.length);t=s(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function d(t){if(t>=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function g(t,e){if(a.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return k(t).length;default:if(r)return Y(t).length;e=(""+e).toLowerCase(),r=!0}}function w(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function p(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=a.from(e,r)),a.isBuffer(e))return 0===e.length?-1:v(t,e,n,r,i);if("number"==typeof e)return e&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):v(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,n,r,i){var o,u=1,s=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;u=2,s/=2,a/=2,n/=2}function c(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(i){var h=-1;for(o=n;o<s;o++)if(c(t,o)===c(e,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===a)return h*u}else-1!==h&&(o-=o-h),h=-1}else for(n+a>s&&(n=s-a),o=n;o>=0;o--){for(var f=!0,l=0;l<a;l++)if(c(t,o+l)!==c(e,l)){f=!1;break}if(f)return o}return-1}function y(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var u=0;u<r;++u){var s=parseInt(e.substr(2*u,2),16);if(isNaN(s))return u;t[n+u]=s}return u}function b(t,e,n,r){return F(Y(e,t.length-n),t,n,r)}function m(t,e,n,r){return F(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return m(t,e,n,r)}function S(t,e,n,r){return F(k(e),t,n,r)}function T(t,e,n,r){return F(function(t,e){for(var n,r,i,o=[],u=0;u<t.length&&!((e-=2)<0);++u)n=t.charCodeAt(u),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function A(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function U(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i<n;){var o,u,s,a,c=t[i],h=null,f=c>239?4:c>223?3:c>191?2:1;if(i+f<=n)switch(f){case 1:c<128&&(h=c);break;case 2:128==(192&(o=t[i+1]))&&(a=(31&c)<<6|63&o)>127&&(h=a);break;case 3:o=t[i+1],u=t[i+2],128==(192&o)&&128==(192&u)&&(a=(15&c)<<12|(63&o)<<6|63&u)>2047&&(a<55296||a>57343)&&(h=a);break;case 4:o=t[i+1],u=t[i+2],s=t[i+3],128==(192&o)&&128==(192&u)&&128==(192&s)&&(a=(15&c)<<18|(63&o)<<12|(63&u)<<6|63&s)>65535&&a<1114112&&(h=a)}null===h?(h=65533,f=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),i+=f}return function(t){var e=t.length;if(e<=R)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=R));return n}(r)}e.Buffer=a,e.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},e.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=u(),a.poolSize=8192,a._augment=function(t){return t.__proto__=a.prototype,t},a.from=function(t,e,n){return c(null,t,e,n)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(t,e,n){return function(t,e,n,r){return h(e),e<=0?s(t,e):void 0!==n?"string"==typeof r?s(t,e).fill(n,r):s(t,e).fill(n):s(t,e)}(null,t,e,n)},a.allocUnsafe=function(t){return f(null,t)},a.allocUnsafeSlow=function(t){return f(null,t)},a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,e){if(!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=a.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var u=t[n];if(!a.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(r,i),i+=u.length}return r},a.byteLength=g,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)w(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},a.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?U(this,0,t):function(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,n);case"utf8":case"utf-8":return U(this,e,n);case"ascii":return N(this,e,n);case"latin1":case"binary":return C(this,e,n);case"base64":return A(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},a.prototype.compare=function(t,e,n,r,i){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var o=i-r,u=n-e,s=Math.min(o,u),c=this.slice(r,i),h=t.slice(e,n),f=0;f<s;++f)if(c[f]!==h[f]){o=c[f],u=h[f];break}return o<u?-1:u<o?1:0},a.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},a.prototype.indexOf=function(t,e,n){return p(this,t,e,n,!0)},a.prototype.lastIndexOf=function(t,e,n){return p(this,t,e,n,!1)},a.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return y(this,t,e,n);case"utf8":case"utf-8":return b(this,t,e,n);case"ascii":return m(this,t,e,n);case"latin1":case"binary":return E(this,t,e,n);case"base64":return S(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function N(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function C(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function I(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=e;o<n;++o)i+=j(t[o]);return i}function x(t,e,n){for(var r=t.slice(e,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function _(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,n,r,i,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function B(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i<o;++i)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function P(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i<o;++i)t[n+i]=e>>>8*(r?i:3-i)&255}function D(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(t,e,n,r,o){return o||D(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function L(t,e,n,r,o){return o||D(t,0,n,8),i.write(t,e,n,r,52,8),n+8}a.prototype.slice=function(t,e){var n,r=this.length;if(t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),a.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=a.prototype;else{var i=e-t;n=new a(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+t]}return n},a.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||_(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r},a.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||_(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},a.prototype.readUInt8=function(t,e){return e||_(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return e||_(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return e||_(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return e||_(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return e||_(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||_(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*e)),r},a.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||_(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},a.prototype.readInt8=function(t,e){return e||_(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){e||_(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(t,e){e||_(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(t,e){return e||_(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return e||_(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return e||_(t,4,this.length),i.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return e||_(t,4,this.length),i.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return e||_(t,8,this.length),i.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return e||_(t,8,this.length),i.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||O(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},a.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||O(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},a.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},a.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},a.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):P(this,t,e,!0),e+4},a.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):P(this,t,e,!1),e+4},a.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);O(this,t,e,n,i-1,-i)}var o=0,u=1,s=0;for(this[e]=255&t;++o<n&&(u*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/u>>0)-s&255;return e+n},a.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);O(this,t,e,n,i-1,-i)}var o=n-1,u=1,s=0;for(this[e+o]=255&t;--o>=0&&(u*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/u>>0)-s&255;return e+n},a.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},a.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},a.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):P(this,t,e,!0),e+4},a.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):P(this,t,e,!1),e+4},a.prototype.writeFloatLE=function(t,e,n){return M(this,t,e,!0,n)},a.prototype.writeFloatBE=function(t,e,n){return M(this,t,e,!1,n)},a.prototype.writeDoubleLE=function(t,e,n){return L(this,t,e,!0,n)},a.prototype.writeDoubleBE=function(t,e,n){return L(this,t,e,!1,n)},a.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i,o=r-n;if(this===t&&n<e&&e<r)for(i=o-1;i>=0;--i)t[i+e]=this[i+n];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),e);return o},a.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var o;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o<n;++o)this[o]=t;else{var u=a.isBuffer(t)?t:Y(new a(t,r).toString()),s=u.length;for(o=0;o<n-e;++o)this[o+e]=u[o%s]}return this};var $=/[^+\/0-9A-Za-z-_]/g;function j(t){return t<16?"0"+t.toString(16):t.toString(16)}function Y(t,e){var n;e=e||1/0;for(var r=t.length,i=null,o=[],u=0;u<r;++u){if((n=t.charCodeAt(u))>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(u+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function k(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace($,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(this,n(9))},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";e.byteLength=function(t){var e=c(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){for(var e,n=c(t),r=n[0],u=n[1],s=new o(function(t,e,n){return 3*(e+n)/4-n}(0,r,u)),a=0,h=u>0?r-4:r,f=0;f<h;f+=4)e=i[t.charCodeAt(f)]<<18|i[t.charCodeAt(f+1)]<<12|i[t.charCodeAt(f+2)]<<6|i[t.charCodeAt(f+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;2===u&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,s[a++]=255&e);1===u&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e);return s},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],u=0,s=n-i;u<s;u+=16383)o.push(f(t,u,u+16383>s?s:u+16383));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=u.length;s<a;++s)r[s]=u[s],i[u.charCodeAt(s)]=s;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function h(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function f(t,e,n){for(var r,i=[],o=e;o<n;o+=3)r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(h(r));return i.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,n,r,i){var o,u,s=8*i-r-1,a=(1<<s)-1,c=a>>1,h=-7,f=n?i-1:0,l=n?-1:1,d=t[e+f];for(f+=l,o=d&(1<<-h)-1,d>>=-h,h+=s;h>0;o=256*o+t[e+f],f+=l,h-=8);for(u=o&(1<<-h)-1,o>>=-h,h+=r;h>0;u=256*u+t[e+f],f+=l,h-=8);if(0===o)o=1-c;else{if(o===a)return u?NaN:1/0*(d?-1:1);u+=Math.pow(2,r),o-=c}return(d?-1:1)*u*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var u,s,a,c=8*o-i-1,h=(1<<c)-1,f=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,g=r?1:-1,w=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,u=h):(u=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-u))<1&&(u--,a*=2),(e+=u+f>=1?l/a:l*Math.pow(2,1-f))*a>=2&&(u++,a/=2),u+f>=h?(s=0,u=h):u+f>=1?(s=(e*a-1)*Math.pow(2,i),u+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),u=0));i>=8;t[n+d]=255&s,d+=g,s/=256,i-=8);for(u=u<<i|s,c+=i;c>0;t[n+d]=255&u,d+=g,u/=256,c-=8);t[n+d-g]|=128*w}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}}]);