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.
@@ -2233,6 +2233,14 @@
2233
2233
  }
2234
2234
  function userAuthenticate(context, fetchToken, userInteraction, hints) {
2235
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
+ }
2236
2244
  const { privateKey, publicKey } = yield crypto.subtle.generateKey({
2237
2245
  name: 'RSASSA-PKCS1-v1_5',
2238
2246
  modulusLength: 2048,
@@ -2278,7 +2286,7 @@
2278
2286
  type: 'error',
2279
2287
  messageCode: 'GENERIC_ERROR',
2280
2288
  message: `We're having a problem authenticating right now.`,
2281
- messageParams: {}
2289
+ messageParams: {},
2282
2290
  }).catch(() => { });
2283
2291
  throw error;
2284
2292
  }
@@ -2516,7 +2524,20 @@
2516
2524
  lastLogin: new Date(0),
2517
2525
  });
2518
2526
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
2519
- 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
+ }
2520
2541
  yield setCurrentUser(db, context);
2521
2542
  // Make sure to resync as the new login will be authorized
2522
2543
  // for new realms.