Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

it-ws

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

it-ws - npm Package Compare versions

Comparing version 6.1.1 to 6.1.2

2

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.ItWs = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var ItWs=(()=>{var nr=Object.create;var j=Object.defineProperty;var or=Object.getOwnPropertyDescriptor;var sr=Object.getOwnPropertyNames;var ir=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty;var ge=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),p=(e,r)=>{for(var t in r)j(e,t,{get:r[t],enumerable:!0})},ve=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of sr(r))!ar.call(e,o)&&o!==t&&j(e,o,{get:()=>r[o],enumerable:!(n=or(r,o))||n.enumerable});return e};var cr=(e,r,t)=>(t=e!=null?nr(ir(e)):{},ve(r||!e||!e.__esModule?j(t,"default",{value:e,enumerable:!0}):t,e)),dr=e=>ve(j({},"__esModule",{value:!0}),e);var Se=ge(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});var Z=class{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(r){if(this.isStopped)return;let t={value:r,done:!1};if(this.pullQueue.length){let n=this.pullQueue.shift();n&&n.resolve(t)}else this.pushQueue.push(Promise.resolve(t)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(let r of this.pullQueue)r.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(r){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(let t of this.pullQueue)t.reject(r);this.pullQueue.length=0}else{let t=Promise.reject(r);t.catch(()=>{}),this.pushQueue.push(t)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:r=>{let t=this.pushQueue.shift();return t?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),t):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((n,o)=>{this.pullQueue.push({resolve:n,reject:o})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}},R=class{constructor(r,{highWaterMark:t=100,lowWaterMark:n=1}={}){let o=new Z;o.highWaterMark=t,o.lowWaterMark=n,o.removeCallback=r({push:s=>o.push(s),stop:()=>o.stop(),fail:s=>o.fail(s),on:(s,i)=>{o.eventHandlers[s]=i}})||(()=>{}),this[Symbol.asyncIterator]=()=>o[Symbol.asyncIterator](),Object.freeze(this)}};q.EventIterator=R;q.default=R});var Ae=ge(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});var Y=Se();B.EventIterator=Y.EventIterator;function fr(e,r,t){return new Y.EventIterator(({push:n})=>(this.addEventListener(e,n,r),()=>this.removeEventListener(e,n,r)),t)}B.subscribe=fr;B.default=Y.EventIterator});var gt={};p(gt,{connect:()=>er,createServer:()=>void 0,duplex:()=>K,sink:()=>W,source:()=>X});var Ee=async e=>{if(e.readyState>=2)throw new Error("socket closed");e.readyState!==1&&await new Promise((r,t)=>{function n(){e.removeEventListener("open",o),e.removeEventListener("error",s)}function o(){n(),r()}function s(i){n(),t(i.error??new Error(`connect ECONNREFUSED ${e.url}`))}e.addEventListener("open",o),e.addEventListener("error",s)})};var W=(e,r)=>(r=r??{},r.closeOnEnd=r.closeOnEnd!==!1,async n=>{for await(let o of n){try{await Ee(e)}catch(s){if(s.message==="socket closed")break;throw s}if(e.readyState===e.CLOSING||e.readyState===e.CLOSED)break;e.send(o)}r.closeOnEnd!=null&&e.readyState<=1&&await new Promise((o,s)=>{e.addEventListener("close",i=>{if(i.wasClean||i.code===1006)o();else{let a=Object.assign(new Error("ws error"),{event:i});s(a)}}),setTimeout(()=>{e.close()})})});var Ze=cr(Ae(),1);function J(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}var te={};p(te,{base10:()=>br});function hr(e,r){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=e.length,f=e.charAt(0),m=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function u(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";for(var l=0,D=0,w=0,g=c.length;w!==g&&c[w]===0;)w++,l++;for(var v=(g-w)*h+1>>>0,b=new Uint8Array(v);w!==g;){for(var E=c[w],U=0,x=v-1;(E!==0||U<D)&&x!==-1;x--,U++)E+=256*b[x]>>>0,b[x]=E%a>>>0,E=E/a>>>0;if(E!==0)throw new Error("Non-zero carry");D=U,w++}for(var A=v-D;A!==v&&b[A]===0;)A++;for(var F=f.repeat(l);A<v;++A)F+=e.charAt(b[A]);return F}function y(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;var l=0;if(c[l]!==" "){for(var D=0,w=0;c[l]===f;)D++,l++;for(var g=(c.length-l)*m+1>>>0,v=new Uint8Array(g);c[l];){var b=t[c.charCodeAt(l)];if(b===255)return;for(var E=0,U=g-1;(b!==0||E<w)&&U!==-1;U--,E++)b+=a*v[U]>>>0,v[U]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");w=E,l++}if(c[l]!==" "){for(var x=g-w;x!==g&&v[x]===0;)x++;for(var A=new Uint8Array(D+(g-x)),F=D;x!==g;)A[F++]=v[x++];return A}}}function tr(c){var l=y(c);if(l)return l;throw new Error(`Non-${r} character`)}return{encode:u,decodeUnsafe:y,decode:tr}}var ur=hr,lr=ur,Ce=lr;var It=new Uint8Array(0);var Ue=(e,r)=>{if(e===r)return!0;if(e.byteLength!==r.byteLength)return!1;for(let t=0;t<e.byteLength;t++)if(e[t]!==r[t])return!1;return!0},C=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var Le=e=>new TextEncoder().encode(e),De=e=>new TextDecoder().decode(e);var _=class{constructor(r,t,n){this.name=r,this.prefix=t,this.baseEncode=n}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}},k=class{constructor(r,t,n){if(this.name=r,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return Oe(this,r)}},ee=class{constructor(r){this.decoders=r}or(r){return Oe(this,r)}decode(r){let t=r[0],n=this.decoders[t];if(n)return n.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Oe=(e,r)=>new ee({...e.decoders||{[e.prefix]:e},...r.decoders||{[r.prefix]:r}}),re=class{constructor(r,t,n,o){this.name=r,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new _(r,t,n),this.decoder=new k(r,t,o)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}},O=({name:e,prefix:r,encode:t,decode:n})=>new re(e,r,t,n),L=({prefix:e,name:r,alphabet:t})=>{let{encode:n,decode:o}=Ce(t,r);return O({prefix:e,name:r,encode:n,decode:s=>C(o(s))})},pr=(e,r,t,n)=>{let o={};for(let h=0;h<r.length;++h)o[r[h]]=h;let s=e.length;for(;e[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,f=0,m=0;for(let h=0;h<s;++h){let u=o[e[h]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<t|u,a+=t,a>=8&&(a-=8,i[m++]=255&f>>a)}if(a>=t||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return i},mr=(e,r,t)=>{let n=r[r.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let f=0;f<e.length;++f)for(a=a<<8|e[f],i+=8;i>t;)i-=t,s+=r[o&a>>i];if(i&&(s+=r[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},d=({name:e,prefix:r,bitsPerChar:t,alphabet:n})=>O({prefix:r,name:e,encode(o){return mr(o,n,t)},decode(o){return pr(o,n,t,e)}});var br=L({prefix:"9",name:"base10",alphabet:"0123456789"});var ne={};p(ne,{base16:()=>wr,base16upper:()=>xr});var wr=d({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),xr=d({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var oe={};p(oe,{base2:()=>yr});var yr=d({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var se={};p(se,{base256emoji:()=>Ar});var Pe=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),gr=Pe.reduce((e,r,t)=>(e[t]=r,e),[]),vr=Pe.reduce((e,r,t)=>(e[r.codePointAt(0)]=t,e),[]);function Er(e){return e.reduce((r,t)=>(r+=gr[t],r),"")}function Sr(e){let r=[];for(let t of e){let n=vr[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);r.push(n)}return new Uint8Array(r)}var Ar=O({prefix:"\u{1F680}",name:"base256emoji",encode:Er,decode:Sr});var ie={};p(ie,{base32:()=>P,base32hex:()=>Dr,base32hexpad:()=>Or,base32hexpadupper:()=>Pr,base32hexupper:()=>Ir,base32pad:()=>Ur,base32padupper:()=>Lr,base32upper:()=>Cr,base32z:()=>Nr});var P=d({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cr=d({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ur=d({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Lr=d({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Dr=d({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ir=d({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Or=d({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Pr=d({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Nr=d({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ae={};p(ae,{base36:()=>Tr,base36upper:()=>Mr});var Tr=L({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Mr=L({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ce={};p(ce,{base58btc:()=>S,base58flickr:()=>Br});var S=L({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Br=L({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var de={};p(de,{base64:()=>zr,base64pad:()=>$r,base64url:()=>Qr,base64urlpad:()=>Vr});var zr=d({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$r=d({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Qr=d({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Vr=d({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fe={};p(fe,{base8:()=>Fr});var Fr=d({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var he={};p(he,{identity:()=>jr});var jr=O({prefix:"\0",name:"identity",encode:e=>De(e),decode:e=>Le(e)});var qt=new TextEncoder,Jt=new TextDecoder;var le={};p(le,{identity:()=>ft});var qr=Me,Ne=128,Jr=127,Hr=~Jr,Gr=Math.pow(2,31);function Me(e,r,t){r=r||[],t=t||0;for(var n=t;e>=Gr;)r[t++]=e&255|Ne,e/=128;for(;e&Hr;)r[t++]=e&255|Ne,e>>>=7;return r[t]=e|0,Me.bytes=t-n+1,r}var Xr=ue,Kr=128,Te=127;function ue(e,n){var t=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw ue.bytes=0,new RangeError("Could not decode varint");i=e[s++],t+=o<28?(i&Te)<<o:(i&Te)*Math.pow(2,o),o+=7}while(i>=Kr);return ue.bytes=s-n,t}var Zr=Math.pow(2,7),Yr=Math.pow(2,14),_r=Math.pow(2,21),kr=Math.pow(2,28),et=Math.pow(2,35),rt=Math.pow(2,42),tt=Math.pow(2,49),nt=Math.pow(2,56),ot=Math.pow(2,63),st=function(e){return e<Zr?1:e<Yr?2:e<_r?3:e<kr?4:e<et?5:e<rt?6:e<tt?7:e<nt?8:e<ot?9:10},it={encode:qr,decode:Xr,encodingLength:st},at=it,z=at;var $=(e,r=0)=>[z.decode(e,r),z.decode.bytes],N=(e,r,t=0)=>(z.encode(e,r,t),r),T=e=>z.encodingLength(e);var I=(e,r)=>{let t=r.byteLength,n=T(e),o=n+T(t),s=new Uint8Array(o+t);return N(e,s,0),N(t,s,n),s.set(r,o),new M(e,t,r,s)},Be=e=>{let r=C(e),[t,n]=$(r),[o,s]=$(r.subarray(n)),i=r.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new M(t,o,i,r)},ze=(e,r)=>{if(e===r)return!0;{let t=r;return e.code===t.code&&e.size===t.size&&t.bytes instanceof Uint8Array&&Ue(e.bytes,t.bytes)}},M=class{constructor(r,t,n,o){this.code=r,this.size=t,this.digest=n,this.bytes=o}};var $e=0,ct="identity",Qe=C,dt=e=>I($e,Qe(e)),ft={code:$e,name:ct,encode:Qe,digest:dt};var be={};p(be,{sha256:()=>ht,sha512:()=>ut});var me=({name:e,code:r,encode:t})=>new pe(e,r,t),pe=class{constructor(r,t,n){this.name=r,this.code=t,this.encode=n}digest(r){if(r instanceof Uint8Array){let t=this.encode(r);return t instanceof Uint8Array?I(this.code,t):t.then(n=>I(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Fe=e=>async r=>new Uint8Array(await crypto.subtle.digest(e,r)),ht=me({name:"sha2-256",code:18,encode:Fe("SHA-256")}),ut=me({name:"sha2-512",code:19,encode:Fe("SHA-512")});var je=(e,r)=>{let{bytes:t,version:n}=e;switch(n){case 0:return pt(t,we(e),r||S.encoder);default:return mt(t,we(e),r||P.encoder)}};var We=new WeakMap,we=e=>{let r=We.get(e);if(r==null){let t=new Map;return We.set(e,t),t}return r},G=class e{constructor(r,t,n,o){this.code=t,this.version=r,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:r,multihash:t}=this;if(r!==V)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==bt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:r,digest:t}=this.multihash,n=I(r,t);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(r){return e.equals(this,r)}static equals(r,t){let n=t;return n&&r.code===n.code&&r.version===n.version&&ze(r.multihash,n.multihash)}toString(r){return je(this,r)}toJSON(){return{"/":je(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(r){if(r==null)return null;let t=r;if(t instanceof e)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new e(n,o,s,i||Re(n,o,s.bytes))}else if(t[wt]===!0){let{version:n,multihash:o,code:s}=t,i=Be(o);return e.create(n,s,i)}else return null}static create(r,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(r){case 0:{if(t!==V)throw new Error(`Version 0 CID must use dag-pb (code: ${V}) block encoding`);return new e(r,t,n,n.bytes)}case 1:{let o=Re(r,t,n.bytes);return new e(r,t,n,o)}default:throw new Error("Invalid version")}}static createV0(r){return e.create(0,V,r)}static createV1(r,t){return e.create(1,r,t)}static decode(r){let[t,n]=e.decodeFirst(r);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(r){let t=e.inspectBytes(r),n=t.size-t.multihashSize,o=C(r.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new M(t.multihashCode,t.digestSize,s,o);return[t.version===0?e.createV0(i):e.createV1(t.codec,i),r.subarray(t.size)]}static inspectBytes(r){let t=0,n=()=>{let[u,y]=$(r.subarray(t));return t+=y,u},o=n(),s=V;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),f=n(),m=t+f,h=m-i;return{version:o,codec:s,multihashCode:a,digestSize:f,multihashSize:h,size:m}}static parse(r,t){let[n,o]=lt(r,t),s=e.decode(o);if(s.version===0&&r[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return we(s).set(n,r),s}},lt=(e,r)=>{switch(e[0]){case"Q":{let t=r||S;return[S.prefix,t.decode(`${S.prefix}${e}`)]}case S.prefix:{let t=r||S;return[S.prefix,t.decode(e)]}case P.prefix:{let t=r||P;return[P.prefix,t.decode(e)]}default:{if(r==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],r.decode(e)]}}},pt=(e,r,t)=>{let{prefix:n}=t;if(n!==S.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=r.get(n);if(o==null){let s=t.encode(e).slice(1);return r.set(n,s),s}else return o},mt=(e,r,t)=>{let{prefix:n}=t,o=r.get(n);if(o==null){let s=t.encode(e);return r.set(n,s),s}else return o},V=112,bt=18,Re=(e,r,t)=>{let n=T(e),o=n+T(r),s=new Uint8Array(o+t.byteLength);return N(e,s,0),N(r,s,n),s.set(t,o),s},wt=Symbol.for("@ipld/js-cid/CID");var xe={...he,...oe,...fe,...te,...ne,...ie,...ae,...ce,...de,...se},cn={...be,...le};function qe(e=0){return globalThis.Buffer?.allocUnsafe!=null?J(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function He(e,r,t,n){return{name:e,prefix:r,encoder:{name:e,prefix:r,encode:t},decoder:{decode:n}}}var Je=He("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),ye=He("ascii","a",e=>{let r="a";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return r},e=>{e=e.substring(1);let r=qe(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r}),xt={utf8:Je,"utf-8":Je,hex:xe.base16,latin1:ye,ascii:ye,binary:ye,...xe},Ge=xt;function Xe(e,r="utf8"){let t=Ge[r];if(t==null)throw new Error(`Unsupported encoding "${r}"`);return(r==="utf8"||r==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?J(globalThis.Buffer.from(e,"utf-8")):t.decoder.decode(`${t.prefix}${e}`)}function Ke(e){return e instanceof ArrayBuffer||e?.constructor?.name==="ArrayBuffer"&&typeof e?.byteLength=="number"}var X=e=>{e.binaryType="arraybuffer";let r=async()=>{await new Promise((s,i)=>{if(n){s();return}if(o!=null){i(o);return}let a=h=>{e.removeEventListener("open",f),e.removeEventListener("error",m),h()},f=()=>{a(s)},m=h=>{a(()=>{i(h.error??new Error(`connect ECONNREFUSED ${e.url}`))})};e.addEventListener("open",f),e.addEventListener("error",m)})},t=async function*(){let s=new Ze.EventIterator(({push:i,stop:a,fail:f})=>{let m=u=>{let y=null;typeof u.data=="string"&&(y=Xe(u.data)),Ke(u.data)&&(y=new Uint8Array(u.data)),u.data instanceof Uint8Array&&(y=u.data),y!=null&&i(y)},h=u=>{f(u.error??new Error("Socket error"))};return e.addEventListener("message",m),e.addEventListener("error",h),e.addEventListener("close",a),()=>{e.removeEventListener("message",m),e.removeEventListener("error",h),e.removeEventListener("close",a)}},{highWaterMark:1/0});await r();for await(let i of s)yield Ke(i)?new Uint8Array(i):i}(),n=e.readyState===1,o;return e.addEventListener("open",()=>{n=!0,o=null}),e.addEventListener("close",()=>{n=!1,o=null}),e.addEventListener("error",s=>{n||(o=s.error??new Error(`connect ECONNREFUSED ${e.url}`))}),Object.assign(t,{connected:r})};var K=(e,r)=>{r=r??{};let t=X(e),n=r.remoteAddress,o=r.remotePort;if(e.url!=null)try{let i=new URL(e.url);n=i.hostname,o=parseInt(i.port,10)}catch{}if(n==null||o==null)throw new Error("Remote connection did not have address and/or port");return{sink:W(e,r),source:t,connected:async()=>{await t.connected()},close:async()=>{(e.readyState===e.CONNECTING||e.readyState===e.OPEN)&&await new Promise(i=>{e.addEventListener("close",()=>{i()}),e.close()})},destroy:()=>{e.terminate!=null?e.terminate():e.close()},remoteAddress:n,remotePort:o,socket:e}};var Ye=WebSocket;var yt={"http:":"ws:","https:":"wss:"},_e="ws:",ke=(e,r)=>{if(e.startsWith("//")&&(e=`${r?.protocol??_e}${e}`),e.startsWith("/")&&r!=null){let n=r.protocol??_e,o=r.host,s=r.port!=null&&o?.endsWith(`:${r.port}`)!==!0?`:${r.port}`:"";e=`${n}//${o}${s}${e}`}let t=new URL(e);for(let[n,o]of Object.entries(yt))t.protocol===n&&(t.protocol=o);return t};function er(e,r){let t=typeof window>"u"?void 0:window.location;r=r??{};let n=ke(e,t),o=new Ye(n.toString(),r.websocket);return K(o,r)}return dr(gt);})();
"use strict";var ItWs=(()=>{var tr=Object.create;var j=Object.defineProperty;var nr=Object.getOwnPropertyDescriptor;var or=Object.getOwnPropertyNames;var sr=Object.getPrototypeOf,ir=Object.prototype.hasOwnProperty;var ye=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),l=(e,r)=>{for(var t in r)j(e,t,{get:r[t],enumerable:!0})},ge=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of or(r))!ir.call(e,o)&&o!==t&&j(e,o,{get:()=>r[o],enumerable:!(n=nr(r,o))||n.enumerable});return e};var ar=(e,r,t)=>(t=e!=null?tr(sr(e)):{},ge(r||!e||!e.__esModule?j(t,"default",{value:e,enumerable:!0}):t,e)),cr=e=>ge(j({},"__esModule",{value:!0}),e);var Ee=ye(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});var K=class{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(r){if(this.isStopped)return;let t={value:r,done:!1};if(this.pullQueue.length){let n=this.pullQueue.shift();n&&n.resolve(t)}else this.pushQueue.push(Promise.resolve(t)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(let r of this.pullQueue)r.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(r){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(let t of this.pullQueue)t.reject(r);this.pullQueue.length=0}else{let t=Promise.reject(r);t.catch(()=>{}),this.pushQueue.push(t)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:r=>{let t=this.pushQueue.shift();return t?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),t):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((n,o)=>{this.pullQueue.push({resolve:n,reject:o})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}},R=class{constructor(r,{highWaterMark:t=100,lowWaterMark:n=1}={}){let o=new K;o.highWaterMark=t,o.lowWaterMark=n,o.removeCallback=r({push:s=>o.push(s),stop:()=>o.stop(),fail:s=>o.fail(s),on:(s,i)=>{o.eventHandlers[s]=i}})||(()=>{}),this[Symbol.asyncIterator]=()=>o[Symbol.asyncIterator](),Object.freeze(this)}};q.EventIterator=R;q.default=R});var Se=ye(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});var Z=Ee();T.EventIterator=Z.EventIterator;function dr(e,r,t){return new Z.EventIterator(({push:n})=>(this.addEventListener(e,n,r),()=>this.removeEventListener(e,n,r)),t)}T.subscribe=dr;T.default=Z.EventIterator});var yt={};l(yt,{connect:()=>ke,createServer:()=>void 0,duplex:()=>X,sink:()=>W,source:()=>G});var ve=async e=>{if(e.readyState>=2)throw new Error("socket closed");e.readyState!==1&&await new Promise((r,t)=>{function n(){e.removeEventListener("open",o),e.removeEventListener("error",s)}function o(){n(),r()}function s(i){n(),t(i.error??new Error(`connect ECONNREFUSED ${e.url}`))}e.addEventListener("open",o),e.addEventListener("error",s)})};var W=(e,r)=>(r=r??{},r.closeOnEnd=r.closeOnEnd!==!1,async n=>{for await(let o of n){try{await ve(e)}catch(s){if(s.message==="socket closed")break;throw s}if(e.readyState===e.CLOSING||e.readyState===e.CLOSED)break;e.send(o)}r.closeOnEnd!=null&&e.readyState<=1&&await new Promise((o,s)=>{e.addEventListener("close",i=>{if(i.wasClean||i.code===1006)o();else{let a=Object.assign(new Error("ws error"),{event:i});s(a)}}),setTimeout(()=>{e.close()})})});var Ke=ar(Se(),1);var re={};l(re,{base10:()=>mr});var Ut=new Uint8Array(0);function Ce(e,r){if(e===r)return!0;if(e.byteLength!==r.byteLength)return!1;for(let t=0;t<e.byteLength;t++)if(e[t]!==r[t])return!1;return!0}function A(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function Ae(e){return new TextEncoder().encode(e)}function Ue(e){return new TextDecoder().decode(e)}function fr(e,r){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=e.length,f=e.charAt(0),m=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";for(var p=0,L=0,x=0,g=c.length;x!==g&&c[x]===0;)x++,p++;for(var v=(g-x)*u+1>>>0,b=new Uint8Array(v);x!==g;){for(var E=c[x],U=0,w=v-1;(E!==0||U<L)&&w!==-1;w--,U++)E+=256*b[w]>>>0,b[w]=E%a>>>0,E=E/a>>>0;if(E!==0)throw new Error("Non-zero carry");L=U,x++}for(var C=v-L;C!==v&&b[C]===0;)C++;for(var F=f.repeat(p);C<v;++C)F+=e.charAt(b[C]);return F}function y(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;var p=0;if(c[p]!==" "){for(var L=0,x=0;c[p]===f;)L++,p++;for(var g=(c.length-p)*m+1>>>0,v=new Uint8Array(g);c[p];){var b=t[c.charCodeAt(p)];if(b===255)return;for(var E=0,U=g-1;(b!==0||E<x)&&U!==-1;U--,E++)b+=a*v[U]>>>0,v[U]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");x=E,p++}if(c[p]!==" "){for(var w=g-x;w!==g&&v[w]===0;)w++;for(var C=new Uint8Array(L+(g-w)),F=L;w!==g;)C[F++]=v[w++];return C}}}function rr(c){var p=y(c);if(p)return p;throw new Error(`Non-${r} character`)}return{encode:h,decodeUnsafe:y,decode:rr}}var ur=fr,hr=ur,Le=hr;var Y=class{name;prefix;baseEncode;constructor(r,t,n){this.name=r,this.prefix=t,this.baseEncode=n}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}},_=class{name;prefix;baseDecode;prefixCodePoint;constructor(r,t,n){if(this.name=r,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return Ie(this,r)}},k=class{decoders;constructor(r){this.decoders=r}or(r){return Ie(this,r)}decode(r){let t=r[0],n=this.decoders[t];if(n!=null)return n.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ie(e,r){return new k({...e.decoders??{[e.prefix]:e},...r.decoders??{[r.prefix]:r}})}var ee=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(r,t,n,o){this.name=r,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Y(r,t,n),this.decoder=new _(r,t,o)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}};function O({name:e,prefix:r,encode:t,decode:n}){return new ee(e,r,t,n)}function D({name:e,prefix:r,alphabet:t}){let{encode:n,decode:o}=Le(t,e);return O({prefix:r,name:e,encode:n,decode:s=>A(o(s))})}function pr(e,r,t,n){let o={};for(let u=0;u<r.length;++u)o[r[u]]=u;let s=e.length;for(;e[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,f=0,m=0;for(let u=0;u<s;++u){let h=o[e[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<t|h,a+=t,a>=8&&(a-=8,i[m++]=255&f>>a)}if(a>=t||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return i}function lr(e,r,t){let n=r[r.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let f=0;f<e.length;++f)for(a=a<<8|e[f],i+=8;i>t;)i-=t,s+=r[o&a>>i];if(i!==0&&(s+=r[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s}function d({name:e,prefix:r,bitsPerChar:t,alphabet:n}){return O({prefix:r,name:e,encode(o){return lr(o,n,t)},decode(o){return pr(o,n,t,e)}})}var mr=D({prefix:"9",name:"base10",alphabet:"0123456789"});var te={};l(te,{base16:()=>br,base16upper:()=>xr});var br=d({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),xr=d({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ne={};l(ne,{base2:()=>wr});var wr=d({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oe={};l(oe,{base256emoji:()=>Sr});var Oe=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),yr=Oe.reduce((e,r,t)=>(e[t]=r,e),[]),gr=Oe.reduce((e,r,t)=>(e[r.codePointAt(0)]=t,e),[]);function vr(e){return e.reduce((r,t)=>(r+=yr[t],r),"")}function Er(e){let r=[];for(let t of e){let n=gr[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);r.push(n)}return new Uint8Array(r)}var Sr=O({prefix:"\u{1F680}",name:"base256emoji",encode:vr,decode:Er});var se={};l(se,{base32:()=>P,base32hex:()=>Dr,base32hexpad:()=>Ir,base32hexpadupper:()=>Or,base32hexupper:()=>Lr,base32pad:()=>Ar,base32padupper:()=>Ur,base32upper:()=>Cr,base32z:()=>Pr});var P=d({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cr=d({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ar=d({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ur=d({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Dr=d({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Lr=d({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ir=d({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Or=d({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Pr=d({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ie={};l(ie,{base36:()=>Nr,base36upper:()=>Mr});var Nr=D({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Mr=D({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ae={};l(ae,{base58btc:()=>S,base58flickr:()=>zr});var S=D({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),zr=D({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ce={};l(ce,{base64:()=>Tr,base64pad:()=>$r,base64url:()=>Br,base64urlpad:()=>Qr});var Tr=d({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$r=d({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Br=d({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qr=d({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var de={};l(de,{base8:()=>Vr});var Vr=d({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fe={};l(fe,{identity:()=>Fr});var Fr=O({prefix:"\0",name:"identity",encode:e=>Ue(e),decode:e=>Ae(e)});var Wt=new TextEncoder,Rt=new TextDecoder;var he={};l(he,{identity:()=>dt});var Rr=Me,Pe=128,qr=127,Jr=~qr,Hr=Math.pow(2,31);function Me(e,r,t){r=r||[],t=t||0;for(var n=t;e>=Hr;)r[t++]=e&255|Pe,e/=128;for(;e&Jr;)r[t++]=e&255|Pe,e>>>=7;return r[t]=e|0,Me.bytes=t-n+1,r}var Gr=ue,Xr=128,Ne=127;function ue(e,n){var t=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw ue.bytes=0,new RangeError("Could not decode varint");i=e[s++],t+=o<28?(i&Ne)<<o:(i&Ne)*Math.pow(2,o),o+=7}while(i>=Xr);return ue.bytes=s-n,t}var Kr=Math.pow(2,7),Zr=Math.pow(2,14),Yr=Math.pow(2,21),_r=Math.pow(2,28),kr=Math.pow(2,35),et=Math.pow(2,42),rt=Math.pow(2,49),tt=Math.pow(2,56),nt=Math.pow(2,63),ot=function(e){return e<Kr?1:e<Zr?2:e<Yr?3:e<_r?4:e<kr?5:e<et?6:e<rt?7:e<tt?8:e<nt?9:10},st={encode:Rr,decode:Gr,encodingLength:ot},it=st,$=it;function B(e,r=0){return[$.decode(e,r),$.decode.bytes]}function N(e,r,t=0){return $.encode(e,r,t),r}function M(e){return $.encodingLength(e)}function I(e,r){let t=r.byteLength,n=M(e),o=n+M(t),s=new Uint8Array(o+t);return N(e,s,0),N(t,s,n),s.set(r,o),new z(e,t,r,s)}function ze(e){let r=A(e),[t,n]=B(r),[o,s]=B(r.subarray(n)),i=r.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new z(t,o,i,r)}function Te(e,r){if(e===r)return!0;{let t=r;return e.code===t.code&&e.size===t.size&&t.bytes instanceof Uint8Array&&Ce(e.bytes,t.bytes)}}var z=class{code;size;digest;bytes;constructor(r,t,n,o){this.code=r,this.size=t,this.digest=n,this.bytes=o}};var $e=0,at="identity",Be=A;function ct(e){return I($e,Be(e))}var dt={code:$e,name:at,encode:Be,digest:ct};var me={};l(me,{sha256:()=>ft,sha512:()=>ut});function le({name:e,code:r,encode:t}){return new pe(e,r,t)}var pe=class{name;code;encode;constructor(r,t,n){this.name=r,this.code=t,this.encode=n}digest(r){if(r instanceof Uint8Array){let t=this.encode(r);return t instanceof Uint8Array?I(this.code,t):t.then(n=>I(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ve(e){return async r=>new Uint8Array(await crypto.subtle.digest(e,r))}var ft=le({name:"sha2-256",code:18,encode:Ve("SHA-256")}),ut=le({name:"sha2-512",code:19,encode:Ve("SHA-512")});function Fe(e,r){let{bytes:t,version:n}=e;switch(n){case 0:return pt(t,be(e),r??S.encoder);default:return lt(t,be(e),r??P.encoder)}}var je=new WeakMap;function be(e){let r=je.get(e);if(r==null){let t=new Map;return je.set(e,t),t}return r}var H=class e{code;version;multihash;bytes;"/";constructor(r,t,n,o){this.code=t,this.version=r,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:r,multihash:t}=this;if(r!==V)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==mt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:r,digest:t}=this.multihash,n=I(r,t);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(r){return e.equals(this,r)}static equals(r,t){let n=t;return n!=null&&r.code===n.code&&r.version===n.version&&Te(r.multihash,n.multihash)}toString(r){return Fe(this,r)}toJSON(){return{"/":Fe(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(r){if(r==null)return null;let t=r;if(t instanceof e)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new e(n,o,s,i??We(n,o,s.bytes))}else if(t[bt]===!0){let{version:n,multihash:o,code:s}=t,i=ze(o);return e.create(n,s,i)}else return null}static create(r,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(r){case 0:{if(t!==V)throw new Error(`Version 0 CID must use dag-pb (code: ${V}) block encoding`);return new e(r,t,n,n.bytes)}case 1:{let o=We(r,t,n.bytes);return new e(r,t,n,o)}default:throw new Error("Invalid version")}}static createV0(r){return e.create(0,V,r)}static createV1(r,t){return e.create(1,r,t)}static decode(r){let[t,n]=e.decodeFirst(r);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(r){let t=e.inspectBytes(r),n=t.size-t.multihashSize,o=A(r.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new z(t.multihashCode,t.digestSize,s,o);return[t.version===0?e.createV0(i):e.createV1(t.codec,i),r.subarray(t.size)]}static inspectBytes(r){let t=0,n=()=>{let[h,y]=B(r.subarray(t));return t+=y,h},o=n(),s=V;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),f=n(),m=t+f,u=m-i;return{version:o,codec:s,multihashCode:a,digestSize:f,multihashSize:u,size:m}}static parse(r,t){let[n,o]=ht(r,t),s=e.decode(o);if(s.version===0&&r[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return be(s).set(n,r),s}};function ht(e,r){switch(e[0]){case"Q":{let t=r??S;return[S.prefix,t.decode(`${S.prefix}${e}`)]}case S.prefix:{let t=r??S;return[S.prefix,t.decode(e)]}case P.prefix:{let t=r??P;return[P.prefix,t.decode(e)]}default:{if(r==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],r.decode(e)]}}}function pt(e,r,t){let{prefix:n}=t;if(n!==S.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=r.get(n);if(o==null){let s=t.encode(e).slice(1);return r.set(n,s),s}else return o}function lt(e,r,t){let{prefix:n}=t,o=r.get(n);if(o==null){let s=t.encode(e);return r.set(n,s),s}else return o}var V=112,mt=18;function We(e,r,t){let n=M(e),o=n+M(r),s=new Uint8Array(o+t.byteLength);return N(e,s,0),N(r,s,n),s.set(t,o),s}var bt=Symbol.for("@ipld/js-cid/CID");var xe={...fe,...ne,...de,...re,...te,...se,...ie,...ae,...ce,...oe},un={...me,...he};function Re(e=0){return new Uint8Array(e)}function Je(e,r,t,n){return{name:e,prefix:r,encoder:{name:e,prefix:r,encode:t},decoder:{decode:n}}}var qe=Je("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),we=Je("ascii","a",e=>{let r="a";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return r},e=>{e=e.substring(1);let r=Re(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r}),xt={utf8:qe,"utf-8":qe,hex:xe.base16,latin1:we,ascii:we,binary:we,...xe},He=xt;function Ge(e,r="utf8"){let t=He[r];if(t==null)throw new Error(`Unsupported encoding "${r}"`);return t.decoder.decode(`${t.prefix}${e}`)}function Xe(e){return e instanceof ArrayBuffer||e?.constructor?.name==="ArrayBuffer"&&typeof e?.byteLength=="number"}var G=e=>{e.binaryType="arraybuffer";let r=async()=>{await new Promise((s,i)=>{if(n){s();return}if(o!=null){i(o);return}let a=u=>{e.removeEventListener("open",f),e.removeEventListener("error",m),u()},f=()=>{a(s)},m=u=>{a(()=>{i(u.error??new Error(`connect ECONNREFUSED ${e.url}`))})};e.addEventListener("open",f),e.addEventListener("error",m)})},t=async function*(){let s=new Ke.EventIterator(({push:i,stop:a,fail:f})=>{let m=h=>{let y=null;typeof h.data=="string"&&(y=Ge(h.data)),Xe(h.data)&&(y=new Uint8Array(h.data)),h.data instanceof Uint8Array&&(y=h.data),y!=null&&i(y)},u=h=>{f(h.error??new Error("Socket error"))};return e.addEventListener("message",m),e.addEventListener("error",u),e.addEventListener("close",a),()=>{e.removeEventListener("message",m),e.removeEventListener("error",u),e.removeEventListener("close",a)}},{highWaterMark:1/0});await r();for await(let i of s)yield Xe(i)?new Uint8Array(i):i}(),n=e.readyState===1,o;return e.addEventListener("open",()=>{n=!0,o=null}),e.addEventListener("close",()=>{n=!1,o=null}),e.addEventListener("error",s=>{n||(o=s.error??new Error(`connect ECONNREFUSED ${e.url}`))}),Object.assign(t,{connected:r})};var X=(e,r)=>{r=r??{};let t=G(e),n=r.remoteAddress,o=r.remotePort;if(e.url!=null)try{let i=new URL(e.url);n=i.hostname,o=parseInt(i.port,10)}catch{}if(n==null||o==null)throw new Error("Remote connection did not have address and/or port");return{sink:W(e,r),source:t,connected:async()=>{await t.connected()},close:async()=>{(e.readyState===e.CONNECTING||e.readyState===e.OPEN)&&await new Promise(i=>{e.addEventListener("close",()=>{i()}),e.close()})},destroy:()=>{e.terminate!=null?e.terminate():e.close()},remoteAddress:n,remotePort:o,socket:e}};var Ze=WebSocket;var wt={"http:":"ws:","https:":"wss:"},Ye="ws:",_e=(e,r)=>{if(e.startsWith("//")&&(e=`${r?.protocol??Ye}${e}`),e.startsWith("/")&&r!=null){let n=r.protocol??Ye,o=r.host,s=r.port!=null&&o?.endsWith(`:${r.port}`)!==!0?`:${r.port}`:"";e=`${n}//${o}${s}${e}`}let t=new URL(e);for(let[n,o]of Object.entries(wt))t.protocol===n&&(t.protocol=o);return t};function ke(e,r){let t=typeof window>"u"?void 0:window.location;r=r??{};let n=_e(e,t),o=new Ze(n.toString(),r.websocket);return X(o,r)}return cr(yt);})();
return ItWs}));
{
"name": "it-ws",
"version": "6.1.1",
"version": "6.1.2",
"description": "Simple async iterables for websocket client connections",

@@ -15,2 +15,6 @@ "author": "Alan Shaw",

},
"publishConfig": {
"access": "public",
"provenance": true
},
"keywords": [

@@ -76,2 +80,7 @@ "async",

"import": "./dist/src/source.js"
},
"./web-socket": {
"types": "./dist/src/web-socket.d.ts",
"import": "./dist/src/web-socket.js",
"browser": "./dist/src/web-socket.browser.js"
}

@@ -78,0 +87,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc