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.
@@ -26,7 +26,7 @@
26
26
 
27
27
  var Dexie__default = /*#__PURE__*/_interopDefaultLegacy(Dexie);
28
28
 
29
- /*! *****************************************************************************
29
+ /******************************************************************************
30
30
  Copyright (c) Microsoft Corporation.
31
31
 
32
32
  Permission to use, copy, modify, and/or distribute this software for any
@@ -131,7 +131,7 @@
131
131
  ar[i] = from[i];
132
132
  }
133
133
  }
134
- return to.concat(ar || from);
134
+ return to.concat(ar || Array.prototype.slice.call(from));
135
135
  }
136
136
 
137
137
  function __await(v) {
@@ -1306,7 +1306,6 @@
1306
1306
  return _this;
1307
1307
  }
1308
1308
  AsyncAction.prototype.schedule = function (state, delay) {
1309
- var _a;
1310
1309
  if (delay === void 0) { delay = 0; }
1311
1310
  if (this.closed) {
1312
1311
  return this;
@@ -1319,7 +1318,7 @@
1319
1318
  }
1320
1319
  this.pending = true;
1321
1320
  this.delay = delay;
1322
- this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay);
1321
+ this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
1323
1322
  return this;
1324
1323
  };
1325
1324
  AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) {
@@ -1331,9 +1330,7 @@
1331
1330
  if (delay != null && this.delay === delay && this.pending === false) {
1332
1331
  return id;
1333
1332
  }
1334
- if (id != null) {
1335
- intervalProvider.clearInterval(id);
1336
- }
1333
+ intervalProvider.clearInterval(id);
1337
1334
  return undefined;
1338
1335
  };
1339
1336
  AsyncAction.prototype.execute = function (state, delay) {
@@ -1409,6 +1406,7 @@
1409
1406
  var _this = _super.call(this, SchedulerAction, now) || this;
1410
1407
  _this.actions = [];
1411
1408
  _this._active = false;
1409
+ _this._scheduled = undefined;
1412
1410
  return _this;
1413
1411
  }
1414
1412
  AsyncScheduler.prototype.flush = function (action) {
@@ -1818,7 +1816,7 @@
1818
1816
  return concat$1(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector)));
1819
1817
  };
1820
1818
  }
1821
- return mergeMap(function (value, index) { return innerFrom(delayDurationSelector(value, index)).pipe(take(1), mapTo(value)); });
1819
+ return mergeMap(function (value, index) { return delayDurationSelector(value, index).pipe(take(1), mapTo(value)); });
1822
1820
  }
1823
1821
 
1824
1822
  function delay(due, scheduler) {
@@ -2235,6 +2233,14 @@
2235
2233
  }
2236
2234
  function userAuthenticate(context, fetchToken, userInteraction, hints) {
2237
2235
  return __awaiter(this, void 0, void 0, function* () {
2236
+ if (!crypto.subtle) {
2237
+ if (typeof location !== 'undefined' && location.protocol === 'http:') {
2238
+ 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)`);
2239
+ }
2240
+ else {
2241
+ throw new Error(`This browser does not support WebCrypto.`);
2242
+ }
2243
+ }
2238
2244
  const { privateKey, publicKey } = yield crypto.subtle.generateKey({
2239
2245
  name: 'RSASSA-PKCS1-v1_5',
2240
2246
  modulusLength: 2048,
@@ -2280,7 +2286,7 @@
2280
2286
  type: 'error',
2281
2287
  messageCode: 'GENERIC_ERROR',
2282
2288
  message: `We're having a problem authenticating right now.`,
2283
- messageParams: {}
2289
+ messageParams: {},
2284
2290
  }).catch(() => { });
2285
2291
  throw error;
2286
2292
  }
@@ -2518,7 +2524,20 @@
2518
2524
  lastLogin: new Date(0),
2519
2525
  });
2520
2526
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
2521
- yield context.save();
2527
+ try {
2528
+ yield context.save();
2529
+ }
2530
+ catch (e) {
2531
+ try {
2532
+ if (e.name === 'DataCloneError') {
2533
+ console.debug(`Login context property names:`, Object.keys(context));
2534
+ console.debug(`Login context:`, context);
2535
+ console.debug(`Login context JSON:`, JSON.stringify(context));
2536
+ }
2537
+ }
2538
+ catch (_a) { }
2539
+ throw e;
2540
+ }
2522
2541
  yield setCurrentUser(db, context);
2523
2542
  // Make sure to resync as the new login will be authorized
2524
2543
  // for new realms.