dexie-cloud-addon 4.0.1-beta.33 → 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.
@@ -2490,6 +2490,14 @@
2490
2490
  }
2491
2491
  function userAuthenticate(context, fetchToken, userInteraction, hints) {
2492
2492
  return __awaiter(this, void 0, void 0, function* () {
2493
+ if (!crypto.subtle) {
2494
+ if (typeof location !== 'undefined' && location.protocol === 'http:') {
2495
+ 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)`);
2496
+ }
2497
+ else {
2498
+ throw new Error(`This browser does not support WebCrypto.`);
2499
+ }
2500
+ }
2493
2501
  const { privateKey, publicKey } = yield crypto.subtle.generateKey({
2494
2502
  name: 'RSASSA-PKCS1-v1_5',
2495
2503
  modulusLength: 2048,
@@ -2535,7 +2543,7 @@
2535
2543
  type: 'error',
2536
2544
  messageCode: 'GENERIC_ERROR',
2537
2545
  message: `We're having a problem authenticating right now.`,
2538
- messageParams: {}
2546
+ messageParams: {},
2539
2547
  }).catch(() => { });
2540
2548
  throw error;
2541
2549
  }
@@ -4184,7 +4192,20 @@
4184
4192
  lastLogin: new Date(0),
4185
4193
  });
4186
4194
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
4187
- yield context.save();
4195
+ try {
4196
+ yield context.save();
4197
+ }
4198
+ catch (e) {
4199
+ try {
4200
+ if (e.name === 'DataCloneError') {
4201
+ console.debug(`Login context property names:`, Object.keys(context));
4202
+ console.debug(`Login context:`, context);
4203
+ console.debug(`Login context JSON:`, JSON.stringify(context));
4204
+ }
4205
+ }
4206
+ catch (_a) { }
4207
+ throw e;
4208
+ }
4188
4209
  yield setCurrentUser(db, context);
4189
4210
  // Make sure to resync as the new login will be authorized
4190
4211
  // for new realms.
@@ -5944,7 +5965,7 @@
5944
5965
  currentUserEmitter.next(UNAUTHORIZED_USER);
5945
5966
  });
5946
5967
  dexie.cloud = {
5947
- version: '4.0.1-beta.33',
5968
+ version: '4.0.1-beta.35',
5948
5969
  options: Object.assign({}, DEFAULT_OPTIONS),
5949
5970
  schema: null,
5950
5971
  get currentUserId() {
@@ -6199,7 +6220,7 @@
6199
6220
  });
6200
6221
  }
6201
6222
  }
6202
- dexieCloud.version = '4.0.1-beta.33';
6223
+ dexieCloud.version = '4.0.1-beta.35';
6203
6224
  Dexie__default["default"].Cloud = dexieCloud;
6204
6225
 
6205
6226
  // In case the SW lives for a while, let it reuse already opened connections: