@openfort/openfort-js 0.10.34 → 0.10.36

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 (30) hide show
  1. package/dist/cjs/packages/internal/openapi-clients/dist/index.js +1 -1
  2. package/dist/cjs/sdk/src/api/embeddedWallet.js +1 -1
  3. package/dist/cjs/sdk/src/core/configuration/account.js +1 -1
  4. package/dist/cjs/sdk/src/core/openfortInternal.js +1 -1
  5. package/dist/cjs/sdk/src/index.js +1 -1
  6. package/dist/cjs/sdk/src/types/types.js +1 -1
  7. package/dist/cjs/sdk/src/utils/authorization.js +1 -0
  8. package/dist/cjs/sdk/src/version.js +1 -1
  9. package/dist/cjs/sdk/src/wallets/embedded.js +1 -1
  10. package/dist/cjs/sdk/src/wallets/evm/evmProvider.js +1 -1
  11. package/dist/cjs/sdk/src/wallets/evm/registerSession.js +1 -1
  12. package/dist/cjs/sdk/src/wallets/evm/revokeSession.js +1 -1
  13. package/dist/cjs/sdk/src/wallets/evm/sendCallSync.js +1 -1
  14. package/dist/cjs/sdk/src/wallets/evm/sendCalls.js +1 -1
  15. package/dist/index.d.ts +183 -2
  16. package/dist/packages/internal/openapi-clients/dist/index.js +1 -1
  17. package/dist/sdk/src/api/embeddedWallet.js +1 -1
  18. package/dist/sdk/src/core/configuration/account.js +1 -1
  19. package/dist/sdk/src/core/openfortInternal.js +1 -1
  20. package/dist/sdk/src/index.js +1 -1
  21. package/dist/sdk/src/types/types.js +1 -1
  22. package/dist/sdk/src/utils/authorization.js +1 -0
  23. package/dist/sdk/src/version.js +1 -1
  24. package/dist/sdk/src/wallets/embedded.js +1 -1
  25. package/dist/sdk/src/wallets/evm/evmProvider.js +1 -1
  26. package/dist/sdk/src/wallets/evm/registerSession.js +1 -1
  27. package/dist/sdk/src/wallets/evm/revokeSession.js +1 -1
  28. package/dist/sdk/src/wallets/evm/sendCallSync.js +1 -1
  29. package/dist/sdk/src/wallets/evm/sendCalls.js +1 -1
  30. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";var e=require("axios"),t=require("axios-retry");const s="https://api.openfort.io".replace(/\/+$/,"");class n{basePath;axios;configuration;constructor(t,n=s,a=e){this.basePath=n,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,s){if(null==s)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const s="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+s}};function c(e,t,s=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,s)):Object.keys(t).forEach(n=>c(e,t[n],`${s}${""!==s?".":""}${n}`)):e.has(s)?e.append(s,t):e.set(s,t))}const h=function(e,...t){const s=new URLSearchParams(e.search);c(s,t),e.search=s.toString()},u=function(e,t,s){const n="string"!=typeof e;return(n&&s&&s.isJsonMime?s.isJsonMime(t.headers["Content-Type"]):n)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,s,n){return(a=t,i=s)=>{const o={...e.options,url:(n?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const n=function(e){return{cancelTransferOwnership:async(t,s,n={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",s);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},completeRecovery:async(t,s,n={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",s);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},createAccount:async(t,s={})=>{o("createAccount","createAccountRequest",t);const n=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},createAccountV2:async(t,s={})=>{o("createAccountV2","createAccountRequestV2",t);const n=new URL("/v2/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},deployAccount:async(t,s,n={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",s);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},disableAccount:async(t,s={})=>{o("disableAccount","id",t);const n="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccount:async(t,s,n={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getAccountV2:async(t,s={})=>{o("getAccountV2","id",t);const n="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccounts:async(t,s,n,a,o,c,u,l={})=>{const p=new URL("/v1/accounts",i);let y;e&&(y=e.baseOptions);const g={method:"GET",...y,...l},w={},m={};await r(w,e),void 0!==t&&(m.limit=t),void 0!==s&&(m.skip=s),void 0!==n&&(m.order=n),void 0!==a&&(m.chainId=a),void 0!==o&&(m.player=o),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let R=y&&y.headers?y.headers:{};return g.headers={...w,...R,...l.headers},{url:d(p),options:g}},getAccountsV2:async(t,s,n,a,o,c,u,l,p={})=>{const y=new URL("/v2/accounts",i);let g;e&&(g=e.baseOptions);const w={method:"GET",...g,...p},m={},R={};await r(m,e),void 0!==t&&(R.limit=t),void 0!==s&&(R.skip=s),void 0!==n&&(R.order=n),void 0!==a&&(R.chainId=a),void 0!==o&&(R.user=o),void 0!==c&&(R.chainType=c),void 0!==u&&(R.accountType=u),void 0!==l&&(R.address=l),h(y,R);let P=g&&g.headers?g.headers:{};return w.headers={...m,...P,...p.headers},{url:d(y),options:w}},getSignerIdByAddress:async(t,s={})=>{o("getSignerIdByAddress","address",t);const n=new URL("/v2/accounts/signer",i);let a;e&&(a=e.baseOptions);const c={method:"GET",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.address=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},requestTransferOwnership:async(t,s,n={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",s);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},signPayload:async(t,s,n={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",s);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},startRecovery:async(t,s,n={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",s);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},switchChainV2:async(t,s={})=>{o("switchChainV2","switchChainQueriesV2",t);const n=new URL("/v2/accounts/switch-chain",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},syncAccount:async(t,s={})=>{o("syncAccount","id",t);const n="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await n.cancelTransferOwnership(a,i,o);return l(r,e,s,t)},async completeRecovery(a,i,o){const r=await n.completeRecovery(a,i,o);return l(r,e,s,t)},async createAccount(a,i){const o=await n.createAccount(a,i);return l(o,e,s,t)},async createAccountV2(a,i){const o=await n.createAccountV2(a,i);return l(o,e,s,t)},async deployAccount(a,i,o){const r=await n.deployAccount(a,i,o);return l(r,e,s,t)},async disableAccount(a,i){const o=await n.disableAccount(a,i);return l(o,e,s,t)},async getAccount(a,i,o){const r=await n.getAccount(a,i,o);return l(r,e,s,t)},async getAccountV2(a,i){const o=await n.getAccountV2(a,i);return l(o,e,s,t)},async getAccounts(a,i,o,r,c,h,u,d){const p=await n.getAccounts(a,i,o,r,c,h,u,d);return l(p,e,s,t)},async getAccountsV2(a,i,o,r,c,h,u,d,p){const y=await n.getAccountsV2(a,i,o,r,c,h,u,d,p);return l(y,e,s,t)},async getSignerIdByAddress(a,i){const o=await n.getSignerIdByAddress(a,i);return l(o,e,s,t)},async requestTransferOwnership(a,i,o){const r=await n.requestTransferOwnership(a,i,o);return l(r,e,s,t)},async signPayload(a,i,o){const r=await n.signPayload(a,i,o);return l(r,e,s,t)},async startRecovery(a,i,o){const r=await n.startRecovery(a,i,o);return l(r,e,s,t)},async switchChainV2(a,i){const o=await n.switchChainV2(a,i);return l(o,e,s,t)},async syncAccount(a,i){const o=await n.syncAccount(a,i);return l(o,e,s,t)}}};class y extends n{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}createAccountV2(e,t){return p(this.configuration).createAccountV2(e.createAccountRequestV2,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.id,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.chainId,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountsV2(e={},t){return p(this.configuration).getAccountsV2(e.limit,e.skip,e.order,e.chainId,e.user,e.chainType,e.accountType,e.address,t).then(e=>e(this.axios,this.basePath))}getSignerIdByAddress(e,t){return p(this.configuration).getSignerIdByAddress(e.address,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}switchChainV2(e,t){return p(this.configuration).switchChainV2(e.switchChainQueriesV2,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const n=function(e){return{authenticateSIWE:async(t,s={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getJwks:async(t,s={})=>{o("getJwks","publishableKey",t);const n="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(n,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...s};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...s.headers},{url:d(a),options:c}},initOAuth:async(t,s,n={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,s,n={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,s,n={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,s,n={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,s={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},linkThirdParty:async(t,s,n={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,s,n={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,s,n={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,s={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const n=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},logout:async(t,s={})=>{o("logout","logoutRequest",t);const n=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},me:async(t={})=>{const s=new URL("/iam/v1/me",i);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let o=n&&n.headers?n.headers:{};return a.headers={...o,...t.headers},{url:d(s),options:a}},poolOAuth:async(t,s={})=>{o("poolOAuth","key",t);const n=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},refresh:async(t,s={})=>{o("refresh","refreshTokenRequest",t);const n=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},registerGuest:async(t,s={})=>{const n=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...s},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(n,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...s.headers},{url:d(n),options:o}},requestEmailVerification:async(t,s={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const n=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},requestResetPassword:async(t,s={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const n=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},resetPassword:async(t,s={})=>{o("resetPassword","resetPasswordRequest",t);const n=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},signupEmailPassword:async(t,s,n={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,s,n={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,s={})=>{o("unlinkEmail","unlinkEmailRequest",t);const n=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkOAuth:async(t,s={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const n=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkSIWE:async(t,s={})=>{o("unlinkSIWE","sIWERequest",t);const n=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},verifyEmail:async(t,s={})=>{o("verifyEmail","verifyEmailRequest",t);const n=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},verifyOAuthToken:async(t,s={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const n=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await n.authenticateSIWE(a,i);return l(o,e,s,t)},async getJwks(a,i){const o=await n.getJwks(a,i);return l(o,e,s,t)},async initOAuth(a,i,o){const r=await n.initOAuth(a,i,o);return l(r,e,s,t)},async initSIWE(a,i,o){const r=await n.initSIWE(a,i,o);return l(r,e,s,t)},async linkEmail(a,i,o){const r=await n.linkEmail(a,i,o);return l(r,e,s,t)},async linkOAuth(a,i,o){const r=await n.linkOAuth(a,i,o);return l(r,e,s,t)},async linkSIWE(a,i){const o=await n.linkSIWE(a,i);return l(o,e,s,t)},async linkThirdParty(a,i,o){const r=await n.linkThirdParty(a,i,o);return l(r,e,s,t)},async loginEmailPassword(a,i,o){const r=await n.loginEmailPassword(a,i,o);return l(r,e,s,t)},async loginOIDC(a,i,o){const r=await n.loginOIDC(a,i,o);return l(r,e,s,t)},async loginWithIdToken(a,i){const o=await n.loginWithIdToken(a,i);return l(o,e,s,t)},async logout(a,i){const o=await n.logout(a,i);return l(o,e,s,t)},async me(a){const i=await n.me(a);return l(i,e,s,t)},async poolOAuth(a,i){const o=await n.poolOAuth(a,i);return l(o,e,s,t)},async refresh(a,i){const o=await n.refresh(a,i);return l(o,e,s,t)},async registerGuest(a,i){const o=await n.registerGuest(a,i);return l(o,e,s,t)},async requestEmailVerification(a,i){const o=await n.requestEmailVerification(a,i);return l(o,e,s,t)},async requestResetPassword(a,i){const o=await n.requestResetPassword(a,i);return l(o,e,s,t)},async resetPassword(a,i){const o=await n.resetPassword(a,i);return l(o,e,s,t)},async signupEmailPassword(a,i,o){const r=await n.signupEmailPassword(a,i,o);return l(r,e,s,t)},async thirdParty(a,i,o){const r=await n.thirdParty(a,i,o);return l(r,e,s,t)},async unlinkEmail(a,i){const o=await n.unlinkEmail(a,i);return l(o,e,s,t)},async unlinkOAuth(a,i){const o=await n.unlinkOAuth(a,i);return l(o,e,s,t)},async unlinkSIWE(a,i){const o=await n.unlinkSIWE(a,i);return l(o,e,s,t)},async verifyEmail(a,i){const o=await n.verifyEmail(a,i);return l(o,e,s,t)},async verifyOAuthToken(a,i){const o=await n.verifyOAuthToken(a,i);return l(o,e,s,t)}}};class w extends n{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const n=function(e){return{handleRpcRequest:async(t,s={})=>{o("handleRpcRequest","jsonRpcRequest",t);const n=new URL("/rpc",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}}}}(t);return{async handleRpcRequest(a,i){const o=await n.handleRpcRequest(a,i);return l(o,e,s,t)}}};class R extends n{handleRpcRequest(e,t){return m(this.configuration).handleRpcRequest(e.jsonRpcRequest,t).then(e=>e(this.axios,this.basePath))}}const P=function(t){const n=function(e){return{createSession:async(t,s,n={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,s,n,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==s&&(w.limit=s),void 0!==n&&(w.skip=n),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,s,n={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},revokeSession:async(t,s,n={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,s,n={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",s);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await n.createSession(a,i,o);return l(r,e,s,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await n.getPlayerSessions(a,i,o,r,c,h);return l(u,e,s,t)},async getSession(a,i,o){const r=await n.getSession(a,i,o);return l(r,e,s,t)},async revokeSession(a,i,o){const r=await n.revokeSession(a,i,o);return l(r,e,s,t)},async signatureSession(a,i,o){const r=await n.signatureSession(a,i,o);return l(r,e,s,t)}}};class f extends n{createSession(e,t){return P(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return P(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 P(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return P(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return P(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const T=function(t){const n=function(e){return{createTransactionIntent:async(t,s,n={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,s={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const n=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getTransactionIntent:async(t,s,n={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getTransactionIntents:async(t,s,n,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},R={},P={};await r(R,e),void 0!==t&&(P.limit=t),void 0!==s&&(P.skip=s),void 0!==n&&(P.order=n),a&&(P.expand=a),void 0!==o&&(P.chainId=o),c&&(P.account=c),u&&(P.player=u),void 0!==l&&(P.status=l),p&&(P.policy=p),h(g,P);let f=w&&w.headers?w.headers:{};return m.headers={...R,...f,...y.headers},{url:d(g),options:m}},signature:async(t,s,n={})=>{o("signature","id",t),o("signature","signatureRequest",s);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await n.createTransactionIntent(a,i,o);return l(r,e,s,t)},async estimateTransactionIntentCost(a,i){const o=await n.estimateTransactionIntentCost(a,i);return l(o,e,s,t)},async getTransactionIntent(a,i,o){const r=await n.getTransactionIntent(a,i,o);return l(r,e,s,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await n.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,s,t)},async signature(a,i,o){const r=await n.signature(a,i,o);return l(r,e,s,t)}}};class O extends n{createTransactionIntent(e,t){return T(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return T(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return T(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return T(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return T(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class b{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const v=({basePath:e,accessToken:t,nativeAppIdentifier:s})=>{if(!e.trim())throw Error("basePath can not be empty");const n={basePath:e,accessToken:t};return s&&(n.baseOptions={headers:{"x-native-app-identifier":s}}),new b(n)};exports.BackendApiClients=class{config;transactionIntentsApi;accountsApi;rpcApi;sessionsApi;authenticationApi;storage;onLogout;axiosInstance;constructor(s){this.storage=s.storage,this.onLogout=s.onLogout,this.axiosInstance=e.create(),t(this.axiosInstance,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError}),this.setupInterceptors();const n={basePath:s.basePath,accessToken:s.accessToken,nativeAppIdentifier:s.nativeAppIdentifier};this.config={backend:v(n)},this.transactionIntentsApi=new O(this.config.backend,void 0,this.axiosInstance),this.accountsApi=new y(this.config.backend,void 0,this.axiosInstance),this.sessionsApi=new f(this.config.backend,void 0,this.axiosInstance),this.rpcApi=new R(this.config.backend,void 0,this.axiosInstance),this.authenticationApi=new w(this.config.backend,void 0,this.axiosInstance)}setupInterceptors(){this.axiosInstance.interceptors.response.use(e=>e,async e=>(401===e.response?.status&&(await this.clearAuthenticationState(),this.emitLogoutEvent()),Promise.reject(e)))}async clearAuthenticationState(){if(this.storage)try{this.storage.remove("openfort.authentication"),this.storage.remove("openfort.account"),this.storage.remove("openfort.session"),this.storage.remove("openfort.pkce_state"),this.storage.remove("openfort.pkce_verifier")}catch(e){}}emitLogoutEvent(){if(this.onLogout)try{this.onLogout()}catch(e){}}},exports.createConfig=v;
1
+ "use strict";var e=require("axios"),t=require("axios-retry");const s="https://api.openfort.io".replace(/\/+$/,"");class n{basePath;axios;configuration;constructor(t,n=s,a=e){this.basePath=n,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,s){if(null==s)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const s="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+s}};function c(e,t,s=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,s)):Object.keys(t).forEach(n=>c(e,t[n],`${s}${""!==s?".":""}${n}`)):e.has(s)?e.append(s,t):e.set(s,t))}const h=function(e,...t){const s=new URLSearchParams(e.search);c(s,t),e.search=s.toString()},u=function(e,t,s){const n="string"!=typeof e;return(n&&s&&s.isJsonMime?s.isJsonMime(t.headers["Content-Type"]):n)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,s,n){return(a=t,i=s)=>{const o={...e.options,url:(n?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const n=function(e){return{cancelTransferOwnership:async(t,s,n={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",s);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},completeRecovery:async(t,s,n={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",s);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},createAccount:async(t,s={})=>{o("createAccount","createAccountRequest",t);const n=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},createAccountV2:async(t,s={})=>{o("createAccountV2","createAccountRequestV2",t);const n=new URL("/v2/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},deployAccount:async(t,s,n={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",s);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},disableAccount:async(t,s={})=>{o("disableAccount","id",t);const n="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccount:async(t,s,n={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getAccountV2:async(t,s={})=>{o("getAccountV2","id",t);const n="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccounts:async(t,s,n,a,o,c,u,l={})=>{const p=new URL("/v1/accounts",i);let y;e&&(y=e.baseOptions);const g={method:"GET",...y,...l},w={},m={};await r(w,e),void 0!==t&&(m.limit=t),void 0!==s&&(m.skip=s),void 0!==n&&(m.order=n),void 0!==a&&(m.chainId=a),void 0!==o&&(m.player=o),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let R=y&&y.headers?y.headers:{};return g.headers={...w,...R,...l.headers},{url:d(p),options:g}},getAccountsV2:async(t,s,n,a,o,c,u,l,p={})=>{const y=new URL("/v2/accounts",i);let g;e&&(g=e.baseOptions);const w={method:"GET",...g,...p},m={},R={};await r(m,e),void 0!==t&&(R.limit=t),void 0!==s&&(R.skip=s),void 0!==n&&(R.order=n),void 0!==a&&(R.chainId=a),void 0!==o&&(R.user=o),void 0!==c&&(R.chainType=c),void 0!==u&&(R.accountType=u),void 0!==l&&(R.address=l),h(y,R);let P=g&&g.headers?g.headers:{};return w.headers={...m,...P,...p.headers},{url:d(y),options:w}},getSignerIdByAddress:async(t,s={})=>{o("getSignerIdByAddress","address",t);const n=new URL("/v2/accounts/signer",i);let a;e&&(a=e.baseOptions);const c={method:"GET",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.address=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},removeAccount:async(t,s={})=>{o("removeAccount","id",t);const n="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"DELETE",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},requestTransferOwnership:async(t,s,n={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",s);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},signPayload:async(t,s,n={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",s);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},startRecovery:async(t,s,n={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",s);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},switchChainV2:async(t,s={})=>{o("switchChainV2","switchChainQueriesV2",t);const n=new URL("/v2/accounts/switch-chain",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},syncAccount:async(t,s={})=>{o("syncAccount","id",t);const n="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await n.cancelTransferOwnership(a,i,o);return l(r,e,s,t)},async completeRecovery(a,i,o){const r=await n.completeRecovery(a,i,o);return l(r,e,s,t)},async createAccount(a,i){const o=await n.createAccount(a,i);return l(o,e,s,t)},async createAccountV2(a,i){const o=await n.createAccountV2(a,i);return l(o,e,s,t)},async deployAccount(a,i,o){const r=await n.deployAccount(a,i,o);return l(r,e,s,t)},async disableAccount(a,i){const o=await n.disableAccount(a,i);return l(o,e,s,t)},async getAccount(a,i,o){const r=await n.getAccount(a,i,o);return l(r,e,s,t)},async getAccountV2(a,i){const o=await n.getAccountV2(a,i);return l(o,e,s,t)},async getAccounts(a,i,o,r,c,h,u,d){const p=await n.getAccounts(a,i,o,r,c,h,u,d);return l(p,e,s,t)},async getAccountsV2(a,i,o,r,c,h,u,d,p){const y=await n.getAccountsV2(a,i,o,r,c,h,u,d,p);return l(y,e,s,t)},async getSignerIdByAddress(a,i){const o=await n.getSignerIdByAddress(a,i);return l(o,e,s,t)},async removeAccount(a,i){const o=await n.removeAccount(a,i);return l(o,e,s,t)},async requestTransferOwnership(a,i,o){const r=await n.requestTransferOwnership(a,i,o);return l(r,e,s,t)},async signPayload(a,i,o){const r=await n.signPayload(a,i,o);return l(r,e,s,t)},async startRecovery(a,i,o){const r=await n.startRecovery(a,i,o);return l(r,e,s,t)},async switchChainV2(a,i){const o=await n.switchChainV2(a,i);return l(o,e,s,t)},async syncAccount(a,i){const o=await n.syncAccount(a,i);return l(o,e,s,t)}}};class y extends n{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}createAccountV2(e,t){return p(this.configuration).createAccountV2(e.createAccountRequestV2,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.id,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.chainId,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountsV2(e={},t){return p(this.configuration).getAccountsV2(e.limit,e.skip,e.order,e.chainId,e.user,e.chainType,e.accountType,e.address,t).then(e=>e(this.axios,this.basePath))}getSignerIdByAddress(e,t){return p(this.configuration).getSignerIdByAddress(e.address,t).then(e=>e(this.axios,this.basePath))}removeAccount(e,t){return p(this.configuration).removeAccount(e.id,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}switchChainV2(e,t){return p(this.configuration).switchChainV2(e.switchChainQueriesV2,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const n=function(e){return{authenticateSIWE:async(t,s={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getJwks:async(t,s={})=>{o("getJwks","publishableKey",t);const n="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(n,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...s};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...s.headers},{url:d(a),options:c}},initOAuth:async(t,s,n={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,s,n={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,s,n={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,s,n={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,s={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},linkThirdParty:async(t,s,n={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,s,n={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,s,n={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,s={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const n=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},logout:async(t,s={})=>{o("logout","logoutRequest",t);const n=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},me:async(t={})=>{const s=new URL("/iam/v1/me",i);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let o=n&&n.headers?n.headers:{};return a.headers={...o,...t.headers},{url:d(s),options:a}},poolOAuth:async(t,s={})=>{o("poolOAuth","key",t);const n=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},refresh:async(t,s={})=>{o("refresh","refreshTokenRequest",t);const n=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},registerGuest:async(t,s={})=>{const n=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...s},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(n,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...s.headers},{url:d(n),options:o}},requestEmailVerification:async(t,s={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const n=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},requestResetPassword:async(t,s={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const n=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},resetPassword:async(t,s={})=>{o("resetPassword","resetPasswordRequest",t);const n=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},signupEmailPassword:async(t,s,n={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,s,n={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,s={})=>{o("unlinkEmail","unlinkEmailRequest",t);const n=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkOAuth:async(t,s={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const n=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkSIWE:async(t,s={})=>{o("unlinkSIWE","sIWERequest",t);const n=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},verifyEmail:async(t,s={})=>{o("verifyEmail","verifyEmailRequest",t);const n=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},verifyOAuthToken:async(t,s={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const n=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await n.authenticateSIWE(a,i);return l(o,e,s,t)},async getJwks(a,i){const o=await n.getJwks(a,i);return l(o,e,s,t)},async initOAuth(a,i,o){const r=await n.initOAuth(a,i,o);return l(r,e,s,t)},async initSIWE(a,i,o){const r=await n.initSIWE(a,i,o);return l(r,e,s,t)},async linkEmail(a,i,o){const r=await n.linkEmail(a,i,o);return l(r,e,s,t)},async linkOAuth(a,i,o){const r=await n.linkOAuth(a,i,o);return l(r,e,s,t)},async linkSIWE(a,i){const o=await n.linkSIWE(a,i);return l(o,e,s,t)},async linkThirdParty(a,i,o){const r=await n.linkThirdParty(a,i,o);return l(r,e,s,t)},async loginEmailPassword(a,i,o){const r=await n.loginEmailPassword(a,i,o);return l(r,e,s,t)},async loginOIDC(a,i,o){const r=await n.loginOIDC(a,i,o);return l(r,e,s,t)},async loginWithIdToken(a,i){const o=await n.loginWithIdToken(a,i);return l(o,e,s,t)},async logout(a,i){const o=await n.logout(a,i);return l(o,e,s,t)},async me(a){const i=await n.me(a);return l(i,e,s,t)},async poolOAuth(a,i){const o=await n.poolOAuth(a,i);return l(o,e,s,t)},async refresh(a,i){const o=await n.refresh(a,i);return l(o,e,s,t)},async registerGuest(a,i){const o=await n.registerGuest(a,i);return l(o,e,s,t)},async requestEmailVerification(a,i){const o=await n.requestEmailVerification(a,i);return l(o,e,s,t)},async requestResetPassword(a,i){const o=await n.requestResetPassword(a,i);return l(o,e,s,t)},async resetPassword(a,i){const o=await n.resetPassword(a,i);return l(o,e,s,t)},async signupEmailPassword(a,i,o){const r=await n.signupEmailPassword(a,i,o);return l(r,e,s,t)},async thirdParty(a,i,o){const r=await n.thirdParty(a,i,o);return l(r,e,s,t)},async unlinkEmail(a,i){const o=await n.unlinkEmail(a,i);return l(o,e,s,t)},async unlinkOAuth(a,i){const o=await n.unlinkOAuth(a,i);return l(o,e,s,t)},async unlinkSIWE(a,i){const o=await n.unlinkSIWE(a,i);return l(o,e,s,t)},async verifyEmail(a,i){const o=await n.verifyEmail(a,i);return l(o,e,s,t)},async verifyOAuthToken(a,i){const o=await n.verifyOAuthToken(a,i);return l(o,e,s,t)}}};class w extends n{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const n=function(e){return{handleRpcRequest:async(t,s={})=>{o("handleRpcRequest","jsonRpcRequest",t);const n=new URL("/rpc",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}}}}(t);return{async handleRpcRequest(a,i){const o=await n.handleRpcRequest(a,i);return l(o,e,s,t)}}};class R extends n{handleRpcRequest(e,t){return m(this.configuration).handleRpcRequest(e.jsonRpcRequest,t).then(e=>e(this.axios,this.basePath))}}const P=function(t){const n=function(e){return{createSession:async(t,s,n={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,s,n,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==s&&(w.limit=s),void 0!==n&&(w.skip=n),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,s,n={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},revokeSession:async(t,s,n={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,s,n={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",s);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await n.createSession(a,i,o);return l(r,e,s,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await n.getPlayerSessions(a,i,o,r,c,h);return l(u,e,s,t)},async getSession(a,i,o){const r=await n.getSession(a,i,o);return l(r,e,s,t)},async revokeSession(a,i,o){const r=await n.revokeSession(a,i,o);return l(r,e,s,t)},async signatureSession(a,i,o){const r=await n.signatureSession(a,i,o);return l(r,e,s,t)}}};class f extends n{createSession(e,t){return P(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return P(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 P(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return P(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return P(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const T=function(t){const n=function(e){return{createTransactionIntent:async(t,s,n={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,s={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const n=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getTransactionIntent:async(t,s,n={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getTransactionIntents:async(t,s,n,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},R={},P={};await r(R,e),void 0!==t&&(P.limit=t),void 0!==s&&(P.skip=s),void 0!==n&&(P.order=n),a&&(P.expand=a),void 0!==o&&(P.chainId=o),c&&(P.account=c),u&&(P.player=u),void 0!==l&&(P.status=l),p&&(P.policy=p),h(g,P);let f=w&&w.headers?w.headers:{};return m.headers={...R,...f,...y.headers},{url:d(g),options:m}},signature:async(t,s,n={})=>{o("signature","id",t),o("signature","signatureRequest",s);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await n.createTransactionIntent(a,i,o);return l(r,e,s,t)},async estimateTransactionIntentCost(a,i){const o=await n.estimateTransactionIntentCost(a,i);return l(o,e,s,t)},async getTransactionIntent(a,i,o){const r=await n.getTransactionIntent(a,i,o);return l(r,e,s,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await n.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,s,t)},async signature(a,i,o){const r=await n.signature(a,i,o);return l(r,e,s,t)}}};class O extends n{createTransactionIntent(e,t){return T(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return T(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return T(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return T(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return T(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class b{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const v=({basePath:e,accessToken:t,nativeAppIdentifier:s})=>{if(!e.trim())throw Error("basePath can not be empty");const n={basePath:e,accessToken:t};return s&&(n.baseOptions={headers:{"x-native-app-identifier":s}}),new b(n)};exports.BackendApiClients=class{config;transactionIntentsApi;accountsApi;rpcApi;sessionsApi;authenticationApi;storage;onLogout;axiosInstance;constructor(s){this.storage=s.storage,this.onLogout=s.onLogout,this.axiosInstance=e.create(),t(this.axiosInstance,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError}),this.setupInterceptors();const n={basePath:s.basePath,accessToken:s.accessToken,nativeAppIdentifier:s.nativeAppIdentifier};this.config={backend:v(n)},this.transactionIntentsApi=new O(this.config.backend,void 0,this.axiosInstance),this.accountsApi=new y(this.config.backend,void 0,this.axiosInstance),this.sessionsApi=new f(this.config.backend,void 0,this.axiosInstance),this.rpcApi=new R(this.config.backend,void 0,this.axiosInstance),this.authenticationApi=new w(this.config.backend,void 0,this.axiosInstance)}setupInterceptors(){this.axiosInstance.interceptors.response.use(e=>e,async e=>(401===e.response?.status&&(await this.clearAuthenticationState(),this.emitLogoutEvent()),Promise.reject(e)))}async clearAuthenticationState(){if(this.storage)try{this.storage.remove("openfort.authentication"),this.storage.remove("openfort.account"),this.storage.remove("openfort.session"),this.storage.remove("openfort.pkce_state"),this.storage.remove("openfort.pkce_verifier")}catch(e){}}emitLogoutEvent(){if(this.onLogout)try{this.onLogout()}catch(e){}}},exports.createConfig=v;
@@ -1 +1 @@
1
- "use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),r=require("../core/configuration/passkey.js"),t=require("../core/config/config.js"),a=require("../core/configuration/account.js"),s=require("../core/configuration/authentication.js"),n=require("../core/errors/openfortError.js"),i=require("../types/types.js"),o=require("../utils/debug.js"),d=require("../wallets/embedded.js"),c=require("../wallets/evm/evmProvider.js");require("../wallets/evm/types.js");var g=require("../wallets/evm/provider/eip6963.js"),h=require("../wallets/evm/walletHelpers.js"),y=require("../wallets/iframeManager.js"),p=require("../wallets/messaging/ReactNativeMessenger.js");require("../wallets/messaging/browserMessenger/backwardCompatibility.js");var u=require("../wallets/messaging/browserMessenger/messengers/WindowMessenger.js");exports.EmbeddedWalletApi=class{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;passkeyHandler;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,a,s){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=a,this.passkeyHandler=s,this.eventEmitter.on(i.OpenfortEvents.ON_LOGOUT,()=>{o.debugLog("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=t.SDKConfiguration.getInstance();if(!r)throw new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);return new e.BackendApiClients({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey,nativeAppIdentifier:r.nativeAppIdentifier})}async getIframeManager(){if(o.debugLog("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager&&this.iframeManager.hasFailed&&(o.debugLog("[HANDSHAKE DEBUG] Existing iframeManager has failed, clearing for recreation"),this.messenger&&(this.messenger.destroy(),this.messenger=null),this.iframeManager=null),this.iframeManager)return o.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return o.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;o.debugLog("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return o.debugLog("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,o.debugLog("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw o.debugLog("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,this.messenger&&(this.messenger.destroy(),this.messenger=null),this.iframeManager=null,e}}async createIframeManager(){o.debugLog("[HANDSHAKE DEBUG] createIframeManager starting");const e=t.SDKConfiguration.getInstance();if(!e)throw o.debugLog("[HANDSHAKE DEBUG] Configuration not found"),new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);let r;if(o.debugLog("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)o.debugLog("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger&&(o.debugLog("[HANDSHAKE DEBUG] Destroying old messenger before creating new one"),this.messenger.destroy()),this.messenger=new p.ReactNativeMessenger(this.messagePoster),o.debugLog("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),r=this.messenger;else{o.debugLog("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const t=this.createIframe(e.iframeUrl),a=new URL(e.iframeUrl).origin;r=new u({remoteWindow:t.contentWindow,allowedOrigins:[a]}),o.debugLog("[HANDSHAKE DEBUG] Created WindowMessenger")}return o.debugLog("[HANDSHAKE DEBUG] Creating IframeManager instance"),new y.IframeManager(e,this.storage,r)}async ensureSigner(){if(this.iframeManager&&this.iframeManager.hasFailed&&(o.debugLog("IframeManager has failed, clearing signer for recreation"),this.signer=null),this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager();return new d.EmbeddedSigner(e,this.storage,this.backendApiClients,this.passkeyHandler,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new n.OpenfortError("Document is not available. Please provide a message poster for non-browser environments.",n.OpenfortErrorType.INVALID_CONFIGURATION);const r=document.getElementById("openfort-iframe");r&&r.remove();const t=document.createElement("iframe");return t.style.display="none",t.id="openfort-iframe",t.src=e,document.body.appendChild(t),t}async getPasskeyKey(e){const r=await s.Authentication.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:r.player})}async getEntropy(e){switch(e.recoveryMethod){case i.RecoveryMethod.PASSWORD:return{recoveryPassword:e.password};case i.RecoveryMethod.AUTOMATIC:return{encryptionSession:e.encryptionSession};case i.RecoveryMethod.PASSKEY:return{passkey:e.passkeyInfo?{id:e.passkeyInfo.passkeyId,key:e.passkeyInfo.passkeyKey||await this.getPasskeyKey(e.passkeyInfo.passkeyId)}:{}};default:throw new n.OpenfortError("Invalid recovery method",n.OpenfortErrorType.INVALID_CONFIGURATION)}}async configure(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:i.RecoveryMethod.AUTOMATIC},[t,n,o]=await Promise.all([s.Authentication.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(r)]),d={chainId:e.chainId,entropy:o,accountType:e.accountType??i.AccountTypeEnum.SMART_ACCOUNT,chainType:e.chainType??i.ChainTypeEnum.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},c=await n.configure(d);return{id:c.id,chainId:c.chainId,user:t.player,address:c.address,ownerAddress:c.ownerAddress,chainType:c.chainType,accountType:c.accountType,implementationType:c.implementationType,createdAt:c.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(c.recoveryMethod),recoveryMethodDetails:c.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:i.RecoveryMethod.AUTOMATIC},o=await s.Authentication.fromStorage(this.storage);if(!o)throw new n.OpenfortError("missing authentication",n.OpenfortErrorType.AUTHENTICATION_ERROR);if(t.recoveryMethod===i.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:o?.player});t.passkeyInfo={passkeyId:e.id,passkeyKey:e.key}}const[d,c]=await Promise.all([this.ensureSigner(),this.getEntropy(t)]),g=await d.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:c}),h={id:g.id,chainId:g.chainId,user:o.player,address:g.address,ownerAddress:g.ownerAddress,chainType:g.chainType,accountType:g.accountType,implementationType:g.implementationType,createdAt:g.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(g.recoveryMethod),recoveryMethodDetails:g.recoveryMethodDetails};return this.eventEmitter.emit(i.OpenfortEvents.ON_EMBEDDED_WALLET_CREATED,h),h}async recover(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:i.RecoveryMethod.AUTOMATIC};if(r.recoveryMethod===i.RecoveryMethod.PASSKEY){if(!r.passkeyInfo?.passkeyId)throw new n.OpenfortError("Passkey ID must be provided for passkey recovery",n.OpenfortErrorType.INVALID_CONFIGURATION);r.passkeyInfo={passkeyId:r.passkeyInfo.passkeyId}}const[t,o,d]=await Promise.all([this.ensureSigner(),this.getEntropy(r),s.Authentication.fromStorage(this.storage)]),c=await t.recover({account:e.account,entropy:o}),g={id:c.id,chainId:c.chainId,user:d.player,address:c.address,ownerAddress:c.ownerAddress,chainType:c.chainType,accountType:c.accountType,implementationType:c.implementationType,createdAt:c.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(c.recoveryMethod),recoveryMethodDetails:c.recoveryMethodDetails};return this.eventEmitter.emit(i.OpenfortEvents.ON_EMBEDDED_WALLET_RECOVERED,g),g}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:s=!0,arrayifyMessage:n=!1}=r||{},i=await a.Account.fromStorage(this.storage);return await t.sign(e,n,s,i?.chainType)}async signTypedData(e,r,t){await this.validateAndRefreshToken();const s=await this.ensureSigner(),i=await a.Account.fromStorage(this.storage);if(!i)throw new n.OpenfortError("No account found",n.OpenfortErrorType.MISSING_SIGNER_ERROR);const o={...r};delete o.EIP712Domain;const{_TypedDataEncoder:d}=await import("@ethersproject/hash"),c=d.hash(e,o,t);return await h.signMessage({hash:c,implementationType:i.implementationType||i.type,chainId:Number(i.chainId),signer:s,address:i.address,ownerAddress:i.ownerAddress,factoryAddress:i.factoryAddress,salt:i.salt})}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setRecoveryMethod(e,t){await this.validateAndRefreshToken();const o=await this.ensureSigner(),d=await s.Authentication.fromStorage(this.storage);if(!d)throw new n.OpenfortError("missing authentication",n.OpenfortErrorType.AUTHENTICATION_ERROR);let c,g,h,y;if(e.recoveryMethod===i.RecoveryMethod.PASSKEY){const e=await a.Account.fromStorage(this.storage);if(!e)throw new n.OpenfortError("missing account",n.OpenfortErrorType.INVALID_CONFIGURATION);const r=e?.recoveryMethodDetails?.passkeyId;if(!r)throw new n.OpenfortError("missing passkey id for account",n.OpenfortErrorType.INVALID_CONFIGURATION);h={passkeyId:r,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:r,seed:d.player})}}else if(t.recoveryMethod===i.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:d.player});h={passkeyId:e.id,passkeyKey:e.key},y={passkeyId:e.id}}if(e.recoveryMethod===i.RecoveryMethod.PASSWORD?c=e.password:t.recoveryMethod===i.RecoveryMethod.PASSWORD&&(c=t.password),e.recoveryMethod===i.RecoveryMethod.AUTOMATIC?g=e.encryptionSession:t.recoveryMethod===i.RecoveryMethod.AUTOMATIC&&(g=t.encryptionSession),!c&&!g)throw new n.OpenfortError("Password or encryption session is not provided",n.OpenfortErrorType.INVALID_CONFIGURATION);await o.setRecoveryMethod({recoveryMethod:t.recoveryMethod,recoveryPassword:c,encryptionSession:g,passkeyInfo:h});const p=await a.Account.fromStorage(this.storage);p&&new a.Account({...p,recoveryMethod:t.recoveryMethod,recoveryMethodDetails:y}).save(this.storage)}async get(){const e=await a.Account.fromStorage(this.storage);if(!e)throw new n.OpenfortError("No signer configured",n.OpenfortErrorType.MISSING_SIGNER_ERROR);const r=await s.Authentication.fromStorage(this.storage);if(!r)throw new n.OpenfortError("No access token found",n.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{id:e.id,chainId:e.chainId,user:r.player,address:e.address,ownerAddress:e.ownerAddress,chainType:e.chainType,accountType:e.accountType,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const r={accountType:i.AccountTypeEnum.SMART_ACCOUNT,...e},o=t.SDKConfiguration.getInstance();if(!o)throw new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const d=await s.Authentication.fromStorage(this.storage);if(!d)throw new n.OpenfortError("No access token found",n.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return n.withOpenfortError(async()=>(await this.backendApiClients.accountsApi.getAccountsV2(r,{headers:{authorization:`Bearer ${o.baseConfiguration.publishableKey}`,"x-player-token":d.token,"x-auth-provider":d.thirdPartyProvider,"x-token-type":d.thirdPartyTokenType}})).data.data.map(e=>({user:e.user,chainType:e.chainType,id:e.id,address:e.address,ownerAddress:e.ownerAddress,accountType:e.accountType,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{default:n.OpenfortErrorType.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await s.Authentication.fromStorage(this.storage))return i.EmbeddedState.UNAUTHENTICATED;return await a.Account.fromStorage(this.storage)?i.EmbeddedState.READY:i.EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return o.debugLog("Failed to get embedded state:",e),i.EmbeddedState.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},t=await s.Authentication.fromStorage(this.storage),n=await a.Account.fromStorage(this.storage);return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new c.EvmProvider({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:n||void 0,authentication:t||void 0,backendApiClients:this.backendApiClients,policyId:r.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:r.chains}),r.announceProvider&&g.announceProvider({info:{...g.openfortProviderInfo,...r.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(r=>{setTimeout(r,e)});const r=await this.getIframeManager();if(!r.isLoaded())return!1;const t=await s.Authentication.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return o.debugLog("Ping failed:",e),!1}}getURL(){const e=t.SDKConfiguration.getInstance();if(!e)throw new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new n.OpenfortError("Invalid message poster",n.OpenfortErrorType.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&this.messenger.destroy(),this.iframeManager&&this.iframeManager.destroy(),this.signer=null,this.signerPromise=null,this.iframeManager=null,this.iframeManagerPromise=null,this.messenger=null}async handleLogout(){const e=await this.ensureSigner();await e.disconnect(),this.provider=null,this.messenger=null,this.iframeManager=null,this.iframeManagerPromise=null,this.signer=null,this.signerPromise=null}async onMessage(e){if(!e||"object"!=typeof e)return void o.debugLog("Invalid message received:",e);o.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 o.debugLog("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const t=await this.getIframeManager();o.debugLog(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${t.isLoaded()}`),r&&!t.isLoaded()&&o.debugLog("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),o.debugLog("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await t.onMessage(e),o.debugLog("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}};
1
+ "use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),r=require("../core/configuration/passkey.js"),t=require("../core/config/config.js"),a=require("../core/configuration/account.js"),s=require("../core/configuration/authentication.js"),n=require("../core/errors/openfortError.js"),i=require("../types/types.js"),o=require("../utils/debug.js"),d=require("../wallets/embedded.js"),c=require("../wallets/evm/evmProvider.js");require("../wallets/evm/types.js");var g=require("../wallets/evm/provider/eip6963.js"),h=require("../wallets/evm/walletHelpers.js"),y=require("../wallets/iframeManager.js"),p=require("../wallets/messaging/ReactNativeMessenger.js");require("../wallets/messaging/browserMessenger/backwardCompatibility.js");var u=require("../wallets/messaging/browserMessenger/messengers/WindowMessenger.js");exports.EmbeddedWalletApi=class{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;passkeyHandler;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,a,s){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=a,this.passkeyHandler=s,this.eventEmitter.on(i.OpenfortEvents.ON_LOGOUT,()=>{o.debugLog("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=t.SDKConfiguration.getInstance();if(!r)throw new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);return new e.BackendApiClients({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey,nativeAppIdentifier:r.nativeAppIdentifier})}async getIframeManager(){if(o.debugLog("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager&&this.iframeManager.hasFailed&&(o.debugLog("[HANDSHAKE DEBUG] Existing iframeManager has failed, clearing for recreation"),this.messenger&&(this.messenger.destroy(),this.messenger=null),this.iframeManager=null),this.iframeManager)return o.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return o.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;o.debugLog("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return o.debugLog("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,o.debugLog("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw o.debugLog("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,this.messenger&&(this.messenger.destroy(),this.messenger=null),this.iframeManager=null,e}}async createIframeManager(){o.debugLog("[HANDSHAKE DEBUG] createIframeManager starting");const e=t.SDKConfiguration.getInstance();if(!e)throw o.debugLog("[HANDSHAKE DEBUG] Configuration not found"),new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);let r;if(o.debugLog("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)o.debugLog("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger&&(o.debugLog("[HANDSHAKE DEBUG] Destroying old messenger before creating new one"),this.messenger.destroy()),this.messenger=new p.ReactNativeMessenger(this.messagePoster),o.debugLog("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),r=this.messenger;else{o.debugLog("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const t=this.createIframe(e.iframeUrl),a=new URL(e.iframeUrl).origin;r=new u({remoteWindow:t.contentWindow,allowedOrigins:[a]}),o.debugLog("[HANDSHAKE DEBUG] Created WindowMessenger")}return o.debugLog("[HANDSHAKE DEBUG] Creating IframeManager instance"),new y.IframeManager(e,this.storage,r)}async ensureSigner(){if(this.iframeManager&&this.iframeManager.hasFailed&&(o.debugLog("IframeManager has failed, clearing signer for recreation"),this.signer=null),this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager();return new d.EmbeddedSigner(e,this.storage,this.backendApiClients,this.passkeyHandler,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new n.OpenfortError("Document is not available. Please provide a message poster for non-browser environments.",n.OpenfortErrorType.INVALID_CONFIGURATION);const r=document.getElementById("openfort-iframe");r&&r.remove();const t=document.createElement("iframe");return t.style.display="none",t.id="openfort-iframe",t.src=e,document.body.appendChild(t),t}async getPasskeyKey(e){const r=await s.Authentication.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:r.player})}async getEntropy(e){switch(e.recoveryMethod){case i.RecoveryMethod.PASSWORD:return{recoveryPassword:e.password};case i.RecoveryMethod.AUTOMATIC:return{encryptionSession:e.encryptionSession};case i.RecoveryMethod.PASSKEY:return{passkey:e.passkeyInfo?{id:e.passkeyInfo.passkeyId,key:e.passkeyInfo.passkeyKey||await this.getPasskeyKey(e.passkeyInfo.passkeyId)}:{}};default:throw new n.OpenfortError("Invalid recovery method",n.OpenfortErrorType.INVALID_CONFIGURATION)}}async configure(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:i.RecoveryMethod.AUTOMATIC},[t,n,o]=await Promise.all([s.Authentication.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(r)]),d={chainId:e.chainId,entropy:o,accountType:e.accountType??i.AccountTypeEnum.SMART_ACCOUNT,chainType:e.chainType??i.ChainTypeEnum.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},c=await n.configure(d);return{id:c.id,chainId:c.chainId,user:t.player,address:c.address,ownerAddress:c.ownerAddress,chainType:c.chainType,accountType:c.accountType,implementationType:c.implementationType,factoryAddress:c.factoryAddress,salt:c.salt,createdAt:c.createdAt,implementationAddress:c.implementationAddress,recoveryMethod:a.Account.parseRecoveryMethod(c.recoveryMethod),recoveryMethodDetails:c.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:i.RecoveryMethod.AUTOMATIC},o=await s.Authentication.fromStorage(this.storage);if(!o)throw new n.OpenfortError("missing authentication",n.OpenfortErrorType.AUTHENTICATION_ERROR);if(t.recoveryMethod===i.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:o?.player});t.passkeyInfo={passkeyId:e.id,passkeyKey:e.key}}const[d,c]=await Promise.all([this.ensureSigner(),this.getEntropy(t)]),g=await d.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:c}),h={id:g.id,chainId:g.chainId,user:o.player,address:g.address,ownerAddress:g.ownerAddress,chainType:g.chainType,accountType:g.accountType,implementationType:g.implementationType,factoryAddress:g.factoryAddress,salt:g.salt,createdAt:g.createdAt,implementationAddress:g.implementationAddress,recoveryMethod:a.Account.parseRecoveryMethod(g.recoveryMethod),recoveryMethodDetails:g.recoveryMethodDetails};return this.eventEmitter.emit(i.OpenfortEvents.ON_EMBEDDED_WALLET_CREATED,h),h}async recover(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:i.RecoveryMethod.AUTOMATIC};if(r.recoveryMethod===i.RecoveryMethod.PASSKEY){if(!r.passkeyInfo?.passkeyId)throw new n.OpenfortError("Passkey ID must be provided for passkey recovery",n.OpenfortErrorType.INVALID_CONFIGURATION);r.passkeyInfo={passkeyId:r.passkeyInfo.passkeyId}}const[t,o,d]=await Promise.all([this.ensureSigner(),this.getEntropy(r),s.Authentication.fromStorage(this.storage)]),c=await t.recover({account:e.account,entropy:o}),g={id:c.id,chainId:c.chainId,implementationAddress:c.implementationAddress,factoryAddress:c.factoryAddress,salt:c.salt,user:d.player,address:c.address,ownerAddress:c.ownerAddress,chainType:c.chainType,accountType:c.accountType,implementationType:c.implementationType,createdAt:c.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(c.recoveryMethod),recoveryMethodDetails:c.recoveryMethodDetails};return this.eventEmitter.emit(i.OpenfortEvents.ON_EMBEDDED_WALLET_RECOVERED,g),g}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:s=!0,arrayifyMessage:n=!1}=r||{},i=await a.Account.fromStorage(this.storage);return await t.sign(e,n,s,i?.chainType)}async signTypedData(e,r,t){await this.validateAndRefreshToken();const s=await this.ensureSigner(),i=await a.Account.fromStorage(this.storage);if(!i)throw new n.OpenfortError("No account found",n.OpenfortErrorType.MISSING_SIGNER_ERROR);const o={...r};delete o.EIP712Domain;const{_TypedDataEncoder:d}=await import("@ethersproject/hash"),c=d.hash(e,o,t);return await h.signMessage({hash:c,implementationType:i.implementationType||i.type,chainId:Number(i.chainId),signer:s,address:i.address,ownerAddress:i.ownerAddress,factoryAddress:i.factoryAddress,salt:i.salt})}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setRecoveryMethod(e,t){await this.validateAndRefreshToken();const o=await this.ensureSigner(),d=await s.Authentication.fromStorage(this.storage);if(!d)throw new n.OpenfortError("missing authentication",n.OpenfortErrorType.AUTHENTICATION_ERROR);let c,g,h,y;if(e.recoveryMethod===i.RecoveryMethod.PASSKEY){const e=await a.Account.fromStorage(this.storage);if(!e)throw new n.OpenfortError("missing account",n.OpenfortErrorType.INVALID_CONFIGURATION);const r=e?.recoveryMethodDetails?.passkeyId;if(!r)throw new n.OpenfortError("missing passkey id for account",n.OpenfortErrorType.INVALID_CONFIGURATION);h={passkeyId:r,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:r,seed:d.player})}}else if(t.recoveryMethod===i.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:d.player});h={passkeyId:e.id,passkeyKey:e.key},y={passkeyId:e.id}}if(e.recoveryMethod===i.RecoveryMethod.PASSWORD?c=e.password:t.recoveryMethod===i.RecoveryMethod.PASSWORD&&(c=t.password),e.recoveryMethod===i.RecoveryMethod.AUTOMATIC?g=e.encryptionSession:t.recoveryMethod===i.RecoveryMethod.AUTOMATIC&&(g=t.encryptionSession),!c&&!g)throw new n.OpenfortError("Password or encryption session is not provided",n.OpenfortErrorType.INVALID_CONFIGURATION);await o.setRecoveryMethod({recoveryMethod:t.recoveryMethod,recoveryPassword:c,encryptionSession:g,passkeyInfo:h});const p=await a.Account.fromStorage(this.storage);p&&new a.Account({...p,recoveryMethod:t.recoveryMethod,recoveryMethodDetails:y}).save(this.storage)}async get(){const e=await a.Account.fromStorage(this.storage);if(!e)throw new n.OpenfortError("No signer configured",n.OpenfortErrorType.MISSING_SIGNER_ERROR);const r=await s.Authentication.fromStorage(this.storage);if(!r)throw new n.OpenfortError("No access token found",n.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{id:e.id,chainId:e.chainId,user:r.player,address:e.address,ownerAddress:e.ownerAddress,factoryAddress:e.factoryAddress,salt:e.salt,chainType:e.chainType,accountType:e.accountType,implementationAddress:e.implementationAddress,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const r={accountType:i.AccountTypeEnum.SMART_ACCOUNT,...e},o=t.SDKConfiguration.getInstance();if(!o)throw new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const d=await s.Authentication.fromStorage(this.storage);if(!d)throw new n.OpenfortError("No access token found",n.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return n.withOpenfortError(async()=>(await this.backendApiClients.accountsApi.getAccountsV2(r,{headers:{authorization:`Bearer ${o.baseConfiguration.publishableKey}`,"x-player-token":d.token,"x-auth-provider":d.thirdPartyProvider,"x-token-type":d.thirdPartyTokenType}})).data.data.map(e=>({user:e.user,chainType:e.chainType,id:e.id,address:e.address,active:e.smartAccount?.active,ownerAddress:e.ownerAddress,factoryAddress:e.smartAccount?.factoryAddress,salt:e.smartAccount?.salt,accountType:e.accountType,implementationAddress:e.smartAccount?.implementationAddress,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{default:n.OpenfortErrorType.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await s.Authentication.fromStorage(this.storage))return i.EmbeddedState.UNAUTHENTICATED;return await a.Account.fromStorage(this.storage)?i.EmbeddedState.READY:i.EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return o.debugLog("Failed to get embedded state:",e),i.EmbeddedState.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},t=await s.Authentication.fromStorage(this.storage),n=await a.Account.fromStorage(this.storage);return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new c.EvmProvider({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:n||void 0,authentication:t||void 0,backendApiClients:this.backendApiClients,policyId:r.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:r.chains}),r.announceProvider&&g.announceProvider({info:{...g.openfortProviderInfo,...r.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(r=>{setTimeout(r,e)});const r=await this.getIframeManager();if(!r.isLoaded())return!1;const t=await s.Authentication.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return o.debugLog("Ping failed:",e),!1}}getURL(){const e=t.SDKConfiguration.getInstance();if(!e)throw new n.OpenfortError("Configuration not found",n.OpenfortErrorType.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new n.OpenfortError("Invalid message poster",n.OpenfortErrorType.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&this.messenger.destroy(),this.iframeManager&&this.iframeManager.destroy(),this.signer=null,this.signerPromise=null,this.iframeManager=null,this.iframeManagerPromise=null,this.messenger=null}async handleLogout(){const e=await this.ensureSigner();await e.disconnect(),this.provider=null,this.messenger=null,this.iframeManager=null,this.iframeManagerPromise=null,this.signer=null,this.signerPromise=null}async onMessage(e){if(!e||"object"!=typeof e)return void o.debugLog("Invalid message received:",e);o.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 o.debugLog("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const t=await this.getIframeManager();o.debugLog(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${t.isLoaded()}`),r&&!t.isLoaded()&&o.debugLog("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),o.debugLog("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await t.onMessage(e),o.debugLog("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}};
@@ -1 +1 @@
1
- "use strict";var e=require("../../storage/istorage.js");require("../errors/openfortError.js");var r=require("../../types/types.js");require("human-id"),require("eventemitter3"),require("../../wallets/evm/JsonRpcError.js"),require("../../wallets/evm/types.js"),require("../../wallets/evm/provider/eip6963.js"),require("../errors/sentry.js"),require("../../wallets/messaging/browserMessenger/backwardCompatibility.js"),require("../../wallets/types.js"),require("jose");class t{constructor(e){this.user=e.user,this.id=e.id,this.chainType=e.chainType,this.address=e.address,this.accountType=e.accountType,this.chainId=e.chainId,this.createdAt=e.createdAt,this.implementationType=e.implementationType,this.factoryAddress=e.factoryAddress,this.recoveryMethod=e.recoveryMethod,this.recoveryMethodDetails=e.recoveryMethodDetails,this.salt=e.salt,this.ownerAddress=e.ownerAddress,this.type=e.type}user;id;chainType;address;accountType;chainId;ownerAddress;factoryAddress;salt;createdAt;implementationType;recoveryMethod;recoveryMethodDetails;type;save(r){r.save(e.StorageKeys.ACCOUNT,JSON.stringify({user:this.user,id:this.id,chainType:this.chainType,address:this.address,accountType:this.accountType,chainId:this.chainId,ownerAddress:this.ownerAddress,createdAt:this.createdAt,implementationType:this.implementationType,factoryAddress:this.factoryAddress,salt:this.salt,recoveryMethod:this.recoveryMethod,recoveryMethodDetails:this.recoveryMethodDetails}))}static parseRecoveryMethod=e=>{switch(e){case"user":case r.RecoveryMethod.PASSWORD:return r.RecoveryMethod.PASSWORD;case"project":case r.RecoveryMethod.AUTOMATIC:return r.RecoveryMethod.AUTOMATIC;case"passkey":case r.RecoveryMethod.PASSKEY:return r.RecoveryMethod.PASSKEY;default:return}};static async fromStorage(r){const s=await r.get(e.StorageKeys.ACCOUNT);if(!s)return null;try{const e=JSON.parse(s);return new t(e)}catch{return null}}}exports.Account=t;
1
+ "use strict";var e=require("../../storage/istorage.js");require("../errors/openfortError.js");var t=require("../../types/types.js");require("human-id"),require("eventemitter3"),require("../../wallets/evm/JsonRpcError.js"),require("@ethersproject/keccak256"),require("../../wallets/evm/types.js"),require("../../wallets/evm/provider/eip6963.js"),require("../errors/sentry.js"),require("../../wallets/messaging/browserMessenger/backwardCompatibility.js"),require("../../wallets/types.js"),require("jose");class r{constructor(e){this.user=e.user,this.id=e.id,this.chainType=e.chainType,this.address=e.address,this.accountType=e.accountType,this.chainId=e.chainId,this.createdAt=e.createdAt,this.implementationAddress=e.implementationAddress,this.implementationType=e.implementationType,this.factoryAddress=e.factoryAddress,this.recoveryMethod=e.recoveryMethod,this.recoveryMethodDetails=e.recoveryMethodDetails,this.salt=e.salt,this.ownerAddress=e.ownerAddress,this.type=e.type}user;id;chainType;address;accountType;chainId;ownerAddress;factoryAddress;implementationAddress;salt;createdAt;implementationType;recoveryMethod;recoveryMethodDetails;type;save(t){t.save(e.StorageKeys.ACCOUNT,JSON.stringify({user:this.user,id:this.id,chainType:this.chainType,address:this.address,accountType:this.accountType,chainId:this.chainId,ownerAddress:this.ownerAddress,createdAt:this.createdAt,implementationType:this.implementationType,factoryAddress:this.factoryAddress,implementationAddress:this.implementationAddress,salt:this.salt,recoveryMethod:this.recoveryMethod,recoveryMethodDetails:this.recoveryMethodDetails}))}static parseRecoveryMethod=e=>{switch(e){case"user":case t.RecoveryMethod.PASSWORD:return t.RecoveryMethod.PASSWORD;case"project":case t.RecoveryMethod.AUTOMATIC:return t.RecoveryMethod.AUTOMATIC;case"passkey":case t.RecoveryMethod.PASSKEY:return t.RecoveryMethod.PASSKEY;default:return}};static async fromStorage(t){const s=await t.get(e.StorageKeys.ACCOUNT);if(!s)return null;try{const e=JSON.parse(s);return new r(e)}catch{return null}}}exports.Account=r;
@@ -1 +1 @@
1
- "use strict";var e=require("./configuration/authentication.js"),r=require("./errors/openfortError.js"),t=require("../types/types.js");require("human-id");var n=require("./config/config.js");require("../storage/istorage.js");var i=require("../utils/debug.js");require("eventemitter3"),require("../wallets/evm/JsonRpcError.js"),require("../wallets/evm/types.js"),require("../wallets/evm/provider/eip6963.js"),require("./errors/sentry.js"),require("../wallets/messaging/browserMessenger/backwardCompatibility.js"),require("../wallets/types.js"),require("jose");var o=require("../utils/promiseUtils.js");exports.OpenfortInternal=class{storage;authManager;eventEmitter;constructor(e,r,t){this.storage=e,this.authManager=r,this.eventEmitter=t}async getThirdPartyAuthToken(){const i=n.SDKConfiguration.getInstance();if(!i?.thirdPartyAuth)throw new r.OpenfortError("No third party configuration found",r.OpenfortErrorType.INTERNAL_ERROR);const{getAccessToken:o,provider:a}=i.thirdPartyAuth;if(!o||!a)throw new r.OpenfortError("Third party is not configured. Please configure getAccessToken and thirdPartyAuthProvider in your Openfort instance",r.OpenfortErrorType.INVALID_CONFIGURATION);const s=await o();if(!s)throw new r.OpenfortError("Could not get access token",r.OpenfortErrorType.AUTHENTICATION_ERROR);let u=(await e.Authentication.fromStorage(this.storage))?.player;if(!u){const e=await this.authManager.authenticateThirdParty(a,s,t.TokenType.ID_TOKEN);u=e?.id}return new e.Authentication("third_party",s,u,null,a,t.TokenType.ID_TOKEN).save(this.storage),s}async getAccessToken(){if(n.SDKConfiguration.getInstance()?.thirdPartyAuth)return this.getThirdPartyAuthToken();return(await e.Authentication.fromStorage(this.storage))?.token??null}async validateAndRefreshToken(a){return o.singlePromise(async()=>{if(n.SDKConfiguration.getInstance()?.thirdPartyAuth)return void await this.getThirdPartyAuthToken();const o=await e.Authentication.fromStorage(this.storage);if(!o)throw new r.OpenfortError("Must be logged in to validate and refresh token",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);let s;i.debugLog("validating credentials...");try{s=await this.authManager.validateCredentials(o,a)}catch(r){throw e.Authentication.clear(this.storage),this.eventEmitter.emit(t.OpenfortEvents.ON_LOGOUT),r}if(!s.player)throw new r.OpenfortError("No user found in credentials",r.OpenfortErrorType.INTERNAL_ERROR);s.accessToken!==o.token&&(i.debugLog("tokens refreshed"),new e.Authentication("jwt",s.accessToken,s.player,s.refreshToken).save(this.storage))},"openfort.validateAndRefreshToken")}};
1
+ "use strict";var e=require("./configuration/authentication.js"),r=require("./errors/openfortError.js"),t=require("../types/types.js");require("human-id");var n=require("./config/config.js");require("../storage/istorage.js");var i=require("../utils/debug.js");require("eventemitter3"),require("../wallets/evm/JsonRpcError.js"),require("@ethersproject/keccak256"),require("../wallets/evm/types.js"),require("../wallets/evm/provider/eip6963.js"),require("./errors/sentry.js"),require("../wallets/messaging/browserMessenger/backwardCompatibility.js"),require("../wallets/types.js"),require("jose");var o=require("../utils/promiseUtils.js");exports.OpenfortInternal=class{storage;authManager;eventEmitter;constructor(e,r,t){this.storage=e,this.authManager=r,this.eventEmitter=t}async getThirdPartyAuthToken(){const i=n.SDKConfiguration.getInstance();if(!i?.thirdPartyAuth)throw new r.OpenfortError("No third party configuration found",r.OpenfortErrorType.INTERNAL_ERROR);const{getAccessToken:o,provider:a}=i.thirdPartyAuth;if(!o||!a)throw new r.OpenfortError("Third party is not configured. Please configure getAccessToken and thirdPartyAuthProvider in your Openfort instance",r.OpenfortErrorType.INVALID_CONFIGURATION);const s=await o();if(!s)throw new r.OpenfortError("Could not get access token",r.OpenfortErrorType.AUTHENTICATION_ERROR);let u=(await e.Authentication.fromStorage(this.storage))?.player;if(!u){const e=await this.authManager.authenticateThirdParty(a,s,t.TokenType.ID_TOKEN);u=e?.id}return new e.Authentication("third_party",s,u,null,a,t.TokenType.ID_TOKEN).save(this.storage),s}async getAccessToken(){if(n.SDKConfiguration.getInstance()?.thirdPartyAuth)return this.getThirdPartyAuthToken();return(await e.Authentication.fromStorage(this.storage))?.token??null}async validateAndRefreshToken(a){return o.singlePromise(async()=>{if(n.SDKConfiguration.getInstance()?.thirdPartyAuth)return void await this.getThirdPartyAuthToken();const o=await e.Authentication.fromStorage(this.storage);if(!o)throw new r.OpenfortError("Must be logged in to validate and refresh token",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);let s;i.debugLog("validating credentials...");try{s=await this.authManager.validateCredentials(o,a)}catch(r){throw e.Authentication.clear(this.storage),this.eventEmitter.emit(t.OpenfortEvents.ON_LOGOUT),r}if(!s.player)throw new r.OpenfortError("No user found in credentials",r.OpenfortErrorType.INTERNAL_ERROR);s.accessToken!==o.token&&(i.debugLog("tokens refreshed"),new e.Authentication("jwt",s.accessToken,s.player,s.refreshToken).save(this.storage))},"openfort.validateAndRefreshToken")}};
@@ -1 +1 @@
1
- "use strict";var e=require("./core/openfort.js"),r=require("./api/auth.js"),t=require("./api/embeddedWallet.js"),o=require("./api/proxy.js"),n=require("./api/user.js"),i=require("./core/config/config.js"),p=require("./core/errors/openfortError.js"),u=require("./core/openfortInternal.js"),s=require("./wallets/iframeManager.js"),f=require("./types/types.js");const c=e.Openfort.getEventEmitter();exports.Openfort=e.Openfort,exports.AuthApi=r.AuthApi,exports.EmbeddedWalletApi=t.EmbeddedWalletApi,exports.ProxyApi=o.ProxyApi,exports.UserApi=n.UserApi,exports.OpenfortConfiguration=i.OpenfortConfiguration,exports.SDKConfiguration=i.SDKConfiguration,exports.ShieldConfiguration=i.ShieldConfiguration,exports.OpenfortError=p.OpenfortError,Object.defineProperty(exports,"OpenfortErrorType",{enumerable:!0,get:function(){return p.OpenfortErrorType}}),exports.OpenfortInternal=u.OpenfortInternal,exports.MissingProjectEntropyError=s.MissingProjectEntropyError,exports.MissingRecoveryPasswordError=s.MissingRecoveryPasswordError,exports.NotConfiguredError=s.NotConfiguredError,exports.OTPRequiredError=s.OTPRequiredError,exports.WrongRecoveryPasswordError=s.WrongRecoveryPasswordError,Object.defineProperty(exports,"AccountTypeEnum",{enumerable:!0,get:function(){return f.AccountTypeEnum}}),Object.defineProperty(exports,"AuthActionRequiredActions",{enumerable:!0,get:function(){return f.AuthActionRequiredActions}}),Object.defineProperty(exports,"AuthType",{enumerable:!0,get:function(){return f.AuthType}}),Object.defineProperty(exports,"BasicAuthProvider",{enumerable:!0,get:function(){return f.BasicAuthProvider}}),Object.defineProperty(exports,"ChainTypeEnum",{enumerable:!0,get:function(){return f.ChainTypeEnum}}),Object.defineProperty(exports,"EmbeddedState",{enumerable:!0,get:function(){return f.EmbeddedState}}),Object.defineProperty(exports,"OAuthProvider",{enumerable:!0,get:function(){return f.OAuthProvider}}),Object.defineProperty(exports,"OpenfortEvents",{enumerable:!0,get:function(){return f.OpenfortEvents}}),Object.defineProperty(exports,"RecoveryMethod",{enumerable:!0,get:function(){return f.RecoveryMethod}}),Object.defineProperty(exports,"ThirdPartyOAuthProvider",{enumerable:!0,get:function(){return f.ThirdPartyAuthProvider}}),Object.defineProperty(exports,"TokenType",{enumerable:!0,get:function(){return f.TokenType}}),exports.openfortEvents=c;
1
+ "use strict";var e=require("./core/openfort.js"),r=require("./api/auth.js"),t=require("./api/embeddedWallet.js"),o=require("./api/proxy.js"),n=require("./api/user.js"),i=require("./core/config/config.js"),p=require("./core/errors/openfortError.js"),u=require("./core/openfortInternal.js"),s=require("./utils/authorization.js"),a=require("./wallets/iframeManager.js"),d=require("./types/types.js");const f=e.Openfort.getEventEmitter();exports.Openfort=e.Openfort,exports.AuthApi=r.AuthApi,exports.EmbeddedWalletApi=t.EmbeddedWalletApi,exports.ProxyApi=o.ProxyApi,exports.UserApi=n.UserApi,exports.OpenfortConfiguration=i.OpenfortConfiguration,exports.SDKConfiguration=i.SDKConfiguration,exports.ShieldConfiguration=i.ShieldConfiguration,exports.OpenfortError=p.OpenfortError,Object.defineProperty(exports,"OpenfortErrorType",{enumerable:!0,get:function(){return p.OpenfortErrorType}}),exports.OpenfortInternal=u.OpenfortInternal,exports.prepareAndSignAuthorization=s.prepareAndSignAuthorization,exports.serializeSignedAuthorization=s.serializeSignedAuthorization,exports.signAuthorization=s.signAuthorization,exports.MissingProjectEntropyError=a.MissingProjectEntropyError,exports.MissingRecoveryPasswordError=a.MissingRecoveryPasswordError,exports.NotConfiguredError=a.NotConfiguredError,exports.OTPRequiredError=a.OTPRequiredError,exports.WrongRecoveryPasswordError=a.WrongRecoveryPasswordError,Object.defineProperty(exports,"AccountTypeEnum",{enumerable:!0,get:function(){return d.AccountTypeEnum}}),Object.defineProperty(exports,"AuthActionRequiredActions",{enumerable:!0,get:function(){return d.AuthActionRequiredActions}}),Object.defineProperty(exports,"AuthType",{enumerable:!0,get:function(){return d.AuthType}}),Object.defineProperty(exports,"BasicAuthProvider",{enumerable:!0,get:function(){return d.BasicAuthProvider}}),Object.defineProperty(exports,"ChainTypeEnum",{enumerable:!0,get:function(){return d.ChainTypeEnum}}),Object.defineProperty(exports,"EmbeddedState",{enumerable:!0,get:function(){return d.EmbeddedState}}),Object.defineProperty(exports,"OAuthProvider",{enumerable:!0,get:function(){return d.OAuthProvider}}),Object.defineProperty(exports,"OpenfortEvents",{enumerable:!0,get:function(){return d.OpenfortEvents}}),Object.defineProperty(exports,"RecoveryMethod",{enumerable:!0,get:function(){return d.RecoveryMethod}}),Object.defineProperty(exports,"ThirdPartyOAuthProvider",{enumerable:!0,get:function(){return d.ThirdPartyAuthProvider}}),Object.defineProperty(exports,"TokenType",{enumerable:!0,get:function(){return d.TokenType}}),exports.openfortEvents=f;
@@ -1 +1 @@
1
- "use strict";var e,o,t,E,r,A,d,p,s,T,n,_;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={})).ON_AUTH_INIT="onAuthInit",o.ON_AUTH_SUCCESS="onAuthSuccess",o.ON_AUTH_FAILURE="onAuthFailure",o.ON_LOGOUT="onLogout",o.ON_SWITCH_ACCOUNT="onSwitchAccount",o.ON_SIGNED_MESSAGE="onSignedMessage",o.ON_EMBEDDED_WALLET_CREATED="onEmbeddedWalletCreated",o.ON_EMBEDDED_WALLET_RECOVERED="onEmbeddedWalletRecovered",exports.RecoveryMethod=void 0,(t=exports.RecoveryMethod||(exports.RecoveryMethod={})).PASSWORD="password",t.AUTOMATIC="automatic",t.PASSKEY="passkey",exports.AccountType=void 0,(E=exports.AccountType||(exports.AccountType={})).UPGRADEABLE_V4="Upgradeable_v04",E.MANAGED_V4="Managed_v04",E.ERC6551_V4="ERC6551_v04",E.ERC6551_V5="ERC6551_v05",E.RECOVERABLE_V4="Recoverable_v04",E.MANAGED_V5="Managed_v05",E.UPGRADEABLE_V5="Upgradeable_v05",E.UPGRADEABLE_V6="Upgradeable_v06",E.ZKSYNC_UPGRADEABLE_V1="zksync_upgradeable_v1",E.ZKSYNC_UPGRADEABLE_V2="zksync_upgradeable_v2",exports.AuthType=void 0,(r=exports.AuthType||(exports.AuthType={})).OPENFORT="openfort",r.THIRD_PARTY="thirdParty",exports.TokenType=void 0,(A=exports.TokenType||(exports.TokenType={})).ID_TOKEN="idToken",A.CUSTOM_TOKEN="customToken",exports.ThirdPartyAuthProvider=void 0,(d=exports.ThirdPartyAuthProvider||(exports.ThirdPartyAuthProvider={})).ACCELBYTE="accelbyte",d.FIREBASE="firebase",d.BETTER_AUTH="better-auth",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,(exports.CodeChallengeMethodEnum||(exports.CodeChallengeMethodEnum={})).S256="S256",exports.AccountTypeEnum=void 0,(T=exports.AccountTypeEnum||(exports.AccountTypeEnum={})).EOA="Externally Owned Account",T.SMART_ACCOUNT="Smart Account",exports.ChainTypeEnum=void 0,(n=exports.ChainTypeEnum||(exports.ChainTypeEnum={})).EVM="EVM",n.SVM="SVM",function(e){e.ASC="asc",e.DESC="desc"}(_||(_={}));
1
+ "use strict";var e,o,t,E,r,A,p,d,T,s,i,n;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={})).ON_AUTH_INIT="onAuthInit",o.ON_AUTH_SUCCESS="onAuthSuccess",o.ON_AUTH_FAILURE="onAuthFailure",o.ON_LOGOUT="onLogout",o.ON_SWITCH_ACCOUNT="onSwitchAccount",o.ON_SIGNED_MESSAGE="onSignedMessage",o.ON_EMBEDDED_WALLET_CREATED="onEmbeddedWalletCreated",o.ON_EMBEDDED_WALLET_RECOVERED="onEmbeddedWalletRecovered",exports.RecoveryMethod=void 0,(t=exports.RecoveryMethod||(exports.RecoveryMethod={})).PASSWORD="password",t.AUTOMATIC="automatic",t.PASSKEY="passkey",exports.AccountType=void 0,(E=exports.AccountType||(exports.AccountType={})).ERC6551V1="ERC6551V1",E.UPGRADEABLE_V5="UpgradeableV5",E.UPGRADEABLE_V4="UpgradeableV4",E.UPGRADEABLE_V6="UpgradeableV6",E.ZKSYNC_UPGRADEABLE_V1="ZKSyncUpgradeableV1",E.ZKSYNC_UPGRADEABLE_V2="ZKSyncUpgradeableV2",E.SIMPLE="Simple",E.CALIBUR="Calibur",exports.AuthType=void 0,(r=exports.AuthType||(exports.AuthType={})).OPENFORT="openfort",r.THIRD_PARTY="thirdParty",exports.TokenType=void 0,(A=exports.TokenType||(exports.TokenType={})).ID_TOKEN="idToken",A.CUSTOM_TOKEN="customToken",exports.ThirdPartyAuthProvider=void 0,(p=exports.ThirdPartyAuthProvider||(exports.ThirdPartyAuthProvider={})).ACCELBYTE="accelbyte",p.FIREBASE="firebase",p.BETTER_AUTH="better-auth",p.LOOTLOCKER="lootlocker",p.PLAYFAB="playfab",p.SUPABASE="supabase",p.CUSTOM="custom",p.OIDC="oidc",exports.BasicAuthProvider=void 0,(d=exports.BasicAuthProvider||(exports.BasicAuthProvider={})).EMAIL="email",d.WALLET="wallet",exports.OAuthProvider=void 0,(T=exports.OAuthProvider||(exports.OAuthProvider={})).GOOGLE="google",T.TWITTER="twitter",T.APPLE="apple",T.FACEBOOK="facebook",T.DISCORD="discord",T.EPIC_GAMES="epic_games",T.LINE="line",exports.AuthActionRequiredActions=void 0,(exports.AuthActionRequiredActions||(exports.AuthActionRequiredActions={})).ACTION_VERIFY_EMAIL="verify_email",exports.CodeChallengeMethodEnum=void 0,(exports.CodeChallengeMethodEnum||(exports.CodeChallengeMethodEnum={})).S256="S256",exports.AccountTypeEnum=void 0,(s=exports.AccountTypeEnum||(exports.AccountTypeEnum={})).EOA="Externally Owned Account",s.SMART_ACCOUNT="Smart Account",s.DELEGATED_ACCOUNT="Delegated Account",exports.ChainTypeEnum=void 0,(i=exports.ChainTypeEnum||(exports.ChainTypeEnum={})).EVM="EVM",i.SVM="SVM",function(e){e.ASC="asc",e.DESC="desc"}(n||(n={}));
@@ -0,0 +1 @@
1
+ "use strict";var t=require("@ethersproject/keccak256");function r(r){const{address:e,chainId:n,nonce:i}=r,o=function(t,r,e){const n=(t,r)=>{if(t<56)return(r+t).toString(16).padStart(2,"0");const e=t.toString(16),n=Math.ceil(e.length/2);return(r+55+n).toString(16).padStart(2,"0")+e.padStart(2*n,"0")},i=[t,r,e].map(t=>{if("number"==typeof t){if(0===t)return"80";t=`0x${t.toString(16)}`}let r=t.startsWith("0x")?t.slice(2):t;return r.length%2!=0&&(r=`0${r}`),0===r.length?"80":2===r.length&&parseInt(r,16)<128?r:n(r.length/2,128)+r}).join(""),o=i.length/2;return`0x${n(o,192)}${i}`}(n,e,i),s=`0x05${o.slice(2)}`;return t.keccak256(s)}async function e(t){const{authorization:e,signer:n}=t,i=r(e),o=await n.sign(i,!1,!1),s=o.startsWith("0x")?o.slice(2):o,a=`0x${s.slice(0,64)}`,c=`0x${s.slice(64,128)}`,d=s.slice(128,130),u=parseInt(d,16);let h;h=27===u||0===u||"1b"===d?0:28===u||1===u||"1c"===d?1:u>=35?u%2==0?1:0:u%2;const g=0===h?27:28;return{...e,r:a,s:c,v:g,yParity:h}}exports.prepareAndSignAuthorization=async function(t){const{signer:r,contractAddress:n,chainId:i,nonce:o}=t;if(!n)throw new Error("contractAddress is required");if(void 0===i)throw new Error("chainId is required. Please provide it or fetch it from your RPC provider using eth_chainId");if(void 0===o)throw new Error("nonce is required. Please provide it or fetch it from your RPC provider using eth_getTransactionCount");return e({authorization:{address:n,chainId:i,nonce:o},signer:r})},exports.serializeSignedAuthorization=function(t){const{r:r,s:e,yParity:n}=t,i=r.startsWith("0x")?r.slice(2):r,o=e.startsWith("0x")?e.slice(2):e;return`0x${i.padStart(64,"0")}${o.padStart(64,"0")}${n.toString(16).padStart(2,"0")}`},exports.signAuthorization=e;
@@ -1 +1 @@
1
- "use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.10.34";
1
+ "use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.10.36";
@@ -1 +1 @@
1
- "use strict";var e=require("../core/configuration/authentication.js"),t=require("../core/configuration/passkey.js"),r=require("../core/errors/openfortError.js"),a=require("../types/types.js"),o=require("../core/config/config.js"),n=require("../core/configuration/account.js"),s=require("../storage/istorage.js");require("eventemitter3"),require("./evm/JsonRpcError.js"),require("./evm/types.js"),require("./evm/provider/eip6963.js"),require("../core/errors/sentry.js"),require("./messaging/browserMessenger/backwardCompatibility.js"),require("./types.js"),require("jose");exports.EmbeddedSigner=class{iframeManager;storage;backendApiClients;passkeyHandler;eventEmitter;constructor(e,t,r,a,o){this.iframeManager=e,this.storage=t,this.backendApiClients=r,this.passkeyHandler=a,this.eventEmitter=o}async createPasskey(e){const r=await this.passkeyHandler.createPasskey({id:t.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:e});return{id:r.id,key:r.key}}async configure(t){const s=await e.Authentication.fromStorage(this.storage);if(!s)throw new r.OpenfortError("No access token found",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const i=o.SDKConfiguration.getInstance();if(!i)throw new r.OpenfortError("Configuration not found",r.OpenfortErrorType.INVALID_CONFIGURATION);const c=await n.Account.fromStorage(this.storage);let d;if(c){const e={account:c.id,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},..."passkey"===c.recoveryMethod&&{passkey:{id:c.recoveryMethodDetails?.passkeyId,env:c.recoveryMethodDetails?.passkeyEnv,key:await t.getPasskeyKeyFn(c.recoveryMethodDetails?.passkeyId)}}}}},r=await this.iframeManager.recover(e);d=r.account}else{const e=await this.backendApiClients.accountsApi.getAccountsV2({user:s.player,accountType:t.accountType,chainType:t.chainType},{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}});if(0===e.data.data.length){const e=t.entropy?.passkey?await this.createPasskey(s.player):void 0,r={accountType:t.accountType,chainType:t.chainType,chainId:t.chainId,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},...t.entropy.passkey&&{passkey:e}}}},a=await this.iframeManager.create(r);d=a.account}else{const r=e.data.data,a=r.find(e=>e.chainId===t.chainId),o=a||r[0],n={account:o.id,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},..."passkey"===o.recoveryMethod&&{passkey:{id:o.recoveryMethodDetails?.passkeyId,env:o.recoveryMethodDetails?.passkeyEnv,key:await t.getPasskeyKeyFn(o.recoveryMethodDetails?.passkeyId)}}}}},s=await this.iframeManager.recover(n);if(d=s.account,!a){const e=await this.iframeManager.switchChain(t.chainId);d=e.account}}}return r.withOpenfortError(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:d},{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}}),t=new n.Account({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:n.Account.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_SWITCH_ACCOUNT,e.data.address),t},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async sign(e,t,r,o){const n=await this.iframeManager.sign(e,t,r,o);return this.eventEmitter.emit(a.OpenfortEvents.ON_SIGNED_MESSAGE,{message:e,signature:n}),n}async export(){return await this.iframeManager.export()}async switchChain({chainId:e}){const t=await n.Account.fromStorage(this.storage);if(t?.accountType===a.AccountTypeEnum.EOA)new n.Account({...t,chainId:e}).save(this.storage);else{const r=await this.iframeManager.switchChain(e);new n.Account({...t,id:r.account,chainId:e}).save(this.storage)}}async create(t){const s=await this.iframeManager.create(t),i=await e.Authentication.fromStorage(this.storage);if(!i)throw new r.OpenfortError("No access token found",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const c=o.SDKConfiguration.getInstance();if(!c)throw new r.OpenfortError("Configuration not found",r.OpenfortErrorType.INVALID_CONFIGURATION);return r.withOpenfortError(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:s.account},{headers:{authorization:`Bearer ${c.baseConfiguration.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}}),t=new n.Account({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:n.Account.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_SWITCH_ACCOUNT,e.data.address),t},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async recover(t){const s=await this.iframeManager.recover(t),i=await e.Authentication.fromStorage(this.storage);if(!i)throw new r.OpenfortError("No access token found",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const c=o.SDKConfiguration.getInstance();if(!c)throw new r.OpenfortError("Configuration not found",r.OpenfortErrorType.INVALID_CONFIGURATION);return r.withOpenfortError(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:s.account},{headers:{authorization:`Bearer ${c.baseConfiguration.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}}),t=new n.Account({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:n.Account.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_SWITCH_ACCOUNT,e.data.address),t},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async setRecoveryMethod({recoveryMethod:e,recoveryPassword:t,encryptionSession:r,passkeyInfo:a}){await this.iframeManager.setRecoveryMethod(e,t,r,a?.passkeyKey,a?.passkeyId)}async disconnect(){await this.iframeManager.disconnect(),this.storage.remove(s.StorageKeys.ACCOUNT)}};
1
+ "use strict";var e=require("../core/configuration/authentication.js"),t=require("../core/configuration/passkey.js"),r=require("../core/errors/openfortError.js"),a=require("../types/types.js"),o=require("../core/config/config.js"),n=require("../core/configuration/account.js"),s=require("../storage/istorage.js");require("eventemitter3"),require("./evm/JsonRpcError.js"),require("@ethersproject/keccak256"),require("./evm/types.js"),require("./evm/provider/eip6963.js"),require("../core/errors/sentry.js"),require("./messaging/browserMessenger/backwardCompatibility.js"),require("./types.js"),require("jose");exports.EmbeddedSigner=class{iframeManager;storage;backendApiClients;passkeyHandler;eventEmitter;constructor(e,t,r,a,o){this.iframeManager=e,this.storage=t,this.backendApiClients=r,this.passkeyHandler=a,this.eventEmitter=o}async createPasskey(e){const r=await this.passkeyHandler.createPasskey({id:t.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:e});return{id:r.id,key:r.key}}async configure(t){const s=await e.Authentication.fromStorage(this.storage);if(!s)throw new r.OpenfortError("No access token found",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const i=o.SDKConfiguration.getInstance();if(!i)throw new r.OpenfortError("Configuration not found",r.OpenfortErrorType.INVALID_CONFIGURATION);const c=await n.Account.fromStorage(this.storage);let d;if(c){const e={account:c.id,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},..."passkey"===c.recoveryMethod&&{passkey:{id:c.recoveryMethodDetails?.passkeyId,env:c.recoveryMethodDetails?.passkeyEnv,key:await t.getPasskeyKeyFn(c.recoveryMethodDetails?.passkeyId)}}}}},r=await this.iframeManager.recover(e);d=r.account}else{const e=await this.backendApiClients.accountsApi.getAccountsV2({user:s.player,accountType:t.accountType,chainType:t.chainType},{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}});if(0===e.data.data.length){const e=t.entropy?.passkey?await this.createPasskey(s.player):void 0,r={accountType:t.accountType,chainType:t.chainType,chainId:t.chainId,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},...t.entropy.passkey&&{passkey:e}}}},a=await this.iframeManager.create(r);d=a.account}else{const r=e.data.data,a=r.find(e=>e.chainId===t.chainId),o=a||r[0],n={account:o.id,...t.entropy&&{entropy:{...t.entropy.recoveryPassword&&{recoveryPassword:t.entropy.recoveryPassword},...t.entropy.encryptionSession&&{encryptionSession:t.entropy.encryptionSession},..."passkey"===o.recoveryMethod&&{passkey:{id:o.recoveryMethodDetails?.passkeyId,env:o.recoveryMethodDetails?.passkeyEnv,key:await t.getPasskeyKeyFn(o.recoveryMethodDetails?.passkeyId)}}}}},s=await this.iframeManager.recover(n);if(d=s.account,!a){const e=await this.iframeManager.switchChain(t.chainId);d=e.account}}}return r.withOpenfortError(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:d},{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}}),t=new n.Account({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationAddress:e.data.smartAccount?.implementationAddress,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:n.Account.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_SWITCH_ACCOUNT,e.data.address),t},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async sign(e,t,r,o){const n=await this.iframeManager.sign(e,t,r,o);return this.eventEmitter.emit(a.OpenfortEvents.ON_SIGNED_MESSAGE,{message:e,signature:n}),n}async export(){return await this.iframeManager.export()}async switchChain({chainId:e}){const t=await n.Account.fromStorage(this.storage);if(t?.accountType===a.AccountTypeEnum.EOA)new n.Account({...t,chainId:e}).save(this.storage);else{const r=await this.iframeManager.switchChain(e);new n.Account({...t,id:r.account,chainId:e}).save(this.storage)}}async create(t){const s=await this.iframeManager.create(t),i=await e.Authentication.fromStorage(this.storage);if(!i)throw new r.OpenfortError("No access token found",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const c=o.SDKConfiguration.getInstance();if(!c)throw new r.OpenfortError("Configuration not found",r.OpenfortErrorType.INVALID_CONFIGURATION);return r.withOpenfortError(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:s.account},{headers:{authorization:`Bearer ${c.baseConfiguration.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}}),t=new n.Account({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,implementationAddress:e.data.smartAccount?.implementationAddress,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:n.Account.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_SWITCH_ACCOUNT,e.data.address),t},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async recover(t){const s=await this.iframeManager.recover(t),i=await e.Authentication.fromStorage(this.storage);if(!i)throw new r.OpenfortError("No access token found",r.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const c=o.SDKConfiguration.getInstance();if(!c)throw new r.OpenfortError("Configuration not found",r.OpenfortErrorType.INVALID_CONFIGURATION);return r.withOpenfortError(async()=>{const e=await this.backendApiClients.accountsApi.getAccountV2({id:s.account},{headers:{authorization:`Bearer ${c.baseConfiguration.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}}),t=new n.Account({user:e.data.user,chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationAddress:e.data.smartAccount?.implementationAddress,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:n.Account.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_SWITCH_ACCOUNT,e.data.address),t},{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})}async setRecoveryMethod({recoveryMethod:e,recoveryPassword:t,encryptionSession:r,passkeyInfo:a}){await this.iframeManager.setRecoveryMethod(e,t,r,a?.passkeyKey,a?.passkeyId)}async disconnect(){await this.iframeManager.disconnect(),this.storage.remove(s.StorageKeys.ACCOUNT)}};
@@ -1 +1 @@
1
- "use strict";var t=require("../../core/configuration/account.js"),e=require("../../core/configuration/authentication.js"),r=require("../../types/types.js"),a=require("../../utils/chains/index.js"),s=require("../../utils/crypto.js"),i=require("../../utils/typedEventEmitter.js"),o=require("./addEthereumChain.js"),n=require("./estimateGas.js"),c=require("./getAssets.js"),h=require("./getCallsStatus.js"),d=require("./JsonRpcError.js"),u=require("./personalSign.js"),p=require("./registerSession.js"),l=require("./revokeSession.js"),w=require("./sendCallSync.js"),g=require("./sendCalls.js"),m=require("./signTypedDataV4.js"),E=require("./types.js"),A=require("./walletHelpers.js");exports.EvmProvider=class{#t;#e;#r;#a;updatePolicy(t){this.#e=t}#s;#i;#o=null;#n;isOpenfort=!0;#c;constructor({storage:t,backendApiClients:e,openfortEventEmitter:a,policyId:s,ensureSigner:o,chains:n,validateAndRefreshSession:c}){this.#c=o,this.#t=t,this.#r=n,this.#e=s,this.#s=c,this.#n=e,this.#i=new i,a.on(r.OpenfortEvents.ON_LOGOUT,this.#h),a.on(r.OpenfortEvents.ON_SWITCH_ACCOUNT,this.#d)}#u=async()=>(this.#a||(this.#a=await this.#c()),this.#a);#h=async()=>{this.#a=void 0,this.#i.emit(E.ProviderEvent.ACCOUNTS_CHANGED,[])};#d=async t=>{this.#i.emit(E.ProviderEvent.ACCOUNTS_CHANGED,[t])};async getRpcProvider(){if(!this.#o){const e=await t.Account.fromStorage(this.#t),r=e?.chainId||8453;await import("@ethersproject/providers").then(t=>{const e=this.#r?this.#r[r]:void 0;this.#o=new t.StaticJsonRpcProvider(e??a.defaultChainRpcs[r])})}if(!this.#o)throw new Error("RPC provider not initialized");return this.#o}async#p(i){switch(i.method){case"eth_accounts":{const e=await t.Account.fromStorage(this.#t);return e?[e.address]:[]}case"eth_requestAccounts":{const e=await t.Account.fromStorage(this.#t);if(e)return this.#i.emit(E.ProviderEvent.ACCOUNTS_CONNECT,{chainId:String(e.chainId)}),[e.address];throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - must be authenticated and configured with a signer.")}case"eth_signTransaction":{const r=await t.Account.fromStorage(this.#t),a=await this.#u(),s=await e.Authentication.fromStorage(this.#t);if(!r||!s)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const o=await this.getRpcProvider(),{chainId:n}=await o.detectNetwork(),[c]=i.params||[];c.chainId||(c.chainId=n.toString());const h=A.parseTransactionRequest(c),{serialize:u}=await import("@ethersproject/transactions"),p=t=>({legacy:0,eip2930:1,eip1559:2}[t]),{gas:l,...w}=h,g={...w,gasLimit:l,to:h.to??void 0,type:p(h.type)},m=u(g),{keccak256:E}=await import("@ethersproject/keccak256"),R=E(m);await this.#s();const f=await a.sign(R,!1,!1),{splitSignature:S}=await import("@ethersproject/bytes");return u(g,S(f))}case"eth_sendTransaction":{const a=await t.Account.fromStorage(this.#t),s=await this.#u(),o=await e.Authentication.fromStorage(this.#t);if(!a||!o)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");if(await this.#s(),a?.accountType===r.AccountTypeEnum.EOA){const[t]=i.params||[],e=await this.getRpcProvider(),r=await A.prepareEOATransaction(t,e,a.address),s=await this.#p({method:"eth_signTransaction",params:[r]});return this.#p({method:"eth_sendRawTransaction",params:[s]})}return(await w.sendCallsSync({params:i.params||[],signer:s,account:a,authentication:o,backendClient:this.#n,policyId:this.#e})).receipt.transactionHash}case"eth_sendRawTransactionSync":{const a=await t.Account.fromStorage(this.#t),s=await this.#u(),o=await e.Authentication.fromStorage(this.#t);if(!a||!o)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");if(a?.accountType===r.AccountTypeEnum.EOA)throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);return await this.#s(),await w.sendCallsSync({params:i.params||[],signer:s,account:a,authentication:o,backendClient:this.#n,policyId:this.#e})}case"eth_estimateGas":{const r=await t.Account.fromStorage(this.#t),a=await e.Authentication.fromStorage(this.#t);if(!r||!a)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await n.estimateGas({params:i.params||[],account:r,authentication:a,backendClient:this.#n,policyId:this.#e})}case"eth_signTypedData":case"eth_signTypedData_v4":{const e=await t.Account.fromStorage(this.#t),r=await this.#u();if(!e)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#s();const a=await this.getRpcProvider();return await m.signTypedDataV4({method:i.method,params:i.params||[],signer:r,implementationType:e.implementationType||e.type,rpcProvider:a,account:e})}case"personal_sign":{const e=await t.Account.fromStorage(this.#t);if(!e)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const r=await this.#u();return await this.#s(),await u.personalSign({params:i.params||[],signer:r,account:e})}case"eth_chainId":{const t=await this.getRpcProvider(),{chainId:e}=await t.detectNetwork();return s.numberToHex(e)}case"wallet_switchEthereumChain":{const t=await this.#u();if(!i.params||!Array.isArray(i.params)||0===i.params.length)throw new d.JsonRpcError(d.RpcErrorCode.INVALID_PARAMS,"Invalid parameters for wallet_switchEthereumChain");await this.#s();try{const e=parseInt(i.params[0].chainId,16);await t.switchChain({chainId:e}),await import("@ethersproject/providers").then(t=>{const r=this.#r?this.#r[e]:void 0;this.#o=new t.StaticJsonRpcProvider(r??a.defaultChainRpcs[e])})}catch(t){const e=t;throw new d.JsonRpcError(d.RpcErrorCode.INTERNAL_ERROR,`Failed to switch chain: ${e.message}`)}return null}case"wallet_addEthereumChain":{await this.#u();const t=await this.getRpcProvider();return await o.addEthereumChain({params:i.params||[],rpcProvider:t,storage:this.#t})}case"wallet_showCallsStatus":return null;case"wallet_getCallsStatus":{const a=await t.Account.fromStorage(this.#t);if(a?.accountType===r.AccountTypeEnum.EOA)throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);const s=await e.Authentication.fromStorage(this.#t);if(!a||!s)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await h.getCallStatus({params:i.params||{},authentication:s,backendClient:this.#n})}case"wallet_sendCalls":{const a=await t.Account.fromStorage(this.#t);if(a?.accountType===r.AccountTypeEnum.EOA)throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);const s=await this.#u(),o=await e.Authentication.fromStorage(this.#t);if(!a||!o)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#s();return await g.sendCalls({params:i.params?i.params[0].calls:[],signer:s,account:a,authentication:o,backendClient:this.#n,policyId:this.#e})}case"wallet_grantPermissions":{const a=await t.Account.fromStorage(this.#t);if(a?.accountType===r.AccountTypeEnum.EOA)throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);const s=await this.#u(),o=await e.Authentication.fromStorage(this.#t);if(!a||!o)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await p.registerSession({params:i.params||[],signer:s,account:a,authentication:o,backendClient:this.#n,policyId:this.#e})}case"wallet_revokePermissions":{const r=await t.Account.fromStorage(this.#t),a=await this.#u(),s=await e.Authentication.fromStorage(this.#t);if(!r||!s)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await l.revokeSession({params:i.params||[],signer:a,account:r,authentication:s,backendClient:this.#n,policyId:this.#e})}case"wallet_getCapabilities":{const e=await t.Account.fromStorage(this.#t);if(e?.accountType===r.AccountTypeEnum.EOA)throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);const a=await this.getRpcProvider(),{chainId:o}=await a.detectNetwork();return{[s.numberToHex(o)]:{permissions:{supported:!0,signerTypes:["account","key"],keyTypes:["secp256k1"],permissionTypes:["contract-calls"]},paymasterService:{supported:!0},atomicBatch:{supported:!0}}}}case"wallet_getAssets":{const r=await t.Account.fromStorage(this.#t),a=await e.Authentication.fromStorage(this.#t);if(!r||!a)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await c.getAssets({params:i.params?.[0],account:r,authentication:a,backendClient:this.#n})}case"eth_gasPrice":case"eth_getBalance":case"eth_sendRawTransaction":case"eth_getCode":case"eth_getStorageAt":case"eth_call":case"eth_blockNumber":case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getTransactionByHash":case"eth_getTransactionReceipt":case"eth_getTransactionCount":return(await this.getRpcProvider()).send(i.method,i.params||[]);default:throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`)}}async request(t){try{return this.#p(t)}catch(t){if(t instanceof d.JsonRpcError)throw t;if(t instanceof Error)throw new d.JsonRpcError(d.RpcErrorCode.INTERNAL_ERROR,t.message);throw new d.JsonRpcError(d.RpcErrorCode.INTERNAL_ERROR,"Internal error")}}on(t,e){this.#i.on(t,e)}removeListener(t,e){this.#i.off(t,e)}};
1
+ "use strict";var e=require("../../core/configuration/account.js"),t=require("../../core/configuration/authentication.js"),r=require("../../types/types.js"),a=require("../../utils/chains/index.js"),s=require("../../utils/crypto.js"),i=require("../../utils/typedEventEmitter.js"),o=require("./addEthereumChain.js"),n=require("./estimateGas.js"),c=require("./getAssets.js"),h=require("./getCallsStatus.js"),d=require("./JsonRpcError.js"),u=require("./personalSign.js"),p=require("./registerSession.js"),l=require("./revokeSession.js"),w=require("./sendCallSync.js"),g=require("./sendCalls.js"),m=require("./signTypedDataV4.js"),E=require("./types.js"),A=require("./walletHelpers.js");exports.EvmProvider=class{#e;#t;#r;#a;updatePolicy(e){this.#t=e}#s;#i;#o=null;#n;isOpenfort=!0;#c;constructor({storage:e,backendApiClients:t,openfortEventEmitter:a,policyId:s,ensureSigner:o,chains:n,validateAndRefreshSession:c}){this.#c=o,this.#e=e,this.#r=n,this.#t=s,this.#s=c,this.#n=t,this.#i=new i,a.on(r.OpenfortEvents.ON_LOGOUT,this.#h),a.on(r.OpenfortEvents.ON_SWITCH_ACCOUNT,this.#d)}#u=async()=>(this.#a||(this.#a=await this.#c()),this.#a);#h=async()=>{this.#a=void 0,this.#i.emit(E.ProviderEvent.ACCOUNTS_CHANGED,[])};#d=async e=>{this.#i.emit(E.ProviderEvent.ACCOUNTS_CHANGED,[e])};async getRpcProvider(){if(!this.#o){const t=await e.Account.fromStorage(this.#e),r=t?.chainId||8453;await import("@ethersproject/providers").then(e=>{const t=this.#r?this.#r[r]:void 0;this.#o=new e.StaticJsonRpcProvider(t??a.defaultChainRpcs[r])})}if(!this.#o)throw new Error("RPC provider not initialized");return this.#o}async#p(i){switch(i.method){case"eth_accounts":{const t=await e.Account.fromStorage(this.#e);return t?[t.address]:[]}case"eth_requestAccounts":{const t=await e.Account.fromStorage(this.#e);if(t)return this.#i.emit(E.ProviderEvent.ACCOUNTS_CONNECT,{chainId:String(t.chainId)}),[t.address];throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - must be authenticated and configured with a signer.")}case"eth_signTransaction":{const r=await e.Account.fromStorage(this.#e),a=await this.#u(),s=await t.Authentication.fromStorage(this.#e);if(!r||!s)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const o=await this.getRpcProvider(),{chainId:n}=await o.detectNetwork(),[c]=i.params||[];c.chainId||(c.chainId=n.toString());const h=A.parseTransactionRequest(c),{serialize:u}=await import("@ethersproject/transactions"),p=e=>({legacy:0,eip2930:1,eip1559:2}[e]),{gas:l,...w}=h,g={...w,gasLimit:l,to:h.to??void 0,type:p(h.type)},m=u(g),{keccak256:E}=await import("@ethersproject/keccak256"),R=E(m);await this.#s();const f=await a.sign(R,!1,!1),{splitSignature:v}=await import("@ethersproject/bytes");return u(g,v(f))}case"eth_sendTransaction":{const[a,s,o]=await Promise.all([e.Account.fromStorage(this.#e),this.#u(),t.Authentication.fromStorage(this.#e)]);if(!a||!o)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");if(await this.#s(),a?.accountType===r.AccountTypeEnum.EOA){const[e]=i.params||[],t=await this.getRpcProvider(),r=await A.prepareEOATransaction(e,t,a.address),s=await this.#p({method:"eth_signTransaction",params:[r]});return this.#p({method:"eth_sendRawTransaction",params:[s]})}return(await w.sendCallsSync({params:i.params||[],signer:s,account:a,authentication:o,backendClient:this.#n,rpcProvider:await this.getRpcProvider(),policyId:this.#t})).receipt.transactionHash}case"eth_sendRawTransactionSync":{const[a,s,o]=await Promise.all([e.Account.fromStorage(this.#e),this.#u(),t.Authentication.fromStorage(this.#e)]);if(!a||!o)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");if(a?.accountType===r.AccountTypeEnum.EOA)throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);return await this.#s(),await w.sendCallsSync({params:i.params||[],signer:s,account:a,authentication:o,backendClient:this.#n,rpcProvider:await this.getRpcProvider(),policyId:this.#t})}case"eth_estimateGas":{const r=await e.Account.fromStorage(this.#e),a=await t.Authentication.fromStorage(this.#e);if(!r||!a)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await n.estimateGas({params:i.params||[],account:r,authentication:a,backendClient:this.#n,policyId:this.#t})}case"eth_signTypedData":case"eth_signTypedData_v4":{const t=await e.Account.fromStorage(this.#e),r=await this.#u();if(!t)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#s();const a=await this.getRpcProvider();return await m.signTypedDataV4({method:i.method,params:i.params||[],signer:r,implementationType:t.implementationType||t.type,rpcProvider:a,account:t})}case"personal_sign":{const t=await e.Account.fromStorage(this.#e);if(!t)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const r=await this.#u();return await this.#s(),await u.personalSign({params:i.params||[],signer:r,account:t})}case"eth_chainId":{const e=await this.getRpcProvider(),{chainId:t}=await e.detectNetwork();return s.numberToHex(t)}case"wallet_switchEthereumChain":{const e=await this.#u();if(!i.params||!Array.isArray(i.params)||0===i.params.length)throw new d.JsonRpcError(d.RpcErrorCode.INVALID_PARAMS,"Invalid parameters for wallet_switchEthereumChain");await this.#s();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??a.defaultChainRpcs[t])})}catch(e){const t=e;throw new d.JsonRpcError(d.RpcErrorCode.INTERNAL_ERROR,`Failed to switch chain: ${t.message}`)}return null}case"wallet_addEthereumChain":{await this.#u();const e=await this.getRpcProvider();return await o.addEthereumChain({params:i.params||[],rpcProvider:e,storage:this.#e})}case"wallet_showCallsStatus":return null;case"wallet_getCallsStatus":{const a=await e.Account.fromStorage(this.#e);if(a?.accountType===r.AccountTypeEnum.EOA)throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);const s=await t.Authentication.fromStorage(this.#e);if(!a||!s)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await h.getCallStatus({params:i.params||{},authentication:s,backendClient:this.#n})}case"wallet_sendCalls":{const[a,s,o]=await Promise.all([e.Account.fromStorage(this.#e),this.#u(),t.Authentication.fromStorage(this.#e)]);if(a?.accountType===r.AccountTypeEnum.EOA)throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);if(!a||!o)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#s();return await g.sendCalls({params:i.params?i.params[0].calls:[],signer:s,account:a,authentication:o,backendClient:this.#n,rpcProvider:await this.getRpcProvider(),policyId:this.#t})}case"wallet_grantPermissions":{const a=await e.Account.fromStorage(this.#e);if(a?.accountType===r.AccountTypeEnum.EOA)throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);const s=await this.#u(),o=await t.Authentication.fromStorage(this.#e);if(!a||!o)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await p.registerSession({params:i.params||[],signer:s,account:a,authentication:o,backendClient:this.#n,policyId:this.#t})}case"wallet_revokePermissions":{const r=await e.Account.fromStorage(this.#e),a=await this.#u(),s=await t.Authentication.fromStorage(this.#e);if(!r||!s)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await l.revokeSession({params:i.params||[],signer:a,account:r,authentication:s,backendClient:this.#n,policyId:this.#t})}case"wallet_getCapabilities":{const t=await e.Account.fromStorage(this.#e);if(t?.accountType===r.AccountTypeEnum.EOA)throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);const a=await this.getRpcProvider(),{chainId:o}=await a.detectNetwork();return{[s.numberToHex(o)]:{permissions:{supported:!0,signerTypes:["account","key"],keyTypes:["secp256k1"],permissionTypes:["contract-calls"]},paymasterService:{supported:!0},atomicBatch:{supported:!0}}}}case"wallet_getAssets":{const r=await e.Account.fromStorage(this.#e),a=await t.Authentication.fromStorage(this.#e);if(!r||!a)throw new d.JsonRpcError(d.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await c.getAssets({params:i.params?.[0],account:r,authentication:a,backendClient:this.#n})}case"eth_gasPrice":case"eth_getBalance":case"eth_sendRawTransaction":case"eth_getCode":case"eth_getStorageAt":case"eth_call":case"eth_blockNumber":case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getTransactionByHash":case"eth_getTransactionReceipt":case"eth_getTransactionCount":return(await this.getRpcProvider()).send(i.method,i.params||[]);default:throw new d.JsonRpcError(d.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`)}}async request(e){try{return this.#p(e)}catch(e){if(e instanceof d.JsonRpcError)throw e;if(e instanceof Error)throw new d.JsonRpcError(d.RpcErrorCode.INTERNAL_ERROR,e.message);throw new d.JsonRpcError(d.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 t=require("../../core/errors/openfortError.js"),e=require("./JsonRpcError.js");function r(t){return{data:(()=>{if("token-allowance"===t.type)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"token-allowance policy is not supported with this account implementation.");if("gas-limit"===t.type)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"gas-limit policy is not supported with this account implementation.");if("rate-limit"===t.type)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"rate-limit policy is not supported with this account implementation.");return t.data})(),type:t.type.custom}}function i(t){if("native-token-transfer"===t.type)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"native-token-transfer permission is not supported with this account implementation.");if("rate-limit"===t.type)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"rate-limit permission is not supported with this account implementation.");if("gas-limit"===t.type)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"gas-limit permission is not supported with this account implementation.");return{...t,policies:t?.policies?.map(r),required:t.required??!1,type:"string"==typeof t.type?t.type:t.type.custom}}function o(t){return{expiry:t.validUntil?Number(t.validUntil):0,grantedPermissions:t.whitelist?t.whitelist.map(e=>({type:"contract-call",data:{address:e,calls:[]},policies:[{data:{limit:t.limit},type:{custom:"usage-limit"}}]})):[],permissionsContext:t.id}}exports.registerSession=async({params:r,signer:n,account:s,authentication:a,backendClient:p,policyId:c})=>{const l=await(async(r,o,n,s,a)=>{const p=r[0],c=Math.floor(Date.now()/1e3),l=Math.floor(new Date(Date.now()+1e3*p.expiry).getTime()/1e3),d=p.permissions.map(i),u=d.filter(t=>"contract-call"===t.type||"erc20-token-transfer"===t.type||"erc721-token-transfer"===t.type||"erc1155-token-transfer"===t.type).map(t=>t.data.address);let y,m=d.find(t=>"call-limit"===t.type)?.data;if(m=d[0]?.policies?.find(t=>"call-limit"===t.type)?.data?.limit,"signer"in p&&p.signer){if("keys"===p.signer.type)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"Multi-key signers are not supported for session creation");"key"!==p.signer.type&&"account"!==p.signer.type||(y=p.signer.data.id)}else"account"in p&&p.account&&(y=p.account);if(!y)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,"Failed to request permissions - missing session address");const R=((t,e,r,i,o,n=!1,s,a,p,c)=>{const l={address:t,chainId:e,validAfter:r,validUntil:i,optimistic:n,whitelist:s,player:a,account:c};return o&&(l.policy=o),p&&(l.limit=p),l})(y,n.chainId,c,l,a,!1,u,s.player,m,n.id);return t.withOpenfortError(async()=>(await o.sessionsApi.createSession({createSessionRequest:R},{headers:{authorization:`Bearer ${o.config.backend.accessToken}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}})).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR})})(r,p,s,a,c).catch(t=>{throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,t.message)});if(l?.nextAction?.payload?.signableHash){let r;r=[300,531050104,324,50104,2741,11124].includes(s.chainId)?await n.sign(l.nextAction.payload.signableHash,!1,!1):await n.sign(l.nextAction.payload.signableHash);return o(await t.withOpenfortError(async()=>(await p.sessionsApi.signatureSession({id:l.id,signatureRequest:{signature:r}})).data,{default:t.OpenfortErrorType.AUTHENTICATION_ERROR}).catch(t=>{throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,t.message)}))}if(!1===l.isActive)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,"Failed to grant permissions");return o(l)};
1
+ "use strict";var e=require("../../core/errors/openfortError.js"),t=require("../../types/types.js"),r=require("./JsonRpcError.js");function i(e){return{data:(()=>{if("token-allowance"===e.type)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"token-allowance policy is not supported with this account implementation.");if("gas-limit"===e.type)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"gas-limit policy is not supported with this account implementation.");if("rate-limit"===e.type)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"rate-limit policy is not supported with this account implementation.");return e.data})(),type:e.type.custom}}function o(e){if("native-token-transfer"===e.type)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"native-token-transfer permission is not supported with this account implementation.");if("rate-limit"===e.type)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"rate-limit permission is not supported with this account implementation.");if("gas-limit"===e.type)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"gas-limit permission is not supported with this account implementation.");return{...e,policies:e?.policies?.map(i),required:e.required??!1,type:"string"==typeof e.type?e.type:e.type.custom}}function n(e){return{expiry:e.validUntil?Number(e.validUntil):0,grantedPermissions:e.whitelist?e.whitelist.map(t=>({type:"contract-call",data:{address:t,calls:[]},policies:[{data:{limit:e.limit},type:{custom:"usage-limit"}}]})):[],permissionsContext:e.id}}exports.registerSession=async({params:i,signer:s,account:a,authentication:p,backendClient:c,policyId:l})=>{const d=await(async(t,i,n,s,a)=>{const p=t[0],c=Math.floor(Date.now()/1e3),l=Math.floor(new Date(Date.now()+1e3*p.expiry).getTime()/1e3),d=p.permissions.map(o),u=d.filter(e=>"contract-call"===e.type||"erc20-token-transfer"===e.type||"erc721-token-transfer"===e.type||"erc1155-token-transfer"===e.type).map(e=>e.data.address);let y,m=d.find(e=>"call-limit"===e.type)?.data;if(m=d[0]?.policies?.find(e=>"call-limit"===e.type)?.data?.limit,"signer"in p&&p.signer){if("keys"===p.signer.type)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"Multi-key signers are not supported for session creation");"key"!==p.signer.type&&"account"!==p.signer.type||(y=p.signer.data.id)}else"account"in p&&p.account&&(y=p.account);if(!y)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"Failed to request permissions - missing session address");const R=((e,t,r,i,o,n=!1,s,a,p,c)=>{const l={address:e,chainId:t,validAfter:r,validUntil:i,optimistic:n,whitelist:s,player:a,account:c};return o&&(l.policy=o),p&&(l.limit=p),l})(y,n.chainId,c,l,a,!1,u,s.player,m,n.id);return e.withOpenfortError(async()=>(await i.sessionsApi.createSession({createSessionRequest:R},{headers:{authorization:`Bearer ${i.config.backend.accessToken}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}})).data,{default:e.OpenfortErrorType.AUTHENTICATION_ERROR})})(i,c,a,p,l).catch(e=>{throw new r.JsonRpcError(r.RpcErrorCode.TRANSACTION_REJECTED,e.message)});if(d?.nextAction?.payload?.signableHash){let i;i=[300,531050104,324,50104,2741,11124].includes(a.chainId)||a.implementationType&&[t.AccountType.CALIBUR].includes(a.implementationType)?await s.sign(d.nextAction.payload.signableHash,!1,!1):await s.sign(d.nextAction.payload.signableHash);return n(await e.withOpenfortError(async()=>(await c.sessionsApi.signatureSession({id:d.id,signatureRequest:{signature:i}})).data,{default:e.OpenfortErrorType.AUTHENTICATION_ERROR}).catch(e=>{throw new r.JsonRpcError(r.RpcErrorCode.TRANSACTION_REJECTED,e.message)}))}if(!1===d.isActive)throw new r.JsonRpcError(r.RpcErrorCode.TRANSACTION_REJECTED,"Failed to grant permissions");return n(d)};
@@ -1 +1 @@
1
- "use strict";var e=require("../../core/errors/openfortError.js"),r=require("./JsonRpcError.js");exports.revokeSession=async({params:n,signer:a,account:t,authentication:s,backendClient:o,policyId:i})=>{const c=n[0];if(!c.permissionContext)return await a.disconnect(),{};const d=await(async(r,n,a,t,s)=>{const o=((e,r,n,a,t)=>{const s={address:e,chainId:r,player:n,account:t};return a&&(s.policy=a),s})(r.permissionContext,a.chainId,t.player,s,a.id);return e.withOpenfortError(async()=>(await n.sessionsApi.revokeSession({revokeSessionRequest:o},{headers:{authorization:`Bearer ${n.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,o,t,s,i).catch(e=>{throw new r.JsonRpcError(r.RpcErrorCode.TRANSACTION_REJECTED,e.message)});if(d?.nextAction?.payload?.signableHash){let e;e=[300,531050104,324,50104,2741,11124].includes(t.chainId)?await a.sign(d.nextAction.payload.signableHash,!1,!1):await a.sign(d.nextAction.payload.signableHash);return(await o.sessionsApi.signatureSession({id:d.id,signatureRequest:{signature:e}}).catch(e=>{throw new r.JsonRpcError(r.RpcErrorCode.TRANSACTION_REJECTED,e.message)})).data}return d};
1
+ "use strict";var e=require("../../core/errors/openfortError.js"),r=require("../../types/types.js"),n=require("./JsonRpcError.js");exports.revokeSession=async({params:t,signer:s,account:a,authentication:o,backendClient:i,policyId:c})=>{const p=t[0];if(!p.permissionContext)return await s.disconnect(),{};const d=await(async(r,n,t,s,a)=>{const o=((e,r,n,t,s)=>{const a={address:e,chainId:r,player:n,account:s};return t&&(a.policy=t),a})(r.permissionContext,t.chainId,s.player,a,t.id);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})})(p,i,a,o,c).catch(e=>{throw new n.JsonRpcError(n.RpcErrorCode.TRANSACTION_REJECTED,e.message)});if(d?.nextAction?.payload?.signableHash){let e;e=[300,531050104,324,50104,2741,11124].includes(a.chainId)||a.implementationType&&[r.AccountType.CALIBUR].includes(a.implementationType)?await s.sign(d.nextAction.payload.signableHash,!1,!1):await s.sign(d.nextAction.payload.signableHash);return(await i.sessionsApi.signatureSession({id:d.id,signatureRequest:{signature:e}}).catch(e=>{throw new n.JsonRpcError(n.RpcErrorCode.TRANSACTION_REJECTED,e.message)})).data}return d};
@@ -1 +1 @@
1
- "use strict";var r=require("../../core/errors/openfortError.js"),e=require("./JsonRpcError.js");const o=r=>{const e=r?.logs?.[0];return{blockHash:e?.blockHash,blockNumber:r?.blockNumber?.toString(),contractAddress:void 0,cumulativeGasUsed:r?.gasUsed,effectiveGasPrice:r?.gasFee,from:void 0,gasUsed:r?.gasUsed,logs:r?.logs||[],logsBloom:void 0,status:1===r?.status?"success":0===r?.status?"reverted":void 0,to:r?.to,transactionHash:r?.transactionHash,transactionIndex:e?.transactionIndex,type:"eip1559",blobGasPrice:void 0,blobGasUsed:void 0,root:void 0}};exports.sendCallsSync=async({params:t,signer:a,account:s,authentication:n,backendClient:i,policyId:c})=>{const d=t[0]?.capabilities?.paymasterService?.policy??c,p=await(async(o,t,a,s,n)=>{const i=o.map(r=>{if(!r.to)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,'wallet_sendCalls requires a "to" field');return{to:String(r.to),data:r.data?String(r.data):void 0,value:r.value?String(r.value):void 0}});return r.withOpenfortError(async()=>(await t.transactionIntentsApi.createTransactionIntent({createTransactionIntentRequest:{account:a.id,policy:n,chainId:a.chainId,interactions:i}},{headers:{authorization:`Bearer ${t.config.backend.accessToken}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}})).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})})(t,i,s,n,d).catch(r=>{throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,r.message)});if(p.response?.error.reason)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,p.response?.error.reason);if(p?.nextAction?.payload?.signableHash){let t;t=[300,531050104,324,50104,2741,11124].includes(s.chainId)?await a.sign(p.nextAction.payload.signableHash,!1,!1):await a.sign(p.nextAction.payload.signableHash);const n=await r.withOpenfortError(async()=>await i.transactionIntentsApi.signature({id:p.id,signatureRequest:{signature:t}}),{default:r.OpenfortErrorType.AUTHENTICATION_ERROR}).catch(r=>{throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,r.message)});if(0===n.data.response?.status)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,n.data.response?.error.reason);if(!n.data.response)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,"No transaction response received");return{id:p.id,receipt:o(n.data.response)}}if(!p.response)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,"No transaction response received");return{id:p.id,receipt:o(p.response)}};
1
+ "use strict";var e=require("../../core/errors/openfortError.js"),r=require("../../types/types.js"),t=require("../../utils/authorization.js"),o=require("./JsonRpcError.js");const a=e=>{const r=e?.logs?.[0];return{blockHash:r?.blockHash,blockNumber:e?.blockNumber?.toString(),contractAddress:void 0,cumulativeGasUsed:e?.gasUsed,effectiveGasPrice:e?.gasFee,from:void 0,gasUsed:e?.gasUsed,logs:e?.logs||[],logsBloom:void 0,status:1===e?.status?"success":0===e?.status?"reverted":void 0,to:e?.to,transactionHash:e?.transactionHash,transactionIndex:r?.transactionIndex,type:"eip1559",blobGasPrice:void 0,blobGasUsed:void 0,root:void 0}};async function n(e,r){try{const t=await e.getCode(r);return"0x"!==t&&t.length>2}catch{return!1}}exports.sendCallsSync=async({params:s,signer:i,account:c,authentication:d,backendClient:p,rpcProvider:u,policyId:l})=>{const E=s[0]?.capabilities?.paymasterService?.policy??l;let T;if(c.accountType===r.AccountTypeEnum.DELEGATED_ACCOUNT){const[e,r]=await Promise.all([n(u,c.address),u.getTransactionCount(c.address)]);if(!e){const e=await t.prepareAndSignAuthorization({signer:i,accountAddress:c.address,contractAddress:c.implementationAddress,chainId:c.chainId,nonce:r});T=t.serializeSignedAuthorization(e)}}const A=await(async(r,t,a,n,s,i)=>{const c=r.map(e=>{if(!e.to)throw new o.JsonRpcError(o.RpcErrorCode.INVALID_PARAMS,'wallet_sendCalls requires a "to" field');return{to:String(e.to),data:e.data?String(e.data):void 0,value:e.value?String(e.value):void 0}});return e.withOpenfortError(async()=>(await t.transactionIntentsApi.createTransactionIntent({createTransactionIntentRequest:{account:a.id,policy:s,signedAuthorization:i,chainId:a.chainId,interactions:c}},{headers:{authorization:`Bearer ${t.config.backend.accessToken}`,"x-player-token":n.token,"x-auth-provider":n.thirdPartyProvider,"x-token-type":n.thirdPartyTokenType}})).data,{default:e.OpenfortErrorType.AUTHENTICATION_ERROR})})(s,p,c,d,E,T).catch(e=>{throw new o.JsonRpcError(o.RpcErrorCode.TRANSACTION_REJECTED,e.message)});if(A.response?.error.reason)throw new o.JsonRpcError(o.RpcErrorCode.TRANSACTION_REJECTED,A.response?.error.reason);if(A?.nextAction?.payload?.signableHash){let t;t=[300,531050104,324,50104,2741,11124].includes(c.chainId)||c.implementationType&&[r.AccountType.CALIBUR].includes(c.implementationType)?await i.sign(A.nextAction.payload.signableHash,!1,!1):await i.sign(A.nextAction.payload.signableHash);const n=await e.withOpenfortError(async()=>await p.transactionIntentsApi.signature({id:A.id,signatureRequest:{signature:t}}),{default:e.OpenfortErrorType.AUTHENTICATION_ERROR}).catch(e=>{throw new o.JsonRpcError(o.RpcErrorCode.TRANSACTION_REJECTED,e.message)});if(0===n.data.response?.status)throw new o.JsonRpcError(o.RpcErrorCode.TRANSACTION_REJECTED,n.data.response?.error.reason);if(!n.data.response)throw new o.JsonRpcError(o.RpcErrorCode.TRANSACTION_REJECTED,"No transaction response received");return{id:A.id,receipt:a(n.data.response)}}if(!A.response)throw new o.JsonRpcError(o.RpcErrorCode.TRANSACTION_REJECTED,"No transaction response received");return{id:A.id,receipt:a(A.response)}};
@@ -1 +1 @@
1
- "use strict";var a=require("./sendCallSync.js");exports.sendCalls=async({params:n,signer:e,account:c,authentication:i,backendClient:s,policyId:t})=>(await a.sendCallsSync({params:n,signer:e,account:c,authentication:i,backendClient:s,policyId:t})).id;
1
+ "use strict";var a=require("./sendCallSync.js");exports.sendCalls=async({params:n,signer:e,account:c,authentication:i,backendClient:r,rpcProvider:s,policyId:t})=>(await a.sendCallsSync({params:n,signer:e,account:c,authentication:i,backendClient:r,rpcProvider:s,policyId:t})).id;