@dream-api/sdk 0.1.29 → 0.1.30

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
@@ -297,8 +297,8 @@ declare class AuthHelpers {
297
297
  /**
298
298
  * Get the sign-in URL for returning users.
299
299
  *
300
- * Redirects to Clerk's hosted sign-in page. After sign-in,
301
- * users are redirected to your specified URL.
300
+ * Redirects to our auth worker which embeds Clerk. After sign-in,
301
+ * users are redirected to your specified URL with JWT.
302
302
  *
303
303
  * @example
304
304
  * ```typescript
@@ -310,19 +310,21 @@ declare class AuthHelpers {
310
310
  /**
311
311
  * Get the customer portal URL for account management.
312
312
  *
313
- * Redirects to Clerk's hosted account page where users can
314
- * manage their profile, password, and security settings.
313
+ * Redirects to our auth worker which embeds Clerk's UserProfile.
314
+ * Users can manage their profile, password, and security settings.
315
315
  *
316
316
  * Note: This is separate from billing management.
317
317
  * For billing, use api.billing.openPortal().
318
318
  *
319
319
  * @example
320
320
  * ```typescript
321
- * const portalUrl = api.auth.getCustomerPortalUrl();
321
+ * const portalUrl = api.auth.getCustomerPortalUrl({ returnUrl: '/dashboard' });
322
322
  * window.location.href = portalUrl;
323
323
  * ```
324
324
  */
325
- getCustomerPortalUrl(): string;
325
+ getCustomerPortalUrl(options?: {
326
+ returnUrl?: string;
327
+ }): string;
326
328
  }
327
329
 
328
330
  /**
package/dist/index.d.ts CHANGED
@@ -297,8 +297,8 @@ declare class AuthHelpers {
297
297
  /**
298
298
  * Get the sign-in URL for returning users.
299
299
  *
300
- * Redirects to Clerk's hosted sign-in page. After sign-in,
301
- * users are redirected to your specified URL.
300
+ * Redirects to our auth worker which embeds Clerk. After sign-in,
301
+ * users are redirected to your specified URL with JWT.
302
302
  *
303
303
  * @example
304
304
  * ```typescript
@@ -310,19 +310,21 @@ declare class AuthHelpers {
310
310
  /**
311
311
  * Get the customer portal URL for account management.
312
312
  *
313
- * Redirects to Clerk's hosted account page where users can
314
- * manage their profile, password, and security settings.
313
+ * Redirects to our auth worker which embeds Clerk's UserProfile.
314
+ * Users can manage their profile, password, and security settings.
315
315
  *
316
316
  * Note: This is separate from billing management.
317
317
  * For billing, use api.billing.openPortal().
318
318
  *
319
319
  * @example
320
320
  * ```typescript
321
- * const portalUrl = api.auth.getCustomerPortalUrl();
321
+ * const portalUrl = api.auth.getCustomerPortalUrl({ returnUrl: '/dashboard' });
322
322
  * window.location.href = portalUrl;
323
323
  * ```
324
324
  */
325
- getCustomerPortalUrl(): string;
325
+ getCustomerPortalUrl(options?: {
326
+ returnUrl?: string;
327
+ }): string;
326
328
  }
327
329
 
328
330
  /**
package/dist/index.js CHANGED
@@ -486,8 +486,8 @@ var AuthHelpers = class {
486
486
  /**
487
487
  * Get the sign-in URL for returning users.
488
488
  *
489
- * Redirects to Clerk's hosted sign-in page. After sign-in,
490
- * users are redirected to your specified URL.
489
+ * Redirects to our auth worker which embeds Clerk. After sign-in,
490
+ * users are redirected to your specified URL with JWT.
491
491
  *
492
492
  * @example
493
493
  * ```typescript
@@ -496,27 +496,44 @@ var AuthHelpers = class {
496
496
  * ```
497
497
  */
498
498
  getSignInUrl(options) {
499
- const clerkBaseUrl = this.client.getClerkBaseUrl();
500
- return `${clerkBaseUrl}/sign-in?redirect_url=${encodeURIComponent(options.redirect)}`;
499
+ const pk = this.client.getPublishableKey();
500
+ if (!pk) {
501
+ throw new Error("DreamAPI: publishableKey required for auth URLs");
502
+ }
503
+ const baseUrl = this.client.getSignupBaseUrl();
504
+ const params = new URLSearchParams({
505
+ pk,
506
+ redirect: options.redirect
507
+ });
508
+ return `${baseUrl}/signin?${params.toString()}`;
501
509
  }
502
510
  /**
503
511
  * Get the customer portal URL for account management.
504
512
  *
505
- * Redirects to Clerk's hosted account page where users can
506
- * manage their profile, password, and security settings.
513
+ * Redirects to our auth worker which embeds Clerk's UserProfile.
514
+ * Users can manage their profile, password, and security settings.
507
515
  *
508
516
  * Note: This is separate from billing management.
509
517
  * For billing, use api.billing.openPortal().
510
518
  *
511
519
  * @example
512
520
  * ```typescript
513
- * const portalUrl = api.auth.getCustomerPortalUrl();
521
+ * const portalUrl = api.auth.getCustomerPortalUrl({ returnUrl: '/dashboard' });
514
522
  * window.location.href = portalUrl;
515
523
  * ```
516
524
  */
517
- getCustomerPortalUrl() {
518
- const clerkBaseUrl = this.client.getClerkBaseUrl();
519
- return `${clerkBaseUrl}/user`;
525
+ getCustomerPortalUrl(options) {
526
+ const pk = this.client.getPublishableKey();
527
+ if (!pk) {
528
+ throw new Error("DreamAPI: publishableKey required for auth URLs");
529
+ }
530
+ const baseUrl = this.client.getSignupBaseUrl();
531
+ const returnUrl = options?.returnUrl || (typeof window !== "undefined" ? window.location.href : "/");
532
+ const params = new URLSearchParams({
533
+ pk,
534
+ redirect: returnUrl
535
+ });
536
+ return `${baseUrl}/account?${params.toString()}`;
520
537
  }
521
538
  };
522
539
 
package/dist/index.mjs CHANGED
@@ -458,8 +458,8 @@ var AuthHelpers = class {
458
458
  /**
459
459
  * Get the sign-in URL for returning users.
460
460
  *
461
- * Redirects to Clerk's hosted sign-in page. After sign-in,
462
- * users are redirected to your specified URL.
461
+ * Redirects to our auth worker which embeds Clerk. After sign-in,
462
+ * users are redirected to your specified URL with JWT.
463
463
  *
464
464
  * @example
465
465
  * ```typescript
@@ -468,27 +468,44 @@ var AuthHelpers = class {
468
468
  * ```
469
469
  */
470
470
  getSignInUrl(options) {
471
- const clerkBaseUrl = this.client.getClerkBaseUrl();
472
- return `${clerkBaseUrl}/sign-in?redirect_url=${encodeURIComponent(options.redirect)}`;
471
+ const pk = this.client.getPublishableKey();
472
+ if (!pk) {
473
+ throw new Error("DreamAPI: publishableKey required for auth URLs");
474
+ }
475
+ const baseUrl = this.client.getSignupBaseUrl();
476
+ const params = new URLSearchParams({
477
+ pk,
478
+ redirect: options.redirect
479
+ });
480
+ return `${baseUrl}/signin?${params.toString()}`;
473
481
  }
474
482
  /**
475
483
  * Get the customer portal URL for account management.
476
484
  *
477
- * Redirects to Clerk's hosted account page where users can
478
- * manage their profile, password, and security settings.
485
+ * Redirects to our auth worker which embeds Clerk's UserProfile.
486
+ * Users can manage their profile, password, and security settings.
479
487
  *
480
488
  * Note: This is separate from billing management.
481
489
  * For billing, use api.billing.openPortal().
482
490
  *
483
491
  * @example
484
492
  * ```typescript
485
- * const portalUrl = api.auth.getCustomerPortalUrl();
493
+ * const portalUrl = api.auth.getCustomerPortalUrl({ returnUrl: '/dashboard' });
486
494
  * window.location.href = portalUrl;
487
495
  * ```
488
496
  */
489
- getCustomerPortalUrl() {
490
- const clerkBaseUrl = this.client.getClerkBaseUrl();
491
- return `${clerkBaseUrl}/user`;
497
+ getCustomerPortalUrl(options) {
498
+ const pk = this.client.getPublishableKey();
499
+ if (!pk) {
500
+ throw new Error("DreamAPI: publishableKey required for auth URLs");
501
+ }
502
+ const baseUrl = this.client.getSignupBaseUrl();
503
+ const returnUrl = options?.returnUrl || (typeof window !== "undefined" ? window.location.href : "/");
504
+ const params = new URLSearchParams({
505
+ pk,
506
+ redirect: returnUrl
507
+ });
508
+ return `${baseUrl}/account?${params.toString()}`;
492
509
  }
493
510
  };
494
511
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dream-api/sdk",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
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",