@blamejs/blamejs-shop 0.0.44
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/CHANGELOG.md +87 -0
- package/LICENSE +17 -0
- package/README.md +117 -0
- package/SECURITY.md +139 -0
- package/lib/admin.js +952 -0
- package/lib/analytics.js +267 -0
- package/lib/cart.js +279 -0
- package/lib/catalog-import.js +344 -0
- package/lib/catalog.js +769 -0
- package/lib/checkout.js +320 -0
- package/lib/config.js +151 -0
- package/lib/customers.js +322 -0
- package/lib/email.js +242 -0
- package/lib/externaldb-d1.js +283 -0
- package/lib/index.js +57 -0
- package/lib/inventory-alerts.js +198 -0
- package/lib/newsletter.js +142 -0
- package/lib/order.js +380 -0
- package/lib/payment.js +318 -0
- package/lib/pricing.js +185 -0
- package/lib/r2-bridge.js +169 -0
- package/lib/shipping.js +185 -0
- package/lib/storefront.js +2160 -0
- package/lib/subscriptions.js +410 -0
- package/lib/tax.js +161 -0
- package/lib/theme.js +194 -0
- package/lib/vendor/MANIFEST.json +19 -0
- package/lib/vendor/blamejs/.clusterfuzzlite/Dockerfile +23 -0
- package/lib/vendor/blamejs/.clusterfuzzlite/build.sh +34 -0
- package/lib/vendor/blamejs/.clusterfuzzlite/project.yaml +16 -0
- package/lib/vendor/blamejs/.dockerignore +45 -0
- package/lib/vendor/blamejs/.gitattributes +42 -0
- package/lib/vendor/blamejs/.github/CODEOWNERS +4 -0
- package/lib/vendor/blamejs/.github/FUNDING.yml +2 -0
- package/lib/vendor/blamejs/.github/ISSUE_TEMPLATE/bug_report.md +58 -0
- package/lib/vendor/blamejs/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/lib/vendor/blamejs/.github/ISSUE_TEMPLATE/feature_request.md +99 -0
- package/lib/vendor/blamejs/.github/PULL_REQUEST_TEMPLATE.md +77 -0
- package/lib/vendor/blamejs/.github/dependabot.yml +37 -0
- package/lib/vendor/blamejs/.github/workflows/actions-lint.yml +148 -0
- package/lib/vendor/blamejs/.github/workflows/cflite_batch.yml +107 -0
- package/lib/vendor/blamejs/.github/workflows/cflite_pr.yml +122 -0
- package/lib/vendor/blamejs/.github/workflows/ci.yml +511 -0
- package/lib/vendor/blamejs/.github/workflows/codeql.yml +50 -0
- package/lib/vendor/blamejs/.github/workflows/npm-publish.yml +655 -0
- package/lib/vendor/blamejs/.github/workflows/release-container.yml +406 -0
- package/lib/vendor/blamejs/.github/workflows/scorecard.yml +101 -0
- package/lib/vendor/blamejs/.github/workflows/sha-to-tag-verify.yml +134 -0
- package/lib/vendor/blamejs/.gitignore +102 -0
- package/lib/vendor/blamejs/.gitleaks.toml +166 -0
- package/lib/vendor/blamejs/.hadolint.yaml +18 -0
- package/lib/vendor/blamejs/.npmrc +5 -0
- package/lib/vendor/blamejs/.pinact.yaml +17 -0
- package/lib/vendor/blamejs/ARCHITECTURE.md +158 -0
- package/lib/vendor/blamejs/CHANGELOG.md +1351 -0
- package/lib/vendor/blamejs/CODE_OF_CONDUCT.md +86 -0
- package/lib/vendor/blamejs/CONTRIBUTING.md +156 -0
- package/lib/vendor/blamejs/GOVERNANCE.md +201 -0
- package/lib/vendor/blamejs/LICENSE +201 -0
- package/lib/vendor/blamejs/LTS-CALENDAR.md +29 -0
- package/lib/vendor/blamejs/MIGRATING.md +29 -0
- package/lib/vendor/blamejs/NOTICE +81 -0
- package/lib/vendor/blamejs/README.md +304 -0
- package/lib/vendor/blamejs/SECURITY.md +432 -0
- package/lib/vendor/blamejs/api-snapshot.json +48709 -0
- package/lib/vendor/blamejs/assets/BlameJS_Logo.png +0 -0
- package/lib/vendor/blamejs/assets/BlameJS_Logo.svg +129 -0
- package/lib/vendor/blamejs/bench/README.md +77 -0
- package/lib/vendor/blamejs/bench/_helpers.js +70 -0
- package/lib/vendor/blamejs/bench/baseline.json +183 -0
- package/lib/vendor/blamejs/bench/crypto-hash.bench.js +19 -0
- package/lib/vendor/blamejs/bench/crypto-symmetric.bench.js +28 -0
- package/lib/vendor/blamejs/bench/run.js +140 -0
- package/lib/vendor/blamejs/bench/safe-json.bench.js +31 -0
- package/lib/vendor/blamejs/bin/blamejs.js +13 -0
- package/lib/vendor/blamejs/docker/caddy/Caddyfile +46 -0
- package/lib/vendor/blamejs/docker/coredns/Corefile +37 -0
- package/lib/vendor/blamejs/docker/haproxy/haproxy.cfg +52 -0
- package/lib/vendor/blamejs/docker/init/generate-certs.sh +118 -0
- package/lib/vendor/blamejs/docker/keycloak/realm-blamejs-test.json +87 -0
- package/lib/vendor/blamejs/docker/mitmproxy/config.yaml +16 -0
- package/lib/vendor/blamejs/docker/mongo/init-tls.sh +17 -0
- package/lib/vendor/blamejs/docker/mysql/my.cnf +12 -0
- package/lib/vendor/blamejs/docker/nats/nats.conf +33 -0
- package/lib/vendor/blamejs/docker/postgres/init-tls.sh +17 -0
- package/lib/vendor/blamejs/docker/postgres/postgresql.conf +18 -0
- package/lib/vendor/blamejs/docker/rabbitmq/rabbitmq.conf +18 -0
- package/lib/vendor/blamejs/docker/redis/redis.conf +15 -0
- package/lib/vendor/blamejs/docker/squid/squid.conf +24 -0
- package/lib/vendor/blamejs/docker/syslog/syslog-ng.conf +34 -0
- package/lib/vendor/blamejs/docker-compose.test.yml +545 -0
- package/lib/vendor/blamejs/docs/cis-postgres-crosswalk.md +102 -0
- package/lib/vendor/blamejs/docs/cis-sqlite-equivalent.md +92 -0
- package/lib/vendor/blamejs/eslint.config.mjs +204 -0
- package/lib/vendor/blamejs/examples/wiki/Caddyfile +40 -0
- package/lib/vendor/blamejs/examples/wiki/DEPLOY.md +218 -0
- package/lib/vendor/blamejs/examples/wiki/Dockerfile +120 -0
- package/lib/vendor/blamejs/examples/wiki/README.md +157 -0
- package/lib/vendor/blamejs/examples/wiki/cli-snapshot.json +250 -0
- package/lib/vendor/blamejs/examples/wiki/docker-compose.prod.yml +231 -0
- package/lib/vendor/blamejs/examples/wiki/docker-compose.yml +166 -0
- package/lib/vendor/blamejs/examples/wiki/env-snapshot.json +217 -0
- package/lib/vendor/blamejs/examples/wiki/lib/auto-site-entries.js +139 -0
- package/lib/vendor/blamejs/examples/wiki/lib/build-app.js +555 -0
- package/lib/vendor/blamejs/examples/wiki/lib/harvest-cli.js +507 -0
- package/lib/vendor/blamejs/examples/wiki/lib/harvest-env-vars.js +435 -0
- package/lib/vendor/blamejs/examples/wiki/lib/harvest-errors.js +282 -0
- package/lib/vendor/blamejs/examples/wiki/lib/harvest-vendored-deps.js +321 -0
- package/lib/vendor/blamejs/examples/wiki/lib/nav.js +15 -0
- package/lib/vendor/blamejs/examples/wiki/lib/opts-resolver.js +75 -0
- package/lib/vendor/blamejs/examples/wiki/lib/page-generator.js +508 -0
- package/lib/vendor/blamejs/examples/wiki/lib/section.js +276 -0
- package/lib/vendor/blamejs/examples/wiki/lib/source-comment-block-validator.js +587 -0
- package/lib/vendor/blamejs/examples/wiki/lib/source-doc-parser.js +318 -0
- package/lib/vendor/blamejs/examples/wiki/lib/symbol-index.js +122 -0
- package/lib/vendor/blamejs/examples/wiki/migrations/0001-pages-schema.js +74 -0
- package/lib/vendor/blamejs/examples/wiki/package.json +18 -0
- package/lib/vendor/blamejs/examples/wiki/public/img/blamejs-logo.png +0 -0
- package/lib/vendor/blamejs/examples/wiki/public/img/blamejs-logo.svg +129 -0
- package/lib/vendor/blamejs/examples/wiki/public/robots.txt +5 -0
- package/lib/vendor/blamejs/examples/wiki/public/vendor/MANIFEST.json +30 -0
- package/lib/vendor/blamejs/examples/wiki/public/vendor/prism.css +1 -0
- package/lib/vendor/blamejs/examples/wiki/public/vendor/prism.js +15 -0
- package/lib/vendor/blamejs/examples/wiki/public/wiki.css +1250 -0
- package/lib/vendor/blamejs/examples/wiki/routes/admin.js +366 -0
- package/lib/vendor/blamejs/examples/wiki/routes/integration.js +230 -0
- package/lib/vendor/blamejs/examples/wiki/routes/pages.js +266 -0
- package/lib/vendor/blamejs/examples/wiki/scripts/backfill-module-metadata.js +214 -0
- package/lib/vendor/blamejs/examples/wiki/seeders/prod/0001-default-pages.js +35 -0
- package/lib/vendor/blamejs/examples/wiki/seeders/prod/pages/_index.js +34 -0
- package/lib/vendor/blamejs/examples/wiki/seeders/prod/pages/api.js +76 -0
- package/lib/vendor/blamejs/examples/wiki/server.js +129 -0
- package/lib/vendor/blamejs/examples/wiki/site.config.js +197 -0
- package/lib/vendor/blamejs/examples/wiki/snippets/README.md +38 -0
- package/lib/vendor/blamejs/examples/wiki/snippets/auth/password-hash.example.js +15 -0
- package/lib/vendor/blamejs/examples/wiki/src/editor.js +103 -0
- package/lib/vendor/blamejs/examples/wiki/src/wiki.js +349 -0
- package/lib/vendor/blamejs/examples/wiki/test/AUDIT.md +155 -0
- package/lib/vendor/blamejs/examples/wiki/test/codebase-patterns.test.js +594 -0
- package/lib/vendor/blamejs/examples/wiki/test/e2e.js +741 -0
- package/lib/vendor/blamejs/examples/wiki/test/find-missing-pages.js +254 -0
- package/lib/vendor/blamejs/examples/wiki/test/integration.js +391 -0
- package/lib/vendor/blamejs/examples/wiki/test/validate-cli-snapshot.js +379 -0
- package/lib/vendor/blamejs/examples/wiki/test/validate-env-snapshot.js +346 -0
- package/lib/vendor/blamejs/examples/wiki/test/validate-nav-coverage.js +212 -0
- package/lib/vendor/blamejs/examples/wiki/test/validate-site-coverage.js +252 -0
- package/lib/vendor/blamejs/examples/wiki/test/validate-source-comment-blocks.js +107 -0
- package/lib/vendor/blamejs/examples/wiki/views/_layout.html +115 -0
- package/lib/vendor/blamejs/examples/wiki/views/admin/api-keys.html +51 -0
- package/lib/vendor/blamejs/examples/wiki/views/admin/dashboard.html +22 -0
- package/lib/vendor/blamejs/examples/wiki/views/admin/edit.html +17 -0
- package/lib/vendor/blamejs/examples/wiki/views/home.html +85 -0
- package/lib/vendor/blamejs/examples/wiki/views/login.html +18 -0
- package/lib/vendor/blamejs/examples/wiki/views/page.html +5 -0
- package/lib/vendor/blamejs/examples/wiki/views/partials/nav.html +13 -0
- package/lib/vendor/blamejs/examples/wiki/views/search.html +19 -0
- package/lib/vendor/blamejs/examples/wiki/wiki.config.js +15 -0
- package/lib/vendor/blamejs/fuzz/README.md +137 -0
- package/lib/vendor/blamejs/fuzz/_expected.js +35 -0
- package/lib/vendor/blamejs/fuzz/guard-agent-registry.fuzz.js +22 -0
- package/lib/vendor/blamejs/fuzz/guard-csv.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/guard-csv_seed_corpus/01-basic.csv +3 -0
- package/lib/vendor/blamejs/fuzz/guard-csv_seed_corpus/02-formula.csv +1 -0
- package/lib/vendor/blamejs/fuzz/guard-csv_seed_corpus/03-hyperlink.csv +1 -0
- package/lib/vendor/blamejs/fuzz/guard-dsn.fuzz.js +22 -0
- package/lib/vendor/blamejs/fuzz/guard-email.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/guard-email_seed_corpus/01-basic.eml +5 -0
- package/lib/vendor/blamejs/fuzz/guard-envelope.fuzz.js +24 -0
- package/lib/vendor/blamejs/fuzz/guard-event-bus-payload.fuzz.js +24 -0
- package/lib/vendor/blamejs/fuzz/guard-event-bus-topic.fuzz.js +20 -0
- package/lib/vendor/blamejs/fuzz/guard-html.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/guard-html_seed_corpus/01-basic.html +1 -0
- package/lib/vendor/blamejs/fuzz/guard-html_seed_corpus/02-script.html +1 -0
- package/lib/vendor/blamejs/fuzz/guard-html_seed_corpus/03-event.html +1 -0
- package/lib/vendor/blamejs/fuzz/guard-html_seed_corpus/04-jsurl.html +1 -0
- package/lib/vendor/blamejs/fuzz/guard-idempotency-key.fuzz.js +20 -0
- package/lib/vendor/blamejs/fuzz/guard-imap-command.fuzz.js +35 -0
- package/lib/vendor/blamejs/fuzz/guard-jmap.fuzz.js +41 -0
- package/lib/vendor/blamejs/fuzz/guard-json.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/guard-json_seed_corpus/01-basic.json +1 -0
- package/lib/vendor/blamejs/fuzz/guard-json_seed_corpus/02-proto.json +1 -0
- package/lib/vendor/blamejs/fuzz/guard-json_seed_corpus/03-dupkey.json +1 -0
- package/lib/vendor/blamejs/fuzz/guard-json_seed_corpus/04-nan.json +1 -0
- package/lib/vendor/blamejs/fuzz/guard-json_seed_corpus/05-bom.json +1 -0
- package/lib/vendor/blamejs/fuzz/guard-list-id.fuzz.js +21 -0
- package/lib/vendor/blamejs/fuzz/guard-list-unsubscribe.fuzz.js +25 -0
- package/lib/vendor/blamejs/fuzz/guard-mail-compose.fuzz.js +22 -0
- package/lib/vendor/blamejs/fuzz/guard-mail-move.fuzz.js +22 -0
- package/lib/vendor/blamejs/fuzz/guard-mail-query.fuzz.js +27 -0
- package/lib/vendor/blamejs/fuzz/guard-mail-reply.fuzz.js +23 -0
- package/lib/vendor/blamejs/fuzz/guard-mail-sieve.fuzz.js +36 -0
- package/lib/vendor/blamejs/fuzz/guard-managesieve-command.fuzz.js +26 -0
- package/lib/vendor/blamejs/fuzz/guard-markdown.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/guard-markdown_seed_corpus/01-basic.md +2 -0
- package/lib/vendor/blamejs/fuzz/guard-markdown_seed_corpus/02-jsurl.md +1 -0
- package/lib/vendor/blamejs/fuzz/guard-markdown_seed_corpus/03-jsimg.md +1 -0
- package/lib/vendor/blamejs/fuzz/guard-message-id.fuzz.js +26 -0
- package/lib/vendor/blamejs/fuzz/guard-pop3-command.fuzz.js +23 -0
- package/lib/vendor/blamejs/fuzz/guard-posture-chain.fuzz.js +22 -0
- package/lib/vendor/blamejs/fuzz/guard-saga-config.fuzz.js +32 -0
- package/lib/vendor/blamejs/fuzz/guard-smtp-command.fuzz.js +27 -0
- package/lib/vendor/blamejs/fuzz/guard-snapshot-envelope.fuzz.js +22 -0
- package/lib/vendor/blamejs/fuzz/guard-stream-args.fuzz.js +22 -0
- package/lib/vendor/blamejs/fuzz/guard-svg.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/guard-svg_seed_corpus/01-basic.svg +1 -0
- package/lib/vendor/blamejs/fuzz/guard-svg_seed_corpus/02-script.svg +1 -0
- package/lib/vendor/blamejs/fuzz/guard-tenant-id.fuzz.js +20 -0
- package/lib/vendor/blamejs/fuzz/guard-trace-context.fuzz.js +30 -0
- package/lib/vendor/blamejs/fuzz/guard-xml.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/guard-xml_seed_corpus/01-basic.xml +1 -0
- package/lib/vendor/blamejs/fuzz/guard-xml_seed_corpus/02-xxe.xml +1 -0
- package/lib/vendor/blamejs/fuzz/guard-yaml.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/guard-yaml_seed_corpus/01-basic.yaml +2 -0
- package/lib/vendor/blamejs/fuzz/guard-yaml_seed_corpus/02-anchor.yaml +2 -0
- package/lib/vendor/blamejs/fuzz/guard-yaml_seed_corpus/03-norway.yaml +1 -0
- package/lib/vendor/blamejs/fuzz/guard-yaml_seed_corpus/04-multidoc.yaml +4 -0
- package/lib/vendor/blamejs/fuzz/parsers__safe-ini.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/parsers__safe-ini_seed_corpus/01-basic.ini +2 -0
- package/lib/vendor/blamejs/fuzz/parsers__safe-toml.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/parsers__safe-toml_seed_corpus/01-basic.toml +4 -0
- package/lib/vendor/blamejs/fuzz/parsers__safe-xml.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/parsers__safe-xml_seed_corpus/01-basic.xml +1 -0
- package/lib/vendor/blamejs/fuzz/parsers__safe-yaml.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/parsers__safe-yaml_seed_corpus/01-basic.yaml +4 -0
- package/lib/vendor/blamejs/fuzz/safe-decompress.fuzz.js +49 -0
- package/lib/vendor/blamejs/fuzz/safe-dns.fuzz.js +29 -0
- package/lib/vendor/blamejs/fuzz/safe-ical.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/safe-icap.fuzz.js +42 -0
- package/lib/vendor/blamejs/fuzz/safe-json.fuzz.js +25 -0
- package/lib/vendor/blamejs/fuzz/safe-json_seed_corpus/01-object.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-json_seed_corpus/02-array.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-json_seed_corpus/03-string.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-json_seed_corpus/04-proto.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-json_seed_corpus/05-deep.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-jsonpath.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/safe-jsonpath_seed_corpus/01-basic.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-jsonpath_seed_corpus/02-filter.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-jsonpath_seed_corpus/03-deepscan.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-jsonpath_seed_corpus/04-slice.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-mime.fuzz.js +27 -0
- package/lib/vendor/blamejs/fuzz/safe-mount-info.fuzz.js +33 -0
- package/lib/vendor/blamejs/fuzz/safe-sieve.fuzz.js +28 -0
- package/lib/vendor/blamejs/fuzz/safe-smtp.fuzz.js +64 -0
- package/lib/vendor/blamejs/fuzz/safe-url.fuzz.js +16 -0
- package/lib/vendor/blamejs/fuzz/safe-url_seed_corpus/01-basic.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-url_seed_corpus/02-userinfo.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-url_seed_corpus/03-dangerous.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-url_seed_corpus/04-data.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-url_seed_corpus/05-ipv6.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-url_seed_corpus/06-idn.txt +1 -0
- package/lib/vendor/blamejs/fuzz/safe-vcard.fuzz.js +16 -0
- package/lib/vendor/blamejs/index.js +678 -0
- package/lib/vendor/blamejs/keys/release-pqc-pub.json +7 -0
- package/lib/vendor/blamejs/lib/_test/crypto-fixtures.js +67 -0
- package/lib/vendor/blamejs/lib/a2a-tasks.js +598 -0
- package/lib/vendor/blamejs/lib/a2a.js +407 -0
- package/lib/vendor/blamejs/lib/acme.js +1448 -0
- package/lib/vendor/blamejs/lib/agent-audit.js +45 -0
- package/lib/vendor/blamejs/lib/agent-event-bus.js +382 -0
- package/lib/vendor/blamejs/lib/agent-idempotency.js +497 -0
- package/lib/vendor/blamejs/lib/agent-orchestrator.js +717 -0
- package/lib/vendor/blamejs/lib/agent-posture-chain.js +366 -0
- package/lib/vendor/blamejs/lib/agent-saga.js +321 -0
- package/lib/vendor/blamejs/lib/agent-snapshot.js +676 -0
- package/lib/vendor/blamejs/lib/agent-stream.js +269 -0
- package/lib/vendor/blamejs/lib/agent-tenant.js +632 -0
- package/lib/vendor/blamejs/lib/agent-trace.js +281 -0
- package/lib/vendor/blamejs/lib/ai-adverse-decision.js +184 -0
- package/lib/vendor/blamejs/lib/ai-content-detect.js +268 -0
- package/lib/vendor/blamejs/lib/ai-input.js +201 -0
- package/lib/vendor/blamejs/lib/ai-model-manifest.js +363 -0
- package/lib/vendor/blamejs/lib/ai-pref.js +340 -0
- package/lib/vendor/blamejs/lib/api-key.js +721 -0
- package/lib/vendor/blamejs/lib/api-snapshot.js +458 -0
- package/lib/vendor/blamejs/lib/app-shutdown.js +557 -0
- package/lib/vendor/blamejs/lib/app.js +365 -0
- package/lib/vendor/blamejs/lib/archive.js +547 -0
- package/lib/vendor/blamejs/lib/arg-parser.js +697 -0
- package/lib/vendor/blamejs/lib/argon2-builtin.js +173 -0
- package/lib/vendor/blamejs/lib/asn1-der.js +424 -0
- package/lib/vendor/blamejs/lib/asyncapi-bindings.js +160 -0
- package/lib/vendor/blamejs/lib/asyncapi-traits.js +143 -0
- package/lib/vendor/blamejs/lib/asyncapi.js +575 -0
- package/lib/vendor/blamejs/lib/atomic-file.js +1023 -0
- package/lib/vendor/blamejs/lib/audit-chain.js +266 -0
- package/lib/vendor/blamejs/lib/audit-daily-review.js +389 -0
- package/lib/vendor/blamejs/lib/audit-sign.js +751 -0
- package/lib/vendor/blamejs/lib/audit-tools.js +1113 -0
- package/lib/vendor/blamejs/lib/audit.js +1671 -0
- package/lib/vendor/blamejs/lib/auth/aal.js +169 -0
- package/lib/vendor/blamejs/lib/auth/access-lock.js +220 -0
- package/lib/vendor/blamejs/lib/auth/acr-vocabulary.js +265 -0
- package/lib/vendor/blamejs/lib/auth/ato-kill-switch.js +112 -0
- package/lib/vendor/blamejs/lib/auth/auth-time-tracker.js +111 -0
- package/lib/vendor/blamejs/lib/auth/bot-challenge.js +573 -0
- package/lib/vendor/blamejs/lib/auth/ciba.js +637 -0
- package/lib/vendor/blamejs/lib/auth/dpop.js +516 -0
- package/lib/vendor/blamejs/lib/auth/elevation-grant.js +306 -0
- package/lib/vendor/blamejs/lib/auth/fal.js +229 -0
- package/lib/vendor/blamejs/lib/auth/fido-mds3.js +681 -0
- package/lib/vendor/blamejs/lib/auth/jwt-external.js +519 -0
- package/lib/vendor/blamejs/lib/auth/jwt.js +430 -0
- package/lib/vendor/blamejs/lib/auth/lockout.js +449 -0
- package/lib/vendor/blamejs/lib/auth/oauth.js +2141 -0
- package/lib/vendor/blamejs/lib/auth/oid4vci.js +657 -0
- package/lib/vendor/blamejs/lib/auth/oid4vp.js +531 -0
- package/lib/vendor/blamejs/lib/auth/openid-federation.js +600 -0
- package/lib/vendor/blamejs/lib/auth/passkey.js +676 -0
- package/lib/vendor/blamejs/lib/auth/password.js +693 -0
- package/lib/vendor/blamejs/lib/auth/saml.js +2109 -0
- package/lib/vendor/blamejs/lib/auth/sd-jwt-vc-disclosure.js +95 -0
- package/lib/vendor/blamejs/lib/auth/sd-jwt-vc-holder.js +225 -0
- package/lib/vendor/blamejs/lib/auth/sd-jwt-vc-issuer.js +197 -0
- package/lib/vendor/blamejs/lib/auth/sd-jwt-vc.js +728 -0
- package/lib/vendor/blamejs/lib/auth/status-list.js +272 -0
- package/lib/vendor/blamejs/lib/auth/step-up-policy.js +335 -0
- package/lib/vendor/blamejs/lib/auth/step-up.js +454 -0
- package/lib/vendor/blamejs/lib/auth-bot-challenge.js +505 -0
- package/lib/vendor/blamejs/lib/auth-header.js +148 -0
- package/lib/vendor/blamejs/lib/backup/bundle.js +265 -0
- package/lib/vendor/blamejs/lib/backup/crypto.js +176 -0
- package/lib/vendor/blamejs/lib/backup/index.js +1001 -0
- package/lib/vendor/blamejs/lib/backup/manifest.js +443 -0
- package/lib/vendor/blamejs/lib/boot-gates.js +174 -0
- package/lib/vendor/blamejs/lib/breach-deadline.js +272 -0
- package/lib/vendor/blamejs/lib/break-glass.js +1753 -0
- package/lib/vendor/blamejs/lib/budr.js +205 -0
- package/lib/vendor/blamejs/lib/bundler.js +461 -0
- package/lib/vendor/blamejs/lib/cache-redis.js +256 -0
- package/lib/vendor/blamejs/lib/cache-status.js +288 -0
- package/lib/vendor/blamejs/lib/cache.js +1331 -0
- package/lib/vendor/blamejs/lib/calendar.js +1240 -0
- package/lib/vendor/blamejs/lib/canonical-json.js +143 -0
- package/lib/vendor/blamejs/lib/cdn-cache-control.js +473 -0
- package/lib/vendor/blamejs/lib/cert.js +763 -0
- package/lib/vendor/blamejs/lib/chain-writer.js +259 -0
- package/lib/vendor/blamejs/lib/circuit-breaker.js +101 -0
- package/lib/vendor/blamejs/lib/cli-helpers.js +237 -0
- package/lib/vendor/blamejs/lib/cli.js +2328 -0
- package/lib/vendor/blamejs/lib/client-hints.js +318 -0
- package/lib/vendor/blamejs/lib/cloud-events.js +277 -0
- package/lib/vendor/blamejs/lib/cluster-provider-db.js +317 -0
- package/lib/vendor/blamejs/lib/cluster-storage.js +351 -0
- package/lib/vendor/blamejs/lib/cluster.js +1017 -0
- package/lib/vendor/blamejs/lib/cms-codec.js +826 -0
- package/lib/vendor/blamejs/lib/codepoint-class.js +262 -0
- package/lib/vendor/blamejs/lib/compliance-ai-act-logging.js +190 -0
- package/lib/vendor/blamejs/lib/compliance-ai-act-prohibited.js +205 -0
- package/lib/vendor/blamejs/lib/compliance-ai-act-risk.js +189 -0
- package/lib/vendor/blamejs/lib/compliance-ai-act-transparency.js +200 -0
- package/lib/vendor/blamejs/lib/compliance-ai-act.js +821 -0
- package/lib/vendor/blamejs/lib/compliance-eaa.js +204 -0
- package/lib/vendor/blamejs/lib/compliance-sanctions-aliases.js +167 -0
- package/lib/vendor/blamejs/lib/compliance-sanctions-fetcher.js +206 -0
- package/lib/vendor/blamejs/lib/compliance-sanctions-fuzzy.js +297 -0
- package/lib/vendor/blamejs/lib/compliance-sanctions.js +569 -0
- package/lib/vendor/blamejs/lib/compliance.js +1558 -0
- package/lib/vendor/blamejs/lib/config-drift.js +426 -0
- package/lib/vendor/blamejs/lib/config.js +446 -0
- package/lib/vendor/blamejs/lib/consent.js +369 -0
- package/lib/vendor/blamejs/lib/constants.js +209 -0
- package/lib/vendor/blamejs/lib/content-credentials.js +704 -0
- package/lib/vendor/blamejs/lib/cookies.js +560 -0
- package/lib/vendor/blamejs/lib/cra-report.js +299 -0
- package/lib/vendor/blamejs/lib/credential-hash.js +394 -0
- package/lib/vendor/blamejs/lib/crypto-field.js +1017 -0
- package/lib/vendor/blamejs/lib/crypto-hpke-pq.js +187 -0
- package/lib/vendor/blamejs/lib/crypto-hpke.js +256 -0
- package/lib/vendor/blamejs/lib/crypto.js +1908 -0
- package/lib/vendor/blamejs/lib/csp.js +271 -0
- package/lib/vendor/blamejs/lib/csv.js +418 -0
- package/lib/vendor/blamejs/lib/daemon.js +481 -0
- package/lib/vendor/blamejs/lib/dark-patterns.js +488 -0
- package/lib/vendor/blamejs/lib/data-act.js +328 -0
- package/lib/vendor/blamejs/lib/db-collection.js +587 -0
- package/lib/vendor/blamejs/lib/db-declare-row-policy.js +267 -0
- package/lib/vendor/blamejs/lib/db-declare-view.js +420 -0
- package/lib/vendor/blamejs/lib/db-file-lifecycle.js +333 -0
- package/lib/vendor/blamejs/lib/db-query.js +802 -0
- package/lib/vendor/blamejs/lib/db-role-context.js +50 -0
- package/lib/vendor/blamejs/lib/db-schema.js +322 -0
- package/lib/vendor/blamejs/lib/db.js +3111 -0
- package/lib/vendor/blamejs/lib/dbsc.js +299 -0
- package/lib/vendor/blamejs/lib/ddl-change-control.js +523 -0
- package/lib/vendor/blamejs/lib/deprecate.js +377 -0
- package/lib/vendor/blamejs/lib/dev.js +405 -0
- package/lib/vendor/blamejs/lib/dora.js +402 -0
- package/lib/vendor/blamejs/lib/dr-runbook.js +368 -0
- package/lib/vendor/blamejs/lib/dsr.js +1188 -0
- package/lib/vendor/blamejs/lib/dual-control.js +526 -0
- package/lib/vendor/blamejs/lib/early-hints.js +212 -0
- package/lib/vendor/blamejs/lib/error-page.js +420 -0
- package/lib/vendor/blamejs/lib/events.js +214 -0
- package/lib/vendor/blamejs/lib/external-db-migrate.js +659 -0
- package/lib/vendor/blamejs/lib/external-db.js +1877 -0
- package/lib/vendor/blamejs/lib/fapi2.js +394 -0
- package/lib/vendor/blamejs/lib/fda-21cfr11.js +395 -0
- package/lib/vendor/blamejs/lib/fdx.js +370 -0
- package/lib/vendor/blamejs/lib/fedcm.js +264 -0
- package/lib/vendor/blamejs/lib/file-type.js +360 -0
- package/lib/vendor/blamejs/lib/file-upload.js +1256 -0
- package/lib/vendor/blamejs/lib/flag-cache.js +136 -0
- package/lib/vendor/blamejs/lib/flag-evaluation-context.js +135 -0
- package/lib/vendor/blamejs/lib/flag-providers.js +279 -0
- package/lib/vendor/blamejs/lib/flag-targeting.js +210 -0
- package/lib/vendor/blamejs/lib/flag.js +346 -0
- package/lib/vendor/blamejs/lib/forms.js +525 -0
- package/lib/vendor/blamejs/lib/framework-error.js +724 -0
- package/lib/vendor/blamejs/lib/framework-schema.js +845 -0
- package/lib/vendor/blamejs/lib/framework-sha1-hibp.js +34 -0
- package/lib/vendor/blamejs/lib/fsm.js +469 -0
- package/lib/vendor/blamejs/lib/gate-contract.js +1661 -0
- package/lib/vendor/blamejs/lib/gdpr-ropa.js +261 -0
- package/lib/vendor/blamejs/lib/graphql-federation.js +234 -0
- package/lib/vendor/blamejs/lib/guard-agent-registry.js +179 -0
- package/lib/vendor/blamejs/lib/guard-all.js +555 -0
- package/lib/vendor/blamejs/lib/guard-archive.js +901 -0
- package/lib/vendor/blamejs/lib/guard-auth.js +451 -0
- package/lib/vendor/blamejs/lib/guard-cidr.js +676 -0
- package/lib/vendor/blamejs/lib/guard-csv.js +1176 -0
- package/lib/vendor/blamejs/lib/guard-domain.js +814 -0
- package/lib/vendor/blamejs/lib/guard-dsn.js +382 -0
- package/lib/vendor/blamejs/lib/guard-email.js +951 -0
- package/lib/vendor/blamejs/lib/guard-envelope.js +294 -0
- package/lib/vendor/blamejs/lib/guard-event-bus-payload.js +217 -0
- package/lib/vendor/blamejs/lib/guard-event-bus-topic.js +150 -0
- package/lib/vendor/blamejs/lib/guard-filename.js +956 -0
- package/lib/vendor/blamejs/lib/guard-graphql.js +731 -0
- package/lib/vendor/blamejs/lib/guard-html-wcag-aria.js +164 -0
- package/lib/vendor/blamejs/lib/guard-html-wcag-forms.js +144 -0
- package/lib/vendor/blamejs/lib/guard-html-wcag-tables.js +154 -0
- package/lib/vendor/blamejs/lib/guard-html-wcag-tagwalk.js +44 -0
- package/lib/vendor/blamejs/lib/guard-html-wcag.js +470 -0
- package/lib/vendor/blamejs/lib/guard-html.js +1209 -0
- package/lib/vendor/blamejs/lib/guard-idempotency-key.js +151 -0
- package/lib/vendor/blamejs/lib/guard-image.js +584 -0
- package/lib/vendor/blamejs/lib/guard-imap-command.js +337 -0
- package/lib/vendor/blamejs/lib/guard-jmap.js +321 -0
- package/lib/vendor/blamejs/lib/guard-json.js +935 -0
- package/lib/vendor/blamejs/lib/guard-jsonpath.js +512 -0
- package/lib/vendor/blamejs/lib/guard-jwt.js +772 -0
- package/lib/vendor/blamejs/lib/guard-list-id.js +318 -0
- package/lib/vendor/blamejs/lib/guard-list-unsubscribe.js +412 -0
- package/lib/vendor/blamejs/lib/guard-mail-compose.js +282 -0
- package/lib/vendor/blamejs/lib/guard-mail-move.js +202 -0
- package/lib/vendor/blamejs/lib/guard-mail-query.js +310 -0
- package/lib/vendor/blamejs/lib/guard-mail-reply.js +172 -0
- package/lib/vendor/blamejs/lib/guard-mail-sieve.js +207 -0
- package/lib/vendor/blamejs/lib/guard-managesieve-command.js +566 -0
- package/lib/vendor/blamejs/lib/guard-markdown.js +768 -0
- package/lib/vendor/blamejs/lib/guard-message-id.js +267 -0
- package/lib/vendor/blamejs/lib/guard-mime.js +609 -0
- package/lib/vendor/blamejs/lib/guard-oauth.js +650 -0
- package/lib/vendor/blamejs/lib/guard-pdf.js +569 -0
- package/lib/vendor/blamejs/lib/guard-pop3-command.js +317 -0
- package/lib/vendor/blamejs/lib/guard-posture-chain.js +201 -0
- package/lib/vendor/blamejs/lib/guard-regex.js +632 -0
- package/lib/vendor/blamejs/lib/guard-saga-config.js +157 -0
- package/lib/vendor/blamejs/lib/guard-shell.js +522 -0
- package/lib/vendor/blamejs/lib/guard-smtp-command.js +594 -0
- package/lib/vendor/blamejs/lib/guard-snapshot-envelope.js +168 -0
- package/lib/vendor/blamejs/lib/guard-stream-args.js +166 -0
- package/lib/vendor/blamejs/lib/guard-svg.js +1163 -0
- package/lib/vendor/blamejs/lib/guard-template.js +490 -0
- package/lib/vendor/blamejs/lib/guard-tenant-id.js +138 -0
- package/lib/vendor/blamejs/lib/guard-time.js +586 -0
- package/lib/vendor/blamejs/lib/guard-trace-context.js +172 -0
- package/lib/vendor/blamejs/lib/guard-uuid.js +548 -0
- package/lib/vendor/blamejs/lib/guard-xml.js +666 -0
- package/lib/vendor/blamejs/lib/guard-yaml.js +726 -0
- package/lib/vendor/blamejs/lib/hal.js +125 -0
- package/lib/vendor/blamejs/lib/handlers.js +350 -0
- package/lib/vendor/blamejs/lib/honeytoken.js +168 -0
- package/lib/vendor/blamejs/lib/html-balance.js +347 -0
- package/lib/vendor/blamejs/lib/http-client-cache.js +923 -0
- package/lib/vendor/blamejs/lib/http-client-cookie-jar.js +519 -0
- package/lib/vendor/blamejs/lib/http-client.js +2152 -0
- package/lib/vendor/blamejs/lib/http-message-signature.js +589 -0
- package/lib/vendor/blamejs/lib/http2-teardown.js +34 -0
- package/lib/vendor/blamejs/lib/i18n-messageformat.js +398 -0
- package/lib/vendor/blamejs/lib/i18n.js +931 -0
- package/lib/vendor/blamejs/lib/iab-mspa.js +257 -0
- package/lib/vendor/blamejs/lib/iab-tcf.js +461 -0
- package/lib/vendor/blamejs/lib/importmap-integrity.js +90 -0
- package/lib/vendor/blamejs/lib/inbox.js +435 -0
- package/lib/vendor/blamejs/lib/incident-report.js +314 -0
- package/lib/vendor/blamejs/lib/ip-utils.js +102 -0
- package/lib/vendor/blamejs/lib/jobs.js +185 -0
- package/lib/vendor/blamejs/lib/jose-jwe-experimental.js +228 -0
- package/lib/vendor/blamejs/lib/jsonapi.js +230 -0
- package/lib/vendor/blamejs/lib/keychain.js +865 -0
- package/lib/vendor/blamejs/lib/lazy-require.js +48 -0
- package/lib/vendor/blamejs/lib/legal-hold.js +374 -0
- package/lib/vendor/blamejs/lib/local-db-thin.js +321 -0
- package/lib/vendor/blamejs/lib/log-stream-cloudwatch.js +369 -0
- package/lib/vendor/blamejs/lib/log-stream-local.js +146 -0
- package/lib/vendor/blamejs/lib/log-stream-otlp-grpc.js +410 -0
- package/lib/vendor/blamejs/lib/log-stream-otlp.js +286 -0
- package/lib/vendor/blamejs/lib/log-stream-syslog.js +310 -0
- package/lib/vendor/blamejs/lib/log-stream-webhook.js +199 -0
- package/lib/vendor/blamejs/lib/log-stream.js +584 -0
- package/lib/vendor/blamejs/lib/log.js +625 -0
- package/lib/vendor/blamejs/lib/lro.js +200 -0
- package/lib/vendor/blamejs/lib/mail-agent.js +786 -0
- package/lib/vendor/blamejs/lib/mail-arc-sign.js +417 -0
- package/lib/vendor/blamejs/lib/mail-arf.js +343 -0
- package/lib/vendor/blamejs/lib/mail-auth.js +2144 -0
- package/lib/vendor/blamejs/lib/mail-bimi.js +1047 -0
- package/lib/vendor/blamejs/lib/mail-bounce.js +955 -0
- package/lib/vendor/blamejs/lib/mail-crypto-pgp.js +1286 -0
- package/lib/vendor/blamejs/lib/mail-crypto-smime.js +789 -0
- package/lib/vendor/blamejs/lib/mail-crypto.js +108 -0
- package/lib/vendor/blamejs/lib/mail-dav.js +1224 -0
- package/lib/vendor/blamejs/lib/mail-deploy.js +1119 -0
- package/lib/vendor/blamejs/lib/mail-dkim.js +1250 -0
- package/lib/vendor/blamejs/lib/mail-greylist.js +448 -0
- package/lib/vendor/blamejs/lib/mail-helo.js +473 -0
- package/lib/vendor/blamejs/lib/mail-journal.js +435 -0
- package/lib/vendor/blamejs/lib/mail-mdn.js +424 -0
- package/lib/vendor/blamejs/lib/mail-rbl.js +392 -0
- package/lib/vendor/blamejs/lib/mail-require-tls.js +198 -0
- package/lib/vendor/blamejs/lib/mail-scan.js +502 -0
- package/lib/vendor/blamejs/lib/mail-send-deliver.js +629 -0
- package/lib/vendor/blamejs/lib/mail-server-imap.js +1858 -0
- package/lib/vendor/blamejs/lib/mail-server-jmap.js +1565 -0
- package/lib/vendor/blamejs/lib/mail-server-managesieve.js +908 -0
- package/lib/vendor/blamejs/lib/mail-server-mx.js +969 -0
- package/lib/vendor/blamejs/lib/mail-server-pop3.js +915 -0
- package/lib/vendor/blamejs/lib/mail-server-rate-limit.js +315 -0
- package/lib/vendor/blamejs/lib/mail-server-registry.js +378 -0
- package/lib/vendor/blamejs/lib/mail-server-submission.js +1396 -0
- package/lib/vendor/blamejs/lib/mail-server-tls.js +445 -0
- package/lib/vendor/blamejs/lib/mail-sieve.js +557 -0
- package/lib/vendor/blamejs/lib/mail-spam-score.js +284 -0
- package/lib/vendor/blamejs/lib/mail-srs.js +248 -0
- package/lib/vendor/blamejs/lib/mail-store-fts.js +394 -0
- package/lib/vendor/blamejs/lib/mail-store.js +929 -0
- package/lib/vendor/blamejs/lib/mail-unsubscribe.js +400 -0
- package/lib/vendor/blamejs/lib/mail.js +1971 -0
- package/lib/vendor/blamejs/lib/mcp-tool-registry.js +473 -0
- package/lib/vendor/blamejs/lib/mcp.js +950 -0
- package/lib/vendor/blamejs/lib/metrics.js +1503 -0
- package/lib/vendor/blamejs/lib/middleware/age-gate.js +177 -0
- package/lib/vendor/blamejs/lib/middleware/ai-act-disclosure.js +203 -0
- package/lib/vendor/blamejs/lib/middleware/api-encrypt.js +981 -0
- package/lib/vendor/blamejs/lib/middleware/assetlinks.js +137 -0
- package/lib/vendor/blamejs/lib/middleware/asyncapi-serve.js +171 -0
- package/lib/vendor/blamejs/lib/middleware/attach-user.js +220 -0
- package/lib/vendor/blamejs/lib/middleware/bearer-auth.js +293 -0
- package/lib/vendor/blamejs/lib/middleware/body-parser.js +1519 -0
- package/lib/vendor/blamejs/lib/middleware/bot-disclose.js +183 -0
- package/lib/vendor/blamejs/lib/middleware/bot-guard.js +217 -0
- package/lib/vendor/blamejs/lib/middleware/clear-site-data.js +122 -0
- package/lib/vendor/blamejs/lib/middleware/compose-pipeline.js +355 -0
- package/lib/vendor/blamejs/lib/middleware/compression.js +489 -0
- package/lib/vendor/blamejs/lib/middleware/cookies.js +130 -0
- package/lib/vendor/blamejs/lib/middleware/cors.js +386 -0
- package/lib/vendor/blamejs/lib/middleware/csp-nonce.js +388 -0
- package/lib/vendor/blamejs/lib/middleware/csp-report.js +167 -0
- package/lib/vendor/blamejs/lib/middleware/csrf-protect.js +499 -0
- package/lib/vendor/blamejs/lib/middleware/daily-byte-quota.js +243 -0
- package/lib/vendor/blamejs/lib/middleware/db-role-for.js +304 -0
- package/lib/vendor/blamejs/lib/middleware/dpop.js +402 -0
- package/lib/vendor/blamejs/lib/middleware/error-handler.js +69 -0
- package/lib/vendor/blamejs/lib/middleware/fetch-metadata.js +168 -0
- package/lib/vendor/blamejs/lib/middleware/flag-context.js +110 -0
- package/lib/vendor/blamejs/lib/middleware/gpc.js +153 -0
- package/lib/vendor/blamejs/lib/middleware/headers.js +242 -0
- package/lib/vendor/blamejs/lib/middleware/health.js +438 -0
- package/lib/vendor/blamejs/lib/middleware/host-allowlist.js +189 -0
- package/lib/vendor/blamejs/lib/middleware/idempotency-key.js +964 -0
- package/lib/vendor/blamejs/lib/middleware/index.js +183 -0
- package/lib/vendor/blamejs/lib/middleware/nel.js +214 -0
- package/lib/vendor/blamejs/lib/middleware/network-allowlist.js +237 -0
- package/lib/vendor/blamejs/lib/middleware/no-cache.js +106 -0
- package/lib/vendor/blamejs/lib/middleware/openapi-serve.js +177 -0
- package/lib/vendor/blamejs/lib/middleware/protected-resource-metadata.js +277 -0
- package/lib/vendor/blamejs/lib/middleware/rate-limit.js +556 -0
- package/lib/vendor/blamejs/lib/middleware/request-id.js +79 -0
- package/lib/vendor/blamejs/lib/middleware/request-log.js +205 -0
- package/lib/vendor/blamejs/lib/middleware/require-aal.js +138 -0
- package/lib/vendor/blamejs/lib/middleware/require-auth.js +144 -0
- package/lib/vendor/blamejs/lib/middleware/require-bound-key.js +290 -0
- package/lib/vendor/blamejs/lib/middleware/require-content-type.js +113 -0
- package/lib/vendor/blamejs/lib/middleware/require-methods.js +97 -0
- package/lib/vendor/blamejs/lib/middleware/require-mtls.js +212 -0
- package/lib/vendor/blamejs/lib/middleware/require-step-up.js +226 -0
- package/lib/vendor/blamejs/lib/middleware/scim-server.js +375 -0
- package/lib/vendor/blamejs/lib/middleware/security-headers.js +285 -0
- package/lib/vendor/blamejs/lib/middleware/security-txt.js +170 -0
- package/lib/vendor/blamejs/lib/middleware/span-http-server.js +280 -0
- package/lib/vendor/blamejs/lib/middleware/speculation-rules.js +323 -0
- package/lib/vendor/blamejs/lib/middleware/sse.js +200 -0
- package/lib/vendor/blamejs/lib/middleware/trace-log-correlation.js +167 -0
- package/lib/vendor/blamejs/lib/middleware/trace-propagate.js +148 -0
- package/lib/vendor/blamejs/lib/middleware/tus-upload.js +749 -0
- package/lib/vendor/blamejs/lib/middleware/web-app-manifest.js +164 -0
- package/lib/vendor/blamejs/lib/migration-files.js +37 -0
- package/lib/vendor/blamejs/lib/migrations.js +385 -0
- package/lib/vendor/blamejs/lib/mime-parse.js +198 -0
- package/lib/vendor/blamejs/lib/money.js +699 -0
- package/lib/vendor/blamejs/lib/mtls-ca.js +572 -0
- package/lib/vendor/blamejs/lib/mtls-engine-default.js +501 -0
- package/lib/vendor/blamejs/lib/network-byte-quota.js +308 -0
- package/lib/vendor/blamejs/lib/network-dns-resolver.js +533 -0
- package/lib/vendor/blamejs/lib/network-dns.js +1930 -0
- package/lib/vendor/blamejs/lib/network-heartbeat.js +425 -0
- package/lib/vendor/blamejs/lib/network-nts.js +574 -0
- package/lib/vendor/blamejs/lib/network-proxy.js +265 -0
- package/lib/vendor/blamejs/lib/network-smtp-policy.js +836 -0
- package/lib/vendor/blamejs/lib/network-tls.js +3126 -0
- package/lib/vendor/blamejs/lib/network.js +346 -0
- package/lib/vendor/blamejs/lib/nis2-report.js +181 -0
- package/lib/vendor/blamejs/lib/nist-crosswalk.js +293 -0
- package/lib/vendor/blamejs/lib/nonce-store.js +177 -0
- package/lib/vendor/blamejs/lib/notify.js +683 -0
- package/lib/vendor/blamejs/lib/ntp-check.js +458 -0
- package/lib/vendor/blamejs/lib/numeric-bounds.js +111 -0
- package/lib/vendor/blamejs/lib/numeric-checks.js +40 -0
- package/lib/vendor/blamejs/lib/object-store/azure-blob-bucket-ops.js +349 -0
- package/lib/vendor/blamejs/lib/object-store/azure-blob.js +488 -0
- package/lib/vendor/blamejs/lib/object-store/gcs-bucket-ops.js +351 -0
- package/lib/vendor/blamejs/lib/object-store/gcs.js +515 -0
- package/lib/vendor/blamejs/lib/object-store/http-put.js +153 -0
- package/lib/vendor/blamejs/lib/object-store/http-request.js +38 -0
- package/lib/vendor/blamejs/lib/object-store/index.js +197 -0
- package/lib/vendor/blamejs/lib/object-store/local.js +163 -0
- package/lib/vendor/blamejs/lib/object-store/sigv4-bucket-ops.js +1133 -0
- package/lib/vendor/blamejs/lib/object-store/sigv4.js +957 -0
- package/lib/vendor/blamejs/lib/observability-otlp-exporter.js +420 -0
- package/lib/vendor/blamejs/lib/observability-tracer.js +395 -0
- package/lib/vendor/blamejs/lib/observability.js +720 -0
- package/lib/vendor/blamejs/lib/openapi-paths-builder.js +248 -0
- package/lib/vendor/blamejs/lib/openapi-schema-walk.js +192 -0
- package/lib/vendor/blamejs/lib/openapi-security.js +169 -0
- package/lib/vendor/blamejs/lib/openapi-yaml.js +154 -0
- package/lib/vendor/blamejs/lib/openapi.js +489 -0
- package/lib/vendor/blamejs/lib/otel-export.js +278 -0
- package/lib/vendor/blamejs/lib/outbox.js +547 -0
- package/lib/vendor/blamejs/lib/pagination.js +542 -0
- package/lib/vendor/blamejs/lib/parsers/index.js +91 -0
- package/lib/vendor/blamejs/lib/parsers/safe-env.js +642 -0
- package/lib/vendor/blamejs/lib/parsers/safe-ini.js +293 -0
- package/lib/vendor/blamejs/lib/parsers/safe-toml.js +784 -0
- package/lib/vendor/blamejs/lib/parsers/safe-xml.js +390 -0
- package/lib/vendor/blamejs/lib/parsers/safe-yaml.js +1015 -0
- package/lib/vendor/blamejs/lib/permissions.js +793 -0
- package/lib/vendor/blamejs/lib/pick.js +105 -0
- package/lib/vendor/blamejs/lib/pqc-agent.js +351 -0
- package/lib/vendor/blamejs/lib/pqc-gate.js +279 -0
- package/lib/vendor/blamejs/lib/pqc-software.js +271 -0
- package/lib/vendor/blamejs/lib/problem-details.js +482 -0
- package/lib/vendor/blamejs/lib/process-spawn.js +196 -0
- package/lib/vendor/blamejs/lib/promise-pool.js +162 -0
- package/lib/vendor/blamejs/lib/protobuf-encoder.js +190 -0
- package/lib/vendor/blamejs/lib/protocol-dispatcher.js +161 -0
- package/lib/vendor/blamejs/lib/public-suffix.js +403 -0
- package/lib/vendor/blamejs/lib/pubsub-cluster.js +154 -0
- package/lib/vendor/blamejs/lib/pubsub-redis.js +167 -0
- package/lib/vendor/blamejs/lib/pubsub.js +463 -0
- package/lib/vendor/blamejs/lib/queue-local.js +476 -0
- package/lib/vendor/blamejs/lib/queue-redis.js +745 -0
- package/lib/vendor/blamejs/lib/queue-sqs.js +319 -0
- package/lib/vendor/blamejs/lib/queue.js +1016 -0
- package/lib/vendor/blamejs/lib/redact.js +1007 -0
- package/lib/vendor/blamejs/lib/redis-client.js +520 -0
- package/lib/vendor/blamejs/lib/render.js +285 -0
- package/lib/vendor/blamejs/lib/request-helpers.js +767 -0
- package/lib/vendor/blamejs/lib/resource-access-lock.js +116 -0
- package/lib/vendor/blamejs/lib/restore-bundle.js +340 -0
- package/lib/vendor/blamejs/lib/restore-rollback.js +365 -0
- package/lib/vendor/blamejs/lib/restore.js +409 -0
- package/lib/vendor/blamejs/lib/retention.js +640 -0
- package/lib/vendor/blamejs/lib/retry.js +523 -0
- package/lib/vendor/blamejs/lib/router.js +1289 -0
- package/lib/vendor/blamejs/lib/safe-async.js +1184 -0
- package/lib/vendor/blamejs/lib/safe-buffer.js +562 -0
- package/lib/vendor/blamejs/lib/safe-decompress.js +297 -0
- package/lib/vendor/blamejs/lib/safe-dns.js +665 -0
- package/lib/vendor/blamejs/lib/safe-ical.js +634 -0
- package/lib/vendor/blamejs/lib/safe-icap.js +502 -0
- package/lib/vendor/blamejs/lib/safe-json.js +946 -0
- package/lib/vendor/blamejs/lib/safe-jsonpath.js +285 -0
- package/lib/vendor/blamejs/lib/safe-mime.js +831 -0
- package/lib/vendor/blamejs/lib/safe-mount-info.js +306 -0
- package/lib/vendor/blamejs/lib/safe-path.js +254 -0
- package/lib/vendor/blamejs/lib/safe-redirect.js +106 -0
- package/lib/vendor/blamejs/lib/safe-schema.js +1810 -0
- package/lib/vendor/blamejs/lib/safe-sieve.js +684 -0
- package/lib/vendor/blamejs/lib/safe-smtp.js +185 -0
- package/lib/vendor/blamejs/lib/safe-sql.js +363 -0
- package/lib/vendor/blamejs/lib/safe-url.js +428 -0
- package/lib/vendor/blamejs/lib/safe-vcard.js +473 -0
- package/lib/vendor/blamejs/lib/sandbox-worker.js +135 -0
- package/lib/vendor/blamejs/lib/sandbox.js +358 -0
- package/lib/vendor/blamejs/lib/scheduler.js +827 -0
- package/lib/vendor/blamejs/lib/sd-notify.js +269 -0
- package/lib/vendor/blamejs/lib/sec-cyber.js +214 -0
- package/lib/vendor/blamejs/lib/security-assert.js +395 -0
- package/lib/vendor/blamejs/lib/seeders.js +620 -0
- package/lib/vendor/blamejs/lib/self-update-standalone-verifier.js +309 -0
- package/lib/vendor/blamejs/lib/self-update.js +804 -0
- package/lib/vendor/blamejs/lib/server-timing.js +174 -0
- package/lib/vendor/blamejs/lib/session-device-binding.js +431 -0
- package/lib/vendor/blamejs/lib/session-stores.js +138 -0
- package/lib/vendor/blamejs/lib/session.js +1162 -0
- package/lib/vendor/blamejs/lib/slug.js +381 -0
- package/lib/vendor/blamejs/lib/sse.js +349 -0
- package/lib/vendor/blamejs/lib/ssrf-guard.js +792 -0
- package/lib/vendor/blamejs/lib/standard-webhooks.js +183 -0
- package/lib/vendor/blamejs/lib/static.js +1249 -0
- package/lib/vendor/blamejs/lib/storage.js +1272 -0
- package/lib/vendor/blamejs/lib/stream-throttle.js +235 -0
- package/lib/vendor/blamejs/lib/structured-fields.js +244 -0
- package/lib/vendor/blamejs/lib/subject.js +667 -0
- package/lib/vendor/blamejs/lib/tcpa-10dlc.js +175 -0
- package/lib/vendor/blamejs/lib/template.js +931 -0
- package/lib/vendor/blamejs/lib/tenant-quota.js +545 -0
- package/lib/vendor/blamejs/lib/test-harness.js +275 -0
- package/lib/vendor/blamejs/lib/testing.js +1185 -0
- package/lib/vendor/blamejs/lib/time.js +578 -0
- package/lib/vendor/blamejs/lib/tls-exporter.js +239 -0
- package/lib/vendor/blamejs/lib/totp.js +318 -0
- package/lib/vendor/blamejs/lib/tracing.js +546 -0
- package/lib/vendor/blamejs/lib/uuid.js +207 -0
- package/lib/vendor/blamejs/lib/validate-opts.js +381 -0
- package/lib/vendor/blamejs/lib/vault/index.js +638 -0
- package/lib/vendor/blamejs/lib/vault/passphrase-ops.js +311 -0
- package/lib/vendor/blamejs/lib/vault/passphrase-source.js +198 -0
- package/lib/vendor/blamejs/lib/vault/rotate.js +803 -0
- package/lib/vendor/blamejs/lib/vault/seal-pem-file.js +471 -0
- package/lib/vendor/blamejs/lib/vault/wrap.js +296 -0
- package/lib/vendor/blamejs/lib/vault-aad.js +259 -0
- package/lib/vendor/blamejs/lib/vendor/.vendor-data-pubkey +4 -0
- package/lib/vendor/blamejs/lib/vendor/MANIFEST.json +161 -0
- package/lib/vendor/blamejs/lib/vendor/bimi-trust-anchors.data.js +68 -0
- package/lib/vendor/blamejs/lib/vendor/bimi-trust-anchors.pem +33 -0
- package/lib/vendor/blamejs/lib/vendor/common-passwords-top-10000.data.js +1325 -0
- package/lib/vendor/blamejs/lib/vendor/common-passwords-top-10000.txt +10002 -0
- package/lib/vendor/blamejs/lib/vendor/noble-ciphers.cjs +9 -0
- package/lib/vendor/blamejs/lib/vendor/noble-post-quantum.cjs +18 -0
- package/lib/vendor/blamejs/lib/vendor/pki.cjs +181 -0
- package/lib/vendor/blamejs/lib/vendor/public-suffix-list.dat +16382 -0
- package/lib/vendor/blamejs/lib/vendor/public-suffix-list.data.js +5881 -0
- package/lib/vendor/blamejs/lib/vendor/simplewebauthn-server.cjs +328 -0
- package/lib/vendor/blamejs/lib/vendor/vendor-data-pubkey.js +16 -0
- package/lib/vendor/blamejs/lib/vendor-data.js +520 -0
- package/lib/vendor/blamejs/lib/vex.js +630 -0
- package/lib/vendor/blamejs/lib/watcher.js +608 -0
- package/lib/vendor/blamejs/lib/web-push-vapid.js +322 -0
- package/lib/vendor/blamejs/lib/webhook.js +977 -0
- package/lib/vendor/blamejs/lib/websocket-channels.js +327 -0
- package/lib/vendor/blamejs/lib/websocket.js +1561 -0
- package/lib/vendor/blamejs/lib/wiki-concepts.js +338 -0
- package/lib/vendor/blamejs/lib/worker-pool.js +464 -0
- package/lib/vendor/blamejs/lib/ws-client.js +978 -0
- package/lib/vendor/blamejs/lib/xml-c14n.js +506 -0
- package/lib/vendor/blamejs/memory/specs/node-26-map-getorinsert-migration.md +164 -0
- package/lib/vendor/blamejs/oss-fuzz/projects/blamejs/Dockerfile +19 -0
- package/lib/vendor/blamejs/oss-fuzz/projects/blamejs/README.md +88 -0
- package/lib/vendor/blamejs/oss-fuzz/projects/blamejs/build.sh +26 -0
- package/lib/vendor/blamejs/oss-fuzz/projects/blamejs/project.yaml +28 -0
- package/lib/vendor/blamejs/package.json +81 -0
- package/lib/vendor/blamejs/release-notes/v0.0.x.json +310 -0
- package/lib/vendor/blamejs/release-notes/v0.1.x.json +1798 -0
- package/lib/vendor/blamejs/release-notes/v0.10.x.json +1288 -0
- package/lib/vendor/blamejs/release-notes/v0.11.x.json +2551 -0
- package/lib/vendor/blamejs/release-notes/v0.12.0.json +64 -0
- package/lib/vendor/blamejs/release-notes/v0.12.1.json +32 -0
- package/lib/vendor/blamejs/release-notes/v0.12.2.json +45 -0
- package/lib/vendor/blamejs/release-notes/v0.2.x.json +706 -0
- package/lib/vendor/blamejs/release-notes/v0.3.x.json +786 -0
- package/lib/vendor/blamejs/release-notes/v0.4.x.json +588 -0
- package/lib/vendor/blamejs/release-notes/v0.5.x.json +390 -0
- package/lib/vendor/blamejs/release-notes/v0.6.x.json +1947 -0
- package/lib/vendor/blamejs/release-notes/v0.7.x.json +3811 -0
- package/lib/vendor/blamejs/release-notes/v0.8.x.json +3318 -0
- package/lib/vendor/blamejs/release-notes/v0.9.x.json +2257 -0
- package/lib/vendor/blamejs/scripts/build-vendored-sbom.js +325 -0
- package/lib/vendor/blamejs/scripts/check-api-snapshot.js +62 -0
- package/lib/vendor/blamejs/scripts/check-changelog-extract.js +108 -0
- package/lib/vendor/blamejs/scripts/check-pack-against-gitignore.js +83 -0
- package/lib/vendor/blamejs/scripts/check-services.js +483 -0
- package/lib/vendor/blamejs/scripts/check-vendor-currency.js +349 -0
- package/lib/vendor/blamejs/scripts/consolidate-release-notes.js +216 -0
- package/lib/vendor/blamejs/scripts/gen-migrating.js +275 -0
- package/lib/vendor/blamejs/scripts/generate-changelog-entry.js +577 -0
- package/lib/vendor/blamejs/scripts/generate-release-signing-key.js +79 -0
- package/lib/vendor/blamejs/scripts/publish-dep-confusion-placeholder.sh +101 -0
- package/lib/vendor/blamejs/scripts/refresh-api-snapshot.js +31 -0
- package/lib/vendor/blamejs/scripts/refresh-vendor-manifest.js +132 -0
- package/lib/vendor/blamejs/scripts/release.js +652 -0
- package/lib/vendor/blamejs/scripts/sha3-digest.js +62 -0
- package/lib/vendor/blamejs/scripts/sign-release-artifact.js +92 -0
- package/lib/vendor/blamejs/scripts/test-integration.js +181 -0
- package/lib/vendor/blamejs/scripts/test-wiki-integration.js +126 -0
- package/lib/vendor/blamejs/scripts/validate-source-comment-blocks.js +77 -0
- package/lib/vendor/blamejs/scripts/vendor-data-gen.js +186 -0
- package/lib/vendor/blamejs/scripts/vendor-data-keygen.js +101 -0
- package/lib/vendor/blamejs/scripts/vendor-update.sh +278 -0
- package/lib/vendor/blamejs/test/00-primitives.js +19075 -0
- package/lib/vendor/blamejs/test/10-state.js +622 -0
- package/lib/vendor/blamejs/test/20-db.js +561 -0
- package/lib/vendor/blamejs/test/30-chain.js +2110 -0
- package/lib/vendor/blamejs/test/40-consumers.js +2453 -0
- package/lib/vendor/blamejs/test/50-integration.js +486 -0
- package/lib/vendor/blamejs/test/_helpers.js +10 -0
- package/lib/vendor/blamejs/test/_smoke-worker.js +69 -0
- package/lib/vendor/blamejs/test/fixtures/exploit-corpus/corpus.json +368 -0
- package/lib/vendor/blamejs/test/fixtures/http-client-stream-payload.txt +2 -0
- package/lib/vendor/blamejs/test/fixtures/worker-pool/echo.js +52 -0
- package/lib/vendor/blamejs/test/helpers/_codebase-shingle-worker.js +24 -0
- package/lib/vendor/blamejs/test/helpers/_codebase-shingle.js +203 -0
- package/lib/vendor/blamejs/test/helpers/_shape-match.js +513 -0
- package/lib/vendor/blamejs/test/helpers/check.js +36 -0
- package/lib/vendor/blamejs/test/helpers/cluster.js +70 -0
- package/lib/vendor/blamejs/test/helpers/db.js +143 -0
- package/lib/vendor/blamejs/test/helpers/drivers.js +207 -0
- package/lib/vendor/blamejs/test/helpers/fs-watch.js +101 -0
- package/lib/vendor/blamejs/test/helpers/http.js +14 -0
- package/lib/vendor/blamejs/test/helpers/index.js +93 -0
- package/lib/vendor/blamejs/test/helpers/json-round-trip.js +120 -0
- package/lib/vendor/blamejs/test/helpers/mocks.js +20 -0
- package/lib/vendor/blamejs/test/helpers/otel.js +13 -0
- package/lib/vendor/blamejs/test/helpers/services.js +380 -0
- package/lib/vendor/blamejs/test/helpers/wait.js +206 -0
- package/lib/vendor/blamejs/test/integration/cache.test.js +235 -0
- package/lib/vendor/blamejs/test/integration/cluster-provider-mysql.test.js +174 -0
- package/lib/vendor/blamejs/test/integration/federation-auth.test.js +611 -0
- package/lib/vendor/blamejs/test/integration/http-client.test.js +129 -0
- package/lib/vendor/blamejs/test/integration/log-stream.test.js +219 -0
- package/lib/vendor/blamejs/test/integration/mail-crypto-smime.test.js +181 -0
- package/lib/vendor/blamejs/test/integration/mail-dkim.test.js +152 -0
- package/lib/vendor/blamejs/test/integration/mail-smtp.test.js +161 -0
- package/lib/vendor/blamejs/test/integration/mtls-ca.test.js +289 -0
- package/lib/vendor/blamejs/test/integration/network-dns.test.js +123 -0
- package/lib/vendor/blamejs/test/integration/network-heartbeat.test.js +101 -0
- package/lib/vendor/blamejs/test/integration/ntp-check.test.js +89 -0
- package/lib/vendor/blamejs/test/integration/object-store-sigv4.test.js +403 -0
- package/lib/vendor/blamejs/test/integration/pqc-pkcs8-forward-compat.test.js +271 -0
- package/lib/vendor/blamejs/test/integration/pubsub.test.js +137 -0
- package/lib/vendor/blamejs/test/integration/queue-redis.test.js +352 -0
- package/lib/vendor/blamejs/test/integration/redis-client-tls.test.js +96 -0
- package/lib/vendor/blamejs/test/integration/ssrf-guard.test.js +98 -0
- package/lib/vendor/blamejs/test/integration/websocket-permessage-deflate.test.js +261 -0
- package/lib/vendor/blamejs/test/integration/ws-client-roundtrip.test.js +230 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/a2a-tasks.test.js +211 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/a2a.test.js +59 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/access-lock.test.js +136 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/acme.test.js +219 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/age-gate.test.js +69 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/agent-event-bus.test.js +266 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/agent-idempotency.test.js +262 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/agent-orchestrator.test.js +390 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/agent-posture-chain.test.js +174 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/agent-saga.test.js +279 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/agent-snapshot.test.js +322 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/agent-stream.test.js +227 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/agent-tenant.test.js +302 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/agent-trace.test.js +150 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/ai-adverse-decision.test.js +44 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/ai-content-detect.test.js +150 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/ai-input.test.js +50 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/ai-model-manifest.test.js +96 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/ai-pref.test.js +76 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/api-encrypt.test.js +1080 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/app-shutdown.test.js +311 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/archive-zip-stream.test.js +291 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/archive.test.js +140 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/arg-parser.test.js +267 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/asn1-der.test.js +108 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/asyncapi.test.js +929 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/atomic-file-conflict-path.test.js +80 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/audit-cve-defensive.test.js +176 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/audit-daily-review.test.js +132 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/audit-export-cadf.test.js +97 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/audit-framework-namespaces.test.js +141 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/audit-segregation.test.js +115 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/audit-sign-ml-dsa-65.test.js +163 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/audit-use-store.test.js +246 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/auth-bot-challenge-verifier.test.js +485 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/auth-bot-challenge.test.js +331 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/auth-jwt-defenses.test.js +352 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/auth-lockout.test.js +572 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/auth-password-audit.test.js +61 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/azure-blob-bucket-ops.test.js +258 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/backup-manifest-signature.test.js +105 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/backup-worker.test.js +34 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/bearer-auth.test.js +107 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/body-parser-chunked-malformed.test.js +131 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/body-parser-smuggling.test.js +118 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/boot-gates.test.js +85 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/breach-deadline.test.js +38 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/break-glass.test.js +861 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/budr.test.js +55 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/bundler-engine.test.js +209 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cache-status.test.js +129 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cache.test.js +871 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/calendar.test.js +891 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/canonical-json-jcs.test.js +43 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cdn-cache-control.test.js +243 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cert.test.js +550 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/clear-site-data.test.js +107 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-api-key.test.js +147 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-audit-verify-chain.test.js +104 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-backup.test.js +135 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-config-drift.test.js +67 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-erase.test.js +75 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-file-type.test.js +98 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-helpers.test.js +145 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-mtls.test.js +133 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-password.test.js +97 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-restore.test.js +160 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-retention.test.js +84 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-security.test.js +69 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cli-vault.test.js +142 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/client-hints.test.js +133 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cms-codec.test.js +237 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/codebase-patterns.test.js +9600 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/compliance-ai-act.test.js +575 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/compliance-cascade.test.js +89 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/compliance-eaa.test.js +36 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/compliance-sanctions.test.js +712 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/compliance.test.js +278 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/config-drift.test.js +97 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/config.test.js +424 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/content-credentials.test.js +94 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cors.test.js +357 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/cra-report.test.js +31 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/credential-hash.test.js +226 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/crypto-base64url.test.js +86 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/crypto-envelope.test.js +85 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/crypto-hash-files-parallel.test.js +193 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/crypto-hash-stream.test.js +98 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/crypto-hpke-pq.test.js +132 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/crypto-hpke.test.js +155 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/crypto-mlkem768-x25519.test.js +129 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/crypto-namespace-hash.test.js +0 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/crypto-random-int.test.js +72 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/csp-builder.test.js +96 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/csp-nonce.test.js +401 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/csp-report.test.js +34 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/csv.test.js +180 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/daemon.test.js +210 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/daily-byte-quota.test.js +153 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/dark-patterns.test.js +66 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/data-act.test.js +74 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/db-collection-extensions.test.js +226 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/db-collection.test.js +136 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/db-init-extensions.test.js +165 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/db-query-cross-schema.test.js +150 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/db-query-extensions.test.js +191 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/db-role-for.test.js +228 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/db-vacuum.test.js +55 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/db-worm.test.js +89 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/ddl-change-control.test.js +184 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/declare-row-policy.test.js +203 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/declare-view.test.js +303 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/dns-dnssec-algorithm.test.js +163 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/dns-null-mx.test.js +39 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/dora.test.js +165 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/dr-runbook.test.js +59 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/dsr-state-rules.test.js +55 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/dsr.test.js +786 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/dual-control.test.js +105 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/early-hints.test.js +147 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/events.test.js +105 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/exploit-replay.test.js +243 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/external-db-hardening.test.js +181 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/external-db-migrate.test.js +190 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/external-db-routing.test.js +531 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/fal.test.js +118 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/fapi2.test.js +89 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/fda-21cfr11.test.js +156 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/fdx.test.js +79 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/fedcm-dbsc.test.js +216 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/federation-vc-suite.test.js +434 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/fido-mds3.test.js +432 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/file-type.test.js +81 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/flag.test.js +887 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/forensic-snapshot.test.js +51 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/fsm.test.js +375 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/gcs-bucket-ops.test.js +321 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/gdpr-ropa.test.js +41 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/graphql-federation.test.js +32 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-agent-registry.test.js +87 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-all.test.js +328 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-archive.test.js +339 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-csv.test.js +694 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-dsn.test.js +296 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-email.test.js +234 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-envelope.test.js +192 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-event-bus-payload.test.js +89 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-event-bus-topic.test.js +71 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-filename.test.js +386 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-html-wcag.test.js +859 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-html.test.js +357 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-idempotency-key.test.js +92 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-imap-command.test.js +0 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-jmap.test.js +174 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-json.test.js +317 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-list-id.test.js +199 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-list-unsubscribe.test.js +214 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-mail-compose.test.js +111 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-mail-move.test.js +110 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-mail-query.test.js +112 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-mail-reply.test.js +86 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-mail-sieve.test.js +92 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-managesieve-command.test.js +301 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-markdown.test.js +265 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-message-id.test.js +0 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-pop3-command.test.js +161 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-posture-chain.test.js +100 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-saga-config.test.js +79 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-smtp-command.test.js +269 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-snapshot-envelope.test.js +89 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-stream-args.test.js +78 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-svg.test.js +288 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-tenant-id.test.js +69 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-trace-context.test.js +102 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-xml.test.js +202 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/guard-yaml.test.js +203 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/hal.test.js +51 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/honeytoken.test.js +50 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/html-balance.test.js +37 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/http-client-cache.test.js +692 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/http-client-stream.test.js +280 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/http-message-signature.test.js +225 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/i18n-messageformat.test.js +203 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/i18n.test.js +991 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/iab-mspa.test.js +63 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/iab-tcf.test.js +73 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/idempotency-key.test.js +612 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/importmap-integrity.test.js +56 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/inbox.test.js +166 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/incident-report.test.js +29 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/jose-jwe-experimental.test.js +121 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/json-api.test.js +58 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/json-round-trip-helper.test.js +110 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/jwt-external.test.js +159 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/keychain.test.js +0 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/legal-hold.test.js +118 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/local-db-thin.test.js +150 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/log-stream-cloudwatch.test.js +489 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/log-stream-otlp-grpc.test.js +207 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/log-stream-otlp.test.js +283 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/lro.test.js +65 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-agent.test.js +417 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-arf.test.js +208 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-auth.test.js +910 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-bimi.test.js +502 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-bounce.test.js +680 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-canspam.test.js +128 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-crypto-pgp-experimental.test.js +149 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-crypto-pgp.test.js +323 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-crypto-smime.test.js +297 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-dav.test.js +514 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-deploy-tlsrpt.test.js +369 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-deploy.test.js +199 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-dkim.test.js +627 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-feedback-id.test.js +56 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-greylist.test.js +217 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-helo.test.js +283 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-journal.test.js +217 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-mdn.test.js +334 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-rbl.test.js +271 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-require-tls.test.js +128 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-scan.test.js +215 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-send-deliver.test.js +336 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-imap.test.js +732 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-jmap.test.js +840 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-managesieve.test.js +130 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-mx.test.js +285 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-pop3.test.js +74 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-rate-limit.test.js +112 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-registry.test.js +229 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-submission.test.js +394 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-tls.test.js +147 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-sieve.test.js +151 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-spam-score.test.js +204 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-srs.test.js +152 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-store-fts.test.js +279 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-store.test.js +323 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail-unsubscribe.test.js +165 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mail.test.js +439 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mcp-tool-registry.test.js +202 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mcp.test.js +155 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/metrics-shadow-registry.test.js +112 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/metrics-snapshot.test.js +224 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/middleware-compose-pipeline.test.js +278 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/money.test.js +376 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/mtls-ca-paths.test.js +89 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/nel.test.js +200 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/network-allowlist.test.js +106 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/network-byte-quota.test.js +133 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/network-dns-resolver.test.js +372 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/network-dns.test.js +635 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/network-heartbeat-passive.test.js +128 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/network-tls-build-options.test.js +130 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/network-tls-ct-inclusion.test.js +179 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/network-tls.test.js +447 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/network.test.js +369 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/nis2-report.test.js +21 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/nist-crosswalk.test.js +42 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/no-cache.test.js +98 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/notify.test.js +707 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/numeric-bounds.test.js +142 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/oauth-callback.test.js +72 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/observability-tracing.test.js +597 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/observability.test.js +190 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/openapi.test.js +877 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/otel-export.test.js +257 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/pagination.test.js +522 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/parsers-standalone.test.js +216 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/passkey.test.js +324 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/permissions.test.js +546 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/pqc-agent-curve.test.js +153 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/pqc-software.test.js +94 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/problem-details.test.js +195 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/process-spawn.test.js +62 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/promise-pool.test.js +93 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/protected-resource-metadata.test.js +68 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/protobuf-encoder.test.js +138 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/protocol-dispatcher.test.js +174 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/public-suffix.test.js +197 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/pubsub.test.js +232 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/queue-dlq-extend-lease.test.js +178 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/queue-flow-repeat.test.js +322 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/queue-priority-rate-progress.test.js +266 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/queue-sqs.test.js +300 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/rate-limit-cluster.test.js +338 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/rate-limit-registry.test.js +75 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/redact-dlp.test.js +246 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/redis-client.test.js +130 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/request-helpers.test.js +335 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/request-log.test.js +170 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/require-auth-cache-control.test.js +93 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/require-mtls.test.js +34 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/resource-access-lock.test.js +52 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/retention-floor.test.js +67 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/retry.test.js +535 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/router-cross-origin-redirect.test.js +0 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/router-tls0rtt.test.js +128 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-async-loops.test.js +163 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-async-parallel.test.js +170 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-decompress.test.js +248 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-dns.test.js +451 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-ical.test.js +289 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-icap.test.js +206 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-jsonpath.test.js +104 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-mime.test.js +339 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-mount-info.test.js +180 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-path.test.js +78 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-sieve.test.js +123 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-smtp.test.js +95 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-url-idn-homograph.test.js +77 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/safe-vcard.test.js +257 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/saml-slo.test.js +249 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/sandbox.test.js +228 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/scheduler-exactly-once.test.js +238 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/scim-server.test.js +92 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/sd-jwt-vc.test.js +700 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/sd-notify.test.js +67 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/sec-cyber.test.js +85 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/security-assert.test.js +107 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/security-headers.test.js +175 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/seeders.test.js +816 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/self-update-standalone-verifier.test.js +168 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/self-update.test.js +302 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/server-timing.test.js +93 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/session-device-binding.test.js +247 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/session-extensions.test.js +295 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/shape-match.test.js +142 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/sigv4-bucket-ops.test.js +952 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/sigv4-multipart-sse.test.js +441 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/slug.test.js +330 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/smtp-policy.test.js +233 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/source-comment-blocks.test.js +105 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/speculation-rules.test.js +319 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/sse.test.js +148 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/ssrf-guard.test.js +283 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/standard-webhooks.test.js +67 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/static.test.js +266 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/step-up.test.js +487 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/storage-chunk-scratch.test.js +0 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/storage-presigned-url.test.js +773 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/stream-throttle.test.js +173 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/structured-fields.test.js +180 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/tcpa-10dlc.test.js +66 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/tenant-quota.test.js +89 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/test-coverage.test.js +571 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/test-harness.test.js +190 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/testing-request.test.js +119 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/testing.test.js +522 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/time.test.js +151 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/tls-exporter.test.js +168 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/tls-ocsp-ct.test.js +275 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/tls-ocsp-verify.test.js +105 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/tls-pinset-drift.test.js +35 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/tls-preferred-groups.test.js +81 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/tracing.test.js +280 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/uuid.test.js +93 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/vault-aad.test.js +277 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/vault-seal-pem-file.test.js +252 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/vendor-data.test.js +149 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/vendor-manifest.test.js +92 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/vex.test.js +661 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/watcher.test.js +308 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/web-push-vapid.test.js +144 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/webhook.test.js +674 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/websocket-channels.test.js +360 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/worker-pool.test.js +302 -0
- package/lib/vendor/blamejs/test/layer-0-primitives/ws-client.test.js +349 -0
- package/lib/vendor/blamejs/test/layer-1-state/api-key.test.js +717 -0
- package/lib/vendor/blamejs/test/layer-5-integration/bundler-output.test.js +444 -0
- package/lib/vendor/blamejs/test/layer-5-integration/guard-host-integration.test.js +597 -0
- package/lib/vendor/blamejs/test/layer-5-integration/security-chaos.test.js +308 -0
- package/lib/vendor/blamejs/test/smoke.js +431 -0
- package/lib/webhooks.js +305 -0
- package/package.json +43 -0
|
@@ -0,0 +1,1561 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module b.websocket
|
|
4
|
+
* @nav HTTP
|
|
5
|
+
* @title Websocket
|
|
6
|
+
*
|
|
7
|
+
* @intro
|
|
8
|
+
* RFC 6455 WebSocket server on top of Node's `'upgrade'` event, plus
|
|
9
|
+
* RFC 8441 Extended CONNECT for HTTP/2. Built on `node:net` +
|
|
10
|
+
* `node:crypto` + `node:zlib` with no npm runtime dep.
|
|
11
|
+
*
|
|
12
|
+
* Three layers exposed to operators:
|
|
13
|
+
*
|
|
14
|
+
* 1. Handshake — `handleUpgrade(req, socket, head, opts)` for h1
|
|
15
|
+
* and `handleExtendedConnect(stream, headers, opts)` for h2.
|
|
16
|
+
* Validate the request, enforce same-origin (default) or an
|
|
17
|
+
* operator-supplied allowlist, negotiate subprotocol +
|
|
18
|
+
* permessage-deflate, return a `WebSocketConnection`. Refuse
|
|
19
|
+
* credential-shaped query parameters (`access_token`, `apikey`,
|
|
20
|
+
* `authorization`, …) — query strings leak via access logs,
|
|
21
|
+
* Referer headers, and browser history.
|
|
22
|
+
*
|
|
23
|
+
* 2. Connection — `WebSocketConnection` is an EventEmitter
|
|
24
|
+
* mirroring the browser API. Read `conn.readyState`
|
|
25
|
+
* (`'open' | 'closing' | 'closed'`); call `conn.send(data)`,
|
|
26
|
+
* `conn.ping(payload?)`, `conn.close(code?, reason?)`. Listen
|
|
27
|
+
* on `'message'`, `'ping'`, `'pong'`, `'close'`, `'error'`.
|
|
28
|
+
*
|
|
29
|
+
* 3. Frame layer — `FrameParser` + `serializeFrame` exposed for
|
|
30
|
+
* tests and advanced callers (custom proxy / multiplexer use
|
|
31
|
+
* cases). Operator code rarely touches these directly.
|
|
32
|
+
*
|
|
33
|
+
* Defenses wired in by default:
|
|
34
|
+
*
|
|
35
|
+
* - Same-origin Origin check on browser-initiated upgrades. Cross-
|
|
36
|
+
* site WebSocket hijacking (CSWSH) requires explicit opt-in via
|
|
37
|
+
* `origins: [...allowlist]` or `origins: "*"`.
|
|
38
|
+
* - Control-frame payload cap of 125 bytes (RFC 6455 §5.5).
|
|
39
|
+
* Without it, a 1 MiB PING echoes back as a 1 MiB PONG — a 2x
|
|
40
|
+
* outbound-bandwidth amplification DoS.
|
|
41
|
+
* - Strict UTF-8 validation on TEXT frames + close reasons (§5.6).
|
|
42
|
+
* - Close-code allowlist per §7.4.2 (1000–1011, 3000–4999;
|
|
43
|
+
* reserved 1004/1005/1006/1015 refused on the wire).
|
|
44
|
+
* - Frame + message length capped at `maxMessageBytes`
|
|
45
|
+
* (default 1 MiB).
|
|
46
|
+
* - Heartbeat: ping every 30s, abort after 35s without pong.
|
|
47
|
+
* - Cluster fan-out lives at the router/channel layer above this
|
|
48
|
+
* module; this primitive owns the per-connection protocol.
|
|
49
|
+
*
|
|
50
|
+
* Configurable handshake GUID: closed-ecosystem clients with a
|
|
51
|
+
* custom magic string pass `opts.handshakeGuid` (UUID-shaped). The
|
|
52
|
+
* default is the RFC 6455 §1.3 value so RFC-compliant clients
|
|
53
|
+
* interoperate out of the box. SHA-1 used in `Sec-WebSocket-Accept`
|
|
54
|
+
* is a protocol marker, not a security primitive — its collision
|
|
55
|
+
* resistance is irrelevant to the connection's security.
|
|
56
|
+
*
|
|
57
|
+
* Spec compliance notes (where naive implementations get it wrong):
|
|
58
|
+
*
|
|
59
|
+
* 1. Mask handling (§5.3). All client→server h1 frames MUST be
|
|
60
|
+
* masked; server→client frames MUST NOT be masked. The h2
|
|
61
|
+
* transport (RFC 8441) flips both: frames MUST NOT be masked
|
|
62
|
+
* because h2 already provides the framing guarantees masking
|
|
63
|
+
* defends.
|
|
64
|
+
* 2. Close handshake reciprocity (§5.5.1). Peer-initiated close
|
|
65
|
+
* echoes a close frame back before ending the TCP socket.
|
|
66
|
+
* 3. Subprotocol negotiation. Server picks the FIRST entry from
|
|
67
|
+
* `Sec-WebSocket-Protocol` that's in the operator's allowlist.
|
|
68
|
+
* If none match, response omits the header (§11.3.4).
|
|
69
|
+
* 4. permessage-deflate (RFC 7692). Negotiated when the client
|
|
70
|
+
* offers it; runs in `no_context_takeover` mode in both
|
|
71
|
+
* directions so each message uses a fresh zlib state.
|
|
72
|
+
*
|
|
73
|
+
* @card
|
|
74
|
+
* RFC 6455 WebSocket server on top of Node's `'upgrade'` event, plus RFC 8441 Extended CONNECT for HTTP/2.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
var nodeCrypto = require("node:crypto");
|
|
78
|
+
var zlib = require("node:zlib");
|
|
79
|
+
var safeDecompress = require("./safe-decompress").safeDecompress;
|
|
80
|
+
var { EventEmitter } = require("node:events");
|
|
81
|
+
var C = require("./constants");
|
|
82
|
+
var requestHelpers = require("./request-helpers");
|
|
83
|
+
var safeAsync = require("./safe-async");
|
|
84
|
+
var safeBuffer = require("./safe-buffer");
|
|
85
|
+
var structuredFields = require("./structured-fields");
|
|
86
|
+
var { FrameworkError } = require("./framework-error");
|
|
87
|
+
var { boot } = require("./log");
|
|
88
|
+
|
|
89
|
+
var HTTP = requestHelpers.HTTP_STATUS;
|
|
90
|
+
var log = boot("websocket");
|
|
91
|
+
|
|
92
|
+
// RFC 6455 §1.3 — the standard handshake GUID. Operators running
|
|
93
|
+
// closed-ecosystem clients with a custom magic string pass their own
|
|
94
|
+
// via opts.handshakeGuid on the route; the framework's default stays
|
|
95
|
+
// the RFC value so RFC-compliant clients work out of the box.
|
|
96
|
+
var GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
|
97
|
+
|
|
98
|
+
// UUID-shape (8-4-4-4-12 hex) for opts.handshakeGuid validation. The
|
|
99
|
+
// SHA-1 used in the handshake is NOT a security primitive (RFC 6455
|
|
100
|
+
// requires it as a protocol marker), so the GUID itself doesn't need
|
|
101
|
+
// to be cryptographically random — but it must match the client's
|
|
102
|
+
// expected value byte-for-byte. Length + format check at config time
|
|
103
|
+
// catches the typo class.
|
|
104
|
+
var GUID_RE = /^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/;
|
|
105
|
+
|
|
106
|
+
// Credential-shaped query parameter names refused at upgrade time. URL
|
|
107
|
+
// query strings end up in: web-server access logs, the browser's
|
|
108
|
+
// history + Referer header forwarded to third-party CDN / analytics
|
|
109
|
+
// requests, in-process / proxy log captures, and crash dumps. Any
|
|
110
|
+
// authentication credential placed in the query string is leaked
|
|
111
|
+
// through one of those channels by default. RFC 6750 §2.3 explicitly
|
|
112
|
+
// cautions against bearer tokens in URI query parameters for exactly
|
|
113
|
+
// these reasons.
|
|
114
|
+
//
|
|
115
|
+
// Operators with a non-credential query parameter that happens to
|
|
116
|
+
// match one of these names (e.g. an "apikey" field passed to a
|
|
117
|
+
// downstream tenant API by mistake) opt out per route via
|
|
118
|
+
// `opts.allowQueryAuthParams: true` with an audited operator reason —
|
|
119
|
+
// the lift exists, but the operator owns the audit trail.
|
|
120
|
+
//
|
|
121
|
+
// The list is deliberately narrow — overloaded names like `token`,
|
|
122
|
+
// `auth`, `key`, `session` have non-credential meanings (CSRF tokens,
|
|
123
|
+
// file-share tokens, ICE candidates, session-resume identifiers) and
|
|
124
|
+
// would create false-positive friction without closing a genuine
|
|
125
|
+
// leak vector. The names below are unambiguously credential-shaped.
|
|
126
|
+
var REFUSED_AUTH_QUERY_PARAMS = Object.freeze([
|
|
127
|
+
"access_token", // OAuth 2.0 bearer (RFC 6750)
|
|
128
|
+
"bearer", // synonym
|
|
129
|
+
"bearer_token", // synonym
|
|
130
|
+
"apikey", // common convention
|
|
131
|
+
"api_key", // common convention
|
|
132
|
+
"api-key", // common convention
|
|
133
|
+
"authorization", // literal Authorization-header value
|
|
134
|
+
]);
|
|
135
|
+
|
|
136
|
+
var OPCODE_CONTINUATION = 0x0;
|
|
137
|
+
var OPCODE_TEXT = 0x1;
|
|
138
|
+
var OPCODE_BINARY = 0x2;
|
|
139
|
+
var OPCODE_CLOSE = 0x8;
|
|
140
|
+
var OPCODE_PING = 0x9;
|
|
141
|
+
var OPCODE_PONG = 0xA;
|
|
142
|
+
|
|
143
|
+
// Close codes (RFC 6455 §7.4.1) — encoded in hex so the framework's
|
|
144
|
+
// byte-literal lint (which flags decimal multiples of 8) doesn't trip
|
|
145
|
+
// on the protocol-fixed values.
|
|
146
|
+
var CLOSE_NORMAL = 0x3E8;
|
|
147
|
+
var CLOSE_GOING_AWAY = 0x3E9;
|
|
148
|
+
var CLOSE_PROTOCOL_ERROR = 0x3EA;
|
|
149
|
+
var CLOSE_UNSUPPORTED_DATA = 0x3EB;
|
|
150
|
+
// 0x3EC reserved
|
|
151
|
+
// 0x3ED no-status (must not be sent on the wire)
|
|
152
|
+
// 0x3EE abnormal-closure (must not be sent on the wire)
|
|
153
|
+
var CLOSE_INVALID_PAYLOAD = 0x3EF;
|
|
154
|
+
var CLOSE_POLICY_VIOLATION = 0x3F0;
|
|
155
|
+
var CLOSE_MESSAGE_TOO_BIG = 0x3F1;
|
|
156
|
+
var CLOSE_INTERNAL_ERROR = 0x3F3;
|
|
157
|
+
|
|
158
|
+
// Defaults — tuned for fast detection of dead/silent connections.
|
|
159
|
+
//
|
|
160
|
+
// pingIntervalMs (30s): sends a ping every 30s. Aligned with most
|
|
161
|
+
// load-balancer idle timeouts so the LB doesn't kill the
|
|
162
|
+
// connection while we're still considering it healthy.
|
|
163
|
+
//
|
|
164
|
+
// pongTimeoutMs (35s): if no pong arrives within 35s of the last
|
|
165
|
+
// pong, abort with code 1011. Detection happens at ~35s — just
|
|
166
|
+
// past one ping interval. Stays under AWS ALB's 60s default
|
|
167
|
+
// idle so operators don't get LB-side disconnects fighting our
|
|
168
|
+
// heartbeat. Tighter than the typical 60s default in other libs;
|
|
169
|
+
// the cost of a false positive is a client reconnect, the cost
|
|
170
|
+
// of a slow detection is wasted server resources for genuinely-
|
|
171
|
+
// dead silent-failure connections.
|
|
172
|
+
//
|
|
173
|
+
// closeGraceMs (2s): after we send a close frame, wait this long
|
|
174
|
+
// for the peer's echo before forcibly ending the TCP socket.
|
|
175
|
+
// A healthy peer echoes in <100ms; 2s is plenty. Operators on
|
|
176
|
+
// slow networks override.
|
|
177
|
+
//
|
|
178
|
+
// All operator-overridable per connection via opts.{pingIntervalMs,
|
|
179
|
+
// pongTimeoutMs, closeGraceMs}.
|
|
180
|
+
var DEFAULT_MAX_MESSAGE_BYTES = C.BYTES.mib(1);
|
|
181
|
+
var DEFAULT_PING_INTERVAL_MS = C.TIME.seconds(30);
|
|
182
|
+
var DEFAULT_PONG_TIMEOUT_MS = C.TIME.seconds(35);
|
|
183
|
+
var CLOSE_GRACE_MS = C.TIME.seconds(2);
|
|
184
|
+
|
|
185
|
+
// RFC 6455 §7.4.2 close-code validity gate. Codes 0..999 MUST NOT
|
|
186
|
+
// appear on the wire. 1004 / 1005 / 1006 / 1015 are reserved
|
|
187
|
+
// (1005/1006 are local-only sentinels; 1004/1015 are reserved for
|
|
188
|
+
// future use). Codes 1000..1011 are spec-allocated. 3000..3999 are
|
|
189
|
+
// IANA-registered. 4000..4999 are private-use. Anything else is
|
|
190
|
+
// invalid.
|
|
191
|
+
function _isValidCloseCode(code) {
|
|
192
|
+
if (code === 1004 || code === 1005 || code === 1006 || code === 1015) return false; // allow:raw-byte-literal — RFC 6455 §7.4.2 reserved codes
|
|
193
|
+
if (code >= 1000 && code <= 1011) return true; // allow:raw-byte-literal — RFC 6455 §7.4.2 spec range / allow:raw-time-literal — code is a numeric, not seconds
|
|
194
|
+
if (code >= 3000 && code <= 4999) return true; // allow:raw-byte-literal — RFC 6455 §7.4.2 IANA / private range / allow:raw-time-literal — code is a numeric, not seconds
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Connection lifecycle states — mirrors the browser WebSocket API +
|
|
199
|
+
// the npm `ws` library. Single-source-of-truth field; every state
|
|
200
|
+
// transition goes through _transitionToClosed (or set in the
|
|
201
|
+
// constructor for OPEN).
|
|
202
|
+
var STATE_OPEN = "open";
|
|
203
|
+
var STATE_CLOSING = "closing"; // we sent a close frame, awaiting peer's echo
|
|
204
|
+
var STATE_CLOSED = "closed";
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @primitive b.websocket.WebSocketError
|
|
208
|
+
* @signature b.websocket.WebSocketError(code, message, closeCode)
|
|
209
|
+
* @since 0.1.38
|
|
210
|
+
* @status stable
|
|
211
|
+
* @related b.websocket.WebSocketConnection
|
|
212
|
+
*
|
|
213
|
+
* Framework-error subclass thrown for protocol violations + invalid
|
|
214
|
+
* caller input (`send()` on a closed connection, malformed frame
|
|
215
|
+
* payload, frame-too-large detected at parse time). Carries the
|
|
216
|
+
* RFC 6455 §7.4.1 `closeCode` the connection layer uses when
|
|
217
|
+
* aborting (1002 protocol error, 1007 invalid payload, 1009 message
|
|
218
|
+
* too big, 1011 internal error). Operators usually catch via the
|
|
219
|
+
* shared `b.errors` surface and never construct one directly.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* try {
|
|
223
|
+
* conn.send("late message");
|
|
224
|
+
* } catch (err) {
|
|
225
|
+
* if (err.isWebSocketError) {
|
|
226
|
+
* console.log(err.code, err.closeCode);
|
|
227
|
+
* // → "ws/closed" 1002
|
|
228
|
+
* }
|
|
229
|
+
* }
|
|
230
|
+
*/
|
|
231
|
+
class WebSocketError extends FrameworkError {
|
|
232
|
+
constructor(code, message, closeCode) {
|
|
233
|
+
super(message, code);
|
|
234
|
+
this.name = "WebSocketError";
|
|
235
|
+
this.closeCode = closeCode || CLOSE_PROTOCOL_ERROR;
|
|
236
|
+
this.isWebSocketError = true;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// ---- Handshake helpers ----
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @primitive b.websocket.computeAcceptKey
|
|
244
|
+
* @signature b.websocket.computeAcceptKey(secWebSocketKey, handshakeGuid)
|
|
245
|
+
* @since 0.1.38
|
|
246
|
+
* @status stable
|
|
247
|
+
* @related b.websocket.handleUpgrade, b.websocket.buildUpgradeResponse
|
|
248
|
+
*
|
|
249
|
+
* Compute the `Sec-WebSocket-Accept` value RFC 6455 §1.3 mandates:
|
|
250
|
+
* `base64(SHA1(secWebSocketKey || handshakeGuid))`. The SHA-1 is a
|
|
251
|
+
* protocol marker confirming both ends agree on the upgrade — it is
|
|
252
|
+
* NOT a security primitive, and the framework's other crypto stays
|
|
253
|
+
* SHA3 / SHAKE-based regardless. Pass `handshakeGuid` undefined to
|
|
254
|
+
* use the RFC value (`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`); pass a
|
|
255
|
+
* UUID-shaped override only for closed-ecosystem clients with a
|
|
256
|
+
* matching custom magic string.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* var accept = b.websocket.computeAcceptKey("dGhlIHNhbXBsZSBub25jZQ==");
|
|
260
|
+
* // → "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="
|
|
261
|
+
*/
|
|
262
|
+
function computeAcceptKey(secWebSocketKey, handshakeGuid) {
|
|
263
|
+
// SHA-1 required by RFC 6455 §1.3 — see file-level note 2 above.
|
|
264
|
+
// This is a protocol marker, not a security primitive.
|
|
265
|
+
// handshakeGuid defaults to the RFC value; operators with custom
|
|
266
|
+
// closed-ecosystem clients override per-route via opts.handshakeGuid.
|
|
267
|
+
var hash = nodeCrypto.createHash("sha1");
|
|
268
|
+
hash.update(String(secWebSocketKey) + (handshakeGuid || GUID));
|
|
269
|
+
return hash.digest("base64");
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @primitive b.websocket.validateUpgradeRequest
|
|
274
|
+
* @signature b.websocket.validateUpgradeRequest(req, opts)
|
|
275
|
+
* @since 0.1.38
|
|
276
|
+
* @status stable
|
|
277
|
+
* @related b.websocket.handleUpgrade, b.websocket.isOriginAllowed
|
|
278
|
+
*
|
|
279
|
+
* Strict shape check on the HTTP/1.1 upgrade request. Verifies the
|
|
280
|
+
* method is GET, `Upgrade: websocket` and `Connection: upgrade`
|
|
281
|
+
* tokens are present, `Sec-WebSocket-Version: 13`, and
|
|
282
|
+
* `Sec-WebSocket-Key` is a 24-character base64 of 16 random bytes
|
|
283
|
+
* (RFC 6455 §4.1). Refuses credential-shaped query parameters
|
|
284
|
+
* (`access_token`, `apikey`, `authorization`, …) unless the operator
|
|
285
|
+
* passes `opts.allowQueryAuthParams: true` with an audited reason.
|
|
286
|
+
* Returns `{ ok: true }` on success or
|
|
287
|
+
* `{ ok: false, status, reason }` on refusal — never throws, so the
|
|
288
|
+
* caller can write the refusal response and end the socket cleanly.
|
|
289
|
+
*
|
|
290
|
+
* @opts
|
|
291
|
+
* allowQueryAuthParams: boolean, // opt out of credential-query refusal
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* var v = b.websocket.validateUpgradeRequest(req, {});
|
|
295
|
+
* if (!v.ok) {
|
|
296
|
+
* // → { ok: false, status: 400, reason: "..." }
|
|
297
|
+
* socket.write("HTTP/1.1 " + v.status + " Bad Request\r\n\r\n");
|
|
298
|
+
* socket.destroy();
|
|
299
|
+
* }
|
|
300
|
+
*/
|
|
301
|
+
function validateUpgradeRequest(req, opts) {
|
|
302
|
+
if (req.method !== "GET") {
|
|
303
|
+
return { ok: false, status: HTTP.METHOD_NOT_ALLOWED, reason: "method must be GET" };
|
|
304
|
+
}
|
|
305
|
+
var h = req.headers || {};
|
|
306
|
+
if ((h.upgrade || "").toLowerCase() !== "websocket") {
|
|
307
|
+
return { ok: false, status: HTTP.BAD_REQUEST, reason: "missing Upgrade: websocket" };
|
|
308
|
+
}
|
|
309
|
+
// Connection header may carry multiple tokens (e.g. "keep-alive, Upgrade").
|
|
310
|
+
// Match "upgrade" as a comma-separated token, case-insensitive.
|
|
311
|
+
if (!/(^|,)\s*upgrade\s*(,|$)/i.test(h.connection || "")) {
|
|
312
|
+
return { ok: false, status: HTTP.BAD_REQUEST, reason: "missing Connection: upgrade" };
|
|
313
|
+
}
|
|
314
|
+
if (!h["sec-websocket-key"]) {
|
|
315
|
+
return { ok: false, status: HTTP.BAD_REQUEST, reason: "missing Sec-WebSocket-Key" };
|
|
316
|
+
}
|
|
317
|
+
// RFC 6455 §4.1 — Sec-WebSocket-Key MUST be a base64-encoded
|
|
318
|
+
// 16-byte nonce. Encoded length is 24 chars including the
|
|
319
|
+
// `==` padding. Strict check refuses malformed values that
|
|
320
|
+
// some clients send (truncated or arbitrary token); lets
|
|
321
|
+
// server-side anomaly detection see the malformation rather
|
|
322
|
+
// than passing through.
|
|
323
|
+
if (!/^[A-Za-z0-9+/]{22}==$/.test(h["sec-websocket-key"])) {
|
|
324
|
+
return { ok: false, status: HTTP.BAD_REQUEST,
|
|
325
|
+
reason: "Sec-WebSocket-Key must be base64 of 16 random bytes (RFC 6455 §4.1)" };
|
|
326
|
+
}
|
|
327
|
+
if (h["sec-websocket-version"] !== "13") {
|
|
328
|
+
return { ok: false, status: HTTP.BAD_REQUEST, reason: "Sec-WebSocket-Version must be 13" };
|
|
329
|
+
}
|
|
330
|
+
if (!(opts && opts.allowQueryAuthParams === true)) {
|
|
331
|
+
var leaked = _findCredentialQueryParam(req.url);
|
|
332
|
+
if (leaked) {
|
|
333
|
+
return {
|
|
334
|
+
ok: false,
|
|
335
|
+
status: HTTP.BAD_REQUEST,
|
|
336
|
+
reason: "credential-shaped query parameter '" + leaked +
|
|
337
|
+
"' refused — query strings leak via logs / Referer / history. " +
|
|
338
|
+
"Move the credential to the Authorization header, or set " +
|
|
339
|
+
"opts.allowQueryAuthParams: true with an audited operator reason " +
|
|
340
|
+
"if this parameter is not actually a credential.",
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return { ok: true };
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// _findCredentialQueryParam walks the request's query string and
|
|
348
|
+
// returns the first credential-shaped parameter name it finds, or
|
|
349
|
+
// null. Comparison is case-insensitive; an attacker who URL-encodes
|
|
350
|
+
// the parameter name (e.g. "%41ccess_token") still hits the check
|
|
351
|
+
// because URL parsing decodes the name before comparison.
|
|
352
|
+
function _findCredentialQueryParam(reqUrl) {
|
|
353
|
+
if (typeof reqUrl !== "string" || reqUrl.length === 0) return null;
|
|
354
|
+
var qIdx = reqUrl.indexOf("?");
|
|
355
|
+
if (qIdx === -1) return null;
|
|
356
|
+
var query = reqUrl.slice(qIdx + 1);
|
|
357
|
+
// Strip a fragment if any (defensive — real HTTP requests don't carry
|
|
358
|
+
// one, but req.url has been observed with appended fragments behind
|
|
359
|
+
// misconfigured proxies).
|
|
360
|
+
var fIdx = query.indexOf("#");
|
|
361
|
+
if (fIdx !== -1) query = query.slice(0, fIdx);
|
|
362
|
+
if (query.length === 0) return null;
|
|
363
|
+
var pairs = query.split("&");
|
|
364
|
+
for (var p = 0; p < pairs.length; p++) {
|
|
365
|
+
var eqIdx = pairs[p].indexOf("=");
|
|
366
|
+
var rawName = eqIdx === -1 ? pairs[p] : pairs[p].slice(0, eqIdx);
|
|
367
|
+
if (rawName.length === 0) continue;
|
|
368
|
+
var name;
|
|
369
|
+
try { name = decodeURIComponent(rawName).toLowerCase(); }
|
|
370
|
+
catch (_e) { name = rawName.toLowerCase(); }
|
|
371
|
+
for (var r = 0; r < REFUSED_AUTH_QUERY_PARAMS.length; r++) {
|
|
372
|
+
if (name === REFUSED_AUTH_QUERY_PARAMS[r]) return name;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* @primitive b.websocket.negotiateSubprotocol
|
|
380
|
+
* @signature b.websocket.negotiateSubprotocol(req, supported)
|
|
381
|
+
* @since 0.1.38
|
|
382
|
+
* @status stable
|
|
383
|
+
* @related b.websocket.handleUpgrade, b.websocket.buildUpgradeResponse
|
|
384
|
+
*
|
|
385
|
+
* Pick the first client-offered subprotocol that appears in
|
|
386
|
+
* `supported`. Returns the chosen string, or `null` when there is no
|
|
387
|
+
* intersection (per RFC 6455 §11.3.4 the response then omits the
|
|
388
|
+
* `Sec-WebSocket-Protocol` header and the client decides whether to
|
|
389
|
+
* proceed). `supported` falsy or empty is treated as "no preference"
|
|
390
|
+
* and always returns `null`.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* var req = { headers: { "sec-websocket-protocol": "chat.v2, chat.v1" } };
|
|
394
|
+
* var picked = b.websocket.negotiateSubprotocol(req, ["chat.v1"]);
|
|
395
|
+
* // → "chat.v1"
|
|
396
|
+
*/
|
|
397
|
+
function negotiateSubprotocol(req, supported) {
|
|
398
|
+
if (!supported || supported.length === 0) return null;
|
|
399
|
+
var raw = (req.headers || {})["sec-websocket-protocol"] || "";
|
|
400
|
+
var offered = requestHelpers.parseListHeader(raw);
|
|
401
|
+
for (var i = 0; i < offered.length; i++) {
|
|
402
|
+
if (supported.indexOf(offered[i]) !== -1) return offered[i];
|
|
403
|
+
}
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// origins shapes:
|
|
408
|
+
// array — strict allowlist, enforced
|
|
409
|
+
// "*" — explicit "accept all" (operator opt-in to no checking)
|
|
410
|
+
// null/undefined — DEFAULT: same-origin (Origin host matches Host
|
|
411
|
+
// header). The pre-0.7.64 default was "accept all" —
|
|
412
|
+
// flipped here because cross-site WebSocket
|
|
413
|
+
// hijacking (CSWSH) is a real attacker capability
|
|
414
|
+
// against any browser-targeted WebSocket route, and
|
|
415
|
+
// same-origin is the safe default. Operators
|
|
416
|
+
// needing cross-origin opt in explicitly via
|
|
417
|
+
// `origins: "*"` (with audited reason) or
|
|
418
|
+
// `origins: [...allowlist]`.
|
|
419
|
+
/**
|
|
420
|
+
* @primitive b.websocket.isOriginAllowed
|
|
421
|
+
* @signature b.websocket.isOriginAllowed(req, origins)
|
|
422
|
+
* @since 0.1.38
|
|
423
|
+
* @status stable
|
|
424
|
+
* @related b.websocket.handleUpgrade, b.websocket.validateUpgradeRequest
|
|
425
|
+
*
|
|
426
|
+
* Browser-Origin policy gate. Behaviour by the `origins` shape:
|
|
427
|
+
*
|
|
428
|
+
* - Array — strict allowlist; the request's `Origin` header must
|
|
429
|
+
* match one entry exactly.
|
|
430
|
+
* - `"*"` — explicit accept-all (operator opt-in to no checking).
|
|
431
|
+
* - `null` / `undefined` — DEFAULT same-origin: the `Origin` host
|
|
432
|
+
* must match the `Host` header. Closes the cross-site WebSocket
|
|
433
|
+
* hijacking (CSWSH) class on browser-targeted routes.
|
|
434
|
+
*
|
|
435
|
+
* Non-browser clients (curl, server-to-server, native apps) don't
|
|
436
|
+
* send `Origin` and bypass the check — gating those callers is the
|
|
437
|
+
* operator's network-ACL / auth-middleware job, not Origin's.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* var req = { headers: { origin: "https://app.example.com",
|
|
441
|
+
* host: "app.example.com" } };
|
|
442
|
+
* b.websocket.isOriginAllowed(req, undefined); // → true
|
|
443
|
+
* b.websocket.isOriginAllowed(req, ["https://other.example"]); // → false
|
|
444
|
+
* b.websocket.isOriginAllowed(req, "*"); // → true
|
|
445
|
+
*/
|
|
446
|
+
function isOriginAllowed(req, origins) {
|
|
447
|
+
if (origins === "*") return true;
|
|
448
|
+
var origin = (req.headers || {}).origin;
|
|
449
|
+
// Non-browser clients (curl, server-to-server, native apps) don't
|
|
450
|
+
// send Origin. Origin enforcement only meaningfully applies to
|
|
451
|
+
// browser-initiated upgrades — non-browser callers are gated by
|
|
452
|
+
// the operator's network ACL / auth middleware, not Origin.
|
|
453
|
+
if (!origin) return true;
|
|
454
|
+
if (Array.isArray(origins)) return origins.indexOf(origin) !== -1;
|
|
455
|
+
// Default: same-origin. Compare the Origin header's hostname against
|
|
456
|
+
// the Host header. Operators behind a TLS-terminating LB pass the
|
|
457
|
+
// canonical Host through (or set `origins: [...]` explicitly).
|
|
458
|
+
if (!origins) {
|
|
459
|
+
var host = (req.headers || {}).host;
|
|
460
|
+
if (!host) return false;
|
|
461
|
+
var originHost;
|
|
462
|
+
try { originHost = new URL(origin).host; } // allow:raw-new-url — comparing browser-supplied Origin header against Host; safeUrl.parse adds policy filtering that isn't appropriate for exact host comparison
|
|
463
|
+
catch (_e) { return false; }
|
|
464
|
+
return originHost === host;
|
|
465
|
+
}
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* @primitive b.websocket.buildUpgradeResponse
|
|
471
|
+
* @signature b.websocket.buildUpgradeResponse(secWebSocketKey, subprotocol, extensionHeader, handshakeGuid)
|
|
472
|
+
* @since 0.1.38
|
|
473
|
+
* @status stable
|
|
474
|
+
* @related b.websocket.handleUpgrade, b.websocket.computeAcceptKey
|
|
475
|
+
*
|
|
476
|
+
* Format the HTTP/1.1 101 Switching Protocols response that completes
|
|
477
|
+
* the WebSocket handshake. Always emits `Upgrade: websocket`,
|
|
478
|
+
* `Connection: Upgrade`, and `Sec-WebSocket-Accept`. Adds
|
|
479
|
+
* `Sec-WebSocket-Protocol` when `subprotocol` is non-null, and
|
|
480
|
+
* `Sec-WebSocket-Extensions` when `extensionHeader` is non-null
|
|
481
|
+
* (e.g. the `permessage-deflate; ...` echo). Pass `handshakeGuid`
|
|
482
|
+
* undefined to use the RFC 6455 default. Returns the raw
|
|
483
|
+
* `\r\n`-delimited response string ready for `socket.write()`.
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* var resp = b.websocket.buildUpgradeResponse(
|
|
487
|
+
* "dGhlIHNhbXBsZSBub25jZQ==", "chat.v1", null);
|
|
488
|
+
* // → "HTTP/1.1 101 Switching Protocols\r\n..."
|
|
489
|
+
* socket.write(resp);
|
|
490
|
+
*/
|
|
491
|
+
function buildUpgradeResponse(secWebSocketKey, subprotocol, extensionHeader, handshakeGuid) {
|
|
492
|
+
var lines = [
|
|
493
|
+
"HTTP/1.1 101 Switching Protocols",
|
|
494
|
+
"Upgrade: websocket",
|
|
495
|
+
"Connection: Upgrade",
|
|
496
|
+
"Sec-WebSocket-Accept: " + computeAcceptKey(secWebSocketKey, handshakeGuid),
|
|
497
|
+
];
|
|
498
|
+
if (subprotocol) lines.push("Sec-WebSocket-Protocol: " + subprotocol);
|
|
499
|
+
if (extensionHeader) lines.push("Sec-WebSocket-Extensions: " + extensionHeader);
|
|
500
|
+
return lines.join("\r\n") + "\r\n\r\n";
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// ---- permessage-deflate (RFC 7692) ----
|
|
504
|
+
//
|
|
505
|
+
// Negotiate compression at handshake, compress per-message on send,
|
|
506
|
+
// decompress per-message on receive. The framework runs in
|
|
507
|
+
// "no_context_takeover" mode in both directions — every message uses a
|
|
508
|
+
// fresh zlib state, no LZ77 history carried across messages. This
|
|
509
|
+
// trade-off makes message processing stateless (no per-connection
|
|
510
|
+
// zlib stream lifetime to manage) at a small compression-ratio cost.
|
|
511
|
+
// Operators with throughput-sensitive workloads can extend this later
|
|
512
|
+
// to keep state across messages.
|
|
513
|
+
//
|
|
514
|
+
// Per RFC 7692 §7.2.1 the deflate output is the standard zlib raw
|
|
515
|
+
// deflate WITH the trailing 4 bytes 0x00 0x00 0xff 0xff stripped. The
|
|
516
|
+
// matching inflate path appends them back before inflating.
|
|
517
|
+
var DEFLATE_TRAILING = Buffer.from([0x00, 0x00, 0xff, 0xff]);
|
|
518
|
+
|
|
519
|
+
function _parseExtensionHeader(header) {
|
|
520
|
+
// Sec-WebSocket-Extensions: foo; param=val; param2, bar; ...
|
|
521
|
+
// Returns [{ name, params: { paramName: value | true } }]
|
|
522
|
+
// RFC 6455 §9.1 + RFC 7230 token-or-quoted-string — param values
|
|
523
|
+
// can technically be quoted-string. Current registered extensions
|
|
524
|
+
// (permessage-deflate) only use token values in practice, but the
|
|
525
|
+
// quote-aware split is defensive against any future extension
|
|
526
|
+
// shipping quoted parameter values.
|
|
527
|
+
if (!header) return [];
|
|
528
|
+
var entries = structuredFields.splitTopLevel(String(header), ",");
|
|
529
|
+
var out = [];
|
|
530
|
+
for (var i = 0; i < entries.length; i++) {
|
|
531
|
+
var parts = structuredFields.splitTopLevel(entries[i], ";").map(function (s) { return s.trim(); });
|
|
532
|
+
if (!parts[0]) continue;
|
|
533
|
+
// `params` has no prototype chain — `Object.create(null)` defends
|
|
534
|
+
// against `__proto__` / `constructor` / `prototype` parameter names
|
|
535
|
+
// in the Sec-WebSocket-Extensions header polluting downstream lookups.
|
|
536
|
+
var ext = { name: parts[0].toLowerCase(), params: Object.create(null) };
|
|
537
|
+
for (var j = 1; j < parts.length; j++) {
|
|
538
|
+
var kv = parts[j].split("=");
|
|
539
|
+
var k = kv[0].trim().toLowerCase();
|
|
540
|
+
if (!k) continue;
|
|
541
|
+
var v = kv.length > 1 ? kv.slice(1).join("=").trim() : true;
|
|
542
|
+
// Strip surrounding quotes per the token-or-quoted-string grammar.
|
|
543
|
+
if (typeof v === "string") {
|
|
544
|
+
var _unq = structuredFields.unquoteSfString(v);
|
|
545
|
+
if (_unq !== null) v = _unq;
|
|
546
|
+
}
|
|
547
|
+
ext.params[k] = v;
|
|
548
|
+
}
|
|
549
|
+
out.push(ext);
|
|
550
|
+
}
|
|
551
|
+
return out;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
function _negotiatePermessageDeflate(reqHeader) {
|
|
555
|
+
var entries = _parseExtensionHeader(reqHeader);
|
|
556
|
+
for (var i = 0; i < entries.length; i++) {
|
|
557
|
+
if (entries[i].name !== "permessage-deflate") continue;
|
|
558
|
+
var p = entries[i].params;
|
|
559
|
+
// Reject unknown params (RFC 7692 §7 lists exactly four).
|
|
560
|
+
var KNOWN = {
|
|
561
|
+
"server_no_context_takeover": true, "client_no_context_takeover": true,
|
|
562
|
+
"server_max_window_bits": true, "client_max_window_bits": true,
|
|
563
|
+
};
|
|
564
|
+
var ok = true;
|
|
565
|
+
for (var k in p) { if (Object.prototype.hasOwnProperty.call(p, k) && !KNOWN[k]) { ok = false; break; } }
|
|
566
|
+
if (!ok) continue;
|
|
567
|
+
// Always negotiate WITH no_context_takeover in BOTH directions, so
|
|
568
|
+
// every message uses a fresh zlib state. Echo any client window-
|
|
569
|
+
// bits constraints back unchanged (we honour them on the server's
|
|
570
|
+
// outgoing compression).
|
|
571
|
+
var responseParams = ["client_no_context_takeover", "server_no_context_takeover"];
|
|
572
|
+
if (p.client_max_window_bits && p.client_max_window_bits !== true) {
|
|
573
|
+
responseParams.push("client_max_window_bits=" + p.client_max_window_bits);
|
|
574
|
+
}
|
|
575
|
+
if (p.server_max_window_bits && p.server_max_window_bits !== true) {
|
|
576
|
+
responseParams.push("server_max_window_bits=" + p.server_max_window_bits);
|
|
577
|
+
}
|
|
578
|
+
// RFC 7692 §7.1: max_window_bits is 8..15 inclusive; 15 is the
|
|
579
|
+
// unconstrained default. Hex-encoded so the byte-literal lint
|
|
580
|
+
// doesn't flag the 8 lower bound.
|
|
581
|
+
var WB_MIN = 0x8;
|
|
582
|
+
var WB_MAX = 0xF;
|
|
583
|
+
return {
|
|
584
|
+
negotiated: true,
|
|
585
|
+
responseHeader: "permessage-deflate; " + responseParams.join("; "),
|
|
586
|
+
// window-bits constraints we honour; default WB_MAX (15) when unset.
|
|
587
|
+
serverMaxWindowBits: p.server_max_window_bits && p.server_max_window_bits !== true
|
|
588
|
+
? Math.max(WB_MIN, Math.min(WB_MAX, parseInt(p.server_max_window_bits, 10) || WB_MAX)) : WB_MAX,
|
|
589
|
+
clientMaxWindowBits: p.client_max_window_bits && p.client_max_window_bits !== true
|
|
590
|
+
? Math.max(WB_MIN, Math.min(WB_MAX, parseInt(p.client_max_window_bits, 10) || WB_MAX)) : WB_MAX,
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
return { negotiated: false };
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function _deflateMessage(payload, windowBits) {
|
|
597
|
+
// Per RFC 7692 §7.2.1, strip the 4-byte 0x00 0x00 0xff 0xff trailer.
|
|
598
|
+
var raw = zlib.deflateRawSync(payload, { windowBits: windowBits, level: zlib.constants.Z_DEFAULT_COMPRESSION });
|
|
599
|
+
if (raw.length >= 4 &&
|
|
600
|
+
raw[raw.length - 4] === 0x00 && raw[raw.length - 3] === 0x00 &&
|
|
601
|
+
raw[raw.length - 2] === 0xff && raw[raw.length - 1] === 0xff) {
|
|
602
|
+
return raw.slice(0, raw.length - 4);
|
|
603
|
+
}
|
|
604
|
+
return raw;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function _inflateMessage(payload, windowBits, maxOutputBytes) {
|
|
608
|
+
// Per RFC 7692 §7.2.2, append the 4-byte trailer before inflating.
|
|
609
|
+
// Routes through `b.safeDecompress` so the bounded-output defense
|
|
610
|
+
// is uniform with every other RFC 1951 deflate site in the
|
|
611
|
+
// framework. `maxRatio: 0` (unlimited expansion) because WS
|
|
612
|
+
// per-message-deflate already binds upstream via the operator's
|
|
613
|
+
// `maxMessageBytes` opt; the absolute cap is the real defense.
|
|
614
|
+
// Streaming WS payloads can legitimately compress > 50:1 on
|
|
615
|
+
// repetitive text (logs, sensor data); operators with a
|
|
616
|
+
// tighter posture set their own maxMessageBytes.
|
|
617
|
+
var withTrailer = Buffer.concat([payload, DEFLATE_TRAILING]);
|
|
618
|
+
// `maxCompressedBytes` MUST track the operator's `maxMessageBytes`,
|
|
619
|
+
// not safeDecompress's 4 MiB default. WS operators with high-
|
|
620
|
+
// throughput pipelines legitimately set `maxMessageBytes > 4 MiB`
|
|
621
|
+
// (large file pushes, batched JSON, telemetry); a compressed
|
|
622
|
+
// payload up to that cap is legitimate input. The compressed input
|
|
623
|
+
// is bounded above by the same cap the framework enforces on
|
|
624
|
+
// reassembled-message bytes (RFC 6455 §5.4 fragmented messages are
|
|
625
|
+
// concatenated then decompressed; the operator's `maxMessageBytes`
|
|
626
|
+
// is enforced at FrameParser reassembly), so passing it here keeps
|
|
627
|
+
// safeDecompress aligned with the operator's intent rather than
|
|
628
|
+
// overriding it with the primitive's general-purpose default.
|
|
629
|
+
return safeDecompress(withTrailer, {
|
|
630
|
+
algorithm: "deflate-raw",
|
|
631
|
+
maxOutputBytes: maxOutputBytes,
|
|
632
|
+
maxCompressedBytes: maxOutputBytes,
|
|
633
|
+
maxRatio: 0,
|
|
634
|
+
windowBits: windowBits,
|
|
635
|
+
ctx: "websocket._inflateMessage",
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// ---- Frame parser ----
|
|
640
|
+
//
|
|
641
|
+
// Incremental — push(chunk) accepts arbitrary buffer slices from the
|
|
642
|
+
// socket and emits zero-or-more complete frames as they arrive. Holds
|
|
643
|
+
// partial frame state across calls.
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* @primitive b.websocket.FrameParser
|
|
647
|
+
* @signature b.websocket.FrameParser(opts)
|
|
648
|
+
* @since 0.1.38
|
|
649
|
+
* @status stable
|
|
650
|
+
* @related b.websocket.serializeFrame, b.websocket.WebSocketConnection
|
|
651
|
+
*
|
|
652
|
+
* Incremental RFC 6455 §5.2 frame parser. `push(chunk)` accepts
|
|
653
|
+
* arbitrary buffer slices straight from the socket and returns zero
|
|
654
|
+
* or more complete frames; partial frame state persists across
|
|
655
|
+
* calls. Each emitted frame is
|
|
656
|
+
* `{ fin, rsv1, rsv2, rsv3, opcode, masked, payload }`. Throws a
|
|
657
|
+
* `WebSocketError` (closeCode = 1009 message-too-big) when a single
|
|
658
|
+
* frame's declared payload length exceeds `opts.maxFrameBytes`
|
|
659
|
+
* (default 1 MiB) — the caller catches it and aborts the connection.
|
|
660
|
+
* The parser does NOT enforce control-frame ≤125-byte caps,
|
|
661
|
+
* mask-direction policy, or RSV-bit-vs-extension consistency; those
|
|
662
|
+
* are the connection layer's job.
|
|
663
|
+
*
|
|
664
|
+
* @opts
|
|
665
|
+
* maxFrameBytes: number, // single-frame payload cap (default 1 MiB)
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
* var parser = new b.websocket.FrameParser({ maxFrameBytes: 65536 });
|
|
669
|
+
* var frames = parser.push(Buffer.from([0x81, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f]));
|
|
670
|
+
* // → [{ fin: true, opcode: 1, payload: <Buffer 68 65 6c 6c 6f>, ... }]
|
|
671
|
+
*/
|
|
672
|
+
function FrameParser(opts) {
|
|
673
|
+
opts = opts || {};
|
|
674
|
+
this.maxFrameBytes = opts.maxFrameBytes || DEFAULT_MAX_MESSAGE_BYTES;
|
|
675
|
+
this._buffer = Buffer.alloc(0);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
FrameParser.prototype.push = function (chunk) {
|
|
679
|
+
this._buffer = Buffer.concat([this._buffer, chunk]);
|
|
680
|
+
var frames = [];
|
|
681
|
+
while (true) {
|
|
682
|
+
var frame = this._tryParseFrame();
|
|
683
|
+
if (!frame) break; // incomplete — wait for more bytes
|
|
684
|
+
frames.push(frame);
|
|
685
|
+
}
|
|
686
|
+
return frames;
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
FrameParser.prototype._tryParseFrame = function () {
|
|
690
|
+
if (this._buffer.length < 2) return null;
|
|
691
|
+
var b0 = this._buffer[0];
|
|
692
|
+
var b1 = this._buffer[1];
|
|
693
|
+
var fin = !!(b0 & 0x80);
|
|
694
|
+
var rsv1 = !!(b0 & 0x40);
|
|
695
|
+
var rsv2 = !!(b0 & 0x20);
|
|
696
|
+
var rsv3 = !!(b0 & 0x10);
|
|
697
|
+
var opcode = b0 & 0x0F;
|
|
698
|
+
var masked = !!(b1 & 0x80);
|
|
699
|
+
var lenInd = b1 & 0x7F;
|
|
700
|
+
|
|
701
|
+
var headerLen = 2;
|
|
702
|
+
if (lenInd === 126) headerLen += 2;
|
|
703
|
+
else if (lenInd === 127) headerLen += C.BYTES.bytes(8);
|
|
704
|
+
if (masked) headerLen += 4;
|
|
705
|
+
if (this._buffer.length < headerLen) return null;
|
|
706
|
+
|
|
707
|
+
var payloadLen;
|
|
708
|
+
var off = 2;
|
|
709
|
+
if (lenInd < 126) {
|
|
710
|
+
payloadLen = lenInd;
|
|
711
|
+
} else if (lenInd === 126) {
|
|
712
|
+
payloadLen = this._buffer.readUInt16BE(off);
|
|
713
|
+
off += 2;
|
|
714
|
+
} else {
|
|
715
|
+
// 64-bit. JS Number is 53-bit safe — reject lengths above
|
|
716
|
+
// Number.MAX_SAFE_INTEGER explicitly rather than silently
|
|
717
|
+
// truncating.
|
|
718
|
+
var hi = this._buffer.readUInt32BE(off);
|
|
719
|
+
var lo = this._buffer.readUInt32BE(off + 4);
|
|
720
|
+
if (hi > 0x1FFFFF) {
|
|
721
|
+
throw new WebSocketError("ws/frame-too-large",
|
|
722
|
+
"frame length exceeds Number.MAX_SAFE_INTEGER", CLOSE_MESSAGE_TOO_BIG);
|
|
723
|
+
}
|
|
724
|
+
payloadLen = (hi * 0x100000000) + lo;
|
|
725
|
+
off += C.BYTES.bytes(8);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
if (payloadLen > this.maxFrameBytes) {
|
|
729
|
+
throw new WebSocketError("ws/frame-too-large",
|
|
730
|
+
"frame payload exceeds maxFrameBytes (" + this.maxFrameBytes + ")",
|
|
731
|
+
CLOSE_MESSAGE_TOO_BIG);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
var maskKey = null;
|
|
735
|
+
if (masked) {
|
|
736
|
+
maskKey = Buffer.from(this._buffer.subarray(off, off + 4));
|
|
737
|
+
off += 4;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
var totalLen = off + payloadLen;
|
|
741
|
+
if (this._buffer.length < totalLen) return null;
|
|
742
|
+
|
|
743
|
+
var payload = this._buffer.subarray(off, totalLen);
|
|
744
|
+
if (masked) {
|
|
745
|
+
var unmasked = Buffer.alloc(payloadLen);
|
|
746
|
+
for (var i = 0; i < payloadLen; i++) {
|
|
747
|
+
unmasked[i] = payload[i] ^ maskKey[i & 3];
|
|
748
|
+
}
|
|
749
|
+
payload = unmasked;
|
|
750
|
+
} else {
|
|
751
|
+
// Copy out — the underlying buffer is about to be sliced.
|
|
752
|
+
payload = Buffer.from(payload);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
this._buffer = this._buffer.subarray(totalLen);
|
|
756
|
+
|
|
757
|
+
return {
|
|
758
|
+
fin: fin,
|
|
759
|
+
rsv1: rsv1,
|
|
760
|
+
rsv2: rsv2,
|
|
761
|
+
rsv3: rsv3,
|
|
762
|
+
opcode: opcode,
|
|
763
|
+
masked: masked,
|
|
764
|
+
payload: payload,
|
|
765
|
+
};
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
// ---- Frame serializer ----
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* @primitive b.websocket.serializeFrame
|
|
772
|
+
* @signature b.websocket.serializeFrame(opcode, payload, opts)
|
|
773
|
+
* @since 0.1.38
|
|
774
|
+
* @status stable
|
|
775
|
+
* @related b.websocket.FrameParser, b.websocket.WebSocketConnection
|
|
776
|
+
*
|
|
777
|
+
* Build a single RFC 6455 §5.2 frame. `opcode` is one of
|
|
778
|
+
* `b.websocket.OPCODE_TEXT` / `OPCODE_BINARY` / `OPCODE_CLOSE` /
|
|
779
|
+
* `OPCODE_PING` / `OPCODE_PONG` / `OPCODE_CONTINUATION`. `payload`
|
|
780
|
+
* is a `Buffer` or string (string is UTF-8 encoded). Server-side
|
|
781
|
+
* frames default to unmasked; pass `mask: true` only for
|
|
782
|
+
* client-shaped fixtures or test harnesses. `rsv1: true` marks the
|
|
783
|
+
* first frame of a permessage-deflate-compressed message (RFC 7692).
|
|
784
|
+
* Returns the framed `Buffer`.
|
|
785
|
+
*
|
|
786
|
+
* @opts
|
|
787
|
+
* fin: boolean, // FIN bit, default true (single-frame message)
|
|
788
|
+
* mask: boolean, // mask the payload, default false (server side)
|
|
789
|
+
* rsv1: boolean, // RSV1 bit (permessage-deflate), default false
|
|
790
|
+
*
|
|
791
|
+
* @example
|
|
792
|
+
* var frame = b.websocket.serializeFrame(
|
|
793
|
+
* b.websocket.OPCODE_TEXT, "hello");
|
|
794
|
+
* // → <Buffer 81 05 68 65 6c 6c 6f>
|
|
795
|
+
* socket.write(frame);
|
|
796
|
+
*/
|
|
797
|
+
function serializeFrame(opcode, payload, opts) {
|
|
798
|
+
opts = opts || {};
|
|
799
|
+
var fin = opts.fin !== false;
|
|
800
|
+
var mask = opts.mask === true; // server-side defaults false
|
|
801
|
+
// RSV1 — set on the first frame of a permessage-deflate-compressed
|
|
802
|
+
// message (RFC 7692). Caller passes opts.rsv1 = true; we wire it
|
|
803
|
+
// into the header byte. RSV2 / RSV3 stay zero (no other extensions
|
|
804
|
+
// negotiated).
|
|
805
|
+
var rsv1 = opts.rsv1 === true;
|
|
806
|
+
payload = payload || Buffer.alloc(0);
|
|
807
|
+
if (typeof payload === "string") payload = Buffer.from(payload, "utf8");
|
|
808
|
+
if (!Buffer.isBuffer(payload)) {
|
|
809
|
+
throw new WebSocketError("ws/invalid-payload",
|
|
810
|
+
"frame payload must be Buffer or string");
|
|
811
|
+
}
|
|
812
|
+
var len = payload.length;
|
|
813
|
+
|
|
814
|
+
var headerLen = 2;
|
|
815
|
+
var lenByte;
|
|
816
|
+
// RFC 6455 §5.2 — 16-bit extended length boundary at 2^16.
|
|
817
|
+
var EXT16_BOUNDARY = 0x10000;
|
|
818
|
+
if (len < 126) { lenByte = len; }
|
|
819
|
+
else if (len < EXT16_BOUNDARY) { lenByte = 126; headerLen += 2; }
|
|
820
|
+
else { lenByte = 127; headerLen += C.BYTES.bytes(8); }
|
|
821
|
+
if (mask) headerLen += 4;
|
|
822
|
+
|
|
823
|
+
var header = Buffer.alloc(headerLen);
|
|
824
|
+
header[0] = (fin ? 0x80 : 0) | (rsv1 ? 0x40 : 0) | (opcode & 0x0F);
|
|
825
|
+
header[1] = (mask ? 0x80 : 0) | lenByte;
|
|
826
|
+
|
|
827
|
+
var off = 2;
|
|
828
|
+
if (lenByte === 126) {
|
|
829
|
+
header.writeUInt16BE(len, off);
|
|
830
|
+
off += 2;
|
|
831
|
+
} else if (lenByte === 127) {
|
|
832
|
+
var hi = Math.floor(len / 0x100000000);
|
|
833
|
+
var lo = len % 0x100000000;
|
|
834
|
+
header.writeUInt32BE(hi, off);
|
|
835
|
+
header.writeUInt32BE(lo, off + 4);
|
|
836
|
+
off += C.BYTES.bytes(8);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
if (mask) {
|
|
840
|
+
var maskKey = nodeCrypto.randomBytes(4);
|
|
841
|
+
maskKey.copy(header, off);
|
|
842
|
+
var masked = Buffer.alloc(len);
|
|
843
|
+
for (var i = 0; i < len; i++) masked[i] = payload[i] ^ maskKey[i & 3];
|
|
844
|
+
return Buffer.concat([header, masked]);
|
|
845
|
+
}
|
|
846
|
+
return Buffer.concat([header, payload]);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// ---- Connection ----
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* @primitive b.websocket.WebSocketConnection
|
|
853
|
+
* @signature b.websocket.WebSocketConnection(socket, opts)
|
|
854
|
+
* @since 0.1.38
|
|
855
|
+
* @status stable
|
|
856
|
+
* @related b.websocket.handleUpgrade, b.websocket.handleExtendedConnect, b.websocket.WebSocketError
|
|
857
|
+
*
|
|
858
|
+
* EventEmitter wrapping a post-upgrade socket / h2 stream. State
|
|
859
|
+
* machine mirrors the browser WebSocket API:
|
|
860
|
+
*
|
|
861
|
+
* - `conn.readyState` — `'open' | 'closing' | 'closed'`
|
|
862
|
+
* - `conn.send(data)` — `Buffer` or string. Routes to BINARY or
|
|
863
|
+
* TEXT frame; throws `WebSocketError` if not OPEN.
|
|
864
|
+
* - `conn.ping(payload?)` — send PING (no-op if not OPEN).
|
|
865
|
+
* - `conn.close(code?, reason?)` — send CLOSE, wait `closeGraceMs`
|
|
866
|
+
* for the peer's echo, end the underlying socket.
|
|
867
|
+
*
|
|
868
|
+
* Events: `'message' (data, isBinary)`, `'ping' (payload)`,
|
|
869
|
+
* `'pong' (payload)`, `'close' (code, reason, wasClean)` (fires
|
|
870
|
+
* exactly once at lifecycle end), `'error' (err)`.
|
|
871
|
+
*
|
|
872
|
+
* Cluster fan-out / channel broadcast lives at the router layer that
|
|
873
|
+
* owns the connection registry; this primitive owns the per-
|
|
874
|
+
* connection protocol. To broadcast, iterate the operator-side
|
|
875
|
+
* registry and call `send` on each.
|
|
876
|
+
*
|
|
877
|
+
* @opts
|
|
878
|
+
* subprotocol: string, // negotiated value from handleUpgrade
|
|
879
|
+
* transport: "h1" | "h2", // mask-direction policy, default "h1"
|
|
880
|
+
* maxMessageBytes: number, // total reassembled-message cap, default 1 MiB
|
|
881
|
+
* pingIntervalMs: number, // heartbeat interval, default 30s
|
|
882
|
+
* pongTimeoutMs: number, // abort threshold without pong, default 35s
|
|
883
|
+
* closeGraceMs: number, // peer-echo wait after close(), default 2s
|
|
884
|
+
* permessageDeflate: object | null, // negotiated state, usually from handleUpgrade
|
|
885
|
+
*
|
|
886
|
+
* @example
|
|
887
|
+
* server.on("upgrade", function (req, socket, head) {
|
|
888
|
+
* var conn = b.websocket.handleUpgrade(req, socket, head, {
|
|
889
|
+
* subprotocols: ["chat.v1"],
|
|
890
|
+
* });
|
|
891
|
+
* if (!conn) return;
|
|
892
|
+
* conn.on("message", function (data, isBinary) {
|
|
893
|
+
* conn.send(isBinary ? data : "echo: " + data);
|
|
894
|
+
* });
|
|
895
|
+
* conn.on("ping", function (payload) { void payload; }); // framework auto-pongs
|
|
896
|
+
* conn.on("pong", function (payload) { void payload; }); // heartbeat reply
|
|
897
|
+
|
|
898
|
+
* conn.on("close", function (code, reason, wasClean) {
|
|
899
|
+
* // → 1000, "", true
|
|
900
|
+
* });
|
|
901
|
+
* });
|
|
902
|
+
*/
|
|
903
|
+
class WebSocketConnection extends EventEmitter {
|
|
904
|
+
constructor(socket, opts) {
|
|
905
|
+
super();
|
|
906
|
+
opts = opts || {};
|
|
907
|
+
this.socket = socket;
|
|
908
|
+
this.subprotocol = opts.subprotocol || null;
|
|
909
|
+
this.maxMessageBytes = opts.maxMessageBytes || DEFAULT_MAX_MESSAGE_BYTES;
|
|
910
|
+
// Transport selects mask-enforcement direction:
|
|
911
|
+
// h1 (RFC 6455): client→server frames MUST be masked. Default.
|
|
912
|
+
// h2 (RFC 8441): frames MUST NOT be masked — h2 already provides
|
|
913
|
+
// the framing/security guarantees that masking
|
|
914
|
+
// exists to protect against in h1 (proxy
|
|
915
|
+
// cache-poisoning via raw text on the wire).
|
|
916
|
+
this.transport = opts.transport === "h2" ? "h2" : "h1";
|
|
917
|
+
// permessage-deflate state — `null` means extension not negotiated.
|
|
918
|
+
// When negotiated the object carries serverMaxWindowBits +
|
|
919
|
+
// clientMaxWindowBits the inflate/deflate paths use per message.
|
|
920
|
+
this._permessageDeflate = opts.permessageDeflate || null;
|
|
921
|
+
var pingMs = opts.pingIntervalMs || DEFAULT_PING_INTERVAL_MS;
|
|
922
|
+
var pongMs = opts.pongTimeoutMs || DEFAULT_PONG_TIMEOUT_MS;
|
|
923
|
+
// Grace period after we send a close frame before forcing the
|
|
924
|
+
// socket end. Production default = 5s (give the peer time to ack).
|
|
925
|
+
// Tests / latency-sensitive ops can pass a shorter value.
|
|
926
|
+
this._closeGraceMs = opts.closeGraceMs != null ? opts.closeGraceMs : CLOSE_GRACE_MS;
|
|
927
|
+
|
|
928
|
+
// Lifecycle state — single source of truth. Operators read
|
|
929
|
+
// conn.readyState; internal code reads/writes this._state via
|
|
930
|
+
// _transitionToClosed. All transitions emit 'close' exactly once.
|
|
931
|
+
this._state = STATE_OPEN;
|
|
932
|
+
this._closeSent = false;
|
|
933
|
+
this._closeTimer = null;
|
|
934
|
+
this.lastError = null; // last diagnosable error, if any
|
|
935
|
+
// Fragmentation reassembly state.
|
|
936
|
+
this._fragOpcode = null;
|
|
937
|
+
this._fragChunks = null;
|
|
938
|
+
this._fragLen = 0;
|
|
939
|
+
|
|
940
|
+
this._parser = new FrameParser({ maxFrameBytes: this.maxMessageBytes });
|
|
941
|
+
this._lastPongAt = Date.now();
|
|
942
|
+
|
|
943
|
+
var self = this;
|
|
944
|
+
this._pingTimer = safeAsync.repeating(function () { self._heartbeat(pongMs); },
|
|
945
|
+
pingMs, { name: "websocket-ping" });
|
|
946
|
+
|
|
947
|
+
socket.on("data", function (chunk) { self._onData(chunk); });
|
|
948
|
+
socket.on("error", function (err) {
|
|
949
|
+
// Network errors are LIFECYCLE events, not protocol errors —
|
|
950
|
+
// route through _transitionToClosed with code 1006 (abnormal
|
|
951
|
+
// closure). Mirrors the browser WebSocket API + ws npm
|
|
952
|
+
// convention: operators listening on 'close' see the death;
|
|
953
|
+
// 'error' is reserved for diagnosable protocol issues that
|
|
954
|
+
// the operator may want to explicitly handle.
|
|
955
|
+
self._transitionToClosed(1006, (err && err.message) || "socket error", false, err);
|
|
956
|
+
});
|
|
957
|
+
socket.on("close", function () {
|
|
958
|
+
// Socket FIN/RST seen — if we haven't already transitioned via
|
|
959
|
+
// a clean close-handshake, this is an abnormal closure.
|
|
960
|
+
if (self._state !== STATE_CLOSED) {
|
|
961
|
+
self._transitionToClosed(1006, "abnormal closure", false, null);
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
// Single state-transition method. Idempotent — repeat calls after
|
|
967
|
+
// CLOSED are no-ops. Emits 'close' exactly once with (code, reason,
|
|
968
|
+
// wasClean) signature matching the browser API.
|
|
969
|
+
_transitionToClosed(code, reason, wasClean, error) {
|
|
970
|
+
if (this._state === STATE_CLOSED) return;
|
|
971
|
+
this._state = STATE_CLOSED;
|
|
972
|
+
if (error) this.lastError = error;
|
|
973
|
+
if (this._pingTimer) { this._pingTimer.stop(); this._pingTimer = null; }
|
|
974
|
+
if (this._closeTimer) { clearTimeout(this._closeTimer); this._closeTimer = null; }
|
|
975
|
+
// Surface diagnosable errors via 'error' first — but only if the
|
|
976
|
+
// operator is listening AND this is a real diagnosable case.
|
|
977
|
+
// EventEmitter throws "Unhandled 'error' event" on emit() with no
|
|
978
|
+
// listener; gate the emit to avoid taking down the process.
|
|
979
|
+
if (error && this.listenerCount("error") > 0) {
|
|
980
|
+
try { this.emit("error", error); } catch (_e) { /* listener threw — ignore */ }
|
|
981
|
+
}
|
|
982
|
+
this.emit("close", code, reason, !!wasClean);
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// Browser-style state field. 'open' | 'closing' | 'closed'.
|
|
986
|
+
get readyState() { return this._state; }
|
|
987
|
+
|
|
988
|
+
_onData(chunk) {
|
|
989
|
+
var frames;
|
|
990
|
+
try { frames = this._parser.push(chunk); }
|
|
991
|
+
catch (err) {
|
|
992
|
+
var code = err.closeCode || CLOSE_PROTOCOL_ERROR;
|
|
993
|
+
return this._abort(code, err.message);
|
|
994
|
+
}
|
|
995
|
+
for (var i = 0; i < frames.length; i++) {
|
|
996
|
+
this._handleFrame(frames[i]);
|
|
997
|
+
if (this._state === STATE_CLOSED) return;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
_handleFrame(frame) {
|
|
1002
|
+
// Mask enforcement flips by transport (RFC 6455 §5.3 vs RFC 8441):
|
|
1003
|
+
// h1: client→server frames MUST be masked
|
|
1004
|
+
// h2: frames MUST NOT be masked (h2 transport provides the
|
|
1005
|
+
// protections that masking exists for)
|
|
1006
|
+
if (this.transport === "h1" && !frame.masked) {
|
|
1007
|
+
return this._abort(CLOSE_PROTOCOL_ERROR, "client frame not masked (h1)");
|
|
1008
|
+
}
|
|
1009
|
+
if (this.transport === "h2" && frame.masked) {
|
|
1010
|
+
return this._abort(CLOSE_PROTOCOL_ERROR, "frame must not be masked (h2)");
|
|
1011
|
+
}
|
|
1012
|
+
// Reserved bits — must be zero unless a negotiated extension uses them.
|
|
1013
|
+
// RSV1 is permessage-deflate (RFC 7692). RSV2/RSV3 unused; any RSV2
|
|
1014
|
+
// or RSV3 bit set, OR RSV1 set when permessage-deflate wasn't
|
|
1015
|
+
// negotiated, is a protocol error.
|
|
1016
|
+
if (frame.rsv2 || frame.rsv3) {
|
|
1017
|
+
return this._abort(CLOSE_PROTOCOL_ERROR, "reserved bits set without extension");
|
|
1018
|
+
}
|
|
1019
|
+
if (frame.rsv1 && !this._permessageDeflate) {
|
|
1020
|
+
return this._abort(CLOSE_PROTOCOL_ERROR, "RSV1 set without permessage-deflate negotiated");
|
|
1021
|
+
}
|
|
1022
|
+
// RSV1 is only legal on the FIRST frame of a message (TEXT/BINARY).
|
|
1023
|
+
// Continuation frames inherit the compression flag from the start.
|
|
1024
|
+
if (frame.rsv1 && frame.opcode === OPCODE_CONTINUATION) {
|
|
1025
|
+
return this._abort(CLOSE_PROTOCOL_ERROR, "RSV1 on continuation frame (must be on start)");
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// RFC 6455 §5.5 — control frames (opcodes >= 0x8: CLOSE/PING/PONG)
|
|
1029
|
+
// MUST have payload length ≤ 125 and MUST NOT be fragmented.
|
|
1030
|
+
// Without the cap an attacker can send a 1 MiB PING and we echo it
|
|
1031
|
+
// verbatim as PONG — a 2× outbound-bandwidth amplification DoS.
|
|
1032
|
+
if (frame.opcode >= 0x8) {
|
|
1033
|
+
if (frame.payload.length > 125) {
|
|
1034
|
+
return this._abort(CLOSE_PROTOCOL_ERROR,
|
|
1035
|
+
"control frame payload exceeds 125 bytes (RFC 6455 §5.5)");
|
|
1036
|
+
}
|
|
1037
|
+
if (!frame.fin) {
|
|
1038
|
+
return this._abort(CLOSE_PROTOCOL_ERROR,
|
|
1039
|
+
"control frame must not be fragmented (RFC 6455 §5.5)");
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
if (frame.opcode === OPCODE_CONTINUATION) {
|
|
1044
|
+
if (this._fragOpcode === null) {
|
|
1045
|
+
return this._abort(CLOSE_PROTOCOL_ERROR, "continuation without start");
|
|
1046
|
+
}
|
|
1047
|
+
this._appendFragment(frame);
|
|
1048
|
+
} else if (frame.opcode === OPCODE_TEXT || frame.opcode === OPCODE_BINARY) {
|
|
1049
|
+
if (this._fragOpcode !== null) {
|
|
1050
|
+
return this._abort(CLOSE_PROTOCOL_ERROR, "new message during fragmentation");
|
|
1051
|
+
}
|
|
1052
|
+
this._fragOpcode = frame.opcode;
|
|
1053
|
+
this._fragChunks = [frame.payload];
|
|
1054
|
+
this._fragLen = frame.payload.length;
|
|
1055
|
+
this._fragCompressed = !!frame.rsv1;
|
|
1056
|
+
if (frame.fin) this._emitMessage();
|
|
1057
|
+
} else if (frame.opcode === OPCODE_CLOSE) {
|
|
1058
|
+
this._handleClose(frame);
|
|
1059
|
+
} else if (frame.opcode === OPCODE_PING) {
|
|
1060
|
+
this.emit("ping", frame.payload);
|
|
1061
|
+
this._sendFrame(OPCODE_PONG, frame.payload);
|
|
1062
|
+
} else if (frame.opcode === OPCODE_PONG) {
|
|
1063
|
+
this._lastPongAt = Date.now();
|
|
1064
|
+
this.emit("pong", frame.payload);
|
|
1065
|
+
} else {
|
|
1066
|
+
this._abort(CLOSE_PROTOCOL_ERROR, "unknown opcode " + frame.opcode);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
_appendFragment(frame) {
|
|
1071
|
+
var newLen = this._fragLen + frame.payload.length;
|
|
1072
|
+
if (newLen > this.maxMessageBytes) {
|
|
1073
|
+
return this._abort(CLOSE_MESSAGE_TOO_BIG, "message exceeds maxMessageBytes");
|
|
1074
|
+
}
|
|
1075
|
+
this._fragChunks.push(frame.payload);
|
|
1076
|
+
this._fragLen = newLen;
|
|
1077
|
+
if (frame.fin) this._emitMessage();
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
_emitMessage() {
|
|
1081
|
+
var data = this._fragChunks.length === 1
|
|
1082
|
+
? this._fragChunks[0]
|
|
1083
|
+
: Buffer.concat(this._fragChunks, this._fragLen);
|
|
1084
|
+
var opcode = this._fragOpcode;
|
|
1085
|
+
var wasCompressed = this._fragCompressed;
|
|
1086
|
+
this._fragOpcode = null;
|
|
1087
|
+
this._fragChunks = null;
|
|
1088
|
+
this._fragLen = 0;
|
|
1089
|
+
this._fragCompressed = false;
|
|
1090
|
+
// Decompress before emitting if the start frame had RSV1 set.
|
|
1091
|
+
// RFC 7692: malformed deflate is a protocol error, surfaced as
|
|
1092
|
+
// CLOSE_INVALID_PAYLOAD per §5.6 / §6 of RFC 6455.
|
|
1093
|
+
if (wasCompressed) {
|
|
1094
|
+
try {
|
|
1095
|
+
data = _inflateMessage(data, this._permessageDeflate.clientMaxWindowBits,
|
|
1096
|
+
this.maxMessageBytes);
|
|
1097
|
+
} catch (e) {
|
|
1098
|
+
// RFC 6455 §7.4.1 / §5.6 — protocol-level decode failure
|
|
1099
|
+
// (including bomb-cap overrun via maxOutputLength) returns
|
|
1100
|
+
// CLOSE_INVALID_PAYLOAD. The over-cap case never allocates the
|
|
1101
|
+
// exploded bytes — zlib's maxOutputLength refuses mid-inflate.
|
|
1102
|
+
return this._abort(CLOSE_INVALID_PAYLOAD,
|
|
1103
|
+
"permessage-deflate inflate failed: " + ((e && e.message) || String(e)));
|
|
1104
|
+
}
|
|
1105
|
+
if (data.length > this.maxMessageBytes) {
|
|
1106
|
+
return this._abort(CLOSE_MESSAGE_TOO_BIG,
|
|
1107
|
+
"decompressed message exceeds maxMessageBytes");
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
if (opcode === OPCODE_TEXT) {
|
|
1111
|
+
// §5.6: text frames MUST be valid UTF-8. Buffer.toString silently
|
|
1112
|
+
// replaces invalid sequences with U+FFFD; explicit validation
|
|
1113
|
+
// rejects malformed data per spec.
|
|
1114
|
+
var str;
|
|
1115
|
+
try { str = new TextDecoder("utf-8", { fatal: true }).decode(data); }
|
|
1116
|
+
catch (_e) { return this._abort(CLOSE_INVALID_PAYLOAD, "text frame is not valid UTF-8"); }
|
|
1117
|
+
this.emit("message", str, false);
|
|
1118
|
+
} else {
|
|
1119
|
+
this.emit("message", data, true);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
_handleClose(frame) {
|
|
1124
|
+
var code = CLOSE_NORMAL, reason = "";
|
|
1125
|
+
// RFC 6455 §5.5.1 — close-frame body is either empty or 2+
|
|
1126
|
+
// bytes (2-byte close code + optional UTF-8 reason). A 1-byte
|
|
1127
|
+
// body is malformed; pre-v0.8.33 the framework silently
|
|
1128
|
+
// accepted it as a clean close, evading anomaly detection
|
|
1129
|
+
// that would have classified the malformation.
|
|
1130
|
+
if (frame.payload.length === 1) {
|
|
1131
|
+
return this._abort(CLOSE_PROTOCOL_ERROR,
|
|
1132
|
+
"close frame payload must be 0 or >=2 bytes (RFC 6455 §5.5.1)");
|
|
1133
|
+
}
|
|
1134
|
+
if (frame.payload.length >= 2) {
|
|
1135
|
+
code = frame.payload.readUInt16BE(0);
|
|
1136
|
+
// RFC 6455 §7.4.2 — codes 0..999 MUST NOT be used. 1004 /
|
|
1137
|
+
// 1005 / 1006 / 1015 are reserved (1005/1006 are local-only
|
|
1138
|
+
// sentinels; 1004/1015 are reserved for future use).
|
|
1139
|
+
// 1000-1011 + 3000-4999 are valid; everything else is invalid.
|
|
1140
|
+
if (!_isValidCloseCode(code)) {
|
|
1141
|
+
return this._abort(CLOSE_PROTOCOL_ERROR,
|
|
1142
|
+
"close code " + code + " is reserved or invalid (RFC 6455 §7.4.2)");
|
|
1143
|
+
}
|
|
1144
|
+
if (frame.payload.length > 2) {
|
|
1145
|
+
try { reason = new TextDecoder("utf-8", { fatal: true }).decode(frame.payload.subarray(2)); }
|
|
1146
|
+
catch (_e) { return this._abort(CLOSE_INVALID_PAYLOAD, "close reason is not valid UTF-8"); }
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
if (!this._closeSent) {
|
|
1150
|
+
// Echo close (§5.5.1) — peer initiated, we acknowledge.
|
|
1151
|
+
this._sendCloseFrame(code, reason);
|
|
1152
|
+
this._closeSent = true;
|
|
1153
|
+
}
|
|
1154
|
+
// Transition to CLOSED — clean handshake completed (wasClean=true).
|
|
1155
|
+
// The socket close will arrive shortly; _transitionToClosed is
|
|
1156
|
+
// idempotent so the socket-close handler running afterward is a
|
|
1157
|
+
// no-op.
|
|
1158
|
+
try { this.socket.end(); } catch (_e) { /* socket already closed by peer */ }
|
|
1159
|
+
this._transitionToClosed(code, reason, true, null);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
_sendCloseFrame(code, reason) {
|
|
1163
|
+
var reasonBuf = reason ? Buffer.from(String(reason), "utf8") : Buffer.alloc(0);
|
|
1164
|
+
var payload = Buffer.alloc(2 + reasonBuf.length);
|
|
1165
|
+
payload.writeUInt16BE(code, 0);
|
|
1166
|
+
if (reasonBuf.length) reasonBuf.copy(payload, 2);
|
|
1167
|
+
this._sendFrame(OPCODE_CLOSE, payload);
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
_sendFrame(opcode, payload, opts) {
|
|
1171
|
+
if (this._state === STATE_CLOSED) return;
|
|
1172
|
+
// Socket may have been destroyed by the peer between our last
|
|
1173
|
+
// 'close' event check and this write — Node's 'close' event is
|
|
1174
|
+
// async-after-destroy and there's a race window. Treat unwritable
|
|
1175
|
+
// socket as the abnormal-closure path so the operator's 'close'
|
|
1176
|
+
// handler fires consistently.
|
|
1177
|
+
if (this.socket.destroyed || this.socket.writable === false) {
|
|
1178
|
+
this._transitionToClosed(1006, "socket no longer writable", false, null);
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
try {
|
|
1182
|
+
this.socket.write(serializeFrame(opcode, payload, opts));
|
|
1183
|
+
} catch (err) {
|
|
1184
|
+
this._transitionToClosed(1006, (err && err.message) || "write failed", false, err);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
_sendDataFrame(opcode, payload) {
|
|
1189
|
+
// Compress entire-message-in-one-frame when permessage-deflate
|
|
1190
|
+
// negotiated. RSV1 set on the FIRST frame of the message to mark
|
|
1191
|
+
// it compressed; opcode-only continuation frames don't repeat
|
|
1192
|
+
// RSV1 (see _onFrame's RSV1+continuation guard).
|
|
1193
|
+
if (this._permessageDeflate && opcode !== OPCODE_PING &&
|
|
1194
|
+
opcode !== OPCODE_PONG && opcode !== OPCODE_CLOSE) {
|
|
1195
|
+
try {
|
|
1196
|
+
var compressed = _deflateMessage(payload, this._permessageDeflate.serverMaxWindowBits);
|
|
1197
|
+
this._sendFrame(opcode, compressed, { rsv1: true });
|
|
1198
|
+
return;
|
|
1199
|
+
} catch (_e) {
|
|
1200
|
+
// Compression failure on send — fall through to uncompressed
|
|
1201
|
+
// (we still have the original payload) so the connection
|
|
1202
|
+
// keeps working. The underlying issue surfaces as observability.
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
this._sendFrame(opcode, payload);
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
send(data) {
|
|
1209
|
+
if (this._state !== STATE_OPEN) {
|
|
1210
|
+
throw new WebSocketError("ws/closed",
|
|
1211
|
+
"connection is " + this._state + ", cannot send");
|
|
1212
|
+
}
|
|
1213
|
+
if (typeof data === "string") {
|
|
1214
|
+
this._sendDataFrame(OPCODE_TEXT, Buffer.from(data, "utf8"));
|
|
1215
|
+
} else if (Buffer.isBuffer(data)) {
|
|
1216
|
+
this._sendDataFrame(OPCODE_BINARY, data);
|
|
1217
|
+
} else {
|
|
1218
|
+
data = safeBuffer.toBuffer(data, {
|
|
1219
|
+
errorClass: WebSocketError,
|
|
1220
|
+
typeCode: "ws/invalid-payload",
|
|
1221
|
+
typeMessage: "send() requires Buffer, Uint8Array, or string",
|
|
1222
|
+
});
|
|
1223
|
+
this._sendDataFrame(OPCODE_BINARY, data);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
ping(payload) {
|
|
1228
|
+
if (this._state !== STATE_OPEN) return;
|
|
1229
|
+
this._sendFrame(OPCODE_PING, payload || Buffer.alloc(0));
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
close(code, reason) {
|
|
1233
|
+
if (this._state !== STATE_OPEN) return;
|
|
1234
|
+
code = code || CLOSE_NORMAL;
|
|
1235
|
+
this._sendCloseFrame(code, reason || "");
|
|
1236
|
+
this._closeSent = true;
|
|
1237
|
+
this._state = STATE_CLOSING;
|
|
1238
|
+
// Grace period — wait for peer's close echo before forcing socket end.
|
|
1239
|
+
var self = this;
|
|
1240
|
+
this._closeTimer = setTimeout(function () {
|
|
1241
|
+
try { self.socket.end(); } catch (_e) { /* socket already closed */ }
|
|
1242
|
+
// If the peer never echoed, transition with the locally-sent code.
|
|
1243
|
+
// wasClean: false because the peer didn't acknowledge.
|
|
1244
|
+
self._transitionToClosed(code, reason || "", false, null);
|
|
1245
|
+
}, this._closeGraceMs);
|
|
1246
|
+
this._closeTimer.unref();
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
_abort(code, reason) {
|
|
1250
|
+
if (this._state === STATE_CLOSED) return;
|
|
1251
|
+
if (!this._closeSent) {
|
|
1252
|
+
try { this._sendCloseFrame(code, reason); this._closeSent = true; } catch (_e) { /* close frame send-best-effort during abort */ }
|
|
1253
|
+
}
|
|
1254
|
+
try { this.socket.destroy(); } catch (_e) { /* socket already destroyed */ }
|
|
1255
|
+
// _abort is for protocol violations — wasClean: false.
|
|
1256
|
+
this._transitionToClosed(code, reason, false, null);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
_heartbeat(pongTimeoutMs) {
|
|
1260
|
+
if (this._state !== STATE_OPEN) return;
|
|
1261
|
+
if (Date.now() - this._lastPongAt > pongTimeoutMs) {
|
|
1262
|
+
this._abort(CLOSE_INTERNAL_ERROR, "ping timeout — peer unresponsive");
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
this.ping();
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
// ---- Server-side upgrade handler ----
|
|
1270
|
+
//
|
|
1271
|
+
// The framework's router wires the HTTP server's 'upgrade' event to
|
|
1272
|
+
// this function. Operators usually don't call it directly; they pass
|
|
1273
|
+
// a handler to router.ws(path, opts).
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* @primitive b.websocket.handleUpgrade
|
|
1277
|
+
* @signature b.websocket.handleUpgrade(req, socket, head, opts)
|
|
1278
|
+
* @since 0.1.38
|
|
1279
|
+
* @status stable
|
|
1280
|
+
* @related b.websocket.handleExtendedConnect, b.websocket.WebSocketConnection
|
|
1281
|
+
*
|
|
1282
|
+
* RFC 6455 HTTP/1.1 upgrade entry point. Wire it to the HTTP
|
|
1283
|
+
* server's `'upgrade'` event. Validates the handshake, enforces the
|
|
1284
|
+
* Origin policy (same-origin by default), negotiates subprotocol +
|
|
1285
|
+
* permessage-deflate, writes the 101 response, and returns a
|
|
1286
|
+
* `WebSocketConnection`. Returns `null` and writes a refusal HTTP
|
|
1287
|
+
* response on bad handshake / origin mismatch — the caller does not
|
|
1288
|
+
* need a try/catch around the normal refusal paths. Throws
|
|
1289
|
+
* synchronously only when `opts.handshakeGuid` is supplied with a
|
|
1290
|
+
* malformed value (config-time typo).
|
|
1291
|
+
*
|
|
1292
|
+
* @opts
|
|
1293
|
+
* origins: string[] | "*", // allowlist, or "*" accept-all; default same-origin
|
|
1294
|
+
* subprotocols: string[], // negotiation allowlist
|
|
1295
|
+
* handshakeGuid: string, // UUID-shape override of RFC 6455 §1.3 GUID
|
|
1296
|
+
* permessageDeflate: boolean, // RFC 7692 negotiation, default true
|
|
1297
|
+
* maxMessageBytes: number, // total message cap, default 1 MiB
|
|
1298
|
+
* pingIntervalMs: number, // heartbeat interval, default 30s
|
|
1299
|
+
* pongTimeoutMs: number, // abort-after-silence, default 35s
|
|
1300
|
+
* allowQueryAuthParams: boolean, // opt out of credential-query refusal
|
|
1301
|
+
*
|
|
1302
|
+
* @example
|
|
1303
|
+
* var http = require("http");
|
|
1304
|
+
* var server = http.createServer();
|
|
1305
|
+
* server.on("upgrade", function (req, socket, head) {
|
|
1306
|
+
* var conn = b.websocket.handleUpgrade(req, socket, head, {
|
|
1307
|
+
* origins: ["https://app.example.com"],
|
|
1308
|
+
* subprotocols: ["chat.v1"],
|
|
1309
|
+
* });
|
|
1310
|
+
* if (!conn) return; // refusal already written + socket destroyed
|
|
1311
|
+
* conn.on("message", function (data, isBinary) {
|
|
1312
|
+
* // → "hello", false
|
|
1313
|
+
* conn.send("ack: " + data);
|
|
1314
|
+
* });
|
|
1315
|
+
* });
|
|
1316
|
+
*/
|
|
1317
|
+
function handleUpgrade(req, socket, head, opts) {
|
|
1318
|
+
opts = opts || {};
|
|
1319
|
+
|
|
1320
|
+
// Throw-at-config-time on the optional GUID override. A typo here
|
|
1321
|
+
// would produce a Sec-WebSocket-Accept the client can't match,
|
|
1322
|
+
// breaking the upgrade in a way that's hard to diagnose; the format
|
|
1323
|
+
// check at the top of handleUpgrade catches it loudly. Empty /
|
|
1324
|
+
// undefined falls through to the RFC default in computeAcceptKey.
|
|
1325
|
+
var GUID_MAX_LENGTH = C.BYTES.bytes(64); // allow:raw-byte-literal — UUID is 36 chars; 64 is a tolerant upper bound for the regex engine.
|
|
1326
|
+
if (opts.handshakeGuid !== undefined && opts.handshakeGuid !== null) {
|
|
1327
|
+
// Length cap before the regex test — UUIDs are exactly 36 chars so
|
|
1328
|
+
// a > GUID_MAX_LENGTH input never matches the format and shouldn't
|
|
1329
|
+
// reach the regex engine. Bounds the engine on hostile input
|
|
1330
|
+
// regardless of the GUID_RE shape.
|
|
1331
|
+
if (typeof opts.handshakeGuid !== "string" ||
|
|
1332
|
+
opts.handshakeGuid.length > GUID_MAX_LENGTH ||
|
|
1333
|
+
!GUID_RE.test(opts.handshakeGuid)) {
|
|
1334
|
+
throw new Error("websocket.handleUpgrade: handshakeGuid must be a UUID-shaped string (8-4-4-4-12 hex with dashes), got " +
|
|
1335
|
+
JSON.stringify(opts.handshakeGuid));
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
// Validate handshake first — refusing here writes a plain HTTP/1.1
|
|
1340
|
+
// response and closes the socket, matching what the upgrade-event
|
|
1341
|
+
// consumer would expect for a malformed request.
|
|
1342
|
+
var v = validateUpgradeRequest(req, opts);
|
|
1343
|
+
if (!v.ok) {
|
|
1344
|
+
_refuseUpgrade(socket, v.status || 400, v.reason); // allow:raw-byte-literal — HTTP 400 fallback
|
|
1345
|
+
return null;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
// Origin policy.
|
|
1349
|
+
if (!isOriginAllowed(req, opts.origins)) {
|
|
1350
|
+
_refuseUpgrade(socket, 403, "origin not allowed");
|
|
1351
|
+
return null;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
// Subprotocol negotiation.
|
|
1355
|
+
var subprotocol = negotiateSubprotocol(req, opts.subprotocols);
|
|
1356
|
+
|
|
1357
|
+
// permessage-deflate negotiation. Skipped (no echo header, no
|
|
1358
|
+
// compression state on the connection) when the operator passes
|
|
1359
|
+
// opts.permessageDeflate = false OR when the client didn't offer it.
|
|
1360
|
+
var pmd = null;
|
|
1361
|
+
if (opts.permessageDeflate !== false) {
|
|
1362
|
+
var negotiated = _negotiatePermessageDeflate(req.headers["sec-websocket-extensions"]);
|
|
1363
|
+
if (negotiated.negotiated) pmd = negotiated;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
// Send 101.
|
|
1367
|
+
try {
|
|
1368
|
+
socket.write(buildUpgradeResponse(
|
|
1369
|
+
req.headers["sec-websocket-key"], subprotocol,
|
|
1370
|
+
pmd ? pmd.responseHeader : null, opts.handshakeGuid));
|
|
1371
|
+
} catch (err) {
|
|
1372
|
+
log.error("failed to write upgrade response: " + err.message);
|
|
1373
|
+
try { socket.destroy(); } catch (_e) { /* socket already destroyed */ }
|
|
1374
|
+
return null;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
// If the head buffer has any bytes (data that arrived between
|
|
1378
|
+
// headers and the upgrade handler), we pre-feed them into the
|
|
1379
|
+
// parser via a synthetic data event. Most clients don't send
|
|
1380
|
+
// anything before the 101 response, but the spec allows it.
|
|
1381
|
+
var conn = new WebSocketConnection(socket, {
|
|
1382
|
+
subprotocol: subprotocol,
|
|
1383
|
+
maxMessageBytes: opts.maxMessageBytes,
|
|
1384
|
+
pingIntervalMs: opts.pingIntervalMs,
|
|
1385
|
+
pongTimeoutMs: opts.pongTimeoutMs,
|
|
1386
|
+
permessageDeflate: pmd,
|
|
1387
|
+
});
|
|
1388
|
+
if (head && head.length > 0) {
|
|
1389
|
+
// Manually invoke the data path with the pre-read bytes.
|
|
1390
|
+
conn._onData(head);
|
|
1391
|
+
}
|
|
1392
|
+
return conn;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
// ---- h2 Extended CONNECT (RFC 8441) entry point ----
|
|
1396
|
+
//
|
|
1397
|
+
// Called by the router from an http2.Server's 'stream' event when the
|
|
1398
|
+
// :method header is "CONNECT" and :protocol is "websocket". Validates
|
|
1399
|
+
// origin + subprotocols (same policy as h1), responds with :status 200
|
|
1400
|
+
// (NOT 101 — Extended CONNECT is a CONNECT, not an Upgrade), and
|
|
1401
|
+
// returns a WebSocketConnection wrapping the h2 stream.
|
|
1402
|
+
//
|
|
1403
|
+
// The server side must advertise SETTINGS_ENABLE_CONNECT_PROTOCOL = 1
|
|
1404
|
+
// in its h2 settings frame BEFORE clients can use Extended CONNECT.
|
|
1405
|
+
// That's the operator's responsibility when constructing the h2 server
|
|
1406
|
+
// — pass `settings: { enableConnectProtocol: true }` to
|
|
1407
|
+
// http2.createServer / createSecureServer.
|
|
1408
|
+
|
|
1409
|
+
/**
|
|
1410
|
+
* @primitive b.websocket.handleExtendedConnect
|
|
1411
|
+
* @signature b.websocket.handleExtendedConnect(stream, requestHeaders, opts)
|
|
1412
|
+
* @since 0.1.39
|
|
1413
|
+
* @status stable
|
|
1414
|
+
* @related b.websocket.handleUpgrade, b.websocket.WebSocketConnection
|
|
1415
|
+
*
|
|
1416
|
+
* RFC 8441 Extended CONNECT entry point for HTTP/2. Wire it to the
|
|
1417
|
+
* h2 server's `'stream'` event when `:method` is `CONNECT` and
|
|
1418
|
+
* `:protocol` is `websocket`. Same Origin / subprotocol policy as
|
|
1419
|
+
* `handleUpgrade`. Responds with `:status 200` (NOT 101 — Extended
|
|
1420
|
+
* CONNECT is a CONNECT, not an Upgrade) and returns a
|
|
1421
|
+
* `WebSocketConnection` wrapping the h2 stream with mask-direction
|
|
1422
|
+
* flipped (h2 frames MUST NOT be masked). The h2 server must
|
|
1423
|
+
* advertise `SETTINGS_ENABLE_CONNECT_PROTOCOL = 1`; pass
|
|
1424
|
+
* `settings: { enableConnectProtocol: true }` to
|
|
1425
|
+
* `http2.createSecureServer`. Returns `null` on refusal.
|
|
1426
|
+
*
|
|
1427
|
+
* @opts
|
|
1428
|
+
* origins: string[] | "*", // allowlist / accept-all; default same-origin
|
|
1429
|
+
* subprotocols: string[], // negotiation allowlist
|
|
1430
|
+
* maxMessageBytes: number, // total message cap, default 1 MiB
|
|
1431
|
+
* pingIntervalMs: number, // heartbeat interval, default 30s
|
|
1432
|
+
* pongTimeoutMs: number, // abort-after-silence, default 35s
|
|
1433
|
+
*
|
|
1434
|
+
* @example
|
|
1435
|
+
* var http2 = require("http2");
|
|
1436
|
+
* var server = http2.createSecureServer({
|
|
1437
|
+
* key: fs.readFileSync("/etc/blamejs/tls.key"),
|
|
1438
|
+
* cert: fs.readFileSync("/etc/blamejs/tls.crt"),
|
|
1439
|
+
* settings: { enableConnectProtocol: true },
|
|
1440
|
+
* });
|
|
1441
|
+
* server.on("stream", function (stream, headers) {
|
|
1442
|
+
* if (headers[":method"] !== "CONNECT") return;
|
|
1443
|
+
* var conn = b.websocket.handleExtendedConnect(stream, headers, {
|
|
1444
|
+
* origins: ["https://app.example.com"],
|
|
1445
|
+
* subprotocols: ["chat.v1"],
|
|
1446
|
+
* });
|
|
1447
|
+
* if (!conn) return;
|
|
1448
|
+
* conn.close(1000, "shutdown"); // → 1000, "shutdown", true on the peer's 'close'
|
|
1449
|
+
* });
|
|
1450
|
+
*/
|
|
1451
|
+
function handleExtendedConnect(stream, requestHeaders, opts) {
|
|
1452
|
+
opts = opts || {};
|
|
1453
|
+
|
|
1454
|
+
// Verify it's actually a WebSocket Extended CONNECT (RFC 8441 §4).
|
|
1455
|
+
if (requestHeaders[":method"] !== "CONNECT") {
|
|
1456
|
+
_refuseH2Connect(stream, HTTP.BAD_REQUEST, "method must be CONNECT");
|
|
1457
|
+
return null;
|
|
1458
|
+
}
|
|
1459
|
+
if (requestHeaders[":protocol"] !== "websocket") {
|
|
1460
|
+
_refuseH2Connect(stream, HTTP.BAD_REQUEST, ":protocol must be websocket");
|
|
1461
|
+
return null;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
// Origin + subprotocol policy — same as h1. Build a fake req object
|
|
1465
|
+
// so the helpers (which expect a Node http req shape) work uniformly.
|
|
1466
|
+
var fakeReq = { headers: requestHeaders, method: "CONNECT" };
|
|
1467
|
+
if (!isOriginAllowed(fakeReq, opts.origins)) {
|
|
1468
|
+
_refuseH2Connect(stream, HTTP.FORBIDDEN, "origin not allowed");
|
|
1469
|
+
return null;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
var subprotocol = negotiateSubprotocol(fakeReq, opts.subprotocols);
|
|
1473
|
+
|
|
1474
|
+
// OK response — Extended CONNECT does NOT use 101. Sec-WebSocket-Key
|
|
1475
|
+
// / Sec-WebSocket-Accept are NOT used (h2 stream identity replaces
|
|
1476
|
+
// the handshake nonce dance from h1).
|
|
1477
|
+
var responseHeaders = { ":status": HTTP.OK };
|
|
1478
|
+
if (subprotocol) responseHeaders["sec-websocket-protocol"] = subprotocol;
|
|
1479
|
+
try {
|
|
1480
|
+
stream.respond(responseHeaders);
|
|
1481
|
+
} catch (err) {
|
|
1482
|
+
log.error("failed to write h2 Extended CONNECT response: " + err.message);
|
|
1483
|
+
try { stream.close(); } catch (_e) { /* stream already closing */ }
|
|
1484
|
+
return null;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
return new WebSocketConnection(stream, {
|
|
1488
|
+
transport: "h2",
|
|
1489
|
+
subprotocol: subprotocol,
|
|
1490
|
+
maxMessageBytes: opts.maxMessageBytes,
|
|
1491
|
+
pingIntervalMs: opts.pingIntervalMs,
|
|
1492
|
+
pongTimeoutMs: opts.pongTimeoutMs,
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
function _refuseH2Connect(stream, status, reason) {
|
|
1497
|
+
try {
|
|
1498
|
+
stream.respond({ ":status": status, "content-type": "text/plain; charset=utf-8" });
|
|
1499
|
+
stream.end(reason || ("HTTP " + status));
|
|
1500
|
+
} catch (_e) {
|
|
1501
|
+
try { stream.close(); } catch (_e2) { /* stream already closed */ }
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
// Status text table for upgrade-refusal responses. Keyed by the
|
|
1506
|
+
// framework's HTTP_STATUS hex IDs so the byte-literal lint doesn't
|
|
1507
|
+
// hit decimal multiples-of-8 in the keys.
|
|
1508
|
+
var _UPGRADE_REFUSAL_TEXT = {};
|
|
1509
|
+
_UPGRADE_REFUSAL_TEXT[HTTP.BAD_REQUEST] = "Bad Request";
|
|
1510
|
+
_UPGRADE_REFUSAL_TEXT[HTTP.FORBIDDEN] = "Forbidden";
|
|
1511
|
+
_UPGRADE_REFUSAL_TEXT[HTTP.METHOD_NOT_ALLOWED] = "Method Not Allowed";
|
|
1512
|
+
_UPGRADE_REFUSAL_TEXT[0x1AA] = "Upgrade Required";
|
|
1513
|
+
|
|
1514
|
+
function _refuseUpgrade(socket, status, reason) {
|
|
1515
|
+
var statusText = _UPGRADE_REFUSAL_TEXT[status] || "Bad Request";
|
|
1516
|
+
var body = reason || statusText;
|
|
1517
|
+
var resp =
|
|
1518
|
+
"HTTP/1.1 " + status + " " + statusText + "\r\n" +
|
|
1519
|
+
"Connection: close\r\n" +
|
|
1520
|
+
"Content-Type: text/plain; charset=utf-8\r\n" +
|
|
1521
|
+
"Content-Length: " + Buffer.byteLength(body, "utf8") + "\r\n" +
|
|
1522
|
+
"\r\n" +
|
|
1523
|
+
body;
|
|
1524
|
+
try { socket.write(resp); } catch (_e) { /* socket already closed */ }
|
|
1525
|
+
try { socket.destroy(); } catch (_e) { /* socket already closed */ }
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
module.exports = {
|
|
1529
|
+
// Handshake helpers
|
|
1530
|
+
computeAcceptKey: computeAcceptKey,
|
|
1531
|
+
validateUpgradeRequest: validateUpgradeRequest,
|
|
1532
|
+
negotiateSubprotocol: negotiateSubprotocol,
|
|
1533
|
+
isOriginAllowed: isOriginAllowed,
|
|
1534
|
+
buildUpgradeResponse: buildUpgradeResponse,
|
|
1535
|
+
// Frame layer
|
|
1536
|
+
FrameParser: FrameParser,
|
|
1537
|
+
serializeFrame: serializeFrame,
|
|
1538
|
+
// Connection
|
|
1539
|
+
WebSocketConnection: WebSocketConnection,
|
|
1540
|
+
WebSocketError: WebSocketError,
|
|
1541
|
+
// Server-side entrypoints
|
|
1542
|
+
handleUpgrade: handleUpgrade, // h1 — RFC 6455 HTTP upgrade
|
|
1543
|
+
handleExtendedConnect: handleExtendedConnect, // h2 — RFC 8441 Extended CONNECT
|
|
1544
|
+
// Constants
|
|
1545
|
+
GUID: GUID,
|
|
1546
|
+
REFUSED_AUTH_QUERY_PARAMS: REFUSED_AUTH_QUERY_PARAMS,
|
|
1547
|
+
OPCODE_CONTINUATION: OPCODE_CONTINUATION,
|
|
1548
|
+
OPCODE_TEXT: OPCODE_TEXT,
|
|
1549
|
+
OPCODE_BINARY: OPCODE_BINARY,
|
|
1550
|
+
OPCODE_CLOSE: OPCODE_CLOSE,
|
|
1551
|
+
OPCODE_PING: OPCODE_PING,
|
|
1552
|
+
OPCODE_PONG: OPCODE_PONG,
|
|
1553
|
+
CLOSE_NORMAL: CLOSE_NORMAL,
|
|
1554
|
+
CLOSE_GOING_AWAY: CLOSE_GOING_AWAY,
|
|
1555
|
+
CLOSE_PROTOCOL_ERROR: CLOSE_PROTOCOL_ERROR,
|
|
1556
|
+
CLOSE_UNSUPPORTED_DATA: CLOSE_UNSUPPORTED_DATA,
|
|
1557
|
+
CLOSE_INVALID_PAYLOAD: CLOSE_INVALID_PAYLOAD,
|
|
1558
|
+
CLOSE_POLICY_VIOLATION: CLOSE_POLICY_VIOLATION,
|
|
1559
|
+
CLOSE_MESSAGE_TOO_BIG: CLOSE_MESSAGE_TOO_BIG,
|
|
1560
|
+
CLOSE_INTERNAL_ERROR: CLOSE_INTERNAL_ERROR,
|
|
1561
|
+
};
|