better-auth 1.7.0-beta.2 → 1.7.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -15
- package/dist/_virtual/_rolldown/runtime.mjs +10 -1
- package/dist/api/index.d.mts +18 -48
- package/dist/api/routes/account.d.mts +4 -23
- package/dist/api/routes/account.mjs +102 -75
- package/dist/api/routes/callback.mjs +42 -20
- package/dist/api/routes/email-verification.d.mts +1 -0
- package/dist/api/routes/email-verification.mjs +6 -5
- package/dist/api/routes/error.mjs +1 -1
- package/dist/api/routes/password.mjs +1 -1
- package/dist/api/routes/session.mjs +15 -10
- package/dist/api/routes/sign-in.d.mts +3 -1
- package/dist/api/routes/sign-in.mjs +13 -15
- package/dist/api/routes/sign-up.d.mts +1 -0
- package/dist/api/routes/sign-up.mjs +10 -8
- package/dist/api/routes/update-user.mjs +8 -8
- package/dist/api/to-auth-endpoints.mjs +7 -1
- package/dist/auth/base.mjs +30 -27
- package/dist/client/config.mjs +8 -1
- package/dist/client/fetch-plugins.mjs +2 -1
- package/dist/client/index.d.mts +2 -2
- package/dist/client/lynx/index.d.mts +13 -0
- package/dist/client/lynx/index.mjs +2 -1
- package/dist/client/parser.mjs +0 -1
- package/dist/client/plugins/index.d.mts +4 -17
- package/dist/client/plugins/index.mjs +1 -4
- package/dist/client/proxy.mjs +2 -1
- package/dist/client/react/index.d.mts +13 -0
- package/dist/client/react/index.mjs +2 -1
- package/dist/client/session-atom.mjs +12 -1
- package/dist/client/solid/index.d.mts +13 -0
- package/dist/client/solid/index.mjs +3 -2
- package/dist/client/svelte/index.d.mts +13 -0
- package/dist/client/svelte/index.mjs +2 -1
- package/dist/client/vanilla.d.mts +13 -0
- package/dist/client/vanilla.mjs +2 -1
- package/dist/client/vue/index.d.mts +13 -0
- package/dist/client/vue/index.mjs +2 -1
- package/dist/context/create-context.mjs +10 -14
- package/dist/context/helpers.mjs +3 -2
- package/dist/cookies/cookie-utils.d.mts +33 -1
- package/dist/cookies/cookie-utils.mjs +95 -14
- package/dist/cookies/index.d.mts +2 -3
- package/dist/cookies/index.mjs +39 -11
- package/dist/cookies/session-store.mjs +4 -23
- package/dist/db/get-migration.mjs +4 -4
- package/dist/db/index.d.mts +2 -2
- package/dist/db/index.mjs +3 -2
- package/dist/db/internal-adapter.mjs +129 -27
- package/dist/db/schema.d.mts +14 -1
- package/dist/db/schema.mjs +26 -1
- package/dist/db/with-hooks.d.mts +1 -0
- package/dist/db/with-hooks.mjs +58 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/integrations/cookie-plugin-guard.mjs +18 -0
- package/dist/integrations/next-js.mjs +6 -0
- package/dist/integrations/svelte-kit.mjs +6 -0
- package/dist/integrations/tanstack-start-solid.mjs +6 -0
- package/dist/integrations/tanstack-start.mjs +6 -0
- package/dist/node_modules/.pnpm/clipboardy@4.0.0/node_modules/clipboardy/index.mjs +32 -0
- package/dist/node_modules/.pnpm/clipboardy@4.0.0/node_modules/clipboardy/lib/linux.mjs +55 -0
- package/dist/node_modules/.pnpm/clipboardy@4.0.0/node_modules/clipboardy/lib/macos.mjs +26 -0
- package/dist/node_modules/.pnpm/clipboardy@4.0.0/node_modules/clipboardy/lib/termux.mjs +39 -0
- package/dist/node_modules/.pnpm/clipboardy@4.0.0/node_modules/clipboardy/lib/windows.mjs +19 -0
- package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/chunks/prompt.mjs +845 -0
- package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs +386 -0
- package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs +320 -0
- package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +62 -0
- package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +190 -0
- package/dist/node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/utils.mjs +2 -0
- package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.mjs +29 -0
- package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.mjs +42 -0
- package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.mjs +67 -0
- package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.mjs +23 -0
- package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.mjs +22 -0
- package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.mjs +36 -0
- package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/adapters/node.d.mts +292 -0
- package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/adapters/node.mjs +127 -0
- package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/index.d.mts +145 -0
- package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/shared/crossws.BQXMA5bH.d.mts +298 -0
- package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/shared/crossws.By9qWDAI.mjs +9 -0
- package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/shared/crossws.CipVM6lf.mjs +3549 -0
- package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/shared/crossws.D9ehKjSh.mjs +66 -0
- package/dist/node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/shared/crossws.DfCzGthR.mjs +227 -0
- package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.mjs +224 -0
- package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/command.mjs +52 -0
- package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/error.mjs +54 -0
- package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/kill.mjs +62 -0
- package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/pipe.mjs +26 -0
- package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/promise.mjs +32 -0
- package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/stdio.mjs +19 -0
- package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/stream.mjs +98 -0
- package/dist/node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/verbose.mjs +15 -0
- package/dist/node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.d.mts +15 -0
- package/dist/node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs +220 -0
- package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/array-buffer.mjs +54 -0
- package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/array.mjs +2 -0
- package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/buffer.mjs +14 -0
- package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/contents.mjs +76 -0
- package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/index.mjs +6 -0
- package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/string.mjs +35 -0
- package/dist/node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/utils.mjs +10 -0
- package/dist/node_modules/.pnpm/http-shutdown@1.2.2/node_modules/http-shutdown/index.mjs +76 -0
- package/dist/node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/core.mjs +274 -0
- package/dist/node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/main.mjs +44 -0
- package/dist/node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/realtime.mjs +15 -0
- package/dist/node_modules/.pnpm/human-signals@5.0.0/node_modules/human-signals/build/src/signals.mjs +23 -0
- package/dist/node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.mjs +24 -0
- package/dist/node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.mjs +18 -0
- package/dist/node_modules/.pnpm/is-stream@3.0.0/node_modules/is-stream/index.mjs +9 -0
- package/dist/node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.mjs +20 -0
- package/dist/node_modules/.pnpm/is64bit@2.0.0/node_modules/is64bit/index.mjs +13 -0
- package/dist/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.mjs +47 -0
- package/dist/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.mjs +33 -0
- package/dist/node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.mjs +33 -0
- package/dist/node_modules/.pnpm/listhen@1.9.0/node_modules/listhen/dist/chunks/xdg-open.mjs +1070 -0
- package/dist/node_modules/.pnpm/listhen@1.9.0/node_modules/listhen/dist/index.mjs +619 -0
- package/dist/node_modules/.pnpm/listhen@1.9.0/node_modules/listhen/dist/shared/listhen.1c46e31d.d.mts +83 -0
- package/dist/node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.mjs +38 -0
- package/dist/node_modules/.pnpm/mimic-fn@4.0.0/node_modules/mimic-fn/index.mjs +38 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/aes.mjs +597 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/aesCipherSuites.mjs +195 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/asn1-validator.mjs +76 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/asn1.mjs +967 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/baseN.mjs +137 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/cipher.mjs +186 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/cipherModes.mjs +597 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/des.mjs +1187 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/ed25519.mjs +1029 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/forge.mjs +15 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/hmac.mjs +107 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/index.mjs +66 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/jsbn.mjs +1334 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/kem.mjs +146 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/log.mjs +241 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/md.all.mjs +24 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/md.mjs +18 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/md5.mjs +324 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/mgf.mjs +20 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/mgf1.mjs +44 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/oids.mjs +154 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pbe.mjs +815 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pbkdf2.mjs +125 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pem.mjs +175 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pkcs1.mjs +200 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pkcs12.mjs +724 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pkcs7.mjs +642 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pkcs7asn1.mjs +405 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pki.mjs +101 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/prime.mjs +193 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/prng.mjs +290 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/pss.mjs +141 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/random.mjs +141 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/rc2.mjs +538 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/rsa.mjs +1309 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/sha1.mjs +230 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/sha256.mjs +267 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/sha512.mjs +413 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/ssh.mjs +194 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/tls.mjs +3655 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/util.mjs +2117 -0
- package/dist/node_modules/.pnpm/node-forge@1.4.0/node_modules/node-forge/lib/x509.mjs +2168 -0
- package/dist/node_modules/.pnpm/npm-run-path@5.3.0/node_modules/npm-run-path/index.mjs +34 -0
- package/dist/node_modules/.pnpm/onetime@6.0.0/node_modules/onetime/index.mjs +26 -0
- package/dist/node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.mjs +14 -0
- package/dist/node_modules/.pnpm/path-key@4.0.0/node_modules/path-key/index.mjs +8 -0
- package/dist/node_modules/.pnpm/pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.mjs +176 -0
- package/dist/node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.mjs +17 -0
- package/dist/node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.mjs +8 -0
- package/dist/node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.mjs +169 -0
- package/dist/node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.mjs +33 -0
- package/dist/node_modules/.pnpm/std-env@3.10.0/node_modules/std-env/dist/index.mjs +171 -0
- package/dist/node_modules/.pnpm/strip-final-newline@3.0.0/node_modules/strip-final-newline/index.mjs +10 -0
- package/dist/node_modules/.pnpm/system-architecture@0.1.0/node_modules/system-architecture/index.mjs +16 -0
- package/dist/node_modules/.pnpm/uncrypto@0.1.3/node_modules/uncrypto/dist/crypto.node.mjs +7 -0
- package/dist/node_modules/.pnpm/untun@0.1.3/node_modules/untun/dist/chunks/index.mjs +154 -0
- package/dist/node_modules/.pnpm/untun@0.1.3/node_modules/untun/dist/index.mjs +34 -0
- package/dist/node_modules/.pnpm/uqr@0.1.2/node_modules/uqr/dist/index.mjs +896 -0
- package/dist/node_modules/.pnpm/which@2.0.2/node_modules/which/which.mjs +76 -0
- package/dist/oauth2/errors.mjs +27 -0
- package/dist/oauth2/index.d.mts +2 -2
- package/dist/oauth2/index.mjs +3 -3
- package/dist/oauth2/link-account.d.mts +27 -1
- package/dist/oauth2/link-account.mjs +30 -5
- package/dist/oauth2/state.mjs +8 -2
- package/dist/{package.mjs → packages/better-auth/package.mjs} +1 -1
- package/dist/plugins/access/access.d.mts +3 -15
- package/dist/plugins/access/access.mjs +11 -6
- package/dist/plugins/access/index.d.mts +2 -2
- package/dist/plugins/access/types.d.mts +11 -4
- package/dist/plugins/admin/access/statement.d.mts +29 -93
- package/dist/plugins/admin/admin.mjs +0 -4
- package/dist/plugins/admin/client.d.mts +6 -1
- package/dist/plugins/admin/client.mjs +5 -0
- package/dist/plugins/admin/routes.mjs +3 -2
- package/dist/plugins/anonymous/client.d.mts +1 -0
- package/dist/plugins/anonymous/error-codes.d.mts +1 -0
- package/dist/plugins/anonymous/error-codes.mjs +1 -0
- package/dist/plugins/anonymous/index.d.mts +1 -0
- package/dist/plugins/anonymous/index.mjs +16 -2
- package/dist/plugins/bearer/index.mjs +5 -12
- package/dist/plugins/captcha/index.mjs +14 -1
- package/dist/plugins/device-authorization/error-codes.mjs +1 -0
- package/dist/plugins/device-authorization/index.d.mts +1 -0
- package/dist/plugins/device-authorization/routes.mjs +34 -3
- package/dist/plugins/email-otp/routes.mjs +4 -4
- package/dist/plugins/generic-oauth/error-codes.mjs +0 -1
- package/dist/plugins/generic-oauth/index.d.mts +2 -4
- package/dist/plugins/generic-oauth/index.mjs +23 -17
- package/dist/plugins/generic-oauth/providers/auth0.mjs +1 -0
- package/dist/plugins/generic-oauth/providers/gumroad.mjs +1 -0
- package/dist/plugins/generic-oauth/providers/hubspot.mjs +1 -0
- package/dist/plugins/generic-oauth/providers/keycloak.mjs +1 -0
- package/dist/plugins/generic-oauth/providers/line.mjs +1 -0
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.mjs +1 -0
- package/dist/plugins/generic-oauth/providers/okta.mjs +1 -0
- package/dist/plugins/generic-oauth/providers/patreon.mjs +1 -0
- package/dist/plugins/generic-oauth/providers/slack.mjs +1 -0
- package/dist/plugins/generic-oauth/types.d.mts +30 -8
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/jwt/utils.d.mts +1 -1
- package/dist/plugins/last-login-method/client.mjs +2 -2
- package/dist/plugins/magic-link/index.d.mts +8 -1
- package/dist/plugins/magic-link/index.mjs +4 -17
- package/dist/plugins/mcp/authorize.mjs +8 -2
- package/dist/plugins/mcp/index.mjs +75 -35
- package/dist/plugins/multi-session/index.mjs +2 -2
- package/dist/plugins/oauth-proxy/index.mjs +45 -32
- package/dist/plugins/oauth-proxy/utils.mjs +3 -10
- package/dist/plugins/oidc-provider/authorize.mjs +8 -2
- package/dist/plugins/oidc-provider/index.mjs +65 -38
- package/dist/plugins/one-tap/client.mjs +9 -2
- package/dist/plugins/one-tap/index.mjs +19 -36
- package/dist/plugins/open-api/generator.mjs +25 -5
- package/dist/plugins/organization/access/statement.d.mts +68 -201
- package/dist/plugins/organization/adapter.d.mts +1 -1
- package/dist/plugins/organization/adapter.mjs +65 -58
- package/dist/plugins/organization/client.d.mts +3 -1
- package/dist/plugins/organization/client.mjs +1 -1
- package/dist/plugins/organization/error-codes.d.mts +2 -0
- package/dist/plugins/organization/error-codes.mjs +3 -1
- package/dist/plugins/organization/routes/crud-access-control.d.mts +2 -2
- package/dist/plugins/organization/routes/crud-invites.d.mts +8 -1
- package/dist/plugins/organization/routes/crud-invites.mjs +8 -3
- package/dist/plugins/organization/routes/crud-org.d.mts +4 -4
- package/dist/plugins/organization/routes/crud-org.mjs +2 -2
- package/dist/plugins/organization/routes/crud-team.mjs +7 -2
- package/dist/plugins/organization/schema.d.mts +1 -1
- package/dist/plugins/organization/types.d.mts +15 -5
- package/dist/plugins/phone-number/routes.mjs +1 -1
- package/dist/plugins/siwe/client.d.mts +4 -0
- package/dist/plugins/siwe/client.mjs +5 -1
- package/dist/plugins/siwe/index.d.mts +13 -2
- package/dist/plugins/siwe/index.mjs +179 -165
- package/dist/plugins/two-factor/backup-codes/index.d.mts +4 -3
- package/dist/plugins/two-factor/client.mjs +2 -1
- package/dist/plugins/two-factor/index.mjs +3 -2
- package/dist/plugins/username/client.d.mts +1 -0
- package/dist/plugins/username/error-codes.d.mts +1 -0
- package/dist/plugins/username/error-codes.mjs +2 -1
- package/dist/plugins/username/index.d.mts +43 -2
- package/dist/plugins/username/index.mjs +73 -6
- package/dist/state.d.mts +2 -2
- package/dist/state.mjs +18 -4
- package/dist/test-utils/headers.mjs +2 -7
- package/dist/test-utils/http-test-instance.d.mts +397 -0
- package/dist/test-utils/http-test-instance.mjs +54 -0
- package/dist/test-utils/index.d.mts +2 -1
- package/dist/test-utils/index.mjs +2 -1
- package/dist/test-utils/test-instance.d.mts +4110 -224
- package/dist/test-utils/test-instance.mjs +11 -2
- package/dist/types/auth.d.mts +4 -0
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/url.d.mts +2 -1
- package/dist/utils/url.mjs +9 -3
- package/dist/version.mjs +1 -1
- package/package.json +14 -14
- package/dist/oauth2/error-codes.d.mts +0 -20
- package/dist/plugins/generic-oauth/client.d.mts +0 -32
- package/dist/plugins/generic-oauth/client.mjs +0 -19
- package/dist/plugins/generic-oauth/error-codes.d.mts +0 -10
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
|
|
3
|
+
var require_enoent = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
|
+
const isWin = process.platform === "win32";
|
|
5
|
+
function notFoundError(original, syscall) {
|
|
6
|
+
return Object.assign(/* @__PURE__ */ new Error(`${syscall} ${original.command} ENOENT`), {
|
|
7
|
+
code: "ENOENT",
|
|
8
|
+
errno: "ENOENT",
|
|
9
|
+
syscall: `${syscall} ${original.command}`,
|
|
10
|
+
path: original.command,
|
|
11
|
+
spawnargs: original.args
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function hookChildProcess(cp, parsed) {
|
|
15
|
+
if (!isWin) return;
|
|
16
|
+
const originalEmit = cp.emit;
|
|
17
|
+
cp.emit = function(name, arg1) {
|
|
18
|
+
if (name === "exit") {
|
|
19
|
+
const err = verifyENOENT(arg1, parsed);
|
|
20
|
+
if (err) return originalEmit.call(cp, "error", err);
|
|
21
|
+
}
|
|
22
|
+
return originalEmit.apply(cp, arguments);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function verifyENOENT(status, parsed) {
|
|
26
|
+
if (isWin && status === 1 && !parsed.file) return notFoundError(parsed.original, "spawn");
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function verifyENOENTSync(status, parsed) {
|
|
30
|
+
if (isWin && status === 1 && !parsed.file) return notFoundError(parsed.original, "spawnSync");
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
module.exports = {
|
|
34
|
+
hookChildProcess,
|
|
35
|
+
verifyENOENT,
|
|
36
|
+
verifyENOENTSync,
|
|
37
|
+
notFoundError
|
|
38
|
+
};
|
|
39
|
+
}));
|
|
40
|
+
//#endregion
|
|
41
|
+
export default require_enoent();
|
|
42
|
+
export { require_enoent };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { __commonJSMin, __require } from "../../../../../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { require_resolveCommand } from "./util/resolveCommand.mjs";
|
|
3
|
+
import { require_escape } from "./util/escape.mjs";
|
|
4
|
+
import { require_readShebang } from "./util/readShebang.mjs";
|
|
5
|
+
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
|
|
6
|
+
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
7
|
+
const path = __require("path");
|
|
8
|
+
const resolveCommand = require_resolveCommand();
|
|
9
|
+
const escape = require_escape();
|
|
10
|
+
const readShebang = require_readShebang();
|
|
11
|
+
const isWin = process.platform === "win32";
|
|
12
|
+
const isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
13
|
+
const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
14
|
+
function detectShebang(parsed) {
|
|
15
|
+
parsed.file = resolveCommand(parsed);
|
|
16
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
17
|
+
if (shebang) {
|
|
18
|
+
parsed.args.unshift(parsed.file);
|
|
19
|
+
parsed.command = shebang;
|
|
20
|
+
return resolveCommand(parsed);
|
|
21
|
+
}
|
|
22
|
+
return parsed.file;
|
|
23
|
+
}
|
|
24
|
+
function parseNonShell(parsed) {
|
|
25
|
+
if (!isWin) return parsed;
|
|
26
|
+
const commandFile = detectShebang(parsed);
|
|
27
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
28
|
+
if (parsed.options.forceShell || needsShell) {
|
|
29
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
30
|
+
parsed.command = path.normalize(parsed.command);
|
|
31
|
+
parsed.command = escape.command(parsed.command);
|
|
32
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
33
|
+
parsed.args = [
|
|
34
|
+
"/d",
|
|
35
|
+
"/s",
|
|
36
|
+
"/c",
|
|
37
|
+
`"${[parsed.command].concat(parsed.args).join(" ")}"`
|
|
38
|
+
];
|
|
39
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
40
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
41
|
+
}
|
|
42
|
+
return parsed;
|
|
43
|
+
}
|
|
44
|
+
function parse(command, args, options) {
|
|
45
|
+
if (args && !Array.isArray(args)) {
|
|
46
|
+
options = args;
|
|
47
|
+
args = null;
|
|
48
|
+
}
|
|
49
|
+
args = args ? args.slice(0) : [];
|
|
50
|
+
options = Object.assign({}, options);
|
|
51
|
+
const parsed = {
|
|
52
|
+
command,
|
|
53
|
+
args,
|
|
54
|
+
options,
|
|
55
|
+
file: void 0,
|
|
56
|
+
original: {
|
|
57
|
+
command,
|
|
58
|
+
args
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
62
|
+
}
|
|
63
|
+
module.exports = parse;
|
|
64
|
+
}));
|
|
65
|
+
//#endregion
|
|
66
|
+
export default require_parse();
|
|
67
|
+
export { require_parse };
|
package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
|
|
3
|
+
var require_escape = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
|
+
const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
5
|
+
function escapeCommand(arg) {
|
|
6
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
7
|
+
return arg;
|
|
8
|
+
}
|
|
9
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
10
|
+
arg = `${arg}`;
|
|
11
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
|
|
12
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
13
|
+
arg = `"${arg}"`;
|
|
14
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
15
|
+
if (doubleEscapeMetaChars) arg = arg.replace(metaCharsRegExp, "^$1");
|
|
16
|
+
return arg;
|
|
17
|
+
}
|
|
18
|
+
module.exports.command = escapeCommand;
|
|
19
|
+
module.exports.argument = escapeArgument;
|
|
20
|
+
}));
|
|
21
|
+
//#endregion
|
|
22
|
+
export default require_escape();
|
|
23
|
+
export { require_escape };
|
package/dist/node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { __commonJSMin, __require } from "../../../../../../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { require_shebang_command } from "../../../../../shebang-command@2.0.0/node_modules/shebang-command/index.mjs";
|
|
3
|
+
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
|
|
4
|
+
var require_readShebang = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
|
+
const fs = __require("fs");
|
|
6
|
+
const shebangCommand = require_shebang_command();
|
|
7
|
+
function readShebang(command) {
|
|
8
|
+
const size = 150;
|
|
9
|
+
const buffer = Buffer.alloc(size);
|
|
10
|
+
let fd;
|
|
11
|
+
try {
|
|
12
|
+
fd = fs.openSync(command, "r");
|
|
13
|
+
fs.readSync(fd, buffer, 0, size, 0);
|
|
14
|
+
fs.closeSync(fd);
|
|
15
|
+
} catch (e) {}
|
|
16
|
+
return shebangCommand(buffer.toString());
|
|
17
|
+
}
|
|
18
|
+
module.exports = readShebang;
|
|
19
|
+
}));
|
|
20
|
+
//#endregion
|
|
21
|
+
export default require_readShebang();
|
|
22
|
+
export { require_readShebang };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { __commonJSMin, __require } from "../../../../../../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { require_which } from "../../../../../which@2.0.2/node_modules/which/which.mjs";
|
|
3
|
+
import { require_path_key } from "../../../../../path-key@3.1.1/node_modules/path-key/index.mjs";
|
|
4
|
+
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
5
|
+
var require_resolveCommand = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6
|
+
const path = __require("path");
|
|
7
|
+
const which = require_which();
|
|
8
|
+
const getPathKey = require_path_key();
|
|
9
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
10
|
+
const env = parsed.options.env || process.env;
|
|
11
|
+
const cwd = process.cwd();
|
|
12
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
13
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
|
|
14
|
+
if (shouldSwitchCwd) try {
|
|
15
|
+
process.chdir(parsed.options.cwd);
|
|
16
|
+
} catch (err) {}
|
|
17
|
+
let resolved;
|
|
18
|
+
try {
|
|
19
|
+
resolved = which.sync(parsed.command, {
|
|
20
|
+
path: env[getPathKey({ env })],
|
|
21
|
+
pathExt: withoutPathExt ? path.delimiter : void 0
|
|
22
|
+
});
|
|
23
|
+
} catch (e) {} finally {
|
|
24
|
+
if (shouldSwitchCwd) process.chdir(cwd);
|
|
25
|
+
}
|
|
26
|
+
if (resolved) resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
27
|
+
return resolved;
|
|
28
|
+
}
|
|
29
|
+
function resolveCommand(parsed) {
|
|
30
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
31
|
+
}
|
|
32
|
+
module.exports = resolveCommand;
|
|
33
|
+
}));
|
|
34
|
+
//#endregion
|
|
35
|
+
export default require_resolveCommand();
|
|
36
|
+
export { require_resolveCommand };
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { AdapterOptions } from "../index.mjs";
|
|
2
|
+
import { Agent, ClientRequest, ClientRequestArgs, IncomingMessage, OutgoingHttpHeaders, Server } from "node:http";
|
|
3
|
+
import { Server as Server$1 } from "node:https";
|
|
4
|
+
import { URL } from "node:url";
|
|
5
|
+
import { EventEmitter } from "events";
|
|
6
|
+
import { Duplex, DuplexOptions } from "node:stream";
|
|
7
|
+
import { SecureContextOptions } from "node:tls";
|
|
8
|
+
import { ZlibOptions } from "node:zlib";
|
|
9
|
+
|
|
10
|
+
//#region ../../node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/adapters/node.d.mts
|
|
11
|
+
type BufferLike = string | Buffer | DataView | number | ArrayBufferView | Uint8Array | ArrayBuffer | SharedArrayBuffer | readonly any[] | readonly number[] | {
|
|
12
|
+
valueOf(): ArrayBuffer;
|
|
13
|
+
} | {
|
|
14
|
+
valueOf(): SharedArrayBuffer;
|
|
15
|
+
} | {
|
|
16
|
+
valueOf(): Uint8Array;
|
|
17
|
+
} | {
|
|
18
|
+
valueOf(): readonly number[];
|
|
19
|
+
} | {
|
|
20
|
+
valueOf(): string;
|
|
21
|
+
} | {
|
|
22
|
+
[Symbol.toPrimitive](hint: string): string;
|
|
23
|
+
};
|
|
24
|
+
declare class WebSocket extends EventEmitter {
|
|
25
|
+
static readonly createWebSocketStream: typeof createWebSocketStream;
|
|
26
|
+
static readonly WebSocketServer: WebSocketServer;
|
|
27
|
+
static readonly Server: typeof Server$2;
|
|
28
|
+
static readonly WebSocket: typeof WebSocket;
|
|
29
|
+
/** The connection is not yet open. */
|
|
30
|
+
static readonly CONNECTING: 0;
|
|
31
|
+
/** The connection is open and ready to communicate. */
|
|
32
|
+
static readonly OPEN: 1;
|
|
33
|
+
/** The connection is in the process of closing. */
|
|
34
|
+
static readonly CLOSING: 2;
|
|
35
|
+
/** The connection is closed. */
|
|
36
|
+
static readonly CLOSED: 3;
|
|
37
|
+
binaryType: "nodebuffer" | "arraybuffer" | "fragments";
|
|
38
|
+
readonly bufferedAmount: number;
|
|
39
|
+
readonly extensions: string;
|
|
40
|
+
/** Indicates whether the websocket is paused */
|
|
41
|
+
readonly isPaused: boolean;
|
|
42
|
+
readonly protocol: string;
|
|
43
|
+
/** The current state of the connection */
|
|
44
|
+
readonly readyState: typeof WebSocket.CONNECTING | typeof WebSocket.OPEN | typeof WebSocket.CLOSING | typeof WebSocket.CLOSED;
|
|
45
|
+
readonly url: string;
|
|
46
|
+
/** The connection is not yet open. */
|
|
47
|
+
readonly CONNECTING: 0;
|
|
48
|
+
/** The connection is open and ready to communicate. */
|
|
49
|
+
readonly OPEN: 1;
|
|
50
|
+
/** The connection is in the process of closing. */
|
|
51
|
+
readonly CLOSING: 2;
|
|
52
|
+
/** The connection is closed. */
|
|
53
|
+
readonly CLOSED: 3;
|
|
54
|
+
onopen: ((event: Event) => void) | null;
|
|
55
|
+
onerror: ((event: ErrorEvent) => void) | null;
|
|
56
|
+
onclose: ((event: CloseEvent) => void) | null;
|
|
57
|
+
onmessage: ((event: MessageEvent) => void) | null;
|
|
58
|
+
constructor(address: null);
|
|
59
|
+
constructor(address: string | URL, options?: ClientOptions | ClientRequestArgs);
|
|
60
|
+
constructor(address: string | URL, protocols?: string | string[], options?: ClientOptions | ClientRequestArgs);
|
|
61
|
+
close(code?: number, data?: string | Buffer): void;
|
|
62
|
+
ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
|
|
63
|
+
pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
|
|
64
|
+
send(data: BufferLike, cb?: (err?: Error) => void): void;
|
|
65
|
+
send(data: BufferLike, options: {
|
|
66
|
+
mask?: boolean | undefined;
|
|
67
|
+
binary?: boolean | undefined;
|
|
68
|
+
compress?: boolean | undefined;
|
|
69
|
+
fin?: boolean | undefined;
|
|
70
|
+
}, cb?: (err?: Error) => void): void;
|
|
71
|
+
terminate(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Pause the websocket causing it to stop emitting events. Some events can still be
|
|
74
|
+
* emitted after this is called, until all buffered data is consumed. This method
|
|
75
|
+
* is a noop if the ready state is `CONNECTING` or `CLOSED`.
|
|
76
|
+
*/
|
|
77
|
+
pause(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Make a paused socket resume emitting events. This method is a noop if the ready
|
|
80
|
+
* state is `CONNECTING` or `CLOSED`.
|
|
81
|
+
*/
|
|
82
|
+
resume(): void;
|
|
83
|
+
addEventListener(method: "message", cb: (event: MessageEvent) => void, options?: EventListenerOptions): void;
|
|
84
|
+
addEventListener(method: "close", cb: (event: CloseEvent) => void, options?: EventListenerOptions): void;
|
|
85
|
+
addEventListener(method: "error", cb: (event: ErrorEvent) => void, options?: EventListenerOptions): void;
|
|
86
|
+
addEventListener(method: "open", cb: (event: Event) => void, options?: EventListenerOptions): void;
|
|
87
|
+
removeEventListener(method: "message", cb: (event: MessageEvent) => void): void;
|
|
88
|
+
removeEventListener(method: "close", cb: (event: CloseEvent) => void): void;
|
|
89
|
+
removeEventListener(method: "error", cb: (event: ErrorEvent) => void): void;
|
|
90
|
+
removeEventListener(method: "open", cb: (event: Event) => void): void;
|
|
91
|
+
on(event: "close", listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
|
|
92
|
+
on(event: "error", listener: (this: WebSocket, err: Error) => void): this;
|
|
93
|
+
on(event: "upgrade", listener: (this: WebSocket, request: IncomingMessage) => void): this;
|
|
94
|
+
on(event: "message", listener: (this: WebSocket, data: RawData, isBinary: boolean) => void): this;
|
|
95
|
+
on(event: "open", listener: (this: WebSocket) => void): this;
|
|
96
|
+
on(event: "ping" | "pong", listener: (this: WebSocket, data: Buffer) => void): this;
|
|
97
|
+
on(event: "unexpected-response", listener: (this: WebSocket, request: ClientRequest, response: IncomingMessage) => void): this;
|
|
98
|
+
on(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
|
|
99
|
+
once(event: "close", listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
|
|
100
|
+
once(event: "error", listener: (this: WebSocket, err: Error) => void): this;
|
|
101
|
+
once(event: "upgrade", listener: (this: WebSocket, request: IncomingMessage) => void): this;
|
|
102
|
+
once(event: "message", listener: (this: WebSocket, data: RawData, isBinary: boolean) => void): this;
|
|
103
|
+
once(event: "open", listener: (this: WebSocket) => void): this;
|
|
104
|
+
once(event: "ping" | "pong", listener: (this: WebSocket, data: Buffer) => void): this;
|
|
105
|
+
once(event: "unexpected-response", listener: (this: WebSocket, request: ClientRequest, response: IncomingMessage) => void): this;
|
|
106
|
+
once(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
|
|
107
|
+
off(event: "close", listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
|
|
108
|
+
off(event: "error", listener: (this: WebSocket, err: Error) => void): this;
|
|
109
|
+
off(event: "upgrade", listener: (this: WebSocket, request: IncomingMessage) => void): this;
|
|
110
|
+
off(event: "message", listener: (this: WebSocket, data: RawData, isBinary: boolean) => void): this;
|
|
111
|
+
off(event: "open", listener: (this: WebSocket) => void): this;
|
|
112
|
+
off(event: "ping" | "pong", listener: (this: WebSocket, data: Buffer) => void): this;
|
|
113
|
+
off(event: "unexpected-response", listener: (this: WebSocket, request: ClientRequest, response: IncomingMessage) => void): this;
|
|
114
|
+
off(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
|
|
115
|
+
addListener(event: "close", listener: (code: number, reason: Buffer) => void): this;
|
|
116
|
+
addListener(event: "error", listener: (err: Error) => void): this;
|
|
117
|
+
addListener(event: "upgrade", listener: (request: IncomingMessage) => void): this;
|
|
118
|
+
addListener(event: "message", listener: (data: RawData, isBinary: boolean) => void): this;
|
|
119
|
+
addListener(event: "open", listener: () => void): this;
|
|
120
|
+
addListener(event: "ping" | "pong", listener: (data: Buffer) => void): this;
|
|
121
|
+
addListener(event: "unexpected-response", listener: (request: ClientRequest, response: IncomingMessage) => void): this;
|
|
122
|
+
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
123
|
+
removeListener(event: "close", listener: (code: number, reason: Buffer) => void): this;
|
|
124
|
+
removeListener(event: "error", listener: (err: Error) => void): this;
|
|
125
|
+
removeListener(event: "upgrade", listener: (request: IncomingMessage) => void): this;
|
|
126
|
+
removeListener(event: "message", listener: (data: RawData, isBinary: boolean) => void): this;
|
|
127
|
+
removeListener(event: "open", listener: () => void): this;
|
|
128
|
+
removeListener(event: "ping" | "pong", listener: (data: Buffer) => void): this;
|
|
129
|
+
removeListener(event: "unexpected-response", listener: (request: ClientRequest, response: IncomingMessage) => void): this;
|
|
130
|
+
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Data represents the raw message payload received over the
|
|
134
|
+
*/
|
|
135
|
+
type RawData = Buffer | ArrayBuffer | Buffer[];
|
|
136
|
+
/**
|
|
137
|
+
* Data represents the message payload received over the
|
|
138
|
+
*/
|
|
139
|
+
type Data = string | Buffer | ArrayBuffer | Buffer[];
|
|
140
|
+
/**
|
|
141
|
+
* CertMeta represents the accepted types for certificate & key data.
|
|
142
|
+
*/
|
|
143
|
+
type CertMeta = string | string[] | Buffer | Buffer[];
|
|
144
|
+
/**
|
|
145
|
+
* VerifyClientCallbackSync is a synchronous callback used to inspect the
|
|
146
|
+
* incoming message. The return value (boolean) of the function determines
|
|
147
|
+
* whether or not to accept the handshake.
|
|
148
|
+
*/
|
|
149
|
+
type VerifyClientCallbackSync<Request extends IncomingMessage = IncomingMessage> = (info: {
|
|
150
|
+
origin: string;
|
|
151
|
+
secure: boolean;
|
|
152
|
+
req: Request;
|
|
153
|
+
}) => boolean;
|
|
154
|
+
/**
|
|
155
|
+
* VerifyClientCallbackAsync is an asynchronous callback used to inspect the
|
|
156
|
+
* incoming message. The return value (boolean) of the function determines
|
|
157
|
+
* whether or not to accept the handshake.
|
|
158
|
+
*/
|
|
159
|
+
type VerifyClientCallbackAsync<Request extends IncomingMessage = IncomingMessage> = (info: {
|
|
160
|
+
origin: string;
|
|
161
|
+
secure: boolean;
|
|
162
|
+
req: Request;
|
|
163
|
+
}, callback: (res: boolean, code?: number, message?: string, headers?: OutgoingHttpHeaders) => void) => void;
|
|
164
|
+
interface ClientOptions extends SecureContextOptions {
|
|
165
|
+
protocol?: string | undefined;
|
|
166
|
+
followRedirects?: boolean | undefined;
|
|
167
|
+
generateMask?(mask: Buffer): void;
|
|
168
|
+
handshakeTimeout?: number | undefined;
|
|
169
|
+
maxRedirects?: number | undefined;
|
|
170
|
+
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
|
|
171
|
+
localAddress?: string | undefined;
|
|
172
|
+
protocolVersion?: number | undefined;
|
|
173
|
+
headers?: {
|
|
174
|
+
[key: string]: string;
|
|
175
|
+
} | undefined;
|
|
176
|
+
origin?: string | undefined;
|
|
177
|
+
agent?: Agent | undefined;
|
|
178
|
+
host?: string | undefined;
|
|
179
|
+
family?: number | undefined;
|
|
180
|
+
checkServerIdentity?(servername: string, cert: CertMeta): boolean;
|
|
181
|
+
rejectUnauthorized?: boolean | undefined;
|
|
182
|
+
maxPayload?: number | undefined;
|
|
183
|
+
skipUTF8Validation?: boolean | undefined;
|
|
184
|
+
}
|
|
185
|
+
interface PerMessageDeflateOptions {
|
|
186
|
+
serverNoContextTakeover?: boolean | undefined;
|
|
187
|
+
clientNoContextTakeover?: boolean | undefined;
|
|
188
|
+
serverMaxWindowBits?: number | undefined;
|
|
189
|
+
clientMaxWindowBits?: number | undefined;
|
|
190
|
+
zlibDeflateOptions?: {
|
|
191
|
+
flush?: number | undefined;
|
|
192
|
+
finishFlush?: number | undefined;
|
|
193
|
+
chunkSize?: number | undefined;
|
|
194
|
+
windowBits?: number | undefined;
|
|
195
|
+
level?: number | undefined;
|
|
196
|
+
memLevel?: number | undefined;
|
|
197
|
+
strategy?: number | undefined;
|
|
198
|
+
dictionary?: Buffer | Buffer[] | DataView | undefined;
|
|
199
|
+
info?: boolean | undefined;
|
|
200
|
+
} | undefined;
|
|
201
|
+
zlibInflateOptions?: ZlibOptions | undefined;
|
|
202
|
+
threshold?: number | undefined;
|
|
203
|
+
concurrencyLimit?: number | undefined;
|
|
204
|
+
}
|
|
205
|
+
interface Event {
|
|
206
|
+
type: string;
|
|
207
|
+
target: WebSocket;
|
|
208
|
+
}
|
|
209
|
+
interface ErrorEvent {
|
|
210
|
+
error: any;
|
|
211
|
+
message: string;
|
|
212
|
+
type: string;
|
|
213
|
+
target: WebSocket;
|
|
214
|
+
}
|
|
215
|
+
interface CloseEvent {
|
|
216
|
+
wasClean: boolean;
|
|
217
|
+
code: number;
|
|
218
|
+
reason: string;
|
|
219
|
+
type: string;
|
|
220
|
+
target: WebSocket;
|
|
221
|
+
}
|
|
222
|
+
interface MessageEvent {
|
|
223
|
+
data: Data;
|
|
224
|
+
type: string;
|
|
225
|
+
target: WebSocket;
|
|
226
|
+
}
|
|
227
|
+
interface EventListenerOptions {
|
|
228
|
+
once?: boolean | undefined;
|
|
229
|
+
}
|
|
230
|
+
interface ServerOptions<U extends typeof WebSocket = typeof WebSocket, V extends typeof IncomingMessage = typeof IncomingMessage> {
|
|
231
|
+
host?: string | undefined;
|
|
232
|
+
port?: number | undefined;
|
|
233
|
+
backlog?: number | undefined;
|
|
234
|
+
server?: Server<V> | Server$1<V> | undefined;
|
|
235
|
+
verifyClient?: VerifyClientCallbackAsync<InstanceType<V>> | VerifyClientCallbackSync<InstanceType<V>> | undefined;
|
|
236
|
+
handleProtocols?: (protocols: Set<string>, request: InstanceType<V>) => string | false;
|
|
237
|
+
path?: string | undefined;
|
|
238
|
+
noServer?: boolean | undefined;
|
|
239
|
+
clientTracking?: boolean | undefined;
|
|
240
|
+
perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
|
|
241
|
+
maxPayload?: number | undefined;
|
|
242
|
+
skipUTF8Validation?: boolean | undefined;
|
|
243
|
+
WebSocket?: U | undefined;
|
|
244
|
+
}
|
|
245
|
+
interface AddressInfo {
|
|
246
|
+
address: string;
|
|
247
|
+
family: string;
|
|
248
|
+
port: number;
|
|
249
|
+
}
|
|
250
|
+
declare class Server$2<T extends typeof WebSocket = typeof WebSocket, U extends typeof IncomingMessage = typeof IncomingMessage> extends EventEmitter {
|
|
251
|
+
options: ServerOptions<T, U>;
|
|
252
|
+
path: string;
|
|
253
|
+
clients: Set<InstanceType<T>>;
|
|
254
|
+
constructor(options?: ServerOptions<T, U>, callback?: () => void);
|
|
255
|
+
address(): AddressInfo | string;
|
|
256
|
+
close(cb?: (err?: Error) => void): void;
|
|
257
|
+
handleUpgrade(request: InstanceType<U>, socket: Duplex, upgradeHead: Buffer, callback: (client: InstanceType<T>, request: InstanceType<U>) => void): void;
|
|
258
|
+
shouldHandle(request: InstanceType<U>): boolean | Promise<boolean>;
|
|
259
|
+
on(event: "connection", cb: (this: Server$2<T>, socket: InstanceType<T>, request: InstanceType<U>) => void): this;
|
|
260
|
+
on(event: "error", cb: (this: Server$2<T>, error: Error) => void): this;
|
|
261
|
+
on(event: "headers", cb: (this: Server$2<T>, headers: string[], request: InstanceType<U>) => void): this;
|
|
262
|
+
on(event: "close" | "listening", cb: (this: Server$2<T>) => void): this;
|
|
263
|
+
on(event: string | symbol, listener: (this: Server$2<T>, ...args: any[]) => void): this;
|
|
264
|
+
once(event: "connection", cb: (this: Server$2<T>, socket: InstanceType<T>, request: InstanceType<U>) => void): this;
|
|
265
|
+
once(event: "error", cb: (this: Server$2<T>, error: Error) => void): this;
|
|
266
|
+
once(event: "headers", cb: (this: Server$2<T>, headers: string[], request: InstanceType<U>) => void): this;
|
|
267
|
+
once(event: "close" | "listening", cb: (this: Server$2<T>) => void): this;
|
|
268
|
+
once(event: string | symbol, listener: (this: Server$2<T>, ...args: any[]) => void): this;
|
|
269
|
+
off(event: "connection", cb: (this: Server$2<T>, socket: InstanceType<T>, request: InstanceType<U>) => void): this;
|
|
270
|
+
off(event: "error", cb: (this: Server$2<T>, error: Error) => void): this;
|
|
271
|
+
off(event: "headers", cb: (this: Server$2<T>, headers: string[], request: InstanceType<U>) => void): this;
|
|
272
|
+
off(event: "close" | "listening", cb: (this: Server$2<T>) => void): this;
|
|
273
|
+
off(event: string | symbol, listener: (this: Server$2<T>, ...args: any[]) => void): this;
|
|
274
|
+
addListener(event: "connection", cb: (client: InstanceType<T>, request: InstanceType<U>) => void): this;
|
|
275
|
+
addListener(event: "error", cb: (err: Error) => void): this;
|
|
276
|
+
addListener(event: "headers", cb: (headers: string[], request: InstanceType<U>) => void): this;
|
|
277
|
+
addListener(event: "close" | "listening", cb: () => void): this;
|
|
278
|
+
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
279
|
+
removeListener(event: "connection", cb: (client: InstanceType<T>, request: InstanceType<U>) => void): this;
|
|
280
|
+
removeListener(event: "error", cb: (err: Error) => void): this;
|
|
281
|
+
removeListener(event: "headers", cb: (headers: string[], request: InstanceType<U>) => void): this;
|
|
282
|
+
removeListener(event: "close" | "listening", cb: () => void): this;
|
|
283
|
+
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
284
|
+
}
|
|
285
|
+
type WebSocketServer = Server$2;
|
|
286
|
+
declare function createWebSocketStream(websocket: WebSocket, options?: DuplexOptions): Duplex;
|
|
287
|
+
interface NodeOptions extends AdapterOptions {
|
|
288
|
+
wss?: WebSocketServer;
|
|
289
|
+
serverOptions?: ServerOptions;
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
292
|
+
export { type NodeOptions };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Message, Peer, toBufferLike } from "../shared/crossws.DfCzGthR.mjs";
|
|
2
|
+
import { AdapterHookable, adapterUtils } from "../shared/crossws.D9ehKjSh.mjs";
|
|
3
|
+
import { WSError } from "../shared/crossws.By9qWDAI.mjs";
|
|
4
|
+
import { _WebSocketServer } from "../shared/crossws.CipVM6lf.mjs";
|
|
5
|
+
//#region ../../node_modules/.pnpm/crossws@0.3.5/node_modules/crossws/dist/adapters/node.mjs
|
|
6
|
+
const nodeAdapter = (options = {}) => {
|
|
7
|
+
const hooks = new AdapterHookable(options);
|
|
8
|
+
const peers = /* @__PURE__ */ new Set();
|
|
9
|
+
const wss = options.wss || new _WebSocketServer({
|
|
10
|
+
noServer: true,
|
|
11
|
+
...options.serverOptions
|
|
12
|
+
});
|
|
13
|
+
wss.on("connection", (ws, nodeReq) => {
|
|
14
|
+
const peer = new NodePeer({
|
|
15
|
+
ws,
|
|
16
|
+
request: new NodeReqProxy(nodeReq),
|
|
17
|
+
peers,
|
|
18
|
+
nodeReq
|
|
19
|
+
});
|
|
20
|
+
peers.add(peer);
|
|
21
|
+
hooks.callHook("open", peer);
|
|
22
|
+
ws.on("message", (data) => {
|
|
23
|
+
if (Array.isArray(data)) data = Buffer.concat(data);
|
|
24
|
+
hooks.callHook("message", peer, new Message(data, peer));
|
|
25
|
+
});
|
|
26
|
+
ws.on("error", (error) => {
|
|
27
|
+
peers.delete(peer);
|
|
28
|
+
hooks.callHook("error", peer, new WSError(error));
|
|
29
|
+
});
|
|
30
|
+
ws.on("close", (code, reason) => {
|
|
31
|
+
peers.delete(peer);
|
|
32
|
+
hooks.callHook("close", peer, {
|
|
33
|
+
code,
|
|
34
|
+
reason: reason?.toString()
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
wss.on("headers", (outgoingHeaders, req) => {
|
|
39
|
+
const upgradeHeaders = req._upgradeHeaders;
|
|
40
|
+
if (upgradeHeaders) for (const [key, value] of new Headers(upgradeHeaders)) outgoingHeaders.push(`${key}: ${value}`);
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
...adapterUtils(peers),
|
|
44
|
+
handleUpgrade: async (nodeReq, socket, head) => {
|
|
45
|
+
const request = new NodeReqProxy(nodeReq);
|
|
46
|
+
const { upgradeHeaders, endResponse, context } = await hooks.upgrade(request);
|
|
47
|
+
if (endResponse) return sendResponse(socket, endResponse);
|
|
48
|
+
nodeReq._request = request;
|
|
49
|
+
nodeReq._upgradeHeaders = upgradeHeaders;
|
|
50
|
+
nodeReq._context = context;
|
|
51
|
+
wss.handleUpgrade(nodeReq, socket, head, (ws) => {
|
|
52
|
+
wss.emit("connection", ws, nodeReq);
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
closeAll: (code, data, force) => {
|
|
56
|
+
for (const client of wss.clients) if (force) client.terminate();
|
|
57
|
+
else client.close(code, data);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
var NodePeer = class extends Peer {
|
|
62
|
+
get remoteAddress() {
|
|
63
|
+
return this._internal.nodeReq.socket?.remoteAddress;
|
|
64
|
+
}
|
|
65
|
+
get context() {
|
|
66
|
+
return this._internal.nodeReq._context;
|
|
67
|
+
}
|
|
68
|
+
send(data, options) {
|
|
69
|
+
const dataBuff = toBufferLike(data);
|
|
70
|
+
const isBinary = typeof dataBuff !== "string";
|
|
71
|
+
this._internal.ws.send(dataBuff, {
|
|
72
|
+
compress: options?.compress,
|
|
73
|
+
binary: isBinary,
|
|
74
|
+
...options
|
|
75
|
+
});
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
publish(topic, data, options) {
|
|
79
|
+
const dataBuff = toBufferLike(data);
|
|
80
|
+
const isBinary = typeof data !== "string";
|
|
81
|
+
const sendOptions = {
|
|
82
|
+
compress: options?.compress,
|
|
83
|
+
binary: isBinary,
|
|
84
|
+
...options
|
|
85
|
+
};
|
|
86
|
+
for (const peer of this._internal.peers) if (peer !== this && peer._topics.has(topic)) peer._internal.ws.send(dataBuff, sendOptions);
|
|
87
|
+
}
|
|
88
|
+
close(code, data) {
|
|
89
|
+
this._internal.ws.close(code, data);
|
|
90
|
+
}
|
|
91
|
+
terminate() {
|
|
92
|
+
this._internal.ws.terminate();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var NodeReqProxy = class {
|
|
96
|
+
_req;
|
|
97
|
+
_headers;
|
|
98
|
+
_url;
|
|
99
|
+
constructor(req) {
|
|
100
|
+
this._req = req;
|
|
101
|
+
}
|
|
102
|
+
get url() {
|
|
103
|
+
if (!this._url) {
|
|
104
|
+
const req = this._req;
|
|
105
|
+
const host = req.headers["host"] || "localhost";
|
|
106
|
+
this._url = `${req.socket?.encrypted ?? req.headers["x-forwarded-proto"] === "https" ? "https" : "http"}://${host}${req.url}`;
|
|
107
|
+
}
|
|
108
|
+
return this._url;
|
|
109
|
+
}
|
|
110
|
+
get headers() {
|
|
111
|
+
if (!this._headers) this._headers = new Headers(this._req.headers);
|
|
112
|
+
return this._headers;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
async function sendResponse(socket, res) {
|
|
116
|
+
const head = [`HTTP/1.1 ${res.status || 200} ${res.statusText || ""}`, ...[...res.headers.entries()].map(([key, value]) => `${encodeURIComponent(key)}: ${encodeURIComponent(value)}`)];
|
|
117
|
+
socket.write(head.join("\r\n") + "\r\n\r\n");
|
|
118
|
+
if (res.body) for await (const chunk of res.body) socket.write(chunk);
|
|
119
|
+
return new Promise((resolve) => {
|
|
120
|
+
socket.end(() => {
|
|
121
|
+
socket.destroy();
|
|
122
|
+
resolve();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { nodeAdapter as default };
|