recker 1.0.20-next.de24f7d → 1.0.20-next.e194d90
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/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 +0 -1
- package/dist/core/client.js +1 -1
- 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 +1 -1
- package/dist/index.js +1 -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 +0 -1
- package/dist/plugins/cache.js +1 -1
- package/dist/plugins/certificate-pinning.d.ts +59 -0
- package/dist/plugins/certificate-pinning.js +236 -0
- package/dist/plugins/circuit-breaker.d.ts +0 -1
- package/dist/plugins/compression.d.ts +0 -1
- package/dist/plugins/cookie-jar.d.ts +0 -1
- package/dist/plugins/dedup.d.ts +0 -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 +0 -1
- package/dist/plugins/har-recorder.d.ts +0 -1
- package/dist/plugins/hls.d.ts +0 -1
- 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 +0 -1
- package/dist/plugins/jsonrpc.d.ts +0 -1
- package/dist/plugins/logger.d.ts +0 -1
- package/dist/plugins/odata.d.ts +0 -1
- package/dist/plugins/pagination.d.ts +0 -1
- package/dist/plugins/proxy-rotator.d.ts +0 -1
- package/dist/plugins/rate-limit.d.ts +15 -0
- package/dist/plugins/rate-limit.js +162 -0
- package/dist/plugins/retry.d.ts +0 -1
- package/dist/plugins/retry.js +2 -2
- package/dist/plugins/scrape.d.ts +0 -1
- package/dist/plugins/server-timing.d.ts +0 -1
- package/dist/plugins/soap.d.ts +0 -1
- package/dist/plugins/user-agent.d.ts +0 -1
- package/dist/plugins/xml.d.ts +0 -1
- package/dist/plugins/xsrf.d.ts +0 -1
- 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 +12 -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
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { createClient } from '../../core/client.js';
|
|
2
|
+
import { createDNS } from '../../dns/index.js';
|
|
3
|
+
import { createWhois } from '../../utils/whois.js';
|
|
4
|
+
import { createConnection } from 'net';
|
|
5
|
+
const dnsClient = createDNS({ provider: 'system' });
|
|
6
|
+
const whoisClient = createWhois();
|
|
7
|
+
async function httpRequest(args) {
|
|
8
|
+
const url = String(args.url || '');
|
|
9
|
+
const method = String(args.method || 'GET').toUpperCase();
|
|
10
|
+
const headers = args.headers || {};
|
|
11
|
+
const body = args.body;
|
|
12
|
+
const timeout = Number(args.timeout) || 10000;
|
|
13
|
+
const retries = Number(args.retries) || 0;
|
|
14
|
+
if (!url) {
|
|
15
|
+
return {
|
|
16
|
+
content: [{ type: 'text', text: 'Error: url is required' }],
|
|
17
|
+
isError: true,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const client = createClient({
|
|
22
|
+
headers,
|
|
23
|
+
timeout,
|
|
24
|
+
retry: {
|
|
25
|
+
maxAttempts: retries,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
let response;
|
|
29
|
+
switch (method) {
|
|
30
|
+
case 'GET':
|
|
31
|
+
response = await client.get(url);
|
|
32
|
+
break;
|
|
33
|
+
case 'POST':
|
|
34
|
+
response = await client.post(url, { json: body });
|
|
35
|
+
break;
|
|
36
|
+
case 'PUT':
|
|
37
|
+
response = await client.put(url, { json: body });
|
|
38
|
+
break;
|
|
39
|
+
case 'DELETE':
|
|
40
|
+
response = await client.delete(url);
|
|
41
|
+
break;
|
|
42
|
+
case 'PATCH':
|
|
43
|
+
response = await client.patch(url, { json: body });
|
|
44
|
+
break;
|
|
45
|
+
case 'HEAD':
|
|
46
|
+
response = await client.head(url);
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: 'text', text: `Error: Unsupported method ${method}` }],
|
|
51
|
+
isError: true,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const responseHeaders = {};
|
|
55
|
+
response.headers.forEach((val, key) => {
|
|
56
|
+
responseHeaders[key] = val;
|
|
57
|
+
});
|
|
58
|
+
const result = {
|
|
59
|
+
status: response.status,
|
|
60
|
+
statusText: response.statusText,
|
|
61
|
+
headers: responseHeaders,
|
|
62
|
+
data: await response.text(),
|
|
63
|
+
};
|
|
64
|
+
try {
|
|
65
|
+
result.data = JSON.parse(result.data);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
content: [{
|
|
71
|
+
type: 'text',
|
|
72
|
+
text: JSON.stringify(result, null, 2),
|
|
73
|
+
}],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return {
|
|
78
|
+
content: [{
|
|
79
|
+
type: 'text',
|
|
80
|
+
text: `Request failed: ${error.message}`,
|
|
81
|
+
}],
|
|
82
|
+
isError: true,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function dnsLookup(args) {
|
|
87
|
+
const domain = String(args.domain || '');
|
|
88
|
+
const type = String(args.type || 'A').toUpperCase();
|
|
89
|
+
if (!domain) {
|
|
90
|
+
return {
|
|
91
|
+
content: [{ type: 'text', text: 'Error: domain is required' }],
|
|
92
|
+
isError: true,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
let result;
|
|
97
|
+
if (type === 'ALL') {
|
|
98
|
+
result = await dnsClient.resolveAll(domain);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
result = await dnsClient.resolve(domain, type);
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
content: [{
|
|
105
|
+
type: 'text',
|
|
106
|
+
text: JSON.stringify({ domain, type, result }, null, 2),
|
|
107
|
+
}],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return {
|
|
112
|
+
content: [{
|
|
113
|
+
type: 'text',
|
|
114
|
+
text: `DNS lookup failed: ${error.message}`,
|
|
115
|
+
}],
|
|
116
|
+
isError: true,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function whoisLookup(args) {
|
|
121
|
+
const query = String(args.query || '');
|
|
122
|
+
if (!query) {
|
|
123
|
+
return {
|
|
124
|
+
content: [{ type: 'text', text: 'Error: query is required' }],
|
|
125
|
+
isError: true,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const result = await whoisClient.lookup(query);
|
|
130
|
+
return {
|
|
131
|
+
content: [{
|
|
132
|
+
type: 'text',
|
|
133
|
+
text: JSON.stringify({
|
|
134
|
+
server: result.server,
|
|
135
|
+
data: result.data,
|
|
136
|
+
}, null, 2),
|
|
137
|
+
}],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
return {
|
|
142
|
+
content: [{
|
|
143
|
+
type: 'text',
|
|
144
|
+
text: `WHOIS lookup failed: ${error.message}`,
|
|
145
|
+
}],
|
|
146
|
+
isError: true,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async function ping(args) {
|
|
151
|
+
const host = String(args.host || '');
|
|
152
|
+
const port = Number(args.port) || 80;
|
|
153
|
+
const timeout = Number(args.timeout) || 5000;
|
|
154
|
+
const count = Number(args.count) || 3;
|
|
155
|
+
if (!host) {
|
|
156
|
+
return {
|
|
157
|
+
content: [{ type: 'text', text: 'Error: host is required' }],
|
|
158
|
+
isError: true,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
const results = [];
|
|
162
|
+
for (let i = 0; i < count; i++) {
|
|
163
|
+
const start = Date.now();
|
|
164
|
+
try {
|
|
165
|
+
await new Promise((resolve, reject) => {
|
|
166
|
+
const socket = createConnection({ host, port, timeout });
|
|
167
|
+
socket.on('connect', () => {
|
|
168
|
+
socket.destroy();
|
|
169
|
+
resolve();
|
|
170
|
+
});
|
|
171
|
+
socket.on('timeout', () => {
|
|
172
|
+
socket.destroy();
|
|
173
|
+
reject(new Error('Timeout'));
|
|
174
|
+
});
|
|
175
|
+
socket.on('error', (err) => {
|
|
176
|
+
socket.destroy();
|
|
177
|
+
reject(err);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
results.push({ seq: i + 1, time: Date.now() - start });
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
results.push({ seq: i + 1, error: error.message });
|
|
184
|
+
}
|
|
185
|
+
if (i < count - 1) {
|
|
186
|
+
await new Promise(r => setTimeout(r, 200));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const successful = results.filter(r => !r.error);
|
|
190
|
+
const totalTime = successful.reduce((acc, r) => acc + (r.time || 0), 0);
|
|
191
|
+
const avg = successful.length > 0 ? totalTime / successful.length : 0;
|
|
192
|
+
return {
|
|
193
|
+
content: [{
|
|
194
|
+
type: 'text',
|
|
195
|
+
text: JSON.stringify({
|
|
196
|
+
host,
|
|
197
|
+
port,
|
|
198
|
+
sent: count,
|
|
199
|
+
received: successful.length,
|
|
200
|
+
loss: `${((count - successful.length) / count * 100).toFixed(1)}%`,
|
|
201
|
+
avgLatency: `${avg.toFixed(2)}ms`,
|
|
202
|
+
details: results,
|
|
203
|
+
}, null, 2),
|
|
204
|
+
}],
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
export const networkTools = [
|
|
208
|
+
{
|
|
209
|
+
name: 'rek_http_request',
|
|
210
|
+
description: 'Perform an HTTP request to any URL using Recker\'s robust client. Supports all methods, headers, and automatic JSON parsing.',
|
|
211
|
+
inputSchema: {
|
|
212
|
+
type: 'object',
|
|
213
|
+
properties: {
|
|
214
|
+
url: { type: 'string', description: 'Target URL' },
|
|
215
|
+
method: { type: 'string', description: 'HTTP method (GET, POST, PUT, DELETE, etc.)', default: 'GET' },
|
|
216
|
+
headers: { type: 'object', description: 'Request headers' },
|
|
217
|
+
body: { type: 'object', description: 'JSON body for POST/PUT/PATCH' },
|
|
218
|
+
timeout: { type: 'number', description: 'Timeout in ms', default: 10000 },
|
|
219
|
+
retries: { type: 'number', description: 'Number of retries', default: 0 },
|
|
220
|
+
},
|
|
221
|
+
required: ['url'],
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: 'rek_dns_lookup',
|
|
226
|
+
description: 'Resolve DNS records for a domain. Supports A, AAAA, MX, TXT, NS, etc.',
|
|
227
|
+
inputSchema: {
|
|
228
|
+
type: 'object',
|
|
229
|
+
properties: {
|
|
230
|
+
domain: { type: 'string', description: 'Domain name to resolve' },
|
|
231
|
+
type: { type: 'string', description: 'Record type (A, AAAA, MX, TXT, NS, ALL)', default: 'A' },
|
|
232
|
+
},
|
|
233
|
+
required: ['domain'],
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: 'rek_whois_lookup',
|
|
238
|
+
description: 'Perform a WHOIS lookup for a domain or IP address to find registration info.',
|
|
239
|
+
inputSchema: {
|
|
240
|
+
type: 'object',
|
|
241
|
+
properties: {
|
|
242
|
+
query: { type: 'string', description: 'Domain or IP to lookup' },
|
|
243
|
+
},
|
|
244
|
+
required: ['query'],
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: 'rek_network_ping',
|
|
249
|
+
description: 'Check TCP connectivity to a host and port. Measures latency.',
|
|
250
|
+
inputSchema: {
|
|
251
|
+
type: 'object',
|
|
252
|
+
properties: {
|
|
253
|
+
host: { type: 'string', description: 'Hostname or IP' },
|
|
254
|
+
port: { type: 'number', description: 'Target port', default: 80 },
|
|
255
|
+
count: { type: 'number', description: 'Number of pings', default: 3 },
|
|
256
|
+
timeout: { type: 'number', description: 'Timeout per ping in ms', default: 5000 },
|
|
257
|
+
},
|
|
258
|
+
required: ['host'],
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
];
|
|
262
|
+
export const networkToolHandlers = {
|
|
263
|
+
rek_http_request: httpRequest,
|
|
264
|
+
rek_dns_lookup: dnsLookup,
|
|
265
|
+
rek_whois_lookup: whoisLookup,
|
|
266
|
+
rek_network_ping: ping,
|
|
267
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MCPTool, MCPToolResult } from '../types.js';
|
|
2
|
+
export type MCPToolHandler = (args: Record<string, unknown>) => Promise<MCPToolResult>;
|
|
3
|
+
export interface ToolModule {
|
|
4
|
+
tools: MCPTool[];
|
|
5
|
+
handlers: Record<string, MCPToolHandler>;
|
|
6
|
+
}
|
|
7
|
+
export declare class ToolRegistry {
|
|
8
|
+
private tools;
|
|
9
|
+
private handlers;
|
|
10
|
+
constructor();
|
|
11
|
+
registerTool(tool: MCPTool, handler: MCPToolHandler): void;
|
|
12
|
+
registerModule(module: ToolModule): void;
|
|
13
|
+
getTool(name: string): MCPTool | undefined;
|
|
14
|
+
listTools(): MCPTool[];
|
|
15
|
+
callTool(name: string, args: Record<string, unknown>): Promise<MCPToolResult>;
|
|
16
|
+
hasTool(name: string): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class ToolRegistry {
|
|
2
|
+
tools = new Map();
|
|
3
|
+
handlers = new Map();
|
|
4
|
+
constructor() { }
|
|
5
|
+
registerTool(tool, handler) {
|
|
6
|
+
if (this.tools.has(tool.name)) {
|
|
7
|
+
throw new Error(`Tool already registered: ${tool.name}`);
|
|
8
|
+
}
|
|
9
|
+
this.tools.set(tool.name, tool);
|
|
10
|
+
this.handlers.set(tool.name, handler);
|
|
11
|
+
}
|
|
12
|
+
registerModule(module) {
|
|
13
|
+
for (const tool of module.tools) {
|
|
14
|
+
const handler = module.handlers[tool.name];
|
|
15
|
+
if (!handler) {
|
|
16
|
+
throw new Error(`Handler missing for tool: ${tool.name}`);
|
|
17
|
+
}
|
|
18
|
+
this.registerTool(tool, handler);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
getTool(name) {
|
|
22
|
+
return this.tools.get(name);
|
|
23
|
+
}
|
|
24
|
+
listTools() {
|
|
25
|
+
return Array.from(this.tools.values());
|
|
26
|
+
}
|
|
27
|
+
async callTool(name, args) {
|
|
28
|
+
const handler = this.handlers.get(name);
|
|
29
|
+
if (!handler) {
|
|
30
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
31
|
+
}
|
|
32
|
+
return handler(args);
|
|
33
|
+
}
|
|
34
|
+
hasTool(name) {
|
|
35
|
+
return this.tools.has(name);
|
|
36
|
+
}
|
|
37
|
+
}
|
package/dist/mcp/types.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Middleware, Plugin } from '../../types/index.js';
|
|
2
|
+
export interface ApiKeyAuthOptions {
|
|
3
|
+
key: string | (() => string | Promise<string>);
|
|
4
|
+
in?: 'header' | 'query';
|
|
5
|
+
name?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function apiKeyAuth(options: ApiKeyAuthOptions): Middleware;
|
|
8
|
+
export declare function apiKeyAuthPlugin(options: ApiKeyAuthOptions): Plugin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function apiKeyAuth(options) {
|
|
2
|
+
const location = options.in ?? 'header';
|
|
3
|
+
const name = options.name ?? 'X-API-Key';
|
|
4
|
+
return async (req, next) => {
|
|
5
|
+
const key = typeof options.key === 'function'
|
|
6
|
+
? await options.key()
|
|
7
|
+
: options.key;
|
|
8
|
+
if (location === 'header') {
|
|
9
|
+
const newReq = req.withHeader(name, key);
|
|
10
|
+
return next(newReq);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
const url = new URL(req.url);
|
|
14
|
+
url.searchParams.set(name, key);
|
|
15
|
+
const newReq = {
|
|
16
|
+
...req,
|
|
17
|
+
url: url.toString(),
|
|
18
|
+
};
|
|
19
|
+
return next(newReq);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function apiKeyAuthPlugin(options) {
|
|
24
|
+
return (client) => {
|
|
25
|
+
client.use(apiKeyAuth(options));
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Middleware, Plugin } from '../../types/index.js';
|
|
2
|
+
import { OIDCTokens } from './oidc.js';
|
|
3
|
+
export interface Auth0Options {
|
|
4
|
+
domain: string;
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret?: string;
|
|
7
|
+
audience?: string;
|
|
8
|
+
scopes?: string[];
|
|
9
|
+
accessToken?: string | (() => string | Promise<string>);
|
|
10
|
+
refreshToken?: string;
|
|
11
|
+
tokenStorage?: {
|
|
12
|
+
get: () => Promise<OIDCTokens | null>;
|
|
13
|
+
set: (tokens: OIDCTokens) => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
organization?: string;
|
|
16
|
+
connection?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function generateAuth0AuthUrl(options: Auth0Options & {
|
|
19
|
+
redirectUri: string;
|
|
20
|
+
state?: string;
|
|
21
|
+
usePKCE?: boolean;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
url: string;
|
|
24
|
+
codeVerifier?: string;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function exchangeAuth0Code(options: Auth0Options & {
|
|
27
|
+
code: string;
|
|
28
|
+
redirectUri: string;
|
|
29
|
+
codeVerifier?: string;
|
|
30
|
+
}): Promise<OIDCTokens>;
|
|
31
|
+
export declare function getAuth0UserInfo(domain: string, accessToken: string): Promise<Record<string, unknown>>;
|
|
32
|
+
export declare function auth0(options: Auth0Options): Middleware;
|
|
33
|
+
export declare function auth0Plugin(options: Auth0Options): Plugin;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { oidc, generatePKCE } from './oidc.js';
|
|
2
|
+
export async function generateAuth0AuthUrl(options) {
|
|
3
|
+
const issuer = `https://${options.domain}`;
|
|
4
|
+
const pkce = options.usePKCE ? generatePKCE() : undefined;
|
|
5
|
+
const params = new URLSearchParams({
|
|
6
|
+
response_type: 'code',
|
|
7
|
+
client_id: options.clientId,
|
|
8
|
+
redirect_uri: options.redirectUri,
|
|
9
|
+
scope: (options.scopes || ['openid', 'profile', 'email']).join(' '),
|
|
10
|
+
});
|
|
11
|
+
if (options.audience) {
|
|
12
|
+
params.set('audience', options.audience);
|
|
13
|
+
}
|
|
14
|
+
if (options.state) {
|
|
15
|
+
params.set('state', options.state);
|
|
16
|
+
}
|
|
17
|
+
if (options.organization) {
|
|
18
|
+
params.set('organization', options.organization);
|
|
19
|
+
}
|
|
20
|
+
if (options.connection) {
|
|
21
|
+
params.set('connection', options.connection);
|
|
22
|
+
}
|
|
23
|
+
if (pkce) {
|
|
24
|
+
params.set('code_challenge', pkce.codeChallenge);
|
|
25
|
+
params.set('code_challenge_method', 'S256');
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
url: `${issuer}/authorize?${params.toString()}`,
|
|
29
|
+
codeVerifier: pkce?.codeVerifier,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export async function exchangeAuth0Code(options) {
|
|
33
|
+
const tokenUrl = `https://${options.domain}/oauth/token`;
|
|
34
|
+
const params = {
|
|
35
|
+
grant_type: 'authorization_code',
|
|
36
|
+
client_id: options.clientId,
|
|
37
|
+
code: options.code,
|
|
38
|
+
redirect_uri: options.redirectUri,
|
|
39
|
+
};
|
|
40
|
+
if (options.clientSecret) {
|
|
41
|
+
params.client_secret = options.clientSecret;
|
|
42
|
+
}
|
|
43
|
+
if (options.codeVerifier) {
|
|
44
|
+
params.code_verifier = options.codeVerifier;
|
|
45
|
+
}
|
|
46
|
+
const response = await fetch(tokenUrl, {
|
|
47
|
+
method: 'POST',
|
|
48
|
+
headers: {
|
|
49
|
+
'Content-Type': 'application/json',
|
|
50
|
+
},
|
|
51
|
+
body: JSON.stringify(params),
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
const error = await response.text();
|
|
55
|
+
throw new Error(`Auth0 token exchange failed: ${error}`);
|
|
56
|
+
}
|
|
57
|
+
const data = await response.json();
|
|
58
|
+
return {
|
|
59
|
+
accessToken: data.access_token,
|
|
60
|
+
refreshToken: data.refresh_token,
|
|
61
|
+
idToken: data.id_token,
|
|
62
|
+
expiresAt: data.expires_in ? Date.now() + data.expires_in * 1000 : undefined,
|
|
63
|
+
tokenType: data.token_type || 'Bearer',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export async function getAuth0UserInfo(domain, accessToken) {
|
|
67
|
+
const response = await fetch(`https://${domain}/userinfo`, {
|
|
68
|
+
headers: {
|
|
69
|
+
Authorization: `Bearer ${accessToken}`,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
if (!response.ok) {
|
|
73
|
+
throw new Error(`Failed to get user info: ${response.status}`);
|
|
74
|
+
}
|
|
75
|
+
return response.json();
|
|
76
|
+
}
|
|
77
|
+
export function auth0(options) {
|
|
78
|
+
const issuer = `https://${options.domain}`;
|
|
79
|
+
return oidc({
|
|
80
|
+
issuer,
|
|
81
|
+
clientId: options.clientId,
|
|
82
|
+
clientSecret: options.clientSecret,
|
|
83
|
+
scopes: options.scopes || ['openid', 'profile', 'email'],
|
|
84
|
+
accessToken: options.accessToken,
|
|
85
|
+
refreshToken: options.refreshToken,
|
|
86
|
+
tokenStorage: options.tokenStorage,
|
|
87
|
+
audience: options.audience,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
export function auth0Plugin(options) {
|
|
91
|
+
return (client) => {
|
|
92
|
+
client.use(auth0(options));
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Middleware, Plugin } from '../../types/index.js';
|
|
2
|
+
export interface AWSSignatureV4Options {
|
|
3
|
+
accessKeyId: string;
|
|
4
|
+
secretAccessKey: string;
|
|
5
|
+
region: string;
|
|
6
|
+
service: string;
|
|
7
|
+
sessionToken?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function awsSignatureV4(options: AWSSignatureV4Options): Middleware;
|
|
10
|
+
export declare function awsSignatureV4Plugin(options: AWSSignatureV4Options): Plugin;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createHash, createHmac } from 'node:crypto';
|
|
2
|
+
function sha256(str) {
|
|
3
|
+
return createHash('sha256').update(str).digest('hex');
|
|
4
|
+
}
|
|
5
|
+
export function awsSignatureV4(options) {
|
|
6
|
+
return async (req, next) => {
|
|
7
|
+
const url = new URL(req.url);
|
|
8
|
+
const host = url.host;
|
|
9
|
+
const pathname = url.pathname;
|
|
10
|
+
const queryString = url.search.slice(1);
|
|
11
|
+
const now = new Date();
|
|
12
|
+
const amzDate = now.toISOString().replace(/[:-]|\.\d{3}/g, '');
|
|
13
|
+
const dateStamp = amzDate.slice(0, 8);
|
|
14
|
+
const method = req.method;
|
|
15
|
+
const canonicalUri = pathname || '/';
|
|
16
|
+
const canonicalQueryString = queryString
|
|
17
|
+
.split('&')
|
|
18
|
+
.filter(Boolean)
|
|
19
|
+
.sort()
|
|
20
|
+
.join('&');
|
|
21
|
+
let payload = '';
|
|
22
|
+
if (req.body) {
|
|
23
|
+
if (typeof req.body === 'string') {
|
|
24
|
+
payload = req.body;
|
|
25
|
+
}
|
|
26
|
+
else if (req.body instanceof ArrayBuffer) {
|
|
27
|
+
payload = Buffer.from(req.body).toString();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const payloadHash = sha256(payload);
|
|
31
|
+
const headers = {
|
|
32
|
+
host,
|
|
33
|
+
'x-amz-date': amzDate,
|
|
34
|
+
'x-amz-content-sha256': payloadHash,
|
|
35
|
+
};
|
|
36
|
+
if (options.sessionToken) {
|
|
37
|
+
headers['x-amz-security-token'] = options.sessionToken;
|
|
38
|
+
}
|
|
39
|
+
req.headers.forEach((value, key) => {
|
|
40
|
+
headers[key.toLowerCase()] = value;
|
|
41
|
+
});
|
|
42
|
+
const signedHeaders = Object.keys(headers).sort().join(';');
|
|
43
|
+
const canonicalHeaders = Object.keys(headers)
|
|
44
|
+
.sort()
|
|
45
|
+
.map(key => `${key}:${headers[key].trim()}\n`)
|
|
46
|
+
.join('');
|
|
47
|
+
const canonicalRequest = [
|
|
48
|
+
method,
|
|
49
|
+
canonicalUri,
|
|
50
|
+
canonicalQueryString,
|
|
51
|
+
canonicalHeaders,
|
|
52
|
+
signedHeaders,
|
|
53
|
+
payloadHash,
|
|
54
|
+
].join('\n');
|
|
55
|
+
const algorithm = 'AWS4-HMAC-SHA256';
|
|
56
|
+
const credentialScope = `${dateStamp}/${options.region}/${options.service}/aws4_request`;
|
|
57
|
+
const stringToSign = [
|
|
58
|
+
algorithm,
|
|
59
|
+
amzDate,
|
|
60
|
+
credentialScope,
|
|
61
|
+
sha256(canonicalRequest),
|
|
62
|
+
].join('\n');
|
|
63
|
+
const getSignatureKey = (key, dateStamp, regionName, serviceName) => {
|
|
64
|
+
const kDate = createHmac('sha256', `AWS4${key}`).update(dateStamp).digest();
|
|
65
|
+
const kRegion = createHmac('sha256', kDate).update(regionName).digest();
|
|
66
|
+
const kService = createHmac('sha256', kRegion).update(serviceName).digest();
|
|
67
|
+
const kSigning = createHmac('sha256', kService).update('aws4_request').digest();
|
|
68
|
+
return kSigning;
|
|
69
|
+
};
|
|
70
|
+
const signingKey = getSignatureKey(options.secretAccessKey, dateStamp, options.region, options.service);
|
|
71
|
+
const signature = createHmac('sha256', signingKey)
|
|
72
|
+
.update(stringToSign)
|
|
73
|
+
.digest('hex');
|
|
74
|
+
const authorizationHeader = `${algorithm} Credential=${options.accessKeyId}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`;
|
|
75
|
+
let newReq = req.withHeader('Authorization', authorizationHeader);
|
|
76
|
+
newReq = newReq.withHeader('x-amz-date', amzDate);
|
|
77
|
+
newReq = newReq.withHeader('x-amz-content-sha256', payloadHash);
|
|
78
|
+
if (options.sessionToken) {
|
|
79
|
+
newReq = newReq.withHeader('x-amz-security-token', options.sessionToken);
|
|
80
|
+
}
|
|
81
|
+
return next(newReq);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function awsSignatureV4Plugin(options) {
|
|
85
|
+
return (client) => {
|
|
86
|
+
client.use(awsSignatureV4(options));
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Middleware, Plugin } from '../../types/index.js';
|
|
2
|
+
import { OIDCTokens } from './oidc.js';
|
|
3
|
+
export interface AzureADOptions {
|
|
4
|
+
tenantId: string;
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret?: string;
|
|
7
|
+
clientCertificate?: {
|
|
8
|
+
thumbprint: string;
|
|
9
|
+
privateKey: string;
|
|
10
|
+
};
|
|
11
|
+
scopes?: string[];
|
|
12
|
+
accessToken?: string | (() => string | Promise<string>);
|
|
13
|
+
refreshToken?: string;
|
|
14
|
+
tokenStorage?: {
|
|
15
|
+
get: () => Promise<OIDCTokens | null>;
|
|
16
|
+
set: (tokens: OIDCTokens) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
cloudInstance?: string;
|
|
19
|
+
b2c?: {
|
|
20
|
+
tenantName: string;
|
|
21
|
+
policy: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare function generateAzureADAuthUrl(options: AzureADOptions & {
|
|
25
|
+
redirectUri: string;
|
|
26
|
+
state?: string;
|
|
27
|
+
nonce?: string;
|
|
28
|
+
usePKCE?: boolean;
|
|
29
|
+
prompt?: 'login' | 'none' | 'consent' | 'select_account';
|
|
30
|
+
loginHint?: string;
|
|
31
|
+
domainHint?: string;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
url: string;
|
|
34
|
+
codeVerifier?: string;
|
|
35
|
+
}>;
|
|
36
|
+
export declare function exchangeAzureADCode(options: AzureADOptions & {
|
|
37
|
+
code: string;
|
|
38
|
+
redirectUri: string;
|
|
39
|
+
codeVerifier?: string;
|
|
40
|
+
}): Promise<OIDCTokens>;
|
|
41
|
+
export declare function azureADOnBehalfOf(options: AzureADOptions & {
|
|
42
|
+
assertion: string;
|
|
43
|
+
scope: string;
|
|
44
|
+
}): Promise<OIDCTokens>;
|
|
45
|
+
export declare function getAzureADUserInfo(accessToken: string): Promise<Record<string, unknown>>;
|
|
46
|
+
export declare function azureAD(options: AzureADOptions): Middleware;
|
|
47
|
+
export declare function azureADPlugin(options: AzureADOptions): Plugin;
|
|
48
|
+
export { azureAD as entraId, azureADPlugin as entraIdPlugin };
|