@neuctra/authix 1.1.71 → 1.1.72
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.
|
@@ -1811,7 +1811,7 @@ class ui {
|
|
|
1811
1811
|
const { name: r, email: s, password: i } = e;
|
|
1812
1812
|
if (!r || !s || !i)
|
|
1813
1813
|
throw new Error("signup: 'name', 'email', and 'password' are required");
|
|
1814
|
-
return this.request("POST", "/users/signup", e);
|
|
1814
|
+
return this.request("POST", "/users/signup", e, {}, !0);
|
|
1815
1815
|
}
|
|
1816
1816
|
/**
|
|
1817
1817
|
* Login a user
|
|
@@ -1822,10 +1822,13 @@ class ui {
|
|
|
1822
1822
|
if (!r || !s)
|
|
1823
1823
|
throw new Error("login: 'email' and 'password' are required");
|
|
1824
1824
|
try {
|
|
1825
|
-
return
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1825
|
+
return this.request(
|
|
1826
|
+
"POST",
|
|
1827
|
+
"/users/login",
|
|
1828
|
+
{ email: r, password: s },
|
|
1829
|
+
{},
|
|
1830
|
+
!0
|
|
1831
|
+
);
|
|
1829
1832
|
} catch (i) {
|
|
1830
1833
|
throw new Error(i.message || "Login failed due to an unknown error");
|
|
1831
1834
|
}
|
|
@@ -1841,10 +1844,13 @@ class ui {
|
|
|
1841
1844
|
throw new Error(
|
|
1842
1845
|
"changePassword: both 'currentPassword' and 'newPassword' are required"
|
|
1843
1846
|
);
|
|
1844
|
-
return this.request(
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1847
|
+
return this.request(
|
|
1848
|
+
"PUT",
|
|
1849
|
+
`/users/change-password/${r}`,
|
|
1850
|
+
{ currentPassword: s, newPassword: i },
|
|
1851
|
+
{},
|
|
1852
|
+
!0
|
|
1853
|
+
);
|
|
1848
1854
|
}
|
|
1849
1855
|
/**
|
|
1850
1856
|
* Send email verification OTP for a user
|
|
@@ -1863,10 +1869,12 @@ class ui {
|
|
|
1863
1869
|
status: 400
|
|
1864
1870
|
};
|
|
1865
1871
|
try {
|
|
1866
|
-
return
|
|
1872
|
+
return this.request(
|
|
1867
1873
|
"POST",
|
|
1868
1874
|
`/users/send-verify-otp/${encodeURIComponent(r)}`,
|
|
1869
|
-
{ email: s }
|
|
1875
|
+
{ email: s },
|
|
1876
|
+
{},
|
|
1877
|
+
!0
|
|
1870
1878
|
);
|
|
1871
1879
|
} catch (i) {
|
|
1872
1880
|
throw console.error("requestEmailVerificationOTP Error:", i), {
|
|
@@ -1884,10 +1892,13 @@ class ui {
|
|
|
1884
1892
|
if (!r) throw new Error("verifyEmail: 'email' is required");
|
|
1885
1893
|
if (!s) throw new Error("verifyEmail: 'otp' is required");
|
|
1886
1894
|
try {
|
|
1887
|
-
return
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1895
|
+
return this.request(
|
|
1896
|
+
"POST",
|
|
1897
|
+
"/users/verify-email",
|
|
1898
|
+
{ email: r, otp: s },
|
|
1899
|
+
{},
|
|
1900
|
+
!0
|
|
1901
|
+
);
|
|
1891
1902
|
} catch (i) {
|
|
1892
1903
|
throw {
|
|
1893
1904
|
message: i.message || "Failed to verify email",
|
|
@@ -1903,7 +1914,13 @@ class ui {
|
|
|
1903
1914
|
if (typeof window > "u")
|
|
1904
1915
|
return { authenticated: !1 };
|
|
1905
1916
|
try {
|
|
1906
|
-
return
|
|
1917
|
+
return this.request(
|
|
1918
|
+
"GET",
|
|
1919
|
+
"/users/session",
|
|
1920
|
+
void 0,
|
|
1921
|
+
{},
|
|
1922
|
+
!0
|
|
1923
|
+
);
|
|
1907
1924
|
} catch {
|
|
1908
1925
|
return { authenticated: !1 };
|
|
1909
1926
|
}
|
|
@@ -1915,9 +1932,13 @@ class ui {
|
|
|
1915
1932
|
async updateUser(e) {
|
|
1916
1933
|
const { userId: r } = e;
|
|
1917
1934
|
if (!r) throw new Error("updateUser: 'userId' is required");
|
|
1918
|
-
return this.request(
|
|
1919
|
-
|
|
1920
|
-
|
|
1935
|
+
return this.request(
|
|
1936
|
+
"PUT",
|
|
1937
|
+
`/users/update/${r}`,
|
|
1938
|
+
{ ...e },
|
|
1939
|
+
{},
|
|
1940
|
+
!0
|
|
1941
|
+
);
|
|
1921
1942
|
}
|
|
1922
1943
|
/**
|
|
1923
1944
|
* Delete a user
|
|
@@ -1926,7 +1947,7 @@ class ui {
|
|
|
1926
1947
|
async deleteUser(e) {
|
|
1927
1948
|
const { userId: r } = e;
|
|
1928
1949
|
if (!r) throw new Error("deleteUser: 'userId' is required");
|
|
1929
|
-
return this.request("DELETE", `/users/delete/${r}`, {});
|
|
1950
|
+
return this.request("DELETE", `/users/delete/${r}`, {}, {}, !0);
|
|
1930
1951
|
}
|
|
1931
1952
|
/**
|
|
1932
1953
|
* Get the profile of a user for a specific app
|
|
@@ -1937,9 +1958,7 @@ class ui {
|
|
|
1937
1958
|
if (!r)
|
|
1938
1959
|
throw new Error("getProfile: 'userId' and 'appId' are required");
|
|
1939
1960
|
try {
|
|
1940
|
-
return
|
|
1941
|
-
userId: r
|
|
1942
|
-
});
|
|
1961
|
+
return this.request("POST", "/users/profile", { userId: r }, {}, !0);
|
|
1943
1962
|
} catch (s) {
|
|
1944
1963
|
throw {
|
|
1945
1964
|
message: s.message || "Failed to fetch profile",
|
|
@@ -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,...r){const s=new this(e);return r.forEach(i=>s.set(i)),s}static accessor(e){const s=(this[It]=this[It]={accessors:{}}).accessors,i=this.prototype;function a(o){const d=Ce(o);s[d]||(dn(i,o),s[d]=!0)}return f.isArray(e)?e.forEach(a):a(e),this}};ne.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),f.reduceDescriptors(ne.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(s){this[r]=s}}}),f.freezeMethods(ne);function Ze(t,e){const r=this||ke,s=e||r,i=ne.from(s.headers);let a=s.data;return f.forEach(t,function(d){a=d.call(r,a,i.normalize(),e?e.status:void 0)}),i.normalize(),a}function Ot(t){return!!(t&&t.__CANCEL__)}function be(t,e,r){U.call(this,t??"canceled",U.ERR_CANCELED,e,r),this.name="CanceledError"}f.inherits(be,U,{__CANCEL__:!0});function Rt(t,e,r){const s=r.config.validateStatus;!r.status||!s||s(r.status)?t(r):e(new U("Request failed with status code "+r.status,[U.ERR_BAD_REQUEST,U.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function cn(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function un(t,e){t=t||10;const r=new Array(t),s=new Array(t);let i=0,a=0,o;return e=e!==void 0?e:1e3,function(h){const p=Date.now(),c=s[a];o||(o=p),r[i]=h,s[i]=p;let m=a,I=0;for(;m!==i;)I+=r[m++],m=m%t;if(i=(i+1)%t,i===a&&(a=(a+1)%t),p-o<e)return;const R=c&&p-c;return R?Math.round(I*1e3/R):void 0}}function pn(t,e){let r=0,s=1e3/e,i,a;const o=(p,c=Date.now())=>{r=c,i=null,a&&(clearTimeout(a),a=null),t(...p)};return[(...p)=>{const c=Date.now(),m=c-r;m>=s?o(p,c):(i=p,a||(a=setTimeout(()=>{a=null,o(i)},s-m)))},()=>i&&o(i)]}const De=(t,e,r=3)=>{let s=0;const i=un(50,250);return pn(a=>{const o=a.loaded,d=a.lengthComputable?a.total:void 0,h=o-s,p=i(h),c=o<=d;s=o;const m={loaded:o,total:d,progress:d?o/d:void 0,bytes:h,rate:p||void 0,estimated:p&&d&&c?(d-o)/p:void 0,event:a,lengthComputable:d!=null,[e?"download":"upload"]:!0};t(m)},r)},zt=(t,e)=>{const r=t!=null;return[s=>e[0]({lengthComputable:r,total:t,loaded:s}),e[1]]},_t=t=>(...e)=>f.asap(()=>t(...e)),fn=Q.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,Q.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(Q.origin),Q.navigator&&/(msie|trident)/i.test(Q.navigator.userAgent)):()=>!0,xn=Q.hasStandardBrowserEnv?{write(t,e,r,s,i,a){const o=[t+"="+encodeURIComponent(e)];f.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),f.isString(s)&&o.push("path="+s),f.isString(i)&&o.push("domain="+i),a===!0&&o.push("secure"),document.cookie=o.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 hn(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function mn(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function At(t,e,r){let s=!hn(e);return t&&(s||r==!1)?mn(t,e):e}const Nt=t=>t instanceof ne?{...t}:t;function he(t,e){e=e||{};const r={};function s(p,c,m,I){return f.isPlainObject(p)&&f.isPlainObject(c)?f.merge.call({caseless:I},p,c):f.isPlainObject(c)?f.merge({},c):f.isArray(c)?c.slice():c}function i(p,c,m,I){if(f.isUndefined(c)){if(!f.isUndefined(p))return s(void 0,p,m,I)}else return s(p,c,m,I)}function a(p,c){if(!f.isUndefined(c))return s(void 0,c)}function o(p,c){if(f.isUndefined(c)){if(!f.isUndefined(p))return s(void 0,p)}else return s(void 0,c)}function d(p,c,m){if(m in e)return s(p,c);if(m in t)return s(void 0,p)}const h={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:d,headers:(p,c,m)=>i(Nt(p),Nt(c),m,!0)};return f.forEach(Object.keys({...t,...e}),function(c){const m=h[c]||i,I=m(t[c],e[c],c);f.isUndefined(I)&&m!==d||(r[c]=I)}),r}const $t=t=>{const e=he({},t);let{data:r,withXSRFToken:s,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:d}=e;if(e.headers=o=ne.from(o),e.url=kt(At(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),d&&o.set("Authorization","Basic "+btoa((d.username||"")+":"+(d.password?unescape(encodeURIComponent(d.password)):""))),f.isFormData(r)){if(Q.hasStandardBrowserEnv||Q.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(f.isFunction(r.getHeaders)){const h=r.getHeaders(),p=["content-type","content-length"];Object.entries(h).forEach(([c,m])=>{p.includes(c.toLowerCase())&&o.set(c,m)})}}if(Q.hasStandardBrowserEnv&&(s&&f.isFunction(s)&&(s=s(e)),s||s!==!1&&fn(e.url))){const h=i&&a&&xn.read(a);h&&o.set(i,h)}return e},gn=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,s){const i=$t(t);let a=i.data;const o=ne.from(i.headers).normalize();let{responseType:d,onUploadProgress:h,onDownloadProgress:p}=i,c,m,I,R,u;function S(){R&&R(),u&&u(),i.cancelToken&&i.cancelToken.unsubscribe(c),i.signal&&i.signal.removeEventListener("abort",c)}let x=new XMLHttpRequest;x.open(i.method.toUpperCase(),i.url,!0),x.timeout=i.timeout;function T(){if(!x)return;const _=ne.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),A={data:!d||d==="text"||d==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:_,config:t,request:x};Rt(function(v){r(v),S()},function(v){s(v),S()},A),x=null}"onloadend"in x?x.onloadend=T:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(T)},x.onabort=function(){x&&(s(new U("Request aborted",U.ECONNABORTED,t,x)),x=null)},x.onerror=function(y){const A=y&&y.message?y.message:"Network Error",g=new U(A,U.ERR_NETWORK,t,x);g.event=y||null,s(g),x=null},x.ontimeout=function(){let y=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const A=i.transitional||Tt;i.timeoutErrorMessage&&(y=i.timeoutErrorMessage),s(new U(y,A.clarifyTimeoutError?U.ETIMEDOUT:U.ECONNABORTED,t,x)),x=null},a===void 0&&o.setContentType(null),"setRequestHeader"in x&&f.forEach(o.toJSON(),function(y,A){x.setRequestHeader(A,y)}),f.isUndefined(i.withCredentials)||(x.withCredentials=!!i.withCredentials),d&&d!=="json"&&(x.responseType=i.responseType),p&&([I,u]=De(p,!0),x.addEventListener("progress",I)),h&&x.upload&&([m,R]=De(h),x.upload.addEventListener("progress",m),x.upload.addEventListener("loadend",R)),(i.cancelToken||i.signal)&&(c=_=>{x&&(s(!_||_.type?new be(null,t,x):_),x.abort(),x=null)},i.cancelToken&&i.cancelToken.subscribe(c),i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c)));const P=cn(i.url);if(P&&Q.protocols.indexOf(P)===-1){s(new U("Unsupported protocol "+P+":",U.ERR_BAD_REQUEST,t));return}x.send(a||null)})},yn=(t,e)=>{const{length:r}=t=t?t.filter(Boolean):[];if(e||r){let s=new AbortController,i;const a=function(p){if(!i){i=!0,d();const c=p instanceof Error?p:this.reason;s.abort(c instanceof U?c:new be(c instanceof Error?c.message:c))}};let o=e&&setTimeout(()=>{o=null,a(new U(`timeout ${e} of ms exceeded`,U.ETIMEDOUT))},e);const d=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(p=>{p.unsubscribe?p.unsubscribe(a):p.removeEventListener("abort",a)}),t=null)};t.forEach(p=>p.addEventListener("abort",a));const{signal:h}=s;return h.unsubscribe=()=>f.asap(d),h}},bn=function*(t,e){let r=t.byteLength;if(r<e){yield t;return}let s=0,i;for(;s<r;)i=s+e,yield t.slice(s,i),s=i},wn=async function*(t,e){for await(const r of Sn(t))yield*bn(r,e)},Sn=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:r,value:s}=await e.read();if(r)break;yield s}}finally{await e.cancel()}},Ut=(t,e,r,s)=>{const i=wn(t,e);let a=0,o,d=h=>{o||(o=!0,s&&s(h))};return new ReadableStream({async pull(h){try{const{done:p,value:c}=await i.next();if(p){d(),h.close();return}let m=c.byteLength;if(r){let I=a+=m;r(I)}h.enqueue(new Uint8Array(c))}catch(p){throw d(p),p}},cancel(h){return d(h),i.return()}},{highWaterMark:2})},Dt=64*1024,{isFunction:Le}=f,jn=(({Request:t,Response:e})=>({Request:t,Response:e}))(f.global),{ReadableStream:Lt,TextEncoder:Ft}=f.global,qt=(t,...e)=>{try{return!!t(...e)}catch{return!1}},vn=t=>{t=f.merge.call({skipUndefined:!0},jn,t);const{fetch:e,Request:r,Response:s}=t,i=e?Le(e):typeof fetch=="function",a=Le(r),o=Le(s);if(!i)return!1;const d=i&&Le(Lt),h=i&&(typeof Ft=="function"?(u=>S=>u.encode(S))(new Ft):async u=>new Uint8Array(await new r(u).arrayBuffer())),p=a&&d&&qt(()=>{let u=!1;const S=new r(Q.origin,{body:new Lt,method:"POST",get duplex(){return u=!0,"half"}}).headers.has("Content-Type");return u&&!S}),c=o&&d&&qt(()=>f.isReadableStream(new s("").body)),m={stream:c&&(u=>u.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(u=>{!m[u]&&(m[u]=(S,x)=>{let T=S&&S[u];if(T)return T.call(S);throw new U(`Response type '${u}' is not supported`,U.ERR_NOT_SUPPORT,x)})});const I=async u=>{if(u==null)return 0;if(f.isBlob(u))return u.size;if(f.isSpecCompliantForm(u))return(await new r(Q.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 h(u)).byteLength},R=async(u,S)=>{const x=f.toFiniteNumber(u.getContentLength());return x??I(S)};return async u=>{let{url:S,method:x,data:T,signal:P,cancelToken:_,timeout:y,onDownloadProgress:A,onUploadProgress:g,responseType:v,headers:L,withCredentials:N="same-origin",fetchOptions:M}=$t(u),X=e||fetch;v=v?(v+"").toLowerCase():"text";let C=yn([P,_&&_.toAbortSignal()],y),V=null;const z=C&&C.unsubscribe&&(()=>{C.unsubscribe()});let O;try{if(g&&p&&x!=="get"&&x!=="head"&&(O=await R(L,T))!==0){let l=new r(S,{method:"POST",body:T,duplex:"half"}),w;if(f.isFormData(T)&&(w=l.headers.get("content-type"))&&L.setContentType(w),l.body){const[E,j]=zt(O,De(_t(g)));T=Ut(l.body,Dt,E,j)}}f.isString(N)||(N=N?"include":"omit");const W=a&&"credentials"in r.prototype,ee={...M,signal:C,method:x.toUpperCase(),headers:L.normalize().toJSON(),body:T,duplex:"half",credentials:W?N:void 0};V=a&&new r(S,ee);let B=await(a?X(V,M):X(S,ee));const J=c&&(v==="stream"||v==="response");if(c&&(A||J&&z)){const l={};["status","statusText","headers"].forEach(G=>{l[G]=B[G]});const w=f.toFiniteNumber(B.headers.get("content-length")),[E,j]=A&&zt(w,De(_t(A),!0))||[];B=new s(Ut(B.body,Dt,E,()=>{j&&j(),z&&z()}),l)}v=v||"text";let F=await m[f.findKey(m,v)||"text"](B,u);return!J&&z&&z(),await new Promise((l,w)=>{Rt(l,w,{data:F,headers:ne.from(B.headers),status:B.status,statusText:B.statusText,config:u,request:V})})}catch(W){throw z&&z(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new U("Network Error",U.ERR_NETWORK,u,V),{cause:W.cause||W}):U.from(W,W&&W.code,u,V)}}},En=new Map,Mt=t=>{let e=t?t.env:{};const{fetch:r,Request:s,Response:i}=e,a=[s,i,r];let o=a.length,d=o,h,p,c=En;for(;d--;)h=a[d],p=c.get(h),p===void 0&&c.set(h,p=d?new Map:vn(e)),c=p;return p};Mt();const Qe={http:Hr,xhr:gn,fetch:{get:Mt}};f.forEach(Qe,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Wt=t=>`- ${t}`,kn=t=>f.isFunction(t)||t===null||t===!1,Bt={getAdapter:(t,e)=>{t=f.isArray(t)?t:[t];const{length:r}=t;let s,i;const a={};for(let o=0;o<r;o++){s=t[o];let d;if(i=s,!kn(s)&&(i=Qe[(d=String(s)).toLowerCase()],i===void 0))throw new U(`Unknown adapter '${d}'`);if(i&&(f.isFunction(i)||(i=i.get(e))))break;a[d||"#"+o]=i}if(!i){const o=Object.entries(a).map(([h,p])=>`adapter ${h} `+(p===!1?"is not supported by the environment":"is not available in the build"));let d=r?o.length>1?`since :
|
|
4
4
|
`+o.map(Wt).join(`
|
|
5
5
|
`):" "+Wt(o[0]):"as no adapter specified";throw new U("There is no suitable adapter to dispatch the request "+d,"ERR_NOT_SUPPORT")}return i},adapters:Qe};function et(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new be(null,t)}function Ht(t){return et(t),t.headers=ne.from(t.headers),t.data=Ze.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Bt.getAdapter(t.adapter||ke.adapter,t)(t).then(function(s){return et(t),s.data=Ze.call(t,t.transformResponse,s),s.headers=ne.from(s.headers),s},function(s){return Ot(s)||(et(t),s&&s.response&&(s.response.data=Ze.call(t,t.transformResponse,s.response),s.response.headers=ne.from(s.response.headers))),Promise.reject(s)})}const Vt="1.12.2",Fe={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Fe[t]=function(s){return typeof s===t||"a"+(e<1?"n ":" ")+t}});const Yt={};Fe.transitional=function(e,r,s){function i(a,o){return"[Axios v"+Vt+"] Transitional option '"+a+"'"+o+(s?". "+s:"")}return(a,o,d)=>{if(e===!1)throw new U(i(o," has been removed"+(r?" in "+r:"")),U.ERR_DEPRECATED);return r&&!Yt[o]&&(Yt[o]=!0,console.warn(i(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(a,o,d):!0}},Fe.spelling=function(e){return(r,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function Cn(t,e,r){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 a=s[i],o=e[a];if(o){const d=t[a],h=d===void 0||o(d,a,t);if(h!==!0)throw new U("option "+a+" must be "+h,U.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new U("Unknown option "+a,U.ERR_BAD_OPTION)}}const qe={assertOptions:Cn,validators:Fe},ae=qe.validators;let me=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Ct,response:new Ct}}async request(e,r){try{return await this._request(e,r)}catch(s){if(s instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const a=i.stack?i.stack.replace(/^.+\n/,""):"";try{s.stack?a&&!String(s.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(s.stack+=`
|
|
6
|
-
`+a):s.stack=a}catch{}}throw s}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=he(this.defaults,r);const{transitional:s,paramsSerializer:i,headers:a}=r;s!==void 0&&qe.assertOptions(s,{silentJSONParsing:ae.transitional(ae.boolean),forcedJSONParsing:ae.transitional(ae.boolean),clarifyTimeoutError:ae.transitional(ae.boolean)},!1),i!=null&&(f.isFunction(i)?r.paramsSerializer={serialize:i}:qe.assertOptions(i,{encode:ae.function,serialize:ae.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),qe.assertOptions(r,{baseUrl:ae.spelling("baseURL"),withXsrfToken:ae.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=a&&f.merge(a.common,a[r.method]);a&&f.forEach(["delete","get","head","post","put","patch","common"],u=>{delete a[u]}),r.headers=ne.concat(o,a);const d=[];let h=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(r)===!1||(h=h&&S.synchronous,d.unshift(S.fulfilled,S.rejected))});const p=[];this.interceptors.response.forEach(function(S){p.push(S.fulfilled,S.rejected)});let c,m=0,I;if(!h){const u=[Ht.bind(this),void 0];for(u.unshift(...d),u.push(...p),I=u.length,c=Promise.resolve(r);m<I;)c=c.then(u[m++],u[m++]);return c}I=d.length;let R=r;for(;m<I;){const u=d[m++],S=d[m++];try{R=u(R)}catch(x){S.call(this,x);break}}try{c=Ht.call(this,R)}catch(u){return Promise.reject(u)}for(m=0,I=p.length;m<I;)c=c.then(p[m++],p[m++]);return c}getUri(e){e=he(this.defaults,e);const r=At(e.baseURL,e.url,e.allowAbsoluteUrls);return kt(r,e.params,e.paramsSerializer)}};f.forEach(["delete","get","head","options"],function(e){me.prototype[e]=function(r,s){return this.request(he(s||{},{method:e,url:r,data:(s||{}).data}))}}),f.forEach(["post","put","patch"],function(e){function r(s){return function(a,o,d){return this.request(he(d||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:a,data:o}))}}me.prototype[e]=r(),me.prototype[e+"Form"]=r(!0)});let Tn=class or{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(a){r=a});const s=this;this.promise.then(i=>{if(!s._listeners)return;let a=s._listeners.length;for(;a-- >0;)s._listeners[a](i);s._listeners=null}),this.promise.then=i=>{let a;const o=new Promise(d=>{s.subscribe(d),a=d}).then(i);return o.cancel=function(){s.unsubscribe(a)},o},e(function(a,o,d){s.reason||(s.reason=new be(a,o,d),r(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 r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=s=>{e.abort(s)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new or(function(i){e=i}),cancel:e}}};function Pn(t){return function(r){return t.apply(null,r)}}function In(t){return f.isObject(t)&&t.isAxiosError===!0}const tt={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(tt).forEach(([t,e])=>{tt[e]=t});function Kt(t){const e=new me(t),r=ct(me.prototype.request,e);return f.extend(r,me.prototype,e,{allOwnKeys:!0}),f.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return Kt(he(t,i))},r}const K=Kt(ke);K.Axios=me,K.CanceledError=be,K.CancelToken=Tn,K.isCancel=Ot,K.VERSION=Vt,K.toFormData=$e,K.AxiosError=U,K.Cancel=K.CanceledError,K.all=function(e){return Promise.all(e)},K.spread=Pn,K.isAxiosError=In,K.mergeConfig=he,K.AxiosHeaders=ne,K.formToJSON=t=>Pt(f.isHTMLForm(t)?new FormData(t):t),K.getAdapter=Bt.getAdapter,K.HttpStatusCode=tt,K.default=K;const{Axios:bs,AxiosError:ws,CanceledError:Ss,isCancel:js,CancelToken:vs,VERSION:Es,all:ks,Cancel:Cs,isAxiosError:Ts,spread:Ps,toFormData:Is,AxiosHeaders:Os,HttpStatusCode:Rs,formToJSON:zs,getAdapter:_s,mergeConfig:As}=K;class On{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=K.create({baseURL:this.baseUrl,headers:{"Content-Type":"application/json",...this.apiKey?{"x-api-key":this.apiKey}:{}},timeout:3e4,withCredentials:!0})}async request(e,r,s,i={},a=!1){try{const o={...this.appId?{appId:this.appId}:{},...s||{}};return(await this.client.request({url:r,method:e,data:o,headers:i,withCredentials:a})).data}catch(o){throw K.isAxiosError(o)?{message:o.response?.data?.message||o.message||"Request failed",status:o.response?.status??0}:{message:o.message||"Unexpected error occurred"}}}async signupUser(e){const{name:r,email:s,password:i}=e;if(!r||!s||!i)throw new Error("signup: 'name', 'email', and 'password' are required");return this.request("POST","/users/signup",e)}async loginUser(e){const{email:r,password:s}=e;if(!r||!s)throw new Error("login: 'email' and 'password' are required");try{return await this.request("POST","/users/login",{email:r,password:s})}catch(i){throw new Error(i.message||"Login failed due to an unknown error")}}async changePassword(e){const{userId:r,currentPassword:s,newPassword:i}=e;if(!r)throw new Error("changePassword: 'userId' is required");if(!s||!i)throw new Error("changePassword: both 'currentPassword' and 'newPassword' are required");return this.request("PUT",`/users/change-password/${r}`,{currentPassword:s,newPassword:i})}async requestEmailVerificationOTP(e){const{userId:r,email:s}=e;if(!r)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(r)}`,{email:s})}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:r,otp:s}=e;if(!r)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:r,otp:s})}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")}catch{return{authenticated:!1}}}async updateUser(e){const{userId:r}=e;if(!r)throw new Error("updateUser: 'userId' is required");return this.request("PUT",`/users/update/${r}`,{...e})}async deleteUser(e){const{userId:r}=e;if(!r)throw new Error("deleteUser: 'userId' is required");return this.request("DELETE",`/users/delete/${r}`,{})}async getUserProfile(e){const{userId:r}=e;if(!r)throw new Error("getProfile: 'userId' and 'appId' are required");try{return await this.request("POST","/users/profile",{userId:r})}catch(s){throw{message:s.message||"Failed to fetch profile",status:s.status||500}}}async requestResetUserPasswordOTP(e){const{email:r}=e;if(!r)throw new Error("forgotPassword: 'email' is required");return this.request("POST","/users/forgot-password",{email:r})}async resetUserPassword(e){const{email:r,otp:s,newPassword:i}=e;if(!r||!s||!i)throw new Error("resetPassword: 'email', 'otp' and 'newPassword' are required");return this.request("POST","/users/reset-password",{email:r,otp:s,newPassword:i})}async checkIfUserExists(e){if(!e)throw new Error("checkUser: 'userId' is required");return this.request("GET",`/users/check-user/${e}?appId=${this.appId}`)}async searchUserData(e){const{userId:r,...s}=e;if(!r)throw new Error("userId required");const i=new URLSearchParams(s).toString();return this.request("GET",`/users/${r}/data/search?${i}`,void 0,{},!1)}async searchUserDataByKeys(e){const{userId:r,...s}=e;if(!r)throw new Error("searchUserDataByKeys: 'userId' is required");const i=new URLSearchParams(Object.entries(s).reduce((a,[o,d])=>(d!=null&&(a[o]=String(d)),a),{})).toString();return this.request("GET",`/users/${r}/data/searchbyref?${i}`,void 0,{},!1)}async getUserData(e){const{userId:r}=e;if(!r)throw new Error("getUserData: 'userId' is required");return this.request("GET",`/users/${r}/data`,void 0,{},!1)}async getSingleUserData(e){const{userId:r,dataId:s}=e;if(!r||!s)throw new Error("getSingleUserData: 'userId' and 'dataId' are required");return this.request("GET",`/users/${r}/data/${s}`,void 0,{},!1)}async addUserData(e){const{userId:r,dataCategory:s,data:i}=e;if(!r)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 this.request("POST",`/users/${r}/data`,{dataCategory:s,...i},{},!1)}async updateUserData(e){const{userId:r,dataId:s,data:i}=e;if(!r||!s)throw new Error("updateUserData: 'userId' and 'dataId' are required");if(!i)throw new Error("updateUserData: 'data' is required");return this.request("PUT",`/users/${r}/data/${s}`,i,{},!1)}async deleteUserData(e){const{userId:r,dataId:s}=e;if(!r||!s)throw new Error("deleteUserData: 'userId' and 'dataId' are required");return this.request("DELETE",`/users/${r}/data/${s}`,void 0,{},!1)}async getAppData(e){const r=this.appId;if(!r)throw new Error("getAppData: 'appId' is required");const s=e?`?category=${encodeURIComponent(e)}`:"";return(await this.request("GET",`/app/${r}/data${s}`))?.data||[]}async getSingleAppData(e){const r=this.appId;if(!r)throw new Error("getSingleAppData: 'appId' is required");if(!e.dataId)throw new Error("getSingleAppData: 'dataId' is required");return(await this.request("GET",`/app/${r}/data/${e.dataId}`))?.data}async searchAppDataByKeys(e){const r=this.appId;if(!r)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(r)}/data/search/bykeys`,e))?.data||[]}async addAppData(e){const r=this.appId;if(!r)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/${r}/data/${encodeURIComponent(s)}`,{item:i}))?.data}async updateAppData(e){const r=this.appId;if(!r)throw new Error("updateAppData: 'appId' is required");if(!e.dataId)throw new Error("updateAppData: 'dataId' is required");if(!e.data)throw new Error("updateAppData: 'data' is required");return(await this.request("PATCH",`/app/${r}/data/${e.dataId}`,e.data))?.data}async deleteAppData(e){const r=this.appId;if(!r)throw new Error("deleteAppData: 'appId' is required");if(!e.dataId)throw new Error("deleteAppData: 'dataId' is required");return(await this.request("DELETE",`/app/${r}/data/${e.dataId}`))?.data}}var Me={exports:{}},Te={};/**
|
|
6
|
+
`+a):s.stack=a}catch{}}throw s}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=he(this.defaults,r);const{transitional:s,paramsSerializer:i,headers:a}=r;s!==void 0&&qe.assertOptions(s,{silentJSONParsing:ae.transitional(ae.boolean),forcedJSONParsing:ae.transitional(ae.boolean),clarifyTimeoutError:ae.transitional(ae.boolean)},!1),i!=null&&(f.isFunction(i)?r.paramsSerializer={serialize:i}:qe.assertOptions(i,{encode:ae.function,serialize:ae.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),qe.assertOptions(r,{baseUrl:ae.spelling("baseURL"),withXsrfToken:ae.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=a&&f.merge(a.common,a[r.method]);a&&f.forEach(["delete","get","head","post","put","patch","common"],u=>{delete a[u]}),r.headers=ne.concat(o,a);const d=[];let h=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(r)===!1||(h=h&&S.synchronous,d.unshift(S.fulfilled,S.rejected))});const p=[];this.interceptors.response.forEach(function(S){p.push(S.fulfilled,S.rejected)});let c,m=0,I;if(!h){const u=[Ht.bind(this),void 0];for(u.unshift(...d),u.push(...p),I=u.length,c=Promise.resolve(r);m<I;)c=c.then(u[m++],u[m++]);return c}I=d.length;let R=r;for(;m<I;){const u=d[m++],S=d[m++];try{R=u(R)}catch(x){S.call(this,x);break}}try{c=Ht.call(this,R)}catch(u){return Promise.reject(u)}for(m=0,I=p.length;m<I;)c=c.then(p[m++],p[m++]);return c}getUri(e){e=he(this.defaults,e);const r=At(e.baseURL,e.url,e.allowAbsoluteUrls);return kt(r,e.params,e.paramsSerializer)}};f.forEach(["delete","get","head","options"],function(e){me.prototype[e]=function(r,s){return this.request(he(s||{},{method:e,url:r,data:(s||{}).data}))}}),f.forEach(["post","put","patch"],function(e){function r(s){return function(a,o,d){return this.request(he(d||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:a,data:o}))}}me.prototype[e]=r(),me.prototype[e+"Form"]=r(!0)});let Tn=class or{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(a){r=a});const s=this;this.promise.then(i=>{if(!s._listeners)return;let a=s._listeners.length;for(;a-- >0;)s._listeners[a](i);s._listeners=null}),this.promise.then=i=>{let a;const o=new Promise(d=>{s.subscribe(d),a=d}).then(i);return o.cancel=function(){s.unsubscribe(a)},o},e(function(a,o,d){s.reason||(s.reason=new be(a,o,d),r(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 r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=s=>{e.abort(s)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new or(function(i){e=i}),cancel:e}}};function Pn(t){return function(r){return t.apply(null,r)}}function In(t){return f.isObject(t)&&t.isAxiosError===!0}const tt={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(tt).forEach(([t,e])=>{tt[e]=t});function Kt(t){const e=new me(t),r=ct(me.prototype.request,e);return f.extend(r,me.prototype,e,{allOwnKeys:!0}),f.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return Kt(he(t,i))},r}const K=Kt(ke);K.Axios=me,K.CanceledError=be,K.CancelToken=Tn,K.isCancel=Ot,K.VERSION=Vt,K.toFormData=$e,K.AxiosError=U,K.Cancel=K.CanceledError,K.all=function(e){return Promise.all(e)},K.spread=Pn,K.isAxiosError=In,K.mergeConfig=he,K.AxiosHeaders=ne,K.formToJSON=t=>Pt(f.isHTMLForm(t)?new FormData(t):t),K.getAdapter=Bt.getAdapter,K.HttpStatusCode=tt,K.default=K;const{Axios:bs,AxiosError:ws,CanceledError:Ss,isCancel:js,CancelToken:vs,VERSION:Es,all:ks,Cancel:Cs,isAxiosError:Ts,spread:Ps,toFormData:Is,AxiosHeaders:Os,HttpStatusCode:Rs,formToJSON:zs,getAdapter:_s,mergeConfig:As}=K;class On{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=K.create({baseURL:this.baseUrl,headers:{"Content-Type":"application/json",...this.apiKey?{"x-api-key":this.apiKey}:{}},timeout:3e4,withCredentials:!0})}async request(e,r,s,i={},a=!1){try{const o={...this.appId?{appId:this.appId}:{},...s||{}};return(await this.client.request({url:r,method:e,data:o,headers:i,withCredentials:a})).data}catch(o){throw K.isAxiosError(o)?{message:o.response?.data?.message||o.message||"Request failed",status:o.response?.status??0}:{message:o.message||"Unexpected error occurred"}}}async signupUser(e){const{name:r,email:s,password:i}=e;if(!r||!s||!i)throw new Error("signup: 'name', 'email', and 'password' are required");return this.request("POST","/users/signup",e,{},!0)}async loginUser(e){const{email:r,password:s}=e;if(!r||!s)throw new Error("login: 'email' and 'password' are required");try{return this.request("POST","/users/login",{email:r,password:s},{},!0)}catch(i){throw new Error(i.message||"Login failed due to an unknown error")}}async changePassword(e){const{userId:r,currentPassword:s,newPassword:i}=e;if(!r)throw new Error("changePassword: 'userId' is required");if(!s||!i)throw new Error("changePassword: both 'currentPassword' and 'newPassword' are required");return this.request("PUT",`/users/change-password/${r}`,{currentPassword:s,newPassword:i},{},!0)}async requestEmailVerificationOTP(e){const{userId:r,email:s}=e;if(!r)throw{message:"requestEmailVerificationOTP: 'userId' is required",status:400};if(!s)throw{message:"requestEmailVerificationOTP: 'email' is required",status:400};try{return this.request("POST",`/users/send-verify-otp/${encodeURIComponent(r)}`,{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:r,otp:s}=e;if(!r)throw new Error("verifyEmail: 'email' is required");if(!s)throw new Error("verifyEmail: 'otp' is required");try{return this.request("POST","/users/verify-email",{email:r,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 this.request("GET","/users/session",void 0,{},!0)}catch{return{authenticated:!1}}}async updateUser(e){const{userId:r}=e;if(!r)throw new Error("updateUser: 'userId' is required");return this.request("PUT",`/users/update/${r}`,{...e},{},!0)}async deleteUser(e){const{userId:r}=e;if(!r)throw new Error("deleteUser: 'userId' is required");return this.request("DELETE",`/users/delete/${r}`,{},{},!0)}async getUserProfile(e){const{userId:r}=e;if(!r)throw new Error("getProfile: 'userId' and 'appId' are required");try{return this.request("POST","/users/profile",{userId:r},{},!0)}catch(s){throw{message:s.message||"Failed to fetch profile",status:s.status||500}}}async requestResetUserPasswordOTP(e){const{email:r}=e;if(!r)throw new Error("forgotPassword: 'email' is required");return this.request("POST","/users/forgot-password",{email:r})}async resetUserPassword(e){const{email:r,otp:s,newPassword:i}=e;if(!r||!s||!i)throw new Error("resetPassword: 'email', 'otp' and 'newPassword' are required");return this.request("POST","/users/reset-password",{email:r,otp:s,newPassword:i})}async checkIfUserExists(e){if(!e)throw new Error("checkUser: 'userId' is required");return this.request("GET",`/users/check-user/${e}?appId=${this.appId}`)}async searchUserData(e){const{userId:r,...s}=e;if(!r)throw new Error("userId required");const i=new URLSearchParams(s).toString();return this.request("GET",`/users/${r}/data/search?${i}`,void 0,{},!1)}async searchUserDataByKeys(e){const{userId:r,...s}=e;if(!r)throw new Error("searchUserDataByKeys: 'userId' is required");const i=new URLSearchParams(Object.entries(s).reduce((a,[o,d])=>(d!=null&&(a[o]=String(d)),a),{})).toString();return this.request("GET",`/users/${r}/data/searchbyref?${i}`,void 0,{},!1)}async getUserData(e){const{userId:r}=e;if(!r)throw new Error("getUserData: 'userId' is required");return this.request("GET",`/users/${r}/data`,void 0,{},!1)}async getSingleUserData(e){const{userId:r,dataId:s}=e;if(!r||!s)throw new Error("getSingleUserData: 'userId' and 'dataId' are required");return this.request("GET",`/users/${r}/data/${s}`,void 0,{},!1)}async addUserData(e){const{userId:r,dataCategory:s,data:i}=e;if(!r)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 this.request("POST",`/users/${r}/data`,{dataCategory:s,...i},{},!1)}async updateUserData(e){const{userId:r,dataId:s,data:i}=e;if(!r||!s)throw new Error("updateUserData: 'userId' and 'dataId' are required");if(!i)throw new Error("updateUserData: 'data' is required");return this.request("PUT",`/users/${r}/data/${s}`,i,{},!1)}async deleteUserData(e){const{userId:r,dataId:s}=e;if(!r||!s)throw new Error("deleteUserData: 'userId' and 'dataId' are required");return this.request("DELETE",`/users/${r}/data/${s}`,void 0,{},!1)}async getAppData(e){const r=this.appId;if(!r)throw new Error("getAppData: 'appId' is required");const s=e?`?category=${encodeURIComponent(e)}`:"";return(await this.request("GET",`/app/${r}/data${s}`))?.data||[]}async getSingleAppData(e){const r=this.appId;if(!r)throw new Error("getSingleAppData: 'appId' is required");if(!e.dataId)throw new Error("getSingleAppData: 'dataId' is required");return(await this.request("GET",`/app/${r}/data/${e.dataId}`))?.data}async searchAppDataByKeys(e){const r=this.appId;if(!r)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(r)}/data/search/bykeys`,e))?.data||[]}async addAppData(e){const r=this.appId;if(!r)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/${r}/data/${encodeURIComponent(s)}`,{item:i}))?.data}async updateAppData(e){const r=this.appId;if(!r)throw new Error("updateAppData: 'appId' is required");if(!e.dataId)throw new Error("updateAppData: 'dataId' is required");if(!e.data)throw new Error("updateAppData: 'data' is required");return(await this.request("PATCH",`/app/${r}/data/${e.dataId}`,e.data))?.data}async deleteAppData(e){const r=this.appId;if(!r)throw new Error("deleteAppData: 'appId' is required");if(!e.dataId)throw new Error("deleteAppData: 'dataId' is required");return(await this.request("DELETE",`/app/${r}/data/${e.dataId}`))?.data}}var Me={exports:{}},Te={};/**
|
|
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,EAEhB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,MAAM,CAAgB;IAE9B;;;OAGG;gBACS,MAAM,EAAE,mBAAmB;IAoBvC;;;;;;OAMG;YACW,OAAO;IAqCrB;;;OAGG;IACG,UAAU,CAAC,MAAM,EAAE,YAAY;IASrC;;;OAGG;IACG,SAAS,CAAC,MAAM,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"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"}
|