@openfort/openfort-js 0.9.10 → 0.9.11
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.
|
@@ -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.11";
|
|
@@ -1 +1 @@
|
|
|
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");var
|
|
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");var n=require("../storage/istorage.js"),o=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(n){const i=await this.iframeManager.configure(n),s=await t.Authentication.fromStorage(this.storage);if(!s)throw new e.OpenfortError("No access token found",e.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const d=o.SDKConfiguration.fromStorage();if(!d)throw new e.OpenfortError("Configuration not found",e.OpenfortErrorType.INVALID_CONFIGURATION);return i?.account||e.withOpenfortError(async()=>{const t=await this.backendApiClients.accountsApi.getAccountsV2({chainId:i.chainId,address:i.address},{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.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].chainType,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:i.account},{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}}),e=new r.Account({user:t.data.user,chainType:t.data.chainType,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(n){const i=await this.iframeManager.create(n),s=await t.Authentication.fromStorage(this.storage);if(!s)throw new e.OpenfortError("No access token found",e.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const d=o.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:i.account},{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}}),e=new r.Account({user:t.data.user,chainType:t.data.chainType,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(n){const i=await this.iframeManager.recover(n),s=await t.Authentication.fromStorage(this.storage);if(!s)throw new e.OpenfortError("No access token found",e.OpenfortErrorType.NOT_LOGGED_IN_ERROR);const d=o.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:i.account},{headers:{authorization:`Bearer ${d.baseConfiguration.publishableKey}`,"x-player-token":s.token,"x-auth-provider":s.thirdPartyProvider,"x-token-type":s.thirdPartyTokenType}}),e=new r.Account({user:t.data.user,chainType:t.data.chainType,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(){await this.iframeManager.disconnect(),this.storage.remove(n.StorageKeys.ACCOUNT)}};
|
package/dist/sdk/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="0.9.
|
|
1
|
+
const o="0.9.11",t="@openfort/openfort-js";export{t as PACKAGE,o as VERSION};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Authentication as a}from"../core/configuration/authentication.js";import{OpenfortError as t,OpenfortErrorType as e,withOpenfortError as r}from"../core/errors/openfortError.js";import{OpenfortEvents as o}from"../types/types.js";import"./types.js";import{Account as s}from"../core/configuration/account.js";import"./messaging/browserMessenger/backwardCompatibility.js";import{StorageKeys as n}from"../storage/istorage.js";import{SDKConfiguration as i}from"../core/config/config.js";import"../core/errors/sentry.js";import"jose";import"./evm/types.js";import"./evm/JsonRpcError.js";import"eventemitter3";import"./evm/provider/eip6963.js";class d{iframeManager;storage;backendApiClients;eventEmitter;constructor(a,t,e,r){this.iframeManager=a,this.storage=t,this.backendApiClients=e,this.eventEmitter=r}async configure(n){const d=await this.iframeManager.configure(n),c=await a.fromStorage(this.storage);if(!c)throw new t("No access token found",e.NOT_LOGGED_IN_ERROR);const
|
|
1
|
+
import{Authentication as a}from"../core/configuration/authentication.js";import{OpenfortError as t,OpenfortErrorType as e,withOpenfortError as r}from"../core/errors/openfortError.js";import{OpenfortEvents as o}from"../types/types.js";import"./types.js";import{Account as s}from"../core/configuration/account.js";import"./messaging/browserMessenger/backwardCompatibility.js";import{StorageKeys as n}from"../storage/istorage.js";import{SDKConfiguration as i}from"../core/config/config.js";import"../core/errors/sentry.js";import"jose";import"./evm/types.js";import"./evm/JsonRpcError.js";import"eventemitter3";import"./evm/provider/eip6963.js";class d{iframeManager;storage;backendApiClients;eventEmitter;constructor(a,t,e,r){this.iframeManager=a,this.storage=t,this.backendApiClients=e,this.eventEmitter=r}async configure(n){const d=await this.iframeManager.configure(n),c=await a.fromStorage(this.storage);if(!c)throw new t("No access token found",e.NOT_LOGGED_IN_ERROR);const p=i.fromStorage();if(!p)throw new t("Configuration not found",e.INVALID_CONFIGURATION);return d?.account||r(async()=>{const a=await this.backendApiClients.accountsApi.getAccountsV2({chainId:d.chainId,address:d.address},{headers:{authorization:`Bearer ${p.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}});if(0===a.data.data.length)throw new t("No account found",e.MISSING_SIGNER_ERROR);const r=new s({user:a.data.data[0].user,chainType:a.data.data[0].chainType,id:a.data.data[0].id,address:a.data.data[0].address,ownerAddress:a.data.data[0].ownerAddress,accountType:a.data.data[0].accountType,createdAt:a.data.data[0].createdAt,implementationType:a.data.data[0].smartAccount?.implementationType,chainId:a.data.data[0].chainId,factoryAddress:a.data.data[0].smartAccount?.factoryAddress,salt:a.data.data[0].smartAccount?.salt});return r.save(this.storage),this.eventEmitter.emit(o.SWITCH_ACCOUNT,a.data.data[0].address),r},{default:e.AUTHENTICATION_ERROR}),r(async()=>{const a=await this.backendApiClients.accountsApi.getAccountV2({id:d.account},{headers:{authorization:`Bearer ${p.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}}),t=new s({user:a.data.user,chainType:a.data.chainType,id:a.data.id,address:a.data.address,ownerAddress:a.data.ownerAddress,accountType:a.data.accountType,createdAt:a.data.createdAt,implementationType:a.data.smartAccount?.implementationType,chainId:a.data.chainId,salt:a.data.smartAccount?.salt,factoryAddress:a.data.smartAccount?.factoryAddress});return t.save(this.storage),this.eventEmitter.emit(o.SWITCH_ACCOUNT,a.data.address),t},{default:e.AUTHENTICATION_ERROR})}async sign(a,t,e){return await this.iframeManager.sign(a,t,e)}async export(){return await this.iframeManager.export()}async switchChain({chainId:a}){const t=await this.iframeManager.switchChain(a),e=await s.fromStorage(this.storage);new s({...e,id:t.account,chainId:a}).save(this.storage)}async create(n){const d=await this.iframeManager.create(n),c=await a.fromStorage(this.storage);if(!c)throw new t("No access token found",e.NOT_LOGGED_IN_ERROR);const p=i.fromStorage();if(!p)throw new t("Configuration not found",e.INVALID_CONFIGURATION);return r(async()=>{const a=await this.backendApiClients.accountsApi.getAccountV2({id:d.account},{headers:{authorization:`Bearer ${p.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}}),t=new s({user:a.data.user,chainType:a.data.chainType,id:a.data.id,address:a.data.address,ownerAddress:a.data.ownerAddress,accountType:a.data.accountType,createdAt:a.data.createdAt,implementationType:a.data.smartAccount?.implementationType,chainId:a.data.chainId,salt:a.data.smartAccount?.salt,factoryAddress:a.data.smartAccount?.factoryAddress});return t.save(this.storage),this.eventEmitter.emit(o.SWITCH_ACCOUNT,a.data.address),t},{default:e.AUTHENTICATION_ERROR})}async recover(n){const d=await this.iframeManager.recover(n),c=await a.fromStorage(this.storage);if(!c)throw new t("No access token found",e.NOT_LOGGED_IN_ERROR);const p=i.fromStorage();if(!p)throw new t("Configuration not found",e.INVALID_CONFIGURATION);return r(async()=>{const a=await this.backendApiClients.accountsApi.getAccountV2({id:d.account},{headers:{authorization:`Bearer ${p.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}}),t=new s({user:a.data.user,chainType:a.data.chainType,id:a.data.id,address:a.data.address,ownerAddress:a.data.ownerAddress,accountType:a.data.accountType,createdAt:a.data.createdAt,implementationType:a.data.smartAccount?.implementationType,chainId:a.data.chainId,salt:a.data.smartAccount?.salt,factoryAddress:a.data.smartAccount?.factoryAddress});return t.save(this.storage),this.eventEmitter.emit(o.SWITCH_ACCOUNT,a.data.address),t},{default:e.AUTHENTICATION_ERROR})}async setEmbeddedRecovery({recoveryMethod:a,recoveryPassword:t,encryptionSession:e}){await this.iframeManager.setEmbeddedRecovery(a,t,e)}async disconnect(){await this.iframeManager.disconnect(),this.storage.remove(n.ACCOUNT)}}export{d as EmbeddedSigner};
|
package/package.json
CHANGED