typescript-virtual-container 1.5.0 → 1.5.1
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 +32 -18
- package/builds/{self-standalone.mjs → fortune-nyx-v1.5.1-directbash-k6.1.0.mjs} +18 -18
- package/builds/{standalone-wo-sftp.js → fortune-nyx-v1.5.1-ssh-nosftp.js} +20 -20
- package/builds/{standalone.cjs → fortune-nyx-v1.5.1-ssh.cjs} +11 -11
- package/dist/VirtualFileSystem/journal.d.ts.map +1 -1
- package/dist/VirtualFileSystem/journal.js +3 -1
- package/dist/VirtualFileSystem/journal.js.map +1 -1
- package/docs/classes/HoneyPot.html +9 -9
- package/docs/classes/IdleManager.html +8 -8
- package/docs/classes/SshClient.html +18 -18
- package/docs/classes/VirtualFileSystem.html +34 -34
- package/docs/classes/VirtualPackageManager.html +13 -13
- package/docs/classes/VirtualSftpServer.html +3 -3
- package/docs/classes/VirtualShell.html +28 -28
- package/docs/classes/VirtualSshServer.html +5 -5
- package/docs/classes/VirtualUserManager.html +27 -27
- package/docs/functions/assertDiff.html +2 -2
- package/docs/functions/diffSnapshots.html +2 -2
- package/docs/functions/formatDiff.html +2 -2
- package/docs/functions/getArg.html +2 -2
- package/docs/functions/getFlag.html +2 -2
- package/docs/functions/ifFlag.html +2 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +34 -30
- package/docs/interfaces/AuditLogEntry.html +3 -3
- package/docs/interfaces/CommandContext.html +12 -12
- package/docs/interfaces/CommandResult.html +13 -13
- package/docs/interfaces/ExecStream.html +6 -6
- package/docs/interfaces/HoneyPotStats.html +3 -3
- package/docs/interfaces/IdleManagerOptions.html +3 -3
- package/docs/interfaces/InstalledPackage.html +11 -11
- package/docs/interfaces/NanoEditorSession.html +5 -5
- package/docs/interfaces/PackageDefinition.html +14 -14
- package/docs/interfaces/PackageFile.html +5 -5
- package/docs/interfaces/PasswordChallenge.html +9 -9
- package/docs/interfaces/RemoveOptions.html +3 -3
- package/docs/interfaces/ShellEnv.html +4 -4
- package/docs/interfaces/ShellModule.html +8 -8
- package/docs/interfaces/ShellProperties.html +5 -5
- package/docs/interfaces/ShellStream.html +7 -7
- package/docs/interfaces/SudoChallenge.html +9 -9
- package/docs/interfaces/VfsBaseNode.html +7 -7
- package/docs/interfaces/VfsDiff.html +6 -6
- package/docs/interfaces/VfsDiffEntry.html +4 -4
- package/docs/interfaces/VfsDiffModified.html +6 -6
- package/docs/interfaces/VfsDirectoryNode.html +8 -8
- package/docs/interfaces/VfsFileNode.html +9 -9
- package/docs/interfaces/VfsOptions.html +6 -6
- package/docs/interfaces/VfsSnapshot.html +3 -3
- package/docs/interfaces/VfsSnapshotBaseNode.html +4 -4
- package/docs/interfaces/VfsSnapshotDirectoryNode.html +5 -5
- package/docs/interfaces/VfsSnapshotFileNode.html +6 -6
- package/docs/interfaces/VirtualActiveSession.html +7 -7
- package/docs/interfaces/VirtualSftpServerOptions.html +3 -3
- package/docs/interfaces/VirtualShellVfsLike.html +3 -3
- package/docs/interfaces/VirtualShellVfsOptions.html +3 -3
- package/docs/interfaces/WriteFileOptions.html +4 -4
- package/docs/modules.html +1 -1
- package/docs/types/ArgParseOptions.html +3 -3
- package/docs/types/CommandMode.html +2 -2
- package/docs/types/CommandOutcome.html +2 -2
- package/docs/types/IdleState.html +1 -1
- package/docs/types/VfsNodeStats.html +2 -2
- package/docs/types/VfsNodeType.html +2 -2
- package/docs/types/VfsPersistenceMode.html +2 -2
- package/docs/types/VfsSnapshotNode.html +2 -2
- package/package.json +5 -4
- package/scripts/build-all.mjs +198 -0
- package/scripts/build-names.mjs +44 -0
- package/src/VirtualFileSystem/journal.ts +3 -1
- /package/builds/{web-full-api.min.js → fortune-nyx-v1.5.1-web-full.min.js} +0 -0
- /package/builds/{web.min.js → fortune-nyx-v1.5.1-web.min.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var wp=Object.create;var zc=Object.defineProperty;var Ip=Object.getOwnPropertyDescriptor;var Cp=Object.getOwnPropertyNames;var kp=Object.getPrototypeOf,vp=Object.prototype.hasOwnProperty;var ut=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var Np=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Cp(t))!vp.call(n,s)&&s!==e&&zc(n,s,{get:()=>t[s],enumerable:!(r=Ip(t,s))||r.enumerable});return n};var Vt=(n,t,e)=>(e=n!=null?wp(kp(n)):{},Np(t||!n||!n.__esModule?zc(e,"default",{value:n,enumerable:!0}):e,n));var bs=ut((Ax,cf)=>{cf.exports={newInvalidAsn1Error:function(n){var t=new Error;return t.name="InvalidAsn1Error",t.message=n||"",t}}});var xs=ut((yx,lf)=>{lf.exports={EOC:0,Boolean:1,Integer:2,BitString:3,OctetString:4,Null:5,OID:6,ObjectDescriptor:7,External:8,Real:9,Enumeration:10,PDV:11,Utf8String:12,RelativeOID:13,Sequence:16,Set:17,NumericString:18,PrintableString:19,T61String:20,VideotexString:21,IA5String:22,UTCTime:23,GeneralizedTime:24,GraphicString:25,VisibleString:26,GeneralString:28,UniversalString:29,CharacterString:30,BMPString:31,Constructor:32,Context:128}});var $o=ut((Ex,uf)=>{"use strict";var ws=require("buffer"),Ur=ws.Buffer,An={},yn;for(yn in ws)ws.hasOwnProperty(yn)&&(yn==="SlowBuffer"||yn==="Buffer"||(An[yn]=ws[yn]));var $r=An.Buffer={};for(yn in Ur)Ur.hasOwnProperty(yn)&&(yn==="allocUnsafe"||yn==="allocUnsafeSlow"||($r[yn]=Ur[yn]));An.Buffer.prototype=Ur.prototype;(!$r.from||$r.from===Uint8Array.from)&&($r.from=function(n,t,e){if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof n);if(n&&typeof n.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);return Ur(n,t,e)});$r.alloc||($r.alloc=function(n,t,e){if(typeof n!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof n);if(n<0||n>=2*(1<<30))throw new RangeError('The value "'+n+'" is invalid for option "size"');var r=Ur(n);return!t||t.length===0?r.fill(0):typeof e=="string"?r.fill(t,e):r.fill(t),r});if(!An.kStringMaxLength)try{An.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}An.constants||(An.constants={MAX_LENGTH:An.kMaxLength},An.kStringMaxLength&&(An.constants.MAX_STRING_LENGTH=An.kStringMaxLength));uf.exports=An});var hf=ut((Sx,df)=>{var Um=require("assert"),ff=$o().Buffer,_i=xs(),$m=bs(),Fr=$m.newInvalidAsn1Error;function tn(n){if(!n||!ff.isBuffer(n))throw new TypeError("data must be a node Buffer");this._buf=n,this._size=n.length,this._len=0,this._offset=0}Object.defineProperty(tn.prototype,"length",{enumerable:!0,get:function(){return this._len}});Object.defineProperty(tn.prototype,"offset",{enumerable:!0,get:function(){return this._offset}});Object.defineProperty(tn.prototype,"remain",{get:function(){return this._size-this._offset}});Object.defineProperty(tn.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}});tn.prototype.readByte=function(n){if(this._size-this._offset<1)return null;var t=this._buf[this._offset]&255;return n||(this._offset+=1),t};tn.prototype.peek=function(){return this.readByte(!0)};tn.prototype.readLength=function(n){if(n===void 0&&(n=this._offset),n>=this._size)return null;var t=this._buf[n++]&255;if(t===null)return null;if((t&128)===128){if(t&=127,t===0)throw Fr("Indefinite length not supported");if(t>4)throw Fr("encoding too long");if(this._size-n<t)return null;this._len=0;for(var e=0;e<t;e++)this._len=(this._len<<8)+(this._buf[n++]&255)}else this._len=t;return n};tn.prototype.readSequence=function(n){var t=this.peek();if(t===null)return null;if(n!==void 0&&n!==t)throw Fr("Expected 0x"+n.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);return e===null?null:(this._offset=e,t)};tn.prototype.readInt=function(){return this._readTag(_i.Integer)};tn.prototype.readBoolean=function(){return this._readTag(_i.Boolean)!==0};tn.prototype.readEnumeration=function(){return this._readTag(_i.Enumeration)};tn.prototype.readString=function(n,t){n||(n=_i.OctetString);var e=this.peek();if(e===null)return null;if(e!==n)throw Fr("Expected 0x"+n.toString(16)+": got 0x"+e.toString(16));var r=this.readLength(this._offset+1);if(r===null||this.length>this._size-r)return null;if(this._offset=r,this.length===0)return t?ff.alloc(0):"";var s=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,t?s:s.toString("utf8")};tn.prototype.readOID=function(n){n||(n=_i.OID);var t=this.readString(n,!0);if(t===null)return null;for(var e=[],r=0,s=0;s<t.length;s++){var i=t[s]&255;r<<=7,r+=i&127,(i&128)===0&&(e.push(r),r=0)}return r=e.shift(),e.unshift(r%40),e.unshift(r/40>>0),e.join(".")};tn.prototype._readTag=function(n){Um.ok(n!==void 0);var t=this.peek();if(t===null)return null;if(t!==n)throw Fr("Expected 0x"+n.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);if(e===null)return null;if(this.length>4)throw Fr("Integer too long: "+this.length);if(this.length>this._size-e)return null;this._offset=e;for(var r=this._buf[this._offset],s=0,i=0;i<this.length;i++)s<<=8,s|=this._buf[this._offset++]&255;return(r&128)===128&&i!==4&&(s-=1<<i*8),s>>0};df.exports=tn});var mf=ut((_x,pf)=>{var Jn=require("assert"),Is=$o().Buffer,Zn=xs(),Fm=bs(),Cs=Fm.newInvalidAsn1Error,Hm={size:1024,growthFactor:8};function Qm(n,t){Jn.ok(n),Jn.equal(typeof n,"object"),Jn.ok(t),Jn.equal(typeof t,"object");var e=Object.getOwnPropertyNames(n);return e.forEach(function(r){if(!t[r]){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,s)}}),t}function Xt(n){n=Qm(Hm,n||{}),this._buf=Is.alloc(n.size||1024),this._size=this._buf.length,this._offset=0,this._options=n,this._seq=[]}Object.defineProperty(Xt.prototype,"buffer",{get:function(){if(this._seq.length)throw Cs(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)}});Xt.prototype.writeByte=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=n};Xt.prototype.writeInt=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");typeof t!="number"&&(t=Zn.Integer);for(var e=4;((n&4286578688)===0||(n&4286578688)===-8388608)&&e>1;)e--,n<<=8;if(e>4)throw Cs("BER ints cannot be > 0xffffffff");for(this._ensure(2+e),this._buf[this._offset++]=t,this._buf[this._offset++]=e;e-- >0;)this._buf[this._offset++]=(n&4278190080)>>>24,n<<=8};Xt.prototype.writeNull=function(){this.writeByte(Zn.Null),this.writeByte(0)};Xt.prototype.writeEnumeration=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");return typeof t!="number"&&(t=Zn.Enumeration),this.writeInt(n,t)};Xt.prototype.writeBoolean=function(n,t){if(typeof n!="boolean")throw new TypeError("argument must be a Boolean");typeof t!="number"&&(t=Zn.Boolean),this._ensure(3),this._buf[this._offset++]=t,this._buf[this._offset++]=1,this._buf[this._offset++]=n?255:0};Xt.prototype.writeString=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string (was: "+typeof n+")");typeof t!="number"&&(t=Zn.OctetString);var e=Is.byteLength(n);this.writeByte(t),this.writeLength(e),e&&(this._ensure(e),this._buf.write(n,this._offset),this._offset+=e)};Xt.prototype.writeBuffer=function(n,t){if(typeof t!="number")throw new TypeError("tag must be a number");if(!Is.isBuffer(n))throw new TypeError("argument must be a buffer");this.writeByte(t),this.writeLength(n.length),this._ensure(n.length),n.copy(this._buf,this._offset,0,n.length),this._offset+=n.length};Xt.prototype.writeStringArray=function(n){if(!n instanceof Array)throw new TypeError("argument must be an Array[String]");var t=this;n.forEach(function(e){t.writeString(e)})};Xt.prototype.writeOID=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string");if(typeof t!="number"&&(t=Zn.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(n))throw new Error("argument is not a valid OID string");function e(o,a){a<128?o.push(a):a<16384?(o.push(a>>>7|128),o.push(a&127)):a<2097152?(o.push(a>>>14|128),o.push((a>>>7|128)&255),o.push(a&127)):a<268435456?(o.push(a>>>21|128),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127)):(o.push((a>>>28|128)&255),o.push((a>>>21|128)&255),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127))}var r=n.split("."),s=[];s.push(parseInt(r[0],10)*40+parseInt(r[1],10)),r.slice(2).forEach(function(o){e(s,parseInt(o,10))});var i=this;this._ensure(2+s.length),this.writeByte(t),this.writeLength(s.length),s.forEach(function(o){i.writeByte(o)})};Xt.prototype.writeLength=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");if(this._ensure(4),n<=127)this._buf[this._offset++]=n;else if(n<=255)this._buf[this._offset++]=129,this._buf[this._offset++]=n;else if(n<=65535)this._buf[this._offset++]=130,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else if(n<=16777215)this._buf[this._offset++]=131,this._buf[this._offset++]=n>>16,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else throw Cs("Length too long (> 4 bytes)")};Xt.prototype.startSequence=function(n){typeof n!="number"&&(n=Zn.Sequence|Zn.Constructor),this.writeByte(n),this._seq.push(this._offset),this._ensure(3),this._offset+=3};Xt.prototype.endSequence=function(){var n=this._seq.pop(),t=n+3,e=this._offset-t;if(e<=127)this._shift(t,e,-2),this._buf[n]=e;else if(e<=255)this._shift(t,e,-1),this._buf[n]=129,this._buf[n+1]=e;else if(e<=65535)this._buf[n]=130,this._buf[n+1]=e>>8,this._buf[n+2]=e;else if(e<=16777215)this._shift(t,e,1),this._buf[n]=131,this._buf[n+1]=e>>16,this._buf[n+2]=e>>8,this._buf[n+3]=e;else throw Cs("Sequence too long")};Xt.prototype._shift=function(n,t,e){Jn.ok(n!==void 0),Jn.ok(t!==void 0),Jn.ok(e),this._buf.copy(this._buf,n+e,n,n+t),this._offset+=e};Xt.prototype._ensure=function(n){if(Jn.ok(n),this._size-this._offset<n){var t=this._size*this._options.growthFactor;t-this._offset<n&&(t+=n);var e=Is.alloc(t);this._buf.copy(e,0,0,this._offset),this._buf=e,this._size=t}};pf.exports=Xt});var gf=ut((bx,Ns)=>{var Fo=bs(),Ho=xs(),Wm=hf(),qm=mf();Ns.exports={Reader:Wm,Writer:qm};for(ks in Ho)Ho.hasOwnProperty(ks)&&(Ns.exports[ks]=Ho[ks]);var ks;for(vs in Fo)Fo.hasOwnProperty(vs)&&(Ns.exports[vs]=Fo[vs]);var vs});var bi=ut((xx,Af)=>{var Qo=gf();Af.exports={Ber:Qo,BerReader:Qo.Reader,BerWriter:Qo.Writer}});var yf=ut((wx,Bs)=>{(function(n){"use strict";var t=function(m){var y,g=new Float64Array(16);if(m)for(y=0;y<m.length;y++)g[y]=m[y];return g},e=function(){throw new Error("no PRNG")},r=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var i=t(),o=t([1]),a=t([56129,1]),c=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),f=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),h=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(m,y,g,d){m[y]=g>>24&255,m[y+1]=g>>16&255,m[y+2]=g>>8&255,m[y+3]=g&255,m[y+4]=d>>24&255,m[y+5]=d>>16&255,m[y+6]=d>>8&255,m[y+7]=d&255}function A(m,y,g,d,S){var L,W=0;for(L=0;L<S;L++)W|=m[y+L]^g[d+L];return(1&W-1>>>8)-1}function E(m,y,g,d){return A(m,y,g,d,16)}function b(m,y,g,d){return A(m,y,g,d,32)}function x(m,y,g,d){for(var S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,L=g[0]&255|(g[1]&255)<<8|(g[2]&255)<<16|(g[3]&255)<<24,W=g[4]&255|(g[5]&255)<<8|(g[6]&255)<<16|(g[7]&255)<<24,ee=g[8]&255|(g[9]&255)<<8|(g[10]&255)<<16|(g[11]&255)<<24,le=g[12]&255|(g[13]&255)<<8|(g[14]&255)<<16|(g[15]&255)<<24,Ee=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,ge=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,st=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,ye=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,Me=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,De=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,We=g[16]&255|(g[17]&255)<<8|(g[18]&255)<<16|(g[19]&255)<<24,He=g[20]&255|(g[21]&255)<<8|(g[22]&255)<<16|(g[23]&255)<<24,Le=g[24]&255|(g[25]&255)<<8|(g[26]&255)<<16|(g[27]&255)<<24,$e=g[28]&255|(g[29]&255)<<8|(g[30]&255)<<16|(g[31]&255)<<24,Ue=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,Se=S,xe=L,Ae=W,_e=ee,be=le,me=Ee,V=ge,K=st,se=ye,Z=Me,te=De,ce=We,ve=He,qe=Le,Ke=$e,Ve=Ue,I,Ge=0;Ge<20;Ge+=2)I=Se+ve|0,be^=I<<7|I>>>25,I=be+Se|0,se^=I<<9|I>>>23,I=se+be|0,ve^=I<<13|I>>>19,I=ve+se|0,Se^=I<<18|I>>>14,I=me+xe|0,Z^=I<<7|I>>>25,I=Z+me|0,qe^=I<<9|I>>>23,I=qe+Z|0,xe^=I<<13|I>>>19,I=xe+qe|0,me^=I<<18|I>>>14,I=te+V|0,Ke^=I<<7|I>>>25,I=Ke+te|0,Ae^=I<<9|I>>>23,I=Ae+Ke|0,V^=I<<13|I>>>19,I=V+Ae|0,te^=I<<18|I>>>14,I=Ve+ce|0,_e^=I<<7|I>>>25,I=_e+Ve|0,K^=I<<9|I>>>23,I=K+_e|0,ce^=I<<13|I>>>19,I=ce+K|0,Ve^=I<<18|I>>>14,I=Se+_e|0,xe^=I<<7|I>>>25,I=xe+Se|0,Ae^=I<<9|I>>>23,I=Ae+xe|0,_e^=I<<13|I>>>19,I=_e+Ae|0,Se^=I<<18|I>>>14,I=me+be|0,V^=I<<7|I>>>25,I=V+me|0,K^=I<<9|I>>>23,I=K+V|0,be^=I<<13|I>>>19,I=be+K|0,me^=I<<18|I>>>14,I=te+Z|0,ce^=I<<7|I>>>25,I=ce+te|0,se^=I<<9|I>>>23,I=se+ce|0,Z^=I<<13|I>>>19,I=Z+se|0,te^=I<<18|I>>>14,I=Ve+Ke|0,ve^=I<<7|I>>>25,I=ve+Ve|0,qe^=I<<9|I>>>23,I=qe+ve|0,Ke^=I<<13|I>>>19,I=Ke+qe|0,Ve^=I<<18|I>>>14;Se=Se+S|0,xe=xe+L|0,Ae=Ae+W|0,_e=_e+ee|0,be=be+le|0,me=me+Ee|0,V=V+ge|0,K=K+st|0,se=se+ye|0,Z=Z+Me|0,te=te+De|0,ce=ce+We|0,ve=ve+He|0,qe=qe+Le|0,Ke=Ke+$e|0,Ve=Ve+Ue|0,m[0]=Se>>>0&255,m[1]=Se>>>8&255,m[2]=Se>>>16&255,m[3]=Se>>>24&255,m[4]=xe>>>0&255,m[5]=xe>>>8&255,m[6]=xe>>>16&255,m[7]=xe>>>24&255,m[8]=Ae>>>0&255,m[9]=Ae>>>8&255,m[10]=Ae>>>16&255,m[11]=Ae>>>24&255,m[12]=_e>>>0&255,m[13]=_e>>>8&255,m[14]=_e>>>16&255,m[15]=_e>>>24&255,m[16]=be>>>0&255,m[17]=be>>>8&255,m[18]=be>>>16&255,m[19]=be>>>24&255,m[20]=me>>>0&255,m[21]=me>>>8&255,m[22]=me>>>16&255,m[23]=me>>>24&255,m[24]=V>>>0&255,m[25]=V>>>8&255,m[26]=V>>>16&255,m[27]=V>>>24&255,m[28]=K>>>0&255,m[29]=K>>>8&255,m[30]=K>>>16&255,m[31]=K>>>24&255,m[32]=se>>>0&255,m[33]=se>>>8&255,m[34]=se>>>16&255,m[35]=se>>>24&255,m[36]=Z>>>0&255,m[37]=Z>>>8&255,m[38]=Z>>>16&255,m[39]=Z>>>24&255,m[40]=te>>>0&255,m[41]=te>>>8&255,m[42]=te>>>16&255,m[43]=te>>>24&255,m[44]=ce>>>0&255,m[45]=ce>>>8&255,m[46]=ce>>>16&255,m[47]=ce>>>24&255,m[48]=ve>>>0&255,m[49]=ve>>>8&255,m[50]=ve>>>16&255,m[51]=ve>>>24&255,m[52]=qe>>>0&255,m[53]=qe>>>8&255,m[54]=qe>>>16&255,m[55]=qe>>>24&255,m[56]=Ke>>>0&255,m[57]=Ke>>>8&255,m[58]=Ke>>>16&255,m[59]=Ke>>>24&255,m[60]=Ve>>>0&255,m[61]=Ve>>>8&255,m[62]=Ve>>>16&255,m[63]=Ve>>>24&255}function P(m,y,g,d){for(var S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,L=g[0]&255|(g[1]&255)<<8|(g[2]&255)<<16|(g[3]&255)<<24,W=g[4]&255|(g[5]&255)<<8|(g[6]&255)<<16|(g[7]&255)<<24,ee=g[8]&255|(g[9]&255)<<8|(g[10]&255)<<16|(g[11]&255)<<24,le=g[12]&255|(g[13]&255)<<8|(g[14]&255)<<16|(g[15]&255)<<24,Ee=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,ge=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,st=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,ye=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,Me=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,De=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,We=g[16]&255|(g[17]&255)<<8|(g[18]&255)<<16|(g[19]&255)<<24,He=g[20]&255|(g[21]&255)<<8|(g[22]&255)<<16|(g[23]&255)<<24,Le=g[24]&255|(g[25]&255)<<8|(g[26]&255)<<16|(g[27]&255)<<24,$e=g[28]&255|(g[29]&255)<<8|(g[30]&255)<<16|(g[31]&255)<<24,Ue=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,Se=S,xe=L,Ae=W,_e=ee,be=le,me=Ee,V=ge,K=st,se=ye,Z=Me,te=De,ce=We,ve=He,qe=Le,Ke=$e,Ve=Ue,I,Ge=0;Ge<20;Ge+=2)I=Se+ve|0,be^=I<<7|I>>>25,I=be+Se|0,se^=I<<9|I>>>23,I=se+be|0,ve^=I<<13|I>>>19,I=ve+se|0,Se^=I<<18|I>>>14,I=me+xe|0,Z^=I<<7|I>>>25,I=Z+me|0,qe^=I<<9|I>>>23,I=qe+Z|0,xe^=I<<13|I>>>19,I=xe+qe|0,me^=I<<18|I>>>14,I=te+V|0,Ke^=I<<7|I>>>25,I=Ke+te|0,Ae^=I<<9|I>>>23,I=Ae+Ke|0,V^=I<<13|I>>>19,I=V+Ae|0,te^=I<<18|I>>>14,I=Ve+ce|0,_e^=I<<7|I>>>25,I=_e+Ve|0,K^=I<<9|I>>>23,I=K+_e|0,ce^=I<<13|I>>>19,I=ce+K|0,Ve^=I<<18|I>>>14,I=Se+_e|0,xe^=I<<7|I>>>25,I=xe+Se|0,Ae^=I<<9|I>>>23,I=Ae+xe|0,_e^=I<<13|I>>>19,I=_e+Ae|0,Se^=I<<18|I>>>14,I=me+be|0,V^=I<<7|I>>>25,I=V+me|0,K^=I<<9|I>>>23,I=K+V|0,be^=I<<13|I>>>19,I=be+K|0,me^=I<<18|I>>>14,I=te+Z|0,ce^=I<<7|I>>>25,I=ce+te|0,se^=I<<9|I>>>23,I=se+ce|0,Z^=I<<13|I>>>19,I=Z+se|0,te^=I<<18|I>>>14,I=Ve+Ke|0,ve^=I<<7|I>>>25,I=ve+Ve|0,qe^=I<<9|I>>>23,I=qe+ve|0,Ke^=I<<13|I>>>19,I=Ke+qe|0,Ve^=I<<18|I>>>14;m[0]=Se>>>0&255,m[1]=Se>>>8&255,m[2]=Se>>>16&255,m[3]=Se>>>24&255,m[4]=me>>>0&255,m[5]=me>>>8&255,m[6]=me>>>16&255,m[7]=me>>>24&255,m[8]=te>>>0&255,m[9]=te>>>8&255,m[10]=te>>>16&255,m[11]=te>>>24&255,m[12]=Ve>>>0&255,m[13]=Ve>>>8&255,m[14]=Ve>>>16&255,m[15]=Ve>>>24&255,m[16]=V>>>0&255,m[17]=V>>>8&255,m[18]=V>>>16&255,m[19]=V>>>24&255,m[20]=K>>>0&255,m[21]=K>>>8&255,m[22]=K>>>16&255,m[23]=K>>>24&255,m[24]=se>>>0&255,m[25]=se>>>8&255,m[26]=se>>>16&255,m[27]=se>>>24&255,m[28]=Z>>>0&255,m[29]=Z>>>8&255,m[30]=Z>>>16&255,m[31]=Z>>>24&255}function q(m,y,g,d){x(m,y,g,d)}function C(m,y,g,d){P(m,y,g,d)}var $=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function F(m,y,g,d,S,L,W){var ee=new Uint8Array(16),le=new Uint8Array(64),Ee,ge;for(ge=0;ge<16;ge++)ee[ge]=0;for(ge=0;ge<8;ge++)ee[ge]=L[ge];for(;S>=64;){for(q(le,ee,W,$),ge=0;ge<64;ge++)m[y+ge]=g[d+ge]^le[ge];for(Ee=1,ge=8;ge<16;ge++)Ee=Ee+(ee[ge]&255)|0,ee[ge]=Ee&255,Ee>>>=8;S-=64,y+=64,d+=64}if(S>0)for(q(le,ee,W,$),ge=0;ge<S;ge++)m[y+ge]=g[d+ge]^le[ge];return 0}function v(m,y,g,d,S){var L=new Uint8Array(16),W=new Uint8Array(64),ee,le;for(le=0;le<16;le++)L[le]=0;for(le=0;le<8;le++)L[le]=d[le];for(;g>=64;){for(q(W,L,S,$),le=0;le<64;le++)m[y+le]=W[le];for(ee=1,le=8;le<16;le++)ee=ee+(L[le]&255)|0,L[le]=ee&255,ee>>>=8;g-=64,y+=64}if(g>0)for(q(W,L,S,$),le=0;le<g;le++)m[y+le]=W[le];return 0}function _(m,y,g,d,S){var L=new Uint8Array(32);C(L,d,S,$);for(var W=new Uint8Array(8),ee=0;ee<8;ee++)W[ee]=d[ee+16];return v(m,y,g,W,L)}function w(m,y,g,d,S,L,W){var ee=new Uint8Array(32);C(ee,L,W,$);for(var le=new Uint8Array(8),Ee=0;Ee<8;Ee++)le[Ee]=L[Ee+16];return F(m,y,g,d,S,le,ee)}var k=function(m){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var y,g,d,S,L,W,ee,le;y=m[0]&255|(m[1]&255)<<8,this.r[0]=y&8191,g=m[2]&255|(m[3]&255)<<8,this.r[1]=(y>>>13|g<<3)&8191,d=m[4]&255|(m[5]&255)<<8,this.r[2]=(g>>>10|d<<6)&7939,S=m[6]&255|(m[7]&255)<<8,this.r[3]=(d>>>7|S<<9)&8191,L=m[8]&255|(m[9]&255)<<8,this.r[4]=(S>>>4|L<<12)&255,this.r[5]=L>>>1&8190,W=m[10]&255|(m[11]&255)<<8,this.r[6]=(L>>>14|W<<2)&8191,ee=m[12]&255|(m[13]&255)<<8,this.r[7]=(W>>>11|ee<<5)&8065,le=m[14]&255|(m[15]&255)<<8,this.r[8]=(ee>>>8|le<<8)&8191,this.r[9]=le>>>5&127,this.pad[0]=m[16]&255|(m[17]&255)<<8,this.pad[1]=m[18]&255|(m[19]&255)<<8,this.pad[2]=m[20]&255|(m[21]&255)<<8,this.pad[3]=m[22]&255|(m[23]&255)<<8,this.pad[4]=m[24]&255|(m[25]&255)<<8,this.pad[5]=m[26]&255|(m[27]&255)<<8,this.pad[6]=m[28]&255|(m[29]&255)<<8,this.pad[7]=m[30]&255|(m[31]&255)<<8};k.prototype.blocks=function(m,y,g){for(var d=this.fin?0:2048,S,L,W,ee,le,Ee,ge,st,ye,Me,De,We,He,Le,$e,Ue,Se,xe,Ae,_e=this.h[0],be=this.h[1],me=this.h[2],V=this.h[3],K=this.h[4],se=this.h[5],Z=this.h[6],te=this.h[7],ce=this.h[8],ve=this.h[9],qe=this.r[0],Ke=this.r[1],Ve=this.r[2],I=this.r[3],Ge=this.r[4],ot=this.r[5],at=this.r[6],ze=this.r[7],tt=this.r[8],nt=this.r[9];g>=16;)S=m[y+0]&255|(m[y+1]&255)<<8,_e+=S&8191,L=m[y+2]&255|(m[y+3]&255)<<8,be+=(S>>>13|L<<3)&8191,W=m[y+4]&255|(m[y+5]&255)<<8,me+=(L>>>10|W<<6)&8191,ee=m[y+6]&255|(m[y+7]&255)<<8,V+=(W>>>7|ee<<9)&8191,le=m[y+8]&255|(m[y+9]&255)<<8,K+=(ee>>>4|le<<12)&8191,se+=le>>>1&8191,Ee=m[y+10]&255|(m[y+11]&255)<<8,Z+=(le>>>14|Ee<<2)&8191,ge=m[y+12]&255|(m[y+13]&255)<<8,te+=(Ee>>>11|ge<<5)&8191,st=m[y+14]&255|(m[y+15]&255)<<8,ce+=(ge>>>8|st<<8)&8191,ve+=st>>>5|d,ye=0,Me=ye,Me+=_e*qe,Me+=be*(5*nt),Me+=me*(5*tt),Me+=V*(5*ze),Me+=K*(5*at),ye=Me>>>13,Me&=8191,Me+=se*(5*ot),Me+=Z*(5*Ge),Me+=te*(5*I),Me+=ce*(5*Ve),Me+=ve*(5*Ke),ye+=Me>>>13,Me&=8191,De=ye,De+=_e*Ke,De+=be*qe,De+=me*(5*nt),De+=V*(5*tt),De+=K*(5*ze),ye=De>>>13,De&=8191,De+=se*(5*at),De+=Z*(5*ot),De+=te*(5*Ge),De+=ce*(5*I),De+=ve*(5*Ve),ye+=De>>>13,De&=8191,We=ye,We+=_e*Ve,We+=be*Ke,We+=me*qe,We+=V*(5*nt),We+=K*(5*tt),ye=We>>>13,We&=8191,We+=se*(5*ze),We+=Z*(5*at),We+=te*(5*ot),We+=ce*(5*Ge),We+=ve*(5*I),ye+=We>>>13,We&=8191,He=ye,He+=_e*I,He+=be*Ve,He+=me*Ke,He+=V*qe,He+=K*(5*nt),ye=He>>>13,He&=8191,He+=se*(5*tt),He+=Z*(5*ze),He+=te*(5*at),He+=ce*(5*ot),He+=ve*(5*Ge),ye+=He>>>13,He&=8191,Le=ye,Le+=_e*Ge,Le+=be*I,Le+=me*Ve,Le+=V*Ke,Le+=K*qe,ye=Le>>>13,Le&=8191,Le+=se*(5*nt),Le+=Z*(5*tt),Le+=te*(5*ze),Le+=ce*(5*at),Le+=ve*(5*ot),ye+=Le>>>13,Le&=8191,$e=ye,$e+=_e*ot,$e+=be*Ge,$e+=me*I,$e+=V*Ve,$e+=K*Ke,ye=$e>>>13,$e&=8191,$e+=se*qe,$e+=Z*(5*nt),$e+=te*(5*tt),$e+=ce*(5*ze),$e+=ve*(5*at),ye+=$e>>>13,$e&=8191,Ue=ye,Ue+=_e*at,Ue+=be*ot,Ue+=me*Ge,Ue+=V*I,Ue+=K*Ve,ye=Ue>>>13,Ue&=8191,Ue+=se*Ke,Ue+=Z*qe,Ue+=te*(5*nt),Ue+=ce*(5*tt),Ue+=ve*(5*ze),ye+=Ue>>>13,Ue&=8191,Se=ye,Se+=_e*ze,Se+=be*at,Se+=me*ot,Se+=V*Ge,Se+=K*I,ye=Se>>>13,Se&=8191,Se+=se*Ve,Se+=Z*Ke,Se+=te*qe,Se+=ce*(5*nt),Se+=ve*(5*tt),ye+=Se>>>13,Se&=8191,xe=ye,xe+=_e*tt,xe+=be*ze,xe+=me*at,xe+=V*ot,xe+=K*Ge,ye=xe>>>13,xe&=8191,xe+=se*I,xe+=Z*Ve,xe+=te*Ke,xe+=ce*qe,xe+=ve*(5*nt),ye+=xe>>>13,xe&=8191,Ae=ye,Ae+=_e*nt,Ae+=be*tt,Ae+=me*ze,Ae+=V*at,Ae+=K*ot,ye=Ae>>>13,Ae&=8191,Ae+=se*Ge,Ae+=Z*I,Ae+=te*Ve,Ae+=ce*Ke,Ae+=ve*qe,ye+=Ae>>>13,Ae&=8191,ye=(ye<<2)+ye|0,ye=ye+Me|0,Me=ye&8191,ye=ye>>>13,De+=ye,_e=Me,be=De,me=We,V=He,K=Le,se=$e,Z=Ue,te=Se,ce=xe,ve=Ae,y+=16,g-=16;this.h[0]=_e,this.h[1]=be,this.h[2]=me,this.h[3]=V,this.h[4]=K,this.h[5]=se,this.h[6]=Z,this.h[7]=te,this.h[8]=ce,this.h[9]=ve},k.prototype.finish=function(m,y){var g=new Uint16Array(10),d,S,L,W;if(this.leftover){for(W=this.leftover,this.buffer[W++]=1;W<16;W++)this.buffer[W]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(d=this.h[1]>>>13,this.h[1]&=8191,W=2;W<10;W++)this.h[W]+=d,d=this.h[W]>>>13,this.h[W]&=8191;for(this.h[0]+=d*5,d=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=d,d=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=d,g[0]=this.h[0]+5,d=g[0]>>>13,g[0]&=8191,W=1;W<10;W++)g[W]=this.h[W]+d,d=g[W]>>>13,g[W]&=8191;for(g[9]-=8192,S=(d^1)-1,W=0;W<10;W++)g[W]&=S;for(S=~S,W=0;W<10;W++)this.h[W]=this.h[W]&S|g[W];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,L=this.h[0]+this.pad[0],this.h[0]=L&65535,W=1;W<8;W++)L=(this.h[W]+this.pad[W]|0)+(L>>>16)|0,this.h[W]=L&65535;m[y+0]=this.h[0]>>>0&255,m[y+1]=this.h[0]>>>8&255,m[y+2]=this.h[1]>>>0&255,m[y+3]=this.h[1]>>>8&255,m[y+4]=this.h[2]>>>0&255,m[y+5]=this.h[2]>>>8&255,m[y+6]=this.h[3]>>>0&255,m[y+7]=this.h[3]>>>8&255,m[y+8]=this.h[4]>>>0&255,m[y+9]=this.h[4]>>>8&255,m[y+10]=this.h[5]>>>0&255,m[y+11]=this.h[5]>>>8&255,m[y+12]=this.h[6]>>>0&255,m[y+13]=this.h[6]>>>8&255,m[y+14]=this.h[7]>>>0&255,m[y+15]=this.h[7]>>>8&255},k.prototype.update=function(m,y,g){var d,S;if(this.leftover){for(S=16-this.leftover,S>g&&(S=g),d=0;d<S;d++)this.buffer[this.leftover+d]=m[y+d];if(g-=S,y+=S,this.leftover+=S,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(g>=16&&(S=g-g%16,this.blocks(m,y,S),y+=S,g-=S),g){for(d=0;d<g;d++)this.buffer[this.leftover+d]=m[y+d];this.leftover+=g}};function N(m,y,g,d,S,L){var W=new k(L);return W.update(g,d,S),W.finish(m,y),0}function R(m,y,g,d,S,L){var W=new Uint8Array(16);return N(W,0,g,d,S,L),E(m,y,W,0)}function ie(m,y,g,d,S){var L;if(g<32)return-1;for(w(m,0,y,0,g,d,S),N(m,16,m,32,g-32,m),L=0;L<16;L++)m[L]=0;return 0}function j(m,y,g,d,S){var L,W=new Uint8Array(32);if(g<32||(_(W,0,32,d,S),R(y,16,y,32,g-32,W)!==0))return-1;for(w(m,0,y,0,g,d,S),L=0;L<32;L++)m[L]=0;return 0}function X(m,y){var g;for(g=0;g<16;g++)m[g]=y[g]|0}function re(m){var y,g,d=1;for(y=0;y<16;y++)g=m[y]+d+65535,d=Math.floor(g/65536),m[y]=g-d*65536;m[0]+=d-1+37*(d-1)}function fe(m,y,g){for(var d,S=~(g-1),L=0;L<16;L++)d=S&(m[L]^y[L]),m[L]^=d,y[L]^=d}function H(m,y){var g,d,S,L=t(),W=t();for(g=0;g<16;g++)W[g]=y[g];for(re(W),re(W),re(W),d=0;d<2;d++){for(L[0]=W[0]-65517,g=1;g<15;g++)L[g]=W[g]-65535-(L[g-1]>>16&1),L[g-1]&=65535;L[15]=W[15]-32767-(L[14]>>16&1),S=L[15]>>16&1,L[14]&=65535,fe(W,L,1-S)}for(g=0;g<16;g++)m[2*g]=W[g]&255,m[2*g+1]=W[g]>>8}function B(m,y){var g=new Uint8Array(32),d=new Uint8Array(32);return H(g,m),H(d,y),b(g,0,d,0)}function D(m){var y=new Uint8Array(32);return H(y,m),y[0]&1}function z(m,y){var g;for(g=0;g<16;g++)m[g]=y[2*g]+(y[2*g+1]<<8);m[15]&=32767}function ne(m,y,g){for(var d=0;d<16;d++)m[d]=y[d]+g[d]}function de(m,y,g){for(var d=0;d<16;d++)m[d]=y[d]-g[d]}function oe(m,y,g){var d,S,L=0,W=0,ee=0,le=0,Ee=0,ge=0,st=0,ye=0,Me=0,De=0,We=0,He=0,Le=0,$e=0,Ue=0,Se=0,xe=0,Ae=0,_e=0,be=0,me=0,V=0,K=0,se=0,Z=0,te=0,ce=0,ve=0,qe=0,Ke=0,Ve=0,I=g[0],Ge=g[1],ot=g[2],at=g[3],ze=g[4],tt=g[5],nt=g[6],Pt=g[7],pt=g[8],Nt=g[9],Bt=g[10],Rt=g[11],Ft=g[12],Gt=g[13],Yt=g[14],jt=g[15];d=y[0],L+=d*I,W+=d*Ge,ee+=d*ot,le+=d*at,Ee+=d*ze,ge+=d*tt,st+=d*nt,ye+=d*Pt,Me+=d*pt,De+=d*Nt,We+=d*Bt,He+=d*Rt,Le+=d*Ft,$e+=d*Gt,Ue+=d*Yt,Se+=d*jt,d=y[1],W+=d*I,ee+=d*Ge,le+=d*ot,Ee+=d*at,ge+=d*ze,st+=d*tt,ye+=d*nt,Me+=d*Pt,De+=d*pt,We+=d*Nt,He+=d*Bt,Le+=d*Rt,$e+=d*Ft,Ue+=d*Gt,Se+=d*Yt,xe+=d*jt,d=y[2],ee+=d*I,le+=d*Ge,Ee+=d*ot,ge+=d*at,st+=d*ze,ye+=d*tt,Me+=d*nt,De+=d*Pt,We+=d*pt,He+=d*Nt,Le+=d*Bt,$e+=d*Rt,Ue+=d*Ft,Se+=d*Gt,xe+=d*Yt,Ae+=d*jt,d=y[3],le+=d*I,Ee+=d*Ge,ge+=d*ot,st+=d*at,ye+=d*ze,Me+=d*tt,De+=d*nt,We+=d*Pt,He+=d*pt,Le+=d*Nt,$e+=d*Bt,Ue+=d*Rt,Se+=d*Ft,xe+=d*Gt,Ae+=d*Yt,_e+=d*jt,d=y[4],Ee+=d*I,ge+=d*Ge,st+=d*ot,ye+=d*at,Me+=d*ze,De+=d*tt,We+=d*nt,He+=d*Pt,Le+=d*pt,$e+=d*Nt,Ue+=d*Bt,Se+=d*Rt,xe+=d*Ft,Ae+=d*Gt,_e+=d*Yt,be+=d*jt,d=y[5],ge+=d*I,st+=d*Ge,ye+=d*ot,Me+=d*at,De+=d*ze,We+=d*tt,He+=d*nt,Le+=d*Pt,$e+=d*pt,Ue+=d*Nt,Se+=d*Bt,xe+=d*Rt,Ae+=d*Ft,_e+=d*Gt,be+=d*Yt,me+=d*jt,d=y[6],st+=d*I,ye+=d*Ge,Me+=d*ot,De+=d*at,We+=d*ze,He+=d*tt,Le+=d*nt,$e+=d*Pt,Ue+=d*pt,Se+=d*Nt,xe+=d*Bt,Ae+=d*Rt,_e+=d*Ft,be+=d*Gt,me+=d*Yt,V+=d*jt,d=y[7],ye+=d*I,Me+=d*Ge,De+=d*ot,We+=d*at,He+=d*ze,Le+=d*tt,$e+=d*nt,Ue+=d*Pt,Se+=d*pt,xe+=d*Nt,Ae+=d*Bt,_e+=d*Rt,be+=d*Ft,me+=d*Gt,V+=d*Yt,K+=d*jt,d=y[8],Me+=d*I,De+=d*Ge,We+=d*ot,He+=d*at,Le+=d*ze,$e+=d*tt,Ue+=d*nt,Se+=d*Pt,xe+=d*pt,Ae+=d*Nt,_e+=d*Bt,be+=d*Rt,me+=d*Ft,V+=d*Gt,K+=d*Yt,se+=d*jt,d=y[9],De+=d*I,We+=d*Ge,He+=d*ot,Le+=d*at,$e+=d*ze,Ue+=d*tt,Se+=d*nt,xe+=d*Pt,Ae+=d*pt,_e+=d*Nt,be+=d*Bt,me+=d*Rt,V+=d*Ft,K+=d*Gt,se+=d*Yt,Z+=d*jt,d=y[10],We+=d*I,He+=d*Ge,Le+=d*ot,$e+=d*at,Ue+=d*ze,Se+=d*tt,xe+=d*nt,Ae+=d*Pt,_e+=d*pt,be+=d*Nt,me+=d*Bt,V+=d*Rt,K+=d*Ft,se+=d*Gt,Z+=d*Yt,te+=d*jt,d=y[11],He+=d*I,Le+=d*Ge,$e+=d*ot,Ue+=d*at,Se+=d*ze,xe+=d*tt,Ae+=d*nt,_e+=d*Pt,be+=d*pt,me+=d*Nt,V+=d*Bt,K+=d*Rt,se+=d*Ft,Z+=d*Gt,te+=d*Yt,ce+=d*jt,d=y[12],Le+=d*I,$e+=d*Ge,Ue+=d*ot,Se+=d*at,xe+=d*ze,Ae+=d*tt,_e+=d*nt,be+=d*Pt,me+=d*pt,V+=d*Nt,K+=d*Bt,se+=d*Rt,Z+=d*Ft,te+=d*Gt,ce+=d*Yt,ve+=d*jt,d=y[13],$e+=d*I,Ue+=d*Ge,Se+=d*ot,xe+=d*at,Ae+=d*ze,_e+=d*tt,be+=d*nt,me+=d*Pt,V+=d*pt,K+=d*Nt,se+=d*Bt,Z+=d*Rt,te+=d*Ft,ce+=d*Gt,ve+=d*Yt,qe+=d*jt,d=y[14],Ue+=d*I,Se+=d*Ge,xe+=d*ot,Ae+=d*at,_e+=d*ze,be+=d*tt,me+=d*nt,V+=d*Pt,K+=d*pt,se+=d*Nt,Z+=d*Bt,te+=d*Rt,ce+=d*Ft,ve+=d*Gt,qe+=d*Yt,Ke+=d*jt,d=y[15],Se+=d*I,xe+=d*Ge,Ae+=d*ot,_e+=d*at,be+=d*ze,me+=d*tt,V+=d*nt,K+=d*Pt,se+=d*pt,Z+=d*Nt,te+=d*Bt,ce+=d*Rt,ve+=d*Ft,qe+=d*Gt,Ke+=d*Yt,Ve+=d*jt,L+=38*xe,W+=38*Ae,ee+=38*_e,le+=38*be,Ee+=38*me,ge+=38*V,st+=38*K,ye+=38*se,Me+=38*Z,De+=38*te,We+=38*ce,He+=38*ve,Le+=38*qe,$e+=38*Ke,Ue+=38*Ve,S=1,d=L+S+65535,S=Math.floor(d/65536),L=d-S*65536,d=W+S+65535,S=Math.floor(d/65536),W=d-S*65536,d=ee+S+65535,S=Math.floor(d/65536),ee=d-S*65536,d=le+S+65535,S=Math.floor(d/65536),le=d-S*65536,d=Ee+S+65535,S=Math.floor(d/65536),Ee=d-S*65536,d=ge+S+65535,S=Math.floor(d/65536),ge=d-S*65536,d=st+S+65535,S=Math.floor(d/65536),st=d-S*65536,d=ye+S+65535,S=Math.floor(d/65536),ye=d-S*65536,d=Me+S+65535,S=Math.floor(d/65536),Me=d-S*65536,d=De+S+65535,S=Math.floor(d/65536),De=d-S*65536,d=We+S+65535,S=Math.floor(d/65536),We=d-S*65536,d=He+S+65535,S=Math.floor(d/65536),He=d-S*65536,d=Le+S+65535,S=Math.floor(d/65536),Le=d-S*65536,d=$e+S+65535,S=Math.floor(d/65536),$e=d-S*65536,d=Ue+S+65535,S=Math.floor(d/65536),Ue=d-S*65536,d=Se+S+65535,S=Math.floor(d/65536),Se=d-S*65536,L+=S-1+37*(S-1),S=1,d=L+S+65535,S=Math.floor(d/65536),L=d-S*65536,d=W+S+65535,S=Math.floor(d/65536),W=d-S*65536,d=ee+S+65535,S=Math.floor(d/65536),ee=d-S*65536,d=le+S+65535,S=Math.floor(d/65536),le=d-S*65536,d=Ee+S+65535,S=Math.floor(d/65536),Ee=d-S*65536,d=ge+S+65535,S=Math.floor(d/65536),ge=d-S*65536,d=st+S+65535,S=Math.floor(d/65536),st=d-S*65536,d=ye+S+65535,S=Math.floor(d/65536),ye=d-S*65536,d=Me+S+65535,S=Math.floor(d/65536),Me=d-S*65536,d=De+S+65535,S=Math.floor(d/65536),De=d-S*65536,d=We+S+65535,S=Math.floor(d/65536),We=d-S*65536,d=He+S+65535,S=Math.floor(d/65536),He=d-S*65536,d=Le+S+65535,S=Math.floor(d/65536),Le=d-S*65536,d=$e+S+65535,S=Math.floor(d/65536),$e=d-S*65536,d=Ue+S+65535,S=Math.floor(d/65536),Ue=d-S*65536,d=Se+S+65535,S=Math.floor(d/65536),Se=d-S*65536,L+=S-1+37*(S-1),m[0]=L,m[1]=W,m[2]=ee,m[3]=le,m[4]=Ee,m[5]=ge,m[6]=st,m[7]=ye,m[8]=Me,m[9]=De,m[10]=We,m[11]=He,m[12]=Le,m[13]=$e,m[14]=Ue,m[15]=Se}function Je(m,y){oe(m,y,y)}function ht(m,y){var g=t(),d;for(d=0;d<16;d++)g[d]=y[d];for(d=253;d>=0;d--)Je(g,g),d!==2&&d!==4&&oe(g,g,y);for(d=0;d<16;d++)m[d]=g[d]}function ln(m,y){var g=t(),d;for(d=0;d<16;d++)g[d]=y[d];for(d=250;d>=0;d--)Je(g,g),d!==1&&oe(g,g,y);for(d=0;d<16;d++)m[d]=g[d]}function xr(m,y,g){var d=new Uint8Array(32),S=new Float64Array(80),L,W,ee=t(),le=t(),Ee=t(),ge=t(),st=t(),ye=t();for(W=0;W<31;W++)d[W]=y[W];for(d[31]=y[31]&127|64,d[0]&=248,z(S,g),W=0;W<16;W++)le[W]=S[W],ge[W]=ee[W]=Ee[W]=0;for(ee[0]=ge[0]=1,W=254;W>=0;--W)L=d[W>>>3]>>>(W&7)&1,fe(ee,le,L),fe(Ee,ge,L),ne(st,ee,Ee),de(ee,ee,Ee),ne(Ee,le,ge),de(le,le,ge),Je(ge,st),Je(ye,ee),oe(ee,Ee,ee),oe(Ee,le,st),ne(st,ee,Ee),de(ee,ee,Ee),Je(le,ee),de(Ee,ge,ye),oe(ee,Ee,a),ne(ee,ee,ge),oe(Ee,Ee,ee),oe(ee,ge,ye),oe(ge,le,S),Je(le,st),fe(ee,le,L),fe(Ee,ge,L);for(W=0;W<16;W++)S[W+16]=ee[W],S[W+32]=Ee[W],S[W+48]=le[W],S[W+64]=ge[W];var Me=S.subarray(32),De=S.subarray(16);return ht(Me,Me),oe(De,De,Me),H(m,De),0}function wr(m,y){return xr(m,y,s)}function Ln(m,y){return e(y,32),wr(m,y)}function Ir(m,y,g){var d=new Uint8Array(32);return xr(d,g,y),C(m,r,d,$)}var li=ie,os=j;function ui(m,y,g,d,S,L){var W=new Uint8Array(32);return Ir(W,S,L),li(m,y,g,d,W)}function Cr(m,y,g,d,S,L){var W=new Uint8Array(32);return Ir(W,S,L),os(m,y,g,d,W)}var kr=[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];function J(m,y,g,d){for(var S=new Int32Array(16),L=new Int32Array(16),W,ee,le,Ee,ge,st,ye,Me,De,We,He,Le,$e,Ue,Se,xe,Ae,_e,be,me,V,K,se,Z,te,ce,ve=m[0],qe=m[1],Ke=m[2],Ve=m[3],I=m[4],Ge=m[5],ot=m[6],at=m[7],ze=y[0],tt=y[1],nt=y[2],Pt=y[3],pt=y[4],Nt=y[5],Bt=y[6],Rt=y[7],Ft=0;d>=128;){for(be=0;be<16;be++)me=8*be+Ft,S[be]=g[me+0]<<24|g[me+1]<<16|g[me+2]<<8|g[me+3],L[be]=g[me+4]<<24|g[me+5]<<16|g[me+6]<<8|g[me+7];for(be=0;be<80;be++)if(W=ve,ee=qe,le=Ke,Ee=Ve,ge=I,st=Ge,ye=ot,Me=at,De=ze,We=tt,He=nt,Le=Pt,$e=pt,Ue=Nt,Se=Bt,xe=Rt,V=at,K=Rt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=(I>>>14|pt<<18)^(I>>>18|pt<<14)^(pt>>>9|I<<23),K=(pt>>>14|I<<18)^(pt>>>18|I<<14)^(I>>>9|pt<<23),se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,V=I&Ge^~I&ot,K=pt&Nt^~pt&Bt,se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,V=kr[be*2],K=kr[be*2+1],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,V=S[be%16],K=L[be%16],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,Ae=te&65535|ce<<16,_e=se&65535|Z<<16,V=Ae,K=_e,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=(ve>>>28|ze<<4)^(ze>>>2|ve<<30)^(ze>>>7|ve<<25),K=(ze>>>28|ve<<4)^(ve>>>2|ze<<30)^(ve>>>7|ze<<25),se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,V=ve&qe^ve&Ke^qe&Ke,K=ze&tt^ze&nt^tt&nt,se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,Me=te&65535|ce<<16,xe=se&65535|Z<<16,V=Ee,K=Le,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=Ae,K=_e,se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,Ee=te&65535|ce<<16,Le=se&65535|Z<<16,qe=W,Ke=ee,Ve=le,I=Ee,Ge=ge,ot=st,at=ye,ve=Me,tt=De,nt=We,Pt=He,pt=Le,Nt=$e,Bt=Ue,Rt=Se,ze=xe,be%16===15)for(me=0;me<16;me++)V=S[me],K=L[me],se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=S[(me+9)%16],K=L[(me+9)%16],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Ae=S[(me+1)%16],_e=L[(me+1)%16],V=(Ae>>>1|_e<<31)^(Ae>>>8|_e<<24)^Ae>>>7,K=(_e>>>1|Ae<<31)^(_e>>>8|Ae<<24)^(_e>>>7|Ae<<25),se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Ae=S[(me+14)%16],_e=L[(me+14)%16],V=(Ae>>>19|_e<<13)^(_e>>>29|Ae<<3)^Ae>>>6,K=(_e>>>19|Ae<<13)^(Ae>>>29|_e<<3)^(_e>>>6|Ae<<26),se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,S[me]=te&65535|ce<<16,L[me]=se&65535|Z<<16;V=ve,K=ze,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[0],K=y[0],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[0]=ve=te&65535|ce<<16,y[0]=ze=se&65535|Z<<16,V=qe,K=tt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[1],K=y[1],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[1]=qe=te&65535|ce<<16,y[1]=tt=se&65535|Z<<16,V=Ke,K=nt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[2],K=y[2],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[2]=Ke=te&65535|ce<<16,y[2]=nt=se&65535|Z<<16,V=Ve,K=Pt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[3],K=y[3],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[3]=Ve=te&65535|ce<<16,y[3]=Pt=se&65535|Z<<16,V=I,K=pt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[4],K=y[4],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[4]=I=te&65535|ce<<16,y[4]=pt=se&65535|Z<<16,V=Ge,K=Nt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[5],K=y[5],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[5]=Ge=te&65535|ce<<16,y[5]=Nt=se&65535|Z<<16,V=ot,K=Bt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[6],K=y[6],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[6]=ot=te&65535|ce<<16,y[6]=Bt=se&65535|Z<<16,V=at,K=Rt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[7],K=y[7],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[7]=at=te&65535|ce<<16,y[7]=Rt=se&65535|Z<<16,Ft+=128,d-=128}return d}function pe(m,y,g){var d=new Int32Array(8),S=new Int32Array(8),L=new Uint8Array(256),W,ee=g;for(d[0]=1779033703,d[1]=3144134277,d[2]=1013904242,d[3]=2773480762,d[4]=1359893119,d[5]=2600822924,d[6]=528734635,d[7]=1541459225,S[0]=4089235720,S[1]=2227873595,S[2]=4271175723,S[3]=1595750129,S[4]=2917565137,S[5]=725511199,S[6]=4215389547,S[7]=327033209,J(d,S,y,g),g%=128,W=0;W<g;W++)L[W]=y[ee-g+W];for(L[g]=128,g=256-128*(g<112?1:0),L[g-9]=0,p(L,g-8,ee/536870912|0,ee<<3),J(d,S,L,g),W=0;W<8;W++)p(m,8*W,d[W],S[W]);return 0}function we(m,y){var g=t(),d=t(),S=t(),L=t(),W=t(),ee=t(),le=t(),Ee=t(),ge=t();de(g,m[1],m[0]),de(ge,y[1],y[0]),oe(g,g,ge),ne(d,m[0],m[1]),ne(ge,y[0],y[1]),oe(d,d,ge),oe(S,m[3],y[3]),oe(S,S,l),oe(L,m[2],y[2]),ne(L,L,L),de(W,d,g),de(ee,L,S),ne(le,L,S),ne(Ee,d,g),oe(m[0],W,ee),oe(m[1],Ee,le),oe(m[2],le,ee),oe(m[3],W,Ee)}function Oe(m,y,g){var d;for(d=0;d<4;d++)fe(m[d],y[d],g)}function Ze(m,y){var g=t(),d=t(),S=t();ht(S,y[2]),oe(g,y[0],S),oe(d,y[1],S),H(m,d),m[31]^=D(g)<<7}function Dt(m,y,g){var d,S;for(X(m[0],i),X(m[1],o),X(m[2],o),X(m[3],i),S=255;S>=0;--S)d=g[S/8|0]>>(S&7)&1,Oe(m,y,d),we(y,m),we(m,m),Oe(m,y,d)}function vn(m,y){var g=[t(),t(),t(),t()];X(g[0],u),X(g[1],f),X(g[2],o),oe(g[3],u,f),Dt(m,g,y)}function un(m,y,g){var d=new Uint8Array(64),S=[t(),t(),t(),t()],L;for(g||e(y,32),pe(d,y,32),d[0]&=248,d[31]&=127,d[31]|=64,vn(S,d),Ze(m,S),L=0;L<32;L++)y[L+32]=m[L];return 0}var vr=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]);function lt(m,y){var g,d,S,L;for(d=63;d>=32;--d){for(g=0,S=d-32,L=d-12;S<L;++S)y[S]+=g-16*y[d]*vr[S-(d-32)],g=y[S]+128>>8,y[S]-=g*256;y[S]+=g,y[d]=0}for(g=0,S=0;S<32;S++)y[S]+=g-(y[31]>>4)*vr[S],g=y[S]>>8,y[S]&=255;for(S=0;S<32;S++)y[S]-=g*vr[S];for(d=0;d<32;d++)y[d+1]+=y[d]>>8,m[d]=y[d]&255}function Ht(m){var y=new Float64Array(64),g;for(g=0;g<64;g++)y[g]=m[g];for(g=0;g<64;g++)m[g]=0;lt(m,y)}function $t(m,y,g,d){var S=new Uint8Array(64),L=new Uint8Array(64),W=new Uint8Array(64),ee,le,Ee=new Float64Array(64),ge=[t(),t(),t(),t()];pe(S,d,32),S[0]&=248,S[31]&=127,S[31]|=64;var st=g+64;for(ee=0;ee<g;ee++)m[64+ee]=y[ee];for(ee=0;ee<32;ee++)m[32+ee]=S[32+ee];for(pe(W,m.subarray(32),g+32),Ht(W),vn(ge,W),Ze(m,ge),ee=32;ee<64;ee++)m[ee]=d[ee];for(pe(L,m,g+64),Ht(L),ee=0;ee<64;ee++)Ee[ee]=0;for(ee=0;ee<32;ee++)Ee[ee]=W[ee];for(ee=0;ee<32;ee++)for(le=0;le<32;le++)Ee[ee+le]+=L[ee]*S[le];return lt(m.subarray(32),Ee),st}function kt(m,y){var g=t(),d=t(),S=t(),L=t(),W=t(),ee=t(),le=t();return X(m[2],o),z(m[1],y),Je(S,m[1]),oe(L,S,c),de(S,S,m[2]),ne(L,m[2],L),Je(W,L),Je(ee,W),oe(le,ee,W),oe(g,le,S),oe(g,g,L),ln(g,g),oe(g,g,S),oe(g,g,L),oe(g,g,L),oe(m[0],g,L),Je(d,m[0]),oe(d,d,L),B(d,S)&&oe(m[0],m[0],h),Je(d,m[0]),oe(d,d,L),B(d,S)?-1:(D(m[0])===y[31]>>7&&de(m[0],i,m[0]),oe(m[3],m[0],m[1]),0)}function At(m,y,g,d){var S,L,W=new Uint8Array(32),ee=new Uint8Array(64),le=[t(),t(),t(),t()],Ee=[t(),t(),t(),t()];if(L=-1,g<64||kt(Ee,d))return-1;for(S=0;S<g;S++)m[S]=y[S];for(S=0;S<32;S++)m[S+32]=d[S];if(pe(ee,m,g),Ht(ee),Dt(le,Ee,ee),vn(Ee,y.subarray(32)),we(le,Ee),Ze(W,le),g-=64,b(y,0,W,0)){for(S=0;S<g;S++)m[S]=0;return-1}for(S=0;S<g;S++)m[S]=y[S+64];return L=g,L}var mn=32,vt=24,dr=32,Nr=16,fi=32,as=32,di=32,hi=32,bo=32,qc=vt,_p=dr,bp=Nr,Un=64,hr=32,Br=64,xo=32,wo=64;n.lowlevel={crypto_core_hsalsa20:C,crypto_stream_xor:w,crypto_stream:_,crypto_stream_salsa20_xor:F,crypto_stream_salsa20:v,crypto_onetimeauth:N,crypto_onetimeauth_verify:R,crypto_verify_16:E,crypto_verify_32:b,crypto_secretbox:ie,crypto_secretbox_open:j,crypto_scalarmult:xr,crypto_scalarmult_base:wr,crypto_box_beforenm:Ir,crypto_box_afternm:li,crypto_box:ui,crypto_box_open:Cr,crypto_box_keypair:Ln,crypto_hash:pe,crypto_sign:$t,crypto_sign_keypair:un,crypto_sign_open:At,crypto_secretbox_KEYBYTES:mn,crypto_secretbox_NONCEBYTES:vt,crypto_secretbox_ZEROBYTES:dr,crypto_secretbox_BOXZEROBYTES:Nr,crypto_scalarmult_BYTES:fi,crypto_scalarmult_SCALARBYTES:as,crypto_box_PUBLICKEYBYTES:di,crypto_box_SECRETKEYBYTES:hi,crypto_box_BEFORENMBYTES:bo,crypto_box_NONCEBYTES:qc,crypto_box_ZEROBYTES:_p,crypto_box_BOXZEROBYTES:bp,crypto_sign_BYTES:Un,crypto_sign_PUBLICKEYBYTES:hr,crypto_sign_SECRETKEYBYTES:Br,crypto_sign_SEEDBYTES:xo,crypto_hash_BYTES:wo};function Vc(m,y){if(m.length!==mn)throw new Error("bad key size");if(y.length!==vt)throw new Error("bad nonce size")}function xp(m,y){if(m.length!==di)throw new Error("bad public key size");if(y.length!==hi)throw new Error("bad secret key size")}function fn(){var m,y;for(y=0;y<arguments.length;y++)if((m=Object.prototype.toString.call(arguments[y]))!=="[object Uint8Array]")throw new TypeError("unexpected type "+m+", use Uint8Array")}function Kc(m){for(var y=0;y<m.length;y++)m[y]=0}n.util||(n.util={},n.util.decodeUTF8=n.util.encodeUTF8=n.util.encodeBase64=n.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),n.randomBytes=function(m){var y=new Uint8Array(m);return e(y,m),y},n.secretbox=function(m,y,g){fn(m,y,g),Vc(g,y);for(var d=new Uint8Array(dr+m.length),S=new Uint8Array(d.length),L=0;L<m.length;L++)d[L+dr]=m[L];return ie(S,d,d.length,y,g),S.subarray(Nr)},n.secretbox.open=function(m,y,g){fn(m,y,g),Vc(g,y);for(var d=new Uint8Array(Nr+m.length),S=new Uint8Array(d.length),L=0;L<m.length;L++)d[L+Nr]=m[L];return d.length<32||j(S,d,d.length,y,g)!==0?!1:S.subarray(dr)},n.secretbox.keyLength=mn,n.secretbox.nonceLength=vt,n.secretbox.overheadLength=Nr,n.scalarMult=function(m,y){if(fn(m,y),m.length!==as)throw new Error("bad n size");if(y.length!==fi)throw new Error("bad p size");var g=new Uint8Array(fi);return xr(g,m,y),g},n.scalarMult.base=function(m){if(fn(m),m.length!==as)throw new Error("bad n size");var y=new Uint8Array(fi);return wr(y,m),y},n.scalarMult.scalarLength=as,n.scalarMult.groupElementLength=fi,n.box=function(m,y,g,d){var S=n.box.before(g,d);return n.secretbox(m,y,S)},n.box.before=function(m,y){fn(m,y),xp(m,y);var g=new Uint8Array(bo);return Ir(g,m,y),g},n.box.after=n.secretbox,n.box.open=function(m,y,g,d){var S=n.box.before(g,d);return n.secretbox.open(m,y,S)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var m=new Uint8Array(di),y=new Uint8Array(hi);return Ln(m,y),{publicKey:m,secretKey:y}},n.box.keyPair.fromSecretKey=function(m){if(fn(m),m.length!==hi)throw new Error("bad secret key size");var y=new Uint8Array(di);return wr(y,m),{publicKey:y,secretKey:new Uint8Array(m)}},n.box.publicKeyLength=di,n.box.secretKeyLength=hi,n.box.sharedKeyLength=bo,n.box.nonceLength=qc,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(m,y){if(fn(m,y),y.length!==Br)throw new Error("bad secret key size");var g=new Uint8Array(Un+m.length);return $t(g,m,m.length,y),g},n.sign.open=function(m,y){if(arguments.length!==2)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(fn(m,y),y.length!==hr)throw new Error("bad public key size");var g=new Uint8Array(m.length),d=At(g,m,m.length,y);if(d<0)return null;for(var S=new Uint8Array(d),L=0;L<S.length;L++)S[L]=g[L];return S},n.sign.detached=function(m,y){for(var g=n.sign(m,y),d=new Uint8Array(Un),S=0;S<d.length;S++)d[S]=g[S];return d},n.sign.detached.verify=function(m,y,g){if(fn(m,y,g),y.length!==Un)throw new Error("bad signature size");if(g.length!==hr)throw new Error("bad public key size");var d=new Uint8Array(Un+m.length),S=new Uint8Array(Un+m.length),L;for(L=0;L<Un;L++)d[L]=y[L];for(L=0;L<m.length;L++)d[L+Un]=m[L];return At(S,d,d.length,g)>=0},n.sign.keyPair=function(){var m=new Uint8Array(hr),y=new Uint8Array(Br);return un(m,y),{publicKey:m,secretKey:y}},n.sign.keyPair.fromSecretKey=function(m){if(fn(m),m.length!==Br)throw new Error("bad secret key size");for(var y=new Uint8Array(hr),g=0;g<y.length;g++)y[g]=m[32+g];return{publicKey:y,secretKey:new Uint8Array(m)}},n.sign.keyPair.fromSeed=function(m){if(fn(m),m.length!==xo)throw new Error("bad seed size");for(var y=new Uint8Array(hr),g=new Uint8Array(Br),d=0;d<32;d++)g[d]=m[d];return un(y,g,!0),{publicKey:y,secretKey:g}},n.sign.publicKeyLength=hr,n.sign.secretKeyLength=Br,n.sign.seedLength=xo,n.sign.signatureLength=Un,n.hash=function(m){fn(m);var y=new Uint8Array(wo);return pe(y,m,m.length),y},n.hash.hashLength=wo,n.verify=function(m,y){return fn(m,y),m.length===0||y.length===0||m.length!==y.length?!1:A(m,0,y,0,m.length)===0},n.setPRNG=function(m){e=m},(function(){var m=typeof self<"u"?self.crypto||self.msCrypto:null;if(m&&m.getRandomValues){var y=65536;n.setPRNG(function(g,d){var S,L=new Uint8Array(d);for(S=0;S<d;S+=y)m.getRandomValues(L.subarray(S,S+Math.min(d-S,y)));for(S=0;S<d;S++)g[S]=L[S];Kc(L)})}else typeof require<"u"&&(m=require("crypto"),m&&m.randomBytes&&n.setPRNG(function(g,d){var S,L=m.randomBytes(d);for(S=0;S<d;S++)g[S]=L[S];Kc(L)}))})()})(typeof Bs<"u"&&Bs.exports?Bs.exports:self.nacl=self.nacl||{})});var Ko=ut((Ix,Ef)=>{"use strict";var Wo=yf().lowlevel.crypto_hash,Qn=0,gr=function(){this.S=[new Uint32Array([3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946]),new Uint32Array([1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055]),new Uint32Array([3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504]),new Uint32Array([976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462])],this.P=new Uint32Array([608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731])};function Ps(n,t,e){return(n[0][t[e+3]]+n[1][t[e+2]]^n[2][t[e+1]])+n[3][t[e]]}gr.prototype.encipher=function(n,t){t===void 0&&(t=new Uint8Array(n.buffer),n.byteOffset!==0&&(t=t.subarray(n.byteOffset))),n[0]^=this.P[0];for(var e=1;e<16;e+=2)n[1]^=Ps(this.S,t,0)^this.P[e],n[0]^=Ps(this.S,t,4)^this.P[e+1];var r=n[0];n[0]=n[1]^this.P[17],n[1]=r};gr.prototype.decipher=function(n){var t=new Uint8Array(n.buffer);n.byteOffset!==0&&(t=t.subarray(n.byteOffset)),n[0]^=this.P[17];for(var e=16;e>0;e-=2)n[1]^=Ps(this.S,t,0)^this.P[e],n[0]^=Ps(this.S,t,4)^this.P[e-1];var r=n[0];n[0]=n[1]^this.P[0],n[1]=r};function mr(n,t){var e,r=0;for(e=0;e<4;e++,Qn++)Qn>=t&&(Qn=0),r=r<<8|n[Qn];return r}gr.prototype.expand0state=function(n,t){var e=new Uint32Array(2),r,s,i=new Uint8Array(e.buffer);for(r=0,Qn=0;r<18;r++)this.P[r]^=mr(n,t);for(Qn=0,r=0;r<18;r+=2)this.encipher(e,i),this.P[r]=e[0],this.P[r+1]=e[1];for(r=0;r<4;r++)for(s=0;s<256;s+=2)this.encipher(e,i),this.S[r][s]=e[0],this.S[r][s+1]=e[1]};gr.prototype.expandstate=function(n,t,e,r){var s=new Uint32Array(2),i,o;for(i=0,Qn=0;i<18;i++)this.P[i]^=mr(e,r);for(i=0,Qn=0;i<18;i+=2)s[0]^=mr(n,t),s[1]^=mr(n,t),this.encipher(s),this.P[i]=s[0],this.P[i+1]=s[1];for(i=0;i<4;i++)for(o=0;o<256;o+=2)s[0]^=mr(n,t),s[1]^=mr(n,t),this.encipher(s),this.S[i][o]=s[0],this.S[i][o+1]=s[1];Qn=0};gr.prototype.enc=function(n,t){for(var e=0;e<t;e++)this.encipher(n.subarray(e*2))};gr.prototype.dec=function(n,t){for(var e=0;e<t;e++)this.decipher(n.subarray(e*2))};var Rs=8,qo=32;function Vo(n,t,e){var r=new gr,s=new Uint32Array(Rs),i,o=new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,105,116,101]);for(r.expandstate(t,64,n,64),i=0;i<64;i++)r.expand0state(t,64),r.expand0state(n,64);for(i=0;i<Rs;i++)s[i]=mr(o,o.byteLength);for(i=0;i<64;i++)r.enc(s,s.byteLength/8);for(i=0;i<Rs;i++)e[4*i+3]=s[i]>>>24,e[4*i+2]=s[i]>>>16,e[4*i+1]=s[i]>>>8,e[4*i+0]=s[i]}function Vm(n,t,e,r,s,i,o){var a=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(qo),u=new Uint8Array(qo),f=new Uint8Array(r+4),h,p,A,E,b,x,P=i;if(o<1||t===0||r===0||i===0||i>l.byteLength*l.byteLength||r>1<<20)return-1;for(E=Math.floor((i+l.byteLength-1)/l.byteLength),A=Math.floor((i+E-1)/E),h=0;h<r;h++)f[h]=e[h];for(Wo(a,n,t),x=1;i>0;x++){for(f[r+0]=x>>>24,f[r+1]=x>>>16,f[r+2]=x>>>8,f[r+3]=x,Wo(c,f,r+4),Vo(a,c,u),h=l.byteLength;h--;)l[h]=u[h];for(h=1;h<o;h++)for(Wo(c,u,u.byteLength),Vo(a,c,u),p=0;p<l.byteLength;p++)l[p]^=u[p];for(A=Math.min(A,i),h=0;h<A&&(b=h*E+(x-1),!(b>=P));h++)s[b]=l[h];i-=h}return 0}Ef.exports={BLOCKS:Rs,HASHSIZE:qo,hash:Vo,pbkdf:Vm}});var qn=ut((Cx,Os)=>{"use strict";var Wn=require("crypto"),Qr;try{Qr=require("cpu-features")()}catch{}var{bindingAvailable:Sf,CIPHER_INFO:Km,MAC_INFO:zm}=tr(),_f=(()=>{if(typeof Wn.sign=="function"&&typeof Wn.verify=="function"){let n=`-----BEGIN PRIVATE KEY-----\r
|
|
2
|
+
"use strict";var wp=Object.create;var zc=Object.defineProperty;var Ip=Object.getOwnPropertyDescriptor;var Cp=Object.getOwnPropertyNames;var kp=Object.getPrototypeOf,vp=Object.prototype.hasOwnProperty;var ut=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var Np=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Cp(t))!vp.call(n,s)&&s!==e&&zc(n,s,{get:()=>t[s],enumerable:!(r=Ip(t,s))||r.enumerable});return n};var Vt=(n,t,e)=>(e=n!=null?wp(kp(n)):{},Np(t||!n||!n.__esModule?zc(e,"default",{value:n,enumerable:!0}):e,n));var bs=ut((Ax,cf)=>{cf.exports={newInvalidAsn1Error:function(n){var t=new Error;return t.name="InvalidAsn1Error",t.message=n||"",t}}});var xs=ut((yx,lf)=>{lf.exports={EOC:0,Boolean:1,Integer:2,BitString:3,OctetString:4,Null:5,OID:6,ObjectDescriptor:7,External:8,Real:9,Enumeration:10,PDV:11,Utf8String:12,RelativeOID:13,Sequence:16,Set:17,NumericString:18,PrintableString:19,T61String:20,VideotexString:21,IA5String:22,UTCTime:23,GeneralizedTime:24,GraphicString:25,VisibleString:26,GeneralString:28,UniversalString:29,CharacterString:30,BMPString:31,Constructor:32,Context:128}});var $o=ut((Ex,uf)=>{"use strict";var ws=require("buffer"),Ur=ws.Buffer,An={},yn;for(yn in ws)ws.hasOwnProperty(yn)&&(yn==="SlowBuffer"||yn==="Buffer"||(An[yn]=ws[yn]));var $r=An.Buffer={};for(yn in Ur)Ur.hasOwnProperty(yn)&&(yn==="allocUnsafe"||yn==="allocUnsafeSlow"||($r[yn]=Ur[yn]));An.Buffer.prototype=Ur.prototype;(!$r.from||$r.from===Uint8Array.from)&&($r.from=function(n,t,e){if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof n);if(n&&typeof n.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);return Ur(n,t,e)});$r.alloc||($r.alloc=function(n,t,e){if(typeof n!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof n);if(n<0||n>=2*(1<<30))throw new RangeError('The value "'+n+'" is invalid for option "size"');var r=Ur(n);return!t||t.length===0?r.fill(0):typeof e=="string"?r.fill(t,e):r.fill(t),r});if(!An.kStringMaxLength)try{An.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}An.constants||(An.constants={MAX_LENGTH:An.kMaxLength},An.kStringMaxLength&&(An.constants.MAX_STRING_LENGTH=An.kStringMaxLength));uf.exports=An});var hf=ut((Sx,df)=>{var Um=require("assert"),ff=$o().Buffer,_i=xs(),$m=bs(),Fr=$m.newInvalidAsn1Error;function tn(n){if(!n||!ff.isBuffer(n))throw new TypeError("data must be a node Buffer");this._buf=n,this._size=n.length,this._len=0,this._offset=0}Object.defineProperty(tn.prototype,"length",{enumerable:!0,get:function(){return this._len}});Object.defineProperty(tn.prototype,"offset",{enumerable:!0,get:function(){return this._offset}});Object.defineProperty(tn.prototype,"remain",{get:function(){return this._size-this._offset}});Object.defineProperty(tn.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}});tn.prototype.readByte=function(n){if(this._size-this._offset<1)return null;var t=this._buf[this._offset]&255;return n||(this._offset+=1),t};tn.prototype.peek=function(){return this.readByte(!0)};tn.prototype.readLength=function(n){if(n===void 0&&(n=this._offset),n>=this._size)return null;var t=this._buf[n++]&255;if(t===null)return null;if((t&128)===128){if(t&=127,t===0)throw Fr("Indefinite length not supported");if(t>4)throw Fr("encoding too long");if(this._size-n<t)return null;this._len=0;for(var e=0;e<t;e++)this._len=(this._len<<8)+(this._buf[n++]&255)}else this._len=t;return n};tn.prototype.readSequence=function(n){var t=this.peek();if(t===null)return null;if(n!==void 0&&n!==t)throw Fr("Expected 0x"+n.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);return e===null?null:(this._offset=e,t)};tn.prototype.readInt=function(){return this._readTag(_i.Integer)};tn.prototype.readBoolean=function(){return this._readTag(_i.Boolean)!==0};tn.prototype.readEnumeration=function(){return this._readTag(_i.Enumeration)};tn.prototype.readString=function(n,t){n||(n=_i.OctetString);var e=this.peek();if(e===null)return null;if(e!==n)throw Fr("Expected 0x"+n.toString(16)+": got 0x"+e.toString(16));var r=this.readLength(this._offset+1);if(r===null||this.length>this._size-r)return null;if(this._offset=r,this.length===0)return t?ff.alloc(0):"";var s=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,t?s:s.toString("utf8")};tn.prototype.readOID=function(n){n||(n=_i.OID);var t=this.readString(n,!0);if(t===null)return null;for(var e=[],r=0,s=0;s<t.length;s++){var i=t[s]&255;r<<=7,r+=i&127,(i&128)===0&&(e.push(r),r=0)}return r=e.shift(),e.unshift(r%40),e.unshift(r/40>>0),e.join(".")};tn.prototype._readTag=function(n){Um.ok(n!==void 0);var t=this.peek();if(t===null)return null;if(t!==n)throw Fr("Expected 0x"+n.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);if(e===null)return null;if(this.length>4)throw Fr("Integer too long: "+this.length);if(this.length>this._size-e)return null;this._offset=e;for(var r=this._buf[this._offset],s=0,i=0;i<this.length;i++)s<<=8,s|=this._buf[this._offset++]&255;return(r&128)===128&&i!==4&&(s-=1<<i*8),s>>0};df.exports=tn});var mf=ut((_x,pf)=>{var Jn=require("assert"),Is=$o().Buffer,Zn=xs(),Fm=bs(),Cs=Fm.newInvalidAsn1Error,Hm={size:1024,growthFactor:8};function Qm(n,t){Jn.ok(n),Jn.equal(typeof n,"object"),Jn.ok(t),Jn.equal(typeof t,"object");var e=Object.getOwnPropertyNames(n);return e.forEach(function(r){if(!t[r]){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,s)}}),t}function Xt(n){n=Qm(Hm,n||{}),this._buf=Is.alloc(n.size||1024),this._size=this._buf.length,this._offset=0,this._options=n,this._seq=[]}Object.defineProperty(Xt.prototype,"buffer",{get:function(){if(this._seq.length)throw Cs(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)}});Xt.prototype.writeByte=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=n};Xt.prototype.writeInt=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");typeof t!="number"&&(t=Zn.Integer);for(var e=4;((n&4286578688)===0||(n&4286578688)===-8388608)&&e>1;)e--,n<<=8;if(e>4)throw Cs("BER ints cannot be > 0xffffffff");for(this._ensure(2+e),this._buf[this._offset++]=t,this._buf[this._offset++]=e;e-- >0;)this._buf[this._offset++]=(n&4278190080)>>>24,n<<=8};Xt.prototype.writeNull=function(){this.writeByte(Zn.Null),this.writeByte(0)};Xt.prototype.writeEnumeration=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");return typeof t!="number"&&(t=Zn.Enumeration),this.writeInt(n,t)};Xt.prototype.writeBoolean=function(n,t){if(typeof n!="boolean")throw new TypeError("argument must be a Boolean");typeof t!="number"&&(t=Zn.Boolean),this._ensure(3),this._buf[this._offset++]=t,this._buf[this._offset++]=1,this._buf[this._offset++]=n?255:0};Xt.prototype.writeString=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string (was: "+typeof n+")");typeof t!="number"&&(t=Zn.OctetString);var e=Is.byteLength(n);this.writeByte(t),this.writeLength(e),e&&(this._ensure(e),this._buf.write(n,this._offset),this._offset+=e)};Xt.prototype.writeBuffer=function(n,t){if(typeof t!="number")throw new TypeError("tag must be a number");if(!Is.isBuffer(n))throw new TypeError("argument must be a buffer");this.writeByte(t),this.writeLength(n.length),this._ensure(n.length),n.copy(this._buf,this._offset,0,n.length),this._offset+=n.length};Xt.prototype.writeStringArray=function(n){if(!n instanceof Array)throw new TypeError("argument must be an Array[String]");var t=this;n.forEach(function(e){t.writeString(e)})};Xt.prototype.writeOID=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string");if(typeof t!="number"&&(t=Zn.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(n))throw new Error("argument is not a valid OID string");function e(o,a){a<128?o.push(a):a<16384?(o.push(a>>>7|128),o.push(a&127)):a<2097152?(o.push(a>>>14|128),o.push((a>>>7|128)&255),o.push(a&127)):a<268435456?(o.push(a>>>21|128),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127)):(o.push((a>>>28|128)&255),o.push((a>>>21|128)&255),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127))}var r=n.split("."),s=[];s.push(parseInt(r[0],10)*40+parseInt(r[1],10)),r.slice(2).forEach(function(o){e(s,parseInt(o,10))});var i=this;this._ensure(2+s.length),this.writeByte(t),this.writeLength(s.length),s.forEach(function(o){i.writeByte(o)})};Xt.prototype.writeLength=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");if(this._ensure(4),n<=127)this._buf[this._offset++]=n;else if(n<=255)this._buf[this._offset++]=129,this._buf[this._offset++]=n;else if(n<=65535)this._buf[this._offset++]=130,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else if(n<=16777215)this._buf[this._offset++]=131,this._buf[this._offset++]=n>>16,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else throw Cs("Length too long (> 4 bytes)")};Xt.prototype.startSequence=function(n){typeof n!="number"&&(n=Zn.Sequence|Zn.Constructor),this.writeByte(n),this._seq.push(this._offset),this._ensure(3),this._offset+=3};Xt.prototype.endSequence=function(){var n=this._seq.pop(),t=n+3,e=this._offset-t;if(e<=127)this._shift(t,e,-2),this._buf[n]=e;else if(e<=255)this._shift(t,e,-1),this._buf[n]=129,this._buf[n+1]=e;else if(e<=65535)this._buf[n]=130,this._buf[n+1]=e>>8,this._buf[n+2]=e;else if(e<=16777215)this._shift(t,e,1),this._buf[n]=131,this._buf[n+1]=e>>16,this._buf[n+2]=e>>8,this._buf[n+3]=e;else throw Cs("Sequence too long")};Xt.prototype._shift=function(n,t,e){Jn.ok(n!==void 0),Jn.ok(t!==void 0),Jn.ok(e),this._buf.copy(this._buf,n+e,n,n+t),this._offset+=e};Xt.prototype._ensure=function(n){if(Jn.ok(n),this._size-this._offset<n){var t=this._size*this._options.growthFactor;t-this._offset<n&&(t+=n);var e=Is.alloc(t);this._buf.copy(e,0,0,this._offset),this._buf=e,this._size=t}};pf.exports=Xt});var gf=ut((bx,Ns)=>{var Fo=bs(),Ho=xs(),Wm=hf(),qm=mf();Ns.exports={Reader:Wm,Writer:qm};for(ks in Ho)Ho.hasOwnProperty(ks)&&(Ns.exports[ks]=Ho[ks]);var ks;for(vs in Fo)Fo.hasOwnProperty(vs)&&(Ns.exports[vs]=Fo[vs]);var vs});var bi=ut((xx,Af)=>{var Qo=gf();Af.exports={Ber:Qo,BerReader:Qo.Reader,BerWriter:Qo.Writer}});var yf=ut((wx,Bs)=>{(function(n){"use strict";var t=function(m){var y,g=new Float64Array(16);if(m)for(y=0;y<m.length;y++)g[y]=m[y];return g},e=function(){throw new Error("no PRNG")},r=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var i=t(),o=t([1]),a=t([56129,1]),c=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),f=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),h=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(m,y,g,d){m[y]=g>>24&255,m[y+1]=g>>16&255,m[y+2]=g>>8&255,m[y+3]=g&255,m[y+4]=d>>24&255,m[y+5]=d>>16&255,m[y+6]=d>>8&255,m[y+7]=d&255}function A(m,y,g,d,S){var L,W=0;for(L=0;L<S;L++)W|=m[y+L]^g[d+L];return(1&W-1>>>8)-1}function E(m,y,g,d){return A(m,y,g,d,16)}function b(m,y,g,d){return A(m,y,g,d,32)}function x(m,y,g,d){for(var S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,L=g[0]&255|(g[1]&255)<<8|(g[2]&255)<<16|(g[3]&255)<<24,W=g[4]&255|(g[5]&255)<<8|(g[6]&255)<<16|(g[7]&255)<<24,ee=g[8]&255|(g[9]&255)<<8|(g[10]&255)<<16|(g[11]&255)<<24,le=g[12]&255|(g[13]&255)<<8|(g[14]&255)<<16|(g[15]&255)<<24,Ee=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,ge=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,st=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,ye=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,Me=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,De=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,We=g[16]&255|(g[17]&255)<<8|(g[18]&255)<<16|(g[19]&255)<<24,He=g[20]&255|(g[21]&255)<<8|(g[22]&255)<<16|(g[23]&255)<<24,Le=g[24]&255|(g[25]&255)<<8|(g[26]&255)<<16|(g[27]&255)<<24,$e=g[28]&255|(g[29]&255)<<8|(g[30]&255)<<16|(g[31]&255)<<24,Ue=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,Se=S,xe=L,Ae=W,_e=ee,be=le,me=Ee,V=ge,K=st,se=ye,Z=Me,te=De,ce=We,ve=He,qe=Le,Ke=$e,Ve=Ue,I,Ge=0;Ge<20;Ge+=2)I=Se+ve|0,be^=I<<7|I>>>25,I=be+Se|0,se^=I<<9|I>>>23,I=se+be|0,ve^=I<<13|I>>>19,I=ve+se|0,Se^=I<<18|I>>>14,I=me+xe|0,Z^=I<<7|I>>>25,I=Z+me|0,qe^=I<<9|I>>>23,I=qe+Z|0,xe^=I<<13|I>>>19,I=xe+qe|0,me^=I<<18|I>>>14,I=te+V|0,Ke^=I<<7|I>>>25,I=Ke+te|0,Ae^=I<<9|I>>>23,I=Ae+Ke|0,V^=I<<13|I>>>19,I=V+Ae|0,te^=I<<18|I>>>14,I=Ve+ce|0,_e^=I<<7|I>>>25,I=_e+Ve|0,K^=I<<9|I>>>23,I=K+_e|0,ce^=I<<13|I>>>19,I=ce+K|0,Ve^=I<<18|I>>>14,I=Se+_e|0,xe^=I<<7|I>>>25,I=xe+Se|0,Ae^=I<<9|I>>>23,I=Ae+xe|0,_e^=I<<13|I>>>19,I=_e+Ae|0,Se^=I<<18|I>>>14,I=me+be|0,V^=I<<7|I>>>25,I=V+me|0,K^=I<<9|I>>>23,I=K+V|0,be^=I<<13|I>>>19,I=be+K|0,me^=I<<18|I>>>14,I=te+Z|0,ce^=I<<7|I>>>25,I=ce+te|0,se^=I<<9|I>>>23,I=se+ce|0,Z^=I<<13|I>>>19,I=Z+se|0,te^=I<<18|I>>>14,I=Ve+Ke|0,ve^=I<<7|I>>>25,I=ve+Ve|0,qe^=I<<9|I>>>23,I=qe+ve|0,Ke^=I<<13|I>>>19,I=Ke+qe|0,Ve^=I<<18|I>>>14;Se=Se+S|0,xe=xe+L|0,Ae=Ae+W|0,_e=_e+ee|0,be=be+le|0,me=me+Ee|0,V=V+ge|0,K=K+st|0,se=se+ye|0,Z=Z+Me|0,te=te+De|0,ce=ce+We|0,ve=ve+He|0,qe=qe+Le|0,Ke=Ke+$e|0,Ve=Ve+Ue|0,m[0]=Se>>>0&255,m[1]=Se>>>8&255,m[2]=Se>>>16&255,m[3]=Se>>>24&255,m[4]=xe>>>0&255,m[5]=xe>>>8&255,m[6]=xe>>>16&255,m[7]=xe>>>24&255,m[8]=Ae>>>0&255,m[9]=Ae>>>8&255,m[10]=Ae>>>16&255,m[11]=Ae>>>24&255,m[12]=_e>>>0&255,m[13]=_e>>>8&255,m[14]=_e>>>16&255,m[15]=_e>>>24&255,m[16]=be>>>0&255,m[17]=be>>>8&255,m[18]=be>>>16&255,m[19]=be>>>24&255,m[20]=me>>>0&255,m[21]=me>>>8&255,m[22]=me>>>16&255,m[23]=me>>>24&255,m[24]=V>>>0&255,m[25]=V>>>8&255,m[26]=V>>>16&255,m[27]=V>>>24&255,m[28]=K>>>0&255,m[29]=K>>>8&255,m[30]=K>>>16&255,m[31]=K>>>24&255,m[32]=se>>>0&255,m[33]=se>>>8&255,m[34]=se>>>16&255,m[35]=se>>>24&255,m[36]=Z>>>0&255,m[37]=Z>>>8&255,m[38]=Z>>>16&255,m[39]=Z>>>24&255,m[40]=te>>>0&255,m[41]=te>>>8&255,m[42]=te>>>16&255,m[43]=te>>>24&255,m[44]=ce>>>0&255,m[45]=ce>>>8&255,m[46]=ce>>>16&255,m[47]=ce>>>24&255,m[48]=ve>>>0&255,m[49]=ve>>>8&255,m[50]=ve>>>16&255,m[51]=ve>>>24&255,m[52]=qe>>>0&255,m[53]=qe>>>8&255,m[54]=qe>>>16&255,m[55]=qe>>>24&255,m[56]=Ke>>>0&255,m[57]=Ke>>>8&255,m[58]=Ke>>>16&255,m[59]=Ke>>>24&255,m[60]=Ve>>>0&255,m[61]=Ve>>>8&255,m[62]=Ve>>>16&255,m[63]=Ve>>>24&255}function P(m,y,g,d){for(var S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,L=g[0]&255|(g[1]&255)<<8|(g[2]&255)<<16|(g[3]&255)<<24,W=g[4]&255|(g[5]&255)<<8|(g[6]&255)<<16|(g[7]&255)<<24,ee=g[8]&255|(g[9]&255)<<8|(g[10]&255)<<16|(g[11]&255)<<24,le=g[12]&255|(g[13]&255)<<8|(g[14]&255)<<16|(g[15]&255)<<24,Ee=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,ge=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,st=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,ye=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,Me=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,De=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,We=g[16]&255|(g[17]&255)<<8|(g[18]&255)<<16|(g[19]&255)<<24,He=g[20]&255|(g[21]&255)<<8|(g[22]&255)<<16|(g[23]&255)<<24,Le=g[24]&255|(g[25]&255)<<8|(g[26]&255)<<16|(g[27]&255)<<24,$e=g[28]&255|(g[29]&255)<<8|(g[30]&255)<<16|(g[31]&255)<<24,Ue=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,Se=S,xe=L,Ae=W,_e=ee,be=le,me=Ee,V=ge,K=st,se=ye,Z=Me,te=De,ce=We,ve=He,qe=Le,Ke=$e,Ve=Ue,I,Ge=0;Ge<20;Ge+=2)I=Se+ve|0,be^=I<<7|I>>>25,I=be+Se|0,se^=I<<9|I>>>23,I=se+be|0,ve^=I<<13|I>>>19,I=ve+se|0,Se^=I<<18|I>>>14,I=me+xe|0,Z^=I<<7|I>>>25,I=Z+me|0,qe^=I<<9|I>>>23,I=qe+Z|0,xe^=I<<13|I>>>19,I=xe+qe|0,me^=I<<18|I>>>14,I=te+V|0,Ke^=I<<7|I>>>25,I=Ke+te|0,Ae^=I<<9|I>>>23,I=Ae+Ke|0,V^=I<<13|I>>>19,I=V+Ae|0,te^=I<<18|I>>>14,I=Ve+ce|0,_e^=I<<7|I>>>25,I=_e+Ve|0,K^=I<<9|I>>>23,I=K+_e|0,ce^=I<<13|I>>>19,I=ce+K|0,Ve^=I<<18|I>>>14,I=Se+_e|0,xe^=I<<7|I>>>25,I=xe+Se|0,Ae^=I<<9|I>>>23,I=Ae+xe|0,_e^=I<<13|I>>>19,I=_e+Ae|0,Se^=I<<18|I>>>14,I=me+be|0,V^=I<<7|I>>>25,I=V+me|0,K^=I<<9|I>>>23,I=K+V|0,be^=I<<13|I>>>19,I=be+K|0,me^=I<<18|I>>>14,I=te+Z|0,ce^=I<<7|I>>>25,I=ce+te|0,se^=I<<9|I>>>23,I=se+ce|0,Z^=I<<13|I>>>19,I=Z+se|0,te^=I<<18|I>>>14,I=Ve+Ke|0,ve^=I<<7|I>>>25,I=ve+Ve|0,qe^=I<<9|I>>>23,I=qe+ve|0,Ke^=I<<13|I>>>19,I=Ke+qe|0,Ve^=I<<18|I>>>14;m[0]=Se>>>0&255,m[1]=Se>>>8&255,m[2]=Se>>>16&255,m[3]=Se>>>24&255,m[4]=me>>>0&255,m[5]=me>>>8&255,m[6]=me>>>16&255,m[7]=me>>>24&255,m[8]=te>>>0&255,m[9]=te>>>8&255,m[10]=te>>>16&255,m[11]=te>>>24&255,m[12]=Ve>>>0&255,m[13]=Ve>>>8&255,m[14]=Ve>>>16&255,m[15]=Ve>>>24&255,m[16]=V>>>0&255,m[17]=V>>>8&255,m[18]=V>>>16&255,m[19]=V>>>24&255,m[20]=K>>>0&255,m[21]=K>>>8&255,m[22]=K>>>16&255,m[23]=K>>>24&255,m[24]=se>>>0&255,m[25]=se>>>8&255,m[26]=se>>>16&255,m[27]=se>>>24&255,m[28]=Z>>>0&255,m[29]=Z>>>8&255,m[30]=Z>>>16&255,m[31]=Z>>>24&255}function q(m,y,g,d){x(m,y,g,d)}function C(m,y,g,d){P(m,y,g,d)}var $=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function F(m,y,g,d,S,L,W){var ee=new Uint8Array(16),le=new Uint8Array(64),Ee,ge;for(ge=0;ge<16;ge++)ee[ge]=0;for(ge=0;ge<8;ge++)ee[ge]=L[ge];for(;S>=64;){for(q(le,ee,W,$),ge=0;ge<64;ge++)m[y+ge]=g[d+ge]^le[ge];for(Ee=1,ge=8;ge<16;ge++)Ee=Ee+(ee[ge]&255)|0,ee[ge]=Ee&255,Ee>>>=8;S-=64,y+=64,d+=64}if(S>0)for(q(le,ee,W,$),ge=0;ge<S;ge++)m[y+ge]=g[d+ge]^le[ge];return 0}function v(m,y,g,d,S){var L=new Uint8Array(16),W=new Uint8Array(64),ee,le;for(le=0;le<16;le++)L[le]=0;for(le=0;le<8;le++)L[le]=d[le];for(;g>=64;){for(q(W,L,S,$),le=0;le<64;le++)m[y+le]=W[le];for(ee=1,le=8;le<16;le++)ee=ee+(L[le]&255)|0,L[le]=ee&255,ee>>>=8;g-=64,y+=64}if(g>0)for(q(W,L,S,$),le=0;le<g;le++)m[y+le]=W[le];return 0}function _(m,y,g,d,S){var L=new Uint8Array(32);C(L,d,S,$);for(var W=new Uint8Array(8),ee=0;ee<8;ee++)W[ee]=d[ee+16];return v(m,y,g,W,L)}function w(m,y,g,d,S,L,W){var ee=new Uint8Array(32);C(ee,L,W,$);for(var le=new Uint8Array(8),Ee=0;Ee<8;Ee++)le[Ee]=L[Ee+16];return F(m,y,g,d,S,le,ee)}var k=function(m){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var y,g,d,S,L,W,ee,le;y=m[0]&255|(m[1]&255)<<8,this.r[0]=y&8191,g=m[2]&255|(m[3]&255)<<8,this.r[1]=(y>>>13|g<<3)&8191,d=m[4]&255|(m[5]&255)<<8,this.r[2]=(g>>>10|d<<6)&7939,S=m[6]&255|(m[7]&255)<<8,this.r[3]=(d>>>7|S<<9)&8191,L=m[8]&255|(m[9]&255)<<8,this.r[4]=(S>>>4|L<<12)&255,this.r[5]=L>>>1&8190,W=m[10]&255|(m[11]&255)<<8,this.r[6]=(L>>>14|W<<2)&8191,ee=m[12]&255|(m[13]&255)<<8,this.r[7]=(W>>>11|ee<<5)&8065,le=m[14]&255|(m[15]&255)<<8,this.r[8]=(ee>>>8|le<<8)&8191,this.r[9]=le>>>5&127,this.pad[0]=m[16]&255|(m[17]&255)<<8,this.pad[1]=m[18]&255|(m[19]&255)<<8,this.pad[2]=m[20]&255|(m[21]&255)<<8,this.pad[3]=m[22]&255|(m[23]&255)<<8,this.pad[4]=m[24]&255|(m[25]&255)<<8,this.pad[5]=m[26]&255|(m[27]&255)<<8,this.pad[6]=m[28]&255|(m[29]&255)<<8,this.pad[7]=m[30]&255|(m[31]&255)<<8};k.prototype.blocks=function(m,y,g){for(var d=this.fin?0:2048,S,L,W,ee,le,Ee,ge,st,ye,Me,De,We,He,Le,$e,Ue,Se,xe,Ae,_e=this.h[0],be=this.h[1],me=this.h[2],V=this.h[3],K=this.h[4],se=this.h[5],Z=this.h[6],te=this.h[7],ce=this.h[8],ve=this.h[9],qe=this.r[0],Ke=this.r[1],Ve=this.r[2],I=this.r[3],Ge=this.r[4],ot=this.r[5],at=this.r[6],ze=this.r[7],tt=this.r[8],nt=this.r[9];g>=16;)S=m[y+0]&255|(m[y+1]&255)<<8,_e+=S&8191,L=m[y+2]&255|(m[y+3]&255)<<8,be+=(S>>>13|L<<3)&8191,W=m[y+4]&255|(m[y+5]&255)<<8,me+=(L>>>10|W<<6)&8191,ee=m[y+6]&255|(m[y+7]&255)<<8,V+=(W>>>7|ee<<9)&8191,le=m[y+8]&255|(m[y+9]&255)<<8,K+=(ee>>>4|le<<12)&8191,se+=le>>>1&8191,Ee=m[y+10]&255|(m[y+11]&255)<<8,Z+=(le>>>14|Ee<<2)&8191,ge=m[y+12]&255|(m[y+13]&255)<<8,te+=(Ee>>>11|ge<<5)&8191,st=m[y+14]&255|(m[y+15]&255)<<8,ce+=(ge>>>8|st<<8)&8191,ve+=st>>>5|d,ye=0,Me=ye,Me+=_e*qe,Me+=be*(5*nt),Me+=me*(5*tt),Me+=V*(5*ze),Me+=K*(5*at),ye=Me>>>13,Me&=8191,Me+=se*(5*ot),Me+=Z*(5*Ge),Me+=te*(5*I),Me+=ce*(5*Ve),Me+=ve*(5*Ke),ye+=Me>>>13,Me&=8191,De=ye,De+=_e*Ke,De+=be*qe,De+=me*(5*nt),De+=V*(5*tt),De+=K*(5*ze),ye=De>>>13,De&=8191,De+=se*(5*at),De+=Z*(5*ot),De+=te*(5*Ge),De+=ce*(5*I),De+=ve*(5*Ve),ye+=De>>>13,De&=8191,We=ye,We+=_e*Ve,We+=be*Ke,We+=me*qe,We+=V*(5*nt),We+=K*(5*tt),ye=We>>>13,We&=8191,We+=se*(5*ze),We+=Z*(5*at),We+=te*(5*ot),We+=ce*(5*Ge),We+=ve*(5*I),ye+=We>>>13,We&=8191,He=ye,He+=_e*I,He+=be*Ve,He+=me*Ke,He+=V*qe,He+=K*(5*nt),ye=He>>>13,He&=8191,He+=se*(5*tt),He+=Z*(5*ze),He+=te*(5*at),He+=ce*(5*ot),He+=ve*(5*Ge),ye+=He>>>13,He&=8191,Le=ye,Le+=_e*Ge,Le+=be*I,Le+=me*Ve,Le+=V*Ke,Le+=K*qe,ye=Le>>>13,Le&=8191,Le+=se*(5*nt),Le+=Z*(5*tt),Le+=te*(5*ze),Le+=ce*(5*at),Le+=ve*(5*ot),ye+=Le>>>13,Le&=8191,$e=ye,$e+=_e*ot,$e+=be*Ge,$e+=me*I,$e+=V*Ve,$e+=K*Ke,ye=$e>>>13,$e&=8191,$e+=se*qe,$e+=Z*(5*nt),$e+=te*(5*tt),$e+=ce*(5*ze),$e+=ve*(5*at),ye+=$e>>>13,$e&=8191,Ue=ye,Ue+=_e*at,Ue+=be*ot,Ue+=me*Ge,Ue+=V*I,Ue+=K*Ve,ye=Ue>>>13,Ue&=8191,Ue+=se*Ke,Ue+=Z*qe,Ue+=te*(5*nt),Ue+=ce*(5*tt),Ue+=ve*(5*ze),ye+=Ue>>>13,Ue&=8191,Se=ye,Se+=_e*ze,Se+=be*at,Se+=me*ot,Se+=V*Ge,Se+=K*I,ye=Se>>>13,Se&=8191,Se+=se*Ve,Se+=Z*Ke,Se+=te*qe,Se+=ce*(5*nt),Se+=ve*(5*tt),ye+=Se>>>13,Se&=8191,xe=ye,xe+=_e*tt,xe+=be*ze,xe+=me*at,xe+=V*ot,xe+=K*Ge,ye=xe>>>13,xe&=8191,xe+=se*I,xe+=Z*Ve,xe+=te*Ke,xe+=ce*qe,xe+=ve*(5*nt),ye+=xe>>>13,xe&=8191,Ae=ye,Ae+=_e*nt,Ae+=be*tt,Ae+=me*ze,Ae+=V*at,Ae+=K*ot,ye=Ae>>>13,Ae&=8191,Ae+=se*Ge,Ae+=Z*I,Ae+=te*Ve,Ae+=ce*Ke,Ae+=ve*qe,ye+=Ae>>>13,Ae&=8191,ye=(ye<<2)+ye|0,ye=ye+Me|0,Me=ye&8191,ye=ye>>>13,De+=ye,_e=Me,be=De,me=We,V=He,K=Le,se=$e,Z=Ue,te=Se,ce=xe,ve=Ae,y+=16,g-=16;this.h[0]=_e,this.h[1]=be,this.h[2]=me,this.h[3]=V,this.h[4]=K,this.h[5]=se,this.h[6]=Z,this.h[7]=te,this.h[8]=ce,this.h[9]=ve},k.prototype.finish=function(m,y){var g=new Uint16Array(10),d,S,L,W;if(this.leftover){for(W=this.leftover,this.buffer[W++]=1;W<16;W++)this.buffer[W]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(d=this.h[1]>>>13,this.h[1]&=8191,W=2;W<10;W++)this.h[W]+=d,d=this.h[W]>>>13,this.h[W]&=8191;for(this.h[0]+=d*5,d=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=d,d=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=d,g[0]=this.h[0]+5,d=g[0]>>>13,g[0]&=8191,W=1;W<10;W++)g[W]=this.h[W]+d,d=g[W]>>>13,g[W]&=8191;for(g[9]-=8192,S=(d^1)-1,W=0;W<10;W++)g[W]&=S;for(S=~S,W=0;W<10;W++)this.h[W]=this.h[W]&S|g[W];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,L=this.h[0]+this.pad[0],this.h[0]=L&65535,W=1;W<8;W++)L=(this.h[W]+this.pad[W]|0)+(L>>>16)|0,this.h[W]=L&65535;m[y+0]=this.h[0]>>>0&255,m[y+1]=this.h[0]>>>8&255,m[y+2]=this.h[1]>>>0&255,m[y+3]=this.h[1]>>>8&255,m[y+4]=this.h[2]>>>0&255,m[y+5]=this.h[2]>>>8&255,m[y+6]=this.h[3]>>>0&255,m[y+7]=this.h[3]>>>8&255,m[y+8]=this.h[4]>>>0&255,m[y+9]=this.h[4]>>>8&255,m[y+10]=this.h[5]>>>0&255,m[y+11]=this.h[5]>>>8&255,m[y+12]=this.h[6]>>>0&255,m[y+13]=this.h[6]>>>8&255,m[y+14]=this.h[7]>>>0&255,m[y+15]=this.h[7]>>>8&255},k.prototype.update=function(m,y,g){var d,S;if(this.leftover){for(S=16-this.leftover,S>g&&(S=g),d=0;d<S;d++)this.buffer[this.leftover+d]=m[y+d];if(g-=S,y+=S,this.leftover+=S,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(g>=16&&(S=g-g%16,this.blocks(m,y,S),y+=S,g-=S),g){for(d=0;d<g;d++)this.buffer[this.leftover+d]=m[y+d];this.leftover+=g}};function N(m,y,g,d,S,L){var W=new k(L);return W.update(g,d,S),W.finish(m,y),0}function R(m,y,g,d,S,L){var W=new Uint8Array(16);return N(W,0,g,d,S,L),E(m,y,W,0)}function ie(m,y,g,d,S){var L;if(g<32)return-1;for(w(m,0,y,0,g,d,S),N(m,16,m,32,g-32,m),L=0;L<16;L++)m[L]=0;return 0}function j(m,y,g,d,S){var L,W=new Uint8Array(32);if(g<32||(_(W,0,32,d,S),R(y,16,y,32,g-32,W)!==0))return-1;for(w(m,0,y,0,g,d,S),L=0;L<32;L++)m[L]=0;return 0}function X(m,y){var g;for(g=0;g<16;g++)m[g]=y[g]|0}function re(m){var y,g,d=1;for(y=0;y<16;y++)g=m[y]+d+65535,d=Math.floor(g/65536),m[y]=g-d*65536;m[0]+=d-1+37*(d-1)}function fe(m,y,g){for(var d,S=~(g-1),L=0;L<16;L++)d=S&(m[L]^y[L]),m[L]^=d,y[L]^=d}function H(m,y){var g,d,S,L=t(),W=t();for(g=0;g<16;g++)W[g]=y[g];for(re(W),re(W),re(W),d=0;d<2;d++){for(L[0]=W[0]-65517,g=1;g<15;g++)L[g]=W[g]-65535-(L[g-1]>>16&1),L[g-1]&=65535;L[15]=W[15]-32767-(L[14]>>16&1),S=L[15]>>16&1,L[14]&=65535,fe(W,L,1-S)}for(g=0;g<16;g++)m[2*g]=W[g]&255,m[2*g+1]=W[g]>>8}function B(m,y){var g=new Uint8Array(32),d=new Uint8Array(32);return H(g,m),H(d,y),b(g,0,d,0)}function D(m){var y=new Uint8Array(32);return H(y,m),y[0]&1}function z(m,y){var g;for(g=0;g<16;g++)m[g]=y[2*g]+(y[2*g+1]<<8);m[15]&=32767}function ne(m,y,g){for(var d=0;d<16;d++)m[d]=y[d]+g[d]}function de(m,y,g){for(var d=0;d<16;d++)m[d]=y[d]-g[d]}function oe(m,y,g){var d,S,L=0,W=0,ee=0,le=0,Ee=0,ge=0,st=0,ye=0,Me=0,De=0,We=0,He=0,Le=0,$e=0,Ue=0,Se=0,xe=0,Ae=0,_e=0,be=0,me=0,V=0,K=0,se=0,Z=0,te=0,ce=0,ve=0,qe=0,Ke=0,Ve=0,I=g[0],Ge=g[1],ot=g[2],at=g[3],ze=g[4],tt=g[5],nt=g[6],Tt=g[7],pt=g[8],Bt=g[9],Rt=g[10],Pt=g[11],Ft=g[12],Gt=g[13],Yt=g[14],jt=g[15];d=y[0],L+=d*I,W+=d*Ge,ee+=d*ot,le+=d*at,Ee+=d*ze,ge+=d*tt,st+=d*nt,ye+=d*Tt,Me+=d*pt,De+=d*Bt,We+=d*Rt,He+=d*Pt,Le+=d*Ft,$e+=d*Gt,Ue+=d*Yt,Se+=d*jt,d=y[1],W+=d*I,ee+=d*Ge,le+=d*ot,Ee+=d*at,ge+=d*ze,st+=d*tt,ye+=d*nt,Me+=d*Tt,De+=d*pt,We+=d*Bt,He+=d*Rt,Le+=d*Pt,$e+=d*Ft,Ue+=d*Gt,Se+=d*Yt,xe+=d*jt,d=y[2],ee+=d*I,le+=d*Ge,Ee+=d*ot,ge+=d*at,st+=d*ze,ye+=d*tt,Me+=d*nt,De+=d*Tt,We+=d*pt,He+=d*Bt,Le+=d*Rt,$e+=d*Pt,Ue+=d*Ft,Se+=d*Gt,xe+=d*Yt,Ae+=d*jt,d=y[3],le+=d*I,Ee+=d*Ge,ge+=d*ot,st+=d*at,ye+=d*ze,Me+=d*tt,De+=d*nt,We+=d*Tt,He+=d*pt,Le+=d*Bt,$e+=d*Rt,Ue+=d*Pt,Se+=d*Ft,xe+=d*Gt,Ae+=d*Yt,_e+=d*jt,d=y[4],Ee+=d*I,ge+=d*Ge,st+=d*ot,ye+=d*at,Me+=d*ze,De+=d*tt,We+=d*nt,He+=d*Tt,Le+=d*pt,$e+=d*Bt,Ue+=d*Rt,Se+=d*Pt,xe+=d*Ft,Ae+=d*Gt,_e+=d*Yt,be+=d*jt,d=y[5],ge+=d*I,st+=d*Ge,ye+=d*ot,Me+=d*at,De+=d*ze,We+=d*tt,He+=d*nt,Le+=d*Tt,$e+=d*pt,Ue+=d*Bt,Se+=d*Rt,xe+=d*Pt,Ae+=d*Ft,_e+=d*Gt,be+=d*Yt,me+=d*jt,d=y[6],st+=d*I,ye+=d*Ge,Me+=d*ot,De+=d*at,We+=d*ze,He+=d*tt,Le+=d*nt,$e+=d*Tt,Ue+=d*pt,Se+=d*Bt,xe+=d*Rt,Ae+=d*Pt,_e+=d*Ft,be+=d*Gt,me+=d*Yt,V+=d*jt,d=y[7],ye+=d*I,Me+=d*Ge,De+=d*ot,We+=d*at,He+=d*ze,Le+=d*tt,$e+=d*nt,Ue+=d*Tt,Se+=d*pt,xe+=d*Bt,Ae+=d*Rt,_e+=d*Pt,be+=d*Ft,me+=d*Gt,V+=d*Yt,K+=d*jt,d=y[8],Me+=d*I,De+=d*Ge,We+=d*ot,He+=d*at,Le+=d*ze,$e+=d*tt,Ue+=d*nt,Se+=d*Tt,xe+=d*pt,Ae+=d*Bt,_e+=d*Rt,be+=d*Pt,me+=d*Ft,V+=d*Gt,K+=d*Yt,se+=d*jt,d=y[9],De+=d*I,We+=d*Ge,He+=d*ot,Le+=d*at,$e+=d*ze,Ue+=d*tt,Se+=d*nt,xe+=d*Tt,Ae+=d*pt,_e+=d*Bt,be+=d*Rt,me+=d*Pt,V+=d*Ft,K+=d*Gt,se+=d*Yt,Z+=d*jt,d=y[10],We+=d*I,He+=d*Ge,Le+=d*ot,$e+=d*at,Ue+=d*ze,Se+=d*tt,xe+=d*nt,Ae+=d*Tt,_e+=d*pt,be+=d*Bt,me+=d*Rt,V+=d*Pt,K+=d*Ft,se+=d*Gt,Z+=d*Yt,te+=d*jt,d=y[11],He+=d*I,Le+=d*Ge,$e+=d*ot,Ue+=d*at,Se+=d*ze,xe+=d*tt,Ae+=d*nt,_e+=d*Tt,be+=d*pt,me+=d*Bt,V+=d*Rt,K+=d*Pt,se+=d*Ft,Z+=d*Gt,te+=d*Yt,ce+=d*jt,d=y[12],Le+=d*I,$e+=d*Ge,Ue+=d*ot,Se+=d*at,xe+=d*ze,Ae+=d*tt,_e+=d*nt,be+=d*Tt,me+=d*pt,V+=d*Bt,K+=d*Rt,se+=d*Pt,Z+=d*Ft,te+=d*Gt,ce+=d*Yt,ve+=d*jt,d=y[13],$e+=d*I,Ue+=d*Ge,Se+=d*ot,xe+=d*at,Ae+=d*ze,_e+=d*tt,be+=d*nt,me+=d*Tt,V+=d*pt,K+=d*Bt,se+=d*Rt,Z+=d*Pt,te+=d*Ft,ce+=d*Gt,ve+=d*Yt,qe+=d*jt,d=y[14],Ue+=d*I,Se+=d*Ge,xe+=d*ot,Ae+=d*at,_e+=d*ze,be+=d*tt,me+=d*nt,V+=d*Tt,K+=d*pt,se+=d*Bt,Z+=d*Rt,te+=d*Pt,ce+=d*Ft,ve+=d*Gt,qe+=d*Yt,Ke+=d*jt,d=y[15],Se+=d*I,xe+=d*Ge,Ae+=d*ot,_e+=d*at,be+=d*ze,me+=d*tt,V+=d*nt,K+=d*Tt,se+=d*pt,Z+=d*Bt,te+=d*Rt,ce+=d*Pt,ve+=d*Ft,qe+=d*Gt,Ke+=d*Yt,Ve+=d*jt,L+=38*xe,W+=38*Ae,ee+=38*_e,le+=38*be,Ee+=38*me,ge+=38*V,st+=38*K,ye+=38*se,Me+=38*Z,De+=38*te,We+=38*ce,He+=38*ve,Le+=38*qe,$e+=38*Ke,Ue+=38*Ve,S=1,d=L+S+65535,S=Math.floor(d/65536),L=d-S*65536,d=W+S+65535,S=Math.floor(d/65536),W=d-S*65536,d=ee+S+65535,S=Math.floor(d/65536),ee=d-S*65536,d=le+S+65535,S=Math.floor(d/65536),le=d-S*65536,d=Ee+S+65535,S=Math.floor(d/65536),Ee=d-S*65536,d=ge+S+65535,S=Math.floor(d/65536),ge=d-S*65536,d=st+S+65535,S=Math.floor(d/65536),st=d-S*65536,d=ye+S+65535,S=Math.floor(d/65536),ye=d-S*65536,d=Me+S+65535,S=Math.floor(d/65536),Me=d-S*65536,d=De+S+65535,S=Math.floor(d/65536),De=d-S*65536,d=We+S+65535,S=Math.floor(d/65536),We=d-S*65536,d=He+S+65535,S=Math.floor(d/65536),He=d-S*65536,d=Le+S+65535,S=Math.floor(d/65536),Le=d-S*65536,d=$e+S+65535,S=Math.floor(d/65536),$e=d-S*65536,d=Ue+S+65535,S=Math.floor(d/65536),Ue=d-S*65536,d=Se+S+65535,S=Math.floor(d/65536),Se=d-S*65536,L+=S-1+37*(S-1),S=1,d=L+S+65535,S=Math.floor(d/65536),L=d-S*65536,d=W+S+65535,S=Math.floor(d/65536),W=d-S*65536,d=ee+S+65535,S=Math.floor(d/65536),ee=d-S*65536,d=le+S+65535,S=Math.floor(d/65536),le=d-S*65536,d=Ee+S+65535,S=Math.floor(d/65536),Ee=d-S*65536,d=ge+S+65535,S=Math.floor(d/65536),ge=d-S*65536,d=st+S+65535,S=Math.floor(d/65536),st=d-S*65536,d=ye+S+65535,S=Math.floor(d/65536),ye=d-S*65536,d=Me+S+65535,S=Math.floor(d/65536),Me=d-S*65536,d=De+S+65535,S=Math.floor(d/65536),De=d-S*65536,d=We+S+65535,S=Math.floor(d/65536),We=d-S*65536,d=He+S+65535,S=Math.floor(d/65536),He=d-S*65536,d=Le+S+65535,S=Math.floor(d/65536),Le=d-S*65536,d=$e+S+65535,S=Math.floor(d/65536),$e=d-S*65536,d=Ue+S+65535,S=Math.floor(d/65536),Ue=d-S*65536,d=Se+S+65535,S=Math.floor(d/65536),Se=d-S*65536,L+=S-1+37*(S-1),m[0]=L,m[1]=W,m[2]=ee,m[3]=le,m[4]=Ee,m[5]=ge,m[6]=st,m[7]=ye,m[8]=Me,m[9]=De,m[10]=We,m[11]=He,m[12]=Le,m[13]=$e,m[14]=Ue,m[15]=Se}function Je(m,y){oe(m,y,y)}function ht(m,y){var g=t(),d;for(d=0;d<16;d++)g[d]=y[d];for(d=253;d>=0;d--)Je(g,g),d!==2&&d!==4&&oe(g,g,y);for(d=0;d<16;d++)m[d]=g[d]}function ln(m,y){var g=t(),d;for(d=0;d<16;d++)g[d]=y[d];for(d=250;d>=0;d--)Je(g,g),d!==1&&oe(g,g,y);for(d=0;d<16;d++)m[d]=g[d]}function xr(m,y,g){var d=new Uint8Array(32),S=new Float64Array(80),L,W,ee=t(),le=t(),Ee=t(),ge=t(),st=t(),ye=t();for(W=0;W<31;W++)d[W]=y[W];for(d[31]=y[31]&127|64,d[0]&=248,z(S,g),W=0;W<16;W++)le[W]=S[W],ge[W]=ee[W]=Ee[W]=0;for(ee[0]=ge[0]=1,W=254;W>=0;--W)L=d[W>>>3]>>>(W&7)&1,fe(ee,le,L),fe(Ee,ge,L),ne(st,ee,Ee),de(ee,ee,Ee),ne(Ee,le,ge),de(le,le,ge),Je(ge,st),Je(ye,ee),oe(ee,Ee,ee),oe(Ee,le,st),ne(st,ee,Ee),de(ee,ee,Ee),Je(le,ee),de(Ee,ge,ye),oe(ee,Ee,a),ne(ee,ee,ge),oe(Ee,Ee,ee),oe(ee,ge,ye),oe(ge,le,S),Je(le,st),fe(ee,le,L),fe(Ee,ge,L);for(W=0;W<16;W++)S[W+16]=ee[W],S[W+32]=Ee[W],S[W+48]=le[W],S[W+64]=ge[W];var Me=S.subarray(32),De=S.subarray(16);return ht(Me,Me),oe(De,De,Me),H(m,De),0}function wr(m,y){return xr(m,y,s)}function Ln(m,y){return e(y,32),wr(m,y)}function Ir(m,y,g){var d=new Uint8Array(32);return xr(d,g,y),C(m,r,d,$)}var li=ie,os=j;function ui(m,y,g,d,S,L){var W=new Uint8Array(32);return Ir(W,S,L),li(m,y,g,d,W)}function Cr(m,y,g,d,S,L){var W=new Uint8Array(32);return Ir(W,S,L),os(m,y,g,d,W)}var kr=[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];function J(m,y,g,d){for(var S=new Int32Array(16),L=new Int32Array(16),W,ee,le,Ee,ge,st,ye,Me,De,We,He,Le,$e,Ue,Se,xe,Ae,_e,be,me,V,K,se,Z,te,ce,ve=m[0],qe=m[1],Ke=m[2],Ve=m[3],I=m[4],Ge=m[5],ot=m[6],at=m[7],ze=y[0],tt=y[1],nt=y[2],Tt=y[3],pt=y[4],Bt=y[5],Rt=y[6],Pt=y[7],Ft=0;d>=128;){for(be=0;be<16;be++)me=8*be+Ft,S[be]=g[me+0]<<24|g[me+1]<<16|g[me+2]<<8|g[me+3],L[be]=g[me+4]<<24|g[me+5]<<16|g[me+6]<<8|g[me+7];for(be=0;be<80;be++)if(W=ve,ee=qe,le=Ke,Ee=Ve,ge=I,st=Ge,ye=ot,Me=at,De=ze,We=tt,He=nt,Le=Tt,$e=pt,Ue=Bt,Se=Rt,xe=Pt,V=at,K=Pt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=(I>>>14|pt<<18)^(I>>>18|pt<<14)^(pt>>>9|I<<23),K=(pt>>>14|I<<18)^(pt>>>18|I<<14)^(I>>>9|pt<<23),se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,V=I&Ge^~I&ot,K=pt&Bt^~pt&Rt,se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,V=kr[be*2],K=kr[be*2+1],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,V=S[be%16],K=L[be%16],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,Ae=te&65535|ce<<16,_e=se&65535|Z<<16,V=Ae,K=_e,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=(ve>>>28|ze<<4)^(ze>>>2|ve<<30)^(ze>>>7|ve<<25),K=(ze>>>28|ve<<4)^(ve>>>2|ze<<30)^(ve>>>7|ze<<25),se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,V=ve&qe^ve&Ke^qe&Ke,K=ze&tt^ze&nt^tt&nt,se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,Me=te&65535|ce<<16,xe=se&65535|Z<<16,V=Ee,K=Le,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=Ae,K=_e,se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,Ee=te&65535|ce<<16,Le=se&65535|Z<<16,qe=W,Ke=ee,Ve=le,I=Ee,Ge=ge,ot=st,at=ye,ve=Me,tt=De,nt=We,Tt=He,pt=Le,Bt=$e,Rt=Ue,Pt=Se,ze=xe,be%16===15)for(me=0;me<16;me++)V=S[me],K=L[me],se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=S[(me+9)%16],K=L[(me+9)%16],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Ae=S[(me+1)%16],_e=L[(me+1)%16],V=(Ae>>>1|_e<<31)^(Ae>>>8|_e<<24)^Ae>>>7,K=(_e>>>1|Ae<<31)^(_e>>>8|Ae<<24)^(_e>>>7|Ae<<25),se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Ae=S[(me+14)%16],_e=L[(me+14)%16],V=(Ae>>>19|_e<<13)^(_e>>>29|Ae<<3)^Ae>>>6,K=(_e>>>19|Ae<<13)^(Ae>>>29|_e<<3)^(_e>>>6|Ae<<26),se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,S[me]=te&65535|ce<<16,L[me]=se&65535|Z<<16;V=ve,K=ze,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[0],K=y[0],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[0]=ve=te&65535|ce<<16,y[0]=ze=se&65535|Z<<16,V=qe,K=tt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[1],K=y[1],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[1]=qe=te&65535|ce<<16,y[1]=tt=se&65535|Z<<16,V=Ke,K=nt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[2],K=y[2],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[2]=Ke=te&65535|ce<<16,y[2]=nt=se&65535|Z<<16,V=Ve,K=Tt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[3],K=y[3],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[3]=Ve=te&65535|ce<<16,y[3]=Tt=se&65535|Z<<16,V=I,K=pt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[4],K=y[4],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[4]=I=te&65535|ce<<16,y[4]=pt=se&65535|Z<<16,V=Ge,K=Bt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[5],K=y[5],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[5]=Ge=te&65535|ce<<16,y[5]=Bt=se&65535|Z<<16,V=ot,K=Rt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[6],K=y[6],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[6]=ot=te&65535|ce<<16,y[6]=Rt=se&65535|Z<<16,V=at,K=Pt,se=K&65535,Z=K>>>16,te=V&65535,ce=V>>>16,V=m[7],K=y[7],se+=K&65535,Z+=K>>>16,te+=V&65535,ce+=V>>>16,Z+=se>>>16,te+=Z>>>16,ce+=te>>>16,m[7]=at=te&65535|ce<<16,y[7]=Pt=se&65535|Z<<16,Ft+=128,d-=128}return d}function pe(m,y,g){var d=new Int32Array(8),S=new Int32Array(8),L=new Uint8Array(256),W,ee=g;for(d[0]=1779033703,d[1]=3144134277,d[2]=1013904242,d[3]=2773480762,d[4]=1359893119,d[5]=2600822924,d[6]=528734635,d[7]=1541459225,S[0]=4089235720,S[1]=2227873595,S[2]=4271175723,S[3]=1595750129,S[4]=2917565137,S[5]=725511199,S[6]=4215389547,S[7]=327033209,J(d,S,y,g),g%=128,W=0;W<g;W++)L[W]=y[ee-g+W];for(L[g]=128,g=256-128*(g<112?1:0),L[g-9]=0,p(L,g-8,ee/536870912|0,ee<<3),J(d,S,L,g),W=0;W<8;W++)p(m,8*W,d[W],S[W]);return 0}function we(m,y){var g=t(),d=t(),S=t(),L=t(),W=t(),ee=t(),le=t(),Ee=t(),ge=t();de(g,m[1],m[0]),de(ge,y[1],y[0]),oe(g,g,ge),ne(d,m[0],m[1]),ne(ge,y[0],y[1]),oe(d,d,ge),oe(S,m[3],y[3]),oe(S,S,l),oe(L,m[2],y[2]),ne(L,L,L),de(W,d,g),de(ee,L,S),ne(le,L,S),ne(Ee,d,g),oe(m[0],W,ee),oe(m[1],Ee,le),oe(m[2],le,ee),oe(m[3],W,Ee)}function Oe(m,y,g){var d;for(d=0;d<4;d++)fe(m[d],y[d],g)}function Ze(m,y){var g=t(),d=t(),S=t();ht(S,y[2]),oe(g,y[0],S),oe(d,y[1],S),H(m,d),m[31]^=D(g)<<7}function Lt(m,y,g){var d,S;for(X(m[0],i),X(m[1],o),X(m[2],o),X(m[3],i),S=255;S>=0;--S)d=g[S/8|0]>>(S&7)&1,Oe(m,y,d),we(y,m),we(m,m),Oe(m,y,d)}function vn(m,y){var g=[t(),t(),t(),t()];X(g[0],u),X(g[1],f),X(g[2],o),oe(g[3],u,f),Lt(m,g,y)}function un(m,y,g){var d=new Uint8Array(64),S=[t(),t(),t(),t()],L;for(g||e(y,32),pe(d,y,32),d[0]&=248,d[31]&=127,d[31]|=64,vn(S,d),Ze(m,S),L=0;L<32;L++)y[L+32]=m[L];return 0}var vr=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]);function lt(m,y){var g,d,S,L;for(d=63;d>=32;--d){for(g=0,S=d-32,L=d-12;S<L;++S)y[S]+=g-16*y[d]*vr[S-(d-32)],g=y[S]+128>>8,y[S]-=g*256;y[S]+=g,y[d]=0}for(g=0,S=0;S<32;S++)y[S]+=g-(y[31]>>4)*vr[S],g=y[S]>>8,y[S]&=255;for(S=0;S<32;S++)y[S]-=g*vr[S];for(d=0;d<32;d++)y[d+1]+=y[d]>>8,m[d]=y[d]&255}function Ht(m){var y=new Float64Array(64),g;for(g=0;g<64;g++)y[g]=m[g];for(g=0;g<64;g++)m[g]=0;lt(m,y)}function $t(m,y,g,d){var S=new Uint8Array(64),L=new Uint8Array(64),W=new Uint8Array(64),ee,le,Ee=new Float64Array(64),ge=[t(),t(),t(),t()];pe(S,d,32),S[0]&=248,S[31]&=127,S[31]|=64;var st=g+64;for(ee=0;ee<g;ee++)m[64+ee]=y[ee];for(ee=0;ee<32;ee++)m[32+ee]=S[32+ee];for(pe(W,m.subarray(32),g+32),Ht(W),vn(ge,W),Ze(m,ge),ee=32;ee<64;ee++)m[ee]=d[ee];for(pe(L,m,g+64),Ht(L),ee=0;ee<64;ee++)Ee[ee]=0;for(ee=0;ee<32;ee++)Ee[ee]=W[ee];for(ee=0;ee<32;ee++)for(le=0;le<32;le++)Ee[ee+le]+=L[ee]*S[le];return lt(m.subarray(32),Ee),st}function vt(m,y){var g=t(),d=t(),S=t(),L=t(),W=t(),ee=t(),le=t();return X(m[2],o),z(m[1],y),Je(S,m[1]),oe(L,S,c),de(S,S,m[2]),ne(L,m[2],L),Je(W,L),Je(ee,W),oe(le,ee,W),oe(g,le,S),oe(g,g,L),ln(g,g),oe(g,g,S),oe(g,g,L),oe(g,g,L),oe(m[0],g,L),Je(d,m[0]),oe(d,d,L),B(d,S)&&oe(m[0],m[0],h),Je(d,m[0]),oe(d,d,L),B(d,S)?-1:(D(m[0])===y[31]>>7&&de(m[0],i,m[0]),oe(m[3],m[0],m[1]),0)}function At(m,y,g,d){var S,L,W=new Uint8Array(32),ee=new Uint8Array(64),le=[t(),t(),t(),t()],Ee=[t(),t(),t(),t()];if(L=-1,g<64||vt(Ee,d))return-1;for(S=0;S<g;S++)m[S]=y[S];for(S=0;S<32;S++)m[S+32]=d[S];if(pe(ee,m,g),Ht(ee),Lt(le,Ee,ee),vn(Ee,y.subarray(32)),we(le,Ee),Ze(W,le),g-=64,b(y,0,W,0)){for(S=0;S<g;S++)m[S]=0;return-1}for(S=0;S<g;S++)m[S]=y[S+64];return L=g,L}var mn=32,Nt=24,dr=32,Nr=16,fi=32,as=32,di=32,hi=32,bo=32,qc=Nt,_p=dr,bp=Nr,Un=64,hr=32,Br=64,xo=32,wo=64;n.lowlevel={crypto_core_hsalsa20:C,crypto_stream_xor:w,crypto_stream:_,crypto_stream_salsa20_xor:F,crypto_stream_salsa20:v,crypto_onetimeauth:N,crypto_onetimeauth_verify:R,crypto_verify_16:E,crypto_verify_32:b,crypto_secretbox:ie,crypto_secretbox_open:j,crypto_scalarmult:xr,crypto_scalarmult_base:wr,crypto_box_beforenm:Ir,crypto_box_afternm:li,crypto_box:ui,crypto_box_open:Cr,crypto_box_keypair:Ln,crypto_hash:pe,crypto_sign:$t,crypto_sign_keypair:un,crypto_sign_open:At,crypto_secretbox_KEYBYTES:mn,crypto_secretbox_NONCEBYTES:Nt,crypto_secretbox_ZEROBYTES:dr,crypto_secretbox_BOXZEROBYTES:Nr,crypto_scalarmult_BYTES:fi,crypto_scalarmult_SCALARBYTES:as,crypto_box_PUBLICKEYBYTES:di,crypto_box_SECRETKEYBYTES:hi,crypto_box_BEFORENMBYTES:bo,crypto_box_NONCEBYTES:qc,crypto_box_ZEROBYTES:_p,crypto_box_BOXZEROBYTES:bp,crypto_sign_BYTES:Un,crypto_sign_PUBLICKEYBYTES:hr,crypto_sign_SECRETKEYBYTES:Br,crypto_sign_SEEDBYTES:xo,crypto_hash_BYTES:wo};function Vc(m,y){if(m.length!==mn)throw new Error("bad key size");if(y.length!==Nt)throw new Error("bad nonce size")}function xp(m,y){if(m.length!==di)throw new Error("bad public key size");if(y.length!==hi)throw new Error("bad secret key size")}function fn(){var m,y;for(y=0;y<arguments.length;y++)if((m=Object.prototype.toString.call(arguments[y]))!=="[object Uint8Array]")throw new TypeError("unexpected type "+m+", use Uint8Array")}function Kc(m){for(var y=0;y<m.length;y++)m[y]=0}n.util||(n.util={},n.util.decodeUTF8=n.util.encodeUTF8=n.util.encodeBase64=n.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),n.randomBytes=function(m){var y=new Uint8Array(m);return e(y,m),y},n.secretbox=function(m,y,g){fn(m,y,g),Vc(g,y);for(var d=new Uint8Array(dr+m.length),S=new Uint8Array(d.length),L=0;L<m.length;L++)d[L+dr]=m[L];return ie(S,d,d.length,y,g),S.subarray(Nr)},n.secretbox.open=function(m,y,g){fn(m,y,g),Vc(g,y);for(var d=new Uint8Array(Nr+m.length),S=new Uint8Array(d.length),L=0;L<m.length;L++)d[L+Nr]=m[L];return d.length<32||j(S,d,d.length,y,g)!==0?!1:S.subarray(dr)},n.secretbox.keyLength=mn,n.secretbox.nonceLength=Nt,n.secretbox.overheadLength=Nr,n.scalarMult=function(m,y){if(fn(m,y),m.length!==as)throw new Error("bad n size");if(y.length!==fi)throw new Error("bad p size");var g=new Uint8Array(fi);return xr(g,m,y),g},n.scalarMult.base=function(m){if(fn(m),m.length!==as)throw new Error("bad n size");var y=new Uint8Array(fi);return wr(y,m),y},n.scalarMult.scalarLength=as,n.scalarMult.groupElementLength=fi,n.box=function(m,y,g,d){var S=n.box.before(g,d);return n.secretbox(m,y,S)},n.box.before=function(m,y){fn(m,y),xp(m,y);var g=new Uint8Array(bo);return Ir(g,m,y),g},n.box.after=n.secretbox,n.box.open=function(m,y,g,d){var S=n.box.before(g,d);return n.secretbox.open(m,y,S)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var m=new Uint8Array(di),y=new Uint8Array(hi);return Ln(m,y),{publicKey:m,secretKey:y}},n.box.keyPair.fromSecretKey=function(m){if(fn(m),m.length!==hi)throw new Error("bad secret key size");var y=new Uint8Array(di);return wr(y,m),{publicKey:y,secretKey:new Uint8Array(m)}},n.box.publicKeyLength=di,n.box.secretKeyLength=hi,n.box.sharedKeyLength=bo,n.box.nonceLength=qc,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(m,y){if(fn(m,y),y.length!==Br)throw new Error("bad secret key size");var g=new Uint8Array(Un+m.length);return $t(g,m,m.length,y),g},n.sign.open=function(m,y){if(arguments.length!==2)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(fn(m,y),y.length!==hr)throw new Error("bad public key size");var g=new Uint8Array(m.length),d=At(g,m,m.length,y);if(d<0)return null;for(var S=new Uint8Array(d),L=0;L<S.length;L++)S[L]=g[L];return S},n.sign.detached=function(m,y){for(var g=n.sign(m,y),d=new Uint8Array(Un),S=0;S<d.length;S++)d[S]=g[S];return d},n.sign.detached.verify=function(m,y,g){if(fn(m,y,g),y.length!==Un)throw new Error("bad signature size");if(g.length!==hr)throw new Error("bad public key size");var d=new Uint8Array(Un+m.length),S=new Uint8Array(Un+m.length),L;for(L=0;L<Un;L++)d[L]=y[L];for(L=0;L<m.length;L++)d[L+Un]=m[L];return At(S,d,d.length,g)>=0},n.sign.keyPair=function(){var m=new Uint8Array(hr),y=new Uint8Array(Br);return un(m,y),{publicKey:m,secretKey:y}},n.sign.keyPair.fromSecretKey=function(m){if(fn(m),m.length!==Br)throw new Error("bad secret key size");for(var y=new Uint8Array(hr),g=0;g<y.length;g++)y[g]=m[32+g];return{publicKey:y,secretKey:new Uint8Array(m)}},n.sign.keyPair.fromSeed=function(m){if(fn(m),m.length!==xo)throw new Error("bad seed size");for(var y=new Uint8Array(hr),g=new Uint8Array(Br),d=0;d<32;d++)g[d]=m[d];return un(y,g,!0),{publicKey:y,secretKey:g}},n.sign.publicKeyLength=hr,n.sign.secretKeyLength=Br,n.sign.seedLength=xo,n.sign.signatureLength=Un,n.hash=function(m){fn(m);var y=new Uint8Array(wo);return pe(y,m,m.length),y},n.hash.hashLength=wo,n.verify=function(m,y){return fn(m,y),m.length===0||y.length===0||m.length!==y.length?!1:A(m,0,y,0,m.length)===0},n.setPRNG=function(m){e=m},(function(){var m=typeof self<"u"?self.crypto||self.msCrypto:null;if(m&&m.getRandomValues){var y=65536;n.setPRNG(function(g,d){var S,L=new Uint8Array(d);for(S=0;S<d;S+=y)m.getRandomValues(L.subarray(S,S+Math.min(d-S,y)));for(S=0;S<d;S++)g[S]=L[S];Kc(L)})}else typeof require<"u"&&(m=require("crypto"),m&&m.randomBytes&&n.setPRNG(function(g,d){var S,L=m.randomBytes(d);for(S=0;S<d;S++)g[S]=L[S];Kc(L)}))})()})(typeof Bs<"u"&&Bs.exports?Bs.exports:self.nacl=self.nacl||{})});var Ko=ut((Ix,Ef)=>{"use strict";var Wo=yf().lowlevel.crypto_hash,Qn=0,gr=function(){this.S=[new Uint32Array([3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946]),new Uint32Array([1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055]),new Uint32Array([3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504]),new Uint32Array([976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462])],this.P=new Uint32Array([608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731])};function Ps(n,t,e){return(n[0][t[e+3]]+n[1][t[e+2]]^n[2][t[e+1]])+n[3][t[e]]}gr.prototype.encipher=function(n,t){t===void 0&&(t=new Uint8Array(n.buffer),n.byteOffset!==0&&(t=t.subarray(n.byteOffset))),n[0]^=this.P[0];for(var e=1;e<16;e+=2)n[1]^=Ps(this.S,t,0)^this.P[e],n[0]^=Ps(this.S,t,4)^this.P[e+1];var r=n[0];n[0]=n[1]^this.P[17],n[1]=r};gr.prototype.decipher=function(n){var t=new Uint8Array(n.buffer);n.byteOffset!==0&&(t=t.subarray(n.byteOffset)),n[0]^=this.P[17];for(var e=16;e>0;e-=2)n[1]^=Ps(this.S,t,0)^this.P[e],n[0]^=Ps(this.S,t,4)^this.P[e-1];var r=n[0];n[0]=n[1]^this.P[0],n[1]=r};function mr(n,t){var e,r=0;for(e=0;e<4;e++,Qn++)Qn>=t&&(Qn=0),r=r<<8|n[Qn];return r}gr.prototype.expand0state=function(n,t){var e=new Uint32Array(2),r,s,i=new Uint8Array(e.buffer);for(r=0,Qn=0;r<18;r++)this.P[r]^=mr(n,t);for(Qn=0,r=0;r<18;r+=2)this.encipher(e,i),this.P[r]=e[0],this.P[r+1]=e[1];for(r=0;r<4;r++)for(s=0;s<256;s+=2)this.encipher(e,i),this.S[r][s]=e[0],this.S[r][s+1]=e[1]};gr.prototype.expandstate=function(n,t,e,r){var s=new Uint32Array(2),i,o;for(i=0,Qn=0;i<18;i++)this.P[i]^=mr(e,r);for(i=0,Qn=0;i<18;i+=2)s[0]^=mr(n,t),s[1]^=mr(n,t),this.encipher(s),this.P[i]=s[0],this.P[i+1]=s[1];for(i=0;i<4;i++)for(o=0;o<256;o+=2)s[0]^=mr(n,t),s[1]^=mr(n,t),this.encipher(s),this.S[i][o]=s[0],this.S[i][o+1]=s[1];Qn=0};gr.prototype.enc=function(n,t){for(var e=0;e<t;e++)this.encipher(n.subarray(e*2))};gr.prototype.dec=function(n,t){for(var e=0;e<t;e++)this.decipher(n.subarray(e*2))};var Rs=8,qo=32;function Vo(n,t,e){var r=new gr,s=new Uint32Array(Rs),i,o=new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,105,116,101]);for(r.expandstate(t,64,n,64),i=0;i<64;i++)r.expand0state(t,64),r.expand0state(n,64);for(i=0;i<Rs;i++)s[i]=mr(o,o.byteLength);for(i=0;i<64;i++)r.enc(s,s.byteLength/8);for(i=0;i<Rs;i++)e[4*i+3]=s[i]>>>24,e[4*i+2]=s[i]>>>16,e[4*i+1]=s[i]>>>8,e[4*i+0]=s[i]}function Vm(n,t,e,r,s,i,o){var a=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(qo),u=new Uint8Array(qo),f=new Uint8Array(r+4),h,p,A,E,b,x,P=i;if(o<1||t===0||r===0||i===0||i>l.byteLength*l.byteLength||r>1<<20)return-1;for(E=Math.floor((i+l.byteLength-1)/l.byteLength),A=Math.floor((i+E-1)/E),h=0;h<r;h++)f[h]=e[h];for(Wo(a,n,t),x=1;i>0;x++){for(f[r+0]=x>>>24,f[r+1]=x>>>16,f[r+2]=x>>>8,f[r+3]=x,Wo(c,f,r+4),Vo(a,c,u),h=l.byteLength;h--;)l[h]=u[h];for(h=1;h<o;h++)for(Wo(c,u,u.byteLength),Vo(a,c,u),p=0;p<l.byteLength;p++)l[p]^=u[p];for(A=Math.min(A,i),h=0;h<A&&(b=h*E+(x-1),!(b>=P));h++)s[b]=l[h];i-=h}return 0}Ef.exports={BLOCKS:Rs,HASHSIZE:qo,hash:Vo,pbkdf:Vm}});var qn=ut((Cx,Os)=>{"use strict";var Wn=require("crypto"),Qr;try{Qr=require("cpu-features")()}catch{}var{bindingAvailable:Sf,CIPHER_INFO:Km,MAC_INFO:zm}=tr(),_f=(()=>{if(typeof Wn.sign=="function"&&typeof Wn.verify=="function"){let n=`-----BEGIN PRIVATE KEY-----\r
|
|
3
3
|
MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
|
|
4
|
-
-----END PRIVATE KEY-----`,t=Buffer.from("a"),e,r;try{e=Wn.sign(null,t,n),r=Wn.verify(null,t,n,e)}catch{}return Buffer.isBuffer(e)&&e.length===64&&r===!0}return!1})(),bf=typeof Wn.diffieHellman=="function"&&typeof Wn.generateKeyPairSync=="function"&&typeof Wn.createPublicKey=="function",Ts=["ecdh-sha2-nistp256","ecdh-sha2-nistp384","ecdh-sha2-nistp521","diffie-hellman-group-exchange-sha256","diffie-hellman-group14-sha256","diffie-hellman-group15-sha512","diffie-hellman-group16-sha512","diffie-hellman-group17-sha512","diffie-hellman-group18-sha512"];bf&&(Ts.unshift("curve25519-sha256"),Ts.unshift("curve25519-sha256@libssh.org"));var Gm=Ts.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),zo=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];_f&&zo.unshift("ssh-ed25519");var Ym=zo.concat(["ssh-dss"]),xf=(()=>{let n=Wn.getCiphers();return t=>n.includes(Km[t].sslName)})(),er=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];Qr&&Qr.flags&&!Qr.flags.aes?Sf?er.unshift("chacha20-poly1305@openssh.com"):er.push("chacha20-poly1305@openssh.com"):Sf&&Qr&&Qr.arch==="x86"?er.splice(4,0,"chacha20-poly1305@openssh.com"):er.push("chacha20-poly1305@openssh.com");er=er.filter(xf);var jm=er.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter(xf)),wf=(()=>{let n=Wn.getHashes();return t=>n.includes(zm[t].sslName)})(),If=["hmac-sha2-256-etm@openssh.com","hmac-sha2-512-etm@openssh.com","hmac-sha1-etm@openssh.com","hmac-sha2-256","hmac-sha2-512","hmac-sha1"].filter(wf),Xm=If.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(wf)),Cf=["none","zlib@openssh.com","zlib"],Jm=Cf.concat([]),Hr={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};Os.exports={MESSAGE:{DISCONNECT:1,IGNORE:2,UNIMPLEMENTED:3,DEBUG:4,SERVICE_REQUEST:5,SERVICE_ACCEPT:6,EXT_INFO:7,KEXINIT:20,NEWKEYS:21,KEXDH_INIT:30,KEXDH_REPLY:31,KEXDH_GEX_GROUP:31,KEXDH_GEX_INIT:32,KEXDH_GEX_REPLY:33,KEXDH_GEX_REQUEST:34,KEXECDH_INIT:30,KEXECDH_REPLY:31,USERAUTH_REQUEST:50,USERAUTH_FAILURE:51,USERAUTH_SUCCESS:52,USERAUTH_BANNER:53,USERAUTH_PASSWD_CHANGEREQ:60,USERAUTH_PK_OK:60,USERAUTH_INFO_REQUEST:60,USERAUTH_INFO_RESPONSE:61,GLOBAL_REQUEST:80,REQUEST_SUCCESS:81,REQUEST_FAILURE:82,CHANNEL_OPEN:90,CHANNEL_OPEN_CONFIRMATION:91,CHANNEL_OPEN_FAILURE:92,CHANNEL_WINDOW_ADJUST:93,CHANNEL_DATA:94,CHANNEL_EXTENDED_DATA:95,CHANNEL_EOF:96,CHANNEL_CLOSE:97,CHANNEL_REQUEST:98,CHANNEL_SUCCESS:99,CHANNEL_FAILURE:100},DISCONNECT_REASON:{HOST_NOT_ALLOWED_TO_CONNECT:1,PROTOCOL_ERROR:2,KEY_EXCHANGE_FAILED:3,RESERVED:4,MAC_ERROR:5,COMPRESSION_ERROR:6,SERVICE_NOT_AVAILABLE:7,PROTOCOL_VERSION_NOT_SUPPORTED:8,HOST_KEY_NOT_VERIFIABLE:9,CONNECTION_LOST:10,BY_APPLICATION:11,TOO_MANY_CONNECTIONS:12,AUTH_CANCELED_BY_USER:13,NO_MORE_AUTH_METHODS_AVAILABLE:14,ILLEGAL_USER_NAME:15},DISCONNECT_REASON_STR:void 0,CHANNEL_OPEN_FAILURE:{ADMINISTRATIVELY_PROHIBITED:1,CONNECT_FAILED:2,UNKNOWN_CHANNEL_TYPE:3,RESOURCE_SHORTAGE:4},TERMINAL_MODE:{TTY_OP_END:0,VINTR:1,VQUIT:2,VERASE:3,VKILL:4,VEOF:5,VEOL:6,VEOL2:7,VSTART:8,VSTOP:9,VSUSP:10,VDSUSP:11,VREPRINT:12,VWERASE:13,VLNEXT:14,VFLUSH:15,VSWTCH:16,VSTATUS:17,VDISCARD:18,IGNPAR:30,PARMRK:31,INPCK:32,ISTRIP:33,INLCR:34,IGNCR:35,ICRNL:36,IUCLC:37,IXON:38,IXANY:39,IXOFF:40,IMAXBEL:41,ISIG:50,ICANON:51,XCASE:52,ECHO:53,ECHOE:54,ECHOK:55,ECHONL:56,NOFLSH:57,TOSTOP:58,IEXTEN:59,ECHOCTL:60,ECHOKE:61,PENDIN:62,OPOST:70,OLCUC:71,ONLCR:72,OCRNL:73,ONOCR:74,ONLRET:75,CS7:90,CS8:91,PARENB:92,PARODD:93,TTY_OP_ISPEED:128,TTY_OP_OSPEED:129},CHANNEL_EXTENDED_DATATYPE:{STDERR:1},SIGNALS:["ABRT","ALRM","FPE","HUP","ILL","INT","QUIT","SEGV","TERM","USR1","USR2","KILL","PIPE"].reduce((n,t)=>({...n,[t]:1}),{}),COMPAT:Hr,COMPAT_CHECKS:[["Cisco-1.25",Hr.BAD_DHGEX],[/^Cisco-1[.]/,Hr.BUG_DHGEX_LARGE],[/^[0-9.]+$/,Hr.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,Hr.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,Hr.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:Ts,SUPPORTED_KEX:Gm,DEFAULT_SERVER_HOST_KEY:zo,SUPPORTED_SERVER_HOST_KEY:Ym,DEFAULT_CIPHER:er,SUPPORTED_CIPHER:jm,DEFAULT_MAC:If,SUPPORTED_MAC:Xm,DEFAULT_COMPRESSION:Cf,SUPPORTED_COMPRESSION:Jm,curve25519Supported:bf,eddsaSupported:_f};Os.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(Os.exports.DISCONNECT_REASON)).reduce((n,[t,e])=>({...n,[e]:t}),{})});var xn=ut((kx,Bf)=>{"use strict";var En=bi().Ber,Ms,Nf=Buffer[Symbol.species],Zm=Object.getPrototypeOf(Uint8Array.prototype).fill;function kf(n,t){return n[t++]*16777216+n[t++]*65536+n[t++]*256+n[t]}function xi(n,t,e,r,s){s||(s=0),r>n.length&&(r=n.length);let i=r-e,o=t.length-s;return i>o&&(i=o),t.set(new Uint8Array(n.buffer,n.byteOffset+e,i),s),i}function wi(n,t,e){return e===void 0&&(e=n.length),new Nf(n.buffer,n.byteOffset+t,e-t)}function Yo(){let n=0,t,e={init:(r,s)=>{t=r,n=typeof s=="number"?s:0},pos:()=>n,length:()=>t?t.length:0,avail:()=>t&&n<t.length?t.length-n:0,clear:()=>{t=void 0},readUInt32BE:()=>{if(!(!t||n+3>=t.length))return t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]},readUInt64BE:r=>{if(!(!t||n+7>=t.length))switch(r){case"always":return BigInt(`0x${t.hexSlice(n,n+=8)}`);case"maybe":if(t[n]>31)return BigInt(`0x${t.hexSlice(n,n+=8)}`);default:return t[n++]*72057594037927940+t[n++]*281474976710656+t[n++]*1099511627776+t[n++]*4294967296+t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]}},skip:r=>{t&&r>0&&(n+=r)},skipString:()=>{let r=e.readUInt32BE();if(r!==void 0)return n+=r,n<=t.length?r:void 0},readByte:()=>{if(t&&n<t.length)return t[n++]},readBool:()=>{if(t&&n<t.length)return!!t[n++]},readList:()=>{let r=e.readString(!0);if(r!==void 0)return r?r.split(","):[]},readString:(r,s)=>{typeof r=="number"&&(s=r,r=void 0);let i=e.readUInt32BE();if(i!==void 0&&!(t.length-n<i||typeof s=="number"&&i>s))return r?Buffer.isBuffer(r)?xi(t,r,n,n+=i):t.utf8Slice(n,n+=i):wi(t,n,n+=i)},readRaw:r=>{if(t){if(typeof r!="number")return wi(t,n,n+=t.length-n);if(t.length-n>=r)return wi(t,n,n+=r)}}};return e}function vf(n,t,e){let r=new Error(n);return typeof t=="boolean"?(e=t,r.level="protocol"):r.level=t||"protocol",r.fatal=!!e,r}function Go(n,t,e){return n[e++]=t>>>24,n[e++]=t>>>16,n[e++]=t>>>8,n[e++]=t,e}var Ds=Yo();Bf.exports={bufferCopy:xi,bufferSlice:wi,FastBuffer:Nf,bufferFill:(n,t,e,r)=>Zm.call(n,t,e,r),makeError:vf,doFatalError:(n,t,e,r)=>{let s;return Ms===void 0&&({DISCONNECT_REASON:Ms}=qn()),t instanceof Error?(s=t,typeof e!="number"?r=Ms.PROTOCOL_ERROR:r=e):s=vf(t,e,!0),typeof r!="number"&&(r=Ms.PROTOCOL_ERROR),n.disconnect(r),n._destruct(),n._onError(s),1/0},readUInt32BE:kf,writeUInt32BE:Go,writeUInt32LE:(n,t,e)=>(n[e++]=t,n[e++]=t>>>8,n[e++]=t>>>16,n[e++]=t>>>24,e),makeBufferParser:Yo,bufferParser:Yo(),readString:(n,t,e,r)=>{typeof e=="number"&&(r=e,e=void 0),t===void 0&&(t=0);let s=n.length-t;if(t<0||t>=n.length||s<4)return;let i=kf(n,t);if(s<4+i||typeof r=="number"&&i>r)return;t+=4;let o=t+i;return n._pos=o,e?Buffer.isBuffer(e)?xi(n,e,t,o):n.utf8Slice(t,o):wi(n,t,o)},sigSSHToASN1:(n,t)=>{switch(t){case"ssh-dss":{if(n.length>40)return n;let e=new En.Writer;e.startSequence();let r=n.slice(0,20),s=n.slice(20);if(r[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,r.copy(i,1),r=i}else r[0]===0&&!(r[1]&128)&&(r=r.slice(1));if(s[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,s.copy(i,1),s=i}else s[0]===0&&!(s[1]&128)&&(s=s.slice(1));return e.writeBuffer(r,En.Integer),e.writeBuffer(s,En.Integer),e.endSequence(),e.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{Ds.init(n,0);let e=Ds.readString(),r=Ds.readString();if(Ds.clear(),e===void 0||r===void 0)return;let s=new En.Writer;return s.startSequence(),s.writeBuffer(e,En.Integer),s.writeBuffer(r,En.Integer),s.endSequence(),s.buffer}default:return n}},convertSignature:(n,t)=>{switch(t){case"ssh-dss":{if(n.length<=40)return n;let e=new En.Reader(n);e.readSequence();let r=e.readString(En.Integer,!0),s=e.readString(En.Integer,!0),i=0,o=0;if(r.length<20){let c=Buffer.allocUnsafe(20);c.set(r,1),r=c,r[0]=0}if(s.length<20){let c=Buffer.allocUnsafe(20);c.set(s,1),s=c,s[0]=0}r.length>20&&r[0]===0&&(i=1),s.length>20&&s[0]===0&&(o=1);let a=Buffer.allocUnsafe(r.length-i+(s.length-o));return xi(r,a,i,r.length,0),xi(s,a,o,s.length,r.length-i),a}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{if(n[0]===0)return n;let e=new En.Reader(n);e.readSequence();let r=e.readString(En.Integer,!0),s=e.readString(En.Integer,!0);if(r===null||s===null)return;let i=Buffer.allocUnsafe(4+r.length+4+s.length);return Go(i,r.length,0),i.set(r,4),Go(i,s.length,4+r.length),i.set(s,8+r.length),i}}return n},sendPacket:(n,t,e)=>!e&&n._kexinit!==void 0?(n._queue===void 0&&(n._queue=[]),n._queue.push(t),n._debug&&n._debug("Outbound: ... packet queued"),!1):(n._cipher.encrypt(t),!0)}});var Rf=ut((Ls,Xo)=>{var jo=(function(){var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),(function(t){t=t||{};var e;e||(e=typeof t<"u"?t:{});var r,s;e.ready=new Promise(function(J,pe){r=J,s=pe});var i={},o;for(o in e)e.hasOwnProperty(o)&&(i[o]=e[o]);var a=typeof window=="object",c=typeof importScripts=="function",l=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",u="",f,h,p,A,E;l?(u=c?require("path").dirname(u)+"/":__dirname+"/",f=function(J,pe){var we=Ln(J);return we?pe?we:we.toString():(A||(A=require("fs")),E||(E=require("path")),J=E.normalize(J),A.readFileSync(J,pe?null:"utf8"))},p=function(J){return J=f(J,!0),J.buffer||(J=new Uint8Array(J)),$(J.buffer),J},h=function(J,pe,we){var Oe=Ln(J);Oe&&pe(Oe),A||(A=require("fs")),E||(E=require("path")),J=E.normalize(J),A.readFile(J,function(Ze,Dt){Ze?we(Ze):pe(Dt.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),e.inspect=function(){return"[Emscripten Module object]"}):(a||c)&&(c?u=self.location.href:typeof document<"u"&&document.currentScript&&(u=document.currentScript.src),n&&(u=n),u.indexOf("blob:")!==0?u=u.substr(0,u.lastIndexOf("/")+1):u="",f=function(J){try{var pe=new XMLHttpRequest;return pe.open("GET",J,!1),pe.send(null),pe.responseText}catch(Ze){if(J=Ln(J)){pe=[];for(var we=0;we<J.length;we++){var Oe=J[we];255<Oe&&(xr&&$(!1,"Character code "+Oe+" ("+String.fromCharCode(Oe)+") at offset "+we+" not in 0x00-0xFF."),Oe&=255),pe.push(String.fromCharCode(Oe))}return pe.join("")}throw Ze}},c&&(p=function(J){try{var pe=new XMLHttpRequest;return pe.open("GET",J,!1),pe.responseType="arraybuffer",pe.send(null),new Uint8Array(pe.response)}catch(we){if(J=Ln(J))return J;throw we}}),h=function(J,pe,we){var Oe=new XMLHttpRequest;Oe.open("GET",J,!0),Oe.responseType="arraybuffer",Oe.onload=function(){if(Oe.status==200||Oe.status==0&&Oe.response)pe(Oe.response);else{var Ze=Ln(J);Ze?pe(Ze.buffer):we()}},Oe.onerror=we,Oe.send(null)}),e.print||console.log.bind(console);var b=e.printErr||console.warn.bind(console);for(o in i)i.hasOwnProperty(o)&&(e[o]=i[o]);i=null;var x;e.wasmBinary&&(x=e.wasmBinary);var P=e.noExitRuntime||!0;typeof WebAssembly!="object"&&z("no native wasm support detected");var q,C=!1;function $(J,pe){J||z("Assertion failed: "+pe)}function F(J){var pe=e["_"+J];return $(pe,"Cannot call unknown function "+J+", make sure it is exported"),pe}function v(J,pe,we,Oe){var Ze={string:function(lt){var Ht=0;if(lt!=null&<!==0){var $t=(lt.length<<2)+1;Ht=ui($t);var kt=Ht,At=N;if(0<$t){$t=kt+$t-1;for(var mn=0;mn<lt.length;++mn){var vt=lt.charCodeAt(mn);if(55296<=vt&&57343>=vt){var dr=lt.charCodeAt(++mn);vt=65536+((vt&1023)<<10)|dr&1023}if(127>=vt){if(kt>=$t)break;At[kt++]=vt}else{if(2047>=vt){if(kt+1>=$t)break;At[kt++]=192|vt>>6}else{if(65535>=vt){if(kt+2>=$t)break;At[kt++]=224|vt>>12}else{if(kt+3>=$t)break;At[kt++]=240|vt>>18,At[kt++]=128|vt>>12&63}At[kt++]=128|vt>>6&63}At[kt++]=128|vt&63}}At[kt]=0}}return Ht},array:function(lt){var Ht=ui(lt.length);return k.set(lt,Ht),Ht}},Dt=F(J),vn=[];if(J=0,Oe)for(var un=0;un<Oe.length;un++){var vr=Ze[we[un]];vr?(J===0&&(J=li()),vn[un]=vr(Oe[un])):vn[un]=Oe[un]}return we=Dt.apply(null,vn),we=(function(lt){if(pe==="string")if(lt){for(var Ht=N,$t=lt+NaN,kt=lt;Ht[kt]&&!(kt>=$t);)++kt;if(16<kt-lt&&Ht.subarray&&_)lt=_.decode(Ht.subarray(lt,kt));else{for($t="";lt<kt;){var At=Ht[lt++];if(At&128){var mn=Ht[lt++]&63;if((At&224)==192)$t+=String.fromCharCode((At&31)<<6|mn);else{var vt=Ht[lt++]&63;At=(At&240)==224?(At&15)<<12|mn<<6|vt:(At&7)<<18|mn<<12|vt<<6|Ht[lt++]&63,65536>At?$t+=String.fromCharCode(At):(At-=65536,$t+=String.fromCharCode(55296|At>>10,56320|At&1023))}}else $t+=String.fromCharCode(At)}lt=$t}}else lt="";else lt=pe==="boolean"?!!lt:lt;return lt})(we),J!==0&&os(J),we}var _=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,w,k,N;function R(){var J=q.buffer;w=J,e.HEAP8=k=new Int8Array(J),e.HEAP16=new Int16Array(J),e.HEAP32=new Int32Array(J),e.HEAPU8=N=new Uint8Array(J),e.HEAPU16=new Uint16Array(J),e.HEAPU32=new Uint32Array(J),e.HEAPF32=new Float32Array(J),e.HEAPF64=new Float64Array(J)}var ie,j=[],X=[],re=[];function fe(){var J=e.preRun.shift();j.unshift(J)}var H=0,B=null,D=null;e.preloadedImages={},e.preloadedAudios={};function z(J){throw e.onAbort&&e.onAbort(J),b(J),C=!0,J=new WebAssembly.RuntimeError("abort("+J+"). Build with -s ASSERTIONS=1 for more info."),s(J),J}var ne="data:application/octet-stream;base64,",de;if(de="data:application/octet-stream;base64,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",!de.startsWith(ne)){var oe=de;de=e.locateFile?e.locateFile(oe,u):u+oe}function Je(){var J=de;try{if(J==de&&x)return new Uint8Array(x);var pe=Ln(J);if(pe)return pe;if(p)return p(J);throw"both async and sync fetching of the wasm failed"}catch(we){z(we)}}function ht(){if(!x&&(a||c)){if(typeof fetch=="function"&&!de.startsWith("file://"))return fetch(de,{credentials:"same-origin"}).then(function(J){if(!J.ok)throw"failed to load wasm binary file at '"+de+"'";return J.arrayBuffer()}).catch(function(){return Je()});if(h)return new Promise(function(J,pe){h(de,function(we){J(new Uint8Array(we))},pe)})}return Promise.resolve().then(function(){return Je()})}function ln(J){for(;0<J.length;){var pe=J.shift();if(typeof pe=="function")pe(e);else{var we=pe.m;typeof we=="number"?pe.l===void 0?ie.get(we)():ie.get(we)(pe.l):we(pe.l===void 0?null:pe.l)}}}var xr=!1,wr=typeof atob=="function"?atob:function(J){var pe="",we=0;J=J.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var Oe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(J.charAt(we++)),Ze="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(J.charAt(we++)),Dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(J.charAt(we++)),vn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(J.charAt(we++));Oe=Oe<<2|Ze>>4,Ze=(Ze&15)<<4|Dt>>2;var un=(Dt&3)<<6|vn;pe+=String.fromCharCode(Oe),Dt!==64&&(pe+=String.fromCharCode(Ze)),vn!==64&&(pe+=String.fromCharCode(un))}while(we<J.length);return pe};function Ln(J){if(J.startsWith(ne)){if(J=J.slice(ne.length),typeof l=="boolean"&&l){var pe=Buffer.from(J,"base64");pe=new Uint8Array(pe.buffer,pe.byteOffset,pe.byteLength)}else try{var we=wr(J),Oe=new Uint8Array(we.length);for(J=0;J<we.length;++J)Oe[J]=we.charCodeAt(J);pe=Oe}catch{throw Error("Converting base64 string to bytes failed.")}return pe}}var Ir={a:function(J){var pe=N.length;if(J>>>=0,2147483648<J)return!1;for(var we=1;4>=we;we*=2){var Oe=pe*(1+.2/we);Oe=Math.min(Oe,J+100663296),Oe=Math.max(J,Oe),0<Oe%65536&&(Oe+=65536-Oe%65536);e:{try{q.grow(Math.min(2147483648,Oe)-w.byteLength+65535>>>16),R();var Ze=1;break e}catch{}Ze=void 0}if(Ze)return!0}return!1}};(function(){function J(Ze){e.asm=Ze.exports,q=e.asm.b,R(),ie=e.asm.j,X.unshift(e.asm.c),H--,e.monitorRunDependencies&&e.monitorRunDependencies(H),H==0&&(B!==null&&(clearInterval(B),B=null),D&&(Ze=D,D=null,Ze()))}function pe(Ze){J(Ze.instance)}function we(Ze){return ht().then(function(Dt){return WebAssembly.instantiate(Dt,Oe)}).then(Ze,function(Dt){b("failed to asynchronously prepare wasm: "+Dt),z(Dt)})}var Oe={a:Ir};if(H++,e.monitorRunDependencies&&e.monitorRunDependencies(H),e.instantiateWasm)try{return e.instantiateWasm(Oe,J)}catch(Ze){return b("Module.instantiateWasm callback failed with error: "+Ze),!1}return(function(){return x||typeof WebAssembly.instantiateStreaming!="function"||de.startsWith(ne)||de.startsWith("file://")||typeof fetch!="function"?we(pe):fetch(de,{credentials:"same-origin"}).then(function(Ze){return WebAssembly.instantiateStreaming(Ze,Oe).then(pe,function(Dt){return b("wasm streaming compile failed: "+Dt),b("falling back to ArrayBuffer instantiation"),we(pe)})})})().catch(s),{}})(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.c).apply(null,arguments)},e._poly1305_auth=function(){return(e._poly1305_auth=e.asm.d).apply(null,arguments)};var li=e.stackSave=function(){return(li=e.stackSave=e.asm.e).apply(null,arguments)},os=e.stackRestore=function(){return(os=e.stackRestore=e.asm.f).apply(null,arguments)},ui=e.stackAlloc=function(){return(ui=e.stackAlloc=e.asm.g).apply(null,arguments)};e._malloc=function(){return(e._malloc=e.asm.h).apply(null,arguments)},e._free=function(){return(e._free=e.asm.i).apply(null,arguments)},e.cwrap=function(J,pe,we,Oe){we=we||[];var Ze=we.every(function(Dt){return Dt==="number"});return pe!=="string"&&Ze&&!Oe?F(J):function(){return v(J,pe,we,arguments)}};var Cr;D=function J(){Cr||kr(),Cr||(D=J)};function kr(){function J(){if(!Cr&&(Cr=!0,e.calledRun=!0,!C)){if(ln(X),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;){var pe=e.postRun.shift();re.unshift(pe)}ln(re)}}if(!(0<H)){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)fe();ln(j),0<H||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),J()},1)):J())}}if(e.run=kr,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();return kr(),t.ready})})();typeof Ls=="object"&&typeof Xo=="object"?Xo.exports=jo:typeof define=="function"&&define.amd?define([],function(){return jo}):typeof Ls=="object"&&(Ls.createPoly1305=jo)});var tr=ut((vx,Df)=>{"use strict";var{createCipheriv:qr,createDecipheriv:Us,createHmac:Jo,randomFillSync:Ar,timingSafeEqual:Zo}=require("crypto"),{readUInt32BE:Ci,writeUInt32BE:hn}=xn(),nr=Buffer[Symbol.species],Pf=2**32-1,Tf=Buffer.alloc(0),Wr=Buffer.alloc(4),$s=new Map,yr=35e3,ea,ma,ga,Aa,ya,Ea,Sa;try{ea=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:ma,ChaChaPolyCipher:ga,GenericCipher:Aa,AESGCMDecipher:ya,ChaChaPolyDecipher:Ea,GenericDecipher:Sa}=ea}catch{}var Kt=1,e0=(()=>{function n(t,e,r,s,i,o,a){return{sslName:t,blockLen:e,keyLen:r,ivLen:s!==0||a&Kt?s:e,authLen:i,discardLen:o,stream:!!(a&Kt)}}return{"chacha20-poly1305@openssh.com":n("chacha20",8,64,0,16,0,Kt),"aes128-gcm":n("aes-128-gcm",16,16,12,16,0,Kt),"aes256-gcm":n("aes-256-gcm",16,32,12,16,0,Kt),"aes128-gcm@openssh.com":n("aes-128-gcm",16,16,12,16,0,Kt),"aes256-gcm@openssh.com":n("aes-256-gcm",16,32,12,16,0,Kt),"aes128-cbc":n("aes-128-cbc",16,16,0,0,0,0),"aes192-cbc":n("aes-192-cbc",16,24,0,0,0,0),"aes256-cbc":n("aes-256-cbc",16,32,0,0,0,0),"rijndael-cbc@lysator.liu.se":n("aes-256-cbc",16,32,0,0,0,0),"3des-cbc":n("des-ede3-cbc",8,24,0,0,0,0),"blowfish-cbc":n("bf-cbc",8,16,0,0,0,0),"idea-cbc":n("idea-cbc",8,16,0,0,0,0),"cast128-cbc":n("cast-cbc",8,16,0,0,0,0),"aes128-ctr":n("aes-128-ctr",16,16,16,0,0,Kt),"aes192-ctr":n("aes-192-ctr",16,24,16,0,0,Kt),"aes256-ctr":n("aes-256-ctr",16,32,16,0,0,Kt),"3des-ctr":n("des-ede3",8,24,8,0,0,Kt),"blowfish-ctr":n("bf-ecb",8,16,8,0,0,Kt),"cast128-ctr":n("cast5-ecb",8,16,8,0,0,Kt),arcfour:n("rc4",8,16,0,0,1536,Kt),arcfour128:n("rc4",8,16,0,0,1536,Kt),arcfour256:n("rc4",8,32,0,0,1536,Kt),arcfour512:n("rc4",8,64,0,0,1536,Kt)}})(),t0=(()=>{function n(t,e,r,s){return{sslName:t,len:e,actualLen:r,isETM:s}}return{"hmac-md5":n("md5",16,16,!1),"hmac-md5-96":n("md5",16,12,!1),"hmac-ripemd160":n("ripemd160",20,20,!1),"hmac-sha1":n("sha1",20,20,!1),"hmac-sha1-etm@openssh.com":n("sha1",20,20,!0),"hmac-sha1-96":n("sha1",20,12,!1),"hmac-sha2-256":n("sha256",32,32,!1),"hmac-sha2-256-etm@openssh.com":n("sha256",32,32,!0),"hmac-sha2-256-96":n("sha256",32,12,!1),"hmac-sha2-512":n("sha512",64,64,!1),"hmac-sha2-512-etm@openssh.com":n("sha512",64,64,!0),"hmac-sha2-512-96":n("sha512",64,12,!1)}})(),ta=class{constructor(t,e){this.outSeqno=t,this._onWrite=e,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return hn(s,e-4,0),s[4]=r,Ar(s,5+t,r),s}encrypt(t){this._dead||(this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},Of=Buffer.alloc(32),sn=Buffer.alloc(16),Ii,ki,_a,na=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encKeyMain=e.cipherKey.slice(0,32),this._encKeyPktLen=e.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return hn(s,e-4,0),s[4]=r,Ar(s,5+t,r),s}encrypt(t){if(this._dead)return;sn[0]=0,hn(sn,this.outSeqno,12);let e=qr("chacha20",this._encKeyMain,sn).update(Of),r=qr("chacha20",this._encKeyPktLen,sn).update(t.slice(0,4));this._onWrite(r),sn[0]=1;let s=qr("chacha20",this._encKeyMain,sn).update(t.slice(4));this._onWrite(s),_a(ki,r,r.length,s,s.length,e);let i=Buffer.allocUnsafe(16);i.set(new Uint8Array(Ii.HEAPU8.buffer,ki,16),0),this._onWrite(i),this.outSeqno=this.outSeqno+1>>>0}},ra=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new ga(e.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e+16);return hn(s,e-4,0),s[4]=r,Ar(s,5+t,r),s}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},ia=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encSSLName=e.cipherInfo.sslName,this._encKey=e.cipherKey,this._encIV=e.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e);return hn(s,e-4,0),s[4]=r,Ar(s,5+t,r),s}encrypt(t){if(this._dead)return;let e=qr(this._encSSLName,this._encKey,this._encIV);e.setAutoPadding(!1);let r=t.slice(0,4);e.setAAD(r),this._onWrite(r);let s=e.update(t.slice(4));this._onWrite(s);let i=e.final();i.length&&this._onWrite(i);let o=e.getAuthTag();this._onWrite(o),Mf(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},sa=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new ma(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e+16);return hn(s,e-4,0),s[4]=r,Ar(s,5+t,r),s}encrypt(t){this._dead||(this._instance.encrypt(t),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},oa=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._cipherInstance=qr(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;let r=e.cipherInfo.discardLen;if(r){let s=$s.get(r);s===void 0&&(s=Buffer.alloc(r),$s.set(r,s)),this._cipherInstance.update(s)}}free(){this._dead=!0}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r);return hn(i,r-4,0),i[4]=s,Ar(i,5+t,s),i}encrypt(t){if(this._dead)return;let e;if(this._macETM){let s=new Uint8Array(t.buffer,t.byteOffset,4),i=this._cipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+4,t.length-4));this._onWrite(s),this._onWrite(i),e=Jo(this._macSSLName,this._macKey),hn(Wr,this.outSeqno,0),e.update(Wr),e.update(s),e.update(i)}else{let s=this._cipherInstance.update(t);this._onWrite(s),e=Jo(this._macSSLName,this._macKey),hn(Wr,this.outSeqno,0),e.update(Wr),e.update(t)}let r=e.digest();r.length>this._macActualLen&&(r=r.slice(0,this._macActualLen)),this._onWrite(r),this.outSeqno=this.outSeqno+1>>>0}},aa=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._macLen=e.macInfo.len,this._macActualLen=e.macInfo.actualLen,this._aadLen=e.macInfo.isETM?4:0,this._instance=new Aa(e.cipherInfo.sslName,e.cipherKey,e.cipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r+this._macLen);return hn(i,r-4,0),i[4]=s,Ar(i,5+t,s),i}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._macActualLen<this._macLen&&(t=new nr(t.buffer,t.byteOffset,t.length-(this._macLen-this._macActualLen))),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},ca=class{constructor(t,e){this.inSeqno=t,this._onPayload=e,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len>yr||this._len<8||(4+this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._packetPos<this._len){let i=Math.min(this._len-this._packetPos,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),e+=i,this._packetPos+=i,this._packetPos<this._len)return}let s=this._packet?new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Tf;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},la=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decKeyMain=e.decipherKey.slice(0,32),this._decKeyPktLen=e.decipherKey.slice(32),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._calcMac=Buffer.allocUnsafe(16),this._macPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenPos<4){let a=Math.min(4-this._lenPos,r-e);for(;a--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;sn[0]=0,hn(sn,this.inSeqno,12);let c=Us("chacha20",this._decKeyPktLen,sn).update(this._lenBuf);if(this._len=Ci(c,0),this._len>yr||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length")}if(this._pktLen<this._len){if(e>=r)return;let a=Math.min(this._len-this._pktLen,r-e),c;if(e!==0||a!==r?c=new Uint8Array(t.buffer,t.byteOffset+e,a):c=t,a===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._pktLen)),e+=a,this._pktLen+=a,this._pktLen<this._len||e>=r)return}{let a=Math.min(16-this._macPos,r-e);if(e!==0||a!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,a),this._macPos):this._mac.set(t,this._macPos),e+=a,this._macPos+=a,this._macPos<16)return}sn[0]=0,hn(sn,this.inSeqno,12);let s=qr("chacha20",this._decKeyMain,sn).update(Of);if(_a(ki,this._lenBuf,4,this._packet,this._packet.length,s),this._calcMac.set(new Uint8Array(Ii.HEAPU8.buffer,ki,16),0),!Zo(this._calcMac,this._mac))throw new Error("Invalid MAC");sn[0]=1;let i=Us("chacha20",this._decKeyMain,sn).update(this._packet),o=new nr(i.buffer,i.byteOffset+1,i.length-i[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let a=this._onPayload(o);if(a!==void 0)return a===!1?e:a}}}},ua=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Ea(e.decipherKey),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._macPos=0}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._lenPos<4){let i=Math.min(4-this._lenPos,r-e);for(;i--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>yr||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let s=new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},fa=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=null,this._decipherSSLName=e.decipherInfo.sslName,this._decipherKey=e.decipherKey,this._decipherIV=e.decipherIV,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>yr||this._len<16||(this._len&15)!==0)throw new Error("Bad packet length");this._decipherInstance=Us(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(n0(this._len))}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=this._decipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+e,i)):o=this._decipherInstance.update(t),o.length&&(i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),this._packetPos+=o.length),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let i=this._decipherInstance.final();i.length&&(this._packet?this._packet.set(i,this._packetPos):this._packet=i)}let s=this._packet?new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Tf;this.inSeqno=this.inSeqno+1>>>0,Mf(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},da=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new ya(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>yr||this._len<16||(this._len&15)!==0)throw new Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let s=new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tagPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},ha=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=Us(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(e.macInfo.isETM?4:e.decipherInfo.blockLen),this._blockSize=e.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._macInstance=null;let r=e.decipherInfo.discardLen;if(r){let s=$s.get(r);s===void 0&&(s=Buffer.alloc(r),$s.set(r,s)),this._decipherInstance.update(s)}}free(){}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let o=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||o!==r||o<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._blockPos):this._block.set(t,this._blockPos),e+=o,this._blockPos+=o,this._blockPos<this._block.length)return;let a,c;if(this._macETM?this._len=c=Ci(this._block,0):(a=this._decipherInstance.update(this._block),this._len=Ci(a,0),c=4+this._len-this._blockSize),this._len>yr||this._len<5||(c&this._blockSize-1)!==0)throw new Error("Bad packet length");if(this._macInstance=Jo(this._macSSLName,this._macKey),hn(Wr,this.inSeqno,0),this._macInstance.update(Wr),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(a.buffer,a.byteOffset,4)),this._pktLen=a.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(a.buffer,a.byteOffset+4,this._packetPos),0)),e>=r)return}if(this._pktLen<this._len){let o=Math.min(this._len-this._pktLen,r-e),a;e!==0||o!==r?a=new Uint8Array(t.buffer,t.byteOffset+e,o):a=t,this._macETM&&this._macInstance.update(a);let c=this._decipherInstance.update(a);if(c.length&&(o===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._packetPos)),this._packetPos+=c.length),e+=o,this._pktLen+=o,this._pktLen<this._len||e>=r)return}{let o=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||o!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._macPos):this._mac.set(t,this._macPos),e+=o,this._macPos+=o,this._macPos<this._macActualLen)return}this._macETM||this._macInstance.update(this._packet);let s=this._macInstance.digest();if(this._macActualLen<s.length&&(s=new Uint8Array(s.buffer,s.byteOffset,this._macActualLen)),!r0(s,this._mac))throw new Error("Invalid MAC");let i=new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._macPos=0,this._macInstance=null;{let o=this._onPayload(i);if(o!==void 0)return o===!1?e:o}}}},pa=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Sa(e.decipherInfo.sslName,e.decipherKey,e.decipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM,e.macInfo.actualLen),this._block=Buffer.allocUnsafe(e.macInfo.isETM||e.decipherInfo.stream?4:e.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let i=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||i!==r||i<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._blockPos):this._block.set(t,this._blockPos),e+=i,this._blockPos+=i,this._blockPos<this._block.length)return;let o;if(this._macETM?this._len=o=Ci(this._block,0):(this._instance.decryptBlock(this._block),this._len=Ci(this._block,0),o=4+this._len-this._block.length),this._len>yr||this._len<5||(o&this._block.length-1)!==0)throw new Error("Bad packet length");if(this._macETM||(this._pktLen=this._block.length-4,this._pktLen&&(this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(this._block.buffer,this._block.byteOffset+4,this._pktLen),0))),e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let s=new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._macPos=0,this._macInstance=null;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}};function Mf(n){++n[11]>>>8&&++n[10]>>>8&&++n[9]>>>8&&++n[8]>>>8&&++n[7]>>>8&&++n[6]>>>8&&++n[5]>>>8&&++n[4]>>>8}var n0=(()=>{let n=Buffer.alloc(4);return t=>(n[0]=t>>>24,n[1]=t>>>16,n[2]=t>>>8,n[3]=t,n)})();function r0(n,t){return n.length!==t.length?(Zo(n,n),!1):Zo(n,t)}function i0(n){if(typeof n!="object"||n===null)throw new Error("Invalid config");if(typeof n.outbound!="object"||n.outbound===null)throw new Error("Invalid outbound");let t=n.outbound;if(typeof t.onWrite!="function")throw new Error("Invalid outbound.onWrite");if(typeof t.cipherInfo!="object"||t.cipherInfo===null)throw new Error("Invalid outbound.cipherInfo");if(!Buffer.isBuffer(t.cipherKey)||t.cipherKey.length!==t.cipherInfo.keyLen)throw new Error("Invalid outbound.cipherKey");if(t.cipherInfo.ivLen&&(!Buffer.isBuffer(t.cipherIV)||t.cipherIV.length!==t.cipherInfo.ivLen))throw new Error("Invalid outbound.cipherIV");if(typeof t.seqno!="number"||t.seqno<0||t.seqno>Pf)throw new Error("Invalid outbound.seqno");let e=!!t.forceNative;switch(t.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return ma&&!e?new sa(n):new ia(n);case"chacha20":return ga&&!e?new ra(n):new na(n);default:{if(typeof t.macInfo!="object"||t.macInfo===null)throw new Error("Invalid outbound.macInfo");if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw new Error("Invalid outbound.macKey");return Aa&&!e?new aa(n):new oa(n)}}}function s0(n){if(typeof n!="object"||n===null)throw new Error("Invalid config");if(typeof n.inbound!="object"||n.inbound===null)throw new Error("Invalid inbound");let t=n.inbound;if(typeof t.onPayload!="function")throw new Error("Invalid inbound.onPayload");if(typeof t.decipherInfo!="object"||t.decipherInfo===null)throw new Error("Invalid inbound.decipherInfo");if(!Buffer.isBuffer(t.decipherKey)||t.decipherKey.length!==t.decipherInfo.keyLen)throw new Error("Invalid inbound.decipherKey");if(t.decipherInfo.ivLen&&(!Buffer.isBuffer(t.decipherIV)||t.decipherIV.length!==t.decipherInfo.ivLen))throw new Error("Invalid inbound.decipherIV");if(typeof t.seqno!="number"||t.seqno<0||t.seqno>Pf)throw new Error("Invalid inbound.seqno");let e=!!t.forceNative;switch(t.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return ya&&!e?new da(n):new fa(n);case"chacha20":return Ea&&!e?new ua(n):new la(n);default:{if(typeof t.macInfo!="object"||t.macInfo===null)throw new Error("Invalid inbound.macInfo");if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw new Error("Invalid inbound.macKey");return Sa&&!e?new pa(n):new ha(n)}}}Df.exports={CIPHER_INFO:e0,MAC_INFO:t0,bindingAvailable:!!ea,init:new Promise(async(n,t)=>{try{Ii=await Rf()(),ki=Ii._malloc(16),_a=Ii.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(e){return t(e)}n()}),NullCipher:ta,createCipher:i0,NullDecipher:ca,createDecipher:s0}});var ir=ut((Nx,Kf)=>{"use strict";var{createDecipheriv:xa,createECDH:o0,createHash:Ni,createHmac:a0,createSign:c0,createVerify:l0,getCiphers:u0,sign:Lf,verify:Uf}=require("crypto"),f0=u0(),{Ber:Pe}=bi(),d0=Ko().pbkdf,{CIPHER_INFO:Bi}=tr(),{eddsaSupported:wa,SUPPORTED_CIPHER:h0}=qn(),{bufferSlice:Er,makeBufferParser:p0,readString:Ne,readUInt32BE:vi,writeUInt32BE:Wt}=xn(),Vn=Symbol("Hash Algorithm"),wn=Symbol("Private key PEM"),Pn=Symbol("Public key PEM"),rr=Symbol("Public key SSH"),Vr=Symbol("Decrypted Key"),ba=Object.create(null);{let n=Object.keys(Bi);for(let t=0;t<n.length;++t){let e=Bi[n[t]].sslName;!e||ba[e]||(ba[e]=Bi[n[t]])}}var Fs=p0();function In(n,t){t=t.base64Slice(0,t.length);let e=t.replace(/.{64}/g,`$&
|
|
4
|
+
-----END PRIVATE KEY-----`,t=Buffer.from("a"),e,r;try{e=Wn.sign(null,t,n),r=Wn.verify(null,t,n,e)}catch{}return Buffer.isBuffer(e)&&e.length===64&&r===!0}return!1})(),bf=typeof Wn.diffieHellman=="function"&&typeof Wn.generateKeyPairSync=="function"&&typeof Wn.createPublicKey=="function",Ts=["ecdh-sha2-nistp256","ecdh-sha2-nistp384","ecdh-sha2-nistp521","diffie-hellman-group-exchange-sha256","diffie-hellman-group14-sha256","diffie-hellman-group15-sha512","diffie-hellman-group16-sha512","diffie-hellman-group17-sha512","diffie-hellman-group18-sha512"];bf&&(Ts.unshift("curve25519-sha256"),Ts.unshift("curve25519-sha256@libssh.org"));var Gm=Ts.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),zo=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];_f&&zo.unshift("ssh-ed25519");var Ym=zo.concat(["ssh-dss"]),xf=(()=>{let n=Wn.getCiphers();return t=>n.includes(Km[t].sslName)})(),er=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];Qr&&Qr.flags&&!Qr.flags.aes?Sf?er.unshift("chacha20-poly1305@openssh.com"):er.push("chacha20-poly1305@openssh.com"):Sf&&Qr&&Qr.arch==="x86"?er.splice(4,0,"chacha20-poly1305@openssh.com"):er.push("chacha20-poly1305@openssh.com");er=er.filter(xf);var jm=er.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter(xf)),wf=(()=>{let n=Wn.getHashes();return t=>n.includes(zm[t].sslName)})(),If=["hmac-sha2-256-etm@openssh.com","hmac-sha2-512-etm@openssh.com","hmac-sha1-etm@openssh.com","hmac-sha2-256","hmac-sha2-512","hmac-sha1"].filter(wf),Xm=If.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(wf)),Cf=["none","zlib@openssh.com","zlib"],Jm=Cf.concat([]),Hr={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};Os.exports={MESSAGE:{DISCONNECT:1,IGNORE:2,UNIMPLEMENTED:3,DEBUG:4,SERVICE_REQUEST:5,SERVICE_ACCEPT:6,EXT_INFO:7,KEXINIT:20,NEWKEYS:21,KEXDH_INIT:30,KEXDH_REPLY:31,KEXDH_GEX_GROUP:31,KEXDH_GEX_INIT:32,KEXDH_GEX_REPLY:33,KEXDH_GEX_REQUEST:34,KEXECDH_INIT:30,KEXECDH_REPLY:31,USERAUTH_REQUEST:50,USERAUTH_FAILURE:51,USERAUTH_SUCCESS:52,USERAUTH_BANNER:53,USERAUTH_PASSWD_CHANGEREQ:60,USERAUTH_PK_OK:60,USERAUTH_INFO_REQUEST:60,USERAUTH_INFO_RESPONSE:61,GLOBAL_REQUEST:80,REQUEST_SUCCESS:81,REQUEST_FAILURE:82,CHANNEL_OPEN:90,CHANNEL_OPEN_CONFIRMATION:91,CHANNEL_OPEN_FAILURE:92,CHANNEL_WINDOW_ADJUST:93,CHANNEL_DATA:94,CHANNEL_EXTENDED_DATA:95,CHANNEL_EOF:96,CHANNEL_CLOSE:97,CHANNEL_REQUEST:98,CHANNEL_SUCCESS:99,CHANNEL_FAILURE:100},DISCONNECT_REASON:{HOST_NOT_ALLOWED_TO_CONNECT:1,PROTOCOL_ERROR:2,KEY_EXCHANGE_FAILED:3,RESERVED:4,MAC_ERROR:5,COMPRESSION_ERROR:6,SERVICE_NOT_AVAILABLE:7,PROTOCOL_VERSION_NOT_SUPPORTED:8,HOST_KEY_NOT_VERIFIABLE:9,CONNECTION_LOST:10,BY_APPLICATION:11,TOO_MANY_CONNECTIONS:12,AUTH_CANCELED_BY_USER:13,NO_MORE_AUTH_METHODS_AVAILABLE:14,ILLEGAL_USER_NAME:15},DISCONNECT_REASON_STR:void 0,CHANNEL_OPEN_FAILURE:{ADMINISTRATIVELY_PROHIBITED:1,CONNECT_FAILED:2,UNKNOWN_CHANNEL_TYPE:3,RESOURCE_SHORTAGE:4},TERMINAL_MODE:{TTY_OP_END:0,VINTR:1,VQUIT:2,VERASE:3,VKILL:4,VEOF:5,VEOL:6,VEOL2:7,VSTART:8,VSTOP:9,VSUSP:10,VDSUSP:11,VREPRINT:12,VWERASE:13,VLNEXT:14,VFLUSH:15,VSWTCH:16,VSTATUS:17,VDISCARD:18,IGNPAR:30,PARMRK:31,INPCK:32,ISTRIP:33,INLCR:34,IGNCR:35,ICRNL:36,IUCLC:37,IXON:38,IXANY:39,IXOFF:40,IMAXBEL:41,ISIG:50,ICANON:51,XCASE:52,ECHO:53,ECHOE:54,ECHOK:55,ECHONL:56,NOFLSH:57,TOSTOP:58,IEXTEN:59,ECHOCTL:60,ECHOKE:61,PENDIN:62,OPOST:70,OLCUC:71,ONLCR:72,OCRNL:73,ONOCR:74,ONLRET:75,CS7:90,CS8:91,PARENB:92,PARODD:93,TTY_OP_ISPEED:128,TTY_OP_OSPEED:129},CHANNEL_EXTENDED_DATATYPE:{STDERR:1},SIGNALS:["ABRT","ALRM","FPE","HUP","ILL","INT","QUIT","SEGV","TERM","USR1","USR2","KILL","PIPE"].reduce((n,t)=>({...n,[t]:1}),{}),COMPAT:Hr,COMPAT_CHECKS:[["Cisco-1.25",Hr.BAD_DHGEX],[/^Cisco-1[.]/,Hr.BUG_DHGEX_LARGE],[/^[0-9.]+$/,Hr.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,Hr.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,Hr.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:Ts,SUPPORTED_KEX:Gm,DEFAULT_SERVER_HOST_KEY:zo,SUPPORTED_SERVER_HOST_KEY:Ym,DEFAULT_CIPHER:er,SUPPORTED_CIPHER:jm,DEFAULT_MAC:If,SUPPORTED_MAC:Xm,DEFAULT_COMPRESSION:Cf,SUPPORTED_COMPRESSION:Jm,curve25519Supported:bf,eddsaSupported:_f};Os.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(Os.exports.DISCONNECT_REASON)).reduce((n,[t,e])=>({...n,[e]:t}),{})});var xn=ut((kx,Bf)=>{"use strict";var En=bi().Ber,Ms,Nf=Buffer[Symbol.species],Zm=Object.getPrototypeOf(Uint8Array.prototype).fill;function kf(n,t){return n[t++]*16777216+n[t++]*65536+n[t++]*256+n[t]}function xi(n,t,e,r,s){s||(s=0),r>n.length&&(r=n.length);let i=r-e,o=t.length-s;return i>o&&(i=o),t.set(new Uint8Array(n.buffer,n.byteOffset+e,i),s),i}function wi(n,t,e){return e===void 0&&(e=n.length),new Nf(n.buffer,n.byteOffset+t,e-t)}function Yo(){let n=0,t,e={init:(r,s)=>{t=r,n=typeof s=="number"?s:0},pos:()=>n,length:()=>t?t.length:0,avail:()=>t&&n<t.length?t.length-n:0,clear:()=>{t=void 0},readUInt32BE:()=>{if(!(!t||n+3>=t.length))return t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]},readUInt64BE:r=>{if(!(!t||n+7>=t.length))switch(r){case"always":return BigInt(`0x${t.hexSlice(n,n+=8)}`);case"maybe":if(t[n]>31)return BigInt(`0x${t.hexSlice(n,n+=8)}`);default:return t[n++]*72057594037927940+t[n++]*281474976710656+t[n++]*1099511627776+t[n++]*4294967296+t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]}},skip:r=>{t&&r>0&&(n+=r)},skipString:()=>{let r=e.readUInt32BE();if(r!==void 0)return n+=r,n<=t.length?r:void 0},readByte:()=>{if(t&&n<t.length)return t[n++]},readBool:()=>{if(t&&n<t.length)return!!t[n++]},readList:()=>{let r=e.readString(!0);if(r!==void 0)return r?r.split(","):[]},readString:(r,s)=>{typeof r=="number"&&(s=r,r=void 0);let i=e.readUInt32BE();if(i!==void 0&&!(t.length-n<i||typeof s=="number"&&i>s))return r?Buffer.isBuffer(r)?xi(t,r,n,n+=i):t.utf8Slice(n,n+=i):wi(t,n,n+=i)},readRaw:r=>{if(t){if(typeof r!="number")return wi(t,n,n+=t.length-n);if(t.length-n>=r)return wi(t,n,n+=r)}}};return e}function vf(n,t,e){let r=new Error(n);return typeof t=="boolean"?(e=t,r.level="protocol"):r.level=t||"protocol",r.fatal=!!e,r}function Go(n,t,e){return n[e++]=t>>>24,n[e++]=t>>>16,n[e++]=t>>>8,n[e++]=t,e}var Ds=Yo();Bf.exports={bufferCopy:xi,bufferSlice:wi,FastBuffer:Nf,bufferFill:(n,t,e,r)=>Zm.call(n,t,e,r),makeError:vf,doFatalError:(n,t,e,r)=>{let s;return Ms===void 0&&({DISCONNECT_REASON:Ms}=qn()),t instanceof Error?(s=t,typeof e!="number"?r=Ms.PROTOCOL_ERROR:r=e):s=vf(t,e,!0),typeof r!="number"&&(r=Ms.PROTOCOL_ERROR),n.disconnect(r),n._destruct(),n._onError(s),1/0},readUInt32BE:kf,writeUInt32BE:Go,writeUInt32LE:(n,t,e)=>(n[e++]=t,n[e++]=t>>>8,n[e++]=t>>>16,n[e++]=t>>>24,e),makeBufferParser:Yo,bufferParser:Yo(),readString:(n,t,e,r)=>{typeof e=="number"&&(r=e,e=void 0),t===void 0&&(t=0);let s=n.length-t;if(t<0||t>=n.length||s<4)return;let i=kf(n,t);if(s<4+i||typeof r=="number"&&i>r)return;t+=4;let o=t+i;return n._pos=o,e?Buffer.isBuffer(e)?xi(n,e,t,o):n.utf8Slice(t,o):wi(n,t,o)},sigSSHToASN1:(n,t)=>{switch(t){case"ssh-dss":{if(n.length>40)return n;let e=new En.Writer;e.startSequence();let r=n.slice(0,20),s=n.slice(20);if(r[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,r.copy(i,1),r=i}else r[0]===0&&!(r[1]&128)&&(r=r.slice(1));if(s[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,s.copy(i,1),s=i}else s[0]===0&&!(s[1]&128)&&(s=s.slice(1));return e.writeBuffer(r,En.Integer),e.writeBuffer(s,En.Integer),e.endSequence(),e.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{Ds.init(n,0);let e=Ds.readString(),r=Ds.readString();if(Ds.clear(),e===void 0||r===void 0)return;let s=new En.Writer;return s.startSequence(),s.writeBuffer(e,En.Integer),s.writeBuffer(r,En.Integer),s.endSequence(),s.buffer}default:return n}},convertSignature:(n,t)=>{switch(t){case"ssh-dss":{if(n.length<=40)return n;let e=new En.Reader(n);e.readSequence();let r=e.readString(En.Integer,!0),s=e.readString(En.Integer,!0),i=0,o=0;if(r.length<20){let c=Buffer.allocUnsafe(20);c.set(r,1),r=c,r[0]=0}if(s.length<20){let c=Buffer.allocUnsafe(20);c.set(s,1),s=c,s[0]=0}r.length>20&&r[0]===0&&(i=1),s.length>20&&s[0]===0&&(o=1);let a=Buffer.allocUnsafe(r.length-i+(s.length-o));return xi(r,a,i,r.length,0),xi(s,a,o,s.length,r.length-i),a}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{if(n[0]===0)return n;let e=new En.Reader(n);e.readSequence();let r=e.readString(En.Integer,!0),s=e.readString(En.Integer,!0);if(r===null||s===null)return;let i=Buffer.allocUnsafe(4+r.length+4+s.length);return Go(i,r.length,0),i.set(r,4),Go(i,s.length,4+r.length),i.set(s,8+r.length),i}}return n},sendPacket:(n,t,e)=>!e&&n._kexinit!==void 0?(n._queue===void 0&&(n._queue=[]),n._queue.push(t),n._debug&&n._debug("Outbound: ... packet queued"),!1):(n._cipher.encrypt(t),!0)}});var Rf=ut((Ls,Xo)=>{var jo=(function(){var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),(function(t){t=t||{};var e;e||(e=typeof t<"u"?t:{});var r,s;e.ready=new Promise(function(J,pe){r=J,s=pe});var i={},o;for(o in e)e.hasOwnProperty(o)&&(i[o]=e[o]);var a=typeof window=="object",c=typeof importScripts=="function",l=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",u="",f,h,p,A,E;l?(u=c?require("path").dirname(u)+"/":__dirname+"/",f=function(J,pe){var we=Ln(J);return we?pe?we:we.toString():(A||(A=require("fs")),E||(E=require("path")),J=E.normalize(J),A.readFileSync(J,pe?null:"utf8"))},p=function(J){return J=f(J,!0),J.buffer||(J=new Uint8Array(J)),$(J.buffer),J},h=function(J,pe,we){var Oe=Ln(J);Oe&&pe(Oe),A||(A=require("fs")),E||(E=require("path")),J=E.normalize(J),A.readFile(J,function(Ze,Lt){Ze?we(Ze):pe(Lt.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),e.inspect=function(){return"[Emscripten Module object]"}):(a||c)&&(c?u=self.location.href:typeof document<"u"&&document.currentScript&&(u=document.currentScript.src),n&&(u=n),u.indexOf("blob:")!==0?u=u.substr(0,u.lastIndexOf("/")+1):u="",f=function(J){try{var pe=new XMLHttpRequest;return pe.open("GET",J,!1),pe.send(null),pe.responseText}catch(Ze){if(J=Ln(J)){pe=[];for(var we=0;we<J.length;we++){var Oe=J[we];255<Oe&&(xr&&$(!1,"Character code "+Oe+" ("+String.fromCharCode(Oe)+") at offset "+we+" not in 0x00-0xFF."),Oe&=255),pe.push(String.fromCharCode(Oe))}return pe.join("")}throw Ze}},c&&(p=function(J){try{var pe=new XMLHttpRequest;return pe.open("GET",J,!1),pe.responseType="arraybuffer",pe.send(null),new Uint8Array(pe.response)}catch(we){if(J=Ln(J))return J;throw we}}),h=function(J,pe,we){var Oe=new XMLHttpRequest;Oe.open("GET",J,!0),Oe.responseType="arraybuffer",Oe.onload=function(){if(Oe.status==200||Oe.status==0&&Oe.response)pe(Oe.response);else{var Ze=Ln(J);Ze?pe(Ze.buffer):we()}},Oe.onerror=we,Oe.send(null)}),e.print||console.log.bind(console);var b=e.printErr||console.warn.bind(console);for(o in i)i.hasOwnProperty(o)&&(e[o]=i[o]);i=null;var x;e.wasmBinary&&(x=e.wasmBinary);var P=e.noExitRuntime||!0;typeof WebAssembly!="object"&&z("no native wasm support detected");var q,C=!1;function $(J,pe){J||z("Assertion failed: "+pe)}function F(J){var pe=e["_"+J];return $(pe,"Cannot call unknown function "+J+", make sure it is exported"),pe}function v(J,pe,we,Oe){var Ze={string:function(lt){var Ht=0;if(lt!=null&<!==0){var $t=(lt.length<<2)+1;Ht=ui($t);var vt=Ht,At=N;if(0<$t){$t=vt+$t-1;for(var mn=0;mn<lt.length;++mn){var Nt=lt.charCodeAt(mn);if(55296<=Nt&&57343>=Nt){var dr=lt.charCodeAt(++mn);Nt=65536+((Nt&1023)<<10)|dr&1023}if(127>=Nt){if(vt>=$t)break;At[vt++]=Nt}else{if(2047>=Nt){if(vt+1>=$t)break;At[vt++]=192|Nt>>6}else{if(65535>=Nt){if(vt+2>=$t)break;At[vt++]=224|Nt>>12}else{if(vt+3>=$t)break;At[vt++]=240|Nt>>18,At[vt++]=128|Nt>>12&63}At[vt++]=128|Nt>>6&63}At[vt++]=128|Nt&63}}At[vt]=0}}return Ht},array:function(lt){var Ht=ui(lt.length);return k.set(lt,Ht),Ht}},Lt=F(J),vn=[];if(J=0,Oe)for(var un=0;un<Oe.length;un++){var vr=Ze[we[un]];vr?(J===0&&(J=li()),vn[un]=vr(Oe[un])):vn[un]=Oe[un]}return we=Lt.apply(null,vn),we=(function(lt){if(pe==="string")if(lt){for(var Ht=N,$t=lt+NaN,vt=lt;Ht[vt]&&!(vt>=$t);)++vt;if(16<vt-lt&&Ht.subarray&&_)lt=_.decode(Ht.subarray(lt,vt));else{for($t="";lt<vt;){var At=Ht[lt++];if(At&128){var mn=Ht[lt++]&63;if((At&224)==192)$t+=String.fromCharCode((At&31)<<6|mn);else{var Nt=Ht[lt++]&63;At=(At&240)==224?(At&15)<<12|mn<<6|Nt:(At&7)<<18|mn<<12|Nt<<6|Ht[lt++]&63,65536>At?$t+=String.fromCharCode(At):(At-=65536,$t+=String.fromCharCode(55296|At>>10,56320|At&1023))}}else $t+=String.fromCharCode(At)}lt=$t}}else lt="";else lt=pe==="boolean"?!!lt:lt;return lt})(we),J!==0&&os(J),we}var _=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,w,k,N;function R(){var J=q.buffer;w=J,e.HEAP8=k=new Int8Array(J),e.HEAP16=new Int16Array(J),e.HEAP32=new Int32Array(J),e.HEAPU8=N=new Uint8Array(J),e.HEAPU16=new Uint16Array(J),e.HEAPU32=new Uint32Array(J),e.HEAPF32=new Float32Array(J),e.HEAPF64=new Float64Array(J)}var ie,j=[],X=[],re=[];function fe(){var J=e.preRun.shift();j.unshift(J)}var H=0,B=null,D=null;e.preloadedImages={},e.preloadedAudios={};function z(J){throw e.onAbort&&e.onAbort(J),b(J),C=!0,J=new WebAssembly.RuntimeError("abort("+J+"). Build with -s ASSERTIONS=1 for more info."),s(J),J}var ne="data:application/octet-stream;base64,",de;if(de="data:application/octet-stream;base64,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",!de.startsWith(ne)){var oe=de;de=e.locateFile?e.locateFile(oe,u):u+oe}function Je(){var J=de;try{if(J==de&&x)return new Uint8Array(x);var pe=Ln(J);if(pe)return pe;if(p)return p(J);throw"both async and sync fetching of the wasm failed"}catch(we){z(we)}}function ht(){if(!x&&(a||c)){if(typeof fetch=="function"&&!de.startsWith("file://"))return fetch(de,{credentials:"same-origin"}).then(function(J){if(!J.ok)throw"failed to load wasm binary file at '"+de+"'";return J.arrayBuffer()}).catch(function(){return Je()});if(h)return new Promise(function(J,pe){h(de,function(we){J(new Uint8Array(we))},pe)})}return Promise.resolve().then(function(){return Je()})}function ln(J){for(;0<J.length;){var pe=J.shift();if(typeof pe=="function")pe(e);else{var we=pe.m;typeof we=="number"?pe.l===void 0?ie.get(we)():ie.get(we)(pe.l):we(pe.l===void 0?null:pe.l)}}}var xr=!1,wr=typeof atob=="function"?atob:function(J){var pe="",we=0;J=J.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var Oe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(J.charAt(we++)),Ze="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(J.charAt(we++)),Lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(J.charAt(we++)),vn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(J.charAt(we++));Oe=Oe<<2|Ze>>4,Ze=(Ze&15)<<4|Lt>>2;var un=(Lt&3)<<6|vn;pe+=String.fromCharCode(Oe),Lt!==64&&(pe+=String.fromCharCode(Ze)),vn!==64&&(pe+=String.fromCharCode(un))}while(we<J.length);return pe};function Ln(J){if(J.startsWith(ne)){if(J=J.slice(ne.length),typeof l=="boolean"&&l){var pe=Buffer.from(J,"base64");pe=new Uint8Array(pe.buffer,pe.byteOffset,pe.byteLength)}else try{var we=wr(J),Oe=new Uint8Array(we.length);for(J=0;J<we.length;++J)Oe[J]=we.charCodeAt(J);pe=Oe}catch{throw Error("Converting base64 string to bytes failed.")}return pe}}var Ir={a:function(J){var pe=N.length;if(J>>>=0,2147483648<J)return!1;for(var we=1;4>=we;we*=2){var Oe=pe*(1+.2/we);Oe=Math.min(Oe,J+100663296),Oe=Math.max(J,Oe),0<Oe%65536&&(Oe+=65536-Oe%65536);e:{try{q.grow(Math.min(2147483648,Oe)-w.byteLength+65535>>>16),R();var Ze=1;break e}catch{}Ze=void 0}if(Ze)return!0}return!1}};(function(){function J(Ze){e.asm=Ze.exports,q=e.asm.b,R(),ie=e.asm.j,X.unshift(e.asm.c),H--,e.monitorRunDependencies&&e.monitorRunDependencies(H),H==0&&(B!==null&&(clearInterval(B),B=null),D&&(Ze=D,D=null,Ze()))}function pe(Ze){J(Ze.instance)}function we(Ze){return ht().then(function(Lt){return WebAssembly.instantiate(Lt,Oe)}).then(Ze,function(Lt){b("failed to asynchronously prepare wasm: "+Lt),z(Lt)})}var Oe={a:Ir};if(H++,e.monitorRunDependencies&&e.monitorRunDependencies(H),e.instantiateWasm)try{return e.instantiateWasm(Oe,J)}catch(Ze){return b("Module.instantiateWasm callback failed with error: "+Ze),!1}return(function(){return x||typeof WebAssembly.instantiateStreaming!="function"||de.startsWith(ne)||de.startsWith("file://")||typeof fetch!="function"?we(pe):fetch(de,{credentials:"same-origin"}).then(function(Ze){return WebAssembly.instantiateStreaming(Ze,Oe).then(pe,function(Lt){return b("wasm streaming compile failed: "+Lt),b("falling back to ArrayBuffer instantiation"),we(pe)})})})().catch(s),{}})(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.c).apply(null,arguments)},e._poly1305_auth=function(){return(e._poly1305_auth=e.asm.d).apply(null,arguments)};var li=e.stackSave=function(){return(li=e.stackSave=e.asm.e).apply(null,arguments)},os=e.stackRestore=function(){return(os=e.stackRestore=e.asm.f).apply(null,arguments)},ui=e.stackAlloc=function(){return(ui=e.stackAlloc=e.asm.g).apply(null,arguments)};e._malloc=function(){return(e._malloc=e.asm.h).apply(null,arguments)},e._free=function(){return(e._free=e.asm.i).apply(null,arguments)},e.cwrap=function(J,pe,we,Oe){we=we||[];var Ze=we.every(function(Lt){return Lt==="number"});return pe!=="string"&&Ze&&!Oe?F(J):function(){return v(J,pe,we,arguments)}};var Cr;D=function J(){Cr||kr(),Cr||(D=J)};function kr(){function J(){if(!Cr&&(Cr=!0,e.calledRun=!0,!C)){if(ln(X),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;){var pe=e.postRun.shift();re.unshift(pe)}ln(re)}}if(!(0<H)){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)fe();ln(j),0<H||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),J()},1)):J())}}if(e.run=kr,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();return kr(),t.ready})})();typeof Ls=="object"&&typeof Xo=="object"?Xo.exports=jo:typeof define=="function"&&define.amd?define([],function(){return jo}):typeof Ls=="object"&&(Ls.createPoly1305=jo)});var tr=ut((vx,Df)=>{"use strict";var{createCipheriv:qr,createDecipheriv:Us,createHmac:Jo,randomFillSync:Ar,timingSafeEqual:Zo}=require("crypto"),{readUInt32BE:Ci,writeUInt32BE:hn}=xn(),nr=Buffer[Symbol.species],Pf=2**32-1,Tf=Buffer.alloc(0),Wr=Buffer.alloc(4),$s=new Map,yr=35e3,ea,ma,ga,Aa,ya,Ea,Sa;try{ea=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:ma,ChaChaPolyCipher:ga,GenericCipher:Aa,AESGCMDecipher:ya,ChaChaPolyDecipher:Ea,GenericDecipher:Sa}=ea}catch{}var Kt=1,e0=(()=>{function n(t,e,r,s,i,o,a){return{sslName:t,blockLen:e,keyLen:r,ivLen:s!==0||a&Kt?s:e,authLen:i,discardLen:o,stream:!!(a&Kt)}}return{"chacha20-poly1305@openssh.com":n("chacha20",8,64,0,16,0,Kt),"aes128-gcm":n("aes-128-gcm",16,16,12,16,0,Kt),"aes256-gcm":n("aes-256-gcm",16,32,12,16,0,Kt),"aes128-gcm@openssh.com":n("aes-128-gcm",16,16,12,16,0,Kt),"aes256-gcm@openssh.com":n("aes-256-gcm",16,32,12,16,0,Kt),"aes128-cbc":n("aes-128-cbc",16,16,0,0,0,0),"aes192-cbc":n("aes-192-cbc",16,24,0,0,0,0),"aes256-cbc":n("aes-256-cbc",16,32,0,0,0,0),"rijndael-cbc@lysator.liu.se":n("aes-256-cbc",16,32,0,0,0,0),"3des-cbc":n("des-ede3-cbc",8,24,0,0,0,0),"blowfish-cbc":n("bf-cbc",8,16,0,0,0,0),"idea-cbc":n("idea-cbc",8,16,0,0,0,0),"cast128-cbc":n("cast-cbc",8,16,0,0,0,0),"aes128-ctr":n("aes-128-ctr",16,16,16,0,0,Kt),"aes192-ctr":n("aes-192-ctr",16,24,16,0,0,Kt),"aes256-ctr":n("aes-256-ctr",16,32,16,0,0,Kt),"3des-ctr":n("des-ede3",8,24,8,0,0,Kt),"blowfish-ctr":n("bf-ecb",8,16,8,0,0,Kt),"cast128-ctr":n("cast5-ecb",8,16,8,0,0,Kt),arcfour:n("rc4",8,16,0,0,1536,Kt),arcfour128:n("rc4",8,16,0,0,1536,Kt),arcfour256:n("rc4",8,32,0,0,1536,Kt),arcfour512:n("rc4",8,64,0,0,1536,Kt)}})(),t0=(()=>{function n(t,e,r,s){return{sslName:t,len:e,actualLen:r,isETM:s}}return{"hmac-md5":n("md5",16,16,!1),"hmac-md5-96":n("md5",16,12,!1),"hmac-ripemd160":n("ripemd160",20,20,!1),"hmac-sha1":n("sha1",20,20,!1),"hmac-sha1-etm@openssh.com":n("sha1",20,20,!0),"hmac-sha1-96":n("sha1",20,12,!1),"hmac-sha2-256":n("sha256",32,32,!1),"hmac-sha2-256-etm@openssh.com":n("sha256",32,32,!0),"hmac-sha2-256-96":n("sha256",32,12,!1),"hmac-sha2-512":n("sha512",64,64,!1),"hmac-sha2-512-etm@openssh.com":n("sha512",64,64,!0),"hmac-sha2-512-96":n("sha512",64,12,!1)}})(),ta=class{constructor(t,e){this.outSeqno=t,this._onWrite=e,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return hn(s,e-4,0),s[4]=r,Ar(s,5+t,r),s}encrypt(t){this._dead||(this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},Of=Buffer.alloc(32),sn=Buffer.alloc(16),Ii,ki,_a,na=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encKeyMain=e.cipherKey.slice(0,32),this._encKeyPktLen=e.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return hn(s,e-4,0),s[4]=r,Ar(s,5+t,r),s}encrypt(t){if(this._dead)return;sn[0]=0,hn(sn,this.outSeqno,12);let e=qr("chacha20",this._encKeyMain,sn).update(Of),r=qr("chacha20",this._encKeyPktLen,sn).update(t.slice(0,4));this._onWrite(r),sn[0]=1;let s=qr("chacha20",this._encKeyMain,sn).update(t.slice(4));this._onWrite(s),_a(ki,r,r.length,s,s.length,e);let i=Buffer.allocUnsafe(16);i.set(new Uint8Array(Ii.HEAPU8.buffer,ki,16),0),this._onWrite(i),this.outSeqno=this.outSeqno+1>>>0}},ra=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new ga(e.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e+16);return hn(s,e-4,0),s[4]=r,Ar(s,5+t,r),s}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},ia=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encSSLName=e.cipherInfo.sslName,this._encKey=e.cipherKey,this._encIV=e.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e);return hn(s,e-4,0),s[4]=r,Ar(s,5+t,r),s}encrypt(t){if(this._dead)return;let e=qr(this._encSSLName,this._encKey,this._encIV);e.setAutoPadding(!1);let r=t.slice(0,4);e.setAAD(r),this._onWrite(r);let s=e.update(t.slice(4));this._onWrite(s);let i=e.final();i.length&&this._onWrite(i);let o=e.getAuthTag();this._onWrite(o),Mf(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},sa=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new ma(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e+16);return hn(s,e-4,0),s[4]=r,Ar(s,5+t,r),s}encrypt(t){this._dead||(this._instance.encrypt(t),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},oa=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._cipherInstance=qr(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;let r=e.cipherInfo.discardLen;if(r){let s=$s.get(r);s===void 0&&(s=Buffer.alloc(r),$s.set(r,s)),this._cipherInstance.update(s)}}free(){this._dead=!0}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r);return hn(i,r-4,0),i[4]=s,Ar(i,5+t,s),i}encrypt(t){if(this._dead)return;let e;if(this._macETM){let s=new Uint8Array(t.buffer,t.byteOffset,4),i=this._cipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+4,t.length-4));this._onWrite(s),this._onWrite(i),e=Jo(this._macSSLName,this._macKey),hn(Wr,this.outSeqno,0),e.update(Wr),e.update(s),e.update(i)}else{let s=this._cipherInstance.update(t);this._onWrite(s),e=Jo(this._macSSLName,this._macKey),hn(Wr,this.outSeqno,0),e.update(Wr),e.update(t)}let r=e.digest();r.length>this._macActualLen&&(r=r.slice(0,this._macActualLen)),this._onWrite(r),this.outSeqno=this.outSeqno+1>>>0}},aa=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._macLen=e.macInfo.len,this._macActualLen=e.macInfo.actualLen,this._aadLen=e.macInfo.isETM?4:0,this._instance=new Aa(e.cipherInfo.sslName,e.cipherKey,e.cipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r+this._macLen);return hn(i,r-4,0),i[4]=s,Ar(i,5+t,s),i}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._macActualLen<this._macLen&&(t=new nr(t.buffer,t.byteOffset,t.length-(this._macLen-this._macActualLen))),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},ca=class{constructor(t,e){this.inSeqno=t,this._onPayload=e,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len>yr||this._len<8||(4+this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._packetPos<this._len){let i=Math.min(this._len-this._packetPos,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),e+=i,this._packetPos+=i,this._packetPos<this._len)return}let s=this._packet?new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Tf;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},la=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decKeyMain=e.decipherKey.slice(0,32),this._decKeyPktLen=e.decipherKey.slice(32),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._calcMac=Buffer.allocUnsafe(16),this._macPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenPos<4){let a=Math.min(4-this._lenPos,r-e);for(;a--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;sn[0]=0,hn(sn,this.inSeqno,12);let c=Us("chacha20",this._decKeyPktLen,sn).update(this._lenBuf);if(this._len=Ci(c,0),this._len>yr||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length")}if(this._pktLen<this._len){if(e>=r)return;let a=Math.min(this._len-this._pktLen,r-e),c;if(e!==0||a!==r?c=new Uint8Array(t.buffer,t.byteOffset+e,a):c=t,a===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._pktLen)),e+=a,this._pktLen+=a,this._pktLen<this._len||e>=r)return}{let a=Math.min(16-this._macPos,r-e);if(e!==0||a!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,a),this._macPos):this._mac.set(t,this._macPos),e+=a,this._macPos+=a,this._macPos<16)return}sn[0]=0,hn(sn,this.inSeqno,12);let s=qr("chacha20",this._decKeyMain,sn).update(Of);if(_a(ki,this._lenBuf,4,this._packet,this._packet.length,s),this._calcMac.set(new Uint8Array(Ii.HEAPU8.buffer,ki,16),0),!Zo(this._calcMac,this._mac))throw new Error("Invalid MAC");sn[0]=1;let i=Us("chacha20",this._decKeyMain,sn).update(this._packet),o=new nr(i.buffer,i.byteOffset+1,i.length-i[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let a=this._onPayload(o);if(a!==void 0)return a===!1?e:a}}}},ua=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Ea(e.decipherKey),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._macPos=0}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._lenPos<4){let i=Math.min(4-this._lenPos,r-e);for(;i--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>yr||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let s=new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},fa=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=null,this._decipherSSLName=e.decipherInfo.sslName,this._decipherKey=e.decipherKey,this._decipherIV=e.decipherIV,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>yr||this._len<16||(this._len&15)!==0)throw new Error("Bad packet length");this._decipherInstance=Us(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(n0(this._len))}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=this._decipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+e,i)):o=this._decipherInstance.update(t),o.length&&(i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),this._packetPos+=o.length),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let i=this._decipherInstance.final();i.length&&(this._packet?this._packet.set(i,this._packetPos):this._packet=i)}let s=this._packet?new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Tf;this.inSeqno=this.inSeqno+1>>>0,Mf(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},da=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new ya(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>yr||this._len<16||(this._len&15)!==0)throw new Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let s=new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tagPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},ha=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=Us(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(e.macInfo.isETM?4:e.decipherInfo.blockLen),this._blockSize=e.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._macInstance=null;let r=e.decipherInfo.discardLen;if(r){let s=$s.get(r);s===void 0&&(s=Buffer.alloc(r),$s.set(r,s)),this._decipherInstance.update(s)}}free(){}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let o=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||o!==r||o<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._blockPos):this._block.set(t,this._blockPos),e+=o,this._blockPos+=o,this._blockPos<this._block.length)return;let a,c;if(this._macETM?this._len=c=Ci(this._block,0):(a=this._decipherInstance.update(this._block),this._len=Ci(a,0),c=4+this._len-this._blockSize),this._len>yr||this._len<5||(c&this._blockSize-1)!==0)throw new Error("Bad packet length");if(this._macInstance=Jo(this._macSSLName,this._macKey),hn(Wr,this.inSeqno,0),this._macInstance.update(Wr),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(a.buffer,a.byteOffset,4)),this._pktLen=a.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(a.buffer,a.byteOffset+4,this._packetPos),0)),e>=r)return}if(this._pktLen<this._len){let o=Math.min(this._len-this._pktLen,r-e),a;e!==0||o!==r?a=new Uint8Array(t.buffer,t.byteOffset+e,o):a=t,this._macETM&&this._macInstance.update(a);let c=this._decipherInstance.update(a);if(c.length&&(o===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._packetPos)),this._packetPos+=c.length),e+=o,this._pktLen+=o,this._pktLen<this._len||e>=r)return}{let o=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||o!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._macPos):this._mac.set(t,this._macPos),e+=o,this._macPos+=o,this._macPos<this._macActualLen)return}this._macETM||this._macInstance.update(this._packet);let s=this._macInstance.digest();if(this._macActualLen<s.length&&(s=new Uint8Array(s.buffer,s.byteOffset,this._macActualLen)),!r0(s,this._mac))throw new Error("Invalid MAC");let i=new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._macPos=0,this._macInstance=null;{let o=this._onPayload(i);if(o!==void 0)return o===!1?e:o}}}},pa=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Sa(e.decipherInfo.sslName,e.decipherKey,e.decipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM,e.macInfo.actualLen),this._block=Buffer.allocUnsafe(e.macInfo.isETM||e.decipherInfo.stream?4:e.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let i=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||i!==r||i<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._blockPos):this._block.set(t,this._blockPos),e+=i,this._blockPos+=i,this._blockPos<this._block.length)return;let o;if(this._macETM?this._len=o=Ci(this._block,0):(this._instance.decryptBlock(this._block),this._len=Ci(this._block,0),o=4+this._len-this._block.length),this._len>yr||this._len<5||(o&this._block.length-1)!==0)throw new Error("Bad packet length");if(this._macETM||(this._pktLen=this._block.length-4,this._pktLen&&(this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(this._block.buffer,this._block.byteOffset+4,this._pktLen),0))),e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let s=new nr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._macPos=0,this._macInstance=null;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}};function Mf(n){++n[11]>>>8&&++n[10]>>>8&&++n[9]>>>8&&++n[8]>>>8&&++n[7]>>>8&&++n[6]>>>8&&++n[5]>>>8&&++n[4]>>>8}var n0=(()=>{let n=Buffer.alloc(4);return t=>(n[0]=t>>>24,n[1]=t>>>16,n[2]=t>>>8,n[3]=t,n)})();function r0(n,t){return n.length!==t.length?(Zo(n,n),!1):Zo(n,t)}function i0(n){if(typeof n!="object"||n===null)throw new Error("Invalid config");if(typeof n.outbound!="object"||n.outbound===null)throw new Error("Invalid outbound");let t=n.outbound;if(typeof t.onWrite!="function")throw new Error("Invalid outbound.onWrite");if(typeof t.cipherInfo!="object"||t.cipherInfo===null)throw new Error("Invalid outbound.cipherInfo");if(!Buffer.isBuffer(t.cipherKey)||t.cipherKey.length!==t.cipherInfo.keyLen)throw new Error("Invalid outbound.cipherKey");if(t.cipherInfo.ivLen&&(!Buffer.isBuffer(t.cipherIV)||t.cipherIV.length!==t.cipherInfo.ivLen))throw new Error("Invalid outbound.cipherIV");if(typeof t.seqno!="number"||t.seqno<0||t.seqno>Pf)throw new Error("Invalid outbound.seqno");let e=!!t.forceNative;switch(t.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return ma&&!e?new sa(n):new ia(n);case"chacha20":return ga&&!e?new ra(n):new na(n);default:{if(typeof t.macInfo!="object"||t.macInfo===null)throw new Error("Invalid outbound.macInfo");if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw new Error("Invalid outbound.macKey");return Aa&&!e?new aa(n):new oa(n)}}}function s0(n){if(typeof n!="object"||n===null)throw new Error("Invalid config");if(typeof n.inbound!="object"||n.inbound===null)throw new Error("Invalid inbound");let t=n.inbound;if(typeof t.onPayload!="function")throw new Error("Invalid inbound.onPayload");if(typeof t.decipherInfo!="object"||t.decipherInfo===null)throw new Error("Invalid inbound.decipherInfo");if(!Buffer.isBuffer(t.decipherKey)||t.decipherKey.length!==t.decipherInfo.keyLen)throw new Error("Invalid inbound.decipherKey");if(t.decipherInfo.ivLen&&(!Buffer.isBuffer(t.decipherIV)||t.decipherIV.length!==t.decipherInfo.ivLen))throw new Error("Invalid inbound.decipherIV");if(typeof t.seqno!="number"||t.seqno<0||t.seqno>Pf)throw new Error("Invalid inbound.seqno");let e=!!t.forceNative;switch(t.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return ya&&!e?new da(n):new fa(n);case"chacha20":return Ea&&!e?new ua(n):new la(n);default:{if(typeof t.macInfo!="object"||t.macInfo===null)throw new Error("Invalid inbound.macInfo");if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw new Error("Invalid inbound.macKey");return Sa&&!e?new pa(n):new ha(n)}}}Df.exports={CIPHER_INFO:e0,MAC_INFO:t0,bindingAvailable:!!ea,init:new Promise(async(n,t)=>{try{Ii=await Rf()(),ki=Ii._malloc(16),_a=Ii.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(e){return t(e)}n()}),NullCipher:ta,createCipher:i0,NullDecipher:ca,createDecipher:s0}});var ir=ut((Nx,Kf)=>{"use strict";var{createDecipheriv:xa,createECDH:o0,createHash:Ni,createHmac:a0,createSign:c0,createVerify:l0,getCiphers:u0,sign:Lf,verify:Uf}=require("crypto"),f0=u0(),{Ber:Pe}=bi(),d0=Ko().pbkdf,{CIPHER_INFO:Bi}=tr(),{eddsaSupported:wa,SUPPORTED_CIPHER:h0}=qn(),{bufferSlice:Er,makeBufferParser:p0,readString:Ne,readUInt32BE:vi,writeUInt32BE:Wt}=xn(),Vn=Symbol("Hash Algorithm"),wn=Symbol("Private key PEM"),Pn=Symbol("Public key PEM"),rr=Symbol("Public key SSH"),Vr=Symbol("Decrypted Key"),ba=Object.create(null);{let n=Object.keys(Bi);for(let t=0;t<n.length;++t){let e=Bi[n[t]].sslName;!e||ba[e]||(ba[e]=Bi[n[t]])}}var Fs=p0();function In(n,t){t=t.base64Slice(0,t.length);let e=t.replace(/.{64}/g,`$&
|
|
5
5
|
`);return t.length&63&&(e+=`
|
|
6
6
|
`),`-----BEGIN ${n} KEY-----
|
|
7
7
|
${e}-----END ${n} KEY-----`}function Ri(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return e.set(n,0),e.set(t,n.length),e}function Ia(n,t){let e=n.length,r=n._pos||0;for(let s=0;s<t;++s){let i=e-r;if(r>=e||i<4)return!1;let o=vi(n,r);if(i<4+o)return!1;r+=4+o}return n._pos=r,!0}function Pi(n,t){let e=new Pe.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.113549.1.1.1"),e.writeNull(),e.endSequence(),e.startSequence(Pe.BitString),e.writeByte(0),e.startSequence(),e.writeBuffer(n,Pe.Integer),e.writeBuffer(t,Pe.Integer),e.endSequence(),e.endSequence(),e.endSequence(),In("PUBLIC",e.buffer)}function Ti(n,t){let e=Buffer.allocUnsafe(15+t.length+4+n.length);Wt(e,7,0),e.utf8Write("ssh-rsa",4,7);let r=11;return Wt(e,t.length,r),e.set(t,r+=4),Wt(e,n.length,r+=t.length),e.set(n,r+4),e}var $f=(()=>{function n(r,s,i,o,a,c,l,u){let f=new Pe.Writer;return f.startSequence(),f.writeInt(0,Pe.Integer),f.writeBuffer(r,Pe.Integer),f.writeBuffer(s,Pe.Integer),f.writeBuffer(i,Pe.Integer),f.writeBuffer(o,Pe.Integer),f.writeBuffer(a,Pe.Integer),f.writeBuffer(c,Pe.Integer),f.writeBuffer(l,Pe.Integer),f.writeBuffer(u,Pe.Integer),f.endSequence(),f.buffer}function t(r){return BigInt(`0x${r.hexSlice(0,r.length)}`)}function e(r){let s=r.toString(16);if((s.length&1)!==0)s=`0${s}`;else{let i=s.charCodeAt(0);(i===56||i===57||i>=97&&i<=102)&&(s=`00${s}`)}return Buffer.from(s,"hex")}return function(s,i,o,a,c,l){let u=t(o),f=e(u%(t(c)-1n)),h=e(u%(t(l)-1n));return In("RSA PRIVATE",n(s,i,o,c,l,f,h,a))}})();function Oi(n,t,e,r){let s=new Pe.Writer;return s.startSequence(),s.startSequence(),s.writeOID("1.2.840.10040.4.1"),s.startSequence(),s.writeBuffer(n,Pe.Integer),s.writeBuffer(t,Pe.Integer),s.writeBuffer(e,Pe.Integer),s.endSequence(),s.endSequence(),s.startSequence(Pe.BitString),s.writeByte(0),s.writeBuffer(r,Pe.Integer),s.endSequence(),s.endSequence(),In("PUBLIC",s.buffer)}function Mi(n,t,e,r){let s=Buffer.allocUnsafe(15+n.length+4+t.length+4+e.length+4+r.length);Wt(s,7,0),s.utf8Write("ssh-dss",4,7);let i=11;return Wt(s,n.length,i),s.set(n,i+=4),Wt(s,t.length,i+=n.length),s.set(t,i+=4),Wt(s,e.length,i+=t.length),s.set(e,i+=4),Wt(s,r.length,i+=e.length),s.set(r,i+4),s}function Ff(n,t,e,r,s){let i=new Pe.Writer;return i.startSequence(),i.writeInt(0,Pe.Integer),i.writeBuffer(n,Pe.Integer),i.writeBuffer(t,Pe.Integer),i.writeBuffer(e,Pe.Integer),i.writeBuffer(r,Pe.Integer),i.writeBuffer(s,Pe.Integer),i.endSequence(),In("DSA PRIVATE",i.buffer)}function Hf(n){let t=new Pe.Writer;return t.startSequence(),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Pe.BitString),t.writeByte(0),t._ensure(n.length),t._buf.set(n,t._offset),t._offset+=n.length,t.endSequence(),t.endSequence(),In("PUBLIC",t.buffer)}function Qf(n){let t=Buffer.allocUnsafe(19+n.length);return Wt(t,11,0),t.utf8Write("ssh-ed25519",4,11),Wt(t,n.length,15),t.set(n,19),t}function m0(n){let t=new Pe.Writer;return t.startSequence(),t.writeInt(0,Pe.Integer),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Pe.OctetString),t.writeBuffer(n,Pe.OctetString),t.endSequence(),t.endSequence(),In("PRIVATE",t.buffer)}function Ca(n,t){let e=new Pe.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.10045.2.1"),e.writeOID(n),e.endSequence(),e.startSequence(Pe.BitString),e.writeByte(0),e._ensure(t.length),e._buf.set(t,e._offset),e._offset+=t.length,e.endSequence(),e.endSequence(),In("PUBLIC",e.buffer)}function ka(n,t){let e;switch(n){case"1.2.840.10045.3.1.7":e="nistp256";break;case"1.3.132.0.34":e="nistp384";break;case"1.3.132.0.35":e="nistp521";break;default:return}let r=Buffer.allocUnsafe(39+t.length);return Wt(r,19,0),r.utf8Write(`ecdsa-sha2-${e}`,4,19),Wt(r,8,23),r.utf8Write(e,27,8),Wt(r,t.length,35),r.set(t,39),r}function g0(n,t,e){let r=new Pe.Writer;return r.startSequence(),r.writeInt(1,Pe.Integer),r.writeBuffer(e,Pe.OctetString),r.startSequence(160),r.writeOID(n),r.endSequence(),r.startSequence(161),r.startSequence(Pe.BitString),r.writeByte(0),r._ensure(t.length),r._buf.set(t,r._offset),r._offset+=t.length,r.endSequence(),r.endSequence(),r.endSequence(),In("EC PRIVATE",r.buffer)}function A0(n,t){let e=o0(n);return e.setPrivateKey(t),e.getPublicKey()}var Di={sign:typeof Lf=="function"?function(t,e){let r=this[wn];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[Vn]);try{return Lf(e,t,r)}catch(s){return s}}:function(t,e){let r=this[wn];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[Vn]);let s=c0(e);s.update(t);try{return s.sign(r)}catch(i){return i}},verify:typeof Uf=="function"?function(t,e,r){let s=this[Pn];if(s===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[Vn]);try{return Uf(r,t,s,e)}catch(i){return i}}:function(t,e,r){let s=this[Pn];if(s===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[Vn]);let i=l0(r);i.update(t);try{return i.verify(s,e)}catch(o){return o}},isPrivateKey:function(){return this[wn]!==null},getPrivatePEM:function(){return this[wn]},getPublicPEM:function(){return this[Pn]},getPublicSSH:function(){return this[rr]},equals:function(t){let e=Vf(t);return e instanceof Error?!1:this.type===e.type&&this[wn]===e[wn]&&this[Pn]===e[Pn]&&this[rr].equals(e[rr])}};function Hs(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[wn]=e,this[Pn]=r,this[rr]=s,this[Vn]=i,this[Vr]=o}Hs.prototype=Di;{let t=function(e,r,s){let i=[];if(e.length<8)return new Error("Malformed OpenSSH private key");let o=vi(e,0),a=vi(e,4);if(o!==a)return s?new Error("OpenSSH key integrity check failed -- bad passphrase?"):new Error("OpenSSH key integrity check failed");e._pos=8;let c,l;for(c=0;c<r;++c){let f,h,p,A,E=Ne(e,e._pos,!0);if(E===void 0)return new Error("Malformed OpenSSH private key");switch(E){case"ssh-rsa":{let x=Ne(e,e._pos);if(x===void 0)return new Error("Malformed OpenSSH private key");let P=Ne(e,e._pos);if(P===void 0)return new Error("Malformed OpenSSH private key");let q=Ne(e,e._pos);if(q===void 0)return new Error("Malformed OpenSSH private key");let C=Ne(e,e._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");let $=Ne(e,e._pos);if($===void 0)return new Error("Malformed OpenSSH private key");let F=Ne(e,e._pos);if(F===void 0)return new Error("Malformed OpenSSH private key");p=Pi(x,P),A=Ti(x,P),h=$f(x,P,q,C,$,F),f="sha1";break}case"ssh-dss":{let x=Ne(e,e._pos);if(x===void 0)return new Error("Malformed OpenSSH private key");let P=Ne(e,e._pos);if(P===void 0)return new Error("Malformed OpenSSH private key");let q=Ne(e,e._pos);if(q===void 0)return new Error("Malformed OpenSSH private key");let C=Ne(e,e._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");let $=Ne(e,e._pos);if($===void 0)return new Error("Malformed OpenSSH private key");p=Oi(x,P,q,C),A=Mi(x,P,q,C),h=Ff(x,P,q,C,$),f="sha1";break}case"ssh-ed25519":{if(!wa)return new Error(`Unsupported OpenSSH private key type: ${E}`);let x=Ne(e,e._pos);if(x===void 0||x.length!==32)return new Error("Malformed OpenSSH private key");let P=Ne(e,e._pos);if(P===void 0||P.length!==64)return new Error("Malformed OpenSSH private key");p=Hf(x),A=Qf(x),h=m0(Er(P,0,32)),f=null;break}case"ecdsa-sha2-nistp256":f="sha256",l="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":f===void 0&&(f="sha384",l="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(f===void 0&&(f="sha512",l="1.3.132.0.35"),!Ia(e,1))return new Error("Malformed OpenSSH private key");let x=Ne(e,e._pos);if(x===void 0)return new Error("Malformed OpenSSH private key");let P=Ne(e,e._pos);if(P===void 0)return new Error("Malformed OpenSSH private key");p=Ca(l,x),A=ka(l,x),h=g0(l,x,P);break}default:return new Error(`Unsupported OpenSSH private key type: ${E}`)}let b=Ne(e,e._pos,!0);if(b===void 0)return new Error("Malformed OpenSSH private key");i.push(new Hs(E,b,h,p,A,f,s))}let u=0;for(c=e._pos;c<e.length;++c)if(e[c]!==++u%255)return new Error("Malformed OpenSSH private key");return i},n=/^-----BEGIN OPENSSH PRIVATE KEY-----(?:\r\n|\n)([\s\S]+)(?:\r\n|\n)-----END OPENSSH PRIVATE KEY-----$/;Hs.parse=(e,r)=>{let s=n.exec(e);if(s===null)return null;let i,o=Buffer.from(s[1],"base64");if(o.length<31)return new Error("Malformed OpenSSH private key");let a=o.utf8Slice(0,15);if(a!=="openssh-key-v1\0")return new Error(`Unsupported OpenSSH key magic: ${a}`);let c=Ne(o,15,!0);if(c===void 0)return new Error("Malformed OpenSSH private key");if(c!=="none"&&h0.indexOf(c)===-1)return new Error(`Unsupported cipher for OpenSSH key: ${c}`);let l=Ne(o,o._pos,!0);if(l===void 0)return new Error("Malformed OpenSSH private key");if(l!=="none"){if(c==="none")return new Error("Malformed OpenSSH private key");if(l!=="bcrypt")return new Error(`Unsupported kdf name for OpenSSH key: ${l}`);if(!r)return new Error("Encrypted private OpenSSH key detected, but no passphrase given")}else if(c!=="none")return new Error("Malformed OpenSSH private key");let u,f,h;c!=="none"&&(u=Bi[c]);let p=Ne(o,o._pos);if(p===void 0)return new Error("Malformed OpenSSH private key");if(p.length)switch(l){case"none":return new Error("Malformed OpenSSH private key");case"bcrypt":{let E=Ne(p,0);if(E===void 0||p._pos+4>p.length)return new Error("Malformed OpenSSH private key");let b=vi(p,p._pos),x=Buffer.allocUnsafe(u.keyLen+u.ivLen);if(d0(r,r.length,E,E.length,x,x.length,b)!==0)return new Error("Failed to generate information to decrypt key");f=Er(x,0,u.keyLen),h=Er(x,u.keyLen,x.length);break}}else if(l!=="none")return new Error("Malformed OpenSSH private key");if(o._pos+3>=o.length)return new Error("Malformed OpenSSH private key");let A=vi(o,o._pos);if(o._pos+=4,A>0){for(let b=0;b<A;++b){let x=Ne(o,o._pos);if(x===void 0)return new Error("Malformed OpenSSH private key");if(Ne(x,0,!0)===void 0)return new Error("Malformed OpenSSH private key")}let E=Ne(o,o._pos);if(E===void 0)return new Error("Malformed OpenSSH private key");if(f!==void 0){if(E.length<u.blockLen||E.length%u.blockLen!==0)return new Error("Malformed OpenSSH private key");try{let b={authTagLength:u.authLen},x=xa(u.sslName,f,h,b);if(x.setAutoPadding(!1),u.authLen>0){if(o.length-o._pos<u.authLen)return new Error("Malformed OpenSSH private key");x.setAuthTag(Er(o,o._pos,o._pos+=u.authLen))}E=Ri(x.update(E),x.final())}catch(b){return b}}if(o._pos!==o.length)return new Error("Malformed OpenSSH private key");i=t(E,A,f!==void 0)}else i=[];return i instanceof Error?i:i[0]}}function Qs(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[wn]=e,this[Pn]=r,this[rr]=s,this[Vn]=i,this[Vr]=o}Qs.prototype=Di;{let n=/^-----BEGIN (RSA|DSA|EC) PRIVATE KEY-----(?:\r\n|\n)((?:[^:]+:\s*[\S].*(?:\r\n|\n))*)([\s\S]+)(?:\r\n|\n)-----END (RSA|DSA|EC) PRIVATE KEY-----$/;Qs.parse=(t,e)=>{let r=n.exec(t);if(r===null)return null;let s=Buffer.from(r[3],"base64"),i=r[2],o=!1;if(i!==void 0){i=i.split(/\r\n|\n/g);for(let A=0;A<i.length;++A){let E=i[A],b=E.indexOf(":");if(E.slice(0,b)==="DEK-Info"){let x=E.slice(b+2);if(b=x.indexOf(","),b===-1)continue;let P=x.slice(0,b).toLowerCase();if(f0.indexOf(P)===-1)return new Error(`Cipher (${P}) not supported for encrypted OpenSSH private key`);let q=ba[P];if(!q)return new Error(`Cipher (${P}) not supported for encrypted OpenSSH private key`);let C=Buffer.from(x.slice(b+1),"hex");if(C.length!==q.ivLen)return new Error("Malformed encrypted OpenSSH private key");if(!e)return new Error("Encrypted OpenSSH private key detected, but no passphrase given");let $=Er(C,0,8),F=Ni("md5").update(e).update($).digest();for(;F.length<q.keyLen;)F=Ri(F,Ni("md5").update(F).update(e).update($).digest());F.length>q.keyLen&&(F=Er(F,0,q.keyLen));try{let v=xa(P,F,C);v.setAutoPadding(!1),s=Ri(v.update(s),v.final()),o=!0}catch(v){return v}}}}let a,c,l,u,f,h,p="Malformed OpenSSH private key";switch(o&&(p+=". Bad passphrase?"),r[1]){case"RSA":a="ssh-rsa",c=In("RSA PRIVATE",s);try{h=new Pe.Reader(s),h.readSequence(),h.readInt();let A=h.readString(Pe.Integer,!0);if(A===null)return new Error(p);let E=h.readString(Pe.Integer,!0);if(E===null)return new Error(p);l=Pi(A,E),u=Ti(A,E)}catch{return new Error(p)}f="sha1";break;case"DSA":a="ssh-dss",c=In("DSA PRIVATE",s);try{h=new Pe.Reader(s),h.readSequence(),h.readInt();let A=h.readString(Pe.Integer,!0);if(A===null)return new Error(p);let E=h.readString(Pe.Integer,!0);if(E===null)return new Error(p);let b=h.readString(Pe.Integer,!0);if(b===null)return new Error(p);let x=h.readString(Pe.Integer,!0);if(x===null)return new Error(p);l=Oi(A,E,b,x),u=Mi(A,E,b,x)}catch{return new Error(p)}f="sha1";break;case"EC":{let A,E,b;try{h=new Pe.Reader(s),h.readSequence(),h.readInt(),E=h.readString(Pe.OctetString,!0),h.readByte();let P=h.readLength();if(P!==null){if(h._offset=P,b=h.readOID(),b===null)return new Error(p);switch(b){case"1.2.840.10045.3.1.7":A="prime256v1",a="ecdsa-sha2-nistp256",f="sha256";break;case"1.3.132.0.34":A="secp384r1",a="ecdsa-sha2-nistp384",f="sha384";break;case"1.3.132.0.35":A="secp521r1",a="ecdsa-sha2-nistp521",f="sha512";break;default:return new Error(`Unsupported private key EC OID: ${b}`)}}else return new Error(p)}catch{return new Error(p)}c=In("EC PRIVATE",s);let x=A0(A,E);l=Ca(b,x),u=ka(b,x);break}}return new Qs(a,"",c,l,u,f,o)}}function Ws(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[wn]=e,this[Pn]=r,this[rr]=s,this[Vn]=i,this[Vr]=o}Ws.prototype=Di;{let n=Buffer.alloc(0),t=Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e=Buffer.from([0,0,0,0]),r=Buffer.from([0,0,0,1]),s=/^PuTTY-User-Key-File-2: (ssh-(?:rsa|dss))\r?\nEncryption: (aes256-cbc|none)\r?\nComment: ([^\r\n]*)\r?\nPublic-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-MAC: ([^\r\n]+)/;Ws.parse=(i,o)=>{let a=s.exec(i);if(a===null)return null;let c=a[2],l=c!=="none";if(l&&!o)return new Error("Encrypted PPK private key detected, but no passphrase given");let u=Buffer.from(a[5],"base64");if(l){let k=Bi[c],N=Ri(Ni("sha1").update(e).update(o).digest(),Ni("sha1").update(r).update(o).digest());N.length>k.keyLen&&(N=Er(N,0,k.keyLen));try{let R=xa(k.sslName,N,t);R.setAutoPadding(!1),u=Ri(R.update(u),R.final())}catch(R){return R}}let f=a[1],h=a[3],p=Buffer.from(a[4],"base64"),A=a[6],E=f.length,b=c.length,x=Buffer.byteLength(h),P=p.length,q=u.length,C=Buffer.allocUnsafe(4+E+4+b+4+x+4+P+4+q),$=0;if(Wt(C,E,$),C.utf8Write(f,$+=4,E),Wt(C,b,$+=E),C.utf8Write(c,$+=4,b),Wt(C,x,$+=b),C.utf8Write(h,$+=4,x),Wt(C,P,$+=x),C.set(p,$+=4),Wt(C,q,$+=P),C.set(u,$+4),o||(o=n),a0("sha1",Ni("sha1").update("putty-private-key-file-mac-key").update(o).digest()).update(C).digest("hex")!==A)return l?new Error("PPK private key integrity check failed -- bad passphrase?"):new Error("PPK private key integrity check failed");let v,_,w;switch(p._pos=0,Ia(p,1),f){case"ssh-rsa":{let k=Ne(p,p._pos);if(k===void 0)return new Error("Malformed PPK public key");let N=Ne(p,p._pos);if(N===void 0)return new Error("Malformed PPK public key");let R=Ne(u,0);if(R===void 0)return new Error("Malformed PPK private key");let ie=Ne(u,u._pos);if(ie===void 0)return new Error("Malformed PPK private key");let j=Ne(u,u._pos);if(j===void 0)return new Error("Malformed PPK private key");let X=Ne(u,u._pos);if(X===void 0)return new Error("Malformed PPK private key");v=Pi(N,k),_=Ti(N,k),w=$f(N,k,R,X,ie,j);break}case"ssh-dss":{let k=Ne(p,p._pos);if(k===void 0)return new Error("Malformed PPK public key");let N=Ne(p,p._pos);if(N===void 0)return new Error("Malformed PPK public key");let R=Ne(p,p._pos);if(R===void 0)return new Error("Malformed PPK public key");let ie=Ne(p,p._pos);if(ie===void 0)return new Error("Malformed PPK public key");let j=Ne(u,0);if(j===void 0)return new Error("Malformed PPK private key");v=Oi(k,N,R,ie),_=Mi(k,N,R,ie),w=Ff(k,N,R,ie,j);break}}return new Ws(f,h,w,v,_,"sha1",l)}}function Vs(n,t,e,r,s){this.type=n,this.comment=t,this[wn]=null,this[Pn]=e,this[rr]=r,this[Vn]=s,this[Vr]=!1}Vs.prototype=Di;{let n;wa?n=/^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/:n=/^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/,Vs.parse=t=>{let e=n.exec(t);if(e===null)return null;let r=e[1],s=e[2],i=Buffer.from(e[3],"base64"),o=e[4]||"",a=Ne(i,i._pos,!0);return a===void 0||a.indexOf(s)!==0?new Error("Malformed OpenSSH public key"):va(i,s,o,r)}}function qs(n,t,e,r,s){this.type=n,this.comment=t,this[wn]=null,this[Pn]=e,this[rr]=r,this[Vn]=s,this[Vr]=!1}qs.prototype=Di;{let n=/^---- BEGIN SSH2 PUBLIC KEY ----(?:\r?\n)((?:.{0,72}\r?\n)+)---- END SSH2 PUBLIC KEY ----$/,t=/^[A-Z0-9a-z/+=\r\n]+$/,e=/^([\x21-\x39\x3B-\x7E]{1,64}): ((?:[^\\]*\\\r?\n)*[^\r\n]+)\r?\n/gm,r=/\\\r?\n/g;qs.parse=s=>{let i=n.exec(s);if(i===null)return null;let o=i[1],a=0,c="";for(;i=e.exec(o);){let p=i[1],A=i[2].replace(r,"");if(A.length>1024)return e.lastIndex=0,new Error("Malformed RFC4716 public key");a=e.lastIndex,p.toLowerCase()==="comment"&&(c=A,c.length>1&&c.charCodeAt(0)===34&&c.charCodeAt(c.length-1)===34&&(c=c.slice(1,-1)))}let l=o.slice(a);if(!t.test(l))return new Error("Malformed RFC4716 public key");l=Buffer.from(l,"base64");let u=Ne(l,0,!0);if(u===void 0)return new Error("Malformed RFC4716 public key");let f=null,h=null;switch(u){case"ssh-rsa":{let p=Ne(l,l._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let A=Ne(l,l._pos);if(A===void 0)return new Error("Malformed RFC4716 public key");f=Pi(A,p),h=Ti(A,p);break}case"ssh-dss":{let p=Ne(l,l._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let A=Ne(l,l._pos);if(A===void 0)return new Error("Malformed RFC4716 public key");let E=Ne(l,l._pos);if(E===void 0)return new Error("Malformed RFC4716 public key");let b=Ne(l,l._pos);if(b===void 0)return new Error("Malformed RFC4716 public key");f=Oi(p,A,E,b),h=Mi(p,A,E,b);break}default:return new Error("Malformed RFC4716 public key")}return new qs(u,c,f,h,"sha1")}}function va(n,t,e,r){if(!Wf(t))return new Error(`Unsupported OpenSSH public key type: ${t}`);let s,i,o=null,a=null;switch(t){case"ssh-rsa":{let c=Ne(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");let l=Ne(n,n._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");o=Pi(l,c),a=Ti(l,c),s="sha1";break}case"ssh-dss":{let c=Ne(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");let l=Ne(n,n._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");let u=Ne(n,n._pos);if(u===void 0)return new Error("Malformed OpenSSH public key");let f=Ne(n,n._pos);if(f===void 0)return new Error("Malformed OpenSSH public key");o=Oi(c,l,u,f),a=Mi(c,l,u,f),s="sha1";break}case"ssh-ed25519":{let c=Ne(n,n._pos||0);if(c===void 0||c.length!==32)return new Error("Malformed OpenSSH public key");o=Hf(c),a=Qf(c),s=null;break}case"ecdsa-sha2-nistp256":s="sha256",i="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":s===void 0&&(s="sha384",i="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(s===void 0&&(s="sha512",i="1.3.132.0.35"),!Ia(n,1))return new Error("Malformed OpenSSH public key");let c=Ne(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");o=Ca(i,c),a=ka(i,c);break}default:return new Error(`Unsupported OpenSSH public key type: ${t}`)}return new Vs(r,e,o,a,s)}function Wf(n){switch(n){case"ssh-rsa":case"ssh-dss":case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":return!0;case"ssh-ed25519":if(wa)return!0;default:return!1}}function qf(n){return n?typeof n[Vr]=="boolean":!1}function Vf(n,t){if(qf(n))return n;let e;if(Buffer.isBuffer(n))e=n,n=n.utf8Slice(0,n.length).trim();else if(typeof n=="string")n=n.trim();else return new Error("Key data must be a Buffer or string");if(t!=null){if(typeof t=="string")t=Buffer.from(t);else if(!Buffer.isBuffer(t))return new Error("Passphrase must be a string or Buffer when supplied")}let r;if((r=Hs.parse(n,t))!==null||(r=Qs.parse(n,t))!==null||(r=Ws.parse(n,t))!==null||(r=Vs.parse(n))!==null||(r=qs.parse(n))!==null)return r;if(e){Fs.init(e,0);let s=Fs.readString(!0);s!==void 0&&(n=Fs.readRaw(),n!==void 0&&(r=va(n,s,"",s),r instanceof Error&&(r=null))),Fs.clear()}return r||new Error("Unsupported key format")}Kf.exports={isParsedKey:qf,isSupportedKeyType:Wf,parseDERKey:(n,t)=>va(n,t,"",t),parseKey:Vf}});var Oa=ut((Tx,nd)=>{"use strict";var{Socket:jf}=require("net"),{Duplex:Xf}=require("stream"),{resolve:y0}=require("path"),{readFile:zf}=require("fs"),{execFile:E0,spawn:S0}=require("child_process"),{isParsedKey:Gf,parseKey:Li}=ir(),{makeBufferParser:_0,readUInt32BE:Ta,writeUInt32BE:on,writeUInt32LE:Yf}=xn();function Ui(n){let t=!1;return(...e)=>{t||(t=!0,n(...e))}}function b0(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return n.copy(e,0),t.copy(e,n.length),e}function Ba(){}var x0=Buffer.alloc(0),Ct=_0(),$i=class{getIdentities(t){t(new Error("Missing getIdentities() implementation"))}sign(t,e,r,s){typeof r=="function"&&(s=r),s(new Error("Missing sign() implementation"))}},zr=class extends $i{constructor(t){super(),this.socketPath=t}getStream(t){t=Ui(t);let e=new jf;e.on("connect",()=>{t(null,e)}),e.on("close",r).on("end",r).on("error",r),e.connect(this.socketPath);function r(){try{e.destroy()}catch{}t(new Error("Failed to connect to agent"))}}getIdentities(t){t=Ui(t),this.getStream((e,r)=>{function s(o){if(r)try{r.destroy()}catch{}o||(o=new Error("Failed to retrieve identities from agent")),t(o)}if(e)return s(e);let i=new Ra(!0);i.on("error",s),i.pipe(r).pipe(i),r.on("close",s).on("end",s).on("error",s),i.getIdentities((o,a)=>{if(o)return s(o);try{r.destroy()}catch{}t(null,a)})})}sign(t,e,r,s){typeof r=="function"?(s=r,r=void 0):(typeof r!="object"||r===null)&&(r=void 0),s=Ui(s),this.getStream((i,o)=>{function a(l){if(o)try{o.destroy()}catch{}l||(l=new Error("Failed to sign data with agent")),s(l)}if(i)return a(i);let c=new Ra(!0);c.on("error",a),c.pipe(o).pipe(c),o.on("close",a).on("end",a).on("error",a),c.sign(t,e,r,(l,u)=>{if(l)return a(l);try{o.destroy()}catch{}s(null,u)})})}},Jf=(()=>{let o=y0(__dirname,"..","util/pagent.exe"),a={10:new Error("Invalid pagent.exe arguments"),11:new Error("Pageant is not running"),12:new Error("pagent.exe could not create an mmap"),13:new Error("pagent.exe could not set mode for stdin"),14:new Error("pagent.exe could not set mode for stdout"),15:new Error("pagent.exe did not get expected input payload")};function c(u){u.buffer=null,u.proc&&(u.proc.kill(),u.proc=void 0)}class l extends Xf{constructor(){super(),this.proc=void 0,this.buffer=null}_read(f){}_write(f,h,p){if(this.buffer===null)this.buffer=f;else{let x=Buffer.allocUnsafe(this.buffer.length+f.length);this.buffer.copy(x,0),f.copy(x,this.buffer.length),this.buffer=x}if(this.buffer.length<4)return p();let A=Ta(this.buffer,0);if(this.buffer.length-4<A)return p();if(f=this.buffer.slice(0,4+A),this.buffer.length>4+A)return p(new Error("Unexpected multiple agent requests"));this.buffer=null;let E,b=this.proc=S0(o,[f.length]);b.stdout.on("data",x=>{this.push(x)}),b.on("error",x=>{E=x,p(E)}),b.on("close",x=>{if(this.proc=void 0,!E){if(E=a[x])return p(E);p()}}),b.stdin.end(f)}_final(f){c(this),f()}_destroy(f,h){c(this),h()}}return class extends zr{getStream(f){f(null,new l)}}})(),Zf=(()=>{let n=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends zr{getStream(e){e=Ui(e);let r=this.socketPath,s=!1;zf(r,function i(o,a){if(o){if(s)return e(new Error("Invalid cygwin unix socket path"));E0("cygpath",["-w",r],(F,v,_)=>{if(F||v.length===0)return e(new Error("Invalid cygwin unix socket path"));s=!0,r=v.toString().replace(/[\r\n]/g,""),zf(r,i)});return}let c=n.exec(a.toString("ascii"));if(!c)return e(new Error("Malformed cygwin unix socket file"));let l,u=0,f=!1,h=[],p,A=Buffer.alloc(12),E=parseInt(c[1],10),b=c[2].replace(/-/g,""),x=Buffer.allocUnsafe(16);for(let F=0,v=0;v<32;++F,v+=2)x[F]=parseInt(b.substring(v,v+2),16);for(let F=0;F<16;F+=4)Yf(x,Ta(x,F),F);$();function P(){u=0,l="secret",p.write(x)}function q(F){if(u+=F.length,l==="secret"){u===16&&(u=0,l="creds",p.write(A));return}if(l==="creds"&&(f||h.push(F),u===12)){if(p.removeListener("connect",P),p.removeListener("data",q),p.removeListener("error",C),p.removeListener("end",C),p.removeListener("close",C),f)return e(null,p);f=!0,A=Buffer.concat(h),Yf(A,process.pid,0),p.on("error",()=>{}),p.destroy(),$()}}function C(){e(new Error("Problem negotiating cygwin unix socket security"))}function $(){p=new jf,p.on("connect",P),p.on("data",q),p.on("error",C),p.on("end",C),p.on("close",C),p.connect(E)}})}}})(),w0=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function ed(n){return process.platform==="win32"&&!w0.test(n)?n==="pageant"?new Jf:new Zf(n):new zr(n)}var Ra=(()=>{function l(_){let w;for(;_[P].length;){let k=_[P][0][f];if(k===void 0)break;_[P].shift(),w=_.push(k)}return w}let u=Symbol("Inbound Request Type"),f=Symbol("Inbound Request Response"),h=Symbol("Inbound Request Context");class p{constructor(w,k){this[u]=w,this[f]=void 0,this[h]=k}hasResponded(){return this[f]!==void 0}getType(){return this[u]}getContext(){return this[h]}}function A(_,w,k){return w[f]=k,l(_)}function E(_){if(_[C]=null,_[q]===0){let w=_[P];if(w&&w.length){_[P]=[];for(let k of w)k.cb(new Error("No reply from server"))}}try{_.end()}catch{}setImmediate(()=>{_[v]||_.emit("end"),_[F]||_.emit("close")})}function b(){this[F]=!0}function x(){this[v]=!0}let P=Symbol("Requests"),q=Symbol("Agent Protocol Role"),C=Symbol("Agent Protocol Buffer"),$=Symbol("Agent Protocol Current Message Length"),F=Symbol("Agent Protocol Closed"),v=Symbol("Agent Protocol Ended");return class extends Xf{constructor(w){super({autoDestroy:!0,emitClose:!1}),this[q]=w?0:1,this[P]=[],this[C]=null,this[$]=-1,this.once("end",x),this.once("close",b)}_read(w){}_write(w,k,N){this[C]===null?this[C]=w:this[C]=b0(this[C],w);let R=this[C],ie=R.length,j=0;for(;j<ie&&!(ie<5||(this[$]===-1&&(this[$]=Ta(R,j)),ie<4+this[$]));){let X=R[j+=4];if(++j,this[q]===0){if(this[P].length===0)return N(new Error("Received unexpected message from server"));let re=this[P].shift();switch(X){case 5:re.cb(new Error("Agent responded with failure"));break;case 12:{if(re.type!==11)return N(new Error("Agent responded with wrong message type"));Ct.init(R,j);let fe=Ct.readUInt32BE();if(fe===void 0)return Ct.clear(),N(new Error("Malformed agent response"));let H=[];for(let B=0;B<fe;++B){let D=Ct.readString();if(D===void 0)return Ct.clear(),N(new Error("Malformed agent response"));let z=Ct.readString(!0);if(z===void 0)return Ct.clear(),N(new Error("Malformed agent response"));D=Li(D),!(D instanceof Error)&&(D.comment=D.comment||z,H.push(D))}j=Ct.pos(),Ct.clear(),re.cb(null,H);break}case 14:{if(re.type!==13)return N(new Error("Agent responded with wrong message type"));Ct.init(R,j);let fe=Ct.readString();if(j=Ct.pos(),Ct.clear(),fe===void 0)return N(new Error("Malformed agent response"));if(Ct.init(fe,0),Ct.readString(!0),fe=Ct.readString(),Ct.clear(),fe===void 0)return N(new Error("Malformed OpenSSH signature format"));re.cb(null,fe);break}default:return N(new Error("Agent responded with unsupported message type"))}}else switch(X){case 11:{let re=new p(X);this[P].push(re),this.emit("identities",re);break}case 13:{Ct.init(R,j);let re=Ct.readString(),fe=Ct.readString(),H=Ct.readUInt32BE();if(j=Ct.pos(),Ct.clear(),H===void 0){let ne=new p(X);return this[P].push(ne),this.failureReply(ne)}if(re=Li(re),re instanceof Error){let ne=new p(X);return this[P].push(ne),this.failureReply(ne)}let B={hash:void 0},D;re.type==="ssh-rsa"&&(H&2?(D="rsa-sha2-256",B.hash="sha256"):H&4&&(D="rsa-sha2-512",B.hash="sha512")),D===void 0&&(D=re.type);let z=new p(X,D);this[P].push(z),this.emit("sign",z,re,fe,B);break}default:{let re=new p(X);this[P].push(re),this.failureReply(re)}}if(this[$]=-1,j===ie){this[C]=null;break}else this[C]=R=R.slice(j),ie=R.length,j=0}N()}_destroy(w,k){E(this),k()}_final(w){E(this),w()}sign(w,k,N,R){if(this[q]!==0)throw new Error("Client-only method called with server role");typeof N=="function"?(R=N,N=void 0):(typeof N!="object"||N===null)&&(N=void 0);let ie=0;if(w=Li(w),w instanceof Error)throw new Error("Invalid public key argument");if(w.type==="ssh-rsa"&&N)switch(N.hash){case"sha256":ie=2;break;case"sha512":ie=4;break}w=w.getPublicSSH();let j=13,X=w.length,re=k.length,fe=0,H=Buffer.allocUnsafe(9+X+4+re+4);return on(H,H.length-4,fe),H[fe+=4]=j,on(H,X,++fe),w.copy(H,fe+=4),on(H,re,fe+=X),k.copy(H,fe+=4),on(H,ie,fe+=re),typeof R!="function"&&(R=Ba),this[P].push({type:j,cb:R}),this.push(H)}getIdentities(w){if(this[q]!==0)throw new Error("Client-only method called with server role");let k=11,N=0,R=Buffer.allocUnsafe(5);return on(R,R.length-4,N),R[N+=4]=k,typeof w!="function"&&(w=Ba),this[P].push({type:k,cb:w}),this.push(R)}failureReply(w){if(this[q]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;let k=0,N=Buffer.allocUnsafe(5);return on(N,N.length-4,k),N[k+=4]=5,A(this,w,N)}getIdentitiesReply(w,k){if(this[q]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;if(w.getType()!==11)throw new Error("Invalid response to request");if(!Array.isArray(k))throw new Error("Keys argument must be an array");let N=4,R=[];for(let X=0;X<k.length;++X){let re=k[X];if(typeof re!="object"||re===null)throw new Error(`Invalid key entry: ${re}`);let fe,H;if(Gf(re))fe=re;else if(Gf(re.pubKey))fe=re.pubKey;else if(typeof re.pubKey!="object"||re.pubKey===null||({pubKey:fe,comment:H}=re.pubKey,fe=Li(fe),fe instanceof Error))continue;H=fe.comment||H,fe=fe.getPublicSSH(),N+=4+fe.length,H&&typeof H=="string"?H=Buffer.from(H):Buffer.isBuffer(H)||(H=x0),N+=4+H.length,R.push({pubKey:fe,comment:H})}let ie=0,j=Buffer.allocUnsafe(5+N);on(j,j.length-4,ie),j[ie+=4]=12,on(j,R.length,++ie),ie+=4;for(let X=0;X<R.length;++X){let{pubKey:re,comment:fe}=R[X];on(j,re.length,ie),re.copy(j,ie+=4),on(j,fe.length,ie+=re.length),ie+=4,fe.length&&(fe.copy(j,ie),ie+=fe.length)}return A(this,w,j)}signReply(w,k){if(this[q]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;if(w.getType()!==13)throw new Error("Invalid response to request");if(!Buffer.isBuffer(k))throw new Error("Signature argument must be a Buffer");if(k.length===0)throw new Error("Signature argument must be non-empty");let N=0,R=w.getContext(),ie=Buffer.byteLength(R),j=Buffer.allocUnsafe(13+ie+4+k.length);return on(j,j.length-4,N),j[N+=4]=14,on(j,4+ie+4+k.length,++N),on(j,ie,N+=4),j.utf8Write(R,N+=4,ie),on(j,k.length,N+=ie),k.copy(j,N+=4),A(this,w,j)}}})(),Na=Symbol("Agent"),Cn=Symbol("Agent Keys"),Kn=Symbol("Agent Keys Index"),Kr=Symbol("Agent Init Callbacks"),Pa=class{constructor(t){if(typeof t=="string")t=ed(t);else if(!td(t))throw new Error("Invalid agent argument");this[Na]=t,this[Cn]=null,this[Kn]=-1,this[Kr]=null}init(t){if(typeof t!="function"&&(t=Ba),this[Cn]===null)if(this[Kr]===null){this[Kr]=[t];let e=(...r)=>{process.nextTick(()=>{let s=this[Kr];this[Kr]=null;for(let i of s)i(...r)})};this[Na].getIdentities(Ui((r,s)=>{if(r)return e(r);if(!Array.isArray(s))return e(new Error("Agent implementation failed to provide keys"));let i=[];for(let o of s)o=Li(o),!(o instanceof Error)&&i.push(o);this[Cn]=i,this[Kn]=-1,e()}))}else this[Kr].push(t);else process.nextTick(t)}nextKey(){return this[Cn]===null||++this[Kn]>=this[Cn].length?!1:this[Cn][this[Kn]]}currentKey(){return this[Cn]===null||this[Kn]>=this[Cn].length?null:this[Cn][this[Kn]]}pos(){return this[Cn]===null||this[Kn]>=this[Cn].length?-1:this[Kn]}reset(){this[Kn]=-1}sign(...t){this[Na].sign(...t)}};function td(n){return n instanceof $i}nd.exports={AgentContext:Pa,AgentProtocol:Ra,BaseAgent:$i,createAgent:ed,CygwinAgent:Zf,isAgent:td,OpenSSHAgent:zr,PageantAgent:Jf}});var Fa=ut((Ox,rd)=>{"use strict";var{kMaxLength:I0}=require("buffer"),{createInflate:C0,constants:{DEFLATE:k0,INFLATE:v0,Z_DEFAULT_CHUNK:N0,Z_DEFAULT_COMPRESSION:B0,Z_DEFAULT_MEMLEVEL:R0,Z_DEFAULT_STRATEGY:P0,Z_DEFAULT_WINDOWBITS:T0,Z_PARTIAL_FLUSH:O0}}=require("zlib"),M0=C0()._handle.constructor;function D0(){throw new Error("Should not get here")}function L0(n,t,e){let r=this._owner,s=new Error(n);s.errno=t,s.code=e,r._err=s}function $a(n){n._handle&&(n._handle.close(),n._handle=null)}var Ks=class{constructor(t){let e=T0,r=B0,s=R0,i=P0,o=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=N0,this._maxOutputLength=I0,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new M0(t),this._handle._owner=this,this._handle.onerror=L0,this._handle.init(e,r,s,i,this._writeState,D0,o)}writeSync(t,e){let r=this._handle;if(!r)throw new Error("Invalid Zlib instance");let s=t.length,i=this._chunkSize-this._outOffset,o=0,a,c,l,u=0,f=this._writeState,h=this._outBuffer,p=this._outOffset,A=this._chunkSize;for(;;){if(r.writeSync(O0,t,o,s,h,p,i),this._err)throw this._err;a=f[0],c=f[1];let b=s-c,x=i-a;if(x>0){let P=p===0&&x===h.length?h:h.slice(p,p+x);if(p+=x,l?l.push===void 0?l=[l,P]:l.push(P):l=P,u+=P.byteLength,u>this._maxOutputLength)throw $a(this),new Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(x!==0)throw new Error("have should not go down");if((a===0||p>=A)&&(i=A,p=0,h=Buffer.allocUnsafe(A)),a===0)o+=b,s=c;else break}if(this._outBuffer=h,this._outOffset=p,u===0&&(l=Buffer.alloc(0)),e)return l.totalLen=u,l;if(l.push===void 0)return l;let E=Buffer.allocUnsafe(u);for(let b=0,x=0;b<l.length;++b){let P=l[b];E.set(P,x),x+=P.length}return E}},Ma=class{constructor(t){this.allocStart=0,this.allocStartKEX=0,this._protocol=t,this._zlib=new Ks(k0)}cleanup(){this._zlib&&$a(this._zlib)}alloc(t,e){return Buffer.allocUnsafe(t)}finalize(t,e){if(this._protocol._kexinit===void 0||e){let r=this._zlib.writeSync(t,!0),s=this._protocol._cipher.allocPacket(r.totalLen);if(r.push===void 0)s.set(r,5);else for(let i=0,o=5;i<r.length;++i){let a=r[i];s.set(a,o),o+=a.length}return s}return t}},Da=class{constructor(t){this.allocStart=5,this.allocStartKEX=5,this._protocol=t}cleanup(){}alloc(t,e){return this._protocol._kexinit===void 0||e?this._protocol._cipher.allocPacket(t):Buffer.allocUnsafe(t)}finalize(t,e){return t}},La=class{constructor(){this._zlib=new Ks(v0)}cleanup(){this._zlib&&$a(this._zlib)}read(t){return this._zlib.writeSync(t,!1)}},Ua=class{cleanup(){}read(t){return t}};rd.exports={PacketReader:Ua,PacketWriter:Da,ZlibPacketReader:La,ZlibPacketWriter:Ma}});var cd=ut((Mx,ad)=>{"use strict";var{bufferSlice:Ha,bufferParser:U,doFatalError:Et,sigSSHToASN1:id,writeUInt32BE:sd}=xn(),{CHANNEL_OPEN_FAILURE:U0,COMPAT:$0,MESSAGE:bt,TERMINAL_MODE:od}=qn(),{parseKey:F0}=ir(),H0=Array.from(Object.entries(od)).reduce((n,[t,e])=>({...n,[t]:e}),{});ad.exports={[bt.DISCONNECT]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readString(!0),s=U.readString();if(U.clear(),s===void 0)return Et(n,"Inbound: Malformed DISCONNECT packet");n._debug&&n._debug(`Inbound: Received DISCONNECT (${e}, "${r}")`);let i=n._handlers.DISCONNECT;i&&i(n,e,r)},[bt.IGNORE]:(n,t)=>{n._debug&&n._debug("Inbound: Received IGNORE")},[bt.UNIMPLEMENTED]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE();if(U.clear(),e===void 0)return Et(n,"Inbound: Malformed UNIMPLEMENTED packet");n._debug&&n._debug(`Inbound: Received UNIMPLEMENTED (seqno ${e})`)},[bt.DEBUG]:(n,t)=>{U.init(t,1);let e=U.readBool(),r=U.readString(!0),s=U.readString();if(U.clear(),s===void 0)return Et(n,"Inbound: Malformed DEBUG packet");n._debug&&n._debug("Inbound: Received DEBUG");let i=n._handlers.DEBUG;i&&i(n,e,r)},[bt.SERVICE_REQUEST]:(n,t)=>{U.init(t,1);let e=U.readString(!0);if(U.clear(),e===void 0)return Et(n,"Inbound: Malformed SERVICE_REQUEST packet");n._debug&&n._debug(`Inbound: Received SERVICE_REQUEST (${e})`);let r=n._handlers.SERVICE_REQUEST;r&&r(n,e)},[bt.SERVICE_ACCEPT]:(n,t)=>{U.init(t,1);let e=U.readString(!0);if(U.clear(),e===void 0)return Et(n,"Inbound: Malformed SERVICE_ACCEPT packet");n._debug&&n._debug(`Inbound: Received SERVICE_ACCEPT (${e})`);let r=n._handlers.SERVICE_ACCEPT;r&&r(n,e)},[bt.EXT_INFO]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r;if(e!==void 0){r=[];for(let i=0;i<e;++i){let o=U.readString(!0),a=U.readString();if(a!==void 0)if(o==="server-sig-algs"){let c=a.latin1Slice(0,a.length).split(",");r.push({name:o,algs:c});continue}else continue;r=void 0;break}}if(U.clear(),r===void 0)return Et(n,"Inbound: Malformed EXT_INFO packet");n._debug&&n._debug("Inbound: Received EXT_INFO");let s=n._handlers.EXT_INFO;s&&s(n,r)},[bt.USERAUTH_REQUEST]:(n,t)=>{U.init(t,1);let e=U.readString(!0),r=U.readString(!0),s=U.readString(!0),i,o;switch(s){case"none":i=null;break;case"password":{let c=U.readBool();if(c!==void 0&&(i=U.readString(!0),i!==void 0&&c)){let l=U.readString(!0);l!==void 0?i={oldPassword:i,newPassword:l}:i=void 0}break}case"publickey":{let c=U.readBool();if(c!==void 0){let l=U.readString(!0),u=l,f=U.readString(),h;switch(l){case"rsa-sha2-256":u="ssh-rsa",h="sha256";break;case"rsa-sha2-512":u="ssh-rsa",h="sha512";break}if(c){let p=U.pos(),A=U.readString();if(A!==void 0&&(A.length>4+l.length+4&&A.utf8Slice(4,4+l.length)===l&&(A=Ha(A,4+l.length+4)),A=id(A,u),A)){let E=n._kex.sessionID,b=Buffer.allocUnsafe(4+E.length+p);sd(b,E.length,0),b.set(E,4),b.set(new Uint8Array(t.buffer,t.byteOffset,p),4+E.length),i={keyAlgo:u,key:f,signature:A,blob:b,hashAlgo:h}}}else i={keyAlgo:u,key:f,hashAlgo:h},o="publickey -- check"}break}case"hostbased":{let c=U.readString(!0),l=c,u=U.readString(),f=U.readString(!0),h=U.readString(!0),p;switch(c){case"rsa-sha2-256":l="ssh-rsa",p="sha256";break;case"rsa-sha2-512":l="ssh-rsa",p="sha512";break}let A=U.pos(),E=U.readString();if(E!==void 0&&(E.length>4+c.length+4&&E.utf8Slice(4,4+c.length)===c&&(E=Ha(E,4+c.length+4)),E=id(E,l),E!==void 0)){let b=n._kex.sessionID,x=Buffer.allocUnsafe(4+b.length+A);sd(x,b.length,0),x.set(b,4),x.set(new Uint8Array(t.buffer,t.byteOffset,A),4+b.length),i={keyAlgo:l,key:u,signature:E,blob:x,localHostname:f,localUsername:h,hashAlgo:p}}break}case"keyboard-interactive":U.skipString(),i=U.readList();break;default:s!==void 0&&(i=U.readRaw())}if(U.clear(),i===void 0)return Et(n,"Inbound: Malformed USERAUTH_REQUEST packet");o===void 0&&(o=s),n._authsQueue.push(s),n._debug&&n._debug(`Inbound: Received USERAUTH_REQUEST (${o})`);let a=n._handlers.USERAUTH_REQUEST;a&&a(n,e,r,s,i)},[bt.USERAUTH_FAILURE]:(n,t)=>{U.init(t,1);let e=U.readList(),r=U.readBool();if(U.clear(),r===void 0)return Et(n,"Inbound: Malformed USERAUTH_FAILURE packet");n._debug&&n._debug(`Inbound: Received USERAUTH_FAILURE (${e})`),n._authsQueue.shift();let s=n._handlers.USERAUTH_FAILURE;s&&s(n,e,r)},[bt.USERAUTH_SUCCESS]:(n,t)=>{n._debug&&n._debug("Inbound: Received USERAUTH_SUCCESS"),n._authsQueue.shift();let e=n._handlers.USERAUTH_SUCCESS;e&&e(n)},[bt.USERAUTH_BANNER]:(n,t)=>{U.init(t,1);let e=U.readString(!0),r=U.readString();if(U.clear(),r===void 0)return Et(n,"Inbound: Malformed USERAUTH_BANNER packet");n._debug&&n._debug("Inbound: Received USERAUTH_BANNER");let s=n._handlers.USERAUTH_BANNER;s&&s(n,e)},60:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 60 without auth");return}switch(n._authsQueue[0]){case"password":{U.init(t,1);let e=U.readString(!0),r=U.readString();if(U.clear(),r===void 0)return Et(n,"Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet");n._debug&&n._debug("Inbound: Received USERAUTH_PASSWD_CHANGEREQ");let s=n._handlers.USERAUTH_PASSWD_CHANGEREQ;s&&s(n,e);break}case"publickey":{U.init(t,1);let e=U.readString(!0),r=U.readString();if(U.clear(),r===void 0)return Et(n,"Inbound: Malformed USERAUTH_PK_OK packet");n._debug&&n._debug("Inbound: Received USERAUTH_PK_OK"),n._authsQueue.shift();let s=n._handlers.USERAUTH_PK_OK;s&&s(n,e,r);break}case"keyboard-interactive":{U.init(t,1);let e=U.readString(!0),r=U.readString(!0);U.readString();let s=U.readUInt32BE(),i;if(s!==void 0){i=new Array(s);let a;for(a=0;a<s;++a){let c=U.readString(!0),l=U.readBool();if(l===void 0)break;i[a]={prompt:c,echo:l}}a!==s&&(i=void 0)}if(U.clear(),i===void 0)return Et(n,"Inbound: Malformed USERAUTH_INFO_REQUEST packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_REQUEST");let o=n._handlers.USERAUTH_INFO_REQUEST;o&&o(n,e,r,i);break}default:n._debug&&n._debug("Inbound: Received unexpected payload type 60")}},61:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 61 without auth");return}if(n._authsQueue[0]!=="keyboard-interactive")return Et(n,"Inbound: Received unexpected payload type 61");U.init(t,1);let e=U.readUInt32BE(),r;if(e!==void 0){r=new Array(e);let i;for(i=0;i<e;++i){let o=U.readString(!0);if(o===void 0)break;r[i]=o}i!==e&&(r=void 0)}if(U.clear(),r===void 0)return Et(n,"Inbound: Malformed USERAUTH_INFO_RESPONSE packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_RESPONSE");let s=n._handlers.USERAUTH_INFO_RESPONSE;s&&s(n,r)},[bt.GLOBAL_REQUEST]:(n,t)=>{U.init(t,1);let e=U.readString(!0),r=U.readBool(),s;if(r!==void 0)switch(e){case"tcpip-forward":case"cancel-tcpip-forward":{let o=U.readString(!0),a=U.readUInt32BE();a!==void 0&&(s={bindAddr:o,bindPort:a});break}case"streamlocal-forward@openssh.com":case"cancel-streamlocal-forward@openssh.com":{let o=U.readString(!0);o!==void 0&&(s={socketPath:o});break}case"no-more-sessions@openssh.com":s=null;break;case"hostkeys-00@openssh.com":{for(s=[];U.avail()>0;){let o=U.readString();if(o===void 0){s=void 0;break}let a=F0(o);a instanceof Error||s.push(a)}break}default:s=U.readRaw()}if(U.clear(),s===void 0)return Et(n,"Inbound: Malformed GLOBAL_REQUEST packet");n._debug&&n._debug(`Inbound: GLOBAL_REQUEST (${e})`);let i=n._handlers.GLOBAL_REQUEST;i?i(n,e,r,s):n.requestFailure()},[bt.REQUEST_SUCCESS]:(n,t)=>{let e=t.length>1?Ha(t,1):null;n._debug&&n._debug("Inbound: REQUEST_SUCCESS");let r=n._handlers.REQUEST_SUCCESS;r&&r(n,e)},[bt.REQUEST_FAILURE]:(n,t)=>{n._debug&&n._debug("Inbound: Received REQUEST_FAILURE");let e=n._handlers.REQUEST_FAILURE;e&&e(n)},[bt.CHANNEL_OPEN]:(n,t)=>{U.init(t,1);let e=U.readString(!0),r=U.readUInt32BE(),s=U.readUInt32BE(),i=U.readUInt32BE(),o;switch(e){case"forwarded-tcpip":case"direct-tcpip":{let c=U.readString(!0),l=U.readUInt32BE(),u=U.readString(!0),f=U.readUInt32BE();f!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{destIP:c,destPort:l,srcIP:u,srcPort:f}});break}case"forwarded-streamlocal@openssh.com":case"direct-streamlocal@openssh.com":{let c=U.readString(!0);c!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{socketPath:c}});break}case"x11":{let c=U.readString(!0),l=U.readUInt32BE();l!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{srcIP:c,srcPort:l}});break}default:o={type:e,sender:r,window:s,packetSize:i,data:{}}}if(U.clear(),o===void 0)return Et(n,"Inbound: Malformed CHANNEL_OPEN packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN (s:${r}, ${e})`);let a=n._handlers.CHANNEL_OPEN;a?a(n,o):n.channelOpenFail(o.sender,U0.ADMINISTRATIVELY_PROHIBITED,"","")},[bt.CHANNEL_OPEN_CONFIRMATION]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readUInt32BE(),s=U.readUInt32BE(),i=U.readUInt32BE(),o=U.avail()?U.readRaw():void 0;if(U.clear(),i===void 0)return Et(n,"Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_CONFIRMATION (r:${e}, s:${r})`);let a=n._handlers.CHANNEL_OPEN_CONFIRMATION;a&&a(n,{recipient:e,sender:r,window:s,packetSize:i,data:o})},[bt.CHANNEL_OPEN_FAILURE]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readUInt32BE(),s=U.readString(!0),i=U.readString();if(U.clear(),i===void 0)return Et(n,"Inbound: Malformed CHANNEL_OPEN_FAILURE packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${e})`);let o=n._handlers.CHANNEL_OPEN_FAILURE;o&&o(n,e,r,s)},[bt.CHANNEL_WINDOW_ADJUST]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readUInt32BE();if(U.clear(),r===void 0)return Et(n,"Inbound: Malformed CHANNEL_WINDOW_ADJUST packet");n._debug&&n._debug(`Inbound: CHANNEL_WINDOW_ADJUST (r:${e}, ${r})`);let s=n._handlers.CHANNEL_WINDOW_ADJUST;s&&s(n,e,r)},[bt.CHANNEL_DATA]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readString();if(U.clear(),r===void 0)return Et(n,"Inbound: Malformed CHANNEL_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_DATA (r:${e}, ${r.length})`);let s=n._handlers.CHANNEL_DATA;s&&s(n,e,r)},[bt.CHANNEL_EXTENDED_DATA]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readUInt32BE(),s=U.readString();if(U.clear(),s===void 0)return Et(n,"Inbound: Malformed CHANNEL_EXTENDED_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_EXTENDED_DATA (r:${e}, ${s.length})`);let i=n._handlers.CHANNEL_EXTENDED_DATA;i&&i(n,e,s,r)},[bt.CHANNEL_EOF]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE();if(U.clear(),e===void 0)return Et(n,"Inbound: Malformed CHANNEL_EOF packet");n._debug&&n._debug(`Inbound: CHANNEL_EOF (r:${e})`);let r=n._handlers.CHANNEL_EOF;r&&r(n,e)},[bt.CHANNEL_CLOSE]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE();if(U.clear(),e===void 0)return Et(n,"Inbound: Malformed CHANNEL_CLOSE packet");n._debug&&n._debug(`Inbound: CHANNEL_CLOSE (r:${e})`);let r=n._handlers.CHANNEL_CLOSE;r&&r(n,e)},[bt.CHANNEL_REQUEST]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readString(!0),s=U.readBool(),i;if(s!==void 0)switch(r){case"exit-status":i=U.readUInt32BE(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"exit-signal":{let a,c;if(n._compatFlags&$0.OLD_EXIT){let u=U.readUInt32BE();switch(u){case 1:a="HUP";break;case 2:a="INT";break;case 3:a="QUIT";break;case 6:a="ABRT";break;case 9:a="KILL";break;case 14:a="ALRM";break;case 15:a="TERM";break;default:u!==void 0&&(a=`UNKNOWN (${u})`)}c=!1}else a=U.readString(!0),c=U.readBool(),c===void 0&&(a=void 0);let l=U.readString(!0);U.skipString()!==void 0&&(i={signal:a,coreDumped:c,errorMessage:l}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a})`);break}case"pty-req":{let a=U.readString(!0),c=U.readUInt32BE(),l=U.readUInt32BE(),u=U.readUInt32BE(),f=U.readUInt32BE(),h=U.readString();if(h!==void 0){U.init(h,1);let p={};for(;U.avail();){let A=U.readByte();if(A===od.TTY_OP_END)break;let E=H0[A],b=U.readUInt32BE();if(A===void 0||E===void 0||b===void 0){p=void 0;break}p[E]=b}p!==void 0&&(i={term:a,cols:c,rows:l,width:u,height:f,modes:p})}n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"window-change":{let a=U.readUInt32BE(),c=U.readUInt32BE(),l=U.readUInt32BE(),u=U.readUInt32BE();u!==void 0&&(i={cols:a,rows:c,width:l,height:u}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"x11-req":{let a=U.readBool(),c=U.readString(!0),l=U.readString(),u=U.readUInt32BE();u!==void 0&&(i={single:a,protocol:c,cookie:l,screen:u}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"env":{let a=U.readString(!0),c=U.readString(!0);c!==void 0&&(i={name:a,value:c}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a}=${c})`);break}case"shell":i=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;case"exec":i=U.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"subsystem":i=U.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"signal":i=U.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"xon-xoff":i=U.readBool(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"auth-agent-req@openssh.com":i=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;default:i=U.avail()?U.readRaw():null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`)}if(U.clear(),i===void 0)return Et(n,"Inbound: Malformed CHANNEL_REQUEST packet");let o=n._handlers.CHANNEL_REQUEST;o&&o(n,e,r,s,i)},[bt.CHANNEL_SUCCESS]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE();if(U.clear(),e===void 0)return Et(n,"Inbound: Malformed CHANNEL_SUCCESS packet");n._debug&&n._debug(`Inbound: CHANNEL_SUCCESS (r:${e})`);let r=n._handlers.CHANNEL_SUCCESS;r&&r(n,e)},[bt.CHANNEL_FAILURE]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE();if(U.clear(),e===void 0)return Et(n,"Inbound: Malformed CHANNEL_FAILURE packet");n._debug&&n._debug(`Inbound: CHANNEL_FAILURE (r:${e})`);let r=n._handlers.CHANNEL_FAILURE;r&&r(n,e)}}});var zs=ut((Dx,ld)=>{"use strict";var Qa=new Array(256);[Gs().HANDLERS,cd()].forEach(n=>{for(let[t,e]of Object.entries(n))t=+t,isFinite(t)&&t>=0&&t<Qa.length&&(Qa[t]=e)});ld.exports=Qa});var Gs=ut((Ux,Ed)=>{"use strict";var{createDiffieHellman:Q0,createDiffieHellmanGroup:W0,createECDH:q0,createHash:qa,createPublicKey:V0,diffieHellman:K0,generateKeyPairSync:z0,randomFillSync:G0}=require("crypto"),{Ber:ud}=bi(),{COMPAT:Va,curve25519Supported:Y0,DEFAULT_KEX:fd,DEFAULT_SERVER_HOST_KEY:dd,DEFAULT_CIPHER:Ys,DEFAULT_MAC:js,DEFAULT_COMPRESSION:Xs,DISCONNECT_REASON:je,MESSAGE:gt}=qn(),{CIPHER_INFO:jr,createCipher:j0,createDecipher:X0,MAC_INFO:hd}=tr(),{parseDERKey:J0}=ir(),{bufferFill:Z0,bufferParser:Ye,convertSignature:eg,doFatalError:Xe,FastBuffer:tg,sigSSHToASN1:ng,writeUInt32BE:qt}=xn(),{PacketReader:pd,PacketWriter:md,ZlibPacketReader:Js,ZlibPacketWriter:Zs}=Fa(),Gr,rg=2048,ig=8192,sg=Buffer.alloc(0);function gd(n){let t;if(n._compatFlags&Va.BAD_DHGEX){let e=n._offer.lists.kex,r=e.array,s=!1;for(let i=0;i<r.length;++i)r[i].includes("group-exchange")&&(s||(s=!0,r=r.slice()),r.splice(i--,1));if(s){let i=17+n._offer.totalSize+1+4,o=Buffer.from(r.join(","));i-=e.buffer.length-o.length;let a=n._offer.lists.all,c=new Uint8Array(a.buffer,a.byteOffset+4+e.buffer.length,a.length-(4+e.buffer.length));t=Buffer.allocUnsafe(i),qt(t,o.length,17),t.set(o,21),t.set(c,21+o.length)}}t===void 0&&(t=Buffer.allocUnsafe(17+n._offer.totalSize+1+4),n._offer.copyAllTo(t,17)),n._debug&&n._debug("Outbound: Sending KEXINIT"),t[0]=gt.KEXINIT,G0(t,1,16),Z0(t,0,t.length-5),n._kexinit=t,n._packetRW.write.allocStart=0;{let e=n._packetRW.write.allocStartKEX,r=n._packetRW.write.alloc(t.length,!0);r.set(t,e),n._cipher.encrypt(n._packetRW.write.finalize(r,!0))}}function Ad(n,t){let e={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},sc:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0}};if(Ye.init(t,17),(e.kex=Ye.readList())===void 0||(e.serverHostKey=Ye.readList())===void 0||(e.cs.cipher=Ye.readList())===void 0||(e.sc.cipher=Ye.readList())===void 0||(e.cs.mac=Ye.readList())===void 0||(e.sc.mac=Ye.readList())===void 0||(e.cs.compress=Ye.readList())===void 0||(e.sc.compress=Ye.readList())===void 0||(e.cs.lang=Ye.readList())===void 0||(e.sc.lang=Ye.readList())===void 0)return Ye.clear(),Xe(n,"Received malformed KEXINIT","handshake",je.KEY_EXCHANGE_FAILED);let r=Ye.pos(),s=r<t.length&&t[r]===1;Ye.clear();let i=n._offer,o=e,a=i.lists.kex.array;if(n._compatFlags&Va.BAD_DHGEX){let C=!1;for(let $=0;$<a.length;++$)a[$].indexOf("group-exchange")!==-1&&(C||(C=!0,a=a.slice()),a.splice($--,1))}let c,l,u,f=n._debug;f&&f("Inbound: Handshake in progress"),f&&f(`Handshake: (local) KEX method: ${a}`),f&&f(`Handshake: (remote) KEX method: ${o.kex}`);let h;if(n._server?(l=a,c=o.kex,h=c.indexOf("ext-info-c")!==-1):(l=o.kex,c=a,h=l.indexOf("ext-info-s")!==-1),n._strictMode===void 0&&(n._server?n._strictMode=c.indexOf("kex-strict-c-v00@openssh.com")!==-1:n._strictMode=l.indexOf("kex-strict-s-v00@openssh.com")!==-1,n._strictMode&&(f&&f("Handshake: strict KEX mode enabled"),n._decipher.inSeqno!==1)))return f&&f("Handshake: KEXINIT not first packet in strict KEX mode"),Xe(n,"Handshake failed: KEXINIT not first packet in strict KEX mode","handshake",je.KEY_EXCHANGE_FAILED);for(u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f("Handshake: no matching key exchange algorithm"),Xe(n,"Handshake failed: no matching key exchange algorithm","handshake",je.KEY_EXCHANGE_FAILED);e.kex=c[u],f&&f(`Handshake: KEX algorithm: ${c[u]}`),s&&(!o.kex.length||c[u]!==o.kex[0])&&(n._skipNextInboundPacket=!0);let p=i.lists.serverHostKey.array;for(f&&f(`Handshake: (local) Host key format: ${p}`),f&&f(`Handshake: (remote) Host key format: ${o.serverHostKey}`),n._server?(l=p,c=o.serverHostKey):(l=o.serverHostKey,c=p),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f("Handshake: No matching host key format"),Xe(n,"Handshake failed: no matching host key format","handshake",je.KEY_EXCHANGE_FAILED);e.serverHostKey=c[u],f&&f(`Handshake: Host key format: ${c[u]}`);let A=i.lists.cs.cipher.array;for(f&&f(`Handshake: (local) C->S cipher: ${A}`),f&&f(`Handshake: (remote) C->S cipher: ${o.cs.cipher}`),n._server?(l=A,c=o.cs.cipher):(l=o.cs.cipher,c=A),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f("Handshake: No matching C->S cipher"),Xe(n,"Handshake failed: no matching C->S cipher","handshake",je.KEY_EXCHANGE_FAILED);e.cs.cipher=c[u],f&&f(`Handshake: C->S Cipher: ${c[u]}`);let E=i.lists.sc.cipher.array;for(f&&f(`Handshake: (local) S->C cipher: ${E}`),f&&f(`Handshake: (remote) S->C cipher: ${o.sc.cipher}`),n._server?(l=E,c=o.sc.cipher):(l=o.sc.cipher,c=E),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f("Handshake: No matching S->C cipher"),Xe(n,"Handshake failed: no matching S->C cipher","handshake",je.KEY_EXCHANGE_FAILED);e.sc.cipher=c[u],f&&f(`Handshake: S->C cipher: ${c[u]}`);let b=i.lists.cs.mac.array;if(f&&f(`Handshake: (local) C->S MAC: ${b}`),f&&f(`Handshake: (remote) C->S MAC: ${o.cs.mac}`),jr[e.cs.cipher].authLen>0)e.cs.mac="",f&&f("Handshake: C->S MAC: <implicit>");else{for(n._server?(l=b,c=o.cs.mac):(l=o.cs.mac,c=b),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f("Handshake: No matching C->S MAC"),Xe(n,"Handshake failed: no matching C->S MAC","handshake",je.KEY_EXCHANGE_FAILED);e.cs.mac=c[u],f&&f(`Handshake: C->S MAC: ${c[u]}`)}let x=i.lists.sc.mac.array;if(f&&f(`Handshake: (local) S->C MAC: ${x}`),f&&f(`Handshake: (remote) S->C MAC: ${o.sc.mac}`),jr[e.sc.cipher].authLen>0)e.sc.mac="",f&&f("Handshake: S->C MAC: <implicit>");else{for(n._server?(l=x,c=o.sc.mac):(l=o.sc.mac,c=x),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f("Handshake: No matching S->C MAC"),Xe(n,"Handshake failed: no matching S->C MAC","handshake",je.KEY_EXCHANGE_FAILED);e.sc.mac=c[u],f&&f(`Handshake: S->C MAC: ${c[u]}`)}let P=i.lists.cs.compress.array;for(f&&f(`Handshake: (local) C->S compression: ${P}`),f&&f(`Handshake: (remote) C->S compression: ${o.cs.compress}`),n._server?(l=P,c=o.cs.compress):(l=o.cs.compress,c=P),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f("Handshake: No matching C->S compression"),Xe(n,"Handshake failed: no matching C->S compression","handshake",je.KEY_EXCHANGE_FAILED);e.cs.compress=c[u],f&&f(`Handshake: C->S compression: ${c[u]}`);let q=i.lists.sc.compress.array;for(f&&f(`Handshake: (local) S->C compression: ${q}`),f&&f(`Handshake: (remote) S->C compression: ${o.sc.compress}`),n._server?(l=q,c=o.sc.compress):(l=o.sc.compress,c=q),u=0;u<c.length&&l.indexOf(c[u])===-1;++u);if(u===c.length)return f&&f("Handshake: No matching S->C compression"),Xe(n,"Handshake failed: no matching S->C compression","handshake",je.KEY_EXCHANGE_FAILED);e.sc.compress=c[u],f&&f(`Handshake: S->C compression: ${c[u]}`),e.cs.lang="",e.sc.lang="",n._kex&&(n._kexinit||gd(n),n._decipher._onPayload=yd.bind(n,{firstPacket:!1})),n._kex=og(e,n,t),n._kex.remoteExtInfoEnabled=h,n._kex.start()}var og=(()=>{function n(o){let a=0,c=o.length;for(;o[a]===0;)++a,--c;let l;return o[a]&128?(l=Buffer.allocUnsafe(1+c),l[0]=0,o.copy(l,1,a),o=l):c!==o.length&&(l=Buffer.allocUnsafe(c),o.copy(l,0,a),o=l),o}class t{constructor(a,c,l){this._protocol=c,this.sessionID=c._kex?c._kex.sessionID:void 0,this.negotiated=a,this.remoteExtInfoEnabled=!1,this._step=1,this._public=null,this._dh=null,this._sentNEWKEYS=!1,this._receivedNEWKEYS=!1,this._finished=!1,this._hostVerified=!1,this._kexinit=c._kexinit,this._remoteKexinit=l,this._identRaw=c._identRaw,this._remoteIdentRaw=c._remoteIdentRaw,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0}finish(a){if(this._finished)return!1;this._finished=!0;let c=this._protocol._server,l=this.negotiated,u=this.convertPublicKey(this._dhData),f=this.computeSecret(this._dhData);if(f instanceof Error)return f.message=`Error while computing DH secret (${this.type}): ${f.message}`,f.level="handshake",Xe(this._protocol,f,je.KEY_EXCHANGE_FAILED);let h=qa(this.hashName);Tn(h,c?this._remoteIdentRaw:this._identRaw),Tn(h,c?this._identRaw:this._remoteIdentRaw),Tn(h,c?this._remoteKexinit:this._kexinit),Tn(h,c?this._kexinit:this._remoteKexinit);let p=c?this._hostKey.getPublicSSH():this._hostKey;if(Tn(h,p),this.type==="groupex"){let q=this.getDHParams(),C=Buffer.allocUnsafe(4);qt(C,this._minBits,0),h.update(C),qt(C,this._prefBits,0),h.update(C),qt(C,this._maxBits,0),h.update(C),Tn(h,q.prime),Tn(h,q.generator)}Tn(h,c?u:this.getPublicKey());let A=c?this.getPublicKey():u;Tn(h,A),Tn(h,f);let E=h.digest();if(c){let q;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":q="sha256";break;case"rsa-sha2-512":q="sha512";break}this._protocol._debug&&this._protocol._debug("Generating signature ...");let C=this._hostKey.sign(E,q);if(C instanceof Error)return Xe(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${C.message}`,"handshake",je.KEY_EXCHANGE_FAILED);if(C=eg(C,this._hostKey.type),C===!1)return Xe(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,"handshake",je.KEY_EXCHANGE_FAILED);let $=this.negotiated.serverHostKey,F=Buffer.byteLength($),v=4+F+4+C.length,_=this._protocol._packetRW.write.allocStartKEX,w=this._protocol._packetRW.write.alloc(5+p.length+4+A.length+4+v,!0);if(w[_]=gt.KEXDH_REPLY,qt(w,p.length,++_),w.set(p,_+=4),qt(w,A.length,_+=p.length),w.set(A,_+=4),qt(w,v,_+=A.length),qt(w,F,_+=4),w.utf8Write($,_+=4,F),qt(w,C.length,_+=F),w.set(C,_+=4),this._protocol._debug){let k;switch(this.type){case"group":k="KEXDH_REPLY";break;case"groupex":k="KEXDH_GEX_REPLY";break;default:k="KEXECDH_REPLY"}this._protocol._debug(`Outbound: Sending ${k}`)}this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(w,!0))}else{Ye.init(this._sig,0);let q=Ye.readString(!0);if(!q)return Xe(this._protocol,"Malformed packet while reading signature","handshake",je.KEY_EXCHANGE_FAILED);if(q!==l.serverHostKey)return Xe(this._protocol,`Wrong signature type: ${q}, expected: ${l.serverHostKey}`,"handshake",je.KEY_EXCHANGE_FAILED);let C=Ye.readString();if(Ye.clear(),C===void 0)return Xe(this._protocol,"Malformed packet while reading signature","handshake",je.KEY_EXCHANGE_FAILED);if(!(C=ng(C,q)))return Xe(this._protocol,"Malformed signature","handshake",je.KEY_EXCHANGE_FAILED);let $;{Ye.init(this._hostKey,0);let _=Ye.readString(!0),w=this._hostKey.slice(Ye.pos());if(Ye.clear(),$=J0(w,_),$ instanceof Error)return $.level="handshake",Xe(this._protocol,$,je.KEY_EXCHANGE_FAILED)}let F;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":F="sha256";break;case"rsa-sha2-512":F="sha512";break}this._protocol._debug&&this._protocol._debug("Verifying signature ...");let v=$.verify(E,C,F);if(v!==!0)return v instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${v.stack}`):this._protocol._debug&&this._protocol._debug("Signature verification failed"),Xe(this._protocol,"Handshake failed: signature verification failed","handshake",je.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Verified signature")}(c||!a)&&eo(this);let b,x,P=q=>{if(b)return eo(this),b.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=j0(b),this._protocol._packetRW.write=x,b=void 0,x=void 0,this._protocol._onHandshakeComplete(l),!1;this.sessionID||(this.sessionID=E);{let re=Buffer.allocUnsafe(4+f.length);qt(re,f.length,0),re.set(f,4),f=re}let C=jr[l.cs.cipher],$=jr[l.sc.cipher],F=Yr(C.ivLen,this.hashName,f,E,this.sessionID,"A"),v=Yr($.ivLen,this.hashName,f,E,this.sessionID,"B"),_=Yr(C.keyLen,this.hashName,f,E,this.sessionID,"C"),w=Yr($.keyLen,this.hashName,f,E,this.sessionID,"D"),k,N;C.authLen||(k=hd[l.cs.mac],N=Yr(k.len,this.hashName,f,E,this.sessionID,"E"));let R,ie;$.authLen||(R=hd[l.sc.mac],ie=Yr(R.len,this.hashName,f,E,this.sessionID,"F"));let j={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:c?C:$,decipherIV:c?F:v,decipherKey:c?_:w,macInfo:c?k:R,macKey:c?N:ie},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:c?$:C,cipherIV:c?v:F,cipherKey:c?w:_,macInfo:c?R:k,macKey:c?ie:N}};this._protocol._decipher.free(),b=j,this._protocol._decipher=X0(j);let X={read:void 0,write:void 0};switch(l.cs.compress){case"zlib":c?X.read=new Js:X.write=new Zs(this._protocol);break;case"zlib@openssh.com":if(this._protocol._authenticated){c?X.read=new Js:X.write=new Zs(this._protocol);break}default:c?X.read=new pd:X.write=new md(this._protocol)}switch(l.sc.compress){case"zlib":c?X.write=new Zs(this._protocol):X.read=new Js;break;case"zlib@openssh.com":if(this._protocol._authenticated){c?X.write=new Zs(this._protocol):X.read=new Js;break}default:c?X.write=new md(this._protocol):X.read=new pd}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=X.read,x=X.write,this._public=null,this._dh=null,this._kexinit=this._protocol._kexinit=void 0,this._remoteKexinit=void 0,this._identRaw=void 0,this._remoteIdentRaw=void 0,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0,q?!1:P()};if((c||a)&&(this.finish=P),!c)return P(a)}start(){if(!this._protocol._server){if(this._protocol._debug){let u;this.type==="group"?u="KEXDH_INIT":u="KEXECDH_INIT",this._protocol._debug(`Outbound: Sending ${u}`)}let a=this.getPublicKey(),c=this._protocol._packetRW.write.allocStartKEX,l=this._protocol._packetRW.write.alloc(5+a.length,!0);l[c]=gt.KEXDH_INIT,qt(l,a.length,++c),l.set(a,c+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(l,!0))}}getPublicKey(){this.generateKeys();let a=this._public;if(a)return this.convertPublicKey(a)}convertPublicKey(a){let c,l=0,u=a.length;for(;a[l]===0;)++l,--u;return a[l]&128?(c=Buffer.allocUnsafe(1+u),c[0]=0,a.copy(c,1,l),c):(u!==a.length&&(c=Buffer.allocUnsafe(u),a.copy(c,0,l),a=c),a)}computeSecret(a){this.generateKeys();try{return n(this._dh.computeSecret(a))}catch(c){return c}}parse(a){let c=a[0];switch(this._step){case 1:if(this._protocol._server){if(c!==gt.KEXDH_INIT)return Xe(this._protocol,`Received packet ${c} instead of ${gt.KEXDH_INIT}`,"handshake",je.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Init"),Ye.init(a,1);let l=Ye.readString();if(Ye.clear(),l===void 0)return Xe(this._protocol,"Received malformed KEX*_INIT","handshake",je.KEY_EXCHANGE_FAILED);this._dhData=l;let u=this._protocol._hostKeys[this.negotiated.serverHostKey];Array.isArray(u)&&(u=u[0]),this._hostKey=u,this.finish()}else{if(c!==gt.KEXDH_REPLY)return Xe(this._protocol,`Received packet ${c} instead of ${gt.KEXDH_REPLY}`,"handshake",je.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Reply"),Ye.init(a,1);let l,u,f;if((l=Ye.readString())===void 0||(u=Ye.readString())===void 0||(f=Ye.readString())===void 0)return Ye.clear(),Xe(this._protocol,"Received malformed KEX*_REPLY","handshake",je.KEY_EXCHANGE_FAILED);Ye.clear(),Ye.init(l,0);let h=Ye.readString(!0);if(Ye.clear(),h===void 0)return Xe(this._protocol,"Received malformed host public key","handshake",je.KEY_EXCHANGE_FAILED);if(h!==this.negotiated.serverHostKey)switch(this.negotiated.serverHostKey){case"rsa-sha2-256":case"rsa-sha2-512":if(h==="ssh-rsa")break;default:return Xe(this._protocol,"Host key does not match negotiated type","handshake",je.KEY_EXCHANGE_FAILED)}this._hostKey=l,this._dhData=u,this._sig=f;let p=!1,A;if(this._protocol._hostVerifier===void 0?(A=!0,this._protocol._debug&&this._protocol._debug("Host accepted by default (no verification)")):A=this._protocol._hostVerifier(l,E=>{if(!p){if(p=!0,E===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),Xe(this._protocol,"Host denied (verification failed)","handshake",je.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,this._receivedNEWKEYS?this.finish():eo(this)}}),A===void 0){++this._step;return}if(p=!0,A===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),Xe(this._protocol,"Host denied (verification failed)","handshake",je.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,eo(this)}++this._step;break;case 2:return c!==gt.NEWKEYS?Xe(this._protocol,`Received packet ${c} instead of ${gt.NEWKEYS}`,"handshake",je.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Inbound: NEWKEYS"),this._receivedNEWKEYS=!0,this._protocol._strictMode&&(this._protocol._decipher.inSeqno=0),++this._step,this.finish(!this._protocol._server&&!this._hostVerified));default:return Xe(this._protocol,`Received unexpected packet ${c} after NEWKEYS`,"handshake",je.KEY_EXCHANGE_FAILED)}}}class e extends t{constructor(a,...c){super(...c),this.type="25519",this.hashName=a,this._keys=null}generateKeys(){this._keys||(this._keys=z0("x25519"))}getPublicKey(){return this.generateKeys(),this._keys.publicKey.export({type:"spki",format:"der"}).slice(-32)}convertPublicKey(a){let c,l=0,u=a.length;for(;a[l]===0;)++l,--u;return a.length===32||u!==a.length&&(c=Buffer.allocUnsafe(u),a.copy(c,0,l),a=c),a}computeSecret(a){this.generateKeys();try{let c=new ud.Writer;return c.startSequence(),c.startSequence(),c.writeOID("1.3.101.110"),c.endSequence(),c.startSequence(ud.BitString),c.writeByte(0),c._ensure(a.length),a.copy(c._buf,c._offset,0,a.length),c._offset+=a.length,c.endSequence(),c.endSequence(),n(K0({privateKey:this._keys.privateKey,publicKey:V0({key:c.buffer,type:"spki",format:"der"})}))}catch(c){return c}}}class r extends t{constructor(a,c,...l){super(...l),this.type="ecdh",this.curveName=a,this.hashName=c}generateKeys(){this._dh||(this._dh=q0(this.curveName),this._public=this._dh.generateKeys())}}class s extends t{constructor(a,...c){super(...c),this.type="groupex",this.hashName=a,this._prime=null,this._generator=null,this._minBits=rg,this._prefBits=ag(this.negotiated),this._protocol._compatFlags&Va.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=ig}start(){if(this._protocol._server)return;this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_REQUEST");let a=this._protocol._packetRW.write.allocStartKEX,c=this._protocol._packetRW.write.alloc(13,!0);c[a]=gt.KEXDH_GEX_REQUEST,qt(c,this._minBits,++a),qt(c,this._prefBits,a+=4),qt(c,this._maxBits,a+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(c,!0))}generateKeys(){!this._dh&&this._prime&&this._generator&&(this._dh=Q0(this._prime,this._generator),this._public=this._dh.generateKeys())}setDHParams(a,c){if(!Buffer.isBuffer(a))throw new Error("Invalid prime value");if(!Buffer.isBuffer(c))throw new Error("Invalid generator value");this._prime=a,this._generator=c}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}parse(a){let c=a[0];switch(this._step){case 1:{if(this._protocol._server)return c!==gt.KEXDH_GEX_REQUEST?Xe(this._protocol,`Received packet ${c} instead of `+gt.KEXDH_GEX_REQUEST,"handshake",je.KEY_EXCHANGE_FAILED):Xe(this._protocol,"Group exchange not implemented for server","handshake",je.KEY_EXCHANGE_FAILED);if(c!==gt.KEXDH_GEX_GROUP)return Xe(this._protocol,`Received packet ${c} instead of ${gt.KEXDH_GEX_GROUP}`,"handshake",je.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Group"),Ye.init(a,1);let l,u;if((l=Ye.readString())===void 0||(u=Ye.readString())===void 0)return Ye.clear(),Xe(this._protocol,"Received malformed KEXDH_GEX_GROUP","handshake",je.KEY_EXCHANGE_FAILED);Ye.clear(),this.setDHParams(l,u),this.generateKeys();let f=this.getPublicKey();this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_INIT");let h=this._protocol._packetRW.write.allocStartKEX,p=this._protocol._packetRW.write.alloc(5+f.length,!0);p[h]=gt.KEXDH_GEX_INIT,qt(p,f.length,++h),p.set(f,h+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(p,!0)),++this._step;break}case 2:if(this._protocol._server)return c!==gt.KEXDH_GEX_INIT?Xe(this._protocol,`Received packet ${c} instead of ${gt.KEXDH_GEX_INIT}`,"handshake",je.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Received DH GEX Init"),Xe(this._protocol,"Group exchange not implemented for server","handshake",je.KEY_EXCHANGE_FAILED));if(c!==gt.KEXDH_GEX_REPLY)return Xe(this._protocol,`Received packet ${c} instead of ${gt.KEXDH_GEX_REPLY}`,"handshake",je.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Reply"),this._step=1,a[0]=gt.KEXDH_REPLY,this.parse=t.prototype.parse,this.parse(a)}}}class i extends t{constructor(a,c,...l){super(...l),this.type="group",this.groupName=a,this.hashName=c}start(){if(!this._protocol._server){this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_INIT");let a=this.getPublicKey(),c=this._protocol._packetRW.write.allocStartKEX,l=this._protocol._packetRW.write.alloc(5+a.length,!0);l[c]=gt.KEXDH_INIT,qt(l,a.length,++c),l.set(a,c+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(l,!0))}}generateKeys(){this._dh||(this._dh=W0(this.groupName),this._public=this._dh.generateKeys())}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}}return(o,...a)=>{if(typeof o!="object"||o===null)throw new Error("Invalid negotiated argument");let c=o.kex;if(typeof c=="string"){switch(a=[o,...a],c){case"curve25519-sha256":case"curve25519-sha256@libssh.org":if(!Y0)break;return new e("sha256",...a);case"ecdh-sha2-nistp256":return new r("prime256v1","sha256",...a);case"ecdh-sha2-nistp384":return new r("secp384r1","sha384",...a);case"ecdh-sha2-nistp521":return new r("secp521r1","sha512",...a);case"diffie-hellman-group1-sha1":return new i("modp2","sha1",...a);case"diffie-hellman-group14-sha1":return new i("modp14","sha1",...a);case"diffie-hellman-group14-sha256":return new i("modp14","sha256",...a);case"diffie-hellman-group15-sha512":return new i("modp15","sha512",...a);case"diffie-hellman-group16-sha512":return new i("modp16","sha512",...a);case"diffie-hellman-group17-sha512":return new i("modp17","sha512",...a);case"diffie-hellman-group18-sha512":return new i("modp18","sha512",...a);case"diffie-hellman-group-exchange-sha1":return new s("sha1",...a);case"diffie-hellman-group-exchange-sha256":return new s("sha256",...a)}throw new Error(`Unsupported key exchange algorithm: ${c}`)}throw new Error(`Invalid key exchange type: ${c}`)}})(),Wa=(()=>{let n=["kex","serverHostKey",["cs","cipher"],["sc","cipher"],["cs","mac"],["sc","mac"],["cs","compress"],["sc","compress"],["cs","lang"],["sc","lang"]];return class{constructor(e){if(typeof e!="object"||e===null)throw new TypeError("Argument must be an object");let r={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},sc:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},all:void 0},s=0;for(let a of n){let c,l,u,f;if(typeof a=="string")c=r,l=e[a],u=f=a;else{let p=a[0];c=r[p],f=a[1],l=e[p][f],u=`${p}.${f}`}let h={array:void 0,buffer:void 0};if(Buffer.isBuffer(l))h.array=(""+l).split(","),h.buffer=l,s+=4+l.length;else{if(typeof l=="string"&&(l=l.split(",")),Array.isArray(l))h.array=l,h.buffer=Buffer.from(l.join(","));else throw new TypeError(`Invalid \`${u}\` type: ${typeof l}`);s+=4+h.buffer.length}c[f]=h}let i=Buffer.allocUnsafe(s);r.all=i;let o=0;for(let a of n){let c;typeof a=="string"?c=r[a].buffer:c=r[a[0]][a[1]].buffer,o=qt(i,c.length,o),i.set(c,o),o+=c.length}this.totalSize=s,this.lists=r}copyAllTo(e,r){let s=this.lists.all;if(typeof r!="number")throw new TypeError(`Invalid offset value: ${typeof r}`);if(e.length-r<s.length)throw new Error("Insufficient space to copy list");return e.set(s,r),s.length}}})(),Tn=(()=>{let n=Buffer.allocUnsafe(4);return(t,e)=>{qt(n,e.length,0),t.update(n),t.update(e)}})();function Yr(n,t,e,r,s,i){let o;if(n){let a=qa(t).update(e).update(r).update(i).update(s).digest();for(;a.length<n;){let c=qa(t).update(e).update(r).update(a).digest(),l=Buffer.allocUnsafe(a.length+c.length);l.set(a,0),l.set(c,a.length),a=l}a.length===n?o=a:o=new tg(a.buffer,a.byteOffset,n)}else o=sg;return o}function yd(n,t){if(t.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}if(this._skipNextInboundPacket){this._skipNextInboundPacket=!1;return}t=this._packetRW.read.read(t);let e=t[0];if(!this._strictMode)switch(e){case gt.IGNORE:case gt.UNIMPLEMENTED:case gt.DEBUG:return Gr||(Gr=zs()),Gr[e](this,t)}switch(e){case gt.DISCONNECT:return Gr||(Gr=zs()),Gr[e](this,t);case gt.KEXINIT:return n.firstPacket?(n.firstPacket=!1,Ad(this,t)):Xe(this,"Received extra KEXINIT during handshake","handshake",je.KEY_EXCHANGE_FAILED);default:if(e<20||e>49)return Xe(this,`Received unexpected packet type ${e}`,"handshake",je.KEY_EXCHANGE_FAILED)}return this._kex.parse(t)}function ag(n){let t=jr[n.cs.cipher],e=jr[n.sc.cipher],r=Math.max(0,t.sslName==="des-ede3-cbc"?14:t.keyLen,t.blockLen,t.ivLen,e.sslName==="des-ede3-cbc"?14:e.keyLen,e.blockLen,e.ivLen)*8;return r<=112?2048:r<=128?3072:r<=192?7680:8192}function eo(n){if(!n._sentNEWKEYS){n._protocol._debug&&n._protocol._debug("Outbound: Sending NEWKEYS");let t=n._protocol._packetRW.write.allocStartKEX,e=n._protocol._packetRW.write.alloc(1,!0);e[t]=gt.NEWKEYS,n._protocol._cipher.encrypt(n._protocol._packetRW.write.finalize(e,!0)),n._sentNEWKEYS=!0,n._protocol._strictMode&&(n._protocol._cipher.outSeqno=0)}}Ed.exports={KexInit:Wa,kexinit:gd,onKEXPayload:yd,DEFAULT_KEXINIT_CLIENT:new Wa({kex:fd.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:dd,cs:{cipher:Ys,mac:js,compress:Xs,lang:[]},sc:{cipher:Ys,mac:js,compress:Xs,lang:[]}}),DEFAULT_KEXINIT_SERVER:new Wa({kex:fd.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:dd,cs:{cipher:Ys,mac:js,compress:Xs,lang:[]},sc:{cipher:Ys,mac:js,compress:Xs,lang:[]}}),HANDLERS:{[gt.KEXINIT]:Ad}}});var Sd=ut(($x,cg)=>{cg.exports={name:"ssh2",version:"1.17.0",author:"Brian White <mscdex@mscdex.net>",description:"SSH2 client and server modules written in pure JavaScript for node.js",main:"./lib/index.js",engines:{node:">=10.16.0"},dependencies:{asn1:"^0.2.6","bcrypt-pbkdf":"^1.0.2"},devDependencies:{"@mscdex/eslint-config":"^1.1.0",eslint:"^7.32.0"},optionalDependencies:{"cpu-features":"~0.0.10",nan:"^2.23.0"},scripts:{install:"node install.js",rebuild:"node install.js",test:"node test/test.js",lint:"eslint --cache --report-unused-disable-directives --ext=.js .eslintrc.js examples lib test","lint:fix":"npm run lint -- --fix"},keywords:["ssh","ssh2","sftp","secure","shell","exec","remote","client"],licenses:[{type:"MIT",url:"http://github.com/mscdex/ssh2/raw/master/LICENSE"}],repository:{type:"git",url:"http://github.com/mscdex/ssh2.git"}}});var Ya=ut((Fx,Td)=>{"use strict";var{inspect:Cd}=require("util"),{bindingAvailable:lg,NullCipher:ug,NullDecipher:fg}=tr(),{COMPAT_CHECKS:dg,DISCONNECT_REASON:kd,eddsaSupported:hg,MESSAGE:Ie,SIGNALS:_d,TERMINAL_MODE:za}=qn(),{DEFAULT_KEXINIT_CLIENT:pg,DEFAULT_KEXINIT_SERVER:mg,KexInit:bd,kexinit:vd,onKEXPayload:gg}=Gs(),{parseKey:xd}=ir(),Ag=zs(),{bufferCopy:to,bufferFill:yg,bufferSlice:Nd,convertSignature:wd,sendPacket:Ce,writeUInt32BE:O}=xn(),{PacketReader:Eg,PacketWriter:Sg,ZlibPacketReader:Bd,ZlibPacketWriter:Rd}=Fa(),_g=Sd().version,bg=new Map(Object.values(kd).map(n=>[n,1])),Pd=Buffer.from(`SSH-2.0-ssh2js${_g}`),xg=Buffer.from(`${Pd}\r
|
|
@@ -12,7 +12,7 @@ ${e}-----END ${n} KEY-----`}function Ri(n,t){let e=Buffer.allocUnsafe(n.length+t
|
|
|
12
12
|
`)}else this._hostKeys=void 0;let f=t.offer;typeof f!="object"||f===null?f=this._server?mg:pg:f.constructor!==bd&&(this._server?f.kex=f.kex.concat(["kex-strict-s-v00@openssh.com"]):f.kex=f.kex.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),f=new bd(f)),this._kex=void 0,this._strictMode=void 0,this._kexinit=void 0,this._offer=f,this._cipher=new ug(0,this._onWrite),this._decipher=void 0,this._skipNextInboundPacket=!1,this._packetRW={read:new Eg,write:new Sg(this)},this._hostVerifier=!this._server&&typeof t.hostVerifier=="function"?t.hostVerifier:void 0,this._parse=vg,this._buffer=void 0,this._authsQueue=[],this._authenticated=!1,this._remoteIdentRaw=void 0;let h;if(typeof t.ident=="string")this._identRaw=Buffer.from(`SSH-2.0-${t.ident}`),h=Buffer.allocUnsafe(this._identRaw.length+2),h.set(this._identRaw,0),h[h.length-2]=13,h[h.length-1]=10;else if(Buffer.isBuffer(t.ident)){let p=Buffer.allocUnsafe(8+t.ident.length);p.latin1Write("SSH-2.0-",0,8),p.set(t.ident,8),this._identRaw=p,h=Buffer.allocUnsafe(p.length+2),h.set(p,0),h[h.length-2]=13,h[h.length-1]=10}else this._identRaw=Pd,h=xg;this._compatFlags=0,this._debug&&(lg?this._debug("Custom crypto binding available"):this._debug("Custom crypto binding not available")),this._debug&&this._debug(`Local ident: ${Cd(this._identRaw.toString())}`),this.start=()=>{this.start=void 0,u&&this._onWrite(u),this._onWrite(h)}}_destruct(t){this._packetRW.read.cleanup(),this._packetRW.write.cleanup(),this._cipher&&this._cipher.free(),this._decipher&&this._decipher.free(),(typeof t!="string"||t.length===0)&&(t="fatal error"),this.parse=()=>{throw new Error(`Instance unusable after ${t}`)},this._onWrite=()=>{throw new Error(`Instance unusable after ${t}`)},this._destruct=void 0}cleanup(){this._destruct&&this._destruct()}parse(t,e,r){for(;e<r;)e=this._parse(t,e,r)}disconnect(t){let r=this._packetRW.write.allocStartKEX,s=this._packetRW.write.alloc(13,!0),i=r+13;bg.has(t)||(t=kd.PROTOCOL_ERROR),s[r]=Ie.DISCONNECT,O(s,t,++r),s.fill(0,r+=4,i),this._debug&&this._debug(`Outbound: Sending DISCONNECT (${t})`),Ce(this,this._packetRW.write.finalize(s,!0),!0)}ping(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(Id.length);e.set(Id,t),this._debug&&this._debug("Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)"),Ce(this,this._packetRW.write.finalize(e))}rekey(){this._kexinit===void 0?(this._debug&&this._debug("Outbound: Initiated explicit rekey"),this._queue=[],vd(this)):this._debug&&this._debug("Outbound: Ignoring rekey during handshake")}requestSuccess(t){let e=this._packetRW.write.allocStart,r;Buffer.isBuffer(t)?(r=this._packetRW.write.alloc(1+t.length),r[e]=Ie.REQUEST_SUCCESS,r.set(t,++e)):(r=this._packetRW.write.alloc(1),r[e]=Ie.REQUEST_SUCCESS),this._debug&&this._debug("Outbound: Sending REQUEST_SUCCESS"),Ce(this,this._packetRW.write.finalize(r))}requestFailure(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(1);e[t]=Ie.REQUEST_FAILURE,this._debug&&this._debug("Outbound: Sending REQUEST_FAILURE"),Ce(this,this._packetRW.write.finalize(e))}channelSuccess(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Ie.CHANNEL_SUCCESS,O(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${t})`),Ce(this,this._packetRW.write.finalize(r))}channelFailure(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Ie.CHANNEL_FAILURE,O(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${t})`),Ce(this,this._packetRW.write.finalize(r))}channelEOF(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Ie.CHANNEL_EOF,O(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_EOF (r:${t})`),Ce(this,this._packetRW.write.finalize(r))}channelClose(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Ie.CHANNEL_CLOSE,O(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${t})`),Ce(this,this._packetRW.write.finalize(r))}channelWindowAdjust(t,e){let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(9);s[r]=Ie.CHANNEL_WINDOW_ADJUST,O(s,t,++r),O(s,e,r+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${t}, ${e})`),Ce(this,this._packetRW.write.finalize(s))}channelData(t,e){let r=Buffer.isBuffer(e),s=r?e.length:Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(9+s);o[i]=Ie.CHANNEL_DATA,O(o,t,++i),O(o,s,i+=4),r?o.set(e,i+=4):o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_DATA (r:${t}, ${s})`),Ce(this,this._packetRW.write.finalize(o))}channelExtData(t,e,r){let s=Buffer.isBuffer(e),i=s?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(13+i);a[o]=Ie.CHANNEL_EXTENDED_DATA,O(a,t,++o),O(a,r,o+=4),O(a,i,o+=4),s?a.set(e,o+=4):a.utf8Write(e,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${t})`),Ce(this,this._packetRW.write.finalize(a))}channelOpenConfirm(t,e,r,s){let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(17);o[i]=Ie.CHANNEL_OPEN_CONFIRMATION,O(o,t,++i),O(o,e,i+=4),O(o,r,i+=4),O(o,s,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${t}, l:${e})`),Ce(this,this._packetRW.write.finalize(o))}channelOpenFail(t,e,r){typeof r!="string"&&(r="");let s=Buffer.byteLength(r),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(13+s+4);o[i]=Ie.CHANNEL_OPEN_FAILURE,O(o,t,++i),O(o,e,i+=4),O(o,s,i+=4),i+=4,s&&(o.utf8Write(r,i,s),i+=s),O(o,0,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${t})`),Ce(this,this._packetRW.write.finalize(o))}service(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e);s[r]=Ie.SERVICE_REQUEST,O(s,e,++r),s.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_REQUEST (${t})`),Ce(this,this._packetRW.write.finalize(s))}authPassword(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=Buffer.byteLength(e),o=r?Buffer.byteLength(r):0,a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(5+s+4+14+4+8+1+4+i+(r?4+o:0));c[a]=Ie.USERAUTH_REQUEST,O(c,s,++a),c.utf8Write(t,a+=4,s),O(c,14,a+=s),c.utf8Write("ssh-connection",a+=4,14),O(c,8,a+=14),c.utf8Write("password",a+=4,8),c[a+=8]=r?1:0,O(c,i,++a),Buffer.isBuffer(e)?to(e,c,0,i,a+=4):c.utf8Write(e,a+=4,i),r?(O(c,o,a+=i),Buffer.isBuffer(r)?to(r,c,0,o,a+=4):c.utf8Write(r,a+=4,o),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (changed password)")):this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (password)"),this._authsQueue.push("password"),Ce(this,this._packetRW.write.finalize(c))}authPK(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");if(e=xd(e),e instanceof Error)throw new Error("Invalid key");let i=e.type;e=e.getPublicSSH(),typeof r=="function"&&(s=r,r=void 0),r||(r=i);let o=Buffer.byteLength(t),a=Buffer.byteLength(r),c=e.length,l=this._kex.sessionID,u=l.length,f=(s?4+u:0)+1+4+o+4+14+4+9+1+4+a+4+c,h,p;if(s?(h=Buffer.allocUnsafe(f),p=0,O(h,u,p),h.set(l,p+=4),p+=u):(h=this._packetRW.write.alloc(f),p=this._packetRW.write.allocStart),h[p]=Ie.USERAUTH_REQUEST,O(h,o,++p),h.utf8Write(t,p+=4,o),O(h,14,p+=o),h.utf8Write("ssh-connection",p+=4,14),O(h,9,p+=14),h.utf8Write("publickey",p+=4,9),h[p+=9]=s?1:0,O(h,a,++p),h.utf8Write(r,p+=4,a),O(h,c,p+=a),h.set(e,p+=4),!s){this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey -- check)"),Ce(this,this._packetRW.write.finalize(h));return}s(h,A=>{if(A=wd(A,i),A===!1)throw new Error("Error while converting handshake signature");let E=A.length;p=this._packetRW.write.allocStart,h=this._packetRW.write.alloc(5+o+4+14+4+9+1+4+a+4+c+4+4+a+4+E),h[p]=Ie.USERAUTH_REQUEST,O(h,o,++p),h.utf8Write(t,p+=4,o),O(h,14,p+=o),h.utf8Write("ssh-connection",p+=4,14),O(h,9,p+=14),h.utf8Write("publickey",p+=4,9),h[p+=9]=1,O(h,a,++p),h.utf8Write(r,p+=4,a),O(h,c,p+=a),h.set(e,p+=4),O(h,4+a+4+E,p+=c),O(h,a,p+=4),h.utf8Write(r,p+=4,a),O(h,E,p+=a),h.set(A,p+=4),this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey)"),Ce(this,this._packetRW.write.finalize(h))})}authHostbased(t,e,r,s,i,o){if(this._server)throw new Error("Client-only method called in server mode");if(e=xd(e),e instanceof Error)throw new Error("Invalid key");let a=e.type;e=e.getPublicSSH(),typeof i=="function"&&(o=i,i=void 0),i||(i=a);let c=Buffer.byteLength(t),l=Buffer.byteLength(i),u=e.length,f=this._kex.sessionID,h=f.length,p=Buffer.byteLength(r),A=Buffer.byteLength(s),E=Buffer.allocUnsafe(4+h+1+4+c+4+14+4+9+4+l+4+u+4+p+4+A),b=0;O(E,h,b),E.set(f,b+=4),E[b+=h]=Ie.USERAUTH_REQUEST,O(E,c,++b),E.utf8Write(t,b+=4,c),O(E,14,b+=c),E.utf8Write("ssh-connection",b+=4,14),O(E,9,b+=14),E.utf8Write("hostbased",b+=4,9),O(E,l,b+=9),E.utf8Write(i,b+=4,l),O(E,u,b+=l),E.set(e,b+=4),O(E,p,b+=u),E.utf8Write(r,b+=4,p),O(E,A,b+=p),E.utf8Write(s,b+=4,A),o(E,x=>{if(x=wd(x,a),!x)throw new Error("Error while converting handshake signature");let P=x.length,q=E.length-h-4;b=this._packetRW.write.allocStart;let C=this._packetRW.write.alloc(q+4+4+l+4+P);to(E,C,4+h,E.length,b),O(C,4+l+4+P,b+=q),O(C,l,b+=4),C.utf8Write(i,b+=4,l),O(C,P,b+=l),C.set(x,b+=4),this._authsQueue.push("hostbased"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (hostbased)"),Ce(this,this._packetRW.write.finalize(C))})}authKeyboard(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4+14+4+20+4+4);s[r]=Ie.USERAUTH_REQUEST,O(s,e,++r),s.utf8Write(t,r+=4,e),O(s,14,r+=e),s.utf8Write("ssh-connection",r+=4,14),O(s,20,r+=14),s.utf8Write("keyboard-interactive",r+=4,20),O(s,0,r+=20),O(s,0,r+=4),this._authsQueue.push("keyboard-interactive"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)"),Ce(this,this._packetRW.write.finalize(s))}authNone(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4+14+4+4);s[r]=Ie.USERAUTH_REQUEST,O(s,e,++r),s.utf8Write(t,r+=4,e),O(s,14,r+=e),s.utf8Write("ssh-connection",r+=4,14),O(s,4,r+=14),s.utf8Write("none",r+=4,4),this._authsQueue.push("none"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (none)"),Ce(this,this._packetRW.write.finalize(s))}authInfoRes(t){if(this._server)throw new Error("Client-only method called in server mode");let e=0,r;if(t){r=new Array(t.length);for(let o=0;o<t.length;++o){let a=Buffer.byteLength(t[o]);r[o]=a,e+=4+a}}let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+e);if(i[s]=Ie.USERAUTH_INFO_RESPONSE,t){O(i,t.length,++s),s+=4;for(let o=0;o<t.length;++o){let a=r[o];O(i,a,s),s+=4,a&&(i.utf8Write(t[o],s,a),s+=a)}}else O(i,0,++s);this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_RESPONSE"),Ce(this,this._packetRW.write.finalize(i))}tcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+s+4);o[i]=Ie.GLOBAL_REQUEST,O(o,13,++i),o.utf8Write("tcpip-forward",i+=4,13),o[i+=13]=r===void 0||r===!0?1:0,O(o,s,++i),o.utf8Write(t,i+=4,s),O(o,e,i+=s),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (tcpip-forward)"),Ce(this,this._packetRW.write.finalize(o))}cancelTcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(30+s+4);o[i]=Ie.GLOBAL_REQUEST,O(o,20,++i),o.utf8Write("cancel-tcpip-forward",i+=4,20),o[i+=20]=r===void 0||r===!0?1:0,O(o,s,++i),o.utf8Write(t,i+=4,s),O(o,e,i+=s),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)"),Ce(this,this._packetRW.write.finalize(o))}openssh_streamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(41+r);i[s]=Ie.GLOBAL_REQUEST,O(i,31,++s),i.utf8Write("streamlocal-forward@openssh.com",s+=4,31),i[s+=31]=e===void 0||e===!0?1:0,O(i,r,++s),i.utf8Write(t,s+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)"),Ce(this,this._packetRW.write.finalize(i))}openssh_cancelStreamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(48+r);i[s]=Ie.GLOBAL_REQUEST,O(i,38,++s),i.utf8Write("cancel-streamlocal-forward@openssh.com",s+=4,38),i[s+=38]=e===void 0||e===!0?1:0,O(i,r,++s),i.utf8Write(t,s+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-streamlocal-forward@openssh.com)"),Ce(this,this._packetRW.write.finalize(i))}directTcpip(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(s.srcIP),o=Buffer.byteLength(s.dstIP),a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(33+i+4+4+o+4);c[a]=Ie.CHANNEL_OPEN,O(c,12,++a),c.utf8Write("direct-tcpip",a+=4,12),O(c,t,a+=12),O(c,e,a+=4),O(c,r,a+=4),O(c,o,a+=4),c.utf8Write(s.dstIP,a+=4,o),O(c,s.dstPort,a+=o),O(c,i,a+=4),c.utf8Write(s.srcIP,a+=4,i),O(c,s.srcPort,a+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-tcpip)`),Ce(this,this._packetRW.write.finalize(c))}openssh_directStreamLocal(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(s.socketPath),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(51+i+4+4);a[o]=Ie.CHANNEL_OPEN,O(a,30,++o),a.utf8Write("direct-streamlocal@openssh.com",o+=4,30),O(a,t,o+=30),O(a,e,o+=4),O(a,r,o+=4),O(a,i,o+=4),a.utf8Write(s.socketPath,o+=4,i),yg(a,0,o+=i,o+8),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-streamlocal@openssh.com)`),Ce(this,this._packetRW.write.finalize(a))}openssh_noMoreSessions(t){if(this._server)throw new Error("Client-only method called in server mode");let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(34);r[e]=Ie.GLOBAL_REQUEST,O(r,28,++e),r.utf8Write("no-more-sessions@openssh.com",e+=4,28),r[e+=28]=t===void 0||t===!0?1:0,this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (no-more-sessions@openssh.com)"),Ce(this,this._packetRW.write.finalize(r))}session(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(24);i[s]=Ie.CHANNEL_OPEN,O(i,7,++s),i.utf8Write("session",s+=4,7),O(i,t,s+=7),O(i,e,s+=4),O(i,r,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, session)`),Ce(this,this._packetRW.write.finalize(i))}windowChange(t,e,r,s,i){if(this._server)throw new Error("Client-only method called in server mode");let o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(39);a[o]=Ie.CHANNEL_REQUEST,O(a,t,++o),O(a,13,o+=4),a.utf8Write("window-change",o+=4,13),a[o+=13]=0,O(a,r,++o),O(a,e,o+=4),O(a,i,o+=4),O(a,s,o+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, window-change)`),Ce(this,this._packetRW.write.finalize(a))}pty(t,e,r,s,i,o,a,c){if(this._server)throw new Error("Client-only method called in server mode");(!o||!o.length)&&(o="vt100"),a&&!Buffer.isBuffer(a)&&!Array.isArray(a)&&typeof a=="object"&&a!==null&&(a=Pg(a)),(!a||!a.length)&&(a=Cg);let l=o.length,u=a.length,f=this._packetRW.write.allocStart,h=this._packetRW.write.alloc(21+l+4+4+4+4+4+u);if(h[f]=Ie.CHANNEL_REQUEST,O(h,t,++f),O(h,7,f+=4),h.utf8Write("pty-req",f+=4,7),h[f+=7]=c===void 0||c===!0?1:0,O(h,l,++f),h.utf8Write(o,f+=4,l),O(h,r,f+=l),O(h,e,f+=4),O(h,i,f+=4),O(h,s,f+=4),O(h,u,f+=4),f+=4,Array.isArray(a))for(let p=0;p<u;++p)h[f++]=a[p];else Buffer.isBuffer(a)&&h.set(a,f);this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, pty-req)`),Ce(this,this._packetRW.write.finalize(h))}shell(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(15);s[r]=Ie.CHANNEL_REQUEST,O(s,t,++r),O(s,5,r+=4),s.utf8Write("shell",r+=4,5),s[r+=5]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, shell)`),Ce(this,this._packetRW.write.finalize(s))}exec(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.isBuffer(e),i=s?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(18+i);a[o]=Ie.CHANNEL_REQUEST,O(a,t,++o),O(a,4,o+=4),a.utf8Write("exec",o+=4,4),a[o+=4]=r===void 0||r===!0?1:0,O(a,i,++o),s?a.set(e,o+=4):a.utf8Write(e,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exec: ${e})`),Ce(this,this._packetRW.write.finalize(a))}signal(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=e;if(e=e.toUpperCase(),e.slice(0,3)==="SIG"&&(e=e.slice(3)),_d[e]!==1)throw new Error(`Invalid signal: ${r}`);let s=e.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(20+s);o[i]=Ie.CHANNEL_REQUEST,O(o,t,++i),O(o,6,i+=4),o.utf8Write("signal",i+=4,6),o[i+=6]=0,O(o,s,++i),o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, signal: ${e})`),Ce(this,this._packetRW.write.finalize(o))}env(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=Buffer.isBuffer(r),a=o?r.length:Buffer.byteLength(r),c=this._packetRW.write.allocStart,l=this._packetRW.write.alloc(17+i+4+a);l[c]=Ie.CHANNEL_REQUEST,O(l,t,++c),O(l,3,c+=4),l.utf8Write("env",c+=4,3),l[c+=3]=s===void 0||s===!0?1:0,O(l,i,++c),l.utf8Write(e,c+=4,i),O(l,a,c+=i),o?l.set(r,c+=4):l.utf8Write(r,c+=4,a),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, env: ${e}=${r})`),Ce(this,this._packetRW.write.finalize(l))}x11Forward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=e.protocol,i=e.cookie,o=Buffer.isBuffer(s),a=o?s.length:Buffer.byteLength(s),c=Buffer.isBuffer(i),l=c?i.length:Buffer.byteLength(i),u=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(22+a+4+l+4);f[u]=Ie.CHANNEL_REQUEST,O(f,t,++u),O(f,7,u+=4),f.utf8Write("x11-req",u+=4,7),f[u+=7]=r===void 0||r===!0?1:0,f[++u]=e.single?1:0,O(f,a,++u),o?f.set(s,u+=4):f.utf8Write(s,u+=4,a),O(f,l,u+=a),c?f.set(i,u+=4):f.latin1Write(i,u+=4,l),O(f,e.screen||0,u+=l),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, x11-req)`),Ce(this,this._packetRW.write.finalize(f))}subsystem(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+s);o[i]=Ie.CHANNEL_REQUEST,O(o,t,++i),O(o,9,i+=4),o.utf8Write("subsystem",i+=4,9),o[i+=9]=r===void 0||r===!0?1:0,O(o,s,++i),o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, subsystem: ${e})`),Ce(this,this._packetRW.write.finalize(o))}openssh_agentForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(36);s[r]=Ie.CHANNEL_REQUEST,O(s,t,++r),O(s,26,r+=4),s.utf8Write("auth-agent-req@openssh.com",r+=4,26),s[r+=26]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, auth-agent-req@openssh.com)`),Ce(this,this._packetRW.write.finalize(s))}openssh_hostKeysProve(t){if(this._server)throw new Error("Client-only method called in server mode");let e=0,r=[];for(let o of t){let a=o.getPublicSSH();e+=4+a.length,r.push(a)}let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(35+e);i[s]=Ie.GLOBAL_REQUEST,O(i,29,++s),i.utf8Write("hostkeys-prove-00@openssh.com",s+=4,29),i[s+=29]=1,++s;for(let o of r)O(i,o.length,s),to(o,i,0,o.length,s+=4),s+=o.length;this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)"),Ce(this,this._packetRW.write.finalize(i))}serviceAccept(t){if(!this._server)throw new Error("Server-only method called in client mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e);if(s[r]=Ie.SERVICE_ACCEPT,O(s,e,++r),s.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_ACCEPT (${t})`),Ce(this,this._packetRW.write.finalize(s)),this._server&&this._banner&&t==="ssh-userauth"){let i=this._banner;this._banner=void 0;let o=Buffer.byteLength(i);r=this._packetRW.write.allocStart;let a=this._packetRW.write.alloc(5+o+4);a[r]=Ie.USERAUTH_BANNER,O(a,o,++r),a.utf8Write(i,r+=4,o),O(a,0,r+=o),this._debug&&this._debug("Outbound: Sending USERAUTH_BANNER"),Ce(this,this._packetRW.write.finalize(a))}}forwardedTcpip(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.boundAddr),o=Buffer.byteLength(s.remoteAddr),a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(36+i+4+4+o+4);c[a]=Ie.CHANNEL_OPEN,O(c,15,++a),c.utf8Write("forwarded-tcpip",a+=4,15),O(c,t,a+=15),O(c,e,a+=4),O(c,r,a+=4),O(c,i,a+=4),c.utf8Write(s.boundAddr,a+=4,i),O(c,s.boundPort,a+=i),O(c,o,a+=4),c.utf8Write(s.remoteAddr,a+=4,o),O(c,s.remotePort,a+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-tcpip)`),Ce(this,this._packetRW.write.finalize(c))}x11(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.originAddr),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(24+i+4);a[o]=Ie.CHANNEL_OPEN,O(a,3,++o),a.utf8Write("x11",o+=4,3),O(a,t,o+=3),O(a,e,o+=4),O(a,r,o+=4),O(a,i,o+=4),a.utf8Write(s.originAddr,o+=4,i),O(a,s.originPort,o+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, x11)`),Ce(this,this._packetRW.write.finalize(a))}openssh_authAgent(t,e,r){if(!this._server)throw new Error("Server-only method called in client mode");let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(39);i[s]=Ie.CHANNEL_OPEN,O(i,22,++s),i.utf8Write("auth-agent@openssh.com",s+=4,22),O(i,t,s+=22),O(i,e,s+=4),O(i,r,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, auth-agent@openssh.com)`),Ce(this,this._packetRW.write.finalize(i))}openssh_forwardedStreamLocal(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.socketPath),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(54+i+4);a[o]=Ie.CHANNEL_OPEN,O(a,33,++o),a.utf8Write("forwarded-streamlocal@openssh.com",o+=4,33),O(a,t,o+=33),O(a,e,o+=4),O(a,r,o+=4),O(a,i,o+=4),a.utf8Write(s.socketPath,o+=4,i),O(a,0,o+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-streamlocal@openssh.com)`),Ce(this,this._packetRW.write.finalize(a))}exitStatus(t,e){if(!this._server)throw new Error("Server-only method called in client mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(25);s[r]=Ie.CHANNEL_REQUEST,O(s,t,++r),O(s,11,r+=4),s.utf8Write("exit-status",r+=4,11),s[r+=11]=0,O(s,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-status: ${e})`),Ce(this,this._packetRW.write.finalize(s))}exitSignal(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=e;if(typeof i!="string"||!i)throw new Error(`Invalid signal: ${i}`);let o=e.toUpperCase();if(o.slice(0,3)==="SIG"&&(o=o.slice(3)),_d[o]!==1)throw new Error(`Invalid signal: ${i}`);let a=Buffer.byteLength(o),c=s?Buffer.byteLength(s):0,l=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(25+a+1+4+c+4);u[l]=Ie.CHANNEL_REQUEST,O(u,t,++l),O(u,11,l+=4),u.utf8Write("exit-signal",l+=4,11),u[l+=11]=0,O(u,a,++l),u.utf8Write(o,l+=4,a),u[l+=a]=r?1:0,O(u,c,++l),l+=4,c&&(u.utf8Write(s,l,c),l+=c),O(u,0,l),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-signal: ${e})`),Ce(this,this._packetRW.write.finalize(u))}authFailure(t,e){if(!this._server)throw new Error("Server-only method called in client mode");if(this._authsQueue.length===0)throw new Error("No auth in progress");let r;if(typeof t=="boolean"&&(e=t,t=void 0),t){r=[];for(let a=0;a<t.length;++a)t[a].toLowerCase()!=="none"&&r.push(t[a]);r=r.join(",")}else r="";let s=r.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+s+1);o[i]=Ie.USERAUTH_FAILURE,O(o,s,++i),o.utf8Write(r,i+=4,s),o[i+=s]=e===!0?1:0,this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_FAILURE"),Ce(this,this._packetRW.write.finalize(o))}authSuccess(){if(!this._server)throw new Error("Server-only method called in client mode");if(this._authsQueue.length===0)throw new Error("No auth in progress");let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(1);e[t]=Ie.USERAUTH_SUCCESS,this._authsQueue.shift(),this._authenticated=!0,this._debug&&this._debug("Outbound: Sending USERAUTH_SUCCESS"),Ce(this,this._packetRW.write.finalize(e)),this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.read=new Bd),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.write=new Rd(this))}authPKOK(t,e){if(!this._server)throw new Error("Server-only method called in client mode");if(this._authsQueue.length===0||this._authsQueue[0]!=="publickey")throw new Error('"publickey" auth not in progress');let r=Buffer.byteLength(t),s=e.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+r+4+s);o[i]=Ie.USERAUTH_PK_OK,O(o,r,++i),o.utf8Write(t,i+=4,r),O(o,s,i+=r),o.set(e,i+=4),this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_PK_OK"),Ce(this,this._packetRW.write.finalize(o))}authPasswdChg(t){if(!this._server)throw new Error("Server-only method called in client mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4);s[r]=Ie.USERAUTH_PASSWD_CHANGEREQ,O(s,e,++r),s.utf8Write(t,r+=4,e),O(s,0,r+=e),this._debug&&this._debug("Outbound: Sending USERAUTH_PASSWD_CHANGEREQ"),Ce(this,this._packetRW.write.finalize(s))}authInfoReq(t,e,r){if(!this._server)throw new Error("Server-only method called in client mode");let s=0,i=t?Buffer.byteLength(t):0,o=e?Buffer.byteLength(e):0;for(let l=0;l<r.length;++l)s+=4+Buffer.byteLength(r[l].prompt)+1;let a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(5+i+4+o+4+4+s);c[a]=Ie.USERAUTH_INFO_REQUEST,O(c,i,++a),a+=4,t&&(c.utf8Write(t,a,i),a+=i),O(c,o,a),a+=4,e&&(c.utf8Write(e,a,o),a+=o),O(c,0,a),O(c,r.length,a+=4),a+=4;for(let l=0;l<r.length;++l){let u=r[l],f=Buffer.byteLength(u.prompt);O(c,f,a),a+=4,f&&(c.utf8Write(u.prompt,a,f),a+=f),c[a++]=u.echo?1:0}this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_REQUEST"),Ce(this,this._packetRW.write.finalize(c))}},kg=/^SSH-(2\.0|1\.99)-([^ ]+)(?: (.*))?$/;function vg(n,t,e){let r,s;this._buffer?(r=Buffer.allocUnsafe(this._buffer.length+(e-t)),r.set(this._buffer,0),t===0?r.set(n,this._buffer.length):r.set(new Uint8Array(n.buffer,n.byteOffset+t,e-t),this._buffer.length),s=this._buffer.length,t=0):(r=n,s=0);let i=t,o=t,a=t,c=!1,l=0,u=0;for(;t<r.length;++t){let f=r[t];if(f===13){c=!0;continue}if(f===10){if(a>o&&a-o>4&&r[o]===83&&r[o+1]===83&&r[o+2]===72&&r[o+3]===45){let h=r.latin1Slice(i,a+1),p=o===i?h:h.slice(o-i),A=kg.exec(p);if(!A)throw new Error("Invalid identification string");let E={greeting:o===i?"":h.slice(0,o-i),identRaw:p,versions:{protocol:A[1],software:A[2]},comments:A[3]};return this._remoteIdentRaw=Buffer.from(p),this._debug&&this._debug(`Remote ident: ${Cd(p)}`),this._compatFlags=Rg(E),this._buffer=void 0,this._decipher=new fg(0,gg.bind(this,{firstPacket:!0})),this._parse=Ng,this._onHeader(E),this._destruct?(vd(this),t+1-s):e}if(this._server)throw new Error("Greetings from clients not permitted");if(++u>Ig)throw new Error("Max greeting lines exceeded");c=!1,o=t+1,l=0}else{if(c)throw new Error("Invalid header: expected newline");if(++l>=wg)throw new Error("Header line too long")}a=t}return this._buffer||(this._buffer=Nd(r,i)),t-s}function Ng(n,t,e){return this._decipher.decrypt(n,t,e)}function Bg(n){if(this._onPacket(),n.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}n=this._packetRW.read.read(n);let t=n[0];t===Ie.USERAUTH_SUCCESS&&!this._server&&!this._authenticated&&(this._authenticated=!0,this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.write=new Rd(this)),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.read=new Bd));let e=Ag[t];if(e===void 0){this._debug&&this._debug(`Inbound: Unsupported message type: ${t}`);return}return e(this,n)}function Rg(n){let t=n.versions.software,e=0;for(let r of dg)typeof r[0]=="string"?t===r[0]&&(e|=r[1]):r[0].test(t)&&(e|=r[1]);return e}function Pg(n){let t=Object.keys(n),e=Buffer.allocUnsafe(5*t.length+1),r=0;for(let s=0;s<t.length;++s){let i=t[s];if(i==="TTY_OP_END")continue;let o=za[i];if(o===void 0)continue;let a=n[i];typeof a=="number"&&isFinite(a)&&(e[r++]=o,e[r++]=a>>>24,e[r++]=a>>>16,e[r++]=a>>>8,e[r++]=a)}return e[r++]=za.TTY_OP_END,r<e.length?Nd(e,0,r):e}function Tg(n){let t="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss";hg&&(t=`ssh-ed25519,${t}`);let e=Buffer.byteLength(t),r=n._packetRW.write.allocStart,s=n._packetRW.write.alloc(28+e);s[r]=Ie.EXT_INFO,O(s,1,++r),O(s,15,r+=4),s.utf8Write("server-sig-algs",r+=4,15),O(s,e,r+=15),s.utf8Write(t,r+=4,e),n._debug&&n._debug("Outbound: Sending EXT_INFO"),Ce(n,n._packetRW.write.finalize(s))}Td.exports=Ga});var $d=ut(Fi=>{"use strict";var no=require("assert"),{inspect:Og}=require("util");function Od(n){let t="",e=n.length,r=n[0]==="-"?1:0;for(;e>=r+4;e-=3)t=`_${n.slice(e-3,e)}${t}`;return`${n.slice(0,e)}${t}`}function Md(n,t){if(no(typeof t=="string","`thing` has to be of type string"),Array.isArray(n)){let e=n.length;return no(e>0,"At least one expected value needs to be specified"),n=n.map(r=>String(r)),e>2?`one of ${t} ${n.slice(0,e-1).join(", ")}, or `+n[e-1]:e===2?`one of ${t} ${n[0]} or ${n[1]}`:`of ${t} ${n[0]}`}return`of ${t} ${String(n)}`}Fi.ERR_INTERNAL_ASSERTION=class Ld extends Error{constructor(t){super(),Error.captureStackTrace(this,Ld);let e=`This is caused by either a bug in ssh2 or incorrect usage of ssh2 internals.
|
|
13
13
|
Please open an issue with this stack trace at https://github.com/mscdex/ssh2/issues
|
|
14
14
|
`;this.message=t===void 0?e:`${t}
|
|
15
|
-
${e}`}};var Mg=2**32,Dd=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();Fi.ERR_OUT_OF_RANGE=class Ud extends RangeError{constructor(t,e,r,s){super(),Error.captureStackTrace(this,Ud),no(e,'Missing "range" argument');let i=s?t:`The value of "${t}" is out of range.`,o;Number.isInteger(r)&&Math.abs(r)>Mg?o=Od(String(r)):typeof r=="bigint"?(o=String(r),(r>Dd||r<-Dd)&&(o=Od(o)),o+="n"):o=Og(r),i+=` It must be ${e}. Received ${o}`,this.message=i}};var ro=class n extends TypeError{constructor(t,e,r){super(),Error.captureStackTrace(this,n),no(typeof t=="string","'name' must be a string");let s;typeof e=="string"&&e.startsWith("not ")?(s="must not be",e=e.replace(/^not /,"")):s="must be";let i;if(t.endsWith(" argument"))i=`The ${t} ${s} ${Md(e,"type")}`;else{let o=t.includes(".")?"property":"argument";i=`The "${t}" ${o} ${s} ${Md(e,"type")}`}i+=`. Received type ${typeof r}`,this.message=i}};Fi.ERR_INVALID_ARG_TYPE=ro;Fi.validateNumber=function(t,e){if(typeof t!="number")throw new ro(e,"number",t)}});var Hi=ut((Qx,Jd)=>{"use strict";var Dg=require("events"),or=require("fs"),{constants:an}=or,{Readable:Vd,Writable:ic}=require("stream"),{inherits:Kd,types:{isDate:Ja}}=require("util"),Lg=Buffer[Symbol.species],{bufferCopy:sr,bufferSlice:Zr,makeBufferParser:Ug,writeUInt32BE:G}=xn(),zn={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},Te=Buffer.alloc(28),rt={OK:0,EOF:1,NO_SUCH_FILE:2,PERMISSION_DENIED:3,FAILURE:4,BAD_MESSAGE:5,NO_CONNECTION:6,CONNECTION_LOST:7,OP_UNSUPPORTED:8},$g=new Map(Object.values(rt).map(n=>[n,1])),Fg={[rt.OK]:"No error",[rt.EOF]:"End of file",[rt.NO_SUCH_FILE]:"No such file or directory",[rt.PERMISSION_DENIED]:"Permission denied",[rt.FAILURE]:"Failure",[rt.BAD_MESSAGE]:"Bad message",[rt.NO_CONNECTION]:"No connection",[rt.CONNECTION_LOST]:"Connection lost",[rt.OP_UNSUPPORTED]:"Operation unsupported"},Be={INIT:1,OPEN:3,CLOSE:4,READ:5,WRITE:6,LSTAT:7,FSTAT:8,SETSTAT:9,FSETSTAT:10,OPENDIR:11,READDIR:12,REMOVE:13,MKDIR:14,RMDIR:15,REALPATH:16,STAT:17,RENAME:18,READLINK:19,SYMLINK:20,EXTENDED:200},cn={VERSION:2,STATUS:101,HANDLE:102,DATA:103,NAME:104,ATTRS:105,EXTENDED:201},ke={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},Fd=2*1024,mt=2**32-1,Hg=Buffer.from([0,0,0,5,Be.INIT,0,0,0,3]),Qg=Buffer.from([0,0,0,5,cn.VERSION,0,0,0,3]),Wg=/^SSH-2.0-(?:OpenSSH|dropbear)/,ja=256*1024,Q=Ug(),qg={readable:!1,writable:!1,push:n=>{},once:()=>{},on:()=>{},emit:()=>{},end:()=>{}};function zd(){}var Za=class extends Dg{constructor(t,e,r){super(),(typeof r!="object"||!r)&&(r={});let s=t._protocol._remoteIdentRaw;this.server=!!r.server,this._debug=typeof r.debug=="function"?r.debug:void 0,this._isOpenSSH=s&&Wg.test(s),this._version=-1,this._extensions={},this._biOpt=r.biOpt,this._pktLenBytes=0,this._pktLen=0,this._pktPos=0,this._pktType=0,this._pktData=void 0,this._writeReqid=-1,this._requests={},this._maxInPktLen=ja,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?ja:34e3)-Fd,this._maxWriteLen=(this._isOpenSSH?ja:34e3)-Fd,this.maxOpenHandles=void 0,this._client=t,this._protocol=t._protocol,this._callbacks=[],this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this._waitWindow=!1,this._chunkcb=void 0,this._buffer=[],this.type=e.type,this.subtype=void 0,this.incoming=e.incoming,this.outgoing=e.outgoing,this.stderr=qg,this.readable=!0}push(t){if(t===null){if(Xd(this),!this.readable)return;this.readable=!1,this.emit("end");return}let e=0;for(;e<t.length;){if(this._pktLenBytes<4){let o=Math.min(4-this._pktLenBytes,t.length-e);for(this._pktLenBytes+=o;o--;)this._pktLen=(this._pktLen<<8)+t[e++];if(this._pktLenBytes<4)return;if(this._pktLen===0)return ct(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let a=this._maxInPktLen;return ct(this,`Packet length ${this._pktLen} exceeds max length of ${a}`)}if(e>=t.length)return}if(this._pktPos<this._pktLen){let o=Math.min(this._pktLen-this._pktPos,t.length-e);if(e!==0||o!==t.length?o===this._pktLen?this._pkt=new Lg(t.buffer,t.byteOffset+e,o):(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._pktPos)):o===this._pktLen?this._pkt=t:(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(t,this._pktPos)),e+=o,this._pktPos+=o,this._pktPos<this._pktLen)return}let r=this._pkt[0],s=this._pkt;this._pktLen=0,this._pktLenBytes=0,this._pkt=void 0,this._pktPos=0;let i=this.server?Yg[r]:Gg[r];if(!i)return ct(this,`Unknown packet type ${r}`);if(this._version===-1){if(this.server){if(r!==Be.INIT)return ct(this,`Expected INIT packet, got ${r}`)}else if(r!==cn.VERSION)return ct(this,`Expected VERSION packet, got ${r}`)}if(i(this,s)===!1)return}}end(){this.destroy()}destroy(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._protocol.channelClose(this.outgoing.id))}_init(){this._init=zd,this.server||et(this,Hg)}createReadStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new Gn(this,t,e)}createWriteStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new Sn(this,t,e)}open(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");typeof r=="function"&&(s=r,r=void 0);let i=typeof e=="number"?e:Yd(e);if(i===null)throw new Error(`Unknown flags string: ${e}`);let o=0,a=0;(typeof r=="string"||typeof r=="number")&&(r={mode:r}),typeof r=="object"&&r!==null&&(r=Sr(r),o=r.flags,a=r.nb);let c=Buffer.byteLength(t),l=9,u=Buffer.allocUnsafe(13+c+4+4+a);G(u,u.length-4,0),u[4]=Be.OPEN;let f=this._writeReqid=this._writeReqid+1&mt;G(u,f,5),G(u,c,l),u.utf8Write(t,l+=4,c),G(u,i,l+=c),G(u,o,l+=4),a&&(l+=4,a===Te.length?u.set(Te,l):sr(Te,u,0,a,l),l+=a),this._requests[f]={cb:s};let h=et(this,u);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} OPEN`)}close(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.CLOSE;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} CLOSE`)}read(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(r>=e.length)throw new Error("offset is out of bounds");if(r+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");Gd(this,t,e,r,s,i,o)}readData(t,e,r,s,i,o){this.read(t,e,r,s,i,o)}write(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(r>e.length)throw new Error("offset is out of bounds");if(r+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");if(!s){o&&process.nextTick(o,void 0,0);return}let a=this._maxWriteLen,c=Math.max(s-a,0),l=i;c&&(s=a);let u=t.length,f=9,h=Buffer.allocUnsafe(13+u+8+4+s);G(h,h.length-4,0),h[4]=Be.WRITE;let p=this._writeReqid=this._writeReqid+1&mt;G(h,p,5),G(h,u,f),h.set(t,f+=4),f+=u;for(let E=7;E>=0;--E)h[f+E]=i&255,i/=256;G(h,s,f+=8),sr(e,h,r,r+s,f+=4),this._requests[p]={cb:E=>{E?typeof o=="function"&&o(E):c?this.write(t,e,r+s,c,l+s,o):typeof o=="function"&&o(void 0,r+s)}};let A=et(this,h);if(this._debug){let E=A?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${E} WRITE (id:${p})`)}}writeData(t,e,r,s,i,o){this.write(t,e,r,s,i,o)}fastGet(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");Hd(this,or,t,e,r,s)}fastPut(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");Hd(or,this,t,e,r,s)}readFile(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s;if(typeof r=="function"?s=r:typeof e=="function"&&(s=e,e=void 0),typeof e=="string")e={encoding:e,flag:"r"};else if(!e)e={encoding:null,flag:"r"};else if(typeof e!="object")throw new TypeError("Bad arguments");let i=e.encoding;if(i&&!Buffer.isEncoding(i))throw new Error(`Unknown encoding: ${i}`);let o,a,c,l=0,u,f=0,h=e.flag||"r",p=()=>{o===0?(a=Buffer.allocUnsafe(8192),this.read(u,a,0,8192,f,A)):this.read(u,a,l,o-l,f,A)},A=(b,x)=>{let P;if(b){if(P=b.code===rt.EOF,!P)return this.close(u,()=>s&&s(b))}else P=!1;if(P||o===0&&x===0)return E();f+=x,l+=x,o!==0?l===o?E():p():(c.push(Zr(a,0,x)),p())};A._wantEOFError=!0;let E=()=>{this.close(u,b=>(o===0?a=Buffer.concat(c,l):l<o&&(a=Zr(a,0,l)),i&&(a=a.toString(i)),s&&s(b,a)))};this.open(t,h,438,(b,x)=>{if(b)return s&&s(b);u=x;let P=(q,C)=>{if(q){this.stat(t,($,F)=>{if($)return this.close(u,()=>{s&&s(q)});P(null,F)});return}if(o=C.size||0,o===0)return c=[],p();a=Buffer.allocUnsafe(o),p()};this.fstat(u,P)})}writeFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"w"};else if(!r)r={encoding:"utf8",mode:438,flag:"w"};else if(typeof r!="object")throw new TypeError("Bad arguments");if(r.encoding&&!Buffer.isEncoding(r.encoding))throw new Error(`Unknown encoding: ${r.encoding}`);let o=r.flag||"w";this.open(t,o,r.mode,(a,c)=>{if(a)i&&i(a);else{let l=Buffer.isBuffer(e)?e:Buffer.from(""+e,r.encoding||"utf8"),u=/a/.test(o)?null:0;if(u===null){let f=(h,p)=>{if(h){this.stat(t,(A,E)=>{if(A)return this.close(c,()=>{i&&i(h)});f(null,E)});return}ec(this,c,l,0,l.length,p.size,i)};this.fstat(c,f);return}ec(this,c,l,0,l.length,u,i)}})}appendFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"a"};else if(!r)r={encoding:"utf8",mode:438,flag:"a"};else if(typeof r!="object")throw new TypeError("Bad arguments");r.flag||(r=Object.assign({flag:"a"},r)),this.writeFile(t,e,r,i)}exists(t,e){if(this.server)throw new Error("Client-only method called in server mode");this.stat(t,r=>{e&&e(!r)})}unlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.REMOVE;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REMOVE`)}rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=Buffer.byteLength(e),o=9,a=Buffer.allocUnsafe(13+s+4+i);G(a,a.length-4,0),a[4]=Be.RENAME;let c=this._writeReqid=this._writeReqid+1&mt;G(a,c,5),G(a,s,o),a.utf8Write(t,o+=4,s),G(a,i,o+=s),a.utf8Write(e,o+=4,i),this._requests[c]={cb:r};let l=et(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} RENAME`)}mkdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="function"&&(r=e,e=void 0),typeof e=="object"&&e!==null&&(e=Sr(e),s=e.flags,i=e.nb);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);G(c,c.length-4,0),c[4]=Be.MKDIR;let l=this._writeReqid=this._writeReqid+1&mt;G(c,l,5),G(c,o,a),c.utf8Write(t,a+=4,o),G(c,s,a+=o),i&&(a+=4,i===Te.length?c.set(Te,a):sr(Te,c,0,i,a),a+=i),this._requests[l]={cb:r};let u=et(this,c);this._debug&&this._debug(`SFTP: Outbound: ${u?"Buffered":"Sending"} MKDIR`)}rmdir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.RMDIR;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} RMDIR`)}readdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");typeof e=="function"&&(r=e,e={}),(typeof e!="object"||e===null)&&(e={});let s=!(e&&e.full);if(!Buffer.isBuffer(t)&&typeof t!="string")throw new Error("missing directory handle or path");if(typeof t=="string"){let u=[],f=0,h=(p,A)=>{if(p)return r(p);this.readdir(A,e,(E,b)=>{let x=E&&E.code===rt.EOF;if(E&&!x)return this.close(A,()=>r(E));if(x)return this.close(A,P=>{if(P)return r(P);r(void 0,u)});for(let P=0;P<b.length;++P,++f)u[f]=b[P];h(void 0,A)})};return this.opendir(t,h)}let i=t.length,o=9,a=Buffer.allocUnsafe(13+i);G(a,a.length-4,0),a[4]=Be.READDIR;let c=this._writeReqid=this._writeReqid+1&mt;G(a,c,5),G(a,i,o),a.set(t,o+=4),this._requests[c]={cb:s?(u,f)=>{if(typeof r=="function"){if(u)return r(u);for(let h=f.length-1;h>=0;--h)(f[h].filename==="."||f[h].filename==="..")&&f.splice(h,1);r(void 0,f)}}:r};let l=et(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} READDIR`)}fstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.FSTAT;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} FSTAT`)}stat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.STAT;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STAT`)}lstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.LSTAT;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} LSTAT`)}opendir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.OPENDIR;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} OPENDIR`)}setstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="object"&&e!==null?(e=Sr(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);G(c,c.length-4,0),c[4]=Be.SETSTAT;let l=this._writeReqid=this._writeReqid+1&mt;G(c,l,5),G(c,o,a),c.utf8Write(t,a+=4,o),G(c,s,a+=o),i&&(a+=4,i===Te.length?c.set(Te,a):sr(Te,c,0,i,a),a+=i),this._requests[l]={cb:r};let u=et(this,c);this._debug&&this._debug(`SFTP: Outbound: ${u?"Buffered":"Sending"} SETSTAT`)}fsetstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=0,i=0;typeof e=="object"&&e!==null?(e=Sr(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=t.length,a=9,c=Buffer.allocUnsafe(13+o+4+i);G(c,c.length-4,0),c[4]=Be.FSETSTAT;let l=this._writeReqid=this._writeReqid+1&mt;G(c,l,5),G(c,o,a),c.set(t,a+=4),G(c,s,a+=o),i&&(a+=4,i===Te.length?c.set(Te,a):sr(Te,c,0,i,a),a+=i),this._requests[l]={cb:r};let u=et(this,c);this._debug&&this._debug(`SFTP: Outbound: ${u?"Buffered":"Sending"} FSETSTAT`)}futimes(t,e,r,s){return this.fsetstat(t,{atime:Xr(e),mtime:Xr(r)},s)}utimes(t,e,r,s){return this.setstat(t,{atime:Xr(e),mtime:Xr(r)},s)}fchown(t,e,r,s){return this.fsetstat(t,{uid:e,gid:r},s)}chown(t,e,r,s){return this.setstat(t,{uid:e,gid:r},s)}fchmod(t,e,r){return this.fsetstat(t,{mode:e},r)}chmod(t,e,r){return this.setstat(t,{mode:e},r)}readlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.READLINK;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,l)=>{if(typeof e=="function"){if(c)return e(c);if(!l||!l.length)return e(new Error("Response missing link info"));e(void 0,l[0].filename)}}};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} READLINK`)}symlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),i=Buffer.byteLength(t),o=9,a=Buffer.allocUnsafe(13+s+4+i);G(a,a.length-4,0),a[4]=Be.SYMLINK;let c=this._writeReqid=this._writeReqid+1&mt;G(a,c,5),this._isOpenSSH?(G(a,i,o),a.utf8Write(t,o+=4,i),G(a,s,o+=i),a.utf8Write(e,o+=4,s)):(G(a,s,o),a.utf8Write(e,o+=4,s),G(a,i,o+=s),a.utf8Write(t,o+=4,i)),this._requests[c]={cb:r};let l=et(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} SYMLINK`)}realpath(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.REALPATH;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,l)=>{if(typeof e=="function"){if(c)return e(c);if(!l||!l.length)return e(new Error("Response missing path info"));e(void 0,l[0].filename)}}};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REALPATH`)}ext_openssh_rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=this._extensions["posix-rename@openssh.com"];if(!s||s!=="1")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(41+i+4+o);G(c,c.length-4,0),c[4]=Be.EXTENDED;let l=this._writeReqid=this._writeReqid+1&mt;G(c,l,5),G(c,24,a),c.utf8Write("posix-rename@openssh.com",a+=4,24),G(c,i,a+=24),c.utf8Write(t,a+=4,i),G(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[l]={cb:r};let u=et(this,c);if(this._debug){let f=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} posix-rename@openssh.com`)}}ext_openssh_statvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["statvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(36+s);G(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,5),G(o,19,i),o.utf8Write("statvfs@openssh.com",i+=4,19),G(o,s,i+=19),o.utf8Write(t,i+=4,s),this._requests[a]={extended:"statvfs@openssh.com",cb:e};let c=et(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} statvfs@openssh.com`)}}ext_openssh_fstatvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["fstatvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=t.length,i=9,o=Buffer.allocUnsafe(37+s);G(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,5),G(o,20,i),o.utf8Write("fstatvfs@openssh.com",i+=4,20),G(o,s,i+=20),o.set(t,i+=4),this._requests[a]={extended:"fstatvfs@openssh.com",cb:e};let c=et(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} fstatvfs@openssh.com`)}}ext_openssh_hardlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["hardlink@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(37+i+4+o);G(c,c.length-4,0),c[4]=Be.EXTENDED;let l=this._writeReqid=this._writeReqid+1&mt;G(c,l,5),G(c,20,a),c.utf8Write("hardlink@openssh.com",a+=4,20),G(c,i,a+=20),c.utf8Write(t,a+=4,i),G(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[l]={cb:r};let u=et(this,c);if(this._debug){let f=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} hardlink@openssh.com`)}}ext_openssh_fsync(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["fsync@openssh.com"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=t.length,i=9,o=Buffer.allocUnsafe(34+s);G(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,5),G(o,17,i),o.utf8Write("fsync@openssh.com",i+=4,17),G(o,s,i+=17),o.set(t,i+=4),this._requests[a]={cb:e};let c=et(this,o);this._debug&&this._debug(`SFTP: Outbound: ${c?"Buffered":"Sending"} fsync@openssh.com`)}ext_openssh_lsetstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["lsetstat@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let i=0,o=0;typeof e=="object"&&e!==null?(e=Sr(e),i=e.flags,o=e.nb):typeof e=="function"&&(r=e);let a=Buffer.byteLength(t),c=9,l=Buffer.allocUnsafe(37+a+4+o);G(l,l.length-4,0),l[4]=Be.EXTENDED;let u=this._writeReqid=this._writeReqid+1&mt;G(l,u,5),G(l,20,c),l.utf8Write("lsetstat@openssh.com",c+=4,20),G(l,a,c+=20),l.utf8Write(t,c+=4,a),G(l,i,c+=a),o&&(c+=4,o===Te.length?l.set(Te,c):sr(Te,l,0,o,c),c+=o),this._requests[u]={cb:r};let f=et(this,l);if(this._debug){let h=f?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} lsetstat@openssh.com`)}}ext_openssh_expandPath(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["expand-path@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(40+s);G(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,5),G(o,23,i),o.utf8Write("expand-path@openssh.com",i+=4,23),G(o,s,i+=20),o.utf8Write(t,i+=4,s),this._requests[a]={cb:(l,u)=>{if(typeof e=="function"){if(l)return e(l);if(!u||!u.length)return e(new Error("Response missing expanded path"));e(void 0,u[0].filename)}}};let c=et(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} expand-path@openssh.com`)}}ext_copy_data(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["copy-data"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("Source handle is not a Buffer");if(!Buffer.isBuffer(s))throw new Error("Destination handle is not a Buffer");let c=0,l=Buffer.allocUnsafe(26+t.length+8+8+4+s.length+8);G(l,l.length-4,c),c+=4,l[c]=Be.EXTENDED,++c;let u=this._writeReqid=this._writeReqid+1&mt;G(l,u,c),c+=4,G(l,9,c),c+=4,l.utf8Write("copy-data",c,9),c+=9,G(l,t.length,c),c+=4,l.set(t,c),c+=t.length;for(let h=7;h>=0;--h)l[c+h]=e&255,e/=256;c+=8;for(let h=7;h>=0;--h)l[c+h]=r&255,r/=256;c+=8,G(l,s.length,c),c+=4,l.set(s,c),c+=s.length;for(let h=7;h>=0;--h)l[c+h]=i&255,i/=256;this._requests[u]={cb:o};let f=et(this,l);if(this._debug){let h=f?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} copy-data`)}}ext_home_dir(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["home-directory"]!=="1")throw new Error("Server does not support this extended request");if(typeof t!="string")throw new TypeError("username is not a string");let s=0,i=Buffer.byteLength(t),o=Buffer.allocUnsafe(31+i);G(o,o.length-4,s),s+=4,o[s]=Be.EXTENDED,++s;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,s),s+=4,G(o,14,s),s+=4,o.utf8Write("home-directory",s,14),s+=14,G(o,i,s),s+=4,o.utf8Write(t,s,i),s+=i,this._requests[a]={cb:(l,u)=>{if(typeof e=="function"){if(l)return e(l);if(!u||!u.length)return e(new Error("Response missing home directory"));e(void 0,u[0].filename)}}};let c=et(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} home-directory`)}}ext_users_groups(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["users-groups-by-id@openssh.com"]!=="1")throw new Error("Server does not support this extended request");if(!Array.isArray(t))throw new TypeError("uids is not an array");for(let l of t)if(!Number.isInteger(l)||l<0||l>2**32-1)throw new Error("uid values must all be 32-bit unsigned integers");if(!Array.isArray(e))throw new TypeError("gids is not an array");for(let l of e)if(!Number.isInteger(l)||l<0||l>2**32-1)throw new Error("gid values must all be 32-bit unsigned integers");let i=0,o=Buffer.allocUnsafe(47+4*t.length+4+4*e.length);G(o,o.length-4,i),i+=4,o[i]=Be.EXTENDED,++i;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,i),i+=4,G(o,30,i),i+=4,o.utf8Write("users-groups-by-id@openssh.com",i,30),i+=30,G(o,4*t.length,i),i+=4;for(let l of t)G(o,l,i),i+=4;G(o,4*e.length,i),i+=4;for(let l of e)G(o,l,i),i+=4;this._requests[a]={extended:"users-groups-by-id@openssh.com",cb:r};let c=et(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} users-groups-by-id@openssh.com`)}}handle(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let r=e.length;if(r>256)throw new Error("handle too large (> 256 bytes)");let s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=cn.HANDLE,G(i,t,5),G(i,r,s),r&&i.set(e,s+=4);let o=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${o?"Buffered":"Sending"} HANDLE`)}status(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(!$g.has(e))throw new Error(`Bad status code: ${e}`);r||(r="");let s=Buffer.byteLength(r),i=9,o=Buffer.allocUnsafe(17+s+4);G(o,o.length-4,0),o[4]=cn.STATUS,G(o,t,5),G(o,e,i),G(o,s,i+=4),i+=4,s&&(o.utf8Write(r,i,s),i+=s),G(o,0,i);let a=et(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STATUS`)}data(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");let s=Buffer.isBuffer(e);if(!s&&typeof e!="string")throw new Error("data is not a Buffer or string");let i;!s&&!r&&(r=void 0,i=!0);let o=s?e.length:Buffer.byteLength(e,r),a=9,c=Buffer.allocUnsafe(13+o);G(c,c.length-4,0),c[4]=cn.DATA,G(c,t,5),G(c,o,a),o&&(s?c.set(e,a+=4):i?c.utf8Write(e,a+=4,o):c.write(e,a+=4,o,r));let l=et(this,c);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} DATA`)}name(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Array.isArray(e)){if(typeof e!="object"||e===null)throw new Error("names is not an object or array");e=[e]}let r=e.length,s=0,i,o=[];for(let u=0;u<r;++u){let f=e[u],h=!f||!f.filename||typeof f.filename!="string"?"":f.filename;s+=4+Buffer.byteLength(h);let p=!f||!f.longname||typeof f.longname!="string"?"":f.longname;if(s+=4+Buffer.byteLength(p),typeof f.attrs=="object"&&f.attrs!==null){if(i=Sr(f.attrs),s+=4+i.nb,i.nb){let A;i.nb===Te.length?A=new Uint8Array(Te):(A=new Uint8Array(i.nb),sr(Te,A,0,i.nb,0)),i.bytes=A}o.push(i)}else s+=4,o.push(null)}let a=9,c=Buffer.allocUnsafe(13+s);G(c,c.length-4,0),c[4]=cn.NAME,G(c,t,5),G(c,r,a),a+=4;for(let u=0;u<r;++u){let f=e[u];{let p=!f||!f.filename||typeof f.filename!="string"?"":f.filename,A=Buffer.byteLength(p);G(c,A,a),a+=4,A&&(c.utf8Write(p,a,A),a+=A)}{let p=!f||!f.longname||typeof f.longname!="string"?"":f.longname,A=Buffer.byteLength(p);G(c,A,a),a+=4,A&&(c.utf8Write(p,a,A),a+=A)}let h=o[u];h?(G(c,h.flags,a),a+=4,h.flags&&h.bytes&&(c.set(h.bytes,a),a+=h.nb)):(G(c,0,a),a+=4)}let l=et(this,c);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} NAME`)}attrs(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(typeof e!="object"||e===null)throw new Error("attrs is not an object");e=Sr(e);let r=e.flags,s=e.nb,i=9,o=Buffer.allocUnsafe(13+s);G(o,o.length-4,0),o[4]=cn.ATTRS,G(o,t,5),G(o,r,i),s&&(i+=4,s===Te.length?o.set(Te,i):sr(Te,o,0,s,i),i+=s);let a=et(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} ATTRS`)}};function Vg(n){try{return Buffer.allocUnsafe(n)}catch(t){return t}}function Gd(n,t,e,r,s,i,o,a){let c=n._maxReadLen,l=Math.max(s-c,0);l&&(s=c);let u=t.length,f=9,h=i,p=Buffer.allocUnsafe(13+u+8+4);G(p,p.length-4,0),p[4]=Be.READ;let A=n._writeReqid=n._writeReqid+1&mt;G(p,A,5),G(p,u,f),p.set(t,f+=4),f+=u;for(let x=7;x>=0;--x)p[f+x]=h&255,h/=256;G(p,s,f+=8),typeof o!="function"&&(o=zd);let E=a||{nb:0,position:i,off:r,origOff:r,len:void 0,overflow:void 0,cb:(x,P,q)=>{let C=E.len,$=E.overflow;if(x){if(o._wantEOFError||x.code!==rt.EOF)return o(x)}else{if(q>C)return o(new Error("Received more data than requested"));if(q===C&&$){E.nb+=q,E.position+=q,E.off+=q,Gd(n,t,e,E.off,$,E.position,o,E);return}}q=q||0,E.origOff===0&&e.length===E.nb?P=e:P=Zr(e,E.origOff,E.origOff+E.nb+q),o(void 0,E.nb+q,P,E.position)},buffer:void 0};E.len=s,E.overflow=l,E.buffer=Zr(e,r,r+s),n._requests[A]=E;let b=et(n,p);n._debug&&n._debug(`SFTP: Outbound: ${b?"Buffered":"Sending"} READ`)}function Hd(n,t,e,r,s,i){let o=64,a=32768,c,l,u;typeof s=="function"?i=s:typeof s=="object"&&s!==null&&(typeof s.concurrency=="number"&&s.concurrency>0&&!isNaN(s.concurrency)&&(o=s.concurrency),typeof s.chunkSize=="number"&&s.chunkSize>0&&!isNaN(s.chunkSize)&&(a=s.chunkSize),typeof s.fileSize=="number"&&s.fileSize>0&&!isNaN(s.fileSize)&&(u=s.fileSize),typeof s.step=="function"&&(c=s.step),(typeof s.mode=="string"||typeof s.mode=="number")&&(l=sc(s.mode)));let f,h=0,p=0,A=!1,E,b,x,P=a*o;function q(C){if(A)return;A=!0;let $=0,F;E||b?(F=()=>{--$===0&&i(C)},E&&(n===or||n.outgoing.state==="open")&&++$,b&&(t===or||t.outgoing.state==="open")&&++$,E&&(n===or||n.outgoing.state==="open")&&n.close(E,F),b&&(t===or||t.outgoing.state==="open")&&t.close(b,F)):i(C)}n.open(e,"r",(C,$)=>{if(C)return q(C);E=$,u===void 0?n.fstat(E,F):F(null,{size:u});function F(v,_){if(v){if(n!==or){n.stat(e,(w,k)=>{if(w)return q(v);F(null,k)});return}return q(v)}f=_.size,t.open(r,"w",(w,k)=>{if(w)return q(w);if(b=k,f<=0)return q();for(;P>f;){if(o===1){P=f;break}P-=a,--o}if(x=Vg(P),x instanceof Error)return q(x);l!==void 0?t.fchmod(b,l,function X(re){if(re){t.chmod(r,l,fe=>X());return}j()}):j();function N(X,re,fe,H,B,D){if(X)return q(X);B=B||0,t.write(b,x,B,re,H,z);function z(ne){if(ne)return q(ne);if(p+=re,c&&c(p,re,f),re<D)return ie(B,H+re,D-re);if(p===f){t.close(b,oe=>{if(b=void 0,oe)return q(oe);n.close(E,Je=>{if(E=void 0,Je)return q(Je);i()})});return}if(h>=f)return;let de=h+a>f?f-h:a;ie(B,h,de),h+=de}}function R(X,re,fe){return(H,B,D)=>{N(H,B,D,re,X,fe)}}function ie(X,re,fe){n.read(E,x,X,fe,re,R(X,re,fe))}function j(){let X=0,re=0;for(;h<f&&X<o;){let fe=h+a>f?f-h:a;ie(re,h,fe),re+=fe,h+=fe,++X}}})}})}function ec(n,t,e,r,s,i,o){let a=typeof o=="function"?o:void 0;n.write(t,e,r,s,i,(c,l)=>{if(c)return n.close(t,()=>{a&&a(c)});l===s?n.close(t,a):(r+=l,s-=l,i+=l,ec(n,t,e,r,s,i,a))})}var so=class{constructor(t){this.mode=t&&t.mode,this.uid=t&&t.uid,this.gid=t&&t.gid,this.size=t&&t.size,this.atime=t&&t.atime,this.mtime=t&&t.mtime,this.extended=t&&t.extended}isDirectory(){return(this.mode&an.S_IFMT)===an.S_IFDIR}isFile(){return(this.mode&an.S_IFMT)===an.S_IFREG}isBlockDevice(){return(this.mode&an.S_IFMT)===an.S_IFBLK}isCharacterDevice(){return(this.mode&an.S_IFMT)===an.S_IFCHR}isSymbolicLink(){return(this.mode&an.S_IFMT)===an.S_IFLNK}isFIFO(){return(this.mode&an.S_IFMT)===an.S_IFIFO}isSocket(){return(this.mode&an.S_IFMT)===an.S_IFSOCK}};function Sr(n){let t=0,e=0;if(typeof n=="object"&&n!==null){if(typeof n.size=="number"){t|=zn.SIZE;let r=n.size;Te[e++]=r/72057594037927940,Te[e++]=r/281474976710656,Te[e++]=r/1099511627776,Te[e++]=r/4294967296,Te[e++]=r/16777216,Te[e++]=r/65536,Te[e++]=r/256,Te[e++]=r}if(typeof n.uid=="number"&&typeof n.gid=="number"){t|=zn.UIDGID;let r=n.uid,s=n.gid;Te[e++]=r>>>24,Te[e++]=r>>>16,Te[e++]=r>>>8,Te[e++]=r,Te[e++]=s>>>24,Te[e++]=s>>>16,Te[e++]=s>>>8,Te[e++]=s}if(typeof n.mode=="number"||typeof n.mode=="string"){let r=sc(n.mode);t|=zn.PERMISSIONS,Te[e++]=r>>>24,Te[e++]=r>>>16,Te[e++]=r>>>8,Te[e++]=r}if((typeof n.atime=="number"||Ja(n.atime))&&(typeof n.mtime=="number"||Ja(n.mtime))){let r=Xr(n.atime),s=Xr(n.mtime);t|=zn.ACMODTIME,Te[e++]=r>>>24,Te[e++]=r>>>16,Te[e++]=r>>>8,Te[e++]=r,Te[e++]=s>>>24,Te[e++]=s>>>16,Te[e++]=s>>>8,Te[e++]=s}}return{flags:t,nb:e}}function Xr(n){if(typeof n=="number"&&n===n)return n;if(Ja(n))return parseInt(n.getTime()/1e3,10);throw new Error(`Cannot parse time: ${n}`)}function sc(n){if(typeof n=="number"&&n===n)return n;if(typeof n=="string")return sc(parseInt(n,8));throw new Error(`Cannot parse mode: ${n}`)}var tc={r:ke.READ,"r+":ke.READ|ke.WRITE,w:ke.TRUNC|ke.CREAT|ke.WRITE,wx:ke.TRUNC|ke.CREAT|ke.WRITE|ke.EXCL,xw:ke.TRUNC|ke.CREAT|ke.WRITE|ke.EXCL,"w+":ke.TRUNC|ke.CREAT|ke.READ|ke.WRITE,"wx+":ke.TRUNC|ke.CREAT|ke.READ|ke.WRITE|ke.EXCL,"xw+":ke.TRUNC|ke.CREAT|ke.READ|ke.WRITE|ke.EXCL,a:ke.APPEND|ke.CREAT|ke.WRITE,ax:ke.APPEND|ke.CREAT|ke.WRITE|ke.EXCL,xa:ke.APPEND|ke.CREAT|ke.WRITE|ke.EXCL,"a+":ke.APPEND|ke.CREAT|ke.READ|ke.WRITE,"ax+":ke.APPEND|ke.CREAT|ke.READ|ke.WRITE|ke.EXCL,"xa+":ke.APPEND|ke.CREAT|ke.READ|ke.WRITE|ke.EXCL};function Yd(n){let t=tc[n];return t!==void 0?t:null}var Kg=(()=>{let n=Object.keys(tc);return t=>{for(let e=0;e<n.length;++e){let r=n[e];if(tc[r]===t)return r}return null}})();function Jr(n){let t=Q.readUInt32BE();if(t===void 0)return;let e=new so;if(t&zn.SIZE){let r=Q.readUInt64BE(n);if(r===void 0)return;e.size=r}if(t&zn.UIDGID){let r=Q.readUInt32BE(),s=Q.readUInt32BE();if(s===void 0)return;e.uid=r,e.gid=s}if(t&zn.PERMISSIONS){let r=Q.readUInt32BE();if(r===void 0)return;e.mode=r}if(t&zn.ACMODTIME){let r=Q.readUInt32BE(),s=Q.readUInt32BE();if(s===void 0)return;e.atime=r,e.mtime=s}if(t&zn.EXTENDED){let r=Q.readUInt32BE();if(r===void 0)return;let s={};for(let i=0;i<r;++i){let o=Q.readString(!0),a=Q.readString();if(a===void 0)return;s[o]=a}e.extended=s}return e}function et(n,t){let e=jd(n,t);return e!==void 0?(n._buffer.push(e),!1):!0}function jd(n,t){let e=n.outgoing;if(e.state!=="open")return;if(e.window===0)return n._waitWindow=!0,n._chunkcb=Qd,t;let r,s=t.length,i=0;for(;s-i>0&&e.window>0;){let o=Math.min(s-i,e.window,e.packetSize);e.window-=o,e.window===0&&(n._waitWindow=!0,n._chunkcb=Qd),i===0&&o===s?n._protocol.channelData(n.outgoing.id,t):n._protocol.channelData(n.outgoing.id,Zr(t,i,i+o)),i+=o}return s-i>0&&(i>0?r=Zr(t,i,s):r=t),r}function Qd(){this._chunkcb=void 0;let n=this._buffer,t=0;for(;t<n.length;){let e=n[t],r=jd(this,e);if(r!==void 0){r!==e&&(n[t]=r),t>0&&(this._buffer=n.slice(t));return}++t}t>0&&(this._buffer=[])}function ct(n,t,e){let r=new Error(t);return r.level="sftp-protocol",!e&&n._debug&&n._debug(`SFTP: Inbound: ${t}`),n.emit("error",r),n.destroy(),Xd(n),!1}function Xd(n){let t=Object.keys(n._requests);if(t.length===0)return;let e=n._requests;n._requests={};let r=new Error("No response from server");for(let s=0;s<t.length;++s){let i=e[t[s]];typeof i.cb=="function"&&i.cb(r)}}function zg(n,t){let e=9,r=Buffer.allocUnsafe(31);G(r,r.length-4,0),r[4]=Be.EXTENDED;let s=n._writeReqid=n._writeReqid+1&mt;G(r,s,5),G(r,18,e),r.utf8Write("limits@openssh.com",e+=4,18),n._requests[s]={extended:"limits@openssh.com",cb:t};let i=et(n,r);if(n._debug){let o=i?"Buffered":"Sending";n._debug(`SFTP: Outbound: ${o} limits@openssh.com`)}}var Gg={[cn.VERSION]:(n,t)=>{if(n._version!==-1)return ct(n,"Duplicate VERSION packet");let e={};Q.init(t,1);let r=Q.readUInt32BE();for(;Q.avail();){let s=Q.readString(!0),i=Q.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(Q.clear(),r===void 0)return ct(n,"Malformed VERSION packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received VERSION (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received VERSION (v${r})`)}if(n._version=r,n._extensions=e,e["limits@openssh.com"]==="1")return zg(n,(s,i)=>{s||(i.maxPktLen>0&&(n._maxOutPktLen=i.maxPktLen),i.maxReadLen>0&&(n._maxReadLen=i.maxReadLen),i.maxWriteLen>0&&(n._maxWriteLen=i.maxWriteLen),n.maxOpenHandles=i.maxOpenHandles>0?i.maxOpenHandles:1/0),n.emit("ready")});n.emit("ready")},[cn.STATUS]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readUInt32BE(),s=Q.readString(!0);if(Q.clear(),n._debug){let o=JSON.stringify(s);n._debug(`SFTP: Inbound: Received STATUS (id:${e}, ${r}, ${o})`)}let i=n._requests[e];if(delete n._requests[e],i&&typeof i.cb=="function"){if(r===rt.OK){i.cb();return}let o=new Error(s||Fg[r]||"Unknown status");o.code=r,i.cb(o)}},[cn.HANDLE]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString();if(Q.clear(),r===void 0)return e!==void 0&&delete n._requests[e],ct(n,"Malformed HANDLE packet");n._debug&&n._debug(`SFTP: Inbound: Received HANDLE (id:${e})`);let s=n._requests[e];delete n._requests[e],s&&typeof s.cb=="function"&&s.cb(void 0,r)},[cn.DATA]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r;if(e!==void 0&&(r=n._requests[e],delete n._requests[e]),r&&typeof r.cb=="function")if(r.buffer){let s=Q.readString(r.buffer);if(Q.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`),r.cb(void 0,r.buffer,s);return}}else{let s=Q.readString();if(Q.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s.length})`),r.cb(void 0,s);return}}else{let s=Q.skipString();if(Q.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`);return}}return ct(n,"Malformed DATA packet")},[cn.NAME]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=Q.readUInt32BE();if(s!==void 0){let i=[];for(let o=0;o<s;++o){let a=Q.readString(!0),c=Q.readString(!0),l=Jr(n._biOpt);if(l===void 0){i=void 0;break}i.push({filename:a,longname:c,attrs:l})}if(i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received NAME (id:${e}, ${i.length})`),Q.clear(),r&&typeof r.cb=="function"&&r.cb(void 0,i);return}}return Q.clear(),ct(n,"Malformed NAME packet")},[cn.ATTRS]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=Jr(n._biOpt);if(Q.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received ATTRS (id:${e})`),r&&typeof r.cb=="function"&&r.cb(void 0,s);return}return ct(n,"Malformed ATTRS packet")},[cn.EXTENDED]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE();if(e!==void 0){let r=n._requests[e];if(r)switch(delete n._requests[e],r.extended){case"statvfs@openssh.com":case"fstatvfs@openssh.com":{let s=n._biOpt,i={f_bsize:Q.readUInt64BE(s),f_frsize:Q.readUInt64BE(s),f_blocks:Q.readUInt64BE(s),f_bfree:Q.readUInt64BE(s),f_bavail:Q.readUInt64BE(s),f_files:Q.readUInt64BE(s),f_ffree:Q.readUInt64BE(s),f_favail:Q.readUInt64BE(s),f_sid:Q.readUInt64BE(s),f_flag:Q.readUInt64BE(s),f_namemax:Q.readUInt64BE(s)};if(i.f_namemax===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),Q.clear(),typeof r.cb=="function"&&r.cb(void 0,i);return}case"limits@openssh.com":{let s={maxPktLen:Q.readUInt64BE(),maxReadLen:Q.readUInt64BE(),maxWriteLen:Q.readUInt64BE(),maxOpenHandles:Q.readUInt64BE()};if(s.maxOpenHandles===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),Q.clear(),typeof r.cb=="function"&&r.cb(void 0,s);return}case"users-groups-by-id@openssh.com":{let s=Q.readUInt32BE();if(s===void 0)break;let i=new Array(s);for(let c=0;c<i.length;++c)i[c]=Q.readString(!0);let o=Q.readUInt32BE();if(o===void 0)break;let a=new Array(o);for(let c=0;c<a.length;++c)a[c]=Q.readString(!0);if(a.length>0&&a[a.length-1]===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),Q.clear(),typeof r.cb=="function"&&r.cb(void 0,i,a);return}default:n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),Q.clear(),typeof r.cb=="function"&&r.cb();return}else{n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),Q.clear();return}}return Q.clear(),ct(n,"Malformed EXTENDED_REPLY packet")}},Yg={[Be.INIT]:(n,t)=>{if(n._version!==-1)return ct(n,"Duplicate INIT packet");let e={};Q.init(t,1);let r=Q.readUInt32BE();for(;Q.avail();){let s=Q.readString(!0),i=Q.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(Q.clear(),r===void 0)return ct(n,"Malformed INIT packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received INIT (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received INIT (v${r})`)}et(n,Qg),n._version=r,n._extensions=e,n.emit("ready")},[Be.OPEN]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0),s=Q.readUInt32BE(),i=Jr(n._biOpt);if(Q.clear(),i===void 0)return ct(n,"Malformed OPEN packet");n._debug&&n._debug(`SFTP: Inbound: Received OPEN (id:${e})`),n.emit("OPEN",e,r,s,i)||n.status(e,rt.OP_UNSUPPORTED)},[Be.CLOSE]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString();if(Q.clear(),r===void 0||r.length>256)return ct(n,"Malformed CLOSE packet");n._debug&&n._debug(`SFTP: Inbound: Received CLOSE (id:${e})`),n.emit("CLOSE",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.READ]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(),s=Q.readUInt64BE(n._biOpt),i=Q.readUInt32BE();if(Q.clear(),i===void 0||r.length>256)return ct(n,"Malformed READ packet");n._debug&&n._debug(`SFTP: Inbound: Received READ (id:${e})`),n.emit("READ",e,r,s,i)||n.status(e,rt.OP_UNSUPPORTED)},[Be.WRITE]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(),s=Q.readUInt64BE(n._biOpt),i=Q.readString();if(Q.clear(),i===void 0||r.length>256)return ct(n,"Malformed WRITE packet");n._debug&&n._debug(`SFTP: Inbound: Received WRITE (id:${e})`),n.emit("WRITE",e,r,s,i)||n.status(e,rt.OP_UNSUPPORTED)},[Be.LSTAT]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed LSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received LSTAT (id:${e})`),n.emit("LSTAT",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.FSTAT]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString();if(Q.clear(),r===void 0||r.length>256)return ct(n,"Malformed FSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSTAT (id:${e})`),n.emit("FSTAT",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.SETSTAT]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0),s=Jr(n._biOpt);if(Q.clear(),s===void 0)return ct(n,"Malformed SETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received SETSTAT (id:${e})`),n.emit("SETSTAT",e,r,s)||n.status(e,rt.OP_UNSUPPORTED)},[Be.FSETSTAT]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(),s=Jr(n._biOpt);if(Q.clear(),s===void 0||r.length>256)return ct(n,"Malformed FSETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSETSTAT (id:${e})`),n.emit("FSETSTAT",e,r,s)||n.status(e,rt.OP_UNSUPPORTED)},[Be.OPENDIR]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed OPENDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received OPENDIR (id:${e})`),n.emit("OPENDIR",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.READDIR]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString();if(Q.clear(),r===void 0||r.length>256)return ct(n,"Malformed READDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received READDIR (id:${e})`),n.emit("READDIR",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.REMOVE]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed REMOVE packet");n._debug&&n._debug(`SFTP: Inbound: Received REMOVE (id:${e})`),n.emit("REMOVE",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.MKDIR]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0),s=Jr(n._biOpt);if(Q.clear(),s===void 0)return ct(n,"Malformed MKDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received MKDIR (id:${e})`),n.emit("MKDIR",e,r,s)||n.status(e,rt.OP_UNSUPPORTED)},[Be.RMDIR]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed RMDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received RMDIR (id:${e})`),n.emit("RMDIR",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.REALPATH]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed REALPATH packet");n._debug&&n._debug(`SFTP: Inbound: Received REALPATH (id:${e})`),n.emit("REALPATH",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.STAT]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed STAT packet");n._debug&&n._debug(`SFTP: Inbound: Received STAT (id:${e})`),n.emit("STAT",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.RENAME]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0),s=Q.readString(!0);if(Q.clear(),s===void 0)return ct(n,"Malformed RENAME packet");n._debug&&n._debug(`SFTP: Inbound: Received RENAME (id:${e})`),n.emit("RENAME",e,r,s)||n.status(e,rt.OP_UNSUPPORTED)},[Be.READLINK]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed READLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received READLINK (id:${e})`),n.emit("READLINK",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.SYMLINK]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0),s=Q.readString(!0);if(Q.clear(),s===void 0)return ct(n,"Malformed SYMLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received SYMLINK (id:${e})`);let i;n._isOpenSSH?i=n.emit("SYMLINK",e,s,r):i=n.emit("SYMLINK",e,r,s),i||n.status(e,rt.OP_UNSUPPORTED)},[Be.EXTENDED]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(r===void 0)return Q.clear(),ct(n,"Malformed EXTENDED packet");let s;Q.avail()&&(s=Q.readRaw()),Q.clear(),n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED (id:${e})`),n.emit("EXTENDED",e,r,s)||n.status(e,rt.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:jg,ERR_OUT_OF_RANGE:io,validateNumber:Xg}=$d(),Wd=128,nn,nc=[];function Jg(n){nc.length>0?nn=nc.pop():nn=Buffer.allocUnsafe(n),nn.used=0}function rc(n,t){if(!Number.isSafeInteger(n))throw Xg(n,t),Number.isInteger(n)?new io(t,">= 0 and <= 2 ** 53 - 1",n):new io(t,"an integer",n);if(n<0)throw new io(t,">= 0 and <= 2 ** 53 - 1",n)}function Xa(n){return n+7&-8}function Gn(n,t,e){if(e===void 0)e={};else if(typeof e=="string")e={encoding:e};else{if(e===null||typeof e!="object")throw new TypeError('"options" argument must be a string or an object');e=Object.create(e)}if(e.highWaterMark===void 0&&(e.highWaterMark=64*1024),e.emitClose=!1,e.autoDestroy=!1,Vd.call(this,e),this.path=t,this.flags=e.flags===void 0?"r":e.flags,this.mode=e.mode===void 0?438:e.mode,this.start=e.start,this.end=e.end,this.autoClose=e.autoClose===void 0?!0:e.autoClose,this.pos=0,this.bytesRead=0,this.isClosed=!1,this.handle=e.handle===void 0?null:e.handle,this.sftp=n,this._opening=!1,this.start!==void 0&&(rc(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(rc(this.end,"end"),this.start!==void 0&&this.start>this.end))throw new io("start",`<= "end" (here: ${this.end})`,this.start);this.on("end",function(){this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}Kd(Gn,Vd);Gn.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t,this.emit("open",t),this.emit("ready"),this.read()}))};Gn.prototype._read=function(n){if(!Buffer.isBuffer(this.handle))return this.once("open",()=>this._read(n));if(this.destroyed)return;(!nn||nn.length-nn.used<Wd)&&Jg(this.readableHighWaterMark||this._readableState.highWaterMark);let t=nn,e=Math.min(nn.length-nn.used,n),r=nn.used;if(this.end!==void 0&&(e=Math.min(this.end-this.pos+1,e)),e<=0)return this.push(null);this.sftp.read(this.handle,nn,nn.used,e,this.pos,(s,i)=>{if(s){this.emit("error",s),this.autoClose&&this.destroy();return}let o=null;if(r+e===t.used&&t===nn)t.used=Xa(t.used+i-e);else{let a=r+e&-8,c=Xa(r+i);a-c>=Wd&&nc.push(t.slice(c,a))}i>0&&(this.bytesRead+=i,o=t.slice(r,r+i)),this.pos+=i,this.push(o)}),nn.used=Xa(nn.used+e)};Gn.prototype._destroy=function(n,t){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",qd.bind(null,this,t,n));return}qd(this,t,n),this.handle=null,this._opening=!1};function qd(n,t,e){if(!n.handle)return r();n.sftp.close(n.handle,r);function r(s){s=s||e,t(s),n.isClosed=!0,s||n.emit("close")}}Gn.prototype.close=function(n){this.destroy(null,n)};Object.defineProperty(Gn.prototype,"pending",{get(){return this.handle===null},configurable:!0});function Sn(n,t,e){if(e===void 0)e={};else if(typeof e=="string")e={encoding:e};else{if(e===null||typeof e!="object")throw new TypeError('"options" argument must be a string or an object');e=Object.create(e)}e.emitClose=!1,e.autoDestroy=!1,ic.call(this,e),this.path=t,this.flags=e.flags===void 0?"w":e.flags,this.mode=e.mode===void 0?438:e.mode,this.start=e.start,this.autoClose=e.autoClose===void 0?!0:e.autoClose,this.pos=0,this.bytesWritten=0,this.isClosed=!1,this.handle=e.handle===void 0?null:e.handle,this.sftp=n,this._opening=!1,this.start!==void 0&&(rc(this.start,"start"),this.pos=this.start),e.encoding&&this.setDefaultEncoding(e.encoding),this.on("finish",function(){this._writableState.finalCalled||this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}Kd(Sn,ic);Sn.prototype._final=function(n){this.autoClose&&this.destroy(),n()};Sn.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t;let e=r=>{if(r){this.sftp.chmod(this.path,this.mode,s=>e());return}if(this.flags[0]==="a"){let s=(i,o)=>{if(i){this.sftp.stat(this.path,(a,c)=>{if(a){this.destroy(),this.emit("error",i);return}s(null,c)});return}this.pos=o.size,this.emit("open",t),this.emit("ready")};this.sftp.fstat(t,s);return}this.emit("open",t),this.emit("ready")};this.sftp.fchmod(t,this.mode,e)}))};Sn.prototype._write=function(n,t,e){if(!Buffer.isBuffer(n)){let r=new jg("data","Buffer",n);return this.emit("error",r)}if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._write(n,t,e)});this.sftp.write(this.handle,n,0,n.length,this.pos,(r,s)=>{if(r)return this.autoClose&&this.destroy(),e(r);this.bytesWritten+=s,e()}),this.pos+=n.length};Sn.prototype._writev=function(n,t){if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._writev(n,t)});let e=this.sftp,r=this.handle,s=n.length,i=(o,a)=>{if(o)return this.destroy(),t(o);this.bytesWritten+=a,--s===0&&t()};for(let o=0;o<n.length;++o){let a=n[o].chunk;e.write(r,a,0,a.length,this.pos,i),this.pos+=a.length}};typeof ic.prototype.destroy!="function"&&(Sn.prototype.destroy=Gn.prototype.destroy);Sn.prototype._destroy=Gn.prototype._destroy;Sn.prototype.close=function(n){if(n){if(this.isClosed){process.nextTick(n);return}this.on("close",n)}this.autoClose||this.on("finish",this.destroy.bind(this)),this.end()};Sn.prototype.destroySoon=Sn.prototype.end;Object.defineProperty(Sn.prototype,"pending",{get(){return this.handle===null},configurable:!0});Jd.exports={flagsToString:Kg,OPEN_MODE:ke,SFTP:Za,Stats:so,STATUS_CODE:rt,stringToFlags:Yd}});var fc=ut((Wx,nh)=>{"use strict";var{Duplex:Zg,Readable:eA,Writable:tA}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:Zd}}=qn(),{bufferSlice:oo}=xn(),nA=32*1024,Qi=2*1024*1024,lc=Qi/2,oc=class extends eA{constructor(t,e){super(e),this._channel=t}_read(t){this._channel._waitChanDrain&&(this._channel._waitChanDrain=!1,this._channel.incoming.window<=lc&&uc(this._channel))}},ac=class extends tA{constructor(t){super({highWaterMark:Qi}),this._channel=t}_write(t,e,r){let s=this._channel,i=s._client._protocol,o=s.outgoing,a=o.packetSize,c=o.id,l=o.window,u=t.length,f=0;if(o.state==="open"){for(;u-f>0&&l>0;){let h=u-f;h>l&&(h=l),h>a&&(h=a),f===0&&h===u?i.channelExtData(c,t,Zd):i.channelExtData(c,oo(t,f,f+h),Zd),f+=h,l-=h}if(o.window=l,u-f>0){l===0&&(s._waitWindow=!0),f>0?s._chunkErr=oo(t,f,u):s._chunkErr=t,s._chunkcbErr=r;return}r()}}},cc=class extends Zg{constructor(t,e,r){let s={highWaterMark:Qi,allowHalfOpen:!r||r&&r.allowHalfOpen!==!1,emitClose:!1};super(s),this.allowHalfOpen=s.allowHalfOpen;let i=!!(r&&r.server);this.server=i,this.type=e.type,this.subtype=void 0,this.incoming=e.incoming,this.outgoing=e.outgoing,this._callbacks=[],this._client=t,this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this.stdin=this.stdout=this,i?this.stderr=new ac(this):this.stderr=new oc(this,s),this._waitWindow=!1,this._waitChanDrain=!1,this._chunk=void 0,this._chunkcb=void 0,this._chunkErr=void 0,this._chunkcbErr=void 0,this.on("finish",eh).on("prefinish",eh),this.on("end",th).on("close",th)}_read(t){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=lc&&uc(this))}_write(t,e,r){let s=this._client._protocol,i=this.outgoing,o=i.packetSize,a=i.id,c=i.window,l=t.length,u=0;if(i.state==="open"){for(;l-u>0&&c>0;){let f=l-u;f>c&&(f=c),f>o&&(f=o),u===0&&f===l?s.channelData(a,t):s.channelData(a,oo(t,u,u+f)),u+=f,c-=f}if(i.window=c,l-u>0){c===0&&(this._waitWindow=!0),u>0?this._chunk=oo(t,u,l):this._chunk=t,this._chunkcb=r;return}r()}}eof(){this.outgoing.state==="open"&&(this.outgoing.state="eof",this._client._protocol.channelEOF(this.outgoing.id))}close(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._client._protocol.channelClose(this.outgoing.id))}destroy(){return this.end(),this.close(),this}setWindow(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&(this.subtype==="shell"||this.subtype==="exec")&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.windowChange(this.outgoing.id,t,e,r,s)}signal(t){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.signal(this.outgoing.id,t)}exit(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&(typeof t=="number"?this._client._protocol.exitStatus(this.outgoing.id,t):this._client._protocol.exitSignal(this.outgoing.id,t,e,r))}};function eh(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}function th(){this.readable=!1}function uc(n){if(n.outgoing.state==="closed")return;let t=Qi-n.incoming.window;t<=0||(n.incoming.window+=t,n._client._protocol.channelWindowAdjust(n.outgoing.id,t))}nh.exports={Channel:cc,MAX_WINDOW:Qi,PACKET_SIZE:nA,windowAdjust:uc,WINDOW_THRESHOLD:lc}});var pc=ut((qx,sh)=>{"use strict";var{SFTP:rA}=Hi(),Wi=2**32-1;function rh(n,t,e,r){if(n._chanMgr.remove(t),typeof r!="function")return;let s;e instanceof Error?s=e:typeof e=="object"&&e!==null?(s=new Error(`(SSH) Channel open failure: ${e.description}`),s.reason=e.reason):(s=new Error("(SSH) Channel open failure: server closed channel unexpectedly"),s.reason=""),r(s)}function ih(n,t,e,r,s){if(typeof e=="function"){rh(n,t,r,e);return}if(typeof e!="object"||e===null||e.incoming&&e.incoming.state==="closed"||(n._chanMgr.remove(t),e.server&&e.constructor.name==="Session"))return;e.incoming.state="closed",e.readable&&e.push(null),e.server?e.stderr.writable&&e.stderr.end():e.stderr.readable&&e.stderr.push(null),e.constructor!==rA&&(e.outgoing.state==="open"||e.outgoing.state==="eof")&&!s&&e.close(),e.outgoing.state==="closing"&&(e.outgoing.state="closed");let i=e._readableState,o=e._writableState;o&&!o.ending&&!o.finished&&!s&&e.end();let a=e._callbacks;e._callbacks=[];for(let c=0;c<a.length;++c)a[c](!0);if(e.server)!e.readable||e.destroyed||i&&i.endEmitted?e.emit("close"):e.once("end",()=>e.emit("close"));else{let c;switch(e.type){case"direct-streamlocal@openssh.com":case"direct-tcpip":c=()=>e.emit("close");break;default:{let u=e._exit;c=()=>{u.code===null?e.emit("close",u.code,u.signal,u.dump,u.desc):e.emit("close",u.code)}}}!e.readable||e.destroyed||i&&i.endEmitted?c():e.once("end",c);let l=e.stderr._readableState;!e.stderr.readable||e.stderr.destroyed||l&&l.endEmitted?e.stderr.emit("close"):e.stderr.once("end",()=>e.stderr.emit("close"))}}var hc=class{constructor(t){this._client=t,this._channels={},this._cur=-1,this._count=0}add(t){let e;if(this._cur<Wi)e=++this._cur;else if(this._count===0)this._cur=0,e=0;else{let r=this._channels;for(let s=0;s<Wi;++s)if(r[s]===void 0){e=s;break}}return e===void 0?-1:(this._channels[e]=t||!0,++this._count,e)}update(t,e){if(typeof t!="number"||t<0||t>=Wi||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);e&&this._channels[t]&&(this._channels[t]=e)}get(t){if(typeof t!="number"||t<0||t>=Wi||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);return this._channels[t]}remove(t){if(typeof t!="number"||t<0||t>=Wi||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);this._channels[t]&&(delete this._channels[t],this._count&&--this._count)}cleanup(t){let e=this._channels;this._channels={},this._cur=-1,this._count=0;let r=Object.keys(e),s=this._client;for(let i=0;i<r.length;++i){let o=+r[i],a=e[o];ih(s,o,a._channel||a,t,!0)}}},dc=(()=>{let n=Object.prototype.toString;return t=>n.call(t)==="[object RegExp]"})();function iA(n,t,e){if(Array.isArray(n)&&n.length>0){for(let r=0;r<n.length;++r)if(e.indexOf(n[r])===-1)throw new Error(`Unsupported algorithm: ${n[r]}`);return n}if(typeof n=="object"&&n!==null){let r=Object.keys(n),s=t;for(let i=0;i<r.length;++i){let o=r[i],a=n[o];switch(o){case"append":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let l=a[c];if(typeof l=="string"){if(!l||s.indexOf(l)!==-1)continue;if(e.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);s===t&&(s=s.slice()),s.push(l)}else if(dc(l))for(let u=0;u<e.length;++u){let f=e[u];if(l.test(f)){if(s.indexOf(f)!==-1)continue;s===t&&(s=s.slice()),s.push(f)}}}break;case"prepend":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=a.length;c>=0;--c){let l=a[c];if(typeof l=="string"){if(!l||s.indexOf(l)!==-1)continue;if(e.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);s===t&&(s=s.slice()),s.unshift(l)}else if(dc(l))for(let u=e.length;u>=0;--u){let f=e[u];if(l.test(f)){if(s.indexOf(f)!==-1)continue;s===t&&(s=s.slice()),s.unshift(f)}}}break;case"remove":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let l=a[c];if(typeof l=="string"){if(!l)continue;let u=s.indexOf(l);if(u===-1)continue;s===t&&(s=s.slice()),s.splice(u,1)}else if(dc(l))for(let u=0;u<s.length;++u)l.test(s[u])&&(s===t&&(s=s.slice()),s.splice(u,1),--u)}break}}return s}return t}sh.exports={ChannelManager:hc,generateAlgorithmList:iA,onChannelOpenFailure:rh,onCHANNEL_CLOSE:ih,isWritable:n=>n&&n.writable&&n._readableState&&n._readableState.ended===!1}});var _c=ut((Vx,Ih)=>{"use strict";var{createHash:sA,getHashes:oA,randomFillSync:aA}=require("crypto"),{Socket:cA}=require("net"),{lookup:lA}=require("dns"),uA=require("events"),fA=oA(),{COMPAT:bh,CHANNEL_EXTENDED_DATATYPE:{STDERR:dA},CHANNEL_OPEN_FAILURE:qi,DEFAULT_CIPHER:oh,DEFAULT_COMPRESSION:ah,DEFAULT_KEX:ch,DEFAULT_MAC:lh,DEFAULT_SERVER_HOST_KEY:uh,DISCONNECT_REASON:fh,DISCONNECT_REASON_BY_VALUE:hA,SUPPORTED_CIPHER:pA,SUPPORTED_COMPRESSION:mA,SUPPORTED_KEX:gA,SUPPORTED_MAC:AA,SUPPORTED_SERVER_HOST_KEY:yA}=qn(),{init:EA}=tr(),SA=Ya(),{parseKey:lo}=ir(),{SFTP:_A}=Hi(),{bufferCopy:dh,makeBufferParser:xh,makeError:bA,readUInt32BE:xA,sigSSHToASN1:wA,writeUInt32BE:mc}=xn(),{AgentContext:hh,createAgent:ph,isAgent:mh}=Oa(),{Channel:wh,MAX_WINDOW:uo,PACKET_SIZE:fo,windowAdjust:gh,WINDOW_THRESHOLD:Ah}=fc(),{ChannelManager:IA,generateAlgorithmList:Vi,isWritable:Lt,onChannelOpenFailure:CA,onCHANNEL_CLOSE:kA}=pc(),ao=xh(),co=xh(),Ki=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,Ec=n=>{},Sc=class extends uA{constructor(){super(),this.config={host:void 0,port:void 0,localAddress:void 0,localPort:void 0,forceIPv4:void 0,forceIPv6:void 0,keepaliveCountMax:void 0,keepaliveInterval:void 0,readyTimeout:void 0,ident:void 0,username:void 0,password:void 0,privateKey:void 0,tryKeyboard:void 0,agent:void 0,allowAgentFwd:void 0,authHandler:void 0,hostHashAlgo:void 0,hostHashCb:void 0,strictVendor:void 0,debug:void 0},this._agent=void 0,this._readyTimeout=void 0,this._chanMgr=void 0,this._callbacks=void 0,this._forwarding=void 0,this._forwardingUnix=void 0,this._acceptX11=void 0,this._agentFwdEnabled=void 0,this._remoteVer=void 0,this._protocol=void 0,this._sock=void 0,this._resetKA=void 0}connect(t){if(this._sock&&Lt(this._sock))return this.once("close",()=>{this.connect(t)}),this.end(),this;this.config.host=t.hostname||t.host||"localhost",this.config.port=t.port||22,this.config.localAddress=typeof t.localAddress=="string"?t.localAddress:void 0,this.config.localPort=typeof t.localPort=="string"||typeof t.localPort=="number"?t.localPort:void 0,this.config.forceIPv4=t.forceIPv4||!1,this.config.forceIPv6=t.forceIPv6||!1,this.config.keepaliveCountMax=typeof t.keepaliveCountMax=="number"&&t.keepaliveCountMax>=0?t.keepaliveCountMax:3,this.config.keepaliveInterval=typeof t.keepaliveInterval=="number"&&t.keepaliveInterval>0?t.keepaliveInterval:0,this.config.readyTimeout=typeof t.readyTimeout=="number"&&t.readyTimeout>=0?t.readyTimeout:2e4,this.config.ident=typeof t.ident=="string"||Buffer.isBuffer(t.ident)?t.ident:void 0;let e={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:[]},sc:void 0},r=!0;if(typeof t.algorithms=="object"&&t.algorithms!==null&&(e.kex=Vi(t.algorithms.kex,ch,gA),e.kex!==ch&&(r=!1),e.serverHostKey=Vi(t.algorithms.serverHostKey,uh,yA),e.serverHostKey!==uh&&(r=!1),e.cs.cipher=Vi(t.algorithms.cipher,oh,pA),e.cs.cipher!==oh&&(r=!1),e.cs.mac=Vi(t.algorithms.hmac,lh,AA),e.cs.mac!==lh&&(r=!1),e.cs.compress=Vi(t.algorithms.compress,ah,mA),e.cs.compress!==ah&&(r=!1),r||(e.sc=e.cs)),typeof t.username=="string")this.config.username=t.username;else if(typeof t.user=="string")this.config.username=t.user;else throw new Error("Invalid username");this.config.password=typeof t.password=="string"?t.password:void 0,this.config.privateKey=typeof t.privateKey=="string"||Buffer.isBuffer(t.privateKey)?t.privateKey:void 0,this.config.localHostname=typeof t.localHostname=="string"?t.localHostname:void 0,this.config.localUsername=typeof t.localUsername=="string"?t.localUsername:void 0,this.config.tryKeyboard=t.tryKeyboard===!0,typeof t.agent=="string"&&t.agent.length?this.config.agent=ph(t.agent):mh(t.agent)?this.config.agent=t.agent:this.config.agent=void 0,this.config.allowAgentFwd=t.agentForward===!0&&this.config.agent!==void 0;let s=this.config.authHandler=typeof t.authHandler=="function"||Array.isArray(t.authHandler)?t.authHandler:void 0;this.config.strictVendor=typeof t.strictVendor=="boolean"?t.strictVendor:!0;let i=this.config.debug=typeof t.debug=="function"?t.debug:void 0;if(t.agentForward===!0&&!this.config.allowAgentFwd)throw new Error("You must set a valid agent path to allow agent forwarding");let o=this._callbacks=[];this._chanMgr=new IA(this),this._forwarding={},this._forwardingUnix={},this._acceptX11=0,this._agentFwdEnabled=!1,this._agent=this.config.agent?this.config.agent:void 0,this._remoteVer=void 0;let a;if(this.config.privateKey){if(a=lo(this.config.privateKey,t.passphrase),a instanceof Error)throw new Error(`Cannot parse privateKey: ${a.message}`);if(Array.isArray(a)&&(a=a[0]),a.getPrivatePEM()===null)throw new Error("privateKey value does not contain a (valid) private key")}let c;if(typeof t.hostVerifier=="function"){let H=t.hostVerifier,B;fA.indexOf(t.hostHash)!==-1&&(B=t.hostHash),c=(D,z)=>{B&&(D=sA(B).update(D).digest("hex"));let ne=H(D,z);ne!==void 0&&z(ne)}}let l=this._sock=t.sock||new cA,u=!1,f=!1;this._protocol&&this._protocol.cleanup();let h=i?(H,B,D)=>{i(`Debug output from server: ${JSON.stringify(D)}`)}:void 0,p,A=this._protocol=new SA({ident:this.config.ident,offer:r?void 0:e,onWrite:H=>{Lt(l)&&l.write(H)},onError:H=>{H.level==="handshake"&&clearTimeout(this._readyTimeout),A._destruct||l.removeAllListeners("data"),this.emit("error",H);try{l.end()}catch{}},onHeader:H=>{f=!0,this._remoteVer=H.versions.software,H.greeting&&this.emit("greeting",H.greeting)},onHandshakeComplete:H=>{this.emit("handshake",H),u||(u=!0,A.service("ssh-userauth"))},debug:i,hostVerifier:c,messageHandlers:{DEBUG:h,DISCONNECT:(H,B,D)=>{if(B!==fh.BY_APPLICATION){D||(D=hA[B],D===void 0&&(D=`Unexpected disconnection reason: ${B}`));let z=new Error(D);z.code=B,this.emit("error",z)}l.end()},SERVICE_ACCEPT:(H,B)=>{B==="ssh-userauth"&&X()},EXT_INFO:(H,B)=>{if(p===void 0){for(let D of B)if(D.name==="server-sig-algs"){p=D.algs;return}p=null}},USERAUTH_BANNER:(H,B)=>{this.emit("banner",B)},USERAUTH_SUCCESS:H=>{C(),clearTimeout(this._readyTimeout),this.emit("ready")},USERAUTH_FAILURE:(H,B,D)=>{if(_.keyAlgos){let z=_.keyAlgos[0][0];if(i&&i(`Client: ${_.type} (${z}) auth failed`),_.keyAlgos.shift(),_.keyAlgos.length){let[ne,de]=_.keyAlgos[0];switch(_.type){case"agent":A.authPK(_.username,_.agentCtx.currentKey(),ne);return;case"publickey":A.authPK(_.username,_.key,ne);return;case"hostbased":A.authHostbased(_.username,_.key,_.localHostname,_.localUsername,ne,(oe,Je)=>{let ht=_.key.sign(oe,de);if(ht instanceof Error)return ht.message=`Error while signing with key: ${ht.message}`,ht.level="client-authentication",this.emit("error",ht),X();Je(ht)});return}}else _.keyAlgos=void 0}if(_.type==="agent"){let z=_.agentCtx.pos();return i&&i(`Client: Agent key #${z+1} failed`),re()}i&&i(`Client: ${_.type} auth failed`),w=D,k=B,X()},USERAUTH_PASSWD_CHANGEREQ:(H,B)=>{_.type==="password"&&this.emit("change password",B,D=>{A.authPassword(this.config.username,this.config.password,D)})},USERAUTH_PK_OK:H=>{let B,D;if(_.keyAlgos&&([B,D]=_.keyAlgos[0]),_.type==="agent"){let z=_.agentCtx.currentKey();A.authPK(_.username,z,B,(ne,de)=>{let oe={hash:D};_.agentCtx.sign(z,ne,oe,(Je,ht)=>{if(Je)Je.level="agent",this.emit("error",Je);else return de(ht);re()})})}else _.type==="publickey"&&A.authPK(_.username,_.key,B,(z,ne)=>{let de=_.key.sign(z,D);if(de instanceof Error)return de.message=`Error signing data with key: ${de.message}`,de.level="client-authentication",this.emit("error",de),X();ne(de)})},USERAUTH_INFO_REQUEST:(H,B,D,z)=>{if(_.type==="keyboard-interactive"){if((Array.isArray(z)?z.length:0)===0){i&&i("Client: Sending automatic USERAUTH_INFO_RESPONSE"),A.authInfoRes();return}_.prompt(B,D,"",z,de=>{A.authInfoRes(de)})}},REQUEST_SUCCESS:(H,B)=>{o.length&&o.shift()(!1,B)},REQUEST_FAILURE:H=>{o.length&&o.shift()(!0)},GLOBAL_REQUEST:(H,B,D,z)=>{B==="hostkeys-00@openssh.com"?(PA(this,z,(ne,de)=>{ne||this.emit("hostkeys",de)}),D&&A.requestSuccess()):D&&A.requestFailure()},CHANNEL_OPEN:(H,B)=>{BA(this,B)},CHANNEL_OPEN_CONFIRMATION:(H,B)=>{let D=this._chanMgr.get(B.recipient);if(typeof D!="function")return;let z=D.type==="sftp",de={type:z?"session":D.type,incoming:{id:B.recipient,window:uo,packetSize:fo,state:"open"},outgoing:{id:B.sender,window:B.window,packetSize:B.packetSize,state:"open"}},oe=z?new _A(this,de,{debug:i}):new wh(this,de);this._chanMgr.update(B.recipient,oe),D(void 0,oe)},CHANNEL_OPEN_FAILURE:(H,B,D,z)=>{let ne=this._chanMgr.get(B);if(typeof ne!="function")return;CA(this,B,{reason:D,description:z},ne)},CHANNEL_DATA:(H,B,D)=>{let z=this._chanMgr.get(B);if(!(typeof z!="object"||z===null)&&z.incoming.window!==0){if(z.incoming.window-=D.length,z.push(D)===!1){z._waitChanDrain=!0;return}z.incoming.window<=Ah&&gh(z)}},CHANNEL_EXTENDED_DATA:(H,B,D,z)=>{if(z!==dA)return;let ne=this._chanMgr.get(B);if(!(typeof ne!="object"||ne===null)&&ne.incoming.window!==0){if(ne.incoming.window-=D.length,!ne.stderr.push(D)){ne._waitChanDrain=!0;return}ne.incoming.window<=Ah&&gh(ne)}},CHANNEL_WINDOW_ADJUST:(H,B,D)=>{let z=this._chanMgr.get(B);typeof z!="object"||z===null||(z.outgoing.window+=D,z._waitWindow&&(z._waitWindow=!1,z._chunk?z._write(z._chunk,null,z._chunkcb):z._chunkcb?z._chunkcb():z._chunkErr?z.stderr._write(z._chunkErr,null,z._chunkcbErr):z._chunkcbErr&&z._chunkcbErr()))},CHANNEL_SUCCESS:(H,B)=>{let D=this._chanMgr.get(B);typeof D!="object"||D===null||(this._resetKA(),D._callbacks.length&&D._callbacks.shift()(!1))},CHANNEL_FAILURE:(H,B)=>{let D=this._chanMgr.get(B);typeof D!="object"||D===null||(this._resetKA(),D._callbacks.length&&D._callbacks.shift()(!0))},CHANNEL_REQUEST:(H,B,D,z,ne)=>{let de=this._chanMgr.get(B);if(typeof de!="object"||de===null)return;let oe=de._exit;if(oe.code===void 0){switch(D){case"exit-status":de.emit("exit",oe.code=ne);return;case"exit-signal":de.emit("exit",oe.code=null,oe.signal=`SIG${ne.signal}`,oe.dump=ne.coreDumped,oe.desc=ne.errorMessage);return}z&&H.channelFailure(de.outgoing.id)}},CHANNEL_EOF:(H,B)=>{let D=this._chanMgr.get(B);typeof D!="object"||D===null||D.incoming.state==="open"&&(D.incoming.state="eof",D.readable&&D.push(null),D.stderr.readable&&D.stderr.push(null))},CHANNEL_CLOSE:(H,B)=>{kA(this,B,this._chanMgr.get(B))}}});l.pause();let E=this.config.keepaliveInterval,b=this.config.keepaliveCountMax,x=0,P,q=()=>{if(++x>b){if(clearInterval(P),l.readable){let H=new Error("Keepalive timeout");H.level="client-timeout",this.emit("error",H),l.destroy()}return}Lt(l)?(o.push(C),A.ping()):clearInterval(P)};function C(){E>0&&(x=0,clearInterval(P),Lt(l)&&(P=setInterval(q,E)))}this._resetKA=C;let $=(()=>{let H=!1;return()=>{if(!H&&(H=!0,v&&!f)){let B=bA("Connection lost before handshake","protocol",!0);this.emit("error",B)}}})(),F=(()=>{let H=!1;return()=>{H||(H=!0,v=!0,i&&i("Socket connected"),this.emit("connect"),EA.then(()=>{A.start(),l.on("data",B=>{try{A.parse(B,0,B.length)}catch(D){this.emit("error",D);try{Lt(l)&&l.end()}catch{}}}),l.stderr&&typeof l.stderr.resume=="function"&&l.stderr.resume(),l.resume()}).catch(B=>{this.emit("error",B);try{Lt(l)&&l.end()}catch{}}))}})(),v=!1;l.on("connect",F).on("timeout",()=>{this.emit("timeout")}).on("error",H=>{i&&i(`Socket error: ${H.message}`),clearTimeout(this._readyTimeout),H.level="client-socket",this.emit("error",H)}).on("end",()=>{i&&i("Socket ended"),$(),A.cleanup(),clearTimeout(this._readyTimeout),clearInterval(P),this.emit("end")}).on("close",()=>{i&&i("Socket closed"),$(),A.cleanup(),clearTimeout(this._readyTimeout),clearInterval(P),this.emit("close");let H=o;o=this._callbacks=[];let B=new Error("No response from server");for(let D=0;D<H.length;++D)H[D](B);this._chanMgr.cleanup(B)});let _,w=null,k=null,N=["none"];this.config.password!==void 0&&N.push("password"),a!==void 0&&N.push("publickey"),this._agent!==void 0&&N.push("agent"),this.config.tryKeyboard&&N.push("keyboard-interactive"),a!==void 0&&this.config.localHostname!==void 0&&this.config.localUsername!==void 0&&N.push("hostbased"),Array.isArray(s)?s=_h(s):typeof s!="function"&&(s=_h(N));let R=!1,ie=H=>{if(!R){if(R=!0,H===!1){let B=new Error("All configured authentication methods failed");B.level="client-authentication",this.emit("error",B),this.end();return}if(typeof H=="string"){let B=H;if(N.indexOf(B)===-1)return j(`Authentication method not allowed: ${B}`);let D=this.config.username;switch(B){case"password":H={type:B,username:D,password:this.config.password};break;case"publickey":H={type:B,username:D,key:a};break;case"hostbased":H={type:B,username:D,key:a,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":H={type:B,username:D,agentCtx:new hh(this._agent)};break;case"keyboard-interactive":H={type:B,username:D,prompt:(...z)=>this.emit("keyboard-interactive",...z)};break;case"none":H={type:B,username:D};break;default:return j(`Skipping unsupported authentication method: ${H}`)}}else{if(typeof H!="object"||H===null)return j(`Skipping invalid authentication attempt: ${H}`);{let B=H.username;if(typeof B!="string")return j(`Skipping invalid authentication attempt: ${H}`);let D=H.type;switch(D){case"password":{let{password:z}=H;if(typeof z!="string"&&!Buffer.isBuffer(z))return j("Skipping invalid password auth attempt");H={type:D,username:B,password:z};break}case"publickey":{let z=lo(H.key,H.passphrase);if(z instanceof Error)return j("Skipping invalid key auth attempt");if(!z.isPrivateKey())return j("Skipping non-private key");H={type:D,username:B,key:z};break}case"hostbased":{let{localHostname:z,localUsername:ne}=H,de=lo(H.key,H.passphrase);if(de instanceof Error||typeof z!="string"||typeof ne!="string")return j("Skipping invalid hostbased auth attempt");if(!de.isPrivateKey())return j("Skipping non-private key");H={type:D,username:B,key:de,localHostname:z,localUsername:ne};break}case"agent":{let z=H.agent;if(typeof z=="string"&&z.length)z=ph(z);else if(!mh(z))return j(`Skipping invalid agent: ${H.agent}`);H={type:D,username:B,agentCtx:new hh(z)};break}case"keyboard-interactive":{let{prompt:z}=H;if(typeof z!="function")return j("Skipping invalid keyboard-interactive auth attempt");H={type:D,username:B,prompt:z};break}case"none":H={type:D,username:B};break;default:return j(`Skipping unsupported authentication method: ${H}`)}}}_=H;try{let B=_.username;switch(_.type){case"password":A.authPassword(B,_.password);break;case"publickey":{let D;if(_.keyAlgos=yc(this,_.key,p),_.keyAlgos)if(_.keyAlgos.length)D=_.keyAlgos[0][0];else return j("Skipping key authentication (no mutual hash algorithm)");A.authPK(B,_.key,D);break}case"hostbased":{let D,z;if(_.keyAlgos=yc(this,_.key,p),_.keyAlgos)if(_.keyAlgos.length)[D,z]=_.keyAlgos[0];else return j("Skipping hostbased authentication (no mutual hash algorithm)");A.authHostbased(B,_.key,_.localHostname,_.localUsername,D,(ne,de)=>{let oe=_.key.sign(ne,z);if(oe instanceof Error)return oe.message=`Error while signing with key: ${oe.message}`,oe.level="client-authentication",this.emit("error",oe),X();de(oe)});break}case"agent":_.agentCtx.init(D=>{if(D)return D.level="agent",this.emit("error",D),X();re()});break;case"keyboard-interactive":A.authKeyboard(B);break;case"none":A.authNone(B);break}}finally{R=!1}}};function j(H){i&&i(H),process.nextTick(X)}function X(){R=!1;let H=s(k,w,ie);R||H===void 0||ie(H)}let re=()=>{if(_.type==="agent"){let H=_.agentCtx.nextKey();if(H===!1)i&&i("Agent: No more keys left to try"),i&&i("Client: agent auth failed"),X();else{let B=_.agentCtx.pos(),D;if(_.keyAlgos=yc(this,H,p),_.keyAlgos)if(_.keyAlgos.length)D=_.keyAlgos[0][0];else{i&&i(`Agent: Skipping key #${B+1} (no mutual hash algorithm)`),re();return}i&&i(`Agent: Trying key #${B+1}`),A.authPK(_.username,H,D)}}},fe=()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let H=new Error("Timed out while waiting for handshake");H.level="client-timeout",this.emit("error",H),l.destroy()},this.config.readyTimeout))};if(t.sock)fe(),typeof l.connecting=="boolean"&&l.connecting||F();else{let H=this.config.host,B=this.config.forceIPv4,D=this.config.forceIPv6;i&&i(`Client: Trying ${H} on port ${this.config.port} ...`);let z=()=>{fe(),l.connect({host:H,port:this.config.port,localAddress:this.config.localAddress,localPort:this.config.localPort}),l.setMaxListeners(0),l.setTimeout(typeof t.timeout=="number"?t.timeout:0)};!B&&!D||B&&D?z():lA(H,B?4:6,(ne,de,oe)=>{if(ne){let Je=B?"IPv4":"IPv6",ht=new Error(`Error while looking up ${Je} address for '${H}': ${ne}`);clearTimeout(this._readyTimeout),ht.level="client-dns",this.emit("error",ht),this.emit("close");return}H=de,z()})}return this}end(){return this._sock&&Lt(this._sock)&&(this._protocol.disconnect(fh.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&Lt(this._sock)&&this._sock.destroy(),this}exec(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");typeof e=="function"&&(r=e,e={});let s={allowHalfOpen:e.allowHalfOpen!==!1};return ei(this,"session",s,(i,o)=>{if(i){r(i);return}let a=[];function c(l){if(l){o.close(),r(l);return}a.length&&a.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&a.push(()=>Sh(o,c)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&gc(o,e.env),(typeof e.pty=="object"&&e.pty!==null||e.pty===!0)&&a.push(()=>Eh(o,e.pty,c)),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&a.push(()=>yh(o,e.x11,c))),a.push(()=>NA(o,t,e,r)),a.shift()()}),this}shell(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return typeof t=="function"?(r=t,t=e=void 0):typeof e=="function"&&(r=e,e=void 0),t&&(t.x11!==void 0||t.env!==void 0)&&(e=t,t=void 0),ei(this,"session",(s,i)=>{if(s){r(s);return}let o=[];function a(c){if(c){i.close(),r(c);return}o.length&&o.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&o.push(()=>Sh(i,a)),t!==!1&&o.push(()=>Eh(i,t,a)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&gc(i,e.env),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&o.push(()=>yh(i,e.x11,a))),o.push(()=>vA(i,r)),o.shift()()}),this}subsys(t,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return ei(this,"session",(r,s)=>{if(r){e(r);return}Ac(s,t,(i,o)=>{if(i){e(i);return}e(void 0,o)})}),this}forwardIn(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push((i,o)=>{if(i){r(i!==!0?i:new Error(`Unable to bind to ${t}:${e}`));return}let a=e;e===0&&o&&o.length>=4&&(a=xA(o,0),this._protocol._compatFlags&bh.DYN_RPORT_BUG||(e=a)),this._forwarding[`${t}:${e}`]=a,r(void 0,a)}),this._protocol.tcpipForward(t,e,s),this}unforwardIn(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push(i=>{if(i){r(i!==!0?i:new Error(`Unable to unbind from ${t}:${e}`));return}delete this._forwarding[`${t}:${e}`],r()}),this._protocol.cancelTcpipForward(t,e,s),this}forwardOut(t,e,r,s,i){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let o={srcIP:t,srcPort:e,dstIP:r,dstPort:s};return typeof i!="function"&&(i=Ec),ei(this,"direct-tcpip",o,i),this}openssh_noMoreSessions(t){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let e=typeof t=="function";return!this.config.strictVendor||this.config.strictVendor&&Ki.test(this._remoteVer)?(e&&this._callbacks.push(r=>{if(r){t(r!==!0?r:new Error("Unable to disable future sessions"));return}t()}),this._protocol.openssh_noMoreSessions(e),this):e?(process.nextTick(t,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardInStreamLocal(t,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Ki.test(this._remoteVer)?(r&&this._callbacks.push(s=>{if(s){e(s!==!0?s:new Error(`Unable to bind to ${t}`));return}this._forwardingUnix[t]=!0,e()}),this._protocol.openssh_streamLocalForward(t,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_unforwardInStreamLocal(t,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Ki.test(this._remoteVer)?(r&&this._callbacks.push(s=>{if(s){e(s!==!0?s:new Error(`Unable to unbind from ${t}`));return}delete this._forwardingUnix[t],e()}),this._protocol.openssh_cancelStreamLocalForward(t,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardOutStreamLocal(t,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return typeof e!="function"&&(e=Ec),!this.config.strictVendor||this.config.strictVendor&&Ki.test(this._remoteVer)?(ei(this,"direct-streamlocal@openssh.com",{socketPath:t},e),this):(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this)}sftp(t,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return typeof t=="function"&&(e=t,t=void 0),ei(this,"sftp",(r,s)=>{if(r){e(r);return}let i=(o,a)=>{if(o){e(o);return}function c(){s.removeListener("ready",l),s.removeListener("error",u),s.removeListener("exit",f),s.removeListener("close",f)}function l(){c(),e(void 0,s)}function u(h){c(),e(h)}function f(h,p){c();let A;typeof h=="number"?A=`Received exit code ${h} while establishing SFTP session`:p!==void 0?A=`Received signal ${p} while establishing SFTP session`:A="Received unexpected SFTP session termination";let E=new Error(A);E.code=h,E.signal=p,e(E)}s.on("ready",l).on("error",u).on("exit",f).on("close",f),s._init()};typeof t=="object"&&t!==null?gc(s,t,o=>{if(o){e(o);return}Ac(s,"sftp",i)}):Ac(s,"sftp",i)}),this}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function ei(n,t,e,r){let s=uo,i=fo;typeof e=="function"&&(r=e,e={});let o=(c,l)=>{r(c,l)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"session":case"sftp":n._protocol.session(a,s,i);break;case"direct-tcpip":n._protocol.directTcpip(a,s,i,e);break;case"direct-streamlocal@openssh.com":n._protocol.openssh_directStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function yh(n,t,e){let r={single:!1,protocol:"MIT-MAGIC-COOKIE-1",cookie:void 0,screen:0};typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.single=="boolean"&&(r.single=t.single),typeof t.screen=="number"&&(r.screen=t.screen),typeof t.protocol=="string"&&(r.protocol=t.protocol),typeof t.cookie=="string"?r.cookie=t.cookie:Buffer.isBuffer(t.cookie)&&(r.cookie=t.cookie.hexSlice(0,t.cookie.length))),r.cookie===void 0&&(r.cookie=RA());let s=typeof e=="function";if(n.outgoing.state!=="open"){s&&e(new Error("Channel is not open"));return}s&&n._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to request X11"));return}n._hasX11=!0,++n._client._acceptX11,n.once("close",()=>{n._client._acceptX11&&--n._client._acceptX11}),e()}),n._client._protocol.x11Forward(n.outgoing.id,r,s)}function Eh(n,t,e){let r=24,s=80,i=640,o=480,a="vt100",c=null;typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.rows=="number"&&(r=t.rows),typeof t.cols=="number"&&(s=t.cols),typeof t.width=="number"&&(i=t.width),typeof t.height=="number"&&(o=t.height),typeof t.term=="string"&&(a=t.term),typeof t.modes=="object"&&(c=t.modes));let l=typeof e=="function";if(n.outgoing.state!=="open"){l&&e(new Error("Channel is not open"));return}l&&n._callbacks.push(u=>{if(u){e(u!==!0?u:new Error("Unable to request a pseudo-terminal"));return}e()}),n._client._protocol.pty(n.outgoing.id,r,s,o,i,a,c,l)}function Sh(n,t){let e=typeof t=="function";if(n.outgoing.state!=="open"){e&&t(new Error("Channel is not open"));return}if(n._client._agentFwdEnabled){e&&t(!1);return}n._client._agentFwdEnabled=!0,n._callbacks.push(r=>{if(r){n._client._agentFwdEnabled=!1,e&&t(r!==!0?r:new Error("Unable to request agent forwarding"));return}e&&t()}),n._client._protocol.openssh_agentForward(n.outgoing.id,!0)}function vA(n,t){if(n.outgoing.state!=="open"){t(new Error("Channel is not open"));return}n._callbacks.push(e=>{if(e){t(e!==!0?e:new Error("Unable to open shell"));return}n.subtype="shell",t(void 0,n)}),n._client._protocol.shell(n.outgoing.id,!0)}function NA(n,t,e,r){if(n.outgoing.state!=="open"){r(new Error("Channel is not open"));return}n._callbacks.push(s=>{if(s){r(s!==!0?s:new Error("Unable to exec"));return}n.subtype="exec",n.allowHalfOpen=e.allowHalfOpen!==!1,r(void 0,n)}),n._client._protocol.exec(n.outgoing.id,t,!0)}function gc(n,t,e){let r=typeof e=="function";if(n.outgoing.state!=="open"){r&&e(new Error("Channel is not open"));return}r&&n._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to set environment"));return}e()});let s=Object.keys(t||{});for(let i=0;i<s.length;++i){let o=s[i],a=t[o];n._client._protocol.env(n.outgoing.id,o,a,r)}}function Ac(n,t,e){if(n.outgoing.state!=="open"){e(new Error("Channel is not open"));return}n._callbacks.push(r=>{if(r){e(r!==!0?r:new Error(`Unable to start subsystem: ${t}`));return}n.subtype="subsystem",e(void 0,n)}),n._client._protocol.subsystem(n.outgoing.id,t,!0)}function BA(n,t){let e=-1,r,s=()=>{let c={type:t.type,incoming:{id:e,window:uo,packetSize:fo,state:"open"},outgoing:{id:t.sender,window:t.window,packetSize:t.packetSize,state:"open"}},l=new wh(n,c);return n._chanMgr.update(e,l),n._protocol.channelOpenConfirm(t.sender,e,uo,fo),l},i=()=>{r===void 0&&(e===-1?r=qi.RESOURCE_SHORTAGE:r=qi.CONNECT_FAILED),e!==-1&&n._chanMgr.remove(e),n._protocol.channelOpenFail(t.sender,r,"")},o=()=>(e=n._chanMgr.add(),e===-1&&(r=qi.RESOURCE_SHORTAGE,n.config.debug&&n.config.debug("Client: Automatic rejection of incoming channel open: no channels available")),e!==-1),a=t.data;switch(t.type){case"forwarded-tcpip":{let c=n._forwarding[`${a.destIP}:${a.destPort}`];if(c!==void 0&&o()){a.destPort===0&&(a.destPort=c),n.emit("tcp connection",a,s,i);return}break}case"forwarded-streamlocal@openssh.com":if(n._forwardingUnix[a.socketPath]!==void 0&&o()){n.emit("unix connection",a,s,i);return}break;case"auth-agent@openssh.com":if(n._agentFwdEnabled&&typeof n._agent.getStream=="function"&&o()){n._agent.getStream((c,l)=>{if(c)return i();let u=s();u.pipe(l).pipe(u)});return}break;case"x11":if(n._acceptX11!==0&&o()){n.emit("x11",a,s,i);return}break;default:r=qi.UNKNOWN_CHANNEL_TYPE,n.config.debug&&n.config.debug(`Client: Automatic rejection of unsupported incoming channel open type: ${t.type}`)}r===void 0&&(r=qi.ADMINISTRATIVELY_PROHIBITED,n.config.debug&&n.config.debug("Client: Automatic rejection of unexpected incoming channel open for: "+t.type)),i()}var RA=(()=>{let n=Buffer.allocUnsafe(16);return()=>(aA(n,0,16),n.hexSlice(0,16))})();function _h(n){if(!Array.isArray(n))throw new Error("authList must be an array");let t=0;return(e,r,s)=>t===n.length?!1:n[t++]}function PA(n,t,e){if(!n._sock||!Lt(n._sock))return;if(typeof e!="function"&&(e=Ec),!Array.isArray(t))throw new TypeError("Invalid keys argument type");let r=[];for(let s of t){let i=lo(s);if(i instanceof Error)throw i;r.push(i)}if(!n.config.strictVendor||n.config.strictVendor&&Ki.test(n._remoteVer)){n._callbacks.push((s,i)=>{if(s){e(s!==!0?s:new Error("Server failed to prove supplied keys"));return}let o=[],a=0;for(ao.init(i,0);ao.avail()&&a!==r.length;){let c=r[a++],l=c.getPublicSSH(),u=ao.readString();co.init(u,0);let f=co.readString(!0),h=co.readString(),p;if(f!==c.type)if(c.type==="ssh-rsa")switch(f){case"rsa-sha2-256":p="sha256";break;case"rsa-sha2-512":p="sha512";break;default:continue}else continue;let A=n._protocol._kex.sessionID,E=Buffer.allocUnsafe(37+A.length+4+l.length),b=0;mc(E,29,b),E.utf8Write("hostkeys-prove-00@openssh.com",b+=4,29),mc(E,A.length,b+=29),dh(A,E,0,A.length,b+=4),mc(E,l.length,b+=A.length),dh(l,E,0,l.length,b+=4),(h=wA(h,f))&&c.verify(E,h,p)===!0&&o.push(c)}co.clear(),ao.clear(),e(null,o)}),n._protocol.openssh_hostKeysProve(r);return}process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version"))}function yc(n,t,e){switch(t.type){case"ssh-rsa":if(n._protocol._compatFlags&bh.IMPLY_RSA_SHA2_SIGALGS&&(Array.isArray(e)?e=["rsa-sha2-256","rsa-sha2-512",...e]:e=["rsa-sha2-256","rsa-sha2-512"]),Array.isArray(e)){if(e.indexOf("rsa-sha2-256")!==-1)return[["rsa-sha2-256","sha256"]];if(e.indexOf("rsa-sha2-512")!==-1)return[["rsa-sha2-512","sha512"]];if(e.indexOf("ssh-rsa")===-1)return[]}return[["ssh-rsa","sha1"]]}}Ih.exports=Sc});var kh=ut(Ch=>{"use strict";var{Agent:xc}=require("http"),{Agent:TA}=require("https"),{connect:OA}=require("tls"),bc;for(let n of[xc,TA]){class t extends n{constructor(r,s){super(s),this._connectCfg=r,this._defaultSrcIP=s&&s.srcIP||"localhost"}createConnection(r,s){let i=r&&r.localAddress||this._defaultSrcIP,o=r&&r.localPort||0,a=r.host,c=r.port;bc===void 0&&(bc=_c());let l=new bc,u=!1;l.on("ready",()=>{l.forwardOut(i,o,a,c,(f,h)=>{if(u=!0,f)return l.end(),s(f);h.once("close",()=>l.end()),s(null,MA(h,n,r))})}).on("error",s).on("close",()=>{u||s(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}Ch[n===xc?"SSHTTPAgent":"SSHTTPSAgent"]=t}function zi(){}function MA(n,t,e){if(t===xc)return n.setKeepAlive=zi,n.setNoDelay=zi,n.setTimeout=zi,n.ref=zi,n.unref=zi,n.destroySoon=n.destroy,n;e.socket=n;let r=OA(e),s=(()=>{let i=!1;return()=>{i||(i=!0,n.isPaused()&&n.resume())}})();return r.on("end",s).on("close",s),r}});var Nh=ut((zx,kc)=>{"use strict";var{Server:DA}=require("net"),Yi=require("events"),{listenerCount:Jt}=Yi,{CHANNEL_OPEN_FAILURE:ti,DEFAULT_CIPHER:LA,DEFAULT_COMPRESSION:UA,DEFAULT_KEX:$A,DEFAULT_MAC:FA,DEFAULT_SERVER_HOST_KEY:HA,DISCONNECT_REASON:ni,DISCONNECT_REASON_BY_VALUE:QA,SUPPORTED_CIPHER:WA,SUPPORTED_COMPRESSION:qA,SUPPORTED_KEX:VA,SUPPORTED_MAC:KA,SUPPORTED_SERVER_HOST_KEY:zA}=qn(),{init:GA}=tr(),{KexInit:YA}=Gs(),{parseKey:vh}=ir(),jA=Ya(),{SFTP:XA}=Hi(),{writeUInt32BE:JA}=xn(),{Channel:ri,MAX_WINDOW:ar,PACKET_SIZE:cr,windowAdjust:ZA,WINDOW_THRESHOLD:ey}=fc(),{ChannelManager:ty,generateAlgorithmList:Gi,isWritable:ho,onChannelOpenFailure:ny,onCHANNEL_CLOSE:ry}=pc(),iy=10,lr=class extends Yi{constructor(t,e,r,s,i){super(),this.username=this.user=e,this.service=r,this.method=s,this._initialResponse=!1,this._finalResponse=!1,this._multistep=!1,this._cbfinal=(o,a,c)=>{this._finalResponse||(this._finalResponse=!0,i(this,o,a,c))},this._protocol=t}accept(){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!0)}reject(t,e){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!1,t,e)}},po=class extends lr{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this._multistep=!0,this._cb=void 0,this._onInfoResponse=a=>{let c=this._cb;c&&(this._cb=void 0,c(a))},this.submethods=i,this.on("abort",()=>{this._cb&&this._cb(new Error("Authentication request aborted"))})}prompt(t,e,r,s){Array.isArray(t)||(t=[t]),typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"?(s=r,r=void 0):typeof s!="function"&&(s=void 0);for(let i=0;i<t.length;++i)typeof t[i]=="string"&&(t[i]={prompt:t[i],echo:!0});this._cb=s,this._initialResponse=!0,this._protocol.authInfoReq(e,r,t)}},Ic=class extends lr{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.key={algo:i.keyAlgo,data:i.key},this.hashAlgo=i.hashAlgo,this.signature=i.signature,this.blob=i.blob}accept(){this.signature?lr.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},Cc=class extends lr{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.key={algo:i.keyAlgo,data:i.key},this.hashAlgo=i.hashAlgo,this.signature=i.signature,this.blob=i.blob,this.localHostname=i.localHostname,this.localUsername=i.localUsername}},mo=class extends lr{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.password=i,this._changeCb=void 0}requestChange(t,e){if(this._changeCb)throw new Error("Change request already in progress");if(typeof t!="string")throw new Error("prompt argument must be a string");if(typeof e!="function")throw new Error("Callback argument must be a function");this._changeCb=e,this._protocol.authPasswdChg(t)}},On=class extends Yi{constructor(t,e,r){super(),this.type="session",this.subtype=void 0,this.server=!0,this._ending=!1,this._channel=void 0,this._chanInfo={type:"session",incoming:{id:r,window:ar,packetSize:cr,state:"open"},outgoing:{id:e.sender,window:e.window,packetSize:e.packetSize,state:"open"}}}},pn=class extends Yi{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new Error("Missing configuration object");let r=Object.create(null),s=[],i=t.hostKeys;if(!Array.isArray(i))throw new Error("hostKeys must be an array");let o=typeof t.algorithms=="object"&&t.algorithms!==null?t.algorithms:{},a=Gi(o.serverHostKey,HA,zA);for(let h=0;h<i.length;++h){let p;if(Buffer.isBuffer(i[h])||typeof i[h]=="string"?p=vh(i[h]):p=vh(i[h].key,i[h].passphrase),p instanceof Error)throw new Error(`Cannot parse privateKey: ${p.message}`);if(Array.isArray(p)&&(p=p[0]),p.getPrivatePEM()===null)throw new Error("privateKey value contains an invalid private key");if(!s.includes(p.type))if(p.type==="ssh-rsa"){let A=a.indexOf("ssh-rsa"),E=a.indexOf("rsa-sha2-256"),b=a.indexOf("rsa-sha2-512");A===-1&&(A=1/0),[A,E,b].sort(sy).forEach(x=>{if(x===-1)return;let P;switch(x){case A:P="ssh-rsa";break;case E:P="rsa-sha2-256";break;case b:P="rsa-sha2-512";break;default:return}r[P]=p,s.push(P)})}else r[p.type]=p,s.push(p.type)}let c={kex:Gi(o.kex,$A,VA).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:s,cs:{cipher:Gi(o.cipher,LA,WA),mac:Gi(o.hmac,FA,KA),compress:Gi(o.compress,UA,qA),lang:[]},sc:void 0};c.sc=c.cs,typeof e=="function"&&this.on("connection",e);let l=typeof t.debug=="function"?t.debug:void 0,u=t.ident?Buffer.from(t.ident):void 0,f=new YA(c);this._srv=new DA(h=>{if(this._connections>=this.maxConnections){h.destroy();return}++this._connections,h.once("close",()=>{--this._connections});let p;if(l){let A=`[${process.hrtime().join(".")}] `;p=E=>{l(`${A}${E}`)}}new go(h,r,u,f,p,this,t)}).on("error",h=>{this.emit("error",h)}).on("listening",()=>{this.emit("listening")}).on("close",()=>{this.emit("close")}),this._connections=0,this.maxConnections=1/0}injectSocket(t){this._srv.emit("connection",t)}listen(...t){return this._srv.listen(...t),this}address(){return this._srv.address()}getConnections(t){return this._srv.getConnections(t),this}close(t){return this._srv.close(t),this}ref(){return this._srv.ref(),this}unref(){return this._srv.unref(),this}};pn.KEEPALIVE_CLIENT_INTERVAL=15e3;pn.KEEPALIVE_CLIENT_COUNT_MAX=3;var go=class extends Yi{constructor(t,e,r,s,i,o,a){super();let c=0,l=!1,u=[],f,h,p,A=[];this._sock=t,this._chanMgr=new ty(this),this._debug=i,this.noMoreSessions=!1,this.authenticated=!1;function E(v){}this.on("error",E);let b=i?(v,_,w)=>{i(`Debug output from client: ${JSON.stringify(w)}`)}:void 0,x=typeof a.keepaliveInterval=="number"&&isFinite(a.keepaliveInterval)&&a.keepaliveInterval>0?a.keepaliveInterval:typeof pn.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite(pn.KEEPALIVE_CLIENT_INTERVAL)&&pn.KEEPALIVE_CLIENT_INTERVAL>0?pn.KEEPALIVE_CLIENT_INTERVAL:-1,P=typeof a.keepaliveCountMax=="number"&&isFinite(a.keepaliveCountMax)&&a.keepaliveCountMax>=0?a.keepaliveCountMax:typeof pn.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite(pn.KEEPALIVE_CLIENT_COUNT_MAX)&&pn.KEEPALIVE_CLIENT_COUNT_MAX>=0?pn.KEEPALIVE_CLIENT_COUNT_MAX:-1,q=0;x!==-1&&P!==-1&&(this.once("ready",()=>{let v=()=>{clearInterval(h)};this.on("close",v).on("end",v),h=setInterval(()=>{if(++q>P){clearInterval(h);let _=new Error("Keepalive timeout");_.level="client-timeout",this.emit("error",_),this.end()}else C.ping()},x)}),p=()=>{h&&h.refresh(),q=0});let C=this._protocol=new jA({server:!0,hostKeys:e,ident:r,offer:s,onPacket:p,greeting:a.greeting,banner:a.banner,onWrite:v=>{ho(t)&&t.write(v)},onError:v=>{C._destruct||t.removeAllListeners("data"),this.emit("error",v);try{t.end()}catch{}},onHeader:v=>{this.removeListener("error",E);let _={ip:t.remoteAddress,family:t.remoteFamily,port:t.remotePort,header:v};if(!o.emit("connection",this,_)){C.disconnect(ni.BY_APPLICATION),t.end();return}v.greeting&&this.emit("greeting",v.greeting)},onHandshakeComplete:v=>{++c>1&&this.emit("rekey"),this.emit("handshake",v)},debug:i,messageHandlers:{DEBUG:b,DISCONNECT:(v,_,w)=>{if(_!==ni.BY_APPLICATION){w||(w=QA[_],w===void 0&&(w=`Unexpected disconnection reason: ${_}`));let k=new Error(w);k.code=_,this.emit("error",k)}t.end()},CHANNEL_OPEN:(v,_)=>{if(_.type==="session"&&this.noMoreSessions||!this.authenticated){let re=ti.ADMINISTRATIVELY_PROHIBITED;return C.channelOpenFail(_.sender,re)}let w=-1,k,N=!1,R,ie=()=>{N||(N=!0,k===void 0&&(w===-1?k=ti.RESOURCE_SHORTAGE:k=ti.CONNECT_FAILED),w!==-1&&this._chanMgr.remove(w),C.channelOpenFail(_.sender,k,""))},j=()=>(w=this._chanMgr.add(),w===-1&&(k=ti.RESOURCE_SHORTAGE,i&&i("Automatic rejection of incoming channel open: no channels available")),w!==-1),X=_.data;switch(_.type){case"session":if(Jt(this,"session")&&j()){R=()=>{if(N)return;N=!0;let re=new On(this,_,w);return this._chanMgr.update(w,re),C.channelOpenConfirm(_.sender,w,ar,cr),re},this.emit("session",R,ie);return}break;case"direct-tcpip":if(Jt(this,"tcpip")&&j()){R=()=>{if(N)return;N=!0;let re={type:void 0,incoming:{id:w,window:ar,packetSize:cr,state:"open"},outgoing:{id:_.sender,window:_.window,packetSize:_.packetSize,state:"open"}},fe=new ri(this,re,{server:!0});return this._chanMgr.update(w,fe),C.channelOpenConfirm(_.sender,w,ar,cr),fe},this.emit("tcpip",R,ie,X);return}break;case"direct-streamlocal@openssh.com":if(Jt(this,"openssh.streamlocal")&&j()){R=()=>{if(N)return;N=!0;let re={type:void 0,incoming:{id:w,window:ar,packetSize:cr,state:"open"},outgoing:{id:_.sender,window:_.window,packetSize:_.packetSize,state:"open"}},fe=new ri(this,re,{server:!0});return this._chanMgr.update(w,fe),C.channelOpenConfirm(_.sender,w,ar,cr),fe},this.emit("openssh.streamlocal",R,ie,X);return}break;default:k=ti.UNKNOWN_CHANNEL_TYPE,i&&i(`Automatic rejection of unsupported incoming channel open type: ${_.type}`)}k===void 0&&(k=ti.ADMINISTRATIVELY_PROHIBITED,i&&i(`Automatic rejection of unexpected incoming channel open for: ${_.type}`)),ie()},CHANNEL_OPEN_CONFIRMATION:(v,_)=>{let w=this._chanMgr.get(_.recipient);if(typeof w!="function")return;let k={type:w.type,incoming:{id:_.recipient,window:ar,packetSize:cr,state:"open"},outgoing:{id:_.sender,window:_.window,packetSize:_.packetSize,state:"open"}},N=new ri(this,k,{server:!0});this._chanMgr.update(_.recipient,N),w(void 0,N)},CHANNEL_OPEN_FAILURE:(v,_,w,k)=>{let N=this._chanMgr.get(_);if(typeof N!="function")return;ny(this,_,{reason:w,description:k},N)},CHANNEL_DATA:(v,_,w)=>{let k=this._chanMgr.get(_);if(!(typeof k!="object"||k===null)&&!(k.constructor===On&&(k=k._channel,!k))&&k.incoming.window!==0){if(k.incoming.window-=w.length,k.push(w)===!1){k._waitChanDrain=!0;return}k.incoming.window<=ey&&ZA(k)}},CHANNEL_EXTENDED_DATA:(v,_,w,k)=>{},CHANNEL_WINDOW_ADJUST:(v,_,w)=>{let k=this._chanMgr.get(_);typeof k!="object"||k===null||k.constructor===On&&(k=k._channel,!k)||(k.outgoing.window+=w,k._waitWindow&&(k._waitWindow=!1,k._chunk?k._write(k._chunk,null,k._chunkcb):k._chunkcb?k._chunkcb():k._chunkErr?k.stderr._write(k._chunkErr,null,k._chunkcbErr):k._chunkcbErr&&k._chunkcbErr()))},CHANNEL_SUCCESS:(v,_)=>{let w=this._chanMgr.get(_);typeof w!="object"||w===null||w.constructor===On&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!1)},CHANNEL_FAILURE:(v,_)=>{let w=this._chanMgr.get(_);typeof w!="object"||w===null||w.constructor===On&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!0)},CHANNEL_REQUEST:(v,_,w,k,N)=>{let R=this._chanMgr.get(_);if(typeof R!="object"||R===null)return;let ie=!1,j,X;if(R.constructor!==On){k&&C.channelFailure(R.outgoing.id);return}if(k&&(w!=="shell"&&w!=="exec"&&w!=="subsystem"&&(j=()=>{ie||R._ending||R._channel||(ie=!0,C.channelSuccess(R._chanInfo.outgoing.id))}),X=()=>{ie||R._ending||R._channel||(ie=!0,C.channelFailure(R._chanInfo.outgoing.id))}),R._ending){X&&X();return}switch(w){case"env":if(Jt(R,"env")){R.emit("env",j,X,{key:N.name,val:N.value});return}break;case"pty-req":if(Jt(R,"pty")){R.emit("pty",j,X,N);return}break;case"window-change":Jt(R,"window-change")?R.emit("window-change",j,X,N):X&&X();break;case"x11-req":if(Jt(R,"x11")){R.emit("x11",j,X,N);return}break;case"signal":if(Jt(R,"signal")){R.emit("signal",j,X,{name:N});return}break;case"auth-agent-req@openssh.com":if(Jt(R,"auth-agent")){R.emit("auth-agent",j,X);return}break;case"shell":if(Jt(R,"shell")){j=()=>{if(ie||R._ending||R._channel)return;ie=!0,k&&C.channelSuccess(R._chanInfo.outgoing.id);let re=new ri(this,R._chanInfo,{server:!0});return re.subtype=R.subtype=w,R._channel=re,re},R.emit("shell",j,X);return}break;case"exec":if(Jt(R,"exec")){j=()=>{if(ie||R._ending||R._channel)return;ie=!0,k&&C.channelSuccess(R._chanInfo.outgoing.id);let re=new ri(this,R._chanInfo,{server:!0});return re.subtype=R.subtype=w,R._channel=re,re},R.emit("exec",j,X,{command:N});return}break;case"subsystem":{let re=N==="sftp";if(j=()=>{if(ie||R._ending||R._channel)return;ie=!0,k&&C.channelSuccess(R._chanInfo.outgoing.id);let fe;return re?fe=new XA(this,R._chanInfo,{server:!0,debug:i}):(fe=new ri(this,R._chanInfo,{server:!0}),fe.subtype=R.subtype=`${w}:${N}`),R._channel=fe,fe},N==="sftp"){if(Jt(R,"sftp")){R.emit("sftp",j,X);return}re=!1}if(Jt(R,"subsystem")){R.emit("subsystem",j,X,{name:N});return}break}}i&&i(`Automatic rejection of incoming channel request: ${w}`),X&&X()},CHANNEL_EOF:(v,_)=>{let w=this._chanMgr.get(_);typeof w!="object"||w===null||w.constructor===On&&(w._ending||(w._ending=!0,w.emit("eof"),w.emit("end")),w=w._channel,!w)||w.incoming.state==="open"&&(w.incoming.state="eof",w.readable&&w.push(null))},CHANNEL_CLOSE:(v,_)=>{let w=this._chanMgr.get(_);typeof w!="object"||w===null||w.constructor===On&&(w._ending=!0,w.emit("close"),w=w._channel,!w)||ry(this,_,w)},SERVICE_REQUEST:(v,_)=>{if(c===0||l||this.authenticated||_!=="ssh-userauth"){C.disconnect(ni.SERVICE_NOT_AVAILABLE),t.end();return}l=!0,C.serviceAccept(_)},USERAUTH_REQUEST:(v,_,w,k,N)=>{if(c===0||this.authenticated||f&&(f.username!==_||f.service!==w)||k!=="password"&&k!=="publickey"&&k!=="hostbased"&&k!=="keyboard-interactive"&&k!=="none"||u.length===iy){C.disconnect(ni.PROTOCOL_ERROR),t.end();return}else if(w!=="ssh-connection"){C.disconnect(ni.SERVICE_NOT_AVAILABLE),t.end();return}let R;switch(k){case"keyboard-interactive":R=new po(C,_,w,k,N,$);break;case"publickey":R=new Ic(C,_,w,k,N,$);break;case"hostbased":R=new Cc(C,_,w,k,N,$);break;case"password":if(f&&f instanceof mo&&f._changeCb){let ie=f._changeCb;f._changeCb=void 0,ie(N.newPassword);return}R=new mo(C,_,w,k,N,$);break;case"none":R=new lr(C,_,w,k,$);break}if(f)if(f._initialResponse)f._multistep&&!f._finalResponse&&(f._cleanup&&f._cleanup(),f.emit("abort"));else return u.push(R);f=R,Jt(this,"authentication")?this.emit("authentication",f):f.reject()},USERAUTH_INFO_RESPONSE:(v,_)=>{f&&f instanceof po&&f._onInfoResponse(_)},GLOBAL_REQUEST:(v,_,w,k)=>{let N={type:null,buf:null};function R(ie,j){N.type=ie,N.buf=j,F()}if(w&&A.push(N),(_==="tcpip-forward"||_==="cancel-tcpip-forward"||_==="no-more-sessions@openssh.com"||_==="streamlocal-forward@openssh.com"||_==="cancel-streamlocal-forward@openssh.com")&&Jt(this,"request")&&this.authenticated){let ie,j;if(w){let X=!1;ie=re=>{if(X)return;X=!0;let fe;_==="tcpip-forward"&&k.bindPort===0&&typeof re=="number"&&(fe=Buffer.allocUnsafe(4),JA(fe,re,0)),R("SUCCESS",fe)},j=()=>{X||(X=!0,R("FAILURE"))}}if(_==="no-more-sessions@openssh.com"){this.noMoreSessions=!0,ie&&ie();return}this.emit("request",ie,j,_,k)}else w&&R("FAILURE")}}});t.pause(),GA.then(()=>{C.start(),t.on("data",v=>{try{C.parse(v,0,v.length)}catch(_){this.emit("error",_);try{ho(t)&&t.end()}catch{}}}),t.resume()}).catch(v=>{this.emit("error",v);try{ho(t)&&t.end()}catch{}}),t.on("error",v=>{v.level="socket",this.emit("error",v)}).once("end",()=>{i&&i("Socket ended"),C.cleanup(),this.emit("end")}).once("close",()=>{i&&i("Socket closed"),C.cleanup(),this.emit("close");let v=new Error("No response from server");this._chanMgr.cleanup(v)});let $=(v,_,w,k)=>{f===v&&!this.authenticated&&(_?(f=void 0,this.authenticated=!0,C.authSuccess(),u=[],this.emit("ready")):(C.authFailure(w,k),u.length&&(f=u.pop(),Jt(this,"authentication")?this.emit("authentication",f):f.reject())))};function F(){for(;A.length>0&&A[0].type;){let v=A.shift();v.type==="SUCCESS"&&C.requestSuccess(v.buf),v.type==="FAILURE"&&C.requestFailure()}}}end(){return this._sock&&ho(this._sock)&&(this._protocol.disconnect(ni.BY_APPLICATION),this._sock.end()),this}x11(t,e,r){return wc(this,"x11",{originAddr:t,originPort:e},r),this}forwardOut(t,e,r,s,i){return wc(this,"forwarded-tcpip",{boundAddr:t,boundPort:e,remoteAddr:r,remotePort:s},i),this}openssh_forwardOutStreamLocal(t,e){return wc(this,"forwarded-streamlocal@openssh.com",{socketPath:t},e),this}rekey(t){let e;try{this._protocol.rekey()}catch(r){e=r}typeof t=="function"&&(e?process.nextTick(t,e):this.once("rekey",t))}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function wc(n,t,e,r){let s=ar,i=cr;typeof e=="function"&&(r=e,e={});let o=(c,l)=>{r(c,l)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"forwarded-tcpip":n._protocol.forwardedTcpip(a,s,i,e);break;case"x11":n._protocol.x11(a,s,i,e);break;case"forwarded-streamlocal@openssh.com":n._protocol.openssh_forwardedStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function sy(n,t){return n-t}kc.exports=pn;kc.exports.IncomingClient=go});var Oh=ut((Gx,Th)=>{"use strict";var{createCipheriv:oy,generateKeyPair:ay,generateKeyPairSync:cy,getCurves:ly,randomBytes:Bh}=require("crypto"),{Ber:It}=bi(),uy=Ko().pbkdf,{CIPHER_INFO:fy}=tr(),dy=16,hy=16,py=ly(),my=new Map(Object.entries(fy));function Rh(n,t){if(typeof n!="string")throw new TypeError("Key type must be a string");let e={type:"spki",format:"der"},r={type:"pkcs8",format:"der"};switch(n.toLowerCase()){case"rsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for RSA key");let s=t.bits;if(!Number.isInteger(s))throw new TypeError("RSA bits must be an integer");if(s<=0||s>16384)throw new RangeError("RSA bits must be non-zero and <= 16384");return["rsa",{modulusLength:s,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ecdsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for ECDSA key");if(!Number.isInteger(t.bits))throw new TypeError("ECDSA bits must be an integer");let s;switch(t.bits){case 256:s="prime256v1";break;case 384:s="secp384r1";break;case 521:s="secp521r1";break;default:throw new Error("ECDSA bits must be 256, 384, or 521")}if(!py.includes(s))throw new Error("Unsupported ECDSA bits value");return["ec",{namedCurve:s,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ed25519":return["ed25519",{publicKeyEncoding:e,privateKeyEncoding:r}];default:throw new Error(`Unsupported key type: ${n}`)}}function gy(n,t,e){switch(n){case"rsa":{let r=new It.Reader(e);if(r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.113549.1.1.1")throw new Error("Bad RSA private OID");if(r.readByte()!==It.Null)throw new Error("Malformed RSA private key (expected null)");if(r.readByte()!==0)throw new Error("Malformed RSA private key (expected zero-length null)");if(r=new It.Reader(r.readString(It.OctetString,!0)),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");let s=r.readString(It.Integer,!0),i=r.readString(It.Integer,!0),o=r.readString(It.Integer,!0),a=r.readString(It.Integer,!0),c=r.readString(It.Integer,!0);r.readString(It.Integer,!0),r.readString(It.Integer,!0);let l=r.readString(It.Integer,!0),u=Buffer.from("ssh-rsa"),f=Buffer.allocUnsafe(4+u.length+4+s.length+4+i.length+4+o.length+4+l.length+4+a.length+4+c.length),h=0;f.writeUInt32BE(u.length,h+=0),f.set(u,h+=4),f.writeUInt32BE(s.length,h+=u.length),f.set(s,h+=4),f.writeUInt32BE(i.length,h+=s.length),f.set(i,h+=4),f.writeUInt32BE(o.length,h+=i.length),f.set(o,h+=4),f.writeUInt32BE(l.length,h+=o.length),f.set(l,h+=4),f.writeUInt32BE(a.length,h+=l.length),f.set(a,h+=4),f.writeUInt32BE(c.length,h+=a.length),f.set(c,h+=4);let p=Buffer.allocUnsafe(4+u.length+4+i.length+4+s.length);return h=0,p.writeUInt32BE(u.length,h+=0),p.set(u,h+=4),p.writeUInt32BE(i.length,h+=u.length),p.set(i,h+=4),p.writeUInt32BE(s.length,h+=i.length),p.set(s,h+=4),{sshName:u.toString(),priv:f,pub:p}}case"ec":{let r=new It.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA public OID");r.readOID();let s=r.readString(It.BitString,!0);{let h=0;for(;h<s.length&&s[h]===0;++h);h>0&&(s=s.slice(h))}if(r=new It.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ECDSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA private OID");let i=r.readOID(),o;switch(i){case"1.2.840.10045.3.1.7":o="nistp256";break;case"1.3.132.0.34":o="nistp384";break;case"1.3.132.0.35":o="nistp521";break;default:throw new Error("Unsupported curve in ECDSA private key")}if(r=new It.Reader(r.readString(It.OctetString,!0)),r.readSequence(),r.readInt()!==1)throw new Error("Unsupported version in ECDSA private key");let a=Buffer.concat([Buffer.from([0]),r.readString(It.OctetString,!0)]),c=Buffer.from(`ecdsa-sha2-${o}`);o=Buffer.from(o);let l=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length+4+a.length),u=0;l.writeUInt32BE(c.length,u+=0),l.set(c,u+=4),l.writeUInt32BE(o.length,u+=c.length),l.set(o,u+=4),l.writeUInt32BE(s.length,u+=o.length),l.set(s,u+=4),l.writeUInt32BE(a.length,u+=s.length),l.set(a,u+=4);let f=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length);return u=0,f.writeUInt32BE(c.length,u+=0),f.set(c,u+=4),f.writeUInt32BE(o.length,u+=c.length),f.set(o,u+=4),f.writeUInt32BE(s.length,u+=o.length),f.set(s,u+=4),{sshName:c.toString(),priv:l,pub:f}}case"ed25519":{let r=new It.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let s=r.readString(It.BitString,!0);{let u=0;for(;u<s.length&&s[u]===0;++u);u>0&&(s=s.slice(u))}if(r=new It.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ED25519 private key");if(r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 private OID");r=new It.Reader(r.readString(It.OctetString,!0));let i=r.readString(It.OctetString,!0),o=Buffer.from("ssh-ed25519"),a=Buffer.allocUnsafe(4+o.length+4+s.length+4+(i.length+s.length)),c=0;a.writeUInt32BE(o.length,c+=0),a.set(o,c+=4),a.writeUInt32BE(s.length,c+=o.length),a.set(s,c+=4),a.writeUInt32BE(i.length+s.length,c+=s.length),a.set(i,c+=4),a.set(s,c+=i.length);let l=Buffer.allocUnsafe(4+o.length+4+s.length);return c=0,l.writeUInt32BE(o.length,c+=0),l.set(o,c+=4),l.writeUInt32BE(s.length,c+=o.length),l.set(s,c+=4),{sshName:o.toString(),priv:a,pub:l}}}}function Ph(n,t,e,r){let s="new",i,o="";if(typeof r=="object"&&r!==null&&(typeof r.comment=="string"&&r.comment&&(o=r.comment),typeof r.format=="string"&&r.format&&(s=r.format),r.passphrase)){let a;if(typeof r.passphrase=="string")a=Buffer.from(r.passphrase);else if(Buffer.isBuffer(r.passphrase))a=r.passphrase;else throw new Error("Invalid passphrase");if(r.cipher===void 0)throw new Error("Missing cipher name");let c=my.get(r.cipher);if(c===void 0)throw new Error("Invalid cipher name");if(s==="new"){let l=hy;if(r.rounds!==void 0){if(!Number.isInteger(r.rounds))throw new TypeError("rounds must be an integer");r.rounds>0&&(l=r.rounds)}let u=Buffer.allocUnsafe(c.keyLen+c.ivLen),f=Bh(dy);if(uy(a,a.length,f,f.length,u,u.length,l)!==0)return new Error("Failed to generate information to encrypt key");let p=Buffer.allocUnsafe(4+f.length+4);{let A=0;p.writeUInt32BE(f.length,A+=0),p.set(f,A+=4),p.writeUInt32BE(l,A+=f.length)}i={cipher:c,cipherName:r.cipher,kdfName:"bcrypt",kdfOptions:p,key:u.slice(0,c.keyLen),iv:u.slice(c.keyLen)}}}switch(s){case"new":{let a=`-----BEGIN OPENSSH PRIVATE KEY-----
|
|
15
|
+
${e}`}};var Mg=2**32,Dd=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();Fi.ERR_OUT_OF_RANGE=class Ud extends RangeError{constructor(t,e,r,s){super(),Error.captureStackTrace(this,Ud),no(e,'Missing "range" argument');let i=s?t:`The value of "${t}" is out of range.`,o;Number.isInteger(r)&&Math.abs(r)>Mg?o=Od(String(r)):typeof r=="bigint"?(o=String(r),(r>Dd||r<-Dd)&&(o=Od(o)),o+="n"):o=Og(r),i+=` It must be ${e}. Received ${o}`,this.message=i}};var ro=class n extends TypeError{constructor(t,e,r){super(),Error.captureStackTrace(this,n),no(typeof t=="string","'name' must be a string");let s;typeof e=="string"&&e.startsWith("not ")?(s="must not be",e=e.replace(/^not /,"")):s="must be";let i;if(t.endsWith(" argument"))i=`The ${t} ${s} ${Md(e,"type")}`;else{let o=t.includes(".")?"property":"argument";i=`The "${t}" ${o} ${s} ${Md(e,"type")}`}i+=`. Received type ${typeof r}`,this.message=i}};Fi.ERR_INVALID_ARG_TYPE=ro;Fi.validateNumber=function(t,e){if(typeof t!="number")throw new ro(e,"number",t)}});var Hi=ut((Qx,Jd)=>{"use strict";var Dg=require("events"),or=require("fs"),{constants:an}=or,{Readable:Vd,Writable:ic}=require("stream"),{inherits:Kd,types:{isDate:Ja}}=require("util"),Lg=Buffer[Symbol.species],{bufferCopy:sr,bufferSlice:Zr,makeBufferParser:Ug,writeUInt32BE:G}=xn(),zn={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},Te=Buffer.alloc(28),rt={OK:0,EOF:1,NO_SUCH_FILE:2,PERMISSION_DENIED:3,FAILURE:4,BAD_MESSAGE:5,NO_CONNECTION:6,CONNECTION_LOST:7,OP_UNSUPPORTED:8},$g=new Map(Object.values(rt).map(n=>[n,1])),Fg={[rt.OK]:"No error",[rt.EOF]:"End of file",[rt.NO_SUCH_FILE]:"No such file or directory",[rt.PERMISSION_DENIED]:"Permission denied",[rt.FAILURE]:"Failure",[rt.BAD_MESSAGE]:"Bad message",[rt.NO_CONNECTION]:"No connection",[rt.CONNECTION_LOST]:"Connection lost",[rt.OP_UNSUPPORTED]:"Operation unsupported"},Be={INIT:1,OPEN:3,CLOSE:4,READ:5,WRITE:6,LSTAT:7,FSTAT:8,SETSTAT:9,FSETSTAT:10,OPENDIR:11,READDIR:12,REMOVE:13,MKDIR:14,RMDIR:15,REALPATH:16,STAT:17,RENAME:18,READLINK:19,SYMLINK:20,EXTENDED:200},cn={VERSION:2,STATUS:101,HANDLE:102,DATA:103,NAME:104,ATTRS:105,EXTENDED:201},ke={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},Fd=2*1024,mt=2**32-1,Hg=Buffer.from([0,0,0,5,Be.INIT,0,0,0,3]),Qg=Buffer.from([0,0,0,5,cn.VERSION,0,0,0,3]),Wg=/^SSH-2.0-(?:OpenSSH|dropbear)/,ja=256*1024,Q=Ug(),qg={readable:!1,writable:!1,push:n=>{},once:()=>{},on:()=>{},emit:()=>{},end:()=>{}};function zd(){}var Za=class extends Dg{constructor(t,e,r){super(),(typeof r!="object"||!r)&&(r={});let s=t._protocol._remoteIdentRaw;this.server=!!r.server,this._debug=typeof r.debug=="function"?r.debug:void 0,this._isOpenSSH=s&&Wg.test(s),this._version=-1,this._extensions={},this._biOpt=r.biOpt,this._pktLenBytes=0,this._pktLen=0,this._pktPos=0,this._pktType=0,this._pktData=void 0,this._writeReqid=-1,this._requests={},this._maxInPktLen=ja,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?ja:34e3)-Fd,this._maxWriteLen=(this._isOpenSSH?ja:34e3)-Fd,this.maxOpenHandles=void 0,this._client=t,this._protocol=t._protocol,this._callbacks=[],this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this._waitWindow=!1,this._chunkcb=void 0,this._buffer=[],this.type=e.type,this.subtype=void 0,this.incoming=e.incoming,this.outgoing=e.outgoing,this.stderr=qg,this.readable=!0}push(t){if(t===null){if(Xd(this),!this.readable)return;this.readable=!1,this.emit("end");return}let e=0;for(;e<t.length;){if(this._pktLenBytes<4){let o=Math.min(4-this._pktLenBytes,t.length-e);for(this._pktLenBytes+=o;o--;)this._pktLen=(this._pktLen<<8)+t[e++];if(this._pktLenBytes<4)return;if(this._pktLen===0)return ct(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let a=this._maxInPktLen;return ct(this,`Packet length ${this._pktLen} exceeds max length of ${a}`)}if(e>=t.length)return}if(this._pktPos<this._pktLen){let o=Math.min(this._pktLen-this._pktPos,t.length-e);if(e!==0||o!==t.length?o===this._pktLen?this._pkt=new Lg(t.buffer,t.byteOffset+e,o):(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._pktPos)):o===this._pktLen?this._pkt=t:(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(t,this._pktPos)),e+=o,this._pktPos+=o,this._pktPos<this._pktLen)return}let r=this._pkt[0],s=this._pkt;this._pktLen=0,this._pktLenBytes=0,this._pkt=void 0,this._pktPos=0;let i=this.server?Yg[r]:Gg[r];if(!i)return ct(this,`Unknown packet type ${r}`);if(this._version===-1){if(this.server){if(r!==Be.INIT)return ct(this,`Expected INIT packet, got ${r}`)}else if(r!==cn.VERSION)return ct(this,`Expected VERSION packet, got ${r}`)}if(i(this,s)===!1)return}}end(){this.destroy()}destroy(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._protocol.channelClose(this.outgoing.id))}_init(){this._init=zd,this.server||et(this,Hg)}createReadStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new Gn(this,t,e)}createWriteStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new Sn(this,t,e)}open(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");typeof r=="function"&&(s=r,r=void 0);let i=typeof e=="number"?e:Yd(e);if(i===null)throw new Error(`Unknown flags string: ${e}`);let o=0,a=0;(typeof r=="string"||typeof r=="number")&&(r={mode:r}),typeof r=="object"&&r!==null&&(r=Sr(r),o=r.flags,a=r.nb);let c=Buffer.byteLength(t),l=9,u=Buffer.allocUnsafe(13+c+4+4+a);G(u,u.length-4,0),u[4]=Be.OPEN;let f=this._writeReqid=this._writeReqid+1&mt;G(u,f,5),G(u,c,l),u.utf8Write(t,l+=4,c),G(u,i,l+=c),G(u,o,l+=4),a&&(l+=4,a===Te.length?u.set(Te,l):sr(Te,u,0,a,l),l+=a),this._requests[f]={cb:s};let h=et(this,u);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} OPEN`)}close(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.CLOSE;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} CLOSE`)}read(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(r>=e.length)throw new Error("offset is out of bounds");if(r+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");Gd(this,t,e,r,s,i,o)}readData(t,e,r,s,i,o){this.read(t,e,r,s,i,o)}write(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(r>e.length)throw new Error("offset is out of bounds");if(r+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");if(!s){o&&process.nextTick(o,void 0,0);return}let a=this._maxWriteLen,c=Math.max(s-a,0),l=i;c&&(s=a);let u=t.length,f=9,h=Buffer.allocUnsafe(13+u+8+4+s);G(h,h.length-4,0),h[4]=Be.WRITE;let p=this._writeReqid=this._writeReqid+1&mt;G(h,p,5),G(h,u,f),h.set(t,f+=4),f+=u;for(let E=7;E>=0;--E)h[f+E]=i&255,i/=256;G(h,s,f+=8),sr(e,h,r,r+s,f+=4),this._requests[p]={cb:E=>{E?typeof o=="function"&&o(E):c?this.write(t,e,r+s,c,l+s,o):typeof o=="function"&&o(void 0,r+s)}};let A=et(this,h);if(this._debug){let E=A?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${E} WRITE (id:${p})`)}}writeData(t,e,r,s,i,o){this.write(t,e,r,s,i,o)}fastGet(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");Hd(this,or,t,e,r,s)}fastPut(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");Hd(or,this,t,e,r,s)}readFile(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s;if(typeof r=="function"?s=r:typeof e=="function"&&(s=e,e=void 0),typeof e=="string")e={encoding:e,flag:"r"};else if(!e)e={encoding:null,flag:"r"};else if(typeof e!="object")throw new TypeError("Bad arguments");let i=e.encoding;if(i&&!Buffer.isEncoding(i))throw new Error(`Unknown encoding: ${i}`);let o,a,c,l=0,u,f=0,h=e.flag||"r",p=()=>{o===0?(a=Buffer.allocUnsafe(8192),this.read(u,a,0,8192,f,A)):this.read(u,a,l,o-l,f,A)},A=(b,x)=>{let P;if(b){if(P=b.code===rt.EOF,!P)return this.close(u,()=>s&&s(b))}else P=!1;if(P||o===0&&x===0)return E();f+=x,l+=x,o!==0?l===o?E():p():(c.push(Zr(a,0,x)),p())};A._wantEOFError=!0;let E=()=>{this.close(u,b=>(o===0?a=Buffer.concat(c,l):l<o&&(a=Zr(a,0,l)),i&&(a=a.toString(i)),s&&s(b,a)))};this.open(t,h,438,(b,x)=>{if(b)return s&&s(b);u=x;let P=(q,C)=>{if(q){this.stat(t,($,F)=>{if($)return this.close(u,()=>{s&&s(q)});P(null,F)});return}if(o=C.size||0,o===0)return c=[],p();a=Buffer.allocUnsafe(o),p()};this.fstat(u,P)})}writeFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"w"};else if(!r)r={encoding:"utf8",mode:438,flag:"w"};else if(typeof r!="object")throw new TypeError("Bad arguments");if(r.encoding&&!Buffer.isEncoding(r.encoding))throw new Error(`Unknown encoding: ${r.encoding}`);let o=r.flag||"w";this.open(t,o,r.mode,(a,c)=>{if(a)i&&i(a);else{let l=Buffer.isBuffer(e)?e:Buffer.from(""+e,r.encoding||"utf8"),u=/a/.test(o)?null:0;if(u===null){let f=(h,p)=>{if(h){this.stat(t,(A,E)=>{if(A)return this.close(c,()=>{i&&i(h)});f(null,E)});return}ec(this,c,l,0,l.length,p.size,i)};this.fstat(c,f);return}ec(this,c,l,0,l.length,u,i)}})}appendFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"a"};else if(!r)r={encoding:"utf8",mode:438,flag:"a"};else if(typeof r!="object")throw new TypeError("Bad arguments");r.flag||(r=Object.assign({flag:"a"},r)),this.writeFile(t,e,r,i)}exists(t,e){if(this.server)throw new Error("Client-only method called in server mode");this.stat(t,r=>{e&&e(!r)})}unlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.REMOVE;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REMOVE`)}rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=Buffer.byteLength(e),o=9,a=Buffer.allocUnsafe(13+s+4+i);G(a,a.length-4,0),a[4]=Be.RENAME;let c=this._writeReqid=this._writeReqid+1&mt;G(a,c,5),G(a,s,o),a.utf8Write(t,o+=4,s),G(a,i,o+=s),a.utf8Write(e,o+=4,i),this._requests[c]={cb:r};let l=et(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} RENAME`)}mkdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="function"&&(r=e,e=void 0),typeof e=="object"&&e!==null&&(e=Sr(e),s=e.flags,i=e.nb);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);G(c,c.length-4,0),c[4]=Be.MKDIR;let l=this._writeReqid=this._writeReqid+1&mt;G(c,l,5),G(c,o,a),c.utf8Write(t,a+=4,o),G(c,s,a+=o),i&&(a+=4,i===Te.length?c.set(Te,a):sr(Te,c,0,i,a),a+=i),this._requests[l]={cb:r};let u=et(this,c);this._debug&&this._debug(`SFTP: Outbound: ${u?"Buffered":"Sending"} MKDIR`)}rmdir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.RMDIR;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} RMDIR`)}readdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");typeof e=="function"&&(r=e,e={}),(typeof e!="object"||e===null)&&(e={});let s=!(e&&e.full);if(!Buffer.isBuffer(t)&&typeof t!="string")throw new Error("missing directory handle or path");if(typeof t=="string"){let u=[],f=0,h=(p,A)=>{if(p)return r(p);this.readdir(A,e,(E,b)=>{let x=E&&E.code===rt.EOF;if(E&&!x)return this.close(A,()=>r(E));if(x)return this.close(A,P=>{if(P)return r(P);r(void 0,u)});for(let P=0;P<b.length;++P,++f)u[f]=b[P];h(void 0,A)})};return this.opendir(t,h)}let i=t.length,o=9,a=Buffer.allocUnsafe(13+i);G(a,a.length-4,0),a[4]=Be.READDIR;let c=this._writeReqid=this._writeReqid+1&mt;G(a,c,5),G(a,i,o),a.set(t,o+=4),this._requests[c]={cb:s?(u,f)=>{if(typeof r=="function"){if(u)return r(u);for(let h=f.length-1;h>=0;--h)(f[h].filename==="."||f[h].filename==="..")&&f.splice(h,1);r(void 0,f)}}:r};let l=et(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} READDIR`)}fstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.FSTAT;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} FSTAT`)}stat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.STAT;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STAT`)}lstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.LSTAT;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} LSTAT`)}opendir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.OPENDIR;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} OPENDIR`)}setstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="object"&&e!==null?(e=Sr(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);G(c,c.length-4,0),c[4]=Be.SETSTAT;let l=this._writeReqid=this._writeReqid+1&mt;G(c,l,5),G(c,o,a),c.utf8Write(t,a+=4,o),G(c,s,a+=o),i&&(a+=4,i===Te.length?c.set(Te,a):sr(Te,c,0,i,a),a+=i),this._requests[l]={cb:r};let u=et(this,c);this._debug&&this._debug(`SFTP: Outbound: ${u?"Buffered":"Sending"} SETSTAT`)}fsetstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=0,i=0;typeof e=="object"&&e!==null?(e=Sr(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=t.length,a=9,c=Buffer.allocUnsafe(13+o+4+i);G(c,c.length-4,0),c[4]=Be.FSETSTAT;let l=this._writeReqid=this._writeReqid+1&mt;G(c,l,5),G(c,o,a),c.set(t,a+=4),G(c,s,a+=o),i&&(a+=4,i===Te.length?c.set(Te,a):sr(Te,c,0,i,a),a+=i),this._requests[l]={cb:r};let u=et(this,c);this._debug&&this._debug(`SFTP: Outbound: ${u?"Buffered":"Sending"} FSETSTAT`)}futimes(t,e,r,s){return this.fsetstat(t,{atime:Xr(e),mtime:Xr(r)},s)}utimes(t,e,r,s){return this.setstat(t,{atime:Xr(e),mtime:Xr(r)},s)}fchown(t,e,r,s){return this.fsetstat(t,{uid:e,gid:r},s)}chown(t,e,r,s){return this.setstat(t,{uid:e,gid:r},s)}fchmod(t,e,r){return this.fsetstat(t,{mode:e},r)}chmod(t,e,r){return this.setstat(t,{mode:e},r)}readlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.READLINK;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,l)=>{if(typeof e=="function"){if(c)return e(c);if(!l||!l.length)return e(new Error("Response missing link info"));e(void 0,l[0].filename)}}};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} READLINK`)}symlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),i=Buffer.byteLength(t),o=9,a=Buffer.allocUnsafe(13+s+4+i);G(a,a.length-4,0),a[4]=Be.SYMLINK;let c=this._writeReqid=this._writeReqid+1&mt;G(a,c,5),this._isOpenSSH?(G(a,i,o),a.utf8Write(t,o+=4,i),G(a,s,o+=i),a.utf8Write(e,o+=4,s)):(G(a,s,o),a.utf8Write(e,o+=4,s),G(a,i,o+=s),a.utf8Write(t,o+=4,i)),this._requests[c]={cb:r};let l=et(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} SYMLINK`)}realpath(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=Be.REALPATH;let o=this._writeReqid=this._writeReqid+1&mt;G(i,o,5),G(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,l)=>{if(typeof e=="function"){if(c)return e(c);if(!l||!l.length)return e(new Error("Response missing path info"));e(void 0,l[0].filename)}}};let a=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REALPATH`)}ext_openssh_rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=this._extensions["posix-rename@openssh.com"];if(!s||s!=="1")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(41+i+4+o);G(c,c.length-4,0),c[4]=Be.EXTENDED;let l=this._writeReqid=this._writeReqid+1&mt;G(c,l,5),G(c,24,a),c.utf8Write("posix-rename@openssh.com",a+=4,24),G(c,i,a+=24),c.utf8Write(t,a+=4,i),G(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[l]={cb:r};let u=et(this,c);if(this._debug){let f=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} posix-rename@openssh.com`)}}ext_openssh_statvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["statvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(36+s);G(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,5),G(o,19,i),o.utf8Write("statvfs@openssh.com",i+=4,19),G(o,s,i+=19),o.utf8Write(t,i+=4,s),this._requests[a]={extended:"statvfs@openssh.com",cb:e};let c=et(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} statvfs@openssh.com`)}}ext_openssh_fstatvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["fstatvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=t.length,i=9,o=Buffer.allocUnsafe(37+s);G(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,5),G(o,20,i),o.utf8Write("fstatvfs@openssh.com",i+=4,20),G(o,s,i+=20),o.set(t,i+=4),this._requests[a]={extended:"fstatvfs@openssh.com",cb:e};let c=et(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} fstatvfs@openssh.com`)}}ext_openssh_hardlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["hardlink@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(37+i+4+o);G(c,c.length-4,0),c[4]=Be.EXTENDED;let l=this._writeReqid=this._writeReqid+1&mt;G(c,l,5),G(c,20,a),c.utf8Write("hardlink@openssh.com",a+=4,20),G(c,i,a+=20),c.utf8Write(t,a+=4,i),G(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[l]={cb:r};let u=et(this,c);if(this._debug){let f=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} hardlink@openssh.com`)}}ext_openssh_fsync(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["fsync@openssh.com"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=t.length,i=9,o=Buffer.allocUnsafe(34+s);G(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,5),G(o,17,i),o.utf8Write("fsync@openssh.com",i+=4,17),G(o,s,i+=17),o.set(t,i+=4),this._requests[a]={cb:e};let c=et(this,o);this._debug&&this._debug(`SFTP: Outbound: ${c?"Buffered":"Sending"} fsync@openssh.com`)}ext_openssh_lsetstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["lsetstat@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let i=0,o=0;typeof e=="object"&&e!==null?(e=Sr(e),i=e.flags,o=e.nb):typeof e=="function"&&(r=e);let a=Buffer.byteLength(t),c=9,l=Buffer.allocUnsafe(37+a+4+o);G(l,l.length-4,0),l[4]=Be.EXTENDED;let u=this._writeReqid=this._writeReqid+1&mt;G(l,u,5),G(l,20,c),l.utf8Write("lsetstat@openssh.com",c+=4,20),G(l,a,c+=20),l.utf8Write(t,c+=4,a),G(l,i,c+=a),o&&(c+=4,o===Te.length?l.set(Te,c):sr(Te,l,0,o,c),c+=o),this._requests[u]={cb:r};let f=et(this,l);if(this._debug){let h=f?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} lsetstat@openssh.com`)}}ext_openssh_expandPath(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["expand-path@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(40+s);G(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,5),G(o,23,i),o.utf8Write("expand-path@openssh.com",i+=4,23),G(o,s,i+=20),o.utf8Write(t,i+=4,s),this._requests[a]={cb:(l,u)=>{if(typeof e=="function"){if(l)return e(l);if(!u||!u.length)return e(new Error("Response missing expanded path"));e(void 0,u[0].filename)}}};let c=et(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} expand-path@openssh.com`)}}ext_copy_data(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["copy-data"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("Source handle is not a Buffer");if(!Buffer.isBuffer(s))throw new Error("Destination handle is not a Buffer");let c=0,l=Buffer.allocUnsafe(26+t.length+8+8+4+s.length+8);G(l,l.length-4,c),c+=4,l[c]=Be.EXTENDED,++c;let u=this._writeReqid=this._writeReqid+1&mt;G(l,u,c),c+=4,G(l,9,c),c+=4,l.utf8Write("copy-data",c,9),c+=9,G(l,t.length,c),c+=4,l.set(t,c),c+=t.length;for(let h=7;h>=0;--h)l[c+h]=e&255,e/=256;c+=8;for(let h=7;h>=0;--h)l[c+h]=r&255,r/=256;c+=8,G(l,s.length,c),c+=4,l.set(s,c),c+=s.length;for(let h=7;h>=0;--h)l[c+h]=i&255,i/=256;this._requests[u]={cb:o};let f=et(this,l);if(this._debug){let h=f?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} copy-data`)}}ext_home_dir(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["home-directory"]!=="1")throw new Error("Server does not support this extended request");if(typeof t!="string")throw new TypeError("username is not a string");let s=0,i=Buffer.byteLength(t),o=Buffer.allocUnsafe(31+i);G(o,o.length-4,s),s+=4,o[s]=Be.EXTENDED,++s;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,s),s+=4,G(o,14,s),s+=4,o.utf8Write("home-directory",s,14),s+=14,G(o,i,s),s+=4,o.utf8Write(t,s,i),s+=i,this._requests[a]={cb:(l,u)=>{if(typeof e=="function"){if(l)return e(l);if(!u||!u.length)return e(new Error("Response missing home directory"));e(void 0,u[0].filename)}}};let c=et(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} home-directory`)}}ext_users_groups(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["users-groups-by-id@openssh.com"]!=="1")throw new Error("Server does not support this extended request");if(!Array.isArray(t))throw new TypeError("uids is not an array");for(let l of t)if(!Number.isInteger(l)||l<0||l>2**32-1)throw new Error("uid values must all be 32-bit unsigned integers");if(!Array.isArray(e))throw new TypeError("gids is not an array");for(let l of e)if(!Number.isInteger(l)||l<0||l>2**32-1)throw new Error("gid values must all be 32-bit unsigned integers");let i=0,o=Buffer.allocUnsafe(47+4*t.length+4+4*e.length);G(o,o.length-4,i),i+=4,o[i]=Be.EXTENDED,++i;let a=this._writeReqid=this._writeReqid+1&mt;G(o,a,i),i+=4,G(o,30,i),i+=4,o.utf8Write("users-groups-by-id@openssh.com",i,30),i+=30,G(o,4*t.length,i),i+=4;for(let l of t)G(o,l,i),i+=4;G(o,4*e.length,i),i+=4;for(let l of e)G(o,l,i),i+=4;this._requests[a]={extended:"users-groups-by-id@openssh.com",cb:r};let c=et(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} users-groups-by-id@openssh.com`)}}handle(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let r=e.length;if(r>256)throw new Error("handle too large (> 256 bytes)");let s=9,i=Buffer.allocUnsafe(13+r);G(i,i.length-4,0),i[4]=cn.HANDLE,G(i,t,5),G(i,r,s),r&&i.set(e,s+=4);let o=et(this,i);this._debug&&this._debug(`SFTP: Outbound: ${o?"Buffered":"Sending"} HANDLE`)}status(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(!$g.has(e))throw new Error(`Bad status code: ${e}`);r||(r="");let s=Buffer.byteLength(r),i=9,o=Buffer.allocUnsafe(17+s+4);G(o,o.length-4,0),o[4]=cn.STATUS,G(o,t,5),G(o,e,i),G(o,s,i+=4),i+=4,s&&(o.utf8Write(r,i,s),i+=s),G(o,0,i);let a=et(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STATUS`)}data(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");let s=Buffer.isBuffer(e);if(!s&&typeof e!="string")throw new Error("data is not a Buffer or string");let i;!s&&!r&&(r=void 0,i=!0);let o=s?e.length:Buffer.byteLength(e,r),a=9,c=Buffer.allocUnsafe(13+o);G(c,c.length-4,0),c[4]=cn.DATA,G(c,t,5),G(c,o,a),o&&(s?c.set(e,a+=4):i?c.utf8Write(e,a+=4,o):c.write(e,a+=4,o,r));let l=et(this,c);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} DATA`)}name(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Array.isArray(e)){if(typeof e!="object"||e===null)throw new Error("names is not an object or array");e=[e]}let r=e.length,s=0,i,o=[];for(let u=0;u<r;++u){let f=e[u],h=!f||!f.filename||typeof f.filename!="string"?"":f.filename;s+=4+Buffer.byteLength(h);let p=!f||!f.longname||typeof f.longname!="string"?"":f.longname;if(s+=4+Buffer.byteLength(p),typeof f.attrs=="object"&&f.attrs!==null){if(i=Sr(f.attrs),s+=4+i.nb,i.nb){let A;i.nb===Te.length?A=new Uint8Array(Te):(A=new Uint8Array(i.nb),sr(Te,A,0,i.nb,0)),i.bytes=A}o.push(i)}else s+=4,o.push(null)}let a=9,c=Buffer.allocUnsafe(13+s);G(c,c.length-4,0),c[4]=cn.NAME,G(c,t,5),G(c,r,a),a+=4;for(let u=0;u<r;++u){let f=e[u];{let p=!f||!f.filename||typeof f.filename!="string"?"":f.filename,A=Buffer.byteLength(p);G(c,A,a),a+=4,A&&(c.utf8Write(p,a,A),a+=A)}{let p=!f||!f.longname||typeof f.longname!="string"?"":f.longname,A=Buffer.byteLength(p);G(c,A,a),a+=4,A&&(c.utf8Write(p,a,A),a+=A)}let h=o[u];h?(G(c,h.flags,a),a+=4,h.flags&&h.bytes&&(c.set(h.bytes,a),a+=h.nb)):(G(c,0,a),a+=4)}let l=et(this,c);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} NAME`)}attrs(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(typeof e!="object"||e===null)throw new Error("attrs is not an object");e=Sr(e);let r=e.flags,s=e.nb,i=9,o=Buffer.allocUnsafe(13+s);G(o,o.length-4,0),o[4]=cn.ATTRS,G(o,t,5),G(o,r,i),s&&(i+=4,s===Te.length?o.set(Te,i):sr(Te,o,0,s,i),i+=s);let a=et(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} ATTRS`)}};function Vg(n){try{return Buffer.allocUnsafe(n)}catch(t){return t}}function Gd(n,t,e,r,s,i,o,a){let c=n._maxReadLen,l=Math.max(s-c,0);l&&(s=c);let u=t.length,f=9,h=i,p=Buffer.allocUnsafe(13+u+8+4);G(p,p.length-4,0),p[4]=Be.READ;let A=n._writeReqid=n._writeReqid+1&mt;G(p,A,5),G(p,u,f),p.set(t,f+=4),f+=u;for(let x=7;x>=0;--x)p[f+x]=h&255,h/=256;G(p,s,f+=8),typeof o!="function"&&(o=zd);let E=a||{nb:0,position:i,off:r,origOff:r,len:void 0,overflow:void 0,cb:(x,P,q)=>{let C=E.len,$=E.overflow;if(x){if(o._wantEOFError||x.code!==rt.EOF)return o(x)}else{if(q>C)return o(new Error("Received more data than requested"));if(q===C&&$){E.nb+=q,E.position+=q,E.off+=q,Gd(n,t,e,E.off,$,E.position,o,E);return}}q=q||0,E.origOff===0&&e.length===E.nb?P=e:P=Zr(e,E.origOff,E.origOff+E.nb+q),o(void 0,E.nb+q,P,E.position)},buffer:void 0};E.len=s,E.overflow=l,E.buffer=Zr(e,r,r+s),n._requests[A]=E;let b=et(n,p);n._debug&&n._debug(`SFTP: Outbound: ${b?"Buffered":"Sending"} READ`)}function Hd(n,t,e,r,s,i){let o=64,a=32768,c,l,u;typeof s=="function"?i=s:typeof s=="object"&&s!==null&&(typeof s.concurrency=="number"&&s.concurrency>0&&!isNaN(s.concurrency)&&(o=s.concurrency),typeof s.chunkSize=="number"&&s.chunkSize>0&&!isNaN(s.chunkSize)&&(a=s.chunkSize),typeof s.fileSize=="number"&&s.fileSize>0&&!isNaN(s.fileSize)&&(u=s.fileSize),typeof s.step=="function"&&(c=s.step),(typeof s.mode=="string"||typeof s.mode=="number")&&(l=sc(s.mode)));let f,h=0,p=0,A=!1,E,b,x,P=a*o;function q(C){if(A)return;A=!0;let $=0,F;E||b?(F=()=>{--$===0&&i(C)},E&&(n===or||n.outgoing.state==="open")&&++$,b&&(t===or||t.outgoing.state==="open")&&++$,E&&(n===or||n.outgoing.state==="open")&&n.close(E,F),b&&(t===or||t.outgoing.state==="open")&&t.close(b,F)):i(C)}n.open(e,"r",(C,$)=>{if(C)return q(C);E=$,u===void 0?n.fstat(E,F):F(null,{size:u});function F(v,_){if(v){if(n!==or){n.stat(e,(w,k)=>{if(w)return q(v);F(null,k)});return}return q(v)}f=_.size,t.open(r,"w",(w,k)=>{if(w)return q(w);if(b=k,f<=0)return q();for(;P>f;){if(o===1){P=f;break}P-=a,--o}if(x=Vg(P),x instanceof Error)return q(x);l!==void 0?t.fchmod(b,l,function X(re){if(re){t.chmod(r,l,fe=>X());return}j()}):j();function N(X,re,fe,H,B,D){if(X)return q(X);B=B||0,t.write(b,x,B,re,H,z);function z(ne){if(ne)return q(ne);if(p+=re,c&&c(p,re,f),re<D)return ie(B,H+re,D-re);if(p===f){t.close(b,oe=>{if(b=void 0,oe)return q(oe);n.close(E,Je=>{if(E=void 0,Je)return q(Je);i()})});return}if(h>=f)return;let de=h+a>f?f-h:a;ie(B,h,de),h+=de}}function R(X,re,fe){return(H,B,D)=>{N(H,B,D,re,X,fe)}}function ie(X,re,fe){n.read(E,x,X,fe,re,R(X,re,fe))}function j(){let X=0,re=0;for(;h<f&&X<o;){let fe=h+a>f?f-h:a;ie(re,h,fe),re+=fe,h+=fe,++X}}})}})}function ec(n,t,e,r,s,i,o){let a=typeof o=="function"?o:void 0;n.write(t,e,r,s,i,(c,l)=>{if(c)return n.close(t,()=>{a&&a(c)});l===s?n.close(t,a):(r+=l,s-=l,i+=l,ec(n,t,e,r,s,i,a))})}var so=class{constructor(t){this.mode=t&&t.mode,this.uid=t&&t.uid,this.gid=t&&t.gid,this.size=t&&t.size,this.atime=t&&t.atime,this.mtime=t&&t.mtime,this.extended=t&&t.extended}isDirectory(){return(this.mode&an.S_IFMT)===an.S_IFDIR}isFile(){return(this.mode&an.S_IFMT)===an.S_IFREG}isBlockDevice(){return(this.mode&an.S_IFMT)===an.S_IFBLK}isCharacterDevice(){return(this.mode&an.S_IFMT)===an.S_IFCHR}isSymbolicLink(){return(this.mode&an.S_IFMT)===an.S_IFLNK}isFIFO(){return(this.mode&an.S_IFMT)===an.S_IFIFO}isSocket(){return(this.mode&an.S_IFMT)===an.S_IFSOCK}};function Sr(n){let t=0,e=0;if(typeof n=="object"&&n!==null){if(typeof n.size=="number"){t|=zn.SIZE;let r=n.size;Te[e++]=r/72057594037927940,Te[e++]=r/281474976710656,Te[e++]=r/1099511627776,Te[e++]=r/4294967296,Te[e++]=r/16777216,Te[e++]=r/65536,Te[e++]=r/256,Te[e++]=r}if(typeof n.uid=="number"&&typeof n.gid=="number"){t|=zn.UIDGID;let r=n.uid,s=n.gid;Te[e++]=r>>>24,Te[e++]=r>>>16,Te[e++]=r>>>8,Te[e++]=r,Te[e++]=s>>>24,Te[e++]=s>>>16,Te[e++]=s>>>8,Te[e++]=s}if(typeof n.mode=="number"||typeof n.mode=="string"){let r=sc(n.mode);t|=zn.PERMISSIONS,Te[e++]=r>>>24,Te[e++]=r>>>16,Te[e++]=r>>>8,Te[e++]=r}if((typeof n.atime=="number"||Ja(n.atime))&&(typeof n.mtime=="number"||Ja(n.mtime))){let r=Xr(n.atime),s=Xr(n.mtime);t|=zn.ACMODTIME,Te[e++]=r>>>24,Te[e++]=r>>>16,Te[e++]=r>>>8,Te[e++]=r,Te[e++]=s>>>24,Te[e++]=s>>>16,Te[e++]=s>>>8,Te[e++]=s}}return{flags:t,nb:e}}function Xr(n){if(typeof n=="number"&&n===n)return n;if(Ja(n))return parseInt(n.getTime()/1e3,10);throw new Error(`Cannot parse time: ${n}`)}function sc(n){if(typeof n=="number"&&n===n)return n;if(typeof n=="string")return sc(parseInt(n,8));throw new Error(`Cannot parse mode: ${n}`)}var tc={r:ke.READ,"r+":ke.READ|ke.WRITE,w:ke.TRUNC|ke.CREAT|ke.WRITE,wx:ke.TRUNC|ke.CREAT|ke.WRITE|ke.EXCL,xw:ke.TRUNC|ke.CREAT|ke.WRITE|ke.EXCL,"w+":ke.TRUNC|ke.CREAT|ke.READ|ke.WRITE,"wx+":ke.TRUNC|ke.CREAT|ke.READ|ke.WRITE|ke.EXCL,"xw+":ke.TRUNC|ke.CREAT|ke.READ|ke.WRITE|ke.EXCL,a:ke.APPEND|ke.CREAT|ke.WRITE,ax:ke.APPEND|ke.CREAT|ke.WRITE|ke.EXCL,xa:ke.APPEND|ke.CREAT|ke.WRITE|ke.EXCL,"a+":ke.APPEND|ke.CREAT|ke.READ|ke.WRITE,"ax+":ke.APPEND|ke.CREAT|ke.READ|ke.WRITE|ke.EXCL,"xa+":ke.APPEND|ke.CREAT|ke.READ|ke.WRITE|ke.EXCL};function Yd(n){let t=tc[n];return t!==void 0?t:null}var Kg=(()=>{let n=Object.keys(tc);return t=>{for(let e=0;e<n.length;++e){let r=n[e];if(tc[r]===t)return r}return null}})();function Jr(n){let t=Q.readUInt32BE();if(t===void 0)return;let e=new so;if(t&zn.SIZE){let r=Q.readUInt64BE(n);if(r===void 0)return;e.size=r}if(t&zn.UIDGID){let r=Q.readUInt32BE(),s=Q.readUInt32BE();if(s===void 0)return;e.uid=r,e.gid=s}if(t&zn.PERMISSIONS){let r=Q.readUInt32BE();if(r===void 0)return;e.mode=r}if(t&zn.ACMODTIME){let r=Q.readUInt32BE(),s=Q.readUInt32BE();if(s===void 0)return;e.atime=r,e.mtime=s}if(t&zn.EXTENDED){let r=Q.readUInt32BE();if(r===void 0)return;let s={};for(let i=0;i<r;++i){let o=Q.readString(!0),a=Q.readString();if(a===void 0)return;s[o]=a}e.extended=s}return e}function et(n,t){let e=jd(n,t);return e!==void 0?(n._buffer.push(e),!1):!0}function jd(n,t){let e=n.outgoing;if(e.state!=="open")return;if(e.window===0)return n._waitWindow=!0,n._chunkcb=Qd,t;let r,s=t.length,i=0;for(;s-i>0&&e.window>0;){let o=Math.min(s-i,e.window,e.packetSize);e.window-=o,e.window===0&&(n._waitWindow=!0,n._chunkcb=Qd),i===0&&o===s?n._protocol.channelData(n.outgoing.id,t):n._protocol.channelData(n.outgoing.id,Zr(t,i,i+o)),i+=o}return s-i>0&&(i>0?r=Zr(t,i,s):r=t),r}function Qd(){this._chunkcb=void 0;let n=this._buffer,t=0;for(;t<n.length;){let e=n[t],r=jd(this,e);if(r!==void 0){r!==e&&(n[t]=r),t>0&&(this._buffer=n.slice(t));return}++t}t>0&&(this._buffer=[])}function ct(n,t,e){let r=new Error(t);return r.level="sftp-protocol",!e&&n._debug&&n._debug(`SFTP: Inbound: ${t}`),n.emit("error",r),n.destroy(),Xd(n),!1}function Xd(n){let t=Object.keys(n._requests);if(t.length===0)return;let e=n._requests;n._requests={};let r=new Error("No response from server");for(let s=0;s<t.length;++s){let i=e[t[s]];typeof i.cb=="function"&&i.cb(r)}}function zg(n,t){let e=9,r=Buffer.allocUnsafe(31);G(r,r.length-4,0),r[4]=Be.EXTENDED;let s=n._writeReqid=n._writeReqid+1&mt;G(r,s,5),G(r,18,e),r.utf8Write("limits@openssh.com",e+=4,18),n._requests[s]={extended:"limits@openssh.com",cb:t};let i=et(n,r);if(n._debug){let o=i?"Buffered":"Sending";n._debug(`SFTP: Outbound: ${o} limits@openssh.com`)}}var Gg={[cn.VERSION]:(n,t)=>{if(n._version!==-1)return ct(n,"Duplicate VERSION packet");let e={};Q.init(t,1);let r=Q.readUInt32BE();for(;Q.avail();){let s=Q.readString(!0),i=Q.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(Q.clear(),r===void 0)return ct(n,"Malformed VERSION packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received VERSION (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received VERSION (v${r})`)}if(n._version=r,n._extensions=e,e["limits@openssh.com"]==="1")return zg(n,(s,i)=>{s||(i.maxPktLen>0&&(n._maxOutPktLen=i.maxPktLen),i.maxReadLen>0&&(n._maxReadLen=i.maxReadLen),i.maxWriteLen>0&&(n._maxWriteLen=i.maxWriteLen),n.maxOpenHandles=i.maxOpenHandles>0?i.maxOpenHandles:1/0),n.emit("ready")});n.emit("ready")},[cn.STATUS]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readUInt32BE(),s=Q.readString(!0);if(Q.clear(),n._debug){let o=JSON.stringify(s);n._debug(`SFTP: Inbound: Received STATUS (id:${e}, ${r}, ${o})`)}let i=n._requests[e];if(delete n._requests[e],i&&typeof i.cb=="function"){if(r===rt.OK){i.cb();return}let o=new Error(s||Fg[r]||"Unknown status");o.code=r,i.cb(o)}},[cn.HANDLE]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString();if(Q.clear(),r===void 0)return e!==void 0&&delete n._requests[e],ct(n,"Malformed HANDLE packet");n._debug&&n._debug(`SFTP: Inbound: Received HANDLE (id:${e})`);let s=n._requests[e];delete n._requests[e],s&&typeof s.cb=="function"&&s.cb(void 0,r)},[cn.DATA]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r;if(e!==void 0&&(r=n._requests[e],delete n._requests[e]),r&&typeof r.cb=="function")if(r.buffer){let s=Q.readString(r.buffer);if(Q.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`),r.cb(void 0,r.buffer,s);return}}else{let s=Q.readString();if(Q.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s.length})`),r.cb(void 0,s);return}}else{let s=Q.skipString();if(Q.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`);return}}return ct(n,"Malformed DATA packet")},[cn.NAME]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=Q.readUInt32BE();if(s!==void 0){let i=[];for(let o=0;o<s;++o){let a=Q.readString(!0),c=Q.readString(!0),l=Jr(n._biOpt);if(l===void 0){i=void 0;break}i.push({filename:a,longname:c,attrs:l})}if(i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received NAME (id:${e}, ${i.length})`),Q.clear(),r&&typeof r.cb=="function"&&r.cb(void 0,i);return}}return Q.clear(),ct(n,"Malformed NAME packet")},[cn.ATTRS]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=Jr(n._biOpt);if(Q.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received ATTRS (id:${e})`),r&&typeof r.cb=="function"&&r.cb(void 0,s);return}return ct(n,"Malformed ATTRS packet")},[cn.EXTENDED]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE();if(e!==void 0){let r=n._requests[e];if(r)switch(delete n._requests[e],r.extended){case"statvfs@openssh.com":case"fstatvfs@openssh.com":{let s=n._biOpt,i={f_bsize:Q.readUInt64BE(s),f_frsize:Q.readUInt64BE(s),f_blocks:Q.readUInt64BE(s),f_bfree:Q.readUInt64BE(s),f_bavail:Q.readUInt64BE(s),f_files:Q.readUInt64BE(s),f_ffree:Q.readUInt64BE(s),f_favail:Q.readUInt64BE(s),f_sid:Q.readUInt64BE(s),f_flag:Q.readUInt64BE(s),f_namemax:Q.readUInt64BE(s)};if(i.f_namemax===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),Q.clear(),typeof r.cb=="function"&&r.cb(void 0,i);return}case"limits@openssh.com":{let s={maxPktLen:Q.readUInt64BE(),maxReadLen:Q.readUInt64BE(),maxWriteLen:Q.readUInt64BE(),maxOpenHandles:Q.readUInt64BE()};if(s.maxOpenHandles===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),Q.clear(),typeof r.cb=="function"&&r.cb(void 0,s);return}case"users-groups-by-id@openssh.com":{let s=Q.readUInt32BE();if(s===void 0)break;let i=new Array(s);for(let c=0;c<i.length;++c)i[c]=Q.readString(!0);let o=Q.readUInt32BE();if(o===void 0)break;let a=new Array(o);for(let c=0;c<a.length;++c)a[c]=Q.readString(!0);if(a.length>0&&a[a.length-1]===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),Q.clear(),typeof r.cb=="function"&&r.cb(void 0,i,a);return}default:n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),Q.clear(),typeof r.cb=="function"&&r.cb();return}else{n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),Q.clear();return}}return Q.clear(),ct(n,"Malformed EXTENDED_REPLY packet")}},Yg={[Be.INIT]:(n,t)=>{if(n._version!==-1)return ct(n,"Duplicate INIT packet");let e={};Q.init(t,1);let r=Q.readUInt32BE();for(;Q.avail();){let s=Q.readString(!0),i=Q.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(Q.clear(),r===void 0)return ct(n,"Malformed INIT packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received INIT (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received INIT (v${r})`)}et(n,Qg),n._version=r,n._extensions=e,n.emit("ready")},[Be.OPEN]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0),s=Q.readUInt32BE(),i=Jr(n._biOpt);if(Q.clear(),i===void 0)return ct(n,"Malformed OPEN packet");n._debug&&n._debug(`SFTP: Inbound: Received OPEN (id:${e})`),n.emit("OPEN",e,r,s,i)||n.status(e,rt.OP_UNSUPPORTED)},[Be.CLOSE]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString();if(Q.clear(),r===void 0||r.length>256)return ct(n,"Malformed CLOSE packet");n._debug&&n._debug(`SFTP: Inbound: Received CLOSE (id:${e})`),n.emit("CLOSE",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.READ]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(),s=Q.readUInt64BE(n._biOpt),i=Q.readUInt32BE();if(Q.clear(),i===void 0||r.length>256)return ct(n,"Malformed READ packet");n._debug&&n._debug(`SFTP: Inbound: Received READ (id:${e})`),n.emit("READ",e,r,s,i)||n.status(e,rt.OP_UNSUPPORTED)},[Be.WRITE]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(),s=Q.readUInt64BE(n._biOpt),i=Q.readString();if(Q.clear(),i===void 0||r.length>256)return ct(n,"Malformed WRITE packet");n._debug&&n._debug(`SFTP: Inbound: Received WRITE (id:${e})`),n.emit("WRITE",e,r,s,i)||n.status(e,rt.OP_UNSUPPORTED)},[Be.LSTAT]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed LSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received LSTAT (id:${e})`),n.emit("LSTAT",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.FSTAT]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString();if(Q.clear(),r===void 0||r.length>256)return ct(n,"Malformed FSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSTAT (id:${e})`),n.emit("FSTAT",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.SETSTAT]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0),s=Jr(n._biOpt);if(Q.clear(),s===void 0)return ct(n,"Malformed SETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received SETSTAT (id:${e})`),n.emit("SETSTAT",e,r,s)||n.status(e,rt.OP_UNSUPPORTED)},[Be.FSETSTAT]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(),s=Jr(n._biOpt);if(Q.clear(),s===void 0||r.length>256)return ct(n,"Malformed FSETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSETSTAT (id:${e})`),n.emit("FSETSTAT",e,r,s)||n.status(e,rt.OP_UNSUPPORTED)},[Be.OPENDIR]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed OPENDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received OPENDIR (id:${e})`),n.emit("OPENDIR",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.READDIR]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString();if(Q.clear(),r===void 0||r.length>256)return ct(n,"Malformed READDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received READDIR (id:${e})`),n.emit("READDIR",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.REMOVE]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed REMOVE packet");n._debug&&n._debug(`SFTP: Inbound: Received REMOVE (id:${e})`),n.emit("REMOVE",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.MKDIR]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0),s=Jr(n._biOpt);if(Q.clear(),s===void 0)return ct(n,"Malformed MKDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received MKDIR (id:${e})`),n.emit("MKDIR",e,r,s)||n.status(e,rt.OP_UNSUPPORTED)},[Be.RMDIR]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed RMDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received RMDIR (id:${e})`),n.emit("RMDIR",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.REALPATH]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed REALPATH packet");n._debug&&n._debug(`SFTP: Inbound: Received REALPATH (id:${e})`),n.emit("REALPATH",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.STAT]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed STAT packet");n._debug&&n._debug(`SFTP: Inbound: Received STAT (id:${e})`),n.emit("STAT",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.RENAME]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0),s=Q.readString(!0);if(Q.clear(),s===void 0)return ct(n,"Malformed RENAME packet");n._debug&&n._debug(`SFTP: Inbound: Received RENAME (id:${e})`),n.emit("RENAME",e,r,s)||n.status(e,rt.OP_UNSUPPORTED)},[Be.READLINK]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(Q.clear(),r===void 0)return ct(n,"Malformed READLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received READLINK (id:${e})`),n.emit("READLINK",e,r)||n.status(e,rt.OP_UNSUPPORTED)},[Be.SYMLINK]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0),s=Q.readString(!0);if(Q.clear(),s===void 0)return ct(n,"Malformed SYMLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received SYMLINK (id:${e})`);let i;n._isOpenSSH?i=n.emit("SYMLINK",e,s,r):i=n.emit("SYMLINK",e,r,s),i||n.status(e,rt.OP_UNSUPPORTED)},[Be.EXTENDED]:(n,t)=>{Q.init(t,1);let e=Q.readUInt32BE(),r=Q.readString(!0);if(r===void 0)return Q.clear(),ct(n,"Malformed EXTENDED packet");let s;Q.avail()&&(s=Q.readRaw()),Q.clear(),n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED (id:${e})`),n.emit("EXTENDED",e,r,s)||n.status(e,rt.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:jg,ERR_OUT_OF_RANGE:io,validateNumber:Xg}=$d(),Wd=128,nn,nc=[];function Jg(n){nc.length>0?nn=nc.pop():nn=Buffer.allocUnsafe(n),nn.used=0}function rc(n,t){if(!Number.isSafeInteger(n))throw Xg(n,t),Number.isInteger(n)?new io(t,">= 0 and <= 2 ** 53 - 1",n):new io(t,"an integer",n);if(n<0)throw new io(t,">= 0 and <= 2 ** 53 - 1",n)}function Xa(n){return n+7&-8}function Gn(n,t,e){if(e===void 0)e={};else if(typeof e=="string")e={encoding:e};else{if(e===null||typeof e!="object")throw new TypeError('"options" argument must be a string or an object');e=Object.create(e)}if(e.highWaterMark===void 0&&(e.highWaterMark=64*1024),e.emitClose=!1,e.autoDestroy=!1,Vd.call(this,e),this.path=t,this.flags=e.flags===void 0?"r":e.flags,this.mode=e.mode===void 0?438:e.mode,this.start=e.start,this.end=e.end,this.autoClose=e.autoClose===void 0?!0:e.autoClose,this.pos=0,this.bytesRead=0,this.isClosed=!1,this.handle=e.handle===void 0?null:e.handle,this.sftp=n,this._opening=!1,this.start!==void 0&&(rc(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(rc(this.end,"end"),this.start!==void 0&&this.start>this.end))throw new io("start",`<= "end" (here: ${this.end})`,this.start);this.on("end",function(){this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}Kd(Gn,Vd);Gn.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t,this.emit("open",t),this.emit("ready"),this.read()}))};Gn.prototype._read=function(n){if(!Buffer.isBuffer(this.handle))return this.once("open",()=>this._read(n));if(this.destroyed)return;(!nn||nn.length-nn.used<Wd)&&Jg(this.readableHighWaterMark||this._readableState.highWaterMark);let t=nn,e=Math.min(nn.length-nn.used,n),r=nn.used;if(this.end!==void 0&&(e=Math.min(this.end-this.pos+1,e)),e<=0)return this.push(null);this.sftp.read(this.handle,nn,nn.used,e,this.pos,(s,i)=>{if(s){this.emit("error",s),this.autoClose&&this.destroy();return}let o=null;if(r+e===t.used&&t===nn)t.used=Xa(t.used+i-e);else{let a=r+e&-8,c=Xa(r+i);a-c>=Wd&&nc.push(t.slice(c,a))}i>0&&(this.bytesRead+=i,o=t.slice(r,r+i)),this.pos+=i,this.push(o)}),nn.used=Xa(nn.used+e)};Gn.prototype._destroy=function(n,t){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",qd.bind(null,this,t,n));return}qd(this,t,n),this.handle=null,this._opening=!1};function qd(n,t,e){if(!n.handle)return r();n.sftp.close(n.handle,r);function r(s){s=s||e,t(s),n.isClosed=!0,s||n.emit("close")}}Gn.prototype.close=function(n){this.destroy(null,n)};Object.defineProperty(Gn.prototype,"pending",{get(){return this.handle===null},configurable:!0});function Sn(n,t,e){if(e===void 0)e={};else if(typeof e=="string")e={encoding:e};else{if(e===null||typeof e!="object")throw new TypeError('"options" argument must be a string or an object');e=Object.create(e)}e.emitClose=!1,e.autoDestroy=!1,ic.call(this,e),this.path=t,this.flags=e.flags===void 0?"w":e.flags,this.mode=e.mode===void 0?438:e.mode,this.start=e.start,this.autoClose=e.autoClose===void 0?!0:e.autoClose,this.pos=0,this.bytesWritten=0,this.isClosed=!1,this.handle=e.handle===void 0?null:e.handle,this.sftp=n,this._opening=!1,this.start!==void 0&&(rc(this.start,"start"),this.pos=this.start),e.encoding&&this.setDefaultEncoding(e.encoding),this.on("finish",function(){this._writableState.finalCalled||this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}Kd(Sn,ic);Sn.prototype._final=function(n){this.autoClose&&this.destroy(),n()};Sn.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t;let e=r=>{if(r){this.sftp.chmod(this.path,this.mode,s=>e());return}if(this.flags[0]==="a"){let s=(i,o)=>{if(i){this.sftp.stat(this.path,(a,c)=>{if(a){this.destroy(),this.emit("error",i);return}s(null,c)});return}this.pos=o.size,this.emit("open",t),this.emit("ready")};this.sftp.fstat(t,s);return}this.emit("open",t),this.emit("ready")};this.sftp.fchmod(t,this.mode,e)}))};Sn.prototype._write=function(n,t,e){if(!Buffer.isBuffer(n)){let r=new jg("data","Buffer",n);return this.emit("error",r)}if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._write(n,t,e)});this.sftp.write(this.handle,n,0,n.length,this.pos,(r,s)=>{if(r)return this.autoClose&&this.destroy(),e(r);this.bytesWritten+=s,e()}),this.pos+=n.length};Sn.prototype._writev=function(n,t){if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._writev(n,t)});let e=this.sftp,r=this.handle,s=n.length,i=(o,a)=>{if(o)return this.destroy(),t(o);this.bytesWritten+=a,--s===0&&t()};for(let o=0;o<n.length;++o){let a=n[o].chunk;e.write(r,a,0,a.length,this.pos,i),this.pos+=a.length}};typeof ic.prototype.destroy!="function"&&(Sn.prototype.destroy=Gn.prototype.destroy);Sn.prototype._destroy=Gn.prototype._destroy;Sn.prototype.close=function(n){if(n){if(this.isClosed){process.nextTick(n);return}this.on("close",n)}this.autoClose||this.on("finish",this.destroy.bind(this)),this.end()};Sn.prototype.destroySoon=Sn.prototype.end;Object.defineProperty(Sn.prototype,"pending",{get(){return this.handle===null},configurable:!0});Jd.exports={flagsToString:Kg,OPEN_MODE:ke,SFTP:Za,Stats:so,STATUS_CODE:rt,stringToFlags:Yd}});var fc=ut((Wx,nh)=>{"use strict";var{Duplex:Zg,Readable:eA,Writable:tA}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:Zd}}=qn(),{bufferSlice:oo}=xn(),nA=32*1024,Qi=2*1024*1024,lc=Qi/2,oc=class extends eA{constructor(t,e){super(e),this._channel=t}_read(t){this._channel._waitChanDrain&&(this._channel._waitChanDrain=!1,this._channel.incoming.window<=lc&&uc(this._channel))}},ac=class extends tA{constructor(t){super({highWaterMark:Qi}),this._channel=t}_write(t,e,r){let s=this._channel,i=s._client._protocol,o=s.outgoing,a=o.packetSize,c=o.id,l=o.window,u=t.length,f=0;if(o.state==="open"){for(;u-f>0&&l>0;){let h=u-f;h>l&&(h=l),h>a&&(h=a),f===0&&h===u?i.channelExtData(c,t,Zd):i.channelExtData(c,oo(t,f,f+h),Zd),f+=h,l-=h}if(o.window=l,u-f>0){l===0&&(s._waitWindow=!0),f>0?s._chunkErr=oo(t,f,u):s._chunkErr=t,s._chunkcbErr=r;return}r()}}},cc=class extends Zg{constructor(t,e,r){let s={highWaterMark:Qi,allowHalfOpen:!r||r&&r.allowHalfOpen!==!1,emitClose:!1};super(s),this.allowHalfOpen=s.allowHalfOpen;let i=!!(r&&r.server);this.server=i,this.type=e.type,this.subtype=void 0,this.incoming=e.incoming,this.outgoing=e.outgoing,this._callbacks=[],this._client=t,this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this.stdin=this.stdout=this,i?this.stderr=new ac(this):this.stderr=new oc(this,s),this._waitWindow=!1,this._waitChanDrain=!1,this._chunk=void 0,this._chunkcb=void 0,this._chunkErr=void 0,this._chunkcbErr=void 0,this.on("finish",eh).on("prefinish",eh),this.on("end",th).on("close",th)}_read(t){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=lc&&uc(this))}_write(t,e,r){let s=this._client._protocol,i=this.outgoing,o=i.packetSize,a=i.id,c=i.window,l=t.length,u=0;if(i.state==="open"){for(;l-u>0&&c>0;){let f=l-u;f>c&&(f=c),f>o&&(f=o),u===0&&f===l?s.channelData(a,t):s.channelData(a,oo(t,u,u+f)),u+=f,c-=f}if(i.window=c,l-u>0){c===0&&(this._waitWindow=!0),u>0?this._chunk=oo(t,u,l):this._chunk=t,this._chunkcb=r;return}r()}}eof(){this.outgoing.state==="open"&&(this.outgoing.state="eof",this._client._protocol.channelEOF(this.outgoing.id))}close(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._client._protocol.channelClose(this.outgoing.id))}destroy(){return this.end(),this.close(),this}setWindow(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&(this.subtype==="shell"||this.subtype==="exec")&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.windowChange(this.outgoing.id,t,e,r,s)}signal(t){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.signal(this.outgoing.id,t)}exit(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&(typeof t=="number"?this._client._protocol.exitStatus(this.outgoing.id,t):this._client._protocol.exitSignal(this.outgoing.id,t,e,r))}};function eh(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}function th(){this.readable=!1}function uc(n){if(n.outgoing.state==="closed")return;let t=Qi-n.incoming.window;t<=0||(n.incoming.window+=t,n._client._protocol.channelWindowAdjust(n.outgoing.id,t))}nh.exports={Channel:cc,MAX_WINDOW:Qi,PACKET_SIZE:nA,windowAdjust:uc,WINDOW_THRESHOLD:lc}});var pc=ut((qx,sh)=>{"use strict";var{SFTP:rA}=Hi(),Wi=2**32-1;function rh(n,t,e,r){if(n._chanMgr.remove(t),typeof r!="function")return;let s;e instanceof Error?s=e:typeof e=="object"&&e!==null?(s=new Error(`(SSH) Channel open failure: ${e.description}`),s.reason=e.reason):(s=new Error("(SSH) Channel open failure: server closed channel unexpectedly"),s.reason=""),r(s)}function ih(n,t,e,r,s){if(typeof e=="function"){rh(n,t,r,e);return}if(typeof e!="object"||e===null||e.incoming&&e.incoming.state==="closed"||(n._chanMgr.remove(t),e.server&&e.constructor.name==="Session"))return;e.incoming.state="closed",e.readable&&e.push(null),e.server?e.stderr.writable&&e.stderr.end():e.stderr.readable&&e.stderr.push(null),e.constructor!==rA&&(e.outgoing.state==="open"||e.outgoing.state==="eof")&&!s&&e.close(),e.outgoing.state==="closing"&&(e.outgoing.state="closed");let i=e._readableState,o=e._writableState;o&&!o.ending&&!o.finished&&!s&&e.end();let a=e._callbacks;e._callbacks=[];for(let c=0;c<a.length;++c)a[c](!0);if(e.server)!e.readable||e.destroyed||i&&i.endEmitted?e.emit("close"):e.once("end",()=>e.emit("close"));else{let c;switch(e.type){case"direct-streamlocal@openssh.com":case"direct-tcpip":c=()=>e.emit("close");break;default:{let u=e._exit;c=()=>{u.code===null?e.emit("close",u.code,u.signal,u.dump,u.desc):e.emit("close",u.code)}}}!e.readable||e.destroyed||i&&i.endEmitted?c():e.once("end",c);let l=e.stderr._readableState;!e.stderr.readable||e.stderr.destroyed||l&&l.endEmitted?e.stderr.emit("close"):e.stderr.once("end",()=>e.stderr.emit("close"))}}var hc=class{constructor(t){this._client=t,this._channels={},this._cur=-1,this._count=0}add(t){let e;if(this._cur<Wi)e=++this._cur;else if(this._count===0)this._cur=0,e=0;else{let r=this._channels;for(let s=0;s<Wi;++s)if(r[s]===void 0){e=s;break}}return e===void 0?-1:(this._channels[e]=t||!0,++this._count,e)}update(t,e){if(typeof t!="number"||t<0||t>=Wi||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);e&&this._channels[t]&&(this._channels[t]=e)}get(t){if(typeof t!="number"||t<0||t>=Wi||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);return this._channels[t]}remove(t){if(typeof t!="number"||t<0||t>=Wi||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);this._channels[t]&&(delete this._channels[t],this._count&&--this._count)}cleanup(t){let e=this._channels;this._channels={},this._cur=-1,this._count=0;let r=Object.keys(e),s=this._client;for(let i=0;i<r.length;++i){let o=+r[i],a=e[o];ih(s,o,a._channel||a,t,!0)}}},dc=(()=>{let n=Object.prototype.toString;return t=>n.call(t)==="[object RegExp]"})();function iA(n,t,e){if(Array.isArray(n)&&n.length>0){for(let r=0;r<n.length;++r)if(e.indexOf(n[r])===-1)throw new Error(`Unsupported algorithm: ${n[r]}`);return n}if(typeof n=="object"&&n!==null){let r=Object.keys(n),s=t;for(let i=0;i<r.length;++i){let o=r[i],a=n[o];switch(o){case"append":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let l=a[c];if(typeof l=="string"){if(!l||s.indexOf(l)!==-1)continue;if(e.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);s===t&&(s=s.slice()),s.push(l)}else if(dc(l))for(let u=0;u<e.length;++u){let f=e[u];if(l.test(f)){if(s.indexOf(f)!==-1)continue;s===t&&(s=s.slice()),s.push(f)}}}break;case"prepend":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=a.length;c>=0;--c){let l=a[c];if(typeof l=="string"){if(!l||s.indexOf(l)!==-1)continue;if(e.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);s===t&&(s=s.slice()),s.unshift(l)}else if(dc(l))for(let u=e.length;u>=0;--u){let f=e[u];if(l.test(f)){if(s.indexOf(f)!==-1)continue;s===t&&(s=s.slice()),s.unshift(f)}}}break;case"remove":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let l=a[c];if(typeof l=="string"){if(!l)continue;let u=s.indexOf(l);if(u===-1)continue;s===t&&(s=s.slice()),s.splice(u,1)}else if(dc(l))for(let u=0;u<s.length;++u)l.test(s[u])&&(s===t&&(s=s.slice()),s.splice(u,1),--u)}break}}return s}return t}sh.exports={ChannelManager:hc,generateAlgorithmList:iA,onChannelOpenFailure:rh,onCHANNEL_CLOSE:ih,isWritable:n=>n&&n.writable&&n._readableState&&n._readableState.ended===!1}});var _c=ut((Vx,Ih)=>{"use strict";var{createHash:sA,getHashes:oA,randomFillSync:aA}=require("crypto"),{Socket:cA}=require("net"),{lookup:lA}=require("dns"),uA=require("events"),fA=oA(),{COMPAT:bh,CHANNEL_EXTENDED_DATATYPE:{STDERR:dA},CHANNEL_OPEN_FAILURE:qi,DEFAULT_CIPHER:oh,DEFAULT_COMPRESSION:ah,DEFAULT_KEX:ch,DEFAULT_MAC:lh,DEFAULT_SERVER_HOST_KEY:uh,DISCONNECT_REASON:fh,DISCONNECT_REASON_BY_VALUE:hA,SUPPORTED_CIPHER:pA,SUPPORTED_COMPRESSION:mA,SUPPORTED_KEX:gA,SUPPORTED_MAC:AA,SUPPORTED_SERVER_HOST_KEY:yA}=qn(),{init:EA}=tr(),SA=Ya(),{parseKey:lo}=ir(),{SFTP:_A}=Hi(),{bufferCopy:dh,makeBufferParser:xh,makeError:bA,readUInt32BE:xA,sigSSHToASN1:wA,writeUInt32BE:mc}=xn(),{AgentContext:hh,createAgent:ph,isAgent:mh}=Oa(),{Channel:wh,MAX_WINDOW:uo,PACKET_SIZE:fo,windowAdjust:gh,WINDOW_THRESHOLD:Ah}=fc(),{ChannelManager:IA,generateAlgorithmList:Vi,isWritable:Ut,onChannelOpenFailure:CA,onCHANNEL_CLOSE:kA}=pc(),ao=xh(),co=xh(),Ki=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,Ec=n=>{},Sc=class extends uA{constructor(){super(),this.config={host:void 0,port:void 0,localAddress:void 0,localPort:void 0,forceIPv4:void 0,forceIPv6:void 0,keepaliveCountMax:void 0,keepaliveInterval:void 0,readyTimeout:void 0,ident:void 0,username:void 0,password:void 0,privateKey:void 0,tryKeyboard:void 0,agent:void 0,allowAgentFwd:void 0,authHandler:void 0,hostHashAlgo:void 0,hostHashCb:void 0,strictVendor:void 0,debug:void 0},this._agent=void 0,this._readyTimeout=void 0,this._chanMgr=void 0,this._callbacks=void 0,this._forwarding=void 0,this._forwardingUnix=void 0,this._acceptX11=void 0,this._agentFwdEnabled=void 0,this._remoteVer=void 0,this._protocol=void 0,this._sock=void 0,this._resetKA=void 0}connect(t){if(this._sock&&Ut(this._sock))return this.once("close",()=>{this.connect(t)}),this.end(),this;this.config.host=t.hostname||t.host||"localhost",this.config.port=t.port||22,this.config.localAddress=typeof t.localAddress=="string"?t.localAddress:void 0,this.config.localPort=typeof t.localPort=="string"||typeof t.localPort=="number"?t.localPort:void 0,this.config.forceIPv4=t.forceIPv4||!1,this.config.forceIPv6=t.forceIPv6||!1,this.config.keepaliveCountMax=typeof t.keepaliveCountMax=="number"&&t.keepaliveCountMax>=0?t.keepaliveCountMax:3,this.config.keepaliveInterval=typeof t.keepaliveInterval=="number"&&t.keepaliveInterval>0?t.keepaliveInterval:0,this.config.readyTimeout=typeof t.readyTimeout=="number"&&t.readyTimeout>=0?t.readyTimeout:2e4,this.config.ident=typeof t.ident=="string"||Buffer.isBuffer(t.ident)?t.ident:void 0;let e={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:[]},sc:void 0},r=!0;if(typeof t.algorithms=="object"&&t.algorithms!==null&&(e.kex=Vi(t.algorithms.kex,ch,gA),e.kex!==ch&&(r=!1),e.serverHostKey=Vi(t.algorithms.serverHostKey,uh,yA),e.serverHostKey!==uh&&(r=!1),e.cs.cipher=Vi(t.algorithms.cipher,oh,pA),e.cs.cipher!==oh&&(r=!1),e.cs.mac=Vi(t.algorithms.hmac,lh,AA),e.cs.mac!==lh&&(r=!1),e.cs.compress=Vi(t.algorithms.compress,ah,mA),e.cs.compress!==ah&&(r=!1),r||(e.sc=e.cs)),typeof t.username=="string")this.config.username=t.username;else if(typeof t.user=="string")this.config.username=t.user;else throw new Error("Invalid username");this.config.password=typeof t.password=="string"?t.password:void 0,this.config.privateKey=typeof t.privateKey=="string"||Buffer.isBuffer(t.privateKey)?t.privateKey:void 0,this.config.localHostname=typeof t.localHostname=="string"?t.localHostname:void 0,this.config.localUsername=typeof t.localUsername=="string"?t.localUsername:void 0,this.config.tryKeyboard=t.tryKeyboard===!0,typeof t.agent=="string"&&t.agent.length?this.config.agent=ph(t.agent):mh(t.agent)?this.config.agent=t.agent:this.config.agent=void 0,this.config.allowAgentFwd=t.agentForward===!0&&this.config.agent!==void 0;let s=this.config.authHandler=typeof t.authHandler=="function"||Array.isArray(t.authHandler)?t.authHandler:void 0;this.config.strictVendor=typeof t.strictVendor=="boolean"?t.strictVendor:!0;let i=this.config.debug=typeof t.debug=="function"?t.debug:void 0;if(t.agentForward===!0&&!this.config.allowAgentFwd)throw new Error("You must set a valid agent path to allow agent forwarding");let o=this._callbacks=[];this._chanMgr=new IA(this),this._forwarding={},this._forwardingUnix={},this._acceptX11=0,this._agentFwdEnabled=!1,this._agent=this.config.agent?this.config.agent:void 0,this._remoteVer=void 0;let a;if(this.config.privateKey){if(a=lo(this.config.privateKey,t.passphrase),a instanceof Error)throw new Error(`Cannot parse privateKey: ${a.message}`);if(Array.isArray(a)&&(a=a[0]),a.getPrivatePEM()===null)throw new Error("privateKey value does not contain a (valid) private key")}let c;if(typeof t.hostVerifier=="function"){let H=t.hostVerifier,B;fA.indexOf(t.hostHash)!==-1&&(B=t.hostHash),c=(D,z)=>{B&&(D=sA(B).update(D).digest("hex"));let ne=H(D,z);ne!==void 0&&z(ne)}}let l=this._sock=t.sock||new cA,u=!1,f=!1;this._protocol&&this._protocol.cleanup();let h=i?(H,B,D)=>{i(`Debug output from server: ${JSON.stringify(D)}`)}:void 0,p,A=this._protocol=new SA({ident:this.config.ident,offer:r?void 0:e,onWrite:H=>{Ut(l)&&l.write(H)},onError:H=>{H.level==="handshake"&&clearTimeout(this._readyTimeout),A._destruct||l.removeAllListeners("data"),this.emit("error",H);try{l.end()}catch{}},onHeader:H=>{f=!0,this._remoteVer=H.versions.software,H.greeting&&this.emit("greeting",H.greeting)},onHandshakeComplete:H=>{this.emit("handshake",H),u||(u=!0,A.service("ssh-userauth"))},debug:i,hostVerifier:c,messageHandlers:{DEBUG:h,DISCONNECT:(H,B,D)=>{if(B!==fh.BY_APPLICATION){D||(D=hA[B],D===void 0&&(D=`Unexpected disconnection reason: ${B}`));let z=new Error(D);z.code=B,this.emit("error",z)}l.end()},SERVICE_ACCEPT:(H,B)=>{B==="ssh-userauth"&&X()},EXT_INFO:(H,B)=>{if(p===void 0){for(let D of B)if(D.name==="server-sig-algs"){p=D.algs;return}p=null}},USERAUTH_BANNER:(H,B)=>{this.emit("banner",B)},USERAUTH_SUCCESS:H=>{C(),clearTimeout(this._readyTimeout),this.emit("ready")},USERAUTH_FAILURE:(H,B,D)=>{if(_.keyAlgos){let z=_.keyAlgos[0][0];if(i&&i(`Client: ${_.type} (${z}) auth failed`),_.keyAlgos.shift(),_.keyAlgos.length){let[ne,de]=_.keyAlgos[0];switch(_.type){case"agent":A.authPK(_.username,_.agentCtx.currentKey(),ne);return;case"publickey":A.authPK(_.username,_.key,ne);return;case"hostbased":A.authHostbased(_.username,_.key,_.localHostname,_.localUsername,ne,(oe,Je)=>{let ht=_.key.sign(oe,de);if(ht instanceof Error)return ht.message=`Error while signing with key: ${ht.message}`,ht.level="client-authentication",this.emit("error",ht),X();Je(ht)});return}}else _.keyAlgos=void 0}if(_.type==="agent"){let z=_.agentCtx.pos();return i&&i(`Client: Agent key #${z+1} failed`),re()}i&&i(`Client: ${_.type} auth failed`),w=D,k=B,X()},USERAUTH_PASSWD_CHANGEREQ:(H,B)=>{_.type==="password"&&this.emit("change password",B,D=>{A.authPassword(this.config.username,this.config.password,D)})},USERAUTH_PK_OK:H=>{let B,D;if(_.keyAlgos&&([B,D]=_.keyAlgos[0]),_.type==="agent"){let z=_.agentCtx.currentKey();A.authPK(_.username,z,B,(ne,de)=>{let oe={hash:D};_.agentCtx.sign(z,ne,oe,(Je,ht)=>{if(Je)Je.level="agent",this.emit("error",Je);else return de(ht);re()})})}else _.type==="publickey"&&A.authPK(_.username,_.key,B,(z,ne)=>{let de=_.key.sign(z,D);if(de instanceof Error)return de.message=`Error signing data with key: ${de.message}`,de.level="client-authentication",this.emit("error",de),X();ne(de)})},USERAUTH_INFO_REQUEST:(H,B,D,z)=>{if(_.type==="keyboard-interactive"){if((Array.isArray(z)?z.length:0)===0){i&&i("Client: Sending automatic USERAUTH_INFO_RESPONSE"),A.authInfoRes();return}_.prompt(B,D,"",z,de=>{A.authInfoRes(de)})}},REQUEST_SUCCESS:(H,B)=>{o.length&&o.shift()(!1,B)},REQUEST_FAILURE:H=>{o.length&&o.shift()(!0)},GLOBAL_REQUEST:(H,B,D,z)=>{B==="hostkeys-00@openssh.com"?(PA(this,z,(ne,de)=>{ne||this.emit("hostkeys",de)}),D&&A.requestSuccess()):D&&A.requestFailure()},CHANNEL_OPEN:(H,B)=>{BA(this,B)},CHANNEL_OPEN_CONFIRMATION:(H,B)=>{let D=this._chanMgr.get(B.recipient);if(typeof D!="function")return;let z=D.type==="sftp",de={type:z?"session":D.type,incoming:{id:B.recipient,window:uo,packetSize:fo,state:"open"},outgoing:{id:B.sender,window:B.window,packetSize:B.packetSize,state:"open"}},oe=z?new _A(this,de,{debug:i}):new wh(this,de);this._chanMgr.update(B.recipient,oe),D(void 0,oe)},CHANNEL_OPEN_FAILURE:(H,B,D,z)=>{let ne=this._chanMgr.get(B);if(typeof ne!="function")return;CA(this,B,{reason:D,description:z},ne)},CHANNEL_DATA:(H,B,D)=>{let z=this._chanMgr.get(B);if(!(typeof z!="object"||z===null)&&z.incoming.window!==0){if(z.incoming.window-=D.length,z.push(D)===!1){z._waitChanDrain=!0;return}z.incoming.window<=Ah&&gh(z)}},CHANNEL_EXTENDED_DATA:(H,B,D,z)=>{if(z!==dA)return;let ne=this._chanMgr.get(B);if(!(typeof ne!="object"||ne===null)&&ne.incoming.window!==0){if(ne.incoming.window-=D.length,!ne.stderr.push(D)){ne._waitChanDrain=!0;return}ne.incoming.window<=Ah&&gh(ne)}},CHANNEL_WINDOW_ADJUST:(H,B,D)=>{let z=this._chanMgr.get(B);typeof z!="object"||z===null||(z.outgoing.window+=D,z._waitWindow&&(z._waitWindow=!1,z._chunk?z._write(z._chunk,null,z._chunkcb):z._chunkcb?z._chunkcb():z._chunkErr?z.stderr._write(z._chunkErr,null,z._chunkcbErr):z._chunkcbErr&&z._chunkcbErr()))},CHANNEL_SUCCESS:(H,B)=>{let D=this._chanMgr.get(B);typeof D!="object"||D===null||(this._resetKA(),D._callbacks.length&&D._callbacks.shift()(!1))},CHANNEL_FAILURE:(H,B)=>{let D=this._chanMgr.get(B);typeof D!="object"||D===null||(this._resetKA(),D._callbacks.length&&D._callbacks.shift()(!0))},CHANNEL_REQUEST:(H,B,D,z,ne)=>{let de=this._chanMgr.get(B);if(typeof de!="object"||de===null)return;let oe=de._exit;if(oe.code===void 0){switch(D){case"exit-status":de.emit("exit",oe.code=ne);return;case"exit-signal":de.emit("exit",oe.code=null,oe.signal=`SIG${ne.signal}`,oe.dump=ne.coreDumped,oe.desc=ne.errorMessage);return}z&&H.channelFailure(de.outgoing.id)}},CHANNEL_EOF:(H,B)=>{let D=this._chanMgr.get(B);typeof D!="object"||D===null||D.incoming.state==="open"&&(D.incoming.state="eof",D.readable&&D.push(null),D.stderr.readable&&D.stderr.push(null))},CHANNEL_CLOSE:(H,B)=>{kA(this,B,this._chanMgr.get(B))}}});l.pause();let E=this.config.keepaliveInterval,b=this.config.keepaliveCountMax,x=0,P,q=()=>{if(++x>b){if(clearInterval(P),l.readable){let H=new Error("Keepalive timeout");H.level="client-timeout",this.emit("error",H),l.destroy()}return}Ut(l)?(o.push(C),A.ping()):clearInterval(P)};function C(){E>0&&(x=0,clearInterval(P),Ut(l)&&(P=setInterval(q,E)))}this._resetKA=C;let $=(()=>{let H=!1;return()=>{if(!H&&(H=!0,v&&!f)){let B=bA("Connection lost before handshake","protocol",!0);this.emit("error",B)}}})(),F=(()=>{let H=!1;return()=>{H||(H=!0,v=!0,i&&i("Socket connected"),this.emit("connect"),EA.then(()=>{A.start(),l.on("data",B=>{try{A.parse(B,0,B.length)}catch(D){this.emit("error",D);try{Ut(l)&&l.end()}catch{}}}),l.stderr&&typeof l.stderr.resume=="function"&&l.stderr.resume(),l.resume()}).catch(B=>{this.emit("error",B);try{Ut(l)&&l.end()}catch{}}))}})(),v=!1;l.on("connect",F).on("timeout",()=>{this.emit("timeout")}).on("error",H=>{i&&i(`Socket error: ${H.message}`),clearTimeout(this._readyTimeout),H.level="client-socket",this.emit("error",H)}).on("end",()=>{i&&i("Socket ended"),$(),A.cleanup(),clearTimeout(this._readyTimeout),clearInterval(P),this.emit("end")}).on("close",()=>{i&&i("Socket closed"),$(),A.cleanup(),clearTimeout(this._readyTimeout),clearInterval(P),this.emit("close");let H=o;o=this._callbacks=[];let B=new Error("No response from server");for(let D=0;D<H.length;++D)H[D](B);this._chanMgr.cleanup(B)});let _,w=null,k=null,N=["none"];this.config.password!==void 0&&N.push("password"),a!==void 0&&N.push("publickey"),this._agent!==void 0&&N.push("agent"),this.config.tryKeyboard&&N.push("keyboard-interactive"),a!==void 0&&this.config.localHostname!==void 0&&this.config.localUsername!==void 0&&N.push("hostbased"),Array.isArray(s)?s=_h(s):typeof s!="function"&&(s=_h(N));let R=!1,ie=H=>{if(!R){if(R=!0,H===!1){let B=new Error("All configured authentication methods failed");B.level="client-authentication",this.emit("error",B),this.end();return}if(typeof H=="string"){let B=H;if(N.indexOf(B)===-1)return j(`Authentication method not allowed: ${B}`);let D=this.config.username;switch(B){case"password":H={type:B,username:D,password:this.config.password};break;case"publickey":H={type:B,username:D,key:a};break;case"hostbased":H={type:B,username:D,key:a,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":H={type:B,username:D,agentCtx:new hh(this._agent)};break;case"keyboard-interactive":H={type:B,username:D,prompt:(...z)=>this.emit("keyboard-interactive",...z)};break;case"none":H={type:B,username:D};break;default:return j(`Skipping unsupported authentication method: ${H}`)}}else{if(typeof H!="object"||H===null)return j(`Skipping invalid authentication attempt: ${H}`);{let B=H.username;if(typeof B!="string")return j(`Skipping invalid authentication attempt: ${H}`);let D=H.type;switch(D){case"password":{let{password:z}=H;if(typeof z!="string"&&!Buffer.isBuffer(z))return j("Skipping invalid password auth attempt");H={type:D,username:B,password:z};break}case"publickey":{let z=lo(H.key,H.passphrase);if(z instanceof Error)return j("Skipping invalid key auth attempt");if(!z.isPrivateKey())return j("Skipping non-private key");H={type:D,username:B,key:z};break}case"hostbased":{let{localHostname:z,localUsername:ne}=H,de=lo(H.key,H.passphrase);if(de instanceof Error||typeof z!="string"||typeof ne!="string")return j("Skipping invalid hostbased auth attempt");if(!de.isPrivateKey())return j("Skipping non-private key");H={type:D,username:B,key:de,localHostname:z,localUsername:ne};break}case"agent":{let z=H.agent;if(typeof z=="string"&&z.length)z=ph(z);else if(!mh(z))return j(`Skipping invalid agent: ${H.agent}`);H={type:D,username:B,agentCtx:new hh(z)};break}case"keyboard-interactive":{let{prompt:z}=H;if(typeof z!="function")return j("Skipping invalid keyboard-interactive auth attempt");H={type:D,username:B,prompt:z};break}case"none":H={type:D,username:B};break;default:return j(`Skipping unsupported authentication method: ${H}`)}}}_=H;try{let B=_.username;switch(_.type){case"password":A.authPassword(B,_.password);break;case"publickey":{let D;if(_.keyAlgos=yc(this,_.key,p),_.keyAlgos)if(_.keyAlgos.length)D=_.keyAlgos[0][0];else return j("Skipping key authentication (no mutual hash algorithm)");A.authPK(B,_.key,D);break}case"hostbased":{let D,z;if(_.keyAlgos=yc(this,_.key,p),_.keyAlgos)if(_.keyAlgos.length)[D,z]=_.keyAlgos[0];else return j("Skipping hostbased authentication (no mutual hash algorithm)");A.authHostbased(B,_.key,_.localHostname,_.localUsername,D,(ne,de)=>{let oe=_.key.sign(ne,z);if(oe instanceof Error)return oe.message=`Error while signing with key: ${oe.message}`,oe.level="client-authentication",this.emit("error",oe),X();de(oe)});break}case"agent":_.agentCtx.init(D=>{if(D)return D.level="agent",this.emit("error",D),X();re()});break;case"keyboard-interactive":A.authKeyboard(B);break;case"none":A.authNone(B);break}}finally{R=!1}}};function j(H){i&&i(H),process.nextTick(X)}function X(){R=!1;let H=s(k,w,ie);R||H===void 0||ie(H)}let re=()=>{if(_.type==="agent"){let H=_.agentCtx.nextKey();if(H===!1)i&&i("Agent: No more keys left to try"),i&&i("Client: agent auth failed"),X();else{let B=_.agentCtx.pos(),D;if(_.keyAlgos=yc(this,H,p),_.keyAlgos)if(_.keyAlgos.length)D=_.keyAlgos[0][0];else{i&&i(`Agent: Skipping key #${B+1} (no mutual hash algorithm)`),re();return}i&&i(`Agent: Trying key #${B+1}`),A.authPK(_.username,H,D)}}},fe=()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let H=new Error("Timed out while waiting for handshake");H.level="client-timeout",this.emit("error",H),l.destroy()},this.config.readyTimeout))};if(t.sock)fe(),typeof l.connecting=="boolean"&&l.connecting||F();else{let H=this.config.host,B=this.config.forceIPv4,D=this.config.forceIPv6;i&&i(`Client: Trying ${H} on port ${this.config.port} ...`);let z=()=>{fe(),l.connect({host:H,port:this.config.port,localAddress:this.config.localAddress,localPort:this.config.localPort}),l.setMaxListeners(0),l.setTimeout(typeof t.timeout=="number"?t.timeout:0)};!B&&!D||B&&D?z():lA(H,B?4:6,(ne,de,oe)=>{if(ne){let Je=B?"IPv4":"IPv6",ht=new Error(`Error while looking up ${Je} address for '${H}': ${ne}`);clearTimeout(this._readyTimeout),ht.level="client-dns",this.emit("error",ht),this.emit("close");return}H=de,z()})}return this}end(){return this._sock&&Ut(this._sock)&&(this._protocol.disconnect(fh.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&Ut(this._sock)&&this._sock.destroy(),this}exec(t,e,r){if(!this._sock||!Ut(this._sock))throw new Error("Not connected");typeof e=="function"&&(r=e,e={});let s={allowHalfOpen:e.allowHalfOpen!==!1};return ei(this,"session",s,(i,o)=>{if(i){r(i);return}let a=[];function c(l){if(l){o.close(),r(l);return}a.length&&a.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&a.push(()=>Sh(o,c)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&gc(o,e.env),(typeof e.pty=="object"&&e.pty!==null||e.pty===!0)&&a.push(()=>Eh(o,e.pty,c)),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&a.push(()=>yh(o,e.x11,c))),a.push(()=>NA(o,t,e,r)),a.shift()()}),this}shell(t,e,r){if(!this._sock||!Ut(this._sock))throw new Error("Not connected");return typeof t=="function"?(r=t,t=e=void 0):typeof e=="function"&&(r=e,e=void 0),t&&(t.x11!==void 0||t.env!==void 0)&&(e=t,t=void 0),ei(this,"session",(s,i)=>{if(s){r(s);return}let o=[];function a(c){if(c){i.close(),r(c);return}o.length&&o.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&o.push(()=>Sh(i,a)),t!==!1&&o.push(()=>Eh(i,t,a)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&gc(i,e.env),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&o.push(()=>yh(i,e.x11,a))),o.push(()=>vA(i,r)),o.shift()()}),this}subsys(t,e){if(!this._sock||!Ut(this._sock))throw new Error("Not connected");return ei(this,"session",(r,s)=>{if(r){e(r);return}Ac(s,t,(i,o)=>{if(i){e(i);return}e(void 0,o)})}),this}forwardIn(t,e,r){if(!this._sock||!Ut(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push((i,o)=>{if(i){r(i!==!0?i:new Error(`Unable to bind to ${t}:${e}`));return}let a=e;e===0&&o&&o.length>=4&&(a=xA(o,0),this._protocol._compatFlags&bh.DYN_RPORT_BUG||(e=a)),this._forwarding[`${t}:${e}`]=a,r(void 0,a)}),this._protocol.tcpipForward(t,e,s),this}unforwardIn(t,e,r){if(!this._sock||!Ut(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push(i=>{if(i){r(i!==!0?i:new Error(`Unable to unbind from ${t}:${e}`));return}delete this._forwarding[`${t}:${e}`],r()}),this._protocol.cancelTcpipForward(t,e,s),this}forwardOut(t,e,r,s,i){if(!this._sock||!Ut(this._sock))throw new Error("Not connected");let o={srcIP:t,srcPort:e,dstIP:r,dstPort:s};return typeof i!="function"&&(i=Ec),ei(this,"direct-tcpip",o,i),this}openssh_noMoreSessions(t){if(!this._sock||!Ut(this._sock))throw new Error("Not connected");let e=typeof t=="function";return!this.config.strictVendor||this.config.strictVendor&&Ki.test(this._remoteVer)?(e&&this._callbacks.push(r=>{if(r){t(r!==!0?r:new Error("Unable to disable future sessions"));return}t()}),this._protocol.openssh_noMoreSessions(e),this):e?(process.nextTick(t,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardInStreamLocal(t,e){if(!this._sock||!Ut(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Ki.test(this._remoteVer)?(r&&this._callbacks.push(s=>{if(s){e(s!==!0?s:new Error(`Unable to bind to ${t}`));return}this._forwardingUnix[t]=!0,e()}),this._protocol.openssh_streamLocalForward(t,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_unforwardInStreamLocal(t,e){if(!this._sock||!Ut(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Ki.test(this._remoteVer)?(r&&this._callbacks.push(s=>{if(s){e(s!==!0?s:new Error(`Unable to unbind from ${t}`));return}delete this._forwardingUnix[t],e()}),this._protocol.openssh_cancelStreamLocalForward(t,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardOutStreamLocal(t,e){if(!this._sock||!Ut(this._sock))throw new Error("Not connected");return typeof e!="function"&&(e=Ec),!this.config.strictVendor||this.config.strictVendor&&Ki.test(this._remoteVer)?(ei(this,"direct-streamlocal@openssh.com",{socketPath:t},e),this):(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this)}sftp(t,e){if(!this._sock||!Ut(this._sock))throw new Error("Not connected");return typeof t=="function"&&(e=t,t=void 0),ei(this,"sftp",(r,s)=>{if(r){e(r);return}let i=(o,a)=>{if(o){e(o);return}function c(){s.removeListener("ready",l),s.removeListener("error",u),s.removeListener("exit",f),s.removeListener("close",f)}function l(){c(),e(void 0,s)}function u(h){c(),e(h)}function f(h,p){c();let A;typeof h=="number"?A=`Received exit code ${h} while establishing SFTP session`:p!==void 0?A=`Received signal ${p} while establishing SFTP session`:A="Received unexpected SFTP session termination";let E=new Error(A);E.code=h,E.signal=p,e(E)}s.on("ready",l).on("error",u).on("exit",f).on("close",f),s._init()};typeof t=="object"&&t!==null?gc(s,t,o=>{if(o){e(o);return}Ac(s,"sftp",i)}):Ac(s,"sftp",i)}),this}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function ei(n,t,e,r){let s=uo,i=fo;typeof e=="function"&&(r=e,e={});let o=(c,l)=>{r(c,l)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"session":case"sftp":n._protocol.session(a,s,i);break;case"direct-tcpip":n._protocol.directTcpip(a,s,i,e);break;case"direct-streamlocal@openssh.com":n._protocol.openssh_directStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function yh(n,t,e){let r={single:!1,protocol:"MIT-MAGIC-COOKIE-1",cookie:void 0,screen:0};typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.single=="boolean"&&(r.single=t.single),typeof t.screen=="number"&&(r.screen=t.screen),typeof t.protocol=="string"&&(r.protocol=t.protocol),typeof t.cookie=="string"?r.cookie=t.cookie:Buffer.isBuffer(t.cookie)&&(r.cookie=t.cookie.hexSlice(0,t.cookie.length))),r.cookie===void 0&&(r.cookie=RA());let s=typeof e=="function";if(n.outgoing.state!=="open"){s&&e(new Error("Channel is not open"));return}s&&n._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to request X11"));return}n._hasX11=!0,++n._client._acceptX11,n.once("close",()=>{n._client._acceptX11&&--n._client._acceptX11}),e()}),n._client._protocol.x11Forward(n.outgoing.id,r,s)}function Eh(n,t,e){let r=24,s=80,i=640,o=480,a="vt100",c=null;typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.rows=="number"&&(r=t.rows),typeof t.cols=="number"&&(s=t.cols),typeof t.width=="number"&&(i=t.width),typeof t.height=="number"&&(o=t.height),typeof t.term=="string"&&(a=t.term),typeof t.modes=="object"&&(c=t.modes));let l=typeof e=="function";if(n.outgoing.state!=="open"){l&&e(new Error("Channel is not open"));return}l&&n._callbacks.push(u=>{if(u){e(u!==!0?u:new Error("Unable to request a pseudo-terminal"));return}e()}),n._client._protocol.pty(n.outgoing.id,r,s,o,i,a,c,l)}function Sh(n,t){let e=typeof t=="function";if(n.outgoing.state!=="open"){e&&t(new Error("Channel is not open"));return}if(n._client._agentFwdEnabled){e&&t(!1);return}n._client._agentFwdEnabled=!0,n._callbacks.push(r=>{if(r){n._client._agentFwdEnabled=!1,e&&t(r!==!0?r:new Error("Unable to request agent forwarding"));return}e&&t()}),n._client._protocol.openssh_agentForward(n.outgoing.id,!0)}function vA(n,t){if(n.outgoing.state!=="open"){t(new Error("Channel is not open"));return}n._callbacks.push(e=>{if(e){t(e!==!0?e:new Error("Unable to open shell"));return}n.subtype="shell",t(void 0,n)}),n._client._protocol.shell(n.outgoing.id,!0)}function NA(n,t,e,r){if(n.outgoing.state!=="open"){r(new Error("Channel is not open"));return}n._callbacks.push(s=>{if(s){r(s!==!0?s:new Error("Unable to exec"));return}n.subtype="exec",n.allowHalfOpen=e.allowHalfOpen!==!1,r(void 0,n)}),n._client._protocol.exec(n.outgoing.id,t,!0)}function gc(n,t,e){let r=typeof e=="function";if(n.outgoing.state!=="open"){r&&e(new Error("Channel is not open"));return}r&&n._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to set environment"));return}e()});let s=Object.keys(t||{});for(let i=0;i<s.length;++i){let o=s[i],a=t[o];n._client._protocol.env(n.outgoing.id,o,a,r)}}function Ac(n,t,e){if(n.outgoing.state!=="open"){e(new Error("Channel is not open"));return}n._callbacks.push(r=>{if(r){e(r!==!0?r:new Error(`Unable to start subsystem: ${t}`));return}n.subtype="subsystem",e(void 0,n)}),n._client._protocol.subsystem(n.outgoing.id,t,!0)}function BA(n,t){let e=-1,r,s=()=>{let c={type:t.type,incoming:{id:e,window:uo,packetSize:fo,state:"open"},outgoing:{id:t.sender,window:t.window,packetSize:t.packetSize,state:"open"}},l=new wh(n,c);return n._chanMgr.update(e,l),n._protocol.channelOpenConfirm(t.sender,e,uo,fo),l},i=()=>{r===void 0&&(e===-1?r=qi.RESOURCE_SHORTAGE:r=qi.CONNECT_FAILED),e!==-1&&n._chanMgr.remove(e),n._protocol.channelOpenFail(t.sender,r,"")},o=()=>(e=n._chanMgr.add(),e===-1&&(r=qi.RESOURCE_SHORTAGE,n.config.debug&&n.config.debug("Client: Automatic rejection of incoming channel open: no channels available")),e!==-1),a=t.data;switch(t.type){case"forwarded-tcpip":{let c=n._forwarding[`${a.destIP}:${a.destPort}`];if(c!==void 0&&o()){a.destPort===0&&(a.destPort=c),n.emit("tcp connection",a,s,i);return}break}case"forwarded-streamlocal@openssh.com":if(n._forwardingUnix[a.socketPath]!==void 0&&o()){n.emit("unix connection",a,s,i);return}break;case"auth-agent@openssh.com":if(n._agentFwdEnabled&&typeof n._agent.getStream=="function"&&o()){n._agent.getStream((c,l)=>{if(c)return i();let u=s();u.pipe(l).pipe(u)});return}break;case"x11":if(n._acceptX11!==0&&o()){n.emit("x11",a,s,i);return}break;default:r=qi.UNKNOWN_CHANNEL_TYPE,n.config.debug&&n.config.debug(`Client: Automatic rejection of unsupported incoming channel open type: ${t.type}`)}r===void 0&&(r=qi.ADMINISTRATIVELY_PROHIBITED,n.config.debug&&n.config.debug("Client: Automatic rejection of unexpected incoming channel open for: "+t.type)),i()}var RA=(()=>{let n=Buffer.allocUnsafe(16);return()=>(aA(n,0,16),n.hexSlice(0,16))})();function _h(n){if(!Array.isArray(n))throw new Error("authList must be an array");let t=0;return(e,r,s)=>t===n.length?!1:n[t++]}function PA(n,t,e){if(!n._sock||!Ut(n._sock))return;if(typeof e!="function"&&(e=Ec),!Array.isArray(t))throw new TypeError("Invalid keys argument type");let r=[];for(let s of t){let i=lo(s);if(i instanceof Error)throw i;r.push(i)}if(!n.config.strictVendor||n.config.strictVendor&&Ki.test(n._remoteVer)){n._callbacks.push((s,i)=>{if(s){e(s!==!0?s:new Error("Server failed to prove supplied keys"));return}let o=[],a=0;for(ao.init(i,0);ao.avail()&&a!==r.length;){let c=r[a++],l=c.getPublicSSH(),u=ao.readString();co.init(u,0);let f=co.readString(!0),h=co.readString(),p;if(f!==c.type)if(c.type==="ssh-rsa")switch(f){case"rsa-sha2-256":p="sha256";break;case"rsa-sha2-512":p="sha512";break;default:continue}else continue;let A=n._protocol._kex.sessionID,E=Buffer.allocUnsafe(37+A.length+4+l.length),b=0;mc(E,29,b),E.utf8Write("hostkeys-prove-00@openssh.com",b+=4,29),mc(E,A.length,b+=29),dh(A,E,0,A.length,b+=4),mc(E,l.length,b+=A.length),dh(l,E,0,l.length,b+=4),(h=wA(h,f))&&c.verify(E,h,p)===!0&&o.push(c)}co.clear(),ao.clear(),e(null,o)}),n._protocol.openssh_hostKeysProve(r);return}process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version"))}function yc(n,t,e){switch(t.type){case"ssh-rsa":if(n._protocol._compatFlags&bh.IMPLY_RSA_SHA2_SIGALGS&&(Array.isArray(e)?e=["rsa-sha2-256","rsa-sha2-512",...e]:e=["rsa-sha2-256","rsa-sha2-512"]),Array.isArray(e)){if(e.indexOf("rsa-sha2-256")!==-1)return[["rsa-sha2-256","sha256"]];if(e.indexOf("rsa-sha2-512")!==-1)return[["rsa-sha2-512","sha512"]];if(e.indexOf("ssh-rsa")===-1)return[]}return[["ssh-rsa","sha1"]]}}Ih.exports=Sc});var kh=ut(Ch=>{"use strict";var{Agent:xc}=require("http"),{Agent:TA}=require("https"),{connect:OA}=require("tls"),bc;for(let n of[xc,TA]){class t extends n{constructor(r,s){super(s),this._connectCfg=r,this._defaultSrcIP=s&&s.srcIP||"localhost"}createConnection(r,s){let i=r&&r.localAddress||this._defaultSrcIP,o=r&&r.localPort||0,a=r.host,c=r.port;bc===void 0&&(bc=_c());let l=new bc,u=!1;l.on("ready",()=>{l.forwardOut(i,o,a,c,(f,h)=>{if(u=!0,f)return l.end(),s(f);h.once("close",()=>l.end()),s(null,MA(h,n,r))})}).on("error",s).on("close",()=>{u||s(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}Ch[n===xc?"SSHTTPAgent":"SSHTTPSAgent"]=t}function zi(){}function MA(n,t,e){if(t===xc)return n.setKeepAlive=zi,n.setNoDelay=zi,n.setTimeout=zi,n.ref=zi,n.unref=zi,n.destroySoon=n.destroy,n;e.socket=n;let r=OA(e),s=(()=>{let i=!1;return()=>{i||(i=!0,n.isPaused()&&n.resume())}})();return r.on("end",s).on("close",s),r}});var Nh=ut((zx,kc)=>{"use strict";var{Server:DA}=require("net"),Yi=require("events"),{listenerCount:Jt}=Yi,{CHANNEL_OPEN_FAILURE:ti,DEFAULT_CIPHER:LA,DEFAULT_COMPRESSION:UA,DEFAULT_KEX:$A,DEFAULT_MAC:FA,DEFAULT_SERVER_HOST_KEY:HA,DISCONNECT_REASON:ni,DISCONNECT_REASON_BY_VALUE:QA,SUPPORTED_CIPHER:WA,SUPPORTED_COMPRESSION:qA,SUPPORTED_KEX:VA,SUPPORTED_MAC:KA,SUPPORTED_SERVER_HOST_KEY:zA}=qn(),{init:GA}=tr(),{KexInit:YA}=Gs(),{parseKey:vh}=ir(),jA=Ya(),{SFTP:XA}=Hi(),{writeUInt32BE:JA}=xn(),{Channel:ri,MAX_WINDOW:ar,PACKET_SIZE:cr,windowAdjust:ZA,WINDOW_THRESHOLD:ey}=fc(),{ChannelManager:ty,generateAlgorithmList:Gi,isWritable:ho,onChannelOpenFailure:ny,onCHANNEL_CLOSE:ry}=pc(),iy=10,lr=class extends Yi{constructor(t,e,r,s,i){super(),this.username=this.user=e,this.service=r,this.method=s,this._initialResponse=!1,this._finalResponse=!1,this._multistep=!1,this._cbfinal=(o,a,c)=>{this._finalResponse||(this._finalResponse=!0,i(this,o,a,c))},this._protocol=t}accept(){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!0)}reject(t,e){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!1,t,e)}},po=class extends lr{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this._multistep=!0,this._cb=void 0,this._onInfoResponse=a=>{let c=this._cb;c&&(this._cb=void 0,c(a))},this.submethods=i,this.on("abort",()=>{this._cb&&this._cb(new Error("Authentication request aborted"))})}prompt(t,e,r,s){Array.isArray(t)||(t=[t]),typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"?(s=r,r=void 0):typeof s!="function"&&(s=void 0);for(let i=0;i<t.length;++i)typeof t[i]=="string"&&(t[i]={prompt:t[i],echo:!0});this._cb=s,this._initialResponse=!0,this._protocol.authInfoReq(e,r,t)}},Ic=class extends lr{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.key={algo:i.keyAlgo,data:i.key},this.hashAlgo=i.hashAlgo,this.signature=i.signature,this.blob=i.blob}accept(){this.signature?lr.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},Cc=class extends lr{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.key={algo:i.keyAlgo,data:i.key},this.hashAlgo=i.hashAlgo,this.signature=i.signature,this.blob=i.blob,this.localHostname=i.localHostname,this.localUsername=i.localUsername}},mo=class extends lr{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.password=i,this._changeCb=void 0}requestChange(t,e){if(this._changeCb)throw new Error("Change request already in progress");if(typeof t!="string")throw new Error("prompt argument must be a string");if(typeof e!="function")throw new Error("Callback argument must be a function");this._changeCb=e,this._protocol.authPasswdChg(t)}},On=class extends Yi{constructor(t,e,r){super(),this.type="session",this.subtype=void 0,this.server=!0,this._ending=!1,this._channel=void 0,this._chanInfo={type:"session",incoming:{id:r,window:ar,packetSize:cr,state:"open"},outgoing:{id:e.sender,window:e.window,packetSize:e.packetSize,state:"open"}}}},pn=class extends Yi{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new Error("Missing configuration object");let r=Object.create(null),s=[],i=t.hostKeys;if(!Array.isArray(i))throw new Error("hostKeys must be an array");let o=typeof t.algorithms=="object"&&t.algorithms!==null?t.algorithms:{},a=Gi(o.serverHostKey,HA,zA);for(let h=0;h<i.length;++h){let p;if(Buffer.isBuffer(i[h])||typeof i[h]=="string"?p=vh(i[h]):p=vh(i[h].key,i[h].passphrase),p instanceof Error)throw new Error(`Cannot parse privateKey: ${p.message}`);if(Array.isArray(p)&&(p=p[0]),p.getPrivatePEM()===null)throw new Error("privateKey value contains an invalid private key");if(!s.includes(p.type))if(p.type==="ssh-rsa"){let A=a.indexOf("ssh-rsa"),E=a.indexOf("rsa-sha2-256"),b=a.indexOf("rsa-sha2-512");A===-1&&(A=1/0),[A,E,b].sort(sy).forEach(x=>{if(x===-1)return;let P;switch(x){case A:P="ssh-rsa";break;case E:P="rsa-sha2-256";break;case b:P="rsa-sha2-512";break;default:return}r[P]=p,s.push(P)})}else r[p.type]=p,s.push(p.type)}let c={kex:Gi(o.kex,$A,VA).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:s,cs:{cipher:Gi(o.cipher,LA,WA),mac:Gi(o.hmac,FA,KA),compress:Gi(o.compress,UA,qA),lang:[]},sc:void 0};c.sc=c.cs,typeof e=="function"&&this.on("connection",e);let l=typeof t.debug=="function"?t.debug:void 0,u=t.ident?Buffer.from(t.ident):void 0,f=new YA(c);this._srv=new DA(h=>{if(this._connections>=this.maxConnections){h.destroy();return}++this._connections,h.once("close",()=>{--this._connections});let p;if(l){let A=`[${process.hrtime().join(".")}] `;p=E=>{l(`${A}${E}`)}}new go(h,r,u,f,p,this,t)}).on("error",h=>{this.emit("error",h)}).on("listening",()=>{this.emit("listening")}).on("close",()=>{this.emit("close")}),this._connections=0,this.maxConnections=1/0}injectSocket(t){this._srv.emit("connection",t)}listen(...t){return this._srv.listen(...t),this}address(){return this._srv.address()}getConnections(t){return this._srv.getConnections(t),this}close(t){return this._srv.close(t),this}ref(){return this._srv.ref(),this}unref(){return this._srv.unref(),this}};pn.KEEPALIVE_CLIENT_INTERVAL=15e3;pn.KEEPALIVE_CLIENT_COUNT_MAX=3;var go=class extends Yi{constructor(t,e,r,s,i,o,a){super();let c=0,l=!1,u=[],f,h,p,A=[];this._sock=t,this._chanMgr=new ty(this),this._debug=i,this.noMoreSessions=!1,this.authenticated=!1;function E(v){}this.on("error",E);let b=i?(v,_,w)=>{i(`Debug output from client: ${JSON.stringify(w)}`)}:void 0,x=typeof a.keepaliveInterval=="number"&&isFinite(a.keepaliveInterval)&&a.keepaliveInterval>0?a.keepaliveInterval:typeof pn.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite(pn.KEEPALIVE_CLIENT_INTERVAL)&&pn.KEEPALIVE_CLIENT_INTERVAL>0?pn.KEEPALIVE_CLIENT_INTERVAL:-1,P=typeof a.keepaliveCountMax=="number"&&isFinite(a.keepaliveCountMax)&&a.keepaliveCountMax>=0?a.keepaliveCountMax:typeof pn.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite(pn.KEEPALIVE_CLIENT_COUNT_MAX)&&pn.KEEPALIVE_CLIENT_COUNT_MAX>=0?pn.KEEPALIVE_CLIENT_COUNT_MAX:-1,q=0;x!==-1&&P!==-1&&(this.once("ready",()=>{let v=()=>{clearInterval(h)};this.on("close",v).on("end",v),h=setInterval(()=>{if(++q>P){clearInterval(h);let _=new Error("Keepalive timeout");_.level="client-timeout",this.emit("error",_),this.end()}else C.ping()},x)}),p=()=>{h&&h.refresh(),q=0});let C=this._protocol=new jA({server:!0,hostKeys:e,ident:r,offer:s,onPacket:p,greeting:a.greeting,banner:a.banner,onWrite:v=>{ho(t)&&t.write(v)},onError:v=>{C._destruct||t.removeAllListeners("data"),this.emit("error",v);try{t.end()}catch{}},onHeader:v=>{this.removeListener("error",E);let _={ip:t.remoteAddress,family:t.remoteFamily,port:t.remotePort,header:v};if(!o.emit("connection",this,_)){C.disconnect(ni.BY_APPLICATION),t.end();return}v.greeting&&this.emit("greeting",v.greeting)},onHandshakeComplete:v=>{++c>1&&this.emit("rekey"),this.emit("handshake",v)},debug:i,messageHandlers:{DEBUG:b,DISCONNECT:(v,_,w)=>{if(_!==ni.BY_APPLICATION){w||(w=QA[_],w===void 0&&(w=`Unexpected disconnection reason: ${_}`));let k=new Error(w);k.code=_,this.emit("error",k)}t.end()},CHANNEL_OPEN:(v,_)=>{if(_.type==="session"&&this.noMoreSessions||!this.authenticated){let re=ti.ADMINISTRATIVELY_PROHIBITED;return C.channelOpenFail(_.sender,re)}let w=-1,k,N=!1,R,ie=()=>{N||(N=!0,k===void 0&&(w===-1?k=ti.RESOURCE_SHORTAGE:k=ti.CONNECT_FAILED),w!==-1&&this._chanMgr.remove(w),C.channelOpenFail(_.sender,k,""))},j=()=>(w=this._chanMgr.add(),w===-1&&(k=ti.RESOURCE_SHORTAGE,i&&i("Automatic rejection of incoming channel open: no channels available")),w!==-1),X=_.data;switch(_.type){case"session":if(Jt(this,"session")&&j()){R=()=>{if(N)return;N=!0;let re=new On(this,_,w);return this._chanMgr.update(w,re),C.channelOpenConfirm(_.sender,w,ar,cr),re},this.emit("session",R,ie);return}break;case"direct-tcpip":if(Jt(this,"tcpip")&&j()){R=()=>{if(N)return;N=!0;let re={type:void 0,incoming:{id:w,window:ar,packetSize:cr,state:"open"},outgoing:{id:_.sender,window:_.window,packetSize:_.packetSize,state:"open"}},fe=new ri(this,re,{server:!0});return this._chanMgr.update(w,fe),C.channelOpenConfirm(_.sender,w,ar,cr),fe},this.emit("tcpip",R,ie,X);return}break;case"direct-streamlocal@openssh.com":if(Jt(this,"openssh.streamlocal")&&j()){R=()=>{if(N)return;N=!0;let re={type:void 0,incoming:{id:w,window:ar,packetSize:cr,state:"open"},outgoing:{id:_.sender,window:_.window,packetSize:_.packetSize,state:"open"}},fe=new ri(this,re,{server:!0});return this._chanMgr.update(w,fe),C.channelOpenConfirm(_.sender,w,ar,cr),fe},this.emit("openssh.streamlocal",R,ie,X);return}break;default:k=ti.UNKNOWN_CHANNEL_TYPE,i&&i(`Automatic rejection of unsupported incoming channel open type: ${_.type}`)}k===void 0&&(k=ti.ADMINISTRATIVELY_PROHIBITED,i&&i(`Automatic rejection of unexpected incoming channel open for: ${_.type}`)),ie()},CHANNEL_OPEN_CONFIRMATION:(v,_)=>{let w=this._chanMgr.get(_.recipient);if(typeof w!="function")return;let k={type:w.type,incoming:{id:_.recipient,window:ar,packetSize:cr,state:"open"},outgoing:{id:_.sender,window:_.window,packetSize:_.packetSize,state:"open"}},N=new ri(this,k,{server:!0});this._chanMgr.update(_.recipient,N),w(void 0,N)},CHANNEL_OPEN_FAILURE:(v,_,w,k)=>{let N=this._chanMgr.get(_);if(typeof N!="function")return;ny(this,_,{reason:w,description:k},N)},CHANNEL_DATA:(v,_,w)=>{let k=this._chanMgr.get(_);if(!(typeof k!="object"||k===null)&&!(k.constructor===On&&(k=k._channel,!k))&&k.incoming.window!==0){if(k.incoming.window-=w.length,k.push(w)===!1){k._waitChanDrain=!0;return}k.incoming.window<=ey&&ZA(k)}},CHANNEL_EXTENDED_DATA:(v,_,w,k)=>{},CHANNEL_WINDOW_ADJUST:(v,_,w)=>{let k=this._chanMgr.get(_);typeof k!="object"||k===null||k.constructor===On&&(k=k._channel,!k)||(k.outgoing.window+=w,k._waitWindow&&(k._waitWindow=!1,k._chunk?k._write(k._chunk,null,k._chunkcb):k._chunkcb?k._chunkcb():k._chunkErr?k.stderr._write(k._chunkErr,null,k._chunkcbErr):k._chunkcbErr&&k._chunkcbErr()))},CHANNEL_SUCCESS:(v,_)=>{let w=this._chanMgr.get(_);typeof w!="object"||w===null||w.constructor===On&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!1)},CHANNEL_FAILURE:(v,_)=>{let w=this._chanMgr.get(_);typeof w!="object"||w===null||w.constructor===On&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!0)},CHANNEL_REQUEST:(v,_,w,k,N)=>{let R=this._chanMgr.get(_);if(typeof R!="object"||R===null)return;let ie=!1,j,X;if(R.constructor!==On){k&&C.channelFailure(R.outgoing.id);return}if(k&&(w!=="shell"&&w!=="exec"&&w!=="subsystem"&&(j=()=>{ie||R._ending||R._channel||(ie=!0,C.channelSuccess(R._chanInfo.outgoing.id))}),X=()=>{ie||R._ending||R._channel||(ie=!0,C.channelFailure(R._chanInfo.outgoing.id))}),R._ending){X&&X();return}switch(w){case"env":if(Jt(R,"env")){R.emit("env",j,X,{key:N.name,val:N.value});return}break;case"pty-req":if(Jt(R,"pty")){R.emit("pty",j,X,N);return}break;case"window-change":Jt(R,"window-change")?R.emit("window-change",j,X,N):X&&X();break;case"x11-req":if(Jt(R,"x11")){R.emit("x11",j,X,N);return}break;case"signal":if(Jt(R,"signal")){R.emit("signal",j,X,{name:N});return}break;case"auth-agent-req@openssh.com":if(Jt(R,"auth-agent")){R.emit("auth-agent",j,X);return}break;case"shell":if(Jt(R,"shell")){j=()=>{if(ie||R._ending||R._channel)return;ie=!0,k&&C.channelSuccess(R._chanInfo.outgoing.id);let re=new ri(this,R._chanInfo,{server:!0});return re.subtype=R.subtype=w,R._channel=re,re},R.emit("shell",j,X);return}break;case"exec":if(Jt(R,"exec")){j=()=>{if(ie||R._ending||R._channel)return;ie=!0,k&&C.channelSuccess(R._chanInfo.outgoing.id);let re=new ri(this,R._chanInfo,{server:!0});return re.subtype=R.subtype=w,R._channel=re,re},R.emit("exec",j,X,{command:N});return}break;case"subsystem":{let re=N==="sftp";if(j=()=>{if(ie||R._ending||R._channel)return;ie=!0,k&&C.channelSuccess(R._chanInfo.outgoing.id);let fe;return re?fe=new XA(this,R._chanInfo,{server:!0,debug:i}):(fe=new ri(this,R._chanInfo,{server:!0}),fe.subtype=R.subtype=`${w}:${N}`),R._channel=fe,fe},N==="sftp"){if(Jt(R,"sftp")){R.emit("sftp",j,X);return}re=!1}if(Jt(R,"subsystem")){R.emit("subsystem",j,X,{name:N});return}break}}i&&i(`Automatic rejection of incoming channel request: ${w}`),X&&X()},CHANNEL_EOF:(v,_)=>{let w=this._chanMgr.get(_);typeof w!="object"||w===null||w.constructor===On&&(w._ending||(w._ending=!0,w.emit("eof"),w.emit("end")),w=w._channel,!w)||w.incoming.state==="open"&&(w.incoming.state="eof",w.readable&&w.push(null))},CHANNEL_CLOSE:(v,_)=>{let w=this._chanMgr.get(_);typeof w!="object"||w===null||w.constructor===On&&(w._ending=!0,w.emit("close"),w=w._channel,!w)||ry(this,_,w)},SERVICE_REQUEST:(v,_)=>{if(c===0||l||this.authenticated||_!=="ssh-userauth"){C.disconnect(ni.SERVICE_NOT_AVAILABLE),t.end();return}l=!0,C.serviceAccept(_)},USERAUTH_REQUEST:(v,_,w,k,N)=>{if(c===0||this.authenticated||f&&(f.username!==_||f.service!==w)||k!=="password"&&k!=="publickey"&&k!=="hostbased"&&k!=="keyboard-interactive"&&k!=="none"||u.length===iy){C.disconnect(ni.PROTOCOL_ERROR),t.end();return}else if(w!=="ssh-connection"){C.disconnect(ni.SERVICE_NOT_AVAILABLE),t.end();return}let R;switch(k){case"keyboard-interactive":R=new po(C,_,w,k,N,$);break;case"publickey":R=new Ic(C,_,w,k,N,$);break;case"hostbased":R=new Cc(C,_,w,k,N,$);break;case"password":if(f&&f instanceof mo&&f._changeCb){let ie=f._changeCb;f._changeCb=void 0,ie(N.newPassword);return}R=new mo(C,_,w,k,N,$);break;case"none":R=new lr(C,_,w,k,$);break}if(f)if(f._initialResponse)f._multistep&&!f._finalResponse&&(f._cleanup&&f._cleanup(),f.emit("abort"));else return u.push(R);f=R,Jt(this,"authentication")?this.emit("authentication",f):f.reject()},USERAUTH_INFO_RESPONSE:(v,_)=>{f&&f instanceof po&&f._onInfoResponse(_)},GLOBAL_REQUEST:(v,_,w,k)=>{let N={type:null,buf:null};function R(ie,j){N.type=ie,N.buf=j,F()}if(w&&A.push(N),(_==="tcpip-forward"||_==="cancel-tcpip-forward"||_==="no-more-sessions@openssh.com"||_==="streamlocal-forward@openssh.com"||_==="cancel-streamlocal-forward@openssh.com")&&Jt(this,"request")&&this.authenticated){let ie,j;if(w){let X=!1;ie=re=>{if(X)return;X=!0;let fe;_==="tcpip-forward"&&k.bindPort===0&&typeof re=="number"&&(fe=Buffer.allocUnsafe(4),JA(fe,re,0)),R("SUCCESS",fe)},j=()=>{X||(X=!0,R("FAILURE"))}}if(_==="no-more-sessions@openssh.com"){this.noMoreSessions=!0,ie&&ie();return}this.emit("request",ie,j,_,k)}else w&&R("FAILURE")}}});t.pause(),GA.then(()=>{C.start(),t.on("data",v=>{try{C.parse(v,0,v.length)}catch(_){this.emit("error",_);try{ho(t)&&t.end()}catch{}}}),t.resume()}).catch(v=>{this.emit("error",v);try{ho(t)&&t.end()}catch{}}),t.on("error",v=>{v.level="socket",this.emit("error",v)}).once("end",()=>{i&&i("Socket ended"),C.cleanup(),this.emit("end")}).once("close",()=>{i&&i("Socket closed"),C.cleanup(),this.emit("close");let v=new Error("No response from server");this._chanMgr.cleanup(v)});let $=(v,_,w,k)=>{f===v&&!this.authenticated&&(_?(f=void 0,this.authenticated=!0,C.authSuccess(),u=[],this.emit("ready")):(C.authFailure(w,k),u.length&&(f=u.pop(),Jt(this,"authentication")?this.emit("authentication",f):f.reject())))};function F(){for(;A.length>0&&A[0].type;){let v=A.shift();v.type==="SUCCESS"&&C.requestSuccess(v.buf),v.type==="FAILURE"&&C.requestFailure()}}}end(){return this._sock&&ho(this._sock)&&(this._protocol.disconnect(ni.BY_APPLICATION),this._sock.end()),this}x11(t,e,r){return wc(this,"x11",{originAddr:t,originPort:e},r),this}forwardOut(t,e,r,s,i){return wc(this,"forwarded-tcpip",{boundAddr:t,boundPort:e,remoteAddr:r,remotePort:s},i),this}openssh_forwardOutStreamLocal(t,e){return wc(this,"forwarded-streamlocal@openssh.com",{socketPath:t},e),this}rekey(t){let e;try{this._protocol.rekey()}catch(r){e=r}typeof t=="function"&&(e?process.nextTick(t,e):this.once("rekey",t))}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function wc(n,t,e,r){let s=ar,i=cr;typeof e=="function"&&(r=e,e={});let o=(c,l)=>{r(c,l)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"forwarded-tcpip":n._protocol.forwardedTcpip(a,s,i,e);break;case"x11":n._protocol.x11(a,s,i,e);break;case"forwarded-streamlocal@openssh.com":n._protocol.openssh_forwardedStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function sy(n,t){return n-t}kc.exports=pn;kc.exports.IncomingClient=go});var Oh=ut((Gx,Th)=>{"use strict";var{createCipheriv:oy,generateKeyPair:ay,generateKeyPairSync:cy,getCurves:ly,randomBytes:Bh}=require("crypto"),{Ber:It}=bi(),uy=Ko().pbkdf,{CIPHER_INFO:fy}=tr(),dy=16,hy=16,py=ly(),my=new Map(Object.entries(fy));function Rh(n,t){if(typeof n!="string")throw new TypeError("Key type must be a string");let e={type:"spki",format:"der"},r={type:"pkcs8",format:"der"};switch(n.toLowerCase()){case"rsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for RSA key");let s=t.bits;if(!Number.isInteger(s))throw new TypeError("RSA bits must be an integer");if(s<=0||s>16384)throw new RangeError("RSA bits must be non-zero and <= 16384");return["rsa",{modulusLength:s,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ecdsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for ECDSA key");if(!Number.isInteger(t.bits))throw new TypeError("ECDSA bits must be an integer");let s;switch(t.bits){case 256:s="prime256v1";break;case 384:s="secp384r1";break;case 521:s="secp521r1";break;default:throw new Error("ECDSA bits must be 256, 384, or 521")}if(!py.includes(s))throw new Error("Unsupported ECDSA bits value");return["ec",{namedCurve:s,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ed25519":return["ed25519",{publicKeyEncoding:e,privateKeyEncoding:r}];default:throw new Error(`Unsupported key type: ${n}`)}}function gy(n,t,e){switch(n){case"rsa":{let r=new It.Reader(e);if(r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.113549.1.1.1")throw new Error("Bad RSA private OID");if(r.readByte()!==It.Null)throw new Error("Malformed RSA private key (expected null)");if(r.readByte()!==0)throw new Error("Malformed RSA private key (expected zero-length null)");if(r=new It.Reader(r.readString(It.OctetString,!0)),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");let s=r.readString(It.Integer,!0),i=r.readString(It.Integer,!0),o=r.readString(It.Integer,!0),a=r.readString(It.Integer,!0),c=r.readString(It.Integer,!0);r.readString(It.Integer,!0),r.readString(It.Integer,!0);let l=r.readString(It.Integer,!0),u=Buffer.from("ssh-rsa"),f=Buffer.allocUnsafe(4+u.length+4+s.length+4+i.length+4+o.length+4+l.length+4+a.length+4+c.length),h=0;f.writeUInt32BE(u.length,h+=0),f.set(u,h+=4),f.writeUInt32BE(s.length,h+=u.length),f.set(s,h+=4),f.writeUInt32BE(i.length,h+=s.length),f.set(i,h+=4),f.writeUInt32BE(o.length,h+=i.length),f.set(o,h+=4),f.writeUInt32BE(l.length,h+=o.length),f.set(l,h+=4),f.writeUInt32BE(a.length,h+=l.length),f.set(a,h+=4),f.writeUInt32BE(c.length,h+=a.length),f.set(c,h+=4);let p=Buffer.allocUnsafe(4+u.length+4+i.length+4+s.length);return h=0,p.writeUInt32BE(u.length,h+=0),p.set(u,h+=4),p.writeUInt32BE(i.length,h+=u.length),p.set(i,h+=4),p.writeUInt32BE(s.length,h+=i.length),p.set(s,h+=4),{sshName:u.toString(),priv:f,pub:p}}case"ec":{let r=new It.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA public OID");r.readOID();let s=r.readString(It.BitString,!0);{let h=0;for(;h<s.length&&s[h]===0;++h);h>0&&(s=s.slice(h))}if(r=new It.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ECDSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA private OID");let i=r.readOID(),o;switch(i){case"1.2.840.10045.3.1.7":o="nistp256";break;case"1.3.132.0.34":o="nistp384";break;case"1.3.132.0.35":o="nistp521";break;default:throw new Error("Unsupported curve in ECDSA private key")}if(r=new It.Reader(r.readString(It.OctetString,!0)),r.readSequence(),r.readInt()!==1)throw new Error("Unsupported version in ECDSA private key");let a=Buffer.concat([Buffer.from([0]),r.readString(It.OctetString,!0)]),c=Buffer.from(`ecdsa-sha2-${o}`);o=Buffer.from(o);let l=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length+4+a.length),u=0;l.writeUInt32BE(c.length,u+=0),l.set(c,u+=4),l.writeUInt32BE(o.length,u+=c.length),l.set(o,u+=4),l.writeUInt32BE(s.length,u+=o.length),l.set(s,u+=4),l.writeUInt32BE(a.length,u+=s.length),l.set(a,u+=4);let f=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length);return u=0,f.writeUInt32BE(c.length,u+=0),f.set(c,u+=4),f.writeUInt32BE(o.length,u+=c.length),f.set(o,u+=4),f.writeUInt32BE(s.length,u+=o.length),f.set(s,u+=4),{sshName:c.toString(),priv:l,pub:f}}case"ed25519":{let r=new It.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let s=r.readString(It.BitString,!0);{let u=0;for(;u<s.length&&s[u]===0;++u);u>0&&(s=s.slice(u))}if(r=new It.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ED25519 private key");if(r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 private OID");r=new It.Reader(r.readString(It.OctetString,!0));let i=r.readString(It.OctetString,!0),o=Buffer.from("ssh-ed25519"),a=Buffer.allocUnsafe(4+o.length+4+s.length+4+(i.length+s.length)),c=0;a.writeUInt32BE(o.length,c+=0),a.set(o,c+=4),a.writeUInt32BE(s.length,c+=o.length),a.set(s,c+=4),a.writeUInt32BE(i.length+s.length,c+=s.length),a.set(i,c+=4),a.set(s,c+=i.length);let l=Buffer.allocUnsafe(4+o.length+4+s.length);return c=0,l.writeUInt32BE(o.length,c+=0),l.set(o,c+=4),l.writeUInt32BE(s.length,c+=o.length),l.set(s,c+=4),{sshName:o.toString(),priv:a,pub:l}}}}function Ph(n,t,e,r){let s="new",i,o="";if(typeof r=="object"&&r!==null&&(typeof r.comment=="string"&&r.comment&&(o=r.comment),typeof r.format=="string"&&r.format&&(s=r.format),r.passphrase)){let a;if(typeof r.passphrase=="string")a=Buffer.from(r.passphrase);else if(Buffer.isBuffer(r.passphrase))a=r.passphrase;else throw new Error("Invalid passphrase");if(r.cipher===void 0)throw new Error("Missing cipher name");let c=my.get(r.cipher);if(c===void 0)throw new Error("Invalid cipher name");if(s==="new"){let l=hy;if(r.rounds!==void 0){if(!Number.isInteger(r.rounds))throw new TypeError("rounds must be an integer");r.rounds>0&&(l=r.rounds)}let u=Buffer.allocUnsafe(c.keyLen+c.ivLen),f=Bh(dy);if(uy(a,a.length,f,f.length,u,u.length,l)!==0)return new Error("Failed to generate information to encrypt key");let p=Buffer.allocUnsafe(4+f.length+4);{let A=0;p.writeUInt32BE(f.length,A+=0),p.set(f,A+=4),p.writeUInt32BE(l,A+=f.length)}i={cipher:c,cipherName:r.cipher,kdfName:"bcrypt",kdfOptions:p,key:u.slice(0,c.keyLen),iv:u.slice(c.keyLen)}}}switch(s){case"new":{let a=`-----BEGIN OPENSSH PRIVATE KEY-----
|
|
16
16
|
`,c,l=Buffer.from(i?i.cipherName:"none"),u=Buffer.from(i?i.kdfName:"none"),f=i?i.kdfOptions:Buffer.alloc(0),h=i?i.cipher.blockLen:8,p=gy(n,t,e),A=Bh(4),E=Buffer.from(o),b=8+p.priv.length+4+E.length,x=[];for(let F=1;(b+x.length)%h;++F)x.push(F&255);x=Buffer.from(x);let P=Buffer.allocUnsafe(b+x.length),q;{let F=0;P.set(A,F+=0),P.set(A,F+=4),P.set(p.priv,F+=4),P.writeUInt32BE(E.length,F+=p.priv.length),P.set(E,F+=4),P.set(x,F+=E.length)}if(i){let F={authTagLength:i.cipher.authLen},v=oy(i.cipher.sslName,i.key,i.iv,F);v.setAutoPadding(!1),P=Buffer.concat([v.update(P),v.final()]),i.cipher.authLen>0?q=v.getAuthTag():q=Buffer.alloc(0),i.key.fill(0),i.iv.fill(0)}else q=Buffer.alloc(0);let C=Buffer.from("openssh-key-v1\0"),$=Buffer.allocUnsafe(C.length+4+l.length+4+u.length+4+f.length+4+4+p.pub.length+4+P.length+q.length);{let F=0;$.set(C,F+=0),$.writeUInt32BE(l.length,F+=C.length),$.set(l,F+=4),$.writeUInt32BE(u.length,F+=l.length),$.set(u,F+=4),$.writeUInt32BE(f.length,F+=u.length),$.set(f,F+=4),$.writeUInt32BE(1,F+=f.length),$.writeUInt32BE(p.pub.length,F+=4),$.set(p.pub,F+=4),$.writeUInt32BE(P.length,F+=p.pub.length),$.set(P,F+=4),$.set(q,F+=P.length)}{let F=$.base64Slice(0,$.length),v=F.replace(/.{64}/g,`$&
|
|
17
17
|
`);F.length&63&&(v+=`
|
|
18
18
|
`),a+=v}{let F=p.pub.base64Slice(0,p.pub.length);c=`${p.sshName} ${F}${o?` ${o}`:""}`}return a+=`-----END OPENSSH PRIVATE KEY-----
|
|
@@ -981,17 +981,17 @@ Hint: install it with: apt install npm
|
|
|
981
981
|
`),exitCode:0}}};function Im(n,t){let e=0,r="",s=0;for(;s<n.length;){if(n[s]==="\\"&&s+1<n.length)switch(n[s+1]){case"n":r+=`
|
|
982
982
|
`,s+=2;continue;case"t":r+=" ",s+=2;continue;case"r":r+="\r",s+=2;continue;case"\\":r+="\\",s+=2;continue;case"a":r+="\x07",s+=2;continue;case"b":r+="\b",s+=2;continue;case"f":r+="\f",s+=2;continue;case"v":r+="\v",s+=2;continue;default:r+=n[s],s++;continue}if(n[s]==="%"&&s+1<n.length){let i=s+1,o=!1;n[i]==="-"&&(o=!0,i++);let a=!1;n[i]==="0"&&(a=!0,i++);let c=0;for(;i<n.length&&/\d/.test(n[i]);)c=c*10+parseInt(n[i],10),i++;let l=-1;if(n[i]===".")for(i++,l=0;i<n.length&&/\d/.test(n[i]);)l=l*10+parseInt(n[i],10),i++;let u=n[i],f=t[e++]??"",h=(p,A=" ")=>{if(c<=0||p.length>=c)return p;let E=A.repeat(c-p.length);return o?p+E:E+p};switch(u){case"s":{let p=String(f);l>=0&&(p=p.slice(0,l)),r+=h(p);break}case"d":case"i":r+=h(String(parseInt(f,10)||0),a?"0":" ");break;case"f":{let p=l>=0?l:6;r+=h((parseFloat(f)||0).toFixed(p));break}case"o":r+=h((parseInt(f,10)||0).toString(8),a?"0":" ");break;case"x":r+=h((parseInt(f,10)||0).toString(16),a?"0":" ");break;case"X":r+=h((parseInt(f,10)||0).toString(16).toUpperCase(),a?"0":" ");break;case"%":r+="%",e--;break;default:r+=n[s],s++;continue}s=i+1;continue}r+=n[s],s++}return r}var Eu={name:"printf",description:"Format and print data",category:"shell",params:["<format> [args...]"],run:({args:n})=>{let t=n[0];return t?{stdout:Im(t,n.slice(1)),exitCode:0}:{stderr:"printf: missing format string",exitCode:1}}};var Su={name:"ps",description:"Report process status",category:"system",params:["[-a] [-u] [-x] [aux]"],run:({authUser:n,shell:t,args:e})=>{let r=t.users.listActiveSessions(),s=ae(e,["-u"])||e.includes("u")||e.includes("aux")||e.includes("au"),i=ae(e,["-a","-x"])||e.includes("a")||e.includes("aux");if(s){let u=["USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND"],f=1e3;for(let h of r){let p=h.username.padEnd(10).slice(0,10),A=(Math.random()*.5).toFixed(1),E=Math.floor(Math.random()*2e4+5e3),b=Math.floor(Math.random()*5e3+1e3);u.push(`${p} ${String(f).padStart(6)} 0.0 ${A.padStart(4)} ${String(E).padStart(6)} ${String(b).padStart(5)} ${h.tty.padEnd(8)} Ss 00:00 0:00 bash`),f++}return u.push(`root ${String(f).padStart(6)} 0.0 0.0 0 0 ? S 00:00 0:00 ps`),{stdout:u.join(`
|
|
983
983
|
`),exitCode:0}}let a=[" PID TTY TIME CMD"],c=1e3;for(let l of r)!i&&l.username!==n||(a.push(`${String(c).padStart(5)} ${l.tty.padEnd(12)} 00:00:00 ${l.username===n?"bash":`bash (${l.username})`}`),c++);return a.push(`${String(c).padStart(5)} pts/0 00:00:00 ps`),{stdout:a.join(`
|
|
984
|
-
`),exitCode:0}}};var _u={name:"pwd",description:"Print working directory",category:"navigation",params:[],run:({cwd:n})=>({stdout:n,exitCode:0})};var Cm="Python 3.11.2";var ys="3.11.2 (default, Mar 13 2023, 12:18:29) [GCC 12.2.0]",Y={__pytype__:"none"};function _t(n=[]){return{__pytype__:"dict",data:new Map(n)}}function Bo(n,t,e=1){return{__pytype__:"range",start:n,stop:t,step:e}}function yt(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="dict"}function Dr(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="range"}function Rn(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="func"}function Ro(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="class"}function gi(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="instance"}function Hn(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="none"}function
|
|
984
|
+
`),exitCode:0}}};var _u={name:"pwd",description:"Print working directory",category:"navigation",params:[],run:({cwd:n})=>({stdout:n,exitCode:0})};var Cm="Python 3.11.2";var ys="3.11.2 (default, Mar 13 2023, 12:18:29) [GCC 12.2.0]",Y={__pytype__:"none"};function _t(n=[]){return{__pytype__:"dict",data:new Map(n)}}function Bo(n,t,e=1){return{__pytype__:"range",start:n,stop:t,step:e}}function yt(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="dict"}function Dr(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="range"}function Rn(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="func"}function Ro(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="class"}function gi(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="instance"}function Hn(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="none"}function Mt(n){return n===null||Hn(n)?"None":n===!0?"True":n===!1?"False":typeof n=="number"?Number.isInteger(n)?String(n):n.toPrecision(12).replace(/\.?0+$/,""):typeof n=="string"?`'${n.replace(/'/g,"\\'")}'`:Array.isArray(n)?`[${n.map(Mt).join(", ")}]`:yt(n)?`{${[...n.data.entries()].map(([t,e])=>`'${t}': ${Mt(e)}`).join(", ")}}`:Dr(n)?`range(${n.start}, ${n.stop}${n.step!==1?`, ${n.step}`:""})`:Rn(n)?`<function ${n.name} at 0x...>`:Ro(n)?`<class '${n.name}'>`:gi(n)?`<${n.cls.name} object at 0x...>`:String(n)}function Re(n){return n===null||Hn(n)?"None":n===!0?"True":n===!1?"False":typeof n=="number"?Number.isInteger(n)?String(n):n.toPrecision(12).replace(/\.?0+$/,""):typeof n=="string"?n:Array.isArray(n)?`[${n.map(Mt).join(", ")}]`:yt(n)?`{${[...n.data.entries()].map(([t,e])=>`'${t}': ${Mt(e)}`).join(", ")}}`:Dr(n)?`range(${n.start}, ${n.stop}${n.step!==1?`, ${n.step}`:""})`:Mt(n)}function dn(n){return n===null||Hn(n)?!1:typeof n=="boolean"?n:typeof n=="number"?n!==0:typeof n=="string"||Array.isArray(n)?n.length>0:yt(n)?n.data.size>0:Dr(n)?xu(n)>0:!0}function xu(n){if(n.step===0)return 0;let t=Math.ceil((n.stop-n.start)/n.step);return Math.max(0,t)}function km(n){let t=[];for(let e=n.start;(n.step>0?e<n.stop:e>n.stop)&&(t.push(e),!(t.length>1e4));e+=n.step);return t}function Ot(n){if(Array.isArray(n))return n;if(typeof n=="string")return[...n];if(Dr(n))return km(n);if(yt(n))return[...n.data.keys()];throw new St("TypeError",`'${pr(n)}' object is not iterable`)}function pr(n){return n===null||Hn(n)?"NoneType":typeof n=="boolean"?"bool":typeof n=="number"?Number.isInteger(n)?"int":"float":typeof n=="string"?"str":Array.isArray(n)?"list":yt(n)?"dict":Dr(n)?"range":Rn(n)?"function":Ro(n)?"type":gi(n)?n.cls.name:"object"}var St=class{constructor(t,e){this.type=t;this.message=e}type;message;toString(){return`${this.type}: ${this.message}`}},Mr=class{constructor(t){this.value=t}value},Ai=class{},yi=class{},Ei=class{constructor(t){this.code=t}code};function vm(n){let t=new Map,e=_t([["sep","/"],["linesep",`
|
|
985
985
|
`],["curdir","."],["pardir",".."]]);return e.__methods__={getcwd:()=>n,getenv:r=>typeof r=="string"?process.env[r]??Y:Y,path:_t([["join",Y],["exists",Y],["dirname",Y],["basename",Y]]),listdir:()=>[]},t.set("__builtins__",Y),t.set("__name__","__main__"),t.set("__cwd__",n),t}function Nm(n){let t=_t([["sep","/"],["curdir","."]]),e=_t([["sep","/"],["linesep",`
|
|
986
986
|
`],["name","posix"]]);return e._cwd=n,t._cwd=n,e.path=t,e}function Bm(){return _t([["version",ys],["version_info",_t([["major",3],["minor",11],["micro",2]].map(([n,t])=>[n,t]))],["platform","linux"],["executable","/usr/bin/python3"],["prefix","/usr"],["path",["/usr/lib/python3.11","/usr/lib/python3.11/lib-dynload"]],["argv",[""]],["maxsize",9007199254740991]])}function Rm(){return _t([["pi",Math.PI],["e",Math.E],["tau",Math.PI*2],["inf",1/0],["nan",NaN],["sqrt",Y],["floor",Y],["ceil",Y],["log",Y],["pow",Y],["sin",Y],["cos",Y],["tan",Y],["fabs",Y],["factorial",Y]])}function Pm(){return _t([["dumps",Y],["loads",Y]])}function Tm(){return _t([["match",Y],["search",Y],["findall",Y],["sub",Y],["split",Y],["compile",Y]])}var bu={os:Nm,sys:()=>Bm(),math:()=>Rm(),json:()=>Pm(),re:()=>Tm(),random:()=>_t([["random",Y],["randint",Y],["choice",Y],["shuffle",Y]]),time:()=>_t([["time",Y],["sleep",Y],["ctime",Y]]),datetime:()=>_t([["datetime",Y],["date",Y],["timedelta",Y]]),collections:()=>_t([["Counter",Y],["defaultdict",Y],["OrderedDict",Y]]),itertools:()=>_t([["chain",Y],["product",Y],["combinations",Y],["permutations",Y]]),functools:()=>_t([["reduce",Y],["partial",Y],["lru_cache",Y]]),string:()=>_t([["ascii_letters","abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"],["digits","0123456789"],["punctuation","!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"]])},Es=class{constructor(t){this.cwd=t}cwd;output=[];stderr=[];modules=new Map;getOutput(){return this.output.join(`
|
|
987
987
|
`)+(this.output.length?`
|
|
988
988
|
`:"")}getStderr(){return this.stderr.join(`
|
|
989
989
|
`)+(this.stderr.length?`
|
|
990
990
|
`:"")}splitArgs(t){let e=[],r=0,s="",i=!1,o="";for(let a=0;a<t.length;a++){let c=t[a];i?(s+=c,c===o&&t[a-1]!=="\\"&&(i=!1)):c==='"'||c==="'"?(i=!0,o=c,s+=c):"([{".includes(c)?(r++,s+=c):")]}".includes(c)?(r--,s+=c):c===","&&r===0?(e.push(s.trim()),s=""):s+=c}return s.trim()&&e.push(s.trim()),e}pyEval(t,e){if(t=t.trim(),!t||t==="None")return Y;if(t==="True")return!0;if(t==="False")return!1;if(t==="...")return Y;if(/^-?\d+$/.test(t))return parseInt(t,10);if(/^-?\d+\.\d*$/.test(t))return parseFloat(t);if(/^0x[0-9a-fA-F]+$/.test(t))return parseInt(t,16);if(/^0o[0-7]+$/.test(t))return parseInt(t.slice(2),8);if(/^('''[\s\S]*'''|"""[\s\S]*""")$/.test(t))return t.slice(3,-3);if(/^(['"])(.*)\1$/s.test(t))return t.slice(1,-1).replace(/\\n/g,`
|
|
991
|
-
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\").replace(/\\'/g,"'").replace(/\\"/g,'"');let r=t.match(/^f(['"])([\s\S]*)\1$/);if(r){let l=r[2];return l=l.replace(/\{([^{}]+)\}/g,(u,f)=>{try{return Re(this.pyEval(f.trim(),e))}catch{return`{${f}}`}}),l}let s=t.match(/^b(['"])(.*)\1$/s);if(s)return s[2];if(t.startsWith("[")&&t.endsWith("]")){let l=t.slice(1,-1).trim();if(!l)return[];let u=l.match(/^(.+?)\s+for\s+(\w+)\s+in\s+(.+?)(?:\s+if\s+(.+))?$/);if(u){let[,f,h,p,A]=u,E=
|
|
992
|
-
`);case"join":return
|
|
993
|
-
`.replace(/\\n/g,"")),Y;case"input":return this.output.push(Re(e[0]??"")),"";case"int":{if(e.length===0)return 0;let s=e[1]??10,i=parseInt(Re(e[0]??0),s);return Number.isNaN(i)?(()=>{throw new St("ValueError","invalid literal for int()")})():i}case"float":{if(e.length===0)return 0;let s=parseFloat(Re(e[0]??0));return Number.isNaN(s)?(()=>{throw new St("ValueError","could not convert to float")})():s}case"str":return e.length===0?"":Re(e[0]??Y);case"bool":return e.length===0?!1:dn(e[0]??Y);case"list":return e.length===0?[]:
|
|
994
|
-
`);this.execLines(r,0,e)}execLines(t,e,r){let s=e;for(;s<t.length;){let i=t[s];if(!i.trim()||i.trim().startsWith("#")){s++;continue}s=this.execStatement(t,s,r)}return s}execBlock(t,e){try{this.execLines(t,0,e)}catch(r){if(r instanceof Mr)return r.value;throw r}return Y}getIndent(t){let e=0;for(let r of t)if(r===" ")e++;else if(r===" ")e+=4;else break;return e}collectBlock(t,e,r){let s=[];for(let i=e;i<t.length;i++){let o=t[i];if(!o.trim()){s.push("");continue}if(this.getIndent(o)<=r)break;s.push(o.slice(r+4))}return s}execStatement(t,e,r){let s=t[e],i=s.trim(),o=this.getIndent(s);if(i==="pass")return e+1;if(i==="break")throw new Ai;if(i==="continue")throw new yi;let a=i.match(/^return(?:\s+(.+))?$/);if(a)throw new Mr(a[1]?this.pyEval(a[1],r):Y);let c=i.match(/^raise(?:\s+(.+))?$/);if(c){if(c[1]){let v=this.pyEval(c[1],r);throw new St(typeof v=="string"?v:pr(v),Re(v))}throw new St("RuntimeError","")}let l=i.match(/^assert\s+(.+?)(?:,\s*(.+))?$/);if(l){if(!dn(this.pyEval(l[1],r)))throw new St("AssertionError",l[2]?Re(this.pyEval(l[2],r)):"");return e+1}let u=i.match(/^del\s+(.+)$/);if(u)return r.delete(u[1].trim()),e+1;let f=i.match(/^import\s+(\w+)(?:\s+as\s+(\w+))?$/);if(f){let[,v,_]=f,w=bu[v];if(w){let k=w(this.cwd);this.modules.set(v,k),r.set(_??v,k)}return e+1}let h=i.match(/^from\s+(\w+)\s+import\s+(.+)$/);if(h){let[,v,_]=h,w=bu[v];if(w){let k=w(this.cwd);if(_?.trim()==="*")for(let[N,R]of k.data)r.set(N,R);else for(let N of _.split(",").map(R=>R.trim()))r.set(N,k.data.get(N)??Y)}return e+1}let p=i.match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(p){let[,v,_]=p,w=_.split(",").map(R=>R.trim()).filter(Boolean),k=this.collectBlock(t,e+1,o),N={__pytype__:"func",name:v,params:w,body:k,closure:new Map(r)};return r.set(v,N),e+1+k.length}let A=i.match(/^class\s+(\w+)(?:\(([^)]*)\))?\s*:$/);if(A){let[,v,_]=A,w=_?_.split(",").map(ie=>ie.trim()):[],k=this.collectBlock(t,e+1,o),N={__pytype__:"class",name:v,methods:new Map,bases:w},R=0;for(;R<k.length;){let j=k[R].trim().match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(j){let[,X,re]=j,fe=re.split(",").map(B=>B.trim()).filter(Boolean),H=this.collectBlock(k,R+1,0);N.methods.set(X,{__pytype__:"func",name:X,params:fe,body:H,closure:new Map(r)}),R+=1+H.length}else R++}return r.set(v,N),e+1+k.length}if(i.startsWith("if ")&&i.endsWith(":")){let v=i.slice(3,-1).trim(),_=this.collectBlock(t,e+1,o),w=_.length+1;if(dn(this.pyEval(v,r))){this.execBlock(_,new Map(r).also?.(R=>{for(let[ie,j]of r)R.set(ie,j)})??r),this.runBlockInScope(_,r);let N=e+1+_.length;for(;N<t.length;){let R=t[N].trim();if(this.getIndent(t[N])<o||!R.startsWith("elif")&&!R.startsWith("else"))break;let ie=this.collectBlock(t,N+1,o);N+=1+ie.length}return N}let k=e+1+_.length;for(;k<t.length;){let N=t[k],R=N.trim();if(this.getIndent(N)!==o)break;let ie=R.match(/^elif\s+(.+):$/);if(ie){let j=this.collectBlock(t,k+1,o);if(dn(this.pyEval(ie[1],r))){for(this.runBlockInScope(j,r),k+=1+j.length;k<t.length;){let X=t[k].trim();if(this.getIndent(t[k])!==o||!X.startsWith("elif")&&!X.startsWith("else"))break;let re=this.collectBlock(t,k+1,o);k+=1+re.length}return k}k+=1+j.length;continue}if(R==="else:"){let j=this.collectBlock(t,k+1,o);return this.runBlockInScope(j,r),k+1+j.length}break}return k}let E=i.match(/^for\s+(.+?)\s+in\s+(.+?)\s*:$/);if(E){let[,v,_]=E,w=
|
|
991
|
+
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\").replace(/\\'/g,"'").replace(/\\"/g,'"');let r=t.match(/^f(['"])([\s\S]*)\1$/);if(r){let l=r[2];return l=l.replace(/\{([^{}]+)\}/g,(u,f)=>{try{return Re(this.pyEval(f.trim(),e))}catch{return`{${f}}`}}),l}let s=t.match(/^b(['"])(.*)\1$/s);if(s)return s[2];if(t.startsWith("[")&&t.endsWith("]")){let l=t.slice(1,-1).trim();if(!l)return[];let u=l.match(/^(.+?)\s+for\s+(\w+)\s+in\s+(.+?)(?:\s+if\s+(.+))?$/);if(u){let[,f,h,p,A]=u,E=Ot(this.pyEval(p.trim(),e)),b=[];for(let x of E){let P=new Map(e);P.set(h,x),!(A&&!dn(this.pyEval(A,P)))&&b.push(this.pyEval(f.trim(),P))}return b}return this.splitArgs(l).map(f=>this.pyEval(f,e))}if(t.startsWith("(")&&t.endsWith(")")){let l=t.slice(1,-1).trim();if(!l)return[];let u=this.splitArgs(l);return u.length===1&&!l.endsWith(",")?this.pyEval(u[0],e):u.map(f=>this.pyEval(f,e))}if(t.startsWith("{")&&t.endsWith("}")){let l=t.slice(1,-1).trim();if(!l)return _t();let u=_t();for(let f of this.splitArgs(l)){let h=f.indexOf(":");if(h===-1)continue;let p=Re(this.pyEval(f.slice(0,h).trim(),e)),A=this.pyEval(f.slice(h+1).trim(),e);u.data.set(p,A)}return u}let i=t.match(/^not\s+(.+)$/);if(i)return!dn(this.pyEval(i[1],e));let o=[["or"],["and"],["in","not in","is not","is","==","!=","<=",">=","<",">"],["+","-"],["**"],["*","//","/","%"]];for(let l of o){let u=this.tryBinaryOp(t,l,e);if(u!==void 0)return u}if(t.startsWith("-")){let l=this.pyEval(t.slice(1),e);if(typeof l=="number")return-l}if(process.env.PY_DEBUG&&console.error("eval:",JSON.stringify(t)),t.endsWith("]")&&!t.startsWith("[")){let l=this.findMatchingBracket(t,"[");if(l!==-1){let u=this.pyEval(t.slice(0,l),e),f=t.slice(l+1,-1);return this.subscript(u,f,e)}}let a=t.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)$/);if(a){let[,l,u]=a,f=(u?.trim()?this.splitArgs(u):[]).map(h=>this.pyEval(h,e));return this.callBuiltin(l,f,e)}let c=this.findDotAccess(t);if(c){let{objExpr:l,attr:u,callPart:f}=c,h=this.pyEval(l,e);if(f!==void 0){let p=f.slice(1,-1),A=p.trim()?this.splitArgs(p).map(E=>this.pyEval(E,e)):[];return this.callMethod(h,u,A,e)}return this.getAttr(h,u,e)}if(/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)){if(e.has(t))return e.get(t);throw new St("NameError",`name '${t}' is not defined`)}if(/^[A-Za-z_][A-Za-z0-9_.]+$/.test(t)){let l=t.split("."),u=e.get(l[0])??(()=>{throw new St("NameError",`name '${l[0]}' is not defined`)})();for(let f of l.slice(1))u=this.getAttr(u,f,e);return u}return Y}findMatchingBracket(t,e){let r=e==="["?"]":e==="("?")":"}",s=0;for(let i=t.length-1;i>=0;i--)if(t[i]===r&&s++,t[i]===e&&(s--,s===0))return i;return-1}findDotAccess(t){let e=0,r=!1,s="";for(let i=t.length-1;i>0;i--){let o=t[i];if(r){o===s&&t[i-1]!=="\\"&&(r=!1);continue}if(o==='"'||o==="'"){r=!0,s=o;continue}if(")]}".includes(o)){e++;continue}if("([{".includes(o)){e--;continue}if(e!==0||o!==".")continue;let a=t.slice(0,i).trim(),l=t.slice(i+1).match(/^(\w+)(\([\s\S]*\))?$/);if(l&&!/^-?\d+$/.test(a))return{objExpr:a,attr:l[1],callPart:l[2]}}return null}tryBinaryOp(t,e,r){let s=0,i=!1,o="";for(let a=t.length-1;a>=0;a--){let c=t[a];if(i){c===o&&t[a-1]!=="\\"&&(i=!1);continue}if(c==='"'||c==="'"){i=!0,o=c;continue}if(")]}".includes(c)){s++;continue}if("([{".includes(c)){s--;continue}if(s===0){for(let l of e)if(t.slice(a,a+l.length)===l){if(l==="*"&&(t[a+1]==="*"||t[a-1]==="*"))continue;let u=t[a-1],f=t[a+l.length];if(/^[a-z]/.test(l)&&(u&&/\w/.test(u)||f&&/\w/.test(f)))continue;let p=t.slice(0,a).trim(),A=t.slice(a+l.length).trim();if(!p||!A)continue;return this.applyBinaryOp(l,p,A,r)}}}}applyBinaryOp(t,e,r,s){if(t==="and"){let a=this.pyEval(e,s);return dn(a)?this.pyEval(r,s):a}if(t==="or"){let a=this.pyEval(e,s);return dn(a)?a:this.pyEval(r,s)}let i=this.pyEval(e,s),o=this.pyEval(r,s);switch(t){case"+":return typeof i=="string"&&typeof o=="string"?i+o:Array.isArray(i)&&Array.isArray(o)?[...i,...o]:i+o;case"-":return i-o;case"*":if(typeof i=="string"&&typeof o=="number")return i.repeat(o);if(Array.isArray(i)&&typeof o=="number"){let a=[];for(let c=0;c<o;c++)a.push(...i);return a}return i*o;case"/":{if(o===0)throw new St("ZeroDivisionError","division by zero");return i/o}case"//":{if(o===0)throw new St("ZeroDivisionError","integer division or modulo by zero");return Math.floor(i/o)}case"%":{if(typeof i=="string")return this.pyStringFormat(i,Array.isArray(o)?o:[o]);if(o===0)throw new St("ZeroDivisionError","integer division or modulo by zero");return i%o}case"**":return i**o;case"==":return Mt(i)===Mt(o)||i===o;case"!=":return Mt(i)!==Mt(o)&&i!==o;case"<":return i<o;case"<=":return i<=o;case">":return i>o;case">=":return i>=o;case"in":return this.pyIn(o,i);case"not in":return!this.pyIn(o,i);case"is":return i===o||Hn(i)&&Hn(o);case"is not":return!(i===o||Hn(i)&&Hn(o))}return Y}pyIn(t,e){return typeof t=="string"?typeof e=="string"&&t.includes(e):Array.isArray(t)?t.some(r=>Mt(r)===Mt(e)):yt(t)?t.data.has(Re(e)):!1}subscript(t,e,r){if(e.includes(":")){let i=e.split(":").map(c=>c.trim()),o=i[0]?this.pyEval(i[0],r):void 0,a=i[1]?this.pyEval(i[1],r):void 0;return typeof t=="string"||Array.isArray(t)?t.slice(o,a):Y}let s=this.pyEval(e,r);if(Array.isArray(t)){let i=s;return i<0&&(i=t.length+i),t[i]??Y}if(typeof t=="string"){let i=s;return i<0&&(i=t.length+i),t[i]??Y}if(yt(t))return t.data.get(Re(s))??Y;throw new St("TypeError",`'${pr(t)}' is not subscriptable`)}getAttr(t,e,r){return yt(t)?t.data.has(e)?t.data.get(e):e==="path"&&t.path?t.path:Y:gi(t)?t.attrs.get(e)??Y:typeof t=="string"?{__class__:{__pytype__:"class",name:"str"}}[e]??Y:Y}callMethod(t,e,r,s){if(typeof t=="string")switch(e){case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();case"strip":return(r[0]?t.replace(new RegExp(`[${r[0]}]+`,"g"),""):t).trim();case"lstrip":return t.trimStart();case"rstrip":return t.trimEnd();case"split":return t.split(typeof r[0]=="string"?r[0]:/\s+/).filter((i,o)=>o>0||i!=="");case"splitlines":return t.split(`
|
|
992
|
+
`);case"join":return Ot(r[0]??[]).map(Re).join(t);case"replace":return t.replaceAll(Re(r[0]??""),Re(r[1]??""));case"startswith":return t.startsWith(Re(r[0]??""));case"endswith":return t.endsWith(Re(r[0]??""));case"find":return t.indexOf(Re(r[0]??""));case"index":{let i=t.indexOf(Re(r[0]??""));if(i===-1)throw new St("ValueError","substring not found");return i}case"count":return t.split(Re(r[0]??"")).length-1;case"format":return this.pyStringFormat(t,r);case"encode":return t;case"decode":return t;case"isdigit":return/^\d+$/.test(t);case"isalpha":return/^[a-zA-Z]+$/.test(t);case"isalnum":return/^[a-zA-Z0-9]+$/.test(t);case"isspace":return/^\s+$/.test(t);case"isupper":return t===t.toUpperCase()&&t!==t.toLowerCase();case"islower":return t===t.toLowerCase()&&t!==t.toUpperCase();case"center":{let i=r[0]??0,o=Re(r[1]??" ");return t.padStart(Math.floor((i+t.length)/2),o).padEnd(i,o)}case"ljust":return t.padEnd(r[0]??0,Re(r[1]??" "));case"rjust":return t.padStart(r[0]??0,Re(r[1]??" "));case"zfill":return t.padStart(r[0]??0,"0");case"title":return t.replace(/\b\w/g,i=>i.toUpperCase());case"capitalize":return t[0]?.toUpperCase()+t.slice(1).toLowerCase();case"swapcase":return[...t].map(i=>i===i.toUpperCase()?i.toLowerCase():i.toUpperCase()).join("")}if(Array.isArray(t))switch(e){case"append":return t.push(r[0]??Y),Y;case"extend":for(let i of Ot(r[0]??[]))t.push(i);return Y;case"insert":return t.splice(r[0]??0,0,r[1]??Y),Y;case"pop":{let i=r[0]!==void 0?r[0]:-1,o=i<0?t.length+i:i;return t.splice(o,1)[0]??Y}case"remove":{let i=t.findIndex(o=>Mt(o)===Mt(r[0]??Y));return i!==-1&&t.splice(i,1),Y}case"index":{let i=t.findIndex(o=>Mt(o)===Mt(r[0]??Y));if(i===-1)throw new St("ValueError","is not in list");return i}case"count":return t.filter(i=>Mt(i)===Mt(r[0]??Y)).length;case"sort":return t.sort((i,o)=>typeof i=="number"&&typeof o=="number"?i-o:Re(i).localeCompare(Re(o))),Y;case"reverse":return t.reverse(),Y;case"copy":return[...t];case"clear":return t.splice(0),Y}if(yt(t))switch(e){case"keys":return[...t.data.keys()];case"values":return[...t.data.values()];case"items":return[...t.data.entries()].map(([i,o])=>[i,o]);case"get":return t.data.get(Re(r[0]??""))??r[1]??Y;case"update":{if(yt(r[0]??Y))for(let[i,o]of r[0].data)t.data.set(i,o);return Y}case"pop":{let i=Re(r[0]??""),o=t.data.get(i)??r[1]??Y;return t.data.delete(i),o}case"clear":return t.data.clear(),Y;case"copy":return _t([...t.data.entries()]);case"setdefault":{let i=Re(r[0]??"");return t.data.has(i)||t.data.set(i,r[1]??Y),t.data.get(i)??Y}}if(yt(t)&&t.data.has("name")&&t.data.get("name")==="posix")switch(e){case"getcwd":return this.cwd;case"getenv":return typeof r[0]=="string"?process.env[r[0]]??r[1]??Y:Y;case"listdir":return[];case"path":return t}if(yt(t))switch(e){case"join":return r.map(Re).join("/").replace(/\/+/g,"/");case"exists":return!1;case"dirname":return Re(r[0]??"").split("/").slice(0,-1).join("/")||"/";case"basename":return Re(r[0]??"").split("/").pop()??"";case"abspath":return Re(r[0]??"");case"splitext":{let i=Re(r[0]??""),o=i.lastIndexOf(".");return o>0?[i.slice(0,o),i.slice(o)]:[i,""]}case"isfile":return!1;case"isdir":return!1}if(yt(t)&&t.data.has("version")&&t.data.get("version")===ys&&e==="exit")throw new Ei(r[0]??0);if(yt(t)){let i={sqrt:Math.sqrt,floor:Math.floor,ceil:Math.ceil,fabs:Math.abs,log:Math.log,log2:Math.log2,log10:Math.log10,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,pow:Math.pow,exp:Math.exp,hypot:Math.hypot};if(e in i){let o=i[e];return o(...r.map(a=>a))}if(e==="factorial"){let o=r[0]??0,a=1;for(;o>1;)a*=o--;return a}if(e==="gcd"){let o=Math.abs(r[0]??0),a=Math.abs(r[1]??0);for(;a;)[o,a]=[a,o%a];return o}}if(yt(t)){if(e==="dumps"){let i=yt(r[1]??Y)?r[1]:void 0,o=i?i.data.get("indent"):void 0;return JSON.stringify(this.pyToJs(r[0]??Y),null,o)}if(e==="loads")return this.jsToPy(JSON.parse(Re(r[0]??"")))}if(gi(t)){let i=t.attrs.get(e)??t.cls.methods.get(e)??Y;if(Rn(i)){let o=new Map(i.closure);return o.set("self",t),i.params.slice(1).forEach((a,c)=>o.set(a,r[c]??Y)),this.execBlock(i.body,o)}}throw new St("AttributeError",`'${pr(t)}' object has no attribute '${e}'`)}pyStringFormat(t,e){let r=0;return t.replace(/%([diouxXeEfFgGcrs%])/g,(s,i)=>{if(i==="%")return"%";let o=e[r++];switch(i){case"d":case"i":return String(Math.trunc(o));case"f":return o.toFixed(6);case"s":return Re(o??Y);case"r":return Mt(o??Y);default:return String(o)}})}pyToJs(t){return Hn(t)?null:yt(t)?Object.fromEntries([...t.data.entries()].map(([e,r])=>[e,this.pyToJs(r)])):Array.isArray(t)?t.map(e=>this.pyToJs(e)):t}jsToPy(t){return t==null?Y:typeof t=="boolean"||typeof t=="number"||typeof t=="string"?t:Array.isArray(t)?t.map(e=>this.jsToPy(e)):typeof t=="object"?_t(Object.entries(t).map(([e,r])=>[e,this.jsToPy(r)])):Y}callBuiltin(t,e,r){if(r.has(t)){let s=r.get(t)??Y;return Rn(s)?this.callFunc(s,e,r):Ro(s)?this.instantiate(s,e,r):s}switch(t){case"print":return this.output.push(e.map(Re).join(" ")+`
|
|
993
|
+
`.replace(/\\n/g,"")),Y;case"input":return this.output.push(Re(e[0]??"")),"";case"int":{if(e.length===0)return 0;let s=e[1]??10,i=parseInt(Re(e[0]??0),s);return Number.isNaN(i)?(()=>{throw new St("ValueError","invalid literal for int()")})():i}case"float":{if(e.length===0)return 0;let s=parseFloat(Re(e[0]??0));return Number.isNaN(s)?(()=>{throw new St("ValueError","could not convert to float")})():s}case"str":return e.length===0?"":Re(e[0]??Y);case"bool":return e.length===0?!1:dn(e[0]??Y);case"list":return e.length===0?[]:Ot(e[0]??[]);case"tuple":return e.length===0?[]:Ot(e[0]??[]);case"set":return e.length===0?[]:[...new Set(Ot(e[0]??[]).map(Mt))].map(s=>Ot(e[0]??[]).find(o=>Mt(o)===s)??Y);case"dict":return e.length===0?_t():yt(e[0]??Y)?e[0]:_t();case"bytes":return typeof e[0]=="string"?e[0]:Re(e[0]??"");case"bytearray":return e.length===0?"":Re(e[0]??"");case"type":return e.length===1?`<class '${pr(e[0]??Y)}'>`:Y;case"isinstance":return pr(e[0]??Y)===Re(e[1]??"");case"issubclass":return!1;case"callable":return Rn(e[0]??Y);case"hasattr":return yt(e[0]??Y)?e[0].data.has(Re(e[1]??"")):!1;case"getattr":return yt(e[0]??Y)?e[0].data.get(Re(e[1]??""))??e[2]??Y:e[2]??Y;case"setattr":return yt(e[0]??Y)&&e[0].data.set(Re(e[1]??""),e[2]??Y),Y;case"len":{let s=e[0]??Y;if(typeof s=="string"||Array.isArray(s))return s.length;if(yt(s))return s.data.size;if(Dr(s))return xu(s);throw new St("TypeError",`object of type '${pr(s)}' has no len()`)}case"range":return e.length===1?Bo(0,e[0]):e.length===2?Bo(e[0],e[1]):Bo(e[0],e[1],e[2]);case"enumerate":{let s=e[1]??0;return Ot(e[0]??[]).map((i,o)=>[o+s,i])}case"zip":{let s=e.map(Ot),i=Math.min(...s.map(o=>o.length));return Array.from({length:i},(o,a)=>s.map(c=>c[a]??Y))}case"map":{let s=e[0]??Y;return Ot(e[1]??[]).map(i=>Rn(s)?this.callFunc(s,[i],r):Y)}case"filter":{let s=e[0]??Y;return Ot(e[1]??[]).filter(i=>Rn(s)?dn(this.callFunc(s,[i],r)):dn(i))}case"reduce":{let s=e[0]??Y,i=Ot(e[1]??[]);if(i.length===0)return e[2]??Y;let o=e[2]!==void 0?e[2]:i[0];for(let a of e[2]!==void 0?i:i.slice(1))o=Rn(s)?this.callFunc(s,[o,a],r):Y;return o}case"sorted":{let s=[...Ot(e[0]??[])],i=e[1]??Y,o=yt(i)?i.data.get("key")??Y:i;return s.sort((a,c)=>{let l=Rn(o)?this.callFunc(o,[a],r):a,u=Rn(o)?this.callFunc(o,[c],r):c;return typeof l=="number"&&typeof u=="number"?l-u:Re(l).localeCompare(Re(u))}),s}case"reversed":return[...Ot(e[0]??[])].reverse();case"any":return Ot(e[0]??[]).some(dn);case"all":return Ot(e[0]??[]).every(dn);case"sum":return Ot(e[0]??[]).reduce((s,i)=>s+i,e[1]??0);case"max":return(e.length===1?Ot(e[0]??[]):e).reduce((i,o)=>i>=o?i:o);case"min":return(e.length===1?Ot(e[0]??[]):e).reduce((i,o)=>i<=o?i:o);case"abs":return Math.abs(e[0]??0);case"round":return e[1]!==void 0?parseFloat(e[0].toFixed(e[1])):Math.round(e[0]??0);case"divmod":{let s=e[0],i=e[1];return[Math.floor(s/i),s%i]}case"pow":return e[0]**e[1];case"hex":return`0x${e[0].toString(16)}`;case"oct":return`0o${e[0].toString(8)}`;case"bin":return`0b${e[0].toString(2)}`;case"ord":return Re(e[0]??"").charCodeAt(0);case"chr":return String.fromCharCode(e[0]??0);case"id":return Math.floor(Math.random()*4294967295);case"hash":return typeof e[0]=="number"?e[0]:Re(e[0]??"").split("").reduce((s,i)=>s*31+i.charCodeAt(0)|0,0);case"open":throw new St("PermissionError","open() not available in virtual runtime");case"repr":return Mt(e[0]??Y);case"iter":return e[0]??Y;case"next":return Array.isArray(e[0])&&e[0].length>0?e[0].shift():e[1]??(()=>{throw new St("StopIteration","")})();case"vars":return _t([...r.entries()].map(([s,i])=>[s,i]));case"globals":return _t([...r.entries()].map(([s,i])=>[s,i]));case"locals":return _t([...r.entries()].map(([s,i])=>[s,i]));case"dir":{if(e.length===0)return[...r.keys()];let s=e[0]??Y;return typeof s=="string"?["upper","lower","strip","split","join","replace","find","format","encode","startswith","endswith","count","isdigit","isalpha","title","capitalize"]:Array.isArray(s)?["append","extend","insert","pop","remove","index","count","sort","reverse","copy","clear"]:yt(s)?["keys","values","items","get","update","pop","clear","copy","setdefault"]:[]}case"Exception":case"ValueError":case"TypeError":case"KeyError":case"IndexError":case"AttributeError":case"NameError":case"RuntimeError":case"StopIteration":case"NotImplementedError":case"OSError":case"IOError":throw new St(t,Re(e[0]??""));case"exec":return this.execScript(Re(e[0]??""),r),Y;case"eval":return this.pyEval(Re(e[0]??""),r);default:throw new St("NameError",`name '${t}' is not defined`)}}callFunc(t,e,r){let s=new Map(t.closure);t.params.forEach((i,o)=>{if(i.startsWith("*")){s.set(i.slice(1),e.slice(o));return}s.set(i,e[o]??Y)});try{return this.execBlock(t.body,s)}catch(i){if(i instanceof Mr)return i.value;throw i}}instantiate(t,e,r){let s={__pytype__:"instance",cls:t,attrs:new Map};return t.methods.get("__init__")&&this.callMethod(s,"__init__",e,r),s}execScript(t,e){let r=t.split(`
|
|
994
|
+
`);this.execLines(r,0,e)}execLines(t,e,r){let s=e;for(;s<t.length;){let i=t[s];if(!i.trim()||i.trim().startsWith("#")){s++;continue}s=this.execStatement(t,s,r)}return s}execBlock(t,e){try{this.execLines(t,0,e)}catch(r){if(r instanceof Mr)return r.value;throw r}return Y}getIndent(t){let e=0;for(let r of t)if(r===" ")e++;else if(r===" ")e+=4;else break;return e}collectBlock(t,e,r){let s=[];for(let i=e;i<t.length;i++){let o=t[i];if(!o.trim()){s.push("");continue}if(this.getIndent(o)<=r)break;s.push(o.slice(r+4))}return s}execStatement(t,e,r){let s=t[e],i=s.trim(),o=this.getIndent(s);if(i==="pass")return e+1;if(i==="break")throw new Ai;if(i==="continue")throw new yi;let a=i.match(/^return(?:\s+(.+))?$/);if(a)throw new Mr(a[1]?this.pyEval(a[1],r):Y);let c=i.match(/^raise(?:\s+(.+))?$/);if(c){if(c[1]){let v=this.pyEval(c[1],r);throw new St(typeof v=="string"?v:pr(v),Re(v))}throw new St("RuntimeError","")}let l=i.match(/^assert\s+(.+?)(?:,\s*(.+))?$/);if(l){if(!dn(this.pyEval(l[1],r)))throw new St("AssertionError",l[2]?Re(this.pyEval(l[2],r)):"");return e+1}let u=i.match(/^del\s+(.+)$/);if(u)return r.delete(u[1].trim()),e+1;let f=i.match(/^import\s+(\w+)(?:\s+as\s+(\w+))?$/);if(f){let[,v,_]=f,w=bu[v];if(w){let k=w(this.cwd);this.modules.set(v,k),r.set(_??v,k)}return e+1}let h=i.match(/^from\s+(\w+)\s+import\s+(.+)$/);if(h){let[,v,_]=h,w=bu[v];if(w){let k=w(this.cwd);if(_?.trim()==="*")for(let[N,R]of k.data)r.set(N,R);else for(let N of _.split(",").map(R=>R.trim()))r.set(N,k.data.get(N)??Y)}return e+1}let p=i.match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(p){let[,v,_]=p,w=_.split(",").map(R=>R.trim()).filter(Boolean),k=this.collectBlock(t,e+1,o),N={__pytype__:"func",name:v,params:w,body:k,closure:new Map(r)};return r.set(v,N),e+1+k.length}let A=i.match(/^class\s+(\w+)(?:\(([^)]*)\))?\s*:$/);if(A){let[,v,_]=A,w=_?_.split(",").map(ie=>ie.trim()):[],k=this.collectBlock(t,e+1,o),N={__pytype__:"class",name:v,methods:new Map,bases:w},R=0;for(;R<k.length;){let j=k[R].trim().match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(j){let[,X,re]=j,fe=re.split(",").map(B=>B.trim()).filter(Boolean),H=this.collectBlock(k,R+1,0);N.methods.set(X,{__pytype__:"func",name:X,params:fe,body:H,closure:new Map(r)}),R+=1+H.length}else R++}return r.set(v,N),e+1+k.length}if(i.startsWith("if ")&&i.endsWith(":")){let v=i.slice(3,-1).trim(),_=this.collectBlock(t,e+1,o),w=_.length+1;if(dn(this.pyEval(v,r))){this.execBlock(_,new Map(r).also?.(R=>{for(let[ie,j]of r)R.set(ie,j)})??r),this.runBlockInScope(_,r);let N=e+1+_.length;for(;N<t.length;){let R=t[N].trim();if(this.getIndent(t[N])<o||!R.startsWith("elif")&&!R.startsWith("else"))break;let ie=this.collectBlock(t,N+1,o);N+=1+ie.length}return N}let k=e+1+_.length;for(;k<t.length;){let N=t[k],R=N.trim();if(this.getIndent(N)!==o)break;let ie=R.match(/^elif\s+(.+):$/);if(ie){let j=this.collectBlock(t,k+1,o);if(dn(this.pyEval(ie[1],r))){for(this.runBlockInScope(j,r),k+=1+j.length;k<t.length;){let X=t[k].trim();if(this.getIndent(t[k])!==o||!X.startsWith("elif")&&!X.startsWith("else"))break;let re=this.collectBlock(t,k+1,o);k+=1+re.length}return k}k+=1+j.length;continue}if(R==="else:"){let j=this.collectBlock(t,k+1,o);return this.runBlockInScope(j,r),k+1+j.length}break}return k}let E=i.match(/^for\s+(.+?)\s+in\s+(.+?)\s*:$/);if(E){let[,v,_]=E,w=Ot(this.pyEval(_.trim(),r)),k=this.collectBlock(t,e+1,o),N=[],R=e+1+k.length;R<t.length&&t[R]?.trim()==="else:"&&(N=this.collectBlock(t,R+1,o),R+=1+N.length);let ie=!1;for(let j of w){if(v.includes(",")){let X=v.split(",").map(fe=>fe.trim()),re=Array.isArray(j)?j:[j];X.forEach((fe,H)=>r.set(fe,re[H]??Y))}else r.set(v.trim(),j);try{this.runBlockInScope(k,r)}catch(X){if(X instanceof Ai){ie=!0;break}if(X instanceof yi)continue;throw X}}return!ie&&N.length&&this.runBlockInScope(N,r),R}let b=i.match(/^while\s+(.+?)\s*:$/);if(b){let v=b[1],_=this.collectBlock(t,e+1,o),w=0;for(;dn(this.pyEval(v,r))&&w++<1e5;)try{this.runBlockInScope(_,r)}catch(k){if(k instanceof Ai)break;if(k instanceof yi)continue;throw k}return e+1+_.length}if(i==="try:"){let v=this.collectBlock(t,e+1,o),_=e+1+v.length,w=[],k=[],N=[];for(;_<t.length;){let ie=t[_],j=ie.trim();if(this.getIndent(ie)!==o)break;if(j.startsWith("except")){let X=j.match(/^except(?:\s+(\w+)(?:\s+as\s+(\w+))?)?\s*:$/),re=X?.[1]??null,fe=X?.[2],H=this.collectBlock(t,_+1,o);w.push({exc:re,body:H}),fe&&r.set(fe,""),_+=1+H.length}else if(j==="else:")N=this.collectBlock(t,_+1,o),_+=1+N.length;else if(j==="finally:")k=this.collectBlock(t,_+1,o),_+=1+k.length;else break}let R=null;try{this.runBlockInScope(v,r),N.length&&this.runBlockInScope(N,r)}catch(ie){if(ie instanceof St){R=ie;let j=!1;for(let X of w)if(X.exc===null||X.exc===ie.type||X.exc==="Exception"){this.runBlockInScope(X.body,r),j=!0;break}if(!j)throw ie}else throw ie}finally{k.length&&this.runBlockInScope(k,r)}return _}let x=i.match(/^with\s+(.+?)\s+as\s+(\w+)\s*:$/);if(x){let v=this.collectBlock(t,e+1,o);return r.set(x[2],Y),this.runBlockInScope(v,r),e+1+v.length}let P=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(\+=|-=|\*=|\/\/=|\/=|%=|\*\*=|&=|\|=)\s*(.+)$/);if(P){let[,v,_,w]=P,k=r.get(v)??0,N=this.pyEval(w,r),R;switch(_){case"+=":R=typeof k=="string"?k+Re(N):k+N;break;case"-=":R=k-N;break;case"*=":R=k*N;break;case"/=":R=k/N;break;case"//=":R=Math.floor(k/N);break;case"%=":R=k%N;break;case"**=":R=k**N;break;default:R=N}return r.set(v,R),e+1}let q=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\[(.+)\]\s*=\s*(.+)$/);if(q){let[,v,_,w]=q,k=r.get(v)??Y,N=this.pyEval(w,r)??Y,R=this.pyEval(_,r)??Y;return Array.isArray(k)?k[R]=N:yt(k)&&k.data.set(Re(R),N),e+1}let C=i.match(/^([A-Za-z_][A-Za-z0-9_.]+)\s*=\s*(.+)$/);if(C){let v=C[1].lastIndexOf(".");if(v!==-1){let _=C[1].slice(0,v),w=C[1].slice(v+1),k=this.pyEval(C[2],r),N=this.pyEval(_,r);return yt(N)?N.data.set(w,k):gi(N)&&N.attrs.set(w,k),e+1}}let $=i.match(/^([A-Za-z_][A-Za-z0-9_,\s]*),\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.+)$/);if($){let v=this.pyEval($[3],r),_=i.split("=")[0].split(",").map(k=>k.trim()),w=Ot(v);return _.forEach((k,N)=>r.set(k,w[N]??Y)),e+1}let F=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?::[^=]+)?\s*=\s*(.+)$/);if(F){let[,v,_]=F;return r.set(v,this.pyEval(_,r)),e+1}try{this.pyEval(i,r)}catch(v){if(v instanceof St||v instanceof Ei)throw v}return e+1}runBlockInScope(t,e){this.execLines(t,0,e)}run(t){let e=vm(this.cwd);try{this.execScript(t,e)}catch(r){return r instanceof Ei?{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:r.code}:r instanceof St?(this.stderr.push(r.toString()),{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:1}):r instanceof Mr?{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:0}:(this.stderr.push(`RuntimeError: ${r}`),{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:1})}return{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:0}}},wu={name:"python3",aliases:["python"],description:"Python 3 interpreter (virtual)",category:"system",params:["[--version] [-c <code>] [-V] [file]"],run:({args:n,shell:t,cwd:e})=>{if(!t.packageManager.isInstalled("python3"))return{stderr:`bash: python3: command not found
|
|
995
995
|
Hint: install it with: apt install python3
|
|
996
996
|
`,exitCode:127};if(ae(n,["--version","-V"]))return{stdout:`${Cm}
|
|
997
997
|
`,exitCode:0};if(ae(n,["--version-full"]))return{stdout:`${ys}
|
|
@@ -1042,7 +1042,7 @@ Usage: wget [OPTION]... [URL]...`,exitCode:1};let c=s.get("-O")??s.get("--output
|
|
|
1042
1042
|
${h} 100%[==================>] ${E.length} B`),{stderr:p.join(`
|
|
1043
1043
|
`)||void 0,exitCode:0}):{stdout:E,exitCode:0}}};var nf={name:"which",description:"Locate a command in PATH",category:"shell",params:["<command...>"],run:({args:n,shell:t,env:e})=>{if(n.length===0)return{stderr:"which: missing argument",exitCode:1};let r=(e?.vars?.PATH??"/usr/local/bin:/usr/bin:/bin").split(":"),s=[],i=!1;for(let o of n){let a=!1;for(let c of r){let l=`${c}/${o}`;if(t.vfs.exists(l)&&t.vfs.stat(l).type==="file"){s.push(l),a=!0;break}}a||(i=!0)}return s.length===0?{exitCode:1}:{stdout:s.join(`
|
|
1044
1044
|
`),exitCode:i?1:0}}};function Ss(n){let t=n.toLocaleString("en-US",{weekday:"short"}),e=n.toLocaleString("en-US",{month:"short"}),r=n.getDate().toString().padStart(2,"0"),s=n.getHours().toString().padStart(2,"0"),i=n.getMinutes().toString().padStart(2,"0"),o=n.getSeconds().toString().padStart(2,"0"),a=n.getFullYear();return`${t} ${e} ${r} ${s}:${i}:${o} ${a}`}var rf={name:"who",description:"Show active sessions",category:"system",params:[],run:({shell:n})=>({stdout:n.users.listActiveSessions().map(e=>{let r=new Date(e.startedAt),s=Number.isNaN(r.getTime())?e.startedAt:Ss(r);return`${e.username} ${e.tty} ${s} (${e.remoteAddress||"unknown"})`}).join(`
|
|
1045
|
-
`),exitCode:0})};var sf={name:"whoami",description:"Print current user",category:"system",params:[],run:({authUser:n})=>({stdout:n,exitCode:0})};var of={name:"xargs",description:"Build and execute command lines from stdin",category:"text",params:["[command] [args...]"],run:async({authUser:n,hostname:t,mode:e,cwd:r,args:s,stdin:i,shell:o,env:a})=>{let c=s[0]??"echo",l=s.slice(1),u=(i??"").trim().split(/\s+/).filter(Boolean);if(u.length===0)return{exitCode:0};let f=[c,...l,...u].join(" ");return wt(f,n,t,e,r,o,void 0,a)}};var Dm=[_u,ul,jl,Ku,ol,Wu,Cu,eu,hl,tu,Vl,Kl,fl,zl,Gl,vl,Bl,ku,il,Mu,Xu,ef,Ol,$u,ml,Vu,Hu,of,Sl,Fu,Pl,Tl,sl,sf,rf,Hl,Wl,Rl,ju,Su,ql,El,xl,gl,Ou,yu,wl,Il,kl,vu,Ju,Bu,dl,Cl,ru,Ql,pl,tf,jc,Au,yl,Uu,Lu,du,nl,rl,_l,bl,nf,Yu,Zl,Jc,Zc,Qu,Du,Fl,Eu,Iu,Al,Ru,Pu,Tu,zu,Gu,mu,gu,pu,wu,Zu,Nl,Xl],af=[],Si=new Map,_s=null,Lm=$l(()=>Mo().map(n=>n.name));function Oo(){Si.clear();for(let n of Mo()){Si.set(n.name,n);for(let t of n.aliases??[])Si.set(t,n)}_s=Array.from(Si.keys()).sort()}function Mo(){return[...Dm,...af,Lm]}function Do(n){let t={...n,name:n.name.trim().toLowerCase(),aliases:n.aliases?.map(r=>r.trim().toLowerCase())};if([t.name,...t.aliases??[]].some(r=>r.length===0||/\s/.test(r)))throw new Error("Command names must be non-empty and contain no spaces");af.push(t),Oo()}function Lo(n,t,e){return{name:n,params:t,run:e}}function Uo(){return _s||Oo(),_s}function Co(){return Mo()}function bn(n){return _s||Oo(),Si.get(n.toLowerCase())}var mx=gn("SshClient");var Ap=require("node:events"),yp=Vt(vc(),1);var lp=require("node:events");var Mn=Vt(require("node:os"),1);var Qh=require("node:events"),it=Vt(require("node:fs"),1),rn=Vt(require("node:path"),1),br=require("node:zlib");var Pc=Buffer.from([86,70,83,33]),Ry=1,Nc=1,Dh=2,Bc=class{chunks=[];write(t){this.chunks.push(t)}writeUint8(t){let e=Buffer.allocUnsafe(1);e.writeUInt8(t,0),this.chunks.push(e)}writeUint16(t){let e=Buffer.allocUnsafe(2);e.writeUInt16LE(t,0),this.chunks.push(e)}writeUint32(t){let e=Buffer.allocUnsafe(4);e.writeUInt32LE(t,0),this.chunks.push(e)}writeFloat64(t){let e=Buffer.allocUnsafe(8);e.writeDoubleBE(t,0),this.chunks.push(e)}writeString(t){let e=Buffer.from(t,"utf8");this.writeUint16(e.length),this.chunks.push(e)}writeBytes(t){this.writeUint32(t.length),this.chunks.push(t)}toBuffer(){return Buffer.concat(this.chunks)}};function Lh(n,t){if(t.type==="file"){let e=t;n.writeUint8(Nc),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt),n.writeFloat64(e.updatedAt),n.writeUint8(e.compressed?1:0),n.writeBytes(e.content)}else if(t.type==="stub"){let e=t;n.writeUint8(Nc),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt),n.writeFloat64(e.updatedAt),n.writeUint8(0),n.writeBytes(Buffer.from(e.stubContent,"utf8"))}else{let e=t;n.writeUint8(Dh),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt),n.writeFloat64(e.updatedAt);let r=Object.values(e.children);n.writeUint32(r.length);for(let s of r)Lh(n,s)}}function Tc(n){let t=new Bc;return t.write(Pc),t.writeUint8(Ry),Lh(t,n),t.toBuffer()}var Rc=class{constructor(t){this.buf=t}buf;pos=0;readUint8(){return this.buf.readUInt8(this.pos++)}readUint16(){let t=this.buf.readUInt16LE(this.pos);return this.pos+=2,t}readUint32(){let t=this.buf.readUInt32LE(this.pos);return this.pos+=4,t}readFloat64(){let t=this.buf.readDoubleBE(this.pos);return this.pos+=8,t}readString(){let t=this.readUint16(),e=this.buf.toString("utf8",this.pos,this.pos+t);return this.pos+=t,e}readBytes(){let t=this.readUint32(),e=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,e}remaining(){return this.buf.length-this.pos}};function Uh(n){let t=n.readUint8(),e=n.readString(),r=n.readUint32(),s=n.readFloat64(),i=n.readFloat64();if(t===Nc){let o=n.readUint8()===1,a=n.readBytes();return{type:"file",name:e,mode:r,createdAt:s,updatedAt:i,compressed:o,content:a}}if(t===Dh){let o=n.readUint32(),a=Object.create(null);for(let c=0;c<o;c++){let l=Uh(n);a[l.name]=l}return{type:"directory",name:e,mode:r,createdAt:s,updatedAt:i,children:a,_childCount:o}}throw new Error(`[VFS binary] Unknown node type: 0x${t.toString(16)}`)}function ur(n){if(n.length<5)throw new Error("[VFS binary] Buffer too short");if(!n.slice(0,4).equals(Pc))throw new Error("[VFS binary] Invalid magic \u2014 not a VFS binary snapshot");let e=new Rc(n);for(let s=0;s<5;s++)e.readUint8();let r=Uh(e);if(r.type!=="directory")throw new Error("[VFS binary] Root node must be a directory");return r}function $h(n){return n.length>=4&&n.slice(0,4).equals(Pc)}var Ut=Vt(require("node:fs"),1),ft={WRITE:1,MKDIR:2,REMOVE:3,CHMOD:4,MOVE:5,SYMLINK:6},ji="utf8";function Py(n,t,e){let r=Buffer.from(e,ji);return n.writeUInt16LE(r.length,t),r.copy(n,t+2),2+r.length}function Ty(n){let t=Buffer.from(n.path,ji),e=0;n.op===ft.WRITE?e=4+(n.content?.length??0)+4:n.op===ft.MKDIR?e=4:n.op===ft.REMOVE?e=0:n.op===ft.CHMOD?e=4:(n.op===ft.MOVE||n.op===ft.SYMLINK)&&(e=2+Buffer.byteLength(n.dest??"",ji));let r=3+t.length+e,s=Buffer.allocUnsafe(r),i=0;if(s.writeUInt8(n.op,i++),s.writeUInt16LE(t.length,i),i+=2,t.copy(s,i),i+=t.length,n.op===ft.WRITE){let o=n.content??Buffer.alloc(0);s.writeUInt32LE(o.length,i),i+=4,o.copy(s,i),i+=o.length,s.writeUInt32LE(n.mode??420,i),i+=4}else n.op===ft.MKDIR?(s.writeUInt32LE(n.mode??493,i),i+=4):n.op===ft.CHMOD?(s.writeUInt32LE(n.mode??420,i),i+=4):(n.op===ft.MOVE||n.op===ft.SYMLINK)&&(i+=Py(s,i,n.dest??""));return s}function Oy(n){let t=[],e=0;try{for(;e<n.length&&!(e+3>n.length);){let r=n.readUInt8(e++),s=n.readUInt16LE(e);if(e+=2,e+s>n.length)break;let i=n.subarray(e,e+s).toString(ji);if(e+=s,r===ft.WRITE){if(e+4>n.length)break;let o=n.readUInt32LE(e);if(e+=4,e+o+4>n.length)break;let a=Buffer.from(n.subarray(e,e+o));e+=o;let c=n.readUInt32LE(e);e+=4,t.push({op:r,path:i,content:a,mode:c})}else if(r===ft.MKDIR){if(e+4>n.length)break;let o=n.readUInt32LE(e);e+=4,t.push({op:r,path:i,mode:o})}else if(r===ft.REMOVE)t.push({op:r,path:i});else if(r===ft.CHMOD){if(e+4>n.length)break;let o=n.readUInt32LE(e);e+=4,t.push({op:r,path:i,mode:o})}else if(r===ft.MOVE||r===ft.SYMLINK){if(e+2>n.length)break;let o=n.readUInt16LE(e);if(e+=2,e+o>n.length)break;let a=n.subarray(e,e+o).toString(ji);e+=o,t.push({op:r,path:i,dest:a})}else break}}catch{}return t}function Fh(n,t){let e=Ty(t);if(console.log(`[Journal] Appending entry: op=${t.op} path=${t.path} ${t.content?`content_len=${t.content.length}`:""}${t.mode?` mode=${t.mode.toString(8)}`:""}${t.dest?` dest=${t.dest}`:""}`),Ut.existsSync(n)){let r=Ut.openSync(n,Ut.constants.O_WRONLY|Ut.constants.O_CREAT|Ut.constants.O_APPEND);try{Ut.writeSync(r,e)}finally{Ut.closeSync(r)}}else Ut.writeFileSync(n,e)}function Oc(n){if(!Ut.existsSync(n))return[];let t=Ut.readFileSync(n);return t.length===0?[]:Oy(t)}function Hh(n){Ut.existsSync(n)&&Ut.unlinkSync(n)}var Ao=Vt(require("node:path"),1);function dt(n){if(!n||n.trim()==="")return"/";let t=Ao.posix.normalize(n.startsWith("/")?n:`/${n}`);return t===""?"/":t}function My(n){return n.split("/").filter(Boolean)}function zt(n,t){let e=dt(t);if(e==="/")return n;let r=My(e),s=n;for(let i of r){if(s.type!=="directory")throw new Error(`Path '${e}' does not exist.`);let o=s.children[i];if(!o)throw new Error(`Path '${e}' does not exist.`);s=o}return s}function _r(n,t,e,r){let s=dt(t);if(s==="/")throw new Error("Root path has no parent directory.");let i=Ao.posix.dirname(s),o=Ao.posix.basename(s);if(!o)throw new Error(`Invalid path '${t}'.`);e&&r(i);let a=zt(n,i);if(a.type!=="directory")throw new Error(`Parent path '${i}' is not a directory.`);return{parent:a,name:o}}var Mc=class n extends Qh.EventEmitter{root;mode;snapshotFile;journalFile;evictionThreshold;flushAfterNWrites;_writesSinceFlush=0;_flushTimer=null;_dirty=!1;mounts=new Map;static isBrowser=typeof process>"u"||typeof process.versions?.node>"u";constructor(t={}){if(super(),this.mode=t.mode??"memory",this.mode==="fs"){if(!t.snapshotPath)throw new Error('VirtualFileSystem: "snapshotPath" is required when mode is "fs".');this.snapshotFile=rn.resolve(t.snapshotPath,"vfs-snapshot.vfsb"),this.journalFile=rn.resolve(t.snapshotPath,"vfs-journal.bin"),this.evictionThreshold=t.evictionThresholdBytes??64*1024,this.flushAfterNWrites=t.flushAfterNWrites??500;let e=t.flushIntervalMs??1e3;e>0&&(this._flushTimer=setInterval(()=>{this._dirty&&this._autoFlush()},e),typeof this._flushTimer=="object"&&this._flushTimer!==null&&"unref"in this._flushTimer&&this._flushTimer.unref())}else this.snapshotFile=null,this.journalFile=null,this.evictionThreshold=0,this.flushAfterNWrites=0;this.root=this.makeDir("",493)}makeDir(t,e){let r=Date.now();return{type:"directory",name:t,mode:e,createdAt:r,updatedAt:r,children:Object.create(null),_childCount:0}}makeFile(t,e,r,s){let i=Date.now();return{type:"file",name:t,content:e,mode:r,compressed:s,createdAt:i,updatedAt:i}}makeStub(t,e,r){let s=Date.now();return{type:"stub",name:t,stubContent:e,mode:r,createdAt:s,updatedAt:s}}writeStub(t,e,r=420){let s=dt(t),{parent:i,name:o}=_r(this.root,s,!0,c=>this.mkdirRecursive(c,493)),a=i.children[o];if(a?.type==="directory")throw new Error(`Cannot write stub '${s}': path is a directory.`);a?.type!=="file"&&(a||i._childCount++,i.children[o]=this.makeStub(o,e,r))}mkdirRecursive(t,e){let r=dt(t);if(r==="/")return;let s=r.split("/").filter(Boolean),i=this.root,o="";for(let a of s){o+=`/${a}`;let c=i.children[a];if(!c)c=this.makeDir(a,e),i.children[a]=c,i._childCount++,this.emit("dir:create",{path:o,mode:e}),this._journal({op:ft.MKDIR,path:o,mode:e});else if(c.type!=="directory")throw new Error(`Cannot create directory '${o}': path is a file.`);i=c}}async restoreMirror(){if(!(this.mode!=="fs"||!this.snapshotFile)){if(!it.existsSync(this.snapshotFile)){if(this.journalFile){let t=Oc(this.journalFile);t.length>0&&this._replayJournal(t)}return}try{let t=it.readFileSync(this.snapshotFile);if($h(t))this.root=ur(t);else{let e=JSON.parse(t.toString("utf8"));this.root=this.deserializeDir(e.root,""),console.info("[VirtualFileSystem] Migrating legacy JSON snapshot to binary format.")}if(this.emit("snapshot:restore",{path:this.snapshotFile}),this.journalFile){let e=Oc(this.journalFile);e.length>0&&this._replayJournal(e)}}catch(t){console.warn(`[VirtualFileSystem] Could not restore snapshot from ${this.snapshotFile}:`,t instanceof Error?t.message:String(t))}}}async flushMirror(){if(this.mode!=="fs"||!this.snapshotFile){this.emit("mirror:flush");return}let t=rn.dirname(this.snapshotFile);it.mkdirSync(t,{recursive:!0});let e=this.root,r=Tc(e);it.writeFileSync(this.snapshotFile,r),this.journalFile&&Hh(this.journalFile),this._dirty=!1,this._writesSinceFlush=0,this.emit("mirror:flush",{path:this.snapshotFile}),this.evictLargeFiles()}getMode(){return this.mode}getSnapshotPath(){return this.snapshotFile}async _autoFlush(){this._dirty&&await this.flushMirror()}_markDirty(){this._dirty=!0,this.flushAfterNWrites>0&&(this._writesSinceFlush++,this._writesSinceFlush>=this.flushAfterNWrites&&(this._writesSinceFlush=0,this._autoFlush()))}async stopAutoFlush(){this._flushTimer!==null&&(clearInterval(this._flushTimer),this._flushTimer=null),this._dirty&&await this.flushMirror()}importRootTree(t){let e=this._replayMode;this._replayMode=!0;try{this.root=t}finally{this._replayMode=e}}mergeRootTree(t){let e=this._replayMode;this._replayMode=!0;try{this._mergeDir(this.root,t)}finally{this._replayMode=e}}_mergeDir(t,e){for(let[r,s]of Object.entries(e.children)){let i=t.children[r];s.type==="directory"?i?i.type==="directory"&&this._mergeDir(i,s):(t.children[r]=s,t._childCount++):i||(t.children[r]=s,t._childCount++)}}encodeBinary(){return Tc(this.root)}releaseTree(){this.root=this.makeDir("",493)}_replayMode=!1;_journal(t){this.journalFile&&!this._replayMode&&(Fh(this.journalFile,t),this._markDirty())}_replayJournal(t){this._replayMode=!0;try{for(let e of t)try{e.op===ft.WRITE?this.writeFile(e.path,e.content??Buffer.alloc(0),{mode:e.mode}):e.op===ft.MKDIR?this.mkdir(e.path,e.mode):e.op===ft.REMOVE?this.exists(e.path)&&this.remove(e.path,{recursive:!0}):e.op===ft.CHMOD?this.exists(e.path)&&this.chmod(e.path,e.mode??420):e.op===ft.MOVE?this.exists(e.path)&&e.dest&&this.move(e.path,e.dest):e.op===ft.SYMLINK&&e.dest&&this.symlink(e.dest,e.path)}catch{}}finally{this._replayMode=!1}}evictLargeFiles(){!this.snapshotFile||this.evictionThreshold===0||it.existsSync(this.snapshotFile)&&this._evictDir(this.root)}_evictDir(t){for(let e of Object.values(t.children))if(e.type==="directory")this._evictDir(e);else if(e.type==="file"&&!e.evicted){let r=e.compressed?e.size??e.content.length*2:e.content.length;r>this.evictionThreshold&&(e.size=r,e.content=Buffer.alloc(0),e.evicted=!0)}}_reloadEvicted(t,e){if(!(!t.evicted||!this.snapshotFile)&&it.existsSync(this.snapshotFile))try{let r=it.readFileSync(this.snapshotFile),s=ur(r),i=e.split("/").filter(Boolean),o=s;for(let a of i){if(o.type!=="directory")return;let c=o.children[a];if(!c)return;o=c}o.type==="file"&&(t.content=o.content,t.compressed=o.compressed,t.evicted=void 0)}catch{}}mount(t,e,{readOnly:r=!0}={}){if(n.isBrowser)return;let s=dt(t),i=rn.resolve(e);if(!it.existsSync(i))throw new Error(`VirtualFileSystem.mount: host path does not exist: "${i}"`);if(!it.statSync(i).isDirectory())throw new Error(`VirtualFileSystem.mount: host path is not a directory: "${i}"`);this.mkdir(s),this.mounts.set(s,{hostPath:i,readOnly:r}),this.emit("mount",{vPath:s,hostPath:i,readOnly:r})}unmount(t){let e=dt(t);this.mounts.delete(e)&&this.emit("unmount",{vPath:e})}getMounts(){return[...this.mounts.entries()].map(([t,e])=>({vPath:t,...e}))}resolveMount(t){let e=dt(t),r=[...this.mounts.entries()].sort(([s],[i])=>i.length-s.length);for(let[s,i]of r)if(e===s||e.startsWith(`${s}/`)){let o=e.slice(s.length).replace(/^\//,""),a=o?rn.join(i.hostPath,o):i.hostPath;return{hostPath:i.hostPath,readOnly:i.readOnly,relPath:o,fullHostPath:a}}return null}mkdir(t,e=493){let r=dt(t),s=(()=>{try{return zt(this.root,r)}catch{return null}})();if(s&&s.type!=="directory")throw new Error(`Cannot create directory '${r}': path is a file.`);this.mkdirRecursive(r,e)}writeFile(t,e,r={}){let s=this.resolveMount(t);if(s){if(s.readOnly)throw new Error(`EROFS: read-only file system, open '${s.fullHostPath}'`);let p=rn.dirname(s.fullHostPath);it.existsSync(p)||it.mkdirSync(p,{recursive:!0}),it.writeFileSync(s.fullHostPath,Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"));return}let i=dt(t),{parent:o,name:a}=_r(this.root,i,!0,p=>this.mkdirRecursive(p,493)),c=o.children[a];if(c?.type==="directory")throw new Error(`Cannot write file '${i}': path is a directory.`);let l=Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"),u=r.compress??!1,f=u?(0,br.gzipSync)(l):l,h=r.mode??420;if(c&&c.type==="file"){let p=c;p.content=f,p.compressed=u,p.mode=h,p.updatedAt=Date.now()}else c||o._childCount++,o.children[a]=this.makeFile(a,f,h,u);this.emit("file:write",{path:i,size:f.length}),this._journal({op:ft.WRITE,path:i,content:l,mode:h})}readFile(t){let e=this.resolveMount(t);if(e){if(!it.existsSync(e.fullHostPath))throw new Error(`ENOENT: no such file or directory, open '${e.fullHostPath}'`);return it.readFileSync(e.fullHostPath,"utf8")}let r=dt(t),s=zt(this.root,r);if(s.type==="stub")return this.emit("file:read",{path:r,size:s.stubContent.length}),s.stubContent;if(s.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let i=s;i.evicted&&this._reloadEvicted(i,r);let o=i.compressed?(0,br.gunzipSync)(i.content):i.content;return this.emit("file:read",{path:r,size:o.length}),o.toString("utf8")}readFileRaw(t){let e=this.resolveMount(t);if(e){if(!it.existsSync(e.fullHostPath))throw new Error(`ENOENT: no such file or directory, open '${e.fullHostPath}'`);return it.readFileSync(e.fullHostPath)}let r=dt(t),s=zt(this.root,r);if(s.type==="stub"){let a=Buffer.from(s.stubContent,"utf8");return this.emit("file:read",{path:r,size:a.length}),a}if(s.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let i=s;i.evicted&&this._reloadEvicted(i,r);let o=i.compressed?(0,br.gunzipSync)(i.content):i.content;return this.emit("file:read",{path:r,size:o.length}),o}exists(t){let e=this.resolveMount(t);if(e)return it.existsSync(e.fullHostPath);try{return zt(this.root,dt(t)),!0}catch{return!1}}chmod(t,e){let r=dt(t);zt(this.root,r).mode=e,this._journal({op:ft.CHMOD,path:r,mode:e})}stat(t){let e=this.resolveMount(t);if(e){if(!it.existsSync(e.fullHostPath))throw new Error(`ENOENT: stat '${e.fullHostPath}'`);let a=it.statSync(e.fullHostPath),c=e.relPath.split("/").pop()??e.fullHostPath.split("/").pop()??"",l=a.mtime;return a.isDirectory()?{type:"directory",name:c,path:dt(t),mode:493,createdAt:a.birthtime,updatedAt:l,childrenCount:it.readdirSync(e.fullHostPath).length}:{type:"file",name:c,path:dt(t),mode:e.readOnly?292:420,createdAt:a.birthtime,updatedAt:l,compressed:!1,size:a.size}}let r=dt(t),s=zt(this.root,r),i=r==="/"?"":rn.posix.basename(r);if(s.type==="stub"){let a=s;return{type:"file",name:i,path:r,mode:a.mode,createdAt:new Date(a.createdAt),updatedAt:new Date(a.updatedAt),compressed:!1,size:a.stubContent.length}}if(s.type==="file"){let a=s;return{type:"file",name:i,path:r,mode:a.mode,createdAt:new Date(a.createdAt),updatedAt:new Date(a.updatedAt),compressed:a.compressed,size:a.evicted?a.size??0:a.content.length}}let o=s;return{type:"directory",name:i,path:r,mode:o.mode,createdAt:new Date(o.createdAt),updatedAt:new Date(o.updatedAt),childrenCount:o._childCount}}list(t="/"){let e=this.resolveMount(t);if(e){if(!it.existsSync(e.fullHostPath))return[];try{return it.readdirSync(e.fullHostPath).sort()}catch{return[]}}let r=dt(t),s=zt(this.root,r);if(s.type!=="directory")throw new Error(`Cannot list '${t}': not a directory.`);return Object.keys(s.children).sort()}tree(t="/"){let e=dt(t),r=zt(this.root,e);if(r.type!=="directory")throw new Error(`Cannot render tree for '${t}': not a directory.`);let s=t==="/"?"/":rn.posix.basename(e);return this.renderTreeLines(r,s)}renderTreeLines(t,e){let r=[e],s=Object.keys(t.children).sort();for(let i=0;i<s.length;i++){let o=s[i],a=t.children[o],c=i===s.length-1,l=c?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",u=c?" ":"\u2502 ";if(r.push(`${l}${o}`),a.type==="directory"){let f=this.renderTreeLines(a,"").split(`
|
|
1045
|
+
`),exitCode:0})};var sf={name:"whoami",description:"Print current user",category:"system",params:[],run:({authUser:n})=>({stdout:n,exitCode:0})};var of={name:"xargs",description:"Build and execute command lines from stdin",category:"text",params:["[command] [args...]"],run:async({authUser:n,hostname:t,mode:e,cwd:r,args:s,stdin:i,shell:o,env:a})=>{let c=s[0]??"echo",l=s.slice(1),u=(i??"").trim().split(/\s+/).filter(Boolean);if(u.length===0)return{exitCode:0};let f=[c,...l,...u].join(" ");return wt(f,n,t,e,r,o,void 0,a)}};var Dm=[_u,ul,jl,Ku,ol,Wu,Cu,eu,hl,tu,Vl,Kl,fl,zl,Gl,vl,Bl,ku,il,Mu,Xu,ef,Ol,$u,ml,Vu,Hu,of,Sl,Fu,Pl,Tl,sl,sf,rf,Hl,Wl,Rl,ju,Su,ql,El,xl,gl,Ou,yu,wl,Il,kl,vu,Ju,Bu,dl,Cl,ru,Ql,pl,tf,jc,Au,yl,Uu,Lu,du,nl,rl,_l,bl,nf,Yu,Zl,Jc,Zc,Qu,Du,Fl,Eu,Iu,Al,Ru,Pu,Tu,zu,Gu,mu,gu,pu,wu,Zu,Nl,Xl],af=[],Si=new Map,_s=null,Lm=$l(()=>Mo().map(n=>n.name));function Oo(){Si.clear();for(let n of Mo()){Si.set(n.name,n);for(let t of n.aliases??[])Si.set(t,n)}_s=Array.from(Si.keys()).sort()}function Mo(){return[...Dm,...af,Lm]}function Do(n){let t={...n,name:n.name.trim().toLowerCase(),aliases:n.aliases?.map(r=>r.trim().toLowerCase())};if([t.name,...t.aliases??[]].some(r=>r.length===0||/\s/.test(r)))throw new Error("Command names must be non-empty and contain no spaces");af.push(t),Oo()}function Lo(n,t,e){return{name:n,params:t,run:e}}function Uo(){return _s||Oo(),_s}function Co(){return Mo()}function bn(n){return _s||Oo(),Si.get(n.toLowerCase())}var mx=gn("SshClient");var Ap=require("node:events"),yp=Vt(vc(),1);var lp=require("node:events");var Mn=Vt(require("node:os"),1);var Qh=require("node:events"),it=Vt(require("node:fs"),1),rn=Vt(require("node:path"),1),br=require("node:zlib");var Pc=Buffer.from([86,70,83,33]),Ry=1,Nc=1,Dh=2,Bc=class{chunks=[];write(t){this.chunks.push(t)}writeUint8(t){let e=Buffer.allocUnsafe(1);e.writeUInt8(t,0),this.chunks.push(e)}writeUint16(t){let e=Buffer.allocUnsafe(2);e.writeUInt16LE(t,0),this.chunks.push(e)}writeUint32(t){let e=Buffer.allocUnsafe(4);e.writeUInt32LE(t,0),this.chunks.push(e)}writeFloat64(t){let e=Buffer.allocUnsafe(8);e.writeDoubleBE(t,0),this.chunks.push(e)}writeString(t){let e=Buffer.from(t,"utf8");this.writeUint16(e.length),this.chunks.push(e)}writeBytes(t){this.writeUint32(t.length),this.chunks.push(t)}toBuffer(){return Buffer.concat(this.chunks)}};function Lh(n,t){if(t.type==="file"){let e=t;n.writeUint8(Nc),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt),n.writeFloat64(e.updatedAt),n.writeUint8(e.compressed?1:0),n.writeBytes(e.content)}else if(t.type==="stub"){let e=t;n.writeUint8(Nc),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt),n.writeFloat64(e.updatedAt),n.writeUint8(0),n.writeBytes(Buffer.from(e.stubContent,"utf8"))}else{let e=t;n.writeUint8(Dh),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt),n.writeFloat64(e.updatedAt);let r=Object.values(e.children);n.writeUint32(r.length);for(let s of r)Lh(n,s)}}function Tc(n){let t=new Bc;return t.write(Pc),t.writeUint8(Ry),Lh(t,n),t.toBuffer()}var Rc=class{constructor(t){this.buf=t}buf;pos=0;readUint8(){return this.buf.readUInt8(this.pos++)}readUint16(){let t=this.buf.readUInt16LE(this.pos);return this.pos+=2,t}readUint32(){let t=this.buf.readUInt32LE(this.pos);return this.pos+=4,t}readFloat64(){let t=this.buf.readDoubleBE(this.pos);return this.pos+=8,t}readString(){let t=this.readUint16(),e=this.buf.toString("utf8",this.pos,this.pos+t);return this.pos+=t,e}readBytes(){let t=this.readUint32(),e=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,e}remaining(){return this.buf.length-this.pos}};function Uh(n){let t=n.readUint8(),e=n.readString(),r=n.readUint32(),s=n.readFloat64(),i=n.readFloat64();if(t===Nc){let o=n.readUint8()===1,a=n.readBytes();return{type:"file",name:e,mode:r,createdAt:s,updatedAt:i,compressed:o,content:a}}if(t===Dh){let o=n.readUint32(),a=Object.create(null);for(let c=0;c<o;c++){let l=Uh(n);a[l.name]=l}return{type:"directory",name:e,mode:r,createdAt:s,updatedAt:i,children:a,_childCount:o}}throw new Error(`[VFS binary] Unknown node type: 0x${t.toString(16)}`)}function ur(n){if(n.length<5)throw new Error("[VFS binary] Buffer too short");if(!n.slice(0,4).equals(Pc))throw new Error("[VFS binary] Invalid magic \u2014 not a VFS binary snapshot");let e=new Rc(n);for(let s=0;s<5;s++)e.readUint8();let r=Uh(e);if(r.type!=="directory")throw new Error("[VFS binary] Root node must be a directory");return r}function $h(n){return n.length>=4&&n.slice(0,4).equals(Pc)}var kt=Vt(require("node:fs"),1),ft={WRITE:1,MKDIR:2,REMOVE:3,CHMOD:4,MOVE:5,SYMLINK:6},ji="utf8";function Py(n,t,e){let r=Buffer.from(e,ji);return n.writeUInt16LE(r.length,t),r.copy(n,t+2),2+r.length}function Ty(n){let t=Buffer.from(n.path,ji),e=0;n.op===ft.WRITE?e=4+(n.content?.length??0)+4:n.op===ft.MKDIR?e=4:n.op===ft.REMOVE?e=0:n.op===ft.CHMOD?e=4:(n.op===ft.MOVE||n.op===ft.SYMLINK)&&(e=2+Buffer.byteLength(n.dest??"",ji));let r=3+t.length+e,s=Buffer.allocUnsafe(r),i=0;if(s.writeUInt8(n.op,i++),s.writeUInt16LE(t.length,i),i+=2,t.copy(s,i),i+=t.length,n.op===ft.WRITE){let o=n.content??Buffer.alloc(0);s.writeUInt32LE(o.length,i),i+=4,o.copy(s,i),i+=o.length,s.writeUInt32LE(n.mode??420,i),i+=4}else n.op===ft.MKDIR?(s.writeUInt32LE(n.mode??493,i),i+=4):n.op===ft.CHMOD?(s.writeUInt32LE(n.mode??420,i),i+=4):(n.op===ft.MOVE||n.op===ft.SYMLINK)&&(i+=Py(s,i,n.dest??""));return s}function Oy(n){let t=[],e=0;try{for(;e<n.length&&!(e+3>n.length);){let r=n.readUInt8(e++),s=n.readUInt16LE(e);if(e+=2,e+s>n.length)break;let i=n.subarray(e,e+s).toString(ji);if(e+=s,r===ft.WRITE){if(e+4>n.length)break;let o=n.readUInt32LE(e);if(e+=4,e+o+4>n.length)break;let a=Buffer.from(n.subarray(e,e+o));e+=o;let c=n.readUInt32LE(e);e+=4,t.push({op:r,path:i,content:a,mode:c})}else if(r===ft.MKDIR){if(e+4>n.length)break;let o=n.readUInt32LE(e);e+=4,t.push({op:r,path:i,mode:o})}else if(r===ft.REMOVE)t.push({op:r,path:i});else if(r===ft.CHMOD){if(e+4>n.length)break;let o=n.readUInt32LE(e);e+=4,t.push({op:r,path:i,mode:o})}else if(r===ft.MOVE||r===ft.SYMLINK){if(e+2>n.length)break;let o=n.readUInt16LE(e);if(e+=2,e+o>n.length)break;let a=n.subarray(e,e+o).toString(ji);e+=o,t.push({op:r,path:i,dest:a})}else break}}catch{}return t}function Fh(n,t){let e=Ty(t);if(kt.existsSync(n)){let r=kt.openSync(n,kt.constants.O_WRONLY|kt.constants.O_CREAT|kt.constants.O_APPEND);try{kt.writeSync(r,e)}finally{kt.closeSync(r)}}else kt.existsSync(".vfs")||kt.mkdirSync(".vfs"),kt.writeFileSync(n,e)}function Oc(n){if(!kt.existsSync(n))return[];let t=kt.readFileSync(n);return t.length===0?[]:Oy(t)}function Hh(n){kt.existsSync(n)&&kt.unlinkSync(n)}var Ao=Vt(require("node:path"),1);function dt(n){if(!n||n.trim()==="")return"/";let t=Ao.posix.normalize(n.startsWith("/")?n:`/${n}`);return t===""?"/":t}function My(n){return n.split("/").filter(Boolean)}function zt(n,t){let e=dt(t);if(e==="/")return n;let r=My(e),s=n;for(let i of r){if(s.type!=="directory")throw new Error(`Path '${e}' does not exist.`);let o=s.children[i];if(!o)throw new Error(`Path '${e}' does not exist.`);s=o}return s}function _r(n,t,e,r){let s=dt(t);if(s==="/")throw new Error("Root path has no parent directory.");let i=Ao.posix.dirname(s),o=Ao.posix.basename(s);if(!o)throw new Error(`Invalid path '${t}'.`);e&&r(i);let a=zt(n,i);if(a.type!=="directory")throw new Error(`Parent path '${i}' is not a directory.`);return{parent:a,name:o}}var Mc=class n extends Qh.EventEmitter{root;mode;snapshotFile;journalFile;evictionThreshold;flushAfterNWrites;_writesSinceFlush=0;_flushTimer=null;_dirty=!1;mounts=new Map;static isBrowser=typeof process>"u"||typeof process.versions?.node>"u";constructor(t={}){if(super(),this.mode=t.mode??"memory",this.mode==="fs"){if(!t.snapshotPath)throw new Error('VirtualFileSystem: "snapshotPath" is required when mode is "fs".');this.snapshotFile=rn.resolve(t.snapshotPath,"vfs-snapshot.vfsb"),this.journalFile=rn.resolve(t.snapshotPath,"vfs-journal.bin"),this.evictionThreshold=t.evictionThresholdBytes??64*1024,this.flushAfterNWrites=t.flushAfterNWrites??500;let e=t.flushIntervalMs??1e3;e>0&&(this._flushTimer=setInterval(()=>{this._dirty&&this._autoFlush()},e),typeof this._flushTimer=="object"&&this._flushTimer!==null&&"unref"in this._flushTimer&&this._flushTimer.unref())}else this.snapshotFile=null,this.journalFile=null,this.evictionThreshold=0,this.flushAfterNWrites=0;this.root=this.makeDir("",493)}makeDir(t,e){let r=Date.now();return{type:"directory",name:t,mode:e,createdAt:r,updatedAt:r,children:Object.create(null),_childCount:0}}makeFile(t,e,r,s){let i=Date.now();return{type:"file",name:t,content:e,mode:r,compressed:s,createdAt:i,updatedAt:i}}makeStub(t,e,r){let s=Date.now();return{type:"stub",name:t,stubContent:e,mode:r,createdAt:s,updatedAt:s}}writeStub(t,e,r=420){let s=dt(t),{parent:i,name:o}=_r(this.root,s,!0,c=>this.mkdirRecursive(c,493)),a=i.children[o];if(a?.type==="directory")throw new Error(`Cannot write stub '${s}': path is a directory.`);a?.type!=="file"&&(a||i._childCount++,i.children[o]=this.makeStub(o,e,r))}mkdirRecursive(t,e){let r=dt(t);if(r==="/")return;let s=r.split("/").filter(Boolean),i=this.root,o="";for(let a of s){o+=`/${a}`;let c=i.children[a];if(!c)c=this.makeDir(a,e),i.children[a]=c,i._childCount++,this.emit("dir:create",{path:o,mode:e}),this._journal({op:ft.MKDIR,path:o,mode:e});else if(c.type!=="directory")throw new Error(`Cannot create directory '${o}': path is a file.`);i=c}}async restoreMirror(){if(!(this.mode!=="fs"||!this.snapshotFile)){if(!it.existsSync(this.snapshotFile)){if(this.journalFile){let t=Oc(this.journalFile);t.length>0&&this._replayJournal(t)}return}try{let t=it.readFileSync(this.snapshotFile);if($h(t))this.root=ur(t);else{let e=JSON.parse(t.toString("utf8"));this.root=this.deserializeDir(e.root,""),console.info("[VirtualFileSystem] Migrating legacy JSON snapshot to binary format.")}if(this.emit("snapshot:restore",{path:this.snapshotFile}),this.journalFile){let e=Oc(this.journalFile);e.length>0&&this._replayJournal(e)}}catch(t){console.warn(`[VirtualFileSystem] Could not restore snapshot from ${this.snapshotFile}:`,t instanceof Error?t.message:String(t))}}}async flushMirror(){if(this.mode!=="fs"||!this.snapshotFile){this.emit("mirror:flush");return}let t=rn.dirname(this.snapshotFile);it.mkdirSync(t,{recursive:!0});let e=this.root,r=Tc(e);it.writeFileSync(this.snapshotFile,r),this.journalFile&&Hh(this.journalFile),this._dirty=!1,this._writesSinceFlush=0,this.emit("mirror:flush",{path:this.snapshotFile}),this.evictLargeFiles()}getMode(){return this.mode}getSnapshotPath(){return this.snapshotFile}async _autoFlush(){this._dirty&&await this.flushMirror()}_markDirty(){this._dirty=!0,this.flushAfterNWrites>0&&(this._writesSinceFlush++,this._writesSinceFlush>=this.flushAfterNWrites&&(this._writesSinceFlush=0,this._autoFlush()))}async stopAutoFlush(){this._flushTimer!==null&&(clearInterval(this._flushTimer),this._flushTimer=null),this._dirty&&await this.flushMirror()}importRootTree(t){let e=this._replayMode;this._replayMode=!0;try{this.root=t}finally{this._replayMode=e}}mergeRootTree(t){let e=this._replayMode;this._replayMode=!0;try{this._mergeDir(this.root,t)}finally{this._replayMode=e}}_mergeDir(t,e){for(let[r,s]of Object.entries(e.children)){let i=t.children[r];s.type==="directory"?i?i.type==="directory"&&this._mergeDir(i,s):(t.children[r]=s,t._childCount++):i||(t.children[r]=s,t._childCount++)}}encodeBinary(){return Tc(this.root)}releaseTree(){this.root=this.makeDir("",493)}_replayMode=!1;_journal(t){this.journalFile&&!this._replayMode&&(Fh(this.journalFile,t),this._markDirty())}_replayJournal(t){this._replayMode=!0;try{for(let e of t)try{e.op===ft.WRITE?this.writeFile(e.path,e.content??Buffer.alloc(0),{mode:e.mode}):e.op===ft.MKDIR?this.mkdir(e.path,e.mode):e.op===ft.REMOVE?this.exists(e.path)&&this.remove(e.path,{recursive:!0}):e.op===ft.CHMOD?this.exists(e.path)&&this.chmod(e.path,e.mode??420):e.op===ft.MOVE?this.exists(e.path)&&e.dest&&this.move(e.path,e.dest):e.op===ft.SYMLINK&&e.dest&&this.symlink(e.dest,e.path)}catch{}}finally{this._replayMode=!1}}evictLargeFiles(){!this.snapshotFile||this.evictionThreshold===0||it.existsSync(this.snapshotFile)&&this._evictDir(this.root)}_evictDir(t){for(let e of Object.values(t.children))if(e.type==="directory")this._evictDir(e);else if(e.type==="file"&&!e.evicted){let r=e.compressed?e.size??e.content.length*2:e.content.length;r>this.evictionThreshold&&(e.size=r,e.content=Buffer.alloc(0),e.evicted=!0)}}_reloadEvicted(t,e){if(!(!t.evicted||!this.snapshotFile)&&it.existsSync(this.snapshotFile))try{let r=it.readFileSync(this.snapshotFile),s=ur(r),i=e.split("/").filter(Boolean),o=s;for(let a of i){if(o.type!=="directory")return;let c=o.children[a];if(!c)return;o=c}o.type==="file"&&(t.content=o.content,t.compressed=o.compressed,t.evicted=void 0)}catch{}}mount(t,e,{readOnly:r=!0}={}){if(n.isBrowser)return;let s=dt(t),i=rn.resolve(e);if(!it.existsSync(i))throw new Error(`VirtualFileSystem.mount: host path does not exist: "${i}"`);if(!it.statSync(i).isDirectory())throw new Error(`VirtualFileSystem.mount: host path is not a directory: "${i}"`);this.mkdir(s),this.mounts.set(s,{hostPath:i,readOnly:r}),this.emit("mount",{vPath:s,hostPath:i,readOnly:r})}unmount(t){let e=dt(t);this.mounts.delete(e)&&this.emit("unmount",{vPath:e})}getMounts(){return[...this.mounts.entries()].map(([t,e])=>({vPath:t,...e}))}resolveMount(t){let e=dt(t),r=[...this.mounts.entries()].sort(([s],[i])=>i.length-s.length);for(let[s,i]of r)if(e===s||e.startsWith(`${s}/`)){let o=e.slice(s.length).replace(/^\//,""),a=o?rn.join(i.hostPath,o):i.hostPath;return{hostPath:i.hostPath,readOnly:i.readOnly,relPath:o,fullHostPath:a}}return null}mkdir(t,e=493){let r=dt(t),s=(()=>{try{return zt(this.root,r)}catch{return null}})();if(s&&s.type!=="directory")throw new Error(`Cannot create directory '${r}': path is a file.`);this.mkdirRecursive(r,e)}writeFile(t,e,r={}){let s=this.resolveMount(t);if(s){if(s.readOnly)throw new Error(`EROFS: read-only file system, open '${s.fullHostPath}'`);let p=rn.dirname(s.fullHostPath);it.existsSync(p)||it.mkdirSync(p,{recursive:!0}),it.writeFileSync(s.fullHostPath,Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"));return}let i=dt(t),{parent:o,name:a}=_r(this.root,i,!0,p=>this.mkdirRecursive(p,493)),c=o.children[a];if(c?.type==="directory")throw new Error(`Cannot write file '${i}': path is a directory.`);let l=Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"),u=r.compress??!1,f=u?(0,br.gzipSync)(l):l,h=r.mode??420;if(c&&c.type==="file"){let p=c;p.content=f,p.compressed=u,p.mode=h,p.updatedAt=Date.now()}else c||o._childCount++,o.children[a]=this.makeFile(a,f,h,u);this.emit("file:write",{path:i,size:f.length}),this._journal({op:ft.WRITE,path:i,content:l,mode:h})}readFile(t){let e=this.resolveMount(t);if(e){if(!it.existsSync(e.fullHostPath))throw new Error(`ENOENT: no such file or directory, open '${e.fullHostPath}'`);return it.readFileSync(e.fullHostPath,"utf8")}let r=dt(t),s=zt(this.root,r);if(s.type==="stub")return this.emit("file:read",{path:r,size:s.stubContent.length}),s.stubContent;if(s.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let i=s;i.evicted&&this._reloadEvicted(i,r);let o=i.compressed?(0,br.gunzipSync)(i.content):i.content;return this.emit("file:read",{path:r,size:o.length}),o.toString("utf8")}readFileRaw(t){let e=this.resolveMount(t);if(e){if(!it.existsSync(e.fullHostPath))throw new Error(`ENOENT: no such file or directory, open '${e.fullHostPath}'`);return it.readFileSync(e.fullHostPath)}let r=dt(t),s=zt(this.root,r);if(s.type==="stub"){let a=Buffer.from(s.stubContent,"utf8");return this.emit("file:read",{path:r,size:a.length}),a}if(s.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let i=s;i.evicted&&this._reloadEvicted(i,r);let o=i.compressed?(0,br.gunzipSync)(i.content):i.content;return this.emit("file:read",{path:r,size:o.length}),o}exists(t){let e=this.resolveMount(t);if(e)return it.existsSync(e.fullHostPath);try{return zt(this.root,dt(t)),!0}catch{return!1}}chmod(t,e){let r=dt(t);zt(this.root,r).mode=e,this._journal({op:ft.CHMOD,path:r,mode:e})}stat(t){let e=this.resolveMount(t);if(e){if(!it.existsSync(e.fullHostPath))throw new Error(`ENOENT: stat '${e.fullHostPath}'`);let a=it.statSync(e.fullHostPath),c=e.relPath.split("/").pop()??e.fullHostPath.split("/").pop()??"",l=a.mtime;return a.isDirectory()?{type:"directory",name:c,path:dt(t),mode:493,createdAt:a.birthtime,updatedAt:l,childrenCount:it.readdirSync(e.fullHostPath).length}:{type:"file",name:c,path:dt(t),mode:e.readOnly?292:420,createdAt:a.birthtime,updatedAt:l,compressed:!1,size:a.size}}let r=dt(t),s=zt(this.root,r),i=r==="/"?"":rn.posix.basename(r);if(s.type==="stub"){let a=s;return{type:"file",name:i,path:r,mode:a.mode,createdAt:new Date(a.createdAt),updatedAt:new Date(a.updatedAt),compressed:!1,size:a.stubContent.length}}if(s.type==="file"){let a=s;return{type:"file",name:i,path:r,mode:a.mode,createdAt:new Date(a.createdAt),updatedAt:new Date(a.updatedAt),compressed:a.compressed,size:a.evicted?a.size??0:a.content.length}}let o=s;return{type:"directory",name:i,path:r,mode:o.mode,createdAt:new Date(o.createdAt),updatedAt:new Date(o.updatedAt),childrenCount:o._childCount}}list(t="/"){let e=this.resolveMount(t);if(e){if(!it.existsSync(e.fullHostPath))return[];try{return it.readdirSync(e.fullHostPath).sort()}catch{return[]}}let r=dt(t),s=zt(this.root,r);if(s.type!=="directory")throw new Error(`Cannot list '${t}': not a directory.`);return Object.keys(s.children).sort()}tree(t="/"){let e=dt(t),r=zt(this.root,e);if(r.type!=="directory")throw new Error(`Cannot render tree for '${t}': not a directory.`);let s=t==="/"?"/":rn.posix.basename(e);return this.renderTreeLines(r,s)}renderTreeLines(t,e){let r=[e],s=Object.keys(t.children).sort();for(let i=0;i<s.length;i++){let o=s[i],a=t.children[o],c=i===s.length-1,l=c?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",u=c?" ":"\u2502 ";if(r.push(`${l}${o}`),a.type==="directory"){let f=this.renderTreeLines(a,"").split(`
|
|
1046
1046
|
`).slice(1).map(h=>`${u}${h}`);r.push(...f)}}return r.join(`
|
|
1047
1047
|
`)}getUsageBytes(t="/"){return this.computeUsage(zt(this.root,dt(t)))}computeUsage(t){if(t.type==="file")return t.content.length;if(t.type==="stub")return t.stubContent.length;let e=0;for(let r of Object.values(t.children))e+=this.computeUsage(r);return e}compressFile(t){let e=zt(this.root,dt(t));if(e.type!=="file")throw new Error(`Cannot compress '${t}': not a file.`);let r=e;r.compressed||(r.content=(0,br.gzipSync)(r.content),r.compressed=!0,r.updatedAt=Date.now())}decompressFile(t){let e=zt(this.root,dt(t));if(e.type!=="file")throw new Error(`Cannot decompress '${t}': not a file.`);let r=e;r.compressed&&(r.content=(0,br.gunzipSync)(r.content),r.compressed=!1,r.updatedAt=Date.now())}symlink(t,e){let r=dt(e),s=t.startsWith("/")?dt(t):t,{parent:i,name:o}=_r(this.root,r,!0,c=>this.mkdirRecursive(c,493)),a={type:"file",name:o,content:Buffer.from(s,"utf8"),mode:41471,compressed:!1,createdAt:Date.now(),updatedAt:Date.now()};i.children[o]=a,i._childCount++,this._journal({op:ft.SYMLINK,path:r,dest:s}),this.emit("symlink:create",{link:r,target:s})}isSymlink(t){try{let e=zt(this.root,dt(t));return e.type==="file"&&e.mode===41471}catch{return!1}}resolveSymlink(t,e=8){let r=dt(t);for(let s=0;s<e;s++){try{let i=zt(this.root,r);if(i.type==="file"&&i.mode===41471){let o=i.content.toString("utf8");r=o.startsWith("/")?o:dt(rn.posix.join(rn.posix.dirname(r),o));continue}}catch{break}return r}throw new Error(`Too many levels of symbolic links: ${t}`)}remove(t,e={}){let r=this.resolveMount(t);if(r){if(r.readOnly)throw new Error(`EROFS: read-only file system, unlink '${r.fullHostPath}'`);if(!it.existsSync(r.fullHostPath))throw new Error(`ENOENT: no such file or directory, unlink '${r.fullHostPath}'`);it.statSync(r.fullHostPath).isDirectory()?it.rmSync(r.fullHostPath,{recursive:e.recursive??!1}):it.unlinkSync(r.fullHostPath);return}let s=dt(t);if(s==="/")throw new Error("Cannot remove root directory.");let i=zt(this.root,s);if(i.type==="directory"){let c=i;if(!e.recursive&&c._childCount>0)throw new Error(`Directory '${s}' is not empty. Use recursive option.`)}let{parent:o,name:a}=_r(this.root,s,!1,()=>{});delete o.children[a],o._childCount--,this.emit("node:remove",{path:s}),this._journal({op:ft.REMOVE,path:s})}move(t,e){let r=dt(t),s=dt(e);if(r==="/"||s==="/")throw new Error("Cannot move root directory.");let i=zt(this.root,r);if(this.exists(s))throw new Error(`Destination '${s}' already exists.`);this.mkdirRecursive(rn.posix.dirname(s),493);let{parent:o,name:a}=_r(this.root,s,!1,()=>{}),{parent:c,name:l}=_r(this.root,r,!1,()=>{});delete c.children[l],c._childCount--,i.name=a,o.children[a]=i,o._childCount++,this._journal({op:ft.MOVE,path:r,dest:s})}toSnapshot(){return{root:this.serializeDir(this.root)}}serializeDir(t){let e=[];for(let r of Object.values(t.children))r.type==="stub"?e.push({type:"file",name:r.name,mode:r.mode,createdAt:new Date(r.createdAt).toISOString(),updatedAt:new Date(r.updatedAt).toISOString(),compressed:!1,contentBase64:Buffer.from(r.stubContent,"utf8").toString("base64")}):r.type==="file"?e.push(this.serializeFile(r)):e.push(this.serializeDir(r));return{type:"directory",name:t.name,mode:t.mode,createdAt:new Date(t.createdAt).toISOString(),updatedAt:new Date(t.updatedAt).toISOString(),children:e}}serializeFile(t){return{type:"file",name:t.name,mode:t.mode,createdAt:new Date(t.createdAt).toISOString(),updatedAt:new Date(t.updatedAt).toISOString(),compressed:t.compressed,contentBase64:t.content.toString("base64")}}static fromSnapshot(t){let e=new n;return e.root=e.deserializeDir(t.root,""),e}importSnapshot(t){this.root=this.deserializeDir(t.root,""),this.emit("snapshot:import")}deserializeDir(t,e){let r={type:"directory",name:e,mode:t.mode,createdAt:Date.parse(t.createdAt),updatedAt:Date.parse(t.updatedAt),children:Object.create(null),_childCount:0};for(let s of t.children){if(s.type==="file"){let i=s;r.children[i.name]={type:"file",name:i.name,mode:i.mode,createdAt:Date.parse(i.createdAt),updatedAt:Date.parse(i.updatedAt),compressed:i.compressed,content:Buffer.from(i.contentBase64,"base64")}}else{let i=this.deserializeDir(s,s.name);r.children[s.name]=i}r._childCount++}return r}},Xi=Mc;function M(n,t,e=493){n.exists(t)||n.mkdir(t,e)}function T(n,t,e,r=420){n.writeStub(t,e,r)}function ue(n,t,e){n.writeFile(t,e)}function Dy(n){let t=2166136261;for(let e=0;e<n.length;e++)t^=n.charCodeAt(e),t=Math.imul(t,16777619);return t>>>0}function Ly(n,t,e){M(n,"/etc"),T(n,"/etc/os-release",`${['NAME="Fortune GNU/Linux"',`PRETTY_NAME="${e.os}"`,"ID=fortune","ID_LIKE=debian",'HOME_URL="https://github.com/itsrealfortune/typescript-virtual-container"',"VERSION_CODENAME=nyx",'VERSION_ID="24.04"',"FORTUNE_CODENAME=nyx"].join(`
|
|
1048
1048
|
`)}
|
|
@@ -1716,7 +1716,7 @@ echo 'neofetch: virtual stub'
|
|
|
1716
1716
|
`),exitCode:0}}remove(t,e={}){let r=[],s=[];for(let i of t){let o=this.installed.get(i.toLowerCase());o?s.push(o):r.push(`Package '${i}' is not installed, so not removed`)}if(s.length===0)return{output:r.join(`
|
|
1717
1717
|
`)||"Nothing to remove.",exitCode:0};e.quiet||r.push("Reading package lists... Done","Building dependency tree... Done","The following packages will be REMOVED:",` ${s.map(i=>i.name).join(" ")}`,`0 upgraded, 0 newly installed, ${s.length} to remove and 0 not upgraded.`);for(let i of s){e.quiet||r.push(`Removing ${i.name} (${i.version}) ...`);for(let a of i.files)if(!(!e.purge&&(a.startsWith("/etc/")||a.endsWith(".conf"))))try{this.vfs.exists(a)&&this.vfs.remove(a)}catch{}this.findInRegistry(i.name)?.onRemove?.(this.vfs),this.installed.delete(i.name),this.log(`remove ${i.name} ${i.version}`)}return this.aptLog("remove",s.map(i=>i.name)),this.persist(),{output:r.join(`
|
|
1718
1718
|
`),exitCode:0}}search(t){let e=t.toLowerCase();return Lc.filter(r=>r.name.includes(e)||r.description.toLowerCase().includes(e)||(r.shortDesc??"").toLowerCase().includes(e)).sort((r,s)=>r.name.localeCompare(s.name))}show(t){let e=this.findInRegistry(t);if(!e)return null;let r=this.installed.get(t);return[`Package: ${e.name}`,`Version: ${e.version}`,`Architecture: ${e.architecture??"amd64"}`,`Maintainer: ${e.maintainer??"Fortune Maintainers <pkg@fortune.local>"}`,`Installed-Size: ${e.installedSizeKb??0}`,`Depends: ${(e.depends??[]).join(", ")||"(none)"}`,`Section: ${e.section??"misc"}`,"Priority: optional",`Description: ${e.description}`,`Status: ${r?"install ok installed":"install ok not-installed"}`].join(`
|
|
1719
|
-
`)}};var kn=require("node:crypto"),Gh=require("node:events"),Yh=Vt(require("node:path"),1);function jy(){let n=process.env.SSH_MIMIC_FAST_PASSWORD_HASH;return!!n&&!["0","false","no","off"].includes(n.toLowerCase())}var
|
|
1719
|
+
`)}};var kn=require("node:crypto"),Gh=require("node:events"),Yh=Vt(require("node:path"),1);function jy(){let n=process.env.SSH_MIMIC_FAST_PASSWORD_HASH;return!!n&&!["0","false","no","off"].includes(n.toLowerCase())}var Dt=gn("VirtualUserManager"),Zi=class n extends Gh.EventEmitter{constructor(e,r=!0){super();this.vfs=e;this.autoSudoForNewUsers=r;Dt.mark("constructor")}vfs;autoSudoForNewUsers;static recordCache=new Map;static fastPasswordHash=jy();usersPath="/etc/htpasswd";sudoersPath="/etc/sudoers";quotasPath="/etc/quotas";authDirPath="/.virtual-env-js/.auth";users=new Map;sudoers=new Set;quotas=new Map;activeSessions=new Map;nextTty=0;async initialize(){Dt.mark("initialize"),this.loadFromVfs(),this.loadSudoersFromVfs(),this.loadQuotasFromVfs();let e=!1;this.users.has("root")||(this.users.set("root",this.createRecord("root","")),e=!0),this.sudoers.add("root");let r="/root";this.vfs.exists(r)||(this.vfs.mkdir(r,493),this.vfs.writeFile(`${r}/README.txt`,"Welcome to the virtual environment, root")),e&&await this.persist(),this.emit("initialized")}async setQuotaBytes(e,r){if(Dt.mark("setQuotaBytes"),this.validateUsername(e),!this.users.has(e))throw new Error(`quota: user '${e}' does not exist`);if(!Number.isFinite(r)||r<0)throw new Error("quota: maxBytes must be a non-negative number");this.quotas.set(e,Math.floor(r)),await this.persist()}async clearQuota(e){Dt.mark("clearQuota"),this.validateUsername(e),this.quotas.delete(e),await this.persist()}getQuotaBytes(e){return Dt.mark("getQuotaBytes"),this.quotas.get(e)??null}getUsageBytes(e){Dt.mark("getUsageBytes");let r=e==="root"?"/root":`/home/${e}`;return this.vfs.exists(r)?this.vfs.getUsageBytes(r):0}assertWriteWithinQuota(e,r,s){Dt.mark("assertWriteWithinQuota");let i=this.quotas.get(e);if(i===void 0)return;let o=zh(r),a=zh(e==="root"?"/root":`/home/${e}`);if(!(o===a||o.startsWith(`${a}/`)))return;let l=this.getUsageBytes(e),u=0;if(this.vfs.exists(o)){let p=this.vfs.stat(o);p.type==="file"&&(u=p.size)}let f=Buffer.isBuffer(s)?s.length:Buffer.byteLength(s,"utf8"),h=l-u+f;if(h>i)throw new Error(`quota exceeded for '${e}': ${h}/${i} bytes`)}verifyPassword(e,r){Dt.mark("verifyPassword");let s=this.users.get(e);if(!s)return this.hashPassword(r,""),!1;let i=this.hashPassword(r,s.salt),o=s.passwordHash;try{let a=Buffer.from(i,"hex"),c=Buffer.from(o,"hex");return a.length!==c.length?!1:(0,kn.timingSafeEqual)(a,c)}catch{return i===o}}async addUser(e,r){if(Dt.mark("addUser"),this.validateUsername(e),this.validatePassword(r),this.users.has(e))return;this.users.set(e,this.createRecord(e,r)),this.autoSudoForNewUsers&&this.sudoers.add(e);let s=e==="root"?"/root":`/home/${e}`;this.vfs.exists(s)||(this.vfs.mkdir(s,493),this.vfs.writeFile(`${s}/README.txt`,`Welcome to the virtual environment, ${e}`)),await this.persist(),this.emit("user:add",{username:e})}getPasswordHash(e){Dt.mark("getPasswordHash");let r=this.users.get(e);return r?r.passwordHash:null}async setPassword(e,r){if(Dt.mark("setPassword"),this.validateUsername(e),this.validatePassword(r),!this.users.has(e))throw new Error(`passwd: user '${e}' does not exist`);this.users.set(e,this.createRecord(e,r)),await this.persist()}async deleteUser(e){if(Dt.mark("deleteUser"),this.validateUsername(e),e==="root")throw new Error("deluser: cannot delete root");if(!this.users.delete(e))throw new Error(`deluser: user '${e}' does not exist`);this.sudoers.delete(e),this.emit("user:delete",{username:e}),await this.persist()}isSudoer(e){return Dt.mark("isSudoer"),this.sudoers.has(e)}async addSudoer(e){if(Dt.mark("addSudoer"),this.validateUsername(e),!this.users.has(e))throw new Error(`sudoers: user '${e}' does not exist`);this.sudoers.add(e),await this.persist()}async removeSudoer(e){if(Dt.mark("removeSudoer"),this.validateUsername(e),e==="root")throw new Error("sudoers: cannot remove root");this.sudoers.delete(e),await this.persist()}registerSession(e,r){Dt.mark("registerSession");let s={id:(0,kn.randomUUID)(),username:e,tty:`pts/${this.nextTty++}`,remoteAddress:r,startedAt:new Date().toISOString()};return this.activeSessions.set(s.id,s),this.emit("session:register",{sessionId:s.id,username:e,remoteAddress:r}),s}unregisterSession(e){if(Dt.mark("unregisterSession"),!e)return;let r=this.activeSessions.get(e);this.activeSessions.delete(e),r&&this.emit("session:unregister",{sessionId:e,username:r.username}),this.activeSessions.delete(e)}updateSession(e,r,s){if(Dt.mark("updateSession"),!e)return;let i=this.activeSessions.get(e);i&&this.activeSessions.set(e,{...i,username:r,remoteAddress:s})}listActiveSessions(){return Dt.mark("listActiveSessions"),Array.from(this.activeSessions.values()).sort((e,r)=>e.startedAt.localeCompare(r.startedAt))}listUsers(){return Array.from(this.users.keys()).sort()}loadFromVfs(){if(this.users.clear(),!this.vfs.exists(this.usersPath))return;let e=this.vfs.readFile(this.usersPath);for(let r of e.split(`
|
|
1720
1720
|
`)){let s=r.trim();if(s.length===0)continue;let i=s.split(":");if(i.length<3)continue;let[o,a,c]=i;!o||!a||!c||this.users.set(o,{username:o,salt:a,passwordHash:c})}}loadSudoersFromVfs(){if(this.sudoers.clear(),!this.vfs.exists(this.sudoersPath))return;let e=this.vfs.readFile(this.sudoersPath);for(let r of e.split(`
|
|
1721
1721
|
`)){let s=r.trim();s.length>0&&this.sudoers.add(s)}}loadQuotasFromVfs(){if(this.quotas.clear(),!this.vfs.exists(this.quotasPath))return;let e=this.vfs.readFile(this.quotasPath);for(let r of e.split(`
|
|
1722
1722
|
`)){let s=r.trim();if(s.length===0)continue;let[i,o]=s.split(":"),a=Number.parseInt(o??"",10);!i||!Number.isFinite(a)||a<0||this.quotas.set(i,a)}}async persist(){this.vfs.exists(this.authDirPath)||this.vfs.mkdir(this.authDirPath,448);let e=Array.from(this.users.values()).sort((o,a)=>o.username.localeCompare(a.username)).map(o=>[o.username,o.salt,o.passwordHash].join(":")).join(`
|
|
@@ -1725,7 +1725,7 @@ echo 'neofetch: virtual stub'
|
|
|
1725
1725
|
`),i=!1;i=this.writeIfChanged(this.usersPath,e.length>0?`${e}
|
|
1726
1726
|
`:"",384)||i,i=this.writeIfChanged(this.sudoersPath,r.length>0?`${r}
|
|
1727
1727
|
`:"",384)||i,i=this.writeIfChanged(this.quotasPath,s.length>0?`${s}
|
|
1728
|
-
`:"",384)||i,i&&await this.vfs.flushMirror()}writeIfChanged(e,r,s){return this.vfs.exists(e)&&this.vfs.readFile(e)===r?(this.vfs.chmod(e,s),!1):(this.vfs.writeFile(e,r,{mode:s}),!0)}createRecord(e,r){let s=(0,kn.createHash)("sha256").update(e).update(":").update(r).digest("hex"),i=n.recordCache.get(s);if(i)return i;let o=(0,kn.randomBytes)(16).toString("hex"),a={username:e,salt:o,passwordHash:this.hashPassword(r,o)};return n.recordCache.set(s,a),a}hasPassword(e){
|
|
1728
|
+
`:"",384)||i,i&&await this.vfs.flushMirror()}writeIfChanged(e,r,s){return this.vfs.exists(e)&&this.vfs.readFile(e)===r?(this.vfs.chmod(e,s),!1):(this.vfs.writeFile(e,r,{mode:s}),!0)}createRecord(e,r){let s=(0,kn.createHash)("sha256").update(e).update(":").update(r).digest("hex"),i=n.recordCache.get(s);if(i)return i;let o=(0,kn.randomBytes)(16).toString("hex"),a={username:e,salt:o,passwordHash:this.hashPassword(r,o)};return n.recordCache.set(s,a),a}hasPassword(e){Dt.mark("hasPassword");let r=this.users.get(e);if(!r)return!1;let s=this.hashPassword("",r.salt);return r.passwordHash===s?!1:!!r.passwordHash}hashPassword(e,r=""){return n.fastPasswordHash?(0,kn.createHash)("sha256").update(r).update(e).digest("hex"):(0,kn.scryptSync)(e,r||"",32).toString("hex")}validateUsername(e){if(!e||e.trim()==="")throw new Error("invalid username");if(!/^[a-z_][a-z0-9_-]{0,31}$/i.test(e))throw new Error("invalid username")}validatePassword(e){if(!e||e.trim()==="")throw new Error("invalid password")}authorizedKeys=new Map;addAuthorizedKey(e,r,s){Dt.mark("addAuthorizedKey");let i=this.authorizedKeys.get(e)??[];i.push({algo:r,data:s}),this.authorizedKeys.set(e,i),this.emit("key:add",{username:e,algo:r})}removeAuthorizedKeys(e){this.authorizedKeys.delete(e),this.emit("key:remove",{username:e})}getAuthorizedKeys(e){return this.authorizedKeys.get(e)??[]}};function zh(n){let t=Yh.posix.normalize(n);return t.startsWith("/")?t:`/${t}`}var jh=require("node:events");var es=class extends jh.EventEmitter{vfs;idleThresholdMs;checkIntervalMs;_state="active";_lastActivity=Date.now();_frozenBuffer=null;_checkTimer=null;constructor(t,e={}){super(),this.vfs=t,this.idleThresholdMs=e.idleThresholdMs??6e4,this.checkIntervalMs=e.checkIntervalMs??15e3}start(){this._checkTimer||(this._lastActivity=Date.now(),this._checkTimer=setInterval(()=>this._check(),this.checkIntervalMs),typeof this._checkTimer=="object"&&this._checkTimer!==null&&"unref"in this._checkTimer&&this._checkTimer.unref())}async stop(){this._checkTimer&&(clearInterval(this._checkTimer),this._checkTimer=null),this._state==="frozen"&&this._thaw()}ping(){this._lastActivity=Date.now(),this._state==="frozen"&&this._thaw()}get state(){return this._state}get idleMs(){return Date.now()-this._lastActivity}_check(){this._state!=="frozen"&&Date.now()-this._lastActivity>=this.idleThresholdMs&&this._freeze()}async _freeze(){this._state!=="frozen"&&(await this.vfs.stopAutoFlush(),this._frozenBuffer=this.vfs.encodeBinary(),this.vfs.releaseTree(),this._state="frozen",this.emit("freeze"))}_thaw(){if(this._state!=="frozen"||!this._frozenBuffer)return;let t=ur(this._frozenBuffer);this.vfs.importRootTree(t),this._frozenBuffer=null,this._state="active",this.emit("thaw")}};var ii=require("node:fs/promises"),$c=Vt(require("node:path"),1);var np=require("node:child_process");var Xh=require("node:fs/promises"),Eo=Vt(require("node:path"),1);function Uc(n){return`'${n.replace(/'/g,"'\\''")}'`}function ts(n){return n.replace(/\r\n/g,`
|
|
1729
1729
|
`).replace(/\r/g,`
|
|
1730
1730
|
`).replace(/\n/g,`\r
|
|
1731
1731
|
`)}function Jh(n,t){let e=Number.isFinite(t.cols)&&t.cols>0?Math.floor(t.cols):80,r=Number.isFinite(t.rows)&&t.rows>0?Math.floor(t.rows):24;return`stty cols ${e} rows ${r} 2>/dev/null; ${n}`}function Zh(n,t){return!t||t.trim()===""||t==="."?n:t.startsWith("/")?Eo.posix.normalize(t):Eo.posix.normalize(Eo.posix.join(n,t))}async function ep(n){try{let e=(await(0,Xh.readFile)(`/proc/${n}/task/${n}/children`,"utf8")).trim().split(/\s+/).filter(Boolean).map(s=>Number.parseInt(s,10)).filter(s=>Number.isInteger(s)&&s>0),r=await Promise.all(e.map(s=>ep(s)));return[...e,...r.flat()]}catch{return[]}}async function tp(n=process.pid){let t=await ep(n),e=Array.from(new Set(t)).sort((r,s)=>r-s);return e.length===0?null:e.join(",")}function rp(n,t,e){let r=Jh(n,t),s=(0,np.spawn)("script",["-qfec",r,"/dev/null"],{stdio:["pipe","pipe","pipe"],env:{...process.env,TERM:process.env.TERM??"xterm-256color"}});return s.stdout.on("data",i=>{e.write(i.toString("utf8"))}),s.stderr.on("data",i=>{e.write(i.toString("utf8"))}),s}function ip(n,t,e){return rp(`nano -- ${Uc(n)}`,t,e)}function sp(n,t,e){return rp(`htop -p ${Uc(n)}`,t,e)}function op(n,t,e){let r=[`Linux ${n} ${t.kernel} ${t.arch}`,"","The programs included with the Fortune GNU/Linux system are free software;","the exact distribution terms for each program are described in the","individual files in /usr/share/doc/*/copyright.","","Fortune GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent","permitted by applicable law."];if(e){let s=new Date(e.at),i=Number.isNaN(s.getTime())?e.at:Ss(s);r.push(`Last login: ${i} from ${e.from||"unknown"}`)}return r.push(""),`${r.map(s=>`${s}\r
|