UNPKG

matterbridge-roborock-vacuum-plugin

Version:
45 lines 1.63 kB
/** * Adapts the RoborockAuthenticateApi to the domain port interface. */ export class RoborockAuthGateway { authApi; logger; constructor(authApi, logger) { this.authApi = authApi; this.logger = logger; } /** * Request a verification code for email-based authentication. */ async requestVerificationCode(email) { this.logger.info(`Requesting verification code for ${email}`); await this.authApi.requestCodeV4(email); this.logger.info('Verification code sent successfully'); } /** * Authenticate a user with email and verification code. */ async authenticate2FA(email, code) { this.logger.info(`2FA Authenticating user ${email}`); const userData = await this.authApi.loginWithCodeV4(email, code); this.logger.info('2FA Authentication successful'); return userData; } async authenticatePassword(email, password) { this.logger.info(`Password Authenticating user ${email}`); const userData = await this.authApi.loginWithPassword(email, password); this.logger.info('Password authentication successful'); return userData; } /** * Refresh authentication token. */ async refreshToken(userData) { this.logger.info('Refreshing authentication token'); // Use the existing token to re-login const refreshedData = await this.authApi.loginWithUserData(userData.username, userData); this.logger.info('Token refreshed successfully'); return refreshedData; } } //# sourceMappingURL=RoborockAuthGateway.js.map