getUser

getUser(): Promise<User | null> Retrieves info about the current user. Returns null if the user is not logged in.
const user = await client.getUser();
Returns
{
    email: string; // user's email address

    // true if the user has atleast one active subscription
    // or has purchased a lifetime (billing_cycle = once) plan
	paid: boolean;

    // all plans the user has purchased
	plans: [
		{
			id: string,
			name: string,
			price: number,
			credits: number,
			description: string,
			billing_cycle: "yearly" | "monthly" | "once",

			status: "active" | "canceled" | "expired",
			paid_at: number,
			canceled_at: number,
		},
        ...
	];

    // remaining credits
	credits_left: number;
}

getPlans

getPlans(): Promise<Plan[]> Fetches all available plans.
const plans = await client.getPlans();
Returns
[
    {
        id: string,
        name: string,
        price: number,
        credits: number,
        description: string,
        billing_cycle: "yearly" | "monthly" | "once",
    },
    ...
]

getCreditsLeft

getCreditsLeft(): Promise<number> Fetches the remaining credits for the current user.
const credits = await client.getCreditsLeft();
Returns
credits: number; // remaining credits

useCredits

useCredits(amount: number): Promise<UseCreditsResult> Consumes a specified number of credits of the current user. If the user does not have enough credits, an error will be returned.
const response = await client.useCredits(10);
Returns
{
	success: boolean; // true if credits were successfully used
	credits_left: number; // remaining credits
}

openSubscriptionPage

openSubscriptionPage(): void Opens a page showing available subscription plans.
client.openSubscriptionPage();

openManagePage

openManagePage(): void Opens Stripe Portal to allow the user to manage their subscriptions.
client.openManagePage();
It is important you include a easy way to open this page inside your extension!

openLoginPage

openLoginPage(): void Opens a page for the user to log in.
client.openLoginPage();