@silasfmartins/testhub 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/copilot-instructions.md +520 -0
- package/biome.json +37 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +169 -0
- package/dist/scripts/consumer-postinstall.d.ts +15 -0
- package/dist/scripts/consumer-postinstall.js +785 -0
- package/dist/scripts/generate-docs.d.ts +16 -0
- package/dist/scripts/generate-docs.js +1363 -0
- package/dist/scripts/generate-index.d.ts +2 -0
- package/dist/scripts/generate-index.js +314 -0
- package/dist/scripts/init-api.d.ts +2 -0
- package/dist/scripts/init-api.js +525 -0
- package/dist/scripts/init-banco.d.ts +2 -0
- package/dist/scripts/init-banco.js +347 -0
- package/dist/scripts/init-frontend.d.ts +2 -0
- package/dist/scripts/init-frontend.js +627 -0
- package/dist/scripts/init-mobile.d.ts +2 -0
- package/dist/scripts/init-mobile.js +481 -0
- package/dist/scripts/init-scenarios.d.ts +2 -0
- package/dist/scripts/init-scenarios.js +846 -0
- package/dist/scripts/init-ssh.d.ts +2 -0
- package/dist/scripts/init-ssh.js +639 -0
- package/dist/scripts/package-versions.d.ts +57 -0
- package/dist/scripts/package-versions.js +768 -0
- package/dist/scripts/postinstall.d.ts +1 -0
- package/dist/scripts/postinstall.js +527 -0
- package/dist/scripts/robust-build.d.ts +7 -0
- package/dist/scripts/robust-build.js +88 -0
- package/dist/scripts/setup-local-packages.d.ts +31 -0
- package/dist/scripts/setup-local-packages.js +237 -0
- package/dist/scripts/smart-override.d.ts +2 -0
- package/dist/scripts/smart-override.js +1360 -0
- package/dist/scripts/sync-configs.d.ts +27 -0
- package/dist/scripts/sync-configs.js +248 -0
- package/dist/scripts/test-biome-parse.d.ts +5 -0
- package/dist/scripts/test-biome-parse.js +84 -0
- package/dist/scripts/ultracite-setup.d.ts +4 -0
- package/dist/scripts/ultracite-setup.js +310 -0
- package/dist/scripts/update-all-init-scripts.d.ts +2 -0
- package/dist/scripts/update-all-init-scripts.js +52 -0
- package/dist/scripts/update-biome-schema.d.ts +15 -0
- package/dist/scripts/update-biome-schema.js +124 -0
- package/dist/src/AutoCoreFacade.d.ts +145 -0
- package/dist/src/AutoCoreFacade.js +217 -0
- package/dist/src/api/ApiActions.d.ts +297 -0
- package/dist/src/api/ApiActions.js +1905 -0
- package/dist/src/api/Certificate.d.ts +60 -0
- package/dist/src/api/Certificate.js +79 -0
- package/dist/src/api/JsonResponse.d.ts +116 -0
- package/dist/src/api/JsonResponse.js +206 -0
- package/dist/src/appium/DeviceFarmViewer.d.ts +79 -0
- package/dist/src/appium/DeviceFarmViewer.js +1083 -0
- package/dist/src/appium/MobileActions.d.ts +347 -0
- package/dist/src/appium/MobileActions.js +1632 -0
- package/dist/src/appium/MobileConnection.d.ts +160 -0
- package/dist/src/appium/MobileConnection.js +772 -0
- package/dist/src/config/envLoader.d.ts +123 -0
- package/dist/src/config/envLoader.js +361 -0
- package/dist/src/config/jest-safe-setup.d.ts +19 -0
- package/dist/src/config/jest-safe-setup.js +369 -0
- package/dist/src/config/timeouts.d.ts +32 -0
- package/dist/src/config/timeouts.js +38 -0
- package/dist/src/desktop/DesktopActions.d.ts +46 -0
- package/dist/src/desktop/DesktopActions.js +398 -0
- package/dist/src/desktop/DesktopConnection.d.ts +32 -0
- package/dist/src/desktop/DesktopConnection.js +84 -0
- package/dist/src/domain/entities/TestExecution.d.ts +117 -0
- package/dist/src/domain/entities/TestExecution.js +150 -0
- package/dist/src/domain/entities/TestReport.d.ts +114 -0
- package/dist/src/domain/entities/TestReport.js +179 -0
- package/dist/src/domain/repositories/ITestRepository.d.ts +196 -0
- package/dist/src/domain/repositories/ITestRepository.js +14 -0
- package/dist/src/domain/schemas/ValidationSchemas.d.ts +159 -0
- package/dist/src/domain/schemas/ValidationSchemas.js +181 -0
- package/dist/src/functions/errors/BaseError.d.ts +78 -0
- package/dist/src/functions/errors/BaseError.js +245 -0
- package/dist/src/functions/errors/ConfigurationError.d.ts +16 -0
- package/dist/src/functions/errors/ConfigurationError.js +48 -0
- package/dist/src/functions/errors/ErrorCatalog.d.ts +148 -0
- package/dist/src/functions/errors/ErrorCatalog.js +157 -0
- package/dist/src/functions/errors/GlobalErrorHandler.d.ts +101 -0
- package/dist/src/functions/errors/GlobalErrorHandler.js +281 -0
- package/dist/src/functions/errors/IntegrationError.d.ts +17 -0
- package/dist/src/functions/errors/IntegrationError.js +51 -0
- package/dist/src/functions/errors/SecurityError.d.ts +14 -0
- package/dist/src/functions/errors/SecurityError.js +42 -0
- package/dist/src/functions/errors/SystemError.d.ts +12 -0
- package/dist/src/functions/errors/SystemError.js +36 -0
- package/dist/src/functions/errors/ValidationError.d.ts +14 -0
- package/dist/src/functions/errors/ValidationError.js +61 -0
- package/dist/src/functions/errors/index.d.ts +12 -0
- package/dist/src/functions/errors/index.js +13 -0
- package/dist/src/global-setup.d.ts +1 -0
- package/dist/src/global-setup.js +1037 -0
- package/dist/src/helpers/BancoActions.d.ts +188 -0
- package/dist/src/helpers/BancoActions.js +581 -0
- package/dist/src/helpers/EnviromentHelper.d.ts +17 -0
- package/dist/src/helpers/EnviromentHelper.js +66 -0
- package/dist/src/helpers/ParallelExecutionHelper.d.ts +183 -0
- package/dist/src/helpers/ParallelExecutionHelper.js +375 -0
- package/dist/src/helpers/SyncSignal.d.ts +15 -0
- package/dist/src/helpers/SyncSignal.js +44 -0
- package/dist/src/hubdocs/CategoryDetector.d.ts +83 -0
- package/dist/src/hubdocs/CategoryDetector.js +401 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.d.ts +54 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.js +243 -0
- package/dist/src/hubdocs/ExecutionTracker.d.ts +107 -0
- package/dist/src/hubdocs/ExecutionTracker.js +702 -0
- package/dist/src/hubdocs/HubDocs.d.ts +395 -0
- package/dist/src/hubdocs/HubDocs.js +3586 -0
- package/dist/src/hubdocs/StatementMethodFilter.d.ts +71 -0
- package/dist/src/hubdocs/StatementMethodFilter.js +618 -0
- package/dist/src/hubdocs/StatementTracker.d.ts +417 -0
- package/dist/src/hubdocs/StatementTracker.js +2419 -0
- package/dist/src/hubdocs/SwaggerGenerator.d.ts +59 -0
- package/dist/src/hubdocs/SwaggerGenerator.js +405 -0
- package/dist/src/hubdocs/index.d.ts +9 -0
- package/dist/src/hubdocs/index.js +9 -0
- package/dist/src/hubdocs/types.d.ts +114 -0
- package/dist/src/hubdocs/types.js +5 -0
- package/dist/src/infrastructure/DependencyContainer.d.ts +142 -0
- package/dist/src/infrastructure/DependencyContainer.js +250 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.d.ts +168 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.js +468 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.d.ts +150 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.js +388 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.d.ts +192 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.js +382 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.d.ts +141 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.js +428 -0
- package/dist/src/interfaces.d.ts +501 -0
- package/dist/src/interfaces.js +25 -0
- package/dist/src/internal/fakes/__fake-actions__.d.ts +17 -0
- package/dist/src/internal/fakes/__fake-actions__.js +21 -0
- package/dist/src/internal/fakes/__forbidden__.d.ts +10 -0
- package/dist/src/internal/fakes/__forbidden__.js +18 -0
- package/dist/src/internal/fakes/__honeypot__.d.ts +15 -0
- package/dist/src/internal/fakes/__honeypot__.js +24 -0
- package/dist/src/octane/OctaneReporter.d.ts +13 -0
- package/dist/src/octane/OctaneReporter.js +61 -0
- package/dist/src/playwright/CryptoActions.d.ts +20 -0
- package/dist/src/playwright/CryptoActions.js +75 -0
- package/dist/src/playwright/EnhancedWebActions.d.ts +7 -0
- package/dist/src/playwright/EnhancedWebActions.js +65 -0
- package/dist/src/playwright/WebActions.d.ts +1599 -0
- package/dist/src/playwright/WebActions.js +11788 -0
- package/dist/src/playwright/actions/ActionTimeline.d.ts +36 -0
- package/dist/src/playwright/actions/ActionTimeline.js +101 -0
- package/dist/src/playwright/actions/RecoveryQueue.d.ts +82 -0
- package/dist/src/playwright/actions/RecoveryQueue.js +130 -0
- package/dist/src/playwright/actions/SelectorCache.d.ts +53 -0
- package/dist/src/playwright/actions/SelectorCache.js +96 -0
- package/dist/src/playwright/actions/index.d.ts +13 -0
- package/dist/src/playwright/actions/index.js +14 -0
- package/dist/src/playwright/actions/types.d.ts +147 -0
- package/dist/src/playwright/actions/types.js +5 -0
- package/dist/src/playwright/fixtures.d.ts +112 -0
- package/dist/src/playwright/fixtures.js +718 -0
- package/dist/src/playwright/network-logs-reporter.d.ts +7 -0
- package/dist/src/playwright/network-logs-reporter.js +66 -0
- package/dist/src/playwright/registerRecoveryWrappers.d.ts +1 -0
- package/dist/src/playwright/registerRecoveryWrappers.js +54 -0
- package/dist/src/security/BuildSecurity.d.ts +12 -0
- package/dist/src/security/BuildSecurity.js +138 -0
- package/dist/src/security/EulaProtection.d.ts +70 -0
- package/dist/src/security/EulaProtection.js +155 -0
- package/dist/src/security/HoneypotManager.d.ts +46 -0
- package/dist/src/security/HoneypotManager.js +234 -0
- package/dist/src/security/KeysManager.d.ts +36 -0
- package/dist/src/security/KeysManager.js +158 -0
- package/dist/src/security/ProofOfWorkIntegration.d.ts +64 -0
- package/dist/src/security/ProofOfWorkIntegration.js +206 -0
- package/dist/src/security/SecurityValidation.d.ts +21 -0
- package/dist/src/security/SecurityValidation.js +163 -0
- package/dist/src/security/SourceMapProtection.d.ts +55 -0
- package/dist/src/security/SourceMapProtection.js +220 -0
- package/dist/src/security/protector.d.ts +1 -0
- package/dist/src/security/protector.js +97 -0
- package/dist/src/ssh/SSHActions.d.ts +262 -0
- package/dist/src/ssh/SSHActions.js +790 -0
- package/dist/src/ssh/SSHClient.d.ts +99 -0
- package/dist/src/ssh/SSHClient.js +409 -0
- package/dist/src/statements/BaseStatement.d.ts +38 -0
- package/dist/src/statements/BaseStatement.js +78 -0
- package/dist/src/testContext/AuthStateManager.d.ts +93 -0
- package/dist/src/testContext/AuthStateManager.js +256 -0
- package/dist/src/testContext/CoverageManager.d.ts +198 -0
- package/dist/src/testContext/CoverageManager.js +917 -0
- package/dist/src/testContext/TestAnnotations.d.ts +476 -0
- package/dist/src/testContext/TestAnnotations.js +2647 -0
- package/dist/src/testContext/TestContext.d.ts +138 -0
- package/dist/src/testContext/TestContext.js +369 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.d.ts +7 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.js +264 -0
- package/dist/src/testContext/UnifiedReportManager.d.ts +211 -0
- package/dist/src/testContext/UnifiedReportManager.js +1206 -0
- package/dist/src/testhub/DynamicConfigManager.d.ts +121 -0
- package/dist/src/testhub/DynamicConfigManager.js +320 -0
- package/dist/src/testhub/SystemsManager.d.ts +119 -0
- package/dist/src/testhub/SystemsManager.js +365 -0
- package/dist/src/testhub/TestHubClient.d.ts +335 -0
- package/dist/src/testhub/TestHubClient.js +1215 -0
- package/dist/src/testhub/TestHubReporter.d.ts +62 -0
- package/dist/src/testhub/TestHubReporter.js +576 -0
- package/dist/src/testhub/TestHubVars.d.ts +116 -0
- package/dist/src/testhub/TestHubVars.js +273 -0
- package/dist/src/utils/ActionInterceptor.d.ts +59 -0
- package/dist/src/utils/ActionInterceptor.js +741 -0
- package/dist/src/utils/ArtifactsCompressor.d.ts +43 -0
- package/dist/src/utils/ArtifactsCompressor.js +181 -0
- package/dist/src/utils/AutoLogsFinal.d.ts +47 -0
- package/dist/src/utils/AutoLogsFinal.js +148 -0
- package/dist/src/utils/CodeGenSession.d.ts +114 -0
- package/dist/src/utils/CodeGenSession.js +264 -0
- package/dist/src/utils/ConfigLogger.d.ts +133 -0
- package/dist/src/utils/ConfigLogger.js +611 -0
- package/dist/src/utils/CustomReporter.d.ts +22 -0
- package/dist/src/utils/CustomReporter.js +352 -0
- package/dist/src/utils/DataStore.d.ts +171 -0
- package/dist/src/utils/DataStore.js +484 -0
- package/dist/src/utils/DatabaseInterceptor.d.ts +19 -0
- package/dist/src/utils/DatabaseInterceptor.js +295 -0
- package/dist/src/utils/DateHelper.d.ts +16 -0
- package/dist/src/utils/DateHelper.js +120 -0
- package/dist/src/utils/DateValidator.d.ts +4 -0
- package/dist/src/utils/DateValidator.js +51 -0
- package/dist/src/utils/DocumentGenerator.d.ts +35 -0
- package/dist/src/utils/DocumentGenerator.js +129 -0
- package/dist/src/utils/EvidenceCapture.d.ts +90 -0
- package/dist/src/utils/EvidenceCapture.js +600 -0
- package/dist/src/utils/EvidenceReportGenerator.d.ts +70 -0
- package/dist/src/utils/EvidenceReportGenerator.js +799 -0
- package/dist/src/utils/FrameManagementUtil.d.ts +42 -0
- package/dist/src/utils/FrameManagementUtil.js +75 -0
- package/dist/src/utils/GlobalStatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/GlobalStatementsInterceptor.js +1 -0
- package/dist/src/utils/HTMLTemplate.d.ts +1 -0
- package/dist/src/utils/HTMLTemplate.js +1034 -0
- package/dist/src/utils/InterceptacaoMagica.d.ts +23 -0
- package/dist/src/utils/InterceptacaoMagica.js +365 -0
- package/dist/src/utils/LogSanitizer.d.ts +35 -0
- package/dist/src/utils/LogSanitizer.js +110 -0
- package/dist/src/utils/Logger.d.ts +65 -0
- package/dist/src/utils/Logger.js +284 -0
- package/dist/src/utils/McpLocalClient.d.ts +141 -0
- package/dist/src/utils/McpLocalClient.js +871 -0
- package/dist/src/utils/PDFEvidenceGenerator.d.ts +20 -0
- package/dist/src/utils/PDFEvidenceGenerator.js +156 -0
- package/dist/src/utils/SpecFileAnalyzer.d.ts +35 -0
- package/dist/src/utils/SpecFileAnalyzer.js +209 -0
- package/dist/src/utils/StatementInterceptor.d.ts +18 -0
- package/dist/src/utils/StatementInterceptor.js +87 -0
- package/dist/src/utils/StatementLogger.d.ts +33 -0
- package/dist/src/utils/StatementLogger.js +113 -0
- package/dist/src/utils/StatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/StatementsInterceptor.js +1 -0
- package/dist/src/utils/TeamsFlushHook.d.ts +17 -0
- package/dist/src/utils/TeamsFlushHook.js +168 -0
- package/dist/src/utils/TerminalLogCapture.d.ts +158 -0
- package/dist/src/utils/TerminalLogCapture.js +531 -0
- package/dist/src/utils/TestMethodLogger.d.ts +70 -0
- package/dist/src/utils/TestMethodLogger.js +95 -0
- package/dist/src/utils/UnifiedTeardown.d.ts +4 -0
- package/dist/src/utils/UnifiedTeardown.js +400 -0
- package/dist/src/utils/XPathCatalog.d.ts +152 -0
- package/dist/src/utils/XPathCatalog.js +350 -0
- package/dist/src/utils/generators.d.ts +90 -0
- package/dist/src/utils/generators.js +167 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.d.ts +152 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.js +715 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.d.ts +801 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.js +1415 -0
- package/dist/src/utils/testRecovery/autoFixCode.d.ts +65 -0
- package/dist/src/utils/testRecovery/autoFixCode.js +32 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +59 -0
- package/dist/wdio.conf.d.ts +1 -0
- package/dist/wdio.conf.js +420 -0
- package/package.json +137 -0
- package/protect-loader.mjs +643 -0
- package/scripts/consumer-postinstall.ts +975 -0
- package/scripts/generate-index.ts +343 -0
- package/scripts/init-api.ts +613 -0
- package/scripts/init-banco.ts +437 -0
- package/scripts/init-frontend.ts +727 -0
- package/scripts/init-mobile.ts +558 -0
- package/scripts/init-scenarios.ts +925 -0
- package/scripts/init-ssh.ts +734 -0
- package/scripts/package-versions.ts +978 -0
- package/scripts/postinstall.ts +605 -0
- package/scripts/smart-override.ts +1675 -0
- package/scripts/sync-configs.ts +302 -0
- package/scripts/ultracite-setup.ts +370 -0
- package/src/types/globals.d.ts +48 -0
- package/tsconfig.json +29 -0
- package/types/autocore-sync-signal.d.ts +10 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import https from 'node:https';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import fetch from 'node-fetch';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const report = { features: [] };
|
|
10
|
+
export function addScenarioToReport(featureName, scenarioName, octaneTag, steps, status) {
|
|
11
|
+
let feature = report.features.find((f) => f.name === featureName);
|
|
12
|
+
if (!feature) {
|
|
13
|
+
feature = { name: featureName, scenarios: [] };
|
|
14
|
+
report.features.push(feature);
|
|
15
|
+
}
|
|
16
|
+
feature.scenarios.push({
|
|
17
|
+
scenario: scenarioName,
|
|
18
|
+
status,
|
|
19
|
+
octane_tag: octaneTag,
|
|
20
|
+
steps,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function saveReport() {
|
|
24
|
+
const outputPath = path.join(__dirname, '..', 'octane-report.json');
|
|
25
|
+
fs.writeFileSync(outputPath, JSON.stringify(report, null, 2));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Envia o relatório octane-report.json para o endpoint do Octane/ALM
|
|
29
|
+
* Ignora validação SSL (inseguro, apenas para ambientes controlados)
|
|
30
|
+
*/
|
|
31
|
+
export async function sendReportToOctane(octaneUrl, clientId, clientSecret) {
|
|
32
|
+
const outputPath = path.join(__dirname, '..', 'octane-report.json');
|
|
33
|
+
if (!fs.existsSync(outputPath)) {
|
|
34
|
+
throw new Error('Relatório octane-report.json não encontrado');
|
|
35
|
+
}
|
|
36
|
+
const reportData = fs.readFileSync(outputPath, 'utf-8');
|
|
37
|
+
// Ignora validação SSL
|
|
38
|
+
let agent = new https.Agent({
|
|
39
|
+
rejectUnauthorized: false,
|
|
40
|
+
});
|
|
41
|
+
if (process.env.USE_PROXY === 'true') {
|
|
42
|
+
const proxyUrl = `http://${process.env.PROXY_HOST}:${process.env.PROXY_PORT}`;
|
|
43
|
+
agent = new HttpsProxyAgent(proxyUrl);
|
|
44
|
+
agent.options.rejectUnauthorized = false;
|
|
45
|
+
}
|
|
46
|
+
const auth = Buffer.from(`${clientId}:${clientSecret}`, 'utf-8').toString('base64');
|
|
47
|
+
const fetchOptions = {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
headers: {
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
Authorization: `Basic ${auth}`,
|
|
52
|
+
},
|
|
53
|
+
body: reportData,
|
|
54
|
+
agent,
|
|
55
|
+
};
|
|
56
|
+
const response = await fetch(octaneUrl, fetchOptions);
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
const errorBody = await response.text();
|
|
59
|
+
throw new Error(`Falha ao enviar relatório para Octane: ${response.status} ${response.statusText} - ${errorBody}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CryptoActions: encrypt/decrypt files using OpenPGP (PGP/GPG compatible)
|
|
3
|
+
* - Uses openpgp v5 API
|
|
4
|
+
*/
|
|
5
|
+
export declare class CryptoActions {
|
|
6
|
+
/**
|
|
7
|
+
* Encrypt a file using a public key (armored). If `armor` is false, output will be binary.
|
|
8
|
+
*/
|
|
9
|
+
static encryptFile(inputPath: string, outputPath: string, publicKeyArmored: string, armor?: boolean): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Decrypt a file using a private key (armored). If private key is encrypted, passphrase is required.
|
|
12
|
+
*/
|
|
13
|
+
static decryptFile(inputPath: string, outputPath: string, privateKeyArmored: string, passphrase?: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Convenience wrappers for GPG compatibility — same OpenPGP format
|
|
16
|
+
*/
|
|
17
|
+
static encryptFileGPG(inputPath: string, outputPath: string, publicKeyArmored: string, armor?: boolean): Promise<void>;
|
|
18
|
+
static decryptFileGPG(inputPath: string, outputPath: string, privateKeyArmored: string, passphrase?: string): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export default CryptoActions;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import * as openpgp from 'openpgp';
|
|
3
|
+
import { Logger } from '../utils/Logger.js';
|
|
4
|
+
/**
|
|
5
|
+
* CryptoActions: encrypt/decrypt files using OpenPGP (PGP/GPG compatible)
|
|
6
|
+
* - Uses openpgp v5 API
|
|
7
|
+
*/
|
|
8
|
+
export class CryptoActions {
|
|
9
|
+
/**
|
|
10
|
+
* Encrypt a file using a public key (armored). If `armor` is false, output will be binary.
|
|
11
|
+
*/
|
|
12
|
+
static async encryptFile(inputPath, outputPath, publicKeyArmored, armor = true) {
|
|
13
|
+
Logger.info(`CryptoActions.encryptFile ${inputPath} => ${outputPath}`);
|
|
14
|
+
const data = fs.readFileSync(inputPath);
|
|
15
|
+
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
|
|
16
|
+
const message = await openpgp.createMessage({ binary: data });
|
|
17
|
+
const encrypted = await openpgp.encrypt({
|
|
18
|
+
message,
|
|
19
|
+
encryptionKeys: publicKey,
|
|
20
|
+
format: armor ? 'armored' : 'binary',
|
|
21
|
+
});
|
|
22
|
+
if (armor && typeof encrypted === 'string') {
|
|
23
|
+
fs.writeFileSync(outputPath, encrypted, 'utf8');
|
|
24
|
+
}
|
|
25
|
+
else if (!armor && encrypted instanceof Uint8Array) {
|
|
26
|
+
fs.writeFileSync(outputPath, Buffer.from(encrypted));
|
|
27
|
+
}
|
|
28
|
+
else if (typeof encrypted === 'string') {
|
|
29
|
+
// fallback
|
|
30
|
+
fs.writeFileSync(outputPath, encrypted, 'utf8');
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
fs.writeFileSync(outputPath, Buffer.from(encrypted));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Decrypt a file using a private key (armored). If private key is encrypted, passphrase is required.
|
|
38
|
+
*/
|
|
39
|
+
static async decryptFile(inputPath, outputPath, privateKeyArmored, passphrase) {
|
|
40
|
+
Logger.info(`CryptoActions.decryptFile ${inputPath} => ${outputPath}`);
|
|
41
|
+
const data = fs.readFileSync(inputPath);
|
|
42
|
+
// Determine if armored
|
|
43
|
+
const asString = data.toString('utf8');
|
|
44
|
+
const isArmored = asString.includes('-----BEGIN PGP');
|
|
45
|
+
let message;
|
|
46
|
+
if (isArmored) {
|
|
47
|
+
message = await openpgp.readMessage({ armoredMessage: asString });
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
message = await openpgp.readMessage({ binaryMessage: new Uint8Array(data) });
|
|
51
|
+
}
|
|
52
|
+
let privKey = await openpgp.readPrivateKey({ armoredKey: privateKeyArmored });
|
|
53
|
+
if (passphrase) {
|
|
54
|
+
privKey = await openpgp.decryptKey({ privateKey: privKey, passphrase });
|
|
55
|
+
}
|
|
56
|
+
const decrypted = await openpgp.decrypt({ message, decryptionKeys: privKey });
|
|
57
|
+
const out = decrypted.data;
|
|
58
|
+
if (typeof out === 'string') {
|
|
59
|
+
fs.writeFileSync(outputPath, out, 'utf8');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
fs.writeFileSync(outputPath, Buffer.from(out));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Convenience wrappers for GPG compatibility — same OpenPGP format
|
|
67
|
+
*/
|
|
68
|
+
static async encryptFileGPG(inputPath, outputPath, publicKeyArmored, armor = true) {
|
|
69
|
+
return this.encryptFile(inputPath, outputPath, publicKeyArmored, armor);
|
|
70
|
+
}
|
|
71
|
+
static async decryptFileGPG(inputPath, outputPath, privateKeyArmored, passphrase) {
|
|
72
|
+
return this.decryptFile(inputPath, outputPath, privateKeyArmored, passphrase);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export default CryptoActions;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Logger } from '../utils/Logger.js';
|
|
2
|
+
export class EnhancedWebActions {
|
|
3
|
+
page;
|
|
4
|
+
constructor(page) {
|
|
5
|
+
this.page = page;
|
|
6
|
+
}
|
|
7
|
+
async waitForSelectorWithRecovery(selector, context, timeout = 120000) {
|
|
8
|
+
Logger.info(`🔄 [EnhancedWebActions] Aguardando seletor: ${selector}`);
|
|
9
|
+
try {
|
|
10
|
+
await this.page.locator(selector).waitFor({ state: 'visible', timeout });
|
|
11
|
+
Logger.success(`✅ [EnhancedWebActions] Seletor encontrado: ${selector}`);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
Logger.warning(`⚠️ [EnhancedWebActions] Falha ao encontrar seletor: ${selector}. Tentando recuperação...`);
|
|
16
|
+
const newSelector = await this.callTestRecoveryAPI(selector, context);
|
|
17
|
+
if (newSelector) {
|
|
18
|
+
Logger.info(`🔄 [EnhancedWebActions] Tentando novo seletor sugerido: ${newSelector}`);
|
|
19
|
+
try {
|
|
20
|
+
await this.page.locator(newSelector).waitFor({ state: 'visible', timeout });
|
|
21
|
+
Logger.success(`✅ [EnhancedWebActions] Novo seletor encontrado: ${newSelector}`);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
catch (recoveryError) {
|
|
25
|
+
Logger.error(`❌ [EnhancedWebActions] Falha ao usar novo seletor: ${newSelector}`, recoveryError);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
Logger.error('❌ [EnhancedWebActions] Nenhum novo seletor sugerido pela API de Test Recovery.');
|
|
30
|
+
}
|
|
31
|
+
Logger.error('❌ [EnhancedWebActions] Erro final ao aguardar seletor', error);
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async callTestRecoveryAPI(failedSelector, context) {
|
|
36
|
+
Logger.info(`🔄 [EnhancedWebActions] Chamando API de Test Recovery para seletor: ${failedSelector}`);
|
|
37
|
+
try {
|
|
38
|
+
const response = await this.page.request.post('http://api.test-recovery.local/analyze-failure', {
|
|
39
|
+
data: {
|
|
40
|
+
selector: failedSelector,
|
|
41
|
+
context,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
if (response.ok()) {
|
|
45
|
+
const result = await response.json();
|
|
46
|
+
const newSelector = result.newSelector;
|
|
47
|
+
const confidence = result.confidence;
|
|
48
|
+
Logger.success(`✅ [EnhancedWebActions] Novo seletor sugerido: ${newSelector} (confiança: ${confidence})`);
|
|
49
|
+
if (confidence >= 0.7) {
|
|
50
|
+
return newSelector;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
Logger.warning('⚠️ [EnhancedWebActions] Confiança baixa no novo seletor. Revisão manual recomendada.');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
Logger.error(`❌ [EnhancedWebActions] Falha ao chamar API de Test Recovery: ${response.status()}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
Logger.error('❌ [EnhancedWebActions] Erro ao tentar chamar API de Test Recovery', error);
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|