dexie-cloud-addon 4.3.2 → 4.3.3

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.3.2, Thu Jan 22 2026
11
+ * Version 4.3.3, Thu Jan 22 2026
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -2709,6 +2709,21 @@
2709
2709
  });
2710
2710
  }
2711
2711
 
2712
+ /**
2713
+ * Error thrown when initiating an OAuth redirect.
2714
+ *
2715
+ * This is not a real error - it's used to signal that the page is
2716
+ * navigating away to an OAuth provider. It should be caught and
2717
+ * silently ignored at the appropriate level.
2718
+ */
2719
+ class OAuthRedirectError extends Error {
2720
+ constructor(provider) {
2721
+ super(`OAuth redirect initiated for provider: ${provider}`);
2722
+ this.name = 'OAuthRedirectError';
2723
+ this.provider = provider;
2724
+ }
2725
+ }
2726
+
2712
2727
  function loadAccessToken(db) {
2713
2728
  return __awaiter(this, void 0, void 0, function* () {
2714
2729
  var _a, _b, _c;
@@ -2876,6 +2891,10 @@
2876
2891
  return context;
2877
2892
  }
2878
2893
  catch (error) {
2894
+ // OAuth redirect is not an error - page is navigating away
2895
+ if (error instanceof OAuthRedirectError || (error === null || error === void 0 ? void 0 : error.name) === 'OAuthRedirectError') {
2896
+ throw error; // Re-throw without logging
2897
+ }
2879
2898
  if (error instanceof TokenErrorResponseError) {
2880
2899
  yield alertUser(userInteraction, error.title, {
2881
2900
  type: 'error',
@@ -14846,7 +14865,7 @@
14846
14865
  if (hints === null || hints === void 0 ? void 0 : hints.provider) {
14847
14866
  initiateOAuthRedirect(db, hints.provider);
14848
14867
  // This function never returns - page navigates away
14849
- throw new Error('OAuth redirect initiated');
14868
+ throw new OAuthRedirectError(hints.provider);
14850
14869
  }
14851
14870
  if ((hints === null || hints === void 0 ? void 0 : hints.grant_type) === 'demo') {
14852
14871
  const demo_user = yield promptForEmail(userInteraction, 'Enter a demo user email', (hints === null || hints === void 0 ? void 0 : hints.email) || (hints === null || hints === void 0 ? void 0 : hints.userId));
@@ -14881,7 +14900,7 @@
14881
14900
  // User selected an OAuth provider - initiate redirect
14882
14901
  initiateOAuthRedirect(db, selection.provider);
14883
14902
  // This function never returns - page navigates away
14884
- throw new Error('OAuth redirect initiated');
14903
+ throw new OAuthRedirectError(selection.provider);
14885
14904
  }
14886
14905
  // User chose OTP - continue with email prompt below
14887
14906
  }
@@ -15070,7 +15089,15 @@
15070
15089
  claims: {},
15071
15090
  lastLogin: new Date(0),
15072
15091
  });
15073
- yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
15092
+ try {
15093
+ yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
15094
+ }
15095
+ catch (err) {
15096
+ if (err.name === 'OAuthRedirectError') {
15097
+ return false; // Page is redirecting for OAuth login
15098
+ }
15099
+ throw err;
15100
+ }
15074
15101
  if (origUserId !== UNAUTHORIZED_USER.userId &&
15075
15102
  context.userId !== origUserId) {
15076
15103
  // User was logged in before, but now logged in as another user.
@@ -17234,7 +17261,7 @@
17234
17261
  } }))))))),
17235
17262
  _$1("div", { style: Styles.ButtonsDiv },
17236
17263
  _$1(k$1, null,
17237
- hasFields && submitLabel && (_$1("button", { type: "submit", style: Styles.PrimaryButton, onClick: () => onSubmit(params) }, submitLabel)),
17264
+ submitLabel && (hasFields || (!hasOptions && !hasFields)) && (_$1("button", { type: "submit", style: Styles.PrimaryButton, onClick: () => onSubmit(params) }, submitLabel)),
17238
17265
  cancelLabel && (_$1("button", { style: Styles.Button, onClick: onCancel }, cancelLabel))))));
17239
17266
  }
17240
17267
  function valueTransformer(type, value) {
@@ -17916,6 +17943,8 @@
17916
17943
  let configuredProgramatically = false;
17917
17944
  // Pending OAuth auth code from dxc-auth redirect (detected in configure())
17918
17945
  let pendingOAuthCode = null;
17946
+ // Pending OAuth error from dxc-auth redirect (detected in configure())
17947
+ let pendingOAuthError = null;
17919
17948
  // local sync worker - used when there's no service worker.
17920
17949
  let localSyncWorker = null;
17921
17950
  dexie.on('ready', (dexie) => __awaiter(this, void 0, void 0, function* () {
@@ -17945,7 +17974,7 @@
17945
17974
  const syncComplete = new rxjs.Subject();
17946
17975
  dexie.cloud = {
17947
17976
  // @ts-ignore
17948
- version: "4.3.2",
17977
+ version: "4.3.3",
17949
17978
  options: Object.assign({}, DEFAULT_OPTIONS),
17950
17979
  schema: null,
17951
17980
  get currentUserId() {
@@ -17995,9 +18024,14 @@
17995
18024
  }
17996
18025
  catch (error) {
17997
18026
  // parseOAuthCallback throws OAuthError on error callbacks
17998
- // Store null for code but log the error
17999
- console.warn('[dexie-cloud] OAuth callback error:', error);
18000
18027
  cleanupOAuthUrl();
18028
+ if (error instanceof OAuthError) {
18029
+ pendingOAuthError = error;
18030
+ console.error('[dexie-cloud] OAuth callback error:', error.message);
18031
+ }
18032
+ else {
18033
+ console.error('[dexie-cloud] OAuth callback error:', error);
18034
+ }
18001
18035
  }
18002
18036
  }
18003
18037
  },
@@ -18193,7 +18227,20 @@
18193
18227
  }
18194
18228
  // HERE: If requireAuth, do athentication now.
18195
18229
  let changedUser = false;
18196
- const user = yield db.getCurrentUser();
18230
+ let user = yield db.getCurrentUser();
18231
+ // Show pending OAuth error if present (from dxc-auth redirect)
18232
+ if (pendingOAuthError && !db.cloud.isServiceWorkerDB) {
18233
+ const error = pendingOAuthError;
18234
+ pendingOAuthError = null; // Clear pending error
18235
+ console.debug('[dexie-cloud] Showing OAuth error:', error.message);
18236
+ // Show alert to user about the OAuth error
18237
+ yield alertUser(db.cloud.userInteraction, 'Authentication Error', {
18238
+ type: 'error',
18239
+ messageCode: 'GENERIC_ERROR',
18240
+ message: error.message,
18241
+ messageParams: { provider: error.provider || 'unknown' }
18242
+ });
18243
+ }
18197
18244
  // Process pending OAuth callback if present (from dxc-auth redirect)
18198
18245
  if (pendingOAuthCode && !db.cloud.isServiceWorkerDB) {
18199
18246
  const { code, provider } = pendingOAuthCode;
@@ -18201,6 +18248,7 @@
18201
18248
  console.debug('[dexie-cloud] Processing OAuth callback, provider:', provider);
18202
18249
  try {
18203
18250
  changedUser = yield login(db, { oauthCode: code, provider });
18251
+ user = yield db.getCurrentUser();
18204
18252
  }
18205
18253
  catch (error) {
18206
18254
  console.error('[dexie-cloud] OAuth login failed:', error);
@@ -18295,7 +18343,7 @@
18295
18343
  }
18296
18344
  }
18297
18345
  // @ts-ignore
18298
- dexieCloud.version = "4.3.2";
18346
+ dexieCloud.version = "4.3.3";
18299
18347
  Dexie.Cloud = dexieCloud;
18300
18348
 
18301
18349
  // In case the SW lives for a while, let it reuse already opened connections: