@dream-api/sdk 0.1.33 → 0.1.34

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.
package/dist/index.d.mts CHANGED
@@ -325,6 +325,11 @@ declare class AuthHelpers {
325
325
  getCustomerPortalUrl(options?: {
326
326
  returnUrl?: string;
327
327
  }): string;
328
+ /**
329
+ * Convert a relative path to an absolute URL using current origin.
330
+ * Already-absolute URLs are returned unchanged.
331
+ */
332
+ private makeAbsoluteUrl;
328
333
  }
329
334
 
330
335
  /**
package/dist/index.d.ts CHANGED
@@ -325,6 +325,11 @@ declare class AuthHelpers {
325
325
  getCustomerPortalUrl(options?: {
326
326
  returnUrl?: string;
327
327
  }): string;
328
+ /**
329
+ * Convert a relative path to an absolute URL using current origin.
330
+ * Already-absolute URLs are returned unchanged.
331
+ */
332
+ private makeAbsoluteUrl;
328
333
  }
329
334
 
330
335
  /**
package/dist/index.js CHANGED
@@ -478,9 +478,10 @@ var AuthHelpers = class {
478
478
  throw new Error("DreamAPI: publishableKey required for auth URLs");
479
479
  }
480
480
  const baseUrl = this.client.getSignupBaseUrl();
481
+ const redirectUrl = this.makeAbsoluteUrl(options.redirect);
481
482
  const params = new URLSearchParams({
482
483
  pk,
483
- redirect: options.redirect
484
+ redirect: redirectUrl
484
485
  });
485
486
  return `${baseUrl}/signup?${params.toString()}`;
486
487
  }
@@ -502,9 +503,10 @@ var AuthHelpers = class {
502
503
  throw new Error("DreamAPI: publishableKey required for auth URLs");
503
504
  }
504
505
  const baseUrl = this.client.getSignupBaseUrl();
506
+ const redirectUrl = this.makeAbsoluteUrl(options.redirect);
505
507
  const params = new URLSearchParams({
506
508
  pk,
507
- redirect: options.redirect
509
+ redirect: redirectUrl
508
510
  });
509
511
  return `${baseUrl}/signin?${params.toString()}`;
510
512
  }
@@ -530,12 +532,26 @@ var AuthHelpers = class {
530
532
  }
531
533
  const baseUrl = this.client.getSignupBaseUrl();
532
534
  const returnUrl = options?.returnUrl || (typeof window !== "undefined" ? window.location.href : "/");
535
+ const redirectUrl = this.makeAbsoluteUrl(returnUrl);
533
536
  const params = new URLSearchParams({
534
537
  pk,
535
- redirect: returnUrl
538
+ redirect: redirectUrl
536
539
  });
537
540
  return `${baseUrl}/account?${params.toString()}`;
538
541
  }
542
+ /**
543
+ * Convert a relative path to an absolute URL using current origin.
544
+ * Already-absolute URLs are returned unchanged.
545
+ */
546
+ makeAbsoluteUrl(path) {
547
+ if (path.startsWith("http://") || path.startsWith("https://")) {
548
+ return path;
549
+ }
550
+ if (typeof window !== "undefined") {
551
+ return new URL(path, window.location.origin).toString();
552
+ }
553
+ return path;
554
+ }
539
555
  };
540
556
 
541
557
  // src/index.ts
package/dist/index.mjs CHANGED
@@ -450,9 +450,10 @@ var AuthHelpers = class {
450
450
  throw new Error("DreamAPI: publishableKey required for auth URLs");
451
451
  }
452
452
  const baseUrl = this.client.getSignupBaseUrl();
453
+ const redirectUrl = this.makeAbsoluteUrl(options.redirect);
453
454
  const params = new URLSearchParams({
454
455
  pk,
455
- redirect: options.redirect
456
+ redirect: redirectUrl
456
457
  });
457
458
  return `${baseUrl}/signup?${params.toString()}`;
458
459
  }
@@ -474,9 +475,10 @@ var AuthHelpers = class {
474
475
  throw new Error("DreamAPI: publishableKey required for auth URLs");
475
476
  }
476
477
  const baseUrl = this.client.getSignupBaseUrl();
478
+ const redirectUrl = this.makeAbsoluteUrl(options.redirect);
477
479
  const params = new URLSearchParams({
478
480
  pk,
479
- redirect: options.redirect
481
+ redirect: redirectUrl
480
482
  });
481
483
  return `${baseUrl}/signin?${params.toString()}`;
482
484
  }
@@ -502,12 +504,26 @@ var AuthHelpers = class {
502
504
  }
503
505
  const baseUrl = this.client.getSignupBaseUrl();
504
506
  const returnUrl = options?.returnUrl || (typeof window !== "undefined" ? window.location.href : "/");
507
+ const redirectUrl = this.makeAbsoluteUrl(returnUrl);
505
508
  const params = new URLSearchParams({
506
509
  pk,
507
- redirect: returnUrl
510
+ redirect: redirectUrl
508
511
  });
509
512
  return `${baseUrl}/account?${params.toString()}`;
510
513
  }
514
+ /**
515
+ * Convert a relative path to an absolute URL using current origin.
516
+ * Already-absolute URLs are returned unchanged.
517
+ */
518
+ makeAbsoluteUrl(path) {
519
+ if (path.startsWith("http://") || path.startsWith("https://")) {
520
+ return path;
521
+ }
522
+ if (typeof window !== "undefined") {
523
+ return new URL(path, window.location.origin).toString();
524
+ }
525
+ return path;
526
+ }
511
527
  };
512
528
 
513
529
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dream-api/sdk",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "description": "Official SDK for Dream API - Auth, billing, and usage tracking in one API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",