dexie-cloud-addon 4.0.3 → 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.
- package/dist/modern/dexie-cloud-addon.js +17 -8
- package/dist/modern/dexie-cloud-addon.js.map +1 -1
- package/dist/modern/dexie-cloud-addon.min.js +1 -1
- package/dist/modern/dexie-cloud-addon.min.js.map +1 -1
- package/dist/modern/service-worker.js +17 -8
- package/dist/modern/service-worker.js.map +1 -1
- package/dist/modern/service-worker.min.js +1 -1
- package/dist/modern/service-worker.min.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.js +17 -8
- package/dist/umd/dexie-cloud-addon.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.min.js +1 -1
- package/dist/umd/dexie-cloud-addon.min.js.map +1 -1
- package/dist/umd/service-worker.js +17 -8
- package/dist/umd/service-worker.js.map +1 -1
- package/dist/umd/service-worker.min.js +1 -1
- package/dist/umd/service-worker.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.0.
|
|
11
|
+
* Version 4.0.4, Mon Apr 29 2024
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -4427,11 +4427,16 @@ function login(db, hints) {
|
|
|
4427
4427
|
const origUserId = currentUser.userId;
|
|
4428
4428
|
if (currentUser.isLoggedIn && (!hints || (!hints.email && !hints.userId))) {
|
|
4429
4429
|
const licenseStatus = ((_a = currentUser.license) === null || _a === void 0 ? void 0 : _a.status) || 'ok';
|
|
4430
|
-
if (licenseStatus === 'ok' &&
|
|
4430
|
+
if (licenseStatus === 'ok' &&
|
|
4431
|
+
currentUser.accessToken &&
|
|
4432
|
+
(!currentUser.accessTokenExpiration ||
|
|
4433
|
+
currentUser.accessTokenExpiration.getTime() > Date.now())) {
|
|
4431
4434
|
// Already authenticated according to given hints. And license is valid.
|
|
4432
4435
|
return false;
|
|
4433
4436
|
}
|
|
4434
|
-
if (currentUser.refreshToken &&
|
|
4437
|
+
if (currentUser.refreshToken &&
|
|
4438
|
+
(!currentUser.refreshTokenExpiration ||
|
|
4439
|
+
currentUser.refreshTokenExpiration.getTime() > Date.now())) {
|
|
4435
4440
|
// Refresh the token
|
|
4436
4441
|
yield loadAccessToken(db);
|
|
4437
4442
|
return false;
|
|
@@ -4443,7 +4448,8 @@ function login(db, hints) {
|
|
|
4443
4448
|
lastLogin: new Date(0),
|
|
4444
4449
|
});
|
|
4445
4450
|
yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
|
|
4446
|
-
if (origUserId !== UNAUTHORIZED_USER.userId &&
|
|
4451
|
+
if (origUserId !== UNAUTHORIZED_USER.userId &&
|
|
4452
|
+
context.userId !== origUserId) {
|
|
4447
4453
|
// User was logged in before, but now logged in as another user.
|
|
4448
4454
|
yield logout(db);
|
|
4449
4455
|
}
|
|
@@ -4462,7 +4468,7 @@ function login(db, hints) {
|
|
|
4462
4468
|
yield setCurrentUser(db, context);
|
|
4463
4469
|
// Make sure to resync as the new login will be authorized
|
|
4464
4470
|
// for new realms.
|
|
4465
|
-
triggerSync(db,
|
|
4471
|
+
triggerSync(db, 'pull');
|
|
4466
4472
|
return context.userId !== origUserId;
|
|
4467
4473
|
});
|
|
4468
4474
|
}
|
|
@@ -6299,7 +6305,7 @@ function dexieCloud(dexie) {
|
|
|
6299
6305
|
const syncComplete = new Subject();
|
|
6300
6306
|
dexie.cloud = {
|
|
6301
6307
|
// @ts-ignore
|
|
6302
|
-
version: "4.0.
|
|
6308
|
+
version: "4.0.4",
|
|
6303
6309
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6304
6310
|
schema: null,
|
|
6305
6311
|
get currentUserId() {
|
|
@@ -6530,7 +6536,10 @@ function dexieCloud(dexie) {
|
|
|
6530
6536
|
// HERE: If requireAuth, do athentication now.
|
|
6531
6537
|
let changedUser = false;
|
|
6532
6538
|
if ((_c = db.cloud.options) === null || _c === void 0 ? void 0 : _c.requireAuth) {
|
|
6533
|
-
|
|
6539
|
+
const user = yield db.getCurrentUser();
|
|
6540
|
+
if (!user.isLoggedIn) {
|
|
6541
|
+
changedUser = yield login(db);
|
|
6542
|
+
}
|
|
6534
6543
|
}
|
|
6535
6544
|
if (localSyncWorker)
|
|
6536
6545
|
localSyncWorker.stop();
|
|
@@ -6576,7 +6585,7 @@ function dexieCloud(dexie) {
|
|
|
6576
6585
|
}
|
|
6577
6586
|
}
|
|
6578
6587
|
// @ts-ignore
|
|
6579
|
-
dexieCloud.version = "4.0.
|
|
6588
|
+
dexieCloud.version = "4.0.4";
|
|
6580
6589
|
Dexie.Cloud = dexieCloud;
|
|
6581
6590
|
|
|
6582
6591
|
// In case the SW lives for a while, let it reuse already opened connections:
|