@openfort/openfort-js 0.9.2 → 0.9.4

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 (82) 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/config/config.js +1 -1
  8. package/dist/cjs/sdk/src/core/errors/openfortError.js +1 -1
  9. package/dist/cjs/sdk/src/core/openfort.js +1 -1
  10. package/dist/cjs/sdk/src/core/openfortInternal.js +1 -1
  11. package/dist/cjs/sdk/src/storage/istorage.js +1 -1
  12. package/dist/cjs/sdk/src/types/types.js +1 -1
  13. package/dist/cjs/sdk/src/utils/debug.js +1 -0
  14. package/dist/cjs/sdk/src/version.js +1 -1
  15. package/dist/cjs/sdk/src/wallets/embedded.js +1 -1
  16. package/dist/cjs/sdk/src/wallets/evm/addEthereumChain.js +1 -1
  17. package/dist/cjs/sdk/src/wallets/evm/evmProvider.js +1 -1
  18. package/dist/cjs/sdk/src/wallets/evm/revokeSession.js +1 -1
  19. package/dist/cjs/sdk/src/wallets/iframeManager.js +1 -1
  20. package/dist/cjs/sdk/src/wallets/messaging/ReactNativeMessenger.js +1 -0
  21. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/CallOptions.js +1 -0
  22. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/PenpalBugError.js +1 -0
  23. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/PenpalError.js +1 -0
  24. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/Reply.js +1 -0
  25. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/backwardCompatibility.js +1 -0
  26. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/connect.js +1 -0
  27. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/connectCallHandler.js +1 -0
  28. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/connectRemoteProxy.js +1 -0
  29. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/errorSerialization.js +1 -0
  30. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/getPromiseWithResolvers.js +1 -0
  31. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/guards.js +1 -0
  32. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/messengers/WindowMessenger.js +1 -0
  33. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/methodSerialization.js +1 -0
  34. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/namespace.js +1 -0
  35. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/once.js +1 -0
  36. package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/shakeHands.js +1 -0
  37. package/dist/cjs/sdk/src/wallets/types.js +1 -1
  38. package/dist/index.d.ts +71 -34
  39. package/dist/packages/internal/openapi-clients/dist/index.js +1 -1
  40. package/dist/sdk/src/api/auth.js +1 -1
  41. package/dist/sdk/src/api/embeddedWallet.js +1 -1
  42. package/dist/sdk/src/api/proxy.js +1 -1
  43. package/dist/sdk/src/api/user.js +1 -1
  44. package/dist/sdk/src/auth/authManager.js +1 -1
  45. package/dist/sdk/src/core/config/config.js +1 -1
  46. package/dist/sdk/src/core/errors/openfortError.js +1 -1
  47. package/dist/sdk/src/core/openfort.js +1 -1
  48. package/dist/sdk/src/core/openfortInternal.js +1 -1
  49. package/dist/sdk/src/storage/istorage.js +1 -1
  50. package/dist/sdk/src/types/types.js +1 -1
  51. package/dist/sdk/src/utils/debug.js +1 -0
  52. package/dist/sdk/src/version.js +1 -1
  53. package/dist/sdk/src/wallets/embedded.js +1 -1
  54. package/dist/sdk/src/wallets/evm/addEthereumChain.js +1 -1
  55. package/dist/sdk/src/wallets/evm/evmProvider.js +1 -1
  56. package/dist/sdk/src/wallets/evm/revokeSession.js +1 -1
  57. package/dist/sdk/src/wallets/iframeManager.js +1 -1
  58. package/dist/sdk/src/wallets/messaging/ReactNativeMessenger.js +1 -0
  59. package/dist/sdk/src/wallets/messaging/browserMessenger/CallOptions.js +1 -0
  60. package/dist/sdk/src/wallets/messaging/browserMessenger/PenpalBugError.js +1 -0
  61. package/dist/sdk/src/wallets/messaging/browserMessenger/PenpalError.js +1 -0
  62. package/dist/sdk/src/wallets/messaging/browserMessenger/Reply.js +1 -0
  63. package/dist/sdk/src/wallets/messaging/browserMessenger/backwardCompatibility.js +1 -0
  64. package/dist/sdk/src/wallets/messaging/browserMessenger/connect.js +1 -0
  65. package/dist/sdk/src/wallets/messaging/browserMessenger/connectCallHandler.js +1 -0
  66. package/dist/sdk/src/wallets/messaging/browserMessenger/connectRemoteProxy.js +1 -0
  67. package/dist/sdk/src/wallets/messaging/browserMessenger/errorSerialization.js +1 -0
  68. package/dist/sdk/src/wallets/messaging/browserMessenger/getPromiseWithResolvers.js +1 -0
  69. package/dist/sdk/src/wallets/messaging/browserMessenger/guards.js +1 -0
  70. package/dist/sdk/src/wallets/messaging/browserMessenger/messengers/WindowMessenger.js +1 -0
  71. package/dist/sdk/src/wallets/messaging/browserMessenger/methodSerialization.js +1 -0
  72. package/dist/sdk/src/wallets/messaging/browserMessenger/namespace.js +1 -0
  73. package/dist/sdk/src/wallets/messaging/browserMessenger/once.js +1 -0
  74. package/dist/sdk/src/wallets/messaging/browserMessenger/shakeHands.js +1 -0
  75. package/dist/sdk/src/wallets/types.js +1 -1
  76. package/package.json +2 -3
  77. package/dist/cjs/node_modules/penpal/dist/penpal.js +0 -1
  78. package/dist/cjs/sdk/src/core/configuration/recovery.js +0 -1
  79. package/dist/cjs/sdk/src/wallets/signer.js +0 -1
  80. package/dist/node_modules/penpal/dist/penpal.js +0 -1
  81. package/dist/sdk/src/core/configuration/recovery.js +0 -1
  82. package/dist/sdk/src/wallets/signer.js +0 -1
@@ -1 +1 @@
1
- "use strict";var e=require("axios"),t=require("axios-retry");const n="https://api.openfort.xyz".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","accountCreateRequest",t);const s=new URL("/v2/accounts",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}},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","accountId",t);const s="/v2/accounts/{accountId}".replace("{accountId}",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}},getAccounts:async(t,n,s,a,o,c,u={})=>{const l=new URL("/v1/accounts",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==t&&(w.limit=t),void 0!==n&&(w.skip=n),void 0!==s&&(w.order=s),void 0!==a&&(w.player=a),void 0!==o&&(w.address=o),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}},listAccountsV2:async(t,n,s,a,o={})=>{const r=new URL("/v2/accounts",i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...o},l={};void 0!==t&&(l.limit=t),void 0!==n&&(l.skip=n),void 0!==s&&(l.order=s),void 0!==a&&(l.accountType=a),h(r,l);let p=c&&c.headers?c.headers:{};return u.headers={...p,...o.headers},{url:d(r),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}},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){const d=await s.getAccounts(a,i,o,r,c,h,u);return l(d,e,n,t)},async listAccountsV2(a,i,o,r,c){const h=await s.listAccountsV2(a,i,o,r,c);return l(h,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 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.accountCreateRequest,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.accountId,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}listAccountsV2(e={},t){return p(this.configuration).listAccountsV2(e.limit,e.skip,e.order,e.accountType,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))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const s=function(e){return{authenticateSIWE:async(t,n={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getJwks:async(t,n={})=>{o("getJwks","publishableKey",t);const s="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},initOAuth:async(t,n,s={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,n,s={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,n,s={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,n,s={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,n={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},linkThirdParty:async(t,n,s={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,n,s={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,n,s={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,n={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const s=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},logout:async(t,n={})=>{o("logout","logoutRequest",t);const s=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},me:async(t={})=>{const n=new URL("/iam/v1/me",i);let s;e&&(s=e.baseOptions);const a={method:"GET",...s,...t};h(n,{});let o=s&&s.headers?s.headers:{};return a.headers={...o,...t.headers},{url:d(n),options:a}},poolOAuth:async(t,n={})=>{o("poolOAuth","key",t);const s=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},refresh:async(t,n={})=>{o("refresh","refreshTokenRequest",t);const s=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},registerGuest:async(t,n={})=>{const s=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...n},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(s,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...n.headers},{url:d(s),options:o}},requestEmailVerification:async(t,n={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const s=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},requestResetPassword:async(t,n={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const s=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},resetPassword:async(t,n={})=>{o("resetPassword","resetPasswordRequest",t);const s=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},signupEmailPassword:async(t,n,s={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,n,s={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,n={})=>{o("unlinkEmail","unlinkEmailRequest",t);const s=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkOAuth:async(t,n={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const s=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkSIWE:async(t,n={})=>{o("unlinkSIWE","sIWERequest",t);const s=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},verifyEmail:async(t,n={})=>{o("verifyEmail","verifyEmailRequest",t);const s=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},verifyOAuthToken:async(t,n={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const s=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await s.authenticateSIWE(a,i);return l(o,e,n,t)},async getJwks(a,i){const o=await s.getJwks(a,i);return l(o,e,n,t)},async initOAuth(a,i,o){const r=await s.initOAuth(a,i,o);return l(r,e,n,t)},async initSIWE(a,i,o){const r=await s.initSIWE(a,i,o);return l(r,e,n,t)},async linkEmail(a,i,o){const r=await s.linkEmail(a,i,o);return l(r,e,n,t)},async linkOAuth(a,i,o){const r=await s.linkOAuth(a,i,o);return l(r,e,n,t)},async linkSIWE(a,i){const o=await s.linkSIWE(a,i);return l(o,e,n,t)},async linkThirdParty(a,i,o){const r=await s.linkThirdParty(a,i,o);return l(r,e,n,t)},async loginEmailPassword(a,i,o){const r=await s.loginEmailPassword(a,i,o);return l(r,e,n,t)},async loginOIDC(a,i,o){const r=await s.loginOIDC(a,i,o);return l(r,e,n,t)},async loginWithIdToken(a,i){const o=await s.loginWithIdToken(a,i);return l(o,e,n,t)},async logout(a,i){const o=await s.logout(a,i);return l(o,e,n,t)},async me(a){const i=await s.me(a);return l(i,e,n,t)},async poolOAuth(a,i){const o=await s.poolOAuth(a,i);return l(o,e,n,t)},async refresh(a,i){const o=await s.refresh(a,i);return l(o,e,n,t)},async registerGuest(a,i){const o=await s.registerGuest(a,i);return l(o,e,n,t)},async requestEmailVerification(a,i){const o=await s.requestEmailVerification(a,i);return l(o,e,n,t)},async requestResetPassword(a,i){const o=await s.requestResetPassword(a,i);return l(o,e,n,t)},async resetPassword(a,i){const o=await s.resetPassword(a,i);return l(o,e,n,t)},async signupEmailPassword(a,i,o){const r=await s.signupEmailPassword(a,i,o);return l(r,e,n,t)},async thirdParty(a,i,o){const r=await s.thirdParty(a,i,o);return l(r,e,n,t)},async unlinkEmail(a,i){const o=await s.unlinkEmail(a,i);return l(o,e,n,t)},async unlinkOAuth(a,i){const o=await s.unlinkOAuth(a,i);return l(o,e,n,t)},async unlinkSIWE(a,i){const o=await s.unlinkSIWE(a,i);return l(o,e,n,t)},async verifyEmail(a,i){const o=await s.verifyEmail(a,i);return l(o,e,n,t)},async verifyOAuthToken(a,i){const o=await s.verifyOAuthToken(a,i);return l(o,e,n,t)}}};class w extends s{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const s=function(e){return{createSession:async(t,n,s={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,n,s,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==n&&(w.limit=n),void 0!==s&&(w.skip=s),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,n,s={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},revokeSession:async(t,n,s={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,n,s={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",n);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await s.createSession(a,i,o);return l(r,e,n,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await s.getPlayerSessions(a,i,o,r,c,h);return l(u,e,n,t)},async getSession(a,i,o){const r=await s.getSession(a,i,o);return l(r,e,n,t)},async revokeSession(a,i,o){const r=await s.revokeSession(a,i,o);return l(r,e,n,t)},async signatureSession(a,i,o){const r=await s.signatureSession(a,i,o);return l(r,e,n,t)}}};class P extends s{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const s=function(e){return{createTransactionIntent:async(t,n,s={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,n={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const s=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getTransactionIntent:async(t,n,s={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getTransactionIntents:async(t,n,s,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==n&&(R.skip=n),void 0!==s&&(R.order=s),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,n,s={})=>{o("signature","id",t),o("signature","signatureRequest",n);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await s.createTransactionIntent(a,i,o);return l(r,e,n,t)},async estimateTransactionIntentCost(a,i){const o=await s.estimateTransactionIntentCost(a,i);return l(o,e,n,t)},async getTransactionIntent(a,i,o){const r=await s.getTransactionIntent(a,i,o);return l(r,e,n,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await s.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,n,t)},async signature(a,i,o){const r=await s.signature(a,i,o);return l(r,e,n,t)}}};class T extends s{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};exports.BackendApiClients=class{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(n){const s=e.create();t(s,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:n.basePath,accessToken:n.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,s),this.accountsApi=new y(this.config.backend,void 0,s),this.sessionsApi=new P(this.config.backend,void 0,s),this.authenticationApi=new w(this.config.backend,void 0,s)}},exports.createConfig=f;
1
+ "use strict";var e=require("axios"),t=require("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","accountCreateRequest",t);const s=new URL("/v2/accounts",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}},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","accountId",t);const s="/v2/accounts/{accountId}".replace("{accountId}",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}},getAccounts:async(t,n,s,a,o,c,u={})=>{const l=new URL("/v1/accounts",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==t&&(w.limit=t),void 0!==n&&(w.skip=n),void 0!==s&&(w.order=s),void 0!==a&&(w.player=a),void 0!==o&&(w.address=o),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}},listAccountsV2:async(t,n,s,a,o={})=>{const r=new URL("/v2/accounts",i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...o},l={};void 0!==t&&(l.limit=t),void 0!==n&&(l.skip=n),void 0!==s&&(l.order=s),void 0!==a&&(l.accountType=a),h(r,l);let p=c&&c.headers?c.headers:{};return u.headers={...p,...o.headers},{url:d(r),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}},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){const d=await s.getAccounts(a,i,o,r,c,h,u);return l(d,e,n,t)},async listAccountsV2(a,i,o,r,c){const h=await s.listAccountsV2(a,i,o,r,c);return l(h,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 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.accountCreateRequest,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.accountId,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}listAccountsV2(e={},t){return p(this.configuration).listAccountsV2(e.limit,e.skip,e.order,e.accountType,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))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const s=function(e){return{authenticateSIWE:async(t,n={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getJwks:async(t,n={})=>{o("getJwks","publishableKey",t);const s="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},initOAuth:async(t,n,s={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,n,s={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,n,s={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,n,s={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,n={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},linkThirdParty:async(t,n,s={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,n,s={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,n,s={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,n={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const s=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},logout:async(t,n={})=>{o("logout","logoutRequest",t);const s=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},me:async(t={})=>{const n=new URL("/iam/v1/me",i);let s;e&&(s=e.baseOptions);const a={method:"GET",...s,...t};h(n,{});let o=s&&s.headers?s.headers:{};return a.headers={...o,...t.headers},{url:d(n),options:a}},poolOAuth:async(t,n={})=>{o("poolOAuth","key",t);const s=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},refresh:async(t,n={})=>{o("refresh","refreshTokenRequest",t);const s=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},registerGuest:async(t,n={})=>{const s=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...n},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(s,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...n.headers},{url:d(s),options:o}},requestEmailVerification:async(t,n={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const s=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},requestResetPassword:async(t,n={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const s=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},resetPassword:async(t,n={})=>{o("resetPassword","resetPasswordRequest",t);const s=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},signupEmailPassword:async(t,n,s={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,n,s={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,n={})=>{o("unlinkEmail","unlinkEmailRequest",t);const s=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkOAuth:async(t,n={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const s=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkSIWE:async(t,n={})=>{o("unlinkSIWE","sIWERequest",t);const s=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},verifyEmail:async(t,n={})=>{o("verifyEmail","verifyEmailRequest",t);const s=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},verifyOAuthToken:async(t,n={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const s=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await s.authenticateSIWE(a,i);return l(o,e,n,t)},async getJwks(a,i){const o=await s.getJwks(a,i);return l(o,e,n,t)},async initOAuth(a,i,o){const r=await s.initOAuth(a,i,o);return l(r,e,n,t)},async initSIWE(a,i,o){const r=await s.initSIWE(a,i,o);return l(r,e,n,t)},async linkEmail(a,i,o){const r=await s.linkEmail(a,i,o);return l(r,e,n,t)},async linkOAuth(a,i,o){const r=await s.linkOAuth(a,i,o);return l(r,e,n,t)},async linkSIWE(a,i){const o=await s.linkSIWE(a,i);return l(o,e,n,t)},async linkThirdParty(a,i,o){const r=await s.linkThirdParty(a,i,o);return l(r,e,n,t)},async loginEmailPassword(a,i,o){const r=await s.loginEmailPassword(a,i,o);return l(r,e,n,t)},async loginOIDC(a,i,o){const r=await s.loginOIDC(a,i,o);return l(r,e,n,t)},async loginWithIdToken(a,i){const o=await s.loginWithIdToken(a,i);return l(o,e,n,t)},async logout(a,i){const o=await s.logout(a,i);return l(o,e,n,t)},async me(a){const i=await s.me(a);return l(i,e,n,t)},async poolOAuth(a,i){const o=await s.poolOAuth(a,i);return l(o,e,n,t)},async refresh(a,i){const o=await s.refresh(a,i);return l(o,e,n,t)},async registerGuest(a,i){const o=await s.registerGuest(a,i);return l(o,e,n,t)},async requestEmailVerification(a,i){const o=await s.requestEmailVerification(a,i);return l(o,e,n,t)},async requestResetPassword(a,i){const o=await s.requestResetPassword(a,i);return l(o,e,n,t)},async resetPassword(a,i){const o=await s.resetPassword(a,i);return l(o,e,n,t)},async signupEmailPassword(a,i,o){const r=await s.signupEmailPassword(a,i,o);return l(r,e,n,t)},async thirdParty(a,i,o){const r=await s.thirdParty(a,i,o);return l(r,e,n,t)},async unlinkEmail(a,i){const o=await s.unlinkEmail(a,i);return l(o,e,n,t)},async unlinkOAuth(a,i){const o=await s.unlinkOAuth(a,i);return l(o,e,n,t)},async unlinkSIWE(a,i){const o=await s.unlinkSIWE(a,i);return l(o,e,n,t)},async verifyEmail(a,i){const o=await s.verifyEmail(a,i);return l(o,e,n,t)},async verifyOAuthToken(a,i){const o=await s.verifyOAuthToken(a,i);return l(o,e,n,t)}}};class w extends s{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const s=function(e){return{createSession:async(t,n,s={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,n,s,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==n&&(w.limit=n),void 0!==s&&(w.skip=s),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,n,s={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},revokeSession:async(t,n,s={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,n,s={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",n);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await s.createSession(a,i,o);return l(r,e,n,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await s.getPlayerSessions(a,i,o,r,c,h);return l(u,e,n,t)},async getSession(a,i,o){const r=await s.getSession(a,i,o);return l(r,e,n,t)},async revokeSession(a,i,o){const r=await s.revokeSession(a,i,o);return l(r,e,n,t)},async signatureSession(a,i,o){const r=await s.signatureSession(a,i,o);return l(r,e,n,t)}}};class P extends s{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const s=function(e){return{createTransactionIntent:async(t,n,s={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,n={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const s=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getTransactionIntent:async(t,n,s={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getTransactionIntents:async(t,n,s,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==n&&(R.skip=n),void 0!==s&&(R.order=s),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,n,s={})=>{o("signature","id",t),o("signature","signatureRequest",n);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await s.createTransactionIntent(a,i,o);return l(r,e,n,t)},async estimateTransactionIntentCost(a,i){const o=await s.estimateTransactionIntentCost(a,i);return l(o,e,n,t)},async getTransactionIntent(a,i,o){const r=await s.getTransactionIntent(a,i,o);return l(r,e,n,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await s.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,n,t)},async signature(a,i,o){const r=await s.signature(a,i,o);return l(r,e,n,t)}}};class T extends s{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};exports.BackendApiClients=class{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(n){const s=e.create();t(s,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:n.basePath,accessToken:n.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,s),this.accountsApi=new y(this.config.backend,void 0,s),this.sessionsApi=new P(this.config.backend,void 0,s),this.authenticationApi=new w(this.config.backend,void 0,s)}},exports.createConfig=f;
@@ -1 +1 @@
1
- "use strict";var t=require("../storage/istorage.js"),a=require("../core/configuration/authentication.js"),e=require("../wallets/signer.js"),i=require("../core/errors/openfortError.js");exports.AuthApi=class{storage;authManager;validateAndRefreshToken;ensureInitialized;constructor(t,a,e,i){this.storage=t,this.authManager=a,this.validateAndRefreshToken=e,this.ensureInitialized=i}async logInWithEmailPassword({email:t,password:e,ecosystemGame:i}){await this.ensureInitialized();const r=await a.Authentication.fromStorage(this.storage),n=await this.authManager.loginEmailPassword(t,e,i);return"action"in n||(r&&r.player!==n.player.id&&await this.logout(),new a.Authentication("jwt",n.token,n.player.id,n.refreshToken).save(this.storage)),n}async signUpGuest(){await this.ensureInitialized();const t=await a.Authentication.fromStorage(this.storage),e=await this.authManager.registerGuest();return t&&t.player!==e.player.id&&await this.logout(),new a.Authentication("jwt",e.token,e.player.id,e.refreshToken).save(this.storage),e}async signUpWithEmailPassword({email:t,password:e,options:i,ecosystemGame:r}){await this.ensureInitialized();const n=await a.Authentication.fromStorage(this.storage),s=await this.authManager.signupEmailPassword(t,e,i?.data.name,r);return"action"in s||(n&&n.player!==s.player.id&&await this.logout(),new a.Authentication("jwt",s.token,s.player.id,s.refreshToken).save(this.storage)),s}async linkEmailPassword({email:t,password:a,authToken:e,ecosystemGame:i}){return await this.authManager.linkEmail(t,a,e,i)}async unlinkEmailPassword({email:t,authToken:a}){return await this.authManager.unlinkEmail(t,a)}async requestEmailVerification({email:t,redirectUrl:a}){await this.authManager.requestEmailVerification(t,a)}async resetPassword({email:t,password:a,state:e}){await this.authManager.resetPassword(t,a,e)}async requestResetPassword({email:t,redirectUrl:a}){await this.ensureInitialized(),await this.authManager.requestResetPassword(t,a)}async verifyEmail({email:t,state:a}){await this.authManager.verifyEmail(t,a)}async initOAuth({provider:t,options:a,ecosystemGame:e}){return await this.ensureInitialized(),await this.authManager.initOAuth(t,a,e)}async initLinkOAuth({provider:t,options:e,ecosystemGame:r}){const n=await a.Authentication.fromStorage(this.storage);if(!n)throw new i.OpenfortError("No authentication found",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return await this.authManager.linkOAuth(n,t,e,r)}async linkThirdPartyProvider({provider:t,token:e,tokenType:r}){const n=await a.Authentication.fromStorage(this.storage);if(!n)throw new i.OpenfortError("No authentication found",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return await this.authManager.linkThirdParty(n,t,e,r)}async unlinkOAuth({provider:t,authToken:a}){return await this.authManager.unlinkOAuth(t,a)}async poolOAuth(t){await this.ensureInitialized();const e=await a.Authentication.fromStorage(this.storage),i=await this.authManager.poolOAuth(t);return e&&e.player!==i.player.id&&await this.logout(),new a.Authentication("jwt",i.token,i.player.id,i.refreshToken).save(this.storage),i}async authenticateWithThirdPartyProvider({provider:t,token:e,tokenType:i,ecosystemGame:r}){await this.ensureInitialized();const n=await a.Authentication.fromStorage(this.storage),s=await this.authManager.authenticateThirdParty(t,e,i,r);return n&&n.player!==s.id&&await this.logout(),new a.Authentication("third_party",e,s.id,null,t,i).save(this.storage),s}async loginWithIdToken({provider:t,token:e,ecosystemGame:i}){await this.ensureInitialized();const r=await a.Authentication.fromStorage(this.storage),n=await this.authManager.loginWithIdToken(t,e,i);return r&&r.player!==n.player.id&&await this.logout(),new a.Authentication("jwt",n.token,n.player.id,n.refreshToken).save(this.storage),n}async initSIWE({address:t,ecosystemGame:a}){return await this.ensureInitialized(),await this.authManager.initSIWE(t,a)}async authenticateWithSIWE({signature:t,message:e,walletClientType:i,connectorType:r}){await this.ensureInitialized();const n=await a.Authentication.fromStorage(this.storage),s=await this.authManager.authenticateSIWE(t,e,i,r);return n&&n.player!==s.player.id&&await this.logout(),new a.Authentication("jwt",s.token,s.player.id,s.refreshToken).save(this.storage),s}async linkWallet({signature:t,message:a,walletClientType:e,connectorType:i,authToken:r}){return await this.authManager.linkWallet(t,a,e,i,r)}async unlinkWallet({address:t,authToken:a}){return await this.authManager.unlinkWallet(t,a)}async storeCredentials(t){if(await this.ensureInitialized(),!t.player)throw new i.OpenfortError("Player ID is required to store credentials",i.OpenfortErrorType.INVALID_CONFIGURATION);new a.Authentication("jwt",t.accessToken,t.player,t.refreshToken).save(this.storage)}async logout(){await this.ensureInitialized();const a=await e.SignerManager.fromStorage(this.storage);this.storage.remove(t.StorageKeys.AUTHENTICATION),this.storage.remove(t.StorageKeys.ACCOUNT),a&&await a.logout()}};
1
+ "use strict";var t=require("../storage/istorage.js"),e=require("../core/configuration/authentication.js"),a=require("../core/errors/openfortError.js"),i=require("../types/types.js");exports.AuthApi=class{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(t,e,a,i,n){this.storage=t,this.authManager=e,this.validateAndRefreshToken=a,this.ensureInitialized=i,this.eventEmitter=n}async logInWithEmailPassword({email:t,password:a,ecosystemGame:i}){await this.ensureInitialized();const n=await this.authManager.loginEmailPassword(t,a,i);return"action"in n||new e.Authentication("jwt",n.token,n.player.id,n.refreshToken).save(this.storage),n}async signUpGuest(){await this.ensureInitialized();const t=await this.authManager.registerGuest();return new e.Authentication("jwt",t.token,t.player.id,t.refreshToken).save(this.storage),t}async signUpWithEmailPassword({email:t,password:a,options:i,ecosystemGame:n}){await this.ensureInitialized();const r=await this.authManager.signupEmailPassword(t,a,i?.data.name,n);return"action"in r||new e.Authentication("jwt",r.token,r.player.id,r.refreshToken).save(this.storage),r}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:t,options:e,ecosystemGame:a}){return await this.ensureInitialized(),await this.authManager.initOAuth(t,e,a)}async initLinkOAuth({provider:t,options:i,ecosystemGame:n}){await this.validateAndRefreshToken();const r=await e.Authentication.fromStorage(this.storage);if(!r)throw new a.OpenfortError("No authentication found",a.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return await this.authManager.linkOAuth(r,t,i,n)}async linkThirdPartyProvider({provider:t,token:i,tokenType:n}){await this.validateAndRefreshToken();const r=await e.Authentication.fromStorage(this.storage);if(!r)throw new a.OpenfortError("No authentication found",a.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return await this.authManager.linkThirdParty(r,t,i,n)}async unlinkOAuth({provider:t,authToken:e}){return await this.validateAndRefreshToken(),await this.authManager.unlinkOAuth(t,e)}async poolOAuth(t){await this.ensureInitialized();const a=await this.authManager.poolOAuth(t);return new e.Authentication("jwt",a.token,a.player.id,a.refreshToken).save(this.storage),a}async authenticateWithThirdPartyProvider({provider:t,token:a,tokenType:i,ecosystemGame:n}){await this.ensureInitialized();const r=await this.authManager.authenticateThirdParty(t,a,i,n);return new e.Authentication("third_party",a,r.id,null,t,i).save(this.storage),r}async loginWithIdToken({provider:t,token:a,ecosystemGame:i}){await this.ensureInitialized();const n=await this.authManager.loginWithIdToken(t,a,i);return new e.Authentication("jwt",n.token,n.player.id,n.refreshToken).save(this.storage),n}async initSIWE({address:t,ecosystemGame:e}){return await this.ensureInitialized(),await this.authManager.initSIWE(t,e)}async authenticateWithSIWE({signature:t,message:a,walletClientType:i,connectorType:n}){await this.ensureInitialized();const r=await this.authManager.authenticateSIWE(t,a,i,n);return new e.Authentication("jwt",r.token,r.player.id,r.refreshToken).save(this.storage),r}async linkWallet({signature:t,message:e,walletClientType:a,connectorType:i,authToken:n}){return await this.validateAndRefreshToken(),await this.authManager.linkWallet(t,e,a,i,n)}async unlinkWallet({address:t,authToken:e}){return await this.validateAndRefreshToken(),await this.authManager.unlinkWallet(t,e)}async storeCredentials(t){if(await this.ensureInitialized(),!t.player)throw new a.OpenfortError("Player ID is required to store credentials",a.OpenfortErrorType.INVALID_CONFIGURATION);new e.Authentication("jwt",t.accessToken,t.player,t.refreshToken).save(this.storage)}async logout(){const a=await e.Authentication.fromStorage(this.storage);if(a&&a.refreshToken){try{await this.authManager.logout(a.token,a.refreshToken)}catch(t){}this.storage.remove(t.StorageKeys.AUTHENTICATION),this.eventEmitter.emit(i.OpenfortEvents.LOGGED_OUT)}}};
@@ -1 +1 @@
1
- "use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),r=require("../wallets/signer.js"),t=require("../core/configuration/account.js"),o=require("../core/configuration/authentication.js"),i=require("../core/config/config.js"),n=require("../core/errors/openfortError.js"),a=require("../wallets/evm/walletHelpers.js"),s=require("../wallets/evm/evmProvider.js");require("../wallets/evm/types.js");var d=require("../wallets/evm/provider/eip6963.js"),c=require("../utils/typedEventEmitter.js"),h=require("../types/types.js"),f=require("../wallets/iframeManager.js");exports.EmbeddedWalletApi=class{storage;validateAndRefreshToken;ensureInitialized;provider=null;iframeManager=null;constructor(e,r,t){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t}get backendApiClients(){const r=i.SDKConfiguration.fromStorage();if(!r)throw new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);return new e.BackendApiClients({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey})}getIframeManager(){if(!this.iframeManager){const e=i.SDKConfiguration.fromStorage();if(!e)throw new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);this.iframeManager=new f.IframeManager(e,this.storage)}return this.iframeManager}async configure(e={}){const t=e.recoveryParams??{recoveryMethod:h.RecoveryMethod.AUTOMATIC};await this.ensureInitialized(),await this.validateAndRefreshToken();const o=i.SDKConfiguration.fromStorage();let a=null;(t.recoveryMethod===h.RecoveryMethod.PASSWORD||e.shieldAuthentication?.encryptionSession)&&(a={encryptionSession:e.shieldAuthentication?.encryptionSession||null,recoveryPassword:t.recoveryMethod===h.RecoveryMethod.PASSWORD?t.password:null,encryptionPart:o?.shieldConfiguration?.shieldEncryptionKey||null});let s=null,d=null;if(e.shieldAuthentication&&(s="openfort"===e.shieldAuthentication.auth?"openfort":"custom",d=e.shieldAuthentication.token),!this.storage)throw new n.OpenfortError("Storage not available in EmbeddedWalletApi",n.OpenfortErrorType.INVALID_CONFIGURATION);return await r.SignerManager.embedded(this.storage,e.chainId,a,s,d),this.get()}async signMessage(e,t){await this.ensureInitialized(),await this.validateAndRefreshToken();const o=await r.SignerManager.fromStorage(this.storage);if(!o)throw new n.OpenfortError("No signer configured",n.OpenfortErrorType.MISSING_SIGNER_ERROR);const{hashMessage:i=!0,arrayifyMessage:a=!1}=t||{};return await o.sign(e,a,i)}async signTypedData(e,o,i){await this.ensureInitialized(),await this.validateAndRefreshToken();const s=await r.SignerManager.fromStorage(this.storage),d=await t.Account.fromStorage(this.storage);if(!s||!d)throw new n.OpenfortError("No signer configured",n.OpenfortErrorType.MISSING_SIGNER_ERROR);return await a.getSignedTypedData({domain:e,types:o,message:i},d.type,Number(d.chainId),s,d.address)}async exportPrivateKey(){await this.ensureInitialized(),await this.validateAndRefreshToken();const e=await r.SignerManager.fromStorage(this.storage);if(!e)throw new n.OpenfortError("No signer configured",n.OpenfortErrorType.MISSING_SIGNER_ERROR);return await e.export()}async setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:t,encryptionSession:o}){await this.ensureInitialized(),await this.validateAndRefreshToken();const i=await r.SignerManager.fromStorage(this.storage);if(!i)throw new n.OpenfortError("No signer configured",n.OpenfortErrorType.MISSING_SIGNER_ERROR);if("password"===e&&!t)throw new n.OpenfortError("Recovery password is required",n.OpenfortErrorType.INVALID_CONFIGURATION);await i.setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:t,encryptionSession:o})}async get(){const e=await t.Account.fromStorage(this.storage);if(!e)throw new n.OpenfortError("No signer configured",n.OpenfortErrorType.MISSING_SIGNER_ERROR);const r=await o.Authentication.fromStorage(this.storage);if(!r)throw new n.OpenfortError("No access token found",n.OpenfortErrorType.INTERNAL_ERROR);return{chainId:e.chainId.toString(),owner:{id:r.player},address:e.address,ownerAddress:e.ownerAddress,chainType:"ethereum",implementationType:e.type}}async list(){const e=i.SDKConfiguration.fromStorage();if(!e)throw new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);await this.ensureInitialized(),await this.validateAndRefreshToken();const r=await o.Authentication.fromStorage(this.storage);if(!r)throw new n.OpenfortError("No access token found",n.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return n.withOpenfortError(async()=>(await this.backendApiClients.accountsApi.getAccounts(void 0,{headers:{authorization:`Bearer ${e.baseConfiguration.publishableKey}`,"x-player-token":r.token,"x-auth-provider":r.thirdPartyProvider,"x-token-type":r.thirdPartyTokenType}})).data.data.map(e=>({owner:{id:e.player.id},chainType:"ethereum",address:e.address,ownerAddress:e.ownerAddress,createdAt:e.createdAt,implementationType:e.accountType,chainId:e.chainId.toString()})),{default:n.OpenfortErrorType.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await o.Authentication.fromStorage(this.storage))return h.EmbeddedState.UNAUTHENTICATED;if(!await r.SignerManager.fromStorage(this.storage))return h.EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED;return await t.Account.fromStorage(this.storage)?h.EmbeddedState.READY:h.EmbeddedState.CREATING_ACCOUNT}catch(e){return console.error("Failed to get embedded state:",e),h.EmbeddedState.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const i={announceProvider:!0,...e},n=await o.Authentication.fromStorage(this.storage),a=await r.SignerManager.fromStorage(this.storage),h=await t.Account.fromStorage(this.storage);return this.provider?this.provider&&i.policy&&this.provider.updatePolicy(i.policy):(this.provider=new s.EvmProvider({storage:this.storage,openfortEventEmitter:new c,signer:a||void 0,account:h||void 0,authentication:n||void 0,backendApiClients:this.backendApiClients,policyId:i.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:i.chains}),i.announceProvider&&d.announceProvider({info:{...d.openfortProviderInfo,...i.providerInfo},provider:this.provider})),this.provider}async ping(e){try{const r=this.getIframeManager();if(!r.isLoaded())return!1;e>0&&await new Promise(r=>{setTimeout(r,e)});const t=await o.Authentication.fromStorage(this.storage);if(t)try{return await r.getCurrentUser(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return!1}}getURL(){const e=i.SDKConfiguration.fromStorage();if(!e)throw new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);return e.iframeUrl}};
1
+ "use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),r=require("../storage/istorage.js"),t=require("../core/configuration/account.js"),n=require("../core/configuration/authentication.js"),a=require("../core/config/config.js"),i=require("../core/errors/openfortError.js"),o=require("../wallets/evm/walletHelpers.js"),s=require("../wallets/evm/evmProvider.js");require("../wallets/evm/types.js");var d=require("../wallets/evm/provider/eip6963.js"),g=require("../types/types.js"),c=require("../wallets/iframeManager.js"),u=require("../wallets/embedded.js");require("../wallets/messaging/browserMessenger/backwardCompatibility.js");var h=require("../wallets/messaging/browserMessenger/messengers/WindowMessenger.js"),f=require("../wallets/messaging/ReactNativeMessenger.js"),m=require("../utils/debug.js");exports.EmbeddedWalletApi=class{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,n){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=n,this.eventEmitter.on(g.OpenfortEvents.TOKEN_REFRESHED,()=>{m.debugLog("Handling token refresh event in EmbeddedWalletApi"),this.handleTokenRefreshed()}),this.eventEmitter.on(g.OpenfortEvents.LOGGED_OUT,()=>{m.debugLog("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=a.SDKConfiguration.fromStorage();if(!r)throw new i.OpenfortError("Configuration not found",i.OpenfortErrorType.INVALID_CONFIGURATION);return new e.BackendApiClients({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey})}async getIframeManager(){if(m.debugLog("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return m.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return m.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;m.debugLog("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return m.debugLog("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,m.debugLog("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw m.debugLog("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){m.debugLog("[HANDSHAKE DEBUG] createIframeManager starting");const e=a.SDKConfiguration.fromStorage();if(!e)throw m.debugLog("[HANDSHAKE DEBUG] Configuration not found"),new i.OpenfortError("Configuration not found",i.OpenfortErrorType.INVALID_CONFIGURATION);let r;if(m.debugLog("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)m.debugLog("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new f.ReactNativeMessenger(this.messagePoster),m.debugLog("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),r=this.messenger;else{m.debugLog("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const t=this.createIframe(e.iframeUrl),n=new URL(e.iframeUrl).origin;r=new h({remoteWindow:t.contentWindow,allowedOrigins:[n]}),m.debugLog("[HANDSHAKE DEBUG] Created WindowMessenger")}m.debugLog("[HANDSHAKE DEBUG] Creating IframeManager instance");const t=new c.IframeManager(e,this.storage,r);return m.debugLog("[HANDSHAKE DEBUG] Initializing IframeManager"),await t.initialize(),m.debugLog("[HANDSHAKE DEBUG] IframeManager initialized successfully"),t}async ensureSigner(){if(this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager(),r=new u.EmbeddedSigner(e,this.storage);return this.eventEmitter.emit(g.OpenfortEvents.SIGNER_CONFIGURED,r),r}createIframe(e){if("undefined"==typeof document)throw new i.OpenfortError("Document is not available. Please provide a message poster for non-browser environments.",i.OpenfortErrorType.INVALID_CONFIGURATION);const r=document.getElementById("openfort-iframe");r&&r.remove();const t=document.createElement("iframe");return t.style.display="none",t.id="openfort-iframe",t.src=e,document.body.appendChild(t),m.debugLog("Iframe created and appended to document"),t}async configure(e={}){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:g.RecoveryMethod.AUTOMATIC};if(!a.SDKConfiguration.fromStorage())throw new i.OpenfortError("Configuration not found",i.OpenfortErrorType.INVALID_CONFIGURATION);let o;(r.recoveryMethod===g.RecoveryMethod.PASSWORD||e.shieldAuthentication?.encryptionSession)&&(o={encryptionSession:e.shieldAuthentication?.encryptionSession,recoveryPassword:r.recoveryMethod===g.RecoveryMethod.PASSWORD?r.password:void 0});const s=await this.getIframeManager(),d=await s.configure({chainId:e.chainId,entropy:o});new t.Account(d.address,d.chainId,d.ownerAddress,d.accountType).save(this.storage);const c=new u.EmbeddedSigner(s,this.storage);this.eventEmitter.emit(g.OpenfortEvents.SIGNER_CONFIGURED,c);const h=await n.Authentication.fromStorage(this.storage);if(!h)throw new i.OpenfortError("No access token found",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{chainId:d.chainId.toString(),owner:{id:h.player},address:d.address,ownerAddress:"solana"===d.accountType?void 0:d.ownerAddress,chainType:"solana"===d.accountType?"solana":"ethereum",implementationType:"solana"===d.accountType?void 0:d.accountType}}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:n=!0,arrayifyMessage:a=!1}=r||{};return await t.sign(e,a,n)}async signTypedData(e,r,n){await this.validateAndRefreshToken();const a=await this.ensureSigner(),s=await t.Account.fromStorage(this.storage);if(!s)throw new i.OpenfortError("No account found",i.OpenfortErrorType.MISSING_SIGNER_ERROR);return await o.getSignedTypedData({domain:e,types:r,message:n},s.type,Number(s.chainId),a,s.address)}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:r,encryptionSession:t}){await this.validateAndRefreshToken();const n=await this.ensureSigner();if("password"===e&&!r)throw new i.OpenfortError("Recovery password is required",i.OpenfortErrorType.INVALID_CONFIGURATION);await n.setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:r,encryptionSession:t})}async get(){const e=await t.Account.fromStorage(this.storage);if(!e)throw new i.OpenfortError("No signer configured",i.OpenfortErrorType.MISSING_SIGNER_ERROR);const r=await n.Authentication.fromStorage(this.storage);if(!r)throw new i.OpenfortError("No access token found",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{chainId:e.chainId.toString(),owner:{id:r.player},address:e.address,ownerAddress:"solana"===e.type?void 0:e.ownerAddress,chainType:"solana"===e.type?"solana":"ethereum",implementationType:"solana"===e.type?void 0:e.type}}async list(){const e=a.SDKConfiguration.fromStorage();if(!e)throw new i.OpenfortError("Configuration not found",i.OpenfortErrorType.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const r=await n.Authentication.fromStorage(this.storage);if(!r)throw new i.OpenfortError("No access token found",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return i.withOpenfortError(async()=>(await this.backendApiClients.accountsApi.getAccounts(void 0,{headers:{authorization:`Bearer ${e.baseConfiguration.publishableKey}`,"x-player-token":r.token,"x-auth-provider":r.thirdPartyProvider,"x-token-type":r.thirdPartyTokenType}})).data.data.map(e=>({owner:{id:e.player.id},chainType:"ethereum",address:e.address,ownerAddress:e.ownerAddress,createdAt:e.createdAt,implementationType:e.accountType,chainId:e.chainId.toString()})),{default:i.OpenfortErrorType.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await n.Authentication.fromStorage(this.storage))return g.EmbeddedState.UNAUTHENTICATED;return await t.Account.fromStorage(this.storage)?g.EmbeddedState.READY:g.EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return m.debugLog("Failed to get embedded state:",e),g.EmbeddedState.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},a=await n.Authentication.fromStorage(this.storage),i=await t.Account.fromStorage(this.storage);let o;try{o=i?await this.ensureSigner():void 0}catch(e){o=void 0}return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new s.EvmProvider({storage:this.storage,openfortEventEmitter:this.eventEmitter,signer:o||void 0,account:i||void 0,authentication:a||void 0,backendApiClients:this.backendApiClients,policyId:r.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:r.chains}),r.announceProvider&&d.announceProvider({info:{...d.openfortProviderInfo,...r.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(r=>{setTimeout(r,e)});const r=await this.getIframeManager();if(!r.isLoaded())return!1;const t=await n.Authentication.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return m.debugLog("Ping failed:",e),!1}}getURL(){const e=a.SDKConfiguration.fromStorage();if(!e)throw new i.OpenfortError("Configuration not found",i.OpenfortErrorType.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new i.OpenfortError("Invalid message poster",i.OpenfortErrorType.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&(this.messenger.destroy(),this.messenger=null),this.iframeManager&&(this.iframeManager.destroy(),this.iframeManager=null,this.iframeManagerPromise=null),this.signer&&(this.signer=null,this.signerPromise=null)}async handleTokenRefreshed(){if(this.iframeManager)try{await this.iframeManager.updateAuthentication(),m.debugLog("Updated IframeManager authentication after token refresh")}catch(e){m.debugLog("Failed to update IframeManager authentication:",e)}else m.debugLog("IframeManager not initialized, skipping authentication update")}async handleLogout(){if(this.signer){try{await this.signer.disconnect(),m.debugLog("Logged out embedded signer")}catch(e){m.debugLog("Failed to logout embedded signer:",e)}this.signer=null,this.signerPromise=null}this.storage.remove(r.StorageKeys.ACCOUNT),this.iframeManager&&(this.iframeManager.destroy(),this.iframeManager=null,this.iframeManagerPromise=null),this.messenger&&(this.messenger.destroy(),this.messenger=null),this.provider&&(this.provider=null)}async onMessage(e){if(!e||"object"!=typeof e)return void m.debugLog("Invalid message received:",e);m.debugLog("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const r="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(r&&this.messenger&&this.messagePoster)return m.debugLog("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const t=await this.getIframeManager();m.debugLog(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${t.isLoaded()}`),r&&!t.isLoaded()&&m.debugLog("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),m.debugLog("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await t.onMessage(e),m.debugLog("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}};
@@ -1 +1 @@
1
- "use strict";var e=require("../wallets/signer.js"),r=require("../core/config/config.js"),t=require("../core/errors/openfortError.js");exports.ProxyApi=class{storage;backendApiClients;validateAndRefreshToken;ensureInitialized;constructor(e,r,t,i){this.storage=e,this.backendApiClients=r,this.validateAndRefreshToken=t,this.ensureInitialized=i}async sendSignatureTransactionIntentRequest(i,n=null,s=null,a=!1){await this.ensureInitialized();if(!r.SDKConfiguration.fromStorage())throw new t.OpenfortError("Configuration not found",t.OpenfortErrorType.INVALID_CONFIGURATION);await this.validateAndRefreshToken();let o=s;if(!o){if(!n)throw new t.OpenfortError("No signableHash or signature provided",t.OpenfortErrorType.OPERATION_NOT_SUPPORTED_ERROR);const r=await e.SignerManager.fromStorage(this.storage);if(!r)throw new t.OpenfortError("In order to sign a transaction intent, a signer must be configured",t.OpenfortErrorType.MISSING_SIGNER_ERROR);o=await r.sign(n)}const u={id:i,signatureRequest:{signature:o,optimistic:a}};return t.withOpenfortError(async()=>(await this.backendApiClients.transactionIntentsApi.signature(u)).data,{default:t.OpenfortErrorType.INTERNAL_ERROR})}async sendSignatureSessionRequest(e,r,i){await this.ensureInitialized();const n={id:e,signatureRequest:{signature:r,optimistic:i}};return t.withOpenfortError(async()=>(await this.backendApiClients.sessionsApi.signatureSession(n)).data,{default:t.OpenfortErrorType.INTERNAL_ERROR})}};
1
+ "use strict";var e=require("../core/config/config.js"),t=require("../core/errors/openfortError.js");exports.ProxyApi=class{storage;backendApiClients;validateAndRefreshToken;ensureInitialized;getSignerSignFunction;constructor(e,t,n,i,r){this.storage=e,this.backendApiClients=t,this.validateAndRefreshToken=n,this.ensureInitialized=i,this.getSignerSignFunction=r}async sendSignatureTransactionIntentRequest(n,i=null,r=null,s=!1){await this.ensureInitialized();if(!e.SDKConfiguration.fromStorage())throw new t.OpenfortError("Configuration not found",t.OpenfortErrorType.INVALID_CONFIGURATION);await this.validateAndRefreshToken();let o=r;if(!o){if(!i)throw new t.OpenfortError("No signableHash or signature provided",t.OpenfortErrorType.OPERATION_NOT_SUPPORTED_ERROR);if(!this.getSignerSignFunction)throw new t.OpenfortError("In order to sign a transaction intent, a signer must be configured",t.OpenfortErrorType.MISSING_SIGNER_ERROR);const e=await this.getSignerSignFunction();o=await e(i)}const a={id:n,signatureRequest:{signature:o,optimistic:s}};return t.withOpenfortError(async()=>(await this.backendApiClients.transactionIntentsApi.signature(a)).data,{default:t.OpenfortErrorType.INTERNAL_ERROR})}async sendSignatureSessionRequest(e,n,i){await this.ensureInitialized();const r={id:e,signatureRequest:{signature:n,optimistic:i}};return t.withOpenfortError(async()=>(await this.backendApiClients.sessionsApi.signatureSession(r)).data,{default:t.OpenfortErrorType.INTERNAL_ERROR})}};
@@ -1 +1 @@
1
- "use strict";var e=require("../core/configuration/authentication.js"),r=require("../core/errors/openfortError.js");exports.UserApi=class{storage;authManager;validateAndRefreshToken;ensureInitialized;constructor(e,r,t,a){this.storage=e,this.authManager=r,this.validateAndRefreshToken=t,this.ensureInitialized=a}async get(){await this.ensureInitialized(),await this.validateAndRefreshToken();const t=await e.Authentication.fromStorage(this.storage);if(!t)throw new r.OpenfortError("No access token found",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return await this.authManager.getUser(t)}};
1
+ "use strict";var r=require("../core/configuration/authentication.js"),e=require("../core/errors/openfortError.js");exports.UserApi=class{storage;authManager;validateAndRefreshToken;constructor(r,e,t){this.storage=r,this.authManager=e,this.validateAndRefreshToken=t}async get(){await this.validateAndRefreshToken();const t=await r.Authentication.fromStorage(this.storage);if(!t)throw new e.OpenfortError("No access token found",e.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return await this.authManager.getUser(t)}};
@@ -1 +1 @@
1
- "use strict";var e=require("jose"),t=require("../core/errors/openfortError.js"),r=require("../core/errors/sentry.js"),a=require("../types/types.js"),n=require("../storage/istorage.js"),i=require("../utils/crypto.js");async function o(e){const t=(new TextEncoder).encode(e),r=await i.cryptoDigest("SHA-256",t);return new Uint8Array(r)}function s(e){const t=new Uint8Array(e);return crypto.getRandomValues(t),t}class p{decodedPayload;value;constructor(r){this.value=r;try{this.decodedPayload=e.decodeJwt(r)}catch(e){throw new t.OpenfortError("Invalid token format",t.OpenfortErrorType.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||Date.now()>=1e3*(this.expiration-e)}static parse(e){try{return new p(e)}catch{return null}}}class c{storage;constructor(e){this.storage=e}async savePKCEData(e){this.storage.save(n.StorageKeys.PKCE_STATE,e.state),this.storage.save(n.StorageKeys.PKCE_VERIFIER,e.verifier)}async getPKCEData(){const e=await this.storage.get(n.StorageKeys.PKCE_STATE),t=await this.storage.get(n.StorageKeys.PKCE_VERIFIER);return e&&t?{state:e,verifier:t}:null}async clearPKCEData(){this.storage.remove(n.StorageKeys.PKCE_STATE),this.storage.remove(n.StorageKeys.PKCE_VERIFIER)}}class d{deviceCredentialsManager;backendApiClientsInstance;publishableKeyInstance;constructor(e){this.deviceCredentialsManager=new c(e)}setBackendApiClients(e,t){this.backendApiClientsInstance=e,this.publishableKeyInstance=t}get backendApiClients(){if(!this.backendApiClientsInstance)throw new t.OpenfortError("Backend API clients not initialized",t.OpenfortErrorType.INTERNAL_ERROR);return this.backendApiClientsInstance}get publishableKey(){if(!this.publishableKeyInstance)throw new t.OpenfortError("Publishable key not initialized",t.OpenfortErrorType.INTERNAL_ERROR);return this.publishableKeyInstance}async initOAuth(e,r,a){const n=r?.usePooling??!1;delete r?.usePooling;const i={oAuthInitRequest:{provider:e,options:r,usePooling:n}},o=await t.withOpenfortError(async()=>this.backendApiClients.authenticationApi.initOAuth(i,d.getEcosystemGameOptsOrUndefined(a)),{default:t.OpenfortErrorType.AUTHENTICATION_ERROR});return"undefined"==typeof window||r?.skipBrowserRedirect||window.location.assign(o.data.url),{url:o.data.url,key:o.data.key}}async registerGuest(){const e={};return t.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.registerGuest(e)).data,{default:t.OpenfortErrorType.USER_REGISTRATION_ERROR})}async poolOAuth(e){const r={key:e};for(let e=0;e<600;e++)try{const e=await t.withOpenfortError(async()=>this.backendApiClients.authenticationApi.poolOAuth(r),{default:t.OpenfortErrorType.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,a,n){const i={loginWithIdTokenRequest:{provider:e,token:a}};return t.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.loginWithIdToken(i,d.getEcosystemGameOptsOrUndefined(n))).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR,401:t.OpenfortErrorType.AUTHENTICATION_ERROR,403:t.OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{r.sentry.captureAxiosError("loginWithIdToken",e)})}async authenticateThirdParty(e,a,n,i){const o={thirdPartyOAuthRequest:{provider:e,token:a,tokenType:n}};return t.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.thirdParty(o,d.getEcosystemGameOptsOrUndefined(i))).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR,401:t.OpenfortErrorType.AUTHENTICATION_ERROR,403:t.OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{r.sentry.captureAxiosError("authenticateThirdParty",e)})}async initSIWE(e,r){const a={sIWERequest:{address:e}},n=await t.withOpenfortError(async()=>this.backendApiClients.authenticationApi.initSIWE(a,d.getEcosystemGameOptsOrUndefined(r)),{default:t.OpenfortErrorType.AUTHENTICATION_ERROR});return{address:n.data.address,nonce:n.data.nonce,expiresAt:n.data.expiresAt}}async authenticateSIWE(e,a,n,i){const o={sIWEAuthenticateRequest:{signature:e,message:a,walletClientType:n,connectorType:i}};return t.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.authenticateSIWE(o)).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR,401:t.OpenfortErrorType.AUTHENTICATION_ERROR,403:t.OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{r.sentry.captureAxiosError("authenticateSIWE",e)})}static getEcosystemGameOptsOrUndefined(e){if(e)return{headers:{"x-game":e}}}async loginEmailPassword(e,a,n){const i={loginRequest:{email:e,password:a}};return t.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.loginEmailPassword(i,d.getEcosystemGameOptsOrUndefined(n))).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR,401:t.OpenfortErrorType.AUTHENTICATION_ERROR,403:t.OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{r.sentry.captureAxiosError("loginEmailPassword",e)})}async requestResetPassword(r,n){const i=s(32),p=e.base64url.encode(i),c=await o(p),d=e.base64url.encode(c),l=s(32),u=e.base64url.encode(l);await this.deviceCredentialsManager.savePKCEData({state:u,verifier:p});const E={requestResetPasswordRequest:{email:r,redirectUrl:n,challenge:{codeChallenge:d,method:a.CodeChallengeMethodEnum.S256}}};await t.withOpenfortError(async()=>{await this.backendApiClients.authenticationApi.requestResetPassword(E)},{default:t.OpenfortErrorType.AUTHENTICATION_ERROR})}async resetPassword(e,r,a){return t.withOpenfortError(async()=>{const t=await this.deviceCredentialsManager.getPKCEData();if(!t)throw new Error("No code verifier or state for PKCE");const n={resetPasswordRequest:{email:e,password:r,state:a,challenge:{codeVerifier:t.verifier}}};await this.backendApiClients.authenticationApi.resetPassword(n)},{default:t.OpenfortErrorType.AUTHENTICATION_ERROR})}async requestEmailVerification(r,n){const i=s(32),p=e.base64url.encode(i),c=await o(p),d=e.base64url.encode(c),l=s(32),u=e.base64url.encode(l);await this.deviceCredentialsManager.savePKCEData({state:u,verifier:p});const E={requestVerifyEmailRequest:{email:r,redirectUrl:n,challenge:{codeChallenge:d,method:a.CodeChallengeMethodEnum.S256}}};await t.withOpenfortError(async()=>{await this.backendApiClients.authenticationApi.requestEmailVerification(E)},{default:t.OpenfortErrorType.AUTHENTICATION_ERROR})}async verifyEmail(e,r){return t.withOpenfortError(async()=>{const t=await this.deviceCredentialsManager.getPKCEData();if(!t)throw new Error("No code verifier or state for PKCE");const a={verifyEmailRequest:{email:e,token:r,challenge:{codeVerifier:t.verifier}}};await this.backendApiClients.authenticationApi.verifyEmail(a)},{default:t.OpenfortErrorType.AUTHENTICATION_ERROR})}async signupEmailPassword(e,a,n,i){const o={signupRequest:{email:e,password:a,name:n}};return t.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.signupEmailPassword(o,d.getEcosystemGameOptsOrUndefined(i))).data,{default:t.OpenfortErrorType.USER_REGISTRATION_ERROR,401:t.OpenfortErrorType.USER_REGISTRATION_ERROR,403:t.OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{r.sentry.captureAxiosError("signupEmailPassword",e)})}async validateCredentials(e,r){if(!e.refreshToken)throw new t.OpenfortError("No refresh token provided",t.OpenfortErrorType.AUTHENTICATION_ERROR);if(r)return this.refreshTokens(e.refreshToken,r);const a=p.parse(e.token);return a?a.isExpired()?this.refreshTokens(e.refreshToken):{player:a.subject||"",accessToken:e.token,refreshToken:e.refreshToken}:this.refreshTokens(e.refreshToken)}isTokenActive(e){if(!e)return!1;const t=p.parse(e);return null!==t&&!t.isExpired(30)}async refreshTokens(e,r){const a={refreshTokenRequest:{refreshToken:e,forceRefresh:r}};return t.withOpenfortError(async()=>{const e=await this.backendApiClients.authenticationApi.refresh(a);return{player:e.data.player.id,accessToken:e.data.token,refreshToken:e.data.refreshToken}},{default:t.OpenfortErrorType.REFRESH_TOKEN_ERROR})}async logout(e,r){const a={logoutRequest:{refreshToken:r}};return t.withOpenfortError(async()=>{await this.backendApiClients.authenticationApi.logout(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e}})},{default:t.OpenfortErrorType.LOGOUT_ERROR})}async getUser(e){return t.withOpenfortError(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:t.OpenfortErrorType.AUTHENTICATION_ERROR})}async linkThirdParty(e,r,a,n,i){const o={thirdPartyLinkRequest:{provider:r,token:a,tokenType:n}};return t.withOpenfortError(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":i||void 0}})).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR})}async linkOAuth(e,r,a,n){const i={oAuthInitRequest:{provider:r,options:a,usePooling:a?.usePooling||!1}},o=await t.withOpenfortError(async()=>this.backendApiClients.authenticationApi.linkOAuth(i,{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":n||void 0}}),{default:t.OpenfortErrorType.AUTHENTICATION_ERROR});return"undefined"==typeof window||a?.skipBrowserRedirect||window.location.assign(o.data.url),{url:o.data.url,key:o.data.key}}async unlinkOAuth(e,r){const a={unlinkOAuthRequest:{provider:e}};return t.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.unlinkOAuth(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":r}})).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR})}async unlinkWallet(e,r){const a={sIWERequest:{address:e}};return t.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.unlinkSIWE(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":r}})).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR})}async linkWallet(e,r,a,n,i){const o={sIWEAuthenticateRequest:{signature:e,message:r,walletClientType:a,connectorType:n}};return t.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.linkSIWE(o,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":i}})).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR})}async unlinkEmail(e,r){const a={unlinkEmailRequest:{email:e}};return t.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.unlinkEmail(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":r}})).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR})}async linkEmail(e,r,a,n){const i={loginRequest:{email:e,password:r}};return t.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.linkEmail(i,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":a,"x-game":n||void 0}})).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR})}}exports.AuthManager=d;
1
+ "use strict";var e=require("jose"),t=require("../utils/debug.js"),r=require("../core/errors/openfortError.js"),a=require("../core/errors/sentry.js"),n=require("../types/types.js"),i=require("../storage/istorage.js"),o=require("../utils/crypto.js");async function s(e){const t=(new TextEncoder).encode(e),r=await o.cryptoDigest("SHA-256",t);return new Uint8Array(r)}function p(e){const t=new Uint8Array(e);return crypto.getRandomValues(t),t}class d{decodedPayload;value;constructor(t){this.value=t;try{this.decodedPayload=e.decodeJwt(t)}catch(e){throw new r.OpenfortError("Invalid token format",r.OpenfortErrorType.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||(t.debugLog("Token expiration:",1e3*(this.expiration-e),"Current time:",Date.now()),Date.now()>=1e3*(this.expiration-e))}static parse(e){try{return new d(e)}catch{return null}}}class c{storage;constructor(e){this.storage=e}async savePKCEData(e){this.storage.save(i.StorageKeys.PKCE_STATE,e.state),this.storage.save(i.StorageKeys.PKCE_VERIFIER,e.verifier)}async getPKCEData(){const e=await this.storage.get(i.StorageKeys.PKCE_STATE),t=await this.storage.get(i.StorageKeys.PKCE_VERIFIER);return e&&t?{state:e,verifier:t}:null}async clearPKCEData(){this.storage.remove(i.StorageKeys.PKCE_STATE),this.storage.remove(i.StorageKeys.PKCE_VERIFIER)}}class u{deviceCredentialsManager;backendApiClientsInstance;publishableKeyInstance;constructor(e){this.deviceCredentialsManager=new c(e)}setBackendApiClients(e,t){this.backendApiClientsInstance=e,this.publishableKeyInstance=t}get backendApiClients(){if(!this.backendApiClientsInstance)throw new r.OpenfortError("Backend API clients not initialized",r.OpenfortErrorType.INTERNAL_ERROR);return this.backendApiClientsInstance}get publishableKey(){if(!this.publishableKeyInstance)throw new r.OpenfortError("Publishable key not initialized",r.OpenfortErrorType.INTERNAL_ERROR);return this.publishableKeyInstance}async initOAuth(e,t,a){const n=t?.usePooling??!1,i=t?.skipBrowserRedirect??!1,{usePooling:o,skipBrowserRedirect:s,...p}=t||{},d={oAuthInitRequest:{provider:e,options:p,usePooling:n}},c=await r.withOpenfortError(async()=>this.backendApiClients.authenticationApi.initOAuth(d,u.getEcosystemGameOptsOrUndefined(a)),{default:r.OpenfortErrorType.AUTHENTICATION_ERROR});return"undefined"==typeof window||i||window.location.assign(c.data.url),{url:c.data.url,key:c.data.key}}async registerGuest(){const e={};return r.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.registerGuest(e)).data,{default:r.OpenfortErrorType.USER_REGISTRATION_ERROR})}async poolOAuth(e){const t={key:e};for(let e=0;e<600;e++)try{const e=await r.withOpenfortError(async()=>this.backendApiClients.authenticationApi.poolOAuth(t),{default:r.OpenfortErrorType.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,n){const i={loginWithIdTokenRequest:{provider:e,token:t}};return r.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.loginWithIdToken(i,u.getEcosystemGameOptsOrUndefined(n))).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR,401:r.OpenfortErrorType.AUTHENTICATION_ERROR,403:r.OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{a.sentry.captureAxiosError("loginWithIdToken",e)})}async authenticateThirdParty(e,t,n,i){const o={thirdPartyOAuthRequest:{provider:e,token:t,tokenType:n}};return r.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.thirdParty(o,u.getEcosystemGameOptsOrUndefined(i))).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR,401:r.OpenfortErrorType.AUTHENTICATION_ERROR,403:r.OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{a.sentry.captureAxiosError("authenticateThirdParty",e)})}async initSIWE(e,t){const a={sIWERequest:{address:e}},n=await r.withOpenfortError(async()=>this.backendApiClients.authenticationApi.initSIWE(a,u.getEcosystemGameOptsOrUndefined(t)),{default:r.OpenfortErrorType.AUTHENTICATION_ERROR});return{address:n.data.address,nonce:n.data.nonce,expiresAt:n.data.expiresAt}}async authenticateSIWE(e,t,n,i){const o={sIWEAuthenticateRequest:{signature:e,message:t,walletClientType:n,connectorType:i}};return r.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.authenticateSIWE(o)).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR,401:r.OpenfortErrorType.AUTHENTICATION_ERROR,403:r.OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{a.sentry.captureAxiosError("authenticateSIWE",e)})}static getEcosystemGameOptsOrUndefined(e){if(e)return{headers:{"x-game":e}}}async loginEmailPassword(e,t,n){const i={loginRequest:{email:e,password:t}};return r.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.loginEmailPassword(i,u.getEcosystemGameOptsOrUndefined(n))).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR,401:r.OpenfortErrorType.AUTHENTICATION_ERROR,403:r.OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{a.sentry.captureAxiosError("loginEmailPassword",e)})}async requestResetPassword(t,a){const i=p(32),o=e.base64url.encode(i),d=await s(o),c=e.base64url.encode(d),u=p(32),l=e.base64url.encode(u);await this.deviceCredentialsManager.savePKCEData({state:l,verifier:o});const h={requestResetPasswordRequest:{email:t,redirectUrl:a,challenge:{codeChallenge:c,method:n.CodeChallengeMethodEnum.S256}}};await r.withOpenfortError(async()=>{await this.backendApiClients.authenticationApi.requestResetPassword(h)},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async resetPassword(e,t,a){return r.withOpenfortError(async()=>{const r=await this.deviceCredentialsManager.getPKCEData();if(!r)throw new Error("No code verifier or state for PKCE");const n={resetPasswordRequest:{email:e,password:t,state:a,challenge:{codeVerifier:r.verifier}}};await this.backendApiClients.authenticationApi.resetPassword(n)},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async requestEmailVerification(t,a){const i=p(32),o=e.base64url.encode(i),d=await s(o),c=e.base64url.encode(d),u=p(32),l=e.base64url.encode(u);await this.deviceCredentialsManager.savePKCEData({state:l,verifier:o});const h={requestVerifyEmailRequest:{email:t,redirectUrl:a,challenge:{codeChallenge:c,method:n.CodeChallengeMethodEnum.S256}}};await r.withOpenfortError(async()=>{await this.backendApiClients.authenticationApi.requestEmailVerification(h)},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async verifyEmail(e,t){return r.withOpenfortError(async()=>{const r=await this.deviceCredentialsManager.getPKCEData();if(!r)throw new Error("No code verifier or state for PKCE");const a={verifyEmailRequest:{email:e,token:t,challenge:{codeVerifier:r.verifier}}};await this.backendApiClients.authenticationApi.verifyEmail(a)},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async signupEmailPassword(e,t,n,i){const o={signupRequest:{email:e,password:t,name:n}};return r.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.signupEmailPassword(o,u.getEcosystemGameOptsOrUndefined(i))).data,{default:r.OpenfortErrorType.USER_REGISTRATION_ERROR,401:r.OpenfortErrorType.USER_REGISTRATION_ERROR,403:r.OpenfortErrorType.USER_NOT_AUTHORIZED_ON_ECOSYSTEM},e=>{a.sentry.captureAxiosError("signupEmailPassword",e)})}async validateCredentials(e,a){if(!e.refreshToken)throw new r.OpenfortError("No refresh token provided",r.OpenfortErrorType.AUTHENTICATION_ERROR);if(a)return this.refreshTokens(e.refreshToken,a);t.debugLog("Validating credentials with token:",e.token);const n=d.parse(e.token);return n?n.isExpired()?(t.debugLog("Token expired, refreshing..."),this.refreshTokens(e.refreshToken)):{player:n.subject,accessToken:e.token,refreshToken:e.refreshToken}:this.refreshTokens(e.refreshToken)}async refreshTokens(e,t){const a={refreshTokenRequest:{refreshToken:e,forceRefresh:t}};return r.withOpenfortError(async()=>{const e=await this.backendApiClients.authenticationApi.refresh(a);return{player:e.data.player.id,accessToken:e.data.token,refreshToken:e.data.refreshToken}},{default:r.OpenfortErrorType.REFRESH_TOKEN_ERROR})}async logout(e,t){const a={logoutRequest:{refreshToken:t}};return r.withOpenfortError(async()=>{await this.backendApiClients.authenticationApi.logout(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e}})},{default:r.OpenfortErrorType.LOGOUT_ERROR})}async getUser(e){return r.withOpenfortError(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:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async linkThirdParty(e,t,a,n,i){const o={thirdPartyLinkRequest:{provider:t,token:a,tokenType:n}};return r.withOpenfortError(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":i||void 0}})).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async linkOAuth(e,t,a,n){const i=a?.skipBrowserRedirect??!1;delete a?.skipBrowserRedirect;const o={oAuthInitRequest:{provider:t,options:a,usePooling:a?.usePooling||!1}},s=await r.withOpenfortError(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":n||void 0}}),{default:r.OpenfortErrorType.AUTHENTICATION_ERROR});return"undefined"==typeof window||i||window.location.assign(s.data.url),{url:s.data.url,key:s.data.key}}async unlinkOAuth(e,t){const a={unlinkOAuthRequest:{provider:e}};return r.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.unlinkOAuth(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":t}})).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async unlinkWallet(e,t){const a={sIWERequest:{address:e}};return r.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.unlinkSIWE(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":t}})).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async linkWallet(e,t,a,n,i){const o={sIWEAuthenticateRequest:{signature:e,message:t,walletClientType:a,connectorType:n}};return r.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.linkSIWE(o,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":i}})).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async unlinkEmail(e,t){const a={unlinkEmailRequest:{email:e}};return r.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.unlinkEmail(a,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":t}})).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async linkEmail(e,t,a,n){const i={loginRequest:{email:e,password:t}};return r.withOpenfortError(async()=>(await this.backendApiClients.authenticationApi.linkEmail(i,{headers:{authorization:`Bearer ${this.publishableKey}`,"x-player-token":a,"x-game":n||void 0}})).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}}exports.AuthManager=u;
@@ -1 +1 @@
1
- "use strict";var e=require("../../storage/istorage.js"),i=require("../../utils/crypto.js");let s=null;class r{publishableKey;constructor(e){this.publishableKey=e.publishableKey}}class t{shieldPublishableKey;shieldEncryptionKey;debug=!1;constructor(e){this.shieldPublishableKey=e.shieldPublishableKey,this.shieldEncryptionKey=e.shieldEncryptionKey,this.debug=e.shieldDebug||!1}}class l{baseConfiguration;shieldConfiguration;shieldUrl;iframeUrl;backendUrl;storage;constructor({baseConfiguration:e,shieldConfiguration:s,overrides:r}){this.shieldConfiguration=s,this.baseConfiguration=e,this.backendUrl=r?.backendUrl||"https://api.openfort.xyz",this.iframeUrl=r?.iframeUrl||"https://embed.openfort.xyz/iframe",this.iframeUrl=`${this.iframeUrl}/${this.baseConfiguration.publishableKey}`,s?.debug&&(this.iframeUrl=`${this.iframeUrl}?debug=true`),this.shieldUrl=r?.shieldUrl||"https://shield.openfort.xyz",this.storage=r?.storage,r?.crypto?.digest&&i.setCryptoDigestOverride(r.crypto.digest),this.save()}static async isStorageAccessible(i){try{const s=e.StorageKeys.TEST,r="openfort_storage_test";i.save(s,r);const t=await i.get(s);return i.remove(s),t===r}catch(e){return console.error("Storage accessibility check failed:",e),!1}}static fromStorage(e){return e?this.loadFromStorage(e):s}static async loadFromStorage(i){const s=await i.get(e.StorageKeys.CONFIGURATION);if(!s)return null;try{const e=JSON.parse(s),a=new r({publishableKey:e.publishableKey});let o;e.shieldPublishableKey&&(o=new t({shieldPublishableKey:e.shieldPublishableKey,shieldEncryptionKey:e.shieldEncryptionKey,shieldDebug:e.shieldDebug}));const h={backendUrl:e.backendUrl,iframeUrl:`${e.iframeUrl?.split("/")[0]}//${e.iframeUrl?.split("/")[2]}/iframe`,shieldUrl:e.shieldUrl,storage:i};return new l({baseConfiguration:a,shieldConfiguration:o,overrides:h})}catch{return null}}save(){s=this,this.storage&&this.storage.save(e.StorageKeys.CONFIGURATION,JSON.stringify({publishableKey:this.baseConfiguration.publishableKey,backendUrl:this.backendUrl,iframeUrl:this.iframeUrl,shieldUrl:this.shieldUrl,shieldPublishableKey:this.shieldConfiguration?.shieldPublishableKey,shieldEncryptionKey:this.shieldConfiguration?.shieldEncryptionKey,shieldDebug:this.shieldConfiguration?.debug}))}}exports.OpenfortConfiguration=r,exports.SDKConfiguration=l,exports.ShieldConfiguration=t;
1
+ "use strict";var e=require("../../storage/istorage.js"),i=require("../../utils/crypto.js");let s=null;class t{publishableKey;constructor(e){this.publishableKey=e.publishableKey}}class r{shieldPublishableKey;shieldEncryptionKey;debug=!1;constructor(e){this.shieldPublishableKey=e.shieldPublishableKey,this.shieldEncryptionKey=e.shieldEncryptionKey,this.debug=e.shieldDebug||!1}}class l{baseConfiguration;shieldConfiguration;shieldUrl;iframeUrl;backendUrl;storage;constructor({baseConfiguration:e,shieldConfiguration:s,overrides:t}){this.shieldConfiguration=s,this.baseConfiguration=e,this.backendUrl=t?.backendUrl||"https://api.openfort.io",this.iframeUrl=t?.iframeUrl||"https://embed.openfort.io",this.iframeUrl=`${this.iframeUrl}/iframe/${this.baseConfiguration.publishableKey}`,s?.debug&&(this.iframeUrl=`${this.iframeUrl}?debug=true`),this.shieldUrl=t?.shieldUrl||"https://shield.openfort.io",this.storage=t?.storage,t?.crypto?.digest&&i.setCryptoDigestOverride(t.crypto.digest),this.save()}static async isStorageAccessible(i){try{const s=e.StorageKeys.TEST,t="openfort_storage_test";i.save(s,t);const r=await i.get(s);return i.remove(s),r===t}catch(e){return!1}}static fromStorage(e){return e?this.loadFromStorage(e):s}static async loadFromStorage(i){const s=await i.get(e.StorageKeys.CONFIGURATION);if(!s)return null;try{const e=JSON.parse(s),a=new t({publishableKey:e.publishableKey});let o;e.shieldPublishableKey&&(o=new r({shieldPublishableKey:e.shieldPublishableKey,shieldEncryptionKey:e.shieldEncryptionKey,shieldDebug:e.shieldDebug}));const h={backendUrl:e.backendUrl,iframeUrl:e.iframeUrl,shieldUrl:e.shieldUrl,storage:i};return new l({baseConfiguration:a,shieldConfiguration:o,overrides:h})}catch{return null}}save(){s=this,this.storage&&this.storage.save(e.StorageKeys.CONFIGURATION,JSON.stringify({publishableKey:this.baseConfiguration.publishableKey,backendUrl:this.backendUrl,iframeUrl:this.iframeUrl,shieldUrl:this.shieldUrl,shieldPublishableKey:this.shieldConfiguration?.shieldPublishableKey,shieldEncryptionKey:this.shieldConfiguration?.shieldEncryptionKey,shieldDebug:this.shieldConfiguration?.debug}))}}exports.OpenfortConfiguration=t,exports.SDKConfiguration=l,exports.ShieldConfiguration=r;
@@ -1 +1 @@
1
- "use strict";var R,E=require("axios");exports.OpenfortErrorType=void 0,(R=exports.OpenfortErrorType||(exports.OpenfortErrorType={})).AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",R.INVALID_CONFIGURATION="INVALID_CONFIGURATION",R.NOT_LOGGED_IN_ERROR="NOT_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_SESSION_SIGNER_ERROR="MISSING_SESSION_SIGNER_ERROR",R.MISSING_EMBEDDED_SIGNER_ERROR="MISSING_EMBEDDED_SIGNER_ERROR",R.MISSING_SIGNER_ERROR="MISSING_SIGNER_ERROR",R.USER_NOT_AUTHORIZED_ON_ECOSYSTEM="USER_NOT_AUTHORIZED_ON_ECOSYSTEM",R.INTERNAL_ERROR="INTERNAL_ERROR";class O extends Error{type;data;constructor(R,E,O={}){super(R),this.type=E,this.data=O}}exports.OpenfortError=O,exports.withOpenfortError=async(R,r,_)=>{try{return await R()}catch(R){let e;const I={};let N;E.isAxiosError(R)?(N=R.response?.status,e=R.response?.data&&R.response.data.error&&function(R){return"type"in R&&"message"in R}(R.response.data.error)?R.response.data.error.message:R.message):e=R.message;const t=void 0!==N&&r[N]?r[N]:r.default,s=new O(e,t,I);throw void 0!==N&&r[N]||_?.(R,s),s}};
1
+ "use strict";var R,E=require("axios");exports.OpenfortErrorType=void 0,(R=exports.OpenfortErrorType||(exports.OpenfortErrorType={})).AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",R.INVALID_CONFIGURATION="INVALID_CONFIGURATION",R.NOT_LOGGED_IN_ERROR="NOT_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_EMBEDDED_SIGNER_ERROR="MISSING_EMBEDDED_SIGNER_ERROR",R.MISSING_SIGNER_ERROR="MISSING_SIGNER_ERROR",R.USER_NOT_AUTHORIZED_ON_ECOSYSTEM="USER_NOT_AUTHORIZED_ON_ECOSYSTEM",R.INTERNAL_ERROR="INTERNAL_ERROR";class r extends Error{type;data;constructor(R,E,r={}){super(R),this.type=E,this.data=r}}exports.OpenfortError=r,exports.withOpenfortError=async(R,O,e)=>{try{return await R()}catch(R){let _;const t={};let s;E.isAxiosError(R)?(s=R.response?.status,_=R.response?.data&&R.response.data.error&&function(R){return"type"in R&&"message"in R}(R.response.data.error)?R.response.data.error.message:R.message):_=R.message;const N=void 0!==s&&O[s]?O[s]:O.default,o=new r(_,N,t);throw void 0!==s&&O[s]||e?.(R,o),o}};
@@ -1 +1 @@
1
- "use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),t=require("./errors/sentry.js"),i=require("../storage/lazyStorage.js"),n=require("./errors/openfortError.js"),r=require("./config/config.js"),a=require("../auth/authManager.js"),s=require("../api/auth.js"),o=require("../api/embeddedWallet.js"),h=require("../api/user.js"),l=require("../api/proxy.js"),c=require("./openfortInternal.js");exports.Openfort=class{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;configuration;get auth(){if(!this.authInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.userInstance}get proxy(){if(!this.proxyInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.proxyInstance}initializeSynchronously(){try{this.iAuthManager=new a.AuthManager(this.storage),this.openfortInternal=new c.OpenfortInternal(this.storage,this.authManager),this.authInstance=new s.AuthApi(this.storage,this.authManager,()=>this.openfortInternal.validateAndRefreshToken(),this.ensureInitialized.bind(this)),this.embeddedWalletInstance=new o.EmbeddedWalletApi(this.storage,()=>this.openfortInternal.validateAndRefreshToken(),this.ensureInitialized.bind(this)),this.userInstance=new h.UserApi(this.storage,this.authManager,()=>this.openfortInternal.validateAndRefreshToken(),this.ensureInitialized.bind(this)),this.proxyInstance=new l.ProxyApi(this.storage,this.backendApiClients,()=>this.openfortInternal.validateAndRefreshToken(),this.ensureInitialized.bind(this))}catch(e){throw new n.OpenfortError("Openfort SDK synchronous initialization failed",n.OpenfortErrorType.INVALID_CONFIGURATION)}}constructor(e){this.configuration=new r.SDKConfiguration(e),this.storage=new i.LazyStorage(this.configuration.storage),t.InternalSentry.init({configuration:this.configuration}),this.initializeSynchronously(),this.initPromise=Promise.resolve()}async waitForInitialization(){await this.initPromise,await this.ensureAsyncInitialized()}async getAccessToken(){return await this.ensureInitialized(),this.openfortInternal.getAccessToken()}async validateAndRefreshToken(e){return await this.ensureInitialized(),this.openfortInternal.validateAndRefreshToken(e)}get backendApiClients(){return new e.BackendApiClients({basePath:this.configuration.backendUrl,accessToken:this.configuration.baseConfiguration.publishableKey})}get authManager(){if(!this.iAuthManager)throw new n.OpenfortError("AuthManager not initialized",n.OpenfortErrorType.INTERNAL_ERROR);return this.iAuthManager}async initializeAsync(){try{if(!await r.SDKConfiguration.isStorageAccessible(this.storage))throw new n.OpenfortError("Storage is not accessible",n.OpenfortErrorType.INVALID_CONFIGURATION);this.authManager.setBackendApiClients(this.backendApiClients,this.configuration.baseConfiguration.publishableKey)}catch(e){throw new n.OpenfortError("Openfort SDK async initialization failed",n.OpenfortErrorType.INTERNAL_ERROR)}}async ensureAsyncInitialized(){this.asyncInitPromise||(this.asyncInitPromise=this.initializeAsync()),await this.asyncInitPromise}async ensureInitialized(){await this.initPromise,await this.ensureAsyncInitialized()}};
1
+ "use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),t=require("./errors/sentry.js"),i=require("../storage/lazyStorage.js"),n=require("./errors/openfortError.js"),r=require("./config/config.js"),a=require("../auth/authManager.js"),s=require("../api/auth.js"),o=require("../api/embeddedWallet.js"),h=require("../api/user.js"),l=require("../api/proxy.js"),c=require("./openfortInternal.js"),u=require("../utils/typedEventEmitter.js");exports.Openfort=class{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;configuration;eventEmitter;get auth(){if(!this.authInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.userInstance}get proxy(){if(!this.proxyInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.proxyInstance}initializeSynchronously(){try{this.iAuthManager=new a.AuthManager(this.storage),this.openfortInternal=new c.OpenfortInternal(this.storage,this.authManager,this.eventEmitter),this.authInstance=new s.AuthApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.embeddedWalletInstance=new o.EmbeddedWalletApi(this.storage,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.userInstance=new h.UserApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this)),this.proxyInstance=new l.ProxyApi(this.storage,this.backendApiClients,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),async()=>{if(!this.embeddedWalletInstance)throw new n.OpenfortError("Embedded wallet not initialized",n.OpenfortErrorType.MISSING_SIGNER_ERROR);const e=this.embeddedWalletInstance;return t=>e.signMessage(t,{hashMessage:!1,arrayifyMessage:!1})})}catch(e){throw new n.OpenfortError("Openfort SDK synchronous initialization failed",n.OpenfortErrorType.INVALID_CONFIGURATION)}}constructor(e){this.configuration=new r.SDKConfiguration(e),this.storage=new i.LazyStorage(this.configuration.storage),this.eventEmitter=new u,t.InternalSentry.init({configuration:this.configuration}),this.initializeSynchronously(),this.initPromise=Promise.resolve()}async waitForInitialization(){await this.initPromise,await this.ensureAsyncInitialized()}async getAccessToken(){return await this.ensureInitialized(),this.openfortInternal.getAccessToken()}async validateAndRefreshToken(e){return await this.ensureInitialized(),await this.openfortInternal.validateAndRefreshToken(e)}get backendApiClients(){return new e.BackendApiClients({basePath:this.configuration.backendUrl,accessToken:this.configuration.baseConfiguration.publishableKey})}get authManager(){if(!this.iAuthManager)throw new n.OpenfortError("AuthManager not initialized",n.OpenfortErrorType.INTERNAL_ERROR);return this.iAuthManager}async initializeAsync(){try{if(!await r.SDKConfiguration.isStorageAccessible(this.storage))throw new n.OpenfortError("Storage is not accessible",n.OpenfortErrorType.INVALID_CONFIGURATION);this.authManager.setBackendApiClients(this.backendApiClients,this.configuration.baseConfiguration.publishableKey)}catch(e){throw new n.OpenfortError("Openfort SDK async initialization failed",n.OpenfortErrorType.INTERNAL_ERROR)}}async ensureAsyncInitialized(){this.asyncInitPromise||(this.asyncInitPromise=this.initializeAsync()),await this.asyncInitPromise}async ensureInitialized(){await this.initPromise,await this.ensureAsyncInitialized()}};
@@ -1 +1 @@
1
- "use strict";var r=require("../wallets/signer.js"),e=require("./errors/openfortError.js"),t=require("./configuration/authentication.js"),a=require("../wallets/iframeManager.js");exports.OpenfortInternal=class{storage;authManager;constructor(r,e){this.storage=r,this.authManager=e}async getAccessToken(){return(await t.Authentication.fromStorage(this.storage))?.token??null}async validateAndRefreshToken(o){const n=await t.Authentication.fromStorage(this.storage);if(!n)throw new e.OpenfortError("Must be logged in to validate and refresh token",e.OpenfortErrorType.NOT_LOGGED_IN_ERROR);if("jwt"!==n.type)return;const s=await this.authManager.validateCredentials(n,o);if(!s.player)throw new e.OpenfortError("No player found in credentials",e.OpenfortErrorType.INTERNAL_ERROR);if(s.accessToken===n.token)return;new t.Authentication("jwt",s.accessToken,s.player,s.refreshToken).save(this.storage);const i=await r.SignerManager.fromStorage(this.storage);try{await(i?.updateAuthentication())}catch(r){throw(r instanceof a.MissingRecoveryPasswordError||r instanceof a.MissingProjectEntropyError)&&await(i?.logout()),r}}};
1
+ "use strict";var e=require("../utils/debug.js"),t=require("../storage/istorage.js"),r=require("./errors/openfortError.js"),n=require("./configuration/authentication.js"),o=require("../types/types.js");exports.OpenfortInternal=class{storage;authManager;eventEmitter;constructor(e,t,r){this.storage=e,this.authManager=t,this.eventEmitter=r}async getAccessToken(){return(await n.Authentication.fromStorage(this.storage))?.token??null}async validateAndRefreshToken(s){const a=await n.Authentication.fromStorage(this.storage);if(!a)throw new r.OpenfortError("Must be logged in to validate and refresh token",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);if("jwt"!==a.type)return;let i;e.debugLog("validating credentials...");try{i=await this.authManager.validateCredentials(a,s)}catch(e){throw this.storage.remove(t.StorageKeys.AUTHENTICATION),this.eventEmitter.emit(o.OpenfortEvents.LOGGED_OUT),e}if(!i.player)throw new r.OpenfortError("No user found in credentials",r.OpenfortErrorType.INTERNAL_ERROR);i.accessToken!==a.token&&(e.debugLog("tokens refreshed"),new n.Authentication("jwt",i.accessToken,i.player,i.refreshToken).save(this.storage),this.eventEmitter.emit(o.OpenfortEvents.TOKEN_REFRESHED))}};
@@ -1 +1 @@
1
- "use strict";var o;exports.StorageKeys=void 0,(o=exports.StorageKeys||(exports.StorageKeys={})).AUTHENTICATION="openfort.authentication",o.SIGNER="openfort.signer",o.CONFIGURATION="openfort.configuration",o.ACCOUNT="openfort.account",o.TEST="openfort.test",o.RECOVERY="openfort.recovery",o.SESSION="openfort.session",o.PKCE_STATE="openfort.pkce_state",o.PKCE_VERIFIER="openfort.pkce_verifier";
1
+ "use strict";var o;exports.StorageKeys=void 0,(o=exports.StorageKeys||(exports.StorageKeys={})).AUTHENTICATION="openfort.authentication",o.CONFIGURATION="openfort.configuration",o.ACCOUNT="openfort.account",o.TEST="openfort.test",o.SESSION="openfort.session",o.PKCE_STATE="openfort.pkce_state",o.PKCE_VERIFIER="openfort.pkce_verifier";
@@ -1 +1 @@
1
- "use strict";var e,o,t,r,E,A,d,p,s;exports.EmbeddedState=void 0,(e=exports.EmbeddedState||(exports.EmbeddedState={}))[e.NONE=0]="NONE",e[e.UNAUTHENTICATED=1]="UNAUTHENTICATED",e[e.EMBEDDED_SIGNER_NOT_CONFIGURED=2]="EMBEDDED_SIGNER_NOT_CONFIGURED",e[e.CREATING_ACCOUNT=3]="CREATING_ACCOUNT",e[e.READY=4]="READY",exports.OpenfortEvents=void 0,(exports.OpenfortEvents||(exports.OpenfortEvents={})).LOGGED_OUT="loggedOut",exports.RecoveryMethod=void 0,(o=exports.RecoveryMethod||(exports.RecoveryMethod={})).PASSWORD="password",o.AUTOMATIC="automatic",exports.AccountType=void 0,(t=exports.AccountType||(exports.AccountType={})).UPGRADEABLE_V4="Upgradeable_v04",t.MANAGED_V4="Managed_v04",t.ERC6551_V4="ERC6551_v04",t.ERC6551_V5="ERC6551_v05",t.RECOVERABLE_V4="Recoverable_v04",t.MANAGED_V5="Managed_v05",t.UPGRADEABLE_V5="Upgradeable_v05",t.UPGRADEABLE_V6="Upgradeable_v06",t.ZKSYNC_UPGRADEABLE_V1="zksync_upgradeable_v1",t.ZKSYNC_UPGRADEABLE_V2="zksync_upgradeable_v2",exports.AuthType=void 0,(r=exports.AuthType||(exports.AuthType={})).OPENFORT="openfort",r.THIRD_PARTY="thirdParty",exports.TokenType=void 0,(E=exports.TokenType||(exports.TokenType={})).ID_TOKEN="idToken",E.CUSTOM_TOKEN="customToken",exports.ThirdPartyOAuthProvider=void 0,(A=exports.ThirdPartyOAuthProvider||(exports.ThirdPartyOAuthProvider={})).ACCELBYTE="accelbyte",A.FIREBASE="firebase",A.LOOTLOCKER="lootlocker",A.PLAYFAB="playfab",A.SUPABASE="supabase",A.CUSTOM="custom",A.OIDC="oidc",exports.BasicAuthProvider=void 0,(d=exports.BasicAuthProvider||(exports.BasicAuthProvider={})).EMAIL="email",d.WALLET="wallet",exports.OAuthProvider=void 0,(p=exports.OAuthProvider||(exports.OAuthProvider={})).GOOGLE="google",p.TWITTER="twitter",p.APPLE="apple",p.FACEBOOK="facebook",p.DISCORD="discord",p.EPIC_GAMES="epic_games",p.LINE="line",exports.AuthActionRequiredActions=void 0,(exports.AuthActionRequiredActions||(exports.AuthActionRequiredActions={})).ACTION_VERIFY_EMAIL="verify_email",exports.CodeChallengeMethodEnum=void 0,(s=exports.CodeChallengeMethodEnum||(exports.CodeChallengeMethodEnum={})).PLAIN="plain",s.S256="S256";
1
+ "use strict";var e,o,t,r,E,A,d,p,s,i;exports.EmbeddedState=void 0,(e=exports.EmbeddedState||(exports.EmbeddedState={}))[e.NONE=0]="NONE",e[e.UNAUTHENTICATED=1]="UNAUTHENTICATED",e[e.EMBEDDED_SIGNER_NOT_CONFIGURED=2]="EMBEDDED_SIGNER_NOT_CONFIGURED",e[e.CREATING_ACCOUNT=3]="CREATING_ACCOUNT",e[e.READY=4]="READY",exports.OpenfortEvents=void 0,(o=exports.OpenfortEvents||(exports.OpenfortEvents={})).LOGGED_OUT="loggedOut",o.SIGNER_CONFIGURED="signerConfigured",o.TOKEN_REFRESHED="tokenRefreshed",exports.RecoveryMethod=void 0,(t=exports.RecoveryMethod||(exports.RecoveryMethod={})).PASSWORD="password",t.AUTOMATIC="automatic",exports.AccountType=void 0,(r=exports.AccountType||(exports.AccountType={})).UPGRADEABLE_V4="Upgradeable_v04",r.MANAGED_V4="Managed_v04",r.ERC6551_V4="ERC6551_v04",r.ERC6551_V5="ERC6551_v05",r.RECOVERABLE_V4="Recoverable_v04",r.MANAGED_V5="Managed_v05",r.UPGRADEABLE_V5="Upgradeable_v05",r.UPGRADEABLE_V6="Upgradeable_v06",r.ZKSYNC_UPGRADEABLE_V1="zksync_upgradeable_v1",r.ZKSYNC_UPGRADEABLE_V2="zksync_upgradeable_v2",exports.AuthType=void 0,(E=exports.AuthType||(exports.AuthType={})).OPENFORT="openfort",E.THIRD_PARTY="thirdParty",exports.TokenType=void 0,(A=exports.TokenType||(exports.TokenType={})).ID_TOKEN="idToken",A.CUSTOM_TOKEN="customToken",exports.ThirdPartyOAuthProvider=void 0,(d=exports.ThirdPartyOAuthProvider||(exports.ThirdPartyOAuthProvider={})).ACCELBYTE="accelbyte",d.FIREBASE="firebase",d.LOOTLOCKER="lootlocker",d.PLAYFAB="playfab",d.SUPABASE="supabase",d.CUSTOM="custom",d.OIDC="oidc",exports.BasicAuthProvider=void 0,(p=exports.BasicAuthProvider||(exports.BasicAuthProvider={})).EMAIL="email",p.WALLET="wallet",exports.OAuthProvider=void 0,(s=exports.OAuthProvider||(exports.OAuthProvider={})).GOOGLE="google",s.TWITTER="twitter",s.APPLE="apple",s.FACEBOOK="facebook",s.DISCORD="discord",s.EPIC_GAMES="epic_games",s.LINE="line",exports.AuthActionRequiredActions=void 0,(exports.AuthActionRequiredActions||(exports.AuthActionRequiredActions={})).ACTION_VERIFY_EMAIL="verify_email",exports.CodeChallengeMethodEnum=void 0,(i=exports.CodeChallengeMethodEnum||(exports.CodeChallengeMethodEnum={})).PLAIN="plain",i.S256="S256";
@@ -0,0 +1 @@
1
+ "use strict";var o=require("../core/config/config.js");exports.debugLog=function(...e){const n=o.SDKConfiguration.fromStorage();n?.shieldConfiguration?.debug&&console.log(`${(new Date).toISOString()} [SDK]`,...e)};
@@ -1 +1 @@
1
- "use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.9.2";
1
+ "use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.9.4";
@@ -1 +1 @@
1
- "use strict";var e=require("../core/configuration/account.js"),r=require("../core/configuration/authentication.js"),t=require("../core/errors/openfortError.js"),a=require("../core/configuration/recovery.js"),i=require("./types.js"),o=require("../storage/istorage.js");exports.EmbeddedSigner=class{iframeManager;iframeConfiguration;storage;constructor(e,r,t){this.iframeManager=e,this.iframeConfiguration=r,this.storage=t}async sign(e,r,t){return await this.iframeManager.sign(this.iframeConfiguration,e,r,t)}async export(){return await this.iframeManager.export(this.iframeConfiguration)}async switchChain({chainId:r}){const t=await this.iframeManager.switchChain(this.iframeConfiguration,r);new e.Account(t.address,t.chainId,t.ownerAddress,t.accountType).save(this.storage)}async setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:r,encryptionSession:t}){await this.iframeManager.setEmbeddedRecovery(this.iframeConfiguration,e,r,t)}async logout(){await this.iframeManager.logout(),this.storage.remove(o.StorageKeys.RECOVERY)}async updateAuthentication(){const e=await r.Authentication.fromStorage(this.storage);if(!e)throw new t.OpenfortError("Must provide authentication to update authentication",t.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const o=await a.Recovery.fromStorage(this.storage);if(!o)throw new t.OpenfortError("Must have recovery to update authentication",t.OpenfortErrorType.INVALID_CONFIGURATION);await this.iframeManager.updateAuthentication(this.iframeConfiguration,e.token,"openfort"===o.type?i.ShieldAuthType.OPENFORT:i.ShieldAuthType.CUSTOM)}};
1
+ "use strict";var e=require("../utils/debug.js"),a=require("../core/configuration/account.js");exports.EmbeddedSigner=class{iframeManager;storage;constructor(e,a){this.iframeManager=e,this.storage=a}async sign(a,r,s){return e.debugLog("Signing message:",a,"requireArrayify:",r,"requireHash:",s),await this.iframeManager.sign(a,r,s)}async export(){return await this.iframeManager.export()}async switchChain({chainId:e}){const r=await this.iframeManager.switchChain(e);new a.Account(r.address,r.chainId,r.ownerAddress,r.accountType).save(this.storage)}async setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:a,encryptionSession:r}){await this.iframeManager.setEmbeddedRecovery(e,a,r)}async disconnect(){await this.iframeManager.disconnect()}};
@@ -1 +1 @@
1
- "use strict";var r=require("../signer.js"),e=require("./JsonRpcError.js");const n=["chainId","chainName","nativeCurrency"],o=r=>{if(!r||"object"!=typeof r)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"Invalid chain parameter: expected an object");if(!(r=>n.every(e=>e in r))(r))throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,`Invalid chain parameter. The following properties are required: ${n.join(", ")}`);if(!r.chainName||""===r.chainName.trim())throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"chainName cannot be empty");if(!((o=r.nativeCurrency)&&"object"==typeof o&&"name"in o&&"symbol"in o&&"decimals"in o&&"string"==typeof o.name&&"string"==typeof o.symbol&&"number"==typeof o.decimals&&Number.isInteger(o.decimals)))throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"Invalid nativeCurrency object");var o;if(0===r.rpcUrls?.length)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"At least one RPC URL must be provided");if(!/^0x[0-9a-fA-F]+$/.test(r.chainId))throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"chainId must be a valid hex string");return{chainId:r.chainId,blockExplorerUrls:r.blockExplorerUrls||[],chainName:r.chainName,iconUrls:r.iconUrls||[],rpcUrls:r.rpcUrls||[],nativeCurrency:r.nativeCurrency}};exports.addEthereumChain=async({params:n,rpcProvider:a,storage:i})=>{if(!n||!Array.isArray(n)||0===n.length)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"Invalid parameters for wallet_addEthereumChain");const c=o(n[0]),t=parseInt(c.chainId,16),{chainId:s}=await a.detectNetwork();if(t===s)return!1;try{if(!await r.SignerManager.embedded(i))throw new e.JsonRpcError(e.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - no account available");return null}catch(r){if(r instanceof Error)throw new e.JsonRpcError(e.RpcErrorCode.INTERNAL_ERROR,`Failed to add chain: ${r.message}`);throw new e.JsonRpcError(e.RpcErrorCode.INTERNAL_ERROR,"Failed to add chain")}};
1
+ "use strict";var r=require("./JsonRpcError.js");const e=["chainId","chainName","nativeCurrency"],n=n=>{if(!n||"object"!=typeof n)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"Invalid chain parameter: expected an object");if(!(r=>e.every(e=>e in r))(n))throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,`Invalid chain parameter. The following properties are required: ${e.join(", ")}`);if(!n.chainName||""===n.chainName.trim())throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"chainName cannot be empty");if(!((o=n.nativeCurrency)&&"object"==typeof o&&"name"in o&&"symbol"in o&&"decimals"in o&&"string"==typeof o.name&&"string"==typeof o.symbol&&"number"==typeof o.decimals&&Number.isInteger(o.decimals)))throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"Invalid nativeCurrency object");var o;if(0===n.rpcUrls?.length)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"At least one RPC URL must be provided");if(!/^0x[0-9a-fA-F]+$/.test(n.chainId))throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"chainId must be a valid hex string");return{chainId:n.chainId,blockExplorerUrls:n.blockExplorerUrls||[],chainName:n.chainName,iconUrls:n.iconUrls||[],rpcUrls:n.rpcUrls||[],nativeCurrency:n.nativeCurrency}};exports.addEthereumChain=async({params:e,rpcProvider:o,storage:a})=>{if(!e||!Array.isArray(e)||0===e.length)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"Invalid parameters for wallet_addEthereumChain");const i=n(e[0]),c=parseInt(i.chainId,16),{chainId:t}=await o.detectNetwork();return c!==t&&null};
@@ -1 +1 @@
1
- "use strict";var e=require("../../core/configuration/authentication.js"),t=require("./types.js"),r=require("./JsonRpcError.js"),a=require("./signTypedDataV4.js"),i=require("../../types/types.js"),s=require("../../utils/typedEventEmitter.js"),o=require("../../utils/chains/index.js"),n=require("../../core/configuration/account.js"),c=require("../signer.js"),h=require("../../storage/istorage.js"),d=require("./addEthereumChain.js"),u=require("./registerSession.js"),g=require("./revokeSession.js"),p=require("./sendCalls.js"),l=require("./getCallsStatus.js"),w=require("./personalSign.js"),m=require("./estimateGas.js"),f=require("../../utils/crypto.js");exports.EvmProvider=class{#e;#t;#r;updatePolicy(e){this.#t=e}#a;#i;#s=null;#o;isOpenfort=!0;constructor({storage:e,backendApiClients:t,openfortEventEmitter:r,policyId:a,chains:o,validateAndRefreshSession:n}){this.#e=e,this.#r=o,this.#t=a,this.#a=n,this.#o=t,this.#o=t,this.#i=new s,r.on(i.OpenfortEvents.LOGGED_OUT,this.#n)}#n=async()=>{const e=!!await n.Account.fromStorage(this.#e),r=await c.SignerManager.fromStorage(this.#e);r?.logout(),this.#e.remove(h.StorageKeys.ACCOUNT),this.#e.remove(h.StorageKeys.AUTHENTICATION),e&&this.#i.emit(t.ProviderEvent.ACCOUNTS_CHANGED,[])};async getRpcProvider(){if(!this.#s){const e=await n.Account.fromStorage(this.#e),t=e?.chainId||8453;await import("@ethersproject/providers").then(e=>{const r=this.#r?this.#r[t]:void 0;this.#s=new e.StaticJsonRpcProvider(r??o.defaultChainRpcs[t])})}if(!this.#s)throw new Error("RPC provider not initialized");return this.#s}async#c(i){switch(i.method){case"eth_accounts":{const e=await n.Account.fromStorage(this.#e);return e?[e.address]:[]}case"eth_requestAccounts":{let e=await n.Account.fromStorage(this.#e);if(e)return this.#i.emit(t.ProviderEvent.ACCOUNTS_CONNECT,{chainId:f.numberToHex(e.chainId)}),[e.address];if(!await c.SignerManager.fromStorage(this.#e))throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - must be authenticated and configured with a signer");if(await c.SignerManager.embedded(this.#e),e=await n.Account.fromStorage(this.#e),!e)throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - no account available");return this.#i.emit(t.ProviderEvent.ACCOUNTS_CHANGED,[e.address]),[e.address]}case"eth_sendTransaction":{const t=await n.Account.fromStorage(this.#e),a=await c.SignerManager.fromStorage(this.#e),s=await e.Authentication.fromStorage(this.#e);if(!t||!a||!s)throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await p.sendCalls({params:i.params||[],signer:a,account:t,authentication:s,backendClient:this.#o,policyId:this.#t})}case"eth_estimateGas":{const t=await n.Account.fromStorage(this.#e),a=await e.Authentication.fromStorage(this.#e);if(!t||!a)throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await m.estimateGas({params:i.params||[],account:t,authentication:a,backendClient:this.#o,policyId:this.#t})}case"eth_signTypedData":case"eth_signTypedData_v4":{const e=await n.Account.fromStorage(this.#e),t=await c.SignerManager.fromStorage(this.#e);if(!e||!t)throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#a();const s=await this.getRpcProvider();return await a.signTypedDataV4({method:i.method,params:i.params||[],signer:t,accountType:e.type,rpcProvider:s})}case"personal_sign":{const e=await n.Account.fromStorage(this.#e),t=await c.SignerManager.fromStorage(this.#e);if(!e||!t)throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await w.personalSign({params:i.params||[],signer:t,account:e})}case"eth_chainId":{const e=await this.getRpcProvider(),{chainId:t}=await e.detectNetwork();return f.numberToHex(t)}case"wallet_switchEthereumChain":{const e=await c.SignerManager.fromStorage(this.#e);if(!e)throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - must be authenticated and configured with a signer");if(!i.params||!Array.isArray(i.params)||0===i.params.length)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"Invalid parameters for wallet_switchEthereumChain");await this.#a();try{const t=parseInt(i.params[0].chainId,16);await e.switchChain({chainId:t}),await import("@ethersproject/providers").then(e=>{const r=this.#r?this.#r[t]:void 0;this.#s=new e.StaticJsonRpcProvider(r??o.defaultChainRpcs[t])})}catch(e){throw new r.JsonRpcError(r.RpcErrorCode.INTERNAL_ERROR,"Failed to switch chain")}return null}case"wallet_addEthereumChain":{if(!await c.SignerManager.fromStorage(this.#e))throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - must be authenticated and configured with a signer");const e=await this.getRpcProvider();return await d.addEthereumChain({params:i.params||[],rpcProvider:e,storage:this.#e})}case"wallet_showCallsStatus":return null;case"wallet_getCallsStatus":{const t=await n.Account.fromStorage(this.#e),a=await c.SignerManager.fromStorage(this.#e),s=await e.Authentication.fromStorage(this.#e);if(!t||!a||!s)throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await l.getCallStatus({params:i.params||{},authentication:s,backendClient:this.#o,account:t})}case"wallet_sendCalls":{const t=await n.Account.fromStorage(this.#e),a=await c.SignerManager.fromStorage(this.#e),s=await e.Authentication.fromStorage(this.#e);if(!t||!a||!s)throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await p.sendCalls({params:i.params?i.params[0].calls:[],signer:a,account:t,authentication:s,backendClient:this.#o,policyId:this.#t})}case"wallet_grantPermissions":{const t=await n.Account.fromStorage(this.#e),a=await c.SignerManager.fromStorage(this.#e),s=await e.Authentication.fromStorage(this.#e);if(!t||!a||!s)throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await u.registerSession({params:i.params||[],signer:a,account:t,authentication:s,backendClient:this.#o,policyId:this.#t})}case"wallet_revokePermissions":{const t=await n.Account.fromStorage(this.#e),a=await c.SignerManager.fromStorage(this.#e),s=await e.Authentication.fromStorage(this.#e);if(!t||!a||!s)throw new r.JsonRpcError(r.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await g.revokeSession({params:i.params||[],signer:a,account:t,authentication:s,backendClient:this.#o})}case"wallet_getCapabilities":{const e=await this.getRpcProvider(),{chainId:t}=await e.detectNetwork();return{[f.numberToHex(t)]:{permissions:{supported:!0,signerTypes:["account","key"],keyTypes:["secp256k1"],permissionTypes:["contract-calls"]},paymasterService:{supported:!0},atomicBatch:{supported:!0}}}}case"eth_gasPrice":case"eth_getBalance":case"eth_getCode":case"eth_getStorageAt":case"eth_call":case"eth_blockNumber":case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getTransactionByHash":case"eth_getTransactionReceipt":case"eth_getTransactionCount":return(await this.getRpcProvider()).send(i.method,i.params||[]);default:throw new r.JsonRpcError(r.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`)}}async request(e){try{return this.#c(e)}catch(e){if(e instanceof r.JsonRpcError)throw e;if(e instanceof Error)throw new r.JsonRpcError(r.RpcErrorCode.INTERNAL_ERROR,e.message);throw new r.JsonRpcError(r.RpcErrorCode.INTERNAL_ERROR,"Internal error")}}on(e,t){this.#i.on(e,t)}removeListener(e,t){this.#i.off(e,t)}};
1
+ "use strict";var e=require("../../utils/debug.js"),t=require("../../core/configuration/authentication.js"),r=require("./types.js"),s=require("./JsonRpcError.js"),a=require("./signTypedDataV4.js"),i=require("../../types/types.js"),o=require("../../utils/typedEventEmitter.js"),n=require("../../utils/chains/index.js"),c=require("../../core/configuration/account.js"),h=require("./addEthereumChain.js"),d=require("./registerSession.js"),u=require("./revokeSession.js"),p=require("./sendCalls.js"),l=require("./getCallsStatus.js"),g=require("./personalSign.js"),w=require("./estimateGas.js"),m=require("../../utils/crypto.js");exports.EvmProvider=class{#e;#t;#r;#s;updatePolicy(e){this.#t=e}#a;#i;#o=null;#n;isOpenfort=!0;constructor({storage:e,signer:t,backendApiClients:r,openfortEventEmitter:s,policyId:a,chains:n,validateAndRefreshSession:c}){this.#e=e,this.#s=t,this.#r=n,this.#t=a,this.#a=c,this.#n=r,this.#n=r,this.#i=new o,s.on(i.OpenfortEvents.LOGGED_OUT,this.#c),s.on(i.OpenfortEvents.SIGNER_CONFIGURED,e=>{this.#s=e})}#h(){if(!this.#s)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"No signer configured. Please configure an embedded wallet first.");return this.#s}#c=async()=>{this.#s=void 0,this.#i.emit(r.ProviderEvent.ACCOUNTS_CHANGED,[])};async getRpcProvider(){if(!this.#o){const e=await c.Account.fromStorage(this.#e),t=e?.chainId||8453;await import("@ethersproject/providers").then(e=>{const r=this.#r?this.#r[t]:void 0;this.#o=new e.StaticJsonRpcProvider(r??n.defaultChainRpcs[t])})}if(!this.#o)throw new Error("RPC provider not initialized");return this.#o}async#d(i){switch(i.method){case"eth_accounts":{const e=await c.Account.fromStorage(this.#e);return e?[e.address]:[]}case"eth_requestAccounts":{const e=await c.Account.fromStorage(this.#e);if(e)return this.#i.emit(r.ProviderEvent.ACCOUNTS_CONNECT,{chainId:m.numberToHex(e.chainId)}),[e.address];throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - must be authenticated and configured with a signer.")}case"eth_sendTransaction":{const e=await c.Account.fromStorage(this.#e),r=await this.#h(),a=await t.Authentication.fromStorage(this.#e);if(!e||!a)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await p.sendCalls({params:i.params||[],signer:r,account:e,authentication:a,backendClient:this.#n,policyId:this.#t})}case"eth_estimateGas":{const e=await c.Account.fromStorage(this.#e),r=await t.Authentication.fromStorage(this.#e);if(!e||!r)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await w.estimateGas({params:i.params||[],account:e,authentication:r,backendClient:this.#n,policyId:this.#t})}case"eth_signTypedData":case"eth_signTypedData_v4":{const e=await c.Account.fromStorage(this.#e),t=await this.#h();if(!e)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#a();const r=await this.getRpcProvider();return await a.signTypedDataV4({method:i.method,params:i.params||[],signer:t,accountType:e.type,rpcProvider:r})}case"personal_sign":{e.debugLog("[personal_sign] request:",i);const t=await c.Account.fromStorage(this.#e);e.debugLog("[personal_sign] account:",t);const r=await this.#h();if(e.debugLog("[personal_sign] signer:",r),!t)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),e.debugLog("[personal_sign] validateAndRefreshSession:"),await g.personalSign({params:i.params||[],signer:r,account:t})}case"eth_chainId":{const e=await this.getRpcProvider(),{chainId:t}=await e.detectNetwork();return m.numberToHex(t)}case"wallet_switchEthereumChain":{const e=await this.#h();if(!i.params||!Array.isArray(i.params)||0===i.params.length)throw new s.JsonRpcError(s.RpcErrorCode.INVALID_PARAMS,"Invalid parameters for wallet_switchEthereumChain");await this.#a();try{const t=parseInt(i.params[0].chainId,16);await e.switchChain({chainId:t}),await import("@ethersproject/providers").then(e=>{const r=this.#r?this.#r[t]:void 0;this.#o=new e.StaticJsonRpcProvider(r??n.defaultChainRpcs[t])})}catch(e){const t=e;throw new s.JsonRpcError(s.RpcErrorCode.INTERNAL_ERROR,`Failed to switch chain: ${t.message}`)}return null}case"wallet_addEthereumChain":{await this.#h();const e=await this.getRpcProvider();return await h.addEthereumChain({params:i.params||[],rpcProvider:e,storage:this.#e})}case"wallet_showCallsStatus":return null;case"wallet_getCallsStatus":{const e=await c.Account.fromStorage(this.#e);await this.#h();const r=await t.Authentication.fromStorage(this.#e);if(!e||!r)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await l.getCallStatus({params:i.params||{},authentication:r,backendClient:this.#n,account:e})}case"wallet_sendCalls":{const e=await c.Account.fromStorage(this.#e),r=await this.#h(),a=await t.Authentication.fromStorage(this.#e);if(!e||!a)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await p.sendCalls({params:i.params?i.params[0].calls:[],signer:r,account:e,authentication:a,backendClient:this.#n,policyId:this.#t})}case"wallet_grantPermissions":{const e=await c.Account.fromStorage(this.#e),r=await this.#h(),a=await t.Authentication.fromStorage(this.#e);if(!e||!a)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await d.registerSession({params:i.params||[],signer:r,account:e,authentication:a,backendClient:this.#n,policyId:this.#t})}case"wallet_revokePermissions":{const e=await c.Account.fromStorage(this.#e),r=await this.#h(),a=await t.Authentication.fromStorage(this.#e);if(!e||!a)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#a(),await u.revokeSession({params:i.params||[],signer:r,account:e,authentication:a,backendClient:this.#n})}case"wallet_getCapabilities":{const e=await this.getRpcProvider(),{chainId:t}=await e.detectNetwork();return{[m.numberToHex(t)]:{permissions:{supported:!0,signerTypes:["account","key"],keyTypes:["secp256k1"],permissionTypes:["contract-calls"]},paymasterService:{supported:!0},atomicBatch:{supported:!0}}}}case"eth_gasPrice":case"eth_getBalance":case"eth_getCode":case"eth_getStorageAt":case"eth_call":case"eth_blockNumber":case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getTransactionByHash":case"eth_getTransactionReceipt":case"eth_getTransactionCount":return(await this.getRpcProvider()).send(i.method,i.params||[]);default:throw new s.JsonRpcError(s.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`)}}async request(e){try{return this.#d(e)}catch(e){if(e instanceof s.JsonRpcError)throw e;if(e instanceof Error)throw new s.JsonRpcError(s.RpcErrorCode.INTERNAL_ERROR,e.message);throw new s.JsonRpcError(s.RpcErrorCode.INTERNAL_ERROR,"Internal error")}}on(e,t){this.#i.on(e,t)}removeListener(e,t){this.#i.off(e,t)}};
@@ -1 +1 @@
1
- "use strict";var e=require("../../core/errors/openfortError.js"),r=require("./JsonRpcError.js");exports.revokeSession=async({params:a,signer:n,account:t,authentication:o,backendClient:s,policyId:i})=>{const c=a[0];if(!c.permissionContext)return await n.logout(),{};const p=await(async(r,a,n,t,o)=>{const s=((e,r,a,n)=>{const t={address:e,chainId:r,player:a};return n&&(t.policy=n),t})(r.permissionContext,n.chainId,t.player,o);return e.withOpenfortError(async()=>(await a.sessionsApi.revokeSession({revokeSessionRequest:s},{headers:{authorization:`Bearer ${a.config.backend.accessToken}`,"x-player-token":t.token,"x-auth-provider":t.thirdPartyProvider,"x-token-type":t.thirdPartyTokenType}})).data,{default:e.OpenfortErrorType.AUTHENTICATION_ERROR})})(c,s,t,o,i).catch(e=>{throw new r.JsonRpcError(r.RpcErrorCode.TRANSACTION_REJECTED,e.message)});if(p?.nextAction?.payload?.signableHash){let e;e=[300,531050104,324,50104,2741,11124].includes(t.chainId)?await n.sign(p.nextAction.payload.signableHash,!1,!1):await n.sign(p.nextAction.payload.signableHash);return(await s.sessionsApi.signatureSession({id:p.id,signatureRequest:{signature:e}}).catch(e=>{throw new r.JsonRpcError(r.RpcErrorCode.TRANSACTION_REJECTED,e.message)})).data}return p};
1
+ "use strict";var e=require("../../core/errors/openfortError.js"),r=require("./JsonRpcError.js");exports.revokeSession=async({params:n,signer:a,account:s,authentication:t,backendClient:o,policyId:i})=>{const c=n[0];if(!c.permissionContext)return await a.disconnect(),{};const p=await(async(r,n,a,s,t)=>{const o=((e,r,n,a)=>{const s={address:e,chainId:r,player:n};return a&&(s.policy=a),s})(r.permissionContext,a.chainId,s.player,t);return e.withOpenfortError(async()=>(await n.sessionsApi.revokeSession({revokeSessionRequest:o},{headers:{authorization:`Bearer ${n.config.backend.accessToken}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}})).data,{default:e.OpenfortErrorType.AUTHENTICATION_ERROR})})(c,o,s,t,i).catch(e=>{throw new r.JsonRpcError(r.RpcErrorCode.TRANSACTION_REJECTED,e.message)});if(p?.nextAction?.payload?.signableHash){let e;e=[300,531050104,324,50104,2741,11124].includes(s.chainId)?await a.sign(p.nextAction.payload.signableHash,!1,!1):await a.sign(p.nextAction.payload.signableHash);return(await o.sessionsApi.signatureSession({id:p.id,signatureRequest:{signature:e}}).catch(e=>{throw new r.JsonRpcError(r.RpcErrorCode.TRANSACTION_REJECTED,e.message)})).data}return p};
@@ -1 +1 @@
1
- "use strict";var e=require("../../../node_modules/penpal/dist/penpal.js"),r=require("../utils/crypto.js"),o=require("../core/errors/openfortError.js"),t=require("./types.js");class n extends Error{constructor(){super("This embedded signer requires a password to be recovered")}}class i extends Error{constructor(){super("MissingProjectEntropyError")}}class s extends Error{constructor(){super("Wrong recovery password for this embedded signer")}}class a extends Error{message;constructor(e){super(`Unknown response from iframe: ${e}`),this.message=e||""}}class d extends Error{constructor(){super("Not configured")}}class c{iframe;connection;remote;storage;sdkConfiguration;isInitialized=!1;constructor(e,r){if(!e)throw new o.OpenfortError("Configuration is required for IframeManager",o.OpenfortErrorType.INVALID_CONFIGURATION);if(!r)throw new o.OpenfortError("Storage is required for IframeManager",o.OpenfortErrorType.INVALID_CONFIGURATION);this.sdkConfiguration=e,this.storage=r}async iframeSetup(){if("undefined"==typeof document)throw new o.OpenfortError("Document is not available. Please provide a message poster for non-browser environments.",o.OpenfortErrorType.INVALID_CONFIGURATION);const e=document.getElementById("openfort-iframe");e&&document.body.removeChild(e);const r=document.createElement("iframe");r.style.display="none",r.id="openfort-iframe",document.body.appendChild(r),r.src=this.sdkConfiguration.iframeUrl,this.iframe=r,await new Promise((e,o)=>{const t=setTimeout(()=>{o(new Error("Iframe load timeout"))},1e4);r.onload=()=>{clearTimeout(t),e()},r.onerror=()=>{clearTimeout(t),o(new Error("Failed to load iframe"))}})}async establishIframeConnection(){if("undefined"==typeof document)throw new o.OpenfortError("Document is not available.",o.OpenfortErrorType.INVALID_CONFIGURATION);if(!this.iframe?.contentWindow)throw new o.OpenfortError("Iframe does not have content window",o.OpenfortErrorType.INVALID_CONFIGURATION);const r=new URL(this.sdkConfiguration.iframeUrl).origin,t=new e.WindowMessenger({remoteWindow:this.iframe.contentWindow,allowedOrigins:[r]});this.connection=e.connect({messenger:t,timeout:5e3});try{this.remote=await this.connection.promise,this.isInitialized=!0}catch(e){const r=e;throw new Error(`v3 Failed to establish Iframe connection: ${r.cause||r.message}`,r)}}isLoaded(){return this.isInitialized&&void 0!==this.remote}async ensureConnection(){if(!this.isLoaded()){if("undefined"==typeof document)throw new o.OpenfortError("Document is not available.",o.OpenfortErrorType.INVALID_CONFIGURATION);await this.iframeSetup(),await this.establishIframeConnection()}if(!this.remote)throw new Error("Failed to establish connection with iframe");return this.remote}static handleError(e){if(t.isErrorResponse(e)){if(e.error===t.NOT_CONFIGURED_ERROR)throw new d;if(e.error===t.MISSING_USER_ENTROPY_ERROR)throw new n;if(e.error===t.MISSING_PROJECT_ENTROPY_ERROR)throw new i;if(e.error===t.INCORRECT_USER_ENTROPY_ERROR)throw new s;throw new a(e.error)}throw e}async configure(e){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const o=await this.ensureConnection(),n={uuid:r.randomUUID(),action:t.Event.CONFIGURE,chainId:e.chainId,recovery:e.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:e.accessToken,playerID:e.playerID,thirdPartyProvider:e.thirdPartyProvider,thirdPartyTokenType:e.thirdPartyTokenType,encryptionKey:e.password,encryptionPart:this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionKey??null,encryptionSession:e.recovery?.encryptionSession??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl},i=await o.configure(n);return t.isErrorResponse(i)&&c.handleError(i),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",i.version??"undefined"),i}async sign(e,o,n,i){const s=await this.ensureConnection(),a={thirdPartyProvider:e.thirdPartyProvider??void 0,thirdPartyTokenType:e.thirdPartyTokenType??void 0,token:e.accessToken??void 0,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl},h=new t.SignRequest(r.randomUUID(),o,n,i,a);try{const e=await s.sign(h);return t.isErrorResponse(e)&&c.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e.signature}catch(r){if(r instanceof d)return await this.configure(e),this.sign(e,o,n,i);throw r}}async switchChain(e,o){const n=await this.ensureConnection(),i={thirdPartyProvider:e.thirdPartyProvider??void 0,thirdPartyTokenType:e.thirdPartyTokenType??void 0,token:e.accessToken??void 0,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl},s=new t.SwitchChainRequest(r.randomUUID(),o,i);try{const e=await n.switchChain(s);return t.isErrorResponse(e)&&c.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e}catch(r){if(r instanceof d)return await this.configure(e),this.switchChain(e,o);throw r}}async export(e){const o=await this.ensureConnection(),n={thirdPartyProvider:e.thirdPartyProvider??void 0,thirdPartyTokenType:e.thirdPartyTokenType??void 0,token:e.accessToken??void 0,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl},i=new t.ExportPrivateKeyRequest(r.randomUUID(),n);try{const e=await o.export(i);return t.isErrorResponse(e)&&c.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e.key}catch(r){if(r instanceof d)return await this.configure(e),this.export(e);throw r}}async setEmbeddedRecovery(e,o,n,i){const s=await this.ensureConnection(),a={thirdPartyProvider:e.thirdPartyProvider??void 0,thirdPartyTokenType:e.thirdPartyTokenType??void 0,token:e.accessToken??void 0,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl},h=new t.SetRecoveryMethodRequest(r.randomUUID(),o,n,i,a);try{const e=await s.setRecoveryMethod(h);t.isErrorResponse(e)&&c.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined")}catch(r){if(r instanceof d)return await this.configure(e),this.setEmbeddedRecovery(e,o,n,i);throw r}}async getCurrentUser(e){const o=await this.ensureConnection(),n=new t.GetCurrentDeviceRequest(r.randomUUID(),e);try{const e=await o.getCurrentDevice(n);return t.isErrorResponse(e)&&c.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e}catch(e){if(e instanceof d)return null;throw e}}async logout(){const e=await this.ensureConnection(),o={uuid:r.randomUUID()};await e.logout(o)}async updateAuthentication(e,o,n){const i={...e};i.accessToken=o,n===t.ShieldAuthType.OPENFORT&&i.recovery&&(i.recovery={...i.recovery,token:o});const s=await this.ensureConnection(),a=new t.UpdateAuthenticationRequest(r.randomUUID(),o);try{await s.updateAuthentication(a)}catch(e){if(e instanceof d)return await this.configure(i),void await this.updateAuthentication(i,o,n);throw e}}destroy(){if(this.connection&&(this.connection.destroy(),this.connection=void 0),this.remote=void 0,this.isInitialized=!1,this.iframe&&"undefined"!=typeof document){const e=document.getElementById("openfort-iframe");e&&e.parentNode&&e.parentNode.removeChild(e),this.iframe=void 0}}}exports.IframeManager=c,exports.MissingProjectEntropyError=i,exports.MissingRecoveryPasswordError=n,exports.NotConfiguredError=d,exports.UnknownResponseError=a,exports.WrongRecoveryPasswordError=s;
1
+ "use strict";var e=require("../core/configuration/account.js"),r=require("./messaging/browserMessenger/connect.js");require("./messaging/browserMessenger/backwardCompatibility.js");var t=require("../storage/istorage.js"),i=require("../core/errors/openfortError.js"),n=require("../utils/debug.js"),o=require("../utils/crypto.js"),s=require("../core/configuration/authentication.js"),a=require("./messaging/ReactNativeMessenger.js"),c=require("./types.js"),u=require("../core/errors/sentry.js");class d extends Error{constructor(){super("This embedded signer requires a password to be recovered")}}class h extends Error{constructor(){super("MissingProjectEntropyError")}}class g extends Error{constructor(){super("Wrong recovery password for this embedded signer")}}class f extends Error{constructor(){super("Not configured")}}exports.IframeManager=class{messenger;connection;remote;storage;sdkConfiguration;isInitialized=!1;configurationRequest;constructor(e,r,t){if(!e)throw new i.OpenfortError("Configuration is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);if(!r)throw new i.OpenfortError("Storage is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);if(!t)throw new i.OpenfortError("Messenger is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);this.sdkConfiguration=e,this.storage=r,this.messenger=t}async initialize(){if(!this.isInitialized){n.debugLog("Initializing IframeManager connection..."),this.messenger.initialize({validateReceivedMessage:e=>!(!e||"object"!=typeof e),log:n.debugLog}),this.connection=r({messenger:this.messenger,timeout:1e4,log:n.debugLog});try{this.remote=await this.connection.promise,this.isInitialized=!0,n.debugLog("IframeManager connection established")}catch(e){const r=e;throw u.sentry.captureException(r),this.destroy(),n.debugLog("Failed to establish connection:",r),new i.OpenfortError(`Failed to establish iFrame connection: ${r.cause||r.message}`,i.OpenfortErrorType.INTERNAL_ERROR,e)}}}async ensureConnection(){if(this.isInitialized&&this.remote||await this.initialize(),!this.remote)throw new i.OpenfortError("Failed to establish connection",i.OpenfortErrorType.INTERNAL_ERROR);return this.remote}handleError(e){if(c.isErrorResponse(e)){if(e.error===c.NOT_CONFIGURED_ERROR)throw new f;if(e.error===c.MISSING_USER_ENTROPY_ERROR)throw this.storage.remove(t.StorageKeys.ACCOUNT),new d;if(e.error===c.MISSING_PROJECT_ENTROPY_ERROR)throw this.storage.remove(t.StorageKeys.ACCOUNT),new h;if(e.error===c.INCORRECT_USER_ENTROPY_ERROR)throw new g;throw new i.OpenfortError(`Unknown error: ${e.error}`,i.OpenfortErrorType.INTERNAL_ERROR)}throw e}async buildRequestConfiguration(){const e=await s.Authentication.fromStorage(this.storage);if(!e)throw new i.OpenfortError("Must be authenticated to create a signer",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{thirdPartyProvider:e.thirdPartyProvider,thirdPartyTokenType:e.thirdPartyTokenType,token:e.token,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl}}async buildIFrameRequestConfiguration(){const e=await s.Authentication.fromStorage(this.storage);if(!e)throw new i.OpenfortError("Must be authenticated to create a signer",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const r={auth:c.ShieldAuthType.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyTokenType:e.thirdPartyTokenType??null,thirdPartyProvider:e.thirdPartyProvider??null,accessToken:e.token,playerID:e.player,recovery:r,chainId:null,password:null}}async configure(r){if(!this.sdkConfiguration.shieldConfiguration)throw new i.OpenfortError("shieldConfiguration is required",i.OpenfortErrorType.INVALID_CONFIGURATION);const t=await e.Account.fromStorage(this.storage),n=await this.ensureConnection(),s=await this.buildIFrameRequestConfiguration();s.chainId=r?.chainId??t?.chainId??null,s.password=r?.entropy?.recoveryPassword??null,s.recovery={...s.recovery,encryptionSession:r?.entropy?.encryptionSession};const a={uuid:o.randomUUID(),action:c.Event.CONFIGURE,chainId:s.chainId,recovery:s.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:s.accessToken,playerID:s.playerID,thirdPartyProvider:s.thirdPartyProvider,thirdPartyTokenType:s.thirdPartyTokenType,encryptionKey:s.password,encryptionPart:this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionKey??null,encryptionSession:s.recovery?.encryptionSession??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl},u=await n.configure(a);return c.isErrorResponse(u)&&this.handleError(u),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",u.version??"undefined"),u}async sign(e,r,t){n.debugLog("[iframe] ensureConnection");const i=await this.ensureConnection(),s=new c.SignRequest(o.randomUUID(),e,r,t,await this.buildRequestConfiguration());n.debugLog("[iframe] done ensureConnection");try{const e=await i.sign(s);return n.debugLog("[iframe] response",e),c.isErrorResponse(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e.signature}catch(i){if(i instanceof f)return await this.configure(this.configurationRequest),this.sign(e,r,t);throw i}}async switchChain(e){const r=await this.ensureConnection(),t=new c.SwitchChainRequest(o.randomUUID(),e,await this.buildRequestConfiguration());try{const i=await r.switchChain(t);return c.isErrorResponse(i)&&this.handleError(i),this.configurationRequest&&(this.configurationRequest.chainId=e),i}catch(r){if(r instanceof f)return await this.configure(this.configurationRequest),this.switchChain(e);throw r}}async export(){const e=await this.ensureConnection(),r=new c.ExportPrivateKeyRequest(o.randomUUID(),await this.buildRequestConfiguration());try{const t=await e.export(r);return c.isErrorResponse(t)&&this.handleError(t),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",t.version??"undefined"),t.key}catch(e){if(e instanceof f)return await this.configure(this.configurationRequest),this.export();throw e}}async setEmbeddedRecovery(e,r,t){const i=await this.ensureConnection(),n=new c.SetRecoveryMethodRequest(o.randomUUID(),e,r,t,await this.buildRequestConfiguration());try{const e=await i.setRecoveryMethod(n);c.isErrorResponse(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined")}catch(i){if(i instanceof f)return await this.configure(this.configurationRequest),this.setEmbeddedRecovery(e,r,t);throw i}}async getCurrentDevice(e){const r=await this.ensureConnection(),t=new c.GetCurrentDeviceRequest(o.randomUUID(),e);try{const e=await r.getCurrentDevice(t);return c.isErrorResponse(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e}catch(e){if(e instanceof f)return null;throw e}}async updateAuthentication(){if(!this.isLoaded()||!this.remote)return void n.debugLog("IframeManager not loaded, skipping authentication update");const e=await s.Authentication.fromStorage(this.storage);if(!e)return void n.debugLog("No authentication found, skipping update");const r=new c.UpdateAuthenticationRequest(o.randomUUID(),e.token);try{n.debugLog("Updating authentication in iframe with token:",e.token);const t=await this.remote.updateAuthentication(r);c.isErrorResponse(t)&&this.handleError(t)}catch(e){if(e instanceof f)return await this.configure(this.configurationRequest),void await this.updateAuthentication();throw e}}async disconnect(){const e=await this.ensureConnection(),r={uuid:o.randomUUID()};await e.logout(r),this.configurationRequest=void 0}async onMessage(e){n.debugLog("[HANDSHAKE DEBUG] IframeManager.onMessage called with:",e),this.messenger instanceof a.ReactNativeMessenger?(this.isInitialized||this.connection?n.debugLog(`[HANDSHAKE DEBUG] Connection already initialized (isInitialized: ${this.isInitialized}, hasConnection: ${!!this.connection})`):(n.debugLog("[HANDSHAKE DEBUG] First message received, initializing connection..."),this.initialize().catch(e=>{n.debugLog("[HANDSHAKE DEBUG] Failed to initialize connection:",e)})),n.debugLog("[HANDSHAKE DEBUG] Passing message to ReactNativeMessenger"),this.messenger.handleMessage(e)):n.debugLog("[HANDSHAKE DEBUG] Not a ReactNativeMessenger, ignoring message")}isLoaded(){return this.isInitialized&&void 0!==this.remote}destroy(){this.connection&&(this.connection.destroy(),this.connection=void 0),this.remote=void 0,this.isInitialized=!1,this.configurationRequest=void 0,this.messenger.destroy()}},exports.MissingProjectEntropyError=h,exports.MissingRecoveryPasswordError=d,exports.NotConfiguredError=f,exports.WrongRecoveryPasswordError=g;