login-action/dist/index.js

18 lines
2.4 MiB
JavaScript
Raw Normal View History

require('./sourcemap-register.js');(()=>{var e={7799:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){if(n===undefined)n=r;var i=Object.getOwnPropertyDescriptor(t,r);if(!i||("get"in i?!t.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return t[r]}}}Object.defineProperty(e,n,i)}:function(e,t,r,n){if(n===undefined)n=r;e[n]=t[r]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(r!=="default"&&Object.prototype.hasOwnProperty.call(e,r))n(t,e,r);i(t,e);return t};var o=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.saveCache=t.restoreCache=t.isFeatureAvailable=t.ReserveCacheError=t.ValidationError=void 0;const s=a(r(2186));const c=a(r(1017));const l=a(r(1518));const d=a(r(8245));const p=r(6490);class ValidationError extends Error{constructor(e){super(e);this.name="ValidationError";Object.setPrototypeOf(this,ValidationError.prototype)}}t.ValidationError=ValidationError;class ReserveCacheError extends Error{constructor(e){super(e);this.name="ReserveCacheError";Object.setPrototypeOf(this,ReserveCacheError.prototype)}}t.ReserveCacheError=ReserveCacheError;function checkPaths(e){if(!e||e.length===0){throw new ValidationError(`Path Validation Error: At least one directory or file path is required`)}}function checkKey(e){if(e.length>512){throw new ValidationError(`Key Validation Error: ${e} cannot be larger than 512 characters.`)}const t=/^[^,]*$/;if(!t.test(e)){throw new ValidationError(`Key Validation Error: ${e} cannot contain commas.`)}}function isFeatureAvailable(){return!!process.env["ACTIONS_CACHE_URL"]}t.isFeatureAvailable=isFeatureAvailable;function restoreCache(e,t,r,n,i=false){return o(this,void 0,void 0,(function*(){checkPaths(e);r=r||[];const a=[t,...r];s.debug("Resolved Keys:");s.debug(JSON.stringify(a));if(a.length>10){throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`)}for(const e of a){checkKey(e)}const o=yield l.getCompressionMethod();let u="";try{const t=yield d.getCacheEntry(a,e,{compressionMethod:o,enableCrossOsArchive:i});if(!(t===null||t===void 0?void 0:t.archiveLocation)){return undefined}if(n===null||n===void 0?void 0:n.lookupOnly){s.info("Lookup only - skipping download");return t.cacheKey}u=c.join(yield l.createTempDirectory(),l.getCacheFileName(o));s.debug(`Archive Path: ${u}`);yield d.downloadCache(t.archiveLocation,u,n);if(s.isDebug()){yield(0,p.listTar)(u,o)}const r=l.getArchiveFileSizeInBytes(u);s.info(`Cache Size: ~${Math.round(r/(1024*1024))} MB (${r} B)`);yield(0,p.extractTar)(u,o);s.info("Cache restored successfully");return t.cacheKey}catch(e){const t=e;if(t.name===ValidationError.name){throw e}else{s.warning(`Failed to restore: ${e.message}`)}}finally{try{yield l.unlinkFile(u)}catch(e){s.debug(`Failed to delete archive: ${e}`)}}return undefined}))}t.restoreCache=restoreCache;function saveCache(e,t,r,n=false){var i,a,u,A,m;return o(this,void 0,void 0,(function*(){checkPaths(e);checkKey(t);const o=yield l.getCompressionMethod();let g=-1;const h=yield l.resolvePaths(e);s.debug("Cache Paths:");s.debug(`${JSON.stringify(h)}`);if(h.length===0){throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`)}const f=yield l.createTempDirectory();const y=c.join(f,l.getCacheFileName(o));s.debug(`Archive Path: ${y}`);try{yield(0,p.createTar)(f,h,o);if(s.isDebug()){yield(0,p.listTar)(y,o)}const c=10*1024*1024*1024;const E=l.getArchiveFi
/*!
* mime-db
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015-2022 Douglas Christopher Wilson
* MIT Licensed
*/
e.exports=r(3765)},3583:(e,t,r)=>{"use strict";
/*!
* mime-types
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/var n=r(7426);var i=r(1017).extname;var a=/^\s*([^;\s]*)(?:;|\s|$)/;var o=/^text\//i;t.charset=charset;t.charsets={lookup:charset};t.contentType=contentType;t.extension=extension;t.extensions=Object.create(null);t.lookup=lookup;t.types=Object.create(null);populateMaps(t.extensions,t.types);function charset(e){if(!e||typeof e!=="string"){return false}var t=a.exec(e);var r=t&&n[t[1].toLowerCase()];if(r&&r.charset){return r.charset}if(t&&o.test(t[1])){return"UTF-8"}return false}function contentType(e){if(!e||typeof e!=="string"){return false}var r=e.indexOf("/")===-1?t.lookup(e):e;if(!r){return false}if(r.indexOf("charset")===-1){var n=t.charset(r);if(n)r+="; charset="+n.toLowerCase()}return r}function extension(e){if(!e||typeof e!=="string"){return false}var r=a.exec(e);var n=r&&t.extensions[r[1].toLowerCase()];if(!n||!n.length){return false}return n[0]}function lookup(e){if(!e||typeof e!=="string"){return false}var r=i("x."+e).toLowerCase().substr(1);if(!r){return false}return t.types[r]||false}function populateMaps(e,t){var r=["nginx","apache",undefined,"iana"];Object.keys(n).forEach((function forEachMimeType(i){var a=n[i];var o=a.extensions;if(!o||!o.length){return}e[i]=o;for(var s=0;s<o.length;s++){var c=o[s];if(t[c]){var l=r.indexOf(n[t[c]].source);var d=r.indexOf(a.source);if(t[c]!=="application/octet-stream"&&(l>d||l===d&&t[c].substr(0,12)==="application/")){continue}}t[c]=i}}))}},3973:(e,t,r)=>{e.exports=minimatch;minimatch.Minimatch=Minimatch;var n=function(){try{return r(1017)}catch(e){}}()||{sep:"/"};minimatch.sep=n.sep;var i=minimatch.GLOBSTAR=Minimatch.GLOBSTAR={};var a=r(8184);var o={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}};var s="[^/]";var c=s+"*?";var l="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";var d="(?:(?!(?:\\/|^)\\.).)*?";var p=charSet("().*{}+?[]^$\\!");function charSet(e){return e.split("").reduce((function(e,t){e[t]=true;return e}),{})}var u=/\/+/;minimatch.filter=filter;function filter(e,t){t=t||{};return function(r,n,i){return minimatch(r,e,t)}}function ext(e,t){t=t||{};var r={};Object.keys(e).forEach((function(t){r[t]=e[t]}));Object.keys(t).forEach((function(e){r[e]=t[e]}));return r}minimatch.defaults=function(e){if(!e||typeof e!=="object"||!Object.keys(e).length){return minimatch}var t=minimatch;var r=function minimatch(r,n,i){return t(r,n,ext(e,i))};r.Minimatch=function Minimatch(r,n){return new t.Minimatch(r,ext(e,n))};r.Minimatch.defaults=function defaults(r){return t.defaults(ext(e,r)).Minimatch};r.filter=function filter(r,n){return t.filter(r,ext(e,n))};r.defaults=function defaults(r){return t.defaults(ext(e,r))};r.makeRe=function makeRe(r,n){return t.makeRe(r,ext(e,n))};r.braceExpand=function braceExpand(r,n){return t.braceExpand(r,ext(e,n))};r.match=function(r,n,i){return t.match(r,n,ext(e,i))};return r};Minimatch.defaults=function(e){return minimatch.defaults(e).Minimatch};function minimatch(e,t,r){assertValidPattern(t);if(!r)r={};if(!r.nocomment&&t.charAt(0)==="#"){return false}return new Minimatch(t,r).match(e)}function Minimatch(e,t){if(!(this instanceof Minimatch)){return new Minimatch(e,t)}assertValidPattern(e);if(!t)t={};e=e.trim();if(!t.allowWindowsEscape&&n.sep!=="/"){e=e.split(n.sep).join("/")}this.options=t;this.set=[];this.pattern=e;this.regexp=null;this.negate=false;this.comment=false;this.empty=false;this.partial=!!t.partial;this.make()}Minimatch.prototype.debug=function(){};Minimatch.prototype.make=make;function make(){var e=this.pattern;var t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate();var r=this.globSet=this.braceExpand();if(t.debug)this.debug=function debug(){console.error.apply(console,arguments)};this.debug(this.pattern,r);r=this.globParts=r.map((function(e){return e.split(u)}));this.debug(this.pattern,r);r=r.map((function(e,t,r){return e.map(this.parse,this)}),this);this.debug(this.pattern,r);r=r.filter((function(e){return e.indexOf(false)===-1}));this.debug(this.pattern,r);thi
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */if(!String.fromCodePoint){(function(){var e=String.fromCharCode;var t=Math.floor;var fromCodePoint=function(){var r=16384;var n=[];var i;var a;var o=-1;var s=arguments.length;if(!s){return""}var c="";while(++o<s){var l=Number(arguments[o]);if(!isFinite(l)||l<0||l>1114111||t(l)!==l){throw RangeError("Invalid code point: "+l)}if(l<=65535){n.push(l)}else{l-=65536;i=(l>>10)+55296;a=l%1024+56320;n.push(i,a)}if(o+1===s||n.length>r){c+=e.apply(null,n);n.length=0}}return c};if(Object.defineProperty){Object.defineProperty(String,"fromCodePoint",{value:fromCodePoint,configurable:true,writable:true})}else{String.fromCodePoint=fromCodePoint}})()}})(false?0:t)},5911:(e,t)=>{t=e.exports=SemVer;var r;if(typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)){r=function(){var e=Array.prototype.slice.call(arguments,0);e.unshift("SEMVER");console.log.apply(console,e)}}else{r=function(){}}t.SEMVER_SPEC_VERSION="2.0.0";var n=256;var i=Number.MAX_SAFE_INTEGER||9007199254740991;var a=16;var o=n-6;var s=t.re=[];var c=t.safeRe=[];var l=t.src=[];var d=t.tokens={};var p=0;function tok(e){d[e]=p++}var u="[a-zA-Z0-9-]";var A=[["\\s",1],["\\d",n],[u,o]];function makeSafeRe(e){for(var t=0;t<A.length;t++){var r=A[t][0];var n=A[t][1];e=e.split(r+"*").join(r+"{0,"+n+"}").split(r+"+").join(r+"{1,"+n+"}")}return e}tok("NUMERICIDENTIFIER");l[d.NUMERICIDENTIFIER]="0|[1-9]\\d*";tok("NUMERICIDENTIFIERLOOSE");l[d.NUMERICIDENTIFIERLOOSE]="\\d+";tok("NONNUMERICIDENTIFIER");l[d.NONNUMERICIDENTIFIER]="\\d*[a-zA-Z-]"+u+"*";tok("MAINVERSION");l[d.MAINVERSION]="("+l[d.NUMERICIDENTIFIER]+")\\."+"("+l[d.NUMERICIDENTIFIER]+")\\."+"("+l[d.NUMERICIDENTIFIER]+")";tok("MAINVERSIONLOOSE");l[d.MAINVERSIONLOOSE]="("+l[d.NUMERICIDENTIFIERLOOSE]+")\\."+"("+l[d.NUMERICIDENTIFIERLOOSE]+")\\."+"("+l[d.NUMERICIDENTIFIERLOOSE]+")";tok("PRERELEASEIDENTIFIER");l[d.PRERELEASEIDENTIFIER]="(?:"+l[d.NUMERICIDENTIFIER]+"|"+l[d.NONNUMERICIDENTIFIER]+")";tok("PRERELEASEIDENTIFIERLOOSE");l[d.PRERELEASEIDENTIFIERLOOSE]="(?:"+l[d.NUMERICIDENTIFIERLOOSE]+"|"+l[d.NONNUMERICIDENTIFIER]+")";tok("PRERELEASE");l[d.PRERELEASE]="(?:-("+l[d.PRERELEASEIDENTIFIER]+"(?:\\."+l[d.PRERELEASEIDENTIFIER]+")*))";tok("PRERELEASELOOSE");l[d.PRERELEASELOOSE]="(?:-?("+l[d.PRERELEASEIDENTIFIERLOOSE]+"(?:\\."+l[d.PRERELEASEIDENTIFIERLOOSE]+")*))";tok("BUILDIDENTIFIER");l[d.BUILDIDENTIFIER]=u+"+";tok("BUILD");l[d.BUILD]="(?:\\+("+l[d.BUILDIDENTIFIER]+"(?:\\."+l[d.BUILDIDENTIFIER]+")*))";tok("FULL");tok("FULLPLAIN");l[d.FULLPLAIN]="v?"+l[d.MAINVERSION]+l[d.PRERELEASE]+"?"+l[d.BUILD]+"?";l[d.FULL]="^"+l[d.FULLPLAIN]+"$";tok("LOOSEPLAIN");l[d.LOOSEPLAIN]="[v=\\s]*"+l[d.MAINVERSIONLOOSE]+l[d.PRERELEASELOOSE]+"?"+l[d.BUILD]+"?";tok("LOOSE");l[d.LOOSE]="^"+l[d.LOOSEPLAIN]+"$";tok("GTLT");l[d.GTLT]="((?:<|>)?=?)";tok("XRANGEIDENTIFIERLOOSE");l[d.XRANGEIDENTIFIERLOOSE]=l[d.NUMERICIDENTIFIERLOOSE]+"|x|X|\\*";tok("XRANGEIDENTIFIER");l[d.XRANGEIDENTIFIER]=l[d.NUMERICIDENTIFIER]+"|x|X|\\*";tok("XRANGEPLAIN");l[d.XRANGEPLAIN]="[v=\\s]*("+l[d.XRANGEIDENTIFIER]+")"+"(?:\\.("+l[d.XRANGEIDENTIFIER]+")"+"(?:\\.("+l[d.XRANGEIDENTIFIER]+")"+"(?:"+l[d.PRERELEASE]+")?"+l[d.BUILD]+"?"+")?)?";tok("XRANGEPLAINLOOSE");l[d.XRANGEPLAINLOOSE]="[v=\\s]*("+l[d.XRANGEIDENTIFIERLOOSE]+")"+"(?:\\.("+l[d.XRANGEIDENTIFIERLOOSE]+")"+"(?:\\.("+l[d.XRANGEIDENTIFIERLOOSE]+")"+"(?:"+l[d.PRERELEASELOOSE]+")?"+l[d.BUILD]+"?"+")?)?";tok("XRANGE");l[d.XRANGE]="^"+l[d.GTLT]+"\\s*"+l[d.XRANGEPLAIN]+"$";tok("XRANGELOOSE");l[d.XRANGELOOSE]="^"+l[d.GTLT]+"\\s*"+l[d.XRANGEPLAINLOOSE]+"$";tok("COERCE");l[d.COERCE]="(^|[^\\d])"+"(\\d{1,"+a+"})"+"(?:\\.(\\d{1,"+a+"}))?"+"(?:\\.(\\d{1,"+a+"}))?"+"(?:$|[^\\d])";tok("COERCERTL");s[d.COERCERTL]=new RegExp(l[d.COERCE],"g");c[d.COERCERTL]=new RegExp(makeSafeRe(l[d.COERCE]),"g");tok("LONETILDE");l[d.LONETILDE]="(?:~>?)";tok("TILDETRIM");l[d.TILDETRIM]="(\\s*)"+l[d.LONETILDE]+"\\s+";s[d.TILDETRIM]=new RegExp(l[d.TILDETRIM],"g");c[d.TILDETRIM]=new RegExp(makeSafeRe(l[d.TILDETRIM]),"g");var m="$1~";tok("TILDE");l[d.TILDE]="^"+l
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */;const escape=e=>e.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22");const normalizeLinefeeds=e=>e.replace(/\r?\n|\r/g,"\r\n");const n=[];const i=new Uint8Array([13,10]);p=0;let a=false;for(const[t,o]of e){if(typeof o==="string"){const e=Q.encode(r+`; name="${escape(normalizeLinefeeds(t))}"`+`\r\n\r\n${normalizeLinefeeds(o)}\r\n`);n.push(e);p+=e.byteLength}else{const e=Q.encode(`${r}; name="${escape(normalizeLinefeeds(t))}"`+(o.name?`; filename="${escape(o.name)}"`:"")+"\r\n"+`Content-Type: ${o.type||"application/octet-stream"}\r\n\r\n`);n.push(e,o,i);if(typeof o.size==="number"){p+=e.byteLength+o.size+i.byteLength}else{a=true}}}const o=Q.encode(`--${t}--`);n.push(o);p+=o.byteLength;if(a){p=null}d=e;l=async function*(){for(const e of n){if(e.stream){yield*e.stream()}else{yield e}}};u="multipart/form-data; boundary="+t}else if(o(e)){d=e;p=e.size;if(e.type){u=e.type}}else if(typeof e[Symbol.asyncIterator]==="function"){if(t){throw new TypeError("keepalive")}if(i.isDisturbed(e)||e.locked){throw new TypeError("Response body object should not be disturbed or locked")}n=e instanceof w?e:a(e)}if(typeof d==="string"||i.isBuffer(d)){p=Buffer.byteLength(d)}if(l!=null){let t;n=new w({async start(){t=l(e)[Symbol.asyncIterator]()},async pull(e){const{value:r,done:i}=await t.next();if(i){queueMicrotask((()=>{e.close()}))}else{if(!C(n)){e.enqueue(new Uint8Array(r))}}return e.desiredSize>0},async cancel(e){await t.return()},type:undefined})}const A={stream:n,source:d,length:p};return[A,u]}function safelyExtractBody(e,t=false){if(!w){w=r(5356).ReadableStream}if(e instanceof w){E(!i.isDisturbed(e),"The body has already been consumed.");E(!e.locked,"The stream is locked.")}return extractBody(e,t)}function cloneBody(e){const[t,r]=e.stream.tee();const n=g(r,{transfer:[r]});const[,i]=n.tee();e.stream=t;return{stream:i,length:e.length,source:e.source}}async function*consumeBody(e){if(e){if(v(e)){yield e}else{const t=e.stream;if(i.isDisturbed(t)){throw new TypeError("The body has already been consumed.")}if(t.locked){throw new TypeError("The stream is locked.")}t[y]=true;yield*t}}}function throwIfAborted(e){if(e.aborted){throw new m("The operation was aborted.","AbortError")}}function bodyMixinMethods(e){const t={blob(){return specConsumeBody(this,(e=>{let t=bodyMimeType(this);if(t==="failure"){t=""}else if(t){t=S(t)}return new h([e],{type:t})}),e)},arrayBuffer(){return specConsumeBody(this,(e=>new Uint8Array(e).buffer),e)},text(){return specConsumeBody(this,utf8DecodeBytes,e)},json(){return specConsumeBody(this,parseJSONFromBytes,e)},async formData(){A.brandCheck(this,e);throwIfAborted(this[u]);const t=this.headers.get("Content-Type");if(/multipart\/form-data/.test(t)){const e={};for(const[t,r]of this.headers)e[t.toLowerCase()]=r;const t=new p;let r;try{r=new n({headers:e,preservePath:true})}catch(e){throw new m(`${e}`,"AbortError")}r.on("field",((e,r)=>{t.append(e,r)}));r.on("file",((e,r,n,i,a)=>{const o=[];if(i==="base64"||i.toLowerCase()==="base64"){let i="";r.on("data",(e=>{i+=e.toString().replace(/[\r\n]/gm,"");const t=i.length-i.length%4;o.push(Buffer.from(i.slice(0,t),"base64"));i=i.slice(t)}));r.on("end",(()=>{o.push(Buffer.from(i,"base64"));t.append(e,new x(o,n,{type:a}))}))}else{r.on("data",(e=>{o.push(e)}));r.on("end",(()=>{t.append(e,new x(o,n,{type:a}))}))}}));const i=new Promise(((e,t)=>{r.on("finish",e);r.on("error",(e=>t(new TypeError(e))))}));if(this.body!==null)for await(const e of consumeBody(this[u].body))r.write(e);r.end();await i;return t}else if(/application\/x-www-form-urlencoded/.test(t)){let e;try{let t="";const r=new TextDecoder("utf-8",{ignoreBOM:true});for await(const e of consumeBody(this[u].body)){if(!v(e)){throw new TypeError("Expected Uint8Array chunk")}t+=r.decode(e,{stream:true})}t+=r.decode();e=new URLSearchParams(t)}catch(e){throw Object.assign(new TypeError,{cause:e})}const t=new p;for(const[r,n]of e){t.append(r,n)}return t}else{await Promise.resolve();throwIfAborted(this[u]);throw A.errors.exception({he
/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */a[i-4]=this.maskKey[0];a[i-3]=this.maskKey[1];a[i-2]=this.maskKey[2];a[i-1]=this.maskKey[3];a[1]=r;if(r===126){a.writeUInt16BE(t,2)}else if(r===127){a[2]=a[3]=0;a.writeUIntBE(t,4,6)}a[1]|=128;for(let e=0;e<t;e++){a[i+e]=this.frameData[e]^this.maskKey[e%4]}return a}}e.exports={WebsocketFrameSend:WebsocketFrameSend}},1688:(e,t,r)=>{"use strict";const{Writable:n}=r(2781);const i=r(7643);const{parserStates:a,opcodes:o,states:s,emptyBuffer:c}=r(9188);const{kReadyState:l,kSentClose:d,kResponse:p,kReceivedClose:u}=r(7578);const{isValidStatusCode:A,failWebsocketConnection:m,websocketMessageReceived:g}=r(5515);const{WebsocketFrameSend:h}=r(5444);const f={};f.ping=i.channel("undici:websocket:ping");f.pong=i.channel("undici:websocket:pong");class ByteParser extends n{#o=[];#s=0;#c=a.INFO;#l={};#d=[];constructor(e){super();this.ws=e}_write(e,t,r){this.#o.push(e);this.#s+=e.length;this.run(r)}run(e){while(true){if(this.#c===a.INFO){if(this.#s<2){return e()}const t=this.consume(2);this.#l.fin=(t[0]&128)!==0;this.#l.opcode=t[0]&15;this.#l.originalOpcode??=this.#l.opcode;this.#l.fragmented=!this.#l.fin&&this.#l.opcode!==o.CONTINUATION;if(this.#l.fragmented&&this.#l.opcode!==o.BINARY&&this.#l.opcode!==o.TEXT){m(this.ws,"Invalid frame type was fragmented.");return}const r=t[1]&127;if(r<=125){this.#l.payloadLength=r;this.#c=a.READ_DATA}else if(r===126){this.#c=a.PAYLOADLENGTH_16}else if(r===127){this.#c=a.PAYLOADLENGTH_64}if(this.#l.fragmented&&r>125){m(this.ws,"Fragmented frame exceeded 125 bytes.");return}else if((this.#l.opcode===o.PING||this.#l.opcode===o.PONG||this.#l.opcode===o.CLOSE)&&r>125){m(this.ws,"Payload length for control frame exceeded 125 bytes.");return}else if(this.#l.opcode===o.CLOSE){if(r===1){m(this.ws,"Received close frame with a 1-byte body.");return}const e=this.consume(r);this.#l.closeInfo=this.parseCloseBody(false,e);if(!this.ws[d]){const e=Buffer.allocUnsafe(2);e.writeUInt16BE(this.#l.closeInfo.code,0);const t=new h(e);this.ws[p].socket.write(t.createFrame(o.CLOSE),(e=>{if(!e){this.ws[d]=true}}))}this.ws[l]=s.CLOSING;this.ws[u]=true;this.end();return}else if(this.#l.opcode===o.PING){const t=this.consume(r);if(!this.ws[u]){const e=new h(t);this.ws[p].socket.write(e.createFrame(o.PONG));if(f.ping.hasSubscribers){f.ping.publish({payload:t})}}this.#c=a.INFO;if(this.#s>0){continue}else{e();return}}else if(this.#l.opcode===o.PONG){const t=this.consume(r);if(f.pong.hasSubscribers){f.pong.publish({payload:t})}if(this.#s>0){continue}else{e();return}}}else if(this.#c===a.PAYLOADLENGTH_16){if(this.#s<2){return e()}const t=this.consume(2);this.#l.payloadLength=t.readUInt16BE(0);this.#c=a.READ_DATA}else if(this.#c===a.PAYLOADLENGTH_64){if(this.#s<8){return e()}const t=this.consume(8);const r=t.readUInt32BE(0);if(r>2**31-1){m(this.ws,"Received payload length > 2^31 bytes.");return}const n=t.readUInt32BE(4);this.#l.payloadLength=(r<<8)+n;this.#c=a.READ_DATA}else if(this.#c===a.READ_DATA){if(this.#s<this.#l.payloadLength){return e()}else if(this.#s>=this.#l.payloadLength){const e=this.consume(this.#l.payloadLength);this.#d.push(e);if(!this.#l.fragmented||this.#l.fin&&this.#l.opcode===o.CONTINUATION){const e=Buffer.concat(this.#d);g(this.ws,this.#l.originalOpcode,e);this.#l={};this.#d.length=0}this.#c=a.INFO}}if(this.#s>0){continue}else{e();break}}}consume(e){if(e>this.#s){return null}else if(e===0){return c}if(this.#o[0].length===e){this.#s-=this.#o[0].length;return this.#o.shift()}const t=Buffer.allocUnsafe(e);let r=0;while(r!==e){const n=this.#o[0];const{length:i}=n;if(i+r===e){t.set(this.#o.shift(),r);break}else if(i+r>e){t.set(n.subarray(0,e-r),r);this.#o[0]=n.subarray(e-r);break}else{t.set(this.#o.shift(),r);r+=n.length}}this.#s-=e;return t}parseCloseBody(e,t){let r;if(t.length>=2){r=t.readUInt16BE(0)}if(e){if(!A(r)){return null}return{code:r}}let n=t.subarray(2);if(n[0]===239&&n[1]===187&&n[2]===191){n=n.subarray(3)}if(r!==undefined&&!A(r)){return null}try{n=new TextDecoder("utf-8",{fatal:true}).decode(n)}catch{return null}return{code:r,reason:n}}get closingIn
//# sourceMappingURL=index.js.map