move automation out of core

This commit is contained in:
2025-12-16 14:31:43 +01:00
parent 29dc11deb9
commit 29410708c8
145 changed files with 378 additions and 1532 deletions

View File

@@ -0,0 +1,36 @@
import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort';
import { Result } from '@gridpilot/shared/result/Result';
import { BrowserAuthenticationState } from '../../domain/value-objects/BrowserAuthenticationState';
import type { Logger } from '@core/shared/application';
/**
* Use case for verifying browser shows authenticated page state.
* Combines cookie validation with page content verification.
*/
export class VerifyAuthenticatedPageUseCase {
constructor(
private readonly authService: AuthenticationServicePort,
private readonly logger: Logger,
) {}
async execute(): Promise<Result<BrowserAuthenticationState>> {
this.logger.debug('Executing VerifyAuthenticatedPageUseCase');
try {
const result = await this.authService.verifyPageAuthentication();
if (result.isErr()) {
const error = result.error ?? new Error('Page verification failed');
this.logger.error(`Page verification failed: ${error.message}`, error);
return Result.err<BrowserAuthenticationState>(error);
}
const browserState = result.unwrap();
this.logger.info('Successfully verified authenticated page state.');
return Result.ok<BrowserAuthenticationState>(browserState);
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
this.logger.error(`Page verification failed unexpectedly: ${message}`, error instanceof Error ? error : undefined);
return Result.err<BrowserAuthenticationState>(new Error(`Page verification failed: ${message}`));
}
}
}