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.
@@ -19,4 +19,5 @@ export interface UserLogin {
19
19
  nonExportablePrivateKey?: CryptoKey;
20
20
  publicKey?: CryptoKey;
21
21
  isLoggedIn?: boolean;
22
+ data?: any;
22
23
  }
@@ -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
  *
@@ -2223,6 +2223,9 @@
2223
2223
  if (response.userValidUntil != null) {
2224
2224
  login.license.validUntil = new Date(response.userValidUntil);
2225
2225
  }
2226
+ if (response.data) {
2227
+ login.data = response.data;
2228
+ }
2226
2229
  return login;
2227
2230
  });
2228
2231
  }
@@ -2277,6 +2280,7 @@
2277
2280
  type: response2.userType,
2278
2281
  status: response2.claims.license || 'ok',
2279
2282
  };
2283
+ context.data = response2.data;
2280
2284
  if (response2.evalDaysLeft != null) {
2281
2285
  context.license.evalDaysLeft = response2.evalDaysLeft;
2282
2286
  }
@@ -2627,11 +2631,16 @@
2627
2631
  const origUserId = currentUser.userId;
2628
2632
  if (currentUser.isLoggedIn && (!hints || (!hints.email && !hints.userId))) {
2629
2633
  const licenseStatus = ((_a = currentUser.license) === null || _a === void 0 ? void 0 : _a.status) || 'ok';
2630
- if (licenseStatus === 'ok' && currentUser.accessToken && (!currentUser.accessTokenExpiration || currentUser.accessTokenExpiration.getTime() > Date.now())) {
2634
+ if (licenseStatus === 'ok' &&
2635
+ currentUser.accessToken &&
2636
+ (!currentUser.accessTokenExpiration ||
2637
+ currentUser.accessTokenExpiration.getTime() > Date.now())) {
2631
2638
  // Already authenticated according to given hints. And license is valid.
2632
2639
  return false;
2633
2640
  }
2634
- if (currentUser.refreshToken && (!currentUser.refreshTokenExpiration || currentUser.refreshTokenExpiration.getTime() > Date.now())) {
2641
+ if (currentUser.refreshToken &&
2642
+ (!currentUser.refreshTokenExpiration ||
2643
+ currentUser.refreshTokenExpiration.getTime() > Date.now())) {
2635
2644
  // Refresh the token
2636
2645
  yield loadAccessToken(db);
2637
2646
  return false;
@@ -2643,7 +2652,8 @@
2643
2652
  lastLogin: new Date(0),
2644
2653
  });
2645
2654
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
2646
- if (origUserId !== UNAUTHORIZED_USER.userId && context.userId !== origUserId) {
2655
+ if (origUserId !== UNAUTHORIZED_USER.userId &&
2656
+ context.userId !== origUserId) {
2647
2657
  // User was logged in before, but now logged in as another user.
2648
2658
  yield logout(db);
2649
2659
  }
@@ -2662,7 +2672,7 @@
2662
2672
  yield setCurrentUser(db, context);
2663
2673
  // Make sure to resync as the new login will be authorized
2664
2674
  // for new realms.
2665
- triggerSync(db, "pull");
2675
+ triggerSync(db, 'pull');
2666
2676
  return context.userId !== origUserId;
2667
2677
  });
2668
2678
  }
@@ -4222,6 +4232,7 @@
4222
4232
  accessTokenExpiration: refreshedLogin.accessTokenExpiration,
4223
4233
  claims: refreshedLogin.claims,
4224
4234
  license: refreshedLogin.license,
4235
+ data: refreshedLogin.data,
4225
4236
  });
4226
4237
  // Updating $logins will trigger emission of db.cloud.currentUser observable, which
4227
4238
  // in turn will lead to that connectWebSocket.ts will reconnect the socket with the
@@ -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
  }
@@ -6303,7 +6315,7 @@
6303
6315
  const syncComplete = new rxjs.Subject();
6304
6316
  dexie.cloud = {
6305
6317
  // @ts-ignore
6306
- version: "4.0.2",
6318
+ version: "4.0.4",
6307
6319
  options: Object.assign({}, DEFAULT_OPTIONS),
6308
6320
  schema: null,
6309
6321
  get currentUserId() {
@@ -6534,7 +6546,10 @@
6534
6546
  // HERE: If requireAuth, do athentication now.
6535
6547
  let changedUser = false;
6536
6548
  if ((_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth) {
6537
- changedUser = yield login(db);
6549
+ const user = yield db.getCurrentUser();
6550
+ if (!user.isLoggedIn) {
6551
+ changedUser = yield login(db);
6552
+ }
6538
6553
  }
6539
6554
  if (localSyncWorker)
6540
6555
  localSyncWorker.stop();
@@ -6580,7 +6595,7 @@
6580
6595
  }
6581
6596
  }
6582
6597
  // @ts-ignore
6583
- dexieCloud.version = "4.0.2";
6598
+ dexieCloud.version = "4.0.4";
6584
6599
  Dexie.Cloud = dexieCloud;
6585
6600
 
6586
6601
  exports.default = dexieCloud;