spaps-sdk
Version:
Sweet Potato Authentication & Payment Service SDK - Zero-config client for SPAPS
83 lines (81 loc) • 2.25 kB
TypeScript
/**
* @spaps/sdk - Sweet Potato Authentication & Payment Service SDK
* Zero-config client for SPAPS authentication and payments
*/
interface SPAPSConfig {
apiUrl?: string;
apiKey?: string;
autoDetect?: boolean;
timeout?: number;
}
interface AuthResponse {
access_token: string;
refresh_token: string;
user: User;
}
interface User {
id: string;
email?: string;
wallet_address?: string;
chain_type?: string;
role: string;
created_at?: string;
}
interface CheckoutSession {
sessionId: string;
url: string;
}
interface Subscription {
id: string;
status: string;
plan: string;
current_period_end: string;
}
interface UsageBalance {
balance: number;
currency: string;
updated_at: string;
}
declare class SPAPSClient {
private client;
private apiKey?;
private accessToken?;
private refreshToken?;
private _isLocalMode;
constructor(config?: SPAPSConfig);
login(email: string, password: string): Promise<{
data: AuthResponse;
}>;
register(email: string, password: string): Promise<{
data: AuthResponse;
}>;
walletSignIn(walletAddress: string, signature: string, message: string, chainType?: 'solana' | 'ethereum'): Promise<{
data: AuthResponse;
}>;
refresh(refreshToken?: string): Promise<{
data: AuthResponse;
}>;
logout(): Promise<void>;
getUser(): Promise<{
data: User;
}>;
createCheckoutSession(priceId: string, successUrl: string, cancelUrl?: string): Promise<{
data: CheckoutSession;
}>;
getSubscription(): Promise<{
data: Subscription;
}>;
cancelSubscription(): Promise<void>;
getUsageBalance(): Promise<{
data: UsageBalance;
}>;
recordUsage(feature: string, amount: number): Promise<void>;
isAuthenticated(): boolean;
getAccessToken(): string | undefined;
setAccessToken(token: string): void;
isLocalMode(): boolean;
health(): Promise<{
data: any;
}>;
}
export { type AuthResponse, type CheckoutSession, SPAPSClient as SPAPS, SPAPSClient, type SPAPSConfig, type Subscription, SPAPSClient as SweetPotatoSDK, type UsageBalance, type User, SPAPSClient as default };