@openfort/openfort-js 0.9.5 → 0.9.6
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/auth.js +1 -1
- package/dist/cjs/sdk/src/api/embeddedWallet.js +1 -1
- package/dist/cjs/sdk/src/core/configuration/account.js +1 -1
- package/dist/cjs/sdk/src/core/errors/openfortError.js +1 -1
- package/dist/cjs/sdk/src/core/openfort.js +1 -1
- package/dist/cjs/sdk/src/index.js +1 -1
- package/dist/cjs/sdk/src/types/types.js +1 -1
- package/dist/cjs/sdk/src/version.js +1 -1
- package/dist/cjs/sdk/src/wallets/embedded.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/evmProvider.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/personalSign.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/registerSession.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/revokeSession.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/sendCalls.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/signTypedDataV4.js +1 -1
- package/dist/cjs/sdk/src/wallets/evm/walletHelpers.js +1 -1
- package/dist/cjs/sdk/src/wallets/iframeManager.js +1 -1
- package/dist/cjs/sdk/src/wallets/types.js +1 -1
- package/dist/index.d.ts +498 -270
- package/dist/packages/internal/openapi-clients/dist/index.js +1 -1
- package/dist/sdk/src/api/auth.js +1 -1
- package/dist/sdk/src/api/embeddedWallet.js +1 -1
- package/dist/sdk/src/core/configuration/account.js +1 -1
- package/dist/sdk/src/core/errors/openfortError.js +1 -1
- package/dist/sdk/src/core/openfort.js +1 -1
- package/dist/sdk/src/index.js +1 -1
- package/dist/sdk/src/types/types.js +1 -1
- package/dist/sdk/src/version.js +1 -1
- package/dist/sdk/src/wallets/embedded.js +1 -1
- package/dist/sdk/src/wallets/evm/evmProvider.js +1 -1
- package/dist/sdk/src/wallets/evm/personalSign.js +1 -1
- package/dist/sdk/src/wallets/evm/registerSession.js +1 -1
- package/dist/sdk/src/wallets/evm/revokeSession.js +1 -1
- package/dist/sdk/src/wallets/evm/sendCalls.js +1 -1
- package/dist/sdk/src/wallets/evm/signTypedDataV4.js +1 -1
- package/dist/sdk/src/wallets/evm/walletHelpers.js +1 -1
- package/dist/sdk/src/wallets/iframeManager.js +1 -1
- package/dist/sdk/src/wallets/types.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("axios"),t=require("axios-retry");const n="https://api.openfort.io".replace(/\/+$/,"");class s{basePath;axios;configuration;constructor(t,s=n,a=e){this.basePath=s,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,n){if(null==n)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const n="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+n}};function c(e,t,n=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,n)):Object.keys(t).forEach(s=>c(e,t[s],`${n}${""!==n?".":""}${s}`)):e.has(n)?e.append(n,t):e.set(n,t))}const h=function(e,...t){const n=new URLSearchParams(e.search);c(n,t),e.search=n.toString()},u=function(e,t,n){const s="string"!=typeof e;return(s&&n&&n.isJsonMime?n.isJsonMime(t.headers["Content-Type"]):s)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,n,s){return(a=t,i=n)=>{const o={...e.options,url:(s?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const s=function(e){return{cancelTransferOwnership:async(t,n,s={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",n);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},completeRecovery:async(t,n,s={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",n);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},createAccount:async(t,n={})=>{o("createAccount","createAccountRequest",t);const s=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},createAccountV2:async(t,n={})=>{o("createAccountV2","accountCreateRequest",t);const s=new URL("/v2/accounts",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},deployAccount:async(t,n,s={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",n);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},disableAccount:async(t,n={})=>{o("disableAccount","id",t);const s="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}},getAccount:async(t,n,s={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getAccountV2:async(t,n={})=>{o("getAccountV2","accountId",t);const s="/v2/accounts/{accountId}".replace("{accountId}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},getAccounts:async(t,n,s,a,o,c,u={})=>{const l=new URL("/v1/accounts",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==t&&(w.limit=t),void 0!==n&&(w.skip=n),void 0!==s&&(w.order=s),void 0!==a&&(w.player=a),void 0!==o&&(w.address=o),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},listAccountsV2:async(t,n,s,a,o={})=>{const r=new URL("/v2/accounts",i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...o},l={};void 0!==t&&(l.limit=t),void 0!==n&&(l.skip=n),void 0!==s&&(l.order=s),void 0!==a&&(l.accountType=a),h(r,l);let p=c&&c.headers?c.headers:{};return u.headers={...p,...o.headers},{url:d(r),options:u}},requestTransferOwnership:async(t,n,s={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",n);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},signPayload:async(t,n,s={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",n);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},startRecovery:async(t,n,s={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",n);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}},syncAccount:async(t,n={})=>{o("syncAccount","id",t);const s="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(s,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...n},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...n.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await s.cancelTransferOwnership(a,i,o);return l(r,e,n,t)},async completeRecovery(a,i,o){const r=await s.completeRecovery(a,i,o);return l(r,e,n,t)},async createAccount(a,i){const o=await s.createAccount(a,i);return l(o,e,n,t)},async createAccountV2(a,i){const o=await s.createAccountV2(a,i);return l(o,e,n,t)},async deployAccount(a,i,o){const r=await s.deployAccount(a,i,o);return l(r,e,n,t)},async disableAccount(a,i){const o=await s.disableAccount(a,i);return l(o,e,n,t)},async getAccount(a,i,o){const r=await s.getAccount(a,i,o);return l(r,e,n,t)},async getAccountV2(a,i){const o=await s.getAccountV2(a,i);return l(o,e,n,t)},async getAccounts(a,i,o,r,c,h,u){const d=await s.getAccounts(a,i,o,r,c,h,u);return l(d,e,n,t)},async listAccountsV2(a,i,o,r,c){const h=await s.listAccountsV2(a,i,o,r,c);return l(h,e,n,t)},async requestTransferOwnership(a,i,o){const r=await s.requestTransferOwnership(a,i,o);return l(r,e,n,t)},async signPayload(a,i,o){const r=await s.signPayload(a,i,o);return l(r,e,n,t)},async startRecovery(a,i,o){const r=await s.startRecovery(a,i,o);return l(r,e,n,t)},async syncAccount(a,i){const o=await s.syncAccount(a,i);return l(o,e,n,t)}}};class y extends s{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}createAccountV2(e,t){return p(this.configuration).createAccountV2(e.accountCreateRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.accountId,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}listAccountsV2(e={},t){return p(this.configuration).listAccountsV2(e.limit,e.skip,e.order,e.accountType,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const s=function(e){return{authenticateSIWE:async(t,n={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getJwks:async(t,n={})=>{o("getJwks","publishableKey",t);const s="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(s,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...n};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...n.headers},{url:d(a),options:c}},initOAuth:async(t,n,s={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,n,s={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,n,s={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,n,s={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,n={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const s=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},linkThirdParty:async(t,n,s={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...s},l={};null!=n&&(l["x-game"]=String(n)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,n,s={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,n,s={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,n={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const s=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},logout:async(t,n={})=>{o("logout","logoutRequest",t);const s=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},me:async(t={})=>{const n=new URL("/iam/v1/me",i);let s;e&&(s=e.baseOptions);const a={method:"GET",...s,...t};h(n,{});let o=s&&s.headers?s.headers:{};return a.headers={...o,...t.headers},{url:d(n),options:a}},poolOAuth:async(t,n={})=>{o("poolOAuth","key",t);const s=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(s,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...n.headers},{url:d(s),options:c}},refresh:async(t,n={})=>{o("refresh","refreshTokenRequest",t);const s=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},registerGuest:async(t,n={})=>{const s=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...n},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(s,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...n.headers},{url:d(s),options:o}},requestEmailVerification:async(t,n={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const s=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},requestResetPassword:async(t,n={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const s=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},resetPassword:async(t,n={})=>{o("resetPassword","resetPasswordRequest",t);const s=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},signupEmailPassword:async(t,n,s={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,n,s={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["x-game"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,n={})=>{o("unlinkEmail","unlinkEmailRequest",t);const s=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkOAuth:async(t,n={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const s=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},unlinkSIWE:async(t,n={})=>{o("unlinkSIWE","sIWERequest",t);const s=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...n},c={"Content-Type":"application/json"};h(s,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...n.headers},r.data=u(t,r,e),{url:d(s),options:r}},verifyEmail:async(t,n={})=>{o("verifyEmail","verifyEmailRequest",t);const s=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},verifyOAuthToken:async(t,n={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const s=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await s.authenticateSIWE(a,i);return l(o,e,n,t)},async getJwks(a,i){const o=await s.getJwks(a,i);return l(o,e,n,t)},async initOAuth(a,i,o){const r=await s.initOAuth(a,i,o);return l(r,e,n,t)},async initSIWE(a,i,o){const r=await s.initSIWE(a,i,o);return l(r,e,n,t)},async linkEmail(a,i,o){const r=await s.linkEmail(a,i,o);return l(r,e,n,t)},async linkOAuth(a,i,o){const r=await s.linkOAuth(a,i,o);return l(r,e,n,t)},async linkSIWE(a,i){const o=await s.linkSIWE(a,i);return l(o,e,n,t)},async linkThirdParty(a,i,o){const r=await s.linkThirdParty(a,i,o);return l(r,e,n,t)},async loginEmailPassword(a,i,o){const r=await s.loginEmailPassword(a,i,o);return l(r,e,n,t)},async loginOIDC(a,i,o){const r=await s.loginOIDC(a,i,o);return l(r,e,n,t)},async loginWithIdToken(a,i){const o=await s.loginWithIdToken(a,i);return l(o,e,n,t)},async logout(a,i){const o=await s.logout(a,i);return l(o,e,n,t)},async me(a){const i=await s.me(a);return l(i,e,n,t)},async poolOAuth(a,i){const o=await s.poolOAuth(a,i);return l(o,e,n,t)},async refresh(a,i){const o=await s.refresh(a,i);return l(o,e,n,t)},async registerGuest(a,i){const o=await s.registerGuest(a,i);return l(o,e,n,t)},async requestEmailVerification(a,i){const o=await s.requestEmailVerification(a,i);return l(o,e,n,t)},async requestResetPassword(a,i){const o=await s.requestResetPassword(a,i);return l(o,e,n,t)},async resetPassword(a,i){const o=await s.resetPassword(a,i);return l(o,e,n,t)},async signupEmailPassword(a,i,o){const r=await s.signupEmailPassword(a,i,o);return l(r,e,n,t)},async thirdParty(a,i,o){const r=await s.thirdParty(a,i,o);return l(r,e,n,t)},async unlinkEmail(a,i){const o=await s.unlinkEmail(a,i);return l(o,e,n,t)},async unlinkOAuth(a,i){const o=await s.unlinkOAuth(a,i);return l(o,e,n,t)},async unlinkSIWE(a,i){const o=await s.unlinkSIWE(a,i);return l(o,e,n,t)},async verifyEmail(a,i){const o=await s.verifyEmail(a,i);return l(o,e,n,t)},async verifyOAuthToken(a,i){const o=await s.verifyOAuthToken(a,i);return l(o,e,n,t)}}};class w extends s{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const s=function(e){return{createSession:async(t,n,s={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,n,s,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==n&&(w.limit=n),void 0!==s&&(w.skip=s),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,n,s={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},revokeSession:async(t,n,s={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,n,s={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",n);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await s.createSession(a,i,o);return l(r,e,n,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await s.getPlayerSessions(a,i,o,r,c,h);return l(u,e,n,t)},async getSession(a,i,o){const r=await s.getSession(a,i,o);return l(r,e,n,t)},async revokeSession(a,i,o){const r=await s.revokeSession(a,i,o);return l(r,e,n,t)},async signatureSession(a,i,o){const r=await s.signatureSession(a,i,o);return l(r,e,n,t)}}};class P extends s{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const s=function(e){return{createTransactionIntent:async(t,n,s={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...s},p={};await r(p,e),null!=n&&(p["X-Behalf-Of-Project"]=String(n)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...s.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,n={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const s=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...n},l={};await r(l,e),l["Content-Type"]="application/json",h(s,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(s),options:c}},getTransactionIntent:async(t,n,s={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...s},p={},y={};await r(p,e),n&&(y.expand=n),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...s.headers},{url:d(c),options:l}},getTransactionIntents:async(t,n,s,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==n&&(R.skip=n),void 0!==s&&(R.order=s),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,n,s={})=>{o("signature","id",t),o("signature","signatureRequest",n);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...s},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...s.headers},p.data=u(n,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await s.createTransactionIntent(a,i,o);return l(r,e,n,t)},async estimateTransactionIntentCost(a,i){const o=await s.estimateTransactionIntentCost(a,i);return l(o,e,n,t)},async getTransactionIntent(a,i,o){const r=await s.getTransactionIntent(a,i,o);return l(r,e,n,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await s.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,n,t)},async signature(a,i,o){const r=await s.signature(a,i,o);return l(r,e,n,t)}}};class T extends s{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};exports.BackendApiClients=class{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(n){const s=e.create();t(s,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:n.basePath,accessToken:n.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,s),this.accountsApi=new y(this.config.backend,void 0,s),this.sessionsApi=new P(this.config.backend,void 0,s),this.authenticationApi=new w(this.config.backend,void 0,s)}},exports.createConfig=f;
|
|
1
|
+
"use strict";var e=require("axios"),t=require("axios-retry");const s="https://api.openfort.xyz".replace(/\/+$/,"");class n{basePath;axios;configuration;constructor(t,n=s,a=e){this.basePath=n,this.axios=a,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}class a extends Error{field;constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}const i="https://example.com",o=function(e,t,s){if(null==s)throw new a(t,`Required parameter ${t} was null or undefined when calling ${e}.`)},r=async function(e,t){if(t&&t.accessToken){const s="function"==typeof t.accessToken?await t.accessToken():await t.accessToken;e.Authorization="Bearer "+s}};function c(e,t,s=""){null!=t&&("object"==typeof t?Array.isArray(t)?t.forEach(t=>c(e,t,s)):Object.keys(t).forEach(n=>c(e,t[n],`${s}${""!==s?".":""}${n}`)):e.has(s)?e.append(s,t):e.set(s,t))}const h=function(e,...t){const s=new URLSearchParams(e.search);c(s,t),e.search=s.toString()},u=function(e,t,s){const n="string"!=typeof e;return(n&&s&&s.isJsonMime?s.isJsonMime(t.headers["Content-Type"]):n)?JSON.stringify(void 0!==e?e:{}):e||""},d=function(e){return e.pathname+e.search+e.hash},l=function(e,t,s,n){return(a=t,i=s)=>{const o={...e.options,url:(n?.basePath||a.defaults.baseURL||i)+e.url};return a.request(o)}},p=function(t){const n=function(e){return{cancelTransferOwnership:async(t,s,n={})=>{o("cancelTransferOwnership","id",t),o("cancelTransferOwnership","cancelTransferOwnershipRequest",s);const a="/v1/accounts/{id}/cancel_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},completeRecovery:async(t,s,n={})=>{o("completeRecovery","id",t),o("completeRecovery","completeRecoveryRequest",s);const a="/v1/accounts/{id}/complete_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},createAccount:async(t,s={})=>{o("createAccount","createAccountRequest",t);const n=new URL("/v1/accounts",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},deployAccount:async(t,s,n={})=>{o("deployAccount","id",t),o("deployAccount","deployRequest",s);const a="/v1/accounts/{id}/deploy".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},disableAccount:async(t,s={})=>{o("disableAccount","id",t);const n="/v1/accounts/{id}/disable".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccount:async(t,s,n={})=>{o("getAccount","id",t);const a="/v1/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getAccountV2:async(t,s={})=>{o("getAccountV2","id",t);const n="/v2/accounts/{id}".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"GET",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}},getAccounts:async(t,s,n,a,o,c,u,l={})=>{const p=new URL("/v1/accounts",i);let y;e&&(y=e.baseOptions);const g={method:"GET",...y,...l},w={},m={};await r(w,e),void 0!==t&&(m.limit=t),void 0!==s&&(m.skip=s),void 0!==n&&(m.order=n),void 0!==a&&(m.chainId=a),void 0!==o&&(m.player=o),void 0!==c&&(m.address=c),u&&(m.expand=u),h(p,m);let P=y&&y.headers?y.headers:{};return g.headers={...w,...P,...l.headers},{url:d(p),options:g}},getAccountsV2:async(t,s,n,a,o,c,u,l,p={})=>{const y=new URL("/v2/accounts",i);let g;e&&(g=e.baseOptions);const w={method:"GET",...g,...p},m={},P={};await r(m,e),void 0!==t&&(P.limit=t),void 0!==s&&(P.skip=s),void 0!==n&&(P.order=n),void 0!==a&&(P.chainId=a),void 0!==o&&(P.user=o),void 0!==c&&(P.chainType=c),void 0!==u&&(P.accountType=u),void 0!==l&&(P.address=l),h(y,P);let R=g&&g.headers?g.headers:{};return w.headers={...m,...R,...p.headers},{url:d(y),options:w}},getSignerIdByAddress:async(t,s={})=>{o("getSignerIdByAddress","address",t);const n=new URL("/v2/accounts/signer",i);let a;e&&(a=e.baseOptions);const c={method:"GET",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.address=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},requestTransferOwnership:async(t,s,n={})=>{o("requestTransferOwnership","id",t),o("requestTransferOwnership","transferOwnershipRequest",s);const a="/v1/accounts/{id}/request_transfer_ownership".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},signPayload:async(t,s,n={})=>{o("signPayload","id",t),o("signPayload","signPayloadRequest",s);const a="/v1/accounts/{id}/sign_payload".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},startRecovery:async(t,s,n={})=>{o("startRecovery","id",t),o("startRecovery","startRecoveryRequest",s);const a="/v1/accounts/{id}/start_recovery".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}},switchChainV2:async(t,s={})=>{o("switchChainV2","switchChainQueriesV2",t);const n=new URL("/v2/accounts/switch-chain",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},syncAccount:async(t,s={})=>{o("syncAccount","id",t);const n="/v1/accounts/{id}/sync".replace("{id}",encodeURIComponent(String(t))),a=new URL(n,i);let c;e&&(c=e.baseOptions);const u={method:"POST",...c,...s},l={};await r(l,e),h(a,{});let p=c&&c.headers?c.headers:{};return u.headers={...l,...p,...s.headers},{url:d(a),options:u}}}}(t);return{async cancelTransferOwnership(a,i,o){const r=await n.cancelTransferOwnership(a,i,o);return l(r,e,s,t)},async completeRecovery(a,i,o){const r=await n.completeRecovery(a,i,o);return l(r,e,s,t)},async createAccount(a,i){const o=await n.createAccount(a,i);return l(o,e,s,t)},async deployAccount(a,i,o){const r=await n.deployAccount(a,i,o);return l(r,e,s,t)},async disableAccount(a,i){const o=await n.disableAccount(a,i);return l(o,e,s,t)},async getAccount(a,i,o){const r=await n.getAccount(a,i,o);return l(r,e,s,t)},async getAccountV2(a,i){const o=await n.getAccountV2(a,i);return l(o,e,s,t)},async getAccounts(a,i,o,r,c,h,u,d){const p=await n.getAccounts(a,i,o,r,c,h,u,d);return l(p,e,s,t)},async getAccountsV2(a,i,o,r,c,h,u,d,p){const y=await n.getAccountsV2(a,i,o,r,c,h,u,d,p);return l(y,e,s,t)},async getSignerIdByAddress(a,i){const o=await n.getSignerIdByAddress(a,i);return l(o,e,s,t)},async requestTransferOwnership(a,i,o){const r=await n.requestTransferOwnership(a,i,o);return l(r,e,s,t)},async signPayload(a,i,o){const r=await n.signPayload(a,i,o);return l(r,e,s,t)},async startRecovery(a,i,o){const r=await n.startRecovery(a,i,o);return l(r,e,s,t)},async switchChainV2(a,i){const o=await n.switchChainV2(a,i);return l(o,e,s,t)},async syncAccount(a,i){const o=await n.syncAccount(a,i);return l(o,e,s,t)}}};class y extends n{cancelTransferOwnership(e,t){return p(this.configuration).cancelTransferOwnership(e.id,e.cancelTransferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}completeRecovery(e,t){return p(this.configuration).completeRecovery(e.id,e.completeRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}createAccount(e,t){return p(this.configuration).createAccount(e.createAccountRequest,t).then(e=>e(this.axios,this.basePath))}deployAccount(e,t){return p(this.configuration).deployAccount(e.id,e.deployRequest,t).then(e=>e(this.axios,this.basePath))}disableAccount(e,t){return p(this.configuration).disableAccount(e.id,t).then(e=>e(this.axios,this.basePath))}getAccount(e,t){return p(this.configuration).getAccount(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountV2(e,t){return p(this.configuration).getAccountV2(e.id,t).then(e=>e(this.axios,this.basePath))}getAccounts(e={},t){return p(this.configuration).getAccounts(e.limit,e.skip,e.order,e.chainId,e.player,e.address,e.expand,t).then(e=>e(this.axios,this.basePath))}getAccountsV2(e={},t){return p(this.configuration).getAccountsV2(e.limit,e.skip,e.order,e.chainId,e.user,e.chainType,e.accountType,e.address,t).then(e=>e(this.axios,this.basePath))}getSignerIdByAddress(e,t){return p(this.configuration).getSignerIdByAddress(e.address,t).then(e=>e(this.axios,this.basePath))}requestTransferOwnership(e,t){return p(this.configuration).requestTransferOwnership(e.id,e.transferOwnershipRequest,t).then(e=>e(this.axios,this.basePath))}signPayload(e,t){return p(this.configuration).signPayload(e.id,e.signPayloadRequest,t).then(e=>e(this.axios,this.basePath))}startRecovery(e,t){return p(this.configuration).startRecovery(e.id,e.startRecoveryRequest,t).then(e=>e(this.axios,this.basePath))}switchChainV2(e,t){return p(this.configuration).switchChainV2(e.switchChainQueriesV2,t).then(e=>e(this.axios,this.basePath))}syncAccount(e,t){return p(this.configuration).syncAccount(e.id,t).then(e=>e(this.axios,this.basePath))}}const g=function(t){const n=function(e){return{authenticateSIWE:async(t,s={})=>{o("authenticateSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/authenticate",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getJwks:async(t,s={})=>{o("getJwks","publishableKey",t);const n="/iam/v1/{publishable_key}/jwks.json".replace("{publishable_key}",encodeURIComponent(String(t))),a=new URL(n,i);let r;e&&(r=e.baseOptions);const c={method:"GET",...r,...s};h(a,{});let u=r&&r.headers?r.headers:{};return c.headers={...u,...s.headers},{url:d(a),options:c}},initOAuth:async(t,s,n={})=>{o("initOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},initSIWE:async(t,s,n={})=>{o("initSIWE","sIWERequest",t);const a=new URL("/iam/v1/siwe/init",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},linkEmail:async(t,s,n={})=>{o("linkEmail","loginRequest",t);const a=new URL("/iam/v1/password/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkOAuth:async(t,s,n={})=>{o("linkOAuth","oAuthInitRequest",t);const a=new URL("/iam/v1/oauth/init_link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},linkSIWE:async(t,s={})=>{o("linkSIWE","sIWEAuthenticateRequest",t);const n=new URL("/iam/v1/siwe/link",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},linkThirdParty:async(t,s,n={})=>{o("linkThirdParty","thirdPartyLinkRequest",t);const a=new URL("/iam/v1/oauth/link",i);let r;e&&(r=e.baseOptions);const c={method:"POST",...r,...n},l={};null!=s&&(l["x-game"]=String(s)),l["Content-Type"]="application/json",h(a,{});let p=r&&r.headers?r.headers:{};return c.headers={...l,...p,...n.headers},c.data=u(t,c,e),{url:d(a),options:c}},loginEmailPassword:async(t,s,n={})=>{o("loginEmailPassword","loginRequest",t);const a=new URL("/iam/v1/password/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginOIDC:async(t,s,n={})=>{o("loginOIDC","loginOIDCRequest",t);const a=new URL("/iam/v1/oidc/login",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},loginWithIdToken:async(t,s={})=>{o("loginWithIdToken","loginWithIdTokenRequest",t);const n=new URL("/iam/v1/oauth/login_id_token",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},logout:async(t,s={})=>{o("logout","logoutRequest",t);const n=new URL("/iam/v1/sessions/logout",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},me:async(t={})=>{const s=new URL("/iam/v1/me",i);let n;e&&(n=e.baseOptions);const a={method:"GET",...n,...t};h(s,{});let o=n&&n.headers?n.headers:{};return a.headers={...o,...t.headers},{url:d(s),options:a}},poolOAuth:async(t,s={})=>{o("poolOAuth","key",t);const n=new URL("/iam/v1/oauth/pool",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},u={},l={};await r(u,e),void 0!==t&&(l.key=t),h(n,l);let p=a&&a.headers?a.headers:{};return c.headers={...u,...p,...s.headers},{url:d(n),options:c}},refresh:async(t,s={})=>{o("refresh","refreshTokenRequest",t);const n=new URL("/iam/v1/sessions",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},registerGuest:async(t,s={})=>{const n=new URL("/iam/v1/guest",i);let a;e&&(a=e.baseOptions);const o={method:"POST",...a,...s},c={};await r(c,e),null!=t&&(c["x-game"]=String(t)),h(n,{});let u=a&&a.headers?a.headers:{};return o.headers={...c,...u,...s.headers},{url:d(n),options:o}},requestEmailVerification:async(t,s={})=>{o("requestEmailVerification","requestVerifyEmailRequest",t);const n=new URL("/iam/v1/password/request_email_verification",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},requestResetPassword:async(t,s={})=>{o("requestResetPassword","requestResetPasswordRequest",t);const n=new URL("/iam/v1/password/request_reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},resetPassword:async(t,s={})=>{o("resetPassword","resetPasswordRequest",t);const n=new URL("/iam/v1/password/reset",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},signupEmailPassword:async(t,s,n={})=>{o("signupEmailPassword","signupRequest",t);const a=new URL("/iam/v1/password/signup",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},thirdParty:async(t,s,n={})=>{o("thirdParty","thirdPartyOAuthRequest",t);const a=new URL("/iam/v1/oauth/third_party",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["x-game"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},unlinkEmail:async(t,s={})=>{o("unlinkEmail","unlinkEmailRequest",t);const n=new URL("/iam/v1/password/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkOAuth:async(t,s={})=>{o("unlinkOAuth","unlinkOAuthRequest",t);const n=new URL("/iam/v1/oauth/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},unlinkSIWE:async(t,s={})=>{o("unlinkSIWE","sIWERequest",t);const n=new URL("/iam/v1/siwe/unlink",i);let a;e&&(a=e.baseOptions);const r={method:"POST",...a,...s},c={"Content-Type":"application/json"};h(n,{});let l=a&&a.headers?a.headers:{};return r.headers={...c,...l,...s.headers},r.data=u(t,r,e),{url:d(n),options:r}},verifyEmail:async(t,s={})=>{o("verifyEmail","verifyEmailRequest",t);const n=new URL("/iam/v1/password/verify_email",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},verifyOAuthToken:async(t,s={})=>{o("verifyOAuthToken","authenticateOAuthRequest",t);const n=new URL("/iam/v1/oauth/verify",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}}}}(t);return{async authenticateSIWE(a,i){const o=await n.authenticateSIWE(a,i);return l(o,e,s,t)},async getJwks(a,i){const o=await n.getJwks(a,i);return l(o,e,s,t)},async initOAuth(a,i,o){const r=await n.initOAuth(a,i,o);return l(r,e,s,t)},async initSIWE(a,i,o){const r=await n.initSIWE(a,i,o);return l(r,e,s,t)},async linkEmail(a,i,o){const r=await n.linkEmail(a,i,o);return l(r,e,s,t)},async linkOAuth(a,i,o){const r=await n.linkOAuth(a,i,o);return l(r,e,s,t)},async linkSIWE(a,i){const o=await n.linkSIWE(a,i);return l(o,e,s,t)},async linkThirdParty(a,i,o){const r=await n.linkThirdParty(a,i,o);return l(r,e,s,t)},async loginEmailPassword(a,i,o){const r=await n.loginEmailPassword(a,i,o);return l(r,e,s,t)},async loginOIDC(a,i,o){const r=await n.loginOIDC(a,i,o);return l(r,e,s,t)},async loginWithIdToken(a,i){const o=await n.loginWithIdToken(a,i);return l(o,e,s,t)},async logout(a,i){const o=await n.logout(a,i);return l(o,e,s,t)},async me(a){const i=await n.me(a);return l(i,e,s,t)},async poolOAuth(a,i){const o=await n.poolOAuth(a,i);return l(o,e,s,t)},async refresh(a,i){const o=await n.refresh(a,i);return l(o,e,s,t)},async registerGuest(a,i){const o=await n.registerGuest(a,i);return l(o,e,s,t)},async requestEmailVerification(a,i){const o=await n.requestEmailVerification(a,i);return l(o,e,s,t)},async requestResetPassword(a,i){const o=await n.requestResetPassword(a,i);return l(o,e,s,t)},async resetPassword(a,i){const o=await n.resetPassword(a,i);return l(o,e,s,t)},async signupEmailPassword(a,i,o){const r=await n.signupEmailPassword(a,i,o);return l(r,e,s,t)},async thirdParty(a,i,o){const r=await n.thirdParty(a,i,o);return l(r,e,s,t)},async unlinkEmail(a,i){const o=await n.unlinkEmail(a,i);return l(o,e,s,t)},async unlinkOAuth(a,i){const o=await n.unlinkOAuth(a,i);return l(o,e,s,t)},async unlinkSIWE(a,i){const o=await n.unlinkSIWE(a,i);return l(o,e,s,t)},async verifyEmail(a,i){const o=await n.verifyEmail(a,i);return l(o,e,s,t)},async verifyOAuthToken(a,i){const o=await n.verifyOAuthToken(a,i);return l(o,e,s,t)}}};class w extends n{authenticateSIWE(e,t){return g(this.configuration).authenticateSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}getJwks(e,t){return g(this.configuration).getJwks(e.publishableKey,t).then(e=>e(this.axios,this.basePath))}initOAuth(e,t){return g(this.configuration).initOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}initSIWE(e,t){return g(this.configuration).initSIWE(e.sIWERequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkEmail(e,t){return g(this.configuration).linkEmail(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkOAuth(e,t){return g(this.configuration).linkOAuth(e.oAuthInitRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}linkSIWE(e,t){return g(this.configuration).linkSIWE(e.sIWEAuthenticateRequest,t).then(e=>e(this.axios,this.basePath))}linkThirdParty(e,t){return g(this.configuration).linkThirdParty(e.thirdPartyLinkRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginEmailPassword(e,t){return g(this.configuration).loginEmailPassword(e.loginRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginOIDC(e,t){return g(this.configuration).loginOIDC(e.loginOIDCRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}loginWithIdToken(e,t){return g(this.configuration).loginWithIdToken(e.loginWithIdTokenRequest,t).then(e=>e(this.axios,this.basePath))}logout(e,t){return g(this.configuration).logout(e.logoutRequest,t).then(e=>e(this.axios,this.basePath))}me(e){return g(this.configuration).me(e).then(e=>e(this.axios,this.basePath))}poolOAuth(e,t){return g(this.configuration).poolOAuth(e.key,t).then(e=>e(this.axios,this.basePath))}refresh(e,t){return g(this.configuration).refresh(e.refreshTokenRequest,t).then(e=>e(this.axios,this.basePath))}registerGuest(e={},t){return g(this.configuration).registerGuest(e.xGame,t).then(e=>e(this.axios,this.basePath))}requestEmailVerification(e,t){return g(this.configuration).requestEmailVerification(e.requestVerifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}requestResetPassword(e,t){return g(this.configuration).requestResetPassword(e.requestResetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}resetPassword(e,t){return g(this.configuration).resetPassword(e.resetPasswordRequest,t).then(e=>e(this.axios,this.basePath))}signupEmailPassword(e,t){return g(this.configuration).signupEmailPassword(e.signupRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}thirdParty(e,t){return g(this.configuration).thirdParty(e.thirdPartyOAuthRequest,e.xGame,t).then(e=>e(this.axios,this.basePath))}unlinkEmail(e,t){return g(this.configuration).unlinkEmail(e.unlinkEmailRequest,t).then(e=>e(this.axios,this.basePath))}unlinkOAuth(e,t){return g(this.configuration).unlinkOAuth(e.unlinkOAuthRequest,t).then(e=>e(this.axios,this.basePath))}unlinkSIWE(e,t){return g(this.configuration).unlinkSIWE(e.sIWERequest,t).then(e=>e(this.axios,this.basePath))}verifyEmail(e,t){return g(this.configuration).verifyEmail(e.verifyEmailRequest,t).then(e=>e(this.axios,this.basePath))}verifyOAuthToken(e,t){return g(this.configuration).verifyOAuthToken(e.authenticateOAuthRequest,t).then(e=>e(this.axios,this.basePath))}}const m=function(t){const n=function(e){return{createSession:async(t,s,n={})=>{o("createSession","createSessionRequest",t);const a=new URL("/v1/sessions",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},getPlayerSessions:async(t,s,n,a,c,u={})=>{o("getPlayerSessions","player",t);const l=new URL("/v1/sessions",i);let p;e&&(p=e.baseOptions);const y={method:"GET",...p,...u},g={},w={};await r(g,e),void 0!==s&&(w.limit=s),void 0!==n&&(w.skip=n),void 0!==a&&(w.order=a),void 0!==t&&(w.player=t),c&&(w.expand=c),h(l,w);let m=p&&p.headers?p.headers:{};return y.headers={...g,...m,...u.headers},{url:d(l),options:y}},getSession:async(t,s,n={})=>{o("getSession","id",t);const a="/v1/sessions/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},revokeSession:async(t,s,n={})=>{o("revokeSession","revokeSessionRequest",t);const a=new URL("/v1/sessions/revoke",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},signatureSession:async(t,s,n={})=>{o("signatureSession","id",t),o("signatureSession","signatureRequest",s);const a="/v1/sessions/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createSession(a,i,o){const r=await n.createSession(a,i,o);return l(r,e,s,t)},async getPlayerSessions(a,i,o,r,c,h){const u=await n.getPlayerSessions(a,i,o,r,c,h);return l(u,e,s,t)},async getSession(a,i,o){const r=await n.getSession(a,i,o);return l(r,e,s,t)},async revokeSession(a,i,o){const r=await n.revokeSession(a,i,o);return l(r,e,s,t)},async signatureSession(a,i,o){const r=await n.signatureSession(a,i,o);return l(r,e,s,t)}}};class P extends n{createSession(e,t){return m(this.configuration).createSession(e.createSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}getPlayerSessions(e,t){return m(this.configuration).getPlayerSessions(e.player,e.limit,e.skip,e.order,e.expand,t).then(e=>e(this.axios,this.basePath))}getSession(e,t){return m(this.configuration).getSession(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}revokeSession(e,t){return m(this.configuration).revokeSession(e.revokeSessionRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}signatureSession(e,t){return m(this.configuration).signatureSession(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}const R=function(t){const n=function(e){return{createTransactionIntent:async(t,s,n={})=>{o("createTransactionIntent","createTransactionIntentRequest",t);const a=new URL("/v1/transaction_intents",i);let c;e&&(c=e.baseOptions);const l={method:"POST",...c,...n},p={};await r(p,e),null!=s&&(p["X-Behalf-Of-Project"]=String(s)),p["Content-Type"]="application/json",h(a,{});let y=c&&c.headers?c.headers:{};return l.headers={...p,...y,...n.headers},l.data=u(t,l,e),{url:d(a),options:l}},estimateTransactionIntentCost:async(t,s={})=>{o("estimateTransactionIntentCost","createTransactionIntentRequest",t);const n=new URL("/v1/transaction_intents/estimate_gas_cost",i);let a;e&&(a=e.baseOptions);const c={method:"POST",...a,...s},l={};await r(l,e),l["Content-Type"]="application/json",h(n,{});let p=a&&a.headers?a.headers:{};return c.headers={...l,...p,...s.headers},c.data=u(t,c,e),{url:d(n),options:c}},getTransactionIntent:async(t,s,n={})=>{o("getTransactionIntent","id",t);const a="/v1/transaction_intents/{id}".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let u;e&&(u=e.baseOptions);const l={method:"GET",...u,...n},p={},y={};await r(p,e),s&&(y.expand=s),h(c,y);let g=u&&u.headers?u.headers:{};return l.headers={...p,...g,...n.headers},{url:d(c),options:l}},getTransactionIntents:async(t,s,n,a,o,c,u,l,p,y={})=>{const g=new URL("/v1/transaction_intents",i);let w;e&&(w=e.baseOptions);const m={method:"GET",...w,...y},P={},R={};await r(P,e),void 0!==t&&(R.limit=t),void 0!==s&&(R.skip=s),void 0!==n&&(R.order=n),a&&(R.expand=a),void 0!==o&&(R.chainId=o),c&&(R.account=c),u&&(R.player=u),void 0!==l&&(R.status=l),p&&(R.policy=p),h(g,R);let T=w&&w.headers?w.headers:{};return m.headers={...P,...T,...y.headers},{url:d(g),options:m}},signature:async(t,s,n={})=>{o("signature","id",t),o("signature","signatureRequest",s);const a="/v1/transaction_intents/{id}/signature".replace("{id}",encodeURIComponent(String(t))),c=new URL(a,i);let l;e&&(l=e.baseOptions);const p={method:"POST",...l,...n},y={};await r(y,e),await r(y,e),y["Content-Type"]="application/json",h(c,{});let g=l&&l.headers?l.headers:{};return p.headers={...y,...g,...n.headers},p.data=u(s,p,e),{url:d(c),options:p}}}}(t);return{async createTransactionIntent(a,i,o){const r=await n.createTransactionIntent(a,i,o);return l(r,e,s,t)},async estimateTransactionIntentCost(a,i){const o=await n.estimateTransactionIntentCost(a,i);return l(o,e,s,t)},async getTransactionIntent(a,i,o){const r=await n.getTransactionIntent(a,i,o);return l(r,e,s,t)},async getTransactionIntents(a,i,o,r,c,h,u,d,p,y){const g=await n.getTransactionIntents(a,i,o,r,c,h,u,d,p,y);return l(g,e,s,t)},async signature(a,i,o){const r=await n.signature(a,i,o);return l(r,e,s,t)}}};class T extends n{createTransactionIntent(e,t){return R(this.configuration).createTransactionIntent(e.createTransactionIntentRequest,e.xBehalfOfProject,t).then(e=>e(this.axios,this.basePath))}estimateTransactionIntentCost(e,t){return R(this.configuration).estimateTransactionIntentCost(e.createTransactionIntentRequest,t).then(e=>e(this.axios,this.basePath))}getTransactionIntent(e,t){return R(this.configuration).getTransactionIntent(e.id,e.expand,t).then(e=>e(this.axios,this.basePath))}getTransactionIntents(e={},t){return R(this.configuration).getTransactionIntents(e.limit,e.skip,e.order,e.expand,e.chainId,e.account,e.player,e.status,e.policy,t).then(e=>e(this.axios,this.basePath))}signature(e,t){return R(this.configuration).signature(e.id,e.signatureRequest,t).then(e=>e(this.axios,this.basePath))}}class O{apiKey;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(e={}){this.apiKey=e.apiKey,this.username=e.username,this.password=e.password,this.accessToken=e.accessToken,this.basePath=e.basePath,this.baseOptions=e.baseOptions,this.formDataCtor=e.formDataCtor}isJsonMime(e){const t=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==e&&(t.test(e)||"application/json-patch+json"===e.toLowerCase())}}const f=({basePath:e,accessToken:t})=>{if(!e.trim())throw Error("basePath can not be empty");return new O({basePath:e,accessToken:t})};exports.BackendApiClients=class{config;transactionIntentsApi;accountsApi;sessionsApi;authenticationApi;constructor(s){const n=e.create();t(n,{retries:3,retryDelay:t.exponentialDelay,retryCondition:t.isRetryableError});const a={basePath:s.basePath,accessToken:s.accessToken};this.config={backend:f(a)},this.transactionIntentsApi=new T(this.config.backend,void 0,n),this.accountsApi=new y(this.config.backend,void 0,n),this.sessionsApi=new P(this.config.backend,void 0,n),this.authenticationApi=new w(this.config.backend,void 0,n)}},exports.createConfig=f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("../storage/istorage.js"),e=require("../core/configuration/authentication.js"),a=require("../core/errors/openfortError.js"),i=require("../types/types.js");exports.AuthApi=class{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(t,e,a,i,
|
|
1
|
+
"use strict";var t=require("../storage/istorage.js"),e=require("../core/configuration/authentication.js"),a=require("../core/errors/openfortError.js"),i=require("../types/types.js");exports.AuthApi=class{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(t,e,a,i,r){this.storage=t,this.authManager=e,this.validateAndRefreshToken=a,this.ensureInitialized=i,this.eventEmitter=r}async logInWithEmailPassword({email:t,password:i,ecosystemGame:r}){await this.ensureInitialized();if(await e.Authentication.fromStorage(this.storage))throw new a.OpenfortError("Already logged in",a.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);const n=await this.authManager.loginEmailPassword(t,i,r);return"action"in n||new e.Authentication("jwt",n.token,n.player.id,n.refreshToken).save(this.storage),n}async signUpGuest(){await this.ensureInitialized();if(await e.Authentication.fromStorage(this.storage))throw new a.OpenfortError("Already logged in",a.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);const t=await this.authManager.registerGuest();return new e.Authentication("jwt",t.token,t.player.id,t.refreshToken).save(this.storage),t}async signUpWithEmailPassword({email:t,password:i,options:r,ecosystemGame:n}){await this.ensureInitialized();if(await e.Authentication.fromStorage(this.storage))throw new a.OpenfortError("Already logged in",a.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);const s=await this.authManager.signupEmailPassword(t,i,r?.data.name,n);return"action"in s||new e.Authentication("jwt",s.token,s.player.id,s.refreshToken).save(this.storage),s}async linkEmailPassword({email:t,password:e,authToken:a,ecosystemGame:i}){return await this.validateAndRefreshToken(),await this.authManager.linkEmail(t,e,a,i)}async unlinkEmailPassword({email:t,authToken:e}){return await this.validateAndRefreshToken(),await this.authManager.unlinkEmail(t,e)}async requestEmailVerification({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestEmailVerification(t,e)}async resetPassword({email:t,password:e,state:a}){await this.ensureInitialized(),await this.authManager.resetPassword(t,e,a)}async requestResetPassword({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestResetPassword(t,e)}async verifyEmail({email:t,state:e}){await this.ensureInitialized(),await this.authManager.verifyEmail(t,e)}async initOAuth({provider:t,options:i,ecosystemGame:r}){await this.ensureInitialized();if(await e.Authentication.fromStorage(this.storage))throw new a.OpenfortError("Already logged in",a.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);return await this.authManager.initOAuth(t,i,r)}async initLinkOAuth({provider:t,options:i,ecosystemGame:r}){await this.validateAndRefreshToken();const n=await e.Authentication.fromStorage(this.storage);if(!n)throw new a.OpenfortError("No authentication found",a.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return await this.authManager.linkOAuth(n,t,i,r)}async linkThirdPartyProvider({provider:t,token:i,tokenType:r}){await this.validateAndRefreshToken();const n=await e.Authentication.fromStorage(this.storage);if(!n)throw new a.OpenfortError("No authentication found",a.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return await this.authManager.linkThirdParty(n,t,i,r)}async unlinkOAuth({provider:t,authToken:e}){return await this.validateAndRefreshToken(),await this.authManager.unlinkOAuth(t,e)}async poolOAuth(t){await this.ensureInitialized();const a=await this.authManager.poolOAuth(t);return new e.Authentication("jwt",a.token,a.player.id,a.refreshToken).save(this.storage),a}async authenticateWithThirdPartyProvider({provider:t,token:a,tokenType:i,ecosystemGame:r}){await this.ensureInitialized();const n=await this.authManager.authenticateThirdParty(t,a,i,r);return new e.Authentication("third_party",a,n.id,null,t,i).save(this.storage),n}async loginWithIdToken({provider:t,token:i,ecosystemGame:r}){await this.ensureInitialized();if(await e.Authentication.fromStorage(this.storage))throw new a.OpenfortError("Already logged in",a.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);const n=await this.authManager.loginWithIdToken(t,i,r);return new e.Authentication("jwt",n.token,n.player.id,n.refreshToken).save(this.storage),n}async initSIWE({address:t,ecosystemGame:e}){return await this.ensureInitialized(),await this.authManager.initSIWE(t,e)}async authenticateWithSIWE({signature:t,message:i,walletClientType:r,connectorType:n}){await this.ensureInitialized();if(await e.Authentication.fromStorage(this.storage))throw new a.OpenfortError("Already logged in",a.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);const s=await this.authManager.authenticateSIWE(t,i,r,n);return new e.Authentication("jwt",s.token,s.player.id,s.refreshToken).save(this.storage),s}async linkWallet({signature:t,message:e,walletClientType:a,connectorType:i,authToken:r}){return await this.validateAndRefreshToken(),await this.authManager.linkWallet(t,e,a,i,r)}async unlinkWallet({address:t,authToken:e}){return await this.validateAndRefreshToken(),await this.authManager.unlinkWallet(t,e)}async storeCredentials(t){if(await this.ensureInitialized(),!t.player)throw new a.OpenfortError("Player ID is required to store credentials",a.OpenfortErrorType.INVALID_CONFIGURATION);new e.Authentication("jwt",t.accessToken,t.player,t.refreshToken).save(this.storage)}async logout(){const a=await e.Authentication.fromStorage(this.storage);if(a){try{"third_party"!==a.type&&await this.authManager.logout(a.token,a?.refreshToken)}catch(t){}this.storage.remove(t.StorageKeys.AUTHENTICATION),this.eventEmitter.emit(i.OpenfortEvents.LOGGED_OUT)}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),r=require("../storage/istorage.js"),t=require("../core/configuration/account.js"),n=require("../core/configuration/authentication.js"),a=require("../core/config/config.js"),i=require("../core/errors/openfortError.js"),o=require("../wallets/evm/walletHelpers.js"),s=require("../wallets/evm/evmProvider.js");require("../wallets/evm/types.js");var d=require("../wallets/evm/provider/eip6963.js"),g=require("../types/types.js"),c=require("../wallets/iframeManager.js"),u=require("../wallets/embedded.js");require("../wallets/messaging/browserMessenger/backwardCompatibility.js");var h=require("../wallets/messaging/browserMessenger/messengers/WindowMessenger.js"),f=require("../wallets/messaging/ReactNativeMessenger.js"),m=require("../utils/debug.js");exports.EmbeddedWalletApi=class{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,n){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=n,this.eventEmitter.on(g.OpenfortEvents.TOKEN_REFRESHED,()=>{m.debugLog("Handling token refresh event in EmbeddedWalletApi"),this.handleTokenRefreshed()}),this.eventEmitter.on(g.OpenfortEvents.LOGGED_OUT,()=>{m.debugLog("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=a.SDKConfiguration.fromStorage();if(!r)throw new i.OpenfortError("Configuration not found",i.OpenfortErrorType.INVALID_CONFIGURATION);return new e.BackendApiClients({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey})}async getIframeManager(){if(m.debugLog("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return m.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return m.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;m.debugLog("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return m.debugLog("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,m.debugLog("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw m.debugLog("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){m.debugLog("[HANDSHAKE DEBUG] createIframeManager starting");const e=a.SDKConfiguration.fromStorage();if(!e)throw m.debugLog("[HANDSHAKE DEBUG] Configuration not found"),new i.OpenfortError("Configuration not found",i.OpenfortErrorType.INVALID_CONFIGURATION);let r;if(m.debugLog("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)m.debugLog("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new f.ReactNativeMessenger(this.messagePoster),m.debugLog("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),r=this.messenger;else{m.debugLog("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const t=this.createIframe(e.iframeUrl),n=new URL(e.iframeUrl).origin;r=new h({remoteWindow:t.contentWindow,allowedOrigins:[n]}),m.debugLog("[HANDSHAKE DEBUG] Created WindowMessenger")}m.debugLog("[HANDSHAKE DEBUG] Creating IframeManager instance");const t=new c.IframeManager(e,this.storage,r);return m.debugLog("[HANDSHAKE DEBUG] Initializing IframeManager"),await t.initialize(),m.debugLog("[HANDSHAKE DEBUG] IframeManager initialized successfully"),t}async ensureSigner(){if(this.signer)return this.signer;if(this.signerPromise)return this.signerPromise;this.signerPromise=this.createSigner();try{return this.signer=await this.signerPromise,this.signer}catch(e){throw this.signerPromise=null,e}finally{this.signerPromise=null}}async createSigner(){const e=await this.getIframeManager(),r=new u.EmbeddedSigner(e,this.storage);return this.eventEmitter.emit(g.OpenfortEvents.SIGNER_CONFIGURED,r),r}createIframe(e){if("undefined"==typeof document)throw new i.OpenfortError("Document is not available. Please provide a message poster for non-browser environments.",i.OpenfortErrorType.INVALID_CONFIGURATION);const r=document.getElementById("openfort-iframe");r&&r.remove();const t=document.createElement("iframe");return t.style.display="none",t.id="openfort-iframe",t.src=e,document.body.appendChild(t),m.debugLog("Iframe created and appended to document"),t}async configure(e={}){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:g.RecoveryMethod.AUTOMATIC};if(!a.SDKConfiguration.fromStorage())throw new i.OpenfortError("Configuration not found",i.OpenfortErrorType.INVALID_CONFIGURATION);let o;(r.recoveryMethod===g.RecoveryMethod.PASSWORD||e.shieldAuthentication?.encryptionSession)&&(o={encryptionSession:e.shieldAuthentication?.encryptionSession,recoveryPassword:r.recoveryMethod===g.RecoveryMethod.PASSWORD?r.password:void 0});const s=await this.getIframeManager(),d=await s.configure({chainId:e.chainId,entropy:o});new t.Account(d.address,d.chainId,d.ownerAddress,d.accountType).save(this.storage);const c=new u.EmbeddedSigner(s,this.storage);this.eventEmitter.emit(g.OpenfortEvents.SIGNER_CONFIGURED,c);const h=await n.Authentication.fromStorage(this.storage);if(!h)throw new i.OpenfortError("No access token found",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{chainId:d.chainId.toString(),owner:{id:h.player},address:d.address,ownerAddress:"solana"===d.accountType?void 0:d.ownerAddress,chainType:"solana"===d.accountType?"solana":"ethereum",implementationType:"solana"===d.accountType?void 0:d.accountType}}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:n=!0,arrayifyMessage:a=!1}=r||{};return await t.sign(e,a,n)}async signTypedData(e,r,n){await this.validateAndRefreshToken();const a=await this.ensureSigner(),s=await t.Account.fromStorage(this.storage);if(!s)throw new i.OpenfortError("No account found",i.OpenfortErrorType.MISSING_SIGNER_ERROR);return await o.getSignedTypedData({domain:e,types:r,message:n},s.type,Number(s.chainId),a,s.address)}async exportPrivateKey(){await this.validateAndRefreshToken();const e=await this.ensureSigner();return await e.export()}async setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:r,encryptionSession:t}){await this.validateAndRefreshToken();const n=await this.ensureSigner();if("password"===e&&!r)throw new i.OpenfortError("Recovery password is required",i.OpenfortErrorType.INVALID_CONFIGURATION);await n.setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:r,encryptionSession:t})}async get(){const e=await t.Account.fromStorage(this.storage);if(!e)throw new i.OpenfortError("No signer configured",i.OpenfortErrorType.MISSING_SIGNER_ERROR);const r=await n.Authentication.fromStorage(this.storage);if(!r)throw new i.OpenfortError("No access token found",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{chainId:e.chainId.toString(),owner:{id:r.player},address:e.address,ownerAddress:"solana"===e.type?void 0:e.ownerAddress,chainType:"solana"===e.type?"solana":"ethereum",implementationType:"solana"===e.type?void 0:e.type}}async list(){const e=a.SDKConfiguration.fromStorage();if(!e)throw new i.OpenfortError("Configuration not found",i.OpenfortErrorType.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const r=await n.Authentication.fromStorage(this.storage);if(!r)throw new i.OpenfortError("No access token found",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return i.withOpenfortError(async()=>(await this.backendApiClients.accountsApi.getAccounts(void 0,{headers:{authorization:`Bearer ${e.baseConfiguration.publishableKey}`,"x-player-token":r.token,"x-auth-provider":r.thirdPartyProvider,"x-token-type":r.thirdPartyTokenType}})).data.data.map(e=>({owner:{id:e.player.id},chainType:"ethereum",address:e.address,ownerAddress:e.ownerAddress,createdAt:e.createdAt,implementationType:e.accountType,chainId:e.chainId.toString()})),{default:i.OpenfortErrorType.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await n.Authentication.fromStorage(this.storage))return g.EmbeddedState.UNAUTHENTICATED;return await t.Account.fromStorage(this.storage)?g.EmbeddedState.READY:g.EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return m.debugLog("Failed to get embedded state:",e),g.EmbeddedState.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},a=await n.Authentication.fromStorage(this.storage),i=await t.Account.fromStorage(this.storage);let o;try{o=i?await this.ensureSigner():void 0}catch(e){o=void 0}return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new s.EvmProvider({storage:this.storage,openfortEventEmitter:this.eventEmitter,signer:o||void 0,account:i||void 0,authentication:a||void 0,backendApiClients:this.backendApiClients,policyId:r.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:r.chains}),r.announceProvider&&d.announceProvider({info:{...d.openfortProviderInfo,...r.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(r=>{setTimeout(r,e)});const r=await this.getIframeManager();if(!r.isLoaded())return!1;const t=await n.Authentication.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return m.debugLog("Ping failed:",e),!1}}getURL(){const e=a.SDKConfiguration.fromStorage();if(!e)throw new i.OpenfortError("Configuration not found",i.OpenfortErrorType.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new i.OpenfortError("Invalid message poster",i.OpenfortErrorType.INVALID_CONFIGURATION);this.messagePoster=e,this.messenger&&(this.messenger.destroy(),this.messenger=null),this.iframeManager&&(this.iframeManager.destroy(),this.iframeManager=null,this.iframeManagerPromise=null),this.signer&&(this.signer=null,this.signerPromise=null)}async handleTokenRefreshed(){if(this.iframeManager)try{await this.iframeManager.updateAuthentication(),m.debugLog("Updated IframeManager authentication after token refresh")}catch(e){m.debugLog("Failed to update IframeManager authentication:",e)}else m.debugLog("IframeManager not initialized, skipping authentication update")}async handleLogout(){if(this.signer){try{await this.signer.disconnect(),m.debugLog("Logged out embedded signer")}catch(e){m.debugLog("Failed to logout embedded signer:",e)}this.signer=null,this.signerPromise=null}this.storage.remove(r.StorageKeys.ACCOUNT),this.iframeManager&&(this.iframeManager.destroy(),this.iframeManager=null,this.iframeManagerPromise=null),this.messenger&&(this.messenger.destroy(),this.messenger=null),this.provider&&(this.provider=null)}async onMessage(e){if(!e||"object"!=typeof e)return void m.debugLog("Invalid message received:",e);m.debugLog("[HANDSHAKE DEBUG] EmbeddedWalletApi onMessage:",e);const r="penpal"===e.namespace&&"SYN"===e.type||e.penpal&&"string"==typeof e.penpal;if(r&&this.messenger&&this.messagePoster)return m.debugLog("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const t=await this.getIframeManager();m.debugLog(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${t.isLoaded()}`),r&&!t.isLoaded()&&m.debugLog("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),m.debugLog("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await t.onMessage(e),m.debugLog("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}};
|
|
1
|
+
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),r=require("../storage/istorage.js"),t=require("../core/configuration/account.js"),n=require("../core/configuration/authentication.js"),i=require("../core/config/config.js"),a=require("../core/errors/openfortError.js"),s=require("../wallets/evm/walletHelpers.js"),o=require("../wallets/evm/evmProvider.js");require("../wallets/evm/types.js");var d=require("../wallets/evm/provider/eip6963.js"),c=require("../types/types.js"),g=require("../wallets/iframeManager.js"),h=require("../wallets/embedded.js");require("../wallets/messaging/browserMessenger/backwardCompatibility.js");var u=require("../wallets/messaging/browserMessenger/messengers/WindowMessenger.js"),p=require("../wallets/messaging/ReactNativeMessenger.js"),l=require("../utils/debug.js");exports.EmbeddedWalletApi=class{storage;validateAndRefreshToken;ensureInitialized;eventEmitter;iframeManager=null;iframeManagerPromise=null;signer=null;signerPromise=null;provider=null;messagePoster=null;messenger=null;constructor(e,r,t,n){this.storage=e,this.validateAndRefreshToken=r,this.ensureInitialized=t,this.eventEmitter=n,this.eventEmitter.on(c.OpenfortEvents.TOKEN_REFRESHED,()=>{l.debugLog("Handling token refresh event in EmbeddedWalletApi"),this.handleTokenRefreshed()}),this.eventEmitter.on(c.OpenfortEvents.LOGGED_OUT,()=>{l.debugLog("Handling logout event in EmbeddedWalletApi"),this.handleLogout()})}get backendApiClients(){const r=i.SDKConfiguration.fromStorage();if(!r)throw new a.OpenfortError("Configuration not found",a.OpenfortErrorType.INVALID_CONFIGURATION);return new e.BackendApiClients({basePath:r.backendUrl,accessToken:r.baseConfiguration.publishableKey})}async getIframeManager(){if(l.debugLog("[HANDSHAKE DEBUG] getIframeManager called"),this.iframeManager)return l.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManager instance"),this.iframeManager;if(this.iframeManagerPromise)return l.debugLog("[HANDSHAKE DEBUG] Returning existing iframeManagerPromise"),this.iframeManagerPromise;l.debugLog("[HANDSHAKE DEBUG] Creating new iframeManager"),this.iframeManagerPromise=this.createIframeManager();try{return l.debugLog("[HANDSHAKE DEBUG] Awaiting iframeManager creation"),this.iframeManager=await this.iframeManagerPromise,l.debugLog("[HANDSHAKE DEBUG] IframeManager created successfully"),this.iframeManagerPromise=null,this.iframeManager}catch(e){throw l.debugLog("[HANDSHAKE DEBUG] Error creating iframeManager:",e),this.iframeManagerPromise=null,e}}async createIframeManager(){l.debugLog("[HANDSHAKE DEBUG] createIframeManager starting");const e=i.SDKConfiguration.fromStorage();if(!e)throw l.debugLog("[HANDSHAKE DEBUG] Configuration not found"),new a.OpenfortError("Configuration not found",a.OpenfortErrorType.INVALID_CONFIGURATION);let r;if(l.debugLog("[HANDSHAKE DEBUG] Configuration found"),this.messagePoster)l.debugLog("[HANDSHAKE DEBUG] Creating ReactNativeMessenger with messagePoster"),this.messenger=new p.ReactNativeMessenger(this.messagePoster),l.debugLog("[HANDSHAKE DEBUG] Created new ReactNativeMessenger instance"),r=this.messenger;else{l.debugLog("[HANDSHAKE DEBUG] Creating WindowMessenger for browser mode");const t=this.createIframe(e.iframeUrl),n=new URL(e.iframeUrl).origin;r=new u({remoteWindow:t.contentWindow,allowedOrigins:[n]}),l.debugLog("[HANDSHAKE DEBUG] Created WindowMessenger")}return l.debugLog("[HANDSHAKE DEBUG] Creating IframeManager instance"),new g.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 h.EmbeddedSigner(e,this.storage,this.backendApiClients,this.eventEmitter)}createIframe(e){if("undefined"==typeof document)throw new a.OpenfortError("Document is not available. Please provide a message poster for non-browser environments.",a.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),l.debugLog("Iframe created and appended to document"),t}async configure(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:c.RecoveryMethod.AUTOMATIC};let t;(r.recoveryMethod===c.RecoveryMethod.PASSWORD||e.shieldAuthentication?.encryptionSession)&&(t={encryptionSession:e.shieldAuthentication?.encryptionSession,recoveryPassword:r.recoveryMethod===c.RecoveryMethod.PASSWORD?r.password:void 0});const i=await this.ensureSigner(),a=await i.configure({chainId:e.chainId,entropy:t}),s=await n.Authentication.fromStorage(this.storage);return{id:a.id,chainId:a.chainId,user:s.player,address:a.address,ownerAddress:a.ownerAddress,chainType:a.chainType,accountType:a.accountType,implementationType:a.implementationType}}async create(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:c.RecoveryMethod.AUTOMATIC};let t;(r.recoveryMethod===c.RecoveryMethod.PASSWORD||e.shieldAuthentication?.encryptionSession)&&(t={encryptionSession:e.shieldAuthentication?.encryptionSession,recoveryPassword:r.recoveryMethod===c.RecoveryMethod.PASSWORD?r.password:void 0});const i=await this.ensureSigner(),a=await i.create({accountType:e.accountType,chainType:e.chainType,chainId:e.chainId,entropy:t});this.signer=null,this.signerPromise=null;const s=await n.Authentication.fromStorage(this.storage);return{id:a.id,chainId:a.chainId,user:s.player,address:a.address,ownerAddress:a.ownerAddress,chainType:a.chainType,accountType:a.accountType,implementationType:a.implementationType}}async recover(e){await this.validateAndRefreshToken();const r=e.recoveryParams??{recoveryMethod:c.RecoveryMethod.AUTOMATIC};let t;(r.recoveryMethod===c.RecoveryMethod.PASSWORD||e.shieldAuthentication?.encryptionSession)&&(t={encryptionSession:e.shieldAuthentication?.encryptionSession,recoveryPassword:r.recoveryMethod===c.RecoveryMethod.PASSWORD?r.password:void 0});const i=await this.ensureSigner(),a=await i.recover({account:e.account,entropy:t});this.signer=null,this.signerPromise=null;const s=await n.Authentication.fromStorage(this.storage);return{id:a.id,chainId:a.chainId,user:s.player,address:a.address,ownerAddress:a.ownerAddress,chainType:a.chainType,accountType:a.accountType,implementationType:a.implementationType}}async signMessage(e,r){await this.validateAndRefreshToken();const t=await this.ensureSigner(),{hashMessage:n=!0,arrayifyMessage:i=!1}=r||{};return await t.sign(e,i,n)}async signTypedData(e,r,n){await this.validateAndRefreshToken();const i=await this.ensureSigner(),o=await t.Account.fromStorage(this.storage);if(!o)throw new a.OpenfortError("No account found",a.OpenfortErrorType.MISSING_SIGNER_ERROR);const d={...r};delete d.EIP712Domain;const{_TypedDataEncoder:c}=await import("@ethersproject/hash"),g=c.hash(e,d,n);return await s.signMessage({hash:g,implementationType:o.implementationType||o.type,chainId:Number(o.chainId),signer:i,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 setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:r,encryptionSession:t}){await this.validateAndRefreshToken();const n=await this.ensureSigner();if("password"===e&&!r)throw new a.OpenfortError("Recovery password is required",a.OpenfortErrorType.INVALID_CONFIGURATION);await n.setEmbeddedRecovery({recoveryMethod:e,recoveryPassword:r,encryptionSession:t})}async get(){const e=await t.Account.fromStorage(this.storage);if(!e)throw new a.OpenfortError("No signer configured",a.OpenfortErrorType.MISSING_SIGNER_ERROR);const r=await n.Authentication.fromStorage(this.storage);if(!r)throw new a.OpenfortError("No access token found",a.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}}async list(){const e=i.SDKConfiguration.fromStorage();if(!e)throw new a.OpenfortError("Configuration not found",a.OpenfortErrorType.INVALID_CONFIGURATION);await this.validateAndRefreshToken();const r=await n.Authentication.fromStorage(this.storage);if(!r)throw new a.OpenfortError("No access token found",a.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return a.withOpenfortError(async()=>(await this.backendApiClients.accountsApi.getAccountsV2({accountType:c.AccountTypeEnum.SMART_ACCOUNT},{headers:{authorization:`Bearer ${e.baseConfiguration.publishableKey}`,"x-player-token":r.token,"x-auth-provider":r.thirdPartyProvider,"x-token-type":r.thirdPartyTokenType}})).data.data.map(e=>({user:e.user,chainType:e.accountType,id:e.id,address:e.address,ownerAddress:e.ownerAddress,accountType:e.accountType,createdAt:e.createdAt,implementationType:e.smartAccount?.implementationType,chainId:e.chainId})),{default:a.OpenfortErrorType.AUTHENTICATION_ERROR})}async getEmbeddedState(){try{if(!await n.Authentication.fromStorage(this.storage))return c.EmbeddedState.UNAUTHENTICATED;return await t.Account.fromStorage(this.storage)?c.EmbeddedState.READY:c.EmbeddedState.EMBEDDED_SIGNER_NOT_CONFIGURED}catch(e){return l.debugLog("Failed to get embedded state:",e),c.EmbeddedState.UNAUTHENTICATED}}async getEthereumProvider(e){await this.ensureInitialized();const r={announceProvider:!0,...e},i=await n.Authentication.fromStorage(this.storage),a=await t.Account.fromStorage(this.storage);return this.provider?this.provider&&r.policy&&this.provider.updatePolicy(r.policy):(this.provider=new o.EvmProvider({storage:this.storage,openfortEventEmitter:this.eventEmitter,ensureSigner:this.ensureSigner.bind(this),account:a||void 0,authentication:i||void 0,backendApiClients:this.backendApiClients,policyId:r.policy,validateAndRefreshSession:this.validateAndRefreshToken.bind(this),chains:r.chains}),r.announceProvider&&d.announceProvider({info:{...d.openfortProviderInfo,...r.providerInfo},provider:this.provider})),this.provider}async ping(e){try{e>0&&await new Promise(r=>{setTimeout(r,e)});const r=await this.getIframeManager();if(!r.isLoaded())return!1;const t=await n.Authentication.fromStorage(this.storage);if(t)try{return await r.getCurrentDevice(t.player),!0}catch(e){return!1}return r.isLoaded()}catch(e){return l.debugLog("Ping failed:",e),!1}}getURL(){const e=i.SDKConfiguration.fromStorage();if(!e)throw new a.OpenfortError("Configuration not found",a.OpenfortErrorType.INVALID_CONFIGURATION);return e.iframeUrl}async setMessagePoster(e){if(!e||"function"!=typeof e.postMessage)throw new a.OpenfortError("Invalid message poster",a.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 handleTokenRefreshed(){if(this.iframeManager)try{await this.iframeManager.updateAuthentication(),l.debugLog("Updated IframeManager authentication after token refresh")}catch(e){l.debugLog("Failed to update IframeManager authentication:",e)}else l.debugLog("IframeManager not initialized, skipping authentication update")}async handleLogout(){this.provider=null,this.messenger=null,this.iframeManager=null,this.iframeManagerPromise=null,this.signer=null,this.signerPromise=null,this.storage.remove(r.StorageKeys.ACCOUNT)}async onMessage(e){if(!e||"object"!=typeof e)return void l.debugLog("Invalid message received:",e);l.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 l.debugLog("[HANDSHAKE DEBUG] Passing message directly to existing ReactNativeMessenger"),void this.messenger.handleMessage(e);const t=await this.getIframeManager();l.debugLog(`[HANDSHAKE DEBUG] IframeManager obtained, isLoaded: ${t.isLoaded()}`),r&&!t.isLoaded()&&l.debugLog("[HANDSHAKE DEBUG] Received penpal message before connection initialized, setting up connection..."),l.debugLog("[HANDSHAKE DEBUG] Calling iframeManager.onMessage"),await t.onMessage(e),l.debugLog("[HANDSHAKE DEBUG] iframeManager.onMessage completed")}isReady(){return this.iframeManager?.isLoaded()||!1}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var t=require("../../storage/istorage.js");class e{constructor(t){this.user=t.user,this.id=t.id,this.chainType=t.chainType,this.address=t.address,this.accountType=t.accountType,this.chainId=t.chainId,this.createdAt=t.createdAt,this.implementationType=t.implementationType,this.factoryAddress=t.factoryAddress,this.salt=t.salt,this.ownerAddress=t.ownerAddress,this.type=t.type}user;id;chainType;address;accountType;chainId;ownerAddress;factoryAddress;salt;createdAt;implementationType;type;save(e){e.save(t.StorageKeys.ACCOUNT,JSON.stringify({user:this.user,id:this.id,chainType:this.chainType,address:this.address,accountType:this.accountType,chainId:this.chainId,ownerAddress:this.ownerAddress,createdAt:this.createdAt,implementationType:this.implementationType,factoryAddress:this.factoryAddress,salt:this.salt}))}static async fromStorage(s){const r=await s.get(t.StorageKeys.ACCOUNT);if(!r)return null;try{const t=JSON.parse(r);return new e(t)}catch{return null}}}exports.Account=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var R,E=require("axios");exports.OpenfortErrorType=void 0,(R=exports.OpenfortErrorType||(exports.OpenfortErrorType={})).AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",R.INVALID_CONFIGURATION="INVALID_CONFIGURATION",R.NOT_LOGGED_IN_ERROR="NOT_LOGGED_IN_ERROR",R.REFRESH_TOKEN_ERROR="REFRESH_TOKEN_ERROR",R.USER_REGISTRATION_ERROR="USER_REGISTRATION_ERROR",R.LOGOUT_ERROR="LOGOUT_ERROR",R.OPERATION_NOT_SUPPORTED_ERROR="OPERATION_NOT_SUPPORTED_ERROR",R.
|
|
1
|
+
"use strict";var R,E=require("axios");exports.OpenfortErrorType=void 0,(R=exports.OpenfortErrorType||(exports.OpenfortErrorType={})).AUTHENTICATION_ERROR="AUTHENTICATION_ERROR",R.INVALID_CONFIGURATION="INVALID_CONFIGURATION",R.NOT_LOGGED_IN_ERROR="NOT_LOGGED_IN_ERROR",R.ALREADY_LOGGED_IN_ERROR="ALREADY_LOGGED_IN_ERROR",R.REFRESH_TOKEN_ERROR="REFRESH_TOKEN_ERROR",R.USER_REGISTRATION_ERROR="USER_REGISTRATION_ERROR",R.LOGOUT_ERROR="LOGOUT_ERROR",R.OPERATION_NOT_SUPPORTED_ERROR="OPERATION_NOT_SUPPORTED_ERROR",R.MISSING_SIGNER_ERROR="MISSING_SIGNER_ERROR",R.USER_NOT_AUTHORIZED_ON_ECOSYSTEM="USER_NOT_AUTHORIZED_ON_ECOSYSTEM",R.INTERNAL_ERROR="INTERNAL_ERROR";class O extends Error{type;data;constructor(R,E,O={}){super(R),this.type=E,this.data=O}}exports.OpenfortError=O,exports.withOpenfortError=async(R,r,e)=>{try{return await R()}catch(R){let _;const t={};let s;E.isAxiosError(R)?(s=R.response?.status,_=R.response?.data&&R.response.data.error&&function(R){return"type"in R&&"message"in R}(R.response.data.error)?R.response.data.error.message:R.message):_=R.message;const o=void 0!==s&&r[s]?r[s]:r.default,N=new O(_,o,t);throw void 0!==s&&r[s]||e?.(R,N),N}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),t=require("./errors/sentry.js"),i=require("../storage/lazyStorage.js"),n=require("./errors/openfortError.js"),r=require("./config/config.js"),a=require("../auth/authManager.js"),s=require("../api/auth.js"),o=require("../api/embeddedWallet.js"),h=require("../api/user.js"),l=require("../api/proxy.js"),c=require("./openfortInternal.js"),u=require("../utils/typedEventEmitter.js");exports.Openfort=class{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;configuration;eventEmitter;get auth(){if(!this.authInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.userInstance}get proxy(){if(!this.proxyInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.proxyInstance}initializeSynchronously(){try{this.iAuthManager=new a.AuthManager(this.storage),this.openfortInternal=new c.OpenfortInternal(this.storage,this.authManager,this.eventEmitter),this.authInstance=new s.AuthApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.embeddedWalletInstance=new o.EmbeddedWalletApi(this.storage,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.userInstance=new h.UserApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this)),this.proxyInstance=new l.ProxyApi(this.storage,this.backendApiClients,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),async()=>{if(!this.embeddedWalletInstance)throw new n.OpenfortError("Embedded wallet not initialized",n.OpenfortErrorType.MISSING_SIGNER_ERROR);const e=this.embeddedWalletInstance;return t=>e.signMessage(t,{hashMessage:!
|
|
1
|
+
"use strict";var e=require("../../../packages/internal/openapi-clients/dist/index.js"),t=require("./errors/sentry.js"),i=require("../storage/lazyStorage.js"),n=require("./errors/openfortError.js"),r=require("./config/config.js"),a=require("../auth/authManager.js"),s=require("../api/auth.js"),o=require("../api/embeddedWallet.js"),h=require("../api/user.js"),l=require("../api/proxy.js"),c=require("./openfortInternal.js"),u=require("../utils/typedEventEmitter.js");exports.Openfort=class{storage;iAuthManager=null;openfortInternal;initPromise;asyncInitPromise=null;authInstance;embeddedWalletInstance;userInstance;proxyInstance;configuration;eventEmitter;get auth(){if(!this.authInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing auth.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.authInstance}get embeddedWallet(){if(!this.embeddedWalletInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing embeddedWallet.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.embeddedWalletInstance}get user(){if(!this.userInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing user.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.userInstance}get proxy(){if(!this.proxyInstance)throw new n.OpenfortError("Openfort SDK not initialized. Please await waitForInitialization() before accessing proxy.",n.OpenfortErrorType.INVALID_CONFIGURATION);return this.proxyInstance}initializeSynchronously(){try{this.iAuthManager=new a.AuthManager(this.storage),this.openfortInternal=new c.OpenfortInternal(this.storage,this.authManager,this.eventEmitter),this.authInstance=new s.AuthApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.embeddedWalletInstance=new o.EmbeddedWalletApi(this.storage,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),this.eventEmitter),this.userInstance=new h.UserApi(this.storage,this.authManager,this.validateAndRefreshToken.bind(this)),this.proxyInstance=new l.ProxyApi(this.storage,this.backendApiClients,this.validateAndRefreshToken.bind(this),this.ensureInitialized.bind(this),async()=>{if(!this.embeddedWalletInstance)throw new n.OpenfortError("Embedded wallet not initialized",n.OpenfortErrorType.MISSING_SIGNER_ERROR);const e=this.embeddedWalletInstance;return t=>e.signMessage(t,{hashMessage:!0,arrayifyMessage:!0})})}catch(e){throw new n.OpenfortError("Openfort SDK synchronous initialization failed",n.OpenfortErrorType.INVALID_CONFIGURATION)}}constructor(e){this.configuration=new r.SDKConfiguration(e),this.storage=new i.LazyStorage(this.configuration.storage),this.eventEmitter=new u,t.InternalSentry.init({configuration:this.configuration}),this.initializeSynchronously(),this.initPromise=Promise.resolve()}async waitForInitialization(){await this.initPromise,await this.ensureAsyncInitialized()}async getAccessToken(){return await this.ensureInitialized(),this.openfortInternal.getAccessToken()}async validateAndRefreshToken(e){return await this.ensureInitialized(),await this.openfortInternal.validateAndRefreshToken(e)}get backendApiClients(){return new e.BackendApiClients({basePath:this.configuration.backendUrl,accessToken:this.configuration.baseConfiguration.publishableKey})}get authManager(){if(!this.iAuthManager)throw new n.OpenfortError("AuthManager not initialized",n.OpenfortErrorType.INTERNAL_ERROR);return this.iAuthManager}async initializeAsync(){try{if(!await r.SDKConfiguration.isStorageAccessible(this.storage))throw new n.OpenfortError("Storage is not accessible",n.OpenfortErrorType.INVALID_CONFIGURATION);this.authManager.setBackendApiClients(this.backendApiClients,this.configuration.baseConfiguration.publishableKey)}catch(e){throw new n.OpenfortError("Openfort SDK async initialization failed",n.OpenfortErrorType.INTERNAL_ERROR)}}async ensureAsyncInitialized(){this.asyncInitPromise||(this.asyncInitPromise=this.initializeAsync()),await this.asyncInitPromise}async ensureInitialized(){await this.initPromise,await this.ensureAsyncInitialized()}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./core/errors/openfortError.js"),r=require("./types/types.js"),t=require("./wallets/types.js"),o=require("./wallets/iframeManager.js"),n=require("./core/config/config.js"),i=require("./core/openfort.js"),p=require("./api/auth.js"),u=require("./api/embeddedWallet.js"),s=require("./api/user.js"),
|
|
1
|
+
"use strict";var e=require("./core/errors/openfortError.js"),r=require("./types/types.js"),t=require("./wallets/types.js"),o=require("./wallets/iframeManager.js"),n=require("./core/config/config.js"),i=require("./core/openfort.js"),p=require("./api/auth.js"),u=require("./api/embeddedWallet.js"),s=require("./api/user.js"),c=require("./core/openfortInternal.js"),d=require("./api/proxy.js");exports.OpenfortError=e.OpenfortError,Object.defineProperty(exports,"OpenfortErrorType",{enumerable:!0,get:function(){return e.OpenfortErrorType}}),Object.defineProperty(exports,"AccountTypeEnum",{enumerable:!0,get:function(){return r.AccountTypeEnum}}),Object.defineProperty(exports,"AuthActionRequiredActions",{enumerable:!0,get:function(){return r.AuthActionRequiredActions}}),Object.defineProperty(exports,"AuthType",{enumerable:!0,get:function(){return r.AuthType}}),Object.defineProperty(exports,"BasicAuthProvider",{enumerable:!0,get:function(){return r.BasicAuthProvider}}),Object.defineProperty(exports,"ChainTypeEnum",{enumerable:!0,get:function(){return r.ChainTypeEnum}}),Object.defineProperty(exports,"EmbeddedState",{enumerable:!0,get:function(){return r.EmbeddedState}}),Object.defineProperty(exports,"OAuthProvider",{enumerable:!0,get:function(){return r.OAuthProvider}}),Object.defineProperty(exports,"RecoveryMethod",{enumerable:!0,get:function(){return r.RecoveryMethod}}),Object.defineProperty(exports,"ThirdPartyOAuthProvider",{enumerable:!0,get:function(){return r.ThirdPartyOAuthProvider}}),Object.defineProperty(exports,"TokenType",{enumerable:!0,get:function(){return r.TokenType}}),Object.defineProperty(exports,"ShieldAuthType",{enumerable:!0,get:function(){return t.ShieldAuthType}}),exports.MissingProjectEntropyError=o.MissingProjectEntropyError,exports.MissingRecoveryPasswordError=o.MissingRecoveryPasswordError,exports.NotConfiguredError=o.NotConfiguredError,exports.WrongRecoveryPasswordError=o.WrongRecoveryPasswordError,exports.OpenfortConfiguration=n.OpenfortConfiguration,exports.SDKConfiguration=n.SDKConfiguration,exports.ShieldConfiguration=n.ShieldConfiguration,exports.Openfort=i.Openfort,exports.AuthApi=p.AuthApi,exports.EmbeddedWalletApi=u.EmbeddedWalletApi,exports.UserApi=s.UserApi,exports.OpenfortInternal=c.OpenfortInternal,exports.ProxyApi=d.ProxyApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,o,t,r,E,A,
|
|
1
|
+
"use strict";var e,o,t,r,E,A,p,s,d,T,i,n;exports.EmbeddedState=void 0,(e=exports.EmbeddedState||(exports.EmbeddedState={}))[e.NONE=0]="NONE",e[e.UNAUTHENTICATED=1]="UNAUTHENTICATED",e[e.EMBEDDED_SIGNER_NOT_CONFIGURED=2]="EMBEDDED_SIGNER_NOT_CONFIGURED",e[e.CREATING_ACCOUNT=3]="CREATING_ACCOUNT",e[e.READY=4]="READY",exports.OpenfortEvents=void 0,(o=exports.OpenfortEvents||(exports.OpenfortEvents={})).LOGGED_OUT="loggedOut",o.SWITCH_ACCOUNT="switchAccount",o.TOKEN_REFRESHED="tokenRefreshed",exports.RecoveryMethod=void 0,(t=exports.RecoveryMethod||(exports.RecoveryMethod={})).PASSWORD="password",t.AUTOMATIC="automatic",exports.AccountType=void 0,(r=exports.AccountType||(exports.AccountType={})).UPGRADEABLE_V4="Upgradeable_v04",r.MANAGED_V4="Managed_v04",r.ERC6551_V4="ERC6551_v04",r.ERC6551_V5="ERC6551_v05",r.RECOVERABLE_V4="Recoverable_v04",r.MANAGED_V5="Managed_v05",r.UPGRADEABLE_V5="Upgradeable_v05",r.UPGRADEABLE_V6="Upgradeable_v06",r.ZKSYNC_UPGRADEABLE_V1="zksync_upgradeable_v1",r.ZKSYNC_UPGRADEABLE_V2="zksync_upgradeable_v2",exports.AuthType=void 0,(E=exports.AuthType||(exports.AuthType={})).OPENFORT="openfort",E.THIRD_PARTY="thirdParty",exports.TokenType=void 0,(A=exports.TokenType||(exports.TokenType={})).ID_TOKEN="idToken",A.CUSTOM_TOKEN="customToken",exports.ThirdPartyOAuthProvider=void 0,(p=exports.ThirdPartyOAuthProvider||(exports.ThirdPartyOAuthProvider={})).ACCELBYTE="accelbyte",p.FIREBASE="firebase",p.LOOTLOCKER="lootlocker",p.PLAYFAB="playfab",p.SUPABASE="supabase",p.CUSTOM="custom",p.OIDC="oidc",exports.BasicAuthProvider=void 0,(s=exports.BasicAuthProvider||(exports.BasicAuthProvider={})).EMAIL="email",s.WALLET="wallet",exports.OAuthProvider=void 0,(d=exports.OAuthProvider||(exports.OAuthProvider={})).GOOGLE="google",d.TWITTER="twitter",d.APPLE="apple",d.FACEBOOK="facebook",d.DISCORD="discord",d.EPIC_GAMES="epic_games",d.LINE="line",exports.AuthActionRequiredActions=void 0,(exports.AuthActionRequiredActions||(exports.AuthActionRequiredActions={})).ACTION_VERIFY_EMAIL="verify_email",exports.CodeChallengeMethodEnum=void 0,(T=exports.CodeChallengeMethodEnum||(exports.CodeChallengeMethodEnum={})).PLAIN="plain",T.S256="S256",exports.AccountTypeEnum=void 0,(i=exports.AccountTypeEnum||(exports.AccountTypeEnum={})).EOA="Externally Owned Account",i.SMART_ACCOUNT="Smart Account",exports.ChainTypeEnum=void 0,(n=exports.ChainTypeEnum||(exports.ChainTypeEnum={})).EVM="EVM",n.SVM="SVM";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.9.
|
|
1
|
+
"use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.9.6";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../
|
|
1
|
+
"use strict";var t=require("../core/configuration/authentication.js"),e=require("../core/errors/openfortError.js"),a=require("../types/types.js");require("./types.js");var r=require("../core/configuration/account.js");require("./messaging/browserMessenger/backwardCompatibility.js"),require("../storage/istorage.js");var n=require("../core/config/config.js");require("../core/errors/sentry.js"),require("jose"),require("./evm/types.js"),require("./evm/JsonRpcError.js"),require("eventemitter3"),require("./evm/provider/eip6963.js");exports.EmbeddedSigner=class{iframeManager;storage;backendApiClients;eventEmitter;constructor(t,e,a,r){this.iframeManager=t,this.storage=e,this.backendApiClients=a,this.eventEmitter=r}async configure(o){const s=await this.iframeManager.configure(o),i=await t.Authentication.fromStorage(this.storage);if(!i)throw new e.OpenfortError("No access token found",e.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const d=n.SDKConfiguration.fromStorage();if(!d)throw new e.OpenfortError("Configuration not found",e.OpenfortErrorType.INVALID_CONFIGURATION);return s?.account||e.withOpenfortError(async()=>{const t=await this.backendApiClients.accountsApi.getAccountsV2({chainId:s.chainId,address:s.address},{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}});if(0===t.data.data.length)throw new e.OpenfortError("No account found",e.OpenfortErrorType.MISSING_SIGNER_ERROR);const n=new r.Account({user:t.data.data[0].user,chainType:t.data.data[0].accountType,id:t.data.data[0].id,address:t.data.data[0].address,ownerAddress:t.data.data[0].ownerAddress,accountType:t.data.data[0].accountType,createdAt:t.data.data[0].createdAt,implementationType:t.data.data[0].smartAccount?.implementationType,chainId:t.data.data[0].chainId,factoryAddress:t.data.data[0].smartAccount?.factoryAddress,salt:t.data.data[0].smartAccount?.salt});return n.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.SWITCH_ACCOUNT,t.data.data[0].address),n},{default:e.OpenfortErrorType.AUTHENTICATION_ERROR}),e.withOpenfortError(async()=>{const t=await this.backendApiClients.accountsApi.getAccountV2({id:s.account},{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}}),e=new r.Account({user:t.data.user,chainType:t.data.accountType,id:t.data.id,address:t.data.address,ownerAddress:t.data.ownerAddress,accountType:t.data.accountType,createdAt:t.data.createdAt,implementationType:t.data.smartAccount?.implementationType,chainId:t.data.chainId,salt:t.data.smartAccount?.salt,factoryAddress:t.data.smartAccount?.factoryAddress});return e.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.SWITCH_ACCOUNT,t.data.address),e},{default:e.OpenfortErrorType.AUTHENTICATION_ERROR})}async sign(t,e,a){return await this.iframeManager.sign(t,e,a)}async export(){return await this.iframeManager.export()}async switchChain({chainId:t}){const e=await this.iframeManager.switchChain(t),a=await r.Account.fromStorage(this.storage);new r.Account({...a,id:e.account,chainId:t}).save(this.storage)}async create(o){const s=await this.iframeManager.create(o),i=await t.Authentication.fromStorage(this.storage);if(!i)throw new e.OpenfortError("No access token found",e.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const d=n.SDKConfiguration.fromStorage();if(!d)throw new e.OpenfortError("Configuration not found",e.OpenfortErrorType.INVALID_CONFIGURATION);return e.withOpenfortError(async()=>{const t=await this.backendApiClients.accountsApi.getAccountV2({id:s.account},{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}}),e=new r.Account({user:t.data.user,chainType:t.data.accountType,id:t.data.id,address:t.data.address,ownerAddress:t.data.ownerAddress,accountType:t.data.accountType,createdAt:t.data.createdAt,implementationType:t.data.smartAccount?.implementationType,chainId:t.data.chainId,salt:t.data.smartAccount?.salt,factoryAddress:t.data.smartAccount?.factoryAddress});return e.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.SWITCH_ACCOUNT,t.data.address),e},{default:e.OpenfortErrorType.AUTHENTICATION_ERROR})}async recover(o){const s=await this.iframeManager.recover(o),i=await t.Authentication.fromStorage(this.storage);if(!i)throw new e.OpenfortError("No access token found",e.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const d=n.SDKConfiguration.fromStorage();if(!d)throw new e.OpenfortError("Configuration not found",e.OpenfortErrorType.INVALID_CONFIGURATION);return e.withOpenfortError(async()=>{const t=await this.backendApiClients.accountsApi.getAccountV2({id:s.account},{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}}),e=new r.Account({user:t.data.user,chainType:t.data.accountType,id:t.data.id,address:t.data.address,ownerAddress:t.data.ownerAddress,accountType:t.data.accountType,createdAt:t.data.createdAt,implementationType:t.data.smartAccount?.implementationType,chainId:t.data.chainId,salt:t.data.smartAccount?.salt,factoryAddress:t.data.smartAccount?.factoryAddress});return e.save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.SWITCH_ACCOUNT,t.data.address),e},{default:e.OpenfortErrorType.AUTHENTICATION_ERROR})}async setEmbeddedRecovery({recoveryMethod:t,recoveryPassword:e,encryptionSession:a}){await this.iframeManager.setEmbeddedRecovery(t,e,a)}async disconnect(){this.eventEmitter.emit(a.OpenfortEvents.LOGGED_OUT)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../utils/debug.js"),t=require("../../core/configuration/authentication.js"),r=require("./types.js"),s=require("./JsonRpcError.js"),
|
|
1
|
+
"use strict";var e=require("../../utils/debug.js"),t=require("../../core/configuration/authentication.js"),r=require("./types.js"),s=require("./JsonRpcError.js"),i=require("./signTypedDataV4.js"),a=require("../../types/types.js"),n=require("../../utils/typedEventEmitter.js"),o=require("../../utils/chains/index.js"),c=require("../../core/configuration/account.js"),h=require("./addEthereumChain.js"),d=require("./registerSession.js"),u=require("./revokeSession.js"),p=require("./sendCalls.js"),l=require("./getCallsStatus.js"),g=require("./personalSign.js"),w=require("./estimateGas.js"),m=require("../../utils/crypto.js");exports.EvmProvider=class{#e;#t;#r;#s;updatePolicy(e){this.#t=e}#i;#a;#n=null;#o;isOpenfort=!0;#c;constructor({storage:e,backendApiClients:t,openfortEventEmitter:r,policyId:s,ensureSigner:i,chains:o,validateAndRefreshSession:c}){this.#c=i,this.#e=e,this.#r=o,this.#t=s,this.#i=c,this.#o=t,this.#o=t,this.#a=new n,r.on(a.OpenfortEvents.LOGGED_OUT,this.#h),r.on(a.OpenfortEvents.SWITCH_ACCOUNT,this.#d)}#u=async()=>(this.#s||(this.#s=await this.#c()),this.#s);#h=async()=>{this.#s=void 0,this.#a.emit(r.ProviderEvent.ACCOUNTS_CHANGED,[])};#d=async e=>{this.#a.emit(r.ProviderEvent.ACCOUNTS_CHANGED,[e])};async getRpcProvider(){if(!this.#n){const e=await c.Account.fromStorage(this.#e),t=e?.chainId||8453;await import("@ethersproject/providers").then(e=>{const r=this.#r?this.#r[t]:void 0;this.#n=new e.StaticJsonRpcProvider(r??o.defaultChainRpcs[t])})}if(!this.#n)throw new Error("RPC provider not initialized");return this.#n}async#p(a){switch(a.method){case"eth_accounts":{const e=await c.Account.fromStorage(this.#e);return e?[e.address]:[]}case"eth_requestAccounts":{const e=await c.Account.fromStorage(this.#e);if(e)return this.#a.emit(r.ProviderEvent.ACCOUNTS_CONNECT,{chainId:String(e.chainId)}),[e.address];throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - must be authenticated and configured with a signer.")}case"eth_sendTransaction":{const e=await c.Account.fromStorage(this.#e),r=await this.#u(),i=await t.Authentication.fromStorage(this.#e);if(!e||!i)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await p.sendCalls({params:a.params||[],signer:r,account:e,authentication:i,backendClient:this.#o,policyId:this.#t})}case"eth_estimateGas":{const e=await c.Account.fromStorage(this.#e),r=await t.Authentication.fromStorage(this.#e);if(!e||!r)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await w.estimateGas({params:a.params||[],account:e,authentication:r,backendClient:this.#o,policyId:this.#t})}case"eth_signTypedData":case"eth_signTypedData_v4":{const e=await c.Account.fromStorage(this.#e),t=await this.#u();if(!e)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");await this.#i();const r=await this.getRpcProvider();return await i.signTypedDataV4({method:a.method,params:a.params||[],signer:t,implementationType:e.implementationType||e.type,rpcProvider:r,account:e})}case"personal_sign":{const t=await c.Account.fromStorage(this.#e);if(!t)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");const r=await this.#u();return await this.#i(),e.debugLog("[personal_sign] validateAndRefreshSession:"),await g.personalSign({params:a.params||[],signer:r,account:t})}case"eth_chainId":{const e=await this.getRpcProvider(),{chainId:t}=await e.detectNetwork();return m.numberToHex(t)}case"wallet_switchEthereumChain":{const e=await this.#u();if(!a.params||!Array.isArray(a.params)||0===a.params.length)throw new s.JsonRpcError(s.RpcErrorCode.INVALID_PARAMS,"Invalid parameters for wallet_switchEthereumChain");await this.#i();try{const t=parseInt(a.params[0].chainId,16);await e.switchChain({chainId:t}),await import("@ethersproject/providers").then(e=>{const r=this.#r?this.#r[t]:void 0;this.#n=new e.StaticJsonRpcProvider(r??o.defaultChainRpcs[t])})}catch(e){const t=e;throw new s.JsonRpcError(s.RpcErrorCode.INTERNAL_ERROR,`Failed to switch chain: ${t.message}`)}return null}case"wallet_addEthereumChain":{await this.#u();const e=await this.getRpcProvider();return await h.addEthereumChain({params:a.params||[],rpcProvider:e,storage:this.#e})}case"wallet_showCallsStatus":return null;case"wallet_getCallsStatus":{const e=await c.Account.fromStorage(this.#e);await this.#u();const r=await t.Authentication.fromStorage(this.#e);if(!e||!r)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await l.getCallStatus({params:a.params||{},authentication:r,backendClient:this.#o,account:e})}case"wallet_sendCalls":{const e=await c.Account.fromStorage(this.#e),r=await this.#u(),i=await t.Authentication.fromStorage(this.#e);if(!e||!i)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await p.sendCalls({params:a.params?a.params[0].calls:[],signer:r,account:e,authentication:i,backendClient:this.#o,policyId:this.#t})}case"wallet_grantPermissions":{const e=await c.Account.fromStorage(this.#e),r=await this.#u(),i=await t.Authentication.fromStorage(this.#e);if(!e||!i)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await d.registerSession({params:a.params||[],signer:r,account:e,authentication:i,backendClient:this.#o,policyId:this.#t})}case"wallet_revokePermissions":{const e=await c.Account.fromStorage(this.#e),r=await this.#u(),i=await t.Authentication.fromStorage(this.#e);if(!e||!i)throw new s.JsonRpcError(s.ProviderErrorCode.UNAUTHORIZED,"Unauthorized - call eth_requestAccounts first");return await this.#i(),await u.revokeSession({params:a.params||[],signer:r,account:e,authentication:i,backendClient:this.#o})}case"wallet_getCapabilities":{const e=await this.getRpcProvider(),{chainId:t}=await e.detectNetwork();return{[m.numberToHex(t)]:{permissions:{supported:!0,signerTypes:["account","key"],keyTypes:["secp256k1"],permissionTypes:["contract-calls"]},paymasterService:{supported:!0},atomicBatch:{supported:!0}}}}case"eth_gasPrice":case"eth_getBalance":case"eth_getCode":case"eth_getStorageAt":case"eth_call":case"eth_blockNumber":case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getTransactionByHash":case"eth_getTransactionReceipt":case"eth_getTransactionCount":return(await this.getRpcProvider()).send(a.method,a.params||[]);default:throw new s.JsonRpcError(s.ProviderErrorCode.UNSUPPORTED_METHOD,`${a.method}: Method not supported`)}}async request(e){try{return this.#p(e)}catch(e){if(e instanceof s.JsonRpcError)throw e;if(e instanceof Error)throw new s.JsonRpcError(s.RpcErrorCode.INTERNAL_ERROR,e.message);throw new s.JsonRpcError(s.RpcErrorCode.INTERNAL_ERROR,"Internal error")}}on(e,t){this.#a.on(e,t)}removeListener(e,t){this.#a.off(e,t)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=require("../../utils/crypto.js"),r=require("./JsonRpcError.js"),s=require("./walletHelpers.js");exports.personalSign=async({params:a,signer:o,account:t})=>{const n=a[0],i=a[1];if(!i||!n)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"personal_sign requires an address and a message");if(i.toLowerCase()!==t.address.toLowerCase())throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,"personal_sign requires the signer to be the from address");const{hashMessage:d}=await import("@ethersproject/hash");return await s.signMessage({hash:d(e.hexToString(n)),implementationType:t.implementationType||t.type,chainId:Number(t.chainId),signer:o,address:i,salt:t.salt,factoryAddress:t.factoryAddress,ownerAddress:t.ownerAddress})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../core/errors/openfortError.js"),t=require("./JsonRpcError.js");function r(e){return{data:"token-allowance"===e.type?{allowance:e.data.allowance.toString()}:"gas-limit"===e.type?{limit:e.data.limit.toString()}:e.data,type:"string"==typeof e.type?e.type:e.type.custom}}function i(e){return{...e,policies:e.policies.map(r),required:e.required??!1,type:"string"==typeof e.type?e.type:e.type.custom}}function a(e){return{expiry:e.validUntil?Number(e.validUntil):0,grantedPermissions:e.whitelist?e.whitelist.map(t=>({type:"contract-call",data:{address:t,calls:[]},policies:[{data:{limit:e.limit},type:{custom:"usage-limit"}}]})):[],permissionsContext:e.id}}exports.registerSession=async({params:r,signer:s,account:n,authentication:o,backendClient:c,policyId:p})=>{const l=await(async(r,a,s,n,o)=>{const c=r[0],p=Math.floor((new Date).getTime()/1e3),l=Math.floor(new Date(Date.now()+1e3*c.expiry).getTime()/1e3),d=c.permissions.map(i),y=d.filter(e=>"contract-call"===e.type||"erc20-token-transfer"===e.type).map(e=>e.data.address),u=d[0].policies.find(e=>"usage-limit"===e.type)?.data?.limit;let g;if("signer"in c&&c.signer){if("keys"===c.signer.type)throw new t.JsonRpcError(t.RpcErrorCode.INVALID_PARAMS,"Multi-key signers are not supported for session creation");"key"!==c.signer.type&&"account"!==c.signer.type||(g=c.signer.data.id)}else"account"in c&&c.account&&(g=c.account);if(!g)throw new t.JsonRpcError(t.RpcErrorCode.INVALID_PARAMS,"Failed to request permissions - missing session address");const m=((e,t,r,i,a,s=!1,n,o,c,p)=>{const l={address:e,chainId:t,validAfter:r,validUntil:i,optimistic:s,whitelist:n,player:o};return a&&(l.policy=a),
|
|
1
|
+
"use strict";var e=require("../../core/errors/openfortError.js"),t=require("./JsonRpcError.js");function r(e){return{data:"token-allowance"===e.type?{allowance:e.data.allowance.toString()}:"gas-limit"===e.type?{limit:e.data.limit.toString()}:e.data,type:"string"==typeof e.type?e.type:e.type.custom}}function i(e){return{...e,policies:e.policies.map(r),required:e.required??!1,type:"string"==typeof e.type?e.type:e.type.custom}}function a(e){return{expiry:e.validUntil?Number(e.validUntil):0,grantedPermissions:e.whitelist?e.whitelist.map(t=>({type:"contract-call",data:{address:t,calls:[]},policies:[{data:{limit:e.limit},type:{custom:"usage-limit"}}]})):[],permissionsContext:e.id}}exports.registerSession=async({params:r,signer:s,account:n,authentication:o,backendClient:c,policyId:p})=>{const l=await(async(r,a,s,n,o)=>{const c=r[0],p=Math.floor((new Date).getTime()/1e3),l=Math.floor(new Date(Date.now()+1e3*c.expiry).getTime()/1e3),d=c.permissions.map(i),y=d.filter(e=>"contract-call"===e.type||"erc20-token-transfer"===e.type).map(e=>e.data.address),u=d[0].policies.find(e=>"usage-limit"===e.type)?.data?.limit;let g;if("signer"in c&&c.signer){if("keys"===c.signer.type)throw new t.JsonRpcError(t.RpcErrorCode.INVALID_PARAMS,"Multi-key signers are not supported for session creation");"key"!==c.signer.type&&"account"!==c.signer.type||(g=c.signer.data.id)}else"account"in c&&c.account&&(g=c.account);if(!g)throw new t.JsonRpcError(t.RpcErrorCode.INVALID_PARAMS,"Failed to request permissions - missing session address");const m=((e,t,r,i,a,s=!1,n,o,c,p)=>{const l={address:e,chainId:t,validAfter:r,validUntil:i,optimistic:s,whitelist:n,player:o,account:p};return a&&(l.policy=a),c&&(l.limit=c),l})(g,s.chainId,p,l,o,!1,y,n.player,u,s.id);return e.withOpenfortError(async()=>(await a.sessionsApi.createSession({createSessionRequest:m},{headers:{authorization:`Bearer ${a.config.backend.accessToken}`,"x-player-token":n.token,"x-auth-provider":n.thirdPartyProvider,"x-token-type":n.thirdPartyTokenType}})).data,{default:e.OpenfortErrorType.AUTHENTICATION_ERROR})})(r,c,n,o,p).catch(e=>{throw new t.JsonRpcError(t.RpcErrorCode.TRANSACTION_REJECTED,e.message)});if(l?.nextAction?.payload?.signableHash){let r;r=[300,531050104,324,50104,2741,11124].includes(n.chainId)?await s.sign(l.nextAction.payload.signableHash,!1,!1):await s.sign(l.nextAction.payload.signableHash);return a(await e.withOpenfortError(async()=>(await c.sessionsApi.signatureSession({id:l.id,signatureRequest:{signature:r}})).data,{default:e.OpenfortErrorType.AUTHENTICATION_ERROR}).catch(e=>{throw new t.JsonRpcError(t.RpcErrorCode.TRANSACTION_REJECTED,e.message)}))}if(!1===l.isActive)throw new t.JsonRpcError(t.RpcErrorCode.TRANSACTION_REJECTED,"Failed to grant permissions");return a(l)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../core/errors/openfortError.js"),r=require("./JsonRpcError.js");exports.revokeSession=async({params:n,signer:a,account:
|
|
1
|
+
"use strict";var e=require("../../core/errors/openfortError.js"),r=require("./JsonRpcError.js");exports.revokeSession=async({params:n,signer:a,account:t,authentication:s,backendClient:o,policyId:i})=>{const c=n[0];if(!c.permissionContext)return await a.disconnect(),{};const d=await(async(r,n,a,t,s)=>{const o=((e,r,n,a,t)=>{const s={address:e,chainId:r,player:n,account:t};return a&&(s.policy=a),s})(r.permissionContext,a.chainId,t.player,s,a.id);return e.withOpenfortError(async()=>(await n.sessionsApi.revokeSession({revokeSessionRequest:o},{headers:{authorization:`Bearer ${n.config.backend.accessToken}`,"x-player-token":t.token,"x-auth-provider":t.thirdPartyProvider,"x-token-type":t.thirdPartyTokenType}})).data,{default:e.OpenfortErrorType.AUTHENTICATION_ERROR})})(c,o,t,s,i).catch(e=>{throw new r.JsonRpcError(r.RpcErrorCode.TRANSACTION_REJECTED,e.message)});if(d?.nextAction?.payload?.signableHash){let e;e=[300,531050104,324,50104,2741,11124].includes(t.chainId)?await a.sign(d.nextAction.payload.signableHash,!1,!1):await a.sign(d.nextAction.payload.signableHash);return(await o.sessionsApi.signatureSession({id:d.id,signatureRequest:{signature:e}}).catch(e=>{throw new r.JsonRpcError(r.RpcErrorCode.TRANSACTION_REJECTED,e.message)})).data}return d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var r=require("../../core/errors/openfortError.js"),e=require("./JsonRpcError.js");exports.sendCalls=async({params:a,signer:t,account:n,authentication:o,backendClient:s,policyId:i})=>{const c=a[0]?.capabilities?.paymasterService?.policy??i,p=await(async(a,t,n,o,s)=>{const i=a.map(r=>{if(!r.to)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,'wallet_sendCalls requires a "to" field');return{to:String(r.to),data:r.data?String(r.data):void 0,value:r.value?String(r.value):void 0}});return r.withOpenfortError(async()=>(await t.transactionIntentsApi.createTransactionIntent({createTransactionIntentRequest:{policy:s,chainId:n.chainId,interactions:i}},{headers:{authorization:`Bearer ${t.config.backend.accessToken}`,"x-player-token":o.token,"x-auth-provider":o.thirdPartyProvider,"x-token-type":o.thirdPartyTokenType}})).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})})(a,s,n,o,c).catch(r=>{throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,r.message)});if(p.response?.error.reason)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,p.response?.error.reason);if(p?.nextAction?.payload?.signableHash){let a;a=[300,531050104,324,50104,2741,11124].includes(n.chainId)?await t.sign(p.nextAction.payload.signableHash,!1,!1):await t.sign(p.nextAction.payload.signableHash);const o=await r.withOpenfortError(async()=>await s.transactionIntentsApi.signature({id:p.id,signatureRequest:{signature:a}}),{default:r.OpenfortErrorType.AUTHENTICATION_ERROR}).catch(r=>{throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,r.message)});if(0===o.data.response?.status)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,o.data.response?.error.reason);return o.data.response?.transactionHash}return p.response?.transactionHash};
|
|
1
|
+
"use strict";var r=require("../../core/errors/openfortError.js"),e=require("./JsonRpcError.js");exports.sendCalls=async({params:a,signer:t,account:n,authentication:o,backendClient:s,policyId:i})=>{const c=a[0]?.capabilities?.paymasterService?.policy??i,p=await(async(a,t,n,o,s)=>{const i=a.map(r=>{if(!r.to)throw new e.JsonRpcError(e.RpcErrorCode.INVALID_PARAMS,'wallet_sendCalls requires a "to" field');return{to:String(r.to),data:r.data?String(r.data):void 0,value:r.value?String(r.value):void 0}});return r.withOpenfortError(async()=>(await t.transactionIntentsApi.createTransactionIntent({createTransactionIntentRequest:{account:n.id,policy:s,chainId:n.chainId,interactions:i}},{headers:{authorization:`Bearer ${t.config.backend.accessToken}`,"x-player-token":o.token,"x-auth-provider":o.thirdPartyProvider,"x-token-type":o.thirdPartyTokenType}})).data,{default:r.OpenfortErrorType.AUTHENTICATION_ERROR})})(a,s,n,o,c).catch(r=>{throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,r.message)});if(p.response?.error.reason)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,p.response?.error.reason);if(p?.nextAction?.payload?.signableHash){let a;a=[300,531050104,324,50104,2741,11124].includes(n.chainId)?await t.sign(p.nextAction.payload.signableHash,!1,!1):await t.sign(p.nextAction.payload.signableHash);const o=await r.withOpenfortError(async()=>await s.transactionIntentsApi.signature({id:p.id,signatureRequest:{signature:a}}),{default:r.OpenfortErrorType.AUTHENTICATION_ERROR}).catch(r=>{throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,r.message)});if(0===o.data.response?.status)throw new e.JsonRpcError(e.RpcErrorCode.TRANSACTION_REJECTED,o.data.response?.error.reason);return o.data.response?.transactionHash}return p.response?.transactionHash};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=require("./walletHelpers.js"),r=require("./JsonRpcError.js");const a=["types","domain","primaryType","message"],t=(e,t)=>{let o;if("string"==typeof e)try{o=JSON.parse(e)}catch(e){throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,`Failed to parse typed data JSON: ${e}`)}else{if("object"!=typeof e)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,`Invalid typed data argument: ${e}`);o=e}if(!(e=>a.every(r=>r in e))(o))throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,`Invalid typed data argument. The following properties are required: \n ${a.join(", ")}`);const n=o.domain?.chainId;if(n&&("string"==typeof n&&(n.startsWith("0x")?o.domain.chainId=parseInt(n,16):o.domain.chainId=parseInt(n,10)),o.domain.chainId!==t))throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,`Invalid chainId, expected ${t}`);return o};exports.signTypedDataV4=async({params:a,method:o,signer:n,implementationType:s,rpcProvider:d,account:i})=>{const p=a[0],c=a[1];if(!p||!c)throw new r.JsonRpcError(r.RpcErrorCode.INVALID_PARAMS,`${o} requires an address and a typed data JSON`);const{chainId:h}=await d.detectNetwork(),I=t(c,h),y={...I.types};delete y.EIP712Domain;const{_TypedDataEncoder:m}=await import("@ethersproject/hash"),A=m.hash(I.domain,y,I.message);return await e.signMessage({hash:A,implementationType:s,chainId:h,signer:n,address:p,ownerAddress:i.ownerAddress,factoryAddress:i.factoryAddress,salt:i.salt})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../types/types.js");exports.
|
|
1
|
+
"use strict";var e=require("../../types/types.js");exports.signMessage=async t=>{const{hash:s,signer:a,ownerAddress:r,factoryAddress:c,salt:o,chainId:n,address:i,implementationType:d}=t;let p=s;if([e.AccountType.UPGRADEABLE_V5,e.AccountType.UPGRADEABLE_V6,e.AccountType.ZKSYNC_UPGRADEABLE_V1,e.AccountType.ZKSYNC_UPGRADEABLE_V2].includes(d)){const e={name:"Openfort",version:"0.5",chainId:Number(n),verifyingContract:i},t={OpenfortMessage:[{name:"hashedMessage",type:"bytes32"}]},s={hashedMessage:p},{_TypedDataEncoder:a}=await import("@ethersproject/hash");p=a.hash(e,t,s)}const A=await a.sign(p,!1,!1);if(c&&o&&[e.AccountType.UPGRADEABLE_V5,e.AccountType.UPGRADEABLE_V6].includes(d)){const{id:e}=await import("@ethersproject/hash"),{defaultAbiCoder:t}=await import("@ethersproject/abi"),{hexConcat:s}=await import("@ethersproject/bytes"),a=s([e("createAccountWithNonce(address,bytes32,bool)").slice(0,10),t.encode(["address","bytes32","bool"],[r,o,!1])]);return s([t.encode(["address","bytes","bytes"],[c,a,A]),"0x6492649264926492649264926492649264926492649264926492649264926492"])}return A};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../core/configuration/account.js"),r=require("./messaging/browserMessenger/connect.js");require("./messaging/browserMessenger/backwardCompatibility.js");var t=require("../storage/istorage.js"),i=require("../core/errors/openfortError.js"),n=require("../utils/debug.js"),o=require("../utils/crypto.js"),s=require("../core/configuration/authentication.js"),a=require("./messaging/ReactNativeMessenger.js"),c=require("./types.js"),u=require("../core/errors/sentry.js");class d extends Error{constructor(){super("This embedded signer requires a password to be recovered")}}class h extends Error{constructor(){super("MissingProjectEntropyError")}}class g extends Error{constructor(){super("Wrong recovery password for this embedded signer")}}class f extends Error{constructor(){super("Not configured")}}exports.IframeManager=class{messenger;connection;remote;storage;sdkConfiguration;isInitialized=!1;configurationRequest;constructor(e,r,t){if(!e)throw new i.OpenfortError("Configuration is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);if(!r)throw new i.OpenfortError("Storage is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);if(!t)throw new i.OpenfortError("Messenger is required for IframeManager",i.OpenfortErrorType.INVALID_CONFIGURATION);this.sdkConfiguration=e,this.storage=r,this.messenger=t}async initialize(){if(!this.isInitialized){n.debugLog("Initializing IframeManager connection..."),this.messenger.initialize({validateReceivedMessage:e=>!(!e||"object"!=typeof e),log:n.debugLog}),this.connection=r({messenger:this.messenger,timeout:1e4,log:n.debugLog});try{this.remote=await this.connection.promise,this.isInitialized=!0,n.debugLog("IframeManager connection established")}catch(e){const r=e;throw u.sentry.captureException(r),this.destroy(),n.debugLog("Failed to establish connection:",r),new i.OpenfortError(`Failed to establish iFrame connection: ${r.cause||r.message}`,i.OpenfortErrorType.INTERNAL_ERROR,e)}}}async ensureConnection(){if(this.isInitialized&&this.remote||await this.initialize(),!this.remote)throw new i.OpenfortError("Failed to establish connection",i.OpenfortErrorType.INTERNAL_ERROR);return this.remote}handleError(e){if(c.isErrorResponse(e)){if(e.error===c.NOT_CONFIGURED_ERROR)throw new f;if(e.error===c.MISSING_USER_ENTROPY_ERROR)throw this.storage.remove(t.StorageKeys.ACCOUNT),new d;if(e.error===c.MISSING_PROJECT_ENTROPY_ERROR)throw this.storage.remove(t.StorageKeys.ACCOUNT),new h;if(e.error===c.INCORRECT_USER_ENTROPY_ERROR)throw new g;throw new i.OpenfortError(`Unknown error: ${e.error}`,i.OpenfortErrorType.INTERNAL_ERROR)}throw e}async buildRequestConfiguration(){const e=await s.Authentication.fromStorage(this.storage);if(!e)throw new i.OpenfortError("Must be authenticated to create a signer",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{thirdPartyProvider:e.thirdPartyProvider,thirdPartyTokenType:e.thirdPartyTokenType,token:e.token,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl}}async buildIFrameRequestConfiguration(){const e=await s.Authentication.fromStorage(this.storage);if(!e)throw new i.OpenfortError("Must be authenticated to create a signer",i.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const r={auth:c.ShieldAuthType.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyTokenType:e.thirdPartyTokenType??null,thirdPartyProvider:e.thirdPartyProvider??null,accessToken:e.token,playerID:e.player,recovery:r,chainId:null,password:null}}async configure(r){if(!this.sdkConfiguration.shieldConfiguration)throw new i.OpenfortError("shieldConfiguration is required",i.OpenfortErrorType.INVALID_CONFIGURATION);const t=await e.Account.fromStorage(this.storage),n=await this.ensureConnection(),s=await this.buildIFrameRequestConfiguration();s.chainId=r?.chainId??t?.chainId??null,s.password=r?.entropy?.recoveryPassword??null,s.recovery={...s.recovery,encryptionSession:r?.entropy?.encryptionSession};const a={uuid:o.randomUUID(),action:c.Event.CONFIGURE,chainId:s.chainId,recovery:s.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:s.accessToken,playerID:s.playerID,thirdPartyProvider:s.thirdPartyProvider,thirdPartyTokenType:s.thirdPartyTokenType,encryptionKey:s.password,encryptionPart:this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionKey??null,encryptionSession:s.recovery?.encryptionSession??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl},u=await n.configure(a);return c.isErrorResponse(u)&&this.handleError(u),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",u.version??"undefined"),u}async sign(e,r,t){n.debugLog("[iframe] ensureConnection");const i=await this.ensureConnection(),s=new c.SignRequest(o.randomUUID(),e,r,t,await this.buildRequestConfiguration());n.debugLog("[iframe] done ensureConnection");try{const e=await i.sign(s);return n.debugLog("[iframe] response",e),c.isErrorResponse(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e.signature}catch(i){if(i instanceof f)return await this.configure(this.configurationRequest),this.sign(e,r,t);throw i}}async switchChain(e){const r=await this.ensureConnection(),t=new c.SwitchChainRequest(o.randomUUID(),e,await this.buildRequestConfiguration());try{const i=await r.switchChain(t);return c.isErrorResponse(i)&&this.handleError(i),this.configurationRequest&&(this.configurationRequest.chainId=e),i}catch(r){if(r instanceof f)return await this.configure(this.configurationRequest),this.switchChain(e);throw r}}async export(){const e=await this.ensureConnection(),r=new c.ExportPrivateKeyRequest(o.randomUUID(),await this.buildRequestConfiguration());try{const t=await e.export(r);return c.isErrorResponse(t)&&this.handleError(t),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",t.version??"undefined"),t.key}catch(e){if(e instanceof f)return await this.configure(this.configurationRequest),this.export();throw e}}async setEmbeddedRecovery(e,r,t){const i=await this.ensureConnection(),n=new c.SetRecoveryMethodRequest(o.randomUUID(),e,r,t,await this.buildRequestConfiguration());try{const e=await i.setRecoveryMethod(n);c.isErrorResponse(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined")}catch(i){if(i instanceof f)return await this.configure(this.configurationRequest),this.setEmbeddedRecovery(e,r,t);throw i}}async getCurrentDevice(e){const r=await this.ensureConnection(),t=new c.GetCurrentDeviceRequest(o.randomUUID(),e);try{const e=await r.getCurrentDevice(t);return c.isErrorResponse(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e}catch(e){if(e instanceof f)return null;throw e}}async updateAuthentication(){if(!this.isLoaded()||!this.remote)return void n.debugLog("IframeManager not loaded, skipping authentication update");const e=await s.Authentication.fromStorage(this.storage);if(!e)return void n.debugLog("No authentication found, skipping update");const r=new c.UpdateAuthenticationRequest(o.randomUUID(),e.token);try{n.debugLog("Updating authentication in iframe with token:",e.token);const t=await this.remote.updateAuthentication(r);c.isErrorResponse(t)&&this.handleError(t)}catch(e){if(e instanceof f)return await this.configure(this.configurationRequest),void await this.updateAuthentication();throw e}}async disconnect(){const e=await this.ensureConnection(),r={uuid:o.randomUUID()};await e.logout(r),this.configurationRequest=void 0}async onMessage(e){n.debugLog("[HANDSHAKE DEBUG] IframeManager.onMessage called with:",e),this.messenger instanceof a.ReactNativeMessenger?(this.isInitialized||this.connection?n.debugLog(`[HANDSHAKE DEBUG] Connection already initialized (isInitialized: ${this.isInitialized}, hasConnection: ${!!this.connection})`):(n.debugLog("[HANDSHAKE DEBUG] First message received, initializing connection..."),this.initialize().catch(e=>{n.debugLog("[HANDSHAKE DEBUG] Failed to initialize connection:",e)})),n.debugLog("[HANDSHAKE DEBUG] Passing message to ReactNativeMessenger"),this.messenger.handleMessage(e)):n.debugLog("[HANDSHAKE DEBUG] Not a ReactNativeMessenger, ignoring message")}isLoaded(){return this.isInitialized&&void 0!==this.remote}destroy(){this.connection&&(this.connection.destroy(),this.connection=void 0),this.remote=void 0,this.isInitialized=!1,this.configurationRequest=void 0,this.messenger.destroy()}},exports.MissingProjectEntropyError=h,exports.MissingRecoveryPasswordError=d,exports.NotConfiguredError=f,exports.WrongRecoveryPasswordError=g;
|
|
1
|
+
"use strict";var e=require("../core/configuration/account.js"),i=require("./messaging/browserMessenger/connect.js");require("./messaging/browserMessenger/backwardCompatibility.js");var r=require("../storage/istorage.js"),t=require("../core/errors/openfortError.js"),n=require("../utils/debug.js"),o=require("../utils/crypto.js"),s=require("../core/configuration/authentication.js"),a=require("./messaging/ReactNativeMessenger.js"),c=require("./types.js"),d=require("../core/errors/sentry.js");class h extends Error{constructor(){super("This embedded signer requires a password to be recovered")}}class u extends Error{constructor(){super("MissingProjectEntropyError")}}class g extends Error{constructor(){super("Wrong recovery password for this embedded signer")}}class l extends Error{constructor(){super("Not configured")}}exports.IframeManager=class{messenger;connection;remote;storage;sdkConfiguration;isInitialized=!1;initializationPromise=null;constructor(e,i,r){if(!e)throw new t.OpenfortError("Configuration is required for IframeManager",t.OpenfortErrorType.INVALID_CONFIGURATION);if(!i)throw new t.OpenfortError("Storage is required for IframeManager",t.OpenfortErrorType.INVALID_CONFIGURATION);if(!r)throw new t.OpenfortError("Messenger is required for IframeManager",t.OpenfortErrorType.INVALID_CONFIGURATION);this.sdkConfiguration=e,this.storage=i,this.messenger=r}async initialize(){if(!this.isInitialized)if(this.initializationPromise)await this.initializationPromise;else{this.initializationPromise=this.doInitialize();try{await this.initializationPromise,this.isInitialized=!0}catch(e){throw this.initializationPromise=null,e}}}async doInitialize(){n.debugLog("Initializing IframeManager connection..."),this.messenger.initialize({validateReceivedMessage:e=>!(!e||"object"!=typeof e),log:n.debugLog}),this.connection=i({messenger:this.messenger,timeout:1e4,log:n.debugLog});try{this.remote=await this.connection.promise,n.debugLog("IframeManager connection established")}catch(e){const i=e;throw d.sentry.captureException(i),this.destroy(),n.debugLog("Failed to establish connection:",i),new t.OpenfortError(`Failed to establish iFrame connection: ${i.cause||i.message}`,t.OpenfortErrorType.INTERNAL_ERROR,e)}}async ensureConnection(){if(this.isInitialized&&this.remote||await this.initialize(),!this.remote)throw new t.OpenfortError("Failed to establish connection",t.OpenfortErrorType.INTERNAL_ERROR);return this.remote}handleError(e){if(c.isErrorResponse(e)){if(e.error===c.NOT_CONFIGURED_ERROR)throw new l;if(e.error===c.MISSING_USER_ENTROPY_ERROR)throw this.storage.remove(r.StorageKeys.ACCOUNT),new h;if(e.error===c.MISSING_PROJECT_ENTROPY_ERROR)throw this.storage.remove(r.StorageKeys.ACCOUNT),new u;if(e.error===c.INCORRECT_USER_ENTROPY_ERROR)throw new g;throw new t.OpenfortError(`Unknown error: ${e.error}`,t.OpenfortErrorType.INTERNAL_ERROR)}throw e}async buildRequestConfiguration(){const e=await s.Authentication.fromStorage(this.storage);if(!e)throw new t.OpenfortError("Must be authenticated to create a signer",t.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return{thirdPartyProvider:e.thirdPartyProvider,thirdPartyTokenType:e.thirdPartyTokenType,token:e.token,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl}}async buildIFrameRequestConfiguration(){const e=await s.Authentication.fromStorage(this.storage);if(!e)throw new t.OpenfortError("Must be authenticated to create a signer",t.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const i={auth:c.ShieldAuthType.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyTokenType:e.thirdPartyTokenType??null,thirdPartyProvider:e.thirdPartyProvider??null,accessToken:e.token,playerID:e.player,recovery:i,chainId:null,password:null}}async configure(i){if(!this.sdkConfiguration.shieldConfiguration)throw new t.OpenfortError("shieldConfiguration is required",t.OpenfortErrorType.INVALID_CONFIGURATION);const r=await e.Account.fromStorage(this.storage),n=await this.ensureConnection(),s=await this.buildIFrameRequestConfiguration();s.chainId=i?.chainId??r?.chainId??null,s.password=i?.entropy?.recoveryPassword??null,s.recovery={...s.recovery,encryptionSession:i?.entropy?.encryptionSession};const a={uuid:o.randomUUID(),action:c.Event.CONFIGURE,chainId:s.chainId,recovery:s.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:s.accessToken,playerID:s.playerID,thirdPartyProvider:s.thirdPartyProvider,thirdPartyTokenType:s.thirdPartyTokenType,encryptionKey:s.password,encryptionPart:this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionKey??null,encryptionSession:s.recovery?.encryptionSession??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl},d=await n.configure(a);return c.isErrorResponse(d)&&this.handleError(d),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",d.version??"undefined"),d}async create(e){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const i=await this.ensureConnection(),r=await this.buildIFrameRequestConfiguration(),t={uuid:o.randomUUID(),action:c.Event.CREATE,recovery:r.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:r.accessToken,playerID:r.playerID,thirdPartyProvider:r.thirdPartyProvider,thirdPartyTokenType:r.thirdPartyTokenType,encryptionKey:r.password,encryptionPart:this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionKey??null,encryptionSession:r.recovery?.encryptionSession??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,chainId:e.chainId,accountType:e.accountType,chainType:e.chainType},n=await i.create(t);return c.isErrorResponse(n)&&this.handleError(n),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",n.version??"undefined"),n}async recover(i){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const r=await e.Account.fromStorage(this.storage),t=await this.ensureConnection(),n=await this.buildIFrameRequestConfiguration();n.chainId=r?.chainId??null,n.password=i?.entropy?.recoveryPassword??null,n.recovery={...n.recovery,encryptionSession:i?.entropy?.encryptionSession};const s={uuid:o.randomUUID(),action:c.Event.RECOVER,recovery:n.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:n.accessToken,playerID:n.playerID,thirdPartyProvider:n.thirdPartyProvider,thirdPartyTokenType:n.thirdPartyTokenType,encryptionKey:n.password,encryptionPart:this.sdkConfiguration?.shieldConfiguration?.shieldEncryptionKey??null,encryptionSession:n.recovery?.encryptionSession??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,account:i.account},a=await t.recover(s);return c.isErrorResponse(a)&&this.handleError(a),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",a.version??"undefined"),a}async sign(e,i,r){n.debugLog("[iframe] ensureConnection");const t=await this.ensureConnection(),s=new c.SignRequest(o.randomUUID(),e,i,r,await this.buildRequestConfiguration());n.debugLog("[iframe] done ensureConnection");try{const e=await t.sign(s);return n.debugLog("[iframe] response",e),c.isErrorResponse(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e.signature}catch(t){if(t instanceof l)return await this.configure(),this.sign(e,i,r);throw t}}async switchChain(e){const i=await this.ensureConnection(),r=new c.SwitchChainRequest(o.randomUUID(),e,await this.buildRequestConfiguration());try{const e=await i.switchChain(r);return c.isErrorResponse(e)&&this.handleError(e),e}catch(i){if(i instanceof l)return await this.configure(),this.switchChain(e);throw i}}async export(){const e=await this.ensureConnection(),i=new c.ExportPrivateKeyRequest(o.randomUUID(),await this.buildRequestConfiguration());try{const r=await e.export(i);return c.isErrorResponse(r)&&this.handleError(r),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",r.version??"undefined"),r.key}catch(e){if(e instanceof l)return await this.configure(),this.export();throw e}}async setEmbeddedRecovery(e,i,r){const t=await this.ensureConnection(),n=new c.SetRecoveryMethodRequest(o.randomUUID(),e,i,r,await this.buildRequestConfiguration());try{const e=await t.setRecoveryMethod(n);c.isErrorResponse(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined")}catch(t){if(t instanceof l)return await this.configure(),this.setEmbeddedRecovery(e,i,r);throw t}}async getCurrentDevice(e){const i=await this.ensureConnection(),r=new c.GetCurrentDeviceRequest(o.randomUUID(),e);try{const e=await i.getCurrentDevice(r);return c.isErrorResponse(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e}catch(e){if(e instanceof l)return null;throw e}}async updateAuthentication(){if(!this.isLoaded()||!this.remote)return void n.debugLog("IframeManager not loaded, skipping authentication update");const e=await s.Authentication.fromStorage(this.storage);if(!e)return void n.debugLog("No authentication found, skipping update");const i=new c.UpdateAuthenticationRequest(o.randomUUID(),e.token);try{n.debugLog("Updating authentication in iframe with token:",e.token);const r=await this.remote.updateAuthentication(i);c.isErrorResponse(r)&&this.handleError(r)}catch(e){if(e instanceof l)return await this.configure(),void await this.updateAuthentication();throw e}}async disconnect(){const e=await this.ensureConnection(),i={uuid:o.randomUUID()};await e.logout(i)}async onMessage(e){n.debugLog("[HANDSHAKE DEBUG] IframeManager.onMessage called with:",e),this.messenger instanceof a.ReactNativeMessenger?(this.isInitialized||this.connection?n.debugLog(`[HANDSHAKE DEBUG] Connection already initialized (isInitialized: ${this.isInitialized}, hasConnection: ${!!this.connection})`):(n.debugLog("[HANDSHAKE DEBUG] First message received, initializing connection..."),this.initialize().catch(e=>{n.debugLog("[HANDSHAKE DEBUG] Failed to initialize connection:",e)})),n.debugLog("[HANDSHAKE DEBUG] Passing message to ReactNativeMessenger"),this.messenger.handleMessage(e)):n.debugLog("[HANDSHAKE DEBUG] Not a ReactNativeMessenger, ignoring message")}isLoaded(){return this.isInitialized&&void 0!==this.remote}destroy(){this.connection&&this.connection.destroy(),this.messenger.destroy(),this.remote=void 0,this.isInitialized=!1,this.connection=void 0,this.initializationPromise=null}},exports.MissingProjectEntropyError=u,exports.MissingRecoveryPasswordError=h,exports.NotConfiguredError=l,exports.WrongRecoveryPasswordError=g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e;exports.Event=void 0,(e=exports.Event||(exports.Event={})).LOADED="loaded",e.CONFIGURE="configure",e.CONFIGURED="configured",e.UPDATE_AUTHENTICATION="update-authentication",e.AUTHENTICATION_UPDATED="authentication-updated",e.SIGN="sign",e.SET_RECOVERY_METHOD="set-recovery-method",e.SWITCH_CHAIN="switch-chain",e.CHAIN_SWITCHED="chain-switched",e.EXPORT="export",e.SIGNED="signed",e.LOGOUT="logout",e.LOGGED_OUT="logged-out",e.GET_CURRENT_DEVICE="get-current-device",e.CURRENT_DEVICE="current-device",e.PING="ping",e.PONG="pong";exports.ShieldAuthType=void 0,(exports.ShieldAuthType||(exports.ShieldAuthType={})).OPENFORT="openfort",exports.ExportPrivateKeyRequest=class{uuid;action=exports.Event.EXPORT;requestConfiguration;constructor(e,t){this.uuid=e,this.requestConfiguration=t}},exports.GetCurrentDeviceRequest=class{uuid;action=exports.Event.GET_CURRENT_DEVICE;playerID;constructor(e,t){this.uuid=e,this.playerID=t}},exports.INCORRECT_USER_ENTROPY_ERROR="incorrect-user-entropy-error",exports.MISSING_PROJECT_ENTROPY_ERROR="missing-project-entropy-error",exports.MISSING_USER_ENTROPY_ERROR="missing-user-entropy-error",exports.NOT_CONFIGURED_ERROR="not-configured-error",exports.SetRecoveryMethodRequest=class{uuid;action=exports.Event.SET_RECOVERY_METHOD;recoveryMethod;recoveryPassword;encryptionSession;requestConfiguration;constructor(e,t,r,o,s){this.uuid=e,this.recoveryMethod=t,this.recoveryPassword=r,this.encryptionSession=o,this.requestConfiguration=s}},exports.SignRequest=class{uuid;action=exports.Event.SIGN;message;requireArrayify;requireHash;requestConfiguration;constructor(e,t,r,o,s){this.uuid=e,this.message=t,this.requireArrayify=r,this.requireHash=o,this.requestConfiguration=s}},exports.SwitchChainRequest=class{uuid;action=exports.Event.SWITCH_CHAIN;chainId;requestConfiguration;constructor(e,t,r){this.uuid=e,this.chainId=t,this.requestConfiguration=r}},exports.UpdateAuthenticationRequest=class{uuid;action=exports.Event.UPDATE_AUTHENTICATION;accessToken;recovery;constructor(e,t,r){this.uuid=e,this.accessToken=t,this.recovery=r}},exports.isErrorResponse=function(e){return"error"in e};
|
|
1
|
+
"use strict";var e;exports.Event=void 0,(e=exports.Event||(exports.Event={})).LOADED="loaded",e.CONFIGURE="configure",e.CONFIGURED="configured",e.RECOVER="recover",e.RECOVERED="recovered",e.CREATE="create",e.CREATED="created",e.UPDATE_AUTHENTICATION="update-authentication",e.AUTHENTICATION_UPDATED="authentication-updated",e.SIGN="sign",e.SET_RECOVERY_METHOD="set-recovery-method",e.SWITCH_CHAIN="switch-chain",e.CHAIN_SWITCHED="chain-switched",e.EXPORT="export",e.SIGNED="signed",e.LOGOUT="logout",e.LOGGED_OUT="logged-out",e.GET_CURRENT_DEVICE="get-current-device",e.CURRENT_DEVICE="current-device",e.PING="ping",e.PONG="pong";exports.ShieldAuthType=void 0,(exports.ShieldAuthType||(exports.ShieldAuthType={})).OPENFORT="openfort",exports.ExportPrivateKeyRequest=class{uuid;action=exports.Event.EXPORT;requestConfiguration;constructor(e,t){this.uuid=e,this.requestConfiguration=t}},exports.GetCurrentDeviceRequest=class{uuid;action=exports.Event.GET_CURRENT_DEVICE;playerID;constructor(e,t){this.uuid=e,this.playerID=t}},exports.INCORRECT_USER_ENTROPY_ERROR="incorrect-user-entropy-error",exports.MISSING_PROJECT_ENTROPY_ERROR="missing-project-entropy-error",exports.MISSING_USER_ENTROPY_ERROR="missing-user-entropy-error",exports.NOT_CONFIGURED_ERROR="not-configured-error",exports.SetRecoveryMethodRequest=class{uuid;action=exports.Event.SET_RECOVERY_METHOD;recoveryMethod;recoveryPassword;encryptionSession;requestConfiguration;constructor(e,t,r,o,s){this.uuid=e,this.recoveryMethod=t,this.recoveryPassword=r,this.encryptionSession=o,this.requestConfiguration=s}},exports.SignRequest=class{uuid;action=exports.Event.SIGN;message;requireArrayify;requireHash;requestConfiguration;constructor(e,t,r,o,s){this.uuid=e,this.message=t,this.requireArrayify=r,this.requireHash=o,this.requestConfiguration=s}},exports.SwitchChainRequest=class{uuid;action=exports.Event.SWITCH_CHAIN;chainId;requestConfiguration;constructor(e,t,r){this.uuid=e,this.chainId=t,this.requestConfiguration=r}},exports.UpdateAuthenticationRequest=class{uuid;action=exports.Event.UPDATE_AUTHENTICATION;accessToken;recovery;constructor(e,t,r){this.uuid=e,this.accessToken=t,this.recovery=r}},exports.isErrorResponse=function(e){return"error"in e};
|