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.62 to 0.0.63

2

dist/bundle.js

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

var ot=Object.create;var C=Object.defineProperty;var ht=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var ut=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty;var k=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),at=(i,t)=>{for(var e in t)C(i,e,{get:t[e],enumerable:!0})},F=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of lt(t))!ct.call(i,o)&&o!==e&&C(i,o,{get:()=>t[o],enumerable:!(r=ht(t,o))||r.enumerable});return i};var L=(i,t,e)=>(e=i!=null?ot(ut(i)):{},F(t||!i||!i.__esModule?C(e,"default",{value:i,enumerable:!0}):e,i)),ft=i=>F(C({},"__esModule",{value:!0}),i);var A=k(($t,E)=>{var U=(()=>{var i=Object.defineProperty,t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,o=($,f,p)=>f in $?i($,f,{enumerable:!0,configurable:!0,writable:!0,value:p}):$[f]=p,l=($,f)=>{for(var p in f||(f={}))e.call(f,p)&&o($,p,f[p]);if(t)for(var p of t(f))r.call(f,p)&&o($,p,f[p]);return $},h=$=>i($,"__esModule",{value:!0}),v=($,f)=>{h($);for(var p in f)i($,p,{get:f[p],enumerable:!0})},s={};v(s,{DEFAULT_UUID_LENGTH:()=>m,default:()=>y});var w="4.4.4",m=6,u={dictionary:"alphanum",shuffle:!0,debug:!1,length:m},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=(...n)=>{let c=[...n];if(c[0]=`[short-unique-id] ${n[0]}`,this.debug===!0&&typeof console<"u"&&console!==null)return console.log(...c)},this.setDictionary=(n,c)=>{let a;if(n&&Array.isArray(n)&&n.length>1)a=n;else{a=[];let _;this.dictIndex=_=0;let x=`_${n}_dict_ranges`,N=this[x];Object.keys(N).forEach(st=>{let nt=st;for(this.dictRange=N[nt],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=_=this.lowerBound;this.lowerBound<=this.upperBound?_<this.upperBound:_>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?_+=1:_-=1)a.push(String.fromCharCode(this.dictIndex))})}c&&(a=a.sort(()=>Math.random()-.5)),this.dict=a,this.dictLength=this.dict.length,this.counter=0},this.seq=()=>this.sequentialUUID(),this.sequentialUUID=()=>{let n,c,a="";n=this.counter;do c=n%this.dictLength,n=Math.trunc(n/this.dictLength),a+=this.dict[c];while(n!==0);return this.counter+=1,a},this.randomUUID=(n=this.uuidLength||m)=>{let c,a,_;if(n===null||typeof n>"u"||n<1)throw new Error("Invalid UUID Length Provided");let x=n>=0;for(c="",_=0;_<n;_+=1)a=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,c+=this.dict[a];return c},this.availableUUIDs=(n=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,n).toFixed(0)),this.approxMaxBeforeCollision=(n=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*n).toFixed(20)),this.collisionProbability=(n=this.availableUUIDs(this.uuidLength),c=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(n)/this.availableUUIDs(c)).toFixed(20)),this.uniqueness=(n=this.availableUUIDs(this.uuidLength))=>{let c=parseFloat((1-this.approxMaxBeforeCollision(n)/n).toFixed(20));return c>1?1:c<0?0:c},this.getVersion=()=>this.version,this.stamp=n=>{if(typeof n!="number"||n<10)throw new Error("Param finalLength must be number greater than 10");let c=Math.floor(+new Date/1e3).toString(16),a=n-9,_=Math.round(Math.random()*(a>15?15:a)),x=this.randomUUID(a);return`${x.substr(0,_)}${c}${x.substr(_)}${_.toString(16)}`},this.parseStamp=n=>{if(n.length<10)throw new Error("Stamp length invalid");let c=parseInt(n.substr(n.length-1,1),16);return new Date(parseInt(n.substr(c,8),16)*1e3)};let f=l(l({},u),$);this.counter=0,this.debug=!1,this.dict=[],this.version=w;let{dictionary:p,shuffle:it,length:rt}=f;return this.uuidLength=rt,this.setDictionary(p,it),this.debug=f.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength}`),new Proxy(this,{apply:(n,c,a)=>this.randomUUID(...a)})}},y=b;return y.default=b,s})();typeof E<"u"&&(E.exports=U.default),typeof window<"u"&&(U=U.default)});var J=k((wt,P)=>{"use strict";var dt=Object.prototype.hasOwnProperty,g="~";function O(){}Object.create&&(O.prototype=Object.create(null),new O().__proto__||(g=!1));function pt(i,t,e){this.fn=i,this.context=t,this.once=e||!1}function T(i,t,e,r,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var l=new pt(e,r||i,o),h=g?g+t:t;return i._events[h]?i._events[h].fn?i._events[h]=[i._events[h],l]:i._events[h].push(l):(i._events[h]=l,i._eventsCount++),i}function S(i,t){--i._eventsCount===0?i._events=new O:delete i._events[t]}function d(){this._events=new O,this._eventsCount=0}d.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)dt.call(e,r)&&t.push(g?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};d.prototype.listeners=function(t){var e=g?g+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,l=r.length,h=new Array(l);o<l;o++)h[o]=r[o].fn;return h};d.prototype.listenerCount=function(t){var e=g?g+t:t,r=this._events[e];return r?r.fn?1:r.length:0};d.prototype.emit=function(t,e,r,o,l,h){var v=g?g+t:t;if(!this._events[v])return!1;var s=this._events[v],w=arguments.length,m,u;if(s.fn){switch(s.once&&this.removeListener(t,s.fn,void 0,!0),w){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,e),!0;case 3:return s.fn.call(s.context,e,r),!0;case 4:return s.fn.call(s.context,e,r,o),!0;case 5:return s.fn.call(s.context,e,r,o,l),!0;case 6:return s.fn.call(s.context,e,r,o,l,h),!0}for(u=1,m=new Array(w-1);u<w;u++)m[u-1]=arguments[u];s.fn.apply(s.context,m)}else{var b=s.length,y;for(u=0;u<b;u++)switch(s[u].once&&this.removeListener(t,s[u].fn,void 0,!0),w){case 1:s[u].fn.call(s[u].context);break;case 2:s[u].fn.call(s[u].context,e);break;case 3:s[u].fn.call(s[u].context,e,r);break;case 4:s[u].fn.call(s[u].context,e,r,o);break;default:if(!m)for(y=1,m=new Array(w-1);y<w;y++)m[y-1]=arguments[y];s[u].fn.apply(s[u].context,m)}}return!0};d.prototype.on=function(t,e,r){return T(this,t,e,r,!1)};d.prototype.once=function(t,e,r){return T(this,t,e,r,!0)};d.prototype.removeListener=function(t,e,r,o){var l=g?g+t:t;if(!this._events[l])return this;if(!e)return S(this,l),this;var h=this._events[l];if(h.fn)h.fn===e&&(!o||h.once)&&(!r||h.context===r)&&S(this,l);else{for(var v=0,s=[],w=h.length;v<w;v++)(h[v].fn!==e||o&&!h[v].once||r&&h[v].context!==r)&&s.push(h[v]);s.length?this._events[l]=s.length===1?s[0]:s:S(this,l)}return this};d.prototype.removeAllListeners=function(t){var e;return t?(e=g?g+t:t,this._events[e]&&S(this,e)):(this._events=new O,this._eventsCount=0),this};d.prototype.off=d.prototype.removeListener;d.prototype.addListener=d.prototype.on;d.prefixed=g;d.EventEmitter=d;typeof P<"u"&&(P.exports=d)});var gt={};at(gt,{default:()=>I});module.exports=ft(gt);var tt=L(A()),et=L(require("socket.io-client"));var D=L(J(),1);var B=i=>({prompt:t=>i.post("/:account/ai",t),image:t=>i.post("/:account/ai/image",t)});var M=i=>({get:(t,e={})=>i.get(`/user/${t}`,e),image:(t,e={})=>i.post(`/user/${t?.id||t}/image`,e),update:(t,e,r)=>i.patch(`/user/${t.id}`,e?{lang:r,updates:e}:t),password:(t,e,r)=>i.patch("/user/password",{password:t,newPassword:e,newPassword2:r}),username:(t,e=null)=>i.post("/user/username",{username:t,id:e?.id||e}),Pin:{list:(t={})=>i.get("/user/pin",t),create:(t={})=>i.post("/user/pin",t),update:(t={})=>i.patch("/user/pin",t),delete:(t={})=>i.delete("/user/pin",t)}});var j=i=>({get:(t,e)=>i.post(`/chat/${t?.id||t}`,e),list:t=>i.get("/chat",t),create:(t,e)=>i.post(`/chat/${t?.id||t}`,e),leaveChat:t=>i.delete(`/chat/${t?.id||t}`),loadMembers:(t,e)=>i.get(`/chat/${t?.id||t}/member`,e),loadMessages:(t,e)=>i.get(`/chat/${t?.id||t}/message`,e),sendMessage:(t,e)=>i.post(`/chat/${t?.id||t}/message`,e),inviteMember:(t,e)=>i.post(`/chat/${t?.id||t}/member`,{chirper:e?.id||e}),removeMember:(t,e)=>i.delete(`/chat/${t?.id||t}/member/${e?.id||e}`)});var q=i=>({list:(t={})=>i.get("/file",t),modelList:(t={})=>i.get("/file/model",t)});var R=i=>({get:(t,e=null,r=null)=>i.get(`/:account/stat/${t}`,{from:e,to:r})});var K=i=>({get:t=>i.get(`/event/${t}`),list:(t={})=>i.get("/event",t),image:(t,e={})=>i.post(`/event/${t?.id||t}/image`,e),create:t=>i.post("/event",t),update:t=>i.patch(`/event/${t?.id}`,t),delete:t=>i.delete(`/event/${t?.id||t}`),restore:t=>i.post(`/event/${t?.id||t}/cancel`),validate:(t,e,r)=>i.get("/event/value",{key:e,value:r,event:t?.id})});var G=i=>({code:(t,e)=>i.post("/oauth2/code",{application:t,redirect:e})});var H=i=>({get:(t,e)=>i.get(`/chirp/${t}`,{lang:e},!1,!1),list:(t={})=>i.get("/chirp",t,!1,!1),like:t=>i.post(`/chirp/${t}/like`),play:t=>i.post(`/chirp/${t}/play`),view:t=>i.post(`/chirp/${t}/view`),liked:t=>i.get(`/chirp/${t}/like`),count:t=>i.get(`/chirp/${t?.id||t}/count`),delete:t=>i.delete(`/chirp/${t}`),create:(t,e,r,o)=>i.post("/chirp",{type:o,thought:e,chirp:r?.id||r,chirper:t?.id||t})});var V=i=>({get:t=>i.get(`/world/${t}`),list:(t={})=>i.get("/world",t),image:(t,e={})=>i.post(`/world/${t?.id||t}/image`,e),invite:(t,e)=>i.post(`/world/${t?.id||t}/invite`,{chirper:e?.id||e}),remove:(t,e)=>i.post(`/world/${t?.id||t}/remove`,{chirper:e?.id||e}),members:(t,e={})=>i.get(`/world/${t?.id||t}/members`,e),alerts:(t={})=>i.get("/world/alerts",t),create:t=>i.post("/world",t),update:t=>i.patch(`/world/${t?.id}`,t),delete:t=>i.delete(`/world/${t?.id||t}`),restore:t=>i.post(`/world/${t?.id||t}/cancel`),validate:(t,e,r)=>i.get("/world/value",{key:e,value:r,world:t?.id})});var W=i=>({get:t=>i.get(`/follow/${t}`),toggle:t=>i.post(`/follow/${t?.id||t}`)});var Y=i=>({get:t=>i.get(`/chirper/${t}`),list:(t={})=>i.get("/chirper",t),spec:(t,e)=>i.post(`/chirper/${t?.id||t}/spec`,{type:e}),image:(t,e={})=>i.post(`/chirper/${t?.id||t}/image`,e),journal:(t,e)=>i.get(`/chirper/${t?.id||t}/journal`,e),progress:(t,e)=>i.get(`/chirper/${t?.id||t}/progress`,e),username:(t,e=null)=>i.post("/chirper/username",{username:t,id:e?.id||e}),create:(t={})=>i.post("/chirper",t),update:(t={})=>i.patch(`/chirper/${t.id}`,t),delete:t=>i.delete(`/chirper/${t?.id||t}`),restore:t=>i.post(`/chirper/${t?.id||t}/cancel`),validate:(t,e,r)=>i.get("/chirper/value",{key:e,value:r,chirper:t?.id})});var z=i=>({list:({lang:t}={})=>i.get("/trending",{lang:t},!1,!1)});var Q=i=>({list:t=>i.get("/activity",t),count:t=>i.get("/activity/count",t),read:t=>i.post("/activity/count",t)});var X=i=>({get:t=>i.get(`/category/${t?.id||t}`,{}),list:t=>i.get("/category",t)});var Z=i=>({get:t=>i.get(`/application/${t?.id||t}`,{}),list:t=>i.get("/application",t),create:t=>i.post("/application",t),update:(t,e)=>i.patch(`/application/${t?.id||t}`,e),secret:(t,e)=>i.get(`/application/${t?.id||t}/secret`,e)});var _t=new tt.default({length:10}),I=class{constructor({url:t,version:e,options:r={}}){this.key=null;this.url=null;this.cache={};this.events=new D.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),r&&(this.extraOptions=r),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.File=q(this),this.User=M(this),this.Chat=j(this),this.Stat=R(this),this.Event=K(this),this.OAuth=G(this),this.Chirp=H(this),this.World=V(this),this.Follow=W(this),this.Chirper=Y(this),this.Trending=z(this),this.Activity=Q(this),this.Category=X(this),this.Application=Z(this),this.build()}build(){if(this.__resolveConnecting=null,this.connecting=new Promise(e=>{this.__resolveConnecting=e}),!this.url)return;let t=et.default.connect(`${this.url}`,{...this.options,...this.extraOptions});t.on("user",e=>{this.auth(e)}),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(t){!t&&this.user&&(t=this.user),t||(this.loading=!0,this.events.emit("loading",!0),t=(await this.get("/auth",{key:this.key},!1,!1))?.user),t&&(this.user=t,this.events.emit("user",t)),this.loading=!1,this.events.emit("loading",!1),typeof window<"u"&&(window.chirper=this)}async fetch(t,e,r={},o=!1){if(["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(r)}`])return this.cache[`${t}${e}${JSON.stringify(r)}`];delete this.cache[`${t}${e}${JSON.stringify(r)}`],console.time(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(r)}`),Object.keys(r).forEach(h=>{r[h]===void 0&&delete r[h]});let l;try{l=await(await fetch(`${this.url}/${this.version}${e}${`${t}`.toLowerCase()==="get"?`?${new URLSearchParams(r)}`:""}`,{body:`${t}`.toLowerCase()!=="get"?JSON.stringify(r):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(r)}`),h}if(console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(r)}`),!l?.success)throw new Error(l.message);return o&&(this.cache[`${t}${e}${JSON.stringify(r)}`]=l,this.cache[`${t}${e}${JSON.stringify(r)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(r)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(r)}`]})),l.result}async wsFetch(t,e,r={},o=!1,l=!0){if(l&&await this.connecting,l&&await this.authing,l&&!this.account&&e.includes(":account")&&await new Promise(s=>{this.events.once("account",s)}),this.account&&(e=e.replace(":account",this.account?.id)),["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(r)}`])return this.cache[`${t}${e}${JSON.stringify(r)}`];delete this.cache[`${t}${e}${JSON.stringify(r)}`];let h=_t();console.time(`[chirper] [${h}] ${t}:${e} ${JSON.stringify(r)}`);let v=new Promise((s,w)=>{this.socket.once(h,({success:m,result:u,message:b})=>{if(console.timeEnd(`[chirper] [${h}] ${t}:${e} ${JSON.stringify(r)}`),m)return s(u);w(b)})});return o&&(this.cache[`${t}${e}${JSON.stringify(r)}`]=v,this.cache[`${t}${e}${JSON.stringify(r)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(r)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(r)}`]})),this.socket.emit("call",h,t.toUpperCase(),e,r),v}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,...r){return this.wsFetch("GET",`/${this.version}${t}`,e,...r)}put(t,e,...r){return this.wsFetch("PUT",`/${this.version}${t}`,e,...r)}post(t,e,...r){return this.wsFetch("POST",`/${this.version}${t}`,e,...r)}patch(t,e,...r){return this.wsFetch("PATCH",`/${this.version}${t}`,e,...r)}delete(t,e,...r){return this.wsFetch("DELETE",`/${this.version}${t}`,e,...r)}};
var ot=Object.create;var C=Object.defineProperty;var ht=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var ut=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty;var k=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),at=(i,t)=>{for(var e in t)C(i,e,{get:t[e],enumerable:!0})},F=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of lt(t))!ct.call(i,o)&&o!==e&&C(i,o,{get:()=>t[o],enumerable:!(r=ht(t,o))||r.enumerable});return i};var L=(i,t,e)=>(e=i!=null?ot(ut(i)):{},F(t||!i||!i.__esModule?C(e,"default",{value:i,enumerable:!0}):e,i)),ft=i=>F(C({},"__esModule",{value:!0}),i);var A=k(($t,E)=>{var U=(()=>{var i=Object.defineProperty,t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,o=($,f,p)=>f in $?i($,f,{enumerable:!0,configurable:!0,writable:!0,value:p}):$[f]=p,l=($,f)=>{for(var p in f||(f={}))e.call(f,p)&&o($,p,f[p]);if(t)for(var p of t(f))r.call(f,p)&&o($,p,f[p]);return $},h=$=>i($,"__esModule",{value:!0}),v=($,f)=>{h($);for(var p in f)i($,p,{get:f[p],enumerable:!0})},s={};v(s,{DEFAULT_UUID_LENGTH:()=>m,default:()=>y});var w="4.4.4",m=6,u={dictionary:"alphanum",shuffle:!0,debug:!1,length:m},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=(...n)=>{let c=[...n];if(c[0]=`[short-unique-id] ${n[0]}`,this.debug===!0&&typeof console<"u"&&console!==null)return console.log(...c)},this.setDictionary=(n,c)=>{let a;if(n&&Array.isArray(n)&&n.length>1)a=n;else{a=[];let _;this.dictIndex=_=0;let x=`_${n}_dict_ranges`,N=this[x];Object.keys(N).forEach(st=>{let nt=st;for(this.dictRange=N[nt],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=_=this.lowerBound;this.lowerBound<=this.upperBound?_<this.upperBound:_>this.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?_+=1:_-=1)a.push(String.fromCharCode(this.dictIndex))})}c&&(a=a.sort(()=>Math.random()-.5)),this.dict=a,this.dictLength=this.dict.length,this.counter=0},this.seq=()=>this.sequentialUUID(),this.sequentialUUID=()=>{let n,c,a="";n=this.counter;do c=n%this.dictLength,n=Math.trunc(n/this.dictLength),a+=this.dict[c];while(n!==0);return this.counter+=1,a},this.randomUUID=(n=this.uuidLength||m)=>{let c,a,_;if(n===null||typeof n>"u"||n<1)throw new Error("Invalid UUID Length Provided");let x=n>=0;for(c="",_=0;_<n;_+=1)a=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,c+=this.dict[a];return c},this.availableUUIDs=(n=this.uuidLength)=>parseFloat(Math.pow([...new Set(this.dict)].length,n).toFixed(0)),this.approxMaxBeforeCollision=(n=this.availableUUIDs(this.uuidLength))=>parseFloat(Math.sqrt(Math.PI/2*n).toFixed(20)),this.collisionProbability=(n=this.availableUUIDs(this.uuidLength),c=this.uuidLength)=>parseFloat((this.approxMaxBeforeCollision(n)/this.availableUUIDs(c)).toFixed(20)),this.uniqueness=(n=this.availableUUIDs(this.uuidLength))=>{let c=parseFloat((1-this.approxMaxBeforeCollision(n)/n).toFixed(20));return c>1?1:c<0?0:c},this.getVersion=()=>this.version,this.stamp=n=>{if(typeof n!="number"||n<10)throw new Error("Param finalLength must be number greater than 10");let c=Math.floor(+new Date/1e3).toString(16),a=n-9,_=Math.round(Math.random()*(a>15?15:a)),x=this.randomUUID(a);return`${x.substr(0,_)}${c}${x.substr(_)}${_.toString(16)}`},this.parseStamp=n=>{if(n.length<10)throw new Error("Stamp length invalid");let c=parseInt(n.substr(n.length-1,1),16);return new Date(parseInt(n.substr(c,8),16)*1e3)};let f=l(l({},u),$);this.counter=0,this.debug=!1,this.dict=[],this.version=w;let{dictionary:p,shuffle:it,length:rt}=f;return this.uuidLength=rt,this.setDictionary(p,it),this.debug=f.debug,this.log(this.dict),this.log(`Generator instantiated with Dictionary Size ${this.dictLength}`),new Proxy(this,{apply:(n,c,a)=>this.randomUUID(...a)})}},y=b;return y.default=b,s})();typeof E<"u"&&(E.exports=U.default),typeof window<"u"&&(U=U.default)});var J=k((wt,P)=>{"use strict";var dt=Object.prototype.hasOwnProperty,g="~";function O(){}Object.create&&(O.prototype=Object.create(null),new O().__proto__||(g=!1));function pt(i,t,e){this.fn=i,this.context=t,this.once=e||!1}function T(i,t,e,r,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var l=new pt(e,r||i,o),h=g?g+t:t;return i._events[h]?i._events[h].fn?i._events[h]=[i._events[h],l]:i._events[h].push(l):(i._events[h]=l,i._eventsCount++),i}function S(i,t){--i._eventsCount===0?i._events=new O:delete i._events[t]}function d(){this._events=new O,this._eventsCount=0}d.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)dt.call(e,r)&&t.push(g?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};d.prototype.listeners=function(t){var e=g?g+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,l=r.length,h=new Array(l);o<l;o++)h[o]=r[o].fn;return h};d.prototype.listenerCount=function(t){var e=g?g+t:t,r=this._events[e];return r?r.fn?1:r.length:0};d.prototype.emit=function(t,e,r,o,l,h){var v=g?g+t:t;if(!this._events[v])return!1;var s=this._events[v],w=arguments.length,m,u;if(s.fn){switch(s.once&&this.removeListener(t,s.fn,void 0,!0),w){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,e),!0;case 3:return s.fn.call(s.context,e,r),!0;case 4:return s.fn.call(s.context,e,r,o),!0;case 5:return s.fn.call(s.context,e,r,o,l),!0;case 6:return s.fn.call(s.context,e,r,o,l,h),!0}for(u=1,m=new Array(w-1);u<w;u++)m[u-1]=arguments[u];s.fn.apply(s.context,m)}else{var b=s.length,y;for(u=0;u<b;u++)switch(s[u].once&&this.removeListener(t,s[u].fn,void 0,!0),w){case 1:s[u].fn.call(s[u].context);break;case 2:s[u].fn.call(s[u].context,e);break;case 3:s[u].fn.call(s[u].context,e,r);break;case 4:s[u].fn.call(s[u].context,e,r,o);break;default:if(!m)for(y=1,m=new Array(w-1);y<w;y++)m[y-1]=arguments[y];s[u].fn.apply(s[u].context,m)}}return!0};d.prototype.on=function(t,e,r){return T(this,t,e,r,!1)};d.prototype.once=function(t,e,r){return T(this,t,e,r,!0)};d.prototype.removeListener=function(t,e,r,o){var l=g?g+t:t;if(!this._events[l])return this;if(!e)return S(this,l),this;var h=this._events[l];if(h.fn)h.fn===e&&(!o||h.once)&&(!r||h.context===r)&&S(this,l);else{for(var v=0,s=[],w=h.length;v<w;v++)(h[v].fn!==e||o&&!h[v].once||r&&h[v].context!==r)&&s.push(h[v]);s.length?this._events[l]=s.length===1?s[0]:s:S(this,l)}return this};d.prototype.removeAllListeners=function(t){var e;return t?(e=g?g+t:t,this._events[e]&&S(this,e)):(this._events=new O,this._eventsCount=0),this};d.prototype.off=d.prototype.removeListener;d.prototype.addListener=d.prototype.on;d.prefixed=g;d.EventEmitter=d;typeof P<"u"&&(P.exports=d)});var gt={};at(gt,{default:()=>I});module.exports=ft(gt);var tt=L(A()),et=L(require("socket.io-client"));var D=L(J(),1);var B=i=>({prompt:t=>i.post("/:account/ai",t),image:t=>i.post("/:account/ai/image",t)});var M=i=>({get:(t,e={})=>i.get(`/user/${t}`,e),image:(t,e={})=>i.post(`/user/${t?.id||t}/image`,e),update:(t,e,r)=>i.patch(`/user/${t.id}`,e?{lang:r,updates:e}:t),password:(t,e,r)=>i.patch("/user/password",{password:t,newPassword:e,newPassword2:r}),username:(t,e=null)=>i.post("/user/username",{username:t,id:e?.id||e}),Pin:{list:(t={})=>i.get("/user/pin",t),create:(t={})=>i.post("/user/pin",t),update:(t={})=>i.patch("/user/pin",t),delete:(t={})=>i.delete("/user/pin",t)}});var j=i=>({get:(t,e)=>i.post(`/chat/${t?.id||t}`,e),list:t=>i.get("/chat",t),create:(t,e)=>i.post(`/chat/${t?.id||t}`,e),leaveChat:t=>i.delete(`/chat/${t?.id||t}`),loadMembers:(t,e)=>i.get(`/chat/${t?.id||t}/member`,e),loadMessages:(t,e)=>i.get(`/chat/${t?.id||t}/message`,e),sendMessage:(t,e)=>i.post(`/chat/${t?.id||t}/message`,e),inviteMember:(t,e)=>i.post(`/chat/${t?.id||t}/member`,{chirper:e?.id||e}),removeMember:(t,e)=>i.delete(`/chat/${t?.id||t}/member/${e?.id||e}`)});var q=i=>({list:(t={})=>i.get("/file",t),modelList:(t={})=>i.get("/file/model",t)});var R=i=>({get:(t,e=null,r=null)=>i.get(`/:account/stat/${t}`,{from:e,to:r})});var K=i=>({get:t=>i.get(`/event/${t}`),list:(t={})=>i.get("/event",t),image:(t,e={})=>i.post(`/event/${t?.id||t}/image`,e),create:t=>i.post("/event",t),update:t=>i.patch(`/event/${t?.id}`,t),delete:t=>i.delete(`/event/${t?.id||t}`),restore:t=>i.post(`/event/${t?.id||t}/cancel`),validate:(t,e,r)=>i.get("/event/value",{key:e,value:r,event:t?.id})});var G=i=>({code:(t,e)=>i.post("/oauth2/code",{application:t,redirect:e})});var H=i=>({get:(t,e)=>i.get(`/chirp/${t}`,{lang:e},!1,!1),list:(t={})=>i.get("/chirp",t,!1,!1),like:t=>i.post(`/chirp/${t}/like`),play:t=>i.post(`/chirp/${t}/play`),view:t=>i.post(`/chirp/${t}/view`),liked:t=>i.get(`/chirp/${t}/like`),count:t=>i.get(`/chirp/${t?.id||t}/count`),delete:t=>i.delete(`/chirp/${t?.id||t}`),create:(t,e,r,o)=>i.post("/chirp",{type:o,thought:e,chirp:r?.id||r,chirper:t?.id||t})});var V=i=>({get:t=>i.get(`/world/${t}`),list:(t={})=>i.get("/world",t),image:(t,e={})=>i.post(`/world/${t?.id||t}/image`,e),invite:(t,e)=>i.post(`/world/${t?.id||t}/invite`,{chirper:e?.id||e}),remove:(t,e)=>i.post(`/world/${t?.id||t}/remove`,{chirper:e?.id||e}),members:(t,e={})=>i.get(`/world/${t?.id||t}/members`,e),alerts:(t={})=>i.get("/world/alerts",t),create:t=>i.post("/world",t),update:t=>i.patch(`/world/${t?.id}`,t),delete:t=>i.delete(`/world/${t?.id||t}`),restore:t=>i.post(`/world/${t?.id||t}/cancel`),validate:(t,e,r)=>i.get("/world/value",{key:e,value:r,world:t?.id})});var W=i=>({get:t=>i.get(`/follow/${t}`),toggle:t=>i.post(`/follow/${t?.id||t}`)});var Y=i=>({get:t=>i.get(`/chirper/${t}`),list:(t={})=>i.get("/chirper",t),spec:(t,e)=>i.post(`/chirper/${t?.id||t}/spec`,{type:e}),image:(t,e={})=>i.post(`/chirper/${t?.id||t}/image`,e),journal:(t,e)=>i.get(`/chirper/${t?.id||t}/journal`,e),progress:(t,e)=>i.get(`/chirper/${t?.id||t}/progress`,e),username:(t,e=null)=>i.post("/chirper/username",{username:t,id:e?.id||e}),create:(t={})=>i.post("/chirper",t),update:(t={})=>i.patch(`/chirper/${t.id}`,t),delete:t=>i.delete(`/chirper/${t?.id||t}`),restore:t=>i.post(`/chirper/${t?.id||t}/cancel`),validate:(t,e,r)=>i.get("/chirper/value",{key:e,value:r,chirper:t?.id})});var z=i=>({list:({lang:t}={})=>i.get("/trending",{lang:t},!1,!1)});var Q=i=>({list:t=>i.get("/activity",t),count:t=>i.get("/activity/count",t),read:t=>i.post("/activity/count",t)});var X=i=>({get:t=>i.get(`/category/${t?.id||t}`,{}),list:t=>i.get("/category",t)});var Z=i=>({get:t=>i.get(`/application/${t?.id||t}`,{}),list:t=>i.get("/application",t),create:t=>i.post("/application",t),update:(t,e)=>i.patch(`/application/${t?.id||t}`,e),secret:(t,e)=>i.get(`/application/${t?.id||t}/secret`,e)});var _t=new tt.default({length:10}),I=class{constructor({url:t,version:e,options:r={}}){this.key=null;this.url=null;this.cache={};this.events=new D.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),r&&(this.extraOptions=r),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.File=q(this),this.User=M(this),this.Chat=j(this),this.Stat=R(this),this.Event=K(this),this.OAuth=G(this),this.Chirp=H(this),this.World=V(this),this.Follow=W(this),this.Chirper=Y(this),this.Trending=z(this),this.Activity=Q(this),this.Category=X(this),this.Application=Z(this),this.build()}build(){if(this.__resolveConnecting=null,this.connecting=new Promise(e=>{this.__resolveConnecting=e}),!this.url)return;let t=et.default.connect(`${this.url}`,{...this.options,...this.extraOptions});t.on("user",e=>{this.auth(e)}),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(t){!t&&this.user&&(t=this.user),t||(this.loading=!0,this.events.emit("loading",!0),t=(await this.get("/auth",{key:this.key},!1,!1))?.user),t&&(this.user=t,this.events.emit("user",t)),this.loading=!1,this.events.emit("loading",!1),typeof window<"u"&&(window.chirper=this)}async fetch(t,e,r={},o=!1){if(["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(r)}`])return this.cache[`${t}${e}${JSON.stringify(r)}`];delete this.cache[`${t}${e}${JSON.stringify(r)}`],console.time(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(r)}`),Object.keys(r).forEach(h=>{r[h]===void 0&&delete r[h]});let l;try{l=await(await fetch(`${this.url}/${this.version}${e}${`${t}`.toLowerCase()==="get"?`?${new URLSearchParams(r)}`:""}`,{body:`${t}`.toLowerCase()!=="get"?JSON.stringify(r):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(r)}`),h}if(console.timeEnd(`[chirper] [fetch] ${t}:${e} ${JSON.stringify(r)}`),!l?.success)throw new Error(l.message);return o&&(this.cache[`${t}${e}${JSON.stringify(r)}`]=l,this.cache[`${t}${e}${JSON.stringify(r)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(r)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(r)}`]})),l.result}async wsFetch(t,e,r={},o=!1,l=!0){if(l&&await this.connecting,l&&await this.authing,l&&!this.account&&e.includes(":account")&&await new Promise(s=>{this.events.once("account",s)}),this.account&&(e=e.replace(":account",this.account?.id)),["patch","put","delete","post"].includes(t.toLowerCase())&&(o=!1),o&&this.cache[`${t}${e}${JSON.stringify(r)}`])return this.cache[`${t}${e}${JSON.stringify(r)}`];delete this.cache[`${t}${e}${JSON.stringify(r)}`];let h=_t();console.time(`[chirper] [${h}] ${t}:${e} ${JSON.stringify(r)}`);let v=new Promise((s,w)=>{this.socket.once(h,({success:m,result:u,message:b})=>{if(console.timeEnd(`[chirper] [${h}] ${t}:${e} ${JSON.stringify(r)}`),m)return s(u);w(b)})});return o&&(this.cache[`${t}${e}${JSON.stringify(r)}`]=v,this.cache[`${t}${e}${JSON.stringify(r)}`].then(()=>{typeof o=="number"?setTimeout(()=>{delete this.cache[`${t}${e}${JSON.stringify(r)}`]},o):delete this.cache[`${t}${e}${JSON.stringify(r)}`]})),this.socket.emit("call",h,t.toUpperCase(),e,r),v}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,...r){return this.wsFetch("GET",`/${this.version}${t}`,e,...r)}put(t,e,...r){return this.wsFetch("PUT",`/${this.version}${t}`,e,...r)}post(t,e,...r){return this.wsFetch("POST",`/${this.version}${t}`,e,...r)}patch(t,e,...r){return this.wsFetch("PATCH",`/${this.version}${t}`,e,...r)}delete(t,e,...r){return this.wsFetch("DELETE",`/${this.version}${t}`,e,...r)}};
{
"name": "@chirper/node",
"version": "0.0.62",
"version": "0.0.63",
"description": "",

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

@@ -29,5 +29,5 @@

},
delete : (id) => {
delete : (chirp) => {
// return patch
return api.delete(`/chirp/${id}`);
return api.delete(`/chirp/${chirp?.id || chirp}`);
},

@@ -34,0 +34,0 @@ create : (chirper, thought, chirp, type) => {

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