dexie-cloud-addon 4.3.6 → 4.3.7

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.
@@ -21,6 +21,8 @@ export interface LoginHints {
21
21
  provider?: string;
22
22
  /** Dexie Cloud authorization code received from OAuth callback */
23
23
  oauthCode?: string;
24
+ /** Optional redirect path (relative or absolute) to use for OAuth redirect URI. */
25
+ redirectPath?: string;
24
26
  }
25
27
  export interface DexieCloudAPI {
26
28
  version: string;
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.3.6, Wed Jan 28 2026
11
+ * Version 4.3.7, Wed Jan 28 2026
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -1517,7 +1517,21 @@ function otpFetchTokenCallback(db) {
1517
1517
  }
1518
1518
  // Handle OAuth provider login via redirect
1519
1519
  if (hints === null || hints === void 0 ? void 0 : hints.provider) {
1520
- initiateOAuthRedirect(db, hints.provider);
1520
+ let resolvedRedirectUri = undefined;
1521
+ if (hints.redirectPath) {
1522
+ // If redirectPath is absolute, use as is. If relative, resolve against current location
1523
+ if (/^https?:\/\//i.test(hints.redirectPath)) {
1524
+ resolvedRedirectUri = hints.redirectPath;
1525
+ }
1526
+ else if (typeof window !== 'undefined' && window.location) {
1527
+ // Use URL constructor to resolve relative path
1528
+ resolvedRedirectUri = new URL(hints.redirectPath, window.location.href).toString();
1529
+ }
1530
+ else if (typeof location !== 'undefined' && location.href) {
1531
+ resolvedRedirectUri = new URL(hints.redirectPath, location.href).toString();
1532
+ }
1533
+ }
1534
+ initiateOAuthRedirect(db, hints.provider, resolvedRedirectUri);
1521
1535
  // This function never returns - page navigates away
1522
1536
  throw new OAuthRedirectError(hints.provider);
1523
1537
  }
@@ -1662,12 +1676,13 @@ function otpFetchTokenCallback(db) {
1662
1676
  * the user is redirected back with a dxc-auth query parameter that is
1663
1677
  * automatically detected by db.cloud.configure().
1664
1678
  */
1665
- function initiateOAuthRedirect(db, provider) {
1679
+ function initiateOAuthRedirect(db, provider, redirectUriOverride) {
1666
1680
  var _a, _b;
1667
1681
  const url = (_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.databaseUrl;
1668
1682
  if (!url)
1669
1683
  throw new Error(`No database URL given.`);
1670
- const redirectUri = ((_b = db.cloud.options) === null || _b === void 0 ? void 0 : _b.oauthRedirectUri) ||
1684
+ const redirectUri = redirectUriOverride ||
1685
+ ((_b = db.cloud.options) === null || _b === void 0 ? void 0 : _b.oauthRedirectUri) ||
1671
1686
  (typeof location !== 'undefined' ? location.href : undefined);
1672
1687
  // CodeRabbit suggested to fail fast here, but the only situation where
1673
1688
  // redirectUri would be undefined is in non-browser environments, and
@@ -6859,7 +6874,7 @@ function dexieCloud(dexie) {
6859
6874
  const syncComplete = new Subject();
6860
6875
  dexie.cloud = {
6861
6876
  // @ts-ignore
6862
- version: "4.3.6",
6877
+ version: "4.3.7",
6863
6878
  options: Object.assign({}, DEFAULT_OPTIONS),
6864
6879
  schema: null,
6865
6880
  get currentUserId() {
@@ -7244,7 +7259,7 @@ function dexieCloud(dexie) {
7244
7259
  }
7245
7260
  }
7246
7261
  // @ts-ignore
7247
- dexieCloud.version = "4.3.6";
7262
+ dexieCloud.version = "4.3.7";
7248
7263
  Dexie.Cloud = dexieCloud;
7249
7264
 
7250
7265
  export { dexieCloud as default, defineYDocTrigger, dexieCloud, getTiedObjectId, getTiedRealmId, resolveText };