mirror of
https://github.com/yaklang/yaklang-chrome-extension.git
synced 2026-09-26 21:21:53 +08:00
fix(browser): improve transform mapping and browser analysis capabilities
CI / Test and build (push) Canceled after 0s
CI / Test and build (push) Canceled after 0s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
BrowserTransformExecuteInput,
|
||||
BrowserTransformPacket,
|
||||
BrowserTransformValidationExecuteInput,
|
||||
} from '@/types/models';
|
||||
import type { CapabilityDomainHandler } from '../capability-context';
|
||||
import { allowedTarget, requireScope } from '../capability-context';
|
||||
@@ -18,7 +19,10 @@ import {
|
||||
} from '@/features/browser-transform/service';
|
||||
import {
|
||||
compareBrowserPackets,
|
||||
browserTransformValidationById,
|
||||
executeBrowserTransformValidation,
|
||||
latestBrowserTransformValidation,
|
||||
prepareCapturedBrowserTransformProfile,
|
||||
proposeBrowserTransformProfile,
|
||||
validateInferredBrowserTransformProfile,
|
||||
} from '@/features/browser-analysis/service';
|
||||
@@ -27,6 +31,17 @@ import { TRANSFORM_CAPABILITY_DOMAIN } from '../capability-domains';
|
||||
export const transformCapabilityHandler: CapabilityDomainHandler = {
|
||||
...TRANSFORM_CAPABILITY_DOMAIN,
|
||||
async handle({ method, input, grant }) {
|
||||
if (method === 'browser.transform.prepare') {
|
||||
requireScope(grant, 'browser.recording.read');
|
||||
requireScope(grant, 'browser.callable.execute');
|
||||
return prepareCapturedBrowserTransformProfile(
|
||||
await allowedTarget(grant, input),
|
||||
String(input.candidateId || ''),
|
||||
input.packet as BrowserTransformPacket,
|
||||
Array.isArray(input.inputPaths) ? input.inputPaths.map(String) : undefined,
|
||||
typeof input.name === 'string' ? input.name : undefined,
|
||||
);
|
||||
}
|
||||
if (method === 'browser.packet.compare') {
|
||||
await allowedTarget(grant, input);
|
||||
return compareBrowserPackets(
|
||||
@@ -123,6 +138,17 @@ export const transformCapabilityHandler: CapabilityDomainHandler = {
|
||||
await allowedTarget(grant, profile.target);
|
||||
return deleteBrowserTransformProfile(profile.id);
|
||||
}
|
||||
if (method === 'browser.transform.validation.execute') {
|
||||
requireScope(grant, 'browser.transform.execute');
|
||||
const executeValidationInput = input as unknown as BrowserTransformValidationExecuteInput;
|
||||
const draft = await browserTransformValidationById(executeValidationInput.validationId);
|
||||
await allowedTarget(grant, draft.profile.target);
|
||||
return executeBrowserTransformValidation(
|
||||
executeValidationInput.validationId,
|
||||
executeValidationInput.direction,
|
||||
executeValidationInput.packet,
|
||||
);
|
||||
}
|
||||
const executeInput = input as unknown as BrowserTransformExecuteInput;
|
||||
const profile = await getBrowserTransformProfile(executeInput.profileId);
|
||||
await allowedTarget(grant, profile.target);
|
||||
|
||||
Reference in New Issue
Block a user