@auth0/auth0-server-js 1.16.0 → 1.16.1

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/index.js CHANGED
@@ -229,7 +229,7 @@ function getTelemetryConfig(config) {
229
229
  return {
230
230
  enabled: true,
231
231
  name: config?.name ?? "@auth0/auth0-server-js",
232
- version: config?.version ?? "1.16.0"
232
+ version: config?.version ?? "1.16.1"
233
233
  };
234
234
  }
235
235
 
@@ -509,6 +509,7 @@ function applyEnterpriseConnectRestrictions(instance) {
509
509
 
510
510
  // src/anonymous/server-anonymous-client.ts
511
511
  import { decodeJwt } from "jose";
512
+ import { AnonymousSessionError } from "@auth0/auth0-auth-js";
512
513
  var DEFAULT_AUDIENCE_CACHE_KEY = "default";
513
514
  var readAnonymousSub = (accessToken) => {
514
515
  try {
@@ -640,14 +641,22 @@ var ServerAnonymousClient = class {
640
641
  if (cachedTokenSet && cachedTokenSet.expiresAt > Date.now() / 1e3) {
641
642
  return cachedTokenSet;
642
643
  }
643
- const renewed = await this.#options.getAuthClient(domain).anonymous.getAccessToken({
644
- sessionToken: stateData.sessionToken,
645
- ...requestedAudience && { audience: requestedAudience },
646
- ...scope && { scope }
647
- });
648
- if (renewed.sessionReplaced) {
649
- await this.#options.anonymousStore.delete(this.#options.anonymousStoreIdentifier, storeOptions);
650
- throw new AnonymousSessionExpiredError();
644
+ let renewed;
645
+ try {
646
+ renewed = await this.#options.getAuthClient(domain).anonymous.getAccessToken({
647
+ sessionToken: stateData.sessionToken,
648
+ ...requestedAudience && { audience: requestedAudience },
649
+ ...scope && { scope }
650
+ });
651
+ } catch (e) {
652
+ if (e instanceof AnonymousSessionError && e.code === "session_expired") {
653
+ await this.#options.anonymousStore.delete(this.#options.anonymousStoreIdentifier, storeOptions);
654
+ throw new AnonymousSessionExpiredError();
655
+ }
656
+ if (e instanceof AnonymousSessionError && e.code === "invalid_session_token") {
657
+ await this.#options.anonymousStore.delete(this.#options.anonymousStoreIdentifier, storeOptions);
658
+ }
659
+ throw e;
651
660
  }
652
661
  const tokenSet = {
653
662
  audience,
@@ -2652,12 +2661,12 @@ import {
2652
2661
  import { SignUpError, ChangePasswordError } from "@auth0/auth0-auth-js";
2653
2662
 
2654
2663
  // src/anonymous/index.ts
2655
- import { AnonymousSessionError } from "@auth0/auth0-auth-js";
2664
+ import { AnonymousSessionError as AnonymousSessionError2 } from "@auth0/auth0-auth-js";
2656
2665
  export {
2657
2666
  AbstractAnonymousStore,
2658
2667
  AbstractStateStore,
2659
2668
  AbstractTransactionStore,
2660
- AnonymousSessionError,
2669
+ AnonymousSessionError2 as AnonymousSessionError,
2661
2670
  AnonymousSessionExpiredError,
2662
2671
  BackchannelLogoutError,
2663
2672
  ChangePasswordError,