@openfort/openfort-js 0.10.36-beta.1 → 0.10.36-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var t=require("../core/configuration/authentication.js"),e=require("../core/errors/authErrorCodes.js"),i=require("../core/errors/openfortError.js"),a=require("../types/types.js");exports.AuthApi=class{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(t,e,i,a,n){this.storage=t,this.authManager=e,this.validateAndRefreshToken=i,this.ensureInitialized=a,this.eventEmitter=n}async logInWithEmailPassword({email:n,password:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"email"});try{const e=await this.authManager.loginEmailPassword(n,r);return null===e?.token||(new t.Authentication("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async signUpGuest(){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"guest"});try{const e=await this.authManager.registerGuest();return new t.Authentication("session",e.token,e?.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async signUpWithEmailPassword({email:n,password:r,name:s,callbackURL:o}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"email"});try{const e=s||n,i=await this.authManager.signupEmailPassword(n,r,e,o);return i instanceof Object&&"action"in i||(new t.Authentication("session",i.token,i?.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,i)),i}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async initOAuth({provider:n,redirectTo:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"oauth",provider:n});try{return await this.authManager.initOAuth(n,r)}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async logInWithIdToken({provider:n,token:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"idToken",provider:n});try{const e=await this.authManager.loginWithIdToken(n,r);return new t.Authentication("session",e.token,e?.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async storeCredentials({token:e,userId:a}){if(await this.ensureInitialized(),!a)throw new i.ConfigurationError("User ID is required to store credentials");const n=encodeURIComponent(e);new t.Authentication("session",n,a).save(this.storage)}async logout(){const e=await t.Authentication.fromStorage(this.storage);if(e){try{"third_party"!==e.type&&await this.authManager.logout(e)}catch(t){}t.Authentication.clear(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_LOGOUT)}}async requestEmailOtp({email:n}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_OTP_REQUEST,{method:"email"});try{await this.authManager.requestEmailOTP(n)}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_OTP_FAILURE,t),t}}async logInWithEmailOtp({email:n,otp:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"email"});try{const e=await this.authManager.loginWithEmailOTP(n,r);return null===e?.token||(new t.Authentication("session",e.token,e?.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async requestPhoneOtp({phoneNumber:n}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_OTP_REQUEST,{method:"phone",provider:"phone"});try{await this.authManager.requestPhoneOtp(n)}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_OTP_FAILURE,t),t}}async logInWithPhoneOtp({phoneNumber:n,otp:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"phone"});try{const e=await this.authManager.loginWithSMSOTP(n,r);return null===e?.token||(new t.Authentication("session",e.token,e?.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async requestResetPassword({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestResetPassword(t,e)}async resetPassword({password:t,token:e}){await this.ensureInitialized(),await this.authManager.resetPassword(t,e)}async requestEmailVerification({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestEmailVerification(t,e)}async verifyEmail({token:t,callbackURL:e}){await this.ensureInitialized(),await this.authManager.verifyEmail(t,e)}async initLinkOAuth({provider:n,options:r}){await this.validateAndRefreshToken();const s=await t.Authentication.fromStorage(this.storage);if(!s)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"oauth",provider:n}),await this.authManager.linkOAuth(s,n,r)}async unlinkOAuth({provider:a}){await this.validateAndRefreshToken();const n=await t.Authentication.fromStorage(this.storage);if(!n)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkOAuth(a,n)}async initSIWE({address:t,chainId:e}){return await this.ensureInitialized(),await this.authManager.initSIWE(t,e)}async authenticateWithSIWE({signature:n,message:r,walletClientType:s,connectorType:o,address:h,chainId:E}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"siwe"});try{const e=await this.authManager.authenticateSIWE(n,r,s,o,h,E);return new t.Authentication("session",e.token,e?.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async linkWallet({signature:a,message:n,walletClientType:r,connectorType:s,address:o,chainId:h}){await this.validateAndRefreshToken();const E=await t.Authentication.fromStorage(this.storage);if(!E)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkWallet(a,n,r,s,o,h,E)}async unlinkWallet({address:a,chainId:n}){await this.validateAndRefreshToken();const r=await t.Authentication.fromStorage(this.storage);if(!r)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkWallet(a,n,r)}async unlinkEmail(){await this.validateAndRefreshToken();const a=await t.Authentication.fromStorage(this.storage);if(!a)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkEmail(a)}async linkEmailPassword({name:a,email:n,password:r}){await this.validateAndRefreshToken();const s=await t.Authentication.fromStorage(this.storage);if(!s)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkEmail(a,n,r,s)}async unlinkEmailPassword(){await this.validateAndRefreshToken();const a=await t.Authentication.fromStorage(this.storage);if(!a)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkEmail(a)}};
1
+ "use strict";var t=require("../core/configuration/authentication.js"),e=require("../core/errors/authErrorCodes.js"),i=require("../core/errors/openfortError.js"),a=require("../types/types.js");exports.AuthApi=class{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(t,e,i,a,n){this.storage=t,this.authManager=e,this.validateAndRefreshToken=i,this.ensureInitialized=a,this.eventEmitter=n}async logInWithEmailPassword({email:n,password:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"email"});try{const e=await this.authManager.loginEmailPassword(n,r);return null===e?.token||(new t.Authentication("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async signUpGuest(){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"guest"});try{const e=await this.authManager.registerGuest();return new t.Authentication("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async signUpWithEmailPassword({email:n,password:r,name:s,callbackURL:o}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"email"});try{const e=s||n,i=await this.authManager.signupEmailPassword(n,r,e,o);return i instanceof Object&&"action"in i||(new t.Authentication("session",i.token,i.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,i)),i}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async initOAuth({provider:n,redirectTo:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"oauth",provider:n});try{return await this.authManager.initOAuth(n,r)}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async linkOAuthToAnonymous({provider:e,redirectTo:i}){await this.ensureInitialized();const n=await t.Authentication.fromStorage(this.storage);if(!n)throw new Error("Must be signed in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"oauth",provider:e});try{return await this.authManager.linkOAuthToAnonymous(n,e,i)}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async logInWithIdToken({provider:n,token:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"idToken",provider:n});try{const e=await this.authManager.loginWithIdToken(n,r);return new t.Authentication("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async storeCredentials({token:e,userId:a}){if(await this.ensureInitialized(),!a)throw new i.ConfigurationError("User ID is required to store credentials");const n=encodeURIComponent(e);new t.Authentication("session",n,a).save(this.storage)}async logout(){const e=await t.Authentication.fromStorage(this.storage);if(e){try{"third_party"!==e.type&&await this.authManager.logout(e)}catch(t){}t.Authentication.clear(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_LOGOUT)}}async requestEmailOtp({email:n}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_OTP_REQUEST,{method:"email"});try{await this.authManager.requestEmailOTP(n)}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_OTP_FAILURE,t),t}}async logInWithEmailOtp({email:n,otp:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"email"});try{const e=await this.authManager.loginWithEmailOTP(n,r);return null===e?.token||(new t.Authentication("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async requestPhoneOtp({phoneNumber:n}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_OTP_REQUEST,{method:"phone",provider:"phone"});try{await this.authManager.requestPhoneOtp(n)}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_OTP_FAILURE,t),t}}async logInWithPhoneOtp({phoneNumber:n,otp:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"phone"});try{const e=await this.authManager.loginWithSMSOTP(n,r);return null===e?.token||(new t.Authentication("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async requestResetPassword({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestResetPassword(t,e)}async resetPassword({password:t,token:e}){await this.ensureInitialized(),await this.authManager.resetPassword(t,e)}async requestEmailVerification({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestEmailVerification(t,e)}async verifyEmail({token:t,callbackURL:e}){await this.ensureInitialized(),await this.authManager.verifyEmail(t,e)}async initLinkOAuth({provider:n,options:r}){await this.validateAndRefreshToken();const s=await t.Authentication.fromStorage(this.storage);if(!s)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"oauth",provider:n}),await this.authManager.linkOAuth(s,n,r)}async unlinkOAuth({provider:a}){await this.validateAndRefreshToken();const n=await t.Authentication.fromStorage(this.storage);if(!n)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkOAuth(a,n)}async initSIWE({address:t,chainId:e}){return await this.ensureInitialized(),await this.authManager.initSIWE(t,e)}async linkSIWE({address:a,chainId:n}){await this.ensureInitialized();const r=await t.Authentication.fromStorage(this.storage);if(!r)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkSIWE(a,r,n)}async authenticateWithSIWE({signature:n,message:r,walletClientType:s,connectorType:o,address:h,chainId:E}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_INIT,{method:"siwe"});try{const e=await this.authManager.authenticateSIWE(n,r,s,o,h,E);return new t.Authentication("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(a.OpenfortEvents.ON_AUTH_FAILURE,t),t}}async linkWallet({signature:a,message:n,walletClientType:r,connectorType:s,address:o,chainId:h}){await this.validateAndRefreshToken();const E=await t.Authentication.fromStorage(this.storage);if(!E)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkWallet(a,n,r,s,o,h,E)}async unlinkWallet({address:a,chainId:n}){await this.validateAndRefreshToken();const r=await t.Authentication.fromStorage(this.storage);if(!r)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkWallet(a,n,r)}async unlinkEmail(){await this.validateAndRefreshToken();const a=await t.Authentication.fromStorage(this.storage);if(!a)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkEmail(a)}async linkEmailPassword({name:a,email:n,password:r}){await this.validateAndRefreshToken();const s=await t.Authentication.fromStorage(this.storage);if(!s)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkEmail(a,n,r,s)}async unlinkEmailPassword(){await this.validateAndRefreshToken();const a=await t.Authentication.fromStorage(this.storage);if(!a)throw new i.SessionError(e.OPENFORT_AUTH_ERROR_CODES.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkEmail(a)}};
@@ -1 +1 @@
1
- "use strict";var e=require("../utils/debug.js"),t=require("../core/errors/authErrorCodes.js"),i=require("../core/errors/openfortError.js"),a=require("../core/errors/withApiError.js"),r=require("../types/types.js");function n(e){if(!e)throw new i.OpenfortError(t.OPENFORT_AUTH_ERROR_CODES.INTERNAL_ERROR,"User data is missing");return{id:e.id||"",email:e.email,name:e.name??void 0,image:e.image??void 0,emailVerified:e.emailVerified,isAnonymous:e.isAnonymous,createdAt:e.createdAt,updatedAt:e.updatedAt}}function s(e){if(e)return{id:e.id,token:e.token,userId:e.userId,expiresAt:e.expiresAt,createdAt:e.createdAt,updatedAt:e.updatedAt}}exports.AuthManager=class{backendApiClientsInstance;publishableKeyInstance;setBackendApiClients(e,t){this.backendApiClientsInstance=e,this.publishableKeyInstance=t}get backendApiClients(){if(!this.backendApiClientsInstance)throw new i.ConfigurationError("Backend API clients not initialized");return this.backendApiClientsInstance}get publishableKey(){if(!this.publishableKeyInstance)throw new i.ConfigurationError("Publishable key not initialized");return this.publishableKeyInstance}async initOAuth(e,t){return await a.withApiError(async()=>(await this.backendApiClients.authenticationV2Api.socialSignIn({socialSignInRequest:{provider:e,callbackURL:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data.url||"",{context:"initOAuth"})}async registerGuest(){return a.withApiError(async()=>{const e=await this.backendApiClients.anonymousApi.signInAnonymousPost({headers:{"x-project-key":`${this.publishableKey}`}});return{token:e.data.token,user:n(e.data.user)}},{context:"registerGuest"})}async loginWithIdToken(e,t){const i={socialSignInRequest:{provider:e,token:t}};return await a.withApiError(async()=>{const e=await this.backendApiClients.authenticationV2Api.socialSignIn(i);return{token:e.data.token,user:n(e.data.user)}},{context:"loginWithIdToken"})}async authenticateThirdParty(e,t,i){const r={thirdPartyOAuthRequest:{provider:e,token:t,tokenType:i}};return a.withApiError(async()=>({userId:(await this.backendApiClients.authenticationApi.thirdParty(r,{headers:{"x-project-key":`${this.publishableKey}`}})).data.id}),{context:"authenticateThirdParty"})}async initSIWE(e,t){const i={siweNoncePostRequest:{walletAddress:e,chainId:t||1}};return{address:e,nonce:(await a.withApiError(async()=>this.backendApiClients.siweApi.siweNoncePost(i,{headers:{"x-project-key":`${this.publishableKey}`}}),{context:"initSIWE"})).data.nonce}}async authenticateSIWE(e,t,i,r,s,o){const h={siweVerifyPostRequest:{signature:e,walletAddress:s,chainId:o||1,message:t,walletClientType:i,connectorType:r}};return a.withApiError(async()=>{const e=await this.backendApiClients.siweApi.siweVerifyPost(h,{headers:{"x-project-key":`${this.publishableKey}`}}),t=e.data.user;return{token:e.data.token,user:n(t)}},{context:"authenticateSIWE"})}async loginEmailPassword(e,t){return a.withApiError(async()=>{const i=(await this.backendApiClients.authenticationV2Api.signInEmailPost({signInEmailPostRequest:{email:e,password:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:n(i.user)}},{context:"loginEmailPassword"})}async requestResetPassword(e,t){await a.withApiError(async()=>{await this.backendApiClients.authenticationV2Api.forgetPasswordPost({forgetPasswordPostRequest:{email:e,redirectTo:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"requestResetPassword"})}async resetPassword(e,t){return a.withApiError(async()=>{await this.backendApiClients.authenticationV2Api.resetPasswordPost({resetPasswordPostRequest:{newPassword:e,token:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"resetPassword"})}async requestEmailVerification(e,t){await a.withApiError(async()=>{await this.backendApiClients.authenticationV2Api.sendVerificationEmailPost({sendVerificationEmailPostRequest:{email:e,callbackURL:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"requestEmailVerification"})}async verifyEmail(e,t){return a.withApiError(async()=>{await this.backendApiClients.authenticationV2Api.verifyEmailGet({token:e,callbackURL:t})},{context:"verifyEmail"})}async signupEmailPassword(e,t,i,s){return a.withApiError(async()=>{const a=(await this.backendApiClients.authenticationV2Api.signUpEmailPost({signUpEmailPostRequest:{email:e,password:t,name:i,callbackURL:s}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return a.token?{token:a.token,user:n(a.user)}:{action:r.AuthActionRequiredActions.ACTION_VERIFY_EMAIL}},{context:"signupEmailPassword"})}async validateCredentials(t,i){e.debugLog("Validating credentials with token:",t.token);const a=await this.getSessionWithToken(t,i);return{token:a.session.token,user:n(a.user),session:s(a.session)}}async logout(e){return a.withApiError(async()=>{await this.backendApiClients.authenticationV2Api.signOutPost(void 0,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})},{context:"logout"})}async getUser(e){return a.withApiError(async()=>n((await this.backendApiClients.userApi.meV2({headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data),{context:"getUser"})}async listAccounts(e){return a.withApiError(async()=>(await this.backendApiClients.authenticationV2Api.listAccountsGet({headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"listAccounts"})}async linkOAuth(e,t,i){const r=i?.skipBrowserRedirect??!1,n={linkSocialPostRequest:{provider:t,callbackURL:i?.redirectTo,scopes:i?.scopes?.split(" "),disableRedirect:r}},s=await a.withApiError(async()=>this.backendApiClients.authenticationV2Api.linkSocialPost(n,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}}),{context:"linkOAuth"});return"undefined"!=typeof window&&!r&&s.data.url&&window.location.assign(s.data.url),s.data.url||""}async unlinkOAuth(e,t){const i={unlinkAccountPostRequest:{providerId:e}};return a.withApiError(async()=>(await this.backendApiClients.authenticationV2Api.unlinkAccountPost(i,{headers:t.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":t.token,"x-auth-provider":t.thirdPartyProvider,"x-token-type":t.thirdPartyTokenType}:{authorization:`Bearer ${t.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"unlinkOAuth"})}async linkEmail(e,t,i,r){const s={signUpEmailPostRequest:{name:e,email:t,password:i}};return a.withApiError(async()=>{const e=await this.backendApiClients.authenticationV2Api.signUpEmailPost(s,{headers:r.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":r.token,"x-auth-provider":r.thirdPartyProvider,"x-token-type":r.thirdPartyTokenType}:{authorization:`Bearer ${r.token}`,"x-project-key":`${this.publishableKey}`}});return{token:e.data.token,user:n(e.data.user)}},{context:"linkEmail"})}async unlinkEmail(e){const t={unlinkAccountPostRequest:{providerId:"credential"}};return a.withApiError(async()=>(await this.backendApiClients.authenticationV2Api.unlinkAccountPost(t,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data.status,{context:"unlinkEmail"})}async unlinkWallet(e,t,i){const r={linkSiweUnlinkPostRequest:{walletAddress:e,chaindId:t}};return a.withApiError(async()=>(await this.backendApiClients.siweApi.linkSiweUnlinkPost(r,{headers:i.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}:{authorization:`Bearer ${i.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"unlinkWallet"})}async linkWallet(e,t,i,r,n,s,o){const h={siweVerifyPostRequest:{signature:e,message:t,walletAddress:n,chainId:s,walletClientType:i,connectorType:r}};return a.withApiError(async()=>(await this.backendApiClients.siweApi.linkSiweVerifyPost(h,{headers:o.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":o.token,"x-auth-provider":o.thirdPartyProvider,"x-token-type":o.thirdPartyTokenType}:{authorization:`Bearer ${o.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"linkWallet"})}async requestEmailOTP(e){const t={emailOtpSendVerificationOtpPostRequest:{email:e,type:"sign-in"}};await a.withApiError(async()=>(await this.backendApiClients.emailOTPApi.emailOtpSendVerificationOtpPost(t,{headers:{"x-project-key":`${this.publishableKey}`}})).data,{context:"requestEmailOTP"})}async loginWithEmailOTP(e,t){return await a.withApiError(async()=>{const i=(await this.backendApiClients.emailOTPApi.signInEmailOtpPost({signInEmailOtpPostRequest:{email:e,otp:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:n(i.user)}},{context:"loginWithEmailOTP"})}async requestPhoneOtp(e){const t={phoneNumberSendOtpPostRequest:{phoneNumber:e}};await a.withApiError(async()=>(await this.backendApiClients.smsOTPApi.phoneNumberSendOtpPost(t,{headers:{"x-project-key":`${this.publishableKey}`}})).data,{context:"requestPhoneOtp"})}async loginWithSMSOTP(e,t){return await a.withApiError(async()=>{const i=(await this.backendApiClients.smsOTPApi.phoneNumberVerifyPost({phoneNumberVerifyPostRequest:{code:t,phoneNumber:e}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:n(i.user)}},{context:"loginWithSMSOTP"})}async getSessionWithToken(e,t){return await a.withApiError(async()=>(await this.backendApiClients.authenticationV2Api.getSessionGet({disableCookieCache:t},{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"getSessionWithToken"})}};
1
+ "use strict";var e=require("../utils/debug.js"),t=require("../core/errors/authErrorCodes.js"),i=require("../core/errors/openfortError.js"),a=require("../core/errors/withApiError.js"),r=require("../types/types.js");function n(e){if(!e)throw new i.OpenfortError(t.OPENFORT_AUTH_ERROR_CODES.INTERNAL_ERROR,"User data is missing");return{id:e.id||"",email:e.email,name:e.name??void 0,image:e.image??void 0,emailVerified:e.emailVerified,isAnonymous:e.isAnonymous,createdAt:e.createdAt,updatedAt:e.updatedAt}}function s(e){if(e)return{id:e.id,token:e.token,userId:e.userId,expiresAt:e.expiresAt,createdAt:e.createdAt,updatedAt:e.updatedAt}}exports.AuthManager=class{backendApiClientsInstance;publishableKeyInstance;setBackendApiClients(e,t){this.backendApiClientsInstance=e,this.publishableKeyInstance=t}get backendApiClients(){if(!this.backendApiClientsInstance)throw new i.ConfigurationError("Backend API clients not initialized");return this.backendApiClientsInstance}get publishableKey(){if(!this.publishableKeyInstance)throw new i.ConfigurationError("Publishable key not initialized");return this.publishableKeyInstance}async initOAuth(e,t){return await a.withApiError(async()=>(await this.backendApiClients.authenticationV2Api.socialSignIn({socialSignInRequest:{provider:e,callbackURL:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data.url||"",{context:"initOAuth"})}async linkOAuthToAnonymous(e,t,i){return await a.withApiError(async()=>(await this.backendApiClients.authenticationV2Api.socialSignIn({socialSignInRequest:{provider:t,callbackURL:i}},{headers:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data.url||"",{context:"initOAuth"})}async registerGuest(){return a.withApiError(async()=>{const e=await this.backendApiClients.anonymousApi.signInAnonymousPost({headers:{"x-project-key":`${this.publishableKey}`}});return{token:e.data.token,user:n(e.data.user)}},{context:"registerGuest"})}async loginWithIdToken(e,t){const i={socialSignInRequest:{provider:e,token:t}};return await a.withApiError(async()=>{const e=await this.backendApiClients.authenticationV2Api.socialSignIn(i);return{token:e.data.token,user:n(e.data.user)}},{context:"loginWithIdToken"})}async authenticateThirdParty(e,t,i){const r={thirdPartyOAuthRequest:{provider:e,token:t,tokenType:i}};return a.withApiError(async()=>({userId:(await this.backendApiClients.authenticationApi.thirdParty(r,{headers:{"x-project-key":`${this.publishableKey}`}})).data.id}),{context:"authenticateThirdParty"})}async initSIWE(e,t){const i={siweNoncePostRequest:{walletAddress:e,chainId:t||1}};return{address:e,nonce:(await a.withApiError(async()=>this.backendApiClients.siweApi.siweNoncePost(i,{headers:{"x-project-key":`${this.publishableKey}`}}),{context:"initSIWE"})).data.nonce}}async linkSIWE(e,t,i){const r={siweNoncePostRequest:{walletAddress:e,chainId:i||1}};return{address:e,nonce:(await a.withApiError(async()=>this.backendApiClients.siweApi.linkSiweNoncePost(r,{headers:{authorization:`Bearer ${t.token}`,"x-project-key":`${this.publishableKey}`}}),{context:"linkSIWE"})).data.nonce}}async authenticateSIWE(e,t,i,r,s,o){const h={siweVerifyPostRequest:{signature:e,walletAddress:s,chainId:o||1,message:t,walletClientType:i,connectorType:r}};return a.withApiError(async()=>{const e=await this.backendApiClients.siweApi.siweVerifyPost(h,{headers:{"x-project-key":`${this.publishableKey}`}}),t=e.data.user;return{token:e.data.token,user:n(t)}},{context:"authenticateSIWE"})}async loginEmailPassword(e,t){return a.withApiError(async()=>{const i=(await this.backendApiClients.authenticationV2Api.signInEmailPost({signInEmailPostRequest:{email:e,password:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:n(i.user)}},{context:"loginEmailPassword"})}async requestResetPassword(e,t){await a.withApiError(async()=>{await this.backendApiClients.authenticationV2Api.requestPasswordResetPost({forgetPasswordPostRequest:{email:e,redirectTo:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"requestResetPassword"})}async resetPassword(e,t){return a.withApiError(async()=>{await this.backendApiClients.authenticationV2Api.resetPasswordPost({resetPasswordPostRequest:{newPassword:e,token:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"resetPassword"})}async requestEmailVerification(e,t){await a.withApiError(async()=>{await this.backendApiClients.authenticationV2Api.sendVerificationEmailPost({sendVerificationEmailPostRequest:{email:e,callbackURL:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"requestEmailVerification"})}async verifyEmail(e,t){return a.withApiError(async()=>{await this.backendApiClients.authenticationV2Api.verifyEmailGet({token:e,callbackURL:t})},{context:"verifyEmail"})}async signupEmailPassword(e,t,i,s){return a.withApiError(async()=>{const a=(await this.backendApiClients.authenticationV2Api.signUpEmailPost({signUpEmailPostRequest:{email:e,password:t,name:i,callbackURL:s}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return a.token?{token:a.token,user:n(a.user)}:{action:r.AuthActionRequiredActions.ACTION_VERIFY_EMAIL}},{context:"signupEmailPassword"})}async validateCredentials(t,i){e.debugLog("Validating credentials with token:",t.token);const a=await this.getSessionWithToken(t,i);return{token:a.session.token,user:n(a.user),session:s(a.session)}}async logout(e){return a.withApiError(async()=>{await this.backendApiClients.authenticationV2Api.signOutPost(void 0,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})},{context:"logout"})}async getUser(e){return a.withApiError(async()=>n((await this.backendApiClients.userApi.meV2({headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data),{context:"getUser"})}async listAccounts(e){return a.withApiError(async()=>(await this.backendApiClients.authenticationV2Api.listAccountsGet({headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"listAccounts"})}async linkOAuth(e,t,i){const r=i?.skipBrowserRedirect??!1,n={linkSocialPostRequest:{provider:t,callbackURL:i?.redirectTo,scopes:i?.scopes?.split(" "),disableRedirect:r}},s=await a.withApiError(async()=>this.backendApiClients.authenticationV2Api.linkSocialPost(n,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}}),{context:"linkOAuth"});return"undefined"!=typeof window&&!r&&s.data.url&&window.location.assign(s.data.url),s.data.url||""}async unlinkOAuth(e,t){const i={unlinkAccountPostRequest:{providerId:e}};return a.withApiError(async()=>(await this.backendApiClients.authenticationV2Api.unlinkAccountPost(i,{headers:t.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":t.token,"x-auth-provider":t.thirdPartyProvider,"x-token-type":t.thirdPartyTokenType}:{authorization:`Bearer ${t.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"unlinkOAuth"})}async linkEmail(e,t,i,r){const s={signUpEmailPostRequest:{name:e,email:t,password:i}};return a.withApiError(async()=>{const e=await this.backendApiClients.authenticationV2Api.signUpEmailPost(s,{headers:r.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":r.token,"x-auth-provider":r.thirdPartyProvider,"x-token-type":r.thirdPartyTokenType}:{authorization:`Bearer ${r.token}`,"x-project-key":`${this.publishableKey}`}});return{token:e.data.token,user:n(e.data.user)}},{context:"linkEmail"})}async unlinkEmail(e){const t={unlinkAccountPostRequest:{providerId:"credential"}};return a.withApiError(async()=>(await this.backendApiClients.authenticationV2Api.unlinkAccountPost(t,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data.status,{context:"unlinkEmail"})}async unlinkWallet(e,t,i){const r={linkSiweUnlinkPostRequest:{walletAddress:e,chaindId:t}};return a.withApiError(async()=>(await this.backendApiClients.siweApi.linkSiweUnlinkPost(r,{headers:i.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}:{authorization:`Bearer ${i.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"unlinkWallet"})}async linkWallet(e,t,i,r,n,s,o){const h={siweVerifyPostRequest:{signature:e,message:t,walletAddress:n,chainId:s,walletClientType:i,connectorType:r}};return a.withApiError(async()=>(await this.backendApiClients.siweApi.linkSiweVerifyPost(h,{headers:o.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":o.token,"x-auth-provider":o.thirdPartyProvider,"x-token-type":o.thirdPartyTokenType}:{authorization:`Bearer ${o.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"linkWallet"})}async requestEmailOTP(e){const t={emailOtpSendVerificationOtpPostRequest:{email:e,type:"sign-in"}};await a.withApiError(async()=>(await this.backendApiClients.emailOTPApi.emailOtpSendVerificationOtpPost(t,{headers:{"x-project-key":`${this.publishableKey}`}})).data,{context:"requestEmailOTP"})}async loginWithEmailOTP(e,t){return await a.withApiError(async()=>{const i=(await this.backendApiClients.emailOTPApi.signInEmailOtpPost({signInEmailOtpPostRequest:{email:e,otp:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:n(i.user)}},{context:"loginWithEmailOTP"})}async requestPhoneOtp(e){const t={phoneNumberSendOtpPostRequest:{phoneNumber:e}};await a.withApiError(async()=>(await this.backendApiClients.smsOTPApi.phoneNumberSendOtpPost(t,{headers:{"x-project-key":`${this.publishableKey}`}})).data,{context:"requestPhoneOtp"})}async loginWithSMSOTP(e,t){return await a.withApiError(async()=>{const i=(await this.backendApiClients.smsOTPApi.phoneNumberVerifyPost({phoneNumberVerifyPostRequest:{code:t,phoneNumber:e}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:n(i.user)}},{context:"loginWithSMSOTP"})}async getSessionWithToken(e,t){return await a.withApiError(async()=>(await this.backendApiClients.authenticationV2Api.getSessionGet({disableCookieCache:t},{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"getSessionWithToken"})}};
@@ -1 +1 @@
1
- "use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.10.36-beta.1";
1
+ "use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.10.36-beta.2";
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PasskeyDetails } from 'wallets/types';
2
2
  import { PasskeyHandler as PasskeyHandler$1 } from 'core/configuration/passkey';
3
3
  import { User as User$2, ThirdPartyOAuthProvider as ThirdPartyOAuthProvider$1 } from 'types';
4
- import { UserAccountResponse } from 'types/types';
4
+ import { UserAccount as UserAccount$1 } from 'types/types';
5
5
  import { Account } from 'core/configuration/account';
6
6
  import { Hex } from 'wallets/evm/types';
7
7
 
@@ -11089,6 +11089,14 @@ interface TransactionIntentResponse {
11089
11089
  account: TransactionIntentResponseAccount | EntityIdResponse;
11090
11090
  }
11091
11091
  type PlayerMetadataValue = unknown;
11092
+ interface UserAccount {
11093
+ id: string;
11094
+ providerId: string;
11095
+ createdAt: string;
11096
+ updatedAt: string;
11097
+ accountId: string;
11098
+ scopes: string[];
11099
+ }
11092
11100
  /**
11093
11101
  * User profile information
11094
11102
  */
@@ -11298,12 +11306,14 @@ declare class AuthManager {
11298
11306
  private get backendApiClients();
11299
11307
  private get publishableKey();
11300
11308
  initOAuth(provider: OAuthProvider, redirectUrl: string): Promise<string>;
11309
+ linkOAuthToAnonymous(auth: Authentication, provider: OAuthProvider, redirectUrl: string): Promise<string>;
11301
11310
  registerGuest(): Promise<AuthResponse>;
11302
11311
  loginWithIdToken(provider: OAuthProvider, token: string): Promise<AuthResponse>;
11303
11312
  authenticateThirdParty(provider: ThirdPartyAuthProvider, token: string, tokenType: TokenType): Promise<{
11304
11313
  userId: string;
11305
11314
  }>;
11306
11315
  initSIWE(address: string, chainId?: number): Promise<SIWEInitResponse>;
11316
+ linkSIWE(address: string, auth: Authentication, chainId?: number): Promise<SIWEInitResponse>;
11307
11317
  authenticateSIWE(signature: string, message: string, walletClientType: string, connectorType: string, address: string, chainId?: number): Promise<AuthResponse>;
11308
11318
  loginEmailPassword(email: string, password: string): Promise<AuthResponse>;
11309
11319
  requestResetPassword(email: string, redirectUrl: string): Promise<void>;
@@ -11353,6 +11363,10 @@ declare class AuthApi {
11353
11363
  provider: OAuthProvider;
11354
11364
  redirectTo: string;
11355
11365
  }): Promise<string>;
11366
+ linkOAuthToAnonymous({ provider, redirectTo, }: {
11367
+ provider: OAuthProvider;
11368
+ redirectTo: string;
11369
+ }): Promise<string>;
11356
11370
  logInWithIdToken({ provider, token }: {
11357
11371
  provider: OAuthProvider;
11358
11372
  token: string;
@@ -11406,6 +11420,10 @@ declare class AuthApi {
11406
11420
  address: string;
11407
11421
  chainId?: number;
11408
11422
  }): Promise<SIWEInitResponse>;
11423
+ linkSIWE({ address, chainId }: {
11424
+ address: string;
11425
+ chainId?: number;
11426
+ }): Promise<SIWEInitResponse>;
11409
11427
  authenticateWithSIWE({ signature, message, walletClientType, connectorType, address, chainId, }: {
11410
11428
  signature: string;
11411
11429
  message: string;
@@ -11540,7 +11558,7 @@ declare class UserApi {
11540
11558
  private validateAndRefreshToken;
11541
11559
  constructor(storage: IStorage, authManager: AuthManager, validateAndRefreshToken: () => Promise<void>);
11542
11560
  get(): Promise<User$2>;
11543
- list(): Promise<UserAccountResponse[]>;
11561
+ list(): Promise<UserAccount$1[]>;
11544
11562
  }
11545
11563
 
11546
11564
  interface SDKOverrides {
@@ -12681,4 +12699,4 @@ type GrantPermissionsReturnType = {
12681
12699
  */
12682
12700
  declare const openfortEvents: TypedEventEmitter<OpenfortEventMap>;
12683
12701
 
12684
- export { AccountTypeEnum, AuthActionRequiredActions, AuthActionRequiredResponse, AuthApi, AuthInitPayload, AuthResponse, AuthType, AuthenticationError, Authorization, AuthorizationError, BasicAuthProvider, ChainTypeEnum, ConfigurationError, EmbeddedAccount, EmbeddedState, EmbeddedWalletApi, GrantPermissionsParameters, GrantPermissionsReturnType, InitializeOAuthOptions, MissingProjectEntropyError, MissingRecoveryPasswordError, NotConfiguredError, OAuthError, OAuthProvider, OPENFORT_AUTH_ERROR_CODES, OPENFORT_ERROR_CODES, OTPError, OTPRequiredError, Openfort, OpenfortAuthErrorCode, OpenfortConfiguration, OpenfortError, OpenfortEventMap, OpenfortEvents, OpenfortInternal, OpenfortSDKConfiguration, Permission, Policy, PrepareAuthorizationParams, Provider, ProxyApi, RecoveryError, RecoveryMethod, RecoveryParams, RequestError, RevokePermissionsRequestParams, SDKConfiguration, SDKOverrides, SessionError, SessionResponse, ShieldAuthOptions, ShieldConfiguration, ShieldOptions, SignAuthorizationParams, SignedAuthorization, SignedMessagePayload, Signer, SignerError, IStorage as Storage, ThirdPartyAuthConfiguration, ThirdPartyAuthProvider as ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataPayload, User, UserApi, UserError, WrongRecoveryPasswordError, openfortEvents, prepareAndSignAuthorization, serializeSignedAuthorization, signAuthorization };
12702
+ export { AccountTypeEnum, AuthActionRequiredActions, AuthActionRequiredResponse, AuthApi, AuthInitPayload, AuthResponse, AuthType, AuthenticationError, Authorization, AuthorizationError, BasicAuthProvider, ChainTypeEnum, ConfigurationError, EmbeddedAccount, EmbeddedState, EmbeddedWalletApi, GrantPermissionsParameters, GrantPermissionsReturnType, InitializeOAuthOptions, MissingProjectEntropyError, MissingRecoveryPasswordError, NotConfiguredError, OAuthError, OAuthProvider, OPENFORT_AUTH_ERROR_CODES, OPENFORT_ERROR_CODES, OTPError, OTPRequiredError, Openfort, OpenfortAuthErrorCode, OpenfortConfiguration, OpenfortError, OpenfortEventMap, OpenfortEvents, OpenfortInternal, OpenfortSDKConfiguration, Permission, Policy, PrepareAuthorizationParams, Provider, ProxyApi, RecoveryError, RecoveryMethod, RecoveryParams, RequestError, RevokePermissionsRequestParams, SDKConfiguration, SDKOverrides, SessionError, SessionResponse, ShieldAuthOptions, ShieldConfiguration, ShieldOptions, SignAuthorizationParams, SignedAuthorization, SignedMessagePayload, Signer, SignerError, IStorage as Storage, ThirdPartyAuthConfiguration, ThirdPartyAuthProvider as ThirdPartyOAuthProvider, TokenType, TransactionIntentResponse, TypedDataPayload, User, UserAccount, UserApi, UserError, WrongRecoveryPasswordError, openfortEvents, prepareAndSignAuthorization, serializeSignedAuthorization, signAuthorization };
@@ -1 +1 @@
1
- import{Authentication as t}from"../core/configuration/authentication.js";import{OPENFORT_AUTH_ERROR_CODES as e}from"../core/errors/authErrorCodes.js";import{SessionError as i,ConfigurationError as a}from"../core/errors/openfortError.js";import{OpenfortEvents as r}from"../types/types.js";class n{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(t,e,i,a,r){this.storage=t,this.authManager=e,this.validateAndRefreshToken=i,this.ensureInitialized=a,this.eventEmitter=r}async logInWithEmailPassword({email:a,password:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"email"});try{const e=await this.authManager.loginEmailPassword(a,n);return null===e?.token||(new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async signUpGuest(){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"guest"});try{const e=await this.authManager.registerGuest();return new t("session",e.token,e?.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async signUpWithEmailPassword({email:a,password:n,name:s,callbackURL:o}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"email"});try{const e=s||a,i=await this.authManager.signupEmailPassword(a,n,e,o);return i instanceof Object&&"action"in i||(new t("session",i.token,i?.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,i)),i}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async initOAuth({provider:a,redirectTo:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"oauth",provider:a});try{return await this.authManager.initOAuth(a,n)}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async logInWithIdToken({provider:a,token:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"idToken",provider:a});try{const e=await this.authManager.loginWithIdToken(a,n);return new t("session",e.token,e?.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async storeCredentials({token:e,userId:i}){if(await this.ensureInitialized(),!i)throw new a("User ID is required to store credentials");const r=encodeURIComponent(e);new t("session",r,i).save(this.storage)}async logout(){const e=await t.fromStorage(this.storage);if(e){try{"third_party"!==e.type&&await this.authManager.logout(e)}catch(t){}t.clear(this.storage),this.eventEmitter.emit(r.ON_LOGOUT)}}async requestEmailOtp({email:a}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_OTP_REQUEST,{method:"email"});try{await this.authManager.requestEmailOTP(a)}catch(t){throw this.eventEmitter.emit(r.ON_OTP_FAILURE,t),t}}async logInWithEmailOtp({email:a,otp:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"email"});try{const e=await this.authManager.loginWithEmailOTP(a,n);return null===e?.token||(new t("session",e.token,e?.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async requestPhoneOtp({phoneNumber:a}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_OTP_REQUEST,{method:"phone",provider:"phone"});try{await this.authManager.requestPhoneOtp(a)}catch(t){throw this.eventEmitter.emit(r.ON_OTP_FAILURE,t),t}}async logInWithPhoneOtp({phoneNumber:a,otp:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"phone"});try{const e=await this.authManager.loginWithSMSOTP(a,n);return null===e?.token||(new t("session",e.token,e?.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async requestResetPassword({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestResetPassword(t,e)}async resetPassword({password:t,token:e}){await this.ensureInitialized(),await this.authManager.resetPassword(t,e)}async requestEmailVerification({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestEmailVerification(t,e)}async verifyEmail({token:t,callbackURL:e}){await this.ensureInitialized(),await this.authManager.verifyEmail(t,e)}async initLinkOAuth({provider:a,options:n}){await this.validateAndRefreshToken();const s=await t.fromStorage(this.storage);if(!s)throw new i(e.NOT_LOGGED_IN,"No authentication found");return this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"oauth",provider:a}),await this.authManager.linkOAuth(s,a,n)}async unlinkOAuth({provider:a}){await this.validateAndRefreshToken();const r=await t.fromStorage(this.storage);if(!r)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkOAuth(a,r)}async initSIWE({address:t,chainId:e}){return await this.ensureInitialized(),await this.authManager.initSIWE(t,e)}async authenticateWithSIWE({signature:a,message:n,walletClientType:s,connectorType:o,address:h,chainId:w}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"siwe"});try{const e=await this.authManager.authenticateSIWE(a,n,s,o,h,w);return new t("session",e.token,e?.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async linkWallet({signature:a,message:r,walletClientType:n,connectorType:s,address:o,chainId:h}){await this.validateAndRefreshToken();const w=await t.fromStorage(this.storage);if(!w)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkWallet(a,r,n,s,o,h,w)}async unlinkWallet({address:a,chainId:r}){await this.validateAndRefreshToken();const n=await t.fromStorage(this.storage);if(!n)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkWallet(a,r,n)}async unlinkEmail(){await this.validateAndRefreshToken();const a=await t.fromStorage(this.storage);if(!a)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkEmail(a)}async linkEmailPassword({name:a,email:r,password:n}){await this.validateAndRefreshToken();const s=await t.fromStorage(this.storage);if(!s)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkEmail(a,r,n,s)}async unlinkEmailPassword(){await this.validateAndRefreshToken();const a=await t.fromStorage(this.storage);if(!a)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkEmail(a)}}export{n as AuthApi};
1
+ import{Authentication as t}from"../core/configuration/authentication.js";import{OPENFORT_AUTH_ERROR_CODES as e}from"../core/errors/authErrorCodes.js";import{SessionError as i,ConfigurationError as a}from"../core/errors/openfortError.js";import{OpenfortEvents as r}from"../types/types.js";class n{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(t,e,i,a,r){this.storage=t,this.authManager=e,this.validateAndRefreshToken=i,this.ensureInitialized=a,this.eventEmitter=r}async logInWithEmailPassword({email:a,password:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"email"});try{const e=await this.authManager.loginEmailPassword(a,n);return null===e?.token||(new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async signUpGuest(){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"guest"});try{const e=await this.authManager.registerGuest();return new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async signUpWithEmailPassword({email:a,password:n,name:s,callbackURL:o}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"email"});try{const e=s||a,i=await this.authManager.signupEmailPassword(a,n,e,o);return i instanceof Object&&"action"in i||(new t("session",i.token,i.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,i)),i}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async initOAuth({provider:a,redirectTo:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"oauth",provider:a});try{return await this.authManager.initOAuth(a,n)}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async linkOAuthToAnonymous({provider:e,redirectTo:i}){await this.ensureInitialized();const a=await t.fromStorage(this.storage);if(!a)throw new Error("Must be signed in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"oauth",provider:e});try{return await this.authManager.linkOAuthToAnonymous(a,e,i)}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async logInWithIdToken({provider:a,token:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"idToken",provider:a});try{const e=await this.authManager.loginWithIdToken(a,n);return new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async storeCredentials({token:e,userId:i}){if(await this.ensureInitialized(),!i)throw new a("User ID is required to store credentials");const r=encodeURIComponent(e);new t("session",r,i).save(this.storage)}async logout(){const e=await t.fromStorage(this.storage);if(e){try{"third_party"!==e.type&&await this.authManager.logout(e)}catch(t){}t.clear(this.storage),this.eventEmitter.emit(r.ON_LOGOUT)}}async requestEmailOtp({email:a}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_OTP_REQUEST,{method:"email"});try{await this.authManager.requestEmailOTP(a)}catch(t){throw this.eventEmitter.emit(r.ON_OTP_FAILURE,t),t}}async logInWithEmailOtp({email:a,otp:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"email"});try{const e=await this.authManager.loginWithEmailOTP(a,n);return null===e?.token||(new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async requestPhoneOtp({phoneNumber:a}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_OTP_REQUEST,{method:"phone",provider:"phone"});try{await this.authManager.requestPhoneOtp(a)}catch(t){throw this.eventEmitter.emit(r.ON_OTP_FAILURE,t),t}}async logInWithPhoneOtp({phoneNumber:a,otp:n}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"phone"});try{const e=await this.authManager.loginWithSMSOTP(a,n);return null===e?.token||(new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e)),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async requestResetPassword({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestResetPassword(t,e)}async resetPassword({password:t,token:e}){await this.ensureInitialized(),await this.authManager.resetPassword(t,e)}async requestEmailVerification({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestEmailVerification(t,e)}async verifyEmail({token:t,callbackURL:e}){await this.ensureInitialized(),await this.authManager.verifyEmail(t,e)}async initLinkOAuth({provider:a,options:n}){await this.validateAndRefreshToken();const s=await t.fromStorage(this.storage);if(!s)throw new i(e.NOT_LOGGED_IN,"No authentication found");return this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"oauth",provider:a}),await this.authManager.linkOAuth(s,a,n)}async unlinkOAuth({provider:a}){await this.validateAndRefreshToken();const r=await t.fromStorage(this.storage);if(!r)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkOAuth(a,r)}async initSIWE({address:t,chainId:e}){return await this.ensureInitialized(),await this.authManager.initSIWE(t,e)}async linkSIWE({address:a,chainId:r}){await this.ensureInitialized();const n=await t.fromStorage(this.storage);if(!n)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkSIWE(a,n,r)}async authenticateWithSIWE({signature:a,message:n,walletClientType:s,connectorType:o,address:h,chainId:w}){await this.ensureInitialized();if(await t.fromStorage(this.storage))throw new i(e.ALREADY_LOGGED_IN,"Already logged in");this.eventEmitter.emit(r.ON_AUTH_INIT,{method:"siwe"});try{const e=await this.authManager.authenticateSIWE(a,n,s,o,h,w);return new t("session",e.token,e.user.id).save(this.storage),this.eventEmitter.emit(r.ON_AUTH_SUCCESS,e),e}catch(t){throw this.eventEmitter.emit(r.ON_AUTH_FAILURE,t),t}}async linkWallet({signature:a,message:r,walletClientType:n,connectorType:s,address:o,chainId:h}){await this.validateAndRefreshToken();const w=await t.fromStorage(this.storage);if(!w)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkWallet(a,r,n,s,o,h,w)}async unlinkWallet({address:a,chainId:r}){await this.validateAndRefreshToken();const n=await t.fromStorage(this.storage);if(!n)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkWallet(a,r,n)}async unlinkEmail(){await this.validateAndRefreshToken();const a=await t.fromStorage(this.storage);if(!a)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkEmail(a)}async linkEmailPassword({name:a,email:r,password:n}){await this.validateAndRefreshToken();const s=await t.fromStorage(this.storage);if(!s)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.linkEmail(a,r,n,s)}async unlinkEmailPassword(){await this.validateAndRefreshToken();const a=await t.fromStorage(this.storage);if(!a)throw new i(e.NOT_LOGGED_IN,"No authentication found");return await this.authManager.unlinkEmail(a)}}export{n as AuthApi};
@@ -1 +1 @@
1
- import{debugLog as e}from"../utils/debug.js";import{OPENFORT_AUTH_ERROR_CODES as t}from"../core/errors/authErrorCodes.js";import{ConfigurationError as i,OpenfortError as a}from"../core/errors/openfortError.js";import{withApiError as n}from"../core/errors/withApiError.js";import{AuthActionRequiredActions as s}from"../types/types.js";function r(e){if(!e)throw new a(t.INTERNAL_ERROR,"User data is missing");return{id:e.id||"",email:e.email,name:e.name??void 0,image:e.image??void 0,emailVerified:e.emailVerified,isAnonymous:e.isAnonymous,createdAt:e.createdAt,updatedAt:e.updatedAt}}function o(e){if(e)return{id:e.id,token:e.token,userId:e.userId,expiresAt:e.expiresAt,createdAt:e.createdAt,updatedAt:e.updatedAt}}class c{backendApiClientsInstance;publishableKeyInstance;setBackendApiClients(e,t){this.backendApiClientsInstance=e,this.publishableKeyInstance=t}get backendApiClients(){if(!this.backendApiClientsInstance)throw new i("Backend API clients not initialized");return this.backendApiClientsInstance}get publishableKey(){if(!this.publishableKeyInstance)throw new i("Publishable key not initialized");return this.publishableKeyInstance}async initOAuth(e,t){return await n(async()=>(await this.backendApiClients.authenticationV2Api.socialSignIn({socialSignInRequest:{provider:e,callbackURL:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data.url||"",{context:"initOAuth"})}async registerGuest(){return n(async()=>{const e=await this.backendApiClients.anonymousApi.signInAnonymousPost({headers:{"x-project-key":`${this.publishableKey}`}});return{token:e.data.token,user:r(e.data.user)}},{context:"registerGuest"})}async loginWithIdToken(e,t){const i={socialSignInRequest:{provider:e,token:t}};return await n(async()=>{const e=await this.backendApiClients.authenticationV2Api.socialSignIn(i);return{token:e.data.token,user:r(e.data.user)}},{context:"loginWithIdToken"})}async authenticateThirdParty(e,t,i){const a={thirdPartyOAuthRequest:{provider:e,token:t,tokenType:i}};return n(async()=>({userId:(await this.backendApiClients.authenticationApi.thirdParty(a,{headers:{"x-project-key":`${this.publishableKey}`}})).data.id}),{context:"authenticateThirdParty"})}async initSIWE(e,t){const i={siweNoncePostRequest:{walletAddress:e,chainId:t||1}};return{address:e,nonce:(await n(async()=>this.backendApiClients.siweApi.siweNoncePost(i,{headers:{"x-project-key":`${this.publishableKey}`}}),{context:"initSIWE"})).data.nonce}}async authenticateSIWE(e,t,i,a,s,o){const c={siweVerifyPostRequest:{signature:e,walletAddress:s,chainId:o||1,message:t,walletClientType:i,connectorType:a}};return n(async()=>{const e=await this.backendApiClients.siweApi.siweVerifyPost(c,{headers:{"x-project-key":`${this.publishableKey}`}}),t=e.data.user;return{token:e.data.token,user:r(t)}},{context:"authenticateSIWE"})}async loginEmailPassword(e,t){return n(async()=>{const i=(await this.backendApiClients.authenticationV2Api.signInEmailPost({signInEmailPostRequest:{email:e,password:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:r(i.user)}},{context:"loginEmailPassword"})}async requestResetPassword(e,t){await n(async()=>{await this.backendApiClients.authenticationV2Api.forgetPasswordPost({forgetPasswordPostRequest:{email:e,redirectTo:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"requestResetPassword"})}async resetPassword(e,t){return n(async()=>{await this.backendApiClients.authenticationV2Api.resetPasswordPost({resetPasswordPostRequest:{newPassword:e,token:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"resetPassword"})}async requestEmailVerification(e,t){await n(async()=>{await this.backendApiClients.authenticationV2Api.sendVerificationEmailPost({sendVerificationEmailPostRequest:{email:e,callbackURL:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"requestEmailVerification"})}async verifyEmail(e,t){return n(async()=>{await this.backendApiClients.authenticationV2Api.verifyEmailGet({token:e,callbackURL:t})},{context:"verifyEmail"})}async signupEmailPassword(e,t,i,a){return n(async()=>{const n=(await this.backendApiClients.authenticationV2Api.signUpEmailPost({signUpEmailPostRequest:{email:e,password:t,name:i,callbackURL:a}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return n.token?{token:n.token,user:r(n.user)}:{action:s.ACTION_VERIFY_EMAIL}},{context:"signupEmailPassword"})}async validateCredentials(t,i){e("Validating credentials with token:",t.token);const a=await this.getSessionWithToken(t,i);return{token:a.session.token,user:r(a.user),session:o(a.session)}}async logout(e){return n(async()=>{await this.backendApiClients.authenticationV2Api.signOutPost(void 0,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})},{context:"logout"})}async getUser(e){return n(async()=>r((await this.backendApiClients.userApi.meV2({headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data),{context:"getUser"})}async listAccounts(e){return n(async()=>(await this.backendApiClients.authenticationV2Api.listAccountsGet({headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"listAccounts"})}async linkOAuth(e,t,i){const a=i?.skipBrowserRedirect??!1,s={linkSocialPostRequest:{provider:t,callbackURL:i?.redirectTo,scopes:i?.scopes?.split(" "),disableRedirect:a}},r=await n(async()=>this.backendApiClients.authenticationV2Api.linkSocialPost(s,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}}),{context:"linkOAuth"});return"undefined"!=typeof window&&!a&&r.data.url&&window.location.assign(r.data.url),r.data.url||""}async unlinkOAuth(e,t){const i={unlinkAccountPostRequest:{providerId:e}};return n(async()=>(await this.backendApiClients.authenticationV2Api.unlinkAccountPost(i,{headers:t.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":t.token,"x-auth-provider":t.thirdPartyProvider,"x-token-type":t.thirdPartyTokenType}:{authorization:`Bearer ${t.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"unlinkOAuth"})}async linkEmail(e,t,i,a){const s={signUpEmailPostRequest:{name:e,email:t,password:i}};return n(async()=>{const e=await this.backendApiClients.authenticationV2Api.signUpEmailPost(s,{headers:a.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":a.token,"x-auth-provider":a.thirdPartyProvider,"x-token-type":a.thirdPartyTokenType}:{authorization:`Bearer ${a.token}`,"x-project-key":`${this.publishableKey}`}});return{token:e.data.token,user:r(e.data.user)}},{context:"linkEmail"})}async unlinkEmail(e){const t={unlinkAccountPostRequest:{providerId:"credential"}};return n(async()=>(await this.backendApiClients.authenticationV2Api.unlinkAccountPost(t,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data.status,{context:"unlinkEmail"})}async unlinkWallet(e,t,i){const a={linkSiweUnlinkPostRequest:{walletAddress:e,chaindId:t}};return n(async()=>(await this.backendApiClients.siweApi.linkSiweUnlinkPost(a,{headers:i.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}:{authorization:`Bearer ${i.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"unlinkWallet"})}async linkWallet(e,t,i,a,s,r,o){const c={siweVerifyPostRequest:{signature:e,message:t,walletAddress:s,chainId:r,walletClientType:i,connectorType:a}};return n(async()=>(await this.backendApiClients.siweApi.linkSiweVerifyPost(c,{headers:o.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":o.token,"x-auth-provider":o.thirdPartyProvider,"x-token-type":o.thirdPartyTokenType}:{authorization:`Bearer ${o.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"linkWallet"})}async requestEmailOTP(e){const t={emailOtpSendVerificationOtpPostRequest:{email:e,type:"sign-in"}};await n(async()=>(await this.backendApiClients.emailOTPApi.emailOtpSendVerificationOtpPost(t,{headers:{"x-project-key":`${this.publishableKey}`}})).data,{context:"requestEmailOTP"})}async loginWithEmailOTP(e,t){return await n(async()=>{const i=(await this.backendApiClients.emailOTPApi.signInEmailOtpPost({signInEmailOtpPostRequest:{email:e,otp:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:r(i.user)}},{context:"loginWithEmailOTP"})}async requestPhoneOtp(e){const t={phoneNumberSendOtpPostRequest:{phoneNumber:e}};await n(async()=>(await this.backendApiClients.smsOTPApi.phoneNumberSendOtpPost(t,{headers:{"x-project-key":`${this.publishableKey}`}})).data,{context:"requestPhoneOtp"})}async loginWithSMSOTP(e,t){return await n(async()=>{const i=(await this.backendApiClients.smsOTPApi.phoneNumberVerifyPost({phoneNumberVerifyPostRequest:{code:t,phoneNumber:e}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:r(i.user)}},{context:"loginWithSMSOTP"})}async getSessionWithToken(e,t){return await n(async()=>(await this.backendApiClients.authenticationV2Api.getSessionGet({disableCookieCache:t},{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"getSessionWithToken"})}}export{c as AuthManager};
1
+ import{debugLog as e}from"../utils/debug.js";import{OPENFORT_AUTH_ERROR_CODES as t}from"../core/errors/authErrorCodes.js";import{ConfigurationError as i,OpenfortError as a}from"../core/errors/openfortError.js";import{withApiError as n}from"../core/errors/withApiError.js";import{AuthActionRequiredActions as s}from"../types/types.js";function r(e){if(!e)throw new a(t.INTERNAL_ERROR,"User data is missing");return{id:e.id||"",email:e.email,name:e.name??void 0,image:e.image??void 0,emailVerified:e.emailVerified,isAnonymous:e.isAnonymous,createdAt:e.createdAt,updatedAt:e.updatedAt}}function o(e){if(e)return{id:e.id,token:e.token,userId:e.userId,expiresAt:e.expiresAt,createdAt:e.createdAt,updatedAt:e.updatedAt}}class c{backendApiClientsInstance;publishableKeyInstance;setBackendApiClients(e,t){this.backendApiClientsInstance=e,this.publishableKeyInstance=t}get backendApiClients(){if(!this.backendApiClientsInstance)throw new i("Backend API clients not initialized");return this.backendApiClientsInstance}get publishableKey(){if(!this.publishableKeyInstance)throw new i("Publishable key not initialized");return this.publishableKeyInstance}async initOAuth(e,t){return await n(async()=>(await this.backendApiClients.authenticationV2Api.socialSignIn({socialSignInRequest:{provider:e,callbackURL:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data.url||"",{context:"initOAuth"})}async linkOAuthToAnonymous(e,t,i){return await n(async()=>(await this.backendApiClients.authenticationV2Api.socialSignIn({socialSignInRequest:{provider:t,callbackURL:i}},{headers:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data.url||"",{context:"initOAuth"})}async registerGuest(){return n(async()=>{const e=await this.backendApiClients.anonymousApi.signInAnonymousPost({headers:{"x-project-key":`${this.publishableKey}`}});return{token:e.data.token,user:r(e.data.user)}},{context:"registerGuest"})}async loginWithIdToken(e,t){const i={socialSignInRequest:{provider:e,token:t}};return await n(async()=>{const e=await this.backendApiClients.authenticationV2Api.socialSignIn(i);return{token:e.data.token,user:r(e.data.user)}},{context:"loginWithIdToken"})}async authenticateThirdParty(e,t,i){const a={thirdPartyOAuthRequest:{provider:e,token:t,tokenType:i}};return n(async()=>({userId:(await this.backendApiClients.authenticationApi.thirdParty(a,{headers:{"x-project-key":`${this.publishableKey}`}})).data.id}),{context:"authenticateThirdParty"})}async initSIWE(e,t){const i={siweNoncePostRequest:{walletAddress:e,chainId:t||1}};return{address:e,nonce:(await n(async()=>this.backendApiClients.siweApi.siweNoncePost(i,{headers:{"x-project-key":`${this.publishableKey}`}}),{context:"initSIWE"})).data.nonce}}async linkSIWE(e,t,i){const a={siweNoncePostRequest:{walletAddress:e,chainId:i||1}};return{address:e,nonce:(await n(async()=>this.backendApiClients.siweApi.linkSiweNoncePost(a,{headers:{authorization:`Bearer ${t.token}`,"x-project-key":`${this.publishableKey}`}}),{context:"linkSIWE"})).data.nonce}}async authenticateSIWE(e,t,i,a,s,o){const c={siweVerifyPostRequest:{signature:e,walletAddress:s,chainId:o||1,message:t,walletClientType:i,connectorType:a}};return n(async()=>{const e=await this.backendApiClients.siweApi.siweVerifyPost(c,{headers:{"x-project-key":`${this.publishableKey}`}}),t=e.data.user;return{token:e.data.token,user:r(t)}},{context:"authenticateSIWE"})}async loginEmailPassword(e,t){return n(async()=>{const i=(await this.backendApiClients.authenticationV2Api.signInEmailPost({signInEmailPostRequest:{email:e,password:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:r(i.user)}},{context:"loginEmailPassword"})}async requestResetPassword(e,t){await n(async()=>{await this.backendApiClients.authenticationV2Api.requestPasswordResetPost({forgetPasswordPostRequest:{email:e,redirectTo:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"requestResetPassword"})}async resetPassword(e,t){return n(async()=>{await this.backendApiClients.authenticationV2Api.resetPasswordPost({resetPasswordPostRequest:{newPassword:e,token:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"resetPassword"})}async requestEmailVerification(e,t){await n(async()=>{await this.backendApiClients.authenticationV2Api.sendVerificationEmailPost({sendVerificationEmailPostRequest:{email:e,callbackURL:t}},{headers:{"x-project-key":`${this.publishableKey}`}})},{context:"requestEmailVerification"})}async verifyEmail(e,t){return n(async()=>{await this.backendApiClients.authenticationV2Api.verifyEmailGet({token:e,callbackURL:t})},{context:"verifyEmail"})}async signupEmailPassword(e,t,i,a){return n(async()=>{const n=(await this.backendApiClients.authenticationV2Api.signUpEmailPost({signUpEmailPostRequest:{email:e,password:t,name:i,callbackURL:a}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return n.token?{token:n.token,user:r(n.user)}:{action:s.ACTION_VERIFY_EMAIL}},{context:"signupEmailPassword"})}async validateCredentials(t,i){e("Validating credentials with token:",t.token);const a=await this.getSessionWithToken(t,i);return{token:a.session.token,user:r(a.user),session:o(a.session)}}async logout(e){return n(async()=>{await this.backendApiClients.authenticationV2Api.signOutPost(void 0,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})},{context:"logout"})}async getUser(e){return n(async()=>r((await this.backendApiClients.userApi.meV2({headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data),{context:"getUser"})}async listAccounts(e){return n(async()=>(await this.backendApiClients.authenticationV2Api.listAccountsGet({headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"listAccounts"})}async linkOAuth(e,t,i){const a=i?.skipBrowserRedirect??!1,s={linkSocialPostRequest:{provider:t,callbackURL:i?.redirectTo,scopes:i?.scopes?.split(" "),disableRedirect:a}},r=await n(async()=>this.backendApiClients.authenticationV2Api.linkSocialPost(s,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}}),{context:"linkOAuth"});return"undefined"!=typeof window&&!a&&r.data.url&&window.location.assign(r.data.url),r.data.url||""}async unlinkOAuth(e,t){const i={unlinkAccountPostRequest:{providerId:e}};return n(async()=>(await this.backendApiClients.authenticationV2Api.unlinkAccountPost(i,{headers:t.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":t.token,"x-auth-provider":t.thirdPartyProvider,"x-token-type":t.thirdPartyTokenType}:{authorization:`Bearer ${t.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"unlinkOAuth"})}async linkEmail(e,t,i,a){const s={signUpEmailPostRequest:{name:e,email:t,password:i}};return n(async()=>{const e=await this.backendApiClients.authenticationV2Api.signUpEmailPost(s,{headers:a.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":a.token,"x-auth-provider":a.thirdPartyProvider,"x-token-type":a.thirdPartyTokenType}:{authorization:`Bearer ${a.token}`,"x-project-key":`${this.publishableKey}`}});return{token:e.data.token,user:r(e.data.user)}},{context:"linkEmail"})}async unlinkEmail(e){const t={unlinkAccountPostRequest:{providerId:"credential"}};return n(async()=>(await this.backendApiClients.authenticationV2Api.unlinkAccountPost(t,{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data.status,{context:"unlinkEmail"})}async unlinkWallet(e,t,i){const a={linkSiweUnlinkPostRequest:{walletAddress:e,chaindId:t}};return n(async()=>(await this.backendApiClients.siweApi.linkSiweUnlinkPost(a,{headers:i.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":i.token,"x-auth-provider":i.thirdPartyProvider,"x-token-type":i.thirdPartyTokenType}:{authorization:`Bearer ${i.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"unlinkWallet"})}async linkWallet(e,t,i,a,s,r,o){const c={siweVerifyPostRequest:{signature:e,message:t,walletAddress:s,chainId:r,walletClientType:i,connectorType:a}};return n(async()=>(await this.backendApiClients.siweApi.linkSiweVerifyPost(c,{headers:o.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":o.token,"x-auth-provider":o.thirdPartyProvider,"x-token-type":o.thirdPartyTokenType}:{authorization:`Bearer ${o.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"linkWallet"})}async requestEmailOTP(e){const t={emailOtpSendVerificationOtpPostRequest:{email:e,type:"sign-in"}};await n(async()=>(await this.backendApiClients.emailOTPApi.emailOtpSendVerificationOtpPost(t,{headers:{"x-project-key":`${this.publishableKey}`}})).data,{context:"requestEmailOTP"})}async loginWithEmailOTP(e,t){return await n(async()=>{const i=(await this.backendApiClients.emailOTPApi.signInEmailOtpPost({signInEmailOtpPostRequest:{email:e,otp:t}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:r(i.user)}},{context:"loginWithEmailOTP"})}async requestPhoneOtp(e){const t={phoneNumberSendOtpPostRequest:{phoneNumber:e}};await n(async()=>(await this.backendApiClients.smsOTPApi.phoneNumberSendOtpPost(t,{headers:{"x-project-key":`${this.publishableKey}`}})).data,{context:"requestPhoneOtp"})}async loginWithSMSOTP(e,t){return await n(async()=>{const i=(await this.backendApiClients.smsOTPApi.phoneNumberVerifyPost({phoneNumberVerifyPostRequest:{code:t,phoneNumber:e}},{headers:{"x-project-key":`${this.publishableKey}`}})).data;return{token:i.token,user:r(i.user)}},{context:"loginWithSMSOTP"})}async getSessionWithToken(e,t){return await n(async()=>(await this.backendApiClients.authenticationV2Api.getSessionGet({disableCookieCache:t},{headers:e.thirdPartyProvider?{authorization:`Bearer ${this.publishableKey}`,"x-player-token":e.token,"x-auth-provider":e.thirdPartyProvider,"x-token-type":e.thirdPartyTokenType}:{authorization:`Bearer ${e.token}`,"x-project-key":`${this.publishableKey}`}})).data,{context:"getSessionWithToken"})}}export{c as AuthManager};
@@ -1 +1 @@
1
- const o="0.10.36-beta.1",t="@openfort/openfort-js";export{t as PACKAGE,o as VERSION};
1
+ const o="0.10.36-beta.2",t="@openfort/openfort-js";export{t as PACKAGE,o as VERSION};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfort/openfort-js",
3
- "version": "0.10.36-beta.1",
3
+ "version": "0.10.36-beta.2",
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",