visaljs 0.0.0-stage → 0.0.2
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/LICENSE +21 -0
- package/README.md +45 -2
- package/cli.js +8084 -0
- package/node/include/js_node.h +46 -0
- package/node/prelude/async_hooks.js +88 -0
- package/node/prelude/buffer.js +31 -0
- package/node/prelude/crypto.js +114 -0
- package/node/prelude/events.js +227 -0
- package/node/prelude/fs.js +79 -0
- package/node/prelude/http.js +536 -0
- package/node/prelude/http2.js +30 -0
- package/node/prelude/internal/crypto/asym.js +333 -0
- package/node/prelude/internal/crypto/cipher.js +205 -0
- package/node/prelude/internal/crypto/hash.js +137 -0
- package/node/prelude/internal/crypto/kdf.js +182 -0
- package/node/prelude/internal/crypto/keys.js +603 -0
- package/node/prelude/internal/crypto/random.js +118 -0
- package/node/prelude/internal/crypto/util.js +76 -0
- package/node/prelude/internal/errors.js +88 -0
- package/node/prelude/internal/querystring.js +105 -0
- package/node/prelude/module.js +53 -0
- package/node/prelude/net.js +51 -0
- package/node/prelude/os.js +129 -0
- package/node/prelude/path.js +257 -0
- package/node/prelude/process.js +21 -0
- package/node/prelude/querystring.js +469 -0
- package/node/prelude/stream.js +1327 -0
- package/node/prelude/stream_promises.js +7 -0
- package/node/prelude/stream_web.js +6 -0
- package/node/prelude/string_decoder.js +236 -0
- package/node/prelude/tty.js +18 -0
- package/node/prelude/url.js +1156 -0
- package/node/prelude/util.js +64 -0
- package/node/prelude/zlib.js +81 -0
- package/node/src/host_fs.c +126 -0
- package/node/src/host_http.c +486 -0
- package/node/src/host_os.c +505 -0
- package/node/src/host_sys.c +78 -0
- package/node/third_party/libuv/LICENSE +19 -0
- package/node/third_party/libuv/include/uv/aix.h +32 -0
- package/node/third_party/libuv/include/uv/bsd.h +34 -0
- package/node/third_party/libuv/include/uv/darwin.h +61 -0
- package/node/third_party/libuv/include/uv/errno.h +483 -0
- package/node/third_party/libuv/include/uv/linux.h +34 -0
- package/node/third_party/libuv/include/uv/os390.h +33 -0
- package/node/third_party/libuv/include/uv/posix.h +31 -0
- package/node/third_party/libuv/include/uv/sunos.h +44 -0
- package/node/third_party/libuv/include/uv/threadpool.h +37 -0
- package/node/third_party/libuv/include/uv/tree.h +521 -0
- package/node/third_party/libuv/include/uv/unix.h +512 -0
- package/node/third_party/libuv/include/uv/version.h +43 -0
- package/node/third_party/libuv/include/uv/win.h +698 -0
- package/node/third_party/libuv/include/uv.h +1990 -0
- package/node/third_party/libuv/src/fs-poll.c +290 -0
- package/node/third_party/libuv/src/heap-inl.h +245 -0
- package/node/third_party/libuv/src/idna.c +560 -0
- package/node/third_party/libuv/src/idna.h +31 -0
- package/node/third_party/libuv/src/inet.c +298 -0
- package/node/third_party/libuv/src/queue.h +90 -0
- package/node/third_party/libuv/src/random.c +123 -0
- package/node/third_party/libuv/src/strscpy.c +38 -0
- package/node/third_party/libuv/src/strscpy.h +39 -0
- package/node/third_party/libuv/src/strtok.c +52 -0
- package/node/third_party/libuv/src/strtok.h +27 -0
- package/node/third_party/libuv/src/thread-common.c +175 -0
- package/node/third_party/libuv/src/threadpool.c +419 -0
- package/node/third_party/libuv/src/timer.c +200 -0
- package/node/third_party/libuv/src/unix/async.c +418 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +164 -0
- package/node/third_party/libuv/src/unix/core.c +2104 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +176 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +97 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +17 -0
- package/node/third_party/libuv/src/unix/darwin.c +237 -0
- package/node/third_party/libuv/src/unix/dl.c +80 -0
- package/node/third_party/libuv/src/unix/fs.c +2303 -0
- package/node/third_party/libuv/src/unix/fsevents.c +906 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +252 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +121 -0
- package/node/third_party/libuv/src/unix/internal.h +530 -0
- package/node/third_party/libuv/src/unix/kqueue.c +667 -0
- package/node/third_party/libuv/src/unix/linux.c +2761 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +68 -0
- package/node/third_party/libuv/src/unix/loop.c +240 -0
- package/node/third_party/libuv/src/unix/pipe.c +555 -0
- package/node/third_party/libuv/src/unix/poll.c +159 -0
- package/node/third_party/libuv/src/unix/process.c +1123 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +45 -0
- package/node/third_party/libuv/src/unix/proctitle.c +157 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +93 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +57 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +86 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +99 -0
- package/node/third_party/libuv/src/unix/signal.c +581 -0
- package/node/third_party/libuv/src/unix/stream.c +1567 -0
- package/node/third_party/libuv/src/unix/tcp.c +673 -0
- package/node/third_party/libuv/src/unix/thread.c +975 -0
- package/node/third_party/libuv/src/unix/tty.c +510 -0
- package/node/third_party/libuv/src/unix/udp.c +1434 -0
- package/node/third_party/libuv/src/uv-common.c +1051 -0
- package/node/third_party/libuv/src/uv-common.h +474 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +119 -0
- package/node/third_party/libuv/src/version.c +45 -0
- package/node/third_party/llhttp/LICENSE +22 -0
- package/node/third_party/llhttp/api.c +509 -0
- package/node/third_party/llhttp/http.c +170 -0
- package/node/third_party/llhttp/llhttp.c +10099 -0
- package/node/third_party/llhttp/llhttp.h +907 -0
- package/package.json +25 -4
- package/runtime/include/js_atoms.gen.h +68 -0
- package/runtime/include/js_atoms.h +54 -0
- package/runtime/include/js_bigint.h +93 -0
- package/runtime/include/js_buffer.h +79 -0
- package/runtime/include/js_builtins.h +168 -0
- package/runtime/include/js_console.h +58 -0
- package/runtime/include/js_convert.h +22 -0
- package/runtime/include/js_core.def +188 -0
- package/runtime/include/js_crypto.h +58 -0
- package/runtime/include/js_error.h +37 -0
- package/runtime/include/js_exception.h +65 -0
- package/runtime/include/js_function.h +167 -0
- package/runtime/include/js_gc.h +195 -0
- package/runtime/include/js_generator.h +96 -0
- package/runtime/include/js_host.h +19 -0
- package/runtime/include/js_jobs.h +84 -0
- package/runtime/include/js_module.h +16 -0
- package/runtime/include/js_object.h +384 -0
- package/runtime/include/js_ops.h +111 -0
- package/runtime/include/js_promise.h +45 -0
- package/runtime/include/js_regexp.h +25 -0
- package/runtime/include/js_runtime.h +30 -0
- package/runtime/include/js_symbol.h +62 -0
- package/runtime/include/js_web.h +110 -0
- package/runtime/include/jscell.h +48 -0
- package/runtime/include/jscontext.h +240 -0
- package/runtime/include/jsnum.h +42 -0
- package/runtime/include/jsstring.h +161 -0
- package/runtime/include/jsvalue.h +142 -0
- package/runtime/src/arguments.c +115 -0
- package/runtime/src/array.c +1145 -0
- package/runtime/src/arraybuffer.c +608 -0
- package/runtime/src/async_iter.c +479 -0
- package/runtime/src/atoms.c +157 -0
- package/runtime/src/base64.c +107 -0
- package/runtime/src/bigint.c +1189 -0
- package/runtime/src/blob.c +371 -0
- package/runtime/src/buffer.c +1357 -0
- package/runtime/src/builtin_table.c +100 -0
- package/runtime/src/builtins.c +987 -0
- package/runtime/src/builtins_util.h +53 -0
- package/runtime/src/collections.c +912 -0
- package/runtime/src/components.c +28 -0
- package/runtime/src/console.c +637 -0
- package/runtime/src/convert.c +82 -0
- package/runtime/src/core_all.c +21 -0
- package/runtime/src/crypto.c +116 -0
- package/runtime/src/crypto_asym.c +644 -0
- package/runtime/src/crypto_cipher.c +671 -0
- package/runtime/src/crypto_hash.c +260 -0
- package/runtime/src/crypto_host.c +414 -0
- package/runtime/src/crypto_internal.h +304 -0
- package/runtime/src/crypto_kdf.c +143 -0
- package/runtime/src/crypto_key.c +171 -0
- package/runtime/src/crypto_pkey.c +794 -0
- package/runtime/src/crypto_subtle.c +1675 -0
- package/runtime/src/date.c +940 -0
- package/runtime/src/domexception.c +169 -0
- package/runtime/src/elements.c +312 -0
- package/runtime/src/elements.h +45 -0
- package/runtime/src/encoding.c +485 -0
- package/runtime/src/error.c +297 -0
- package/runtime/src/events.c +793 -0
- package/runtime/src/exception.c +56 -0
- package/runtime/src/fetch.c +772 -0
- package/runtime/src/function.c +530 -0
- package/runtime/src/gc.c +803 -0
- package/runtime/src/generator.c +218 -0
- package/runtime/src/global.c +119 -0
- package/runtime/src/headers.c +557 -0
- package/runtime/src/inspect.c +1792 -0
- package/runtime/src/internal.h +80 -0
- package/runtime/src/iterate.c +94 -0
- package/runtime/src/iterator.c +409 -0
- package/runtime/src/jobs.c +337 -0
- package/runtime/src/jsnum.c +353 -0
- package/runtime/src/json.c +1028 -0
- package/runtime/src/math.c +243 -0
- package/runtime/src/module.c +336 -0
- package/runtime/src/number.c +176 -0
- package/runtime/src/object.c +1265 -0
- package/runtime/src/ops.c +322 -0
- package/runtime/src/os.c +196 -0
- package/runtime/src/os.h +29 -0
- package/runtime/src/process.c +432 -0
- package/runtime/src/promise.c +721 -0
- package/runtime/src/proxy.c +570 -0
- package/runtime/src/reflect.c +194 -0
- package/runtime/src/regexp.c +1141 -0
- package/runtime/src/regexp_anchor.h +34 -0
- package/runtime/src/regexp_message.h +32 -0
- package/runtime/src/shape.c +294 -0
- package/runtime/src/shape.h +46 -0
- package/runtime/src/streams.c +1046 -0
- package/runtime/src/streams.h +47 -0
- package/runtime/src/string.c +364 -0
- package/runtime/src/string_builtins.c +837 -0
- package/runtime/src/symbol.c +143 -0
- package/runtime/src/test_host.c +59 -0
- package/runtime/src/typedarray.c +1330 -0
- package/runtime/src/tznames.gen.h +712 -0
- package/runtime/src/uri.c +169 -0
- package/runtime/src/url.c +2116 -0
- package/runtime/src/weak.c +486 -0
- package/runtime/src/web.c +214 -0
- package/runtime/src/wrapper.c +59 -0
- package/runtime/src/writable.c +1486 -0
- package/runtime/third_party/ada-idna/LICENSE-MIT +18 -0
- package/runtime/third_party/ada-idna/README.md +27 -0
- package/runtime/third_party/ada-idna/convert.mjs +83 -0
- package/runtime/third_party/ada-idna/idna.c +416 -0
- package/runtime/third_party/ada-idna/idna.h +15 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2657 -0
- package/runtime/third_party/bearssl/LICENSE.txt +21 -0
- package/runtime/third_party/bearssl/README.txt +136 -0
- package/runtime/third_party/bearssl/VERSION +1 -0
- package/runtime/third_party/bearssl/inc/bearssl.h +183 -0
- package/runtime/third_party/bearssl/inc/bearssl_aead.h +1059 -0
- package/runtime/third_party/bearssl/inc/bearssl_block.h +2618 -0
- package/runtime/third_party/bearssl/inc/bearssl_ec.h +967 -0
- package/runtime/third_party/bearssl/inc/bearssl_hash.h +1346 -0
- package/runtime/third_party/bearssl/inc/bearssl_hmac.h +241 -0
- package/runtime/third_party/bearssl/inc/bearssl_kdf.h +284 -0
- package/runtime/third_party/bearssl/inc/bearssl_pem.h +294 -0
- package/runtime/third_party/bearssl/inc/bearssl_prf.h +150 -0
- package/runtime/third_party/bearssl/inc/bearssl_rand.h +397 -0
- package/runtime/third_party/bearssl/inc/bearssl_rsa.h +1655 -0
- package/runtime/third_party/bearssl/inc/bearssl_ssl.h +4296 -0
- package/runtime/third_party/bearssl/inc/bearssl_x509.h +1474 -0
- package/runtime/third_party/bearssl/src/aead/ccm.c +346 -0
- package/runtime/third_party/bearssl/src/aead/eax.c +525 -0
- package/runtime/third_party/bearssl/src/aead/gcm.c +318 -0
- package/runtime/third_party/bearssl/src/codec/ccopy.c +44 -0
- package/runtime/third_party/bearssl/src/codec/dec16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.c +526 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.t0 +314 -0
- package/runtime/third_party/bearssl/src/codec/pemenc.c +173 -0
- package/runtime/third_party/bearssl/src/config.h +247 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m15.c +121 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m31.c +171 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i15.c +398 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i31.c +390 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m15.c +1478 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m31.c +800 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m62.c +605 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m64.c +831 -0
- package/runtime/third_party/bearssl/src/ec/ec_curve25519.c +46 -0
- package/runtime/third_party/bearssl/src/ec/ec_default.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ec_keygen.c +86 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m15.c +2124 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m31.c +1469 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m62.c +1765 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m64.c +1781 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i15.c +824 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i31.c +826 -0
- package/runtime/third_party/bearssl/src/ec/ec_pubkey.c +85 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp256r1.c +51 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp384r1.c +57 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp521r1.c +64 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_atr.c +134 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_raw.c +174 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_raw.c +166 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_raw.c +173 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_raw.c +165 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_rta.c +121 -0
- package/runtime/third_party/bearssl/src/hash/dig_oid.c +84 -0
- package/runtime/third_party/bearssl/src/hash/dig_size.c +50 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul.c +345 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul32.c +251 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul64.c +154 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pclmul.c +389 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pwr8.c +411 -0
- package/runtime/third_party/bearssl/src/hash/md5.c +208 -0
- package/runtime/third_party/bearssl/src/hash/md5sha1.c +141 -0
- package/runtime/third_party/bearssl/src/hash/mgf1.c +56 -0
- package/runtime/third_party/bearssl/src/hash/multihash.c +166 -0
- package/runtime/third_party/bearssl/src/hash/sha1.c +191 -0
- package/runtime/third_party/bearssl/src/hash/sha2big.c +285 -0
- package/runtime/third_party/bearssl/src/hash/sha2small.c +341 -0
- package/runtime/third_party/bearssl/src/inner.h +2577 -0
- package/runtime/third_party/bearssl/src/int/i15_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i15_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i15_decode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_decred.c +100 -0
- package/runtime/third_party/bearssl/src/int/i15_encode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_fmont.c +59 -0
- package/runtime/third_party/bearssl/src/int/i15_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i15_moddiv.c +465 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow.c +50 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i15_montmul.c +184 -0
- package/runtime/third_party/bearssl/src/int/i15_mulacc.c +61 -0
- package/runtime/third_party/bearssl/src/int/i15_muladd.c +173 -0
- package/runtime/third_party/bearssl/src/int/i15_ninv15.c +38 -0
- package/runtime/third_party/bearssl/src/int/i15_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i15_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i15_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i31_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i31_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i31_decode.c +57 -0
- package/runtime/third_party/bearssl/src/int/i31_decred.c +103 -0
- package/runtime/third_party/bearssl/src/int/i31_encode.c +79 -0
- package/runtime/third_party/bearssl/src/int/i31_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i31_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_moddiv.c +488 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i31_montmul.c +127 -0
- package/runtime/third_party/bearssl/src/int/i31_mulacc.c +74 -0
- package/runtime/third_party/bearssl/src/int/i31_muladd.c +157 -0
- package/runtime/third_party/bearssl/src/int/i31_ninv31.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i31_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i31_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i32_add.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i32_decmod.c +77 -0
- package/runtime/third_party/bearssl/src/int/i32_decode.c +63 -0
- package/runtime/third_party/bearssl/src/int/i32_decred.c +107 -0
- package/runtime/third_party/bearssl/src/int/i32_div32.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_encode.c +72 -0
- package/runtime/third_party/bearssl/src/int/i32_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i32_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i32_montmul.c +69 -0
- package/runtime/third_party/bearssl/src/int/i32_mulacc.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_muladd.c +138 -0
- package/runtime/third_party/bearssl/src/int/i32_ninv32.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i32_sub.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i62_modpow2.c +493 -0
- package/runtime/third_party/bearssl/src/kdf/hkdf.c +107 -0
- package/runtime/third_party/bearssl/src/kdf/shake.c +590 -0
- package/runtime/third_party/bearssl/src/mac/hmac.c +122 -0
- package/runtime/third_party/bearssl/src/mac/hmac_ct.c +193 -0
- package/runtime/third_party/bearssl/src/rand/aesctr_drbg.c +206 -0
- package/runtime/third_party/bearssl/src/rand/hmac_drbg.c +157 -0
- package/runtime/third_party/bearssl/src/rand/sysrng.c +252 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_keygen.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_modulus.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_decrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_encrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_priv.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_privexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pub.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pubexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_keygen.c +583 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_priv.c +209 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_privexp.c +320 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pub.c +113 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen_inner.c +608 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_priv.c +203 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_privexp.c +318 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pub.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_priv.c +160 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pub.c +77 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_keygen.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_decrypt.c +61 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_encrypt.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_sign.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_vrfy.c +63 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_priv.c +223 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_sign.c +60 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_vrfy.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pub.c +125 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_pad.c +112 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_unpad.c +145 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_pad.c +100 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_pad.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_ssl_decrypt.c +52 -0
- package/runtime/third_party/bearssl/src/settings.c +306 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_dec.c +254 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_enc.c +157 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_common.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct.c +328 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64.c +398 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcdec.c +104 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcenc.c +81 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctr.c +114 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctrcbc.c +433 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_dec.c +159 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_enc.c +115 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcdec.c +111 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcenc.c +91 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctr.c +116 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctrcbc.c +422 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_dec.c +170 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_enc.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8.c +445 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcdec.c +670 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcenc.c +417 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctr.c +717 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctrcbc.c +946 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_dec.c +176 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_enc.c +129 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni.c +240 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcdec.c +223 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcenc.c +122 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctr.c +211 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctrcbc.c +596 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_ct.c +106 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_sse2.c +237 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct.c +411 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcdec.c +87 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcenc.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/des_support.c +166 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab.c +310 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcdec.c +85 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul.c +260 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul32.c +297 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmulq.c +475 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_i15.c +221 -0
- package/runtime/third_party/bearssl/src/x509/asn1.t0 +757 -0
- package/runtime/third_party/bearssl/src/x509/asn1enc.c +93 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_pk8der.c +110 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_rawder.c +161 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_pk8der.c +97 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_rawder.c +96 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.c +653 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.t0 +376 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.c +776 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.t0 +324 -0
- package/runtime/third_party/bearssl/src/x509/x509_knownkey.c +105 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.c +1722 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.t0 +1526 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal_full.c +59 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +22 -0
- package/runtime/third_party/quickjs-dtoa/README.md +23 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.c +1640 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +83 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +89 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +22 -0
- package/runtime/third_party/quickjs-regexp/README.md +22 -0
- package/runtime/third_party/quickjs-regexp/cutils.c +641 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +457 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +73 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +3448 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +65 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +5206 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +2124 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +196 -0
- package/runtime/third_party/v8-ieee754/LICENSE +61 -0
- package/runtime/third_party/v8-ieee754/README.md +22 -0
- package/runtime/third_party/v8-ieee754/convert.py +84 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +3030 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +27 -0
- package/runtime/tools/regexp_compile.c +90 -0
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
// node:http (ADR 0012, layer 3), the server side: createServer, Server, IncomingMessage and
|
|
2
|
+
// ServerResponse over the host primitives of runtime/src/host_http.c (libuv TCP, llhttp
|
|
3
|
+
// parsing). Responses are written as Node writes them: the status line, the headers in the
|
|
4
|
+
// order set, then Date, Connection, Keep-Alive and Content-Length or chunked encoding.
|
|
5
|
+
// A request is a Readable of the body's Buffers; a response writes strings and bytes.
|
|
6
|
+
// Not yet: the client, timeouts, upgrades, trailers.
|
|
7
|
+
import { errnoMessage, errnoName, httpAddress, httpCloseServer, httpDate, httpEnd, httpListen, httpWrite } from "visaljs:host";
|
|
8
|
+
import { EventEmitter } from "./events.js";
|
|
9
|
+
import { Readable, Stream } from "./stream.js";
|
|
10
|
+
|
|
11
|
+
export const METHODS = ["ACL", "BIND", "CHECKOUT", "CONNECT", "COPY", "DELETE", "GET", "HEAD", "LINK", "LOCK", "M-SEARCH", "MERGE",
|
|
12
|
+
"MKACTIVITY", "MKCALENDAR", "MKCOL", "MOVE", "NOTIFY", "OPTIONS", "PATCH", "POST", "PROPFIND", "PROPPATCH", "PURGE", "PUT", "QUERY",
|
|
13
|
+
"REBIND", "REPORT", "SEARCH", "SOURCE", "SUBSCRIBE", "TRACE", "UNBIND", "UNLINK", "UNLOCK", "UNSUBSCRIBE"];
|
|
14
|
+
|
|
15
|
+
export const STATUS_CODES = {
|
|
16
|
+
100: "Continue", 101: "Switching Protocols", 102: "Processing", 103: "Early Hints",
|
|
17
|
+
200: "OK", 201: "Created", 202: "Accepted", 203: "Non-Authoritative Information", 204: "No Content", 205: "Reset Content",
|
|
18
|
+
206: "Partial Content", 207: "Multi-Status", 208: "Already Reported", 226: "IM Used",
|
|
19
|
+
300: "Multiple Choices", 301: "Moved Permanently", 302: "Found", 303: "See Other", 304: "Not Modified", 305: "Use Proxy",
|
|
20
|
+
307: "Temporary Redirect", 308: "Permanent Redirect",
|
|
21
|
+
400: "Bad Request", 401: "Unauthorized", 402: "Payment Required", 403: "Forbidden", 404: "Not Found", 405: "Method Not Allowed",
|
|
22
|
+
406: "Not Acceptable", 407: "Proxy Authentication Required", 408: "Request Timeout", 409: "Conflict", 410: "Gone",
|
|
23
|
+
411: "Length Required", 412: "Precondition Failed", 413: "Payload Too Large", 414: "URI Too Long", 415: "Unsupported Media Type",
|
|
24
|
+
416: "Range Not Satisfiable", 417: "Expectation Failed", 418: "I'm a Teapot", 421: "Misdirected Request",
|
|
25
|
+
422: "Unprocessable Entity", 423: "Locked", 424: "Failed Dependency", 425: "Too Early", 426: "Upgrade Required",
|
|
26
|
+
428: "Precondition Required", 429: "Too Many Requests", 431: "Request Header Fields Too Large", 451: "Unavailable For Legal Reasons",
|
|
27
|
+
500: "Internal Server Error", 501: "Not Implemented", 502: "Bad Gateway", 503: "Service Unavailable", 504: "Gateway Timeout",
|
|
28
|
+
505: "HTTP Version Not Supported", 506: "Variant Also Negotiates", 507: "Insufficient Storage", 508: "Loop Detected",
|
|
29
|
+
509: "Bandwidth Limit Exceeded", 510: "Not Extended", 511: "Network Authentication Required",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/* the UTF-8 length of a string: Content-Length counts bytes */
|
|
33
|
+
function byteLength(s) {
|
|
34
|
+
let n = s.length;
|
|
35
|
+
for (let i = 0; i < s.length; i++) {
|
|
36
|
+
const c = s.charCodeAt(i);
|
|
37
|
+
if (c >= 0x80) {
|
|
38
|
+
if (c < 0x800) n += 1;
|
|
39
|
+
else if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length && (s.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {
|
|
40
|
+
n += 2;
|
|
41
|
+
i++;
|
|
42
|
+
} else n += 2;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return n;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function chunkLength(chunk) {
|
|
49
|
+
return typeof chunk === "string" ? byteLength(chunk) : chunk.byteLength;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* ---- IncomingMessage ------------------------------------------------------------------------ */
|
|
53
|
+
|
|
54
|
+
/* A request: a Readable of the body's Buffers, pushed as llhttp parses them. */
|
|
55
|
+
export class IncomingMessage extends Readable {
|
|
56
|
+
constructor(socket) {
|
|
57
|
+
super();
|
|
58
|
+
this.socket = socket;
|
|
59
|
+
this.httpVersionMajor = 1;
|
|
60
|
+
this.httpVersionMinor = 1;
|
|
61
|
+
this.httpVersion = "1.1";
|
|
62
|
+
this.complete = false;
|
|
63
|
+
this.rawHeaders = [];
|
|
64
|
+
this.headers = {};
|
|
65
|
+
this.rawTrailers = [];
|
|
66
|
+
this.trailers = {};
|
|
67
|
+
this.method = null;
|
|
68
|
+
this.url = "";
|
|
69
|
+
this.aborted = false;
|
|
70
|
+
this.statusCode = null;
|
|
71
|
+
this.statusMessage = null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
get connection() {
|
|
75
|
+
return this.socket;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_read() {}
|
|
79
|
+
|
|
80
|
+
_push(chunk) {
|
|
81
|
+
this.push(Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
_finish() {
|
|
85
|
+
this.complete = true;
|
|
86
|
+
this.push(null);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* the connection closed before the body was complete */
|
|
90
|
+
_abort() {
|
|
91
|
+
if (this.complete || this.destroyed) return;
|
|
92
|
+
this.aborted = true;
|
|
93
|
+
this.emit("aborted");
|
|
94
|
+
const e = new Error("aborted");
|
|
95
|
+
e.code = "ECONNRESET";
|
|
96
|
+
this.destroy(e);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setTimeout(msecs, callback) {
|
|
100
|
+
if (typeof callback === "function") this.once("timeout", callback);
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* Node's req.headers: lowercase names; repeats joined with ", " ("; " for cookie), kept as an
|
|
106
|
+
* array for set-cookie, and the first one kept for the headers that can't repeat */
|
|
107
|
+
const SINGLE = new Set(["age", "authorization", "content-length", "content-type", "etag", "expires", "from", "host",
|
|
108
|
+
"if-modified-since", "if-unmodified-since", "last-modified", "location", "max-forwards", "proxy-authorization", "referer",
|
|
109
|
+
"retry-after", "server", "user-agent"]);
|
|
110
|
+
|
|
111
|
+
function addHeader(headers, name, value) {
|
|
112
|
+
const key = name.toLowerCase();
|
|
113
|
+
const existing = headers[key];
|
|
114
|
+
if (existing === undefined) headers[key] = key === "set-cookie" ? [value] : value;
|
|
115
|
+
else if (key === "set-cookie") existing.push(value);
|
|
116
|
+
else if (SINGLE.has(key)) return;
|
|
117
|
+
else headers[key] = existing + (key === "cookie" ? "; " : ", ") + value;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* ---- ServerResponse ------------------------------------------------------------------------- */
|
|
121
|
+
|
|
122
|
+
export class ServerResponse extends Stream {
|
|
123
|
+
constructor(req, conn, keepAlive) {
|
|
124
|
+
super();
|
|
125
|
+
this.writable = true;
|
|
126
|
+
this.destroyed = false;
|
|
127
|
+
this.writableCorked = 0;
|
|
128
|
+
this.writableNeedDrain = false;
|
|
129
|
+
this.writableHighWaterMark = 16384;
|
|
130
|
+
/* Node's OutgoingMessage internals, which frameworks set (@hono/node-server sets
|
|
131
|
+
* _contentLength to have the length sent after the other headers, as Node sends it) */
|
|
132
|
+
this.useChunkedEncodingByDefault = true;
|
|
133
|
+
this._hasBody = req.method !== "HEAD";
|
|
134
|
+
this._contentLength = null;
|
|
135
|
+
this._removedContLen = false;
|
|
136
|
+
this.req = req;
|
|
137
|
+
this.socket = req.socket;
|
|
138
|
+
this.statusCode = 200;
|
|
139
|
+
this.statusMessage = undefined;
|
|
140
|
+
this.headersSent = false;
|
|
141
|
+
this.finished = false;
|
|
142
|
+
this.writableEnded = false;
|
|
143
|
+
this.writableFinished = false;
|
|
144
|
+
this.sendDate = true;
|
|
145
|
+
this.chunkedEncoding = false;
|
|
146
|
+
this._conn = conn;
|
|
147
|
+
this._keepAlive = keepAlive;
|
|
148
|
+
this._headers = new Map(); /* lowercase name → [name as set, value] */
|
|
149
|
+
this._head = req.method === "HEAD";
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
setHeader(name, value) {
|
|
153
|
+
if (this.headersSent) {
|
|
154
|
+
const e = new Error("Cannot set headers after they are sent to the client");
|
|
155
|
+
e.code = "ERR_HTTP_HEADERS_SENT";
|
|
156
|
+
throw e;
|
|
157
|
+
}
|
|
158
|
+
this._headers.set(String(name).toLowerCase(), [String(name), value]);
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
appendHeader(name, value) {
|
|
163
|
+
const key = String(name).toLowerCase();
|
|
164
|
+
const existing = this._headers.get(key);
|
|
165
|
+
if (existing === undefined) return this.setHeader(name, value);
|
|
166
|
+
existing[1] = [].concat(existing[1], value);
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
get connection() {
|
|
171
|
+
return this.socket;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
get writableLength() {
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
cork() {
|
|
179
|
+
this.writableCorked++;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
uncork() {
|
|
183
|
+
if (this.writableCorked) this.writableCorked--;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
setTimeout(msecs, callback) {
|
|
187
|
+
if (typeof callback === "function") this.once("timeout", callback);
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* sends the head now: the body that follows is chunked */
|
|
192
|
+
flushHeaders() {
|
|
193
|
+
if (!this.headersSent) httpWrite(this._conn, this._renderHead(undefined));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
destroy(error) {
|
|
197
|
+
if (this.destroyed) return this;
|
|
198
|
+
this.destroyed = true;
|
|
199
|
+
this.writable = false;
|
|
200
|
+
httpEnd(this._conn, true);
|
|
201
|
+
queueMicrotask(() => {
|
|
202
|
+
if (error) this.emit("error", error);
|
|
203
|
+
this.emit("close");
|
|
204
|
+
});
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* the connection closed: 'close', without 'finish' when the response wasn't ended */
|
|
209
|
+
_connectionClosed() {
|
|
210
|
+
if (this._closeEmitted) return;
|
|
211
|
+
this._closeEmitted = true;
|
|
212
|
+
this.destroyed = true;
|
|
213
|
+
this.writable = false;
|
|
214
|
+
queueMicrotask(() => this.emit("close"));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
getHeader(name) {
|
|
218
|
+
const h = this._headers.get(String(name).toLowerCase());
|
|
219
|
+
return h === undefined ? undefined : h[1];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
hasHeader(name) {
|
|
223
|
+
return this._headers.has(String(name).toLowerCase());
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
removeHeader(name) {
|
|
227
|
+
this._headers.delete(String(name).toLowerCase());
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
getHeaderNames() {
|
|
231
|
+
return [...this._headers.keys()];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
getHeaders() {
|
|
235
|
+
const out = Object.create(null);
|
|
236
|
+
for (const [key, [, value]] of this._headers) out[key] = value;
|
|
237
|
+
return out;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
writeHead(statusCode, statusMessage, headers) {
|
|
241
|
+
if (typeof statusMessage !== "string") {
|
|
242
|
+
headers = statusMessage;
|
|
243
|
+
statusMessage = undefined;
|
|
244
|
+
}
|
|
245
|
+
this.statusCode = statusCode;
|
|
246
|
+
if (statusMessage !== undefined) this.statusMessage = statusMessage;
|
|
247
|
+
if (Array.isArray(headers)) {
|
|
248
|
+
for (let i = 0; i < headers.length; i += 2) this.appendHeader(headers[i], headers[i + 1]);
|
|
249
|
+
} else if (headers) {
|
|
250
|
+
for (const name of Object.keys(headers)) this.setHeader(name, headers[name]);
|
|
251
|
+
}
|
|
252
|
+
/* Node renders the head now (sent with the first write): without a known length, the body
|
|
253
|
+
* is chunked even when end() brings all of it */
|
|
254
|
+
if (!this.headersSent) this._pendingHead = this._renderHead(undefined);
|
|
255
|
+
return this;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/* what goes out before a body chunk: the head, if it hasn't gone yet */
|
|
259
|
+
_takeHead(length) {
|
|
260
|
+
if (!this.headersSent) return this._renderHead(length);
|
|
261
|
+
const head = this._pendingHead;
|
|
262
|
+
this._pendingHead = null;
|
|
263
|
+
return head ?? "";
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/* the status line and headers; `length` is the whole body's when end() knows it */
|
|
267
|
+
_renderHead(length) {
|
|
268
|
+
const status = this.statusCode;
|
|
269
|
+
const noBody = status === 204 || status === 304 || (status >= 100 && status < 200);
|
|
270
|
+
let head = "HTTP/1.1 " + status + " " + (this.statusMessage ?? STATUS_CODES[status] ?? "unknown") + "\r\n";
|
|
271
|
+
for (const [, [name, value]] of this._headers) {
|
|
272
|
+
if (Array.isArray(value)) for (const v of value) head += name + ": " + v + "\r\n";
|
|
273
|
+
else head += name + ": " + value + "\r\n";
|
|
274
|
+
}
|
|
275
|
+
if (this.sendDate && !this._headers.has("date")) head += "Date: " + httpDate() + "\r\n";
|
|
276
|
+
const connection = this._headers.get("connection");
|
|
277
|
+
if (connection !== undefined && String(connection[1]).toLowerCase().includes("close")) this._keepAlive = false;
|
|
278
|
+
if (connection === undefined) head += this._keepAlive ? "Connection: keep-alive\r\nKeep-Alive: timeout=5\r\n" : "Connection: close\r\n";
|
|
279
|
+
/* Node: no length for HEAD; an HTTP/1.0 client gets a body that ends with the connection */
|
|
280
|
+
const http10 = this.req.httpVersionMajor < 1 || this.req.httpVersionMinor < 1;
|
|
281
|
+
/* a Transfer-Encoding: chunked the program set: the body is chunk-encoded, as Node does */
|
|
282
|
+
const te = this._headers.get("transfer-encoding");
|
|
283
|
+
if (te !== undefined && /\bchunked\b/i.test(String(te[1])) && !noBody) this.chunkedEncoding = true;
|
|
284
|
+
if (!noBody && !this._head && !http10 && !this._headers.has("content-length") && te === undefined) {
|
|
285
|
+
if (this._contentLength !== null && this._contentLength !== undefined) length = this._contentLength;
|
|
286
|
+
if (length !== undefined) {
|
|
287
|
+
head += "Content-Length: " + length + "\r\n";
|
|
288
|
+
} else {
|
|
289
|
+
head += "Transfer-Encoding: chunked\r\n";
|
|
290
|
+
this.chunkedEncoding = true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
this.headersSent = true;
|
|
294
|
+
return head + "\r\n";
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
write(chunk, encoding, callback) {
|
|
298
|
+
if (typeof encoding === "function") callback = encoding;
|
|
299
|
+
if (this.writableEnded || this.destroyed) {
|
|
300
|
+
const e = new Error(this.destroyed ? "Cannot call write after a stream was destroyed" : "write after end");
|
|
301
|
+
e.code = this.destroyed ? "ERR_STREAM_DESTROYED" : "ERR_STREAM_WRITE_AFTER_END";
|
|
302
|
+
queueMicrotask(() => this.emit("error", e));
|
|
303
|
+
if (typeof callback === "function") queueMicrotask(() => callback(e));
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
if (typeof chunk === "string" && typeof encoding === "string" && encoding !== "utf8" && encoding !== "utf-8") chunk = Buffer.from(chunk, encoding);
|
|
307
|
+
const head = this._takeHead(undefined);
|
|
308
|
+
if (head) httpWrite(this._conn, head);
|
|
309
|
+
if (chunk !== undefined && chunk !== null && chunkLength(chunk) > 0 && !this._head) {
|
|
310
|
+
if (this.chunkedEncoding) {
|
|
311
|
+
httpWrite(this._conn, chunkLength(chunk).toString(16) + "\r\n");
|
|
312
|
+
httpWrite(this._conn, chunk);
|
|
313
|
+
httpWrite(this._conn, "\r\n");
|
|
314
|
+
} else {
|
|
315
|
+
httpWrite(this._conn, chunk);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (typeof callback === "function") queueMicrotask(callback);
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
end(chunk, encoding, callback) {
|
|
323
|
+
if (typeof chunk === "function") {
|
|
324
|
+
callback = chunk;
|
|
325
|
+
chunk = undefined;
|
|
326
|
+
} else if (typeof encoding === "function") {
|
|
327
|
+
callback = encoding;
|
|
328
|
+
}
|
|
329
|
+
if (this.writableEnded) return this;
|
|
330
|
+
if (typeof chunk === "string" && typeof encoding === "string" && encoding !== "utf8" && encoding !== "utf-8") chunk = Buffer.from(chunk, encoding);
|
|
331
|
+
if (!this.headersSent) {
|
|
332
|
+
const hasChunk = chunk !== undefined && chunk !== null;
|
|
333
|
+
const length = hasChunk ? chunkLength(chunk) : 0;
|
|
334
|
+
if (hasChunk && typeof chunk === "string" && !this._head) httpWrite(this._conn, this._renderHead(length) + chunk);
|
|
335
|
+
else {
|
|
336
|
+
httpWrite(this._conn, this._renderHead(length));
|
|
337
|
+
if (hasChunk && length && !this._head) httpWrite(this._conn, chunk);
|
|
338
|
+
}
|
|
339
|
+
} else {
|
|
340
|
+
if (chunk !== undefined && chunk !== null) this.write(chunk);
|
|
341
|
+
const head = this._takeHead(undefined);
|
|
342
|
+
if (head) httpWrite(this._conn, head);
|
|
343
|
+
if (this.chunkedEncoding && !this._head) httpWrite(this._conn, "0\r\n\r\n");
|
|
344
|
+
}
|
|
345
|
+
this.writableEnded = this.finished = true;
|
|
346
|
+
this.writable = false;
|
|
347
|
+
httpEnd(this._conn, !this._keepAlive);
|
|
348
|
+
queueMicrotask(() => {
|
|
349
|
+
this.writableFinished = true;
|
|
350
|
+
this.emit("finish");
|
|
351
|
+
if (!this._closeEmitted) {
|
|
352
|
+
this._closeEmitted = true;
|
|
353
|
+
this.emit("close");
|
|
354
|
+
}
|
|
355
|
+
if (typeof callback === "function") callback();
|
|
356
|
+
});
|
|
357
|
+
return this;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/* ---- Socket: what a request's and a response's `socket` is ---------------------------------- */
|
|
362
|
+
|
|
363
|
+
class Socket extends EventEmitter {
|
|
364
|
+
constructor(conn) {
|
|
365
|
+
super();
|
|
366
|
+
this._conn = conn;
|
|
367
|
+
this.remoteAddress = undefined;
|
|
368
|
+
this.remotePort = undefined;
|
|
369
|
+
this.encrypted = false;
|
|
370
|
+
this.destroyed = false;
|
|
371
|
+
this.readable = true;
|
|
372
|
+
this.writable = true;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
destroy() {
|
|
376
|
+
if (!this.destroyed) {
|
|
377
|
+
this.destroyed = true;
|
|
378
|
+
httpEnd(this._conn, true);
|
|
379
|
+
}
|
|
380
|
+
return this;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
destroySoon() {
|
|
384
|
+
return this.destroy();
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
end() {
|
|
388
|
+
return this.destroy();
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
setTimeout() {
|
|
392
|
+
return this;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
setNoDelay() {
|
|
396
|
+
return this;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
setKeepAlive() {
|
|
400
|
+
return this;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
ref() {
|
|
404
|
+
return this;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
unref() {
|
|
408
|
+
return this;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/* ---- Server --------------------------------------------------------------------------------- */
|
|
413
|
+
|
|
414
|
+
export class Server extends EventEmitter {
|
|
415
|
+
constructor(options, requestListener) {
|
|
416
|
+
super();
|
|
417
|
+
if (typeof options === "function") requestListener = options;
|
|
418
|
+
if (typeof requestListener === "function") this.on("request", requestListener);
|
|
419
|
+
this.listening = false;
|
|
420
|
+
this._id = -1;
|
|
421
|
+
this._requests = new Map(); /* connection → the request being received */
|
|
422
|
+
this._sockets = new Map(); /* connection → its socket object */
|
|
423
|
+
this._responses = new Map(); /* connection → the response being written */
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
listen(...args) {
|
|
427
|
+
let port, host, backlog = 511, callback;
|
|
428
|
+
if (typeof args[args.length - 1] === "function") callback = args.pop();
|
|
429
|
+
if (args[0] !== null && typeof args[0] === "object") {
|
|
430
|
+
port = args[0].port ?? 0;
|
|
431
|
+
host = args[0].host;
|
|
432
|
+
backlog = args[0].backlog ?? backlog;
|
|
433
|
+
} else {
|
|
434
|
+
port = args[0] ?? 0;
|
|
435
|
+
if (typeof args[1] === "string") host = args[1];
|
|
436
|
+
if (typeof args[args.length - 1] === "number" && args.length > 1) backlog = args[args.length - 1];
|
|
437
|
+
}
|
|
438
|
+
if (callback) this.once("listening", callback);
|
|
439
|
+
const callbacks = [
|
|
440
|
+
(conn, method, url, raw, major, minor, keepAlive) => this._onRequest(conn, method, url, raw, major, minor, keepAlive),
|
|
441
|
+
(conn, chunk) => {
|
|
442
|
+
const req = this._requests.get(conn);
|
|
443
|
+
if (req) req._push(chunk);
|
|
444
|
+
},
|
|
445
|
+
(conn) => {
|
|
446
|
+
const req = this._requests.get(conn);
|
|
447
|
+
if (req) {
|
|
448
|
+
this._requests.delete(conn);
|
|
449
|
+
req._finish();
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
(conn) => {
|
|
453
|
+
const req = this._requests.get(conn);
|
|
454
|
+
this._requests.delete(conn);
|
|
455
|
+
if (req) req._abort();
|
|
456
|
+
const res = this._responses.get(conn);
|
|
457
|
+
this._responses.delete(conn);
|
|
458
|
+
if (res) res._connectionClosed();
|
|
459
|
+
const socket = this._sockets.get(conn);
|
|
460
|
+
this._sockets.delete(conn);
|
|
461
|
+
if (socket) {
|
|
462
|
+
socket.destroyed = true;
|
|
463
|
+
socket.emit("close", false);
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
];
|
|
467
|
+
let address = host ?? "::";
|
|
468
|
+
let id = httpListen(address, Number(port), backlog, ...callbacks);
|
|
469
|
+
if (id < 0 && host === undefined && errnoName(id) === "EAFNOSUPPORT") { /* no IPv6: Node falls back to IPv4 */
|
|
470
|
+
address = "0.0.0.0";
|
|
471
|
+
id = httpListen(address, Number(port), backlog, ...callbacks);
|
|
472
|
+
}
|
|
473
|
+
if (id < 0) {
|
|
474
|
+
const code = errnoName(id);
|
|
475
|
+
const err = new Error("listen " + code + ": " + errnoMessage(id) + " " + address + ":" + port);
|
|
476
|
+
err.code = code;
|
|
477
|
+
err.errno = id;
|
|
478
|
+
err.syscall = "listen";
|
|
479
|
+
err.address = address;
|
|
480
|
+
err.port = Number(port);
|
|
481
|
+
queueMicrotask(() => this.emit("error", err));
|
|
482
|
+
return this;
|
|
483
|
+
}
|
|
484
|
+
this._id = id;
|
|
485
|
+
this.listening = true;
|
|
486
|
+
queueMicrotask(() => this.emit("listening"));
|
|
487
|
+
return this;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
_onRequest(conn, method, url, raw, major, minor, keepAlive) {
|
|
491
|
+
let socket = this._sockets.get(conn);
|
|
492
|
+
if (!socket) {
|
|
493
|
+
socket = new Socket(conn);
|
|
494
|
+
this._sockets.set(conn, socket);
|
|
495
|
+
this.emit("connection", socket);
|
|
496
|
+
}
|
|
497
|
+
const req = new IncomingMessage(socket);
|
|
498
|
+
req.method = method;
|
|
499
|
+
req.url = url;
|
|
500
|
+
req.httpVersionMajor = major;
|
|
501
|
+
req.httpVersionMinor = minor;
|
|
502
|
+
req.httpVersion = major + "." + minor;
|
|
503
|
+
req.rawHeaders = raw;
|
|
504
|
+
for (let i = 0; i < raw.length; i += 2) addHeader(req.headers, raw[i], raw[i + 1]);
|
|
505
|
+
this._requests.set(conn, req);
|
|
506
|
+
const res = new ServerResponse(req, conn, keepAlive);
|
|
507
|
+
this._responses.set(conn, res);
|
|
508
|
+
res.once("finish", () => {
|
|
509
|
+
if (this._responses.get(conn) === res) this._responses.delete(conn);
|
|
510
|
+
});
|
|
511
|
+
this.emit("request", req, res);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
address() {
|
|
515
|
+
const a = httpAddress(this._id);
|
|
516
|
+
return a === null ? null : { address: a[0], family: a[1], port: a[2] };
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
close(callback) {
|
|
520
|
+
if (this.listening) {
|
|
521
|
+
httpCloseServer(this._id);
|
|
522
|
+
this.listening = false;
|
|
523
|
+
}
|
|
524
|
+
queueMicrotask(() => {
|
|
525
|
+
this.emit("close");
|
|
526
|
+
if (typeof callback === "function") callback();
|
|
527
|
+
});
|
|
528
|
+
return this;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export function createServer(options, requestListener) {
|
|
533
|
+
return new Server(options, requestListener);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export default { METHODS, STATUS_CODES, IncomingMessage, ServerResponse, Server, createServer };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// node:http2 (ADR 0012, layer 3): only what code that supports both HTTP versions touches when it
|
|
2
|
+
// runs on HTTP/1 — the request and response classes (for instanceof checks, which never match
|
|
3
|
+
// here) and the constants. Servers and sessions aren't provided: creating one throws.
|
|
4
|
+
import { notSupported } from "./internal/errors.js";
|
|
5
|
+
|
|
6
|
+
export class Http2ServerRequest {}
|
|
7
|
+
export class Http2ServerResponse {}
|
|
8
|
+
|
|
9
|
+
export const constants = {
|
|
10
|
+
NGHTTP2_NO_ERROR: 0, NGHTTP2_PROTOCOL_ERROR: 1, NGHTTP2_INTERNAL_ERROR: 2, NGHTTP2_FLOW_CONTROL_ERROR: 3,
|
|
11
|
+
NGHTTP2_SETTINGS_TIMEOUT: 4, NGHTTP2_STREAM_CLOSED: 5, NGHTTP2_FRAME_SIZE_ERROR: 6, NGHTTP2_REFUSED_STREAM: 7,
|
|
12
|
+
NGHTTP2_CANCEL: 8, NGHTTP2_COMPRESSION_ERROR: 9, NGHTTP2_CONNECT_ERROR: 10, NGHTTP2_ENHANCE_YOUR_CALM: 11,
|
|
13
|
+
NGHTTP2_INADEQUATE_SECURITY: 12, NGHTTP2_HTTP_1_1_REQUIRED: 13,
|
|
14
|
+
HTTP2_HEADER_STATUS: ":status", HTTP2_HEADER_METHOD: ":method", HTTP2_HEADER_AUTHORITY: ":authority",
|
|
15
|
+
HTTP2_HEADER_SCHEME: ":scheme", HTTP2_HEADER_PATH: ":path", HTTP2_HEADER_CONTENT_TYPE: "content-type",
|
|
16
|
+
HTTP2_HEADER_CONTENT_LENGTH: "content-length",
|
|
17
|
+
HTTP_STATUS_OK: 200, HTTP_STATUS_NOT_FOUND: 404, HTTP_STATUS_INTERNAL_SERVER_ERROR: 500,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function createServer() {
|
|
21
|
+
throw notSupported("http2.createServer");
|
|
22
|
+
}
|
|
23
|
+
export function createSecureServer() {
|
|
24
|
+
throw notSupported("http2.createSecureServer");
|
|
25
|
+
}
|
|
26
|
+
export function connect() {
|
|
27
|
+
throw notSupported("http2.connect");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default { Http2ServerRequest, Http2ServerResponse, constants, createServer, createSecureServer, connect };
|