@openfort/openfort-js 0.10.2 → 0.10.3
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/auth.js +1 -1
- package/dist/cjs/sdk/src/core/config/config.js +1 -1
- package/dist/cjs/sdk/src/core/openfortInternal.js +1 -1
- package/dist/cjs/sdk/src/version.js +1 -1
- package/dist/index.d.ts +8 -16
- package/dist/sdk/src/api/auth.js +1 -1
- package/dist/sdk/src/core/config/config.js +1 -1
- package/dist/sdk/src/core/openfortInternal.js +1 -1
- package/dist/sdk/src/version.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("../
|
|
1
|
+
"use strict";var t=require("../core/configuration/authentication.js"),e=require("../core/errors/openfortError.js"),a=require("../types/types.js");exports.AuthApi=class{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(t,e,a,i,r){this.storage=t,this.authManager=e,this.validateAndRefreshToken=a,this.ensureInitialized=i,this.eventEmitter=r}async logInWithEmailPassword({email:a,password:i,ecosystemGame:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new e.OpenfortError("Already logged in",e.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);const n=await this.authManager.loginEmailPassword(a,i,r);return"action"in n||new t.Authentication("jwt",n.token,n.player.id,n.refreshToken).save(this.storage),n}async signUpGuest(){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new e.OpenfortError("Already logged in",e.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);const a=await this.authManager.registerGuest();return new t.Authentication("jwt",a.token,a.player.id,a.refreshToken).save(this.storage),a}async signUpWithEmailPassword({email:a,password:i,options:r,ecosystemGame:n}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new e.OpenfortError("Already logged in",e.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);const s=await this.authManager.signupEmailPassword(a,i,r?.data.name,n);return"action"in s||new t.Authentication("jwt",s.token,s.player.id,s.refreshToken).save(this.storage),s}async linkEmailPassword({email:t,password:e,authToken:a,ecosystemGame:i}){return await this.validateAndRefreshToken(),await this.authManager.linkEmail(t,e,a,i)}async unlinkEmailPassword({email:t,authToken:e}){return await this.validateAndRefreshToken(),await this.authManager.unlinkEmail(t,e)}async requestEmailVerification({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestEmailVerification(t,e)}async resetPassword({email:t,password:e,state:a}){await this.ensureInitialized(),await this.authManager.resetPassword(t,e,a)}async requestResetPassword({email:t,redirectUrl:e}){await this.ensureInitialized(),await this.authManager.requestResetPassword(t,e)}async verifyEmail({email:t,state:e}){await this.ensureInitialized(),await this.authManager.verifyEmail(t,e)}async initOAuth({provider:a,options:i,ecosystemGame:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new e.OpenfortError("Already logged in",e.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);return await this.authManager.initOAuth(a,i,r)}async initLinkOAuth({provider:a,options:i,ecosystemGame:r}){await this.validateAndRefreshToken();const n=await t.Authentication.fromStorage(this.storage);if(!n)throw new e.OpenfortError("No authentication found",e.OpenfortErrorType.NOT_LOGGED_IN_ERROR);return await this.authManager.linkOAuth(n,a,i,r)}async unlinkOAuth({provider:t,authToken:e}){return await this.validateAndRefreshToken(),await this.authManager.unlinkOAuth(t,e)}async poolOAuth(e){await this.ensureInitialized();const a=await this.authManager.poolOAuth(e);return new t.Authentication("jwt",a.token,a.player.id,a.refreshToken).save(this.storage),a}async loginWithIdToken({provider:a,token:i,ecosystemGame:r}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new e.OpenfortError("Already logged in",e.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);const n=await this.authManager.loginWithIdToken(a,i,r);return new t.Authentication("jwt",n.token,n.player.id,n.refreshToken).save(this.storage),n}async initSIWE({address:t,ecosystemGame:e}){return await this.ensureInitialized(),await this.authManager.initSIWE(t,e)}async authenticateWithSIWE({signature:a,message:i,walletClientType:r,connectorType:n}){await this.ensureInitialized();if(await t.Authentication.fromStorage(this.storage))throw new e.OpenfortError("Already logged in",e.OpenfortErrorType.ALREADY_LOGGED_IN_ERROR);const s=await this.authManager.authenticateSIWE(a,i,r,n);return new t.Authentication("jwt",s.token,s.player.id,s.refreshToken).save(this.storage),s}async linkWallet({signature:t,message:e,walletClientType:a,connectorType:i,authToken:r}){return await this.validateAndRefreshToken(),await this.authManager.linkWallet(t,e,a,i,r)}async unlinkWallet({address:t,authToken:e}){return await this.validateAndRefreshToken(),await this.authManager.unlinkWallet(t,e)}async storeCredentials(a){if(await this.ensureInitialized(),!a.player)throw new e.OpenfortError("Player ID is required to store credentials",e.OpenfortErrorType.INVALID_CONFIGURATION);new t.Authentication("jwt",a.accessToken,a.player,a.refreshToken).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.token,e?.refreshToken)}catch(t){}t.Authentication.clear(this.storage),this.eventEmitter.emit(a.OpenfortEvents.LOGGED_OUT)}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var i=require("../../utils/crypto.js");class t{baseConfiguration;shieldConfiguration;thirdPartyAuth;shieldUrl;iframeUrl;backendUrl;storage;static instance=null;constructor({baseConfiguration:e,shieldConfiguration:s,overrides:r,thirdPartyAuth:o}){this.shieldConfiguration=s,this.baseConfiguration=e,this.backendUrl=r?.backendUrl||"https://api.openfort.io",this.iframeUrl=r?.iframeUrl||"https://embed.openfort.io",this.iframeUrl=`${this.iframeUrl}/iframe/${this.baseConfiguration.publishableKey}`,s?.debug&&(this.iframeUrl=`${this.iframeUrl}?debug=true`),this.shieldUrl=r?.shieldUrl||"https://shield.openfort.io",this.storage=r?.storage,this.thirdPartyAuth=o,r?.crypto?.digest&&i.setCryptoDigestOverride(r.crypto.digest),t.instance=this}static getInstance(){return t.instance}}exports.OpenfortConfiguration=class{publishableKey;constructor(i){this.publishableKey=i.publishableKey}},exports.SDKConfiguration=t,exports.ShieldConfiguration=class{shieldPublishableKey;shieldEncryptionKey;debug=!1;constructor(i){this.shieldPublishableKey=i.shieldPublishableKey,this.shieldEncryptionKey=i.shieldEncryptionKey,this.debug=i.shieldDebug||!1}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./errors/openfortError.js"),t=require("../types/types.js");require("../storage/istorage.js"),require("../wallets/messaging/browserMessenger/backwardCompatibility.js");var r=require("../utils/debug.js"),n=require("./configuration/authentication.js");require("../wallets/types.js"),require("./errors/sentry.js");var i=require("./config/config.js");require("jose"),require("../wallets/evm/types.js"),require("../wallets/evm/JsonRpcError.js"),require("eventemitter3"),require("../wallets/evm/provider/eip6963.js");exports.OpenfortInternal=class{storage;authManager;eventEmitter;constructor(e,t,r){this.storage=e,this.authManager=t,this.eventEmitter=r}async
|
|
1
|
+
"use strict";var e=require("./errors/openfortError.js"),t=require("../types/types.js");require("../storage/istorage.js"),require("../wallets/messaging/browserMessenger/backwardCompatibility.js");var r=require("../utils/debug.js"),n=require("./configuration/authentication.js");require("../wallets/types.js"),require("./errors/sentry.js");var i=require("./config/config.js");require("jose"),require("../wallets/evm/types.js"),require("../wallets/evm/JsonRpcError.js"),require("eventemitter3"),require("../wallets/evm/provider/eip6963.js");exports.OpenfortInternal=class{storage;authManager;eventEmitter;constructor(e,t,r){this.storage=e,this.authManager=t,this.eventEmitter=r}async getThirdPartyAuthToken(){const r=i.SDKConfiguration.getInstance();if(!r?.thirdPartyAuth)throw new e.OpenfortError("No third party configuration found",e.OpenfortErrorType.INTERNAL_ERROR);const{getAccessToken:o,provider:a}=r.thirdPartyAuth;if(!o||!a)throw new e.OpenfortError("Third party is not configured. Please configure getAccessToken and thirdPartyAuthProvider in your Openfort instance",e.OpenfortErrorType.INVALID_CONFIGURATION);const s=await o();if(!s)throw new e.OpenfortError("Could not get access token",e.OpenfortErrorType.AUTHENTICATION_ERROR);let h=(await n.Authentication.fromStorage(this.storage))?.player;if(!h){const e=await this.authManager.authenticateThirdParty(a,s,t.TokenType.ID_TOKEN);h=e?.id}return new n.Authentication("third_party",s,h,null,a,t.TokenType.ID_TOKEN).save(this.storage),this.eventEmitter.emit(t.OpenfortEvents.TOKEN_REFRESHED),s}async getAccessToken(){if(i.SDKConfiguration.getInstance()?.thirdPartyAuth)return this.getThirdPartyAuthToken();return(await n.Authentication.fromStorage(this.storage))?.token??null}async validateAndRefreshToken(o){if(i.SDKConfiguration.getInstance()?.thirdPartyAuth)return void await this.getThirdPartyAuthToken();const a=await n.Authentication.fromStorage(this.storage);if(!a)throw new e.OpenfortError("Must be logged in to validate and refresh token",e.OpenfortErrorType.NOT_LOGGED_IN_ERROR);let s;r.debugLog("validating credentials...");try{s=await this.authManager.validateCredentials(a,o)}catch(e){throw n.Authentication.clear(this.storage),this.eventEmitter.emit(t.OpenfortEvents.LOGGED_OUT),e}if(!s.player)throw new e.OpenfortError("No user found in credentials",e.OpenfortErrorType.INTERNAL_ERROR);s.accessToken!==a.token&&(r.debugLog("tokens refreshed"),new n.Authentication("jwt",s.accessToken,s.player,s.refreshToken).save(this.storage),this.eventEmitter.emit(t.OpenfortEvents.TOKEN_REFRESHED))}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.10.
|
|
1
|
+
"use strict";exports.PACKAGE="@openfort/openfort-js",exports.VERSION="0.10.3";
|
package/dist/index.d.ts
CHANGED
|
@@ -448,8 +448,10 @@ interface SDKOverrides {
|
|
|
448
448
|
digest?: (algorithm: string, data: BufferSource) => Promise<ArrayBuffer>;
|
|
449
449
|
};
|
|
450
450
|
storage?: IStorage;
|
|
451
|
-
|
|
452
|
-
|
|
451
|
+
}
|
|
452
|
+
interface ThirdPartyAuthConfiguration {
|
|
453
|
+
provider: ThirdPartyOAuthProvider$1;
|
|
454
|
+
getAccessToken: () => Promise<string | null>;
|
|
453
455
|
}
|
|
454
456
|
declare class OpenfortConfiguration {
|
|
455
457
|
readonly publishableKey: string;
|
|
@@ -472,18 +474,18 @@ type OpenfortSDKConfiguration = {
|
|
|
472
474
|
baseConfiguration: OpenfortConfiguration;
|
|
473
475
|
shieldConfiguration?: ShieldConfiguration;
|
|
474
476
|
overrides?: SDKOverrides;
|
|
477
|
+
thirdPartyAuth?: ThirdPartyAuthConfiguration;
|
|
475
478
|
};
|
|
476
479
|
declare class SDKConfiguration {
|
|
477
480
|
readonly baseConfiguration: OpenfortConfiguration;
|
|
478
481
|
readonly shieldConfiguration?: ShieldConfiguration;
|
|
482
|
+
readonly thirdPartyAuth?: ThirdPartyAuthConfiguration;
|
|
479
483
|
readonly shieldUrl: string;
|
|
480
484
|
readonly iframeUrl: string;
|
|
481
485
|
readonly backendUrl: string;
|
|
482
486
|
readonly storage?: IStorage;
|
|
483
|
-
readonly getAccessToken?: () => Promise<string | null>;
|
|
484
|
-
readonly thirdPartyAuthProvider?: ThirdPartyOAuthProvider$1;
|
|
485
487
|
static instance: SDKConfiguration | null;
|
|
486
|
-
constructor({ baseConfiguration, shieldConfiguration, overrides, }: OpenfortSDKConfiguration);
|
|
488
|
+
constructor({ baseConfiguration, shieldConfiguration, overrides, thirdPartyAuth, }: OpenfortSDKConfiguration);
|
|
487
489
|
static getInstance(): SDKConfiguration | null;
|
|
488
490
|
}
|
|
489
491
|
|
|
@@ -7200,21 +7202,11 @@ declare class AuthApi {
|
|
|
7200
7202
|
options?: InitializeOAuthOptions;
|
|
7201
7203
|
ecosystemGame?: string;
|
|
7202
7204
|
}): Promise<InitAuthResponse>;
|
|
7203
|
-
linkThirdPartyProvider({ provider, token, tokenType, }: {
|
|
7204
|
-
provider: ThirdPartyAuthProvider;
|
|
7205
|
-
token: string;
|
|
7206
|
-
tokenType: TokenType$1;
|
|
7207
|
-
}): Promise<AuthPlayerResponse$1>;
|
|
7208
7205
|
unlinkOAuth({ provider, authToken }: {
|
|
7209
7206
|
provider: OAuthProvider$1;
|
|
7210
7207
|
authToken: string;
|
|
7211
7208
|
}): Promise<AuthPlayerResponse$1>;
|
|
7212
7209
|
poolOAuth(key: string): Promise<AuthResponse$1>;
|
|
7213
|
-
/**
|
|
7214
|
-
* Authenticates the user with a third party provider.
|
|
7215
|
-
* Set up the third party auth provider in the SDK configuration.
|
|
7216
|
-
*/
|
|
7217
|
-
authenticateWithThirdPartyProvider(): Promise<AuthPlayerResponse$1>;
|
|
7218
7210
|
loginWithIdToken({ provider, token, ecosystemGame, }: {
|
|
7219
7211
|
provider: OAuthProvider$1;
|
|
7220
7212
|
token: string;
|
|
@@ -7392,8 +7384,8 @@ declare class OpenfortInternal {
|
|
|
7392
7384
|
private authManager;
|
|
7393
7385
|
private eventEmitter;
|
|
7394
7386
|
constructor(storage: IStorage, authManager: AuthManager, eventEmitter: TypedEventEmitter<OpenfortEventMap>);
|
|
7387
|
+
getThirdPartyAuthToken(): Promise<string>;
|
|
7395
7388
|
getAccessToken(): Promise<string | null>;
|
|
7396
|
-
saveThirdPartyAuth(): Promise<void>;
|
|
7397
7389
|
/**
|
|
7398
7390
|
* Validates and refreshes the access token if needed.
|
|
7399
7391
|
*/
|
package/dist/sdk/src/api/auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Authentication as e}from"../core/configuration/authentication.js";import{OpenfortError as a,OpenfortErrorType as t}from"../core/errors/openfortError.js";import{OpenfortEvents as i}from"../types/types.js";class s{storage;authManager;validateAndRefreshToken;ensureInitialized;eventEmitter;constructor(e,a,t,i,s){this.storage=e,this.authManager=a,this.validateAndRefreshToken=t,this.ensureInitialized=i,this.eventEmitter=s}async logInWithEmailPassword({email:i,password:s,ecosystemGame:r}){await this.ensureInitialized();if(await e.fromStorage(this.storage))throw new a("Already logged in",t.ALREADY_LOGGED_IN_ERROR);const n=await this.authManager.loginEmailPassword(i,s,r);return"action"in n||new e("jwt",n.token,n.player.id,n.refreshToken).save(this.storage),n}async signUpGuest(){await this.ensureInitialized();if(await e.fromStorage(this.storage))throw new a("Already logged in",t.ALREADY_LOGGED_IN_ERROR);const i=await this.authManager.registerGuest();return new e("jwt",i.token,i.player.id,i.refreshToken).save(this.storage),i}async signUpWithEmailPassword({email:i,password:s,options:r,ecosystemGame:n}){await this.ensureInitialized();if(await e.fromStorage(this.storage))throw new a("Already logged in",t.ALREADY_LOGGED_IN_ERROR);const o=await this.authManager.signupEmailPassword(i,s,r?.data.name,n);return"action"in o||new e("jwt",o.token,o.player.id,o.refreshToken).save(this.storage),o}async linkEmailPassword({email:e,password:a,authToken:t,ecosystemGame:i}){return await this.validateAndRefreshToken(),await this.authManager.linkEmail(e,a,t,i)}async unlinkEmailPassword({email:e,authToken:a}){return await this.validateAndRefreshToken(),await this.authManager.unlinkEmail(e,a)}async requestEmailVerification({email:e,redirectUrl:a}){await this.ensureInitialized(),await this.authManager.requestEmailVerification(e,a)}async resetPassword({email:e,password:a,state:t}){await this.ensureInitialized(),await this.authManager.resetPassword(e,a,t)}async requestResetPassword({email:e,redirectUrl:a}){await this.ensureInitialized(),await this.authManager.requestResetPassword(e,a)}async verifyEmail({email:e,state:a}){await this.ensureInitialized(),await this.authManager.verifyEmail(e,a)}async initOAuth({provider:i,options:s,ecosystemGame:r}){await this.ensureInitialized();if(await e.fromStorage(this.storage))throw new a("Already logged in",t.ALREADY_LOGGED_IN_ERROR);return await this.authManager.initOAuth(i,s,r)}async initLinkOAuth({provider:i,options:s,ecosystemGame:r}){await this.validateAndRefreshToken();const n=await e.fromStorage(this.storage);if(!n)throw new a("No authentication found",t.NOT_LOGGED_IN_ERROR);return await this.authManager.linkOAuth(n,i,s,r)}async unlinkOAuth({provider:e,authToken:a}){return await this.validateAndRefreshToken(),await this.authManager.unlinkOAuth(e,a)}async poolOAuth(a){await this.ensureInitialized();const t=await this.authManager.poolOAuth(a);return new e("jwt",t.token,t.player.id,t.refreshToken).save(this.storage),t}async loginWithIdToken({provider:i,token:s,ecosystemGame:r}){await this.ensureInitialized();if(await e.fromStorage(this.storage))throw new a("Already logged in",t.ALREADY_LOGGED_IN_ERROR);const n=await this.authManager.loginWithIdToken(i,s,r);return new e("jwt",n.token,n.player.id,n.refreshToken).save(this.storage),n}async initSIWE({address:e,ecosystemGame:a}){return await this.ensureInitialized(),await this.authManager.initSIWE(e,a)}async authenticateWithSIWE({signature:i,message:s,walletClientType:r,connectorType:n}){await this.ensureInitialized();if(await e.fromStorage(this.storage))throw new a("Already logged in",t.ALREADY_LOGGED_IN_ERROR);const o=await this.authManager.authenticateSIWE(i,s,r,n);return new e("jwt",o.token,o.player.id,o.refreshToken).save(this.storage),o}async linkWallet({signature:e,message:a,walletClientType:t,connectorType:i,authToken:s}){return await this.validateAndRefreshToken(),await this.authManager.linkWallet(e,a,t,i,s)}async unlinkWallet({address:e,authToken:a}){return await this.validateAndRefreshToken(),await this.authManager.unlinkWallet(e,a)}async storeCredentials(i){if(await this.ensureInitialized(),!i.player)throw new a("Player ID is required to store credentials",t.INVALID_CONFIGURATION);new e("jwt",i.accessToken,i.player,i.refreshToken).save(this.storage)}async logout(){const a=await e.fromStorage(this.storage);if(a){try{"third_party"!==a.type&&await this.authManager.logout(a.token,a?.refreshToken)}catch(e){}e.clear(this.storage),this.eventEmitter.emit(i.LOGGED_OUT)}}}export{s as AuthApi};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{setCryptoDigestOverride as i}from"../../utils/crypto.js";class
|
|
1
|
+
import{setCryptoDigestOverride as i}from"../../utils/crypto.js";class t{publishableKey;constructor(i){this.publishableKey=i.publishableKey}}class e{shieldPublishableKey;shieldEncryptionKey;debug=!1;constructor(i){this.shieldPublishableKey=i.shieldPublishableKey,this.shieldEncryptionKey=i.shieldEncryptionKey,this.debug=i.shieldDebug||!1}}class s{baseConfiguration;shieldConfiguration;thirdPartyAuth;shieldUrl;iframeUrl;backendUrl;storage;static instance=null;constructor({baseConfiguration:t,shieldConfiguration:e,overrides:r,thirdPartyAuth:h}){this.shieldConfiguration=e,this.baseConfiguration=t,this.backendUrl=r?.backendUrl||"https://api.openfort.io",this.iframeUrl=r?.iframeUrl||"https://embed.openfort.io",this.iframeUrl=`${this.iframeUrl}/iframe/${this.baseConfiguration.publishableKey}`,e?.debug&&(this.iframeUrl=`${this.iframeUrl}?debug=true`),this.shieldUrl=r?.shieldUrl||"https://shield.openfort.io",this.storage=r?.storage,this.thirdPartyAuth=h,r?.crypto?.digest&&i(r.crypto.digest),s.instance=this}static getInstance(){return s.instance}}export{t as OpenfortConfiguration,s as SDKConfiguration,e as ShieldConfiguration};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{OpenfortError as t,OpenfortErrorType as e}from"./errors/openfortError.js";import{TokenType as r,OpenfortEvents as
|
|
1
|
+
import{OpenfortError as t,OpenfortErrorType as e}from"./errors/openfortError.js";import{TokenType as r,OpenfortEvents as i}from"../types/types.js";import"../storage/istorage.js";import"../wallets/messaging/browserMessenger/backwardCompatibility.js";import{debugLog as s}from"../utils/debug.js";import{Authentication as a}from"./configuration/authentication.js";import"../wallets/types.js";import"./errors/sentry.js";import{SDKConfiguration as o}from"./config/config.js";import"jose";import"../wallets/evm/types.js";import"../wallets/evm/JsonRpcError.js";import"eventemitter3";import"../wallets/evm/provider/eip6963.js";class n{storage;authManager;eventEmitter;constructor(t,e,r){this.storage=t,this.authManager=e,this.eventEmitter=r}async getThirdPartyAuthToken(){const s=o.getInstance();if(!s?.thirdPartyAuth)throw new t("No third party configuration found",e.INTERNAL_ERROR);const{getAccessToken:n,provider:h}=s.thirdPartyAuth;if(!n||!h)throw new t("Third party is not configured. Please configure getAccessToken and thirdPartyAuthProvider in your Openfort instance",e.INVALID_CONFIGURATION);const c=await n();if(!c)throw new t("Could not get access token",e.AUTHENTICATION_ERROR);let g=(await a.fromStorage(this.storage))?.player;if(!g){const t=await this.authManager.authenticateThirdParty(h,c,r.ID_TOKEN);g=t?.id}return new a("third_party",c,g,null,h,r.ID_TOKEN).save(this.storage),this.eventEmitter.emit(i.TOKEN_REFRESHED),c}async getAccessToken(){if(o.getInstance()?.thirdPartyAuth)return this.getThirdPartyAuthToken();return(await a.fromStorage(this.storage))?.token??null}async validateAndRefreshToken(r){if(o.getInstance()?.thirdPartyAuth)return void await this.getThirdPartyAuthToken();const n=await a.fromStorage(this.storage);if(!n)throw new t("Must be logged in to validate and refresh token",e.NOT_LOGGED_IN_ERROR);let h;s("validating credentials...");try{h=await this.authManager.validateCredentials(n,r)}catch(t){throw a.clear(this.storage),this.eventEmitter.emit(i.LOGGED_OUT),t}if(!h.player)throw new t("No user found in credentials",e.INTERNAL_ERROR);h.accessToken!==n.token&&(s("tokens refreshed"),new a("jwt",h.accessToken,h.player,h.refreshToken).save(this.storage),this.eventEmitter.emit(i.TOKEN_REFRESHED))}}export{n as OpenfortInternal};
|
package/dist/sdk/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="0.10.
|
|
1
|
+
const o="0.10.3",t="@openfort/openfort-js";export{t as PACKAGE,o as VERSION};
|
package/package.json
CHANGED