@openfort/openfort-js 0.10.22 → 0.10.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/packages/internal/openapi-clients/dist/index.js +1 -1
- package/dist/cjs/sdk/src/api/embeddedWallet.js +1 -1
- package/dist/cjs/sdk/src/core/errors/sentry.js +1 -1
- package/dist/cjs/sdk/src/types/types.js +1 -1
- package/dist/cjs/sdk/src/utils/chains/index.js +1 -1
- package/dist/cjs/sdk/src/version.js +1 -1
- package/dist/cjs/sdk/src/wallets/embedded.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/JsonRpcError.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/evmProvider.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/sendCallSync.js +1 -0
- package/dist/cjs/sdk/src/wallets/evm/sendCalls.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/types.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/walletHelpers.js +1 -1
- package/dist/cjs/sdk/src/wallets/iframeManager.js +1 -1
- package/dist/cjs/sdk/src/wallets/types.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/packages/internal/openapi-clients/dist/index.js +1 -1
- package/dist/sdk/src/api/embeddedWallet.js +1 -1
- package/dist/sdk/src/core/errors/sentry.js +1 -1
- package/dist/sdk/src/types/types.js +1 -1
- package/dist/sdk/src/utils/chains/index.js +1 -1
- package/dist/sdk/src/version.js +1 -1
- package/dist/sdk/src/wallets/embedded.js +1 -1
- package/dist/sdk/src/wallets/evm/JsonRpcError.js +1 -1
- package/dist/sdk/src/wallets/evm/evmProvider.js +1 -1
- package/dist/sdk/src/wallets/evm/sendCallSync.js +1 -0
- package/dist/sdk/src/wallets/evm/sendCalls.js +1 -1
- package/dist/sdk/src/wallets/evm/types.js +1 -1
- package/dist/sdk/src/wallets/evm/walletHelpers.js +1 -1
- package/dist/sdk/src/wallets/iframeManager.js +1 -1
- package/dist/sdk/src/wallets/types.js +1 -1
- package/package.json +18 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("axios"),t=require("axios-retry");const s="https://api.openfort.io".replace(/\/+$/,"");class n{basePath;axios;configuration;constructor(t,n=s,a=e){this.basePath=n,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,s){if(null==s)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const s="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+s}};function c(e,t,s=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,s)):Object.keys(t).forEach(n=>c(e,t[n],`${s}${""!==s?".":""}${n}`)):e.has(s)?e.append(s,t):e.set(s,t))}const h=function(e,...t){const s=new URLSearchParams(e.search);c(s,t),e.search=s.toString()},u=function(e,t,s){const n="string"!=typeof e;return(n&&s&&s.isJsonMime?s.isJsonMime(t.headers["Content-Type"]):n)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,s,n){return(a=t,i=s)=>{const o={...e.options,url:(n?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const n=function(e){return{cancelTransferOwnership:async(t,s,n={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",s);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},completeRecovery:async(t,s,n={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",s);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},createAccount:async(t,s={})=>{o("createAccount","createAccountRequest",t);const n=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},deployAccount:async(t,s,n={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",s);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},disableAccount:async(t,s={})=>{o("disableAccount","id",t);const n="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccount:async(t,s,n={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getAccountV2:async(t,s={})=>{o("getAccountV2","id",t);const n="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccounts:async(t,s,n,a,o,c,u,l={})=>{const p=new URL("/v1/accounts",i);let y;e&&(y=e.baseOptions);const g={method:"GET",...y,...l},w={},m={};await r(w,e),void 0!==t&&(m.limit=t),void 0!==s&&(m.skip=s),void 0!==n&&(m.order=n),void 0!==a&&(m.chainId=a),void 0!==o&&(m.player=o),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let P=y&&y.headers?y.headers:{};return g.headers={...w,...P,...l.headers},{url:d(p),options:g}},getAccountsV2:async(t,s,n,a,o,c,u,l,p={})=>{const y=new URL("/v2/accounts",i);let g;e&&(g=e.baseOptions);const w={method:"GET",...g,...p},m={},P={};await r(m,e),void 0!==t&&(P.limit=t),void 0!==s&&(P.skip=s),void 0!==n&&(P.order=n),void 0!==a&&(P.chainId=a),void 0!==o&&(P.user=o),void 0!==c&&(P.chainType=c),void 0!==u&&(P.accountType=u),void 0!==l&&(P.address=l),h(y,P);let R=g&&g.headers?g.headers:{};return w.headers={...m,...R,...p.headers},{url:d(y),options:w}},getSignerIdByAddress:async(t,s={})=>{o("getSignerIdByAddress","address",t);const n=new URL("/v2/accounts/signer",i);let a;e&&(a=e.baseOptions);const c={method:"GET",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.address=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},requestTransferOwnership:async(t,s,n={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",s);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},signPayload:async(t,s,n={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",s);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},startRecovery:async(t,s,n={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",s);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},switchChainV2:async(t,s={})=>{o("switchChainV2","switchChainQueriesV2",t);const n=new URL("/v2/accounts/switch-chain",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},syncAccount:async(t,s={})=>{o("syncAccount","id",t);const n="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await n.cancelTransferOwnership(a,i,o);return l(r,e,s,t)},async completeRecovery(a,i,o){const r=await n.completeRecovery(a,i,o);return l(r,e,s,t)},async createAccount(a,i){const o=await n.createAccount(a,i);return l(o,e,s,t)},async deployAccount(a,i,o){const r=await n.deployAccount(a,i,o);return l(r,e,s,t)},async disableAccount(a,i){const o=await n.disableAccount(a,i);return l(o,e,s,t)},async getAccount(a,i,o){const r=await n.getAccount(a,i,o);return l(r,e,s,t)},async getAccountV2(a,i){const o=await n.getAccountV2(a,i);return l(o,e,s,t)},async getAccounts(a,i,o,r,c,h,u,d){const p=await n.getAccounts(a,i,o,r,c,h,u,d);return l(p,e,s,t)},async getAccountsV2(a,i,o,r,c,h,u,d,p){const y=await n.getAccountsV2(a,i,o,r,c,h,u,d,p);return l(y,e,s,t)},async getSignerIdByAddress(a,i){const o=await n.getSignerIdByAddress(a,i);return l(o,e,s,t)},async requestTransferOwnership(a,i,o){const r=await n.requestTransferOwnership(a,i,o);return l(r,e,s,t)},async signPayload(a,i,o){const r=await n.signPayload(a,i,o);return l(r,e,s,t)},async startRecovery(a,i,o){const r=await n.startRecovery(a,i,o);return l(r,e,s,t)},async switchChainV2(a,i){const o=await n.switchChainV2(a,i);return l(o,e,s,t)},async syncAccount(a,i){const o=await n.syncAccount(a,i);return l(o,e,s,t)}}};class y extends n{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.id,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.chainId,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountsV2(e={},t){return p(this.configuration).getAccountsV2(e.limit,e.skip,e.order,e.chainId,e.user,e.chainType,e.accountType,e.address,t).then(e=>e(this.axios,this.basePath))}getSignerIdByAddress(e,t){return p(this.configuration).getSignerIdByAddress(e.address,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}switchChainV2(e,t){return p(this.configuration).switchChainV2(e.switchChainQueriesV2,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const n=function(e){return{authenticateSIWE:async(t,s={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getJwks:async(t,s={})=>{o("getJwks","publishableKey",t);const n="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(n,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...s};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...s.headers},{url:d(a),options:c}},initOAuth:async(t,s,n={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,s,n={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,s,n={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,s,n={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,s={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},linkThirdParty:async(t,s,n={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,s,n={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,s,n={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,s={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const n=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},logout:async(t,s={})=>{o("logout","logoutRequest",t);const n=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},me:async(t={})=>{const s=new URL("/iam/v1/me",i);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let o=n&&n.headers?n.headers:{};return a.headers={...o,...t.headers},{url:d(s),options:a}},poolOAuth:async(t,s={})=>{o("poolOAuth","key",t);const n=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},refresh:async(t,s={})=>{o("refresh","refreshTokenRequest",t);const n=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},registerGuest:async(t,s={})=>{const n=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...s},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(n,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...s.headers},{url:d(n),options:o}},requestEmailVerification:async(t,s={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const n=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},requestResetPassword:async(t,s={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const n=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},resetPassword:async(t,s={})=>{o("resetPassword","resetPasswordRequest",t);const n=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},signupEmailPassword:async(t,s,n={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,s,n={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,s={})=>{o("unlinkEmail","unlinkEmailRequest",t);const n=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkOAuth:async(t,s={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const n=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkSIWE:async(t,s={})=>{o("unlinkSIWE","sIWERequest",t);const n=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},verifyEmail:async(t,s={})=>{o("verifyEmail","verifyEmailRequest",t);const n=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},verifyOAuthToken:async(t,s={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const n=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await n.authenticateSIWE(a,i);return l(o,e,s,t)},async getJwks(a,i){const o=await n.getJwks(a,i);return l(o,e,s,t)},async initOAuth(a,i,o){const r=await n.initOAuth(a,i,o);return l(r,e,s,t)},async initSIWE(a,i,o){const r=await n.initSIWE(a,i,o);return l(r,e,s,t)},async linkEmail(a,i,o){const r=await n.linkEmail(a,i,o);return l(r,e,s,t)},async linkOAuth(a,i,o){const r=await n.linkOAuth(a,i,o);return l(r,e,s,t)},async linkSIWE(a,i){const o=await n.linkSIWE(a,i);return l(o,e,s,t)},async linkThirdParty(a,i,o){const r=await n.linkThirdParty(a,i,o);return l(r,e,s,t)},async loginEmailPassword(a,i,o){const r=await n.loginEmailPassword(a,i,o);return l(r,e,s,t)},async loginOIDC(a,i,o){const r=await n.loginOIDC(a,i,o);return l(r,e,s,t)},async loginWithIdToken(a,i){const o=await n.loginWithIdToken(a,i);return l(o,e,s,t)},async logout(a,i){const o=await n.logout(a,i);return l(o,e,s,t)},async me(a){const i=await n.me(a);return l(i,e,s,t)},async poolOAuth(a,i){const o=await n.poolOAuth(a,i);return l(o,e,s,t)},async refresh(a,i){const o=await n.refresh(a,i);return l(o,e,s,t)},async registerGuest(a,i){const o=await n.registerGuest(a,i);return l(o,e,s,t)},async requestEmailVerification(a,i){const o=await n.requestEmailVerification(a,i);return l(o,e,s,t)},async requestResetPassword(a,i){const o=await n.requestResetPassword(a,i);return l(o,e,s,t)},async resetPassword(a,i){const o=await n.resetPassword(a,i);return l(o,e,s,t)},async signupEmailPassword(a,i,o){const r=await n.signupEmailPassword(a,i,o);return l(r,e,s,t)},async thirdParty(a,i,o){const r=await n.thirdParty(a,i,o);return l(r,e,s,t)},async unlinkEmail(a,i){const o=await n.unlinkEmail(a,i);return l(o,e,s,t)},async unlinkOAuth(a,i){const o=await n.unlinkOAuth(a,i);return l(o,e,s,t)},async unlinkSIWE(a,i){const o=await n.unlinkSIWE(a,i);return l(o,e,s,t)},async verifyEmail(a,i){const o=await n.verifyEmail(a,i);return l(o,e,s,t)},async verifyOAuthToken(a,i){const o=await n.verifyOAuthToken(a,i);return l(o,e,s,t)}}};class w extends n{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const n=function(e){return{createSession:async(t,s,n={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,s,n,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==s&&(w.limit=s),void 0!==n&&(w.skip=n),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,s,n={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},revokeSession:async(t,s,n={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,s,n={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",s);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await n.createSession(a,i,o);return l(r,e,s,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await n.getPlayerSessions(a,i,o,r,c,h);return l(u,e,s,t)},async getSession(a,i,o){const r=await n.getSession(a,i,o);return l(r,e,s,t)},async revokeSession(a,i,o){const r=await n.revokeSession(a,i,o);return l(r,e,s,t)},async signatureSession(a,i,o){const r=await n.signatureSession(a,i,o);return l(r,e,s,t)}}};class P extends n{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const n=function(e){return{createTransactionIntent:async(t,s,n={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,s={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const n=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getTransactionIntent:async(t,s,n={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getTransactionIntents:async(t,s,n,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==s&&(R.skip=s),void 0!==n&&(R.order=n),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,s,n={})=>{o("signature","id",t),o("signature","signatureRequest",s);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await n.createTransactionIntent(a,i,o);return l(r,e,s,t)},async estimateTransactionIntentCost(a,i){const o=await n.estimateTransactionIntentCost(a,i);return l(o,e,s,t)},async getTransactionIntent(a,i,o){const r=await n.getTransactionIntent(a,i,o);return l(r,e,s,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await n.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,s,t)},async signature(a,i,o){const r=await n.signature(a,i,o);return l(r,e,s,t)}}};class T extends n{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};exports.BackendApiClients=class{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(s){const n=e.create();t(n,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:s.basePath,accessToken:s.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,n),this.accountsApi=new y(this.config.backend,void 0,n),this.sessionsApi=new P(this.config.backend,void 0,n),this.authenticationApi=new w(this.config.backend,void 0,n)}},exports.createConfig=f;
|
|
1
|
+
"use strict";var e=require("axios"),t=require("axios-retry");const s="https://api.openfort.io".replace(/\/+$/,"");class n{basePath;axios;configuration;constructor(t,n=s,a=e){this.basePath=n,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,s){if(null==s)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const s="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+s}};function c(e,t,s=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,s)):Object.keys(t).forEach(n=>c(e,t[n],`${s}${""!==s?".":""}${n}`)):e.has(s)?e.append(s,t):e.set(s,t))}const h=function(e,...t){const s=new URLSearchParams(e.search);c(s,t),e.search=s.toString()},u=function(e,t,s){const n="string"!=typeof e;return(n&&s&&s.isJsonMime?s.isJsonMime(t.headers["Content-Type"]):n)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,s,n){return(a=t,i=s)=>{const o={...e.options,url:(n?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const n=function(e){return{cancelTransferOwnership:async(t,s,n={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",s);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},completeRecovery:async(t,s,n={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",s);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},createAccount:async(t,s={})=>{o("createAccount","createAccountRequest",t);const n=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},deployAccount:async(t,s,n={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",s);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},disableAccount:async(t,s={})=>{o("disableAccount","id",t);const n="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccount:async(t,s,n={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getAccountV2:async(t,s={})=>{o("getAccountV2","id",t);const n="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccounts:async(t,s,n,a,o,c,u,l={})=>{const p=new URL("/v1/accounts",i);let y;e&&(y=e.baseOptions);const g={method:"GET",...y,...l},w={},m={};await r(w,e),void 0!==t&&(m.limit=t),void 0!==s&&(m.skip=s),void 0!==n&&(m.order=n),void 0!==a&&(m.chainId=a),void 0!==o&&(m.player=o),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let P=y&&y.headers?y.headers:{};return g.headers={...w,...P,...l.headers},{url:d(p),options:g}},getAccountsV2:async(t,s,n,a,o,c,u,l,p={})=>{const y=new URL("/v2/accounts",i);let g;e&&(g=e.baseOptions);const w={method:"GET",...g,...p},m={},P={};await r(m,e),void 0!==t&&(P.limit=t),void 0!==s&&(P.skip=s),void 0!==n&&(P.order=n),void 0!==a&&(P.chainId=a),void 0!==o&&(P.user=o),void 0!==c&&(P.chainType=c),void 0!==u&&(P.accountType=u),void 0!==l&&(P.address=l),h(y,P);let R=g&&g.headers?g.headers:{};return w.headers={...m,...R,...p.headers},{url:d(y),options:w}},getSignerIdByAddress:async(t,s={})=>{o("getSignerIdByAddress","address",t);const n=new URL("/v2/accounts/signer",i);let a;e&&(a=e.baseOptions);const c={method:"GET",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.address=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},requestTransferOwnership:async(t,s,n={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",s);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},signPayload:async(t,s,n={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",s);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},startRecovery:async(t,s,n={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",s);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},switchChainV2:async(t,s={})=>{o("switchChainV2","switchChainQueriesV2",t);const n=new URL("/v2/accounts/switch-chain",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},syncAccount:async(t,s={})=>{o("syncAccount","id",t);const n="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await n.cancelTransferOwnership(a,i,o);return l(r,e,s,t)},async completeRecovery(a,i,o){const r=await n.completeRecovery(a,i,o);return l(r,e,s,t)},async createAccount(a,i){const o=await n.createAccount(a,i);return l(o,e,s,t)},async deployAccount(a,i,o){const r=await n.deployAccount(a,i,o);return l(r,e,s,t)},async disableAccount(a,i){const o=await n.disableAccount(a,i);return l(o,e,s,t)},async getAccount(a,i,o){const r=await n.getAccount(a,i,o);return l(r,e,s,t)},async getAccountV2(a,i){const o=await n.getAccountV2(a,i);return l(o,e,s,t)},async getAccounts(a,i,o,r,c,h,u,d){const p=await n.getAccounts(a,i,o,r,c,h,u,d);return l(p,e,s,t)},async getAccountsV2(a,i,o,r,c,h,u,d,p){const y=await n.getAccountsV2(a,i,o,r,c,h,u,d,p);return l(y,e,s,t)},async getSignerIdByAddress(a,i){const o=await n.getSignerIdByAddress(a,i);return l(o,e,s,t)},async requestTransferOwnership(a,i,o){const r=await n.requestTransferOwnership(a,i,o);return l(r,e,s,t)},async signPayload(a,i,o){const r=await n.signPayload(a,i,o);return l(r,e,s,t)},async startRecovery(a,i,o){const r=await n.startRecovery(a,i,o);return l(r,e,s,t)},async switchChainV2(a,i){const o=await n.switchChainV2(a,i);return l(o,e,s,t)},async syncAccount(a,i){const o=await n.syncAccount(a,i);return l(o,e,s,t)}}};class y extends n{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.id,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.chainId,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountsV2(e={},t){return p(this.configuration).getAccountsV2(e.limit,e.skip,e.order,e.chainId,e.user,e.chainType,e.accountType,e.address,t).then(e=>e(this.axios,this.basePath))}getSignerIdByAddress(e,t){return p(this.configuration).getSignerIdByAddress(e.address,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}switchChainV2(e,t){return p(this.configuration).switchChainV2(e.switchChainQueriesV2,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const n=function(e){return{authenticateSIWE:async(t,s={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getJwks:async(t,s={})=>{o("getJwks","publishableKey",t);const n="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(n,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...s};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...s.headers},{url:d(a),options:c}},initOAuth:async(t,s,n={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,s,n={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,s,n={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,s,n={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,s={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},linkThirdParty:async(t,s,n={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,s,n={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,s,n={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,s={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const n=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},logout:async(t,s={})=>{o("logout","logoutRequest",t);const n=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},me:async(t={})=>{const s=new URL("/iam/v1/me",i);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let o=n&&n.headers?n.headers:{};return a.headers={...o,...t.headers},{url:d(s),options:a}},poolOAuth:async(t,s={})=>{o("poolOAuth","key",t);const n=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},refresh:async(t,s={})=>{o("refresh","refreshTokenRequest",t);const n=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},registerGuest:async(t,s={})=>{const n=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...s},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(n,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...s.headers},{url:d(n),options:o}},requestEmailVerification:async(t,s={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const n=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},requestResetPassword:async(t,s={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const n=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},resetPassword:async(t,s={})=>{o("resetPassword","resetPasswordRequest",t);const n=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},signupEmailPassword:async(t,s,n={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,s,n={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,s={})=>{o("unlinkEmail","unlinkEmailRequest",t);const n=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkOAuth:async(t,s={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const n=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkSIWE:async(t,s={})=>{o("unlinkSIWE","sIWERequest",t);const n=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},verifyEmail:async(t,s={})=>{o("verifyEmail","verifyEmailRequest",t);const n=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},verifyOAuthToken:async(t,s={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const n=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await n.authenticateSIWE(a,i);return l(o,e,s,t)},async getJwks(a,i){const o=await n.getJwks(a,i);return l(o,e,s,t)},async initOAuth(a,i,o){const r=await n.initOAuth(a,i,o);return l(r,e,s,t)},async initSIWE(a,i,o){const r=await n.initSIWE(a,i,o);return l(r,e,s,t)},async linkEmail(a,i,o){const r=await n.linkEmail(a,i,o);return l(r,e,s,t)},async linkOAuth(a,i,o){const r=await n.linkOAuth(a,i,o);return l(r,e,s,t)},async linkSIWE(a,i){const o=await n.linkSIWE(a,i);return l(o,e,s,t)},async linkThirdParty(a,i,o){const r=await n.linkThirdParty(a,i,o);return l(r,e,s,t)},async loginEmailPassword(a,i,o){const r=await n.loginEmailPassword(a,i,o);return l(r,e,s,t)},async loginOIDC(a,i,o){const r=await n.loginOIDC(a,i,o);return l(r,e,s,t)},async loginWithIdToken(a,i){const o=await n.loginWithIdToken(a,i);return l(o,e,s,t)},async logout(a,i){const o=await n.logout(a,i);return l(o,e,s,t)},async me(a){const i=await n.me(a);return l(i,e,s,t)},async poolOAuth(a,i){const o=await n.poolOAuth(a,i);return l(o,e,s,t)},async refresh(a,i){const o=await n.refresh(a,i);return l(o,e,s,t)},async registerGuest(a,i){const o=await n.registerGuest(a,i);return l(o,e,s,t)},async requestEmailVerification(a,i){const o=await n.requestEmailVerification(a,i);return l(o,e,s,t)},async requestResetPassword(a,i){const o=await n.requestResetPassword(a,i);return l(o,e,s,t)},async resetPassword(a,i){const o=await n.resetPassword(a,i);return l(o,e,s,t)},async signupEmailPassword(a,i,o){const r=await n.signupEmailPassword(a,i,o);return l(r,e,s,t)},async thirdParty(a,i,o){const r=await n.thirdParty(a,i,o);return l(r,e,s,t)},async unlinkEmail(a,i){const o=await n.unlinkEmail(a,i);return l(o,e,s,t)},async unlinkOAuth(a,i){const o=await n.unlinkOAuth(a,i);return l(o,e,s,t)},async unlinkSIWE(a,i){const o=await n.unlinkSIWE(a,i);return l(o,e,s,t)},async verifyEmail(a,i){const o=await n.verifyEmail(a,i);return l(o,e,s,t)},async verifyOAuthToken(a,i){const o=await n.verifyOAuthToken(a,i);return l(o,e,s,t)}}};class w extends n{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const n=function(e){return{createSession:async(t,s,n={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,s,n,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==s&&(w.limit=s),void 0!==n&&(w.skip=n),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,s,n={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},revokeSession:async(t,s,n={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,s,n={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",s);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await n.createSession(a,i,o);return l(r,e,s,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await n.getPlayerSessions(a,i,o,r,c,h);return l(u,e,s,t)},async getSession(a,i,o){const r=await n.getSession(a,i,o);return l(r,e,s,t)},async revokeSession(a,i,o){const r=await n.revokeSession(a,i,o);return l(r,e,s,t)},async signatureSession(a,i,o){const r=await n.signatureSession(a,i,o);return l(r,e,s,t)}}};class P extends n{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const n=function(e){return{createTransactionIntent:async(t,s,n={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,s={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const n=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getTransactionIntent:async(t,s,n={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getTransactionIntents:async(t,s,n,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==s&&(R.skip=s),void 0!==n&&(R.order=n),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,s,n={})=>{o("signature","id",t),o("signature","signatureRequest",s);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await n.createTransactionIntent(a,i,o);return l(r,e,s,t)},async estimateTransactionIntentCost(a,i){const o=await n.estimateTransactionIntentCost(a,i);return l(o,e,s,t)},async getTransactionIntent(a,i,o){const r=await n.getTransactionIntent(a,i,o);return l(r,e,s,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await n.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,s,t)},async signature(a,i,o){const r=await n.signature(a,i,o);return l(r,e,s,t)}}};class T extends n{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};exports.BackendApiClients=class{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(s){const n=e.create();t(n,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:s.basePath,accessToken:s.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,n),this.accountsApi=new y(this.config.backend,void 0,n),this.sessionsApi=new P(this.config.backend,void 0,n),this.authenticationApi=new w(this.config.backend,void 0,n)}},exports.createConfig=f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),r=require("../core/configuration/passkey.js"),t=require("../core/config/config.js"),a=require("../core/configuration/account.js"),n=require("../core/configuration/authentication.js"),s=require("../core/errors/openfortError.js"),o=require("../types/types.js"),i=require("../utils/debug.js"),d=require("../wallets/embedded.js"),c=require("../wallets/evm/evmProvider.js");require("../wallets/evm/types.js");var g=require("../wallets/evm/provider/eip6963.js"),h=require("../wallets/evm/walletHelpers.js"),y=require("../wallets/iframeManager.js"),p=require("../wallets/messaging/ReactNativeMessenger.js");require("../wallets/messaging/browserMessenger/backwardCompatibility.js");var u=require("../wallets/messaging/browserMessenger/messengers/WindowMessenger.js");exports.EmbeddedWalletApi=class{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;passkeyHandler;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,a,n){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=a,this.passkeyHandler=n,this.eventEmitter.on(o.OpenfortEvents.LOGGED_OUT,()=>{i.debugLog("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=t.SDKConfiguration.getInstance();if(!r)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);return new e.BackendApiClients({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey})}async getIframeManager(){if(i.debugLog("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return i.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return i.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;i.debugLog("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return i.debugLog("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,i.debugLog("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw i.debugLog("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){i.debugLog("[HANDSHAKE DEBUG] createIframeManager starting");const e=t.SDKConfiguration.getInstance();if(!e)throw i.debugLog("[HANDSHAKE DEBUG] Configuration not found"),new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);let r;if(i.debugLog("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)i.debugLog("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new p.ReactNativeMessenger(this.messagePoster),i.debugLog("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),r=this.messenger;else{i.debugLog("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const t=this.createIframe(e.iframeUrl),a=new URL(e.iframeUrl).origin;r=new u({remoteWindow:t.contentWindow,allowedOrigins:[a]}),i.debugLog("[HANDSHAKE DEBUG] Created WindowMessenger")}return i.debugLog("[HANDSHAKE DEBUG] Creating IframeManager instance"),new y.IframeManager(e,this.storage,r)}async ensureSigner(){if(this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager();return new d.EmbeddedSigner(e,this.storage,this.backendApiClients,this.passkeyHandler,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new s.OpenfortError("Document is not available. Please provide a message poster for non-browser environments.",s.OpenfortErrorType.INVALID_CONFIGURATION);const r=document.getElementById("openfort-iframe");r&&r.remove();const t=document.createElement("iframe");return t.style.display="none",t.id="openfort-iframe",t.src=e,document.body.appendChild(t),t}async getPasskeyKey(e){const r=await n.Authentication.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:r.player})}async getEntropy(e){switch(e.recoveryMethod){case o.RecoveryMethod.PASSWORD:return{recoveryPassword:e.password};case o.RecoveryMethod.AUTOMATIC:return{encryptionSession:e.encryptionSession};case o.RecoveryMethod.PASSKEY:return{passkey:e.passkeyInfo?{id:e.passkeyInfo.passkeyId,env:e.passkeyInfo.passkeyEnv,key:e.passkeyInfo.passkeyKey||await this.getPasskeyKey(e.passkeyInfo.passkeyId)}:{}};default:throw new s.OpenfortError("Invalid recovery method",s.OpenfortErrorType.INVALID_CONFIGURATION)}}async configure(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC},[t,s,i]=await Promise.all([n.Authentication.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(r)]),d={chainId:e.chainId,entropy:i,accountType:e.accountType??o.AccountTypeEnum.SMART_ACCOUNT,chainType:e.chainType??o.ChainTypeEnum.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},c=await s.configure(d);return{id:c.id,chainId:c.chainId,user:t.player,address:c.address,ownerAddress:c.ownerAddress,chainType:c.chainType,accountType:c.accountType,implementationType:c.implementationType,createdAt:c.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(c.recoveryMethod),recoveryMethodDetails:c.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC},i=await n.Authentication.fromStorage(this.storage);if(!i)throw new s.OpenfortError("missing authentication",s.OpenfortErrorType.AUTHENTICATION_ERROR);if(t.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:i?.player});t.passkeyInfo={passkeyId:e.id,passkeyKey:e.key}}const[d,c]=await Promise.all([this.ensureSigner(),this.getEntropy(t)]),g=await d.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:c});return{id:g.id,chainId:g.chainId,user:i.player,address:g.address,ownerAddress:g.ownerAddress,chainType:g.chainType,accountType:g.accountType,implementationType:g.implementationType,createdAt:g.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(g.recoveryMethod),recoveryMethodDetails:g.recoveryMethodDetails}}async recover(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC};if(r.recoveryMethod===o.RecoveryMethod.PASSKEY){if(!r.passkeyInfo?.passkeyId)throw new s.OpenfortError("Passkey ID must be provided for passkey recovery",s.OpenfortErrorType.INVALID_CONFIGURATION);r.passkeyInfo={passkeyId:r.passkeyInfo.passkeyId,passkeyEnv:r.passkeyInfo.passkeyEnv}}const[t,i,d]=await Promise.all([this.ensureSigner(),this.getEntropy(r),n.Authentication.fromStorage(this.storage)]),c=await t.recover({account:e.account,entropy:i});return{id:c.id,chainId:c.chainId,user:d.player,address:c.address,ownerAddress:c.ownerAddress,chainType:c.chainType,accountType:c.accountType,implementationType:c.implementationType,createdAt:c.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(c.recoveryMethod),recoveryMethodDetails:c.recoveryMethodDetails}}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:n=!0,arrayifyMessage:s=!1}=r||{},o=await a.Account.fromStorage(this.storage);return await t.sign(e,s,n,o?.chainType)}async signTypedData(e,r,t){await this.validateAndRefreshToken();const n=await this.ensureSigner(),o=await a.Account.fromStorage(this.storage);if(!o)throw new s.OpenfortError("No account found",s.OpenfortErrorType.MISSING_SIGNER_ERROR);const i={...r};delete i.EIP712Domain;const{_TypedDataEncoder:d}=await import("@ethersproject/hash"),c=d.hash(e,i,t);return await h.signMessage({hash:c,implementationType:o.implementationType||o.type,chainId:Number(o.chainId),signer:n,address:o.address,ownerAddress:o.ownerAddress,factoryAddress:o.factoryAddress,salt:o.salt})}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setRecoveryMethod(e,t){await this.validateAndRefreshToken();const i=await this.ensureSigner(),d=await n.Authentication.fromStorage(this.storage);if(!d)throw new s.OpenfortError("missing authentication",s.OpenfortErrorType.AUTHENTICATION_ERROR);let c,g,h,y;if(e.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await a.Account.fromStorage(this.storage);if(!e)throw new s.OpenfortError("missing account",s.OpenfortErrorType.INVALID_CONFIGURATION);const r=e?.recoveryMethodDetails?.passkeyId;if(!r)throw new s.OpenfortError("missing passkey id for account",s.OpenfortErrorType.INVALID_CONFIGURATION);h={passkeyId:r,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:r,seed:d.player})}}else if(t.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:d.player});h={passkeyId:e.id,passkeyKey:e.key},y={passkeyId:e.id}}if(e.recoveryMethod===o.RecoveryMethod.PASSWORD?c=e.password:t.recoveryMethod===o.RecoveryMethod.PASSWORD&&(c=t.password),e.recoveryMethod===o.RecoveryMethod.AUTOMATIC?g=e.encryptionSession:t.recoveryMethod===o.RecoveryMethod.AUTOMATIC&&(g=t.encryptionSession),!c&&!g)throw new s.OpenfortError("Password or encryption session is not provided",s.OpenfortErrorType.INVALID_CONFIGURATION);await i.setRecoveryMethod({recoveryMethod:t.recoveryMethod,recoveryPassword:c,encryptionSession:g,passkeyInfo:h});const p=await a.Account.fromStorage(this.storage);p&&new a.Account({...p,recoveryMethod:t.recoveryMethod,recoveryMethodDetails:y}).save(this.storage)}async get(){const e=await a.Account.fromStorage(this.storage);if(!e)throw new s.OpenfortError("No signer configured",s.OpenfortErrorType.MISSING_SIGNER_ERROR);const r=await n.Authentication.fromStorage(this.storage);if(!r)throw new s.OpenfortError("No access token found",s.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{id:e.id,chainId:e.chainId,user:r.player,address:e.address,ownerAddress:e.ownerAddress,chainType:e.chainType,accountType:e.accountType,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const r={accountType:o.AccountTypeEnum.SMART_ACCOUNT,...e},i=t.SDKConfiguration.getInstance();if(!i)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const d=await n.Authentication.fromStorage(this.storage);if(!d)throw new s.OpenfortError("No access token found",s.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return s.withOpenfortError(async()=>(await this.backendApiClients.accountsApi.getAccountsV2(r,{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":d.token,"x-auth-provider":d.thirdPartyProvider,"x-token-type":d.thirdPartyTokenType}})).data.data.map(e=>({user:e.user,chainType:e.chainType,id:e.id,address:e.address,ownerAddress:e.ownerAddress,accountType:e.accountType,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{default:s.OpenfortErrorType.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await n.Authentication.fromStorage(this.storage))return o.EmbeddedState.UNAUTHENTICATED;return await a.Account.fromStorage(this.storage)?o.EmbeddedState.READY:o.EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return i.debugLog("Failed to get embedded state:",e),o.EmbeddedState.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},t=await n.Authentication.fromStorage(this.storage),s=await a.Account.fromStorage(this.storage);return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new c.EvmProvider({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:s||void 0,authentication:t||void 0,backendApiClients:this.backendApiClients,policyId:r.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:r.chains}),r.announceProvider&&g.announceProvider({info:{...g.openfortProviderInfo,...r.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(r=>{setTimeout(r,e)});const r=await this.getIframeManager();if(!r.isLoaded())return!1;const t=await n.Authentication.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return i.debugLog("Ping failed:",e),!1}}getURL(){const e=t.SDKConfiguration.getInstance();if(!e)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new s.OpenfortError("Invalid message poster",s.OpenfortErrorType.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&this.messenger.destroy(),this.iframeManager&&this.iframeManager.destroy(),this.signer=null,this.signerPromise=null,this.iframeManager=null,this.iframeManagerPromise=null,this.messenger=null}async handleLogout(){const e=await this.ensureSigner();await e.disconnect(),this.provider=null,this.messenger=null,this.iframeManager=null,this.iframeManagerPromise=null,this.signer=null,this.signerPromise=null}async onMessage(e){if(!e||"object"!=typeof e)return void i.debugLog("Invalid message received:",e);i.debugLog("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const r="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(r&&this.messenger&&this.messagePoster)return i.debugLog("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const t=await this.getIframeManager();i.debugLog(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${t.isLoaded()}`),r&&!t.isLoaded()&&i.debugLog("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),i.debugLog("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await t.onMessage(e),i.debugLog("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}};
|
|
1
|
+
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),r=require("../core/configuration/passkey.js"),t=require("../core/config/config.js"),a=require("../core/configuration/account.js"),n=require("../core/configuration/authentication.js"),s=require("../core/errors/openfortError.js"),o=require("../types/types.js"),i=require("../utils/debug.js"),d=require("../wallets/embedded.js"),c=require("../wallets/evm/evmProvider.js");require("../wallets/evm/types.js");var g=require("../wallets/evm/provider/eip6963.js"),h=require("../wallets/evm/walletHelpers.js"),y=require("../wallets/iframeManager.js"),p=require("../wallets/messaging/ReactNativeMessenger.js");require("../wallets/messaging/browserMessenger/backwardCompatibility.js");var u=require("../wallets/messaging/browserMessenger/messengers/WindowMessenger.js");exports.EmbeddedWalletApi=class{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;passkeyHandler;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,a,n){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=a,this.passkeyHandler=n,this.eventEmitter.on(o.OpenfortEvents.LOGGED_OUT,()=>{i.debugLog("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=t.SDKConfiguration.getInstance();if(!r)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);return new e.BackendApiClients({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey})}async getIframeManager(){if(i.debugLog("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return i.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return i.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;i.debugLog("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return i.debugLog("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,i.debugLog("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw i.debugLog("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){i.debugLog("[HANDSHAKE DEBUG] createIframeManager starting");const e=t.SDKConfiguration.getInstance();if(!e)throw i.debugLog("[HANDSHAKE DEBUG] Configuration not found"),new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);let r;if(i.debugLog("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)i.debugLog("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new p.ReactNativeMessenger(this.messagePoster),i.debugLog("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),r=this.messenger;else{i.debugLog("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const t=this.createIframe(e.iframeUrl),a=new URL(e.iframeUrl).origin;r=new u({remoteWindow:t.contentWindow,allowedOrigins:[a]}),i.debugLog("[HANDSHAKE DEBUG] Created WindowMessenger")}return i.debugLog("[HANDSHAKE DEBUG] Creating IframeManager instance"),new y.IframeManager(e,this.storage,r)}async ensureSigner(){if(this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager();return new d.EmbeddedSigner(e,this.storage,this.backendApiClients,this.passkeyHandler,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new s.OpenfortError("Document is not available. Please provide a message poster for non-browser environments.",s.OpenfortErrorType.INVALID_CONFIGURATION);const r=document.getElementById("openfort-iframe");r&&r.remove();const t=document.createElement("iframe");return t.style.display="none",t.id="openfort-iframe",t.src=e,document.body.appendChild(t),t}async getPasskeyKey(e){const r=await n.Authentication.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:r.player})}async getEntropy(e){switch(e.recoveryMethod){case o.RecoveryMethod.PASSWORD:return{recoveryPassword:e.password};case o.RecoveryMethod.AUTOMATIC:return{encryptionSession:e.encryptionSession};case o.RecoveryMethod.PASSKEY:return{passkey:e.passkeyInfo?{id:e.passkeyInfo.passkeyId,key:e.passkeyInfo.passkeyKey||await this.getPasskeyKey(e.passkeyInfo.passkeyId)}:{}};default:throw new s.OpenfortError("Invalid recovery method",s.OpenfortErrorType.INVALID_CONFIGURATION)}}async configure(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC},[t,s,i]=await Promise.all([n.Authentication.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(r)]),d={chainId:e.chainId,entropy:i,accountType:e.accountType??o.AccountTypeEnum.SMART_ACCOUNT,chainType:e.chainType??o.ChainTypeEnum.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},c=await s.configure(d);return{id:c.id,chainId:c.chainId,user:t.player,address:c.address,ownerAddress:c.ownerAddress,chainType:c.chainType,accountType:c.accountType,implementationType:c.implementationType,createdAt:c.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(c.recoveryMethod),recoveryMethodDetails:c.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC},i=await n.Authentication.fromStorage(this.storage);if(!i)throw new s.OpenfortError("missing authentication",s.OpenfortErrorType.AUTHENTICATION_ERROR);if(t.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:i?.player});t.passkeyInfo={passkeyId:e.id,passkeyKey:e.key}}const[d,c]=await Promise.all([this.ensureSigner(),this.getEntropy(t)]),g=await d.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:c});return{id:g.id,chainId:g.chainId,user:i.player,address:g.address,ownerAddress:g.ownerAddress,chainType:g.chainType,accountType:g.accountType,implementationType:g.implementationType,createdAt:g.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(g.recoveryMethod),recoveryMethodDetails:g.recoveryMethodDetails}}async recover(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC};if(r.recoveryMethod===o.RecoveryMethod.PASSKEY){if(!r.passkeyInfo?.passkeyId)throw new s.OpenfortError("Passkey ID must be provided for passkey recovery",s.OpenfortErrorType.INVALID_CONFIGURATION);r.passkeyInfo={passkeyId:r.passkeyInfo.passkeyId}}const[t,i,d]=await Promise.all([this.ensureSigner(),this.getEntropy(r),n.Authentication.fromStorage(this.storage)]),c=await t.recover({account:e.account,entropy:i});return{id:c.id,chainId:c.chainId,user:d.player,address:c.address,ownerAddress:c.ownerAddress,chainType:c.chainType,accountType:c.accountType,implementationType:c.implementationType,createdAt:c.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(c.recoveryMethod),recoveryMethodDetails:c.recoveryMethodDetails}}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:n=!0,arrayifyMessage:s=!1}=r||{},o=await a.Account.fromStorage(this.storage);return await t.sign(e,s,n,o?.chainType)}async signTypedData(e,r,t){await this.validateAndRefreshToken();const n=await this.ensureSigner(),o=await a.Account.fromStorage(this.storage);if(!o)throw new s.OpenfortError("No account found",s.OpenfortErrorType.MISSING_SIGNER_ERROR);const i={...r};delete i.EIP712Domain;const{_TypedDataEncoder:d}=await import("@ethersproject/hash"),c=d.hash(e,i,t);return await h.signMessage({hash:c,implementationType:o.implementationType||o.type,chainId:Number(o.chainId),signer:n,address:o.address,ownerAddress:o.ownerAddress,factoryAddress:o.factoryAddress,salt:o.salt})}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setRecoveryMethod(e,t){await this.validateAndRefreshToken();const i=await this.ensureSigner(),d=await n.Authentication.fromStorage(this.storage);if(!d)throw new s.OpenfortError("missing authentication",s.OpenfortErrorType.AUTHENTICATION_ERROR);let c,g,h,y;if(e.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await a.Account.fromStorage(this.storage);if(!e)throw new s.OpenfortError("missing account",s.OpenfortErrorType.INVALID_CONFIGURATION);const r=e?.recoveryMethodDetails?.passkeyId;if(!r)throw new s.OpenfortError("missing passkey id for account",s.OpenfortErrorType.INVALID_CONFIGURATION);h={passkeyId:r,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:r,seed:d.player})}}else if(t.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:d.player});h={passkeyId:e.id,passkeyKey:e.key},y={passkeyId:e.id}}if(e.recoveryMethod===o.RecoveryMethod.PASSWORD?c=e.password:t.recoveryMethod===o.RecoveryMethod.PASSWORD&&(c=t.password),e.recoveryMethod===o.RecoveryMethod.AUTOMATIC?g=e.encryptionSession:t.recoveryMethod===o.RecoveryMethod.AUTOMATIC&&(g=t.encryptionSession),!c&&!g)throw new s.OpenfortError("Password or encryption session is not provided",s.OpenfortErrorType.INVALID_CONFIGURATION);await i.setRecoveryMethod({recoveryMethod:t.recoveryMethod,recoveryPassword:c,encryptionSession:g,passkeyInfo:h});const p=await a.Account.fromStorage(this.storage);p&&new a.Account({...p,recoveryMethod:t.recoveryMethod,recoveryMethodDetails:y}).save(this.storage)}async get(){const e=await a.Account.fromStorage(this.storage);if(!e)throw new s.OpenfortError("No signer configured",s.OpenfortErrorType.MISSING_SIGNER_ERROR);const r=await n.Authentication.fromStorage(this.storage);if(!r)throw new s.OpenfortError("No access token found",s.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{id:e.id,chainId:e.chainId,user:r.player,address:e.address,ownerAddress:e.ownerAddress,chainType:e.chainType,accountType:e.accountType,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const r={accountType:o.AccountTypeEnum.SMART_ACCOUNT,...e},i=t.SDKConfiguration.getInstance();if(!i)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const d=await n.Authentication.fromStorage(this.storage);if(!d)throw new s.OpenfortError("No access token found",s.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return s.withOpenfortError(async()=>(await this.backendApiClients.accountsApi.getAccountsV2(r,{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":d.token,"x-auth-provider":d.thirdPartyProvider,"x-token-type":d.thirdPartyTokenType}})).data.data.map(e=>({user:e.user,chainType:e.chainType,id:e.id,address:e.address,ownerAddress:e.ownerAddress,accountType:e.accountType,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{default:s.OpenfortErrorType.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await n.Authentication.fromStorage(this.storage))return o.EmbeddedState.UNAUTHENTICATED;return await a.Account.fromStorage(this.storage)?o.EmbeddedState.READY:o.EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return i.debugLog("Failed to get embedded state:",e),o.EmbeddedState.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},t=await n.Authentication.fromStorage(this.storage),s=await a.Account.fromStorage(this.storage);return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new c.EvmProvider({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:s||void 0,authentication:t||void 0,backendApiClients:this.backendApiClients,policyId:r.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:r.chains}),r.announceProvider&&g.announceProvider({info:{...g.openfortProviderInfo,...r.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(r=>{setTimeout(r,e)});const r=await this.getIframeManager();if(!r.isLoaded())return!1;const t=await n.Authentication.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return i.debugLog("Ping failed:",e),!1}}getURL(){const e=t.SDKConfiguration.getInstance();if(!e)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new s.OpenfortError("Invalid message poster",s.OpenfortErrorType.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&this.messenger.destroy(),this.iframeManager&&this.iframeManager.destroy(),this.signer=null,this.signerPromise=null,this.iframeManager=null,this.iframeManagerPromise=null,this.messenger=null}async handleLogout(){const e=await this.ensureSigner();await e.disconnect(),this.provider=null,this.messenger=null,this.iframeManager=null,this.iframeManagerPromise=null,this.signer=null,this.signerPromise=null}async onMessage(e){if(!e||"object"!=typeof e)return void i.debugLog("Invalid message received:",e);i.debugLog("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const r="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(r&&this.messenger&&this.messagePoster)return i.debugLog("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const t=await this.getIframeManager();i.debugLog(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${t.isLoaded()}`),r&&!t.isLoaded()&&i.debugLog("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),i.debugLog("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await t.onMessage(e),i.debugLog("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("axios"),e=require("../../version.js");const s="https://64a03e4967fb4dad3ecb914918c777b6@o4504593015242752.ingest.us.sentry.io/4509292415287296";class r{static sentryInstance;static queuedCalls=[];static baseTags;static set sentry(e){const n=e.getDsn();if(!n)throw new Error("Sentry DSN is not set");if(n.projectId!==s.split("https://")[1].split("/")[1]||n.host!==s.split("@")[1].split("/")[0]||n.publicKey!==s.split("@")[0].split("https://")[1])throw new Error("Sentry DSN is not valid");e.captureAxiosError=(s,n,a,o)=>{n instanceof t.AxiosError
|
|
1
|
+
"use strict";var t=require("axios"),e=require("../../version.js");const s="https://64a03e4967fb4dad3ecb914918c777b6@o4504593015242752.ingest.us.sentry.io/4509292415287296";class r{static sentryInstance;static queuedCalls=[];static baseTags;static set sentry(e){const n=e.getDsn();if(!n)throw new Error("Sentry DSN is not set");if(n.projectId!==s.split("https://")[1].split("/")[1]||n.host!==s.split("@")[1].split("/")[0]||n.publicKey!==s.split("@")[0].split("https://")[1])throw new Error("Sentry DSN is not valid");e.captureAxiosError=(s,n,a,o)=>{if(n instanceof t.AxiosError){if(400===n.response?.status||401===n.response?.status)return;n.name=s,e.captureException(n,{...a,captureContext:{...a?.captureContext,extra:{errorResponseData:n.response?.data,errorStatus:n.response?.status,errorHeaders:n.response?.headers,errorRequest:n.request},tags:{...r.baseTags,method:s}}})}else e.captureException(n,a,o)},r.sentryInstance=e}static get sentry(){return r.proxy}static async init({sentry:t,configuration:n}){if(t)return void(r.sentry=t);const a=await import("@sentry/browser");r.sentry=new a.BrowserClient({dsn:s,integrations:[],stackParser:a.defaultStackParser,transport:a.makeFetchTransport}),r.baseTags={projectId:n?.baseConfiguration.publishableKey,sdk:e.PACKAGE,sdkVersion:e.VERSION},r.processQueuedCalls()}static proxy=new Proxy({},{get:(t,e)=>r.sentryInstance&&"function"==typeof r.sentryInstance[e]?(...t)=>r.sentryInstance[e](...t):(...t)=>{r.queuedCalls.push({fn:e,args:t})}});static processQueuedCalls(){r.sentryInstance&&(r.queuedCalls.forEach(({fn:t,args:e})=>{"function"==typeof r.sentryInstance[t]&&r.sentryInstance[t](...e)}),r.queuedCalls=[])}}const{sentry:n}=r;exports.InternalSentry=r,exports.sentry=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,o,t,r,E,A,p,s,d,
|
|
1
|
+
"use strict";var e,o,t,r,E,A,p,s,d,T,i,a;exports.EmbeddedState=void 0,(e=exports.EmbeddedState||(exports.EmbeddedState={}))[e.NONE=0]="NONE",e[e.UNAUTHENTICATED=1]="UNAUTHENTICATED",e[e.EMBEDDED_SIGNER_NOT_CONFIGURED=2]="EMBEDDED_SIGNER_NOT_CONFIGURED",e[e.CREATING_ACCOUNT=3]="CREATING_ACCOUNT",e[e.READY=4]="READY",exports.OpenfortEvents=void 0,(o=exports.OpenfortEvents||(exports.OpenfortEvents={})).LOGGED_OUT="loggedOut",o.SWITCH_ACCOUNT="switchAccount",exports.RecoveryMethod=void 0,(t=exports.RecoveryMethod||(exports.RecoveryMethod={})).PASSWORD="password",t.AUTOMATIC="automatic",t.PASSKEY="passkey",exports.AccountType=void 0,(r=exports.AccountType||(exports.AccountType={})).UPGRADEABLE_V4="Upgradeable_v04",r.MANAGED_V4="Managed_v04",r.ERC6551_V4="ERC6551_v04",r.ERC6551_V5="ERC6551_v05",r.RECOVERABLE_V4="Recoverable_v04",r.MANAGED_V5="Managed_v05",r.UPGRADEABLE_V5="Upgradeable_v05",r.UPGRADEABLE_V6="Upgradeable_v06",r.ZKSYNC_UPGRADEABLE_V1="zksync_upgradeable_v1",r.ZKSYNC_UPGRADEABLE_V2="zksync_upgradeable_v2",exports.AuthType=void 0,(E=exports.AuthType||(exports.AuthType={})).OPENFORT="openfort",E.THIRD_PARTY="thirdParty",exports.TokenType=void 0,(A=exports.TokenType||(exports.TokenType={})).ID_TOKEN="idToken",A.CUSTOM_TOKEN="customToken",exports.ThirdPartyAuthProvider=void 0,(p=exports.ThirdPartyAuthProvider||(exports.ThirdPartyAuthProvider={})).ACCELBYTE="accelbyte",p.FIREBASE="firebase",p.LOOTLOCKER="lootlocker",p.PLAYFAB="playfab",p.SUPABASE="supabase",p.CUSTOM="custom",p.OIDC="oidc",exports.BasicAuthProvider=void 0,(s=exports.BasicAuthProvider||(exports.BasicAuthProvider={})).EMAIL="email",s.WALLET="wallet",exports.OAuthProvider=void 0,(d=exports.OAuthProvider||(exports.OAuthProvider={})).GOOGLE="google",d.TWITTER="twitter",d.APPLE="apple",d.FACEBOOK="facebook",d.DISCORD="discord",d.EPIC_GAMES="epic_games",d.LINE="line",exports.AuthActionRequiredActions=void 0,(exports.AuthActionRequiredActions||(exports.AuthActionRequiredActions={})).ACTION_VERIFY_EMAIL="verify_email",exports.CodeChallengeMethodEnum=void 0,(exports.CodeChallengeMethodEnum||(exports.CodeChallengeMethodEnum={})).S256="S256",exports.AccountTypeEnum=void 0,(T=exports.AccountTypeEnum||(exports.AccountTypeEnum={})).EOA="Externally Owned Account",T.SMART_ACCOUNT="Smart Account",exports.ChainTypeEnum=void 0,(i=exports.ChainTypeEnum||(exports.ChainTypeEnum={})).EVM="EVM",i.SVM="SVM",function(e){e.ASC="asc",e.DESC="desc"}(a||(a={}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.defaultChainRpcs={1:"https://cloudflare-eth.com",10:"https://optimism-rpc.publicnode.com",56:"https://bsc.publicnode.com",97:"https://bsc-testnet.publicnode.com",137:"https://polygon-rpc.com",204:"https://opbnb-mainnet-rpc.bnbchain.org",300:"https://sepolia.era.zksync.dev",324:"https://mainnet.era.zksync.io",1946:"https://rpc.minato.soneium.org",2741:"https://api.mainnet.abs.xyz",3939:"https://test.doschain.com",4337:"https://build.onbeam.com/rpc",5611:"https://opbnb-testnet-rpc.bnbchain.org",7979:"https://main.doschain.com",8453:"https://mainnet.base.org",11124:"https://api.testnet.abs.xyz",13337:"https://build.onbeam.com/rpc/testnet",13473:"https://rpc.testnet.immutable.com",42161:"https://arb1.arbitrum.io/rpc",42170:"https://nova.arbitrum.io/rpc",43113:"https://api.avax-test.network/ext/bc/C/rpc",43114:"https://api.avax.network/ext/bc/C/rpc",50104:"https://rpc.sophon.xyz",80002:"https://polygon-amoy-bor-rpc.publicnode.com",84532:"https://sepolia.base.org",
|
|
1
|
+
"use strict";exports.defaultChainRpcs={1:"https://cloudflare-eth.com",10:"https://optimism-rpc.publicnode.com",56:"https://bsc.publicnode.com",97:"https://bsc-testnet.publicnode.com",137:"https://polygon-rpc.com",204:"https://opbnb-mainnet-rpc.bnbchain.org",300:"https://sepolia.era.zksync.dev",324:"https://mainnet.era.zksync.io",1946:"https://rpc.minato.soneium.org",2741:"https://api.mainnet.abs.xyz",3939:"https://test.doschain.com",4337:"https://build.onbeam.com/rpc",5611:"https://opbnb-testnet-rpc.bnbchain.org",7979:"https://main.doschain.com",8453:"https://mainnet.base.org",11124:"https://api.testnet.abs.xyz",13337:"https://build.onbeam.com/rpc/testnet",13473:"https://rpc.testnet.immutable.com",42161:"https://arb1.arbitrum.io/rpc",42170:"https://nova.arbitrum.io/rpc",43113:"https://api.avax-test.network/ext/bc/C/rpc",43114:"https://api.avax.network/ext/bc/C/rpc",50104:"https://rpc.sophon.xyz",80002:"https://polygon-amoy-bor-rpc.publicnode.com",84532:"https://sepolia.base.org",421614:"https://sepolia-rollup.arbitrum.io/rpc",7225878:"https://rpc.saakuru.network",7777777:"https://rpc.zora.energy",11155111:"https://ethereum-sepolia-rpc.publicnode.com",11155420:"https://optimism-sepolia-rpc.publicnode.com",28122024:"https://rpcv2-testnet.ancient8.gg",531050104:"https://rpc.testnet.sophon.xyz",666666666:"https://rpc.degen.tips",888888888:"https://rpc.ancient8.gg",999999999:"https://sepolia.rpc.zora.energy",85011:"https://subnets.avax.network/criminalsa/testnet/rpc",84358:"https://subnets.avax.network/titan/mainnet/rpc",10143:"https://testnet-rpc.monad.xyz",510525:"https://rpc.clankermon.com",3008:"https://kl1-testnet.kiooverse.xyz/rpc",167e3:"https://rpc.taiko.xyz"};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.10.
|
|
1
|
+
"use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.10.24";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../core/configuration/authentication.js"),t=require("../core/configuration/passkey.js"),r=require("../core/errors/openfortError.js"),a=require("../types/types.js"),o=require("../core/config/config.js"),n=require("../core/configuration/account.js"),s=require("../storage/istorage.js");require("eventemitter3"),require("./evm/JsonRpcError.js"),require("./evm/types.js"),require("./evm/provider/eip6963.js"),require("../core/errors/sentry.js"),require("./messaging/browserMessenger/backwardCompatibility.js"),require("./types.js"),require("jose");exports.EmbeddedSigner=class{iframeManager;storage;backendApiClients;passkeyHandler;eventEmitter;constructor(e,t,r,a,o){this.iframeManager=e,this.storage=t,this.backendApiClients=r,this.passkeyHandler=a,this.eventEmitter=o}async createPasskey(e){const r=await this.passkeyHandler.createPasskey({id:t.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:e});return{id:r.id,key:r.key}}async configure(t){const s=await e.Authentication.fromStorage(this.storage);if(!s)throw new r.OpenfortError("No access token found",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const i=o.SDKConfiguration.getInstance();if(!i)throw new r.OpenfortError("Configuration not found",r.OpenfortErrorType.INVALID_CONFIGURATION);const c=await n.Account.fromStorage(this.storage);let d;if(c){const e={account:c.id,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},..."passkey"===c.recoveryMethod&&{passkey:{id:c.recoveryMethodDetails?.passkeyId,env:c.recoveryMethodDetails?.passkeyEnv,key:await t.getPasskeyKeyFn(c.recoveryMethodDetails?.passkeyId)}}}}},r=await this.iframeManager.recover(e);d=r.account}else{const e=await this.backendApiClients.accountsApi.getAccountsV2({user:s.player,accountType:t.accountType,chainType:t.chainType},{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}});if(0===e.data.data.length){const e=t.entropy?.passkey?await this.createPasskey(s.player):void 0,r={accountType:t.accountType,chainType:t.chainType,chainId:t.chainId,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},...t.entropy.passkey&&{passkey:e}}}},a=await this.iframeManager.create(r);d=a.account}else{const r=e.data.data,a=r.find(e=>e.chainId===t.chainId),o=a||r[0],n={account:o.id,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},..."passkey"===o.recoveryMethod&&{passkey:{id:o.recoveryMethodDetails?.passkeyId,env:o.recoveryMethodDetails?.passkeyEnv,key:await t.getPasskeyKeyFn(o.recoveryMethodDetails?.passkeyId)}}}}},s=await this.iframeManager.recover(n);if(d=s.account,!a){const e=await this.iframeManager.switchChain(t.chainId);d=e.account}}}return r.withOpenfortError(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:d},{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}}),t=new n.Account({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:n.Account.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.SWITCH_ACCOUNT,e.data.address),t},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async sign(e,t,r,a){return await this.iframeManager.sign(e,t,r,a)}async export(){return await this.iframeManager.export()}async switchChain({chainId:e}){const t=await
|
|
1
|
+
"use strict";var e=require("../core/configuration/authentication.js"),t=require("../core/configuration/passkey.js"),r=require("../core/errors/openfortError.js"),a=require("../types/types.js"),o=require("../core/config/config.js"),n=require("../core/configuration/account.js"),s=require("../storage/istorage.js");require("eventemitter3"),require("./evm/JsonRpcError.js"),require("./evm/types.js"),require("./evm/provider/eip6963.js"),require("../core/errors/sentry.js"),require("./messaging/browserMessenger/backwardCompatibility.js"),require("./types.js"),require("jose");exports.EmbeddedSigner=class{iframeManager;storage;backendApiClients;passkeyHandler;eventEmitter;constructor(e,t,r,a,o){this.iframeManager=e,this.storage=t,this.backendApiClients=r,this.passkeyHandler=a,this.eventEmitter=o}async createPasskey(e){const r=await this.passkeyHandler.createPasskey({id:t.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:e});return{id:r.id,key:r.key}}async configure(t){const s=await e.Authentication.fromStorage(this.storage);if(!s)throw new r.OpenfortError("No access token found",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const i=o.SDKConfiguration.getInstance();if(!i)throw new r.OpenfortError("Configuration not found",r.OpenfortErrorType.INVALID_CONFIGURATION);const c=await n.Account.fromStorage(this.storage);let d;if(c){const e={account:c.id,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},..."passkey"===c.recoveryMethod&&{passkey:{id:c.recoveryMethodDetails?.passkeyId,env:c.recoveryMethodDetails?.passkeyEnv,key:await t.getPasskeyKeyFn(c.recoveryMethodDetails?.passkeyId)}}}}},r=await this.iframeManager.recover(e);d=r.account}else{const e=await this.backendApiClients.accountsApi.getAccountsV2({user:s.player,accountType:t.accountType,chainType:t.chainType},{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}});if(0===e.data.data.length){const e=t.entropy?.passkey?await this.createPasskey(s.player):void 0,r={accountType:t.accountType,chainType:t.chainType,chainId:t.chainId,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},...t.entropy.passkey&&{passkey:e}}}},a=await this.iframeManager.create(r);d=a.account}else{const r=e.data.data,a=r.find(e=>e.chainId===t.chainId),o=a||r[0],n={account:o.id,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},..."passkey"===o.recoveryMethod&&{passkey:{id:o.recoveryMethodDetails?.passkeyId,env:o.recoveryMethodDetails?.passkeyEnv,key:await t.getPasskeyKeyFn(o.recoveryMethodDetails?.passkeyId)}}}}},s=await this.iframeManager.recover(n);if(d=s.account,!a){const e=await this.iframeManager.switchChain(t.chainId);d=e.account}}}return r.withOpenfortError(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:d},{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}}),t=new n.Account({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:n.Account.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.SWITCH_ACCOUNT,e.data.address),t},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async sign(e,t,r,a){return await this.iframeManager.sign(e,t,r,a)}async export(){return await this.iframeManager.export()}async switchChain({chainId:e}){const t=await n.Account.fromStorage(this.storage);if(t?.accountType===a.AccountTypeEnum.EOA)new n.Account({...t,chainId:e}).save(this.storage);else{const r=await this.iframeManager.switchChain(e);new n.Account({...t,id:r.account,chainId:e}).save(this.storage)}}async create(t){const s=await this.iframeManager.create(t),i=await e.Authentication.fromStorage(this.storage);if(!i)throw new r.OpenfortError("No access token found",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const c=o.SDKConfiguration.getInstance();if(!c)throw new r.OpenfortError("Configuration not found",r.OpenfortErrorType.INVALID_CONFIGURATION);return r.withOpenfortError(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:s.account},{headers:{authorization:`Bearer ${c.baseConfiguration.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}}),t=new n.Account({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:n.Account.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.SWITCH_ACCOUNT,e.data.address),t},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async recover(t){const s=await this.iframeManager.recover(t),i=await e.Authentication.fromStorage(this.storage);if(!i)throw new r.OpenfortError("No access token found",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const c=o.SDKConfiguration.getInstance();if(!c)throw new r.OpenfortError("Configuration not found",r.OpenfortErrorType.INVALID_CONFIGURATION);return r.withOpenfortError(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:s.account},{headers:{authorization:`Bearer ${c.baseConfiguration.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}}),t=new n.Account({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:n.Account.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.SWITCH_ACCOUNT,e.data.address),t},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async setRecoveryMethod({recoveryMethod:e,recoveryPassword:t,encryptionSession:r,passkeyInfo:a}){await this.iframeManager.setRecoveryMethod(e,t,r,a?.passkeyKey,a?.passkeyId)}async disconnect(){await this.iframeManager.disconnect(),this.storage.remove(s.StorageKeys.ACCOUNT)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r,o;exports.ProviderErrorCode=void 0,(r=exports.ProviderErrorCode||(exports.ProviderErrorCode={}))[r.UNAUTHORIZED=4100]="UNAUTHORIZED",r[r.UNSUPPORTED_METHOD=4200]="UNSUPPORTED_METHOD",exports.RpcErrorCode=void 0,(o=exports.RpcErrorCode||(exports.RpcErrorCode={}))[o.INVALID_PARAMS=-32602]="INVALID_PARAMS",o[o.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",o[o.TRANSACTION_REJECTED=-32003]="TRANSACTION_REJECTED";class e extends Error{message;code;constructor(r,o){super(o),this.message=o,this.code=r}}exports.JsonRpcError=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var t=require("../../core/configuration/account.js"),e=require("../../core/configuration/authentication.js"),r=require("../../types/types.js"),a=require("../../utils/chains/index.js"),i=require("../../utils/crypto.js"),s=require("../../utils/typedEventEmitter.js"),o=require("./addEthereumChain.js"),n=require("./estimateGas.js"),c=require("./getCallsStatus.js"),h=require("./JsonRpcError.js"),d=require("./personalSign.js"),u=require("./registerSession.js"),p=require("./revokeSession.js"),l=require("./sendCallSync.js"),w=require("./sendCalls.js"),g=require("./signTypedDataV4.js"),m=require("./types.js"),E=require("./walletHelpers.js");exports.EvmProvider=class{#t;#e;#r;#a;updatePolicy(t){this.#e=t}#i;#s;#o=null;#n;isOpenfort=!0;#c;constructor({storage:t,backendApiClients:e,openfortEventEmitter:a,policyId:i,ensureSigner:o,chains:n,validateAndRefreshSession:c}){this.#c=o,this.#t=t,this.#r=n,this.#e=i,this.#i=c,this.#n=e,this.#s=new s,a.on(r.OpenfortEvents.LOGGED_OUT,this.#h),a.on(r.OpenfortEvents.SWITCH_ACCOUNT,this.#d)}#u=async()=>(this.#a||(this.#a=await this.#c()),this.#a);#h=async()=>{this.#a=void 0,this.#s.emit(m.ProviderEvent.ACCOUNTS_CHANGED,[])};#d=async t=>{this.#s.emit(m.ProviderEvent.ACCOUNTS_CHANGED,[t])};async getRpcProvider(){if(!this.#o){const e=await t.Account.fromStorage(this.#t),r=e?.chainId||8453;await import("@ethersproject/providers").then(t=>{const e=this.#r?this.#r[r]:void 0;this.#o=new t.StaticJsonRpcProvider(e??a.defaultChainRpcs[r])})}if(!this.#o)throw new Error("RPC provider not initialized");return this.#o}async#p(s){switch(s.method){case"eth_accounts":{const e=await t.Account.fromStorage(this.#t);return e?[e.address]:[]}case"eth_requestAccounts":{const e=await t.Account.fromStorage(this.#t);if(e)return this.#s.emit(m.ProviderEvent.ACCOUNTS_CONNECT,{chainId:String(e.chainId)}),[e.address];throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - must be authenticated and configured with a signer.")}case"eth_signTransaction":{const r=await t.Account.fromStorage(this.#t),a=await this.#u(),i=await e.Authentication.fromStorage(this.#t);if(!r||!i)throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const o=await this.getRpcProvider(),{chainId:n}=await o.detectNetwork(),[c]=s.params||[];c.chainId||(c.chainId=n.toString());const d=E.parseTransactionRequest(c),{serialize:u}=await import("@ethersproject/transactions"),p=t=>{if(!t)return;return{legacy:0,eip2930:1,eip1559:2}[t]},{gas:l,...w}=d,g={...w,gasLimit:l,to:d.to??void 0,type:p(d.type)},m=u(g),{keccak256:A}=await import("@ethersproject/keccak256"),R=A(m);await this.#i();const f=await a.sign(R,!1,!1),{splitSignature:S}=await import("@ethersproject/bytes");return u(g,S(f))}case"eth_sendTransaction":{const a=await t.Account.fromStorage(this.#t),i=await this.#u(),o=await e.Authentication.fromStorage(this.#t);if(!a||!o)throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");if(await this.#i(),a?.accountType===r.AccountTypeEnum.EOA){const[t]=s.params||[],e=await this.getRpcProvider(),r=await E.prepareEOATransaction(t,e,a.address),i=await this.#p({method:"eth_signTransaction",params:[r]});return this.#p({method:"eth_sendRawTransaction",params:[i]})}return(await l.sendCallsSync({params:s.params||[],signer:i,account:a,authentication:o,backendClient:this.#n,policyId:this.#e})).receipt.transactionHash}case"eth_sendRawTransactionSync":{const a=await t.Account.fromStorage(this.#t),i=await this.#u(),o=await e.Authentication.fromStorage(this.#t);if(!a||!o)throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");if(a?.accountType===r.AccountTypeEnum.EOA)throw new h.JsonRpcError(h.ProviderErrorCode.UNSUPPORTED_METHOD,`${s.method}: Method not supported`);return await this.#i(),await l.sendCallsSync({params:s.params||[],signer:i,account:a,authentication:o,backendClient:this.#n,policyId:this.#e})}case"eth_estimateGas":{const r=await t.Account.fromStorage(this.#t),a=await e.Authentication.fromStorage(this.#t);if(!r||!a)throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await n.estimateGas({params:s.params||[],account:r,authentication:a,backendClient:this.#n,policyId:this.#e})}case"eth_signTypedData":case"eth_signTypedData_v4":{const e=await t.Account.fromStorage(this.#t),r=await this.#u();if(!e)throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#i();const a=await this.getRpcProvider();return await g.signTypedDataV4({method:s.method,params:s.params||[],signer:r,implementationType:e.implementationType||e.type,rpcProvider:a,account:e})}case"personal_sign":{const e=await t.Account.fromStorage(this.#t);if(!e)throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const r=await this.#u();return await this.#i(),await d.personalSign({params:s.params||[],signer:r,account:e})}case"eth_chainId":{const t=await this.getRpcProvider(),{chainId:e}=await t.detectNetwork();return i.numberToHex(e)}case"wallet_switchEthereumChain":{const t=await this.#u();if(!s.params||!Array.isArray(s.params)||0===s.params.length)throw new h.JsonRpcError(h.RpcErrorCode.INVALID_PARAMS,"Invalid parameters for wallet_switchEthereumChain");await this.#i();try{const e=parseInt(s.params[0].chainId,16);await t.switchChain({chainId:e}),await import("@ethersproject/providers").then(t=>{const r=this.#r?this.#r[e]:void 0;this.#o=new t.StaticJsonRpcProvider(r??a.defaultChainRpcs[e])})}catch(t){const e=t;throw new h.JsonRpcError(h.RpcErrorCode.INTERNAL_ERROR,`Failed to switch chain: ${e.message}`)}return null}case"wallet_addEthereumChain":{await this.#u();const t=await this.getRpcProvider();return await o.addEthereumChain({params:s.params||[],rpcProvider:t,storage:this.#t})}case"wallet_showCallsStatus":return null;case"wallet_getCallsStatus":{const a=await t.Account.fromStorage(this.#t);if(a?.accountType===r.AccountTypeEnum.EOA)throw new h.JsonRpcError(h.ProviderErrorCode.UNSUPPORTED_METHOD,`${s.method}: Method not supported`);const i=await e.Authentication.fromStorage(this.#t);if(!a||!i)throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await c.getCallStatus({params:s.params||{},authentication:i,backendClient:this.#n,account:a})}case"wallet_sendCalls":{const a=await t.Account.fromStorage(this.#t);if(a?.accountType===r.AccountTypeEnum.EOA)throw new h.JsonRpcError(h.ProviderErrorCode.UNSUPPORTED_METHOD,`${s.method}: Method not supported`);const i=await this.#u(),o=await e.Authentication.fromStorage(this.#t);if(!a||!o)throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#i();return await w.sendCalls({params:s.params?s.params[0].calls:[],signer:i,account:a,authentication:o,backendClient:this.#n,policyId:this.#e})}case"wallet_grantPermissions":{const a=await t.Account.fromStorage(this.#t);if(a?.accountType===r.AccountTypeEnum.EOA)throw new h.JsonRpcError(h.ProviderErrorCode.UNSUPPORTED_METHOD,`${s.method}: Method not supported`);const i=await this.#u(),o=await e.Authentication.fromStorage(this.#t);if(!a||!o)throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await u.registerSession({params:s.params||[],signer:i,account:a,authentication:o,backendClient:this.#n,policyId:this.#e})}case"wallet_revokePermissions":{const r=await t.Account.fromStorage(this.#t),a=await this.#u(),i=await e.Authentication.fromStorage(this.#t);if(!r||!i)throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await p.revokeSession({params:s.params||[],signer:a,account:r,authentication:i,backendClient:this.#n})}case"wallet_getCapabilities":{const e=await t.Account.fromStorage(this.#t);if(e?.accountType===r.AccountTypeEnum.EOA)throw new h.JsonRpcError(h.ProviderErrorCode.UNSUPPORTED_METHOD,`${s.method}: Method not supported`);const a=await this.getRpcProvider(),{chainId:o}=await a.detectNetwork();return{[i.numberToHex(o)]:{permissions:{supported:!0,signerTypes:["account","key"],keyTypes:["secp256k1"],permissionTypes:["contract-calls"]},paymasterService:{supported:!0},atomicBatch:{supported:!0}}}}case"eth_gasPrice":case"eth_getBalance":case"eth_sendRawTransaction":case"eth_getCode":case"eth_getStorageAt":case"eth_call":case"eth_blockNumber":case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getTransactionByHash":case"eth_getTransactionReceipt":case"eth_getTransactionCount":return(await this.getRpcProvider()).send(s.method,s.params||[]);default:throw new h.JsonRpcError(h.ProviderErrorCode.UNSUPPORTED_METHOD,`${s.method}: Method not supported`)}}async request(t){try{return this.#p(t)}catch(t){if(t instanceof h.JsonRpcError)throw t;if(t instanceof Error)throw new h.JsonRpcError(h.RpcErrorCode.INTERNAL_ERROR,t.message);throw new h.JsonRpcError(h.RpcErrorCode.INTERNAL_ERROR,"Internal error")}}on(t,e){this.#s.on(t,e)}removeListener(t,e){this.#s.off(t,e)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=require("../../core/errors/openfortError.js"),e=require("./JsonRpcError.js");const o=r=>{const e=r?.logs?.[0];return{blockHash:e?.blockHash,blockNumber:r?.blockNumber?.toString(),contractAddress:void 0,cumulativeGasUsed:r?.gasUsed,effectiveGasPrice:r?.gasFee,from:void 0,gasUsed:r?.gasUsed,logs:r?.logs||[],logsBloom:void 0,status:1===r?.status?"success":0===r?.status?"reverted":void 0,to:r?.to,transactionHash:r?.transactionHash,transactionIndex:e?.transactionIndex,type:"eip1559",blobGasPrice:void 0,blobGasUsed:void 0,root:void 0}};exports.sendCallsSync=async({params:t,signer:a,account:s,authentication:n,backendClient:i,policyId:c})=>{const d=t[0]?.capabilities?.paymasterService?.policy??c,p=await(async(o,t,a,s,n)=>{const i=o.map(r=>{if(!r.to)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,'wallet_sendCalls requires a "to" field');return{to:String(r.to),data:r.data?String(r.data):void 0,value:r.value?String(r.value):void 0}});return r.withOpenfortError(async()=>(await t.transactionIntentsApi.createTransactionIntent({createTransactionIntentRequest:{account:a.id,policy:n,chainId:a.chainId,interactions:i}},{headers:{authorization:`Bearer ${t.config.backend.accessToken}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}})).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})})(t,i,s,n,d).catch(r=>{throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,r.message)});if(p.response?.error.reason)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,p.response?.error.reason);if(p?.nextAction?.payload?.signableHash){let t;t=[300,531050104,324,50104,2741,11124].includes(s.chainId)?await a.sign(p.nextAction.payload.signableHash,!1,!1):await a.sign(p.nextAction.payload.signableHash);const n=await r.withOpenfortError(async()=>await i.transactionIntentsApi.signature({id:p.id,signatureRequest:{signature:t}}),{default:r.OpenfortErrorType.AUTHENTICATION_ERROR}).catch(r=>{throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,r.message)});if(0===n.data.response?.status)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,n.data.response?.error.reason);if(!n.data.response)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,"No transaction response received");return{id:p.id,receipt:o(n.data.response)}}if(!p.response)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,"No transaction response received");return{id:p.id,receipt:o(p.response)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=require("./sendCallSync.js");exports.sendCalls=async({params:n,signer:e,account:c,authentication:i,backendClient:s,policyId:t})=>(await a.sendCallsSync({params:n,signer:e,account:c,authentication:i,backendClient:s,policyId:t})).id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e;exports.ProviderEvent=void 0,(e=exports.ProviderEvent||(exports.ProviderEvent={})).ACCOUNTS_CHANGED="accountsChanged",e.ACCOUNTS_CONNECT="connect";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../types/types.js");exports.signMessage=async t=>{const{hash:
|
|
1
|
+
"use strict";var e=require("../../types/types.js");exports.parseTransactionRequest=function({from:e,...t}){return{to:t.to,data:t.data,accessList:t.accessList,chainId:(i=t.chainId,i.startsWith("0x")?parseInt(i,16):parseInt(i,10)),type:t.type&&{"0x0":"legacy","0x1":"eip2930","0x2":"eip1559"}[t.type]||"eip1559",maxPriorityFeePerGas:t.maxPriorityFeePerGas?BigInt(t.maxPriorityFeePerGas):void 0,maxFeePerGas:t.maxFeePerGas?BigInt(t.maxFeePerGas):void 0,gasPrice:t.gasPrice?BigInt(t.gasPrice):void 0,value:(a=t.value,s=BigInt,r=0n,void 0!==a?s(a):r),nonce:t.nonce?parseInt(t.nonce.toString(),16):void 0,gas:t.gas?BigInt(t.gas):void 0};var a,s,r,i},exports.prepareEOATransaction=async function(e,t,a){const s={...e};if(!s.nonce){const e=await t.getTransactionCount(a,"pending");s.nonce=`0x${e.toString(16)}`}if(!s.gas)try{const e=await t.estimateGas({from:a,to:s.to,data:s.data,value:s.value});s.gas=e.toHexString()}catch{s.gas="0x5208"}const r=s.maxFeePerGas&&s.maxPriorityFeePerGas,i=s.gasPrice;if(!r&&!i){const e=await t.getBlock("latest");if(null!==e.baseFeePerGas&&void 0!==e.baseFeePerGas){const a=e.baseFeePerGas,r=a.mul(12).div(10),i=await t.getGasPrice();let n=i.sub(a);n.lt(0)&&(n=i.mul(0));const o=r.add(n);s.maxFeePerGas=o.toHexString(),s.maxPriorityFeePerGas=n.toHexString(),s.type="0x2",delete s.gasPrice}else{const e=(await t.getGasPrice()).mul(12).div(10);s.gasPrice=e.toHexString(),s.type="0x0",delete s.maxFeePerGas,delete s.maxPriorityFeePerGas}}return s},exports.signMessage=async t=>{const{hash:a,signer:s,ownerAddress:r,factoryAddress:i,salt:n,chainId:o,address:c,implementationType:d}=t;let p=a;if([e.AccountType.UPGRADEABLE_V5,e.AccountType.UPGRADEABLE_V6,e.AccountType.ZKSYNC_UPGRADEABLE_V1,e.AccountType.ZKSYNC_UPGRADEABLE_V2].includes(d)){const e={name:"Openfort",version:"0.5",chainId:Number(o),verifyingContract:c},t={OpenfortMessage:[{name:"hashedMessage",type:"bytes32"}]},a={hashedMessage:p},{_TypedDataEncoder:s}=await import("@ethersproject/hash");p=s.hash(e,t,a)}const g=await s.sign(p,!1,!1);if(i&&n&&[e.AccountType.UPGRADEABLE_V5,e.AccountType.UPGRADEABLE_V6].includes(d)){const{id:e}=await import("@ethersproject/hash"),{defaultAbiCoder:t}=await import("@ethersproject/abi"),{hexConcat:a}=await import("@ethersproject/bytes"),s=a([e("createAccountWithNonce(address,bytes32,bool)").slice(0,10),t.encode(["address","bytes32","bool"],[r,n,!1])]);return a([t.encode(["address","bytes","bytes"],[i,s,g]),"0x6492649264926492649264926492649264926492649264926492649264926492"])}return g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../core/configuration/account.js"),r=require("../core/configuration/authentication.js"),i=require("../core/errors/openfortError.js"),t=require("../core/errors/sentry.js"),o=require("../storage/istorage.js"),n=require("../utils/crypto.js"),s=require("../utils/debug.js"),a=require("./messaging/ReactNativeMessenger.js"),d=require("./messaging/browserMessenger/connect.js");require("./messaging/browserMessenger/backwardCompatibility.js");var c=require("./types.js");class u extends Error{constructor(){super("This embedded signer requires a password to be recovered")}}class h extends Error{constructor(){super("Wrong recovery passkey for this embedded signer")}}class g extends Error{constructor(){super("MissingProjectEntropyError")}}class l extends Error{constructor(){super("Wrong recovery password for this embedded signer")}}class y extends Error{constructor(){super("Not configured")}}class p extends Error{constructor(){super("OTP required")}}exports.IframeManager=class{messenger;connection;remote;storage;sdkConfiguration;isInitialized=!1;initializationPromise=null;constructor(e,r,t){if(!e)throw new i.OpenfortError("Configuration is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);if(!r)throw new i.OpenfortError("Storage is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);if(!t)throw new i.OpenfortError("Messenger is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);this.sdkConfiguration=e,this.storage=r,this.messenger=t}async initialize(){if(!this.isInitialized)if(this.initializationPromise)await this.initializationPromise;else{this.initializationPromise=this.doInitialize();try{await this.initializationPromise,this.isInitialized=!0}catch(e){throw this.initializationPromise=null,e}}}async doInitialize(){s.debugLog("Initializing IframeManager connection..."),this.messenger.initialize({validateReceivedMessage:e=>!(!e||"object"!=typeof e),log:s.debugLog}),this.connection=d({messenger:this.messenger,timeout:1e4,log:s.debugLog});try{this.remote=await this.connection.promise,s.debugLog("IframeManager connection established")}catch(e){const r=e;throw t.sentry.captureException(r),this.destroy(),s.debugLog("Failed to establish connection:",r),new i.OpenfortError(`Failed to establish iFrame connection: ${r.cause||r.message}`,i.OpenfortErrorType.INTERNAL_ERROR,e)}}async ensureConnection(){if(this.isInitialized&&this.remote||await this.initialize(),!this.remote)throw new i.OpenfortError("Failed to establish connection",i.OpenfortErrorType.INTERNAL_ERROR);return this.remote}handleError(e){if(c.isErrorResponse(e)){if(e.error===c.NOT_CONFIGURED_ERROR)throw this.storage.remove(o.StorageKeys.ACCOUNT),new y;if(e.error===c.MISSING_USER_ENTROPY_ERROR)throw this.storage.remove(o.StorageKeys.ACCOUNT),new u;if(e.error===c.MISSING_PROJECT_ENTROPY_ERROR)throw this.storage.remove(o.StorageKeys.ACCOUNT),new g;if(e.error===c.INCORRECT_USER_ENTROPY_ERROR)throw new l;if(e.error===c.MISSING_PASSKEY_ERROR)throw this.storage.remove(o.StorageKeys.ACCOUNT),new u;if(e.error===c.INCORRECT_PASSKEY_ERROR)throw new h;if(e.error===c.OTP_REQUIRED_ERROR)throw new p;throw this.storage.remove(o.StorageKeys.ACCOUNT),new i.OpenfortError(`Unknown error: ${e.error}`,i.OpenfortErrorType.INTERNAL_ERROR)}throw e}async buildRequestConfiguration(){const e=await r.Authentication.fromStorage(this.storage);if(!e)throw new i.OpenfortError("Must be authenticated to create a signer",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const t={auth:c.ShieldAuthType.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyProvider:e.thirdPartyProvider,thirdPartyTokenType:e.thirdPartyTokenType,token:e.token,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl,shieldAuthentication:t,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",shieldURL:this.sdkConfiguration.shieldUrl,encryptionKey:this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionKey??void 0}}async buildIFrameRequestConfiguration(){const e=await r.Authentication.fromStorage(this.storage);if(!e)throw new i.OpenfortError("Must be authenticated to create a signer",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const t={auth:c.ShieldAuthType.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyTokenType:e.thirdPartyTokenType??null,thirdPartyProvider:e.thirdPartyProvider??null,accessToken:e.token,playerID:e.player,recovery:t,chainId:null,password:null,passkey:null}}async create(e){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const r=await this.ensureConnection(),i=await this.buildIFrameRequestConfiguration();i.chainId=e.chainId??null,i.password=e?.entropy?.recoveryPassword??null,i.recovery={...i.recovery,encryptionSession:e?.entropy?.encryptionSession},i.passkey=e?.entropy?.passkey??null;const t={uuid:n.randomUUID(),action:c.Event.CREATE,recovery:i.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:i.accessToken,playerID:i.playerID,thirdPartyProvider:i.thirdPartyProvider,thirdPartyTokenType:i.thirdPartyTokenType,encryptionKey:i.password,encryptionSession:i.recovery?.encryptionSession??null,passkey:i.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,chainId:e.chainId??null,accountType:e.accountType,chainType:e.chainType},o=await r.create(t);return c.isErrorResponse(o)&&this.handleError(o),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",o.version??"undefined"),o}async recover(r){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const i=await e.Account.fromStorage(this.storage),t=await this.ensureConnection(),o=await this.buildIFrameRequestConfiguration();o.chainId=i?.chainId??null,o.password=r?.entropy?.recoveryPassword??null,o.recovery={...o.recovery,encryptionSession:r?.entropy?.encryptionSession},o.passkey=r?.entropy?.passkey??null;const s={uuid:n.randomUUID(),action:c.Event.RECOVER,recovery:o.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:o.accessToken,playerID:o.playerID,thirdPartyProvider:o.thirdPartyProvider,thirdPartyTokenType:o.thirdPartyTokenType,encryptionKey:o.password,encryptionSession:o.recovery?.encryptionSession??null,passkey:o.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,account:r.account},a=await t.recover(s);return c.isErrorResponse(a)&&this.handleError(a),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",a.version??"undefined"),a}async sign(e,r,i,t){s.debugLog("[iframe] ensureConnection");const o=await this.ensureConnection(),a=new c.SignRequest(n.randomUUID(),e,await this.buildRequestConfiguration(),r,i,t);s.debugLog("[iframe] done ensureConnection");const d=await o.sign(a);return s.debugLog("[iframe] response",d),c.isErrorResponse(d)&&this.handleError(d),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",d.version??"undefined"),d.signature}async switchChain(e){const r=await this.ensureConnection(),i=new c.SwitchChainRequest(n.randomUUID(),e,await this.buildRequestConfiguration()),t=await r.switchChain(i);return c.isErrorResponse(t)&&this.handleError(t),t}async export(){const e=await this.ensureConnection(),r=new c.ExportPrivateKeyRequest(n.randomUUID(),await this.buildRequestConfiguration()),i=await e.export(r);return c.isErrorResponse(i)&&this.handleError(i),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",i.version??"undefined"),i.key}async setRecoveryMethod(e,r,i,t,o){const s=await this.ensureConnection(),a=new c.SetRecoveryMethodRequest(n.randomUUID(),e,await this.buildRequestConfiguration(),r,i,t,o),d=await s.setRecoveryMethod(a);c.isErrorResponse(d)&&this.handleError(d),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",d.version??"undefined")}async getCurrentDevice(e){const r=await this.ensureConnection(),i=new c.GetCurrentDeviceRequest(n.randomUUID(),e);try{const e=await r.getCurrentDevice(i);return c.isErrorResponse(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e}catch(e){if(e instanceof y)return null;throw e}}async updateAuthentication(){if(!this.isLoaded()||!this.remote)return void s.debugLog("IframeManager not loaded, skipping authentication update");const e=await r.Authentication.fromStorage(this.storage);if(!e)return void s.debugLog("No authentication found, skipping update");const i=new c.UpdateAuthenticationRequest(n.randomUUID(),e.token);s.debugLog("Updating authentication in iframe with token");const t=await this.remote.updateAuthentication(i);c.isErrorResponse(t)&&this.handleError(t)}async disconnect(){const e=await this.ensureConnection(),r={uuid:n.randomUUID()};await e.logout(r)}async onMessage(e){s.debugLog("[HANDSHAKE DEBUG] IframeManager.onMessage called with:",e),this.messenger instanceof a.ReactNativeMessenger?(this.isInitialized||this.connection?s.debugLog(`[HANDSHAKE DEBUG] Connection already initialized (isInitialized: ${this.isInitialized}, hasConnection: ${!!this.connection})`):(s.debugLog("[HANDSHAKE DEBUG] First message received, initializing connection..."),this.initialize().catch(e=>{s.debugLog("[HANDSHAKE DEBUG] Failed to initialize connection:",e)})),s.debugLog("[HANDSHAKE DEBUG] Passing message to ReactNativeMessenger"),this.messenger.handleMessage(e)):s.debugLog("[HANDSHAKE DEBUG] Not a ReactNativeMessenger, ignoring message")}isLoaded(){return this.isInitialized&&void 0!==this.remote}destroy(){this.connection&&this.connection.destroy(),this.messenger.destroy(),this.remote=void 0,this.isInitialized=!1,this.connection=void 0,this.initializationPromise=null}},exports.MissingProjectEntropyError=g,exports.MissingRecoveryPasswordError=u,exports.NotConfiguredError=y,exports.OTPRequiredError=p,exports.WrongPasskeyError=h,exports.WrongRecoveryPasswordError=l;
|
|
1
|
+
"use strict";var e=require("../core/configuration/account.js"),r=require("../core/configuration/authentication.js"),i=require("../core/errors/openfortError.js"),t=require("../core/errors/sentry.js"),o=require("../storage/istorage.js"),n=require("../utils/crypto.js"),s=require("../utils/debug.js"),a=require("./messaging/ReactNativeMessenger.js"),d=require("./messaging/browserMessenger/connect.js");require("./messaging/browserMessenger/backwardCompatibility.js");var c=require("./types.js");class u extends Error{constructor(){super("This embedded signer requires a password to be recovered")}}class h extends Error{constructor(){super("Wrong recovery passkey for this embedded signer")}}class g extends Error{constructor(){super("MissingProjectEntropyError")}}class l extends Error{constructor(){super("Wrong recovery password for this embedded signer")}}class y extends Error{constructor(){super("Not configured")}}class p extends Error{constructor(){super("OTP required")}}exports.IframeManager=class{messenger;connection;remote;storage;sdkConfiguration;isInitialized=!1;initializationPromise=null;constructor(e,r,t){if(!e)throw new i.OpenfortError("Configuration is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);if(!r)throw new i.OpenfortError("Storage is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);if(!t)throw new i.OpenfortError("Messenger is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);this.sdkConfiguration=e,this.storage=r,this.messenger=t}async initialize(){if(!this.isInitialized)if(this.initializationPromise)await this.initializationPromise;else{this.initializationPromise=this.doInitialize();try{await this.initializationPromise,this.isInitialized=!0}catch(e){throw this.initializationPromise=null,e}}}async doInitialize(){s.debugLog("Initializing IframeManager connection..."),this.messenger.initialize({validateReceivedMessage:e=>!(!e||"object"!=typeof e),log:s.debugLog}),this.connection=d({messenger:this.messenger,timeout:1e4,log:s.debugLog});try{this.remote=await this.connection.promise,s.debugLog("IframeManager connection established")}catch(e){const r=e;throw t.sentry.captureException(r),this.destroy(),s.debugLog("Failed to establish connection:",r),new i.OpenfortError(`Failed to establish iFrame connection: ${r.cause||r.message}`,i.OpenfortErrorType.INTERNAL_ERROR,e)}}async ensureConnection(){if(this.isInitialized&&this.remote||await this.initialize(),!this.remote)throw new i.OpenfortError("Failed to establish connection",i.OpenfortErrorType.INTERNAL_ERROR);return this.remote}handleError(e){if(c.isErrorResponse(e)){if(e.error===c.NOT_CONFIGURED_ERROR)throw this.storage.remove(o.StorageKeys.ACCOUNT),new y;if(e.error===c.MISSING_USER_ENTROPY_ERROR)throw this.storage.remove(o.StorageKeys.ACCOUNT),new u;if(e.error===c.MISSING_PROJECT_ENTROPY_ERROR)throw this.storage.remove(o.StorageKeys.ACCOUNT),new g;if(e.error===c.INCORRECT_USER_ENTROPY_ERROR)throw new l;if(e.error===c.MISSING_PASSKEY_ERROR)throw this.storage.remove(o.StorageKeys.ACCOUNT),new u;if(e.error===c.INCORRECT_PASSKEY_ERROR)throw new h;if(e.error===c.OTP_REQUIRED_ERROR)throw new p;throw this.storage.remove(o.StorageKeys.ACCOUNT),new i.OpenfortError(`Unknown error: ${e.error}`,i.OpenfortErrorType.INTERNAL_ERROR)}throw e}async buildRequestConfiguration(){const e=await r.Authentication.fromStorage(this.storage);if(!e)throw new i.OpenfortError("Must be authenticated to create a signer",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const t={auth:c.ShieldAuthType.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyProvider:e.thirdPartyProvider,thirdPartyTokenType:e.thirdPartyTokenType,token:e.token,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl,shieldAuthentication:t,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",shieldURL:this.sdkConfiguration.shieldUrl,encryptionKey:this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionKey??void 0}}async buildIFrameRequestConfiguration(){const e=await r.Authentication.fromStorage(this.storage);if(!e)throw new i.OpenfortError("Must be authenticated to create a signer",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const t={auth:c.ShieldAuthType.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyTokenType:e.thirdPartyTokenType??null,thirdPartyProvider:e.thirdPartyProvider??null,accessToken:e.token,playerID:e.player,recovery:t,chainId:null,password:null,passkey:null}}async create(e){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const r=await this.ensureConnection(),i=await this.buildIFrameRequestConfiguration();i.chainId=e.chainId??null,i.password=e?.entropy?.recoveryPassword??null,i.recovery={...i.recovery,encryptionSession:e?.entropy?.encryptionSession},i.passkey=e?.entropy?.passkey??null;const t={uuid:n.randomUUID(),action:c.Event.CREATE,recovery:i.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:i.accessToken,playerID:i.playerID,thirdPartyProvider:i.thirdPartyProvider,thirdPartyTokenType:i.thirdPartyTokenType,encryptionKey:i.password,encryptionSession:i.recovery?.encryptionSession??null,passkey:i.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,chainId:e.chainId??null,accountType:e.accountType,chainType:e.chainType},o=await r.create(t);return c.isErrorResponse(o)&&this.handleError(o),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",o.version??"undefined"),o}async recover(r){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const i=await e.Account.fromStorage(this.storage),t=await this.ensureConnection(),o=await this.buildIFrameRequestConfiguration();o.chainId=i?.chainId??null,o.password=r?.entropy?.recoveryPassword??null,o.recovery={...o.recovery,encryptionSession:r?.entropy?.encryptionSession},o.passkey=r?.entropy?.passkey??null;const s={uuid:n.randomUUID(),action:c.Event.RECOVER,recovery:o.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:o.accessToken,playerID:o.playerID,thirdPartyProvider:o.thirdPartyProvider,thirdPartyTokenType:o.thirdPartyTokenType,encryptionKey:o.password,encryptionSession:o.recovery?.encryptionSession??null,passkey:o.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,account:r.account},a=await t.recover(s);return c.isErrorResponse(a)&&this.handleError(a),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",a.version??"undefined"),a}async sign(e,r,i,t){s.debugLog("[iframe] ensureConnection");const o=await this.ensureConnection(),a=new c.SignRequest(n.randomUUID(),e,await this.buildRequestConfiguration(),r,i,t);s.debugLog("[iframe] done ensureConnection");const d=await o.sign(a);return s.debugLog("[iframe] response",d),c.isErrorResponse(d)&&this.handleError(d),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",d.version??"undefined"),d.signature}async switchChain(e){const r=await this.ensureConnection(),i=new c.SwitchChainRequest(n.randomUUID(),e,await this.buildRequestConfiguration()),t=await r.switchChain(i);return c.isErrorResponse(t)&&this.handleError(t),t}async export(){const e=await this.ensureConnection(),r=new c.ExportPrivateKeyRequest(n.randomUUID(),await this.buildRequestConfiguration()),i=await e.export(r);return c.isErrorResponse(i)&&this.handleError(i),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",i.version??"undefined"),i.key}async setRecoveryMethod(e,r,i,t,o){const s=await this.ensureConnection(),a=new c.SetRecoveryMethodRequest(n.randomUUID(),e,await this.buildRequestConfiguration(),r,i,t,o),d=await s.setRecoveryMethod(a);c.isErrorResponse(d)&&this.handleError(d),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",d.version??"undefined")}async getCurrentDevice(e){const r=await this.ensureConnection(),i=new c.GetCurrentDeviceRequest(n.randomUUID(),e);try{const e=await r.getCurrentDevice(i);return c.isErrorResponse(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e}catch(e){if(e instanceof y)return null;throw e}}async updateAuthentication(){if(!this.isLoaded()||!this.remote)return void s.debugLog("IframeManager not loaded, skipping authentication update");const e=await r.Authentication.fromStorage(this.storage);if(!e)return void s.debugLog("No authentication found, skipping update");const i=new c.UpdateAuthenticationRequest(n.randomUUID(),e.token);s.debugLog("Updating authentication in iframe with token");const t=await this.remote.updateAuthentication(i);c.isErrorResponse(t)&&this.handleError(t)}async disconnect(){const e=await this.ensureConnection(),r={uuid:n.randomUUID()};await e.logout(r)}async onMessage(e){s.debugLog("[HANDSHAKE DEBUG] IframeManager.onMessage called with:",e),this.messenger instanceof a.ReactNativeMessenger?(this.isInitialized||this.connection?s.debugLog(`[HANDSHAKE DEBUG] Connection already initialized (isInitialized: ${this.isInitialized}, hasConnection: ${!!this.connection})`):(s.debugLog("[HANDSHAKE DEBUG] First message received, initializing connection..."),this.initialize().catch(e=>{s.debugLog("[HANDSHAKE DEBUG] Failed to initialize connection:",e)})),s.debugLog("[HANDSHAKE DEBUG] Passing message to ReactNativeMessenger"),this.messenger.handleMessage(e)):s.debugLog("[HANDSHAKE DEBUG] Not a ReactNativeMessenger, ignoring message")}isLoaded(){return this.isInitialized&&void 0!==this.remote}destroy(){this.connection&&this.connection.destroy(),this.messenger.destroy(),this.remote=void 0,this.isInitialized=!1,this.connection=void 0,this.initializationPromise=null}},exports.MissingProjectEntropyError=g,exports.MissingRecoveryPasswordError=u,exports.NotConfiguredError=y,exports.OTPRequiredError=p,exports.WrongRecoveryPasswordError=l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e;exports.Event=void 0,(e=exports.Event||(exports.Event={})).
|
|
1
|
+
"use strict";var e;exports.Event=void 0,(e=exports.Event||(exports.Event={})).RECOVER="recover",e.RECOVERED="recovered",e.CREATE="create",e.CREATED="created",e.UPDATE_AUTHENTICATION="update-authentication",e.AUTHENTICATION_UPDATED="authentication-updated",e.SIGN="sign",e.SET_RECOVERY_METHOD="set-recovery-method",e.SWITCH_CHAIN="switch-chain",e.CHAIN_SWITCHED="chain-switched",e.EXPORT="export",e.SIGNED="signed",e.LOGGED_OUT="logged-out",e.GET_CURRENT_DEVICE="get-current-device",e.CURRENT_DEVICE="current-device";exports.ShieldAuthType=void 0,(exports.ShieldAuthType||(exports.ShieldAuthType={})).OPENFORT="openfort",exports.ExportPrivateKeyRequest=class{uuid;action=exports.Event.EXPORT;requestConfiguration;constructor(e,t){this.uuid=e,this.requestConfiguration=t}},exports.GetCurrentDeviceRequest=class{uuid;action=exports.Event.GET_CURRENT_DEVICE;playerID;constructor(e,t){this.uuid=e,this.playerID=t}},exports.INCORRECT_PASSKEY_ERROR="incorrect-passkey-error",exports.INCORRECT_USER_ENTROPY_ERROR="incorrect-user-entropy-error",exports.MISSING_PASSKEY_ERROR="missing-passkey-error",exports.MISSING_PROJECT_ENTROPY_ERROR="missing-project-entropy-error",exports.MISSING_USER_ENTROPY_ERROR="missing-user-entropy-error",exports.NOT_CONFIGURED_ERROR="not-configured-error",exports.OTP_REQUIRED_ERROR="otp-required-error",exports.SetRecoveryMethodRequest=class{uuid;action=exports.Event.SET_RECOVERY_METHOD;recoveryMethod;recoveryPassword;encryptionSession;passkeyKey;passkeyId;requestConfiguration;constructor(e,t,r,s,o,i,n){this.uuid=e,this.recoveryMethod=t,this.recoveryPassword=s,this.encryptionSession=o,this.requestConfiguration=r,this.passkeyKey=i,this.passkeyId=n}},exports.SignRequest=class{uuid;action=exports.Event.SIGN;message;requestConfiguration;requireArrayify;requireHash;chainType;constructor(e,t,r,s,o,i){this.uuid=e,this.message=t,this.requestConfiguration=r,this.requireArrayify=s,this.requireHash=o,this.chainType=i||"EVM"}},exports.SwitchChainRequest=class{uuid;action=exports.Event.SWITCH_CHAIN;chainId;requestConfiguration;constructor(e,t,r){this.uuid=e,this.chainId=t,this.requestConfiguration=r}},exports.UpdateAuthenticationRequest=class{uuid;action=exports.Event.UPDATE_AUTHENTICATION;accessToken;recovery;constructor(e,t,r){this.uuid=e,this.accessToken=t,this.recovery=r}},exports.isErrorResponse=function(e){return"error"in e};
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"axios";import t from"axios-retry";const n="https://api.openfort.io".replace(/\/+$/,"");class s{basePath;axios;configuration;constructor(t,s=n,a=e){this.basePath=s,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,n){if(null==n)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const n="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+n}};function c(e,t,n=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,n)):Object.keys(t).forEach(s=>c(e,t[s],`${n}${""!==n?".":""}${s}`)):e.has(n)?e.append(n,t):e.set(n,t))}const h=function(e,...t){const n=new URLSearchParams(e.search);c(n,t),e.search=n.toString()},u=function(e,t,n){const s="string"!=typeof e;return(s&&n&&n.isJsonMime?n.isJsonMime(t.headers["Content-Type"]):s)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,n,s){return(a=t,i=n)=>{const o={...e.options,url:(s?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const s=function(e){return{cancelTransferOwnership:async(t,n,s={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",n);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},completeRecovery:async(t,n,s={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",n);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},createAccount:async(t,n={})=>{o("createAccount","createAccountRequest",t);const s=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},deployAccount:async(t,n,s={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",n);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},disableAccount:async(t,n={})=>{o("disableAccount","id",t);const s="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccount:async(t,n,s={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getAccountV2:async(t,n={})=>{o("getAccountV2","id",t);const s="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccounts:async(t,n,s,a,o,c,u,l={})=>{const p=new URL("/v1/accounts",i);let y;e&&(y=e.baseOptions);const g={method:"GET",...y,...l},w={},m={};await r(w,e),void 0!==t&&(m.limit=t),void 0!==n&&(m.skip=n),void 0!==s&&(m.order=s),void 0!==a&&(m.chainId=a),void 0!==o&&(m.player=o),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let P=y&&y.headers?y.headers:{};return g.headers={...w,...P,...l.headers},{url:d(p),options:g}},getAccountsV2:async(t,n,s,a,o,c,u,l,p={})=>{const y=new URL("/v2/accounts",i);let g;e&&(g=e.baseOptions);const w={method:"GET",...g,...p},m={},P={};await r(m,e),void 0!==t&&(P.limit=t),void 0!==n&&(P.skip=n),void 0!==s&&(P.order=s),void 0!==a&&(P.chainId=a),void 0!==o&&(P.user=o),void 0!==c&&(P.chainType=c),void 0!==u&&(P.accountType=u),void 0!==l&&(P.address=l),h(y,P);let R=g&&g.headers?g.headers:{};return w.headers={...m,...R,...p.headers},{url:d(y),options:w}},getSignerIdByAddress:async(t,n={})=>{o("getSignerIdByAddress","address",t);const s=new URL("/v2/accounts/signer",i);let a;e&&(a=e.baseOptions);const c={method:"GET",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.address=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},requestTransferOwnership:async(t,n,s={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",n);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},signPayload:async(t,n,s={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",n);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},startRecovery:async(t,n,s={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",n);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},switchChainV2:async(t,n={})=>{o("switchChainV2","switchChainQueriesV2",t);const s=new URL("/v2/accounts/switch-chain",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},syncAccount:async(t,n={})=>{o("syncAccount","id",t);const s="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await s.cancelTransferOwnership(a,i,o);return l(r,e,n,t)},async completeRecovery(a,i,o){const r=await s.completeRecovery(a,i,o);return l(r,e,n,t)},async createAccount(a,i){const o=await s.createAccount(a,i);return l(o,e,n,t)},async deployAccount(a,i,o){const r=await s.deployAccount(a,i,o);return l(r,e,n,t)},async disableAccount(a,i){const o=await s.disableAccount(a,i);return l(o,e,n,t)},async getAccount(a,i,o){const r=await s.getAccount(a,i,o);return l(r,e,n,t)},async getAccountV2(a,i){const o=await s.getAccountV2(a,i);return l(o,e,n,t)},async getAccounts(a,i,o,r,c,h,u,d){const p=await s.getAccounts(a,i,o,r,c,h,u,d);return l(p,e,n,t)},async getAccountsV2(a,i,o,r,c,h,u,d,p){const y=await s.getAccountsV2(a,i,o,r,c,h,u,d,p);return l(y,e,n,t)},async getSignerIdByAddress(a,i){const o=await s.getSignerIdByAddress(a,i);return l(o,e,n,t)},async requestTransferOwnership(a,i,o){const r=await s.requestTransferOwnership(a,i,o);return l(r,e,n,t)},async signPayload(a,i,o){const r=await s.signPayload(a,i,o);return l(r,e,n,t)},async startRecovery(a,i,o){const r=await s.startRecovery(a,i,o);return l(r,e,n,t)},async switchChainV2(a,i){const o=await s.switchChainV2(a,i);return l(o,e,n,t)},async syncAccount(a,i){const o=await s.syncAccount(a,i);return l(o,e,n,t)}}};class y extends s{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.id,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.chainId,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountsV2(e={},t){return p(this.configuration).getAccountsV2(e.limit,e.skip,e.order,e.chainId,e.user,e.chainType,e.accountType,e.address,t).then(e=>e(this.axios,this.basePath))}getSignerIdByAddress(e,t){return p(this.configuration).getSignerIdByAddress(e.address,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}switchChainV2(e,t){return p(this.configuration).switchChainV2(e.switchChainQueriesV2,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const s=function(e){return{authenticateSIWE:async(t,n={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getJwks:async(t,n={})=>{o("getJwks","publishableKey",t);const s="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},initOAuth:async(t,n,s={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,n,s={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,n,s={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,n,s={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,n={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},linkThirdParty:async(t,n,s={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,n,s={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,n,s={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,n={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const s=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},logout:async(t,n={})=>{o("logout","logoutRequest",t);const s=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},me:async(t={})=>{const n=new URL("/iam/v1/me",i);let s;e&&(s=e.baseOptions);const a={method:"GET",...s,...t};h(n,{});let o=s&&s.headers?s.headers:{};return a.headers={...o,...t.headers},{url:d(n),options:a}},poolOAuth:async(t,n={})=>{o("poolOAuth","key",t);const s=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},refresh:async(t,n={})=>{o("refresh","refreshTokenRequest",t);const s=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},registerGuest:async(t,n={})=>{const s=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...n},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(s,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...n.headers},{url:d(s),options:o}},requestEmailVerification:async(t,n={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const s=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},requestResetPassword:async(t,n={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const s=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},resetPassword:async(t,n={})=>{o("resetPassword","resetPasswordRequest",t);const s=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},signupEmailPassword:async(t,n,s={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,n,s={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,n={})=>{o("unlinkEmail","unlinkEmailRequest",t);const s=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkOAuth:async(t,n={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const s=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkSIWE:async(t,n={})=>{o("unlinkSIWE","sIWERequest",t);const s=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},verifyEmail:async(t,n={})=>{o("verifyEmail","verifyEmailRequest",t);const s=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},verifyOAuthToken:async(t,n={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const s=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await s.authenticateSIWE(a,i);return l(o,e,n,t)},async getJwks(a,i){const o=await s.getJwks(a,i);return l(o,e,n,t)},async initOAuth(a,i,o){const r=await s.initOAuth(a,i,o);return l(r,e,n,t)},async initSIWE(a,i,o){const r=await s.initSIWE(a,i,o);return l(r,e,n,t)},async linkEmail(a,i,o){const r=await s.linkEmail(a,i,o);return l(r,e,n,t)},async linkOAuth(a,i,o){const r=await s.linkOAuth(a,i,o);return l(r,e,n,t)},async linkSIWE(a,i){const o=await s.linkSIWE(a,i);return l(o,e,n,t)},async linkThirdParty(a,i,o){const r=await s.linkThirdParty(a,i,o);return l(r,e,n,t)},async loginEmailPassword(a,i,o){const r=await s.loginEmailPassword(a,i,o);return l(r,e,n,t)},async loginOIDC(a,i,o){const r=await s.loginOIDC(a,i,o);return l(r,e,n,t)},async loginWithIdToken(a,i){const o=await s.loginWithIdToken(a,i);return l(o,e,n,t)},async logout(a,i){const o=await s.logout(a,i);return l(o,e,n,t)},async me(a){const i=await s.me(a);return l(i,e,n,t)},async poolOAuth(a,i){const o=await s.poolOAuth(a,i);return l(o,e,n,t)},async refresh(a,i){const o=await s.refresh(a,i);return l(o,e,n,t)},async registerGuest(a,i){const o=await s.registerGuest(a,i);return l(o,e,n,t)},async requestEmailVerification(a,i){const o=await s.requestEmailVerification(a,i);return l(o,e,n,t)},async requestResetPassword(a,i){const o=await s.requestResetPassword(a,i);return l(o,e,n,t)},async resetPassword(a,i){const o=await s.resetPassword(a,i);return l(o,e,n,t)},async signupEmailPassword(a,i,o){const r=await s.signupEmailPassword(a,i,o);return l(r,e,n,t)},async thirdParty(a,i,o){const r=await s.thirdParty(a,i,o);return l(r,e,n,t)},async unlinkEmail(a,i){const o=await s.unlinkEmail(a,i);return l(o,e,n,t)},async unlinkOAuth(a,i){const o=await s.unlinkOAuth(a,i);return l(o,e,n,t)},async unlinkSIWE(a,i){const o=await s.unlinkSIWE(a,i);return l(o,e,n,t)},async verifyEmail(a,i){const o=await s.verifyEmail(a,i);return l(o,e,n,t)},async verifyOAuthToken(a,i){const o=await s.verifyOAuthToken(a,i);return l(o,e,n,t)}}};class w extends s{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const s=function(e){return{createSession:async(t,n,s={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,n,s,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==n&&(w.limit=n),void 0!==s&&(w.skip=s),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,n,s={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},revokeSession:async(t,n,s={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,n,s={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",n);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await s.createSession(a,i,o);return l(r,e,n,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await s.getPlayerSessions(a,i,o,r,c,h);return l(u,e,n,t)},async getSession(a,i,o){const r=await s.getSession(a,i,o);return l(r,e,n,t)},async revokeSession(a,i,o){const r=await s.revokeSession(a,i,o);return l(r,e,n,t)},async signatureSession(a,i,o){const r=await s.signatureSession(a,i,o);return l(r,e,n,t)}}};class P extends s{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const s=function(e){return{createTransactionIntent:async(t,n,s={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,n={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const s=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getTransactionIntent:async(t,n,s={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getTransactionIntents:async(t,n,s,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==n&&(R.skip=n),void 0!==s&&(R.order=s),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,n,s={})=>{o("signature","id",t),o("signature","signatureRequest",n);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await s.createTransactionIntent(a,i,o);return l(r,e,n,t)},async estimateTransactionIntentCost(a,i){const o=await s.estimateTransactionIntentCost(a,i);return l(o,e,n,t)},async getTransactionIntent(a,i,o){const r=await s.getTransactionIntent(a,i,o);return l(r,e,n,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await s.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,n,t)},async signature(a,i,o){const r=await s.signature(a,i,o);return l(r,e,n,t)}}};class T extends s{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};class b{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(n){const s=e.create();t(s,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:n.basePath,accessToken:n.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,s),this.accountsApi=new y(this.config.backend,void 0,s),this.sessionsApi=new P(this.config.backend,void 0,s),this.authenticationApi=new w(this.config.backend,void 0,s)}}export{b as BackendApiClients,f as createConfig};
|
|
1
|
+
import e from"axios";import t from"axios-retry";const n="https://api.openfort.io".replace(/\/+$/,"");class s{basePath;axios;configuration;constructor(t,s=n,a=e){this.basePath=s,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,n){if(null==n)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const n="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+n}};function c(e,t,n=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,n)):Object.keys(t).forEach(s=>c(e,t[s],`${n}${""!==n?".":""}${s}`)):e.has(n)?e.append(n,t):e.set(n,t))}const h=function(e,...t){const n=new URLSearchParams(e.search);c(n,t),e.search=n.toString()},u=function(e,t,n){const s="string"!=typeof e;return(s&&n&&n.isJsonMime?n.isJsonMime(t.headers["Content-Type"]):s)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,n,s){return(a=t,i=n)=>{const o={...e.options,url:(s?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const s=function(e){return{cancelTransferOwnership:async(t,n,s={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",n);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},completeRecovery:async(t,n,s={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",n);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},createAccount:async(t,n={})=>{o("createAccount","createAccountRequest",t);const s=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},deployAccount:async(t,n,s={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",n);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},disableAccount:async(t,n={})=>{o("disableAccount","id",t);const s="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccount:async(t,n,s={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getAccountV2:async(t,n={})=>{o("getAccountV2","id",t);const s="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccounts:async(t,n,s,a,o,c,u,l={})=>{const p=new URL("/v1/accounts",i);let y;e&&(y=e.baseOptions);const g={method:"GET",...y,...l},w={},m={};await r(w,e),void 0!==t&&(m.limit=t),void 0!==n&&(m.skip=n),void 0!==s&&(m.order=s),void 0!==a&&(m.chainId=a),void 0!==o&&(m.player=o),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let P=y&&y.headers?y.headers:{};return g.headers={...w,...P,...l.headers},{url:d(p),options:g}},getAccountsV2:async(t,n,s,a,o,c,u,l,p={})=>{const y=new URL("/v2/accounts",i);let g;e&&(g=e.baseOptions);const w={method:"GET",...g,...p},m={},P={};await r(m,e),void 0!==t&&(P.limit=t),void 0!==n&&(P.skip=n),void 0!==s&&(P.order=s),void 0!==a&&(P.chainId=a),void 0!==o&&(P.user=o),void 0!==c&&(P.chainType=c),void 0!==u&&(P.accountType=u),void 0!==l&&(P.address=l),h(y,P);let R=g&&g.headers?g.headers:{};return w.headers={...m,...R,...p.headers},{url:d(y),options:w}},getSignerIdByAddress:async(t,n={})=>{o("getSignerIdByAddress","address",t);const s=new URL("/v2/accounts/signer",i);let a;e&&(a=e.baseOptions);const c={method:"GET",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.address=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},requestTransferOwnership:async(t,n,s={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",n);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},signPayload:async(t,n,s={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",n);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},startRecovery:async(t,n,s={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",n);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},switchChainV2:async(t,n={})=>{o("switchChainV2","switchChainQueriesV2",t);const s=new URL("/v2/accounts/switch-chain",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},syncAccount:async(t,n={})=>{o("syncAccount","id",t);const s="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await s.cancelTransferOwnership(a,i,o);return l(r,e,n,t)},async completeRecovery(a,i,o){const r=await s.completeRecovery(a,i,o);return l(r,e,n,t)},async createAccount(a,i){const o=await s.createAccount(a,i);return l(o,e,n,t)},async deployAccount(a,i,o){const r=await s.deployAccount(a,i,o);return l(r,e,n,t)},async disableAccount(a,i){const o=await s.disableAccount(a,i);return l(o,e,n,t)},async getAccount(a,i,o){const r=await s.getAccount(a,i,o);return l(r,e,n,t)},async getAccountV2(a,i){const o=await s.getAccountV2(a,i);return l(o,e,n,t)},async getAccounts(a,i,o,r,c,h,u,d){const p=await s.getAccounts(a,i,o,r,c,h,u,d);return l(p,e,n,t)},async getAccountsV2(a,i,o,r,c,h,u,d,p){const y=await s.getAccountsV2(a,i,o,r,c,h,u,d,p);return l(y,e,n,t)},async getSignerIdByAddress(a,i){const o=await s.getSignerIdByAddress(a,i);return l(o,e,n,t)},async requestTransferOwnership(a,i,o){const r=await s.requestTransferOwnership(a,i,o);return l(r,e,n,t)},async signPayload(a,i,o){const r=await s.signPayload(a,i,o);return l(r,e,n,t)},async startRecovery(a,i,o){const r=await s.startRecovery(a,i,o);return l(r,e,n,t)},async switchChainV2(a,i){const o=await s.switchChainV2(a,i);return l(o,e,n,t)},async syncAccount(a,i){const o=await s.syncAccount(a,i);return l(o,e,n,t)}}};class y extends s{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.id,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.chainId,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountsV2(e={},t){return p(this.configuration).getAccountsV2(e.limit,e.skip,e.order,e.chainId,e.user,e.chainType,e.accountType,e.address,t).then(e=>e(this.axios,this.basePath))}getSignerIdByAddress(e,t){return p(this.configuration).getSignerIdByAddress(e.address,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}switchChainV2(e,t){return p(this.configuration).switchChainV2(e.switchChainQueriesV2,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const s=function(e){return{authenticateSIWE:async(t,n={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getJwks:async(t,n={})=>{o("getJwks","publishableKey",t);const s="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},initOAuth:async(t,n,s={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,n,s={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,n,s={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,n,s={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,n={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},linkThirdParty:async(t,n,s={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,n,s={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,n,s={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,n={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const s=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},logout:async(t,n={})=>{o("logout","logoutRequest",t);const s=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},me:async(t={})=>{const n=new URL("/iam/v1/me",i);let s;e&&(s=e.baseOptions);const a={method:"GET",...s,...t};h(n,{});let o=s&&s.headers?s.headers:{};return a.headers={...o,...t.headers},{url:d(n),options:a}},poolOAuth:async(t,n={})=>{o("poolOAuth","key",t);const s=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},refresh:async(t,n={})=>{o("refresh","refreshTokenRequest",t);const s=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},registerGuest:async(t,n={})=>{const s=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...n},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(s,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...n.headers},{url:d(s),options:o}},requestEmailVerification:async(t,n={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const s=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},requestResetPassword:async(t,n={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const s=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},resetPassword:async(t,n={})=>{o("resetPassword","resetPasswordRequest",t);const s=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},signupEmailPassword:async(t,n,s={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,n,s={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,n={})=>{o("unlinkEmail","unlinkEmailRequest",t);const s=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkOAuth:async(t,n={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const s=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkSIWE:async(t,n={})=>{o("unlinkSIWE","sIWERequest",t);const s=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},verifyEmail:async(t,n={})=>{o("verifyEmail","verifyEmailRequest",t);const s=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},verifyOAuthToken:async(t,n={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const s=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await s.authenticateSIWE(a,i);return l(o,e,n,t)},async getJwks(a,i){const o=await s.getJwks(a,i);return l(o,e,n,t)},async initOAuth(a,i,o){const r=await s.initOAuth(a,i,o);return l(r,e,n,t)},async initSIWE(a,i,o){const r=await s.initSIWE(a,i,o);return l(r,e,n,t)},async linkEmail(a,i,o){const r=await s.linkEmail(a,i,o);return l(r,e,n,t)},async linkOAuth(a,i,o){const r=await s.linkOAuth(a,i,o);return l(r,e,n,t)},async linkSIWE(a,i){const o=await s.linkSIWE(a,i);return l(o,e,n,t)},async linkThirdParty(a,i,o){const r=await s.linkThirdParty(a,i,o);return l(r,e,n,t)},async loginEmailPassword(a,i,o){const r=await s.loginEmailPassword(a,i,o);return l(r,e,n,t)},async loginOIDC(a,i,o){const r=await s.loginOIDC(a,i,o);return l(r,e,n,t)},async loginWithIdToken(a,i){const o=await s.loginWithIdToken(a,i);return l(o,e,n,t)},async logout(a,i){const o=await s.logout(a,i);return l(o,e,n,t)},async me(a){const i=await s.me(a);return l(i,e,n,t)},async poolOAuth(a,i){const o=await s.poolOAuth(a,i);return l(o,e,n,t)},async refresh(a,i){const o=await s.refresh(a,i);return l(o,e,n,t)},async registerGuest(a,i){const o=await s.registerGuest(a,i);return l(o,e,n,t)},async requestEmailVerification(a,i){const o=await s.requestEmailVerification(a,i);return l(o,e,n,t)},async requestResetPassword(a,i){const o=await s.requestResetPassword(a,i);return l(o,e,n,t)},async resetPassword(a,i){const o=await s.resetPassword(a,i);return l(o,e,n,t)},async signupEmailPassword(a,i,o){const r=await s.signupEmailPassword(a,i,o);return l(r,e,n,t)},async thirdParty(a,i,o){const r=await s.thirdParty(a,i,o);return l(r,e,n,t)},async unlinkEmail(a,i){const o=await s.unlinkEmail(a,i);return l(o,e,n,t)},async unlinkOAuth(a,i){const o=await s.unlinkOAuth(a,i);return l(o,e,n,t)},async unlinkSIWE(a,i){const o=await s.unlinkSIWE(a,i);return l(o,e,n,t)},async verifyEmail(a,i){const o=await s.verifyEmail(a,i);return l(o,e,n,t)},async verifyOAuthToken(a,i){const o=await s.verifyOAuthToken(a,i);return l(o,e,n,t)}}};class w extends s{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const s=function(e){return{createSession:async(t,n,s={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,n,s,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==n&&(w.limit=n),void 0!==s&&(w.skip=s),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,n,s={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},revokeSession:async(t,n,s={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,n,s={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",n);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await s.createSession(a,i,o);return l(r,e,n,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await s.getPlayerSessions(a,i,o,r,c,h);return l(u,e,n,t)},async getSession(a,i,o){const r=await s.getSession(a,i,o);return l(r,e,n,t)},async revokeSession(a,i,o){const r=await s.revokeSession(a,i,o);return l(r,e,n,t)},async signatureSession(a,i,o){const r=await s.signatureSession(a,i,o);return l(r,e,n,t)}}};class P extends s{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const s=function(e){return{createTransactionIntent:async(t,n,s={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,n={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const s=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getTransactionIntent:async(t,n,s={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getTransactionIntents:async(t,n,s,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==n&&(R.skip=n),void 0!==s&&(R.order=s),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,n,s={})=>{o("signature","id",t),o("signature","signatureRequest",n);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await s.createTransactionIntent(a,i,o);return l(r,e,n,t)},async estimateTransactionIntentCost(a,i){const o=await s.estimateTransactionIntentCost(a,i);return l(o,e,n,t)},async getTransactionIntent(a,i,o){const r=await s.getTransactionIntent(a,i,o);return l(r,e,n,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await s.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,n,t)},async signature(a,i,o){const r=await s.signature(a,i,o);return l(r,e,n,t)}}};class T extends s{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};class b{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(n){const s=e.create();t(s,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:n.basePath,accessToken:n.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,s),this.accountsApi=new y(this.config.backend,void 0,s),this.sessionsApi=new P(this.config.backend,void 0,s),this.authenticationApi=new w(this.config.backend,void 0,s)}}export{b as BackendApiClients,f as createConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BackendApiClients as e}from"../../../packages/internal/openapi-clients/dist/index.js";import{PasskeyHandler as r}from"../core/configuration/passkey.js";import{SDKConfiguration as t}from"../core/config/config.js";import{Account as a}from"../core/configuration/account.js";import{Authentication as s}from"../core/configuration/authentication.js";import{OpenfortError as i,OpenfortErrorType as n,withOpenfortError as o}from"../core/errors/openfortError.js";import{OpenfortEvents as d,RecoveryMethod as c,AccountTypeEnum as h,ChainTypeEnum as y,EmbeddedState as g}from"../types/types.js";import{debugLog as p}from"../utils/debug.js";import{EmbeddedSigner as m}from"../wallets/embedded.js";import{EvmProvider as l}from"../wallets/evm/evmProvider.js";import"../wallets/evm/types.js";import{announceProvider as f,openfortProviderInfo as u}from"../wallets/evm/provider/eip6963.js";import{signMessage as A}from"../wallets/evm/walletHelpers.js";import{IframeManager as w}from"../wallets/iframeManager.js";import{ReactNativeMessenger as I}from"../wallets/messaging/ReactNativeMessenger.js";import"../wallets/messaging/browserMessenger/backwardCompatibility.js";import v from"../wallets/messaging/browserMessenger/messengers/WindowMessenger.js";class M{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;passkeyHandler;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,a,s){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=a,this.passkeyHandler=s,this.eventEmitter.on(d.LOGGED_OUT,()=>{p("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=t.getInstance();if(!r)throw new i("Configuration not found",n.INVALID_CONFIGURATION);return new e({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey})}async getIframeManager(){if(p("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return p("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return p("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;p("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return p("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,p("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw p("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){p("[HANDSHAKE DEBUG] createIframeManager starting");const e=t.getInstance();if(!e)throw p("[HANDSHAKE DEBUG] Configuration not found"),new i("Configuration not found",n.INVALID_CONFIGURATION);let r;if(p("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)p("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new I(this.messagePoster),p("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),r=this.messenger;else{p("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const t=this.createIframe(e.iframeUrl),a=new URL(e.iframeUrl).origin;r=new v({remoteWindow:t.contentWindow,allowedOrigins:[a]}),p("[HANDSHAKE DEBUG] Created WindowMessenger")}return p("[HANDSHAKE DEBUG] Creating IframeManager instance"),new w(e,this.storage,r)}async ensureSigner(){if(this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager();return new m(e,this.storage,this.backendApiClients,this.passkeyHandler,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new i("Document is not available. Please provide a message poster for non-browser environments.",n.INVALID_CONFIGURATION);const r=document.getElementById("openfort-iframe");r&&r.remove();const t=document.createElement("iframe");return t.style.display="none",t.id="openfort-iframe",t.src=e,document.body.appendChild(t),t}async getPasskeyKey(e){const r=await s.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:r.player})}async getEntropy(e){switch(e.recoveryMethod){case c.PASSWORD:return{recoveryPassword:e.password};case c.AUTOMATIC:return{encryptionSession:e.encryptionSession};case c.PASSKEY:return{passkey:e.passkeyInfo?{id:e.passkeyInfo.passkeyId,env:e.passkeyInfo.passkeyEnv,key:e.passkeyInfo.passkeyKey||await this.getPasskeyKey(e.passkeyInfo.passkeyId)}:{}};default:throw new i("Invalid recovery method",n.INVALID_CONFIGURATION)}}async configure(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:c.AUTOMATIC},[t,i,n]=await Promise.all([s.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(r)]),o={chainId:e.chainId,entropy:n,accountType:e.accountType??h.SMART_ACCOUNT,chainType:e.chainType??y.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},d=await i.configure(o);return{id:d.id,chainId:d.chainId,user:t.player,address:d.address,ownerAddress:d.ownerAddress,chainType:d.chainType,accountType:d.accountType,implementationType:d.implementationType,createdAt:d.createdAt,recoveryMethod:a.parseRecoveryMethod(d.recoveryMethod),recoveryMethodDetails:d.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:c.AUTOMATIC},o=await s.fromStorage(this.storage);if(!o)throw new i("missing authentication",n.AUTHENTICATION_ERROR);if(t.recoveryMethod===c.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:o?.player});t.passkeyInfo={passkeyId:e.id,passkeyKey:e.key}}const[d,h]=await Promise.all([this.ensureSigner(),this.getEntropy(t)]),y=await d.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:h});return{id:y.id,chainId:y.chainId,user:o.player,address:y.address,ownerAddress:y.ownerAddress,chainType:y.chainType,accountType:y.accountType,implementationType:y.implementationType,createdAt:y.createdAt,recoveryMethod:a.parseRecoveryMethod(y.recoveryMethod),recoveryMethodDetails:y.recoveryMethodDetails}}async recover(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:c.AUTOMATIC};if(r.recoveryMethod===c.PASSKEY){if(!r.passkeyInfo?.passkeyId)throw new i("Passkey ID must be provided for passkey recovery",n.INVALID_CONFIGURATION);r.passkeyInfo={passkeyId:r.passkeyInfo.passkeyId,passkeyEnv:r.passkeyInfo.passkeyEnv}}const[t,o,d]=await Promise.all([this.ensureSigner(),this.getEntropy(r),s.fromStorage(this.storage)]),h=await t.recover({account:e.account,entropy:o});return{id:h.id,chainId:h.chainId,user:d.player,address:h.address,ownerAddress:h.ownerAddress,chainType:h.chainType,accountType:h.accountType,implementationType:h.implementationType,createdAt:h.createdAt,recoveryMethod:a.parseRecoveryMethod(h.recoveryMethod),recoveryMethodDetails:h.recoveryMethodDetails}}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:s=!0,arrayifyMessage:i=!1}=r||{},n=await a.fromStorage(this.storage);return await t.sign(e,i,s,n?.chainType)}async signTypedData(e,r,t){await this.validateAndRefreshToken();const s=await this.ensureSigner(),o=await a.fromStorage(this.storage);if(!o)throw new i("No account found",n.MISSING_SIGNER_ERROR);const d={...r};delete d.EIP712Domain;const{_TypedDataEncoder:c}=await import("@ethersproject/hash"),h=c.hash(e,d,t);return await A({hash:h,implementationType:o.implementationType||o.type,chainId:Number(o.chainId),signer:s,address:o.address,ownerAddress:o.ownerAddress,factoryAddress:o.factoryAddress,salt:o.salt})}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setRecoveryMethod(e,t){await this.validateAndRefreshToken();const o=await this.ensureSigner(),d=await s.fromStorage(this.storage);if(!d)throw new i("missing authentication",n.AUTHENTICATION_ERROR);let h,y,g,p;if(e.recoveryMethod===c.PASSKEY){const e=await a.fromStorage(this.storage);if(!e)throw new i("missing account",n.INVALID_CONFIGURATION);const r=e?.recoveryMethodDetails?.passkeyId;if(!r)throw new i("missing passkey id for account",n.INVALID_CONFIGURATION);g={passkeyId:r,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:r,seed:d.player})}}else if(t.recoveryMethod===c.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:d.player});g={passkeyId:e.id,passkeyKey:e.key},p={passkeyId:e.id}}if(e.recoveryMethod===c.PASSWORD?h=e.password:t.recoveryMethod===c.PASSWORD&&(h=t.password),e.recoveryMethod===c.AUTOMATIC?y=e.encryptionSession:t.recoveryMethod===c.AUTOMATIC&&(y=t.encryptionSession),!h&&!y)throw new i("Password or encryption session is not provided",n.INVALID_CONFIGURATION);await o.setRecoveryMethod({recoveryMethod:t.recoveryMethod,recoveryPassword:h,encryptionSession:y,passkeyInfo:g});const m=await a.fromStorage(this.storage);m&&new a({...m,recoveryMethod:t.recoveryMethod,recoveryMethodDetails:p}).save(this.storage)}async get(){const e=await a.fromStorage(this.storage);if(!e)throw new i("No signer configured",n.MISSING_SIGNER_ERROR);const r=await s.fromStorage(this.storage);if(!r)throw new i("No access token found",n.NOT_LOGGED_IN_ERROR);return{id:e.id,chainId:e.chainId,user:r.player,address:e.address,ownerAddress:e.ownerAddress,chainType:e.chainType,accountType:e.accountType,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:a.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const r={accountType:h.SMART_ACCOUNT,...e},d=t.getInstance();if(!d)throw new i("Configuration not found",n.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const c=await s.fromStorage(this.storage);if(!c)throw new i("No access token found",n.NOT_LOGGED_IN_ERROR);return o(async()=>(await this.backendApiClients.accountsApi.getAccountsV2(r,{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}})).data.data.map(e=>({user:e.user,chainType:e.chainType,id:e.id,address:e.address,ownerAddress:e.ownerAddress,accountType:e.accountType,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:a.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{default:n.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await s.fromStorage(this.storage))return g.UNAUTHENTICATED;return await a.fromStorage(this.storage)?g.READY:g.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return p("Failed to get embedded state:",e),g.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},t=await s.fromStorage(this.storage),i=await a.fromStorage(this.storage);return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new l({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:i||void 0,authentication:t||void 0,backendApiClients:this.backendApiClients,policyId:r.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:r.chains}),r.announceProvider&&f({info:{...u,...r.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(r=>{setTimeout(r,e)});const r=await this.getIframeManager();if(!r.isLoaded())return!1;const t=await s.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return p("Ping failed:",e),!1}}getURL(){const e=t.getInstance();if(!e)throw new i("Configuration not found",n.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new i("Invalid message poster",n.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&this.messenger.destroy(),this.iframeManager&&this.iframeManager.destroy(),this.signer=null,this.signerPromise=null,this.iframeManager=null,this.iframeManagerPromise=null,this.messenger=null}async handleLogout(){const e=await this.ensureSigner();await e.disconnect(),this.provider=null,this.messenger=null,this.iframeManager=null,this.iframeManagerPromise=null,this.signer=null,this.signerPromise=null}async onMessage(e){if(!e||"object"!=typeof e)return void p("Invalid message received:",e);p("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const r="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(r&&this.messenger&&this.messagePoster)return p("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const t=await this.getIframeManager();p(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${t.isLoaded()}`),r&&!t.isLoaded()&&p("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),p("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await t.onMessage(e),p("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}}export{M as EmbeddedWalletApi};
|
|
1
|
+
import{BackendApiClients as e}from"../../../packages/internal/openapi-clients/dist/index.js";import{PasskeyHandler as r}from"../core/configuration/passkey.js";import{SDKConfiguration as t}from"../core/config/config.js";import{Account as a}from"../core/configuration/account.js";import{Authentication as s}from"../core/configuration/authentication.js";import{OpenfortError as i,OpenfortErrorType as n,withOpenfortError as o}from"../core/errors/openfortError.js";import{OpenfortEvents as d,RecoveryMethod as c,AccountTypeEnum as h,ChainTypeEnum as y,EmbeddedState as g}from"../types/types.js";import{debugLog as m}from"../utils/debug.js";import{EmbeddedSigner as p}from"../wallets/embedded.js";import{EvmProvider as l}from"../wallets/evm/evmProvider.js";import"../wallets/evm/types.js";import{announceProvider as f,openfortProviderInfo as u}from"../wallets/evm/provider/eip6963.js";import{signMessage as A}from"../wallets/evm/walletHelpers.js";import{IframeManager as w}from"../wallets/iframeManager.js";import{ReactNativeMessenger as I}from"../wallets/messaging/ReactNativeMessenger.js";import"../wallets/messaging/browserMessenger/backwardCompatibility.js";import v from"../wallets/messaging/browserMessenger/messengers/WindowMessenger.js";class M{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;passkeyHandler;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,a,s){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=a,this.passkeyHandler=s,this.eventEmitter.on(d.LOGGED_OUT,()=>{m("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=t.getInstance();if(!r)throw new i("Configuration not found",n.INVALID_CONFIGURATION);return new e({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey})}async getIframeManager(){if(m("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return m("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return m("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;m("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return m("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,m("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw m("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){m("[HANDSHAKE DEBUG] createIframeManager starting");const e=t.getInstance();if(!e)throw m("[HANDSHAKE DEBUG] Configuration not found"),new i("Configuration not found",n.INVALID_CONFIGURATION);let r;if(m("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)m("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new I(this.messagePoster),m("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),r=this.messenger;else{m("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const t=this.createIframe(e.iframeUrl),a=new URL(e.iframeUrl).origin;r=new v({remoteWindow:t.contentWindow,allowedOrigins:[a]}),m("[HANDSHAKE DEBUG] Created WindowMessenger")}return m("[HANDSHAKE DEBUG] Creating IframeManager instance"),new w(e,this.storage,r)}async ensureSigner(){if(this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager();return new p(e,this.storage,this.backendApiClients,this.passkeyHandler,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new i("Document is not available. Please provide a message poster for non-browser environments.",n.INVALID_CONFIGURATION);const r=document.getElementById("openfort-iframe");r&&r.remove();const t=document.createElement("iframe");return t.style.display="none",t.id="openfort-iframe",t.src=e,document.body.appendChild(t),t}async getPasskeyKey(e){const r=await s.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:r.player})}async getEntropy(e){switch(e.recoveryMethod){case c.PASSWORD:return{recoveryPassword:e.password};case c.AUTOMATIC:return{encryptionSession:e.encryptionSession};case c.PASSKEY:return{passkey:e.passkeyInfo?{id:e.passkeyInfo.passkeyId,key:e.passkeyInfo.passkeyKey||await this.getPasskeyKey(e.passkeyInfo.passkeyId)}:{}};default:throw new i("Invalid recovery method",n.INVALID_CONFIGURATION)}}async configure(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:c.AUTOMATIC},[t,i,n]=await Promise.all([s.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(r)]),o={chainId:e.chainId,entropy:n,accountType:e.accountType??h.SMART_ACCOUNT,chainType:e.chainType??y.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},d=await i.configure(o);return{id:d.id,chainId:d.chainId,user:t.player,address:d.address,ownerAddress:d.ownerAddress,chainType:d.chainType,accountType:d.accountType,implementationType:d.implementationType,createdAt:d.createdAt,recoveryMethod:a.parseRecoveryMethod(d.recoveryMethod),recoveryMethodDetails:d.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:c.AUTOMATIC},o=await s.fromStorage(this.storage);if(!o)throw new i("missing authentication",n.AUTHENTICATION_ERROR);if(t.recoveryMethod===c.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:o?.player});t.passkeyInfo={passkeyId:e.id,passkeyKey:e.key}}const[d,h]=await Promise.all([this.ensureSigner(),this.getEntropy(t)]),y=await d.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:h});return{id:y.id,chainId:y.chainId,user:o.player,address:y.address,ownerAddress:y.ownerAddress,chainType:y.chainType,accountType:y.accountType,implementationType:y.implementationType,createdAt:y.createdAt,recoveryMethod:a.parseRecoveryMethod(y.recoveryMethod),recoveryMethodDetails:y.recoveryMethodDetails}}async recover(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:c.AUTOMATIC};if(r.recoveryMethod===c.PASSKEY){if(!r.passkeyInfo?.passkeyId)throw new i("Passkey ID must be provided for passkey recovery",n.INVALID_CONFIGURATION);r.passkeyInfo={passkeyId:r.passkeyInfo.passkeyId}}const[t,o,d]=await Promise.all([this.ensureSigner(),this.getEntropy(r),s.fromStorage(this.storage)]),h=await t.recover({account:e.account,entropy:o});return{id:h.id,chainId:h.chainId,user:d.player,address:h.address,ownerAddress:h.ownerAddress,chainType:h.chainType,accountType:h.accountType,implementationType:h.implementationType,createdAt:h.createdAt,recoveryMethod:a.parseRecoveryMethod(h.recoveryMethod),recoveryMethodDetails:h.recoveryMethodDetails}}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:s=!0,arrayifyMessage:i=!1}=r||{},n=await a.fromStorage(this.storage);return await t.sign(e,i,s,n?.chainType)}async signTypedData(e,r,t){await this.validateAndRefreshToken();const s=await this.ensureSigner(),o=await a.fromStorage(this.storage);if(!o)throw new i("No account found",n.MISSING_SIGNER_ERROR);const d={...r};delete d.EIP712Domain;const{_TypedDataEncoder:c}=await import("@ethersproject/hash"),h=c.hash(e,d,t);return await A({hash:h,implementationType:o.implementationType||o.type,chainId:Number(o.chainId),signer:s,address:o.address,ownerAddress:o.ownerAddress,factoryAddress:o.factoryAddress,salt:o.salt})}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setRecoveryMethod(e,t){await this.validateAndRefreshToken();const o=await this.ensureSigner(),d=await s.fromStorage(this.storage);if(!d)throw new i("missing authentication",n.AUTHENTICATION_ERROR);let h,y,g,m;if(e.recoveryMethod===c.PASSKEY){const e=await a.fromStorage(this.storage);if(!e)throw new i("missing account",n.INVALID_CONFIGURATION);const r=e?.recoveryMethodDetails?.passkeyId;if(!r)throw new i("missing passkey id for account",n.INVALID_CONFIGURATION);g={passkeyId:r,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:r,seed:d.player})}}else if(t.recoveryMethod===c.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:d.player});g={passkeyId:e.id,passkeyKey:e.key},m={passkeyId:e.id}}if(e.recoveryMethod===c.PASSWORD?h=e.password:t.recoveryMethod===c.PASSWORD&&(h=t.password),e.recoveryMethod===c.AUTOMATIC?y=e.encryptionSession:t.recoveryMethod===c.AUTOMATIC&&(y=t.encryptionSession),!h&&!y)throw new i("Password or encryption session is not provided",n.INVALID_CONFIGURATION);await o.setRecoveryMethod({recoveryMethod:t.recoveryMethod,recoveryPassword:h,encryptionSession:y,passkeyInfo:g});const p=await a.fromStorage(this.storage);p&&new a({...p,recoveryMethod:t.recoveryMethod,recoveryMethodDetails:m}).save(this.storage)}async get(){const e=await a.fromStorage(this.storage);if(!e)throw new i("No signer configured",n.MISSING_SIGNER_ERROR);const r=await s.fromStorage(this.storage);if(!r)throw new i("No access token found",n.NOT_LOGGED_IN_ERROR);return{id:e.id,chainId:e.chainId,user:r.player,address:e.address,ownerAddress:e.ownerAddress,chainType:e.chainType,accountType:e.accountType,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:a.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const r={accountType:h.SMART_ACCOUNT,...e},d=t.getInstance();if(!d)throw new i("Configuration not found",n.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const c=await s.fromStorage(this.storage);if(!c)throw new i("No access token found",n.NOT_LOGGED_IN_ERROR);return o(async()=>(await this.backendApiClients.accountsApi.getAccountsV2(r,{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}})).data.data.map(e=>({user:e.user,chainType:e.chainType,id:e.id,address:e.address,ownerAddress:e.ownerAddress,accountType:e.accountType,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:a.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{default:n.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await s.fromStorage(this.storage))return g.UNAUTHENTICATED;return await a.fromStorage(this.storage)?g.READY:g.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return m("Failed to get embedded state:",e),g.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},t=await s.fromStorage(this.storage),i=await a.fromStorage(this.storage);return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new l({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:i||void 0,authentication:t||void 0,backendApiClients:this.backendApiClients,policyId:r.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:r.chains}),r.announceProvider&&f({info:{...u,...r.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(r=>{setTimeout(r,e)});const r=await this.getIframeManager();if(!r.isLoaded())return!1;const t=await s.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return m("Ping failed:",e),!1}}getURL(){const e=t.getInstance();if(!e)throw new i("Configuration not found",n.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new i("Invalid message poster",n.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&this.messenger.destroy(),this.iframeManager&&this.iframeManager.destroy(),this.signer=null,this.signerPromise=null,this.iframeManager=null,this.iframeManagerPromise=null,this.messenger=null}async handleLogout(){const e=await this.ensureSigner();await e.disconnect(),this.provider=null,this.messenger=null,this.iframeManager=null,this.iframeManagerPromise=null,this.signer=null,this.signerPromise=null}async onMessage(e){if(!e||"object"!=typeof e)return void m("Invalid message received:",e);m("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const r="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(r&&this.messenger&&this.messagePoster)return m("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const t=await this.getIframeManager();m(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${t.isLoaded()}`),r&&!t.isLoaded()&&m("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),m("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await t.onMessage(e),m("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}}export{M as EmbeddedWalletApi};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AxiosError as t}from"axios";import{PACKAGE as
|
|
1
|
+
import{AxiosError as t}from"axios";import{PACKAGE as s,VERSION as e}from"../../version.js";const r="https://64a03e4967fb4dad3ecb914918c777b6@o4504593015242752.ingest.us.sentry.io/4509292415287296";class n{static sentryInstance;static queuedCalls=[];static baseTags;static set sentry(s){const e=s.getDsn();if(!e)throw new Error("Sentry DSN is not set");if(e.projectId!==r.split("https://")[1].split("/")[1]||e.host!==r.split("@")[1].split("/")[0]||e.publicKey!==r.split("@")[0].split("https://")[1])throw new Error("Sentry DSN is not valid");s.captureAxiosError=(e,r,a,o)=>{if(r instanceof t){if(400===r.response?.status||401===r.response?.status)return;r.name=e,s.captureException(r,{...a,captureContext:{...a?.captureContext,extra:{errorResponseData:r.response?.data,errorStatus:r.response?.status,errorHeaders:r.response?.headers,errorRequest:r.request},tags:{...n.baseTags,method:e}}})}else s.captureException(r,a,o)},n.sentryInstance=s}static get sentry(){return n.proxy}static async init({sentry:t,configuration:a}){if(t)return void(n.sentry=t);const o=await import("@sentry/browser");n.sentry=new o.BrowserClient({dsn:r,integrations:[],stackParser:o.defaultStackParser,transport:o.makeFetchTransport}),n.baseTags={projectId:a?.baseConfiguration.publishableKey,sdk:s,sdkVersion:e},n.processQueuedCalls()}static proxy=new Proxy({},{get:(t,s)=>n.sentryInstance&&"function"==typeof n.sentryInstance[s]?(...t)=>n.sentryInstance[s](...t):(...t)=>{n.queuedCalls.push({fn:s,args:t})}});static processQueuedCalls(){n.sentryInstance&&(n.queuedCalls.forEach(({fn:t,args:s})=>{"function"==typeof n.sentryInstance[t]&&n.sentryInstance[t](...s)}),n.queuedCalls=[])}}const{sentry:a}=n;export{n as InternalSentry,a as sentry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var E,A,_,n,
|
|
1
|
+
var E,A,_,e,n,o,a,c,t,C,T,O,R,N;!function(E){E[E.NONE=0]="NONE",E[E.UNAUTHENTICATED=1]="UNAUTHENTICATED",E[E.EMBEDDED_SIGNER_NOT_CONFIGURED=2]="EMBEDDED_SIGNER_NOT_CONFIGURED",E[E.CREATING_ACCOUNT=3]="CREATING_ACCOUNT",E[E.READY=4]="READY"}(E||(E={})),function(E){E.LOGGED_OUT="loggedOut",E.SWITCH_ACCOUNT="switchAccount"}(A||(A={})),function(E){E.PASSWORD="password",E.AUTOMATIC="automatic",E.PASSKEY="passkey"}(_||(_={})),function(E){E.UPGRADEABLE_V4="Upgradeable_v04",E.MANAGED_V4="Managed_v04",E.ERC6551_V4="ERC6551_v04",E.ERC6551_V5="ERC6551_v05",E.RECOVERABLE_V4="Recoverable_v04",E.MANAGED_V5="Managed_v05",E.UPGRADEABLE_V5="Upgradeable_v05",E.UPGRADEABLE_V6="Upgradeable_v06",E.ZKSYNC_UPGRADEABLE_V1="zksync_upgradeable_v1",E.ZKSYNC_UPGRADEABLE_V2="zksync_upgradeable_v2"}(e||(e={})),function(E){E.OPENFORT="openfort",E.THIRD_PARTY="thirdParty"}(n||(n={})),function(E){E.ID_TOKEN="idToken",E.CUSTOM_TOKEN="customToken"}(o||(o={})),function(E){E.ACCELBYTE="accelbyte",E.FIREBASE="firebase",E.LOOTLOCKER="lootlocker",E.PLAYFAB="playfab",E.SUPABASE="supabase",E.CUSTOM="custom",E.OIDC="oidc"}(a||(a={})),function(E){E.EMAIL="email",E.WALLET="wallet"}(c||(c={})),function(E){E.GOOGLE="google",E.TWITTER="twitter",E.APPLE="apple",E.FACEBOOK="facebook",E.DISCORD="discord",E.EPIC_GAMES="epic_games",E.LINE="line"}(t||(t={})),function(E){E.ACTION_VERIFY_EMAIL="verify_email"}(C||(C={})),function(E){E.S256="S256"}(T||(T={})),function(E){E.EOA="Externally Owned Account",E.SMART_ACCOUNT="Smart Account"}(O||(O={})),function(E){E.EVM="EVM",E.SVM="SVM"}(R||(R={})),function(E){E.ASC="asc",E.DESC="desc"}(N||(N={}));export{e as AccountType,O as AccountTypeEnum,C as AuthActionRequiredActions,n as AuthType,c as BasicAuthProvider,R as ChainTypeEnum,T as CodeChallengeMethodEnum,E as EmbeddedState,t as OAuthProvider,A as OpenfortEvents,_ as RecoveryMethod,a as ThirdPartyAuthProvider,o as TokenType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t={1:"https://cloudflare-eth.com",10:"https://optimism-rpc.publicnode.com",56:"https://bsc.publicnode.com",97:"https://bsc-testnet.publicnode.com",137:"https://polygon-rpc.com",204:"https://opbnb-mainnet-rpc.bnbchain.org",300:"https://sepolia.era.zksync.dev",324:"https://mainnet.era.zksync.io",1946:"https://rpc.minato.soneium.org",2741:"https://api.mainnet.abs.xyz",3939:"https://test.doschain.com",4337:"https://build.onbeam.com/rpc",5611:"https://opbnb-testnet-rpc.bnbchain.org",7979:"https://main.doschain.com",8453:"https://mainnet.base.org",11124:"https://api.testnet.abs.xyz",13337:"https://build.onbeam.com/rpc/testnet",13473:"https://rpc.testnet.immutable.com",42161:"https://arb1.arbitrum.io/rpc",42170:"https://nova.arbitrum.io/rpc",43113:"https://api.avax-test.network/ext/bc/C/rpc",43114:"https://api.avax.network/ext/bc/C/rpc",50104:"https://rpc.sophon.xyz",80002:"https://polygon-amoy-bor-rpc.publicnode.com",84532:"https://sepolia.base.org",
|
|
1
|
+
const t={1:"https://cloudflare-eth.com",10:"https://optimism-rpc.publicnode.com",56:"https://bsc.publicnode.com",97:"https://bsc-testnet.publicnode.com",137:"https://polygon-rpc.com",204:"https://opbnb-mainnet-rpc.bnbchain.org",300:"https://sepolia.era.zksync.dev",324:"https://mainnet.era.zksync.io",1946:"https://rpc.minato.soneium.org",2741:"https://api.mainnet.abs.xyz",3939:"https://test.doschain.com",4337:"https://build.onbeam.com/rpc",5611:"https://opbnb-testnet-rpc.bnbchain.org",7979:"https://main.doschain.com",8453:"https://mainnet.base.org",11124:"https://api.testnet.abs.xyz",13337:"https://build.onbeam.com/rpc/testnet",13473:"https://rpc.testnet.immutable.com",42161:"https://arb1.arbitrum.io/rpc",42170:"https://nova.arbitrum.io/rpc",43113:"https://api.avax-test.network/ext/bc/C/rpc",43114:"https://api.avax.network/ext/bc/C/rpc",50104:"https://rpc.sophon.xyz",80002:"https://polygon-amoy-bor-rpc.publicnode.com",84532:"https://sepolia.base.org",421614:"https://sepolia-rollup.arbitrum.io/rpc",7225878:"https://rpc.saakuru.network",7777777:"https://rpc.zora.energy",11155111:"https://ethereum-sepolia-rpc.publicnode.com",11155420:"https://optimism-sepolia-rpc.publicnode.com",28122024:"https://rpcv2-testnet.ancient8.gg",531050104:"https://rpc.testnet.sophon.xyz",666666666:"https://rpc.degen.tips",888888888:"https://rpc.ancient8.gg",999999999:"https://sepolia.rpc.zora.energy",85011:"https://subnets.avax.network/criminalsa/testnet/rpc",84358:"https://subnets.avax.network/titan/mainnet/rpc",10143:"https://testnet-rpc.monad.xyz",510525:"https://rpc.clankermon.com",3008:"https://kl1-testnet.kiooverse.xyz/rpc",167e3:"https://rpc.taiko.xyz"};export{t as defaultChainRpcs};
|
package/dist/sdk/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="0.10.
|
|
1
|
+
const o="0.10.24",t="@openfort/openfort-js";export{t as PACKAGE,o as VERSION};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Authentication as e}from"../core/configuration/authentication.js";import{PasskeyHandler as t}from"../core/configuration/passkey.js";import{OpenfortError as a,OpenfortErrorType as r,withOpenfortError as o}from"../core/errors/openfortError.js";import{OpenfortEvents as s}from"../types/types.js";import{SDKConfiguration as
|
|
1
|
+
import{Authentication as e}from"../core/configuration/authentication.js";import{PasskeyHandler as t}from"../core/configuration/passkey.js";import{OpenfortError as a,OpenfortErrorType as r,withOpenfortError as o}from"../core/errors/openfortError.js";import{OpenfortEvents as s,AccountTypeEnum as n}from"../types/types.js";import{SDKConfiguration as i}from"../core/config/config.js";import{Account as c}from"../core/configuration/account.js";import{StorageKeys as d}from"../storage/istorage.js";import"eventemitter3";import"./evm/JsonRpcError.js";import"./evm/types.js";import"./evm/provider/eip6963.js";import"../core/errors/sentry.js";import"./messaging/browserMessenger/backwardCompatibility.js";import"./types.js";import"jose";class y{iframeManager;storage;backendApiClients;passkeyHandler;eventEmitter;constructor(e,t,a,r,o){this.iframeManager=e,this.storage=t,this.backendApiClients=a,this.passkeyHandler=r,this.eventEmitter=o}async createPasskey(e){const a=await this.passkeyHandler.createPasskey({id:t.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:e});return{id:a.id,key:a.key}}async configure(t){const n=await e.fromStorage(this.storage);if(!n)throw new a("No access token found",r.NOT_LOGGED_IN_ERROR);const d=i.getInstance();if(!d)throw new a("Configuration not found",r.INVALID_CONFIGURATION);const y=await c.fromStorage(this.storage);let p;if(y){const e={account:y.id,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},..."passkey"===y.recoveryMethod&&{passkey:{id:y.recoveryMethodDetails?.passkeyId,env:y.recoveryMethodDetails?.passkeyEnv,key:await t.getPasskeyKeyFn(y.recoveryMethodDetails?.passkeyId)}}}}},a=await this.iframeManager.recover(e);p=a.account}else{const e=await this.backendApiClients.accountsApi.getAccountsV2({user:n.player,accountType:t.accountType,chainType:t.chainType},{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":n.token,"x-auth-provider":n.thirdPartyProvider,"x-token-type":n.thirdPartyTokenType}});if(0===e.data.data.length){const e=t.entropy?.passkey?await this.createPasskey(n.player):void 0,a={accountType:t.accountType,chainType:t.chainType,chainId:t.chainId,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},...t.entropy.passkey&&{passkey:e}}}},r=await this.iframeManager.create(a);p=r.account}else{const a=e.data.data,r=a.find(e=>e.chainId===t.chainId),o=r||a[0],s={account:o.id,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},..."passkey"===o.recoveryMethod&&{passkey:{id:o.recoveryMethodDetails?.passkeyId,env:o.recoveryMethodDetails?.passkeyEnv,key:await t.getPasskeyKeyFn(o.recoveryMethodDetails?.passkeyId)}}}}},n=await this.iframeManager.recover(s);if(p=n.account,!r){const e=await this.iframeManager.switchChain(t.chainId);p=e.account}}}return o(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:p},{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":n.token,"x-auth-provider":n.thirdPartyProvider,"x-token-type":n.thirdPartyTokenType}}),t=new c({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:c.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(s.SWITCH_ACCOUNT,e.data.address),t},{default:r.AUTHENTICATION_ERROR})}async sign(e,t,a,r){return await this.iframeManager.sign(e,t,a,r)}async export(){return await this.iframeManager.export()}async switchChain({chainId:e}){const t=await c.fromStorage(this.storage);if(t?.accountType===n.EOA)new c({...t,chainId:e}).save(this.storage);else{const a=await this.iframeManager.switchChain(e);new c({...t,id:a.account,chainId:e}).save(this.storage)}}async create(t){const n=await this.iframeManager.create(t),d=await e.fromStorage(this.storage);if(!d)throw new a("No access token found",r.NOT_LOGGED_IN_ERROR);const y=i.getInstance();if(!y)throw new a("Configuration not found",r.INVALID_CONFIGURATION);return o(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:n.account},{headers:{authorization:`Bearer ${y.baseConfiguration.publishableKey}`,"x-player-token":d.token,"x-auth-provider":d.thirdPartyProvider,"x-token-type":d.thirdPartyTokenType}}),t=new c({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:c.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(s.SWITCH_ACCOUNT,e.data.address),t},{default:r.AUTHENTICATION_ERROR})}async recover(t){const n=await this.iframeManager.recover(t),d=await e.fromStorage(this.storage);if(!d)throw new a("No access token found",r.NOT_LOGGED_IN_ERROR);const y=i.getInstance();if(!y)throw new a("Configuration not found",r.INVALID_CONFIGURATION);return o(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:n.account},{headers:{authorization:`Bearer ${y.baseConfiguration.publishableKey}`,"x-player-token":d.token,"x-auth-provider":d.thirdPartyProvider,"x-token-type":d.thirdPartyTokenType}}),t=new c({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:c.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(s.SWITCH_ACCOUNT,e.data.address),t},{default:r.AUTHENTICATION_ERROR})}async setRecoveryMethod({recoveryMethod:e,recoveryPassword:t,encryptionSession:a,passkeyInfo:r}){await this.iframeManager.setRecoveryMethod(e,t,a,r?.passkeyKey,r?.passkeyId)}async disconnect(){await this.iframeManager.disconnect(),this.storage.remove(d.ACCOUNT)}}export{y as EmbeddedSigner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var E
|
|
1
|
+
var R,E;!function(R){R[R.UNAUTHORIZED=4100]="UNAUTHORIZED",R[R.UNSUPPORTED_METHOD=4200]="UNSUPPORTED_METHOD"}(R||(R={})),function(R){R[R.INVALID_PARAMS=-32602]="INVALID_PARAMS",R[R.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",R[R.TRANSACTION_REJECTED=-32003]="TRANSACTION_REJECTED"}(E||(E={}));class A extends Error{message;code;constructor(R,E){super(E),this.message=E,this.code=R}}export{A as JsonRpcError,R as ProviderErrorCode,E as RpcErrorCode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Account as t}from"../../core/configuration/account.js";import{Authentication as e}from"../../core/configuration/authentication.js";import{OpenfortEvents as a}from"../../types/types.js";import{defaultChainRpcs as
|
|
1
|
+
import{Account as t}from"../../core/configuration/account.js";import{Authentication as e}from"../../core/configuration/authentication.js";import{OpenfortEvents as a,AccountTypeEnum as i}from"../../types/types.js";import{defaultChainRpcs as s}from"../../utils/chains/index.js";import{numberToHex as r}from"../../utils/crypto.js";import o from"../../utils/typedEventEmitter.js";import{addEthereumChain as n}from"./addEthereumChain.js";import{estimateGas as c}from"./estimateGas.js";import{getCallStatus as h}from"./getCallsStatus.js";import{JsonRpcError as d,ProviderErrorCode as p,RpcErrorCode as m}from"./JsonRpcError.js";import{personalSign as u}from"./personalSign.js";import{registerSession as w}from"./registerSession.js";import{revokeSession as l}from"./revokeSession.js";import{sendCallsSync as g}from"./sendCallSync.js";import{sendCalls as f}from"./sendCalls.js";import{signTypedDataV4 as S}from"./signTypedDataV4.js";import{ProviderEvent as A}from"./types.js";import{prepareEOATransaction as R,parseTransactionRequest as _}from"./walletHelpers.js";class y{#t;#e;#a;#i;updatePolicy(t){this.#e=t}#s;#r;#o=null;#n;isOpenfort=!0;#c;constructor({storage:t,backendApiClients:e,openfortEventEmitter:i,policyId:s,ensureSigner:r,chains:n,validateAndRefreshSession:c}){this.#c=r,this.#t=t,this.#a=n,this.#e=s,this.#s=c,this.#n=e,this.#r=new o,i.on(a.LOGGED_OUT,this.#h),i.on(a.SWITCH_ACCOUNT,this.#d)}#p=async()=>(this.#i||(this.#i=await this.#c()),this.#i);#h=async()=>{this.#i=void 0,this.#r.emit(A.ACCOUNTS_CHANGED,[])};#d=async t=>{this.#r.emit(A.ACCOUNTS_CHANGED,[t])};async getRpcProvider(){if(!this.#o){const e=await t.fromStorage(this.#t),a=e?.chainId||8453;await import("@ethersproject/providers").then(t=>{const e=this.#a?this.#a[a]:void 0;this.#o=new t.StaticJsonRpcProvider(e??s[a])})}if(!this.#o)throw new Error("RPC provider not initialized");return this.#o}async#m(a){switch(a.method){case"eth_accounts":{const e=await t.fromStorage(this.#t);return e?[e.address]:[]}case"eth_requestAccounts":{const e=await t.fromStorage(this.#t);if(e)return this.#r.emit(A.ACCOUNTS_CONNECT,{chainId:String(e.chainId)}),[e.address];throw new d(p.UNAUTHORIZED,"Unauthorized - must be authenticated and configured with a signer.")}case"eth_signTransaction":{const i=await t.fromStorage(this.#t),s=await this.#p(),r=await e.fromStorage(this.#t);if(!i||!r)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const o=await this.getRpcProvider(),{chainId:n}=await o.detectNetwork(),[c]=a.params||[];c.chainId||(c.chainId=n.toString());const h=_(c),{serialize:m}=await import("@ethersproject/transactions"),u=t=>{if(!t)return;return{legacy:0,eip2930:1,eip1559:2}[t]},{gas:w,...l}=h,g={...l,gasLimit:w,to:h.to??void 0,type:u(h.type)},f=m(g),{keccak256:S}=await import("@ethersproject/keccak256"),A=S(f);await this.#s();const R=await s.sign(A,!1,!1),{splitSignature:y}=await import("@ethersproject/bytes");return m(g,y(R))}case"eth_sendTransaction":{const s=await t.fromStorage(this.#t),r=await this.#p(),o=await e.fromStorage(this.#t);if(!s||!o)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");if(await this.#s(),s?.accountType===i.EOA){const[t]=a.params||[],e=await this.getRpcProvider(),i=await R(t,e,s.address),r=await this.#m({method:"eth_signTransaction",params:[i]});return this.#m({method:"eth_sendRawTransaction",params:[r]})}return(await g({params:a.params||[],signer:r,account:s,authentication:o,backendClient:this.#n,policyId:this.#e})).receipt.transactionHash}case"eth_sendRawTransactionSync":{const s=await t.fromStorage(this.#t),r=await this.#p(),o=await e.fromStorage(this.#t);if(!s||!o)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");if(s?.accountType===i.EOA)throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`);return await this.#s(),await g({params:a.params||[],signer:r,account:s,authentication:o,backendClient:this.#n,policyId:this.#e})}case"eth_estimateGas":{const i=await t.fromStorage(this.#t),s=await e.fromStorage(this.#t);if(!i||!s)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await c({params:a.params||[],account:i,authentication:s,backendClient:this.#n,policyId:this.#e})}case"eth_signTypedData":case"eth_signTypedData_v4":{const e=await t.fromStorage(this.#t),i=await this.#p();if(!e)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#s();const s=await this.getRpcProvider();return await S({method:a.method,params:a.params||[],signer:i,implementationType:e.implementationType||e.type,rpcProvider:s,account:e})}case"personal_sign":{const e=await t.fromStorage(this.#t);if(!e)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const i=await this.#p();return await this.#s(),await u({params:a.params||[],signer:i,account:e})}case"eth_chainId":{const t=await this.getRpcProvider(),{chainId:e}=await t.detectNetwork();return r(e)}case"wallet_switchEthereumChain":{const t=await this.#p();if(!a.params||!Array.isArray(a.params)||0===a.params.length)throw new d(m.INVALID_PARAMS,"Invalid parameters for wallet_switchEthereumChain");await this.#s();try{const e=parseInt(a.params[0].chainId,16);await t.switchChain({chainId:e}),await import("@ethersproject/providers").then(t=>{const a=this.#a?this.#a[e]:void 0;this.#o=new t.StaticJsonRpcProvider(a??s[e])})}catch(t){const e=t;throw new d(m.INTERNAL_ERROR,`Failed to switch chain: ${e.message}`)}return null}case"wallet_addEthereumChain":{await this.#p();const t=await this.getRpcProvider();return await n({params:a.params||[],rpcProvider:t,storage:this.#t})}case"wallet_showCallsStatus":return null;case"wallet_getCallsStatus":{const s=await t.fromStorage(this.#t);if(s?.accountType===i.EOA)throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`);const r=await e.fromStorage(this.#t);if(!s||!r)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await h({params:a.params||{},authentication:r,backendClient:this.#n,account:s})}case"wallet_sendCalls":{const s=await t.fromStorage(this.#t);if(s?.accountType===i.EOA)throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`);const r=await this.#p(),o=await e.fromStorage(this.#t);if(!s||!o)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#s();return await f({params:a.params?a.params[0].calls:[],signer:r,account:s,authentication:o,backendClient:this.#n,policyId:this.#e})}case"wallet_grantPermissions":{const s=await t.fromStorage(this.#t);if(s?.accountType===i.EOA)throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`);const r=await this.#p(),o=await e.fromStorage(this.#t);if(!s||!o)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await w({params:a.params||[],signer:r,account:s,authentication:o,backendClient:this.#n,policyId:this.#e})}case"wallet_revokePermissions":{const i=await t.fromStorage(this.#t),s=await this.#p(),r=await e.fromStorage(this.#t);if(!i||!r)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await l({params:a.params||[],signer:s,account:i,authentication:r,backendClient:this.#n})}case"wallet_getCapabilities":{const e=await t.fromStorage(this.#t);if(e?.accountType===i.EOA)throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`);const s=await this.getRpcProvider(),{chainId:o}=await s.detectNetwork();return{[r(o)]:{permissions:{supported:!0,signerTypes:["account","key"],keyTypes:["secp256k1"],permissionTypes:["contract-calls"]},paymasterService:{supported:!0},atomicBatch:{supported:!0}}}}case"eth_gasPrice":case"eth_getBalance":case"eth_sendRawTransaction":case"eth_getCode":case"eth_getStorageAt":case"eth_call":case"eth_blockNumber":case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getTransactionByHash":case"eth_getTransactionReceipt":case"eth_getTransactionCount":return(await this.getRpcProvider()).send(a.method,a.params||[]);default:throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`)}}async request(t){try{return this.#m(t)}catch(t){if(t instanceof d)throw t;if(t instanceof Error)throw new d(m.INTERNAL_ERROR,t.message);throw new d(m.INTERNAL_ERROR,"Internal error")}}on(t,e){this.#r.on(t,e)}removeListener(t,e){this.#r.off(t,e)}}export{y as EvmProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{withOpenfortError as e,OpenfortErrorType as t}from"../../core/errors/openfortError.js";import{JsonRpcError as a,RpcErrorCode as s}from"./JsonRpcError.js";const r=e=>{const t=e?.logs?.[0];return{blockHash:t?.blockHash,blockNumber:e?.blockNumber?.toString(),contractAddress:void 0,cumulativeGasUsed:e?.gasUsed,effectiveGasPrice:e?.gasFee,from:void 0,gasUsed:e?.gasUsed,logs:e?.logs||[],logsBloom:void 0,status:1===e?.status?"success":0===e?.status?"reverted":void 0,to:e?.to,transactionHash:e?.transactionHash,transactionIndex:t?.transactionIndex,type:"eip1559",blobGasPrice:void 0,blobGasUsed:void 0,root:void 0}},n=async({params:n,signer:o,account:i,authentication:c,backendClient:d,policyId:l})=>{const p=n[0]?.capabilities?.paymasterService?.policy??l,u=await(async(r,n,o,i,c)=>{const d=r.map(e=>{if(!e.to)throw new a(s.INVALID_PARAMS,'wallet_sendCalls requires a "to" field');return{to:String(e.to),data:e.data?String(e.data):void 0,value:e.value?String(e.value):void 0}});return e(async()=>(await n.transactionIntentsApi.createTransactionIntent({createTransactionIntentRequest:{account:o.id,policy:c,chainId:o.chainId,interactions:d}},{headers:{authorization:`Bearer ${n.config.backend.accessToken}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}})).data,{default:t.AUTHENTICATION_ERROR})})(n,d,i,c,p).catch(e=>{throw new a(s.TRANSACTION_REJECTED,e.message)});if(u.response?.error.reason)throw new a(s.TRANSACTION_REJECTED,u.response?.error.reason);if(u?.nextAction?.payload?.signableHash){let n;n=[300,531050104,324,50104,2741,11124].includes(i.chainId)?await o.sign(u.nextAction.payload.signableHash,!1,!1):await o.sign(u.nextAction.payload.signableHash);const c=await e(async()=>await d.transactionIntentsApi.signature({id:u.id,signatureRequest:{signature:n}}),{default:t.AUTHENTICATION_ERROR}).catch(e=>{throw new a(s.TRANSACTION_REJECTED,e.message)});if(0===c.data.response?.status)throw new a(s.TRANSACTION_REJECTED,c.data.response?.error.reason);if(!c.data.response)throw new a(s.TRANSACTION_REJECTED,"No transaction response received");return{id:u.id,receipt:r(c.data.response)}}if(!u.response)throw new a(s.TRANSACTION_REJECTED,"No transaction response received");return{id:u.id,receipt:r(u.response)}};export{n as sendCallsSync};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{sendCallsSync as a}from"./sendCallSync.js";const n=async({params:n,signer:t,account:c,authentication:i,backendClient:e,policyId:o})=>(await a({params:n,signer:t,account:c,authentication:i,backendClient:e,policyId:o})).id;export{n as sendCalls};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var C;!function(C){C.ACCOUNTS_CHANGED="accountsChanged",C.ACCOUNTS_CONNECT="connect"}(C||(C={}));export{C as ProviderEvent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AccountType as e}from"../../types/types.js";const
|
|
1
|
+
import{AccountType as e}from"../../types/types.js";const t=async t=>{const{hash:a,signer:s,ownerAddress:r,factoryAddress:i,salt:n,chainId:o,address:c,implementationType:d}=t;let g=a;if([e.UPGRADEABLE_V5,e.UPGRADEABLE_V6,e.ZKSYNC_UPGRADEABLE_V1,e.ZKSYNC_UPGRADEABLE_V2].includes(d)){const e={name:"Openfort",version:"0.5",chainId:Number(o),verifyingContract:c},t={OpenfortMessage:[{name:"hashedMessage",type:"bytes32"}]},a={hashedMessage:g},{_TypedDataEncoder:s}=await import("@ethersproject/hash");g=s.hash(e,t,a)}const P=await s.sign(g,!1,!1);if(i&&n&&[e.UPGRADEABLE_V5,e.UPGRADEABLE_V6].includes(d)){const{id:e}=await import("@ethersproject/hash"),{defaultAbiCoder:t}=await import("@ethersproject/abi"),{hexConcat:a}=await import("@ethersproject/bytes"),s=a([e("createAccountWithNonce(address,bytes32,bool)").slice(0,10),t.encode(["address","bytes32","bool"],[r,n,!1])]);return a([t.encode(["address","bytes","bytes"],[i,s,P]),"0x6492649264926492649264926492649264926492649264926492649264926492"])}return P};async function a(e,t,a){const s={...e};if(!s.nonce){const e=await t.getTransactionCount(a,"pending");s.nonce=`0x${e.toString(16)}`}if(!s.gas)try{const e=await t.estimateGas({from:a,to:s.to,data:s.data,value:s.value});s.gas=e.toHexString()}catch{s.gas="0x5208"}const r=s.maxFeePerGas&&s.maxPriorityFeePerGas,i=s.gasPrice;if(!r&&!i){const e=await t.getBlock("latest");if(null!==e.baseFeePerGas&&void 0!==e.baseFeePerGas){const a=e.baseFeePerGas,r=a.mul(12).div(10),i=await t.getGasPrice();let n=i.sub(a);n.lt(0)&&(n=i.mul(0));const o=r.add(n);s.maxFeePerGas=o.toHexString(),s.maxPriorityFeePerGas=n.toHexString(),s.type="0x2",delete s.gasPrice}else{const e=(await t.getGasPrice()).mul(12).div(10);s.gasPrice=e.toHexString(),s.type="0x0",delete s.maxFeePerGas,delete s.maxPriorityFeePerGas}}return s}function s({from:e,...t}){return{to:t.to,data:t.data,accessList:t.accessList,chainId:(i=t.chainId,i.startsWith("0x")?parseInt(i,16):parseInt(i,10)),type:t.type&&{"0x0":"legacy","0x1":"eip2930","0x2":"eip1559"}[t.type]||"eip1559",maxPriorityFeePerGas:t.maxPriorityFeePerGas?BigInt(t.maxPriorityFeePerGas):void 0,maxFeePerGas:t.maxFeePerGas?BigInt(t.maxFeePerGas):void 0,gasPrice:t.gasPrice?BigInt(t.gasPrice):void 0,value:(a=t.value,s=BigInt,r=0n,void 0!==a?s(a):r),nonce:t.nonce?parseInt(t.nonce.toString(),16):void 0,gas:t.gas?BigInt(t.gas):void 0};var a,s,r,i}export{s as parseTransactionRequest,a as prepareEOATransaction,t as signMessage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Account as e}from"../core/configuration/account.js";import{Authentication as i}from"../core/configuration/authentication.js";import{OpenfortError as t,OpenfortErrorType as r}from"../core/errors/openfortError.js";import{sentry as n}from"../core/errors/sentry.js";import{StorageKeys as o}from"../storage/istorage.js";import{randomUUID as s}from"../utils/crypto.js";import{debugLog as a}from"../utils/debug.js";import{ReactNativeMessenger as c}from"./messaging/ReactNativeMessenger.js";import d from"./messaging/browserMessenger/connect.js";import"./messaging/browserMessenger/backwardCompatibility.js";import{isErrorResponse as h,NOT_CONFIGURED_ERROR as u,MISSING_USER_ENTROPY_ERROR as l,MISSING_PROJECT_ENTROPY_ERROR as y,INCORRECT_USER_ENTROPY_ERROR as g,MISSING_PASSKEY_ERROR as f,INCORRECT_PASSKEY_ERROR as p,OTP_REQUIRED_ERROR as m,ShieldAuthType as w,Event as C,SignRequest as v,SwitchChainRequest as k,ExportPrivateKeyRequest as I,SetRecoveryMethodRequest as P,GetCurrentDeviceRequest as E,UpdateAuthenticationRequest as T}from"./types.js";class b extends Error{constructor(){super("This embedded signer requires a password to be recovered")}}class R extends Error{constructor(){super("Wrong recovery passkey for this embedded signer")}}class N extends Error{constructor(){super("MissingProjectEntropyError")}}class A extends Error{constructor(){super("Wrong recovery password for this embedded signer")}}class S extends Error{constructor(){super("Not configured")}}class U extends Error{constructor(){super("OTP required")}}class z{messenger;connection;remote;storage;sdkConfiguration;isInitialized=!1;initializationPromise=null;constructor(e,i,n){if(!e)throw new t("Configuration is required for IframeManager",r.INVALID_CONFIGURATION);if(!i)throw new t("Storage is required for IframeManager",r.INVALID_CONFIGURATION);if(!n)throw new t("Messenger is required for IframeManager",r.INVALID_CONFIGURATION);this.sdkConfiguration=e,this.storage=i,this.messenger=n}async initialize(){if(!this.isInitialized)if(this.initializationPromise)await this.initializationPromise;else{this.initializationPromise=this.doInitialize();try{await this.initializationPromise,this.isInitialized=!0}catch(e){throw this.initializationPromise=null,e}}}async doInitialize(){a("Initializing IframeManager connection..."),this.messenger.initialize({validateReceivedMessage:e=>!(!e||"object"!=typeof e),log:a}),this.connection=d({messenger:this.messenger,timeout:1e4,log:a});try{this.remote=await this.connection.promise,a("IframeManager connection established")}catch(e){const i=e;throw n.captureException(i),this.destroy(),a("Failed to establish connection:",i),new t(`Failed to establish iFrame connection: ${i.cause||i.message}`,r.INTERNAL_ERROR,e)}}async ensureConnection(){if(this.isInitialized&&this.remote||await this.initialize(),!this.remote)throw new t("Failed to establish connection",r.INTERNAL_ERROR);return this.remote}handleError(e){if(h(e)){if(e.error===u)throw this.storage.remove(o.ACCOUNT),new S;if(e.error===l)throw this.storage.remove(o.ACCOUNT),new b;if(e.error===y)throw this.storage.remove(o.ACCOUNT),new N;if(e.error===g)throw new A;if(e.error===f)throw this.storage.remove(o.ACCOUNT),new b;if(e.error===p)throw new R;if(e.error===m)throw new U;throw this.storage.remove(o.ACCOUNT),new t(`Unknown error: ${e.error}`,r.INTERNAL_ERROR)}throw e}async buildRequestConfiguration(){const e=await i.fromStorage(this.storage);if(!e)throw new t("Must be authenticated to create a signer",r.NOT_LOGGED_IN_ERROR);const n={auth:w.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyProvider:e.thirdPartyProvider,thirdPartyTokenType:e.thirdPartyTokenType,token:e.token,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl,shieldAuthentication:n,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",shieldURL:this.sdkConfiguration.shieldUrl,encryptionKey:this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionKey??void 0}}async buildIFrameRequestConfiguration(){const e=await i.fromStorage(this.storage);if(!e)throw new t("Must be authenticated to create a signer",r.NOT_LOGGED_IN_ERROR);const n={auth:w.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyTokenType:e.thirdPartyTokenType??null,thirdPartyProvider:e.thirdPartyProvider??null,accessToken:e.token,playerID:e.player,recovery:n,chainId:null,password:null,passkey:null}}async create(e){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const i=await this.ensureConnection(),t=await this.buildIFrameRequestConfiguration();t.chainId=e.chainId??null,t.password=e?.entropy?.recoveryPassword??null,t.recovery={...t.recovery,encryptionSession:e?.entropy?.encryptionSession},t.passkey=e?.entropy?.passkey??null;const r={uuid:s(),action:C.CREATE,recovery:t.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:t.accessToken,playerID:t.playerID,thirdPartyProvider:t.thirdPartyProvider,thirdPartyTokenType:t.thirdPartyTokenType,encryptionKey:t.password,encryptionSession:t.recovery?.encryptionSession??null,passkey:t.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,chainId:e.chainId??null,accountType:e.accountType,chainType:e.chainType},n=await i.create(r);return h(n)&&this.handleError(n),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",n.version??"undefined"),n}async recover(i){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const t=await e.fromStorage(this.storage),r=await this.ensureConnection(),n=await this.buildIFrameRequestConfiguration();n.chainId=t?.chainId??null,n.password=i?.entropy?.recoveryPassword??null,n.recovery={...n.recovery,encryptionSession:i?.entropy?.encryptionSession},n.passkey=i?.entropy?.passkey??null;const o={uuid:s(),action:C.RECOVER,recovery:n.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:n.accessToken,playerID:n.playerID,thirdPartyProvider:n.thirdPartyProvider,thirdPartyTokenType:n.thirdPartyTokenType,encryptionKey:n.password,encryptionSession:n.recovery?.encryptionSession??null,passkey:n.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,account:i.account},a=await r.recover(o);return h(a)&&this.handleError(a),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",a.version??"undefined"),a}async sign(e,i,t,r){a("[iframe] ensureConnection");const n=await this.ensureConnection(),o=new v(s(),e,await this.buildRequestConfiguration(),i,t,r);a("[iframe] done ensureConnection");const c=await n.sign(o);return a("[iframe] response",c),h(c)&&this.handleError(c),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",c.version??"undefined"),c.signature}async switchChain(e){const i=await this.ensureConnection(),t=new k(s(),e,await this.buildRequestConfiguration()),r=await i.switchChain(t);return h(r)&&this.handleError(r),r}async export(){const e=await this.ensureConnection(),i=new I(s(),await this.buildRequestConfiguration()),t=await e.export(i);return h(t)&&this.handleError(t),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",t.version??"undefined"),t.key}async setRecoveryMethod(e,i,t,r,n){const o=await this.ensureConnection(),a=new P(s(),e,await this.buildRequestConfiguration(),i,t,r,n),c=await o.setRecoveryMethod(a);h(c)&&this.handleError(c),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",c.version??"undefined")}async getCurrentDevice(e){const i=await this.ensureConnection(),t=new E(s(),e);try{const e=await i.getCurrentDevice(t);return h(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e}catch(e){if(e instanceof S)return null;throw e}}async updateAuthentication(){if(!this.isLoaded()||!this.remote)return void a("IframeManager not loaded, skipping authentication update");const e=await i.fromStorage(this.storage);if(!e)return void a("No authentication found, skipping update");const t=new T(s(),e.token);a("Updating authentication in iframe with token");const r=await this.remote.updateAuthentication(t);h(r)&&this.handleError(r)}async disconnect(){const e=await this.ensureConnection(),i={uuid:s()};await e.logout(i)}async onMessage(e){a("[HANDSHAKE DEBUG] IframeManager.onMessage called with:",e),this.messenger instanceof c?(this.isInitialized||this.connection?a(`[HANDSHAKE DEBUG] Connection already initialized (isInitialized: ${this.isInitialized}, hasConnection: ${!!this.connection})`):(a("[HANDSHAKE DEBUG] First message received, initializing connection..."),this.initialize().catch(e=>{a("[HANDSHAKE DEBUG] Failed to initialize connection:",e)})),a("[HANDSHAKE DEBUG] Passing message to ReactNativeMessenger"),this.messenger.handleMessage(e)):a("[HANDSHAKE DEBUG] Not a ReactNativeMessenger, ignoring message")}isLoaded(){return this.isInitialized&&void 0!==this.remote}destroy(){this.connection&&this.connection.destroy(),this.messenger.destroy(),this.remote=void 0,this.isInitialized=!1,this.connection=void 0,this.initializationPromise=null}}export{z as IframeManager,N as MissingProjectEntropyError,b as MissingRecoveryPasswordError,S as NotConfiguredError,U as OTPRequiredError,
|
|
1
|
+
import{Account as e}from"../core/configuration/account.js";import{Authentication as i}from"../core/configuration/authentication.js";import{OpenfortError as t,OpenfortErrorType as r}from"../core/errors/openfortError.js";import{sentry as n}from"../core/errors/sentry.js";import{StorageKeys as o}from"../storage/istorage.js";import{randomUUID as s}from"../utils/crypto.js";import{debugLog as a}from"../utils/debug.js";import{ReactNativeMessenger as c}from"./messaging/ReactNativeMessenger.js";import d from"./messaging/browserMessenger/connect.js";import"./messaging/browserMessenger/backwardCompatibility.js";import{isErrorResponse as h,NOT_CONFIGURED_ERROR as u,MISSING_USER_ENTROPY_ERROR as l,MISSING_PROJECT_ENTROPY_ERROR as y,INCORRECT_USER_ENTROPY_ERROR as g,MISSING_PASSKEY_ERROR as f,INCORRECT_PASSKEY_ERROR as p,OTP_REQUIRED_ERROR as m,ShieldAuthType as w,Event as C,SignRequest as v,SwitchChainRequest as k,ExportPrivateKeyRequest as I,SetRecoveryMethodRequest as P,GetCurrentDeviceRequest as E,UpdateAuthenticationRequest as T}from"./types.js";class b extends Error{constructor(){super("This embedded signer requires a password to be recovered")}}class R extends Error{constructor(){super("Wrong recovery passkey for this embedded signer")}}class N extends Error{constructor(){super("MissingProjectEntropyError")}}class A extends Error{constructor(){super("Wrong recovery password for this embedded signer")}}class S extends Error{constructor(){super("Not configured")}}class U extends Error{constructor(){super("OTP required")}}class z{messenger;connection;remote;storage;sdkConfiguration;isInitialized=!1;initializationPromise=null;constructor(e,i,n){if(!e)throw new t("Configuration is required for IframeManager",r.INVALID_CONFIGURATION);if(!i)throw new t("Storage is required for IframeManager",r.INVALID_CONFIGURATION);if(!n)throw new t("Messenger is required for IframeManager",r.INVALID_CONFIGURATION);this.sdkConfiguration=e,this.storage=i,this.messenger=n}async initialize(){if(!this.isInitialized)if(this.initializationPromise)await this.initializationPromise;else{this.initializationPromise=this.doInitialize();try{await this.initializationPromise,this.isInitialized=!0}catch(e){throw this.initializationPromise=null,e}}}async doInitialize(){a("Initializing IframeManager connection..."),this.messenger.initialize({validateReceivedMessage:e=>!(!e||"object"!=typeof e),log:a}),this.connection=d({messenger:this.messenger,timeout:1e4,log:a});try{this.remote=await this.connection.promise,a("IframeManager connection established")}catch(e){const i=e;throw n.captureException(i),this.destroy(),a("Failed to establish connection:",i),new t(`Failed to establish iFrame connection: ${i.cause||i.message}`,r.INTERNAL_ERROR,e)}}async ensureConnection(){if(this.isInitialized&&this.remote||await this.initialize(),!this.remote)throw new t("Failed to establish connection",r.INTERNAL_ERROR);return this.remote}handleError(e){if(h(e)){if(e.error===u)throw this.storage.remove(o.ACCOUNT),new S;if(e.error===l)throw this.storage.remove(o.ACCOUNT),new b;if(e.error===y)throw this.storage.remove(o.ACCOUNT),new N;if(e.error===g)throw new A;if(e.error===f)throw this.storage.remove(o.ACCOUNT),new b;if(e.error===p)throw new R;if(e.error===m)throw new U;throw this.storage.remove(o.ACCOUNT),new t(`Unknown error: ${e.error}`,r.INTERNAL_ERROR)}throw e}async buildRequestConfiguration(){const e=await i.fromStorage(this.storage);if(!e)throw new t("Must be authenticated to create a signer",r.NOT_LOGGED_IN_ERROR);const n={auth:w.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyProvider:e.thirdPartyProvider,thirdPartyTokenType:e.thirdPartyTokenType,token:e.token,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl,shieldAuthentication:n,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",shieldURL:this.sdkConfiguration.shieldUrl,encryptionKey:this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionKey??void 0}}async buildIFrameRequestConfiguration(){const e=await i.fromStorage(this.storage);if(!e)throw new t("Must be authenticated to create a signer",r.NOT_LOGGED_IN_ERROR);const n={auth:w.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyTokenType:e.thirdPartyTokenType??null,thirdPartyProvider:e.thirdPartyProvider??null,accessToken:e.token,playerID:e.player,recovery:n,chainId:null,password:null,passkey:null}}async create(e){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const i=await this.ensureConnection(),t=await this.buildIFrameRequestConfiguration();t.chainId=e.chainId??null,t.password=e?.entropy?.recoveryPassword??null,t.recovery={...t.recovery,encryptionSession:e?.entropy?.encryptionSession},t.passkey=e?.entropy?.passkey??null;const r={uuid:s(),action:C.CREATE,recovery:t.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:t.accessToken,playerID:t.playerID,thirdPartyProvider:t.thirdPartyProvider,thirdPartyTokenType:t.thirdPartyTokenType,encryptionKey:t.password,encryptionSession:t.recovery?.encryptionSession??null,passkey:t.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,chainId:e.chainId??null,accountType:e.accountType,chainType:e.chainType},n=await i.create(r);return h(n)&&this.handleError(n),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",n.version??"undefined"),n}async recover(i){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const t=await e.fromStorage(this.storage),r=await this.ensureConnection(),n=await this.buildIFrameRequestConfiguration();n.chainId=t?.chainId??null,n.password=i?.entropy?.recoveryPassword??null,n.recovery={...n.recovery,encryptionSession:i?.entropy?.encryptionSession},n.passkey=i?.entropy?.passkey??null;const o={uuid:s(),action:C.RECOVER,recovery:n.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:n.accessToken,playerID:n.playerID,thirdPartyProvider:n.thirdPartyProvider,thirdPartyTokenType:n.thirdPartyTokenType,encryptionKey:n.password,encryptionSession:n.recovery?.encryptionSession??null,passkey:n.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,account:i.account},a=await r.recover(o);return h(a)&&this.handleError(a),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",a.version??"undefined"),a}async sign(e,i,t,r){a("[iframe] ensureConnection");const n=await this.ensureConnection(),o=new v(s(),e,await this.buildRequestConfiguration(),i,t,r);a("[iframe] done ensureConnection");const c=await n.sign(o);return a("[iframe] response",c),h(c)&&this.handleError(c),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",c.version??"undefined"),c.signature}async switchChain(e){const i=await this.ensureConnection(),t=new k(s(),e,await this.buildRequestConfiguration()),r=await i.switchChain(t);return h(r)&&this.handleError(r),r}async export(){const e=await this.ensureConnection(),i=new I(s(),await this.buildRequestConfiguration()),t=await e.export(i);return h(t)&&this.handleError(t),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",t.version??"undefined"),t.key}async setRecoveryMethod(e,i,t,r,n){const o=await this.ensureConnection(),a=new P(s(),e,await this.buildRequestConfiguration(),i,t,r,n),c=await o.setRecoveryMethod(a);h(c)&&this.handleError(c),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",c.version??"undefined")}async getCurrentDevice(e){const i=await this.ensureConnection(),t=new E(s(),e);try{const e=await i.getCurrentDevice(t);return h(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e}catch(e){if(e instanceof S)return null;throw e}}async updateAuthentication(){if(!this.isLoaded()||!this.remote)return void a("IframeManager not loaded, skipping authentication update");const e=await i.fromStorage(this.storage);if(!e)return void a("No authentication found, skipping update");const t=new T(s(),e.token);a("Updating authentication in iframe with token");const r=await this.remote.updateAuthentication(t);h(r)&&this.handleError(r)}async disconnect(){const e=await this.ensureConnection(),i={uuid:s()};await e.logout(i)}async onMessage(e){a("[HANDSHAKE DEBUG] IframeManager.onMessage called with:",e),this.messenger instanceof c?(this.isInitialized||this.connection?a(`[HANDSHAKE DEBUG] Connection already initialized (isInitialized: ${this.isInitialized}, hasConnection: ${!!this.connection})`):(a("[HANDSHAKE DEBUG] First message received, initializing connection..."),this.initialize().catch(e=>{a("[HANDSHAKE DEBUG] Failed to initialize connection:",e)})),a("[HANDSHAKE DEBUG] Passing message to ReactNativeMessenger"),this.messenger.handleMessage(e)):a("[HANDSHAKE DEBUG] Not a ReactNativeMessenger, ignoring message")}isLoaded(){return this.isInitialized&&void 0!==this.remote}destroy(){this.connection&&this.connection.destroy(),this.messenger.destroy(),this.remote=void 0,this.isInitialized=!1,this.connection=void 0,this.initializationPromise=null}}export{z as IframeManager,N as MissingProjectEntropyError,b as MissingRecoveryPasswordError,S as NotConfiguredError,U as OTPRequiredError,A as WrongRecoveryPasswordError};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var r;!function(r){r.
|
|
1
|
+
var r;!function(r){r.RECOVER="recover",r.RECOVERED="recovered",r.CREATE="create",r.CREATED="created",r.UPDATE_AUTHENTICATION="update-authentication",r.AUTHENTICATION_UPDATED="authentication-updated",r.SIGN="sign",r.SET_RECOVERY_METHOD="set-recovery-method",r.SWITCH_CHAIN="switch-chain",r.CHAIN_SWITCHED="chain-switched",r.EXPORT="export",r.SIGNED="signed",r.LOGGED_OUT="logged-out",r.GET_CURRENT_DEVICE="get-current-device",r.CURRENT_DEVICE="current-device"}(r||(r={}));const e="not-configured-error",i="missing-user-entropy-error",t="missing-project-entropy-error",s="incorrect-user-entropy-error",o="incorrect-passkey-error",n="missing-passkey-error",c="otp-required-error";class u{uuid;action=r.GET_CURRENT_DEVICE;playerID;constructor(r,e){this.uuid=r,this.playerID=e}}class a{uuid;action=r.SIGN;message;requestConfiguration;requireArrayify;requireHash;chainType;constructor(r,e,i,t,s,o){this.uuid=r,this.message=e,this.requestConfiguration=i,this.requireArrayify=t,this.requireHash=s,this.chainType=o||"EVM"}}class E{uuid;action=r.SWITCH_CHAIN;chainId;requestConfiguration;constructor(r,e,i){this.uuid=r,this.chainId=e,this.requestConfiguration=i}}class h{uuid;action=r.EXPORT;requestConfiguration;constructor(r,e){this.uuid=r,this.requestConfiguration=e}}class T{uuid;action=r.SET_RECOVERY_METHOD;recoveryMethod;recoveryPassword;encryptionSession;passkeyKey;passkeyId;requestConfiguration;constructor(r,e,i,t,s,o,n){this.uuid=r,this.recoveryMethod=e,this.recoveryPassword=t,this.encryptionSession=s,this.requestConfiguration=i,this.passkeyKey=o,this.passkeyId=n}}function d(r){return"error"in r}class C{uuid;action=r.UPDATE_AUTHENTICATION;accessToken;recovery;constructor(r,e,i){this.uuid=r,this.accessToken=e,this.recovery=i}}var y;!function(r){r.OPENFORT="openfort"}(y||(y={}));export{r as Event,h as ExportPrivateKeyRequest,u as GetCurrentDeviceRequest,o as INCORRECT_PASSKEY_ERROR,s as INCORRECT_USER_ENTROPY_ERROR,n as MISSING_PASSKEY_ERROR,t as MISSING_PROJECT_ENTROPY_ERROR,i as MISSING_USER_ENTROPY_ERROR,e as NOT_CONFIGURED_ERROR,c as OTP_REQUIRED_ERROR,T as SetRecoveryMethodRequest,y as ShieldAuthType,a as SignRequest,E as SwitchChainRequest,C as UpdateAuthenticationRequest,d as isErrorResponse};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfort/openfort-js",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.24",
|
|
4
4
|
"author": "Openfort (https://www.openfort.io)",
|
|
5
5
|
"bugs": "https://github.com/openfort-xyz/openfort-js/issues",
|
|
6
6
|
"repository": "openfort-xyz/openfort-js.git",
|
|
@@ -14,17 +14,6 @@
|
|
|
14
14
|
"package.json",
|
|
15
15
|
"README.md"
|
|
16
16
|
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"test": "pnpm check && pnpm test:unit",
|
|
19
|
-
"test:unit": "jest --passWithNoTests",
|
|
20
|
-
"test:watch": "jest --watch",
|
|
21
|
-
"packageList": "./scripts/generate-package-list.sh",
|
|
22
|
-
"dev": "NODE_ENV=development pnpm rollup --config rollup.config.js --watch",
|
|
23
|
-
"check": "biome check --write src",
|
|
24
|
-
"format": "biome format --write src",
|
|
25
|
-
"build": "pnpm packageList && node copyVersion.cjs && NODE_ENV=production pnpm rollup --config rollup.config.js && rm -rf dist/types",
|
|
26
|
-
"stats": "open ./stats.html"
|
|
27
|
-
},
|
|
28
17
|
"publishConfig": {
|
|
29
18
|
"registry": "https://registry.npmjs.org/"
|
|
30
19
|
},
|
|
@@ -33,11 +22,12 @@
|
|
|
33
22
|
"@ethersproject/bytes": "^5.8.0",
|
|
34
23
|
"@ethersproject/hash": "^5.8.0",
|
|
35
24
|
"@ethersproject/providers": "^5.8.0",
|
|
25
|
+
"@ethersproject/transactions": "^5.8.0",
|
|
26
|
+
"@ethersproject/keccak256": "^5.8.0",
|
|
36
27
|
"@openfort/shield-js": "^0.1.27",
|
|
37
28
|
"@sentry/browser": "^9.15.0",
|
|
38
29
|
"@sentry/core": "^9.15.0",
|
|
39
30
|
"axios": "^1.8.2",
|
|
40
|
-
"axios-retry": "^4.5.0",
|
|
41
31
|
"eventemitter3": "5.0.1",
|
|
42
32
|
"human-id": "^4.1.1",
|
|
43
33
|
"jose": "^5.2.2"
|
|
@@ -51,33 +41,34 @@
|
|
|
51
41
|
}
|
|
52
42
|
},
|
|
53
43
|
"devDependencies": {
|
|
54
|
-
"@babel/core": "^7.26.10",
|
|
55
|
-
"@openfort/openapi-clients": "workspace:*",
|
|
56
|
-
"@parcel/core": "^2.15.0",
|
|
57
|
-
"@parcel/packager-ts": "2.12.0",
|
|
58
|
-
"@parcel/transformer-typescript-types": "2.12.0",
|
|
59
|
-
"@rollup/plugin-babel": "^6.0.4",
|
|
60
44
|
"@rollup/plugin-commonjs": "^24.0.1",
|
|
61
45
|
"@rollup/plugin-json": "^6.0.0",
|
|
62
46
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
63
47
|
"@rollup/plugin-replace": "^5.0.2",
|
|
64
48
|
"@rollup/plugin-terser": "^0.4.3",
|
|
65
49
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
66
|
-
"@swc/core": "^1.11.24",
|
|
67
|
-
"@swc/jest": "^0.2.24",
|
|
68
50
|
"@types/jest": "^29.4.3",
|
|
69
51
|
"jest": "^29.4.3",
|
|
70
|
-
"jest-environment-jsdom": "^29.4.3",
|
|
71
|
-
"parcel": "^2.15.0",
|
|
72
52
|
"rollup": "^3.17.2",
|
|
73
53
|
"rollup-plugin-dts": "^5.3.0",
|
|
74
|
-
"rollup-plugin-polyfill-node": "^0.12.0",
|
|
75
54
|
"rollup-plugin-visualizer": "^5.14.0",
|
|
76
|
-
"typescript": "^5.8.3"
|
|
55
|
+
"typescript": "^5.8.3",
|
|
56
|
+
"@openfort/openapi-clients": "0.0.0"
|
|
77
57
|
},
|
|
78
58
|
"main": "./dist/cjs/sdk/src/index.js",
|
|
79
59
|
"module": "./dist/sdk/src/index.js",
|
|
80
60
|
"type": "module",
|
|
81
61
|
"types": "./dist/index.d.ts",
|
|
82
|
-
"sideEffects": false
|
|
83
|
-
|
|
62
|
+
"sideEffects": false,
|
|
63
|
+
"scripts": {
|
|
64
|
+
"test": "pnpm check && pnpm test:unit",
|
|
65
|
+
"test:unit": "jest --passWithNoTests",
|
|
66
|
+
"test:watch": "jest --watch",
|
|
67
|
+
"packageList": "./scripts/generate-package-list.sh",
|
|
68
|
+
"dev": "NODE_ENV=development pnpm rollup --config rollup.config.js --watch",
|
|
69
|
+
"check": "biome check --write src",
|
|
70
|
+
"format": "biome format --write src",
|
|
71
|
+
"build": "pnpm packageList && node copyVersion.cjs && NODE_ENV=production pnpm rollup --config rollup.config.js && rm -rf dist/types",
|
|
72
|
+
"stats": "open ./stats.html"
|
|
73
|
+
}
|
|
74
|
+
}
|