@arcana/auth
Advanced tools
Comparing version 1.0.9 to 1.0.10-rc.1
@@ -1,1 +0,1 @@ | ||
import{_ as e,P as t,Q as n,S as i,T as o,U as r,V as s,W as a,X as l,Y as d,Z as c,$ as h,a0 as g}from"./vendor.chunk.js";class u extends Error{constructor(e,t){super(e),this.message=t,this.message=`[XAR_AUTH_SDK] error: [${e}] ${t}`}}const p=new u("user_not_logged_in","User is not logged in"),m=new u("wallet_not_initialized","AuthProvider is not initialized. Please run `await auth.init(...)` before calling functions"),f=new class{constructor(e,t){this.message=`[XAR_AUTH_SDK] warning: [${e}] ${t}`}log(){console.warn(this.message)}}("duplicate_iframe","Duplicate iframe detected, please keep a single instance of AuthProvider"),v=1,w=2,y=3,x=4,b=5,_=e=>{O.exceptionReporter&&O.exceptionReporter(e)},C=e=>{O.logLevel=e},I=()=>O.logger;const O={logger:new class{constructor(){this.prefix="[XAR_AUTH_SDK]"}info(e,t={}){this.internalLog(w,e,t)}debug(e,t={}){this.internalLog(v,e,t)}warn(e,t={}){this.internalLog(y,e,t)}error(e,t){if(t instanceof Error)return this.internalLog(x,e,t.message),void _(JSON.stringify({message:e,error:t.message}));"string"==typeof t&&(this.internalLog(x,e,t),_(JSON.stringify({message:e,error:t})))}internalLog(e,t,n){const i=`${this.prefix}\nMessage: ${t} \nParams: ${JSON.stringify(n)}`;this.consoleLog(e,i)}consoleLog(e,t){if(!(e<O.logLevel))switch(e){case v:console.debug(t);break;case y:console.warn(t);break;case x:console.error(t);break;case w:console.info(t);break;default:console.log(t)}}},logLevel:b,exceptionReporter:null};class S{constructor(e){this.url=e,this.requestHandler=()=>new Promise((e=>{let n=!1;const i=window.setInterval((()=>{var t;try{if(!n&&(null===(t=this.window)||void 0===t?void 0:t.closed))return e({id:1,jsonrpc:"2.0",error:"user_closed_popup"})}catch(e){}}),500),o=r=>t(this,void 0,void 0,(function*(){var t;if("json_rpc_response"==r.data.type)return n=!0,this.clear(o,i),null===(t=this.window)||void 0===t||t.close(),e(r.data.response)}));window.addEventListener("message",o,!1)}))}open(){const e=T();return this.window=window.open(this.url,"_blank",e),this.getWindowResponse()}getWindowResponse(){return new Promise(((e,n)=>{let i=!1;const o=window.setInterval((()=>{var e;!i&&(null===(e=this.window)||void 0===e?void 0:e.closed)&&n("User closed the popup")}),500),r=s=>t(this,void 0,void 0,(function*(){var t,a,l;if(!(null===(t=null==s?void 0:s.data)||void 0===t?void 0:t.status))return;const d=s.data;return i=!0,this.clear(r,o),"success"===d.status?(null===(a=this.window)||void 0===a||a.close(),e("success")):"error"==d.status?(null===(l=this.window)||void 0===l||l.close(),n(d.error)):"done"===d.status?e("done"):void console.log("Unexpected event")}));window.addEventListener("message",r,!1)}))}clear(e,t){window.removeEventListener("message",e),window.clearInterval(t)}}const k={titlebar:0,toolbar:0,status:0,menubar:0,resizable:0,height:1200,width:700,popup:1},T=()=>{const e=[];for(const t in k)e.push(`${t}=${k[t]}`);return e.join(",")};class E{constructor(n){this.url=n,this.requestCount=0,this.emitter=new e,this.ready=!1,this.cleanExit=!1,this.requestHandler=e=>new Promise((t=>{this.cleanExit=!1;const n=window.setInterval((()=>{var i;try{(null===(i=this.window)||void 0===i?void 0:i.closed)&&(this.cleanExit||this.emitter.emit(e,{id:e,jsonrpc:"2.0",error:"user_closed_popup"}),window.clearInterval(n),t("ok"))}catch(e){}}),500)})),this.handler=e=>t(this,void 0,void 0,(function*(){"json_rpc_response"==e.data.type&&(this.cleanExit=!0,this.emitter.emit(e.data.response.id,e.data.response))}))}sendRequest(e){return t(this,void 0,void 0,(function*(){if(this.window||(this.ready=!1,this.requestCount=0,this.window=window.open(this.url,"_blank",T()),yield P(),window.addEventListener("message",this.handler,!1)),this.window){this.requestCount++,this.window.postMessage({type:"json_rpc_request",data:e},this.url),this.window.focus(),this.requestHandler(String(e.request.id));return yield new Promise((t=>this.emitter.once(String(e.request.id),(e=>{var n;return this.requestCount--,this.requestCount<=0&&(window.removeEventListener("message",this.handler),null===(n=this.window)||void 0===n||n.close(),this.window=null),t(e)}))))}throw Error("error while opening popup")}))}}const P=()=>new Promise((e=>{const t=n=>{"READY_TO_RECEIVE"===n.data.type&&(window.removeEventListener("message",t),e("ok"))};window.addEventListener("message",t,!1)})),L="data:image/svg+xml,%3Csvg width='116' height='116' viewBox='0 0 116 116' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M115.341 58.0094C115.341 89.6796 89.6673 115.354 57.9967 115.354C26.3265 115.354 0.652344 89.6796 0.652344 58.0094C0.652344 26.3392 26.3265 0.665039 57.9967 0.665039C89.6673 0.665039 115.341 26.3392 115.341 58.0094Z' fill='%23B43030'/%3E%3Cpath d='M78.7969 37.2041L37.1953 78.8057' stroke='white' stroke-width='5.74' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M78.7969 78.8057L37.1953 37.2041' stroke='white' stroke-width='5.74' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A",N=e=>"string"==typeof e&&e.trim().length>0,R=e=>40===U(e).length,A="0x",U=e=>e.startsWith(A)?e.substring(2):e,j=(e,t=!0)=>{const n=e.toString(16);return t?(i=n).startsWith(A)?i:A+i:U(n);var i},D=()=>window.location.origin+window.location.pathname,W=4294967295;let M=Math.floor(Math.random()*W);function $(e){return String.fromCharCode(parseInt(e.slice(1),16))}function q(e){return t=JSON.stringify(e),window.btoa(encodeURIComponent(t).replace(/%[0-9A-F]{2}/g,$));var t}class z extends Error{constructor(e,t,n=""){super(t),this.code=e,this.message=t,this.data=n}}const F=["eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData_v3","eth_signTypedData_v4","personal_sign","eth_decrypt"];class K extends e{constructor(t){super(),this.authUrl=t,this.connected=!1,this.logger=I(),this.onResponse=(e,t)=>{this.subscriber.emit(`result:${e}:${t.id}`,t)},this.handleEvents=(e,t)=>{switch(e){case G.ACCOUNTS_CHANGED:this.emit(e,[t]);break;case G.CHAIN_CHANGED:this.setChainId(t),this.emit(e,j(t.chainId));break;case G.CONNECT:this.chainId="object"==typeof t?t.chainId:"",this.connected=!0,this.emit(e,t);break;case G.DISCONNECT:this.iframe.handleDisconnect(),this.connected=!1,this.emit(e,t);break;case G.MESSAGE:console.log({t:e,val:t}),this.emit(e,t)}},this.subscriber=new e}isArcana(){return!0}init(e,n){return t(this,void 0,void 0,(function*(){this.auth=n,this.popup=new E(this.createRequestUrl(n.appId)),this.iframe=e;const{communication:t}=yield this.iframe.setConnectionMethods({onEvent:this.handleEvents,onMethodResponse:this.onResponse,getParentUrl:D,getAppMode:()=>this.iframe.appMode,getAppConfig:this.iframe.getAppConfig,getWalletPosition:this.iframe.getWalletPlace,getRpcConfig:()=>{},sendPendingRequestCount:this.iframe.onReceivingPendingRequestCount,triggerSocialLogin:n.loginWithSocial,triggerPasswordlessLogin:n.loginWithLink,getPopupState:()=>this.iframe.getState(),setIframeStyle:this.iframe.setIframeStyle,setSessionID:this.iframe.setSessionID,getSDKVersion:()=>"v3"});this.communication=t}))}isLoggedIn(){return t(this,void 0,void 0,(function*(){try{return(yield this.getCommunication("isLoggedIn")).isLoggedIn()}catch(e){return this.logger.error("isLoggedIn",e),!1}}))}connect(){return this.auth.connect()}isConnected(){return t(this,void 0,void 0,(function*(){return this.connected}))}isLoginAvailable(e){return t(this,void 0,void 0,(function*(){const t=yield this.getCommunication("isLoginAvailable"),n=yield t.isLoginAvailable(e);return this.logger.debug("loginAvailable",{[e]:n}),n}))}requestUserInfo(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("getUserInfo");if(!(yield e.isLoggedIn()))throw p;return yield e.getUserInfo()}))}getReconnectionUrl(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("getReconnectionUrl");return yield e.getReconnectionUrl()}))}initOTPLogin(e){return t(this,void 0,void 0,(function*(){const t=yield this.getCommunication("initOTPLogin");return yield t.initOTPLogin(e)}))}completeOTPLogin(e){return t(this,void 0,void 0,(function*(){const t=yield this.getCommunication("completeOTPLogin");yield t.completeOTPLogin(e)}))}getPublicKey(e,n){return t(this,void 0,void 0,(function*(){return(yield this.getCommunication("getPublicKey")).getPublicKey(e,n)}))}getAvailableLogins(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("getAvailableLogins");return yield e.getAvailableLogins()}))}triggerLogout(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("triggerLogout");yield e.triggerLogout(!0)}))}initPasswordlessLogin(e){return t(this,void 0,void 0,(function*(){const t=yield this.getCommunication("initPasswordlessLogin");return yield t.initPasswordlessLogin(e)}))}initSocialLogin(e){return t(this,void 0,void 0,(function*(){const t=yield this.getCommunication("initSocialLogin");return yield t.initSocialLogin(e)}))}expandWallet(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("expandWallet");return yield e.expandWallet()}))}getKeySpaceConfigType(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("getKeySpaceConfigType");return yield e.getKeySpaceConfigType()}))}getCommunication(e="sendRequest"){return t(this,void 0,void 0,(function*(){if(this.communication){const t=yield this.communication.promise;if(!t[e])throw new u("fn_not_available",`The requested fn ${e} is not available in this context`);return t}throw new u("connection_not_available","The connection is not available yet")}))}request(e){return t(this,void 0,void 0,(function*(){if(!e||"object"!=typeof e||Array.isArray(e))throw n.ethErrors.rpc.invalidRequest({message:"Invalid request arguments",data:e});const{method:i,params:o}=e;if(!i)throw n.ethErrors.rpc.invalidRequest({message:"Invalid method argument",data:e});const r={method:i,params:o,jsonrpc:"2.0",id:(M=(M+1)%W,M)},s=yield this.getKeySpaceConfigType(),a=yield this.getCommunication("addToActivity");return new Promise(((e,n)=>{F.includes(i)&&"global"===s?(this.popup.sendRequest({chainId:this.chainId,request:r}).then((t=>{const i=t.error;if(!i){const n=t.result;return a.addToActivity({req:r,result:n,chainId:this.chainId}),e(n)}if(a.addToActivity({req:r,error:i,chainId:this.chainId}),"user_closed_popup"!==i)return n(B(i))})),this.getCommunication().then((o=>t(this,void 0,void 0,(function*(){this.getResponse(i,r.id).then(e,n),yield o.sendRequest(r,"auth-verify")}))),n)):this.getCommunication().then((o=>t(this,void 0,void 0,(function*(){this.getResponse(i,r.id).then(e,n),yield o.sendRequest(r)}))),n)}))}))}getResponse(e,t){return new Promise(((n,i)=>{this.subscriber.once(`result:${e}:${t}`,(e=>e.error?i(B(e.error)):n(e.result)))}))}createRequestUrl(e){return new URL(`/${e}/permission/`,this.authUrl).href}setChainId(e){e&&"object"==typeof e&&"chainId"in e&&"number"==typeof e.chainId&&(this.chainId=j(e.chainId))}}const G={ACCOUNTS_CHANGED:"accountsChanged",CHAIN_CHANGED:"chainChanged",CONNECT:"connect",DISCONNECT:"disconnect",MESSAGE:"message"},B=e=>{switch(I().error("getError",e),e){case"user_deny":return new z(4001,"User rejected the request.");case"user_closed_popup":return new z(4001,"User closed the popup.");case"operation_not_supported":return new z(4200,"The requested method is not supported by this provider.");case"all_disconnected":return new z(4900,"The provider is disconnected from all chains. Login is pending.");default:return"string"!=typeof e?new z(e.code,e.message,e.data):n.ethErrors.rpc.internal(e)}};var H,V,J,X;!function(e){e[e.CREATED=0]="CREATED",e[e.RUNNING=1]="RUNNING",e[e.DONE=2]="DONE"}(H||(H={})),function(e){e.evm_secp256k1="evm_secp256k1",e.solana_cv25519="solana_cv25519"}(V||(V={})),function(e){e.firebase="firebase"}(J||(J={})),function(e){e[e.NoUI=0]="NoUI",e[e.Widget=1]="Widget",e[e.Full=2]="Full"}(X||(X={}));const Y={border:"none",position:"fixed",height:0,width:0,right:0,bottom:0,zIndex:2147483648},Z="xar-wallet";class Q{constructor(e){this.params=e,this.getSessionID=()=>{const e=window.localStorage.getItem(`arcana-auth-${this.getIframeUrl()}-sessionID`);return e?JSON.parse(e):null},this.setSessionID=(e,t)=>{window.localStorage.setItem(`arcana-auth-${this.getIframeUrl()}-sessionID`,JSON.stringify({id:e,expiry:t}))},this.clearSessionID=()=>{window.localStorage.removeItem(`arcana-auth-${this.getIframeUrl()}-sessionID`)},this.setIframeStyle=e=>{var t;if(1==(null===(t=this.params.standaloneMode)||void 0===t?void 0:t.mode))this.widgetIframe.style.height=e.height?e.height:"80vh",this.widgetIframe.style.maxWidth="100%",this.widgetIframe.style.width="430px",this.widgetIframe.style.bottom="0",this.widgetIframe.style.right="0";else for(const t in e)this.widgetIframe.style[t]=e[t]},this.getWalletPlace=()=>this.params.position,this.getAppConfig=()=>this.params.appConfig,this.checkDuplicateIframe(),this.checkSecureOrigin()}setConnectionMethods(e){return t(this,void 0,void 0,(function*(){try{return this.iframeCommunication||(this.iframeCommunication=i({iframe:this.widgetIframe,methods:Object.assign(Object.assign({},e),{uiEvent:(e,t)=>{var n;(null===(n=this.params.standaloneMode)||void 0===n?void 0:n.handler)&&this.params.standaloneMode.handler(e,t)}}),childOrigin:this.params.iframeUrl}),yield this.iframeCommunication.promise),{iframe:this.widgetIframe,communication:this.iframeCommunication}}catch(e){throw new Error("Could not set connection methods")}}))}triggerBearerAuthentication(e,n){return t(this,void 0,void 0,(function*(){return(yield this.iframeCommunication.promise).triggerBearerLogin(e,n)}))}setWalletType(e){this.appMode=null!=e?e:X.Full,this.initWalletUI()}getState(){return this.state}handleDisconnect(){this.widgetIframe.src=this.getIframeUrl(),this.clearSessionID()}onReceivingPendingRequestCount(e){const t=document.getElementById("req-count-badge");t&&(e>0?(t.style.display="flex",t.textContent=`${e}`):t.style.display="none")}getIframeUrl(){var e,t;const n=q({standaloneMode:(null===(e=this.params.standaloneMode)||void 0===e?void 0:e.mode)?null===(t=this.params.standaloneMode)||void 0===t?void 0:t.mode:0}),i=new URL(`/${this.params.appId}/v2/login`,this.params.iframeUrl);return i.hash=n,i.toString()}createWidgetIframe(){return((e,t,...n)=>{const i=document.createElement(e);t&&(Object.assign(i,t),t.style&&Object.assign(i.style,t.style));for(const e of n)"string"!=typeof e?i.appendChild(e):i.appendChild(document.createTextNode(e));return i})("iframe",{style:Y,src:this.getIframeUrl(),allow:"clipboard-write",className:Z})}checkDuplicateIframe(){[].slice.call(document.querySelectorAll(`.${Z}`)).length>0&&f.log()}initWalletUI(){this.widgetIframe=this.createWidgetIframe(),document.body.appendChild(this.widgetIframe)}checkSecureOrigin(){const e="localhost"===location.hostname||"127.0.0.1"===location.hostname,t="https:"===location.protocol;if(!(e||t))throw new Error("Insecure origin")}}const ee={authUrl:"https://verify.dev.arcana.network",gatewayUrl:"https://gateway-dev.arcana.network",walletUrl:"https://wallet.dev.arcana.network"},te={authUrl:"https://verify.beta.arcana.network",gatewayUrl:"https://gateway001-testnet.arcana.network",walletUrl:"https://wallet.beta.arcana.network"},ne={authUrl:"https://auth.arcana.network",gatewayUrl:"https://gateway.arcana.network",walletUrl:"https://wallet.arcana.network"};function ie(e,n){return t(this,void 0,void 0,(function*(){const t=new URL(`/api/v1/get-app-theme/?id=${e}`,n);return yield(yield fetch(t.toString())).json()}))}function oe(e,n){return t(this,void 0,void 0,(function*(){const t=new URL(`/api/v1/get-app-config/?id=${e}`,n);return yield(yield fetch(t.toString())).json()}))}const re="https://auth-icons.s3.ap-south-1.amazonaws.com",se={google:`${re}/google.png`,twitter:`${re}/twitter.png`,github:`${re}/github-light.png`,github_light:`${re}/github.png`,twitch:`${re}/twitch.png`,discord:`${re}/discord.png`,aws:`${re}/aws.png`,aws_light:`${re}/aws_light.png`,steam:`${re}/steam.png`};const ae={light:`${re}/secured-by-arcana-light.svg`,dark:`${re}/secured-by-arcana-dark.svg`};function le(e){const t=e.width?e.width:e.compact?60:80,{stroke:n=8,secondaryColor:i}=e;return o("div",Object.assign({"aria-label":"oval-loading"},{children:o("svg",Object.assign({width:t,height:t,viewBox:de(Number(n),20),xmlns:"http://www.w3.org/2000/svg",className:"xar-loader-circle","data-testid":"oval-svg"},{children:o("g",Object.assign({fill:"none",fillRule:"evenodd"},{children:o("g",Object.assign({transform:"translate(1 1)","stroke-width":n,"data-testid":"oval-secondary-group"},{children:[o("circle",{strokeOpacity:".5",cx:"0",cy:"0",r:20,stroke:i,"stroke-width":n,opacity:.3}),o("path",Object.assign({d:ce(20),stroke:e.strokeColor},{children:o("animateTransform",{attributeName:"transform",type:"rotate",from:"0 0 0",to:"360 0 0",dur:"1s",repeatCount:"indefinite"})}))]}))}))}))}))}const de=(e,t)=>{const n=-t-e/2+1,i=2*t+e;return[n,n,i,i].join(" ")},ce=e=>["M"+e+" 0c0-9.94-8.06",e,e,e].join("-");r("@import url('https://fonts.googleapis.com/css2?family=Sora:wght@100;400;600;700&display=block');\n@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Sora:wght@400;600&display=block');\n\n.xar-light-mode {\n --fg: #333333;\n --bg: #eff1f3;\n --background: #fcfcfc;\n --inputShadow: 0 0 8px 3px rgba(126, 126, 126, 0.25);\n --text-color: #101010;\n --otp-bg: #eeeeee;\n --otp-shadow: 1px 1px 2px 0px #aeaec033 inset,\n -1px -1px 1px 0px #ffffffb2 inset;\n}\n\n.xar-dark-mode {\n --fg: #ffffff;\n --bg: #313131;\n --background: #262626;\n --inputShadow: 0 0 8px 3px rgba(0, 0, 0, 0.05);\n --text-color: #f7f7f7;\n --otp-bg: linear-gradient(141.48deg, #161616 -4.56%, #151515 135.63%);\n --otp-shadow: -50px 49px 29px 22px #1c1c1cd6 inset,\n 5px 5px 10px 0px #0b0b0b80 inset;\n}\n\n.compact {\n --modal-height: 235px;\n --loader-font-size: 14px;\n --loader-font-weight: 400;\n --success-img-width: 70px;\n --action-link-size: 12px;\n}\n\n.full {\n --modal-height: 480px;\n --loader-font-size: 20px;\n --loader-font-weight: 700;\n --success-img-width: 100px;\n --action-link-size: 15px;\n}\n\n#xar-modal {\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n z-index: 2147483648;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n overflow: auto;\n background: rgba(10, 10, 10, 0.7);\n backdrop-filter: blur(16px);\n font-family: Sora, sans-serif;\n}\n\n.xar-header-logo__container {\n width: 70px;\n height: 70px;\n border-radius: 50%;\n margin: 0 auto;\n display: flex;\n align-items: center;\n justify-content: center;\n border: 2px solid var(--fg);\n}\n\n.xar-header-logo__empty-container {\n width: 70px;\n height: 70px;\n border-radius: 50%;\n margin: 0 auto;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.xar-header-logo {\n max-width: 60px;\n max-height: 60px;\n margin: 0 auto;\n display: inline-block;\n}\n\n.xar-header-heading {\n font-family: 'Sora', sans-serif;\n text-align: center;\n}\n\n.xar-header-subtext {\n font-family: 'Sora', sans-serif;\n font-size: 12px;\n font-weight: 400;\n max-width: 200px;\n}\n\n.xar-email-login {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n\n.xar-email-login > *:not(:first-child) {\n margin-top: 20px;\n}\n\n.xar-email-login__label {\n text-align: left;\n font-size: 14px;\n color: var(--fg);\n font-weight: 400;\n}\n\n.xar-success__img {\n max-width: var(--success-img-width);\n}\n\n.xar-email-login__input {\n height: 45px;\n padding: 0 16px;\n font-family: 'Sora', sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: var(--fg);\n background: var(--bg);\n border: none;\n border-radius: 5px;\n outline: none;\n box-shadow: var(--inputShadow);\n}\n\n.xar-social-container {\n display: flex;\n justify-content: center;\n gap: 1rem;\n flex-wrap: wrap;\n}\n\n.xar-social-icon__wrapper {\n display: flex;\n background: var(--fg);\n width: 42px;\n height: 42px;\n border-radius: 50%;\n align-items: center;\n}\n\n.xar-social-icon__wrapper:hover {\n cursor: pointer;\n transition: all 0.5s;\n transform: scale(1.15, 1.15);\n}\n\n.xar-social-icon {\n margin: 0 auto;\n width: 24px;\n max-height: 24px;\n}\n\n.xar-container {\n padding: 30px 30px 20px;\n width: 325px;\n min-height: var(--modal-height);\n background-color: var(--background);\n color: var(--fg);\n margin: 0 auto;\n font-family: 'Sora', sans-serif;\n box-shadow: 4px 5px 4px rgba(0, 0, 0, 0.25);\n border-radius: 10px;\n box-sizing: content-box;\n transition: all 1s ease;\n}\n\n.xar-inner-container {\n min-height: inherit;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n text-align: center;\n}\n\n.xar-inner-container > *:not(:first-child) {\n margin-top: 20px;\n}\n\n.xar-btn {\n margin: 0 auto;\n padding: 0;\n width: 100%;\n height: 2.75rem;\n font-size: 14px;\n font-weight: 600;\n text-transform: uppercase;\n color: var(--bg);\n background: var(--fg);\n border: none;\n border-radius: 5px;\n}\n\n.xar-btn:disabled {\n opacity: 0.7;\n}\n\n.xar-btn:hover:enabled {\n cursor: pointer;\n transition: all 0.5s;\n transform: scale(1.05, 1.15);\n}\n\n.xar-btn:disabled,\n.xar-btn[disabled] {\n cursor: not-allowed;\n}\n\n.xar-footer {\n display: flex;\n align-items: center;\n justify-content: center;\n margin-top: 1rem;\n}\n\n.xar-footer-text {\n font-size: 12px;\n font-weight: 400;\n}\n\n.xar-footer-img__link {\n height: 15px;\n}\n\n.xar-footer-img {\n display: block;\n}\n\n.xar-separator {\n width: 100%;\n display: flex;\n align-items: center;\n text-align: center;\n}\n\n.xar-separator:before,\n.xar-separator:after {\n content: '';\n flex: 1 1 auto;\n border-bottom: 1px solid var(--fg);\n}\n\n.xar-separator:before {\n margin-right: 1rem;\n}\n\n.xar-separator:after {\n margin-left: 1rem;\n}\n\n.xar-action__link {\n border: 0;\n background: none;\n text-underline-offset: 3px;\n text-transform: uppercase;\n text-decoration: underline;\n color: #3e9aff;\n font-weight: 700;\n font-size: var(--action-link-size);\n line-height: 19px;\n cursor: pointer;\n}\n\n.xar-action__link:disabled {\n color: #667b91;\n cursor: not-allowed;\n}\n\n.xar-loader__text {\n font-size: var(--loader-font-size);\n font-weight: var(--loader-font-weight);\n}\n\n.xar-loader-circle {\n stroke: var(--fg);\n}\n\n.xar-otp-box {\n display: flex;\n gap: 0.5em;\n}\n\n.xar-otp-input {\n color: var(--fg);\n font-size: 20px;\n font-weight: 400;\n border: none;\n outline: none;\n text-align: center;\n width: 30px;\n height: 35px;\n border-radius: 10px;\n background: var(--otp-bg);\n box-shadow: var(--otp-shadow);\n}\n\n.xar-invalid-otp {\n border: 1px solid #b43030;\n}\n\n.xar-invalid-otp-text {\n color: #b43030;\n}\n\n.xar-otp-input:disabled {\n opacity: 0.5;\n}\n\n.xar-otp-heading {\n font-family: 'Montserrat', sans-serif;\n font-size: 24px;\n font-weight: 700;\n text-align: center;\n color: var(--text-color);\n}\n\n.xar-otp-sub-heading {\n font-family: 'Montserrat', sans-serif;\n font-size: 12px;\n font-weight: 400;\n text-align: center;\n color: var(--text-color);\n}\n\n.xar-otp-error-heading {\n color: var(--fg);\n font-weight: 700;\n font-size: 24px;\n font-family: 'Montserrat', sans-serif;\n}\n.xar-otp-error-subheading {\n color: var(--text-color);\n font-weight: 400;\n font-size: 12px;\n font-family: 'Montserrat', sans-serif;\n}\n");const he=({compact:e,logo:t})=>{const[n,i]=s(!1);return o(a,{children:[n?"":o("div",{className:"xar-header-logo__empty-container"}),o("div",Object.assign({className:"xar-header-logo__container",style:n?{}:{display:"none"}},{children:o("img",{className:"xar-header-logo",src:t,alt:"app-logo",onLoad:()=>{i(!1)}})})),e?"":o("div",Object.assign({className:"xar-header-text"},{children:[o("h1",Object.assign({className:"xar-header-heading"},{children:"Welcome"})),o("p",Object.assign({className:"xar-header-subtext"},{children:"We’ll email you a login link for a password-free sign in."}))]}))]})},ge=({loginWithOTPStart:e,email:n,setEmail:i})=>{const[r,a]=s(!0);return l((()=>{a(!c(n))}),[]),o("form",Object.assign({className:"xar-email-login"},{children:[o("input",{value:n,onInput:e=>{i(e.currentTarget.value),a(!c(e.currentTarget.value))},className:"xar-email-login__input",type:"text",placeholder:"Enter your email"}),o("button",Object.assign({disabled:r,onClick:i=>t(void 0,void 0,void 0,(function*(){if(i.preventDefault(),!n)return;a(!0);const t=yield e(n);yield t.begin(),a(!1)})),className:"xar-btn"},{children:"Get Login OTP"}))]}))},ue=({text:e})=>o("div",Object.assign({className:"xar-separator"},{children:e})),pe=({loginWithSocial:e,loginList:t,mode:n})=>o("div",Object.assign({className:"xar-social-container"},{children:t.map((t=>{return o("div",Object.assign({className:"xar-social-icon__wrapper",onClick:()=>(t=>e(t))(t)},{children:o("img",{src:(i=t,r=n,se[`${i}_${r}`]?se[`${i}_${r}`]:se[i]),alt:`${t} logo`,className:"xar-social-icon"})}));var i,r}))})),me=({mode:e})=>{const t=ae[e];return o("div",Object.assign({className:"xar-footer"},{children:o("a",Object.assign({href:"https://arcana.network",target:"_blank",className:"xar-footer-img__link"},{children:o("img",{className:"xar-footer-img",src:t,alt:"Secured By Arcana"})}))}))},fe=e=>o(a,{children:[e.header?e.header:o(le,{compact:e.compact,stroke:8,secondaryColor:"#8D8D8D"}),e.text?o("p",Object.assign({className:"xar-loader__text"},{children:e.text})):"",e.children?o(a,{children:e.children}):""]}),ve=({loginWithOtpStart:e,loginWithOtpComplete:n,setError:i,closeFunc:r,compact:c})=>{const{counter:h,resetCounter:g}=we(30),[u,p]=s(3),[m,f]=s(!1),[v,w]=s({loading:!1,text:""}),[y,x]=s(""),[b,_]=s(0),C=d([]),I=()=>y?y.toString().split(""):[],O=()=>{r()};l((()=>{6==y.length&&(f(!1),S(),w({loading:!0,text:"Processing..."}),n(y,O).then((()=>w({loading:!1,text:""}))).catch((e=>{console.log(e),p((e=>e-1)),f(!0),w({loading:!1,text:""}),x(""),k()})))}),[y]),l((()=>{0==u&&i()}),[u]),l((()=>{var e;null===(e=C.current[0])||void 0===e||e.focus()}),[]);const S=()=>{for(let e=0;e<6;e++){const t=C.current[e];t&&(t.disabled=!0)}},k=()=>{for(let e=0;e<6;e++){const t=C.current[e];t&&(t.disabled=!1)}},T=e=>{const t=I();t[b]=e[0],E(t)},E=e=>{const t=e.join("");x(t)},P=e=>{const t=e.target;var n;n=t.value,isNaN(Number(n))||1!==n.trim().length?(null===e.data&&"deleteContentBackward"===e.inputType&&(e.preventDefault(),T(""),N(b-1)),t.value=""):(T(t.value),N(b+1))},L=e=>{const t=I();[e.code,e.key].includes("Backspace")?(e.preventDefault(),T(""),N(b-1)):"Delete"===e.code?(e.preventDefault(),T("")):"ArrowLeft"===e.code?(e.preventDefault(),N(b-1)):"ArrowRight"===e.code||e.key===t[b]?(e.preventDefault(),N(b+1)):"Spacebar"!==e.code&&"Space"!==e.code&&"ArrowUp"!==e.code&&"ArrowDown"!==e.code||e.preventDefault()},N=e=>{var t,n;const i=Math.max(Math.min(5,e),0);C.current[i]&&(null===(t=C.current[i])||void 0===t||t.focus(),null===(n=C.current[i])||void 0===n||n.select(),_(i))},R=e=>{var t;e.preventDefault();const n=I();let i=b;if(!e.clipboardData)return;const o=e.clipboardData.getData("text/plain").slice(0,6-b).split("");if(!o.some((e=>isNaN(Number(e))))){for(let e=0;e<6;++e)e>=b&&o.length>0&&(n[e]=null!==(t=o.shift())&&void 0!==t?t:"",i++);N(i),E(n)}};return v.loading?o(a,{children:[o(le,{stroke:8,secondaryColor:"#8D8D8D",compact:c}),o("div",Object.assign({class:"xar-loader__text"},{children:v.text}))]}):o(a,{children:[o("div",Object.assign({class:"xar-otp-heading"},{children:"Verification"})),o("div",Object.assign({class:"xar-otp-sub-heading"},{children:["Please enter the OTP that was sent to your ",o("br",{}),"email address"]})),o("div",Object.assign({className:"xar-otp-box"},{children:Array(6).fill(null).map(((e,t)=>{var n;return o("input",{value:null!==(n=I()[t])&&void 0!==n?n:"",type:"text",maxLength:1,autoComplete:"off",ref:e=>C.current[t]=e,onFocus:e=>(e=>t=>{_(t),e.target.select()})(e)(t),onInput:P,onKeyDown:L,onPaste:R,className:m?"xar-otp-input xar-invalid-otp":"xar-otp-input"},t)}))})),m?o("div",{children:o("p",Object.assign({class:"xar-invalid-otp-text"},{children:["Incorrect OTP. ",u," attempts left."]}))}):"",o("div",{children:o(be,{disabled:h>0,text:h>0?`Resend code in ${h} seconds`:"Resend code",method:()=>t(void 0,void 0,void 0,(function*(){w({loading:!0,text:"Sending OTP to your email address"}),yield e(),g(),w({loading:!1,text:""})}))})})]})},we=(e=60)=>{const[t,n]=s(e);return l((()=>{if(0==t)return void n(0);const e=setInterval((()=>{n(t-1)}),1e3);return()=>clearInterval(e)}),[t]),{counter:t,resetCounter:()=>n(e)}},ye=({action:e})=>o(a,{children:[o("img",{class:"xar-header-logo",src:L,alt:"failed"}),o("h2",Object.assign({class:"xar-otp-error-heading"},{children:"Login Failed"})),o("p",Object.assign({class:"xar-otp-error-subheading"},{children:"Please check credentials and try again"})),o("button",Object.assign({className:"xar-btn",onClick:e},{children:"Go Home"}))]}),xe=({children:e,mode:t})=>o("div",Object.assign({class:"xar-container"},{children:[o("div",Object.assign({class:"xar-inner-container"},{children:e})),o(me,{mode:t})]})),be=({text:e,method:t,disabled:n=!1})=>o("div",Object.assign({class:"xar-action-container"},{children:o("button",Object.assign({disabled:n,onClick:()=>t(),className:"xar-action__link"},{children:e}))})),_e="xar-modal",Ce=e=>o("div",Object.assign({id:_e,onClick:t=>{var n;(null===(n=t.target)||void 0===n?void 0:n.id)==_e&&e.closeFunc&&e.closeFunc(new Error("User closed the connect modal"))}},{children:e.children})),Ie={SOCIAL:"Please complete the login to proceed",OTP_INIT:"Sending login OTP to your email address",OTP_SENT:"",OTP_SENT_GLOBAL:"Please complete the login to proceed",OTP_ERROR:"Invalid OTP, please try again"},Oe={text:"",loading:!1,type:""},Se=(e,t)=>"OTP_SENT_GLOBAL"==t||"SOCIAL"==t||"OTP_SENT"==t||"OTP_INIT"==t||"OTP_ERROR"==t?{text:Ie[t],type:t,loading:"OTP_ERROR"!=t}:"RESET"==t?Oe:e,ke=e=>{const[n,i]=h(Se,Oe),[r,l]=s("");return n.loading?o(Ce,{children:o(xe,Object.assign({mode:e.mode},{children:"OTP_SENT"==n.type?o(ve,{loginWithOtpStart:()=>e.loginWithOTPStart(r),setError:()=>i("OTP_ERROR"),closeFunc:e.closeFunc,loginWithOtpComplete:e.loginWithOTPComplete,compact:e.options.compact}):o(fe,{compact:e.options.compact,text:n.text,mode:e.mode})}))}):o(Ce,Object.assign({closeFunc:e.closeFunc},{children:o(xe,Object.assign({mode:e.mode},{children:"OTP_ERROR"==n.type?o(ye,{action:()=>i("RESET")}):o(a,{children:[o(he,{compact:e.options.compact,logo:e.logo}),o(ge,{email:r,setEmail:l,loginWithOTPStart:n=>t(void 0,void 0,void 0,(function*(){i("OTP_INIT");const t=yield e.loginWithOTPStart(n);return i(t.isCompleteRequired?"OTP_SENT":"OTP_SENT_GLOBAL"),t}))}),e.loginList.length>0?o(a,{children:[o(ue,{text:"or continue with"}),o(pe,{loginWithSocial:n=>t(void 0,void 0,void 0,(function*(){i("SOCIAL"),e.loginWithSocial(n).finally((()=>{i("RESET")}))})),loginList:e.loginList,mode:e.mode})]}):null]})}))}))};class Te{constructor(e){this.status="closed",this.close=e=>{"closed"!==this.status&&(this.onClose(e),this.status="closed",g(null,this.container))},this.params={loginList:e.loginList.filter((e=>"passwordless"!==e)),loginWithSocial:e.loginWithSocial,loginWithOTPStart:e.loginWithOTPStart,loginWithOTPComplete:e.loginWithOTPComplete,mode:e.mode,closeFunc:this.close,logo:e.logo,options:e.options},this.createContainer()}open(e){"open"!==this.status&&(this.onClose=e,this.status="open",g(o(ke,Object.assign({},this.params)),this.container))}createContainer(){const e=this.params.options.compact?"compact":"full";this.container=document.createElement("div"),this.container.setAttribute("id","xar-login-container"),this.container.classList.add(`xar-${this.params.mode}-mode`),this.container.classList.add(e),document.body.appendChild(this.container)}}class Ee{static create(e){return t(this,void 0,void 0,(function*(){const[t,n]=yield Promise.all([import("./solana.chunk.js"),import("./vendor.chunk.js").then((function(e){return e.i}))]);return new Ee(e,t,n)}))}constructor(e,t,n){this.p=e,this.web3Module=t,this.bs58Module=n}get isConnected(){return this.p.connected}request(e){return t(this,void 0,void 0,(function*(){const t=structuredClone(e);if("signMessage"===t.method){const e=t.params;e.message instanceof Uint8Array&&(e.message=this.bs58Module.encode(e.message))}const n=yield this.p.request(t);switch(t.method){case"signMessage":return this.parseSignatureResponse(n);case"signTransaction":return this.web3Module.VersionedTransaction.deserialize(this.bs58Module.decode(n));case"signAllTransactions":return n.map((e=>this.web3Module.VersionedTransaction.deserialize(this.bs58Module.decode(e))));default:return n}}))}parseSignatureResponse(e){return{signature:this.bs58Module.decode(e.signature),publicKey:new this.web3Module.PublicKey(e.publicKey)}}signMessage(e,t){return this.request({method:"signMessage",params:{message:this.bs58Module.encode(e),display:t}})}signTransaction(e){return this.request({method:"signTransaction",params:{message:this.bs58Module.encode(e.serialize())}})}signAndSendTransaction(e){return this.request({method:"signAndSendTransaction",params:{message:this.bs58Module.encode(e.serialize())}})}signAllTransactions(e){return this.request({method:"signAllTransactions",params:{message:e.map((e=>this.bs58Module.encode(e.serialize())))}})}}class Pe{constructor(e,n){this.initStatus=H.CREATED,this.initPromises=[],this.loginWithOTPStart=e=>t(this,void 0,void 0,(function*(){return yield this.init(),{begin:()=>this._loginWithOTPStart(e),isCompleteRequired:!("global"===(yield this._provider.getKeySpaceConfigType()))}})),this.loginWithOTPComplete=(e,n)=>t(this,void 0,void 0,(function*(){if("global"===(yield this._provider.getKeySpaceConfigType()))throw new Error("complete is not required for global login");yield this._loginWithOTPComplete(e,n)})),this.loginWithSocial=e=>t(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return this._provider;if(!(yield this._provider.isLoginAvailable(e)))throw new Error(`${e} login is not available`);const t=yield this._provider.initSocialLogin(e);return this.beginLogin(t)})),this.loginWithLink=(e,n)=>t(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return this._provider;if(!c(e))throw new Error("Invalid email");const t=yield this._provider.initPasswordlessLogin(e);return t&&"string"==typeof t?this.beginLogin(t):(n&&n(),yield this.waitForConnect())})),this._loginWithOTPStart=e=>t(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return;if(!c(e))throw new Error("Invalid email");const t=yield this._provider.initOTPLogin(e);t&&"string"==typeof t&&(yield this.beginLogin(t))})),this._loginWithOTPComplete=(e,n)=>t(this,void 0,void 0,(function*(){return yield this.init(),(yield this.isLoggedIn())?this._provider:(this._provider.once("message",(e=>{"mfa_flow"===e&&n&&n()})),yield this._provider.completeOTPLogin(e),yield this.waitForConnect())})),this.loginWithBearer=(e,n)=>t(this,void 0,void 0,(function*(){return yield this.init(),yield this.iframeWrapper.triggerBearerAuthentication(e,n)}));let i=null==n?void 0:n.network,o=e;if((e=>{if(!N(e))throw new u("invalid_client_id","Invalid Client ID");return 3==e.split("_").length})(e)){const t=(e=>{const t=e.split("_"),[,n,i]=t;if(!R(i))throw new Error("Invalid ClientId");if("live"==n)return{network:"mainnet",address:i};if("test"==n)return{network:"testnet",address:i};if("dev"==n)return{network:"dev",address:i};throw new Error("Invalid ClientId")})(e);i=t.network,o=t.address}var r;(e=>{if(!(e=>null!=e)(e))throw new Error("appAddress is required");if(!N(e))throw new Error("appAddress is required to be a non-empty string");if(!R(e))throw new Error("appAddress is required to be an ethereum address")})(o),this.appId=U(o),this.params=(e=>{var t;const n={network:"testnet",debug:!1,position:"right",theme:"dark",alwaysVisible:!0,setWindowProvider:!1,connectOptions:{compact:!1}};return(null==e?void 0:e.network)&&(n.network=e.network),void 0!==(null==e?void 0:e.debug)&&(n.debug=e.debug),(null==e?void 0:e.theme)&&(n.theme=e.theme),(null==e?void 0:e.position)&&(n.position=e.position),void 0!==(null==e?void 0:e.alwaysVisible)&&(n.alwaysVisible=e.alwaysVisible),void 0!==(null===(t=null==e?void 0:e.connectOptions)||void 0===t?void 0:t.compact)&&(n.connectOptions.compact=e.connectOptions.compact),"testnet"!=n.network&&"dev"!=n.network||console.log(`%c[XAR_AUTH_SDK] You are currently on ${n.network} network.`,"color: red"),n})(Object.assign(Object.assign({},n),{network:i})),this.networkConfig=(e=>{if("string"==typeof e&&"testnet"==e)return te;if("string"==typeof e&&"dev"==e)return ee;if("string"==typeof e&&"mainnet"==e)return ne;if(function(e){return"string"!=typeof e&&(!("object"!=typeof e||!e.gatewayUrl)&&(!("object"!=typeof e||!e.walletUrl)&&!("object"!=typeof e||!e.authUrl)))}(e))return e;throw new Error("Invalid network config passed")})(this.params.network),function(e,t){try{if("undefined"==typeof document)return;const n=document.createElement("link");n.href=`${e}/${t}/login`,n.type="text/html",n.rel="prefetch",document.head.appendChild(n)}catch(e){console.warn(e)}}(this.networkConfig.walletUrl,this.appId),this._provider=new K(this.networkConfig.authUrl),this.params.debug?(C(v),r=e=>{console.error(e)},O.exceptionReporter=r):C(b)}init(){var e;return t(this,void 0,void 0,(function*(){if(this.initStatus===H.CREATED){if(this.initStatus=H.RUNNING,this.iframeWrapper)return this;if(yield this.setAppConfig(),this.iframeWrapper=new Q({appId:this.appId,iframeUrl:this.networkConfig.walletUrl,appConfig:this.appConfig,position:this.params.position,standaloneMode:this._standaloneMode}),this.iframeWrapper.setWalletType(null!==(e=this.params.appMode)&&void 0!==e?e:this.params.alwaysVisible?X.Full:X.Widget),yield this._provider.init(this.iframeWrapper,this),this.setProviders(),this.appConfig.chainType===V.solana_cv25519)this._solanaAPI=yield Ee.create(this._provider);return this.initStatus=H.DONE,this.resolveInitPromises(),this}return this.initStatus===H.RUNNING?yield this.waitForInit():this}))}connect(){return t(this,void 0,void 0,(function*(){if(this.initStatus!==H.DONE&&(yield this.init()),yield this.isLoggedIn())return this._provider;const e=yield this.getLogins();return this.connectCtrl||(this.connectCtrl=new Te({loginWithOTPStart:this.loginWithOTPStart,loginWithOTPComplete:this.loginWithOTPComplete,loginWithSocial:this.loginWithSocial,loginList:e,mode:this.theme,logo:this.logo.vertical,options:this.params.connectOptions})),new Promise(((e,t)=>{this.connectCtrl.open((e=>{if(e)return t(e)})),this.waitForConnect().then((t=>{this.connectCtrl.close(),e(t)})).catch(t)}))}))}showWallet(){if(!this.connected)throw new Error("no connection yet, cannot show wallet");this._provider.expandWallet()}get connected(){return this._provider.connected}getUser(){if(this.initStatus===H.DONE)return this._provider.requestUserInfo();throw m}isLoggedIn(){return t(this,void 0,void 0,(function*(){if(this.initStatus===H.DONE){return yield this._provider.isLoggedIn()}throw m}))}logout(){if(this.initStatus===H.DONE)return this._provider.triggerLogout();throw m}getPublicKey(e,n="google"){return t(this,void 0,void 0,(function*(){if(this.initStatus===H.DONE){if(!e||""===e)throw new u("email_required",`Email is required in getPublicKey, got ${e}`);return yield this._provider.getPublicKey(e,n)}throw m}))}getLogins(){return t(this,void 0,void 0,(function*(){if(this.initStatus===H.DONE)return yield this._provider.getAvailableLogins();throw m}))}getProvider(){if(this.initStatus===H.DONE)return this._provider;throw m}canReconnect(){return t(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return!1;const e=this.iframeWrapper.getSessionID();return!!e&&!(e.expiry<Date.now())}))}reconnect(){return t(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return void(yield this.waitForConnect());const e=this.iframeWrapper.getSessionID();if(e){if(e.expiry<Date.now())throw new Error("cannot reconnect, session expired");const t=new URL(yield this._provider.getReconnectionUrl());t.searchParams.set("sessionID",e.id);const n=new S(t.toString());return yield n.open(),void(yield this.waitForConnect())}throw new Error("cannot reconnect, no session found")}))}get chainId(){return this._provider.chainId}beginLogin(e){return t(this,void 0,void 0,(function*(){const t=new S(e);return yield t.open(),yield this.waitForConnect()}))}waitForConnect(){return new Promise((e=>{if(this.connected)return e(this._provider);this._provider.once("connect",(()=>e(this._provider)))}))}setAppConfig(){return t(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([ie(this.appId,this.networkConfig.gatewayUrl),oe(this.appId,this.networkConfig.gatewayUrl)]),n=function(e,t,n){const i=new URL(`/api/v2/app/${e}/logo?type=${t}`,n);return{horizontal:`${i.toString()}&orientation=horizontal`,vertical:`${i.toString()}&orientation=vertical`}}(this.appId,this.params.theme,this.networkConfig.gatewayUrl),i=e.logo.dark_horizontal||e.logo.light_horizontal,o=e.logo.dark_vertical||e.logo.light_vertical;this.appConfig={name:t.name,chainType:"evm"===t.chain_type.toLowerCase()?V.evm_secp256k1:V.solana_cv25519,themeConfig:{assets:{logo:{horizontal:i?n.horizontal:"",vertical:o?n.vertical:""}},theme:this.params.theme}}}))}waitForInit(){return t(this,void 0,void 0,(function*(){const e=new Promise((e=>{this.initPromises.push(e)}));return yield e}))}resolveInitPromises(){const e=this.initPromises;this.initPromises=[];for(const t of e)t(this)}get provider(){if(this._provider)return this._provider;throw m}get solana(){if(this._solanaAPI)return this._solanaAPI;throw m}get logo(){if(this.initStatus===H.DONE)return this.appConfig.themeConfig.assets.logo;throw m}get theme(){if(this.initStatus===H.DONE)return this.appConfig.themeConfig.theme;throw m}setProviders(){var e;void 0!==typeof window&&(this.providerInfo={uuid:window.crypto.randomUUID(),name:"Arcana Wallet",icon:"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'/>",rdns:"network.arcana.wallet"},e=()=>{var e,t,n;const i=window;try{i.arcana=null!==(e=i.arcana)&&void 0!==e?e:{},i.arcana.provider=this._provider}catch(e){}if(this.params.setWindowProvider)try{i.ethereum=null!==(t=i.ethereum)&&void 0!==t?t:this._provider,i.ethereum.providers=null!==(n=i.ethereum.providers)&&void 0!==n?n:[],i.ethereum.providers.push(this._provider)}catch(e){console.error(e)}this.announceProvider(),window.addEventListener("eip6963:requestProvider",(()=>{this.announceProvider()}))},"complete"===document.readyState?e():window.addEventListener("load",e))}announceProvider(){window.dispatchEvent(new CustomEvent("eip6963:announceProvider",{detail:Object.freeze({info:this.providerInfo,provider:this._provider})}))}standaloneMode(e,t){this._standaloneMode={mode:e,handler:t}}}export{Pe as AuthProvider,J as BearerAuthentication}; | ||
import{_ as e,P as t,Q as n,S as i,T as o,U as r,V as s,W as a,X as l,Y as d,Z as c,$ as h,a0 as g}from"./vendor.chunk.js";class u extends Error{constructor(e,t){super(e),this.message=t,this.message=`[XAR_AUTH_SDK] error: [${e}] ${t}`}}const p=new u("user_not_logged_in","User is not logged in"),m=new u("wallet_not_initialized","AuthProvider is not initialized. Please run `await auth.init(...)` before calling functions"),f=new class{constructor(e,t){this.message=`[XAR_AUTH_SDK] warning: [${e}] ${t}`}log(){console.warn(this.message)}}("duplicate_iframe","Duplicate iframe detected, please keep a single instance of AuthProvider"),v=1,w=2,x=3,y=4,b=5,_=e=>{I.exceptionReporter&&I.exceptionReporter(e)},C=e=>{I.logLevel=e},O=()=>I.logger;const I={logger:new class{constructor(){this.prefix="[XAR_AUTH_SDK]"}info(e,t={}){this.internalLog(w,e,t)}debug(e,t={}){this.internalLog(v,e,t)}warn(e,t={}){this.internalLog(x,e,t)}error(e,t){if(t instanceof Error)return this.internalLog(y,e,t.message),void _(JSON.stringify({message:e,error:t.message}));"string"==typeof t&&(this.internalLog(y,e,t),_(JSON.stringify({message:e,error:t})))}internalLog(e,t,n){const i=`${this.prefix}\nMessage: ${t} \nParams: ${JSON.stringify(n)}`;this.consoleLog(e,i)}consoleLog(e,t){if(!(e<I.logLevel))switch(e){case v:console.debug(t);break;case x:console.warn(t);break;case y:console.error(t);break;case w:console.info(t);break;default:console.log(t)}}},logLevel:b,exceptionReporter:null};class S{constructor(e){this.url=e,this.requestHandler=()=>new Promise((e=>{let n=!1;const i=window.setInterval((()=>{var t;try{if(!n&&(null===(t=this.window)||void 0===t?void 0:t.closed))return e({id:1,jsonrpc:"2.0",error:"user_closed_popup"})}catch(e){}}),500),o=r=>t(this,void 0,void 0,(function*(){var t;if("json_rpc_response"==r.data.type)return n=!0,this.clear(o,i),null===(t=this.window)||void 0===t||t.close(),e(r.data.response)}));window.addEventListener("message",o,!1)}))}open(){const e=E();return this.window=window.open(this.url,"_blank",e),this.getWindowResponse()}getWindowResponse(){return new Promise(((e,n)=>{let i=!1;const o=window.setInterval((()=>{var e;!i&&(null===(e=this.window)||void 0===e?void 0:e.closed)&&n("User closed the popup")}),500),r=s=>t(this,void 0,void 0,(function*(){var t,a,l;if(!(null===(t=null==s?void 0:s.data)||void 0===t?void 0:t.status))return;const d=s.data;return i=!0,this.clear(r,o),"success"===d.status?(null===(a=this.window)||void 0===a||a.close(),e("success")):"error"==d.status?(null===(l=this.window)||void 0===l||l.close(),n(d.error)):"done"===d.status?e("done"):void console.log("Unexpected event")}));window.addEventListener("message",r,!1)}))}clear(e,t){window.removeEventListener("message",e),window.clearInterval(t)}}const k={titlebar:0,toolbar:0,status:0,menubar:0,resizable:0,height:1200,width:700,popup:1},E=()=>{const e=[];for(const t in k)e.push(`${t}=${k[t]}`);return e.join(",")};class P{constructor(n){this.url=n,this.requestCount=0,this.emitter=new e,this.ready=!1,this.cleanExit=!1,this.requestHandler=e=>new Promise((t=>{this.cleanExit=!1;const n=window.setInterval((()=>{var i;try{(null===(i=this.window)||void 0===i?void 0:i.closed)&&(this.cleanExit||this.emitter.emit(e,{id:e,jsonrpc:"2.0",error:"user_closed_popup"}),window.clearInterval(n),t("ok"))}catch(e){}}),500)})),this.handler=e=>t(this,void 0,void 0,(function*(){"json_rpc_response"==e.data.type&&(this.cleanExit=!0,this.emitter.emit(e.data.response.id,e.data.response))}))}sendRequest(e){return t(this,void 0,void 0,(function*(){if(this.window||(this.ready=!1,this.requestCount=0,this.window=window.open(this.url,"_blank",E()),yield L(),window.addEventListener("message",this.handler,!1)),this.window){this.requestCount++,this.window.postMessage({type:"json_rpc_request",data:e},this.url),this.window.focus(),this.requestHandler(String(e.request.id));return yield new Promise((t=>this.emitter.once(String(e.request.id),(e=>{var n;return this.requestCount--,this.requestCount<=0&&(window.removeEventListener("message",this.handler),null===(n=this.window)||void 0===n||n.close(),this.window=null),t(e)}))))}throw Error("error while opening popup")}))}}const L=()=>new Promise((e=>{const t=n=>{"READY_TO_RECEIVE"===n.data.type&&(window.removeEventListener("message",t),e("ok"))};window.addEventListener("message",t,!1)})),T="data:image/svg+xml,%3Csvg width='116' height='116' viewBox='0 0 116 116' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M115.341 58.0094C115.341 89.6796 89.6673 115.354 57.9967 115.354C26.3265 115.354 0.652344 89.6796 0.652344 58.0094C0.652344 26.3392 26.3265 0.665039 57.9967 0.665039C89.6673 0.665039 115.341 26.3392 115.341 58.0094Z' fill='%23B43030'/%3E%3Cpath d='M78.7969 37.2041L37.1953 78.8057' stroke='white' stroke-width='5.74' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M78.7969 78.8057L37.1953 37.2041' stroke='white' stroke-width='5.74' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A",N=e=>"string"==typeof e&&e.trim().length>0,R=e=>40===U(e).length,A="0x",U=e=>e.startsWith(A)?e.substring(2):e,j=(e,t=!0)=>{const n=e.toString(16);return t?(i=n).startsWith(A)?i:A+i:U(n);var i},W=()=>window.location.origin+window.location.pathname,D=4294967295;let M=Math.floor(Math.random()*D);function $(e){return String.fromCharCode(parseInt(e.slice(1),16))}function q(e){return t=JSON.stringify(e),window.btoa(encodeURIComponent(t).replace(/%[0-9A-F]{2}/g,$));var t}class z extends Error{constructor(e,t,n=""){super(t),this.code=e,this.message=t,this.data=n}}class F extends e{constructor(t){super(),this.authUrl=t,this.connected=!1,this.logger=O(),this.onResponse=(e,t)=>{this.subscriber.emit(`result:${e}:${t.id}`,t)},this.handleEvents=(e,t)=>{switch(e){case K.ACCOUNTS_CHANGED:this.emit(e,[t]);break;case K.CHAIN_CHANGED:this.setChainId(t),this.emit(e,j(t.chainId));break;case K.CONNECT:this.chainId="object"==typeof t?t.chainId:"",this.connected=!0,this.emit(e,t);break;case K.DISCONNECT:this.iframe.handleDisconnect(),this.connected=!1,this.emit(e,t);break;case K.MESSAGE:console.log({t:e,val:t}),this.emit(e,t)}},this.subscriber=new e}isArcana(){return!0}init(e,n){return t(this,void 0,void 0,(function*(){this.auth=n,this.popup=new P(this.createRequestUrl(n.appId)),this.iframe=e;const{communication:t}=yield this.iframe.setConnectionMethods({onEvent:this.handleEvents,onMethodResponse:this.onResponse,getParentUrl:W,getAppMode:()=>this.iframe.appMode,getAppConfig:this.iframe.getAppConfig,getWalletPosition:this.iframe.getWalletPlace,getRpcConfig:()=>{},sendPendingRequestCount:this.iframe.onReceivingPendingRequestCount,triggerSocialLogin:n.loginWithSocial,triggerPasswordlessLogin:n.loginWithLink,getPopupState:()=>this.iframe.getState(),setIframeStyle:this.iframe.setIframeStyle,setSessionID:this.iframe.setSessionID,getSDKVersion:()=>"v3"});this.communication=t}))}isLoggedIn(){return t(this,void 0,void 0,(function*(){try{return(yield this.getCommunication("isLoggedIn")).isLoggedIn()}catch(e){return this.logger.error("isLoggedIn",e),!1}}))}connect(){return this.auth.connect()}isConnected(){return t(this,void 0,void 0,(function*(){return this.connected}))}isLoginAvailable(e){return t(this,void 0,void 0,(function*(){const t=yield this.getCommunication("isLoginAvailable"),n=yield t.isLoginAvailable(e);return this.logger.debug("loginAvailable",{[e]:n}),n}))}requestUserInfo(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("getUserInfo");if(!(yield e.isLoggedIn()))throw p;return yield e.getUserInfo()}))}getReconnectionUrl(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("getReconnectionUrl");return yield e.getReconnectionUrl()}))}initOTPLogin(e){return t(this,void 0,void 0,(function*(){const t=yield this.getCommunication("initOTPLogin");return yield t.initOTPLogin(e)}))}completeOTPLogin(e){return t(this,void 0,void 0,(function*(){const t=yield this.getCommunication("completeOTPLogin");yield t.completeOTPLogin(e)}))}getPublicKey(e,n){return t(this,void 0,void 0,(function*(){return(yield this.getCommunication("getPublicKey")).getPublicKey(e,n)}))}getAvailableLogins(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("getAvailableLogins");return yield e.getAvailableLogins()}))}triggerLogout(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("triggerLogout");yield e.triggerLogout(!0)}))}initPasswordlessLogin(e){return t(this,void 0,void 0,(function*(){const t=yield this.getCommunication("initPasswordlessLogin");return yield t.initPasswordlessLogin(e)}))}initSocialLogin(e){return t(this,void 0,void 0,(function*(){const t=yield this.getCommunication("initSocialLogin");return yield t.initSocialLogin(e)}))}expandWallet(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("expandWallet");return yield e.expandWallet()}))}getKeySpaceConfigType(){return t(this,void 0,void 0,(function*(){const e=yield this.getCommunication("getKeySpaceConfigType");return yield e.getKeySpaceConfigType()}))}getCommunication(e="sendRequest"){return t(this,void 0,void 0,(function*(){if(this.communication){const t=yield this.communication.promise;if(!t[e])throw new u("fn_not_available",`The requested fn ${e} is not available in this context`);return t}throw new u("connection_not_available","The connection is not available yet")}))}request(e){return t(this,void 0,void 0,(function*(){if(!e||"object"!=typeof e||Array.isArray(e))throw n.ethErrors.rpc.invalidRequest({message:"Invalid request arguments",data:e});const{method:i,params:o}=e;if(!i)throw n.ethErrors.rpc.invalidRequest({message:"Invalid method argument",data:e});const r={method:i,params:o,jsonrpc:"2.0",id:(M=(M+1)%D,M)};return new Promise(((e,n)=>{this.getCommunication().then((o=>t(this,void 0,void 0,(function*(){this.getResponse(i,r.id).then(e,n),yield o.sendRequest(r)}))),n)}))}))}getResponse(e,t){return new Promise(((n,i)=>{this.subscriber.once(`result:${e}:${t}`,(e=>e.error?i(G(e.error)):n(e.result)))}))}createRequestUrl(e){return new URL(`/${e}/permission/`,this.authUrl).href}setChainId(e){e&&"object"==typeof e&&"chainId"in e&&"number"==typeof e.chainId&&(this.chainId=j(e.chainId))}}const K={ACCOUNTS_CHANGED:"accountsChanged",CHAIN_CHANGED:"chainChanged",CONNECT:"connect",DISCONNECT:"disconnect",MESSAGE:"message"},G=e=>{switch(O().error("getError",e),e){case"user_deny":return new z(4001,"User rejected the request.");case"user_closed_popup":return new z(4001,"User closed the popup.");case"operation_not_supported":return new z(4200,"The requested method is not supported by this provider.");case"all_disconnected":return new z(4900,"The provider is disconnected from all chains. Login is pending.");default:return"string"!=typeof e?new z(e.code,e.message,e.data):n.ethErrors.rpc.internal(e)}};var B,H,V,J;!function(e){e[e.CREATED=0]="CREATED",e[e.RUNNING=1]="RUNNING",e[e.DONE=2]="DONE"}(B||(B={})),function(e){e.evm_secp256k1="evm_secp256k1",e.solana_cv25519="solana_cv25519"}(H||(H={})),function(e){e.firebase="firebase"}(V||(V={})),function(e){e[e.NoUI=0]="NoUI",e[e.Widget=1]="Widget",e[e.Full=2]="Full"}(J||(J={}));const X={border:"none",position:"fixed",height:0,width:0,right:0,bottom:0,zIndex:2147483648},Y="xar-wallet";class Z{constructor(e){this.params=e,this.getSessionID=()=>{const e=window.localStorage.getItem(`arcana-auth-${this.getIframeUrl()}-sessionID`);return e?JSON.parse(e):null},this.setSessionID=(e,t)=>{window.localStorage.setItem(`arcana-auth-${this.getIframeUrl()}-sessionID`,JSON.stringify({id:e,expiry:t}))},this.clearSessionID=()=>{window.localStorage.removeItem(`arcana-auth-${this.getIframeUrl()}-sessionID`)},this.setIframeStyle=e=>{var t;if(1==(null===(t=this.params.standaloneMode)||void 0===t?void 0:t.mode))this.widgetIframe.style.height=e.height?e.height:"80vh",this.widgetIframe.style.maxWidth="100%",this.widgetIframe.style.width="430px",this.widgetIframe.style.bottom="0",this.widgetIframe.style.right="0";else for(const t in e)this.widgetIframe.style[t]=e[t]},this.getWalletPlace=()=>this.params.position,this.getAppConfig=()=>this.params.appConfig,this.checkDuplicateIframe(),this.checkSecureOrigin()}setConnectionMethods(e){return t(this,void 0,void 0,(function*(){try{return this.iframeCommunication||(this.iframeCommunication=i({iframe:this.widgetIframe,methods:Object.assign(Object.assign({},e),{uiEvent:(e,t)=>{var n;(null===(n=this.params.standaloneMode)||void 0===n?void 0:n.handler)&&this.params.standaloneMode.handler(e,t)}}),childOrigin:this.params.iframeUrl}),yield this.iframeCommunication.promise),{iframe:this.widgetIframe,communication:this.iframeCommunication}}catch(e){throw new Error("Could not set connection methods")}}))}triggerBearerAuthentication(e,n){return t(this,void 0,void 0,(function*(){return(yield this.iframeCommunication.promise).triggerBearerLogin(e,n)}))}setWalletType(e){this.appMode=null!=e?e:J.Full,this.initWalletUI()}getState(){return this.state}handleDisconnect(){this.widgetIframe.src=this.getIframeUrl(),this.clearSessionID()}onReceivingPendingRequestCount(e){const t=document.getElementById("req-count-badge");t&&(e>0?(t.style.display="flex",t.textContent=`${e}`):t.style.display="none")}getIframeUrl(){var e,t;const n=q({standaloneMode:(null===(e=this.params.standaloneMode)||void 0===e?void 0:e.mode)?null===(t=this.params.standaloneMode)||void 0===t?void 0:t.mode:0}),i=new URL(`/${this.params.appId}/v2/login`,this.params.iframeUrl);return i.hash=n,i.toString()}createWidgetIframe(){return((e,t,...n)=>{const i=document.createElement(e);t&&(Object.assign(i,t),t.style&&Object.assign(i.style,t.style));for(const e of n)"string"!=typeof e?i.appendChild(e):i.appendChild(document.createTextNode(e));return i})("iframe",{style:X,src:this.getIframeUrl(),allow:"clipboard-write",className:Y})}checkDuplicateIframe(){[].slice.call(document.querySelectorAll(`.${Y}`)).length>0&&f.log()}initWalletUI(){this.widgetIframe=this.createWidgetIframe(),document.body.appendChild(this.widgetIframe)}checkSecureOrigin(){const e="localhost"===location.hostname||"127.0.0.1"===location.hostname,t="https:"===location.protocol;if(!(e||t))throw new Error("Insecure origin")}}const Q={authUrl:"https://verify.dev.arcana.network",gatewayUrl:"https://gateway-dev.arcana.network",walletUrl:"https://wallet.dev.arcana.network"},ee={authUrl:"https://verify.beta.arcana.network",gatewayUrl:"https://gateway001-testnet.arcana.network",walletUrl:"https://wallet.beta.arcana.network"},te={authUrl:"https://auth.arcana.network",gatewayUrl:"https://gateway.arcana.network",walletUrl:"https://wallet.arcana.network"};function ne(e,n){return t(this,void 0,void 0,(function*(){const t=new URL(`/api/v1/get-app-theme/?id=${e}`,n);return yield(yield fetch(t.toString())).json()}))}function ie(e,n){return t(this,void 0,void 0,(function*(){const t=new URL(`/api/v1/get-app-config/?id=${e}`,n);return yield(yield fetch(t.toString())).json()}))}const oe="https://auth-icons.s3.ap-south-1.amazonaws.com",re={google:`${oe}/google.png`,twitter:`${oe}/twitter.png`,github:`${oe}/github-light.png`,github_light:`${oe}/github.png`,twitch:`${oe}/twitch.png`,discord:`${oe}/discord.png`,aws:`${oe}/aws.png`,aws_light:`${oe}/aws_light.png`,steam:`${oe}/steam.png`};const se={light:`${oe}/secured-by-arcana-light.svg`,dark:`${oe}/secured-by-arcana-dark.svg`};function ae(e){const t=e.width?e.width:e.compact?60:80,{stroke:n=8,secondaryColor:i}=e;return o("div",Object.assign({"aria-label":"oval-loading"},{children:o("svg",Object.assign({width:t,height:t,viewBox:le(Number(n),20),xmlns:"http://www.w3.org/2000/svg",className:"xar-loader-circle","data-testid":"oval-svg"},{children:o("g",Object.assign({fill:"none",fillRule:"evenodd"},{children:o("g",Object.assign({transform:"translate(1 1)","stroke-width":n,"data-testid":"oval-secondary-group"},{children:[o("circle",{strokeOpacity:".5",cx:"0",cy:"0",r:20,stroke:i,"stroke-width":n,opacity:.3}),o("path",Object.assign({d:de(20),stroke:e.strokeColor},{children:o("animateTransform",{attributeName:"transform",type:"rotate",from:"0 0 0",to:"360 0 0",dur:"1s",repeatCount:"indefinite"})}))]}))}))}))}))}const le=(e,t)=>{const n=-t-e/2+1,i=2*t+e;return[n,n,i,i].join(" ")},de=e=>["M"+e+" 0c0-9.94-8.06",e,e,e].join("-");r("@import url('https://fonts.googleapis.com/css2?family=Sora:wght@100;400;600;700&display=block');\n@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Sora:wght@400;600&display=block');\n\n.xar-light-mode {\n --fg: #333333;\n --bg: #eff1f3;\n --background: #fcfcfc;\n --inputShadow: 0 0 8px 3px rgba(126, 126, 126, 0.25);\n --text-color: #101010;\n --otp-bg: #eeeeee;\n --otp-shadow: 1px 1px 2px 0px #aeaec033 inset,\n -1px -1px 1px 0px #ffffffb2 inset;\n}\n\n.xar-dark-mode {\n --fg: #ffffff;\n --bg: #313131;\n --background: #262626;\n --inputShadow: 0 0 8px 3px rgba(0, 0, 0, 0.05);\n --text-color: #f7f7f7;\n --otp-bg: linear-gradient(141.48deg, #161616 -4.56%, #151515 135.63%);\n --otp-shadow: -50px 49px 29px 22px #1c1c1cd6 inset,\n 5px 5px 10px 0px #0b0b0b80 inset;\n}\n\n.compact {\n --modal-height: 235px;\n --loader-font-size: 14px;\n --loader-font-weight: 400;\n --success-img-width: 70px;\n --action-link-size: 12px;\n}\n\n.full {\n --modal-height: 480px;\n --loader-font-size: 20px;\n --loader-font-weight: 700;\n --success-img-width: 100px;\n --action-link-size: 15px;\n}\n\n#xar-modal {\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n z-index: 2147483648;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n overflow: auto;\n background: rgba(10, 10, 10, 0.7);\n backdrop-filter: blur(16px);\n font-family: Sora, sans-serif;\n}\n\n.xar-header-logo__container {\n width: 70px;\n height: 70px;\n border-radius: 50%;\n margin: 0 auto;\n display: flex;\n align-items: center;\n justify-content: center;\n border: 2px solid var(--fg);\n}\n\n.xar-header-logo__empty-container {\n width: 70px;\n height: 70px;\n border-radius: 50%;\n margin: 0 auto;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.xar-header-logo {\n max-width: 60px;\n max-height: 60px;\n margin: 0 auto;\n display: inline-block;\n}\n\n.xar-header-heading {\n font-family: 'Sora', sans-serif;\n text-align: center;\n}\n\n.xar-header-subtext {\n font-family: 'Sora', sans-serif;\n font-size: 12px;\n font-weight: 400;\n max-width: 200px;\n}\n\n.xar-email-login {\n display: flex;\n flex-direction: column;\n width: 100%;\n}\n\n.xar-email-login > *:not(:first-child) {\n margin-top: 20px;\n}\n\n.xar-email-login__label {\n text-align: left;\n font-size: 14px;\n color: var(--fg);\n font-weight: 400;\n}\n\n.xar-success__img {\n max-width: var(--success-img-width);\n}\n\n.xar-email-login__input {\n height: 45px;\n padding: 0 16px;\n font-family: 'Sora', sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: var(--fg);\n background: var(--bg);\n border: none;\n border-radius: 5px;\n outline: none;\n box-shadow: var(--inputShadow);\n}\n\n.xar-social-container {\n display: flex;\n justify-content: center;\n gap: 1rem;\n flex-wrap: wrap;\n}\n\n.xar-social-icon__wrapper {\n display: flex;\n background: var(--fg);\n width: 42px;\n height: 42px;\n border-radius: 50%;\n align-items: center;\n}\n\n.xar-social-icon__wrapper:hover {\n cursor: pointer;\n transition: all 0.5s;\n transform: scale(1.15, 1.15);\n}\n\n.xar-social-icon {\n margin: 0 auto;\n width: 24px;\n max-height: 24px;\n}\n\n.xar-container {\n padding: 30px 30px 20px;\n width: 325px;\n min-height: var(--modal-height);\n background-color: var(--background);\n color: var(--fg);\n margin: 0 auto;\n font-family: 'Sora', sans-serif;\n box-shadow: 4px 5px 4px rgba(0, 0, 0, 0.25);\n border-radius: 10px;\n box-sizing: content-box;\n transition: all 1s ease;\n}\n\n.xar-inner-container {\n min-height: inherit;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n text-align: center;\n}\n\n.xar-inner-container > *:not(:first-child) {\n margin-top: 20px;\n}\n\n.xar-btn {\n margin: 0 auto;\n padding: 0;\n width: 100%;\n height: 2.75rem;\n font-size: 14px;\n font-weight: 600;\n text-transform: uppercase;\n color: var(--bg);\n background: var(--fg);\n border: none;\n border-radius: 5px;\n}\n\n.xar-btn:disabled {\n opacity: 0.7;\n}\n\n.xar-btn:hover:enabled {\n cursor: pointer;\n transition: all 0.5s;\n transform: scale(1.05, 1.15);\n}\n\n.xar-btn:disabled,\n.xar-btn[disabled] {\n cursor: not-allowed;\n}\n\n.xar-footer {\n display: flex;\n align-items: center;\n justify-content: center;\n margin-top: 1rem;\n}\n\n.xar-footer-text {\n font-size: 12px;\n font-weight: 400;\n}\n\n.xar-footer-img__link {\n height: 15px;\n}\n\n.xar-footer-img {\n display: block;\n}\n\n.xar-separator {\n width: 100%;\n display: flex;\n align-items: center;\n text-align: center;\n}\n\n.xar-separator:before,\n.xar-separator:after {\n content: '';\n flex: 1 1 auto;\n border-bottom: 1px solid var(--fg);\n}\n\n.xar-separator:before {\n margin-right: 1rem;\n}\n\n.xar-separator:after {\n margin-left: 1rem;\n}\n\n.xar-action__link {\n border: 0;\n background: none;\n text-underline-offset: 3px;\n text-transform: uppercase;\n text-decoration: underline;\n color: #3e9aff;\n font-weight: 700;\n font-size: var(--action-link-size);\n line-height: 19px;\n cursor: pointer;\n}\n\n.xar-action__link:disabled {\n color: #667b91;\n cursor: not-allowed;\n}\n\n.xar-loader__text {\n font-size: var(--loader-font-size);\n font-weight: var(--loader-font-weight);\n}\n\n.xar-loader-circle {\n stroke: var(--fg);\n}\n\n.xar-otp-box {\n display: flex;\n gap: 0.5em;\n}\n\n.xar-otp-input {\n color: var(--fg);\n font-size: 20px;\n font-weight: 400;\n border: none;\n outline: none;\n text-align: center;\n width: 30px;\n height: 35px;\n border-radius: 10px;\n background: var(--otp-bg);\n box-shadow: var(--otp-shadow);\n}\n\n.xar-invalid-otp {\n border: 1px solid #b43030;\n}\n\n.xar-invalid-otp-text {\n color: #b43030;\n}\n\n.xar-otp-input:disabled {\n opacity: 0.5;\n}\n\n.xar-otp-heading {\n font-family: 'Montserrat', sans-serif;\n font-size: 24px;\n font-weight: 700;\n text-align: center;\n color: var(--text-color);\n}\n\n.xar-otp-sub-heading {\n font-family: 'Montserrat', sans-serif;\n font-size: 12px;\n font-weight: 400;\n text-align: center;\n color: var(--text-color);\n}\n\n.xar-otp-error-heading {\n color: var(--fg);\n font-weight: 700;\n font-size: 24px;\n font-family: 'Montserrat', sans-serif;\n}\n.xar-otp-error-subheading {\n color: var(--text-color);\n font-weight: 400;\n font-size: 12px;\n font-family: 'Montserrat', sans-serif;\n}\n");const ce=({compact:e,logo:t})=>{const[n,i]=s(!1);return o(a,{children:[n?"":o("div",{className:"xar-header-logo__empty-container"}),o("div",Object.assign({className:"xar-header-logo__container",style:n?{}:{display:"none"}},{children:o("img",{className:"xar-header-logo",src:t,alt:"app-logo",onLoad:()=>{i(!1)}})})),e?"":o("div",Object.assign({className:"xar-header-text"},{children:[o("h1",Object.assign({className:"xar-header-heading"},{children:"Welcome"})),o("p",Object.assign({className:"xar-header-subtext"},{children:"We’ll email you a login link for a password-free sign in."}))]}))]})},he=({loginWithOTPStart:e,email:n,setEmail:i})=>{const[r,a]=s(!0);return l((()=>{a(!c(n))}),[]),o("form",Object.assign({className:"xar-email-login"},{children:[o("input",{value:n,onInput:e=>{i(e.currentTarget.value),a(!c(e.currentTarget.value))},className:"xar-email-login__input",type:"text",placeholder:"Enter your email"}),o("button",Object.assign({disabled:r,onClick:i=>t(void 0,void 0,void 0,(function*(){if(i.preventDefault(),!n)return;a(!0);const t=yield e(n);yield t.begin(),a(!1)})),className:"xar-btn"},{children:"Get Login OTP"}))]}))},ge=({text:e})=>o("div",Object.assign({className:"xar-separator"},{children:e})),ue=({loginWithSocial:e,loginList:t,mode:n})=>o("div",Object.assign({className:"xar-social-container"},{children:t.map((t=>{return o("div",Object.assign({className:"xar-social-icon__wrapper",onClick:()=>(t=>e(t))(t)},{children:o("img",{src:(i=t,r=n,re[`${i}_${r}`]?re[`${i}_${r}`]:re[i]),alt:`${t} logo`,className:"xar-social-icon"})}));var i,r}))})),pe=({mode:e})=>{const t=se[e];return o("div",Object.assign({className:"xar-footer"},{children:o("a",Object.assign({href:"https://arcana.network",target:"_blank",className:"xar-footer-img__link"},{children:o("img",{className:"xar-footer-img",src:t,alt:"Secured By Arcana"})}))}))},me=e=>o(a,{children:[e.header?e.header:o(ae,{compact:e.compact,stroke:8,secondaryColor:"#8D8D8D"}),e.text?o("p",Object.assign({className:"xar-loader__text"},{children:e.text})):"",e.children?o(a,{children:e.children}):""]}),fe=({loginWithOtpStart:e,loginWithOtpComplete:n,setError:i,closeFunc:r,compact:c})=>{const{counter:h,resetCounter:g}=ve(30),[u,p]=s(3),[m,f]=s(!1),[v,w]=s({loading:!1,text:""}),[x,y]=s(""),[b,_]=s(0),C=d([]),O=()=>x?x.toString().split(""):[],I=()=>{r()};l((()=>{6==x.length&&(f(!1),S(),w({loading:!0,text:"Processing..."}),n(x,I).then((()=>w({loading:!1,text:""}))).catch((e=>{console.log(e),p((e=>e-1)),f(!0),w({loading:!1,text:""}),y(""),k()})))}),[x]),l((()=>{0==u&&i()}),[u]),l((()=>{var e;null===(e=C.current[0])||void 0===e||e.focus()}),[]);const S=()=>{for(let e=0;e<6;e++){const t=C.current[e];t&&(t.disabled=!0)}},k=()=>{for(let e=0;e<6;e++){const t=C.current[e];t&&(t.disabled=!1)}},E=e=>{const t=O();t[b]=e[0],P(t)},P=e=>{const t=e.join("");y(t)},L=e=>{const t=e.target;var n;n=t.value,isNaN(Number(n))||1!==n.trim().length?(null===e.data&&"deleteContentBackward"===e.inputType&&(e.preventDefault(),E(""),N(b-1)),t.value=""):(E(t.value),N(b+1))},T=e=>{const t=O();[e.code,e.key].includes("Backspace")?(e.preventDefault(),E(""),N(b-1)):"Delete"===e.code?(e.preventDefault(),E("")):"ArrowLeft"===e.code?(e.preventDefault(),N(b-1)):"ArrowRight"===e.code||e.key===t[b]?(e.preventDefault(),N(b+1)):"Spacebar"!==e.code&&"Space"!==e.code&&"ArrowUp"!==e.code&&"ArrowDown"!==e.code||e.preventDefault()},N=e=>{var t,n;const i=Math.max(Math.min(5,e),0);C.current[i]&&(null===(t=C.current[i])||void 0===t||t.focus(),null===(n=C.current[i])||void 0===n||n.select(),_(i))},R=e=>{var t;e.preventDefault();const n=O();let i=b;if(!e.clipboardData)return;const o=e.clipboardData.getData("text/plain").slice(0,6-b).split("");if(!o.some((e=>isNaN(Number(e))))){for(let e=0;e<6;++e)e>=b&&o.length>0&&(n[e]=null!==(t=o.shift())&&void 0!==t?t:"",i++);N(i),P(n)}};return v.loading?o(a,{children:[o(ae,{stroke:8,secondaryColor:"#8D8D8D",compact:c}),o("div",Object.assign({class:"xar-loader__text"},{children:v.text}))]}):o(a,{children:[o("div",Object.assign({class:"xar-otp-heading"},{children:"Verification"})),o("div",Object.assign({class:"xar-otp-sub-heading"},{children:["Please enter the OTP that was sent to your ",o("br",{}),"email address"]})),o("div",Object.assign({className:"xar-otp-box"},{children:Array(6).fill(null).map(((e,t)=>{var n;return o("input",{value:null!==(n=O()[t])&&void 0!==n?n:"",type:"text",maxLength:1,autoComplete:"off",ref:e=>C.current[t]=e,onFocus:e=>(e=>t=>{_(t),e.target.select()})(e)(t),onInput:L,onKeyDown:T,onPaste:R,className:m?"xar-otp-input xar-invalid-otp":"xar-otp-input"},t)}))})),m?o("div",{children:o("p",Object.assign({class:"xar-invalid-otp-text"},{children:["Incorrect OTP. ",u," attempts left."]}))}):"",o("div",{children:o(ye,{disabled:h>0,text:h>0?`Resend code in ${h} seconds`:"Resend code",method:()=>t(void 0,void 0,void 0,(function*(){w({loading:!0,text:"Sending OTP to your email address"}),yield e(),g(),w({loading:!1,text:""})}))})})]})},ve=(e=60)=>{const[t,n]=s(e);return l((()=>{if(0==t)return void n(0);const e=setInterval((()=>{n(t-1)}),1e3);return()=>clearInterval(e)}),[t]),{counter:t,resetCounter:()=>n(e)}},we=({action:e})=>o(a,{children:[o("img",{class:"xar-header-logo",src:T,alt:"failed"}),o("h2",Object.assign({class:"xar-otp-error-heading"},{children:"Login Failed"})),o("p",Object.assign({class:"xar-otp-error-subheading"},{children:"Please check credentials and try again"})),o("button",Object.assign({className:"xar-btn",onClick:e},{children:"Go Home"}))]}),xe=({children:e,mode:t})=>o("div",Object.assign({class:"xar-container"},{children:[o("div",Object.assign({class:"xar-inner-container"},{children:e})),o(pe,{mode:t})]})),ye=({text:e,method:t,disabled:n=!1})=>o("div",Object.assign({class:"xar-action-container"},{children:o("button",Object.assign({disabled:n,onClick:()=>t(),className:"xar-action__link"},{children:e}))})),be="xar-modal",_e=e=>o("div",Object.assign({id:be,onClick:t=>{var n;(null===(n=t.target)||void 0===n?void 0:n.id)==be&&e.closeFunc&&e.closeFunc(new Error("User closed the connect modal"))}},{children:e.children})),Ce={SOCIAL:"Please complete the login to proceed",OTP_INIT:"Sending login OTP to your email address",OTP_SENT:"",OTP_SENT_GLOBAL:"Please complete the login to proceed",OTP_ERROR:"Invalid OTP, please try again"},Oe={text:"",loading:!1,type:""},Ie=(e,t)=>"OTP_SENT_GLOBAL"==t||"SOCIAL"==t||"OTP_SENT"==t||"OTP_INIT"==t||"OTP_ERROR"==t?{text:Ce[t],type:t,loading:"OTP_ERROR"!=t}:"RESET"==t?Oe:e,Se=e=>{const[n,i]=h(Ie,Oe),[r,l]=s("");return n.loading?o(_e,{children:o(xe,Object.assign({mode:e.mode},{children:"OTP_SENT"==n.type?o(fe,{loginWithOtpStart:()=>e.loginWithOTPStart(r),setError:()=>i("OTP_ERROR"),closeFunc:e.closeFunc,loginWithOtpComplete:e.loginWithOTPComplete,compact:e.options.compact}):o(me,{compact:e.options.compact,text:n.text,mode:e.mode})}))}):o(_e,Object.assign({closeFunc:e.closeFunc},{children:o(xe,Object.assign({mode:e.mode},{children:"OTP_ERROR"==n.type?o(we,{action:()=>i("RESET")}):o(a,{children:[o(ce,{compact:e.options.compact,logo:e.logo}),o(he,{email:r,setEmail:l,loginWithOTPStart:n=>t(void 0,void 0,void 0,(function*(){i("OTP_INIT");const t=yield e.loginWithOTPStart(n);return i(t.isCompleteRequired?"OTP_SENT":"OTP_SENT_GLOBAL"),t}))}),e.loginList.length>0?o(a,{children:[o(ge,{text:"or continue with"}),o(ue,{loginWithSocial:n=>t(void 0,void 0,void 0,(function*(){i("SOCIAL"),e.loginWithSocial(n).finally((()=>{i("RESET")}))})),loginList:e.loginList,mode:e.mode})]}):null]})}))}))};class ke{constructor(e){this.status="closed",this.close=e=>{"closed"!==this.status&&(this.onClose(e),this.status="closed",g(null,this.container))},this.params={loginList:e.loginList.filter((e=>"passwordless"!==e)),loginWithSocial:e.loginWithSocial,loginWithOTPStart:e.loginWithOTPStart,loginWithOTPComplete:e.loginWithOTPComplete,mode:e.mode,closeFunc:this.close,logo:e.logo,options:e.options},this.createContainer()}open(e){"open"!==this.status&&(this.onClose=e,this.status="open",g(o(Se,Object.assign({},this.params)),this.container))}createContainer(){const e=this.params.options.compact?"compact":"full";this.container=document.createElement("div"),this.container.setAttribute("id","xar-login-container"),this.container.classList.add(`xar-${this.params.mode}-mode`),this.container.classList.add(e),document.body.appendChild(this.container)}}class Ee{static create(e){return t(this,void 0,void 0,(function*(){const[t,n]=yield Promise.all([import("./solana.chunk.js"),import("./vendor.chunk.js").then((function(e){return e.i}))]);return new Ee(e,t,n)}))}constructor(e,t,n){this.p=e,this.web3Module=t,this.bs58Module=n}get isConnected(){return this.p.connected}request(e){return t(this,void 0,void 0,(function*(){const t=structuredClone(e);if("signMessage"===t.method){const e=t.params;e.message instanceof Uint8Array&&(e.message=this.bs58Module.encode(e.message))}const n=yield this.p.request(t);switch(t.method){case"signMessage":return this.parseSignatureResponse(n);case"signTransaction":return this.web3Module.VersionedTransaction.deserialize(this.bs58Module.decode(n));case"signAllTransactions":return n.map((e=>this.web3Module.VersionedTransaction.deserialize(this.bs58Module.decode(e))));default:return n}}))}parseSignatureResponse(e){return{signature:this.bs58Module.decode(e.signature),publicKey:new this.web3Module.PublicKey(e.publicKey)}}signMessage(e,t){return this.request({method:"signMessage",params:{message:this.bs58Module.encode(e),display:t}})}signTransaction(e){return this.request({method:"signTransaction",params:{message:this.bs58Module.encode(e.serialize())}})}signAndSendTransaction(e){return this.request({method:"signAndSendTransaction",params:{message:this.bs58Module.encode(e.serialize())}})}signAllTransactions(e){return this.request({method:"signAllTransactions",params:{message:e.map((e=>this.bs58Module.encode(e.serialize())))}})}}class Pe{constructor(e,n){this.initStatus=B.CREATED,this.initPromises=[],this.loginWithOTPStart=e=>t(this,void 0,void 0,(function*(){return yield this.init(),{begin:()=>this._loginWithOTPStart(e),isCompleteRequired:!("global"===(yield this._provider.getKeySpaceConfigType()))}})),this.loginWithOTPComplete=(e,n)=>t(this,void 0,void 0,(function*(){if("global"===(yield this._provider.getKeySpaceConfigType()))throw new Error("complete is not required for global login");yield this._loginWithOTPComplete(e,n)})),this.loginWithSocial=e=>t(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return this._provider;if(!(yield this._provider.isLoginAvailable(e)))throw new Error(`${e} login is not available`);const t=yield this._provider.initSocialLogin(e);return this.beginLogin(t)})),this.loginWithLink=(e,n)=>t(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return this._provider;if(!c(e))throw new Error("Invalid email");const t=yield this._provider.initPasswordlessLogin(e);return t&&"string"==typeof t?this.beginLogin(t):(n&&n(),yield this.waitForConnect())})),this._loginWithOTPStart=e=>t(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return;if(!c(e))throw new Error("Invalid email");const t=yield this._provider.initOTPLogin(e);t&&"string"==typeof t&&(yield this.beginLogin(t))})),this._loginWithOTPComplete=(e,n)=>t(this,void 0,void 0,(function*(){return yield this.init(),(yield this.isLoggedIn())?this._provider:(this._provider.once("message",(e=>{"mfa_flow"===e&&n&&n()})),yield this._provider.completeOTPLogin(e),yield this.waitForConnect())})),this.loginWithBearer=(e,n)=>t(this,void 0,void 0,(function*(){return yield this.init(),yield this.iframeWrapper.triggerBearerAuthentication(e,n)}));let i=null==n?void 0:n.network,o=e;if((e=>{if(!N(e))throw new u("invalid_client_id","Invalid Client ID");return 3==e.split("_").length})(e)){const t=(e=>{const t=e.split("_"),[,n,i]=t;if(!R(i))throw new Error("Invalid ClientId");if("live"==n)return{network:"mainnet",address:i};if("test"==n)return{network:"testnet",address:i};if("dev"==n)return{network:"dev",address:i};throw new Error("Invalid ClientId")})(e);i=t.network,o=t.address}var r;(e=>{if(!(e=>null!=e)(e))throw new Error("appAddress is required");if(!N(e))throw new Error("appAddress is required to be a non-empty string");if(!R(e))throw new Error("appAddress is required to be an ethereum address")})(o),this.appId=U(o),this.params=(e=>{var t;const n={network:"testnet",debug:!1,position:"right",theme:"dark",alwaysVisible:!0,setWindowProvider:!1,connectOptions:{compact:!1}};return(null==e?void 0:e.network)&&(n.network=e.network),void 0!==(null==e?void 0:e.debug)&&(n.debug=e.debug),(null==e?void 0:e.theme)&&(n.theme=e.theme),(null==e?void 0:e.position)&&(n.position=e.position),void 0!==(null==e?void 0:e.alwaysVisible)&&(n.alwaysVisible=e.alwaysVisible),void 0!==(null===(t=null==e?void 0:e.connectOptions)||void 0===t?void 0:t.compact)&&(n.connectOptions.compact=e.connectOptions.compact),"testnet"!=n.network&&"dev"!=n.network||console.log(`%c[XAR_AUTH_SDK] You are currently on ${n.network} network.`,"color: red"),n})(Object.assign(Object.assign({},n),{network:i})),this.networkConfig=(e=>{if("string"==typeof e&&"testnet"==e)return ee;if("string"==typeof e&&"dev"==e)return Q;if("string"==typeof e&&"mainnet"==e)return te;if(function(e){return"string"!=typeof e&&(!("object"!=typeof e||!e.gatewayUrl)&&(!("object"!=typeof e||!e.walletUrl)&&!("object"!=typeof e||!e.authUrl)))}(e))return e;throw new Error("Invalid network config passed")})(this.params.network),function(e,t){try{if("undefined"==typeof document)return;const n=document.createElement("link");n.href=`${e}/${t}/login`,n.type="text/html",n.rel="prefetch",document.head.appendChild(n)}catch(e){console.warn(e)}}(this.networkConfig.walletUrl,this.appId),this._provider=new F(this.networkConfig.authUrl),this.params.debug?(C(v),r=e=>{console.error(e)},I.exceptionReporter=r):C(b)}init(){var e;return t(this,void 0,void 0,(function*(){if(this.initStatus===B.CREATED){if(this.initStatus=B.RUNNING,this.iframeWrapper)return this;if(yield this.setAppConfig(),this.iframeWrapper=new Z({appId:this.appId,iframeUrl:this.networkConfig.walletUrl,appConfig:this.appConfig,position:this.params.position,standaloneMode:this._standaloneMode}),this.iframeWrapper.setWalletType(null!==(e=this.params.appMode)&&void 0!==e?e:this.params.alwaysVisible?J.Full:J.Widget),yield this._provider.init(this.iframeWrapper,this),this.setProviders(),this.appConfig.chainType===H.solana_cv25519)this._solanaAPI=yield Ee.create(this._provider);return this.initStatus=B.DONE,this.resolveInitPromises(),this}return this.initStatus===B.RUNNING?yield this.waitForInit():this}))}connect(){return t(this,void 0,void 0,(function*(){if(this.initStatus!==B.DONE&&(yield this.init()),yield this.isLoggedIn())return this._provider;const e=yield this.getLogins();return this.connectCtrl||(this.connectCtrl=new ke({loginWithOTPStart:this.loginWithOTPStart,loginWithOTPComplete:this.loginWithOTPComplete,loginWithSocial:this.loginWithSocial,loginList:e,mode:this.theme,logo:this.logo.vertical,options:this.params.connectOptions})),new Promise(((e,t)=>{this.connectCtrl.open((e=>{if(e)return t(e)})),this.waitForConnect().then((t=>{this.connectCtrl.close(),e(t)})).catch(t)}))}))}showWallet(){if(!this.connected)throw new Error("no connection yet, cannot show wallet");this._provider.expandWallet()}get connected(){return this._provider.connected}getUser(){if(this.initStatus===B.DONE)return this._provider.requestUserInfo();throw m}isLoggedIn(){return t(this,void 0,void 0,(function*(){if(this.initStatus===B.DONE){return yield this._provider.isLoggedIn()}throw m}))}logout(){if(this.initStatus===B.DONE)return this._provider.triggerLogout();throw m}getPublicKey(e,n="google"){return t(this,void 0,void 0,(function*(){if(this.initStatus===B.DONE){if(!e||""===e)throw new u("email_required",`Email is required in getPublicKey, got ${e}`);return yield this._provider.getPublicKey(e,n)}throw m}))}getLogins(){return t(this,void 0,void 0,(function*(){if(this.initStatus===B.DONE)return yield this._provider.getAvailableLogins();throw m}))}getProvider(){if(this.initStatus===B.DONE)return this._provider;throw m}canReconnect(){return t(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return!1;const e=this.iframeWrapper.getSessionID();return!!e&&!(e.expiry<Date.now())}))}reconnect(){return t(this,void 0,void 0,(function*(){if(yield this.init(),yield this.isLoggedIn())return void(yield this.waitForConnect());const e=this.iframeWrapper.getSessionID();if(e){if(e.expiry<Date.now())throw new Error("cannot reconnect, session expired");const t=new URL(yield this._provider.getReconnectionUrl());t.searchParams.set("sessionID",e.id);const n=new S(t.toString());return yield n.open(),void(yield this.waitForConnect())}throw new Error("cannot reconnect, no session found")}))}get chainId(){return this._provider.chainId}beginLogin(e){return t(this,void 0,void 0,(function*(){const t=new S(e);return yield t.open(),yield this.waitForConnect()}))}waitForConnect(){return new Promise((e=>{if(this.connected)return e(this._provider);this._provider.once("connect",(()=>e(this._provider)))}))}setAppConfig(){return t(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([ne(this.appId,this.networkConfig.gatewayUrl),ie(this.appId,this.networkConfig.gatewayUrl)]),n=function(e,t,n){const i=new URL(`/api/v2/app/${e}/logo?type=${t}`,n);return{horizontal:`${i.toString()}&orientation=horizontal`,vertical:`${i.toString()}&orientation=vertical`}}(this.appId,this.params.theme,this.networkConfig.gatewayUrl),i=e.logo.dark_horizontal||e.logo.light_horizontal,o=e.logo.dark_vertical||e.logo.light_vertical;this.appConfig={name:t.name,chainType:"evm"===t.chain_type.toLowerCase()?H.evm_secp256k1:H.solana_cv25519,themeConfig:{assets:{logo:{horizontal:i?n.horizontal:"",vertical:o?n.vertical:""}},theme:this.params.theme}}}))}waitForInit(){return t(this,void 0,void 0,(function*(){const e=new Promise((e=>{this.initPromises.push(e)}));return yield e}))}resolveInitPromises(){const e=this.initPromises;this.initPromises=[];for(const t of e)t(this)}get provider(){if(this._provider)return this._provider;throw m}get solana(){if(this._solanaAPI)return this._solanaAPI;throw m}get logo(){if(this.initStatus===B.DONE)return this.appConfig.themeConfig.assets.logo;throw m}get theme(){if(this.initStatus===B.DONE)return this.appConfig.themeConfig.theme;throw m}setProviders(){var e;void 0!==typeof window&&(this.providerInfo={uuid:window.crypto.randomUUID(),name:"Arcana Wallet",icon:"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'/>",rdns:"network.arcana.wallet"},e=()=>{var e,t,n;const i=window;try{i.arcana=null!==(e=i.arcana)&&void 0!==e?e:{},i.arcana.provider=this._provider}catch(e){}if(this.params.setWindowProvider)try{i.ethereum=null!==(t=i.ethereum)&&void 0!==t?t:this._provider,i.ethereum.providers=null!==(n=i.ethereum.providers)&&void 0!==n?n:[],i.ethereum.providers.push(this._provider)}catch(e){console.error(e)}this.announceProvider(),window.addEventListener("eip6963:requestProvider",(()=>{this.announceProvider()}))},"complete"===document.readyState?e():window.addEventListener("load",e))}announceProvider(){window.dispatchEvent(new CustomEvent("eip6963:announceProvider",{detail:Object.freeze({info:this.providerInfo,provider:this._provider})}))}standaloneMode(e,t){this._standaloneMode={mode:e,handler:t}}}export{Pe as AuthProvider,V as BearerAuthentication}; |
@@ -22,2 +22,5 @@ import { ArcanaProvider } from './provider'; | ||
init(): Promise<AuthProvider>; | ||
/** | ||
* A function to start otp login | ||
*/ | ||
loginWithOTPStart: (email: string) => Promise<{ | ||
@@ -27,4 +30,7 @@ begin: () => Promise<void>; | ||
}>; | ||
loginWithOTPComplete: (email: string, onMFAFlow?: () => void) => Promise<void>; | ||
/** | ||
* A function to finish otp login | ||
*/ | ||
loginWithOTPComplete: (otp: string, onMFAFlow?: () => void) => Promise<void>; | ||
/** | ||
* A function to open login plug n play modal | ||
@@ -43,2 +49,3 @@ */ | ||
* A function to trigger passwordless login in the wallet | ||
* @deprecated use loginWithOTPStart and loginWithOTPComplete instead | ||
*/ | ||
@@ -45,0 +52,0 @@ loginWithLink: (email: string, emailSentHook?: () => void) => Promise<EthereumProvider>; |
@@ -22,2 +22,5 @@ import { ArcanaProvider } from './provider'; | ||
init(): Promise<AuthProvider>; | ||
/** | ||
* A function to start otp login | ||
*/ | ||
loginWithOTPStart: (email: string) => Promise<{ | ||
@@ -27,4 +30,7 @@ begin: () => Promise<void>; | ||
}>; | ||
loginWithOTPComplete: (email: string, onMFAFlow?: () => void) => Promise<void>; | ||
/** | ||
* A function to finish otp login | ||
*/ | ||
loginWithOTPComplete: (otp: string, onMFAFlow?: () => void) => Promise<void>; | ||
/** | ||
* A function to open login plug n play modal | ||
@@ -43,2 +49,3 @@ */ | ||
* A function to trigger passwordless login in the wallet | ||
* @deprecated use loginWithOTPStart and loginWithOTPComplete instead | ||
*/ | ||
@@ -45,0 +52,0 @@ loginWithLink: (email: string, emailSentHook?: () => void) => Promise<EthereumProvider>; |
{ | ||
"name": "@arcana/auth", | ||
"version": "1.0.9", | ||
"version": "1.0.10-rc.1", | ||
"description": "Arcana Auth", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3528
928376
2