diff --git a/Web/index.js b/Web/index.js index d44b316..d359772 100644 --- a/Web/index.js +++ b/Web/index.js @@ -1,4 +1,4 @@ -!function(e,t,r,i,n){var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof a[i]&&a[i],o=s.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function c(t,r){if(!o[t]){if(!e[t]){var n="function"==typeof a[i]&&a[i];if(!r&&n)return n(t,!0);if(s)return s(t,!0);if(f&&"string"==typeof t)return f(t);var d=Error("Cannot find module '"+t+"'");throw d.code="MODULE_NOT_FOUND",d}l.resolve=function(r){var i=e[t][1][r];return null!=i?i:r},l.cache={};var u=o[t]=new c.Module(t);e[t][0].call(u.exports,l,u,u.exports,this)}return o[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:c(t)}}c.isParcelRequire=!0,c.Module=function(e){this.id=e,this.bundle=c,this.exports={}},c.modules=e,c.cache=o,c.parent=s,c.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(c,"root",{get:function(){return a[i]}}),a[i]=c;for(var d=0;d{let t=JSON.stringify(e);if(console.log(`callbackToGame: ${t}`),void 0!==window.ue){if(void 0===window.ue.jsconnector){let e="Unreal JSConnector not defined";throw console.error(e),Error(e)}window.ue.jsconnector.sendtogame(t)}else if("undefined"!=typeof blu_event)blu_event("sendtogame",t);else if("undefined"!=typeof UnityPostMessage)UnityPostMessage(t);else if("undefined"!==window.Unity)window.Unity.call(t);else{let e="No available game callbacks to call from ImmutableSDK game-bridge";throw console.error(e),Error(e)}},m=()=>{if(null==i)throw Error("No Passport client");return i},g=e=>null!=e?(n=e,console.log("IMX provider set"),!0):(console.log("No IMX provider"),!1),y=()=>{if(null==n)throw Error("No IMX provider");return n},v=e=>null!=e?(a=e,console.log("zkEvm provider set"),!0):(console.log("No zkEvm provider"),!1),w=()=>{if(null==a)throw Error("No zkEvm provider");return a},_=e=>Date.now()-e;(0,d.track)(l,"loadedGameBridge",{sdkVersionTag:h}),window.callFunction=async e=>{console.log(`Call function ${e}`);let t=null,r=null,o=Date.now();try{let M=JSON.parse(e);t=M.fxName,r=M.requestId;let E=M.data;switch((0,d.track)(l,"startedCallFunction",{function:t,requestId:r}),t){case p.init:{let e=JSON.parse(E),n=e?.redirectUri,a=e?.isSilentLogout===!0?"silent":"redirect";if(!i){let t={baseConfig:new c.ImmutableConfiguration({environment:e.environment}),clientId:e.clientId,audience:"platform_api",scope:"openid offline_access profile email transact",redirectUri:n??"https://localhost:3000/",logoutRedirectUri:e?.logoutRedirectUri,crossSdkBridgeEnabled:!0,logoutMode:a};i=new f.Passport(t),(0,d.trackDuration)(l,"initialisedPassport",_(o))}b({responseFor:t,requestId:r,success:!0,error:null});let{engineVersion:u}=e;s={gameBridgeTag:h,gameBridgeSha:"603dc982247130dee516fc1c54facf2c179ef1b7",engine:u.engine,engineVersion:u.engineVersion,engineSdkVersion:u.engineSdkVersion??"",platform:u.platform,platformVersion:u.platformVersion,deviceModel:u.deviceModel??"N/A"},console.log(`Version check: ${JSON.stringify(s)}`),(0,d.trackDuration)(l,"completedInitGameBridge",_(o),{...s});break}case p.initDeviceFlow:{let e=await m().loginWithDeviceFlow();(0,d.trackDuration)(l,"performedInitDeviceFlow",_(o)),b({responseFor:t,requestId:r,success:!0,error:null,code:e.code,deviceCode:e.deviceCode,url:e.url,interval:e.interval});break}case p.relogin:{let e=await m().login({useCachedSession:!0}),i=null!==e;if(!i)throw Error("Failed to re-login");(0,d.identify)({passportId:e?.sub}),(0,d.trackDuration)(l,"performedRelogin",_(o),{succeeded:i}),b({responseFor:t,requestId:r,success:null!==e,error:null});break}case p.reconnect:{let e=!1,i=await m().login({useCachedSession:!0});if(i){let t=await m().connectImx();e=g(t),(0,d.identify)({passportId:i?.sub})}if(!e)throw Error("Failed to reconnect");(0,d.trackDuration)(l,"performedReconnect",_(o),{succeeded:null!==i}),b({responseFor:t,requestId:r,success:e,error:null});break}case p.getPKCEAuthUrl:{let e=m().loginWithPKCEFlow();(0,d.trackDuration)(l,"performedGetPkceAuthUrl",_(o)),b({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case p.loginPKCE:{let e=JSON.parse(E),i=await m().loginWithPKCEFlowCallback(e.authorizationCode,e.state);(0,d.identify)({passportId:i.sub}),(0,d.trackDuration)(l,"performedLoginPkce",_(o)),b({responseFor:t,requestId:r,success:!0,error:null});break}case p.connectPKCE:{let e=JSON.parse(E),i=await m().loginWithPKCEFlowCallback(e.authorizationCode,e.state),n=await m().connectImx(),a=g(n);if(!a)throw Error("Failed to connect via PKCE");(0,d.identify)({passportId:i.sub}),(0,d.trackDuration)(l,"performedConnectPkce",_(o),{succeeded:a}),b({responseFor:t,requestId:r,success:a,error:null});break}case p.loginConfirmCode:{let e=JSON.parse(E),i=await m().loginWithDeviceFlowCallback(e.deviceCode,e.interval,e.timeoutMs??null);(0,d.identify)({passportId:i.sub}),(0,d.trackDuration)(l,"performedLoginConfirmCode",_(o)),b({responseFor:t,requestId:r,success:!0,error:null});break}case p.connectConfirmCode:{let e=JSON.parse(E),i=await m().loginWithDeviceFlowCallback(e.deviceCode,e.interval,e.timeoutMs??null),n=await m().connectImx(),a=g(n);if(!a)throw Error("Failed to connect via confirm code");(0,d.identify)({passportId:i.sub}),(0,d.trackDuration)(l,"performedConnectConfirmCode",_(o),{succeeded:a}),b({responseFor:t,requestId:r,success:a,error:null});break}case p.logout:{let e=await m().logoutDeviceFlow();n=null,a=null,(0,d.trackDuration)(l,"performedGetLogoutUrl",_(o)),b({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case p.getAccessToken:{let e=await m().getAccessToken(),i=void 0!==e;if(!i)throw Error("No access token");(0,d.trackDuration)(l,"performedGetAccessToken",_(o)),b({responseFor:t,requestId:r,success:i,error:null,result:e});break}case p.getIdToken:{let e=await m().getIdToken(),i=void 0!==e;if(!i)throw Error("No ID token");(0,d.trackDuration)(l,"performedGetIdToken",_(o)),b({responseFor:t,requestId:r,success:i,error:null,result:e});break}case p.getEmail:{let e=await m().getUserInfo(),i=e?.email!==void 0;if(!i)throw Error("No email");(0,d.trackDuration)(l,"performedGetEmail",_(o)),b({responseFor:t,requestId:r,success:i,error:null,result:e?.email});break}case p.getPassportId:{let e=await m().getUserInfo(),i=e?.sub!==void 0;if(!i)throw Error("No Passport ID");(0,d.trackDuration)(l,"performedGetPassportId",_(o)),b({responseFor:t,requestId:r,success:i,error:null,result:e?.sub});break}case p.getLinkedAddresses:{let e=await m().getLinkedAddresses();(0,d.trackDuration)(l,"performedGetLinkedAddresses",_(o)),b({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case p.imx.getAddress:{let e=await y().getAddress();(0,d.trackDuration)(l,"performedImxGetAddress",_(o)),b({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case p.imx.isRegisteredOffchain:{let e=await y().isRegisteredOffchain();(0,d.trackDuration)(l,"performedImxIsRegisteredOffchain",_(o)),b({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case p.imx.registerOffchain:{let e=await y().registerOffchain();(0,d.trackDuration)(l,"performedImxRegisterOffchain",_(o)),b({responseFor:t,requestId:r,success:!0,error:null,...e});break}case p.imx.transfer:{let e=JSON.parse(E),i=await y().transfer(e);(0,d.trackDuration)(l,"performedImxTransfer",_(o),{requestId:r,transferRequest:JSON.stringify(e),transferResponse:JSON.stringify(i)}),b({responseFor:t,requestId:r,success:!0,error:null,...i});break}case p.imx.batchNftTransfer:{let e=JSON.parse(E),i=await y().batchNftTransfer(e);(0,d.trackDuration)(l,"performedImxBatchNftTransfer",_(o),{requestId:r,transferRequest:JSON.stringify(e),transferResponse:JSON.stringify(i)}),b({responseFor:t,requestId:r,success:!0,error:null,...i});break}case p.zkEvm.connectEvm:{let e=m().connectEvm(),i=v(e);if(!i)throw Error("Failed to connect to EVM");(0,d.trackDuration)(l,"performedZkevmConnectEvm",_(o),{succeeded:i}),b({responseFor:t,requestId:r,success:i,error:null});break}case p.zkEvm.sendTransaction:{let e=JSON.parse(E),i=await w().request({method:"eth_sendTransaction",params:[e]}),n=null!=i;if(!n)throw Error("Failed to send transaction");(0,d.trackDuration)(l,"performedZkevmSendTransaction",_(o),{requestId:r,transactionRequest:JSON.stringify(e),transactionResponse:i}),b({responseFor:t,requestId:r,success:n,error:null,result:i});break}case p.zkEvm.sendTransactionWithConfirmation:{let e=JSON.parse(E),i=w(),n=new u.providers.Web3Provider(i),a=n.getSigner(),s=await a.sendTransaction(e),f=await s.wait();(0,d.trackDuration)(l,"performedZkevmSendTransactionWithConfirmation",_(o),{requestId:r,transactionRequest:JSON.stringify(e),transactionResponse:JSON.stringify(f)}),b({responseFor:t,requestId:r,success:!0,error:null,...f});break}case p.zkEvm.requestAccounts:{let e=await w().request({method:"eth_requestAccounts"}),i=null!=e;if(!i)throw Error("Failed to request accounts");(0,d.trackDuration)(l,"performedZkevmRequestAccounts",_(o)),b({responseFor:t,requestId:r,success:i,error:null,accounts:e});break}case p.zkEvm.getBalance:{let e=JSON.parse(E),i=await w().request({method:"eth_getBalance",params:[e.address,e.blockNumberOrTag]}),n=null!=i;if(!n)throw Error("Failed to get balance");(0,d.trackDuration)(l,"performedZkevmGetBalance",_(o)),b({responseFor:t,requestId:r,success:n,error:null,result:i});break}case p.zkEvm.getTransactionReceipt:{let e=JSON.parse(E),i=await w().request({method:"eth_getTransactionReceipt",params:[e.txHash]}),n=void 0!==i;if(!n)throw Error("Failed to get transaction receipt");(0,d.trackDuration)(l,"performedZkevmGetTransactionReceipt",_(o)),b({responseFor:t,requestId:r,success:n,error:null,...i});break}case"track":{let e=JSON.parse(E),i=e.properties?JSON.parse(e.properties):{};(0,d.track)(e.moduleName,e.eventName,i),b({responseFor:t,requestId:r,success:!0,error:null})}}}catch(n){let e;console.log(`Error in callFunction: ${n}`),e=n instanceof Error?n:Error(n);let i=n instanceof f.PassportError?n?.type:void 0;(0,d.trackError)(l,t,e,{fxName:t,requestId:r,errorType:i,...s}),(0,d.trackDuration)(l,"failedCallFunction",_(o),{fxName:t,requestId:r,error:e.message}),console.log("callFunction error",e),console.log("callFunction errorType",i),b({responseFor:t,requestId:r,success:!1,error:n?.message!==null&&n?.message!==void 0?n.message:"Error",errorType:n instanceof f.PassportError?n?.type:null})}},window.addEventListener("offline",()=>{console.log("gameBridge offline")}),window.addEventListener("online",()=>{console.log("gameBridge online")}),console.log("index.ts loaded"),o=function(){b({responseFor:"init",requestId:"1",success:!0,error:null})},"complete"===document.readyState?o():window.addEventListener("load",o)},{"@imtbl/passport":"iPtWy","@imtbl/config":"ed8SG","@imtbl/metrics":"dO0KB",ethers:"8wpcu"}],iPtWy:[function(e,t,r){let i;var n,a,s,o,f,c,d,u,l,h,p,b,m,g,y=e("@parcel/transformer-js/src/esmodule-helpers.js");y.defineInteropFlag(r),y.export(r,"JsonRpcError",()=>e6),y.export(r,"Passport",()=>tT),y.export(r,"PassportError",()=>K),y.export(r,"ProviderErrorCode",()=>m),y.export(r,"ProviderEvent",()=>b),y.export(r,"RpcErrorCode",()=>g);var v=e("axios"),w=y.interopDefault(v),_=e("@imtbl/generated-clients"),M=e("@imtbl/x-client"),E=e("@imtbl/config"),A=e("@imtbl/metrics"),S=e("oidc-client-ts"),x=e("crypto"),I=e("jwt-decode"),R=y.interopDefault(I),T=e("localforage"),k=y.interopDefault(T),C=e("magic-sdk"),P=e("@magic-ext/oidc"),O=e("@ethersproject/providers"),N=e("@imtbl/toolkit"),j=e("@imtbl/guardian"),B=e("ethers"),L=e("events"),D=e("@0xsequence/abi"),F=e("@0xsequence/core"),U=e("uuid"),q=e("a7402fb880ab41a1");function z(e){return"code"in e&&"message"in e}(n=d||(d={})).AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",n.INVALID_CONFIGURATION="INVALID_CONFIGURATION",n.WALLET_CONNECTION_ERROR="WALLET_CONNECTION_ERROR",n.NOT_LOGGED_IN_ERROR="NOT_LOGGED_IN_ERROR",n.SILENT_LOGIN_ERROR="SILENT_LOGIN_ERROR",n.REFRESH_TOKEN_ERROR="REFRESH_TOKEN_ERROR",n.USER_REGISTRATION_ERROR="USER_REGISTRATION_ERROR",n.USER_NOT_REGISTERED_ERROR="USER_NOT_REGISTERED_ERROR",n.LOGOUT_ERROR="LOGOUT_ERROR",n.TRANSFER_ERROR="TRANSFER_ERROR",n.CREATE_ORDER_ERROR="CREATE_ORDER_ERROR",n.CANCEL_ORDER_ERROR="CANCEL_ORDER_ERROR",n.EXCHANGE_TRANSFER_ERROR="EXCHANGE_TRANSFER_ERROR",n.CREATE_TRADE_ERROR="CREATE_TRADE_ERROR",n.OPERATION_NOT_SUPPORTED_ERROR="OPERATION_NOT_SUPPORTED_ERROR",n.LINK_WALLET_ALREADY_LINKED_ERROR="LINK_WALLET_ALREADY_LINKED_ERROR",n.LINK_WALLET_MAX_WALLETS_LINKED_ERROR="LINK_WALLET_MAX_WALLETS_LINKED_ERROR",n.LINK_WALLET_VALIDATION_ERROR="LINK_WALLET_VALIDATION_ERROR",n.LINK_WALLET_DUPLICATE_NONCE_ERROR="LINK_WALLET_DUPLICATE_NONCE_ERROR",n.LINK_WALLET_GENERIC_ERROR="LINK_WALLET_GENERIC_ERROR";class K extends Error{type;constructor(e,t){super(e),this.type=t}}let H=async(e,t)=>{try{return await e()}catch(r){let e;throw e=(0,v.isAxiosError)(r)&&r.response?.data&&z(r.response.data)?r.response.data.message:r.message,new K(e,t)}},W="pkce_state",V="pkce_verifier";class G{areValid(e){if(e){let t=this.isTokenValid(e.access_token),r=this.isTokenValid(e.id_token);return t&&r}return!1}isTokenValid(e){try{let t=(0,R.default)(e),r=t.exp??0,i=Date.now()/1e3+3600;return r>i}catch(e){return!1}}savePKCEData(e){localStorage.setItem(W,e.state),localStorage.setItem(V,e.verifier)}getPKCEData(){let e=localStorage.getItem(W),t=localStorage.getItem(V);return e&&t?{state:e,verifier:t}:null}}var J={warn:(...e)=>{if(void 0===q)return;let t=q?.env?.JEST_WORKER_ID===void 0;t&&console.warn(...e)}};(a=u||(u={})).LOGGED_OUT="loggedOut",a.LOGGED_IN="loggedIn",a.ACCOUNTS_REQUESTED="accountsRequested";let Z=e=>!!e.zkEvm,X=e=>!!e.imx,$="passport-overlay",Y=`${$}-close`,Q=`${$}-try-again`,ee=` +!function(e,t,r,i,n){var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof a[i]&&a[i],o=s.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,r){if(!o[t]){if(!e[t]){var n="function"==typeof a[i]&&a[i];if(!r&&n)return n(t,!0);if(s)return s(t,!0);if(f&&"string"==typeof t)return f(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}l.resolve=function(r){var i=e[t][1][r];return null!=i?i:r},l.cache={};var u=o[t]=new d.Module(t);e[t][0].call(u.exports,l,u,u.exports,this)}return o[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.exports={}},d.modules=e,d.cache=o,d.parent=s,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return a[i]}}),a[i]=d;for(var c=0;c{let t=JSON.stringify(e);if(console.log(`callbackToGame: ${t}`),void 0!==window.ue){if(void 0===window.ue.jsconnector){let e="Unreal JSConnector not defined";throw console.error(e),Error(e)}window.ue.jsconnector.sendtogame(t)}else if("undefined"!=typeof blu_event)blu_event("sendtogame",t);else if("undefined"!=typeof UnityPostMessage)UnityPostMessage(t);else if("undefined"!==window.Unity)window.Unity.call(t);else{let e="No available game callbacks to call from ImmutableSDK game-bridge";throw console.error(e),Error(e)}},w=()=>{if(null==i)throw Error("No Passport client");return i},_=e=>null!=e?(n=e,console.log("IMX provider set"),!0):(console.log("No IMX provider"),!1),M=()=>{if(null==n)throw Error("No IMX provider");return n},E=e=>null!=e?(a=e,console.log("zkEvm provider set"),!0):(console.log("No zkEvm provider"),!1),A=()=>{if(null==a)throw Error("No zkEvm provider");return a},S=e=>Date.now()-e;(0,u.track)(m,"loadedGameBridge",{sdkVersionTag:g}),window.callFunction=async e=>{console.log(`Call function ${e}`);let t=null,r=null,o=Date.now();try{let x=JSON.parse(e);t=x.fxName,r=x.requestId;let I=x.data;switch(t){case y.init:{let e=JSON.parse(I),n=e?.redirectUri,a=e?.isSilentLogout===!0?"silent":"redirect";if(!i){let t;console.log(`Connecting to ${e.environment} environment`);let r="production"===e.environment?d.Environment.PRODUCTION:d.Environment.SANDBOX,s=new d.ImmutableConfiguration({environment:r});t="dev"===e.environment||"development"===e.environment?{baseConfig:s,clientId:e.clientId,redirectUri:n??b,logoutRedirectUri:e?.logoutRedirectUri,audience:p,scope:h,crossSdkBridgeEnabled:!0,logoutMode:a,overrides:{authenticationDomain:"https://auth.dev.immutable.com",magicPublishableApiKey:"pk_live_4058236363130CA9",magicProviderId:"C9odf7hU4EQ5EufcfgYfcBaT5V6LhocXyiPRhIjw2EY=",passportDomain:"https://passport.dev.immutable.com",imxPublicApiDomain:"https://api.dev.immutable.com",immutableXClient:new c.IMXClient({baseConfig:s,overrides:{immutableXConfig:c.createConfig({basePath:"https://api.dev.x.immutable.com",chainID:5,coreContractAddress:"0xd05323731807A35599BF9798a1DE15e89d6D6eF1",registrationContractAddress:"0x7EB840223a3b1E0e8D54bF8A6cd83df5AFfC88B2"})}}),zkEvmRpcUrl:"https://rpc.dev.immutable.com",relayerUrl:"https://api.dev.immutable.com/relayer-mr",indexerMrBasePath:"https://api.dev.immutable.com",orderBookMrBasePath:"https://api.dev.immutable.com",passportMrBasePath:"https://api.dev.immutable.com"}}:{baseConfig:s,clientId:e.clientId,audience:p,scope:h,redirectUri:n??b,logoutRedirectUri:e?.logoutRedirectUri,crossSdkBridgeEnabled:!0,logoutMode:a},i=new f.Passport(t),(0,u.trackDuration)(m,"initialisedPassport",S(o))}v({responseFor:t,requestId:r,success:!0,error:null});let{engineVersion:l}=e;s={gameBridgeTag:g,gameBridgeSha:"4f52795f78561e593faaa89d6bd39a85d9d7d05b",engine:l.engine,engineVersion:l.engineVersion,engineSdkVersion:l.engineSdkVersion??"",platform:l.platform,platformVersion:l.platformVersion,deviceModel:l.deviceModel??"N/A"},console.log(`Version check: ${JSON.stringify(s)}`),(0,u.trackDuration)(m,"completedInitGameBridge",S(o),{...s});break}case y.initDeviceFlow:{let e=await w().loginWithDeviceFlow();(0,u.trackDuration)(m,"performedInitDeviceFlow",S(o)),v({responseFor:t,requestId:r,success:!0,error:null,code:e.code,deviceCode:e.deviceCode,url:e.url,interval:e.interval});break}case y.relogin:{let e=await w().login({useCachedSession:!0}),i=null!==e;if(!i)throw Error("Failed to re-login");(0,u.identify)({passportId:e?.sub}),(0,u.trackDuration)(m,"performedRelogin",S(o),{succeeded:i}),v({responseFor:t,requestId:r,success:null!==e,error:null});break}case y.reconnect:{let e=!1,i=await w().login({useCachedSession:!0});if(i){let t=await w().connectImx();e=_(t),(0,u.identify)({passportId:i?.sub})}if(!e)throw Error("Failed to reconnect");(0,u.trackDuration)(m,"performedReconnect",S(o),{succeeded:null!==i}),v({responseFor:t,requestId:r,success:e,error:null});break}case y.getPKCEAuthUrl:{let e=w().loginWithPKCEFlow();(0,u.trackDuration)(m,"performedGetPkceAuthUrl",S(o)),v({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case y.loginPKCE:{let e=JSON.parse(I),i=await w().loginWithPKCEFlowCallback(e.authorizationCode,e.state);(0,u.identify)({passportId:i.sub}),(0,u.trackDuration)(m,"performedLoginPkce",S(o)),v({responseFor:t,requestId:r,success:!0,error:null});break}case y.connectPKCE:{let e=JSON.parse(I),i=await w().loginWithPKCEFlowCallback(e.authorizationCode,e.state),n=await w().connectImx(),a=_(n);if(!a)throw Error("Failed to connect via PKCE");(0,u.identify)({passportId:i.sub}),(0,u.trackDuration)(m,"performedConnectPkce",S(o),{succeeded:a}),v({responseFor:t,requestId:r,success:a,error:null});break}case y.loginConfirmCode:{let e=JSON.parse(I),i=await w().loginWithDeviceFlowCallback(e.deviceCode,e.interval,e.timeoutMs??null);(0,u.identify)({passportId:i.sub}),(0,u.trackDuration)(m,"performedLoginConfirmCode",S(o)),v({responseFor:t,requestId:r,success:!0,error:null});break}case y.connectConfirmCode:{let e=JSON.parse(I),i=await w().loginWithDeviceFlowCallback(e.deviceCode,e.interval,e.timeoutMs??null),n=await w().connectImx(),a=_(n);if(!a)throw Error("Failed to connect via confirm code");(0,u.identify)({passportId:i.sub}),(0,u.trackDuration)(m,"performedConnectConfirmCode",S(o),{succeeded:a}),v({responseFor:t,requestId:r,success:a,error:null});break}case y.logout:{let e=await w().logoutDeviceFlow();n=null,a=null,(0,u.trackDuration)(m,"performedGetLogoutUrl",S(o)),v({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case y.getAccessToken:{let e=await w().getAccessToken(),i=void 0!==e;if(!i)throw Error("No access token");(0,u.trackDuration)(m,"performedGetAccessToken",S(o)),v({responseFor:t,requestId:r,success:i,error:null,result:e});break}case y.getIdToken:{let e=await w().getIdToken(),i=void 0!==e;if(!i)throw Error("No ID token");(0,u.trackDuration)(m,"performedGetIdToken",S(o)),v({responseFor:t,requestId:r,success:i,error:null,result:e});break}case y.getEmail:{let e=await w().getUserInfo(),i=e?.email!==void 0;if(!i)throw Error("No email");(0,u.trackDuration)(m,"performedGetEmail",S(o)),v({responseFor:t,requestId:r,success:i,error:null,result:e?.email});break}case y.getPassportId:{let e=await w().getUserInfo(),i=e?.sub!==void 0;if(!i)throw Error("No Passport ID");(0,u.trackDuration)(m,"performedGetPassportId",S(o)),v({responseFor:t,requestId:r,success:i,error:null,result:e?.sub});break}case y.getLinkedAddresses:{let e=await w().getLinkedAddresses();(0,u.trackDuration)(m,"performedGetLinkedAddresses",S(o)),v({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case y.imx.getAddress:{let e=await M().getAddress();(0,u.trackDuration)(m,"performedImxGetAddress",S(o)),v({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case y.imx.isRegisteredOffchain:{let e=await M().isRegisteredOffchain();(0,u.trackDuration)(m,"performedImxIsRegisteredOffchain",S(o)),v({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case y.imx.registerOffchain:{let e=await M().registerOffchain();(0,u.trackDuration)(m,"performedImxRegisterOffchain",S(o)),v({responseFor:t,requestId:r,success:!0,error:null,...e});break}case y.imx.transfer:{let e=JSON.parse(I),i=await M().transfer(e);(0,u.trackDuration)(m,"performedImxTransfer",S(o),{requestId:r,transferRequest:JSON.stringify(e),transferResponse:JSON.stringify(i)}),v({responseFor:t,requestId:r,success:!0,error:null,...i});break}case y.imx.batchNftTransfer:{let e=JSON.parse(I),i=await M().batchNftTransfer(e);(0,u.trackDuration)(m,"performedImxBatchNftTransfer",S(o),{requestId:r,transferRequest:JSON.stringify(e),transferResponse:JSON.stringify(i)}),v({responseFor:t,requestId:r,success:!0,error:null,...i});break}case y.zkEvm.connectEvm:{let e=w().connectEvm(),i=E(e);if(!i)throw Error("Failed to connect to EVM");(0,u.trackDuration)(m,"performedZkevmConnectEvm",S(o),{succeeded:i}),v({responseFor:t,requestId:r,success:i,error:null});break}case y.zkEvm.sendTransaction:{let e=JSON.parse(I),i=await A().request({method:"eth_sendTransaction",params:[e]}),n=null!=i;if(!n)throw Error("Failed to send transaction");(0,u.trackDuration)(m,"performedZkevmSendTransaction",S(o),{requestId:r,transactionRequest:JSON.stringify(e),transactionResponse:i}),v({responseFor:t,requestId:r,success:n,error:null,result:i});break}case y.zkEvm.sendTransactionWithConfirmation:{let e=JSON.parse(I),i=A(),n=new l.providers.Web3Provider(i),a=n.getSigner(),s=await a.sendTransaction(e),f=await s.wait();(0,u.trackDuration)(m,"performedZkevmSendTransactionWithConfirmation",S(o),{requestId:r,transactionRequest:JSON.stringify(e),transactionResponse:JSON.stringify(f)}),v({responseFor:t,requestId:r,success:!0,error:null,...f});break}case y.zkEvm.requestAccounts:{let e=await A().request({method:"eth_requestAccounts"}),i=null!=e;if(!i)throw Error("Failed to request accounts");(0,u.trackDuration)(m,"performedZkevmRequestAccounts",S(o)),v({responseFor:t,requestId:r,success:i,error:null,accounts:e});break}case y.zkEvm.getBalance:{let e=JSON.parse(I),i=await A().request({method:"eth_getBalance",params:[e.address,e.blockNumberOrTag]}),n=null!=i;if(!n)throw Error("Failed to get balance");(0,u.trackDuration)(m,"performedZkevmGetBalance",S(o)),v({responseFor:t,requestId:r,success:n,error:null,result:i});break}case y.zkEvm.getTransactionReceipt:{let e=JSON.parse(I),i=await A().request({method:"eth_getTransactionReceipt",params:[e.txHash]}),n=void 0!==i;if(!n)throw Error("Failed to get transaction receipt");(0,u.trackDuration)(m,"performedZkevmGetTransactionReceipt",S(o)),v({responseFor:t,requestId:r,success:n,error:null,...i});break}case"track":{let e=JSON.parse(I),i=e.properties?JSON.parse(e.properties):{};(0,u.track)(e.moduleName,e.eventName,i),v({responseFor:t,requestId:r,success:!0,error:null})}}}catch(n){let e;console.log(`Error in callFunction: ${n}`),e=n instanceof Error?n:Error(n);let i=n instanceof f.PassportError?n?.type:void 0;(0,u.trackError)(m,t,e,{fxName:t,requestId:r,errorType:i,...s}),(0,u.trackDuration)(m,"failedCallFunction",S(o),{fxName:t,requestId:r,error:e.message}),console.log("callFunction error",e),console.log("callFunction errorType",i),v({responseFor:t,requestId:r,success:!1,error:n?.message!==null&&n?.message!==void 0?n.message:"Error",errorType:n instanceof f.PassportError?n?.type:null})}},window.addEventListener("offline",()=>{console.log("gameBridge offline")}),window.addEventListener("online",()=>{console.log("gameBridge online")}),console.log("index.ts loaded"),o=function(){v({responseFor:"init",requestId:"1",success:!0,error:null})},"complete"===document.readyState?o():window.addEventListener("load",o)},{"@imtbl/passport":"iPtWy","@imtbl/config":"ed8SG","@imtbl/x-client":"hV3j7","@imtbl/metrics":"dO0KB",ethers:"8wpcu"}],iPtWy:[function(e,t,r){let i;var n,a,s,o,f,d,c,u,l,h,p,b,m,g,y=e("@parcel/transformer-js/src/esmodule-helpers.js");y.defineInteropFlag(r),y.export(r,"JsonRpcError",()=>e3),y.export(r,"Passport",()=>tO),y.export(r,"PassportError",()=>z),y.export(r,"ProviderErrorCode",()=>m),y.export(r,"ProviderEvent",()=>b),y.export(r,"RpcErrorCode",()=>g);var v=e("axios"),w=y.interopDefault(v),_=e("@imtbl/generated-clients"),M=e("@imtbl/x-client"),E=e("@imtbl/config"),A=e("@imtbl/metrics"),S=e("oidc-client-ts"),x=e("crypto"),I=e("jwt-decode"),R=y.interopDefault(I),k=e("localforage"),T=y.interopDefault(k),C=e("magic-sdk"),P=e("@magic-ext/oidc"),O=e("@ethersproject/providers"),N=e("@imtbl/toolkit"),j=e("ethers"),B=e("events"),L=e("@0xsequence/abi"),D=e("@0xsequence/core"),F=e("uuid"),U=e("a7402fb880ab41a1");function q(e){return"code"in e&&"message"in e}(n=c||(c={})).AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",n.INVALID_CONFIGURATION="INVALID_CONFIGURATION",n.WALLET_CONNECTION_ERROR="WALLET_CONNECTION_ERROR",n.NOT_LOGGED_IN_ERROR="NOT_LOGGED_IN_ERROR",n.SILENT_LOGIN_ERROR="SILENT_LOGIN_ERROR",n.REFRESH_TOKEN_ERROR="REFRESH_TOKEN_ERROR",n.USER_REGISTRATION_ERROR="USER_REGISTRATION_ERROR",n.USER_NOT_REGISTERED_ERROR="USER_NOT_REGISTERED_ERROR",n.LOGOUT_ERROR="LOGOUT_ERROR",n.TRANSFER_ERROR="TRANSFER_ERROR",n.CREATE_ORDER_ERROR="CREATE_ORDER_ERROR",n.CANCEL_ORDER_ERROR="CANCEL_ORDER_ERROR",n.EXCHANGE_TRANSFER_ERROR="EXCHANGE_TRANSFER_ERROR",n.CREATE_TRADE_ERROR="CREATE_TRADE_ERROR",n.OPERATION_NOT_SUPPORTED_ERROR="OPERATION_NOT_SUPPORTED_ERROR",n.LINK_WALLET_ALREADY_LINKED_ERROR="LINK_WALLET_ALREADY_LINKED_ERROR",n.LINK_WALLET_MAX_WALLETS_LINKED_ERROR="LINK_WALLET_MAX_WALLETS_LINKED_ERROR",n.LINK_WALLET_VALIDATION_ERROR="LINK_WALLET_VALIDATION_ERROR",n.LINK_WALLET_DUPLICATE_NONCE_ERROR="LINK_WALLET_DUPLICATE_NONCE_ERROR",n.LINK_WALLET_GENERIC_ERROR="LINK_WALLET_GENERIC_ERROR";class z extends Error{type;constructor(e,t){super(e),this.type=t}}let K=async(e,t)=>{try{return await e()}catch(r){let e;throw e=(0,v.isAxiosError)(r)&&r.response?.data&&q(r.response.data)?r.response.data.message:r.message,new z(e,t)}},H="pkce_state",W="pkce_verifier";class V{areValid(e){if(e){let t=this.isTokenValid(e.access_token),r=this.isTokenValid(e.id_token);return t&&r}return!1}isTokenValid(e){try{let t=(0,R.default)(e),r=t.exp??0,i=Date.now()/1e3+3600;return r>i}catch(e){return!1}}savePKCEData(e){localStorage.setItem(H,e.state),localStorage.setItem(W,e.verifier)}getPKCEData(){let e=localStorage.getItem(H),t=localStorage.getItem(W);return e&&t?{state:e,verifier:t}:null}}var G={warn:(...e)=>{if(void 0===U)return;let t=U?.env?.JEST_WORKER_ID===void 0;t&&console.warn(...e)}};(a=u||(u={})).LOGGED_OUT="loggedOut",a.LOGGED_IN="loggedIn",a.ACCOUNTS_REQUESTED="accountsRequested";let J=e=>!!e.zkEvm,Z=e=>!!e.imx,X="passport-overlay",$=`${X}-close`,Y=`${X}-try-again`,Q=` -`,et=` +`,ee=` -`,er=` +`,et=` - ${ee} + ${Q} - `,en=()=>` + `,ei=()=>`
- ${et} + ${ee} Pop-up blocked

Secure pop-up not showing?
We'll help you re-launch

- `,es=()=>` + `,ea=()=>`