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
  *
@@ -4394,11 +4394,16 @@
4394
4394
  const origUserId = currentUser.userId;
4395
4395
  if (currentUser.isLoggedIn && (!hints || (!hints.email && !hints.userId))) {
4396
4396
  const licenseStatus = ((_a = currentUser.license) === null || _a === void 0 ? void 0 : _a.status) || 'ok';
4397
- if (licenseStatus === 'ok' && currentUser.accessToken && (!currentUser.accessTokenExpiration || currentUser.accessTokenExpiration.getTime() > Date.now())) {
4397
+ if (licenseStatus === 'ok' &&
4398
+ currentUser.accessToken &&
4399
+ (!currentUser.accessTokenExpiration ||
4400
+ currentUser.accessTokenExpiration.getTime() > Date.now())) {
4398
4401
  // Already authenticated according to given hints. And license is valid.
4399
4402
  return false;
4400
4403
  }
4401
- if (currentUser.refreshToken && (!currentUser.refreshTokenExpiration || currentUser.refreshTokenExpiration.getTime() > Date.now())) {
4404
+ if (currentUser.refreshToken &&
4405
+ (!currentUser.refreshTokenExpiration ||
4406
+ currentUser.refreshTokenExpiration.getTime() > Date.now())) {
4402
4407
  // Refresh the token
4403
4408
  yield loadAccessToken(db);
4404
4409
  return false;
@@ -4410,7 +4415,8 @@
4410
4415
  lastLogin: new Date(0),
4411
4416
  });
4412
4417
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
4413
- if (origUserId !== UNAUTHORIZED_USER.userId && context.userId !== origUserId) {
4418
+ if (origUserId !== UNAUTHORIZED_USER.userId &&
4419
+ context.userId !== origUserId) {
4414
4420
  // User was logged in before, but now logged in as another user.
4415
4421
  yield logout(db);
4416
4422
  }
@@ -4429,7 +4435,7 @@
4429
4435
  yield setCurrentUser(db, context);
4430
4436
  // Make sure to resync as the new login will be authorized
4431
4437
  // for new realms.
4432
- triggerSync(db, "pull");
4438
+ triggerSync(db, 'pull');
4433
4439
  return context.userId !== origUserId;
4434
4440
  });
4435
4441
  }
@@ -6260,7 +6266,7 @@
6260
6266
  const syncComplete = new rxjs.Subject();
6261
6267
  dexie.cloud = {
6262
6268
  // @ts-ignore
6263
- version: "4.0.1-beta.57",
6269
+ version: "4.0.1-beta.58",
6264
6270
  options: Object.assign({}, DEFAULT_OPTIONS),
6265
6271
  schema: null,
6266
6272
  get currentUserId() {
@@ -6491,7 +6497,10 @@
6491
6497
  // HERE: If requireAuth, do athentication now.
6492
6498
  let changedUser = false;
6493
6499
  if ((_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth) {
6494
- changedUser = yield login(db);
6500
+ const user = yield db.getCurrentUser();
6501
+ if (!user.isLoggedIn) {
6502
+ changedUser = yield login(db);
6503
+ }
6495
6504
  }
6496
6505
  if (localSyncWorker)
6497
6506
  localSyncWorker.stop();
@@ -6537,7 +6546,7 @@
6537
6546
  }
6538
6547
  }
6539
6548
  // @ts-ignore
6540
- dexieCloud.version = "4.0.1-beta.57";
6549
+ dexieCloud.version = "4.0.1-beta.58";
6541
6550
  Dexie.Cloud = dexieCloud;
6542
6551
 
6543
6552
  // In case the SW lives for a while, let it reuse already opened connections: