@openfort/openfort-js 1.3.3 → 1.3.4
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/sdk/src/api/embeddedWallet.cjs +1 -1
- package/dist/cjs/sdk/src/core/passkey/handler.cjs +1 -1
- package/dist/cjs/sdk/src/version.cjs +1 -1
- package/dist/cjs/sdk/src/wallets/embedded.cjs +1 -1
- package/dist/cjs/sdk/src/wallets/iframeManager.cjs +1 -1
- package/dist/cjs/sdk/src/wallets/types.cjs +1 -1
- package/dist/index.d.cts +134 -202
- package/dist/index.d.ts +134 -202
- package/dist/sdk/src/api/embeddedWallet.js +1 -1
- package/dist/sdk/src/core/passkey/handler.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/iframeManager.js +1 -1
- package/dist/sdk/src/wallets/types.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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};
|
package/dist/sdk/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="1.3.
|
|
1
|
+
const o="1.3.4",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};
|
|
@@ -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