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.
@@ -2483,6 +2483,14 @@ function refreshAccessToken(url, login) {
2483
2483
  }
2484
2484
  function userAuthenticate(context, fetchToken, userInteraction, hints) {
2485
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
+ }
2486
2494
  const { privateKey, publicKey } = yield crypto.subtle.generateKey({
2487
2495
  name: 'RSASSA-PKCS1-v1_5',
2488
2496
  modulusLength: 2048,
@@ -2528,7 +2536,7 @@ function userAuthenticate(context, fetchToken, userInteraction, hints) {
2528
2536
  type: 'error',
2529
2537
  messageCode: 'GENERIC_ERROR',
2530
2538
  message: `We're having a problem authenticating right now.`,
2531
- messageParams: {}
2539
+ messageParams: {},
2532
2540
  }).catch(() => { });
2533
2541
  throw error;
2534
2542
  }
@@ -4177,7 +4185,20 @@ function login(db, hints) {
4177
4185
  lastLogin: new Date(0),
4178
4186
  });
4179
4187
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
4180
- 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
+ }
4181
4202
  yield setCurrentUser(db, context);
4182
4203
  // Make sure to resync as the new login will be authorized
4183
4204
  // for new realms.
@@ -5937,7 +5958,7 @@ function dexieCloud(dexie) {
5937
5958
  currentUserEmitter.next(UNAUTHORIZED_USER);
5938
5959
  });
5939
5960
  dexie.cloud = {
5940
- version: '4.0.1-beta.33',
5961
+ version: '4.0.1-beta.35',
5941
5962
  options: Object.assign({}, DEFAULT_OPTIONS),
5942
5963
  schema: null,
5943
5964
  get currentUserId() {
@@ -6192,7 +6213,7 @@ function dexieCloud(dexie) {
6192
6213
  });
6193
6214
  }
6194
6215
  }
6195
- dexieCloud.version = '4.0.1-beta.33';
6216
+ dexieCloud.version = '4.0.1-beta.35';
6196
6217
  Dexie.Cloud = dexieCloud;
6197
6218
 
6198
6219
  // In case the SW lives for a while, let it reuse already opened connections: