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.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.0.1-beta.33, Sat Mar 11 2023
11
+ * Version 4.0.1-beta.35, Tue Apr 11 2023
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -2226,6 +2226,14 @@ function refreshAccessToken(url, login) {
2226
2226
  }
2227
2227
  function userAuthenticate(context, fetchToken, userInteraction, hints) {
2228
2228
  return __awaiter(this, void 0, void 0, function* () {
2229
+ if (!crypto.subtle) {
2230
+ if (typeof location !== 'undefined' && location.protocol === 'http:') {
2231
+ 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)`);
2232
+ }
2233
+ else {
2234
+ throw new Error(`This browser does not support WebCrypto.`);
2235
+ }
2236
+ }
2229
2237
  const { privateKey, publicKey } = yield crypto.subtle.generateKey({
2230
2238
  name: 'RSASSA-PKCS1-v1_5',
2231
2239
  modulusLength: 2048,
@@ -2271,7 +2279,7 @@ function userAuthenticate(context, fetchToken, userInteraction, hints) {
2271
2279
  type: 'error',
2272
2280
  messageCode: 'GENERIC_ERROR',
2273
2281
  message: `We're having a problem authenticating right now.`,
2274
- messageParams: {}
2282
+ messageParams: {},
2275
2283
  }).catch(() => { });
2276
2284
  throw error;
2277
2285
  }
@@ -2509,7 +2517,20 @@ function login(db, hints) {
2509
2517
  lastLogin: new Date(0),
2510
2518
  });
2511
2519
  yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
2512
- yield context.save();
2520
+ try {
2521
+ yield context.save();
2522
+ }
2523
+ catch (e) {
2524
+ try {
2525
+ if (e.name === 'DataCloneError') {
2526
+ console.debug(`Login context property names:`, Object.keys(context));
2527
+ console.debug(`Login context:`, context);
2528
+ console.debug(`Login context JSON:`, JSON.stringify(context));
2529
+ }
2530
+ }
2531
+ catch (_a) { }
2532
+ throw e;
2533
+ }
2513
2534
  yield setCurrentUser(db, context);
2514
2535
  // Make sure to resync as the new login will be authorized
2515
2536
  // for new realms.
@@ -5962,7 +5983,7 @@ function dexieCloud(dexie) {
5962
5983
  currentUserEmitter.next(UNAUTHORIZED_USER);
5963
5984
  });
5964
5985
  dexie.cloud = {
5965
- version: '4.0.1-beta.33',
5986
+ version: '4.0.1-beta.35',
5966
5987
  options: Object.assign({}, DEFAULT_OPTIONS),
5967
5988
  schema: null,
5968
5989
  get currentUserId() {
@@ -6217,7 +6238,7 @@ function dexieCloud(dexie) {
6217
6238
  });
6218
6239
  }
6219
6240
  }
6220
- dexieCloud.version = '4.0.1-beta.33';
6241
+ dexieCloud.version = '4.0.1-beta.35';
6221
6242
  Dexie.Cloud = dexieCloud;
6222
6243
 
6223
6244
  export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId };