@neuctra/authix 1.1.9 → 1.1.12
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.
|
@@ -1795,8 +1795,8 @@ class uo {
|
|
|
1795
1795
|
})).data;
|
|
1796
1796
|
} catch (i) {
|
|
1797
1797
|
if (console.error("❌ [Request Error]:", i), i.isAxiosError) {
|
|
1798
|
-
const a = i.response?.
|
|
1799
|
-
throw new Error(
|
|
1798
|
+
const a = i.response?.data?.message || i.message || "Unknown Axios error occurred";
|
|
1799
|
+
throw new Error(`${a}`);
|
|
1800
1800
|
}
|
|
1801
1801
|
throw new Error(`Unexpected error: ${i.message || "Unknown failure"}`);
|
|
1802
1802
|
}
|
|
@@ -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[It]=this[It]={accessors:{}}).accessors,o=this.prototype;function i(a){const l=Re(a);s[l]||(cn(o,a),s[l]=!0)}return u.isArray(t)?t.forEach(i):i(t),this}};ne.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),u.reduceDescriptors(ne.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(s){this[r]=s}}}),u.freezeMethods(ne);function Ze(e,t){const r=this||Te,s=t||r,o=ne.from(s.headers);let i=s.data;return u.forEach(e,function(l){i=l.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function Pt(e){return!!(e&&e.__CANCEL__)}function we(e,t,r){A.call(this,e??"canceled",A.ERR_CANCELED,t,r),this.name="CanceledError"}u.inherits(we,A,{__CANCEL__:!0});function Ot(e,t,r){const s=r.config.validateStatus;!r.status||!s||s(r.status)?e(r):t(new A("Request failed with status code "+r.status,[A.ERR_BAD_REQUEST,A.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function dn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function un(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 p=Date.now(),c=s[i];a||(a=p),r[o]=h,s[o]=p;let m=i,I=0;for(;m!==o;)I+=r[m++],m=m%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),p-a<t)return;const v=c&&p-c;return v?Math.round(I*1e3/v):void 0}}function pn(e,t){let r=0,s=1e3/t,o,i;const a=(p,c=Date.now())=>{r=c,o=null,i&&(clearTimeout(i),i=null),e(...p)};return[(...p)=>{const c=Date.now(),m=c-r;m>=s?a(p,c):(o=p,i||(i=setTimeout(()=>{i=null,a(o)},s-m)))},()=>o&&a(o)]}const Fe=(e,t,r=3)=>{let s=0;const o=un(50,250);return pn(i=>{const a=i.loaded,l=i.lengthComputable?i.total:void 0,h=a-s,p=o(h),c=a<=l;s=a;const m={loaded:a,total:l,progress:l?a/l:void 0,bytes:h,rate:p||void 0,estimated:p&&l&&c?(l-a)/p:void 0,event:i,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(m)},r)},_t=(e,t)=>{const r=e!=null;return[s=>t[0]({lengthComputable:r,total:e,loaded:s}),t[1]]},At=e=>(...t)=>u.asap(()=>e(...t)),fn=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,xn=ee.hasStandardBrowserEnv?{write(e,t,r,s,o,i){const a=[e+"="+encodeURIComponent(t)];u.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),u.isString(s)&&a.push("path="+s),u.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 hn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function gn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function zt(e,t,r){let s=!hn(t);return e&&(s||r==!1)?gn(e,t):t}const Nt=e=>e instanceof ne?{...e}:e;function pe(e,t){t=t||{};const r={};function s(p,c,m,I){return u.isPlainObject(p)&&u.isPlainObject(c)?u.merge.call({caseless:I},p,c):u.isPlainObject(c)?u.merge({},c):u.isArray(c)?c.slice():c}function o(p,c,m,I){if(u.isUndefined(c)){if(!u.isUndefined(p))return s(void 0,p,m,I)}else return s(p,c,m,I)}function i(p,c){if(!u.isUndefined(c))return s(void 0,c)}function a(p,c){if(u.isUndefined(c)){if(!u.isUndefined(p))return s(void 0,p)}else return s(void 0,c)}function l(p,c,m){if(m in t)return s(p,c);if(m in e)return s(void 0,p)}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:(p,c,m)=>o(Nt(p),Nt(c),m,!0)};return u.forEach(Object.keys({...e,...t}),function(c){const m=h[c]||o,I=m(e[c],t[c],c);u.isUndefined(I)&&m!==l||(r[c]=I)}),r}const Ut=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=Et(zt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&a.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),u.isFormData(r)){if(ee.hasStandardBrowserEnv||ee.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(u.isFunction(r.getHeaders)){const h=r.getHeaders(),p=["content-type","content-length"];Object.entries(h).forEach(([c,m])=>{p.includes(c.toLowerCase())&&a.set(c,m)})}}if(ee.hasStandardBrowserEnv&&(s&&u.isFunction(s)&&(s=s(t)),s||s!==!1&&fn(t.url))){const h=o&&i&&xn.read(i);h&&a.set(o,h)}return t},mn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,s){const o=Ut(e);let i=o.data;const a=ne.from(o.headers).normalize();let{responseType:l,onUploadProgress:h,onDownloadProgress:p}=o,c,m,I,v,d;function b(){v&&v(),d&&d(),o.cancelToken&&o.cancelToken.unsubscribe(c),o.signal&&o.signal.removeEventListener("abort",c)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function U(){if(!g)return;const P=ne.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),M={data:!l||l==="text"||l==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:P,config:e,request:g};Ot(function(O){r(O),b()},function(O){s(O),b()},M),g=null}"onloadend"in g?g.onloadend=U:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(U)},g.onabort=function(){g&&(s(new A("Request aborted",A.ECONNABORTED,e,g)),g=null)},g.onerror=function(C){const M=C&&C.message?C.message:"Network Error",y=new A(M,A.ERR_NETWORK,e,g);y.event=C||null,s(y),g=null},g.ontimeout=function(){let C=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const M=o.transitional||Tt;o.timeoutErrorMessage&&(C=o.timeoutErrorMessage),s(new A(C,M.clarifyTimeoutError?A.ETIMEDOUT:A.ECONNABORTED,e,g)),g=null},i===void 0&&a.setContentType(null),"setRequestHeader"in g&&u.forEach(a.toJSON(),function(C,M){g.setRequestHeader(M,C)}),u.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),l&&l!=="json"&&(g.responseType=o.responseType),p&&([I,d]=Fe(p,!0),g.addEventListener("progress",I)),h&&g.upload&&([m,v]=Fe(h),g.upload.addEventListener("progress",m),g.upload.addEventListener("loadend",v)),(o.cancelToken||o.signal)&&(c=P=>{g&&(s(!P||P.type?new we(null,e,g):P),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(c),o.signal&&(o.signal.aborted?c():o.signal.addEventListener("abort",c)));const z=dn(o.url);if(z&&ee.protocols.indexOf(z)===-1){s(new A("Unsupported protocol "+z+":",A.ERR_BAD_REQUEST,e));return}g.send(i||null)})},yn=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let s=new AbortController,o;const i=function(p){if(!o){o=!0,l();const c=p instanceof Error?p:this.reason;s.abort(c instanceof A?c:new we(c instanceof Error?c.message:c))}};let a=t&&setTimeout(()=>{a=null,i(new A(`timeout ${t} of ms exceeded`,A.ETIMEDOUT))},t);const l=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(p=>{p.unsubscribe?p.unsubscribe(i):p.removeEventListener("abort",i)}),e=null)};e.forEach(p=>p.addEventListener("abort",i));const{signal:h}=s;return h.unsubscribe=()=>u.asap(l),h}},bn=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},wn=async function*(e,t){for await(const r of Sn(e))yield*bn(r,t)},Sn=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()}},Dt=(e,t,r,s)=>{const o=wn(e,t);let i=0,a,l=h=>{a||(a=!0,s&&s(h))};return new ReadableStream({async pull(h){try{const{done:p,value:c}=await o.next();if(p){l(),h.close();return}let m=c.byteLength;if(r){let I=i+=m;r(I)}h.enqueue(new Uint8Array(c))}catch(p){throw l(p),p}},cancel(h){return l(h),o.return()}},{highWaterMark:2})},Ft=64*1024,{isFunction:Le}=u,jn=(({Request:e,Response:t})=>({Request:e,Response:t}))(u.global),{ReadableStream:Lt,TextEncoder:Mt}=u.global,Bt=(e,...t)=>{try{return!!e(...t)}catch{return!1}},vn=e=>{e=u.merge.call({skipUndefined:!0},jn,e);const{fetch:t,Request:r,Response:s}=e,o=t?Le(t):typeof fetch=="function",i=Le(r),a=Le(s);if(!o)return!1;const l=o&&Le(Lt),h=o&&(typeof Mt=="function"?(d=>b=>d.encode(b))(new Mt):async d=>new Uint8Array(await new r(d).arrayBuffer())),p=i&&l&&Bt(()=>{let d=!1;const b=new r(ee.origin,{body:new Lt,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!b}),c=a&&l&&Bt(()=>u.isReadableStream(new s("").body)),m={stream:c&&(d=>d.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!m[d]&&(m[d]=(b,g)=>{let U=b&&b[d];if(U)return U.call(b);throw new A(`Response type '${d}' is not supported`,A.ERR_NOT_SUPPORT,g)})});const I=async d=>{if(d==null)return 0;if(u.isBlob(d))return d.size;if(u.isSpecCompliantForm(d))return(await new r(ee.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(u.isArrayBufferView(d)||u.isArrayBuffer(d))return d.byteLength;if(u.isURLSearchParams(d)&&(d=d+""),u.isString(d))return(await h(d)).byteLength},v=async(d,b)=>{const g=u.toFiniteNumber(d.getContentLength());return g??I(b)};return async d=>{let{url:b,method:g,data:U,signal:z,cancelToken:P,timeout:C,onDownloadProgress:M,onUploadProgress:y,responseType:O,headers:w,withCredentials:F="same-origin",fetchOptions:K}=Ut(d),D=t||fetch;O=O?(O+"").toLowerCase():"text";let q=yn([z,P&&P.toAbortSignal()],C),Q=null;const k=q&&q.unsubscribe&&(()=>{q.unsubscribe()});let Z;try{if(y&&p&&g!=="get"&&g!=="head"&&(Z=await v(w,U))!==0){let E=new r(b,{method:"POST",body:U,duplex:"half"}),N;if(u.isFormData(U)&&(N=E.headers.get("content-type"))&&w.setContentType(N),E.body){const[W,f]=_t(Z,Fe(At(y)));U=Dt(E.body,Ft,W,f)}}u.isString(F)||(F=F?"include":"omit");const B=i&&"credentials"in r.prototype,L={...K,signal:q,method:g.toUpperCase(),headers:w.normalize().toJSON(),body:U,duplex:"half",credentials:B?F:void 0};Q=i&&new r(b,L);let R=await(i?D(Q,K):D(b,L));const Y=c&&(O==="stream"||O==="response");if(c&&(M||Y&&k)){const E={};["status","statusText","headers"].forEach(S=>{E[S]=R[S]});const N=u.toFiniteNumber(R.headers.get("content-length")),[W,f]=M&&_t(N,Fe(At(M),!0))||[];R=new s(Dt(R.body,Ft,W,()=>{f&&f(),k&&k()}),E)}O=O||"text";let x=await m[u.findKey(m,O)||"text"](R,d);return!Y&&k&&k(),await new Promise((E,N)=>{Ot(E,N,{data:x,headers:ne.from(R.headers),status:R.status,statusText:R.statusText,config:d,request:Q})})}catch(B){throw k&&k(),B&&B.name==="TypeError"&&/Load failed|fetch/i.test(B.message)?Object.assign(new A("Network Error",A.ERR_NETWORK,d,Q),{cause:B.cause||B}):A.from(B,B&&B.code,d,Q)}}},kn=new Map,Wt=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,p,c=kn;for(;l--;)h=i[l],p=c.get(h),p===void 0&&c.set(h,p=l?new Map:vn(t)),c=p;return p};Wt();const Qe={http:Vr,xhr:mn,fetch:{get:Wt}};u.forEach(Qe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const $t=e=>`- ${e}`,En=e=>u.isFunction(e)||e===null||e===!1,Ht={getAdapter:(e,t)=>{e=u.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,!En(s)&&(o=Qe[(l=String(s)).toLowerCase()],o===void 0))throw new A(`Unknown adapter '${l}'`);if(o&&(u.isFunction(o)||(o=o.get(t))))break;i[l||"#"+a]=o}if(!o){const a=Object.entries(i).map(([h,p])=>`adapter ${h} `+(p===!1?"is not supported by the environment":"is not available in the build"));let l=r?a.length>1?`since :
|
|
4
4
|
`+a.map($t).join(`
|
|
5
5
|
`):" "+$t(a[0]):"as no adapter specified";throw new A("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return o},adapters:Qe};function et(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new we(null,e)}function Vt(e){return et(e),e.headers=ne.from(e.headers),e.data=Ze.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ht.getAdapter(e.adapter||Te.adapter,e)(e).then(function(s){return et(e),s.data=Ze.call(e,e.transformResponse,s),s.headers=ne.from(s.headers),s},function(s){return Pt(s)||(et(e),s&&s.response&&(s.response.data=Ze.call(e,e.transformResponse,s.response),s.response.headers=ne.from(s.response.headers))),Promise.reject(s)})}const Yt="1.12.2",Me={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Me[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const qt={};Me.transitional=function(t,r,s){function o(i,a){return"[Axios v"+Yt+"] Transitional option '"+i+"'"+a+(s?". "+s:"")}return(i,a,l)=>{if(t===!1)throw new A(o(a," has been removed"+(r?" in "+r:"")),A.ERR_DEPRECATED);return r&&!qt[a]&&(qt[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}},Me.spelling=function(t){return(r,s)=>(console.warn(`${s} is likely a misspelling of ${t}`),!0)};function Cn(e,t,r){if(typeof e!="object")throw new A("options must be an object",A.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 A("option "+i+" must be "+h,A.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new A("Unknown option "+i,A.ERR_BAD_OPTION)}}const Be={assertOptions:Cn,validators:Me},ie=Be.validators;let fe=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ct,response:new Ct}}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&&Be.assertOptions(s,{silentJSONParsing:ie.transitional(ie.boolean),forcedJSONParsing:ie.transitional(ie.boolean),clarifyTimeoutError:ie.transitional(ie.boolean)},!1),o!=null&&(u.isFunction(o)?r.paramsSerializer={serialize:o}:Be.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),Be.assertOptions(r,{baseUrl:ie.spelling("baseURL"),withXsrfToken:ie.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let a=i&&u.merge(i.common,i[r.method]);i&&u.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 p=[];this.interceptors.response.forEach(function(b){p.push(b.fulfilled,b.rejected)});let c,m=0,I;if(!h){const d=[Vt.bind(this),void 0];for(d.unshift(...l),d.push(...p),I=d.length,c=Promise.resolve(r);m<I;)c=c.then(d[m++],d[m++]);return c}I=l.length;let v=r;for(;m<I;){const d=l[m++],b=l[m++];try{v=d(v)}catch(g){b.call(this,g);break}}try{c=Vt.call(this,v)}catch(d){return Promise.reject(d)}for(m=0,I=p.length;m<I;)c=c.then(p[m++],p[m++]);return c}getUri(t){t=pe(this.defaults,t);const r=zt(t.baseURL,t.url,t.allowAbsoluteUrls);return Et(r,t.params,t.paramsSerializer)}};u.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}))}}),u.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 Tn=class ar{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 ar(function(o){t=o}),cancel:t}}};function Rn(e){return function(r){return e.apply(null,r)}}function In(e){return u.isObject(e)&&e.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(([e,t])=>{tt[t]=e});function Kt(e){const t=new fe(e),r=dt(fe.prototype.request,t);return u.extend(r,fe.prototype,t,{allOwnKeys:!0}),u.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Kt(pe(e,o))},r}const $=Kt(Te);$.Axios=fe,$.CanceledError=we,$.CancelToken=Tn,$.isCancel=Pt,$.VERSION=Yt,$.toFormData=Ue,$.AxiosError=A,$.Cancel=$.CanceledError,$.all=function(t){return Promise.all(t)},$.spread=Rn,$.isAxiosError=In,$.mergeConfig=pe,$.AxiosHeaders=ne,$.formToJSON=e=>Rt(u.isHTMLForm(e)?new FormData(e):e),$.getAdapter=Ht.getAdapter,$.HttpStatusCode=tt,$.default=$;const{Axios:ys,AxiosError:bs,CanceledError:ws,isCancel:Ss,CancelToken:js,VERSION:vs,all:ks,Cancel:Es,isAxiosError:Cs,spread:Ts,toFormData:Rs,AxiosHeaders:Is,HttpStatusCode:Ps,formToJSON:Os,getAdapter:_s,mergeConfig:As}=$;class Pn{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=$.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)throw new Error("HTTP method is required");if(!r)throw new Error("Request path is required");try{const i={...this.appId?{appId:this.appId}:{},...s||{}};return(await this.client.request({url:r,method:t,data:i,headers:o})).data}catch(i){if(console.error("❌ [Request Error]:",i),i.isAxiosError){const a=i.response?.
|
|
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&&Be.assertOptions(s,{silentJSONParsing:ie.transitional(ie.boolean),forcedJSONParsing:ie.transitional(ie.boolean),clarifyTimeoutError:ie.transitional(ie.boolean)},!1),o!=null&&(u.isFunction(o)?r.paramsSerializer={serialize:o}:Be.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),Be.assertOptions(r,{baseUrl:ie.spelling("baseURL"),withXsrfToken:ie.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let a=i&&u.merge(i.common,i[r.method]);i&&u.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 p=[];this.interceptors.response.forEach(function(b){p.push(b.fulfilled,b.rejected)});let c,m=0,I;if(!h){const d=[Vt.bind(this),void 0];for(d.unshift(...l),d.push(...p),I=d.length,c=Promise.resolve(r);m<I;)c=c.then(d[m++],d[m++]);return c}I=l.length;let v=r;for(;m<I;){const d=l[m++],b=l[m++];try{v=d(v)}catch(g){b.call(this,g);break}}try{c=Vt.call(this,v)}catch(d){return Promise.reject(d)}for(m=0,I=p.length;m<I;)c=c.then(p[m++],p[m++]);return c}getUri(t){t=pe(this.defaults,t);const r=zt(t.baseURL,t.url,t.allowAbsoluteUrls);return Et(r,t.params,t.paramsSerializer)}};u.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}))}}),u.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 Tn=class ar{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 ar(function(o){t=o}),cancel:t}}};function Rn(e){return function(r){return e.apply(null,r)}}function In(e){return u.isObject(e)&&e.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(([e,t])=>{tt[t]=e});function Kt(e){const t=new fe(e),r=dt(fe.prototype.request,t);return u.extend(r,fe.prototype,t,{allOwnKeys:!0}),u.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return Kt(pe(e,o))},r}const $=Kt(Te);$.Axios=fe,$.CanceledError=we,$.CancelToken=Tn,$.isCancel=Pt,$.VERSION=Yt,$.toFormData=Ue,$.AxiosError=A,$.Cancel=$.CanceledError,$.all=function(t){return Promise.all(t)},$.spread=Rn,$.isAxiosError=In,$.mergeConfig=pe,$.AxiosHeaders=ne,$.formToJSON=e=>Rt(u.isHTMLForm(e)?new FormData(e):e),$.getAdapter=Ht.getAdapter,$.HttpStatusCode=tt,$.default=$;const{Axios:ys,AxiosError:bs,CanceledError:ws,isCancel:Ss,CancelToken:js,VERSION:vs,all:ks,Cancel:Es,isAxiosError:Cs,spread:Ts,toFormData:Rs,AxiosHeaders:Is,HttpStatusCode:Ps,formToJSON:Os,getAdapter:_s,mergeConfig:As}=$;class Pn{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=$.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)throw new Error("HTTP method is required");if(!r)throw new Error("Request path is required");try{const i={...this.appId?{appId:this.appId}:{},...s||{}};return(await this.client.request({url:r,method:t,data:i,headers:o})).data}catch(i){if(console.error("❌ [Request Error]:",i),i.isAxiosError){const a=i.response?.data?.message||i.message||"Unknown Axios error occurred";throw new Error(`${a}`)}throw new Error(`Unexpected error: ${i.message||"Unknown failure"}`)}}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 We={exports:{}},Ie={};/**
|
|
7
7
|
* @license React
|
|
8
8
|
* react-jsx-runtime.production.js
|
|
9
9
|
*
|
package/dist/src/index.d.ts
CHANGED
|
@@ -5,5 +5,10 @@ interface ReactSignedInProps {
|
|
|
5
5
|
width?: string;
|
|
6
6
|
height?: string;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* ReactSignedIn
|
|
10
|
+
* Renders children only when the user is signed in.
|
|
11
|
+
* Provides optional width/height props for consistent alignment in layouts.
|
|
12
|
+
*/
|
|
8
13
|
export declare const ReactSignedIn: React.FC<ReactSignedInProps>;
|
|
9
14
|
export {};
|
|
@@ -8,7 +8,7 @@ interface ReactSignedOutProps {
|
|
|
8
8
|
/**
|
|
9
9
|
* ReactSignedOut
|
|
10
10
|
* Renders its children only when the user is NOT signed in.
|
|
11
|
-
*
|
|
11
|
+
* Uses inline-flex for consistent alignment within navbars or flex layouts.
|
|
12
12
|
*/
|
|
13
13
|
export declare const ReactSignedOut: React.FC<ReactSignedOutProps>;
|
|
14
14
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neuctra/authix",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.1.12",
|
|
4
|
+
"description": "Authentication SDK and UI components library for React and Vue with TailwindCSS",
|
|
5
5
|
"author": "Taha Asif",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"main": "
|
|
9
|
-
"module": "
|
|
10
|
-
"types": "
|
|
8
|
+
"main": "dist/neuctra-authix.cjs.js",
|
|
9
|
+
"module": "dist/neuctra-authix.es.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"require": "./dist/index.cjs.js"
|
|
13
|
+
"import": "./dist/neuctra-authix.es.js",
|
|
14
|
+
"require": "./dist/neuctra-authix.cjs.js"
|
|
16
15
|
},
|
|
17
16
|
"./react": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
17
|
+
"import": "./dist/react/index.js",
|
|
18
|
+
"types": "./dist/react/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./vue": {
|
|
21
|
+
"import": "./dist/vue/index.js",
|
|
22
|
+
"types": "./dist/vue/index.d.ts"
|
|
21
23
|
},
|
|
22
24
|
"./sdk": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"require": "./dist/sdk/index.cjs.js"
|
|
25
|
+
"import": "./dist/sdk/index.js",
|
|
26
|
+
"types": "./dist/sdk/index.d.ts"
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
"files": [
|
|
@@ -30,40 +31,42 @@
|
|
|
30
31
|
],
|
|
31
32
|
"scripts": {
|
|
32
33
|
"dev": "vite",
|
|
33
|
-
"build": "
|
|
34
|
-
"clean": "rimraf dist",
|
|
34
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
|
35
35
|
"preview": "vite preview",
|
|
36
|
+
"clean": "rm -rf dist",
|
|
36
37
|
"release": "npm publish --access public"
|
|
37
38
|
},
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"react
|
|
41
|
-
|
|
39
|
+
"keywords": [
|
|
40
|
+
"ui-components",
|
|
41
|
+
"react",
|
|
42
|
+
"vue",
|
|
43
|
+
"tailwind",
|
|
44
|
+
"vite",
|
|
45
|
+
"library",
|
|
46
|
+
"authentication",
|
|
47
|
+
"sdk",
|
|
48
|
+
"jwt",
|
|
49
|
+
"otp"
|
|
50
|
+
],
|
|
42
51
|
"devDependencies": {
|
|
43
52
|
"@tailwindcss/vite": "^4.1.13",
|
|
44
|
-
"@types/node": "^20.
|
|
53
|
+
"@types/node": "^20.0.0",
|
|
45
54
|
"@types/react": "^18.2.48",
|
|
46
55
|
"@types/react-dom": "^18.2.18",
|
|
47
56
|
"@vitejs/plugin-react": "^5.0.3",
|
|
57
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
48
58
|
"autoprefixer": "^10.4.21",
|
|
49
59
|
"axios": "^1.12.2",
|
|
50
60
|
"lucide-react": "^0.544.0",
|
|
61
|
+
"lucide-vue-next": "^0.544.0",
|
|
51
62
|
"postcss": "^8.5.6",
|
|
52
63
|
"tailwindcss": "^4.1.13",
|
|
53
|
-
"typescript": "^5.
|
|
54
|
-
"vite": "^7.1.7"
|
|
55
|
-
"rimraf": "^5.0.5"
|
|
64
|
+
"typescript": "^5.9.2",
|
|
65
|
+
"vite": "^7.1.7"
|
|
56
66
|
},
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"react",
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
"library",
|
|
63
|
-
"auth",
|
|
64
|
-
"authentication",
|
|
65
|
-
"jwt",
|
|
66
|
-
"otp",
|
|
67
|
-
"sdk"
|
|
68
|
-
]
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"react": ">=16",
|
|
69
|
+
"react-dom": ">=16",
|
|
70
|
+
"vue": ">=3"
|
|
71
|
+
}
|
|
69
72
|
}
|