rea-agents 2.0.0 → 2.1.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/README.md +78 -32
- package/bridge/ghidra/ReaGhidraBridge.java +96 -11
- package/dist/application/ArtifactExtraction.js +1 -1
- package/dist/application/ArtifactInventory/classify.js +42 -0
- package/dist/application/ArtifactInventory/hash.js +43 -0
- package/dist/application/ArtifactInventory/reader.js +41 -0
- package/dist/application/ArtifactInventory/scanCanonical.js +155 -0
- package/dist/application/ArtifactInventory/scanReader.js +124 -0
- package/dist/application/ArtifactInventory/types.js +10 -0
- package/dist/application/ArtifactInventory.js +9 -351
- package/dist/application/AuthorizedArtifactInventory.js +2 -2
- package/dist/application/BinarySession.js +47 -270
- package/dist/application/BinarySessionExecution.js +28 -0
- package/dist/application/BinarySessionOpen.js +39 -0
- package/dist/application/BinarySessionRecords.js +149 -0
- package/dist/application/BinarySessionStatus.js +75 -0
- package/dist/application/CapabilityInventory.js +24 -2
- package/dist/application/ClientRegistrationStatus.js +1 -1
- package/dist/application/CrossVersionInventory.js +8 -2
- package/dist/application/CrossVersionInvestigation.js +1 -23
- package/dist/application/CrossVersionInvestigationCollections.js +23 -0
- package/dist/application/DirectAnalysis.js +47 -44
- package/dist/application/Doctor.js +156 -238
- package/dist/application/DoctorDiagnostics.js +180 -0
- package/dist/application/ElectronBoundaryAnalysis.js +23 -7
- package/dist/application/ElectronBoundaryGraphWindows.js +32 -8
- package/dist/application/EnhancedToolPagination.js +22 -0
- package/dist/application/EnhancedToolTypes.js +4 -0
- package/dist/application/EnhancedTools.js +20 -37
- package/dist/application/InstrumentedJavaScriptReplayHost.js +36 -0
- package/dist/application/InvestigationWorkspaceStore.js +24 -10
- package/dist/application/JavaScriptArtifactAnalysis.js +45 -6
- package/dist/application/JavaScriptArtifactFiles.js +6 -2
- package/dist/application/JavaScriptArtifactGraphBuilder.js +23 -1
- package/dist/application/JavaScriptArtifactGraphBundlers.js +225 -0
- package/dist/application/JavaScriptArtifactGraphContext.js +37 -36
- package/dist/application/JavaScriptArtifactGraphDocuments.js +27 -4
- package/dist/application/JavaScriptArtifactGraphFindings.js +54 -8
- package/dist/application/JavaScriptArtifactGraphStructure.js +29 -101
- package/dist/application/JavaScriptArtifactPathResolution.js +269 -0
- package/dist/application/JavaScriptArtifactReconstruction.js +1 -1
- package/dist/application/JavaScriptJsonModules.js +39 -0
- package/dist/application/JavaScriptModuleRelationships.js +262 -0
- package/dist/application/JavaScriptReplayPermission.js +16 -0
- package/dist/application/JavaScriptReplayService.js +182 -156
- package/dist/application/LinuxHopper.js +10 -0
- package/dist/application/MacHopper.js +22 -11
- package/dist/application/NodeRuntimeCharacterizationService.js +196 -0
- package/dist/application/PermissionAuthority.js +106 -63
- package/dist/application/ProcessCaptureCapability.js +1 -1
- package/dist/application/ProcessCapturePermission.js +13 -0
- package/dist/application/ProcessCli.js +2 -12
- package/dist/application/ProcessHarness.js +1 -1
- package/dist/application/ProjectPermissionStore.js +48 -9
- package/dist/application/RealHopperAssertions.js +76 -0
- package/dist/application/ReconstructionCoverageService.js +69 -0
- package/dist/application/ReconstructionCoverageWorkspaceStore.js +31 -0
- package/dist/application/RuntimeExecutableDiagnostics.js +172 -0
- package/dist/application/Setup.js +147 -259
- package/dist/application/SetupClientConfiguration.js +220 -0
- package/dist/application/SetupClients.js +24 -2
- package/dist/application/SetupPlan.js +123 -12
- package/dist/application/SetupSkill.js +26 -12
- package/dist/application/SupportedClients.js +1 -0
- package/dist/application/Uninstall.js +6 -3
- package/dist/application/WindowsCapabilities.js +86 -0
- package/dist/artifacts/AsarArtifactReader.js +11 -0
- package/dist/browser/BrowserProcessStartup.js +88 -0
- package/dist/browser/CdpCaptureDocuments.js +12 -8
- package/dist/browser/CdpCaptureEventBodyShapes.js +75 -0
- package/dist/browser/CdpCaptureEventHandlers.js +336 -0
- package/dist/browser/CdpCaptureEventHelpers.js +71 -0
- package/dist/browser/CdpCaptureEventState.js +1 -0
- package/dist/browser/CdpCaptureEventTypes.js +1 -0
- package/dist/browser/CdpCaptureEvents.js +29 -496
- package/dist/browser/CdpObservationSession.js +51 -8
- package/dist/browser/CdpPageCapture.js +12 -133
- package/dist/browser/CdpPageCaptureScripts.js +97 -0
- package/dist/browser/CdpPageCaptureWorkers.js +46 -0
- package/dist/browser/CdpWebMcpDiscovery.js +38 -14
- package/dist/browser/PngVisualDiff.js +9 -2
- package/dist/catalogIdentity.js +4 -0
- package/dist/cli/artifactCommands.js +82 -0
- package/dist/cli/coreAnalysisCommands.js +232 -0
- package/dist/cli/managedCommands.js +397 -0
- package/dist/cli/managedProjectGraphCommand.js +24 -0
- package/dist/cli/options.js +9 -0
- package/dist/cli/setupCommands.js +108 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/utilityCommands.js +122 -0
- package/dist/cli.js +10 -768
- package/dist/cliApplicationCommands.js +118 -4
- package/dist/cliBrowserAdvancedCommands.js +73 -16
- package/dist/cliBrowserCommands.js +39 -115
- package/dist/cliCommandNames.js +4 -0
- package/dist/cliElectronCommands.js +33 -62
- package/dist/cliEvidenceCommands.js +13 -2
- package/dist/cliInvestigationCommands.js +53 -10
- package/dist/cliObservationOptions.js +137 -0
- package/dist/cliPolicyCommands.js +80 -46
- package/dist/cliSetup.js +289 -0
- package/dist/config/environment.js +107 -0
- package/dist/config/parseConfig.js +228 -0
- package/dist/config/parsers.js +68 -0
- package/dist/config/permissions.js +30 -0
- package/dist/config/types.js +1 -0
- package/dist/config.js +1 -375
- package/dist/contracts/applicationToolContracts.js +134 -0
- package/dist/contracts/managedToolContracts.js +1 -1
- package/dist/contracts/managedWorkflowToolContracts.js +3 -3
- package/dist/contracts/providerSelection.js +2 -0
- package/dist/contracts/toolContracts.js +2 -2
- package/dist/contracts/toolEffects.js +14 -0
- package/dist/contracts/toolOutputSchemaGroups.js +232 -0
- package/dist/contracts/toolOutputSchemaPrimitives.js +327 -0
- package/dist/contracts/toolOutputSchemas.js +2 -550
- package/dist/domain/analysisErrorPresentation.js +234 -0
- package/dist/domain/analysisErrorProjection.js +284 -0
- package/dist/domain/artifactComparison.js +34 -15
- package/dist/domain/binaryTarget.js +87 -37
- package/dist/domain/browserObservation.js +1 -285
- package/dist/domain/browserObservationSchemas.js +286 -0
- package/dist/domain/electronStaticAnalysisBrowser.js +14 -2
- package/dist/domain/errors.js +4 -486
- package/dist/domain/functionComparison.js +4 -165
- package/dist/domain/functionComparisonDimensions.js +164 -0
- package/dist/domain/javascriptApplicationVersionItems.js +18 -6
- package/dist/domain/javascriptApplicationVersionKeys.js +8 -8
- package/dist/domain/javascriptExportInstrumentation.js +97 -0
- package/dist/domain/javascriptFeatureTraversal.js +19 -7
- package/dist/domain/javascriptRuntimeStaticCandidates.js +3 -1
- package/dist/domain/javascriptSemanticAnalysis.js +386 -0
- package/dist/domain/javascriptSemanticIr.js +30 -0
- package/dist/domain/javascriptSemanticProjection.js +366 -0
- package/dist/domain/javascriptSemanticState.js +40 -0
- package/dist/domain/javascriptSemanticTraversal.js +22 -0
- package/dist/domain/javascriptSemanticValues.js +352 -0
- package/dist/domain/javascriptStaticAnalysis.js +5 -221
- package/dist/domain/javascriptStaticAnalysisBundler.js +209 -0
- package/dist/domain/javascriptStaticAnalysisCalls.js +180 -0
- package/dist/domain/javascriptStaticAnalysisHelpers.js +71 -2
- package/dist/domain/knownPageCoverage.js +21 -0
- package/dist/domain/managedApplicationGraph.js +14 -364
- package/dist/domain/managedApplicationGraphCoverage.js +170 -0
- package/dist/domain/managedApplicationGraphNodeCoverage.js +6 -0
- package/dist/domain/managedApplicationGraphNodes.js +336 -0
- package/dist/domain/managedArtifact.js +16 -8
- package/dist/domain/managedMemberComparison.js +37 -391
- package/dist/domain/managedMemberComparisonCoverage.js +72 -0
- package/dist/domain/managedMemberComparisonMatch.js +356 -0
- package/dist/domain/managedNativeVerification.js +27 -389
- package/dist/domain/managedNativeVerificationMatch.js +272 -0
- package/dist/domain/managedNativeVerificationSchemas.js +141 -0
- package/dist/domain/managedReconstruction.js +82 -69
- package/dist/domain/managedRuntimeCorrelation.js +12 -3
- package/dist/domain/nodeRuntimeCharacterization.js +66 -0
- package/dist/domain/permissionPolicy.js +2 -0
- package/dist/domain/reconstructionCoverage.js +387 -0
- package/dist/domain/reconstructionCoverageEvaluation.js +212 -0
- package/dist/domain/reconstructionVerificationSchemas.js +8 -0
- package/dist/domain/runtimeCharacterization.js +85 -0
- package/dist/domain/webBundleAnalyzer.js +3 -409
- package/dist/domain/webBundleAnalyzerAst.js +77 -0
- package/dist/domain/webBundleAnalyzerInspection.js +307 -0
- package/dist/domain/webBundleAnalyzerResult.js +120 -0
- package/dist/dotnet/ManagedArtifactInspector.js +50 -29
- package/dist/dotnet/ManagedMemberInspector.js +51 -785
- package/dist/dotnet/ManagedMemberInspectorCore.js +297 -0
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +427 -0
- package/dist/dotnet/ManagedMemberRows.js +120 -0
- package/dist/dotnet/ManagedMetadataInventory.js +42 -306
- package/dist/dotnet/ManagedMetadataInventoryRows.js +292 -0
- package/dist/dotnet/ManagedMetadataLayout.js +48 -111
- package/dist/dotnet/ManagedMetadataRowSizes.js +54 -0
- package/dist/dotnet/ManagedMethodBodyReader.js +143 -0
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +311 -0
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +102 -350
- package/dist/dotnet/ManagedPeReader.js +59 -28
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraClient.js +76 -91
- package/dist/ghidra/GhidraClientStartup.js +29 -0
- package/dist/ghidra/GhidraClientWire.js +34 -0
- package/dist/ghidra/GhidraDefaults.js +1 -1
- package/dist/ghidra/GhidraDiagnostics.js +6 -1
- package/dist/ghidra/GhidraInstallation.js +20 -15
- package/dist/ghidra/GhidraLauncher.js +93 -29
- package/dist/ghidra/GhidraProvider.js +61 -161
- package/dist/ghidra/GhidraProviderCapabilities.js +173 -0
- package/dist/ghidra/GhidraSessionValues.js +2 -0
- package/dist/ghidra/GhidraSocketConnection.js +44 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +30 -0
- package/dist/ghidra/GhidraTransport.js +71 -0
- package/dist/identity.js +3 -2
- package/dist/main/messages.js +5 -0
- package/dist/main/reload.js +49 -0
- package/dist/main/shutdown.js +25 -0
- package/dist/main/startup.js +14 -0
- package/dist/main/state.js +26 -0
- package/dist/main/transport.js +61 -0
- package/dist/main/types.js +1 -0
- package/dist/main.js +35 -146
- package/dist/process/PrivateRuntimeRoot.js +3 -2
- package/dist/process/ProcessOwnership.js +35 -0
- package/dist/process/ProviderProcess.js +2 -0
- package/dist/replay/JavaScriptReplayWorker.js +64 -50
- package/dist/replay/LinuxJavaScriptReplayRunner.js +173 -390
- package/dist/replay/LinuxJavaScriptReplaySandbox.js +140 -0
- package/dist/replay/ReplayOutcome.js +95 -0
- package/dist/replay/ReplayProcessLifecycle.js +71 -0
- package/dist/server/ProcessCaptureElicitation.js +157 -0
- package/dist/server/createServer.js +119 -54
- package/dist/server/registerApplicationTools/characterization.js +57 -0
- package/dist/server/registerApplicationTools/compareVersions.js +34 -0
- package/dist/server/registerApplicationTools/controlledReplay.js +38 -0
- package/dist/server/registerApplicationTools/coverage.js +84 -0
- package/dist/server/registerApplicationTools/helpers.js +42 -0
- package/dist/server/registerApplicationTools/traceFeature.js +26 -0
- package/dist/server/registerApplicationTools/types.js +1 -0
- package/dist/server/registerApplicationTools.js +10 -112
- package/dist/server/registerBrowserTools.js +59 -83
- package/dist/server/registerElectronTools.js +31 -46
- package/dist/server/registerEnhancedTools.js +34 -42
- package/dist/server/registerEvidenceResources.js +54 -0
- package/dist/server/registerInvestigationTools/helpers.js +74 -0
- package/dist/server/registerInvestigationTools/types.js +1 -0
- package/dist/server/registerInvestigationTools.js +83 -116
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +65 -0
- package/dist/server/registerManagedWorkflowTools/contract.js +8 -0
- package/dist/server/registerManagedWorkflowTools/evidence.js +43 -0
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +39 -0
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +39 -0
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +52 -0
- package/dist/server/registerManagedWorkflowTools/types.js +1 -0
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +75 -0
- package/dist/server/registerManagedWorkflowTools.js +10 -274
- package/dist/server/registerOfficialTools.js +73 -59
- package/dist/server/registerSessionRecordTools.js +137 -0
- package/dist/server/registerSessionStatusTool.js +2 -1
- package/dist/server/registerSessionTools.js +60 -164
- package/dist/server/sessionAvailabilityPolicy.js +10 -0
- package/dist/server/toolRegistrationOptions.js +101 -3
- package/dist/server/toolResult.js +5 -0
- package/package.json +10 -11
- package/skills/{rea-analysis → reverse-engineer-anything}/SKILL.md +20 -7
- package/scripts/prepare-node-pty.mjs +0 -35
- package/scripts/rebuild-native.mjs +0 -22
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { inferJsonShape } from "../domain/jsonShape.js";
|
|
2
1
|
import { CdpCaptureCompleteness } from "./CdpCaptureCompleteness.js";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
2
|
+
import * as bodyShapes from "./CdpCaptureEventBodyShapes.js";
|
|
3
|
+
import * as handlers from "./CdpCaptureEventHandlers.js";
|
|
4
|
+
import { isJsonMediaType } from "./CdpCaptureEventHelpers.js";
|
|
5
|
+
import { recordValue } from "./CdpCaptureValues.js";
|
|
6
|
+
export {} from "./CdpCaptureEventTypes.js";
|
|
6
7
|
/** Bounded event accumulator that drops payload values at ingestion time. */
|
|
7
8
|
export class CdpCaptureEvents {
|
|
8
|
-
input;
|
|
9
|
-
allowedOrigins;
|
|
10
9
|
scripts = new Map();
|
|
11
10
|
executionContextFrames = new Map();
|
|
12
11
|
network = new Map();
|
|
@@ -24,16 +23,18 @@ export class CdpCaptureEvents {
|
|
|
24
23
|
]);
|
|
25
24
|
originViolation = false;
|
|
26
25
|
navigationDuringCapture = false;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
mainFrameId = undefined;
|
|
27
|
+
consoleTextBytes = 0;
|
|
28
|
+
jsonBodyBytes = 0;
|
|
29
|
+
websocketShapeBytes = 0;
|
|
30
|
+
input;
|
|
31
|
+
allowedOrigins;
|
|
31
32
|
constructor(input, allowedOrigins) {
|
|
32
33
|
this.input = input;
|
|
33
34
|
this.allowedOrigins = allowedOrigins;
|
|
34
35
|
}
|
|
35
36
|
beginAuthorizedFrame(frameId) {
|
|
36
|
-
this
|
|
37
|
+
this.mainFrameId = frameId;
|
|
37
38
|
this.originViolation = false;
|
|
38
39
|
this.navigationDuringCapture = false;
|
|
39
40
|
this.scripts.clear();
|
|
@@ -44,9 +45,9 @@ export class CdpCaptureEvents {
|
|
|
44
45
|
this.websockets.length = 0;
|
|
45
46
|
this.responseMetadata.length = 0;
|
|
46
47
|
this.agentHints.length = 0;
|
|
47
|
-
this
|
|
48
|
-
this
|
|
49
|
-
this
|
|
48
|
+
this.consoleTextBytes = 0;
|
|
49
|
+
this.jsonBodyBytes = 0;
|
|
50
|
+
this.websocketShapeBytes = 0;
|
|
50
51
|
this.completeness.reset();
|
|
51
52
|
if (!this.input.include_console_text)
|
|
52
53
|
this.completeness.exclude("console_text", "not_approved", null);
|
|
@@ -56,7 +57,7 @@ export class CdpCaptureEvents {
|
|
|
56
57
|
this.completeness.exclude("websocket_shapes", "not_approved", null);
|
|
57
58
|
}
|
|
58
59
|
beginFinalCapture(frameId) {
|
|
59
|
-
this
|
|
60
|
+
this.mainFrameId = frameId;
|
|
60
61
|
this.navigationDuringCapture = false;
|
|
61
62
|
}
|
|
62
63
|
ingest(event) {
|
|
@@ -65,40 +66,40 @@ export class CdpCaptureEvents {
|
|
|
65
66
|
return;
|
|
66
67
|
switch (event.method) {
|
|
67
68
|
case "Runtime.executionContextCreated":
|
|
68
|
-
this
|
|
69
|
+
handlers.handleExecutionContextCreated(this, params);
|
|
69
70
|
break;
|
|
70
71
|
case "Runtime.executionContextDestroyed":
|
|
71
|
-
this
|
|
72
|
+
handlers.handleExecutionContextDestroyed(this, params);
|
|
72
73
|
break;
|
|
73
74
|
case "Runtime.executionContextsCleared":
|
|
74
75
|
this.executionContextFrames.clear();
|
|
75
76
|
break;
|
|
76
77
|
case "Debugger.scriptParsed":
|
|
77
|
-
this
|
|
78
|
+
handlers.handleScriptParsed(this, params);
|
|
78
79
|
break;
|
|
79
80
|
case "Network.requestWillBeSent":
|
|
80
|
-
this
|
|
81
|
+
handlers.handleRequestWillBeSent(this, params);
|
|
81
82
|
break;
|
|
82
83
|
case "Network.responseReceived":
|
|
83
|
-
this
|
|
84
|
+
handlers.handleResponseReceived(this, params);
|
|
84
85
|
break;
|
|
85
86
|
case "Network.loadingFinished":
|
|
86
|
-
this
|
|
87
|
+
handlers.handleLoadingFinished(this, params);
|
|
87
88
|
break;
|
|
88
89
|
case "Runtime.consoleAPICalled":
|
|
89
|
-
this
|
|
90
|
+
handlers.handleConsoleAPICalled(this, params);
|
|
90
91
|
break;
|
|
91
92
|
case "Page.frameNavigated":
|
|
92
|
-
this
|
|
93
|
+
handlers.handleFrameNavigated(this, params);
|
|
93
94
|
break;
|
|
94
95
|
case "Network.webSocketCreated":
|
|
95
|
-
this
|
|
96
|
+
handlers.handleWebSocketCreated(this, params);
|
|
96
97
|
break;
|
|
97
98
|
case "Network.webSocketFrameSent":
|
|
98
|
-
this
|
|
99
|
+
handlers.handleWebSocketFrame(this, params, "sent");
|
|
99
100
|
break;
|
|
100
101
|
case "Network.webSocketFrameReceived":
|
|
101
|
-
this
|
|
102
|
+
handlers.handleWebSocketFrame(this, params, "received");
|
|
102
103
|
break;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
@@ -111,220 +112,6 @@ export class CdpCaptureEvents {
|
|
|
111
112
|
? frameId
|
|
112
113
|
: null;
|
|
113
114
|
}
|
|
114
|
-
#executionContext(params) {
|
|
115
|
-
const context = recordValue(params.context);
|
|
116
|
-
const identifier = numberValue(context?.id);
|
|
117
|
-
const frameId = stringValue(recordValue(context?.auxData)?.frameId);
|
|
118
|
-
if (identifier === undefined ||
|
|
119
|
-
!Number.isSafeInteger(identifier) ||
|
|
120
|
-
frameId === undefined ||
|
|
121
|
-
frameId.length > 256)
|
|
122
|
-
return;
|
|
123
|
-
const key = String(identifier);
|
|
124
|
-
if (this.executionContextFrames.size >= this.input.limits.max_scripts &&
|
|
125
|
-
!this.executionContextFrames.has(key)) {
|
|
126
|
-
this.completeness.truncate("scripts");
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
this.executionContextFrames.set(key, frameId);
|
|
130
|
-
}
|
|
131
|
-
#destroyExecutionContext(params) {
|
|
132
|
-
const key = executionContextKey(params.executionContextId);
|
|
133
|
-
if (key !== null)
|
|
134
|
-
this.executionContextFrames.delete(key);
|
|
135
|
-
}
|
|
136
|
-
#script(params) {
|
|
137
|
-
const scriptId = stringValue(params.scriptId);
|
|
138
|
-
const rawUrl = stringValue(params.url) ?? "";
|
|
139
|
-
const sanitized = allowedSanitizedUrl(rawUrl, this.allowedOrigins);
|
|
140
|
-
if (scriptId === undefined || scriptId.length > 256) {
|
|
141
|
-
this.completeness.exclude("scripts", "invalid_protocol_value");
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (sanitized === undefined) {
|
|
145
|
-
this.completeness.exclude("scripts", exclusionReasonForUrl(rawUrl));
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (this.scripts.size >= this.input.limits.max_scripts &&
|
|
149
|
-
!this.scripts.has(scriptId)) {
|
|
150
|
-
this.completeness.drop("scripts");
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const sourceMap = this.#sourceMap(params.sourceMapURL, rawUrl);
|
|
154
|
-
this.scripts.set(scriptId, {
|
|
155
|
-
scriptId,
|
|
156
|
-
rawUrl,
|
|
157
|
-
url: sanitized.url,
|
|
158
|
-
origin: sanitized.origin,
|
|
159
|
-
hash: (stringValue(params.hash) ?? "").slice(0, 512),
|
|
160
|
-
length: Math.max(0, Math.min(Number.MAX_SAFE_INTEGER, Math.trunc(numberValue(params.length) ?? 0))),
|
|
161
|
-
isModule: params.isModule === true,
|
|
162
|
-
language: boundedText(params.scriptLanguage, 100),
|
|
163
|
-
sourceMapUrl: sourceMap.sanitized,
|
|
164
|
-
sourceMapRawUrl: sourceMap.raw,
|
|
165
|
-
executionContextKey: executionContextKey(params.executionContextId),
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
#sourceMap(value, scriptUrl) {
|
|
169
|
-
const declaredUrl = stringValue(value);
|
|
170
|
-
if (declaredUrl === undefined || declaredUrl === "")
|
|
171
|
-
return { sanitized: null, raw: null };
|
|
172
|
-
let rawUrl;
|
|
173
|
-
try {
|
|
174
|
-
rawUrl = new URL(declaredUrl, scriptUrl).href;
|
|
175
|
-
}
|
|
176
|
-
catch {
|
|
177
|
-
this.completeness.exclude("source_maps", "unsupported_url");
|
|
178
|
-
return { sanitized: null, raw: null };
|
|
179
|
-
}
|
|
180
|
-
const sanitized = allowedSanitizedUrl(rawUrl, this.allowedOrigins);
|
|
181
|
-
if (sanitized !== undefined)
|
|
182
|
-
return { sanitized: sanitized.url, raw: rawUrl };
|
|
183
|
-
this.completeness.exclude("source_maps", exclusionReasonForUrl(rawUrl));
|
|
184
|
-
return { sanitized: null, raw: null };
|
|
185
|
-
}
|
|
186
|
-
#request(params) {
|
|
187
|
-
const requestId = stringValue(params.requestId);
|
|
188
|
-
const request = recordValue(params.request);
|
|
189
|
-
if (requestId === undefined || requestId.length > 256) {
|
|
190
|
-
this.completeness.exclude("network_requests", "invalid_protocol_value");
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
if (request === undefined) {
|
|
194
|
-
this.completeness.exclude("network_requests", "invalid_protocol_value");
|
|
195
|
-
this.network.delete(requestId);
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
const sanitized = allowedSanitizedUrl(request.url, this.allowedOrigins);
|
|
199
|
-
if (sanitized === undefined) {
|
|
200
|
-
this.completeness.exclude("network_requests", exclusionReasonForUrl(stringValue(request.url)));
|
|
201
|
-
this.network.delete(requestId);
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (this.network.size >= this.input.limits.max_network_events &&
|
|
205
|
-
!this.network.has(requestId)) {
|
|
206
|
-
this.completeness.drop("network_requests");
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const initiator = recordValue(params.initiator);
|
|
210
|
-
const initiatorFrame = initiatorLocation(initiator);
|
|
211
|
-
const rawInitiatorUrl = stringValue(initiatorFrame?.url);
|
|
212
|
-
const initiatorUrl = allowedSanitizedUrl(rawInitiatorUrl, this.allowedOrigins);
|
|
213
|
-
if (rawInitiatorUrl !== undefined && initiatorUrl === undefined)
|
|
214
|
-
this.completeness.exclude("network_initiators", exclusionReasonForUrl(rawInitiatorUrl));
|
|
215
|
-
this.network.set(requestId, {
|
|
216
|
-
request_id: requestId,
|
|
217
|
-
url: sanitized.url,
|
|
218
|
-
origin: sanitized.origin ?? "",
|
|
219
|
-
method: (stringValue(request.method) ?? "GET").slice(0, 32),
|
|
220
|
-
resource_type: boundedText(params.type, 100),
|
|
221
|
-
status: null,
|
|
222
|
-
mime_type: null,
|
|
223
|
-
encoded_data_length: null,
|
|
224
|
-
initiator: {
|
|
225
|
-
type: (stringValue(initiator?.type) ?? "other").slice(0, 100),
|
|
226
|
-
url: initiatorUrl?.url ?? null,
|
|
227
|
-
line: integerOrNull(initiatorFrame?.lineNumber),
|
|
228
|
-
column: integerOrNull(initiatorFrame?.columnNumber),
|
|
229
|
-
},
|
|
230
|
-
body_shapes: this.#requestBodyShape(request),
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
#response(params) {
|
|
234
|
-
const requestId = stringValue(params.requestId);
|
|
235
|
-
if (requestId === undefined || requestId.length > 256) {
|
|
236
|
-
this.completeness.exclude("network_requests", "invalid_protocol_value");
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
const current = this.network.get(requestId);
|
|
240
|
-
const response = recordValue(params.response);
|
|
241
|
-
if (current === undefined)
|
|
242
|
-
return;
|
|
243
|
-
const sanitized = allowedSanitizedUrl(response?.url, this.allowedOrigins);
|
|
244
|
-
if (response === undefined || sanitized === undefined) {
|
|
245
|
-
this.completeness.exclude("network_requests", response === undefined
|
|
246
|
-
? "invalid_protocol_value"
|
|
247
|
-
: exclusionReasonForUrl(stringValue(response.url)));
|
|
248
|
-
this.network.delete(requestId);
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
this.network.set(requestId, {
|
|
252
|
-
...current,
|
|
253
|
-
status: numberValue(response.status) ?? null,
|
|
254
|
-
mime_type: boundedText(response.mimeType, 256),
|
|
255
|
-
});
|
|
256
|
-
if (this.responseMetadata.length >= this.input.limits.max_network_events) {
|
|
257
|
-
this.completeness.truncate("metadata");
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
const metadata = safeResponseMetadata(requestId, sanitized.url, response, this.allowedOrigins);
|
|
261
|
-
this.responseMetadata.push(metadata.response);
|
|
262
|
-
this.agentHints.push(...metadata.agentHints);
|
|
263
|
-
}
|
|
264
|
-
#finished(params) {
|
|
265
|
-
const requestId = stringValue(params.requestId);
|
|
266
|
-
if (requestId === undefined || requestId.length > 256)
|
|
267
|
-
return;
|
|
268
|
-
const current = this.network.get(requestId);
|
|
269
|
-
if (current === undefined)
|
|
270
|
-
return;
|
|
271
|
-
this.network.set(requestId, {
|
|
272
|
-
...current,
|
|
273
|
-
encoded_data_length: Math.max(0, numberValue(params.encodedDataLength) ?? 0),
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
#console(params) {
|
|
277
|
-
const frame = firstCallFrame(recordValue(params.stackTrace));
|
|
278
|
-
if (frame === undefined) {
|
|
279
|
-
this.completeness.exclude("console_events", "unattributed_origin");
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
const source = allowedSanitizedUrl(frame.url, this.allowedOrigins);
|
|
283
|
-
if (source === undefined) {
|
|
284
|
-
this.completeness.exclude("console_events", exclusionReasonForUrl(stringValue(frame.url)));
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
if (this.console.length >= this.input.limits.max_console_events) {
|
|
288
|
-
this.completeness.drop("console_events");
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
const arguments_ = recordsValue(params.args);
|
|
292
|
-
this.console.push({
|
|
293
|
-
type: (stringValue(params.type) ?? "unknown").slice(0, 100),
|
|
294
|
-
timestamp: numberValue(params.timestamp) ?? 0,
|
|
295
|
-
argument_types: arguments_
|
|
296
|
-
.map((argument) => (stringValue(argument.type) ?? "unknown").slice(0, 100))
|
|
297
|
-
.slice(0, 100),
|
|
298
|
-
url: source.url,
|
|
299
|
-
line: integerOrNull(frame.lineNumber),
|
|
300
|
-
column: integerOrNull(frame.columnNumber),
|
|
301
|
-
text_capture: this.#consoleText(arguments_),
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
#websocket(params, direction) {
|
|
305
|
-
const requestId = stringValue(params.requestId);
|
|
306
|
-
if (requestId === undefined ||
|
|
307
|
-
requestId.length > 256 ||
|
|
308
|
-
(!this.network.has(requestId) && !this.allowedWebSockets.has(requestId)))
|
|
309
|
-
return;
|
|
310
|
-
if (this.websockets.length >= this.input.limits.max_websocket_events) {
|
|
311
|
-
this.completeness.drop("websocket_frames");
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
const response = recordValue(params.response);
|
|
315
|
-
const payload = stringValue(response?.payloadData) ?? "";
|
|
316
|
-
const opcode = Math.max(0, Math.trunc(numberValue(response?.opcode) ?? 0));
|
|
317
|
-
const decoded = opcode === 1 ? undefined : decodeBase64(payload);
|
|
318
|
-
if (opcode !== 1 && decoded === undefined)
|
|
319
|
-
this.completeness.exclude("websocket_frames", "invalid_protocol_value");
|
|
320
|
-
this.websockets.push({
|
|
321
|
-
request_id: requestId,
|
|
322
|
-
direction,
|
|
323
|
-
opcode,
|
|
324
|
-
payload_bytes: opcode === 1 ? Buffer.byteLength(payload) : (decoded?.byteLength ?? 0),
|
|
325
|
-
payload_shape: this.#websocketShape(payload, opcode),
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
115
|
responseBodyRequestIds() {
|
|
329
116
|
if (!this.input.include_json_body_shapes)
|
|
330
117
|
return [];
|
|
@@ -333,264 +120,10 @@ export class CdpCaptureEvents {
|
|
|
333
120
|
.map((request) => request.request_id);
|
|
334
121
|
}
|
|
335
122
|
responseBodyUnavailable(requestId) {
|
|
336
|
-
this
|
|
123
|
+
bodyShapes.updateResponseBodyShape(this, requestId, null, false);
|
|
337
124
|
this.completeness.unavailable("json_body_shapes");
|
|
338
125
|
}
|
|
339
126
|
ingestResponseBody(requestId, value) {
|
|
340
|
-
|
|
341
|
-
const body = stringValue(result?.body);
|
|
342
|
-
if (body === undefined) {
|
|
343
|
-
this.#invalidResponseBody(requestId);
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
const decoded = result?.base64Encoded === true
|
|
347
|
-
? decodeBase64(body)?.toString("utf8")
|
|
348
|
-
: body;
|
|
349
|
-
if (decoded === undefined) {
|
|
350
|
-
this.#invalidResponseBody(requestId);
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
const inferred = this.#inferBodyShape(decoded);
|
|
354
|
-
this.#updateResponseShape(requestId, inferred.shape, inferred.truncated);
|
|
355
|
-
}
|
|
356
|
-
#invalidResponseBody(requestId) {
|
|
357
|
-
this.#updateResponseShape(requestId, null, false);
|
|
358
|
-
this.completeness.exclude("json_body_shapes", "invalid_protocol_value");
|
|
359
|
-
}
|
|
360
|
-
#requestBodyShape(request) {
|
|
361
|
-
if (!this.input.include_json_body_shapes)
|
|
362
|
-
return { status: "not_approved", request: null, response: null };
|
|
363
|
-
const body = stringValue(request.postData);
|
|
364
|
-
if (!isJsonContentType(recordValue(request.headers)) || body === undefined)
|
|
365
|
-
return { status: "unavailable", request: null, response: null };
|
|
366
|
-
const inferred = this.#inferBodyShape(body);
|
|
367
|
-
return {
|
|
368
|
-
status: inferred.truncated
|
|
369
|
-
? "truncated"
|
|
370
|
-
: inferred.shape === null
|
|
371
|
-
? "unavailable"
|
|
372
|
-
: "included",
|
|
373
|
-
request: inferred.shape,
|
|
374
|
-
response: null,
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
#inferBodyShape(text) {
|
|
378
|
-
const bytes = Buffer.byteLength(text);
|
|
379
|
-
const remaining = this.input.limits.max_total_json_body_bytes - this.#jsonBodyBytes;
|
|
380
|
-
if (bytes > this.input.limits.max_json_body_bytes || bytes > remaining) {
|
|
381
|
-
this.completeness.truncate("json_body_shapes");
|
|
382
|
-
return { shape: null, truncated: true };
|
|
383
|
-
}
|
|
384
|
-
this.#jsonBodyBytes += bytes;
|
|
385
|
-
const shape = inferJsonShape(text, {
|
|
386
|
-
maximumBytes: this.input.limits.max_json_body_bytes,
|
|
387
|
-
maximumNodes: this.input.limits.max_json_shape_nodes,
|
|
388
|
-
maximumDepth: this.input.limits.max_json_shape_depth,
|
|
389
|
-
});
|
|
390
|
-
if (shape?.truncated === true)
|
|
391
|
-
this.completeness.truncate("json_body_shapes");
|
|
392
|
-
return { shape, truncated: shape?.truncated === true };
|
|
393
|
-
}
|
|
394
|
-
#updateResponseShape(requestId, response, truncated) {
|
|
395
|
-
const current = this.network.get(requestId);
|
|
396
|
-
if (current === undefined)
|
|
397
|
-
return;
|
|
398
|
-
const request = current.body_shapes.request;
|
|
399
|
-
const status = truncated || current.body_shapes.status === "truncated"
|
|
400
|
-
? "truncated"
|
|
401
|
-
: response !== null
|
|
402
|
-
? "included"
|
|
403
|
-
: request !== null
|
|
404
|
-
? "partial"
|
|
405
|
-
: "unavailable";
|
|
406
|
-
this.network.set(requestId, {
|
|
407
|
-
...current,
|
|
408
|
-
body_shapes: { status, request, response },
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
#consoleText(arguments_) {
|
|
412
|
-
if (!this.input.include_console_text)
|
|
413
|
-
return {
|
|
414
|
-
status: "not_approved",
|
|
415
|
-
values: [],
|
|
416
|
-
retained_bytes: 0,
|
|
417
|
-
truncated_values: 0,
|
|
418
|
-
};
|
|
419
|
-
const values = [];
|
|
420
|
-
let retainedBytes = 0;
|
|
421
|
-
let truncatedValues = 0;
|
|
422
|
-
for (const [argumentIndex, argument] of arguments_.entries()) {
|
|
423
|
-
const primitive = consolePrimitive(argument);
|
|
424
|
-
if (primitive === undefined)
|
|
425
|
-
continue;
|
|
426
|
-
const remaining = this.input.limits.max_total_console_text_bytes - this.#consoleTextBytes;
|
|
427
|
-
if (remaining <= 0) {
|
|
428
|
-
truncatedValues += 1;
|
|
429
|
-
continue;
|
|
430
|
-
}
|
|
431
|
-
const bounded = boundedSensitiveText(primitive.text, Math.min(this.input.limits.max_console_text_field_bytes, remaining));
|
|
432
|
-
values.push({
|
|
433
|
-
argument_index: argumentIndex,
|
|
434
|
-
type: primitive.type,
|
|
435
|
-
text: bounded.text,
|
|
436
|
-
});
|
|
437
|
-
retainedBytes += bounded.bytes;
|
|
438
|
-
this.#consoleTextBytes += bounded.bytes;
|
|
439
|
-
if (bounded.truncated)
|
|
440
|
-
truncatedValues += 1;
|
|
441
|
-
}
|
|
442
|
-
if (truncatedValues > 0)
|
|
443
|
-
this.completeness.truncate("console_text");
|
|
444
|
-
return {
|
|
445
|
-
status: truncatedValues > 0 ? "truncated" : "included",
|
|
446
|
-
values,
|
|
447
|
-
retained_bytes: retainedBytes,
|
|
448
|
-
truncated_values: truncatedValues,
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
#websocketShape(payload, opcode) {
|
|
452
|
-
if (!this.input.include_websocket_shapes)
|
|
453
|
-
return null;
|
|
454
|
-
if (opcode !== 1)
|
|
455
|
-
return { format: "binary", json_shape: null, truncated: false };
|
|
456
|
-
const bytes = Buffer.byteLength(payload);
|
|
457
|
-
const remaining = this.input.limits.max_total_websocket_shape_bytes -
|
|
458
|
-
this.#websocketShapeBytes;
|
|
459
|
-
if (bytes > this.input.limits.max_websocket_shape_bytes ||
|
|
460
|
-
bytes > remaining) {
|
|
461
|
-
this.completeness.truncate("websocket_shapes");
|
|
462
|
-
return { format: "text", json_shape: null, truncated: true };
|
|
463
|
-
}
|
|
464
|
-
this.#websocketShapeBytes += bytes;
|
|
465
|
-
const shape = inferJsonShape(payload, {
|
|
466
|
-
maximumBytes: this.input.limits.max_websocket_shape_bytes,
|
|
467
|
-
maximumNodes: this.input.limits.max_json_shape_nodes,
|
|
468
|
-
maximumDepth: this.input.limits.max_json_shape_depth,
|
|
469
|
-
});
|
|
470
|
-
if (shape?.truncated === true)
|
|
471
|
-
this.completeness.truncate("websocket_shapes");
|
|
472
|
-
return {
|
|
473
|
-
format: shape === null ? "text" : "json",
|
|
474
|
-
json_shape: shape,
|
|
475
|
-
truncated: shape?.truncated === true,
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
#websocketCreated(params) {
|
|
479
|
-
const requestId = stringValue(params.requestId);
|
|
480
|
-
const rawUrl = stringValue(params.url);
|
|
481
|
-
if (requestId === undefined || requestId.length > 256) {
|
|
482
|
-
this.completeness.exclude("websocket_connections", "invalid_protocol_value");
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
if (rawUrl === undefined) {
|
|
486
|
-
this.completeness.exclude("websocket_connections", "invalid_protocol_value");
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
let parsed;
|
|
490
|
-
try {
|
|
491
|
-
parsed = new URL(rawUrl);
|
|
492
|
-
}
|
|
493
|
-
catch {
|
|
494
|
-
this.completeness.exclude("websocket_connections", "unsupported_url");
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
if (parsed.protocol === "ws:")
|
|
498
|
-
parsed.protocol = "http:";
|
|
499
|
-
else if (parsed.protocol === "wss:")
|
|
500
|
-
parsed.protocol = "https:";
|
|
501
|
-
else {
|
|
502
|
-
this.completeness.exclude("websocket_connections", "unsupported_url");
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
if (!this.allowedOrigins.has(parsed.origin)) {
|
|
506
|
-
this.completeness.exclude("websocket_connections", "disallowed_origin");
|
|
507
|
-
return;
|
|
508
|
-
}
|
|
509
|
-
if (!this.allowedWebSockets.has(requestId) &&
|
|
510
|
-
this.allowedWebSockets.size >= this.input.limits.max_websocket_events) {
|
|
511
|
-
this.completeness.drop("websocket_connections");
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
this.allowedWebSockets.add(requestId);
|
|
515
|
-
}
|
|
516
|
-
#frameNavigated(params) {
|
|
517
|
-
const frame = recordValue(params.frame);
|
|
518
|
-
if (stringValue(frame?.id) !== this.#mainFrameId)
|
|
519
|
-
return;
|
|
520
|
-
this.navigationDuringCapture = true;
|
|
521
|
-
const rawUrl = stringValue(frame?.url);
|
|
522
|
-
if (isHttpUrl(rawUrl) &&
|
|
523
|
-
allowedSanitizedUrl(rawUrl, this.allowedOrigins) === undefined)
|
|
524
|
-
this.originViolation = true;
|
|
127
|
+
bodyShapes.ingestResponseBodyShape(this, requestId, value);
|
|
525
128
|
}
|
|
526
129
|
}
|
|
527
|
-
const firstCallFrame = (value) => recordsValue(value?.callFrames)[0];
|
|
528
|
-
const initiatorLocation = (initiator) => {
|
|
529
|
-
let stack = recordValue(initiator?.stack);
|
|
530
|
-
for (let depth = 0; depth < 32 && stack !== undefined; depth += 1) {
|
|
531
|
-
const frame = firstCallFrame(stack);
|
|
532
|
-
if (frame !== undefined)
|
|
533
|
-
return frame;
|
|
534
|
-
stack = recordValue(stack.parent);
|
|
535
|
-
}
|
|
536
|
-
return stringValue(initiator?.url) === undefined ? undefined : initiator;
|
|
537
|
-
};
|
|
538
|
-
const exclusionReasonForUrl = (value) => value === undefined || value === ""
|
|
539
|
-
? "unattributed_origin"
|
|
540
|
-
: isHttpUrl(value)
|
|
541
|
-
? "disallowed_origin"
|
|
542
|
-
: "unsupported_url";
|
|
543
|
-
const integerOrNull = (value) => {
|
|
544
|
-
const number = numberValue(value);
|
|
545
|
-
return number === undefined ? null : Math.max(0, Math.trunc(number));
|
|
546
|
-
};
|
|
547
|
-
const executionContextKey = (value) => {
|
|
548
|
-
const identifier = numberValue(value);
|
|
549
|
-
return identifier !== undefined && Number.isSafeInteger(identifier)
|
|
550
|
-
? String(identifier)
|
|
551
|
-
: null;
|
|
552
|
-
};
|
|
553
|
-
const isJsonContentType = (headers) => {
|
|
554
|
-
if (headers === undefined)
|
|
555
|
-
return false;
|
|
556
|
-
for (const [name, value] of Object.entries(headers))
|
|
557
|
-
if (name.toLowerCase() === "content-type" &&
|
|
558
|
-
isJsonMediaType(stringValue(value)))
|
|
559
|
-
return true;
|
|
560
|
-
return false;
|
|
561
|
-
};
|
|
562
|
-
const isJsonMediaType = (value) => {
|
|
563
|
-
const mediaType = value?.split(";", 1)[0]?.trim().toLowerCase();
|
|
564
|
-
return (mediaType === "application/json" || mediaType?.endsWith("+json") === true);
|
|
565
|
-
};
|
|
566
|
-
const consolePrimitive = (value) => {
|
|
567
|
-
const type = stringValue(value.type);
|
|
568
|
-
switch (type) {
|
|
569
|
-
case "string":
|
|
570
|
-
return typeof value.value === "string"
|
|
571
|
-
? { type, text: value.value }
|
|
572
|
-
: undefined;
|
|
573
|
-
case "boolean":
|
|
574
|
-
return typeof value.value === "boolean"
|
|
575
|
-
? { type, text: String(value.value) }
|
|
576
|
-
: undefined;
|
|
577
|
-
case "number":
|
|
578
|
-
return typeof value.value === "number"
|
|
579
|
-
? { type, text: String(value.value) }
|
|
580
|
-
: typeof value.unserializableValue === "string"
|
|
581
|
-
? { type, text: value.unserializableValue }
|
|
582
|
-
: undefined;
|
|
583
|
-
case "bigint":
|
|
584
|
-
return typeof value.unserializableValue === "string"
|
|
585
|
-
? { type, text: value.unserializableValue }
|
|
586
|
-
: undefined;
|
|
587
|
-
case "undefined":
|
|
588
|
-
return { type, text: "undefined" };
|
|
589
|
-
default:
|
|
590
|
-
return undefined;
|
|
591
|
-
}
|
|
592
|
-
};
|
|
593
|
-
const BASE64 = /^(?:[A-Za-z\d+/]{4})*(?:[A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/u;
|
|
594
|
-
const decodeBase64 = (value) => value.length % 4 === 0 && BASE64.test(value)
|
|
595
|
-
? Buffer.from(value, "base64")
|
|
596
|
-
: undefined;
|