@neuctra/authix 1.0.18 → 1.0.19

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.
@@ -1773,12 +1773,12 @@ class co {
1773
1773
  });
1774
1774
  }
1775
1775
  /**
1776
- * 🌐 Universal request helper with structured responses and error handling
1777
- * @param method HTTP method (GET, POST, PUT, DELETE)
1778
- * @param path API endpoint path
1779
- * @param data optional request body
1780
- * @param extraHeaders optional headers
1781
- */
1776
+ * 🌐 Universal request helper with structured responses and error handling
1777
+ * @param method HTTP method (GET, POST, PUT, DELETE)
1778
+ * @param path API endpoint path
1779
+ * @param data optional request body
1780
+ * @param extraHeaders optional headers
1781
+ */
1782
1782
  async request(t, r, s, o = {}) {
1783
1783
  if (!t) return { success: !1, message: "HTTP method is required" };
1784
1784
  if (!r) return { success: !1, message: "Request path is required" };
@@ -1795,24 +1795,18 @@ class co {
1795
1795
  data: i,
1796
1796
  headers: o
1797
1797
  })).data,
1798
- message: "Request completed successfully"
1798
+ message: "Request completed successfully"
1799
1799
  };
1800
1800
  } catch (i) {
1801
- if (console.error("[Request Error]:", i), i.isAxiosError && !i.response)
1802
- return {
1803
- success: !1,
1804
- message: `🌐 Network error: ${i.message}`
1805
- };
1806
- if (i.response) {
1807
- const a = i.response.status, l = i.response.data?.message || i.response.statusText || "Server returned an error";
1808
- return {
1809
- success: !1,
1810
- message: `⚠️ Request failed (${a}): ${l}`
1811
- };
1812
- }
1813
- return {
1801
+ return console.error("[Request Error]:", i), i.isAxiosError && !i.response ? {
1802
+ success: !1,
1803
+ message: `Network error: ${i.message}`
1804
+ } : i.response ? {
1805
+ success: !1,
1806
+ message: `Request failed: ${i.response.data?.message || i.response.statusText || "Server returned an error"}`
1807
+ } : {
1814
1808
  success: !1,
1815
- message: `🚨 Unexpected error: ${i.message || "Something went wrong"}`
1809
+ message: `Unexpected error: ${i.message || "Something went wrong"}`
1816
1810
  };
1817
1811
  }
1818
1812
  }
@@ -3,7 +3,7 @@
3
3
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const s=new this(t);return r.forEach(o=>s.set(o)),s}static accessor(t){const s=(this[Rt]=this[Rt]={accessors:{}}).accessors,o=this.prototype;function i(a){const l=Te(a);s[l]||(ln(o,a),s[l]=!0)}return p.isArray(t)?t.forEach(i):i(t),this}};ne.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),p.reduceDescriptors(ne.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[r]=s}}}),p.freezeMethods(ne);function Ge(e,t){const r=this||Ce,s=t||r,o=ne.from(s.headers);let i=s.data;return p.forEach(e,function(l){i=l.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function It(e){return!!(e&&e.__CANCEL__)}function we(e,t,r){U.call(this,e??"canceled",U.ERR_CANCELED,t,r),this.name="CanceledError"}p.inherits(we,U,{__CANCEL__:!0});function Pt(e,t,r){const s=r.config.validateStatus;!r.status||!s||s(r.status)?e(r):t(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(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function dn(e,t){e=e||10;const r=new Array(e),s=new Array(e);let o=0,i=0,a;return t=t!==void 0?t:1e3,function(h){const c=Date.now(),u=s[i];a||(a=c),r[o]=h,s[o]=c;let y=i,R=0;for(;y!==o;)R+=r[y++],y=y%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),c-a<t)return;const k=u&&c-u;return k?Math.round(R*1e3/k):void 0}}function un(e,t){let r=0,s=1e3/t,o,i;const a=(c,u=Date.now())=>{r=u,o=null,i&&(clearTimeout(i),i=null),e(...c)};return[(...c)=>{const u=Date.now(),y=u-r;y>=s?a(c,u):(o=c,i||(i=setTimeout(()=>{i=null,a(o)},s-y)))},()=>o&&a(o)]}const De=(e,t,r=3)=>{let s=0;const o=dn(50,250);return un(i=>{const a=i.loaded,l=i.lengthComputable?i.total:void 0,h=a-s,c=o(h),u=a<=l;s=a;const y={loaded:a,total:l,progress:l?a/l:void 0,bytes:h,rate:c||void 0,estimated:c&&l&&u?(l-a)/c:void 0,event:i,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(y)},r)},Ot=(e,t)=>{const r=e!=null;return[s=>t[0]({lengthComputable:r,total:e,loaded:s}),t[1]]},_t=e=>(...t)=>p.asap(()=>e(...t)),pn=ee.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,ee.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(ee.origin),ee.navigator&&/(msie|trident)/i.test(ee.navigator.userAgent)):()=>!0,fn=ee.hasStandardBrowserEnv?{write(e,t,r,s,o,i){const a=[e+"="+encodeURIComponent(t)];p.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),p.isString(s)&&a.push("path="+s),p.isString(o)&&a.push("domain="+o),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function hn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function At(e,t,r){let s=!xn(t);return e&&(s||r==!1)?hn(e,t):t}const zt=e=>e instanceof ne?{...e}:e;function pe(e,t){t=t||{};const r={};function s(c,u,y,R){return p.isPlainObject(c)&&p.isPlainObject(u)?p.merge.call({caseless:R},c,u):p.isPlainObject(u)?p.merge({},u):p.isArray(u)?u.slice():u}function o(c,u,y,R){if(p.isUndefined(u)){if(!p.isUndefined(c))return s(void 0,c,y,R)}else return s(c,u,y,R)}function i(c,u){if(!p.isUndefined(u))return s(void 0,u)}function a(c,u){if(p.isUndefined(u)){if(!p.isUndefined(c))return s(void 0,c)}else return s(void 0,u)}function l(c,u,y){if(y in t)return s(c,u);if(y in e)return s(void 0,c)}const h={url:i,method:i,data:i,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:l,headers:(c,u,y)=>o(zt(c),zt(u),y,!0)};return p.forEach(Object.keys({...e,...t}),function(u){const y=h[u]||o,R=y(e[u],t[u],u);p.isUndefined(R)&&y!==l||(r[u]=R)}),r}const Nt=e=>{const t=pe({},e);let{data:r,withXSRFToken:s,xsrfHeaderName:o,xsrfCookieName:i,headers:a,auth:l}=t;if(t.headers=a=ne.from(a),t.url=kt(At(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&a.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),p.isFormData(r)){if(ee.hasStandardBrowserEnv||ee.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(p.isFunction(r.getHeaders)){const h=r.getHeaders(),c=["content-type","content-length"];Object.entries(h).forEach(([u,y])=>{c.includes(u.toLowerCase())&&a.set(u,y)})}}if(ee.hasStandardBrowserEnv&&(s&&p.isFunction(s)&&(s=s(t)),s||s!==!1&&pn(t.url))){const h=o&&i&&fn.read(i);h&&a.set(o,h)}return t},gn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,s){const o=Nt(e);let i=o.data;const a=ne.from(o.headers).normalize();let{responseType:l,onUploadProgress:h,onDownloadProgress:c}=o,u,y,R,k,d;function b(){k&&k(),d&&d(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function M(){if(!g)return;const _=ne.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),B={data:!l||l==="text"||l==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:_,config:e,request:g};Pt(function(N){r(N),b()},function(N){s(N),b()},B),g=null}"onloadend"in g?g.onloadend=M:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(M)},g.onabort=function(){g&&(s(new U("Request aborted",U.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const B=E&&E.message?E.message:"Network Error",m=new U(B,U.ERR_NETWORK,e,g);m.event=E||null,s(m),g=null},g.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const B=o.transitional||Ct;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),s(new U(E,B.clarifyTimeoutError?U.ETIMEDOUT:U.ECONNABORTED,e,g)),g=null},i===void 0&&a.setContentType(null),"setRequestHeader"in g&&p.forEach(a.toJSON(),function(E,B){g.setRequestHeader(B,E)}),p.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),l&&l!=="json"&&(g.responseType=o.responseType),c&&([R,d]=De(c,!0),g.addEventListener("progress",R)),h&&g.upload&&([y,k]=De(h),g.upload.addEventListener("progress",y),g.upload.addEventListener("loadend",k)),(o.cancelToken||o.signal)&&(u=_=>{g&&(s(!_||_.type?new we(null,e,g):_),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const D=cn(o.url);if(D&&ee.protocols.indexOf(D)===-1){s(new U("Unsupported protocol "+D+":",U.ERR_BAD_REQUEST,e));return}g.send(i||null)})},mn=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let s=new AbortController,o;const i=function(c){if(!o){o=!0,l();const u=c instanceof Error?c:this.reason;s.abort(u instanceof U?u:new we(u instanceof Error?u.message:u))}};let a=t&&setTimeout(()=>{a=null,i(new U(`timeout ${t} of ms exceeded`,U.ETIMEDOUT))},t);const l=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(i):c.removeEventListener("abort",i)}),e=null)};e.forEach(c=>c.addEventListener("abort",i));const{signal:h}=s;return h.unsubscribe=()=>p.asap(l),h}},yn=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let s=0,o;for(;s<r;)o=s+t,yield e.slice(s,o),s=o},bn=async function*(e,t){for await(const r of wn(e))yield*yn(r,t)},wn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:s}=await t.read();if(r)break;yield s}}finally{await t.cancel()}},Ut=(e,t,r,s)=>{const o=bn(e,t);let i=0,a,l=h=>{a||(a=!0,s&&s(h))};return new ReadableStream({async pull(h){try{const{done:c,value:u}=await o.next();if(c){l(),h.close();return}let y=u.byteLength;if(r){let R=i+=y;r(R)}h.enqueue(new Uint8Array(u))}catch(c){throw l(c),c}},cancel(h){return l(h),o.return()}},{highWaterMark:2})},Dt=64*1024,{isFunction:Fe}=p,Sn=(({Request:e,Response:t})=>({Request:e,Response:t}))(p.global),{ReadableStream:Ft,TextEncoder:Lt}=p.global,Mt=(e,...t)=>{try{return!!e(...t)}catch{return!1}},jn=e=>{e=p.merge.call({skipUndefined:!0},Sn,e);const{fetch:t,Request:r,Response:s}=e,o=t?Fe(t):typeof fetch=="function",i=Fe(r),a=Fe(s);if(!o)return!1;const l=o&&Fe(Ft),h=o&&(typeof Lt=="function"?(d=>b=>d.encode(b))(new Lt):async d=>new Uint8Array(await new r(d).arrayBuffer())),c=i&&l&&Mt(()=>{let d=!1;const b=new r(ee.origin,{body:new Ft,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!b}),u=a&&l&&Mt(()=>p.isReadableStream(new s("").body)),y={stream:u&&(d=>d.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!y[d]&&(y[d]=(b,g)=>{let M=b&&b[d];if(M)return M.call(b);throw new U(`Response type '${d}' is not supported`,U.ERR_NOT_SUPPORT,g)})});const R=async d=>{if(d==null)return 0;if(p.isBlob(d))return d.size;if(p.isSpecCompliantForm(d))return(await new r(ee.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(p.isArrayBufferView(d)||p.isArrayBuffer(d))return d.byteLength;if(p.isURLSearchParams(d)&&(d=d+""),p.isString(d))return(await h(d)).byteLength},k=async(d,b)=>{const g=p.toFiniteNumber(d.getContentLength());return g??R(b)};return async d=>{let{url:b,method:g,data:M,signal:D,cancelToken:_,timeout:E,onDownloadProgress:B,onUploadProgress:m,responseType:N,headers:w,withCredentials:F="same-origin",fetchOptions:K}=Nt(d),L=t||fetch;N=N?(N+"").toLowerCase():"text";let Y=mn([D,_&&_.toAbortSignal()],E),Z=null;const C=Y&&Y.unsubscribe&&(()=>{Y.unsubscribe()});let J;try{if(m&&c&&g!=="get"&&g!=="head"&&(J=await k(w,M))!==0){let T=new r(b,{method:"POST",body:M,duplex:"half"}),z;if(p.isFormData(M)&&(z=T.headers.get("content-type"))&&w.setContentType(z),T.body){const[O,x]=Ot(J,De(_t(m)));M=Ut(T.body,Dt,O,x)}}p.isString(F)||(F=F?"include":"omit");const H=i&&"credentials"in r.prototype,A={...K,signal:Y,method:g.toUpperCase(),headers:w.normalize().toJSON(),body:M,duplex:"half",credentials:H?F:void 0};Z=i&&new r(b,A);let I=await(i?L(Z,K):L(b,A));const q=u&&(N==="stream"||N==="response");if(u&&(B||q&&C)){const T={};["status","statusText","headers"].forEach(j=>{T[j]=I[j]});const z=p.toFiniteNumber(I.headers.get("content-length")),[O,x]=B&&Ot(z,De(_t(B),!0))||[];I=new s(Ut(I.body,Dt,O,()=>{x&&x(),C&&C()}),T)}N=N||"text";let f=await y[p.findKey(y,N)||"text"](I,d);return!q&&C&&C(),await new Promise((T,z)=>{Pt(T,z,{data:f,headers:ne.from(I.headers),status:I.status,statusText:I.statusText,config:d,request:Z})})}catch(H){throw C&&C(),H&&H.name==="TypeError"&&/Load failed|fetch/i.test(H.message)?Object.assign(new U("Network Error",U.ERR_NETWORK,d,Z),{cause:H.cause||H}):U.from(H,H&&H.code,d,Z)}}},vn=new Map,Bt=e=>{let t=e?e.env:{};const{fetch:r,Request:s,Response:o}=t,i=[s,o,r];let a=i.length,l=a,h,c,u=vn;for(;l--;)h=i[l],c=u.get(h),c===void 0&&u.set(h,c=l?new Map:jn(t)),u=c;return c};Bt();const Ze={http:Hr,xhr:gn,fetch:{get:Bt}};p.forEach(Ze,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Wt=e=>`- ${e}`,kn=e=>p.isFunction(e)||e===null||e===!1,$t={getAdapter:(e,t)=>{e=p.isArray(e)?e:[e];const{length:r}=e;let s,o;const i={};for(let a=0;a<r;a++){s=e[a];let l;if(o=s,!kn(s)&&(o=Ze[(l=String(s)).toLowerCase()],o===void 0))throw new U(`Unknown adapter '${l}'`);if(o&&(p.isFunction(o)||(o=o.get(t))))break;i[l||"#"+a]=o}if(!o){const a=Object.entries(i).map(([h,c])=>`adapter ${h} `+(c===!1?"is not supported by the environment":"is not available in the build"));let l=r?a.length>1?`since :
4
4
  `+a.map(Wt).join(`
5
5
  `):" "+Wt(a[0]):"as no adapter specified";throw new U("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return o},adapters:Ze};function Qe(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new we(null,e)}function Ht(e){return Qe(e),e.headers=ne.from(e.headers),e.data=Ge.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),$t.getAdapter(e.adapter||Ce.adapter,e)(e).then(function(s){return Qe(e),s.data=Ge.call(e,e.transformResponse,s),s.headers=ne.from(s.headers),s},function(s){return It(s)||(Qe(e),s&&s.response&&(s.response.data=Ge.call(e,e.transformResponse,s.response),s.response.headers=ne.from(s.response.headers))),Promise.reject(s)})}const Vt="1.12.2",Le={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Le[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const Yt={};Le.transitional=function(t,r,s){function o(i,a){return"[Axios v"+Vt+"] Transitional option '"+i+"'"+a+(s?". "+s:"")}return(i,a,l)=>{if(t===!1)throw new U(o(a," has been removed"+(r?" in "+r:"")),U.ERR_DEPRECATED);return r&&!Yt[a]&&(Yt[a]=!0,console.warn(o(a," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,a,l):!0}},Le.spelling=function(t){return(r,s)=>(console.warn(`${s} is likely a misspelling of ${t}`),!0)};function En(e,t,r){if(typeof e!="object")throw new U("options must be an object",U.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let o=s.length;for(;o-- >0;){const i=s[o],a=t[i];if(a){const l=e[i],h=l===void 0||a(l,i,e);if(h!==!0)throw new U("option "+i+" must be "+h,U.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new U("Unknown option "+i,U.ERR_BAD_OPTION)}}const Me={assertOptions:En,validators:Le},ie=Me.validators;let fe=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Et,response:new Et}}async request(t,r){try{return await this._request(t,r)}catch(s){if(s instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const i=o.stack?o.stack.replace(/^.+\n/,""):"";try{s.stack?i&&!String(s.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(s.stack+=`
6
- `+i):s.stack=i}catch{}}throw s}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=pe(this.defaults,r);const{transitional:s,paramsSerializer:o,headers:i}=r;s!==void 0&&Me.assertOptions(s,{silentJSONParsing:ie.transitional(ie.boolean),forcedJSONParsing:ie.transitional(ie.boolean),clarifyTimeoutError:ie.transitional(ie.boolean)},!1),o!=null&&(p.isFunction(o)?r.paramsSerializer={serialize:o}:Me.assertOptions(o,{encode:ie.function,serialize:ie.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Me.assertOptions(r,{baseUrl:ie.spelling("baseURL"),withXsrfToken:ie.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let a=i&&p.merge(i.common,i[r.method]);i&&p.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),r.headers=ne.concat(a,i);const l=[];let h=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(r)===!1||(h=h&&b.synchronous,l.unshift(b.fulfilled,b.rejected))});const c=[];this.interceptors.response.forEach(function(b){c.push(b.fulfilled,b.rejected)});let u,y=0,R;if(!h){const d=[Ht.bind(this),void 0];for(d.unshift(...l),d.push(...c),R=d.length,u=Promise.resolve(r);y<R;)u=u.then(d[y++],d[y++]);return u}R=l.length;let k=r;for(;y<R;){const d=l[y++],b=l[y++];try{k=d(k)}catch(g){b.call(this,g);break}}try{u=Ht.call(this,k)}catch(d){return Promise.reject(d)}for(y=0,R=c.length;y<R;)u=u.then(c[y++],c[y++]);return u}getUri(t){t=pe(this.defaults,t);const r=At(t.baseURL,t.url,t.allowAbsoluteUrls);return kt(r,t.params,t.paramsSerializer)}};p.forEach(["delete","get","head","options"],function(t){fe.prototype[t]=function(r,s){return this.request(pe(s||{},{method:t,url:r,data:(s||{}).data}))}}),p.forEach(["post","put","patch"],function(t){function r(s){return function(i,a,l){return this.request(pe(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}fe.prototype[t]=r(),fe.prototype[t+"Form"]=r(!0)});let Cn=class or{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const s=this;this.promise.then(o=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](o);s._listeners=null}),this.promise.then=o=>{let i;const a=new Promise(l=>{s.subscribe(l),i=l}).then(o);return a.cancel=function(){s.unsubscribe(i)},a},t(function(i,a,l){s.reason||(s.reason=new we(i,a,l),r(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=s=>{t.abort(s)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new or(function(o){t=o}),cancel:t}}};function Tn(e){return function(r){return e.apply(null,r)}}function Rn(e){return p.isObject(e)&&e.isAxiosError===!0}const et={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(et).forEach(([e,t])=>{et[t]=e});function qt(e){const t=new fe(e),r=ct(fe.prototype.request,t);return p.extend(r,fe.prototype,t,{allOwnKeys:!0}),p.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return qt(pe(e,o))},r}const W=qt(Ce);W.Axios=fe,W.CanceledError=we,W.CancelToken=Cn,W.isCancel=It,W.VERSION=Vt,W.toFormData=Ne,W.AxiosError=U,W.Cancel=W.CanceledError,W.all=function(t){return Promise.all(t)},W.spread=Tn,W.isAxiosError=Rn,W.mergeConfig=pe,W.AxiosHeaders=ne,W.formToJSON=e=>Tt(p.isHTMLForm(e)?new FormData(e):e),W.getAdapter=$t.getAdapter,W.HttpStatusCode=et,W.default=W;const{Axios:ms,AxiosError:ys,CanceledError:bs,isCancel:ws,CancelToken:Ss,VERSION:js,all:vs,Cancel:ks,isAxiosError:Es,spread:Cs,toFormData:Ts,AxiosHeaders:Rs,HttpStatusCode:Is,formToJSON:Ps,getAdapter:Os,mergeConfig:_s}=W;class In{baseUrl;apiKey;appId;client;constructor(t){if(!t||!t.baseUrl)throw new Error("NeuctraAuthixClient: 'baseUrl' is required in config");this.baseUrl=t.baseUrl.replace(/\/$/,""),this.apiKey=t.apiKey||null,this.appId=t.appId||null,this.client=W.create({baseURL:this.baseUrl,headers:{"Content-Type":"application/json",...this.apiKey?{"x-api-key":this.apiKey}:{}},timeout:1e4})}async request(t,r,s,o={}){if(!t)return{success:!1,message:"HTTP method is required"};if(!r)return{success:!1,message:"Request path is required"};try{const i={...this.appId?{appId:this.appId}:{},...s||{}};return{success:!0,data:(await this.client.request({url:r,method:t,data:i,headers:o})).data,message:"Request completed successfully"}}catch(i){if(console.error("[Request Error]:",i),i.isAxiosError&&!i.response)return{success:!1,message:`🌐 Network error: ${i.message}`};if(i.response){const a=i.response.status,l=i.response.data?.message||i.response.statusText||"Server returned an error";return{success:!1,message:`⚠️ Request failed (${a}): ${l}`}}return{success:!1,message:`🚨 Unexpected error: ${i.message||"Something went wrong"}`}}}async signup(t){const{name:r,email:s,password:o}=t;if(!r||!s||!o)throw new Error("signup: 'name', 'email', and 'password' are required");return this.request("POST","/users/signup",t)}async login(t){const{email:r,password:s,appId:o}=t;if(!r||!s)throw new Error("login: 'email' and 'password' are required");return this.request("POST","/users/login",{email:r,password:s,appId:o||this.appId})}async updateUser(t){const{userId:r,appId:s}=t;if(!r)throw new Error("updateUser: 'userId' is required");return this.request("PUT",`/users/update/${r}`,{...t,appId:s||this.appId})}async changePassword(t){const{userId:r,currentPassword:s,newPassword:o,appId:i}=t;if(!r)throw new Error("changePassword: 'userId' is required");if(!s||!o)throw new Error("changePassword: both 'currentPassword' and 'newPassword' are required");return this.request("PUT",`/users/change-password/${r}`,{currentPassword:s,newPassword:o,appId:i||this.appId})}async deleteUser(t){const{userId:r,appId:s}=t;if(!r)throw new Error("deleteUser: 'userId' is required");return this.request("DELETE",`/users/delete/${r}`,{appId:s||this.appId})}async getProfile(t){const{token:r}=t;if(!r)throw new Error("getProfile: 'token' is required");return this.request("GET","/users/profile",{},{Authorization:`Bearer ${r}`})}async sendVerifyOTP(t){const{token:r,appId:s}=t;if(!r)throw new Error("sendVerifyOTP: 'token' is required");return this.request("POST","/users/send-verify-otp",{appId:s||this.appId},{Authorization:`Bearer ${r}`})}async verifyEmail(t){const{token:r,otp:s,appId:o}=t;if(!r)throw new Error("verifyEmail: 'token' is required");if(!s)throw new Error("verifyEmail: 'otp' is required");return this.request("POST","/users/verify-email",{otp:s,appId:o||this.appId},{Authorization:`Bearer ${r}`})}async forgotPassword(t){const{email:r,appId:s}=t;if(!r)throw new Error("forgotPassword: 'email' is required");return this.request("POST","/users/forgot-password",{email:r,appId:s||this.appId})}async resetPassword(t){const{email:r,otp:s,newPassword:o,appId:i}=t;if(!r||!s||!o)throw new Error("resetPassword: 'email', 'otp' and 'newPassword' are required");return this.request("POST","/users/reset-password",{email:r,otp:s,newPassword:o,appId:i||this.appId})}async getUserData(t){const{userId:r}=t;if(!r)throw new Error("getUserData: 'userId' is required");return this.request("GET",`/users/${r}/data`)}async getSingleUserData(t){const{userId:r,dataId:s}=t;if(!r||!s)throw new Error("getSingleUserData: 'userId' and 'dataId' are required");return this.request("GET",`/users/${r}/data/${s}`)}async addUserData(t){const{userId:r,data:s}=t;if(!r)throw new Error("addUserData: 'userId' is required");if(!s)throw new Error("addUserData: 'data' is required");return this.request("POST",`/users/${r}/data`,s)}async updateUserData(t){const{userId:r,dataId:s,data:o}=t;if(!r||!s)throw new Error("updateUserData: 'userId' and 'dataId' are required");if(!o)throw new Error("updateUserData: 'data' is required");return this.request("PUT",`/users/${r}/data/${s}`,o)}async deleteUserData(t){const{userId:r,dataId:s}=t;if(!r||!s)throw new Error("deleteUserData: 'userId' and 'dataId' are required");return this.request("DELETE",`/users/${r}/data/${s}`)}}var Be={exports:{}},Re={};/**
6
+ `+i):s.stack=i}catch{}}throw s}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=pe(this.defaults,r);const{transitional:s,paramsSerializer:o,headers:i}=r;s!==void 0&&Me.assertOptions(s,{silentJSONParsing:ie.transitional(ie.boolean),forcedJSONParsing:ie.transitional(ie.boolean),clarifyTimeoutError:ie.transitional(ie.boolean)},!1),o!=null&&(p.isFunction(o)?r.paramsSerializer={serialize:o}:Me.assertOptions(o,{encode:ie.function,serialize:ie.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Me.assertOptions(r,{baseUrl:ie.spelling("baseURL"),withXsrfToken:ie.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let a=i&&p.merge(i.common,i[r.method]);i&&p.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),r.headers=ne.concat(a,i);const l=[];let h=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(r)===!1||(h=h&&b.synchronous,l.unshift(b.fulfilled,b.rejected))});const c=[];this.interceptors.response.forEach(function(b){c.push(b.fulfilled,b.rejected)});let u,y=0,R;if(!h){const d=[Ht.bind(this),void 0];for(d.unshift(...l),d.push(...c),R=d.length,u=Promise.resolve(r);y<R;)u=u.then(d[y++],d[y++]);return u}R=l.length;let k=r;for(;y<R;){const d=l[y++],b=l[y++];try{k=d(k)}catch(g){b.call(this,g);break}}try{u=Ht.call(this,k)}catch(d){return Promise.reject(d)}for(y=0,R=c.length;y<R;)u=u.then(c[y++],c[y++]);return u}getUri(t){t=pe(this.defaults,t);const r=At(t.baseURL,t.url,t.allowAbsoluteUrls);return kt(r,t.params,t.paramsSerializer)}};p.forEach(["delete","get","head","options"],function(t){fe.prototype[t]=function(r,s){return this.request(pe(s||{},{method:t,url:r,data:(s||{}).data}))}}),p.forEach(["post","put","patch"],function(t){function r(s){return function(i,a,l){return this.request(pe(l||{},{method:t,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}fe.prototype[t]=r(),fe.prototype[t+"Form"]=r(!0)});let Cn=class or{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const s=this;this.promise.then(o=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](o);s._listeners=null}),this.promise.then=o=>{let i;const a=new Promise(l=>{s.subscribe(l),i=l}).then(o);return a.cancel=function(){s.unsubscribe(i)},a},t(function(i,a,l){s.reason||(s.reason=new we(i,a,l),r(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=s=>{t.abort(s)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new or(function(o){t=o}),cancel:t}}};function Tn(e){return function(r){return e.apply(null,r)}}function Rn(e){return p.isObject(e)&&e.isAxiosError===!0}const et={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(et).forEach(([e,t])=>{et[t]=e});function qt(e){const t=new fe(e),r=ct(fe.prototype.request,t);return p.extend(r,fe.prototype,t,{allOwnKeys:!0}),p.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return qt(pe(e,o))},r}const W=qt(Ce);W.Axios=fe,W.CanceledError=we,W.CancelToken=Cn,W.isCancel=It,W.VERSION=Vt,W.toFormData=Ne,W.AxiosError=U,W.Cancel=W.CanceledError,W.all=function(t){return Promise.all(t)},W.spread=Tn,W.isAxiosError=Rn,W.mergeConfig=pe,W.AxiosHeaders=ne,W.formToJSON=e=>Tt(p.isHTMLForm(e)?new FormData(e):e),W.getAdapter=$t.getAdapter,W.HttpStatusCode=et,W.default=W;const{Axios:ms,AxiosError:ys,CanceledError:bs,isCancel:ws,CancelToken:Ss,VERSION:js,all:vs,Cancel:ks,isAxiosError:Es,spread:Cs,toFormData:Ts,AxiosHeaders:Rs,HttpStatusCode:Is,formToJSON:Ps,getAdapter:Os,mergeConfig:_s}=W;class In{baseUrl;apiKey;appId;client;constructor(t){if(!t||!t.baseUrl)throw new Error("NeuctraAuthixClient: 'baseUrl' is required in config");this.baseUrl=t.baseUrl.replace(/\/$/,""),this.apiKey=t.apiKey||null,this.appId=t.appId||null,this.client=W.create({baseURL:this.baseUrl,headers:{"Content-Type":"application/json",...this.apiKey?{"x-api-key":this.apiKey}:{}},timeout:1e4})}async request(t,r,s,o={}){if(!t)return{success:!1,message:"HTTP method is required"};if(!r)return{success:!1,message:"Request path is required"};try{const i={...this.appId?{appId:this.appId}:{},...s||{}};return{success:!0,data:(await this.client.request({url:r,method:t,data:i,headers:o})).data,message:"Request completed successfully"}}catch(i){return console.error("[Request Error]:",i),i.isAxiosError&&!i.response?{success:!1,message:`Network error: ${i.message}`}:i.response?{success:!1,message:`Request failed: ${i.response.data?.message||i.response.statusText||"Server returned an error"}`}:{success:!1,message:`Unexpected error: ${i.message||"Something went wrong"}`}}}async signup(t){const{name:r,email:s,password:o}=t;if(!r||!s||!o)throw new Error("signup: 'name', 'email', and 'password' are required");return this.request("POST","/users/signup",t)}async login(t){const{email:r,password:s,appId:o}=t;if(!r||!s)throw new Error("login: 'email' and 'password' are required");return this.request("POST","/users/login",{email:r,password:s,appId:o||this.appId})}async updateUser(t){const{userId:r,appId:s}=t;if(!r)throw new Error("updateUser: 'userId' is required");return this.request("PUT",`/users/update/${r}`,{...t,appId:s||this.appId})}async changePassword(t){const{userId:r,currentPassword:s,newPassword:o,appId:i}=t;if(!r)throw new Error("changePassword: 'userId' is required");if(!s||!o)throw new Error("changePassword: both 'currentPassword' and 'newPassword' are required");return this.request("PUT",`/users/change-password/${r}`,{currentPassword:s,newPassword:o,appId:i||this.appId})}async deleteUser(t){const{userId:r,appId:s}=t;if(!r)throw new Error("deleteUser: 'userId' is required");return this.request("DELETE",`/users/delete/${r}`,{appId:s||this.appId})}async getProfile(t){const{token:r}=t;if(!r)throw new Error("getProfile: 'token' is required");return this.request("GET","/users/profile",{},{Authorization:`Bearer ${r}`})}async sendVerifyOTP(t){const{token:r,appId:s}=t;if(!r)throw new Error("sendVerifyOTP: 'token' is required");return this.request("POST","/users/send-verify-otp",{appId:s||this.appId},{Authorization:`Bearer ${r}`})}async verifyEmail(t){const{token:r,otp:s,appId:o}=t;if(!r)throw new Error("verifyEmail: 'token' is required");if(!s)throw new Error("verifyEmail: 'otp' is required");return this.request("POST","/users/verify-email",{otp:s,appId:o||this.appId},{Authorization:`Bearer ${r}`})}async forgotPassword(t){const{email:r,appId:s}=t;if(!r)throw new Error("forgotPassword: 'email' is required");return this.request("POST","/users/forgot-password",{email:r,appId:s||this.appId})}async resetPassword(t){const{email:r,otp:s,newPassword:o,appId:i}=t;if(!r||!s||!o)throw new Error("resetPassword: 'email', 'otp' and 'newPassword' are required");return this.request("POST","/users/reset-password",{email:r,otp:s,newPassword:o,appId:i||this.appId})}async getUserData(t){const{userId:r}=t;if(!r)throw new Error("getUserData: 'userId' is required");return this.request("GET",`/users/${r}/data`)}async getSingleUserData(t){const{userId:r,dataId:s}=t;if(!r||!s)throw new Error("getSingleUserData: 'userId' and 'dataId' are required");return this.request("GET",`/users/${r}/data/${s}`)}async addUserData(t){const{userId:r,data:s}=t;if(!r)throw new Error("addUserData: 'userId' is required");if(!s)throw new Error("addUserData: 'data' is required");return this.request("POST",`/users/${r}/data`,s)}async updateUserData(t){const{userId:r,dataId:s,data:o}=t;if(!r||!s)throw new Error("updateUserData: 'userId' and 'dataId' are required");if(!o)throw new Error("updateUserData: 'data' is required");return this.request("PUT",`/users/${r}/data/${s}`,o)}async deleteUserData(t){const{userId:r,dataId:s}=t;if(!r||!s)throw new Error("deleteUserData: 'userId' and 'dataId' are required");return this.request("DELETE",`/users/${r}/data/${s}`)}}var Be={exports:{}},Re={};/**
7
7
  * @license React
8
8
  * react-jsx-runtime.production.js
9
9
  *
@@ -120,12 +120,12 @@ export declare class NeuctraAuthix {
120
120
  */
121
121
  constructor(config: NeuctraAuthixConfig);
122
122
  /**
123
- * 🌐 Universal request helper with structured responses and error handling
124
- * @param method HTTP method (GET, POST, PUT, DELETE)
125
- * @param path API endpoint path
126
- * @param data optional request body
127
- * @param extraHeaders optional headers
128
- */
123
+ * 🌐 Universal request helper with structured responses and error handling
124
+ * @param method HTTP method (GET, POST, PUT, DELETE)
125
+ * @param path API endpoint path
126
+ * @param data optional request body
127
+ * @param extraHeaders optional headers
128
+ */
129
129
  private request;
130
130
  /**
131
131
  * Register a new user
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neuctra/authix",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "Authentication SDK and UI components library for React and Vue with TailwindCSS",
5
5
  "author": "Taha Asif",
6
6
  "license": "MIT",