@stablyai/internal-playwright-core 0.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +3 -0
- package/ThirdPartyNotices.txt +1134 -0
- package/bin/install_media_pack.ps1 +5 -0
- package/bin/install_webkit_wsl.ps1 +35 -0
- package/bin/reinstall_chrome_beta_linux.sh +42 -0
- package/bin/reinstall_chrome_beta_mac.sh +13 -0
- package/bin/reinstall_chrome_beta_win.ps1 +24 -0
- package/bin/reinstall_chrome_stable_linux.sh +42 -0
- package/bin/reinstall_chrome_stable_mac.sh +12 -0
- package/bin/reinstall_chrome_stable_win.ps1 +24 -0
- package/bin/reinstall_msedge_beta_linux.sh +48 -0
- package/bin/reinstall_msedge_beta_mac.sh +11 -0
- package/bin/reinstall_msedge_beta_win.ps1 +23 -0
- package/bin/reinstall_msedge_dev_linux.sh +48 -0
- package/bin/reinstall_msedge_dev_mac.sh +11 -0
- package/bin/reinstall_msedge_dev_win.ps1 +23 -0
- package/bin/reinstall_msedge_stable_linux.sh +48 -0
- package/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- package/browsers.json +80 -0
- package/cli.js +18 -0
- package/index.d.ts +17 -0
- package/index.js +32 -0
- package/index.mjs +28 -0
- package/lib/androidServerImpl.js +65 -0
- package/lib/browserServerImpl.js +120 -0
- package/lib/cli/cli.js +58 -0
- package/lib/cli/driver.js +97 -0
- package/lib/cli/program.js +634 -0
- package/lib/cli/programWithTestStub.js +74 -0
- package/lib/client/accessibility.js +49 -0
- package/lib/client/android.js +361 -0
- package/lib/client/api.js +137 -0
- package/lib/client/artifact.js +79 -0
- package/lib/client/browser.js +163 -0
- package/lib/client/browserContext.js +529 -0
- package/lib/client/browserType.js +184 -0
- package/lib/client/cdpSession.js +51 -0
- package/lib/client/channelOwner.js +194 -0
- package/lib/client/clientHelper.js +64 -0
- package/lib/client/clientInstrumentation.js +55 -0
- package/lib/client/clientStackTrace.js +69 -0
- package/lib/client/clock.js +68 -0
- package/lib/client/connection.js +314 -0
- package/lib/client/consoleMessage.js +54 -0
- package/lib/client/coverage.js +44 -0
- package/lib/client/dialog.js +56 -0
- package/lib/client/download.js +62 -0
- package/lib/client/electron.js +138 -0
- package/lib/client/elementHandle.js +281 -0
- package/lib/client/errors.js +77 -0
- package/lib/client/eventEmitter.js +314 -0
- package/lib/client/events.js +99 -0
- package/lib/client/fetch.js +369 -0
- package/lib/client/fileChooser.js +46 -0
- package/lib/client/fileUtils.js +34 -0
- package/lib/client/frame.js +408 -0
- package/lib/client/harRouter.js +87 -0
- package/lib/client/input.js +84 -0
- package/lib/client/jsHandle.js +109 -0
- package/lib/client/jsonPipe.js +39 -0
- package/lib/client/localUtils.js +60 -0
- package/lib/client/locator.js +368 -0
- package/lib/client/network.js +747 -0
- package/lib/client/page.js +721 -0
- package/lib/client/platform.js +74 -0
- package/lib/client/playwright.js +71 -0
- package/lib/client/selectors.js +55 -0
- package/lib/client/stream.js +39 -0
- package/lib/client/timeoutSettings.js +79 -0
- package/lib/client/tracing.js +117 -0
- package/lib/client/types.js +28 -0
- package/lib/client/video.js +59 -0
- package/lib/client/waiter.js +142 -0
- package/lib/client/webError.js +39 -0
- package/lib/client/webSocket.js +93 -0
- package/lib/client/worker.js +63 -0
- package/lib/client/writableStream.js +39 -0
- package/lib/common/debugLogger.js +90 -0
- package/lib/common/socksProxy.js +569 -0
- package/lib/common/timeoutSettings.js +73 -0
- package/lib/common/types.js +5 -0
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +28 -0
- package/lib/generated/consoleApiSource.js +28 -0
- package/lib/generated/injectedScriptSource.js +28 -0
- package/lib/generated/pollingRecorderSource.js +28 -0
- package/lib/generated/recorderSource.js +28 -0
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +28 -0
- package/lib/generated/webSocketMockSource.js +336 -0
- package/lib/image_tools/colorUtils.js +98 -0
- package/lib/image_tools/compare.js +108 -0
- package/lib/image_tools/imageChannel.js +70 -0
- package/lib/image_tools/stats.js +102 -0
- package/lib/inProcessFactory.js +60 -0
- package/lib/index.js +19 -0
- package/lib/inprocess.js +3 -0
- package/lib/outofprocess.js +76 -0
- package/lib/protocol/debug.js +27 -0
- package/lib/protocol/serializers.js +192 -0
- package/lib/protocol/transport.js +82 -0
- package/lib/protocol/validator.js +2919 -0
- package/lib/protocol/validatorPrimitives.js +193 -0
- package/lib/remote/playwrightConnection.js +129 -0
- package/lib/remote/playwrightServer.js +335 -0
- package/lib/server/accessibility.js +69 -0
- package/lib/server/android/android.js +465 -0
- package/lib/server/android/backendAdb.js +177 -0
- package/lib/server/artifact.js +127 -0
- package/lib/server/bidi/bidiBrowser.js +490 -0
- package/lib/server/bidi/bidiChromium.js +153 -0
- package/lib/server/bidi/bidiConnection.js +212 -0
- package/lib/server/bidi/bidiExecutionContext.js +221 -0
- package/lib/server/bidi/bidiFirefox.js +130 -0
- package/lib/server/bidi/bidiInput.js +146 -0
- package/lib/server/bidi/bidiNetworkManager.js +383 -0
- package/lib/server/bidi/bidiOverCdp.js +102 -0
- package/lib/server/bidi/bidiPage.js +552 -0
- package/lib/server/bidi/bidiPdf.js +106 -0
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +98 -0
- package/lib/server/bidi/third_party/bidiKeyboard.js +256 -0
- package/lib/server/bidi/third_party/bidiProtocol.js +24 -0
- package/lib/server/bidi/third_party/bidiProtocolCore.js +179 -0
- package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +148 -0
- package/lib/server/bidi/third_party/firefoxPrefs.js +259 -0
- package/lib/server/browser.js +149 -0
- package/lib/server/browserContext.js +695 -0
- package/lib/server/browserType.js +328 -0
- package/lib/server/callLog.js +82 -0
- package/lib/server/chromium/appIcon.png +0 -0
- package/lib/server/chromium/chromium.js +402 -0
- package/lib/server/chromium/chromiumSwitches.js +95 -0
- package/lib/server/chromium/crAccessibility.js +263 -0
- package/lib/server/chromium/crBrowser.js +501 -0
- package/lib/server/chromium/crConnection.js +202 -0
- package/lib/server/chromium/crCoverage.js +235 -0
- package/lib/server/chromium/crDevTools.js +113 -0
- package/lib/server/chromium/crDragDrop.js +131 -0
- package/lib/server/chromium/crExecutionContext.js +146 -0
- package/lib/server/chromium/crInput.js +187 -0
- package/lib/server/chromium/crNetworkManager.js +666 -0
- package/lib/server/chromium/crPage.js +1069 -0
- package/lib/server/chromium/crPdf.js +121 -0
- package/lib/server/chromium/crProtocolHelper.js +145 -0
- package/lib/server/chromium/crServiceWorker.js +123 -0
- package/lib/server/chromium/defaultFontFamilies.js +162 -0
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +113 -0
- package/lib/server/clock.js +149 -0
- package/lib/server/codegen/csharp.js +327 -0
- package/lib/server/codegen/java.js +274 -0
- package/lib/server/codegen/javascript.js +270 -0
- package/lib/server/codegen/jsonl.js +52 -0
- package/lib/server/codegen/language.js +132 -0
- package/lib/server/codegen/languages.js +68 -0
- package/lib/server/codegen/python.js +279 -0
- package/lib/server/codegen/types.js +16 -0
- package/lib/server/console.js +53 -0
- package/lib/server/cookieStore.js +206 -0
- package/lib/server/debugController.js +191 -0
- package/lib/server/debugger.js +119 -0
- package/lib/server/deviceDescriptors.js +39 -0
- package/lib/server/deviceDescriptorsSource.json +1779 -0
- package/lib/server/dialog.js +116 -0
- package/lib/server/dispatchers/androidDispatcher.js +325 -0
- package/lib/server/dispatchers/artifactDispatcher.js +118 -0
- package/lib/server/dispatchers/browserContextDispatcher.js +364 -0
- package/lib/server/dispatchers/browserDispatcher.js +118 -0
- package/lib/server/dispatchers/browserTypeDispatcher.js +64 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +44 -0
- package/lib/server/dispatchers/debugControllerDispatcher.js +78 -0
- package/lib/server/dispatchers/dialogDispatcher.js +47 -0
- package/lib/server/dispatchers/dispatcher.js +371 -0
- package/lib/server/dispatchers/electronDispatcher.js +89 -0
- package/lib/server/dispatchers/elementHandlerDispatcher.js +181 -0
- package/lib/server/dispatchers/frameDispatcher.js +227 -0
- package/lib/server/dispatchers/jsHandleDispatcher.js +85 -0
- package/lib/server/dispatchers/jsonPipeDispatcher.js +58 -0
- package/lib/server/dispatchers/localUtilsDispatcher.js +149 -0
- package/lib/server/dispatchers/networkDispatchers.js +213 -0
- package/lib/server/dispatchers/pageDispatcher.js +401 -0
- package/lib/server/dispatchers/playwrightDispatcher.js +108 -0
- package/lib/server/dispatchers/selectorsDispatcher.js +36 -0
- package/lib/server/dispatchers/streamDispatcher.js +67 -0
- package/lib/server/dispatchers/tracingDispatcher.js +68 -0
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +165 -0
- package/lib/server/dispatchers/writableStreamDispatcher.js +79 -0
- package/lib/server/dom.js +806 -0
- package/lib/server/download.js +70 -0
- package/lib/server/electron/electron.js +270 -0
- package/lib/server/electron/loader.js +29 -0
- package/lib/server/errors.js +69 -0
- package/lib/server/fetch.js +621 -0
- package/lib/server/fileChooser.js +43 -0
- package/lib/server/fileUploadUtils.js +84 -0
- package/lib/server/firefox/ffAccessibility.js +238 -0
- package/lib/server/firefox/ffBrowser.js +428 -0
- package/lib/server/firefox/ffConnection.js +147 -0
- package/lib/server/firefox/ffExecutionContext.js +150 -0
- package/lib/server/firefox/ffInput.js +159 -0
- package/lib/server/firefox/ffNetworkManager.js +256 -0
- package/lib/server/firefox/ffPage.js +503 -0
- package/lib/server/firefox/firefox.js +116 -0
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +147 -0
- package/lib/server/frameSelectors.js +156 -0
- package/lib/server/frames.js +1502 -0
- package/lib/server/har/harRecorder.js +147 -0
- package/lib/server/har/harTracer.js +607 -0
- package/lib/server/harBackend.js +157 -0
- package/lib/server/helper.js +96 -0
- package/lib/server/index.js +58 -0
- package/lib/server/input.js +273 -0
- package/lib/server/instrumentation.js +69 -0
- package/lib/server/isomorphic/utilityScriptSerializers.js +212 -0
- package/lib/server/javascript.js +291 -0
- package/lib/server/launchApp.js +128 -0
- package/lib/server/localUtils.js +218 -0
- package/lib/server/macEditingCommands.js +143 -0
- package/lib/server/network.js +629 -0
- package/lib/server/page.js +871 -0
- package/lib/server/pipeTransport.js +89 -0
- package/lib/server/playwright.js +69 -0
- package/lib/server/progress.js +112 -0
- package/lib/server/protocolError.js +52 -0
- package/lib/server/recorder/chat.js +161 -0
- package/lib/server/recorder/codeGenerator.js +153 -0
- package/lib/server/recorder/csharp.js +310 -0
- package/lib/server/recorder/java.js +248 -0
- package/lib/server/recorder/javascript.js +229 -0
- package/lib/server/recorder/jsonl.js +47 -0
- package/lib/server/recorder/language.js +44 -0
- package/lib/server/recorder/python.js +276 -0
- package/lib/server/recorder/recorderActions.js +5 -0
- package/lib/server/recorder/recorderApp.js +387 -0
- package/lib/server/recorder/recorderRunner.js +138 -0
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +157 -0
- package/lib/server/recorder/throttledFile.js +57 -0
- package/lib/server/recorder/utils.js +45 -0
- package/lib/server/recorder.js +499 -0
- package/lib/server/registry/browserFetcher.js +175 -0
- package/lib/server/registry/dependencies.js +371 -0
- package/lib/server/registry/index.js +1331 -0
- package/lib/server/registry/nativeDeps.js +1280 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +120 -0
- package/lib/server/screenshotter.js +333 -0
- package/lib/server/selectors.js +112 -0
- package/lib/server/socksClientCertificatesInterceptor.js +383 -0
- package/lib/server/socksInterceptor.js +95 -0
- package/lib/server/stably/ai-tools/http-request.js +70 -0
- package/lib/server/stably/ai-tools/stablyApiCaller.js +137 -0
- package/lib/server/stably/autohealing/elementHandleFromCoordinates.js +64 -0
- package/lib/server/stably/autohealing/healingService.js +228 -0
- package/lib/server/stably/autohealing/screenshotFrame.js +41 -0
- package/lib/server/stably/constants.js +31 -0
- package/lib/server/trace/recorder/snapshotter.js +147 -0
- package/lib/server/trace/recorder/snapshotterInjected.js +541 -0
- package/lib/server/trace/recorder/tracing.js +602 -0
- package/lib/server/trace/test/inMemorySnapshotter.js +87 -0
- package/lib/server/trace/viewer/traceViewer.js +240 -0
- package/lib/server/transport.js +181 -0
- package/lib/server/types.js +28 -0
- package/lib/server/usKeyboardLayout.js +145 -0
- package/lib/server/utils/ascii.js +44 -0
- package/lib/server/utils/comparators.js +161 -0
- package/lib/server/utils/crypto.js +216 -0
- package/lib/server/utils/debug.js +42 -0
- package/lib/server/utils/debugLogger.js +122 -0
- package/lib/server/utils/env.js +73 -0
- package/lib/server/utils/eventsHelper.js +39 -0
- package/lib/server/utils/expectUtils.js +38 -0
- package/lib/server/utils/fileUtils.js +191 -0
- package/lib/server/utils/happyEyeballs.js +207 -0
- package/lib/server/utils/hostPlatform.js +111 -0
- package/lib/server/utils/httpServer.js +218 -0
- package/lib/server/utils/image_tools/colorUtils.js +89 -0
- package/lib/server/utils/image_tools/compare.js +109 -0
- package/lib/server/utils/image_tools/imageChannel.js +78 -0
- package/lib/server/utils/image_tools/stats.js +102 -0
- package/lib/server/utils/linuxUtils.js +71 -0
- package/lib/server/utils/network.js +233 -0
- package/lib/server/utils/nodePlatform.js +148 -0
- package/lib/server/utils/pipeTransport.js +84 -0
- package/lib/server/utils/processLauncher.js +241 -0
- package/lib/server/utils/profiler.js +65 -0
- package/lib/server/utils/socksProxy.js +511 -0
- package/lib/server/utils/spawnAsync.js +41 -0
- package/lib/server/utils/task.js +51 -0
- package/lib/server/utils/userAgent.js +98 -0
- package/lib/server/utils/wsServer.js +121 -0
- package/lib/server/utils/zipFile.js +74 -0
- package/lib/server/utils/zones.js +57 -0
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +119 -0
- package/lib/server/webkit/wkAccessibility.js +237 -0
- package/lib/server/webkit/wkBrowser.js +339 -0
- package/lib/server/webkit/wkConnection.js +149 -0
- package/lib/server/webkit/wkExecutionContext.js +154 -0
- package/lib/server/webkit/wkInput.js +181 -0
- package/lib/server/webkit/wkInterceptableRequest.js +169 -0
- package/lib/server/webkit/wkPage.js +1134 -0
- package/lib/server/webkit/wkProvisionalPage.js +83 -0
- package/lib/server/webkit/wkWorkers.js +104 -0
- package/lib/server/webkit/wsl/webkit-wsl-transport-client.js +74 -0
- package/lib/server/webkit/wsl/webkit-wsl-transport-server.js +113 -0
- package/lib/third_party/diff_match_patch.js +2222 -0
- package/lib/third_party/pixelmatch.js +255 -0
- package/lib/utils/ascii.js +31 -0
- package/lib/utils/comparators.js +171 -0
- package/lib/utils/crypto.js +33 -0
- package/lib/utils/debug.js +46 -0
- package/lib/utils/debugLogger.js +89 -0
- package/lib/utils/env.js +49 -0
- package/lib/utils/eventsHelper.js +38 -0
- package/lib/utils/fileUtils.js +205 -0
- package/lib/utils/glob.js +83 -0
- package/lib/utils/happy-eyeballs.js +160 -0
- package/lib/utils/headers.js +52 -0
- package/lib/utils/hostPlatform.js +128 -0
- package/lib/utils/httpServer.js +236 -0
- package/lib/utils/index.js +346 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +392 -0
- package/lib/utils/isomorphic/assert.js +31 -0
- package/lib/utils/isomorphic/colors.js +72 -0
- package/lib/utils/isomorphic/cssParser.js +245 -0
- package/lib/utils/isomorphic/cssTokenizer.js +1051 -0
- package/lib/utils/isomorphic/headers.js +53 -0
- package/lib/utils/isomorphic/locatorGenerators.js +673 -0
- package/lib/utils/isomorphic/locatorParser.js +176 -0
- package/lib/utils/isomorphic/locatorUtils.js +81 -0
- package/lib/utils/isomorphic/manualPromise.js +114 -0
- package/lib/utils/isomorphic/mimeType.js +459 -0
- package/lib/utils/isomorphic/multimap.js +80 -0
- package/lib/utils/isomorphic/protocolFormatter.js +78 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +321 -0
- package/lib/utils/isomorphic/rtti.js +43 -0
- package/lib/utils/isomorphic/selectorParser.js +386 -0
- package/lib/utils/isomorphic/semaphore.js +54 -0
- package/lib/utils/isomorphic/stackTrace.js +158 -0
- package/lib/utils/isomorphic/stringUtils.js +155 -0
- package/lib/utils/isomorphic/time.js +49 -0
- package/lib/utils/isomorphic/timeoutRunner.js +66 -0
- package/lib/utils/isomorphic/traceUtils.js +58 -0
- package/lib/utils/isomorphic/types.js +16 -0
- package/lib/utils/isomorphic/urlMatch.js +176 -0
- package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
- package/lib/utils/linuxUtils.js +78 -0
- package/lib/utils/manualPromise.js +109 -0
- package/lib/utils/mimeType.js +29 -0
- package/lib/utils/multimap.js +75 -0
- package/lib/utils/network.js +188 -0
- package/lib/utils/processLauncher.js +248 -0
- package/lib/utils/profiler.js +53 -0
- package/lib/utils/rtti.js +44 -0
- package/lib/utils/semaphore.js +51 -0
- package/lib/utils/spawnAsync.js +45 -0
- package/lib/utils/stackTrace.js +121 -0
- package/lib/utils/task.js +58 -0
- package/lib/utils/time.js +37 -0
- package/lib/utils/timeoutRunner.js +66 -0
- package/lib/utils/traceUtils.js +44 -0
- package/lib/utils/userAgent.js +105 -0
- package/lib/utils/wsServer.js +127 -0
- package/lib/utils/zipFile.js +75 -0
- package/lib/utils/zones.js +62 -0
- package/lib/utils.js +107 -0
- package/lib/utilsBundle.js +109 -0
- package/lib/utilsBundleImpl/index.js +218 -0
- package/lib/utilsBundleImpl/xdg-open +1066 -0
- package/lib/vite/htmlReport/index.html +84 -0
- package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +1 -0
- package/lib/vite/recorder/assets/codeMirrorModule-RJCXzfmE.js +24 -0
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-Ri0uHF7I.css +1 -0
- package/lib/vite/recorder/assets/index-Y-X2TGJv.js +193 -0
- package/lib/vite/recorder/index.html +29 -0
- package/lib/vite/recorder/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-Bhnc5o2x.js +24 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-ClwvkA2N.js +265 -0
- package/lib/vite/traceViewer/assets/xtermModule-CsJ4vdCR.js +9 -0
- package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +1 -0
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/defaultSettingsView.TQ8_7ybu.css +1 -0
- package/lib/vite/traceViewer/index.DFO9NNF5.js +2 -0
- package/lib/vite/traceViewer/index.I8N9v4jT.css +1 -0
- package/lib/vite/traceViewer/index.html +43 -0
- package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/snapshot.html +21 -0
- package/lib/vite/traceViewer/sw.bundle.js +3 -0
- package/lib/vite/traceViewer/uiMode.Btcz36p_.css +1 -0
- package/lib/vite/traceViewer/uiMode.Shu3QS-1.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +17 -0
- package/lib/vite/traceViewer/xtermModule.DYP7pi_n.css +32 -0
- package/lib/zipBundle.js +34 -0
- package/lib/zipBundleImpl.js +5 -0
- package/package.json +43 -0
- package/types/protocol.d.ts +23130 -0
- package/types/structs.d.ts +45 -0
- package/types/types.d.ts +22857 -0
@@ -0,0 +1,383 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var socksClientCertificatesInterceptor_exports = {};
|
30
|
+
__export(socksClientCertificatesInterceptor_exports, {
|
31
|
+
ClientCertificatesProxy: () => ClientCertificatesProxy,
|
32
|
+
getMatchingTLSOptionsForOrigin: () => getMatchingTLSOptionsForOrigin,
|
33
|
+
rewriteOpenSSLErrorIfNeeded: () => rewriteOpenSSLErrorIfNeeded
|
34
|
+
});
|
35
|
+
module.exports = __toCommonJS(socksClientCertificatesInterceptor_exports);
|
36
|
+
var import_events = require("events");
|
37
|
+
var import_http2 = __toESM(require("http2"));
|
38
|
+
var import_net = __toESM(require("net"));
|
39
|
+
var import_stream = __toESM(require("stream"));
|
40
|
+
var import_tls = __toESM(require("tls"));
|
41
|
+
var import_socksProxy = require("./utils/socksProxy");
|
42
|
+
var import_utils = require("../utils");
|
43
|
+
var import_browserContext = require("./browserContext");
|
44
|
+
var import_network = require("./utils/network");
|
45
|
+
var import_debugLogger = require("./utils/debugLogger");
|
46
|
+
var import_happyEyeballs = require("./utils/happyEyeballs");
|
47
|
+
var import_utilsBundle = require("../utilsBundle");
|
48
|
+
let dummyServerTlsOptions = void 0;
|
49
|
+
function loadDummyServerCertsIfNeeded() {
|
50
|
+
if (dummyServerTlsOptions)
|
51
|
+
return;
|
52
|
+
const { cert, key } = (0, import_utils.generateSelfSignedCertificate)();
|
53
|
+
dummyServerTlsOptions = { key, cert };
|
54
|
+
}
|
55
|
+
class SocksProxyConnection {
|
56
|
+
constructor(socksProxy, uid, host, port) {
|
57
|
+
this._firstPackageReceived = false;
|
58
|
+
this._closed = false;
|
59
|
+
this.socksProxy = socksProxy;
|
60
|
+
this.uid = uid;
|
61
|
+
this.host = host;
|
62
|
+
this.port = port;
|
63
|
+
this._serverCloseEventListener = () => {
|
64
|
+
this._browserEncrypted.destroy();
|
65
|
+
};
|
66
|
+
this._browserEncrypted = new import_stream.default.Duplex({
|
67
|
+
read: () => {
|
68
|
+
},
|
69
|
+
write: (data, encoding, callback) => {
|
70
|
+
this.socksProxy._socksProxy.sendSocketData({ uid: this.uid, data });
|
71
|
+
callback();
|
72
|
+
},
|
73
|
+
destroy: (error, callback) => {
|
74
|
+
if (error)
|
75
|
+
socksProxy._socksProxy.sendSocketError({ uid: this.uid, error: error.message });
|
76
|
+
else
|
77
|
+
socksProxy._socksProxy.sendSocketEnd({ uid: this.uid });
|
78
|
+
callback();
|
79
|
+
}
|
80
|
+
});
|
81
|
+
}
|
82
|
+
async connect() {
|
83
|
+
const proxyAgent = this.socksProxy.getProxyAgent(this.host, this.port);
|
84
|
+
if (proxyAgent)
|
85
|
+
this._serverEncrypted = await proxyAgent.connect(new import_events.EventEmitter(), { host: rewriteToLocalhostIfNeeded(this.host), port: this.port, secureEndpoint: false });
|
86
|
+
else
|
87
|
+
this._serverEncrypted = await (0, import_happyEyeballs.createSocket)(rewriteToLocalhostIfNeeded(this.host), this.port);
|
88
|
+
this._serverEncrypted.once("close", this._serverCloseEventListener);
|
89
|
+
this._serverEncrypted.once("error", (error) => this._browserEncrypted.destroy(error));
|
90
|
+
if (this._closed) {
|
91
|
+
this._serverEncrypted.destroy();
|
92
|
+
return;
|
93
|
+
}
|
94
|
+
this.socksProxy._socksProxy.socketConnected({
|
95
|
+
uid: this.uid,
|
96
|
+
host: this._serverEncrypted.localAddress,
|
97
|
+
port: this._serverEncrypted.localPort
|
98
|
+
});
|
99
|
+
}
|
100
|
+
onClose() {
|
101
|
+
this._serverEncrypted.destroy();
|
102
|
+
this._browserEncrypted.destroy();
|
103
|
+
this._closed = true;
|
104
|
+
}
|
105
|
+
onData(data) {
|
106
|
+
if (!this._firstPackageReceived) {
|
107
|
+
this._firstPackageReceived = true;
|
108
|
+
if (data[0] === 22)
|
109
|
+
this._establishTlsTunnel(this._browserEncrypted, data);
|
110
|
+
else
|
111
|
+
this._establishPlaintextTunnel(this._browserEncrypted);
|
112
|
+
}
|
113
|
+
this._browserEncrypted.push(data);
|
114
|
+
}
|
115
|
+
_establishPlaintextTunnel(browserEncrypted) {
|
116
|
+
browserEncrypted.pipe(this._serverEncrypted);
|
117
|
+
this._serverEncrypted.pipe(browserEncrypted);
|
118
|
+
}
|
119
|
+
_establishTlsTunnel(browserEncrypted, clientHello) {
|
120
|
+
const browserALPNProtocols = parseALPNFromClientHello(clientHello) || ["http/1.1"];
|
121
|
+
import_debugLogger.debugLogger.log("client-certificates", `Browser->Proxy ${this.host}:${this.port} offers ALPN ${browserALPNProtocols}`);
|
122
|
+
const serverDecrypted = import_tls.default.connect({
|
123
|
+
socket: this._serverEncrypted,
|
124
|
+
host: this.host,
|
125
|
+
port: this.port,
|
126
|
+
rejectUnauthorized: !this.socksProxy.ignoreHTTPSErrors,
|
127
|
+
ALPNProtocols: browserALPNProtocols,
|
128
|
+
servername: !import_net.default.isIP(this.host) ? this.host : void 0,
|
129
|
+
secureContext: this.socksProxy.secureContextMap.get(new URL(`https://${this.host}:${this.port}`).origin)
|
130
|
+
}, async () => {
|
131
|
+
const browserDecrypted = await this._upgradeToTLSIfNeeded(browserEncrypted, serverDecrypted.alpnProtocol);
|
132
|
+
import_debugLogger.debugLogger.log("client-certificates", `Proxy->Server ${this.host}:${this.port} chooses ALPN ${browserDecrypted.alpnProtocol}`);
|
133
|
+
browserDecrypted.pipe(serverDecrypted);
|
134
|
+
serverDecrypted.pipe(browserDecrypted);
|
135
|
+
const cleanup = (error) => this._serverEncrypted.destroy(error);
|
136
|
+
browserDecrypted.once("error", cleanup);
|
137
|
+
serverDecrypted.once("error", cleanup);
|
138
|
+
browserDecrypted.once("close", cleanup);
|
139
|
+
serverDecrypted.once("close", cleanup);
|
140
|
+
if (this._closed)
|
141
|
+
serverDecrypted.destroy();
|
142
|
+
});
|
143
|
+
serverDecrypted.once("error", async (error) => {
|
144
|
+
import_debugLogger.debugLogger.log("client-certificates", `error when connecting to server: ${error.message.replaceAll("\n", " ")}`);
|
145
|
+
this._serverEncrypted.removeListener("close", this._serverCloseEventListener);
|
146
|
+
this._serverEncrypted.destroy();
|
147
|
+
const browserDecrypted = await this._upgradeToTLSIfNeeded(this._browserEncrypted, serverDecrypted.alpnProtocol);
|
148
|
+
const responseBody = (0, import_utils.escapeHTML)("Playwright client-certificate error: " + error.message).replaceAll("\n", " <br>");
|
149
|
+
if (browserDecrypted.alpnProtocol === "h2") {
|
150
|
+
if ("performServerHandshake" in import_http2.default) {
|
151
|
+
const session = import_http2.default.performServerHandshake(browserDecrypted);
|
152
|
+
session.on("error", (error2) => {
|
153
|
+
this._browserEncrypted.destroy(error2);
|
154
|
+
});
|
155
|
+
session.once("stream", (stream2) => {
|
156
|
+
const cleanup = (error2) => {
|
157
|
+
session.close();
|
158
|
+
this._browserEncrypted.destroy(error2);
|
159
|
+
};
|
160
|
+
stream2.once("end", cleanup);
|
161
|
+
stream2.once("error", cleanup);
|
162
|
+
stream2.respond({
|
163
|
+
[import_http2.default.constants.HTTP2_HEADER_CONTENT_TYPE]: "text/html",
|
164
|
+
[import_http2.default.constants.HTTP2_HEADER_STATUS]: 503
|
165
|
+
});
|
166
|
+
stream2.end(responseBody);
|
167
|
+
});
|
168
|
+
} else {
|
169
|
+
this._browserEncrypted.destroy(error);
|
170
|
+
}
|
171
|
+
} else {
|
172
|
+
browserDecrypted.end([
|
173
|
+
"HTTP/1.1 503 Internal Server Error",
|
174
|
+
"Content-Type: text/html; charset=utf-8",
|
175
|
+
"Content-Length: " + Buffer.byteLength(responseBody),
|
176
|
+
"",
|
177
|
+
responseBody
|
178
|
+
].join("\r\n"));
|
179
|
+
}
|
180
|
+
});
|
181
|
+
}
|
182
|
+
async _upgradeToTLSIfNeeded(socket, alpnProtocol) {
|
183
|
+
this._brorwserDecrypted ??= new Promise((resolve, reject) => {
|
184
|
+
const dummyServer = import_tls.default.createServer({
|
185
|
+
...dummyServerTlsOptions,
|
186
|
+
ALPNProtocols: [alpnProtocol || "http/1.1"]
|
187
|
+
});
|
188
|
+
dummyServer.emit("connection", socket);
|
189
|
+
dummyServer.once("secureConnection", (tlsSocket) => {
|
190
|
+
dummyServer.close();
|
191
|
+
resolve(tlsSocket);
|
192
|
+
});
|
193
|
+
dummyServer.once("error", (error) => {
|
194
|
+
dummyServer.close();
|
195
|
+
reject(error);
|
196
|
+
});
|
197
|
+
});
|
198
|
+
return this._brorwserDecrypted;
|
199
|
+
}
|
200
|
+
}
|
201
|
+
class ClientCertificatesProxy {
|
202
|
+
constructor(contextOptions) {
|
203
|
+
this._connections = /* @__PURE__ */ new Map();
|
204
|
+
this.secureContextMap = /* @__PURE__ */ new Map();
|
205
|
+
(0, import_browserContext.verifyClientCertificates)(contextOptions.clientCertificates);
|
206
|
+
this.ignoreHTTPSErrors = contextOptions.ignoreHTTPSErrors;
|
207
|
+
this._proxy = contextOptions.proxy;
|
208
|
+
this._initSecureContexts(contextOptions.clientCertificates);
|
209
|
+
this._socksProxy = new import_socksProxy.SocksProxy();
|
210
|
+
this._socksProxy.setPattern("*");
|
211
|
+
this._socksProxy.addListener(import_socksProxy.SocksProxy.Events.SocksRequested, async (payload) => {
|
212
|
+
try {
|
213
|
+
const connection = new SocksProxyConnection(this, payload.uid, payload.host, payload.port);
|
214
|
+
await connection.connect();
|
215
|
+
this._connections.set(payload.uid, connection);
|
216
|
+
} catch (error) {
|
217
|
+
import_debugLogger.debugLogger.log("client-certificates", `Failed to connect to ${payload.host}:${payload.port}: ${error.message}`);
|
218
|
+
this._socksProxy.socketFailed({ uid: payload.uid, errorCode: error.code });
|
219
|
+
}
|
220
|
+
});
|
221
|
+
this._socksProxy.addListener(import_socksProxy.SocksProxy.Events.SocksData, (payload) => {
|
222
|
+
this._connections.get(payload.uid)?.onData(payload.data);
|
223
|
+
});
|
224
|
+
this._socksProxy.addListener(import_socksProxy.SocksProxy.Events.SocksClosed, (payload) => {
|
225
|
+
this._connections.get(payload.uid)?.onClose();
|
226
|
+
this._connections.delete(payload.uid);
|
227
|
+
});
|
228
|
+
loadDummyServerCertsIfNeeded();
|
229
|
+
}
|
230
|
+
getProxyAgent(host, port) {
|
231
|
+
const proxyFromOptions = (0, import_network.createProxyAgent)(this._proxy);
|
232
|
+
if (proxyFromOptions)
|
233
|
+
return proxyFromOptions;
|
234
|
+
const proxyFromEnv = (0, import_utilsBundle.getProxyForUrl)(`https://${host}:${port}`);
|
235
|
+
if (proxyFromEnv)
|
236
|
+
return (0, import_network.createProxyAgent)({ server: proxyFromEnv });
|
237
|
+
}
|
238
|
+
_initSecureContexts(clientCertificates) {
|
239
|
+
const origin2certs = /* @__PURE__ */ new Map();
|
240
|
+
for (const cert of clientCertificates || []) {
|
241
|
+
const origin = normalizeOrigin(cert.origin);
|
242
|
+
const certs = origin2certs.get(origin) || [];
|
243
|
+
certs.push(cert);
|
244
|
+
origin2certs.set(origin, certs);
|
245
|
+
}
|
246
|
+
for (const [origin, certs] of origin2certs) {
|
247
|
+
try {
|
248
|
+
this.secureContextMap.set(origin, import_tls.default.createSecureContext(convertClientCertificatesToTLSOptions(certs)));
|
249
|
+
} catch (error) {
|
250
|
+
error = rewriteOpenSSLErrorIfNeeded(error);
|
251
|
+
throw (0, import_utils.rewriteErrorMessage)(error, `Failed to load client certificate: ${error.message}`);
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|
255
|
+
static async create(progress, contextOptions) {
|
256
|
+
const proxy = new ClientCertificatesProxy(contextOptions);
|
257
|
+
try {
|
258
|
+
await progress.race(proxy._socksProxy.listen(0, "127.0.0.1"));
|
259
|
+
return proxy;
|
260
|
+
} catch (error) {
|
261
|
+
await proxy.close();
|
262
|
+
throw error;
|
263
|
+
}
|
264
|
+
}
|
265
|
+
proxySettings() {
|
266
|
+
return { server: `socks5://127.0.0.1:${this._socksProxy.port()}` };
|
267
|
+
}
|
268
|
+
async close() {
|
269
|
+
await this._socksProxy.close();
|
270
|
+
}
|
271
|
+
}
|
272
|
+
function normalizeOrigin(origin) {
|
273
|
+
try {
|
274
|
+
return new URL(origin).origin;
|
275
|
+
} catch (error) {
|
276
|
+
return origin;
|
277
|
+
}
|
278
|
+
}
|
279
|
+
function convertClientCertificatesToTLSOptions(clientCertificates) {
|
280
|
+
if (!clientCertificates || !clientCertificates.length)
|
281
|
+
return;
|
282
|
+
const tlsOptions = {
|
283
|
+
pfx: [],
|
284
|
+
key: [],
|
285
|
+
cert: []
|
286
|
+
};
|
287
|
+
for (const cert of clientCertificates) {
|
288
|
+
if (cert.cert)
|
289
|
+
tlsOptions.cert.push(cert.cert);
|
290
|
+
if (cert.key)
|
291
|
+
tlsOptions.key.push({ pem: cert.key, passphrase: cert.passphrase });
|
292
|
+
if (cert.pfx)
|
293
|
+
tlsOptions.pfx.push({ buf: cert.pfx, passphrase: cert.passphrase });
|
294
|
+
}
|
295
|
+
return tlsOptions;
|
296
|
+
}
|
297
|
+
function getMatchingTLSOptionsForOrigin(clientCertificates, origin) {
|
298
|
+
const matchingCerts = clientCertificates?.filter(
|
299
|
+
(c) => normalizeOrigin(c.origin) === origin
|
300
|
+
);
|
301
|
+
return convertClientCertificatesToTLSOptions(matchingCerts);
|
302
|
+
}
|
303
|
+
function rewriteToLocalhostIfNeeded(host) {
|
304
|
+
return host === "local.playwright" ? "localhost" : host;
|
305
|
+
}
|
306
|
+
function rewriteOpenSSLErrorIfNeeded(error) {
|
307
|
+
if (error.message !== "unsupported" && error.code !== "ERR_CRYPTO_UNSUPPORTED_OPERATION")
|
308
|
+
return error;
|
309
|
+
return (0, import_utils.rewriteErrorMessage)(error, [
|
310
|
+
"Unsupported TLS certificate.",
|
311
|
+
"Most likely, the security algorithm of the given certificate was deprecated by OpenSSL.",
|
312
|
+
"For more details, see https://github.com/openssl/openssl/blob/master/README-PROVIDERS.md#the-legacy-provider",
|
313
|
+
"You could probably modernize the certificate by following the steps at https://github.com/nodejs/node/issues/40672#issuecomment-1243648223"
|
314
|
+
].join("\n"));
|
315
|
+
}
|
316
|
+
function parseALPNFromClientHello(buffer) {
|
317
|
+
if (buffer.length < 6)
|
318
|
+
return null;
|
319
|
+
if (buffer[0] !== 22)
|
320
|
+
return null;
|
321
|
+
let offset = 5;
|
322
|
+
if (buffer[offset] !== 1)
|
323
|
+
return null;
|
324
|
+
offset += 4;
|
325
|
+
offset += 2;
|
326
|
+
offset += 32;
|
327
|
+
if (offset >= buffer.length)
|
328
|
+
return null;
|
329
|
+
const sessionIdLength = buffer[offset];
|
330
|
+
offset += 1 + sessionIdLength;
|
331
|
+
if (offset + 2 > buffer.length)
|
332
|
+
return null;
|
333
|
+
const cipherSuitesLength = buffer.readUInt16BE(offset);
|
334
|
+
offset += 2 + cipherSuitesLength;
|
335
|
+
if (offset >= buffer.length)
|
336
|
+
return null;
|
337
|
+
const compressionMethodsLength = buffer[offset];
|
338
|
+
offset += 1 + compressionMethodsLength;
|
339
|
+
if (offset + 2 > buffer.length)
|
340
|
+
return null;
|
341
|
+
const extensionsLength = buffer.readUInt16BE(offset);
|
342
|
+
offset += 2;
|
343
|
+
const extensionsEnd = offset + extensionsLength;
|
344
|
+
if (extensionsEnd > buffer.length)
|
345
|
+
return null;
|
346
|
+
while (offset + 4 <= extensionsEnd) {
|
347
|
+
const extensionType = buffer.readUInt16BE(offset);
|
348
|
+
offset += 2;
|
349
|
+
const extensionLength = buffer.readUInt16BE(offset);
|
350
|
+
offset += 2;
|
351
|
+
if (offset + extensionLength > extensionsEnd)
|
352
|
+
return null;
|
353
|
+
if (extensionType === 16)
|
354
|
+
return parseALPNExtension(buffer.subarray(offset, offset + extensionLength));
|
355
|
+
offset += extensionLength;
|
356
|
+
}
|
357
|
+
return null;
|
358
|
+
}
|
359
|
+
function parseALPNExtension(buffer) {
|
360
|
+
if (buffer.length < 2)
|
361
|
+
return null;
|
362
|
+
const listLength = buffer.readUInt16BE(0);
|
363
|
+
if (listLength !== buffer.length - 2)
|
364
|
+
return null;
|
365
|
+
const protocols = [];
|
366
|
+
let offset = 2;
|
367
|
+
while (offset < buffer.length) {
|
368
|
+
const protocolLength = buffer[offset];
|
369
|
+
offset += 1;
|
370
|
+
if (offset + protocolLength > buffer.length)
|
371
|
+
break;
|
372
|
+
const protocol = buffer.subarray(offset, offset + protocolLength).toString("utf8");
|
373
|
+
protocols.push(protocol);
|
374
|
+
offset += protocolLength;
|
375
|
+
}
|
376
|
+
return protocols.length > 0 ? protocols : null;
|
377
|
+
}
|
378
|
+
// Annotate the CommonJS export names for ESM import in node:
|
379
|
+
0 && (module.exports = {
|
380
|
+
ClientCertificatesProxy,
|
381
|
+
getMatchingTLSOptionsForOrigin,
|
382
|
+
rewriteOpenSSLErrorIfNeeded
|
383
|
+
});
|
@@ -0,0 +1,95 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var socksInterceptor_exports = {};
|
30
|
+
__export(socksInterceptor_exports, {
|
31
|
+
SocksInterceptor: () => SocksInterceptor
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(socksInterceptor_exports);
|
34
|
+
var import_events = __toESM(require("events"));
|
35
|
+
var socks = __toESM(require("./utils/socksProxy"));
|
36
|
+
var import_validator = require("../protocol/validator");
|
37
|
+
var import_debug = require("./utils/debug");
|
38
|
+
class SocksInterceptor {
|
39
|
+
constructor(transport, pattern, redirectPortForTest) {
|
40
|
+
this._ids = /* @__PURE__ */ new Set();
|
41
|
+
this._handler = new socks.SocksProxyHandler(pattern, redirectPortForTest);
|
42
|
+
let lastId = -1;
|
43
|
+
this._channel = new Proxy(new import_events.default(), {
|
44
|
+
get: (obj, prop) => {
|
45
|
+
if (prop in obj || obj[prop] !== void 0 || typeof prop !== "string")
|
46
|
+
return obj[prop];
|
47
|
+
return (params) => {
|
48
|
+
try {
|
49
|
+
const id = --lastId;
|
50
|
+
this._ids.add(id);
|
51
|
+
const validator = (0, import_validator.findValidator)("SocksSupport", prop, "Params");
|
52
|
+
params = validator(params, "", { tChannelImpl: tChannelForSocks, binary: "toBase64", isUnderTest: import_debug.isUnderTest });
|
53
|
+
transport.send({ id, guid: this._socksSupportObjectGuid, method: prop, params, metadata: { stack: [], apiName: "", internal: true } });
|
54
|
+
} catch (e) {
|
55
|
+
}
|
56
|
+
};
|
57
|
+
}
|
58
|
+
});
|
59
|
+
this._handler.on(socks.SocksProxyHandler.Events.SocksConnected, (payload) => this._channel.socksConnected(payload));
|
60
|
+
this._handler.on(socks.SocksProxyHandler.Events.SocksData, (payload) => this._channel.socksData(payload));
|
61
|
+
this._handler.on(socks.SocksProxyHandler.Events.SocksError, (payload) => this._channel.socksError(payload));
|
62
|
+
this._handler.on(socks.SocksProxyHandler.Events.SocksFailed, (payload) => this._channel.socksFailed(payload));
|
63
|
+
this._handler.on(socks.SocksProxyHandler.Events.SocksEnd, (payload) => this._channel.socksEnd(payload));
|
64
|
+
this._channel.on("socksRequested", (payload) => this._handler.socketRequested(payload));
|
65
|
+
this._channel.on("socksClosed", (payload) => this._handler.socketClosed(payload));
|
66
|
+
this._channel.on("socksData", (payload) => this._handler.sendSocketData(payload));
|
67
|
+
}
|
68
|
+
cleanup() {
|
69
|
+
this._handler.cleanup();
|
70
|
+
}
|
71
|
+
interceptMessage(message) {
|
72
|
+
if (this._ids.has(message.id)) {
|
73
|
+
this._ids.delete(message.id);
|
74
|
+
return true;
|
75
|
+
}
|
76
|
+
if (message.method === "__create__" && message.params.type === "SocksSupport") {
|
77
|
+
this._socksSupportObjectGuid = message.params.guid;
|
78
|
+
return false;
|
79
|
+
}
|
80
|
+
if (this._socksSupportObjectGuid && message.guid === this._socksSupportObjectGuid) {
|
81
|
+
const validator = (0, import_validator.findValidator)("SocksSupport", message.method, "Event");
|
82
|
+
const params = validator(message.params, "", { tChannelImpl: tChannelForSocks, binary: "fromBase64", isUnderTest: import_debug.isUnderTest });
|
83
|
+
this._channel.emit(message.method, params);
|
84
|
+
return true;
|
85
|
+
}
|
86
|
+
return false;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
function tChannelForSocks(names, arg, path, context) {
|
90
|
+
throw new import_validator.ValidationError(`${path}: channels are not expected in SocksSupport`);
|
91
|
+
}
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
93
|
+
0 && (module.exports = {
|
94
|
+
SocksInterceptor
|
95
|
+
});
|
@@ -0,0 +1,70 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var http_request_exports = {};
|
20
|
+
__export(http_request_exports, {
|
21
|
+
createMultipartFormData: () => createMultipartFormData,
|
22
|
+
makeHTTPRequest: () => makeHTTPRequest
|
23
|
+
});
|
24
|
+
module.exports = __toCommonJS(http_request_exports);
|
25
|
+
async function makeHTTPRequest(options, body) {
|
26
|
+
const protocol = options.protocol || (options.port === 443 ? "https:" : "http:");
|
27
|
+
const hostname = options.hostname || options.host || "localhost";
|
28
|
+
const port = options.port ? `:${options.port}` : "";
|
29
|
+
const path = options.path || "/";
|
30
|
+
const url = `${protocol}//${hostname}${port}${path}`;
|
31
|
+
const response = await fetch(url, {
|
32
|
+
method: options.method || "GET",
|
33
|
+
headers: options.headers,
|
34
|
+
body
|
35
|
+
});
|
36
|
+
const data = await response.text();
|
37
|
+
if (!response.ok)
|
38
|
+
throw new Error(`HTTP ${response.status}: ${data}`);
|
39
|
+
return data;
|
40
|
+
}
|
41
|
+
function createMultipartFormData({
|
42
|
+
fields,
|
43
|
+
files
|
44
|
+
}) {
|
45
|
+
const boundary = "----WebKitFormBoundary" + Math.random().toString(36).substring(2, 15);
|
46
|
+
const CRLF = "\r\n";
|
47
|
+
const buffers = [];
|
48
|
+
for (const [key, value] of Object.entries(fields ?? {})) {
|
49
|
+
buffers.push(Buffer.from(`--${boundary}${CRLF}`, "utf8"));
|
50
|
+
buffers.push(Buffer.from(`Content-Disposition: form-data; name="${key}"${CRLF}`, "utf8"));
|
51
|
+
buffers.push(Buffer.from(CRLF, "utf8"));
|
52
|
+
buffers.push(Buffer.from(value + CRLF, "utf8"));
|
53
|
+
}
|
54
|
+
for (const file of files ?? []) {
|
55
|
+
buffers.push(Buffer.from(`--${boundary}${CRLF}`, "utf8"));
|
56
|
+
buffers.push(Buffer.from(`Content-Disposition: form-data; name="${file.fieldName}"; filename="${file.filename}"${CRLF}`, "utf8"));
|
57
|
+
buffers.push(Buffer.from(`Content-Type: ${file.contentType}${CRLF}`, "utf8"));
|
58
|
+
buffers.push(Buffer.from(CRLF, "utf8"));
|
59
|
+
buffers.push(file.data);
|
60
|
+
buffers.push(Buffer.from(CRLF, "utf8"));
|
61
|
+
}
|
62
|
+
buffers.push(Buffer.from(`--${boundary}--${CRLF}`, "utf8"));
|
63
|
+
const finalFormData = Buffer.concat(buffers);
|
64
|
+
return { formData: finalFormData, boundary };
|
65
|
+
}
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
67
|
+
0 && (module.exports = {
|
68
|
+
createMultipartFormData,
|
69
|
+
makeHTTPRequest
|
70
|
+
});
|
@@ -0,0 +1,137 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var stablyApiCaller_exports = {};
|
30
|
+
__export(stablyApiCaller_exports, {
|
31
|
+
callAiToAutohealLocator: () => callAiToAutohealLocator,
|
32
|
+
callAiToAutohealScreenshot: () => callAiToAutohealScreenshot
|
33
|
+
});
|
34
|
+
module.exports = __toCommonJS(stablyApiCaller_exports);
|
35
|
+
var import_zod = __toESM(require("zod"));
|
36
|
+
var import_http_request = require("./http-request");
|
37
|
+
var import_constants = require("../constants");
|
38
|
+
const LOCATOR_AUTOHEAL_ENDPOINT = "/v1/internal/sdk/autohealLocator";
|
39
|
+
const SCREENSHOT_AUTOHEAL_ENDPOINT = "/v1/internal/sdk/autohealToHaveScreenshot";
|
40
|
+
const zFastAutohealLocatorResponse = import_zod.default.discriminatedUnion("success", [
|
41
|
+
import_zod.default.object({
|
42
|
+
reasoning: import_zod.default.string(),
|
43
|
+
success: import_zod.default.literal(true),
|
44
|
+
coordinates: import_zod.default.array(import_zod.default.number()).length(2)
|
45
|
+
}),
|
46
|
+
import_zod.default.object({
|
47
|
+
reasoning: import_zod.default.string(),
|
48
|
+
success: import_zod.default.literal(false)
|
49
|
+
})
|
50
|
+
]);
|
51
|
+
async function callAiToAutohealLocator({
|
52
|
+
description,
|
53
|
+
screenshot,
|
54
|
+
originalSelector,
|
55
|
+
actionName,
|
56
|
+
model = "claude-sonnet-4-5"
|
57
|
+
}) {
|
58
|
+
const stablyApiKey = process.env.STABLY_API_KEY;
|
59
|
+
if (!stablyApiKey)
|
60
|
+
throw new Error("STABLY_API_KEY environment variable is required for auto-healing");
|
61
|
+
const { formData, boundary } = (0, import_http_request.createMultipartFormData)({
|
62
|
+
fields: {
|
63
|
+
originalSelector,
|
64
|
+
description,
|
65
|
+
actionName
|
66
|
+
},
|
67
|
+
files: [{
|
68
|
+
fieldName: "file",
|
69
|
+
filename: "screenshot.png",
|
70
|
+
data: screenshot,
|
71
|
+
contentType: "image/png"
|
72
|
+
}]
|
73
|
+
});
|
74
|
+
const options = {
|
75
|
+
hostname: import_constants.STABLY_API_HOSTNAME,
|
76
|
+
port: import_constants.STABLY_API_PORT,
|
77
|
+
path: `${LOCATOR_AUTOHEAL_ENDPOINT}?model=${encodeURIComponent(model)}`,
|
78
|
+
method: "POST",
|
79
|
+
headers: {
|
80
|
+
"Content-Type": `multipart/form-data; boundary=${boundary}`,
|
81
|
+
"Authorization": stablyApiKey,
|
82
|
+
"Content-Length": formData.length.toString()
|
83
|
+
}
|
84
|
+
};
|
85
|
+
const responseData = await (0, import_http_request.makeHTTPRequest)(options, formData);
|
86
|
+
const response = zFastAutohealLocatorResponse.parse(JSON.parse(responseData));
|
87
|
+
return {
|
88
|
+
coordinate: response.success ? response.coordinates : void 0,
|
89
|
+
reasoning: response.reasoning
|
90
|
+
};
|
91
|
+
}
|
92
|
+
const zAutohealScreenshotResponse = import_zod.default.object({
|
93
|
+
result: import_zod.default.boolean(),
|
94
|
+
reason: import_zod.default.string()
|
95
|
+
});
|
96
|
+
async function callAiToAutohealScreenshot({
|
97
|
+
actualScreenshot,
|
98
|
+
expectedScreenshot,
|
99
|
+
model = "claude-sonnet-4-5"
|
100
|
+
}) {
|
101
|
+
const stablyApiKey = process.env.STABLY_API_KEY;
|
102
|
+
if (!stablyApiKey)
|
103
|
+
throw new Error("STABLY_API_KEY environment variable is required for auto-healing");
|
104
|
+
const files = [
|
105
|
+
{
|
106
|
+
fieldName: "actualScreenshot",
|
107
|
+
filename: "actual.png",
|
108
|
+
data: actualScreenshot,
|
109
|
+
contentType: "image/png"
|
110
|
+
},
|
111
|
+
{
|
112
|
+
fieldName: "expectedScreenshot",
|
113
|
+
filename: "expected.png",
|
114
|
+
data: expectedScreenshot,
|
115
|
+
contentType: "image/png"
|
116
|
+
}
|
117
|
+
];
|
118
|
+
const { formData, boundary } = (0, import_http_request.createMultipartFormData)({ files });
|
119
|
+
const options = {
|
120
|
+
hostname: import_constants.STABLY_API_HOSTNAME,
|
121
|
+
port: import_constants.STABLY_API_PORT,
|
122
|
+
path: `${SCREENSHOT_AUTOHEAL_ENDPOINT}?model=${encodeURIComponent(model)}`,
|
123
|
+
method: "POST",
|
124
|
+
headers: {
|
125
|
+
"Content-Type": `multipart/form-data; boundary=${boundary}`,
|
126
|
+
"Authorization": stablyApiKey,
|
127
|
+
"Content-Length": formData.length.toString()
|
128
|
+
}
|
129
|
+
};
|
130
|
+
const responseData = await (0, import_http_request.makeHTTPRequest)(options, formData);
|
131
|
+
return zAutohealScreenshotResponse.parse(JSON.parse(responseData));
|
132
|
+
}
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
134
|
+
0 && (module.exports = {
|
135
|
+
callAiToAutohealLocator,
|
136
|
+
callAiToAutohealScreenshot
|
137
|
+
});
|