UNPKG

x509-ts

Version:

Encode and decode X.509 (TLS) Certificates, Attribute Certificates, CRLs, and more.

8 lines 169 kB
var x509=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=35)}([function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(6)),r(n(38)),r(n(43)),r(n(4)),r(n(16)),r(n(44)),r(n(5))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class r extends Error{constructor(e){super(e)}}t.X509Error=r},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const i=r(n(1));t.default=function(e,t,n,r,s){switch(e.validateTag(n,r,s)){case 0:break;case-1:{const n={0:"UNIVERSAL",1:"APPLICATION",2:"CONTEXT-SPECIFIC",3:"PRIVATE"}[e.tagClass];throw new i.X509Error(`Invalid tag class on ${t}. Actual class: ${n}.`)}case-2:throw new i.X509Error(`Invalid construction on ${t}.`);case-3:throw new i.X509Error(`Invalid tag number on ${t}. Actual number was ${e.tagNumber}.`);default:throw new i.X509Error(`Undefined error when validating ${t} tag.`)}}},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const i=n(0),s=r(n(1));class o{constructor(e,t){this.algorithm=e,this.parameters=t}static fromElement(e){const t=e.sequence;if(0===t.length)throw new s.X509Error("AlgorithmIdentifier may not contain zero elements.");if(t.length>2)throw new s.X509Error("Too many elements in AlgorithmIdentifier.");switch(t[0].validateTag([i.ASN1TagClass.universal],[i.ASN1Construction.primitive],[i.ASN1UniversalType.objectIdentifier])){case 0:break;case-1:throw new s.X509Error("Invalid tag class on AlgorithmIdentifier.algorithm");case-2:throw new s.X509Error("Invalid construction on AlgorithmIdentifier.algorithm");case-3:throw new s.X509Error("Invalid tag number on AlgorithmIdentifier.algorithm");default:throw new s.X509Error("Undefined error when validating AlgorithmIdentifier.algorithm tag")}return new o(t[0].objectIdentifier,2===t.length?t[1]:void 0)}toElement(){if(void 0===this.algorithm)throw new s.X509Error("Algorithm is undefined");const e=new i.DERElement;e.tagNumber=i.ASN1UniversalType.objectIdentifier,e.objectIdentifier=this.algorithm;const t=new i.DERElement;return t.tagClass=i.ASN1TagClass.universal,t.construction=i.ASN1Construction.constructed,t.tagNumber=i.ASN1UniversalType.sequence,void 0===this.parameters?t.sequence=[e]:t.sequence=[e,this.parameters],t}static fromBytes(e){const t=new i.DERElement;return t.fromBytes(e),o.fromElement(t)}toBytes(){return this.toElement().toBytes()}}t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class r extends Error{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}}t.ASN1Error=r;t.ASN1NotImplementedError=class extends r{constructor(){super("Not yet implemented."),Object.setPrototypeOf(this,r.prototype)}};t.ASN1RecursionError=class extends r{constructor(){super("Recursion was too deep."),Object.setPrototypeOf(this,r.prototype)}};t.ASN1TruncationError=class extends r{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};t.ASN1OverflowError=class extends r{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};t.ASN1SizeError=class extends r{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};t.ASN1PaddingError=class extends r{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};t.ASN1UndefinedError=class extends r{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};t.ASN1CharactersError=class extends r{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};t.ASN1ConstructionError=class extends r{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}}},function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_UINT_32=4294967295,t.MIN_UINT_32=0,t.MAX_SINT_32=2147483647,t.MIN_SINT_32=-2147483648,function(e){e[e.universal=0]="universal",e[e.application=1]="application",e[e.context=2]="context",e[e.private=3]="private"}(r=t.ASN1TagClass||(t.ASN1TagClass={})),function(e){e[e.primitive=0]="primitive",e[e.constructed=1]="constructed"}(t.ASN1Construction||(t.ASN1Construction={})),function(e){e[e.definite=0]="definite",e[e.indefinite=1]="indefinite"}(t.LengthEncodingPreference||(t.LengthEncodingPreference={})),function(e){e[e.plusInfinity=64]="plusInfinity",e[e.minusInfinity=65]="minusInfinity",e[e.notANumber=66]="notANumber",e[e.minusZero=67]="minusZero"}(t.ASN1SpecialRealValue||(t.ASN1SpecialRealValue={})),function(e){e[e.base2=0]="base2",e[e.base8=16]="base8",e[e.base16=32]="base16"}(t.ASN1RealEncodingBase||(t.ASN1RealEncodingBase={})),function(e){e[e.scale0=0]="scale0",e[e.scale1=4]="scale1",e[e.scale2=8]="scale2",e[e.scale3=12]="scale3"}(t.ASN1RealEncodingScale||(t.ASN1RealEncodingScale={})),function(e){e[e.endOfContent=0]="endOfContent",e[e.boolean=1]="boolean",e[e.integer=2]="integer",e[e.bitString=3]="bitString",e[e.octetString=4]="octetString",e[e.nill=5]="nill",e[e.objectIdentifier=6]="objectIdentifier",e[e.objectDescriptor=7]="objectDescriptor",e[e.external=8]="external",e[e.realNumber=9]="realNumber",e[e.enumerated=10]="enumerated",e[e.embeddedPDV=11]="embeddedPDV",e[e.utf8String=12]="utf8String",e[e.relativeOID=13]="relativeOID",e[e.reserved14=14]="reserved14",e[e.reserved15=15]="reserved15",e[e.sequence=16]="sequence",e[e.set=17]="set",e[e.numericString=18]="numericString",e[e.printableString=19]="printableString",e[e.teletexString=20]="teletexString",e[e.videotexString=21]="videotexString",e[e.ia5String=22]="ia5String",e[e.utcTime=23]="utcTime",e[e.generalizedTime=24]="generalizedTime",e[e.graphicString=25]="graphicString",e[e.visibleString=26]="visibleString",e[e.generalString=27]="generalString",e[e.universalString=28]="universalString",e[e.characterString=29]="characterString",e[e.bmpString=30]="bmpString"}(t.ASN1UniversalType||(t.ASN1UniversalType={})),t.printableStringCharacters="etaoinsrhdlucmfywgpbvkxqjzETAOINSRHDLUCMFYWGPBVKXQJZ0123456789 '()+,-./:=?",t.utcTimeRegex=/^(\d{2})((?:1[0-2])|(?:0\d))((?:3[01])|(?:[0-2]\d))((?:2[0-3])|(?:[01]\d))([0-5]\d)([0-5]\d)?((?:(\+|-)((?:2[0-3])|(?:[01]\d))[0-5]\d)|Z)$/,t.generalizedTimeRegex=/^(\d{4})((?:1[0-2])|(?:0\d))((?:3[01])|(?:[0-2]\d))((?:2[0-3])|(?:[01]\d))([0-5]\d)?([0-5]\d)?(?:(?:\.|,)(\d+))?((?:(?:\+|-)((?:2[0-3])|(?:[01]\d))[0-5]\d)|Z)?$/,t.nr1Regex=/^ *(\+|-)?\d+$/u,t.nr2Regex=/^ *(\+|-)?(?:\d+(\.|,)\d*)|(?:\d*(\.|,)\d+)$/u,t.nr3Regex=/^ *(\+|-)?(?:\d+(\.|,)\d*)|(?:\d*(\.|,)\d+)(e|E)(\+|-)?\d+$/u,t.canonicalNR3Regex=/^ *-?(?:[1-9]\d*)?[1-9]\.E(?:\+0)|(?:-?[1-9]\d*)$/u,t.distinguishedNR3Regex=/^ *-?(?:[1-9]\d*)?[1-9]\.E(?:\+0)|(?:-?[1-9]\d*)$/u,t.CANONICAL_TAG_CLASS_ORDERING=[r.universal,r.application,r.private,r.context]},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const i=r(n(4)),s=n(5);class o{constructor(){this.recursionCount=0,this.tagClass=s.ASN1TagClass.universal,this.construction=s.ASN1Construction.primitive,this.tagNumber=0,this.value=new Uint8Array(0)}get length(){return this.value.length}static validateDateTime(e,t,n,r,s,o,a){switch(n){case 0:case 2:case 4:case 6:case 7:case 9:case 11:if(r>31)throw new i.ASN1Error(`Day > 31 encountered in ${e} with 31-day month.`);break;case 3:case 5:case 8:case 10:if(r>30)throw new i.ASN1Error(`Day > 31 encountered in ${e} with 30-day month.`);break;case 1:if(t%4==0&&t%100!=0||t%400==0){if(r>29)throw new i.ASN1Error(`Day > 29 encountered in ${e} with month of February in leap year.`)}else if(r>28)throw new i.ASN1Error(`Day > 28 encountered in ${e} with month of February and non leap year.`);break;default:throw new i.ASN1Error(`Month greater than 12 encountered in ${e}.`)}if(s>23)throw new i.ASN1Error(`Hours > 23 encountered in ${e}.`);if(o>59)throw new i.ASN1Error(`Minutes > 60 encountered in ${e}.`);if(a>59)throw new i.ASN1Error(`Seconds > 60 encountered in ${e}.`)}static decodeUnsignedBigEndianInteger(e){if(0===e.length)return 0;if(e.length>4)throw new i.ASN1OverflowError("Number too long to decode.");const t=new Uint8Array(4);return t.set(e,4-e.length),new Uint32Array(t.reverse().buffer)[0]}static decodeSignedBigEndianInteger(e){if(0===e.length)return 0;if(e.length>4)throw new i.ASN1OverflowError("Number too long to decode.");const t=new Uint8Array(4);return e[0]>=128&&t.fill(255),t.set(e,4-e.length),new Int32Array(t.reverse().buffer)[0]}}t.ASN1Element=o,o.nestingRecursionLimit=5},function(e,t,n){"use strict";(function(e){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> * @license MIT */ var r=n(40),i=n(41),s=n(42);function o(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return l.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=l.prototype:(null===e&&(e=new l(t)),e.length=t),e}function l(e,t,n){if(!(l.TYPED_ARRAY_SUPPORT||this instanceof l))return new l(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return h(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);l.TYPED_ARRAY_SUPPORT?(e=t).__proto__=l.prototype:e=f(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!l.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|g(t,n),i=(e=a(e,r)).write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(l.isBuffer(t)){var n=0|d(t.length);return 0===(e=a(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):f(e,t);if("Buffer"===t.type&&s(t.data))return f(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function h(e,t){if(c(t),e=a(e,t<0?0:0|d(t)),!l.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function f(e,t){var n=t.length<0?0:0|d(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function d(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function g(e,t){if(l.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return k(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(e).length;default:if(r)return k(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return D(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return U(this,t,n);case"latin1":case"binary":return _(this,t,n);case"base64":return C(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function v(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function w(e,t,n,r,i){if(0===e.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:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=l.from(t,r)),l.isBuffer(t))return 0===t.length?-1:S(e,t,n,r,i);if("number"==typeof t)return t&=255,l.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):S(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function S(e,t,n,r,i){var s,o=1,a=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,l/=2,n/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var c=-1;for(s=n;s<a;s++)if(u(e,s)===u(t,-1===c?0:s-c)){if(-1===c&&(c=s),s-c+1===l)return c*o}else-1!==c&&(s-=s-c),c=-1}else for(n+l>a&&(n=a-l),s=n;s>=0;s--){for(var h=!0,f=0;f<l;f++)if(u(e,s+f)!==u(t,f)){h=!1;break}if(h)return s}return-1}function E(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;o<r;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[n+o]=a}return o}function p(e,t,n,r){return z(k(t,e.length-n),e,n,r)}function N(e,t,n,r){return z(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function A(e,t,n,r){return N(e,t,n,r)}function y(e,t,n,r){return z($(t),e,n,r)}function b(e,t,n,r){return z(function(e,t){for(var n,r,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,s.push(i),s.push(r);return s}(t,e.length-n),e,n,r)}function C(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function T(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s,o,a,l,u=e[i],c=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=n)switch(h){case 1:u<128&&(c=u);break;case 2:128==(192&(s=e[i+1]))&&(l=(31&u)<<6|63&s)>127&&(c=l);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(l=(15&u)<<12|(63&s)<<6|63&o)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&l<1114112&&(c=l)}null===c?(c=65533,h=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=h}return function(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=I));return n}(r)}t.Buffer=l,t.SlowBuffer=function(e){+e!=e&&(e=0);return l.alloc(+e)},t.INSPECT_MAX_BYTES=50,l.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=o(),l.poolSize=8192,l._augment=function(e){return e.__proto__=l.prototype,e},l.from=function(e,t,n){return u(null,e,t,n)},l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&l[Symbol.species]===l&&Object.defineProperty(l,Symbol.species,{value:null,configurable:!0})),l.alloc=function(e,t,n){return function(e,t,n,r){return c(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},l.allocUnsafe=function(e){return h(null,e)},l.allocUnsafeSlow=function(e){return h(null,e)},l.isBuffer=function(e){return!(null==e||!e._isBuffer)},l.compare=function(e,t){if(!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,s=Math.min(n,r);i<s;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},l.isEncoding=function(e){switch(String(e).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}},l.concat=function(e,t){if(!s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return l.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=l.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var o=e[n];if(!l.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},l.byteLength=g,l.prototype._isBuffer=!0,l.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)v(this,t,t+1);return this},l.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)v(this,t,t+3),v(this,t+1,t+2);return this},l.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)v(this,t,t+7),v(this,t+1,t+6),v(this,t+2,t+5),v(this,t+3,t+4);return this},l.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?T(this,0,e):m.apply(this,arguments)},l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===l.compare(this,e)},l.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},l.prototype.compare=function(e,t,n,r,i){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(t>>>=0),a=Math.min(s,o),u=this.slice(r,i),c=e.slice(t,n),h=0;h<a;++h)if(u[h]!==c[h]){s=u[h],o=c[h];break}return s<o?-1:o<s?1:0},l.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},l.prototype.indexOf=function(e,t,n){return w(this,e,t,n,!0)},l.prototype.lastIndexOf=function(e,t,n){return w(this,e,t,n,!1)},l.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return E(this,e,t,n);case"utf8":case"utf-8":return p(this,e,t,n);case"ascii":return N(this,e,t,n);case"latin1":case"binary":return A(this,e,t,n);case"base64":return y(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function U(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function _(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function D(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",s=t;s<n;++s)i+=L(e[s]);return i}function R(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}function P(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function O(e,t,n,r,i,s){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function B(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-n,2);i<s;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function x(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-n,4);i<s;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function X(e,t,n,r,i,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function j(e,t,n,r,s){return s||X(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function M(e,t,n,r,s){return s||X(e,0,n,8),i.write(e,t,n,r,52,8),n+8}l.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),l.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=l.prototype;else{var i=t-e;n=new l(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+e]}return n},l.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r},l.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},l.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},l.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},l.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=t,i=1,s=this[e+--r];r>0&&(i*=256);)s+=this[e+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},l.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!1,52,8)},l.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||O(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[t]=255&e;++s<n&&(i*=256);)this[t+s]=e/i&255;return t+n},l.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||O(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+n},l.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,1,255,0),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):B(this,e,t,!0),t+2},l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):B(this,e,t,!1),t+2},l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):x(this,e,t,!0),t+4},l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},l.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);O(this,e,t,n,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<n&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},l.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);O(this,e,t,n,i-1,-i)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},l.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,1,127,-128),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):B(this,e,t,!0),t+2},l.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):B(this,e,t,!1),t+2},l.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):x(this,e,t,!0),t+4},l.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},l.prototype.writeFloatLE=function(e,t,n){return j(this,e,t,!0,n)},l.prototype.writeFloatBE=function(e,t,n){return j(this,e,t,!1,n)},l.prototype.writeDoubleLE=function(e,t,n){return M(this,e,t,!0,n)},l.prototype.writeDoubleBE=function(e,t,n){return M(this,e,t,!1,n)},l.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<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),e.length-t<r-n&&(r=e.length-t+n);var i,s=r-n;if(this===e&&n<t&&t<r)for(i=s-1;i>=0;--i)e[i+t]=this[i+n];else if(s<1e3||!l.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s},l.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!l.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var s;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s<n;++s)this[s]=e;else{var o=l.isBuffer(e)?e:k(new l(e,r).toString()),a=o.length;for(s=0;s<n-t;++s)this[s+t]=o[s%a]}return this};var q=/[^+\/0-9A-Za-z-_]/g;function L(e){return e<16?"0"+e.toString(16):e.toString(16)}function k(e,t){var n;t=t||1/0;for(var r=e.length,i=null,s=[],o=0;o<r;++o){if((n=e.charCodeAt(o))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function $(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function z(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(39))},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(0),o=r(n(1)),a=i(n(2)),l=i(n(3));class u{constructor(e,t,n,r){this.digestedObjectType=e,this.otherObjectTypeID=t,this.digestAlgorithm=n,this.objectDigest=r}static fromElement(e){a.default(e,"ObjectDigestInfo",[s.ASN1TagClass.universal],[s.ASN1Construction.constructed],[s.ASN1UniversalType.sequence]);const t=e.sequence;if(t.length<3)throw new o.X509Error(`Too few elements in ObjectDigestInfo: ${t.length}.`);const n=new Map([["digestedObjectType",t[0]]]);if(t[1].tagNumber===s.ASN1UniversalType.objectIdentifier){if(t.length<4)throw new o.X509Error(`Too few elements in ObjectDigestInfo: ${t.length}.`);n.set("otherObjectTypeID",t[1]),n.set("digestAlgorithm",t[2]),n.set("objectDigest",t[3])}else n.set("digestAlgorithm",t[1]),n.set("objectDigest",t[2]);a.default(n.get("digestedObjectType"),"ObjectDigestInfo.digestedObjectType",[s.ASN1TagClass.universal],[s.ASN1Construction.primitive],[s.ASN1UniversalType.enumerated]),n.has("otherObjectTypeID")&&a.default(n.get("otherObjectTypeID"),"ObjectDigestInfo.otherObjectTypeID",[s.ASN1TagClass.universal],[s.ASN1Construction.primitive],[s.ASN1UniversalType.objectIdentifier]),a.default(n.get("objectDigest"),"ObjectDigestInfo.objectDigest",[s.ASN1TagClass.universal],[s.ASN1Construction.primitive],[s.ASN1UniversalType.bitString]);const r=n.get("digestedObjectType").enumerated,i=n.has("otherObjectTypeID")?n.get("otherObjectTypeID").objectIdentifier:void 0,c=l.default.fromElement(n.get("digestAlgorithm")),h=n.get("objectDigest").bitString;return new u(r,i,c,h)}toElement(){const e=[],t=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.primitive,s.ASN1UniversalType.enumerated);if(t.enumerated=this.digestedObjectType,e.push(t),this.otherObjectTypeID){const t=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.primitive,s.ASN1UniversalType.objectIdentifier);t.objectIdentifier=this.otherObjectTypeID,e.push(t)}const n=this.digestAlgorithm.toElement();e.push(n);const r=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.primitive,s.ASN1UniversalType.bitString);r.bitString=this.objectDigest,e.push(r);const i=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.constructed,s.ASN1UniversalType.sequence);return i.sequence=e,i}static fromBytes(e){const t=new s.DERElement;return t.fromBytes(e),u.fromElement(t)}toBytes(){return this.toElement().toBytes()}}t.default=u},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(0),o=r(n(1)),a=i(n(2));class l{constructor(e,t,n){this.issuer=e,this.serial=t,this.issuerUID=n}static fromElement(e){a.default(e,"IssuerElement",[s.ASN1TagClass.universal],[s.ASN1Construction.constructed],[s.ASN1UniversalType.sequence]);const t=e.sequence;if(t.length<2||t.length>3)throw new o.X509Error(`Invalid number of elements in IssuerSerial: ${t.length}`);a.default(t[0],"IssuerSerial.issuer",[s.ASN1TagClass.universal],[s.ASN1Construction.constructed],[s.ASN1UniversalType.sequence]),a.default(t[1],"IssuerSerial.serial",[s.ASN1TagClass.universal],[s.ASN1Construction.primitive],[s.ASN1UniversalType.integer]),3===t.length&&a.default(t[2],"IssuerSerial.issuerUID",[s.ASN1TagClass.universal],[s.ASN1Construction.primitive],[s.ASN1UniversalType.bitString]);const n=t[0].sequence;if(n.length<1)throw new o.X509Error("No GeneralNames provided in IssuerSerial.issuer.");const r=t[1].octetString,i=(()=>3===t.length?t[2].bitString:void 0)();return new l(n,r,i)}toElement(){const e=[],t=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.constructed,s.ASN1UniversalType.sequence);t.sequence=this.issuer,e.push(t);const n=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.primitive,s.ASN1UniversalType.integer);if(n.value=this.serial.subarray(0),e.push(n),this.issuerUID){const t=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.primitive,s.ASN1UniversalType.bitString);t.bitString=this.issuerUID,e.push(t)}const r=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.constructed,s.ASN1UniversalType.sequence);return r.sequence=e,r}static fromBytes(e){const t=new s.DERElement;return t.fromBytes(e),l.fromElement(t)}toBytes(){return this.toElement().toBytes()}}t.default=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(0);t.authenticationFrameworkOID=new r.ObjectIdentifier([2,5,1,7]);var i=n(3);t.AlgorithmIdentifier=i.default;var s=n(48);t.Certificate=s.default;var o=n(49);t.CertificateList=o.default;var a=n(31);t.CertificateListContent=a.default;var l=n(27);t.Extension=l.default;var u=n(26);t.SubjectPublicKeyInfo=u.default;var c=n(24);t.TBSCertificate=c.default;var h=n(25);t.Validity=h.default;var f=n(11);t.Version=f.default},function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.v1=0]="v1",e[e.v2=1]="v2",e[e.v3=2]="v3"}(r||(r={})),t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=n(0);t.informationFrameworkOID=new r.ObjectIdentifier([2,5,1,1]);var i=n(28);t.AttributeTypeAndValue=i.default;var s=n(29);t.RDNSequence=s.default;var o=n(30);t.RelativeDistinguishedName=o.default},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const i=n(0),s=r(n(1));class o{constructor(e){this.value=e}toString(){return this.value}static print(e){return o.fromElement(e).toString()}static fromElement(e){if(e.tagClass!==i.ASN1TagClass.universal)throw new s.X509Error("UnboundedDirectoryString must be of universal class");if(e.construction!==i.ASN1Construction.primitive)throw new s.X509Error("UnboundedDirectoryString must be of primitive construction");switch(e.tagNumber){case i.ASN1UniversalType.teletexString:return new o("");case i.ASN1UniversalType.printableString:return new o(e.printableString);case i.ASN1UniversalType.bmpString:return new o(e.bmpString);case i.ASN1UniversalType.universalString:return new o(e.universalString);case i.ASN1UniversalType.utf8String:return new o(e.utf8String);default:throw new s.X509Error("UnboundedDirectoryString was constituted of an invalid CHOICE")}}toElement(){const e=new i.DERElement(i.ASN1TagClass.universal,i.ASN1Construction.primitive,i.ASN1UniversalType.utf8String);return e.utf8String=this.value,e}static fromBytes(e){const t=new i.DERElement;return t.fromBytes(e),this.fromElement(t)}toBytes(){return this.toElement().toBytes()}}t.default=o},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const i=n(0),s=r(n(1));class o{constructor(e=!1,t=!1,n=!1,r=!1,i=!1,s=!1,o=!1,a=!1,l=!1,u=!1){this.unused=e,this.keyCompromise=t,this.cACompromise=n,this.affiliationChanged=r,this.superseded=i,this.cessationOfOperation=s,this.certificateHold=o,this.privilegeWithdrawn=a,this.aACompromise=l,this.weakAlgorithmOrKeySize=u}static fromElement(e){switch(e.validateTag([i.ASN1TagClass.universal],[i.ASN1Construction.primitive],[i.ASN1UniversalType.bitString])){case 0:break;case-1:throw new s.X509Error("Invalid tag class on ReasonFlags");case-2:throw new s.X509Error("Invalid construction on ReasonFlags");case-3:throw new s.X509Error("Invalid tag number on ReasonFlags");default:throw new s.X509Error("Undefined error when validating ReasonFlags tag")}const t=e.bitString;return new o(t.length>=1&&t[0],t.length>=2&&t[1],t.length>=3&&t[2],t.length>=4&&t[3],t.length>=5&&t[4],t.length>=6&&t[5],t.length>=7&&t[6],t.length>=8&&t[7],t.length>=9&&t[8],t.length>=10&&t[9])}toElement(){const e=new i.DERElement(i.ASN1TagClass.universal,i.ASN1Construction.constructed,i.ASN1UniversalType.bitString);return e.bitString=[this.unused,this.keyCompromise,this.cACompromise,this.affiliationChanged,this.superseded,this.cessationOfOperation,this.certificateHold,this.privilegeWithdrawn,this.aACompromise,this.weakAlgorithmOrKeySize],e}static fromBytes(e){const t=new i.DERElement;return t.fromBytes(e),o.fromElement(t)}toBytes(){return this.toElement().toBytes()}}t.default=o},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});const i=n(6),s=r(n(4)),o=n(16),a=n(5);class l extends i.ASN1Element{validateTag(e,t,n){return e.includes(this.tagClass)?t.includes(this.construction)?n.includes(this.tagNumber)?0:-3:-2:-1}set integer(e){if(e<a.MIN_SINT_32)throw new s.ASN1OverflowError(`Number ${e} too small to be converted.`);if(e>a.MAX_SINT_32)throw new s.ASN1OverflowError(`Number ${e} too big to be converted.`);return e<=127&&e>=-128?void(this.value=new Uint8Array([255&e])):e<=32767&&e>=-32768?void(this.value=new Uint8Array([e>>8&255,255&e])):e<=8388607&&e>=-8388608?void(this.value=new Uint8Array([e>>16&255,e>>8&255,255&e])):void(this.value=new Uint8Array([e>>24&255,e>>16&255,e>>8&255,255&e]))}get integer(){if(this.construction!==a.ASN1Construction.primitive)throw new s.ASN1ConstructionError("INTEGER cannot be constructed.");if(0===this.value.length)throw new s.ASN1SizeError("Number encoded on zero bytes!");if(this.value.length>4)throw new s.ASN1OverflowError("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 s.ASN1PaddingError("Unnecessary padding bytes on INTEGER or ENUMERATED.");return i.ASN1Element.decodeSignedBigEndianInteger(this.value.subarray(0))}set objectIdentifier(e){const t=e.nodes,n=[40*t[0]+t[1]],r=l.encodeObjectIdentifierNodes(t.slice(2));this.value=new Uint8Array(n.concat(r))}get objectIdentifier(){if(this.construction!==a.ASN1Construction.primitive)throw new s.ASN1ConstructionError("OBJECT IDENTIFIER cannot be constructed.");if(0===this.value.length)throw new s.ASN1TruncationError("Encoded value was too short to be an OBJECT IDENTIFIER!");let e=[0,0];return this.value[0]>=80?(e[0]=2,e[1]=this.value[0]-80):this.value[0]>=40?(e[0]=1,e[1]=this.value[0]-40):(e[0]=0,e[1]=this.value[0]),1===this.value.length?new o.ObjectIdentifier(e):(e=e.concat(l.decodeObjectIdentifierNodes(this.value.slice(1))),new o.ObjectIdentifier(e))}set enumerated(e){this.integer=e}get enumerated(){return this.integer}set relativeObjectIdentifier(e){this.value=new Uint8Array(l.encodeObjectIdentifierNodes(e))}get relativeObjectIdentifier(){if(this.construction!==a.ASN1Construction.primitive)throw new s.ASN1ConstructionError("Relative OID cannot be constructed.");return l.decodeObjectIdentifierNodes(this.value.slice(0))}static decodeObjectIdentifierNodes(e){if(0===e.length)return[];const t=[];if(e.length>0&&128==(128&e[e.length-1]))throw new s.ASN1TruncationError("OID truncated");let n=0;e.forEach(e=>{128&e||n++}),t.length=n;let r=0,i=0;return e.forEach(e=>{if(0===i&&128===e)throw new s.ASN1PaddingError("OID had invalid padding byte.");if(t[r]>Number.MAX_SAFE_INTEGER>>>7)throw new s.ASN1OverflowError("OID node too big");t[r]<<=7,t[r]|=127&e,128&e?i++:(r++,i=0)}),t}static encodeObjectIdentifierNodes(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r<128){t.push(r);continue}const i=[];for(;0!==r;){const e=[255&r,r>>>8&255,r>>>16&255,r>>>24&255];0==(128&e[0])&&(e[0]|=128),i.unshift(e[0]),r>>=7}i[i.length-1]&=127,t=t.concat(i)}return t}static isInCanonicalOrder(e){let t=null,n=null;return!!e.every(e=>!(null!==t&&e.tagClass!==t&&a.CANONICAL_TAG_CLASS_ORDERING.indexOf(e.tagClass)<=a.CANONICAL_TAG_CLASS_ORDERING.indexOf(t))&&(e.tagClass!==t&&(n=null),!(null!==n&&e.tagNumber<n)&&(t=e.tagClass,n=e.tagNumber,!0)))}static isUniquelyTagged(e){const t={};for(let n=0;n<e.length;n++){const r=`${e[n].tagClass}.${e[n].tagNumber}`;if(r in t)return!1;t[r]=null}return!0}}t.X690Element=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ObjectIdentifier=class{constructor(e){if(e.length<2)throw new Error("Cannot construct an OID with less than two nodes!");if(e.length>=1&&!(e[0]in[0,1,2]))throw new Error("OIDs first node must be 0, 1, or 2!");if(e[0]<2&&e[1]>39||2===e[0]&&e[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: ${e}.`);e.forEach(e=>{if(e<0)throw new Error("OID node numbers cannot be negative!");if(e>Number.MAX_SAFE_INTEGER)throw new Error("OID number was too big!")}),this._nodes=e.slice(0)}get nodes(){return this._nodes.slice(0)}get dotDelimitedNotation(){return this._nodes.join(".")}toString(){return this.dotDelimitedNotation}}},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const r=n(4);t.default=function(t,n="utf-8"){if("undefined"!=typeof TextEncoder)return new TextDecoder(n).decode(t.buffer);if(void 0!==e)return e.from(t).toString(n);throw new r.ASN1Error("Neither TextDecoder nor Buffer are defined to decode bytes into text.")}}).call(this,n(7).Buffer)},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const r=n(4);t.default=function(t,n="utf-8"){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);if(void 0!==e)return e.from(t,n);throw new r.ASN1Error("Neither TextEncoder nor Buffer are defined to encode text into bytes.")}}).call(this,n(7).Buffer)},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(0),o=r(n(1)),a=i(n(2)),l=i(n(8)),u=i(n(9));class c{constructor(e,t,n){this.issuerName=e,this.baseCertificateID=t,this.objectDigestInfo=n}static fromElement(e){a.default(e,"AttCertIssuer",[s.ASN1TagClass.context],[s.ASN1Construction.constructed],[0]);const t=e.sequence;if(t.length<1)throw new o.X509Error(`Invalid number of elements in AttCertIssuer: ${t.length}.`);if(!s.DERElement.isInCanonicalOrder(t))throw new o.X509Error("Elements of AttCertIssuer were not in canonical order.");let n,r,i;if(t.forEach(e=>{if(e.construction===s.ASN1Construction.constructed)if(e.tagClass===s.ASN1TagClass.context){if(0===e.tagNumber){if(r)throw new o.X509Error("AttCertIssuer.baseCertificateID already defined.");r=u.default.fromElement(e)}else if(1===e.tagNumber){if(i)throw new o.X509Error("AttCertIssuer.objectDigestInfo already defined.");i=l.default.fromElement(e)}}else if(e.tagClass===s.ASN1TagClass.universal&&e.tagNumber===s.ASN1UniversalType.sequence){if(n)throw new o.X509Error("AttCertIssuer.issuerName already defined.");n=e.sequence}}),!r&&!n&&!i)throw new o.X509Error("One of { baseCertificateID, issuerName, objectDigestInfo } must be defined for a AttCertIssuer element.");return new c(n,r,i)}toElement(){const e=[];if(this.issuerName){const t=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.constructed,s.ASN1UniversalType.sequence);t.sequence=this.issuerName,e.push(t)}if(this.baseCertificateID){const t=this.baseCertificateID.toElement();t.tagClass=s.ASN1TagClass.context,t.tagNumber=0,e.push(t)}if(this.objectDigestInfo){const t=this.objectDigestInfo.toElement();t.tagClass=s.ASN1TagClass.context,t.tagNumber=1,e.push(t)}const t=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.constructed,s.ASN1UniversalType.sequence);return t.sequence=e,t}static fromBytes(e){const t=new s.DERElement;return t.fromBytes(e),c.fromElement(t)}toBytes(){return this.toElement().toBytes()}}t.default=c},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(0),o=r(n(1)),a=i(n(2));class l{constructor(e,t){this.notBefore=e,this.notAfter=t}static fromElement(e){a.default(e,"AttCertValidityPeriod",[s.ASN1TagClass.universal],[s.ASN1Construction.constructed],[s.ASN1UniversalType.sequence]);const t=e.sequence;if(t.length<2)throw new o.X509Error("AttCertValidityPeriod contained fewer than two ASN.1 elements.");return a.default(t[0],"AttCertValidityPeriod.notBefore",[s.ASN1TagClass.universal],[s.ASN1Construction.primitive],[s.ASN1UniversalType.generalizedTime]),a.default(t[1],"AttCertValidityPeriod.notAfter",[s.ASN1TagClass.universal],[s.ASN1Construction.primitive],[s.ASN1UniversalType.generalizedTime]),new l(t[0].generalizedTime,t[1].generalizedTime)}toElement(){const e=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.primitive,s.ASN1UniversalType.generalizedTime);e.generalizedTime=this.notBefore;const t=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.primitive,s.ASN1UniversalType.generalizedTime);t.generalizedTime=this.notAfter;const n=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.constructed,s.ASN1UniversalType.sequence);return n.sequence=[e,t],n}static fromBytes(e){const t=new s.DERElement;return t.fromBytes(e),l.fromElement(t)}toBytes(){return this.toElement().toBytes()}}t.default=l},function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.v2=1]="v2"}(r||(r={})),t.default=r},function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(0),o=r(n(1)),a=i(n(2)),l=i(n(21)),u=i(n(3)),c=i(n(23)),h=i(n(19)),f=i(n(20)),d=i(n(46)),g=n(10);class m{constructor(e=l.default.v2,t,n,r,i,s,o,a,u){this.ver=e,this.holder=t,this.issuer=n,this.signature=r,this.serialNumber=i,this.attrCertValidityPeriod=s,this.attributes=o,this.issuerUniqueID=a,this.extensions=u}static fromElement(e){a.default(e,"TBSAttributeCertificate",[s.ASN1TagClass.universal],[s.ASN1Construction.constructed],[s.ASN1UniversalType.sequence]);const t=e.sequence;if(t.length<7)throw new o.X509Error(`TBSAttributeCertificate was too short. It contained ${t.length} elements.`);a.default(t[0],"TBSAttributeCertificate.version",[s.ASN1TagClass.universal],[s.ASN1Construction.primitive],[s.ASN1UniversalType.integer]),a.default(t[4],"TBSAttributeCertificate.serialNumber",[s.ASN1TagClass.universal],[s.ASN1Construction.primitive],[s.ASN1UniversalType.integer]),a.default(t[6],"TBSAttributeCertificate.attributes",[s.ASN1TagClass.universal],[s.ASN1Construction.constructed],[s.ASN1UniversalType.sequence]);const n=t[0].integer,r=c.default.fromElement(t[1]),i=h.default.fromElement(t[2]),l=u.default.fromElement(t[3]),v=t[4].octetString,w=f.default.fromElement(t[5]),S=t[6].sequence.map(d.default.fromElement);let E=7,p=void 0;t.length>7&&t[7].tagClass===s.ASN1TagClass.universal&&t[7].construction===s.ASN1Construction.primitive&&t[7].tagNumber===s.ASN1UniversalType.bitString&&(p=t[7].bitString,E++);let N=void 0;return t.length>8&&t[t.length-1].tagClass===s.ASN1TagClass.universal&&t[t.length-1].construction===s.ASN1Construction.constructed&&t[t.length-1].tagNumber===s.ASN1UniversalType.sequence&&(N=t[t.length-1].sequence.map(g.Extension.fromElement)),s.DERElement.isInCanonicalOrder(t.slice(E,N?t.length-1:void 0)),s.DERElement.isUniquelyTagged(t.slice(E,N?t.length-1:void 0)),new m(n,r,i,l,v,w,S,p,N)}toElement(){const e=[],t=new s.DERElement(s.ASN1TagClass.universal,s.ASN1Construction.primitive,s.ASN1UniversalType.integer);t.integer=this.ver,e.push(t),e.push(this.holder.toElement()),e.push(this.issu