@better-auth/stripe 1.5.0-beta.13 → 1.5.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.
- package/.turbo/turbo-build.log +11 -11
- package/dist/client.d.mts +48 -47
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.mts +522 -2
- package/dist/index.mjs +282 -69
- package/dist/index.mjs.map +1 -1
- package/dist/types-Bzc6yg83.d.mts +471 -0
- package/package.json +8 -8
- package/src/client.ts +2 -3
- package/src/hooks.ts +63 -30
- package/src/index.ts +154 -9
- package/src/routes.ts +283 -124
- package/src/schema.ts +4 -0
- package/src/types.ts +22 -0
- package/src/utils.ts +47 -18
- package/test/seat-based-billing.test.ts +1181 -0
- package/test/stripe-organization.test.ts +130 -6
- package/test/stripe.test.ts +733 -107
- package/test/utils.test.ts +97 -0
- package/vitest.config.ts +1 -0
- package/dist/index-BELqjMd2.d.mts +0 -955
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/stripe@1.5.0-beta.
|
|
2
|
+
> @better-auth/stripe@1.5.0-beta.16 build /home/runner/work/better-auth/better-auth/packages/stripe
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
|
-
[34mℹ[39m tsdown [2mv0.20.
|
|
5
|
+
[34mℹ[39m tsdown [2mv0.20.3[22m powered by rolldown [2mv1.0.0-rc.3[22m
|
|
6
6
|
[34mℹ[39m config file: [4m/home/runner/work/better-auth/better-auth/packages/stripe/tsdown.config.ts[24m
|
|
7
7
|
[34mℹ[39m entry: [34msrc/index.ts, src/client.ts[39m
|
|
8
8
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
9
|
[34mℹ[39m Build start
|
|
10
|
-
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m
|
|
10
|
+
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m 65.58 kB[22m [2m│ gzip: 12.29 kB[22m
|
|
11
|
+
[33m[PLUGIN_TIMINGS] Warning:[0m Your build spent significant time in plugin `rolldown-plugin-dts:generate`. See https://rolldown.rs/options/checks#plugintimings for more details.
|
|
11
12
|
[34mℹ[39m [2mdist/[22m[1mclient.mjs[22m [2m 0.43 kB[22m [2m│ gzip: 0.29 kB[22m
|
|
12
|
-
[34mℹ[39m [2mdist/[22mindex.mjs.map [
|
|
13
|
+
[34mℹ[39m [2mdist/[22mindex.mjs.map [2m140.31 kB[22m [2m│ gzip: 26.79 kB[22m
|
|
13
14
|
[34mℹ[39m [2mdist/[22merror-codes-CHMyMR5v.mjs.map [2m 2.23 kB[22m [2m│ gzip: 1.01 kB[22m
|
|
14
15
|
[34mℹ[39m [2mdist/[22merror-codes-CHMyMR5v.mjs [2m 1.78 kB[22m [2m│ gzip: 0.82 kB[22m
|
|
15
|
-
[34mℹ[39m [2mdist/[22mclient.mjs.map [2m 1.
|
|
16
|
-
[34mℹ[39m [2mdist/[22m[32m[
|
|
17
|
-
[34mℹ[39m [2mdist/[22m[32m[
|
|
18
|
-
[34mℹ[39m [2mdist/[22m[
|
|
19
|
-
[34mℹ[39m 9 files, total:
|
|
20
|
-
[
|
|
16
|
+
[34mℹ[39m [2mdist/[22mclient.mjs.map [2m 1.26 kB[22m [2m│ gzip: 0.59 kB[22m
|
|
17
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 19.89 kB[22m [2m│ gzip: 3.12 kB[22m
|
|
18
|
+
[34mℹ[39m [2mdist/[22m[32m[1mclient.d.mts[22m[39m [2m 4.62 kB[22m [2m│ gzip: 0.92 kB[22m
|
|
19
|
+
[34mℹ[39m [2mdist/[22m[32mtypes-Bzc6yg83.d.mts[39m [2m 12.67 kB[22m [2m│ gzip: 2.91 kB[22m
|
|
20
|
+
[34mℹ[39m 9 files, total: 248.77 kB
|
|
21
|
+
[32m✔[39m Build complete in [32m41456ms[39m
|
|
21
22
|
|
|
22
|
-
[32m✔[39m Build complete in [32m35719ms[39m
|
package/dist/client.d.mts
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { a as StripePlan } from "./types-Bzc6yg83.mjs";
|
|
2
|
+
import { stripe } from "./index.mjs";
|
|
3
|
+
import * as better_auth0 from "better-auth";
|
|
3
4
|
|
|
4
5
|
//#region src/error-codes.d.ts
|
|
5
6
|
declare const STRIPE_ERROR_CODES: {
|
|
6
|
-
UNAUTHORIZED:
|
|
7
|
-
INVALID_REQUEST_BODY:
|
|
8
|
-
SUBSCRIPTION_NOT_FOUND:
|
|
9
|
-
SUBSCRIPTION_PLAN_NOT_FOUND:
|
|
10
|
-
ALREADY_SUBSCRIBED_PLAN:
|
|
11
|
-
REFERENCE_ID_NOT_ALLOWED:
|
|
12
|
-
CUSTOMER_NOT_FOUND:
|
|
13
|
-
UNABLE_TO_CREATE_CUSTOMER:
|
|
14
|
-
UNABLE_TO_CREATE_BILLING_PORTAL:
|
|
15
|
-
STRIPE_SIGNATURE_NOT_FOUND:
|
|
16
|
-
STRIPE_WEBHOOK_SECRET_NOT_FOUND:
|
|
17
|
-
STRIPE_WEBHOOK_ERROR:
|
|
18
|
-
FAILED_TO_CONSTRUCT_STRIPE_EVENT:
|
|
19
|
-
FAILED_TO_FETCH_PLANS:
|
|
20
|
-
EMAIL_VERIFICATION_REQUIRED:
|
|
21
|
-
SUBSCRIPTION_NOT_ACTIVE:
|
|
22
|
-
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:
|
|
23
|
-
ORGANIZATION_NOT_FOUND:
|
|
24
|
-
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED:
|
|
25
|
-
AUTHORIZE_REFERENCE_REQUIRED:
|
|
26
|
-
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION:
|
|
27
|
-
ORGANIZATION_REFERENCE_ID_REQUIRED:
|
|
7
|
+
UNAUTHORIZED: better_auth0.RawError<"UNAUTHORIZED">;
|
|
8
|
+
INVALID_REQUEST_BODY: better_auth0.RawError<"INVALID_REQUEST_BODY">;
|
|
9
|
+
SUBSCRIPTION_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_NOT_FOUND">;
|
|
10
|
+
SUBSCRIPTION_PLAN_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
|
|
11
|
+
ALREADY_SUBSCRIBED_PLAN: better_auth0.RawError<"ALREADY_SUBSCRIBED_PLAN">;
|
|
12
|
+
REFERENCE_ID_NOT_ALLOWED: better_auth0.RawError<"REFERENCE_ID_NOT_ALLOWED">;
|
|
13
|
+
CUSTOMER_NOT_FOUND: better_auth0.RawError<"CUSTOMER_NOT_FOUND">;
|
|
14
|
+
UNABLE_TO_CREATE_CUSTOMER: better_auth0.RawError<"UNABLE_TO_CREATE_CUSTOMER">;
|
|
15
|
+
UNABLE_TO_CREATE_BILLING_PORTAL: better_auth0.RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
|
|
16
|
+
STRIPE_SIGNATURE_NOT_FOUND: better_auth0.RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
|
|
17
|
+
STRIPE_WEBHOOK_SECRET_NOT_FOUND: better_auth0.RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
|
|
18
|
+
STRIPE_WEBHOOK_ERROR: better_auth0.RawError<"STRIPE_WEBHOOK_ERROR">;
|
|
19
|
+
FAILED_TO_CONSTRUCT_STRIPE_EVENT: better_auth0.RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
|
|
20
|
+
FAILED_TO_FETCH_PLANS: better_auth0.RawError<"FAILED_TO_FETCH_PLANS">;
|
|
21
|
+
EMAIL_VERIFICATION_REQUIRED: better_auth0.RawError<"EMAIL_VERIFICATION_REQUIRED">;
|
|
22
|
+
SUBSCRIPTION_NOT_ACTIVE: better_auth0.RawError<"SUBSCRIPTION_NOT_ACTIVE">;
|
|
23
|
+
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: better_auth0.RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
|
|
24
|
+
ORGANIZATION_NOT_FOUND: better_auth0.RawError<"ORGANIZATION_NOT_FOUND">;
|
|
25
|
+
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: better_auth0.RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
|
|
26
|
+
AUTHORIZE_REFERENCE_REQUIRED: better_auth0.RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
|
|
27
|
+
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: better_auth0.RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
|
|
28
|
+
ORGANIZATION_REFERENCE_ID_REQUIRED: better_auth0.RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
|
|
28
29
|
};
|
|
29
30
|
//#endregion
|
|
30
31
|
//#region src/client.d.ts
|
|
@@ -37,7 +38,7 @@ declare const stripeClient: <O extends {
|
|
|
37
38
|
stripeWebhookSecret: string;
|
|
38
39
|
subscription: {
|
|
39
40
|
enabled: true;
|
|
40
|
-
plans: [];
|
|
41
|
+
plans: StripePlan[];
|
|
41
42
|
};
|
|
42
43
|
} : {
|
|
43
44
|
stripeClient: any;
|
|
@@ -48,28 +49,28 @@ declare const stripeClient: <O extends {
|
|
|
48
49
|
"/subscription/restore": "POST";
|
|
49
50
|
};
|
|
50
51
|
$ERROR_CODES: {
|
|
51
|
-
UNAUTHORIZED:
|
|
52
|
-
INVALID_REQUEST_BODY:
|
|
53
|
-
SUBSCRIPTION_NOT_FOUND:
|
|
54
|
-
SUBSCRIPTION_PLAN_NOT_FOUND:
|
|
55
|
-
ALREADY_SUBSCRIBED_PLAN:
|
|
56
|
-
REFERENCE_ID_NOT_ALLOWED:
|
|
57
|
-
CUSTOMER_NOT_FOUND:
|
|
58
|
-
UNABLE_TO_CREATE_CUSTOMER:
|
|
59
|
-
UNABLE_TO_CREATE_BILLING_PORTAL:
|
|
60
|
-
STRIPE_SIGNATURE_NOT_FOUND:
|
|
61
|
-
STRIPE_WEBHOOK_SECRET_NOT_FOUND:
|
|
62
|
-
STRIPE_WEBHOOK_ERROR:
|
|
63
|
-
FAILED_TO_CONSTRUCT_STRIPE_EVENT:
|
|
64
|
-
FAILED_TO_FETCH_PLANS:
|
|
65
|
-
EMAIL_VERIFICATION_REQUIRED:
|
|
66
|
-
SUBSCRIPTION_NOT_ACTIVE:
|
|
67
|
-
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION:
|
|
68
|
-
ORGANIZATION_NOT_FOUND:
|
|
69
|
-
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED:
|
|
70
|
-
AUTHORIZE_REFERENCE_REQUIRED:
|
|
71
|
-
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION:
|
|
72
|
-
ORGANIZATION_REFERENCE_ID_REQUIRED:
|
|
52
|
+
UNAUTHORIZED: better_auth0.RawError<"UNAUTHORIZED">;
|
|
53
|
+
INVALID_REQUEST_BODY: better_auth0.RawError<"INVALID_REQUEST_BODY">;
|
|
54
|
+
SUBSCRIPTION_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_NOT_FOUND">;
|
|
55
|
+
SUBSCRIPTION_PLAN_NOT_FOUND: better_auth0.RawError<"SUBSCRIPTION_PLAN_NOT_FOUND">;
|
|
56
|
+
ALREADY_SUBSCRIBED_PLAN: better_auth0.RawError<"ALREADY_SUBSCRIBED_PLAN">;
|
|
57
|
+
REFERENCE_ID_NOT_ALLOWED: better_auth0.RawError<"REFERENCE_ID_NOT_ALLOWED">;
|
|
58
|
+
CUSTOMER_NOT_FOUND: better_auth0.RawError<"CUSTOMER_NOT_FOUND">;
|
|
59
|
+
UNABLE_TO_CREATE_CUSTOMER: better_auth0.RawError<"UNABLE_TO_CREATE_CUSTOMER">;
|
|
60
|
+
UNABLE_TO_CREATE_BILLING_PORTAL: better_auth0.RawError<"UNABLE_TO_CREATE_BILLING_PORTAL">;
|
|
61
|
+
STRIPE_SIGNATURE_NOT_FOUND: better_auth0.RawError<"STRIPE_SIGNATURE_NOT_FOUND">;
|
|
62
|
+
STRIPE_WEBHOOK_SECRET_NOT_FOUND: better_auth0.RawError<"STRIPE_WEBHOOK_SECRET_NOT_FOUND">;
|
|
63
|
+
STRIPE_WEBHOOK_ERROR: better_auth0.RawError<"STRIPE_WEBHOOK_ERROR">;
|
|
64
|
+
FAILED_TO_CONSTRUCT_STRIPE_EVENT: better_auth0.RawError<"FAILED_TO_CONSTRUCT_STRIPE_EVENT">;
|
|
65
|
+
FAILED_TO_FETCH_PLANS: better_auth0.RawError<"FAILED_TO_FETCH_PLANS">;
|
|
66
|
+
EMAIL_VERIFICATION_REQUIRED: better_auth0.RawError<"EMAIL_VERIFICATION_REQUIRED">;
|
|
67
|
+
SUBSCRIPTION_NOT_ACTIVE: better_auth0.RawError<"SUBSCRIPTION_NOT_ACTIVE">;
|
|
68
|
+
SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION: better_auth0.RawError<"SUBSCRIPTION_NOT_SCHEDULED_FOR_CANCELLATION">;
|
|
69
|
+
ORGANIZATION_NOT_FOUND: better_auth0.RawError<"ORGANIZATION_NOT_FOUND">;
|
|
70
|
+
ORGANIZATION_SUBSCRIPTION_NOT_ENABLED: better_auth0.RawError<"ORGANIZATION_SUBSCRIPTION_NOT_ENABLED">;
|
|
71
|
+
AUTHORIZE_REFERENCE_REQUIRED: better_auth0.RawError<"AUTHORIZE_REFERENCE_REQUIRED">;
|
|
72
|
+
ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION: better_auth0.RawError<"ORGANIZATION_HAS_ACTIVE_SUBSCRIPTION">;
|
|
73
|
+
ORGANIZATION_REFERENCE_ID_REQUIRED: better_auth0.RawError<"ORGANIZATION_REFERENCE_ID_REQUIRED">;
|
|
73
74
|
};
|
|
74
75
|
};
|
|
75
76
|
//#endregion
|
package/dist/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"better-auth/client\";\nimport { STRIPE_ERROR_CODES } from \"./error-codes\";\nimport type { stripe } from \"./index\";\
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"better-auth/client\";\nimport { STRIPE_ERROR_CODES } from \"./error-codes\";\nimport type { StripePlan, stripe } from \"./index\";\nexport const stripeClient = <\n\tO extends {\n\t\tsubscription: boolean;\n\t},\n>(\n\toptions?: O | undefined,\n) => {\n\treturn {\n\t\tid: \"stripe-client\",\n\t\t$InferServerPlugin: {} as ReturnType<\n\t\t\ttypeof stripe<\n\t\t\t\tO[\"subscription\"] extends true\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tstripeClient: any;\n\t\t\t\t\t\t\tstripeWebhookSecret: string;\n\t\t\t\t\t\t\tsubscription: {\n\t\t\t\t\t\t\t\tenabled: true;\n\t\t\t\t\t\t\t\tplans: StripePlan[];\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tstripeClient: any;\n\t\t\t\t\t\t\tstripeWebhookSecret: string;\n\t\t\t\t\t\t}\n\t\t\t>\n\t\t>,\n\t\tpathMethods: {\n\t\t\t\"/subscription/billing-portal\": \"POST\",\n\t\t\t\"/subscription/restore\": \"POST\",\n\t\t},\n\t\t$ERROR_CODES: STRIPE_ERROR_CODES,\n\t} satisfies BetterAuthClientPlugin;\n};\nexport * from \"./error-codes\";\n"],"mappings":";;;AAGA,MAAa,gBAKZ,YACI;AACJ,QAAO;EACN,IAAI;EACJ,oBAAoB,EAAE;EAiBtB,aAAa;GACZ,gCAAgC;GAChC,yBAAyB;GACzB;EACD,cAAc;EACd"}
|