UNPKG

@ley0x/better-auth-lastfm

Version:

Last.fm authentication plugin for BetterAuth

93 lines (88 loc) 4.68 kB
import * as better_auth_client from 'better-auth/client'; import * as better_auth from 'better-auth'; interface LastfmPluginOptions { /** * Last.fm API key */ apiKey: string; /** * Last.fm shared secret for API signature generation */ sharedSecret: string; /** * Base URL for your application (used for callback URL generation) * @default process.env.BETTER_AUTH_URL || 'http://localhost:3000' */ baseUrl?: string; /** * Custom redirect path after successful authentication * @default '/dashboard' */ redirectTo?: string; } /** * Last.fm authentication plugin for BetterAuth * * Provides Last.fm authentication using their custom API flow (not OAuth) * Creates a session with the Last.fm session key for subsequent API calls */ declare function lastfmPlugin(options: LastfmPluginOptions): { id: "lastfm"; endpoints: { '/lastfm/signin': better_auth.StrictEndpoint<"/lastfm/signin", { method: "GET"; }, { status: ("OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED") | better_auth.Status; body: ({ message?: string; code?: string; cause?: unknown; } & Record<string, any>) | undefined; headers: HeadersInit; statusCode: number; name: string; message: string; stack?: string; }>; '/lastfm/callback': better_auth.StrictEndpoint<"/lastfm/callback", { method: "GET"; }, { status: ("OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED") | better_auth.Status; body: ({ message?: string; code?: string; cause?: unknown; } & Record<string, any>) | undefined; headers: HeadersInit; statusCode: number; name: string; message: string; stack?: string; } | { error: string; }>; }; }; /** * Client-side plugin for Last.fm authentication * Provides methods to interact with Last.fm authentication flow */ declare const lastfmClientPlugin: () => { id: "lastfm"; $InferServerPlugin: ReturnType<typeof lastfmPlugin>; getActions: ($fetch: better_auth_client.BetterFetch) => { signInWithLastfm: () => Promise<void>; getLastfmSession: () => Promise<{ data: unknown; error: null; } | { data: null; error: { message?: string | undefined; status: number; statusText: string; }; }>; }; }; export { lastfmClientPlugin };