@dream-api/sdk 0.1.34 → 0.1.36

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,23 @@ declare class AuthHelpers {
325
325
  getCustomerPortalUrl(options?: {
326
326
  returnUrl?: string;
327
327
  }): string;
328
+ /**
329
+ * Get the refresh URL for updating JWT after plan changes.
330
+ *
331
+ * Use this as Stripe's success_url to ensure the JWT is refreshed
332
+ * with updated plan metadata after checkout completes.
333
+ *
334
+ * @example
335
+ * ```typescript
336
+ * const refreshUrl = api.auth.getRefreshUrl({ redirect: '/dashboard' });
337
+ * // Use as Stripe success_url
338
+ * await api.billing.createCheckout({
339
+ * tier: 'pro',
340
+ * successUrl: refreshUrl,
341
+ * });
342
+ * ```
343
+ */
344
+ getRefreshUrl(options: AuthUrlOptions): string;
328
345
  /**
329
346
  * Convert a relative path to an absolute URL using current origin.
330
347
  * Already-absolute URLs are returned unchanged.
package/dist/index.d.ts CHANGED
@@ -325,6 +325,23 @@ declare class AuthHelpers {
325
325
  getCustomerPortalUrl(options?: {
326
326
  returnUrl?: string;
327
327
  }): string;
328
+ /**
329
+ * Get the refresh URL for updating JWT after plan changes.
330
+ *
331
+ * Use this as Stripe's success_url to ensure the JWT is refreshed
332
+ * with updated plan metadata after checkout completes.
333
+ *
334
+ * @example
335
+ * ```typescript
336
+ * const refreshUrl = api.auth.getRefreshUrl({ redirect: '/dashboard' });
337
+ * // Use as Stripe success_url
338
+ * await api.billing.createCheckout({
339
+ * tier: 'pro',
340
+ * successUrl: refreshUrl,
341
+ * });
342
+ * ```
343
+ */
344
+ getRefreshUrl(options: AuthUrlOptions): string;
328
345
  /**
329
346
  * Convert a relative path to an absolute URL using current origin.
330
347
  * Already-absolute URLs are returned unchanged.
package/dist/index.js CHANGED
@@ -360,7 +360,7 @@ var ClerkManager = class {
360
360
  if (clerk.user?.reload) {
361
361
  await clerk.user.reload();
362
362
  }
363
- this.token = await clerk.session.getToken({ template: JWT_TEMPLATE });
363
+ this.token = await clerk.session.getToken({ template: JWT_TEMPLATE, skipCache: true });
364
364
  this.setToken(this.token);
365
365
  return this.token;
366
366
  } catch (err) {
@@ -539,6 +539,35 @@ var AuthHelpers = class {
539
539
  });
540
540
  return `${baseUrl}/account?${params.toString()}`;
541
541
  }
542
+ /**
543
+ * Get the refresh URL for updating JWT after plan changes.
544
+ *
545
+ * Use this as Stripe's success_url to ensure the JWT is refreshed
546
+ * with updated plan metadata after checkout completes.
547
+ *
548
+ * @example
549
+ * ```typescript
550
+ * const refreshUrl = api.auth.getRefreshUrl({ redirect: '/dashboard' });
551
+ * // Use as Stripe success_url
552
+ * await api.billing.createCheckout({
553
+ * tier: 'pro',
554
+ * successUrl: refreshUrl,
555
+ * });
556
+ * ```
557
+ */
558
+ getRefreshUrl(options) {
559
+ const pk = this.client.getPublishableKey();
560
+ if (!pk) {
561
+ throw new Error("DreamAPI: publishableKey required for auth URLs");
562
+ }
563
+ const baseUrl = this.client.getSignupBaseUrl();
564
+ const redirectUrl = this.makeAbsoluteUrl(options.redirect);
565
+ const params = new URLSearchParams({
566
+ pk,
567
+ redirect: redirectUrl
568
+ });
569
+ return `${baseUrl}/refresh?${params.toString()}`;
570
+ }
542
571
  /**
543
572
  * Convert a relative path to an absolute URL using current origin.
544
573
  * Already-absolute URLs are returned unchanged.
package/dist/index.mjs CHANGED
@@ -332,7 +332,7 @@ var ClerkManager = class {
332
332
  if (clerk.user?.reload) {
333
333
  await clerk.user.reload();
334
334
  }
335
- this.token = await clerk.session.getToken({ template: JWT_TEMPLATE });
335
+ this.token = await clerk.session.getToken({ template: JWT_TEMPLATE, skipCache: true });
336
336
  this.setToken(this.token);
337
337
  return this.token;
338
338
  } catch (err) {
@@ -511,6 +511,35 @@ var AuthHelpers = class {
511
511
  });
512
512
  return `${baseUrl}/account?${params.toString()}`;
513
513
  }
514
+ /**
515
+ * Get the refresh URL for updating JWT after plan changes.
516
+ *
517
+ * Use this as Stripe's success_url to ensure the JWT is refreshed
518
+ * with updated plan metadata after checkout completes.
519
+ *
520
+ * @example
521
+ * ```typescript
522
+ * const refreshUrl = api.auth.getRefreshUrl({ redirect: '/dashboard' });
523
+ * // Use as Stripe success_url
524
+ * await api.billing.createCheckout({
525
+ * tier: 'pro',
526
+ * successUrl: refreshUrl,
527
+ * });
528
+ * ```
529
+ */
530
+ getRefreshUrl(options) {
531
+ const pk = this.client.getPublishableKey();
532
+ if (!pk) {
533
+ throw new Error("DreamAPI: publishableKey required for auth URLs");
534
+ }
535
+ const baseUrl = this.client.getSignupBaseUrl();
536
+ const redirectUrl = this.makeAbsoluteUrl(options.redirect);
537
+ const params = new URLSearchParams({
538
+ pk,
539
+ redirect: redirectUrl
540
+ });
541
+ return `${baseUrl}/refresh?${params.toString()}`;
542
+ }
514
543
  /**
515
544
  * Convert a relative path to an absolute URL using current origin.
516
545
  * Already-absolute URLs are returned unchanged.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dream-api/sdk",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
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",