diff --git a/examples/cstg/html/index.html b/examples/cstg/html/index.html index b04c95e9..d248b473 100644 --- a/examples/cstg/html/index.html +++ b/examples/cstg/html/index.html @@ -29,9 +29,7 @@ $('#login_required').text( sdk.isLoginRequired() || sdk.isLoginRequired() === undefined ? 'yes' : 'no' ); - $(`#has_opted_out`).text( - sdk.hasOptedOut() ? 'yes' : 'no' - ); + $(`#has_opted_out`).text(sdk.hasOptedOut() ? 'yes' : 'no'); $('#update_counter').text(callbackCounter); $('#identity_state').text(String(JSON.stringify(state, null, 2))); diff --git a/examples/google-secure-signals-integration/with_sdk_v3/views/login.html b/examples/google-secure-signals-integration/with_sdk_v3/views/login.html index 05181322..b9c8ba37 100644 --- a/examples/google-secure-signals-integration/with_sdk_v3/views/login.html +++ b/examples/google-secure-signals-integration/with_sdk_v3/views/login.html @@ -1,4 +1,4 @@ - + diff --git a/src/sdkBase.ts b/src/sdkBase.ts index b402916a..5b880c31 100644 --- a/src/sdkBase.ts +++ b/src/sdkBase.ts @@ -181,16 +181,20 @@ export abstract class SdkBase { return this._initComplete; } - /** - * Deprecated - */ public isLoginRequired() { - return this.hasIdentity(); + return !this.isIdentityAvailable(); } + /** + * @deprecated in version 3.10.0. Will remove in June 2025. Use isIdentityAvailable() instead. + **/ public hasIdentity() { if (!this._initComplete) return undefined; - return !(this.isLoggedIn() || this._apiClient?.hasActiveRequests()); + return !(this.isIdentityValid() || this._apiClient?.hasActiveRequests()); + } + + public isIdentityAvailable() { + return this.isIdentityValid() || this._apiClient?.hasActiveRequests(); } public hasOptedOut() { @@ -295,8 +299,9 @@ export abstract class SdkBase { if (this.hasOptedOut()) this._callbackManager.runCallbacks(EventType.OptoutReceived, {}); } - private isLoggedIn() { - return this._identity && !hasExpired(this._identity.refresh_expires); + private isIdentityValid() { + const identity = this._identity ?? this.getIdentityNoInit(); + return identity && !hasExpired(identity.refresh_expires); } private temporarilyUnavailable(identity: Identity | OptoutIdentity | null | undefined) {