@neuctra/authix 1.2.22 → 1.2.23
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.
|
@@ -2249,12 +2249,23 @@ class li {
|
|
|
2249
2249
|
const n = this.appId;
|
|
2250
2250
|
if (!n)
|
|
2251
2251
|
throw new Error("getAppUsersData: 'appId' is required");
|
|
2252
|
-
const {
|
|
2253
|
-
|
|
2252
|
+
const {
|
|
2253
|
+
category: s,
|
|
2254
|
+
limit: i = 20,
|
|
2255
|
+
cursor: o
|
|
2256
|
+
} = e;
|
|
2257
|
+
let a = `/app/${encodeURIComponent(n)}/users-data`;
|
|
2258
|
+
s && (a += `/${encodeURIComponent(s)}`);
|
|
2254
2259
|
const c = new URLSearchParams();
|
|
2255
|
-
|
|
2260
|
+
c.append("limit", String(i)), o && c.append("cursor", o);
|
|
2256
2261
|
const d = c.toString();
|
|
2257
|
-
return d && (a += `?${d}`), await this.request(
|
|
2262
|
+
return d && (a += `?${d}`), await this.request(
|
|
2263
|
+
"GET",
|
|
2264
|
+
a,
|
|
2265
|
+
void 0,
|
|
2266
|
+
{},
|
|
2267
|
+
!1
|
|
2268
|
+
);
|
|
2258
2269
|
}
|
|
2259
2270
|
/**
|
|
2260
2271
|
* 👥 Get all app users (Paginated + Load More + Filters)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const s=new this(e);return n.forEach(i=>s.set(i)),s}static accessor(e){const s=(this[Pt]=this[Pt]={accessors:{}}).accessors,i=this.prototype;function o(a){const d=Te(a);s[d]||(on(i,a),s[d]=!0)}return f.isArray(e)?e.forEach(o):o(e),this}};re.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),f.reduceDescriptors(re.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(s){this[n]=s}}}),f.freezeMethods(re);function Ge(t,e){const n=this||Ce,s=e||n,i=re.from(s.headers);let o=s.data;return f.forEach(t,function(d){o=d.call(n,o,i.normalize(),e?e.status:void 0)}),i.normalize(),o}function It(t){return!!(t&&t.__CANCEL__)}function we(t,e,n){U.call(this,t??"canceled",U.ERR_CANCELED,e,n),this.name="CanceledError"}f.inherits(we,U,{__CANCEL__:!0});function Rt(t,e,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?t(n):e(new U("Request failed with status code "+n.status,[U.ERR_BAD_REQUEST,U.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function an(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function ln(t,e){t=t||10;const n=new Array(t),s=new Array(t);let i=0,o=0,a;return e=e!==void 0?e:1e3,function(c){const x=Date.now(),p=s[o];a||(a=x),n[i]=c,s[i]=x;let y=o,k=0;for(;y!==i;)k+=n[y++],y=y%t;if(i=(i+1)%t,i===o&&(o=(o+1)%t),x-a<e)return;const C=p&&x-p;return C?Math.round(k*1e3/C):void 0}}function dn(t,e){let n=0,s=1e3/e,i,o;const a=(x,p=Date.now())=>{n=p,i=null,o&&(clearTimeout(o),o=null),t(...x)};return[(...x)=>{const p=Date.now(),y=p-n;y>=s?a(x,p):(i=x,o||(o=setTimeout(()=>{o=null,a(i)},s-y)))},()=>i&&a(i)]}const Ne=(t,e,n=3)=>{let s=0;const i=ln(50,250);return dn(o=>{const a=o.loaded,d=o.lengthComputable?o.total:void 0,c=a-s,x=i(c),p=a<=d;s=a;const y={loaded:a,total:d,progress:d?a/d:void 0,bytes:c,rate:x||void 0,estimated:x&&d&&p?(d-a)/x:void 0,event:o,lengthComputable:d!=null,[e?"download":"upload"]:!0};t(y)},n)},Ot=(t,e)=>{const n=t!=null;return[s=>e[0]({lengthComputable:n,total:t,loaded:s}),e[1]]},At=t=>(...e)=>f.asap(()=>t(...e)),cn=Z.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,Z.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(Z.origin),Z.navigator&&/(msie|trident)/i.test(Z.navigator.userAgent)):()=>!0,un=Z.hasStandardBrowserEnv?{write(t,e,n,s,i,o){const a=[t+"="+encodeURIComponent(e)];f.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),f.isString(s)&&a.push("path="+s),f.isString(i)&&a.push("domain="+i),o===!0&&a.push("secure"),document.cookie=a.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function pn(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function fn(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function _t(t,e,n){let s=!pn(e);return t&&(s||n==!1)?fn(t,e):e}const zt=t=>t instanceof re?{...t}:t;function xe(t,e){e=e||{};const n={};function s(x,p,y,k){return f.isPlainObject(x)&&f.isPlainObject(p)?f.merge.call({caseless:k},x,p):f.isPlainObject(p)?f.merge({},p):f.isArray(p)?p.slice():p}function i(x,p,y,k){if(f.isUndefined(p)){if(!f.isUndefined(x))return s(void 0,x,y,k)}else return s(x,p,y,k)}function o(x,p){if(!f.isUndefined(p))return s(void 0,p)}function a(x,p){if(f.isUndefined(p)){if(!f.isUndefined(x))return s(void 0,x)}else return s(void 0,p)}function d(x,p,y){if(y in e)return s(x,p);if(y in t)return s(void 0,x)}const c={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:d,headers:(x,p,y)=>i(zt(x),zt(p),y,!0)};return f.forEach(Object.keys({...t,...e}),function(p){const y=c[p]||i,k=y(t[p],e[p],p);f.isUndefined(k)&&y!==d||(n[p]=k)}),n}const $t=t=>{const e=xe({},t);let{data:n,withXSRFToken:s,xsrfHeaderName:i,xsrfCookieName:o,headers:a,auth:d}=e;if(e.headers=a=re.from(a),e.url=Et(_t(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),d&&a.set("Authorization","Basic "+btoa((d.username||"")+":"+(d.password?unescape(encodeURIComponent(d.password)):""))),f.isFormData(n)){if(Z.hasStandardBrowserEnv||Z.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(f.isFunction(n.getHeaders)){const c=n.getHeaders(),x=["content-type","content-length"];Object.entries(c).forEach(([p,y])=>{x.includes(p.toLowerCase())&&a.set(p,y)})}}if(Z.hasStandardBrowserEnv&&(s&&f.isFunction(s)&&(s=s(e)),s||s!==!1&&cn(e.url))){const c=i&&o&&un.read(o);c&&a.set(i,c)}return e},xn=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(n,s){const i=$t(t);let o=i.data;const a=re.from(i.headers).normalize();let{responseType:d,onUploadProgress:c,onDownloadProgress:x}=i,p,y,k,C,u;function w(){C&&C(),u&&u(),i.cancelToken&&i.cancelToken.unsubscribe(p),i.signal&&i.signal.removeEventListener("abort",p)}let h=new XMLHttpRequest;h.open(i.method.toUpperCase(),i.url,!0),h.timeout=i.timeout;function R(){if(!h)return;const g=re.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),D={data:!d||d==="text"||d==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:g,config:t,request:h};Rt(function(j){n(j),w()},function(j){s(j),w()},D),h=null}"onloadend"in h?h.onloadend=R:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(R)},h.onabort=function(){h&&(s(new U("Request aborted",U.ECONNABORTED,t,h)),h=null)},h.onerror=function(z){const D=z&&z.message?z.message:"Network Error",b=new U(D,U.ERR_NETWORK,t,h);b.event=z||null,s(b),h=null},h.ontimeout=function(){let z=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const D=i.transitional||Ct;i.timeoutErrorMessage&&(z=i.timeoutErrorMessage),s(new U(z,D.clarifyTimeoutError?U.ETIMEDOUT:U.ECONNABORTED,t,h)),h=null},o===void 0&&a.setContentType(null),"setRequestHeader"in h&&f.forEach(a.toJSON(),function(z,D){h.setRequestHeader(D,z)}),f.isUndefined(i.withCredentials)||(h.withCredentials=!!i.withCredentials),d&&d!=="json"&&(h.responseType=i.responseType),x&&([k,u]=Ne(x,!0),h.addEventListener("progress",k)),c&&h.upload&&([y,C]=Ne(c),h.upload.addEventListener("progress",y),h.upload.addEventListener("loadend",C)),(i.cancelToken||i.signal)&&(p=g=>{h&&(s(!g||g.type?new we(null,t,h):g),h.abort(),h=null)},i.cancelToken&&i.cancelToken.subscribe(p),i.signal&&(i.signal.aborted?p():i.signal.addEventListener("abort",p)));const T=an(i.url);if(T&&Z.protocols.indexOf(T)===-1){s(new U("Unsupported protocol "+T+":",U.ERR_BAD_REQUEST,t));return}h.send(o||null)})},hn=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let s=new AbortController,i;const o=function(x){if(!i){i=!0,d();const p=x instanceof Error?x:this.reason;s.abort(p instanceof U?p:new we(p instanceof Error?p.message:p))}};let a=e&&setTimeout(()=>{a=null,o(new U(`timeout ${e} of ms exceeded`,U.ETIMEDOUT))},e);const d=()=>{t&&(a&&clearTimeout(a),a=null,t.forEach(x=>{x.unsubscribe?x.unsubscribe(o):x.removeEventListener("abort",o)}),t=null)};t.forEach(x=>x.addEventListener("abort",o));const{signal:c}=s;return c.unsubscribe=()=>f.asap(d),c}},mn=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let s=0,i;for(;s<n;)i=s+e,yield t.slice(s,i),s=i},gn=async function*(t,e){for await(const n of yn(t))yield*mn(n,e)},yn=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:s}=await e.read();if(n)break;yield s}}finally{await e.cancel()}},Ut=(t,e,n,s)=>{const i=gn(t,e);let o=0,a,d=c=>{a||(a=!0,s&&s(c))};return new ReadableStream({async pull(c){try{const{done:x,value:p}=await i.next();if(x){d(),c.close();return}let y=p.byteLength;if(n){let k=o+=y;n(k)}c.enqueue(new Uint8Array(p))}catch(x){throw d(x),x}},cancel(c){return d(c),i.return()}},{highWaterMark:2})},Nt=64*1024,{isFunction:De}=f,bn=(({Request:t,Response:e})=>({Request:t,Response:e}))(f.global),{ReadableStream:Dt,TextEncoder:Lt}=f.global,Ft=(t,...e)=>{try{return!!t(...e)}catch{return!1}},wn=t=>{t=f.merge.call({skipUndefined:!0},bn,t);const{fetch:e,Request:n,Response:s}=t,i=e?De(e):typeof fetch=="function",o=De(n),a=De(s);if(!i)return!1;const d=i&&De(Dt),c=i&&(typeof Lt=="function"?(u=>w=>u.encode(w))(new Lt):async u=>new Uint8Array(await new n(u).arrayBuffer())),x=o&&d&&Ft(()=>{let u=!1;const w=new n(Z.origin,{body:new Dt,method:"POST",get duplex(){return u=!0,"half"}}).headers.has("Content-Type");return u&&!w}),p=a&&d&&Ft(()=>f.isReadableStream(new s("").body)),y={stream:p&&(u=>u.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(u=>{!y[u]&&(y[u]=(w,h)=>{let R=w&&w[u];if(R)return R.call(w);throw new U(`Response type '${u}' is not supported`,U.ERR_NOT_SUPPORT,h)})});const k=async u=>{if(u==null)return 0;if(f.isBlob(u))return u.size;if(f.isSpecCompliantForm(u))return(await new n(Z.origin,{method:"POST",body:u}).arrayBuffer()).byteLength;if(f.isArrayBufferView(u)||f.isArrayBuffer(u))return u.byteLength;if(f.isURLSearchParams(u)&&(u=u+""),f.isString(u))return(await c(u)).byteLength},C=async(u,w)=>{const h=f.toFiniteNumber(u.getContentLength());return h??k(w)};return async u=>{let{url:w,method:h,data:R,signal:T,cancelToken:g,timeout:z,onDownloadProgress:D,onUploadProgress:b,responseType:j,headers:q,withCredentials:O="same-origin",fetchOptions:X}=$t(u),W=e||fetch;j=j?(j+"").toLowerCase():"text";let I=hn([T,g&&g.toAbortSignal()],z),G=null;const P=I&&I.unsubscribe&&(()=>{I.unsubscribe()});let A;try{if(b&&x&&h!=="get"&&h!=="head"&&(A=await C(q,R))!==0){let l=new n(w,{method:"POST",body:R,duplex:"half"}),m;if(f.isFormData(R)&&(m=l.headers.get("content-type"))&&q.setContentType(m),l.body){const[E,N]=Ot(A,Ne(At(b)));R=Ut(l.body,Nt,E,N)}}f.isString(O)||(O=O?"include":"omit");const M=o&&"credentials"in n.prototype,J={...X,signal:I,method:h.toUpperCase(),headers:q.normalize().toJSON(),body:R,duplex:"half",credentials:M?O:void 0};G=o&&new n(w,J);let H=await(o?W(G,X):W(w,J));const L=p&&(j==="stream"||j==="response");if(p&&(D||L&&P)){const l={};["status","statusText","headers"].forEach(ne=>{l[ne]=H[ne]});const m=f.toFiniteNumber(H.headers.get("content-length")),[E,N]=D&&Ot(m,Ne(At(D),!0))||[];H=new s(Ut(H.body,Nt,E,()=>{N&&N(),P&&P()}),l)}j=j||"text";let K=await y[f.findKey(y,j)||"text"](H,u);return!L&&P&&P(),await new Promise((l,m)=>{Rt(l,m,{data:K,headers:re.from(H.headers),status:H.status,statusText:H.statusText,config:u,request:G})})}catch(M){throw P&&P(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new U("Network Error",U.ERR_NETWORK,u,G),{cause:M.cause||M}):U.from(M,M&&M.code,u,G)}}},Sn=new Map,qt=t=>{let e=t?t.env:{};const{fetch:n,Request:s,Response:i}=e,o=[s,i,n];let a=o.length,d=a,c,x,p=Sn;for(;d--;)c=o[d],x=p.get(c),x===void 0&&p.set(c,x=d?new Map:wn(e)),p=x;return x};qt();const Xe={http:Mr,xhr:xn,fetch:{get:qt}};f.forEach(Xe,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Mt=t=>`- ${t}`,jn=t=>f.isFunction(t)||t===null||t===!1,Wt={getAdapter:(t,e)=>{t=f.isArray(t)?t:[t];const{length:n}=t;let s,i;const o={};for(let a=0;a<n;a++){s=t[a];let d;if(i=s,!jn(s)&&(i=Xe[(d=String(s)).toLowerCase()],i===void 0))throw new U(`Unknown adapter '${d}'`);if(i&&(f.isFunction(i)||(i=i.get(e))))break;o[d||"#"+a]=i}if(!i){const a=Object.entries(o).map(([c,x])=>`adapter ${c} `+(x===!1?"is not supported by the environment":"is not available in the build"));let d=n?a.length>1?`since :
|
|
4
4
|
`+a.map(Mt).join(`
|
|
5
5
|
`):" "+Mt(a[0]):"as no adapter specified";throw new U("There is no suitable adapter to dispatch the request "+d,"ERR_NOT_SUPPORT")}return i},adapters:Xe};function Ze(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new we(null,t)}function Bt(t){return Ze(t),t.headers=re.from(t.headers),t.data=Ge.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Wt.getAdapter(t.adapter||Ce.adapter,t)(t).then(function(s){return Ze(t),s.data=Ge.call(t,t.transformResponse,s),s.headers=re.from(s.headers),s},function(s){return It(s)||(Ze(t),s&&s.response&&(s.response.data=Ge.call(t,t.transformResponse,s.response),s.response.headers=re.from(s.response.headers))),Promise.reject(s)})}const Ht="1.12.2",Le={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Le[t]=function(s){return typeof s===t||"a"+(e<1?"n ":" ")+t}});const Vt={};Le.transitional=function(e,n,s){function i(o,a){return"[Axios v"+Ht+"] Transitional option '"+o+"'"+a+(s?". "+s:"")}return(o,a,d)=>{if(e===!1)throw new U(i(a," has been removed"+(n?" in "+n:"")),U.ERR_DEPRECATED);return n&&!Vt[a]&&(Vt[a]=!0,console.warn(i(a," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(o,a,d):!0}},Le.spelling=function(e){return(n,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function vn(t,e,n){if(typeof t!="object")throw new U("options must be an object",U.ERR_BAD_OPTION_VALUE);const s=Object.keys(t);let i=s.length;for(;i-- >0;){const o=s[i],a=e[o];if(a){const d=t[o],c=d===void 0||a(d,o,t);if(c!==!0)throw new U("option "+o+" must be "+c,U.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new U("Unknown option "+o,U.ERR_BAD_OPTION)}}const Fe={assertOptions:vn,validators:Le},ae=Fe.validators;let he=class{constructor(e){this.defaults=e||{},this.interceptors={request:new kt,response:new kt}}async request(e,n){try{return await this._request(e,n)}catch(s){if(s instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const o=i.stack?i.stack.replace(/^.+\n/,""):"";try{s.stack?o&&!String(s.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(s.stack+=`
|
|
6
|
-
`+o):s.stack=o}catch{}}throw s}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=xe(this.defaults,n);const{transitional:s,paramsSerializer:i,headers:o}=n;s!==void 0&&Fe.assertOptions(s,{silentJSONParsing:ae.transitional(ae.boolean),forcedJSONParsing:ae.transitional(ae.boolean),clarifyTimeoutError:ae.transitional(ae.boolean)},!1),i!=null&&(f.isFunction(i)?n.paramsSerializer={serialize:i}:Fe.assertOptions(i,{encode:ae.function,serialize:ae.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Fe.assertOptions(n,{baseUrl:ae.spelling("baseURL"),withXsrfToken:ae.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let a=o&&f.merge(o.common,o[n.method]);o&&f.forEach(["delete","get","head","post","put","patch","common"],u=>{delete o[u]}),n.headers=re.concat(a,o);const d=[];let c=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(c=c&&w.synchronous,d.unshift(w.fulfilled,w.rejected))});const x=[];this.interceptors.response.forEach(function(w){x.push(w.fulfilled,w.rejected)});let p,y=0,k;if(!c){const u=[Bt.bind(this),void 0];for(u.unshift(...d),u.push(...x),k=u.length,p=Promise.resolve(n);y<k;)p=p.then(u[y++],u[y++]);return p}k=d.length;let C=n;for(;y<k;){const u=d[y++],w=d[y++];try{C=u(C)}catch(h){w.call(this,h);break}}try{p=Bt.call(this,C)}catch(u){return Promise.reject(u)}for(y=0,k=x.length;y<k;)p=p.then(x[y++],x[y++]);return p}getUri(e){e=xe(this.defaults,e);const n=_t(e.baseURL,e.url,e.allowAbsoluteUrls);return Et(n,e.params,e.paramsSerializer)}};f.forEach(["delete","get","head","options"],function(e){he.prototype[e]=function(n,s){return this.request(xe(s||{},{method:e,url:n,data:(s||{}).data}))}}),f.forEach(["post","put","patch"],function(e){function n(s){return function(o,a,d){return this.request(xe(d||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:o,data:a}))}}he.prototype[e]=n(),he.prototype[e+"Form"]=n(!0)});let En=class nr{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const s=this;this.promise.then(i=>{if(!s._listeners)return;let o=s._listeners.length;for(;o-- >0;)s._listeners[o](i);s._listeners=null}),this.promise.then=i=>{let o;const a=new Promise(d=>{s.subscribe(d),o=d}).then(i);return a.cancel=function(){s.unsubscribe(o)},a},e(function(o,a,d){s.reason||(s.reason=new we(o,a,d),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=s=>{e.abort(s)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new nr(function(i){e=i}),cancel:e}}};function kn(t){return function(n){return t.apply(null,n)}}function Cn(t){return f.isObject(t)&&t.isAxiosError===!0}const Qe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Qe).forEach(([t,e])=>{Qe[e]=t});function Yt(t){const e=new he(t),n=dt(he.prototype.request,e);return f.extend(n,he.prototype,e,{allOwnKeys:!0}),f.extend(n,e,null,{allOwnKeys:!0}),n.create=function(i){return Yt(xe(t,i))},n}const Y=Yt(Ce);Y.Axios=he,Y.CanceledError=we,Y.CancelToken=En,Y.isCancel=It,Y.VERSION=Ht,Y.toFormData=$e,Y.AxiosError=U,Y.Cancel=Y.CanceledError,Y.all=function(e){return Promise.all(e)},Y.spread=kn,Y.isAxiosError=Cn,Y.mergeConfig=xe,Y.AxiosHeaders=re,Y.formToJSON=t=>Tt(f.isHTMLForm(t)?new FormData(t):t),Y.getAdapter=Wt.getAdapter,Y.HttpStatusCode=Qe,Y.default=Y;const{Axios:xs,AxiosError:hs,CanceledError:ms,isCancel:gs,CancelToken:ys,VERSION:bs,all:ws,Cancel:Ss,isAxiosError:js,spread:vs,toFormData:Es,AxiosHeaders:ks,HttpStatusCode:Cs,formToJSON:Ts,getAdapter:Ps,mergeConfig:Is}=Y;class Tn{baseUrl;apiKey;appId;client;constructor(e){if(!e||!e.baseUrl)throw new Error("NeuctraAuthixClient: 'baseUrl' is required in config");this.baseUrl=e.baseUrl.replace(/\/$/,""),this.apiKey=e.apiKey||null,this.appId=e.appId||null,this.client=Y.create({baseURL:this.baseUrl,headers:{"Content-Type":"application/json",...this.apiKey?{"x-api-key":this.apiKey}:{}},timeout:3e4,withCredentials:!0})}async request(e,n,s,i={},o=!1){try{const a={...this.appId?{appId:this.appId}:{},...s||{}};return(await this.client.request({url:n,method:e,data:a,headers:i,withCredentials:o})).data}catch(a){throw Y.isAxiosError(a)?{message:a.response?.data?.message||a.message||"Request failed",status:a.response?.status??0}:{message:a.message||"Unexpected error occurred"}}}async signupUser(e){const{name:n,email:s,password:i}=e;if(!n||!s||!i)throw new Error("signup: 'name', 'email', and 'password' are required");return await this.request("POST","/users/signup",e,{},!0)}async loginUser(e){const{email:n,password:s}=e;if(!n||!s)throw new Error("login: 'email' and 'password' are required");try{return await this.request("POST","/users/login",{email:n,password:s},{},!0)}catch(i){throw new Error(i.message||"Login failed due to an unknown error")}}async logoutUser(){try{return(await this.request("POST","/users/logout",{},{},!0))?.success?(typeof window<"u"&&(document.cookie="a_s_b=; path=/; Max-Age=0; SameSite=Lax",window.location.protocol==="https:"&&(document.cookie="a_s_b=; path=/; Max-Age=0; SameSite=Lax; Secure"),window.location.reload()),{success:!0}):{success:!1}}catch(e){throw new Error(e?.message||"Logout failed due to an unknown error")}}async changePassword(e){const{userId:n,currentPassword:s,newPassword:i}=e;if(!n)throw new Error("changePassword: 'userId' is required");if(!s||!i)throw new Error("changePassword: both 'currentPassword' and 'newPassword' are required");return await this.request("PUT",`/users/change-password/${n}`,{currentPassword:s,newPassword:i},{},!0)}async requestEmailVerificationOTP(e){const{userId:n,email:s}=e;if(!n)throw{message:"requestEmailVerificationOTP: 'userId' is required",status:400};if(!s)throw{message:"requestEmailVerificationOTP: 'email' is required",status:400};try{return await this.request("POST",`/users/send-verify-otp/${encodeURIComponent(n)}`,{email:s},{},!0)}catch(i){throw console.error("requestEmailVerificationOTP Error:",i),{message:i?.message||"Failed to send verification OTP",status:i?.status||500}}}async verifyEmail(e){const{email:n,otp:s}=e;if(!n)throw new Error("verifyEmail: 'email' is required");if(!s)throw new Error("verifyEmail: 'otp' is required");try{return await this.request("POST","/users/verify-email",{email:n,otp:s},{},!0)}catch(i){throw{message:i.message||"Failed to verify email",status:i.status||500}}}async checkUserSession(){if(typeof window>"u")return{authenticated:!1};try{return await this.request("GET","/users/session",void 0,{},!0)}catch{return{authenticated:!1}}}async getUser(e){const n=this.appId;if(!n)throw new Error("getUser: 'appId' is required in SDK config");if(!e?.id&&!e?.username)throw new Error("getUser: either 'id' or 'username' is required");const s=new URLSearchParams;return e.id&&s.append("id",e.id),e.username&&s.append("username",e.username),await this.request("GET",`/users/${encodeURIComponent(n)}/user?${s.toString()}`,void 0,{},!0)}async updateUser(e){const{userId:n}=e;if(!n)throw new Error("updateUser: 'userId' is required");return await this.request("PUT",`/users/update/${n}`,{...e},{},!0)}async deleteUser(e){const{userId:n}=e;if(!n)throw new Error("deleteUser: 'userId' is required");return await this.request("DELETE",`/users/delete/${n}`,{},{},!0)}async getUserProfile(e){const{userId:n}=e;if(!n)throw new Error("getProfile: 'userId' and 'appId' are required");try{return await this.request("POST","/users/profile",{userId:n},{},!0)}catch(s){throw{message:s.message||"Failed to fetch profile",status:s.status||500}}}async requestResetUserPasswordOTP(e){const{email:n}=e;if(!n)throw new Error("forgotPassword: 'email' is required");return await this.request("POST","/users/forgot-password",{email:n})}async resetUserPassword(e){const{email:n,otp:s,newPassword:i}=e;if(!n||!s||!i)throw new Error("resetPassword: 'email', 'otp' and 'newPassword' are required");return await this.request("POST","/users/reset-password",{email:n,otp:s,newPassword:i})}async checkIfUserExists(e){if(!e)throw new Error("checkUser: 'userId' is required");return await this.request("GET",`/users/check-user/${e}?appId=${this.appId}`)}async searchUserData(e){const{userId:n,...s}=e;if(!n)throw new Error("userId required");const i=new URLSearchParams(s).toString();return await this.request("GET",`/users/${n}/data/search?${i}`,void 0,{},!1)}async searchUserDataByKeys(e){const{userId:n,...s}=e;if(!n)throw new Error("searchUserDataByKeys: 'userId' is required");const i=new URLSearchParams(Object.entries(s).reduce((o,[a,d])=>(d!=null&&(o[a]=String(d)),o),{})).toString();return await this.request("GET",`/users/${n}/data/searchbyref?${i}`,void 0,{},!1)}async getUserData(e){const{userId:n,limit:s=20,cursor:i,type:o}=e;if(!n)throw new Error("getUserData: 'userId' is required");const a=`/users/${encodeURIComponent(n)}/data`,d=new URLSearchParams;d.append("limit",String(s)),i&&d.append("cursor",i),o&&d.append("type",o);const c=d.toString();return await this.request("GET",c?`${a}?${c}`:a,void 0,{},!1)}async getSingleUserData(e){const{userId:n,dataId:s}=e;if(!n||!s)throw new Error("getSingleUserData: 'userId' and 'dataId' are required");return await this.request("GET",`/users/${n}/data/${s}`,void 0,{},!1)}async addUserData(e){const{userId:n,dataCategory:s,data:i}=e;if(!n)throw new Error("addUserData: 'userId' is required");if(!s)throw new Error("addUserData: 'dataCategory' is required");if(!i)throw new Error("addUserData: 'data' is required");return await this.request("POST",`/users/${n}/data`,{dataCategory:s,...i},{},!1)}async updateUserData(e){const{userId:n,dataId:s,data:i}=e;if(!n||!s)throw new Error("updateUserData: 'userId' and 'dataId' are required");if(!i)throw new Error("updateUserData: 'data' is required");return await this.request("PUT",`/users/${n}/data/${s}`,i,{},!1)}async deleteUserData(e){const{userId:n,dataId:s}=e;if(!n||!s)throw new Error("deleteUserData: 'userId' and 'dataId' are required");return await this.request("DELETE",`/users/${n}/data/${s}`,void 0,{},!1)}async searchAllUsersDataFromApp(e){const{dataCategory:n}=e,s=this.appId;if(!s)throw new Error("searchAllUsersDataFromApp: 'appId' is required");if(!n)throw new Error("searchAllUsersDataFromApp: 'category' is required");return await this.request("GET",`/users/app/${encodeURIComponent(s)}/category/${encodeURIComponent(n)}`,void 0,{},!1)}async getAppData(e){const n=this.appId;if(!n)throw new Error("getAppData: 'appId' is required");const s=e?`/app/${encodeURIComponent(n)}/app-data/${encodeURIComponent(e)}`:`/app/${encodeURIComponent(n)}/app-data`;return await this.request("GET",s,void 0,{},!1)}async getAppUsersData(e={}){const n=this.appId;if(!n)throw new Error("getAppUsersData: 'appId' is required");const{category:s,limit:i=20,cursor:o}=e;let a=s?`/app/${encodeURIComponent(n)}/users-data/${encodeURIComponent(s)}`:`/app/${encodeURIComponent(n)}/users-data`;const d=new URLSearchParams;i&&d.append("limit",String(i)),o&&d.append("cursor",o);const c=d.toString();return c&&(a+=`?${c}`),await this.request("GET",a,void 0,{},!1)}async getAllAppUsers(e={}){const n=this.appId;if(!n)throw new Error("getAllAppUsers: 'appId' is required");const{limit:s=20,cursor:i,search:o,role:a,isActive:d,isVerified:c}=e,x=`/app/${encodeURIComponent(n)}/users`,p=new URLSearchParams;p.append("limit",String(s)),i&&p.append("cursor",i),o&&p.append("search",o),a&&p.append("role",a),typeof d=="boolean"&&p.append("isActive",String(d)),typeof c=="boolean"&&p.append("isVerified",String(c));const y=p.toString();return await this.request("GET",y?`${x}?${y}`:x,void 0,{},!1)}async getSingleAppData(e){const n=this.appId;if(!n)throw new Error("getSingleAppData: 'appId' is required");if(!e?.dataId)throw new Error("getSingleAppData: 'dataId' is required");return await this.request("GET",`/app/${encodeURIComponent(n)}/data/${encodeURIComponent(e.dataId)}`,void 0,{},!1)}async searchAppDataByKeys(e){const n=this.appId;if(!n)throw new Error("searchAppDataByKeys: 'appId' is required");if(!e||typeof e!="object")throw new Error("searchAppDataByKeys: params object is required");return await this.request("POST",`/app/${encodeURIComponent(n)}/data/searchByKeys`,e,{},!1)}async addAppData(e){const n=this.appId;if(!n)throw new Error("addAppData: 'appId' is required");const{dataCategory:s,data:i}=e;if(!s)throw new Error("addAppData: 'dataCategory' is required");if(!i||typeof i!="object")throw new Error("addAppData: 'data' is required");return await this.request("POST",`/app/${encodeURIComponent(n)}/data/${encodeURIComponent(s)}`,{item:i},{},!1)}async updateAppData(e){const n=this.appId;if(!n)throw new Error("updateAppData: 'appId' is required");if(!e?.dataId)throw new Error("updateAppData: 'dataId' is required");if(!e?.data||typeof e.data!="object")throw new Error("updateAppData: 'data' is required");return await this.request("PATCH",`/app/${encodeURIComponent(n)}/data/${encodeURIComponent(e.dataId)}`,e.data,{},!1)}async deleteAppData(e){const n=this.appId;if(!n)throw new Error("deleteAppData: 'appId' is required");if(!e?.dataId)throw new Error("deleteAppData: 'dataId' is required");return await this.request("DELETE",`/app/${encodeURIComponent(n)}/data/${encodeURIComponent(e.dataId)}`,void 0,{},!1)}}var qe={exports:{}},Pe={};/**
|
|
6
|
+
`+o):s.stack=o}catch{}}throw s}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=xe(this.defaults,n);const{transitional:s,paramsSerializer:i,headers:o}=n;s!==void 0&&Fe.assertOptions(s,{silentJSONParsing:ae.transitional(ae.boolean),forcedJSONParsing:ae.transitional(ae.boolean),clarifyTimeoutError:ae.transitional(ae.boolean)},!1),i!=null&&(f.isFunction(i)?n.paramsSerializer={serialize:i}:Fe.assertOptions(i,{encode:ae.function,serialize:ae.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Fe.assertOptions(n,{baseUrl:ae.spelling("baseURL"),withXsrfToken:ae.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let a=o&&f.merge(o.common,o[n.method]);o&&f.forEach(["delete","get","head","post","put","patch","common"],u=>{delete o[u]}),n.headers=re.concat(a,o);const d=[];let c=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(c=c&&w.synchronous,d.unshift(w.fulfilled,w.rejected))});const x=[];this.interceptors.response.forEach(function(w){x.push(w.fulfilled,w.rejected)});let p,y=0,k;if(!c){const u=[Bt.bind(this),void 0];for(u.unshift(...d),u.push(...x),k=u.length,p=Promise.resolve(n);y<k;)p=p.then(u[y++],u[y++]);return p}k=d.length;let C=n;for(;y<k;){const u=d[y++],w=d[y++];try{C=u(C)}catch(h){w.call(this,h);break}}try{p=Bt.call(this,C)}catch(u){return Promise.reject(u)}for(y=0,k=x.length;y<k;)p=p.then(x[y++],x[y++]);return p}getUri(e){e=xe(this.defaults,e);const n=_t(e.baseURL,e.url,e.allowAbsoluteUrls);return Et(n,e.params,e.paramsSerializer)}};f.forEach(["delete","get","head","options"],function(e){he.prototype[e]=function(n,s){return this.request(xe(s||{},{method:e,url:n,data:(s||{}).data}))}}),f.forEach(["post","put","patch"],function(e){function n(s){return function(o,a,d){return this.request(xe(d||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:o,data:a}))}}he.prototype[e]=n(),he.prototype[e+"Form"]=n(!0)});let En=class nr{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const s=this;this.promise.then(i=>{if(!s._listeners)return;let o=s._listeners.length;for(;o-- >0;)s._listeners[o](i);s._listeners=null}),this.promise.then=i=>{let o;const a=new Promise(d=>{s.subscribe(d),o=d}).then(i);return a.cancel=function(){s.unsubscribe(o)},a},e(function(o,a,d){s.reason||(s.reason=new we(o,a,d),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=s=>{e.abort(s)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new nr(function(i){e=i}),cancel:e}}};function kn(t){return function(n){return t.apply(null,n)}}function Cn(t){return f.isObject(t)&&t.isAxiosError===!0}const Qe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Qe).forEach(([t,e])=>{Qe[e]=t});function Yt(t){const e=new he(t),n=dt(he.prototype.request,e);return f.extend(n,he.prototype,e,{allOwnKeys:!0}),f.extend(n,e,null,{allOwnKeys:!0}),n.create=function(i){return Yt(xe(t,i))},n}const Y=Yt(Ce);Y.Axios=he,Y.CanceledError=we,Y.CancelToken=En,Y.isCancel=It,Y.VERSION=Ht,Y.toFormData=$e,Y.AxiosError=U,Y.Cancel=Y.CanceledError,Y.all=function(e){return Promise.all(e)},Y.spread=kn,Y.isAxiosError=Cn,Y.mergeConfig=xe,Y.AxiosHeaders=re,Y.formToJSON=t=>Tt(f.isHTMLForm(t)?new FormData(t):t),Y.getAdapter=Wt.getAdapter,Y.HttpStatusCode=Qe,Y.default=Y;const{Axios:xs,AxiosError:hs,CanceledError:ms,isCancel:gs,CancelToken:ys,VERSION:bs,all:ws,Cancel:Ss,isAxiosError:js,spread:vs,toFormData:Es,AxiosHeaders:ks,HttpStatusCode:Cs,formToJSON:Ts,getAdapter:Ps,mergeConfig:Is}=Y;class Tn{baseUrl;apiKey;appId;client;constructor(e){if(!e||!e.baseUrl)throw new Error("NeuctraAuthixClient: 'baseUrl' is required in config");this.baseUrl=e.baseUrl.replace(/\/$/,""),this.apiKey=e.apiKey||null,this.appId=e.appId||null,this.client=Y.create({baseURL:this.baseUrl,headers:{"Content-Type":"application/json",...this.apiKey?{"x-api-key":this.apiKey}:{}},timeout:3e4,withCredentials:!0})}async request(e,n,s,i={},o=!1){try{const a={...this.appId?{appId:this.appId}:{},...s||{}};return(await this.client.request({url:n,method:e,data:a,headers:i,withCredentials:o})).data}catch(a){throw Y.isAxiosError(a)?{message:a.response?.data?.message||a.message||"Request failed",status:a.response?.status??0}:{message:a.message||"Unexpected error occurred"}}}async signupUser(e){const{name:n,email:s,password:i}=e;if(!n||!s||!i)throw new Error("signup: 'name', 'email', and 'password' are required");return await this.request("POST","/users/signup",e,{},!0)}async loginUser(e){const{email:n,password:s}=e;if(!n||!s)throw new Error("login: 'email' and 'password' are required");try{return await this.request("POST","/users/login",{email:n,password:s},{},!0)}catch(i){throw new Error(i.message||"Login failed due to an unknown error")}}async logoutUser(){try{return(await this.request("POST","/users/logout",{},{},!0))?.success?(typeof window<"u"&&(document.cookie="a_s_b=; path=/; Max-Age=0; SameSite=Lax",window.location.protocol==="https:"&&(document.cookie="a_s_b=; path=/; Max-Age=0; SameSite=Lax; Secure"),window.location.reload()),{success:!0}):{success:!1}}catch(e){throw new Error(e?.message||"Logout failed due to an unknown error")}}async changePassword(e){const{userId:n,currentPassword:s,newPassword:i}=e;if(!n)throw new Error("changePassword: 'userId' is required");if(!s||!i)throw new Error("changePassword: both 'currentPassword' and 'newPassword' are required");return await this.request("PUT",`/users/change-password/${n}`,{currentPassword:s,newPassword:i},{},!0)}async requestEmailVerificationOTP(e){const{userId:n,email:s}=e;if(!n)throw{message:"requestEmailVerificationOTP: 'userId' is required",status:400};if(!s)throw{message:"requestEmailVerificationOTP: 'email' is required",status:400};try{return await this.request("POST",`/users/send-verify-otp/${encodeURIComponent(n)}`,{email:s},{},!0)}catch(i){throw console.error("requestEmailVerificationOTP Error:",i),{message:i?.message||"Failed to send verification OTP",status:i?.status||500}}}async verifyEmail(e){const{email:n,otp:s}=e;if(!n)throw new Error("verifyEmail: 'email' is required");if(!s)throw new Error("verifyEmail: 'otp' is required");try{return await this.request("POST","/users/verify-email",{email:n,otp:s},{},!0)}catch(i){throw{message:i.message||"Failed to verify email",status:i.status||500}}}async checkUserSession(){if(typeof window>"u")return{authenticated:!1};try{return await this.request("GET","/users/session",void 0,{},!0)}catch{return{authenticated:!1}}}async getUser(e){const n=this.appId;if(!n)throw new Error("getUser: 'appId' is required in SDK config");if(!e?.id&&!e?.username)throw new Error("getUser: either 'id' or 'username' is required");const s=new URLSearchParams;return e.id&&s.append("id",e.id),e.username&&s.append("username",e.username),await this.request("GET",`/users/${encodeURIComponent(n)}/user?${s.toString()}`,void 0,{},!0)}async updateUser(e){const{userId:n}=e;if(!n)throw new Error("updateUser: 'userId' is required");return await this.request("PUT",`/users/update/${n}`,{...e},{},!0)}async deleteUser(e){const{userId:n}=e;if(!n)throw new Error("deleteUser: 'userId' is required");return await this.request("DELETE",`/users/delete/${n}`,{},{},!0)}async getUserProfile(e){const{userId:n}=e;if(!n)throw new Error("getProfile: 'userId' and 'appId' are required");try{return await this.request("POST","/users/profile",{userId:n},{},!0)}catch(s){throw{message:s.message||"Failed to fetch profile",status:s.status||500}}}async requestResetUserPasswordOTP(e){const{email:n}=e;if(!n)throw new Error("forgotPassword: 'email' is required");return await this.request("POST","/users/forgot-password",{email:n})}async resetUserPassword(e){const{email:n,otp:s,newPassword:i}=e;if(!n||!s||!i)throw new Error("resetPassword: 'email', 'otp' and 'newPassword' are required");return await this.request("POST","/users/reset-password",{email:n,otp:s,newPassword:i})}async checkIfUserExists(e){if(!e)throw new Error("checkUser: 'userId' is required");return await this.request("GET",`/users/check-user/${e}?appId=${this.appId}`)}async searchUserData(e){const{userId:n,...s}=e;if(!n)throw new Error("userId required");const i=new URLSearchParams(s).toString();return await this.request("GET",`/users/${n}/data/search?${i}`,void 0,{},!1)}async searchUserDataByKeys(e){const{userId:n,...s}=e;if(!n)throw new Error("searchUserDataByKeys: 'userId' is required");const i=new URLSearchParams(Object.entries(s).reduce((o,[a,d])=>(d!=null&&(o[a]=String(d)),o),{})).toString();return await this.request("GET",`/users/${n}/data/searchbyref?${i}`,void 0,{},!1)}async getUserData(e){const{userId:n,limit:s=20,cursor:i,type:o}=e;if(!n)throw new Error("getUserData: 'userId' is required");const a=`/users/${encodeURIComponent(n)}/data`,d=new URLSearchParams;d.append("limit",String(s)),i&&d.append("cursor",i),o&&d.append("type",o);const c=d.toString();return await this.request("GET",c?`${a}?${c}`:a,void 0,{},!1)}async getSingleUserData(e){const{userId:n,dataId:s}=e;if(!n||!s)throw new Error("getSingleUserData: 'userId' and 'dataId' are required");return await this.request("GET",`/users/${n}/data/${s}`,void 0,{},!1)}async addUserData(e){const{userId:n,dataCategory:s,data:i}=e;if(!n)throw new Error("addUserData: 'userId' is required");if(!s)throw new Error("addUserData: 'dataCategory' is required");if(!i)throw new Error("addUserData: 'data' is required");return await this.request("POST",`/users/${n}/data`,{dataCategory:s,...i},{},!1)}async updateUserData(e){const{userId:n,dataId:s,data:i}=e;if(!n||!s)throw new Error("updateUserData: 'userId' and 'dataId' are required");if(!i)throw new Error("updateUserData: 'data' is required");return await this.request("PUT",`/users/${n}/data/${s}`,i,{},!1)}async deleteUserData(e){const{userId:n,dataId:s}=e;if(!n||!s)throw new Error("deleteUserData: 'userId' and 'dataId' are required");return await this.request("DELETE",`/users/${n}/data/${s}`,void 0,{},!1)}async searchAllUsersDataFromApp(e){const{dataCategory:n}=e,s=this.appId;if(!s)throw new Error("searchAllUsersDataFromApp: 'appId' is required");if(!n)throw new Error("searchAllUsersDataFromApp: 'category' is required");return await this.request("GET",`/users/app/${encodeURIComponent(s)}/category/${encodeURIComponent(n)}`,void 0,{},!1)}async getAppData(e){const n=this.appId;if(!n)throw new Error("getAppData: 'appId' is required");const s=e?`/app/${encodeURIComponent(n)}/app-data/${encodeURIComponent(e)}`:`/app/${encodeURIComponent(n)}/app-data`;return await this.request("GET",s,void 0,{},!1)}async getAppUsersData(e={}){const n=this.appId;if(!n)throw new Error("getAppUsersData: 'appId' is required");const{category:s,limit:i=20,cursor:o}=e;let a=`/app/${encodeURIComponent(n)}/users-data`;s&&(a+=`/${encodeURIComponent(s)}`);const d=new URLSearchParams;d.append("limit",String(i)),o&&d.append("cursor",o);const c=d.toString();return c&&(a+=`?${c}`),await this.request("GET",a,void 0,{},!1)}async getAllAppUsers(e={}){const n=this.appId;if(!n)throw new Error("getAllAppUsers: 'appId' is required");const{limit:s=20,cursor:i,search:o,role:a,isActive:d,isVerified:c}=e,x=`/app/${encodeURIComponent(n)}/users`,p=new URLSearchParams;p.append("limit",String(s)),i&&p.append("cursor",i),o&&p.append("search",o),a&&p.append("role",a),typeof d=="boolean"&&p.append("isActive",String(d)),typeof c=="boolean"&&p.append("isVerified",String(c));const y=p.toString();return await this.request("GET",y?`${x}?${y}`:x,void 0,{},!1)}async getSingleAppData(e){const n=this.appId;if(!n)throw new Error("getSingleAppData: 'appId' is required");if(!e?.dataId)throw new Error("getSingleAppData: 'dataId' is required");return await this.request("GET",`/app/${encodeURIComponent(n)}/data/${encodeURIComponent(e.dataId)}`,void 0,{},!1)}async searchAppDataByKeys(e){const n=this.appId;if(!n)throw new Error("searchAppDataByKeys: 'appId' is required");if(!e||typeof e!="object")throw new Error("searchAppDataByKeys: params object is required");return await this.request("POST",`/app/${encodeURIComponent(n)}/data/searchByKeys`,e,{},!1)}async addAppData(e){const n=this.appId;if(!n)throw new Error("addAppData: 'appId' is required");const{dataCategory:s,data:i}=e;if(!s)throw new Error("addAppData: 'dataCategory' is required");if(!i||typeof i!="object")throw new Error("addAppData: 'data' is required");return await this.request("POST",`/app/${encodeURIComponent(n)}/data/${encodeURIComponent(s)}`,{item:i},{},!1)}async updateAppData(e){const n=this.appId;if(!n)throw new Error("updateAppData: 'appId' is required");if(!e?.dataId)throw new Error("updateAppData: 'dataId' is required");if(!e?.data||typeof e.data!="object")throw new Error("updateAppData: 'data' is required");return await this.request("PATCH",`/app/${encodeURIComponent(n)}/data/${encodeURIComponent(e.dataId)}`,e.data,{},!1)}async deleteAppData(e){const n=this.appId;if(!n)throw new Error("deleteAppData: 'appId' is required");if(!e?.dataId)throw new Error("deleteAppData: 'dataId' is required");return await this.request("DELETE",`/app/${encodeURIComponent(n)}/data/${encodeURIComponent(e.dataId)}`,void 0,{},!1)}}var qe={exports:{}},Pe={};/**
|
|
7
7
|
* @license React
|
|
8
8
|
* react-jsx-runtime.production.js
|
|
9
9
|
*
|
package/dist/sdk/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EAEvB,uBAAuB,EACvB,oBAAoB,EAEpB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,+BAA+B,EAC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