@ley0x/better-auth-lastfm
Version:
Last.fm authentication plugin for BetterAuth
53 lines (48 loc) • 1.54 kB
text/typescript
import { BetterAuthPlugin } 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;
}
interface LastfmSession {
key: string;
name: string;
subscriber: number;
}
interface LastfmAuthResponse {
session: LastfmSession;
}
interface LastfmUserProfile {
username: string;
sessionKey: 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): BetterAuthPlugin;
/**
* Creates a Last.fm API signature as required by their authentication flow
* @param params - Object containing API parameters
* @param secret - Last.fm shared secret
* @returns MD5 hash of sorted parameters + secret
*/
declare function createLastfmApiSignature(params: Record<string, string>, secret: string): string;
export { type LastfmAuthResponse, type LastfmPluginOptions, type LastfmSession, type LastfmUserProfile, createLastfmApiSignature, lastfmPlugin };