rea-agents 6.2.0 → 6.4.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 +24 -23
- package/bridge/ghidra/ReaGhidraApplySeeds.java +151 -0
- package/bridge/ghidra/ReaGhidraBridge.java +597 -209
- package/bridge/ghidra/ReaGhidraNoReturnFix.java +123 -0
- package/bridge/hopper_bridge.py +2 -0
- package/dist/adb/AdbConfiguration.js +88 -0
- package/dist/adb/AdbDeviceOutput.js +186 -0
- package/dist/adb/AdbProvider.js +1190 -0
- package/dist/adb/AdbShellOutput.js +309 -0
- package/dist/android/AndroidTargetSnapshot.js +104 -22
- package/dist/android/JadxConfiguration.js +44 -24
- package/dist/android/JadxProvider.js +59 -21
- package/dist/android/JadxSession.js +51 -9
- package/dist/apktool/ApktoolConfiguration.js +84 -0
- package/dist/apktool/ApktoolDecodeOutput.js +59 -0
- package/dist/apktool/ApktoolProvider.js +506 -0
- package/dist/application/AnalysisProvider.js +8 -2
- package/dist/application/AppBundleExecutable.js +27 -22
- package/dist/application/BinaryTargetResolver.js +85 -19
- package/dist/application/BrowserScenarioEvidence.js +2 -2
- package/dist/application/CapabilityInventory.js +11 -1
- package/dist/application/ClientConfigurationDocument.js +98 -0
- package/dist/application/ClientConfigurationFiles.js +91 -0
- package/dist/application/ClientRegistrationEnvironment.js +35 -0
- package/dist/application/ClientRegistrationStatus.js +75 -27
- package/dist/application/DirectAnalysis.js +14 -8
- package/dist/application/DirectAnalysisCleanup.js +1 -2
- package/dist/application/DirectAnalysisStatus.js +3 -6
- package/dist/application/Doctor.js +27 -34
- package/dist/application/DoctorDiagnostics.js +1 -1
- package/dist/application/EvidenceBundleCommands.js +6 -12
- package/dist/application/EvidenceBundleFiles.js +1 -1
- package/dist/application/GeminiClientSettings.js +139 -0
- package/dist/application/HermesClientHome.js +115 -0
- package/dist/application/HopperDownload.js +39 -0
- package/dist/application/InvestigationProviders.js +10 -4
- package/dist/application/JsonFiles.js +16 -15
- package/dist/application/JsonInputFile.js +252 -0
- package/dist/application/LinuxHopper.js +6 -13
- package/dist/application/MacHopper.js +172 -149
- package/dist/application/MipsElfAbiFlags.js +140 -0
- package/dist/application/ProviderOperationExecution.js +31 -0
- package/dist/application/ReconstructionObligationCandidates.js +16 -3
- package/dist/application/ReconstructionObligationLedgerProjection.js +3 -1
- package/dist/application/ReferenceSourceImport.js +76 -29
- package/dist/application/ReferenceSourceImportEntries.js +18 -9
- package/dist/application/ReferenceSourceImportPolicy.js +99 -23
- package/dist/application/ReferenceSourceImportTypes.js +30 -22
- package/dist/application/ReferenceSourceVcsAdapter.js +145 -30
- package/dist/application/RegularFileRead.js +103 -0
- package/dist/application/Setup.js +69 -10
- package/dist/application/SetupClientConfiguration.js +134 -23
- package/dist/application/SetupHost.js +102 -22
- package/dist/application/SetupPlan.js +18 -17
- package/dist/application/SetupSkill.js +81 -13
- package/dist/application/SupportedClients.js +305 -37
- package/dist/application/Uninstall.js +172 -8
- package/dist/application/UpdateMaintenance.js +23 -23
- package/dist/application/Utf8JsonInput.js +71 -0
- package/dist/application/WebScriptExportService.js +130 -57
- package/dist/application/WebSourceLocationService.js +3 -0
- package/dist/application/adb/AdbDeviceAnalysisPort.js +1 -0
- package/dist/application/adb/AdbDeviceAnalysisService.js +13 -0
- package/dist/application/analysisView/AnalysisViewService.js +40 -2
- package/dist/application/android/AndroidAnalysisService.js +1 -1
- package/dist/application/apktool/ApktoolResourceAnalysisPort.js +1 -0
- package/dist/application/apktool/ApktoolResourceAnalysisService.js +13 -0
- package/dist/application/binary/AnalysisClientCleanup.js +0 -24
- package/dist/application/binary/AnalysisSnapshotCache.js +5 -4
- package/dist/application/binary/BinarySession.js +18 -1
- package/dist/application/binary/BinarySessionOpen.js +9 -1
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +2 -1
- package/dist/application/binaryDiagnostics/PeResourcesPort.js +1 -0
- package/dist/application/binaryDiagnostics/PeResourcesService.js +111 -0
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +2 -1
- package/dist/application/evm/EvmInterfaceService.js +3 -0
- package/dist/application/firmware/FirmwareAnalysisService.js +3 -0
- package/dist/application/investigation/InspectEvidenceBundle.js +18 -0
- package/dist/application/javascript/ElectronActiveEvidence.js +2 -2
- package/dist/application/javascript/ElectronBoundaryAnalysis.js +2 -2
- package/dist/application/javascript/ElectronBoundaryGraphContext.js +3 -2
- package/dist/application/javascript/ElectronBoundaryGraphIpc.js +2 -2
- package/dist/application/javascript/ElectronBoundaryGraphNative.js +20 -3
- package/dist/application/javascript/ElectronBoundaryGraphWindows.js +3 -3
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +1 -0
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +107 -46
- package/dist/application/javascript/JavaScriptApplicationService.js +23 -11
- package/dist/application/javascript/JavaScriptApplicationWorkflowEvidence.js +5 -6
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +59 -45
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +171 -36
- package/dist/application/javascript/JavaScriptArtifactGraphAccumulator.js +14 -16
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +74 -36
- package/dist/application/javascript/JavaScriptArtifactGraphBundlers.js +4 -3
- package/dist/application/javascript/JavaScriptArtifactGraphContext.js +11 -5
- package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +53 -42
- package/dist/application/javascript/JavaScriptArtifactGraphStructure.js +92 -10
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +293 -238
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +120 -28
- package/dist/application/javascript/JavaScriptArtifactReconstructionInput.js +4 -0
- package/dist/application/javascript/JavaScriptJsonModules.js +2 -2
- package/dist/application/javascript/JavaScriptModuleRelationships.js +10 -20
- package/dist/application/javascript/JavaScriptRecoveryService.js +3 -0
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +11 -27
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +11 -5
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +206 -66
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +18 -23
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +5 -2
- package/dist/application/javascript/JavaScriptSemanticGraphEvidence.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphFingerprintProjection.js +2 -2
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +7 -5
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +6 -4
- package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +4 -4
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +29 -15
- package/dist/application/javascript/JavaScriptSemanticTraceService.js +15 -10
- package/dist/application/jeb/JebAnalysisPort.js +1 -0
- package/dist/application/jeb/JebAnalysisService.js +13 -0
- package/dist/application/managed/ManagedApplicationGraphService.js +1 -1
- package/dist/application/native/NativeCallRoutes.js +2 -4
- package/dist/application/native/NativeUiActionTrace.js +16 -8
- package/dist/application/native/NativeValueTrace.js +23 -6
- package/dist/application/process/ProcessCli.js +25 -20
- package/dist/artifacts/ArtifactPaths.js +129 -8
- package/dist/artifacts/ArtifactProvider.js +34 -31
- package/dist/artifacts/ArtifactProviderMetadata.js +1 -4
- package/dist/artifacts/ArtifactReader.js +23 -0
- package/dist/artifacts/ArtifactResourceScope.js +100 -0
- package/dist/artifacts/AsarArtifactReader.js +218 -80
- package/dist/artifacts/AsarHeader.js +24 -0
- package/dist/artifacts/DirectoryArtifactReader.js +168 -65
- package/dist/artifacts/MachOSliceArtifactReader.js +116 -39
- package/dist/artifacts/NativeDmgArtifactReader.js +179 -87
- package/dist/artifacts/NativeDmgOwnership.js +109 -0
- package/dist/artifacts/SafeOutputTree.js +245 -70
- package/dist/artifacts/SafeOutputTreeCleanup.js +45 -0
- package/dist/artifacts/SafeOutputTreeCreationFailure.js +20 -0
- package/dist/artifacts/SafeOutputTreeIdentity.js +42 -0
- package/dist/artifacts/SafeOutputTreeReadback.js +33 -0
- package/dist/artifacts/ZipArtifactReader.js +77 -27
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +58 -18
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +62 -24
- package/dist/artifacts/apple/KeyedArchiveReader.js +76 -49
- package/dist/artifacts/apple/MachoLoadCommandReader.js +36 -6
- package/dist/artifacts/extraction/ArtifactExtraction.js +134 -92
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +116 -50
- package/dist/artifacts/inventory/ArtifactInventory.js +5 -4
- package/dist/artifacts/inventory/classify.js +87 -25
- package/dist/artifacts/inventory/hashStableRootArtifact.js +70 -0
- package/dist/artifacts/inventory/reader.js +13 -5
- package/dist/artifacts/inventory/scanCanonical.js +73 -30
- package/dist/artifacts/inventory/scanReader.js +43 -20
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +72 -28
- package/dist/artifacts/javascript/JavaScriptSourceAnalysis.js +3 -0
- package/dist/browser/BrowserScenarioPartialObservation.js +8 -2
- package/dist/browser/BrowserScenarioSecrets.js +52 -37
- package/dist/browser/CdpBrowserProvider.js +9 -3
- package/dist/browser/CdpCaptureDocuments.js +40 -6
- package/dist/browser/CdpCaptureDomSvg.js +210 -0
- package/dist/browser/CdpCaptureEventBodyShapes.js +4 -8
- package/dist/browser/CdpCaptureEventHandlers.js +26 -9
- package/dist/browser/CdpCaptureEvents.js +4 -9
- package/dist/browser/CdpCaptureStorageFingerprints.js +3 -3
- package/dist/browser/CdpConnection.js +22 -5
- package/dist/browser/CdpElectronInspection.js +2 -2
- package/dist/browser/CdpElectronProvider.js +4 -3
- package/dist/browser/CdpElectronScripts.js +2 -2
- package/dist/browser/CdpPageCapture.js +1 -1
- package/dist/browser/CdpTargetSession.js +30 -34
- package/dist/browser/CdpWebMcpDiscovery.js +48 -23
- package/dist/browser/ElectronFileScope.js +99 -9
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +63 -7
- package/dist/browser/PlaywrightElectronActiveProvider.js +11 -6
- package/dist/browser/PlaywrightScenarioArtifacts.js +5 -5
- package/dist/browser/PlaywrightScenarioBrowser.js +208 -43
- package/dist/browser/PlaywrightScenarioSession.js +130 -65
- package/dist/browser/PlaywrightScenarioStorage.js +507 -0
- package/dist/browser/PngVisualDiff.js +198 -29
- package/dist/browser/WebSourceMapFetcher.js +35 -9
- package/dist/browser/assets/LocalWebScriptArtifacts.js +3 -1
- package/dist/browser/assets/PublishWebScripts.js +75 -20
- package/dist/browser/assets/ScenarioScriptCapture.js +8 -12
- package/dist/browser/assets/WebArtifactReads.js +23 -1
- package/dist/browser/assets/WebSourceLocationArtifacts.js +1 -0
- package/dist/browser/execution/CdpExecutionCapture.js +3 -3
- package/dist/browser/execution/CdpPreciseCoverage.js +5 -8
- package/dist/browser/history/HarCapture.js +14 -0
- package/dist/browser/history/HarCaptureProcess.js +2 -10
- package/dist/browser/history/MitmproxyCaptureAdapter.js +3 -1
- package/dist/browser/modules/WebModuleArtifacts.js +1 -0
- package/dist/cli/adbCommands.js +337 -0
- package/dist/cli/analysisViewCommands.js +39 -1
- package/dist/cli/apktoolCommands.js +53 -0
- package/dist/cli/artifactCommands.js +8 -11
- package/dist/cli/binaryDiagnosticsCommands.js +19 -1
- package/dist/cli/browserAdvancedCommands.js +65 -36
- package/dist/cli/coreAnalysisCommands.js +2 -2
- package/dist/cli/coreBinaryCommands.js +12 -13
- package/dist/cli/coreNativeCommands.js +1 -14
- package/dist/cli/electronCommands.js +14 -10
- package/dist/cli/evmCommands.js +13 -4
- package/dist/cli/firmwareCommands.js +7 -2
- package/dist/cli/javascriptApplicationAnalysis.js +19 -13
- package/dist/cli/javascriptRecoveryCommands.js +22 -15
- package/dist/cli/jebCommands.js +99 -0
- package/dist/cli/jsonOutput.js +12 -4
- package/dist/cli/referenceSourceImportStatus.js +7 -0
- package/dist/cli/setupCommands.js +15 -3
- package/dist/cli/streamedJsonOutput.js +83 -4
- package/dist/cli/utilityCommands.js +68 -22
- package/dist/cli/webScriptCommands.js +20 -1
- package/dist/cli/webSourceLocationCommands.js +21 -9
- package/dist/cli.js +11 -2
- package/dist/cliBrowserScenarioCommands.js +2 -1
- package/dist/cliCommandNames.js +32 -0
- package/dist/cliJsonInput.js +47 -34
- package/dist/cliObservationOptions.js +7 -0
- package/dist/composition/adb.js +3 -0
- package/dist/composition/apktool.js +3 -0
- package/dist/composition/auxiliaryAnalysisProviders.js +5 -4
- package/dist/composition/binaryDiagnostics.js +4 -0
- package/dist/composition/browserScenario.js +2 -2
- package/dist/composition/directAnalysis.js +14 -7
- package/dist/composition/javascriptAnalysisWorkerProcess.js +48 -0
- package/dist/composition/jeb.js +6 -0
- package/dist/config/environment.js +10 -0
- package/dist/config/ghidraLanguageOverride.js +9 -0
- package/dist/config/mcpInputSchemaProfile.js +27 -0
- package/dist/config/parseConfig.js +28 -1
- package/dist/contracts/adb/adbToolContracts.js +353 -0
- package/dist/contracts/advertisedInputExamples.js +48 -0
- package/dist/contracts/analysisDetail.js +10 -0
- package/dist/contracts/analysisViewToolContracts.js +17 -2
- package/dist/contracts/apktool/apktoolToolContracts.js +33 -0
- package/dist/contracts/artifactComparisonExample.js +5 -5
- package/dist/contracts/artifactToolContracts.js +8 -5
- package/dist/contracts/browserToolContracts.js +1 -1
- package/dist/contracts/compactInputSchema.js +256 -0
- package/dist/contracts/errorSchemas.js +3 -1
- package/dist/contracts/functionComparisonExample.js +8 -0
- package/dist/contracts/functionWorkflowToolContracts.js +1 -1
- package/dist/contracts/inputSchemaPresentation.js +104 -13
- package/dist/contracts/javascript/electronToolContracts.js +16 -3
- package/dist/contracts/javascript/javascriptApplicationWorkflowExamples.js +3 -2
- package/dist/contracts/javascript/javascriptExportShapeComparisonExample.js +6 -3
- package/dist/contracts/javascript/javascriptRecoveryToolContracts.js +1 -1
- package/dist/contracts/javascript/javascriptRuntimeReconciliationExample.js +8 -7
- package/dist/contracts/jeb/jebToolContracts.js +64 -0
- package/dist/contracts/managed/managedToolContracts.js +3 -2
- package/dist/contracts/mobileApplicationGraphExamples.js +5 -5
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +25 -3
- package/dist/contracts/native/nativeToolContracts.js +1 -1
- package/dist/contracts/officialToolContracts.js +5 -5
- package/dist/contracts/sessionLifecycleInputs.js +4 -3
- package/dist/contracts/sessionStatusContract.js +3 -2
- package/dist/contracts/sessionToolContracts.js +5 -4
- package/dist/contracts/sessionToolSchemas.js +9 -4
- package/dist/contracts/toolContractExamples.js +6 -0
- package/dist/contracts/toolContractTypes.js +3 -0
- package/dist/contracts/toolContracts.js +6 -0
- package/dist/contracts/toolEffects.js +167 -0
- package/dist/contracts/toolOutputSchemaGroups.js +7 -5
- package/dist/contracts/toolOutputSchemaPrimitives.js +2 -5
- package/dist/contracts/toolSchemaMetadata.js +82 -7
- package/dist/domain/adb/adbDeviceAnalysis.js +583 -0
- package/dist/domain/analysisErrorBase.js +5 -0
- package/dist/domain/analysisErrorCleanup.js +29 -0
- package/dist/domain/analysisErrorPresentation.js +18 -4
- package/dist/domain/analysisErrorProjection.js +4 -1
- package/dist/domain/analysisSnapshot.js +5 -2
- package/dist/domain/analysisView/analysisView.js +53 -5
- package/dist/domain/analysisView/binaryLayoutView.js +2 -0
- package/dist/domain/analysisView/javascriptApplicationView.js +2 -0
- package/dist/domain/analysisView/nativeFunctionView.js +155 -0
- package/dist/domain/android/androidApplication.js +25 -20
- package/dist/domain/android/androidPartialObservation.js +36 -0
- package/dist/domain/apktool/apktoolResourceAnalysis.js +77 -0
- package/dist/domain/apple/appleApplication.js +40 -23
- package/dist/domain/apple/appleBundleAnatomy.js +95 -28
- package/dist/domain/apple/dyldPaths.js +9 -1
- package/dist/domain/apple/dylibResolution.js +3 -3
- package/dist/domain/apple/interfaceBuilderGraph.js +22 -19
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +10 -1
- package/dist/domain/artifactComparison.js +39 -11
- package/dist/domain/artifactGraph.js +6 -4
- package/dist/domain/artifactIdentity.js +37 -9
- package/dist/domain/artifactInspection.js +10 -50
- package/dist/domain/artifactIntegrityPolicy.js +10 -0
- package/dist/domain/artifactInventoryEvidence.js +16 -17
- package/dist/domain/artifactPathSyntax.js +1 -1
- package/dist/domain/binaryTarget.js +16 -0
- package/dist/domain/binaryTargetTypes.js +8 -1
- package/dist/domain/browserCompleteness.js +3 -2
- package/dist/domain/browserObservationSchemas.js +8 -4
- package/dist/domain/browserScenarioCaptureValues.js +2 -2
- package/dist/domain/browserScenarioNormalization.js +3 -3
- package/dist/domain/browserScenarioValues.js +3 -2
- package/dist/domain/callPath.js +8 -10
- package/dist/domain/canonicalDigest.js +7 -1
- package/dist/domain/canonicalJsonDigestSteps.js +34 -12
- package/dist/domain/canonicalOrdering.js +1 -13
- package/dist/domain/changedBehavior.js +2 -3
- package/dist/domain/compactStringIdentity.js +9 -0
- package/dist/domain/comparisonSemantics.js +0 -5
- package/dist/domain/digests.js +0 -3
- package/dist/domain/evidence.js +12 -6
- package/dist/domain/evidenceBundle.js +51 -33
- package/dist/domain/evidenceRecordSummary.js +144 -0
- package/dist/domain/firmware/firmwareAnalysis.js +4 -3
- package/dist/domain/functionComparison.js +2 -1
- package/dist/domain/functionComparisonNormalization.js +4 -3
- package/dist/domain/functionComparisonResults.js +2 -2
- package/dist/domain/functionDossierEvidence.js +2 -1
- package/dist/domain/hopperValues.js +11 -15
- package/dist/domain/inputIssueProjection.js +16 -1
- package/dist/domain/javascript/electronActiveObservation.js +4 -3
- package/dist/domain/javascript/electronStaticAnalysisBrowser.js +14 -15
- package/dist/domain/javascript/electronStaticAnalysisIpc.js +20 -21
- package/dist/domain/javascript/electronStaticAnalysisNative.js +73 -41
- package/dist/domain/javascript/electronStaticAnalysisValues.js +24 -4
- package/dist/domain/javascript/javascriptAnalysisResourceControls.js +45 -0
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +6 -1
- package/dist/domain/javascript/javascriptApplicationChangeGraph.js +18 -14
- package/dist/domain/javascript/javascriptApplicationEvidenceSchemas.js +4 -0
- package/dist/domain/javascript/javascriptApplicationGraph.js +91 -28
- package/dist/domain/javascript/javascriptApplicationProjectionResources.js +35 -0
- package/dist/domain/javascript/javascriptApplicationVersionComparison.js +4 -4
- package/dist/domain/javascript/javascriptApplicationVersionComparisonSchemas.js +37 -22
- package/dist/domain/javascript/javascriptApplicationVersionItems.js +72 -45
- package/dist/domain/javascript/javascriptApplicationVersionKeys.js +16 -8
- package/dist/domain/javascript/javascriptAstFingerprint.js +60 -33
- package/dist/domain/javascript/javascriptAstValues.js +54 -0
- package/dist/domain/javascript/javascriptElectronMemberWrites.js +50 -0
- package/dist/domain/javascript/javascriptExportShapeComparison.js +3 -2
- package/dist/domain/javascript/javascriptExportShapeComparisonSchemas.js +31 -23
- package/dist/domain/javascript/javascriptExportShapeSelection.js +2 -2
- package/dist/domain/javascript/javascriptExportShapeVariants.js +3 -2
- package/dist/domain/javascript/javascriptFeatureSeed.js +5 -3
- package/dist/domain/javascript/javascriptFeatureTrace.js +7 -6
- package/dist/domain/javascript/javascriptFeatureTraceSchemas.js +17 -9
- package/dist/domain/javascript/javascriptFeatureTraversal.js +4 -4
- package/dist/domain/javascript/javascriptModuleSemanticIr.js +15 -0
- package/dist/domain/javascript/javascriptNativeHandoff.js +12 -7
- package/dist/domain/javascript/javascriptRpcEndpoints.js +253 -0
- package/dist/domain/javascript/javascriptRuntimeLoadState.js +1 -3
- package/dist/domain/javascript/javascriptRuntimeObservation.js +8 -5
- package/dist/domain/javascript/javascriptRuntimeReconciliation.js +12 -6
- package/dist/domain/javascript/javascriptRuntimeReconciliationActive.js +9 -8
- package/dist/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js +212 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationGraph.js +12 -6
- package/dist/domain/javascript/javascriptRuntimeReconciliationInputValidation.js +28 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationMatching.js +5 -5
- package/dist/domain/javascript/javascriptRuntimeReconciliationParsing.js +12 -223
- package/dist/domain/javascript/javascriptRuntimeReconciliationResult.js +2 -2
- package/dist/domain/javascript/javascriptRuntimeReconciliationRuntime.js +15 -4
- package/dist/domain/javascript/javascriptRuntimeReconciliationSchemas.js +2 -2
- package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +15 -17
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +379 -30
- package/dist/domain/javascript/javascriptSemanticCallResolution.js +9 -7
- package/dist/domain/javascript/javascriptSemanticCallableResults.js +42 -0
- package/dist/domain/javascript/javascriptSemanticCalls.js +8 -1
- package/dist/domain/javascript/javascriptSemanticChildProcesses.js +2 -2
- package/dist/domain/javascript/javascriptSemanticCoverage.js +20 -0
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +7 -9
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +4 -11
- package/dist/domain/javascript/javascriptSemanticDerivedAnalysis.js +15 -4
- package/dist/domain/javascript/javascriptSemanticFileProjection.js +1 -0
- package/dist/domain/javascript/javascriptSemanticFingerprints.js +43 -42
- package/dist/domain/javascript/javascriptSemanticGraph.js +205 -52
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +21 -11
- package/dist/domain/javascript/javascriptSemanticIr.js +0 -4
- package/dist/domain/javascript/javascriptSemanticIterationSources.js +139 -0
- package/dist/domain/javascript/javascriptSemanticMemberMutations.js +774 -136
- package/dist/domain/javascript/javascriptSemanticMutationInitializers.js +190 -0
- package/dist/domain/javascript/javascriptSemanticMutationValues.js +98 -41
- package/dist/domain/javascript/javascriptSemanticObjectReferences.js +381 -0
- package/dist/domain/javascript/javascriptSemanticObjects.js +9 -7
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +7 -2
- package/dist/domain/javascript/javascriptSemanticProjection.js +72 -28
- package/dist/domain/javascript/javascriptSemanticPromises.js +15 -21
- package/dist/domain/javascript/javascriptSemanticPropertyPaths.js +100 -0
- package/dist/domain/javascript/javascriptSemanticProvenance.js +3 -3
- package/dist/domain/javascript/javascriptSemanticQuery.js +33 -29
- package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +4 -5
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -9
- package/dist/domain/javascript/javascriptSemanticRequireOrigin.js +16 -10
- package/dist/domain/javascript/javascriptSemanticReturnedReferences.js +219 -0
- package/dist/domain/javascript/javascriptSemanticReturns.js +34 -48
- package/dist/domain/javascript/javascriptSemanticState.js +22 -2
- package/dist/domain/javascript/javascriptSemanticTraversal.js +25 -2
- package/dist/domain/javascript/javascriptSemanticValues.js +169 -30
- package/dist/domain/javascript/javascriptSourceAnalysis.js +1 -0
- package/dist/domain/javascript/javascriptSourceMapPaths.js +11 -1
- package/dist/domain/javascript/javascriptSourceParser.js +34 -9
- package/dist/domain/javascript/javascriptStaticAnalysis.js +29 -17
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +13 -12
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +49 -5
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +8 -4
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +26 -15
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +1 -0
- package/dist/domain/javascript/sourceToBundleComparison.js +7 -5
- package/dist/domain/javascript/sourceToBundleSignals.js +7 -7
- package/dist/domain/jeb/jebAnalysis.js +114 -0
- package/dist/domain/jsonSerialization.js +109 -55
- package/dist/domain/jsonShape.js +69 -31
- package/dist/domain/jsonValue.js +3 -0
- package/dist/domain/localPath.js +10 -4
- package/dist/domain/managed/managedApplicationGraph.js +47 -6
- package/dist/domain/managed/managedApplicationGraphCoverage.js +8 -2
- package/dist/domain/managed/managedApplicationGraphNodes.js +94 -59
- package/dist/domain/managed/managedArtifact.js +1 -0
- package/dist/domain/managed/managedInspectionEvidence.js +13 -0
- package/dist/domain/managed/managedMemberComparisonMatch.js +6 -7
- package/dist/domain/native/nativeAotPe.js +1408 -0
- package/dist/domain/native/nativeCallObservation.js +2 -4
- package/dist/domain/native/nativeInstruction.js +21 -0
- package/dist/domain/native/nativeMetadataRecovery.js +79 -6
- package/dist/domain/native/nativeValueFlow.js +5 -11
- package/dist/domain/native/objcSwiftMetadata.js +15 -17
- package/dist/domain/native/peResources.js +94 -0
- package/dist/domain/nativeConvention.js +33 -0
- package/dist/domain/process/processCapture.js +102 -11
- package/dist/domain/process/processCaptureCoverage.js +8 -5
- package/dist/domain/process/processCaptureExample.js +67 -0
- package/dist/domain/process/processCaptureValidation.js +83 -3
- package/dist/domain/process/processComparison.js +0 -23
- package/dist/domain/process/processScenario.js +62 -10
- package/dist/domain/process/processTraceEvaluation.js +4 -4
- package/dist/domain/process/processTraceSpecification.js +1 -3
- package/dist/domain/propertyListKeys.js +3 -1
- package/dist/domain/providerCleanupError.js +6 -2
- package/dist/domain/reconstructionCoverage.js +2 -1
- package/dist/domain/reconstructionUnknowns.js +4 -3
- package/dist/domain/reconstructionVerification.js +3 -2
- package/dist/domain/referenceSourceGraph.js +32 -23
- package/dist/domain/referenceSourceImportParsing.js +40 -48
- package/dist/domain/referenceSourcePathIdentity.js +22 -0
- package/dist/domain/referenceSourceRequireBindings.js +137 -0
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/staticRuntimeCorrelation.js +2 -1
- package/dist/domain/swiftSymbolClassification.js +6 -1
- package/dist/domain/symbolAnalysis.js +17 -2
- package/dist/domain/unicodeCodePointOrder.js +6 -0
- package/dist/domain/webBundleAnalyzerInspection.js +23 -3
- package/dist/domain/webCaptureDiff.js +170 -30
- package/dist/domain/webCaptureDiffSchemas.js +2 -8
- package/dist/domain/webInventory.js +3 -2
- package/dist/domain/webMcpDiscovery.js +4 -3
- package/dist/domain/webScriptExport.js +1 -1
- package/dist/domain/webScriptExportError.js +10 -4
- package/dist/domain/webScriptExportPlan.js +7 -13
- package/dist/domain/zipPackageFormat.js +4 -1
- package/dist/domain/zodCollectionSteps.js +24 -0
- package/dist/dotnet/ManagedArtifactInspector.js +55 -43
- package/dist/dotnet/ManagedDecodeBudget.js +80 -0
- package/dist/dotnet/ManagedMemberInspector.js +13 -6
- package/dist/dotnet/ManagedMemberInspectorCore.js +2 -2
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +5 -4
- package/dist/dotnet/ManagedMemberRows.js +9 -4
- package/dist/dotnet/ManagedMetadataHeaps.js +15 -5
- package/dist/dotnet/ManagedMetadataInventoryRows.js +20 -11
- package/dist/dotnet/ManagedMetadataLayout.js +10 -4
- package/dist/dotnet/ManagedMethodBodyReader.js +8 -3
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +3 -2
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +49 -34
- package/dist/dotnet/ManagedPeReader.js +41 -25
- package/dist/dotnet/ManagedReaderFailure.js +2 -1
- package/dist/dotnet/ManagedStaticProvider.js +65 -31
- package/dist/dotnet/ManagedStaticProviderMetadata.js +1 -4
- package/dist/evaluation/AgentEvaluationReport.js +9 -5
- package/dist/evaluation/CodexAgentEval.js +43 -13
- package/dist/evm/EvmoleFailures.js +0 -2
- package/dist/evm/EvmoleInterfaceProvider.js +67 -2
- package/dist/filesystem/OwnedDirectoryHandle.js +29 -0
- package/dist/filesystem/OwnedFileHandle.js +36 -0
- package/dist/filesystem/RegularFile.js +73 -0
- package/dist/filesystem/StableFileHash.js +46 -0
- package/dist/filesystem/readFileHandleChunks.js +26 -0
- package/dist/firmware/FirmwareCommand.js +25 -3
- package/dist/firmware/FirmwareFiles.js +23 -8
- package/dist/firmware/FirmwareProvider.js +156 -32
- package/dist/firmware/FirmwarePublication.js +24 -3
- package/dist/firmware/FirmwareRelease.js +1 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +55 -4
- package/dist/ghidra/GhidraAnalysisSeeds.js +211 -0
- package/dist/ghidra/GhidraClient.js +90 -8
- package/dist/ghidra/GhidraDiagnostics.js +11 -8
- package/dist/ghidra/GhidraFunctionValues.js +26 -2
- package/dist/ghidra/GhidraInstallation.js +111 -10
- package/dist/ghidra/GhidraInventoryValues.js +23 -1
- package/dist/ghidra/GhidraLanguageCatalog.js +99 -0
- package/dist/ghidra/GhidraLauncher.js +123 -58
- package/dist/ghidra/GhidraLoadImageAttest.js +49 -2
- package/dist/ghidra/GhidraMipsProfile.js +79 -0
- package/dist/ghidra/GhidraProvider.js +57 -9
- package/dist/ghidra/GhidraProviderCapabilities.js +18 -8
- package/dist/ghidra/GhidraProviderClient.js +282 -21
- package/dist/ghidra/GhidraSessionValues.js +9 -2
- package/dist/hopper/HopperAnalysisProfile.js +2 -0
- package/dist/hopper/HopperCleanup.js +1 -1
- package/dist/hopper/HopperClient.js +15 -6
- package/dist/hopper/HopperMachOImage.js +2 -0
- package/dist/hopper/HopperProvider.js +13 -2
- package/dist/ida/IdaOperationRunner.js +10 -2
- package/dist/ida/IdaProvider.js +7 -0
- package/dist/ida/IdaSessionClient.js +7 -3
- package/dist/ida/IdaWorkspace.js +4 -2
- package/dist/inspector/JavaScriptRuntimeScope.js +9 -5
- package/dist/inspector/V8InspectorCaptureProjection.js +46 -13
- package/dist/inspector/V8InspectorProvider.js +60 -8
- package/dist/javascript/analysis/JavaScriptAnalysisTransfer.js +326 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorker.js +520 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerProtocol.js +63 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerSchemas.js +521 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerServer.js +116 -0
- package/dist/javascript/recovery/RecoveryFiles.js +18 -7
- package/dist/javascript/recovery/WakaruCommand.js +22 -9
- package/dist/javascript/recovery/WakaruExecution.js +11 -7
- package/dist/javascript/recovery/WakaruProvider.js +139 -16
- package/dist/javascript/recovery/WakaruPublication.js +14 -4
- package/dist/javascript/recovery/WakaruRelease.js +10 -3
- package/dist/javascript/recovery/WakaruReport.js +12 -7
- package/dist/javascript/recovery/WakaruVersion.js +24 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +16 -3
- package/dist/javascript/sourceMaps/SourceMapDecoder.js +63 -7
- package/dist/javascript/sourceMaps/SourceMapFormat.js +15 -4
- package/dist/jeb/JebMcpConnection.js +179 -0
- package/dist/jeb/JebMcpEndpoint.js +40 -0
- package/dist/jeb/JebProvider.js +299 -0
- package/dist/main/shutdown.js +76 -32
- package/dist/main/transport.js +1 -1
- package/dist/mcpDoctor.js +15 -6
- package/dist/native/AppleDispatchCoverage.js +25 -12
- package/dist/native/AppleDispatchMetadata.js +14 -7
- package/dist/native/AppleMachoFixups.js +71 -15
- package/dist/native/AppleMachoSelection.js +23 -3
- package/dist/native/AppleObjcDispatchFacets.js +3 -3
- package/dist/native/AppleObjcProperties.js +17 -7
- package/dist/native/LldbCallTracer.js +241 -75
- package/dist/native/NativeMacOSProvider.js +100 -20
- package/dist/native/NativeMacOSProviderMetadata.js +1 -2
- package/dist/native/NativeMachoInspection.js +11 -7
- package/dist/native/NativeUiHelperRuntime.js +6 -1
- package/dist/native/NativeUiObservation.js +4 -3
- package/dist/native/pe/PeResourceLayout.js +120 -0
- package/dist/native/pe/PeResourceParser.js +286 -0
- package/dist/native/pe/PeResourcesProvider.js +63 -0
- package/dist/process/BoundedFileBytes.js +30 -7
- package/dist/process/DarwinProcessRunTokenReader.js +8 -3
- package/dist/process/OwnedCommand.js +4 -3
- package/dist/process/ProcessOwnership.js +104 -112
- package/dist/process/ProcessOwnershipObservation.js +104 -51
- package/dist/process/ProcessOwnershipProcessTree.js +4 -4
- package/dist/process/ProcessRunTokenObservations.js +48 -0
- package/dist/process/ProviderDiagnosticRedaction.js +17 -0
- package/dist/process/ProviderProcess.js +4 -3
- package/dist/process/capture/FilesystemSnapshot.js +116 -22
- package/dist/process/capture/ProcessCaptureLifecycle.js +363 -86
- package/dist/process/capture/ProcessCaptureProgress.js +62 -0
- package/dist/process/capture/ProcessFilesystemEffects.js +19 -4
- package/dist/process/capture/ProcessHarness.js +202 -47
- package/dist/process/capture/ProcessNormalization.js +3 -1
- package/dist/process/capture/ProcessScenarioRuntimeValidation.js +5 -2
- package/dist/process/capture/TerminalRenderer.js +24 -7
- package/dist/reference/ReferenceSourceReader.js +22 -5
- package/dist/reference/ReferenceSourceReaderEntries.js +114 -51
- package/dist/reference/ReferenceSourceReaderErrors.js +12 -0
- package/dist/reference/ReferenceSourceReaderFile.js +50 -10
- package/dist/reference/ReferenceSourceReaderValidate.js +4 -4
- package/dist/server/EvidenceMcpServer.js +36 -1
- package/dist/server/admittedToolOperation.js +9 -0
- package/dist/server/analysisAdmission.js +8 -0
- package/dist/server/contractToolHandler.js +21 -0
- package/dist/server/createServer.js +118 -47
- package/dist/server/registerAdbTools.js +36 -0
- package/dist/server/registerAnalysisViewTool.js +4 -9
- package/dist/server/registerAndroidTools.js +3 -12
- package/dist/server/registerApktoolTools.js +14 -0
- package/dist/server/registerApplicationTools/compareExportShapes.js +6 -7
- package/dist/server/registerApplicationTools/compareSourceToBundle.js +4 -5
- package/dist/server/registerApplicationTools/compareVersions.js +3 -2
- package/dist/server/registerApplicationTools/coverage.js +3 -2
- package/dist/server/registerApplicationTools/helpers.js +3 -2
- package/dist/server/registerApplicationTools/obligationLedger.js +3 -2
- package/dist/server/registerApplicationTools/projectMobileApplicationGraph.js +3 -2
- package/dist/server/registerApplicationTools/traceFeature.js +3 -2
- package/dist/server/registerApplicationTools/traceSemantics.js +4 -5
- package/dist/server/registerArtifactComparisonTool.js +5 -2
- package/dist/server/registerArtifactTools.js +2 -2
- package/dist/server/registerBinaryDiagnosticsTools.js +16 -4
- package/dist/server/registerBrowserScenarioTool.js +10 -7
- package/dist/server/registerBrowserTools.js +12 -9
- package/dist/server/registerBundleComparisonTool.js +16 -2
- package/dist/server/registerCloseLifecycleTool.js +36 -5
- package/dist/server/registerElectronTools.js +28 -10
- package/dist/server/registerEnhancedTools.js +78 -73
- package/dist/server/registerEvidenceTools.js +54 -46
- package/dist/server/registerEvmTools.js +4 -9
- package/dist/server/registerFirmwareTools.js +3 -11
- package/dist/server/registerFunctionComparisonTool.js +5 -2
- package/dist/server/registerJavaScriptRecoveryTool.js +4 -9
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +9 -6
- package/dist/server/registerJebTools.js +16 -0
- package/dist/server/registerManagedTools.js +7 -4
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +4 -6
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +3 -2
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +3 -2
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +3 -2
- package/dist/server/registerOfficialTools.js +31 -25
- package/dist/server/registerPeResourcesTool.js +9 -0
- package/dist/server/registerProcessComparisonTool.js +5 -2
- package/dist/server/registerRecordedCrashTools.js +4 -9
- package/dist/server/registerSessionRecordTools.js +2 -1
- package/dist/server/registerSessionTools.js +58 -21
- package/dist/server/registerWebModuleTool.js +4 -9
- package/dist/server/registerWebNetworkCaptureTool.js +4 -9
- package/dist/server/registerWebRuntimeTools.js +6 -5
- package/dist/server/registerWebScriptTool.js +6 -3
- package/dist/server/registerWebSourceLocationTool.js +4 -9
- package/dist/server/toolResult.js +21 -2
- package/dist/windows/WindowsPrivateRuntime.js +12 -5
- package/install.sh +7 -4
- package/licenses/nativeaot-parser-MIT.txt +28 -0
- package/native/windows/build/manifest.json +2 -2
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +38 -7
- package/scripts/rea.mjs +16 -1
- package/skills/reverse-engineer-anything/SKILL.md +52 -51
- package/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +8 -0
- package/skills/reverse-engineer-anything/references/javascript-applications.md +92 -13
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +31 -1
- package/dist/artifacts/inventory/policy.js +0 -2
- package/dist/domain/managed/managedApplicationGraphNodeCoverage.js +0 -6
- package/dist/server/registerNativeTools.js +0 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isBuiltin } from "node:module";
|
|
2
2
|
import { posix } from "node:path";
|
|
3
|
+
import { normalizeJoinedLogicalPath, logicalPathEscapesRoot, } from "../../domain/artifactIdentity.js";
|
|
3
4
|
import { admitsCanonicalPathSyntax, hasScheme, htmlUrlText, looksExternal, percentDecodeUrlPath, stripQueryAndFragment, } from "../../domain/artifactPathSyntax.js";
|
|
4
5
|
const EXTENSIONS = [
|
|
5
6
|
".js",
|
|
@@ -11,60 +12,59 @@ const EXTENSIONS = [
|
|
|
11
12
|
".html",
|
|
12
13
|
".node",
|
|
13
14
|
];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
/** Resolve one declaration while preserving its original input identity. */
|
|
16
|
+
export const resolveArtifactPathByContext = (input) => {
|
|
17
|
+
const resolution = resolvePath(input);
|
|
18
|
+
return resolution.status === "resolved"
|
|
19
|
+
? {
|
|
20
|
+
declared_path: input.declaredPath,
|
|
21
|
+
resolution_context: input.context,
|
|
22
|
+
resolved_path: resolution.resolvedPath,
|
|
23
|
+
resolution_status: resolution.status,
|
|
24
|
+
limitations: resolution.limitations,
|
|
25
|
+
}
|
|
26
|
+
: {
|
|
27
|
+
declared_path: input.declaredPath,
|
|
28
|
+
resolution_context: input.context,
|
|
29
|
+
resolved_path: null,
|
|
30
|
+
resolution_status: resolution.status,
|
|
31
|
+
limitations: resolution.limitations,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const resolvePath = (input) => {
|
|
35
|
+
const rejected = rejectDeclaration(input.declaredPath);
|
|
19
36
|
if (rejected !== null)
|
|
20
37
|
return rejected;
|
|
21
|
-
const candidate = contextualCandidate(input
|
|
38
|
+
const candidate = contextualCandidate(input);
|
|
22
39
|
if (typeof candidate !== "string")
|
|
23
40
|
return candidate;
|
|
24
|
-
const confined = confineCandidate(
|
|
41
|
+
const confined = confineCandidate(candidate);
|
|
25
42
|
if (typeof confined !== "string")
|
|
26
43
|
return confined;
|
|
27
44
|
if (input.context === "html-reference")
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
status: "not-found",
|
|
31
|
-
limitations: [
|
|
45
|
+
return (resolveFileCandidates(input, [confined]) ??
|
|
46
|
+
unresolvedCandidate("not-found", [
|
|
32
47
|
`The exact HTML resource ${confined} was not found among the selected application files.`,
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
// An exports target names one exact file; Node tries no extension or index.
|
|
36
|
-
const resolved = exportsTargetUrl
|
|
37
|
-
? (resolveFileCandidates(input, [confined]) ??
|
|
38
|
-
exactExportsTargetNotFound(confined))
|
|
39
|
-
: mode === "files-and-index"
|
|
40
|
-
? (resolveFileCandidates(input, [
|
|
41
|
-
...fileCandidates(confined),
|
|
42
|
-
...indexCandidates(confined),
|
|
43
|
-
]) ?? notFoundCandidate())
|
|
44
|
-
: resolveCandidate(input, confined, packageChain);
|
|
45
|
-
return outcome(input, resolved);
|
|
48
|
+
]));
|
|
49
|
+
return resolveCandidate(input, confined, new Set());
|
|
46
50
|
};
|
|
47
|
-
const rejectDeclaration = (
|
|
48
|
-
const declared = input.declaredPath;
|
|
51
|
+
const rejectDeclaration = (declared) => {
|
|
49
52
|
if (declared.length === 0)
|
|
50
|
-
return
|
|
51
|
-
"The declared path is empty.",
|
|
52
|
-
]);
|
|
53
|
+
return unresolvedCandidate("rejected", ["The declared path is empty."]);
|
|
53
54
|
if (declared.includes("\0") || declared.includes("\\"))
|
|
54
|
-
return
|
|
55
|
+
return unresolvedCandidate("rejected", [
|
|
55
56
|
"NUL and backslash path syntax are not admitted for canonical artifact paths.",
|
|
56
57
|
]);
|
|
57
58
|
if (!admitsCanonicalPathSyntax(declared))
|
|
58
|
-
return
|
|
59
|
+
return unresolvedCandidate("rejected", [
|
|
59
60
|
"Encoded dot or separator bytes are rejected before artifact path resolution.",
|
|
60
61
|
]);
|
|
61
62
|
return null;
|
|
62
63
|
};
|
|
63
|
-
const contextualCandidate = (input
|
|
64
|
+
const contextualCandidate = (input) => {
|
|
64
65
|
const { context } = input;
|
|
65
66
|
let declared = context === "html-reference" ||
|
|
66
67
|
context === "url-reference" ||
|
|
67
|
-
exportsTargetUrl ||
|
|
68
68
|
(context === "module-specifier" && input.moduleKind !== "require")
|
|
69
69
|
? stripQueryAndFragment(input.declaredPath)
|
|
70
70
|
: input.declaredPath;
|
|
@@ -75,64 +75,117 @@ const contextualCandidate = (input, exportsTargetUrl) => {
|
|
|
75
75
|
if (fileUrl !== undefined)
|
|
76
76
|
return fileUrl;
|
|
77
77
|
if (hasScheme(declared))
|
|
78
|
-
return
|
|
78
|
+
return unresolvedCandidate("external", [
|
|
79
79
|
"URL and Node builtin schemes are outside static artifact module resolution.",
|
|
80
80
|
]);
|
|
81
81
|
if (!declared.startsWith(".") && !declared.startsWith("/"))
|
|
82
82
|
return bareModuleCandidate(input, declared);
|
|
83
|
+
if (input.moduleKind !== "require") {
|
|
84
|
+
const decoded = decodeModuleUrlPath(declared);
|
|
85
|
+
if (typeof decoded !== "string")
|
|
86
|
+
return decoded;
|
|
87
|
+
declared = decoded;
|
|
88
|
+
}
|
|
83
89
|
}
|
|
84
90
|
else if (looksExternal(declared))
|
|
85
|
-
return
|
|
91
|
+
return unresolvedCandidate("external", [
|
|
86
92
|
"URL schemes and protocol-relative URLs are outside this local artifact path context.",
|
|
87
93
|
]);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
catch (cause) {
|
|
95
|
-
void cause;
|
|
96
|
-
return unresolvedOutcome(input, "rejected", [
|
|
97
|
-
"The module URL path contains malformed percent encoding.",
|
|
98
|
-
]);
|
|
99
|
-
}
|
|
100
|
-
if (declared.includes("\0"))
|
|
101
|
-
return unresolvedOutcome(input, "rejected", [
|
|
102
|
-
"The decoded module URL path contains NUL.",
|
|
103
|
-
]);
|
|
94
|
+
return relativeCandidate(input.sourcePath, declared);
|
|
95
|
+
};
|
|
96
|
+
const decodeModuleUrlPath = (declared) => {
|
|
97
|
+
let decoded;
|
|
98
|
+
try {
|
|
99
|
+
decoded = decodeURIComponent(declared);
|
|
104
100
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
catch (cause) {
|
|
102
|
+
void cause;
|
|
103
|
+
return unresolvedCandidate("rejected", [
|
|
104
|
+
"The module URL path contains malformed percent encoding.",
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
return decoded.includes("\0")
|
|
108
|
+
? unresolvedCandidate("rejected", [
|
|
109
|
+
"The decoded module URL path contains NUL.",
|
|
110
|
+
])
|
|
111
|
+
: decoded;
|
|
109
112
|
};
|
|
113
|
+
const relativeCandidate = (sourcePath, declared) => declared.startsWith("/")
|
|
114
|
+
? declared.slice(1)
|
|
115
|
+
: posix.join(posix.dirname(sourcePath), declared);
|
|
110
116
|
const bareModuleCandidate = (input, declared) => {
|
|
111
117
|
const packageName = barePackageName(declared);
|
|
112
|
-
if (packageName === null ||
|
|
113
|
-
|
|
114
|
-
declared.startsWith("#"))
|
|
115
|
-
return unresolvedOutcome(input, "external", [
|
|
118
|
+
if (packageName === null || isBuiltin(declared) || declared.startsWith("#"))
|
|
119
|
+
return unresolvedCandidate("external", [
|
|
116
120
|
"The bare specifier is a Node builtin, package import map, or invalid package name.",
|
|
117
121
|
]);
|
|
118
|
-
|
|
119
|
-
return unresolvedOutcome(input, "external", [
|
|
120
|
-
"Bare package subpaths remain unresolved unless an exact package-exports subpath model is available.",
|
|
121
|
-
]);
|
|
122
|
+
const subpath = declared === packageName ? "." : `.${declared.slice(packageName.length)}`;
|
|
122
123
|
const source = input.files.get(input.sourcePath);
|
|
123
124
|
let directory = posix.dirname(input.sourcePath);
|
|
124
125
|
while (true) {
|
|
125
|
-
const candidate = posix.join(directory, "node_modules",
|
|
126
|
-
if (
|
|
127
|
-
|
|
126
|
+
const candidate = posix.join(directory, "node_modules", packageName);
|
|
127
|
+
if (subpath === ".") {
|
|
128
|
+
const direct = resolveFileCandidates(input, fileCandidates(candidate));
|
|
129
|
+
if (direct !== null)
|
|
130
|
+
return direct;
|
|
131
|
+
}
|
|
132
|
+
if (hasContainerDirectory(input.files, candidate, source?.container_sha256))
|
|
133
|
+
return resolvePackageSpecifier(input, candidate, subpath);
|
|
128
134
|
if (directory === "." || directory === "")
|
|
129
135
|
break;
|
|
130
136
|
directory = posix.dirname(directory);
|
|
131
137
|
}
|
|
132
|
-
return
|
|
138
|
+
return unresolvedCandidate("external", [
|
|
133
139
|
"No matching bare package was inventoried in an enclosing node_modules directory.",
|
|
134
140
|
]);
|
|
135
141
|
};
|
|
142
|
+
/** Package roots and exact subpaths share metadata and exports selection. */
|
|
143
|
+
const resolvePackageSpecifier = (input, directory, subpath) => {
|
|
144
|
+
const metadata = readPackageMetadata(input, directory);
|
|
145
|
+
if (metadata.kind === "unavailable")
|
|
146
|
+
return unresolvedCandidate("unavailable", [metadata.limitation]);
|
|
147
|
+
const rawExports = metadata.kind === "available"
|
|
148
|
+
? Reflect.get(metadata.value, "exports")
|
|
149
|
+
: undefined;
|
|
150
|
+
if (rawExports === undefined || rawExports === null) {
|
|
151
|
+
if (subpath === ".")
|
|
152
|
+
return resolveDirectory(input, directory, metadata, new Set());
|
|
153
|
+
// Preserve the trailing slash for a package directory request.
|
|
154
|
+
const candidate = confineCandidate(`${directory}/${subpath.slice(2)}`);
|
|
155
|
+
return typeof candidate === "string"
|
|
156
|
+
? resolveCandidate(input, candidate, new Set())
|
|
157
|
+
: candidate;
|
|
158
|
+
}
|
|
159
|
+
const exported = selectPackageExport(rawExports, subpath, input.moduleKind);
|
|
160
|
+
const packagePath = posix.join(directory, "package.json");
|
|
161
|
+
if (exported.status === "rejected")
|
|
162
|
+
return unresolvedCandidate("rejected", [
|
|
163
|
+
`Package metadata ${packagePath}: ${exported.limitation}`,
|
|
164
|
+
]);
|
|
165
|
+
if (exported.status === "unmatched")
|
|
166
|
+
return unresolvedCandidate("external", [
|
|
167
|
+
`Directory package metadata ${packagePath} declares no exports target ${subpath === "." ? "for the active conditions" : `for subpath ${subpath}`}; exports encapsulation permits no file or index lookup. It declares ${exported.declared.join(", ") || "a root target only"}.`,
|
|
168
|
+
]);
|
|
169
|
+
if (exported.status === "blocked")
|
|
170
|
+
return unresolvedCandidate("external", [
|
|
171
|
+
`Directory package metadata ${packagePath} blocks subpath ${subpath} with an explicit null exports target.`,
|
|
172
|
+
]);
|
|
173
|
+
return resolveExportTarget(input, packagePath, exported.value);
|
|
174
|
+
};
|
|
175
|
+
/** An exports target is a URL naming one exact file for both Node loaders. */
|
|
176
|
+
const resolveExportTarget = (input, packagePath, target) => {
|
|
177
|
+
const rejected = rejectDeclaration(target);
|
|
178
|
+
if (rejected !== null)
|
|
179
|
+
return rejected;
|
|
180
|
+
const decoded = decodeModuleUrlPath(stripQueryAndFragment(target));
|
|
181
|
+
if (typeof decoded !== "string")
|
|
182
|
+
return decoded;
|
|
183
|
+
const candidate = confineCandidate(relativeCandidate(packagePath, decoded));
|
|
184
|
+
if (typeof candidate !== "string")
|
|
185
|
+
return candidate;
|
|
186
|
+
return (resolveFileCandidates(input, [candidate]) ??
|
|
187
|
+
exactExportsTargetNotFound(candidate));
|
|
188
|
+
};
|
|
136
189
|
const barePackageName = (specifier) => {
|
|
137
190
|
const segments = specifier.split("/");
|
|
138
191
|
if (specifier.startsWith("@"))
|
|
@@ -141,20 +194,28 @@ const barePackageName = (specifier) => {
|
|
|
141
194
|
: null;
|
|
142
195
|
return segments[0] === "" ? null : (segments[0] ?? null);
|
|
143
196
|
};
|
|
144
|
-
const
|
|
145
|
-
...
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
197
|
+
const hasContainerDirectory = (files, candidate, containerSha256) => {
|
|
198
|
+
if ([...indexCandidates(candidate), posix.join(candidate, "package.json")].some((path) => {
|
|
199
|
+
const file = files.get(path);
|
|
200
|
+
return (file !== undefined &&
|
|
201
|
+
(containerSha256 === undefined ||
|
|
202
|
+
file.container_sha256 === containerSha256));
|
|
203
|
+
}))
|
|
204
|
+
return true;
|
|
205
|
+
// Inventory has files rather than directory entries. Any same-container
|
|
206
|
+
// descendant establishes a package directory even without package.json.
|
|
207
|
+
const prefix = `${candidate}/`;
|
|
208
|
+
for (const [path, file] of files)
|
|
209
|
+
if (path.startsWith(prefix) &&
|
|
210
|
+
(containerSha256 === undefined ||
|
|
211
|
+
file.container_sha256 === containerSha256))
|
|
212
|
+
return true;
|
|
213
|
+
return false;
|
|
214
|
+
};
|
|
154
215
|
const htmlCandidate = (input) => {
|
|
155
216
|
const declared = stripQueryAndFragment(htmlUrlText(input.declaredPath));
|
|
156
217
|
if (looksExternal(declared))
|
|
157
|
-
return
|
|
218
|
+
return unresolvedCandidate("external", [
|
|
158
219
|
"External HTML references are not mapped to local artifact assets.",
|
|
159
220
|
]);
|
|
160
221
|
const rawBase = input.htmlBaseHref;
|
|
@@ -162,151 +223,156 @@ const htmlCandidate = (input) => {
|
|
|
162
223
|
? rawBase
|
|
163
224
|
: stripQueryAndFragment(htmlUrlText(rawBase));
|
|
164
225
|
if (base !== undefined && base !== null && looksExternal(base))
|
|
165
|
-
return
|
|
226
|
+
return unresolvedCandidate("external", [
|
|
166
227
|
"The document base href is external, so its script reference is not a local artifact path.",
|
|
167
228
|
]);
|
|
168
229
|
// Removing URL tabs and newlines can join an encoded dot or separator that
|
|
169
230
|
// the raw declaration split, so admit the parsed URL text again.
|
|
170
231
|
if (!admitsCanonicalPathSyntax(declared))
|
|
171
|
-
return
|
|
232
|
+
return unresolvedCandidate("rejected", [
|
|
172
233
|
"Encoded dot or separator bytes are rejected before artifact path resolution.",
|
|
173
234
|
]);
|
|
174
235
|
const declaredPath = percentDecodeUrlPath(declared);
|
|
175
236
|
if (declaredPath === null)
|
|
176
|
-
return
|
|
237
|
+
return unresolvedCandidate("rejected", [
|
|
177
238
|
"The HTML reference path percent-decodes to NUL or to bytes that are not UTF-8.",
|
|
178
239
|
]);
|
|
179
240
|
if (declaredPath.startsWith("/"))
|
|
180
241
|
return declaredPath.slice(1);
|
|
181
242
|
if (base === undefined || base === null || base === "")
|
|
182
|
-
return
|
|
243
|
+
return declaredPath === ""
|
|
244
|
+
? input.sourcePath
|
|
245
|
+
: posix.join(posix.dirname(input.sourcePath), declaredPath);
|
|
183
246
|
// A local base href is a second untrusted path input; apply the same
|
|
184
247
|
// admission rules a declared path gets so it cannot smuggle traversal or
|
|
185
248
|
// separator syntax past canonicalization.
|
|
186
249
|
if (!admitsCanonicalPathSyntax(base))
|
|
187
|
-
return
|
|
250
|
+
return unresolvedCandidate("rejected", [
|
|
188
251
|
"The document base href uses NUL, backslash, or encoded dot and separator bytes that are not admitted for canonical artifact paths.",
|
|
189
252
|
]);
|
|
190
253
|
const decodedBase = percentDecodeUrlPath(base);
|
|
191
254
|
if (decodedBase === null)
|
|
192
|
-
return
|
|
255
|
+
return unresolvedCandidate("rejected", [
|
|
193
256
|
"The document base href path percent-decodes to NUL or to bytes that are not UTF-8.",
|
|
194
257
|
]);
|
|
195
258
|
const basePath = decodedBase.startsWith("/")
|
|
196
259
|
? decodedBase.slice(1)
|
|
197
260
|
: posix.join(posix.dirname(input.sourcePath), decodedBase);
|
|
261
|
+
if (declaredPath === "")
|
|
262
|
+
return emptyHtmlReference(decodedBase, basePath);
|
|
198
263
|
return posix.join(htmlBaseDirectory(decodedBase, basePath), declaredPath);
|
|
199
264
|
};
|
|
265
|
+
const emptyHtmlReference = (base, basePath) => {
|
|
266
|
+
if (!htmlBaseIsDirectory(base))
|
|
267
|
+
return basePath;
|
|
268
|
+
const confined = confineCandidate(basePath);
|
|
269
|
+
if (typeof confined !== "string")
|
|
270
|
+
return confined;
|
|
271
|
+
return unresolvedCandidate("not-found", [
|
|
272
|
+
`The HTML reference resolves to directory ${confined || "."}, not an exact selected application file.`,
|
|
273
|
+
]);
|
|
274
|
+
};
|
|
200
275
|
/**
|
|
201
276
|
* The directory a relative HTML reference resolves against. A base path
|
|
202
277
|
* ending in "/" or in a "." or ".." segment is already a directory, because a
|
|
203
278
|
* relative reference resolves against the base URL's directory and those
|
|
204
279
|
* segments are dropped rather than stepped through.
|
|
205
280
|
*/
|
|
206
|
-
const
|
|
281
|
+
const htmlBaseIsDirectory = (base) => base.endsWith("/") ||
|
|
207
282
|
base.endsWith("/.") ||
|
|
208
283
|
base.endsWith("/..") ||
|
|
209
284
|
base === "." ||
|
|
210
|
-
base === ".."
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
normalized.startsWith("../") ||
|
|
217
|
-
normalized.startsWith("/"))
|
|
218
|
-
return unresolvedOutcome(input, "rejected", [
|
|
285
|
+
base === "..";
|
|
286
|
+
const htmlBaseDirectory = (base, basePath) => htmlBaseIsDirectory(base) ? basePath : posix.dirname(basePath);
|
|
287
|
+
const confineCandidate = (candidate) => {
|
|
288
|
+
const normalized = normalizeJoinedLogicalPath(candidate);
|
|
289
|
+
if (logicalPathEscapesRoot(normalized))
|
|
290
|
+
return unresolvedCandidate("rejected", [
|
|
219
291
|
"The resolved candidate escapes the canonical artifact root.",
|
|
220
292
|
]);
|
|
221
293
|
return normalized === "." ? "" : normalized;
|
|
222
294
|
};
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
return direct;
|
|
295
|
+
const readPackageMetadata = (input, directory) => {
|
|
296
|
+
const path = posix.join(directory, "package.json");
|
|
297
|
+
const file = input.files.get(path);
|
|
227
298
|
const source = input.files.get(input.sourcePath);
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
packageFile.container_sha256 !== source.container_sha256))
|
|
233
|
-
return (resolveFileCandidates(input, indexCandidates(candidate)) ??
|
|
234
|
-
notFoundCandidate());
|
|
235
|
-
if (!packageFile.text.included)
|
|
236
|
-
return {
|
|
237
|
-
resolvedPath: null,
|
|
238
|
-
status: "unavailable",
|
|
239
|
-
limitations: [
|
|
240
|
-
`Directory package metadata ${packagePath} was inventoried but its text is unavailable: ${packageFile.text.reason}.`,
|
|
241
|
-
],
|
|
242
|
-
};
|
|
243
|
-
const main = packageEntry(packageFile.text.value, input.moduleKind, input.context === "module-specifier" &&
|
|
244
|
-
!input.declaredPath.startsWith(".") &&
|
|
245
|
-
!input.declaredPath.startsWith("/") &&
|
|
246
|
-
!hasScheme(input.declaredPath));
|
|
247
|
-
if (main.status === "invalid")
|
|
248
|
-
return {
|
|
249
|
-
resolvedPath: null,
|
|
250
|
-
status: "unavailable",
|
|
251
|
-
limitations: [
|
|
252
|
-
`Directory package metadata ${packagePath} is not valid package JSON.`,
|
|
253
|
-
],
|
|
254
|
-
};
|
|
255
|
-
if (main.status === "rejected")
|
|
256
|
-
return {
|
|
257
|
-
resolvedPath: null,
|
|
258
|
-
status: "rejected",
|
|
259
|
-
limitations: [`Package metadata ${packagePath}: ${main.limitation}`],
|
|
260
|
-
};
|
|
261
|
-
if (main.status === "unmatched")
|
|
299
|
+
if (file === undefined ||
|
|
300
|
+
(source !== undefined && file.container_sha256 !== source.container_sha256))
|
|
301
|
+
return { kind: "absent" };
|
|
302
|
+
if (!file.text.included)
|
|
262
303
|
return {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
limitations: [
|
|
266
|
-
`Directory package metadata ${packagePath} declares no exports target for the active conditions; it declares ${main.declared.join(", ")}.`,
|
|
267
|
-
],
|
|
304
|
+
kind: "unavailable",
|
|
305
|
+
limitation: `Directory package metadata ${path} was inventoried but its text is unavailable: ${file.text.reason}.`,
|
|
268
306
|
};
|
|
269
|
-
|
|
307
|
+
let value;
|
|
308
|
+
try {
|
|
309
|
+
value = JSON.parse(file.text.value);
|
|
310
|
+
}
|
|
311
|
+
catch (cause) {
|
|
312
|
+
void cause;
|
|
270
313
|
return {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
limitations: [
|
|
274
|
-
`Directory package entrypoint cycle includes ${packagePath}.`,
|
|
275
|
-
],
|
|
314
|
+
kind: "unavailable",
|
|
315
|
+
limitation: `Directory package metadata ${path} is not valid package JSON.`,
|
|
276
316
|
};
|
|
277
317
|
}
|
|
278
|
-
|
|
279
|
-
|
|
318
|
+
return typeof value === "object" && value !== null
|
|
319
|
+
? { kind: "available", path, value }
|
|
320
|
+
: {
|
|
321
|
+
kind: "unavailable",
|
|
322
|
+
limitation: `Directory package metadata ${path} is not valid package JSON.`,
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
/** File and directory lookup never interprets a nested directory's exports. */
|
|
326
|
+
const resolveCandidate = (input, candidate, packageChain) => resolveFileCandidates(input, fileCandidates(candidate)) ??
|
|
327
|
+
resolveDirectory(input, candidate, readPackageMetadata(input, candidate), packageChain);
|
|
328
|
+
const resolveDirectory = (input, directory, metadata, packageChain) => {
|
|
329
|
+
if (metadata.kind === "absent")
|
|
330
|
+
return (resolveFileCandidates(input, indexCandidates(directory)) ??
|
|
280
331
|
notFoundCandidate());
|
|
332
|
+
if (metadata.kind === "unavailable")
|
|
333
|
+
return unresolvedCandidate("unavailable", [metadata.limitation]);
|
|
334
|
+
if (packageChain.has(metadata.path))
|
|
335
|
+
return unresolvedCandidate("unavailable", [
|
|
336
|
+
`Directory package entrypoint cycle includes ${metadata.path}.`,
|
|
337
|
+
]);
|
|
338
|
+
const preferred = [
|
|
339
|
+
Reflect.get(metadata.value, "main"),
|
|
340
|
+
...(input.moduleKind === undefined
|
|
341
|
+
? [Reflect.get(metadata.value, "module")]
|
|
342
|
+
: []),
|
|
343
|
+
];
|
|
344
|
+
const entry = preferred.find((value) => value !== undefined);
|
|
345
|
+
if (entry === undefined)
|
|
346
|
+
return (resolveFileCandidates(input, indexCandidates(directory)) ??
|
|
347
|
+
notFoundCandidate());
|
|
348
|
+
if (typeof entry !== "string" || entry.length === 0)
|
|
349
|
+
return unresolvedCandidate("unavailable", [
|
|
350
|
+
`Directory package metadata ${metadata.path} is not valid package JSON.`,
|
|
351
|
+
]);
|
|
281
352
|
const entryInput = {
|
|
282
|
-
declaredPath:
|
|
283
|
-
sourcePath:
|
|
353
|
+
declaredPath: entry,
|
|
354
|
+
sourcePath: metadata.path,
|
|
284
355
|
context: "package-entrypoint",
|
|
285
356
|
files: input.files,
|
|
357
|
+
...(input.moduleKind === undefined ? {} : { moduleKind: input.moduleKind }),
|
|
286
358
|
};
|
|
287
|
-
const
|
|
288
|
-
if (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
359
|
+
const rejected = rejectDeclaration(entryInput.declaredPath);
|
|
360
|
+
if (rejected !== null)
|
|
361
|
+
return rejected;
|
|
362
|
+
const candidate = contextualCandidate(entryInput);
|
|
363
|
+
if (typeof candidate !== "string")
|
|
364
|
+
return candidate;
|
|
365
|
+
const confined = confineCandidate(candidate);
|
|
366
|
+
if (typeof confined !== "string")
|
|
367
|
+
return confined;
|
|
368
|
+
const selected = resolveFileCandidates(entryInput, [
|
|
369
|
+
...fileCandidates(confined),
|
|
370
|
+
...indexCandidates(confined),
|
|
371
|
+
]) ?? resolveFileCandidates(input, indexCandidates(directory));
|
|
372
|
+
if (selected !== null)
|
|
373
|
+
return selected;
|
|
374
|
+
return resolveCandidate(entryInput, confined, new Set([...packageChain, metadata.path]));
|
|
298
375
|
};
|
|
299
|
-
const candidateOutcome = (nested) => nested.resolution_status === "resolved"
|
|
300
|
-
? {
|
|
301
|
-
resolvedPath: nested.resolved_path,
|
|
302
|
-
status: nested.resolution_status,
|
|
303
|
-
limitations: nested.limitations,
|
|
304
|
-
}
|
|
305
|
-
: {
|
|
306
|
-
resolvedPath: null,
|
|
307
|
-
status: nested.resolution_status,
|
|
308
|
-
limitations: nested.limitations,
|
|
309
|
-
};
|
|
310
376
|
const resolveFileCandidates = (input, candidates) => {
|
|
311
377
|
const source = input.files.get(input.sourcePath);
|
|
312
378
|
for (const path of candidates) {
|
|
@@ -323,50 +389,44 @@ const fileCandidates = (candidate) => [
|
|
|
323
389
|
...EXTENSIONS.map((extension) => `${candidate}${extension}`),
|
|
324
390
|
];
|
|
325
391
|
const indexCandidates = (candidate) => EXTENSIONS.map((extension) => posix.join(candidate, `index${extension}`));
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return
|
|
335
|
-
|
|
336
|
-
:
|
|
392
|
+
/** Only exact non-directory keys participate; wildcard expansion is unsupported. */
|
|
393
|
+
const selectPackageExport = (value, subpath, moduleKind) => {
|
|
394
|
+
let target = value;
|
|
395
|
+
let declared = [];
|
|
396
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
397
|
+
const keys = Object.keys(value);
|
|
398
|
+
const hasSubpaths = keys.some((key) => key.startsWith("."));
|
|
399
|
+
if (hasSubpaths && keys.some((key) => !key.startsWith(".")))
|
|
400
|
+
return {
|
|
401
|
+
status: "rejected",
|
|
402
|
+
limitation: "The package exports configuration mixes subpath keys and condition keys.",
|
|
403
|
+
};
|
|
404
|
+
declared = keys;
|
|
405
|
+
if (hasSubpaths) {
|
|
406
|
+
if (subpath.endsWith("/") ||
|
|
407
|
+
subpath.includes("*") ||
|
|
408
|
+
!Object.hasOwn(value, subpath))
|
|
409
|
+
return { status: "unmatched", declared };
|
|
410
|
+
target = Reflect.get(value, subpath);
|
|
337
411
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const preferred = [
|
|
341
|
-
Reflect.get(value, "main"),
|
|
342
|
-
...(moduleKind === undefined ? [Reflect.get(value, "module")] : []),
|
|
343
|
-
];
|
|
344
|
-
const entry = preferred.find((candidate) => candidate !== undefined);
|
|
345
|
-
if (entry === undefined)
|
|
346
|
-
return { status: "missing" };
|
|
347
|
-
const legacy = packagePathValue(entry);
|
|
348
|
-
return legacy.status === "value" ? { ...legacy, source: "legacy" } : legacy;
|
|
349
|
-
}
|
|
350
|
-
catch (cause) {
|
|
351
|
-
// Reflect-based manifest reads fail closed as invalid.
|
|
352
|
-
void cause;
|
|
353
|
-
return { status: "invalid" };
|
|
412
|
+
else if (subpath !== ".")
|
|
413
|
+
return { status: "unmatched", declared };
|
|
354
414
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
:
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
return { status: "rejected", limitation: flattened.limitation };
|
|
363
|
-
const first = flattened.kind === "unmatched" ? undefined : flattened.values[0];
|
|
364
|
-
return first === undefined
|
|
365
|
-
? {
|
|
415
|
+
else if (subpath !== ".")
|
|
416
|
+
return { status: "unmatched", declared };
|
|
417
|
+
const selected = selectExportTarget(target, packageExportConditions(moduleKind));
|
|
418
|
+
if (selected.kind === "invalid" || selected.kind === "invalid-config")
|
|
419
|
+
return { status: "rejected", limitation: selected.limitation };
|
|
420
|
+
if (selected.kind === "unmatched")
|
|
421
|
+
return {
|
|
366
422
|
status: "unmatched",
|
|
367
|
-
declared: typeof
|
|
368
|
-
|
|
369
|
-
|
|
423
|
+
declared: typeof target === "object" && target !== null
|
|
424
|
+
? Object.keys(target)
|
|
425
|
+
: declared,
|
|
426
|
+
};
|
|
427
|
+
return selected.kind === "blocked"
|
|
428
|
+
? { status: "blocked" }
|
|
429
|
+
: { status: "value", value: selected.value };
|
|
370
430
|
};
|
|
371
431
|
const invalidExportTarget = (value, reason) => ({
|
|
372
432
|
kind: "invalid",
|
|
@@ -389,21 +449,24 @@ const forbiddenExportSegment = (value) => value
|
|
|
389
449
|
* An array skips unmatched and invalid entries, stops at its first string, and
|
|
390
450
|
* preserves the final invalid-versus-null refusal if no string is selected.
|
|
391
451
|
*/
|
|
392
|
-
const
|
|
452
|
+
const selectExportTarget = (value, conditions) => {
|
|
393
453
|
if (typeof value === "string") {
|
|
394
454
|
if (!value.startsWith("./"))
|
|
395
455
|
return invalidExportTarget(value, 'must start with "./"');
|
|
396
456
|
const forbidden = forbiddenExportSegment(value);
|
|
397
457
|
return forbidden === undefined
|
|
398
|
-
? { kind: "
|
|
458
|
+
? { kind: "value", value }
|
|
399
459
|
: invalidExportTarget(value, `contains forbidden path segment ${JSON.stringify(forbidden)} before URL normalization`);
|
|
400
460
|
}
|
|
401
461
|
if (value === null)
|
|
402
|
-
return { kind: "
|
|
462
|
+
return { kind: "blocked" };
|
|
403
463
|
if (Array.isArray(value)) {
|
|
404
464
|
let invalid = null;
|
|
405
465
|
for (const entry of value) {
|
|
406
|
-
const nested =
|
|
466
|
+
const nested = selectExportTarget(entry, conditions);
|
|
467
|
+
// Node's array fallback catches invalid targets, not invalid configuration.
|
|
468
|
+
if (nested.kind === "invalid-config")
|
|
469
|
+
return nested;
|
|
407
470
|
if (nested.kind === "invalid") {
|
|
408
471
|
invalid = nested.limitation;
|
|
409
472
|
continue;
|
|
@@ -411,19 +474,27 @@ const exportTargets = (value, conditions) => {
|
|
|
411
474
|
if (nested.kind === "unmatched")
|
|
412
475
|
continue;
|
|
413
476
|
invalid = null;
|
|
414
|
-
if (nested.
|
|
477
|
+
if (nested.kind === "value")
|
|
415
478
|
return nested;
|
|
416
479
|
}
|
|
417
480
|
return invalid === null
|
|
418
|
-
? { kind: "
|
|
481
|
+
? { kind: "blocked" }
|
|
419
482
|
: { kind: "invalid", limitation: invalid };
|
|
420
483
|
}
|
|
421
484
|
if (typeof value !== "object")
|
|
422
485
|
return invalidExportTarget(value, "must be a relative string, object, array, or null");
|
|
486
|
+
for (const key of Object.keys(value)) {
|
|
487
|
+
const numeric = Number(key);
|
|
488
|
+
if (String(numeric) === key && numeric >= 0 && numeric < 0xffff_ffff)
|
|
489
|
+
return {
|
|
490
|
+
kind: "invalid-config",
|
|
491
|
+
limitation: `The package exports configuration contains numeric condition key ${JSON.stringify(key)}.`,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
423
494
|
for (const [condition, target] of Object.entries(value)) {
|
|
424
495
|
if (!conditions.has(condition))
|
|
425
496
|
continue;
|
|
426
|
-
const nested =
|
|
497
|
+
const nested = selectExportTarget(target, conditions);
|
|
427
498
|
if (nested.kind !== "unmatched")
|
|
428
499
|
return nested;
|
|
429
500
|
}
|
|
@@ -433,17 +504,16 @@ const exportTargets = (value, conditions) => {
|
|
|
433
504
|
* Node selects an exports target by walking the declared keys in order and
|
|
434
505
|
* taking the first whose condition is active for the calling resolver.
|
|
435
506
|
* "default" is always active, and "node" plus "node-addons" are active for the
|
|
436
|
-
* built-in resolver that owns installed-package imports and requires.
|
|
507
|
+
* built-in resolver that owns installed-package imports and requires. The
|
|
508
|
+
* supported Node runtimes also activate "module-sync" for both loaders.
|
|
437
509
|
*/
|
|
438
510
|
const packageExportConditions = (moduleKind) => new Set([
|
|
439
511
|
"node",
|
|
440
512
|
"node-addons",
|
|
513
|
+
"module-sync",
|
|
441
514
|
...(moduleKind === undefined ? [] : [moduleKind]),
|
|
442
515
|
"default",
|
|
443
516
|
]);
|
|
444
|
-
const packagePathValue = (value) => typeof value === "string" && value.length > 0
|
|
445
|
-
? { status: "value", value }
|
|
446
|
-
: { status: "invalid" };
|
|
447
517
|
const notFoundCandidate = () => ({
|
|
448
518
|
resolvedPath: null,
|
|
449
519
|
status: "not-found",
|
|
@@ -473,19 +543,4 @@ const fileUrlPath = (value) => {
|
|
|
473
543
|
return undefined;
|
|
474
544
|
}
|
|
475
545
|
};
|
|
476
|
-
const
|
|
477
|
-
? {
|
|
478
|
-
declared_path: input.declaredPath,
|
|
479
|
-
resolution_context: input.context,
|
|
480
|
-
resolved_path: resolution.resolvedPath,
|
|
481
|
-
resolution_status: resolution.status,
|
|
482
|
-
limitations: resolution.limitations,
|
|
483
|
-
}
|
|
484
|
-
: {
|
|
485
|
-
declared_path: input.declaredPath,
|
|
486
|
-
resolution_context: input.context,
|
|
487
|
-
resolved_path: null,
|
|
488
|
-
resolution_status: resolution.status,
|
|
489
|
-
limitations: resolution.limitations,
|
|
490
|
-
};
|
|
491
|
-
const unresolvedOutcome = (input, status, limitations) => outcome(input, { resolvedPath: null, status, limitations });
|
|
546
|
+
const unresolvedCandidate = (status, limitations) => ({ resolvedPath: null, status, limitations });
|