@better-auth/stripe 1.4.0-beta.14 → 1.4.0-beta.16

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.
@@ -1,23 +1,16 @@
1
1
 
2
- > @better-auth/stripe@1.4.0-beta.14 build /home/runner/work/better-auth/better-auth/packages/stripe
2
+ > @better-auth/stripe@1.4.0-beta.16 build /home/runner/work/better-auth/better-auth/packages/stripe
3
3
  > tsdown
4
4
 
5
- ℹ tsdown v0.15.10 powered by rolldown v1.0.0-beta.44
5
+ ℹ tsdown v0.15.11 powered by rolldown v1.0.0-beta.45
6
6
  ℹ Using tsdown config: /home/runner/work/better-auth/better-auth/packages/stripe/tsdown.config.ts
7
7
  ℹ entry: src/client.ts, src/index.ts
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
- ℹ [CJS] dist/index.cjs 38.46 kB │ gzip: 7.55 kB
11
- ℹ [CJS] dist/client.cjs  0.28 kB │ gzip: 0.20 kB
12
- ℹ [CJS] 2 files, total: 38.73 kB
13
- ℹ [ESM] dist/index.js 36.17 kB │ gzip: 7.02 kB
14
- ℹ [ESM] dist/client.js  0.26 kB │ gzip: 0.20 kB
15
- ℹ [ESM] dist/client.d.ts  0.60 kB │ gzip: 0.34 kB
16
- ℹ [ESM] dist/index.d.ts  0.16 kB │ gzip: 0.12 kB
17
- ℹ [ESM] dist/index-BeNixy9H.d.ts 24.78 kB │ gzip: 4.94 kB
18
- ℹ [ESM] 5 files, total: 61.98 kB
19
- ℹ [CJS] dist/client.d.cts  0.61 kB │ gzip: 0.34 kB
20
- ℹ [CJS] dist/index.d.cts  0.17 kB │ gzip: 0.13 kB
21
- ℹ [CJS] dist/index-CCjm8Nrc.d.cts 24.78 kB │ gzip: 4.94 kB
22
- ℹ [CJS] 3 files, total: 25.55 kB
23
- ✔ Build complete in 9263ms
10
+ ℹ dist/index.js 36.19 kB │ gzip: 7.05 kB
11
+ ℹ dist/client.js  0.26 kB │ gzip: 0.20 kB
12
+ ℹ dist/client.d.ts  0.62 kB │ gzip: 0.34 kB
13
+ ℹ dist/index.d.ts  0.16 kB │ gzip: 0.12 kB
14
+ ℹ dist/index-xD0GavfM.d.ts 25.28 kB │ gzip: 4.97 kB
15
+ ℹ 5 files, total: 62.51 kB
16
+ ✔ Build complete in 11764ms
package/dist/client.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { n as stripe } from "./index-BeNixy9H.js";
1
+ import { n as stripe } from "./index-xD0GavfM.js";
2
2
 
3
3
  //#region src/client.d.ts
4
4
  declare const stripeClient: <O extends {
5
5
  subscription: boolean;
6
- }>(options?: O) => {
6
+ }>(options?: O | undefined) => {
7
7
  id: "stripe-client";
8
8
  $InferServerPlugin: ReturnType<typeof stripe<O["subscription"] extends true ? {
9
9
  stripeClient: any;
@@ -72,28 +72,28 @@ type StripePlan = {
72
72
  /**
73
73
  * Monthly price id
74
74
  */
75
- priceId?: string;
75
+ priceId?: string | undefined;
76
76
  /**
77
77
  * To use lookup key instead of price id
78
78
  *
79
79
  * https://docs.stripe.com/products-prices/
80
80
  * manage-prices#lookup-keys
81
81
  */
82
- lookupKey?: string;
82
+ lookupKey?: string | undefined;
83
83
  /**
84
84
  * A yearly discount price id
85
85
  *
86
86
  * useful when you want to offer a discount for
87
87
  * yearly subscription
88
88
  */
89
- annualDiscountPriceId?: string;
89
+ annualDiscountPriceId?: string | undefined;
90
90
  /**
91
91
  * To use lookup key instead of price id
92
92
  *
93
93
  * https://docs.stripe.com/products-prices/
94
94
  * manage-prices#lookup-keys
95
95
  */
96
- annualDiscountLookupKey?: string;
96
+ annualDiscountLookupKey?: string | undefined;
97
97
  /**
98
98
  * Plan name
99
99
  */
@@ -101,14 +101,14 @@ type StripePlan = {
101
101
  /**
102
102
  * Limits for the plan
103
103
  */
104
- limits?: Record<string, number>;
104
+ limits?: Record<string, number> | undefined;
105
105
  /**
106
106
  * Plan group name
107
107
  *
108
108
  * useful when you want to group plans or
109
109
  * when a user can subscribe to multiple plans.
110
110
  */
111
- group?: string;
111
+ group?: string | undefined;
112
112
  /**
113
113
  * Free trial days
114
114
  */
@@ -142,7 +142,7 @@ type StripePlan = {
142
142
  * @returns
143
143
  */
144
144
  onTrialExpired?: (subscription: Subscription, ctx: GenericEndpointContext) => Promise<void>;
145
- };
145
+ } | undefined;
146
146
  };
147
147
  interface Subscription {
148
148
  /**
@@ -156,23 +156,23 @@ interface Subscription {
156
156
  /**
157
157
  * Stripe customer id
158
158
  */
159
- stripeCustomerId?: string;
159
+ stripeCustomerId?: string | undefined;
160
160
  /**
161
161
  * Stripe subscription id
162
162
  */
163
- stripeSubscriptionId?: string;
163
+ stripeSubscriptionId?: string | undefined;
164
164
  /**
165
165
  * Trial start date
166
166
  */
167
- trialStart?: Date;
167
+ trialStart?: Date | undefined;
168
168
  /**
169
169
  * Trial end date
170
170
  */
171
- trialEnd?: Date;
171
+ trialEnd?: Date | undefined;
172
172
  /**
173
173
  * Price Id for the subscription
174
174
  */
175
- priceId?: string;
175
+ priceId?: string | undefined;
176
176
  /**
177
177
  * To what reference id the subscription belongs to
178
178
  * @example
@@ -190,24 +190,24 @@ interface Subscription {
190
190
  /**
191
191
  * The billing cycle start date
192
192
  */
193
- periodStart?: Date;
193
+ periodStart?: Date | undefined;
194
194
  /**
195
195
  * The billing cycle end date
196
196
  */
197
- periodEnd?: Date;
197
+ periodEnd?: Date | undefined;
198
198
  /**
199
199
  * Cancel at period end
200
200
  */
201
- cancelAtPeriodEnd?: boolean;
201
+ cancelAtPeriodEnd?: boolean | undefined;
202
202
  /**
203
203
  * A field to group subscriptions so you can have multiple subscriptions
204
204
  * for one reference id
205
205
  */
206
- groupId?: string;
206
+ groupId?: string | undefined;
207
207
  /**
208
208
  * Number of seats for the subscription (useful for team plans)
209
209
  */
210
- seats?: number;
210
+ seats?: number | undefined;
211
211
  }
212
212
  type SubscriptionOptions = {
213
213
  /**
@@ -223,37 +223,37 @@ type SubscriptionOptions = {
223
223
  *
224
224
  * @default false
225
225
  */
226
- requireEmailVerification?: boolean;
226
+ requireEmailVerification?: boolean | undefined;
227
227
  /**
228
228
  * A callback to run after a user has subscribed to a package
229
229
  * @param event - Stripe Event
230
230
  * @param subscription - Subscription Data
231
231
  * @returns
232
232
  */
233
- onSubscriptionComplete?: (data: {
233
+ onSubscriptionComplete?: ((data: {
234
234
  event: Stripe.Event;
235
235
  stripeSubscription: Stripe.Subscription;
236
236
  subscription: Subscription;
237
237
  plan: StripePlan;
238
- }, ctx: GenericEndpointContext) => Promise<void>;
238
+ }, ctx: GenericEndpointContext) => Promise<void>) | undefined;
239
239
  /**
240
240
  * A callback to run after a user is about to cancel their subscription
241
241
  * @returns
242
242
  */
243
- onSubscriptionUpdate?: (data: {
243
+ onSubscriptionUpdate?: ((data: {
244
244
  event: Stripe.Event;
245
245
  subscription: Subscription;
246
- }) => Promise<void>;
246
+ }) => Promise<void>) | undefined;
247
247
  /**
248
248
  * A callback to run after a user is about to cancel their subscription
249
249
  * @returns
250
250
  */
251
- onSubscriptionCancel?: (data: {
251
+ onSubscriptionCancel?: ((data: {
252
252
  event?: Stripe.Event;
253
253
  subscription: Subscription;
254
254
  stripeSubscription: Stripe.Subscription;
255
255
  cancellationDetails?: Stripe.Subscription.CancellationDetails | null;
256
- }) => Promise<void>;
256
+ }) => Promise<void>) | undefined;
257
257
  /**
258
258
  * A function to check if the reference id is valid
259
259
  * and belongs to the user
@@ -262,21 +262,21 @@ type SubscriptionOptions = {
262
262
  * @param ctx - the context object
263
263
  * @returns
264
264
  */
265
- authorizeReference?: (data: {
265
+ authorizeReference?: ((data: {
266
266
  user: User & Record<string, any>;
267
267
  session: Session & Record<string, any>;
268
268
  referenceId: string;
269
269
  action: "upgrade-subscription" | "list-subscription" | "cancel-subscription" | "restore-subscription" | "billing-portal";
270
- }, ctx: GenericEndpointContext) => Promise<boolean>;
270
+ }, ctx: GenericEndpointContext) => Promise<boolean>) | undefined;
271
271
  /**
272
272
  * A callback to run after a user has deleted their subscription
273
273
  * @returns
274
274
  */
275
- onSubscriptionDeleted?: (data: {
275
+ onSubscriptionDeleted?: ((data: {
276
276
  event: Stripe.Event;
277
277
  stripeSubscription: Stripe.Subscription;
278
278
  subscription: Subscription;
279
- }) => Promise<void>;
279
+ }) => Promise<void>) | undefined;
280
280
  /**
281
281
  * parameters for session create params
282
282
  *
@@ -284,7 +284,7 @@ type SubscriptionOptions = {
284
284
  * @param req - the request object
285
285
  * @param ctx - the context object
286
286
  */
287
- getCheckoutSessionParams?: (data: {
287
+ getCheckoutSessionParams?: ((data: {
288
288
  user: User & Record<string, any>;
289
289
  session: Session & Record<string, any>;
290
290
  plan: StripePlan;
@@ -295,13 +295,13 @@ type SubscriptionOptions = {
295
295
  }> | {
296
296
  params?: Stripe.Checkout.SessionCreateParams;
297
297
  options?: Stripe.RequestOptions;
298
- };
298
+ }) | undefined;
299
299
  /**
300
300
  * Enable organization subscription
301
301
  */
302
302
  organization?: {
303
303
  enabled: boolean;
304
- };
304
+ } | undefined;
305
305
  };
306
306
  interface StripeOptions {
307
307
  /**
@@ -317,44 +317,44 @@ interface StripeOptions {
317
317
  /**
318
318
  * Enable customer creation when a user signs up
319
319
  */
320
- createCustomerOnSignUp?: boolean;
320
+ createCustomerOnSignUp?: boolean | undefined;
321
321
  /**
322
322
  * A callback to run after a customer has been created
323
323
  * @param customer - Customer Data
324
324
  * @param stripeCustomer - Stripe Customer Data
325
325
  * @returns
326
326
  */
327
- onCustomerCreate?: (data: {
327
+ onCustomerCreate?: ((data: {
328
328
  stripeCustomer: Stripe.Customer;
329
329
  user: User & {
330
330
  stripeCustomerId: string;
331
331
  };
332
- }, ctx: GenericEndpointContext) => Promise<void>;
332
+ }, ctx: GenericEndpointContext) => Promise<void>) | undefined;
333
333
  /**
334
334
  * A custom function to get the customer create
335
335
  * params
336
336
  * @param data - data containing user and session
337
337
  * @returns
338
338
  */
339
- getCustomerCreateParams?: (user: User, ctx: GenericEndpointContext) => Promise<Partial<Stripe.CustomerCreateParams>>;
339
+ getCustomerCreateParams?: ((user: User, ctx: GenericEndpointContext) => Promise<Partial<Stripe.CustomerCreateParams>>) | undefined;
340
340
  /**
341
341
  * Subscriptions
342
342
  */
343
- subscription?: {
343
+ subscription?: ({
344
344
  enabled: false;
345
345
  } | ({
346
346
  enabled: true;
347
- } & SubscriptionOptions);
347
+ } & SubscriptionOptions)) | undefined;
348
348
  /**
349
349
  * A callback to run after a stripe event is received
350
350
  * @param event - Stripe Event
351
351
  * @returns
352
352
  */
353
- onEvent?: (event: Stripe.Event) => Promise<void>;
353
+ onEvent?: ((event: Stripe.Event) => Promise<void>) | undefined;
354
354
  /**
355
355
  * Schema for the stripe plugin
356
356
  */
357
- schema?: InferOptionSchema<typeof subscriptions & typeof user>;
357
+ schema?: InferOptionSchema<typeof subscriptions & typeof user> | undefined;
358
358
  }
359
359
  //#endregion
360
360
  //#region src/index.d.ts
@@ -651,17 +651,17 @@ declare const stripe: <O extends StripeOptions>(options: O) => {
651
651
  priceId: string | undefined;
652
652
  id: string;
653
653
  plan: string;
654
- stripeCustomerId?: string;
655
- stripeSubscriptionId?: string;
656
- trialStart?: Date;
657
- trialEnd?: Date;
654
+ stripeCustomerId?: string | undefined;
655
+ stripeSubscriptionId?: string | undefined;
656
+ trialStart?: Date | undefined;
657
+ trialEnd?: Date | undefined;
658
658
  referenceId: string;
659
659
  status: "active" | "canceled" | "incomplete" | "incomplete_expired" | "past_due" | "paused" | "trialing" | "unpaid";
660
- periodStart?: Date;
661
- periodEnd?: Date;
662
- cancelAtPeriodEnd?: boolean;
663
- groupId?: string;
664
- seats?: number;
660
+ periodStart?: Date | undefined;
661
+ periodEnd?: Date | undefined;
662
+ cancelAtPeriodEnd?: boolean | undefined;
663
+ groupId?: string | undefined;
664
+ seats?: number | undefined;
665
665
  }[]>;
666
666
  readonly subscriptionSuccess: better_call0.StrictEndpoint<"/subscription/success", {
667
667
  method: "GET";
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as Subscription, n as stripe, r as StripePlan, t as StripePlugin } from "./index-BeNixy9H.js";
1
+ import { i as Subscription, n as stripe, r as StripePlan, t as StripePlugin } from "./index-xD0GavfM.js";
2
2
  export { StripePlan, StripePlugin, Subscription, stripe };
package/dist/index.js CHANGED
@@ -265,7 +265,7 @@ const STRIPE_ERROR_CODES = defineErrorCodes({
265
265
  SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: "Subscription is not scheduled for cancellation"
266
266
  });
267
267
  const getUrl = (ctx, url) => {
268
- if (url.startsWith("http")) return url;
268
+ if (/^[a-zA-Z][a-zA-Z0-9+\-.]*:/.test(url)) return url;
269
269
  return `${ctx.context.options.baseURL}${url.startsWith("/") ? url : `/${url}`}`;
270
270
  };
271
271
  async function resolvePriceIdFromLookupKey(stripeClient, lookupKey) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@better-auth/stripe",
3
3
  "author": "Bereket Engida",
4
- "version": "1.4.0-beta.14",
4
+ "version": "1.4.0-beta.16",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "license": "MIT",
@@ -25,14 +25,12 @@
25
25
  ".": {
26
26
  "better-auth-dev-source": "./src/index.ts",
27
27
  "types": "./dist/index.d.ts",
28
- "import": "./dist/index.js",
29
- "require": "./dist/index.cjs"
28
+ "default": "./dist/index.js"
30
29
  },
31
30
  "./client": {
32
31
  "better-auth-dev-source": "./src/client.ts",
33
32
  "types": "./dist/client.d.ts",
34
- "import": "./dist/client.js",
35
- "require": "./dist/client.cjs"
33
+ "default": "./dist/client.js"
36
34
  }
37
35
  },
38
36
  "typesVersions": {
@@ -51,15 +49,15 @@
51
49
  },
52
50
  "peerDependencies": {
53
51
  "stripe": "^18 || ^19",
54
- "@better-auth/core": "1.4.0-beta.14",
55
- "better-auth": "1.4.0-beta.14"
52
+ "@better-auth/core": "1.4.0-beta.16",
53
+ "better-auth": "1.4.0-beta.16"
56
54
  },
57
55
  "devDependencies": {
58
56
  "better-call": "1.0.24",
59
57
  "stripe": "^19.1.0",
60
- "tsdown": "^0.15.10",
61
- "@better-auth/core": "1.4.0-beta.14",
62
- "better-auth": "1.4.0-beta.14"
58
+ "tsdown": "^0.15.11",
59
+ "@better-auth/core": "1.4.0-beta.16",
60
+ "better-auth": "1.4.0-beta.16"
63
61
  },
64
62
  "scripts": {
65
63
  "test": "vitest",
package/src/client.ts CHANGED
@@ -6,7 +6,7 @@ export const stripeClient = <
6
6
  subscription: boolean;
7
7
  },
8
8
  >(
9
- options?: O,
9
+ options?: O | undefined,
10
10
  ) => {
11
11
  return {
12
12
  id: "stripe-client",
package/src/index.ts CHANGED
@@ -46,7 +46,7 @@ const STRIPE_ERROR_CODES = defineErrorCodes({
46
46
  });
47
47
 
48
48
  const getUrl = (ctx: GenericEndpointContext, url: string) => {
49
- if (url.startsWith("http")) {
49
+ if (/^[a-zA-Z][a-zA-Z0-9+\-.]*:/.test(url)) {
50
50
  return url;
51
51
  }
52
52
  return `${ctx.context.options.baseURL}${