@logto/client 2.6.5 → 2.6.6

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/lib/client.cjs CHANGED
@@ -61,6 +61,10 @@ class StandardLogtoClient {
61
61
  * Clear the access token from the cache storage.
62
62
  */
63
63
  this.clearAccessToken = memoize.memoize(this.#clearAccessToken);
64
+ /**
65
+ * Clear all cached tokens from storage.
66
+ */
67
+ this.clearAllTokens = memoize.memoize(this.#clearAllTokens);
64
68
  /**
65
69
  * Handle the sign-in callback by parsing the authorization code from the
66
70
  * callback URI and exchanging it for the tokens.
@@ -183,9 +187,7 @@ class StandardLogtoClient {
183
187
  });
184
188
  await Promise.all([
185
189
  this.setSignInSession({ redirectUri, postRedirectUri, codeVerifier, state }),
186
- this.setRefreshToken(null),
187
- this.setIdToken(null),
188
- this.clearAccessToken(),
190
+ this.clearAllTokens(),
189
191
  ]);
190
192
  await this.adapter.navigate(signInUri, { redirectUri, for: 'sign-in' });
191
193
  }
@@ -233,7 +235,7 @@ class StandardLogtoClient {
233
235
  postLogoutRedirectUri,
234
236
  clientId,
235
237
  });
236
- await Promise.all([this.setRefreshToken(null), this.setIdToken(null), this.clearAccessToken()]);
238
+ await this.clearAllTokens();
237
239
  await this.adapter.navigate(url, { redirectUri: postLogoutRedirectUri, for: 'sign-out' });
238
240
  }
239
241
  async getSignInSession() {
@@ -351,6 +353,9 @@ class StandardLogtoClient {
351
353
  this.accessTokenMap.clear();
352
354
  await this.adapter.storage.removeItem('accessToken');
353
355
  }
356
+ async #clearAllTokens() {
357
+ await Promise.all([this.setRefreshToken(null), this.setIdToken(null), this.clearAccessToken()]);
358
+ }
354
359
  async #handleSignInCallback(callbackUri) {
355
360
  const signInSession = await this.getSignInSession();
356
361
  if (!signInSession) {
package/lib/client.d.ts CHANGED
@@ -70,6 +70,10 @@ export declare class StandardLogtoClient {
70
70
  * Clear the access token from the cache storage.
71
71
  */
72
72
  readonly clearAccessToken: (this: unknown) => Promise<void>;
73
+ /**
74
+ * Clear all cached tokens from storage.
75
+ */
76
+ readonly clearAllTokens: (this: unknown) => Promise<void>;
73
77
  /**
74
78
  * Handle the sign-in callback by parsing the authorization code from the
75
79
  * callback URI and exchanging it for the tokens.
package/lib/client.js CHANGED
@@ -59,6 +59,10 @@ class StandardLogtoClient {
59
59
  * Clear the access token from the cache storage.
60
60
  */
61
61
  this.clearAccessToken = memoize(this.#clearAccessToken);
62
+ /**
63
+ * Clear all cached tokens from storage.
64
+ */
65
+ this.clearAllTokens = memoize(this.#clearAllTokens);
62
66
  /**
63
67
  * Handle the sign-in callback by parsing the authorization code from the
64
68
  * callback URI and exchanging it for the tokens.
@@ -181,9 +185,7 @@ class StandardLogtoClient {
181
185
  });
182
186
  await Promise.all([
183
187
  this.setSignInSession({ redirectUri, postRedirectUri, codeVerifier, state }),
184
- this.setRefreshToken(null),
185
- this.setIdToken(null),
186
- this.clearAccessToken(),
188
+ this.clearAllTokens(),
187
189
  ]);
188
190
  await this.adapter.navigate(signInUri, { redirectUri, for: 'sign-in' });
189
191
  }
@@ -231,7 +233,7 @@ class StandardLogtoClient {
231
233
  postLogoutRedirectUri,
232
234
  clientId,
233
235
  });
234
- await Promise.all([this.setRefreshToken(null), this.setIdToken(null), this.clearAccessToken()]);
236
+ await this.clearAllTokens();
235
237
  await this.adapter.navigate(url, { redirectUri: postLogoutRedirectUri, for: 'sign-out' });
236
238
  }
237
239
  async getSignInSession() {
@@ -349,6 +351,9 @@ class StandardLogtoClient {
349
351
  this.accessTokenMap.clear();
350
352
  await this.adapter.storage.removeItem('accessToken');
351
353
  }
354
+ async #clearAllTokens() {
355
+ await Promise.all([this.setRefreshToken(null), this.setIdToken(null), this.clearAccessToken()]);
356
+ }
352
357
  async #handleSignInCallback(callbackUri) {
353
358
  const signInSession = await this.getSignInSession();
354
359
  if (!signInSession) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/client",
3
- "version": "2.6.5",
3
+ "version": "2.6.6",
4
4
  "type": "module",
5
5
  "main": "./lib/index.cjs",
6
6
  "module": "./lib/index.js",