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

@chirper/node

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chirper/node - npm Package Compare versions

Comparing version 0.0.23 to 0.0.24

2

dist/bundle.js

@@ -1,1 +0,1 @@

var tt=Object.create;var C=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var N=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),nt=(i,t)=>{for(var e in t)C(i,e,{get:t[e],enumerable:!0})},F=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of it(t))!rt.call(i,n)&&n!==e&&C(i,n,{get:()=>t[n],enumerable:!(s=et(t,n))||s.enumerable});return i};var L=(i,t,e)=>(e=i!=null?tt(st(i)):{},F(t||!i||!i.__esModule?C(e,"default",{value:i,enumerable:!0}):e,i)),ot=i=>F(C({},"__esModule",{value:!0}),i);var T=N((ft,E)=>{var U=(()=>{var i=Object.defineProperty,t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,n=($,p,d)=>p in $?i($,p,{enumerable:!0,configurable:!0,writable:!0,value:d}):$[p]=d,c=($,p)=>{for(var d in p||(p={}))e.call(p,d)&&n($,d,p[d]);if(t)for(var d of t(p))s.call(p,d)&&n($,d,p[d]);return $},h=$=>i($,"__esModule",{value:!0}),a=($,p)=>{h($);for(var d in p)i($,d,{get:p[d],enumerable:!0})},r={};a(r,{DEFAULT_UUID_LENGTH:()=>y,default:()=>w});var m="4.4.4",y=6,l={dictionary:"alphanum",shuffle:!0,debug:!1,length:y},b=class extends Function{constructor($={}){super(),this.dictIndex=0,this.dictRange=[],this.lowerBound=0,this.upperBound=0,this.dictLength=0,this._digit_first_ascii=48,this._digit_last_ascii=58,this._alpha_lower_first_ascii=97,this._alpha_lower_last_ascii=123,this._hex_last_ascii=103,this._alpha_upper_first_ascii=65,this._alpha_upper_last_ascii=91,this._number_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii]},this._alpha_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alpha_lower_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alpha_upper_dict_ranges={upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_lower_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alphanum_upper_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._hex_dict_ranges={decDigits:[this._digit_first_ascii,this._digit_last_ascii],alphaDigits:[this._alpha_lower_first_ascii,this._hex_last_ascii]},this.log=(...o)=>{let u=[...o];if(u[0]=`[short-unique-id] ${o[0]}`,this.debug===!0&&typeof console<"u"&&console!==null)return console.log(...u)},this.setDictionary=(o,u)=>{let f;if(o&&Array.isArray(o)&&o.length>1)f=o;else{f=[];let g;this.dictIndex=g=0;let x=`_${o}_dict_ranges`,D=this[x];Object.keys(D).forEach(X=>{let Z=X;for(this.dictRange=D[Z],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=g=this.lowerBound;this.lowerBound<=this.upperBound?g<this.upperBound:g>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?g+=1:g-=1)f.push(String.fromCharCode(this.dictIndex))})}u&&(f=f.sort(()=>Math.random()-.5)),this.dict=f,this.dictLength=this.dict.length,this.counter=0},this.seq=()=>this.sequentialUUID(),this.sequentialUUID=()=>{let o,u,f="";o=this.counter;do u=o%this.dictLength,o=Math.trunc(o/this.dictLength),f+=this.dict[u];while(o!==0);return this.counter+=1,f},this.randomUUID=(o=this.uuidLength||y)=>{let u,f,g;if(o===null||typeof o>"u"||o<1)throw new Error("Invalid UUID Length Provided");let x=o>=0;for(u="",g=0;g<o;g+=1)f=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,u+=this.dict[f];return u},this.availableUUIDs=(o=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,o).toFixed(0)),this.approxMaxBeforeCollision=(o=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*o).toFixed(20)),this.collisionProbability=(o=this.availableUUIDs(this.uuidLength),u=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(o)/this.availableUUIDs(u)).toFixed(20)),this.uniqueness=(o=this.availableUUIDs(this.uuidLength))=>{let u=parseFloat((1-this.approxMaxBeforeCollision(o)/o).toFixed(20));return u>1?1:u<0?0:u},this.getVersion=()=>this.version,this.stamp=o=>{if(typeof o!="number"||o<10)throw new Error("Param finalLength must be number greater than 10");let u=Math.floor(+new Date/1e3).toString(16),f=o-9,g=Math.round(Math.random()*(f>15?15:f)),x=this.randomUUID(f);return`${x.substr(0,g)}${u}${x.substr(g)}${g.toString(16)}`},this.parseStamp=o=>{if(o.length<10)throw new Error("Stamp length invalid");let u=parseInt(o.substr(o.length-1,1),16);return new Date(parseInt(o.substr(u,8),16)*1e3)};let p=c(c({},l),$);this.counter=0,this.debug=!1,this.dict=[],this.version=m;let{dictionary:d,shuffle:Q,length:W}=p;return this.uuidLength=W,this.setDictionary(d,Q),this.debug=p.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength}`),new Proxy(this,{apply:(o,u,f)=>this.randomUUID(...f)})}},w=b;return w.default=b,r})();typeof E<"u"&&(E.exports=U.default),typeof window<"u"&&(U=U.default)});var A=N((_t,P)=>{"use strict";var ht=Object.prototype.hasOwnProperty,v="~";function O(){}Object.create&&(O.prototype=Object.create(null),new O().__proto__||(v=!1));function ct(i,t,e){this.fn=i,this.context=t,this.once=e||!1}function J(i,t,e,s,n){if(typeof e!="function")throw new TypeError("The listener must be a function");var c=new ct(e,s||i,n),h=v?v+t:t;return i._events[h]?i._events[h].fn?i._events[h]=[i._events[h],c]:i._events[h].push(c):(i._events[h]=c,i._eventsCount++),i}function S(i,t){--i._eventsCount===0?i._events=new O:delete i._events[t]}function _(){this._events=new O,this._eventsCount=0}_.prototype.eventNames=function(){var t=[],e,s;if(this._eventsCount===0)return t;for(s in e=this._events)ht.call(e,s)&&t.push(v?s.slice(1):s);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};_.prototype.listeners=function(t){var e=v?v+t:t,s=this._events[e];if(!s)return[];if(s.fn)return[s.fn];for(var n=0,c=s.length,h=new Array(c);n<c;n++)h[n]=s[n].fn;return h};_.prototype.listenerCount=function(t){var e=v?v+t:t,s=this._events[e];return s?s.fn?1:s.length:0};_.prototype.emit=function(t,e,s,n,c,h){var a=v?v+t:t;if(!this._events[a])return!1;var r=this._events[a],m=arguments.length,y,l;if(r.fn){switch(r.once&&this.removeListener(t,r.fn,void 0,!0),m){case 1:return r.fn.call(r.context),!0;case 2:return r.fn.call(r.context,e),!0;case 3:return r.fn.call(r.context,e,s),!0;case 4:return r.fn.call(r.context,e,s,n),!0;case 5:return r.fn.call(r.context,e,s,n,c),!0;case 6:return r.fn.call(r.context,e,s,n,c,h),!0}for(l=1,y=new Array(m-1);l<m;l++)y[l-1]=arguments[l];r.fn.apply(r.context,y)}else{var b=r.length,w;for(l=0;l<b;l++)switch(r[l].once&&this.removeListener(t,r[l].fn,void 0,!0),m){case 1:r[l].fn.call(r[l].context);break;case 2:r[l].fn.call(r[l].context,e);break;case 3:r[l].fn.call(r[l].context,e,s);break;case 4:r[l].fn.call(r[l].context,e,s,n);break;default:if(!y)for(w=1,y=new Array(m-1);w<m;w++)y[w-1]=arguments[w];r[l].fn.apply(r[l].context,y)}}return!0};_.prototype.on=function(t,e,s){return J(this,t,e,s,!1)};_.prototype.once=function(t,e,s){return J(this,t,e,s,!0)};_.prototype.removeListener=function(t,e,s,n){var c=v?v+t:t;if(!this._events[c])return this;if(!e)return S(this,c),this;var h=this._events[c];if(h.fn)h.fn===e&&(!n||h.once)&&(!s||h.context===s)&&S(this,c);else{for(var a=0,r=[],m=h.length;a<m;a++)(h[a].fn!==e||n&&!h[a].once||s&&h[a].context!==s)&&r.push(h[a]);r.length?this._events[c]=r.length===1?r[0]:r:S(this,c)}return this};_.prototype.removeAllListeners=function(t){var e;return t?(e=v?v+t:t,this._events[e]&&S(this,e)):(this._events=new O,this._eventsCount=0),this};_.prototype.off=_.prototype.removeListener;_.prototype.addListener=_.prototype.on;_.prefixed=v;_.EventEmitter=_;typeof P<"u"&&(P.exports=_)});var ut={};nt(ut,{default:()=>I});module.exports=ot(ut);var Y=L(T()),z=L(require("socket.io-client"));var k=L(A(),1);var B=i=>({prompt:t=>i.post("/:account/ai",t),image:t=>i.post("/:account/ai/image",t)});var M=i=>({add:(t,e)=>i.post(`/chat/${t?.id||t}/invite`,{chirper:e?.id||e}),list:(t,e)=>i.get("/chat",e),create:(t,e)=>i.post(`/chat/${t?.id||t}`,e),members:(t,e)=>i.get(`/chat/${t?.id||t}/members`,e),messages:(t,e)=>i.get(`/chat/${t?.id||t}/messages`,e),send:(t,e)=>i.post(`/chat/${t?.id||t}/send`,e),get:(t,e)=>i.post(`/chat/${t?.id||t}`,e)});var q=i=>({get:(t,e=null,s=null)=>i.get(`/:account/stat/${t}`,{from:e,to:s})});var j=i=>({get:t=>i.get(`/chirp/${t}`,{},!1,!1),list:(t={},e=!0,s=!0)=>i.get("/chirp",{...t,array:e,rollup:s},!1,!1),like:t=>i.post(`/chirp/${t}/like`),liked:t=>i.get(`/chirp/${t}/like`),count:t=>i.get(`/chirp/${t?.id||t}/count`),delete:t=>i.delete(`/chirp/${t}`),respond:(t,e)=>i.post(`/chirp/${e?.id||e}/respond`,{chirper:t?.id||t})});var R=i=>({get:t=>i.get(`/follow/${t}`),toggle:t=>i.post(`/follow/${t?.id||t}`)});var K=i=>({get:t=>i.get(`/chirper/${t}`),list:({user:t,skip:e,limit:s,search:n,contact:c,sort:h,filter:a,page:r}={})=>i.get("/chirper",{user:t,skip:e,limit:s,search:n,contact:c,sort:h,filter:a,page:r}),task:(t,e)=>i.post(`/chirper/${t?.id||t}/task`,{task:e?.id||e}),bump:t=>i.post(`/chirper/${t}/bump`),bumpAll:()=>i.post("/chirper/bump/all"),order:t=>i.post("/chirper/order",{chirpers:t}),create:t=>i.post("/chirper",t),update:(t,e,s)=>i.patch(`/chirper/${t.id}`,e?{lang:s,updates:e}:t),delete:t=>i.delete(`/chirper/${t}`),restore:t=>i.post(`/chirper/${t}/cancel`)});var G=i=>({list:({lang:t}={})=>i.get("/trending",{lang:t},!1,!1)});var H=i=>({list:t=>i.get("/activity",t),count:t=>i.get("/activity/count",t),read:t=>i.post("/activity/count",t)});var V=i=>({get:t=>i.get(`/community/${t}`),list:({user:t,skip:e,limit:s,search:n,contact:c,sort:h,filter:a,page:r}={})=>i.get("/community",{user:t,skip:e,limit:s,search:n,contact:c,sort:h,filter:a,page:r}),order:t=>i.post("/community/order",{communities:t}),create:t=>i.post("/community",t),update:(t,e,s)=>i.patch(`/community/${t.id}`,e?{lang:s,updates:e}:t),delete:t=>i.delete(`/community/${t}`),restore:t=>i.post(`/community/${t}/cancel`)});var lt=new Y.default({length:10}),I=class{constructor({url:t,version:e,options:s={}}){this.key=null;this.url=null;this.cache={};this.events=new k.default;this.call=null;this.socket=null;this.account=null;this.version="v1";this.loading=!0;this.authing=null;this.authKey=null;this.shareKey=null;this.customer=null;this.presences={};this.connecting=null;this.extraOptions={};this.options={path:"/ws",cors:!0,agent:!0,reconnect:!0,transports:["websocket"],withCredentials:!0};t&&(this.url=t),e&&(this.version=e),s&&(this.extraOptions=s),this.build=this.build.bind(this),this.fetch=this.fetch.bind(this),this.wsFetch=this.wsFetch.bind(this),this.on=this.on.bind(this),this.off=this.off.bind(this),this.emit=this.emit.bind(this),this.once=this.once.bind(this),this.addListener=this.events.addListener.bind(this.events),this.removeListener=this.events.removeListener.bind(this.events),this.get=this.get.bind(this),this.put=this.put.bind(this),this.post=this.post.bind(this),this.patch=this.patch.bind(this),this.delete=this.delete.bind(this),this.AI=B(this),this.Chat=M(this),this.Stat=q(this),this.Chirp=j(this),this.Follow=R(this),this.Chirper=K(this),this.Trending=G(this),this.Activity=H(this),this.Community=V(this),this.build()}build(){if(this.__resolveConnecting=null,this.connecting=new Promise(e=>{this.__resolveConnecting=e}),!this.url)return;let t=z.default.connect(`${this.url}`,{...this.options,...this.extraOptions});t.on("connect",async(...e)=>{this.authing||(this.authing=this.auth(this.authKey,this.shareKey),await this.authing,this.authing=null,this.__resolveConnecting())}),t.on("disconnect",()=>{this.connecting=new Promise(e=>{this.__resolveConnecting=e})}),this.socket=t}async auth(){this.loading=!0,this.events.emit("loading",!0);let t=await this.get("/auth",{key:this.key},!1,!1);t?.user&&(this.user=t.user,this.events.emit("user",t.user)),this.loading=!1,this.events.emit("loading",!1),typeof window<"u"&&(window.chirper=this)}async fetch(t,e,s={},n=!1){if(["patch","put","delete","post"].includes(t.toLowerCase())&&(n=!1),n&&this.cache[`${t}${e}${JSON.stringify(s)}`])return this.cache[`${t}${e}${JSON.stringify(s)}`];delete this.cache[`${t}${e}${JSON.stringify(s)}`],console.time(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(s)}`),Object.keys(s).forEach(h=>{s[h]===void 0&&delete s[h]});let c;try{c=await(await fetch(`${this.url}/${this.version}${e}${`${t}`.toLowerCase()==="get"?`?${new URLSearchParams(s)}`:""}`,{body:`${t}`.toLowerCase()!=="get"?JSON.stringify(s):void 0,headers:{"Content-Type":"application/json",Authentication:this.key?`Bearer ${this.key}`:void 0},credentials:"include"})).json()}catch(h){throw console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(s)}`),h}if(console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(s)}`),!c?.success)throw new Error(c.message);return n&&(this.cache[`${t}${e}${JSON.stringify(s)}`]=c,this.cache[`${t}${e}${JSON.stringify(s)}`].then(()=>{typeof n=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(s)}`]},n):delete this.cache[`${t}${e}${JSON.stringify(s)}`]})),c.result}async wsFetch(t,e,s={},n=!1,c=!0){if(c&&await this.connecting,c&&await this.authing,c&&!this.account&&e.includes(":account")&&await new Promise(r=>{this.events.once("account",r)}),this.account&&(e=e.replace(":account",this.account?.id)),["patch","put","delete","post"].includes(t.toLowerCase())&&(n=!1),n&&this.cache[`${t}${e}${JSON.stringify(s)}`])return this.cache[`${t}${e}${JSON.stringify(s)}`];delete this.cache[`${t}${e}${JSON.stringify(s)}`];let h=lt();console.time(`[chirper] [${h}] ${t}:${e} ${JSON.stringify(s)}`);let a=new Promise((r,m)=>{this.socket.once(h,({success:y,result:l,message:b})=>{if(console.timeEnd(`[chirper] [${h}] ${t}:${e} ${JSON.stringify(s)}`),y)return r(l);m(b)})});return n&&(this.cache[`${t}${e}${JSON.stringify(s)}`]=a,this.cache[`${t}${e}${JSON.stringify(s)}`].then(()=>{typeof n=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(s)}`]},n):delete this.cache[`${t}${e}${JSON.stringify(s)}`]})),this.socket.emit("call",h,t.toUpperCase(),e,s),a}on(...t){this.socket.on(...t)}off(...t){this.socket.off(...t)}emit(...t){this.socket.emit(...t)}once(...t){this.socket.once(...t)}get(t,e,...s){return this.wsFetch("GET",`/${this.version}${t}`,e,...s)}put(t,e,...s){return this.wsFetch("PUT",`/${this.version}${t}`,e,...s)}post(t,e,...s){return this.wsFetch("POST",`/${this.version}${t}`,e,...s)}patch(t,e,...s){return this.wsFetch("PATCH",`/${this.version}${t}`,e,...s)}delete(t,e,...s){return this.wsFetch("DELETE",`/${this.version}${t}`,e,...s)}};
var tt=Object.create;var C=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var N=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),nt=(i,t)=>{for(var e in t)C(i,e,{get:t[e],enumerable:!0})},F=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of it(t))!rt.call(i,n)&&n!==e&&C(i,n,{get:()=>t[n],enumerable:!(s=et(t,n))||s.enumerable});return i};var L=(i,t,e)=>(e=i!=null?tt(st(i)):{},F(t||!i||!i.__esModule?C(e,"default",{value:i,enumerable:!0}):e,i)),ot=i=>F(C({},"__esModule",{value:!0}),i);var T=N((ft,E)=>{var U=(()=>{var i=Object.defineProperty,t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,n=($,p,d)=>p in $?i($,p,{enumerable:!0,configurable:!0,writable:!0,value:d}):$[p]=d,c=($,p)=>{for(var d in p||(p={}))e.call(p,d)&&n($,d,p[d]);if(t)for(var d of t(p))s.call(p,d)&&n($,d,p[d]);return $},h=$=>i($,"__esModule",{value:!0}),a=($,p)=>{h($);for(var d in p)i($,d,{get:p[d],enumerable:!0})},r={};a(r,{DEFAULT_UUID_LENGTH:()=>y,default:()=>w});var m="4.4.4",y=6,l={dictionary:"alphanum",shuffle:!0,debug:!1,length:y},b=class extends Function{constructor($={}){super(),this.dictIndex=0,this.dictRange=[],this.lowerBound=0,this.upperBound=0,this.dictLength=0,this._digit_first_ascii=48,this._digit_last_ascii=58,this._alpha_lower_first_ascii=97,this._alpha_lower_last_ascii=123,this._hex_last_ascii=103,this._alpha_upper_first_ascii=65,this._alpha_upper_last_ascii=91,this._number_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii]},this._alpha_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alpha_lower_dict_ranges={lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alpha_upper_dict_ranges={upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._alphanum_lower_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],lowerCase:[this._alpha_lower_first_ascii,this._alpha_lower_last_ascii]},this._alphanum_upper_dict_ranges={digits:[this._digit_first_ascii,this._digit_last_ascii],upperCase:[this._alpha_upper_first_ascii,this._alpha_upper_last_ascii]},this._hex_dict_ranges={decDigits:[this._digit_first_ascii,this._digit_last_ascii],alphaDigits:[this._alpha_lower_first_ascii,this._hex_last_ascii]},this.log=(...o)=>{let u=[...o];if(u[0]=`[short-unique-id] ${o[0]}`,this.debug===!0&&typeof console<"u"&&console!==null)return console.log(...u)},this.setDictionary=(o,u)=>{let f;if(o&&Array.isArray(o)&&o.length>1)f=o;else{f=[];let g;this.dictIndex=g=0;let x=`_${o}_dict_ranges`,D=this[x];Object.keys(D).forEach(X=>{let Z=X;for(this.dictRange=D[Z],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=g=this.lowerBound;this.lowerBound<=this.upperBound?g<this.upperBound:g>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?g+=1:g-=1)f.push(String.fromCharCode(this.dictIndex))})}u&&(f=f.sort(()=>Math.random()-.5)),this.dict=f,this.dictLength=this.dict.length,this.counter=0},this.seq=()=>this.sequentialUUID(),this.sequentialUUID=()=>{let o,u,f="";o=this.counter;do u=o%this.dictLength,o=Math.trunc(o/this.dictLength),f+=this.dict[u];while(o!==0);return this.counter+=1,f},this.randomUUID=(o=this.uuidLength||y)=>{let u,f,g;if(o===null||typeof o>"u"||o<1)throw new Error("Invalid UUID Length Provided");let x=o>=0;for(u="",g=0;g<o;g+=1)f=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,u+=this.dict[f];return u},this.availableUUIDs=(o=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,o).toFixed(0)),this.approxMaxBeforeCollision=(o=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*o).toFixed(20)),this.collisionProbability=(o=this.availableUUIDs(this.uuidLength),u=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(o)/this.availableUUIDs(u)).toFixed(20)),this.uniqueness=(o=this.availableUUIDs(this.uuidLength))=>{let u=parseFloat((1-this.approxMaxBeforeCollision(o)/o).toFixed(20));return u>1?1:u<0?0:u},this.getVersion=()=>this.version,this.stamp=o=>{if(typeof o!="number"||o<10)throw new Error("Param finalLength must be number greater than 10");let u=Math.floor(+new Date/1e3).toString(16),f=o-9,g=Math.round(Math.random()*(f>15?15:f)),x=this.randomUUID(f);return`${x.substr(0,g)}${u}${x.substr(g)}${g.toString(16)}`},this.parseStamp=o=>{if(o.length<10)throw new Error("Stamp length invalid");let u=parseInt(o.substr(o.length-1,1),16);return new Date(parseInt(o.substr(u,8),16)*1e3)};let p=c(c({},l),$);this.counter=0,this.debug=!1,this.dict=[],this.version=m;let{dictionary:d,shuffle:Q,length:W}=p;return this.uuidLength=W,this.setDictionary(d,Q),this.debug=p.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength}`),new Proxy(this,{apply:(o,u,f)=>this.randomUUID(...f)})}},w=b;return w.default=b,r})();typeof E<"u"&&(E.exports=U.default),typeof window<"u"&&(U=U.default)});var A=N((_t,P)=>{"use strict";var ht=Object.prototype.hasOwnProperty,v="~";function O(){}Object.create&&(O.prototype=Object.create(null),new O().__proto__||(v=!1));function ct(i,t,e){this.fn=i,this.context=t,this.once=e||!1}function J(i,t,e,s,n){if(typeof e!="function")throw new TypeError("The listener must be a function");var c=new ct(e,s||i,n),h=v?v+t:t;return i._events[h]?i._events[h].fn?i._events[h]=[i._events[h],c]:i._events[h].push(c):(i._events[h]=c,i._eventsCount++),i}function S(i,t){--i._eventsCount===0?i._events=new O:delete i._events[t]}function _(){this._events=new O,this._eventsCount=0}_.prototype.eventNames=function(){var t=[],e,s;if(this._eventsCount===0)return t;for(s in e=this._events)ht.call(e,s)&&t.push(v?s.slice(1):s);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};_.prototype.listeners=function(t){var e=v?v+t:t,s=this._events[e];if(!s)return[];if(s.fn)return[s.fn];for(var n=0,c=s.length,h=new Array(c);n<c;n++)h[n]=s[n].fn;return h};_.prototype.listenerCount=function(t){var e=v?v+t:t,s=this._events[e];return s?s.fn?1:s.length:0};_.prototype.emit=function(t,e,s,n,c,h){var a=v?v+t:t;if(!this._events[a])return!1;var r=this._events[a],m=arguments.length,y,l;if(r.fn){switch(r.once&&this.removeListener(t,r.fn,void 0,!0),m){case 1:return r.fn.call(r.context),!0;case 2:return r.fn.call(r.context,e),!0;case 3:return r.fn.call(r.context,e,s),!0;case 4:return r.fn.call(r.context,e,s,n),!0;case 5:return r.fn.call(r.context,e,s,n,c),!0;case 6:return r.fn.call(r.context,e,s,n,c,h),!0}for(l=1,y=new Array(m-1);l<m;l++)y[l-1]=arguments[l];r.fn.apply(r.context,y)}else{var b=r.length,w;for(l=0;l<b;l++)switch(r[l].once&&this.removeListener(t,r[l].fn,void 0,!0),m){case 1:r[l].fn.call(r[l].context);break;case 2:r[l].fn.call(r[l].context,e);break;case 3:r[l].fn.call(r[l].context,e,s);break;case 4:r[l].fn.call(r[l].context,e,s,n);break;default:if(!y)for(w=1,y=new Array(m-1);w<m;w++)y[w-1]=arguments[w];r[l].fn.apply(r[l].context,y)}}return!0};_.prototype.on=function(t,e,s){return J(this,t,e,s,!1)};_.prototype.once=function(t,e,s){return J(this,t,e,s,!0)};_.prototype.removeListener=function(t,e,s,n){var c=v?v+t:t;if(!this._events[c])return this;if(!e)return S(this,c),this;var h=this._events[c];if(h.fn)h.fn===e&&(!n||h.once)&&(!s||h.context===s)&&S(this,c);else{for(var a=0,r=[],m=h.length;a<m;a++)(h[a].fn!==e||n&&!h[a].once||s&&h[a].context!==s)&&r.push(h[a]);r.length?this._events[c]=r.length===1?r[0]:r:S(this,c)}return this};_.prototype.removeAllListeners=function(t){var e;return t?(e=v?v+t:t,this._events[e]&&S(this,e)):(this._events=new O,this._eventsCount=0),this};_.prototype.off=_.prototype.removeListener;_.prototype.addListener=_.prototype.on;_.prefixed=v;_.EventEmitter=_;typeof P<"u"&&(P.exports=_)});var ut={};nt(ut,{default:()=>I});module.exports=ot(ut);var Y=L(T()),z=L(require("socket.io-client"));var k=L(A(),1);var B=i=>({prompt:t=>i.post("/:account/ai",t),image:t=>i.post("/:account/ai/image",t)});var M=i=>({add:(t,e)=>i.post(`/chat/${t?.id||t}/invite`,{chirper:e?.id||e}),list:(t,e)=>i.get("/chat",e),create:(t,e)=>i.post(`/chat/${t?.id||t}`,e),members:(t,e)=>i.get(`/chat/${t?.id||t}/members`,e),messages:(t,e)=>i.get(`/chat/${t?.id||t}/messages`,e),send:(t,e)=>i.post(`/chat/${t?.id||t}/send`,e),get:(t,e)=>i.post(`/chat/${t?.id||t}`,e)});var q=i=>({get:(t,e=null,s=null)=>i.get(`/:account/stat/${t}`,{from:e,to:s})});var j=i=>({get:t=>i.get(`/chirp/${t}`,{},!1,!1),list:(t={},e=!0,s=!0)=>i.get("/chirp",{...t,array:e,rollup:s},!1,!1),like:t=>i.post(`/chirp/${t}/like`),liked:t=>i.get(`/chirp/${t}/like`),count:t=>i.get(`/chirp/${t?.id||t}/count`),delete:t=>i.delete(`/chirp/${t}`),respond:(t,e)=>i.post(`/chirp/${e?.id||e}/respond`,{chirper:t?.id||t})});var R=i=>({get:t=>i.get(`/follow/${t}`),toggle:t=>i.post(`/follow/${t?.id||t}`)});var K=i=>({get:t=>i.get(`/chirper/${t}`),list:({user:t,skip:e,limit:s,search:n,contact:c,sort:h,filter:a,page:r}={})=>i.get("/chirper",{user:t,skip:e,limit:s,search:n,contact:c,sort:h,filter:a,page:r}),task:(t,e)=>i.post(`/chirper/${t?.id||t}/task`,{task:e?.id||e}),bump:t=>i.post(`/chirper/${t}/bump`),bumpAll:()=>i.post("/chirper/bump/all"),order:t=>i.post("/chirper/order",{chirpers:t}),create:t=>i.post("/chirper",t),update:(t,e,s)=>i.patch(`/chirper/${t.id}`,e?{lang:s,updates:e}:t),delete:t=>i.delete(`/chirper/${t}`),restore:t=>i.post(`/chirper/${t}/cancel`)});var G=i=>({list:({lang:t}={})=>i.get("/trending",{lang:t},!1,!1)});var H=i=>({list:t=>i.get("/activity",t),count:t=>i.get("/activity/count",t),read:t=>i.post("/activity/count",t)});var V=i=>({get:t=>i.get(`/community/${t}`),list:({user:t,skip:e,limit:s,search:n,chirper:c,sort:h,filter:a,page:r}={})=>i.get("/community",{user:t,skip:e,limit:s,search:n,chirper:c,sort:h,filter:a,page:r}),order:t=>i.post("/community/order",{communities:t}),create:t=>i.post("/community",t),update:(t,e,s)=>i.patch(`/community/${t.id}`,e?{lang:s,updates:e}:t),delete:t=>i.delete(`/community/${t}`),restore:t=>i.post(`/community/${t}/cancel`)});var lt=new Y.default({length:10}),I=class{constructor({url:t,version:e,options:s={}}){this.key=null;this.url=null;this.cache={};this.events=new k.default;this.call=null;this.socket=null;this.account=null;this.version="v1";this.loading=!0;this.authing=null;this.authKey=null;this.shareKey=null;this.customer=null;this.presences={};this.connecting=null;this.extraOptions={};this.options={path:"/ws",cors:!0,agent:!0,reconnect:!0,transports:["websocket"],withCredentials:!0};t&&(this.url=t),e&&(this.version=e),s&&(this.extraOptions=s),this.build=this.build.bind(this),this.fetch=this.fetch.bind(this),this.wsFetch=this.wsFetch.bind(this),this.on=this.on.bind(this),this.off=this.off.bind(this),this.emit=this.emit.bind(this),this.once=this.once.bind(this),this.addListener=this.events.addListener.bind(this.events),this.removeListener=this.events.removeListener.bind(this.events),this.get=this.get.bind(this),this.put=this.put.bind(this),this.post=this.post.bind(this),this.patch=this.patch.bind(this),this.delete=this.delete.bind(this),this.AI=B(this),this.Chat=M(this),this.Stat=q(this),this.Chirp=j(this),this.Follow=R(this),this.Chirper=K(this),this.Trending=G(this),this.Activity=H(this),this.Community=V(this),this.build()}build(){if(this.__resolveConnecting=null,this.connecting=new Promise(e=>{this.__resolveConnecting=e}),!this.url)return;let t=z.default.connect(`${this.url}`,{...this.options,...this.extraOptions});t.on("connect",async(...e)=>{this.authing||(this.authing=this.auth(this.authKey,this.shareKey),await this.authing,this.authing=null,this.__resolveConnecting())}),t.on("disconnect",()=>{this.connecting=new Promise(e=>{this.__resolveConnecting=e})}),this.socket=t}async auth(){this.loading=!0,this.events.emit("loading",!0);let t=await this.get("/auth",{key:this.key},!1,!1);t?.user&&(this.user=t.user,this.events.emit("user",t.user)),this.loading=!1,this.events.emit("loading",!1),typeof window<"u"&&(window.chirper=this)}async fetch(t,e,s={},n=!1){if(["patch","put","delete","post"].includes(t.toLowerCase())&&(n=!1),n&&this.cache[`${t}${e}${JSON.stringify(s)}`])return this.cache[`${t}${e}${JSON.stringify(s)}`];delete this.cache[`${t}${e}${JSON.stringify(s)}`],console.time(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(s)}`),Object.keys(s).forEach(h=>{s[h]===void 0&&delete s[h]});let c;try{c=await(await fetch(`${this.url}/${this.version}${e}${`${t}`.toLowerCase()==="get"?`?${new URLSearchParams(s)}`:""}`,{body:`${t}`.toLowerCase()!=="get"?JSON.stringify(s):void 0,headers:{"Content-Type":"application/json",Authentication:this.key?`Bearer ${this.key}`:void 0},credentials:"include"})).json()}catch(h){throw console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(s)}`),h}if(console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(s)}`),!c?.success)throw new Error(c.message);return n&&(this.cache[`${t}${e}${JSON.stringify(s)}`]=c,this.cache[`${t}${e}${JSON.stringify(s)}`].then(()=>{typeof n=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(s)}`]},n):delete this.cache[`${t}${e}${JSON.stringify(s)}`]})),c.result}async wsFetch(t,e,s={},n=!1,c=!0){if(c&&await this.connecting,c&&await this.authing,c&&!this.account&&e.includes(":account")&&await new Promise(r=>{this.events.once("account",r)}),this.account&&(e=e.replace(":account",this.account?.id)),["patch","put","delete","post"].includes(t.toLowerCase())&&(n=!1),n&&this.cache[`${t}${e}${JSON.stringify(s)}`])return this.cache[`${t}${e}${JSON.stringify(s)}`];delete this.cache[`${t}${e}${JSON.stringify(s)}`];let h=lt();console.time(`[chirper] [${h}] ${t}:${e} ${JSON.stringify(s)}`);let a=new Promise((r,m)=>{this.socket.once(h,({success:y,result:l,message:b})=>{if(console.timeEnd(`[chirper] [${h}] ${t}:${e} ${JSON.stringify(s)}`),y)return r(l);m(b)})});return n&&(this.cache[`${t}${e}${JSON.stringify(s)}`]=a,this.cache[`${t}${e}${JSON.stringify(s)}`].then(()=>{typeof n=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(s)}`]},n):delete this.cache[`${t}${e}${JSON.stringify(s)}`]})),this.socket.emit("call",h,t.toUpperCase(),e,s),a}on(...t){this.socket.on(...t)}off(...t){this.socket.off(...t)}emit(...t){this.socket.emit(...t)}once(...t){this.socket.once(...t)}get(t,e,...s){return this.wsFetch("GET",`/${this.version}${t}`,e,...s)}put(t,e,...s){return this.wsFetch("PUT",`/${this.version}${t}`,e,...s)}post(t,e,...s){return this.wsFetch("POST",`/${this.version}${t}`,e,...s)}patch(t,e,...s){return this.wsFetch("PATCH",`/${this.version}${t}`,e,...s)}delete(t,e,...s){return this.wsFetch("DELETE",`/${this.version}${t}`,e,...s)}};
{
"name": "@chirper/node",
"version": "0.0.23",
"version": "0.0.24",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/bundle.js",

@@ -9,5 +9,5 @@

},
list : ({ user, skip, limit, search, contact, sort, filter, page } = {}) => {
list : ({ user, skip, limit, search, chirper, sort, filter, page } = {}) => {
// return done
return api.get(`/community`, { user, skip, limit, search, contact, sort, filter, page });
return api.get(`/community`, { user, skip, limit, search, chirper, sort, filter, page });
},

@@ -14,0 +14,0 @@ order : (communities) => {

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