fix types
This commit is contained in:
parent
d87ad8f1af
commit
e5b7ff5d63
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@bowong/better-auth-stripe",
|
"name": "@bowong/better-auth-stripe",
|
||||||
"author": "Bowong",
|
"author": "Bowong",
|
||||||
"version": "1.4.1",
|
"version": "1.4.0-beta.10",
|
||||||
"main": "dist/index.cjs",
|
"main": "dist/index.cjs",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,36 @@
|
||||||
import type { BetterAuthClientPlugin } from "better-auth";
|
import {type BetterAuthClientPlugin} from "better-auth";
|
||||||
import type { stripe } from "./index";
|
import type {stripe} from "./index";
|
||||||
|
|
||||||
export const stripeClient = <
|
export const stripeClient = <
|
||||||
O extends {
|
O extends {
|
||||||
subscription: boolean;
|
subscription: boolean;
|
||||||
},
|
},
|
||||||
>(
|
>(
|
||||||
options?: O,
|
options?: O,
|
||||||
) => {
|
): BetterAuthClientPlugin => {
|
||||||
return {
|
return {
|
||||||
id: "stripe-client",
|
id: "stripe-client",
|
||||||
$InferServerPlugin: {} as ReturnType<
|
$InferServerPlugin: {} as ReturnType<
|
||||||
typeof stripe<
|
typeof stripe<
|
||||||
O["subscription"] extends true
|
O["subscription"] extends true
|
||||||
? {
|
? {
|
||||||
stripeClient: any;
|
stripeClient: any;
|
||||||
stripeWebhookSecret: string;
|
stripeWebhookSecret: string;
|
||||||
subscription: {
|
subscription: {
|
||||||
enabled: true;
|
enabled: true;
|
||||||
plans: [];
|
plans: [];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
stripeClient: any;
|
stripeClient: any;
|
||||||
stripeWebhookSecret: string;
|
stripeWebhookSecret: string;
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
>,
|
>,
|
||||||
pathMethods: {
|
pathMethods: {
|
||||||
"/subscription/restore": "POST",
|
"/subscription/restore": "POST",
|
||||||
"/subscription/billing-portal": "POST",
|
"/subscription/billing-portal": "POST",
|
||||||
"/subscription/meter-event": "POST",
|
"/subscription/meter-event": "POST",
|
||||||
},
|
},
|
||||||
} satisfies BetterAuthClientPlugin;
|
} satisfies BetterAuthClientPlugin;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {
|
import {
|
||||||
type GenericEndpointContext,
|
type GenericEndpointContext,
|
||||||
type BetterAuthPlugin,
|
type BetterAuthPlugin,
|
||||||
logger,
|
logger, type BetterAuthClientPlugin,
|
||||||
} from "better-auth";
|
} from "better-auth";
|
||||||
import {createAuthEndpoint, createAuthMiddleware} from "better-auth/plugins";
|
import {createAuthEndpoint, createAuthMiddleware} from "better-auth/plugins";
|
||||||
import Stripe from "stripe";
|
import Stripe from "stripe";
|
||||||
|
|
@ -64,7 +64,7 @@ async function resolvePriceIdFromLookupKey(
|
||||||
return prices.data[0]?.id;
|
return prices.data[0]?.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const stripe = <O extends StripeOptions>(options: O) => {
|
export const stripe = <O extends StripeOptions>(options: O) : BetterAuthPlugin => {
|
||||||
const client = options.stripeClient;
|
const client = options.stripeClient;
|
||||||
|
|
||||||
const referenceMiddleware = (
|
const referenceMiddleware = (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue