dexie-cloud-addon 4.0.2 → 4.0.4

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.2, Wed Apr 10 2024
11
+ * Version 4.0.4, Mon Apr 29 2024
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -2540,6 +2540,9 @@
2540
2540
  if (response.userValidUntil != null) {
2541
2541
  login.license.validUntil = new Date(response.userValidUntil);
2542
2542
  }
2543
+ if (response.data) {
2544
+ login.data = response.data;
2545
+ }
2543
2546
  return login;
2544
2547
  });
2545
2548
  }
@@ -2594,6 +2597,7 @@
2594
2597
  type: response2.userType,
2595
2598
  status: response2.claims.license || 'ok',
2596
2599
  };
2600
+ context.data = response2.data;
2597
2601
  if (response2.evalDaysLeft != null) {
2598
2602
  context.license.evalDaysLeft = response2.evalDaysLeft;
2599
2603
  }
@@ -3922,6 +3926,7 @@
3922
3926
  accessTokenExpiration: refreshedLogin.accessTokenExpiration,
3923
3927
  claims: refreshedLogin.claims,
3924
3928
  license: refreshedLogin.license,
3929
+ data: refreshedLogin.data,
3925
3930
  });
3926
3931
  // Updating $logins will trigger emission of db.cloud.currentUser observable, which
3927
3932
  // in turn will lead to that connectWebSocket.ts will reconnect the socket with the
@@ -4425,11 +4430,16 @@
4425
4430
  const origUserId = currentUser.userId;
4426
4431
  if (currentUser.isLoggedIn && (!hints || (!hints.email && !hints.userId))) {
4427
4432
  const licenseStatus = ((_a = currentUser.license) === null || _a === void 0 ? void 0 : _a.status) || 'ok';
4428
- if (licenseStatus === 'ok' && currentUser.accessToken && (!currentUser.accessTokenExpiration || currentUser.accessTokenExpiration.getTime() > Date.now())) {
4433
+ if (licenseStatus === 'ok' &&
4434
+ currentUser.accessToken &&
4435
+ (!currentUser.accessTokenExpiration ||
4436
+ currentUser.accessTokenExpiration.getTime() > Date.now())) {
4429
4437
  // Already authenticated according to given hints. And license is valid.
4430
4438
  return false;
4431
4439
  }
4432
- if (currentUser.refreshToken && (!currentUser.refreshTokenExpiration || currentUser.refreshTokenExpiration.getTime() > Date.now())) {
4440
+ if (currentUser.refreshToken &&
4441
+ (!currentUser.refreshTokenExpiration ||
4442
+ currentUser.refreshTokenExpiration.getTime() > Date.now())) {
4433
4443
  // Refresh the token
4434
4444
  yield loadAccessToken(db);
4435
4445
  return false;
@@ -4441,7 +4451,8 @@
4441
4451
  lastLogin: new Date(0),
4442
4452
  });
4443
4453
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
4444
- if (origUserId !== UNAUTHORIZED_USER.userId && context.userId !== origUserId) {
4454
+ if (origUserId !== UNAUTHORIZED_USER.userId &&
4455
+ context.userId !== origUserId) {
4445
4456
  // User was logged in before, but now logged in as another user.
4446
4457
  yield logout(db);
4447
4458
  }
@@ -4460,7 +4471,7 @@
4460
4471
  yield setCurrentUser(db, context);
4461
4472
  // Make sure to resync as the new login will be authorized
4462
4473
  // for new realms.
4463
- triggerSync(db, "pull");
4474
+ triggerSync(db, 'pull');
4464
4475
  return context.userId !== origUserId;
4465
4476
  });
4466
4477
  }
@@ -5470,6 +5481,7 @@
5470
5481
  accessTokenExpiration: refreshedLogin.accessTokenExpiration,
5471
5482
  claims: refreshedLogin.claims,
5472
5483
  license: refreshedLogin.license,
5484
+ data: refreshedLogin.data
5473
5485
  });
5474
5486
  })), switchMap(() => createObservable()));
5475
5487
  }
@@ -6296,7 +6308,7 @@
6296
6308
  const syncComplete = new rxjs.Subject();
6297
6309
  dexie.cloud = {
6298
6310
  // @ts-ignore
6299
- version: "4.0.2",
6311
+ version: "4.0.4",
6300
6312
  options: Object.assign({}, DEFAULT_OPTIONS),
6301
6313
  schema: null,
6302
6314
  get currentUserId() {
@@ -6527,7 +6539,10 @@
6527
6539
  // HERE: If requireAuth, do athentication now.
6528
6540
  let changedUser = false;
6529
6541
  if ((_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth) {
6530
- changedUser = yield login(db);
6542
+ const user = yield db.getCurrentUser();
6543
+ if (!user.isLoggedIn) {
6544
+ changedUser = yield login(db);
6545
+ }
6531
6546
  }
6532
6547
  if (localSyncWorker)
6533
6548
  localSyncWorker.stop();
@@ -6573,7 +6588,7 @@
6573
6588
  }
6574
6589
  }
6575
6590
  // @ts-ignore
6576
- dexieCloud.version = "4.0.2";
6591
+ dexieCloud.version = "4.0.4";
6577
6592
  Dexie.Cloud = dexieCloud;
6578
6593
 
6579
6594
  // In case the SW lives for a while, let it reuse already opened connections: