From 59cd70fd606c42788474ec584c1f2284450599f0 Mon Sep 17 00:00:00 2001 From: CodeSchwert Date: Fri, 2 Aug 2024 04:49:34 +0000 Subject: [PATCH] chore: update game bridge to 1.46.11 --- Web/index.js | 115829 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 115797 insertions(+), 32 deletions(-) diff --git a/Web/index.js b/Web/index.js index 4a654e0..49fba39 100644 --- a/Web/index.js +++ b/Web/index.js @@ -1,4 +1,966 @@ -!function(e,t,r,n,i){var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof a[n]&&a[n],o=s.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function f(t,r){if(!o[t]){if(!e[t]){var i="function"==typeof a[n]&&a[n];if(!r&&i)return i(t,!0);if(s)return s(t,!0);if(c&&"string"==typeof t)return c(t);var u=Error("Cannot find module '"+t+"'");throw u.code="MODULE_NOT_FOUND",u}l.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},l.cache={};var d=o[t]=new f.Module(t);e[t][0].call(d.exports,l,d,d.exports,this)}return o[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:f(t)}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=o,f.parent=s,f.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(f,"root",{get:function(){return a[n]}}),a[n]=f;for(var u=0;u{let t=JSON.stringify(e);if(console.log(`callbackToGame: ${t}`),console.log(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)}},b=()=>{if(null==n)throw Error("No Passport client");return n},g=e=>null!=e?(i=e,console.log("IMX provider set"),!0):(console.log("No IMX provider"),!1),y=()=>{if(null==i)throw Error("No IMX provider");return i},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,u.track)(l,"loadedGameBridge",{sdkVersionTag:h}),window.callFunction=async e=>{console.log(`Call function ${e}`);let t=null,r=null,o=Date.now();try{let E=JSON.parse(e);t=E.fxName,r=E.requestId;let A=E.data;switch((0,u.track)(l,"startedCallFunction",{function:t}),t){case p.init:{let e=JSON.parse(A),i=e?.redirectUri;if(!n){let t={baseConfig:new f.ImmutableConfiguration({environment:e.environment}),clientId:e.clientId,audience:"platform_api",scope:"openid offline_access profile email transact",redirectUri:i??"https://localhost:3000/",logoutRedirectUri:e?.logoutRedirectUri,crossSdkBridgeEnabled:!0};n=new c.Passport(t),(0,u.trackDuration)(l,"initialisedPassport",_(o))}m({responseFor:t,requestId:r,success:!0,error:null});let{engineVersion:a}=e;s={gameBridgeTag:h,gameBridgeSha:"__SDK_VERSION_SHA__",engine:a.engine,engineVersion:a.engineVersion,engineSdkVersion:a.engineSdkVersion??"",platform:a.platform,platformVersion:a.platformVersion,deviceModel:a.deviceModel??"N/A"},console.log(`Version check: ${JSON.stringify(s)}`),(0,u.trackDuration)(l,"completedInitGameBridge",_(o),{...s});break}case p.initDeviceFlow:{let e=await b().loginWithDeviceFlow();(0,u.trackDuration)(l,"performedInitDeviceFlow",_(o)),m({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 b().login({useCachedSession:!0}),n=null!==e;if(!n)throw Error("Failed to re-login");(0,u.identify)({passportId:e?.sub}),(0,u.trackDuration)(l,"performedRelogin",_(o),{succeeded:n}),m({responseFor:t,requestId:r,success:null!==e,error:null});break}case p.reconnect:{let e=!1,n=await b().login({useCachedSession:!0});if(n){let t=await b().connectImx();e=g(t),(0,u.identify)({passportId:n?.sub})}if(!e)throw Error("Failed to reconnect");(0,u.trackDuration)(l,"performedReconnect",_(o),{succeeded:null!==n}),m({responseFor:t,requestId:r,success:e,error:null});break}case p.getPKCEAuthUrl:{let e=b().loginWithPKCEFlow();(0,u.trackDuration)(l,"performedGetPkceAuthUrl",_(o)),m({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case p.loginPKCE:{let e=JSON.parse(A),n=await b().loginWithPKCEFlowCallback(e.authorizationCode,e.state);(0,u.identify)({passportId:n.sub}),(0,u.trackDuration)(l,"performedLoginPkce",_(o)),m({responseFor:t,requestId:r,success:!0,error:null});break}case p.connectPKCE:{let e=JSON.parse(A),n=await b().loginWithPKCEFlowCallback(e.authorizationCode,e.state),i=await b().connectImx(),a=g(i);if(!a)throw Error("Failed to connect via PKCE");(0,u.identify)({passportId:n.sub}),(0,u.trackDuration)(l,"performedConnectPkce",_(o),{succeeded:a}),m({responseFor:t,requestId:r,success:a,error:null});break}case p.loginConfirmCode:{let e=JSON.parse(A),n=await b().loginWithDeviceFlowCallback(e.deviceCode,e.interval,e.timeoutMs??null);(0,u.identify)({passportId:n.sub}),(0,u.trackDuration)(l,"performedLoginConfirmCode",_(o)),m({responseFor:t,requestId:r,success:!0,error:null});break}case p.connectConfirmCode:{let e=JSON.parse(A),n=await b().loginWithDeviceFlowCallback(e.deviceCode,e.interval,e.timeoutMs??null),i=await b().connectImx(),a=g(i);if(!a)throw Error("Failed to connect via confirm code");(0,u.identify)({passportId:n.sub}),(0,u.trackDuration)(l,"performedConnectConfirmCode",_(o),{succeeded:a}),m({responseFor:t,requestId:r,success:a,error:null});break}case p.logout:{let e=await b().logoutDeviceFlow();i=null,a=null,(0,u.trackDuration)(l,"performedGetLogoutUrl",_(o)),m({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case p.getAccessToken:{let e=await b().getAccessToken(),n=void 0!==e;if(!n)throw Error("No access token");(0,u.trackDuration)(l,"performedGetAccessToken",_(o)),m({responseFor:t,requestId:r,success:n,error:null,result:e});break}case p.getIdToken:{let e=await b().getIdToken(),n=void 0!==e;if(!n)throw Error("No ID token");(0,u.trackDuration)(l,"performedGetIdToken",_(o)),m({responseFor:t,requestId:r,success:n,error:null,result:e});break}case p.getEmail:{let e=await b().getUserInfo(),n=e?.email!==void 0;if(!n)throw Error("No email");(0,u.trackDuration)(l,"performedGetEmail",_(o)),m({responseFor:t,requestId:r,success:n,error:null,result:e?.email});break}case p.getPassportId:{let e=await b().getUserInfo(),n=e?.sub!==void 0;if(!n)throw Error("No Passport ID");(0,u.trackDuration)(l,"performedGetPassportId",_(o)),m({responseFor:t,requestId:r,success:n,error:null,result:e?.sub});break}case p.getLinkedAddresses:{let e=await b().getLinkedAddresses();(0,u.trackDuration)(l,"performedGetLinkedAddresses",_(o)),m({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case p.imx.getAddress:{let e=await y().getAddress();(0,u.trackDuration)(l,"performedImxGetAddress",_(o)),m({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case p.imx.isRegisteredOffchain:{let e=await y().isRegisteredOffchain();(0,u.trackDuration)(l,"performedImxIsRegisteredOffchain",_(o)),m({responseFor:t,requestId:r,success:!0,error:null,result:e});break}case p.imx.registerOffchain:{let e=await y().registerOffchain();(0,u.trackDuration)(l,"performedImxRegisterOffchain",_(o)),m({responseFor:t,requestId:r,success:!0,error:null,...e});break}case p.imx.transfer:{let e=JSON.parse(A),n=await y().transfer(e);(0,u.trackDuration)(l,"performedImxTransfer",_(o)),m({responseFor:t,requestId:r,success:!0,error:null,...n});break}case p.imx.batchNftTransfer:{let e=JSON.parse(A),n=await y().batchNftTransfer(e);(0,u.trackDuration)(l,"performedImxBatchNftTransfer",_(o)),m({responseFor:t,requestId:r,success:!0,error:null,...n});break}case p.zkEvm.connectEvm:{let e=b().connectEvm(),n=v(e);if(!n)throw Error("Failed to connect to EVM");(0,u.trackDuration)(l,"performedZkevmConnectEvm",_(o),{succeeded:n}),m({responseFor:t,requestId:r,success:n,error:null});break}case p.zkEvm.sendTransaction:{let e=JSON.parse(A),n=await w().request({method:"eth_sendTransaction",params:[e]}),i=null!=n;if(!i)throw Error("Failed to send transaction");(0,u.trackDuration)(l,"performedZkevmSendTransaction",_(o)),m({responseFor:t,requestId:r,success:i,error:null,result:n});break}case p.zkEvm.sendTransactionWithConfirmation:{let e=JSON.parse(A),n=w(),i=new d.providers.Web3Provider(n),a=i.getSigner(),s=await a.sendTransaction(e),c=await s.wait();(0,u.trackDuration)(l,"performedZkevmSendTransactionWithConfirmation",_(o)),m({responseFor:t,requestId:r,success:!0,error:null,...c});break}case p.zkEvm.requestAccounts:{let e=await w().request({method:"eth_requestAccounts"}),n=null!=e;if(!n)throw Error("Failed to request accounts");(0,u.trackDuration)(l,"performedZkevmRequestAccounts",_(o)),m({responseFor:t,requestId:r,success:n,error:null,accounts:e});break}case p.zkEvm.getBalance:{let e=JSON.parse(A),n=await w().request({method:"eth_getBalance",params:[e.address,e.blockNumberOrTag]}),i=null!=n;if(!i)throw Error("Failed to get balance");(0,u.trackDuration)(l,"performedZkevmGetBalance",_(o)),m({responseFor:t,requestId:r,success:i,error:null,result:n});break}case p.zkEvm.getTransactionReceipt:{let e=JSON.parse(A),n=await w().request({method:"eth_getTransactionReceipt",params:[e.txHash]}),i=null!=n;if(!i)throw Error("Failed to get transaction receipt");(0,u.trackDuration)(l,"performedZkevmGetTransactionReceipt",_(o)),m({responseFor:t,requestId:r,success:i,error:null,...n});break}case"track":{let e=JSON.parse(A),n=JSON.parse(e.properties);(0,u.track)(e.moduleName,e.eventName,n),m({responseFor:t,requestId:r,success:!0,error:null})}}}catch(i){let e;e=i instanceof Error?i:Error(i);let n=i instanceof c.PassportError?i?.type:void 0;(0,u.trackError)(l,t,e,{fxName:t,requestId:r,errorType:n,...s}),(0,u.trackDuration)(l,"failedCallFunction",_(o),{fxName:t,requestId:r,error:e.message}),console.log("callFunction error",i),m({responseFor:t,requestId:r,success:!1,error:i?.message!==null&&i?.message!==void 0?i.message:"Error",errorType:i instanceof c.PassportError?i?.type:null})}},console.log("index.ts loaded"),o=function(){m({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 n;var i,a,s,o,c,f,u,d,l,h,p,m,b,g,y=e("@parcel/transformer-js/src/esmodule-helpers.js");y.defineInteropFlag(r),y.export(r,"JsonRpcError",()=>e6),y.export(r,"Passport",()=>tR),y.export(r,"PassportError",()=>K),y.export(r,"ProviderErrorCode",()=>b),y.export(r,"ProviderEvent",()=>m),y.export(r,"RpcErrorCode",()=>g);var v=e("axios"),w=y.interopDefault(v),_=e("@imtbl/metrics"),E=e("@imtbl/generated-clients"),A=e("@imtbl/x-client"),M=e("@imtbl/config"),S=e("oidc-client-ts"),x=e("crypto"),T=e("jwt-decode"),k=y.interopDefault(T),R=e("localforage"),I=y.interopDefault(R),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"),U=e("@0xsequence/core"),F=e("uuid"),q=e("a7402fb880ab41a1");function z(e){return"code"in e&&"message"in e}(i=u||(u={})).AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",i.INVALID_CONFIGURATION="INVALID_CONFIGURATION",i.WALLET_CONNECTION_ERROR="WALLET_CONNECTION_ERROR",i.NOT_LOGGED_IN_ERROR="NOT_LOGGED_IN_ERROR",i.SILENT_LOGIN_ERROR="SILENT_LOGIN_ERROR",i.REFRESH_TOKEN_ERROR="REFRESH_TOKEN_ERROR",i.USER_REGISTRATION_ERROR="USER_REGISTRATION_ERROR",i.USER_NOT_REGISTERED_ERROR="USER_NOT_REGISTERED_ERROR",i.LOGOUT_ERROR="LOGOUT_ERROR",i.TRANSFER_ERROR="TRANSFER_ERROR",i.CREATE_ORDER_ERROR="CREATE_ORDER_ERROR",i.CANCEL_ORDER_ERROR="CANCEL_ORDER_ERROR",i.EXCHANGE_TRANSFER_ERROR="EXCHANGE_TRANSFER_ERROR",i.CREATE_TRADE_ERROR="CREATE_TRADE_ERROR",i.OPERATION_NOT_SUPPORTED_ERROR="OPERATION_NOT_SUPPORTED_ERROR",i.LINK_WALLET_ALREADY_LINKED_ERROR="LINK_WALLET_ALREADY_LINKED_ERROR",i.LINK_WALLET_MAX_WALLETS_LINKED_ERROR="LINK_WALLET_MAX_WALLETS_LINKED_ERROR",i.LINK_WALLET_VALIDATION_ERROR="LINK_WALLET_VALIDATION_ERROR",i.LINK_WALLET_DUPLICATE_NONCE_ERROR="LINK_WALLET_DUPLICATE_NONCE_ERROR",i.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,r)=>{try{return await e()}catch(i){let e;e=(0,v.isAxiosError)(i)&&i.response?.data&&z(i.response.data)?i.response.data.message:i.message;let n=new K(e,t);throw r&&(0,_.trackError)("passport",r,n),n}},V="pkce_state",W="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,k.default)(e),r=t.exp??0,n=Date.now()/1e3+3600;return r>n}catch(e){return!1}}savePKCEData(e){localStorage.setItem(V,e.state),localStorage.setItem(W,e.verifier)}getPKCEData(){let e=localStorage.getItem(V),t=localStorage.getItem(W);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=d||(d={})).LOGGED_OUT="loggedOut",a.LOGGED_IN="loggedIn",a.ACCOUNTS_REQUESTED="accountsRequested";let Z=e=>!!e.zkEvm,$=e=>!!e.imx,X="passport-overlay",Y=`${X}-close`,Q=`${X}-try-again`,ee=` +// modules are defined as an array +// [ module function, map of requires ] +// +// map of requires is short require name -> numeric require +// +// anything defined in a previous bundle is accessed via the +// orig method which is the require for previous bundles + +(function (modules, entry, mainEntry, parcelRequireName, globalName) { + /* eslint-disable no-undef */ + var globalObject = + typeof globalThis !== 'undefined' + ? globalThis + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : typeof global !== 'undefined' + ? global + : {}; + /* eslint-enable no-undef */ + + // Save the require from previous bundle to this closure if any + var previousRequire = + typeof globalObject[parcelRequireName] === 'function' && + globalObject[parcelRequireName]; + + var cache = previousRequire.cache || {}; + // Do not use `require` to prevent Webpack from trying to bundle this call + var nodeRequire = + typeof module !== 'undefined' && + typeof module.require === 'function' && + module.require.bind(module); + + function newRequire(name, jumped) { + if (!cache[name]) { + if (!modules[name]) { + // if we cannot find the module within our internal map or + // cache jump to the current global require ie. the last bundle + // that was added to the page. + var currentRequire = + typeof globalObject[parcelRequireName] === 'function' && + globalObject[parcelRequireName]; + if (!jumped && currentRequire) { + return currentRequire(name, true); + } + + // If there are other bundles on this page the require from the + // previous one is saved to 'previousRequire'. Repeat this as + // many times as there are bundles until the module is found or + // we exhaust the require chain. + if (previousRequire) { + return previousRequire(name, true); + } + + // Try the node require function if it exists. + if (nodeRequire && typeof name === 'string') { + return nodeRequire(name); + } + + var err = new Error("Cannot find module '" + name + "'"); + err.code = 'MODULE_NOT_FOUND'; + throw err; + } + + localRequire.resolve = resolve; + localRequire.cache = {}; + + var module = (cache[name] = new newRequire.Module(name)); + + modules[name][0].call( + module.exports, + localRequire, + module, + module.exports, + this + ); + } + + return cache[name].exports; + + function localRequire(x) { + var res = localRequire.resolve(x); + return res === false ? {} : newRequire(res); + } + + function resolve(x) { + var id = modules[name][1][x]; + return id != null ? id : x; + } + } + + function Module(moduleName) { + this.id = moduleName; + this.bundle = newRequire; + this.exports = {}; + } + + newRequire.isParcelRequire = true; + newRequire.Module = Module; + newRequire.modules = modules; + newRequire.cache = cache; + newRequire.parent = previousRequire; + newRequire.register = function (id, exports) { + modules[id] = [ + function (require, module) { + module.exports = exports; + }, + {}, + ]; + }; + + Object.defineProperty(newRequire, 'root', { + get: function () { + return globalObject[parcelRequireName]; + }, + }); + + globalObject[parcelRequireName] = newRequire; + + for (var i = 0; i < entry.length; i++) { + newRequire(entry[i]); + } + + if (mainEntry) { + // Expose entry point to Node, AMD or browser globals + // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js + var mainExports = newRequire(mainEntry); + + // CommonJS + if (typeof exports === 'object' && typeof module !== 'undefined') { + module.exports = mainExports; + + // RequireJS + } else if (typeof define === 'function' && define.amd) { + define(function () { + return mainExports; + }); + + //