skapi-js 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/skapi.cjs CHANGED
@@ -214,7 +214,7 @@ var Nn=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var ee=(n=>t
214
214
  runInterval(); // Start interval
215
215
  `,o=new Blob([s],{type:"application/javascript"});Z=new Worker(URL.createObjectURL(o)),Z.onmessage=c=>{r.readyState===1&&r.send(JSON.stringify({action:"keepAlive"}));},i(r);},r.onmessage=async s=>{let o="";try{o=JSON.parse(decodeURI(s.data)),this.log("socket onmessage",o);}catch{return}let c;switch(true){case !!o?.["#message"]:c="message";break;case !!o?.["#private"]:c="private";break;case !!o?.["#notice"]:c="notice";break;case !!o?.["#rtc"]:c="rtc";break;case !!o?.["#error"]:c="error";break}if(!c)return;let l={type:c,message:o?.["#rtc"]||o?.["#message"]||o?.["#private"]||o?.["#notice"]||o?.["#error"]||null,sender:o?.["#user_id"]||null,sender_cid:o?.["#scid"]?"cid:"+o["#scid"]:null,sender_rid:o?.["#srid"]||null,code:o?.["#code"]||null};if(c==="notice")n(l);else if(c==="rtc"){if(l.sender!==this.user.user_id){let d=l.message;if(d.hungup){K[l.sender_cid]&&(K[l.sender_cid](false),delete K[l.sender_cid]),H[l.sender_cid]&&delete H[l.sender_cid],I?.[l.sender_cid]&&Q.bind(this)({cid:l.sender_cid}),l.type="rtc:closed",n(l);return}if(d.candidate&&qe.bind(this)(d.candidate,l.sender_cid),d.sdpoffer&&($e.bind(this)(d.sdpoffer,l.sender_cid),H[l.sender_cid]||(H[l.sender_cid]=l.sender_cid,delete l.message,l.connectRTC=zt.bind(this)(l),l.type="rtc:incoming",l.hangup=(()=>{I[l.sender_cid]?Q.bind(this)({cid:l.sender_cid}):H[l.sender_cid]&&(delete H[l.sender_cid],r.send(JSON.stringify({action:"rtc",uid:l.sender_cid,content:{hungup:this.user.user_id},token:this.session.accessToken.jwtToken})));}).bind(this),n(l))),d.pickup&&K[l.sender_cid]&&(K[l.sender_cid](true),delete K[l.sender_cid]),d.sdpanswer&&I[l.sender_cid])if(I[l.sender_cid].signalingState==="have-local-offer")await I[l.sender_cid].setRemoteDescription(new RTCSessionDescription(d.sdpanswer));else throw new a("Invalid signaling state.",{code:"INVALID_REQUEST"})}}else n(l);},r.onclose=()=>{ge?(this.log("realtime onclose","WebSocket connection closed."),n({type:"close",message:"WebSocket connection closed."})):(this.log("realtime onclose","WebSocket unexpected close."),n({type:"error",message:"Skapi: WebSocket unexpected close."}),se++,se<3?(this.log("realtime onclose","Reconnecting to WebSocket server..."+se),n({type:"reconnect",message:"Reconnecting to WebSocket server..."+se}),ke.bind(this)(n,3e3,"reconnect")):(this.log("realtime onclose","Max reconnection attempts reached."),n({type:"error",message:"Skapi: Max reconnection attempts reached."})));},r.onerror=()=>{this.log("realtime onerror","WebSocket connection error."),n({type:"error",message:"Skapi: WebSocket connection error."});};},e);});}async function Yt(n,e,t){if(typeof window>"u"||window._runningInNodeJS)throw new a("WebSocket is not supported in Node.js environment.",{code:"NOT_SUPPORTED"});let i=this.__socket?await this.__socket:this.__socket;if(!i)throw new a("No realtime connection. Execute connectRealtime() before this method.",{code:"INVALID_REQUEST"});if(!e)throw new a("No recipient.",{code:"INVALID_REQUEST"});await ne.bind(this)(),n=D(n).data;let r="";if(t&&(t=g.Params(t,{config:{always:"boolean"},title:"string",body:"string"},["title","body"]),r=JSON.stringify({title:t.title,body:t.body}),new Blob([r]).size>3072))throw new a("Notification size exceeds 3kb.",{code:"INVALID_PARAMETER"});if(i.readyState===1){try{g.UserId(e),i.send(JSON.stringify({action:"sendMessage",uid:e,content:n,notification:r,notificationConfig:t?.config||{},token:`IdT:${this.service}:${this.owner}:`+(this.bearerToken||this.session?.idToken?.jwtToken||"null")}));}catch(s){if(this.log("postRealtime:err",{err:s}),Y!==e)throw new a(`User has not joined to the recipient group. Run joinRealtime({ group: "${e}" })`,{code:"INVALID_REQUEST"});i.send(JSON.stringify({action:"broadcast",rid:e,content:n,notification:r,notificationConfig:t?.config||{},token:`IdT:${this.service}:${this.owner}:`+(this.bearerToken||this.session?.idToken?.jwtToken||"null")}));}return {type:"success",message:"Message sent."}}throw new a("Realtime connection is not open. Try reconnecting with connectRealtime().",{code:"INVALID_REQUEST"})}async function Be(n){if(typeof window>"u"||window._runningInNodeJS)throw new a("WebSocket is not supported in Node.js environment.",{code:"NOT_SUPPORTED"});let e=this.__socket?await this.__socket:this.__socket;if(!e)throw new a("No realtime connection. Execute connectRealtime() before this method.",{code:"INVALID_REQUEST"});await ne.bind(this)(),n=D(n,{nullIfEmpty:true}).data;let{group:t=null}=n;if(!t&&!Y)return {type:"success",message:"Left realtime message group."};if(t!==null&&typeof t!="string")throw new a('"group" must be a string | null.',{code:"INVALID_PARAMETER"});return e.send(JSON.stringify({action:"joinRoom",rid:t,token:this.session.accessToken.jwtToken})),Y=t,{type:"success",message:t?`Joined realtime message group: "${t}".`:"Left realtime message group."}}async function en(n,e){n=g.Params(n,{user_id:i=>g.UserId(i,'User ID in "user_id"'),group:["string",()=>{if(!Y)throw new a('No group has been joined. Otherwise "group" is required.',{code:"INVALID_REQUEST"});return Y}]});let t=await R.bind(this)("get-ws-group",n,{fetchOptions:e,auth:true,method:"post"});return t.list=t.list.map(i=>({user_id:i.uid.split("#")[1],cid:"cid:"+i.cid})),t}async function tn(n,e){if(await this.__connection,n||(n={searchFor:"group",value:" ",condition:">"}),n=g.Params(n,{searchFor:["group","number_of_users",()=>"group"],value:["string","number",()=>n?.searchFor&&n?.searchFor==="number_of_users"?0:" "],condition:[">",">=","=","<","<=","!=","gt","gte","eq","lt","lte","ne"],range:["string","number"]}),n.condition||(n.value===" "||!n.value?n.condition=">":n.condition="="),n.range&&n.condition&&delete n.condition,n.searchFor==="number_of_users"&&typeof n.value!="number")throw new a('"value" must be a number.',{code:"INVALID_PARAMETER"});if(n.searchFor==="group"&&typeof n.value!="string")throw new a('"value" must be a string.',{code:"INVALID_PARAMETER"});if(n.hasOwnProperty("range")&&typeof n.range!=typeof n.value)throw new a(`"range" must be a ${typeof n.value}.`,{code:"INVALID_PARAMETER"});let t=await R.bind(this)("get-ws-group",n,{fetchOptions:e,auth:true,method:"post"});return t.list=t.list.map(i=>({group:i.rid.split("#")[1],number_of_users:i.cnt})),t}var kr=typeof FormData<"u",xr=typeof HTMLFormElement<"u",vr=typeof SubmitEvent<"u";async function nn(n){let e=false,t=r=>{for(let s in r)if(typeof r[s]=="string"&&r[s].includes("$CLIENT_SECRET")){e=true;break}};if(n=g.Params(n,{url:r=>{if(!r||typeof r!="string")throw new a('"url" should be type: <string>.',{code:"INVALID_PARAMETER"});return g.Url(r),r.includes("$CLIENT_SECRET")&&(e=true),r},clientSecretName:"string",method:r=>{if(r&&typeof r!="string")throw new a('"method" should be either "GET" or "POST" or "DELETE" or "PUT".',{code:"INVALID_PARAMETER"});let s=r.toLowerCase();if(s!=="get"&&s!=="post"&&s!=="delete"&&s!=="put")throw new a('"method" should be either "GET" or "POST" or "DELETE" or "PUT".',{code:"INVALID_PARAMETER"});return s},headers:r=>{if(r&&typeof r!="object")throw new a('"headers" should be type: <object>.',{code:"INVALID_PARAMETER"});return t(r),r},data:r=>{if(r&&typeof r!="object")throw new a('"data" should be type: <object>.',{code:"INVALID_PARAMETER"});return t(r),r},params:r=>{if(r&&typeof r!="object")throw new a('"params" should be type: <object>.',{code:"INVALID_PARAMETER"});return t(r),r}},["clientSecretName","method","url"]),!e)throw new a(`At least one parameter value should include "$CLIENT_SECRET" in ${n.method.toLowerCase()==="post"?'"data"':'"params"'} or "headers".`,{code:"INVALID_PARAMETER"});await this.__connection;let i=!!this.__user;return R.bind(this)("csr",n,{auth:i})}async function rn(n){await this.__connection;let e={name:"string",email:t=>(g.Email(t),t),subject:"string",message:"string"};return n=g.Params(n,e,["name","email","subject","message"]),await R.bind(this)("send-inquiry",n),"SUCCESS: Inquiry has been sent."}async function sn(n,e){if(await this.__connection,kr&&n instanceof FormData||xr&&n instanceof HTMLFormElement||vr&&n instanceof SubmitEvent){if(!e)throw new a("Url string as a second argument is required when form is passed.",{code:"INVALID_PARAMETER"});let i=D(n);n={url:e,data:i.data,sync:true};}let t={url:i=>g.Url(i),data:i=>i,sync:["boolean",()=>true]};if(Array.isArray(n))for(let i of n)i=g.Params(i,t);else n=g.Params(n,t);return R.bind(this)("post-secure",n,{auth:true})}async function on(n,e){await this.__connection;let{auth:t=false,method:i="POST",bypassAwaitConnection:r=false,responseType:s,contentType:o,progress:c}=e||{};if(e=Object.assign({auth:t,method:i,bypassAwaitConnection:r,responseType:s,contentType:o},{fetchOptions:{progress:c}}),typeof n!="object"&&(o==="application/json"||o===void 0))throw new a('"data" should be type: <object>.',{code:"INVALID_PARAMETER"});return R.bind(this)("mock",n,e)}async function an(n,e){await this.__connection,n=g.Params(n||{},{access_group:i=>{if(i==="authorized"&&(i=1),i==="public"&&(i=0),typeof i!="number")throw new a('"access_group" should be type number.',{code:"INVALID_PARAMETER"});if(i<0)throw new a('"access_group" should be zero or a positive number.',{code:"INVALID_PARAMETER"});if(i>this.__user.access_group)throw new a("User has no access.",{code:"INVALID_REQUEST"});return i}});let t=await R.bind(this)("get-feed",n,{auth:true,fetchOptions:e});for(let i in t.list)t.list[i]=await ie.bind(this)(t.list[i]);return t}function fe(n){if(n===this.__user.user_id)throw new a(`"user_id" cannot be the user's own ID.`,{code:"INVALID_PARAMETER"});return g.UserId(n,'"user_id"')}async function cn(n,e){if(n=D(n,{ignoreEmpty:true}).data,n=g.Params(n,{subscriber:i=>g.UserId(i,'User ID in "subscriber"'),subscription:fe.bind(this),blocked:"boolean"}),!n.subscriber&&!n.subscription)throw new a('At least either "subscriber" or "subscription" should have a value.',{code:"INVALID_PARAMETER"});let t=await R.bind(this)("get-subscription",n,Object.assign({auth:true},{fetchOptions:e}));return t.list=t.list.map((i=>{let r={};if(i.sub){let s=i.sub.split("#");r.subscriber=s[2],r.subscription=s[0];}else r.subscriber=i.subscriber,r.subscription=i.subscription;return r.timestamp=i?.timestamp||i.stmp,r.blocked=i?.blocked||i.grp.substring(0,1)==="N",Object.assign(r,i.opt),r})),t}async function ln(n){await this.__connection,n=g.Params(n,{user_id:fe.bind(this),get_feed:["boolean",()=>false],get_notified:["boolean",()=>false],get_email:i=>{if(i&&!this.__user.email||!this.__user.email_verified)throw new a("User has no verified email address.",{code:"INVALID_REQUEST"});return !!i}},["user_id"]);let e=await R.bind(this)("subscription",{subscribe:n.user_id,option:{get_feed:n.get_feed,get_notified:n.get_notified,get_email:n.get_email||false}},{auth:true}),t={};if(e.sub){let i=e.sub.split("#");t.subscriber=i[2],t.subscription=i[0];}else t.subscriber=e.subscriber,t.subscription=e.subscription;return t.timestamp=e?.timestamp||e.stmp,t.blocked=e?.blocked||e.grp.substring(0,1)==="N",Object.assign(t,e.opt),t}async function un(n){await this.__connection;let{user_id:e}=g.Params(n,{user_id:fe.bind(this)},["user_id"]);return await R.bind(this)("subscription",{unsubscribe:e},{auth:true})}async function dn(n){await this.__connection;let{user_id:e}=g.Params(n,{user_id:fe.bind(this)},["user_id"]);return await R.bind(this)("subscription",{block:e},{auth:true})}async function gn(n){await this.__connection;let{user_id:e}=g.Params(n,{user_id:fe.bind(this)},["user_id"]);return await R.bind(this)("subscription",{unblock:e},{auth:true})}async function fn(n,e){await this.__connection;let t=await M.bind(this)();n=g.Params(n,{user_id:o=>{if(o!==this.__user.user_id&&!t)throw new a("No access.",{code:"INVALID_REQUEST"});return o},group:o=>{if(o==="public"&&(o=0),o==="authorized"&&(o=1),typeof o!="number")throw new a('"group" should be type number | "public" | "authorized".',{code:"INVALID_PARAMETER"});return o}});let i=await R.bind(this)("get-newsletter-subscription",n,{auth:true,fetchOptions:e||null}),r=i?.list||i,s=[];Array.isArray(r)||(r=[]);for(let o of r){let c=o.subt.split("#"),l=true;c[0].charAt(0)==="@"&&(l=false,c[0]=c[0].substring(1));let d=parseInt(c[0]);s.push({timestamp:o.stmp,group:d,subscribed_email:c[1],active:l});}return i?.list?(i.list=s,i):s}async function hn(n){await this.__connection;let e=g.Params(n||{},{email:t=>Array.isArray(t)&&t.length>0?t.length===1?g.Email(t[0]):t.map(i=>g.Email(i)):g.Email(t),group:["number","public","authorized","admin",t=>{if(typeof t!="string"||t.length>20||!/^[a-zA-Z0-9]+$/.test(t))throw new a('"group" should be an alphanumeric string without spaces and less than 20 characters.',{code:"INVALID_PARAMETER"});return t}],redirect:t=>g.Url(t)},this.__user?["group"]:["email","group"]);return R.bind(this)(`subscribe-${this.__user?"":"public-"}newsletter`,e,{auth:!!this.__user})}async function pn(n){await this.__connection,n=g.Params(n,{group:["number","public","authorized","admin"]},["group"]);let e=Object.assign({action:"unsubscribe"},n);return R.bind(this)("subscribe-newsletter",e,{auth:true})}async function mn(n,e){let t=await M.bind(this)(),i={message_id:"string",timestamp:"number",read:"number",complaint:"number",subject:"string",bounced:"number"};n||(e=Object.assign({ascending:false},e||{})),n=D(n).data,n=n||{searchFor:"timestamp",value:Date.now(),condition:"<",group:"public"},n=g.Params(n,{searchFor:["message_id","timestamp","subject","complaint","read","bounced"],value:l=>{if(typeof l!==i[n.searchFor])throw new a(`"value" type does not match the type of "${n.searchFor}" index.`,{code:"INVALID_PARAMETER"});if(typeof l=="string"&&!l)throw new a('"value" should not be empty string.',{code:"INVALID_PARAMETER"});return l},range:l=>{if(!n.hasOwnProperty("value")||typeof l!=typeof n.value)throw new a('"range" should match type of "value".',{code:"INVALID_PARAMETER"});return l},condition:[">",">=","=","<","<=","gt","gte","eq","lt","lte",()=>"="],group:l=>{if(l==="public")return 0;if(!this.session)throw new a("User should be logged in.",{code:"INVALID_REQUEST"});if(l==="authorized")return 1;if(typeof l=="number"){if(!t&&l>parseInt(this.user?.access_group||this.session?.idToken?.payload?.access_group))throw new a("User has no access.",{code:"INVALID_REQUEST"});return l}throw new a('"group" should be type: number | "public" | "authorized".',{code:"INVALID_PARAMETER"})}},["searchFor","value","group"]);let r=n.group===0?"get-public-newsletters":"get-newsletters",s=await R.bind(this)(r,n,Object.assign({method:"get",auth:r==="get-public-newsletters"?!!this.__user:true},{fetchOptions:e})),o={message_id:"mid",timestamp:"stmp",complaint:"cmpl",read:"read",subject:"subj",bounced:"bnce",url:"url",delivered:"delv"},c={message_id:"",timestamp:0,complaint:0,read:0,subject:"",bounced:"",url:"",delivered:0};return s.list=s.list.map(l=>{let d={};for(let h in o)d[h]=l[o[h]]||c[h];return d.bounced=String(d.bounced),d}),s}async function _n(n){let e=g.Params(n,{user_id:i=>g.UserId(i,'"user_id"')},["user_id"]);if(e?.service&&e?.owner?e={service:e?.service,owner:e?.owner,block:e.user_id}:e={block:e.user_id},!await M.bind(this)()){if(!this.__user)throw new a("User needs to login.",{code:"INVALID_REQUEST"});if(this.__user.access_group<90)throw new a("Invalid access.",{code:"INVALID_REQUEST"})}return await R.bind(this)("block-account",e,{auth:true})}async function bn(n){let e=g.Params(n,{user_id:i=>g.UserId(i,'"user_id"')},["user_id"]);if(e?.service&&e?.owner?e={service:e?.service,owner:e?.owner,unblock:e.user_id}:e={unblock:e.user_id},!await M.bind(this)()){if(!this.__user)throw new a("User needs to login.",{code:"INVALID_REQUEST"});if(this.__user.access_group<90)throw new a("Invalid access.",{code:"INVALID_REQUEST"})}return await R.bind(this)("block-account",e,{auth:true})}async function yn(n){let e=g.Params(n,{user_id:i=>g.UserId(i,'"user_id"')},["user_id"]);if(e?.service&&e?.owner?e={service:e?.service,owner:e?.owner,delete:e.user_id}:e={delete:e.user_id},!await M.bind(this)()){if(!this.__user)throw new a("User needs to login.",{code:"INVALID_REQUEST"});if(this.__user.access_group<90)throw new a("Invalid access.",{code:"INVALID_REQUEST"})}return await R.bind(this)("remove-account",e,{auth:true})}async function wn(n,e){let t={email:s=>g.Email(s),password:s=>g.Password(s),name:"string",username:"string",gender:"string",address:s=>{if(!s)return "";if(typeof s=="string")return s;if(typeof s=="object")return JSON.stringify(s)},birthdate:s=>g.Birthdate(s),phone_number:s=>g.PhoneNumber(s),picture:s=>{if(s)return g.Url(s)},profile:s=>{if(s)return g.Url(s)},website:s=>{if(s)return g.Url(s)},nickname:"string",misc:"string",email_public:["boolean",()=>false],gender_public:["boolean",()=>false],address_public:["boolean",()=>false],birthdate_public:["boolean",()=>false],phone_number_public:["boolean",()=>false],openid_id:"string",access_group:s=>{try{typeof s=="string"&&(s=s==="admin"?99:parseInt(s));}catch{throw new a('"access_group" is invalid. Should be type <number>.',{code:"INVALID_PARAMETER"})}if(typeof s!="number"||s<1||s>100)throw new a('"access_group" is invalid. Should be type <number> of range 1~99',{code:"INVALID_PARAMETER"});return s}},i=g.Params(n,t,["email"]);if(e=g.Params(e,{confirmation_url:s=>{let o=s;if(typeof s=="string")o=g.Url(s);else throw new a('"options.confirmation_url" should be type: <string>.',{code:"INVALID_PARAMETER"});if(o&&!i.email)throw new a('"email" is required for signup confirmation.',{code:"INVALID_PARAMETER"});return o},email_subscription:s=>{if(typeof s!="boolean")throw new a('"options.email_subscription" should be type: <boolean>.',{code:"INVALID_PARAMETER"});if(!e?.confirmation_url)throw new a('"options.confirmation_url" is required for email subscription.',{code:"INVALID_PARAMETER"});return s},template:s=>{if(typeof s!="object"||!s.url||!s.subject)throw new a('"options.template" should be type: <object> with "url" and "subject".',{code:"INVALID_PARAMETER"});return {url:g.Url(s.url),subject:s.subject}}}),i.signup_confirmation=e?.confirmation_url||true,i.email_subscription=e?.email_subscription||false,i.template=e?.template||{},!await M.bind(this)()){if(!this.__user)throw new a("User needs to login.",{code:"INVALID_REQUEST"});if(this.__user.access_group<90)throw new a("Invalid access.",{code:"INVALID_REQUEST"})}return await R.bind(this)("admin-signup",i,{auth:true})}async function En(n){let e={email:r=>g.Email(r),password:r=>g.Password(r),openid_id:"string",name:"string",username:"string",gender:"string",address:r=>{if(!r)return "";if(typeof r=="string")return r;if(typeof r=="object")return JSON.stringify(r)},birthdate:r=>g.Birthdate(r),phone_number:r=>g.PhoneNumber(r),picture:r=>r?g.Url(r):"",profile:r=>r?g.Url(r):"",website:r=>r?g.Url(r):"",nickname:"string",misc:"string",email_public:["boolean",()=>false],gender_public:["boolean",()=>false],address_public:["boolean",()=>false],birthdate_public:["boolean",()=>false],phone_number_public:["boolean",()=>false],access_group:r=>{try{typeof r=="string"&&(r=parseInt(r));}catch{throw new a('"access_group" is invalid. Should be type <number>.',{code:"INVALID_PARAMETER"})}if(typeof r!="number"||r<1||r>100)throw new a('"access_group" is invalid. Should be type <number> of range 1~99',{code:"INVALID_PARAMETER"});return r}},t=g.Params(n,e,["email","password"]);if(!await M.bind(this)()){if(!this.__user)throw new a("User needs to login.",{code:"INVALID_REQUEST"});if(this.__user.access_group<90)throw new a("Invalid access.",{code:"INVALID_REQUEST"})}return await R.bind(this)("admin-signup",t,{auth:true})}async function Rn(n){if(n=g.Params(n,{user_id:t=>g.UserId(t,'"user_id"'),access_group:t=>{try{typeof t=="string"&&(t=parseInt(t));}catch{throw new a('"access_group" is invalid. Should be type <number>.',{code:"INVALID_PARAMETER"})}if(typeof t=="number"&&t>0&&t<100)return t;throw new a('"access_group" is invalid. Should be type <number> of range 1~99',{code:"INVALID_PARAMETER"})}},["user_id","access_group"]),!await M.bind(this)()){if(!this.__user)throw new a("User needs to login.",{code:"INVALID_REQUEST"});if(this.__user.access_group<90)throw new a("Invalid access.",{code:"INVALID_REQUEST"})}return await R.bind(this)("grant-access",n,{auth:true})}async function An(n,e){if(n=g.Params(n,{email:"string"}),!await M.bind(this)()){if(!this.__user)throw new a("User needs to login.",{code:"INVALID_REQUEST"});if(this.__user.access_group<90)throw new a("Invalid access.",{code:"INVALID_REQUEST"})}let i=await R.bind(this)("invitation-list",Object.assign({mode:"search"},n),{fetchOptions:e,auth:true});return i.list=i.list.map(r=>ae(r.user)),i}async function In(n){if(n=g.Params(n,{email:t=>g.Email(t)},["email"]),!await M.bind(this)()){if(!this.__user)throw new a("User needs to login.",{code:"INVALID_REQUEST"});if(this.__user.access_group<90)throw new a("Invalid access.",{code:"INVALID_REQUEST"})}return await R.bind(this)("invitation-list",Object.assign({mode:"cancel"},n),{auth:true})}async function Tn(n){if(n=g.Params(n,{email:t=>g.Email(t)},["email"]),!await M.bind(this)()){if(!this.__user)throw new a("User needs to login.",{code:"INVALID_REQUEST"});if(this.__user.access_group<90)throw new a("Invalid access.",{code:"INVALID_REQUEST"})}return await R.bind(this)("invitation-list",Object.assign({mode:"resend"},n),{auth:true})}async function Pn(n){if(typeof window>"u"||window._runningInNodeJS)throw new a("Push Notifications are not supported in Node.js environment.",{code:"NOT_SUPPORTED"});if(await this.__connection,!n.endpoint)throw new a("Missing parameter: endpoint",{code:"INVALID_PARAMETER"});if(!n.keys||!n.keys.p256dh||!n.keys.auth)throw new a("Missing parameter: keys.p256dh or keys.auth",{code:"INVALID_PARAMETER"});return await R.bind(this)("store-subscription",{endpoint:n.endpoint,keys:n.keys},{auth:true}),"SUCCESS: Subscribed to receive notifications."}async function Sn(n){if(typeof window>"u"||window._runningInNodeJS)throw new a("Push Notifications are not supported in Node.js environment.",{code:"NOT_SUPPORTED"});if(await this.__connection,!n.endpoint)throw new a("Missing parameter: endpoint",{code:"INVALID_PARAMETER"});if(!n.keys||!n.keys.p256dh||!n.keys.auth)throw new a("Missing parameter: keys.p256dh or keys.auth",{code:"INVALID_PARAMETER"});return await R.bind(this)("delete-subscription",{endpoint:n.endpoint,keys:n.keys},{auth:true}),"SUCCESS: Unsubscribed from notifications."}async function kn(){if(typeof window>"u"||window._runningInNodeJS)throw new a("Push Notifications are not supported in Node.js environment.",{code:"NOT_SUPPORTED"});return await this.__connection,{VAPIDPublicKey:await R.bind(this)("get-vapid-public-key",null,{auth:true})}}async function xn(n,e){if(typeof window>"u"||window._runningInNodeJS)throw new a("Push Notifications are not supported in Node.js environment.",{code:"NOT_SUPPORTED"});await this.__connection;let{title:t,body:i}=D(n||{},{nullIfEmpty:true}).data;if(!t)throw new a("Missing parameter: message title",{code:"INVALID_PARAMETER"});if(!i)throw new a("Missing parameter: message body",{code:"INVALID_PARAMETER"});let r={title:t,body:i};return e?(typeof e=="string"&&(e=[e]),r.user_ids=e):r.user_ids="all_users",await R.bind(this)("push-notification",r,{auth:true}),"SUCCESS: Notification sent."}async function vn(n){await this.__connection,n=g.Params(n,{spell:"string",name:"string",magic:t=>t},["spell","name"]);await R.bind(this)("castspell",n);return `The spell "${n.spell}" has been cast.`}async function Dn(n){return await this.__connection,n=g.Params(n||{},{search:["spell","name",()=>"spell"],value:"string"}),await R.bind(this)("getspell",n)}async function Un(n){await this.__connection,n=g.Params(n,{message:"string",name:"string"},["message","name"]);let e=await R.bind(this)("dopamine",n,{auth:true}),t=e?.previous_message?.message,i=e?.previous_message?.name;if($())t&&i&&window.alert(`${i} said: ${t}`),window.location.href=e.video;else return t&&i?`${i} said: ${t}
216
216
  Watch the video here: ${e.video}`:`Your message has been uploaded for future generations to receive.
217
- Watch the video here: ${e.video}`}var b=class{constructor(e,t,i,r){this.__version="1.5.0";this.session=null;this.connection=null;this.__my_unique_ids={};this.userPool=null;this.__socket=null;this.__mediaStream=null;this.host="skapi";this.hostDomain="skapi.com";this.target_cdn="d3e9syvbtso631";this.customApiDomain="skapi.dev";this.requestBatchSize=30;this.__disabledAccount=null;this.__cached_requests={};this.__startKeyHistory={};this.__request_signup_confirmation=null;this.__private_access_key={};this.__class_properties_has_been_cached=false;this.__user=null;this._userProfileListeners=[];this._onLoginListeners=[];this._onBatchProcessListeners=[];this.validate={userId(e){try{return g.UserId(e),!0}catch{return false}},url(e){try{return g.Url(e),!0}catch{return false}},phoneNumber(e){try{return g.PhoneNumber(e),!0}catch{return false}},birthdate(e){try{return g.Birthdate(e),!0}catch{return false}},email(e){try{return g.Email(e),!0}catch{return false}},params(e,t,i){return g.Params(e,t,i)}};this.util={MD5:V,generateRandom:oe,toBase62:Ge,fromBase62:B,decodeServiceId:De,formatServiceId:Xe,extractFormData:D,terminatePendingRequests:It,request:(e,t,i)=>R.bind(this)(e,t,i,{ignoreService:true})};this.__network_logs=false;this.__endpoint_version="v1";this.__public_identifier="";this.bearerToken="";this.registerTicket=nt.bind(this);this.unregisterTicket=rt.bind(this);if(!e||typeof e!="string")throw this._alert("Service ID is required."),new a("Service ID is required.",{code:"INVALID_PARAMETER"});let s=e.split("-").length;if(s===2||s===7)try{let f=De(e);i&&typeof i=="object"&&(r=i),t&&typeof t=="object"&&(i=t),t=f.owner,e=f.service;}catch{throw this._alert("Service ID is invalid."),new a("Service ID is invalid.",{code:"INVALID_PARAMETER"})}if(!t||typeof t!="string")throw this._alert("Owner ID is invalid."),new a("Owner ID is invalid.",{code:"INVALID_PARAMETER"});if(e.toLowerCase()==="service_id")throw this._alert('Replace "service_id" with your actual Service ID.'),new a("Service ID is required.",{code:"INVALID_PARAMETER"});if(t!==this.host)try{g.UserId(t,'"owner"');}catch{throw this._alert("Owner ID is invalid."),new a("Owner ID is invalid.",{code:"INVALID_PARAMETER"})}this.service=e,this.owner=t;let l=true;if(i&&(typeof i.autoLogin=="boolean"&&(l=i.autoLogin),typeof i.requestBatchSize=="number")){if(i.requestBatchSize<1)throw new a('"requestBatchSize" must be greater than 0.',{code:"INVALID_PARAMETER"});this.requestBatchSize=i.requestBatchSize;}i?.eventListener&&typeof i.eventListener=="object"&&(i.eventListener?.onLogin&&typeof i.eventListener.onLogin=="function"&&(this.onLogin=i.eventListener.onLogin),i.eventListener?.onUserUpdate&&typeof i.eventListener.onUserUpdate=="function"&&(this.onUserUpdate=i.eventListener.onUserUpdate),i.eventListener?.onBatchProcess&&typeof i.eventListener.onBatchProcess=="function"&&(this.onBatchProcess=i.eventListener.onBatchProcess)),this.target_cdn=r?.target_cdn||this.target_cdn,this.hostDomain=r?.hostDomain||this.hostDomain,this.customApiDomain=r?.customApiDomain||this.customApiDomain,this.__network_logs=!!r?.network_logs;let d=`https://${this.target_cdn}.cloudfront.net`,h=e.substring(0,4);this.admin_endpoint=fetch(`${d}/${h}/admin-${this.__endpoint_version}.json`).then(f=>f.blob()).then(f=>new Promise((y,P)=>{let _=new FileReader;_.onloadend=()=>y(_.result),_.onerror=P,_.readAsDataURL(f);})).then(f=>{try{return typeof f=="string"?JSON.parse(atob(f.split(",")[1])):null}catch{throw new a("Service does not exist. Create your service from skapi.com",{code:"NOT_EXISTS"})}}),this.record_endpoint=fetch(`${d}/${h}/record-${this.__endpoint_version}.json`).then(f=>f.blob()).then(f=>new Promise((y,P)=>{let _=new FileReader;_.onloadend=()=>y(_.result),_.onerror=P,_.readAsDataURL(f);})).then(f=>{try{return typeof f=="string"?JSON.parse(atob(f.split(",")[1])):null}catch{throw new a("Service does not exist. Create your service from skapi.com",{code:"NOT_EXISTS"})}});let u=$();if(u&&!window.sessionStorage)throw this._alert("This browser is not supported."),new Error("This browser is not supported.");let p=u?JSON.parse(window.sessionStorage.getItem(`${e}#${t}`)||"null"):null;if(this.log("constructor:restore",p),p?.connection){for(let f in p)this[f]=p[f];p.__public_identifier||(this.__public_identifier=`${this.service}:${this.owner}:${oe(16)}`);}this.__authConnection=(async()=>{let f=await this.admin_endpoint,y={UserPoolId:f.userpool_id,ClientId:f.userpool_client};ve()&&(y.Storage=window.localStorage),this.userPool=new amazonCognitoIdentityJs.CognitoUserPool(y);try{this.user||await F.bind(this)().getSession({skipUserUpdateEventTrigger:!0}),this.user&&(!p?.connection&&!l?G.bind(this)():(this._runOnLoginListeners(this.user),this._runOnUserUpdateListeners(this.user)));}catch{}})();let A=u?window.sessionStorage.getItem(`${this.service}:uniqueids`):null;if(A)try{this.__my_unique_ids=JSON.parse(A);}catch{this.__my_unique_ids={};}this.__connection=(async()=>{let f=null;await this.record_endpoint,p?.connection||(f=this._updateConnection());let y=()=>{if(this.__class_properties_has_been_cached)return;let P=()=>{let _={},k=["__startKeyHistory","__disabledAccount","__cached_requests","__request_signup_confirmation","__public_identifier","connection"];if(this.connection){for(let S of k)_[S]=this[S];u&&window.sessionStorage.setItem(`${e}#${t}`,JSON.stringify(_)),this.__class_properties_has_been_cached=true;}};return f instanceof Promise?f.then(()=>P()):P()};return u&&(window.addEventListener("beforeunload",()=>{this.closeRealtime(),y();}),window.addEventListener("visibilitychange",()=>{y();})),await f,await this.__authConnection,this.connection})(),this.__connection.then(f=>{((f?.group||0)<3||this.__network_logs)&&this.version();});}get user(){return this.__user&&Object.keys(this.__user).length?JSON.parse(JSON.stringify(this.__user)):null}set user(e){}get onLogin(){return this._onLoginListeners}set onLogin(e){typeof e=="function"&&this._onLoginListeners.push(e);}get onUserUpdate(){return this._userProfileListeners}set onUserUpdate(e){typeof e=="function"&&this._userProfileListeners.push(e);}_runOnUserUpdateListeners(e){for(let t of this._userProfileListeners)typeof t=="function"&&t(e);}_runOnLoginListeners(e){for(let t of this._onLoginListeners)typeof t=="function"&&t(e);}get onBatchProcess(){return this._onBatchProcessListeners}set onBatchProcess(e){typeof e=="function"&&this._onBatchProcessListeners.push(e);}_alert(e){$()&&typeof window.alert=="function"&&window.alert(e);}async getConnectionInfo(){let e=await this.__connection,t=e?.user_agent||($()&&typeof window.navigator?.userAgent=="string"?window.navigator.userAgent:`skapi-node/${globalThis?.process?.versions?.node||"unknown"}`);return {user_ip:e.ip,user_agent:t,user_location:e.locale,service_name:e.service_name,version:this.__version}}async _updateConnection(){try{this.connection=await R.bind(this)("service",{service:this.service,owner:this.owner},{bypassAwaitConnection:!0,method:"get"});}catch(e){throw this.log("connection fail",e),this._alert("Service is not available: "+(e.message||e.toString())),this.connection=null,e}return this.connection}async version(){if(await this.__connection,$()){let t=`Built with:
217
+ Watch the video here: ${e.video}`}var b=class{constructor(e,t,i,r){this.__version="1.5.1";this.session=null;this.connection=null;this.__my_unique_ids={};this.userPool=null;this.__socket=null;this.__mediaStream=null;this.host="skapi";this.hostDomain="skapi.com";this.target_cdn="d3e9syvbtso631";this.customApiDomain="skapi.dev";this.requestBatchSize=30;this.__disabledAccount=null;this.__cached_requests={};this.__startKeyHistory={};this.__request_signup_confirmation=null;this.__private_access_key={};this.__class_properties_has_been_cached=false;this.__user=null;this._userProfileListeners=[];this._onLoginListeners=[];this._onBatchProcessListeners=[];this.validate={userId(e){try{return g.UserId(e),!0}catch{return false}},url(e){try{return g.Url(e),!0}catch{return false}},phoneNumber(e){try{return g.PhoneNumber(e),!0}catch{return false}},birthdate(e){try{return g.Birthdate(e),!0}catch{return false}},email(e){try{return g.Email(e),!0}catch{return false}},params(e,t,i){return g.Params(e,t,i)}};this.util={MD5:V,generateRandom:oe,toBase62:Ge,fromBase62:B,decodeServiceId:De,formatServiceId:Xe,extractFormData:D,terminatePendingRequests:It,request:(e,t,i)=>R.bind(this)(e,t,i,{ignoreService:true})};this.__network_logs=false;this.__endpoint_version="v1";this.__public_identifier="";this.bearerToken="";this.registerTicket=nt.bind(this);this.unregisterTicket=rt.bind(this);if(!e||typeof e!="string")throw this._alert("Service ID is required."),new a("Service ID is required.",{code:"INVALID_PARAMETER"});let s=e.split("-").length;if(s===2||s===7)try{let f=De(e);i&&typeof i=="object"&&(r=i),t&&typeof t=="object"&&(i=t),t=f.owner,e=f.service;}catch{throw this._alert("Service ID is invalid."),new a("Service ID is invalid.",{code:"INVALID_PARAMETER"})}if(!t||typeof t!="string")throw this._alert("Owner ID is invalid."),new a("Owner ID is invalid.",{code:"INVALID_PARAMETER"});if(e.toLowerCase()==="service_id")throw this._alert('Replace "service_id" with your actual Service ID.'),new a("Service ID is required.",{code:"INVALID_PARAMETER"});if(t!==this.host)try{g.UserId(t,'"owner"');}catch{throw this._alert("Owner ID is invalid."),new a("Owner ID is invalid.",{code:"INVALID_PARAMETER"})}this.service=e,this.owner=t;let l=true;if(i&&(typeof i.autoLogin=="boolean"&&(l=i.autoLogin),typeof i.requestBatchSize=="number")){if(i.requestBatchSize<1)throw new a('"requestBatchSize" must be greater than 0.',{code:"INVALID_PARAMETER"});this.requestBatchSize=i.requestBatchSize;}i?.eventListener&&typeof i.eventListener=="object"&&(i.eventListener?.onLogin&&typeof i.eventListener.onLogin=="function"&&(this.onLogin=i.eventListener.onLogin),i.eventListener?.onUserUpdate&&typeof i.eventListener.onUserUpdate=="function"&&(this.onUserUpdate=i.eventListener.onUserUpdate),i.eventListener?.onBatchProcess&&typeof i.eventListener.onBatchProcess=="function"&&(this.onBatchProcess=i.eventListener.onBatchProcess)),this.target_cdn=r?.target_cdn||this.target_cdn,this.hostDomain=r?.hostDomain||this.hostDomain,this.customApiDomain=r?.customApiDomain||this.customApiDomain,this.__network_logs=!!r?.network_logs;let d=`https://${this.target_cdn}.cloudfront.net`,h=e.substring(0,4);this.admin_endpoint=fetch(`${d}/${h}/admin-${this.__endpoint_version}.json`).then(f=>f.blob()).then(f=>new Promise((y,P)=>{let _=new FileReader;_.onloadend=()=>y(_.result),_.onerror=P,_.readAsDataURL(f);})).then(f=>{try{return typeof f=="string"?JSON.parse(atob(f.split(",")[1])):null}catch{throw new a("Service does not exist. Create your service from skapi.com",{code:"NOT_EXISTS"})}}),this.record_endpoint=fetch(`${d}/${h}/record-${this.__endpoint_version}.json`).then(f=>f.blob()).then(f=>new Promise((y,P)=>{let _=new FileReader;_.onloadend=()=>y(_.result),_.onerror=P,_.readAsDataURL(f);})).then(f=>{try{return typeof f=="string"?JSON.parse(atob(f.split(",")[1])):null}catch{throw new a("Service does not exist. Create your service from skapi.com",{code:"NOT_EXISTS"})}});let u=$();if(u&&!window.sessionStorage)throw this._alert("This browser is not supported."),new Error("This browser is not supported.");let p=u?JSON.parse(window.sessionStorage.getItem(`${e}#${t}`)||"null"):null;if(this.log("constructor:restore",p),p?.connection){for(let f in p)this[f]=p[f];p.__public_identifier||(this.__public_identifier=`${this.service}:${this.owner}:${oe(16)}`);}this.__authConnection=(async()=>{let f=await this.admin_endpoint,y={UserPoolId:f.userpool_id,ClientId:f.userpool_client};ve()&&(y.Storage=window.localStorage),this.userPool=new amazonCognitoIdentityJs.CognitoUserPool(y);try{this.user||await F.bind(this)().getSession({skipUserUpdateEventTrigger:!0}),this.user&&(!p?.connection&&!l?G.bind(this)():(this._runOnLoginListeners(this.user),this._runOnUserUpdateListeners(this.user)));}catch{}})();let A=u?window.sessionStorage.getItem(`${this.service}:uniqueids`):null;if(A)try{this.__my_unique_ids=JSON.parse(A);}catch{this.__my_unique_ids={};}this.__connection=(async()=>{let f=null;await this.record_endpoint,p?.connection||(f=this._updateConnection());let y=()=>{if(this.__class_properties_has_been_cached)return;let P=()=>{let _={},k=["__startKeyHistory","__disabledAccount","__cached_requests","__request_signup_confirmation","__public_identifier","connection"];if(this.connection){for(let S of k)_[S]=this[S];u&&window.sessionStorage.setItem(`${e}#${t}`,JSON.stringify(_)),this.__class_properties_has_been_cached=true;}};return f instanceof Promise?f.then(()=>P()):P()};return u&&(window.addEventListener("beforeunload",()=>{this.closeRealtime(),y();}),window.addEventListener("visibilitychange",()=>{y();})),await f,await this.__authConnection,this.connection})(),this.__connection.then(f=>{((f?.group||0)<3||this.__network_logs)&&this.version();});}get user(){return this.__user&&Object.keys(this.__user).length?JSON.parse(JSON.stringify(this.__user)):null}set user(e){}get onLogin(){return this._onLoginListeners}set onLogin(e){typeof e=="function"&&this._onLoginListeners.push(e);}get onUserUpdate(){return this._userProfileListeners}set onUserUpdate(e){typeof e=="function"&&this._userProfileListeners.push(e);}_runOnUserUpdateListeners(e){for(let t of this._userProfileListeners)typeof t=="function"&&t(e);}_runOnLoginListeners(e){for(let t of this._onLoginListeners)typeof t=="function"&&t(e);}get onBatchProcess(){return this._onBatchProcessListeners}set onBatchProcess(e){typeof e=="function"&&this._onBatchProcessListeners.push(e);}_alert(e){$()&&typeof window.alert=="function"&&window.alert(e);}async getConnectionInfo(){let e=await this.__connection,t=e?.user_agent||($()&&typeof window.navigator?.userAgent=="string"?window.navigator.userAgent:`skapi-node/${globalThis?.process?.versions?.node||"unknown"}`);return {user_ip:e.ip,user_agent:t,user_location:e.locale,service_name:e.service_name,version:this.__version}}async _updateConnection(){try{this.connection=await R.bind(this)("service",{service:this.service,owner:this.owner},{bypassAwaitConnection:!0,method:"get"});}catch(e){throw this.log("connection fail",e),this._alert("Service is not available: "+(e.message||e.toString())),this.connection=null,e}return this.connection}async version(){if(await this.__connection,$()){let t=`Built with:
218
218
  %c\r
219
219
  $$\\ $$\\ \r
220
220
  $$ | \\__|\r
@@ -229,6 +229,6 @@ $$$$$$$ |$$ | \\$$\\\\$$$$$$$ |$$$$$$$ |$$ |\r
229
229
  \\__| \r
230
230
  Version: ${this.__version}
231
231
 
232
- Full Documentation: https://docs.skapi.com/skapi.md`;console.log(t,"font-family: monospace; color:blue;"),this.connection.group===1&&console.log("%cSKAPI: THE SERVICE IS IN TRIAL MODE.","font-family: monospace; color:red;");}return this.__version}log(e,t){if(this.__network_logs){if(typeof t=="object")try{t=JSON.parse(JSON.stringify(t));}catch{t=String(t);}else typeof t=="string"&&t.length>100&&(t=t.substring(0,100)+"...");console.log(`%c${e}:`,"color: blue;",t);}}getFeed(e,t){return an.bind(this)(e,t)}closeRTC(e){return Q.bind(this)(e)}connectRTC(e,t){return Jt.bind(this)(e,t)}connectRealtime(e){return ke.bind(this)(e)}spellcast(e){return vn.bind(this)(e)}getspell(e){return Dn.bind(this)(e)}dopamine(e){return Un.bind(this)(e)}getUniqueId(e,t){return Vt.bind(this)(e,t)}resendInvitation(e){return Tn.bind(this)(e)}cancelInvitation(e){return In.bind(this)(e)}getInvitations(e,t){return An.bind(this)(e,t)}openIdLogin(e){return st.bind(this)(e)}loginWithToken(e){return ot.bind(this)(e)}clientSecretRequest(e){return nn.bind(this)(e)}consumeTicket(e){return Ye.bind(this)(e)}getConsumedTickets(e,t){return tt.bind(this)(e,t)}getTickets(e,t){return et.bind(this)(e,t)}closeRealtime(){return Zt.bind(this)()}getRealtimeUsers(e,t){return en.bind(this)(e,t)}sendInquiry(e){return rn.bind(this)(e)}blockAccount(e){return _n.bind(this)(e)}unblockAccount(e){return bn.bind(this)(e)}deleteAccount(e){return yn.bind(this)(e)}inviteUser(e,t){return wn.bind(this)(e,t)}createAccount(e){return En.bind(this)(e)}grantAccess(e){return Rn.bind(this)(e)}getRealtimeGroups(e,t){return tn.bind(this)(e,t)}postRealtime(e,t,i){return Yt.bind(this)(e,t,i)}joinRealtime(e){return Be.bind(this)(e)}getProfile(e){return it.bind(this)(e)}getFile(e,t){return Ie.bind(this)(e,t)}secureRequest(e,t){return sn.bind(this)(e,t)}getFormResponse(){return Pt.bind(this)()}getRecords(e,t){return Ut.bind(this)(e,t)}getTables(e,t){return Ot.bind(this)(e,t)}getIndexes(e,t){return Ft.bind(this)(e,t)}getTags(e,t){return Mt.bind(this)(e,t)}deleteRecords(e,t){return $t.bind(this)(e,t)}resendSignupConfirmation(){return at.bind(this)()}recoverAccount(e=false){return ct.bind(this)(e)}getUsers(e,t){return bt.bind(this)(e,t)}disableAccount(){return ut.bind(this)()}lastVerifiedEmail(e){return yt.bind(this)(e)}unsubscribeNewsletter(e){return pn.bind(this)(e)}subscribeNotification(e,t){return Pn.bind(this)({endpoint:e,keys:t})}unsubscribeNotification(e,t){return Sn.bind(this)({endpoint:e,keys:t})}vapidPublicKey(){return kn.bind(this)()}pushNotification(e,t){return xn.bind(this)(e,t)}getNewsletters(e,t){return mn.bind(this)(e,t)}getNewsletterSubscription(e,t){return fn.bind(this)(e,t)}requestUsernameChange(e){return wt.bind(this)(e)}grantPrivateRecordAccess(e){return qt.bind(this)(e)}removePrivateRecordAccess(e){return jt.bind(this)(e)}listPrivateRecordAccess(e){return Bt.bind(this)(e)}requestPrivateRecordAccessKey(e){return Kt.bind(this)(e)}deleteFiles(e){return vt.bind(this)(e)}uploadFiles(e,t){return we.bind(this)(e,t)}mock(e,t){return on.bind(this)(e,t)}login(e){return Ne.bind(this)(e)}logout(e){return ce.bind(this)(e)}signup(e,t){return lt.bind(this)(e,t)}resetPassword(e){return dt.bind(this)(e)}verifyEmail(e){return ht.bind(this)(e)}verifyPhoneNumber(e){return ft.bind(this)(e)}forgotPassword(e){return pt.bind(this)(e)}changePassword(e){return mt.bind(this)(e)}updateProfile(e){return _t.bind(this)(e)}postRecord(e,t,i){return Lt.bind(this)(e,t,i)}getSubscriptions(e,t){return cn.bind(this)(e,t)}subscribe(e){return ln.bind(this)(e)}unsubscribe(e){return un.bind(this)(e)}blockSubscriber(e){return dn.bind(this)(e)}unblockSubscriber(e){return gn.bind(this)(e)}subscribeNewsletter(e){return hn.bind(this)(e)}bulkPostRecords(e){return Ct.bind(this)(e)}};w([E()],b.prototype,"getFeed"),w([E()],b.prototype,"closeRTC"),w([E()],b.prototype,"connectRTC"),w([E()],b.prototype,"spellcast"),w([E()],b.prototype,"getspell"),w([E()],b.prototype,"dopamine"),w([E()],b.prototype,"getUniqueId"),w([E()],b.prototype,"resendInvitation"),w([E()],b.prototype,"cancelInvitation"),w([E()],b.prototype,"getInvitations"),w([E()],b.prototype,"openIdLogin"),w([E()],b.prototype,"loginWithToken"),w([E()],b.prototype,"clientSecretRequest"),w([E()],b.prototype,"consumeTicket"),w([E()],b.prototype,"getConsumedTickets"),w([E()],b.prototype,"getTickets"),w([E()],b.prototype,"getRealtimeUsers"),w([E()],b.prototype,"sendInquiry"),w([E()],b.prototype,"blockAccount"),w([E()],b.prototype,"unblockAccount"),w([E()],b.prototype,"deleteAccount"),w([E()],b.prototype,"inviteUser"),w([E()],b.prototype,"createAccount"),w([E()],b.prototype,"grantAccess"),w([E()],b.prototype,"getRealtimeGroups"),w([E()],b.prototype,"postRealtime"),w([E()],b.prototype,"joinRealtime"),w([E()],b.prototype,"getProfile"),w([E()],b.prototype,"getFile"),w([E()],b.prototype,"secureRequest"),w([E()],b.prototype,"getFormResponse"),w([E()],b.prototype,"getRecords"),w([E()],b.prototype,"getTables"),w([E()],b.prototype,"getIndexes"),w([E()],b.prototype,"getTags"),w([E()],b.prototype,"deleteRecords"),w([E()],b.prototype,"resendSignupConfirmation"),w([E()],b.prototype,"recoverAccount"),w([E()],b.prototype,"getUsers"),w([E()],b.prototype,"disableAccount"),w([E()],b.prototype,"lastVerifiedEmail"),w([E()],b.prototype,"unsubscribeNewsletter"),w([E()],b.prototype,"subscribeNotification"),w([E()],b.prototype,"unsubscribeNotification"),w([E()],b.prototype,"vapidPublicKey"),w([E()],b.prototype,"pushNotification"),w([E()],b.prototype,"getNewsletters"),w([E()],b.prototype,"getNewsletterSubscription"),w([E()],b.prototype,"requestUsernameChange"),w([E()],b.prototype,"grantPrivateRecordAccess"),w([E()],b.prototype,"removePrivateRecordAccess"),w([E()],b.prototype,"listPrivateRecordAccess"),w([E()],b.prototype,"requestPrivateRecordAccessKey"),w([E()],b.prototype,"deleteFiles"),w([E()],b.prototype,"uploadFiles"),w([E()],b.prototype,"mock"),w([E({preventMultipleCalls:true})],b.prototype,"login"),w([E()],b.prototype,"logout"),w([E({preventMultipleCalls:true})],b.prototype,"signup"),w([E({preventMultipleCalls:true})],b.prototype,"resetPassword"),w([E({preventMultipleCalls:true})],b.prototype,"verifyEmail"),w([E({preventMultipleCalls:true})],b.prototype,"verifyPhoneNumber"),w([E({preventMultipleCalls:true})],b.prototype,"forgotPassword"),w([E({preventMultipleCalls:true})],b.prototype,"changePassword"),w([E({preventMultipleCalls:true})],b.prototype,"updateProfile"),w([E()],b.prototype,"postRecord"),w([E()],b.prototype,"getSubscriptions"),w([E()],b.prototype,"subscribe"),w([E()],b.prototype,"unsubscribe"),w([E()],b.prototype,"blockSubscriber"),w([E()],b.prototype,"unblockSubscriber"),w([E()],b.prototype,"subscribeNewsletter");var Ur={};
232
+ Full Documentation: https://docs.skapi.com/skapi.md`;console.log(t,"font-family: monospace; color:blue;"),this.connection.group===1&&console.log("%cSKAPI: THE SERVICE IS IN TRIAL MODE.","font-family: monospace; color:red;");}return this.__version}log(e,t){if(this.__network_logs){if(t!==null&&typeof t=="object")try{$()?t=JSON.parse(JSON.stringify(t)):t=JSON.stringify(t,null,2);}catch{t=String(t);}else typeof t=="string"&&t.length>100&&(t=t.substring(0,100)+"...");console.log(`%c${e}:`,"color: blue;",t);}}getFeed(e,t){return an.bind(this)(e,t)}closeRTC(e){return Q.bind(this)(e)}connectRTC(e,t){return Jt.bind(this)(e,t)}connectRealtime(e){return ke.bind(this)(e)}spellcast(e){return vn.bind(this)(e)}getspell(e){return Dn.bind(this)(e)}dopamine(e){return Un.bind(this)(e)}getUniqueId(e,t){return Vt.bind(this)(e,t)}resendInvitation(e){return Tn.bind(this)(e)}cancelInvitation(e){return In.bind(this)(e)}getInvitations(e,t){return An.bind(this)(e,t)}openIdLogin(e){return st.bind(this)(e)}loginWithToken(e){return ot.bind(this)(e)}clientSecretRequest(e){return nn.bind(this)(e)}consumeTicket(e){return Ye.bind(this)(e)}getConsumedTickets(e,t){return tt.bind(this)(e,t)}getTickets(e,t){return et.bind(this)(e,t)}closeRealtime(){return Zt.bind(this)()}getRealtimeUsers(e,t){return en.bind(this)(e,t)}sendInquiry(e){return rn.bind(this)(e)}blockAccount(e){return _n.bind(this)(e)}unblockAccount(e){return bn.bind(this)(e)}deleteAccount(e){return yn.bind(this)(e)}inviteUser(e,t){return wn.bind(this)(e,t)}createAccount(e){return En.bind(this)(e)}grantAccess(e){return Rn.bind(this)(e)}getRealtimeGroups(e,t){return tn.bind(this)(e,t)}postRealtime(e,t,i){return Yt.bind(this)(e,t,i)}joinRealtime(e){return Be.bind(this)(e)}getProfile(e){return it.bind(this)(e)}getFile(e,t){return Ie.bind(this)(e,t)}secureRequest(e,t){return sn.bind(this)(e,t)}getFormResponse(){return Pt.bind(this)()}getRecords(e,t){return Ut.bind(this)(e,t)}getTables(e,t){return Ot.bind(this)(e,t)}getIndexes(e,t){return Ft.bind(this)(e,t)}getTags(e,t){return Mt.bind(this)(e,t)}deleteRecords(e,t){return $t.bind(this)(e,t)}resendSignupConfirmation(){return at.bind(this)()}recoverAccount(e=false){return ct.bind(this)(e)}getUsers(e,t){return bt.bind(this)(e,t)}disableAccount(){return ut.bind(this)()}lastVerifiedEmail(e){return yt.bind(this)(e)}unsubscribeNewsletter(e){return pn.bind(this)(e)}subscribeNotification(e,t){return Pn.bind(this)({endpoint:e,keys:t})}unsubscribeNotification(e,t){return Sn.bind(this)({endpoint:e,keys:t})}vapidPublicKey(){return kn.bind(this)()}pushNotification(e,t){return xn.bind(this)(e,t)}getNewsletters(e,t){return mn.bind(this)(e,t)}getNewsletterSubscription(e,t){return fn.bind(this)(e,t)}requestUsernameChange(e){return wt.bind(this)(e)}grantPrivateRecordAccess(e){return qt.bind(this)(e)}removePrivateRecordAccess(e){return jt.bind(this)(e)}listPrivateRecordAccess(e){return Bt.bind(this)(e)}requestPrivateRecordAccessKey(e){return Kt.bind(this)(e)}deleteFiles(e){return vt.bind(this)(e)}uploadFiles(e,t){return we.bind(this)(e,t)}mock(e,t){return on.bind(this)(e,t)}login(e){return Ne.bind(this)(e)}logout(e){return ce.bind(this)(e)}signup(e,t){return lt.bind(this)(e,t)}resetPassword(e){return dt.bind(this)(e)}verifyEmail(e){return ht.bind(this)(e)}verifyPhoneNumber(e){return ft.bind(this)(e)}forgotPassword(e){return pt.bind(this)(e)}changePassword(e){return mt.bind(this)(e)}updateProfile(e){return _t.bind(this)(e)}postRecord(e,t,i){return Lt.bind(this)(e,t,i)}getSubscriptions(e,t){return cn.bind(this)(e,t)}subscribe(e){return ln.bind(this)(e)}unsubscribe(e){return un.bind(this)(e)}blockSubscriber(e){return dn.bind(this)(e)}unblockSubscriber(e){return gn.bind(this)(e)}subscribeNewsletter(e){return hn.bind(this)(e)}bulkPostRecords(e){return Ct.bind(this)(e)}};w([E()],b.prototype,"getFeed"),w([E()],b.prototype,"closeRTC"),w([E()],b.prototype,"connectRTC"),w([E()],b.prototype,"spellcast"),w([E()],b.prototype,"getspell"),w([E()],b.prototype,"dopamine"),w([E()],b.prototype,"getUniqueId"),w([E()],b.prototype,"resendInvitation"),w([E()],b.prototype,"cancelInvitation"),w([E()],b.prototype,"getInvitations"),w([E()],b.prototype,"openIdLogin"),w([E()],b.prototype,"loginWithToken"),w([E()],b.prototype,"clientSecretRequest"),w([E()],b.prototype,"consumeTicket"),w([E()],b.prototype,"getConsumedTickets"),w([E()],b.prototype,"getTickets"),w([E()],b.prototype,"getRealtimeUsers"),w([E()],b.prototype,"sendInquiry"),w([E()],b.prototype,"blockAccount"),w([E()],b.prototype,"unblockAccount"),w([E()],b.prototype,"deleteAccount"),w([E()],b.prototype,"inviteUser"),w([E()],b.prototype,"createAccount"),w([E()],b.prototype,"grantAccess"),w([E()],b.prototype,"getRealtimeGroups"),w([E()],b.prototype,"postRealtime"),w([E()],b.prototype,"joinRealtime"),w([E()],b.prototype,"getProfile"),w([E()],b.prototype,"getFile"),w([E()],b.prototype,"secureRequest"),w([E()],b.prototype,"getFormResponse"),w([E()],b.prototype,"getRecords"),w([E()],b.prototype,"getTables"),w([E()],b.prototype,"getIndexes"),w([E()],b.prototype,"getTags"),w([E()],b.prototype,"deleteRecords"),w([E()],b.prototype,"resendSignupConfirmation"),w([E()],b.prototype,"recoverAccount"),w([E()],b.prototype,"getUsers"),w([E()],b.prototype,"disableAccount"),w([E()],b.prototype,"lastVerifiedEmail"),w([E()],b.prototype,"unsubscribeNewsletter"),w([E()],b.prototype,"subscribeNotification"),w([E()],b.prototype,"unsubscribeNotification"),w([E()],b.prototype,"vapidPublicKey"),w([E()],b.prototype,"pushNotification"),w([E()],b.prototype,"getNewsletters"),w([E()],b.prototype,"getNewsletterSubscription"),w([E()],b.prototype,"requestUsernameChange"),w([E()],b.prototype,"grantPrivateRecordAccess"),w([E()],b.prototype,"removePrivateRecordAccess"),w([E()],b.prototype,"listPrivateRecordAccess"),w([E()],b.prototype,"requestPrivateRecordAccessKey"),w([E()],b.prototype,"deleteFiles"),w([E()],b.prototype,"uploadFiles"),w([E()],b.prototype,"mock"),w([E({preventMultipleCalls:true})],b.prototype,"login"),w([E()],b.prototype,"logout"),w([E({preventMultipleCalls:true})],b.prototype,"signup"),w([E({preventMultipleCalls:true})],b.prototype,"resetPassword"),w([E({preventMultipleCalls:true})],b.prototype,"verifyEmail"),w([E({preventMultipleCalls:true})],b.prototype,"verifyPhoneNumber"),w([E({preventMultipleCalls:true})],b.prototype,"forgotPassword"),w([E({preventMultipleCalls:true})],b.prototype,"changePassword"),w([E({preventMultipleCalls:true})],b.prototype,"updateProfile"),w([E()],b.prototype,"postRecord"),w([E()],b.prototype,"getSubscriptions"),w([E()],b.prototype,"subscribe"),w([E()],b.prototype,"unsubscribe"),w([E()],b.prototype,"blockSubscriber"),w([E()],b.prototype,"unblockSubscriber"),w([E()],b.prototype,"subscribeNewsletter");var Ur={};
233
233
  exports.Skapi=b;exports.SkapiError=a;exports.Types=Ur;//# sourceMappingURL=skapi.cjs.map
234
234
  //# sourceMappingURL=skapi.cjs.map