// Built-in Discord provider (OAuth2). Endpoints hardcoded — admins configure only // Enabled + Client ID + Client Secret. `identify` yields the stable user id; // `email` yields the address. Discord's id is the stable per-user subject. const OAuth2Provider = require('./oauth2.provider') class DiscordProvider extends OAuth2Provider { constructor(config = {}) { super({ kind: 'discord', name: 'Discord', ...config, id: config.id || 'discord' }) } authEndpoint() { return 'https://discord.com/oauth2/authorize' } tokenEndpoint() { return 'https://discord.com/api/oauth2/token' } userinfoEndpoint() { return 'https://discord.com/api/users/@me' } scopeString() { return 'identify email' } normalizeProfile(p = {}) { // global_name is the new display name; fall back to the legacy username. return { subject: p.id, email: p.email || null, // Discord spells the claim `verified` rather than `email_verified`, and it // means exactly this: the user confirmed the address with Discord. emailVerified: p.verified === true, name: p.global_name || p.username || null, } } } module.exports = DiscordProvider