@dream-api/sdk 0.1.34 → 0.1.35
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 +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +29 -0
- package/dist/index.mjs +29 -0
- package/package.json +1 -1
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
|
@@ -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
|
@@ -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.
|