pokeedex 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.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +30 -0
- data/.gitignore +13 -0
- data/.standard.yml +9 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +125 -0
- data/LICENSE.txt +21 -0
- data/README.md +154 -0
- data/Rakefile +20 -0
- data/bin/pokeedex +85 -0
- data/lib/pokeedex/configuration.rb +47 -0
- data/lib/pokeedex/database.rb +42 -0
- data/lib/pokeedex/db/migrations/001_create_pokemons.rb +26 -0
- data/lib/pokeedex/exceptions.rb +15 -0
- data/lib/pokeedex/pokemon/base.rb +16 -0
- data/lib/pokeedex/pokemon/decorators/base.rb +112 -0
- data/lib/pokeedex/pokemon/model/base.rb +43 -0
- data/lib/pokeedex/pokemon/scrapper/base.rb +34 -0
- data/lib/pokeedex/pokemon/scrapper/fetchers/base.rb +123 -0
- data/lib/pokeedex/pokemon/scrapper/parsers/base.rb +205 -0
- data/lib/pokeedex/pokemon/scrapper/pokedex.rb +50 -0
- data/lib/pokeedex/pokemon/searcher/base.rb +59 -0
- data/lib/pokeedex/version.rb +5 -0
- data/lib/pokeedex.rb +55 -0
- data/node_modules/.bin/playwright +1 -0
- data/node_modules/.bin/playwright-core +1 -0
- data/node_modules/.yarn-integrity +22 -0
- data/node_modules/@playwright/test/LICENSE +202 -0
- data/node_modules/@playwright/test/NOTICE +5 -0
- data/node_modules/@playwright/test/README.md +169 -0
- data/node_modules/@playwright/test/cli.js +19 -0
- data/node_modules/@playwright/test/index.d.ts +18 -0
- data/node_modules/@playwright/test/index.js +17 -0
- data/node_modules/@playwright/test/index.mjs +18 -0
- data/node_modules/@playwright/test/node_modules/.bin/playwright +1 -0
- data/node_modules/@playwright/test/package.json +35 -0
- data/node_modules/@playwright/test/reporter.d.ts +17 -0
- data/node_modules/@playwright/test/reporter.js +17 -0
- data/node_modules/@playwright/test/reporter.mjs +17 -0
- data/node_modules/@types/node/LICENSE +21 -0
- data/node_modules/@types/node/README.md +15 -0
- data/node_modules/@types/node/assert/strict.d.ts +8 -0
- data/node_modules/@types/node/assert.d.ts +1040 -0
- data/node_modules/@types/node/async_hooks.d.ts +541 -0
- data/node_modules/@types/node/buffer.d.ts +2300 -0
- data/node_modules/@types/node/child_process.d.ts +1544 -0
- data/node_modules/@types/node/cluster.d.ts +578 -0
- data/node_modules/@types/node/console.d.ts +452 -0
- data/node_modules/@types/node/constants.d.ts +19 -0
- data/node_modules/@types/node/crypto.d.ts +4451 -0
- data/node_modules/@types/node/dgram.d.ts +596 -0
- data/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- data/node_modules/@types/node/dns/promises.d.ts +476 -0
- data/node_modules/@types/node/dns.d.ts +865 -0
- data/node_modules/@types/node/dom-events.d.ts +124 -0
- data/node_modules/@types/node/domain.d.ts +170 -0
- data/node_modules/@types/node/events.d.ts +931 -0
- data/node_modules/@types/node/fs/promises.d.ts +1264 -0
- data/node_modules/@types/node/fs.d.ts +4390 -0
- data/node_modules/@types/node/globals.d.ts +611 -0
- data/node_modules/@types/node/globals.global.d.ts +1 -0
- data/node_modules/@types/node/http.d.ts +1921 -0
- data/node_modules/@types/node/http2.d.ts +2555 -0
- data/node_modules/@types/node/https.d.ts +544 -0
- data/node_modules/@types/node/index.d.ts +90 -0
- data/node_modules/@types/node/inspector.d.ts +3966 -0
- data/node_modules/@types/node/module.d.ts +301 -0
- data/node_modules/@types/node/net.d.ts +995 -0
- data/node_modules/@types/node/os.d.ts +495 -0
- data/node_modules/@types/node/package.json +217 -0
- data/node_modules/@types/node/path.d.ts +200 -0
- data/node_modules/@types/node/perf_hooks.d.ts +941 -0
- data/node_modules/@types/node/process.d.ts +1912 -0
- data/node_modules/@types/node/punycode.d.ts +117 -0
- data/node_modules/@types/node/querystring.d.ts +153 -0
- data/node_modules/@types/node/readline/promises.d.ts +150 -0
- data/node_modules/@types/node/readline.d.ts +540 -0
- data/node_modules/@types/node/repl.d.ts +430 -0
- data/node_modules/@types/node/sea.d.ts +153 -0
- data/node_modules/@types/node/sqlite.d.ts +213 -0
- data/node_modules/@types/node/stream/consumers.d.ts +12 -0
- data/node_modules/@types/node/stream/promises.d.ts +83 -0
- data/node_modules/@types/node/stream/web.d.ts +606 -0
- data/node_modules/@types/node/stream.d.ts +1726 -0
- data/node_modules/@types/node/string_decoder.d.ts +67 -0
- data/node_modules/@types/node/test.d.ts +2098 -0
- data/node_modules/@types/node/timers/promises.d.ts +97 -0
- data/node_modules/@types/node/timers.d.ts +240 -0
- data/node_modules/@types/node/tls.d.ts +1220 -0
- data/node_modules/@types/node/trace_events.d.ts +197 -0
- data/node_modules/@types/node/tty.d.ts +208 -0
- data/node_modules/@types/node/url.d.ts +969 -0
- data/node_modules/@types/node/util.d.ts +2301 -0
- data/node_modules/@types/node/v8.d.ts +808 -0
- data/node_modules/@types/node/vm.d.ts +922 -0
- data/node_modules/@types/node/wasi.d.ts +181 -0
- data/node_modules/@types/node/worker_threads.d.ts +712 -0
- data/node_modules/@types/node/zlib.d.ts +539 -0
- data/node_modules/fsevents/LICENSE +22 -0
- data/node_modules/fsevents/README.md +83 -0
- data/node_modules/fsevents/fsevents.d.ts +46 -0
- data/node_modules/fsevents/fsevents.js +82 -0
- data/node_modules/fsevents/fsevents.node +0 -0
- data/node_modules/fsevents/package.json +62 -0
- data/node_modules/playwright/.eslintrc.js +6 -0
- data/node_modules/playwright/LICENSE +202 -0
- data/node_modules/playwright/NOTICE +5 -0
- data/node_modules/playwright/README.md +169 -0
- data/node_modules/playwright/ThirdPartyNotices.txt +4356 -0
- data/node_modules/playwright/cli.js +19 -0
- data/node_modules/playwright/index.d.ts +17 -0
- data/node_modules/playwright/index.js +17 -0
- data/node_modules/playwright/index.mjs +18 -0
- data/node_modules/playwright/jsx-runtime.js +41 -0
- data/node_modules/playwright/jsx-runtime.mjs +21 -0
- data/node_modules/playwright/lib/common/config.js +256 -0
- data/node_modules/playwright/lib/common/configLoader.js +321 -0
- data/node_modules/playwright/lib/common/esmLoaderHost.js +93 -0
- data/node_modules/playwright/lib/common/expectBundle.js +27 -0
- data/node_modules/playwright/lib/common/expectBundleImpl.js +389 -0
- data/node_modules/playwright/lib/common/fixtures.js +323 -0
- data/node_modules/playwright/lib/common/globals.js +48 -0
- data/node_modules/playwright/lib/common/ipc.js +48 -0
- data/node_modules/playwright/lib/common/poolBuilder.js +79 -0
- data/node_modules/playwright/lib/common/process.js +140 -0
- data/node_modules/playwright/lib/common/suiteUtils.js +133 -0
- data/node_modules/playwright/lib/common/test.js +311 -0
- data/node_modules/playwright/lib/common/testLoader.js +102 -0
- data/node_modules/playwright/lib/common/testType.js +284 -0
- data/node_modules/playwright/lib/fsWatcher.js +69 -0
- data/node_modules/playwright/lib/index.js +888 -0
- data/node_modules/playwright/lib/internalsForTest.js +28 -0
- data/node_modules/playwright/lib/isomorphic/events.js +72 -0
- data/node_modules/playwright/lib/isomorphic/folders.js +25 -0
- data/node_modules/playwright/lib/isomorphic/stringInternPool.js +58 -0
- data/node_modules/playwright/lib/isomorphic/teleReceiver.js +504 -0
- data/node_modules/playwright/lib/isomorphic/teleSuiteUpdater.js +149 -0
- data/node_modules/playwright/lib/isomorphic/testServerConnection.js +210 -0
- data/node_modules/playwright/lib/isomorphic/testServerInterface.js +5 -0
- data/node_modules/playwright/lib/isomorphic/testTree.js +272 -0
- data/node_modules/playwright/lib/loader/loaderMain.js +58 -0
- data/node_modules/playwright/lib/matchers/expect.js +297 -0
- data/node_modules/playwright/lib/matchers/matcherHint.js +50 -0
- data/node_modules/playwright/lib/matchers/matchers.js +449 -0
- data/node_modules/playwright/lib/matchers/toBeTruthy.js +55 -0
- data/node_modules/playwright/lib/matchers/toEqual.js +57 -0
- data/node_modules/playwright/lib/matchers/toMatchSnapshot.js +383 -0
- data/node_modules/playwright/lib/matchers/toMatchText.js +76 -0
- data/node_modules/playwright/lib/plugins/gitCommitInfoPlugin.js +78 -0
- data/node_modules/playwright/lib/plugins/index.js +19 -0
- data/node_modules/playwright/lib/plugins/webServerPlugin.js +187 -0
- data/node_modules/playwright/lib/program.js +346 -0
- data/node_modules/playwright/lib/reporters/base.js +553 -0
- data/node_modules/playwright/lib/reporters/blob.js +133 -0
- data/node_modules/playwright/lib/reporters/dot.js +82 -0
- data/node_modules/playwright/lib/reporters/empty.js +42 -0
- data/node_modules/playwright/lib/reporters/github.js +115 -0
- data/node_modules/playwright/lib/reporters/html.js +623 -0
- data/node_modules/playwright/lib/reporters/internalReporter.js +123 -0
- data/node_modules/playwright/lib/reporters/json.js +243 -0
- data/node_modules/playwright/lib/reporters/junit.js +233 -0
- data/node_modules/playwright/lib/reporters/line.js +108 -0
- data/node_modules/playwright/lib/reporters/list.js +222 -0
- data/node_modules/playwright/lib/reporters/markdown.js +76 -0
- data/node_modules/playwright/lib/reporters/merge.js +477 -0
- data/node_modules/playwright/lib/reporters/multiplexer.js +90 -0
- data/node_modules/playwright/lib/reporters/reporterV2.js +118 -0
- data/node_modules/playwright/lib/reporters/teleEmitter.js +268 -0
- data/node_modules/playwright/lib/reporters/versions/blobV1.js +5 -0
- data/node_modules/playwright/lib/runner/dispatcher.js +532 -0
- data/node_modules/playwright/lib/runner/failureTracker.js +60 -0
- data/node_modules/playwright/lib/runner/loadUtils.js +308 -0
- data/node_modules/playwright/lib/runner/loaderHost.js +85 -0
- data/node_modules/playwright/lib/runner/processHost.js +175 -0
- data/node_modules/playwright/lib/runner/projectUtils.js +203 -0
- data/node_modules/playwright/lib/runner/reporters.js +151 -0
- data/node_modules/playwright/lib/runner/runner.js +179 -0
- data/node_modules/playwright/lib/runner/sigIntWatcher.js +100 -0
- data/node_modules/playwright/lib/runner/taskRunner.js +147 -0
- data/node_modules/playwright/lib/runner/tasks.js +407 -0
- data/node_modules/playwright/lib/runner/testGroups.js +136 -0
- data/node_modules/playwright/lib/runner/testServer.js +605 -0
- data/node_modules/playwright/lib/runner/uiModeReporter.js +31 -0
- data/node_modules/playwright/lib/runner/vcs.js +55 -0
- data/node_modules/playwright/lib/runner/watchMode.js +398 -0
- data/node_modules/playwright/lib/runner/workerHost.js +85 -0
- data/node_modules/playwright/lib/third_party/tsconfig-loader.js +134 -0
- data/node_modules/playwright/lib/transform/babelBundle.js +28 -0
- data/node_modules/playwright/lib/transform/babelBundleImpl.js +2032 -0
- data/node_modules/playwright/lib/transform/compilationCache.js +254 -0
- data/node_modules/playwright/lib/transform/esmLoader.js +117 -0
- data/node_modules/playwright/lib/transform/esmUtils.js +32 -0
- data/node_modules/playwright/lib/transform/portTransport.js +81 -0
- data/node_modules/playwright/lib/transform/transform.js +267 -0
- data/node_modules/playwright/lib/util.js +356 -0
- data/node_modules/playwright/lib/utilsBundle.js +28 -0
- data/node_modules/playwright/lib/utilsBundleImpl.js +102 -0
- data/node_modules/playwright/lib/worker/fixtureRunner.js +279 -0
- data/node_modules/playwright/lib/worker/testInfo.js +397 -0
- data/node_modules/playwright/lib/worker/testTracing.js +314 -0
- data/node_modules/playwright/lib/worker/timeoutManager.js +153 -0
- data/node_modules/playwright/lib/worker/workerMain.js +637 -0
- data/node_modules/playwright/node_modules/.bin/playwright-core +1 -0
- data/node_modules/playwright/package.json +66 -0
- data/node_modules/playwright/test.d.ts +18 -0
- data/node_modules/playwright/test.js +24 -0
- data/node_modules/playwright/test.mjs +33 -0
- data/node_modules/playwright/types/test.d.ts +8444 -0
- data/node_modules/playwright/types/testReporter.d.ts +749 -0
- data/node_modules/playwright-core/LICENSE +202 -0
- data/node_modules/playwright-core/NOTICE +5 -0
- data/node_modules/playwright-core/README.md +3 -0
- data/node_modules/playwright-core/ThirdPartyNotices.txt +1548 -0
- data/node_modules/playwright-core/bin/PrintDeps.exe +0 -0
- data/node_modules/playwright-core/bin/README.md +2 -0
- data/node_modules/playwright-core/bin/install_media_pack.ps1 +5 -0
- data/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +40 -0
- data/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +13 -0
- data/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +24 -0
- data/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +40 -0
- data/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +12 -0
- data/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +24 -0
- data/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +40 -0
- data/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +11 -0
- data/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +23 -0
- data/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +40 -0
- data/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +11 -0
- data/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +23 -0
- data/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +40 -0
- data/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +11 -0
- data/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +24 -0
- data/node_modules/playwright-core/browsers.json +53 -0
- data/node_modules/playwright-core/cli.js +18 -0
- data/node_modules/playwright-core/index.d.ts +17 -0
- data/node_modules/playwright-core/index.js +33 -0
- data/node_modules/playwright-core/index.mjs +28 -0
- data/node_modules/playwright-core/lib/androidServerImpl.js +69 -0
- data/node_modules/playwright-core/lib/browserServerImpl.js +92 -0
- data/node_modules/playwright-core/lib/cli/driver.js +95 -0
- data/node_modules/playwright-core/lib/cli/program.js +577 -0
- data/node_modules/playwright-core/lib/cli/programWithTestStub.js +67 -0
- data/node_modules/playwright-core/lib/client/accessibility.js +50 -0
- data/node_modules/playwright-core/lib/client/android.js +473 -0
- data/node_modules/playwright-core/lib/client/api.js +279 -0
- data/node_modules/playwright-core/lib/client/artifact.js +79 -0
- data/node_modules/playwright-core/lib/client/browser.js +145 -0
- data/node_modules/playwright-core/lib/client/browserContext.js +541 -0
- data/node_modules/playwright-core/lib/client/browserType.js +241 -0
- data/node_modules/playwright-core/lib/client/cdpSession.js +53 -0
- data/node_modules/playwright-core/lib/client/channelOwner.js +231 -0
- data/node_modules/playwright-core/lib/client/clientHelper.js +57 -0
- data/node_modules/playwright-core/lib/client/clientInstrumentation.js +50 -0
- data/node_modules/playwright-core/lib/client/clock.js +68 -0
- data/node_modules/playwright-core/lib/client/connection.js +330 -0
- data/node_modules/playwright-core/lib/client/consoleMessage.js +55 -0
- data/node_modules/playwright-core/lib/client/coverage.js +41 -0
- data/node_modules/playwright-core/lib/client/dialog.js +57 -0
- data/node_modules/playwright-core/lib/client/download.js +62 -0
- data/node_modules/playwright-core/lib/client/electron.js +135 -0
- data/node_modules/playwright-core/lib/client/elementHandle.js +321 -0
- data/node_modules/playwright-core/lib/client/errors.js +77 -0
- data/node_modules/playwright-core/lib/client/eventEmitter.js +314 -0
- data/node_modules/playwright-core/lib/client/events.js +94 -0
- data/node_modules/playwright-core/lib/client/fetch.js +396 -0
- data/node_modules/playwright-core/lib/client/fileChooser.js +45 -0
- data/node_modules/playwright-core/lib/client/frame.js +504 -0
- data/node_modules/playwright-core/lib/client/harRouter.js +99 -0
- data/node_modules/playwright-core/lib/client/input.js +111 -0
- data/node_modules/playwright-core/lib/client/jsHandle.js +129 -0
- data/node_modules/playwright-core/lib/client/jsonPipe.js +35 -0
- data/node_modules/playwright-core/lib/client/localUtils.js +35 -0
- data/node_modules/playwright-core/lib/client/locator.js +441 -0
- data/node_modules/playwright-core/lib/client/network.js +604 -0
- data/node_modules/playwright-core/lib/client/page.js +725 -0
- data/node_modules/playwright-core/lib/client/playwright.js +77 -0
- data/node_modules/playwright-core/lib/client/selectors.js +67 -0
- data/node_modules/playwright-core/lib/client/stream.js +54 -0
- data/node_modules/playwright-core/lib/client/tracing.js +138 -0
- data/node_modules/playwright-core/lib/client/types.js +24 -0
- data/node_modules/playwright-core/lib/client/video.js +51 -0
- data/node_modules/playwright-core/lib/client/waiter.js +158 -0
- data/node_modules/playwright-core/lib/client/webError.js +37 -0
- data/node_modules/playwright-core/lib/client/worker.js +71 -0
- data/node_modules/playwright-core/lib/client/writableStream.js +54 -0
- data/node_modules/playwright-core/lib/common/socksProxy.js +569 -0
- data/node_modules/playwright-core/lib/common/timeoutSettings.js +73 -0
- data/node_modules/playwright-core/lib/common/types.js +5 -0
- data/node_modules/playwright-core/lib/generated/clockSource.js +7 -0
- data/node_modules/playwright-core/lib/generated/consoleApiSource.js +7 -0
- data/node_modules/playwright-core/lib/generated/injectedScriptSource.js +7 -0
- data/node_modules/playwright-core/lib/generated/recorderSource.js +7 -0
- data/node_modules/playwright-core/lib/generated/utilityScriptSource.js +7 -0
- data/node_modules/playwright-core/lib/image_tools/colorUtils.js +98 -0
- data/node_modules/playwright-core/lib/image_tools/compare.js +108 -0
- data/node_modules/playwright-core/lib/image_tools/imageChannel.js +70 -0
- data/node_modules/playwright-core/lib/image_tools/stats.js +102 -0
- data/node_modules/playwright-core/lib/inProcessFactory.js +54 -0
- data/node_modules/playwright-core/lib/inprocess.js +20 -0
- data/node_modules/playwright-core/lib/outofprocess.js +67 -0
- data/node_modules/playwright-core/lib/protocol/debug.js +27 -0
- data/node_modules/playwright-core/lib/protocol/serializers.js +173 -0
- data/node_modules/playwright-core/lib/protocol/transport.js +82 -0
- data/node_modules/playwright-core/lib/protocol/validator.js +2694 -0
- data/node_modules/playwright-core/lib/protocol/validatorPrimitives.js +139 -0
- data/node_modules/playwright-core/lib/remote/playwrightConnection.js +274 -0
- data/node_modules/playwright-core/lib/remote/playwrightServer.js +110 -0
- data/node_modules/playwright-core/lib/server/accessibility.js +62 -0
- data/node_modules/playwright-core/lib/server/android/android.js +441 -0
- data/node_modules/playwright-core/lib/server/android/backendAdb.js +172 -0
- data/node_modules/playwright-core/lib/server/artifact.js +104 -0
- data/node_modules/playwright-core/lib/server/bidi/bidiBrowser.js +296 -0
- data/node_modules/playwright-core/lib/server/bidi/bidiConnection.js +206 -0
- data/node_modules/playwright-core/lib/server/bidi/bidiExecutionContext.js +162 -0
- data/node_modules/playwright-core/lib/server/bidi/bidiFirefox.js +110 -0
- data/node_modules/playwright-core/lib/server/bidi/bidiInput.js +174 -0
- data/node_modules/playwright-core/lib/server/bidi/bidiNetworkManager.js +304 -0
- data/node_modules/playwright-core/lib/server/bidi/bidiPage.js +456 -0
- data/node_modules/playwright-core/lib/server/bidi/third_party/bidiDeserializer.js +93 -0
- data/node_modules/playwright-core/lib/server/bidi/third_party/bidiKeyboard.js +238 -0
- data/node_modules/playwright-core/lib/server/bidi/third_party/bidiProtocol.js +139 -0
- data/node_modules/playwright-core/lib/server/bidi/third_party/bidiSerializer.js +144 -0
- data/node_modules/playwright-core/lib/server/browser.js +137 -0
- data/node_modules/playwright-core/lib/server/browserContext.js +684 -0
- data/node_modules/playwright-core/lib/server/browserType.js +307 -0
- data/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
- data/node_modules/playwright-core/lib/server/chromium/chromium.js +362 -0
- data/node_modules/playwright-core/lib/server/chromium/chromiumSwitches.js +44 -0
- data/node_modules/playwright-core/lib/server/chromium/crAccessibility.js +237 -0
- data/node_modules/playwright-core/lib/server/chromium/crBrowser.js +515 -0
- data/node_modules/playwright-core/lib/server/chromium/crConnection.js +228 -0
- data/node_modules/playwright-core/lib/server/chromium/crCoverage.js +246 -0
- data/node_modules/playwright-core/lib/server/chromium/crDevTools.js +104 -0
- data/node_modules/playwright-core/lib/server/chromium/crDragDrop.js +143 -0
- data/node_modules/playwright-core/lib/server/chromium/crExecutionContext.js +156 -0
- data/node_modules/playwright-core/lib/server/chromium/crInput.js +171 -0
- data/node_modules/playwright-core/lib/server/chromium/crNetworkManager.js +767 -0
- data/node_modules/playwright-core/lib/server/chromium/crPage.js +1128 -0
- data/node_modules/playwright-core/lib/server/chromium/crPdf.js +153 -0
- data/node_modules/playwright-core/lib/server/chromium/crProtocolHelper.js +133 -0
- data/node_modules/playwright-core/lib/server/chromium/crServiceWorker.js +112 -0
- data/node_modules/playwright-core/lib/server/chromium/defaultFontFamilies.js +145 -0
- data/node_modules/playwright-core/lib/server/chromium/videoRecorder.js +155 -0
- data/node_modules/playwright-core/lib/server/clock.js +125 -0
- data/node_modules/playwright-core/lib/server/codegen/csharp.js +299 -0
- data/node_modules/playwright-core/lib/server/codegen/java.js +235 -0
- data/node_modules/playwright-core/lib/server/codegen/javascript.js +223 -0
- data/node_modules/playwright-core/lib/server/codegen/jsonl.js +47 -0
- data/node_modules/playwright-core/lib/server/codegen/language.js +76 -0
- data/node_modules/playwright-core/lib/server/codegen/languages.js +30 -0
- data/node_modules/playwright-core/lib/server/codegen/python.js +265 -0
- data/node_modules/playwright-core/lib/server/codegen/types.js +5 -0
- data/node_modules/playwright-core/lib/server/console.js +57 -0
- data/node_modules/playwright-core/lib/server/cookieStore.js +112 -0
- data/node_modules/playwright-core/lib/server/debugController.js +234 -0
- data/node_modules/playwright-core/lib/server/debugger.js +132 -0
- data/node_modules/playwright-core/lib/server/deviceDescriptors.js +26 -0
- data/node_modules/playwright-core/lib/server/deviceDescriptorsSource.json +1669 -0
- data/node_modules/playwright-core/lib/server/dialog.js +70 -0
- data/node_modules/playwright-core/lib/server/dispatchers/androidDispatcher.js +193 -0
- data/node_modules/playwright-core/lib/server/dispatchers/artifactDispatcher.js +118 -0
- data/node_modules/playwright-core/lib/server/dispatchers/browserContextDispatcher.js +351 -0
- data/node_modules/playwright-core/lib/server/dispatchers/browserDispatcher.js +170 -0
- data/node_modules/playwright-core/lib/server/dispatchers/browserTypeDispatcher.js +55 -0
- data/node_modules/playwright-core/lib/server/dispatchers/cdpSessionDispatcher.js +48 -0
- data/node_modules/playwright-core/lib/server/dispatchers/debugControllerDispatcher.js +103 -0
- data/node_modules/playwright-core/lib/server/dispatchers/dialogDispatcher.js +44 -0
- data/node_modules/playwright-core/lib/server/dispatchers/dispatcher.js +395 -0
- data/node_modules/playwright-core/lib/server/dispatchers/electronDispatcher.js +93 -0
- data/node_modules/playwright-core/lib/server/dispatchers/elementHandlerDispatcher.js +228 -0
- data/node_modules/playwright-core/lib/server/dispatchers/frameDispatcher.js +286 -0
- data/node_modules/playwright-core/lib/server/dispatchers/jsHandleDispatcher.js +102 -0
- data/node_modules/playwright-core/lib/server/dispatchers/jsonPipeDispatcher.js +59 -0
- data/node_modules/playwright-core/lib/server/dispatchers/localUtilsDispatcher.js +413 -0
- data/node_modules/playwright-core/lib/server/dispatchers/networkDispatchers.js +221 -0
- data/node_modules/playwright-core/lib/server/dispatchers/pageDispatcher.js +358 -0
- data/node_modules/playwright-core/lib/server/dispatchers/playwrightDispatcher.js +106 -0
- data/node_modules/playwright-core/lib/server/dispatchers/selectorsDispatcher.js +36 -0
- data/node_modules/playwright-core/lib/server/dispatchers/streamDispatcher.js +62 -0
- data/node_modules/playwright-core/lib/server/dispatchers/tracingDispatcher.js +54 -0
- data/node_modules/playwright-core/lib/server/dispatchers/writableStreamDispatcher.js +58 -0
- data/node_modules/playwright-core/lib/server/dom.js +845 -0
- data/node_modules/playwright-core/lib/server/download.js +53 -0
- data/node_modules/playwright-core/lib/server/electron/electron.js +296 -0
- data/node_modules/playwright-core/lib/server/electron/loader.js +57 -0
- data/node_modules/playwright-core/lib/server/errors.js +68 -0
- data/node_modules/playwright-core/lib/server/fetch.js +660 -0
- data/node_modules/playwright-core/lib/server/fileChooser.js +42 -0
- data/node_modules/playwright-core/lib/server/fileUploadUtils.js +75 -0
- data/node_modules/playwright-core/lib/server/firefox/ffAccessibility.js +216 -0
- data/node_modules/playwright-core/lib/server/firefox/ffBrowser.js +458 -0
- data/node_modules/playwright-core/lib/server/firefox/ffConnection.js +168 -0
- data/node_modules/playwright-core/lib/server/firefox/ffExecutionContext.js +138 -0
- data/node_modules/playwright-core/lib/server/firefox/ffInput.js +150 -0
- data/node_modules/playwright-core/lib/server/firefox/ffNetworkManager.js +233 -0
- data/node_modules/playwright-core/lib/server/firefox/ffPage.js +556 -0
- data/node_modules/playwright-core/lib/server/firefox/firefox.js +110 -0
- data/node_modules/playwright-core/lib/server/formData.js +75 -0
- data/node_modules/playwright-core/lib/server/frameSelectors.js +171 -0
- data/node_modules/playwright-core/lib/server/frames.js +1654 -0
- data/node_modules/playwright-core/lib/server/har/harRecorder.js +139 -0
- data/node_modules/playwright-core/lib/server/har/harTracer.js +531 -0
- data/node_modules/playwright-core/lib/server/helper.js +103 -0
- data/node_modules/playwright-core/lib/server/index.js +114 -0
- data/node_modules/playwright-core/lib/server/input.js +311 -0
- data/node_modules/playwright-core/lib/server/instrumentation.js +70 -0
- data/node_modules/playwright-core/lib/server/isomorphic/utilityScriptSerializers.js +226 -0
- data/node_modules/playwright-core/lib/server/javascript.js +306 -0
- data/node_modules/playwright-core/lib/server/launchApp.js +91 -0
- data/node_modules/playwright-core/lib/server/macEditingCommands.js +139 -0
- data/node_modules/playwright-core/lib/server/network.js +617 -0
- data/node_modules/playwright-core/lib/server/page.js +825 -0
- data/node_modules/playwright-core/lib/server/pipeTransport.js +85 -0
- data/node_modules/playwright-core/lib/server/playwright.js +85 -0
- data/node_modules/playwright-core/lib/server/progress.js +102 -0
- data/node_modules/playwright-core/lib/server/protocolError.js +49 -0
- data/node_modules/playwright-core/lib/server/recorder/contextRecorder.js +316 -0
- data/node_modules/playwright-core/lib/server/recorder/recorderActions.js +5 -0
- data/node_modules/playwright-core/lib/server/recorder/recorderApp.js +190 -0
- data/node_modules/playwright-core/lib/server/recorder/recorderCollection.js +127 -0
- data/node_modules/playwright-core/lib/server/recorder/recorderRunner.js +177 -0
- data/node_modules/playwright-core/lib/server/recorder/recorderUtils.js +71 -0
- data/node_modules/playwright-core/lib/server/recorder/throttledFile.js +46 -0
- data/node_modules/playwright-core/lib/server/recorder.js +324 -0
- data/node_modules/playwright-core/lib/server/registry/browserFetcher.js +168 -0
- data/node_modules/playwright-core/lib/server/registry/dependencies.js +322 -0
- data/node_modules/playwright-core/lib/server/registry/index.js +924 -0
- data/node_modules/playwright-core/lib/server/registry/nativeDeps.js +490 -0
- data/node_modules/playwright-core/lib/server/registry/oopDownloadBrowserMain.js +138 -0
- data/node_modules/playwright-core/lib/server/screenshotter.js +348 -0
- data/node_modules/playwright-core/lib/server/selectors.js +73 -0
- data/node_modules/playwright-core/lib/server/socksClientCertificatesInterceptor.js +328 -0
- data/node_modules/playwright-core/lib/server/socksInterceptor.js +100 -0
- data/node_modules/playwright-core/lib/server/trace/recorder/snapshotter.js +171 -0
- data/node_modules/playwright-core/lib/server/trace/recorder/snapshotterInjected.js +493 -0
- data/node_modules/playwright-core/lib/server/trace/recorder/tracing.js +486 -0
- data/node_modules/playwright-core/lib/server/trace/test/inMemorySnapshotter.js +93 -0
- data/node_modules/playwright-core/lib/server/trace/viewer/traceViewer.js +216 -0
- data/node_modules/playwright-core/lib/server/transport.js +191 -0
- data/node_modules/playwright-core/lib/server/types.js +24 -0
- data/node_modules/playwright-core/lib/server/usKeyboardLayout.js +555 -0
- data/node_modules/playwright-core/lib/server/webkit/webkit.js +87 -0
- data/node_modules/playwright-core/lib/server/webkit/wkAccessibility.js +194 -0
- data/node_modules/playwright-core/lib/server/webkit/wkBrowser.js +328 -0
- data/node_modules/playwright-core/lib/server/webkit/wkConnection.js +173 -0
- data/node_modules/playwright-core/lib/server/webkit/wkExecutionContext.js +146 -0
- data/node_modules/playwright-core/lib/server/webkit/wkInput.js +169 -0
- data/node_modules/playwright-core/lib/server/webkit/wkInterceptableRequest.js +162 -0
- data/node_modules/playwright-core/lib/server/webkit/wkPage.js +1216 -0
- data/node_modules/playwright-core/lib/server/webkit/wkProvisionalPage.js +94 -0
- data/node_modules/playwright-core/lib/server/webkit/wkWorkers.js +104 -0
- data/node_modules/playwright-core/lib/third_party/diff_match_patch.js +2222 -0
- data/node_modules/playwright-core/lib/third_party/pixelmatch.js +255 -0
- data/node_modules/playwright-core/lib/utils/ascii.js +31 -0
- data/node_modules/playwright-core/lib/utils/comparators.js +171 -0
- data/node_modules/playwright-core/lib/utils/crypto.js +174 -0
- data/node_modules/playwright-core/lib/utils/debug.js +46 -0
- data/node_modules/playwright-core/lib/utils/debugLogger.js +91 -0
- data/node_modules/playwright-core/lib/utils/env.js +49 -0
- data/node_modules/playwright-core/lib/utils/eventsHelper.js +38 -0
- data/node_modules/playwright-core/lib/utils/expectUtils.js +33 -0
- data/node_modules/playwright-core/lib/utils/fileUtils.js +205 -0
- data/node_modules/playwright-core/lib/utils/happy-eyeballs.js +181 -0
- data/node_modules/playwright-core/lib/utils/headers.js +52 -0
- data/node_modules/playwright-core/lib/utils/hostPlatform.js +133 -0
- data/node_modules/playwright-core/lib/utils/httpServer.js +236 -0
- data/node_modules/playwright-core/lib/utils/index.js +368 -0
- data/node_modules/playwright-core/lib/utils/isomorphic/cssParser.js +250 -0
- data/node_modules/playwright-core/lib/utils/isomorphic/cssTokenizer.js +979 -0
- data/node_modules/playwright-core/lib/utils/isomorphic/locatorGenerators.js +651 -0
- data/node_modules/playwright-core/lib/utils/isomorphic/locatorParser.js +179 -0
- data/node_modules/playwright-core/lib/utils/isomorphic/locatorUtils.js +62 -0
- data/node_modules/playwright-core/lib/utils/isomorphic/mimeType.js +29 -0
- data/node_modules/playwright-core/lib/utils/isomorphic/selectorParser.js +397 -0
- data/node_modules/playwright-core/lib/utils/isomorphic/stringUtils.js +139 -0
- data/node_modules/playwright-core/lib/utils/isomorphic/traceUtils.js +39 -0
- data/node_modules/playwright-core/lib/utils/isomorphic/urlMatch.js +120 -0
- data/node_modules/playwright-core/lib/utils/linuxUtils.js +78 -0
- data/node_modules/playwright-core/lib/utils/manualPromise.js +109 -0
- data/node_modules/playwright-core/lib/utils/multimap.js +75 -0
- data/node_modules/playwright-core/lib/utils/network.js +160 -0
- data/node_modules/playwright-core/lib/utils/processLauncher.js +248 -0
- data/node_modules/playwright-core/lib/utils/profiler.js +53 -0
- data/node_modules/playwright-core/lib/utils/rtti.js +44 -0
- data/node_modules/playwright-core/lib/utils/semaphore.js +51 -0
- data/node_modules/playwright-core/lib/utils/spawnAsync.js +45 -0
- data/node_modules/playwright-core/lib/utils/stackTrace.js +121 -0
- data/node_modules/playwright-core/lib/utils/task.js +58 -0
- data/node_modules/playwright-core/lib/utils/time.js +37 -0
- data/node_modules/playwright-core/lib/utils/timeoutRunner.js +66 -0
- data/node_modules/playwright-core/lib/utils/traceUtils.js +44 -0
- data/node_modules/playwright-core/lib/utils/userAgent.js +105 -0
- data/node_modules/playwright-core/lib/utils/wsServer.js +127 -0
- data/node_modules/playwright-core/lib/utils/zipFile.js +75 -0
- data/node_modules/playwright-core/lib/utils/zones.js +62 -0
- data/node_modules/playwright-core/lib/utilsBundle.js +82 -0
- data/node_modules/playwright-core/lib/utilsBundleImpl/index.js +53 -0
- data/node_modules/playwright-core/lib/utilsBundleImpl/xdg-open +1066 -0
- data/node_modules/playwright-core/lib/vite/htmlReport/index.html +66 -0
- data/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-aW6Vz3gf.js +24 -0
- data/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-ez37Vkbh.css +1 -0
- data/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- data/node_modules/playwright-core/lib/vite/recorder/assets/index-B-MT5gKo.css +1 -0
- data/node_modules/playwright-core/lib/vite/recorder/assets/index-DCpXOVIh.js +47 -0
- data/node_modules/playwright-core/lib/vite/recorder/index.html +29 -0
- data/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +9 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-eFKCUIu2.js +24 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +1 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/assets/workbench-D0cirtfA.js +72 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-BeNbaIVa.js +9 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.ez37Vkbh.css +1 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/embedded.BkuvsLJp.js +2 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/embedded.html +16 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/embedded.w7WN2u1R.css +1 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/index.C968kAiC.js +2 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/index.CrbWWHbf.css +1 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/index.html +27 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +9 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +21 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +3 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/uiMode.BkFnr4V0.js +10 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/uiMode.D3cNFP6u.css +1 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +18 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/workbench.DjbIuxix.css +1 -0
- data/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.DSXBckUd.css +32 -0
- data/node_modules/playwright-core/lib/zipBundle.js +25 -0
- data/node_modules/playwright-core/lib/zipBundleImpl.js +5 -0
- data/node_modules/playwright-core/package.json +44 -0
- data/node_modules/playwright-core/types/protocol.d.ts +21500 -0
- data/node_modules/playwright-core/types/structs.d.ts +45 -0
- data/node_modules/playwright-core/types/types.d.ts +21431 -0
- data/node_modules/undici-types/LICENSE +21 -0
- data/node_modules/undici-types/README.md +6 -0
- data/node_modules/undici-types/agent.d.ts +31 -0
- data/node_modules/undici-types/api.d.ts +43 -0
- data/node_modules/undici-types/balanced-pool.d.ts +29 -0
- data/node_modules/undici-types/cache.d.ts +36 -0
- data/node_modules/undici-types/client.d.ts +108 -0
- data/node_modules/undici-types/connector.d.ts +34 -0
- data/node_modules/undici-types/content-type.d.ts +21 -0
- data/node_modules/undici-types/cookies.d.ts +28 -0
- data/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- data/node_modules/undici-types/dispatcher.d.ts +255 -0
- data/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- data/node_modules/undici-types/errors.d.ts +149 -0
- data/node_modules/undici-types/eventsource.d.ts +63 -0
- data/node_modules/undici-types/fetch.d.ts +209 -0
- data/node_modules/undici-types/file.d.ts +39 -0
- data/node_modules/undici-types/filereader.d.ts +54 -0
- data/node_modules/undici-types/formdata.d.ts +108 -0
- data/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- data/node_modules/undici-types/global-origin.d.ts +7 -0
- data/node_modules/undici-types/handlers.d.ts +15 -0
- data/node_modules/undici-types/header.d.ts +4 -0
- data/node_modules/undici-types/index.d.ts +71 -0
- data/node_modules/undici-types/interceptors.d.ts +15 -0
- data/node_modules/undici-types/mock-agent.d.ts +50 -0
- data/node_modules/undici-types/mock-client.d.ts +25 -0
- data/node_modules/undici-types/mock-errors.d.ts +12 -0
- data/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- data/node_modules/undici-types/mock-pool.d.ts +25 -0
- data/node_modules/undici-types/package.json +55 -0
- data/node_modules/undici-types/patch.d.ts +71 -0
- data/node_modules/undici-types/pool-stats.d.ts +19 -0
- data/node_modules/undici-types/pool.d.ts +39 -0
- data/node_modules/undici-types/proxy-agent.d.ts +28 -0
- data/node_modules/undici-types/readable.d.ts +60 -0
- data/node_modules/undici-types/retry-agent.d.ts +8 -0
- data/node_modules/undici-types/retry-handler.d.ts +116 -0
- data/node_modules/undici-types/util.d.ts +18 -0
- data/node_modules/undici-types/webidl.d.ts +222 -0
- data/node_modules/undici-types/websocket.d.ts +152 -0
- data/pokeedex.gemspec +32 -0
- data/spec/fixtures/pokemon_com/responses/GET-200-bulbasaur.html +2262 -0
- data/spec/fixtures/pokemon_com/responses/GET-404-not-found.html +808 -0
- data/spec/pokeedex/configuration_spec.rb +37 -0
- data/spec/pokeedex/database_spec.rb +21 -0
- data/spec/pokeedex/exceptions_spec.rb +11 -0
- data/spec/pokeedex/pokemon/base_spec.rb +15 -0
- data/spec/pokeedex/pokemon/decorators/base_spec.rb +63 -0
- data/spec/pokeedex/pokemon/model/base_spec.rb +36 -0
- data/spec/pokeedex/pokemon/scrapper/fetchers/base_spec.rb +36 -0
- data/spec/pokeedex/pokemon/scrapper/parsers/base_spec.rb +49 -0
- data/spec/pokeedex/pokemon/scrapper/pokedex_spec.rb +71 -0
- data/spec/pokeedex/pokemon/searcher/base.rb +81 -0
- data/spec/pokeedex_spec.rb +7 -0
- data/spec/spec_helper.rb +42 -0
- data/yarn.lock +41 -0
- metadata +731 -0
@@ -0,0 +1,767 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.CRNetworkManager = void 0;
|
7
|
+
var _helper = require("../helper");
|
8
|
+
var _eventsHelper = require("../../utils/eventsHelper");
|
9
|
+
var network = _interopRequireWildcard(require("../network"));
|
10
|
+
var _utils = require("../../utils");
|
11
|
+
var _protocolError = require("../protocolError");
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
14
|
+
/**
|
15
|
+
* Copyright 2017 Google Inc. All rights reserved.
|
16
|
+
* Modifications copyright (c) Microsoft Corporation.
|
17
|
+
*
|
18
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
19
|
+
* you may not use this file except in compliance with the License.
|
20
|
+
* You may obtain a copy of the License at
|
21
|
+
*
|
22
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
23
|
+
*
|
24
|
+
* Unless required by applicable law or agreed to in writing, software
|
25
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
26
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
27
|
+
* See the License for the specific language governing permissions and
|
28
|
+
* limitations under the License.
|
29
|
+
*/
|
30
|
+
|
31
|
+
class CRNetworkManager {
|
32
|
+
constructor(page, serviceWorker) {
|
33
|
+
this._page = void 0;
|
34
|
+
this._serviceWorker = void 0;
|
35
|
+
this._requestIdToRequest = new Map();
|
36
|
+
this._requestIdToRequestWillBeSentEvent = new Map();
|
37
|
+
this._credentials = null;
|
38
|
+
this._attemptedAuthentications = new Set();
|
39
|
+
this._userRequestInterceptionEnabled = false;
|
40
|
+
this._protocolRequestInterceptionEnabled = false;
|
41
|
+
this._offline = false;
|
42
|
+
this._extraHTTPHeaders = [];
|
43
|
+
this._requestIdToRequestPausedEvent = new Map();
|
44
|
+
this._responseExtraInfoTracker = new ResponseExtraInfoTracker();
|
45
|
+
this._sessions = new Map();
|
46
|
+
this._page = page;
|
47
|
+
this._serviceWorker = serviceWorker;
|
48
|
+
}
|
49
|
+
async addSession(session, workerFrame, isMain) {
|
50
|
+
const sessionInfo = {
|
51
|
+
session,
|
52
|
+
isMain,
|
53
|
+
workerFrame,
|
54
|
+
eventListeners: []
|
55
|
+
};
|
56
|
+
sessionInfo.eventListeners = [_eventsHelper.eventsHelper.addEventListener(session, 'Fetch.requestPaused', this._onRequestPaused.bind(this, sessionInfo)), _eventsHelper.eventsHelper.addEventListener(session, 'Fetch.authRequired', this._onAuthRequired.bind(this, sessionInfo)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.requestWillBeSent', this._onRequestWillBeSent.bind(this, sessionInfo)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.requestWillBeSentExtraInfo', this._onRequestWillBeSentExtraInfo.bind(this)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.requestServedFromCache', this._onRequestServedFromCache.bind(this)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.responseReceived', this._onResponseReceived.bind(this, sessionInfo)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.responseReceivedExtraInfo', this._onResponseReceivedExtraInfo.bind(this)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.loadingFinished', this._onLoadingFinished.bind(this, sessionInfo)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.loadingFailed', this._onLoadingFailed.bind(this, sessionInfo))];
|
57
|
+
if (this._page) {
|
58
|
+
sessionInfo.eventListeners.push(...[_eventsHelper.eventsHelper.addEventListener(session, 'Network.webSocketCreated', e => this._page._frameManager.onWebSocketCreated(e.requestId, e.url)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.webSocketWillSendHandshakeRequest', e => this._page._frameManager.onWebSocketRequest(e.requestId)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.webSocketHandshakeResponseReceived', e => this._page._frameManager.onWebSocketResponse(e.requestId, e.response.status, e.response.statusText)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.webSocketFrameSent', e => e.response.payloadData && this._page._frameManager.onWebSocketFrameSent(e.requestId, e.response.opcode, e.response.payloadData)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.webSocketFrameReceived', e => e.response.payloadData && this._page._frameManager.webSocketFrameReceived(e.requestId, e.response.opcode, e.response.payloadData)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.webSocketClosed', e => this._page._frameManager.webSocketClosed(e.requestId)), _eventsHelper.eventsHelper.addEventListener(session, 'Network.webSocketFrameError', e => this._page._frameManager.webSocketError(e.requestId, e.errorMessage))]);
|
59
|
+
}
|
60
|
+
this._sessions.set(session, sessionInfo);
|
61
|
+
await Promise.all([session.send('Network.enable'), this._updateProtocolRequestInterceptionForSession(sessionInfo, true /* initial */), this._setOfflineForSession(sessionInfo, true /* initial */), this._setExtraHTTPHeadersForSession(sessionInfo, true /* initial */)]);
|
62
|
+
}
|
63
|
+
removeSession(session) {
|
64
|
+
const info = this._sessions.get(session);
|
65
|
+
if (info) _eventsHelper.eventsHelper.removeEventListeners(info.eventListeners);
|
66
|
+
this._sessions.delete(session);
|
67
|
+
}
|
68
|
+
async _forEachSession(cb) {
|
69
|
+
await Promise.all([...this._sessions.values()].map(info => {
|
70
|
+
if (info.isMain) return cb(info);
|
71
|
+
return cb(info).catch(e => {
|
72
|
+
// Broadcasting a message to the closed target should be a noop.
|
73
|
+
if ((0, _protocolError.isSessionClosedError)(e)) return;
|
74
|
+
throw e;
|
75
|
+
});
|
76
|
+
}));
|
77
|
+
}
|
78
|
+
async authenticate(credentials) {
|
79
|
+
this._credentials = credentials;
|
80
|
+
await this._updateProtocolRequestInterception();
|
81
|
+
}
|
82
|
+
async setOffline(offline) {
|
83
|
+
if (offline === this._offline) return;
|
84
|
+
this._offline = offline;
|
85
|
+
await this._forEachSession(info => this._setOfflineForSession(info));
|
86
|
+
}
|
87
|
+
async _setOfflineForSession(info, initial) {
|
88
|
+
if (initial && !this._offline) return;
|
89
|
+
// Workers are affected by the owner frame's Network.emulateNetworkConditions.
|
90
|
+
if (info.workerFrame) return;
|
91
|
+
await info.session.send('Network.emulateNetworkConditions', {
|
92
|
+
offline: this._offline,
|
93
|
+
// values of 0 remove any active throttling. crbug.com/456324#c9
|
94
|
+
latency: 0,
|
95
|
+
downloadThroughput: -1,
|
96
|
+
uploadThroughput: -1
|
97
|
+
});
|
98
|
+
}
|
99
|
+
async setRequestInterception(value) {
|
100
|
+
this._userRequestInterceptionEnabled = value;
|
101
|
+
await this._updateProtocolRequestInterception();
|
102
|
+
}
|
103
|
+
async _updateProtocolRequestInterception() {
|
104
|
+
const enabled = this._userRequestInterceptionEnabled || !!this._credentials;
|
105
|
+
if (enabled === this._protocolRequestInterceptionEnabled) return;
|
106
|
+
this._protocolRequestInterceptionEnabled = enabled;
|
107
|
+
await this._forEachSession(info => this._updateProtocolRequestInterceptionForSession(info));
|
108
|
+
}
|
109
|
+
async _updateProtocolRequestInterceptionForSession(info, initial) {
|
110
|
+
const enabled = this._protocolRequestInterceptionEnabled;
|
111
|
+
if (initial && !enabled) return;
|
112
|
+
const cachePromise = info.session.send('Network.setCacheDisabled', {
|
113
|
+
cacheDisabled: enabled
|
114
|
+
});
|
115
|
+
let fetchPromise = Promise.resolve(undefined);
|
116
|
+
if (!info.workerFrame) {
|
117
|
+
if (enabled) fetchPromise = info.session.send('Fetch.enable', {
|
118
|
+
handleAuthRequests: true,
|
119
|
+
patterns: [{
|
120
|
+
urlPattern: '*',
|
121
|
+
requestStage: 'Request'
|
122
|
+
}]
|
123
|
+
});else fetchPromise = info.session.send('Fetch.disable');
|
124
|
+
}
|
125
|
+
await Promise.all([cachePromise, fetchPromise]);
|
126
|
+
}
|
127
|
+
async setExtraHTTPHeaders(extraHTTPHeaders) {
|
128
|
+
if (!this._extraHTTPHeaders.length && !extraHTTPHeaders.length) return;
|
129
|
+
this._extraHTTPHeaders = extraHTTPHeaders;
|
130
|
+
await this._forEachSession(info => this._setExtraHTTPHeadersForSession(info));
|
131
|
+
}
|
132
|
+
async _setExtraHTTPHeadersForSession(info, initial) {
|
133
|
+
if (initial && !this._extraHTTPHeaders.length) return;
|
134
|
+
await info.session.send('Network.setExtraHTTPHeaders', {
|
135
|
+
headers: (0, _utils.headersArrayToObject)(this._extraHTTPHeaders, false /* lowerCase */)
|
136
|
+
});
|
137
|
+
}
|
138
|
+
async clearCache() {
|
139
|
+
await this._forEachSession(async info => {
|
140
|
+
// Sending 'Network.setCacheDisabled' with 'cacheDisabled = true' will clear the MemoryCache.
|
141
|
+
await info.session.send('Network.setCacheDisabled', {
|
142
|
+
cacheDisabled: true
|
143
|
+
});
|
144
|
+
if (!this._protocolRequestInterceptionEnabled) await info.session.send('Network.setCacheDisabled', {
|
145
|
+
cacheDisabled: false
|
146
|
+
});
|
147
|
+
if (!info.workerFrame) await info.session.send('Network.clearBrowserCache');
|
148
|
+
});
|
149
|
+
}
|
150
|
+
_onRequestWillBeSent(sessionInfo, event) {
|
151
|
+
// Request interception doesn't happen for data URLs with Network Service.
|
152
|
+
if (this._protocolRequestInterceptionEnabled && !event.request.url.startsWith('data:')) {
|
153
|
+
const requestId = event.requestId;
|
154
|
+
const requestPausedEvent = this._requestIdToRequestPausedEvent.get(requestId);
|
155
|
+
if (requestPausedEvent) {
|
156
|
+
this._onRequest(sessionInfo, event, requestPausedEvent.sessionInfo, requestPausedEvent.event);
|
157
|
+
this._requestIdToRequestPausedEvent.delete(requestId);
|
158
|
+
} else {
|
159
|
+
this._requestIdToRequestWillBeSentEvent.set(event.requestId, {
|
160
|
+
sessionInfo,
|
161
|
+
event
|
162
|
+
});
|
163
|
+
}
|
164
|
+
} else {
|
165
|
+
this._onRequest(sessionInfo, event, undefined, undefined);
|
166
|
+
}
|
167
|
+
}
|
168
|
+
_onRequestServedFromCache(event) {
|
169
|
+
this._responseExtraInfoTracker.requestServedFromCache(event);
|
170
|
+
}
|
171
|
+
_onRequestWillBeSentExtraInfo(event) {
|
172
|
+
this._responseExtraInfoTracker.requestWillBeSentExtraInfo(event);
|
173
|
+
}
|
174
|
+
_onAuthRequired(sessionInfo, event) {
|
175
|
+
let response = 'Default';
|
176
|
+
const shouldProvideCredentials = this._shouldProvideCredentials(event.request.url);
|
177
|
+
if (this._attemptedAuthentications.has(event.requestId)) {
|
178
|
+
response = 'CancelAuth';
|
179
|
+
} else if (shouldProvideCredentials) {
|
180
|
+
response = 'ProvideCredentials';
|
181
|
+
this._attemptedAuthentications.add(event.requestId);
|
182
|
+
}
|
183
|
+
const {
|
184
|
+
username,
|
185
|
+
password
|
186
|
+
} = shouldProvideCredentials && this._credentials ? this._credentials : {
|
187
|
+
username: undefined,
|
188
|
+
password: undefined
|
189
|
+
};
|
190
|
+
sessionInfo.session._sendMayFail('Fetch.continueWithAuth', {
|
191
|
+
requestId: event.requestId,
|
192
|
+
authChallengeResponse: {
|
193
|
+
response,
|
194
|
+
username,
|
195
|
+
password
|
196
|
+
}
|
197
|
+
});
|
198
|
+
}
|
199
|
+
_shouldProvideCredentials(url) {
|
200
|
+
if (!this._credentials) return false;
|
201
|
+
return !this._credentials.origin || new URL(url).origin.toLowerCase() === this._credentials.origin.toLowerCase();
|
202
|
+
}
|
203
|
+
_onRequestPaused(sessionInfo, event) {
|
204
|
+
if (!event.networkId) {
|
205
|
+
// Fetch without networkId means that request was not recognized by inspector, and
|
206
|
+
// it will never receive Network.requestWillBeSent. Continue the request to not affect it.
|
207
|
+
sessionInfo.session._sendMayFail('Fetch.continueRequest', {
|
208
|
+
requestId: event.requestId
|
209
|
+
});
|
210
|
+
return;
|
211
|
+
}
|
212
|
+
if (event.request.url.startsWith('data:')) return;
|
213
|
+
const requestId = event.networkId;
|
214
|
+
const requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get(requestId);
|
215
|
+
if (requestWillBeSentEvent) {
|
216
|
+
this._onRequest(requestWillBeSentEvent.sessionInfo, requestWillBeSentEvent.event, sessionInfo, event);
|
217
|
+
this._requestIdToRequestWillBeSentEvent.delete(requestId);
|
218
|
+
} else {
|
219
|
+
var _existingRequest$_rou;
|
220
|
+
const existingRequest = this._requestIdToRequest.get(requestId);
|
221
|
+
const alreadyContinuedParams = existingRequest === null || existingRequest === void 0 || (_existingRequest$_rou = existingRequest._route) === null || _existingRequest$_rou === void 0 ? void 0 : _existingRequest$_rou._alreadyContinuedParams;
|
222
|
+
if (alreadyContinuedParams && !event.redirectedRequestId) {
|
223
|
+
// Sometimes Chromium network stack restarts the request internally.
|
224
|
+
// For example, when no-cors request hits a "less public address space", it should be resent with cors.
|
225
|
+
// There are some more examples here: https://source.chromium.org/chromium/chromium/src/+/main:services/network/url_loader.cc;l=1205-1234;drc=d5dd931e0ad3d9ffe74888ec62a3cc106efd7ea6
|
226
|
+
// There are probably even more cases deep inside the network stack.
|
227
|
+
//
|
228
|
+
// Anyway, in this case, continue the request in the same way as before, and it should go through.
|
229
|
+
//
|
230
|
+
// Note: make sure not to prematurely continue the redirect, which shares the
|
231
|
+
// `networkId` between the original request and the redirect.
|
232
|
+
sessionInfo.session._sendMayFail('Fetch.continueRequest', {
|
233
|
+
...alreadyContinuedParams,
|
234
|
+
requestId: event.requestId
|
235
|
+
});
|
236
|
+
return;
|
237
|
+
}
|
238
|
+
this._requestIdToRequestPausedEvent.set(requestId, {
|
239
|
+
sessionInfo,
|
240
|
+
event
|
241
|
+
});
|
242
|
+
}
|
243
|
+
}
|
244
|
+
_onRequest(requestWillBeSentSessionInfo, requestWillBeSentEvent, requestPausedSessionInfo, requestPausedEvent) {
|
245
|
+
var _this$_page, _this$_page2, _this$_page3;
|
246
|
+
if (requestWillBeSentEvent.request.url.startsWith('data:')) return;
|
247
|
+
let redirectedFrom = null;
|
248
|
+
if (requestWillBeSentEvent.redirectResponse) {
|
249
|
+
const request = this._requestIdToRequest.get(requestWillBeSentEvent.requestId);
|
250
|
+
// If we connect late to the target, we could have missed the requestWillBeSent event.
|
251
|
+
if (request) {
|
252
|
+
this._handleRequestRedirect(request, requestWillBeSentEvent.redirectResponse, requestWillBeSentEvent.timestamp, requestWillBeSentEvent.redirectHasExtraInfo);
|
253
|
+
redirectedFrom = request;
|
254
|
+
}
|
255
|
+
}
|
256
|
+
let frame = requestWillBeSentEvent.frameId ? (_this$_page = this._page) === null || _this$_page === void 0 ? void 0 : _this$_page._frameManager.frame(requestWillBeSentEvent.frameId) : requestWillBeSentSessionInfo.workerFrame;
|
257
|
+
// Requests from workers lack frameId, because we receive Network.requestWillBeSent
|
258
|
+
// on the worker target. However, we receive Fetch.requestPaused on the page target,
|
259
|
+
// and lack workerFrame there. Luckily, Fetch.requestPaused provides a frameId.
|
260
|
+
if (!frame && this._page && requestPausedEvent && requestPausedEvent.frameId) frame = this._page._frameManager.frame(requestPausedEvent.frameId);
|
261
|
+
|
262
|
+
// Check if it's main resource request interception (targetId === main frame id).
|
263
|
+
if (!frame && this._page && requestWillBeSentEvent.frameId === ((_this$_page2 = this._page) === null || _this$_page2 === void 0 ? void 0 : _this$_page2._delegate)._targetId) {
|
264
|
+
// Main resource request for the page is being intercepted so the Frame is not created
|
265
|
+
// yet. Precreate it here for the purposes of request interception. It will be updated
|
266
|
+
// later as soon as the request continues and we receive frame tree from the page.
|
267
|
+
frame = this._page._frameManager.frameAttached(requestWillBeSentEvent.frameId, null);
|
268
|
+
}
|
269
|
+
|
270
|
+
// CORS options preflight request is generated by the network stack. If interception is enabled,
|
271
|
+
// we accept all CORS options, assuming that this was intended when setting route.
|
272
|
+
//
|
273
|
+
// Note: it would be better to match the URL against interception patterns.
|
274
|
+
const isInterceptedOptionsPreflight = !!requestPausedEvent && requestPausedEvent.request.method === 'OPTIONS' && requestWillBeSentEvent.initiator.type === 'preflight';
|
275
|
+
if (isInterceptedOptionsPreflight && (this._page || this._serviceWorker).needsRequestInterception()) {
|
276
|
+
const requestHeaders = requestPausedEvent.request.headers;
|
277
|
+
const responseHeaders = [{
|
278
|
+
name: 'Access-Control-Allow-Origin',
|
279
|
+
value: requestHeaders['Origin'] || '*'
|
280
|
+
}, {
|
281
|
+
name: 'Access-Control-Allow-Methods',
|
282
|
+
value: requestHeaders['Access-Control-Request-Method'] || 'GET, POST, OPTIONS, DELETE'
|
283
|
+
}, {
|
284
|
+
name: 'Access-Control-Allow-Credentials',
|
285
|
+
value: 'true'
|
286
|
+
}];
|
287
|
+
if (requestHeaders['Access-Control-Request-Headers']) responseHeaders.push({
|
288
|
+
name: 'Access-Control-Allow-Headers',
|
289
|
+
value: requestHeaders['Access-Control-Request-Headers']
|
290
|
+
});
|
291
|
+
requestPausedSessionInfo.session._sendMayFail('Fetch.fulfillRequest', {
|
292
|
+
requestId: requestPausedEvent.requestId,
|
293
|
+
responseCode: 204,
|
294
|
+
responsePhrase: network.statusText(204),
|
295
|
+
responseHeaders,
|
296
|
+
body: ''
|
297
|
+
});
|
298
|
+
return;
|
299
|
+
}
|
300
|
+
|
301
|
+
// Non-service-worker requests MUST have a frame—if they don't, we pretend there was no request
|
302
|
+
if (!frame && !this._serviceWorker) {
|
303
|
+
if (requestPausedEvent) requestPausedSessionInfo.session._sendMayFail('Fetch.continueRequest', {
|
304
|
+
requestId: requestPausedEvent.requestId
|
305
|
+
});
|
306
|
+
return;
|
307
|
+
}
|
308
|
+
let route = null;
|
309
|
+
let headersOverride;
|
310
|
+
if (requestPausedEvent) {
|
311
|
+
// We do not support intercepting redirects.
|
312
|
+
if (redirectedFrom || !this._userRequestInterceptionEnabled && this._protocolRequestInterceptionEnabled) {
|
313
|
+
var _redirectedFrom;
|
314
|
+
// Chromium does not preserve header overrides between redirects, so we have to do it ourselves.
|
315
|
+
headersOverride = (_redirectedFrom = redirectedFrom) === null || _redirectedFrom === void 0 || (_redirectedFrom = _redirectedFrom._originalRequestRoute) === null || _redirectedFrom === void 0 || (_redirectedFrom = _redirectedFrom._alreadyContinuedParams) === null || _redirectedFrom === void 0 ? void 0 : _redirectedFrom.headers;
|
316
|
+
requestPausedSessionInfo.session._sendMayFail('Fetch.continueRequest', {
|
317
|
+
requestId: requestPausedEvent.requestId,
|
318
|
+
headers: headersOverride
|
319
|
+
});
|
320
|
+
} else {
|
321
|
+
route = new RouteImpl(requestPausedSessionInfo.session, requestPausedEvent.requestId);
|
322
|
+
}
|
323
|
+
}
|
324
|
+
const isNavigationRequest = requestWillBeSentEvent.requestId === requestWillBeSentEvent.loaderId && requestWillBeSentEvent.type === 'Document';
|
325
|
+
const documentId = isNavigationRequest ? requestWillBeSentEvent.loaderId : undefined;
|
326
|
+
const request = new InterceptableRequest({
|
327
|
+
session: requestWillBeSentSessionInfo.session,
|
328
|
+
context: (this._page || this._serviceWorker)._browserContext,
|
329
|
+
frame: frame || null,
|
330
|
+
serviceWorker: this._serviceWorker || null,
|
331
|
+
documentId,
|
332
|
+
route,
|
333
|
+
requestWillBeSentEvent,
|
334
|
+
requestPausedEvent,
|
335
|
+
redirectedFrom,
|
336
|
+
headersOverride: headersOverride || null
|
337
|
+
});
|
338
|
+
this._requestIdToRequest.set(requestWillBeSentEvent.requestId, request);
|
339
|
+
if (route) {
|
340
|
+
// We may not receive extra info when intercepting the request.
|
341
|
+
// Use the headers from the Fetch.requestPausedPayload and release the allHeaders()
|
342
|
+
// right away, so that client can call it from the route handler.
|
343
|
+
request.request.setRawRequestHeaders((0, _utils.headersObjectToArray)(requestPausedEvent.request.headers, '\n'));
|
344
|
+
}
|
345
|
+
(((_this$_page3 = this._page) === null || _this$_page3 === void 0 ? void 0 : _this$_page3._frameManager) || this._serviceWorker).requestStarted(request.request, route || undefined);
|
346
|
+
}
|
347
|
+
_createResponse(request, responsePayload, hasExtraInfo) {
|
348
|
+
var _responsePayload$secu, _responsePayload$secu2, _responsePayload$secu3, _responsePayload$secu4, _responsePayload$secu5;
|
349
|
+
const getResponseBody = async () => {
|
350
|
+
var _request$_route;
|
351
|
+
const contentLengthHeader = Object.entries(responsePayload.headers).find(header => header[0].toLowerCase() === 'content-length');
|
352
|
+
const expectedLength = contentLengthHeader ? +contentLengthHeader[1] : undefined;
|
353
|
+
const session = request.session;
|
354
|
+
const response = await session.send('Network.getResponseBody', {
|
355
|
+
requestId: request._requestId
|
356
|
+
});
|
357
|
+
if (response.body || !expectedLength) return Buffer.from(response.body, response.base64Encoded ? 'base64' : 'utf8');
|
358
|
+
|
359
|
+
// Make sure no network requests sent while reading the body for fulfilled requests.
|
360
|
+
if ((_request$_route = request._route) !== null && _request$_route !== void 0 && _request$_route._fulfilled) return Buffer.from('');
|
361
|
+
|
362
|
+
// For <link prefetch we are going to receive empty body with non-empty content-length expectation. Reach out for the actual content.
|
363
|
+
const resource = await session.send('Network.loadNetworkResource', {
|
364
|
+
url: request.request.url(),
|
365
|
+
frameId: this._serviceWorker ? undefined : request.request.frame()._id,
|
366
|
+
options: {
|
367
|
+
disableCache: false,
|
368
|
+
includeCredentials: true
|
369
|
+
}
|
370
|
+
});
|
371
|
+
const chunks = [];
|
372
|
+
while (resource.resource.stream) {
|
373
|
+
const chunk = await session.send('IO.read', {
|
374
|
+
handle: resource.resource.stream
|
375
|
+
});
|
376
|
+
chunks.push(Buffer.from(chunk.data, chunk.base64Encoded ? 'base64' : 'utf-8'));
|
377
|
+
if (chunk.eof) {
|
378
|
+
await session.send('IO.close', {
|
379
|
+
handle: resource.resource.stream
|
380
|
+
});
|
381
|
+
break;
|
382
|
+
}
|
383
|
+
}
|
384
|
+
return Buffer.concat(chunks);
|
385
|
+
};
|
386
|
+
const timingPayload = responsePayload.timing;
|
387
|
+
let timing;
|
388
|
+
if (timingPayload && !this._responseExtraInfoTracker.servedFromCache(request._requestId)) {
|
389
|
+
timing = {
|
390
|
+
startTime: (timingPayload.requestTime - request._timestamp + request._wallTime) * 1000,
|
391
|
+
domainLookupStart: timingPayload.dnsStart,
|
392
|
+
domainLookupEnd: timingPayload.dnsEnd,
|
393
|
+
connectStart: timingPayload.connectStart,
|
394
|
+
secureConnectionStart: timingPayload.sslStart,
|
395
|
+
connectEnd: timingPayload.connectEnd,
|
396
|
+
requestStart: timingPayload.sendStart,
|
397
|
+
responseStart: timingPayload.receiveHeadersEnd
|
398
|
+
};
|
399
|
+
} else {
|
400
|
+
timing = {
|
401
|
+
startTime: request._wallTime * 1000,
|
402
|
+
domainLookupStart: -1,
|
403
|
+
domainLookupEnd: -1,
|
404
|
+
connectStart: -1,
|
405
|
+
secureConnectionStart: -1,
|
406
|
+
connectEnd: -1,
|
407
|
+
requestStart: -1,
|
408
|
+
responseStart: -1
|
409
|
+
};
|
410
|
+
}
|
411
|
+
const response = new network.Response(request.request, responsePayload.status, responsePayload.statusText, (0, _utils.headersObjectToArray)(responsePayload.headers), timing, getResponseBody, !!responsePayload.fromServiceWorker, responsePayload.protocol);
|
412
|
+
if (responsePayload !== null && responsePayload !== void 0 && responsePayload.remoteIPAddress && typeof (responsePayload === null || responsePayload === void 0 ? void 0 : responsePayload.remotePort) === 'number') {
|
413
|
+
response._serverAddrFinished({
|
414
|
+
ipAddress: responsePayload.remoteIPAddress,
|
415
|
+
port: responsePayload.remotePort
|
416
|
+
});
|
417
|
+
} else {
|
418
|
+
response._serverAddrFinished();
|
419
|
+
}
|
420
|
+
response._securityDetailsFinished({
|
421
|
+
protocol: responsePayload === null || responsePayload === void 0 || (_responsePayload$secu = responsePayload.securityDetails) === null || _responsePayload$secu === void 0 ? void 0 : _responsePayload$secu.protocol,
|
422
|
+
subjectName: responsePayload === null || responsePayload === void 0 || (_responsePayload$secu2 = responsePayload.securityDetails) === null || _responsePayload$secu2 === void 0 ? void 0 : _responsePayload$secu2.subjectName,
|
423
|
+
issuer: responsePayload === null || responsePayload === void 0 || (_responsePayload$secu3 = responsePayload.securityDetails) === null || _responsePayload$secu3 === void 0 ? void 0 : _responsePayload$secu3.issuer,
|
424
|
+
validFrom: responsePayload === null || responsePayload === void 0 || (_responsePayload$secu4 = responsePayload.securityDetails) === null || _responsePayload$secu4 === void 0 ? void 0 : _responsePayload$secu4.validFrom,
|
425
|
+
validTo: responsePayload === null || responsePayload === void 0 || (_responsePayload$secu5 = responsePayload.securityDetails) === null || _responsePayload$secu5 === void 0 ? void 0 : _responsePayload$secu5.validTo
|
426
|
+
});
|
427
|
+
this._responseExtraInfoTracker.processResponse(request._requestId, response, hasExtraInfo);
|
428
|
+
return response;
|
429
|
+
}
|
430
|
+
_deleteRequest(request) {
|
431
|
+
this._requestIdToRequest.delete(request._requestId);
|
432
|
+
if (request._interceptionId) this._attemptedAuthentications.delete(request._interceptionId);
|
433
|
+
}
|
434
|
+
_handleRequestRedirect(request, responsePayload, timestamp, hasExtraInfo) {
|
435
|
+
var _this$_page4, _this$_page5;
|
436
|
+
const response = this._createResponse(request, responsePayload, hasExtraInfo);
|
437
|
+
response.setTransferSize(null);
|
438
|
+
response.setEncodedBodySize(null);
|
439
|
+
response._requestFinished((timestamp - request._timestamp) * 1000);
|
440
|
+
this._deleteRequest(request);
|
441
|
+
(((_this$_page4 = this._page) === null || _this$_page4 === void 0 ? void 0 : _this$_page4._frameManager) || this._serviceWorker).requestReceivedResponse(response);
|
442
|
+
(((_this$_page5 = this._page) === null || _this$_page5 === void 0 ? void 0 : _this$_page5._frameManager) || this._serviceWorker).reportRequestFinished(request.request, response);
|
443
|
+
}
|
444
|
+
_onResponseReceivedExtraInfo(event) {
|
445
|
+
this._responseExtraInfoTracker.responseReceivedExtraInfo(event);
|
446
|
+
}
|
447
|
+
_onResponseReceived(sessionInfo, event) {
|
448
|
+
var _this$_page6;
|
449
|
+
let request = this._requestIdToRequest.get(event.requestId);
|
450
|
+
// For frame-level Requests that are handled by a Service Worker's fetch handler, we'll never get a requestPaused event, so we need to
|
451
|
+
// manually create the request. In an ideal world, crNetworkManager would be able to know this on Network.requestWillBeSent, but there
|
452
|
+
// is not enough metadata there.
|
453
|
+
if (!request && event.response.fromServiceWorker) {
|
454
|
+
const requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get(event.requestId);
|
455
|
+
if (requestWillBeSentEvent) {
|
456
|
+
this._requestIdToRequestWillBeSentEvent.delete(event.requestId);
|
457
|
+
this._onRequest(sessionInfo, requestWillBeSentEvent.event, undefined, undefined);
|
458
|
+
request = this._requestIdToRequest.get(event.requestId);
|
459
|
+
}
|
460
|
+
}
|
461
|
+
// FileUpload sends a response without a matching request.
|
462
|
+
if (!request) return;
|
463
|
+
const response = this._createResponse(request, event.response, event.hasExtraInfo);
|
464
|
+
(((_this$_page6 = this._page) === null || _this$_page6 === void 0 ? void 0 : _this$_page6._frameManager) || this._serviceWorker).requestReceivedResponse(response);
|
465
|
+
}
|
466
|
+
_onLoadingFinished(sessionInfo, event) {
|
467
|
+
var _this$_page7;
|
468
|
+
this._responseExtraInfoTracker.loadingFinished(event);
|
469
|
+
const request = this._requestIdToRequest.get(event.requestId);
|
470
|
+
// For certain requestIds we never receive requestWillBeSent event.
|
471
|
+
// @see https://crbug.com/750469
|
472
|
+
if (!request) return;
|
473
|
+
this._maybeUpdateOOPIFMainRequest(sessionInfo, request);
|
474
|
+
|
475
|
+
// Under certain conditions we never get the Network.responseReceived
|
476
|
+
// event from protocol. @see https://crbug.com/883475
|
477
|
+
const response = request.request._existingResponse();
|
478
|
+
if (response) {
|
479
|
+
response.setTransferSize(event.encodedDataLength);
|
480
|
+
response.responseHeadersSize().then(size => response.setEncodedBodySize(event.encodedDataLength - size));
|
481
|
+
response._requestFinished(_helper.helper.secondsToRoundishMillis(event.timestamp - request._timestamp));
|
482
|
+
}
|
483
|
+
this._deleteRequest(request);
|
484
|
+
(((_this$_page7 = this._page) === null || _this$_page7 === void 0 ? void 0 : _this$_page7._frameManager) || this._serviceWorker).reportRequestFinished(request.request, response);
|
485
|
+
}
|
486
|
+
_onLoadingFailed(sessionInfo, event) {
|
487
|
+
var _this$_page8;
|
488
|
+
this._responseExtraInfoTracker.loadingFailed(event);
|
489
|
+
let request = this._requestIdToRequest.get(event.requestId);
|
490
|
+
if (!request) {
|
491
|
+
const requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get(event.requestId);
|
492
|
+
if (requestWillBeSentEvent) {
|
493
|
+
// This is a case where request has failed before we had a chance to intercept it.
|
494
|
+
// We stop waiting for Fetch.requestPaused (it might never come), and dispatch request event
|
495
|
+
// right away, followed by requestfailed event.
|
496
|
+
this._requestIdToRequestWillBeSentEvent.delete(event.requestId);
|
497
|
+
this._onRequest(sessionInfo, requestWillBeSentEvent.event, undefined, undefined);
|
498
|
+
request = this._requestIdToRequest.get(event.requestId);
|
499
|
+
}
|
500
|
+
}
|
501
|
+
|
502
|
+
// For certain requestIds we never receive requestWillBeSent event.
|
503
|
+
// @see https://crbug.com/750469
|
504
|
+
if (!request) return;
|
505
|
+
this._maybeUpdateOOPIFMainRequest(sessionInfo, request);
|
506
|
+
const response = request.request._existingResponse();
|
507
|
+
if (response) {
|
508
|
+
response.setTransferSize(null);
|
509
|
+
response.setEncodedBodySize(null);
|
510
|
+
response._requestFinished(_helper.helper.secondsToRoundishMillis(event.timestamp - request._timestamp));
|
511
|
+
} else {
|
512
|
+
// Loading failed before response has arrived - there will be no extra info events.
|
513
|
+
request.request.setRawRequestHeaders(null);
|
514
|
+
}
|
515
|
+
this._deleteRequest(request);
|
516
|
+
request.request._setFailureText(event.errorText || event.blockedReason || '');
|
517
|
+
(((_this$_page8 = this._page) === null || _this$_page8 === void 0 ? void 0 : _this$_page8._frameManager) || this._serviceWorker).requestFailed(request.request, !!event.canceled);
|
518
|
+
}
|
519
|
+
_maybeUpdateOOPIFMainRequest(sessionInfo, request) {
|
520
|
+
// OOPIF has a main request that starts in the parent session but finishes in the child session.
|
521
|
+
// We check for the main request by matching loaderId and requestId, and if it now belongs to
|
522
|
+
// a child session, migrate it there.
|
523
|
+
if (request.session !== sessionInfo.session && !sessionInfo.isMain && request._documentId === request._requestId) request.session = sessionInfo.session;
|
524
|
+
}
|
525
|
+
}
|
526
|
+
exports.CRNetworkManager = CRNetworkManager;
|
527
|
+
class InterceptableRequest {
|
528
|
+
constructor(options) {
|
529
|
+
this.request = void 0;
|
530
|
+
this._requestId = void 0;
|
531
|
+
this._interceptionId = void 0;
|
532
|
+
this._documentId = void 0;
|
533
|
+
this._timestamp = void 0;
|
534
|
+
this._wallTime = void 0;
|
535
|
+
this._route = void 0;
|
536
|
+
// Only first request in the chain can be intercepted, so this will
|
537
|
+
// store the first and only Route in the chain (if any).
|
538
|
+
this._originalRequestRoute = void 0;
|
539
|
+
this.session = void 0;
|
540
|
+
const {
|
541
|
+
session,
|
542
|
+
context,
|
543
|
+
frame,
|
544
|
+
documentId,
|
545
|
+
route,
|
546
|
+
requestWillBeSentEvent,
|
547
|
+
requestPausedEvent,
|
548
|
+
redirectedFrom,
|
549
|
+
serviceWorker,
|
550
|
+
headersOverride
|
551
|
+
} = options;
|
552
|
+
this.session = session;
|
553
|
+
this._timestamp = requestWillBeSentEvent.timestamp;
|
554
|
+
this._wallTime = requestWillBeSentEvent.wallTime;
|
555
|
+
this._requestId = requestWillBeSentEvent.requestId;
|
556
|
+
this._interceptionId = requestPausedEvent && requestPausedEvent.requestId;
|
557
|
+
this._documentId = documentId;
|
558
|
+
this._route = route;
|
559
|
+
this._originalRequestRoute = route !== null && route !== void 0 ? route : redirectedFrom === null || redirectedFrom === void 0 ? void 0 : redirectedFrom._originalRequestRoute;
|
560
|
+
const {
|
561
|
+
headers,
|
562
|
+
method,
|
563
|
+
url,
|
564
|
+
postDataEntries = null
|
565
|
+
} = requestPausedEvent ? requestPausedEvent.request : requestWillBeSentEvent.request;
|
566
|
+
const type = (requestWillBeSentEvent.type || '').toLowerCase();
|
567
|
+
let postDataBuffer = null;
|
568
|
+
const entries = postDataEntries === null || postDataEntries === void 0 ? void 0 : postDataEntries.filter(entry => entry.bytes);
|
569
|
+
if (entries && entries.length) postDataBuffer = Buffer.concat(entries.map(entry => Buffer.from(entry.bytes, 'base64')));
|
570
|
+
this.request = new network.Request(context, frame, serviceWorker, (redirectedFrom === null || redirectedFrom === void 0 ? void 0 : redirectedFrom.request) || null, documentId, url, type, method, postDataBuffer, headersOverride || (0, _utils.headersObjectToArray)(headers));
|
571
|
+
}
|
572
|
+
}
|
573
|
+
class RouteImpl {
|
574
|
+
constructor(session, interceptionId) {
|
575
|
+
this._session = void 0;
|
576
|
+
this._interceptionId = void 0;
|
577
|
+
this._alreadyContinuedParams = void 0;
|
578
|
+
this._fulfilled = false;
|
579
|
+
this._session = session;
|
580
|
+
this._interceptionId = interceptionId;
|
581
|
+
}
|
582
|
+
async continue(overrides) {
|
583
|
+
this._alreadyContinuedParams = {
|
584
|
+
requestId: this._interceptionId,
|
585
|
+
url: overrides.url,
|
586
|
+
headers: overrides.headers,
|
587
|
+
method: overrides.method,
|
588
|
+
postData: overrides.postData ? overrides.postData.toString('base64') : undefined
|
589
|
+
};
|
590
|
+
await catchDisallowedErrors(async () => {
|
591
|
+
await this._session.send('Fetch.continueRequest', this._alreadyContinuedParams);
|
592
|
+
});
|
593
|
+
}
|
594
|
+
async fulfill(response) {
|
595
|
+
this._fulfilled = true;
|
596
|
+
const body = response.isBase64 ? response.body : Buffer.from(response.body).toString('base64');
|
597
|
+
const responseHeaders = splitSetCookieHeader(response.headers);
|
598
|
+
await catchDisallowedErrors(async () => {
|
599
|
+
await this._session.send('Fetch.fulfillRequest', {
|
600
|
+
requestId: this._interceptionId,
|
601
|
+
responseCode: response.status,
|
602
|
+
responsePhrase: network.statusText(response.status),
|
603
|
+
responseHeaders,
|
604
|
+
body
|
605
|
+
});
|
606
|
+
});
|
607
|
+
}
|
608
|
+
async abort(errorCode = 'failed') {
|
609
|
+
const errorReason = errorReasons[errorCode];
|
610
|
+
(0, _utils.assert)(errorReason, 'Unknown error code: ' + errorCode);
|
611
|
+
await catchDisallowedErrors(async () => {
|
612
|
+
await this._session.send('Fetch.failRequest', {
|
613
|
+
requestId: this._interceptionId,
|
614
|
+
errorReason
|
615
|
+
});
|
616
|
+
});
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
620
|
+
// In certain cases, protocol will return error if the request was already canceled
|
621
|
+
// or the page was closed. We should tolerate these errors but propagate other.
|
622
|
+
async function catchDisallowedErrors(callback) {
|
623
|
+
try {
|
624
|
+
return await callback();
|
625
|
+
} catch (e) {
|
626
|
+
if ((0, _protocolError.isProtocolError)(e) && e.message.includes('Invalid http status code or phrase')) throw e;
|
627
|
+
}
|
628
|
+
}
|
629
|
+
function splitSetCookieHeader(headers) {
|
630
|
+
const index = headers.findIndex(({
|
631
|
+
name
|
632
|
+
}) => name.toLowerCase() === 'set-cookie');
|
633
|
+
if (index === -1) return headers;
|
634
|
+
const header = headers[index];
|
635
|
+
const values = header.value.split('\n');
|
636
|
+
if (values.length === 1) return headers;
|
637
|
+
const result = headers.slice();
|
638
|
+
result.splice(index, 1, ...values.map(value => ({
|
639
|
+
name: header.name,
|
640
|
+
value
|
641
|
+
})));
|
642
|
+
return result;
|
643
|
+
}
|
644
|
+
const errorReasons = {
|
645
|
+
'aborted': 'Aborted',
|
646
|
+
'accessdenied': 'AccessDenied',
|
647
|
+
'addressunreachable': 'AddressUnreachable',
|
648
|
+
'blockedbyclient': 'BlockedByClient',
|
649
|
+
'blockedbyresponse': 'BlockedByResponse',
|
650
|
+
'connectionaborted': 'ConnectionAborted',
|
651
|
+
'connectionclosed': 'ConnectionClosed',
|
652
|
+
'connectionfailed': 'ConnectionFailed',
|
653
|
+
'connectionrefused': 'ConnectionRefused',
|
654
|
+
'connectionreset': 'ConnectionReset',
|
655
|
+
'internetdisconnected': 'InternetDisconnected',
|
656
|
+
'namenotresolved': 'NameNotResolved',
|
657
|
+
'timedout': 'TimedOut',
|
658
|
+
'failed': 'Failed'
|
659
|
+
};
|
660
|
+
// This class aligns responses with response headers from extra info:
|
661
|
+
// - Network.requestWillBeSent, Network.responseReceived, Network.loadingFinished/loadingFailed are
|
662
|
+
// dispatched using one channel.
|
663
|
+
// - Network.requestWillBeSentExtraInfo and Network.responseReceivedExtraInfo are dispatched on
|
664
|
+
// another channel. Those channels are not associated, so events come in random order.
|
665
|
+
//
|
666
|
+
// This class will associate responses with the new headers. These extra info headers will become
|
667
|
+
// available to client reliably upon requestfinished event only. It consumes CDP
|
668
|
+
// signals on one end and processResponse(network.Response) signals on the other hands. It then makes
|
669
|
+
// sure that responses have all the extra headers in place by the time request finishes.
|
670
|
+
//
|
671
|
+
// The shape of the instrumentation API is deliberately following the CDP, so that it
|
672
|
+
// is clear what is called when and what this means to the tracker without extra
|
673
|
+
// documentation.
|
674
|
+
class ResponseExtraInfoTracker {
|
675
|
+
constructor() {
|
676
|
+
this._requests = new Map();
|
677
|
+
}
|
678
|
+
requestWillBeSentExtraInfo(event) {
|
679
|
+
const info = this._getOrCreateEntry(event.requestId);
|
680
|
+
info.requestWillBeSentExtraInfo.push(event);
|
681
|
+
this._patchHeaders(info, info.requestWillBeSentExtraInfo.length - 1);
|
682
|
+
this._checkFinished(info);
|
683
|
+
}
|
684
|
+
requestServedFromCache(event) {
|
685
|
+
const info = this._getOrCreateEntry(event.requestId);
|
686
|
+
info.servedFromCache = true;
|
687
|
+
}
|
688
|
+
servedFromCache(requestId) {
|
689
|
+
const info = this._requests.get(requestId);
|
690
|
+
return !!(info !== null && info !== void 0 && info.servedFromCache);
|
691
|
+
}
|
692
|
+
responseReceivedExtraInfo(event) {
|
693
|
+
const info = this._getOrCreateEntry(event.requestId);
|
694
|
+
info.responseReceivedExtraInfo.push(event);
|
695
|
+
this._patchHeaders(info, info.responseReceivedExtraInfo.length - 1);
|
696
|
+
this._checkFinished(info);
|
697
|
+
}
|
698
|
+
processResponse(requestId, response, hasExtraInfo) {
|
699
|
+
var _info;
|
700
|
+
let info = this._requests.get(requestId);
|
701
|
+
// Cached responses have erroneous "hasExtraInfo" flag.
|
702
|
+
// https://bugs.chromium.org/p/chromium/issues/detail?id=1340398
|
703
|
+
if (!hasExtraInfo || (_info = info) !== null && _info !== void 0 && _info.servedFromCache) {
|
704
|
+
// Use "provisional" headers as "raw" ones.
|
705
|
+
response.request().setRawRequestHeaders(null);
|
706
|
+
response.setResponseHeadersSize(null);
|
707
|
+
response.setRawResponseHeaders(null);
|
708
|
+
return;
|
709
|
+
}
|
710
|
+
info = this._getOrCreateEntry(requestId);
|
711
|
+
info.responses.push(response);
|
712
|
+
this._patchHeaders(info, info.responses.length - 1);
|
713
|
+
}
|
714
|
+
loadingFinished(event) {
|
715
|
+
const info = this._requests.get(event.requestId);
|
716
|
+
if (!info) return;
|
717
|
+
info.loadingFinished = event;
|
718
|
+
this._checkFinished(info);
|
719
|
+
}
|
720
|
+
loadingFailed(event) {
|
721
|
+
const info = this._requests.get(event.requestId);
|
722
|
+
if (!info) return;
|
723
|
+
info.loadingFailed = event;
|
724
|
+
this._checkFinished(info);
|
725
|
+
}
|
726
|
+
_getOrCreateEntry(requestId) {
|
727
|
+
let info = this._requests.get(requestId);
|
728
|
+
if (!info) {
|
729
|
+
info = {
|
730
|
+
requestId: requestId,
|
731
|
+
requestWillBeSentExtraInfo: [],
|
732
|
+
responseReceivedExtraInfo: [],
|
733
|
+
responses: []
|
734
|
+
};
|
735
|
+
this._requests.set(requestId, info);
|
736
|
+
}
|
737
|
+
return info;
|
738
|
+
}
|
739
|
+
_patchHeaders(info, index) {
|
740
|
+
const response = info.responses[index];
|
741
|
+
const requestExtraInfo = info.requestWillBeSentExtraInfo[index];
|
742
|
+
if (response && requestExtraInfo) {
|
743
|
+
response.request().setRawRequestHeaders((0, _utils.headersObjectToArray)(requestExtraInfo.headers, '\n'));
|
744
|
+
info.requestWillBeSentExtraInfo[index] = undefined;
|
745
|
+
}
|
746
|
+
const responseExtraInfo = info.responseReceivedExtraInfo[index];
|
747
|
+
if (response && responseExtraInfo) {
|
748
|
+
var _responseExtraInfo$he;
|
749
|
+
response.setResponseHeadersSize(((_responseExtraInfo$he = responseExtraInfo.headersText) === null || _responseExtraInfo$he === void 0 ? void 0 : _responseExtraInfo$he.length) || 0);
|
750
|
+
response.setRawResponseHeaders((0, _utils.headersObjectToArray)(responseExtraInfo.headers, '\n'));
|
751
|
+
info.responseReceivedExtraInfo[index] = undefined;
|
752
|
+
}
|
753
|
+
}
|
754
|
+
_checkFinished(info) {
|
755
|
+
if (!info.loadingFinished && !info.loadingFailed) return;
|
756
|
+
if (info.responses.length <= info.responseReceivedExtraInfo.length) {
|
757
|
+
// We have extra info for each response.
|
758
|
+
this._stopTracking(info.requestId);
|
759
|
+
return;
|
760
|
+
}
|
761
|
+
|
762
|
+
// We are not done yet.
|
763
|
+
}
|
764
|
+
_stopTracking(requestId) {
|
765
|
+
this._requests.delete(requestId);
|
766
|
+
}
|
767
|
+
}
|