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
  *
@@ -2817,7 +2817,21 @@
2817
2817
  }
2818
2818
  // Handle OAuth provider login via redirect
2819
2819
  if (hints === null || hints === void 0 ? void 0 : hints.provider) {
2820
- initiateOAuthRedirect(db, hints.provider);
2820
+ let resolvedRedirectUri = undefined;
2821
+ if (hints.redirectPath) {
2822
+ // If redirectPath is absolute, use as is. If relative, resolve against current location
2823
+ if (/^https?:\/\//i.test(hints.redirectPath)) {
2824
+ resolvedRedirectUri = hints.redirectPath;
2825
+ }
2826
+ else if (typeof window !== 'undefined' && window.location) {
2827
+ // Use URL constructor to resolve relative path
2828
+ resolvedRedirectUri = new URL(hints.redirectPath, window.location.href).toString();
2829
+ }
2830
+ else if (typeof location !== 'undefined' && location.href) {
2831
+ resolvedRedirectUri = new URL(hints.redirectPath, location.href).toString();
2832
+ }
2833
+ }
2834
+ initiateOAuthRedirect(db, hints.provider, resolvedRedirectUri);
2821
2835
  // This function never returns - page navigates away
2822
2836
  throw new OAuthRedirectError(hints.provider);
2823
2837
  }
@@ -2962,12 +2976,13 @@
2962
2976
  * the user is redirected back with a dxc-auth query parameter that is
2963
2977
  * automatically detected by db.cloud.configure().
2964
2978
  */
2965
- function initiateOAuthRedirect(db, provider) {
2979
+ function initiateOAuthRedirect(db, provider, redirectUriOverride) {
2966
2980
  var _a, _b;
2967
2981
  const url = (_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.databaseUrl;
2968
2982
  if (!url)
2969
2983
  throw new Error(`No database URL given.`);
2970
- const redirectUri = ((_b = db.cloud.options) === null || _b === void 0 ? void 0 : _b.oauthRedirectUri) ||
2984
+ const redirectUri = redirectUriOverride ||
2985
+ ((_b = db.cloud.options) === null || _b === void 0 ? void 0 : _b.oauthRedirectUri) ||
2971
2986
  (typeof location !== 'undefined' ? location.href : undefined);
2972
2987
  // CodeRabbit suggested to fail fast here, but the only situation where
2973
2988
  // redirectUri would be undefined is in non-browser environments, and
@@ -13778,7 +13793,7 @@
13778
13793
  *
13779
13794
  * ==========================================================================
13780
13795
  *
13781
- * Version 4.2.2, Wed Jan 28 2026
13796
+ * Version 4.2.2, Thu Jan 29 2026
13782
13797
  *
13783
13798
  * https://dexie.org
13784
13799
  *
@@ -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;
@@ -18089,7 +18106,7 @@
18089
18106
  const syncComplete = new rxjs.Subject();
18090
18107
  dexie.cloud = {
18091
18108
  // @ts-ignore
18092
- version: "4.3.6",
18109
+ version: "4.3.8",
18093
18110
  options: Object.assign({}, DEFAULT_OPTIONS),
18094
18111
  schema: null,
18095
18112
  get currentUserId() {
@@ -18130,8 +18147,6 @@
18130
18147
  try {
18131
18148
  const callback = parseOAuthCallback();
18132
18149
  if (callback) {
18133
- // Clean up URL immediately (remove dxc-auth param)
18134
- cleanupOAuthUrl();
18135
18150
  // Store the pending auth code for processing when db is ready
18136
18151
  pendingOAuthCode = { code: callback.code, provider: callback.provider };
18137
18152
  console.debug('[dexie-cloud] OAuth callback detected, auth code stored for processing');
@@ -18139,7 +18154,6 @@
18139
18154
  }
18140
18155
  catch (error) {
18141
18156
  // parseOAuthCallback throws OAuthError on error callbacks
18142
- cleanupOAuthUrl();
18143
18157
  if (error instanceof OAuthError) {
18144
18158
  pendingOAuthError = error;
18145
18159
  console.error('[dexie-cloud] OAuth callback error:', error.message);
@@ -18367,6 +18381,9 @@
18367
18381
  message: error.message,
18368
18382
  messageParams: { provider: error.provider || 'unknown' }
18369
18383
  });
18384
+ // Clean up URL (remove dxc-auth param)
18385
+ cleanupOAuthUrl();
18386
+ currentUserEmitter.next(Object.assign(Object.assign({}, currentUserEmitter.value), { oauthInProgress: false }));
18370
18387
  }
18371
18388
  catch (uiError) {
18372
18389
  console.error('[dexie-cloud] Failed to show OAuth error alert:', uiError);
@@ -18380,6 +18397,8 @@
18380
18397
  try {
18381
18398
  changedUser = yield login(db, { oauthCode: code, provider });
18382
18399
  user = yield db.getCurrentUser();
18400
+ // Clean up URL (remove dxc-auth param)
18401
+ cleanupOAuthUrl();
18383
18402
  }
18384
18403
  catch (error) {
18385
18404
  console.error('[dexie-cloud] OAuth login failed:', error);
@@ -18474,7 +18493,7 @@
18474
18493
  }
18475
18494
  }
18476
18495
  // @ts-ignore
18477
- dexieCloud.version = "4.3.6";
18496
+ dexieCloud.version = "4.3.8";
18478
18497
  Dexie.Cloud = dexieCloud;
18479
18498
 
18480
18499
  exports.default = dexieCloud;