dexie-cloud-addon 4.0.1-beta.34 → 4.0.1-beta.35

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.34, Mon Mar 27 2023
11
+ * Version 4.0.1-beta.35, Tue Apr 11 2023
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -19,7 +19,7 @@
19
19
  import Dexie, { cmp, liveQuery } from 'dexie';
20
20
  import { Observable as Observable$1, BehaviorSubject, Subject, fromEvent, of, merge, Subscription as Subscription$1, from as from$1, throwError, combineLatest, map as map$1, share, timer as timer$1 } from 'rxjs';
21
21
 
22
- /*! *****************************************************************************
22
+ /******************************************************************************
23
23
  Copyright (c) Microsoft Corporation.
24
24
 
25
25
  Permission to use, copy, modify, and/or distribute this software for any
@@ -124,7 +124,7 @@ function __spreadArray(to, from, pack) {
124
124
  ar[i] = from[i];
125
125
  }
126
126
  }
127
- return to.concat(ar || from);
127
+ return to.concat(ar || Array.prototype.slice.call(from));
128
128
  }
129
129
 
130
130
  function __await(v) {
@@ -1299,7 +1299,6 @@ var AsyncAction = (function (_super) {
1299
1299
  return _this;
1300
1300
  }
1301
1301
  AsyncAction.prototype.schedule = function (state, delay) {
1302
- var _a;
1303
1302
  if (delay === void 0) { delay = 0; }
1304
1303
  if (this.closed) {
1305
1304
  return this;
@@ -1312,7 +1311,7 @@ var AsyncAction = (function (_super) {
1312
1311
  }
1313
1312
  this.pending = true;
1314
1313
  this.delay = delay;
1315
- this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay);
1314
+ this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
1316
1315
  return this;
1317
1316
  };
1318
1317
  AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) {
@@ -1324,9 +1323,7 @@ var AsyncAction = (function (_super) {
1324
1323
  if (delay != null && this.delay === delay && this.pending === false) {
1325
1324
  return id;
1326
1325
  }
1327
- if (id != null) {
1328
- intervalProvider.clearInterval(id);
1329
- }
1326
+ intervalProvider.clearInterval(id);
1330
1327
  return undefined;
1331
1328
  };
1332
1329
  AsyncAction.prototype.execute = function (state, delay) {
@@ -1402,6 +1399,7 @@ var AsyncScheduler = (function (_super) {
1402
1399
  var _this = _super.call(this, SchedulerAction, now) || this;
1403
1400
  _this.actions = [];
1404
1401
  _this._active = false;
1402
+ _this._scheduled = undefined;
1405
1403
  return _this;
1406
1404
  }
1407
1405
  AsyncScheduler.prototype.flush = function (action) {
@@ -1811,7 +1809,7 @@ function delayWhen(delayDurationSelector, subscriptionDelay) {
1811
1809
  return concat$1(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector)));
1812
1810
  };
1813
1811
  }
1814
- return mergeMap(function (value, index) { return innerFrom(delayDurationSelector(value, index)).pipe(take(1), mapTo(value)); });
1812
+ return mergeMap(function (value, index) { return delayDurationSelector(value, index).pipe(take(1), mapTo(value)); });
1815
1813
  }
1816
1814
 
1817
1815
  function delay(due, scheduler) {
@@ -2228,6 +2226,14 @@ function refreshAccessToken(url, login) {
2228
2226
  }
2229
2227
  function userAuthenticate(context, fetchToken, userInteraction, hints) {
2230
2228
  return __awaiter(this, void 0, void 0, function* () {
2229
+ if (!crypto.subtle) {
2230
+ if (typeof location !== 'undefined' && location.protocol === 'http:') {
2231
+ throw new Error(`Dexie Cloud Addon needs to use WebCrypto, but your browser has disabled it due to being served from an insecure location. Please serve it from https or http://localhost:<port> (See https://stackoverflow.com/questions/46670556/how-to-enable-crypto-subtle-for-unsecure-origins-in-chrome/46671627#46671627)`);
2232
+ }
2233
+ else {
2234
+ throw new Error(`This browser does not support WebCrypto.`);
2235
+ }
2236
+ }
2231
2237
  const { privateKey, publicKey } = yield crypto.subtle.generateKey({
2232
2238
  name: 'RSASSA-PKCS1-v1_5',
2233
2239
  modulusLength: 2048,
@@ -2273,7 +2279,7 @@ function userAuthenticate(context, fetchToken, userInteraction, hints) {
2273
2279
  type: 'error',
2274
2280
  messageCode: 'GENERIC_ERROR',
2275
2281
  message: `We're having a problem authenticating right now.`,
2276
- messageParams: {}
2282
+ messageParams: {},
2277
2283
  }).catch(() => { });
2278
2284
  throw error;
2279
2285
  }
@@ -2511,7 +2517,20 @@ function login(db, hints) {
2511
2517
  lastLogin: new Date(0),
2512
2518
  });
2513
2519
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
2514
- yield context.save();
2520
+ try {
2521
+ yield context.save();
2522
+ }
2523
+ catch (e) {
2524
+ try {
2525
+ if (e.name === 'DataCloneError') {
2526
+ console.debug(`Login context property names:`, Object.keys(context));
2527
+ console.debug(`Login context:`, context);
2528
+ console.debug(`Login context JSON:`, JSON.stringify(context));
2529
+ }
2530
+ }
2531
+ catch (_a) { }
2532
+ throw e;
2533
+ }
2515
2534
  yield setCurrentUser(db, context);
2516
2535
  // Make sure to resync as the new login will be authorized
2517
2536
  // for new realms.
@@ -5964,7 +5983,7 @@ function dexieCloud(dexie) {
5964
5983
  currentUserEmitter.next(UNAUTHORIZED_USER);
5965
5984
  });
5966
5985
  dexie.cloud = {
5967
- version: '4.0.1-beta.34',
5986
+ version: '4.0.1-beta.35',
5968
5987
  options: Object.assign({}, DEFAULT_OPTIONS),
5969
5988
  schema: null,
5970
5989
  get currentUserId() {
@@ -6219,7 +6238,7 @@ function dexieCloud(dexie) {
6219
6238
  });
6220
6239
  }
6221
6240
  }
6222
- dexieCloud.version = '4.0.1-beta.34';
6241
+ dexieCloud.version = '4.0.1-beta.35';
6223
6242
  Dexie.Cloud = dexieCloud;
6224
6243
 
6225
6244
  export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId };