dexie-cloud-addon 4.0.1-beta.55 → 4.0.1-beta.57
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/DexieCloudAPI.d.ts +8 -5
- package/dist/modern/authentication/authenticate.d.ts +3 -10
- package/dist/modern/authentication/login.d.ts +2 -5
- package/dist/modern/dexie-cloud-addon.js +23 -12
- 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 +23 -12
- 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/DexieCloudAPI.d.ts +8 -5
- package/dist/umd/authentication/authenticate.d.ts +3 -10
- package/dist/umd/authentication/login.d.ts +2 -5
- package/dist/umd/dexie-cloud-addon.js +23 -12
- 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 +23 -12
- 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 +2 -2
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.0.1-beta.
|
|
11
|
+
* Version 4.0.1-beta.57, Wed Feb 14 2024
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -3329,7 +3329,7 @@ function syncWithServer(changes, syncState, baseRevs, db, databaseUrl, schema, c
|
|
|
3329
3329
|
const res = yield fetch(`${databaseUrl}/sync`, {
|
|
3330
3330
|
method: 'post',
|
|
3331
3331
|
headers,
|
|
3332
|
-
credentials: 'include',
|
|
3332
|
+
credentials: 'include', // For Arr Affinity cookie only, for better Rate-Limit counting only.
|
|
3333
3333
|
body: TSON.stringify(syncRequest),
|
|
3334
3334
|
});
|
|
3335
3335
|
//const contentLength = Number(res.headers.get('content-length'));
|
|
@@ -4238,6 +4238,19 @@ function otpFetchTokenCallback(db) {
|
|
|
4238
4238
|
demo_user,
|
|
4239
4239
|
grant_type: 'demo',
|
|
4240
4240
|
scopes: ['ACCESS_DB'],
|
|
4241
|
+
public_key
|
|
4242
|
+
};
|
|
4243
|
+
}
|
|
4244
|
+
else if ((hints === null || hints === void 0 ? void 0 : hints.otpId) && hints.otp) {
|
|
4245
|
+
// User provided OTP ID and OTP code. This means that the OTP email
|
|
4246
|
+
// has already gone out and the user may have clicked a magic link
|
|
4247
|
+
// in the email with otp and otpId in query and the app has picked
|
|
4248
|
+
// up those values and passed them to db.cloud.login().
|
|
4249
|
+
tokenRequest = {
|
|
4250
|
+
grant_type: 'otp',
|
|
4251
|
+
otp_id: hints.otpId,
|
|
4252
|
+
otp: hints.otp,
|
|
4253
|
+
scopes: ['ACCESS_DB'],
|
|
4241
4254
|
public_key,
|
|
4242
4255
|
};
|
|
4243
4256
|
}
|
|
@@ -4247,7 +4260,6 @@ function otpFetchTokenCallback(db) {
|
|
|
4247
4260
|
email,
|
|
4248
4261
|
grant_type: 'otp',
|
|
4249
4262
|
scopes: ['ACCESS_DB'],
|
|
4250
|
-
public_key,
|
|
4251
4263
|
};
|
|
4252
4264
|
}
|
|
4253
4265
|
const res1 = yield fetch(`${url}/token`, {
|
|
@@ -4271,28 +4283,27 @@ function otpFetchTokenCallback(db) {
|
|
|
4271
4283
|
// Error can also be returned right away.
|
|
4272
4284
|
return response;
|
|
4273
4285
|
}
|
|
4274
|
-
else if (tokenRequest.grant_type === 'otp') {
|
|
4286
|
+
else if (tokenRequest.grant_type === 'otp' && 'email' in tokenRequest) {
|
|
4275
4287
|
if (response.type !== 'otp-sent')
|
|
4276
4288
|
throw new Error(`Unexpected response from ${url}/token`);
|
|
4277
4289
|
const otp = yield promptForOTP(userInteraction, tokenRequest.email);
|
|
4278
|
-
|
|
4279
|
-
tokenRequest.otp_id = response.otp_id;
|
|
4290
|
+
const tokenRequest2 = Object.assign(Object.assign({}, tokenRequest), { otp: otp || '', otp_id: response.otp_id, public_key });
|
|
4280
4291
|
let res2 = yield fetch(`${url}/token`, {
|
|
4281
|
-
body: JSON.stringify(
|
|
4292
|
+
body: JSON.stringify(tokenRequest2),
|
|
4282
4293
|
method: 'post',
|
|
4283
4294
|
headers: { 'Content-Type': 'application/json' },
|
|
4284
4295
|
mode: 'cors',
|
|
4285
4296
|
});
|
|
4286
4297
|
while (res2.status === 401) {
|
|
4287
4298
|
const errorText = yield res2.text();
|
|
4288
|
-
|
|
4299
|
+
tokenRequest2.otp = yield promptForOTP(userInteraction, tokenRequest.email, {
|
|
4289
4300
|
type: 'error',
|
|
4290
4301
|
messageCode: 'INVALID_OTP',
|
|
4291
4302
|
message: errorText,
|
|
4292
4303
|
messageParams: {}
|
|
4293
4304
|
});
|
|
4294
4305
|
res2 = yield fetch(`${url}/token`, {
|
|
4295
|
-
body: JSON.stringify(
|
|
4306
|
+
body: JSON.stringify(tokenRequest2),
|
|
4296
4307
|
method: 'post',
|
|
4297
4308
|
headers: { 'Content-Type': 'application/json' },
|
|
4298
4309
|
mode: 'cors',
|
|
@@ -5572,7 +5583,7 @@ function LocalSyncWorker(db, cloudOptions, cloudSchema) {
|
|
|
5572
5583
|
retryPurpose = null;
|
|
5573
5584
|
syncIfPossible(db, cloudOptions, cloudSchema, {
|
|
5574
5585
|
cancelToken,
|
|
5575
|
-
retryImmediatelyOnFetchError: true,
|
|
5586
|
+
retryImmediatelyOnFetchError: true, // workaround for "net::ERR_NETWORK_CHANGED" in chrome.
|
|
5576
5587
|
purpose: combPurpose,
|
|
5577
5588
|
}).catch((e) => {
|
|
5578
5589
|
console.error('error in syncIfPossible()', e);
|
|
@@ -6246,7 +6257,7 @@ function dexieCloud(dexie) {
|
|
|
6246
6257
|
const syncComplete = new Subject();
|
|
6247
6258
|
dexie.cloud = {
|
|
6248
6259
|
// @ts-ignore
|
|
6249
|
-
version: "4.0.1-beta.
|
|
6260
|
+
version: "4.0.1-beta.57",
|
|
6250
6261
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6251
6262
|
schema: null,
|
|
6252
6263
|
get currentUserId() {
|
|
@@ -6523,7 +6534,7 @@ function dexieCloud(dexie) {
|
|
|
6523
6534
|
}
|
|
6524
6535
|
}
|
|
6525
6536
|
// @ts-ignore
|
|
6526
|
-
dexieCloud.version = "4.0.1-beta.
|
|
6537
|
+
dexieCloud.version = "4.0.1-beta.57";
|
|
6527
6538
|
Dexie.Cloud = dexieCloud;
|
|
6528
6539
|
|
|
6529
6540
|
// In case the SW lives for a while, let it reuse already opened connections:
|