authifyer-sdk 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authifyer-sdk.es.js +538 -476
- package/dist/authifyer-sdk.umd.js +9 -9
- package/package.json +1 -1
- package/src/core/client.ts +27 -3
- package/src/react/components/SignUp.tsx +68 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(C,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],R):(C=typeof globalThis<"u"?globalThis:C||self,R(C.AuthifyerSDK={},C.React))})(this,(function(C,R){"use strict";var Tn=Object.defineProperty;var An=(C,R,V)=>R in C?Tn(C,R,{enumerable:!0,configurable:!0,writable:!0,value:V}):C[R]=V;var Z=(C,R,V)=>An(C,typeof R!="symbol"?R+"":R,V);var V={exports:{}},oe={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var $e;function Bt(){if($e)return oe;$e=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function r(n,s,o){var i=null;if(o!==void 0&&(i=""+o),s.key!==void 0&&(i=""+s.key),"key"in s){o={};for(var c in s)c!=="key"&&(o[c]=s[c])}else o=s;return s=o.ref,{$$typeof:t,type:n,key:i,ref:s!==void 0?s:null,props:o}}return oe.Fragment=e,oe.jsx=r,oe.jsxs=r,oe}var ie={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var Xe;function Dt(){return Xe||(Xe=1,process.env.NODE_ENV!=="production"&&(function(){function t(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===Ne?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case h:return"Fragment";case v:return"Profiler";case T:return"StrictMode";case q:return"Suspense";case U:return"SuspenseList";case _e:return"Activity"}if(typeof l=="object")switch(typeof l.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),l.$$typeof){case b:return"Portal";case j:return l.displayName||"Context";case O:return(l._context.displayName||"Context")+".Consumer";case N:var E=l.render;return l=l.displayName,l||(l=E.displayName||E.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case I:return E=l.displayName||null,E!==null?E:t(l.type)||"Memo";case F:E=l._payload,l=l._init;try{return t(l(E))}catch{}}return null}function e(l){return""+l}function r(l){try{e(l);var E=!1}catch{E=!0}if(E){E=console;var A=E.error,x=typeof Symbol=="function"&&Symbol.toStringTag&&l[Symbol.toStringTag]||l.constructor.name||"Object";return A.call(E,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",x),e(l)}}function n(l){if(l===h)return"<>";if(typeof l=="object"&&l!==null&&l.$$typeof===F)return"<...>";try{var E=t(l);return E?"<"+E+">":"<...>"}catch{return"<...>"}}function s(){var l=K.A;return l===null?null:l.getOwner()}function o(){return Error("react-stack-top-frame")}function i(l){if(Y.call(l,"key")){var E=Object.getOwnPropertyDescriptor(l,"key").get;if(E&&E.isReactWarning)return!1}return l.key!==void 0}function c(l,E){function A(){k||(k=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",E))}A.isReactWarning=!0,Object.defineProperty(l,"key",{get:A,configurable:!0})}function p(){var l=t(this.type);return pe[l]||(pe[l]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),l=this.props.ref,l!==void 0?l:null}function d(l,E,A,x,Q,Ke){var P=A.ref;return l={$$typeof:f,type:l,key:E,props:A,_owner:x},(P!==void 0?P:null)!==null?Object.defineProperty(l,"ref",{enumerable:!1,get:p}):Object.defineProperty(l,"ref",{enumerable:!1,value:null}),l._store={},Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(l,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(l,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.defineProperty(l,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ke}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}function u(l,E,A,x,Q,Ke){var P=E.children;if(P!==void 0)if(x)if(J(P)){for(x=0;x<P.length;x++)y(P[x]);Object.freeze&&Object.freeze(P)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(P);if(Y.call(E,"key")){P=t(l);var se=Object.keys(E).filter(function(Sn){return Sn!=="key"});x=0<se.length?"{key: someKey, "+se.join(": ..., ")+": ...}":"{key: someKey}",Ce[P+x]||(se=0<se.length?"{"+se.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,_,C,ne,C),Ne[C+_]=!0)}if(C=null,A!==void 0&&(r(A),C=""+A),i(E)&&(r(E.key),C=""+E.key),"key"in E){A={};for(var $e in E)$e!=="key"&&(A[$e]=E[$e])}else A=E;return C&&c(A,typeof l=="function"?l.displayName||l.name||"Unknown":l),d(l,C,A,s(),G,Ve)}function m(l){w(l)?l._store&&(l._store.validated=1):typeof l=="object"&&l!==null&&l.$$typeof===J&&(l._payload.status==="fulfilled"?w(l._payload.value)&&l._payload.value._store&&(l._payload.value._store.validated=1):l._store&&(l._store.validated=1))}function w(l){return typeof l=="object"&&l!==null&&l.$$typeof===f}var R=S,f=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),U=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),v=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),he=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),Oe=Symbol.for("react.activity"),xe=Symbol.for("react.client.reference"),V=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,W=Array.isArray,re=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(l){return l()}};var P,pe={},M=R.react_stack_bottom_frame.bind(R,o)(),me=re(n(o)),Ne={};oe.Fragment=h,oe.jsx=function(l,E,A){var _=1e4>V.recentlyCreatedOwnerStacks++;return u(l,E,A,!1,_?Error("react-stack-top-frame"):M,_?re(n(l)):me)},oe.jsxs=function(l,E,A){var _=1e4>V.recentlyCreatedOwnerStacks++;return u(l,E,A,!0,_?Error("react-stack-top-frame"):M,_?re(n(l)):me)}})()),oe}var Xe;function Mt(){return Xe||(Xe=1,process.env.NODE_ENV==="production"?q.exports=Bt():q.exports=Dt()),q.exports}var y=Mt();function Ge(t,e){return function(){return t.apply(e,arguments)}}const{toString:Ht}=Object.prototype,{getPrototypeOf:Ce}=Object,{iterator:ye,toStringTag:Qe}=Symbol,be=(t=>e=>{const r=Ht.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),D=t=>(t=t.toLowerCase(),e=>be(e)===t),ge=t=>e=>typeof e===t,{isArray:Z}=Array,ee=ge("undefined");function ie(t){return t!==null&&!ee(t)&&t.constructor!==null&&!ee(t.constructor)&&k(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Ze=D("ArrayBuffer");function qt(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Ze(t.buffer),e}const zt=ge("string"),k=ge("function"),et=ge("number"),ae=t=>t!==null&&typeof t=="object",Wt=t=>t===!0||t===!1,Ee=t=>{if(be(t)!=="object")return!1;const e=Ce(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Qe in t)&&!(ye in t)},Jt=t=>{if(!ae(t)||ie(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Vt=D("Date"),$t=D("File"),Kt=D("Blob"),Yt=D("FileList"),Xt=t=>ae(t)&&k(t.pipe),Gt=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||k(t.append)&&((e=be(t))==="formdata"||e==="object"&&k(t.toString)&&t.toString()==="[object FormData]"))},Qt=D("URLSearchParams"),[Zt,er,tr,rr]=["ReadableStream","Request","Response","Headers"].map(D),nr=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ce(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,s;if(typeof t!="object"&&(t=[t]),Z(t))for(n=0,s=t.length;n<s;n++)e.call(null,t[n],n,t);else{if(ie(t))return;const o=r?Object.getOwnPropertyNames(t):Object.keys(t),i=o.length;let c;for(n=0;n<i;n++)c=o[n],e.call(null,t[c],c,t)}}function tt(t,e){if(ie(t))return null;e=e.toLowerCase();const r=Object.keys(t);let n=r.length,s;for(;n-- >0;)if(s=r[n],e===s.toLowerCase())return s;return null}const K=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,rt=t=>!ee(t)&&t!==K;function Pe(){const{caseless:t,skipUndefined:e}=rt(this)&&this||{},r={},n=(s,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const i=t&&tt(r,o)||o;Ee(r[i])&&Ee(s)?r[i]=Pe(r[i],s):Ee(s)?r[i]=Pe({},s):Z(s)?r[i]=s.slice():(!e||!ee(s))&&(r[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&ce(arguments[s],n);return r}const sr=(t,e,r,{allOwnKeys:n}={})=>(ce(e,(s,o)=>{r&&k(s)?Object.defineProperty(t,o,{value:Ge(s,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),t),or=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),ir=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},ar=(t,e,r,n)=>{let s,o,i;const c={};if(e=e||{},t==null)return e;do{for(s=Object.getOwnPropertyNames(t),o=s.length;o-- >0;)i=s[o],(!n||n(i,t,e))&&!c[i]&&(e[i]=t[i],c[i]=!0);t=r!==!1&&Ce(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},cr=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return n!==-1&&n===r},lr=t=>{if(!t)return null;if(Z(t))return t;let e=t.length;if(!et(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},ur=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&Ce(Uint8Array)),fr=(t,e)=>{const n=(t&&t[ye]).call(t);let s;for(;(s=n.next())&&!s.done;){const o=s.value;e.call(t,o[0],o[1])}},dr=(t,e)=>{let r;const n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},hr=D("HTMLFormElement"),pr=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,s){return n.toUpperCase()+s}),nt=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),mr=D("RegExp"),st=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};ce(r,(s,o)=>{let i;(i=e(s,o,t))!==!1&&(n[o]=i||s)}),Object.defineProperties(t,n)},yr=t=>{st(t,(e,r)=>{if(k(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=t[r];if(k(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},br=(t,e)=>{const r={},n=s=>{s.forEach(o=>{r[o]=!0})};return Z(t)?n(t):n(String(t).split(e)),r},gr=()=>{},Er=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function wr(t){return!!(t&&k(t.append)&&t[Qe]==="FormData"&&t[ye])}const Rr=t=>{const e=new Array(10),r=(n,s)=>{if(ae(n)){if(e.indexOf(n)>=0)return;if(ie(n))return n;if(!("toJSON"in n)){e[s]=n;const o=Z(n)?[]:{};return ce(n,(i,c)=>{const p=r(i,s+1);!ee(p)&&(o[c]=p)}),e[s]=void 0,o}}return n};return r(t,0)},Sr=D("AsyncFunction"),Tr=t=>t&&(ae(t)||k(t))&&k(t.then)&&k(t.catch),ot=((t,e)=>t?setImmediate:e?((r,n)=>(K.addEventListener("message",({source:s,data:o})=>{s===K&&o===r&&n.length&&n.shift()()},!1),s=>{n.push(s),K.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",k(K.postMessage)),Ar=typeof queueMicrotask<"u"?queueMicrotask.bind(K):typeof process<"u"&&process.nextTick||ot,a={isArray:Z,isArrayBuffer:Ze,isBuffer:ie,isFormData:Gt,isArrayBufferView:qt,isString:zt,isNumber:et,isBoolean:Wt,isObject:ae,isPlainObject:Ee,isEmptyObject:Jt,isReadableStream:Zt,isRequest:er,isResponse:tr,isHeaders:rr,isUndefined:ee,isDate:Vt,isFile:$t,isBlob:Kt,isRegExp:mr,isFunction:k,isStream:Xt,isURLSearchParams:Qt,isTypedArray:ur,isFileList:Yt,forEach:ce,merge:Pe,extend:sr,trim:nr,stripBOM:or,inherits:ir,toFlatObject:ar,kindOf:be,kindOfTest:D,endsWith:cr,toArray:lr,forEachEntry:fr,matchAll:dr,isHTMLForm:hr,hasOwnProperty:nt,hasOwnProp:nt,reduceDescriptors:st,freezeMethods:yr,toObjectSet:br,toCamelCase:pr,noop:gr,toFiniteNumber:Er,findKey:tt,global:K,isContextDefined:rt,isSpecCompliantForm:wr,toJSONObject:Rr,isAsyncFn:Sr,isThenable:Tr,setImmediate:ot,asap:Ar,isIterable:t=>t!=null&&k(t[ye])};let g=class It extends Error{static from(e,r,n,s,o,i){const c=new It(e.message,r||e.code,n,s,o);return c.cause=e,c.name=e.name,i&&Object.assign(c,i),c}constructor(e,r,n,s,o){super(e),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),s&&(this.request=s),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}};g.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",g.ERR_BAD_OPTION="ERR_BAD_OPTION",g.ECONNABORTED="ECONNABORTED",g.ETIMEDOUT="ETIMEDOUT",g.ERR_NETWORK="ERR_NETWORK",g.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",g.ERR_DEPRECATED="ERR_DEPRECATED",g.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",g.ERR_BAD_REQUEST="ERR_BAD_REQUEST",g.ERR_CANCELED="ERR_CANCELED",g.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",g.ERR_INVALID_URL="ERR_INVALID_URL";const _r=null;function je(t){return a.isPlainObject(t)||a.isArray(t)}function it(t){return a.endsWith(t,"[]")?t.slice(0,-2):t}function at(t,e,r){return t?t.concat(e).map(function(s,o){return s=it(s),!r&&o?"["+s+"]":s}).join(r?".":""):e}function Or(t){return a.isArray(t)&&!t.some(je)}const xr=a.toFlatObject(a,{},null,function(e){return/^is[A-Z]/.test(e)});function we(t,e,r){if(!a.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(b,h){return!a.isUndefined(h[b])});const n=r.metaTokens,s=r.visitor||u,o=r.dots,i=r.indexes,p=(r.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(e);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function d(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!p&&a.isBlob(f))throw new g("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?p&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function u(f,b,h){let T=f;if(f&&!h&&typeof f=="object"){if(a.endsWith(b,"{}"))b=n?b:b.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Or(f)||(a.isFileList(f)||a.endsWith(b,"[]"))&&(T=a.toArray(f)))return b=it(b),T.forEach(function(x,v){!(a.isUndefined(x)||x===null)&&e.append(i===!0?at([b],v,o):i===null?b:b+"[]",d(x))}),!1}return je(f)?!0:(e.append(at(h,b,o),d(f)),!1)}const m=[],w=Object.assign(xr,{defaultVisitor:u,convertValue:d,isVisitable:je});function R(f,b){if(!a.isUndefined(f)){if(m.indexOf(f)!==-1)throw Error("Circular reference detected in "+b.join("."));m.push(f),a.forEach(f,function(T,U){(!(a.isUndefined(T)||T===null)&&s.call(e,T,a.isString(U)?U.trim():U,b,w))===!0&&R(T,b?b.concat(U):[U])}),m.pop()}}if(!a.isObject(t))throw new TypeError("data must be an object");return R(t),e}function ct(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function ve(t,e){this._pairs=[],t&&we(t,this,e)}const lt=ve.prototype;lt.append=function(e,r){this._pairs.push([e,r])},lt.toString=function(e){const r=e?function(n){return e.call(this,n,ct)}:ct;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function Nr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ut(t,e,r){if(!e)return t;const n=r&&r.encode||Nr,s=a.isFunction(r)?{serialize:r}:r,o=s&&s.serialize;let i;if(o?i=o(e,s):i=a.isURLSearchParams(e)?e.toString():new ve(e,s).toString(n),i){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+i}return t}class ft{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){a.forEach(this.handlers,function(n){n!==null&&e(n)})}}const ke={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Cr={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ve,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Le=typeof window<"u"&&typeof document<"u",Ue=typeof navigator=="object"&&navigator||void 0,Pr=Le&&(!Ue||["ReactNative","NativeScript","NS"].indexOf(Ue.product)<0),jr=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",vr=Le&&window.location.href||"http://localhost",j={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Le,hasStandardBrowserEnv:Pr,hasStandardBrowserWebWorkerEnv:jr,navigator:Ue,origin:vr},Symbol.toStringTag,{value:"Module"})),...Cr};function kr(t,e){return we(t,new j.classes.URLSearchParams,{visitor:function(r,n,s,o){return j.isNode&&a.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}function Lr(t){return a.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Ur(t){const e={},r=Object.keys(t);let n;const s=r.length;let o;for(n=0;n<s;n++)o=r[n],e[o]=t[o];return e}function dt(t){function e(r,n,s,o){let i=r[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),p=o>=r.length;return i=!i&&a.isArray(s)?s.length:i,p?(a.hasOwnProp(s,i)?s[i]=[s[i],n]:s[i]=n,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),e(r,n,s[i],o)&&a.isArray(s[i])&&(s[i]=Ur(s[i])),!c)}if(a.isFormData(t)&&a.isFunction(t.entries)){const r={};return a.forEachEntry(t,(n,s)=>{e(Lr(n),s,r,0)}),r}return null}function Ir(t,e,r){if(a.isString(t))try{return(e||JSON.parse)(t),a.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}const le={transitional:ke,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){const n=r.getContentType()||"",s=n.indexOf("application/json")>-1,o=a.isObject(e);if(o&&a.isHTMLForm(e)&&(e=new FormData(e)),a.isFormData(e))return s?JSON.stringify(dt(e)):e;if(a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)||a.isReadableStream(e))return e;if(a.isArrayBufferView(e))return e.buffer;if(a.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let c;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return kr(e,this.formSerializer).toString();if((c=a.isFileList(e))||n.indexOf("multipart/form-data")>-1){const p=this.env&&this.env.FormData;return we(c?{"files[]":e}:e,p&&new p,this.formSerializer)}}return o||s?(r.setContentType("application/json",!1),Ir(e)):e}],transformResponse:[function(e){const r=this.transitional||le.transitional,n=r&&r.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(e)||a.isReadableStream(e))return e;if(e&&a.isString(e)&&(n&&!this.responseType||s)){const i=!(r&&r.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?g.from(c,g.ERR_BAD_RESPONSE,this,null,this.response):c}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:j.classes.FormData,Blob:j.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],t=>{le.headers[t]={}});const Fr=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Br=t=>{const e={};let r,n,s;return t&&t.split(`
|
|
23
|
-
`).forEach(function(i){s=i.indexOf(":"),r=i.substring(0,s).trim().toLowerCase(),n=i.substring(s+1).trim(),!(!r||e[r]&&Fr[r])&&(r==="set-cookie"?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)}),e},
|
|
24
|
-
`)}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 n=new this(e);return r.forEach(s=>n.set(s)),n}static accessor(e){const n=(this[ht]=this[ht]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=ue(i);n[c]||(qr(s,i),n[c]=!0)}return a.isArray(e)?e.forEach(o):o(e),this}};L.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(L.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}}),a.freezeMethods(L);function Fe(t,e){const r=this||le,n=e||r,s=L.from(n.headers);let o=n.data;return a.forEach(t,function(c){o=c.call(r,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function pt(t){return!!(t&&t.__CANCEL__)}let fe=class extends g{constructor(e,r,n){super(e??"canceled",g.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function mt(t,e,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new g("Request failed with status code "+r.status,[g.ERR_BAD_REQUEST,g.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function zr(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Wr(t,e){t=t||10;const r=new Array(t),n=new Array(t);let s=0,o=0,i;return e=e!==void 0?e:1e3,function(p){const d=Date.now(),u=n[o];i||(i=d),r[s]=p,n[s]=d;let m=o,w=0;for(;m!==s;)w+=r[m++],m=m%t;if(s=(s+1)%t,s===o&&(o=(o+1)%t),d-i<e)return;const R=u&&d-u;return R?Math.round(w*1e3/R):void 0}}function Jr(t,e){let r=0,n=1e3/e,s,o;const i=(d,u=Date.now())=>{r=u,s=null,o&&(clearTimeout(o),o=null),t(...d)};return[(...d)=>{const u=Date.now(),m=u-r;m>=n?i(d,u):(s=d,o||(o=setTimeout(()=>{o=null,i(s)},n-m)))},()=>s&&i(s)]}const Se=(t,e,r=3)=>{let n=0;const s=Wr(50,250);return Jr(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,p=i-n,d=s(p),u=i<=c;n=i;const m={loaded:i,total:c,progress:c?i/c:void 0,bytes:p,rate:d||void 0,estimated:d&&c&&u?(c-i)/d:void 0,event:o,lengthComputable:c!=null,[e?"download":"upload"]:!0};t(m)},r)},yt=(t,e)=>{const r=t!=null;return[n=>e[0]({lengthComputable:r,total:t,loaded:n}),e[1]]},bt=t=>(...e)=>a.asap(()=>t(...e)),Vr=j.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,j.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(j.origin),j.navigator&&/(msie|trident)/i.test(j.navigator.userAgent)):()=>!0,$r=j.hasStandardBrowserEnv?{write(t,e,r,n,s,o,i){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(e)}`];a.isNumber(r)&&c.push(`expires=${new Date(r).toUTCString()}`),a.isString(n)&&c.push(`path=${n}`),a.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),a.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Kr(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Yr(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function gt(t,e,r){let n=!Kr(e);return t&&(n||r==!1)?Yr(t,e):e}const Et=t=>t instanceof L?{...t}:t;function Y(t,e){e=e||{};const r={};function n(d,u,m,w){return a.isPlainObject(d)&&a.isPlainObject(u)?a.merge.call({caseless:w},d,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function s(d,u,m,w){if(a.isUndefined(u)){if(!a.isUndefined(d))return n(void 0,d,m,w)}else return n(d,u,m,w)}function o(d,u){if(!a.isUndefined(u))return n(void 0,u)}function i(d,u){if(a.isUndefined(u)){if(!a.isUndefined(d))return n(void 0,d)}else return n(void 0,u)}function c(d,u,m){if(m in e)return n(d,u);if(m in t)return n(void 0,d)}const p={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(d,u,m)=>s(Et(d),Et(u),m,!0)};return a.forEach(Object.keys({...t,...e}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const m=a.hasOwnProp(p,u)?p[u]:s,w=m(t[u],e[u],u);a.isUndefined(w)&&m!==c||(r[u]=w)}),r}const wt=t=>{const e=Y({},t);let{data:r,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=e;if(e.headers=i=L.from(i),e.url=ut(gt(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),a.isFormData(r)){if(j.hasStandardBrowserEnv||j.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(r.getHeaders)){const p=r.getHeaders(),d=["content-type","content-length"];Object.entries(p).forEach(([u,m])=>{d.includes(u.toLowerCase())&&i.set(u,m)})}}if(j.hasStandardBrowserEnv&&(n&&a.isFunction(n)&&(n=n(e)),n||n!==!1&&Vr(e.url))){const p=s&&o&&$r.read(o);p&&i.set(s,p)}return e},Xr=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,n){const s=wt(t);let o=s.data;const i=L.from(s.headers).normalize();let{responseType:c,onUploadProgress:p,onDownloadProgress:d}=s,u,m,w,R,f;function b(){R&&R(),f&&f(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function T(){if(!h)return;const x=L.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),F={data:!c||c==="text"||c==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:x,config:t,request:h};mt(function(I){r(I),b()},function(I){n(I),b()},F),h=null}"onloadend"in h?h.onloadend=T:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(T)},h.onabort=function(){h&&(n(new g("Request aborted",g.ECONNABORTED,t,h)),h=null)},h.onerror=function(v){const F=v&&v.message?v.message:"Network Error",z=new g(F,g.ERR_NETWORK,t,h);z.event=v||null,n(z),h=null},h.ontimeout=function(){let v=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const F=s.transitional||ke;s.timeoutErrorMessage&&(v=s.timeoutErrorMessage),n(new g(v,F.clarifyTimeoutError?g.ETIMEDOUT:g.ECONNABORTED,t,h)),h=null},o===void 0&&i.setContentType(null),"setRequestHeader"in h&&a.forEach(i.toJSON(),function(v,F){h.setRequestHeader(F,v)}),a.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),c&&c!=="json"&&(h.responseType=s.responseType),d&&([w,f]=Se(d,!0),h.addEventListener("progress",w)),p&&h.upload&&([m,R]=Se(p),h.upload.addEventListener("progress",m),h.upload.addEventListener("loadend",R)),(s.cancelToken||s.signal)&&(u=x=>{h&&(n(!x||x.type?new fe(null,t,h):x),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const U=zr(s.url);if(U&&j.protocols.indexOf(U)===-1){n(new g("Unsupported protocol "+U+":",g.ERR_BAD_REQUEST,t));return}h.send(o||null)})},Gr=(t,e)=>{const{length:r}=t=t?t.filter(Boolean):[];if(e||r){let n=new AbortController,s;const o=function(d){if(!s){s=!0,c();const u=d instanceof Error?d:this.reason;n.abort(u instanceof g?u:new fe(u instanceof Error?u.message:u))}};let i=e&&setTimeout(()=>{i=null,o(new g(`timeout of ${e}ms exceeded`,g.ETIMEDOUT))},e);const c=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(d=>{d.unsubscribe?d.unsubscribe(o):d.removeEventListener("abort",o)}),t=null)};t.forEach(d=>d.addEventListener("abort",o));const{signal:p}=n;return p.unsubscribe=()=>a.asap(c),p}},Qr=function*(t,e){let r=t.byteLength;if(r<e){yield t;return}let n=0,s;for(;n<r;)s=n+e,yield t.slice(n,s),n=s},Zr=async function*(t,e){for await(const r of en(t))yield*Qr(r,e)},en=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:r,value:n}=await e.read();if(r)break;yield n}}finally{await e.cancel()}},Rt=(t,e,r,n)=>{const s=Zr(t,e);let o=0,i,c=p=>{i||(i=!0,n&&n(p))};return new ReadableStream({async pull(p){try{const{done:d,value:u}=await s.next();if(d){c(),p.close();return}let m=u.byteLength;if(r){let w=o+=m;r(w)}p.enqueue(new Uint8Array(u))}catch(d){throw c(d),d}},cancel(p){return c(p),s.return()}},{highWaterMark:2})},St=64*1024,{isFunction:Te}=a,tn=(({Request:t,Response:e})=>({Request:t,Response:e}))(a.global),{ReadableStream:Tt,TextEncoder:At}=a.global,_t=(t,...e)=>{try{return!!t(...e)}catch{return!1}},rn=t=>{t=a.merge.call({skipUndefined:!0},tn,t);const{fetch:e,Request:r,Response:n}=t,s=e?Te(e):typeof fetch=="function",o=Te(r),i=Te(n);if(!s)return!1;const c=s&&Te(Tt),p=s&&(typeof At=="function"?(f=>b=>f.encode(b))(new At):async f=>new Uint8Array(await new r(f).arrayBuffer())),d=o&&c&&_t(()=>{let f=!1;const b=new r(j.origin,{body:new Tt,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!b}),u=i&&c&&_t(()=>a.isReadableStream(new n("").body)),m={stream:u&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!m[f]&&(m[f]=(b,h)=>{let T=b&&b[f];if(T)return T.call(b);throw new g(`Response type '${f}' is not supported`,g.ERR_NOT_SUPPORT,h)})});const w=async f=>{if(f==null)return 0;if(a.isBlob(f))return f.size;if(a.isSpecCompliantForm(f))return(await new r(j.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(a.isArrayBufferView(f)||a.isArrayBuffer(f))return f.byteLength;if(a.isURLSearchParams(f)&&(f=f+""),a.isString(f))return(await p(f)).byteLength},R=async(f,b)=>{const h=a.toFiniteNumber(f.getContentLength());return h??w(b)};return async f=>{let{url:b,method:h,data:T,signal:U,cancelToken:x,timeout:v,onDownloadProgress:F,onUploadProgress:z,responseType:I,headers:he,withCredentials:J="same-origin",fetchOptions:Oe}=wt(f),xe=e||fetch;I=I?(I+"").toLowerCase():"text";let V=Gr([U,x&&x.toAbortSignal()],v),$=null;const W=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let re;try{if(z&&d&&h!=="get"&&h!=="head"&&(re=await R(he,T))!==0){let l=new r(b,{method:"POST",body:T,duplex:"half"}),E;if(a.isFormData(T)&&(E=l.headers.get("content-type"))&&he.setContentType(E),l.body){const[A,_]=yt(re,Se(bt(z)));T=Rt(l.body,St,A,_)}}a.isString(J)||(J=J?"include":"omit");const P=o&&"credentials"in r.prototype,pe={...Oe,signal:V,method:h.toUpperCase(),headers:he.normalize().toJSON(),body:T,duplex:"half",credentials:P?J:void 0};$=o&&new r(b,pe);let M=await(o?xe($,Oe):xe(b,pe));const me=u&&(I==="stream"||I==="response");if(u&&(F||me&&W)){const l={};["status","statusText","headers"].forEach(G=>{l[G]=M[G]});const E=a.toFiniteNumber(M.headers.get("content-length")),[A,_]=F&&yt(E,Se(bt(F),!0))||[];M=new n(Rt(M.body,St,A,()=>{_&&_(),W&&W()}),l)}I=I||"text";let Ne=await m[a.findKey(m,I)||"text"](M,f);return!me&&W&&W(),await new Promise((l,E)=>{mt(l,E,{data:Ne,headers:L.from(M.headers),status:M.status,statusText:M.statusText,config:f,request:$})})}catch(P){throw W&&W(),P&&P.name==="TypeError"&&/Load failed|fetch/i.test(P.message)?Object.assign(new g("Network Error",g.ERR_NETWORK,f,$,P&&P.response),{cause:P.cause||P}):g.from(P,P&&P.code,f,$,P&&P.response)}}},nn=new Map,Ot=t=>{let e=t&&t.env||{};const{fetch:r,Request:n,Response:s}=e,o=[n,s,r];let i=o.length,c=i,p,d,u=nn;for(;c--;)p=o[c],d=u.get(p),d===void 0&&u.set(p,d=c?new Map:rn(e)),u=d;return d};Ot();const Be={http:_r,xhr:Xr,fetch:{get:Ot}};a.forEach(Be,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const xt=t=>`- ${t}`,sn=t=>a.isFunction(t)||t===null||t===!1;function on(t,e){t=a.isArray(t)?t:[t];const{length:r}=t;let n,s;const o={};for(let i=0;i<r;i++){n=t[i];let c;if(s=n,!sn(n)&&(s=Be[(c=String(n)).toLowerCase()],s===void 0))throw new g(`Unknown adapter '${c}'`);if(s&&(a.isFunction(s)||(s=s.get(e))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([p,d])=>`adapter ${p} `+(d===!1?"is not supported by the environment":"is not available in the build"));let c=r?i.length>1?`since :
|
|
25
|
-
`+i.map(
|
|
26
|
-
`):" "+
|
|
27
|
-
`+o):n.stack=o}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=Y(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:o}=r;n!==void 0&&_e.assertOptions(n,{silentJSONParsing:B.transitional(B.boolean),forcedJSONParsing:B.transitional(B.boolean),clarifyTimeoutError:B.transitional(B.boolean),legacyInterceptorReqResOrdering:B.transitional(B.boolean)},!1),s!=null&&(a.isFunction(s)?r.paramsSerializer={serialize:s}:_e.assertOptions(s,{encode:B.function,serialize:B.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),_e.assertOptions(r,{baseUrl:B.spelling("baseURL"),withXsrfToken:B.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[r.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete o[f]}),r.headers=L.concat(i,o);const c=[];let p=!0;this.interceptors.request.forEach(function(b){if(typeof b.runWhen=="function"&&b.runWhen(r)===!1)return;p=p&&b.synchronous;const h=r.transitional||ke;h&&h.legacyInterceptorReqResOrdering?c.unshift(b.fulfilled,b.rejected):c.push(b.fulfilled,b.rejected)});const d=[];this.interceptors.response.forEach(function(b){d.push(b.fulfilled,b.rejected)});let u,m=0,w;if(!p){const f=[Ct.bind(this),void 0];for(f.unshift(...c),f.push(...d),w=f.length,u=Promise.resolve(r);m<w;)u=u.then(f[m++],f[m++]);return u}w=c.length;let R=r;for(;m<w;){const f=c[m++],b=c[m++];try{R=f(R)}catch(h){b.call(this,h);break}}try{u=Ct.call(this,R)}catch(f){return Promise.reject(f)}for(m=0,w=d.length;m<w;)u=u.then(d[m++],d[m++]);return u}getUri(e){e=Y(this.defaults,e);const r=gt(e.baseURL,e.url,e.allowAbsoluteUrls);return ut(r,e.params,e.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(e){X.prototype[e]=function(r,n){return this.request(Y(n||{},{method:e,url:r,data:(n||{}).data}))}}),a.forEach(["post","put","patch"],function(e){function r(n){return function(o,i,c){return this.request(Y(c||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}X.prototype[e]=r(),X.prototype[e+"Form"]=r(!0)});let cn=class Ft{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});const n=this;this.promise.then(s=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](s);n._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{n.subscribe(c),o=c}).then(s);return i.cancel=function(){n.unsubscribe(o)},i},e(function(o,i,c){n.reason||(n.reason=new fe(o,i,c),r(n.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=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new Ft(function(s){e=s}),cancel:e}}};function ln(t){return function(r){return t.apply(null,r)}}function un(t){return a.isObject(t)&&t.isAxiosError===!0}const Me={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Me).forEach(([t,e])=>{Me[e]=t});function vt(t){const e=new X(t),r=Ge(X.prototype.request,e);return a.extend(r,X.prototype,e,{allOwnKeys:!0}),a.extend(r,e,null,{allOwnKeys:!0}),r.create=function(s){return vt(Y(t,s))},r}const O=vt(le);O.Axios=X,O.CanceledError=fe,O.CancelToken=cn,O.isCancel=pt,O.VERSION=Pt,O.toFormData=we,O.AxiosError=g,O.Cancel=O.CanceledError,O.all=function(e){return Promise.all(e)},O.spread=ln,O.isAxiosError=un,O.mergeConfig=Y,O.AxiosHeaders=L,O.formToJSON=t=>dt(a.isHTMLForm(t)?new FormData(t):t),O.getAdapter=Nt.getAdapter,O.HttpStatusCode=Me,O.default=O;const{Axios:jn,AxiosError:vn,CanceledError:kn,isCancel:Ln,CancelToken:Un,VERSION:In,all:Fn,Cancel:Bn,isAxiosError:Dn,spread:Mn,toFormData:Hn,AxiosHeaders:qn,HttpStatusCode:zn,formToJSON:Wn,getAdapter:Jn,mergeConfig:Vn}=O,H=O.create({baseURL:"https://authifyer-backend.onrender.com",headers:{"Content-Type":"application/json"}}),He="authifyer_access_token",qe=t=>{try{t?(localStorage.setItem(He,t),H.defaults.headers.common.Authorization=`Bearer ${t}`):(localStorage.removeItem(He),delete H.defaults.headers.common.Authorization)}catch(e){console.warn("Authifyer: localStorage is not accessible.",e)}},fn=()=>{try{return localStorage.getItem(He)}catch{return null}},ze="authifyer_refresh_token",We=t=>{try{t?localStorage.setItem(ze,t):localStorage.removeItem(ze)}catch(e){console.warn("Authifyer: localStorage is not accessible. Session persistence may fail.",e),typeof window<"u"&&window.dispatchEvent(new CustomEvent("auth:storage_error"))}},kt=()=>{try{return localStorage.getItem(ze)}catch(t){return console.warn("Authifyer: localStorage is not accessible. Session persistence may fail.",t),typeof window<"u"&&window.dispatchEvent(new CustomEvent("auth:storage_error")),null}};class de extends Error{}de.prototype.name="InvalidTokenError";function dn(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,r)=>{let n=r.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}function hn(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return dn(e)}catch{return atob(e)}}function pn(t,e){if(typeof t!="string")throw new de("Invalid token specified: must be a string");e||(e={});const r=e.header===!0?0:1,n=t.split(".")[r];if(typeof n!="string")throw new de(`Invalid token specified: missing part #${r+1}`);let s;try{s=hn(n)}catch(o){throw new de(`Invalid token specified: invalid base64 for part #${r+1} (${o.message})`)}try{return JSON.parse(s)}catch(o){throw new de(`Invalid token specified: invalid json for part #${r+1} (${o.message})`)}}const Lt=t=>{try{const e=pn(t),r=Date.now()/1e3;if(e.exp<r)return null;const n={authifyerId:e.sub,name:e.name,email:e.email,emailVerified:!1,isActive:!0,provider:"email"};return{token:t,sessionId:e.sid,expireAt:e.exp,user:n}}catch(e){return console.error("Invalid token",e),null}};class mn{constructor(e,r){Q(this,"publishableKey");Q(this,"refreshTimer",null);Q(this,"session",null);Q(this,"config",null);Q(this,"isLoading",!0);Q(this,"listeners",[]);this.publishableKey=e,r!=null&&r.backendUrl&&(H.defaults.baseURL=r.backendUrl)}async load(){try{this.isLoading=!0,this.notifyListeners();try{const n=(await H.get(`/public/config/${this.publishableKey}`)).data,s=[];n.isGoogleOauthEnabled&&s.push("google"),n.isGithubOauthEnabled&&s.push("github"),this.config={emailPasswordEnabled:n.isEmailPassEnabled,oauthProviders:s}}catch(r){console.warn("Authifyer: Failed to fetch public project configuration. Using defaults.",r),this.config={emailPasswordEnabled:!0,oauthProviders:["google","github"]}}const e=fn();if(e){const r=Lt(e);r&&(this.session=r,qe(e),this.startRefreshTimer())}this.session||await this.refreshSession()}catch(e){console.error("Failed to load Authifyer client",e)}finally{this.isLoading=!1,this.notifyListeners()}}async signInWithEmail(e,r){try{const n=await H.post("/authifyer/project/login/email",{email:e,password:r,publicProjectId:this.publishableKey});this.handleAuthResponse(n.data)}catch(n){throw n}}async signUpWithEmail(e,r){try{const n=await H.post("/authifyer/project/register/email",{email:e,password:r,publicProjectId:this.publishableKey});this.handleAuthResponse(n.data)}catch(n){throw n}}async signOut(){try{await H.post("/authifyer/session/logout")}catch(e){console.warn("Logout failed",e)}finally{this.clearSession()}}signInWithOAuth(e){const r=window.location.origin,n=`${H.defaults.baseURL}/oauth2/authorization/${e}?publishable_key=${this.publishableKey}&redirect_uri=${r}`;window.location.href=n}async refreshSession(){try{const e=kt(),r=await H.post("/authifyer/jwt/refresh-jwt",{refresh_token:e||void 0}),{access_token:n,refresh_token:s}=r.data;if(n){const o=n.accessToken||n;this.setSession(o)}s&&We(s)}catch{this.clearSession()}}async rotateSession(){try{const e=kt();await H.post("/authifyer/session/refresh",{refresh_token:e||void 0}),await this.refreshSession()}catch(e){console.warn("Session rotation failed",e),this.clearSession()}}handleAuthResponse(e){e.accessToken&&this.setSession(e.accessToken),(e.refreshToken||e.refresh_token)&&We(e.refreshToken||e.refresh_token)}setSession(e){const r=Lt(e);r&&(this.session=r,qe(e),this.startRefreshTimer(),this.notifyListeners())}clearSession(){this.session=null,qe(null),We(null),this.stopRefreshTimer(),this.notifyListeners()}startRefreshTimer(){this.stopRefreshTimer(),this.refreshTimer=setInterval(()=>{this.refreshSession()},270*1e3)}stopRefreshTimer(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=null)}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(r=>r!==e)}}notifyListeners(){this.listeners.forEach(e=>e(this))}}const Ut=S.createContext(void 0),yn=({publishableKey:t,backendUrl:e,config:r,children:n})=>{var f;const s=S.useMemo(()=>{const b=typeof process<"u"&&process.env&&(process.env.NEXT_PUBLIC_AUTHIFYER_PUBLISHABLE_KEY||process.env.REACT_APP_AUTHIFYER_PUBLISHABLE_KEY),h=t||b;h||console.error("AuthifyerProvider requires a publishableKey either passed as a prop or set as an environment variable (e.g. VITE_AUTHIFYER_PUBLISHABLE_KEY, NEXT_PUBLIC_AUTHIFYER_PUBLISHABLE_KEY, REACT_APP_AUTHIFYER_PUBLISHABLE_KEY).");const T=new mn(h||"",{backendUrl:e});return r&&(T.config=r),T},[t,e,r]),[o,i]=S.useState(((f=s.session)==null?void 0:f.user)||null),[c,p]=S.useState(s.session),[d,u]=S.useState(s.config),[m,w]=S.useState(s.isLoading);S.useEffect(()=>{const b=s.subscribe(h=>{var T;i(((T=h.session)==null?void 0:T.user)||null),p(h.session),r||u(h.config),w(h.isLoading)});return s.load(),()=>{b()}},[s,r]);const R={client:s,user:o,session:c,config:r||d,isLoading:m};return y.jsx(Ut.Provider,{value:R,children:n})},te=()=>{const t=S.useContext(Ut);if(t===void 0)throw new Error("useAuth must be used within an AuthifyerProvider");return t},bn=()=>{const{user:t,isLoading:e}=te();return{user:t,isLoading:e,isSignedIn:!!t}},gn=()=>{const{session:t,isLoading:e}=te();return{session:t,isLoading:e,isSignedIn:!!t}},En=()=>{const{client:t}=te();return t},Je=({title:t,subtitle:e,children:r})=>y.jsx("div",{className:"authifyer-root",children:y.jsxs("div",{className:"authifyer-card",children:[y.jsxs("div",{className:"authifyer-card-header",children:[y.jsx("h2",{className:"authifyer-card-title",children:t}),e&&y.jsx("p",{className:"authifyer-card-subtitle",children:e})]}),y.jsx("div",{className:"authifyer-card-content",children:r}),y.jsxs("div",{className:"authifyer-footer",children:[y.jsx("span",{className:"authifyer-secured-text",children:"Secured by"}),y.jsxs("span",{className:"authifyer-brand",children:[y.jsx("svg",{className:"authifyer-logo-icon",viewBox:"0 0 24 24",fill:"currentColor",children:y.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"})}),"Authifyer"]})]})]})}),wn=()=>{const{client:t,config:e}=te(),[r,n]=S.useState(""),[s,o]=S.useState(""),[i,c]=S.useState(""),[p,d]=S.useState(!1),u=(e==null?void 0:e.emailPasswordEnabled)??!0,m=(e==null?void 0:e.oauthProviders)??["google","github"],w=async R=>{R.preventDefault(),d(!0),c("");try{await t.signInWithEmail(r,s)}catch{c("Invalid credentials")}finally{d(!1)}};return y.jsxs(Je,{title:"Sign in",subtitle:"to continue to Authifyer",children:[i&&y.jsx("p",{className:"authifyer-error",children:i}),(m.includes("google")||m.includes("github"))&&y.jsxs("div",{className:"authifyer-form",children:[m.includes("google")&&y.jsxs("button",{className:"authifyer-provider-btn",onClick:()=>t.signInWithOAuth("google"),children:[y.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[y.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),y.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),y.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),y.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]}),m.includes("github")&&y.jsxs("button",{className:"authifyer-provider-btn",onClick:()=>t.signInWithOAuth("github"),children:[y.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:y.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.3 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),"Continue with GitHub"]})]}),(m.includes("google")||m.includes("github"))&&u&&y.jsx("div",{className:"authifyer-divider",children:"or"}),u&&y.jsxs("form",{onSubmit:w,className:"authifyer-form",children:[y.jsxs("div",{className:"authifyer-form-group",children:[y.jsx("label",{className:"authifyer-label",children:"Email address"}),y.jsx("input",{type:"email",className:"authifyer-input",value:r,onChange:R=>n(R.target.value),required:!0})]}),y.jsxs("div",{className:"authifyer-form-group",children:[y.jsx("label",{className:"authifyer-label",children:"Password"}),y.jsx("input",{type:"password",className:"authifyer-input",value:s,onChange:R=>o(R.target.value),required:!0})]}),y.jsx("button",{type:"submit",className:"authifyer-submit-btn",disabled:p,children:p?"Signing In...":"Continue"})]})]})},Rn=()=>{const{client:t,config:e}=te(),[r,n]=S.useState(""),[s,o]=S.useState(""),[i,c]=S.useState(""),[p,d]=S.useState(!1),[u,m]=S.useState(!1),w=(e==null?void 0:e.emailPasswordEnabled)??!0,R=(e==null?void 0:e.oauthProviders)??["google","github"],f=async b=>{b.preventDefault(),d(!0),c("");try{await t.signUpWithEmail(r,s),m(!0)}catch{c("Registration failed. User might already exist.")}finally{d(!1)}};return u?y.jsx(Je,{title:"Welcome!",children:y.jsxs("div",{className:"authifyer-success",children:[y.jsx("svg",{className:"authifyer-success-icon",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),y.jsxs("div",{children:[y.jsx("h3",{className:"authifyer-success-title",children:"Success"}),y.jsx("p",{className:"authifyer-success-text",children:"Registration completed. Please verify your email."})]})]})}):y.jsxs(Je,{title:"Create your account",subtitle:"Welcome to Authifyer",children:[i&&y.jsx("p",{className:"authifyer-error",children:i}),(R.includes("google")||R.includes("github"))&&y.jsxs("div",{className:"authifyer-form",children:[R.includes("google")&&y.jsxs("button",{className:"authifyer-provider-btn",onClick:()=>t.signInWithOAuth("google"),children:[y.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[y.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),y.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),y.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),y.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]}),R.includes("github")&&y.jsxs("button",{className:"authifyer-provider-btn",onClick:()=>t.signInWithOAuth("github"),children:[y.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:y.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.3 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),"Continue with GitHub"]})]}),(R.includes("google")||R.includes("github"))&&w&&y.jsx("div",{className:"authifyer-divider",children:"or"}),w&&y.jsxs("form",{onSubmit:f,className:"authifyer-form",children:[y.jsxs("div",{className:"authifyer-form-group",children:[y.jsx("label",{className:"authifyer-label",children:"Email address"}),y.jsx("input",{type:"email",className:"authifyer-input",value:r,onChange:b=>n(b.target.value),required:!0})]}),y.jsxs("div",{className:"authifyer-form-group",children:[y.jsx("label",{className:"authifyer-label",children:"Password"}),y.jsx("input",{type:"password",className:"authifyer-input",value:s,onChange:b=>o(b.target.value),required:!0})]}),y.jsx("button",{type:"submit",className:"authifyer-submit-btn",disabled:p,children:p?"Signing Up...":"Continue"})]})]})};N.AuthifyerProvider=yn,N.SignIn=wn,N.SignUp=Rn,N.useAuth=te,N.useAuthifyer=En,N.useSession=gn,N.useUser=bn,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}));
|
|
22
|
+
<%s key={someKey} {...props} />`,x,P,se,P),Ce[P+x]=!0)}if(P=null,A!==void 0&&(r(A),P=""+A),i(E)&&(r(E.key),P=""+E.key),"key"in E){A={};for(var Ye in E)Ye!=="key"&&(A[Ye]=E[Ye])}else A=E;return P&&c(A,typeof l=="function"?l.displayName||l.name||"Unknown":l),d(l,P,A,s(),Q,Ke)}function y(l){w(l)?l._store&&(l._store.validated=1):typeof l=="object"&&l!==null&&l.$$typeof===F&&(l._payload.status==="fulfilled"?w(l._payload.value)&&l._payload.value._store&&(l._payload.value._store.validated=1):l._store&&(l._store.validated=1))}function w(l){return typeof l=="object"&&l!==null&&l.$$typeof===f}var S=R,f=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),j=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),_e=Symbol.for("react.activity"),Ne=Symbol.for("react.client.reference"),K=S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=Object.prototype.hasOwnProperty,J=Array.isArray,ne=console.createTask?console.createTask:function(){return null};S={react_stack_bottom_frame:function(l){return l()}};var k,pe={},W=S.react_stack_bottom_frame.bind(S,o)(),me=ne(n(o)),Ce={};ie.Fragment=h,ie.jsx=function(l,E,A){var x=1e4>K.recentlyCreatedOwnerStacks++;return u(l,E,A,!1,x?Error("react-stack-top-frame"):W,x?ne(n(l)):me)},ie.jsxs=function(l,E,A){var x=1e4>K.recentlyCreatedOwnerStacks++;return u(l,E,A,!0,x?Error("react-stack-top-frame"):W,x?ne(n(l)):me)}})()),ie}var Ge;function Mt(){return Ge||(Ge=1,process.env.NODE_ENV==="production"?V.exports=Bt():V.exports=Dt()),V.exports}var m=Mt();function Qe(t,e){return function(){return t.apply(e,arguments)}}const{toString:Ht}=Object.prototype,{getPrototypeOf:je}=Object,{iterator:ye,toStringTag:Ze}=Symbol,be=(t=>e=>{const r=Ht.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),H=t=>(t=t.toLowerCase(),e=>be(e)===t),ge=t=>e=>typeof e===t,{isArray:ee}=Array,te=ge("undefined");function ae(t){return t!==null&&!te(t)&&t.constructor!==null&&!te(t.constructor)&&B(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const et=H("ArrayBuffer");function zt(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&et(t.buffer),e}const qt=ge("string"),B=ge("function"),tt=ge("number"),ce=t=>t!==null&&typeof t=="object",Wt=t=>t===!0||t===!1,Ee=t=>{if(be(t)!=="object")return!1;const e=je(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Ze in t)&&!(ye in t)},Vt=t=>{if(!ce(t)||ae(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Jt=H("Date"),Kt=H("File"),Yt=H("Blob"),$t=H("FileList"),Xt=t=>ce(t)&&B(t.pipe),Gt=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||B(t.append)&&((e=be(t))==="formdata"||e==="object"&&B(t.toString)&&t.toString()==="[object FormData]"))},Qt=H("URLSearchParams"),[Zt,er,tr,rr]=["ReadableStream","Request","Response","Headers"].map(H),nr=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function le(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,s;if(typeof t!="object"&&(t=[t]),ee(t))for(n=0,s=t.length;n<s;n++)e.call(null,t[n],n,t);else{if(ae(t))return;const o=r?Object.getOwnPropertyNames(t):Object.keys(t),i=o.length;let c;for(n=0;n<i;n++)c=o[n],e.call(null,t[c],c,t)}}function rt(t,e){if(ae(t))return null;e=e.toLowerCase();const r=Object.keys(t);let n=r.length,s;for(;n-- >0;)if(s=r[n],e===s.toLowerCase())return s;return null}const $=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,nt=t=>!te(t)&&t!==$;function Pe(){const{caseless:t,skipUndefined:e}=nt(this)&&this||{},r={},n=(s,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const i=t&&rt(r,o)||o;Ee(r[i])&&Ee(s)?r[i]=Pe(r[i],s):Ee(s)?r[i]=Pe({},s):ee(s)?r[i]=s.slice():(!e||!te(s))&&(r[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&le(arguments[s],n);return r}const sr=(t,e,r,{allOwnKeys:n}={})=>(le(e,(s,o)=>{r&&B(s)?Object.defineProperty(t,o,{value:Qe(s,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),t),or=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),ir=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},ar=(t,e,r,n)=>{let s,o,i;const c={};if(e=e||{},t==null)return e;do{for(s=Object.getOwnPropertyNames(t),o=s.length;o-- >0;)i=s[o],(!n||n(i,t,e))&&!c[i]&&(e[i]=t[i],c[i]=!0);t=r!==!1&&je(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},cr=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return n!==-1&&n===r},lr=t=>{if(!t)return null;if(ee(t))return t;let e=t.length;if(!tt(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},ur=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&je(Uint8Array)),fr=(t,e)=>{const n=(t&&t[ye]).call(t);let s;for(;(s=n.next())&&!s.done;){const o=s.value;e.call(t,o[0],o[1])}},dr=(t,e)=>{let r;const n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},hr=H("HTMLFormElement"),pr=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,s){return n.toUpperCase()+s}),st=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),mr=H("RegExp"),ot=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};le(r,(s,o)=>{let i;(i=e(s,o,t))!==!1&&(n[o]=i||s)}),Object.defineProperties(t,n)},yr=t=>{ot(t,(e,r)=>{if(B(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=t[r];if(B(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},br=(t,e)=>{const r={},n=s=>{s.forEach(o=>{r[o]=!0})};return ee(t)?n(t):n(String(t).split(e)),r},gr=()=>{},Er=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function wr(t){return!!(t&&B(t.append)&&t[Ze]==="FormData"&&t[ye])}const Rr=t=>{const e=new Array(10),r=(n,s)=>{if(ce(n)){if(e.indexOf(n)>=0)return;if(ae(n))return n;if(!("toJSON"in n)){e[s]=n;const o=ee(n)?[]:{};return le(n,(i,c)=>{const p=r(i,s+1);!te(p)&&(o[c]=p)}),e[s]=void 0,o}}return n};return r(t,0)},Sr=H("AsyncFunction"),Tr=t=>t&&(ce(t)||B(t))&&B(t.then)&&B(t.catch),it=((t,e)=>t?setImmediate:e?((r,n)=>($.addEventListener("message",({source:s,data:o})=>{s===$&&o===r&&n.length&&n.shift()()},!1),s=>{n.push(s),$.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",B($.postMessage)),Ar=typeof queueMicrotask<"u"?queueMicrotask.bind($):typeof process<"u"&&process.nextTick||it,a={isArray:ee,isArrayBuffer:et,isBuffer:ae,isFormData:Gt,isArrayBufferView:zt,isString:qt,isNumber:tt,isBoolean:Wt,isObject:ce,isPlainObject:Ee,isEmptyObject:Vt,isReadableStream:Zt,isRequest:er,isResponse:tr,isHeaders:rr,isUndefined:te,isDate:Jt,isFile:Kt,isBlob:Yt,isRegExp:mr,isFunction:B,isStream:Xt,isURLSearchParams:Qt,isTypedArray:ur,isFileList:$t,forEach:le,merge:Pe,extend:sr,trim:nr,stripBOM:or,inherits:ir,toFlatObject:ar,kindOf:be,kindOfTest:H,endsWith:cr,toArray:lr,forEachEntry:fr,matchAll:dr,isHTMLForm:hr,hasOwnProperty:st,hasOwnProp:st,reduceDescriptors:ot,freezeMethods:yr,toObjectSet:br,toCamelCase:pr,noop:gr,toFiniteNumber:Er,findKey:rt,global:$,isContextDefined:nt,isSpecCompliantForm:wr,toJSONObject:Rr,isAsyncFn:Sr,isThenable:Tr,setImmediate:it,asap:Ar,isIterable:t=>t!=null&&B(t[ye])};let g=class It extends Error{static from(e,r,n,s,o,i){const c=new It(e.message,r||e.code,n,s,o);return c.cause=e,c.name=e.name,i&&Object.assign(c,i),c}constructor(e,r,n,s,o){super(e),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),s&&(this.request=s),o&&(this.response=o,this.status=o.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}};g.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",g.ERR_BAD_OPTION="ERR_BAD_OPTION",g.ECONNABORTED="ECONNABORTED",g.ETIMEDOUT="ETIMEDOUT",g.ERR_NETWORK="ERR_NETWORK",g.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",g.ERR_DEPRECATED="ERR_DEPRECATED",g.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",g.ERR_BAD_REQUEST="ERR_BAD_REQUEST",g.ERR_CANCELED="ERR_CANCELED",g.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",g.ERR_INVALID_URL="ERR_INVALID_URL";const xr=null;function ve(t){return a.isPlainObject(t)||a.isArray(t)}function at(t){return a.endsWith(t,"[]")?t.slice(0,-2):t}function ct(t,e,r){return t?t.concat(e).map(function(s,o){return s=at(s),!r&&o?"["+s+"]":s}).join(r?".":""):e}function Or(t){return a.isArray(t)&&!t.some(ve)}const _r=a.toFlatObject(a,{},null,function(e){return/^is[A-Z]/.test(e)});function we(t,e,r){if(!a.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(b,h){return!a.isUndefined(h[b])});const n=r.metaTokens,s=r.visitor||u,o=r.dots,i=r.indexes,p=(r.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(e);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function d(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(a.isBoolean(f))return f.toString();if(!p&&a.isBlob(f))throw new g("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?p&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function u(f,b,h){let T=f;if(f&&!h&&typeof f=="object"){if(a.endsWith(b,"{}"))b=n?b:b.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Or(f)||(a.isFileList(f)||a.endsWith(b,"[]"))&&(T=a.toArray(f)))return b=at(b),T.forEach(function(O,j){!(a.isUndefined(O)||O===null)&&e.append(i===!0?ct([b],j,o):i===null?b:b+"[]",d(O))}),!1}return ve(f)?!0:(e.append(ct(h,b,o),d(f)),!1)}const y=[],w=Object.assign(_r,{defaultVisitor:u,convertValue:d,isVisitable:ve});function S(f,b){if(!a.isUndefined(f)){if(y.indexOf(f)!==-1)throw Error("Circular reference detected in "+b.join("."));y.push(f),a.forEach(f,function(T,v){(!(a.isUndefined(T)||T===null)&&s.call(e,T,a.isString(v)?v.trim():v,b,w))===!0&&S(T,b?b.concat(v):[v])}),y.pop()}}if(!a.isObject(t))throw new TypeError("data must be an object");return S(t),e}function lt(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function ke(t,e){this._pairs=[],t&&we(t,this,e)}const ut=ke.prototype;ut.append=function(e,r){this._pairs.push([e,r])},ut.toString=function(e){const r=e?function(n){return e.call(this,n,lt)}:lt;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function Nr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ft(t,e,r){if(!e)return t;const n=r&&r.encode||Nr,s=a.isFunction(r)?{serialize:r}:r,o=s&&s.serialize;let i;if(o?i=o(e,s):i=a.isURLSearchParams(e)?e.toString():new ke(e,s).toString(n),i){const c=t.indexOf("#");c!==-1&&(t=t.slice(0,c)),t+=(t.indexOf("?")===-1?"?":"&")+i}return t}class dt{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){a.forEach(this.handlers,function(n){n!==null&&e(n)})}}const Le={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Cr={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ke,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ue=typeof window<"u"&&typeof document<"u",Ie=typeof navigator=="object"&&navigator||void 0,jr=Ue&&(!Ie||["ReactNative","NativeScript","NS"].indexOf(Ie.product)<0),Pr=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",vr=Ue&&window.location.href||"http://localhost",L={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ue,hasStandardBrowserEnv:jr,hasStandardBrowserWebWorkerEnv:Pr,navigator:Ie,origin:vr},Symbol.toStringTag,{value:"Module"})),...Cr};function kr(t,e){return we(t,new L.classes.URLSearchParams,{visitor:function(r,n,s,o){return L.isNode&&a.isBuffer(r)?(this.append(n,r.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}function Lr(t){return a.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Ur(t){const e={},r=Object.keys(t);let n;const s=r.length;let o;for(n=0;n<s;n++)o=r[n],e[o]=t[o];return e}function ht(t){function e(r,n,s,o){let i=r[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),p=o>=r.length;return i=!i&&a.isArray(s)?s.length:i,p?(a.hasOwnProp(s,i)?s[i]=[s[i],n]:s[i]=n,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),e(r,n,s[i],o)&&a.isArray(s[i])&&(s[i]=Ur(s[i])),!c)}if(a.isFormData(t)&&a.isFunction(t.entries)){const r={};return a.forEachEntry(t,(n,s)=>{e(Lr(n),s,r,0)}),r}return null}function Ir(t,e,r){if(a.isString(t))try{return(e||JSON.parse)(t),a.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}const ue={transitional:Le,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){const n=r.getContentType()||"",s=n.indexOf("application/json")>-1,o=a.isObject(e);if(o&&a.isHTMLForm(e)&&(e=new FormData(e)),a.isFormData(e))return s?JSON.stringify(ht(e)):e;if(a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)||a.isReadableStream(e))return e;if(a.isArrayBufferView(e))return e.buffer;if(a.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let c;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return kr(e,this.formSerializer).toString();if((c=a.isFileList(e))||n.indexOf("multipart/form-data")>-1){const p=this.env&&this.env.FormData;return we(c?{"files[]":e}:e,p&&new p,this.formSerializer)}}return o||s?(r.setContentType("application/json",!1),Ir(e)):e}],transformResponse:[function(e){const r=this.transitional||ue.transitional,n=r&&r.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(e)||a.isReadableStream(e))return e;if(e&&a.isString(e)&&(n&&!this.responseType||s)){const i=!(r&&r.silentJSONParsing)&&s;try{return JSON.parse(e,this.parseReviver)}catch(c){if(i)throw c.name==="SyntaxError"?g.from(c,g.ERR_BAD_RESPONSE,this,null,this.response):c}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:L.classes.FormData,Blob:L.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],t=>{ue.headers[t]={}});const Fr=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Br=t=>{const e={};let r,n,s;return t&&t.split(`
|
|
23
|
+
`).forEach(function(i){s=i.indexOf(":"),r=i.substring(0,s).trim().toLowerCase(),n=i.substring(s+1).trim(),!(!r||e[r]&&Fr[r])&&(r==="set-cookie"?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)}),e},pt=Symbol("internals");function fe(t){return t&&String(t).trim().toLowerCase()}function Re(t){return t===!1||t==null?t:a.isArray(t)?t.map(Re):String(t)}function Dr(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}const Mr=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Fe(t,e,r,n,s){if(a.isFunction(n))return n.call(this,e,r);if(s&&(e=r),!!a.isString(e)){if(a.isString(n))return e.indexOf(n)!==-1;if(a.isRegExp(n))return n.test(e)}}function Hr(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,r,n)=>r.toUpperCase()+n)}function zr(t,e){const r=a.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(t,n+r,{value:function(s,o,i){return this[n].call(this,e,s,o,i)},configurable:!0})})}let D=class{constructor(e){e&&this.set(e)}set(e,r,n){const s=this;function o(c,p,d){const u=fe(p);if(!u)throw new Error("header name must be a non-empty string");const y=a.findKey(s,u);(!y||s[y]===void 0||d===!0||d===void 0&&s[y]!==!1)&&(s[y||p]=Re(c))}const i=(c,p)=>a.forEach(c,(d,u)=>o(d,u,p));if(a.isPlainObject(e)||e instanceof this.constructor)i(e,r);else if(a.isString(e)&&(e=e.trim())&&!Mr(e))i(Br(e),r);else if(a.isObject(e)&&a.isIterable(e)){let c={},p,d;for(const u of e){if(!a.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[d=u[0]]=(p=c[d])?a.isArray(p)?[...p,u[1]]:[p,u[1]]:u[1]}i(c,r)}else e!=null&&o(r,e,n);return this}get(e,r){if(e=fe(e),e){const n=a.findKey(this,e);if(n){const s=this[n];if(!r)return s;if(r===!0)return Dr(s);if(a.isFunction(r))return r.call(this,s,n);if(a.isRegExp(r))return r.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,r){if(e=fe(e),e){const n=a.findKey(this,e);return!!(n&&this[n]!==void 0&&(!r||Fe(this,this[n],n,r)))}return!1}delete(e,r){const n=this;let s=!1;function o(i){if(i=fe(i),i){const c=a.findKey(n,i);c&&(!r||Fe(n,n[c],c,r))&&(delete n[c],s=!0)}}return a.isArray(e)?e.forEach(o):o(e),s}clear(e){const r=Object.keys(this);let n=r.length,s=!1;for(;n--;){const o=r[n];(!e||Fe(this,this[o],o,e,!0))&&(delete this[o],s=!0)}return s}normalize(e){const r=this,n={};return a.forEach(this,(s,o)=>{const i=a.findKey(n,o);if(i){r[i]=Re(s),delete r[o];return}const c=e?Hr(o):String(o).trim();c!==o&&delete r[o],r[c]=Re(s),n[c]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const r=Object.create(null);return a.forEach(this,(n,s)=>{n!=null&&n!==!1&&(r[s]=e&&a.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,r])=>e+": "+r).join(`
|
|
24
|
+
`)}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 n=new this(e);return r.forEach(s=>n.set(s)),n}static accessor(e){const n=(this[pt]=this[pt]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=fe(i);n[c]||(zr(s,i),n[c]=!0)}return a.isArray(e)?e.forEach(o):o(e),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(D.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}}),a.freezeMethods(D);function Be(t,e){const r=this||ue,n=e||r,s=D.from(n.headers);let o=n.data;return a.forEach(t,function(c){o=c.call(r,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function mt(t){return!!(t&&t.__CANCEL__)}let de=class extends g{constructor(e,r,n){super(e??"canceled",g.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}};function yt(t,e,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new g("Request failed with status code "+r.status,[g.ERR_BAD_REQUEST,g.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function qr(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Wr(t,e){t=t||10;const r=new Array(t),n=new Array(t);let s=0,o=0,i;return e=e!==void 0?e:1e3,function(p){const d=Date.now(),u=n[o];i||(i=d),r[s]=p,n[s]=d;let y=o,w=0;for(;y!==s;)w+=r[y++],y=y%t;if(s=(s+1)%t,s===o&&(o=(o+1)%t),d-i<e)return;const S=u&&d-u;return S?Math.round(w*1e3/S):void 0}}function Vr(t,e){let r=0,n=1e3/e,s,o;const i=(d,u=Date.now())=>{r=u,s=null,o&&(clearTimeout(o),o=null),t(...d)};return[(...d)=>{const u=Date.now(),y=u-r;y>=n?i(d,u):(s=d,o||(o=setTimeout(()=>{o=null,i(s)},n-y)))},()=>s&&i(s)]}const Se=(t,e,r=3)=>{let n=0;const s=Wr(50,250);return Vr(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,p=i-n,d=s(p),u=i<=c;n=i;const y={loaded:i,total:c,progress:c?i/c:void 0,bytes:p,rate:d||void 0,estimated:d&&c&&u?(c-i)/d:void 0,event:o,lengthComputable:c!=null,[e?"download":"upload"]:!0};t(y)},r)},bt=(t,e)=>{const r=t!=null;return[n=>e[0]({lengthComputable:r,total:t,loaded:n}),e[1]]},gt=t=>(...e)=>a.asap(()=>t(...e)),Jr=L.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,L.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(L.origin),L.navigator&&/(msie|trident)/i.test(L.navigator.userAgent)):()=>!0,Kr=L.hasStandardBrowserEnv?{write(t,e,r,n,s,o,i){if(typeof document>"u")return;const c=[`${t}=${encodeURIComponent(e)}`];a.isNumber(r)&&c.push(`expires=${new Date(r).toUTCString()}`),a.isString(n)&&c.push(`path=${n}`),a.isString(s)&&c.push(`domain=${s}`),o===!0&&c.push("secure"),a.isString(i)&&c.push(`SameSite=${i}`),document.cookie=c.join("; ")},read(t){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Yr(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function $r(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Et(t,e,r){let n=!Yr(e);return t&&(n||r==!1)?$r(t,e):e}const wt=t=>t instanceof D?{...t}:t;function X(t,e){e=e||{};const r={};function n(d,u,y,w){return a.isPlainObject(d)&&a.isPlainObject(u)?a.merge.call({caseless:w},d,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function s(d,u,y,w){if(a.isUndefined(u)){if(!a.isUndefined(d))return n(void 0,d,y,w)}else return n(d,u,y,w)}function o(d,u){if(!a.isUndefined(u))return n(void 0,u)}function i(d,u){if(a.isUndefined(u)){if(!a.isUndefined(d))return n(void 0,d)}else return n(void 0,u)}function c(d,u,y){if(y in e)return n(d,u);if(y in t)return n(void 0,d)}const p={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(d,u,y)=>s(wt(d),wt(u),y,!0)};return a.forEach(Object.keys({...t,...e}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const y=a.hasOwnProp(p,u)?p[u]:s,w=y(t[u],e[u],u);a.isUndefined(w)&&y!==c||(r[u]=w)}),r}const Rt=t=>{const e=X({},t);let{data:r,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=e;if(e.headers=i=D.from(i),e.url=ft(Et(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),a.isFormData(r)){if(L.hasStandardBrowserEnv||L.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(a.isFunction(r.getHeaders)){const p=r.getHeaders(),d=["content-type","content-length"];Object.entries(p).forEach(([u,y])=>{d.includes(u.toLowerCase())&&i.set(u,y)})}}if(L.hasStandardBrowserEnv&&(n&&a.isFunction(n)&&(n=n(e)),n||n!==!1&&Jr(e.url))){const p=s&&o&&Kr.read(o);p&&i.set(s,p)}return e},Xr=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,n){const s=Rt(t);let o=s.data;const i=D.from(s.headers).normalize();let{responseType:c,onUploadProgress:p,onDownloadProgress:d}=s,u,y,w,S,f;function b(){S&&S(),f&&f(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function T(){if(!h)return;const O=D.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),N={data:!c||c==="text"||c==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:O,config:t,request:h};yt(function(U){r(U),b()},function(U){n(U),b()},N),h=null}"onloadend"in h?h.onloadend=T:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(T)},h.onabort=function(){h&&(n(new g("Request aborted",g.ECONNABORTED,t,h)),h=null)},h.onerror=function(j){const N=j&&j.message?j.message:"Network Error",q=new g(N,g.ERR_NETWORK,t,h);q.event=j||null,n(q),h=null},h.ontimeout=function(){let j=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const N=s.transitional||Le;s.timeoutErrorMessage&&(j=s.timeoutErrorMessage),n(new g(j,N.clarifyTimeoutError?g.ETIMEDOUT:g.ECONNABORTED,t,h)),h=null},o===void 0&&i.setContentType(null),"setRequestHeader"in h&&a.forEach(i.toJSON(),function(j,N){h.setRequestHeader(N,j)}),a.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),c&&c!=="json"&&(h.responseType=s.responseType),d&&([w,f]=Se(d,!0),h.addEventListener("progress",w)),p&&h.upload&&([y,S]=Se(p),h.upload.addEventListener("progress",y),h.upload.addEventListener("loadend",S)),(s.cancelToken||s.signal)&&(u=O=>{h&&(n(!O||O.type?new de(null,t,h):O),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const v=qr(s.url);if(v&&L.protocols.indexOf(v)===-1){n(new g("Unsupported protocol "+v+":",g.ERR_BAD_REQUEST,t));return}h.send(o||null)})},Gr=(t,e)=>{const{length:r}=t=t?t.filter(Boolean):[];if(e||r){let n=new AbortController,s;const o=function(d){if(!s){s=!0,c();const u=d instanceof Error?d:this.reason;n.abort(u instanceof g?u:new de(u instanceof Error?u.message:u))}};let i=e&&setTimeout(()=>{i=null,o(new g(`timeout of ${e}ms exceeded`,g.ETIMEDOUT))},e);const c=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(d=>{d.unsubscribe?d.unsubscribe(o):d.removeEventListener("abort",o)}),t=null)};t.forEach(d=>d.addEventListener("abort",o));const{signal:p}=n;return p.unsubscribe=()=>a.asap(c),p}},Qr=function*(t,e){let r=t.byteLength;if(r<e){yield t;return}let n=0,s;for(;n<r;)s=n+e,yield t.slice(n,s),n=s},Zr=async function*(t,e){for await(const r of en(t))yield*Qr(r,e)},en=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:r,value:n}=await e.read();if(r)break;yield n}}finally{await e.cancel()}},St=(t,e,r,n)=>{const s=Zr(t,e);let o=0,i,c=p=>{i||(i=!0,n&&n(p))};return new ReadableStream({async pull(p){try{const{done:d,value:u}=await s.next();if(d){c(),p.close();return}let y=u.byteLength;if(r){let w=o+=y;r(w)}p.enqueue(new Uint8Array(u))}catch(d){throw c(d),d}},cancel(p){return c(p),s.return()}},{highWaterMark:2})},Tt=64*1024,{isFunction:Te}=a,tn=(({Request:t,Response:e})=>({Request:t,Response:e}))(a.global),{ReadableStream:At,TextEncoder:xt}=a.global,Ot=(t,...e)=>{try{return!!t(...e)}catch{return!1}},rn=t=>{t=a.merge.call({skipUndefined:!0},tn,t);const{fetch:e,Request:r,Response:n}=t,s=e?Te(e):typeof fetch=="function",o=Te(r),i=Te(n);if(!s)return!1;const c=s&&Te(At),p=s&&(typeof xt=="function"?(f=>b=>f.encode(b))(new xt):async f=>new Uint8Array(await new r(f).arrayBuffer())),d=o&&c&&Ot(()=>{let f=!1;const b=new r(L.origin,{body:new At,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!b}),u=i&&c&&Ot(()=>a.isReadableStream(new n("").body)),y={stream:u&&(f=>f.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!y[f]&&(y[f]=(b,h)=>{let T=b&&b[f];if(T)return T.call(b);throw new g(`Response type '${f}' is not supported`,g.ERR_NOT_SUPPORT,h)})});const w=async f=>{if(f==null)return 0;if(a.isBlob(f))return f.size;if(a.isSpecCompliantForm(f))return(await new r(L.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(a.isArrayBufferView(f)||a.isArrayBuffer(f))return f.byteLength;if(a.isURLSearchParams(f)&&(f=f+""),a.isString(f))return(await p(f)).byteLength},S=async(f,b)=>{const h=a.toFiniteNumber(f.getContentLength());return h??w(b)};return async f=>{let{url:b,method:h,data:T,signal:v,cancelToken:O,timeout:j,onDownloadProgress:N,onUploadProgress:q,responseType:U,headers:I,withCredentials:F="same-origin",fetchOptions:_e}=Rt(f),Ne=e||fetch;U=U?(U+"").toLowerCase():"text";let K=Gr([v,O&&O.toAbortSignal()],j),Y=null;const J=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let ne;try{if(q&&d&&h!=="get"&&h!=="head"&&(ne=await S(I,T))!==0){let l=new r(b,{method:"POST",body:T,duplex:"half"}),E;if(a.isFormData(T)&&(E=l.headers.get("content-type"))&&I.setContentType(E),l.body){const[A,x]=bt(ne,Se(gt(q)));T=St(l.body,Tt,A,x)}}a.isString(F)||(F=F?"include":"omit");const k=o&&"credentials"in r.prototype,pe={..._e,signal:K,method:h.toUpperCase(),headers:I.normalize().toJSON(),body:T,duplex:"half",credentials:k?F:void 0};Y=o&&new r(b,pe);let W=await(o?Ne(Y,_e):Ne(b,pe));const me=u&&(U==="stream"||U==="response");if(u&&(N||me&&J)){const l={};["status","statusText","headers"].forEach(Q=>{l[Q]=W[Q]});const E=a.toFiniteNumber(W.headers.get("content-length")),[A,x]=N&&bt(E,Se(gt(N),!0))||[];W=new n(St(W.body,Tt,A,()=>{x&&x(),J&&J()}),l)}U=U||"text";let Ce=await y[a.findKey(y,U)||"text"](W,f);return!me&&J&&J(),await new Promise((l,E)=>{yt(l,E,{data:Ce,headers:D.from(W.headers),status:W.status,statusText:W.statusText,config:f,request:Y})})}catch(k){throw J&&J(),k&&k.name==="TypeError"&&/Load failed|fetch/i.test(k.message)?Object.assign(new g("Network Error",g.ERR_NETWORK,f,Y,k&&k.response),{cause:k.cause||k}):g.from(k,k&&k.code,f,Y,k&&k.response)}}},nn=new Map,_t=t=>{let e=t&&t.env||{};const{fetch:r,Request:n,Response:s}=e,o=[n,s,r];let i=o.length,c=i,p,d,u=nn;for(;c--;)p=o[c],d=u.get(p),d===void 0&&u.set(p,d=c?new Map:rn(e)),u=d;return d};_t();const De={http:xr,xhr:Xr,fetch:{get:_t}};a.forEach(De,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Nt=t=>`- ${t}`,sn=t=>a.isFunction(t)||t===null||t===!1;function on(t,e){t=a.isArray(t)?t:[t];const{length:r}=t;let n,s;const o={};for(let i=0;i<r;i++){n=t[i];let c;if(s=n,!sn(n)&&(s=De[(c=String(n)).toLowerCase()],s===void 0))throw new g(`Unknown adapter '${c}'`);if(s&&(a.isFunction(s)||(s=s.get(e))))break;o[c||"#"+i]=s}if(!s){const i=Object.entries(o).map(([p,d])=>`adapter ${p} `+(d===!1?"is not supported by the environment":"is not available in the build"));let c=r?i.length>1?`since :
|
|
25
|
+
`+i.map(Nt).join(`
|
|
26
|
+
`):" "+Nt(i[0]):"as no adapter specified";throw new g("There is no suitable adapter to dispatch the request "+c,"ERR_NOT_SUPPORT")}return s}const Ct={getAdapter:on,adapters:De};function Me(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new de(null,t)}function jt(t){return Me(t),t.headers=D.from(t.headers),t.data=Be.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Ct.getAdapter(t.adapter||ue.adapter,t)(t).then(function(n){return Me(t),n.data=Be.call(t,t.transformResponse,n),n.headers=D.from(n.headers),n},function(n){return mt(n)||(Me(t),n&&n.response&&(n.response.data=Be.call(t,t.transformResponse,n.response),n.response.headers=D.from(n.response.headers))),Promise.reject(n)})}const Pt="1.13.5",Ae={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Ae[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const vt={};Ae.transitional=function(e,r,n){function s(o,i){return"[Axios v"+Pt+"] Transitional option '"+o+"'"+i+(n?". "+n:"")}return(o,i,c)=>{if(e===!1)throw new g(s(i," has been removed"+(r?" in "+r:"")),g.ERR_DEPRECATED);return r&&!vt[i]&&(vt[i]=!0,console.warn(s(i," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(o,i,c):!0}},Ae.spelling=function(e){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function an(t,e,r){if(typeof t!="object")throw new g("options must be an object",g.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let s=n.length;for(;s-- >0;){const o=n[s],i=e[o];if(i){const c=t[o],p=c===void 0||i(c,o,t);if(p!==!0)throw new g("option "+o+" must be "+p,g.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new g("Unknown option "+o,g.ERR_BAD_OPTION)}}const xe={assertOptions:an,validators:Ae},M=xe.validators;let G=class{constructor(e){this.defaults=e||{},this.interceptors={request:new dt,response:new dt}}async request(e,r){try{return await this._request(e,r)}catch(n){if(n instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
27
|
+
`+o):n.stack=o}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=X(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:o}=r;n!==void 0&&xe.assertOptions(n,{silentJSONParsing:M.transitional(M.boolean),forcedJSONParsing:M.transitional(M.boolean),clarifyTimeoutError:M.transitional(M.boolean),legacyInterceptorReqResOrdering:M.transitional(M.boolean)},!1),s!=null&&(a.isFunction(s)?r.paramsSerializer={serialize:s}:xe.assertOptions(s,{encode:M.function,serialize:M.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),xe.assertOptions(r,{baseUrl:M.spelling("baseURL"),withXsrfToken:M.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[r.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete o[f]}),r.headers=D.concat(i,o);const c=[];let p=!0;this.interceptors.request.forEach(function(b){if(typeof b.runWhen=="function"&&b.runWhen(r)===!1)return;p=p&&b.synchronous;const h=r.transitional||Le;h&&h.legacyInterceptorReqResOrdering?c.unshift(b.fulfilled,b.rejected):c.push(b.fulfilled,b.rejected)});const d=[];this.interceptors.response.forEach(function(b){d.push(b.fulfilled,b.rejected)});let u,y=0,w;if(!p){const f=[jt.bind(this),void 0];for(f.unshift(...c),f.push(...d),w=f.length,u=Promise.resolve(r);y<w;)u=u.then(f[y++],f[y++]);return u}w=c.length;let S=r;for(;y<w;){const f=c[y++],b=c[y++];try{S=f(S)}catch(h){b.call(this,h);break}}try{u=jt.call(this,S)}catch(f){return Promise.reject(f)}for(y=0,w=d.length;y<w;)u=u.then(d[y++],d[y++]);return u}getUri(e){e=X(this.defaults,e);const r=Et(e.baseURL,e.url,e.allowAbsoluteUrls);return ft(r,e.params,e.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(e){G.prototype[e]=function(r,n){return this.request(X(n||{},{method:e,url:r,data:(n||{}).data}))}}),a.forEach(["post","put","patch"],function(e){function r(n){return function(o,i,c){return this.request(X(c||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}G.prototype[e]=r(),G.prototype[e+"Form"]=r(!0)});let cn=class Ft{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});const n=this;this.promise.then(s=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](s);n._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{n.subscribe(c),o=c}).then(s);return i.cancel=function(){n.unsubscribe(o)},i},e(function(o,i,c){n.reason||(n.reason=new de(o,i,c),r(n.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=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new Ft(function(s){e=s}),cancel:e}}};function ln(t){return function(r){return t.apply(null,r)}}function un(t){return a.isObject(t)&&t.isAxiosError===!0}const He={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(He).forEach(([t,e])=>{He[e]=t});function kt(t){const e=new G(t),r=Qe(G.prototype.request,e);return a.extend(r,G.prototype,e,{allOwnKeys:!0}),a.extend(r,e,null,{allOwnKeys:!0}),r.create=function(s){return kt(X(t,s))},r}const _=kt(ue);_.Axios=G,_.CanceledError=de,_.CancelToken=cn,_.isCancel=mt,_.VERSION=Pt,_.toFormData=we,_.AxiosError=g,_.Cancel=_.CanceledError,_.all=function(e){return Promise.all(e)},_.spread=ln,_.isAxiosError=un,_.mergeConfig=X,_.AxiosHeaders=D,_.formToJSON=t=>ht(a.isHTMLForm(t)?new FormData(t):t),_.getAdapter=Ct.getAdapter,_.HttpStatusCode=He,_.default=_;const{Axios:Pn,AxiosError:vn,CanceledError:kn,isCancel:Ln,CancelToken:Un,VERSION:In,all:Fn,Cancel:Bn,isAxiosError:Dn,spread:Mn,toFormData:Hn,AxiosHeaders:zn,HttpStatusCode:qn,formToJSON:Wn,getAdapter:Vn,mergeConfig:Jn}=_,z=_.create({baseURL:"https://authifyer-backend.onrender.com",headers:{"Content-Type":"application/json"}}),ze="authifyer_access_token",qe=t=>{try{t?(localStorage.setItem(ze,t),z.defaults.headers.common.Authorization=`Bearer ${t}`):(localStorage.removeItem(ze),delete z.defaults.headers.common.Authorization)}catch(e){console.warn("Authifyer: localStorage is not accessible.",e)}},fn=()=>{try{return localStorage.getItem(ze)}catch{return null}},We="authifyer_refresh_token",Ve=t=>{try{t?localStorage.setItem(We,t):localStorage.removeItem(We)}catch(e){console.warn("Authifyer: localStorage is not accessible. Session persistence may fail.",e),typeof window<"u"&&window.dispatchEvent(new CustomEvent("auth:storage_error"))}},Je=()=>{try{return localStorage.getItem(We)}catch(t){return console.warn("Authifyer: localStorage is not accessible. Session persistence may fail.",t),typeof window<"u"&&window.dispatchEvent(new CustomEvent("auth:storage_error")),null}};class he extends Error{}he.prototype.name="InvalidTokenError";function dn(t){return decodeURIComponent(atob(t).replace(/(.)/g,(e,r)=>{let n=r.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}))}function hn(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return dn(e)}catch{return atob(e)}}function pn(t,e){if(typeof t!="string")throw new he("Invalid token specified: must be a string");e||(e={});const r=e.header===!0?0:1,n=t.split(".")[r];if(typeof n!="string")throw new he(`Invalid token specified: missing part #${r+1}`);let s;try{s=hn(n)}catch(o){throw new he(`Invalid token specified: invalid base64 for part #${r+1} (${o.message})`)}try{return JSON.parse(s)}catch(o){throw new he(`Invalid token specified: invalid json for part #${r+1} (${o.message})`)}}const Lt=t=>{try{const e=pn(t),r=Date.now()/1e3;if(e.exp<r)return null;const n={authifyerId:e.sub,name:e.name,email:e.email,emailVerified:!1,isActive:!0,provider:"email"};return{token:t,sessionId:e.sid,expireAt:e.exp,user:n}}catch(e){return console.error("Invalid token",e),null}};class mn{constructor(e,r){Z(this,"publishableKey");Z(this,"refreshTimer",null);Z(this,"session",null);Z(this,"config",null);Z(this,"isLoading",!0);Z(this,"listeners",[]);this.publishableKey=e,r!=null&&r.backendUrl&&(z.defaults.baseURL=r.backendUrl)}async load(){try{this.isLoading=!0,this.notifyListeners();try{const n=(await z.get(`/public/config/${this.publishableKey}`)).data,s=[];n.isGoogleOauthEnabled&&s.push("google"),n.isGithubOauthEnabled&&s.push("github"),this.config={emailPasswordEnabled:n.isEmailPassEnabled,oauthProviders:s}}catch(r){console.warn("Authifyer: Failed to fetch public project configuration. Using defaults.",r),this.config={emailPasswordEnabled:!0,oauthProviders:["google","github"]}}const e=fn();if(e){const r=Lt(e);r&&(this.session=r,qe(e),this.startRefreshTimer())}this.session||await this.refreshSession()}catch(e){console.error("Failed to load Authifyer client",e)}finally{this.isLoading=!1,this.notifyListeners()}}async signInWithEmail(e,r){try{const n=await z.post("/authifyer/project/login/email",{email:e,password:r,publicProjectId:this.publishableKey});this.handleAuthResponse(n.data)}catch(n){throw n}}async signUpWithEmail(e,r){try{const n=await z.post("/authifyer/project/register/email",{email:e,password:r,publicProjectId:this.publishableKey});return this.handleAuthResponse(n.data),n.data}catch(n){throw n}}async verifyEmail(e,r){try{await z.post("/api/auth/verify-email",{token:e,subjectId:r})}catch(n){throw n}}async signOut(){try{const e=Je();await z.post("/authifyer/session/logout",{refresh_token:e||void 0})}catch(e){console.warn("Logout failed",e)}finally{this.clearSession()}}signInWithOAuth(e){const r=window.location.origin,n=`${z.defaults.baseURL}/oauth2/authorization/${e}?publishable_key=${this.publishableKey}&redirect_uri=${r}`;window.location.href=n}async refreshSession(){try{const e=Je();if(!e){this.clearSession();return}const r=await z.post("/authifyer/jwt/refresh-jwt",{refresh_token:e}),{access_token:n,refresh_token:s}=r.data;if(n){const o=n.accessToken||n;this.setSession(o)}s&&Ve(s)}catch{this.clearSession()}}async rotateSession(){try{const e=Je();await z.post("/authifyer/session/refresh",{refresh_token:e||void 0}),await this.refreshSession()}catch(e){console.warn("Session rotation failed",e),this.clearSession()}}handleAuthResponse(e){e.accessToken&&this.setSession(e.accessToken),(e.refreshToken||e.refresh_token)&&Ve(e.refreshToken||e.refresh_token)}setSession(e){const r=Lt(e);r&&(this.session=r,qe(e),this.startRefreshTimer(),this.notifyListeners())}clearSession(){this.session=null,qe(null),Ve(null),this.stopRefreshTimer(),this.notifyListeners()}startRefreshTimer(){this.stopRefreshTimer(),this.refreshTimer=setInterval(()=>{this.refreshSession()},270*1e3)}stopRefreshTimer(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=null)}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(r=>r!==e)}}notifyListeners(){this.listeners.forEach(e=>e(this))}}const Ut=R.createContext(void 0),yn=({publishableKey:t,backendUrl:e,config:r,children:n})=>{var f;const s=R.useMemo(()=>{const b=typeof process<"u"&&process.env&&(process.env.NEXT_PUBLIC_AUTHIFYER_PUBLISHABLE_KEY||process.env.REACT_APP_AUTHIFYER_PUBLISHABLE_KEY),h=t||b;h||console.error("AuthifyerProvider requires a publishableKey either passed as a prop or set as an environment variable (e.g. VITE_AUTHIFYER_PUBLISHABLE_KEY, NEXT_PUBLIC_AUTHIFYER_PUBLISHABLE_KEY, REACT_APP_AUTHIFYER_PUBLISHABLE_KEY).");const T=new mn(h||"",{backendUrl:e});return r&&(T.config=r),T},[t,e,r]),[o,i]=R.useState(((f=s.session)==null?void 0:f.user)||null),[c,p]=R.useState(s.session),[d,u]=R.useState(s.config),[y,w]=R.useState(s.isLoading);R.useEffect(()=>{const b=s.subscribe(h=>{var T;i(((T=h.session)==null?void 0:T.user)||null),p(h.session),r||u(h.config),w(h.isLoading)});return s.load(),()=>{b()}},[s,r]);const S={client:s,user:o,session:c,config:r||d,isLoading:y};return m.jsx(Ut.Provider,{value:S,children:n})},re=()=>{const t=R.useContext(Ut);if(t===void 0)throw new Error("useAuth must be used within an AuthifyerProvider");return t},bn=()=>{const{user:t,isLoading:e}=re();return{user:t,isLoading:e,isSignedIn:!!t}},gn=()=>{const{session:t,isLoading:e}=re();return{session:t,isLoading:e,isSignedIn:!!t}},En=()=>{const{client:t}=re();return t},Oe=({title:t,subtitle:e,children:r})=>m.jsx("div",{className:"authifyer-root",children:m.jsxs("div",{className:"authifyer-card",children:[m.jsxs("div",{className:"authifyer-card-header",children:[m.jsx("h2",{className:"authifyer-card-title",children:t}),e&&m.jsx("p",{className:"authifyer-card-subtitle",children:e})]}),m.jsx("div",{className:"authifyer-card-content",children:r}),m.jsxs("div",{className:"authifyer-footer",children:[m.jsx("span",{className:"authifyer-secured-text",children:"Secured by"}),m.jsxs("span",{className:"authifyer-brand",children:[m.jsx("svg",{className:"authifyer-logo-icon",viewBox:"0 0 24 24",fill:"currentColor",children:m.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"})}),"Authifyer"]})]})]})}),wn=()=>{const{client:t,config:e}=re(),[r,n]=R.useState(""),[s,o]=R.useState(""),[i,c]=R.useState(""),[p,d]=R.useState(!1),u=(e==null?void 0:e.emailPasswordEnabled)??!0,y=(e==null?void 0:e.oauthProviders)??["google","github"],w=async S=>{S.preventDefault(),d(!0),c("");try{await t.signInWithEmail(r,s)}catch{c("Invalid credentials")}finally{d(!1)}};return m.jsxs(Oe,{title:"Sign in",subtitle:"to continue to Authifyer",children:[i&&m.jsx("p",{className:"authifyer-error",children:i}),(y.includes("google")||y.includes("github"))&&m.jsxs("div",{className:"authifyer-form",children:[y.includes("google")&&m.jsxs("button",{className:"authifyer-provider-btn",onClick:()=>t.signInWithOAuth("google"),children:[m.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),m.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),m.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),m.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]}),y.includes("github")&&m.jsxs("button",{className:"authifyer-provider-btn",onClick:()=>t.signInWithOAuth("github"),children:[m.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:m.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.3 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),"Continue with GitHub"]})]}),(y.includes("google")||y.includes("github"))&&u&&m.jsx("div",{className:"authifyer-divider",children:"or"}),u&&m.jsxs("form",{onSubmit:w,className:"authifyer-form",children:[m.jsxs("div",{className:"authifyer-form-group",children:[m.jsx("label",{className:"authifyer-label",children:"Email address"}),m.jsx("input",{type:"email",className:"authifyer-input",value:r,onChange:S=>n(S.target.value),required:!0})]}),m.jsxs("div",{className:"authifyer-form-group",children:[m.jsx("label",{className:"authifyer-label",children:"Password"}),m.jsx("input",{type:"password",className:"authifyer-input",value:s,onChange:S=>o(S.target.value),required:!0})]}),m.jsx("button",{type:"submit",className:"authifyer-submit-btn",disabled:p,children:p?"Signing In...":"Continue"})]})]})},Rn=()=>{const{client:t,config:e}=re(),[r,n]=R.useState(""),[s,o]=R.useState(""),[i,c]=R.useState(""),[p,d]=R.useState(!1),[u,y]=R.useState(!1),[w,S]=R.useState(null),[f,b]=R.useState(""),[h,T]=R.useState(""),[v,O]=R.useState(!1),j=(e==null?void 0:e.emailPasswordEnabled)??!0,N=(e==null?void 0:e.oauthProviders)??["google","github"],q=async I=>{I.preventDefault(),d(!0),c("");try{const F=await t.signUpWithEmail(r,s);F!=null&&F.subjectId?S(F.subjectId):y(!0)}catch{c("Registration failed. User might already exist.")}finally{d(!1)}},U=async I=>{if(I.preventDefault(),!!w){O(!0),T("");try{await t.verifyEmail(f,w),S(null),y(!0)}catch{T("Invalid authorization code. Please try again.")}finally{O(!1)}}};return u?m.jsx(Oe,{title:"Welcome!",children:m.jsxs("div",{className:"authifyer-success",children:[m.jsx("svg",{className:"authifyer-success-icon",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),m.jsxs("div",{children:[m.jsx("h3",{className:"authifyer-success-title",children:"Success"}),m.jsx("p",{className:"authifyer-success-text",children:"Application authenticated. You are now logged in."})]})]})}):w?m.jsxs(Oe,{title:"Verify your email",subtitle:`Code sent to ${r}`,children:[h&&m.jsx("p",{className:"authifyer-error",children:h}),m.jsxs("form",{onSubmit:U,className:"authifyer-form",children:[m.jsxs("div",{className:"authifyer-form-group",children:[m.jsx("label",{className:"authifyer-label",style:{textAlign:"center"},children:"Enter 6-digit Code"}),m.jsx("input",{type:"text",maxLength:6,className:"authifyer-input",style:{textAlign:"center",letterSpacing:"0.25em",fontSize:"1.25rem",fontWeight:600},value:f,onChange:I=>b(I.target.value.replace(/\D/g,"")),required:!0})]}),m.jsx("button",{type:"submit",className:"authifyer-submit-btn",disabled:v||f.length<6,children:v?"Verifying...":"Verify Code"}),m.jsx("button",{type:"button",className:"authifyer-provider-btn",style:{marginTop:"0.5rem",border:"none",background:"transparent",color:"#666"},onClick:()=>{S(null),b("")},children:"Back to Sign Up"})]})]}):m.jsxs(Oe,{title:"Create your account",subtitle:"Welcome to Authifyer",children:[i&&m.jsx("p",{className:"authifyer-error",children:i}),(N.includes("google")||N.includes("github"))&&m.jsxs("div",{className:"authifyer-form",children:[N.includes("google")&&m.jsxs("button",{className:"authifyer-provider-btn",onClick:()=>t.signInWithOAuth("google"),children:[m.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),m.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),m.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),m.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]}),N.includes("github")&&m.jsxs("button",{className:"authifyer-provider-btn",onClick:()=>t.signInWithOAuth("github"),children:[m.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor",children:m.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.3 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),"Continue with GitHub"]})]}),(N.includes("google")||N.includes("github"))&&j&&m.jsx("div",{className:"authifyer-divider",children:"or"}),j&&m.jsxs("form",{onSubmit:q,className:"authifyer-form",children:[m.jsxs("div",{className:"authifyer-form-group",children:[m.jsx("label",{className:"authifyer-label",children:"Email address"}),m.jsx("input",{type:"email",className:"authifyer-input",value:r,onChange:I=>n(I.target.value),required:!0})]}),m.jsxs("div",{className:"authifyer-form-group",children:[m.jsx("label",{className:"authifyer-label",children:"Password"}),m.jsx("input",{type:"password",className:"authifyer-input",value:s,onChange:I=>o(I.target.value),required:!0})]}),m.jsx("button",{type:"submit",className:"authifyer-submit-btn",disabled:p,children:p?"Signing Up...":"Continue"})]})]})};C.AuthifyerProvider=yn,C.SignIn=wn,C.SignUp=Rn,C.useAuth=re,C.useAuthifyer=En,C.useSession=gn,C.useUser=bn,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
package/src/core/client.ts
CHANGED
|
@@ -88,7 +88,7 @@ export class AuthifyerClient {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
public async signUpWithEmail(email: string, password: string): Promise<
|
|
91
|
+
public async signUpWithEmail(email: string, password: string): Promise<any> {
|
|
92
92
|
try {
|
|
93
93
|
const response = await api.post('/authifyer/project/register/email', {
|
|
94
94
|
email,
|
|
@@ -96,6 +96,20 @@ export class AuthifyerClient {
|
|
|
96
96
|
publicProjectId: this.publishableKey,
|
|
97
97
|
});
|
|
98
98
|
this.handleAuthResponse(response.data);
|
|
99
|
+
return response.data;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public async verifyEmail(token: string, subjectId: string): Promise<void> {
|
|
106
|
+
try {
|
|
107
|
+
await api.post('/api/auth/verify-email', {
|
|
108
|
+
token,
|
|
109
|
+
subjectId
|
|
110
|
+
});
|
|
111
|
+
// On success, the backend verified the email.
|
|
112
|
+
// The session is already established from signUpWithEmail.
|
|
99
113
|
} catch (error) {
|
|
100
114
|
throw error;
|
|
101
115
|
}
|
|
@@ -103,7 +117,10 @@ export class AuthifyerClient {
|
|
|
103
117
|
|
|
104
118
|
public async signOut(): Promise<void> {
|
|
105
119
|
try {
|
|
106
|
-
|
|
120
|
+
const currentRefreshToken = getRefreshToken();
|
|
121
|
+
await api.post('/authifyer/session/logout', {
|
|
122
|
+
refresh_token: currentRefreshToken || undefined
|
|
123
|
+
});
|
|
107
124
|
} catch (e) {
|
|
108
125
|
console.warn("Logout failed", e);
|
|
109
126
|
} finally {
|
|
@@ -125,9 +142,16 @@ export class AuthifyerClient {
|
|
|
125
142
|
try {
|
|
126
143
|
const currentRefreshToken = getRefreshToken();
|
|
127
144
|
|
|
145
|
+
if (!currentRefreshToken) {
|
|
146
|
+
// If there is no refresh token natively available, we cannot refresh.
|
|
147
|
+
// Avoid calling the backend to prevent unnecessary 401 Unauthorized errors.
|
|
148
|
+
this.clearSession();
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
128
152
|
// Retrieve new short-lived JWT using the refresh_token from local storage
|
|
129
153
|
const response = await api.post('/authifyer/jwt/refresh-jwt', {
|
|
130
|
-
refresh_token: currentRefreshToken
|
|
154
|
+
refresh_token: currentRefreshToken
|
|
131
155
|
});
|
|
132
156
|
|
|
133
157
|
const { access_token, refresh_token } = response.data;
|
|
@@ -10,6 +10,12 @@ export const SignUp: React.FC = () => {
|
|
|
10
10
|
const [isLoading, setIsLoading] = useState(false);
|
|
11
11
|
const [success, setSuccess] = useState(false);
|
|
12
12
|
|
|
13
|
+
// OTP State
|
|
14
|
+
const [otpTargetId, setOtpTargetId] = useState<string | null>(null);
|
|
15
|
+
const [otpToken, setOtpToken] = useState('');
|
|
16
|
+
const [otpError, setOtpError] = useState('');
|
|
17
|
+
const [isVerifying, setIsVerifying] = useState(false);
|
|
18
|
+
|
|
13
19
|
// Defaults if config is missing
|
|
14
20
|
const showEmailPass = config?.emailPasswordEnabled ?? true;
|
|
15
21
|
const providers = config?.oauthProviders ?? ['google', 'github'];
|
|
@@ -19,8 +25,13 @@ export const SignUp: React.FC = () => {
|
|
|
19
25
|
setIsLoading(true);
|
|
20
26
|
setError('');
|
|
21
27
|
try {
|
|
22
|
-
await client.signUpWithEmail(email, password);
|
|
23
|
-
|
|
28
|
+
const data = await client.signUpWithEmail(email, password);
|
|
29
|
+
// After successful creation, we need to verify OTP
|
|
30
|
+
if (data?.subjectId) {
|
|
31
|
+
setOtpTargetId(data.subjectId);
|
|
32
|
+
} else {
|
|
33
|
+
setSuccess(true); // Fallback if no subjectId returned
|
|
34
|
+
}
|
|
24
35
|
} catch (err) {
|
|
25
36
|
setError('Registration failed. User might already exist.');
|
|
26
37
|
} finally {
|
|
@@ -28,6 +39,24 @@ export const SignUp: React.FC = () => {
|
|
|
28
39
|
}
|
|
29
40
|
};
|
|
30
41
|
|
|
42
|
+
const handleOtpVerify = async (e: React.FormEvent) => {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
if (!otpTargetId) return;
|
|
45
|
+
|
|
46
|
+
setIsVerifying(true);
|
|
47
|
+
setOtpError('');
|
|
48
|
+
try {
|
|
49
|
+
await client.verifyEmail(otpToken, otpTargetId);
|
|
50
|
+
// Verification successful, proceed to success UI
|
|
51
|
+
setOtpTargetId(null);
|
|
52
|
+
setSuccess(true);
|
|
53
|
+
} catch (err) {
|
|
54
|
+
setOtpError('Invalid authorization code. Please try again.');
|
|
55
|
+
} finally {
|
|
56
|
+
setIsVerifying(false); // Enable the button again
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
31
60
|
if (success) {
|
|
32
61
|
return (
|
|
33
62
|
<AuthBox title="Welcome!">
|
|
@@ -37,13 +66,49 @@ export const SignUp: React.FC = () => {
|
|
|
37
66
|
</svg>
|
|
38
67
|
<div>
|
|
39
68
|
<h3 className="authifyer-success-title">Success</h3>
|
|
40
|
-
<p className="authifyer-success-text">
|
|
69
|
+
<p className="authifyer-success-text">Application authenticated. You are now logged in.</p>
|
|
41
70
|
</div>
|
|
42
71
|
</div>
|
|
43
72
|
</AuthBox>
|
|
44
73
|
);
|
|
45
74
|
}
|
|
46
75
|
|
|
76
|
+
if (otpTargetId) {
|
|
77
|
+
return (
|
|
78
|
+
<AuthBox title="Verify your email" subtitle={`Code sent to ${email}`}>
|
|
79
|
+
{otpError && <p className="authifyer-error">{otpError}</p>}
|
|
80
|
+
<form onSubmit={handleOtpVerify} className="authifyer-form">
|
|
81
|
+
<div className="authifyer-form-group">
|
|
82
|
+
<label className="authifyer-label" style={{ textAlign: 'center' }}>Enter 6-digit Code</label>
|
|
83
|
+
<input
|
|
84
|
+
type="text"
|
|
85
|
+
maxLength={6}
|
|
86
|
+
className="authifyer-input"
|
|
87
|
+
style={{ textAlign: 'center', letterSpacing: '0.25em', fontSize: '1.25rem', fontWeight: 600 }}
|
|
88
|
+
value={otpToken}
|
|
89
|
+
onChange={e => setOtpToken(e.target.value.replace(/\D/g, ''))} // only digits
|
|
90
|
+
required
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
<button type="submit" className="authifyer-submit-btn" disabled={isVerifying || otpToken.length < 6}>
|
|
94
|
+
{isVerifying ? 'Verifying...' : 'Verify Code'}
|
|
95
|
+
</button>
|
|
96
|
+
<button
|
|
97
|
+
type="button"
|
|
98
|
+
className="authifyer-provider-btn"
|
|
99
|
+
style={{ marginTop: '0.5rem', border: 'none', background: 'transparent', color: '#666' }}
|
|
100
|
+
onClick={() => {
|
|
101
|
+
setOtpTargetId(null); // allow going back
|
|
102
|
+
setOtpToken('');
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
105
|
+
Back to Sign Up
|
|
106
|
+
</button>
|
|
107
|
+
</form>
|
|
108
|
+
</AuthBox>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
47
112
|
return (
|
|
48
113
|
<AuthBox title="Create your account" subtitle="Welcome to Authifyer">
|
|
49
114
|
{error && <p className="authifyer-error">{error}</p>}
|