@openfort/openfort-js 0.10.26 → 0.10.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/packages/internal/openapi-clients/dist/index.js +1 -1
- package/dist/cjs/sdk/src/api/embeddedWallet.js +1 -1
- package/dist/cjs/sdk/src/core/config/config.js +1 -1
- package/dist/cjs/sdk/src/core/openfort.js +1 -1
- package/dist/cjs/sdk/src/core/openfortInternal.js +1 -1
- package/dist/cjs/sdk/src/utils/promiseUtils.js +1 -0
- package/dist/cjs/sdk/src/version.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/evmProvider.js +1 -1
- package/dist/cjs/sdk/src/wallets/messaging/browserMessenger/shakeHands.js +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/packages/internal/openapi-clients/dist/index.js +1 -1
- package/dist/sdk/src/api/embeddedWallet.js +1 -1
- package/dist/sdk/src/core/config/config.js +1 -1
- package/dist/sdk/src/core/errors/sentry.js +1 -1
- package/dist/sdk/src/core/openfort.js +1 -1
- package/dist/sdk/src/core/openfortInternal.js +1 -1
- package/dist/sdk/src/utils/promiseUtils.js +1 -0
- package/dist/sdk/src/version.js +1 -1
- package/dist/sdk/src/wallets/evm/evmProvider.js +1 -1
- package/dist/sdk/src/wallets/messaging/browserMessenger/connect.js +1 -1
- package/dist/sdk/src/wallets/messaging/browserMessenger/shakeHands.js +1 -1
- package/package.json +7 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("axios"),t=require("axios-retry");const s="https://api.openfort.io".replace(/\/+$/,"");class n{basePath;axios;configuration;constructor(t,n=s,a=e){this.basePath=n,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,s){if(null==s)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const s="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+s}};function c(e,t,s=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,s)):Object.keys(t).forEach(n=>c(e,t[n],`${s}${""!==s?".":""}${n}`)):e.has(s)?e.append(s,t):e.set(s,t))}const h=function(e,...t){const s=new URLSearchParams(e.search);c(s,t),e.search=s.toString()},u=function(e,t,s){const n="string"!=typeof e;return(n&&s&&s.isJsonMime?s.isJsonMime(t.headers["Content-Type"]):n)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,s,n){return(a=t,i=s)=>{const o={...e.options,url:(n?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const n=function(e){return{cancelTransferOwnership:async(t,s,n={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",s);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},completeRecovery:async(t,s,n={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",s);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},createAccount:async(t,s={})=>{o("createAccount","createAccountRequest",t);const n=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},deployAccount:async(t,s,n={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",s);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},disableAccount:async(t,s={})=>{o("disableAccount","id",t);const n="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccount:async(t,s,n={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getAccountV2:async(t,s={})=>{o("getAccountV2","id",t);const n="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccounts:async(t,s,n,a,o,c,u,l={})=>{const p=new URL("/v1/accounts",i);let y;e&&(y=e.baseOptions);const g={method:"GET",...y,...l},w={},m={};await r(w,e),void 0!==t&&(m.limit=t),void 0!==s&&(m.skip=s),void 0!==n&&(m.order=n),void 0!==a&&(m.chainId=a),void 0!==o&&(m.player=o),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let P=y&&y.headers?y.headers:{};return g.headers={...w,...P,...l.headers},{url:d(p),options:g}},getAccountsV2:async(t,s,n,a,o,c,u,l,p={})=>{const y=new URL("/v2/accounts",i);let g;e&&(g=e.baseOptions);const w={method:"GET",...g,...p},m={},P={};await r(m,e),void 0!==t&&(P.limit=t),void 0!==s&&(P.skip=s),void 0!==n&&(P.order=n),void 0!==a&&(P.chainId=a),void 0!==o&&(P.user=o),void 0!==c&&(P.chainType=c),void 0!==u&&(P.accountType=u),void 0!==l&&(P.address=l),h(y,P);let R=g&&g.headers?g.headers:{};return w.headers={...m,...R,...p.headers},{url:d(y),options:w}},getSignerIdByAddress:async(t,s={})=>{o("getSignerIdByAddress","address",t);const n=new URL("/v2/accounts/signer",i);let a;e&&(a=e.baseOptions);const c={method:"GET",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.address=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},requestTransferOwnership:async(t,s,n={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",s);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},signPayload:async(t,s,n={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",s);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},startRecovery:async(t,s,n={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",s);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},switchChainV2:async(t,s={})=>{o("switchChainV2","switchChainQueriesV2",t);const n=new URL("/v2/accounts/switch-chain",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},syncAccount:async(t,s={})=>{o("syncAccount","id",t);const n="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await n.cancelTransferOwnership(a,i,o);return l(r,e,s,t)},async completeRecovery(a,i,o){const r=await n.completeRecovery(a,i,o);return l(r,e,s,t)},async createAccount(a,i){const o=await n.createAccount(a,i);return l(o,e,s,t)},async deployAccount(a,i,o){const r=await n.deployAccount(a,i,o);return l(r,e,s,t)},async disableAccount(a,i){const o=await n.disableAccount(a,i);return l(o,e,s,t)},async getAccount(a,i,o){const r=await n.getAccount(a,i,o);return l(r,e,s,t)},async getAccountV2(a,i){const o=await n.getAccountV2(a,i);return l(o,e,s,t)},async getAccounts(a,i,o,r,c,h,u,d){const p=await n.getAccounts(a,i,o,r,c,h,u,d);return l(p,e,s,t)},async getAccountsV2(a,i,o,r,c,h,u,d,p){const y=await n.getAccountsV2(a,i,o,r,c,h,u,d,p);return l(y,e,s,t)},async getSignerIdByAddress(a,i){const o=await n.getSignerIdByAddress(a,i);return l(o,e,s,t)},async requestTransferOwnership(a,i,o){const r=await n.requestTransferOwnership(a,i,o);return l(r,e,s,t)},async signPayload(a,i,o){const r=await n.signPayload(a,i,o);return l(r,e,s,t)},async startRecovery(a,i,o){const r=await n.startRecovery(a,i,o);return l(r,e,s,t)},async switchChainV2(a,i){const o=await n.switchChainV2(a,i);return l(o,e,s,t)},async syncAccount(a,i){const o=await n.syncAccount(a,i);return l(o,e,s,t)}}};class y extends n{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.id,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.chainId,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountsV2(e={},t){return p(this.configuration).getAccountsV2(e.limit,e.skip,e.order,e.chainId,e.user,e.chainType,e.accountType,e.address,t).then(e=>e(this.axios,this.basePath))}getSignerIdByAddress(e,t){return p(this.configuration).getSignerIdByAddress(e.address,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}switchChainV2(e,t){return p(this.configuration).switchChainV2(e.switchChainQueriesV2,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const n=function(e){return{authenticateSIWE:async(t,s={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getJwks:async(t,s={})=>{o("getJwks","publishableKey",t);const n="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(n,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...s};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...s.headers},{url:d(a),options:c}},initOAuth:async(t,s,n={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,s,n={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,s,n={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,s,n={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,s={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},linkThirdParty:async(t,s,n={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,s,n={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,s,n={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,s={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const n=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},logout:async(t,s={})=>{o("logout","logoutRequest",t);const n=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},me:async(t={})=>{const s=new URL("/iam/v1/me",i);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let o=n&&n.headers?n.headers:{};return a.headers={...o,...t.headers},{url:d(s),options:a}},poolOAuth:async(t,s={})=>{o("poolOAuth","key",t);const n=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},refresh:async(t,s={})=>{o("refresh","refreshTokenRequest",t);const n=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},registerGuest:async(t,s={})=>{const n=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...s},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(n,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...s.headers},{url:d(n),options:o}},requestEmailVerification:async(t,s={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const n=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},requestResetPassword:async(t,s={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const n=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},resetPassword:async(t,s={})=>{o("resetPassword","resetPasswordRequest",t);const n=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},signupEmailPassword:async(t,s,n={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,s,n={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,s={})=>{o("unlinkEmail","unlinkEmailRequest",t);const n=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkOAuth:async(t,s={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const n=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkSIWE:async(t,s={})=>{o("unlinkSIWE","sIWERequest",t);const n=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},verifyEmail:async(t,s={})=>{o("verifyEmail","verifyEmailRequest",t);const n=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},verifyOAuthToken:async(t,s={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const n=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await n.authenticateSIWE(a,i);return l(o,e,s,t)},async getJwks(a,i){const o=await n.getJwks(a,i);return l(o,e,s,t)},async initOAuth(a,i,o){const r=await n.initOAuth(a,i,o);return l(r,e,s,t)},async initSIWE(a,i,o){const r=await n.initSIWE(a,i,o);return l(r,e,s,t)},async linkEmail(a,i,o){const r=await n.linkEmail(a,i,o);return l(r,e,s,t)},async linkOAuth(a,i,o){const r=await n.linkOAuth(a,i,o);return l(r,e,s,t)},async linkSIWE(a,i){const o=await n.linkSIWE(a,i);return l(o,e,s,t)},async linkThirdParty(a,i,o){const r=await n.linkThirdParty(a,i,o);return l(r,e,s,t)},async loginEmailPassword(a,i,o){const r=await n.loginEmailPassword(a,i,o);return l(r,e,s,t)},async loginOIDC(a,i,o){const r=await n.loginOIDC(a,i,o);return l(r,e,s,t)},async loginWithIdToken(a,i){const o=await n.loginWithIdToken(a,i);return l(o,e,s,t)},async logout(a,i){const o=await n.logout(a,i);return l(o,e,s,t)},async me(a){const i=await n.me(a);return l(i,e,s,t)},async poolOAuth(a,i){const o=await n.poolOAuth(a,i);return l(o,e,s,t)},async refresh(a,i){const o=await n.refresh(a,i);return l(o,e,s,t)},async registerGuest(a,i){const o=await n.registerGuest(a,i);return l(o,e,s,t)},async requestEmailVerification(a,i){const o=await n.requestEmailVerification(a,i);return l(o,e,s,t)},async requestResetPassword(a,i){const o=await n.requestResetPassword(a,i);return l(o,e,s,t)},async resetPassword(a,i){const o=await n.resetPassword(a,i);return l(o,e,s,t)},async signupEmailPassword(a,i,o){const r=await n.signupEmailPassword(a,i,o);return l(r,e,s,t)},async thirdParty(a,i,o){const r=await n.thirdParty(a,i,o);return l(r,e,s,t)},async unlinkEmail(a,i){const o=await n.unlinkEmail(a,i);return l(o,e,s,t)},async unlinkOAuth(a,i){const o=await n.unlinkOAuth(a,i);return l(o,e,s,t)},async unlinkSIWE(a,i){const o=await n.unlinkSIWE(a,i);return l(o,e,s,t)},async verifyEmail(a,i){const o=await n.verifyEmail(a,i);return l(o,e,s,t)},async verifyOAuthToken(a,i){const o=await n.verifyOAuthToken(a,i);return l(o,e,s,t)}}};class w extends n{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const n=function(e){return{createSession:async(t,s,n={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,s,n,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==s&&(w.limit=s),void 0!==n&&(w.skip=n),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,s,n={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},revokeSession:async(t,s,n={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,s,n={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",s);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await n.createSession(a,i,o);return l(r,e,s,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await n.getPlayerSessions(a,i,o,r,c,h);return l(u,e,s,t)},async getSession(a,i,o){const r=await n.getSession(a,i,o);return l(r,e,s,t)},async revokeSession(a,i,o){const r=await n.revokeSession(a,i,o);return l(r,e,s,t)},async signatureSession(a,i,o){const r=await n.signatureSession(a,i,o);return l(r,e,s,t)}}};class P extends n{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const n=function(e){return{createTransactionIntent:async(t,s,n={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,s={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const n=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getTransactionIntent:async(t,s,n={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getTransactionIntents:async(t,s,n,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==s&&(R.skip=s),void 0!==n&&(R.order=n),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,s,n={})=>{o("signature","id",t),o("signature","signatureRequest",s);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await n.createTransactionIntent(a,i,o);return l(r,e,s,t)},async estimateTransactionIntentCost(a,i){const o=await n.estimateTransactionIntentCost(a,i);return l(o,e,s,t)},async getTransactionIntent(a,i,o){const r=await n.getTransactionIntent(a,i,o);return l(r,e,s,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await n.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,s,t)},async signature(a,i,o){const r=await n.signature(a,i,o);return l(r,e,s,t)}}};class T extends n{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};exports.BackendApiClients=class{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(s){const n=e.create();t(n,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:s.basePath,accessToken:s.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,n),this.accountsApi=new y(this.config.backend,void 0,n),this.sessionsApi=new P(this.config.backend,void 0,n),this.authenticationApi=new w(this.config.backend,void 0,n)}},exports.createConfig=f;
|
|
1
|
+
"use strict";var e=require("axios"),t=require("axios-retry");const n="https://api.openfort.io".replace(/\/+$/,"");class s{basePath;axios;configuration;constructor(t,s=n,a=e){this.basePath=s,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,n){if(null==n)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const n="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+n}};function c(e,t,n=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,n)):Object.keys(t).forEach(s=>c(e,t[s],`${n}${""!==n?".":""}${s}`)):e.has(n)?e.append(n,t):e.set(n,t))}const h=function(e,...t){const n=new URLSearchParams(e.search);c(n,t),e.search=n.toString()},u=function(e,t,n){const s="string"!=typeof e;return(s&&n&&n.isJsonMime?n.isJsonMime(t.headers["Content-Type"]):s)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,n,s){return(a=t,i=n)=>{const o={...e.options,url:(s?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const s=function(e){return{cancelTransferOwnership:async(t,n,s={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",n);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},completeRecovery:async(t,n,s={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",n);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},createAccount:async(t,n={})=>{o("createAccount","createAccountRequest",t);const s=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},deployAccount:async(t,n,s={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",n);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},disableAccount:async(t,n={})=>{o("disableAccount","id",t);const s="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccount:async(t,n,s={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getAccountV2:async(t,n={})=>{o("getAccountV2","id",t);const s="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccounts:async(t,n,s,a,o,c,u,l={})=>{const p=new URL("/v1/accounts",i);let y;e&&(y=e.baseOptions);const g={method:"GET",...y,...l},w={},m={};await r(w,e),void 0!==t&&(m.limit=t),void 0!==n&&(m.skip=n),void 0!==s&&(m.order=s),void 0!==a&&(m.chainId=a),void 0!==o&&(m.player=o),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let P=y&&y.headers?y.headers:{};return g.headers={...w,...P,...l.headers},{url:d(p),options:g}},getAccountsV2:async(t,n,s,a,o,c,u,l,p={})=>{const y=new URL("/v2/accounts",i);let g;e&&(g=e.baseOptions);const w={method:"GET",...g,...p},m={},P={};await r(m,e),void 0!==t&&(P.limit=t),void 0!==n&&(P.skip=n),void 0!==s&&(P.order=s),void 0!==a&&(P.chainId=a),void 0!==o&&(P.user=o),void 0!==c&&(P.chainType=c),void 0!==u&&(P.accountType=u),void 0!==l&&(P.address=l),h(y,P);let R=g&&g.headers?g.headers:{};return w.headers={...m,...R,...p.headers},{url:d(y),options:w}},getSignerIdByAddress:async(t,n={})=>{o("getSignerIdByAddress","address",t);const s=new URL("/v2/accounts/signer",i);let a;e&&(a=e.baseOptions);const c={method:"GET",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.address=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},requestTransferOwnership:async(t,n,s={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",n);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},signPayload:async(t,n,s={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",n);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},startRecovery:async(t,n,s={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",n);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},switchChainV2:async(t,n={})=>{o("switchChainV2","switchChainQueriesV2",t);const s=new URL("/v2/accounts/switch-chain",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},syncAccount:async(t,n={})=>{o("syncAccount","id",t);const s="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await s.cancelTransferOwnership(a,i,o);return l(r,e,n,t)},async completeRecovery(a,i,o){const r=await s.completeRecovery(a,i,o);return l(r,e,n,t)},async createAccount(a,i){const o=await s.createAccount(a,i);return l(o,e,n,t)},async deployAccount(a,i,o){const r=await s.deployAccount(a,i,o);return l(r,e,n,t)},async disableAccount(a,i){const o=await s.disableAccount(a,i);return l(o,e,n,t)},async getAccount(a,i,o){const r=await s.getAccount(a,i,o);return l(r,e,n,t)},async getAccountV2(a,i){const o=await s.getAccountV2(a,i);return l(o,e,n,t)},async getAccounts(a,i,o,r,c,h,u,d){const p=await s.getAccounts(a,i,o,r,c,h,u,d);return l(p,e,n,t)},async getAccountsV2(a,i,o,r,c,h,u,d,p){const y=await s.getAccountsV2(a,i,o,r,c,h,u,d,p);return l(y,e,n,t)},async getSignerIdByAddress(a,i){const o=await s.getSignerIdByAddress(a,i);return l(o,e,n,t)},async requestTransferOwnership(a,i,o){const r=await s.requestTransferOwnership(a,i,o);return l(r,e,n,t)},async signPayload(a,i,o){const r=await s.signPayload(a,i,o);return l(r,e,n,t)},async startRecovery(a,i,o){const r=await s.startRecovery(a,i,o);return l(r,e,n,t)},async switchChainV2(a,i){const o=await s.switchChainV2(a,i);return l(o,e,n,t)},async syncAccount(a,i){const o=await s.syncAccount(a,i);return l(o,e,n,t)}}};class y extends s{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.id,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.chainId,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountsV2(e={},t){return p(this.configuration).getAccountsV2(e.limit,e.skip,e.order,e.chainId,e.user,e.chainType,e.accountType,e.address,t).then(e=>e(this.axios,this.basePath))}getSignerIdByAddress(e,t){return p(this.configuration).getSignerIdByAddress(e.address,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}switchChainV2(e,t){return p(this.configuration).switchChainV2(e.switchChainQueriesV2,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const s=function(e){return{authenticateSIWE:async(t,n={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getJwks:async(t,n={})=>{o("getJwks","publishableKey",t);const s="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},initOAuth:async(t,n,s={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,n,s={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,n,s={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,n,s={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,n={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},linkThirdParty:async(t,n,s={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,n,s={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,n,s={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,n={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const s=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},logout:async(t,n={})=>{o("logout","logoutRequest",t);const s=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},me:async(t={})=>{const n=new URL("/iam/v1/me",i);let s;e&&(s=e.baseOptions);const a={method:"GET",...s,...t};h(n,{});let o=s&&s.headers?s.headers:{};return a.headers={...o,...t.headers},{url:d(n),options:a}},poolOAuth:async(t,n={})=>{o("poolOAuth","key",t);const s=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},refresh:async(t,n={})=>{o("refresh","refreshTokenRequest",t);const s=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},registerGuest:async(t,n={})=>{const s=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...n},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(s,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...n.headers},{url:d(s),options:o}},requestEmailVerification:async(t,n={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const s=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},requestResetPassword:async(t,n={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const s=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},resetPassword:async(t,n={})=>{o("resetPassword","resetPasswordRequest",t);const s=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},signupEmailPassword:async(t,n,s={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,n,s={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,n={})=>{o("unlinkEmail","unlinkEmailRequest",t);const s=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkOAuth:async(t,n={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const s=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkSIWE:async(t,n={})=>{o("unlinkSIWE","sIWERequest",t);const s=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},verifyEmail:async(t,n={})=>{o("verifyEmail","verifyEmailRequest",t);const s=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},verifyOAuthToken:async(t,n={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const s=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await s.authenticateSIWE(a,i);return l(o,e,n,t)},async getJwks(a,i){const o=await s.getJwks(a,i);return l(o,e,n,t)},async initOAuth(a,i,o){const r=await s.initOAuth(a,i,o);return l(r,e,n,t)},async initSIWE(a,i,o){const r=await s.initSIWE(a,i,o);return l(r,e,n,t)},async linkEmail(a,i,o){const r=await s.linkEmail(a,i,o);return l(r,e,n,t)},async linkOAuth(a,i,o){const r=await s.linkOAuth(a,i,o);return l(r,e,n,t)},async linkSIWE(a,i){const o=await s.linkSIWE(a,i);return l(o,e,n,t)},async linkThirdParty(a,i,o){const r=await s.linkThirdParty(a,i,o);return l(r,e,n,t)},async loginEmailPassword(a,i,o){const r=await s.loginEmailPassword(a,i,o);return l(r,e,n,t)},async loginOIDC(a,i,o){const r=await s.loginOIDC(a,i,o);return l(r,e,n,t)},async loginWithIdToken(a,i){const o=await s.loginWithIdToken(a,i);return l(o,e,n,t)},async logout(a,i){const o=await s.logout(a,i);return l(o,e,n,t)},async me(a){const i=await s.me(a);return l(i,e,n,t)},async poolOAuth(a,i){const o=await s.poolOAuth(a,i);return l(o,e,n,t)},async refresh(a,i){const o=await s.refresh(a,i);return l(o,e,n,t)},async registerGuest(a,i){const o=await s.registerGuest(a,i);return l(o,e,n,t)},async requestEmailVerification(a,i){const o=await s.requestEmailVerification(a,i);return l(o,e,n,t)},async requestResetPassword(a,i){const o=await s.requestResetPassword(a,i);return l(o,e,n,t)},async resetPassword(a,i){const o=await s.resetPassword(a,i);return l(o,e,n,t)},async signupEmailPassword(a,i,o){const r=await s.signupEmailPassword(a,i,o);return l(r,e,n,t)},async thirdParty(a,i,o){const r=await s.thirdParty(a,i,o);return l(r,e,n,t)},async unlinkEmail(a,i){const o=await s.unlinkEmail(a,i);return l(o,e,n,t)},async unlinkOAuth(a,i){const o=await s.unlinkOAuth(a,i);return l(o,e,n,t)},async unlinkSIWE(a,i){const o=await s.unlinkSIWE(a,i);return l(o,e,n,t)},async verifyEmail(a,i){const o=await s.verifyEmail(a,i);return l(o,e,n,t)},async verifyOAuthToken(a,i){const o=await s.verifyOAuthToken(a,i);return l(o,e,n,t)}}};class w extends s{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const s=function(e){return{createSession:async(t,n,s={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,n,s,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==n&&(w.limit=n),void 0!==s&&(w.skip=s),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,n,s={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},revokeSession:async(t,n,s={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,n,s={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",n);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await s.createSession(a,i,o);return l(r,e,n,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await s.getPlayerSessions(a,i,o,r,c,h);return l(u,e,n,t)},async getSession(a,i,o){const r=await s.getSession(a,i,o);return l(r,e,n,t)},async revokeSession(a,i,o){const r=await s.revokeSession(a,i,o);return l(r,e,n,t)},async signatureSession(a,i,o){const r=await s.signatureSession(a,i,o);return l(r,e,n,t)}}};class P extends s{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const s=function(e){return{createTransactionIntent:async(t,n,s={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,n={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const s=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getTransactionIntent:async(t,n,s={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getTransactionIntents:async(t,n,s,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==n&&(R.skip=n),void 0!==s&&(R.order=s),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,n,s={})=>{o("signature","id",t),o("signature","signatureRequest",n);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await s.createTransactionIntent(a,i,o);return l(r,e,n,t)},async estimateTransactionIntentCost(a,i){const o=await s.estimateTransactionIntentCost(a,i);return l(o,e,n,t)},async getTransactionIntent(a,i,o){const r=await s.getTransactionIntent(a,i,o);return l(r,e,n,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await s.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,n,t)},async signature(a,i,o){const r=await s.signature(a,i,o);return l(r,e,n,t)}}};class T extends s{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t,nativeAppIdentifier:n})=>{if(!e.trim())throw Error("basePath can not be empty");const s={basePath:e,accessToken:t};return n&&(s.baseOptions={headers:{"x-native-app-identifier":n}}),new O(s)};exports.BackendApiClients=class{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(n){const s=e.create();t(s,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:n.basePath,accessToken:n.accessToken,nativeAppIdentifier:n.nativeAppIdentifier};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,s),this.accountsApi=new y(this.config.backend,void 0,s),this.sessionsApi=new P(this.config.backend,void 0,s),this.authenticationApi=new w(this.config.backend,void 0,s)}},exports.createConfig=f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),r=require("../core/configuration/passkey.js"),t=require("../core/config/config.js"),a=require("../core/configuration/account.js"),n=require("../core/configuration/authentication.js"),s=require("../core/errors/openfortError.js"),o=require("../types/types.js"),i=require("../utils/debug.js"),d=require("../wallets/embedded.js"),c=require("../wallets/evm/evmProvider.js");require("../wallets/evm/types.js");var g=require("../wallets/evm/provider/eip6963.js"),h=require("../wallets/evm/walletHelpers.js"),y=require("../wallets/iframeManager.js"),p=require("../wallets/messaging/ReactNativeMessenger.js");require("../wallets/messaging/browserMessenger/backwardCompatibility.js");var u=require("../wallets/messaging/browserMessenger/messengers/WindowMessenger.js");exports.EmbeddedWalletApi=class{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;passkeyHandler;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,a,n){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=a,this.passkeyHandler=n,this.eventEmitter.on(o.OpenfortEvents.ON_LOGOUT,()=>{i.debugLog("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=t.SDKConfiguration.getInstance();if(!r)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);return new e.BackendApiClients({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey})}async getIframeManager(){if(i.debugLog("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return i.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return i.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;i.debugLog("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return i.debugLog("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,i.debugLog("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw i.debugLog("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){i.debugLog("[HANDSHAKE DEBUG] createIframeManager starting");const e=t.SDKConfiguration.getInstance();if(!e)throw i.debugLog("[HANDSHAKE DEBUG] Configuration not found"),new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);let r;if(i.debugLog("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)i.debugLog("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new p.ReactNativeMessenger(this.messagePoster),i.debugLog("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),r=this.messenger;else{i.debugLog("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const t=this.createIframe(e.iframeUrl),a=new URL(e.iframeUrl).origin;r=new u({remoteWindow:t.contentWindow,allowedOrigins:[a]}),i.debugLog("[HANDSHAKE DEBUG] Created WindowMessenger")}return i.debugLog("[HANDSHAKE DEBUG] Creating IframeManager instance"),new y.IframeManager(e,this.storage,r)}async ensureSigner(){if(this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager();return new d.EmbeddedSigner(e,this.storage,this.backendApiClients,this.passkeyHandler,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new s.OpenfortError("Document is not available. Please provide a message poster for non-browser environments.",s.OpenfortErrorType.INVALID_CONFIGURATION);const r=document.getElementById("openfort-iframe");r&&r.remove();const t=document.createElement("iframe");return t.style.display="none",t.id="openfort-iframe",t.src=e,document.body.appendChild(t),t}async getPasskeyKey(e){const r=await n.Authentication.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:r.player})}async getEntropy(e){switch(e.recoveryMethod){case o.RecoveryMethod.PASSWORD:return{recoveryPassword:e.password};case o.RecoveryMethod.AUTOMATIC:return{encryptionSession:e.encryptionSession};case o.RecoveryMethod.PASSKEY:return{passkey:e.passkeyInfo?{id:e.passkeyInfo.passkeyId,key:e.passkeyInfo.passkeyKey||await this.getPasskeyKey(e.passkeyInfo.passkeyId)}:{}};default:throw new s.OpenfortError("Invalid recovery method",s.OpenfortErrorType.INVALID_CONFIGURATION)}}async configure(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC},[t,s,i]=await Promise.all([n.Authentication.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(r)]),d={chainId:e.chainId,entropy:i,accountType:e.accountType??o.AccountTypeEnum.SMART_ACCOUNT,chainType:e.chainType??o.ChainTypeEnum.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},c=await s.configure(d);return{id:c.id,chainId:c.chainId,user:t.player,address:c.address,ownerAddress:c.ownerAddress,chainType:c.chainType,accountType:c.accountType,implementationType:c.implementationType,createdAt:c.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(c.recoveryMethod),recoveryMethodDetails:c.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC},i=await n.Authentication.fromStorage(this.storage);if(!i)throw new s.OpenfortError("missing authentication",s.OpenfortErrorType.AUTHENTICATION_ERROR);if(t.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:i?.player});t.passkeyInfo={passkeyId:e.id,passkeyKey:e.key}}const[d,c]=await Promise.all([this.ensureSigner(),this.getEntropy(t)]),g=await d.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:c}),h={id:g.id,chainId:g.chainId,user:i.player,address:g.address,ownerAddress:g.ownerAddress,chainType:g.chainType,accountType:g.accountType,implementationType:g.implementationType,createdAt:g.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(g.recoveryMethod),recoveryMethodDetails:g.recoveryMethodDetails};return this.eventEmitter.emit(o.OpenfortEvents.ON_EMBEDDED_WALLET_CREATED,h),h}async recover(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC};if(r.recoveryMethod===o.RecoveryMethod.PASSKEY){if(!r.passkeyInfo?.passkeyId)throw new s.OpenfortError("Passkey ID must be provided for passkey recovery",s.OpenfortErrorType.INVALID_CONFIGURATION);r.passkeyInfo={passkeyId:r.passkeyInfo.passkeyId}}const[t,i,d]=await Promise.all([this.ensureSigner(),this.getEntropy(r),n.Authentication.fromStorage(this.storage)]),c=await t.recover({account:e.account,entropy:i}),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(o.OpenfortEvents.ON_EMBEDDED_WALLET_RECOVERED,g),g}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:n=!0,arrayifyMessage:s=!1}=r||{},o=await a.Account.fromStorage(this.storage);return await t.sign(e,s,n,o?.chainType)}async signTypedData(e,r,t){await this.validateAndRefreshToken();const n=await this.ensureSigner(),o=await a.Account.fromStorage(this.storage);if(!o)throw new s.OpenfortError("No account found",s.OpenfortErrorType.MISSING_SIGNER_ERROR);const i={...r};delete i.EIP712Domain;const{_TypedDataEncoder:d}=await import("@ethersproject/hash"),c=d.hash(e,i,t);return await h.signMessage({hash:c,implementationType:o.implementationType||o.type,chainId:Number(o.chainId),signer:n,address:o.address,ownerAddress:o.ownerAddress,factoryAddress:o.factoryAddress,salt:o.salt})}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setRecoveryMethod(e,t){await this.validateAndRefreshToken();const i=await this.ensureSigner(),d=await n.Authentication.fromStorage(this.storage);if(!d)throw new s.OpenfortError("missing authentication",s.OpenfortErrorType.AUTHENTICATION_ERROR);let c,g,h,y;if(e.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await a.Account.fromStorage(this.storage);if(!e)throw new s.OpenfortError("missing account",s.OpenfortErrorType.INVALID_CONFIGURATION);const r=e?.recoveryMethodDetails?.passkeyId;if(!r)throw new s.OpenfortError("missing passkey id for account",s.OpenfortErrorType.INVALID_CONFIGURATION);h={passkeyId:r,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:r,seed:d.player})}}else if(t.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:d.player});h={passkeyId:e.id,passkeyKey:e.key},y={passkeyId:e.id}}if(e.recoveryMethod===o.RecoveryMethod.PASSWORD?c=e.password:t.recoveryMethod===o.RecoveryMethod.PASSWORD&&(c=t.password),e.recoveryMethod===o.RecoveryMethod.AUTOMATIC?g=e.encryptionSession:t.recoveryMethod===o.RecoveryMethod.AUTOMATIC&&(g=t.encryptionSession),!c&&!g)throw new s.OpenfortError("Password or encryption session is not provided",s.OpenfortErrorType.INVALID_CONFIGURATION);await i.setRecoveryMethod({recoveryMethod:t.recoveryMethod,recoveryPassword:c,encryptionSession:g,passkeyInfo:h});const p=await a.Account.fromStorage(this.storage);p&&new a.Account({...p,recoveryMethod:t.recoveryMethod,recoveryMethodDetails:y}).save(this.storage)}async get(){const e=await a.Account.fromStorage(this.storage);if(!e)throw new s.OpenfortError("No signer configured",s.OpenfortErrorType.MISSING_SIGNER_ERROR);const r=await n.Authentication.fromStorage(this.storage);if(!r)throw new s.OpenfortError("No access token found",s.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{id:e.id,chainId:e.chainId,user:r.player,address:e.address,ownerAddress:e.ownerAddress,chainType:e.chainType,accountType:e.accountType,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const r={accountType:o.AccountTypeEnum.SMART_ACCOUNT,...e},i=t.SDKConfiguration.getInstance();if(!i)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const d=await n.Authentication.fromStorage(this.storage);if(!d)throw new s.OpenfortError("No access token found",s.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return s.withOpenfortError(async()=>(await this.backendApiClients.accountsApi.getAccountsV2(r,{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":d.token,"x-auth-provider":d.thirdPartyProvider,"x-token-type":d.thirdPartyTokenType}})).data.data.map(e=>({user:e.user,chainType:e.chainType,id:e.id,address:e.address,ownerAddress:e.ownerAddress,accountType:e.accountType,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{default:s.OpenfortErrorType.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await n.Authentication.fromStorage(this.storage))return o.EmbeddedState.UNAUTHENTICATED;return await a.Account.fromStorage(this.storage)?o.EmbeddedState.READY:o.EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return i.debugLog("Failed to get embedded state:",e),o.EmbeddedState.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},t=await n.Authentication.fromStorage(this.storage),s=await a.Account.fromStorage(this.storage);return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new c.EvmProvider({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:s||void 0,authentication:t||void 0,backendApiClients:this.backendApiClients,policyId:r.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:r.chains}),r.announceProvider&&g.announceProvider({info:{...g.openfortProviderInfo,...r.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(r=>{setTimeout(r,e)});const r=await this.getIframeManager();if(!r.isLoaded())return!1;const t=await n.Authentication.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return i.debugLog("Ping failed:",e),!1}}getURL(){const e=t.SDKConfiguration.getInstance();if(!e)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new s.OpenfortError("Invalid message poster",s.OpenfortErrorType.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&this.messenger.destroy(),this.iframeManager&&this.iframeManager.destroy(),this.signer=null,this.signerPromise=null,this.iframeManager=null,this.iframeManagerPromise=null,this.messenger=null}async handleLogout(){const e=await this.ensureSigner();await e.disconnect(),this.provider=null,this.messenger=null,this.iframeManager=null,this.iframeManagerPromise=null,this.signer=null,this.signerPromise=null}async onMessage(e){if(!e||"object"!=typeof e)return void i.debugLog("Invalid message received:",e);i.debugLog("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const r="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(r&&this.messenger&&this.messagePoster)return i.debugLog("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const t=await this.getIframeManager();i.debugLog(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${t.isLoaded()}`),r&&!t.isLoaded()&&i.debugLog("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),i.debugLog("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await t.onMessage(e),i.debugLog("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}};
|
|
1
|
+
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),r=require("../core/configuration/passkey.js"),t=require("../core/config/config.js"),a=require("../core/configuration/account.js"),n=require("../core/configuration/authentication.js"),s=require("../core/errors/openfortError.js"),o=require("../types/types.js"),i=require("../utils/debug.js"),d=require("../wallets/embedded.js"),c=require("../wallets/evm/evmProvider.js");require("../wallets/evm/types.js");var g=require("../wallets/evm/provider/eip6963.js"),h=require("../wallets/evm/walletHelpers.js"),y=require("../wallets/iframeManager.js"),p=require("../wallets/messaging/ReactNativeMessenger.js");require("../wallets/messaging/browserMessenger/backwardCompatibility.js");var u=require("../wallets/messaging/browserMessenger/messengers/WindowMessenger.js");exports.EmbeddedWalletApi=class{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;passkeyHandler;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,a,n){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=a,this.passkeyHandler=n,this.eventEmitter.on(o.OpenfortEvents.ON_LOGOUT,()=>{i.debugLog("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=t.SDKConfiguration.getInstance();if(!r)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);return new e.BackendApiClients({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey,nativeAppIdentifier:r.nativeAppIdentifier})}async getIframeManager(){if(i.debugLog("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return i.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return i.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;i.debugLog("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return i.debugLog("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,i.debugLog("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw i.debugLog("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){i.debugLog("[HANDSHAKE DEBUG] createIframeManager starting");const e=t.SDKConfiguration.getInstance();if(!e)throw i.debugLog("[HANDSHAKE DEBUG] Configuration not found"),new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);let r;if(i.debugLog("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)i.debugLog("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new p.ReactNativeMessenger(this.messagePoster),i.debugLog("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),r=this.messenger;else{i.debugLog("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const t=this.createIframe(e.iframeUrl),a=new URL(e.iframeUrl).origin;r=new u({remoteWindow:t.contentWindow,allowedOrigins:[a]}),i.debugLog("[HANDSHAKE DEBUG] Created WindowMessenger")}return i.debugLog("[HANDSHAKE DEBUG] Creating IframeManager instance"),new y.IframeManager(e,this.storage,r)}async ensureSigner(){if(this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager();return new d.EmbeddedSigner(e,this.storage,this.backendApiClients,this.passkeyHandler,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new s.OpenfortError("Document is not available. Please provide a message poster for non-browser environments.",s.OpenfortErrorType.INVALID_CONFIGURATION);const r=document.getElementById("openfort-iframe");r&&r.remove();const t=document.createElement("iframe");return t.style.display="none",t.id="openfort-iframe",t.src=e,document.body.appendChild(t),t}async getPasskeyKey(e){const r=await n.Authentication.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:r.player})}async getEntropy(e){switch(e.recoveryMethod){case o.RecoveryMethod.PASSWORD:return{recoveryPassword:e.password};case o.RecoveryMethod.AUTOMATIC:return{encryptionSession:e.encryptionSession};case o.RecoveryMethod.PASSKEY:return{passkey:e.passkeyInfo?{id:e.passkeyInfo.passkeyId,key:e.passkeyInfo.passkeyKey||await this.getPasskeyKey(e.passkeyInfo.passkeyId)}:{}};default:throw new s.OpenfortError("Invalid recovery method",s.OpenfortErrorType.INVALID_CONFIGURATION)}}async configure(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC},[t,s,i]=await Promise.all([n.Authentication.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(r)]),d={chainId:e.chainId,entropy:i,accountType:e.accountType??o.AccountTypeEnum.SMART_ACCOUNT,chainType:e.chainType??o.ChainTypeEnum.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},c=await s.configure(d);return{id:c.id,chainId:c.chainId,user:t.player,address:c.address,ownerAddress:c.ownerAddress,chainType:c.chainType,accountType:c.accountType,implementationType:c.implementationType,createdAt:c.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(c.recoveryMethod),recoveryMethodDetails:c.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC},i=await n.Authentication.fromStorage(this.storage);if(!i)throw new s.OpenfortError("missing authentication",s.OpenfortErrorType.AUTHENTICATION_ERROR);if(t.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:i?.player});t.passkeyInfo={passkeyId:e.id,passkeyKey:e.key}}const[d,c]=await Promise.all([this.ensureSigner(),this.getEntropy(t)]),g=await d.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:c}),h={id:g.id,chainId:g.chainId,user:i.player,address:g.address,ownerAddress:g.ownerAddress,chainType:g.chainType,accountType:g.accountType,implementationType:g.implementationType,createdAt:g.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(g.recoveryMethod),recoveryMethodDetails:g.recoveryMethodDetails};return this.eventEmitter.emit(o.OpenfortEvents.ON_EMBEDDED_WALLET_CREATED,h),h}async recover(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:o.RecoveryMethod.AUTOMATIC};if(r.recoveryMethod===o.RecoveryMethod.PASSKEY){if(!r.passkeyInfo?.passkeyId)throw new s.OpenfortError("Passkey ID must be provided for passkey recovery",s.OpenfortErrorType.INVALID_CONFIGURATION);r.passkeyInfo={passkeyId:r.passkeyInfo.passkeyId}}const[t,i,d]=await Promise.all([this.ensureSigner(),this.getEntropy(r),n.Authentication.fromStorage(this.storage)]),c=await t.recover({account:e.account,entropy:i}),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(o.OpenfortEvents.ON_EMBEDDED_WALLET_RECOVERED,g),g}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:n=!0,arrayifyMessage:s=!1}=r||{},o=await a.Account.fromStorage(this.storage);return await t.sign(e,s,n,o?.chainType)}async signTypedData(e,r,t){await this.validateAndRefreshToken();const n=await this.ensureSigner(),o=await a.Account.fromStorage(this.storage);if(!o)throw new s.OpenfortError("No account found",s.OpenfortErrorType.MISSING_SIGNER_ERROR);const i={...r};delete i.EIP712Domain;const{_TypedDataEncoder:d}=await import("@ethersproject/hash"),c=d.hash(e,i,t);return await h.signMessage({hash:c,implementationType:o.implementationType||o.type,chainId:Number(o.chainId),signer:n,address:o.address,ownerAddress:o.ownerAddress,factoryAddress:o.factoryAddress,salt:o.salt})}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setRecoveryMethod(e,t){await this.validateAndRefreshToken();const i=await this.ensureSigner(),d=await n.Authentication.fromStorage(this.storage);if(!d)throw new s.OpenfortError("missing authentication",s.OpenfortErrorType.AUTHENTICATION_ERROR);let c,g,h,y;if(e.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await a.Account.fromStorage(this.storage);if(!e)throw new s.OpenfortError("missing account",s.OpenfortErrorType.INVALID_CONFIGURATION);const r=e?.recoveryMethodDetails?.passkeyId;if(!r)throw new s.OpenfortError("missing passkey id for account",s.OpenfortErrorType.INVALID_CONFIGURATION);h={passkeyId:r,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:r,seed:d.player})}}else if(t.recoveryMethod===o.RecoveryMethod.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:r.PasskeyHandler.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:d.player});h={passkeyId:e.id,passkeyKey:e.key},y={passkeyId:e.id}}if(e.recoveryMethod===o.RecoveryMethod.PASSWORD?c=e.password:t.recoveryMethod===o.RecoveryMethod.PASSWORD&&(c=t.password),e.recoveryMethod===o.RecoveryMethod.AUTOMATIC?g=e.encryptionSession:t.recoveryMethod===o.RecoveryMethod.AUTOMATIC&&(g=t.encryptionSession),!c&&!g)throw new s.OpenfortError("Password or encryption session is not provided",s.OpenfortErrorType.INVALID_CONFIGURATION);await i.setRecoveryMethod({recoveryMethod:t.recoveryMethod,recoveryPassword:c,encryptionSession:g,passkeyInfo:h});const p=await a.Account.fromStorage(this.storage);p&&new a.Account({...p,recoveryMethod:t.recoveryMethod,recoveryMethodDetails:y}).save(this.storage)}async get(){const e=await a.Account.fromStorage(this.storage);if(!e)throw new s.OpenfortError("No signer configured",s.OpenfortErrorType.MISSING_SIGNER_ERROR);const r=await n.Authentication.fromStorage(this.storage);if(!r)throw new s.OpenfortError("No access token found",s.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{id:e.id,chainId:e.chainId,user:r.player,address:e.address,ownerAddress:e.ownerAddress,chainType:e.chainType,accountType:e.accountType,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const r={accountType:o.AccountTypeEnum.SMART_ACCOUNT,...e},i=t.SDKConfiguration.getInstance();if(!i)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const d=await n.Authentication.fromStorage(this.storage);if(!d)throw new s.OpenfortError("No access token found",s.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return s.withOpenfortError(async()=>(await this.backendApiClients.accountsApi.getAccountsV2(r,{headers:{authorization:`Bearer ${i.baseConfiguration.publishableKey}`,"x-player-token":d.token,"x-auth-provider":d.thirdPartyProvider,"x-token-type":d.thirdPartyTokenType}})).data.data.map(e=>({user:e.user,chainType:e.chainType,id:e.id,address:e.address,ownerAddress:e.ownerAddress,accountType:e.accountType,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:a.Account.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{default:s.OpenfortErrorType.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await n.Authentication.fromStorage(this.storage))return o.EmbeddedState.UNAUTHENTICATED;return await a.Account.fromStorage(this.storage)?o.EmbeddedState.READY:o.EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return i.debugLog("Failed to get embedded state:",e),o.EmbeddedState.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},t=await n.Authentication.fromStorage(this.storage),s=await a.Account.fromStorage(this.storage);return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new c.EvmProvider({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:s||void 0,authentication:t||void 0,backendApiClients:this.backendApiClients,policyId:r.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:r.chains}),r.announceProvider&&g.announceProvider({info:{...g.openfortProviderInfo,...r.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(r=>{setTimeout(r,e)});const r=await this.getIframeManager();if(!r.isLoaded())return!1;const t=await n.Authentication.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return i.debugLog("Ping failed:",e),!1}}getURL(){const e=t.SDKConfiguration.getInstance();if(!e)throw new s.OpenfortError("Configuration not found",s.OpenfortErrorType.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new s.OpenfortError("Invalid message poster",s.OpenfortErrorType.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&this.messenger.destroy(),this.iframeManager&&this.iframeManager.destroy(),this.signer=null,this.signerPromise=null,this.iframeManager=null,this.iframeManagerPromise=null,this.messenger=null}async handleLogout(){const e=await this.ensureSigner();await e.disconnect(),this.provider=null,this.messenger=null,this.iframeManager=null,this.iframeManagerPromise=null,this.signer=null,this.signerPromise=null}async onMessage(e){if(!e||"object"!=typeof e)return void i.debugLog("Invalid message received:",e);i.debugLog("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const r="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(r&&this.messenger&&this.messagePoster)return i.debugLog("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const t=await this.getIframeManager();i.debugLog(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${t.isLoaded()}`),r&&!t.isLoaded()&&i.debugLog("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),i.debugLog("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await t.onMessage(e),i.debugLog("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=require("../../utils/crypto.js");class i{baseConfiguration;shieldConfiguration;thirdPartyAuth;shieldUrl;iframeUrl;backendUrl;storage;passkeyRpId;passkeyRpName;nativeAppIdentifier;static instance=null;constructor({baseConfiguration:s,shieldConfiguration:t,overrides:r,thirdPartyAuth:a}){this.shieldConfiguration=t,this.baseConfiguration=s,this.backendUrl=r?.backendUrl||"https://api.openfort.io",this.iframeUrl=r?.iframeUrl||"https://embed.openfort.io",this.iframeUrl=`${this.iframeUrl}/iframe/${this.baseConfiguration.publishableKey}`,t?.debug&&(this.iframeUrl=`${this.iframeUrl}?debug=true`),this.shieldUrl=r?.shieldUrl||"https://shield.openfort.io",this.storage=r?.storage,this.thirdPartyAuth=a,this.passkeyRpId=t?.passkeyRpId,this.passkeyRpName=t?.passkeyRpName,this.nativeAppIdentifier=s.nativeAppIdentifier,r?.crypto?.digest&&e.setCryptoDigestOverride(r.crypto.digest),i.instance=this}static getInstance(){return i.instance}}exports.OpenfortConfiguration=class{publishableKey;nativeAppIdentifier;constructor(e){this.publishableKey=e.publishableKey,this.nativeAppIdentifier=e.nativeAppIdentifier}},exports.SDKConfiguration=i,exports.ShieldConfiguration=class{shieldPublishableKey;shieldEncryptionKey;debug=!1;passkeyRpId;passkeyRpName;constructor(e){this.shieldPublishableKey=e.shieldPublishableKey,this.debug=e.shieldDebug||!1,this.passkeyRpId=e.passkeyRpId,this.passkeyRpName=e.passkeyRpName}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),t=require("../api/auth.js"),i=require("../api/embeddedWallet.js"),n=require("../api/proxy.js"),r=require("../api/user.js"),a=require("../auth/authManager.js"),s=require("../storage/istorage.js"),o=require("../storage/lazyStorage.js"),h=require("../utils/typedEventEmitter.js"),l=require("./config/config.js"),c=require("./configuration/passkey.js"),u=require("./errors/openfortError.js"),d=require("./errors/sentry.js"),p=require("./openfortInternal.js");class g{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;configuration;eventEmitter;iPasskeyHandler;static globalEventEmitter=null;get auth(){if(!this.authInstance)throw new u.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.",u.OpenfortErrorType.INVALID_CONFIGURATION);return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new u.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.",u.OpenfortErrorType.INVALID_CONFIGURATION);return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new u.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.",u.OpenfortErrorType.INVALID_CONFIGURATION);return this.userInstance}get proxy(){if(!this.proxyInstance)throw new u.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.",u.OpenfortErrorType.INVALID_CONFIGURATION);return this.proxyInstance}initializeSynchronously(){try{this.iAuthManager=new a.AuthManager(this.storage),this.openfortInternal=new p.OpenfortInternal(this.storage,this.authManager,this.eventEmitter),this.authInstance=new t.AuthApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.embeddedWalletInstance=new i.EmbeddedWalletApi(this.storage,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter,this.passkeyHandler),this.userInstance=new r.UserApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this)),this.proxyInstance=new n.ProxyApi(this.storage,this.backendApiClients,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),async()=>{if(!this.embeddedWalletInstance)throw new u.OpenfortError("Embedded wallet not initialized",u.OpenfortErrorType.MISSING_SIGNER_ERROR);const e=this.embeddedWalletInstance;return t=>e.signMessage(t,{hashMessage:!0,arrayifyMessage:!0})})}catch(e){throw new u.OpenfortError("Openfort SDK synchronous initialization failed",u.OpenfortErrorType.INVALID_CONFIGURATION)}}constructor(e){if(this.configuration=new l.SDKConfiguration(e),this.storage=new o.LazyStorage(this.configuration.storage),this.eventEmitter=new h,g.globalEventEmitter){["onAuthInit","onAuthSuccess","onAuthFailure","onLogout","onSwitchAccount","onSignedMessage","onEmbeddedWalletCreated","onEmbeddedWalletRecovered","onAuthFlowOpen","onAuthFlowClose","onAuthFlowCancel"].forEach(e=>{this.eventEmitter.on(e,(...t)=>{g.globalEventEmitter?.emit(e,...t)})})}else g.globalEventEmitter=this.eventEmitter;this.iPasskeyHandler=new c.PasskeyHandler({rpId:this.configuration.passkeyRpId,rpName:this.configuration.passkeyRpName,extractableKey:!0}),d.InternalSentry.init({configuration:this.configuration}),this.initializeSynchronously(),this.initPromise=Promise.resolve()}static getEventEmitter(){return g.globalEventEmitter||(g.globalEventEmitter=new h),g.globalEventEmitter}async waitForInitialization(){await this.initPromise,await this.ensureAsyncInitialized()}async getAccessToken(){return await this.ensureInitialized(),this.openfortInternal.getAccessToken()}async validateAndRefreshToken(e){return await this.ensureInitialized(),await this.openfortInternal.validateAndRefreshToken(e)}get backendApiClients(){return new e.BackendApiClients({basePath:this.configuration.backendUrl,accessToken:this.configuration.baseConfiguration.publishableKey})}get authManager(){if(!this.iAuthManager)throw new u.OpenfortError("AuthManager not initialized",u.OpenfortErrorType.INTERNAL_ERROR);return this.iAuthManager}get passkeyHandler(){return this.iPasskeyHandler}static async isStorageAccessible(e){try{const t=s.StorageKeys.TEST,i="openfort_storage_test";e.save(t,i);const n=await e.get(t);return e.remove(t),n===i}catch(e){return!1}}async initializeAsync(){try{if(!await g.isStorageAccessible(this.storage))throw new u.OpenfortError("Storage is not accessible",u.OpenfortErrorType.INVALID_CONFIGURATION);this.authManager.setBackendApiClients(this.backendApiClients,this.configuration.baseConfiguration.publishableKey)}catch(e){throw new u.OpenfortError("Openfort SDK async initialization failed",u.OpenfortErrorType.INTERNAL_ERROR)}}async ensureAsyncInitialized(){this.asyncInitPromise||(this.asyncInitPromise=this.initializeAsync()),await this.asyncInitPromise}async ensureInitialized(){await this.initPromise,await this.ensureAsyncInitialized()}}exports.Openfort=g;
|
|
1
|
+
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),t=require("../api/auth.js"),i=require("../api/embeddedWallet.js"),n=require("../api/proxy.js"),r=require("../api/user.js"),a=require("../auth/authManager.js"),s=require("../storage/istorage.js"),o=require("../storage/lazyStorage.js"),h=require("../utils/typedEventEmitter.js"),l=require("./config/config.js"),c=require("./configuration/passkey.js"),u=require("./errors/openfortError.js"),d=require("./errors/sentry.js"),p=require("./openfortInternal.js");class g{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;configuration;eventEmitter;iPasskeyHandler;static globalEventEmitter=null;get auth(){if(!this.authInstance)throw new u.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.",u.OpenfortErrorType.INVALID_CONFIGURATION);return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new u.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.",u.OpenfortErrorType.INVALID_CONFIGURATION);return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new u.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.",u.OpenfortErrorType.INVALID_CONFIGURATION);return this.userInstance}get proxy(){if(!this.proxyInstance)throw new u.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.",u.OpenfortErrorType.INVALID_CONFIGURATION);return this.proxyInstance}initializeSynchronously(){try{this.iAuthManager=new a.AuthManager(this.storage),this.openfortInternal=new p.OpenfortInternal(this.storage,this.authManager,this.eventEmitter),this.authInstance=new t.AuthApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.embeddedWalletInstance=new i.EmbeddedWalletApi(this.storage,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter,this.passkeyHandler),this.userInstance=new r.UserApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this)),this.proxyInstance=new n.ProxyApi(this.storage,this.backendApiClients,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),async()=>{if(!this.embeddedWalletInstance)throw new u.OpenfortError("Embedded wallet not initialized",u.OpenfortErrorType.MISSING_SIGNER_ERROR);const e=this.embeddedWalletInstance;return t=>e.signMessage(t,{hashMessage:!0,arrayifyMessage:!0})})}catch(e){throw new u.OpenfortError("Openfort SDK synchronous initialization failed",u.OpenfortErrorType.INVALID_CONFIGURATION)}}constructor(e){if(this.configuration=new l.SDKConfiguration(e),this.storage=new o.LazyStorage(this.configuration.storage),this.eventEmitter=new h,g.globalEventEmitter){["onAuthInit","onAuthSuccess","onAuthFailure","onLogout","onSwitchAccount","onSignedMessage","onEmbeddedWalletCreated","onEmbeddedWalletRecovered","onAuthFlowOpen","onAuthFlowClose","onAuthFlowCancel"].forEach(e=>{this.eventEmitter.on(e,(...t)=>{g.globalEventEmitter?.emit(e,...t)})})}else g.globalEventEmitter=this.eventEmitter;this.iPasskeyHandler=new c.PasskeyHandler({rpId:this.configuration.passkeyRpId,rpName:this.configuration.passkeyRpName,extractableKey:!0}),d.InternalSentry.init({configuration:this.configuration}),this.initializeSynchronously(),this.initPromise=Promise.resolve()}static getEventEmitter(){return g.globalEventEmitter||(g.globalEventEmitter=new h),g.globalEventEmitter}async waitForInitialization(){await this.initPromise,await this.ensureAsyncInitialized()}async getAccessToken(){return await this.ensureInitialized(),this.openfortInternal.getAccessToken()}async validateAndRefreshToken(e){return await this.ensureInitialized(),await this.openfortInternal.validateAndRefreshToken(e)}get backendApiClients(){return new e.BackendApiClients({basePath:this.configuration.backendUrl,accessToken:this.configuration.baseConfiguration.publishableKey,nativeAppIdentifier:this.configuration.nativeAppIdentifier})}get authManager(){if(!this.iAuthManager)throw new u.OpenfortError("AuthManager not initialized",u.OpenfortErrorType.INTERNAL_ERROR);return this.iAuthManager}get passkeyHandler(){return this.iPasskeyHandler}static async isStorageAccessible(e){try{const t=s.StorageKeys.TEST,i="openfort_storage_test";e.save(t,i);const n=await e.get(t);return e.remove(t),n===i}catch(e){return!1}}async initializeAsync(){try{if(!await g.isStorageAccessible(this.storage))throw new u.OpenfortError("Storage is not accessible",u.OpenfortErrorType.INVALID_CONFIGURATION);this.authManager.setBackendApiClients(this.backendApiClients,this.configuration.baseConfiguration.publishableKey)}catch(e){throw new u.OpenfortError("Openfort SDK async initialization failed",u.OpenfortErrorType.INTERNAL_ERROR)}}async ensureAsyncInitialized(){this.asyncInitPromise||(this.asyncInitPromise=this.initializeAsync()),await this.asyncInitPromise}async ensureInitialized(){await this.initPromise,await this.ensureAsyncInitialized()}}exports.Openfort=g;
|
|
@@ -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");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(o){if(n.SDKConfiguration.getInstance()?.thirdPartyAuth)return void await this.getThirdPartyAuthToken();const
|
|
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")}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e={};exports.singlePromise=(l,t)=>{let s=e[t];return s||(s=l().finally(()=>{delete e[t],s=null}),e[t]=s),s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.10.
|
|
1
|
+
"use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.10.28";
|
|
@@ -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"),
|
|
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("./getCallsStatus.js"),h=require("./JsonRpcError.js"),d=require("./personalSign.js"),u=require("./registerSession.js"),p=require("./revokeSession.js"),l=require("./sendCallSync.js"),w=require("./sendCalls.js"),g=require("./signTypedDataV4.js"),m=require("./types.js"),E=require("./walletHelpers.js");exports.EvmProvider=class{#t;#e;#r;#a;updatePolicy(t){this.#e=t}#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(m.ProviderEvent.ACCOUNTS_CHANGED,[])};#d=async t=>{this.#i.emit(m.ProviderEvent.ACCOUNTS_CHANGED,[t])};async getRpcProvider(){if(!this.#o){const e=await t.Account.fromStorage(this.#t),r=e?.chainId||8453;await import("@ethersproject/providers").then(t=>{const e=this.#r?this.#r[r]:void 0;this.#o=new t.StaticJsonRpcProvider(e??a.defaultChainRpcs[r])})}if(!this.#o)throw new Error("RPC provider not initialized");return this.#o}async#p(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(m.ProviderEvent.ACCOUNTS_CONNECT,{chainId:String(e.chainId)}),[e.address];throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - must be authenticated and configured with a signer.")}case"eth_signTransaction":{const r=await t.Account.fromStorage(this.#t),a=await this.#u(),s=await e.Authentication.fromStorage(this.#t);if(!r||!s)throw new h.JsonRpcError(h.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 d=E.parseTransactionRequest(c),{serialize:u}=await import("@ethersproject/transactions"),p=t=>({legacy:0,eip2930:1,eip1559:2}[t]),{gas:l,...w}=d,g={...w,gasLimit:l,to:d.to??void 0,type:p(d.type)},m=u(g),{keccak256:A}=await import("@ethersproject/keccak256"),R=A(m);await this.#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 h.JsonRpcError(h.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 E.prepareEOATransaction(t,e,a.address),s=await this.#p({method:"eth_signTransaction",params:[r]});return this.#p({method:"eth_sendRawTransaction",params:[s]})}return(await l.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 h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");if(a?.accountType===r.AccountTypeEnum.EOA)throw new h.JsonRpcError(h.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);return await this.#s(),await l.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 h.JsonRpcError(h.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 h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#s();const a=await this.getRpcProvider();return await g.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 h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const r=await this.#u();return await this.#s(),await d.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 h.JsonRpcError(h.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 h.JsonRpcError(h.RpcErrorCode.INTERNAL_ERROR,`Failed to switch chain: ${e.message}`)}return null}case"wallet_addEthereumChain":{await this.#u();const t=await this.getRpcProvider();return await o.addEthereumChain({params: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 h.JsonRpcError(h.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`);const s=await e.Authentication.fromStorage(this.#t);if(!a||!s)throw new h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await c.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 h.JsonRpcError(h.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 h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#s();return await w.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 h.JsonRpcError(h.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 h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await u.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 h.JsonRpcError(h.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#s(),await p.revokeSession({params:i.params||[],signer:a,account:r,authentication:s,backendClient:this.#n})}case"wallet_getCapabilities":{const e=await t.Account.fromStorage(this.#t);if(e?.accountType===r.AccountTypeEnum.EOA)throw new h.JsonRpcError(h.ProviderErrorCode.UNSUPPORTED_METHOD,`${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"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 h.JsonRpcError(h.ProviderErrorCode.UNSUPPORTED_METHOD,`${i.method}: Method not supported`)}}async request(t){try{return this.#p(t)}catch(t){if(t instanceof h.JsonRpcError)throw t;if(t instanceof Error)throw new h.JsonRpcError(h.RpcErrorCode.INTERNAL_ERROR,t.message);throw new h.JsonRpcError(h.RpcErrorCode.INTERNAL_ERROR,"Internal error")}}on(t,e){this.#i.on(t,e)}removeListener(t,e){this.#i.off(t,e)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../../utils/crypto.js"),s=require("./backwardCompatibility.js"),r=require("./connectCallHandler.js"),t=require("./connectRemoteProxy.js"),a=require("./getPromiseWithResolvers.js"),n=require("./guards.js"),o=require("./methodSerialization.js"),i=require("./namespace.js"),c=require("./PenpalError.js");module.exports=({messenger:d,methods:h,timeout:m,channel:u,log:A})=>{const p=e.randomUUID();let I;const l=[];let g=!1;const P=o.extractMethodPathsFromMethods(h),{promise:S,resolve:N,reject:C}=a(),y=
|
|
1
|
+
"use strict";var e=require("../../../utils/crypto.js"),s=require("./backwardCompatibility.js"),r=require("./connectCallHandler.js"),t=require("./connectRemoteProxy.js"),a=require("./getPromiseWithResolvers.js"),n=require("./guards.js"),o=require("./methodSerialization.js"),i=require("./namespace.js"),c=require("./PenpalError.js");module.exports=({messenger:d,methods:h,timeout:m,channel:u,log:A})=>{const p=e.randomUUID();let I;const l=[];let g=!1;const P=o.extractMethodPathsFromMethods(h),{promise:S,resolve:N,reject:C}=a(),y=setTimeout(()=>{C(new c("CONNECTION_TIMEOUT",`Connection timed out after ${m}ms`))},m),E=()=>{for(const e of l)e()},M=()=>{if(g)return;l.push(r(d,h,u,A));const{remoteProxy:e,destroy:s}=t(d,u,A);l.push(s),clearTimeout(y),g=!0,N({remoteProxy:e,destroy:E})},T=()=>{const e={namespace:i,type:"SYN",channel:u,participantId:p};A?.("Sending handshake SYN",e);try{d.sendMessage(e)}catch(e){C(new c("TRANSMISSION_FAILED",e.message))}},R=e=>{n.isSynMessage(e)&&(e=>{if(A?.("Received handshake SYN",e),e.participantId===I&&I!==s.DEPRECATED_PENPAL_PARTICIPANT_ID)return;if(I=e.participantId,T(),!(p>I||I===s.DEPRECATED_PENPAL_PARTICIPANT_ID))return;const r={namespace:i,channel:u,type:"ACK1",methodPaths:P};A?.("Sending handshake ACK1",r);try{d.sendMessage(r)}catch(e){C(new c("TRANSMISSION_FAILED",e.message))}})(e),n.isAck1Message(e)&&(e=>{A?.("Received handshake ACK1",e);const s={namespace:i,channel:u,type:"ACK2"};A?.("Sending handshake ACK2",s);try{d.sendMessage(s)}catch(e){return void C(new c("TRANSMISSION_FAILED",e.message))}M()})(e),n.isAck2Message(e)&&(e=>{A?.("Received handshake ACK2",e),M()})(e)};return d.addMessageHandler(R),l.push(()=>d.removeMessageHandler(R)),T(),S};
|
package/dist/index.d.ts
CHANGED
|
@@ -6516,6 +6516,7 @@ type OpenfortAPIConfiguration = {
|
|
|
6516
6516
|
interface BackendApiClientsOptions {
|
|
6517
6517
|
basePath: string;
|
|
6518
6518
|
accessToken: string;
|
|
6519
|
+
nativeAppIdentifier?: string;
|
|
6519
6520
|
}
|
|
6520
6521
|
declare class BackendApiClients {
|
|
6521
6522
|
config: OpenfortAPIConfiguration;
|
|
@@ -7258,8 +7259,10 @@ interface ThirdPartyAuthConfiguration {
|
|
|
7258
7259
|
}
|
|
7259
7260
|
declare class OpenfortConfiguration {
|
|
7260
7261
|
readonly publishableKey: string;
|
|
7262
|
+
readonly nativeAppIdentifier?: string;
|
|
7261
7263
|
constructor(options: {
|
|
7262
7264
|
publishableKey: string;
|
|
7265
|
+
nativeAppIdentifier?: string;
|
|
7263
7266
|
});
|
|
7264
7267
|
}
|
|
7265
7268
|
declare class ShieldConfiguration {
|
|
@@ -7294,6 +7297,7 @@ declare class SDKConfiguration {
|
|
|
7294
7297
|
readonly storage?: IStorage;
|
|
7295
7298
|
readonly passkeyRpId?: string;
|
|
7296
7299
|
readonly passkeyRpName?: string;
|
|
7300
|
+
readonly nativeAppIdentifier?: string;
|
|
7297
7301
|
static instance: SDKConfiguration | null;
|
|
7298
7302
|
constructor({ baseConfiguration, shieldConfiguration, overrides, thirdPartyAuth }: OpenfortSDKConfiguration);
|
|
7299
7303
|
static getInstance(): SDKConfiguration | null;
|
|
@@ -7481,6 +7485,8 @@ declare class OpenfortInternal {
|
|
|
7481
7485
|
getAccessToken(): Promise<string | null>;
|
|
7482
7486
|
/**
|
|
7483
7487
|
* Validates and refreshes the access token if needed.
|
|
7488
|
+
* Uses promise deduplication to prevent race conditions when multiple API calls
|
|
7489
|
+
* simultaneously detect an expired token.
|
|
7484
7490
|
*/
|
|
7485
7491
|
validateAndRefreshToken(forceRefresh?: boolean): Promise<void>;
|
|
7486
7492
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"axios";import t from"axios-retry";const n="https://api.openfort.io".replace(/\/+$/,"");class s{basePath;axios;configuration;constructor(t,s=n,a=e){this.basePath=s,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,n){if(null==n)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const n="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+n}};function c(e,t,n=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,n)):Object.keys(t).forEach(s=>c(e,t[s],`${n}${""!==n?".":""}${s}`)):e.has(n)?e.append(n,t):e.set(n,t))}const h=function(e,...t){const n=new URLSearchParams(e.search);c(n,t),e.search=n.toString()},u=function(e,t,n){const s="string"!=typeof e;return(s&&n&&n.isJsonMime?n.isJsonMime(t.headers["Content-Type"]):s)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,n,s){return(a=t,i=n)=>{const o={...e.options,url:(s?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const s=function(e){return{cancelTransferOwnership:async(t,n,s={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",n);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},completeRecovery:async(t,n,s={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",n);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},createAccount:async(t,n={})=>{o("createAccount","createAccountRequest",t);const s=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},deployAccount:async(t,n,s={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",n);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},disableAccount:async(t,n={})=>{o("disableAccount","id",t);const s="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccount:async(t,n,s={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getAccountV2:async(t,n={})=>{o("getAccountV2","id",t);const s="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccounts:async(t,n,s,a,o,c,u,l={})=>{const p=new URL("/v1/accounts",i);let y;e&&(y=e.baseOptions);const g={method:"GET",...y,...l},w={},m={};await r(w,e),void 0!==t&&(m.limit=t),void 0!==n&&(m.skip=n),void 0!==s&&(m.order=s),void 0!==a&&(m.chainId=a),void 0!==o&&(m.player=o),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let P=y&&y.headers?y.headers:{};return g.headers={...w,...P,...l.headers},{url:d(p),options:g}},getAccountsV2:async(t,n,s,a,o,c,u,l,p={})=>{const y=new URL("/v2/accounts",i);let g;e&&(g=e.baseOptions);const w={method:"GET",...g,...p},m={},P={};await r(m,e),void 0!==t&&(P.limit=t),void 0!==n&&(P.skip=n),void 0!==s&&(P.order=s),void 0!==a&&(P.chainId=a),void 0!==o&&(P.user=o),void 0!==c&&(P.chainType=c),void 0!==u&&(P.accountType=u),void 0!==l&&(P.address=l),h(y,P);let R=g&&g.headers?g.headers:{};return w.headers={...m,...R,...p.headers},{url:d(y),options:w}},getSignerIdByAddress:async(t,n={})=>{o("getSignerIdByAddress","address",t);const s=new URL("/v2/accounts/signer",i);let a;e&&(a=e.baseOptions);const c={method:"GET",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.address=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},requestTransferOwnership:async(t,n,s={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",n);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},signPayload:async(t,n,s={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",n);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},startRecovery:async(t,n,s={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",n);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},switchChainV2:async(t,n={})=>{o("switchChainV2","switchChainQueriesV2",t);const s=new URL("/v2/accounts/switch-chain",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},syncAccount:async(t,n={})=>{o("syncAccount","id",t);const s="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await s.cancelTransferOwnership(a,i,o);return l(r,e,n,t)},async completeRecovery(a,i,o){const r=await s.completeRecovery(a,i,o);return l(r,e,n,t)},async createAccount(a,i){const o=await s.createAccount(a,i);return l(o,e,n,t)},async deployAccount(a,i,o){const r=await s.deployAccount(a,i,o);return l(r,e,n,t)},async disableAccount(a,i){const o=await s.disableAccount(a,i);return l(o,e,n,t)},async getAccount(a,i,o){const r=await s.getAccount(a,i,o);return l(r,e,n,t)},async getAccountV2(a,i){const o=await s.getAccountV2(a,i);return l(o,e,n,t)},async getAccounts(a,i,o,r,c,h,u,d){const p=await s.getAccounts(a,i,o,r,c,h,u,d);return l(p,e,n,t)},async getAccountsV2(a,i,o,r,c,h,u,d,p){const y=await s.getAccountsV2(a,i,o,r,c,h,u,d,p);return l(y,e,n,t)},async getSignerIdByAddress(a,i){const o=await s.getSignerIdByAddress(a,i);return l(o,e,n,t)},async requestTransferOwnership(a,i,o){const r=await s.requestTransferOwnership(a,i,o);return l(r,e,n,t)},async signPayload(a,i,o){const r=await s.signPayload(a,i,o);return l(r,e,n,t)},async startRecovery(a,i,o){const r=await s.startRecovery(a,i,o);return l(r,e,n,t)},async switchChainV2(a,i){const o=await s.switchChainV2(a,i);return l(o,e,n,t)},async syncAccount(a,i){const o=await s.syncAccount(a,i);return l(o,e,n,t)}}};class y extends s{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.id,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.chainId,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountsV2(e={},t){return p(this.configuration).getAccountsV2(e.limit,e.skip,e.order,e.chainId,e.user,e.chainType,e.accountType,e.address,t).then(e=>e(this.axios,this.basePath))}getSignerIdByAddress(e,t){return p(this.configuration).getSignerIdByAddress(e.address,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}switchChainV2(e,t){return p(this.configuration).switchChainV2(e.switchChainQueriesV2,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const s=function(e){return{authenticateSIWE:async(t,n={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getJwks:async(t,n={})=>{o("getJwks","publishableKey",t);const s="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},initOAuth:async(t,n,s={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,n,s={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,n,s={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,n,s={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,n={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},linkThirdParty:async(t,n,s={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,n,s={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,n,s={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,n={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const s=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},logout:async(t,n={})=>{o("logout","logoutRequest",t);const s=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},me:async(t={})=>{const n=new URL("/iam/v1/me",i);let s;e&&(s=e.baseOptions);const a={method:"GET",...s,...t};h(n,{});let o=s&&s.headers?s.headers:{};return a.headers={...o,...t.headers},{url:d(n),options:a}},poolOAuth:async(t,n={})=>{o("poolOAuth","key",t);const s=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},refresh:async(t,n={})=>{o("refresh","refreshTokenRequest",t);const s=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},registerGuest:async(t,n={})=>{const s=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...n},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(s,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...n.headers},{url:d(s),options:o}},requestEmailVerification:async(t,n={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const s=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},requestResetPassword:async(t,n={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const s=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},resetPassword:async(t,n={})=>{o("resetPassword","resetPasswordRequest",t);const s=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},signupEmailPassword:async(t,n,s={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,n,s={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,n={})=>{o("unlinkEmail","unlinkEmailRequest",t);const s=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkOAuth:async(t,n={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const s=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkSIWE:async(t,n={})=>{o("unlinkSIWE","sIWERequest",t);const s=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},verifyEmail:async(t,n={})=>{o("verifyEmail","verifyEmailRequest",t);const s=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},verifyOAuthToken:async(t,n={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const s=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await s.authenticateSIWE(a,i);return l(o,e,n,t)},async getJwks(a,i){const o=await s.getJwks(a,i);return l(o,e,n,t)},async initOAuth(a,i,o){const r=await s.initOAuth(a,i,o);return l(r,e,n,t)},async initSIWE(a,i,o){const r=await s.initSIWE(a,i,o);return l(r,e,n,t)},async linkEmail(a,i,o){const r=await s.linkEmail(a,i,o);return l(r,e,n,t)},async linkOAuth(a,i,o){const r=await s.linkOAuth(a,i,o);return l(r,e,n,t)},async linkSIWE(a,i){const o=await s.linkSIWE(a,i);return l(o,e,n,t)},async linkThirdParty(a,i,o){const r=await s.linkThirdParty(a,i,o);return l(r,e,n,t)},async loginEmailPassword(a,i,o){const r=await s.loginEmailPassword(a,i,o);return l(r,e,n,t)},async loginOIDC(a,i,o){const r=await s.loginOIDC(a,i,o);return l(r,e,n,t)},async loginWithIdToken(a,i){const o=await s.loginWithIdToken(a,i);return l(o,e,n,t)},async logout(a,i){const o=await s.logout(a,i);return l(o,e,n,t)},async me(a){const i=await s.me(a);return l(i,e,n,t)},async poolOAuth(a,i){const o=await s.poolOAuth(a,i);return l(o,e,n,t)},async refresh(a,i){const o=await s.refresh(a,i);return l(o,e,n,t)},async registerGuest(a,i){const o=await s.registerGuest(a,i);return l(o,e,n,t)},async requestEmailVerification(a,i){const o=await s.requestEmailVerification(a,i);return l(o,e,n,t)},async requestResetPassword(a,i){const o=await s.requestResetPassword(a,i);return l(o,e,n,t)},async resetPassword(a,i){const o=await s.resetPassword(a,i);return l(o,e,n,t)},async signupEmailPassword(a,i,o){const r=await s.signupEmailPassword(a,i,o);return l(r,e,n,t)},async thirdParty(a,i,o){const r=await s.thirdParty(a,i,o);return l(r,e,n,t)},async unlinkEmail(a,i){const o=await s.unlinkEmail(a,i);return l(o,e,n,t)},async unlinkOAuth(a,i){const o=await s.unlinkOAuth(a,i);return l(o,e,n,t)},async unlinkSIWE(a,i){const o=await s.unlinkSIWE(a,i);return l(o,e,n,t)},async verifyEmail(a,i){const o=await s.verifyEmail(a,i);return l(o,e,n,t)},async verifyOAuthToken(a,i){const o=await s.verifyOAuthToken(a,i);return l(o,e,n,t)}}};class w extends s{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const s=function(e){return{createSession:async(t,n,s={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,n,s,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==n&&(w.limit=n),void 0!==s&&(w.skip=s),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,n,s={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},revokeSession:async(t,n,s={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,n,s={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",n);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await s.createSession(a,i,o);return l(r,e,n,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await s.getPlayerSessions(a,i,o,r,c,h);return l(u,e,n,t)},async getSession(a,i,o){const r=await s.getSession(a,i,o);return l(r,e,n,t)},async revokeSession(a,i,o){const r=await s.revokeSession(a,i,o);return l(r,e,n,t)},async signatureSession(a,i,o){const r=await s.signatureSession(a,i,o);return l(r,e,n,t)}}};class P extends s{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const s=function(e){return{createTransactionIntent:async(t,n,s={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,n={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const s=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getTransactionIntent:async(t,n,s={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getTransactionIntents:async(t,n,s,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==n&&(R.skip=n),void 0!==s&&(R.order=s),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,n,s={})=>{o("signature","id",t),o("signature","signatureRequest",n);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await s.createTransactionIntent(a,i,o);return l(r,e,n,t)},async estimateTransactionIntentCost(a,i){const o=await s.estimateTransactionIntentCost(a,i);return l(o,e,n,t)},async getTransactionIntent(a,i,o){const r=await s.getTransactionIntent(a,i,o);return l(r,e,n,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await s.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,n,t)},async signature(a,i,o){const r=await s.signature(a,i,o);return l(r,e,n,t)}}};class T extends s{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};class b{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(n){const s=e.create();t(s,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:n.basePath,accessToken:n.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,s),this.accountsApi=new y(this.config.backend,void 0,s),this.sessionsApi=new P(this.config.backend,void 0,s),this.authenticationApi=new w(this.config.backend,void 0,s)}}export{b as BackendApiClients,f as createConfig};
|
|
1
|
+
import e from"axios";import t from"axios-retry";const n="https://api.openfort.io".replace(/\/+$/,"");class s{basePath;axios;configuration;constructor(t,s=n,a=e){this.basePath=s,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,n){if(null==n)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const n="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+n}};function c(e,t,n=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,n)):Object.keys(t).forEach(s=>c(e,t[s],`${n}${""!==n?".":""}${s}`)):e.has(n)?e.append(n,t):e.set(n,t))}const h=function(e,...t){const n=new URLSearchParams(e.search);c(n,t),e.search=n.toString()},u=function(e,t,n){const s="string"!=typeof e;return(s&&n&&n.isJsonMime?n.isJsonMime(t.headers["Content-Type"]):s)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,n,s){return(a=t,i=n)=>{const o={...e.options,url:(s?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const s=function(e){return{cancelTransferOwnership:async(t,n,s={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",n);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},completeRecovery:async(t,n,s={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",n);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},createAccount:async(t,n={})=>{o("createAccount","createAccountRequest",t);const s=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},deployAccount:async(t,n,s={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",n);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},disableAccount:async(t,n={})=>{o("disableAccount","id",t);const s="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccount:async(t,n,s={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getAccountV2:async(t,n={})=>{o("getAccountV2","id",t);const s="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccounts:async(t,n,s,a,o,c,u,l={})=>{const p=new URL("/v1/accounts",i);let y;e&&(y=e.baseOptions);const g={method:"GET",...y,...l},w={},m={};await r(w,e),void 0!==t&&(m.limit=t),void 0!==n&&(m.skip=n),void 0!==s&&(m.order=s),void 0!==a&&(m.chainId=a),void 0!==o&&(m.player=o),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let P=y&&y.headers?y.headers:{};return g.headers={...w,...P,...l.headers},{url:d(p),options:g}},getAccountsV2:async(t,n,s,a,o,c,u,l,p={})=>{const y=new URL("/v2/accounts",i);let g;e&&(g=e.baseOptions);const w={method:"GET",...g,...p},m={},P={};await r(m,e),void 0!==t&&(P.limit=t),void 0!==n&&(P.skip=n),void 0!==s&&(P.order=s),void 0!==a&&(P.chainId=a),void 0!==o&&(P.user=o),void 0!==c&&(P.chainType=c),void 0!==u&&(P.accountType=u),void 0!==l&&(P.address=l),h(y,P);let R=g&&g.headers?g.headers:{};return w.headers={...m,...R,...p.headers},{url:d(y),options:w}},getSignerIdByAddress:async(t,n={})=>{o("getSignerIdByAddress","address",t);const s=new URL("/v2/accounts/signer",i);let a;e&&(a=e.baseOptions);const c={method:"GET",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.address=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},requestTransferOwnership:async(t,n,s={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",n);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},signPayload:async(t,n,s={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",n);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},startRecovery:async(t,n,s={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",n);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},switchChainV2:async(t,n={})=>{o("switchChainV2","switchChainQueriesV2",t);const s=new URL("/v2/accounts/switch-chain",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},syncAccount:async(t,n={})=>{o("syncAccount","id",t);const s="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await s.cancelTransferOwnership(a,i,o);return l(r,e,n,t)},async completeRecovery(a,i,o){const r=await s.completeRecovery(a,i,o);return l(r,e,n,t)},async createAccount(a,i){const o=await s.createAccount(a,i);return l(o,e,n,t)},async deployAccount(a,i,o){const r=await s.deployAccount(a,i,o);return l(r,e,n,t)},async disableAccount(a,i){const o=await s.disableAccount(a,i);return l(o,e,n,t)},async getAccount(a,i,o){const r=await s.getAccount(a,i,o);return l(r,e,n,t)},async getAccountV2(a,i){const o=await s.getAccountV2(a,i);return l(o,e,n,t)},async getAccounts(a,i,o,r,c,h,u,d){const p=await s.getAccounts(a,i,o,r,c,h,u,d);return l(p,e,n,t)},async getAccountsV2(a,i,o,r,c,h,u,d,p){const y=await s.getAccountsV2(a,i,o,r,c,h,u,d,p);return l(y,e,n,t)},async getSignerIdByAddress(a,i){const o=await s.getSignerIdByAddress(a,i);return l(o,e,n,t)},async requestTransferOwnership(a,i,o){const r=await s.requestTransferOwnership(a,i,o);return l(r,e,n,t)},async signPayload(a,i,o){const r=await s.signPayload(a,i,o);return l(r,e,n,t)},async startRecovery(a,i,o){const r=await s.startRecovery(a,i,o);return l(r,e,n,t)},async switchChainV2(a,i){const o=await s.switchChainV2(a,i);return l(o,e,n,t)},async syncAccount(a,i){const o=await s.syncAccount(a,i);return l(o,e,n,t)}}};class y extends s{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.id,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.chainId,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountsV2(e={},t){return p(this.configuration).getAccountsV2(e.limit,e.skip,e.order,e.chainId,e.user,e.chainType,e.accountType,e.address,t).then(e=>e(this.axios,this.basePath))}getSignerIdByAddress(e,t){return p(this.configuration).getSignerIdByAddress(e.address,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}switchChainV2(e,t){return p(this.configuration).switchChainV2(e.switchChainQueriesV2,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const s=function(e){return{authenticateSIWE:async(t,n={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getJwks:async(t,n={})=>{o("getJwks","publishableKey",t);const s="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},initOAuth:async(t,n,s={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,n,s={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,n,s={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,n,s={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,n={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},linkThirdParty:async(t,n,s={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,n,s={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,n,s={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,n={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const s=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},logout:async(t,n={})=>{o("logout","logoutRequest",t);const s=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},me:async(t={})=>{const n=new URL("/iam/v1/me",i);let s;e&&(s=e.baseOptions);const a={method:"GET",...s,...t};h(n,{});let o=s&&s.headers?s.headers:{};return a.headers={...o,...t.headers},{url:d(n),options:a}},poolOAuth:async(t,n={})=>{o("poolOAuth","key",t);const s=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},refresh:async(t,n={})=>{o("refresh","refreshTokenRequest",t);const s=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},registerGuest:async(t,n={})=>{const s=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...n},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(s,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...n.headers},{url:d(s),options:o}},requestEmailVerification:async(t,n={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const s=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},requestResetPassword:async(t,n={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const s=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},resetPassword:async(t,n={})=>{o("resetPassword","resetPasswordRequest",t);const s=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},signupEmailPassword:async(t,n,s={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,n,s={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,n={})=>{o("unlinkEmail","unlinkEmailRequest",t);const s=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkOAuth:async(t,n={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const s=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkSIWE:async(t,n={})=>{o("unlinkSIWE","sIWERequest",t);const s=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},verifyEmail:async(t,n={})=>{o("verifyEmail","verifyEmailRequest",t);const s=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},verifyOAuthToken:async(t,n={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const s=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await s.authenticateSIWE(a,i);return l(o,e,n,t)},async getJwks(a,i){const o=await s.getJwks(a,i);return l(o,e,n,t)},async initOAuth(a,i,o){const r=await s.initOAuth(a,i,o);return l(r,e,n,t)},async initSIWE(a,i,o){const r=await s.initSIWE(a,i,o);return l(r,e,n,t)},async linkEmail(a,i,o){const r=await s.linkEmail(a,i,o);return l(r,e,n,t)},async linkOAuth(a,i,o){const r=await s.linkOAuth(a,i,o);return l(r,e,n,t)},async linkSIWE(a,i){const o=await s.linkSIWE(a,i);return l(o,e,n,t)},async linkThirdParty(a,i,o){const r=await s.linkThirdParty(a,i,o);return l(r,e,n,t)},async loginEmailPassword(a,i,o){const r=await s.loginEmailPassword(a,i,o);return l(r,e,n,t)},async loginOIDC(a,i,o){const r=await s.loginOIDC(a,i,o);return l(r,e,n,t)},async loginWithIdToken(a,i){const o=await s.loginWithIdToken(a,i);return l(o,e,n,t)},async logout(a,i){const o=await s.logout(a,i);return l(o,e,n,t)},async me(a){const i=await s.me(a);return l(i,e,n,t)},async poolOAuth(a,i){const o=await s.poolOAuth(a,i);return l(o,e,n,t)},async refresh(a,i){const o=await s.refresh(a,i);return l(o,e,n,t)},async registerGuest(a,i){const o=await s.registerGuest(a,i);return l(o,e,n,t)},async requestEmailVerification(a,i){const o=await s.requestEmailVerification(a,i);return l(o,e,n,t)},async requestResetPassword(a,i){const o=await s.requestResetPassword(a,i);return l(o,e,n,t)},async resetPassword(a,i){const o=await s.resetPassword(a,i);return l(o,e,n,t)},async signupEmailPassword(a,i,o){const r=await s.signupEmailPassword(a,i,o);return l(r,e,n,t)},async thirdParty(a,i,o){const r=await s.thirdParty(a,i,o);return l(r,e,n,t)},async unlinkEmail(a,i){const o=await s.unlinkEmail(a,i);return l(o,e,n,t)},async unlinkOAuth(a,i){const o=await s.unlinkOAuth(a,i);return l(o,e,n,t)},async unlinkSIWE(a,i){const o=await s.unlinkSIWE(a,i);return l(o,e,n,t)},async verifyEmail(a,i){const o=await s.verifyEmail(a,i);return l(o,e,n,t)},async verifyOAuthToken(a,i){const o=await s.verifyOAuthToken(a,i);return l(o,e,n,t)}}};class w extends s{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const s=function(e){return{createSession:async(t,n,s={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,n,s,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==n&&(w.limit=n),void 0!==s&&(w.skip=s),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,n,s={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},revokeSession:async(t,n,s={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,n,s={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",n);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await s.createSession(a,i,o);return l(r,e,n,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await s.getPlayerSessions(a,i,o,r,c,h);return l(u,e,n,t)},async getSession(a,i,o){const r=await s.getSession(a,i,o);return l(r,e,n,t)},async revokeSession(a,i,o){const r=await s.revokeSession(a,i,o);return l(r,e,n,t)},async signatureSession(a,i,o){const r=await s.signatureSession(a,i,o);return l(r,e,n,t)}}};class P extends s{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const s=function(e){return{createTransactionIntent:async(t,n,s={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,n={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const s=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getTransactionIntent:async(t,n,s={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getTransactionIntents:async(t,n,s,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==n&&(R.skip=n),void 0!==s&&(R.order=s),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,n,s={})=>{o("signature","id",t),o("signature","signatureRequest",n);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await s.createTransactionIntent(a,i,o);return l(r,e,n,t)},async estimateTransactionIntentCost(a,i){const o=await s.estimateTransactionIntentCost(a,i);return l(o,e,n,t)},async getTransactionIntent(a,i,o){const r=await s.getTransactionIntent(a,i,o);return l(r,e,n,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await s.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,n,t)},async signature(a,i,o){const r=await s.signature(a,i,o);return l(r,e,n,t)}}};class T extends s{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t,nativeAppIdentifier:n})=>{if(!e.trim())throw Error("basePath can not be empty");const s={basePath:e,accessToken:t};return n&&(s.baseOptions={headers:{"x-native-app-identifier":n}}),new O(s)};class b{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(n){const s=e.create();t(s,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:n.basePath,accessToken:n.accessToken,nativeAppIdentifier:n.nativeAppIdentifier};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,s),this.accountsApi=new y(this.config.backend,void 0,s),this.sessionsApi=new P(this.config.backend,void 0,s),this.authenticationApi=new w(this.config.backend,void 0,s)}}export{b as BackendApiClients,f as createConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BackendApiClients as e}from"../../../packages/internal/openapi-clients/dist/index.js";import{PasskeyHandler as t}from"../core/configuration/passkey.js";import{SDKConfiguration as r}from"../core/config/config.js";import{Account as a}from"../core/configuration/account.js";import{Authentication as s}from"../core/configuration/authentication.js";import{OpenfortError as i,OpenfortErrorType as n,withOpenfortError as o}from"../core/errors/openfortError.js";import{OpenfortEvents as d,RecoveryMethod as c,AccountTypeEnum as h,ChainTypeEnum as y,EmbeddedState as g}from"../types/types.js";import{debugLog as m}from"../utils/debug.js";import{EmbeddedSigner as p}from"../wallets/embedded.js";import{EvmProvider as l}from"../wallets/evm/evmProvider.js";import"../wallets/evm/types.js";import{announceProvider as f,openfortProviderInfo as u}from"../wallets/evm/provider/eip6963.js";import{signMessage as A}from"../wallets/evm/walletHelpers.js";import{IframeManager as w}from"../wallets/iframeManager.js";import{ReactNativeMessenger as I}from"../wallets/messaging/ReactNativeMessenger.js";import"../wallets/messaging/browserMessenger/backwardCompatibility.js";import v from"../wallets/messaging/browserMessenger/messengers/WindowMessenger.js";class M{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;passkeyHandler;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,t,r,a,s){this.storage=e,this.validateAndRefreshToken=t,this.ensureInitialized=r,this.eventEmitter=a,this.passkeyHandler=s,this.eventEmitter.on(d.ON_LOGOUT,()=>{m("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const t=r.getInstance();if(!t)throw new i("Configuration not found",n.INVALID_CONFIGURATION);return new e({basePath:t.backendUrl,accessToken:t.baseConfiguration.publishableKey})}async getIframeManager(){if(m("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return m("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return m("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;m("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return m("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,m("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw m("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){m("[HANDSHAKE DEBUG] createIframeManager starting");const e=r.getInstance();if(!e)throw m("[HANDSHAKE DEBUG] Configuration not found"),new i("Configuration not found",n.INVALID_CONFIGURATION);let t;if(m("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)m("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new I(this.messagePoster),m("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),t=this.messenger;else{m("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const r=this.createIframe(e.iframeUrl),a=new URL(e.iframeUrl).origin;t=new v({remoteWindow:r.contentWindow,allowedOrigins:[a]}),m("[HANDSHAKE DEBUG] Created WindowMessenger")}return m("[HANDSHAKE DEBUG] Creating IframeManager instance"),new w(e,this.storage,t)}async ensureSigner(){if(this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager();return new p(e,this.storage,this.backendApiClients,this.passkeyHandler,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new i("Document is not available. Please provide a message poster for non-browser environments.",n.INVALID_CONFIGURATION);const t=document.getElementById("openfort-iframe");t&&t.remove();const r=document.createElement("iframe");return r.style.display="none",r.id="openfort-iframe",r.src=e,document.body.appendChild(r),r}async getPasskeyKey(e){const t=await s.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:t.player})}async getEntropy(e){switch(e.recoveryMethod){case c.PASSWORD:return{recoveryPassword:e.password};case c.AUTOMATIC:return{encryptionSession:e.encryptionSession};case c.PASSKEY:return{passkey:e.passkeyInfo?{id:e.passkeyInfo.passkeyId,key:e.passkeyInfo.passkeyKey||await this.getPasskeyKey(e.passkeyInfo.passkeyId)}:{}};default:throw new i("Invalid recovery method",n.INVALID_CONFIGURATION)}}async configure(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:c.AUTOMATIC},[r,i,n]=await Promise.all([s.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(t)]),o={chainId:e.chainId,entropy:n,accountType:e.accountType??h.SMART_ACCOUNT,chainType:e.chainType??y.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},d=await i.configure(o);return{id:d.id,chainId:d.chainId,user:r.player,address:d.address,ownerAddress:d.ownerAddress,chainType:d.chainType,accountType:d.accountType,implementationType:d.implementationType,createdAt:d.createdAt,recoveryMethod:a.parseRecoveryMethod(d.recoveryMethod),recoveryMethodDetails:d.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:c.AUTOMATIC},o=await s.fromStorage(this.storage);if(!o)throw new i("missing authentication",n.AUTHENTICATION_ERROR);if(r.recoveryMethod===c.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:t.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:o?.player});r.passkeyInfo={passkeyId:e.id,passkeyKey:e.key}}const[h,y]=await Promise.all([this.ensureSigner(),this.getEntropy(r)]),g=await h.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:y}),m={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.parseRecoveryMethod(g.recoveryMethod),recoveryMethodDetails:g.recoveryMethodDetails};return this.eventEmitter.emit(d.ON_EMBEDDED_WALLET_CREATED,m),m}async recover(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:c.AUTOMATIC};if(t.recoveryMethod===c.PASSKEY){if(!t.passkeyInfo?.passkeyId)throw new i("Passkey ID must be provided for passkey recovery",n.INVALID_CONFIGURATION);t.passkeyInfo={passkeyId:t.passkeyInfo.passkeyId}}const[r,o,h]=await Promise.all([this.ensureSigner(),this.getEntropy(t),s.fromStorage(this.storage)]),y=await r.recover({account:e.account,entropy:o}),g={id:y.id,chainId:y.chainId,user:h.player,address:y.address,ownerAddress:y.ownerAddress,chainType:y.chainType,accountType:y.accountType,implementationType:y.implementationType,createdAt:y.createdAt,recoveryMethod:a.parseRecoveryMethod(y.recoveryMethod),recoveryMethodDetails:y.recoveryMethodDetails};return this.eventEmitter.emit(d.ON_EMBEDDED_WALLET_RECOVERED,g),g}async signMessage(e,t){await this.validateAndRefreshToken();const r=await this.ensureSigner(),{hashMessage:s=!0,arrayifyMessage:i=!1}=t||{},n=await a.fromStorage(this.storage);return await r.sign(e,i,s,n?.chainType)}async signTypedData(e,t,r){await this.validateAndRefreshToken();const s=await this.ensureSigner(),o=await a.fromStorage(this.storage);if(!o)throw new i("No account found",n.MISSING_SIGNER_ERROR);const d={...t};delete d.EIP712Domain;const{_TypedDataEncoder:c}=await import("@ethersproject/hash"),h=c.hash(e,d,r);return await A({hash:h,implementationType:o.implementationType||o.type,chainId:Number(o.chainId),signer:s,address:o.address,ownerAddress:o.ownerAddress,factoryAddress:o.factoryAddress,salt:o.salt})}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setRecoveryMethod(e,r){await this.validateAndRefreshToken();const o=await this.ensureSigner(),d=await s.fromStorage(this.storage);if(!d)throw new i("missing authentication",n.AUTHENTICATION_ERROR);let h,y,g,m;if(e.recoveryMethod===c.PASSKEY){const e=await a.fromStorage(this.storage);if(!e)throw new i("missing account",n.INVALID_CONFIGURATION);const t=e?.recoveryMethodDetails?.passkeyId;if(!t)throw new i("missing passkey id for account",n.INVALID_CONFIGURATION);g={passkeyId:t,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:t,seed:d.player})}}else if(r.recoveryMethod===c.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:t.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:d.player});g={passkeyId:e.id,passkeyKey:e.key},m={passkeyId:e.id}}if(e.recoveryMethod===c.PASSWORD?h=e.password:r.recoveryMethod===c.PASSWORD&&(h=r.password),e.recoveryMethod===c.AUTOMATIC?y=e.encryptionSession:r.recoveryMethod===c.AUTOMATIC&&(y=r.encryptionSession),!h&&!y)throw new i("Password or encryption session is not provided",n.INVALID_CONFIGURATION);await o.setRecoveryMethod({recoveryMethod:r.recoveryMethod,recoveryPassword:h,encryptionSession:y,passkeyInfo:g});const p=await a.fromStorage(this.storage);p&&new a({...p,recoveryMethod:r.recoveryMethod,recoveryMethodDetails:m}).save(this.storage)}async get(){const e=await a.fromStorage(this.storage);if(!e)throw new i("No signer configured",n.MISSING_SIGNER_ERROR);const t=await s.fromStorage(this.storage);if(!t)throw new i("No access token found",n.NOT_LOGGED_IN_ERROR);return{id:e.id,chainId:e.chainId,user:t.player,address:e.address,ownerAddress:e.ownerAddress,chainType:e.chainType,accountType:e.accountType,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:a.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const t={accountType:h.SMART_ACCOUNT,...e},d=r.getInstance();if(!d)throw new i("Configuration not found",n.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const c=await s.fromStorage(this.storage);if(!c)throw new i("No access token found",n.NOT_LOGGED_IN_ERROR);return o(async()=>(await this.backendApiClients.accountsApi.getAccountsV2(t,{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}})).data.data.map(e=>({user:e.user,chainType:e.chainType,id:e.id,address:e.address,ownerAddress:e.ownerAddress,accountType:e.accountType,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:a.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{default:n.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await s.fromStorage(this.storage))return g.UNAUTHENTICATED;return await a.fromStorage(this.storage)?g.READY:g.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return m("Failed to get embedded state:",e),g.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const t={announceProvider:!0,...e},r=await s.fromStorage(this.storage),i=await a.fromStorage(this.storage);return this.provider?this.provider&&t.policy&&this.provider.updatePolicy(t.policy):(this.provider=new l({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:i||void 0,authentication:r||void 0,backendApiClients:this.backendApiClients,policyId:t.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:t.chains}),t.announceProvider&&f({info:{...u,...t.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(t=>{setTimeout(t,e)});const t=await this.getIframeManager();if(!t.isLoaded())return!1;const r=await s.fromStorage(this.storage);if(r)try{return await t.getCurrentDevice(r.player),!0}catch(e){return!1}return t.isLoaded()}catch(e){return m("Ping failed:",e),!1}}getURL(){const e=r.getInstance();if(!e)throw new i("Configuration not found",n.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new i("Invalid message poster",n.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&this.messenger.destroy(),this.iframeManager&&this.iframeManager.destroy(),this.signer=null,this.signerPromise=null,this.iframeManager=null,this.iframeManagerPromise=null,this.messenger=null}async handleLogout(){const e=await this.ensureSigner();await e.disconnect(),this.provider=null,this.messenger=null,this.iframeManager=null,this.iframeManagerPromise=null,this.signer=null,this.signerPromise=null}async onMessage(e){if(!e||"object"!=typeof e)return void m("Invalid message received:",e);m("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const t="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(t&&this.messenger&&this.messagePoster)return m("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const r=await this.getIframeManager();m(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${r.isLoaded()}`),t&&!r.isLoaded()&&m("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),m("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await r.onMessage(e),m("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}}export{M as EmbeddedWalletApi};
|
|
1
|
+
import{BackendApiClients as e}from"../../../packages/internal/openapi-clients/dist/index.js";import{PasskeyHandler as t}from"../core/configuration/passkey.js";import{SDKConfiguration as r}from"../core/config/config.js";import{Account as a}from"../core/configuration/account.js";import{Authentication as s}from"../core/configuration/authentication.js";import{OpenfortError as i,OpenfortErrorType as n,withOpenfortError as o}from"../core/errors/openfortError.js";import{OpenfortEvents as d,RecoveryMethod as c,ChainTypeEnum as h,AccountTypeEnum as y,EmbeddedState as g}from"../types/types.js";import{debugLog as m}from"../utils/debug.js";import{EmbeddedSigner as p}from"../wallets/embedded.js";import{EvmProvider as l}from"../wallets/evm/evmProvider.js";import"../wallets/evm/types.js";import{announceProvider as f,openfortProviderInfo as u}from"../wallets/evm/provider/eip6963.js";import{signMessage as A}from"../wallets/evm/walletHelpers.js";import{IframeManager as w}from"../wallets/iframeManager.js";import{ReactNativeMessenger as I}from"../wallets/messaging/ReactNativeMessenger.js";import"../wallets/messaging/browserMessenger/backwardCompatibility.js";import v from"../wallets/messaging/browserMessenger/messengers/WindowMessenger.js";class M{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;passkeyHandler;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,t,r,a,s){this.storage=e,this.validateAndRefreshToken=t,this.ensureInitialized=r,this.eventEmitter=a,this.passkeyHandler=s,this.eventEmitter.on(d.ON_LOGOUT,()=>{m("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const t=r.getInstance();if(!t)throw new i("Configuration not found",n.INVALID_CONFIGURATION);return new e({basePath:t.backendUrl,accessToken:t.baseConfiguration.publishableKey,nativeAppIdentifier:t.nativeAppIdentifier})}async getIframeManager(){if(m("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return m("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return m("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;m("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return m("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,m("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw m("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){m("[HANDSHAKE DEBUG] createIframeManager starting");const e=r.getInstance();if(!e)throw m("[HANDSHAKE DEBUG] Configuration not found"),new i("Configuration not found",n.INVALID_CONFIGURATION);let t;if(m("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)m("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new I(this.messagePoster),m("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),t=this.messenger;else{m("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const r=this.createIframe(e.iframeUrl),a=new URL(e.iframeUrl).origin;t=new v({remoteWindow:r.contentWindow,allowedOrigins:[a]}),m("[HANDSHAKE DEBUG] Created WindowMessenger")}return m("[HANDSHAKE DEBUG] Creating IframeManager instance"),new w(e,this.storage,t)}async ensureSigner(){if(this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager();return new p(e,this.storage,this.backendApiClients,this.passkeyHandler,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new i("Document is not available. Please provide a message poster for non-browser environments.",n.INVALID_CONFIGURATION);const t=document.getElementById("openfort-iframe");t&&t.remove();const r=document.createElement("iframe");return r.style.display="none",r.id="openfort-iframe",r.src=e,document.body.appendChild(r),r}async getPasskeyKey(e){const t=await s.fromStorage(this.storage);return await this.passkeyHandler.deriveAndExportKey({id:e,seed:t.player})}async getEntropy(e){switch(e.recoveryMethod){case c.PASSWORD:return{recoveryPassword:e.password};case c.AUTOMATIC:return{encryptionSession:e.encryptionSession};case c.PASSKEY:return{passkey:e.passkeyInfo?{id:e.passkeyInfo.passkeyId,key:e.passkeyInfo.passkeyKey||await this.getPasskeyKey(e.passkeyInfo.passkeyId)}:{}};default:throw new i("Invalid recovery method",n.INVALID_CONFIGURATION)}}async configure(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:c.AUTOMATIC},[r,i,n]=await Promise.all([s.fromStorage(this.storage),this.ensureSigner(),this.getEntropy(t)]),o={chainId:e.chainId,entropy:n,accountType:e.accountType??y.SMART_ACCOUNT,chainType:e.chainType??h.EVM,getPasskeyKeyFn:async e=>this.getPasskeyKey(e)},d=await i.configure(o);return{id:d.id,chainId:d.chainId,user:r.player,address:d.address,ownerAddress:d.ownerAddress,chainType:d.chainType,accountType:d.accountType,implementationType:d.implementationType,createdAt:d.createdAt,recoveryMethod:a.parseRecoveryMethod(d.recoveryMethod),recoveryMethodDetails:d.recoveryMethodDetails}}async create(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:c.AUTOMATIC},o=await s.fromStorage(this.storage);if(!o)throw new i("missing authentication",n.AUTHENTICATION_ERROR);if(r.recoveryMethod===c.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:t.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:o?.player});r.passkeyInfo={passkeyId:e.id,passkeyKey:e.key}}const[h,y]=await Promise.all([this.ensureSigner(),this.getEntropy(r)]),g=await h.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:y}),m={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.parseRecoveryMethod(g.recoveryMethod),recoveryMethodDetails:g.recoveryMethodDetails};return this.eventEmitter.emit(d.ON_EMBEDDED_WALLET_CREATED,m),m}async recover(e){await this.validateAndRefreshToken();const t=e.recoveryParams??{recoveryMethod:c.AUTOMATIC};if(t.recoveryMethod===c.PASSKEY){if(!t.passkeyInfo?.passkeyId)throw new i("Passkey ID must be provided for passkey recovery",n.INVALID_CONFIGURATION);t.passkeyInfo={passkeyId:t.passkeyInfo.passkeyId}}const[r,o,h]=await Promise.all([this.ensureSigner(),this.getEntropy(t),s.fromStorage(this.storage)]),y=await r.recover({account:e.account,entropy:o}),g={id:y.id,chainId:y.chainId,user:h.player,address:y.address,ownerAddress:y.ownerAddress,chainType:y.chainType,accountType:y.accountType,implementationType:y.implementationType,createdAt:y.createdAt,recoveryMethod:a.parseRecoveryMethod(y.recoveryMethod),recoveryMethodDetails:y.recoveryMethodDetails};return this.eventEmitter.emit(d.ON_EMBEDDED_WALLET_RECOVERED,g),g}async signMessage(e,t){await this.validateAndRefreshToken();const r=await this.ensureSigner(),{hashMessage:s=!0,arrayifyMessage:i=!1}=t||{},n=await a.fromStorage(this.storage);return await r.sign(e,i,s,n?.chainType)}async signTypedData(e,t,r){await this.validateAndRefreshToken();const s=await this.ensureSigner(),o=await a.fromStorage(this.storage);if(!o)throw new i("No account found",n.MISSING_SIGNER_ERROR);const d={...t};delete d.EIP712Domain;const{_TypedDataEncoder:c}=await import("@ethersproject/hash"),h=c.hash(e,d,r);return await A({hash:h,implementationType:o.implementationType||o.type,chainId:Number(o.chainId),signer:s,address:o.address,ownerAddress:o.ownerAddress,factoryAddress:o.factoryAddress,salt:o.salt})}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setRecoveryMethod(e,r){await this.validateAndRefreshToken();const o=await this.ensureSigner(),d=await s.fromStorage(this.storage);if(!d)throw new i("missing authentication",n.AUTHENTICATION_ERROR);let h,y,g,m;if(e.recoveryMethod===c.PASSKEY){const e=await a.fromStorage(this.storage);if(!e)throw new i("missing account",n.INVALID_CONFIGURATION);const t=e?.recoveryMethodDetails?.passkeyId;if(!t)throw new i("missing passkey id for account",n.INVALID_CONFIGURATION);g={passkeyId:t,passkeyKey:await this.passkeyHandler.deriveAndExportKey({id:t,seed:d.player})}}else if(r.recoveryMethod===c.PASSKEY){const e=await this.passkeyHandler.createPasskey({id:t.randomPasskeyName(),displayName:"Openfort - Embedded Wallet",seed:d.player});g={passkeyId:e.id,passkeyKey:e.key},m={passkeyId:e.id}}if(e.recoveryMethod===c.PASSWORD?h=e.password:r.recoveryMethod===c.PASSWORD&&(h=r.password),e.recoveryMethod===c.AUTOMATIC?y=e.encryptionSession:r.recoveryMethod===c.AUTOMATIC&&(y=r.encryptionSession),!h&&!y)throw new i("Password or encryption session is not provided",n.INVALID_CONFIGURATION);await o.setRecoveryMethod({recoveryMethod:r.recoveryMethod,recoveryPassword:h,encryptionSession:y,passkeyInfo:g});const p=await a.fromStorage(this.storage);p&&new a({...p,recoveryMethod:r.recoveryMethod,recoveryMethodDetails:m}).save(this.storage)}async get(){const e=await a.fromStorage(this.storage);if(!e)throw new i("No signer configured",n.MISSING_SIGNER_ERROR);const t=await s.fromStorage(this.storage);if(!t)throw new i("No access token found",n.NOT_LOGGED_IN_ERROR);return{id:e.id,chainId:e.chainId,user:t.player,address:e.address,ownerAddress:e.ownerAddress,chainType:e.chainType,accountType:e.accountType,implementationType:e.implementationType,createdAt:e.createdAt,recoveryMethod:a.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails}}async list(e){const t={accountType:y.SMART_ACCOUNT,...e},d=r.getInstance();if(!d)throw new i("Configuration not found",n.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const c=await s.fromStorage(this.storage);if(!c)throw new i("No access token found",n.NOT_LOGGED_IN_ERROR);return o(async()=>(await this.backendApiClients.accountsApi.getAccountsV2(t,{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}})).data.data.map(e=>({user:e.user,chainType:e.chainType,id:e.id,address:e.address,ownerAddress:e.ownerAddress,accountType:e.accountType,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId,recoveryMethod:a.parseRecoveryMethod(e.recoveryMethod),recoveryMethodDetails:e.recoveryMethodDetails})),{default:n.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await s.fromStorage(this.storage))return g.UNAUTHENTICATED;return await a.fromStorage(this.storage)?g.READY:g.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return m("Failed to get embedded state:",e),g.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const t={announceProvider:!0,...e},r=await s.fromStorage(this.storage),i=await a.fromStorage(this.storage);return this.provider?this.provider&&t.policy&&this.provider.updatePolicy(t.policy):(this.provider=new l({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:i||void 0,authentication:r||void 0,backendApiClients:this.backendApiClients,policyId:t.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:t.chains}),t.announceProvider&&f({info:{...u,...t.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(t=>{setTimeout(t,e)});const t=await this.getIframeManager();if(!t.isLoaded())return!1;const r=await s.fromStorage(this.storage);if(r)try{return await t.getCurrentDevice(r.player),!0}catch(e){return!1}return t.isLoaded()}catch(e){return m("Ping failed:",e),!1}}getURL(){const e=r.getInstance();if(!e)throw new i("Configuration not found",n.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new i("Invalid message poster",n.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&this.messenger.destroy(),this.iframeManager&&this.iframeManager.destroy(),this.signer=null,this.signerPromise=null,this.iframeManager=null,this.iframeManagerPromise=null,this.messenger=null}async handleLogout(){const e=await this.ensureSigner();await e.disconnect(),this.provider=null,this.messenger=null,this.iframeManager=null,this.iframeManagerPromise=null,this.signer=null,this.signerPromise=null}async onMessage(e){if(!e||"object"!=typeof e)return void m("Invalid message received:",e);m("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const t="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(t&&this.messenger&&this.messagePoster)return m("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const r=await this.getIframeManager();m(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${r.isLoaded()}`),t&&!r.isLoaded()&&m("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),m("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await r.onMessage(e),m("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}}export{M as EmbeddedWalletApi};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{setCryptoDigestOverride as
|
|
1
|
+
import{setCryptoDigestOverride as e}from"../../utils/crypto.js";class i{publishableKey;nativeAppIdentifier;constructor(e){this.publishableKey=e.publishableKey,this.nativeAppIdentifier=e.nativeAppIdentifier}}class s{shieldPublishableKey;shieldEncryptionKey;debug=!1;passkeyRpId;passkeyRpName;constructor(e){this.shieldPublishableKey=e.shieldPublishableKey,this.debug=e.shieldDebug||!1,this.passkeyRpId=e.passkeyRpId,this.passkeyRpName=e.passkeyRpName}}class t{baseConfiguration;shieldConfiguration;thirdPartyAuth;shieldUrl;iframeUrl;backendUrl;storage;passkeyRpId;passkeyRpName;nativeAppIdentifier;static instance=null;constructor({baseConfiguration:i,shieldConfiguration:s,overrides:a,thirdPartyAuth:r}){this.shieldConfiguration=s,this.baseConfiguration=i,this.backendUrl=a?.backendUrl||"https://api.openfort.io",this.iframeUrl=a?.iframeUrl||"https://embed.openfort.io",this.iframeUrl=`${this.iframeUrl}/iframe/${this.baseConfiguration.publishableKey}`,s?.debug&&(this.iframeUrl=`${this.iframeUrl}?debug=true`),this.shieldUrl=a?.shieldUrl||"https://shield.openfort.io",this.storage=a?.storage,this.thirdPartyAuth=r,this.passkeyRpId=s?.passkeyRpId,this.passkeyRpName=s?.passkeyRpName,this.nativeAppIdentifier=i.nativeAppIdentifier,a?.crypto?.digest&&e(a.crypto.digest),t.instance=this}static getInstance(){return t.instance}}export{i as OpenfortConfiguration,t as SDKConfiguration,s as ShieldConfiguration};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AxiosError as t}from"axios";import{
|
|
1
|
+
import{AxiosError as t}from"axios";import{VERSION as s,PACKAGE as e}from"../../version.js";const r="https://64a03e4967fb4dad3ecb914918c777b6@o4504593015242752.ingest.us.sentry.io/4509292415287296";class n{static sentryInstance;static queuedCalls=[];static baseTags;static set sentry(s){const e=s.getDsn();if(!e)throw new Error("Sentry DSN is not set");if(e.projectId!==r.split("https://")[1].split("/")[1]||e.host!==r.split("@")[1].split("/")[0]||e.publicKey!==r.split("@")[0].split("https://")[1])throw new Error("Sentry DSN is not valid");s.captureAxiosError=(e,r,a,o)=>{if(r instanceof t){if(400===r.response?.status||401===r.response?.status)return;r.name=e,s.captureException(r,{...a,captureContext:{...a?.captureContext,extra:{errorResponseData:r.response?.data,errorStatus:r.response?.status,errorHeaders:r.response?.headers,errorRequest:r.request},tags:{...n.baseTags,method:e}}})}else s.captureException(r,a,o)},n.sentryInstance=s}static get sentry(){return n.proxy}static async init({sentry:t,configuration:a}){if(t)return void(n.sentry=t);const o=await import("@sentry/browser");n.sentry=new o.BrowserClient({dsn:r,integrations:[],stackParser:o.defaultStackParser,transport:o.makeFetchTransport}),n.baseTags={projectId:a?.baseConfiguration.publishableKey,sdk:e,sdkVersion:s},n.processQueuedCalls()}static proxy=new Proxy({},{get:(t,s)=>n.sentryInstance&&"function"==typeof n.sentryInstance[s]?(...t)=>n.sentryInstance[s](...t):(...t)=>{n.queuedCalls.push({fn:s,args:t})}});static processQueuedCalls(){n.sentryInstance&&(n.queuedCalls.forEach(({fn:t,args:s})=>{"function"==typeof n.sentryInstance[t]&&n.sentryInstance[t](...s)}),n.queuedCalls=[])}}const{sentry:a}=n;export{n as InternalSentry,a as sentry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BackendApiClients as t}from"../../../packages/internal/openapi-clients/dist/index.js";import{AuthApi as e}from"../api/auth.js";import{EmbeddedWalletApi as i}from"../api/embeddedWallet.js";import{ProxyApi as n}from"../api/proxy.js";import{UserApi as a}from"../api/user.js";import{AuthManager as s}from"../auth/authManager.js";import{StorageKeys as r}from"../storage/istorage.js";import{LazyStorage as o}from"../storage/lazyStorage.js";import h from"../utils/typedEventEmitter.js";import{SDKConfiguration as l}from"./config/config.js";import{PasskeyHandler as c}from"./configuration/passkey.js";import{OpenfortError as d,OpenfortErrorType as u}from"./errors/openfortError.js";import{InternalSentry as g}from"./errors/sentry.js";import{OpenfortInternal as I}from"./openfortInternal.js";class m{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;configuration;eventEmitter;iPasskeyHandler;static globalEventEmitter=null;get auth(){if(!this.authInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.",u.INVALID_CONFIGURATION);return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.",u.INVALID_CONFIGURATION);return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.",u.INVALID_CONFIGURATION);return this.userInstance}get proxy(){if(!this.proxyInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.",u.INVALID_CONFIGURATION);return this.proxyInstance}initializeSynchronously(){try{this.iAuthManager=new s(this.storage),this.openfortInternal=new I(this.storage,this.authManager,this.eventEmitter),this.authInstance=new e(this.storage,this.authManager,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.embeddedWalletInstance=new i(this.storage,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter,this.passkeyHandler),this.userInstance=new a(this.storage,this.authManager,this.validateAndRefreshToken.bind(this)),this.proxyInstance=new n(this.storage,this.backendApiClients,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),async()=>{if(!this.embeddedWalletInstance)throw new d("Embedded wallet not initialized",u.MISSING_SIGNER_ERROR);const t=this.embeddedWalletInstance;return e=>t.signMessage(e,{hashMessage:!0,arrayifyMessage:!0})})}catch(t){throw new d("Openfort SDK synchronous initialization failed",u.INVALID_CONFIGURATION)}}constructor(t){if(this.configuration=new l(t),this.storage=new o(this.configuration.storage),this.eventEmitter=new h,m.globalEventEmitter){["onAuthInit","onAuthSuccess","onAuthFailure","onLogout","onSwitchAccount","onSignedMessage","onEmbeddedWalletCreated","onEmbeddedWalletRecovered","onAuthFlowOpen","onAuthFlowClose","onAuthFlowCancel"].forEach(t=>{this.eventEmitter.on(t,(...e)=>{m.globalEventEmitter?.emit(t,...e)})})}else m.globalEventEmitter=this.eventEmitter;this.iPasskeyHandler=new c({rpId:this.configuration.passkeyRpId,rpName:this.configuration.passkeyRpName,extractableKey:!0}),g.init({configuration:this.configuration}),this.initializeSynchronously(),this.initPromise=Promise.resolve()}static getEventEmitter(){return m.globalEventEmitter||(m.globalEventEmitter=new h),m.globalEventEmitter}async waitForInitialization(){await this.initPromise,await this.ensureAsyncInitialized()}async getAccessToken(){return await this.ensureInitialized(),this.openfortInternal.getAccessToken()}async validateAndRefreshToken(t){return await this.ensureInitialized(),await this.openfortInternal.validateAndRefreshToken(t)}get backendApiClients(){return new t({basePath:this.configuration.backendUrl,accessToken:this.configuration.baseConfiguration.publishableKey})}get authManager(){if(!this.iAuthManager)throw new d("AuthManager not initialized",u.INTERNAL_ERROR);return this.iAuthManager}get passkeyHandler(){return this.iPasskeyHandler}static async isStorageAccessible(t){try{const e=r.TEST,i="openfort_storage_test";t.save(e,i);const n=await t.get(e);return t.remove(e),n===i}catch(t){return!1}}async initializeAsync(){try{if(!await m.isStorageAccessible(this.storage))throw new d("Storage is not accessible",u.INVALID_CONFIGURATION);this.authManager.setBackendApiClients(this.backendApiClients,this.configuration.baseConfiguration.publishableKey)}catch(t){throw new d("Openfort SDK async initialization failed",u.INTERNAL_ERROR)}}async ensureAsyncInitialized(){this.asyncInitPromise||(this.asyncInitPromise=this.initializeAsync()),await this.asyncInitPromise}async ensureInitialized(){await this.initPromise,await this.ensureAsyncInitialized()}}export{m as Openfort};
|
|
1
|
+
import{BackendApiClients as t}from"../../../packages/internal/openapi-clients/dist/index.js";import{AuthApi as e}from"../api/auth.js";import{EmbeddedWalletApi as i}from"../api/embeddedWallet.js";import{ProxyApi as n}from"../api/proxy.js";import{UserApi as a}from"../api/user.js";import{AuthManager as s}from"../auth/authManager.js";import{StorageKeys as r}from"../storage/istorage.js";import{LazyStorage as o}from"../storage/lazyStorage.js";import h from"../utils/typedEventEmitter.js";import{SDKConfiguration as l}from"./config/config.js";import{PasskeyHandler as c}from"./configuration/passkey.js";import{OpenfortError as d,OpenfortErrorType as u}from"./errors/openfortError.js";import{InternalSentry as g}from"./errors/sentry.js";import{OpenfortInternal as I}from"./openfortInternal.js";class m{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;configuration;eventEmitter;iPasskeyHandler;static globalEventEmitter=null;get auth(){if(!this.authInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.",u.INVALID_CONFIGURATION);return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.",u.INVALID_CONFIGURATION);return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.",u.INVALID_CONFIGURATION);return this.userInstance}get proxy(){if(!this.proxyInstance)throw new d("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.",u.INVALID_CONFIGURATION);return this.proxyInstance}initializeSynchronously(){try{this.iAuthManager=new s(this.storage),this.openfortInternal=new I(this.storage,this.authManager,this.eventEmitter),this.authInstance=new e(this.storage,this.authManager,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.embeddedWalletInstance=new i(this.storage,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter,this.passkeyHandler),this.userInstance=new a(this.storage,this.authManager,this.validateAndRefreshToken.bind(this)),this.proxyInstance=new n(this.storage,this.backendApiClients,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),async()=>{if(!this.embeddedWalletInstance)throw new d("Embedded wallet not initialized",u.MISSING_SIGNER_ERROR);const t=this.embeddedWalletInstance;return e=>t.signMessage(e,{hashMessage:!0,arrayifyMessage:!0})})}catch(t){throw new d("Openfort SDK synchronous initialization failed",u.INVALID_CONFIGURATION)}}constructor(t){if(this.configuration=new l(t),this.storage=new o(this.configuration.storage),this.eventEmitter=new h,m.globalEventEmitter){["onAuthInit","onAuthSuccess","onAuthFailure","onLogout","onSwitchAccount","onSignedMessage","onEmbeddedWalletCreated","onEmbeddedWalletRecovered","onAuthFlowOpen","onAuthFlowClose","onAuthFlowCancel"].forEach(t=>{this.eventEmitter.on(t,(...e)=>{m.globalEventEmitter?.emit(t,...e)})})}else m.globalEventEmitter=this.eventEmitter;this.iPasskeyHandler=new c({rpId:this.configuration.passkeyRpId,rpName:this.configuration.passkeyRpName,extractableKey:!0}),g.init({configuration:this.configuration}),this.initializeSynchronously(),this.initPromise=Promise.resolve()}static getEventEmitter(){return m.globalEventEmitter||(m.globalEventEmitter=new h),m.globalEventEmitter}async waitForInitialization(){await this.initPromise,await this.ensureAsyncInitialized()}async getAccessToken(){return await this.ensureInitialized(),this.openfortInternal.getAccessToken()}async validateAndRefreshToken(t){return await this.ensureInitialized(),await this.openfortInternal.validateAndRefreshToken(t)}get backendApiClients(){return new t({basePath:this.configuration.backendUrl,accessToken:this.configuration.baseConfiguration.publishableKey,nativeAppIdentifier:this.configuration.nativeAppIdentifier})}get authManager(){if(!this.iAuthManager)throw new d("AuthManager not initialized",u.INTERNAL_ERROR);return this.iAuthManager}get passkeyHandler(){return this.iPasskeyHandler}static async isStorageAccessible(t){try{const e=r.TEST,i="openfort_storage_test";t.save(e,i);const n=await t.get(e);return t.remove(e),n===i}catch(t){return!1}}async initializeAsync(){try{if(!await m.isStorageAccessible(this.storage))throw new d("Storage is not accessible",u.INVALID_CONFIGURATION);this.authManager.setBackendApiClients(this.backendApiClients,this.configuration.baseConfiguration.publishableKey)}catch(t){throw new d("Openfort SDK async initialization failed",u.INTERNAL_ERROR)}}async ensureAsyncInitialized(){this.asyncInitPromise||(this.asyncInitPromise=this.initializeAsync()),await this.asyncInitPromise}async ensureInitialized(){await this.initPromise,await this.ensureAsyncInitialized()}}export{m as Openfort};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Authentication as t}from"./configuration/authentication.js";import{OpenfortError as e,OpenfortErrorType as r}from"./errors/openfortError.js";import{TokenType as
|
|
1
|
+
import{Authentication as t}from"./configuration/authentication.js";import{OpenfortError as e,OpenfortErrorType as r}from"./errors/openfortError.js";import{TokenType as o,OpenfortEvents as i}from"../types/types.js";import"human-id";import{SDKConfiguration as s}from"./config/config.js";import"../storage/istorage.js";import{debugLog as a}from"../utils/debug.js";import"eventemitter3";import"../wallets/evm/JsonRpcError.js";import"../wallets/evm/types.js";import"../wallets/evm/provider/eip6963.js";import"./errors/sentry.js";import"../wallets/messaging/browserMessenger/backwardCompatibility.js";import"../wallets/types.js";import"jose";import{singlePromise as n}from"../utils/promiseUtils.js";class h{storage;authManager;eventEmitter;constructor(t,e,r){this.storage=t,this.authManager=e,this.eventEmitter=r}async getThirdPartyAuthToken(){const i=s.getInstance();if(!i?.thirdPartyAuth)throw new e("No third party configuration found",r.INTERNAL_ERROR);const{getAccessToken:a,provider:n}=i.thirdPartyAuth;if(!a||!n)throw new e("Third party is not configured. Please configure getAccessToken and thirdPartyAuthProvider in your Openfort instance",r.INVALID_CONFIGURATION);const h=await a();if(!h)throw new e("Could not get access token",r.AUTHENTICATION_ERROR);let c=(await t.fromStorage(this.storage))?.player;if(!c){const t=await this.authManager.authenticateThirdParty(n,h,o.ID_TOKEN);c=t?.id}return new t("third_party",h,c,null,n,o.ID_TOKEN).save(this.storage),h}async getAccessToken(){if(s.getInstance()?.thirdPartyAuth)return this.getThirdPartyAuthToken();return(await t.fromStorage(this.storage))?.token??null}async validateAndRefreshToken(o){return n(async()=>{if(s.getInstance()?.thirdPartyAuth)return void await this.getThirdPartyAuthToken();const n=await t.fromStorage(this.storage);if(!n)throw new e("Must be logged in to validate and refresh token",r.NOT_LOGGED_IN_ERROR);let h;a("validating credentials...");try{h=await this.authManager.validateCredentials(n,o)}catch(e){throw t.clear(this.storage),this.eventEmitter.emit(i.ON_LOGOUT),e}if(!h.player)throw new e("No user found in credentials",r.INTERNAL_ERROR);h.accessToken!==n.token&&(a("tokens refreshed"),new t("jwt",h.accessToken,h.player,h.refreshToken).save(this.storage))},"openfort.validateAndRefreshToken")}}export{h as OpenfortInternal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={},l=(l,t)=>{let n=e[t];return n||(n=l().finally(()=>{delete e[t],n=null}),e[t]=n),n};export{l as singlePromise};
|
package/dist/sdk/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="0.10.
|
|
1
|
+
const o="0.10.28",t="@openfort/openfort-js";export{t as PACKAGE,o as VERSION};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Account as t}from"../../core/configuration/account.js";import{Authentication as e}from"../../core/configuration/authentication.js";import{OpenfortEvents as a,AccountTypeEnum as
|
|
1
|
+
import{Account as t}from"../../core/configuration/account.js";import{Authentication as e}from"../../core/configuration/authentication.js";import{OpenfortEvents as a,AccountTypeEnum as s}from"../../types/types.js";import{defaultChainRpcs as i}from"../../utils/chains/index.js";import{numberToHex as r}from"../../utils/crypto.js";import o from"../../utils/typedEventEmitter.js";import{addEthereumChain as n}from"./addEthereumChain.js";import{estimateGas as c}from"./estimateGas.js";import{getCallStatus as h}from"./getCallsStatus.js";import{JsonRpcError as d,ProviderErrorCode as p,RpcErrorCode as m}from"./JsonRpcError.js";import{personalSign as w}from"./personalSign.js";import{registerSession as u}from"./registerSession.js";import{revokeSession as l}from"./revokeSession.js";import{sendCallsSync as g}from"./sendCallSync.js";import{sendCalls as f}from"./sendCalls.js";import{signTypedDataV4 as S}from"./signTypedDataV4.js";import{ProviderEvent as A}from"./types.js";import{prepareEOATransaction as R,parseTransactionRequest as _}from"./walletHelpers.js";class y{#t;#e;#a;#s;updatePolicy(t){this.#e=t}#i;#r;#o=null;#n;isOpenfort=!0;#c;constructor({storage:t,backendApiClients:e,openfortEventEmitter:s,policyId:i,ensureSigner:r,chains:n,validateAndRefreshSession:c}){this.#c=r,this.#t=t,this.#a=n,this.#e=i,this.#i=c,this.#n=e,this.#r=new o,s.on(a.ON_LOGOUT,this.#h),s.on(a.ON_SWITCH_ACCOUNT,this.#d)}#p=async()=>(this.#s||(this.#s=await this.#c()),this.#s);#h=async()=>{this.#s=void 0,this.#r.emit(A.ACCOUNTS_CHANGED,[])};#d=async t=>{this.#r.emit(A.ACCOUNTS_CHANGED,[t])};async getRpcProvider(){if(!this.#o){const e=await t.fromStorage(this.#t),a=e?.chainId||8453;await import("@ethersproject/providers").then(t=>{const e=this.#a?this.#a[a]:void 0;this.#o=new t.StaticJsonRpcProvider(e??i[a])})}if(!this.#o)throw new Error("RPC provider not initialized");return this.#o}async#m(a){switch(a.method){case"eth_accounts":{const e=await t.fromStorage(this.#t);return e?[e.address]:[]}case"eth_requestAccounts":{const e=await t.fromStorage(this.#t);if(e)return this.#r.emit(A.ACCOUNTS_CONNECT,{chainId:String(e.chainId)}),[e.address];throw new d(p.UNAUTHORIZED,"Unauthorized - must be authenticated and configured with a signer.")}case"eth_signTransaction":{const s=await t.fromStorage(this.#t),i=await this.#p(),r=await e.fromStorage(this.#t);if(!s||!r)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const o=await this.getRpcProvider(),{chainId:n}=await o.detectNetwork(),[c]=a.params||[];c.chainId||(c.chainId=n.toString());const h=_(c),{serialize:m}=await import("@ethersproject/transactions"),w=t=>({legacy:0,eip2930:1,eip1559:2}[t]),{gas:u,...l}=h,g={...l,gasLimit:u,to:h.to??void 0,type:w(h.type)},f=m(g),{keccak256:S}=await import("@ethersproject/keccak256"),A=S(f);await this.#i();const R=await i.sign(A,!1,!1),{splitSignature:y}=await import("@ethersproject/bytes");return m(g,y(R))}case"eth_sendTransaction":{const i=await t.fromStorage(this.#t),r=await this.#p(),o=await e.fromStorage(this.#t);if(!i||!o)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");if(await this.#i(),i?.accountType===s.EOA){const[t]=a.params||[],e=await this.getRpcProvider(),s=await R(t,e,i.address),r=await this.#m({method:"eth_signTransaction",params:[s]});return this.#m({method:"eth_sendRawTransaction",params:[r]})}return(await g({params:a.params||[],signer:r,account:i,authentication:o,backendClient:this.#n,policyId:this.#e})).receipt.transactionHash}case"eth_sendRawTransactionSync":{const i=await t.fromStorage(this.#t),r=await this.#p(),o=await e.fromStorage(this.#t);if(!i||!o)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");if(i?.accountType===s.EOA)throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`);return await this.#i(),await g({params:a.params||[],signer:r,account:i,authentication:o,backendClient:this.#n,policyId:this.#e})}case"eth_estimateGas":{const s=await t.fromStorage(this.#t),i=await e.fromStorage(this.#t);if(!s||!i)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await c({params:a.params||[],account:s,authentication:i,backendClient:this.#n,policyId:this.#e})}case"eth_signTypedData":case"eth_signTypedData_v4":{const e=await t.fromStorage(this.#t),s=await this.#p();if(!e)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#i();const i=await this.getRpcProvider();return await S({method:a.method,params:a.params||[],signer:s,implementationType:e.implementationType||e.type,rpcProvider:i,account:e})}case"personal_sign":{const e=await t.fromStorage(this.#t);if(!e)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const s=await this.#p();return await this.#i(),await w({params:a.params||[],signer:s,account:e})}case"eth_chainId":{const t=await this.getRpcProvider(),{chainId:e}=await t.detectNetwork();return r(e)}case"wallet_switchEthereumChain":{const t=await this.#p();if(!a.params||!Array.isArray(a.params)||0===a.params.length)throw new d(m.INVALID_PARAMS,"Invalid parameters for wallet_switchEthereumChain");await this.#i();try{const e=parseInt(a.params[0].chainId,16);await t.switchChain({chainId:e}),await import("@ethersproject/providers").then(t=>{const a=this.#a?this.#a[e]:void 0;this.#o=new t.StaticJsonRpcProvider(a??i[e])})}catch(t){const e=t;throw new d(m.INTERNAL_ERROR,`Failed to switch chain: ${e.message}`)}return null}case"wallet_addEthereumChain":{await this.#p();const t=await this.getRpcProvider();return await n({params:a.params||[],rpcProvider:t,storage:this.#t})}case"wallet_showCallsStatus":return null;case"wallet_getCallsStatus":{const i=await t.fromStorage(this.#t);if(i?.accountType===s.EOA)throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`);const r=await e.fromStorage(this.#t);if(!i||!r)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await h({params:a.params||{},authentication:r,backendClient:this.#n})}case"wallet_sendCalls":{const i=await t.fromStorage(this.#t);if(i?.accountType===s.EOA)throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`);const r=await this.#p(),o=await e.fromStorage(this.#t);if(!i||!o)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#i();return await f({params:a.params?a.params[0].calls:[],signer:r,account:i,authentication:o,backendClient:this.#n,policyId:this.#e})}case"wallet_grantPermissions":{const i=await t.fromStorage(this.#t);if(i?.accountType===s.EOA)throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`);const r=await this.#p(),o=await e.fromStorage(this.#t);if(!i||!o)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await u({params:a.params||[],signer:r,account:i,authentication:o,backendClient:this.#n,policyId:this.#e})}case"wallet_revokePermissions":{const s=await t.fromStorage(this.#t),i=await this.#p(),r=await e.fromStorage(this.#t);if(!s||!r)throw new d(p.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await l({params:a.params||[],signer:i,account:s,authentication:r,backendClient:this.#n})}case"wallet_getCapabilities":{const e=await t.fromStorage(this.#t);if(e?.accountType===s.EOA)throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`);const i=await this.getRpcProvider(),{chainId:o}=await i.detectNetwork();return{[r(o)]:{permissions:{supported:!0,signerTypes:["account","key"],keyTypes:["secp256k1"],permissionTypes:["contract-calls"]},paymasterService:{supported:!0},atomicBatch:{supported:!0}}}}case"eth_gasPrice":case"eth_getBalance":case"eth_sendRawTransaction":case"eth_getCode":case"eth_getStorageAt":case"eth_call":case"eth_blockNumber":case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getTransactionByHash":case"eth_getTransactionReceipt":case"eth_getTransactionCount":return(await this.getRpcProvider()).send(a.method,a.params||[]);default:throw new d(p.UNSUPPORTED_METHOD,`${a.method}: Method not supported`)}}async request(t){try{return this.#m(t)}catch(t){if(t instanceof d)throw t;if(t instanceof Error)throw new d(m.INTERNAL_ERROR,t.message);throw new d(m.INTERNAL_ERROR,"Internal error")}}on(t,e){this.#r.on(t,e)}removeListener(t,e){this.#r.off(t,e)}}export{y as EvmProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isMessage as e,isDestroyMessage as s}from"./guards.js";import o from"./namespace.js";import n from"./once.js";import t from"./PenpalError.js";import r from"./shakeHands.js";const a=new WeakSet,m=({messenger:m,methods:c={},timeout:i,channel:d,log:h})=>{if(!m)throw new t("INVALID_ARGUMENT","messenger must be defined");if(a.has(m))throw new t("INVALID_ARGUMENT","A messenger can only be used for a single connection");a.add(m);const l=[m.destroy],f=n(e=>{if(e){const e={namespace:o,channel:d,type:"DESTROY"};try{m.sendMessage(e)}catch(e){}}for(const e of l)e();h?.("Connection destroyed")}),g=s=>e(s)&&s.channel===d;return{promise:(async()=>{try{m.initialize({log:h,validateReceivedMessage:g}),m.addMessageHandler(e=>{s(e)&&f(!1)});const{remoteProxy:e,destroy:o}=await r({messenger:m,methods:c,timeout:i,channel:d,log:h});return l.push(o),e}catch(e){throw f(!0),e}})(),destroy:()=>{f(!0)}}};export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomUUID as e}from"../../../utils/crypto.js";import{DEPRECATED_PENPAL_PARTICIPANT_ID as t}from"./backwardCompatibility.js";import s from"./connectCallHandler.js";import
|
|
1
|
+
import{randomUUID as e}from"../../../utils/crypto.js";import{DEPRECATED_PENPAL_PARTICIPANT_ID as t}from"./backwardCompatibility.js";import s from"./connectCallHandler.js";import r from"./connectRemoteProxy.js";import n from"./getPromiseWithResolvers.js";import{isSynMessage as o,isAck1Message as a,isAck2Message as m}from"./guards.js";import{extractMethodPathsFromMethods as i}from"./methodSerialization.js";import c from"./namespace.js";import d from"./PenpalError.js";const p=({messenger:p,methods:h,timeout:l,channel:f,log:S})=>{const g=e();let u;const I=[];let y=!1;const A=i(h),{promise:N,resolve:C,reject:j}=n(),M=setTimeout(()=>{j(new d("CONNECTION_TIMEOUT",`Connection timed out after ${l}ms`))},l),R=()=>{for(const e of I)e()},T=()=>{if(y)return;I.push(s(p,h,f,S));const{remoteProxy:e,destroy:t}=r(p,f,S);I.push(t),clearTimeout(M),y=!0,C({remoteProxy:e,destroy:R})},k=()=>{const e={namespace:c,type:"SYN",channel:f,participantId:g};S?.("Sending handshake SYN",e);try{p.sendMessage(e)}catch(e){j(new d("TRANSMISSION_FAILED",e.message))}},v=e=>{o(e)&&(e=>{if(S?.("Received handshake SYN",e),e.participantId===u&&u!==t)return;if(u=e.participantId,k(),!(g>u||u===t))return;const s={namespace:c,channel:f,type:"ACK1",methodPaths:A};S?.("Sending handshake ACK1",s);try{p.sendMessage(s)}catch(e){j(new d("TRANSMISSION_FAILED",e.message))}})(e),a(e)&&(e=>{S?.("Received handshake ACK1",e);const t={namespace:c,channel:f,type:"ACK2"};S?.("Sending handshake ACK2",t);try{p.sendMessage(t)}catch(e){return void j(new d("TRANSMISSION_FAILED",e.message))}T()})(e),m(e)&&(e=>{S?.("Received handshake ACK2",e),T()})(e)};return p.addMessageHandler(v),I.push(()=>p.removeMessageHandler(v)),k(),N};export{p as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfort/openfort-js",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.28",
|
|
4
4
|
"author": "Openfort (https://www.openfort.io)",
|
|
5
5
|
"bugs": "https://github.com/openfort-xyz/openfort-js/issues",
|
|
6
6
|
"repository": "openfort-xyz/openfort-js.git",
|
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
"@ethersproject/providers": "^5.8.0",
|
|
25
25
|
"@ethersproject/transactions": "^5.8.0",
|
|
26
26
|
"@ethersproject/keccak256": "^5.8.0",
|
|
27
|
-
"@openfort/shield-js": "^0.1.
|
|
27
|
+
"@openfort/shield-js": "^0.1.29",
|
|
28
28
|
"@sentry/browser": "^9.15.0",
|
|
29
29
|
"@sentry/core": "^9.15.0",
|
|
30
|
-
"axios": "^1.
|
|
30
|
+
"axios": "^1.12.2",
|
|
31
|
+
"axios-retry": "^4.5.0",
|
|
31
32
|
"eventemitter3": "5.0.1",
|
|
32
33
|
"human-id": "^4.1.1",
|
|
33
34
|
"jose": "^5.2.2"
|
|
@@ -41,15 +42,15 @@
|
|
|
41
42
|
}
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@rollup/plugin-commonjs": "^
|
|
45
|
+
"@rollup/plugin-commonjs": "^25.0.0",
|
|
45
46
|
"@rollup/plugin-json": "^6.0.0",
|
|
46
47
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
47
48
|
"@rollup/plugin-replace": "^5.0.2",
|
|
48
49
|
"@rollup/plugin-terser": "^0.4.3",
|
|
49
|
-
"@rollup/plugin-typescript": "^11.
|
|
50
|
+
"@rollup/plugin-typescript": "^11.1.0",
|
|
50
51
|
"@types/jest": "^29.4.3",
|
|
51
52
|
"jest": "^29.4.3",
|
|
52
|
-
"rollup": "^
|
|
53
|
+
"rollup": "^4.0.0",
|
|
53
54
|
"rollup-plugin-dts": "^5.3.0",
|
|
54
55
|
"rollup-plugin-visualizer": "^5.14.0",
|
|
55
56
|
"typescript": "^5.8.3",
|