@3kles/3kles-ionauth
Version:
3KLES Ion Auth
2 lines • 208 kB
JavaScript
/*! For license information please see index.js.LICENSE.txt */
(()=>{var e={6861:(e,t,r)=>{const{define:n}=r(7694),i=r(3910),o=r(3088),s=r(3586),a=r(3670);e.exports={base:i,constants:o,decoders:s,define:n,encoders:a}},7694:(e,t,r)=>{const{inherits:n}=r(9023),i=r(3670),o=r(3586);function s(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}e.exports.define=function(e,t){return new s(e,t)},s.prototype._createNamed=function(e){const t=this.name;function r(e){this._initNamed(e,t)}return n(r,e),r.prototype._initNamed=function(t,r){e.call(this,t,r)},new r(this)},s.prototype._getDecoder=function(e){return e=e||"der",Object.prototype.hasOwnProperty.call(this.decoders,e)||(this.decoders[e]=this._createNamed(o[e])),this.decoders[e]},s.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},s.prototype._getEncoder=function(e){return e=e||"der",Object.prototype.hasOwnProperty.call(this.encoders,e)||(this.encoders[e]=this._createNamed(i[e])),this.encoders[e]},s.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},4662:(e,t,r)=>{const{inherits:n}=r(9023),{Reporter:i}=r(3517);function o(e,t){i.call(this,t),Buffer.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return s.isEncoderBuffer(e)||(e=new s(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(e>=0&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=Buffer.byteLength(e);else{if(!Buffer.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}n(o,i),o.isDecoderBuffer=function(e){return e instanceof o||"object"==typeof e&&Buffer.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},o.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)}},o.prototype.restore=function(e){const t=new o(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,i.prototype.restore.call(this,e.reporter),t},o.prototype.isEmpty=function(){return this.offset===this.length},o.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},o.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new o(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},o.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},s.isEncoderBuffer=function(e){return e instanceof s||"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},s.prototype.join=function(e,t){return e||(e=Buffer.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):Buffer.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e},e.exports={DecoderBuffer:o,EncoderBuffer:s}},3910:(e,t,r)=>{const{Reporter:n}=r(3517),{DecoderBuffer:i,EncoderBuffer:o}=r(4662),s=r(7868);e.exports={DecoderBuffer:i,EncoderBuffer:o,Node:s,Reporter:n}},7868:(e,t,r)=>{const{strict:n}=r(2613),{Reporter:i}=r(3517),{DecoderBuffer:o,EncoderBuffer:s}=r(4662),a=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],c=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(a);function u(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}const p=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];u.prototype.clone=function(){const e=this._baseState,t={};p.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},u.prototype._wrap=function(){const e=this._baseState;c.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},u.prototype._init=function(e){const t=this._baseState;n(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),n.equal(t.children.length,1,"Root node can have only one child")},u.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(n(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(n(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){u.prototype[e]=function(){const t=this._baseState;throw new Error(`${e} not implemented for encoding: ${t.enc}`)}})),a.forEach((function(e){u.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return n(null===t.tag),t.tag=e,this._useArgs(r),this}})),u.prototype.use=function(e){n(e);const t=this._baseState;return n(null===t.use),t.use=e,this},u.prototype.optional=function(){return this._baseState.optional=!0,this},u.prototype.def=function(e){const t=this._baseState;return n(null===t.default),t.default=e,t.optional=!0,this},u.prototype.explicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.explicit=e,this},u.prototype.implicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.implicit=e,this},u.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},u.prototype.key=function(e){const t=this._baseState;return n(null===t.key),t.key=e,this},u.prototype.any=function(){return this._baseState.any=!0,this},u.prototype.choice=function(e){const t=this._baseState;return n(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},u.prototype.contains=function(e){const t=this._baseState;return n(null===t.use),t.contains=e,this},u.prototype._decode=function(e,t){const r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));let n,i=r.default,s=!0,a=null;if(null!==r.key&&(a=e.enterKey(r.key)),r.optional){let n=null;if(null!==r.explicit?n=r.explicit:null!==r.implicit?n=r.implicit:null!==r.tag&&(n=r.tag),null!==n||r.any){if(s=this._peekTag(e,n,r.any),e.isError(s))return s}else{const n=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),s=!0}catch(e){s=!1}e.restore(n)}}if(r.obj&&s&&(n=e.enterObject()),s){if(null!==r.explicit){const t=this._decodeTag(e,r.explicit);if(e.isError(t))return t;e=t}const n=e.offset;if(null===r.use&&null===r.choice){let t;r.any&&(t=e.save());const n=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(n))return n;r.any?i=e.raw(t):e=n}if(t&&t.track&&null!==r.tag&&t.track(e.path(),n,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),r.any||(i=null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach((function(r){r._decode(e,t)})),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){const n=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(n,t)}}return r.obj&&s&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==s?null!==a&&e.exitKey(a):e.leaveKey(a,r.key,i),i},u.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error(`unknown tag: ${e}`)},u.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),n(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},u.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,i=!1;return Object.keys(r.choice).some((function(o){const s=e.save(),a=r.choice[o];try{const r=a._decode(e,t);if(e.isError(r))return!1;n={type:o,value:r},i=!0}catch(t){return e.restore(s),!1}return!0}),this),i?n:e.error("Choice not matched")},u.prototype._createEncoderBuffer=function(e){return new s(e,this.reporter)},u.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const i=this._encodeValue(e,t,r);return void 0===i||this._skipDefault(i,t,r)?void 0:i},u.prototype._encodeValue=function(e,t,r){const n=this._baseState;if(null===n.parent)return n.children[0]._encode(e,t||new i);let o=null;if(this.reporter=t,n.optional&&void 0===e){if(null===n.default)return;e=n.default}let s=null,a=!1;if(n.any)o=this._createEncoderBuffer(e);else if(n.choice)o=this._encodeChoice(e,t);else if(n.contains)s=this._getUse(n.contains,r)._encode(e,t),a=!0;else if(n.children)s=n.children.map((function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");const n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");const i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i}),this).filter((function(e){return e})),s=this._createEncoderBuffer(s);else if("seqof"===n.tag||"setof"===n.tag){if(!n.args||1!==n.args.length)return t.error(`Too many args for: ${n.tag}`);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");const r=this.clone();r._baseState.implicit=null,s=this._createEncoderBuffer(e.map((function(r){const n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)}),r))}else null!==n.use?o=this._getUse(n.use,r)._encode(e,t):(s=this._encodePrimitive(n.tag,e),a=!0);if(!n.any&&null===n.choice){const e=null!==n.implicit?n.implicit:n.tag,r=null===n.implicit?"universal":"context";null===e?null===n.use&&t.error("Tag could be omitted only for .use()"):null===n.use&&(o=this._encodeComposite(e,a,r,s))}return null!==n.explicit&&(o=this._encodeComposite(n.explicit,!1,"context",o)),o},u.prototype._encodeChoice=function(e,t){const r=this._baseState,i=r.choice[e.type];return i||n(!1,`${e.type} not found in ${JSON.stringify(Object.keys(r.choice))}`),i._encode(e.value,t)},u.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error(`Unsupported tag: ${e}`)},u.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},u.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)},e.exports=u},3517:(e,t,r)=>{const{inherits:n}=r(9023);function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){let t;const r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map((function(e){return`[${JSON.stringify(e)}]`})).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=`${e} at: ${this.path||"(shallow)"}`,Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this},t.Reporter=i},3236:(e,t)=>{function r(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=r(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=r(t.tag)},3088:(e,t,r)=>{e.exports={der:r(3236)}},473:(e,t,r)=>{const{inherits:n}=r(9023),{DecoderBuffer:i}=r(4662),o=r(7868),s=r(3236);function a(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.call(this,"der",e)}function u(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=s.tagClass[r>>6],i=!(32&r);if(31&~r)r&=31;else{let n=r;for(r=0;!(128&~n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function p(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(!(128&n))return n;const i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(let t=0;t<i;t++){n<<=8;const t=e.readUInt8(r);if(e.isError(t))return t;n|=t}return n}a.prototype.decode=function(e,t){return i.isDecoderBuffer(e)||(e=new i(e,t)),this.tree._decode(e,t)},n(c,o),c.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;const n=e.save(),i=u(e,`Failed to peek tag: "${t}"`);return e.isError(i)?i:(e.restore(n),i.tag===t||i.tagStr===t||i.tagStr+"of"===t||r)},c.prototype._decodeTag=function(e,t,r){const n=u(e,`Failed to decode tag of "${t}"`);if(e.isError(n))return n;let i=p(e,n.primitive,`Failed to get length of "${t}"`);if(e.isError(i))return i;if(!r&&n.tag!==t&&n.tagStr!==t&&n.tagStr+"of"!==t)return e.error(`Failed to match tag: "${t}"`);if(n.primitive||null!==i)return e.skip(i,`Failed to match body of: "${t}"`);const o=e.save(),s=this._skipUntilEnd(e,`Failed to skip indefinite length body: "${this.tag}"`);return e.isError(s)?s:(i=e.offset-o.offset,e.restore(o),e.skip(i,`Failed to match body of: "${t}"`))},c.prototype._skipUntilEnd=function(e,t){for(;;){const r=u(e,t);if(e.isError(r))return r;const n=p(e,r.primitive,t);if(e.isError(n))return n;let i;if(i=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(i))return i;if("end"===r.tagStr)break}},c.prototype._decodeList=function(e,t,r,n){const i=[];for(;!e.isEmpty();){const t=this._peekTag(e,"end");if(e.isError(t))return t;const o=r.decode(e,"der",n);if(e.isError(o)&&t)break;i.push(o)}return i},c.prototype._decodeStr=function(e,t){if("bitstr"===t){const t=e.readUInt8();return e.isError(t)?t:{unused:t,data:e.raw()}}if("bmpstr"===t){const t=e.raw();if(t.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");let r="";for(let e=0;e<t.length/2;e++)r+=String.fromCharCode(t.readUInt16BE(2*e));return r}if("numstr"===t){const t=e.raw().toString("ascii");return this._isNumstr(t)?t:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){const t=e.raw().toString("ascii");return this._isPrintstr(t)?t:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error(`Decoding of string type: ${t} unsupported`)},c.prototype._decodeObjid=function(e,t,r){let n;const i=[];let o=0,s=0;for(;!e.isEmpty();)s=e.readUInt8(),o<<=7,o|=127&s,128&s||(i.push(o),o=0);128&s&&i.push(o);const a=i[0]/40|0,c=i[0]%40;if(n=r?i:[a,c].concat(i.slice(1)),t){let e=t[n.join(" ")];void 0===e&&(e=t[n.join(".")]),void 0!==e&&(n=e)}return n},c.prototype._decodeTime=function(e,t){const r=e.raw().toString();let n,i,o,s,a,c;if("gentime"===t)n=0|r.slice(0,4),i=0|r.slice(4,6),o=0|r.slice(6,8),s=0|r.slice(8,10),a=0|r.slice(10,12),c=0|r.slice(12,14);else{if("utctime"!==t)return e.error(`Decoding ${t} time is not supported yet`);n=0|r.slice(0,2),i=0|r.slice(2,4),o=0|r.slice(4,6),s=0|r.slice(6,8),a=0|r.slice(8,10),c=0|r.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,i-1,o,s,a,c,0)},c.prototype._decodeNull=function(){return null},c.prototype._decodeBool=function(e){const t=e.readUInt8();return e.isError(t)?t:0!==t},c.prototype._decodeInt=function(e,t){const r=e.raw();let n=BigInt(`0x${r.toString("hex")}`);return t&&(n=t[n.toString(10)]||n),n},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree},e.exports=a},3586:(e,t,r)=>{e.exports={der:r(473),pem:r(8536)}},8536:(e,t,r)=>{const{inherits:n}=r(9023),i=r(473);function o(e){i.call(this,e),this.enc="pem"}n(o,i),o.prototype.decode=function(e,t){const r=e.toString().split(/[\r\n]+/g),n=t.label.toUpperCase(),o=/^-----(BEGIN|END) ([^-]+)-----$/;let s=-1,a=-1;for(let e=0;e<r.length;e++){const t=r[e].match(o);if(null!==t&&t[2]===n){if(-1!==s){if("END"!==t[1])break;a=e;break}if("BEGIN"!==t[1])break;s=e}}if(-1===s||-1===a)throw new Error(`PEM section not found for: ${n}`);const c=r.slice(s+1,a).join("");c.replace(/[^a-z0-9+/=]+/gi,"");const u=Buffer.from(c,"base64");return i.prototype.decode.call(this,u,t)},e.exports=o},6325:(e,t,r)=>{const{inherits:n}=r(9023),i=r(7868),o=r(3236);function s(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new a,this.tree._init(e.body)}function a(e){i.call(this,"der",e)}function c(e){return e<10?`0${e}`:e}function u(e){var t=BigInt(e).toString(16);t.length%2&&(t="0"+t);for(var r=t.length/2,n=new Uint8Array(r),i=0,o=0;i<r;)n[i]=parseInt(t.slice(o,o+2),16),i+=1,o+=2;return n}s.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},n(a,i),a.prototype._encodeComposite=function(e,t,r,n){const i=function(e,t,r,n){let i;if("seqof"===e?e="seq":"setof"===e&&(e="set"),Object.prototype.hasOwnProperty.call(o.tagByName,e))i=o.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return n.error(`Unknown tag: ${e}`);i=e}return i>=31?n.error("Multi-octet tag encoding unsupported"):(t||(i|=32),i|=o.tagClassByName[r||"universal"]<<6,i)}(e,t,r,this.reporter);if(n.length<128){const e=Buffer.alloc(2);return e[0]=i,e[1]=n.length,this._createEncoderBuffer([e,n])}let s=1;for(let e=n.length;e>=256;e>>=8)s++;const a=Buffer.alloc(2+s);a[0]=i,a[1]=128|s;for(let e=1+s,t=n.length;t>0;e--,t>>=8)a[e]=255&t;return this._createEncoderBuffer([a,n])},a.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=Buffer.alloc(2*e.length);for(let r=0;r<e.length;r++)t.writeUInt16BE(e.charCodeAt(r),2*r);return this._createEncoderBuffer(t)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)||"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error(`Encoding of string type: ${t} unsupported`)},a.prototype._encodeObjid=function(e,t,r){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!Object.prototype.hasOwnProperty.call(t,e))return this.reporter.error("objid not found in values map");e=t[e].split(/[\s.]+/g);for(let t=0;t<e.length;t++)e[t]|=0}else if(Array.isArray(e)){e=e.slice();for(let t=0;t<e.length;t++)e[t]|=0}if(!Array.isArray(e))return this.reporter.error(`objid() should be either array or string, got: ${JSON.stringify(e)}`);if(!r){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let n=0;for(let t=0;t<e.length;t++){let r=e[t];for(n++;r>=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},a.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[c(n.getUTCFullYear()),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[c(n.getUTCFullYear()%100),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):this.reporter.error(`Encoding ${t} time is not supported yet`),this._encodeStr(r,"octstr")},a.prototype._encodeNull=function(){return this._createEncoderBuffer("")},a.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!Object.prototype.hasOwnProperty.call(t,e))return this.reporter.error(`Values map doesn't contain: ${JSON.stringify(e)}`);e=t[e]}if("bigint"==typeof e){const t=[...u(e)];128&t[0]&&t.unshift(0),e=Buffer.from(t)}if(Buffer.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=Buffer.alloc(t);return e.copy(r),0===e.length&&(r[0]=0),this._createEncoderBuffer(r)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let r=1;for(let t=e;t>=256;t>>=8)r++;const n=new Array(r);for(let t=n.length-1;t>=0;t--)n[t]=255&e,e>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},a.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},a.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},a.prototype._skipDefault=function(e,t,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i<o.length;i++)if(o[i]!==n.defaultBuffer[i])return!1;return!0},e.exports=s},3670:(e,t,r)=>{e.exports={der:r(6325),pem:r(2276)}},2276:(e,t,r)=>{const{inherits:n}=r(9023),i=r(6325);function o(e){i.call(this,e),this.enc="pem"}n(o,i),o.prototype.encode=function(e,t){const r=i.prototype.encode.call(this,e).toString("base64"),n=[`-----BEGIN ${t.label}-----`];for(let e=0;e<r.length;e+=64)n.push(r.slice(e,e+64));return n.push(`-----END ${t.label}-----`),n.join("\n")},e.exports=o},1045:(e,t,r)=>{"use strict";var n=r(181).Buffer,i=r(181).SlowBuffer;function o(e,t){if(!n.isBuffer(e)||!n.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(var r=0,i=0;i<e.length;i++)r|=e[i]^t[i];return 0===r}e.exports=o,o.install=function(){n.prototype.equal=i.prototype.equal=function(e){return o(this,e)}};var s=n.prototype.equal,a=i.prototype.equal;o.restore=function(){n.prototype.equal=s,i.prototype.equal=a}},7833:(e,t,r)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(736)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},736:(e,t,r)=>{e.exports=function(e){function t(e){let r,i,o,s=null;function a(...e){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if("%%"===r)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];r=o.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function i(e,t){let r=0,n=0,i=-1,o=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(i=n,o=r,n++):(r++,n++);else{if(-1===i)return!1;n=i+1,o++,r=o}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(" ",",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(i(e,r))return!1;for(const r of t.names)if(i(e,r))return!0;return!1},t.humanize=r(6585),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},5753:(e,t,r)=>{"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?e.exports=r(7833):e.exports=r(6033)},6033:(e,t,r)=>{const n=r(2018),i=r(9023);t.init=function(e){e.inspectOpts={};const r=Object.keys(t.inspectOpts);for(let n=0;n<r.length;n++)e.inspectOpts[r[n]]=t.inspectOpts[r[n]]},t.log=function(...e){return process.stderr.write(i.formatWithOptions(t.inspectOpts,...e)+"\n")},t.formatArgs=function(r){const{namespace:n,useColors:i}=this;if(i){const t=this.color,i="[3"+(t<8?t:"8;5;"+t),o=` ${i};1m${n} [0m`;r[0]=o+r[0].split("\n").join("\n"+o),r.push(i+"m+"+e.exports.humanize(this.diff)+"[0m")}else r[0]=(t.inspectOpts.hideDate?"":(new Date).toISOString()+" ")+n+" "+r[0]},t.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},t.load=function(){return process.env.DEBUG},t.useColors=function(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):n.isatty(process.stderr.fd)},t.destroy=i.deprecate((()=>{}),"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=r(7687);e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter((e=>/^debug_/i.test(e))).reduce(((e,t)=>{const r=t.substring(6).toLowerCase().replace(/_([a-z])/g,((e,t)=>t.toUpperCase()));let n=process.env[t];return n=!!/^(yes|on|true|enabled)$/i.test(n)||!/^(no|off|false|disabled)$/i.test(n)&&("null"===n?null:Number(n)),e[r]=n,e}),{}),e.exports=r(736)(t);const{formatters:o}=e.exports;o.o=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts).split("\n").map((e=>e.trim())).join(" ")},o.O=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts)}},2010:(e,t,r)=>{"use strict";var n=r(2861).Buffer,i=r(3527);function o(e){if(n.isBuffer(e))return e;if("string"==typeof e)return n.from(e,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function s(e,t,r){for(var n=0;t+n<r&&0===e[t+n];)++n;return e[t+n]>=128&&--n,n}e.exports={derToJose:function(e,t){e=o(e);var r=i(t),s=r+1,a=e.length,c=0;if(48!==e[c++])throw new Error('Could not find expected "seq"');var u=e[c++];if(129===u&&(u=e[c++]),a-c<u)throw new Error('"seq" specified length of "'+u+'", only "'+(a-c)+'" remaining');if(2!==e[c++])throw new Error('Could not find expected "int" for "r"');var p=e[c++];if(a-c-2<p)throw new Error('"r" specified length of "'+p+'", only "'+(a-c-2)+'" available');if(s<p)throw new Error('"r" specified length of "'+p+'", max of "'+s+'" is acceptable');var l=c;if(c+=p,2!==e[c++])throw new Error('Could not find expected "int" for "s"');var f=e[c++];if(a-c!==f)throw new Error('"s" specified length of "'+f+'", expected "'+(a-c)+'"');if(s<f)throw new Error('"s" specified length of "'+f+'", max of "'+s+'" is acceptable');var h=c;if((c+=f)!==a)throw new Error('Expected to consume entire buffer, but "'+(a-c)+'" bytes remain');var d=r-p,y=r-f,g=n.allocUnsafe(d+p+y+f);for(c=0;c<d;++c)g[c]=0;e.copy(g,c,l+Math.max(-d,0),l+p);for(var m=c=r;c<m+y;++c)g[c]=0;return e.copy(g,c,h+Math.max(-y,0),h+f),(g=g.toString("base64")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")},joseToDer:function(e,t){e=o(e);var r=i(t),a=e.length;if(a!==2*r)throw new TypeError('"'+t+'" signatures must be "'+2*r+'" bytes, saw "'+a+'"');var c=s(e,0,r),u=s(e,r,e.length),p=r-c,l=r-u,f=2+p+1+1+l,h=f<128,d=n.allocUnsafe((h?2:3)+f),y=0;return d[y++]=48,h?d[y++]=f:(d[y++]=129,d[y++]=255&f),d[y++]=2,d[y++]=p,c<0?(d[y++]=0,y+=e.copy(d,y,0,r)):y+=e.copy(d,y,c,r),d[y++]=2,d[y++]=l,u<0?(d[y++]=0,e.copy(d,y,r)):e.copy(d,y,r+u),d}}},3527:e=>{"use strict";function t(e){return(e/8|0)+(e%8==0?0:1)}var r={ES256:t(256),ES384:t(384),ES512:t(521)};e.exports=function(e){var t=r[e];if(t)return t;throw new Error('Unknown algorithm "'+e+'"')}},5884:e=>{"use strict";e.exports=(e,t=process.argv)=>{const r=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(r+e),i=t.indexOf("--");return-1!==n&&(-1===i||n<i)}},8083:e=>{const t={JOSEAlgNotWhitelisted:"ERR_JOSE_ALG_NOT_WHITELISTED",JOSECritNotUnderstood:"ERR_JOSE_CRIT_NOT_UNDERSTOOD",JOSEInvalidEncoding:"ERR_JOSE_INVALID_ENCODING",JOSEMultiError:"ERR_JOSE_MULTIPLE_ERRORS",JOSENotSupported:"ERR_JOSE_NOT_SUPPORTED",JWEDecryptionFailed:"ERR_JWE_DECRYPTION_FAILED",JWEInvalid:"ERR_JWE_INVALID",JWKImportFailed:"ERR_JWK_IMPORT_FAILED",JWKInvalid:"ERR_JWK_INVALID",JWKKeySupport:"ERR_JWK_KEY_SUPPORT",JWKSNoMatchingKey:"ERR_JWKS_NO_MATCHING_KEY",JWSInvalid:"ERR_JWS_INVALID",JWSVerificationFailed:"ERR_JWS_VERIFICATION_FAILED",JWTClaimInvalid:"ERR_JWT_CLAIM_INVALID",JWTExpired:"ERR_JWT_EXPIRED",JWTMalformed:"ERR_JWT_MALFORMED"},r={JWEDecryptionFailed:"decryption operation failed",JWEInvalid:"JWE invalid",JWKSNoMatchingKey:"no matching key found in the KeyStore",JWSInvalid:"JWS invalid",JWSVerificationFailed:"signature verification failed"};class n extends Error{constructor(e){super(e),void 0===e&&(this.message=r[this.constructor.name]),this.name=this.constructor.name,this.code=t[this.constructor.name],Error.captureStackTrace(this,this.constructor)}}const i=e=>e instanceof o;class o extends n{constructor(e){let t;for(super();(t=e.findIndex(i))&&-1!==t;)e.splice(t,1,...e[t]);Object.defineProperty(this,"errors",{value:e})}*[Symbol.iterator](){for(const e of this.errors)yield e}}e.exports.JOSEError=n,e.exports.JOSEAlgNotWhitelisted=class extends n{},e.exports.JOSECritNotUnderstood=class extends n{},e.exports.JOSEInvalidEncoding=class extends n{},e.exports.JOSEMultiError=o,e.exports.JOSENotSupported=class extends n{},e.exports.JWEDecryptionFailed=class extends n{},e.exports.JWEInvalid=class extends n{},e.exports.JWKImportFailed=class extends n{},e.exports.JWKInvalid=class extends n{},e.exports.JWKKeySupport=class extends n{},e.exports.JWKSNoMatchingKey=class extends n{},e.exports.JWSInvalid=class extends n{},e.exports.JWSVerificationFailed=class extends n{};class s extends n{constructor(e,t="unspecified",r="unspecified"){super(e),this.claim=t,this.reason=r}}e.exports.JWTClaimInvalid=s,e.exports.JWTExpired=class extends s{},e.exports.JWTMalformed=class extends n{}},9327:(e,t,r)=>{const n=r(1603);e.exports=function(){this.seq().obj(this.key("algorithm").objid(n),this.key("parameters").optional().choice({namedCurve:this.objid(n),null:this.null_()}))}},8510:(e,t,r)=>{const n=r(1603);e.exports=function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().choice({namedCurve:this.objid(n)}),this.key("publicKey").explicit(1).optional().bitstr())}},4804:(e,t,r)=>{const n=r(6861),i=new Map,o=n.define("AlgorithmIdentifier",r(9327));i.set("AlgorithmIdentifier",o);const s=n.define("ECPrivateKey",r(8510));i.set("ECPrivateKey",s);const a=n.define("PrivateKeyInfo",r(7634)(o));i.set("PrivateKeyInfo",a);const c=n.define("PublicKeyInfo",r(6646)(o));i.set("PublicKeyInfo",c);const u=n.define("PrivateKey",r(2035));i.set("PrivateKey",u);const p=n.define("OneAsymmetricKey",r(6553)(o,u));i.set("OneAsymmetricKey",p);const l=n.define("RSAPrivateKey",r(4574));i.set("RSAPrivateKey",l);const f=n.define("RSAPublicKey",r(4372));i.set("RSAPublicKey",f),e.exports=i},1603:e=>{e.exports={"1 2 840 10045 3 1 7":"P-256","1 3 132 0 10":"secp256k1","1 3 132 0 34":"P-384","1 3 132 0 35":"P-521","1 2 840 10045 2 1":"ecPublicKey","1 2 840 113549 1 1 1":"rsaEncryption","1 3 101 110":"X25519","1 3 101 111":"X448","1 3 101 112":"Ed25519","1 3 101 113":"Ed448"}},6553:e=>{e.exports=(e,t)=>function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(e),this.key("privateKey").use(t))}},2035:e=>{e.exports=function(){this.octstr().contains().obj(this.key("privateKey").octstr())}},7634:e=>{e.exports=e=>function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(e),this.key("privateKey").octstr())}},6646:e=>{e.exports=e=>function(){this.seq().obj(this.key("algorithm").use(e),this.key("publicKey").bitstr())}},4574:e=>{e.exports=function(){this.seq().obj(this.key("version").int({0:"two-prime",1:"multi"}),this.key("n").int(),this.key("e").int(),this.key("d").int(),this.key("p").int(),this.key("q").int(),this.key("dp").int(),this.key("dq").int(),this.key("qi").int())}},4372:e=>{e.exports=function(){this.seq().obj(this.key("n").int(),this.key("e").int())}},6204:e=>{let t,r;if(Buffer.isEncoding("base64url"))t=(e,t="utf8")=>Buffer.from(e,t).toString("base64url"),r=e=>e.toString("base64url");else{const e=e=>e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");t=(t,r="utf8")=>e(Buffer.from(t,r).toString("base64")),r=t=>e(t.toString("base64"))}const n=e=>Buffer.from(e,"base64"),i=(e,t="utf8")=>n(e).toString(t),o={encode:e=>t(JSON.stringify(e)),decode:(e,t="utf8")=>JSON.parse(i(e,t))};o.decode.try=(e,t="utf8")=>{try{return o.decode(e,t)}catch(r){return i(e,t)}},e.exports.decode=i,e.exports.decodeToBuffer=n,e.exports.encode=t,e.exports.encodeBuffer=r,e.exports.JSON=o,e.exports.encodeBigInt=e=>r(Buffer.from((e=>{let t=BigInt(e).toString(16);t.length%2&&(t=`0${t}`);const r=t.length/2,n=new Uint8Array(r);let i=0,o=0;for(;i<r;)n[i]=parseInt(t.slice(o,o+2),16),i+=1,o+=2;return n})(e)))},3146:e=>{e.exports.KEYOBJECT=Symbol("KEYOBJECT"),e.exports.PRIVATE_MEMBERS=Symbol("PRIVATE_MEMBERS"),e.exports.PUBLIC_MEMBERS=Symbol("PUBLIC_MEMBERS"),e.exports.THUMBPRINT_MATERIAL=Symbol("THUMBPRINT_MATERIAL"),e.exports.JWK_MEMBERS=Symbol("JWK_MEMBERS"),e.exports.KEY_MANAGEMENT_ENCRYPT=Symbol("KEY_MANAGEMENT_ENCRYPT"),e.exports.KEY_MANAGEMENT_DECRYPT=Symbol("KEY_MANAGEMENT_DECRYPT");const t={sig:new Set(["sign","verify"]),enc:new Set(["encrypt","decrypt","wrapKey","unwrapKey","deriveKey"])},r=new Set([...t.sig,...t.enc]),n=new Set(Object.keys(t));e.exports.USES_MAPPING=t,e.exports.OPS=r,e.exports.USES=n},8290:e=>{e.exports=e=>JSON.parse(JSON.stringify(e))},2028:e=>{const t=e=>(e/8|0)+(e%8==0?0:1),r={ES256:t(256),ES256K:t(256),ES384:t(384),ES512:t(521)},n=(e,t,r)=>{let n=0;for(;t+n<r&&0===e[t+n];)++n;return e[t+n]>=128&&--n,n};e.exports.derToJose=(e,t)=>{if(!Buffer.isBuffer(e))throw new TypeError("ECDSA signature must be a Buffer");if(!r[t])throw new Error(`Unknown algorithm "${t}"`);const n=r[t],i=n+1,o=e.length;let s=0;if(48!==e[s++])throw new Error('Could not find expected "seq"');let a=e[s++];if(129===a&&(a=e[s++]),o-s<a)throw new Error(`"seq" specified length of ${a}", only ${o-s}" remaining`);if(2!==e[s++])throw new Error('Could not find expected "int" for "r"');const c=e[s++];if(o-s-2<c)throw new Error(`"r" specified length of "${c}", only "${o-s-2}" available`);if(i<c)throw new Error(`"r" specified length of "${c}", max of "${i}" is acceptable`);const u=s;if(s+=c,2!==e[s++])throw new Error('Could not find expected "int" for "s"');const p=e[s++];if(o-s!==p)throw new Error(`"s" specified length of "${p}", expected "${o-s}"`);if(i<p)throw new Error(`"s" specified length of "${p}", max of "${i}" is acceptable`);const l=s;if(s+=p,s!==o)throw new Error(`Expected to consume entire buffer, but "${o-s}" bytes remain`);const f=n-c,h=n-p,d=Buffer.allocUnsafe(f+c+h+p);for(s=0;s<f;++s)d[s]=0;e.copy(d,s,u+Math.max(-f,0),u+c),s=n;for(const e=s;s<e+h;++s)d[s]=0;return e.copy(d,s,l+Math.max(-h,0),l+p),d},e.exports.joseToDer=(e,t)=>{if(!Buffer.isBuffer(e))throw new TypeError("ECDSA signature must be a Buffer");if(!r[t])throw new TypeError(`Unknown algorithm "${t}"`);const i=r[t],o=e.length;if(o!==2*i)throw new Error(`"${t}" signatures must be "${2*i}" bytes, saw "${o}"`);const s=n(e,0,i),a=n(e,i,e.length),c=i-s,u=i-a,p=2+c+1+1+u,l=p<128,f=Buffer.allocUnsafe((l?2:3)+p);let h=0;return f[h++]=48,l?f[h++]=p:(f[h++]=129,f[h++]=255&p),f[h++]=2,f[h++]=c,s<0?(f[h++]=0,h+=e.copy(f,h,0,i)):h+=e.copy(f,h,s,i),f[h++]=2,f[h++]=u,a<0?(f[h++]=0,e.copy(f,h,i)):e.copy(f,h,i+a),f}},9973:e=>{e.exports=e=>Math.floor(e.getTime()/1e3)},8399:(e,t,r)=>{const{randomBytes:n}=r(6982),{IVLENGTHS:i}=r(3648);e.exports=e=>n(i.get(e)/8)},9096:(e,t,r)=>{const n=r(8083),i=r(6108),o=r(876),{KeyStore:s}=r(5088);e.exports=(e,t=!1)=>{if(e instanceof i)return e;if(e instanceof s){if(!t)throw new TypeError("key argument for this operation must not be a JWKS.KeyStore instance");return e}try{return o(e)}catch(e){if(e instanceof n.JOSEError&&!(e instanceof n.JWKImportFailed))throw e;let r;throw r=t?"key must be an instance of a key instantiated by JWK.asKey, a valid JWK.asKey input, or a JWKS.KeyStore instance":"key must be an instance of a key instantiated by JWK.asKey, or a valid JWK.asKey input",new TypeError(r)}}},8253:e=>{e.exports=(e={},t={})=>{const r=Object.keys(e),n=new Set(Object.keys(t));return!r.some((e=>n.has(e)))}},226:e=>{e.exports=e=>!!e&&e.constructor===Object},2805:(e,t,r)=>{const{keyObjectSupported:n}=r(7580);let i,o,s,a,c;if(n)({createPublicKey:i,createPrivateKey:o,createSecretKey:s,KeyObject:a}=r(6982)),c=e=>e;else{const{EOL:e}=r(857),t=r(8083),n=r(226),u=r(4804),p=Symbol("toInput"),l=Symbol("namedCurve");c=(e,t)=>e instanceof a?e[p](t):s(e)[p](t);const f=e=>Buffer.from(e.replace(/(?:-----(?:BEGIN|END)(?: (?:RSA|EC))? (?:PRIVATE|PUBLIC) KEY-----|\s)/g,""),"base64"),h=(t,r)=>`-----BEGIN ${r}-----${e}${(t.toString("base64").match(/.{1,64}/g)||[]).join(e)}${e}-----END ${r}-----`,d=e=>{const r="string"==typeof e?e:`OID ${e.join(".")}`;throw new t.JOSENotSupported(`${r} is not supported in your Node.js runtime version`)};a=class{export({cipher:e,passphrase:r,type:n,format:i}={}){if("secret"===this._type)return this._buffer;if("public"===this._type){if("rsa"===this.asymmetricKeyType)switch(n){case"pkcs1":return"pem"===i?this._pem:f(this._pem);case"spki":{const e=u.get("PublicKeyInfo").encode({algorithm:{algorithm:"rsaEncryption",parameters:{type:"null"}},publicKey:{unused:0,data:f(this._pem)}},"pem",{label:"PUBLIC KEY"});return"pem"===i?e:f(e)}default:throw new TypeError(`The value ${n} is invalid for option "type"`)}if("ec"===this.asymmetricKeyType){if("spki"!==n)throw new TypeError(`The value ${n} is invalid for option "type"`);return"pem"===i?this._pem:f(this._pem)}}if("private"===this._type){if(void 0!==r||void 0!==e)throw new t.JOSENotSupported("encrypted private keys are not supported in your Node.js runtime version");if("pkcs8"===n){if(this._pkcs8)return"der"===i&&"string"==typeof this._pkcs8?f(this._pkcs8):"pem"===i&&Buffer.isBuffer(this._pkcs8)?h(this._pkcs8,"PRIVATE KEY"):this._pkcs8;if("rsa"===this.asymmetricKeyType){const e=this._asn1,t=u.get("RSAPrivateKey").encode(e),r=u.get("PrivateKeyInfo").encode({version:0,privateKey:t,algorithm:{algorithm:"rsaEncryption",parameters:{type:"null"}}});return this._pkcs8=r,this.export({type:n,format:i})}if("ec"===this.asymmetricKeyType){const e=this._asn1,t=u.get("ECPrivateKey").encode({version:e.version,privateKey:e.privateKey,publicKey:e.publicKey}),r=u.get("PrivateKeyInfo").encode({version:0,privateKey:t,algorithm:{algorithm:"ecPublicKey",parameters:this._asn1.parameters}});return this._pkcs8=r,this.export({type:n,format:i})}}if("rsa"===this.asymmetricKeyType&&"pkcs1"===n)return"pem"===i?this._pem:f(this._pem);if("ec"===this.asymmetricKeyType&&"sec1"===n)return"pem"===i?this._pem:f(this._pem);throw new TypeError(`The value ${n} is invalid for option "type"`)}}get type(){return this._type}get asymmetricKeyType(){return this._asymmetricKeyType}get symmetricKeySize(){return this._symmetricKeySize}[p](e){switch(this._type){case"secret":return this._buffer;case"public":return this._pem;default:return e?("_pub"in this||(this._pub=i(this)),this._pub[p](!1)):this._pem}}},s=e=>{if(!Buffer.isBuffer(e)||!e.length)throw new TypeError("input must be a non-empty Buffer instance");const t=new a;return t._buffer=Buffer.from(e),t._symmetricKeySize=e.length,t._type="secret",t},i=e=>{if(e instanceof a){if("private"!==e.type)throw new TypeError(`Invalid key object type ${e.type}, expected private.`);switch(e.asymmetricKeyType){case"ec":{const t=u.get("PublicKeyInfo").encode({algorithm:{algorithm:"ecPublicKey",parameters:e._asn1.parameters},publicKey:e._asn1.publicKey});return i({key:t,format:"der",type:"spki"})}case"rsa":{const t=u.get("RSAPublicKey").encode(e._asn1);return i({key:t,format:"der",type:"pkcs1"})}}}if(("string"==typeof e||Buffer.isBuffer(e))&&(e={key:e,format:"pem"}),!n(e))throw new TypeError("input must be a string, Buffer or an object");const{format:r,passphrase:s}=e;let c,{key:p,type:l}=e;if("string"!=typeof p&&!Buffer.isBuffer(p))throw new TypeError("key must be a string or Buffer");if("pem"!==r&&"der"!==r)throw new TypeError('format must be one of "pem" or "der"');if("pem"===r)switch(p=p.toString(),p.split(/\r?\n/g)[0].toString()){case"-----BEGIN PUBLIC KEY-----":l="spki",c="PUBLIC KEY";break;case"-----BEGIN RSA PUBLIC KEY-----":l="pkcs1",c="RSA PUBLIC KEY";break;case"-----BEGIN CERTIFICATE-----":throw new t.JOSENotSupported("X.509 certificates are not supported in your Node.js runtime version");case"-----BEGIN PRIVATE KEY-----":case"-----BEGIN EC PRIVATE KEY-----":case"-----BEGIN RSA PRIVATE KEY-----":return i(o(p));default:throw new TypeError("unknown/unsupported PEM type")}switch(l){case"spki":{const e=u.get("PublicKeyInfo"),t=e.decode(p,r,{label:c});let n,o;switch(t.algorithm.algorithm){case"ecPublicKey":o=new a,o._asn1=t,o._asymmetricKeyType="ec",o._type="public",o._pem=e.encode(t,"pem",{label:"PUBLIC KEY"});break;case"rsaEncryption":n="pkcs1",o=i({type:n,key:t.publicKey.data,format:"der"});break;default:d(t.algorithm.algorithm)}return o}case"pkcs1":{const e=u.get("RSAPublicKey"),t=e.decode(p,r,{label:c});if(t.n===BigInt(0))return i(o({key:p,format:r,type:l,passphrase:s}));const n=new a;return n._asn1=t,n._asymmetricKeyType="rsa",n._type="public",n._pem=e.encode(t,"pem",{label:"RSA PUBLIC KEY"}),n}case"pkcs8":case"sec1":return i(o({format:r,key:p,type:l,passphrase:s}));default:throw new TypeError(`The value ${l} is invalid for option "type"`)}},o=(e,r)=>{if(("string"==typeof e||Buffer.isBuffer(e))&&(e={key:e,format:"pem"}),!n(e))throw new TypeError("input must be a string, Buffer or an object");const{format:i,passphrase:s}=e;let c,{key:p,type:f}=e;if("string"!=typeof p&&!Buffer.isBuffer(p))throw new TypeError("key must be a string or Buffer");if(void 0!==s)throw new t.JOSENotSupported("encrypted private keys are not supported in your Node.js runtime version");if("pem"!==i&&"der"!==i)throw new TypeError('format must be one of "pem" or "der"');if("pem"===i)switch(p=p.toString(),p.split(/\r?\n/g)[0].toString()){case"-----BEGIN PRIVATE KEY-----":f="pkcs8",c="PRIVATE KEY";break;case"-----BEGIN EC PRIVATE KEY-----":f="sec1",c="EC PRIVATE KEY";break;case"-----BEGIN RSA PRIVATE KEY-----":f="pkcs1",c="RSA PRIVATE KEY";break;default:throw new TypeError("unknown/unsupported PEM type")}switch(f){case"pkcs8":{const e=u.get("PrivateKeyInfo").decode(p,i,{label:c});let t,r;switch(e.algorithm.algorithm){case"ecPublicKey":t="sec1",r=o({type:t,key:e.privateKey,format:"der"},{[l]:e.algorithm.parameters.value});break;case"rsaEncryption":t="pkcs1",r=o({type:t,key:e.privateKey,format:"der"});break;default:d(e.algorithm.algorithm)}return r._pkcs8=p,r}case"pkcs1":{const e=u.get("RSAPrivateKey"),t=e.decode(p,i,{label:c}),r=new a;return r._asn1=t,r._asymmetricKeyType="rsa",r._type="private",r._pem=e.encode(t,"pem",{label:"RSA PRIVATE KEY"}),r}case"sec1":{const e=u.get("ECPrivateKey");let t=e.decode(p,i,{label:c});if(!("parameters"in t)&&!r[l])throw new Error("invalid sec1");"parameters"in t||(t={...t,parameters:{type:"namedCurve",value:r[l]}});const n=new a;return n._asn1=t,n._asymmetricKeyType="ec",n._type="private",n._pem=e.encode(t,"pem",{label:"EC PRIVATE KEY"}),n}default:throw new TypeError(`The value ${f} is invalid for option "type"`)}}}e.exports={createPublicKey:i,createPrivateKey:o,createSecretKey:s,KeyObject:a,asInput:c}},4297:(e,t,r)=>{const{EOL:n}=r(857),i=r(8083),{keyObjectSupported:o}=r(7580),{createPublicKey:s}=r(2805),a=r(6204),c=r(4804),u=r(1549),{OKP_CURVES:p,EC_CURVES:l}=r(3648),f={private(e,t){const r=t.export({type:"pkcs8",format:"der"}),n=c.get("OneAsymmetricKey"),{privateKey:{privateKey:i}}=n.decode(r);return{...f.public(e,s(t)),d:a.encodeBu