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.
@@ -1,7 +1,7 @@
1
1
  import Dexie, { cmp, liveQuery } from 'dexie';
2
2
  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';
3
3
 
4
- /*! *****************************************************************************
4
+ /******************************************************************************
5
5
  Copyright (c) Microsoft Corporation.
6
6
 
7
7
  Permission to use, copy, modify, and/or distribute this software for any
@@ -106,7 +106,7 @@ function __spreadArray(to, from, pack) {
106
106
  ar[i] = from[i];
107
107
  }
108
108
  }
109
- return to.concat(ar || from);
109
+ return to.concat(ar || Array.prototype.slice.call(from));
110
110
  }
111
111
 
112
112
  function __await(v) {
@@ -1089,7 +1089,6 @@ var AsyncAction = (function (_super) {
1089
1089
  return _this;
1090
1090
  }
1091
1091
  AsyncAction.prototype.schedule = function (state, delay) {
1092
- var _a;
1093
1092
  if (delay === void 0) { delay = 0; }
1094
1093
  if (this.closed) {
1095
1094
  return this;
@@ -1102,7 +1101,7 @@ var AsyncAction = (function (_super) {
1102
1101
  }
1103
1102
  this.pending = true;
1104
1103
  this.delay = delay;
1105
- this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay);
1104
+ this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
1106
1105
  return this;
1107
1106
  };
1108
1107
  AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) {
@@ -1114,9 +1113,7 @@ var AsyncAction = (function (_super) {
1114
1113
  if (delay != null && this.delay === delay && this.pending === false) {
1115
1114
  return id;
1116
1115
  }
1117
- if (id != null) {
1118
- intervalProvider.clearInterval(id);
1119
- }
1116
+ intervalProvider.clearInterval(id);
1120
1117
  return undefined;
1121
1118
  };
1122
1119
  AsyncAction.prototype.execute = function (state, delay) {
@@ -1192,6 +1189,7 @@ var AsyncScheduler = (function (_super) {
1192
1189
  var _this = _super.call(this, SchedulerAction, now) || this;
1193
1190
  _this.actions = [];
1194
1191
  _this._active = false;
1192
+ _this._scheduled = undefined;
1195
1193
  return _this;
1196
1194
  }
1197
1195
  AsyncScheduler.prototype.flush = function (action) {
@@ -1601,7 +1599,7 @@ function delayWhen(delayDurationSelector, subscriptionDelay) {
1601
1599
  return concat$1(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector)));
1602
1600
  };
1603
1601
  }
1604
- return mergeMap(function (value, index) { return innerFrom(delayDurationSelector(value, index)).pipe(take(1), mapTo(value)); });
1602
+ return mergeMap(function (value, index) { return delayDurationSelector(value, index).pipe(take(1), mapTo(value)); });
1605
1603
  }
1606
1604
 
1607
1605
  function delay(due, scheduler) {
@@ -2485,6 +2483,14 @@ function refreshAccessToken(url, login) {
2485
2483
  }
2486
2484
  function userAuthenticate(context, fetchToken, userInteraction, hints) {
2487
2485
  return __awaiter(this, void 0, void 0, function* () {
2486
+ if (!crypto.subtle) {
2487
+ if (typeof location !== 'undefined' && location.protocol === 'http:') {
2488
+ 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)`);
2489
+ }
2490
+ else {
2491
+ throw new Error(`This browser does not support WebCrypto.`);
2492
+ }
2493
+ }
2488
2494
  const { privateKey, publicKey } = yield crypto.subtle.generateKey({
2489
2495
  name: 'RSASSA-PKCS1-v1_5',
2490
2496
  modulusLength: 2048,
@@ -2530,7 +2536,7 @@ function userAuthenticate(context, fetchToken, userInteraction, hints) {
2530
2536
  type: 'error',
2531
2537
  messageCode: 'GENERIC_ERROR',
2532
2538
  message: `We're having a problem authenticating right now.`,
2533
- messageParams: {}
2539
+ messageParams: {},
2534
2540
  }).catch(() => { });
2535
2541
  throw error;
2536
2542
  }
@@ -4179,7 +4185,20 @@ function login(db, hints) {
4179
4185
  lastLogin: new Date(0),
4180
4186
  });
4181
4187
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
4182
- yield context.save();
4188
+ try {
4189
+ yield context.save();
4190
+ }
4191
+ catch (e) {
4192
+ try {
4193
+ if (e.name === 'DataCloneError') {
4194
+ console.debug(`Login context property names:`, Object.keys(context));
4195
+ console.debug(`Login context:`, context);
4196
+ console.debug(`Login context JSON:`, JSON.stringify(context));
4197
+ }
4198
+ }
4199
+ catch (_a) { }
4200
+ throw e;
4201
+ }
4183
4202
  yield setCurrentUser(db, context);
4184
4203
  // Make sure to resync as the new login will be authorized
4185
4204
  // for new realms.
@@ -5939,7 +5958,7 @@ function dexieCloud(dexie) {
5939
5958
  currentUserEmitter.next(UNAUTHORIZED_USER);
5940
5959
  });
5941
5960
  dexie.cloud = {
5942
- version: '4.0.1-beta.34',
5961
+ version: '4.0.1-beta.35',
5943
5962
  options: Object.assign({}, DEFAULT_OPTIONS),
5944
5963
  schema: null,
5945
5964
  get currentUserId() {
@@ -6194,7 +6213,7 @@ function dexieCloud(dexie) {
6194
6213
  });
6195
6214
  }
6196
6215
  }
6197
- dexieCloud.version = '4.0.1-beta.34';
6216
+ dexieCloud.version = '4.0.1-beta.35';
6198
6217
  Dexie.Cloud = dexieCloud;
6199
6218
 
6200
6219
  // In case the SW lives for a while, let it reuse already opened connections: