UNPKG

matterbridge-roborock-vacuum-plugin

Version:
28 lines 1.19 kB
/** Coordinates authentication strategies based on the selected method. */ export class AuthenticationCoordinator { logger; strategies; constructor(passwordStrategy, twoFactorStrategy, logger) { this.logger = logger; this.strategies = new Map([ ['Password', passwordStrategy], ['VerificationCode', twoFactorStrategy], ]); } /** * Authenticate user using the specified method. * @param method Authentication method ('Password' or 'VerificationCode') * @param context Authentication context containing credentials * @returns UserData if successful, undefined if further action required */ async authenticate(method, context) { const strategy = this.strategies.get(method); if (!strategy) { const availableMethods = Array.from(this.strategies.keys()).join(', '); this.logger.error(`Unknown authentication method: ${method}. Available methods: ${availableMethods}`); throw new Error(`Unknown authentication method: ${method}`); } return strategy.authenticate(context); } } //# sourceMappingURL=AuthenticationCoordinator.js.map