recker 1.0.20 → 1.0.21-next.b21cd45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/ai/adaptive-timeout.d.ts +0 -1
- package/dist/ai/client.d.ts +0 -1
- package/dist/ai/client.js +6 -0
- package/dist/ai/index.d.ts +3 -1
- package/dist/ai/index.js +3 -0
- package/dist/ai/providers/anthropic.d.ts +0 -1
- package/dist/ai/providers/base.d.ts +0 -1
- package/dist/ai/providers/google.d.ts +59 -0
- package/dist/ai/providers/google.js +305 -0
- package/dist/ai/providers/index.d.ts +4 -1
- package/dist/ai/providers/index.js +2 -0
- package/dist/ai/providers/ollama.d.ts +44 -0
- package/dist/ai/providers/ollama.js +240 -0
- package/dist/ai/providers/openai.d.ts +0 -1
- package/dist/ai/rate-limiter.d.ts +0 -1
- package/dist/ai/vector/index.d.ts +2 -0
- package/dist/ai/vector/index.js +2 -0
- package/dist/ai/vector/similarity.d.ts +2 -0
- package/dist/ai/vector/similarity.js +27 -0
- package/dist/ai/vector/store.d.ts +27 -0
- package/dist/ai/vector/store.js +82 -0
- package/dist/bare.d.ts +22 -0
- package/dist/bare.js +91 -0
- package/dist/bench/generator.d.ts +0 -1
- package/dist/bench/stats.d.ts +0 -1
- package/dist/cache/basic-file-storage.d.ts +12 -0
- package/dist/cache/basic-file-storage.js +50 -0
- package/dist/cache/file-storage.d.ts +25 -11
- package/dist/cache/file-storage.js +175 -30
- package/dist/cache/memory-limits.d.ts +0 -1
- package/dist/cache/memory-storage.d.ts +0 -1
- package/dist/cache/redis-storage.d.ts +0 -1
- package/dist/cli/handler.d.ts +2 -1
- package/dist/cli/handler.js +36 -5
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +559 -6
- package/dist/cli/presets.d.ts +0 -1
- package/dist/cli/tui/ai-chat.d.ts +0 -1
- package/dist/cli/tui/load-dashboard.d.ts +0 -1
- package/dist/cli/tui/scroll-buffer.d.ts +0 -1
- package/dist/cli/tui/search-panel.d.ts +0 -1
- package/dist/cli/tui/shell-search.d.ts +0 -1
- package/dist/cli/tui/shell.d.ts +0 -1
- package/dist/cli/tui/shell.js +1 -1
- package/dist/cli/tui/websocket.d.ts +0 -1
- package/dist/constants/http-status.d.ts +0 -1
- package/dist/constants.d.ts +0 -1
- package/dist/contract/index.d.ts +0 -1
- package/dist/cookies/memory-cookie-jar.d.ts +0 -1
- package/dist/core/client.d.ts +2 -1
- package/dist/core/client.js +11 -7
- package/dist/core/errors.d.ts +0 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/request-promise.d.ts +0 -1
- package/dist/core/request.d.ts +0 -1
- package/dist/core/response.d.ts +0 -1
- package/dist/dns/index.d.ts +0 -1
- package/dist/dns/propagation.d.ts +0 -1
- package/dist/events/request-events.d.ts +0 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -0
- package/dist/mcp/cli.d.ts +2 -0
- package/dist/mcp/cli.js +136 -0
- package/dist/mcp/client.d.ts +0 -1
- package/dist/mcp/contract.d.ts +0 -1
- package/dist/mcp/embeddings-loader.d.ts +0 -1
- package/dist/mcp/geoip-loader.d.ts +0 -1
- package/dist/mcp/index.d.ts +0 -1
- package/dist/mcp/ip-intel.d.ts +0 -1
- package/dist/mcp/search/hybrid-search.d.ts +0 -1
- package/dist/mcp/search/index.d.ts +0 -1
- package/dist/mcp/search/math.d.ts +0 -1
- package/dist/mcp/search/types.d.ts +0 -1
- package/dist/mcp/server.d.ts +6 -2
- package/dist/mcp/server.js +193 -151
- package/dist/mcp/tools/loader.d.ts +2 -0
- package/dist/mcp/tools/loader.js +41 -0
- package/dist/mcp/tools/network.d.ts +3 -0
- package/dist/mcp/tools/network.js +267 -0
- package/dist/mcp/tools/registry.d.ts +17 -0
- package/dist/mcp/tools/registry.js +37 -0
- package/dist/mcp/types.d.ts +0 -1
- package/dist/plugins/auth/api-key.d.ts +8 -0
- package/dist/plugins/auth/api-key.js +27 -0
- package/dist/plugins/auth/auth0.d.ts +33 -0
- package/dist/plugins/auth/auth0.js +94 -0
- package/dist/plugins/auth/aws-sigv4.d.ts +10 -0
- package/dist/plugins/auth/aws-sigv4.js +88 -0
- package/dist/plugins/auth/azure-ad.d.ts +48 -0
- package/dist/plugins/auth/azure-ad.js +152 -0
- package/dist/plugins/auth/basic.d.ts +7 -0
- package/dist/plugins/auth/basic.js +13 -0
- package/dist/plugins/auth/bearer.d.ts +8 -0
- package/dist/plugins/auth/bearer.js +17 -0
- package/dist/plugins/auth/cognito.d.ts +45 -0
- package/dist/plugins/auth/cognito.js +208 -0
- package/dist/plugins/auth/digest.d.ts +8 -0
- package/dist/plugins/auth/digest.js +100 -0
- package/dist/plugins/auth/firebase.d.ts +32 -0
- package/dist/plugins/auth/firebase.js +195 -0
- package/dist/plugins/auth/github-app.d.ts +36 -0
- package/dist/plugins/auth/github-app.js +170 -0
- package/dist/plugins/auth/google-service-account.d.ts +49 -0
- package/dist/plugins/auth/google-service-account.js +172 -0
- package/dist/plugins/auth/index.d.ts +15 -0
- package/dist/plugins/auth/index.js +15 -0
- package/dist/plugins/auth/mtls.d.ts +37 -0
- package/dist/plugins/auth/mtls.js +140 -0
- package/dist/plugins/auth/oauth2.d.ts +8 -0
- package/dist/plugins/auth/oauth2.js +26 -0
- package/dist/plugins/auth/oidc.d.ts +55 -0
- package/dist/plugins/auth/oidc.js +222 -0
- package/dist/plugins/auth/okta.d.ts +47 -0
- package/dist/plugins/auth/okta.js +157 -0
- package/dist/plugins/auth.d.ts +1 -45
- package/dist/plugins/auth.js +1 -268
- package/dist/plugins/cache.d.ts +1 -2
- package/dist/plugins/cache.js +2 -2
- package/dist/plugins/certificate-pinning.d.ts +59 -0
- package/dist/plugins/certificate-pinning.js +236 -0
- package/dist/plugins/circuit-breaker.d.ts +1 -2
- package/dist/plugins/circuit-breaker.js +1 -1
- package/dist/plugins/compression.d.ts +0 -1
- package/dist/plugins/cookie-jar.d.ts +1 -2
- package/dist/plugins/cookie-jar.js +1 -1
- package/dist/plugins/dedup.d.ts +1 -2
- package/dist/plugins/dedup.js +1 -1
- package/dist/plugins/graphql.d.ts +0 -1
- package/dist/plugins/grpc-web.d.ts +0 -1
- package/dist/plugins/har-player.d.ts +1 -2
- package/dist/plugins/har-player.js +1 -1
- package/dist/plugins/har-recorder.d.ts +1 -2
- package/dist/plugins/har-recorder.js +1 -1
- package/dist/plugins/hls.d.ts +90 -18
- package/dist/plugins/hls.js +343 -173
- package/dist/plugins/http2-push.d.ts +0 -1
- package/dist/plugins/http3.d.ts +0 -1
- package/dist/plugins/index.d.ts +27 -0
- package/dist/plugins/index.js +27 -0
- package/dist/plugins/interface-rotator.d.ts +1 -2
- package/dist/plugins/interface-rotator.js +1 -1
- package/dist/plugins/jsonrpc.d.ts +0 -1
- package/dist/plugins/logger.d.ts +1 -2
- package/dist/plugins/logger.js +1 -1
- package/dist/plugins/odata.d.ts +0 -1
- package/dist/plugins/pagination.d.ts +0 -1
- package/dist/plugins/proxy-rotator.d.ts +1 -2
- package/dist/plugins/proxy-rotator.js +1 -1
- package/dist/plugins/rate-limit.d.ts +15 -0
- package/dist/plugins/rate-limit.js +162 -0
- package/dist/plugins/retry.d.ts +1 -2
- package/dist/plugins/retry.js +3 -3
- package/dist/plugins/scrape.d.ts +0 -1
- package/dist/plugins/server-timing.d.ts +1 -2
- package/dist/plugins/server-timing.js +1 -1
- package/dist/plugins/soap.d.ts +0 -1
- package/dist/plugins/user-agent.d.ts +1 -2
- package/dist/plugins/user-agent.js +1 -1
- package/dist/plugins/xml.d.ts +0 -1
- package/dist/plugins/xsrf.d.ts +1 -2
- package/dist/plugins/xsrf.js +3 -3
- package/dist/presets/anthropic.d.ts +0 -1
- package/dist/presets/aws.d.ts +0 -1
- package/dist/presets/azure-openai.d.ts +0 -1
- package/dist/presets/azure.d.ts +0 -1
- package/dist/presets/cloudflare.d.ts +0 -1
- package/dist/presets/cohere.d.ts +0 -1
- package/dist/presets/deepseek.d.ts +0 -1
- package/dist/presets/digitalocean.d.ts +0 -1
- package/dist/presets/discord.d.ts +0 -1
- package/dist/presets/fireworks.d.ts +0 -1
- package/dist/presets/gcp.d.ts +0 -1
- package/dist/presets/gemini.d.ts +0 -1
- package/dist/presets/github.d.ts +0 -1
- package/dist/presets/gitlab.d.ts +0 -1
- package/dist/presets/groq.d.ts +0 -1
- package/dist/presets/huggingface.d.ts +0 -1
- package/dist/presets/index.d.ts +0 -1
- package/dist/presets/linear.d.ts +0 -1
- package/dist/presets/mailgun.d.ts +0 -1
- package/dist/presets/meta.d.ts +0 -1
- package/dist/presets/mistral.d.ts +0 -1
- package/dist/presets/notion.d.ts +0 -1
- package/dist/presets/openai.d.ts +0 -1
- package/dist/presets/oracle.d.ts +0 -1
- package/dist/presets/perplexity.d.ts +0 -1
- package/dist/presets/registry.d.ts +0 -1
- package/dist/presets/replicate.d.ts +0 -1
- package/dist/presets/sinch.d.ts +0 -1
- package/dist/presets/slack.d.ts +0 -1
- package/dist/presets/stripe.d.ts +0 -1
- package/dist/presets/supabase.d.ts +0 -1
- package/dist/presets/tiktok.d.ts +0 -1
- package/dist/presets/together.d.ts +0 -1
- package/dist/presets/twilio.d.ts +0 -1
- package/dist/presets/vercel.d.ts +0 -1
- package/dist/presets/vultr.d.ts +0 -1
- package/dist/presets/xai.d.ts +0 -1
- package/dist/presets/youtube.d.ts +0 -1
- package/dist/protocols/ftp.d.ts +0 -1
- package/dist/protocols/index.d.ts +0 -1
- package/dist/protocols/sftp.d.ts +0 -1
- package/dist/protocols/telnet.d.ts +0 -1
- package/dist/recker.d.ts +0 -1
- package/dist/runner/request-runner.d.ts +0 -1
- package/dist/scrape/document.d.ts +0 -1
- package/dist/scrape/element.d.ts +0 -1
- package/dist/scrape/extractors.d.ts +0 -1
- package/dist/scrape/index.d.ts +0 -1
- package/dist/scrape/types.d.ts +0 -1
- package/dist/testing/index.d.ts +16 -1
- package/dist/testing/index.js +8 -0
- package/dist/testing/mock-dns-server.d.ts +69 -0
- package/dist/testing/mock-dns-server.js +269 -0
- package/dist/testing/mock-ftp-server.d.ts +89 -0
- package/dist/testing/mock-ftp-server.js +562 -0
- package/dist/testing/mock-hls-server.d.ts +80 -0
- package/dist/testing/mock-hls-server.js +381 -0
- package/dist/testing/mock-http-server.d.ts +99 -0
- package/dist/testing/mock-http-server.js +298 -0
- package/dist/testing/mock-sse-server.d.ts +76 -0
- package/dist/testing/mock-sse-server.js +291 -0
- package/dist/testing/mock-telnet-server.d.ts +59 -0
- package/dist/testing/mock-telnet-server.js +273 -0
- package/dist/testing/mock-udp-server.d.ts +0 -1
- package/dist/testing/mock-websocket-server.d.ts +77 -0
- package/dist/testing/mock-websocket-server.js +316 -0
- package/dist/testing/mock-whois-server.d.ts +56 -0
- package/dist/testing/mock-whois-server.js +234 -0
- package/dist/testing/mock.d.ts +0 -1
- package/dist/transport/base-udp.d.ts +0 -1
- package/dist/transport/fetch.d.ts +0 -1
- package/dist/transport/udp-response.d.ts +0 -1
- package/dist/transport/udp.d.ts +0 -1
- package/dist/transport/undici.d.ts +0 -1
- package/dist/transport/undici.js +1 -1
- package/dist/types/ai.d.ts +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/logger.d.ts +0 -1
- package/dist/types/udp.d.ts +0 -1
- package/dist/udp/index.d.ts +0 -1
- package/dist/utils/agent-manager.d.ts +0 -1
- package/dist/utils/body.d.ts +0 -1
- package/dist/utils/cert.d.ts +0 -1
- package/dist/utils/charset.d.ts +0 -1
- package/dist/utils/chart.d.ts +0 -1
- package/dist/utils/client-pool.d.ts +0 -1
- package/dist/utils/colors.d.ts +0 -1
- package/dist/utils/concurrency.d.ts +0 -1
- package/dist/utils/dns-toolkit.d.ts +0 -1
- package/dist/utils/dns-toolkit.js +1 -1
- package/dist/utils/dns.d.ts +0 -1
- package/dist/utils/dns.js +2 -2
- package/dist/utils/doh.d.ts +0 -1
- package/dist/utils/download.d.ts +0 -1
- package/dist/utils/env-proxy.d.ts +0 -1
- package/dist/utils/header-parser.d.ts +0 -1
- package/dist/utils/html-cleaner.d.ts +0 -1
- package/dist/utils/link-header.d.ts +0 -1
- package/dist/utils/optional-require.d.ts +0 -1
- package/dist/utils/optional-require.js +1 -1
- package/dist/utils/progress.d.ts +0 -1
- package/dist/utils/rdap.d.ts +0 -1
- package/dist/utils/request-pool.d.ts +0 -1
- package/dist/utils/security-grader.d.ts +0 -1
- package/dist/utils/sparkline.d.ts +0 -1
- package/dist/utils/sse.d.ts +0 -1
- package/dist/utils/streaming.d.ts +0 -1
- package/dist/utils/system-metrics.d.ts +0 -1
- package/dist/utils/tls-inspector.d.ts +0 -1
- package/dist/utils/try-fn.d.ts +0 -1
- package/dist/utils/upload.d.ts +0 -1
- package/dist/utils/user-agent.d.ts +0 -1
- package/dist/utils/whois.d.ts +0 -1
- package/dist/webrtc/index.d.ts +0 -1
- package/dist/webrtc/index.js +1 -1
- package/dist/websocket/client.d.ts +0 -1
- package/package.json +35 -3
- package/dist/ai/adaptive-timeout.d.ts.map +0 -1
- package/dist/ai/client.d.ts.map +0 -1
- package/dist/ai/index.d.ts.map +0 -1
- package/dist/ai/providers/anthropic.d.ts.map +0 -1
- package/dist/ai/providers/base.d.ts.map +0 -1
- package/dist/ai/providers/index.d.ts.map +0 -1
- package/dist/ai/providers/openai.d.ts.map +0 -1
- package/dist/ai/rate-limiter.d.ts.map +0 -1
- package/dist/bench/generator.d.ts.map +0 -1
- package/dist/bench/stats.d.ts.map +0 -1
- package/dist/cache/file-storage.d.ts.map +0 -1
- package/dist/cache/memory-limits.d.ts.map +0 -1
- package/dist/cache/memory-storage.d.ts.map +0 -1
- package/dist/cache/redis-storage.d.ts.map +0 -1
- package/dist/cli/handler.d.ts.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/presets.d.ts.map +0 -1
- package/dist/cli/tui/ai-chat.d.ts.map +0 -1
- package/dist/cli/tui/load-dashboard.d.ts.map +0 -1
- package/dist/cli/tui/scroll-buffer.d.ts.map +0 -1
- package/dist/cli/tui/search-panel.d.ts.map +0 -1
- package/dist/cli/tui/shell-search.d.ts.map +0 -1
- package/dist/cli/tui/shell.d.ts.map +0 -1
- package/dist/cli/tui/websocket.d.ts.map +0 -1
- package/dist/constants/http-status.d.ts.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/contract/index.d.ts.map +0 -1
- package/dist/cookies/memory-cookie-jar.d.ts.map +0 -1
- package/dist/core/client.d.ts.map +0 -1
- package/dist/core/errors.d.ts.map +0 -1
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/request-promise.d.ts.map +0 -1
- package/dist/core/request.d.ts.map +0 -1
- package/dist/core/response.d.ts.map +0 -1
- package/dist/dns/index.d.ts.map +0 -1
- package/dist/dns/propagation.d.ts.map +0 -1
- package/dist/events/request-events.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/mcp/client.d.ts.map +0 -1
- package/dist/mcp/contract.d.ts.map +0 -1
- package/dist/mcp/embeddings-loader.d.ts.map +0 -1
- package/dist/mcp/geoip-loader.d.ts.map +0 -1
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/ip-intel.d.ts.map +0 -1
- package/dist/mcp/search/hybrid-search.d.ts.map +0 -1
- package/dist/mcp/search/index.d.ts.map +0 -1
- package/dist/mcp/search/math.d.ts.map +0 -1
- package/dist/mcp/search/types.d.ts.map +0 -1
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/types.d.ts.map +0 -1
- package/dist/plugins/auth.d.ts.map +0 -1
- package/dist/plugins/cache.d.ts.map +0 -1
- package/dist/plugins/circuit-breaker.d.ts.map +0 -1
- package/dist/plugins/compression.d.ts.map +0 -1
- package/dist/plugins/cookie-jar.d.ts.map +0 -1
- package/dist/plugins/dedup.d.ts.map +0 -1
- package/dist/plugins/graphql.d.ts.map +0 -1
- package/dist/plugins/grpc-web.d.ts.map +0 -1
- package/dist/plugins/har-player.d.ts.map +0 -1
- package/dist/plugins/har-recorder.d.ts.map +0 -1
- package/dist/plugins/hls.d.ts.map +0 -1
- package/dist/plugins/http2-push.d.ts.map +0 -1
- package/dist/plugins/http3.d.ts.map +0 -1
- package/dist/plugins/interface-rotator.d.ts.map +0 -1
- package/dist/plugins/jsonrpc.d.ts.map +0 -1
- package/dist/plugins/logger.d.ts.map +0 -1
- package/dist/plugins/odata.d.ts.map +0 -1
- package/dist/plugins/pagination.d.ts.map +0 -1
- package/dist/plugins/proxy-rotator.d.ts.map +0 -1
- package/dist/plugins/retry.d.ts.map +0 -1
- package/dist/plugins/scrape.d.ts.map +0 -1
- package/dist/plugins/server-timing.d.ts.map +0 -1
- package/dist/plugins/soap.d.ts.map +0 -1
- package/dist/plugins/user-agent.d.ts.map +0 -1
- package/dist/plugins/xml.d.ts.map +0 -1
- package/dist/plugins/xsrf.d.ts.map +0 -1
- package/dist/presets/anthropic.d.ts.map +0 -1
- package/dist/presets/aws.d.ts.map +0 -1
- package/dist/presets/azure-openai.d.ts.map +0 -1
- package/dist/presets/azure.d.ts.map +0 -1
- package/dist/presets/cloudflare.d.ts.map +0 -1
- package/dist/presets/cohere.d.ts.map +0 -1
- package/dist/presets/deepseek.d.ts.map +0 -1
- package/dist/presets/digitalocean.d.ts.map +0 -1
- package/dist/presets/discord.d.ts.map +0 -1
- package/dist/presets/fireworks.d.ts.map +0 -1
- package/dist/presets/gcp.d.ts.map +0 -1
- package/dist/presets/gemini.d.ts.map +0 -1
- package/dist/presets/github.d.ts.map +0 -1
- package/dist/presets/gitlab.d.ts.map +0 -1
- package/dist/presets/groq.d.ts.map +0 -1
- package/dist/presets/huggingface.d.ts.map +0 -1
- package/dist/presets/index.d.ts.map +0 -1
- package/dist/presets/linear.d.ts.map +0 -1
- package/dist/presets/mailgun.d.ts.map +0 -1
- package/dist/presets/meta.d.ts.map +0 -1
- package/dist/presets/mistral.d.ts.map +0 -1
- package/dist/presets/notion.d.ts.map +0 -1
- package/dist/presets/openai.d.ts.map +0 -1
- package/dist/presets/oracle.d.ts.map +0 -1
- package/dist/presets/perplexity.d.ts.map +0 -1
- package/dist/presets/registry.d.ts.map +0 -1
- package/dist/presets/replicate.d.ts.map +0 -1
- package/dist/presets/sinch.d.ts.map +0 -1
- package/dist/presets/slack.d.ts.map +0 -1
- package/dist/presets/stripe.d.ts.map +0 -1
- package/dist/presets/supabase.d.ts.map +0 -1
- package/dist/presets/tiktok.d.ts.map +0 -1
- package/dist/presets/together.d.ts.map +0 -1
- package/dist/presets/twilio.d.ts.map +0 -1
- package/dist/presets/vercel.d.ts.map +0 -1
- package/dist/presets/vultr.d.ts.map +0 -1
- package/dist/presets/xai.d.ts.map +0 -1
- package/dist/presets/youtube.d.ts.map +0 -1
- package/dist/protocols/ftp.d.ts.map +0 -1
- package/dist/protocols/index.d.ts.map +0 -1
- package/dist/protocols/sftp.d.ts.map +0 -1
- package/dist/protocols/telnet.d.ts.map +0 -1
- package/dist/recker.d.ts.map +0 -1
- package/dist/runner/request-runner.d.ts.map +0 -1
- package/dist/scrape/document.d.ts.map +0 -1
- package/dist/scrape/element.d.ts.map +0 -1
- package/dist/scrape/extractors.d.ts.map +0 -1
- package/dist/scrape/index.d.ts.map +0 -1
- package/dist/scrape/types.d.ts.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/mock-udp-server.d.ts.map +0 -1
- package/dist/testing/mock.d.ts.map +0 -1
- package/dist/transport/base-udp.d.ts.map +0 -1
- package/dist/transport/fetch.d.ts.map +0 -1
- package/dist/transport/udp-response.d.ts.map +0 -1
- package/dist/transport/udp.d.ts.map +0 -1
- package/dist/transport/undici.d.ts.map +0 -1
- package/dist/types/ai.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/logger.d.ts.map +0 -1
- package/dist/types/udp.d.ts.map +0 -1
- package/dist/udp/index.d.ts.map +0 -1
- package/dist/utils/agent-manager.d.ts.map +0 -1
- package/dist/utils/body.d.ts.map +0 -1
- package/dist/utils/cert.d.ts.map +0 -1
- package/dist/utils/charset.d.ts.map +0 -1
- package/dist/utils/chart.d.ts.map +0 -1
- package/dist/utils/client-pool.d.ts.map +0 -1
- package/dist/utils/colors.d.ts.map +0 -1
- package/dist/utils/concurrency.d.ts.map +0 -1
- package/dist/utils/dns-toolkit.d.ts.map +0 -1
- package/dist/utils/dns.d.ts.map +0 -1
- package/dist/utils/doh.d.ts.map +0 -1
- package/dist/utils/download.d.ts.map +0 -1
- package/dist/utils/env-proxy.d.ts.map +0 -1
- package/dist/utils/header-parser.d.ts.map +0 -1
- package/dist/utils/html-cleaner.d.ts.map +0 -1
- package/dist/utils/link-header.d.ts.map +0 -1
- package/dist/utils/optional-require.d.ts.map +0 -1
- package/dist/utils/progress.d.ts.map +0 -1
- package/dist/utils/rdap.d.ts.map +0 -1
- package/dist/utils/request-pool.d.ts.map +0 -1
- package/dist/utils/security-grader.d.ts.map +0 -1
- package/dist/utils/sparkline.d.ts.map +0 -1
- package/dist/utils/sse.d.ts.map +0 -1
- package/dist/utils/streaming.d.ts.map +0 -1
- package/dist/utils/system-metrics.d.ts.map +0 -1
- package/dist/utils/tls-inspector.d.ts.map +0 -1
- package/dist/utils/try-fn.d.ts.map +0 -1
- package/dist/utils/upload.d.ts.map +0 -1
- package/dist/utils/user-agent.d.ts.map +0 -1
- package/dist/utils/whois.d.ts.map +0 -1
- package/dist/webrtc/index.d.ts.map +0 -1
- package/dist/websocket/client.d.ts.map +0 -1
package/dist/plugins/hls.js
CHANGED
|
@@ -1,225 +1,395 @@
|
|
|
1
1
|
import { createWriteStream } from 'node:fs';
|
|
2
|
+
import { mkdir } from 'node:fs/promises';
|
|
2
3
|
import { dirname, join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
function parseAttributes(line, prefix) {
|
|
5
|
+
const attrs = {};
|
|
6
|
+
const content = line.substring(prefix.length);
|
|
7
|
+
const regex = /([A-Z0-9-]+)=(?:"([^"]*)"|([^,]*))/g;
|
|
8
|
+
let match;
|
|
9
|
+
while ((match = regex.exec(content)) !== null) {
|
|
10
|
+
attrs[match[1]] = match[2] ?? match[3];
|
|
11
|
+
}
|
|
12
|
+
return attrs;
|
|
13
|
+
}
|
|
14
|
+
function resolveUrl(url, baseUrl) {
|
|
15
|
+
if (url.startsWith('http://') || url.startsWith('https://')) {
|
|
16
|
+
return url;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const base = new URL(baseUrl);
|
|
20
|
+
const basePath = base.pathname.substring(0, base.pathname.lastIndexOf('/') + 1);
|
|
21
|
+
return new URL(url, base.origin + basePath).toString();
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return url;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function parseMasterPlaylist(content, baseUrl) {
|
|
28
|
+
const lines = content.split('\n');
|
|
29
|
+
const variants = [];
|
|
30
|
+
let pendingVariant = {};
|
|
31
|
+
for (const rawLine of lines) {
|
|
32
|
+
const line = rawLine.trim();
|
|
33
|
+
if (!line)
|
|
34
|
+
continue;
|
|
35
|
+
if (line.startsWith('#EXT-X-STREAM-INF:')) {
|
|
36
|
+
const attrs = parseAttributes(line, '#EXT-X-STREAM-INF:');
|
|
37
|
+
pendingVariant = {
|
|
38
|
+
bandwidth: attrs.BANDWIDTH ? parseInt(attrs.BANDWIDTH, 10) : undefined,
|
|
39
|
+
resolution: attrs.RESOLUTION,
|
|
40
|
+
codecs: attrs.CODECS,
|
|
41
|
+
name: attrs.NAME,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
else if (!line.startsWith('#') && pendingVariant.bandwidth !== undefined) {
|
|
45
|
+
variants.push({
|
|
46
|
+
...pendingVariant,
|
|
47
|
+
url: resolveUrl(line, baseUrl),
|
|
48
|
+
});
|
|
49
|
+
pendingVariant = {};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { variants, isMaster: true };
|
|
53
|
+
}
|
|
54
|
+
function parseMediaPlaylist(content, baseUrl) {
|
|
5
55
|
const lines = content.split('\n');
|
|
6
56
|
const segments = [];
|
|
7
|
-
let currentDuration = 0;
|
|
8
|
-
let mediaSequence = 0;
|
|
9
57
|
let targetDuration = 5;
|
|
58
|
+
let mediaSequence = 0;
|
|
59
|
+
let discontinuitySequence = 0;
|
|
10
60
|
let endList = false;
|
|
61
|
+
let playlistType;
|
|
62
|
+
let currentDuration = 0;
|
|
11
63
|
let currentKey;
|
|
12
|
-
|
|
13
|
-
|
|
64
|
+
let currentDiscontinuity = false;
|
|
65
|
+
let currentProgramDateTime;
|
|
66
|
+
let segmentIndex = 0;
|
|
67
|
+
for (const rawLine of lines) {
|
|
68
|
+
const line = rawLine.trim();
|
|
14
69
|
if (!line)
|
|
15
70
|
continue;
|
|
16
71
|
if (line.startsWith('#EXT-X-TARGETDURATION:')) {
|
|
17
|
-
targetDuration =
|
|
72
|
+
targetDuration = parseInt(line.split(':')[1], 10);
|
|
18
73
|
}
|
|
19
74
|
else if (line.startsWith('#EXT-X-MEDIA-SEQUENCE:')) {
|
|
20
75
|
mediaSequence = parseInt(line.split(':')[1], 10);
|
|
21
76
|
}
|
|
22
|
-
else if (line.startsWith('#EXT-X-
|
|
77
|
+
else if (line.startsWith('#EXT-X-DISCONTINUITY-SEQUENCE:')) {
|
|
78
|
+
discontinuitySequence = parseInt(line.split(':')[1], 10);
|
|
79
|
+
}
|
|
80
|
+
else if (line.startsWith('#EXT-X-PLAYLIST-TYPE:')) {
|
|
81
|
+
playlistType = line.split(':')[1];
|
|
82
|
+
}
|
|
83
|
+
else if (line === '#EXT-X-ENDLIST') {
|
|
23
84
|
endList = true;
|
|
24
85
|
}
|
|
86
|
+
else if (line === '#EXT-X-DISCONTINUITY') {
|
|
87
|
+
currentDiscontinuity = true;
|
|
88
|
+
}
|
|
89
|
+
else if (line.startsWith('#EXT-X-PROGRAM-DATE-TIME:')) {
|
|
90
|
+
currentProgramDateTime = new Date(line.split(':').slice(1).join(':'));
|
|
91
|
+
}
|
|
25
92
|
else if (line.startsWith('#EXT-X-KEY:')) {
|
|
26
|
-
const attrs = line
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
93
|
+
const attrs = parseAttributes(line, '#EXT-X-KEY:');
|
|
94
|
+
if (attrs.METHOD === 'NONE') {
|
|
95
|
+
currentKey = undefined;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
31
98
|
currentKey = {
|
|
32
|
-
method:
|
|
33
|
-
uri:
|
|
34
|
-
iv:
|
|
99
|
+
method: attrs.METHOD,
|
|
100
|
+
uri: attrs.URI ? resolveUrl(attrs.URI, baseUrl) : undefined,
|
|
101
|
+
iv: attrs.IV,
|
|
35
102
|
};
|
|
36
103
|
}
|
|
37
104
|
}
|
|
38
105
|
else if (line.startsWith('#EXTINF:')) {
|
|
39
|
-
const durationStr = line.substring(8).split(','
|
|
106
|
+
const durationStr = line.substring(8).split(',')[0];
|
|
40
107
|
currentDuration = parseFloat(durationStr);
|
|
41
108
|
}
|
|
42
109
|
else if (!line.startsWith('#')) {
|
|
43
|
-
let url = line;
|
|
44
|
-
if (!url.startsWith('http')) {
|
|
45
|
-
try {
|
|
46
|
-
const base = new URL(baseUrl);
|
|
47
|
-
const basePath = base.pathname.substring(0, base.pathname.lastIndexOf('/') + 1);
|
|
48
|
-
url = new URL(url, base.origin + basePath).toString();
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
110
|
segments.push({
|
|
54
|
-
url,
|
|
111
|
+
url: resolveUrl(line, baseUrl),
|
|
55
112
|
duration: currentDuration,
|
|
56
|
-
sequence:
|
|
57
|
-
key: currentKey
|
|
113
|
+
sequence: mediaSequence + segmentIndex,
|
|
114
|
+
key: currentKey,
|
|
115
|
+
discontinuity: currentDiscontinuity,
|
|
116
|
+
programDateTime: currentProgramDateTime,
|
|
58
117
|
});
|
|
118
|
+
segmentIndex++;
|
|
119
|
+
currentDiscontinuity = false;
|
|
120
|
+
currentProgramDateTime = undefined;
|
|
59
121
|
}
|
|
60
122
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
123
|
+
return {
|
|
124
|
+
segments,
|
|
125
|
+
targetDuration,
|
|
126
|
+
mediaSequence,
|
|
127
|
+
endList,
|
|
128
|
+
playlistType,
|
|
129
|
+
discontinuitySequence,
|
|
130
|
+
};
|
|
65
131
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const bwMatch = line.match(/BANDWIDTH=(\d+)/);
|
|
77
|
-
const resMatch = line.match(/RESOLUTION=(\d+x\d+)/);
|
|
78
|
-
if (bwMatch)
|
|
79
|
-
currentBandwidth = parseInt(bwMatch[1], 10);
|
|
80
|
-
if (resMatch)
|
|
81
|
-
currentResolution = resMatch[1];
|
|
82
|
-
}
|
|
83
|
-
else if (!line.startsWith('#')) {
|
|
84
|
-
let url = line;
|
|
85
|
-
if (!url.startsWith('http')) {
|
|
86
|
-
try {
|
|
87
|
-
const base = new URL(baseUrl);
|
|
88
|
-
const basePath = base.pathname.substring(0, base.pathname.lastIndexOf('/') + 1);
|
|
89
|
-
url = new URL(url, base.origin + basePath).toString();
|
|
90
|
-
}
|
|
91
|
-
catch { }
|
|
92
|
-
}
|
|
93
|
-
variants.push({
|
|
94
|
-
url,
|
|
95
|
-
bandwidth: currentBandwidth,
|
|
96
|
-
resolution: currentResolution
|
|
97
|
-
});
|
|
98
|
-
}
|
|
132
|
+
function isMasterPlaylist(content) {
|
|
133
|
+
return content.includes('#EXT-X-STREAM-INF');
|
|
134
|
+
}
|
|
135
|
+
function selectVariant(variants, quality) {
|
|
136
|
+
if (!variants.length) {
|
|
137
|
+
throw new Error('No variants found in master playlist');
|
|
138
|
+
}
|
|
139
|
+
const sorted = [...variants].sort((a, b) => (a.bandwidth ?? 0) - (b.bandwidth ?? 0));
|
|
140
|
+
if (quality === 'lowest') {
|
|
141
|
+
return sorted[0];
|
|
99
142
|
}
|
|
100
|
-
|
|
143
|
+
if (quality === 'highest' || quality === undefined) {
|
|
144
|
+
return sorted[sorted.length - 1];
|
|
145
|
+
}
|
|
146
|
+
if (quality.resolution) {
|
|
147
|
+
const match = variants.find((v) => v.resolution === quality.resolution);
|
|
148
|
+
if (match)
|
|
149
|
+
return match;
|
|
150
|
+
}
|
|
151
|
+
if (quality.bandwidth) {
|
|
152
|
+
const target = quality.bandwidth;
|
|
153
|
+
return sorted.reduce((prev, curr) => {
|
|
154
|
+
const prevDiff = Math.abs((prev.bandwidth ?? 0) - target);
|
|
155
|
+
const currDiff = Math.abs((curr.bandwidth ?? 0) - target);
|
|
156
|
+
return currDiff < prevDiff ? curr : prev;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return sorted[sorted.length - 1];
|
|
101
160
|
}
|
|
102
|
-
export
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
if (initialManifest.includes('#EXT-X-STREAM-INF')) {
|
|
125
|
-
const variants = parseVariants(initialManifest, currentManifestUrl);
|
|
126
|
-
if (variants.length > 0) {
|
|
127
|
-
let selected = variants[variants.length - 1];
|
|
128
|
-
if (options.onVariantSelected) {
|
|
129
|
-
const userSelected = options.onVariantSelected(variants, selected);
|
|
130
|
-
if (userSelected)
|
|
131
|
-
selected = userSelected;
|
|
132
|
-
}
|
|
133
|
-
currentManifestUrl = selected.url;
|
|
134
|
-
info(`Master playlist detected. Switching to variant: ${currentManifestUrl}`);
|
|
135
|
-
}
|
|
161
|
+
export class HlsPromise {
|
|
162
|
+
client;
|
|
163
|
+
manifestUrl;
|
|
164
|
+
options;
|
|
165
|
+
seenSequences = new Set();
|
|
166
|
+
downloadedBytes = 0;
|
|
167
|
+
downloadedSegments = 0;
|
|
168
|
+
startTime = 0;
|
|
169
|
+
aborted = false;
|
|
170
|
+
abortController = new AbortController();
|
|
171
|
+
constructor(client, manifestUrl, options = {}) {
|
|
172
|
+
this.client = client;
|
|
173
|
+
this.manifestUrl = manifestUrl;
|
|
174
|
+
this.options = {
|
|
175
|
+
mode: 'merge',
|
|
176
|
+
format: 'ts',
|
|
177
|
+
concurrency: 5,
|
|
178
|
+
...options,
|
|
179
|
+
};
|
|
180
|
+
if (this.options.format !== 'ts') {
|
|
181
|
+
throw new Error(`Format '${this.options.format}' requires ffmpeg. Use format: 'ts' or install ffmpeg.`);
|
|
136
182
|
}
|
|
137
183
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return;
|
|
184
|
+
get [Symbol.toStringTag]() {
|
|
185
|
+
return 'HlsPromise';
|
|
141
186
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
187
|
+
then(onfulfilled, onrejected) {
|
|
188
|
+
return Promise.reject(new Error('HlsPromise requires .download(), .stream(), or .pipe() to execute')).then(onfulfilled, onrejected);
|
|
189
|
+
}
|
|
190
|
+
catch(onrejected) {
|
|
191
|
+
return this.then(null, onrejected);
|
|
192
|
+
}
|
|
193
|
+
finally(onfinally) {
|
|
194
|
+
return this.then(() => {
|
|
195
|
+
onfinally?.();
|
|
196
|
+
}, () => {
|
|
197
|
+
onfinally?.();
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
cancel() {
|
|
201
|
+
this.aborted = true;
|
|
202
|
+
this.abortController.abort();
|
|
203
|
+
}
|
|
204
|
+
async download(dest) {
|
|
205
|
+
this.startTime = Date.now();
|
|
206
|
+
const mediaPlaylistUrl = await this.resolveMediaPlaylist();
|
|
207
|
+
if (this.options.mode === 'chunks') {
|
|
208
|
+
await this.downloadChunks(mediaPlaylistUrl, dest);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
if (typeof dest !== 'string') {
|
|
212
|
+
throw new Error('Merge mode requires a string path, not a function');
|
|
153
213
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
filtered.push(seg);
|
|
214
|
+
await this.downloadMerged(mediaPlaylistUrl, dest);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
async *stream() {
|
|
218
|
+
this.startTime = Date.now();
|
|
219
|
+
const mediaPlaylistUrl = await this.resolveMediaPlaylist();
|
|
220
|
+
const isLive = this.isLiveMode();
|
|
221
|
+
const maxDuration = this.getMaxDuration();
|
|
222
|
+
while (!this.aborted) {
|
|
223
|
+
const playlist = await this.fetchMediaPlaylist(mediaPlaylistUrl);
|
|
224
|
+
const newSegments = playlist.segments.filter((s) => !this.seenSequences.has(s.sequence));
|
|
225
|
+
for (const segment of newSegments) {
|
|
226
|
+
if (this.aborted)
|
|
227
|
+
break;
|
|
228
|
+
if (maxDuration && Date.now() - this.startTime > maxDuration) {
|
|
229
|
+
return;
|
|
171
230
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
231
|
+
this.seenSequences.add(segment.sequence);
|
|
232
|
+
const data = await this.downloadSegment(segment);
|
|
233
|
+
const segmentData = {
|
|
234
|
+
sequence: segment.sequence,
|
|
235
|
+
duration: segment.duration,
|
|
236
|
+
data,
|
|
237
|
+
url: segment.url,
|
|
238
|
+
downloadedAt: new Date(),
|
|
239
|
+
};
|
|
240
|
+
this.downloadedSegments++;
|
|
241
|
+
this.downloadedBytes += data.byteLength;
|
|
242
|
+
this.emitProgress(playlist, isLive);
|
|
243
|
+
if (this.options.onSegment) {
|
|
244
|
+
await this.options.onSegment(segmentData);
|
|
245
|
+
}
|
|
246
|
+
yield segmentData;
|
|
183
247
|
}
|
|
184
248
|
if (!isLive || playlist.endList) {
|
|
185
|
-
recording = false;
|
|
186
249
|
break;
|
|
187
250
|
}
|
|
188
|
-
if (maxDuration
|
|
189
|
-
info('Max duration reached. Stopping.');
|
|
190
|
-
recording = false;
|
|
251
|
+
if (maxDuration && Date.now() - this.startTime > maxDuration) {
|
|
191
252
|
break;
|
|
192
253
|
}
|
|
193
|
-
const
|
|
194
|
-
await
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
254
|
+
const pollInterval = Math.max(1000, (playlist.targetDuration * 1000) / 2);
|
|
255
|
+
await this.sleep(pollInterval);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async pipe(writable) {
|
|
259
|
+
try {
|
|
260
|
+
for await (const segment of this.stream()) {
|
|
261
|
+
const canContinue = writable.write(segment.data);
|
|
262
|
+
if (!canContinue) {
|
|
263
|
+
await new Promise((resolve) => writable.once('drain', resolve));
|
|
264
|
+
}
|
|
201
265
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
266
|
+
}
|
|
267
|
+
finally {
|
|
268
|
+
if ('end' in writable && typeof writable.end === 'function') {
|
|
269
|
+
writable.end();
|
|
205
270
|
}
|
|
206
271
|
}
|
|
207
272
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
273
|
+
async info() {
|
|
274
|
+
const content = await this.client.get(this.manifestUrl).text();
|
|
275
|
+
if (isMasterPlaylist(content)) {
|
|
276
|
+
const master = parseMasterPlaylist(content, this.manifestUrl);
|
|
277
|
+
const selectedVariant = selectVariant(master.variants, this.options.quality);
|
|
278
|
+
const playlistContent = await this.client.get(selectedVariant.url).text();
|
|
279
|
+
const playlist = parseMediaPlaylist(playlistContent, selectedVariant.url);
|
|
280
|
+
const totalDuration = playlist.endList
|
|
281
|
+
? playlist.segments.reduce((sum, s) => sum + s.duration, 0)
|
|
282
|
+
: undefined;
|
|
283
|
+
return {
|
|
284
|
+
master,
|
|
285
|
+
playlist,
|
|
286
|
+
selectedVariant,
|
|
287
|
+
isLive: !playlist.endList,
|
|
288
|
+
totalDuration,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
const playlist = parseMediaPlaylist(content, this.manifestUrl);
|
|
292
|
+
const totalDuration = playlist.endList
|
|
293
|
+
? playlist.segments.reduce((sum, s) => sum + s.duration, 0)
|
|
294
|
+
: undefined;
|
|
295
|
+
return {
|
|
296
|
+
playlist,
|
|
297
|
+
isLive: !playlist.endList,
|
|
298
|
+
totalDuration,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
async resolveMediaPlaylist() {
|
|
302
|
+
const content = await this.client.get(this.manifestUrl).text();
|
|
303
|
+
if (!isMasterPlaylist(content)) {
|
|
304
|
+
return this.manifestUrl;
|
|
305
|
+
}
|
|
306
|
+
const master = parseMasterPlaylist(content, this.manifestUrl);
|
|
307
|
+
const variant = selectVariant(master.variants, this.options.quality);
|
|
308
|
+
return variant.url;
|
|
309
|
+
}
|
|
310
|
+
async fetchMediaPlaylist(url) {
|
|
311
|
+
const content = await this.client.get(url).text();
|
|
312
|
+
return parseMediaPlaylist(content, url);
|
|
313
|
+
}
|
|
314
|
+
async downloadSegment(segment) {
|
|
315
|
+
if (segment.key && segment.key.method !== 'NONE') {
|
|
316
|
+
throw new Error(`Encrypted HLS (${segment.key.method}) requires ffmpeg. Use unencrypted streams or install ffmpeg.`);
|
|
317
|
+
}
|
|
318
|
+
const response = await this.client.get(segment.url, {
|
|
319
|
+
headers: this.options.headers,
|
|
320
|
+
signal: this.abortController.signal,
|
|
321
|
+
});
|
|
322
|
+
const blob = await response.blob();
|
|
323
|
+
return new Uint8Array(await blob.arrayBuffer());
|
|
324
|
+
}
|
|
325
|
+
async downloadMerged(playlistUrl, outputPath) {
|
|
326
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
327
|
+
const output = createWriteStream(outputPath);
|
|
328
|
+
try {
|
|
329
|
+
await this.pipe(output);
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
output.destroy();
|
|
333
|
+
throw error;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
async downloadChunks(playlistUrl, dest) {
|
|
337
|
+
const getPath = typeof dest === 'string'
|
|
338
|
+
? (seg) => join(dest, `segment-${seg.sequence}.ts`)
|
|
339
|
+
: dest;
|
|
340
|
+
const baseDir = typeof dest === 'string' ? dest : dirname(getPath({ sequence: 0, duration: 0, url: '' }));
|
|
341
|
+
await mkdir(baseDir, { recursive: true });
|
|
342
|
+
for await (const segment of this.stream()) {
|
|
343
|
+
const filePath = getPath({
|
|
344
|
+
sequence: segment.sequence,
|
|
345
|
+
duration: segment.duration,
|
|
346
|
+
url: segment.url,
|
|
347
|
+
});
|
|
348
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
349
|
+
const output = createWriteStream(filePath);
|
|
350
|
+
await new Promise((resolve, reject) => {
|
|
351
|
+
output.write(segment.data, (err) => {
|
|
352
|
+
if (err)
|
|
353
|
+
reject(err);
|
|
354
|
+
else {
|
|
355
|
+
output.end();
|
|
356
|
+
resolve();
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
});
|
|
217
360
|
}
|
|
218
|
-
dest.end();
|
|
219
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
220
|
-
info(`Saved to ${outputPath}`);
|
|
221
361
|
}
|
|
222
|
-
|
|
223
|
-
|
|
362
|
+
isLiveMode() {
|
|
363
|
+
return this.options.live === true || typeof this.options.live === 'object';
|
|
224
364
|
}
|
|
365
|
+
getMaxDuration() {
|
|
366
|
+
if (typeof this.options.live === 'object' && this.options.live.duration) {
|
|
367
|
+
return this.options.live.duration;
|
|
368
|
+
}
|
|
369
|
+
return undefined;
|
|
370
|
+
}
|
|
371
|
+
emitProgress(playlist, isLive) {
|
|
372
|
+
if (!this.options.onProgress)
|
|
373
|
+
return;
|
|
374
|
+
this.options.onProgress({
|
|
375
|
+
downloadedSegments: this.downloadedSegments,
|
|
376
|
+
totalSegments: isLive ? undefined : playlist.segments.length,
|
|
377
|
+
downloadedBytes: this.downloadedBytes,
|
|
378
|
+
currentSegment: Math.max(...this.seenSequences),
|
|
379
|
+
isLive,
|
|
380
|
+
elapsed: Date.now() - this.startTime,
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
sleep(ms) {
|
|
384
|
+
return new Promise((resolve) => {
|
|
385
|
+
const timeout = setTimeout(resolve, ms);
|
|
386
|
+
this.abortController.signal.addEventListener('abort', () => {
|
|
387
|
+
clearTimeout(timeout);
|
|
388
|
+
resolve();
|
|
389
|
+
}, { once: true });
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
export function hls(client, manifestUrl, options = {}) {
|
|
394
|
+
return new HlsPromise(client, manifestUrl, options);
|
|
225
395
|
}
|
package/dist/plugins/http3.d.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export * from './auth/index.js';
|
|
2
|
+
export { retryPlugin, type RetryOptions } from './retry.js';
|
|
3
|
+
export { circuitBreakerPlugin, type CircuitBreakerOptions, CircuitBreakerError } from './circuit-breaker.js';
|
|
4
|
+
export { rateLimitPlugin, type RateLimitOptions, RateLimitExceededError } from './rate-limit.js';
|
|
5
|
+
export { cachePlugin, type CacheOptions } from './cache.js';
|
|
6
|
+
export { dedupPlugin, type DedupOptions } from './dedup.js';
|
|
7
|
+
export { compression } from './compression.js';
|
|
8
|
+
export { loggerPlugin, type LoggerPluginOptions as LoggerOptions } from './logger.js';
|
|
9
|
+
export { serverTimingPlugin } from './server-timing.js';
|
|
10
|
+
export { harRecorderPlugin } from './har-recorder.js';
|
|
11
|
+
export { harPlayerPlugin } from './har-player.js';
|
|
12
|
+
export { xsrfPlugin, type XSRFPluginOptions as XsrfOptions } from './xsrf.js';
|
|
13
|
+
export { certificatePinning, certificatePinningPlugin, type CertificatePinningOptions } from './certificate-pinning.js';
|
|
14
|
+
export { parseXML, serializeXML } from './xml.js';
|
|
15
|
+
export { soap, type SoapOptions } from './soap.js';
|
|
16
|
+
export { graphqlPlugin, type GraphQLOptions as GraphqlOptions } from './graphql.js';
|
|
17
|
+
export { jsonrpc } from './jsonrpc.js';
|
|
18
|
+
export { odata, type ODataOptions } from './odata.js';
|
|
19
|
+
export { proxyRotatorPlugin, type ProxyRotatorOptions } from './proxy-rotator.js';
|
|
20
|
+
export { interfaceRotatorPlugin } from './interface-rotator.js';
|
|
21
|
+
export { userAgentRotatorPlugin, type UserAgentOptions } from './user-agent.js';
|
|
22
|
+
export { cookieJarPlugin } from './cookie-jar.js';
|
|
23
|
+
export { hls, type HlsOptions } from './hls.js';
|
|
24
|
+
export { http2Push } from './http2-push.js';
|
|
25
|
+
export { http3 } from './http3.js';
|
|
26
|
+
export { grpcWeb } from './grpc-web.js';
|
|
27
|
+
export { scrape, type ScrapeOptions } from './scrape.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export * from './auth/index.js';
|
|
2
|
+
export { retryPlugin } from './retry.js';
|
|
3
|
+
export { circuitBreakerPlugin, CircuitBreakerError } from './circuit-breaker.js';
|
|
4
|
+
export { rateLimitPlugin, RateLimitExceededError } from './rate-limit.js';
|
|
5
|
+
export { cachePlugin } from './cache.js';
|
|
6
|
+
export { dedupPlugin } from './dedup.js';
|
|
7
|
+
export { compression } from './compression.js';
|
|
8
|
+
export { loggerPlugin } from './logger.js';
|
|
9
|
+
export { serverTimingPlugin } from './server-timing.js';
|
|
10
|
+
export { harRecorderPlugin } from './har-recorder.js';
|
|
11
|
+
export { harPlayerPlugin } from './har-player.js';
|
|
12
|
+
export { xsrfPlugin } from './xsrf.js';
|
|
13
|
+
export { certificatePinning, certificatePinningPlugin } from './certificate-pinning.js';
|
|
14
|
+
export { parseXML, serializeXML } from './xml.js';
|
|
15
|
+
export { soap } from './soap.js';
|
|
16
|
+
export { graphqlPlugin } from './graphql.js';
|
|
17
|
+
export { jsonrpc } from './jsonrpc.js';
|
|
18
|
+
export { odata } from './odata.js';
|
|
19
|
+
export { proxyRotatorPlugin } from './proxy-rotator.js';
|
|
20
|
+
export { interfaceRotatorPlugin } from './interface-rotator.js';
|
|
21
|
+
export { userAgentRotatorPlugin } from './user-agent.js';
|
|
22
|
+
export { cookieJarPlugin } from './cookie-jar.js';
|
|
23
|
+
export { hls } from './hls.js';
|
|
24
|
+
export { http2Push } from './http2-push.js';
|
|
25
|
+
export { http3 } from './http3.js';
|
|
26
|
+
export { grpcWeb } from './grpc-web.js';
|
|
27
|
+
export { scrape } from './scrape.js';
|
|
@@ -6,5 +6,4 @@ export interface InterfaceRotatorOptions {
|
|
|
6
6
|
excludeInternal?: boolean;
|
|
7
7
|
ips?: string[];
|
|
8
8
|
}
|
|
9
|
-
export declare function
|
|
10
|
-
//# sourceMappingURL=interface-rotator.d.ts.map
|
|
9
|
+
export declare function interfaceRotatorPlugin(options?: InterfaceRotatorOptions): Plugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Agent } from 'undici';
|
|
2
2
|
import { networkInterfaces } from 'node:os';
|
|
3
|
-
export function
|
|
3
|
+
export function interfaceRotatorPlugin(options = {}) {
|
|
4
4
|
const strategy = options.strategy || 'round-robin';
|
|
5
5
|
const familyFilter = options.family || 'IPv4';
|
|
6
6
|
const excludeInternal = options.excludeInternal !== false;
|