@stacksjs/rpx 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -12
- package/dist/bin/cli.js +7 -7
- package/dist/{chunk-45dw2f5f.js → chunk-1j93wxbr.js} +1 -1
- package/dist/chunk-1rkjbws7.js +60 -0
- package/dist/{chunk-e794mmrn.js → chunk-7am1svx0.js} +1 -1
- package/dist/{chunk-2y0c08hn.js → chunk-ny83tnrp.js} +3 -3
- package/dist/chunk-zxymjc5f.js +45 -0
- package/dist/config.d.ts +3 -3
- package/dist/https.d.ts +8 -8
- package/dist/process-manager.d.ts +152 -0
- package/dist/src/index.js +1 -1
- package/dist/start.d.ts +90 -8
- package/dist/types.d.ts +23 -21
- package/dist/utils.d.ts +7 -6
- package/package.json +22 -17
- package/dist/chunk-9v712d8y.js +0 -45
- package/dist/chunk-en36kajt.js +0 -24
- package/dist/chunk-wn28gp4d.js +0 -37
package/dist/chunk-wn28gp4d.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import{H as ce}from"./chunk-en36kajt.js";import{I as cr,J as le,K as zt,O as Kr}from"./chunk-2y0c08hn.js";import{P as ua,Q as na}from"./chunk-e794mmrn.js";var ui=na((Nn,Ar)=>{var $t=process||{},oi=$t.argv||[],Zt=$t.env||{},sa=!(!!Zt.NO_COLOR||oi.includes("--no-color"))&&(!!Zt.FORCE_COLOR||oi.includes("--color")||$t.platform==="win32"||($t.stdout||{}).isTTY&&Zt.TERM!=="dumb"||!!Zt.CI),oa=(N,_,t=N)=>(e)=>{let a=""+e,d=a.indexOf(_,N.length);return~d?N+ca(a,_,t,d)+_:N+a+_},ca=(N,_,t,e)=>{let a="",d=0;do a+=N.substring(d,e)+t,d=e+_.length,e=N.indexOf(_,d);while(~e);return a+N.substring(d)},ci=(N=sa)=>{let _=N?oa:()=>String;return{isColorSupported:N,reset:_("\x1B[0m","\x1B[0m"),bold:_("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:_("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:_("\x1B[3m","\x1B[23m"),underline:_("\x1B[4m","\x1B[24m"),inverse:_("\x1B[7m","\x1B[27m"),hidden:_("\x1B[8m","\x1B[28m"),strikethrough:_("\x1B[9m","\x1B[29m"),black:_("\x1B[30m","\x1B[39m"),red:_("\x1B[31m","\x1B[39m"),green:_("\x1B[32m","\x1B[39m"),yellow:_("\x1B[33m","\x1B[39m"),blue:_("\x1B[34m","\x1B[39m"),magenta:_("\x1B[35m","\x1B[39m"),cyan:_("\x1B[36m","\x1B[39m"),white:_("\x1B[37m","\x1B[39m"),gray:_("\x1B[90m","\x1B[39m"),bgBlack:_("\x1B[40m","\x1B[49m"),bgRed:_("\x1B[41m","\x1B[49m"),bgGreen:_("\x1B[42m","\x1B[49m"),bgYellow:_("\x1B[43m","\x1B[49m"),bgBlue:_("\x1B[44m","\x1B[49m"),bgMagenta:_("\x1B[45m","\x1B[49m"),bgCyan:_("\x1B[46m","\x1B[49m"),bgWhite:_("\x1B[47m","\x1B[49m"),blackBright:_("\x1B[90m","\x1B[39m"),redBright:_("\x1B[91m","\x1B[39m"),greenBright:_("\x1B[92m","\x1B[39m"),yellowBright:_("\x1B[93m","\x1B[39m"),blueBright:_("\x1B[94m","\x1B[39m"),magentaBright:_("\x1B[95m","\x1B[39m"),cyanBright:_("\x1B[96m","\x1B[39m"),whiteBright:_("\x1B[97m","\x1B[39m"),bgBlackBright:_("\x1B[100m","\x1B[49m"),bgRedBright:_("\x1B[101m","\x1B[49m"),bgGreenBright:_("\x1B[102m","\x1B[49m"),bgYellowBright:_("\x1B[103m","\x1B[49m"),bgBlueBright:_("\x1B[104m","\x1B[49m"),bgMagentaBright:_("\x1B[105m","\x1B[49m"),bgCyanBright:_("\x1B[106m","\x1B[49m"),bgWhiteBright:_("\x1B[107m","\x1B[49m")}};Ar.exports=ci();Ar.exports.createColors=ci});var Br="0.9.1";import{homedir as rr}from"node:os";import{join as ir}from"node:path";import{resolve as Di}from"path";import Ui from"process";function tr(N,_){if(Array.isArray(_)&&!Array.isArray(N))return _;if(Array.isArray(_)&&Array.isArray(N))return _.map((e,a)=>{let d=N[a];if(Nt(e)&&Nt(d))return tr(d,e);return e});if(!Nt(_)||!Nt(N))return _;let t={...N};for(let e in _)if(Object.prototype.hasOwnProperty.call(_,e)){let a=_[e],d=t[e];if(a===null||a===void 0)t[e]=a;else if(Nt(a)&&Nt(d))t[e]=tr(d,a);else t[e]=a}return t}function Nt(N){return Boolean(N&&typeof N==="object"&&!Array.isArray(N))}async function Nr({name:N,cwd:_,defaultConfig:t}){let e=Di(_||Ui.cwd(),`${N}.config`);try{let a=await import(e),d=a.default||a;return tr(t,d)}catch(a){return t}}var Vi={from:"localhost:5173",to:"stacks.localhost",cleanUrls:!1,https:{basePath:"",caCertPath:ir(rr(),".stacks","ssl","stacks.localhost.ca.crt"),certPath:ir(rr(),".stacks","ssl","stacks.localhost.crt"),keyPath:ir(rr(),".stacks","ssl","stacks.localhost.crt.key")},cleanup:{certs:!1,hosts:!1},vitePluginUsage:!1,verbose:!0},Ut=await Nr({name:"reverse-proxy",defaultConfig:Vi});import*as wr from"node:fs/promises";function $(N,_,t){if(t)console.debug(`[rpx:${N}] ${_}`)}function Ia(N){if(Pt(N))return N.proxies.map((_)=>{let t=_.to||"stacks.localhost";return t.startsWith("http")?new URL(t).hostname:t});if(Qt(N)){let _=N.to||"stacks.localhost";return[_.startsWith("http")?new URL(_).hostname:_]}return["stacks.localhost"]}function kr(N){return typeof N==="object"&&N!==null&&"certificate"in N&&"privateKey"in N&&typeof N.certificate==="string"&&typeof N.privateKey==="string"}function Ht(N){if(!N)return"stacks.localhost";if(Pt(N)&&N.proxies.length>0)return N.proxies[0].to||"stacks.localhost";if(Qt(N))return N.to||"stacks.localhost";return"stacks.localhost"}function Vt(N){return"proxies"in N&&Array.isArray(N.proxies)}function Pt(N){return"proxies"in N&&Array.isArray(N.proxies)}function Qt(N){return"to"in N&&typeof N.to==="string"}async function Rr(N,_){try{await wr.unlink(N),$("certificates",`Successfully deleted: ${N}`,_)}catch(t){if(t.code!=="ENOENT")$("certificates",`Warning: Could not delete ${N}: ${t}`,_)}}import{exec as Pi}from"node:child_process";import St from"node:fs";import _r from"node:os";import ar from"node:path";import xt from"node:process";import{promisify as xi}from"node:util";var Ki=xi(Pi),mt=xt.platform==="win32"?ar.join(xt.env.windir||"C:\\Windows","System32","drivers","etc","hosts"):"/etc/hosts";async function Lr(N){if(xt.platform==="win32")throw new Error("Administrator privileges required on Windows");try{await Ki(`sudo ${N}`)}catch(_){throw new Error(`Failed to execute sudo command: ${_.message}`)}}async function Dr(N,_){$("hosts",`Adding hosts: ${N.join(", ")}`,_),$("hosts",`Using hosts file at: ${mt}`,_);try{let t=await St.promises.readFile(mt,"utf-8"),e=N.filter((v)=>{let g=`127.0.0.1 ${v}`,u=`::1 ${v}`;return!t.includes(g)&&!t.includes(u)});if(e.length===0){$("hosts","All hosts already exist in hosts file",_),ce.info("All hosts are already in the hosts file");return}let a=e.map((v)=>`
|
|
2
|
-
# Added by rpx
|
|
3
|
-
127.0.0.1 ${v}
|
|
4
|
-
::1 ${v}`).join(`
|
|
5
|
-
`),d=ar.join(_r.tmpdir(),"hosts.tmp");await St.promises.writeFile(d,t+a,"utf8");try{await Lr(`cp "${d}" "${mt}"`),ce.success(`Added new hosts: ${e.join(", ")}`)}catch(v){if(ce.error("Failed to modify hosts file automatically"),ce.warn("Please add these entries to your hosts file manually:"),a.split(`
|
|
6
|
-
`).forEach((g)=>ce.warn(g)),xt.platform==="win32")ce.warn(`
|
|
7
|
-
On Windows:`),ce.warn("1. Run notepad as administrator"),ce.warn("2. Open C:\\Windows\\System32\\drivers\\etc\\hosts");else ce.warn(`
|
|
8
|
-
On Unix systems:`),ce.warn(`sudo nano ${mt}`);throw new Error("Failed to modify hosts file: manual intervention required")}finally{St.unlinkSync(d)}}catch(t){let e=t;throw ce.error(`Failed to manage hosts file: ${e.message}`),e}}async function Ur(N,_){$("hosts",`Removing hosts: ${N.join(", ")}`,_);try{let e=(await St.promises.readFile(mt,"utf-8")).split(`
|
|
9
|
-
`),a=e.filter((g,u)=>{if(g.trim()==="# Added by rpx")return e.splice(u+1,2),!1;return!0});while(a[a.length-1]?.trim()==="")a.pop();let d=`${a.join(`
|
|
10
|
-
`)}
|
|
11
|
-
`,v=ar.join(_r.tmpdir(),"hosts.tmp");await St.promises.writeFile(v,d,"utf8");try{await Lr(`cp "${v}" "${mt}"`),ce.success("Hosts removed successfully")}catch(g){if(ce.error("Failed to modify hosts file automatically"),ce.warn("Please remove these entries from your hosts file manually:"),N.forEach((u)=>{ce.warn("# Added by rpx"),ce.warn(`127.0.0.1 ${u}`),ce.warn(`::1 ${u}`)}),xt.platform==="win32")ce.warn(`
|
|
12
|
-
On Windows:`),ce.warn("1. Run notepad as administrator"),ce.warn("2. Open C:\\Windows\\System32\\drivers\\etc\\hosts");else ce.warn(`
|
|
13
|
-
On Unix systems:`),ce.warn(`sudo nano ${mt}`);throw new Error("Failed to modify hosts file: manual intervention required")}finally{St.unlinkSync(v)}}catch(t){let e=t;throw ce.error(`Failed to remove hosts: ${e.message}`),e}}async function Vr(N,_){$("hosts",`Checking hosts: ${N}`,_);let t=await St.promises.readFile(mt,"utf-8");return N.map((e)=>{let a=`127.0.0.1 ${e}`,d=`::1 ${e}`;return t.includes(a)||t.includes(d)})}import Ft from"node:fs/promises";import{homedir as aa}from"node:os";import{join as At}from"node:path";import nr from"node:os";import sr from"node:path";import{resolve as Xi}from"path";import Wi from"process";import{exec as $i}from"node:child_process";import Pr from"node:fs";import Ji from"node:path";import ea from"node:process";import{promisify as ta}from"node:util";import dt from"node:fs";import xr from"node:os";import kt from"node:path";var pe=le((N,_)=>{_.exports={options:{usePureJavaScript:!1}}}),Oi=le((N,_)=>{var t={};_.exports=t;var e={};t.encode=function(d,v,g){if(typeof v!=="string")throw new TypeError('"alphabet" must be a string.');if(g!==void 0&&typeof g!=="number")throw new TypeError('"maxline" must be a number.');var u="";if(!(d instanceof Uint8Array))u=a(d,v);else{var r=0,C=v.length,f=v.charAt(0),I=[0];for(r=0;r<d.length;++r){for(var U=0,T=d[r];U<I.length;++U)T+=I[U]<<8,I[U]=T%C,T=T/C|0;while(T>0)I.push(T%C),T=T/C|0}for(r=0;d[r]===0&&r<d.length-1;++r)u+=f;for(r=I.length-1;r>=0;--r)u+=v[I[r]]}if(g){var c=new RegExp(".{1,"+g+"}","g");u=u.match(c).join(`\r
|
|
14
|
-
`)}return u},t.decode=function(d,v){if(typeof d!=="string")throw new TypeError('"input" must be a string.');if(typeof v!=="string")throw new TypeError('"alphabet" must be a string.');var g=e[v];if(!g){g=e[v]=[];for(var u=0;u<v.length;++u)g[v.charCodeAt(u)]=u}d=d.replace(/\s/g,"");var r=v.length,C=v.charAt(0),f=[0];for(var u=0;u<d.length;u++){var I=g[d.charCodeAt(u)];if(I===void 0)return;for(var U=0,T=I;U<f.length;++U)T+=f[U]*r,f[U]=T&255,T>>=8;while(T>0)f.push(T&255),T>>=8}for(var c=0;d[c]===C&&c<d.length-1;++c)f.push(0);if(typeof Buffer!=="undefined")return Buffer.from(f.reverse());return new Uint8Array(f.reverse())};function a(d,v){var g=0,u=v.length,r=v.charAt(0),C=[0];for(g=0;g<d.length();++g){for(var f=0,I=d.at(g);f<C.length;++f)I+=C[f]<<8,C[f]=I%u,I=I/u|0;while(I>0)C.push(I%u),I=I/u|0}var U="";for(g=0;d.at(g)===0&&g<d.length()-1;++g)U+=r;for(g=C.length-1;g>=0;--g)U+=v[C[g]];return U}}),Ce=le((N,_)=>{var t=pe(),e=Oi(),a=_.exports=t.util=t.util||{};(function(){if(typeof process!=="undefined"&&process.nextTick){if(a.nextTick=process.nextTick,typeof setImmediate==="function")a.setImmediate=setImmediate;else a.setImmediate=a.nextTick;return}if(typeof setImmediate==="function"){a.setImmediate=function(){return setImmediate.apply(void 0,arguments)},a.nextTick=function(i){return setImmediate(i)};return}if(a.setImmediate=function(i){setTimeout(i,0)},typeof window!=="undefined"&&typeof window.postMessage==="function"){let i=function(B){if(B.source===window&&B.data===p){B.stopPropagation();var P=y.slice();y.length=0,P.forEach(function(O){O()})}};var n=i,p="forge.setImmediate",y=[];a.setImmediate=function(B){if(y.push(B),y.length===1)window.postMessage(p,"*")},window.addEventListener("message",i,!0)}if(typeof MutationObserver!=="undefined"){var b=Date.now(),L=!0,h=document.createElement("div"),y=[];new MutationObserver(function(){var B=y.slice();y.length=0,B.forEach(function(P){P()})}).observe(h,{attributes:!0});var s=a.setImmediate;a.setImmediate=function(B){if(Date.now()-b>15)b=Date.now(),s(B);else if(y.push(B),y.length===1)h.setAttribute("a",L=!L)}}a.nextTick=a.setImmediate})(),a.isNodejs=typeof process!=="undefined"&&process.versions&&process.versions.node,a.globalScope=function(){if(a.isNodejs)return global;return typeof self==="undefined"?window:self}(),a.isArray=Array.isArray||function(n){return Object.prototype.toString.call(n)==="[object Array]"},a.isArrayBuffer=function(n){return typeof ArrayBuffer!=="undefined"&&n instanceof ArrayBuffer},a.isArrayBufferView=function(n){return n&&a.isArrayBuffer(n.buffer)&&n.byteLength!==void 0};function d(n){if(!(n===8||n===16||n===24||n===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+n)}a.ByteBuffer=v;function v(n){if(this.data="",this.read=0,typeof n==="string")this.data=n;else if(a.isArrayBuffer(n)||a.isArrayBufferView(n))if(typeof Buffer!=="undefined"&&n instanceof Buffer)this.data=n.toString("binary");else{var p=new Uint8Array(n);try{this.data=String.fromCharCode.apply(null,p)}catch(b){for(var y=0;y<p.length;++y)this.putByte(p[y])}}else if(n instanceof v||typeof n==="object"&&typeof n.data==="string"&&typeof n.read==="number")this.data=n.data,this.read=n.read;this._constructedStringLength=0}a.ByteStringBuffer=v;var g=4096;a.ByteStringBuffer.prototype._optimizeConstructedString=function(n){if(this._constructedStringLength+=n,this._constructedStringLength>g)this.data.substr(0,1),this._constructedStringLength=0},a.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},a.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},a.ByteStringBuffer.prototype.putByte=function(n){return this.putBytes(String.fromCharCode(n))},a.ByteStringBuffer.prototype.fillWithByte=function(n,p){n=String.fromCharCode(n);var y=this.data;while(p>0){if(p&1)y+=n;if(p>>>=1,p>0)n+=n}return this.data=y,this._optimizeConstructedString(p),this},a.ByteStringBuffer.prototype.putBytes=function(n){return this.data+=n,this._optimizeConstructedString(n.length),this},a.ByteStringBuffer.prototype.putString=function(n){return this.putBytes(a.encodeUtf8(n))},a.ByteStringBuffer.prototype.putInt16=function(n){return this.putBytes(String.fromCharCode(n>>8&255)+String.fromCharCode(n&255))},a.ByteStringBuffer.prototype.putInt24=function(n){return this.putBytes(String.fromCharCode(n>>16&255)+String.fromCharCode(n>>8&255)+String.fromCharCode(n&255))},a.ByteStringBuffer.prototype.putInt32=function(n){return this.putBytes(String.fromCharCode(n>>24&255)+String.fromCharCode(n>>16&255)+String.fromCharCode(n>>8&255)+String.fromCharCode(n&255))},a.ByteStringBuffer.prototype.putInt16Le=function(n){return this.putBytes(String.fromCharCode(n&255)+String.fromCharCode(n>>8&255))},a.ByteStringBuffer.prototype.putInt24Le=function(n){return this.putBytes(String.fromCharCode(n&255)+String.fromCharCode(n>>8&255)+String.fromCharCode(n>>16&255))},a.ByteStringBuffer.prototype.putInt32Le=function(n){return this.putBytes(String.fromCharCode(n&255)+String.fromCharCode(n>>8&255)+String.fromCharCode(n>>16&255)+String.fromCharCode(n>>24&255))},a.ByteStringBuffer.prototype.putInt=function(n,p){d(p);var y="";do p-=8,y+=String.fromCharCode(n>>p&255);while(p>0);return this.putBytes(y)},a.ByteStringBuffer.prototype.putSignedInt=function(n,p){if(n<0)n+=2<<p-1;return this.putInt(n,p)},a.ByteStringBuffer.prototype.putBuffer=function(n){return this.putBytes(n.getBytes())},a.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},a.ByteStringBuffer.prototype.getInt16=function(){var n=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,n},a.ByteStringBuffer.prototype.getInt24=function(){var n=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,n},a.ByteStringBuffer.prototype.getInt32=function(){var n=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,n},a.ByteStringBuffer.prototype.getInt16Le=function(){var n=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,n},a.ByteStringBuffer.prototype.getInt24Le=function(){var n=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,n},a.ByteStringBuffer.prototype.getInt32Le=function(){var n=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,n},a.ByteStringBuffer.prototype.getInt=function(n){d(n);var p=0;do p=(p<<8)+this.data.charCodeAt(this.read++),n-=8;while(n>0);return p},a.ByteStringBuffer.prototype.getSignedInt=function(n){var p=this.getInt(n),y=2<<n-2;if(p>=y)p-=y<<1;return p},a.ByteStringBuffer.prototype.getBytes=function(n){var p;if(n)n=Math.min(this.length(),n),p=this.data.slice(this.read,this.read+n),this.read+=n;else if(n===0)p="";else p=this.read===0?this.data:this.data.slice(this.read),this.clear();return p},a.ByteStringBuffer.prototype.bytes=function(n){return typeof n==="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+n)},a.ByteStringBuffer.prototype.at=function(n){return this.data.charCodeAt(this.read+n)},a.ByteStringBuffer.prototype.setAt=function(n,p){return this.data=this.data.substr(0,this.read+n)+String.fromCharCode(p)+this.data.substr(this.read+n+1),this},a.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},a.ByteStringBuffer.prototype.copy=function(){var n=a.createBuffer(this.data);return n.read=this.read,n},a.ByteStringBuffer.prototype.compact=function(){if(this.read>0)this.data=this.data.slice(this.read),this.read=0;return this},a.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},a.ByteStringBuffer.prototype.truncate=function(n){var p=Math.max(0,this.length()-n);return this.data=this.data.substr(this.read,p),this.read=0,this},a.ByteStringBuffer.prototype.toHex=function(){var n="";for(var p=this.read;p<this.data.length;++p){var y=this.data.charCodeAt(p);if(y<16)n+="0";n+=y.toString(16)}return n},a.ByteStringBuffer.prototype.toString=function(){return a.decodeUtf8(this.bytes())};function u(n,p){p=p||{},this.read=p.readOffset||0,this.growSize=p.growSize||1024;var y=a.isArrayBuffer(n),b=a.isArrayBufferView(n);if(y||b){if(y)this.data=new DataView(n);else this.data=new DataView(n.buffer,n.byteOffset,n.byteLength);this.write="writeOffset"in p?p.writeOffset:this.data.byteLength;return}if(this.data=new DataView(new ArrayBuffer(0)),this.write=0,n!==null&&n!==void 0)this.putBytes(n);if("writeOffset"in p)this.write=p.writeOffset}a.DataBuffer=u,a.DataBuffer.prototype.length=function(){return this.write-this.read},a.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},a.DataBuffer.prototype.accommodate=function(n,p){if(this.length()>=n)return this;p=Math.max(p||this.growSize,n);var y=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),b=new Uint8Array(this.length()+p);return b.set(y),this.data=new DataView(b.buffer),this},a.DataBuffer.prototype.putByte=function(n){return this.accommodate(1),this.data.setUint8(this.write++,n),this},a.DataBuffer.prototype.fillWithByte=function(n,p){this.accommodate(p);for(var y=0;y<p;++y)this.data.setUint8(n);return this},a.DataBuffer.prototype.putBytes=function(n,p){if(a.isArrayBufferView(n)){var y=new Uint8Array(n.buffer,n.byteOffset,n.byteLength),b=y.byteLength-y.byteOffset;this.accommodate(b);var L=new Uint8Array(this.data.buffer,this.write);return L.set(y),this.write+=b,this}if(a.isArrayBuffer(n)){var y=new Uint8Array(n);this.accommodate(y.byteLength);var L=new Uint8Array(this.data.buffer);return L.set(y,this.write),this.write+=y.byteLength,this}if(n instanceof a.DataBuffer||typeof n==="object"&&typeof n.read==="number"&&typeof n.write==="number"&&a.isArrayBufferView(n.data)){var y=new Uint8Array(n.data.byteLength,n.read,n.length());this.accommodate(y.byteLength);var L=new Uint8Array(n.data.byteLength,this.write);return L.set(y),this.write+=y.byteLength,this}if(n instanceof a.ByteStringBuffer)n=n.data,p="binary";if(p=p||"binary",typeof n==="string"){var h;if(p==="hex")return this.accommodate(Math.ceil(n.length/2)),h=new Uint8Array(this.data.buffer,this.write),this.write+=a.binary.hex.decode(n,h,this.write),this;if(p==="base64")return this.accommodate(Math.ceil(n.length/4)*3),h=new Uint8Array(this.data.buffer,this.write),this.write+=a.binary.base64.decode(n,h,this.write),this;if(p==="utf8")n=a.encodeUtf8(n),p="binary";if(p==="binary"||p==="raw")return this.accommodate(n.length),h=new Uint8Array(this.data.buffer,this.write),this.write+=a.binary.raw.decode(h),this;if(p==="utf16")return this.accommodate(n.length*2),h=new Uint16Array(this.data.buffer,this.write),this.write+=a.text.utf16.encode(h),this;throw new Error("Invalid encoding: "+p)}throw Error("Invalid parameter: "+n)},a.DataBuffer.prototype.putBuffer=function(n){return this.putBytes(n),n.clear(),this},a.DataBuffer.prototype.putString=function(n){return this.putBytes(n,"utf16")},a.DataBuffer.prototype.putInt16=function(n){return this.accommodate(2),this.data.setInt16(this.write,n),this.write+=2,this},a.DataBuffer.prototype.putInt24=function(n){return this.accommodate(3),this.data.setInt16(this.write,n>>8&65535),this.data.setInt8(this.write,n>>16&255),this.write+=3,this},a.DataBuffer.prototype.putInt32=function(n){return this.accommodate(4),this.data.setInt32(this.write,n),this.write+=4,this},a.DataBuffer.prototype.putInt16Le=function(n){return this.accommodate(2),this.data.setInt16(this.write,n,!0),this.write+=2,this},a.DataBuffer.prototype.putInt24Le=function(n){return this.accommodate(3),this.data.setInt8(this.write,n>>16&255),this.data.setInt16(this.write,n>>8&65535,!0),this.write+=3,this},a.DataBuffer.prototype.putInt32Le=function(n){return this.accommodate(4),this.data.setInt32(this.write,n,!0),this.write+=4,this},a.DataBuffer.prototype.putInt=function(n,p){d(p),this.accommodate(p/8);do p-=8,this.data.setInt8(this.write++,n>>p&255);while(p>0);return this},a.DataBuffer.prototype.putSignedInt=function(n,p){if(d(p),this.accommodate(p/8),n<0)n+=2<<p-1;return this.putInt(n,p)},a.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},a.DataBuffer.prototype.getInt16=function(){var n=this.data.getInt16(this.read);return this.read+=2,n},a.DataBuffer.prototype.getInt24=function(){var n=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,n},a.DataBuffer.prototype.getInt32=function(){var n=this.data.getInt32(this.read);return this.read+=4,n},a.DataBuffer.prototype.getInt16Le=function(){var n=this.data.getInt16(this.read,!0);return this.read+=2,n},a.DataBuffer.prototype.getInt24Le=function(){var n=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,n},a.DataBuffer.prototype.getInt32Le=function(){var n=this.data.getInt32(this.read,!0);return this.read+=4,n},a.DataBuffer.prototype.getInt=function(n){d(n);var p=0;do p=(p<<8)+this.data.getInt8(this.read++),n-=8;while(n>0);return p},a.DataBuffer.prototype.getSignedInt=function(n){var p=this.getInt(n),y=2<<n-2;if(p>=y)p-=y<<1;return p},a.DataBuffer.prototype.getBytes=function(n){var p;if(n)n=Math.min(this.length(),n),p=this.data.slice(this.read,this.read+n),this.read+=n;else if(n===0)p="";else p=this.read===0?this.data:this.data.slice(this.read),this.clear();return p},a.DataBuffer.prototype.bytes=function(n){return typeof n==="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+n)},a.DataBuffer.prototype.at=function(n){return this.data.getUint8(this.read+n)},a.DataBuffer.prototype.setAt=function(n,p){return this.data.setUint8(n,p),this},a.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},a.DataBuffer.prototype.copy=function(){return new a.DataBuffer(this)},a.DataBuffer.prototype.compact=function(){if(this.read>0){var n=new Uint8Array(this.data.buffer,this.read),p=new Uint8Array(n.byteLength);p.set(n),this.data=new DataView(p),this.write-=this.read,this.read=0}return this},a.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},a.DataBuffer.prototype.truncate=function(n){return this.write=Math.max(0,this.length()-n),this.read=Math.min(this.read,this.write),this},a.DataBuffer.prototype.toHex=function(){var n="";for(var p=this.read;p<this.data.byteLength;++p){var y=this.data.getUint8(p);if(y<16)n+="0";n+=y.toString(16)}return n},a.DataBuffer.prototype.toString=function(n){var p=new Uint8Array(this.data,this.read,this.length());if(n=n||"utf8",n==="binary"||n==="raw")return a.binary.raw.encode(p);if(n==="hex")return a.binary.hex.encode(p);if(n==="base64")return a.binary.base64.encode(p);if(n==="utf8")return a.text.utf8.decode(p);if(n==="utf16")return a.text.utf16.decode(p);throw new Error("Invalid encoding: "+n)},a.createBuffer=function(n,p){if(p=p||"raw",n!==void 0&&p==="utf8")n=a.encodeUtf8(n);return new a.ByteBuffer(n)},a.fillString=function(n,p){var y="";while(p>0){if(p&1)y+=n;if(p>>>=1,p>0)n+=n}return y},a.xorBytes=function(n,p,y){var b="",L="",h="",s=0,i=0;for(;y>0;--y,++s){if(L=n.charCodeAt(s)^p.charCodeAt(s),i>=10)b+=h,h="",i=0;h+=String.fromCharCode(L),++i}return b+=h,b},a.hexToBytes=function(n){var p="",y=0;if(n.length&!0)y=1,p+=String.fromCharCode(parseInt(n[0],16));for(;y<n.length;y+=2)p+=String.fromCharCode(parseInt(n.substr(y,2),16));return p},a.bytesToHex=function(n){return a.createBuffer(n).toHex()},a.int32ToBytes=function(n){return String.fromCharCode(n>>24&255)+String.fromCharCode(n>>16&255)+String.fromCharCode(n>>8&255)+String.fromCharCode(n&255)};var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",C=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],f="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";a.encode64=function(n,p){var y="",b="",L,h,s,i=0;while(i<n.length){if(L=n.charCodeAt(i++),h=n.charCodeAt(i++),s=n.charCodeAt(i++),y+=r.charAt(L>>2),y+=r.charAt((L&3)<<4|h>>4),isNaN(h))y+="==";else y+=r.charAt((h&15)<<2|s>>6),y+=isNaN(s)?"=":r.charAt(s&63);if(p&&y.length>p)b+=y.substr(0,p)+`\r
|
|
15
|
-
`,y=y.substr(p)}return b+=y,b},a.decode64=function(n){n=n.replace(/[^A-Za-z0-9\+\/\=]/g,"");var p="",y,b,L,h,s=0;while(s<n.length)if(y=C[n.charCodeAt(s++)-43],b=C[n.charCodeAt(s++)-43],L=C[n.charCodeAt(s++)-43],h=C[n.charCodeAt(s++)-43],p+=String.fromCharCode(y<<2|b>>4),L!==64){if(p+=String.fromCharCode((b&15)<<4|L>>2),h!==64)p+=String.fromCharCode((L&3)<<6|h)}return p},a.encodeUtf8=function(n){return unescape(encodeURIComponent(n))},a.decodeUtf8=function(n){return decodeURIComponent(escape(n))},a.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:e.encode,decode:e.decode}},a.binary.raw.encode=function(n){return String.fromCharCode.apply(null,n)},a.binary.raw.decode=function(n,p,y){var b=p;if(!b)b=new Uint8Array(n.length);y=y||0;var L=y;for(var h=0;h<n.length;++h)b[L++]=n.charCodeAt(h);return p?L-y:b},a.binary.hex.encode=a.bytesToHex,a.binary.hex.decode=function(n,p,y){var b=p;if(!b)b=new Uint8Array(Math.ceil(n.length/2));y=y||0;var L=0,h=y;if(n.length&1)L=1,b[h++]=parseInt(n[0],16);for(;L<n.length;L+=2)b[h++]=parseInt(n.substr(L,2),16);return p?h-y:b},a.binary.base64.encode=function(n,p){var y="",b="",L,h,s,i=0;while(i<n.byteLength){if(L=n[i++],h=n[i++],s=n[i++],y+=r.charAt(L>>2),y+=r.charAt((L&3)<<4|h>>4),isNaN(h))y+="==";else y+=r.charAt((h&15)<<2|s>>6),y+=isNaN(s)?"=":r.charAt(s&63);if(p&&y.length>p)b+=y.substr(0,p)+`\r
|
|
16
|
-
`,y=y.substr(p)}return b+=y,b},a.binary.base64.decode=function(n,p,y){var b=p;if(!b)b=new Uint8Array(Math.ceil(n.length/4)*3);n=n.replace(/[^A-Za-z0-9\+\/\=]/g,""),y=y||0;var L,h,s,i,B=0,P=y;while(B<n.length)if(L=C[n.charCodeAt(B++)-43],h=C[n.charCodeAt(B++)-43],s=C[n.charCodeAt(B++)-43],i=C[n.charCodeAt(B++)-43],b[P++]=L<<2|h>>4,s!==64){if(b[P++]=(h&15)<<4|s>>2,i!==64)b[P++]=(s&3)<<6|i}return p?P-y:b.subarray(0,P)},a.binary.base58.encode=function(n,p){return a.binary.baseN.encode(n,f,p)},a.binary.base58.decode=function(n,p){return a.binary.baseN.decode(n,f,p)},a.text={utf8:{},utf16:{}},a.text.utf8.encode=function(n,p,y){n=a.encodeUtf8(n);var b=p;if(!b)b=new Uint8Array(n.length);y=y||0;var L=y;for(var h=0;h<n.length;++h)b[L++]=n.charCodeAt(h);return p?L-y:b},a.text.utf8.decode=function(n){return a.decodeUtf8(String.fromCharCode.apply(null,n))},a.text.utf16.encode=function(n,p,y){var b=p;if(!b)b=new Uint8Array(n.length*2);var L=new Uint16Array(b.buffer);y=y||0;var h=y,s=y;for(var i=0;i<n.length;++i)L[s++]=n.charCodeAt(i),h+=2;return p?h-y:b},a.text.utf16.decode=function(n){return String.fromCharCode.apply(null,new Uint16Array(n.buffer))},a.deflate=function(n,p,y){if(p=a.decode64(n.deflate(a.encode64(p)).rval),y){var b=2,L=p.charCodeAt(1);if(L&32)b=6;p=p.substring(b,p.length-4)}return p},a.inflate=function(n,p,y){var b=n.inflate(a.encode64(p)).rval;return b===null?null:a.decode64(b)};var I=function(n,p,y){if(!n)throw new Error("WebStorage not available.");var b;if(y===null)b=n.removeItem(p);else y=a.encode64(JSON.stringify(y)),b=n.setItem(p,y);if(typeof b!=="undefined"&&b.rval!==!0){var L=new Error(b.error.message);throw L.id=b.error.id,L.name=b.error.name,L}},U=function(n,p){if(!n)throw new Error("WebStorage not available.");var y=n.getItem(p);if(n.init)if(y.rval===null){if(y.error){var b=new Error(y.error.message);throw b.id=y.error.id,b.name=y.error.name,b}y=null}else y=y.rval;if(y!==null)y=JSON.parse(a.decode64(y));return y},T=function(n,p,y,b){var L=U(n,p);if(L===null)L={};L[y]=b,I(n,p,L)},c=function(n,p,y){var b=U(n,p);if(b!==null)b=y in b?b[y]:null;return b},m=function(n,p,y){var b=U(n,p);if(b!==null&&y in b){delete b[y];var L=!0;for(var h in b){L=!1;break}if(L)b=null;I(n,p,b)}},S=function(n,p){I(n,p,null)},E=function(n,p,y){var b=null;if(typeof y==="undefined")y=["web","flash"];var L,h=!1,s=null;for(var i in y){L=y[i];try{if(L==="flash"||L==="both"){if(p[0]===null)throw new Error("Flash local storage not available.");b=n.apply(this,p),h=L==="flash"}if(L==="web"||L==="both")p[0]=localStorage,b=n.apply(this,p),h=!0}catch(B){s=B}if(h)break}if(!h)throw s;return b};a.setItem=function(n,p,y,b,L){E(T,arguments,L)},a.getItem=function(n,p,y,b){return E(c,arguments,b)},a.removeItem=function(n,p,y,b){E(m,arguments,b)},a.clearItems=function(n,p,y){E(S,arguments,y)},a.isEmpty=function(n){for(var p in n)if(n.hasOwnProperty(p))return!1;return!0},a.format=function(n){var p=/%./g,y,b,L=0,h=[],s=0;while(y=p.exec(n)){if(b=n.substring(s,p.lastIndex-2),b.length>0)h.push(b);s=p.lastIndex;var i=y[0][1];switch(i){case"s":case"o":if(L<arguments.length)h.push(arguments[L+++1]);else h.push("<?>");break;case"%":h.push("%");break;default:h.push("<%"+i+"?>")}}return h.push(n.substring(s)),h.join("")},a.formatNumber=function(n,p,y,b){var L=n,h=isNaN(p=Math.abs(p))?2:p,s=y===void 0?",":y,i=b===void 0?".":b,B=L<0?"-":"",P=parseInt(L=Math.abs(+L||0).toFixed(h),10)+"",O=P.length>3?P.length%3:0;return B+(O?P.substr(0,O)+i:"")+P.substr(O).replace(/(\d{3})(?=\d)/g,"$1"+i)+(h?s+Math.abs(L-P).toFixed(h).slice(2):"")},a.formatSize=function(n){if(n>=1073741824)n=a.formatNumber(n/1073741824,2,".","")+" GiB";else if(n>=1048576)n=a.formatNumber(n/1048576,2,".","")+" MiB";else if(n>=1024)n=a.formatNumber(n/1024,0)+" KiB";else n=a.formatNumber(n,0)+" bytes";return n},a.bytesFromIP=function(n){if(n.indexOf(".")!==-1)return a.bytesFromIPv4(n);if(n.indexOf(":")!==-1)return a.bytesFromIPv6(n);return null},a.bytesFromIPv4=function(n){if(n=n.split("."),n.length!==4)return null;var p=a.createBuffer();for(var y=0;y<n.length;++y){var b=parseInt(n[y],10);if(isNaN(b))return null;p.putByte(b)}return p.getBytes()},a.bytesFromIPv6=function(n){var p=0;n=n.split(":").filter(function(s){if(s.length===0)++p;return!0});var y=(8-n.length+p)*2,b=a.createBuffer();for(var L=0;L<8;++L){if(!n[L]||n[L].length===0){b.fillWithByte(0,y),y=0;continue}var h=a.hexToBytes(n[L]);if(h.length<2)b.putByte(0);b.putBytes(h)}return b.getBytes()},a.bytesToIP=function(n){if(n.length===4)return a.bytesToIPv4(n);if(n.length===16)return a.bytesToIPv6(n);return null},a.bytesToIPv4=function(n){if(n.length!==4)return null;var p=[];for(var y=0;y<n.length;++y)p.push(n.charCodeAt(y));return p.join(".")},a.bytesToIPv6=function(n){if(n.length!==16)return null;var p=[],y=[],b=0;for(var L=0;L<n.length;L+=2){var h=a.bytesToHex(n[L]+n[L+1]);while(h[0]==="0"&&h!=="0")h=h.substr(1);if(h==="0"){var s=y[y.length-1],i=p.length;if(!s||i!==s.end+1)y.push({start:i,end:i});else if(s.end=i,s.end-s.start>y[b].end-y[b].start)b=y.length-1}p.push(h)}if(y.length>0){var B=y[b];if(B.end-B.start>0){if(p.splice(B.start,B.end-B.start+1,""),B.start===0)p.unshift("");if(B.end===7)p.push("")}}return p.join(":")},a.estimateCores=function(n,p){if(typeof n==="function")p=n,n={};if(n=n||{},"cores"in a&&!n.update)return p(null,a.cores);if(typeof navigator!=="undefined"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return a.cores=navigator.hardwareConcurrency,p(null,a.cores);if(typeof Worker==="undefined")return a.cores=1,p(null,a.cores);if(typeof Blob==="undefined")return a.cores=2,p(null,a.cores);var y=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(s){var i=Date.now(),B=i+4;while(Date.now()<B);self.postMessage({st:i,et:B})})}.toString(),")()"],{type:"application/javascript"}));b([],5,16);function b(s,i,B){if(i===0){var P=Math.floor(s.reduce(function(O,V){return O+V},0)/s.length);return a.cores=Math.max(1,P),URL.revokeObjectURL(y),p(null,a.cores)}L(B,function(O,V){s.push(h(B,V)),b(s,i-1,B)})}function L(s,i){var B=[],P=[];for(var O=0;O<s;++O){var V=new Worker(y);V.addEventListener("message",function(M){if(P.push(M.data),P.length===s){for(var G=0;G<s;++G)B[G].terminate();i(null,P)}}),B.push(V)}for(var O=0;O<s;++O)B[O].postMessage(O)}function h(s,i){var B=[];for(var P=0;P<s;++P){var O=i[P],V=B[P]=[];for(var M=0;M<s;++M){if(P===M)continue;var G=i[M];if(O.st>G.st&&O.st<G.et||G.st>O.st&&G.st<O.et)V.push(M)}}return B.reduce(function(q,H){return Math.max(q,H.length)},0)}}}),ur=le((N,_)=>{var t=pe();Ce(),_.exports=t.cipher=t.cipher||{},t.cipher.algorithms=t.cipher.algorithms||{},t.cipher.createCipher=function(a,d){var v=a;if(typeof v==="string"){if(v=t.cipher.getAlgorithm(v),v)v=v()}if(!v)throw new Error("Unsupported algorithm: "+a);return new t.cipher.BlockCipher({algorithm:v,key:d,decrypt:!1})},t.cipher.createDecipher=function(a,d){var v=a;if(typeof v==="string"){if(v=t.cipher.getAlgorithm(v),v)v=v()}if(!v)throw new Error("Unsupported algorithm: "+a);return new t.cipher.BlockCipher({algorithm:v,key:d,decrypt:!0})},t.cipher.registerAlgorithm=function(a,d){a=a.toUpperCase(),t.cipher.algorithms[a]=d},t.cipher.getAlgorithm=function(a){if(a=a.toUpperCase(),a in t.cipher.algorithms)return t.cipher.algorithms[a];return null};var e=t.cipher.BlockCipher=function(a){this.algorithm=a.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=a.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=a.decrypt,this.algorithm.initialize(a)};e.prototype.start=function(a){a=a||{};var d={};for(var v in a)d[v]=a[v];d.decrypt=this._decrypt,this._finish=!1,this._input=t.util.createBuffer(),this.output=a.output||t.util.createBuffer(),this.mode.start(d)},e.prototype.update=function(a){if(a)this._input.putBuffer(a);while(!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish);this._input.compact()},e.prototype.finish=function(a){if(a&&(this.mode.name==="ECB"||this.mode.name==="CBC"))this.mode.pad=function(v){return a(this.blockSize,v,!1)},this.mode.unpad=function(v){return a(this.blockSize,v,!0)};var d={};if(d.decrypt=this._decrypt,d.overflow=this._input.length()%this.blockSize,!this._decrypt&&this.mode.pad){if(!this.mode.pad(this._input,d))return!1}if(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad){if(!this.mode.unpad(this.output,d))return!1}if(this.mode.afterFinish){if(!this.mode.afterFinish(this.output,d))return!1}return!0}}),Or=le((N,_)=>{var t=pe();Ce(),t.cipher=t.cipher||{};var e=_.exports=t.cipher.modes=t.cipher.modes||{};e.ecb=function(g){g=g||{},this.name="ECB",this.cipher=g.cipher,this.blockSize=g.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},e.ecb.prototype.start=function(g){},e.ecb.prototype.encrypt=function(g,u,r){if(g.length()<this.blockSize&&!(r&&g.length()>0))return!0;for(var C=0;C<this._ints;++C)this._inBlock[C]=g.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var C=0;C<this._ints;++C)u.putInt32(this._outBlock[C])},e.ecb.prototype.decrypt=function(g,u,r){if(g.length()<this.blockSize&&!(r&&g.length()>0))return!0;for(var C=0;C<this._ints;++C)this._inBlock[C]=g.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var C=0;C<this._ints;++C)u.putInt32(this._outBlock[C])},e.ecb.prototype.pad=function(g,u){var r=g.length()===this.blockSize?this.blockSize:this.blockSize-g.length();return g.fillWithByte(r,r),!0},e.ecb.prototype.unpad=function(g,u){if(u.overflow>0)return!1;var r=g.length(),C=g.at(r-1);if(C>this.blockSize<<2)return!1;return g.truncate(C),!0},e.cbc=function(g){g=g||{},this.name="CBC",this.cipher=g.cipher,this.blockSize=g.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},e.cbc.prototype.start=function(g){if(g.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if(!("iv"in g))throw new Error("Invalid IV parameter.");else this._iv=a(g.iv,this.blockSize),this._prev=this._iv.slice(0)},e.cbc.prototype.encrypt=function(g,u,r){if(g.length()<this.blockSize&&!(r&&g.length()>0))return!0;for(var C=0;C<this._ints;++C)this._inBlock[C]=this._prev[C]^g.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var C=0;C<this._ints;++C)u.putInt32(this._outBlock[C]);this._prev=this._outBlock},e.cbc.prototype.decrypt=function(g,u,r){if(g.length()<this.blockSize&&!(r&&g.length()>0))return!0;for(var C=0;C<this._ints;++C)this._inBlock[C]=g.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var C=0;C<this._ints;++C)u.putInt32(this._prev[C]^this._outBlock[C]);this._prev=this._inBlock.slice(0)},e.cbc.prototype.pad=function(g,u){var r=g.length()===this.blockSize?this.blockSize:this.blockSize-g.length();return g.fillWithByte(r,r),!0},e.cbc.prototype.unpad=function(g,u){if(u.overflow>0)return!1;var r=g.length(),C=g.at(r-1);if(C>this.blockSize<<2)return!1;return g.truncate(C),!0},e.cfb=function(g){g=g||{},this.name="CFB",this.cipher=g.cipher,this.blockSize=g.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.cfb.prototype.start=function(g){if(!("iv"in g))throw new Error("Invalid IV parameter.");this._iv=a(g.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.cfb.prototype.encrypt=function(g,u,r){var C=g.length();if(C===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&C>=this.blockSize){for(var f=0;f<this._ints;++f)this._inBlock[f]=g.getInt32()^this._outBlock[f],u.putInt32(this._inBlock[f]);return}var I=(this.blockSize-C)%this.blockSize;if(I>0)I=this.blockSize-I;this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialBlock[f]=g.getInt32()^this._outBlock[f],this._partialOutput.putInt32(this._partialBlock[f]);if(I>0)g.read-=this.blockSize;else for(var f=0;f<this._ints;++f)this._inBlock[f]=this._partialBlock[f];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(I>0&&!r)return u.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;u.putBytes(this._partialOutput.getBytes(C-this._partialBytes)),this._partialBytes=0},e.cfb.prototype.decrypt=function(g,u,r){var C=g.length();if(C===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&C>=this.blockSize){for(var f=0;f<this._ints;++f)this._inBlock[f]=g.getInt32(),u.putInt32(this._inBlock[f]^this._outBlock[f]);return}var I=(this.blockSize-C)%this.blockSize;if(I>0)I=this.blockSize-I;this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialBlock[f]=g.getInt32(),this._partialOutput.putInt32(this._partialBlock[f]^this._outBlock[f]);if(I>0)g.read-=this.blockSize;else for(var f=0;f<this._ints;++f)this._inBlock[f]=this._partialBlock[f];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(I>0&&!r)return u.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;u.putBytes(this._partialOutput.getBytes(C-this._partialBytes)),this._partialBytes=0},e.ofb=function(g){g=g||{},this.name="OFB",this.cipher=g.cipher,this.blockSize=g.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.ofb.prototype.start=function(g){if(!("iv"in g))throw new Error("Invalid IV parameter.");this._iv=a(g.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ofb.prototype.encrypt=function(g,u,r){var C=g.length();if(g.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&C>=this.blockSize){for(var f=0;f<this._ints;++f)u.putInt32(g.getInt32()^this._outBlock[f]),this._inBlock[f]=this._outBlock[f];return}var I=(this.blockSize-C)%this.blockSize;if(I>0)I=this.blockSize-I;this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialOutput.putInt32(g.getInt32()^this._outBlock[f]);if(I>0)g.read-=this.blockSize;else for(var f=0;f<this._ints;++f)this._inBlock[f]=this._outBlock[f];if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(I>0&&!r)return u.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;u.putBytes(this._partialOutput.getBytes(C-this._partialBytes)),this._partialBytes=0},e.ofb.prototype.decrypt=e.ofb.prototype.encrypt,e.ctr=function(g){g=g||{},this.name="CTR",this.cipher=g.cipher,this.blockSize=g.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.ctr.prototype.start=function(g){if(!("iv"in g))throw new Error("Invalid IV parameter.");this._iv=a(g.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ctr.prototype.encrypt=function(g,u,r){var C=g.length();if(C===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&C>=this.blockSize)for(var f=0;f<this._ints;++f)u.putInt32(g.getInt32()^this._outBlock[f]);else{var I=(this.blockSize-C)%this.blockSize;if(I>0)I=this.blockSize-I;this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialOutput.putInt32(g.getInt32()^this._outBlock[f]);if(I>0)g.read-=this.blockSize;if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(I>0&&!r)return u.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;u.putBytes(this._partialOutput.getBytes(C-this._partialBytes)),this._partialBytes=0}d(this._inBlock)},e.ctr.prototype.decrypt=e.ctr.prototype.encrypt,e.gcm=function(g){g=g||{},this.name="GCM",this.cipher=g.cipher,this.blockSize=g.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0,this._R=3774873600},e.gcm.prototype.start=function(g){if(!("iv"in g))throw new Error("Invalid IV parameter.");var u=t.util.createBuffer(g.iv);this._cipherLength=0;var r;if("additionalData"in g)r=t.util.createBuffer(g.additionalData);else r=t.util.createBuffer();if("tagLength"in g)this._tagLength=g.tagLength;else this._tagLength=128;if(this._tag=null,g.decrypt){if(this._tag=t.util.createBuffer(g.tag).getBytes(),this._tag.length!==this._tagLength/8)throw new Error("Authentication tag does not match tag length.")}this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var C=u.length();if(C===12)this._j0=[u.getInt32(),u.getInt32(),u.getInt32(),1];else{this._j0=[0,0,0,0];while(u.length()>0)this._j0=this.ghash(this._hashSubkey,this._j0,[u.getInt32(),u.getInt32(),u.getInt32(),u.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(v(C*8)))}this._inBlock=this._j0.slice(0),d(this._inBlock),this._partialBytes=0,r=t.util.createBuffer(r),this._aDataLength=v(r.length()*8);var f=r.length()%this.blockSize;if(f)r.fillWithByte(0,this.blockSize-f);this._s=[0,0,0,0];while(r.length()>0)this._s=this.ghash(this._hashSubkey,this._s,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()])},e.gcm.prototype.encrypt=function(g,u,r){var C=g.length();if(C===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&C>=this.blockSize){for(var f=0;f<this._ints;++f)u.putInt32(this._outBlock[f]^=g.getInt32());this._cipherLength+=this.blockSize}else{var I=(this.blockSize-C)%this.blockSize;if(I>0)I=this.blockSize-I;this._partialOutput.clear();for(var f=0;f<this._ints;++f)this._partialOutput.putInt32(g.getInt32()^this._outBlock[f]);if(I<=0||r){if(r){var U=C%this.blockSize;this._cipherLength+=U,this._partialOutput.truncate(this.blockSize-U)}else this._cipherLength+=this.blockSize;for(var f=0;f<this._ints;++f)this._outBlock[f]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0)this._partialOutput.getBytes(this._partialBytes);if(I>0&&!r)return g.read-=this.blockSize,u.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;u.putBytes(this._partialOutput.getBytes(C-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),d(this._inBlock)},e.gcm.prototype.decrypt=function(g,u,r){var C=g.length();if(C<this.blockSize&&!(r&&C>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),d(this._inBlock),this._hashBlock[0]=g.getInt32(),this._hashBlock[1]=g.getInt32(),this._hashBlock[2]=g.getInt32(),this._hashBlock[3]=g.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var f=0;f<this._ints;++f)u.putInt32(this._outBlock[f]^this._hashBlock[f]);if(C<this.blockSize)this._cipherLength+=C%this.blockSize;else this._cipherLength+=this.blockSize},e.gcm.prototype.afterFinish=function(g,u){var r=!0;if(u.decrypt&&u.overflow)g.truncate(this.blockSize-u.overflow);this.tag=t.util.createBuffer();var C=this._aDataLength.concat(v(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,C);var f=[];this.cipher.encrypt(this._j0,f);for(var I=0;I<this._ints;++I)this.tag.putInt32(this._s[I]^f[I]);if(this.tag.truncate(this.tag.length()%(this._tagLength/8)),u.decrypt&&this.tag.bytes()!==this._tag)r=!1;return r},e.gcm.prototype.multiply=function(g,u){var r=[0,0,0,0],C=u.slice(0);for(var f=0;f<128;++f){var I=g[f/32|0]&1<<31-f%32;if(I)r[0]^=C[0],r[1]^=C[1],r[2]^=C[2],r[3]^=C[3];this.pow(C,C)}return r},e.gcm.prototype.pow=function(g,u){var r=g[3]&1;for(var C=3;C>0;--C)u[C]=g[C]>>>1|(g[C-1]&1)<<31;if(u[0]=g[0]>>>1,r)u[0]^=this._R},e.gcm.prototype.tableMultiply=function(g){var u=[0,0,0,0];for(var r=0;r<32;++r){var C=r/8|0,f=g[C]>>>(7-r%8)*4&15,I=this._m[r][f];u[0]^=I[0],u[1]^=I[1],u[2]^=I[2],u[3]^=I[3]}return u},e.gcm.prototype.ghash=function(g,u,r){return u[0]^=r[0],u[1]^=r[1],u[2]^=r[2],u[3]^=r[3],this.tableMultiply(u)},e.gcm.prototype.generateHashTable=function(g,u){var r=8/u,C=4*r,f=16*r,I=new Array(f);for(var U=0;U<f;++U){var T=[0,0,0,0],c=U/C|0,m=(C-1-U%C)*u;T[c]=1<<u-1<<m,I[U]=this.generateSubHashTable(this.multiply(T,g),u)}return I},e.gcm.prototype.generateSubHashTable=function(g,u){var r=1<<u,C=r>>>1,f=new Array(r);f[C]=g.slice(0);var I=C>>>1;while(I>0)this.pow(f[2*I],f[I]=[]),I>>=1;I=2;while(I<C){for(var U=1;U<I;++U){var T=f[I],c=f[U];f[I+U]=[T[0]^c[0],T[1]^c[1],T[2]^c[2],T[3]^c[3]]}I*=2}f[0]=[0,0,0,0];for(I=C+1;I<r;++I){var m=f[I^C];f[I]=[g[0]^m[0],g[1]^m[1],g[2]^m[2],g[3]^m[3]]}return f};function a(g,u){if(typeof g==="string")g=t.util.createBuffer(g);if(t.util.isArray(g)&&g.length>4){var r=g;g=t.util.createBuffer();for(var C=0;C<r.length;++C)g.putByte(r[C])}if(g.length()<u)throw new Error("Invalid IV length; got "+g.length()+" bytes and expected "+u+" bytes.");if(!t.util.isArray(g)){var f=[],I=u/4;for(var C=0;C<I;++C)f.push(g.getInt32());g=f}return g}function d(g){g[g.length-1]=g[g.length-1]+1&4294967295}function v(g){return[g/4294967296|0,g&4294967295]}}),Tt=le((N,_)=>{var t=pe();ur(),Or(),Ce(),_.exports=t.aes=t.aes||{},t.aes.startEncrypting=function(c,m,S,E){var n=T({key:c,output:S,decrypt:!1,mode:E});return n.start(m),n},t.aes.createEncryptionCipher=function(c,m){return T({key:c,output:null,decrypt:!1,mode:m})},t.aes.startDecrypting=function(c,m,S,E){var n=T({key:c,output:S,decrypt:!0,mode:E});return n.start(m),n},t.aes.createDecryptionCipher=function(c,m){return T({key:c,output:null,decrypt:!0,mode:m})},t.aes.Algorithm=function(c,m){if(!a)f();var S=this;S.name=c,S.mode=new m({blockSize:16,cipher:{encrypt:function(E,n){return U(S._w,E,n,!1)},decrypt:function(E,n){return U(S._w,E,n,!0)}}}),S._init=!1},t.aes.Algorithm.prototype.initialize=function(c){if(this._init)return;var m=c.key,S;if(typeof m==="string"&&(m.length===16||m.length===24||m.length===32))m=t.util.createBuffer(m);else if(t.util.isArray(m)&&(m.length===16||m.length===24||m.length===32)){S=m,m=t.util.createBuffer();for(var E=0;E<S.length;++E)m.putByte(S[E])}if(!t.util.isArray(m)){S=m,m=[];var n=S.length();if(n===16||n===24||n===32){n=n>>>2;for(var E=0;E<n;++E)m.push(S.getInt32())}}if(!t.util.isArray(m)||!(m.length===4||m.length===6||m.length===8))throw new Error("Invalid key parameter.");var p=this.mode.name,y=["CFB","OFB","CTR","GCM"].indexOf(p)!==-1;this._w=I(m,c.decrypt&&!y),this._init=!0},t.aes._expandKey=function(c,m){if(!a)f();return I(c,m)},t.aes._updateBlock=U,e("AES-ECB",t.cipher.modes.ecb),e("AES-CBC",t.cipher.modes.cbc),e("AES-CFB",t.cipher.modes.cfb),e("AES-OFB",t.cipher.modes.ofb),e("AES-CTR",t.cipher.modes.ctr),e("AES-GCM",t.cipher.modes.gcm);function e(c,m){var S=function(){return new t.aes.Algorithm(c,m)};t.cipher.registerAlgorithm(c,S)}var a=!1,d=4,v,g,u,r,C;function f(){a=!0,u=[0,1,2,4,8,16,32,64,128,27,54];var c=new Array(256);for(var m=0;m<128;++m)c[m]=m<<1,c[m+128]=m+128<<1^283;v=new Array(256),g=new Array(256),r=new Array(4),C=new Array(4);for(var m=0;m<4;++m)r[m]=new Array(256),C[m]=new Array(256);var S=0,E=0,n,p,y,b,L,h,s;for(var m=0;m<256;++m){b=E^E<<1^E<<2^E<<3^E<<4,b=b>>8^b&255^99,v[S]=b,g[b]=S,L=c[b],n=c[S],p=c[n],y=c[p],h=L<<24^b<<16^b<<8^(b^L),s=(n^p^y)<<24^(S^y)<<16^(S^p^y)<<8^(S^n^y);for(var i=0;i<4;++i)r[i][S]=h,C[i][b]=s,h=h<<24|h>>>8,s=s<<24|s>>>8;if(S===0)S=E=1;else S=n^c[c[c[n^y]]],E^=c[c[E]]}}function I(c,m){var S=c.slice(0),E,n=1,p=S.length,y=p+6+1,b=d*y;for(var L=p;L<b;++L){if(E=S[L-1],L%p===0)E=v[E>>>16&255]<<24^v[E>>>8&255]<<16^v[E&255]<<8^v[E>>>24]^u[n]<<24,n++;else if(p>6&&L%p===4)E=v[E>>>24]<<24^v[E>>>16&255]<<16^v[E>>>8&255]<<8^v[E&255];S[L]=S[L-p]^E}if(m){var h,s=C[0],i=C[1],B=C[2],P=C[3],O=S.slice(0);b=S.length;for(var L=0,V=b-d;L<b;L+=d,V-=d)if(L===0||L===b-d)O[L]=S[V],O[L+1]=S[V+3],O[L+2]=S[V+2],O[L+3]=S[V+1];else for(var M=0;M<d;++M)h=S[V+M],O[L+(3&-M)]=s[v[h>>>24]]^i[v[h>>>16&255]]^B[v[h>>>8&255]]^P[v[h&255]];S=O}return S}function U(c,m,S,E){var n=c.length/4-1,p,y,b,L,h;if(E)p=C[0],y=C[1],b=C[2],L=C[3],h=g;else p=r[0],y=r[1],b=r[2],L=r[3],h=v;var s,i,B,P,O,V,M;s=m[0]^c[0],i=m[E?3:1]^c[1],B=m[2]^c[2],P=m[E?1:3]^c[3];var G=3;for(var q=1;q<n;++q)O=p[s>>>24]^y[i>>>16&255]^b[B>>>8&255]^L[P&255]^c[++G],V=p[i>>>24]^y[B>>>16&255]^b[P>>>8&255]^L[s&255]^c[++G],M=p[B>>>24]^y[P>>>16&255]^b[s>>>8&255]^L[i&255]^c[++G],P=p[P>>>24]^y[s>>>16&255]^b[i>>>8&255]^L[B&255]^c[++G],s=O,i=V,B=M;S[0]=h[s>>>24]<<24^h[i>>>16&255]<<16^h[B>>>8&255]<<8^h[P&255]^c[++G],S[E?3:1]=h[i>>>24]<<24^h[B>>>16&255]<<16^h[P>>>8&255]<<8^h[s&255]^c[++G],S[2]=h[B>>>24]<<24^h[P>>>16&255]<<16^h[s>>>8&255]<<8^h[i&255]^c[++G],S[E?1:3]=h[P>>>24]<<24^h[s>>>16&255]<<16^h[i>>>8&255]<<8^h[B&255]^c[++G]}function T(c){c=c||{};var m=(c.mode||"CBC").toUpperCase(),S="AES-"+m,E;if(c.decrypt)E=t.cipher.createDecipher(S,c.key);else E=t.cipher.createCipher(S,c.key);var n=E.start;return E.start=function(p,y){var b=null;if(y instanceof t.util.ByteBuffer)b=y,y={};y=y||{},y.output=b,y.iv=p,n.call(E,y)},E}}),It=le((N,_)=>{var t=pe();t.pki=t.pki||{};var e=_.exports=t.pki.oids=t.oids=t.oids||{};function a(v,g){e[v]=g,e[g]=v}function d(v,g){e[v]=g}a("1.2.840.113549.1.1.1","rsaEncryption"),a("1.2.840.113549.1.1.4","md5WithRSAEncryption"),a("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),a("1.2.840.113549.1.1.7","RSAES-OAEP"),a("1.2.840.113549.1.1.8","mgf1"),a("1.2.840.113549.1.1.9","pSpecified"),a("1.2.840.113549.1.1.10","RSASSA-PSS"),a("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),a("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),a("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),a("1.3.101.112","EdDSA25519"),a("1.2.840.10040.4.3","dsa-with-sha1"),a("1.3.14.3.2.7","desCBC"),a("1.3.14.3.2.26","sha1"),a("1.3.14.3.2.29","sha1WithRSASignature"),a("2.16.840.1.101.3.4.2.1","sha256"),a("2.16.840.1.101.3.4.2.2","sha384"),a("2.16.840.1.101.3.4.2.3","sha512"),a("2.16.840.1.101.3.4.2.4","sha224"),a("2.16.840.1.101.3.4.2.5","sha512-224"),a("2.16.840.1.101.3.4.2.6","sha512-256"),a("1.2.840.113549.2.2","md2"),a("1.2.840.113549.2.5","md5"),a("1.2.840.113549.1.7.1","data"),a("1.2.840.113549.1.7.2","signedData"),a("1.2.840.113549.1.7.3","envelopedData"),a("1.2.840.113549.1.7.4","signedAndEnvelopedData"),a("1.2.840.113549.1.7.5","digestedData"),a("1.2.840.113549.1.7.6","encryptedData"),a("1.2.840.113549.1.9.1","emailAddress"),a("1.2.840.113549.1.9.2","unstructuredName"),a("1.2.840.113549.1.9.3","contentType"),a("1.2.840.113549.1.9.4","messageDigest"),a("1.2.840.113549.1.9.5","signingTime"),a("1.2.840.113549.1.9.6","counterSignature"),a("1.2.840.113549.1.9.7","challengePassword"),a("1.2.840.113549.1.9.8","unstructuredAddress"),a("1.2.840.113549.1.9.14","extensionRequest"),a("1.2.840.113549.1.9.20","friendlyName"),a("1.2.840.113549.1.9.21","localKeyId"),a("1.2.840.113549.1.9.22.1","x509Certificate"),a("1.2.840.113549.1.12.10.1.1","keyBag"),a("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),a("1.2.840.113549.1.12.10.1.3","certBag"),a("1.2.840.113549.1.12.10.1.4","crlBag"),a("1.2.840.113549.1.12.10.1.5","secretBag"),a("1.2.840.113549.1.12.10.1.6","safeContentsBag"),a("1.2.840.113549.1.5.13","pkcs5PBES2"),a("1.2.840.113549.1.5.12","pkcs5PBKDF2"),a("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),a("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),a("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),a("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),a("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),a("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),a("1.2.840.113549.2.7","hmacWithSHA1"),a("1.2.840.113549.2.8","hmacWithSHA224"),a("1.2.840.113549.2.9","hmacWithSHA256"),a("1.2.840.113549.2.10","hmacWithSHA384"),a("1.2.840.113549.2.11","hmacWithSHA512"),a("1.2.840.113549.3.7","des-EDE3-CBC"),a("2.16.840.1.101.3.4.1.2","aes128-CBC"),a("2.16.840.1.101.3.4.1.22","aes192-CBC"),a("2.16.840.1.101.3.4.1.42","aes256-CBC"),a("2.5.4.3","commonName"),a("2.5.4.4","surname"),a("2.5.4.5","serialNumber"),a("2.5.4.6","countryName"),a("2.5.4.7","localityName"),a("2.5.4.8","stateOrProvinceName"),a("2.5.4.9","streetAddress"),a("2.5.4.10","organizationName"),a("2.5.4.11","organizationalUnitName"),a("2.5.4.12","title"),a("2.5.4.13","description"),a("2.5.4.15","businessCategory"),a("2.5.4.17","postalCode"),a("2.5.4.42","givenName"),a("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),a("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),a("2.16.840.1.113730.1.1","nsCertType"),a("2.16.840.1.113730.1.13","nsComment"),d("2.5.29.1","authorityKeyIdentifier"),d("2.5.29.2","keyAttributes"),d("2.5.29.3","certificatePolicies"),d("2.5.29.4","keyUsageRestriction"),d("2.5.29.5","policyMapping"),d("2.5.29.6","subtreesConstraint"),d("2.5.29.7","subjectAltName"),d("2.5.29.8","issuerAltName"),d("2.5.29.9","subjectDirectoryAttributes"),d("2.5.29.10","basicConstraints"),d("2.5.29.11","nameConstraints"),d("2.5.29.12","policyConstraints"),d("2.5.29.13","basicConstraints"),a("2.5.29.14","subjectKeyIdentifier"),a("2.5.29.15","keyUsage"),d("2.5.29.16","privateKeyUsagePeriod"),a("2.5.29.17","subjectAltName"),a("2.5.29.18","issuerAltName"),a("2.5.29.19","basicConstraints"),d("2.5.29.20","cRLNumber"),d("2.5.29.21","cRLReason"),d("2.5.29.22","expirationDate"),d("2.5.29.23","instructionCode"),d("2.5.29.24","invalidityDate"),d("2.5.29.25","cRLDistributionPoints"),d("2.5.29.26","issuingDistributionPoint"),d("2.5.29.27","deltaCRLIndicator"),d("2.5.29.28","issuingDistributionPoint"),d("2.5.29.29","certificateIssuer"),d("2.5.29.30","nameConstraints"),a("2.5.29.31","cRLDistributionPoints"),a("2.5.29.32","certificatePolicies"),d("2.5.29.33","policyMappings"),d("2.5.29.34","policyConstraints"),a("2.5.29.35","authorityKeyIdentifier"),d("2.5.29.36","policyConstraints"),a("2.5.29.37","extKeyUsage"),d("2.5.29.46","freshestCRL"),d("2.5.29.54","inhibitAnyPolicy"),a("1.3.6.1.4.1.11129.2.4.2","timestampList"),a("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),a("1.3.6.1.5.5.7.3.1","serverAuth"),a("1.3.6.1.5.5.7.3.2","clientAuth"),a("1.3.6.1.5.5.7.3.3","codeSigning"),a("1.3.6.1.5.5.7.3.4","emailProtection"),a("1.3.6.1.5.5.7.3.8","timeStamping")}),ut=le((N,_)=>{var t=pe();Ce(),It();var e=_.exports=t.asn1=t.asn1||{};e.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},e.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},e.create=function(u,r,C,f,I){if(t.util.isArray(f)){var U=[];for(var T=0;T<f.length;++T)if(f[T]!==void 0)U.push(f[T]);f=U}var c={tagClass:u,type:r,constructed:C,composed:C||t.util.isArray(f),value:f};if(I&&"bitStringContents"in I)c.bitStringContents=I.bitStringContents,c.original=e.copy(c);return c},e.copy=function(u,r){var C;if(t.util.isArray(u)){C=[];for(var f=0;f<u.length;++f)C.push(e.copy(u[f],r));return C}if(typeof u==="string")return u;if(C={tagClass:u.tagClass,type:u.type,constructed:u.constructed,composed:u.composed,value:e.copy(u.value,r)},r&&!r.excludeBitStringContents)C.bitStringContents=u.bitStringContents;return C},e.equals=function(u,r,C){if(t.util.isArray(u)){if(!t.util.isArray(r))return!1;if(u.length!==r.length)return!1;for(var f=0;f<u.length;++f)if(!e.equals(u[f],r[f]))return!1;return!0}if(typeof u!==typeof r)return!1;if(typeof u==="string")return u===r;var I=u.tagClass===r.tagClass&&u.type===r.type&&u.constructed===r.constructed&&u.composed===r.composed&&e.equals(u.value,r.value);if(C&&C.includeBitStringContents)I=I&&u.bitStringContents===r.bitStringContents;return I},e.getBerValueLength=function(u){var r=u.getByte();if(r===128)return;var C,f=r&128;if(!f)C=r;else C=u.getInt((r&127)<<3);return C};function a(u,r,C){if(C>r){var f=new Error("Too few bytes to parse DER.");throw f.available=u.length(),f.remaining=r,f.requested=C,f}}var d=function(u,r){var C=u.getByte();if(r--,C===128)return;var f,I=C&128;if(!I)f=C;else{var U=C&127;a(u,r,U),f=u.getInt(U<<3)}if(f<0)throw new Error("Negative length: "+f);return f};e.fromDer=function(u,r){if(r===void 0)r={strict:!0,parseAllBytes:!0,decodeBitStrings:!0};if(typeof r==="boolean")r={strict:r,parseAllBytes:!0,decodeBitStrings:!0};if(!("strict"in r))r.strict=!0;if(!("parseAllBytes"in r))r.parseAllBytes=!0;if(!("decodeBitStrings"in r))r.decodeBitStrings=!0;if(typeof u==="string")u=t.util.createBuffer(u);var C=u.length(),f=v(u,u.length(),0,r);if(r.parseAllBytes&&u.length()!==0){var I=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw I.byteCount=C,I.remaining=u.length(),I}return f};function v(u,r,C,f){var I;a(u,r,2);var U=u.getByte();r--;var T=U&192,c=U&31;I=u.length();var m=d(u,r);if(r-=I-u.length(),m!==void 0&&m>r){if(f.strict){var S=new Error("Too few bytes to read ASN.1 value.");throw S.available=u.length(),S.remaining=r,S.requested=m,S}m=r}var E,n,p=(U&32)===32;if(p)if(E=[],m===void 0)for(;;){if(a(u,r,2),u.bytes(2)===String.fromCharCode(0,0)){u.getBytes(2),r-=2;break}I=u.length(),E.push(v(u,r,C+1,f)),r-=I-u.length()}else while(m>0)I=u.length(),E.push(v(u,m,C+1,f)),r-=I-u.length(),m-=I-u.length();if(E===void 0&&T===e.Class.UNIVERSAL&&c===e.Type.BITSTRING)n=u.bytes(m);if(E===void 0&&f.decodeBitStrings&&T===e.Class.UNIVERSAL&&c===e.Type.BITSTRING&&m>1){var y=u.read,b=r,L=0;if(c===e.Type.BITSTRING)a(u,r,1),L=u.getByte(),r--;if(L===0)try{I=u.length();var h={strict:!0,decodeBitStrings:!0},s=v(u,r,C+1,h),i=I-u.length();if(r-=i,c==e.Type.BITSTRING)i++;var B=s.tagClass;if(i===m&&(B===e.Class.UNIVERSAL||B===e.Class.CONTEXT_SPECIFIC))E=[s]}catch(O){}if(E===void 0)u.read=y,r=b}if(E===void 0){if(m===void 0){if(f.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");m=r}if(c===e.Type.BMPSTRING){E="";for(;m>0;m-=2)a(u,r,2),E+=String.fromCharCode(u.getInt16()),r-=2}else E=u.getBytes(m),r-=m}var P=n===void 0?null:{bitStringContents:n};return e.create(T,c,p,E,P)}e.toDer=function(u){var r=t.util.createBuffer(),C=u.tagClass|u.type,f=t.util.createBuffer(),I=!1;if("bitStringContents"in u){if(I=!0,u.original)I=e.equals(u,u.original)}if(I)f.putBytes(u.bitStringContents);else if(u.composed){if(u.constructed)C|=32;else f.putByte(0);for(var U=0;U<u.value.length;++U)if(u.value[U]!==void 0)f.putBuffer(e.toDer(u.value[U]))}else if(u.type===e.Type.BMPSTRING)for(var U=0;U<u.value.length;++U)f.putInt16(u.value.charCodeAt(U));else if(u.type===e.Type.INTEGER&&u.value.length>1&&(u.value.charCodeAt(0)===0&&(u.value.charCodeAt(1)&128)===0||u.value.charCodeAt(0)===255&&(u.value.charCodeAt(1)&128)===128))f.putBytes(u.value.substr(1));else f.putBytes(u.value);if(r.putByte(C),f.length()<=127)r.putByte(f.length()&127);else{var T=f.length(),c="";do c+=String.fromCharCode(T&255),T=T>>>8;while(T>0);r.putByte(c.length|128);for(var U=c.length-1;U>=0;--U)r.putByte(c.charCodeAt(U))}return r.putBuffer(f),r},e.oidToDer=function(u){var r=u.split("."),C=t.util.createBuffer();C.putByte(40*parseInt(r[0],10)+parseInt(r[1],10));var f,I,U,T;for(var c=2;c<r.length;++c){f=!0,I=[],U=parseInt(r[c],10);do{if(T=U&127,U=U>>>7,!f)T|=128;I.push(T),f=!1}while(U>0);for(var m=I.length-1;m>=0;--m)C.putByte(I[m])}return C},e.derToOid=function(u){var r;if(typeof u==="string")u=t.util.createBuffer(u);var C=u.getByte();r=Math.floor(C/40)+"."+C%40;var f=0;while(u.length()>0)if(C=u.getByte(),f=f<<7,C&128)f+=C&127;else r+="."+(f+C),f=0;return r},e.utcTimeToDate=function(u){var r=new Date,C=parseInt(u.substr(0,2),10);C=C>=50?1900+C:2000+C;var f=parseInt(u.substr(2,2),10)-1,I=parseInt(u.substr(4,2),10),U=parseInt(u.substr(6,2),10),T=parseInt(u.substr(8,2),10),c=0;if(u.length>11){var m=u.charAt(10),S=10;if(m!=="+"&&m!=="-")c=parseInt(u.substr(10,2),10),S+=2}if(r.setUTCFullYear(C,f,I),r.setUTCHours(U,T,c,0),S){if(m=u.charAt(S),m==="+"||m==="-"){var E=parseInt(u.substr(S+1,2),10),n=parseInt(u.substr(S+4,2),10),p=E*60+n;if(p*=60000,m==="+")r.setTime(+r-p);else r.setTime(+r+p)}}return r},e.generalizedTimeToDate=function(u){var r=new Date,C=parseInt(u.substr(0,4),10),f=parseInt(u.substr(4,2),10)-1,I=parseInt(u.substr(6,2),10),U=parseInt(u.substr(8,2),10),T=parseInt(u.substr(10,2),10),c=parseInt(u.substr(12,2),10),m=0,S=0,E=!1;if(u.charAt(u.length-1)==="Z")E=!0;var n=u.length-5,p=u.charAt(n);if(p==="+"||p==="-"){var y=parseInt(u.substr(n+1,2),10),b=parseInt(u.substr(n+4,2),10);if(S=y*60+b,S*=60000,p==="+")S*=-1;E=!0}if(u.charAt(14)===".")m=parseFloat(u.substr(14),10)*1000;if(E)r.setUTCFullYear(C,f,I),r.setUTCHours(U,T,c,m),r.setTime(+r+S);else r.setFullYear(C,f,I),r.setHours(U,T,c,m);return r},e.dateToUtcTime=function(u){if(typeof u==="string")return u;var r="",C=[];C.push((""+u.getUTCFullYear()).substr(2)),C.push(""+(u.getUTCMonth()+1)),C.push(""+u.getUTCDate()),C.push(""+u.getUTCHours()),C.push(""+u.getUTCMinutes()),C.push(""+u.getUTCSeconds());for(var f=0;f<C.length;++f){if(C[f].length<2)r+="0";r+=C[f]}return r+="Z",r},e.dateToGeneralizedTime=function(u){if(typeof u==="string")return u;var r="",C=[];C.push(""+u.getUTCFullYear()),C.push(""+(u.getUTCMonth()+1)),C.push(""+u.getUTCDate()),C.push(""+u.getUTCHours()),C.push(""+u.getUTCMinutes()),C.push(""+u.getUTCSeconds());for(var f=0;f<C.length;++f){if(C[f].length<2)r+="0";r+=C[f]}return r+="Z",r},e.integerToDer=function(u){var r=t.util.createBuffer();if(u>=-128&&u<128)return r.putSignedInt(u,8);if(u>=-32768&&u<32768)return r.putSignedInt(u,16);if(u>=-8388608&&u<8388608)return r.putSignedInt(u,24);if(u>=-2147483648&&u<2147483648)return r.putSignedInt(u,32);var C=new Error("Integer too large; max is 32-bits.");throw C.integer=u,C},e.derToInteger=function(u){if(typeof u==="string")u=t.util.createBuffer(u);var r=u.length()*8;if(r>32)throw new Error("Integer too large; max is 32-bits.");return u.getSignedInt(r)},e.validate=function(u,r,C,f){var I=!1;if((u.tagClass===r.tagClass||typeof r.tagClass==="undefined")&&(u.type===r.type||typeof r.type==="undefined")){if(u.constructed===r.constructed||typeof r.constructed==="undefined"){if(I=!0,r.value&&t.util.isArray(r.value)){var U=0;for(var T=0;I&&T<r.value.length;++T){if(I=r.value[T].optional||!1,u.value[U]){if(I=e.validate(u.value[U],r.value[T],C,f),I)++U;else if(r.value[T].optional)I=!0}if(!I&&f)f.push("["+r.name+'] Tag class "'+r.tagClass+'", type "'+r.type+'" expected value length "'+r.value.length+'", got "'+u.value.length+'"')}}if(I&&C){if(r.capture)C[r.capture]=u.value;if(r.captureAsn1)C[r.captureAsn1]=u;if(r.captureBitStringContents&&"bitStringContents"in u)C[r.captureBitStringContents]=u.bitStringContents;if(r.captureBitStringValue&&"bitStringContents"in u){var c;if(u.bitStringContents.length<2)C[r.captureBitStringValue]="";else{var m=u.bitStringContents.charCodeAt(0);if(m!==0)throw new Error("captureBitStringValue only supported for zero unused bits");C[r.captureBitStringValue]=u.bitStringContents.slice(1)}}}}else if(f)f.push("["+r.name+'] Expected constructed "'+r.constructed+'", got "'+u.constructed+'"')}else if(f){if(u.tagClass!==r.tagClass)f.push("["+r.name+'] Expected tag class "'+r.tagClass+'", got "'+u.tagClass+'"');if(u.type!==r.type)f.push("["+r.name+'] Expected type "'+r.type+'", got "'+u.type+'"')}return I};var g=/[^\\u0000-\\u00ff]/;e.prettyPrint=function(u,r,C){var f="";if(r=r||0,C=C||2,r>0)f+=`
|
|
17
|
-
`;var I="";for(var U=0;U<r*C;++U)I+=" ";switch(f+=I+"Tag: ",u.tagClass){case e.Class.UNIVERSAL:f+="Universal:";break;case e.Class.APPLICATION:f+="Application:";break;case e.Class.CONTEXT_SPECIFIC:f+="Context-Specific:";break;case e.Class.PRIVATE:f+="Private:";break}if(u.tagClass===e.Class.UNIVERSAL)switch(f+=u.type,u.type){case e.Type.NONE:f+=" (None)";break;case e.Type.BOOLEAN:f+=" (Boolean)";break;case e.Type.INTEGER:f+=" (Integer)";break;case e.Type.BITSTRING:f+=" (Bit string)";break;case e.Type.OCTETSTRING:f+=" (Octet string)";break;case e.Type.NULL:f+=" (Null)";break;case e.Type.OID:f+=" (Object Identifier)";break;case e.Type.ODESC:f+=" (Object Descriptor)";break;case e.Type.EXTERNAL:f+=" (External or Instance of)";break;case e.Type.REAL:f+=" (Real)";break;case e.Type.ENUMERATED:f+=" (Enumerated)";break;case e.Type.EMBEDDED:f+=" (Embedded PDV)";break;case e.Type.UTF8:f+=" (UTF8)";break;case e.Type.ROID:f+=" (Relative Object Identifier)";break;case e.Type.SEQUENCE:f+=" (Sequence)";break;case e.Type.SET:f+=" (Set)";break;case e.Type.PRINTABLESTRING:f+=" (Printable String)";break;case e.Type.IA5String:f+=" (IA5String (ASCII))";break;case e.Type.UTCTIME:f+=" (UTC time)";break;case e.Type.GENERALIZEDTIME:f+=" (Generalized time)";break;case e.Type.BMPSTRING:f+=" (BMP String)";break}else f+=u.type;if(f+=`
|
|
18
|
-
`,f+=I+"Constructed: "+u.constructed+`
|
|
19
|
-
`,u.composed){var T=0,c="";for(var U=0;U<u.value.length;++U)if(u.value[U]!==void 0){if(T+=1,c+=e.prettyPrint(u.value[U],r+1,C),U+1<u.value.length)c+=","}f+=I+"Sub values: "+T+c}else{if(f+=I+"Value: ",u.type===e.Type.OID){var m=e.derToOid(u.value);if(f+=m,t.pki&&t.pki.oids){if(m in t.pki.oids)f+=" ("+t.pki.oids[m]+") "}}if(u.type===e.Type.INTEGER)try{f+=e.derToInteger(u.value)}catch(E){f+="0x"+t.util.bytesToHex(u.value)}else if(u.type===e.Type.BITSTRING){if(u.value.length>1)f+="0x"+t.util.bytesToHex(u.value.slice(1));else f+="(none)";if(u.value.length>0){var S=u.value.charCodeAt(0);if(S==1)f+=" (1 unused bit shown)";else if(S>1)f+=" ("+S+" unused bits shown)"}}else if(u.type===e.Type.OCTETSTRING){if(!g.test(u.value))f+="("+u.value+") ";f+="0x"+t.util.bytesToHex(u.value)}else if(u.type===e.Type.UTF8)try{f+=t.util.decodeUtf8(u.value)}catch(E){if(E.message==="URI malformed")f+="0x"+t.util.bytesToHex(u.value)+" (malformed UTF8)";else throw E}else if(u.type===e.Type.PRINTABLESTRING||u.type===e.Type.IA5String)f+=u.value;else if(g.test(u.value))f+="0x"+t.util.bytesToHex(u.value);else if(u.value.length===0)f+="[null]";else f+=u.value}return f}}),yt=le((N,_)=>{var t=pe();_.exports=t.md=t.md||{},t.md.algorithms=t.md.algorithms||{}}),Ot=le((N,_)=>{var t=pe();yt(),Ce();var e=_.exports=t.hmac=t.hmac||{};e.create=function(){var a=null,d=null,v=null,g=null,u={};return u.start=function(r,C){if(r!==null)if(typeof r==="string")if(r=r.toLowerCase(),r in t.md.algorithms)d=t.md.algorithms[r].create();else throw new Error('Unknown hash algorithm "'+r+'"');else d=r;if(C===null)C=a;else{if(typeof C==="string")C=t.util.createBuffer(C);else if(t.util.isArray(C)){var f=C;C=t.util.createBuffer();for(var I=0;I<f.length;++I)C.putByte(f[I])}var U=C.length();if(U>d.blockLength)d.start(),d.update(C.bytes()),C=d.digest();v=t.util.createBuffer(),g=t.util.createBuffer(),U=C.length();for(var I=0;I<U;++I){var f=C.at(I);v.putByte(54^f),g.putByte(92^f)}if(U<d.blockLength){var f=d.blockLength-U;for(var I=0;I<f;++I)v.putByte(54),g.putByte(92)}a=C,v=v.bytes(),g=g.bytes()}d.start(),d.update(v)},u.update=function(r){d.update(r)},u.getMac=function(){var r=d.digest().bytes();return d.start(),d.update(g),d.update(r),d.digest()},u.digest=u.getMac,u}}),lr=le((N,_)=>{var t=pe();yt(),Ce();var e=_.exports=t.md5=t.md5||{};t.md.md5=t.md.algorithms.md5=e,e.create=function(){if(!u)r();var f=null,I=t.util.createBuffer(),U=new Array(16),T={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return T.start=function(){T.messageLength=0,T.fullMessageLength=T.messageLength64=[];var c=T.messageLengthSize/4;for(var m=0;m<c;++m)T.fullMessageLength.push(0);return I=t.util.createBuffer(),f={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},T},T.start(),T.update=function(c,m){if(m==="utf8")c=t.util.encodeUtf8(c);var S=c.length;T.messageLength+=S,S=[S/4294967296>>>0,S>>>0];for(var E=T.fullMessageLength.length-1;E>=0;--E)T.fullMessageLength[E]+=S[1],S[1]=S[0]+(T.fullMessageLength[E]/4294967296>>>0),T.fullMessageLength[E]=T.fullMessageLength[E]>>>0,S[0]=S[1]/4294967296>>>0;if(I.putBytes(c),C(f,U,I),I.read>2048||I.length()===0)I.compact();return T},T.digest=function(){var c=t.util.createBuffer();c.putBytes(I.bytes());var m=T.fullMessageLength[T.fullMessageLength.length-1]+T.messageLengthSize,S=m&T.blockLength-1;c.putBytes(a.substr(0,T.blockLength-S));var E,n=0;for(var p=T.fullMessageLength.length-1;p>=0;--p)E=T.fullMessageLength[p]*8+n,n=E/4294967296>>>0,c.putInt32Le(E>>>0);var y={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3};C(y,U,c);var b=t.util.createBuffer();return b.putInt32Le(y.h0),b.putInt32Le(y.h1),b.putInt32Le(y.h2),b.putInt32Le(y.h3),b},T};var a=null,d=null,v=null,g=null,u=!1;function r(){a=String.fromCharCode(128),a+=t.util.fillString(String.fromCharCode(0),64),d=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],v=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],g=new Array(64);for(var f=0;f<64;++f)g[f]=Math.floor(Math.abs(Math.sin(f+1))*4294967296);u=!0}function C(f,I,U){var T,c,m,S,E,n,p,y,b=U.length();while(b>=64){c=f.h0,m=f.h1,S=f.h2,E=f.h3;for(y=0;y<16;++y)I[y]=U.getInt32Le(),n=E^m&(S^E),T=c+n+g[y]+I[y],p=v[y],c=E,E=S,S=m,m+=T<<p|T>>>32-p;for(;y<32;++y)n=S^E&(m^S),T=c+n+g[y]+I[d[y]],p=v[y],c=E,E=S,S=m,m+=T<<p|T>>>32-p;for(;y<48;++y)n=m^S^E,T=c+n+g[y]+I[d[y]],p=v[y],c=E,E=S,S=m,m+=T<<p|T>>>32-p;for(;y<64;++y)n=S^(m|~E),T=c+n+g[y]+I[d[y]],p=v[y],c=E,E=S,S=m,m+=T<<p|T>>>32-p;f.h0=f.h0+c|0,f.h1=f.h1+m|0,f.h2=f.h2+S|0,f.h3=f.h3+E|0,b-=64}}}),Rt=le((N,_)=>{var t=pe();Ce();var e=_.exports=t.pem=t.pem||{};e.encode=function(v,g){g=g||{};var u="-----BEGIN "+v.type+`-----\r
|
|
20
|
-
`,r;if(v.procType)r={name:"Proc-Type",values:[String(v.procType.version),v.procType.type]},u+=a(r);if(v.contentDomain)r={name:"Content-Domain",values:[v.contentDomain]},u+=a(r);if(v.dekInfo){if(r={name:"DEK-Info",values:[v.dekInfo.algorithm]},v.dekInfo.parameters)r.values.push(v.dekInfo.parameters);u+=a(r)}if(v.headers)for(var C=0;C<v.headers.length;++C)u+=a(v.headers[C]);if(v.procType)u+=`\r
|
|
21
|
-
`;return u+=t.util.encode64(v.body,g.maxline||64)+`\r
|
|
22
|
-
`,u+="-----END "+v.type+`-----\r
|
|
23
|
-
`,u},e.decode=function(v){var g=[],u=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,r=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,C=/\r?\n/,f;while(!0){if(f=u.exec(v),!f)break;var I=f[1];if(I==="NEW CERTIFICATE REQUEST")I="CERTIFICATE REQUEST";var U={type:I,procType:null,contentDomain:null,dekInfo:null,headers:[],body:t.util.decode64(f[3])};if(g.push(U),!f[2])continue;var T=f[2].split(C),c=0;while(f&&c<T.length){var m=T[c].replace(/\s+$/,"");for(var S=c+1;S<T.length;++S){var E=T[S];if(!/\s/.test(E[0]))break;m+=E,c=S}if(f=m.match(r),f){var n={name:f[1],values:[]},p=f[2].split(",");for(var y=0;y<p.length;++y)n.values.push(d(p[y]));if(!U.procType){if(n.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');else if(n.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');U.procType={version:p[0],type:p[1]}}else if(!U.contentDomain&&n.name==="Content-Domain")U.contentDomain=p[0]||"";else if(!U.dekInfo&&n.name==="DEK-Info"){if(n.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');U.dekInfo={algorithm:p[0],parameters:p[1]||null}}else U.headers.push(n)}++c}if(U.procType==="ENCRYPTED"&&!U.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}if(g.length===0)throw new Error("Invalid PEM formatted message.");return g};function a(v){var g=v.name+": ",u=[],r=function(T,c){return" "+c};for(var C=0;C<v.values.length;++C)u.push(v.values[C].replace(/^(\S+\r\n)/,r));g+=u.join(",")+`\r
|
|
24
|
-
`;var f=0,I=-1;for(var C=0;C<g.length;++C,++f)if(f>65&&I!==-1){var U=g[I];if(U===",")++I,g=g.substr(0,I)+`\r
|
|
25
|
-
`+g.substr(I);else g=g.substr(0,I)+`\r
|
|
26
|
-
`+U+g.substr(I+1);f=C-I-1,I=-1,++C}else if(g[C]===" "||g[C]==="\t"||g[C]===",")I=C;return g}function d(v){return v.replace(/^\s+/,"")}}),Yt=le((N,_)=>{var t=pe();ur(),Or(),Ce(),_.exports=t.des=t.des||{},t.des.startEncrypting=function(c,m,S,E){var n=T({key:c,output:S,decrypt:!1,mode:E||(m===null?"ECB":"CBC")});return n.start(m),n},t.des.createEncryptionCipher=function(c,m){return T({key:c,output:null,decrypt:!1,mode:m})},t.des.startDecrypting=function(c,m,S,E){var n=T({key:c,output:S,decrypt:!0,mode:E||(m===null?"ECB":"CBC")});return n.start(m),n},t.des.createDecryptionCipher=function(c,m){return T({key:c,output:null,decrypt:!0,mode:m})},t.des.Algorithm=function(c,m){var S=this;S.name=c,S.mode=new m({blockSize:8,cipher:{encrypt:function(E,n){return U(S._keys,E,n,!1)},decrypt:function(E,n){return U(S._keys,E,n,!0)}}}),S._init=!1},t.des.Algorithm.prototype.initialize=function(c){if(this._init)return;var m=t.util.createBuffer(c.key);if(this.name.indexOf("3DES")===0){if(m.length()!==24)throw new Error("Invalid Triple-DES key size: "+m.length()*8)}this._keys=I(m),this._init=!0},e("DES-ECB",t.cipher.modes.ecb),e("DES-CBC",t.cipher.modes.cbc),e("DES-CFB",t.cipher.modes.cfb),e("DES-OFB",t.cipher.modes.ofb),e("DES-CTR",t.cipher.modes.ctr),e("3DES-ECB",t.cipher.modes.ecb),e("3DES-CBC",t.cipher.modes.cbc),e("3DES-CFB",t.cipher.modes.cfb),e("3DES-OFB",t.cipher.modes.ofb),e("3DES-CTR",t.cipher.modes.ctr);function e(c,m){var S=function(){return new t.des.Algorithm(c,m)};t.cipher.registerAlgorithm(c,S)}var a=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],d=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],v=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],g=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],r=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],C=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],f=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function I(c){var m=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],S=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],E=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],n=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],p=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],y=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],b=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],L=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],h=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],s=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],i=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],B=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],P=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],O=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],V=c.length()>8?3:1,M=[],G=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],q=0,H;for(var X=0;X<V;X++){var J=c.getInt32(),te=c.getInt32();H=(J>>>4^te)&252645135,te^=H,J^=H<<4,H=(te>>>-16^J)&65535,J^=H,te^=H<<-16,H=(J>>>2^te)&858993459,te^=H,J^=H<<2,H=(te>>>-16^J)&65535,J^=H,te^=H<<-16,H=(J>>>1^te)&1431655765,te^=H,J^=H<<1,H=(te>>>8^J)&16711935,J^=H,te^=H<<8,H=(J>>>1^te)&1431655765,te^=H,J^=H<<1,H=J<<8|te>>>20&240,J=te<<24|te<<8&16711680|te>>>8&65280|te>>>24&240,te=H;for(var se=0;se<G.length;++se){if(G[se])J=J<<2|J>>>26,te=te<<2|te>>>26;else J=J<<1|J>>>27,te=te<<1|te>>>27;J&=-15,te&=-15;var fe=m[J>>>28]|S[J>>>24&15]|E[J>>>20&15]|n[J>>>16&15]|p[J>>>12&15]|y[J>>>8&15]|b[J>>>4&15],ve=L[te>>>28]|h[te>>>24&15]|s[te>>>20&15]|i[te>>>16&15]|B[te>>>12&15]|P[te>>>8&15]|O[te>>>4&15];H=(ve>>>16^fe)&65535,M[q++]=fe^H,M[q++]=ve^H<<16}}return M}function U(c,m,S,E){var n=c.length===32?3:9,p;if(n===3)p=E?[30,-2,-2]:[0,32,2];else p=E?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var y,b=m[0],L=m[1];y=(b>>>4^L)&252645135,L^=y,b^=y<<4,y=(b>>>16^L)&65535,L^=y,b^=y<<16,y=(L>>>2^b)&858993459,b^=y,L^=y<<2,y=(L>>>8^b)&16711935,b^=y,L^=y<<8,y=(b>>>1^L)&1431655765,L^=y,b^=y<<1,b=b<<1|b>>>31,L=L<<1|L>>>31;for(var h=0;h<n;h+=3){var s=p[h+1],i=p[h+2];for(var B=p[h];B!=s;B+=i){var P=L^c[B],O=(L>>>4|L<<28)^c[B+1];y=b,b=L,L=y^(d[P>>>24&63]|g[P>>>16&63]|r[P>>>8&63]|f[P&63]|a[O>>>24&63]|v[O>>>16&63]|u[O>>>8&63]|C[O&63])}y=b,b=L,L=y}b=b>>>1|b<<31,L=L>>>1|L<<31,y=(b>>>1^L)&1431655765,L^=y,b^=y<<1,y=(L>>>8^b)&16711935,b^=y,L^=y<<8,y=(L>>>2^b)&858993459,b^=y,L^=y<<2,y=(b>>>16^L)&65535,L^=y,b^=y<<16,y=(b>>>4^L)&252645135,L^=y,b^=y<<4,S[0]=b,S[1]=L}function T(c){c=c||{};var m=(c.mode||"CBC").toUpperCase(),S="DES-"+m,E;if(c.decrypt)E=t.cipher.createDecipher(S,c.key);else E=t.cipher.createCipher(S,c.key);var n=E.start;return E.start=function(p,y){var b=null;if(y instanceof t.util.ByteBuffer)b=y,y={};y=y||{},y.output=b,y.iv=p,n.call(E,y)},E}}),fr=le((N,_)=>{var t=pe();Ot(),yt(),Ce();var e=t.pkcs5=t.pkcs5||{},a;if(t.util.isNodejs&&!t.options.usePureJavaScript)a=zt("crypto");_.exports=t.pbkdf2=e.pbkdf2=function(d,v,g,u,r,C){if(typeof r==="function")C=r,r=null;if(t.util.isNodejs&&!t.options.usePureJavaScript&&a.pbkdf2&&(r===null||typeof r!=="object")&&(a.pbkdf2Sync.length>4||(!r||r==="sha1"))){if(typeof r!=="string")r="sha1";if(d=Buffer.from(d,"binary"),v=Buffer.from(v,"binary"),!C){if(a.pbkdf2Sync.length===4)return a.pbkdf2Sync(d,v,g,u).toString("binary");return a.pbkdf2Sync(d,v,g,u,r).toString("binary")}if(a.pbkdf2Sync.length===4)return a.pbkdf2(d,v,g,u,function(h,s){if(h)return C(h);C(null,s.toString("binary"))});return a.pbkdf2(d,v,g,u,r,function(h,s){if(h)return C(h);C(null,s.toString("binary"))})}if(typeof r==="undefined"||r===null)r="sha1";if(typeof r==="string"){if(!(r in t.md.algorithms))throw new Error("Unknown hash algorithm: "+r);r=t.md[r].create()}var f=r.digestLength;if(u>4294967295*f){var I=new Error("Derived key is too long.");if(C)return C(I);throw I}var U=Math.ceil(u/f),T=u-(U-1)*f,c=t.hmac.create();c.start(r,d);var m="",S,E,n;if(!C){for(var p=1;p<=U;++p){c.start(null,null),c.update(v),c.update(t.util.int32ToBytes(p)),S=n=c.digest().getBytes();for(var y=2;y<=g;++y)c.start(null,null),c.update(n),E=c.digest().getBytes(),S=t.util.xorBytes(S,E,f),n=E;m+=p<U?S:S.substr(0,T)}return m}var p=1,y;function b(){if(p>U)return C(null,m);c.start(null,null),c.update(v),c.update(t.util.int32ToBytes(p)),S=n=c.digest().getBytes(),y=2,L()}function L(){if(y<=g)return c.start(null,null),c.update(n),E=c.digest().getBytes(),S=t.util.xorBytes(S,E,f),n=E,++y,t.util.setImmediate(L);m+=p<U?S:S.substr(0,T),++p,b()}b()}}),Mr=le((N,_)=>{var t=pe();yt(),Ce();var e=_.exports=t.sha256=t.sha256||{};t.md.sha256=t.md.algorithms.sha256=e,e.create=function(){if(!d)g();var r=null,C=t.util.createBuffer(),f=new Array(64),I={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return I.start=function(){I.messageLength=0,I.fullMessageLength=I.messageLength64=[];var U=I.messageLengthSize/4;for(var T=0;T<U;++T)I.fullMessageLength.push(0);return C=t.util.createBuffer(),r={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},I},I.start(),I.update=function(U,T){if(T==="utf8")U=t.util.encodeUtf8(U);var c=U.length;I.messageLength+=c,c=[c/4294967296>>>0,c>>>0];for(var m=I.fullMessageLength.length-1;m>=0;--m)I.fullMessageLength[m]+=c[1],c[1]=c[0]+(I.fullMessageLength[m]/4294967296>>>0),I.fullMessageLength[m]=I.fullMessageLength[m]>>>0,c[0]=c[1]/4294967296>>>0;if(C.putBytes(U),u(r,f,C),C.read>2048||C.length()===0)C.compact();return I},I.digest=function(){var U=t.util.createBuffer();U.putBytes(C.bytes());var T=I.fullMessageLength[I.fullMessageLength.length-1]+I.messageLengthSize,c=T&I.blockLength-1;U.putBytes(a.substr(0,I.blockLength-c));var m,S,E=I.fullMessageLength[0]*8;for(var n=0;n<I.fullMessageLength.length-1;++n)m=I.fullMessageLength[n+1]*8,S=m/4294967296>>>0,E+=S,U.putInt32(E>>>0),E=m>>>0;U.putInt32(E);var p={h0:r.h0,h1:r.h1,h2:r.h2,h3:r.h3,h4:r.h4,h5:r.h5,h6:r.h6,h7:r.h7};u(p,f,U);var y=t.util.createBuffer();return y.putInt32(p.h0),y.putInt32(p.h1),y.putInt32(p.h2),y.putInt32(p.h3),y.putInt32(p.h4),y.putInt32(p.h5),y.putInt32(p.h6),y.putInt32(p.h7),y},I};var a=null,d=!1,v=null;function g(){a=String.fromCharCode(128),a+=t.util.fillString(String.fromCharCode(0),64),v=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],d=!0}function u(r,C,f){var I,U,T,c,m,S,E,n,p,y,b,L,h,s,i,B=f.length();while(B>=64){for(E=0;E<16;++E)C[E]=f.getInt32();for(;E<64;++E)I=C[E-2],I=(I>>>17|I<<15)^(I>>>19|I<<13)^I>>>10,U=C[E-15],U=(U>>>7|U<<25)^(U>>>18|U<<14)^U>>>3,C[E]=I+C[E-7]+U+C[E-16]|0;n=r.h0,p=r.h1,y=r.h2,b=r.h3,L=r.h4,h=r.h5,s=r.h6,i=r.h7;for(E=0;E<64;++E)c=(L>>>6|L<<26)^(L>>>11|L<<21)^(L>>>25|L<<7),m=s^L&(h^s),T=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),S=n&p|y&(n^p),I=i+c+m+v[E]+C[E],U=T+S,i=s,s=h,h=L,L=b+I>>>0,b=y,y=p,p=n,n=I+U>>>0;r.h0=r.h0+n|0,r.h1=r.h1+p|0,r.h2=r.h2+y|0,r.h3=r.h3+b|0,r.h4=r.h4+L|0,r.h5=r.h5+h|0,r.h6=r.h6+s|0,r.h7=r.h7+i|0,B-=64}}}),Fr=le((N,_)=>{var t=pe();Ce();var e=null;if(t.util.isNodejs&&!t.options.usePureJavaScript&&!process.versions["node-webkit"])e=zt("crypto");var a=_.exports=t.prng=t.prng||{};a.create=function(d){var v={plugin:d,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},g=d.md,u=new Array(32);for(var r=0;r<32;++r)u[r]=g.create();v.pools=u,v.pool=0,v.generate=function(T,c){if(!c)return v.generateSync(T);var m=v.plugin.cipher,S=v.plugin.increment,E=v.plugin.formatKey,n=v.plugin.formatSeed,p=t.util.createBuffer();v.key=null,y();function y(b){if(b)return c(b);if(p.length()>=T)return c(null,p.getBytes(T));if(v.generated>1048575)v.key=null;if(v.key===null)return t.util.nextTick(function(){C(y)});var L=m(v.key,v.seed);v.generated+=L.length,p.putBytes(L),v.key=E(m(v.key,S(v.seed))),v.seed=n(m(v.key,v.seed)),t.util.setImmediate(y)}},v.generateSync=function(T){var c=v.plugin.cipher,m=v.plugin.increment,S=v.plugin.formatKey,E=v.plugin.formatSeed;v.key=null;var n=t.util.createBuffer();while(n.length()<T){if(v.generated>1048575)v.key=null;if(v.key===null)f();var p=c(v.key,v.seed);v.generated+=p.length,n.putBytes(p),v.key=S(c(v.key,m(v.seed))),v.seed=E(c(v.key,v.seed))}return n.getBytes(T)};function C(T){if(v.pools[0].messageLength>=32)return I(),T();var c=32-v.pools[0].messageLength<<5;v.seedFile(c,function(m,S){if(m)return T(m);v.collect(S),I(),T()})}function f(){if(v.pools[0].messageLength>=32)return I();var T=32-v.pools[0].messageLength<<5;v.collect(v.seedFileSync(T)),I()}function I(){v.reseeds=v.reseeds===4294967295?0:v.reseeds+1;var T=v.plugin.md.create();T.update(v.keyBytes);var c=1;for(var m=0;m<32;++m){if(v.reseeds%c===0)T.update(v.pools[m].digest().getBytes()),v.pools[m].start();c=c<<1}v.keyBytes=T.digest().getBytes(),T.start(),T.update(v.keyBytes);var S=T.digest().getBytes();v.key=v.plugin.formatKey(v.keyBytes),v.seed=v.plugin.formatSeed(S),v.generated=0}function U(T){var c=null,m=t.util.globalScope,S=m.crypto||m.msCrypto;if(S&&S.getRandomValues)c=function(i){return S.getRandomValues(i)};var E=t.util.createBuffer();if(c)while(E.length()<T){var n=Math.max(1,Math.min(T-E.length(),65536)/4),p=new Uint32Array(Math.floor(n));try{c(p);for(var y=0;y<p.length;++y)E.putInt32(p[y])}catch(i){if(!(typeof QuotaExceededError!=="undefined"&&i instanceof QuotaExceededError))throw i}}if(E.length()<T){var b,L,h,s=Math.floor(Math.random()*65536);while(E.length()<T){L=16807*(s&65535),b=16807*(s>>16),L+=(b&32767)<<16,L+=b>>15,L=(L&2147483647)+(L>>31),s=L&4294967295;for(var y=0;y<3;++y)h=s>>>(y<<3),h^=Math.floor(Math.random()*256),E.putByte(h&255)}}return E.getBytes(T)}if(e)v.seedFile=function(T,c){e.randomBytes(T,function(m,S){if(m)return c(m);c(null,S.toString())})},v.seedFileSync=function(T){return e.randomBytes(T).toString()};else v.seedFile=function(T,c){try{c(null,U(T))}catch(m){c(m)}},v.seedFileSync=U;return v.collect=function(T){var c=T.length;for(var m=0;m<c;++m)v.pools[v.pool].update(T.substr(m,1)),v.pool=v.pool===31?0:v.pool+1},v.collectInt=function(T,c){var m="";for(var S=0;S<c;S+=8)m+=String.fromCharCode(T>>S&255);v.collect(m)},v.registerWorker=function(T){if(T===self)v.seedFile=function(m,S){function E(n){var p=n.data;if(p.forge&&p.forge.prng)self.removeEventListener("message",E),S(p.forge.prng.err,p.forge.prng.bytes)}self.addEventListener("message",E),self.postMessage({forge:{prng:{needed:m}}})};else{var c=function(m){var S=m.data;if(S.forge&&S.forge.prng)v.seedFile(S.forge.prng.needed,function(E,n){T.postMessage({forge:{prng:{err:E,bytes:n}}})})};T.addEventListener("message",c)}},v}}),ot=le((N,_)=>{var t=pe();Tt(),Mr(),Fr(),Ce(),function(){if(t.random&&t.random.getBytes){_.exports=t.random;return}(function(e){var a={},d=new Array(4),v=t.util.createBuffer();a.formatKey=function(T){var c=t.util.createBuffer(T);return T=new Array(4),T[0]=c.getInt32(),T[1]=c.getInt32(),T[2]=c.getInt32(),T[3]=c.getInt32(),t.aes._expandKey(T,!1)},a.formatSeed=function(T){var c=t.util.createBuffer(T);return T=new Array(4),T[0]=c.getInt32(),T[1]=c.getInt32(),T[2]=c.getInt32(),T[3]=c.getInt32(),T},a.cipher=function(T,c){return t.aes._updateBlock(T,c,d,!1),v.putInt32(d[0]),v.putInt32(d[1]),v.putInt32(d[2]),v.putInt32(d[3]),v.getBytes()},a.increment=function(T){return++T[3],T},a.md=t.md.sha256;function g(){var T=t.prng.create(a);return T.getBytes=function(c,m){return T.generate(c,m)},T.getBytesSync=function(c){return T.generate(c)},T}var u=g(),r=null,C=t.util.globalScope,f=C.crypto||C.msCrypto;if(f&&f.getRandomValues)r=function(T){return f.getRandomValues(T)};if(t.options.usePureJavaScript||!t.util.isNodejs&&!r){if(typeof window==="undefined"||window.document===void 0);if(u.collectInt(+new Date,32),typeof navigator!=="undefined"){var I="";for(var U in navigator)try{if(typeof navigator[U]=="string")I+=navigator[U]}catch(T){}u.collect(I),I=null}if(e)e().mousemove(function(T){u.collectInt(T.clientX,16),u.collectInt(T.clientY,16)}),e().keypress(function(T){u.collectInt(T.charCode,8)})}if(!t.random)t.random=u;else for(var U in u)t.random[U]=u[U];t.random.createInstance=g,_.exports=t.random})(typeof jQuery!=="undefined"?jQuery:null)}()}),jr=le((N,_)=>{var t=pe();Ce();var e=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],a=[1,2,3,5],d=function(u,r){return u<<r&65535|(u&65535)>>16-r},v=function(u,r){return(u&65535)>>r|u<<16-r&65535};_.exports=t.rc2=t.rc2||{},t.rc2.expandKey=function(u,r){if(typeof u==="string")u=t.util.createBuffer(u);r=r||128;var C=u,f=u.length(),I=r,U=Math.ceil(I/8),T=255>>(I&7),c;for(c=f;c<128;c++)C.putByte(e[C.at(c-1)+C.at(c-f)&255]);C.setAt(128-U,e[C.at(128-U)&T]);for(c=127-U;c>=0;c--)C.setAt(c,e[C.at(c+1)^C.at(c+U)]);return C};var g=function(u,r,C){var f=!1,I=null,U=null,T=null,c,m,S,E,n=[];u=t.rc2.expandKey(u,r);for(S=0;S<64;S++)n.push(u.getInt16Le());if(C)c=function(b){for(S=0;S<4;S++)b[S]+=n[E]+(b[(S+3)%4]&b[(S+2)%4])+(~b[(S+3)%4]&b[(S+1)%4]),b[S]=d(b[S],a[S]),E++},m=function(b){for(S=0;S<4;S++)b[S]+=n[b[(S+3)%4]&63]};else c=function(b){for(S=3;S>=0;S--)b[S]=v(b[S],a[S]),b[S]-=n[E]+(b[(S+3)%4]&b[(S+2)%4])+(~b[(S+3)%4]&b[(S+1)%4]),E--},m=function(b){for(S=3;S>=0;S--)b[S]-=n[b[(S+3)%4]&63]};var p=function(b){var L=[];for(S=0;S<4;S++){var h=I.getInt16Le();if(T!==null)if(C)h^=T.getInt16Le();else T.putInt16Le(h);L.push(h&65535)}E=C?0:63;for(var s=0;s<b.length;s++)for(var i=0;i<b[s][0];i++)b[s][1](L);for(S=0;S<4;S++){if(T!==null)if(C)T.putInt16Le(L[S]);else L[S]^=T.getInt16Le();U.putInt16Le(L[S])}},y=null;return y={start:function(b,L){if(b){if(typeof b==="string")b=t.util.createBuffer(b)}f=!1,I=t.util.createBuffer(),U=L||new t.util.createBuffer,T=b,y.output=U},update:function(b){if(!f)I.putBuffer(b);while(I.length()>=8)p([[5,c],[1,m],[6,c],[1,m],[5,c]])},finish:function(b){var L=!0;if(C)if(b)L=b(8,I,!C);else{var h=I.length()===8?8:8-I.length();I.fillWithByte(h,h)}if(L)f=!0,y.update();if(!C){if(L=I.length()===0,L)if(b)L=b(8,U,!C);else{var s=U.length(),i=U.at(s-1);if(i>s)L=!1;else U.truncate(i)}}return L}},y};t.rc2.startEncrypting=function(u,r,C){var f=t.rc2.createEncryptionCipher(u,128);return f.start(r,C),f},t.rc2.createEncryptionCipher=function(u,r){return g(u,r,!0)},t.rc2.startDecrypting=function(u,r,C){var f=t.rc2.createDecryptionCipher(u,128);return f.start(r,C),f},t.rc2.createDecryptionCipher=function(u,r){return g(u,r,!1)}}),Xt=le((N,_)=>{var t=pe();_.exports=t.jsbn=t.jsbn||{};var e,a=244837814094590,d=(a&16777215)==15715070;function v(A,k,x){if(this.data=[],A!=null)if(typeof A=="number")this.fromNumber(A,k,x);else if(k==null&&typeof A!="string")this.fromString(A,256);else this.fromString(A,k)}t.jsbn.BigInteger=v;function g(){return new v(null)}function u(A,k,x,j,z,W){while(--W>=0){var ne=k*this.data[A++]+x.data[j]+z;z=Math.floor(ne/67108864),x.data[j++]=ne&67108863}return z}function r(A,k,x,j,z,W){var ne=k&32767,re=k>>15;while(--W>=0){var Ee=this.data[A]&32767,Ye=this.data[A++]>>15,rt=re*Ee+Ye*ne;Ee=ne*Ee+((rt&32767)<<15)+x.data[j]+(z&1073741823),z=(Ee>>>30)+(rt>>>15)+re*Ye+(z>>>30),x.data[j++]=Ee&1073741823}return z}function C(A,k,x,j,z,W){var ne=k&16383,re=k>>14;while(--W>=0){var Ee=this.data[A]&16383,Ye=this.data[A++]>>14,rt=re*Ee+Ye*ne;Ee=ne*Ee+((rt&16383)<<14)+x.data[j]+z,z=(Ee>>28)+(rt>>14)+re*Ye,x.data[j++]=Ee&268435455}return z}if(typeof navigator==="undefined")v.prototype.am=C,e=28;else if(d&&navigator.appName=="Microsoft Internet Explorer")v.prototype.am=r,e=30;else if(d&&navigator.appName!="Netscape")v.prototype.am=u,e=26;else v.prototype.am=C,e=28;v.prototype.DB=e,v.prototype.DM=(1<<e)-1,v.prototype.DV=1<<e;var f=52;v.prototype.FV=Math.pow(2,f),v.prototype.F1=f-e,v.prototype.F2=2*e-f;var I="0123456789abcdefghijklmnopqrstuvwxyz",U=new Array,T,c;T=48;for(c=0;c<=9;++c)U[T++]=c;T=97;for(c=10;c<36;++c)U[T++]=c;T=65;for(c=10;c<36;++c)U[T++]=c;function m(A){return I.charAt(A)}function S(A,k){var x=U[A.charCodeAt(k)];return x==null?-1:x}function E(A){for(var k=this.t-1;k>=0;--k)A.data[k]=this.data[k];A.t=this.t,A.s=this.s}function n(A){if(this.t=1,this.s=A<0?-1:0,A>0)this.data[0]=A;else if(A<-1)this.data[0]=A+this.DV;else this.t=0}function p(A){var k=g();return k.fromInt(A),k}function y(A,k){var x;if(k==16)x=4;else if(k==8)x=3;else if(k==256)x=8;else if(k==2)x=1;else if(k==32)x=5;else if(k==4)x=2;else{this.fromRadix(A,k);return}this.t=0,this.s=0;var j=A.length,z=!1,W=0;while(--j>=0){var ne=x==8?A[j]&255:S(A,j);if(ne<0){if(A.charAt(j)=="-")z=!0;continue}if(z=!1,W==0)this.data[this.t++]=ne;else if(W+x>this.DB)this.data[this.t-1]|=(ne&(1<<this.DB-W)-1)<<W,this.data[this.t++]=ne>>this.DB-W;else this.data[this.t-1]|=ne<<W;if(W+=x,W>=this.DB)W-=this.DB}if(x==8&&(A[0]&128)!=0){if(this.s=-1,W>0)this.data[this.t-1]|=(1<<this.DB-W)-1<<W}if(this.clamp(),z)v.ZERO.subTo(this,this)}function b(){var A=this.s&this.DM;while(this.t>0&&this.data[this.t-1]==A)--this.t}function L(A){if(this.s<0)return"-"+this.negate().toString(A);var k;if(A==16)k=4;else if(A==8)k=3;else if(A==2)k=1;else if(A==32)k=5;else if(A==4)k=2;else return this.toRadix(A);var x=(1<<k)-1,j,z=!1,W="",ne=this.t,re=this.DB-ne*this.DB%k;if(ne-- >0){if(re<this.DB&&(j=this.data[ne]>>re)>0)z=!0,W=m(j);while(ne>=0){if(re<k)j=(this.data[ne]&(1<<re)-1)<<k-re,j|=this.data[--ne]>>(re+=this.DB-k);else if(j=this.data[ne]>>(re-=k)&x,re<=0)re+=this.DB,--ne;if(j>0)z=!0;if(z)W+=m(j)}}return z?W:"0"}function h(){var A=g();return v.ZERO.subTo(this,A),A}function s(){return this.s<0?this.negate():this}function i(A){var k=this.s-A.s;if(k!=0)return k;var x=this.t;if(k=x-A.t,k!=0)return this.s<0?-k:k;while(--x>=0)if((k=this.data[x]-A.data[x])!=0)return k;return 0}function B(A){var k=1,x;if((x=A>>>16)!=0)A=x,k+=16;if((x=A>>8)!=0)A=x,k+=8;if((x=A>>4)!=0)A=x,k+=4;if((x=A>>2)!=0)A=x,k+=2;if((x=A>>1)!=0)A=x,k+=1;return k}function P(){if(this.t<=0)return 0;return this.DB*(this.t-1)+B(this.data[this.t-1]^this.s&this.DM)}function O(A,k){var x;for(x=this.t-1;x>=0;--x)k.data[x+A]=this.data[x];for(x=A-1;x>=0;--x)k.data[x]=0;k.t=this.t+A,k.s=this.s}function V(A,k){for(var x=A;x<this.t;++x)k.data[x-A]=this.data[x];k.t=Math.max(this.t-A,0),k.s=this.s}function M(A,k){var x=A%this.DB,j=this.DB-x,z=(1<<j)-1,W=Math.floor(A/this.DB),ne=this.s<<x&this.DM,re;for(re=this.t-1;re>=0;--re)k.data[re+W+1]=this.data[re]>>j|ne,ne=(this.data[re]&z)<<x;for(re=W-1;re>=0;--re)k.data[re]=0;k.data[W]=ne,k.t=this.t+W+1,k.s=this.s,k.clamp()}function G(A,k){k.s=this.s;var x=Math.floor(A/this.DB);if(x>=this.t){k.t=0;return}var j=A%this.DB,z=this.DB-j,W=(1<<j)-1;k.data[0]=this.data[x]>>j;for(var ne=x+1;ne<this.t;++ne)k.data[ne-x-1]|=(this.data[ne]&W)<<z,k.data[ne-x]=this.data[ne]>>j;if(j>0)k.data[this.t-x-1]|=(this.s&W)<<z;k.t=this.t-x,k.clamp()}function q(A,k){var x=0,j=0,z=Math.min(A.t,this.t);while(x<z)j+=this.data[x]-A.data[x],k.data[x++]=j&this.DM,j>>=this.DB;if(A.t<this.t){j-=A.s;while(x<this.t)j+=this.data[x],k.data[x++]=j&this.DM,j>>=this.DB;j+=this.s}else{j+=this.s;while(x<A.t)j-=A.data[x],k.data[x++]=j&this.DM,j>>=this.DB;j-=A.s}if(k.s=j<0?-1:0,j<-1)k.data[x++]=this.DV+j;else if(j>0)k.data[x++]=j;k.t=x,k.clamp()}function H(A,k){var x=this.abs(),j=A.abs(),z=x.t;k.t=z+j.t;while(--z>=0)k.data[z]=0;for(z=0;z<j.t;++z)k.data[z+x.t]=x.am(0,j.data[z],k,z,0,x.t);if(k.s=0,k.clamp(),this.s!=A.s)v.ZERO.subTo(k,k)}function X(A){var k=this.abs(),x=A.t=2*k.t;while(--x>=0)A.data[x]=0;for(x=0;x<k.t-1;++x){var j=k.am(x,k.data[x],A,2*x,0,1);if((A.data[x+k.t]+=k.am(x+1,2*k.data[x],A,2*x+1,j,k.t-x-1))>=k.DV)A.data[x+k.t]-=k.DV,A.data[x+k.t+1]=1}if(A.t>0)A.data[A.t-1]+=k.am(x,k.data[x],A,2*x,0,1);A.s=0,A.clamp()}function J(A,k,x){var j=A.abs();if(j.t<=0)return;var z=this.abs();if(z.t<j.t){if(k!=null)k.fromInt(0);if(x!=null)this.copyTo(x);return}if(x==null)x=g();var W=g(),ne=this.s,re=A.s,Ee=this.DB-B(j.data[j.t-1]);if(Ee>0)j.lShiftTo(Ee,W),z.lShiftTo(Ee,x);else j.copyTo(W),z.copyTo(x);var Ye=W.t,rt=W.data[Ye-1];if(rt==0)return;var tt=rt*(1<<this.F1)+(Ye>1?W.data[Ye-2]>>this.F2:0),pt=this.FV/tt,Gt=(1<<this.F1)/tt,nt=1<<this.F2,st=x.t,qt=st-Ye,vt=k==null?g():k;if(W.dlShiftTo(qt,vt),x.compareTo(vt)>=0)x.data[x.t++]=1,x.subTo(vt,x);v.ONE.dlShiftTo(Ye,vt),vt.subTo(W,W);while(W.t<Ye)W.data[W.t++]=0;while(--qt>=0){var er=x.data[--st]==rt?this.DM:Math.floor(x.data[st]*pt+(x.data[st-1]+nt)*Gt);if((x.data[st]+=W.am(0,er,x,qt,0,Ye))<er){W.dlShiftTo(qt,vt),x.subTo(vt,x);while(x.data[st]<--er)x.subTo(vt,x)}}if(k!=null){if(x.drShiftTo(Ye,k),ne!=re)v.ZERO.subTo(k,k)}if(x.t=Ye,x.clamp(),Ee>0)x.rShiftTo(Ee,x);if(ne<0)v.ZERO.subTo(x,x)}function te(A){var k=g();if(this.abs().divRemTo(A,null,k),this.s<0&&k.compareTo(v.ZERO)>0)A.subTo(k,k);return k}function se(A){this.m=A}function fe(A){if(A.s<0||A.compareTo(this.m)>=0)return A.mod(this.m);else return A}function ve(A){return A}function Ie(A){A.divRemTo(this.m,null,A)}function Z(A,k,x){A.multiplyTo(k,x),this.reduce(x)}function me(A,k){A.squareTo(k),this.reduce(k)}se.prototype.convert=fe,se.prototype.revert=ve,se.prototype.reduce=Ie,se.prototype.mulTo=Z,se.prototype.sqrTo=me;function ee(){if(this.t<1)return 0;var A=this.data[0];if((A&1)==0)return 0;var k=A&3;return k=k*(2-(A&15)*k)&15,k=k*(2-(A&255)*k)&255,k=k*(2-((A&65535)*k&65535))&65535,k=k*(2-A*k%this.DV)%this.DV,k>0?this.DV-k:-k}function Ae(A){this.m=A,this.mp=A.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<A.DB-15)-1,this.mt2=2*A.t}function de(A){var k=g();if(A.abs().dlShiftTo(this.m.t,k),k.divRemTo(this.m,null,k),A.s<0&&k.compareTo(v.ZERO)>0)this.m.subTo(k,k);return k}function l(A){var k=g();return A.copyTo(k),this.reduce(k),k}function D(A){while(A.t<=this.mt2)A.data[A.t++]=0;for(var k=0;k<this.m.t;++k){var x=A.data[k]&32767,j=x*this.mpl+((x*this.mph+(A.data[k]>>15)*this.mpl&this.um)<<15)&A.DM;x=k+this.m.t,A.data[x]+=this.m.am(0,j,A,k,0,this.m.t);while(A.data[x]>=A.DV)A.data[x]-=A.DV,A.data[++x]++}if(A.clamp(),A.drShiftTo(this.m.t,A),A.compareTo(this.m)>=0)A.subTo(this.m,A)}function R(A,k){A.squareTo(k),this.reduce(k)}function o(A,k,x){A.multiplyTo(k,x),this.reduce(x)}Ae.prototype.convert=de,Ae.prototype.revert=l,Ae.prototype.reduce=D,Ae.prototype.mulTo=o,Ae.prototype.sqrTo=R;function w(){return(this.t>0?this.data[0]&1:this.s)==0}function F(A,k){if(A>4294967295||A<1)return v.ONE;var x=g(),j=g(),z=k.convert(this),W=B(A)-1;z.copyTo(x);while(--W>=0)if(k.sqrTo(x,j),(A&1<<W)>0)k.mulTo(j,z,x);else{var ne=x;x=j,j=ne}return k.revert(x)}function K(A,k){var x;if(A<256||k.isEven())x=new se(k);else x=new Ae(k);return this.exp(A,x)}v.prototype.copyTo=E,v.prototype.fromInt=n,v.prototype.fromString=y,v.prototype.clamp=b,v.prototype.dlShiftTo=O,v.prototype.drShiftTo=V,v.prototype.lShiftTo=M,v.prototype.rShiftTo=G,v.prototype.subTo=q,v.prototype.multiplyTo=H,v.prototype.squareTo=X,v.prototype.divRemTo=J,v.prototype.invDigit=ee,v.prototype.isEven=w,v.prototype.exp=F,v.prototype.toString=L,v.prototype.negate=h,v.prototype.abs=s,v.prototype.compareTo=i,v.prototype.bitLength=P,v.prototype.mod=te,v.prototype.modPowInt=K,v.ZERO=p(0),v.ONE=p(1);function Y(){var A=g();return this.copyTo(A),A}function ie(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;else if(this.t==0)return-1}else if(this.t==1)return this.data[0];else if(this.t==0)return 0;return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function oe(){return this.t==0?this.s:this.data[0]<<24>>24}function Q(){return this.t==0?this.s:this.data[0]<<16>>16}function ae(A){return Math.floor(Math.LN2*this.DB/Math.log(A))}function ue(){if(this.s<0)return-1;else if(this.t<=0||this.t==1&&this.data[0]<=0)return 0;else return 1}function ge(A){if(A==null)A=10;if(this.signum()==0||A<2||A>36)return"0";var k=this.chunkSize(A),x=Math.pow(A,k),j=p(x),z=g(),W=g(),ne="";this.divRemTo(j,z,W);while(z.signum()>0)ne=(x+W.intValue()).toString(A).substr(1)+ne,z.divRemTo(j,z,W);return W.intValue().toString(A)+ne}function he(A,k){if(this.fromInt(0),k==null)k=10;var x=this.chunkSize(k),j=Math.pow(k,x),z=!1,W=0,ne=0;for(var re=0;re<A.length;++re){var Ee=S(A,re);if(Ee<0){if(A.charAt(re)=="-"&&this.signum()==0)z=!0;continue}if(ne=k*ne+Ee,++W>=x)this.dMultiply(j),this.dAddOffset(ne,0),W=0,ne=0}if(W>0)this.dMultiply(Math.pow(k,W)),this.dAddOffset(ne,0);if(z)v.ZERO.subTo(this,this)}function be(A,k,x){if(typeof k=="number")if(A<2)this.fromInt(1);else{if(this.fromNumber(A,x),!this.testBit(A-1))this.bitwiseTo(v.ONE.shiftLeft(A-1),De,this);if(this.isEven())this.dAddOffset(1,0);while(!this.isProbablePrime(k))if(this.dAddOffset(2,0),this.bitLength()>A)this.subTo(v.ONE.shiftLeft(A-1),this)}else{var j=new Array,z=A&7;if(j.length=(A>>3)+1,k.nextBytes(j),z>0)j[0]&=(1<<z)-1;else j[0]=0;this.fromString(j,256)}}function ke(){var A=this.t,k=new Array;k[0]=this.s;var x=this.DB-A*this.DB%8,j,z=0;if(A-- >0){if(x<this.DB&&(j=this.data[A]>>x)!=(this.s&this.DM)>>x)k[z++]=j|this.s<<this.DB-x;while(A>=0){if(x<8)j=(this.data[A]&(1<<x)-1)<<8-x,j|=this.data[--A]>>(x+=this.DB-8);else if(j=this.data[A]>>(x-=8)&255,x<=0)x+=this.DB,--A;if((j&128)!=0)j|=-256;if(z==0&&(this.s&128)!=(j&128))++z;if(z>0||j!=this.s)k[z++]=j}}return k}function we(A){return this.compareTo(A)==0}function Be(A){return this.compareTo(A)<0?this:A}function Se(A){return this.compareTo(A)>0?this:A}function Te(A,k,x){var j,z,W=Math.min(A.t,this.t);for(j=0;j<W;++j)x.data[j]=k(this.data[j],A.data[j]);if(A.t<this.t){z=A.s&this.DM;for(j=W;j<this.t;++j)x.data[j]=k(this.data[j],z);x.t=this.t}else{z=this.s&this.DM;for(j=W;j<A.t;++j)x.data[j]=k(z,A.data[j]);x.t=A.t}x.s=k(this.s,A.s),x.clamp()}function Le(A,k){return A&k}function We(A){var k=g();return this.bitwiseTo(A,Le,k),k}function De(A,k){return A|k}function Ze(A){var k=g();return this.bitwiseTo(A,De,k),k}function $e(A,k){return A^k}function Je(A){var k=g();return this.bitwiseTo(A,$e,k),k}function et(A,k){return A&~k}function it(A){var k=g();return this.bitwiseTo(A,et,k),k}function ct(){var A=g();for(var k=0;k<this.t;++k)A.data[k]=this.DM&~this.data[k];return A.t=this.t,A.s=~this.s,A}function ht(A){var k=g();if(A<0)this.rShiftTo(-A,k);else this.lShiftTo(A,k);return k}function gt(A){var k=g();if(A<0)this.lShiftTo(-A,k);else this.rShiftTo(A,k);return k}function Et(A){if(A==0)return-1;var k=0;if((A&65535)==0)A>>=16,k+=16;if((A&255)==0)A>>=8,k+=8;if((A&15)==0)A>>=4,k+=4;if((A&3)==0)A>>=2,k+=2;if((A&1)==0)++k;return k}function bt(){for(var A=0;A<this.t;++A)if(this.data[A]!=0)return A*this.DB+Et(this.data[A]);if(this.s<0)return this.t*this.DB;return-1}function Dt(A){var k=0;while(A!=0)A&=A-1,++k;return k}function jt(){var A=0,k=this.s&this.DM;for(var x=0;x<this.t;++x)A+=Dt(this.data[x]^k);return A}function Ue(A){var k=Math.floor(A/this.DB);if(k>=this.t)return this.s!=0;return(this.data[k]&1<<A%this.DB)!=0}function Ve(A,k){var x=v.ONE.shiftLeft(A);return this.bitwiseTo(x,k,x),x}function Pe(A){return this.changeBit(A,De)}function xe(A){return this.changeBit(A,et)}function Ke(A){return this.changeBit(A,$e)}function Oe(A,k){var x=0,j=0,z=Math.min(A.t,this.t);while(x<z)j+=this.data[x]+A.data[x],k.data[x++]=j&this.DM,j>>=this.DB;if(A.t<this.t){j+=A.s;while(x<this.t)j+=this.data[x],k.data[x++]=j&this.DM,j>>=this.DB;j+=this.s}else{j+=this.s;while(x<A.t)j+=A.data[x],k.data[x++]=j&this.DM,j>>=this.DB;j+=A.s}if(k.s=j<0?-1:0,j>0)k.data[x++]=j;else if(j<-1)k.data[x++]=this.DV+j;k.t=x,k.clamp()}function Me(A){var k=g();return this.addTo(A,k),k}function Fe(A){var k=g();return this.subTo(A,k),k}function je(A){var k=g();return this.multiplyTo(A,k),k}function Ge(A){var k=g();return this.divRemTo(A,k,null),k}function qe(A){var k=g();return this.divRemTo(A,null,k),k}function He(A){var k=g(),x=g();return this.divRemTo(A,k,x),new Array(k,x)}function Qe(A){this.data[this.t]=this.am(0,A-1,this,0,0,this.t),++this.t,this.clamp()}function ze(A,k){if(A==0)return;while(this.t<=k)this.data[this.t++]=0;this.data[k]+=A;while(this.data[k]>=this.DV){if(this.data[k]-=this.DV,++k>=this.t)this.data[this.t++]=0;++this.data[k]}}function Ne(){}function Re(A){return A}function di(A,k,x){A.multiplyTo(k,x)}function yi(A,k){A.squareTo(k)}Ne.prototype.convert=Re,Ne.prototype.revert=Re,Ne.prototype.mulTo=di,Ne.prototype.sqrTo=yi;function gi(A){return this.exp(A,new Ne)}function vi(A,k,x){var j=Math.min(this.t+A.t,k);x.s=0,x.t=j;while(j>0)x.data[--j]=0;var z;for(z=x.t-this.t;j<z;++j)x.data[j+this.t]=this.am(0,A.data[j],x,j,0,this.t);for(z=Math.min(A.t,k);j<z;++j)this.am(0,A.data[j],x,j,0,k-j);x.clamp()}function mi(A,k,x){--k;var j=x.t=this.t+A.t-k;x.s=0;while(--j>=0)x.data[j]=0;for(j=Math.max(k-this.t,0);j<A.t;++j)x.data[this.t+j-k]=this.am(k-j,A.data[j],x,0,0,this.t+j-k);x.clamp(),x.drShiftTo(1,x)}function Bt(A){this.r2=g(),this.q3=g(),v.ONE.dlShiftTo(2*A.t,this.r2),this.mu=this.r2.divide(A),this.m=A}function Ci(A){if(A.s<0||A.t>2*this.m.t)return A.mod(this.m);else if(A.compareTo(this.m)<0)return A;else{var k=g();return A.copyTo(k),this.reduce(k),k}}function Ei(A){return A}function Si(A){if(A.drShiftTo(this.m.t-1,this.r2),A.t>this.m.t+1)A.t=this.m.t+1,A.clamp();this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(A.compareTo(this.r2)<0)A.dAddOffset(1,this.m.t+1);A.subTo(this.r2,A);while(A.compareTo(this.m)>=0)A.subTo(this.m,A)}function Ti(A,k){A.squareTo(k),this.reduce(k)}function Ii(A,k,x){A.multiplyTo(k,x),this.reduce(x)}Bt.prototype.convert=Ci,Bt.prototype.revert=Ei,Bt.prototype.reduce=Si,Bt.prototype.mulTo=Ii,Bt.prototype.sqrTo=Ti;function Ai(A,k){var x=A.bitLength(),j,z=p(1),W;if(x<=0)return z;else if(x<18)j=1;else if(x<48)j=3;else if(x<144)j=4;else if(x<768)j=5;else j=6;if(x<8)W=new se(k);else if(k.isEven())W=new Bt(k);else W=new Ae(k);var ne=new Array,re=3,Ee=j-1,Ye=(1<<j)-1;if(ne[1]=W.convert(this),j>1){var rt=g();W.sqrTo(ne[1],rt);while(re<=Ye)ne[re]=g(),W.mulTo(rt,ne[re-2],ne[re]),re+=2}var tt=A.t-1,pt,Gt=!0,nt=g(),st;x=B(A.data[tt])-1;while(tt>=0){if(x>=Ee)pt=A.data[tt]>>x-Ee&Ye;else if(pt=(A.data[tt]&(1<<x+1)-1)<<Ee-x,tt>0)pt|=A.data[tt-1]>>this.DB+x-Ee;re=j;while((pt&1)==0)pt>>=1,--re;if((x-=re)<0)x+=this.DB,--tt;if(Gt)ne[pt].copyTo(z),Gt=!1;else{while(re>1)W.sqrTo(z,nt),W.sqrTo(nt,z),re-=2;if(re>0)W.sqrTo(z,nt);else st=z,z=nt,nt=st;W.mulTo(nt,ne[pt],z)}while(tt>=0&&(A.data[tt]&1<<x)==0)if(W.sqrTo(z,nt),st=z,z=nt,nt=st,--x<0)x=this.DB-1,--tt}return W.revert(z)}function bi(A){var k=this.s<0?this.negate():this.clone(),x=A.s<0?A.negate():A.clone();if(k.compareTo(x)<0){var j=k;k=x,x=j}var z=k.getLowestSetBit(),W=x.getLowestSetBit();if(W<0)return k;if(z<W)W=z;if(W>0)k.rShiftTo(W,k),x.rShiftTo(W,x);while(k.signum()>0){if((z=k.getLowestSetBit())>0)k.rShiftTo(z,k);if((z=x.getLowestSetBit())>0)x.rShiftTo(z,x);if(k.compareTo(x)>=0)k.subTo(x,k),k.rShiftTo(1,k);else x.subTo(k,x),x.rShiftTo(1,x)}if(W>0)x.lShiftTo(W,x);return x}function Bi(A){if(A<=0)return 0;var k=this.DV%A,x=this.s<0?A-1:0;if(this.t>0)if(k==0)x=this.data[0]%A;else for(var j=this.t-1;j>=0;--j)x=(k*x+this.data[j])%A;return x}function Ni(A){var k=A.isEven();if(this.isEven()&&k||A.signum()==0)return v.ZERO;var x=A.clone(),j=this.clone(),z=p(1),W=p(0),ne=p(0),re=p(1);while(x.signum()!=0){while(x.isEven()){if(x.rShiftTo(1,x),k){if(!z.isEven()||!W.isEven())z.addTo(this,z),W.subTo(A,W);z.rShiftTo(1,z)}else if(!W.isEven())W.subTo(A,W);W.rShiftTo(1,W)}while(j.isEven()){if(j.rShiftTo(1,j),k){if(!ne.isEven()||!re.isEven())ne.addTo(this,ne),re.subTo(A,re);ne.rShiftTo(1,ne)}else if(!re.isEven())re.subTo(A,re);re.rShiftTo(1,re)}if(x.compareTo(j)>=0){if(x.subTo(j,x),k)z.subTo(ne,z);W.subTo(re,W)}else{if(j.subTo(x,j),k)ne.subTo(z,ne);re.subTo(W,re)}}if(j.compareTo(v.ONE)!=0)return v.ZERO;if(re.compareTo(A)>=0)return re.subtract(A);if(re.signum()<0)re.addTo(A,re);else return re;if(re.signum()<0)return re.add(A);else return re}var at=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],wi=67108864/at[at.length-1];function ki(A){var k,x=this.abs();if(x.t==1&&x.data[0]<=at[at.length-1]){for(k=0;k<at.length;++k)if(x.data[0]==at[k])return!0;return!1}if(x.isEven())return!1;k=1;while(k<at.length){var j=at[k],z=k+1;while(z<at.length&&j<wi)j*=at[z++];j=x.modInt(j);while(k<z)if(j%at[k++]==0)return!1}return x.millerRabin(A)}function Ri(A){var k=this.subtract(v.ONE),x=k.getLowestSetBit();if(x<=0)return!1;var j=k.shiftRight(x),z=_i(),W;for(var ne=0;ne<A;++ne){do W=new v(this.bitLength(),z);while(W.compareTo(v.ONE)<=0||W.compareTo(k)>=0);var re=W.modPow(j,this);if(re.compareTo(v.ONE)!=0&&re.compareTo(k)!=0){var Ee=1;while(Ee++<x&&re.compareTo(k)!=0)if(re=re.modPowInt(2,this),re.compareTo(v.ONE)==0)return!1;if(re.compareTo(k)!=0)return!1}}return!0}function _i(){return{nextBytes:function(A){for(var k=0;k<A.length;++k)A[k]=Math.floor(Math.random()*256)}}}v.prototype.chunkSize=ae,v.prototype.toRadix=ge,v.prototype.fromRadix=he,v.prototype.fromNumber=be,v.prototype.bitwiseTo=Te,v.prototype.changeBit=Ve,v.prototype.addTo=Oe,v.prototype.dMultiply=Qe,v.prototype.dAddOffset=ze,v.prototype.multiplyLowerTo=vi,v.prototype.multiplyUpperTo=mi,v.prototype.modInt=Bi,v.prototype.millerRabin=Ri,v.prototype.clone=Y,v.prototype.intValue=ie,v.prototype.byteValue=oe,v.prototype.shortValue=Q,v.prototype.signum=ue,v.prototype.toByteArray=ke,v.prototype.equals=we,v.prototype.min=Be,v.prototype.max=Se,v.prototype.and=We,v.prototype.or=Ze,v.prototype.xor=Je,v.prototype.andNot=it,v.prototype.not=ct,v.prototype.shiftLeft=ht,v.prototype.shiftRight=gt,v.prototype.getLowestSetBit=bt,v.prototype.bitCount=jt,v.prototype.testBit=Ue,v.prototype.setBit=Pe,v.prototype.clearBit=xe,v.prototype.flipBit=Ke,v.prototype.add=Me,v.prototype.subtract=Fe,v.prototype.multiply=je,v.prototype.divide=Ge,v.prototype.remainder=qe,v.prototype.divideAndRemainder=He,v.prototype.modPow=Ai,v.prototype.modInverse=Ni,v.prototype.pow=gi,v.prototype.gcd=bi,v.prototype.isProbablePrime=ki}),Mt=le((N,_)=>{var t=pe();yt(),Ce();var e=_.exports=t.sha1=t.sha1||{};t.md.sha1=t.md.algorithms.sha1=e,e.create=function(){if(!d)v();var u=null,r=t.util.createBuffer(),C=new Array(80),f={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return f.start=function(){f.messageLength=0,f.fullMessageLength=f.messageLength64=[];var I=f.messageLengthSize/4;for(var U=0;U<I;++U)f.fullMessageLength.push(0);return r=t.util.createBuffer(),u={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},f},f.start(),f.update=function(I,U){if(U==="utf8")I=t.util.encodeUtf8(I);var T=I.length;f.messageLength+=T,T=[T/4294967296>>>0,T>>>0];for(var c=f.fullMessageLength.length-1;c>=0;--c)f.fullMessageLength[c]+=T[1],T[1]=T[0]+(f.fullMessageLength[c]/4294967296>>>0),f.fullMessageLength[c]=f.fullMessageLength[c]>>>0,T[0]=T[1]/4294967296>>>0;if(r.putBytes(I),g(u,C,r),r.read>2048||r.length()===0)r.compact();return f},f.digest=function(){var I=t.util.createBuffer();I.putBytes(r.bytes());var U=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize,T=U&f.blockLength-1;I.putBytes(a.substr(0,f.blockLength-T));var c,m,S=f.fullMessageLength[0]*8;for(var E=0;E<f.fullMessageLength.length-1;++E)c=f.fullMessageLength[E+1]*8,m=c/4294967296>>>0,S+=m,I.putInt32(S>>>0),S=c>>>0;I.putInt32(S);var n={h0:u.h0,h1:u.h1,h2:u.h2,h3:u.h3,h4:u.h4};g(n,C,I);var p=t.util.createBuffer();return p.putInt32(n.h0),p.putInt32(n.h1),p.putInt32(n.h2),p.putInt32(n.h3),p.putInt32(n.h4),p},f};var a=null,d=!1;function v(){a=String.fromCharCode(128),a+=t.util.fillString(String.fromCharCode(0),64),d=!0}function g(u,r,C){var f,I,U,T,c,m,S,E,n=C.length();while(n>=64){I=u.h0,U=u.h1,T=u.h2,c=u.h3,m=u.h4;for(E=0;E<16;++E)f=C.getInt32(),r[E]=f,S=c^U&(T^c),f=(I<<5|I>>>27)+S+m+1518500249+f,m=c,c=T,T=(U<<30|U>>>2)>>>0,U=I,I=f;for(;E<20;++E)f=r[E-3]^r[E-8]^r[E-14]^r[E-16],f=f<<1|f>>>31,r[E]=f,S=c^U&(T^c),f=(I<<5|I>>>27)+S+m+1518500249+f,m=c,c=T,T=(U<<30|U>>>2)>>>0,U=I,I=f;for(;E<32;++E)f=r[E-3]^r[E-8]^r[E-14]^r[E-16],f=f<<1|f>>>31,r[E]=f,S=U^T^c,f=(I<<5|I>>>27)+S+m+1859775393+f,m=c,c=T,T=(U<<30|U>>>2)>>>0,U=I,I=f;for(;E<40;++E)f=r[E-6]^r[E-16]^r[E-28]^r[E-32],f=f<<2|f>>>30,r[E]=f,S=U^T^c,f=(I<<5|I>>>27)+S+m+1859775393+f,m=c,c=T,T=(U<<30|U>>>2)>>>0,U=I,I=f;for(;E<60;++E)f=r[E-6]^r[E-16]^r[E-28]^r[E-32],f=f<<2|f>>>30,r[E]=f,S=U&T|c&(U^T),f=(I<<5|I>>>27)+S+m+2400959708+f,m=c,c=T,T=(U<<30|U>>>2)>>>0,U=I,I=f;for(;E<80;++E)f=r[E-6]^r[E-16]^r[E-28]^r[E-32],f=f<<2|f>>>30,r[E]=f,S=U^T^c,f=(I<<5|I>>>27)+S+m+3395469782+f,m=c,c=T,T=(U<<30|U>>>2)>>>0,U=I,I=f;u.h0=u.h0+I|0,u.h1=u.h1+U|0,u.h2=u.h2+T|0,u.h3=u.h3+c|0,u.h4=u.h4+m|0,n-=64}}}),Gr=le((N,_)=>{var t=pe();Ce(),ot(),Mt();var e=_.exports=t.pkcs1=t.pkcs1||{};e.encode_rsa_oaep=function(d,v,g){var u,r,C,f;if(typeof g==="string")u=g,r=arguments[3]||void 0,C=arguments[4]||void 0;else if(g){if(u=g.label||void 0,r=g.seed||void 0,C=g.md||void 0,g.mgf1&&g.mgf1.md)f=g.mgf1.md}if(!C)C=t.md.sha1.create();else C.start();if(!f)f=C;var I=Math.ceil(d.n.bitLength()/8),U=I-2*C.digestLength-2;if(v.length>U){var T=new Error("RSAES-OAEP input message length is too long.");throw T.length=v.length,T.maxLength=U,T}if(!u)u="";C.update(u,"raw");var c=C.digest(),m="",S=U-v.length;for(var E=0;E<S;E++)m+="\x00";var n=c.getBytes()+m+"\x01"+v;if(!r)r=t.random.getBytes(C.digestLength);else if(r.length!==C.digestLength){var T=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw T.seedLength=r.length,T.digestLength=C.digestLength,T}var p=a(r,I-C.digestLength-1,f),y=t.util.xorBytes(n,p,n.length),b=a(y,C.digestLength,f),L=t.util.xorBytes(r,b,r.length);return"\x00"+L+y},e.decode_rsa_oaep=function(d,v,g){var u,r,C;if(typeof g==="string")u=g,r=arguments[3]||void 0;else if(g){if(u=g.label||void 0,r=g.md||void 0,g.mgf1&&g.mgf1.md)C=g.mgf1.md}var f=Math.ceil(d.n.bitLength()/8);if(v.length!==f){var y=new Error("RSAES-OAEP encoded message length is invalid.");throw y.length=v.length,y.expectedLength=f,y}if(r===void 0)r=t.md.sha1.create();else r.start();if(!C)C=r;if(f<2*r.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");if(!u)u="";r.update(u,"raw");var I=r.digest().getBytes(),U=v.charAt(0),T=v.substring(1,r.digestLength+1),c=v.substring(1+r.digestLength),m=a(c,r.digestLength,C),S=t.util.xorBytes(T,m,T.length),E=a(S,f-r.digestLength-1,C),n=t.util.xorBytes(c,E,c.length),p=n.substring(0,r.digestLength),y=U!=="\x00";for(var b=0;b<r.digestLength;++b)y|=I.charAt(b)!==p.charAt(b);var L=1,h=r.digestLength;for(var s=r.digestLength;s<n.length;s++){var i=n.charCodeAt(s),B=i&1^1,P=L?65534:0;y|=i&P,L=L&B,h+=L}if(y||n.charCodeAt(h)!==1)throw new Error("Invalid RSAES-OAEP padding.");return n.substring(h+1)};function a(d,v,g){if(!g)g=t.md.sha1.create();var u="",r=Math.ceil(v/g.digestLength);for(var C=0;C<r;++C){var f=String.fromCharCode(C>>24&255,C>>16&255,C>>8&255,C&255);g.start(),g.update(d+f),u+=g.digest().getBytes()}return u.substring(0,v)}}),qr=le((N,_)=>{var t=pe();Ce(),Xt(),ot(),function(){if(t.prime){_.exports=t.prime;return}var e=_.exports=t.prime=t.prime||{},a=t.jsbn.BigInteger,d=[6,4,2,4,2,4,6,2],v=new a(null);v.fromInt(30);var g=function(T,c){return T|c};e.generateProbablePrime=function(T,c,m){if(typeof c==="function")m=c,c={};c=c||{};var S=c.algorithm||"PRIMEINC";if(typeof S==="string")S={name:S};S.options=S.options||{};var E=c.prng||t.random,n={nextBytes:function(p){var y=E.getBytesSync(p.length);for(var b=0;b<p.length;++b)p[b]=y.charCodeAt(b)}};if(S.name==="PRIMEINC")return u(T,n,S.options,m);throw new Error("Invalid prime generation algorithm: "+S.name)};function u(T,c,m,S){if("workers"in m)return f(T,c,m,S);return r(T,c,m,S)}function r(T,c,m,S){var E=I(T,c),n=0,p=U(E.bitLength());if("millerRabinTests"in m)p=m.millerRabinTests;var y=10;if("maxBlockTime"in m)y=m.maxBlockTime;C(E,T,c,n,p,y,S)}function C(T,c,m,S,E,n,p){var y=+new Date;do{if(T.bitLength()>c)T=I(c,m);if(T.isProbablePrime(E))return p(null,T);T.dAddOffset(d[S++%8],0)}while(n<0||+new Date-y<n);t.util.setImmediate(function(){C(T,c,m,S,E,n,p)})}function f(T,c,m,S){if(typeof Worker==="undefined")return r(T,c,m,S);var E=I(T,c),n=m.workers,p=m.workLoad||100,y=p*30/8,b=m.workerScript||"forge/prime.worker.js";if(n===-1)return t.util.estimateCores(function(h,s){if(h)s=2;n=s-1,L()});L();function L(){n=Math.max(1,n);var h=[];for(var s=0;s<n;++s)h[s]=new Worker(b);var i=n;for(var s=0;s<n;++s)h[s].addEventListener("message",P);var B=!1;function P(O){if(B)return;--i;var V=O.data;if(V.found){for(var M=0;M<h.length;++M)h[M].terminate();return B=!0,S(null,new a(V.prime,16))}if(E.bitLength()>T)E=I(T,c);var G=E.toString(16);O.target.postMessage({hex:G,workLoad:p}),E.dAddOffset(y,0)}}}function I(T,c){var m=new a(T,c),S=T-1;if(!m.testBit(S))m.bitwiseTo(a.ONE.shiftLeft(S),g,m);return m.dAddOffset(31-m.mod(v).byteValue(),0),m}function U(T){if(T<=100)return 27;if(T<=150)return 18;if(T<=200)return 15;if(T<=250)return 12;if(T<=300)return 9;if(T<=350)return 8;if(T<=400)return 7;if(T<=500)return 6;if(T<=600)return 5;if(T<=800)return 4;if(T<=1250)return 3;return 2}}()}),Wt=le((N,_)=>{var t=pe();if(ut(),Xt(),It(),Gr(),qr(),ot(),Ce(),typeof e==="undefined")e=t.jsbn.BigInteger;var e,a=t.util.isNodejs?zt("crypto"):null,d=t.asn1,v=t.util;t.pki=t.pki||{},_.exports=t.pki.rsa=t.rsa=t.rsa||{};var g=t.pki,u=[6,4,2,4,2,4,6,2],r={name:"PrivateKeyInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},C={name:"RSAPrivateKey",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},f={name:"RSAPublicKey",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},I=t.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},U={name:"DigestInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:d.Class.UNIVERSAL,type:d.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:d.Class.UNIVERSAL,type:d.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},T=function(s){var i;if(s.algorithm in g.oids)i=g.oids[s.algorithm];else{var B=new Error("Unknown message digest algorithm.");throw B.algorithm=s.algorithm,B}var P=d.oidToDer(i).getBytes(),O=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),V=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);V.value.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,P)),V.value.push(d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,""));var M=d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,s.digest().getBytes());return O.value.push(V),O.value.push(M),d.toDer(O).getBytes()},c=function(s,i,B){if(B)return s.modPow(i.e,i.n);if(!i.p||!i.q)return s.modPow(i.d,i.n);if(!i.dP)i.dP=i.d.mod(i.p.subtract(e.ONE));if(!i.dQ)i.dQ=i.d.mod(i.q.subtract(e.ONE));if(!i.qInv)i.qInv=i.q.modInverse(i.p);var P;do P=new e(t.util.bytesToHex(t.random.getBytes(i.n.bitLength()/8)),16);while(P.compareTo(i.n)>=0||!P.gcd(i.n).equals(e.ONE));s=s.multiply(P.modPow(i.e,i.n)).mod(i.n);var O=s.mod(i.p).modPow(i.dP,i.p),V=s.mod(i.q).modPow(i.dQ,i.q);while(O.compareTo(V)<0)O=O.add(i.p);var M=O.subtract(V).multiply(i.qInv).mod(i.p).multiply(i.q).add(V);return M=M.multiply(P.modInverse(i.n)).mod(i.n),M};g.rsa.encrypt=function(s,i,B){var P=B,O,V=Math.ceil(i.n.bitLength()/8);if(B!==!1&&B!==!0)P=B===2,O=m(s,i,B);else O=t.util.createBuffer(),O.putBytes(s);var M=new e(O.toHex(),16),G=c(M,i,P),q=G.toString(16),H=t.util.createBuffer(),X=V-Math.ceil(q.length/2);while(X>0)H.putByte(0),--X;return H.putBytes(t.util.hexToBytes(q)),H.getBytes()},g.rsa.decrypt=function(s,i,B,P){var O=Math.ceil(i.n.bitLength()/8);if(s.length!==O){var V=new Error("Encrypted message length is invalid.");throw V.length=s.length,V.expected=O,V}var M=new e(t.util.createBuffer(s).toHex(),16);if(M.compareTo(i.n)>=0)throw new Error("Encrypted message is invalid.");var G=c(M,i,B),q=G.toString(16),H=t.util.createBuffer(),X=O-Math.ceil(q.length/2);while(X>0)H.putByte(0),--X;if(H.putBytes(t.util.hexToBytes(q)),P!==!1)return S(H.getBytes(),i,B);return H.getBytes()},g.rsa.createKeyPairGenerationState=function(s,i,B){if(typeof s==="string")s=parseInt(s,10);s=s||2048,B=B||{};var P=B.prng||t.random,O={nextBytes:function(G){var q=P.getBytesSync(G.length);for(var H=0;H<G.length;++H)G[H]=q.charCodeAt(H)}},V=B.algorithm||"PRIMEINC",M;if(V==="PRIMEINC")M={algorithm:V,state:0,bits:s,rng:O,eInt:i||65537,e:new e(null),p:null,q:null,qBits:s>>1,pBits:s-(s>>1),pqState:0,num:null,keys:null},M.e.fromInt(M.eInt);else throw new Error("Invalid key generation algorithm: "+V);return M},g.rsa.stepKeyPairGenerationState=function(s,i){if(!("algorithm"in s))s.algorithm="PRIMEINC";var B=new e(null);B.fromInt(30);var P=0,O=function(J,te){return J|te},V=+new Date,M,G=0;while(s.keys===null&&(i<=0||G<i)){if(s.state===0){var q=s.p===null?s.pBits:s.qBits,H=q-1;if(s.pqState===0){if(s.num=new e(q,s.rng),!s.num.testBit(H))s.num.bitwiseTo(e.ONE.shiftLeft(H),O,s.num);s.num.dAddOffset(31-s.num.mod(B).byteValue(),0),P=0,++s.pqState}else if(s.pqState===1)if(s.num.bitLength()>q)s.pqState=0;else if(s.num.isProbablePrime(p(s.num.bitLength())))++s.pqState;else s.num.dAddOffset(u[P++%8],0);else if(s.pqState===2)s.pqState=s.num.subtract(e.ONE).gcd(s.e).compareTo(e.ONE)===0?3:0;else if(s.pqState===3){if(s.pqState=0,s.p===null)s.p=s.num;else s.q=s.num;if(s.p!==null&&s.q!==null)++s.state;s.num=null}}else if(s.state===1){if(s.p.compareTo(s.q)<0)s.num=s.p,s.p=s.q,s.q=s.num;++s.state}else if(s.state===2)s.p1=s.p.subtract(e.ONE),s.q1=s.q.subtract(e.ONE),s.phi=s.p1.multiply(s.q1),++s.state;else if(s.state===3)if(s.phi.gcd(s.e).compareTo(e.ONE)===0)++s.state;else s.p=null,s.q=null,s.state=0;else if(s.state===4)if(s.n=s.p.multiply(s.q),s.n.bitLength()===s.bits)++s.state;else s.q=null,s.state=0;else if(s.state===5){var X=s.e.modInverse(s.phi);s.keys={privateKey:g.rsa.setPrivateKey(s.n,s.e,X,s.p,s.q,X.mod(s.p1),X.mod(s.q1),s.q.modInverse(s.p)),publicKey:g.rsa.setPublicKey(s.n,s.e)}}M=+new Date,G+=M-V,V=M}return s.keys!==null},g.rsa.generateKeyPair=function(s,i,B,P){if(arguments.length===1){if(typeof s==="object")B=s,s=void 0;else if(typeof s==="function")P=s,s=void 0}else if(arguments.length===2)if(typeof s==="number"){if(typeof i==="function")P=i,i=void 0;else if(typeof i!=="number")B=i,i=void 0}else B=s,P=i,s=void 0,i=void 0;else if(arguments.length===3)if(typeof i==="number"){if(typeof B==="function")P=B,B=void 0}else P=B,B=i,i=void 0;if(B=B||{},s===void 0)s=B.bits||2048;if(i===void 0)i=B.e||65537;if(!t.options.usePureJavaScript&&!B.prng&&s>=256&&s<=16384&&(i===65537||i===3)){if(P){if(y("generateKeyPair"))return a.generateKeyPair("rsa",{modulusLength:s,publicExponent:i,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(G,q,H){if(G)return P(G);P(null,{privateKey:g.privateKeyFromPem(H),publicKey:g.publicKeyFromPem(q)})});if(b("generateKey")&&b("exportKey"))return v.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:s,publicExponent:h(i),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(G){return v.globalScope.crypto.subtle.exportKey("pkcs8",G.privateKey)}).then(void 0,function(G){P(G)}).then(function(G){if(G){var q=g.privateKeyFromAsn1(d.fromDer(t.util.createBuffer(G)));P(null,{privateKey:q,publicKey:g.setRsaPublicKey(q.n,q.e)})}});if(L("generateKey")&&L("exportKey")){var O=v.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:s,publicExponent:h(i),hash:{name:"SHA-256"}},!0,["sign","verify"]);O.oncomplete=function(G){var q=G.target.result,H=v.globalScope.msCrypto.subtle.exportKey("pkcs8",q.privateKey);H.oncomplete=function(X){var J=X.target.result,te=g.privateKeyFromAsn1(d.fromDer(t.util.createBuffer(J)));P(null,{privateKey:te,publicKey:g.setRsaPublicKey(te.n,te.e)})},H.onerror=function(X){P(X)}},O.onerror=function(G){P(G)};return}}else if(y("generateKeyPairSync")){var V=a.generateKeyPairSync("rsa",{modulusLength:s,publicExponent:i,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:g.privateKeyFromPem(V.privateKey),publicKey:g.publicKeyFromPem(V.publicKey)}}}var M=g.rsa.createKeyPairGenerationState(s,i,B);if(!P)return g.rsa.stepKeyPairGenerationState(M,0),M.keys;E(M,B,P)},g.setRsaPublicKey=g.rsa.setPublicKey=function(s,i){var B={n:s,e:i};return B.encrypt=function(P,O,V){if(typeof O==="string")O=O.toUpperCase();else if(O===void 0)O="RSAES-PKCS1-V1_5";if(O==="RSAES-PKCS1-V1_5")O={encode:function(G,q,H){return m(G,q,2).getBytes()}};else if(O==="RSA-OAEP"||O==="RSAES-OAEP")O={encode:function(G,q){return t.pkcs1.encode_rsa_oaep(q,G,V)}};else if(["RAW","NONE","NULL",null].indexOf(O)!==-1)O={encode:function(G){return G}};else if(typeof O==="string")throw new Error('Unsupported encryption scheme: "'+O+'".');var M=O.encode(P,B,!0);return g.rsa.encrypt(M,B,!0)},B.verify=function(P,O,V,M){if(typeof V==="string")V=V.toUpperCase();else if(V===void 0)V="RSASSA-PKCS1-V1_5";if(M===void 0)M={_parseAllDigestBytes:!0};if(!("_parseAllDigestBytes"in M))M._parseAllDigestBytes=!0;if(V==="RSASSA-PKCS1-V1_5")V={verify:function(q,H){H=S(H,B,!0);var X=d.fromDer(H,{parseAllBytes:M._parseAllDigestBytes}),J={},te=[];if(!d.validate(X,U,J,te)){var se=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw se.errors=te,se}var fe=d.derToOid(J.algorithmIdentifier);if(!(fe===t.oids.md2||fe===t.oids.md5||fe===t.oids.sha1||fe===t.oids.sha224||fe===t.oids.sha256||fe===t.oids.sha384||fe===t.oids.sha512||fe===t.oids["sha512-224"]||fe===t.oids["sha512-256"])){var se=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw se.oid=fe,se}if(fe===t.oids.md2||fe===t.oids.md5){if(!("parameters"in J))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.")}return q===J.digest}};else if(V==="NONE"||V==="NULL"||V===null)V={verify:function(q,H){return H=S(H,B,!0),q===H}};var G=g.rsa.decrypt(O,B,!0,!1);return V.verify(P,G,B.n.bitLength())},B},g.setRsaPrivateKey=g.rsa.setPrivateKey=function(s,i,B,P,O,V,M,G){var q={n:s,e:i,d:B,p:P,q:O,dP:V,dQ:M,qInv:G};return q.decrypt=function(H,X,J){if(typeof X==="string")X=X.toUpperCase();else if(X===void 0)X="RSAES-PKCS1-V1_5";var te=g.rsa.decrypt(H,q,!1,!1);if(X==="RSAES-PKCS1-V1_5")X={decode:S};else if(X==="RSA-OAEP"||X==="RSAES-OAEP")X={decode:function(se,fe){return t.pkcs1.decode_rsa_oaep(fe,se,J)}};else if(["RAW","NONE","NULL",null].indexOf(X)!==-1)X={decode:function(se){return se}};else throw new Error('Unsupported encryption scheme: "'+X+'".');return X.decode(te,q,!1)},q.sign=function(H,X){var J=!1;if(typeof X==="string")X=X.toUpperCase();if(X===void 0||X==="RSASSA-PKCS1-V1_5")X={encode:T},J=1;else if(X==="NONE"||X==="NULL"||X===null)X={encode:function(){return H}},J=1;var te=X.encode(H,q.n.bitLength());return g.rsa.encrypt(te,q,J)},q},g.wrapRsaPrivateKey=function(s){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(0).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(g.oids.rsaEncryption).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")]),d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,d.toDer(s).getBytes())])},g.privateKeyFromAsn1=function(s){var i={},B=[];if(d.validate(s,r,i,B))s=d.fromDer(t.util.createBuffer(i.privateKey));if(i={},B=[],!d.validate(s,C,i,B)){var P=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw P.errors=B,P}var O,V,M,G,q,H,X,J;return O=t.util.createBuffer(i.privateKeyModulus).toHex(),V=t.util.createBuffer(i.privateKeyPublicExponent).toHex(),M=t.util.createBuffer(i.privateKeyPrivateExponent).toHex(),G=t.util.createBuffer(i.privateKeyPrime1).toHex(),q=t.util.createBuffer(i.privateKeyPrime2).toHex(),H=t.util.createBuffer(i.privateKeyExponent1).toHex(),X=t.util.createBuffer(i.privateKeyExponent2).toHex(),J=t.util.createBuffer(i.privateKeyCoefficient).toHex(),g.setRsaPrivateKey(new e(O,16),new e(V,16),new e(M,16),new e(G,16),new e(q,16),new e(H,16),new e(X,16),new e(J,16))},g.privateKeyToAsn1=g.privateKeyToRSAPrivateKey=function(s){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(0).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,n(s.n)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,n(s.e)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,n(s.d)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,n(s.p)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,n(s.q)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,n(s.dP)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,n(s.dQ)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,n(s.qInv))])},g.publicKeyFromAsn1=function(s){var i={},B=[];if(d.validate(s,I,i,B)){var P=d.derToOid(i.publicKeyOid);if(P!==g.oids.rsaEncryption){var O=new Error("Cannot read public key. Unknown OID.");throw O.oid=P,O}s=i.rsaPublicKey}if(B=[],!d.validate(s,f,i,B)){var O=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw O.errors=B,O}var V=t.util.createBuffer(i.publicKeyModulus).toHex(),M=t.util.createBuffer(i.publicKeyExponent).toHex();return g.setRsaPublicKey(new e(V,16),new e(M,16))},g.publicKeyToAsn1=g.publicKeyToSubjectPublicKeyInfo=function(s){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(g.oids.rsaEncryption).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")]),d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,[g.publicKeyToRSAPublicKey(s)])])},g.publicKeyToRSAPublicKey=function(s){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,n(s.n)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,n(s.e))])};function m(s,i,B){var P=t.util.createBuffer(),O=Math.ceil(i.n.bitLength()/8);if(s.length>O-11){var V=new Error("Message is too long for PKCS#1 v1.5 padding.");throw V.length=s.length,V.max=O-11,V}P.putByte(0),P.putByte(B);var M=O-3-s.length,G;if(B===0||B===1){G=B===0?0:255;for(var q=0;q<M;++q)P.putByte(G)}else while(M>0){var H=0,X=t.random.getBytes(M);for(var q=0;q<M;++q)if(G=X.charCodeAt(q),G===0)++H;else P.putByte(G);M=H}return P.putByte(0),P.putBytes(s),P}function S(s,i,B,P){var O=Math.ceil(i.n.bitLength()/8),V=t.util.createBuffer(s),M=V.getByte(),G=V.getByte();if(M!==0||B&&G!==0&&G!==1||!B&&G!=2||B&&G===0&&typeof P==="undefined")throw new Error("Encryption block is invalid.");var q=0;if(G===0){q=O-3-P;for(var H=0;H<q;++H)if(V.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(G===1){q=0;while(V.length()>1){if(V.getByte()!==255){--V.read;break}++q}}else if(G===2){q=0;while(V.length()>1){if(V.getByte()===0){--V.read;break}++q}}var X=V.getByte();if(X!==0||q!==O-3-V.length())throw new Error("Encryption block is invalid.");return V.getBytes()}function E(s,i,B){if(typeof i==="function")B=i,i={};i=i||{};var P={algorithm:{name:i.algorithm||"PRIMEINC",options:{workers:i.workers||2,workLoad:i.workLoad||100,workerScript:i.workerScript}}};if("prng"in i)P.prng=i.prng;O();function O(){V(s.pBits,function(G,q){if(G)return B(G);if(s.p=q,s.q!==null)return M(G,s.q);V(s.qBits,M)})}function V(G,q){t.prime.generateProbablePrime(G,P,q)}function M(G,q){if(G)return B(G);if(s.q=q,s.p.compareTo(s.q)<0){var H=s.p;s.p=s.q,s.q=H}if(s.p.subtract(e.ONE).gcd(s.e).compareTo(e.ONE)!==0){s.p=null,O();return}if(s.q.subtract(e.ONE).gcd(s.e).compareTo(e.ONE)!==0){s.q=null,V(s.qBits,M);return}if(s.p1=s.p.subtract(e.ONE),s.q1=s.q.subtract(e.ONE),s.phi=s.p1.multiply(s.q1),s.phi.gcd(s.e).compareTo(e.ONE)!==0){s.p=s.q=null,O();return}if(s.n=s.p.multiply(s.q),s.n.bitLength()!==s.bits){s.q=null,V(s.qBits,M);return}var X=s.e.modInverse(s.phi);s.keys={privateKey:g.rsa.setPrivateKey(s.n,s.e,X,s.p,s.q,X.mod(s.p1),X.mod(s.q1),s.q.modInverse(s.p)),publicKey:g.rsa.setPublicKey(s.n,s.e)},B(null,s.keys)}}function n(s){var i=s.toString(16);if(i[0]>="8")i="00"+i;var B=t.util.hexToBytes(i);if(B.length>1&&(B.charCodeAt(0)===0&&(B.charCodeAt(1)&128)===0||B.charCodeAt(0)===255&&(B.charCodeAt(1)&128)===128))return B.substr(1);return B}function p(s){if(s<=100)return 27;if(s<=150)return 18;if(s<=200)return 15;if(s<=250)return 12;if(s<=300)return 9;if(s<=350)return 8;if(s<=400)return 7;if(s<=500)return 6;if(s<=600)return 5;if(s<=800)return 4;if(s<=1250)return 3;return 2}function y(s){return t.util.isNodejs&&typeof a[s]==="function"}function b(s){return typeof v.globalScope!=="undefined"&&typeof v.globalScope.crypto==="object"&&typeof v.globalScope.crypto.subtle==="object"&&typeof v.globalScope.crypto.subtle[s]==="function"}function L(s){return typeof v.globalScope!=="undefined"&&typeof v.globalScope.msCrypto==="object"&&typeof v.globalScope.msCrypto.subtle==="object"&&typeof v.globalScope.msCrypto.subtle[s]==="function"}function h(s){var i=t.util.hexToBytes(s.toString(16)),B=new Uint8Array(i.length);for(var P=0;P<i.length;++P)B[P]=i.charCodeAt(P);return B}}),Hr=le((N,_)=>{var t=pe();if(Tt(),ut(),Yt(),yt(),It(),fr(),Rt(),ot(),jr(),Wt(),Ce(),typeof e==="undefined")e=t.jsbn.BigInteger;var e,a=t.asn1,d=t.pki=t.pki||{};_.exports=d.pbe=t.pbe=t.pbe||{};var v=d.oids,g={name:"EncryptedPrivateKeyInfo",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},u={name:"PBES2Algorithms",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},r={name:"pkcs-12PbeParams",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"iterations"}]};d.encryptPrivateKeyInfo=function(T,c,m){m=m||{},m.saltSize=m.saltSize||8,m.count=m.count||2048,m.algorithm=m.algorithm||"aes128",m.prfAlgorithm=m.prfAlgorithm||"sha1";var S=t.random.getBytesSync(m.saltSize),E=m.count,n=a.integerToDer(E),p,y,b;if(m.algorithm.indexOf("aes")===0||m.algorithm==="des"){var L,h,s;switch(m.algorithm){case"aes128":p=16,L=16,h=v["aes128-CBC"],s=t.aes.createEncryptionCipher;break;case"aes192":p=24,L=16,h=v["aes192-CBC"],s=t.aes.createEncryptionCipher;break;case"aes256":p=32,L=16,h=v["aes256-CBC"],s=t.aes.createEncryptionCipher;break;case"des":p=8,L=8,h=v.desCBC,s=t.des.createEncryptionCipher;break;default:var i=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw i.algorithm=m.algorithm,i}var B="hmacWith"+m.prfAlgorithm.toUpperCase(),P=I(B),O=t.pkcs5.pbkdf2(c,S,E,p,P),V=t.random.getBytesSync(L),M=s(O);M.start(V),M.update(a.toDer(T)),M.finish(),b=M.output.getBytes();var G=U(S,n,p,B);y=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(v.pkcs5PBES2).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(v.pkcs5PBKDF2).getBytes()),G]),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(h).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,V)])])])}else if(m.algorithm==="3des"){p=24;var q=new t.util.ByteBuffer(S),O=d.pbe.generatePkcs12Key(c,q,1,E,p),V=d.pbe.generatePkcs12Key(c,q,2,E,p),M=t.des.createEncryptionCipher(O);M.start(V),M.update(a.toDer(T)),M.finish(),b=M.output.getBytes(),y=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(v["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,S),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,n.getBytes())])])}else{var i=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw i.algorithm=m.algorithm,i}var H=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[y,a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,b)]);return H},d.decryptPrivateKeyInfo=function(T,c){var m=null,S={},E=[];if(!a.validate(T,g,S,E)){var n=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw n.errors=E,n}var p=a.derToOid(S.encryptionOid),y=d.pbe.getCipher(p,S.encryptionParams,c),b=t.util.createBuffer(S.encryptedData);if(y.update(b),y.finish())m=a.fromDer(y.output);return m},d.encryptedPrivateKeyToPem=function(T,c){var m={type:"ENCRYPTED PRIVATE KEY",body:a.toDer(T).getBytes()};return t.pem.encode(m,{maxline:c})},d.encryptedPrivateKeyFromPem=function(T){var c=t.pem.decode(T)[0];if(c.type!=="ENCRYPTED PRIVATE KEY"){var m=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw m.headerType=c.type,m}if(c.procType&&c.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return a.fromDer(c.body)},d.encryptRsaPrivateKey=function(T,c,m){if(m=m||{},!m.legacy){var S=d.wrapRsaPrivateKey(d.privateKeyToAsn1(T));return S=d.encryptPrivateKeyInfo(S,c,m),d.encryptedPrivateKeyToPem(S)}var E,n,p,y;switch(m.algorithm){case"aes128":E="AES-128-CBC",p=16,n=t.random.getBytesSync(16),y=t.aes.createEncryptionCipher;break;case"aes192":E="AES-192-CBC",p=24,n=t.random.getBytesSync(16),y=t.aes.createEncryptionCipher;break;case"aes256":E="AES-256-CBC",p=32,n=t.random.getBytesSync(16),y=t.aes.createEncryptionCipher;break;case"3des":E="DES-EDE3-CBC",p=24,n=t.random.getBytesSync(8),y=t.des.createEncryptionCipher;break;case"des":E="DES-CBC",p=8,n=t.random.getBytesSync(8),y=t.des.createEncryptionCipher;break;default:var b=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+m.algorithm+'".');throw b.algorithm=m.algorithm,b}var L=t.pbe.opensslDeriveBytes(c,n.substr(0,8),p),h=y(L);h.start(n),h.update(a.toDer(d.privateKeyToAsn1(T))),h.finish();var s={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:E,parameters:t.util.bytesToHex(n).toUpperCase()},body:h.output.getBytes()};return t.pem.encode(s)},d.decryptRsaPrivateKey=function(T,c){var m=null,S=t.pem.decode(T)[0];if(S.type!=="ENCRYPTED PRIVATE KEY"&&S.type!=="PRIVATE KEY"&&S.type!=="RSA PRIVATE KEY"){var E=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw E.headerType=E,E}if(S.procType&&S.procType.type==="ENCRYPTED"){var n,p;switch(S.dekInfo.algorithm){case"DES-CBC":n=8,p=t.des.createDecryptionCipher;break;case"DES-EDE3-CBC":n=24,p=t.des.createDecryptionCipher;break;case"AES-128-CBC":n=16,p=t.aes.createDecryptionCipher;break;case"AES-192-CBC":n=24,p=t.aes.createDecryptionCipher;break;case"AES-256-CBC":n=32,p=t.aes.createDecryptionCipher;break;case"RC2-40-CBC":n=5,p=function(s){return t.rc2.createDecryptionCipher(s,40)};break;case"RC2-64-CBC":n=8,p=function(s){return t.rc2.createDecryptionCipher(s,64)};break;case"RC2-128-CBC":n=16,p=function(s){return t.rc2.createDecryptionCipher(s,128)};break;default:var E=new Error('Could not decrypt private key; unsupported encryption algorithm "'+S.dekInfo.algorithm+'".');throw E.algorithm=S.dekInfo.algorithm,E}var y=t.util.hexToBytes(S.dekInfo.parameters),b=t.pbe.opensslDeriveBytes(c,y.substr(0,8),n),L=p(b);if(L.start(y),L.update(t.util.createBuffer(S.body)),L.finish())m=L.output.getBytes();else return m}else m=S.body;if(S.type==="ENCRYPTED PRIVATE KEY")m=d.decryptPrivateKeyInfo(a.fromDer(m),c);else m=a.fromDer(m);if(m!==null)m=d.privateKeyFromAsn1(m);return m},d.pbe.generatePkcs12Key=function(T,c,m,S,E,n){var p,y;if(typeof n==="undefined"||n===null){if(!("sha1"in t.md))throw new Error('"sha1" hash algorithm unavailable.');n=t.md.sha1.create()}var{digestLength:b,blockLength:L}=n,h=new t.util.ByteBuffer,s=new t.util.ByteBuffer;if(T!==null&&T!==void 0){for(y=0;y<T.length;y++)s.putInt16(T.charCodeAt(y));s.putInt16(0)}var i=s.length(),B=c.length(),P=new t.util.ByteBuffer;P.fillWithByte(m,L);var O=L*Math.ceil(B/L),V=new t.util.ByteBuffer;for(y=0;y<O;y++)V.putByte(c.at(y%B));var M=L*Math.ceil(i/L),G=new t.util.ByteBuffer;for(y=0;y<M;y++)G.putByte(s.at(y%i));var q=V;q.putBuffer(G);var H=Math.ceil(E/b);for(var X=1;X<=H;X++){var J=new t.util.ByteBuffer;J.putBytes(P.bytes()),J.putBytes(q.bytes());for(var te=0;te<S;te++)n.start(),n.update(J.getBytes()),J=n.digest();var se=new t.util.ByteBuffer;for(y=0;y<L;y++)se.putByte(J.at(y%b));var fe=Math.ceil(B/L)+Math.ceil(i/L),ve=new t.util.ByteBuffer;for(p=0;p<fe;p++){var Ie=new t.util.ByteBuffer(q.getBytes(L)),Z=511;for(y=se.length()-1;y>=0;y--)Z=Z>>8,Z+=se.at(y)+Ie.at(y),Ie.setAt(y,Z&255);ve.putBuffer(Ie)}q=ve,h.putBuffer(J)}return h.truncate(h.length()-E),h},d.pbe.getCipher=function(T,c,m){switch(T){case d.oids.pkcs5PBES2:return d.pbe.getCipherForPBES2(T,c,m);case d.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case d.oids["pbewithSHAAnd40BitRC2-CBC"]:return d.pbe.getCipherForPKCS12PBE(T,c,m);default:var S=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw S.oid=T,S.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],S}},d.pbe.getCipherForPBES2=function(T,c,m){var S={},E=[];if(!a.validate(c,u,S,E)){var n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw n.errors=E,n}if(T=a.derToOid(S.kdfOid),T!==d.oids.pkcs5PBKDF2){var n=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw n.oid=T,n.supportedOids=["pkcs5PBKDF2"],n}if(T=a.derToOid(S.encOid),T!==d.oids["aes128-CBC"]&&T!==d.oids["aes192-CBC"]&&T!==d.oids["aes256-CBC"]&&T!==d.oids["des-EDE3-CBC"]&&T!==d.oids.desCBC){var n=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw n.oid=T,n.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],n}var p=S.kdfSalt,y=t.util.createBuffer(S.kdfIterationCount);y=y.getInt(y.length()<<3);var b,L;switch(d.oids[T]){case"aes128-CBC":b=16,L=t.aes.createDecryptionCipher;break;case"aes192-CBC":b=24,L=t.aes.createDecryptionCipher;break;case"aes256-CBC":b=32,L=t.aes.createDecryptionCipher;break;case"des-EDE3-CBC":b=24,L=t.des.createDecryptionCipher;break;case"desCBC":b=8,L=t.des.createDecryptionCipher;break}var h=f(S.prfOid),s=t.pkcs5.pbkdf2(m,p,y,b,h),i=S.encIv,B=L(s);return B.start(i),B},d.pbe.getCipherForPKCS12PBE=function(T,c,m){var S={},E=[];if(!a.validate(c,r,S,E)){var n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw n.errors=E,n}var p=t.util.createBuffer(S.salt),y=t.util.createBuffer(S.iterations);y=y.getInt(y.length()<<3);var b,L,h;switch(T){case d.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:b=24,L=8,h=t.des.startDecrypting;break;case d.oids["pbewithSHAAnd40BitRC2-CBC"]:b=5,L=8,h=function(O,V){var M=t.rc2.createDecryptionCipher(O,40);return M.start(V,null),M};break;default:var n=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw n.oid=T,n}var s=f(S.prfOid),i=d.pbe.generatePkcs12Key(m,p,1,y,b,s);s.start();var B=d.pbe.generatePkcs12Key(m,p,2,y,L,s);return h(i,B)},d.pbe.opensslDeriveBytes=function(T,c,m,S){if(typeof S==="undefined"||S===null){if(!("md5"in t.md))throw new Error('"md5" hash algorithm unavailable.');S=t.md.md5.create()}if(c===null)c="";var E=[C(S,T+c)];for(var n=16,p=1;n<m;++p,n+=16)E.push(C(S,E[p-1]+T+c));return E.join("").substr(0,m)};function C(T,c){return T.start().update(c).digest().getBytes()}function f(T){var c;if(!T)c="hmacWithSHA1";else if(c=d.oids[a.derToOid(T)],!c){var m=new Error("Unsupported PRF OID.");throw m.oid=T,m.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],m}return I(c)}function I(T){var c=t.md;switch(T){case"hmacWithSHA224":c=t.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":T=T.substr(8).toLowerCase();break;default:var m=new Error("Unsupported PRF algorithm.");throw m.algorithm=T,m.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],m}if(!c||!(T in c))throw new Error("Unknown hash algorithm: "+T);return c[T].create()}function U(T,c,m,S){var E=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,T),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,c.getBytes())]);if(S!=="hmacWithSHA1")E.value.push(a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,t.util.hexToBytes(m.toString(16))),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(d.oids[S]).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.NULL,!1,"")]));return E}}),Qr=le((N,_)=>{var t=pe();ut(),Ce();var e=t.asn1,a=_.exports=t.pkcs7asn1=t.pkcs7asn1||{};t.pkcs7=t.pkcs7||{},t.pkcs7.asn1=a;var d={name:"ContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};a.contentInfoValidator=d;var v={name:"EncryptedContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};a.envelopedDataValidator={name:"EnvelopedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(v)},a.encryptedDataValidator={name:"EncryptedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"}].concat(v)};var g={name:"SignerInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};a.signedDataValidator={name:"SignedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},d,{name:"SignedData.Certificates",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,capture:"signerInfos",optional:!0,value:[g]}]},a.recipientInfoValidator={name:"RecipientInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}}),zr=le((N,_)=>{var t=pe();Ce(),t.mgf=t.mgf||{};var e=_.exports=t.mgf.mgf1=t.mgf1=t.mgf1||{};e.create=function(a){var d={generate:function(v,g){var u=new t.util.ByteBuffer,r=Math.ceil(g/a.digestLength);for(var C=0;C<r;C++){var f=new t.util.ByteBuffer;f.putInt32(C),a.start(),a.update(v+f.getBytes()),u.putBuffer(a.digest())}return u.truncate(u.length()-g),u.getBytes()}};return d}}),Mi=le((N,_)=>{var t=pe();zr(),_.exports=t.mgf=t.mgf||{},t.mgf.mgf1=t.mgf1}),hr=le((N,_)=>{var t=pe();ot(),Ce();var e=_.exports=t.pss=t.pss||{};e.create=function(a){if(arguments.length===3)a={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]};var{md:d,mgf:v}=a,g=d.digestLength,u=a.salt||null;if(typeof u==="string")u=t.util.createBuffer(u);var r;if("saltLength"in a)r=a.saltLength;else if(u!==null)r=u.length();else throw new Error("Salt length not specified or specific salt not given.");if(u!==null&&u.length()!==r)throw new Error("Given salt length does not match length of given salt.");var C=a.prng||t.random,f={};return f.encode=function(I,U){var T,c=U-1,m=Math.ceil(c/8),S=I.digest().getBytes();if(m<g+r+2)throw new Error("Message is too long to encrypt.");var E;if(u===null)E=C.getBytesSync(r);else E=u.bytes();var n=new t.util.ByteBuffer;n.fillWithByte(0,8),n.putBytes(S),n.putBytes(E),d.start(),d.update(n.getBytes());var p=d.digest().getBytes(),y=new t.util.ByteBuffer;y.fillWithByte(0,m-r-g-2),y.putByte(1),y.putBytes(E);var b=y.getBytes(),L=m-g-1,h=v.generate(p,L),s="";for(T=0;T<L;T++)s+=String.fromCharCode(b.charCodeAt(T)^h.charCodeAt(T));var i=65280>>8*m-c&255;return s=String.fromCharCode(s.charCodeAt(0)&~i)+s.substr(1),s+p+String.fromCharCode(188)},f.verify=function(I,U,T){var c,m=T-1,S=Math.ceil(m/8);if(U=U.substr(-S),S<g+r+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(U.charCodeAt(S-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var E=S-g-1,n=U.substr(0,E),p=U.substr(E,g),y=65280>>8*S-m&255;if((n.charCodeAt(0)&y)!==0)throw new Error("Bits beyond keysize not zero as expected.");var b=v.generate(p,E),L="";for(c=0;c<E;c++)L+=String.fromCharCode(n.charCodeAt(c)^b.charCodeAt(c));L=String.fromCharCode(L.charCodeAt(0)&~y)+L.substr(1);var h=S-g-r-2;for(c=0;c<h;c++)if(L.charCodeAt(c)!==0)throw new Error("Leftmost octets not zero as expected");if(L.charCodeAt(h)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var s=L.substr(-r),i=new t.util.ByteBuffer;i.fillWithByte(0,8),i.putBytes(I),i.putBytes(s),d.start(),d.update(i.getBytes());var B=d.digest().getBytes();return p===B},f}}),pr=le((N,_)=>{var t=pe();Tt(),ut(),Yt(),yt(),Mi(),It(),Rt(),hr(),Wt(),Ce();var e=t.asn1,a=_.exports=t.pki=t.pki||{},d=a.oids,v={};v.CN=d.commonName,v.commonName="CN",v.C=d.countryName,v.countryName="C",v.L=d.localityName,v.localityName="L",v.ST=d.stateOrProvinceName,v.stateOrProvinceName="ST",v.O=d.organizationName,v.organizationName="O",v.OU=d.organizationalUnitName,v.organizationalUnitName="OU",v.E=d.emailAddress,v.emailAddress="E";var g=t.pki.rsa.publicKeyValidator,u={name:"Certificate",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:e.Class.UNIVERSAL,type:e.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:e.Class.UNIVERSAL,type:e.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:e.Class.UNIVERSAL,type:e.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:e.Class.UNIVERSAL,type:e.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},g,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:e.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:e.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},r={name:"rsapss",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:e.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:e.Class.UNIVERSAL,type:e.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:e.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:e.Class.UNIVERSAL,type:e.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},C={name:"CertificationRequestInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},g,{name:"CertificationRequestInfo.attributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0}]}]}]},f={name:"CertificationRequest",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[C,{name:"CertificationRequest.signatureAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};a.RDNAttributesAsArray=function(h,s){var i=[],B,P,O;for(var V=0;V<h.value.length;++V){B=h.value[V];for(var M=0;M<B.value.length;++M){if(O={},P=B.value[M],O.type=e.derToOid(P.value[0].value),O.value=P.value[1].value,O.valueTagClass=P.value[1].type,O.type in d){if(O.name=d[O.type],O.name in v)O.shortName=v[O.name]}if(s)s.update(O.type),s.update(O.value);i.push(O)}}return i},a.CRIAttributesAsArray=function(h){var s=[];for(var i=0;i<h.length;++i){var B=h[i],P=e.derToOid(B.value[0].value),O=B.value[1].value;for(var V=0;V<O.length;++V){var M={};if(M.type=P,M.value=O[V].value,M.valueTagClass=O[V].type,M.type in d){if(M.name=d[M.type],M.name in v)M.shortName=v[M.name]}if(M.type===d.extensionRequest){M.extensions=[];for(var G=0;G<M.value.length;++G)M.extensions.push(a.certificateExtensionFromAsn1(M.value[G]))}s.push(M)}}return s};function I(h,s){if(typeof s==="string")s={shortName:s};var i=null,B;for(var P=0;i===null&&P<h.attributes.length;++P)if(B=h.attributes[P],s.type&&s.type===B.type)i=B;else if(s.name&&s.name===B.name)i=B;else if(s.shortName&&s.shortName===B.shortName)i=B;return i}var U=function(h,s,i){var B={};if(h!==d["RSASSA-PSS"])return B;if(i)B={hash:{algorithmOid:d.sha1},mgf:{algorithmOid:d.mgf1,hash:{algorithmOid:d.sha1}},saltLength:20};var P={},O=[];if(!e.validate(s,r,P,O)){var V=new Error("Cannot read RSASSA-PSS parameter block.");throw V.errors=O,V}if(P.hashOid!==void 0)B.hash=B.hash||{},B.hash.algorithmOid=e.derToOid(P.hashOid);if(P.maskGenOid!==void 0)B.mgf=B.mgf||{},B.mgf.algorithmOid=e.derToOid(P.maskGenOid),B.mgf.hash=B.mgf.hash||{},B.mgf.hash.algorithmOid=e.derToOid(P.maskGenHashOid);if(P.saltLength!==void 0)B.saltLength=P.saltLength.charCodeAt(0);return B},T=function(h){switch(d[h.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return t.md.sha1.create();case"md5WithRSAEncryption":return t.md.md5.create();case"sha256WithRSAEncryption":return t.md.sha256.create();case"sha384WithRSAEncryption":return t.md.sha384.create();case"sha512WithRSAEncryption":return t.md.sha512.create();case"RSASSA-PSS":return t.md.sha256.create();default:var s=new Error("Could not compute "+h.type+" digest. Unknown signature OID.");throw s.signatureOid=h.signatureOid,s}},c=function(h){var s=h.certificate,i;switch(s.signatureOid){case d.sha1WithRSAEncryption:case d.sha1WithRSASignature:break;case d["RSASSA-PSS"]:var B,P;if(B=d[s.signatureParameters.mgf.hash.algorithmOid],B===void 0||t.md[B]===void 0){var O=new Error("Unsupported MGF hash function.");throw O.oid=s.signatureParameters.mgf.hash.algorithmOid,O.name=B,O}if(P=d[s.signatureParameters.mgf.algorithmOid],P===void 0||t.mgf[P]===void 0){var O=new Error("Unsupported MGF function.");throw O.oid=s.signatureParameters.mgf.algorithmOid,O.name=P,O}if(P=t.mgf[P].create(t.md[B].create()),B=d[s.signatureParameters.hash.algorithmOid],B===void 0||t.md[B]===void 0){var O=new Error("Unsupported RSASSA-PSS hash function.");throw O.oid=s.signatureParameters.hash.algorithmOid,O.name=B,O}i=t.pss.create(t.md[B].create(),P,s.signatureParameters.saltLength);break}return s.publicKey.verify(h.md.digest().getBytes(),h.signature,i)};a.certificateFromPem=function(h,s,i){var B=t.pem.decode(h)[0];if(B.type!=="CERTIFICATE"&&B.type!=="X509 CERTIFICATE"&&B.type!=="TRUSTED CERTIFICATE"){var P=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw P.headerType=B.type,P}if(B.procType&&B.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var O=e.fromDer(B.body,i);return a.certificateFromAsn1(O,s)},a.certificateToPem=function(h,s){var i={type:"CERTIFICATE",body:e.toDer(a.certificateToAsn1(h)).getBytes()};return t.pem.encode(i,{maxline:s})},a.publicKeyFromPem=function(h){var s=t.pem.decode(h)[0];if(s.type!=="PUBLIC KEY"&&s.type!=="RSA PUBLIC KEY"){var i=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw i.headerType=s.type,i}if(s.procType&&s.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var B=e.fromDer(s.body);return a.publicKeyFromAsn1(B)},a.publicKeyToPem=function(h,s){var i={type:"PUBLIC KEY",body:e.toDer(a.publicKeyToAsn1(h)).getBytes()};return t.pem.encode(i,{maxline:s})},a.publicKeyToRSAPublicKeyPem=function(h,s){var i={type:"RSA PUBLIC KEY",body:e.toDer(a.publicKeyToRSAPublicKey(h)).getBytes()};return t.pem.encode(i,{maxline:s})},a.getPublicKeyFingerprint=function(h,s){s=s||{};var i=s.md||t.md.sha1.create(),B=s.type||"RSAPublicKey",P;switch(B){case"RSAPublicKey":P=e.toDer(a.publicKeyToRSAPublicKey(h)).getBytes();break;case"SubjectPublicKeyInfo":P=e.toDer(a.publicKeyToAsn1(h)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+s.type+'".')}i.start(),i.update(P);var O=i.digest();if(s.encoding==="hex"){var V=O.toHex();if(s.delimiter)return V.match(/.{2}/g).join(s.delimiter);return V}else if(s.encoding==="binary")return O.getBytes();else if(s.encoding)throw new Error('Unknown encoding "'+s.encoding+'".');return O},a.certificationRequestFromPem=function(h,s,i){var B=t.pem.decode(h)[0];if(B.type!=="CERTIFICATE REQUEST"){var P=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw P.headerType=B.type,P}if(B.procType&&B.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var O=e.fromDer(B.body,i);return a.certificationRequestFromAsn1(O,s)},a.certificationRequestToPem=function(h,s){var i={type:"CERTIFICATE REQUEST",body:e.toDer(a.certificationRequestToAsn1(h)).getBytes()};return t.pem.encode(i,{maxline:s})},a.createCertificate=function(){var h={};return h.version=2,h.serialNumber="00",h.signatureOid=null,h.signature=null,h.siginfo={},h.siginfo.algorithmOid=null,h.validity={},h.validity.notBefore=new Date,h.validity.notAfter=new Date,h.issuer={},h.issuer.getField=function(s){return I(h.issuer,s)},h.issuer.addField=function(s){S([s]),h.issuer.attributes.push(s)},h.issuer.attributes=[],h.issuer.hash=null,h.subject={},h.subject.getField=function(s){return I(h.subject,s)},h.subject.addField=function(s){S([s]),h.subject.attributes.push(s)},h.subject.attributes=[],h.subject.hash=null,h.extensions=[],h.publicKey=null,h.md=null,h.setSubject=function(s,i){if(S(s),h.subject.attributes=s,delete h.subject.uniqueId,i)h.subject.uniqueId=i;h.subject.hash=null},h.setIssuer=function(s,i){if(S(s),h.issuer.attributes=s,delete h.issuer.uniqueId,i)h.issuer.uniqueId=i;h.issuer.hash=null},h.setExtensions=function(s){for(var i=0;i<s.length;++i)E(s[i],{cert:h});h.extensions=s},h.getExtension=function(s){if(typeof s==="string")s={name:s};var i=null,B;for(var P=0;i===null&&P<h.extensions.length;++P)if(B=h.extensions[P],s.id&&B.id===s.id)i=B;else if(s.name&&B.name===s.name)i=B;return i},h.sign=function(s,i){h.md=i||t.md.sha1.create();var B=d[h.md.algorithm+"WithRSAEncryption"];if(!B){var P=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw P.algorithm=h.md.algorithm,P}h.signatureOid=h.siginfo.algorithmOid=B,h.tbsCertificate=a.getTBSCertificate(h);var O=e.toDer(h.tbsCertificate);h.md.update(O.getBytes()),h.signature=s.sign(h.md)},h.verify=function(s){var i=!1;if(!h.issued(s)){var B=s.issuer,P=h.subject,O=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw O.expectedIssuer=P.attributes,O.actualIssuer=B.attributes,O}var V=s.md;if(V===null){V=T({signatureOid:s.signatureOid,type:"certificate"});var M=s.tbsCertificate||a.getTBSCertificate(s),G=e.toDer(M);V.update(G.getBytes())}if(V!==null)i=c({certificate:h,md:V,signature:s.signature});return i},h.isIssuer=function(s){var i=!1,B=h.issuer,P=s.subject;if(B.hash&&P.hash)i=B.hash===P.hash;else if(B.attributes.length===P.attributes.length){i=!0;var O,V;for(var M=0;i&&M<B.attributes.length;++M)if(O=B.attributes[M],V=P.attributes[M],O.type!==V.type||O.value!==V.value)i=!1}return i},h.issued=function(s){return s.isIssuer(h)},h.generateSubjectKeyIdentifier=function(){return a.getPublicKeyFingerprint(h.publicKey,{type:"RSAPublicKey"})},h.verifySubjectKeyIdentifier=function(){var s=d.subjectKeyIdentifier;for(var i=0;i<h.extensions.length;++i){var B=h.extensions[i];if(B.id===s){var P=h.generateSubjectKeyIdentifier().getBytes();return t.util.hexToBytes(B.subjectKeyIdentifier)===P}}return!1},h},a.certificateFromAsn1=function(h,s){var i={},B=[];if(!e.validate(h,u,i,B)){var P=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw P.errors=B,P}var O=e.derToOid(i.publicKeyOid);if(O!==a.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var V=a.createCertificate();V.version=i.certVersion?i.certVersion.charCodeAt(0):0;var M=t.util.createBuffer(i.certSerialNumber);V.serialNumber=M.toHex(),V.signatureOid=t.asn1.derToOid(i.certSignatureOid),V.signatureParameters=U(V.signatureOid,i.certSignatureParams,!0),V.siginfo.algorithmOid=t.asn1.derToOid(i.certinfoSignatureOid),V.siginfo.parameters=U(V.siginfo.algorithmOid,i.certinfoSignatureParams,!1),V.signature=i.certSignature;var G=[];if(i.certValidity1UTCTime!==void 0)G.push(e.utcTimeToDate(i.certValidity1UTCTime));if(i.certValidity2GeneralizedTime!==void 0)G.push(e.generalizedTimeToDate(i.certValidity2GeneralizedTime));if(i.certValidity3UTCTime!==void 0)G.push(e.utcTimeToDate(i.certValidity3UTCTime));if(i.certValidity4GeneralizedTime!==void 0)G.push(e.generalizedTimeToDate(i.certValidity4GeneralizedTime));if(G.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(G.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(V.validity.notBefore=G[0],V.validity.notAfter=G[1],V.tbsCertificate=i.tbsCertificate,s){V.md=T({signatureOid:V.signatureOid,type:"certificate"});var q=e.toDer(V.tbsCertificate);V.md.update(q.getBytes())}var H=t.md.sha1.create(),X=e.toDer(i.certIssuer);if(H.update(X.getBytes()),V.issuer.getField=function(se){return I(V.issuer,se)},V.issuer.addField=function(se){S([se]),V.issuer.attributes.push(se)},V.issuer.attributes=a.RDNAttributesAsArray(i.certIssuer),i.certIssuerUniqueId)V.issuer.uniqueId=i.certIssuerUniqueId;V.issuer.hash=H.digest().toHex();var J=t.md.sha1.create(),te=e.toDer(i.certSubject);if(J.update(te.getBytes()),V.subject.getField=function(se){return I(V.subject,se)},V.subject.addField=function(se){S([se]),V.subject.attributes.push(se)},V.subject.attributes=a.RDNAttributesAsArray(i.certSubject),i.certSubjectUniqueId)V.subject.uniqueId=i.certSubjectUniqueId;if(V.subject.hash=J.digest().toHex(),i.certExtensions)V.extensions=a.certificateExtensionsFromAsn1(i.certExtensions);else V.extensions=[];return V.publicKey=a.publicKeyFromAsn1(i.subjectPublicKeyInfo),V},a.certificateExtensionsFromAsn1=function(h){var s=[];for(var i=0;i<h.value.length;++i){var B=h.value[i];for(var P=0;P<B.value.length;++P)s.push(a.certificateExtensionFromAsn1(B.value[P]))}return s},a.certificateExtensionFromAsn1=function(h){var s={};if(s.id=e.derToOid(h.value[0].value),s.critical=!1,h.value[1].type===e.Type.BOOLEAN)s.critical=h.value[1].value.charCodeAt(0)!==0,s.value=h.value[2].value;else s.value=h.value[1].value;if(s.id in d){if(s.name=d[s.id],s.name==="keyUsage"){var i=e.fromDer(s.value),B=0,P=0;if(i.value.length>1)B=i.value.charCodeAt(1),P=i.value.length>2?i.value.charCodeAt(2):0;s.digitalSignature=(B&128)===128,s.nonRepudiation=(B&64)===64,s.keyEncipherment=(B&32)===32,s.dataEncipherment=(B&16)===16,s.keyAgreement=(B&8)===8,s.keyCertSign=(B&4)===4,s.cRLSign=(B&2)===2,s.encipherOnly=(B&1)===1,s.decipherOnly=(P&128)===128}else if(s.name==="basicConstraints"){var i=e.fromDer(s.value);if(i.value.length>0&&i.value[0].type===e.Type.BOOLEAN)s.cA=i.value[0].value.charCodeAt(0)!==0;else s.cA=!1;var O=null;if(i.value.length>0&&i.value[0].type===e.Type.INTEGER)O=i.value[0].value;else if(i.value.length>1)O=i.value[1].value;if(O!==null)s.pathLenConstraint=e.derToInteger(O)}else if(s.name==="extKeyUsage"){var i=e.fromDer(s.value);for(var V=0;V<i.value.length;++V){var M=e.derToOid(i.value[V].value);if(M in d)s[d[M]]=!0;else s[M]=!0}}else if(s.name==="nsCertType"){var i=e.fromDer(s.value),B=0;if(i.value.length>1)B=i.value.charCodeAt(1);s.client=(B&128)===128,s.server=(B&64)===64,s.email=(B&32)===32,s.objsign=(B&16)===16,s.reserved=(B&8)===8,s.sslCA=(B&4)===4,s.emailCA=(B&2)===2,s.objCA=(B&1)===1}else if(s.name==="subjectAltName"||s.name==="issuerAltName"){s.altNames=[];var G,i=e.fromDer(s.value);for(var q=0;q<i.value.length;++q){G=i.value[q];var H={type:G.type,value:G.value};switch(s.altNames.push(H),G.type){case 1:case 2:case 6:break;case 7:H.ip=t.util.bytesToIP(G.value);break;case 8:H.oid=e.derToOid(G.value);break;default:}}}else if(s.name==="subjectKeyIdentifier"){var i=e.fromDer(s.value);s.subjectKeyIdentifier=t.util.bytesToHex(i.value)}}return s},a.certificationRequestFromAsn1=function(h,s){var i={},B=[];if(!e.validate(h,f,i,B)){var P=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw P.errors=B,P}var O=e.derToOid(i.publicKeyOid);if(O!==a.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var V=a.createCertificationRequest();if(V.version=i.csrVersion?i.csrVersion.charCodeAt(0):0,V.signatureOid=t.asn1.derToOid(i.csrSignatureOid),V.signatureParameters=U(V.signatureOid,i.csrSignatureParams,!0),V.siginfo.algorithmOid=t.asn1.derToOid(i.csrSignatureOid),V.siginfo.parameters=U(V.siginfo.algorithmOid,i.csrSignatureParams,!1),V.signature=i.csrSignature,V.certificationRequestInfo=i.certificationRequestInfo,s){V.md=T({signatureOid:V.signatureOid,type:"certification request"});var M=e.toDer(V.certificationRequestInfo);V.md.update(M.getBytes())}var G=t.md.sha1.create();return V.subject.getField=function(q){return I(V.subject,q)},V.subject.addField=function(q){S([q]),V.subject.attributes.push(q)},V.subject.attributes=a.RDNAttributesAsArray(i.certificationRequestInfoSubject,G),V.subject.hash=G.digest().toHex(),V.publicKey=a.publicKeyFromAsn1(i.subjectPublicKeyInfo),V.getAttribute=function(q){return I(V,q)},V.addAttribute=function(q){S([q]),V.attributes.push(q)},V.attributes=a.CRIAttributesAsArray(i.certificationRequestInfoAttributes||[]),V},a.createCertificationRequest=function(){var h={};return h.version=0,h.signatureOid=null,h.signature=null,h.siginfo={},h.siginfo.algorithmOid=null,h.subject={},h.subject.getField=function(s){return I(h.subject,s)},h.subject.addField=function(s){S([s]),h.subject.attributes.push(s)},h.subject.attributes=[],h.subject.hash=null,h.publicKey=null,h.attributes=[],h.getAttribute=function(s){return I(h,s)},h.addAttribute=function(s){S([s]),h.attributes.push(s)},h.md=null,h.setSubject=function(s){S(s),h.subject.attributes=s,h.subject.hash=null},h.setAttributes=function(s){S(s),h.attributes=s},h.sign=function(s,i){h.md=i||t.md.sha1.create();var B=d[h.md.algorithm+"WithRSAEncryption"];if(!B){var P=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw P.algorithm=h.md.algorithm,P}h.signatureOid=h.siginfo.algorithmOid=B,h.certificationRequestInfo=a.getCertificationRequestInfo(h);var O=e.toDer(h.certificationRequestInfo);h.md.update(O.getBytes()),h.signature=s.sign(h.md)},h.verify=function(){var s=!1,i=h.md;if(i===null){i=T({signatureOid:h.signatureOid,type:"certification request"});var B=h.certificationRequestInfo||a.getCertificationRequestInfo(h),P=e.toDer(B);i.update(P.getBytes())}if(i!==null)s=c({certificate:h,md:i,signature:h.signature});return s},h};function m(h){var s=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),i,B,P=h.attributes;for(var O=0;O<P.length;++O){i=P[O];var V=i.value,M=e.Type.PRINTABLESTRING;if("valueTagClass"in i){if(M=i.valueTagClass,M===e.Type.UTF8)V=t.util.encodeUtf8(V)}B=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(i.type).getBytes()),e.create(e.Class.UNIVERSAL,M,!1,V)])]),s.value.push(B)}return s}function S(h){var s;for(var i=0;i<h.length;++i){if(s=h[i],typeof s.name==="undefined"){if(s.type&&s.type in a.oids)s.name=a.oids[s.type];else if(s.shortName&&s.shortName in v)s.name=a.oids[v[s.shortName]]}if(typeof s.type==="undefined")if(s.name&&s.name in a.oids)s.type=a.oids[s.name];else{var B=new Error("Attribute type not specified.");throw B.attribute=s,B}if(typeof s.shortName==="undefined"){if(s.name&&s.name in v)s.shortName=v[s.name]}if(s.type===d.extensionRequest){if(s.valueConstructed=!0,s.valueTagClass=e.Type.SEQUENCE,!s.value&&s.extensions){s.value=[];for(var P=0;P<s.extensions.length;++P)s.value.push(a.certificateExtensionToAsn1(E(s.extensions[P])))}}if(typeof s.value==="undefined"){var B=new Error("Attribute value not specified.");throw B.attribute=s,B}}}function E(h,s){if(s=s||{},typeof h.name==="undefined"){if(h.id&&h.id in a.oids)h.name=a.oids[h.id]}if(typeof h.id==="undefined")if(h.name&&h.name in a.oids)h.id=a.oids[h.name];else{var i=new Error("Extension ID not specified.");throw i.extension=h,i}if(typeof h.value!=="undefined")return h;if(h.name==="keyUsage"){var B=0,P=0,O=0;if(h.digitalSignature)P|=128,B=7;if(h.nonRepudiation)P|=64,B=6;if(h.keyEncipherment)P|=32,B=5;if(h.dataEncipherment)P|=16,B=4;if(h.keyAgreement)P|=8,B=3;if(h.keyCertSign)P|=4,B=2;if(h.cRLSign)P|=2,B=1;if(h.encipherOnly)P|=1,B=0;if(h.decipherOnly)O|=128,B=7;var V=String.fromCharCode(B);if(O!==0)V+=String.fromCharCode(P)+String.fromCharCode(O);else if(P!==0)V+=String.fromCharCode(P);h.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,V)}else if(h.name==="basicConstraints"){if(h.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),h.cA)h.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,String.fromCharCode(255)));if("pathLenConstraint"in h)h.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(h.pathLenConstraint).getBytes()))}else if(h.name==="extKeyUsage"){h.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var M=h.value.value;for(var G in h){if(h[G]!==!0)continue;if(G in d)M.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(d[G]).getBytes()));else if(G.indexOf(".")!==-1)M.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(G).getBytes()))}}else if(h.name==="nsCertType"){var B=0,P=0;if(h.client)P|=128,B=7;if(h.server)P|=64,B=6;if(h.email)P|=32,B=5;if(h.objsign)P|=16,B=4;if(h.reserved)P|=8,B=3;if(h.sslCA)P|=4,B=2;if(h.emailCA)P|=2,B=1;if(h.objCA)P|=1,B=0;var V=String.fromCharCode(B);if(P!==0)V+=String.fromCharCode(P);h.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,V)}else if(h.name==="subjectAltName"||h.name==="issuerAltName"){h.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var q;for(var H=0;H<h.altNames.length;++H){q=h.altNames[H];var V=q.value;if(q.type===7&&q.ip){if(V=t.util.bytesFromIP(q.ip),V===null){var i=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw i.extension=h,i}}else if(q.type===8)if(q.oid)V=e.oidToDer(e.oidToDer(q.oid));else V=e.oidToDer(V);h.value.value.push(e.create(e.Class.CONTEXT_SPECIFIC,q.type,!1,V))}}else if(h.name==="nsComment"&&s.cert){if(!/^[\x00-\x7F]*$/.test(h.comment)||h.comment.length<1||h.comment.length>128)throw new Error('Invalid "nsComment" content.');h.value=e.create(e.Class.UNIVERSAL,e.Type.IA5STRING,!1,h.comment)}else if(h.name==="subjectKeyIdentifier"&&s.cert){var X=s.cert.generateSubjectKeyIdentifier();h.subjectKeyIdentifier=X.toHex(),h.value=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,X.getBytes())}else if(h.name==="authorityKeyIdentifier"&&s.cert){h.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var M=h.value.value;if(h.keyIdentifier){var J=h.keyIdentifier===!0?s.cert.generateSubjectKeyIdentifier().getBytes():h.keyIdentifier;M.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!1,J))}if(h.authorityCertIssuer){var te=[e.create(e.Class.CONTEXT_SPECIFIC,4,!0,[m(h.authorityCertIssuer===!0?s.cert.issuer:h.authorityCertIssuer)])];M.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,te))}if(h.serialNumber){var se=t.util.hexToBytes(h.serialNumber===!0?s.cert.serialNumber:h.serialNumber);M.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!1,se))}}else if(h.name==="cRLDistributionPoints"){h.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var M=h.value.value,fe=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),ve=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]),q;for(var H=0;H<h.altNames.length;++H){q=h.altNames[H];var V=q.value;if(q.type===7&&q.ip){if(V=t.util.bytesFromIP(q.ip),V===null){var i=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw i.extension=h,i}}else if(q.type===8)if(q.oid)V=e.oidToDer(e.oidToDer(q.oid));else V=e.oidToDer(V);ve.value.push(e.create(e.Class.CONTEXT_SPECIFIC,q.type,!1,V))}fe.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[ve])),M.push(fe)}if(typeof h.value==="undefined"){var i=new Error("Extension value not specified.");throw i.extension=h,i}return h}function n(h,s){switch(h){case d["RSASSA-PSS"]:var i=[];if(s.hash.algorithmOid!==void 0)i.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(s.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])]));if(s.mgf.algorithmOid!==void 0)i.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(s.mgf.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(s.mgf.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])])]));if(s.saltLength!==void 0)i.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(s.saltLength).getBytes())]));return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,i);default:return e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")}}function p(h){var s=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);if(h.attributes.length===0)return s;var i=h.attributes;for(var B=0;B<i.length;++B){var P=i[B],O=P.value,V=e.Type.UTF8;if("valueTagClass"in P)V=P.valueTagClass;if(V===e.Type.UTF8)O=t.util.encodeUtf8(O);var M=!1;if("valueConstructed"in P)M=P.valueConstructed;var G=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(P.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,V,M,O)])]);s.value.push(G)}return s}var y=new Date("1950-01-01T00:00:00Z"),b=new Date("2050-01-01T00:00:00Z");function L(h){if(h>=y&&h<b)return e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(h));else return e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(h))}a.getTBSCertificate=function(h){var s=L(h.validity.notBefore),i=L(h.validity.notAfter),B=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(h.version).getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(h.serialNumber)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.siginfo.algorithmOid).getBytes()),n(h.siginfo.algorithmOid,h.siginfo.parameters)]),m(h.issuer),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[s,i]),m(h.subject),a.publicKeyToAsn1(h.publicKey)]);if(h.issuer.uniqueId)B.value.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,String.fromCharCode(0)+h.issuer.uniqueId)]));if(h.subject.uniqueId)B.value.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,String.fromCharCode(0)+h.subject.uniqueId)]));if(h.extensions.length>0)B.value.push(a.certificateExtensionsToAsn1(h.extensions));return B},a.getCertificationRequestInfo=function(h){var s=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(h.version).getBytes()),m(h.subject),a.publicKeyToAsn1(h.publicKey),p(h)]);return s},a.distinguishedNameToAsn1=function(h){return m(h)},a.certificateToAsn1=function(h){var s=h.tbsCertificate||a.getTBSCertificate(h);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[s,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.signatureOid).getBytes()),n(h.signatureOid,h.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,String.fromCharCode(0)+h.signature)])},a.certificateExtensionsToAsn1=function(h){var s=e.create(e.Class.CONTEXT_SPECIFIC,3,!0,[]),i=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);s.value.push(i);for(var B=0;B<h.length;++B)i.value.push(a.certificateExtensionToAsn1(h[B]));return s},a.certificateExtensionToAsn1=function(h){var s=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);if(s.value.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.id).getBytes())),h.critical)s.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,String.fromCharCode(255)));var i=h.value;if(typeof h.value!=="string")i=e.toDer(i).getBytes();return s.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,i)),s},a.certificationRequestToAsn1=function(h){var s=h.certificationRequestInfo||a.getCertificationRequestInfo(h);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[s,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(h.signatureOid).getBytes()),n(h.signatureOid,h.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,String.fromCharCode(0)+h.signature)])},a.createCaStore=function(h){var s={certs:{}};s.getIssuer=function(V){var M=i(V.issuer);return M},s.addCertificate=function(V){if(typeof V==="string")V=t.pki.certificateFromPem(V);if(B(V.subject),!s.hasCertificate(V))if(V.subject.hash in s.certs){var M=s.certs[V.subject.hash];if(!t.util.isArray(M))M=[M];M.push(V),s.certs[V.subject.hash]=M}else s.certs[V.subject.hash]=V},s.hasCertificate=function(V){if(typeof V==="string")V=t.pki.certificateFromPem(V);var M=i(V.subject);if(!M)return!1;if(!t.util.isArray(M))M=[M];var G=e.toDer(a.certificateToAsn1(V)).getBytes();for(var q=0;q<M.length;++q){var H=e.toDer(a.certificateToAsn1(M[q])).getBytes();if(G===H)return!0}return!1},s.listAllCertificates=function(){var V=[];for(var M in s.certs)if(s.certs.hasOwnProperty(M)){var G=s.certs[M];if(!t.util.isArray(G))V.push(G);else for(var q=0;q<G.length;++q)V.push(G[q])}return V},s.removeCertificate=function(V){var M;if(typeof V==="string")V=t.pki.certificateFromPem(V);if(B(V.subject),!s.hasCertificate(V))return null;var G=i(V.subject);if(!t.util.isArray(G))return M=s.certs[V.subject.hash],delete s.certs[V.subject.hash],M;var q=e.toDer(a.certificateToAsn1(V)).getBytes();for(var H=0;H<G.length;++H){var X=e.toDer(a.certificateToAsn1(G[H])).getBytes();if(q===X)M=G[H],G.splice(H,1)}if(G.length===0)delete s.certs[V.subject.hash];return M};function i(V){return B(V),s.certs[V.hash]||null}function B(V){if(!V.hash){var M=t.md.sha1.create();V.attributes=a.RDNAttributesAsArray(m(V),M),V.hash=M.digest().toHex()}}if(h)for(var P=0;P<h.length;++P){var O=h[P];s.addCertificate(O)}return s},a.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},a.verifyCertificateChain=function(h,s,i){if(typeof i==="function")i={verify:i};i=i||{},s=s.slice(0);var B=s.slice(0),P=i.validityCheckDate;if(typeof P==="undefined")P=new Date;var O=!0,V=null,M=0;do{var G=s.shift(),q=null,H=!1;if(P){if(P<G.validity.notBefore||P>G.validity.notAfter)V={message:"Certificate is not valid yet or has expired.",error:a.certificateError.certificate_expired,notBefore:G.validity.notBefore,notAfter:G.validity.notAfter,now:P}}if(V===null){if(q=s[0]||h.getIssuer(G),q===null){if(G.isIssuer(G))H=!0,q=G}if(q){var X=q;if(!t.util.isArray(X))X=[X];var J=!1;while(!J&&X.length>0){q=X.shift();try{J=q.verify(G)}catch(Ae){}}if(!J)V={message:"Certificate signature is invalid.",error:a.certificateError.bad_certificate}}if(V===null&&(!q||H)&&!h.hasCertificate(G))V={message:"Certificate is not trusted.",error:a.certificateError.unknown_ca}}if(V===null&&q&&!G.isIssuer(q))V={message:"Certificate issuer is invalid.",error:a.certificateError.bad_certificate};if(V===null){var te={keyUsage:!0,basicConstraints:!0};for(var se=0;V===null&&se<G.extensions.length;++se){var fe=G.extensions[se];if(fe.critical&&!(fe.name in te))V={message:"Certificate has an unsupported critical extension.",error:a.certificateError.unsupported_certificate}}}if(V===null&&(!O||s.length===0&&(!q||H))){var ve=G.getExtension("basicConstraints"),Ie=G.getExtension("keyUsage");if(Ie!==null){if(!Ie.keyCertSign||ve===null)V={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:a.certificateError.bad_certificate}}if(V===null&&ve!==null&&!ve.cA)V={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:a.certificateError.bad_certificate};if(V===null&&Ie!==null&&"pathLenConstraint"in ve){var Z=M-1;if(Z>ve.pathLenConstraint)V={message:"Certificate basicConstraints pathLenConstraint violated.",error:a.certificateError.bad_certificate}}}var me=V===null?!0:V.error,ee=i.verify?i.verify(me,M,B):me;if(ee===!0)V=null;else{if(me===!0)V={message:"The application rejected the certificate.",error:a.certificateError.bad_certificate};if(ee||ee===0){if(typeof ee==="object"&&!t.util.isArray(ee)){if(ee.message)V.message=ee.message;if(ee.error)V.error=ee.error}else if(typeof ee==="string")V.error=ee}throw V}O=!1,++M}while(s.length>0);return!0}}),Yr=le((N,_)=>{var t=pe();ut(),Ot(),It(),Qr(),Hr(),ot(),Wt(),Mt(),Ce(),pr();var{asn1:e,pki:a}=t,d=_.exports=t.pkcs12=t.pkcs12||{},v={name:"ContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},g={name:"PFX",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},v,{name:"PFX.macData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:e.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},u={name:"SafeBag",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},r={name:"Attribute",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,capture:"values"}]},C={name:"CertBag",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:e.Class.UNIVERSAL,type:e.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function f(S,E,n,p){var y=[];for(var b=0;b<S.length;b++)for(var L=0;L<S[b].safeBags.length;L++){var h=S[b].safeBags[L];if(p!==void 0&&h.type!==p)continue;if(E===null){y.push(h);continue}if(h.attributes[E]!==void 0&&h.attributes[E].indexOf(n)>=0)y.push(h)}return y}d.pkcs12FromAsn1=function(S,E,n){if(typeof E==="string")n=E,E=!0;else if(E===void 0)E=!0;var p={},y=[];if(!e.validate(S,g,p,y)){var b=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw b.errors=b,b}var L={version:p.version.charCodeAt(0),safeContents:[],getBags:function(q){var H={},X;if("localKeyId"in q)X=q.localKeyId;else if("localKeyIdHex"in q)X=t.util.hexToBytes(q.localKeyIdHex);if(X===void 0&&!("friendlyName"in q)&&"bagType"in q)H[q.bagType]=f(L.safeContents,null,null,q.bagType);if(X!==void 0)H.localKeyId=f(L.safeContents,"localKeyId",X,q.bagType);if("friendlyName"in q)H.friendlyName=f(L.safeContents,"friendlyName",q.friendlyName,q.bagType);return H},getBagsByFriendlyName:function(q,H){return f(L.safeContents,"friendlyName",q,H)},getBagsByLocalKeyId:function(q,H){return f(L.safeContents,"localKeyId",q,H)}};if(p.version.charCodeAt(0)!==3){var b=new Error("PKCS#12 PFX of version other than 3 not supported.");throw b.version=p.version.charCodeAt(0),b}if(e.derToOid(p.contentType)!==a.oids.data){var b=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw b.oid=e.derToOid(p.contentType),b}var h=p.content.value[0];if(h.tagClass!==e.Class.UNIVERSAL||h.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(h=I(h),p.mac){var s=null,i=0,B=e.derToOid(p.macAlgorithm);switch(B){case a.oids.sha1:s=t.md.sha1.create(),i=20;break;case a.oids.sha256:s=t.md.sha256.create(),i=32;break;case a.oids.sha384:s=t.md.sha384.create(),i=48;break;case a.oids.sha512:s=t.md.sha512.create(),i=64;break;case a.oids.md5:s=t.md.md5.create(),i=16;break}if(s===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+B);var P=new t.util.ByteBuffer(p.macSalt),O="macIterations"in p?parseInt(t.util.bytesToHex(p.macIterations),16):1,V=d.generateKey(n,P,3,O,i,s),M=t.hmac.create();M.start(s,V),M.update(h.value);var G=M.getMac();if(G.getBytes()!==p.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return U(L,h.value,E,n),L};function I(S){if(S.composed||S.constructed){var E=t.util.createBuffer();for(var n=0;n<S.value.length;++n)E.putBytes(S.value[n].value);S.composed=S.constructed=!1,S.value=E.getBytes()}return S}function U(S,E,n,p){if(E=e.fromDer(E,n),E.tagClass!==e.Class.UNIVERSAL||E.type!==e.Type.SEQUENCE||E.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var y=0;y<E.value.length;y++){var b=E.value[y],L={},h=[];if(!e.validate(b,v,L,h)){var s=new Error("Cannot read ContentInfo.");throw s.errors=h,s}var i={encrypted:!1},B=null,P=L.content.value[0];switch(e.derToOid(L.contentType)){case a.oids.data:if(P.tagClass!==e.Class.UNIVERSAL||P.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");B=I(P).value;break;case a.oids.encryptedData:B=T(P,p),i.encrypted=!0;break;default:var s=new Error("Unsupported PKCS#12 contentType.");throw s.contentType=e.derToOid(L.contentType),s}i.safeBags=c(B,n,p),S.safeContents.push(i)}}function T(S,E){var n={},p=[];if(!e.validate(S,t.pkcs7.asn1.encryptedDataValidator,n,p)){var y=new Error("Cannot read EncryptedContentInfo.");throw y.errors=p,y}var b=e.derToOid(n.contentType);if(b!==a.oids.data){var y=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw y.oid=b,y}b=e.derToOid(n.encAlgorithm);var L=a.pbe.getCipher(b,n.encParameter,E),h=I(n.encryptedContentAsn1),s=t.util.createBuffer(h.value);if(L.update(s),!L.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return L.output.getBytes()}function c(S,E,n){if(!E&&S.length===0)return[];if(S=e.fromDer(S,E),S.tagClass!==e.Class.UNIVERSAL||S.type!==e.Type.SEQUENCE||S.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");var p=[];for(var y=0;y<S.value.length;y++){var b=S.value[y],L={},h=[];if(!e.validate(b,u,L,h)){var s=new Error("Cannot read SafeBag.");throw s.errors=h,s}var i={type:e.derToOid(L.bagId),attributes:m(L.bagAttributes)};p.push(i);var B,P,O=L.bagValue.value[0];switch(i.type){case a.oids.pkcs8ShroudedKeyBag:if(O=a.decryptPrivateKeyInfo(O,n),O===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case a.oids.keyBag:try{i.key=a.privateKeyFromAsn1(O)}catch(M){i.key=null,i.asn1=O}continue;case a.oids.certBag:B=C,P=function(){if(e.derToOid(L.certId)!==a.oids.x509Certificate){var M=new Error("Unsupported certificate type, only X.509 supported.");throw M.oid=e.derToOid(L.certId),M}var G=e.fromDer(L.cert,E);try{i.cert=a.certificateFromAsn1(G,!0)}catch(q){i.cert=null,i.asn1=G}};break;default:var s=new Error("Unsupported PKCS#12 SafeBag type.");throw s.oid=i.type,s}if(B!==void 0&&!e.validate(O,B,L,h)){var s=new Error("Cannot read PKCS#12 "+B.name);throw s.errors=h,s}P()}return p}function m(S){var E={};if(S!==void 0)for(var n=0;n<S.length;++n){var p={},y=[];if(!e.validate(S[n],r,p,y)){var b=new Error("Cannot read PKCS#12 BagAttribute.");throw b.errors=y,b}var L=e.derToOid(p.oid);if(a.oids[L]===void 0)continue;E[a.oids[L]]=[];for(var h=0;h<p.values.length;++h)E[a.oids[L]].push(p.values[h].value)}return E}d.toPkcs12Asn1=function(S,E,n,p){if(p=p||{},p.saltSize=p.saltSize||8,p.count=p.count||2048,p.algorithm=p.algorithm||p.encAlgorithm||"aes128",!("useMac"in p))p.useMac=!0;if(!("localKeyId"in p))p.localKeyId=null;if(!("generateLocalKeyId"in p))p.generateLocalKeyId=!0;var y=p.localKeyId,b;if(y!==null)y=t.util.hexToBytes(y);else if(p.generateLocalKeyId)if(E){var L=t.util.isArray(E)?E[0]:E;if(typeof L==="string")L=a.certificateFromPem(L);var h=t.md.sha1.create();h.update(e.toDer(a.certificateToAsn1(L)).getBytes()),y=h.digest().getBytes()}else y=t.random.getBytes(20);var s=[];if(y!==null)s.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.localKeyId).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,y)])]));if("friendlyName"in p)s.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.friendlyName).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.BMPSTRING,!1,p.friendlyName)])]));if(s.length>0)b=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,s);var i=[],B=[];if(E!==null)if(t.util.isArray(E))B=E;else B=[E];var P=[];for(var O=0;O<B.length;++O){if(E=B[O],typeof E==="string")E=a.certificateFromPem(E);var V=O===0?b:void 0,M=a.certificateToAsn1(E),G=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.certBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.x509Certificate).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(M).getBytes())])])]),V]);P.push(G)}if(P.length>0){var q=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,P),H=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(q).getBytes())])]);i.push(H)}var X=null;if(S!==null){var J=a.wrapRsaPrivateKey(a.privateKeyToAsn1(S));if(n===null)X=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.keyBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[J]),b]);else X=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.pkcs8ShroudedKeyBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[a.encryptPrivateKeyInfo(J,n,p)]),b]);var te=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[X]),se=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(te).getBytes())])]);i.push(se)}var fe=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,i),ve;if(p.useMac){var h=t.md.sha1.create(),Ie=new t.util.ByteBuffer(t.random.getBytes(p.saltSize)),Z=p.count,S=d.generateKey(n,Ie,3,Z,20),me=t.hmac.create();me.start(h,S),me.update(e.toDer(fe).getBytes());var ee=me.getMac();ve=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.sha1).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,ee.getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,Ie.getBytes()),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(Z).getBytes())])}return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(3).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(a.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(fe).getBytes())])]),ve])},d.generateKey=t.pbe.generatePkcs12Key}),Xr=le((N,_)=>{var t=pe();ut(),It(),Hr(),Rt(),fr(),Yr(),hr(),Wt(),Ce(),pr();var e=t.asn1,a=_.exports=t.pki=t.pki||{};a.pemToDer=function(d){var v=t.pem.decode(d)[0];if(v.procType&&v.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return t.util.createBuffer(v.body)},a.privateKeyFromPem=function(d){var v=t.pem.decode(d)[0];if(v.type!=="PRIVATE KEY"&&v.type!=="RSA PRIVATE KEY"){var g=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw g.headerType=v.type,g}if(v.procType&&v.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var u=e.fromDer(v.body);return a.privateKeyFromAsn1(u)},a.privateKeyToPem=function(d,v){var g={type:"RSA PRIVATE KEY",body:e.toDer(a.privateKeyToAsn1(d)).getBytes()};return t.pem.encode(g,{maxline:v})},a.privateKeyInfoToPem=function(d,v){var g={type:"PRIVATE KEY",body:e.toDer(d).getBytes()};return t.pem.encode(g,{maxline:v})}}),Wr=le((N,_)=>{var t=pe();ut(),Ot(),lr(),Rt(),Xr(),ot(),Mt(),Ce();var e=function(l,D,R,o){var w=t.util.createBuffer(),F=l.length>>1,K=F+(l.length&1),Y=l.substr(0,K),ie=l.substr(F,K),oe=t.util.createBuffer(),Q=t.hmac.create();R=D+R;var ae=Math.ceil(o/16),ue=Math.ceil(o/20);Q.start("MD5",Y);var ge=t.util.createBuffer();oe.putBytes(R);for(var he=0;he<ae;++he)Q.start(null,null),Q.update(oe.getBytes()),oe.putBuffer(Q.digest()),Q.start(null,null),Q.update(oe.bytes()+R),ge.putBuffer(Q.digest());Q.start("SHA1",ie);var be=t.util.createBuffer();oe.clear(),oe.putBytes(R);for(var he=0;he<ue;++he)Q.start(null,null),Q.update(oe.getBytes()),oe.putBuffer(Q.digest()),Q.start(null,null),Q.update(oe.bytes()+R),be.putBuffer(Q.digest());return w.putBytes(t.util.xorBytes(ge.getBytes(),be.getBytes(),o)),w},a=function(l,D,R){var o=t.hmac.create();o.start("SHA1",l);var w=t.util.createBuffer();return w.putInt32(D[0]),w.putInt32(D[1]),w.putByte(R.type),w.putByte(R.version.major),w.putByte(R.version.minor),w.putInt16(R.length),w.putBytes(R.fragment.bytes()),o.update(w.getBytes()),o.digest().getBytes()},d=function(l,D,R){var o=!1;try{var w=l.deflate(D.fragment.getBytes());D.fragment=t.util.createBuffer(w),D.length=w.length,o=!0}catch(F){}return o},v=function(l,D,R){var o=!1;try{var w=l.inflate(D.fragment.getBytes());D.fragment=t.util.createBuffer(w),D.length=w.length,o=!0}catch(F){}return o},g=function(l,D){var R=0;switch(D){case 1:R=l.getByte();break;case 2:R=l.getInt16();break;case 3:R=l.getInt24();break;case 4:R=l.getInt32();break}return t.util.createBuffer(l.getBytes(R))},u=function(l,D,R){l.putInt(R.length(),D<<3),l.putBuffer(R)},r={};r.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}},r.SupportedVersions=[r.Versions.TLS_1_1,r.Versions.TLS_1_0],r.Version=r.SupportedVersions[0],r.MaxFragment=15360,r.ConnectionEnd={server:0,client:1},r.PRFAlgorithm={tls_prf_sha256:0},r.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},r.CipherType={stream:0,block:1,aead:2},r.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},r.CompressionMethod={none:0,deflate:1},r.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},r.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},r.Alert={},r.Alert.Level={warning:1,fatal:2},r.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},r.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},r.CipherSuites={},r.getCipherSuite=function(l){var D=null;for(var R in r.CipherSuites){var o=r.CipherSuites[R];if(o.id[0]===l.charCodeAt(0)&&o.id[1]===l.charCodeAt(1)){D=o;break}}return D},r.handleUnexpected=function(l,D){var R=!l.open&&l.entity===r.ConnectionEnd.client;if(!R)l.error(l,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.unexpected_message}})},r.handleHelloRequest=function(l,D,R){if(!l.handshaking&&l.handshakes>0)r.queue(l,r.createAlert(l,{level:r.Alert.Level.warning,description:r.Alert.Description.no_renegotiation})),r.flush(l);l.process()},r.parseHelloMessage=function(l,D,R){var o=null,w=l.entity===r.ConnectionEnd.client;if(R<38)l.error(l,{message:w?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});else{var F=D.fragment,K=F.length();if(o={version:{major:F.getByte(),minor:F.getByte()},random:t.util.createBuffer(F.getBytes(32)),session_id:g(F,1),extensions:[]},w)o.cipher_suite=F.getBytes(2),o.compression_method=F.getByte();else o.cipher_suites=g(F,2),o.compression_methods=g(F,1);if(K=R-(K-F.length()),K>0){var Y=g(F,2);while(Y.length()>0)o.extensions.push({type:[Y.getByte(),Y.getByte()],data:g(Y,2)});if(!w)for(var ie=0;ie<o.extensions.length;++ie){var oe=o.extensions[ie];if(oe.type[0]===0&&oe.type[1]===0){var Q=g(oe.data,2);while(Q.length()>0){var ae=Q.getByte();if(ae!==0)break;l.session.extensions.server_name.serverNameList.push(g(Q,2).getBytes())}}}}if(l.session.version){if(o.version.major!==l.session.version.major||o.version.minor!==l.session.version.minor)return l.error(l,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.protocol_version}})}if(w)l.session.cipherSuite=r.getCipherSuite(o.cipher_suite);else{var ue=t.util.createBuffer(o.cipher_suites.bytes());while(ue.length()>0)if(l.session.cipherSuite=r.getCipherSuite(ue.getBytes(2)),l.session.cipherSuite!==null)break}if(l.session.cipherSuite===null)return l.error(l,{message:"No cipher suites in common.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.handshake_failure},cipherSuite:t.util.bytesToHex(o.cipher_suite)});if(w)l.session.compressionMethod=o.compression_method;else l.session.compressionMethod=r.CompressionMethod.none}return o},r.createSecurityParameters=function(l,D){var R=l.entity===r.ConnectionEnd.client,o=D.random.bytes(),w=R?l.session.sp.client_random:o,F=R?o:r.createRandom().getBytes();l.session.sp={entity:l.entity,prf_algorithm:r.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:l.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:w,server_random:F}},r.handleServerHello=function(l,D,R){var o=r.parseHelloMessage(l,D,R);if(l.fail)return;if(o.version.minor<=l.version.minor)l.version.minor=o.version.minor;else return l.error(l,{message:"Incompatible TLS version.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.protocol_version}});l.session.version=l.version;var w=o.session_id.bytes();if(w.length>0&&w===l.session.id)l.expect=c,l.session.resuming=!0,l.session.sp.server_random=o.random.bytes();else l.expect=f,l.session.resuming=!1,r.createSecurityParameters(l,o);l.session.id=w,l.process()},r.handleClientHello=function(l,D,R){var o=r.parseHelloMessage(l,D,R);if(l.fail)return;var w=o.session_id.bytes(),F=null;if(l.sessionCache){if(F=l.sessionCache.getSession(w),F===null)w="";else if(F.version.major!==o.version.major||F.version.minor>o.version.minor)F=null,w=""}if(w.length===0)w=t.random.getBytes(32);if(l.session.id=w,l.session.clientHelloVersion=o.version,l.session.sp={},F)l.version=l.session.version=F.version,l.session.sp=F.sp;else{var K;for(var Y=1;Y<r.SupportedVersions.length;++Y)if(K=r.SupportedVersions[Y],K.minor<=o.version.minor)break;l.version={major:K.major,minor:K.minor},l.session.version=l.version}if(F!==null)l.expect=L,l.session.resuming=!0,l.session.sp.client_random=o.random.bytes();else l.expect=l.verifyClient!==!1?p:y,l.session.resuming=!1,r.createSecurityParameters(l,o);if(l.open=!0,r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createServerHello(l)})),l.session.resuming)r.queue(l,r.createRecord(l,{type:r.ContentType.change_cipher_spec,data:r.createChangeCipherSpec()})),l.state.pending=r.createConnectionState(l),l.state.current.write=l.state.pending.write,r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createFinished(l)}));else if(r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createCertificate(l)})),!l.fail){if(r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createServerKeyExchange(l)})),l.verifyClient!==!1)r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createCertificateRequest(l)}));r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createServerHelloDone(l)}))}r.flush(l),l.process()},r.handleCertificate=function(l,D,R){if(R<3)return l.error(l,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});var o=D.fragment,w={certificate_list:g(o,3)},F,K,Y=[];try{while(w.certificate_list.length()>0)F=g(w.certificate_list,3),K=t.asn1.fromDer(F),F=t.pki.certificateFromAsn1(K,!0),Y.push(F)}catch(oe){return l.error(l,{message:"Could not parse certificate list.",cause:oe,send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.bad_certificate}})}var ie=l.entity===r.ConnectionEnd.client;if((ie||l.verifyClient===!0)&&Y.length===0)l.error(l,{message:ie?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});else if(Y.length===0)l.expect=ie?I:y;else{if(ie)l.session.serverCertificate=Y[0];else l.session.clientCertificate=Y[0];if(r.verifyCertificateChain(l,Y))l.expect=ie?I:y}l.process()},r.handleServerKeyExchange=function(l,D,R){if(R>0)return l.error(l,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.unsupported_certificate}});l.expect=U,l.process()},r.handleClientKeyExchange=function(l,D,R){if(R<48)return l.error(l,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.unsupported_certificate}});var o=D.fragment,w={enc_pre_master_secret:g(o,2).getBytes()},F=null;if(l.getPrivateKey)try{F=l.getPrivateKey(l,l.session.serverCertificate),F=t.pki.privateKeyFromPem(F)}catch(ie){l.error(l,{message:"Could not get private key.",cause:ie,send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}})}if(F===null)return l.error(l,{message:"No private key set.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}});try{var K=l.session.sp;K.pre_master_secret=F.decrypt(w.enc_pre_master_secret);var Y=l.session.clientHelloVersion;if(Y.major!==K.pre_master_secret.charCodeAt(0)||Y.minor!==K.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(ie){K.pre_master_secret=t.random.getBytes(48)}if(l.expect=L,l.session.clientCertificate!==null)l.expect=b;l.process()},r.handleCertificateRequest=function(l,D,R){if(R<3)return l.error(l,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});var o=D.fragment,w={certificate_types:g(o,1),certificate_authorities:g(o,2)};l.session.certificateRequest=w,l.expect=T,l.process()},r.handleCertificateVerify=function(l,D,R){if(R<2)return l.error(l,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});var o=D.fragment;o.read-=4;var w=o.bytes();o.read+=4;var F={signature:g(o,2).getBytes()},K=t.util.createBuffer();K.putBuffer(l.session.md5.digest()),K.putBuffer(l.session.sha1.digest()),K=K.getBytes();try{var Y=l.session.clientCertificate;if(!Y.publicKey.verify(K,F.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");l.session.md5.update(w),l.session.sha1.update(w)}catch(ie){return l.error(l,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.handshake_failure}})}l.expect=L,l.process()},r.handleServerHelloDone=function(l,D,R){if(R>0)return l.error(l,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.record_overflow}});if(l.serverCertificate===null){var o={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.insufficient_security}},w=0,F=l.verify(l,o.alert.description,w,[]);if(F!==!0){if(F||F===0){if(typeof F==="object"&&!t.util.isArray(F)){if(F.message)o.message=F.message;if(F.alert)o.alert.description=F.alert}else if(typeof F==="number")o.alert.description=F}return l.error(l,o)}}if(l.session.certificateRequest!==null)D=r.createRecord(l,{type:r.ContentType.handshake,data:r.createCertificate(l)}),r.queue(l,D);D=r.createRecord(l,{type:r.ContentType.handshake,data:r.createClientKeyExchange(l)}),r.queue(l,D),l.expect=E;var K=function(Y,ie){if(Y.session.certificateRequest!==null&&Y.session.clientCertificate!==null)r.queue(Y,r.createRecord(Y,{type:r.ContentType.handshake,data:r.createCertificateVerify(Y,ie)}));r.queue(Y,r.createRecord(Y,{type:r.ContentType.change_cipher_spec,data:r.createChangeCipherSpec()})),Y.state.pending=r.createConnectionState(Y),Y.state.current.write=Y.state.pending.write,r.queue(Y,r.createRecord(Y,{type:r.ContentType.handshake,data:r.createFinished(Y)})),Y.expect=c,r.flush(Y),Y.process()};if(l.session.certificateRequest===null||l.session.clientCertificate===null)return K(l,null);r.getClientSignature(l,K)},r.handleChangeCipherSpec=function(l,D){if(D.fragment.getByte()!==1)return l.error(l,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.illegal_parameter}});var R=l.entity===r.ConnectionEnd.client;if(l.session.resuming&&R||!l.session.resuming&&!R)l.state.pending=r.createConnectionState(l);if(l.state.current.read=l.state.pending.read,!l.session.resuming&&R||l.session.resuming&&!R)l.state.pending=null;l.expect=R?m:h,l.process()},r.handleFinished=function(l,D,R){var o=D.fragment;o.read-=4;var w=o.bytes();o.read+=4;var F=D.fragment.getBytes();o=t.util.createBuffer(),o.putBuffer(l.session.md5.digest()),o.putBuffer(l.session.sha1.digest());var K=l.entity===r.ConnectionEnd.client,Y=K?"server finished":"client finished",ie=l.session.sp,oe=12,Q=e;if(o=Q(ie.master_secret,Y,o.getBytes(),oe),o.getBytes()!==F)return l.error(l,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.decrypt_error}});if(l.session.md5.update(w),l.session.sha1.update(w),l.session.resuming&&K||!l.session.resuming&&!K)r.queue(l,r.createRecord(l,{type:r.ContentType.change_cipher_spec,data:r.createChangeCipherSpec()})),l.state.current.write=l.state.pending.write,l.state.pending=null,r.queue(l,r.createRecord(l,{type:r.ContentType.handshake,data:r.createFinished(l)}));l.expect=K?S:s,l.handshaking=!1,++l.handshakes,l.peerCertificate=K?l.session.serverCertificate:l.session.clientCertificate,r.flush(l),l.isConnected=!0,l.connected(l),l.process()},r.handleAlert=function(l,D){var R=D.fragment,o={level:R.getByte(),description:R.getByte()},w;switch(o.description){case r.Alert.Description.close_notify:w="Connection closed.";break;case r.Alert.Description.unexpected_message:w="Unexpected message.";break;case r.Alert.Description.bad_record_mac:w="Bad record MAC.";break;case r.Alert.Description.decryption_failed:w="Decryption failed.";break;case r.Alert.Description.record_overflow:w="Record overflow.";break;case r.Alert.Description.decompression_failure:w="Decompression failed.";break;case r.Alert.Description.handshake_failure:w="Handshake failure.";break;case r.Alert.Description.bad_certificate:w="Bad certificate.";break;case r.Alert.Description.unsupported_certificate:w="Unsupported certificate.";break;case r.Alert.Description.certificate_revoked:w="Certificate revoked.";break;case r.Alert.Description.certificate_expired:w="Certificate expired.";break;case r.Alert.Description.certificate_unknown:w="Certificate unknown.";break;case r.Alert.Description.illegal_parameter:w="Illegal parameter.";break;case r.Alert.Description.unknown_ca:w="Unknown certificate authority.";break;case r.Alert.Description.access_denied:w="Access denied.";break;case r.Alert.Description.decode_error:w="Decode error.";break;case r.Alert.Description.decrypt_error:w="Decrypt error.";break;case r.Alert.Description.export_restriction:w="Export restriction.";break;case r.Alert.Description.protocol_version:w="Unsupported protocol version.";break;case r.Alert.Description.insufficient_security:w="Insufficient security.";break;case r.Alert.Description.internal_error:w="Internal error.";break;case r.Alert.Description.user_canceled:w="User canceled.";break;case r.Alert.Description.no_renegotiation:w="Renegotiation not supported.";break;default:w="Unknown error.";break}if(o.description===r.Alert.Description.close_notify)return l.close();l.error(l,{message:w,send:!1,origin:l.entity===r.ConnectionEnd.client?"server":"client",alert:o}),l.process()},r.handleHandshake=function(l,D){var R=D.fragment,o=R.getByte(),w=R.getInt24();if(w>R.length())return l.fragmented=D,D.fragment=t.util.createBuffer(),R.read-=4,l.process();l.fragmented=null,R.read-=4;var F=R.bytes(w+4);if(R.read+=4,o in ve[l.entity][l.expect]){if(l.entity===r.ConnectionEnd.server&&!l.open&&!l.fail)l.handshaking=!0,l.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:t.md.md5.create(),sha1:t.md.sha1.create()};if(o!==r.HandshakeType.hello_request&&o!==r.HandshakeType.certificate_verify&&o!==r.HandshakeType.finished)l.session.md5.update(F),l.session.sha1.update(F);ve[l.entity][l.expect][o](l,D,w)}else r.handleUnexpected(l,D)},r.handleApplicationData=function(l,D){l.data.putBuffer(D.fragment),l.dataReady(l),l.process()},r.handleHeartbeat=function(l,D){var R=D.fragment,o=R.getByte(),w=R.getInt16(),F=R.getBytes(w);if(o===r.HeartbeatMessageType.heartbeat_request){if(l.handshaking||w>F.length)return l.process();r.queue(l,r.createRecord(l,{type:r.ContentType.heartbeat,data:r.createHeartbeat(r.HeartbeatMessageType.heartbeat_response,F)})),r.flush(l)}else if(o===r.HeartbeatMessageType.heartbeat_response){if(F!==l.expectedHeartbeatPayload)return l.process();if(l.heartbeatReceived)l.heartbeatReceived(l,t.util.createBuffer(F))}l.process()};var C=0,f=1,I=2,U=3,T=4,c=5,m=6,S=7,E=8,n=0,p=1,y=2,b=3,L=4,h=5,s=6,i=r.handleUnexpected,B=r.handleChangeCipherSpec,P=r.handleAlert,O=r.handleHandshake,V=r.handleApplicationData,M=r.handleHeartbeat,G=[];G[r.ConnectionEnd.client]=[[i,P,O,i,M],[i,P,O,i,M],[i,P,O,i,M],[i,P,O,i,M],[i,P,O,i,M],[B,P,i,i,M],[i,P,O,i,M],[i,P,O,V,M],[i,P,O,i,M]],G[r.ConnectionEnd.server]=[[i,P,O,i,M],[i,P,O,i,M],[i,P,O,i,M],[i,P,O,i,M],[B,P,i,i,M],[i,P,O,i,M],[i,P,O,V,M],[i,P,O,i,M]];var{handleHelloRequest:q,handleServerHello:H,handleCertificate:X,handleServerKeyExchange:J,handleCertificateRequest:te,handleServerHelloDone:se,handleFinished:fe}=r,ve=[];ve[r.ConnectionEnd.client]=[[i,i,H,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,X,J,te,se,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,J,te,se,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,i,te,se,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,i,i,se,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,fe],[q,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[q,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i]];var{handleClientHello:Ie,handleClientKeyExchange:Z,handleCertificateVerify:me}=r;ve[r.ConnectionEnd.server]=[[i,Ie,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,X,i,i,i,i,i,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,Z,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,me,i,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,fe],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i],[i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i]],r.generateKeys=function(l,D){var R=e,o=D.client_random+D.server_random;if(!l.session.resuming)D.master_secret=R(D.pre_master_secret,"master secret",o,48).bytes(),D.pre_master_secret=null;o=D.server_random+D.client_random;var w=2*D.mac_key_length+2*D.enc_key_length,F=l.version.major===r.Versions.TLS_1_0.major&&l.version.minor===r.Versions.TLS_1_0.minor;if(F)w+=2*D.fixed_iv_length;var K=R(D.master_secret,"key expansion",o,w),Y={client_write_MAC_key:K.getBytes(D.mac_key_length),server_write_MAC_key:K.getBytes(D.mac_key_length),client_write_key:K.getBytes(D.enc_key_length),server_write_key:K.getBytes(D.enc_key_length)};if(F)Y.client_write_IV=K.getBytes(D.fixed_iv_length),Y.server_write_IV=K.getBytes(D.fixed_iv_length);return Y},r.createConnectionState=function(l){var D=l.entity===r.ConnectionEnd.client,R=function(){var F={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(K){return!0},compressionState:null,compressFunction:function(K){return!0},updateSequenceNumber:function(){if(F.sequenceNumber[1]===4294967295)F.sequenceNumber[1]=0,++F.sequenceNumber[0];else++F.sequenceNumber[1]}};return F},o={read:R(),write:R()};if(o.read.update=function(F,K){if(!o.read.cipherFunction(K,o.read))F.error(F,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.bad_record_mac}});else if(!o.read.compressFunction(F,K,o.read))F.error(F,{message:"Could not decompress record.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.decompression_failure}});return!F.fail},o.write.update=function(F,K){if(!o.write.compressFunction(F,K,o.write))F.error(F,{message:"Could not compress record.",send:!1,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}});else if(!o.write.cipherFunction(K,o.write))F.error(F,{message:"Could not encrypt record.",send:!1,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}});return!F.fail},l.session){var w=l.session.sp;switch(l.session.cipherSuite.initSecurityParameters(w),w.keys=r.generateKeys(l,w),o.read.macKey=D?w.keys.server_write_MAC_key:w.keys.client_write_MAC_key,o.write.macKey=D?w.keys.client_write_MAC_key:w.keys.server_write_MAC_key,l.session.cipherSuite.initConnectionState(o,l,w),w.compression_algorithm){case r.CompressionMethod.none:break;case r.CompressionMethod.deflate:o.read.compressFunction=v,o.write.compressFunction=d;break;default:throw new Error("Unsupported compression algorithm.")}}return o},r.createRandom=function(){var l=new Date,D=+l+l.getTimezoneOffset()*60000,R=t.util.createBuffer();return R.putInt32(D),R.putBytes(t.random.getBytes(28)),R},r.createRecord=function(l,D){if(!D.data)return null;var R={type:D.type,version:{major:l.version.major,minor:l.version.minor},length:D.data.length(),fragment:D.data};return R},r.createAlert=function(l,D){var R=t.util.createBuffer();return R.putByte(D.level),R.putByte(D.description),r.createRecord(l,{type:r.ContentType.alert,data:R})},r.createClientHello=function(l){l.session.clientHelloVersion={major:l.version.major,minor:l.version.minor};var D=t.util.createBuffer();for(var R=0;R<l.cipherSuites.length;++R){var o=l.cipherSuites[R];D.putByte(o.id[0]),D.putByte(o.id[1])}var w=D.length(),F=t.util.createBuffer();F.putByte(r.CompressionMethod.none);var K=F.length(),Y=t.util.createBuffer();if(l.virtualHost){var ie=t.util.createBuffer();ie.putByte(0),ie.putByte(0);var oe=t.util.createBuffer();oe.putByte(0),u(oe,2,t.util.createBuffer(l.virtualHost));var Q=t.util.createBuffer();u(Q,2,oe),u(ie,2,Q),Y.putBuffer(ie)}var ae=Y.length();if(ae>0)ae+=2;var ue=l.session.id,ge=ue.length+1+2+4+28+2+w+1+K+ae,he=t.util.createBuffer();if(he.putByte(r.HandshakeType.client_hello),he.putInt24(ge),he.putByte(l.version.major),he.putByte(l.version.minor),he.putBytes(l.session.sp.client_random),u(he,1,t.util.createBuffer(ue)),u(he,2,D),u(he,1,F),ae>0)u(he,2,Y);return he},r.createServerHello=function(l){var D=l.session.id,R=D.length+1+2+4+28+2+1,o=t.util.createBuffer();return o.putByte(r.HandshakeType.server_hello),o.putInt24(R),o.putByte(l.version.major),o.putByte(l.version.minor),o.putBytes(l.session.sp.server_random),u(o,1,t.util.createBuffer(D)),o.putByte(l.session.cipherSuite.id[0]),o.putByte(l.session.cipherSuite.id[1]),o.putByte(l.session.compressionMethod),o},r.createCertificate=function(l){var D=l.entity===r.ConnectionEnd.client,R=null;if(l.getCertificate){var o;if(D)o=l.session.certificateRequest;else o=l.session.extensions.server_name.serverNameList;R=l.getCertificate(l,o)}var w=t.util.createBuffer();if(R!==null)try{if(!t.util.isArray(R))R=[R];var F=null;for(var K=0;K<R.length;++K){var Y=t.pem.decode(R[K])[0];if(Y.type!=="CERTIFICATE"&&Y.type!=="X509 CERTIFICATE"&&Y.type!=="TRUSTED CERTIFICATE"){var ie=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw ie.headerType=Y.type,ie}if(Y.procType&&Y.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var oe=t.util.createBuffer(Y.body);if(F===null)F=t.asn1.fromDer(oe.bytes(),!1);var Q=t.util.createBuffer();u(Q,3,oe),w.putBuffer(Q)}if(R=t.pki.certificateFromAsn1(F),D)l.session.clientCertificate=R;else l.session.serverCertificate=R}catch(ge){return l.error(l,{message:"Could not send certificate list.",cause:ge,send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.bad_certificate}})}var ae=3+w.length(),ue=t.util.createBuffer();return ue.putByte(r.HandshakeType.certificate),ue.putInt24(ae),u(ue,3,w),ue},r.createClientKeyExchange=function(l){var D=t.util.createBuffer();D.putByte(l.session.clientHelloVersion.major),D.putByte(l.session.clientHelloVersion.minor),D.putBytes(t.random.getBytes(46));var R=l.session.sp;R.pre_master_secret=D.getBytes();var o=l.session.serverCertificate.publicKey;D=o.encrypt(R.pre_master_secret);var w=D.length+2,F=t.util.createBuffer();return F.putByte(r.HandshakeType.client_key_exchange),F.putInt24(w),F.putInt16(D.length),F.putBytes(D),F},r.createServerKeyExchange=function(l){var D=0,R=t.util.createBuffer();if(D>0)R.putByte(r.HandshakeType.server_key_exchange),R.putInt24(D);return R},r.getClientSignature=function(l,D){var R=t.util.createBuffer();R.putBuffer(l.session.md5.digest()),R.putBuffer(l.session.sha1.digest()),R=R.getBytes(),l.getSignature=l.getSignature||function(o,w,F){var K=null;if(o.getPrivateKey)try{K=o.getPrivateKey(o,o.session.clientCertificate),K=t.pki.privateKeyFromPem(K)}catch(Y){o.error(o,{message:"Could not get private key.",cause:Y,send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}})}if(K===null)o.error(o,{message:"No private key set.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.internal_error}});else w=K.sign(w,null);F(o,w)},l.getSignature(l,R,D)},r.createCertificateVerify=function(l,D){var R=D.length+2,o=t.util.createBuffer();return o.putByte(r.HandshakeType.certificate_verify),o.putInt24(R),o.putInt16(D.length),o.putBytes(D),o},r.createCertificateRequest=function(l){var D=t.util.createBuffer();D.putByte(1);var R=t.util.createBuffer();for(var o in l.caStore.certs){var w=l.caStore.certs[o],F=t.pki.distinguishedNameToAsn1(w.subject),K=t.asn1.toDer(F);R.putInt16(K.length()),R.putBuffer(K)}var Y=1+D.length()+2+R.length(),ie=t.util.createBuffer();return ie.putByte(r.HandshakeType.certificate_request),ie.putInt24(Y),u(ie,1,D),u(ie,2,R),ie},r.createServerHelloDone=function(l){var D=t.util.createBuffer();return D.putByte(r.HandshakeType.server_hello_done),D.putInt24(0),D},r.createChangeCipherSpec=function(){var l=t.util.createBuffer();return l.putByte(1),l},r.createFinished=function(l){var D=t.util.createBuffer();D.putBuffer(l.session.md5.digest()),D.putBuffer(l.session.sha1.digest());var R=l.entity===r.ConnectionEnd.client,o=l.session.sp,w=12,F=e,K=R?"client finished":"server finished";D=F(o.master_secret,K,D.getBytes(),w);var Y=t.util.createBuffer();return Y.putByte(r.HandshakeType.finished),Y.putInt24(D.length()),Y.putBuffer(D),Y},r.createHeartbeat=function(l,D,R){if(typeof R==="undefined")R=D.length;var o=t.util.createBuffer();o.putByte(l),o.putInt16(R),o.putBytes(D);var w=o.length(),F=Math.max(16,w-R-3);return o.putBytes(t.random.getBytes(F)),o},r.queue=function(l,D){if(!D)return;if(D.fragment.length()===0){if(D.type===r.ContentType.handshake||D.type===r.ContentType.alert||D.type===r.ContentType.change_cipher_spec)return}if(D.type===r.ContentType.handshake){var R=D.fragment.bytes();l.session.md5.update(R),l.session.sha1.update(R),R=null}var o;if(D.fragment.length()<=r.MaxFragment)o=[D];else{o=[];var w=D.fragment.bytes();while(w.length>r.MaxFragment)o.push(r.createRecord(l,{type:D.type,data:t.util.createBuffer(w.slice(0,r.MaxFragment))})),w=w.slice(r.MaxFragment);if(w.length>0)o.push(r.createRecord(l,{type:D.type,data:t.util.createBuffer(w)}))}for(var F=0;F<o.length&&!l.fail;++F){var K=o[F],Y=l.state.current.write;if(Y.update(l,K))l.records.push(K)}},r.flush=function(l){for(var D=0;D<l.records.length;++D){var R=l.records[D];l.tlsData.putByte(R.type),l.tlsData.putByte(R.version.major),l.tlsData.putByte(R.version.minor),l.tlsData.putInt16(R.fragment.length()),l.tlsData.putBuffer(l.records[D].fragment)}return l.records=[],l.tlsDataReady(l)};var ee=function(l){switch(l){case!0:return!0;case t.pki.certificateError.bad_certificate:return r.Alert.Description.bad_certificate;case t.pki.certificateError.unsupported_certificate:return r.Alert.Description.unsupported_certificate;case t.pki.certificateError.certificate_revoked:return r.Alert.Description.certificate_revoked;case t.pki.certificateError.certificate_expired:return r.Alert.Description.certificate_expired;case t.pki.certificateError.certificate_unknown:return r.Alert.Description.certificate_unknown;case t.pki.certificateError.unknown_ca:return r.Alert.Description.unknown_ca;default:return r.Alert.Description.bad_certificate}},Ae=function(l){switch(l){case!0:return!0;case r.Alert.Description.bad_certificate:return t.pki.certificateError.bad_certificate;case r.Alert.Description.unsupported_certificate:return t.pki.certificateError.unsupported_certificate;case r.Alert.Description.certificate_revoked:return t.pki.certificateError.certificate_revoked;case r.Alert.Description.certificate_expired:return t.pki.certificateError.certificate_expired;case r.Alert.Description.certificate_unknown:return t.pki.certificateError.certificate_unknown;case r.Alert.Description.unknown_ca:return t.pki.certificateError.unknown_ca;default:return t.pki.certificateError.bad_certificate}};r.verifyCertificateChain=function(l,D){try{var R={};for(var o in l.verifyOptions)R[o]=l.verifyOptions[o];R.verify=function(F,K,Y){var ie=ee(F),oe=l.verify(l,F,K,Y);if(oe!==!0){if(typeof oe==="object"&&!t.util.isArray(oe)){var Q=new Error("The application rejected the certificate.");if(Q.send=!0,Q.alert={level:r.Alert.Level.fatal,description:r.Alert.Description.bad_certificate},oe.message)Q.message=oe.message;if(oe.alert)Q.alert.description=oe.alert;throw Q}if(oe!==F)oe=Ae(oe)}return oe},t.pki.verifyCertificateChain(l.caStore,D,R)}catch(F){var w=F;if(typeof w!=="object"||t.util.isArray(w))w={send:!0,alert:{level:r.Alert.Level.fatal,description:ee(F)}};if(!("send"in w))w.send=!0;if(!("alert"in w))w.alert={level:r.Alert.Level.fatal,description:ee(w.error)};l.error(l,w)}return!l.fail},r.createSessionCache=function(l,D){var R=null;if(l&&l.getSession&&l.setSession&&l.order)R=l;else{R={},R.cache=l||{},R.capacity=Math.max(D||100,1),R.order=[];for(var o in l)if(R.order.length<=D)R.order.push(o);else delete l[o];R.getSession=function(w){var F=null,K=null;if(w)K=t.util.bytesToHex(w);else if(R.order.length>0)K=R.order[0];if(K!==null&&K in R.cache){F=R.cache[K],delete R.cache[K];for(var Y in R.order)if(R.order[Y]===K){R.order.splice(Y,1);break}}return F},R.setSession=function(w,F){if(R.order.length===R.capacity){var K=R.order.shift();delete R.cache[K]}var K=t.util.bytesToHex(w);R.order.push(K),R.cache[K]=F}}return R},r.createConnection=function(l){var D=null;if(l.caStore)if(t.util.isArray(l.caStore))D=t.pki.createCaStore(l.caStore);else D=l.caStore;else D=t.pki.createCaStore();var R=l.cipherSuites||null;if(R===null){R=[];for(var o in r.CipherSuites)R.push(r.CipherSuites[o])}var w=l.server?r.ConnectionEnd.server:r.ConnectionEnd.client,F=l.sessionCache?r.createSessionCache(l.sessionCache):null,K={version:{major:r.Version.major,minor:r.Version.minor},entity:w,sessionId:l.sessionId,caStore:D,sessionCache:F,cipherSuites:R,connected:l.connected,virtualHost:l.virtualHost||null,verifyClient:l.verifyClient||!1,verify:l.verify||function(Q,ae,ue,ge){return ae},verifyOptions:l.verifyOptions||{},getCertificate:l.getCertificate||null,getPrivateKey:l.getPrivateKey||null,getSignature:l.getSignature||null,input:t.util.createBuffer(),tlsData:t.util.createBuffer(),data:t.util.createBuffer(),tlsDataReady:l.tlsDataReady,dataReady:l.dataReady,heartbeatReceived:l.heartbeatReceived,closed:l.closed,error:function(Q,ae){if(ae.origin=ae.origin||(Q.entity===r.ConnectionEnd.client?"client":"server"),ae.send)r.queue(Q,r.createAlert(Q,ae.alert)),r.flush(Q);var ue=ae.fatal!==!1;if(ue)Q.fail=!0;if(l.error(Q,ae),ue)Q.close(!1)},deflate:l.deflate||null,inflate:l.inflate||null};K.reset=function(Q){K.version={major:r.Version.major,minor:r.Version.minor},K.record=null,K.session=null,K.peerCertificate=null,K.state={pending:null,current:null},K.expect=K.entity===r.ConnectionEnd.client?C:n,K.fragmented=null,K.records=[],K.open=!1,K.handshakes=0,K.handshaking=!1,K.isConnected=!1,K.fail=!(Q||typeof Q==="undefined"),K.input.clear(),K.tlsData.clear(),K.data.clear(),K.state.current=r.createConnectionState(K)},K.reset();var Y=function(Q,ae){var ue=ae.type-r.ContentType.change_cipher_spec,ge=G[Q.entity][Q.expect];if(ue in ge)ge[ue](Q,ae);else r.handleUnexpected(Q,ae)},ie=function(Q){var ae=0,ue=Q.input,ge=ue.length();if(ge<5)ae=5-ge;else{Q.record={type:ue.getByte(),version:{major:ue.getByte(),minor:ue.getByte()},length:ue.getInt16(),fragment:t.util.createBuffer(),ready:!1};var he=Q.record.version.major===Q.version.major;if(he&&Q.session&&Q.session.version)he=Q.record.version.minor===Q.version.minor;if(!he)Q.error(Q,{message:"Incompatible TLS version.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.protocol_version}})}return ae},oe=function(Q){var ae=0,ue=Q.input,ge=ue.length();if(ge<Q.record.length)ae=Q.record.length-ge;else{Q.record.fragment.putBytes(ue.getBytes(Q.record.length)),ue.compact();var he=Q.state.current.read;if(he.update(Q,Q.record)){if(Q.fragmented!==null)if(Q.fragmented.type===Q.record.type)Q.fragmented.fragment.putBuffer(Q.record.fragment),Q.record=Q.fragmented;else Q.error(Q,{message:"Invalid fragmented record.",send:!0,alert:{level:r.Alert.Level.fatal,description:r.Alert.Description.unexpected_message}});Q.record.ready=!0}}return ae};return K.handshake=function(Q){if(K.entity!==r.ConnectionEnd.client)K.error(K,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(K.handshaking)K.error(K,{message:"Handshake already in progress.",fatal:!1});else{if(K.fail&&!K.open&&K.handshakes===0)K.fail=!1;K.handshaking=!0,Q=Q||"";var ae=null;if(Q.length>0){if(K.sessionCache)ae=K.sessionCache.getSession(Q);if(ae===null)Q=""}if(Q.length===0&&K.sessionCache){if(ae=K.sessionCache.getSession(),ae!==null)Q=ae.id}if(K.session={id:Q,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:t.md.md5.create(),sha1:t.md.sha1.create()},ae)K.version=ae.version,K.session.sp=ae.sp;K.session.sp.client_random=r.createRandom().getBytes(),K.open=!0,r.queue(K,r.createRecord(K,{type:r.ContentType.handshake,data:r.createClientHello(K)})),r.flush(K)}},K.process=function(Q){var ae=0;if(Q)K.input.putBytes(Q);if(!K.fail){if(K.record!==null&&K.record.ready&&K.record.fragment.isEmpty())K.record=null;if(K.record===null)ae=ie(K);if(!K.fail&&K.record!==null&&!K.record.ready)ae=oe(K);if(!K.fail&&K.record!==null&&K.record.ready)Y(K,K.record)}return ae},K.prepare=function(Q){return r.queue(K,r.createRecord(K,{type:r.ContentType.application_data,data:t.util.createBuffer(Q)})),r.flush(K)},K.prepareHeartbeatRequest=function(Q,ae){if(Q instanceof t.util.ByteBuffer)Q=Q.bytes();if(typeof ae==="undefined")ae=Q.length;return K.expectedHeartbeatPayload=Q,r.queue(K,r.createRecord(K,{type:r.ContentType.heartbeat,data:r.createHeartbeat(r.HeartbeatMessageType.heartbeat_request,Q,ae)})),r.flush(K)},K.close=function(Q){if(!K.fail&&K.sessionCache&&K.session){var ae={id:K.session.id,version:K.session.version,sp:K.session.sp};ae.sp.keys=null,K.sessionCache.setSession(ae.id,ae)}if(K.open){if(K.open=!1,K.input.clear(),K.isConnected||K.handshaking)K.isConnected=K.handshaking=!1,r.queue(K,r.createAlert(K,{level:r.Alert.Level.warning,description:r.Alert.Description.close_notify})),r.flush(K);K.closed(K)}K.reset(Q)},K},_.exports=t.tls=t.tls||{};for(de in r)if(typeof r[de]!=="function")t.tls[de]=r[de];var de;t.tls.prf_tls1=e,t.tls.hmac_sha1=a,t.tls.createSessionCache=r.createSessionCache,t.tls.createConnection=r.createConnection}),Fi=le((N,_)=>{var t=pe();Tt(),Wr();var e=_.exports=t.tls;e.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(C){C.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,C.cipher_type=e.CipherType.block,C.enc_key_length=16,C.block_length=16,C.fixed_iv_length=16,C.record_iv_length=16,C.mac_algorithm=e.MACAlgorithm.hmac_sha1,C.mac_length=20,C.mac_key_length=20},initConnectionState:a},e.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(C){C.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,C.cipher_type=e.CipherType.block,C.enc_key_length=32,C.block_length=16,C.fixed_iv_length=16,C.record_iv_length=16,C.mac_algorithm=e.MACAlgorithm.hmac_sha1,C.mac_length=20,C.mac_key_length=20},initConnectionState:a};function a(C,f,I){var U=f.entity===t.tls.ConnectionEnd.client;C.read.cipherState={init:!1,cipher:t.cipher.createDecipher("AES-CBC",U?I.keys.server_write_key:I.keys.client_write_key),iv:U?I.keys.server_write_IV:I.keys.client_write_IV},C.write.cipherState={init:!1,cipher:t.cipher.createCipher("AES-CBC",U?I.keys.client_write_key:I.keys.server_write_key),iv:U?I.keys.client_write_IV:I.keys.server_write_IV},C.read.cipherFunction=u,C.write.cipherFunction=d,C.read.macLength=C.write.macLength=I.mac_length,C.read.macFunction=C.write.macFunction=e.hmac_sha1}function d(C,f){var I=!1,U=f.macFunction(f.macKey,f.sequenceNumber,C);C.fragment.putBytes(U),f.updateSequenceNumber();var T;if(C.version.minor===e.Versions.TLS_1_0.minor)T=f.cipherState.init?null:f.cipherState.iv;else T=t.random.getBytesSync(16);f.cipherState.init=!0;var c=f.cipherState.cipher;if(c.start({iv:T}),C.version.minor>=e.Versions.TLS_1_1.minor)c.output.putBytes(T);if(c.update(C.fragment),c.finish(v))C.fragment=c.output,C.length=C.fragment.length(),I=!0;return I}function v(C,f,I){if(!I){var U=C-f.length()%C;f.fillWithByte(U-1,U)}return!0}function g(C,f,I){var U=!0;if(I){var T=f.length(),c=f.last();for(var m=T-1-c;m<T-1;++m)U=U&&f.at(m)==c;if(U)f.truncate(c+1)}return U}function u(C,f){var I=!1,U;if(C.version.minor===e.Versions.TLS_1_0.minor)U=f.cipherState.init?null:f.cipherState.iv;else U=C.fragment.getBytes(16);f.cipherState.init=!0;var T=f.cipherState.cipher;T.start({iv:U}),T.update(C.fragment),I=T.finish(g);var c=f.macLength,m=t.random.getBytesSync(c),S=T.output.length();if(S>=c)C.fragment=T.output.getBytes(S-c),m=T.output.getBytes(c);else C.fragment=T.output.getBytes();C.fragment=t.util.createBuffer(C.fragment),C.length=C.fragment.length();var E=f.macFunction(f.macKey,f.sequenceNumber,C);return f.updateSequenceNumber(),I=r(f.macKey,m,E)&&I,I}function r(C,f,I){var U=t.hmac.create();return U.start("SHA1",C),U.update(f),f=U.digest().getBytes(),U.start(null,null),U.update(I),I=U.digest().getBytes(),f===I}}),Zr=le((N,_)=>{var t=pe();yt(),Ce();var e=_.exports=t.sha512=t.sha512||{};t.md.sha512=t.md.algorithms.sha512=e;var a=t.sha384=t.sha512.sha384=t.sha512.sha384||{};a.create=function(){return e.create("SHA-384")},t.md.sha384=t.md.algorithms.sha384=a,t.sha512.sha256=t.sha512.sha256||{create:function(){return e.create("SHA-512/256")}},t.md["sha512/256"]=t.md.algorithms["sha512/256"]=t.sha512.sha256,t.sha512.sha224=t.sha512.sha224||{create:function(){return e.create("SHA-512/224")}},t.md["sha512/224"]=t.md.algorithms["sha512/224"]=t.sha512.sha224,e.create=function(f){if(!v)r();if(typeof f==="undefined")f="SHA-512";if(!(f in u))throw new Error("Invalid SHA-512 algorithm: "+f);var I=u[f],U=null,T=t.util.createBuffer(),c=new Array(80);for(var m=0;m<80;++m)c[m]=new Array(2);var S=64;switch(f){case"SHA-384":S=48;break;case"SHA-512/256":S=32;break;case"SHA-512/224":S=28;break}var E={algorithm:f.replace("-","").toLowerCase(),blockLength:128,digestLength:S,messageLength:0,fullMessageLength:null,messageLengthSize:16};return E.start=function(){E.messageLength=0,E.fullMessageLength=E.messageLength128=[];var n=E.messageLengthSize/4;for(var p=0;p<n;++p)E.fullMessageLength.push(0);T=t.util.createBuffer(),U=new Array(I.length);for(var p=0;p<I.length;++p)U[p]=I[p].slice(0);return E},E.start(),E.update=function(n,p){if(p==="utf8")n=t.util.encodeUtf8(n);var y=n.length;E.messageLength+=y,y=[y/4294967296>>>0,y>>>0];for(var b=E.fullMessageLength.length-1;b>=0;--b)E.fullMessageLength[b]+=y[1],y[1]=y[0]+(E.fullMessageLength[b]/4294967296>>>0),E.fullMessageLength[b]=E.fullMessageLength[b]>>>0,y[0]=y[1]/4294967296>>>0;if(T.putBytes(n),C(U,c,T),T.read>2048||T.length()===0)T.compact();return E},E.digest=function(){var n=t.util.createBuffer();n.putBytes(T.bytes());var p=E.fullMessageLength[E.fullMessageLength.length-1]+E.messageLengthSize,y=p&E.blockLength-1;n.putBytes(d.substr(0,E.blockLength-y));var b,L,h=E.fullMessageLength[0]*8;for(var s=0;s<E.fullMessageLength.length-1;++s)b=E.fullMessageLength[s+1]*8,L=b/4294967296>>>0,h+=L,n.putInt32(h>>>0),h=b>>>0;n.putInt32(h);var i=new Array(U.length);for(var s=0;s<U.length;++s)i[s]=U[s].slice(0);C(i,c,n);var B=t.util.createBuffer(),P;if(f==="SHA-512")P=i.length;else if(f==="SHA-384")P=i.length-2;else P=i.length-4;for(var s=0;s<P;++s)if(B.putInt32(i[s][0]),s!==P-1||f!=="SHA-512/224")B.putInt32(i[s][1]);return B},E};var d=null,v=!1,g=null,u=null;function r(){d=String.fromCharCode(128),d+=t.util.fillString(String.fromCharCode(0),128),g=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],u={},u["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],u["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],u["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],u["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],v=!0}function C(f,I,U){var T,c,m,S,E,n,p,y,b,L,h,s,i,B,P,O,V,M,G,q,H,X,J,te,se,fe,ve,Ie,Z,me,ee,Ae,de,l,D,R=U.length();while(R>=128){for(Z=0;Z<16;++Z)I[Z][0]=U.getInt32()>>>0,I[Z][1]=U.getInt32()>>>0;for(;Z<80;++Z)Ae=I[Z-2],me=Ae[0],ee=Ae[1],T=((me>>>19|ee<<13)^(ee>>>29|me<<3)^me>>>6)>>>0,c=((me<<13|ee>>>19)^(ee<<3|me>>>29)^(me<<26|ee>>>6))>>>0,l=I[Z-15],me=l[0],ee=l[1],m=((me>>>1|ee<<31)^(me>>>8|ee<<24)^me>>>7)>>>0,S=((me<<31|ee>>>1)^(me<<24|ee>>>8)^(me<<25|ee>>>7))>>>0,de=I[Z-7],D=I[Z-16],ee=c+de[1]+S+D[1],I[Z][0]=T+de[0]+m+D[0]+(ee/4294967296>>>0)>>>0,I[Z][1]=ee>>>0;i=f[0][0],B=f[0][1],P=f[1][0],O=f[1][1],V=f[2][0],M=f[2][1],G=f[3][0],q=f[3][1],H=f[4][0],X=f[4][1],J=f[5][0],te=f[5][1],se=f[6][0],fe=f[6][1],ve=f[7][0],Ie=f[7][1];for(Z=0;Z<80;++Z)p=((H>>>14|X<<18)^(H>>>18|X<<14)^(X>>>9|H<<23))>>>0,y=((H<<18|X>>>14)^(H<<14|X>>>18)^(X<<23|H>>>9))>>>0,b=(se^H&(J^se))>>>0,L=(fe^X&(te^fe))>>>0,E=((i>>>28|B<<4)^(B>>>2|i<<30)^(B>>>7|i<<25))>>>0,n=((i<<4|B>>>28)^(B<<30|i>>>2)^(B<<25|i>>>7))>>>0,h=(i&P|V&(i^P))>>>0,s=(B&O|M&(B^O))>>>0,ee=Ie+y+L+g[Z][1]+I[Z][1],T=ve+p+b+g[Z][0]+I[Z][0]+(ee/4294967296>>>0)>>>0,c=ee>>>0,ee=n+s,m=E+h+(ee/4294967296>>>0)>>>0,S=ee>>>0,ve=se,Ie=fe,se=J,fe=te,J=H,te=X,ee=q+c,H=G+T+(ee/4294967296>>>0)>>>0,X=ee>>>0,G=V,q=M,V=P,M=O,P=i,O=B,ee=c+S,i=T+m+(ee/4294967296>>>0)>>>0,B=ee>>>0;ee=f[0][1]+B,f[0][0]=f[0][0]+i+(ee/4294967296>>>0)>>>0,f[0][1]=ee>>>0,ee=f[1][1]+O,f[1][0]=f[1][0]+P+(ee/4294967296>>>0)>>>0,f[1][1]=ee>>>0,ee=f[2][1]+M,f[2][0]=f[2][0]+V+(ee/4294967296>>>0)>>>0,f[2][1]=ee>>>0,ee=f[3][1]+q,f[3][0]=f[3][0]+G+(ee/4294967296>>>0)>>>0,f[3][1]=ee>>>0,ee=f[4][1]+X,f[4][0]=f[4][0]+H+(ee/4294967296>>>0)>>>0,f[4][1]=ee>>>0,ee=f[5][1]+te,f[5][0]=f[5][0]+J+(ee/4294967296>>>0)>>>0,f[5][1]=ee>>>0,ee=f[6][1]+fe,f[6][0]=f[6][0]+se+(ee/4294967296>>>0)>>>0,f[6][1]=ee>>>0,ee=f[7][1]+Ie,f[7][0]=f[7][0]+ve+(ee/4294967296>>>0)>>>0,f[7][1]=ee>>>0,R-=128}}}),ji=le((N)=>{var _=pe();ut();var t=_.asn1;N.privateKeyValidator={name:"PrivateKeyInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},N.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]}}),Gi=le((N,_)=>{var t=pe();Xt(),ot(),Zr(),Ce();var e=ji(),a=e.publicKeyValidator,d=e.privateKeyValidator;if(typeof v==="undefined")v=t.jsbn.BigInteger;var v,g=t.util.ByteBuffer,u=typeof Buffer==="undefined"?Uint8Array:Buffer;t.pki=t.pki||{},_.exports=t.pki.ed25519=t.ed25519=t.ed25519||{};var r=t.ed25519;r.constants={},r.constants.PUBLIC_KEY_BYTE_LENGTH=32,r.constants.PRIVATE_KEY_BYTE_LENGTH=64,r.constants.SEED_BYTE_LENGTH=32,r.constants.SIGN_BYTE_LENGTH=64,r.constants.HASH_BYTE_LENGTH=64,r.generateKeyPair=function(l){l=l||{};var D=l.seed;if(D===void 0)D=t.random.getBytesSync(r.constants.SEED_BYTE_LENGTH);else if(typeof D==="string"){if(D.length!==r.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+r.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(D instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');D=C({message:D,encoding:"binary"});var R=new u(r.constants.PUBLIC_KEY_BYTE_LENGTH),o=new u(r.constants.PRIVATE_KEY_BYTE_LENGTH);for(var w=0;w<32;++w)o[w]=D[w];return p(R,o),{publicKey:R,privateKey:o}},r.privateKeyFromAsn1=function(l){var D={},R=[],o=t.asn1.validate(l,d,D,R);if(!o){var w=new Error("Invalid Key.");throw w.errors=R,w}var F=t.asn1.derToOid(D.privateKeyOid),K=t.oids.EdDSA25519;if(F!==K)throw new Error('Invalid OID "'+F+'"; OID must be "'+K+'".');var Y=D.privateKey,ie=C({message:t.asn1.fromDer(Y).value,encoding:"binary"});return{privateKeyBytes:ie}},r.publicKeyFromAsn1=function(l){var D={},R=[],o=t.asn1.validate(l,a,D,R);if(!o){var w=new Error("Invalid Key.");throw w.errors=R,w}var F=t.asn1.derToOid(D.publicKeyOid),K=t.oids.EdDSA25519;if(F!==K)throw new Error('Invalid OID "'+F+'"; OID must be "'+K+'".');var Y=D.ed25519PublicKey;if(Y.length!==r.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return C({message:Y,encoding:"binary"})},r.publicKeyFromPrivateKey=function(l){l=l||{};var D=C({message:l.privateKey,encoding:"binary"});if(D.length!==r.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+r.constants.PRIVATE_KEY_BYTE_LENGTH);var R=new u(r.constants.PUBLIC_KEY_BYTE_LENGTH);for(var o=0;o<R.length;++o)R[o]=D[32+o];return R},r.sign=function(l){l=l||{};var D=C(l),R=C({message:l.privateKey,encoding:"binary"});if(R.length===r.constants.SEED_BYTE_LENGTH){var o=r.generateKeyPair({seed:R});R=o.privateKey}else if(R.length!==r.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+r.constants.SEED_BYTE_LENGTH+" or "+r.constants.PRIVATE_KEY_BYTE_LENGTH);var w=new u(r.constants.SIGN_BYTE_LENGTH+D.length);y(w,D,D.length,R);var F=new u(r.constants.SIGN_BYTE_LENGTH);for(var K=0;K<F.length;++K)F[K]=w[K];return F},r.verify=function(l){l=l||{};var D=C(l);if(l.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var R=C({message:l.signature,encoding:"binary"});if(R.length!==r.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+r.constants.SIGN_BYTE_LENGTH);var o=C({message:l.publicKey,encoding:"binary"});if(o.length!==r.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+r.constants.PUBLIC_KEY_BYTE_LENGTH);var w=new u(r.constants.SIGN_BYTE_LENGTH+D.length),F=new u(r.constants.SIGN_BYTE_LENGTH+D.length),K;for(K=0;K<r.constants.SIGN_BYTE_LENGTH;++K)w[K]=R[K];for(K=0;K<D.length;++K)w[K+r.constants.SIGN_BYTE_LENGTH]=D[K];return b(F,w,w.length,o)>=0};function C(l){var D=l.message;if(D instanceof Uint8Array||D instanceof u)return D;var R=l.encoding;if(D===void 0)if(l.md)D=l.md.digest().getBytes(),R="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof D==="string"&&!R)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof D==="string"){if(typeof Buffer!=="undefined")return Buffer.from(D,R);D=new g(D,R)}else if(!(D instanceof g))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');var o=new u(D.length());for(var w=0;w<o.length;++w)o[w]=D.at(w);return o}var f=Z(),I=Z([1]),U=Z([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),T=Z([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),c=Z([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=Z([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),S=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),E=Z([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function n(l,D){var R=t.md.sha512.create(),o=new g(l);R.update(o.getBytes(D),"binary");var w=R.digest().getBytes();if(typeof Buffer!=="undefined")return Buffer.from(w,"binary");var F=new u(r.constants.HASH_BYTE_LENGTH);for(var K=0;K<64;++K)F[K]=w.charCodeAt(K);return F}function p(l,D){var R=[Z(),Z(),Z(),Z()],o,w=n(D,32);w[0]&=248,w[31]&=127,w[31]|=64,te(R,w),B(l,R);for(o=0;o<32;++o)D[o+32]=l[o];return 0}function y(l,D,R,o){var w,F,K=new Float64Array(64),Y=[Z(),Z(),Z(),Z()],ie=n(o,32);ie[0]&=248,ie[31]&=127,ie[31]|=64;var oe=R+64;for(w=0;w<R;++w)l[64+w]=D[w];for(w=0;w<32;++w)l[32+w]=ie[32+w];var Q=n(l.subarray(32),R+32);h(Q),te(Y,Q),B(l,Y);for(w=32;w<64;++w)l[w]=o[w];var ae=n(l,R+64);h(ae);for(w=32;w<64;++w)K[w]=0;for(w=0;w<32;++w)K[w]=Q[w];for(w=0;w<32;++w)for(F=0;F<32;F++)K[w+F]+=ae[w]*ie[F];return L(l.subarray(32),K),oe}function b(l,D,R,o){var w,F,K=new u(32),Y=[Z(),Z(),Z(),Z()],ie=[Z(),Z(),Z(),Z()];if(F=-1,R<64)return-1;if(O(ie,o))return-1;for(w=0;w<R;++w)l[w]=D[w];for(w=0;w<32;++w)l[w+32]=o[w];var oe=n(l,R);if(h(oe),J(Y,ie,oe),te(ie,D.subarray(32)),s(Y,ie),B(K,Y),R-=64,q(D,0,K,0)){for(w=0;w<R;++w)l[w]=0;return-1}for(w=0;w<R;++w)l[w]=D[w+64];return F=R,F}function L(l,D){var R,o,w,F;for(o=63;o>=32;--o){R=0;for(w=o-32,F=o-12;w<F;++w)D[w]+=R-16*D[o]*S[w-(o-32)],R=D[w]+128>>8,D[w]-=R*256;D[w]+=R,D[o]=0}R=0;for(w=0;w<32;++w)D[w]+=R-(D[31]>>4)*S[w],R=D[w]>>8,D[w]&=255;for(w=0;w<32;++w)D[w]-=R*S[w];for(o=0;o<32;++o)D[o+1]+=D[o]>>8,l[o]=D[o]&255}function h(l){var D=new Float64Array(64);for(var R=0;R<64;++R)D[R]=l[R],l[R]=0;L(l,D)}function s(l,D){var R=Z(),o=Z(),w=Z(),F=Z(),K=Z(),Y=Z(),ie=Z(),oe=Z(),Q=Z();ee(R,l[1],l[0]),ee(Q,D[1],D[0]),de(R,R,Q),me(o,l[0],l[1]),me(Q,D[0],D[1]),de(o,o,Q),de(w,l[3],D[3]),de(w,w,T),de(F,l[2],D[2]),me(F,F,F),ee(K,o,R),ee(Y,F,w),me(ie,F,w),me(oe,o,R),de(l[0],K,Y),de(l[1],oe,ie),de(l[2],ie,Y),de(l[3],K,oe)}function i(l,D,R){for(var o=0;o<4;++o)Ie(l[o],D[o],R)}function B(l,D){var R=Z(),o=Z(),w=Z();fe(w,D[2]),de(R,D[0],w),de(o,D[1],w),P(l,o),l[31]^=X(R)<<7}function P(l,D){var R,o,w,F=Z(),K=Z();for(R=0;R<16;++R)K[R]=D[R];ve(K),ve(K),ve(K);for(o=0;o<2;++o){F[0]=K[0]-65517;for(R=1;R<15;++R)F[R]=K[R]-65535-(F[R-1]>>16&1),F[R-1]&=65535;F[15]=K[15]-32767-(F[14]>>16&1),w=F[15]>>16&1,F[14]&=65535,Ie(K,F,1-w)}for(R=0;R<16;R++)l[2*R]=K[R]&255,l[2*R+1]=K[R]>>8}function O(l,D){var R=Z(),o=Z(),w=Z(),F=Z(),K=Z(),Y=Z(),ie=Z();if(se(l[2],I),V(l[1],D),Ae(w,l[1]),de(F,w,U),ee(w,w,l[2]),me(F,l[2],F),Ae(K,F),Ae(Y,K),de(ie,Y,K),de(R,ie,w),de(R,R,F),M(R,R),de(R,R,w),de(R,R,F),de(R,R,F),de(l[0],R,F),Ae(o,l[0]),de(o,o,F),G(o,w))de(l[0],l[0],E);if(Ae(o,l[0]),de(o,o,F),G(o,w))return-1;if(X(l[0])===D[31]>>7)ee(l[0],f,l[0]);return de(l[3],l[0],l[1]),0}function V(l,D){var R;for(R=0;R<16;++R)l[R]=D[2*R]+(D[2*R+1]<<8);l[15]&=32767}function M(l,D){var R=Z(),o;for(o=0;o<16;++o)R[o]=D[o];for(o=250;o>=0;--o)if(Ae(R,R),o!==1)de(R,R,D);for(o=0;o<16;++o)l[o]=R[o]}function G(l,D){var R=new u(32),o=new u(32);return P(R,l),P(o,D),q(R,0,o,0)}function q(l,D,R,o){return H(l,D,R,o,32)}function H(l,D,R,o,w){var F,K=0;for(F=0;F<w;++F)K|=l[D+F]^R[o+F];return(1&K-1>>>8)-1}function X(l){var D=new u(32);return P(D,l),D[0]&1}function J(l,D,R){var o,w;se(l[0],f),se(l[1],I),se(l[2],I),se(l[3],f);for(w=255;w>=0;--w)o=R[w/8|0]>>(w&7)&1,i(l,D,o),s(D,l),s(l,l),i(l,D,o)}function te(l,D){var R=[Z(),Z(),Z(),Z()];se(R[0],c),se(R[1],m),se(R[2],I),de(R[3],c,m),J(l,R,D)}function se(l,D){var R;for(R=0;R<16;R++)l[R]=D[R]|0}function fe(l,D){var R=Z(),o;for(o=0;o<16;++o)R[o]=D[o];for(o=253;o>=0;--o)if(Ae(R,R),o!==2&&o!==4)de(R,R,D);for(o=0;o<16;++o)l[o]=R[o]}function ve(l){var D,R,o=1;for(D=0;D<16;++D)R=l[D]+o+65535,o=Math.floor(R/65536),l[D]=R-o*65536;l[0]+=o-1+37*(o-1)}function Ie(l,D,R){var o,w=~(R-1);for(var F=0;F<16;++F)o=w&(l[F]^D[F]),l[F]^=o,D[F]^=o}function Z(l){var D,R=new Float64Array(16);if(l)for(D=0;D<l.length;++D)R[D]=l[D];return R}function me(l,D,R){for(var o=0;o<16;++o)l[o]=D[o]+R[o]}function ee(l,D,R){for(var o=0;o<16;++o)l[o]=D[o]-R[o]}function Ae(l,D){de(l,D,D)}function de(l,D,R){var o,w,F=0,K=0,Y=0,ie=0,oe=0,Q=0,ae=0,ue=0,ge=0,he=0,be=0,ke=0,we=0,Be=0,Se=0,Te=0,Le=0,We=0,De=0,Ze=0,$e=0,Je=0,et=0,it=0,ct=0,ht=0,gt=0,Et=0,bt=0,Dt=0,jt=0,Ue=R[0],Ve=R[1],Pe=R[2],xe=R[3],Ke=R[4],Oe=R[5],Me=R[6],Fe=R[7],je=R[8],Ge=R[9],qe=R[10],He=R[11],Qe=R[12],ze=R[13],Ne=R[14],Re=R[15];o=D[0],F+=o*Ue,K+=o*Ve,Y+=o*Pe,ie+=o*xe,oe+=o*Ke,Q+=o*Oe,ae+=o*Me,ue+=o*Fe,ge+=o*je,he+=o*Ge,be+=o*qe,ke+=o*He,we+=o*Qe,Be+=o*ze,Se+=o*Ne,Te+=o*Re,o=D[1],K+=o*Ue,Y+=o*Ve,ie+=o*Pe,oe+=o*xe,Q+=o*Ke,ae+=o*Oe,ue+=o*Me,ge+=o*Fe,he+=o*je,be+=o*Ge,ke+=o*qe,we+=o*He,Be+=o*Qe,Se+=o*ze,Te+=o*Ne,Le+=o*Re,o=D[2],Y+=o*Ue,ie+=o*Ve,oe+=o*Pe,Q+=o*xe,ae+=o*Ke,ue+=o*Oe,ge+=o*Me,he+=o*Fe,be+=o*je,ke+=o*Ge,we+=o*qe,Be+=o*He,Se+=o*Qe,Te+=o*ze,Le+=o*Ne,We+=o*Re,o=D[3],ie+=o*Ue,oe+=o*Ve,Q+=o*Pe,ae+=o*xe,ue+=o*Ke,ge+=o*Oe,he+=o*Me,be+=o*Fe,ke+=o*je,we+=o*Ge,Be+=o*qe,Se+=o*He,Te+=o*Qe,Le+=o*ze,We+=o*Ne,De+=o*Re,o=D[4],oe+=o*Ue,Q+=o*Ve,ae+=o*Pe,ue+=o*xe,ge+=o*Ke,he+=o*Oe,be+=o*Me,ke+=o*Fe,we+=o*je,Be+=o*Ge,Se+=o*qe,Te+=o*He,Le+=o*Qe,We+=o*ze,De+=o*Ne,Ze+=o*Re,o=D[5],Q+=o*Ue,ae+=o*Ve,ue+=o*Pe,ge+=o*xe,he+=o*Ke,be+=o*Oe,ke+=o*Me,we+=o*Fe,Be+=o*je,Se+=o*Ge,Te+=o*qe,Le+=o*He,We+=o*Qe,De+=o*ze,Ze+=o*Ne,$e+=o*Re,o=D[6],ae+=o*Ue,ue+=o*Ve,ge+=o*Pe,he+=o*xe,be+=o*Ke,ke+=o*Oe,we+=o*Me,Be+=o*Fe,Se+=o*je,Te+=o*Ge,Le+=o*qe,We+=o*He,De+=o*Qe,Ze+=o*ze,$e+=o*Ne,Je+=o*Re,o=D[7],ue+=o*Ue,ge+=o*Ve,he+=o*Pe,be+=o*xe,ke+=o*Ke,we+=o*Oe,Be+=o*Me,Se+=o*Fe,Te+=o*je,Le+=o*Ge,We+=o*qe,De+=o*He,Ze+=o*Qe,$e+=o*ze,Je+=o*Ne,et+=o*Re,o=D[8],ge+=o*Ue,he+=o*Ve,be+=o*Pe,ke+=o*xe,we+=o*Ke,Be+=o*Oe,Se+=o*Me,Te+=o*Fe,Le+=o*je,We+=o*Ge,De+=o*qe,Ze+=o*He,$e+=o*Qe,Je+=o*ze,et+=o*Ne,it+=o*Re,o=D[9],he+=o*Ue,be+=o*Ve,ke+=o*Pe,we+=o*xe,Be+=o*Ke,Se+=o*Oe,Te+=o*Me,Le+=o*Fe,We+=o*je,De+=o*Ge,Ze+=o*qe,$e+=o*He,Je+=o*Qe,et+=o*ze,it+=o*Ne,ct+=o*Re,o=D[10],be+=o*Ue,ke+=o*Ve,we+=o*Pe,Be+=o*xe,Se+=o*Ke,Te+=o*Oe,Le+=o*Me,We+=o*Fe,De+=o*je,Ze+=o*Ge,$e+=o*qe,Je+=o*He,et+=o*Qe,it+=o*ze,ct+=o*Ne,ht+=o*Re,o=D[11],ke+=o*Ue,we+=o*Ve,Be+=o*Pe,Se+=o*xe,Te+=o*Ke,Le+=o*Oe,We+=o*Me,De+=o*Fe,Ze+=o*je,$e+=o*Ge,Je+=o*qe,et+=o*He,it+=o*Qe,ct+=o*ze,ht+=o*Ne,gt+=o*Re,o=D[12],we+=o*Ue,Be+=o*Ve,Se+=o*Pe,Te+=o*xe,Le+=o*Ke,We+=o*Oe,De+=o*Me,Ze+=o*Fe,$e+=o*je,Je+=o*Ge,et+=o*qe,it+=o*He,ct+=o*Qe,ht+=o*ze,gt+=o*Ne,Et+=o*Re,o=D[13],Be+=o*Ue,Se+=o*Ve,Te+=o*Pe,Le+=o*xe,We+=o*Ke,De+=o*Oe,Ze+=o*Me,$e+=o*Fe,Je+=o*je,et+=o*Ge,it+=o*qe,ct+=o*He,ht+=o*Qe,gt+=o*ze,Et+=o*Ne,bt+=o*Re,o=D[14],Se+=o*Ue,Te+=o*Ve,Le+=o*Pe,We+=o*xe,De+=o*Ke,Ze+=o*Oe,$e+=o*Me,Je+=o*Fe,et+=o*je,it+=o*Ge,ct+=o*qe,ht+=o*He,gt+=o*Qe,Et+=o*ze,bt+=o*Ne,Dt+=o*Re,o=D[15],Te+=o*Ue,Le+=o*Ve,We+=o*Pe,De+=o*xe,Ze+=o*Ke,$e+=o*Oe,Je+=o*Me,et+=o*Fe,it+=o*je,ct+=o*Ge,ht+=o*qe,gt+=o*He,Et+=o*Qe,bt+=o*ze,Dt+=o*Ne,jt+=o*Re,F+=38*Le,K+=38*We,Y+=38*De,ie+=38*Ze,oe+=38*$e,Q+=38*Je,ae+=38*et,ue+=38*it,ge+=38*ct,he+=38*ht,be+=38*gt,ke+=38*Et,we+=38*bt,Be+=38*Dt,Se+=38*jt,w=1,o=F+w+65535,w=Math.floor(o/65536),F=o-w*65536,o=K+w+65535,w=Math.floor(o/65536),K=o-w*65536,o=Y+w+65535,w=Math.floor(o/65536),Y=o-w*65536,o=ie+w+65535,w=Math.floor(o/65536),ie=o-w*65536,o=oe+w+65535,w=Math.floor(o/65536),oe=o-w*65536,o=Q+w+65535,w=Math.floor(o/65536),Q=o-w*65536,o=ae+w+65535,w=Math.floor(o/65536),ae=o-w*65536,o=ue+w+65535,w=Math.floor(o/65536),ue=o-w*65536,o=ge+w+65535,w=Math.floor(o/65536),ge=o-w*65536,o=he+w+65535,w=Math.floor(o/65536),he=o-w*65536,o=be+w+65535,w=Math.floor(o/65536),be=o-w*65536,o=ke+w+65535,w=Math.floor(o/65536),ke=o-w*65536,o=we+w+65535,w=Math.floor(o/65536),we=o-w*65536,o=Be+w+65535,w=Math.floor(o/65536),Be=o-w*65536,o=Se+w+65535,w=Math.floor(o/65536),Se=o-w*65536,o=Te+w+65535,w=Math.floor(o/65536),Te=o-w*65536,F+=w-1+37*(w-1),w=1,o=F+w+65535,w=Math.floor(o/65536),F=o-w*65536,o=K+w+65535,w=Math.floor(o/65536),K=o-w*65536,o=Y+w+65535,w=Math.floor(o/65536),Y=o-w*65536,o=ie+w+65535,w=Math.floor(o/65536),ie=o-w*65536,o=oe+w+65535,w=Math.floor(o/65536),oe=o-w*65536,o=Q+w+65535,w=Math.floor(o/65536),Q=o-w*65536,o=ae+w+65535,w=Math.floor(o/65536),ae=o-w*65536,o=ue+w+65535,w=Math.floor(o/65536),ue=o-w*65536,o=ge+w+65535,w=Math.floor(o/65536),ge=o-w*65536,o=he+w+65535,w=Math.floor(o/65536),he=o-w*65536,o=be+w+65535,w=Math.floor(o/65536),be=o-w*65536,o=ke+w+65535,w=Math.floor(o/65536),ke=o-w*65536,o=we+w+65535,w=Math.floor(o/65536),we=o-w*65536,o=Be+w+65535,w=Math.floor(o/65536),Be=o-w*65536,o=Se+w+65535,w=Math.floor(o/65536),Se=o-w*65536,o=Te+w+65535,w=Math.floor(o/65536),Te=o-w*65536,F+=w-1+37*(w-1),l[0]=F,l[1]=K,l[2]=Y,l[3]=ie,l[4]=oe,l[5]=Q,l[6]=ae,l[7]=ue,l[8]=ge,l[9]=he,l[10]=be,l[11]=ke,l[12]=we,l[13]=Be,l[14]=Se,l[15]=Te}}),qi=le((N,_)=>{var t=pe();Ce(),ot(),Xt(),_.exports=t.kem=t.kem||{};var e=t.jsbn.BigInteger;t.kem.rsa={},t.kem.rsa.create=function(d,v){v=v||{};var g=v.prng||t.random,u={};return u.encrypt=function(r,C){var f=Math.ceil(r.n.bitLength()/8),I;do I=new e(t.util.bytesToHex(g.getBytesSync(f)),16).mod(r.n);while(I.compareTo(e.ONE)<=0);I=t.util.hexToBytes(I.toString(16));var U=f-I.length;if(U>0)I=t.util.fillString(String.fromCharCode(0),U)+I;var T=r.encrypt(I,"NONE"),c=d.generate(I,C);return{encapsulation:T,key:c}},u.decrypt=function(r,C,f){var I=r.decrypt(C,"NONE");return d.generate(I,f)},u},t.kem.kdf1=function(d,v){a(this,d,0,v||d.digestLength)},t.kem.kdf2=function(d,v){a(this,d,1,v||d.digestLength)};function a(d,v,g,u){d.generate=function(r,C){var f=new t.util.ByteBuffer,I=Math.ceil(C/u)+g,U=new t.util.ByteBuffer;for(var T=g;T<I;++T){U.putInt32(T),v.start(),v.update(r+U.getBytes());var c=v.digest();f.putBytes(c.getBytes(u))}return f.truncate(f.length()-C),f.getBytes()}}}),Hi=le((N,_)=>{var t=pe();Ce(),_.exports=t.log=t.log||{},t.log.levels=["none","error","warning","info","debug","verbose","max"];var e={},a=[],d=null;t.log.LEVEL_LOCKED=2,t.log.NO_LEVEL_CHECK=4,t.log.INTERPOLATE=8;for(u=0;u<t.log.levels.length;++u)v=t.log.levels[u],e[v]={index:u,name:v.toUpperCase()};var v,u;t.log.logMessage=function(T){var c=e[T.level].index;for(var m=0;m<a.length;++m){var S=a[m];if(S.flags&t.log.NO_LEVEL_CHECK)S.f(T);else{var E=e[S.level].index;if(c<=E)S.f(S,T)}}},t.log.prepareStandard=function(T){if(!("standard"in T))T.standard=e[T.level].name+" ["+T.category+"] "+T.message},t.log.prepareFull=function(T){if(!("full"in T)){var c=[T.message];c=c.concat([]),T.full=t.util.format.apply(this,c)}},t.log.prepareStandardFull=function(T){if(!("standardFull"in T))t.log.prepareStandard(T),T.standardFull=T.standard},g=["error","warning","info","debug","verbose"];for(u=0;u<g.length;++u)(function(T){t.log[T]=function(c,m){var S=Array.prototype.slice.call(arguments).slice(2),E={timestamp:new Date,level:T,category:c,message:m,arguments:S};t.log.logMessage(E)}})(g[u]);var g,u;if(t.log.makeLogger=function(T){var c={flags:0,f:T};return t.log.setLevel(c,"none"),c},t.log.setLevel=function(T,c){var m=!1;if(T&&!(T.flags&t.log.LEVEL_LOCKED))for(var S=0;S<t.log.levels.length;++S){var E=t.log.levels[S];if(c==E){T.level=c,m=!0;break}}return m},t.log.lock=function(T,c){if(typeof c==="undefined"||c)T.flags|=t.log.LEVEL_LOCKED;else T.flags&=~t.log.LEVEL_LOCKED},t.log.addLogger=function(T){a.push(T)},typeof console!=="undefined"&&"log"in console){if(console.error&&console.warn&&console.info&&console.debug)C={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},f=function(T,c){t.log.prepareStandard(c);var m=C[c.level],S=[c.standard];S=S.concat(c.arguments.slice()),m.apply(console,S)},r=t.log.makeLogger(f);else f=function(T,c){t.log.prepareStandardFull(c),console.log(c.standardFull)},r=t.log.makeLogger(f);t.log.setLevel(r,"debug"),t.log.addLogger(r),d=r}else console={log:function(){}};var r,C,f;if(d!==null&&typeof window!=="undefined"&&window.location){if(I=new URL(window.location.href).searchParams,I.has("console.level"))t.log.setLevel(d,I.get("console.level").slice(-1)[0]);if(I.has("console.lock")){if(U=I.get("console.lock").slice(-1)[0],U=="true")t.log.lock(d)}}var I,U;t.log.consoleLogger=d}),Qi=le((N,_)=>{_.exports=yt(),lr(),Mt(),Mr(),Zr()}),zi=le((N,_)=>{var t=pe();Tt(),ut(),Yt(),It(),Rt(),Qr(),ot(),Ce(),pr();var e=t.asn1,a=_.exports=t.pkcs7=t.pkcs7||{};a.messageFromPem=function(c){var m=t.pem.decode(c)[0];if(m.type!=="PKCS7"){var S=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw S.headerType=m.type,S}if(m.procType&&m.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var E=e.fromDer(m.body);return a.messageFromAsn1(E)},a.messageToPem=function(c,m){var S={type:"PKCS7",body:e.toDer(c.toAsn1()).getBytes()};return t.pem.encode(S,{maxline:m})},a.messageFromAsn1=function(c){var m={},S=[];if(!e.validate(c,a.asn1.contentInfoValidator,m,S)){var E=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw E.errors=S,E}var n=e.derToOid(m.contentType),p;switch(n){case t.pki.oids.envelopedData:p=a.createEnvelopedData();break;case t.pki.oids.encryptedData:p=a.createEncryptedData();break;case t.pki.oids.signedData:p=a.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+n+" is not (yet) supported.")}return p.fromAsn1(m.content.value[0]),p},a.createSignedData=function(){var c=null;return c={type:t.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(E){if(U(c,E,a.asn1.signedDataValidator),c.certificates=[],c.crls=[],c.digestAlgorithmIdentifiers=[],c.contentInfo=null,c.signerInfos=[],c.rawCapture.certificates){var n=c.rawCapture.certificates.value;for(var p=0;p<n.length;++p)c.certificates.push(t.pki.certificateFromAsn1(n[p]))}},toAsn1:function(){if(!c.contentInfo)c.sign();var E=[];for(var n=0;n<c.certificates.length;++n)E.push(t.pki.certificateToAsn1(c.certificates[n]));var p=[],y=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,c.digestAlgorithmIdentifiers),c.contentInfo])]);if(E.length>0)y.value[0].value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,E));if(p.length>0)y.value[0].value.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,p));return y.value[0].value.push(e.create(e.Class.UNIVERSAL,e.Type.SET,!0,c.signerInfos)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.type).getBytes()),y])},addSigner:function(E){var{issuer:n,serialNumber:p}=E;if(E.certificate){var y=E.certificate;if(typeof y==="string")y=t.pki.certificateFromPem(y);n=y.issuer.attributes,p=y.serialNumber}var b=E.key;if(!b)throw new Error("Could not add PKCS#7 signer; no private key specified.");if(typeof b==="string")b=t.pki.privateKeyFromPem(b);var L=E.digestAlgorithm||t.pki.oids.sha1;switch(L){case t.pki.oids.sha1:case t.pki.oids.sha256:case t.pki.oids.sha384:case t.pki.oids.sha512:case t.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+L)}var h=E.authenticatedAttributes||[];if(h.length>0){var s=!1,i=!1;for(var B=0;B<h.length;++B){var P=h[B];if(!s&&P.type===t.pki.oids.contentType){if(s=!0,i)break;continue}if(!i&&P.type===t.pki.oids.messageDigest){if(i=!0,s)break;continue}}if(!s||!i)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}c.signers.push({key:b,version:1,issuer:n,serialNumber:p,digestAlgorithm:L,signatureAlgorithm:t.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:h,unauthenticatedAttributes:[]})},sign:function(E){if(E=E||{},typeof c.content!=="object"||c.contentInfo===null){if(c.contentInfo=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.pki.oids.data).getBytes())]),"content"in c){var n;if(c.content instanceof t.util.ByteBuffer)n=c.content.bytes();else if(typeof c.content==="string")n=t.util.encodeUtf8(c.content);if(E.detached)c.detachedContent=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,n);else c.contentInfo.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,n)]))}}if(c.signers.length===0)return;var p=m();S(p)},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(E){if(typeof E==="string")E=t.pki.certificateFromPem(E);c.certificates.push(E)},addCertificateRevokationList:function(E){throw new Error("PKCS#7 CRL support not yet implemented.")}},c;function m(){var E={};for(var n=0;n<c.signers.length;++n){var p=c.signers[n],y=p.digestAlgorithm;if(!(y in E))E[y]=t.md[t.pki.oids[y]].create();if(p.authenticatedAttributes.length===0)p.md=E[y];else p.md=t.md[t.pki.oids[y]].create()}c.digestAlgorithmIdentifiers=[];for(var y in E)c.digestAlgorithmIdentifiers.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(y).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]));return E}function S(E){var n;if(c.detachedContent)n=c.detachedContent;else n=c.contentInfo.value[1],n=n.value[0];if(!n)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var p=e.derToOid(c.contentInfo.value[0].value),y=e.toDer(n);y.getByte(),e.getBerValueLength(y),y=y.getBytes();for(var b in E)E[b].start().update(y);var L=new Date;for(var h=0;h<c.signers.length;++h){var s=c.signers[h];if(s.authenticatedAttributes.length===0){if(p!==t.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{s.authenticatedAttributesAsn1=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);var i=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[]);for(var B=0;B<s.authenticatedAttributes.length;++B){var P=s.authenticatedAttributes[B];if(P.type===t.pki.oids.messageDigest)P.value=E[s.digestAlgorithm].digest();else if(P.type===t.pki.oids.signingTime){if(!P.value)P.value=L}i.value.push(f(P)),s.authenticatedAttributesAsn1.value.push(f(P))}y=e.toDer(i).getBytes(),s.md.start().update(y)}s.signature=s.key.sign(s.md,"RSASSA-PKCS1-V1_5")}c.signerInfos=C(c.signers)}},a.createEncryptedData=function(){var c=null;return c={type:t.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:t.pki.oids["aes256-CBC"]},fromAsn1:function(m){U(c,m,a.asn1.encryptedDataValidator)},decrypt:function(m){if(m!==void 0)c.encryptedContent.key=m;T(c)}},c},a.createEnvelopedData=function(){var c=null;return c={type:t.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:t.pki.oids["aes256-CBC"]},fromAsn1:function(m){var S=U(c,m,a.asn1.envelopedDataValidator);c.recipients=g(S.recipientInfos.value)},toAsn1:function(){return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.type).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,u(c.recipients)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,I(c.encryptedContent))])])])},findRecipient:function(m){var S=m.issuer.attributes;for(var E=0;E<c.recipients.length;++E){var n=c.recipients[E],p=n.issuer;if(n.serialNumber!==m.serialNumber)continue;if(p.length!==S.length)continue;var y=!0;for(var b=0;b<S.length;++b)if(p[b].type!==S[b].type||p[b].value!==S[b].value){y=!1;break}if(y)return n}return null},decrypt:function(m,S){if(c.encryptedContent.key===void 0&&m!==void 0&&S!==void 0)switch(m.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:case t.pki.oids.desCBC:var E=S.decrypt(m.encryptedContent.content);c.encryptedContent.key=t.util.createBuffer(E);break;default:throw new Error("Unsupported asymmetric cipher, OID "+m.encryptedContent.algorithm)}T(c)},addRecipient:function(m){c.recipients.push({version:0,issuer:m.issuer.attributes,serialNumber:m.serialNumber,encryptedContent:{algorithm:t.pki.oids.rsaEncryption,key:m.publicKey}})},encrypt:function(m,S){if(c.encryptedContent.content===void 0){S=S||c.encryptedContent.algorithm,m=m||c.encryptedContent.key;var E,n,p;switch(S){case t.pki.oids["aes128-CBC"]:E=16,n=16,p=t.aes.createEncryptionCipher;break;case t.pki.oids["aes192-CBC"]:E=24,n=16,p=t.aes.createEncryptionCipher;break;case t.pki.oids["aes256-CBC"]:E=32,n=16,p=t.aes.createEncryptionCipher;break;case t.pki.oids["des-EDE3-CBC"]:E=24,n=8,p=t.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+S)}if(m===void 0)m=t.util.createBuffer(t.random.getBytes(E));else if(m.length()!=E)throw new Error("Symmetric key has wrong length; got "+m.length()+" bytes, expected "+E+".");c.encryptedContent.algorithm=S,c.encryptedContent.key=m,c.encryptedContent.parameter=t.util.createBuffer(t.random.getBytes(n));var y=p(m);if(y.start(c.encryptedContent.parameter.copy()),y.update(c.content),!y.finish())throw new Error("Symmetric encryption failed.");c.encryptedContent.content=y.output}for(var b=0;b<c.recipients.length;++b){var L=c.recipients[b];if(L.encryptedContent.content!==void 0)continue;switch(L.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:L.encryptedContent.content=L.encryptedContent.key.encrypt(c.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+L.encryptedContent.algorithm)}}}},c};function d(c){var m={},S=[];if(!e.validate(c,a.asn1.recipientInfoValidator,m,S)){var E=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw E.errors=S,E}return{version:m.version.charCodeAt(0),issuer:t.pki.RDNAttributesAsArray(m.issuer),serialNumber:t.util.createBuffer(m.serial).toHex(),encryptedContent:{algorithm:e.derToOid(m.encAlgorithm),parameter:m.encParameter?m.encParameter.value:void 0,content:m.encKey}}}function v(c){return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[t.pki.distinguishedNameToAsn1({attributes:c.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(c.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.encryptedContent.algorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.encryptedContent.content)])}function g(c){var m=[];for(var S=0;S<c.length;++S)m.push(d(c[S]));return m}function u(c){var m=[];for(var S=0;S<c.length;++S)m.push(v(c[S]));return m}function r(c){var m=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[t.pki.distinguishedNameToAsn1({attributes:c.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(c.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.digestAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])]);if(c.authenticatedAttributesAsn1)m.value.push(c.authenticatedAttributesAsn1);if(m.value.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.signatureAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])),m.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.signature)),c.unauthenticatedAttributes.length>0){var S=e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[]);for(var E=0;E<c.unauthenticatedAttributes.length;++E){var n=c.unauthenticatedAttributes[E];S.values.push(f(n))}m.value.push(S)}return m}function C(c){var m=[];for(var S=0;S<c.length;++S)m.push(r(c[S]));return m}function f(c){var m;if(c.type===t.pki.oids.contentType)m=e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.value).getBytes());else if(c.type===t.pki.oids.messageDigest)m=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.value.bytes());else if(c.type===t.pki.oids.signingTime){var S=new Date("1950-01-01T00:00:00Z"),E=new Date("2050-01-01T00:00:00Z"),n=c.value;if(typeof n==="string"){var p=Date.parse(n);if(!isNaN(p))n=new Date(p);else if(n.length===13)n=e.utcTimeToDate(n);else n=e.generalizedTimeToDate(n)}if(n>=S&&n<E)m=e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(n));else m=e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(n))}return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[m])])}function I(c){return[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.pki.oids.data).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.algorithm).getBytes()),!c.parameter?void 0:e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.parameter.getBytes())]),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.content.getBytes())])]}function U(c,m,S){var E={},n=[];if(!e.validate(m,S,E,n)){var p=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw p.errors=p,p}var y=e.derToOid(E.contentType);if(y!==t.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(E.encryptedContent){var b="";if(t.util.isArray(E.encryptedContent))for(var L=0;L<E.encryptedContent.length;++L){if(E.encryptedContent[L].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");b+=E.encryptedContent[L].value}else b=E.encryptedContent;c.encryptedContent={algorithm:e.derToOid(E.encAlgorithm),parameter:t.util.createBuffer(E.encParameter.value),content:t.util.createBuffer(b)}}if(E.content){var b="";if(t.util.isArray(E.content))for(var L=0;L<E.content.length;++L){if(E.content[L].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");b+=E.content[L].value}else b=E.content;c.content=t.util.createBuffer(b)}return c.version=E.version.charCodeAt(0),c.rawCapture=E,E}function T(c){if(c.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(c.content===void 0){var m;switch(c.encryptedContent.algorithm){case t.pki.oids["aes128-CBC"]:case t.pki.oids["aes192-CBC"]:case t.pki.oids["aes256-CBC"]:m=t.aes.createDecryptionCipher(c.encryptedContent.key);break;case t.pki.oids.desCBC:case t.pki.oids["des-EDE3-CBC"]:m=t.des.createDecryptionCipher(c.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+c.encryptedContent.algorithm)}if(m.start(c.encryptedContent.parameter),m.update(c.encryptedContent.content),!m.finish())throw new Error("Symmetric decryption failed.");c.content=m.output}}}),Yi=le((N,_)=>{var t=pe();Tt(),Ot(),lr(),Mt(),Ce();var e=_.exports=t.ssh=t.ssh||{};e.privateKeyToPutty=function(g,u,r){r=r||"",u=u||"";var C="ssh-rsa",f=u===""?"none":"aes256-cbc",I="PuTTY-User-Key-File-2: "+C+`\r
|
|
27
|
-
`;I+="Encryption: "+f+`\r
|
|
28
|
-
`,I+="Comment: "+r+`\r
|
|
29
|
-
`;var U=t.util.createBuffer();d(U,C),a(U,g.e),a(U,g.n);var T=t.util.encode64(U.bytes(),64),c=Math.floor(T.length/66)+1;I+="Public-Lines: "+c+`\r
|
|
30
|
-
`,I+=T;var m=t.util.createBuffer();a(m,g.d),a(m,g.p),a(m,g.q),a(m,g.qInv);var S;if(!u)S=t.util.encode64(m.bytes(),64);else{var E=m.length()+16-1;E-=E%16;var n=v(m.bytes());n.truncate(n.length()-E+m.length()),m.putBuffer(n);var p=t.util.createBuffer();p.putBuffer(v("\x00\x00\x00\x00",u)),p.putBuffer(v("\x00\x00\x00\x01",u));var y=t.aes.createEncryptionCipher(p.truncate(8),"CBC");y.start(t.util.createBuffer().fillWithByte(0,16)),y.update(m.copy()),y.finish();var b=y.output;b.truncate(16),S=t.util.encode64(b.bytes(),64)}c=Math.floor(S.length/66)+1,I+=`\r
|
|
31
|
-
Private-Lines: `+c+`\r
|
|
32
|
-
`,I+=S;var L=v("putty-private-key-file-mac-key",u),h=t.util.createBuffer();d(h,C),d(h,f),d(h,r),h.putInt32(U.length()),h.putBuffer(U),h.putInt32(m.length()),h.putBuffer(m);var s=t.hmac.create();return s.start("sha1",L),s.update(h.bytes()),I+=`\r
|
|
33
|
-
Private-MAC: `+s.digest().toHex()+`\r
|
|
34
|
-
`,I},e.publicKeyToOpenSSH=function(g,u){var r="ssh-rsa";u=u||"";var C=t.util.createBuffer();return d(C,r),a(C,g.e),a(C,g.n),r+" "+t.util.encode64(C.bytes())+" "+u},e.privateKeyToOpenSSH=function(g,u){if(!u)return t.pki.privateKeyToPem(g);return t.pki.encryptRsaPrivateKey(g,u,{legacy:!0,algorithm:"aes128"})},e.getPublicKeyFingerprint=function(g,u){u=u||{};var r=u.md||t.md.md5.create(),C="ssh-rsa",f=t.util.createBuffer();d(f,C),a(f,g.e),a(f,g.n),r.start(),r.update(f.getBytes());var I=r.digest();if(u.encoding==="hex"){var U=I.toHex();if(u.delimiter)return U.match(/.{2}/g).join(u.delimiter);return U}else if(u.encoding==="binary")return I.getBytes();else if(u.encoding)throw new Error('Unknown encoding "'+u.encoding+'".');return I};function a(g,u){var r=u.toString(16);if(r[0]>="8")r="00"+r;var C=t.util.hexToBytes(r);g.putInt32(C.length),g.putBytes(C)}function d(g,u){g.putInt32(u.length),g.putString(u)}function v(){var g=t.md.sha1.create(),u=arguments.length;for(var r=0;r<u;++r)g.update(arguments[r]);return g.digest()}}),$r=le((N,_)=>{_.exports=pe(),Tt(),Fi(),ut(),ur(),Yt(),Gi(),Ot(),qi(),Hi(),Qi(),zr(),fr(),Rt(),Gr(),Yr(),zi(),Xr(),qr(),Fr(),hr(),ot(),jr(),Yi(),Wr(),Ce()});function or(N,_){if(Array.isArray(_)&&!Array.isArray(N))return _;if(Array.isArray(_)&&Array.isArray(N))return _.map((e,a)=>{let d=N[a];if(wt(e)&&wt(d))return or(d,e);return e});if(!wt(_)||!wt(N))return _;let t={...N};for(let e in _)if(Object.prototype.hasOwnProperty.call(_,e)){let a=_[e],d=t[e];if(a===null||a===void 0)t[e]=a;else if(wt(a)&&wt(d))t[e]=or(d,a);else t[e]=a}return t}function wt(N){return Boolean(N&&typeof N==="object"&&!Array.isArray(N))}async function Zi({name:N,cwd:_,defaultConfig:t}){let e=Xi(_||Wi.cwd(),`${N}.config`);try{let a=await import(e),d=a.default||a;return or(t,d)}catch(a){return t}}var Jr={altNameIPs:["127.0.0.1"],altNameURIs:["localhost"],organizationName:"Local Development",countryName:"US",stateName:"California",localityName:"Playa Vista",commonName:"stacks.localhost",validityDays:825,hostCertCN:"stacks.localhost",domain:"stacks.localhost",rootCA:{certificate:"",privateKey:""},basePath:"",caCertPath:sr.join(nr.homedir(),".stacks","ssl","stacks.localhost.ca.crt"),certPath:sr.join(nr.homedir(),".stacks","ssl","stacks.localhost.crt"),keyPath:sr.join(nr.homedir(),".stacks","ssl","stacks.localhost.crt.key"),verbose:!1},_e=await Zi({name:"tls",defaultConfig:Jr}),Ya=cr($r(),1);function ei(N){let _=Number.parseInt(N[0],16);if(_<8)return N;return _-=8,_.toString()+N.substring(1)}function ti(N,_){let t=[];function e(a){try{let d=Pr.readdirSync(a);for(let v of d){let g=Ji.join(a,v);if(Pr.lstatSync(g).isDirectory())e(g);else if(v===_)t.push(a)}}catch(d){console.warn(`Error reading directory ${a}: ${d}`)}}return e(N),t}function ye(N,_,t){if(t||_e.verbose)console.debug(`[tlsx:${N}] ${_}`)}var ra=ta($i);async function Kt(N,_={}){try{let{stdout:t,stderr:e}=await ra(N,{cwd:_.cwd||ea.cwd(),timeout:_.timeout||30000});return{stdout:t.trim(),stderr:e.trim()}}catch(t){let e=new Error(`Failed to execute command: ${N}
|
|
35
|
-
Error: ${t.message}`);throw e.stack=t.stack,e}}var Xe=cr($r(),1);function dr(N){ye("cert","Generating random serial number",N);let _=ei(Xe.default.util.bytesToHex(Xe.default.random.getBytesSync(20)));return ye("cert",`Generated serial number: ${_}`,N),_}function yr(N){let _=N.notBeforeDays??2,t=N.validityDays??(N.validityYears?N.validityYears*365:180);ye("cert","Calculating certificate validity dates",N.verbose);let e=new Date(Date.now()-86400*_*1000),a=new Date(e.getTime()+t*24*60*60*1000);return e.setUTCHours(0,0,0,0),a.setUTCHours(23,59,59,999),ye("cert",`Validity period: ${e.toISOString()} to ${a.toISOString()}`,N.verbose),{notBefore:e,notAfter:a}}function ia(N){let _=[];if(_.push({name:"basicConstraints",cA:N.isCA??!1,critical:!0,...N.basicConstraints||{}}),N.keyUsage)_.push({name:"keyUsage",critical:!0,...N.keyUsage});if(N.extKeyUsage)_.push({name:"extKeyUsage",...N.extKeyUsage});if(N.subjectAltNames&&N.subjectAltNames.length>0)_.push({name:"subjectAltName",altNames:N.subjectAltNames});return _}async function gr(N={}){ye("ca","Creating new Root CA Certificate",N.verbose);let _=N.keySize||2048;ye("ca",`Generating ${_}-bit RSA key pair`,N.verbose);let{privateKey:t,publicKey:e}=Xe.pki.rsa.generateKeyPair(_),a=[{shortName:"C",value:N.countryName||_e.countryName},{shortName:"ST",value:N.stateName||_e.stateName},{shortName:"L",value:N.localityName||_e.localityName},{shortName:"O",value:N.organization||"Local Development CA"},{shortName:"OU",value:N.organizationalUnit||"Certificate Authority"},{shortName:"CN",value:N.commonName||"Local Development Root CA"},...N.extraAttributes||[]],{notBefore:d,notAfter:v}=yr({validityYears:N.validityYears||100,verbose:N.verbose}),g=Xe.pki.createCertificate();return g.publicKey=e,g.serialNumber=dr(N.verbose),g.validity.notBefore=d,g.validity.notAfter=v,g.setSubject(a),g.setIssuer(a),g.setExtensions([{name:"basicConstraints",cA:!0,critical:!0},{name:"keyUsage",keyCertSign:!0,cRLSign:!0,critical:!0},{name:"subjectKeyIdentifier"}]),g.sign(t,Xe.default.md.sha256.create()),{certificate:Xe.pki.certificateToPem(g),privateKey:Xe.pki.privateKeyToPem(t),notBefore:d,notAfter:v}}async function vr(N){if(ye("cert","Generating new certificate",N.verbose),ye("cert",`Options: ${JSON.stringify(N)}`,N.verbose),!N.rootCA?.certificate||!N.rootCA?.privateKey)throw new Error("Root CA certificate and private key are required");let _=Xe.pki.certificateFromPem(N.rootCA.certificate),t=Xe.pki.privateKeyFromPem(N.rootCA.privateKey);ye("cert","Generating 2048-bit RSA key pair for host certificate",N.verbose);let e=2048,{privateKey:a,publicKey:d}=Xe.pki.rsa.generateKeyPair(e),v=N.certificateAttributes||[{shortName:"C",value:N.countryName||_e.countryName},{shortName:"ST",value:N.stateName||_e.stateName},{shortName:"L",value:N.localityName||_e.localityName},{shortName:"O",value:N.organizationName||_e.organizationName},{shortName:"CN",value:N.commonName||_e.commonName}],{notBefore:g,notAfter:u}=yr({validityDays:N.validityDays,verbose:N.verbose}),r=Xe.pki.createCertificate();return r.publicKey=d,r.serialNumber=dr(N.verbose),r.validity.notBefore=g,r.validity.notAfter=u,r.setSubject(v),r.setIssuer(_.subject.attributes),r.setExtensions(ia(N)),r.sign(t,Xe.default.md.sha256.create()),{certificate:Xe.pki.certificateToPem(r),privateKey:Xe.pki.privateKeyToPem(a),notBefore:g,notAfter:u}}async function mr(N,_,t){ye("trust",`Adding certificate to system trust store with options: ${JSON.stringify(t)}`,t?.verbose),ye("trust","Storing certificate and private key",t?.verbose);let e=ri(N,t);ye("trust","Storing CA certificate",t?.verbose);let a=ii(_,t),d=xr.platform();ye("trust",`Detected platform: ${d}`,t?.verbose);let v="TC, C, C";if(d==="darwin")ye("trust","Adding certificate to macOS keychain",t?.verbose),await Kt(`sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${a}`);else if(d==="win32")ye("trust","Adding certificate to Windows certificate store",t?.verbose),await Kt(`certutil -f -v -addstore -enterprise Root ${a}`);else if(d==="linux"){ye("trust","Adding certificate to Linux certificate store",t?.verbose);let g=xr.homedir(),u="cert9.db";ye("trust",`Searching for certificate databases in ${g}`,t?.verbose);let r=ti(g,u);for(let C of r){ye("trust",`Processing certificate database in ${C}`,t?.verbose);try{ye("trust",`Attempting to delete existing cert for ${_e.commonName}`,t?.verbose),await Kt(`certutil -d sql:${C} -D -n ${_e.commonName}`)}catch(f){ye("trust",`Warning: Error deleting existing cert: ${f}`,t?.verbose),console.warn(`Error deleting existing cert: ${f}`)}ye("trust",`Adding new certificate to ${C}`,t?.verbose),await Kt(`certutil -d sql:${C} -A -t ${v} -n ${_e.commonName} -i ${a}`),Kr.info(`Cert added to ${C}`)}}else throw ye("trust",`Error: Unsupported platform ${d}`,t?.verbose),new Error(`Unsupported platform: ${d}`);return ye("trust","Certificate successfully added to system trust store",t?.verbose),e}function ri(N,_){ye("storage",`Storing certificate and private key with options: ${JSON.stringify(_)}`,_?.verbose);let t=kt.join(_?.basePath||_e.basePath,_?.certPath||_e.certPath),e=kt.join(_?.basePath||_e.basePath,_?.keyPath||_e.keyPath);ye("storage",`Certificate path: ${t}`,_?.verbose),ye("storage",`Private key path: ${e}`,_?.verbose);let a=kt.dirname(t);if(!dt.existsSync(a))ye("storage",`Creating certificate directory: ${a}`,_?.verbose),dt.mkdirSync(a,{recursive:!0});ye("storage","Writing certificate file",_?.verbose),dt.writeFileSync(t,N.certificate);let d=kt.dirname(e);if(!dt.existsSync(d))ye("storage",`Creating private key directory: ${d}`,_?.verbose),dt.mkdirSync(d,{recursive:!0});return ye("storage","Writing private key file",_?.verbose),dt.writeFileSync(e,N.privateKey),ye("storage","Certificate and private key stored successfully",_?.verbose),t}function ii(N,_){ye("storage","Storing CA certificate",_?.verbose);let t=kt.join(_?.basePath||_e.basePath,_?.caCertPath||_e.caCertPath);ye("storage",`CA certificate path: ${t}`,_?.verbose);let e=kt.dirname(t);if(!dt.existsSync(e))ye("storage",`Creating CA certificate directory: ${e}`,_?.verbose),dt.mkdirSync(e,{recursive:!0});return ye("storage","Writing CA certificate file",_?.verbose),dt.writeFileSync(t,N),ye("storage","CA certificate stored successfully",_?.verbose),t}var pn=Xe.tls,dn=Xe.pki,yn=Xe.default;var Cr=null;function An(N,_){let t=Vt(N)?N.proxies[0].to||"stacks.localhost":N.to||"stacks.localhost";if(typeof N.https==="object"&&typeof _.https==="object"){if(N.https.caCertPath&&N.https.certPath&&N.https.keyPath){let a=Ct({...N,to:t,https:_.https}),d=N.https.altNameIPs?.filter((g)=>g!==void 0)||a.altNameIPs,v=N.https.altNameURIs?.filter((g)=>g!==void 0)||a.altNameURIs;return{...a,caCertPath:N.https.caCertPath||a.caCertPath,certPath:N.https.certPath||a.certPath,keyPath:N.https.keyPath||a.keyPath,basePath:N.https.basePath||a.basePath,commonName:N.https.commonName||a.commonName,organizationName:N.https.organizationName||a.organizationName,countryName:N.https.countryName||a.countryName,stateName:N.https.stateName||a.stateName,localityName:N.https.localityName||a.localityName,validityDays:N.https.validityDays||a.validityDays,altNameIPs:d,altNameURIs:v,verbose:N.verbose||a.verbose}}}return Ct({...N,to:t})}function ai(N){let _=new Set;_.add(N);let t=N.split(".");if(t.length>=2)_.add(`*.${t.slice(1).join(".")}`);return Array.from(_)}function Er(N){let _=Ht(N),t="";if(typeof N?.https==="object")return t=N.https.basePath||"",{caCertPath:N.https.caCertPath||At(t,`${_}.ca.crt`),certPath:N.https.certPath||At(t,`${_}.crt`),keyPath:N.https.keyPath||At(t,`${_}.key`)};let e=t||At(aa(),".stacks","ssl"),a=_.replace(/\*/g,"wildcard");return{caCertPath:At(e,`${a}.ca.crt`),certPath:At(e,`${a}.crt`),keyPath:At(e,`${a}.key`)}}function ni(N){let _=new Set;if(Pt(N))N.proxies.forEach((t)=>{let e=t.to||"stacks.localhost";ai(e).forEach((a)=>_.add(a))});else if(Qt(N)){let t=N.to||"stacks.localhost";ai(t).forEach((e)=>_.add(e))}else _.add("stacks.localhost");return _.add("localhost"),_.add("*.localhost"),_}async function Sr(N){$("ssl","Loading SSL configuration",N.verbose);let _={...Ut,...N};if(N.https=Ct(_),!N.https?.keyPath&&!N.https?.certPath)return $("ssl","No SSL configuration provided",N.verbose),null;if(N.https?.keyPath&&!N.https?.certPath||!N.https?.keyPath&&N.https?.certPath){let t=!N.https?.keyPath?"keyPath":"certPath";throw $("ssl",`Invalid SSL configuration - missing ${t}`,N.verbose),new Error(`SSL Configuration requires both keyPath and certPath. Missing: ${t}`)}try{if(!N.https?.keyPath||!N.https?.certPath)return null;try{$("ssl","Reading SSL certificate files",N.verbose);let t=await Ft.readFile(N.https?.keyPath,"utf8"),e=await Ft.readFile(N.https?.certPath,"utf8");return $("ssl","SSL configuration loaded successfully",N.verbose),{key:t,cert:e}}catch(t){return $("ssl",`Failed to read certificates: ${t}`,N.verbose),null}}catch(t){throw $("ssl",`SSL configuration error: ${t}`,N.verbose),t}}async function Tr(N){if(Cr){$("ssl","Using cached SSL configuration",N.verbose);return}let _=Pt(N)?N.proxies.map((v)=>v.to):[N.to];$("ssl",`Generating certificate for domains: ${_.join(", ")}`,N.verbose);let t=Ct(N,N.verbose);ce.info("Generating Root CA certificate...");let e=await gr(t),a=Ct(N,N.verbose);ce.info(`Generating host certificate for: ${_.join(", ")}`);let d=await vr({...a,rootCA:{certificate:e.certificate,privateKey:e.privateKey}});await mr(d,e.certificate,a),Cr={key:d.privateKey,cert:d.certificate,ca:e.certificate},ce.success(`Certificate generated successfully for ${_.length} domain${_.length>1?"s":""}`),$("ssl",`Certificate includes domains: ${_.join(", ")}`,N.verbose)}function bn(){return Cr}async function Ir(N){let _=Ht(N),t=Er(N);try{$("ssl",`Checking certificates for ${_} at paths:`,N?.verbose),$("ssl",`CA: ${t.caCertPath}`,N?.verbose),$("ssl",`Cert: ${t.certPath}`,N?.verbose),$("ssl",`Key: ${t.keyPath}`,N?.verbose);let e=await Ft.readFile(t.keyPath,"utf8"),a=await Ft.readFile(t.certPath,"utf8"),d;if(t.caCertPath)try{d=await Ft.readFile(t.caCertPath,"utf8")}catch(v){$("ssl",`Failed to read CA cert: ${v}`,N?.verbose)}return{key:e,cert:a,ca:d}}catch(e){return $("ssl",`Failed to read certificates: ${e}`,N?.verbose),null}}function Ct(N,_){let t=Ht(N);$("ssl",`Primary domain: ${t}`,_);let e=Er(N);if(typeof N.https==="object"){let a={domain:t,hostCertCN:t,basePath:N.https.basePath||"",caCertPath:N.https.caCertPath||e.caCertPath,certPath:N.https.certPath||e.certPath,keyPath:N.https.keyPath||e.keyPath,altNameIPs:["127.0.0.1","::1"],altNameURIs:[],commonName:N.https.commonName||t,organizationName:N.https.organizationName||"Local Development",countryName:N.https.countryName||"US",stateName:N.https.stateName||"California",localityName:N.https.localityName||"Playa Vista",validityDays:N.https.validityDays||825,verbose:_||!1,subjectAltNames:Array.from(ni(N)).map((d)=>({type:2,value:d}))};if(kr(N.https.rootCA))a.rootCA=N.https.rootCA;return a}return{domain:t,hostCertCN:t,basePath:"",...e,altNameIPs:["127.0.0.1","::1"],altNameURIs:[],commonName:t,organizationName:"Local Development",countryName:"US",stateName:"California",localityName:"Playa Vista",validityDays:825,verbose:_||!1,subjectAltNames:Array.from(ni(N)).map((a)=>({type:2,value:a}))}}async function si(N,_){let t=Er({to:N,verbose:_}),e=[t.caCertPath,t.certPath,t.keyPath];$("certificates","Attempting to clean up relating certificates",_),await Promise.all(e.map((a)=>Rr(a,_)))}import*as _t from"node:http";import*as li from"node:http2";import*as fi from"node:https";import*as Jt from"node:net";import ft from"node:process";var lt=ua(ui(),1);var hi=new Set;async function Lt(N){$("cleanup","Starting cleanup process",N?.verbose),console.log(`
|
|
36
|
-
`),ce.info("Shutting down proxy servers...");let _=[],t=Array.from(hi).map((e)=>new Promise((a)=>{e.close(()=>{$("cleanup","Server closed successfully",N?.verbose),a()})}));if(_.push(...t),N?.hosts&&N.domains?.length){$("cleanup","Cleaning up hosts file entries",N?.verbose);let e=N.domains.filter((a)=>!a.includes("localhost"));if(e.length>0)ce.info("Cleaning up hosts file entries..."),_.push(Ur(e,N?.verbose).then(()=>{$("cleanup",`Removed hosts entries for ${e.join(", ")}`,N?.verbose)}).catch((a)=>{$("cleanup",`Failed to remove hosts entries: ${a}`,N?.verbose),ce.warn(`Failed to clean up hosts file entries for ${e.join(", ")}:`,a)}))}if(N?.certs&&N.domains?.length){$("cleanup","Cleaning up SSL certificates",N?.verbose),ce.info("Cleaning up SSL certificates...");let e=N.domains.map(async(a)=>{try{await si(a,N?.verbose),$("cleanup",`Removed certificates for ${a}`,N?.verbose)}catch(d){console.log("checkError",d),$("cleanup",`Failed to remove certificates for ${a}: ${d}`,N?.verbose),ce.warn(`Failed to clean up certificates for ${a}:`,d)}});_.push(...e)}try{await Promise.all(_),$("cleanup","All cleanup tasks completed successfully",N?.verbose),ce.success("All cleanup tasks completed successfully"),ft.exit(0)}catch(e){$("cleanup",`Error during cleanup: ${e}`,N?.verbose),ce.error("Error during cleanup:",e),ft.exit(1)}}ft.on("SIGINT",Lt);ft.on("SIGTERM",Lt);ft.on("uncaughtException",(N)=>{$("process",`Uncaught exception: ${N}`,!0),ce.error("Uncaught exception:",N),Lt()});function br(N,_,t){return $("port",`Checking if port ${N} is in use on ${_}`,t),new Promise((e)=>{let a=Jt.createServer();a.once("error",(d)=>{if(d.code==="EADDRINUSE")$("port",`Port ${N} is in use`,t),e(!0)}),a.once("listening",()=>{$("port",`Port ${N} is available`,t),a.close(),e(!1)}),a.listen(N,_)})}async function la(N,_,t){$("port",`Finding available port starting from ${N}`,t);let e=N;while(await br(e,_,t))$("port",`Port ${e} is in use, trying ${e+1}`,t),e++;return $("port",`Found available port: ${e}`,t),e}async function fa(N,_,t){return $("connection",`Testing connection to ${N}:${_}`,t),new Promise((e,a)=>{let d=Jt.connect({host:N,port:_,timeout:5000});d.once("connect",()=>{$("connection",`Successfully connected to ${N}:${_}`,t),d.end(),e()}),d.once("timeout",()=>{$("connection",`Connection to ${N}:${_} timed out`,t),d.destroy(),a(new Error(`Connection to ${N}:${_} timed out`))}),d.once("error",(v)=>{$("connection",`Failed to connect to ${N}:${_}: ${v}`,t),d.destroy(),a(new Error(`Failed to connect to ${N}:${_}: ${v.message}`))})})}async function pi(N){$("server",`Starting server with options: ${JSON.stringify(N)}`,N.verbose);let _=new URL((N.from?.startsWith("http")?N.from:`http://${N.from}`)||"localhost:5173"),t=new URL((N.to?.startsWith("http")?N.to:`http://${N.to}`)||"stacks.localhost"),e=Number.parseInt(_.port)||(_.protocol.includes("https:")?443:80),a=[t.hostname];if(!t.hostname.includes("localhost")&&!t.hostname.includes("127.0.0.1")){$("hosts",`Checking if hosts file entry exists for: ${t.hostname}`,N?.verbose);try{if(!(await Vr(a,N.verbose))[0]){ce.info(`Adding ${t.hostname} to hosts file...`),ce.info("This may require sudo/administrator privileges");try{await Dr(a,N.verbose)}catch(g){if(ce.error("Failed to add hosts entry:",g.message),ce.warn("You can manually add this entry to your hosts file:"),ce.warn(`127.0.0.1 ${t.hostname}`),ce.warn(`::1 ${t.hostname}`),ft.platform==="win32")ce.warn("On Windows:"),ce.warn("1. Run notepad as administrator"),ce.warn("2. Open C:\\Windows\\System32\\drivers\\etc\\hosts");else ce.warn("On Unix systems:"),ce.warn("sudo nano /etc/hosts")}}else $("hosts",`Host entry already exists for ${t.hostname}`,N.verbose)}catch(v){ce.error("Failed to check hosts file:",v.message)}}try{await fa(_.hostname,e,N.verbose)}catch(v){$("server",`Connection test failed: ${v}`,N.verbose),ce.error(v.message),ft.exit(1)}let d=N._cachedSSLConfig||null;if(N.https)try{if(N.https===!0)N.https=Ct({...N,to:t.hostname});try{$("ssl",`Attempting to load SSL configuration for ${t.hostname}`,N.verbose),d=await Sr({...N,to:t.hostname,https:N.https})}catch(v){$("ssl",`Failed to load certificates, will generate new ones: ${v}`,N.verbose)}if(!d){if($("ssl",`Generating new certificates for ${t.hostname}`,N.verbose),await Tr({...N,from:_.toString(),to:t.hostname,https:N.https}),d=await Sr({...N,to:t.hostname,https:N.https}),!d)throw new Error(`Failed to load SSL configuration after generating certificates for ${t.hostname}`)}}catch(v){throw $("server",`SSL setup failed: ${v}`,N.verbose),v}$("server",`Setting up reverse proxy with SSL config for ${t.hostname}`,N.verbose),await pa({...N,from:N.from||"localhost:5173",to:t.hostname,fromPort:e,sourceUrl:{hostname:_.hostname,host:_.host},ssl:d})}async function ha(N,_,t,e,a,d,v,g,u,r){$("proxy",`Creating proxy server ${N} -> ${_} with cleanUrls: ${r}`,u);function C(m){let S={};for(let[E,n]of Object.entries(m))if(!E.startsWith(":"))S[E]=n;return S}let f=(m,S)=>{$("request",`Incoming request: ${m.method} ${m.url}`,u);let E=m.url||"/",n=m.method||"GET";if(m instanceof li.Http2ServerRequest){let b=m.headers;n=b[":method"]||n,E=b[":path"]||E}if(r){if(!E.match(/\.[a-z0-9]+$/i))if(E.endsWith("/"))E=`${E}index.html`;else E=`${E}.html`}let p={hostname:d.hostname,port:t,path:E,method:n,headers:C(m.headers)};$("request",`Proxy request options: ${JSON.stringify(p)}`,u);let y=_t.request(p,(b)=>{if($("response",`Proxy response received with status ${b.statusCode}`,u),r&&b.statusCode===404){let h=[];if(E.endsWith(".html"))h.push(E.slice(0,-5));else if(!E.match(/\.[a-z0-9]+$/i))h.push(`${E}.html`);if(!E.endsWith("/"))h.push(`${E}/index.html`);if(h.length>0){$("cleanUrls",`Trying alternative paths: ${h.join(", ")}`,u);let s=(i)=>{if(i.length===0){S.writeHead(b.statusCode||404,b.headers),b.pipe(S);return}let B=i[0],P={...p,path:B},O=_t.request(P,(V)=>{if(V.statusCode===200)$("cleanUrls",`Found matching path: ${B}`,u),S.writeHead(V.statusCode,V.headers),V.pipe(S);else s(i.slice(1))});O.on("error",()=>s(i.slice(1))),O.end()};s(h);return}}let L={...b.headers,"Strict-Transport-Security":"max-age=31536000; includeSubDomains; preload","X-Content-Type-Options":"nosniff"};S.writeHead(b.statusCode||500,L),b.pipe(S)});y.on("error",(b)=>{$("request",`Proxy request failed: ${b}`,u),ce.error("Proxy request failed:",b),S.writeHead(502),S.end(`Proxy Error: ${b.message}`)}),m.pipe(y)},I=v?{key:v.key,cert:v.cert,ca:v.ca,minVersion:"TLSv1.2",maxVersion:"TLSv1.3",requestCert:!1,rejectUnauthorized:!1,ciphers:["TLS_AES_128_GCM_SHA256","TLS_AES_256_GCM_SHA384","TLS_CHACHA20_POLY1305_SHA256","ECDHE-ECDSA-AES128-GCM-SHA256","ECDHE-RSA-AES128-GCM-SHA256","ECDHE-ECDSA-AES256-GCM-SHA384","ECDHE-RSA-AES256-GCM-SHA384"].join(":")}:void 0;$("server",`Creating server with SSL config: ${!!v}`,u);let U;if(v&&I)U=fi.createServer(I,f),U.on("error",(m)=>{$("server",`HTTPS server error: ${m}`,u)}),U.on("secureConnection",(m)=>{$("tls",`TLS Connection established: ${JSON.stringify({protocol:m.getProtocol?.(),cipher:m.getCipher?.(),authorized:m.authorized,authError:m.authorizationError})}`,u)});else U=_t.createServer(f);let T=new Set;function c(m){return T.add(m),new Promise((S,E)=>{m.listen(e,a,()=>{if($("server",`Server listening on port ${e}`,u),!g){if(console.log(""),console.log(` ${lt.default.green(lt.default.bold("reverse-proxy"))} ${lt.default.green(`v${Br}`)}`),console.log(""),console.log(` ${lt.default.green("➜")} ${lt.default.dim(N)} ${lt.default.dim("➜")} ${v?"https":"http"}://${_}`),e!==(v?443:80))console.log(` ${lt.default.green("➜")} Listening on port ${e}`);if(v)console.log(` ${lt.default.green("➜")} SSL enabled with:`),console.log(" - TLS 1.2/1.3"),console.log(" - Modern cipher suite"),console.log(" - HTTP/2 enabled"),console.log(" - HSTS enabled");if(r)console.log(` ${lt.default.green("➜")} Clean URLs enabled`)}S()}),m.on("error",(n)=>{$("server",`Server error: ${n}`,u),E(n)})})}return c(U)}async function pa(N){$("setup",`Setting up reverse proxy: ${JSON.stringify(N)}`,N.verbose);let{from:_,to:t,fromPort:e,sourceUrl:a,ssl:d,verbose:v,cleanup:g,vitePluginUsage:u,portManager:r}=N,C=80,f=443,I="0.0.0.0";try{if(d&&!r?.usedPorts.has(C))if(!await br(C,I,v))$("setup","Starting HTTP redirect server",v),da(v),r?.usedPorts.add(C);else $("setup","Port 80 is in use, skipping HTTP redirect",v),ce.warn("Port 80 is in use, HTTP to HTTPS redirect will not be available");let U=d?f:C,T;if(r)T=await r.getNextAvailablePort(U);else T=await br(U,I,v)?await la(d?8443:8080,I,v):U;if(T!==U)ce.warn(`Port ${U} is in use. Using port ${T} instead.`),ce.info(`You can use 'sudo lsof -i :${U}' (Unix) or 'netstat -ano | findstr :${U}' (Windows) to check what's using the port.`);await ha(_,t,e,T,I,a,d,u,v)}catch(U){$("setup",`Setup failed: ${U}`,v),ce.error(`Failed to setup reverse proxy: ${U.message}`),Lt({domains:[t],hosts:typeof g==="boolean"?g:g?.hosts,certs:typeof g==="boolean"?g:g?.certs,verbose:v})}}function da(N){$("redirect","Starting HTTP redirect server",N);let _=_t.createServer((t,e)=>{let a=t.headers.host||"";$("redirect",`Redirecting request from ${a}${t.url} to HTTPS`,N),e.writeHead(301,{Location:`https://${a}${t.url}`}),e.end()}).listen(80);hi.add(_),$("redirect","HTTP redirect server started",N)}function Vn(N){let _={...Ut,...N};$("proxy",`Starting proxy with options: ${JSON.stringify(_)}`,_?.verbose);let t={from:_.from,to:_.to,cleanUrls:_.cleanUrls,https:Ct(_),cleanup:_.cleanup,vitePluginUsage:_.vitePluginUsage,verbose:_.verbose};console.log("serverOptions",t),pi(t).catch((e)=>{$("proxy",`Failed to start proxy: ${e}`,_.verbose),ce.error(`Failed to start proxy: ${e.message}`),Lt({domains:[_.to],hosts:typeof _.cleanup==="boolean"?_.cleanup:_.cleanup?.hosts,certs:typeof _.cleanup==="boolean"?_.cleanup:_.cleanup?.certs,verbose:_.verbose})})}async function Pn(N){$("proxies","Starting proxy setup",N?.verbose);let _={...Ut,...N},t=Vt(_)?_.proxies[0].to||"stacks.localhost":_.to||"stacks.localhost";if(_.https){let g=await Ir(_);if(g)$("ssl",`Using existing certificates for ${t}`,_.verbose),_._cachedSSLConfig=g;else{$("ssl",`No valid certificates found for ${t}, generating new ones`,_.verbose),await Tr(_);let u=await Ir(_);if(!u)throw new Error(`Failed to load SSL certificates after generation for ${t}. Please check file permissions and paths.`);_._cachedSSLConfig=u}}let e=Vt(_)?_.proxies.map((g)=>({...g,https:_.https,cleanup:_.cleanup,cleanUrls:_.cleanUrls,vitePluginUsage:_.vitePluginUsage,verbose:_.verbose,_cachedSSLConfig:_._cachedSSLConfig})):[{from:_.from||"localhost:5173",to:_.to||"stacks.localhost",cleanUrls:_.cleanUrls||!1,https:_.https,cleanup:_.cleanup,vitePluginUsage:_.vitePluginUsage,verbose:_.verbose,_cachedSSLConfig:_._cachedSSLConfig}],a=e.map((g)=>g.to||"stacks.localhost"),d=_._cachedSSLConfig,v=()=>Lt({domains:a,hosts:typeof _.cleanup==="boolean"?_.cleanup:_.cleanup?.hosts,certs:typeof _.cleanup==="boolean"?_.cleanup:_.cleanup?.certs,verbose:_.verbose||!1});ft.on("SIGINT",v),ft.on("SIGTERM",v),ft.on("uncaughtException",(g)=>{$("process",`Uncaught exception: ${g}`,!0),console.error("Uncaught exception:",g),v()});for(let g of e)try{let u=g.to||"stacks.localhost";$("proxy",`Starting proxy for ${u} with SSL config: ${!!d}`,g.verbose),await pi({from:g.from||"localhost:5173",to:u,cleanUrls:g.cleanUrls||!1,https:g.https||!1,cleanup:g.cleanup||!1,vitePluginUsage:g.vitePluginUsage||!1,verbose:g.verbose||!1,_cachedSSLConfig:d})}catch(u){$("proxies",`Failed to start proxy for ${g.to}: ${u}`,g.verbose),console.error(`Failed to start proxy for ${g.to}:`,u),v()}}
|
|
37
|
-
export{Br as a,Ut as b,$ as c,Ia as d,kr as e,Ht as f,Vt as g,Pt as h,Qt as i,Rr as j,mt as k,Dr as l,Ur as m,Vr as n,An as o,ai as p,Er as q,ni as r,Sr as s,Tr as t,bn as u,Ir as v,Ct as w,si as x,Lt as y,pi as z,pa as A,da as B,Vn as C,Pn as D};
|