@xrkseek/harness 0.2.3 → 0.2.5
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/node_modules/@xrkseek/core-tools/dist/index.d.ts +1 -0
- package/node_modules/@xrkseek/core-tools/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/index.js +1 -0
- package/node_modules/@xrkseek/core-tools/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/settings-tools.d.ts +37 -0
- package/node_modules/@xrkseek/core-tools/dist/settings-tools.d.ts.map +1 -0
- package/node_modules/@xrkseek/core-tools/dist/settings-tools.js +161 -0
- package/node_modules/@xrkseek/core-tools/dist/settings-tools.js.map +1 -0
- package/node_modules/@xrkseek/core-tools/dist/std-tools.d.ts +4 -1
- package/node_modules/@xrkseek/core-tools/dist/std-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/std-tools.js +6 -1
- package/node_modules/@xrkseek/core-tools/dist/std-tools.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.d.ts +2 -2
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js +5 -6
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/read-image.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/read-image.js +20 -2
- package/node_modules/@xrkseek/exec-fs/dist/read-image.js.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts +5 -0
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.js +21 -8
- package/node_modules/@xrkseek/preset-harness/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-minimal/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-server/dist/preset.d.ts +1 -0
- package/node_modules/@xrkseek/preset-server/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-server/dist/preset.js +12 -2
- package/node_modules/@xrkseek/preset-server/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-server/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-server/package.json +1 -0
- package/node_modules/@xrkseek/server-config/dist/index.d.ts +6 -2
- package/node_modules/@xrkseek/server-config/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-config/dist/index.js +17 -4
- package/node_modules/@xrkseek/server-config/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-config/dist/mcp-servers.d.ts +12 -1
- package/node_modules/@xrkseek/server-config/dist/mcp-servers.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-config/dist/mcp-servers.js +56 -1
- package/node_modules/@xrkseek/server-config/dist/mcp-servers.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.js +17 -1
- package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/context.d.ts +8 -0
- package/node_modules/@xrkseek/server-face/dist/context.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/dispatch.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/dispatch.js +4 -1
- package/node_modules/@xrkseek/server-face/dist/dispatch.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/face-schema.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/face-schema.js +2 -0
- package/node_modules/@xrkseek/server-face/dist/face-schema.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/catalog.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/catalog.js +15 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/catalog.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/host.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/host.js +2 -0
- package/node_modules/@xrkseek/server-face/dist/handlers/host.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/remotes.d.ts +6 -0
- package/node_modules/@xrkseek/server-face/dist/handlers/remotes.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/remotes.js +89 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/remotes.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/session.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/session.js +19 -113
- package/node_modules/@xrkseek/server-face/dist/handlers/session.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.d.ts +3 -2
- package/node_modules/@xrkseek/server-face/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.js +3 -2
- package/node_modules/@xrkseek/server-face/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/plugin-inventory.d.ts +22 -3
- package/node_modules/@xrkseek/server-face/dist/plugin-inventory.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/plugin-inventory.js +117 -6
- package/node_modules/@xrkseek/server-face/dist/plugin-inventory.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/presets-catalog.d.ts +53 -6
- package/node_modules/@xrkseek/server-face/dist/presets-catalog.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/presets-catalog.js +100 -10
- package/node_modules/@xrkseek/server-face/dist/presets-catalog.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/runtime.d.ts +5 -0
- package/node_modules/@xrkseek/server-face/dist/runtime.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/runtime.js +5 -0
- package/node_modules/@xrkseek/server-face/dist/runtime.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/select-session-model.d.ts +15 -0
- package/node_modules/@xrkseek/server-face/dist/select-session-model.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/select-session-model.js +117 -0
- package/node_modules/@xrkseek/server-face/dist/select-session-model.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/settings-agent-tools.d.ts +7 -0
- package/node_modules/@xrkseek/server-face/dist/settings-agent-tools.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/settings-agent-tools.js +91 -0
- package/node_modules/@xrkseek/server-face/dist/settings-agent-tools.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.d.ts +7 -1
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.js +85 -26
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +2 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/slash.d.ts +8 -3
- package/node_modules/@xrkseek/server-face/dist/slash.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/slash.js +204 -21
- package/node_modules/@xrkseek/server-face/dist/slash.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts +7 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.js +27 -7
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/http-proxy.d.ts +11 -0
- package/node_modules/@xrkseek/server-host/dist/http-proxy.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-host/dist/http-proxy.js +42 -0
- package/node_modules/@xrkseek/server-host/dist/http-proxy.js.map +1 -0
- package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.js +33 -6
- package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/mcp-wire.d.ts +4 -3
- package/node_modules/@xrkseek/server-host/dist/mcp-wire.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/mcp-wire.js +14 -10
- package/node_modules/@xrkseek/server-host/dist/mcp-wire.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/standing-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/standing-tools.js +11 -4
- package/node_modules/@xrkseek/server-host/dist/standing-tools.js.map +1 -1
- package/node_modules/@xrkseek/server-host/package.json +57 -56
- package/node_modules/@xrkseek/server-http/dist/index.d.ts +1 -0
- package/node_modules/@xrkseek/server-http/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/index.js +1 -0
- package/node_modules/@xrkseek/server-http/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/sidebar/index.d.ts +7 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/sidebar/index.js.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/workspace/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/index.js +1 -1
- package/node_modules/@xrkseek/workspace/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/recipes.d.ts +2 -0
- package/node_modules/@xrkseek/workspace/dist/recipes.d.ts.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/recipes.js +9 -0
- package/node_modules/@xrkseek/workspace/dist/recipes.js.map +1 -1
- package/node_modules/undici/LICENSE +21 -0
- package/node_modules/undici/README.md +741 -0
- package/node_modules/undici/docs/docs/api/Agent.md +84 -0
- package/node_modules/undici/docs/docs/api/BalancedPool.md +99 -0
- package/node_modules/undici/docs/docs/api/CacheStorage.md +30 -0
- package/node_modules/undici/docs/docs/api/CacheStore.md +164 -0
- package/node_modules/undici/docs/docs/api/Client.md +288 -0
- package/node_modules/undici/docs/docs/api/ClientStats.md +27 -0
- package/node_modules/undici/docs/docs/api/Connector.md +115 -0
- package/node_modules/undici/docs/docs/api/ContentType.md +57 -0
- package/node_modules/undici/docs/docs/api/Cookies.md +128 -0
- package/node_modules/undici/docs/docs/api/Debug.md +62 -0
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +315 -0
- package/node_modules/undici/docs/docs/api/Dispatcher.md +1392 -0
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +159 -0
- package/node_modules/undici/docs/docs/api/Errors.md +49 -0
- package/node_modules/undici/docs/docs/api/EventSource.md +45 -0
- package/node_modules/undici/docs/docs/api/Fetch.md +60 -0
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +139 -0
- package/node_modules/undici/docs/docs/api/H2CClient.md +263 -0
- package/node_modules/undici/docs/docs/api/MockAgent.md +603 -0
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +197 -0
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +43 -0
- package/node_modules/undici/docs/docs/api/MockClient.md +81 -0
- package/node_modules/undici/docs/docs/api/MockErrors.md +12 -0
- package/node_modules/undici/docs/docs/api/MockPool.md +555 -0
- package/node_modules/undici/docs/docs/api/Pool.md +84 -0
- package/node_modules/undici/docs/docs/api/PoolStats.md +35 -0
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +229 -0
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +93 -0
- package/node_modules/undici/docs/docs/api/RetryAgent.md +50 -0
- package/node_modules/undici/docs/docs/api/RetryHandler.md +118 -0
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +145 -0
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +616 -0
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +275 -0
- package/node_modules/undici/docs/docs/api/Util.md +25 -0
- package/node_modules/undici/docs/docs/api/WebSocket.md +141 -0
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +91 -0
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +64 -0
- package/node_modules/undici/docs/docs/best-practices/crawling.md +58 -0
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +190 -0
- package/node_modules/undici/docs/docs/best-practices/proxy.md +127 -0
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +224 -0
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +63 -0
- package/node_modules/undici/index-fetch.js +65 -0
- package/node_modules/undici/index.d.ts +3 -0
- package/node_modules/undici/index.js +234 -0
- package/node_modules/undici/lib/api/abort-signal.js +59 -0
- package/node_modules/undici/lib/api/api-connect.js +110 -0
- package/node_modules/undici/lib/api/api-pipeline.js +252 -0
- package/node_modules/undici/lib/api/api-request.js +214 -0
- package/node_modules/undici/lib/api/api-stream.js +209 -0
- package/node_modules/undici/lib/api/api-upgrade.js +111 -0
- package/node_modules/undici/lib/api/index.js +7 -0
- package/node_modules/undici/lib/api/readable.js +580 -0
- package/node_modules/undici/lib/cache/memory-cache-store.js +279 -0
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +467 -0
- package/node_modules/undici/lib/core/connect.js +153 -0
- package/node_modules/undici/lib/core/constants.js +143 -0
- package/node_modules/undici/lib/core/diagnostics.js +227 -0
- package/node_modules/undici/lib/core/errors.js +477 -0
- package/node_modules/undici/lib/core/request.js +464 -0
- package/node_modules/undici/lib/core/socks5-client.js +422 -0
- package/node_modules/undici/lib/core/socks5-utils.js +212 -0
- package/node_modules/undici/lib/core/symbols.js +75 -0
- package/node_modules/undici/lib/core/tree.js +160 -0
- package/node_modules/undici/lib/core/util.js +992 -0
- package/node_modules/undici/lib/dispatcher/agent.js +158 -0
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +221 -0
- package/node_modules/undici/lib/dispatcher/client-h1.js +1739 -0
- package/node_modules/undici/lib/dispatcher/client-h2.js +1051 -0
- package/node_modules/undici/lib/dispatcher/client.js +668 -0
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +184 -0
- package/node_modules/undici/lib/dispatcher/dispatcher.js +48 -0
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +146 -0
- package/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
- package/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
- package/node_modules/undici/lib/dispatcher/pool-base.js +214 -0
- package/node_modules/undici/lib/dispatcher/pool.js +118 -0
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +319 -0
- package/node_modules/undici/lib/dispatcher/retry-agent.js +35 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +137 -0
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +260 -0
- package/node_modules/undici/lib/encoding/index.js +33 -0
- package/node_modules/undici/lib/global.js +59 -0
- package/node_modules/undici/lib/handler/cache-handler.js +776 -0
- package/node_modules/undici/lib/handler/cache-revalidation-handler.js +124 -0
- package/node_modules/undici/lib/handler/decorator-handler.js +67 -0
- package/node_modules/undici/lib/handler/deduplication-handler.js +460 -0
- package/node_modules/undici/lib/handler/redirect-handler.js +238 -0
- package/node_modules/undici/lib/handler/retry-handler.js +453 -0
- package/node_modules/undici/lib/handler/unwrap-handler.js +106 -0
- package/node_modules/undici/lib/handler/wrap-handler.js +105 -0
- package/node_modules/undici/lib/interceptor/cache.js +621 -0
- package/node_modules/undici/lib/interceptor/decompress.js +391 -0
- package/node_modules/undici/lib/interceptor/deduplicate.js +117 -0
- package/node_modules/undici/lib/interceptor/dns.js +571 -0
- package/node_modules/undici/lib/interceptor/dump.js +99 -0
- package/node_modules/undici/lib/interceptor/redirect.js +21 -0
- package/node_modules/undici/lib/interceptor/response-error.js +95 -0
- package/node_modules/undici/lib/interceptor/retry.js +19 -0
- package/node_modules/undici/lib/llhttp/.gitkeep +0 -0
- package/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
- package/node_modules/undici/lib/llhttp/constants.js +531 -0
- package/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
- package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
- package/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
- package/node_modules/undici/lib/llhttp/utils.js +12 -0
- package/node_modules/undici/lib/mock/mock-agent.js +232 -0
- package/node_modules/undici/lib/mock/mock-call-history.js +248 -0
- package/node_modules/undici/lib/mock/mock-client.js +68 -0
- package/node_modules/undici/lib/mock/mock-errors.js +29 -0
- package/node_modules/undici/lib/mock/mock-interceptor.js +209 -0
- package/node_modules/undici/lib/mock/mock-pool.js +68 -0
- package/node_modules/undici/lib/mock/mock-symbols.js +32 -0
- package/node_modules/undici/lib/mock/mock-utils.js +486 -0
- package/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
- package/node_modules/undici/lib/mock/snapshot-agent.js +353 -0
- package/node_modules/undici/lib/mock/snapshot-recorder.js +588 -0
- package/node_modules/undici/lib/mock/snapshot-utils.js +158 -0
- package/node_modules/undici/lib/util/cache.js +676 -0
- package/node_modules/undici/lib/util/date.js +670 -0
- package/node_modules/undici/lib/util/promise.js +28 -0
- package/node_modules/undici/lib/util/runtime-features.js +124 -0
- package/node_modules/undici/lib/util/stats.js +32 -0
- package/node_modules/undici/lib/util/timers.js +425 -0
- package/node_modules/undici/lib/web/cache/cache.js +864 -0
- package/node_modules/undici/lib/web/cache/cachestorage.js +152 -0
- package/node_modules/undici/lib/web/cache/util.js +45 -0
- package/node_modules/undici/lib/web/cookies/constants.js +12 -0
- package/node_modules/undici/lib/web/cookies/index.js +199 -0
- package/node_modules/undici/lib/web/cookies/parse.js +314 -0
- package/node_modules/undici/lib/web/cookies/util.js +352 -0
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +494 -0
- package/node_modules/undici/lib/web/eventsource/eventsource.js +501 -0
- package/node_modules/undici/lib/web/eventsource/util.js +29 -0
- package/node_modules/undici/lib/web/fetch/LICENSE +21 -0
- package/node_modules/undici/lib/web/fetch/body.js +509 -0
- package/node_modules/undici/lib/web/fetch/constants.js +131 -0
- package/node_modules/undici/lib/web/fetch/data-url.js +596 -0
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +586 -0
- package/node_modules/undici/lib/web/fetch/formdata.js +259 -0
- package/node_modules/undici/lib/web/fetch/global.js +40 -0
- package/node_modules/undici/lib/web/fetch/headers.js +719 -0
- package/node_modules/undici/lib/web/fetch/index.js +2413 -0
- package/node_modules/undici/lib/web/fetch/request.js +1115 -0
- package/node_modules/undici/lib/web/fetch/response.js +641 -0
- package/node_modules/undici/lib/web/fetch/util.js +1522 -0
- package/node_modules/undici/lib/web/infra/index.js +229 -0
- package/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
- package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
- package/node_modules/undici/lib/web/webidl/index.js +1006 -0
- package/node_modules/undici/lib/web/websocket/connection.js +329 -0
- package/node_modules/undici/lib/web/websocket/constants.js +126 -0
- package/node_modules/undici/lib/web/websocket/events.js +331 -0
- package/node_modules/undici/lib/web/websocket/frame.js +133 -0
- package/node_modules/undici/lib/web/websocket/permessage-deflate.js +105 -0
- package/node_modules/undici/lib/web/websocket/receiver.js +507 -0
- package/node_modules/undici/lib/web/websocket/sender.js +109 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +104 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +496 -0
- package/node_modules/undici/lib/web/websocket/util.js +347 -0
- package/node_modules/undici/lib/web/websocket/websocket.js +758 -0
- package/node_modules/undici/package.json +152 -0
- package/node_modules/undici/scripts/strip-comments.js +10 -0
- package/node_modules/undici/types/README.md +6 -0
- package/node_modules/undici/types/agent.d.ts +32 -0
- package/node_modules/undici/types/api.d.ts +43 -0
- package/node_modules/undici/types/balanced-pool.d.ts +30 -0
- package/node_modules/undici/types/cache-interceptor.d.ts +179 -0
- package/node_modules/undici/types/cache.d.ts +36 -0
- package/node_modules/undici/types/client-stats.d.ts +15 -0
- package/node_modules/undici/types/client.d.ts +139 -0
- package/node_modules/undici/types/connector.d.ts +36 -0
- package/node_modules/undici/types/content-type.d.ts +21 -0
- package/node_modules/undici/types/cookies.d.ts +30 -0
- package/node_modules/undici/types/diagnostics-channel.d.ts +74 -0
- package/node_modules/undici/types/dispatcher.d.ts +275 -0
- package/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
- package/node_modules/undici/types/errors.d.ts +177 -0
- package/node_modules/undici/types/eventsource.d.ts +66 -0
- package/node_modules/undici/types/fetch.d.ts +231 -0
- package/node_modules/undici/types/formdata.d.ts +114 -0
- package/node_modules/undici/types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici/types/global-origin.d.ts +7 -0
- package/node_modules/undici/types/h2c-client.d.ts +73 -0
- package/node_modules/undici/types/handlers.d.ts +14 -0
- package/node_modules/undici/types/header.d.ts +160 -0
- package/node_modules/undici/types/index.d.ts +91 -0
- package/node_modules/undici/types/interceptors.d.ts +82 -0
- package/node_modules/undici/types/mock-agent.d.ts +68 -0
- package/node_modules/undici/types/mock-call-history.d.ts +111 -0
- package/node_modules/undici/types/mock-client.d.ts +27 -0
- package/node_modules/undici/types/mock-errors.d.ts +12 -0
- package/node_modules/undici/types/mock-interceptor.d.ts +94 -0
- package/node_modules/undici/types/mock-pool.d.ts +27 -0
- package/node_modules/undici/types/patch.d.ts +29 -0
- package/node_modules/undici/types/pool-stats.d.ts +19 -0
- package/node_modules/undici/types/pool.d.ts +41 -0
- package/node_modules/undici/types/proxy-agent.d.ts +29 -0
- package/node_modules/undici/types/readable.d.ts +68 -0
- package/node_modules/undici/types/retry-agent.d.ts +8 -0
- package/node_modules/undici/types/retry-handler.d.ts +125 -0
- package/node_modules/undici/types/round-robin-pool.d.ts +41 -0
- package/node_modules/undici/types/snapshot-agent.d.ts +109 -0
- package/node_modules/undici/types/socks5-proxy-agent.d.ts +25 -0
- package/node_modules/undici/types/util.d.ts +18 -0
- package/node_modules/undici/types/utility.d.ts +7 -0
- package/node_modules/undici/types/webidl.d.ts +347 -0
- package/node_modules/undici/types/websocket.d.ts +188 -0
- package/package.json +3 -1
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
safeHTTPMethods,
|
|
5
|
+
pathHasQueryOrFragment,
|
|
6
|
+
hasSafeIterator,
|
|
7
|
+
isValidHTTPToken
|
|
8
|
+
} = require('../core/util')
|
|
9
|
+
|
|
10
|
+
const { serializePathWithQuery } = require('../core/util')
|
|
11
|
+
|
|
12
|
+
const MAX_DELTA_SECONDS = 2147483647
|
|
13
|
+
const RESTRICTIVE_DIRECTIVE_NAMES = ['no-store', 'private', 'no-cache']
|
|
14
|
+
const kInvalidCacheControlDirectives = Symbol('invalid cache-control directives')
|
|
15
|
+
|
|
16
|
+
function trimOWS (value) {
|
|
17
|
+
return value.replace(/^[\t ]+|[\t ]+$/g, '')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function arrayIncludes (array, value) {
|
|
21
|
+
for (let i = 0; i < array.length; i++) {
|
|
22
|
+
if (array[i] === value) {
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function trimOWSStart (value) {
|
|
31
|
+
return value.replace(/^[\t ]+/, '')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function trimOWSEnd (value) {
|
|
35
|
+
return value.replace(/[\t ]+$/, '')
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function findUnescapedQuote (value, start) {
|
|
39
|
+
let escaped = false
|
|
40
|
+
for (let i = start; i < value.length; i++) {
|
|
41
|
+
if (escaped) {
|
|
42
|
+
escaped = false
|
|
43
|
+
} else if (value[i] === '\\') {
|
|
44
|
+
escaped = true
|
|
45
|
+
} else if (value[i] === '"') {
|
|
46
|
+
return i
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return -1
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function splitCacheControlHeaderValue (value) {
|
|
54
|
+
const directives = []
|
|
55
|
+
let start = 0
|
|
56
|
+
let quoteStart = -1
|
|
57
|
+
let inQuote = false
|
|
58
|
+
let escaped = false
|
|
59
|
+
|
|
60
|
+
for (let i = 0; i < value.length; i++) {
|
|
61
|
+
if (inQuote) {
|
|
62
|
+
if (escaped) {
|
|
63
|
+
escaped = false
|
|
64
|
+
} else if (value[i] === '\\') {
|
|
65
|
+
escaped = true
|
|
66
|
+
} else if (value[i] === '"') {
|
|
67
|
+
inQuote = false
|
|
68
|
+
quoteStart = -1
|
|
69
|
+
}
|
|
70
|
+
} else if (value[i] === '"') {
|
|
71
|
+
inQuote = true
|
|
72
|
+
quoteStart = i
|
|
73
|
+
} else if (value[i] === ',') {
|
|
74
|
+
directives.push({ value: value.substring(start, i), fromMalformedQuote: false })
|
|
75
|
+
start = i + 1
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!inQuote) {
|
|
80
|
+
directives.push({ value: value.substring(start), fromMalformedQuote: false })
|
|
81
|
+
return directives
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const tail = value.substring(start)
|
|
85
|
+
const quoteOffset = quoteStart - start
|
|
86
|
+
let tailStart = 0
|
|
87
|
+
for (let i = 0; i < tail.length; i++) {
|
|
88
|
+
if (tail[i] === ',') {
|
|
89
|
+
directives.push({
|
|
90
|
+
value: tail.substring(tailStart, i),
|
|
91
|
+
fromMalformedQuote: tailStart > quoteOffset
|
|
92
|
+
})
|
|
93
|
+
tailStart = i + 1
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
directives.push({
|
|
98
|
+
value: tail.substring(tailStart),
|
|
99
|
+
fromMalformedQuote: tailStart > quoteOffset
|
|
100
|
+
})
|
|
101
|
+
return directives
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function markInvalidCacheControlDirective (directives, key) {
|
|
105
|
+
let invalidDirectives = directives[kInvalidCacheControlDirectives]
|
|
106
|
+
|
|
107
|
+
if (invalidDirectives === undefined) {
|
|
108
|
+
invalidDirectives = new Set()
|
|
109
|
+
Object.defineProperty(directives, kInvalidCacheControlDirectives, {
|
|
110
|
+
value: invalidDirectives
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
invalidDirectives.add(key)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function hasInvalidCacheControlDirective (directives, key) {
|
|
118
|
+
return directives[kInvalidCacheControlDirectives]?.has(key) === true
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function getMalformedRestrictiveDirectiveName (key) {
|
|
122
|
+
for (const directiveName of RESTRICTIVE_DIRECTIVE_NAMES) {
|
|
123
|
+
if (
|
|
124
|
+
key.startsWith(directiveName) &&
|
|
125
|
+
key.length > directiveName.length &&
|
|
126
|
+
!isValidHTTPToken(key[directiveName.length])
|
|
127
|
+
) {
|
|
128
|
+
return directiveName
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let tokenOnlyKey = ''
|
|
133
|
+
let hasInvalidTokenChar = false
|
|
134
|
+
for (let i = 0; i < key.length; i++) {
|
|
135
|
+
if (isValidHTTPToken(key[i])) {
|
|
136
|
+
tokenOnlyKey += key[i]
|
|
137
|
+
} else {
|
|
138
|
+
hasInvalidTokenChar = true
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (hasInvalidTokenChar && arrayIncludes(RESTRICTIVE_DIRECTIVE_NAMES, tokenOnlyKey)) {
|
|
143
|
+
return tokenOnlyKey
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @param {import('../../types/dispatcher.d.ts').default.DispatchOptions} opts
|
|
149
|
+
*/
|
|
150
|
+
function makeCacheKey (opts) {
|
|
151
|
+
if (!opts.origin) {
|
|
152
|
+
throw new Error('opts.origin is undefined')
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
let fullPath = opts.path || '/'
|
|
156
|
+
|
|
157
|
+
if (opts.query && !pathHasQueryOrFragment(fullPath)) {
|
|
158
|
+
fullPath = serializePathWithQuery(fullPath, opts.query)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
origin: opts.origin.toString(),
|
|
163
|
+
method: opts.method,
|
|
164
|
+
path: fullPath,
|
|
165
|
+
headers: opts.headers
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function appendHeader (headers, key, val) {
|
|
170
|
+
const headerName = key.toLowerCase()
|
|
171
|
+
const current = headers[headerName]
|
|
172
|
+
const values = Array.isArray(val) ? val : [val]
|
|
173
|
+
|
|
174
|
+
if (current === undefined) {
|
|
175
|
+
headers[headerName] = Array.isArray(val) ? val.slice() : val
|
|
176
|
+
} else if (Array.isArray(current)) {
|
|
177
|
+
current.push(...values)
|
|
178
|
+
} else {
|
|
179
|
+
headers[headerName] = [current, ...values]
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @param {Record<string, string[] | string>}
|
|
185
|
+
* @returns {Record<string, string[] | string>}
|
|
186
|
+
*/
|
|
187
|
+
function normalizeHeaders (opts) {
|
|
188
|
+
let headers
|
|
189
|
+
if (opts.headers == null) {
|
|
190
|
+
headers = {}
|
|
191
|
+
} else if (typeof opts.headers === 'object') {
|
|
192
|
+
headers = {}
|
|
193
|
+
|
|
194
|
+
if (hasSafeIterator(opts.headers)) {
|
|
195
|
+
for (const x of opts.headers) {
|
|
196
|
+
if (!Array.isArray(x)) {
|
|
197
|
+
throw new Error('opts.headers is not a valid header map')
|
|
198
|
+
}
|
|
199
|
+
const [key, val] = x
|
|
200
|
+
if (typeof key !== 'string' || typeof val !== 'string') {
|
|
201
|
+
throw new Error('opts.headers is not a valid header map')
|
|
202
|
+
}
|
|
203
|
+
appendHeader(headers, key, val)
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
for (const key of Object.keys(opts.headers)) {
|
|
207
|
+
appendHeader(headers, key, opts.headers[key])
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
throw new Error('opts.headers is not an object')
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return headers
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @param {any} key
|
|
219
|
+
*/
|
|
220
|
+
function assertCacheKey (key) {
|
|
221
|
+
if (typeof key !== 'object') {
|
|
222
|
+
throw new TypeError(`expected key to be object, got ${typeof key}`)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
for (const property of ['origin', 'method', 'path']) {
|
|
226
|
+
if (typeof key[property] !== 'string') {
|
|
227
|
+
throw new TypeError(`expected key.${property} to be string, got ${typeof key[property]}`)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (key.headers !== undefined && typeof key.headers !== 'object') {
|
|
232
|
+
throw new TypeError(`expected headers to be object, got ${typeof key}`)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @param {any} value
|
|
238
|
+
*/
|
|
239
|
+
function assertCacheValue (value) {
|
|
240
|
+
if (typeof value !== 'object') {
|
|
241
|
+
throw new TypeError(`expected value to be object, got ${typeof value}`)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
for (const property of ['statusCode', 'cachedAt', 'staleAt', 'deleteAt']) {
|
|
245
|
+
if (typeof value[property] !== 'number') {
|
|
246
|
+
throw new TypeError(`expected value.${property} to be number, got ${typeof value[property]}`)
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (typeof value.statusMessage !== 'string') {
|
|
251
|
+
throw new TypeError(`expected value.statusMessage to be string, got ${typeof value.statusMessage}`)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (value.headers != null && typeof value.headers !== 'object') {
|
|
255
|
+
throw new TypeError(`expected value.rawHeaders to be object, got ${typeof value.headers}`)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (value.vary !== undefined && typeof value.vary !== 'object') {
|
|
259
|
+
throw new TypeError(`expected value.vary to be object, got ${typeof value.vary}`)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (value.etag !== undefined && typeof value.etag !== 'string') {
|
|
263
|
+
throw new TypeError(`expected value.etag to be string, got ${typeof value.etag}`)
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @see https://www.rfc-editor.org/rfc/rfc9111.html#name-cache-control
|
|
269
|
+
* @see https://www.iana.org/assignments/http-cache-directives/http-cache-directives.xhtml
|
|
270
|
+
|
|
271
|
+
* @param {string | string[]} header
|
|
272
|
+
* @returns {import('../../types/cache-interceptor.d.ts').default.CacheControlDirectives}
|
|
273
|
+
*/
|
|
274
|
+
function parseCacheControlHeader (header) {
|
|
275
|
+
/**
|
|
276
|
+
* @type {import('../../types/cache-interceptor.d.ts').default.CacheControlDirectives}
|
|
277
|
+
*/
|
|
278
|
+
const output = {}
|
|
279
|
+
const invalidNumericDirectives = new Set()
|
|
280
|
+
const invalidNoArgumentDirectives = new Set()
|
|
281
|
+
|
|
282
|
+
const directives = splitCacheControlHeaderValue(Array.isArray(header) ? header.join(',') : header)
|
|
283
|
+
|
|
284
|
+
for (let i = 0; i < directives.length; i++) {
|
|
285
|
+
const directiveRecord = directives[i]
|
|
286
|
+
const directive = directiveRecord.value.toLowerCase()
|
|
287
|
+
const fromMalformedQuote = directiveRecord.fromMalformedQuote
|
|
288
|
+
const keyValueDelimiter = directive.indexOf('=')
|
|
289
|
+
|
|
290
|
+
let key
|
|
291
|
+
let value
|
|
292
|
+
let keyHasTrailingWhitespace = false
|
|
293
|
+
let valueHasLeadingWhitespace = false
|
|
294
|
+
if (keyValueDelimiter !== -1) {
|
|
295
|
+
const rawKey = directive.substring(0, keyValueDelimiter)
|
|
296
|
+
const rawValue = directive.substring(keyValueDelimiter + 1)
|
|
297
|
+
|
|
298
|
+
keyHasTrailingWhitespace = trimOWSEnd(rawKey) !== rawKey
|
|
299
|
+
valueHasLeadingWhitespace = trimOWSStart(rawValue) !== rawValue
|
|
300
|
+
key = trimOWS(rawKey)
|
|
301
|
+
value = trimOWSStart(rawValue)
|
|
302
|
+
} else {
|
|
303
|
+
key = trimOWS(directive)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const malformedRestrictiveDirectiveName = getMalformedRestrictiveDirectiveName(key)
|
|
307
|
+
if (malformedRestrictiveDirectiveName !== undefined) {
|
|
308
|
+
output[malformedRestrictiveDirectiveName] = true
|
|
309
|
+
continue
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
switch (key) {
|
|
313
|
+
case 'min-fresh':
|
|
314
|
+
case 'max-stale':
|
|
315
|
+
case 'max-age':
|
|
316
|
+
case 's-maxage':
|
|
317
|
+
case 'stale-while-revalidate':
|
|
318
|
+
case 'stale-if-error': {
|
|
319
|
+
if (fromMalformedQuote || invalidNumericDirectives.has(key)) {
|
|
320
|
+
continue
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (value === undefined || keyHasTrailingWhitespace || valueHasLeadingWhitespace) {
|
|
324
|
+
delete output[key]
|
|
325
|
+
invalidNumericDirectives.add(key)
|
|
326
|
+
markInvalidCacheControlDirective(output, key)
|
|
327
|
+
continue
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (
|
|
331
|
+
value.length >= 2 &&
|
|
332
|
+
value[0] === '"' &&
|
|
333
|
+
value[value.length - 1] === '"'
|
|
334
|
+
) {
|
|
335
|
+
value = value.substring(1, value.length - 1)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (!/^[0-9]+$/.test(value)) {
|
|
339
|
+
delete output[key]
|
|
340
|
+
invalidNumericDirectives.add(key)
|
|
341
|
+
markInvalidCacheControlDirective(output, key)
|
|
342
|
+
continue
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const parsedValue = Math.min(parseInt(value, 10), MAX_DELTA_SECONDS)
|
|
346
|
+
|
|
347
|
+
if (key === 'min-fresh') {
|
|
348
|
+
if (!(key in output) || output[key] < parsedValue) {
|
|
349
|
+
output[key] = parsedValue
|
|
350
|
+
}
|
|
351
|
+
} else if (!(key in output) || output[key] > parsedValue) {
|
|
352
|
+
output[key] = parsedValue
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
break
|
|
356
|
+
}
|
|
357
|
+
case 'private':
|
|
358
|
+
case 'no-cache': {
|
|
359
|
+
if (fromMalformedQuote) {
|
|
360
|
+
output[key] = true
|
|
361
|
+
break
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (value !== undefined && value.length === 0) {
|
|
365
|
+
output[key] = true
|
|
366
|
+
break
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (value) {
|
|
370
|
+
// The private and no-cache directives can be unqualified (aka just
|
|
371
|
+
// `private` or `no-cache`) or qualified (w/ a value). When they're
|
|
372
|
+
// qualified, it's a list of headers like `no-cache=header1`,
|
|
373
|
+
// `no-cache="header1"`, or `no-cache="header1, header2"`
|
|
374
|
+
// If we're given multiple headers, the comma messes us up since
|
|
375
|
+
// we split the full header by commas. So, let's loop through the
|
|
376
|
+
// remaining parts in front of us until we find one that contains a
|
|
377
|
+
// closing quote. We can then skip the consumed quoted-list fragments and
|
|
378
|
+
// continue parsing like normal.
|
|
379
|
+
// https://www.rfc-editor.org/rfc/rfc9111.html#name-no-cache-2
|
|
380
|
+
if (value[0] === '"') {
|
|
381
|
+
// Something like `no-cache="some-header"` OR `no-cache="some-header, another-header"`.
|
|
382
|
+
value = trimOWSEnd(value)
|
|
383
|
+
|
|
384
|
+
let fieldList = ''
|
|
385
|
+
let lastQuotedPart = i
|
|
386
|
+
let foundEndingQuote = false
|
|
387
|
+
const closingQuote = findUnescapedQuote(value, 1)
|
|
388
|
+
|
|
389
|
+
if (closingQuote !== -1) {
|
|
390
|
+
fieldList = value.substring(1, closingQuote)
|
|
391
|
+
foundEndingQuote = true
|
|
392
|
+
} else {
|
|
393
|
+
// Something like `no-cache="some-header, another-header"`
|
|
394
|
+
// This can still be something invalid, e.g. `no-cache="some-header, ...`
|
|
395
|
+
const fieldListParts = [value.substring(1)]
|
|
396
|
+
|
|
397
|
+
for (let j = i + 1; j < directives.length; j++) {
|
|
398
|
+
const nextPart = trimOWS(directives[j].value)
|
|
399
|
+
const closingQuote = findUnescapedQuote(nextPart, 0)
|
|
400
|
+
|
|
401
|
+
lastQuotedPart = j
|
|
402
|
+
|
|
403
|
+
if (closingQuote !== -1) {
|
|
404
|
+
fieldListParts.push(nextPart.substring(0, closingQuote))
|
|
405
|
+
foundEndingQuote = true
|
|
406
|
+
break
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
fieldListParts.push(nextPart)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
fieldList = fieldListParts.join(',')
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
if (!foundEndingQuote) {
|
|
416
|
+
output[key] = true
|
|
417
|
+
break
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
i = lastQuotedPart
|
|
421
|
+
|
|
422
|
+
const headers = fieldList.split(',')
|
|
423
|
+
let validFieldNames = true
|
|
424
|
+
for (let j = 0; j < headers.length; j++) {
|
|
425
|
+
headers[j] = trimOWS(headers[j])
|
|
426
|
+
if (!isValidHTTPToken(headers[j])) {
|
|
427
|
+
validFieldNames = false
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
if (!validFieldNames) {
|
|
432
|
+
output[key] = true
|
|
433
|
+
} else if (output[key] !== true) {
|
|
434
|
+
if (key in output) {
|
|
435
|
+
output[key] = output[key].concat(headers)
|
|
436
|
+
} else {
|
|
437
|
+
output[key] = headers
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
} else {
|
|
441
|
+
// Something like `no-cache=some-header`
|
|
442
|
+
const fieldName = trimOWS(value)
|
|
443
|
+
|
|
444
|
+
if (!isValidHTTPToken(fieldName)) {
|
|
445
|
+
output[key] = true
|
|
446
|
+
} else if (output[key] !== true) {
|
|
447
|
+
if (key in output) {
|
|
448
|
+
output[key] = output[key].concat(fieldName)
|
|
449
|
+
} else {
|
|
450
|
+
output[key] = [fieldName]
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
break
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
// eslint-disable-next-line no-fallthrough
|
|
459
|
+
case 'public':
|
|
460
|
+
case 'must-revalidate':
|
|
461
|
+
case 'proxy-revalidate':
|
|
462
|
+
case 'immutable':
|
|
463
|
+
case 'no-transform':
|
|
464
|
+
case 'must-understand':
|
|
465
|
+
case 'only-if-cached':
|
|
466
|
+
if (fromMalformedQuote || invalidNoArgumentDirectives.has(key)) {
|
|
467
|
+
continue
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (value !== undefined) {
|
|
471
|
+
// These are qualified (something like `public=...`) when they aren't
|
|
472
|
+
// allowed to be, skip all instances of the malformed directive.
|
|
473
|
+
delete output[key]
|
|
474
|
+
invalidNoArgumentDirectives.add(key)
|
|
475
|
+
continue
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
output[key] = true
|
|
479
|
+
break
|
|
480
|
+
case 'no-store':
|
|
481
|
+
output[key] = true
|
|
482
|
+
break
|
|
483
|
+
default:
|
|
484
|
+
// Ignore unknown directives as per https://www.rfc-editor.org/rfc/rfc9111.html#section-5.2.3-1
|
|
485
|
+
continue
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
return output
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* @param {string | string[]} varyHeader Vary header from the server
|
|
494
|
+
* @returns {string[]}
|
|
495
|
+
*/
|
|
496
|
+
function splitVaryHeader (varyHeader) {
|
|
497
|
+
const values = Array.isArray(varyHeader) ? varyHeader : [varyHeader]
|
|
498
|
+
const output = []
|
|
499
|
+
|
|
500
|
+
for (let i = 0; i < values.length; i++) {
|
|
501
|
+
const parts = values[i].split(',')
|
|
502
|
+
for (let j = 0; j < parts.length; j++) {
|
|
503
|
+
output.push(parts[j])
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
return output
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* @param {string | string[]} varyHeader Vary header from the server
|
|
512
|
+
* @returns {boolean}
|
|
513
|
+
*/
|
|
514
|
+
function hasVaryStar (varyHeader) {
|
|
515
|
+
const values = splitVaryHeader(varyHeader)
|
|
516
|
+
for (let i = 0; i < values.length; i++) {
|
|
517
|
+
if (trimOWS(values[i]).indexOf('*') !== -1) {
|
|
518
|
+
return true
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
return false
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* @param {string | string[]} varyHeader Vary header from the server
|
|
527
|
+
* @param {Record<string, string | string[]>} headers Request headers
|
|
528
|
+
* @returns {Record<string, string | string[] | null> | undefined}
|
|
529
|
+
*/
|
|
530
|
+
function parseVaryHeader (varyHeader, headers) {
|
|
531
|
+
if (hasVaryStar(varyHeader)) {
|
|
532
|
+
return headers
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const output = /** @type {Record<string, string | string[] | null>} */ ({})
|
|
536
|
+
|
|
537
|
+
const varyingHeaders = splitVaryHeader(varyHeader)
|
|
538
|
+
|
|
539
|
+
for (const header of varyingHeaders) {
|
|
540
|
+
const trimmedHeader = trimOWS(header).toLowerCase()
|
|
541
|
+
|
|
542
|
+
if (trimmedHeader.length === 0) {
|
|
543
|
+
continue
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (!isValidHTTPToken(trimmedHeader)) {
|
|
547
|
+
return undefined
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
const headerValue = headers[trimmedHeader]
|
|
551
|
+
output[trimmedHeader] = Array.isArray(headerValue) ? headerValue.slice() : headerValue ?? null
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return output
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* @param {string | string[]} varyHeader Vary header from the server
|
|
559
|
+
* @returns {boolean}
|
|
560
|
+
*/
|
|
561
|
+
function isInvalidOrWildcardVaryHeader (varyHeader) {
|
|
562
|
+
return hasVaryStar(varyHeader) || parseVaryHeader(varyHeader, {}) === undefined
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Note: this deviates from the spec a little. Empty etags ("", W/"") are valid,
|
|
567
|
+
* however, including them in cached resposnes serves little to no purpose.
|
|
568
|
+
*
|
|
569
|
+
* @see https://www.rfc-editor.org/rfc/rfc9110.html#name-etag
|
|
570
|
+
*
|
|
571
|
+
* @param {string} etag
|
|
572
|
+
* @returns {boolean}
|
|
573
|
+
*/
|
|
574
|
+
function isEtagUsable (etag) {
|
|
575
|
+
if (etag.length <= 2) {
|
|
576
|
+
// Shortest an etag can be is two chars (just ""). This is where we deviate
|
|
577
|
+
// from the spec requiring a min of 3 chars however
|
|
578
|
+
return false
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (etag[0] === '"' && etag[etag.length - 1] === '"') {
|
|
582
|
+
// ETag: ""asd123"" or ETag: "W/"asd123"", kinda undefined behavior in the
|
|
583
|
+
// spec. Some servers will accept these while others don't.
|
|
584
|
+
// ETag: "asd123"
|
|
585
|
+
return !(etag[1] === '"' || etag.startsWith('"W/'))
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
if (etag.startsWith('W/"') && etag[etag.length - 1] === '"') {
|
|
589
|
+
// ETag: W/"", also where we deviate from the spec & require a min of 3
|
|
590
|
+
// chars
|
|
591
|
+
// ETag: for W/"", W/"asd123"
|
|
592
|
+
return etag.length !== 4
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// Anything else
|
|
596
|
+
return false
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* @param {unknown} store
|
|
601
|
+
* @returns {asserts store is import('../../types/cache-interceptor.d.ts').default.CacheStore}
|
|
602
|
+
*/
|
|
603
|
+
function assertCacheStore (store, name = 'CacheStore') {
|
|
604
|
+
if (typeof store !== 'object' || store === null) {
|
|
605
|
+
throw new TypeError(`expected type of ${name} to be a CacheStore, got ${store === null ? 'null' : typeof store}`)
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
for (const fn of ['get', 'createWriteStream', 'delete']) {
|
|
609
|
+
if (typeof store[fn] !== 'function') {
|
|
610
|
+
throw new TypeError(`${name} needs to have a \`${fn}()\` function`)
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* @param {unknown} methods
|
|
616
|
+
* @returns {asserts methods is import('../../types/cache-interceptor.d.ts').default.CacheMethods[]}
|
|
617
|
+
*/
|
|
618
|
+
function assertCacheMethods (methods, name = 'CacheMethods') {
|
|
619
|
+
if (!Array.isArray(methods)) {
|
|
620
|
+
throw new TypeError(`expected type of ${name} needs to be an array, got ${methods === null ? 'null' : typeof methods}`)
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
if (methods.length === 0) {
|
|
624
|
+
throw new TypeError(`${name} needs to have at least one method`)
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
for (const method of methods) {
|
|
628
|
+
if (!arrayIncludes(safeHTTPMethods, method)) {
|
|
629
|
+
throw new TypeError(`element of ${name}-array needs to be one of following values: ${safeHTTPMethods.join(', ')}, got ${method}`)
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Creates a string key for request deduplication purposes.
|
|
636
|
+
* This key is used to identify in-flight requests that can be shared.
|
|
637
|
+
* @param {import('../../types/cache-interceptor.d.ts').default.CacheKey} cacheKey
|
|
638
|
+
* @param {Set<string>} [excludeHeaders] Set of lowercase header names to exclude from the key
|
|
639
|
+
* @returns {string}
|
|
640
|
+
*/
|
|
641
|
+
function makeDeduplicationKey (cacheKey, excludeHeaders) {
|
|
642
|
+
// Use JSON.stringify to produce a collision-resistant key.
|
|
643
|
+
// Previous format used `:` and `=` delimiters without escaping, which
|
|
644
|
+
// allowed different header sets to produce identical keys (e.g.
|
|
645
|
+
// {a:"x:b=y"} vs {a:"x", b:"y"}). See: https://github.com/nodejs/undici/issues/5012
|
|
646
|
+
const headers = {}
|
|
647
|
+
|
|
648
|
+
if (cacheKey.headers) {
|
|
649
|
+
const sortedHeaders = Object.keys(cacheKey.headers).sort()
|
|
650
|
+
for (const header of sortedHeaders) {
|
|
651
|
+
// Skip excluded headers
|
|
652
|
+
if (excludeHeaders?.has(header.toLowerCase())) {
|
|
653
|
+
continue
|
|
654
|
+
}
|
|
655
|
+
headers[header] = cacheKey.headers[header]
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
return JSON.stringify([cacheKey.origin, cacheKey.method, cacheKey.path, headers])
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
module.exports = {
|
|
663
|
+
makeCacheKey,
|
|
664
|
+
normalizeHeaders,
|
|
665
|
+
assertCacheKey,
|
|
666
|
+
assertCacheValue,
|
|
667
|
+
parseCacheControlHeader,
|
|
668
|
+
hasInvalidCacheControlDirective,
|
|
669
|
+
parseVaryHeader,
|
|
670
|
+
hasVaryStar,
|
|
671
|
+
isInvalidOrWildcardVaryHeader,
|
|
672
|
+
isEtagUsable,
|
|
673
|
+
assertCacheMethods,
|
|
674
|
+
assertCacheStore,
|
|
675
|
+
makeDeduplicationKey
|
|
676
|
+
}
|