dexie-cloud-addon 4.3.6 → 4.3.8

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.6, Wed Jan 28 2026
11
+ * Version 4.3.8, Thu Jan 29 2026
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -13207,7 +13207,7 @@
13207
13207
  *
13208
13208
  * ==========================================================================
13209
13209
  *
13210
- * Version 4.2.2, Wed Jan 28 2026
13210
+ * Version 4.2.2, Thu Jan 29 2026
13211
13211
  *
13212
13212
  * https://dexie.org
13213
13213
  *
@@ -14809,7 +14809,21 @@
14809
14809
  }
14810
14810
  // Handle OAuth provider login via redirect
14811
14811
  if (hints === null || hints === void 0 ? void 0 : hints.provider) {
14812
- initiateOAuthRedirect(db, hints.provider);
14812
+ let resolvedRedirectUri = undefined;
14813
+ if (hints.redirectPath) {
14814
+ // If redirectPath is absolute, use as is. If relative, resolve against current location
14815
+ if (/^https?:\/\//i.test(hints.redirectPath)) {
14816
+ resolvedRedirectUri = hints.redirectPath;
14817
+ }
14818
+ else if (typeof window !== 'undefined' && window.location) {
14819
+ // Use URL constructor to resolve relative path
14820
+ resolvedRedirectUri = new URL(hints.redirectPath, window.location.href).toString();
14821
+ }
14822
+ else if (typeof location !== 'undefined' && location.href) {
14823
+ resolvedRedirectUri = new URL(hints.redirectPath, location.href).toString();
14824
+ }
14825
+ }
14826
+ initiateOAuthRedirect(db, hints.provider, resolvedRedirectUri);
14813
14827
  // This function never returns - page navigates away
14814
14828
  throw new OAuthRedirectError(hints.provider);
14815
14829
  }
@@ -14954,12 +14968,13 @@
14954
14968
  * the user is redirected back with a dxc-auth query parameter that is
14955
14969
  * automatically detected by db.cloud.configure().
14956
14970
  */
14957
- function initiateOAuthRedirect(db, provider) {
14971
+ function initiateOAuthRedirect(db, provider, redirectUriOverride) {
14958
14972
  var _a, _b;
14959
14973
  const url = (_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.databaseUrl;
14960
14974
  if (!url)
14961
14975
  throw new Error(`No database URL given.`);
14962
- const redirectUri = ((_b = db.cloud.options) === null || _b === void 0 ? void 0 : _b.oauthRedirectUri) ||
14976
+ const redirectUri = redirectUriOverride ||
14977
+ ((_b = db.cloud.options) === null || _b === void 0 ? void 0 : _b.oauthRedirectUri) ||
14963
14978
  (typeof location !== 'undefined' ? location.href : undefined);
14964
14979
  // CodeRabbit suggested to fail fast here, but the only situation where
14965
14980
  // redirectUri would be undefined is in non-browser environments, and
@@ -17283,7 +17298,9 @@
17283
17298
  };
17284
17299
  }
17285
17300
 
17286
- const getCurrentUserEmitter = associate((db) => new rxjs.BehaviorSubject(UNAUTHORIZED_USER));
17301
+ const isOathCallback = typeof location !== 'undefined' && !!(new URL(location.href)).searchParams.get('dxc-auth');
17302
+ const getCurrentUserEmitter = associate((db) => new rxjs.BehaviorSubject(isOathCallback
17303
+ ? Object.assign(Object.assign({}, UNAUTHORIZED_USER), { oauthInProgress: true }) : UNAUTHORIZED_USER));
17287
17304
 
17288
17305
  function computeSyncState(db) {
17289
17306
  let _prevStatus = db.cloud.webSocketStatus.value;
@@ -17918,7 +17935,7 @@
17918
17935
  const syncComplete = new rxjs.Subject();
17919
17936
  dexie.cloud = {
17920
17937
  // @ts-ignore
17921
- version: "4.3.6",
17938
+ version: "4.3.8",
17922
17939
  options: Object.assign({}, DEFAULT_OPTIONS),
17923
17940
  schema: null,
17924
17941
  get currentUserId() {
@@ -17959,8 +17976,6 @@
17959
17976
  try {
17960
17977
  const callback = parseOAuthCallback();
17961
17978
  if (callback) {
17962
- // Clean up URL immediately (remove dxc-auth param)
17963
- cleanupOAuthUrl();
17964
17979
  // Store the pending auth code for processing when db is ready
17965
17980
  pendingOAuthCode = { code: callback.code, provider: callback.provider };
17966
17981
  console.debug('[dexie-cloud] OAuth callback detected, auth code stored for processing');
@@ -17968,7 +17983,6 @@
17968
17983
  }
17969
17984
  catch (error) {
17970
17985
  // parseOAuthCallback throws OAuthError on error callbacks
17971
- cleanupOAuthUrl();
17972
17986
  if (error instanceof OAuthError) {
17973
17987
  pendingOAuthError = error;
17974
17988
  console.error('[dexie-cloud] OAuth callback error:', error.message);
@@ -18196,6 +18210,9 @@
18196
18210
  message: error.message,
18197
18211
  messageParams: { provider: error.provider || 'unknown' }
18198
18212
  });
18213
+ // Clean up URL (remove dxc-auth param)
18214
+ cleanupOAuthUrl();
18215
+ currentUserEmitter.next(Object.assign(Object.assign({}, currentUserEmitter.value), { oauthInProgress: false }));
18199
18216
  }
18200
18217
  catch (uiError) {
18201
18218
  console.error('[dexie-cloud] Failed to show OAuth error alert:', uiError);
@@ -18209,6 +18226,8 @@
18209
18226
  try {
18210
18227
  changedUser = yield login(db, { oauthCode: code, provider });
18211
18228
  user = yield db.getCurrentUser();
18229
+ // Clean up URL (remove dxc-auth param)
18230
+ cleanupOAuthUrl();
18212
18231
  }
18213
18232
  catch (error) {
18214
18233
  console.error('[dexie-cloud] OAuth login failed:', error);
@@ -18303,7 +18322,7 @@
18303
18322
  }
18304
18323
  }
18305
18324
  // @ts-ignore
18306
- dexieCloud.version = "4.3.6";
18325
+ dexieCloud.version = "4.3.8";
18307
18326
  Dexie.Cloud = dexieCloud;
18308
18327
 
18309
18328
  // In case the SW lives for a while, let it reuse already opened connections: