@openfort/openfort-js 1.3.3 → 1.3.5

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
- import{humanId as e}from"human-id";import{PasskeyPRFNotSupportedError as t,PasskeySeedInvalidError as r,PasskeyUserCancelledError as i,PasskeyCreationFailedError as s,PasskeyAssertionFailedError as n}from"./errors.js";import{DEFAULT_PASSKEY_DISPLAY_NAME as a}from"./types.js";import{arrayBufferToBase64URL as o,base64ToArrayBuffer as d}from"./utils.js";class l{validByteLengths=[16,24,32];rpId;rpName;displayName;timeoutMs;derivedKeyLengthBytes;constructor({rpId:e,rpName:t,displayName:r,timeoutMs:i,derivedKeyLengthBytes:s}={}){if(this.rpId=e,this.rpName=t,this.displayName=r??a,this.timeoutMs=i??6e4,this.derivedKeyLengthBytes=s??32,!this.validByteLengths.includes(this.derivedKeyLengthBytes))throw new Error(`Invalid key byte length ${this.derivedKeyLengthBytes}`)}static randomPasskeyName(){return e({capitalize:!0,separator:" "})}getChallengeBytes(){return crypto.getRandomValues(new Uint8Array(32))}async deriveKeyFromAssertion(e){const r=e.getClientExtensionResults();if(!r)throw new t("Passkey fetch failed: no client extension results");const i=r.prf;if(!i||!i.results)throw new t("PRF extension not supported or missing results");const s=i.results.first,n=await crypto.subtle.importKey("raw",s,{name:"AES-CBC",length:this.derivedKeyLengthBytes},!0,["encrypt","decrypt"]);return crypto.subtle.exportKey("raw",n)}async createPasskey({id:e,seed:n}){if(!n||0===n.trim().length)throw new r;const a={challenge:this.getChallengeBytes(),rp:{id:this.rpId,name:this.rpName},user:{id:(new TextEncoder).encode(e),name:e,displayName:this.displayName},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{residentKey:"required",userVerification:"required"},extensions:{prf:{eval:{first:(new TextEncoder).encode(n)}}},timeout:this.timeoutMs,attestation:"direct"};let d,l;try{d=await navigator.credentials.create({publicKey:a})}catch(e){if(e instanceof Error&&"NotAllowedError"===e.name)throw new i;throw new s(e instanceof Error?e.message:"Unknown error",e instanceof Error?e:void 0)}if(!d)throw new i;try{l=await this.deriveKeyFromAssertion(d)}catch(e){throw e instanceof t&&console.warn(`[Openfort] Passkey created but PRF extension failed. A passkey credential may exist on the device that cannot be used for wallet recovery. Credential ID: ${o(d.rawId)}`),e}return{id:o(d.rawId),displayName:this.displayName,key:o(l)}}async deriveAndExportKey({id:e,seed:t}){if(!t||0===t.trim().length)throw new r;let s;try{s=await navigator.credentials.get({publicKey:{challenge:this.getChallengeBytes(),rpId:this.rpId,allowCredentials:[{id:d(e),type:"public-key"}],userVerification:"required",extensions:{prf:{eval:{first:(new TextEncoder).encode(t)}}}}})}catch(e){if(e instanceof Error&&"NotAllowedError"===e.name)throw new i;throw new n(e instanceof Error?e.message:"Unknown error",e instanceof Error?e:void 0)}if(!s)throw new i;const a=await this.deriveKeyFromAssertion(s);return o(a)}}export{l as PasskeyHandler};
1
+ import{humanId as e}from"human-id";import{PasskeyPRFNotSupportedError as t,PasskeySeedInvalidError as r,PasskeyUserCancelledError as i,PasskeyCreationFailedError as s,PasskeyAssertionFailedError as n}from"./errors.js";import{DEFAULT_PASSKEY_DISPLAY_NAME as a}from"./types.js";import{arrayBufferToBase64URL as o,base64ToArrayBuffer as d}from"./utils.js";class l{validByteLengths=[16,24,32];rpId;rpName;displayName;timeoutMs;derivedKeyLengthBytes;constructor({rpId:e,rpName:t,displayName:r,timeoutMs:i,derivedKeyLengthBytes:s}={}){if(this.rpId=e,this.rpName=t,this.displayName=r??a,this.timeoutMs=i??6e4,this.derivedKeyLengthBytes=s??32,!this.validByteLengths.includes(this.derivedKeyLengthBytes))throw new Error(`Invalid key byte length ${this.derivedKeyLengthBytes}`)}static randomPasskeyName(){return e({capitalize:!0,separator:" "})}getChallengeBytes(){return crypto.getRandomValues(new Uint8Array(32))}async deriveKeyFromAssertion(e){const r=e.getClientExtensionResults();if(!r)throw new t("Passkey fetch failed: no client extension results");const i=r.prf;if(!i?.results)throw new t("PRF extension not supported or missing results");const s=i.results.first,n=await crypto.subtle.importKey("raw",s,{name:"AES-CBC",length:this.derivedKeyLengthBytes},!0,["encrypt","decrypt"]);return crypto.subtle.exportKey("raw",n)}async createPasskey({id:e,seed:n}){if(!n||0===n.trim().length)throw new r;const a={challenge:this.getChallengeBytes(),rp:{id:this.rpId,name:this.rpName},user:{id:(new TextEncoder).encode(e),name:e,displayName:this.displayName},pubKeyCredParams:[{type:"public-key",alg:-7},{type:"public-key",alg:-257}],authenticatorSelection:{residentKey:"required",userVerification:"required"},extensions:{prf:{eval:{first:(new TextEncoder).encode(n)}}},timeout:this.timeoutMs,attestation:"direct"};let d,l;try{d=await navigator.credentials.create({publicKey:a})}catch(e){if(e instanceof Error&&"NotAllowedError"===e.name)throw new i;throw new s(e instanceof Error?e.message:"Unknown error",e instanceof Error?e:void 0)}if(!d)throw new i;try{l=await this.deriveKeyFromAssertion(d)}catch(e){throw e instanceof t&&console.warn(`[Openfort] Passkey created but PRF extension failed. A passkey credential may exist on the device that cannot be used for wallet recovery. Credential ID: ${o(d.rawId)}`),e}return{id:o(d.rawId),displayName:this.displayName,key:o(l)}}async deriveAndExportKey({id:e,seed:t}){if(!t||0===t.trim().length)throw new r;let s;try{s=await navigator.credentials.get({publicKey:{challenge:this.getChallengeBytes(),rpId:this.rpId,allowCredentials:[{id:d(e),type:"public-key"}],userVerification:"required",extensions:{prf:{eval:{first:(new TextEncoder).encode(t)}}}}})}catch(e){if(e instanceof Error&&"NotAllowedError"===e.name)throw new i;throw new n(e instanceof Error?e.message:"Unknown error",e instanceof Error?e:void 0)}if(!s)throw new i;const a=await this.deriveKeyFromAssertion(s);return o(a)}}export{l as PasskeyHandler};
@@ -1 +1 @@
1
- const o="1.3.3",t="@openfort/openfort-js";export{t as PACKAGE,o as VERSION};
1
+ const o="1.3.5",t="@openfort/openfort-js";export{t as PACKAGE,o as VERSION};
@@ -1 +1 @@
1
- import{Authentication as e}from"../core/configuration/authentication.js";import{OPENFORT_AUTH_ERROR_CODES as t}from"../core/errors/authErrorCodes.js";import{SessionError as a,ConfigurationError as r}from"../core/errors/openfortError.js";import{withApiError as o}from"../core/errors/withApiError.js";import{PasskeyHandler as s}from"../core/passkey/handler.js";import{SDKConfiguration as n}from"../core/config/config.js";import{Account as i}from"../core/configuration/account.js";import{StorageKeys as c}from"../storage/istorage.js";import{OpenfortEvents as d,AccountTypeEnum as y}from"../types/types.js";class p{iframeManager;storage;backendApiClients;passkeyHandler;eventEmitter;constructor(e,t,a,r,o){this.iframeManager=e,this.storage=t,this.backendApiClients=a,this.passkeyHandler=r,this.eventEmitter=o}async createPasskey(e){const t=await this.passkeyHandler.createPasskey({id:s.randomPasskeyName(),seed:e});return{id:t.id,key:t.key}}async configure(s){const c=await e.fromStorage(this.storage);if(!c)throw new a(t.NOT_LOGGED_IN,"No access token found");const y=n.getInstance();if(!y)throw new r("Configuration not found");const p=await i.fromStorage(this.storage);let h;if(p){const e={account:p.id,...s.entropy&&{entropy:{...s.entropy.recoveryPassword&&{recoveryPassword:s.entropy.recoveryPassword},...s.entropy.encryptionSession&&{encryptionSession:s.entropy.encryptionSession},..."passkey"===p.recoveryMethod&&{passkey:{id:p.recoveryMethodDetails?.passkeyId,env:p.recoveryMethodDetails?.passkeyEnv,key:await s.getPasskeyKeyFn(p.recoveryMethodDetails?.passkeyId??"")}}}}},t=await this.iframeManager.recover(e);h=t.account}else{const e=await this.backendApiClients.accountsV2Api.getAccountsV2({accountType:s.accountType,chainType:s.chainType},{headers:c.thirdPartyProvider?{authorization:`Bearer ${y.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}:{authorization:`Bearer ${c.token}`,"x-project-key":y.baseConfiguration.publishableKey}});if(0===e.data.data.length){const e=s.entropy?.passkey?await this.createPasskey(c.userId):void 0,t={accountType:s.accountType,chainType:s.chainType,chainId:s.chainId,...s.entropy&&{entropy:{...s.entropy.recoveryPassword&&{recoveryPassword:s.entropy.recoveryPassword},...s.entropy.encryptionSession&&{encryptionSession:s.entropy.encryptionSession},...s.entropy.passkey&&{passkey:e}}}},a=await this.iframeManager.create(t);h=a.account}else{const t=e.data.data,a=t.find(e=>e.chainId===s.chainId),r=a||t[0],o={account:r.id,...s.entropy&&{entropy:{...s.entropy.recoveryPassword&&{recoveryPassword:s.entropy.recoveryPassword},...s.entropy.encryptionSession&&{encryptionSession:s.entropy.encryptionSession},..."passkey"===r.recoveryMethod&&{passkey:{id:r.recoveryMethodDetails?.passkeyId,env:r.recoveryMethodDetails?.passkeyEnv,key:await s.getPasskeyKeyFn(r.recoveryMethodDetails?.passkeyId??"")}}}}},n=await this.iframeManager.recover(o);if(h=n.account,!a){const e=await this.iframeManager.switchChain(s.chainId);h=e.account}}}return o(async()=>{const e=await this.backendApiClients.accountsV2Api.getAccountV2({id:h},{headers:c.thirdPartyProvider?{authorization:`Bearer ${y.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}:{authorization:`Bearer ${c.token}`,"x-project-key":y.baseConfiguration.publishableKey}}),t=new i({chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationAddress:e.data.smartAccount?.implementationAddress,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:i.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(d.ON_SWITCH_ACCOUNT,e.data.address),t},{context:"configure"})}async sign(e,t,a,r){const o=await this.iframeManager.sign(e,t,a,r);return this.eventEmitter.emit(d.ON_SIGNED_MESSAGE,{message:e,signature:o}),o}async export(){return await this.iframeManager.export()}async switchChain({chainId:e}){const t=await i.fromStorage(this.storage);if(t?.accountType===y.EOA)new i({...t,chainId:e}).save(this.storage);else{const a=await this.iframeManager.switchChain(e);new i({...t,id:a.account,chainId:e}).save(this.storage)}}async create(s){const c=await this.iframeManager.create(s),y=await e.fromStorage(this.storage);if(!y)throw new a(t.NOT_LOGGED_IN,"No access token found");const p=n.getInstance();if(!p)throw new r("Configuration not found");return o(async()=>{const e=await this.backendApiClients.accountsV2Api.getAccountV2({id:c.account},{headers:y.thirdPartyProvider?{authorization:`Bearer ${p.baseConfiguration.publishableKey}`,"x-player-token":y.token,"x-auth-provider":y.thirdPartyProvider,"x-token-type":y.thirdPartyTokenType}:{authorization:`Bearer ${y.token}`,"x-project-key":p.baseConfiguration.publishableKey}}),t=new i({chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,implementationAddress:e.data.smartAccount?.implementationAddress,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:i.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(d.ON_SWITCH_ACCOUNT,e.data.address),t},{context:"create"})}async recover(s){const c=await this.iframeManager.recover(s),y=await e.fromStorage(this.storage);if(!y)throw new a(t.NOT_LOGGED_IN,"No access token found");const p=n.getInstance();if(!p)throw new r("Configuration not found");return o(async()=>{const e=await this.backendApiClients.accountsV2Api.getAccountV2({id:c.account},{headers:y.thirdPartyProvider?{authorization:`Bearer ${p.baseConfiguration.publishableKey}`,"x-player-token":y.token,"x-auth-provider":y.thirdPartyProvider,"x-token-type":y.thirdPartyTokenType}:{authorization:`Bearer ${y.token}`,"x-project-key":p.baseConfiguration.publishableKey}}),t=new i({chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationAddress:e.data.smartAccount?.implementationAddress,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:i.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(d.ON_SWITCH_ACCOUNT,e.data.address),t},{context:"recover"})}async setRecoveryMethod({recoveryMethod:e,recoveryPassword:t,encryptionSession:a,passkeyInfo:r}){await this.iframeManager.setRecoveryMethod(e,t,a,r?.passkeyKey,r?.passkeyId)}async disconnect(){await this.iframeManager.disconnect(),this.storage.remove(c.ACCOUNT)}}export{p as EmbeddedSigner};
1
+ import{Authentication as e}from"../core/configuration/authentication.js";import{OPENFORT_AUTH_ERROR_CODES as t}from"../core/errors/authErrorCodes.js";import{SessionError as a,ConfigurationError as r}from"../core/errors/openfortError.js";import{withApiError as o}from"../core/errors/withApiError.js";import{PasskeyHandler as s}from"../core/passkey/handler.js";import{SDKConfiguration as n}from"../core/config/config.js";import{Account as i}from"../core/configuration/account.js";import{StorageKeys as c}from"../storage/istorage.js";import{OpenfortEvents as d,AccountTypeEnum as y}from"../types/types.js";class p{iframeManager;storage;backendApiClients;passkeyHandler;eventEmitter;constructor(e,t,a,r,o){this.iframeManager=e,this.storage=t,this.backendApiClients=a,this.passkeyHandler=r,this.eventEmitter=o}async createPasskey(e){const t=await this.passkeyHandler.createPasskey({id:s.randomPasskeyName(),seed:e});return{id:t.id,key:t.key}}async configure(s){const c=await e.fromStorage(this.storage);if(!c)throw new a(t.NOT_LOGGED_IN,"No access token found");const y=n.getInstance();if(!y)throw new r("Configuration not found");const p=await i.fromStorage(this.storage);let h;if(p){const e={account:p.id,...s.entropy&&{entropy:{...s.entropy.recoveryPassword&&{recoveryPassword:s.entropy.recoveryPassword},...s.entropy.encryptionSession&&{encryptionSession:s.entropy.encryptionSession},..."passkey"===p.recoveryMethod&&{passkey:{id:p.recoveryMethodDetails?.passkeyId,env:p.recoveryMethodDetails?.passkeyEnv,key:await s.getPasskeyKeyFn(p.recoveryMethodDetails?.passkeyId??"")}}}}},t=await this.iframeManager.recover(e);h=t.account}else{const e=await this.backendApiClients.accountsV2Api.getAccountsV2({accountType:s.accountType,chainType:s.chainType},{headers:c.thirdPartyProvider?{authorization:`Bearer ${y.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}:{authorization:`Bearer ${c.token}`,"x-project-key":y.baseConfiguration.publishableKey}});if(0===e.data.data.length){const e=s.entropy?.passkey?await this.createPasskey(c.userId):void 0,t={accountType:s.accountType,chainType:s.chainType,chainId:s.chainId,...s.entropy&&{entropy:{...s.entropy.recoveryPassword&&{recoveryPassword:s.entropy.recoveryPassword},...s.entropy.encryptionSession&&{encryptionSession:s.entropy.encryptionSession},...s.entropy.passkey&&{passkey:e}}}},a=await this.iframeManager.create(t);h=a.account}else{const t=e.data.data,a=t.find(e=>e.chainId===s.chainId),r=a||t[0],o={account:r.id,...s.entropy&&{entropy:{...s.entropy.recoveryPassword&&{recoveryPassword:s.entropy.recoveryPassword},...s.entropy.encryptionSession&&{encryptionSession:s.entropy.encryptionSession},..."passkey"===r.recoveryMethod&&{passkey:{id:r.recoveryMethodDetails?.passkeyId,env:r.recoveryMethodDetails?.passkeyEnv,key:await s.getPasskeyKeyFn(r.recoveryMethodDetails?.passkeyId??"")}}}}},n=await this.iframeManager.recover(o);if(h=n.account,!a){const e=await this.iframeManager.switchChain(s.chainId);h=e.account}}}return o(async()=>{const e=await this.backendApiClients.accountsV2Api.getAccountV2({id:h},{headers:c.thirdPartyProvider?{authorization:`Bearer ${y.baseConfiguration.publishableKey}`,"x-player-token":c.token,"x-auth-provider":c.thirdPartyProvider,"x-token-type":c.thirdPartyTokenType}:{authorization:`Bearer ${c.token}`,"x-project-key":y.baseConfiguration.publishableKey}}),t=new i({chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationAddress:e.data.smartAccount?.implementationAddress,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:i.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(d.ON_SWITCH_ACCOUNT,e.data.address),t},{context:"configure"})}async sign(e,t,a,r){const o=await this.iframeManager.sign(e,t,a,r);return this.eventEmitter.emit(d.ON_SIGNED_MESSAGE,{message:e,signature:o}),o}async export(){return await this.iframeManager.export()}async switchChain({chainId:e}){const t=await i.fromStorage(this.storage);if(t?.accountType===y.EOA)new i({...t,chainId:e}).save(this.storage);else{const a=await this.iframeManager.switchChain(e);new i({...t,id:a.account,chainId:e}).save(this.storage)}}async create(s){const c=await this.iframeManager.create(s),y=await e.fromStorage(this.storage);if(!y)throw new a(t.NOT_LOGGED_IN,"No access token found");const p=n.getInstance();if(!p)throw new r("Configuration not found");return o(async()=>{const e=await this.backendApiClients.accountsV2Api.getAccountV2({id:c.account},{headers:y.thirdPartyProvider?{authorization:`Bearer ${p.baseConfiguration.publishableKey}`,"x-player-token":y.token,"x-auth-provider":y.thirdPartyProvider,"x-token-type":y.thirdPartyTokenType}:{authorization:`Bearer ${y.token}`,"x-project-key":p.baseConfiguration.publishableKey}}),t=new i({chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,implementationAddress:e.data.smartAccount?.implementationAddress,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:i.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(d.ON_SWITCH_ACCOUNT,e.data.address),t},{context:"create"})}async import(s){const c=await this.iframeManager.import(s),y=await e.fromStorage(this.storage);if(!y)throw new a(t.NOT_LOGGED_IN,"No access token found");const p=n.getInstance();if(!p)throw new r("Configuration not found");return o(async()=>{const e=await this.backendApiClients.accountsV2Api.getAccountV2({id:c.account},{headers:y.thirdPartyProvider?{authorization:`Bearer ${p.baseConfiguration.publishableKey}`,"x-player-token":y.token,"x-auth-provider":y.thirdPartyProvider,"x-token-type":y.thirdPartyTokenType}:{authorization:`Bearer ${y.token}`,"x-project-key":p.baseConfiguration.publishableKey}}),t=new i({chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,implementationAddress:e.data.smartAccount?.implementationAddress,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:i.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(d.ON_SWITCH_ACCOUNT,e.data.address),t},{context:"import"})}async recover(s){const c=await this.iframeManager.recover(s),y=await e.fromStorage(this.storage);if(!y)throw new a(t.NOT_LOGGED_IN,"No access token found");const p=n.getInstance();if(!p)throw new r("Configuration not found");return o(async()=>{const e=await this.backendApiClients.accountsV2Api.getAccountV2({id:c.account},{headers:y.thirdPartyProvider?{authorization:`Bearer ${p.baseConfiguration.publishableKey}`,"x-player-token":y.token,"x-auth-provider":y.thirdPartyProvider,"x-token-type":y.thirdPartyTokenType}:{authorization:`Bearer ${y.token}`,"x-project-key":p.baseConfiguration.publishableKey}}),t=new i({chainType:e.data.chainType,id:e.data.id,address:e.data.address,ownerAddress:e.data.ownerAddress,accountType:e.data.accountType,createdAt:e.data.createdAt,implementationAddress:e.data.smartAccount?.implementationAddress,implementationType:e.data.smartAccount?.implementationType,chainId:e.data.chainId,salt:e.data.smartAccount?.salt,factoryAddress:e.data.smartAccount?.factoryAddress,recoveryMethod:i.parseRecoveryMethod(e.data.recoveryMethod),recoveryMethodDetails:e.data.recoveryMethodDetails});return t.save(this.storage),this.eventEmitter.emit(d.ON_SWITCH_ACCOUNT,e.data.address),t},{context:"recover"})}async setRecoveryMethod({recoveryMethod:e,recoveryPassword:t,encryptionSession:a,passkeyInfo:r}){await this.iframeManager.setRecoveryMethod(e,t,a,r?.passkeyKey,r?.passkeyId)}async disconnect(){await this.iframeManager.disconnect(),this.storage.remove(c.ACCOUNT)}}export{p as EmbeddedSigner};
@@ -0,0 +1 @@
1
+ const t="0xef0100";function n(n,e){return!!e&&function(n){if(!n)return null;const e=n.toLowerCase();return 48!==e.length?null:e.startsWith(t)?`0x${e.slice(8)}`:null}(n)===e.toLowerCase()}export{n as isDelegatedTo};
@@ -1 +1 @@
1
- import{withApiError as t}from"../../core/errors/withApiError.js";import{AccountType as e}from"../../types/types.js";import{JsonRpcError as i,RpcErrorCode as n}from"./JsonRpcError.js";function a(t){return{data:(()=>{if("token-allowance"===t.type)throw new i(n.INVALID_PARAMS,"token-allowance policy is not supported with this account implementation.");if("gas-limit"===t.type)throw new i(n.INVALID_PARAMS,"gas-limit policy is not supported with this account implementation.");if("rate-limit"===t.type)throw new i(n.INVALID_PARAMS,"rate-limit policy is not supported with this account implementation.");return t.data})(),type:t.type.custom}}function s(t){if("native-token-transfer"===t.type)throw new i(n.INVALID_PARAMS,"native-token-transfer permission is not supported with this account implementation.");if("rate-limit"===t.type)throw new i(n.INVALID_PARAMS,"rate-limit permission is not supported with this account implementation.");if("gas-limit"===t.type)throw new i(n.INVALID_PARAMS,"gas-limit permission is not supported with this account implementation.");return{...t,policies:t?.policies?.map(a),required:t.required??!1,type:"string"==typeof t.type?t.type:t.type.custom}}function o(t){return{expiry:t.validUntil?Number(t.validUntil):0,grantedPermissions:t.whitelist?t.whitelist.map(e=>({type:"contract-call",data:{address:e,calls:[]},policies:[{data:{limit:t.limit},type:{custom:"usage-limit"}}]})):[],permissionsContext:t.id}}const r=async({params:a,signer:r,account:c,authentication:p,backendClient:l,feeSponsorshipId:d})=>{const m=await(async(e,a,o,r,c)=>{const p=e[0],l=Math.floor(Date.now()/1e3),d=Math.floor(new Date(Date.now()+1e3*p.expiry).getTime()/1e3),m=p.permissions.map(s),y=m.filter(t=>"contract-call"===t.type||"erc20-token-transfer"===t.type||"erc721-token-transfer"===t.type||"erc1155-token-transfer"===t.type).map(t=>t.data.address);let u,h=m.find(t=>"call-limit"===t.type)?.data;if(h=m[0]?.policies?.find(t=>"call-limit"===t.type)?.data?.limit,"signer"in p&&p.signer){if("keys"===p.signer.type)throw new i(n.INVALID_PARAMS,"Multi-key signers are not supported for session creation");"key"!==p.signer.type&&"account"!==p.signer.type||(u=p.signer.data.id)}else"account"in p&&p.account&&(u=p.account);if(!u)throw new i(n.INVALID_PARAMS,"Failed to request permissions - missing session address");const w=((t,e,i,n,a,s=!1,o,r,c)=>{const p={address:t,chainId:e,validAfter:i,validUntil:n,optimistic:s,whitelist:o,account:c};return a&&(p.policy=a),r&&(p.limit=r),p})(u,o.chainId,l,d,c,!1,y,h,o.id);return t(async()=>(await a.sessionsApi.createSession({createSessionRequest:w},{headers:r.thirdPartyProvider?{authorization:`Bearer ${a.config.backend.accessToken}`,"x-player-token":r.token,"x-auth-provider":r.thirdPartyProvider,"x-token-type":r.thirdPartyTokenType}:{authorization:`Bearer ${r.token}`,"x-project-key":String(a.config.backend.accessToken)}})).data,{context:"operation"})})(a,l,c,p,d).catch(t=>{throw new i(n.TRANSACTION_REJECTED,t.message)});if(m?.nextAction?.payload?.signableHash){let a;a=[300,324].includes(c.chainId)||c.implementationType&&[e.CALIBUR].includes(c.implementationType)?await r.sign(m.nextAction.payload.signableHash,!1,!1):await r.sign(m.nextAction.payload.signableHash);return o(await t(async()=>(await l.sessionsApi.signatureSession({id:m.id,signatureRequest:{signature:a}})).data,{context:"operation"}).catch(t=>{throw new i(n.TRANSACTION_REJECTED,t.message)}))}if(!1===m.isActive)throw new i(n.TRANSACTION_REJECTED,"Failed to grant permissions");return o(m)};export{r as registerSession};
1
+ import{withApiError as t}from"../../core/errors/withApiError.js";import{AccountTypeEnum as e}from"../../types/types.js";import{JsonRpcError as i,RpcErrorCode as n}from"./JsonRpcError.js";function a(t){return{data:(()=>{if("token-allowance"===t.type)throw new i(n.INVALID_PARAMS,"token-allowance policy is not supported with this account implementation.");if("gas-limit"===t.type)throw new i(n.INVALID_PARAMS,"gas-limit policy is not supported with this account implementation.");if("rate-limit"===t.type)throw new i(n.INVALID_PARAMS,"rate-limit policy is not supported with this account implementation.");return t.data})(),type:t.type.custom}}function s(t){if("native-token-transfer"===t.type)throw new i(n.INVALID_PARAMS,"native-token-transfer permission is not supported with this account implementation.");if("rate-limit"===t.type)throw new i(n.INVALID_PARAMS,"rate-limit permission is not supported with this account implementation.");if("gas-limit"===t.type)throw new i(n.INVALID_PARAMS,"gas-limit permission is not supported with this account implementation.");return{...t,policies:t?.policies?.map(a),required:t.required??!1,type:"string"==typeof t.type?t.type:t.type.custom}}function o(t){return{expiry:t.validUntil?Number(t.validUntil):0,grantedPermissions:t.whitelist?t.whitelist.map(e=>({type:"contract-call",data:{address:e,calls:[]},policies:[{data:{limit:t.limit},type:{custom:"usage-limit"}}]})):[],permissionsContext:t.id}}const r=async({params:a,signer:r,account:c,authentication:p,backendClient:l,feeSponsorshipId:d})=>{const m=await(async(e,a,o,r,c)=>{const p=e[0],l=Math.floor(Date.now()/1e3),d=Math.floor(new Date(Date.now()+1e3*p.expiry).getTime()/1e3),m=p.permissions.map(s),u=m.filter(t=>"contract-call"===t.type||"erc20-token-transfer"===t.type||"erc721-token-transfer"===t.type||"erc1155-token-transfer"===t.type).map(t=>t.data.address);let y,h=m.find(t=>"call-limit"===t.type)?.data;if(h=m[0]?.policies?.find(t=>"call-limit"===t.type)?.data?.limit,"signer"in p&&p.signer){if("keys"===p.signer.type)throw new i(n.INVALID_PARAMS,"Multi-key signers are not supported for session creation");"key"!==p.signer.type&&"account"!==p.signer.type||(y=p.signer.data.id)}else"account"in p&&p.account&&(y=p.account);if(!y)throw new i(n.INVALID_PARAMS,"Failed to request permissions - missing session address");const w=((t,e,i,n,a,s=!1,o,r,c)=>{const p={address:t,chainId:e,validAfter:i,validUntil:n,optimistic:s,whitelist:o,account:c};return a&&(p.policy=a),r&&(p.limit=r),p})(y,o.chainId,l,d,c,!1,u,h,o.id);return t(async()=>(await a.sessionsApi.createSession({createSessionRequest:w},{headers:r.thirdPartyProvider?{authorization:`Bearer ${a.config.backend.accessToken}`,"x-player-token":r.token,"x-auth-provider":r.thirdPartyProvider,"x-token-type":r.thirdPartyTokenType}:{authorization:`Bearer ${r.token}`,"x-project-key":String(a.config.backend.accessToken)}})).data,{context:"operation"})})(a,l,c,p,d).catch(t=>{throw new i(n.TRANSACTION_REJECTED,t.message)});if(m?.nextAction?.payload?.signableHash){let a;a=[300,324].includes(c.chainId)||c.accountType===e.DELEGATED_ACCOUNT?await r.sign(m.nextAction.payload.signableHash,!1,!1):await r.sign(m.nextAction.payload.signableHash);return o(await t(async()=>(await l.sessionsApi.signatureSession({id:m.id,signatureRequest:{signature:a}})).data,{context:"operation"}).catch(t=>{throw new i(n.TRANSACTION_REJECTED,t.message)}))}if(!1===m.isActive)throw new i(n.TRANSACTION_REJECTED,"Failed to grant permissions");return o(m)};export{r as registerSession};
@@ -1 +1 @@
1
- import{withApiError as e}from"../../core/errors/withApiError.js";import{AccountType as t}from"../../types/types.js";import{JsonRpcError as n,RpcErrorCode as a}from"./JsonRpcError.js";const i=async({params:i,signer:o,account:s,authentication:r,backendClient:c,feeSponsorshipId:p})=>{const d=i[0];if(!d.permissionContext)return await o.disconnect(),{};const h=await(async(t,n,a,i,o)=>{const s=((e,t,n,a)=>{const i={address:e,chainId:t,account:a};return n&&(i.policy=n),i})(t.permissionContext,a.chainId,o,a.id);return e(async()=>(await n.sessionsApi.revokeSession({revokeSessionRequest:s},{headers:i.thirdPartyProvider?{authorization:`Bearer ${n.config.backend.accessToken}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}:{authorization:`Bearer ${i.token}`,"x-project-key":String(n.config.backend.accessToken)}})).data,{context:"operation"})})(d,c,s,r,p).catch(e=>{throw new n(a.TRANSACTION_REJECTED,e.message)});if(h?.nextAction?.payload?.signableHash){let e;e=[300,324].includes(s.chainId)||s.implementationType&&[t.CALIBUR].includes(s.implementationType)?await o.sign(h.nextAction.payload.signableHash,!1,!1):await o.sign(h.nextAction.payload.signableHash);return(await c.sessionsApi.signatureSession({id:h.id,signatureRequest:{signature:e}}).catch(e=>{throw new n(a.TRANSACTION_REJECTED,e.message)})).data}return h};export{i as revokeSession};
1
+ import{withApiError as e}from"../../core/errors/withApiError.js";import{AccountTypeEnum as t}from"../../types/types.js";import{JsonRpcError as n,RpcErrorCode as a}from"./JsonRpcError.js";const o=async({params:o,signer:i,account:r,authentication:s,backendClient:c,feeSponsorshipId:d})=>{const p=o[0];if(!p.permissionContext)return await i.disconnect(),{};const h=await(async(t,n,a,o,i)=>{const r=((e,t,n,a)=>{const o={address:e,chainId:t,account:a};return n&&(o.policy=n),o})(t.permissionContext,a.chainId,i,a.id);return e(async()=>(await n.sessionsApi.revokeSession({revokeSessionRequest:r},{headers:o.thirdPartyProvider?{authorization:`Bearer ${n.config.backend.accessToken}`,"x-player-token":o.token,"x-auth-provider":o.thirdPartyProvider,"x-token-type":o.thirdPartyTokenType}:{authorization:`Bearer ${o.token}`,"x-project-key":String(n.config.backend.accessToken)}})).data,{context:"operation"})})(p,c,r,s,d).catch(e=>{throw new n(a.TRANSACTION_REJECTED,e.message)});if(h?.nextAction?.payload?.signableHash){let e;e=[300,324].includes(r.chainId)||r.accountType===t.DELEGATED_ACCOUNT?await i.sign(h.nextAction.payload.signableHash,!1,!1):await i.sign(h.nextAction.payload.signableHash);return(await c.sessionsApi.signatureSession({id:h.id,signatureRequest:{signature:e}}).catch(e=>{throw new n(a.TRANSACTION_REJECTED,e.message)})).data}return h};export{o as revokeSession};
@@ -1 +1 @@
1
- import{withApiError as e}from"../../core/errors/withApiError.js";import{AccountTypeEnum as t,AccountType as a}from"../../types/types.js";import{prepareAndSignAuthorization as n,serializeSignedAuthorization as o}from"../../utils/authorization.js";import{JsonRpcError as r,RpcErrorCode as s}from"./JsonRpcError.js";const i=e=>{const t=e?.logs?.[0];return{blockHash:t?.blockHash,blockNumber:e?.blockNumber?.toString(),contractAddress:void 0,cumulativeGasUsed:e?.gasUsed,effectiveGasPrice:e?.gasFee,from:void 0,gasUsed:e?.gasUsed,logs:e?.logs||[],logsBloom:void 0,status:1===e?.status?"success":0===e?.status?"reverted":void 0,to:e?.to,transactionHash:e?.transactionHash,transactionIndex:t?.transactionIndex,type:"eip1559",blobGasPrice:void 0,blobGasUsed:void 0,root:void 0}};async function c(e,t){try{const a=await e.getCode(t);return"0x"!==a&&a.length>2}catch{return!1}}const d=async({params:d,signer:p,account:l,authentication:u,backendClient:h,rpcProvider:g,feeSponsorshipId:T})=>{const A=d[0]?.capabilities?.paymasterService?.policy??T;let m;if(l.accountType===t.DELEGATED_ACCOUNT){const[e,t]=await Promise.all([c(g,l.address),g.getTransactionCount(l.address)]);if(!e){const e=await n({signer:p,accountAddress:l.address,contractAddress:l.implementationAddress,chainId:l.chainId,nonce:t});m=o(e)}}const w=await(async(t,a,n,o,i,c)=>{const d=t.map(e=>{if(!e.to)throw new r(s.INVALID_PARAMS,'wallet_sendCalls requires a "to" field');return{to:String(e.to),data:e.data?String(e.data):void 0,value:e.value?String(e.value):void 0}});return e(async()=>(await a.transactionIntentsApi.createTransactionIntent({createTransactionIntentRequest:{account:n.id,policy:i,signedAuthorization:c,chainId:n.chainId,interactions:d}},{headers:o.thirdPartyProvider?{authorization:`Bearer ${a.config.backend.accessToken}`,"x-player-token":o.token,"x-auth-provider":o.thirdPartyProvider,"x-token-type":o.thirdPartyTokenType}:{authorization:`Bearer ${o.token}`,"x-project-key":String(a.config.backend.accessToken)}})).data,{context:"operation"})})(d,h,l,u,A,m).catch(e=>{throw new r(s.TRANSACTION_REJECTED,e.message)});if(w.response?.error?.reason)throw new r(s.TRANSACTION_REJECTED,w.response.error.reason);if(w?.nextAction?.payload?.signableHash){let t;t=[300,324].includes(l.chainId)||l.implementationType&&[a.CALIBUR].includes(l.implementationType)?await p.sign(w.nextAction.payload.signableHash,!1,!1):await p.sign(w.nextAction.payload.signableHash);const n=await e(async()=>await h.transactionIntentsApi.signature({id:w.id,signatureRequest:{signature:t}}),{context:"operation"}).catch(e=>{throw new r(s.TRANSACTION_REJECTED,e.message)});if(0===n.data.response?.status)throw new r(s.TRANSACTION_REJECTED,n.data.response?.error?.reason??"");if(!n.data.response)throw new r(s.TRANSACTION_REJECTED,"No transaction response received");return{id:w.id,receipt:i(n.data.response)}}if(!w.response)throw new r(s.TRANSACTION_REJECTED,"No transaction response received");return{id:w.id,receipt:i(w.response)}};export{d as sendCallsSync};
1
+ import{withApiError as t}from"../../core/errors/withApiError.js";import{AccountTypeEnum as e}from"../../types/types.js";import{prepareAndSignAuthorization as a,serializeSignedAuthorization as n}from"../../utils/authorization.js";import{isDelegatedTo as o}from"./delegation.js";import{JsonRpcError as s,RpcErrorCode as r}from"./JsonRpcError.js";const i=t=>{const e=t?.logs?.[0];return{blockHash:e?.blockHash,blockNumber:t?.blockNumber?.toString(),contractAddress:void 0,cumulativeGasUsed:t?.gasUsed,effectiveGasPrice:t?.gasFee,from:void 0,gasUsed:t?.gasUsed,logs:t?.logs||[],logsBloom:void 0,status:1===t?.status?"success":0===t?.status?"reverted":void 0,to:t?.to,transactionHash:t?.transactionHash,transactionIndex:e?.transactionIndex,type:"eip1559",blobGasPrice:void 0,blobGasUsed:void 0,root:void 0}};async function c(t,e,a){try{const n=await t.getCode(e);return o(n,a)}catch{return!1}}const d=async({params:o,signer:d,account:p,authentication:l,backendClient:u,rpcProvider:h,feeSponsorshipId:g})=>{const A=o[0]?.capabilities?.paymasterService?.policy??g;let T;if(p.accountType===e.DELEGATED_ACCOUNT){const{implementationAddress:t,chainId:e}=p;if(!t)throw new s(r.INVALID_PARAMS,`Delegated account ${p.id} is missing an implementationAddress; cannot authorize its EIP-7702 delegation`);if(void 0===e)throw new s(r.INVALID_PARAMS,`Delegated account ${p.id} is missing a chainId; cannot authorize its EIP-7702 delegation`);const[o,i]=await Promise.all([c(h,p.address,t),h.getTransactionCount(p.address)]);if(!o){const o=await a({signer:d,accountAddress:p.address,contractAddress:t,chainId:e,nonce:i});T=n(o)}}const w=await(async(e,a,n,o,i,c)=>{const d=e.map(t=>{if(!t.to)throw new s(r.INVALID_PARAMS,'wallet_sendCalls requires a "to" field');return{to:String(t.to),data:t.data?String(t.data):void 0,value:t.value?String(t.value):void 0}});return t(async()=>(await a.transactionIntentsApi.createTransactionIntent({createTransactionIntentRequest:{account:n.id,policy:i,signedAuthorization:c,chainId:n.chainId,interactions:d}},{headers:o.thirdPartyProvider?{authorization:`Bearer ${a.config.backend.accessToken}`,"x-player-token":o.token,"x-auth-provider":o.thirdPartyProvider,"x-token-type":o.thirdPartyTokenType}:{authorization:`Bearer ${o.token}`,"x-project-key":String(a.config.backend.accessToken)}})).data,{context:"operation"})})(o,u,p,l,A,T).catch(t=>{throw new s(r.TRANSACTION_REJECTED,t.message)});if(w.response?.error?.reason)throw new s(r.TRANSACTION_REJECTED,w.response.error.reason);if(w?.nextAction?.payload?.signableHash){let a;a=[300,324].includes(p.chainId)||p.accountType===e.DELEGATED_ACCOUNT?await d.sign(w.nextAction.payload.signableHash,!1,!1):await d.sign(w.nextAction.payload.signableHash);const n=await t(async()=>await u.transactionIntentsApi.signature({id:w.id,signatureRequest:{signature:a}}),{context:"operation"}).catch(t=>{throw new s(r.TRANSACTION_REJECTED,t.message)});if(0===n.data.response?.status)throw new s(r.TRANSACTION_REJECTED,n.data.response?.error?.reason??"");if(!n.data.response)throw new s(r.TRANSACTION_REJECTED,"No transaction response received");return{id:w.id,receipt:i(n.data.response)}}if(!w.response)throw new s(r.TRANSACTION_REJECTED,"No transaction response received");return{id:w.id,receipt:i(w.response)}};export{d as sendCallsSync};
@@ -1 +1 @@
1
- import{Account as e}from"../core/configuration/account.js";import{Authentication as i}from"../core/configuration/authentication.js";import{OPENFORT_AUTH_ERROR_CODES as t}from"../core/errors/authErrorCodes.js";import{RecoveryError as n,SignerError as r,OpenfortError as o,ConfigurationError as s,SessionError as a}from"../core/errors/openfortError.js";import{sentry as d}from"../core/errors/sentry.js";import{StorageKeys as c}from"../storage/istorage.js";import{randomUUID as h}from"../utils/crypto.js";import{debugLog as u}from"../utils/debug.js";import{ReactNativeMessenger as l}from"./messaging/ReactNativeMessenger.js";import f from"./messaging/browserMessenger/connect.js";import"./messaging/browserMessenger/backwardCompatibility.js";import{isErrorResponse as y,NOT_CONFIGURED_ERROR as g,MISSING_USER_ENTROPY_ERROR as p,MISSING_PROJECT_ENTROPY_ERROR as m,INCORRECT_USER_ENTROPY_ERROR as w,MISSING_PASSKEY_ERROR as C,INCORRECT_PASSKEY_ERROR as v,OTP_REQUIRED_ERROR as k,ShieldAuthType as I,Event as P,SignRequest as R,SwitchChainRequest as b,ExportPrivateKeyRequest as E,SetRecoveryMethodRequest as T,GetCurrentDeviceRequest as S,UpdateAuthenticationRequest as N}from"./types.js";class A extends n{constructor(){super(t.MISSING_RECOVERY_PASSWORD,"This embedded signer requires a password to be recovered","password")}}class O extends n{constructor(){super(t.INCORRECT_PASSKEY,"Wrong recovery passkey for this embedded signer","passkey")}}class U extends n{constructor(){super(t.MISSING_PROJECT_ENTROPY,"Project entropy is missing","entropy")}}class z extends n{constructor(){super(t.WRONG_RECOVERY_PASSWORD,"Wrong recovery password for this embedded signer","password")}}class D extends r{constructor(){super(t.NOT_CONFIGURED,"Signer is not configured")}}class M extends o{constructor(){super(t.OTP_REQUIRED,"OTP verification required")}}class K{messenger;connection;remote;storage;sdkConfiguration;isInitialized=!1;initializationPromise=null;hasFailed=!1;constructor(e,i,t){if(!e)throw new s("Configuration is required for IframeManager");if(!i)throw new s("Storage is required for IframeManager");if(!t)throw new s("Messenger is required for IframeManager");this.sdkConfiguration=e,this.storage=i,this.messenger=t}async initialize(){if(!this.isInitialized){if(this.hasFailed)throw new o(t.INTERNAL_ERROR,"Failed to establish iFrame connection: Previous connection attempt failed");if(this.initializationPromise)await this.initializationPromise;else{this.initializationPromise=this.doInitialize();try{await this.initializationPromise,this.isInitialized=!0}catch(e){throw this.hasFailed=!0,this.initializationPromise=null,e}}}}async doInitialize(){u("Initializing IframeManager connection..."),this.messenger.initialize({validateReceivedMessage:e=>!(!e||"object"!=typeof e),log:u}),this.connection=f({messenger:this.messenger,timeout:1e4,log:u});try{this.remote=await this.connection.promise,u("IframeManager connection established")}catch(e){const i=e;throw d.captureException(i),this.destroy(),u("Failed to establish connection:",i),new o(t.INTERNAL_ERROR,`Failed to establish iFrame connection: ${i.cause||i.message}\n \n In apps built with:\n - react native\n - swift\n - unity (non-webgl) \n \n You must configure your origin in the openfort dashboard before using the embedded wallet.\n\n For more information, see: https://www.openfort.io/docs/configuration/native-apps\n `)}}async ensureConnection(){if(this.isInitialized&&this.remote||await this.initialize(),!this.remote)throw new o(t.INTERNAL_ERROR,"Failed to establish connection");return this.remote}handleError(e){if(y(e)){if(e.error===g)throw this.storage.remove(c.ACCOUNT),new D;if(e.error===p)throw this.storage.remove(c.ACCOUNT),new A;if(e.error===m)throw this.storage.remove(c.ACCOUNT),new U;if(e.error===w)throw new z;if(e.error===C)throw this.storage.remove(c.ACCOUNT),new A;if(e.error===v)throw new O;if(e.error===k)throw new M;throw this.storage.remove(c.ACCOUNT),new o(t.INTERNAL_ERROR,`Unknown error: ${e.error}`)}throw e}async buildRequestConfiguration(){const e=await i.fromStorage(this.storage);if(!e)throw new a(t.NOT_LOGGED_IN,"Must be authenticated to create a signer");const n={auth:I.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyProvider:e.thirdPartyProvider,thirdPartyTokenType:e.thirdPartyTokenType,token:e.token,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl,shieldAuthentication:n,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",shieldURL:this.sdkConfiguration.shieldUrl,encryptionKey:void 0,appNativeIdentifier:this.sdkConfiguration?.nativeAppIdentifier??void 0}}async buildIFrameRequestConfiguration(){const e=await i.fromStorage(this.storage);if(!e)throw new a(t.NOT_LOGGED_IN,"Must be authenticated to create a signer");const n={auth:I.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyTokenType:e.thirdPartyTokenType??null,thirdPartyProvider:e.thirdPartyProvider??null,accessToken:e.token,playerID:e.userId,recovery:n,chainId:null,password:null,passkey:null}}async create(e){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const i=await this.ensureConnection(),t=await this.buildIFrameRequestConfiguration();t.chainId=e.chainId??null,t.password=e?.entropy?.recoveryPassword??null,t.recovery={...t.recovery,encryptionSession:e?.entropy?.encryptionSession},t.passkey=e?.entropy?.passkey??null;const n={uuid:h(),action:P.CREATE,recovery:t.recovery,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",accessToken:t.accessToken,playerID:t.playerID,thirdPartyProvider:t.thirdPartyProvider,thirdPartyTokenType:t.thirdPartyTokenType,encryptionKey:t.password,encryptionSession:t.recovery?.encryptionSession??null,passkey:t.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,chainId:e.chainId??null,accountType:e.accountType,chainType:e.chainType,nativeAppIdentifier:this.sdkConfiguration?.nativeAppIdentifier??null},r=await i.create(n);return y(r)&&this.handleError(r),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",r.version??"undefined"),r}async recover(i){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const t=await e.fromStorage(this.storage),n=await this.ensureConnection(),r=await this.buildIFrameRequestConfiguration();r.chainId=t?.chainId??null,r.password=i?.entropy?.recoveryPassword??null,r.recovery={...r.recovery,encryptionSession:i?.entropy?.encryptionSession},r.passkey=i?.entropy?.passkey??null;const o={uuid:h(),action:P.RECOVER,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,encryptionSession:r.recovery?.encryptionSession??null,passkey:r.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,account:i.account,nativeAppIdentifier:this.sdkConfiguration?.nativeAppIdentifier??null},s=await n.recover(o);return y(s)&&this.handleError(s),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",s.version??"undefined"),s}async sign(e,i,t,n){u("[iframe] ensureConnection");const r=await this.ensureConnection(),o=new R(h(),e,await this.buildRequestConfiguration(),i,t,n);u("[iframe] done ensureConnection");const s=await r.sign(o);return u("[iframe] response",s),y(s)&&this.handleError(s),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",s.version??"undefined"),s.signature}async switchChain(e){const i=await this.ensureConnection(),t=new b(h(),e,await this.buildRequestConfiguration()),n=await i.switchChain(t);return y(n)&&this.handleError(n),n}async export(){const e=await this.ensureConnection(),i=new E(h(),await this.buildRequestConfiguration()),t=await e.export(i);return y(t)&&this.handleError(t),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",t.version??"undefined"),t.key}async setRecoveryMethod(e,i,t,n,r){const o=await this.ensureConnection(),s=new T(h(),e,await this.buildRequestConfiguration(),i,t,n,r),a=await o.setRecoveryMethod(s);y(a)&&this.handleError(a),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",a.version??"undefined")}async getCurrentDevice(e){const i=await this.ensureConnection(),t=new S(h(),e);try{const e=await i.getCurrentDevice(t);return y(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e}catch(e){if(e instanceof D)return null;throw e}}async updateAuthentication(){if(!this.isLoaded()||!this.remote)return void u("IframeManager not loaded, skipping authentication update");const e=await i.fromStorage(this.storage);if(!e)return void u("No authentication found, skipping update");const t=new N(h(),e.token);u("Updating authentication in iframe with token");const n=await this.remote.updateAuthentication(t);y(n)&&this.handleError(n)}async disconnect(){const e=await this.ensureConnection(),i={uuid:h()};await e.logout(i)}async onMessage(e){u("[HANDSHAKE DEBUG] IframeManager.onMessage called with:",e),this.messenger instanceof l?(this.isInitialized||this.connection?u(`[HANDSHAKE DEBUG] Connection already initialized (isInitialized: ${this.isInitialized}, hasConnection: ${!!this.connection})`):(u("[HANDSHAKE DEBUG] First message received, initializing connection..."),this.initialize().catch(e=>{u("[HANDSHAKE DEBUG] Failed to initialize connection:",e)})),u("[HANDSHAKE DEBUG] Passing message to ReactNativeMessenger"),this.messenger.handleMessage(e)):u("[HANDSHAKE DEBUG] Not a ReactNativeMessenger, ignoring message")}isLoaded(){return this.isInitialized&&void 0!==this.remote}destroy(){this.connection&&this.connection.destroy(),this.remote=void 0,this.isInitialized=!1,this.connection=void 0,this.initializationPromise=null}}export{K as IframeManager,U as MissingProjectEntropyError,A as MissingRecoveryPasswordError,D as NotConfiguredError,M as OTPRequiredError,O as WrongPasskeyError,z as WrongRecoveryPasswordError};
1
+ import{Account as e}from"../core/configuration/account.js";import{Authentication as i}from"../core/configuration/authentication.js";import{OPENFORT_AUTH_ERROR_CODES as n}from"../core/errors/authErrorCodes.js";import{RecoveryError as t,SignerError as r,OpenfortError as o,ConfigurationError as s,SessionError as a}from"../core/errors/openfortError.js";import{sentry as d}from"../core/errors/sentry.js";import{StorageKeys as c}from"../storage/istorage.js";import{randomUUID as h}from"../utils/crypto.js";import{debugLog as u}from"../utils/debug.js";import{ReactNativeMessenger as l}from"./messaging/ReactNativeMessenger.js";import y from"./messaging/browserMessenger/connect.js";import"./messaging/browserMessenger/backwardCompatibility.js";import{isErrorResponse as p,NOT_CONFIGURED_ERROR as f,MISSING_USER_ENTROPY_ERROR as g,MISSING_PROJECT_ENTROPY_ERROR as w,INCORRECT_USER_ENTROPY_ERROR as m,MISSING_PASSKEY_ERROR as v,INCORRECT_PASSKEY_ERROR as C,OTP_REQUIRED_ERROR as k,ShieldAuthType as I,Event as P,SignRequest as b,SwitchChainRequest as T,ExportPrivateKeyRequest as R,SetRecoveryMethodRequest as E,GetCurrentDeviceRequest as S,UpdateAuthenticationRequest as A}from"./types.js";class N extends t{constructor(){super(n.MISSING_RECOVERY_PASSWORD,"This embedded signer requires a password to be recovered","password")}}class O extends t{constructor(){super(n.INCORRECT_PASSKEY,"Wrong recovery passkey for this embedded signer","passkey")}}class U extends t{constructor(){super(n.MISSING_PROJECT_ENTROPY,"Project entropy is missing","entropy")}}class K extends t{constructor(){super(n.WRONG_RECOVERY_PASSWORD,"Wrong recovery password for this embedded signer","password")}}class D extends r{constructor(){super(n.NOT_CONFIGURED,"Signer is not configured")}}class z extends o{constructor(){super(n.OTP_REQUIRED,"OTP verification required")}}class M{messenger;connection;remote;storage;sdkConfiguration;isInitialized=!1;initializationPromise=null;hasFailed=!1;constructor(e,i,n){if(!e)throw new s("Configuration is required for IframeManager");if(!i)throw new s("Storage is required for IframeManager");if(!n)throw new s("Messenger is required for IframeManager");this.sdkConfiguration=e,this.storage=i,this.messenger=n}async initialize(){if(!this.isInitialized){if(this.hasFailed)throw new o(n.INTERNAL_ERROR,"Failed to establish iFrame connection: Previous connection attempt failed");if(this.initializationPromise)await this.initializationPromise;else{this.initializationPromise=this.doInitialize();try{await this.initializationPromise,this.isInitialized=!0}catch(e){throw this.hasFailed=!0,this.initializationPromise=null,e}}}}async doInitialize(){u("Initializing IframeManager connection..."),this.messenger.initialize({validateReceivedMessage:e=>!(!e||"object"!=typeof e),log:u}),this.connection=y({messenger:this.messenger,timeout:1e4,log:u});try{this.remote=await this.connection.promise,u("IframeManager connection established")}catch(e){const i=e;throw d.captureException(i),this.destroy(),u("Failed to establish connection:",i),new o(n.INTERNAL_ERROR,`Failed to establish iFrame connection: ${i.cause||i.message}\n \n In apps built with:\n - react native\n - swift\n - unity (non-webgl) \n \n You must configure your origin in the openfort dashboard before using the embedded wallet.\n\n For more information, see: https://www.openfort.io/docs/configuration/native-apps\n `)}}async ensureConnection(){if(this.isInitialized&&this.remote||await this.initialize(),!this.remote)throw new o(n.INTERNAL_ERROR,"Failed to establish connection");return this.remote}handleError(e){if(p(e)){if(e.error===f)throw this.storage.remove(c.ACCOUNT),new D;if(e.error===g)throw this.storage.remove(c.ACCOUNT),new N;if(e.error===w)throw this.storage.remove(c.ACCOUNT),new U;if(e.error===m)throw new K;if(e.error===v)throw this.storage.remove(c.ACCOUNT),new N;if(e.error===C)throw new O;if(e.error===k)throw new z;throw this.storage.remove(c.ACCOUNT),new o(n.INTERNAL_ERROR,`Unknown error: ${e.error}`)}throw e}async buildRequestConfiguration(){const e=await i.fromStorage(this.storage);if(!e)throw new a(n.NOT_LOGGED_IN,"Must be authenticated to create a signer");const t={auth:I.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyProvider:e.thirdPartyProvider,thirdPartyTokenType:e.thirdPartyTokenType,token:e.token,publishableKey:this.sdkConfiguration.baseConfiguration.publishableKey,openfortURL:this.sdkConfiguration.backendUrl,shieldAuthentication:t,shieldAPIKey:this.sdkConfiguration.shieldConfiguration?.shieldPublishableKey||"",shieldURL:this.sdkConfiguration.shieldUrl,encryptionKey:void 0,appNativeIdentifier:this.sdkConfiguration?.nativeAppIdentifier??void 0}}async buildIFrameRequestConfiguration(){const e=await i.fromStorage(this.storage);if(!e)throw new a(n.NOT_LOGGED_IN,"Must be authenticated to create a signer");const t={auth:I.OPENFORT,authProvider:e.thirdPartyProvider,token:e.token,tokenType:e.thirdPartyTokenType};return{thirdPartyTokenType:e.thirdPartyTokenType??null,thirdPartyProvider:e.thirdPartyProvider??null,accessToken:e.token,playerID:e.userId,recovery:t,chainId:null,password:null,passkey:null}}async create(e){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const i=await this.ensureConnection(),n=await this.buildIFrameRequestConfiguration();n.chainId=e.chainId??null,n.password=e?.entropy?.recoveryPassword??null,n.recovery={...n.recovery,encryptionSession:e?.entropy?.encryptionSession},n.passkey=e?.entropy?.passkey??null;const t={uuid:h(),action:P.CREATE,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,encryptionSession:n.recovery?.encryptionSession??null,passkey:n.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,chainId:e.chainId??null,accountType:e.accountType,chainType:e.chainType,nativeAppIdentifier:this.sdkConfiguration?.nativeAppIdentifier??null},r=await i.create(t);return p(r)&&this.handleError(r),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",r.version??"undefined"),r}async import(e){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const i=await this.ensureConnection(),n=await this.buildIFrameRequestConfiguration();n.chainId=e.chainId??null,n.password=e?.entropy?.recoveryPassword??null,n.recovery={...n.recovery,encryptionSession:e?.entropy?.encryptionSession},n.passkey=e?.entropy?.passkey??null;const t={uuid:h(),action:P.IMPORT,privateKey:e.privateKey,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,encryptionSession:n.recovery?.encryptionSession??null,passkey:n.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,chainId:e.chainId??null,accountType:e.accountType,chainType:e.chainType,nativeAppIdentifier:this.sdkConfiguration?.nativeAppIdentifier??null},r=await i.import(t);return p(r)&&this.handleError(r),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",r.version??"undefined"),r}async recover(i){if(!this.sdkConfiguration.shieldConfiguration)throw new Error("shieldConfiguration is required");const n=await e.fromStorage(this.storage),t=await this.ensureConnection(),r=await this.buildIFrameRequestConfiguration();r.chainId=n?.chainId??null,r.password=i?.entropy?.recoveryPassword??null,r.recovery={...r.recovery,encryptionSession:i?.entropy?.encryptionSession},r.passkey=i?.entropy?.passkey??null;const o={uuid:h(),action:P.RECOVER,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,encryptionSession:r.recovery?.encryptionSession??null,passkey:r.passkey??null,openfortURL:this.sdkConfiguration.backendUrl,shieldURL:this.sdkConfiguration.shieldUrl,account:i.account,nativeAppIdentifier:this.sdkConfiguration?.nativeAppIdentifier??null},s=await t.recover(o);return p(s)&&this.handleError(s),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",s.version??"undefined"),s}async sign(e,i,n,t){u("[iframe] ensureConnection");const r=await this.ensureConnection(),o=new b(h(),e,await this.buildRequestConfiguration(),i,n,t);u("[iframe] done ensureConnection");const s=await r.sign(o);return u("[iframe] response",s),p(s)&&this.handleError(s),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",s.version??"undefined"),s.signature}async switchChain(e){const i=await this.ensureConnection(),n=new T(h(),e,await this.buildRequestConfiguration()),t=await i.switchChain(n);return p(t)&&this.handleError(t),t}async export(){const e=await this.ensureConnection(),i=new R(h(),await this.buildRequestConfiguration()),n=await e.export(i);return p(n)&&this.handleError(n),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",n.version??"undefined"),n.key}async setRecoveryMethod(e,i,n,t,r){const o=await this.ensureConnection(),s=new E(h(),e,await this.buildRequestConfiguration(),i,n,t,r),a=await o.setRecoveryMethod(s);p(a)&&this.handleError(a),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",a.version??"undefined")}async getCurrentDevice(e){const i=await this.ensureConnection(),n=new S(h(),e);try{const e=await i.getCurrentDevice(n);return p(e)&&this.handleError(e),"undefined"!=typeof sessionStorage&&sessionStorage.setItem("iframe-version",e.version??"undefined"),e}catch(e){if(e instanceof D)return null;throw e}}async updateAuthentication(){if(!this.isLoaded()||!this.remote)return void u("IframeManager not loaded, skipping authentication update");const e=await i.fromStorage(this.storage);if(!e)return void u("No authentication found, skipping update");const n=new A(h(),e.token);u("Updating authentication in iframe with token");const t=await this.remote.updateAuthentication(n);p(t)&&this.handleError(t)}async disconnect(){const e=await this.ensureConnection(),i={uuid:h()};await e.logout(i)}async onMessage(e){u("[HANDSHAKE DEBUG] IframeManager.onMessage called with:",e),this.messenger instanceof l?(this.isInitialized||this.connection?u(`[HANDSHAKE DEBUG] Connection already initialized (isInitialized: ${this.isInitialized}, hasConnection: ${!!this.connection})`):(u("[HANDSHAKE DEBUG] First message received, initializing connection..."),this.initialize().catch(e=>{u("[HANDSHAKE DEBUG] Failed to initialize connection:",e)})),u("[HANDSHAKE DEBUG] Passing message to ReactNativeMessenger"),this.messenger.handleMessage(e)):u("[HANDSHAKE DEBUG] Not a ReactNativeMessenger, ignoring message")}isLoaded(){return this.isInitialized&&void 0!==this.remote}destroy(){this.connection&&this.connection.destroy(),this.remote=void 0,this.isInitialized=!1,this.connection=void 0,this.initializationPromise=null}}export{M as IframeManager,U as MissingProjectEntropyError,N as MissingRecoveryPasswordError,D as NotConfiguredError,z as OTPRequiredError,O as WrongPasskeyError,K as WrongRecoveryPasswordError};
@@ -1 +1 @@
1
- var r;!function(r){r.RECOVER="recover",r.RECOVERED="recovered",r.CREATE="create",r.CREATED="created",r.UPDATE_AUTHENTICATION="update-authentication",r.AUTHENTICATION_UPDATED="authentication-updated",r.SIGN="sign",r.SET_RECOVERY_METHOD="set-recovery-method",r.SWITCH_CHAIN="switch-chain",r.CHAIN_SWITCHED="chain-switched",r.EXPORT="export",r.SIGNED="signed",r.LOGGED_OUT="logged-out",r.GET_CURRENT_DEVICE="get-current-device",r.CURRENT_DEVICE="current-device"}(r||(r={}));const e="not-configured-error",i="missing-user-entropy-error",t="missing-project-entropy-error",s="incorrect-user-entropy-error",o="incorrect-passkey-error",n="missing-passkey-error",c="otp-required-error";class u{uuid;action=r.GET_CURRENT_DEVICE;playerID;constructor(r,e){this.uuid=r,this.playerID=e}}class a{uuid;action=r.SIGN;message;requestConfiguration;requireArrayify;requireHash;chainType;constructor(r,e,i,t,s,o){this.uuid=r,this.message=e,this.requestConfiguration=i,this.requireArrayify=t,this.requireHash=s,this.chainType=o||"EVM"}}class E{uuid;action=r.SWITCH_CHAIN;chainId;requestConfiguration;constructor(r,e,i){this.uuid=r,this.chainId=e,this.requestConfiguration=i}}class h{uuid;action=r.EXPORT;requestConfiguration;constructor(r,e){this.uuid=r,this.requestConfiguration=e}}class T{uuid;action=r.SET_RECOVERY_METHOD;recoveryMethod;recoveryPassword;encryptionSession;passkeyKey;passkeyId;requestConfiguration;constructor(r,e,i,t,s,o,n){this.uuid=r,this.recoveryMethod=e,this.recoveryPassword=t,this.encryptionSession=s,this.requestConfiguration=i,this.passkeyKey=o,this.passkeyId=n}}function d(r){return"error"in r}class C{uuid;action=r.UPDATE_AUTHENTICATION;accessToken;recovery;constructor(r,e,i){this.uuid=r,this.accessToken=e,this.recovery=i}}var y;!function(r){r.OPENFORT="openfort"}(y||(y={}));export{r as Event,h as ExportPrivateKeyRequest,u as GetCurrentDeviceRequest,o as INCORRECT_PASSKEY_ERROR,s as INCORRECT_USER_ENTROPY_ERROR,n as MISSING_PASSKEY_ERROR,t as MISSING_PROJECT_ENTROPY_ERROR,i as MISSING_USER_ENTROPY_ERROR,e as NOT_CONFIGURED_ERROR,c as OTP_REQUIRED_ERROR,T as SetRecoveryMethodRequest,y as ShieldAuthType,a as SignRequest,E as SwitchChainRequest,C as UpdateAuthenticationRequest,d as isErrorResponse};
1
+ var r;!function(r){r.RECOVER="recover",r.RECOVERED="recovered",r.CREATE="create",r.CREATED="created",r.IMPORT="import",r.IMPORTED="imported",r.UPDATE_AUTHENTICATION="update-authentication",r.AUTHENTICATION_UPDATED="authentication-updated",r.SIGN="sign",r.SET_RECOVERY_METHOD="set-recovery-method",r.SWITCH_CHAIN="switch-chain",r.CHAIN_SWITCHED="chain-switched",r.EXPORT="export",r.SIGNED="signed",r.LOGGED_OUT="logged-out",r.GET_CURRENT_DEVICE="get-current-device",r.CURRENT_DEVICE="current-device"}(r||(r={}));const e="not-configured-error",i="missing-user-entropy-error",t="missing-project-entropy-error",s="incorrect-user-entropy-error",o="incorrect-passkey-error",n="missing-passkey-error",c="otp-required-error";class u{uuid;action=r.GET_CURRENT_DEVICE;playerID;constructor(r,e){this.uuid=r,this.playerID=e}}class a{uuid;action=r.SIGN;message;requestConfiguration;requireArrayify;requireHash;chainType;constructor(r,e,i,t,s,o){this.uuid=r,this.message=e,this.requestConfiguration=i,this.requireArrayify=t,this.requireHash=s,this.chainType=o||"EVM"}}class E{uuid;action=r.SWITCH_CHAIN;chainId;requestConfiguration;constructor(r,e,i){this.uuid=r,this.chainId=e,this.requestConfiguration=i}}class h{uuid;action=r.EXPORT;requestConfiguration;constructor(r,e){this.uuid=r,this.requestConfiguration=e}}class T{uuid;action=r.SET_RECOVERY_METHOD;recoveryMethod;recoveryPassword;encryptionSession;passkeyKey;passkeyId;requestConfiguration;constructor(r,e,i,t,s,o,n){this.uuid=r,this.recoveryMethod=e,this.recoveryPassword=t,this.encryptionSession=s,this.requestConfiguration=i,this.passkeyKey=o,this.passkeyId=n}}function d(r){return"error"in r}class C{uuid;action=r.UPDATE_AUTHENTICATION;accessToken;recovery;constructor(r,e,i){this.uuid=r,this.accessToken=e,this.recovery=i}}var y;!function(r){r.OPENFORT="openfort"}(y||(y={}));export{r as Event,h as ExportPrivateKeyRequest,u as GetCurrentDeviceRequest,o as INCORRECT_PASSKEY_ERROR,s as INCORRECT_USER_ENTROPY_ERROR,n as MISSING_PASSKEY_ERROR,t as MISSING_PROJECT_ENTROPY_ERROR,i as MISSING_USER_ENTROPY_ERROR,e as NOT_CONFIGURED_ERROR,c as OTP_REQUIRED_ERROR,T as SetRecoveryMethodRequest,y as ShieldAuthType,a as SignRequest,E as SwitchChainRequest,C as UpdateAuthenticationRequest,d as isErrorResponse};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfort/openfort-js",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "author": "Openfort (https://www.openfort.io)",
5
5
  "bugs": "https://github.com/openfort-xyz/openfort-js/issues",
6
6
  "repository": "openfort-xyz/openfort-js.git",
@@ -53,13 +53,13 @@
53
53
  "@rollup/plugin-terser": "^0.4.4",
54
54
  "@rollup/plugin-typescript": "^11.1.6",
55
55
  "@types/node": "^22.19.17",
56
- "@vitest/coverage-v8": "^2.1.9",
56
+ "@vitest/coverage-v8": "^4.1.8",
57
57
  "jsdom": "^25.0.1",
58
58
  "rollup": "^4.60.1",
59
59
  "rollup-plugin-dts": "^5.3.1",
60
60
  "rollup-plugin-visualizer": "^5.14.0",
61
61
  "typescript": "^5.9.3",
62
- "vitest": "^2.1.9",
62
+ "vitest": "^4.1.8",
63
63
  "@openfort/openapi-clients": "0.0.1"
64
64
  },
65
65
  "main": "./dist/cjs/sdk/src/index.cjs",