@openfort/openfort-js 0.10.36-beta.2 → 0.10.37

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.
Files changed (64) hide show
  1. package/dist/cjs/packages/internal/openapi-clients/dist/index.js +1 -1
  2. package/dist/cjs/sdk/src/api/auth.js +1 -1
  3. package/dist/cjs/sdk/src/api/embeddedWallet.js +1 -1
  4. package/dist/cjs/sdk/src/api/proxy.js +1 -1
  5. package/dist/cjs/sdk/src/api/user.js +1 -1
  6. package/dist/cjs/sdk/src/auth/authManager.js +1 -1
  7. package/dist/cjs/sdk/src/core/configuration/account.js +1 -1
  8. package/dist/cjs/sdk/src/core/configuration/authentication.js +1 -1
  9. package/dist/cjs/sdk/src/core/errors/openfortError.js +1 -1
  10. package/dist/cjs/sdk/src/core/errors/sentry.js +1 -1
  11. package/dist/cjs/sdk/src/core/openfort.js +1 -1
  12. package/dist/cjs/sdk/src/core/openfortInternal.js +1 -1
  13. package/dist/cjs/sdk/src/index.js +1 -1
  14. package/dist/cjs/sdk/src/storage/istorage.js +1 -1
  15. package/dist/cjs/sdk/src/storage/lazyStorage.js +1 -1
  16. package/dist/cjs/sdk/src/types/types.js +1 -1
  17. package/dist/cjs/sdk/src/utils/chains/index.js +1 -1
  18. package/dist/cjs/sdk/src/utils/crypto.js +1 -1
  19. package/dist/cjs/sdk/src/version.js +1 -1
  20. package/dist/cjs/sdk/src/wallets/embedded.js +1 -1
  21. package/dist/cjs/sdk/src/wallets/evm/estimateGas.js +1 -1
  22. package/dist/cjs/sdk/src/wallets/evm/getAssets.js +1 -1
  23. package/dist/cjs/sdk/src/wallets/evm/getCallsStatus.js +1 -1
  24. package/dist/cjs/sdk/src/wallets/evm/registerSession.js +1 -1
  25. package/dist/cjs/sdk/src/wallets/evm/revokeSession.js +1 -1
  26. package/dist/cjs/sdk/src/wallets/evm/sendCallSync.js +1 -1
  27. package/dist/cjs/sdk/src/wallets/iframeManager.js +1 -1
  28. package/dist/index.d.ts +2889 -7333
  29. package/dist/packages/internal/openapi-clients/dist/index.js +1 -1
  30. package/dist/sdk/src/api/auth.js +1 -1
  31. package/dist/sdk/src/api/embeddedWallet.js +1 -1
  32. package/dist/sdk/src/api/proxy.js +1 -1
  33. package/dist/sdk/src/api/user.js +1 -1
  34. package/dist/sdk/src/auth/authManager.js +1 -1
  35. package/dist/sdk/src/core/configuration/account.js +1 -1
  36. package/dist/sdk/src/core/configuration/authentication.js +1 -1
  37. package/dist/sdk/src/core/errors/openfortError.js +1 -1
  38. package/dist/sdk/src/core/errors/sentry.js +1 -1
  39. package/dist/sdk/src/core/openfort.js +1 -1
  40. package/dist/sdk/src/core/openfortInternal.js +1 -1
  41. package/dist/sdk/src/index.js +1 -1
  42. package/dist/sdk/src/storage/istorage.js +1 -1
  43. package/dist/sdk/src/storage/lazyStorage.js +1 -1
  44. package/dist/sdk/src/types/types.js +1 -1
  45. package/dist/sdk/src/utils/chains/index.js +1 -1
  46. package/dist/sdk/src/utils/crypto.js +1 -1
  47. package/dist/sdk/src/version.js +1 -1
  48. package/dist/sdk/src/wallets/embedded.js +1 -1
  49. package/dist/sdk/src/wallets/evm/estimateGas.js +1 -1
  50. package/dist/sdk/src/wallets/evm/getAssets.js +1 -1
  51. package/dist/sdk/src/wallets/evm/getCallsStatus.js +1 -1
  52. package/dist/sdk/src/wallets/evm/registerSession.js +1 -1
  53. package/dist/sdk/src/wallets/evm/revokeSession.js +1 -1
  54. package/dist/sdk/src/wallets/evm/sendCallSync.js +1 -1
  55. package/dist/sdk/src/wallets/iframeManager.js +1 -1
  56. package/package.json +5 -8
  57. package/dist/cjs/sdk/src/core/errors/authErrorCodes.js +0 -1
  58. package/dist/cjs/sdk/src/core/errors/internal/extractApiError.js +0 -1
  59. package/dist/cjs/sdk/src/core/errors/internal/extractAuthError.js +0 -1
  60. package/dist/cjs/sdk/src/core/errors/withApiError.js +0 -1
  61. package/dist/sdk/src/core/errors/authErrorCodes.js +0 -1
  62. package/dist/sdk/src/core/errors/internal/extractApiError.js +0 -1
  63. package/dist/sdk/src/core/errors/internal/extractAuthError.js +0 -1
  64. package/dist/sdk/src/core/errors/withApiError.js +0 -1
@@ -1 +1 @@
1
- import e from"axios";import t from"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 o="https://example.com",i=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,o=s)=>{const i={...e.options,url:(n?.basePath||a.defaults.baseURL||o)+e.url};return a.request(i)}},p=function(t){const n=function(e){return{cancelTransferOwnership:async(t,s,n={})=>{i("cancelTransferOwnership","id",t),i("cancelTransferOwnership","cancelTransferOwnershipRequest",s);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,o);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},P={};await r(P,e),P["Content-Type"]="application/json",h(c,{});let w=l&&l.headers?l.headers:{};return p.headers={...P,...w,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},completeRecovery:async(t,s,n={})=>{i("completeRecovery","id",t),i("completeRecovery","completeRecoveryRequest",s);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,o);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},P={};await r(P,e),P["Content-Type"]="application/json",h(c,{});let w=l&&l.headers?l.headers:{};return p.headers={...P,...w,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},createAccount:async(t,s={})=>{i("createAccount","createAccountRequest",t);const n=new URL("/v1/accounts",o);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}},createAccountV2:async(t,s={})=>{i("createAccountV2","createAccountRequestV2",t);const n=new URL("/v2/accounts",o);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={})=>{i("deployAccount","id",t),i("deployAccount","deployRequest",s);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,o);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},P={};await r(P,e),P["Content-Type"]="application/json",h(c,{});let w=l&&l.headers?l.headers:{};return p.headers={...P,...w,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},disableAccount:async(t,s={})=>{i("disableAccount","id",t);const n="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,o);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={})=>{i("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,o);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},P={};await r(p,e),s&&(P.expand=s),h(c,P);let w=u&&u.headers?u.headers:{};return l.headers={...p,...w,...n.headers},{url:d(c),options:l}},getAccountV2:async(t,s={})=>{i("getAccountV2","id",t);const n="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,o);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,i,c,u,l={})=>{const p=new URL("/v1/accounts",o);let P;e&&(P=e.baseOptions);const w={method:"GET",...P,...l},y={},m={};await r(y,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!==i&&(m.player=i),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let g=P&&P.headers?P.headers:{};return w.headers={...y,...g,...l.headers},{url:d(p),options:w}},getAccountsV2:async(t,s,n,a,i,c,u,l,p={})=>{const P=new URL("/v2/accounts",o);let w;e&&(w=e.baseOptions);const y={method:"GET",...w,...p},m={},g={};await r(m,e),void 0!==t&&(g.limit=t),void 0!==s&&(g.skip=s),void 0!==n&&(g.order=n),void 0!==a&&(g.chainId=a),void 0!==i&&(g.user=i),void 0!==c&&(g.chainType=c),void 0!==u&&(g.accountType=u),void 0!==l&&(g.address=l),h(P,g);let f=w&&w.headers?w.headers:{};return y.headers={...m,...f,...p.headers},{url:d(P),options:y}},getSignerIdByAddress:async(t,s={})=>{i("getSignerIdByAddress","address",t);const n=new URL("/v2/accounts/signer",o);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}},removeAccount:async(t,s={})=>{i("removeAccount","id",t);const n="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,o);let c;e&&(c=e.baseOptions);const u={method:"DELETE",...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}},requestTransferOwnership:async(t,s,n={})=>{i("requestTransferOwnership","id",t),i("requestTransferOwnership","transferOwnershipRequest",s);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,o);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},P={};await r(P,e),P["Content-Type"]="application/json",h(c,{});let w=l&&l.headers?l.headers:{};return p.headers={...P,...w,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},signPayload:async(t,s,n={})=>{i("signPayload","id",t),i("signPayload","signPayloadRequest",s);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,o);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},P={};await r(P,e),P["Content-Type"]="application/json",h(c,{});let w=l&&l.headers?l.headers:{};return p.headers={...P,...w,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},startRecovery:async(t,s,n={})=>{i("startRecovery","id",t),i("startRecovery","startRecoveryRequest",s);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,o);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},P={};await r(P,e),P["Content-Type"]="application/json",h(c,{});let w=l&&l.headers?l.headers:{};return p.headers={...P,...w,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},switchChainV2:async(t,s={})=>{i("switchChainV2","switchChainQueriesV2",t);const n=new URL("/v2/accounts/switch-chain",o);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={})=>{i("syncAccount","id",t);const n="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,o);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,o,i){const r=await n.cancelTransferOwnership(a,o,i);return l(r,e,s,t)},async completeRecovery(a,o,i){const r=await n.completeRecovery(a,o,i);return l(r,e,s,t)},async createAccount(a,o){const i=await n.createAccount(a,o);return l(i,e,s,t)},async createAccountV2(a,o){const i=await n.createAccountV2(a,o);return l(i,e,s,t)},async deployAccount(a,o,i){const r=await n.deployAccount(a,o,i);return l(r,e,s,t)},async disableAccount(a,o){const i=await n.disableAccount(a,o);return l(i,e,s,t)},async getAccount(a,o,i){const r=await n.getAccount(a,o,i);return l(r,e,s,t)},async getAccountV2(a,o){const i=await n.getAccountV2(a,o);return l(i,e,s,t)},async getAccounts(a,o,i,r,c,h,u,d){const p=await n.getAccounts(a,o,i,r,c,h,u,d);return l(p,e,s,t)},async getAccountsV2(a,o,i,r,c,h,u,d,p){const P=await n.getAccountsV2(a,o,i,r,c,h,u,d,p);return l(P,e,s,t)},async getSignerIdByAddress(a,o){const i=await n.getSignerIdByAddress(a,o);return l(i,e,s,t)},async removeAccount(a,o){const i=await n.removeAccount(a,o);return l(i,e,s,t)},async requestTransferOwnership(a,o,i){const r=await n.requestTransferOwnership(a,o,i);return l(r,e,s,t)},async signPayload(a,o,i){const r=await n.signPayload(a,o,i);return l(r,e,s,t)},async startRecovery(a,o,i){const r=await n.startRecovery(a,o,i);return l(r,e,s,t)},async switchChainV2(a,o){const i=await n.switchChainV2(a,o);return l(i,e,s,t)},async syncAccount(a,o){const i=await n.syncAccount(a,o);return l(i,e,s,t)}}};class P 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))}createAccountV2(e,t){return p(this.configuration).createAccountV2(e.createAccountRequestV2,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))}removeAccount(e,t){return p(this.configuration).removeAccount(e.id,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 w=function(t){const n=function(e){return{signInAnonymousPost:async(t={})=>{const s=new URL("/sign-in/anonymous",o);let n;e&&(n=e.baseOptions);const a={method:"POST",...n,...t};h(s,{});let i=n&&n.headers?n.headers:{};return a.headers={...i,...t.headers},{url:d(s),options:a}}}}(t);return{async signInAnonymousPost(a){const o=await n.signInAnonymousPost(a);return l(o,e,s,t)}}};class y extends n{signInAnonymousPost(e){return w(this.configuration).signInAnonymousPost(e).then(e=>e(this.axios,this.basePath))}}const m=function(t){const n=function(e){return{authenticateSIWE:async(t,s={})=>{i("authenticateSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/authenticate",o);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={})=>{i("getJwks","publishableKey",t);const n="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(n,o);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={})=>{i("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",o);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 P=c&&c.headers?c.headers:{};return l.headers={...p,...P,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,s,n={})=>{i("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",o);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 P=c&&c.headers?c.headers:{};return l.headers={...p,...P,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,s,n={})=>{i("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",o);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={})=>{i("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",o);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={})=>{i("linkSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/link",o);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={})=>{i("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",o);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={})=>{i("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",o);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 P=c&&c.headers?c.headers:{};return l.headers={...p,...P,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,s,n={})=>{i("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",o);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 P=c&&c.headers?c.headers:{};return l.headers={...p,...P,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,s={})=>{i("loginWithIdToken","loginWithIdTokenRequest",t);const n=new URL("/iam/v1/oauth/login_id_token",o);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={})=>{i("logout","logoutRequest",t);const n=new URL("/iam/v1/sessions/logout",o);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",o);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let i=n&&n.headers?n.headers:{};return a.headers={...i,...t.headers},{url:d(s),options:a}},poolOAuth:async(t,s={})=>{i("poolOAuth","key",t);const n=new URL("/iam/v1/oauth/pool",o);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={})=>{i("refresh","refreshTokenRequest",t);const n=new URL("/iam/v1/sessions",o);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",o);let a;e&&(a=e.baseOptions);const i={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 i.headers={...c,...u,...s.headers},{url:d(n),options:i}},requestEmailVerification:async(t,s={})=>{i("requestEmailVerification","requestVerifyEmailRequest",t);const n=new URL("/iam/v1/password/request_email_verification",o);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={})=>{i("requestResetPassword","requestResetPasswordRequest",t);const n=new URL("/iam/v1/password/request_reset",o);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={})=>{i("resetPassword","resetPasswordRequest",t);const n=new URL("/iam/v1/password/reset",o);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={})=>{i("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",o);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 P=c&&c.headers?c.headers:{};return l.headers={...p,...P,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,s,n={})=>{i("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",o);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 P=c&&c.headers?c.headers:{};return l.headers={...p,...P,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,s={})=>{i("unlinkEmail","unlinkEmailRequest",t);const n=new URL("/iam/v1/password/unlink",o);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={})=>{i("unlinkOAuth","unlinkOAuthRequest",t);const n=new URL("/iam/v1/oauth/unlink",o);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={})=>{i("unlinkSIWE","sIWERequest",t);const n=new URL("/iam/v1/siwe/unlink",o);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={})=>{i("verifyEmail","verifyEmailRequest",t);const n=new URL("/iam/v1/password/verify_email",o);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={})=>{i("verifyOAuthToken","authenticateOAuthRequest",t);const n=new URL("/iam/v1/oauth/verify",o);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,o){const i=await n.authenticateSIWE(a,o);return l(i,e,s,t)},async getJwks(a,o){const i=await n.getJwks(a,o);return l(i,e,s,t)},async initOAuth(a,o,i){const r=await n.initOAuth(a,o,i);return l(r,e,s,t)},async initSIWE(a,o,i){const r=await n.initSIWE(a,o,i);return l(r,e,s,t)},async linkEmail(a,o,i){const r=await n.linkEmail(a,o,i);return l(r,e,s,t)},async linkOAuth(a,o,i){const r=await n.linkOAuth(a,o,i);return l(r,e,s,t)},async linkSIWE(a,o){const i=await n.linkSIWE(a,o);return l(i,e,s,t)},async linkThirdParty(a,o,i){const r=await n.linkThirdParty(a,o,i);return l(r,e,s,t)},async loginEmailPassword(a,o,i){const r=await n.loginEmailPassword(a,o,i);return l(r,e,s,t)},async loginOIDC(a,o,i){const r=await n.loginOIDC(a,o,i);return l(r,e,s,t)},async loginWithIdToken(a,o){const i=await n.loginWithIdToken(a,o);return l(i,e,s,t)},async logout(a,o){const i=await n.logout(a,o);return l(i,e,s,t)},async me(a){const o=await n.me(a);return l(o,e,s,t)},async poolOAuth(a,o){const i=await n.poolOAuth(a,o);return l(i,e,s,t)},async refresh(a,o){const i=await n.refresh(a,o);return l(i,e,s,t)},async registerGuest(a,o){const i=await n.registerGuest(a,o);return l(i,e,s,t)},async requestEmailVerification(a,o){const i=await n.requestEmailVerification(a,o);return l(i,e,s,t)},async requestResetPassword(a,o){const i=await n.requestResetPassword(a,o);return l(i,e,s,t)},async resetPassword(a,o){const i=await n.resetPassword(a,o);return l(i,e,s,t)},async signupEmailPassword(a,o,i){const r=await n.signupEmailPassword(a,o,i);return l(r,e,s,t)},async thirdParty(a,o,i){const r=await n.thirdParty(a,o,i);return l(r,e,s,t)},async unlinkEmail(a,o){const i=await n.unlinkEmail(a,o);return l(i,e,s,t)},async unlinkOAuth(a,o){const i=await n.unlinkOAuth(a,o);return l(i,e,s,t)},async unlinkSIWE(a,o){const i=await n.unlinkSIWE(a,o);return l(i,e,s,t)},async verifyEmail(a,o){const i=await n.verifyEmail(a,o);return l(i,e,s,t)},async verifyOAuthToken(a,o){const i=await n.verifyOAuthToken(a,o);return l(i,e,s,t)}}};class g extends n{authenticateSIWE(e,t){return m(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return m(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return m(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return m(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return m(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return m(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return m(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return m(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return m(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return m(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return m(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return m(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return m(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return m(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return m(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return m(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return m(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return m(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return m(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return m(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return m(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return m(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return m(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return m(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return m(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return m(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const f=function(t){const n=function(e){return{meV2:async(t={})=>{const s=new URL("/iam/v2/me",o);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let i=n&&n.headers?n.headers:{};return a.headers={...i,...t.headers},{url:d(s),options:a}}}}(t);return{async meV2(a){const o=await n.meV2(a);return l(o,e,s,t)}}};class R extends n{meV2(e){return f(this.configuration).meV2(e).then(e=>e(this.axios,this.basePath))}}const O=function(t){const n=function(e){return{accountInfoPost:async(t,s={})=>{i("accountInfoPost","accountInfoPostRequest",t);const n=new URL("/account-info",o);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}},changeEmailPost:async(t,s={})=>{i("changeEmailPost","changeEmailPostRequest",t);const n=new URL("/change-email",o);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}},changePasswordPost:async(t,s={})=>{i("changePasswordPost","changePasswordPostRequest",t);const n=new URL("/change-password",o);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}},deleteUserCallbackGet:async(t,s,n={})=>{const a=new URL("/delete-user/callback",o);let i;e&&(i=e.baseOptions);const r={method:"GET",...i,...n},c={};void 0!==t&&(c.token=t),void 0!==s&&(c.callbackURL=s),h(a,c);let u=i&&i.headers?i.headers:{};return r.headers={...u,...n.headers},{url:d(a),options:r}},deleteUserPost:async(t,s={})=>{i("deleteUserPost","deleteUserPostRequest",t);const n=new URL("/delete-user",o);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}},errorGet:async(t={})=>{const s=new URL("/error",o);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let i=n&&n.headers?n.headers:{};return a.headers={...i,...t.headers},{url:d(s),options:a}},forgetPasswordPost:async(t,s={})=>{i("forgetPasswordPost","forgetPasswordPostRequest",t);const n=new URL("/forget-password",o);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}},getAccessTokenPost:async(t,s={})=>{i("getAccessTokenPost","refreshTokenPostRequest",t);const n=new URL("/get-access-token",o);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}},getSessionGet:async(t,s={})=>{const n=new URL("/get-session",o);let a;e&&(a=e.baseOptions);const i={method:"GET",...a,...s},r={};void 0!==t&&(r.disableCookieCache=t),h(n,r);let c=a&&a.headers?a.headers:{};return i.headers={...c,...s.headers},{url:d(n),options:i}},linkSocialPost:async(t,s={})=>{i("linkSocialPost","linkSocialPostRequest",t);const n=new URL("/link-social",o);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}},listAccountsGet:async(t={})=>{const s=new URL("/list-accounts",o);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let i=n&&n.headers?n.headers:{};return a.headers={...i,...t.headers},{url:d(s),options:a}},listSessionsGet:async(t={})=>{const s=new URL("/list-sessions",o);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let i=n&&n.headers?n.headers:{};return a.headers={...i,...t.headers},{url:d(s),options:a}},okGet:async(t={})=>{const s=new URL("/ok",o);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let i=n&&n.headers?n.headers:{};return a.headers={...i,...t.headers},{url:d(s),options:a}},refreshTokenPost:async(t,s={})=>{i("refreshTokenPost","refreshTokenPostRequest",t);const n=new URL("/refresh-token",o);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}},requestPasswordResetPost:async(t,s={})=>{i("requestPasswordResetPost","forgetPasswordPostRequest",t);const n=new URL("/request-password-reset",o);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}},resetPasswordPost:async(t,s={})=>{i("resetPasswordPost","resetPasswordPostRequest",t);const n=new URL("/reset-password",o);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}},resetPasswordTokenGet:async(t,s,n={})=>{i("resetPasswordTokenGet","token",t);const a="/reset-password/{token}".replace("{token}",encodeURIComponent(String(t))),r=new URL(a,o);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...n},l={};void 0!==s&&(l.callbackURL=s),h(r,l);let p=c&&c.headers?c.headers:{};return u.headers={...p,...n.headers},{url:d(r),options:u}},revokeOtherSessionsPost:async(t,s={})=>{const n=new URL("/revoke-other-sessions",o);let a;e&&(a=e.baseOptions);const i={method:"POST",...a,...s},r={"Content-Type":"application/json"};h(n,{});let c=a&&a.headers?a.headers:{};return i.headers={...r,...c,...s.headers},i.data=u(t,i,e),{url:d(n),options:i}},revokeSessionPost:async(t,s={})=>{const n=new URL("/revoke-session",o);let a;e&&(a=e.baseOptions);const i={method:"POST",...a,...s},r={"Content-Type":"application/json"};h(n,{});let c=a&&a.headers?a.headers:{};return i.headers={...r,...c,...s.headers},i.data=u(t,i,e),{url:d(n),options:i}},revokeSessionsPost:async(t,s={})=>{const n=new URL("/revoke-sessions",o);let a;e&&(a=e.baseOptions);const i={method:"POST",...a,...s},r={"Content-Type":"application/json"};h(n,{});let c=a&&a.headers?a.headers:{};return i.headers={...r,...c,...s.headers},i.data=u(t,i,e),{url:d(n),options:i}},sendVerificationEmailPost:async(t,s={})=>{const n=new URL("/send-verification-email",o);let a;e&&(a=e.baseOptions);const i={method:"POST",...a,...s},r={"Content-Type":"application/json"};h(n,{});let c=a&&a.headers?a.headers:{};return i.headers={...r,...c,...s.headers},i.data=u(t,i,e),{url:d(n),options:i}},signInEmailPost:async(t,s={})=>{i("signInEmailPost","signInEmailPostRequest",t);const n=new URL("/sign-in/email",o);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}},signOutPost:async(t,s={})=>{const n=new URL("/sign-out",o);let a;e&&(a=e.baseOptions);const i={method:"POST",...a,...s},r={"Content-Type":"application/json"};h(n,{});let c=a&&a.headers?a.headers:{};return i.headers={...r,...c,...s.headers},i.data=u(t,i,e),{url:d(n),options:i}},signUpEmailPost:async(t,s={})=>{const n=new URL("/sign-up/email",o);let a;e&&(a=e.baseOptions);const i={method:"POST",...a,...s},r={"Content-Type":"application/json"};h(n,{});let c=a&&a.headers?a.headers:{};return i.headers={...r,...c,...s.headers},i.data=u(t,i,e),{url:d(n),options:i}},socialSignIn:async(t,s={})=>{i("socialSignIn","socialSignInRequest",t);const n=new URL("/sign-in/social",o);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}},unlinkAccountPost:async(t,s={})=>{i("unlinkAccountPost","unlinkAccountPostRequest",t);const n=new URL("/unlink-account",o);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}},updateUserPost:async(t,s={})=>{const n=new URL("/update-user",o);let a;e&&(a=e.baseOptions);const i={method:"POST",...a,...s},r={"Content-Type":"application/json"};h(n,{});let c=a&&a.headers?a.headers:{};return i.headers={...r,...c,...s.headers},i.data=u(t,i,e),{url:d(n),options:i}},verifyEmailGet:async(t,s,n={})=>{i("verifyEmailGet","token",t);const a=new URL("/verify-email",o);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n},u={};void 0!==t&&(u.token=t),void 0!==s&&(u.callbackURL=s),h(a,u);let l=r&&r.headers?r.headers:{};return c.headers={...l,...n.headers},{url:d(a),options:c}}}}(t);return{async accountInfoPost(a,o){const i=await n.accountInfoPost(a,o);return l(i,e,s,t)},async changeEmailPost(a,o){const i=await n.changeEmailPost(a,o);return l(i,e,s,t)},async changePasswordPost(a,o){const i=await n.changePasswordPost(a,o);return l(i,e,s,t)},async deleteUserCallbackGet(a,o,i){const r=await n.deleteUserCallbackGet(a,o,i);return l(r,e,s,t)},async deleteUserPost(a,o){const i=await n.deleteUserPost(a,o);return l(i,e,s,t)},async errorGet(a){const o=await n.errorGet(a);return l(o,e,s,t)},async forgetPasswordPost(a,o){const i=await n.forgetPasswordPost(a,o);return l(i,e,s,t)},async getAccessTokenPost(a,o){const i=await n.getAccessTokenPost(a,o);return l(i,e,s,t)},async getSessionGet(a,o){const i=await n.getSessionGet(a,o);return l(i,e,s,t)},async linkSocialPost(a,o){const i=await n.linkSocialPost(a,o);return l(i,e,s,t)},async listAccountsGet(a){const o=await n.listAccountsGet(a);return l(o,e,s,t)},async listSessionsGet(a){const o=await n.listSessionsGet(a);return l(o,e,s,t)},async okGet(a){const o=await n.okGet(a);return l(o,e,s,t)},async refreshTokenPost(a,o){const i=await n.refreshTokenPost(a,o);return l(i,e,s,t)},async requestPasswordResetPost(a,o){const i=await n.requestPasswordResetPost(a,o);return l(i,e,s,t)},async resetPasswordPost(a,o){const i=await n.resetPasswordPost(a,o);return l(i,e,s,t)},async resetPasswordTokenGet(a,o,i){const r=await n.resetPasswordTokenGet(a,o,i);return l(r,e,s,t)},async revokeOtherSessionsPost(a,o){const i=await n.revokeOtherSessionsPost(a,o);return l(i,e,s,t)},async revokeSessionPost(a,o){const i=await n.revokeSessionPost(a,o);return l(i,e,s,t)},async revokeSessionsPost(a,o){const i=await n.revokeSessionsPost(a,o);return l(i,e,s,t)},async sendVerificationEmailPost(a,o){const i=await n.sendVerificationEmailPost(a,o);return l(i,e,s,t)},async signInEmailPost(a,o){const i=await n.signInEmailPost(a,o);return l(i,e,s,t)},async signOutPost(a,o){const i=await n.signOutPost(a,o);return l(i,e,s,t)},async signUpEmailPost(a,o){const i=await n.signUpEmailPost(a,o);return l(i,e,s,t)},async socialSignIn(a,o){const i=await n.socialSignIn(a,o);return l(i,e,s,t)},async unlinkAccountPost(a,o){const i=await n.unlinkAccountPost(a,o);return l(i,e,s,t)},async updateUserPost(a,o){const i=await n.updateUserPost(a,o);return l(i,e,s,t)},async verifyEmailGet(a,o,i){const r=await n.verifyEmailGet(a,o,i);return l(r,e,s,t)}}};class b extends n{accountInfoPost(e,t){return O(this.configuration).accountInfoPost(e.accountInfoPostRequest,t).then(e=>e(this.axios,this.basePath))}changeEmailPost(e,t){return O(this.configuration).changeEmailPost(e.changeEmailPostRequest,t).then(e=>e(this.axios,this.basePath))}changePasswordPost(e,t){return O(this.configuration).changePasswordPost(e.changePasswordPostRequest,t).then(e=>e(this.axios,this.basePath))}deleteUserCallbackGet(e={},t){return O(this.configuration).deleteUserCallbackGet(e.token,e.callbackURL,t).then(e=>e(this.axios,this.basePath))}deleteUserPost(e,t){return O(this.configuration).deleteUserPost(e.deleteUserPostRequest,t).then(e=>e(this.axios,this.basePath))}errorGet(e){return O(this.configuration).errorGet(e).then(e=>e(this.axios,this.basePath))}forgetPasswordPost(e,t){return O(this.configuration).forgetPasswordPost(e.forgetPasswordPostRequest,t).then(e=>e(this.axios,this.basePath))}getAccessTokenPost(e,t){return O(this.configuration).getAccessTokenPost(e.refreshTokenPostRequest,t).then(e=>e(this.axios,this.basePath))}getSessionGet(e={},t){return O(this.configuration).getSessionGet(e.disableCookieCache,t).then(e=>e(this.axios,this.basePath))}linkSocialPost(e,t){return O(this.configuration).linkSocialPost(e.linkSocialPostRequest,t).then(e=>e(this.axios,this.basePath))}listAccountsGet(e){return O(this.configuration).listAccountsGet(e).then(e=>e(this.axios,this.basePath))}listSessionsGet(e){return O(this.configuration).listSessionsGet(e).then(e=>e(this.axios,this.basePath))}okGet(e){return O(this.configuration).okGet(e).then(e=>e(this.axios,this.basePath))}refreshTokenPost(e,t){return O(this.configuration).refreshTokenPost(e.refreshTokenPostRequest,t).then(e=>e(this.axios,this.basePath))}requestPasswordResetPost(e,t){return O(this.configuration).requestPasswordResetPost(e.forgetPasswordPostRequest,t).then(e=>e(this.axios,this.basePath))}resetPasswordPost(e,t){return O(this.configuration).resetPasswordPost(e.resetPasswordPostRequest,t).then(e=>e(this.axios,this.basePath))}resetPasswordTokenGet(e,t){return O(this.configuration).resetPasswordTokenGet(e.token,e.callbackURL,t).then(e=>e(this.axios,this.basePath))}revokeOtherSessionsPost(e={},t){return O(this.configuration).revokeOtherSessionsPost(e.body,t).then(e=>e(this.axios,this.basePath))}revokeSessionPost(e={},t){return O(this.configuration).revokeSessionPost(e.revokeSessionPostRequest,t).then(e=>e(this.axios,this.basePath))}revokeSessionsPost(e={},t){return O(this.configuration).revokeSessionsPost(e.body,t).then(e=>e(this.axios,this.basePath))}sendVerificationEmailPost(e={},t){return O(this.configuration).sendVerificationEmailPost(e.sendVerificationEmailPostRequest,t).then(e=>e(this.axios,this.basePath))}signInEmailPost(e,t){return O(this.configuration).signInEmailPost(e.signInEmailPostRequest,t).then(e=>e(this.axios,this.basePath))}signOutPost(e={},t){return O(this.configuration).signOutPost(e.body,t).then(e=>e(this.axios,this.basePath))}signUpEmailPost(e={},t){return O(this.configuration).signUpEmailPost(e.signUpEmailPostRequest,t).then(e=>e(this.axios,this.basePath))}socialSignIn(e,t){return O(this.configuration).socialSignIn(e.socialSignInRequest,t).then(e=>e(this.axios,this.basePath))}unlinkAccountPost(e,t){return O(this.configuration).unlinkAccountPost(e.unlinkAccountPostRequest,t).then(e=>e(this.axios,this.basePath))}updateUserPost(e={},t){return O(this.configuration).updateUserPost(e.updateUserPostRequest,t).then(e=>e(this.axios,this.basePath))}verifyEmailGet(e,t){return O(this.configuration).verifyEmailGet(e.token,e.callbackURL,t).then(e=>e(this.axios,this.basePath))}}const T=function(t){const n=function(e){return{checkVerificationOtp:async(t,s={})=>{i("checkVerificationOtp","checkVerificationOtpRequest",t);const n=new URL("/email-otp/check-verification-otp",o);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}},emailOtpResetPasswordPost:async(t,s={})=>{i("emailOtpResetPasswordPost","emailOtpResetPasswordPostRequest",t);const n=new URL("/email-otp/reset-password",o);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}},emailOtpSendVerificationOtpPost:async(t,s={})=>{i("emailOtpSendVerificationOtpPost","emailOtpSendVerificationOtpPostRequest",t);const n=new URL("/email-otp/send-verification-otp",o);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}},emailOtpVerifyEmailPost:async(t,s={})=>{i("emailOtpVerifyEmailPost","emailOtpVerifyEmailPostRequest",t);const n=new URL("/email-otp/verify-email",o);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}},forgetPasswordEmailOtpPost:async(t,s={})=>{i("forgetPasswordEmailOtpPost","forgetPasswordEmailOtpPostRequest",t);const n=new URL("/forget-password/email-otp",o);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}},signInEmailOtpPost:async(t,s={})=>{i("signInEmailOtpPost","signInEmailOtpPostRequest",t);const n=new URL("/sign-in/email-otp",o);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}}}}(t);return{async checkVerificationOtp(a,o){const i=await n.checkVerificationOtp(a,o);return l(i,e,s,t)},async emailOtpResetPasswordPost(a,o){const i=await n.emailOtpResetPasswordPost(a,o);return l(i,e,s,t)},async emailOtpSendVerificationOtpPost(a,o){const i=await n.emailOtpSendVerificationOtpPost(a,o);return l(i,e,s,t)},async emailOtpVerifyEmailPost(a,o){const i=await n.emailOtpVerifyEmailPost(a,o);return l(i,e,s,t)},async forgetPasswordEmailOtpPost(a,o){const i=await n.forgetPasswordEmailOtpPost(a,o);return l(i,e,s,t)},async signInEmailOtpPost(a,o){const i=await n.signInEmailOtpPost(a,o);return l(i,e,s,t)}}};class S extends n{checkVerificationOtp(e,t){return T(this.configuration).checkVerificationOtp(e.checkVerificationOtpRequest,t).then(e=>e(this.axios,this.basePath))}emailOtpResetPasswordPost(e,t){return T(this.configuration).emailOtpResetPasswordPost(e.emailOtpResetPasswordPostRequest,t).then(e=>e(this.axios,this.basePath))}emailOtpSendVerificationOtpPost(e,t){return T(this.configuration).emailOtpSendVerificationOtpPost(e.emailOtpSendVerificationOtpPostRequest,t).then(e=>e(this.axios,this.basePath))}emailOtpVerifyEmailPost(e,t){return T(this.configuration).emailOtpVerifyEmailPost(e.emailOtpVerifyEmailPostRequest,t).then(e=>e(this.axios,this.basePath))}forgetPasswordEmailOtpPost(e,t){return T(this.configuration).forgetPasswordEmailOtpPost(e.forgetPasswordEmailOtpPostRequest,t).then(e=>e(this.axios,this.basePath))}signInEmailOtpPost(e,t){return T(this.configuration).signInEmailOtpPost(e.signInEmailOtpPostRequest,t).then(e=>e(this.axios,this.basePath))}}const k=function(t){const n=function(e){return{phoneNumberForgetPasswordPost:async(t,s={})=>{i("phoneNumberForgetPasswordPost","phoneNumberForgetPasswordPostRequest",t);const n=new URL("/phone-number/forget-password",o);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}},phoneNumberRequestPasswordResetPost:async(t,s={})=>{i("phoneNumberRequestPasswordResetPost","phoneNumberRequestPasswordResetPostRequest",t);const n=new URL("/phone-number/request-password-reset",o);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}},phoneNumberResetPasswordPost:async(t,s={})=>{i("phoneNumberResetPasswordPost","phoneNumberResetPasswordPostRequest",t);const n=new URL("/phone-number/reset-password",o);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}},phoneNumberSendOtpPost:async(t,s={})=>{i("phoneNumberSendOtpPost","phoneNumberSendOtpPostRequest",t);const n=new URL("/phone-number/send-otp",o);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}},phoneNumberVerifyPost:async(t,s={})=>{i("phoneNumberVerifyPost","phoneNumberVerifyPostRequest",t);const n=new URL("/phone-number/verify",o);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}},signInPhoneNumberPost:async(t,s={})=>{i("signInPhoneNumberPost","signInPhoneNumberPostRequest",t);const n=new URL("/sign-in/phone-number",o);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}}}}(t);return{async phoneNumberForgetPasswordPost(a,o){const i=await n.phoneNumberForgetPasswordPost(a,o);return l(i,e,s,t)},async phoneNumberRequestPasswordResetPost(a,o){const i=await n.phoneNumberRequestPasswordResetPost(a,o);return l(i,e,s,t)},async phoneNumberResetPasswordPost(a,o){const i=await n.phoneNumberResetPasswordPost(a,o);return l(i,e,s,t)},async phoneNumberSendOtpPost(a,o){const i=await n.phoneNumberSendOtpPost(a,o);return l(i,e,s,t)},async phoneNumberVerifyPost(a,o){const i=await n.phoneNumberVerifyPost(a,o);return l(i,e,s,t)},async signInPhoneNumberPost(a,o){const i=await n.signInPhoneNumberPost(a,o);return l(i,e,s,t)}}};class v extends n{phoneNumberForgetPasswordPost(e,t){return k(this.configuration).phoneNumberForgetPasswordPost(e.phoneNumberForgetPasswordPostRequest,t).then(e=>e(this.axios,this.basePath))}phoneNumberRequestPasswordResetPost(e,t){return k(this.configuration).phoneNumberRequestPasswordResetPost(e.phoneNumberRequestPasswordResetPostRequest,t).then(e=>e(this.axios,this.basePath))}phoneNumberResetPasswordPost(e,t){return k(this.configuration).phoneNumberResetPasswordPost(e.phoneNumberResetPasswordPostRequest,t).then(e=>e(this.axios,this.basePath))}phoneNumberSendOtpPost(e,t){return k(this.configuration).phoneNumberSendOtpPost(e.phoneNumberSendOtpPostRequest,t).then(e=>e(this.axios,this.basePath))}phoneNumberVerifyPost(e,t){return k(this.configuration).phoneNumberVerifyPost(e.phoneNumberVerifyPostRequest,t).then(e=>e(this.axios,this.basePath))}signInPhoneNumberPost(e,t){return k(this.configuration).signInPhoneNumberPost(e.signInPhoneNumberPostRequest,t).then(e=>e(this.axios,this.basePath))}}const q=function(t){const n=function(e){return{handleRpcRequest:async(t,s={})=>{i("handleRpcRequest","jsonRpcRequest",t);const n=new URL("/rpc",o);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}}}}(t);return{async handleRpcRequest(a,o){const i=await n.handleRpcRequest(a,o);return l(i,e,s,t)}}};class I extends n{handleRpcRequest(e,t){return q(this.configuration).handleRpcRequest(e.jsonRpcRequest,t).then(e=>e(this.axios,this.basePath))}}const x=function(t){const n=function(e){return{linkSiweListWalletsGet:async(t={})=>{const s=new URL("/link-siwe/list-wallets",o);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let i=n&&n.headers?n.headers:{};return a.headers={...i,...t.headers},{url:d(s),options:a}},linkSiweNoncePost:async(t,s={})=>{i("linkSiweNoncePost","siweNoncePostRequest",t);const n=new URL("/link-siwe/nonce",o);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}},linkSiweUnlinkPost:async(t,s={})=>{i("linkSiweUnlinkPost","linkSiweUnlinkPostRequest",t);const n=new URL("/link-siwe/unlink",o);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}},linkSiweVerifyPost:async(t,s={})=>{i("linkSiweVerifyPost","siweVerifyPostRequest",t);const n=new URL("/link-siwe/verify",o);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}},siweNoncePost:async(t,s={})=>{i("siweNoncePost","siweNoncePostRequest",t);const n=new URL("/siwe/nonce",o);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}},siweVerifyPost:async(t,s={})=>{i("siweVerifyPost","siweVerifyPostRequest",t);const n=new URL("/siwe/verify",o);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}}}}(t);return{async linkSiweListWalletsGet(a){const o=await n.linkSiweListWalletsGet(a);return l(o,e,s,t)},async linkSiweNoncePost(a,o){const i=await n.linkSiweNoncePost(a,o);return l(i,e,s,t)},async linkSiweUnlinkPost(a,o){const i=await n.linkSiweUnlinkPost(a,o);return l(i,e,s,t)},async linkSiweVerifyPost(a,o){const i=await n.linkSiweVerifyPost(a,o);return l(i,e,s,t)},async siweNoncePost(a,o){const i=await n.siweNoncePost(a,o);return l(i,e,s,t)},async siweVerifyPost(a,o){const i=await n.siweVerifyPost(a,o);return l(i,e,s,t)}}};class A extends n{linkSiweListWalletsGet(e){return x(this.configuration).linkSiweListWalletsGet(e).then(e=>e(this.axios,this.basePath))}linkSiweNoncePost(e,t){return x(this.configuration).linkSiweNoncePost(e.siweNoncePostRequest,t).then(e=>e(this.axios,this.basePath))}linkSiweUnlinkPost(e,t){return x(this.configuration).linkSiweUnlinkPost(e.linkSiweUnlinkPostRequest,t).then(e=>e(this.axios,this.basePath))}linkSiweVerifyPost(e,t){return x(this.configuration).linkSiweVerifyPost(e.siweVerifyPostRequest,t).then(e=>e(this.axios,this.basePath))}siweNoncePost(e,t){return x(this.configuration).siweNoncePost(e.siweNoncePostRequest,t).then(e=>e(this.axios,this.basePath))}siweVerifyPost(e,t){return x(this.configuration).siweVerifyPost(e.siweVerifyPostRequest,t).then(e=>e(this.axios,this.basePath))}}const E=function(t){const n=function(e){return{createSession:async(t,s,n={})=>{i("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",o);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 P=c&&c.headers?c.headers:{};return l.headers={...p,...P,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,s,n,a,c,u={})=>{i("getPlayerSessions","player",t);const l=new URL("/v1/sessions",o);let p;e&&(p=e.baseOptions);const P={method:"GET",...p,...u},w={},y={};await r(w,e),void 0!==s&&(y.limit=s),void 0!==n&&(y.skip=n),void 0!==a&&(y.order=a),void 0!==t&&(y.player=t),c&&(y.expand=c),h(l,y);let m=p&&p.headers?p.headers:{};return P.headers={...w,...m,...u.headers},{url:d(l),options:P}},getSession:async(t,s,n={})=>{i("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,o);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},P={};await r(p,e),s&&(P.expand=s),h(c,P);let w=u&&u.headers?u.headers:{};return l.headers={...p,...w,...n.headers},{url:d(c),options:l}},revokeSession:async(t,s,n={})=>{i("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",o);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 P=c&&c.headers?c.headers:{};return l.headers={...p,...P,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,s,n={})=>{i("signatureSession","id",t),i("signatureSession","signatureRequest",s);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,o);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},P={};await r(P,e),await r(P,e),P["Content-Type"]="application/json",h(c,{});let w=l&&l.headers?l.headers:{};return p.headers={...P,...w,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,o,i){const r=await n.createSession(a,o,i);return l(r,e,s,t)},async getPlayerSessions(a,o,i,r,c,h){const u=await n.getPlayerSessions(a,o,i,r,c,h);return l(u,e,s,t)},async getSession(a,o,i){const r=await n.getSession(a,o,i);return l(r,e,s,t)},async revokeSession(a,o,i){const r=await n.revokeSession(a,o,i);return l(r,e,s,t)},async signatureSession(a,o,i){const r=await n.signatureSession(a,o,i);return l(r,e,s,t)}}};class U extends n{createSession(e,t){return E(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return E(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 E(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return E(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return E(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const C=function(t){const n=function(e){return{createTransactionIntent:async(t,s,n={})=>{i("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",o);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 P=c&&c.headers?c.headers:{};return l.headers={...p,...P,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,s={})=>{i("estimateTransactionIntentCost","createTransactionIntentRequest",t);const n=new URL("/v1/transaction_intents/estimate_gas_cost",o);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={})=>{i("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,o);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},P={};await r(p,e),s&&(P.expand=s),h(c,P);let w=u&&u.headers?u.headers:{};return l.headers={...p,...w,...n.headers},{url:d(c),options:l}},getTransactionIntents:async(t,s,n,a,i,c,u,l,p,P={})=>{const w=new URL("/v1/transaction_intents",o);let y;e&&(y=e.baseOptions);const m={method:"GET",...y,...P},g={},f={};await r(g,e),void 0!==t&&(f.limit=t),void 0!==s&&(f.skip=s),void 0!==n&&(f.order=n),a&&(f.expand=a),void 0!==i&&(f.chainId=i),c&&(f.account=c),u&&(f.player=u),void 0!==l&&(f.status=l),p&&(f.policy=p),h(w,f);let R=y&&y.headers?y.headers:{};return m.headers={...g,...R,...P.headers},{url:d(w),options:m}},signature:async(t,s,n={})=>{i("signature","id",t),i("signature","signatureRequest",s);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,o);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},P={};await r(P,e),await r(P,e),P["Content-Type"]="application/json",h(c,{});let w=l&&l.headers?l.headers:{};return p.headers={...P,...w,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,o,i){const r=await n.createTransactionIntent(a,o,i);return l(r,e,s,t)},async estimateTransactionIntentCost(a,o){const i=await n.estimateTransactionIntentCost(a,o);return l(i,e,s,t)},async getTransactionIntent(a,o,i){const r=await n.getTransactionIntent(a,o,i);return l(r,e,s,t)},async getTransactionIntents(a,o,i,r,c,h,u,d,p,P){const w=await n.getTransactionIntents(a,o,i,r,c,h,u,d,p,P);return l(w,e,s,t)},async signature(a,o,i){const r=await n.signature(a,o,i);return l(r,e,s,t)}}};class L extends n{createTransactionIntent(e,t){return C(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return C(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return C(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return C(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 C(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class V{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 j=({basePath:e,accessToken:t,nativeAppIdentifier:s})=>{if(!e.trim())throw Error("basePath can not be empty");const n={basePath:e,accessToken:t};return s&&(n.baseOptions={headers:{"x-native-app-identifier":s}}),new V(n)};class G{config;transactionIntentsApi;accountsApi;rpcApi;sessionsApi;emailOTPApi;userApi;anonymousApi;siweApi;smsOTPApi;authenticationApi;authenticationV2Api;storage;onLogout;axiosInstance;constructor(s){this.storage=s.storage,this.onLogout=s.onLogout,this.axiosInstance=e.create(),t(this.axiosInstance,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError}),this.setupInterceptors();const n={basePath:s.basePath,accessToken:s.accessToken,nativeAppIdentifier:s.nativeAppIdentifier};this.config={backend:j(n)};const a={basePath:`${s.basePath}/iam/v2/auth`,accessToken:s.accessToken,nativeAppIdentifier:s.nativeAppIdentifier},o=j(a);this.emailOTPApi=new S(o,void 0,this.axiosInstance),this.smsOTPApi=new v(o,void 0,this.axiosInstance),this.anonymousApi=new y(o,void 0,this.axiosInstance),this.authenticationV2Api=new b(o,void 0,this.axiosInstance),this.authenticationApi=new g(this.config.backend,void 0,this.axiosInstance),this.siweApi=new A(o,void 0,this.axiosInstance),this.userApi=new R(this.config.backend,void 0,this.axiosInstance),this.transactionIntentsApi=new L(this.config.backend,void 0,this.axiosInstance),this.accountsApi=new P(this.config.backend,void 0,this.axiosInstance),this.sessionsApi=new U(this.config.backend,void 0,this.axiosInstance),this.rpcApi=new I(this.config.backend,void 0,this.axiosInstance)}setupInterceptors(){this.axiosInstance.interceptors.response.use(e=>e,async e=>(401===e.response?.status&&(await this.clearAuthenticationState(),this.emitLogoutEvent()),Promise.reject(e)))}async clearAuthenticationState(){if(this.storage)try{this.storage.remove("openfort.authentication"),this.storage.remove("openfort.account"),this.storage.remove("openfort.session"),this.storage.remove("openfort.pkce_state"),this.storage.remove("openfort.pkce_verifier")}catch(e){}}emitLogoutEvent(){if(this.onLogout)try{this.onLogout()}catch(e){}}}export{G as BackendApiClients,j 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}},createAccountV2:async(t,n={})=>{o("createAccountV2","createAccountRequestV2",t);const s=new URL("/v2/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 R=y&&y.headers?y.headers:{};return g.headers={...w,...R,...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={},R={};await r(m,e),void 0!==t&&(R.limit=t),void 0!==n&&(R.skip=n),void 0!==s&&(R.order=s),void 0!==a&&(R.chainId=a),void 0!==o&&(R.user=o),void 0!==c&&(R.chainType=c),void 0!==u&&(R.accountType=u),void 0!==l&&(R.address=l),h(y,R);let f=g&&g.headers?g.headers:{};return w.headers={...m,...f,...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}},removeAccount:async(t,n={})=>{o("removeAccount","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:"DELETE",...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}},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 createAccountV2(a,i){const o=await s.createAccountV2(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 removeAccount(a,i){const o=await s.removeAccount(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))}createAccountV2(e,t){return p(this.configuration).createAccountV2(e.createAccountRequestV2,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))}removeAccount(e,t){return p(this.configuration).removeAccount(e.id,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{handleRpcRequest:async(t,n={})=>{o("handleRpcRequest","jsonRpcRequest",t);const s=new URL("/rpc",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}}}}(t);return{async handleRpcRequest(a,i){const o=await s.handleRpcRequest(a,i);return l(o,e,n,t)}}};class R extends s{handleRpcRequest(e,t){return m(this.configuration).handleRpcRequest(e.jsonRpcRequest,t).then(e=>e(this.axios,this.basePath))}}const f=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 f(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return f(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 f(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return f(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return f(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const T=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},R={},f={};await r(R,e),void 0!==t&&(f.limit=t),void 0!==n&&(f.skip=n),void 0!==s&&(f.order=s),a&&(f.expand=a),void 0!==o&&(f.chainId=o),c&&(f.account=c),u&&(f.player=u),void 0!==l&&(f.status=l),p&&(f.policy=p),h(g,f);let P=w&&w.headers?w.headers:{};return m.headers={...R,...P,...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 O extends s{createTransactionIntent(e,t){return T(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return T(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return T(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return T(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 T(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class b{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 v=({basePath:e,accessToken:t,nativeAppIdentifier:n})=>{if(!e.trim())throw Error("basePath can not be empty");const s={basePath:e,accessToken:t};return n&&(s.baseOptions={headers:{"x-native-app-identifier":n}}),new b(s)};class S{config;transactionIntentsApi;accountsApi;rpcApi;sessionsApi;authenticationApi;storage;onLogout;axiosInstance;constructor(n){this.storage=n.storage,this.onLogout=n.onLogout,this.axiosInstance=e.create(),t(this.axiosInstance,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError}),this.setupInterceptors();const s={basePath:n.basePath,accessToken:n.accessToken,nativeAppIdentifier:n.nativeAppIdentifier};this.config={backend:v(s)},this.transactionIntentsApi=new O(this.config.backend,void 0,this.axiosInstance),this.accountsApi=new y(this.config.backend,void 0,this.axiosInstance),this.sessionsApi=new P(this.config.backend,void 0,this.axiosInstance),this.rpcApi=new R(this.config.backend,void 0,this.axiosInstance),this.authenticationApi=new w(this.config.backend,void 0,this.axiosInstance)}setupInterceptors(){this.axiosInstance.interceptors.response.use(e=>e,async e=>(401===e.response?.status&&(await this.clearAuthenticationState(),this.emitLogoutEvent()),Promise.reject(e)))}async clearAuthenticationState(){if(this.storage)try{this.storage.remove("openfort.authentication"),this.storage.remove("openfort.account"),this.storage.remove("openfort.session"),this.storage.remove("openfort.pkce_state"),this.storage.remove("openfort.pkce_verifier")}catch(e){}}emitLogoutEvent(){if(this.onLogout)try{this.onLogout()}catch(e){}}}export{S as BackendApiClients,v as createConfig};
@@ -1 +1 @@
1
- import{Authentication as t}from"../core/configuration/authentication.js";import{OPENFORT_AUTH_ERROR_CODES as e}from"../core/errors/authErrorCodes.js";import{SessionError as i,ConfigurationError as a}from"../core/errors/openfortError.js";import{OpenfortEvents as r}from"../types/types.js";class n{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(t,e,i,a,r){this.storage=t,this.authManager=e,this.validateAndRefreshToken=i,this.ensureInitialized=a,this.eventEmitter=r}async logInWithEmailPassword({email:a,password:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"email"});try{const e=await this.authManager.loginEmailPassword(a,n);return null===e?.token||(new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async signUpGuest(){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"guest"});try{const e=await this.authManager.registerGuest();return new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async signUpWithEmailPassword({email:a,password:n,name:s,callbackURL:o}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"email"});try{const e=s||a,i=await this.authManager.signupEmailPassword(a,n,e,o);return i instanceof Object&&"action"in i||(new t("session",i.token,i.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,i)),i}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async initOAuth({provider:a,redirectTo:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"oauth",provider:a});try{return await this.authManager.initOAuth(a,n)}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async linkOAuthToAnonymous({provider:e,redirectTo:i}){await this.ensureInitialized();const a=await t.fromStorage(this.storage);if(!a)throw new Error("Must be signed in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"oauth",provider:e});try{return await this.authManager.linkOAuthToAnonymous(a,e,i)}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async logInWithIdToken({provider:a,token:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"idToken",provider:a});try{const e=await this.authManager.loginWithIdToken(a,n);return new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async storeCredentials({token:e,userId:i}){if(await this.ensureInitialized(),!i)throw new a("User ID is required to store credentials");const r=encodeURIComponent(e);new t("session",r,i).save(this.storage)}async logout(){const e=await t.fromStorage(this.storage);if(e){try{"third_party"!==e.type&&await this.authManager.logout(e)}catch(t){}t.clear(this.storage),this.eventEmitter.emit(r.ON_LOGOUT)}}async requestEmailOtp({email:a}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_OTP_REQUEST,{method:"email"});try{await this.authManager.requestEmailOTP(a)}catch(t){throw this.eventEmitter.emit(r.ON_OTP_FAILURE,t),t}}async logInWithEmailOtp({email:a,otp:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"email"});try{const e=await this.authManager.loginWithEmailOTP(a,n);return null===e?.token||(new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async requestPhoneOtp({phoneNumber:a}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_OTP_REQUEST,{method:"phone",provider:"phone"});try{await this.authManager.requestPhoneOtp(a)}catch(t){throw this.eventEmitter.emit(r.ON_OTP_FAILURE,t),t}}async logInWithPhoneOtp({phoneNumber:a,otp:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"phone"});try{const e=await this.authManager.loginWithSMSOTP(a,n);return null===e?.token||(new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async requestResetPassword({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestResetPassword(t,e)}async resetPassword({password:t,token:e}){await this.ensureInitialized(),await this.authManager.resetPassword(t,e)}async requestEmailVerification({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestEmailVerification(t,e)}async verifyEmail({token:t,callbackURL:e}){await this.ensureInitialized(),await this.authManager.verifyEmail(t,e)}async initLinkOAuth({provider:a,options:n}){await this.validateAndRefreshToken();const s=await t.fromStorage(this.storage);if(!s)throw new i(e.NOT_LOGGED_IN,"No authentication found");return this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"oauth",provider:a}),await this.authManager.linkOAuth(s,a,n)}async unlinkOAuth({provider:a}){await this.validateAndRefreshToken();const r=await t.fromStorage(this.storage);if(!r)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkOAuth(a,r)}async initSIWE({address:t,chainId:e}){return await this.ensureInitialized(),await this.authManager.initSIWE(t,e)}async linkSIWE({address:a,chainId:r}){await this.ensureInitialized();const n=await t.fromStorage(this.storage);if(!n)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkSIWE(a,n,r)}async authenticateWithSIWE({signature:a,message:n,walletClientType:s,connectorType:o,address:h,chainId:w}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"siwe"});try{const e=await this.authManager.authenticateSIWE(a,n,s,o,h,w);return new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async linkWallet({signature:a,message:r,walletClientType:n,connectorType:s,address:o,chainId:h}){await this.validateAndRefreshToken();const w=await t.fromStorage(this.storage);if(!w)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkWallet(a,r,n,s,o,h,w)}async unlinkWallet({address:a,chainId:r}){await this.validateAndRefreshToken();const n=await t.fromStorage(this.storage);if(!n)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkWallet(a,r,n)}async unlinkEmail(){await this.validateAndRefreshToken();const a=await t.fromStorage(this.storage);if(!a)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkEmail(a)}async linkEmailPassword({name:a,email:r,password:n}){await this.validateAndRefreshToken();const s=await t.fromStorage(this.storage);if(!s)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkEmail(a,r,n,s)}async unlinkEmailPassword(){await this.validateAndRefreshToken();const a=await t.fromStorage(this.storage);if(!a)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkEmail(a)}}export{n as AuthApi};
1
+ import{Authentication as t}from"../core/configuration/authentication.js";import{OpenfortError as e,OpenfortErrorType as a}from"../core/errors/openfortError.js";import{OpenfortEvents as i}from"../types/types.js";class r{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(t,e,a,i,r){this.storage=t,this.authManager=e,this.validateAndRefreshToken=a,this.ensureInitialized=i,this.eventEmitter=r}async logInWithEmailPassword({email:r,password:s,ecosystemGame:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new e("Already logged in",a.ALREADY_LOGGED_IN_ERROR);this.eventEmitter.emit(i.ON_AUTH_INIT,{method:"email",provider:"email"});try{const e=await this.authManager.loginEmailPassword(r,s,n);return"action"in e||(new t("jwt",e.token,e.player.id,e.refreshToken).save(this.storage),this.eventEmitter.emit(i.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(i.ON_AUTH_FAILURE,t),t}}async signUpGuest(){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new e("Already logged in",a.ALREADY_LOGGED_IN_ERROR);this.eventEmitter.emit(i.ON_AUTH_INIT,{method:"guest"});try{const e=await this.authManager.registerGuest();return new t("jwt",e.token,e.player.id,e.refreshToken).save(this.storage),this.eventEmitter.emit(i.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(i.ON_AUTH_FAILURE,t),t}}async signUpWithEmailPassword({email:r,password:s,options:n,ecosystemGame:o}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new e("Already logged in",a.ALREADY_LOGGED_IN_ERROR);this.eventEmitter.emit(i.ON_AUTH_INIT,{method:"email",provider:"email"});try{const e=await this.authManager.signupEmailPassword(r,s,n?.data.name,o);return"action"in e||(new t("jwt",e.token,e.player.id,e.refreshToken).save(this.storage),this.eventEmitter.emit(i.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(i.ON_AUTH_FAILURE,t),t}}async linkEmailPassword({email:t,password:e,authToken:a,ecosystemGame:i}){return await this.validateAndRefreshToken(),await this.authManager.linkEmail(t,e,a,i)}async unlinkEmailPassword({email:t,authToken:e}){return await this.validateAndRefreshToken(),await this.authManager.unlinkEmail(t,e)}async requestEmailVerification({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestEmailVerification(t,e)}async resetPassword({email:t,password:e,state:a}){await this.ensureInitialized(),await this.authManager.resetPassword(t,e,a)}async requestResetPassword({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestResetPassword(t,e)}async verifyEmail({email:t,state:e}){await this.ensureInitialized(),await this.authManager.verifyEmail(t,e)}async initOAuth({provider:r,options:s,ecosystemGame:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new e("Already logged in",a.ALREADY_LOGGED_IN_ERROR);return this.eventEmitter.emit(i.ON_AUTH_INIT,{method:"oauth",provider:r}),await this.authManager.initOAuth(r,s,n)}async initLinkOAuth({provider:r,options:s,ecosystemGame:n}){await this.validateAndRefreshToken();const o=await t.fromStorage(this.storage);if(!o)throw new e("No authentication found",a.NOT_LOGGED_IN_ERROR);return this.eventEmitter.emit(i.ON_AUTH_INIT,{method:"oauth",provider:r}),await this.authManager.linkOAuth(o,r,s,n)}async unlinkOAuth({provider:t,authToken:e}){return await this.validateAndRefreshToken(),await this.authManager.unlinkOAuth(t,e)}async poolOAuth(e){await this.ensureInitialized();try{const a=await this.authManager.poolOAuth(e);return new t("jwt",a.token,a.player.id,a.refreshToken).save(this.storage),this.eventEmitter.emit(i.ON_AUTH_SUCCESS,a),a}catch(t){throw this.eventEmitter.emit(i.ON_AUTH_FAILURE,t),t}}async loginWithIdToken({provider:r,token:s,ecosystemGame:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new e("Already logged in",a.ALREADY_LOGGED_IN_ERROR);this.eventEmitter.emit(i.ON_AUTH_INIT,{method:"idToken",provider:r});try{const e=await this.authManager.loginWithIdToken(r,s,n);return new t("jwt",e.token,e.player.id,e.refreshToken).save(this.storage),this.eventEmitter.emit(i.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(i.ON_AUTH_FAILURE,t),t}}async initSIWE({address:t,ecosystemGame:e}){return await this.ensureInitialized(),await this.authManager.initSIWE(t,e)}async authenticateWithSIWE({signature:r,message:s,walletClientType:n,connectorType:o}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new e("Already logged in",a.ALREADY_LOGGED_IN_ERROR);this.eventEmitter.emit(i.ON_AUTH_INIT,{method:"siwe",provider:"wallet"});try{const e=await this.authManager.authenticateSIWE(r,s,n,o);return new t("jwt",e.token,e.player.id,e.refreshToken).save(this.storage),this.eventEmitter.emit(i.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(i.ON_AUTH_FAILURE,t),t}}async linkWallet({signature:t,message:e,walletClientType:a,connectorType:i,authToken:r}){return await this.validateAndRefreshToken(),await this.authManager.linkWallet(t,e,a,i,r)}async unlinkWallet({address:t,authToken:e}){return await this.validateAndRefreshToken(),await this.authManager.unlinkWallet(t,e)}async storeCredentials(i){if(await this.ensureInitialized(),!i.player)throw new e("Player ID is required to store credentials",a.INVALID_CONFIGURATION);new t("jwt",i.accessToken,i.player,i.refreshToken).save(this.storage)}async logout(){const e=await t.fromStorage(this.storage);if(e){try{"third_party"!==e.type&&await this.authManager.logout(e.token,e.refreshToken??"")}catch(t){}t.clear(this.storage),this.eventEmitter.emit(i.ON_LOGOUT)}}}export{r as AuthApi};
@@ -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 s}from"../core/configuration/account.js";import{Authentication as a}from"../core/configuration/authentication.js";import{OPENFORT_AUTH_ERROR_CODES as i}from"../core/errors/authErrorCodes.js";import{ConfigurationError as n,SessionError as o,SignerError as d}from"../core/errors/openfortError.js";import{withApiError as c}from"../core/errors/withApiError.js";import{OpenfortEvents as h,RecoveryMethod as m,ChainTypeEnum as g,AccountTypeEnum as y,EmbeddedState as l}from"../types/types.js";import{debugLog as p}from"../utils/debug.js";import{EmbeddedSigner as f}from"../wallets/embedded.js";import{EvmProvider as u}from"../wallets/evm/evmProvider.js";import"../wallets/evm/types.js";import{announceProvider as A,openfortProviderInfo as w}from"../wallets/evm/provider/eip6963.js";import{signMessage as v}from"../wallets/evm/walletHelpers.js";import{IframeManager as M}from"../wallets/iframeManager.js";import{ReactNativeMessenger as E}from"../wallets/messaging/ReactNativeMessenger.js";import"../wallets/messaging/browserMessenger/backwardCompatibility.js";import I from"../wallets/messaging/browserMessenger/messengers/WindowMessenger.js";class T{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;passkeyHandler;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,s,a){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=s,this.passkeyHandler=a,this.eventEmitter.on(h.ON_LOGOUT,()=>{p("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=t.getInstance();if(!r)throw new n("Configuration not found");return new e({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey,nativeAppIdentifier:r.nativeAppIdentifier})}async getIframeManager(){if(p("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager&&this.iframeManager.hasFailed&&(p("[HANDSHAKE DEBUG] Existing iframeManager has failed, clearing for recreation"),this.messenger&&(this.messenger.destroy(),this.messenger=null),this.iframeManager=null),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,this.messenger&&(this.messenger.destroy(),this.messenger=null),this.iframeManager=null,e}}async createIframeManager(){p("[HANDSHAKE DEBUG] createIframeManager starting");const e=t.getInstance();if(!e)throw p("[HANDSHAKE DEBUG] Configuration not found"),new n("Configuration not found");let r;if(p("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)p("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger&&(p("[HANDSHAKE DEBUG] Destroying old messenger before creating new one"),this.messenger.destroy()),this.messenger=new E(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),s=new URL(e.iframeUrl).origin;r=new I({remoteWindow:t.contentWindow,allowedOrigins:[s]}),p("[HANDSHAKE DEBUG] Created WindowMessenger")}return p("[HANDSHAKE DEBUG] Creating IframeManager instance"),new M(e,this.storage,r)}async ensureSigner(){if(this.iframeManager&&this.iframeManager.hasFailed&&(p("IframeManager has failed, clearing signer for recreation"),this.signer=null),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 f(e,this.storage,this.backendApiClients,this.passkeyHandler,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new n("Document is not available. Please provide a message poster for non-browser environments.");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 a.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:r.userId})}async getEntropy(e){switch(e.recoveryMethod){case m.PASSWORD:return{recoveryPassword:e.password};case m.AUTOMATIC:return{encryptionSession:e.encryptionSession};case m.PASSKEY:return{passkey:e.passkeyInfo?{id:e.passkeyInfo.passkeyId,key:e.passkeyInfo.passkeyKey||await this.getPasskeyKey(e.passkeyInfo.passkeyId)}:{}};default:throw new n("Invalid recovery method")}}async configure(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:m.AUTOMATIC},[t,i,n]=await Promise.all([a.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(r)]),o={chainId:e.chainId,entropy:n,accountType:e.accountType??y.SMART_ACCOUNT,chainType:e.chainType??g.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},d=await i.configure(o);return{id:d.id,chainId:d.chainId,user:t.userId,address:d.address,ownerAddress:d.ownerAddress,chainType:d.chainType,accountType:d.accountType,implementationType:d.implementationType,factoryAddress:d.factoryAddress,salt:d.salt,createdAt:d.createdAt,implementationAddress:d.implementationAddress,recoveryMethod:s.parseRecoveryMethod(d.recoveryMethod),recoveryMethodDetails:d.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:m.AUTOMATIC},n=await a.fromStorage(this.storage);if(!n)throw new o(i.NOT_LOGGED_IN,"missing authentication");if(t.recoveryMethod===m.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:n?.userId});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}),y={id:g.id,chainId:g.chainId,user:n.userId,address:g.address,ownerAddress:g.ownerAddress,chainType:g.chainType,accountType:g.accountType,implementationType:g.implementationType,factoryAddress:g.factoryAddress,salt:g.salt,createdAt:g.createdAt,implementationAddress:g.implementationAddress,recoveryMethod:s.parseRecoveryMethod(g.recoveryMethod),recoveryMethodDetails:g.recoveryMethodDetails};return this.eventEmitter.emit(h.ON_EMBEDDED_WALLET_CREATED,y),y}async recover(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:m.AUTOMATIC};if(r.recoveryMethod===m.PASSKEY){if(!r.passkeyInfo?.passkeyId)throw new n("Passkey ID must be provided for passkey recovery");r.passkeyInfo={passkeyId:r.passkeyInfo.passkeyId}}const[t,i,o]=await Promise.all([this.ensureSigner(),this.getEntropy(r),a.fromStorage(this.storage)]),d=await t.recover({account:e.account,entropy:i}),c={id:d.id,chainId:d.chainId,user:o.userId,address:d.address,ownerAddress:d.ownerAddress,chainType:d.chainType,accountType:d.accountType,implementationType:d.implementationType,createdAt:d.createdAt,recoveryMethod:s.parseRecoveryMethod(d.recoveryMethod),recoveryMethodDetails:d.recoveryMethodDetails};return this.eventEmitter.emit(h.ON_EMBEDDED_WALLET_RECOVERED,c),c}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:a=!0,arrayifyMessage:i=!1}=r||{},n=await s.fromStorage(this.storage);return await t.sign(e,i,a,n?.chainType)}async signTypedData(e,r,t){await this.validateAndRefreshToken();const a=await this.ensureSigner(),n=await s.fromStorage(this.storage);if(!n)throw new d(i.MISSING_SIGNER,"No account found");const o={...r};delete o.EIP712Domain;const{_TypedDataEncoder:c}=await import("@ethersproject/hash"),h=c.hash(e,o,t);return await v({hash:h,implementationType:n.implementationType||n.type,chainId:Number(n.chainId),signer:a,address:n.address,ownerAddress:n.ownerAddress,factoryAddress:n.factoryAddress,salt:n.salt})}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setRecoveryMethod(e,t){await this.validateAndRefreshToken();const d=await this.ensureSigner(),c=await a.fromStorage(this.storage);if(!c)throw new o(i.NOT_LOGGED_IN,"missing authentication");let h,g,y,l;if(e.recoveryMethod===m.PASSKEY){const e=await s.fromStorage(this.storage);if(!e)throw new n("missing account");const r=e?.recoveryMethodDetails?.passkeyId;if(!r)throw new n("missing passkey id for account");y={passkeyId:r,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:r,seed:c.userId})}}else if(t.recoveryMethod===m.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:c.userId});y={passkeyId:e.id,passkeyKey:e.key},l={passkeyId:e.id}}if(e.recoveryMethod===m.PASSWORD?h=e.password:t.recoveryMethod===m.PASSWORD&&(h=t.password),e.recoveryMethod===m.AUTOMATIC?g=e.encryptionSession:t.recoveryMethod===m.AUTOMATIC&&(g=t.encryptionSession),!h&&!g)throw new n("Password or encryption session is not provided");await d.setRecoveryMethod({recoveryMethod:t.recoveryMethod,recoveryPassword:h,encryptionSession:g,passkeyInfo:y});const p=await s.fromStorage(this.storage);p&&new s({...p,recoveryMethod:t.recoveryMethod,recoveryMethodDetails:l}).save(this.storage)}async get(){const e=await s.fromStorage(this.storage);if(!e)throw new d(i.MISSING_SIGNER,"No signer configured");const r=await a.fromStorage(this.storage);if(!r)throw new o(i.NOT_LOGGED_IN,"No access token found");return{id:e.id,chainId:e.chainId,user:r.userId,address:e.address,ownerAddress:e.ownerAddress,factoryAddress:e.factoryAddress,salt:e.salt,chainType:e.chainType,accountType:e.accountType,implementationAddress:e.implementationAddress,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:s.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const r={accountType:y.SMART_ACCOUNT,...e},d=t.getInstance();if(!d)throw new n("Configuration not found");const h=await a.fromStorage(this.storage);if(!h)throw new o(i.NOT_LOGGED_IN,"No access token found");return await this.validateAndRefreshToken(),c(async()=>(await this.backendApiClients.accountsApi.getAccountsV2(r,{headers:h.thirdPartyProvider?{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":h.token,"x-auth-provider":h.thirdPartyProvider,"x-token-type":h.thirdPartyTokenType}:{authorization:`Bearer ${h.token}`,"x-project-key":d.baseConfiguration.publishableKey}})).data.data.map(e=>({user:e.user,chainType:e.chainType,id:e.id,address:e.address,active:e.smartAccount?.active,ownerAddress:e.ownerAddress,factoryAddress:e.smartAccount?.factoryAddress,salt:e.smartAccount?.salt,accountType:e.accountType,implementationAddress:e.smartAccount?.implementationAddress,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:s.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{context:"list"})}async getEmbeddedState(){try{if(!await a.fromStorage(this.storage))return l.UNAUTHENTICATED;return await s.fromStorage(this.storage)?l.READY:l.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return p("Failed to get embedded state:",e),l.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},t=await a.fromStorage(this.storage),i=await s.fromStorage(this.storage);return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new u({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&&A({info:{...w,...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 a.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.userId),!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 n("Configuration not found");return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new n("Invalid message poster");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{T as EmbeddedWalletApi};
1
+ import{BackendApiClients as e}from"../../../packages/internal/openapi-clients/dist/index.js";import{PasskeyHandler as t}from"../core/configuration/passkey.js";import{SDKConfiguration as r}from"../core/config/config.js";import{Account as s}from"../core/configuration/account.js";import{Authentication as a}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,ChainTypeEnum as h,AccountTypeEnum as m,EmbeddedState as g}from"../types/types.js";import{debugLog as y}from"../utils/debug.js";import{EmbeddedSigner as l}from"../wallets/embedded.js";import{EvmProvider as p}from"../wallets/evm/evmProvider.js";import"../wallets/evm/types.js";import{announceProvider as f,openfortProviderInfo as A}from"../wallets/evm/provider/eip6963.js";import{signMessage as u}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,t,r,s,a){this.storage=e,this.validateAndRefreshToken=t,this.ensureInitialized=r,this.eventEmitter=s,this.passkeyHandler=a,this.eventEmitter.on(d.ON_LOGOUT,()=>{y("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const t=r.getInstance();if(!t)throw new i("Configuration not found",n.INVALID_CONFIGURATION);return new e({basePath:t.backendUrl,accessToken:t.baseConfiguration.publishableKey,nativeAppIdentifier:t.nativeAppIdentifier})}async getIframeManager(){if(y("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager&&this.iframeManager.hasFailed&&(y("[HANDSHAKE DEBUG] Existing iframeManager has failed, clearing for recreation"),this.messenger&&(this.messenger.destroy(),this.messenger=null),this.iframeManager=null),this.iframeManager)return y("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return y("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;y("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return y("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,y("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw y("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,this.messenger&&(this.messenger.destroy(),this.messenger=null),this.iframeManager=null,e}}async createIframeManager(){y("[HANDSHAKE DEBUG] createIframeManager starting");const e=r.getInstance();if(!e)throw y("[HANDSHAKE DEBUG] Configuration not found"),new i("Configuration not found",n.INVALID_CONFIGURATION);let t;if(y("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)y("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger&&(y("[HANDSHAKE DEBUG] Destroying old messenger before creating new one"),this.messenger.destroy()),this.messenger=new I(this.messagePoster),y("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),t=this.messenger;else{y("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const r=this.createIframe(e.iframeUrl),s=new URL(e.iframeUrl).origin;t=new v({remoteWindow:r.contentWindow,allowedOrigins:[s]}),y("[HANDSHAKE DEBUG] Created WindowMessenger")}return y("[HANDSHAKE DEBUG] Creating IframeManager instance"),new w(e,this.storage,t)}async ensureSigner(){if(this.iframeManager&&this.iframeManager.hasFailed&&(y("IframeManager has failed, clearing signer for recreation"),this.signer=null),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 l(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 t=document.getElementById("openfort-iframe");t&&t.remove();const r=document.createElement("iframe");return r.style.display="none",r.id="openfort-iframe",r.src=e,document.body.appendChild(r),r}async getPasskeyKey(e){const t=await a.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:t.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 t=e.recoveryParams??{recoveryMethod:c.AUTOMATIC},[r,i,n]=await Promise.all([a.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(t)]),o={chainId:e.chainId,entropy:n,accountType:e.accountType??m.SMART_ACCOUNT,chainType:e.chainType??h.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},d=await i.configure(o);return{id:d.id,chainId:d.chainId,user:r.player,address:d.address,ownerAddress:d.ownerAddress,chainType:d.chainType,accountType:d.accountType,implementationType:d.implementationType,factoryAddress:d.factoryAddress,salt:d.salt,createdAt:d.createdAt,implementationAddress:d.implementationAddress,recoveryMethod:s.parseRecoveryMethod(d.recoveryMethod),recoveryMethodDetails:d.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:c.AUTOMATIC},o=await a.fromStorage(this.storage);if(!o)throw new i("missing authentication",n.AUTHENTICATION_ERROR);if(r.recoveryMethod===c.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:t.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:o?.player??""});r.passkeyInfo={passkeyId:e.id,passkeyKey:e.key}}const[h,m]=await Promise.all([this.ensureSigner(),this.getEntropy(r)]),g=await h.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:m}),y={id:g.id,chainId:g.chainId,user:o.player,address:g.address,ownerAddress:g.ownerAddress,chainType:g.chainType,accountType:g.accountType,implementationType:g.implementationType,factoryAddress:g.factoryAddress,salt:g.salt,createdAt:g.createdAt,implementationAddress:g.implementationAddress,recoveryMethod:s.parseRecoveryMethod(g.recoveryMethod),recoveryMethodDetails:g.recoveryMethodDetails};return this.eventEmitter.emit(d.ON_EMBEDDED_WALLET_CREATED,y),y}async recover(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:c.AUTOMATIC};if(t.recoveryMethod===c.PASSKEY){if(!t.passkeyInfo?.passkeyId)throw new i("Passkey ID must be provided for passkey recovery",n.INVALID_CONFIGURATION);t.passkeyInfo={passkeyId:t.passkeyInfo.passkeyId}}const[r,o,h]=await Promise.all([this.ensureSigner(),this.getEntropy(t),a.fromStorage(this.storage)]),m=await r.recover({account:e.account,entropy:o}),g={id:m.id,chainId:m.chainId,implementationAddress:m.implementationAddress,factoryAddress:m.factoryAddress,salt:m.salt,user:h.player,address:m.address,ownerAddress:m.ownerAddress,chainType:m.chainType,accountType:m.accountType,implementationType:m.implementationType,createdAt:m.createdAt,recoveryMethod:s.parseRecoveryMethod(m.recoveryMethod),recoveryMethodDetails:m.recoveryMethodDetails};return this.eventEmitter.emit(d.ON_EMBEDDED_WALLET_RECOVERED,g),g}async signMessage(e,t){await this.validateAndRefreshToken();const r=await this.ensureSigner(),{hashMessage:a=!0,arrayifyMessage:i=!1}=t||{},n=await s.fromStorage(this.storage);return await r.sign(e,i,a,n?.chainType)}async signTypedData(e,t,r){await this.validateAndRefreshToken();const a=await this.ensureSigner(),o=await s.fromStorage(this.storage);if(!o)throw new i("No account found",n.MISSING_SIGNER_ERROR);const d={...t};delete d.EIP712Domain;const{_TypedDataEncoder:c}=await import("@ethersproject/hash"),h=c.hash(e,d,r);return await u({hash:h,implementationType:o.implementationType||o.type,chainId:Number(o.chainId),signer:a,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,r){await this.validateAndRefreshToken();const o=await this.ensureSigner(),d=await a.fromStorage(this.storage);if(!d)throw new i("missing authentication",n.AUTHENTICATION_ERROR);let h,m,g,y;if(e.recoveryMethod===c.PASSKEY){const e=await s.fromStorage(this.storage);if(!e)throw new i("missing account",n.INVALID_CONFIGURATION);const t=e?.recoveryMethodDetails?.passkeyId;if(!t)throw new i("missing passkey id for account",n.INVALID_CONFIGURATION);g={passkeyId:t,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:t,seed:d.player})}}else if(r.recoveryMethod===c.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:t.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:d.player});g={passkeyId:e.id,passkeyKey:e.key},y={passkeyId:e.id}}if(e.recoveryMethod===c.PASSWORD?h=e.password:r.recoveryMethod===c.PASSWORD&&(h=r.password),e.recoveryMethod===c.AUTOMATIC?m=e.encryptionSession:r.recoveryMethod===c.AUTOMATIC&&(m=r.encryptionSession),!h&&!m)throw new i("Password or encryption session is not provided",n.INVALID_CONFIGURATION);await o.setRecoveryMethod({recoveryMethod:r.recoveryMethod,recoveryPassword:h,encryptionSession:m,passkeyInfo:g});const l=await s.fromStorage(this.storage);l&&new s({...l,recoveryMethod:r.recoveryMethod,recoveryMethodDetails:y}).save(this.storage)}async get(){const e=await s.fromStorage(this.storage);if(!e)throw new i("No signer configured",n.MISSING_SIGNER_ERROR);const t=await a.fromStorage(this.storage);if(!t)throw new i("No access token found",n.NOT_LOGGED_IN_ERROR);return{id:e.id,chainId:e.chainId,user:t.player,address:e.address,ownerAddress:e.ownerAddress,factoryAddress:e.factoryAddress,salt:e.salt,chainType:e.chainType,accountType:e.accountType,implementationAddress:e.implementationAddress,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:s.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const t={accountType:m.SMART_ACCOUNT,...e},d=r.getInstance();if(!d)throw new i("Configuration not found",n.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const c=await a.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(t,{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,active:e.smartAccount?.active,ownerAddress:e.ownerAddress,factoryAddress:e.smartAccount?.factoryAddress,salt:e.smartAccount?.salt,accountType:e.accountType,implementationAddress:e.smartAccount?.implementationAddress,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:s.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{default:n.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await a.fromStorage(this.storage))return g.UNAUTHENTICATED;return await s.fromStorage(this.storage)?g.READY:g.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return y("Failed to get embedded state:",e),g.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const t={announceProvider:!0,...e},r=await a.fromStorage(this.storage),i=await s.fromStorage(this.storage);return this.provider?this.provider&&t.policy&&this.provider.updatePolicy(t.policy):(this.provider=new p({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:i||void 0,authentication:r||void 0,backendApiClients:this.backendApiClients,policyId:t.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:t.chains}),t.announceProvider&&f({info:{...A,...t.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(t=>{setTimeout(t,e)});const t=await this.getIframeManager();if(!t.isLoaded())return!1;const r=await a.fromStorage(this.storage);if(r)try{return await t.getCurrentDevice(r.player),!0}catch(e){return!1}return t.isLoaded()}catch(e){return y("Ping failed:",e),!1}}getURL(){const e=r.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 y("Invalid message received:",e);y("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const t="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(t&&this.messenger&&this.messagePoster)return y("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const r=await this.getIframeManager();y(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${r.isLoaded()}`),t&&!r.isLoaded()&&y("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),y("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await r.onMessage(e),y("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}}export{M as EmbeddedWalletApi};
@@ -1 +1 @@
1
- import{SDKConfiguration as n}from"../core/config/config.js";import{OPENFORT_AUTH_ERROR_CODES as t}from"../core/errors/authErrorCodes.js";import{ConfigurationError as i,SignerError as e}from"../core/errors/openfortError.js";import{withApiError as s}from"../core/errors/withApiError.js";class r{backendApiClients;validateAndRefreshToken;ensureInitialized;getSignerSignFunction;constructor(n,t,i,e,s){this.backendApiClients=t,this.validateAndRefreshToken=i,this.ensureInitialized=e,this.getSignerSignFunction=s}async sendSignatureTransactionIntentRequest(r,a=null,o=null,u=!1){await this.ensureInitialized();if(!n.getInstance())throw new i("Configuration not found");await this.validateAndRefreshToken();let c=o;if(!c){if(!a)throw new i("No signableHash or signature provided");if(!this.getSignerSignFunction)throw new e(t.MISSING_SIGNER,"In order to sign a transaction intent, a signer must be configured");const n=await this.getSignerSignFunction();c=await n(a)}const g={id:r,signatureRequest:{signature:c,optimistic:u}};return s(async()=>(await this.backendApiClients.transactionIntentsApi.signature(g)).data,{context:"sendSignatureTransactionIntentRequest"})}async sendSignatureSessionRequest(n,t,i){await this.ensureInitialized();const e={id:n,signatureRequest:{signature:t,optimistic:i}};return s(async()=>(await this.backendApiClients.sessionsApi.signatureSession(e)).data,{context:"sendSignatureSessionRequest"})}}export{r as ProxyApi};
1
+ import{SDKConfiguration as i}from"../core/config/config.js";import{OpenfortError as n,OpenfortErrorType as t,withOpenfortError as e}from"../core/errors/openfortError.js";class s{backendApiClients;validateAndRefreshToken;ensureInitialized;getSignerSignFunction;constructor(i,n,t,e,s){this.backendApiClients=n,this.validateAndRefreshToken=t,this.ensureInitialized=e,this.getSignerSignFunction=s}async sendSignatureTransactionIntentRequest(s,a=null,r=null,o=!1){await this.ensureInitialized();if(!i.getInstance())throw new n("Configuration not found",t.INVALID_CONFIGURATION);await this.validateAndRefreshToken();let u=r;if(!u){if(!a)throw new n("No signableHash or signature provided",t.OPERATION_NOT_SUPPORTED_ERROR);if(!this.getSignerSignFunction)throw new n("In order to sign a transaction intent, a signer must be configured",t.MISSING_SIGNER_ERROR);const i=await this.getSignerSignFunction();u=await i(a)}const c={id:s,signatureRequest:{signature:u,optimistic:o}};return e(async()=>(await this.backendApiClients.transactionIntentsApi.signature(c)).data,{default:t.INTERNAL_ERROR})}async sendSignatureSessionRequest(i,n,s){await this.ensureInitialized();const a={id:i,signatureRequest:{signature:n,optimistic:s}};return e(async()=>(await this.backendApiClients.sessionsApi.signatureSession(a)).data,{default:t.INTERNAL_ERROR})}}export{s as ProxyApi};
@@ -1 +1 @@
1
- import{Authentication as t}from"../core/configuration/authentication.js";import{OPENFORT_AUTH_ERROR_CODES as r}from"../core/errors/authErrorCodes.js";import{SessionError as a}from"../core/errors/openfortError.js";class e{storage;authManager;validateAndRefreshToken;constructor(t,r,a){this.storage=t,this.authManager=r,this.validateAndRefreshToken=a}async get(){await this.validateAndRefreshToken();const e=await t.fromStorage(this.storage);if(!e)throw new a(r.NOT_LOGGED_IN,"No access token found");return await this.authManager.getUser(e)}async list(){await this.validateAndRefreshToken();const e=await t.fromStorage(this.storage);if(!e)throw new a(r.NOT_LOGGED_IN,"No access token found");return await this.authManager.listAccounts(e)}}export{e as UserApi};
1
+ import{Authentication as t}from"../core/configuration/authentication.js";import{OpenfortError as e,OpenfortErrorType as r}from"../core/errors/openfortError.js";class a{storage;authManager;validateAndRefreshToken;constructor(t,e,r){this.storage=t,this.authManager=e,this.validateAndRefreshToken=r}async get(){await this.validateAndRefreshToken();const a=await t.fromStorage(this.storage);if(!a)throw new e("No access token found",r.NOT_LOGGED_IN_ERROR);return await this.authManager.getUser(a)}}export{a as UserApi};
@@ -1 +1 @@
1
- import{debugLog as e}from"../utils/debug.js";import{OPENFORT_AUTH_ERROR_CODES as t}from"../core/errors/authErrorCodes.js";import{ConfigurationError as i,OpenfortError as a}from"../core/errors/openfortError.js";import{withApiError as n}from"../core/errors/withApiError.js";import{AuthActionRequiredActions as s}from"../types/types.js";function r(e){if(!e)throw new a(t.INTERNAL_ERROR,"User data is missing");return{id:e.id||"",email:e.email,name:e.name??void 0,image:e.image??void 0,emailVerified:e.emailVerified,isAnonymous:e.isAnonymous,createdAt:e.createdAt,updatedAt:e.updatedAt}}function o(e){if(e)return{id:e.id,token:e.token,userId:e.userId,expiresAt:e.expiresAt,createdAt:e.createdAt,updatedAt:e.updatedAt}}class c{backendApiClientsInstance;publishableKeyInstance;setBackendApiClients(e,t){this.backendApiClientsInstance=e,this.publishableKeyInstance=t}get backendApiClients(){if(!this.backendApiClientsInstance)throw new i("Backend API clients not initialized");return this.backendApiClientsInstance}get publishableKey(){if(!this.publishableKeyInstance)throw new i("Publishable key not initialized");return this.publishableKeyInstance}async initOAuth(e,t){return await n(async()=>(await this.backendApiClients.authenticationV2Api.socialSignIn({socialSignInRequest:{provider:e,callbackURL:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data.url||"",{context:"initOAuth"})}async linkOAuthToAnonymous(e,t,i){return await n(async()=>(await this.backendApiClients.authenticationV2Api.socialSignIn({socialSignInRequest:{provider:t,callbackURL:i}},{headers:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data.url||"",{context:"initOAuth"})}async registerGuest(){return n(async()=>{const e=await this.backendApiClients.anonymousApi.signInAnonymousPost({headers:{"x-project-key":`${this.publishableKey}`}});return{token:e.data.token,user:r(e.data.user)}},{context:"registerGuest"})}async loginWithIdToken(e,t){const i={socialSignInRequest:{provider:e,token:t}};return await n(async()=>{const e=await this.backendApiClients.authenticationV2Api.socialSignIn(i);return{token:e.data.token,user:r(e.data.user)}},{context:"loginWithIdToken"})}async authenticateThirdParty(e,t,i){const a={thirdPartyOAuthRequest:{provider:e,token:t,tokenType:i}};return n(async()=>({userId:(await this.backendApiClients.authenticationApi.thirdParty(a,{headers:{"x-project-key":`${this.publishableKey}`}})).data.id}),{context:"authenticateThirdParty"})}async initSIWE(e,t){const i={siweNoncePostRequest:{walletAddress:e,chainId:t||1}};return{address:e,nonce:(await n(async()=>this.backendApiClients.siweApi.siweNoncePost(i,{headers:{"x-project-key":`${this.publishableKey}`}}),{context:"initSIWE"})).data.nonce}}async linkSIWE(e,t,i){const a={siweNoncePostRequest:{walletAddress:e,chainId:i||1}};return{address:e,nonce:(await n(async()=>this.backendApiClients.siweApi.linkSiweNoncePost(a,{headers:{authorization:`Bearer ${t.token}`,"x-project-key":`${this.publishableKey}`}}),{context:"linkSIWE"})).data.nonce}}async authenticateSIWE(e,t,i,a,s,o){const c={siweVerifyPostRequest:{signature:e,walletAddress:s,chainId:o||1,message:t,walletClientType:i,connectorType:a}};return n(async()=>{const e=await this.backendApiClients.siweApi.siweVerifyPost(c,{headers:{"x-project-key":`${this.publishableKey}`}}),t=e.data.user;return{token:e.data.token,user:r(t)}},{context:"authenticateSIWE"})}async loginEmailPassword(e,t){return n(async()=>{const i=(await this.backendApiClients.authenticationV2Api.signInEmailPost({signInEmailPostRequest:{email:e,password:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:r(i.user)}},{context:"loginEmailPassword"})}async requestResetPassword(e,t){await n(async()=>{await this.backendApiClients.authenticationV2Api.requestPasswordResetPost({forgetPasswordPostRequest:{email:e,redirectTo:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"requestResetPassword"})}async resetPassword(e,t){return n(async()=>{await this.backendApiClients.authenticationV2Api.resetPasswordPost({resetPasswordPostRequest:{newPassword:e,token:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"resetPassword"})}async requestEmailVerification(e,t){await n(async()=>{await this.backendApiClients.authenticationV2Api.sendVerificationEmailPost({sendVerificationEmailPostRequest:{email:e,callbackURL:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"requestEmailVerification"})}async verifyEmail(e,t){return n(async()=>{await this.backendApiClients.authenticationV2Api.verifyEmailGet({token:e,callbackURL:t})},{context:"verifyEmail"})}async signupEmailPassword(e,t,i,a){return n(async()=>{const n=(await this.backendApiClients.authenticationV2Api.signUpEmailPost({signUpEmailPostRequest:{email:e,password:t,name:i,callbackURL:a}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return n.token?{token:n.token,user:r(n.user)}:{action:s.ACTION_VERIFY_EMAIL}},{context:"signupEmailPassword"})}async validateCredentials(t,i){e("Validating credentials with token:",t.token);const a=await this.getSessionWithToken(t,i);return{token:a.session.token,user:r(a.user),session:o(a.session)}}async logout(e){return n(async()=>{await this.backendApiClients.authenticationV2Api.signOutPost(void 0,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})},{context:"logout"})}async getUser(e){return n(async()=>r((await this.backendApiClients.userApi.meV2({headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data),{context:"getUser"})}async listAccounts(e){return n(async()=>(await this.backendApiClients.authenticationV2Api.listAccountsGet({headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"listAccounts"})}async linkOAuth(e,t,i){const a=i?.skipBrowserRedirect??!1,s={linkSocialPostRequest:{provider:t,callbackURL:i?.redirectTo,scopes:i?.scopes?.split(" "),disableRedirect:a}},r=await n(async()=>this.backendApiClients.authenticationV2Api.linkSocialPost(s,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}}),{context:"linkOAuth"});return"undefined"!=typeof window&&!a&&r.data.url&&window.location.assign(r.data.url),r.data.url||""}async unlinkOAuth(e,t){const i={unlinkAccountPostRequest:{providerId:e}};return n(async()=>(await this.backendApiClients.authenticationV2Api.unlinkAccountPost(i,{headers:t.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":t.token,"x-auth-provider":t.thirdPartyProvider,"x-token-type":t.thirdPartyTokenType}:{authorization:`Bearer ${t.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"unlinkOAuth"})}async linkEmail(e,t,i,a){const s={signUpEmailPostRequest:{name:e,email:t,password:i}};return n(async()=>{const e=await this.backendApiClients.authenticationV2Api.signUpEmailPost(s,{headers:a.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":a.token,"x-auth-provider":a.thirdPartyProvider,"x-token-type":a.thirdPartyTokenType}:{authorization:`Bearer ${a.token}`,"x-project-key":`${this.publishableKey}`}});return{token:e.data.token,user:r(e.data.user)}},{context:"linkEmail"})}async unlinkEmail(e){const t={unlinkAccountPostRequest:{providerId:"credential"}};return n(async()=>(await this.backendApiClients.authenticationV2Api.unlinkAccountPost(t,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data.status,{context:"unlinkEmail"})}async unlinkWallet(e,t,i){const a={linkSiweUnlinkPostRequest:{walletAddress:e,chaindId:t}};return n(async()=>(await this.backendApiClients.siweApi.linkSiweUnlinkPost(a,{headers:i.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}:{authorization:`Bearer ${i.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"unlinkWallet"})}async linkWallet(e,t,i,a,s,r,o){const c={siweVerifyPostRequest:{signature:e,message:t,walletAddress:s,chainId:r,walletClientType:i,connectorType:a}};return n(async()=>(await this.backendApiClients.siweApi.linkSiweVerifyPost(c,{headers:o.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":o.token,"x-auth-provider":o.thirdPartyProvider,"x-token-type":o.thirdPartyTokenType}:{authorization:`Bearer ${o.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"linkWallet"})}async requestEmailOTP(e){const t={emailOtpSendVerificationOtpPostRequest:{email:e,type:"sign-in"}};await n(async()=>(await this.backendApiClients.emailOTPApi.emailOtpSendVerificationOtpPost(t,{headers:{"x-project-key":`${this.publishableKey}`}})).data,{context:"requestEmailOTP"})}async loginWithEmailOTP(e,t){return await n(async()=>{const i=(await this.backendApiClients.emailOTPApi.signInEmailOtpPost({signInEmailOtpPostRequest:{email:e,otp:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:r(i.user)}},{context:"loginWithEmailOTP"})}async requestPhoneOtp(e){const t={phoneNumberSendOtpPostRequest:{phoneNumber:e}};await n(async()=>(await this.backendApiClients.smsOTPApi.phoneNumberSendOtpPost(t,{headers:{"x-project-key":`${this.publishableKey}`}})).data,{context:"requestPhoneOtp"})}async loginWithSMSOTP(e,t){return await n(async()=>{const i=(await this.backendApiClients.smsOTPApi.phoneNumberVerifyPost({phoneNumberVerifyPostRequest:{code:t,phoneNumber:e}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:r(i.user)}},{context:"loginWithSMSOTP"})}async getSessionWithToken(e,t){return await n(async()=>(await this.backendApiClients.authenticationV2Api.getSessionGet({disableCookieCache:t},{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"getSessionWithToken"})}}export{c as AuthManager};
1
+ import{base64url as e,decodeJwt as t}from"jose";import{debugLog as a}from"../utils/debug.js";import{OpenfortError as i,OpenfortErrorType as n,withOpenfortError as s}from"../core/errors/openfortError.js";import{sentry as r}from"../core/errors/sentry.js";import{StorageKeys as o}from"../storage/istorage.js";import{CodeChallengeMethodEnum as c}from"../types/types.js";import{cryptoDigest as d}from"../utils/crypto.js";async function l(e){const t=(new TextEncoder).encode(e),a=await d("SHA-256",t);return new Uint8Array(a)}function u(e){const t=new Uint8Array(e);return crypto.getRandomValues(t),t}class h{decodedPayload;value;constructor(e){this.value=e;try{this.decodedPayload=t(e)}catch(e){throw new i("Invalid token format",n.AUTHENTICATION_ERROR)}}get subject(){return this.decodedPayload.sub}get expiration(){return this.decodedPayload.exp}get issuer(){return this.decodedPayload.iss}isExpired(e=30){return!this.expiration||(a("Token expiration:",1e3*(this.expiration-e),"Current time:",Date.now()),Date.now()>=1e3*(this.expiration-e))}static parse(e){try{return new h(e)}catch{return null}}}class p{storage;constructor(e){this.storage=e}async savePKCEData(e){this.storage.save(o.PKCE_STATE,e.state),this.storage.save(o.PKCE_VERIFIER,e.verifier)}async getPKCEData(){const e=await this.storage.get(o.PKCE_STATE),t=await this.storage.get(o.PKCE_VERIFIER);return e&&t?{state:e,verifier:t}:null}async clearPKCEData(){this.storage.remove(o.PKCE_STATE),this.storage.remove(o.PKCE_VERIFIER)}}class E{deviceCredentialsManager;backendApiClientsInstance;publishableKeyInstance;constructor(e){this.deviceCredentialsManager=new p(e)}setBackendApiClients(e,t){this.backendApiClientsInstance=e,this.publishableKeyInstance=t}get backendApiClients(){if(!this.backendApiClientsInstance)throw new i("Backend API clients not initialized",n.INTERNAL_ERROR);return this.backendApiClientsInstance}get publishableKey(){if(!this.publishableKeyInstance)throw new i("Publishable key not initialized",n.INTERNAL_ERROR);return this.publishableKeyInstance}async initOAuth(e,t,a){const i=t?.usePooling??!1,r=t?.skipBrowserRedirect??!1,{usePooling:o,skipBrowserRedirect:c,...d}=t||{},l={oAuthInitRequest:{provider:e,options:d,usePooling:i}},u=await s(async()=>this.backendApiClients.authenticationApi.initOAuth(l,E.getEcosystemGameOptsOrUndefined(a)),{default:n.AUTHENTICATION_ERROR});return"undefined"==typeof window||r||window.location.assign(u.data.url),{url:u.data.url,key:u.data.key}}async registerGuest(){const e={};return s(async()=>(await this.backendApiClients.authenticationApi.registerGuest(e)).data,{default:n.USER_REGISTRATION_ERROR})}async poolOAuth(e){const t={key:e};for(let e=0;e<600;e++)try{const e=await s(async()=>this.backendApiClients.authenticationApi.poolOAuth(t),{default:n.AUTHENTICATION_ERROR});if(200===e.status)return e.data}catch(e){if(e.response&&404===e.response.status){await new Promise(e=>{setTimeout(e,500)});continue}throw e}throw new Error("Failed to pool OAuth, try again later")}async loginWithIdToken(e,t,a){const i={loginWithIdTokenRequest:{provider:e,token:t}};return s(async()=>(await this.backendApiClients.authenticationApi.loginWithIdToken(i,E.getEcosystemGameOptsOrUndefined(a))).data,{default:n.AUTHENTICATION_ERROR,401:n.AUTHENTICATION_ERROR,403:n.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{r.captureAxiosError("loginWithIdToken",e)})}async authenticateThirdParty(e,t,a,i){const o={thirdPartyOAuthRequest:{provider:e,token:t,tokenType:a}};return s(async()=>(await this.backendApiClients.authenticationApi.thirdParty(o,E.getEcosystemGameOptsOrUndefined(i))).data,{default:n.AUTHENTICATION_ERROR,401:n.AUTHENTICATION_ERROR,403:n.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{r.captureAxiosError("authenticateThirdParty",e)})}async initSIWE(e,t){const a={sIWERequest:{address:e}},i=await s(async()=>this.backendApiClients.authenticationApi.initSIWE(a,E.getEcosystemGameOptsOrUndefined(t)),{default:n.AUTHENTICATION_ERROR});return{address:i.data.address,nonce:i.data.nonce,expiresAt:i.data.expiresAt}}async authenticateSIWE(e,t,a,i){const o={sIWEAuthenticateRequest:{signature:e,message:t,walletClientType:a,connectorType:i}};return s(async()=>(await this.backendApiClients.authenticationApi.authenticateSIWE(o)).data,{default:n.AUTHENTICATION_ERROR,401:n.AUTHENTICATION_ERROR,403:n.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{r.captureAxiosError("authenticateSIWE",e)})}static getEcosystemGameOptsOrUndefined(e){if(e)return{headers:{"x-game":e}}}async loginEmailPassword(e,t,a){const i={loginRequest:{email:e,password:t}};return s(async()=>(await this.backendApiClients.authenticationApi.loginEmailPassword(i,E.getEcosystemGameOptsOrUndefined(a))).data,{default:n.AUTHENTICATION_ERROR,401:n.AUTHENTICATION_ERROR,403:n.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{r.captureAxiosError("loginEmailPassword",e)})}async requestResetPassword(t,a){const i=u(32),r=e.encode(i),o=await l(r),d=e.encode(o),h=u(32),p=e.encode(h);await this.deviceCredentialsManager.savePKCEData({state:p,verifier:r});const E={requestResetPasswordRequest:{email:t,redirectUrl:a,challenge:{codeChallenge:d,method:c.S256}}};await s(async()=>{await this.backendApiClients.authenticationApi.requestResetPassword(E)},{default:n.AUTHENTICATION_ERROR})}async resetPassword(e,t,a){return s(async()=>{const i=await this.deviceCredentialsManager.getPKCEData();if(!i)throw new Error("No code verifier or state for PKCE");const n={resetPasswordRequest:{email:e,password:t,state:a,challenge:{codeVerifier:i.verifier}}};await this.backendApiClients.authenticationApi.resetPassword(n)},{default:n.AUTHENTICATION_ERROR})}async requestEmailVerification(t,a){const i=u(32),r=e.encode(i),o=await l(r),d=e.encode(o),h=u(32),p=e.encode(h);await this.deviceCredentialsManager.savePKCEData({state:p,verifier:r});const E={requestVerifyEmailRequest:{email:t,redirectUrl:a,challenge:{codeChallenge:d,method:c.S256}}};await s(async()=>{await this.backendApiClients.authenticationApi.requestEmailVerification(E)},{default:n.AUTHENTICATION_ERROR})}async verifyEmail(e,t){return s(async()=>{const a=await this.deviceCredentialsManager.getPKCEData();if(!a)throw new Error("No code verifier or state for PKCE");const i={verifyEmailRequest:{email:e,token:t,challenge:{codeVerifier:a.verifier}}};await this.backendApiClients.authenticationApi.verifyEmail(i)},{default:n.AUTHENTICATION_ERROR})}async signupEmailPassword(e,t,a,i){const o={signupRequest:{email:e,password:t,name:a}};return s(async()=>(await this.backendApiClients.authenticationApi.signupEmailPassword(o,E.getEcosystemGameOptsOrUndefined(i))).data,{default:n.USER_REGISTRATION_ERROR,401:n.USER_REGISTRATION_ERROR,403:n.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{r.captureAxiosError("signupEmailPassword",e)})}async validateCredentials(e,t){if(!e.refreshToken)throw new i("No refresh token provided",n.AUTHENTICATION_ERROR);if(t)return this.refreshTokens(e.refreshToken,t);a("Validating credentials with token:",e.token);const s=h.parse(e.token);return s?s.isExpired()?(a("Token expired, refreshing..."),this.refreshTokens(e.refreshToken)):{player:s.subject,accessToken:e.token,refreshToken:e.refreshToken}:this.refreshTokens(e.refreshToken)}async refreshTokens(e,t){const a={refreshTokenRequest:{refreshToken:e,forceRefresh:t}};return s(async()=>{const e=await this.backendApiClients.authenticationApi.refresh(a);return{player:e.data.player.id,accessToken:e.data.token,refreshToken:e.data.refreshToken}},{default:n.REFRESH_TOKEN_ERROR})}async logout(e,t){const a={logoutRequest:{refreshToken:t}};return s(async()=>{await this.backendApiClients.authenticationApi.logout(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e}})},{default:n.LOGOUT_ERROR})}async getUser(e){return s(async()=>(await this.backendApiClients.authenticationApi.me({headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}})).data,{default:n.AUTHENTICATION_ERROR})}async linkThirdParty(e,t,a,i,r){const o={thirdPartyLinkRequest:{provider:t,token:a,tokenType:i}};return s(async()=>(await this.backendApiClients.authenticationApi.linkThirdParty(o,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider||void 0,"x-token-type":e.thirdPartyTokenType||void 0,"x-game":r||void 0}})).data,{default:n.AUTHENTICATION_ERROR})}async linkOAuth(e,t,a,i){const r=a?.skipBrowserRedirect??!1;delete a?.skipBrowserRedirect;const o={oAuthInitRequest:{provider:t,options:a,usePooling:a?.usePooling||!1}},c=await s(async()=>this.backendApiClients.authenticationApi.linkOAuth(o,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider||void 0,"x-token-type":e.thirdPartyTokenType||void 0,"x-game":i||void 0}}),{default:n.AUTHENTICATION_ERROR});return"undefined"==typeof window||r||window.location.assign(c.data.url),{url:c.data.url,key:c.data.key}}async unlinkOAuth(e,t){const a={unlinkOAuthRequest:{provider:e}};return s(async()=>(await this.backendApiClients.authenticationApi.unlinkOAuth(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":t}})).data,{default:n.AUTHENTICATION_ERROR})}async unlinkWallet(e,t){const a={sIWERequest:{address:e}};return s(async()=>(await this.backendApiClients.authenticationApi.unlinkSIWE(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":t}})).data,{default:n.AUTHENTICATION_ERROR})}async linkWallet(e,t,a,i,r){const o={sIWEAuthenticateRequest:{signature:e,message:t,walletClientType:a,connectorType:i}};return s(async()=>(await this.backendApiClients.authenticationApi.linkSIWE(o,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":r}})).data,{default:n.AUTHENTICATION_ERROR})}async unlinkEmail(e,t){const a={unlinkEmailRequest:{email:e}};return s(async()=>(await this.backendApiClients.authenticationApi.unlinkEmail(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":t}})).data,{default:n.AUTHENTICATION_ERROR})}async linkEmail(e,t,a,i){const r={loginRequest:{email:e,password:t}};return s(async()=>(await this.backendApiClients.authenticationApi.linkEmail(r,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":a,"x-game":i||void 0}})).data,{default:n.AUTHENTICATION_ERROR})}}export{E as AuthManager};
@@ -1 +1 @@
1
- import{StorageKeys as e}from"../../storage/istorage.js";import{RecoveryMethod as t}from"../../types/types.js";import"human-id";import"axios";import"../errors/sentry.js";import"eventemitter3";import"../../wallets/evm/JsonRpcError.js";import"@ethersproject/keccak256";import"../../wallets/evm/types.js";import"../../wallets/evm/provider/eip6963.js";import"../../wallets/messaging/browserMessenger/backwardCompatibility.js";import"../../wallets/types.js";class s{constructor(e){this.user=e.user,this.id=e.id,this.chainType=e.chainType,this.address=e.address,this.accountType=e.accountType,this.chainId=e.chainId,this.createdAt=e.createdAt,this.implementationAddress=e.implementationAddress,this.implementationType=e.implementationType,this.factoryAddress=e.factoryAddress,this.recoveryMethod=e.recoveryMethod,this.recoveryMethodDetails=e.recoveryMethodDetails,this.salt=e.salt,this.ownerAddress=e.ownerAddress,this.type=e.type}user;id;chainType;address;accountType;chainId;ownerAddress;factoryAddress;implementationAddress;salt;createdAt;implementationType;recoveryMethod;recoveryMethodDetails;type;save(t){t.save(e.ACCOUNT,JSON.stringify({user:this.user,id:this.id,chainType:this.chainType,address:this.address,accountType:this.accountType,chainId:this.chainId,ownerAddress:this.ownerAddress,createdAt:this.createdAt,implementationType:this.implementationType,factoryAddress:this.factoryAddress,implementationAddress:this.implementationAddress,salt:this.salt,recoveryMethod:this.recoveryMethod,recoveryMethodDetails:this.recoveryMethodDetails}))}static parseRecoveryMethod=e=>{switch(e){case"user":case t.PASSWORD:return t.PASSWORD;case"project":case t.AUTOMATIC:return t.AUTOMATIC;case"passkey":case t.PASSKEY:return t.PASSKEY;default:return}};static async fromStorage(t){const r=await t.get(e.ACCOUNT);if(!r)return null;try{const e=JSON.parse(r);return new s(e)}catch{return null}}}export{s as Account};
1
+ import{StorageKeys as e}from"../../storage/istorage.js";import"../errors/openfortError.js";import{RecoveryMethod as t}from"../../types/types.js";import"human-id";import"eventemitter3";import"../../wallets/evm/JsonRpcError.js";import"@ethersproject/keccak256";import"../../wallets/evm/types.js";import"../../wallets/evm/provider/eip6963.js";import"../errors/sentry.js";import"../../wallets/messaging/browserMessenger/backwardCompatibility.js";import"../../wallets/types.js";import"jose";class s{constructor(e){this.user=e.user,this.id=e.id,this.chainType=e.chainType,this.address=e.address,this.accountType=e.accountType,this.chainId=e.chainId,this.createdAt=e.createdAt,this.implementationAddress=e.implementationAddress,this.implementationType=e.implementationType,this.factoryAddress=e.factoryAddress,this.recoveryMethod=e.recoveryMethod,this.recoveryMethodDetails=e.recoveryMethodDetails,this.salt=e.salt,this.ownerAddress=e.ownerAddress,this.type=e.type}user;id;chainType;address;accountType;chainId;ownerAddress;factoryAddress;implementationAddress;salt;createdAt;implementationType;recoveryMethod;recoveryMethodDetails;type;save(t){t.save(e.ACCOUNT,JSON.stringify({user:this.user,id:this.id,chainType:this.chainType,address:this.address,accountType:this.accountType,chainId:this.chainId,ownerAddress:this.ownerAddress,createdAt:this.createdAt,implementationType:this.implementationType,factoryAddress:this.factoryAddress,implementationAddress:this.implementationAddress,salt:this.salt,recoveryMethod:this.recoveryMethod,recoveryMethodDetails:this.recoveryMethodDetails}))}static parseRecoveryMethod=e=>{switch(e){case"user":case t.PASSWORD:return t.PASSWORD;case"project":case t.AUTOMATIC:return t.AUTOMATIC;case"passkey":case t.PASSKEY:return t.PASSKEY;default:return}};static async fromStorage(t){const r=await t.get(e.ACCOUNT);if(!r)return null;try{const e=JSON.parse(r);return new s(e)}catch{return null}}}export{s as Account};
@@ -1 +1 @@
1
- import{StorageKeys as t}from"../../storage/istorage.js";class r{type;token;userId;thirdPartyProvider;thirdPartyTokenType;constructor(t,r,e,i,o){this.type=t,this.token=r,this.userId=e,this.thirdPartyProvider=i,this.thirdPartyTokenType=o}static thirdPartyAuthToken;get provider(){return this.thirdPartyProvider}get tokenType(){return this.thirdPartyTokenType}save(e){const i="third_party"===this.type;i&&(r.thirdPartyAuthToken=this.token),e.save(t.AUTHENTICATION,JSON.stringify({type:this.type,token:i?void 0:this.token,userId:this.userId,thirdPartyProvider:this.thirdPartyProvider,thirdPartyTokenType:this.thirdPartyTokenType}))}static clear(e){r.thirdPartyAuthToken="",e.remove(t.AUTHENTICATION)}static async fromStorage(e){const i=await e.get(t.AUTHENTICATION);if(!i)return null;try{const t=JSON.parse(i);return"third_party"===t.type&&(t.token=r.thirdPartyAuthToken),new r(t.type,t.token,t.userId||t.player,t.thirdPartyProvider,t.thirdPartyTokenType)}catch{return null}}}export{r as Authentication};
1
+ import{StorageKeys as t}from"../../storage/istorage.js";class r{type;token;player;refreshToken;thirdPartyProvider;thirdPartyTokenType;constructor(t,r,e,i,h,o){this.type=t,this.token=r,this.player=e,this.refreshToken=i,this.thirdPartyProvider=h,this.thirdPartyTokenType=o}static thirdPartyAuthToken;get provider(){return this.thirdPartyProvider}get tokenType(){return this.thirdPartyTokenType}save(e){const i="third_party"===this.type;i&&(r.thirdPartyAuthToken=this.token),e.save(t.AUTHENTICATION,JSON.stringify({type:this.type,token:i?void 0:this.token,player:this.player,refreshToken:this.refreshToken,thirdPartyProvider:this.thirdPartyProvider,thirdPartyTokenType:this.thirdPartyTokenType}))}static clear(e){r.thirdPartyAuthToken="",e.remove(t.AUTHENTICATION)}static async fromStorage(e){const i=await e.get(t.AUTHENTICATION);if(!i)return null;try{const t=JSON.parse(i);return"third_party"===t.type&&(t.token=r.thirdPartyAuthToken),new r(t.type,t.token,t.player,t.refreshToken,t.thirdPartyProvider,t.thirdPartyTokenType)}catch{return null}}}export{r as Authentication};
@@ -1 +1 @@
1
- class t extends Error{error;error_description;constructor(r,e){super(e),this.name="OpenfortError",this.error=r,this.error_description=e,Object.setPrototypeOf(this,t.prototype)}static fromPayload({error:r,error_description:e,message:o,code:s}){let c,n;return"object"==typeof r&&null!==r?(c=r.code||"unknown_error",n=r.message||o||e||"An unknown error occurred"):(c=s||r||"unknown_error",n=e||o||"An unknown error occurred"),new t(c,n)}}class r extends t{statusCode;constructor(t,e,o){super(t,e),this.statusCode=o,this.name="AuthenticationError",Object.setPrototypeOf(this,r.prototype)}}class e extends t{audience;scope;constructor(t,r,o,s){super(t,r),this.audience=o,this.scope=s,this.name="SessionError",Object.setPrototypeOf(this,e.prototype)}}class o extends t{constructor(t){super("invalid_configuration",t),this.name="ConfigurationError",Object.setPrototypeOf(this,o.prototype)}}class s extends t{accountId;constructor(t,r,e){super(t,r),this.accountId=e,this.name="SignerError",Object.setPrototypeOf(this,s.prototype)}}class c extends t{userId;constructor(t,r,e){super(t,r),this.userId=e,this.name="UserError",Object.setPrototypeOf(this,c.prototype)}}class n extends t{constructor(t,r){super(t,r),this.name="OTPError",Object.setPrototypeOf(this,n.prototype)}}class i extends t{provider;constructor(t,r,e){super(t,r),this.provider=e,this.name="OAuthError",Object.setPrototypeOf(this,i.prototype)}}class p extends t{constructor(t="User not authorized to access this ecosystem"){super("user_not_authorized",t),this.name="AuthorizationError",Object.setPrototypeOf(this,p.prototype)}}class u extends t{recoveryMethod;constructor(t,r,e){super(t,r),this.recoveryMethod=e,this.name="RecoveryError",Object.setPrototypeOf(this,u.prototype)}}class a extends t{statusCode;constructor(t,r){super("request_error",t),this.statusCode=r,this.name="RequestError",Object.setPrototypeOf(this,a.prototype)}}export{r as AuthenticationError,p as AuthorizationError,o as ConfigurationError,i as OAuthError,n as OTPError,t as OpenfortError,u as RecoveryError,a as RequestError,e as SessionError,s as SignerError,c as UserError};
1
+ import{isAxiosError as R}from"axios";var O;!function(R){R.AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",R.INVALID_CONFIGURATION="INVALID_CONFIGURATION",R.NOT_LOGGED_IN_ERROR="NOT_LOGGED_IN_ERROR",R.ALREADY_LOGGED_IN_ERROR="ALREADY_LOGGED_IN_ERROR",R.REFRESH_TOKEN_ERROR="REFRESH_TOKEN_ERROR",R.USER_REGISTRATION_ERROR="USER_REGISTRATION_ERROR",R.LOGOUT_ERROR="LOGOUT_ERROR",R.OPERATION_NOT_SUPPORTED_ERROR="OPERATION_NOT_SUPPORTED_ERROR",R.MISSING_SIGNER_ERROR="MISSING_SIGNER_ERROR",R.USER_NOT_AUTHORIZED_ON_ECOSYSTEM="USER_NOT_AUTHORIZED_ON_ECOSYSTEM",R.INTERNAL_ERROR="INTERNAL_ERROR"}(O||(O={}));class E extends Error{type;data;constructor(R,O,E={}){super(R),this.type=O,this.data=E}}const _=async(O,_,N)=>{try{return await O()}catch(O){let e;const I={};let T;R(O)?(T=O.response?.status,e=O.response?.data?.error&&function(R){return"type"in R&&"message"in R}(O.response.data.error)?O.response.data.error.message:O.message):e=O.message;const t=void 0!==T&&_[T]?_[T]:_.default,s=new E(e,t,I);throw void 0!==T&&_[T]||N?.(O,s),s}};export{E as OpenfortError,O as OpenfortErrorType,_ as withOpenfortError};
@@ -1 +1 @@
1
- import{AxiosError as e}from"axios";import{VERSION as t,PACKAGE as s}from"../../version.js";const r="https://64a03e4967fb4dad3ecb914918c777b6@o4504593015242752.ingest.us.sentry.io/4509292415287296";class n{static sentryInstance;static queuedCalls=[];static baseTags;static set sentry(t){const s=t.getDsn();if(!s)throw new Error("Sentry DSN is not set");if(s.projectId!==r.split("https://")[1].split("/")[1]||s.host!==r.split("@")[1].split("/")[0]||s.publicKey!==r.split("@")[0].split("https://")[1])throw new Error("Sentry DSN is not valid");t.captureAxiosError=(s,r,o,a)=>{if(r instanceof e){if(400===r.response?.status||401===r.response?.status)return;r.name=s,t.captureException(r,{...o,captureContext:{...o?.captureContext,extra:{errorResponseData:r.response?.data,errorStatus:r.response?.status,errorHeaders:r.response?.headers,errorRequest:r.request},tags:{...n.baseTags,method:s}}})}else t.captureException(r,o,a)},t.captureError=(e,s,r,o)=>{const a=s.statusCode;if(400===a||401===a)return;const c=s,i=c.error,u=c.error_description,p=r?.captureContext;t.captureException(s,{...r,captureContext:{...p,extra:{...p?.extra,errorCode:i,errorDescription:u,errorClass:s.constructor.name,...c.statusCode&&{statusCode:c.statusCode},...c.audience&&{audience:c.audience},...c.scope&&{scope:c.scope},...c.accountId&&{accountId:c.accountId},...c.userId&&{userId:c.userId},...c.provider&&{provider:c.provider},...c.recoveryMethod&&{recoveryMethod:c.recoveryMethod}},tags:{...n.baseTags,context:e,errorClass:s.constructor.name}}})},n.sentryInstance=t}static get sentry(){return n.proxy}static async init({sentry:e,configuration:o}){if(e)return void(n.sentry=e);const a=await import("@sentry/browser");n.sentry=new a.BrowserClient({dsn:r,integrations:[],stackParser:a.defaultStackParser,transport:a.makeFetchTransport}),n.baseTags={projectId:o?.baseConfiguration.publishableKey,sdk:s,sdkVersion:t},n.processQueuedCalls()}static proxy=new Proxy({},{get:(e,t)=>n.sentryInstance&&"function"==typeof n.sentryInstance[t]?(...e)=>n.sentryInstance[t](...e):(...e)=>{n.queuedCalls.push({fn:t,args:e})}});static processQueuedCalls(){n.sentryInstance&&(n.queuedCalls.forEach(({fn:e,args:t})=>{"function"==typeof n.sentryInstance[e]&&n.sentryInstance[e](...t)}),n.queuedCalls=[])}}const{sentry:o}=n;export{n as InternalSentry,o as sentry};
1
+ import{AxiosError as t}from"axios";import{VERSION as s,PACKAGE 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:e,sdkVersion:s},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
- import{BackendApiClients as t}from"../../../packages/internal/openapi-clients/dist/index.js";import{AuthApi as e}from"../api/auth.js";import{EmbeddedWalletApi as i}from"../api/embeddedWallet.js";import{ProxyApi as n}from"../api/proxy.js";import{UserApi as a}from"../api/user.js";import{AuthManager as s}from"../auth/authManager.js";import{StorageKeys as r}from"../storage/istorage.js";import{LazyStorage as o}from"../storage/lazyStorage.js";import h from"../utils/typedEventEmitter.js";import{SDKConfiguration as l}from"./config/config.js";import{PasskeyHandler as c}from"./configuration/passkey.js";import{OPENFORT_AUTH_ERROR_CODES as d}from"./errors/authErrorCodes.js";import{ConfigurationError as u,SignerError as g,RequestError as m}from"./errors/openfortError.js";import{InternalSentry as f}from"./errors/sentry.js";import{OpenfortInternal as p}from"./openfortInternal.js";class w{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;configuration;eventEmitter;iPasskeyHandler;static globalEventEmitter=null;get auth(){if(!this.authInstance)throw new u("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.");return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new u("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.");return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new u("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.");return this.userInstance}get proxy(){if(!this.proxyInstance)throw new u("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.");return this.proxyInstance}initializeSynchronously(){try{this.iAuthManager=new s,this.openfortInternal=new p(this.storage,this.authManager,this.eventEmitter),this.authInstance=new e(this.storage,this.authManager,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.embeddedWalletInstance=new i(this.storage,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter,this.passkeyHandler),this.userInstance=new a(this.storage,this.authManager,this.validateAndRefreshToken.bind(this)),this.proxyInstance=new n(this.storage,this.backendApiClients,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),async()=>{if(!this.embeddedWalletInstance)throw new g(d.MISSING_SIGNER,"Embedded wallet not initialized");const t=this.embeddedWalletInstance;return e=>t.signMessage(e,{hashMessage:!0,arrayifyMessage:!0})})}catch(t){throw new u("Openfort SDK synchronous initialization failed")}}constructor(t){if(this.configuration=new l(t),this.storage=new o(this.configuration.storage),this.eventEmitter=new h,w.globalEventEmitter){["onAuthInit","onAuthSuccess","onAuthFailure","onLogout","onSwitchAccount","onSignedMessage","onEmbeddedWalletCreated","onEmbeddedWalletRecovered","onAuthFlowOpen","onAuthFlowClose","onAuthFlowCancel"].forEach(t=>{this.eventEmitter.on(t,(...e)=>{w.globalEventEmitter?.emit(t,...e)})})}else w.globalEventEmitter=this.eventEmitter;this.iPasskeyHandler=new c({rpId:this.configuration.passkeyRpId,rpName:this.configuration.passkeyRpName,extractableKey:!0}),f.init({configuration:this.configuration}),this.initializeSynchronously(),this.initPromise=Promise.resolve()}static getEventEmitter(){return w.globalEventEmitter||(w.globalEventEmitter=new h),w.globalEventEmitter}async waitForInitialization(){await this.initPromise,await this.ensureAsyncInitialized()}async getAccessToken(){return await this.ensureInitialized(),this.openfortInternal.getAccessToken()}async validateAndRefreshToken(t){return await this.ensureInitialized(),await this.openfortInternal.validateAndRefreshToken(t)}get backendApiClients(){return new t({basePath:this.configuration.backendUrl,accessToken:this.configuration.baseConfiguration.publishableKey,nativeAppIdentifier:this.configuration.nativeAppIdentifier,storage:this.storage,onLogout:()=>{this.eventEmitter.emit("onLogout")}})}get authManager(){if(!this.iAuthManager)throw new m("AuthManager not initialized");return this.iAuthManager}get passkeyHandler(){return this.iPasskeyHandler}static async isStorageAccessible(t){try{const e=r.TEST,i="openfort_storage_test";t.save(e,i);const n=await t.get(e);return t.remove(e),n===i}catch(t){return!1}}async initializeAsync(){try{if(!await w.isStorageAccessible(this.storage))throw new u("Storage is not accessible");this.authManager.setBackendApiClients(this.backendApiClients,this.configuration.baseConfiguration.publishableKey)}catch(t){throw new m("Openfort SDK async initialization failed")}}async ensureAsyncInitialized(){this.asyncInitPromise||(this.asyncInitPromise=this.initializeAsync()),await this.asyncInitPromise}async ensureInitialized(){await this.initPromise,await this.ensureAsyncInitialized()}}export{w as Openfort};
1
+ import{BackendApiClients as t}from"../../../packages/internal/openapi-clients/dist/index.js";import{AuthApi as e}from"../api/auth.js";import{EmbeddedWalletApi as i}from"../api/embeddedWallet.js";import{ProxyApi as n}from"../api/proxy.js";import{UserApi as a}from"../api/user.js";import{AuthManager as s}from"../auth/authManager.js";import{StorageKeys as r}from"../storage/istorage.js";import{LazyStorage as o}from"../storage/lazyStorage.js";import h from"../utils/typedEventEmitter.js";import{SDKConfiguration as l}from"./config/config.js";import{PasskeyHandler as c}from"./configuration/passkey.js";import{OpenfortError as d,OpenfortErrorType as u}from"./errors/openfortError.js";import{InternalSentry as g}from"./errors/sentry.js";import{OpenfortInternal as I}from"./openfortInternal.js";class m{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;configuration;eventEmitter;iPasskeyHandler;static globalEventEmitter=null;get auth(){if(!this.authInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.",u.INVALID_CONFIGURATION);return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.",u.INVALID_CONFIGURATION);return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.",u.INVALID_CONFIGURATION);return this.userInstance}get proxy(){if(!this.proxyInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.",u.INVALID_CONFIGURATION);return this.proxyInstance}initializeSynchronously(){try{this.iAuthManager=new s(this.storage),this.openfortInternal=new I(this.storage,this.authManager,this.eventEmitter),this.authInstance=new e(this.storage,this.authManager,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.embeddedWalletInstance=new i(this.storage,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter,this.passkeyHandler),this.userInstance=new a(this.storage,this.authManager,this.validateAndRefreshToken.bind(this)),this.proxyInstance=new n(this.storage,this.backendApiClients,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),async()=>{if(!this.embeddedWalletInstance)throw new d("Embedded wallet not initialized",u.MISSING_SIGNER_ERROR);const t=this.embeddedWalletInstance;return e=>t.signMessage(e,{hashMessage:!0,arrayifyMessage:!0})})}catch(t){throw new d("Openfort SDK synchronous initialization failed",u.INVALID_CONFIGURATION)}}constructor(t){if(this.configuration=new l(t),this.storage=new o(this.configuration.storage),this.eventEmitter=new h,m.globalEventEmitter){["onAuthInit","onAuthSuccess","onAuthFailure","onLogout","onSwitchAccount","onSignedMessage","onEmbeddedWalletCreated","onEmbeddedWalletRecovered","onAuthFlowOpen","onAuthFlowClose","onAuthFlowCancel"].forEach(t=>{this.eventEmitter.on(t,(...e)=>{m.globalEventEmitter?.emit(t,...e)})})}else m.globalEventEmitter=this.eventEmitter;this.iPasskeyHandler=new c({rpId:this.configuration.passkeyRpId,rpName:this.configuration.passkeyRpName,extractableKey:!0}),g.init({configuration:this.configuration}),this.initializeSynchronously(),this.initPromise=Promise.resolve()}static getEventEmitter(){return m.globalEventEmitter||(m.globalEventEmitter=new h),m.globalEventEmitter}async waitForInitialization(){await this.initPromise,await this.ensureAsyncInitialized()}async getAccessToken(){return await this.ensureInitialized(),this.openfortInternal.getAccessToken()}async validateAndRefreshToken(t){return await this.ensureInitialized(),await this.openfortInternal.validateAndRefreshToken(t)}get backendApiClients(){return new t({basePath:this.configuration.backendUrl,accessToken:this.configuration.baseConfiguration.publishableKey,nativeAppIdentifier:this.configuration.nativeAppIdentifier,storage:this.storage,onLogout:()=>{this.eventEmitter.emit("onLogout")}})}get authManager(){if(!this.iAuthManager)throw new d("AuthManager not initialized",u.INTERNAL_ERROR);return this.iAuthManager}get passkeyHandler(){return this.iPasskeyHandler}static async isStorageAccessible(t){try{const e=r.TEST,i="openfort_storage_test";t.save(e,i);const n=await t.get(e);return t.remove(e),n===i}catch(t){return!1}}async initializeAsync(){try{if(!await m.isStorageAccessible(this.storage))throw new d("Storage is not accessible",u.INVALID_CONFIGURATION);this.authManager.setBackendApiClients(this.backendApiClients,this.configuration.baseConfiguration.publishableKey)}catch(t){throw new d("Openfort SDK async initialization failed",u.INTERNAL_ERROR)}}async ensureAsyncInitialized(){this.asyncInitPromise||(this.asyncInitPromise=this.initializeAsync()),await this.asyncInitPromise}async ensureInitialized(){await this.initPromise,await this.ensureAsyncInitialized()}}export{m as Openfort};
@@ -1 +1 @@
1
- import{Authentication as t}from"./configuration/authentication.js";import{OPENFORT_AUTH_ERROR_CODES as e}from"./errors/authErrorCodes.js";import{RequestError as r,ConfigurationError as o,AuthenticationError as i,SessionError as s}from"./errors/openfortError.js";import{TokenType as a,OpenfortEvents as n}from"../types/types.js";import"human-id";import{SDKConfiguration as h}from"./config/config.js";import"../storage/istorage.js";import"axios";import"./errors/sentry.js";import{debugLog as d}from"../utils/debug.js";import"eventemitter3";import"../wallets/evm/JsonRpcError.js";import"@ethersproject/keccak256";import"../wallets/evm/types.js";import"../wallets/evm/provider/eip6963.js";import"../wallets/messaging/browserMessenger/backwardCompatibility.js";import"../wallets/types.js";import{singlePromise as c}from"../utils/promiseUtils.js";class g{storage;authManager;eventEmitter;constructor(t,e,r){this.storage=t,this.authManager=e,this.eventEmitter=r}async getThirdPartyAuthToken(){const s=h.getInstance();if(!s?.thirdPartyAuth)throw new r("No third party configuration found");const{getAccessToken:n,provider:d}=s.thirdPartyAuth;if(!n||!d)throw new o("Third party is not configured. Please configure getAccessToken and thirdPartyAuthProvider in your Openfort instance");const c=await n();if(!c)throw new i(e.INVALID_TOKEN,"Could not get access token");let g=(await t.fromStorage(this.storage))?.userId;if(!g){g=(await this.authManager.authenticateThirdParty(d,c,a.ID_TOKEN)).userId}return new t("third_party",c,g,d,a.ID_TOKEN).save(this.storage),c}async getAccessToken(){if(h.getInstance()?.thirdPartyAuth)return this.getThirdPartyAuthToken();return(await t.fromStorage(this.storage))?.token??null}async validateAndRefreshToken(o){return c(async()=>{if(h.getInstance()?.thirdPartyAuth)return void await this.getThirdPartyAuthToken();const i=await t.fromStorage(this.storage);if(!i)throw new s(e.NOT_LOGGED_IN,"Must be logged in to validate and refresh token");let a;d("validating credentials...");try{a=await this.authManager.validateCredentials(i,o)}catch(e){throw t.clear(this.storage),this.eventEmitter.emit(n.ON_LOGOUT),e}if(!a.user?.id)throw new r("No user found in credentials");a.token!==i.token&&(d("tokens refreshed"),new t("session",a.token,a.user.id).save(this.storage))},"openfort.validateAndRefreshToken")}}export{g as OpenfortInternal};
1
+ import{Authentication as t}from"./configuration/authentication.js";import{OpenfortError as e,OpenfortErrorType as r}from"./errors/openfortError.js";import{TokenType as o,OpenfortEvents as i}from"../types/types.js";import"human-id";import{SDKConfiguration as s}from"./config/config.js";import"../storage/istorage.js";import{debugLog as a}from"../utils/debug.js";import"eventemitter3";import"../wallets/evm/JsonRpcError.js";import"@ethersproject/keccak256";import"../wallets/evm/types.js";import"../wallets/evm/provider/eip6963.js";import"./errors/sentry.js";import"../wallets/messaging/browserMessenger/backwardCompatibility.js";import"../wallets/types.js";import"jose";import{singlePromise as n}from"../utils/promiseUtils.js";class h{storage;authManager;eventEmitter;constructor(t,e,r){this.storage=t,this.authManager=e,this.eventEmitter=r}async getThirdPartyAuthToken(){const i=s.getInstance();if(!i?.thirdPartyAuth)throw new e("No third party configuration found",r.INTERNAL_ERROR);const{getAccessToken:a,provider:n}=i.thirdPartyAuth;if(!a||!n)throw new e("Third party is not configured. Please configure getAccessToken and thirdPartyAuthProvider in your Openfort instance",r.INVALID_CONFIGURATION);const h=await a();if(!h)throw new e("Could not get access token",r.AUTHENTICATION_ERROR);let c=(await t.fromStorage(this.storage))?.player;if(!c){const t=await this.authManager.authenticateThirdParty(n,h,o.ID_TOKEN);c=t?.id}return new t("third_party",h,c,null,n,o.ID_TOKEN).save(this.storage),h}async getAccessToken(){if(s.getInstance()?.thirdPartyAuth)return this.getThirdPartyAuthToken();return(await t.fromStorage(this.storage))?.token??null}async validateAndRefreshToken(o){return n(async()=>{if(s.getInstance()?.thirdPartyAuth)return void await this.getThirdPartyAuthToken();const n=await t.fromStorage(this.storage);if(!n)throw new e("Must be logged in to validate and refresh token",r.NOT_LOGGED_IN_ERROR);let h;a("validating credentials...");try{h=await this.authManager.validateCredentials(n,o)}catch(e){throw t.clear(this.storage),this.eventEmitter.emit(i.ON_LOGOUT),e}if(!h.player)throw new e("No user found in credentials",r.INTERNAL_ERROR);h.accessToken!==n.token&&(a("tokens refreshed"),new t("jwt",h.accessToken,h.player,h.refreshToken).save(this.storage))},"openfort.validateAndRefreshToken")}}export{h as OpenfortInternal};
@@ -1 +1 @@
1
- import{Openfort as r}from"./core/openfort.js";export{AuthApi}from"./api/auth.js";export{EmbeddedWalletApi}from"./api/embeddedWallet.js";export{ProxyApi}from"./api/proxy.js";export{UserApi}from"./api/user.js";export{OPENFORT_AUTH_ERROR_CODES,OPENFORT_ERROR_CODES}from"./core/errors/authErrorCodes.js";export{AuthenticationError,AuthorizationError,ConfigurationError,OAuthError,OTPError,OpenfortError,RecoveryError,RequestError,SessionError,SignerError,UserError}from"./core/errors/openfortError.js";export{OpenfortConfiguration,SDKConfiguration,ShieldConfiguration}from"./core/config/config.js";export{OpenfortInternal}from"./core/openfortInternal.js";export{prepareAndSignAuthorization,serializeSignedAuthorization,signAuthorization}from"./utils/authorization.js";export{MissingProjectEntropyError,MissingRecoveryPasswordError,NotConfiguredError,OTPRequiredError,WrongRecoveryPasswordError}from"./wallets/iframeManager.js";export{AccountTypeEnum,AuthActionRequiredActions,AuthType,BasicAuthProvider,ChainTypeEnum,EmbeddedState,OAuthProvider,OpenfortEvents,RecoveryMethod,ThirdPartyAuthProvider as ThirdPartyOAuthProvider,TokenType}from"./types/types.js";const o=r.getEventEmitter();export{r as Openfort,o as openfortEvents};
1
+ import{Openfort as r}from"./core/openfort.js";export{AuthApi}from"./api/auth.js";export{EmbeddedWalletApi}from"./api/embeddedWallet.js";export{ProxyApi}from"./api/proxy.js";export{UserApi}from"./api/user.js";export{OpenfortConfiguration,SDKConfiguration,ShieldConfiguration}from"./core/config/config.js";export{OpenfortError,OpenfortErrorType}from"./core/errors/openfortError.js";export{OpenfortInternal}from"./core/openfortInternal.js";export{prepareAndSignAuthorization,serializeSignedAuthorization,signAuthorization}from"./utils/authorization.js";export{MissingProjectEntropyError,MissingRecoveryPasswordError,NotConfiguredError,OTPRequiredError,WrongRecoveryPasswordError}from"./wallets/iframeManager.js";export{AccountTypeEnum,AuthActionRequiredActions,AuthType,BasicAuthProvider,ChainTypeEnum,EmbeddedState,OAuthProvider,OpenfortEvents,RecoveryMethod,ThirdPartyAuthProvider as ThirdPartyOAuthProvider,TokenType}from"./types/types.js";const o=r.getEventEmitter();export{r as Openfort,o as openfortEvents};