dexie-cloud-addon 4.0.1-beta.57 → 4.0.1-beta.58

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.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.0.1-beta.57, Wed Feb 14 2024
11
+ * Version 4.0.1-beta.58, Tue Feb 20 2024
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -2605,11 +2605,16 @@
2605
2605
  const origUserId = currentUser.userId;
2606
2606
  if (currentUser.isLoggedIn && (!hints || (!hints.email && !hints.userId))) {
2607
2607
  const licenseStatus = ((_a = currentUser.license) === null || _a === void 0 ? void 0 : _a.status) || 'ok';
2608
- if (licenseStatus === 'ok' && currentUser.accessToken && (!currentUser.accessTokenExpiration || currentUser.accessTokenExpiration.getTime() > Date.now())) {
2608
+ if (licenseStatus === 'ok' &&
2609
+ currentUser.accessToken &&
2610
+ (!currentUser.accessTokenExpiration ||
2611
+ currentUser.accessTokenExpiration.getTime() > Date.now())) {
2609
2612
  // Already authenticated according to given hints. And license is valid.
2610
2613
  return false;
2611
2614
  }
2612
- if (currentUser.refreshToken && (!currentUser.refreshTokenExpiration || currentUser.refreshTokenExpiration.getTime() > Date.now())) {
2615
+ if (currentUser.refreshToken &&
2616
+ (!currentUser.refreshTokenExpiration ||
2617
+ currentUser.refreshTokenExpiration.getTime() > Date.now())) {
2613
2618
  // Refresh the token
2614
2619
  yield loadAccessToken(db);
2615
2620
  return false;
@@ -2621,7 +2626,8 @@
2621
2626
  lastLogin: new Date(0),
2622
2627
  });
2623
2628
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
2624
- if (origUserId !== UNAUTHORIZED_USER.userId && context.userId !== origUserId) {
2629
+ if (origUserId !== UNAUTHORIZED_USER.userId &&
2630
+ context.userId !== origUserId) {
2625
2631
  // User was logged in before, but now logged in as another user.
2626
2632
  yield logout(db);
2627
2633
  }
@@ -2640,7 +2646,7 @@
2640
2646
  yield setCurrentUser(db, context);
2641
2647
  // Make sure to resync as the new login will be authorized
2642
2648
  // for new realms.
2643
- triggerSync(db, "pull");
2649
+ triggerSync(db, 'pull');
2644
2650
  return context.userId !== origUserId;
2645
2651
  });
2646
2652
  }
@@ -6267,7 +6273,7 @@
6267
6273
  const syncComplete = new rxjs.Subject();
6268
6274
  dexie.cloud = {
6269
6275
  // @ts-ignore
6270
- version: "4.0.1-beta.57",
6276
+ version: "4.0.1-beta.58",
6271
6277
  options: Object.assign({}, DEFAULT_OPTIONS),
6272
6278
  schema: null,
6273
6279
  get currentUserId() {
@@ -6498,7 +6504,10 @@
6498
6504
  // HERE: If requireAuth, do athentication now.
6499
6505
  let changedUser = false;
6500
6506
  if ((_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth) {
6501
- changedUser = yield login(db);
6507
+ const user = yield db.getCurrentUser();
6508
+ if (!user.isLoggedIn) {
6509
+ changedUser = yield login(db);
6510
+ }
6502
6511
  }
6503
6512
  if (localSyncWorker)
6504
6513
  localSyncWorker.stop();
@@ -6544,7 +6553,7 @@
6544
6553
  }
6545
6554
  }
6546
6555
  // @ts-ignore
6547
- dexieCloud.version = "4.0.1-beta.57";
6556
+ dexieCloud.version = "4.0.1-beta.58";
6548
6557
  Dexie.Cloud = dexieCloud;
6549
6558
 
6550
6559
  exports.default = dexieCloud;