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,46 @@
|
|
|
1
|
+
/* js_node.h — the Node platform's host primitives (ADR 0012): the C side of node/prelude.
|
|
2
|
+
* Prelude modules import them from "visaljs:host"; node/index.ts lists them for the
|
|
3
|
+
* compiler, which makes each a function object. Failures return -errno as a number, which the
|
|
4
|
+
* prelude turns into Node's error; only bad arguments throw here. */
|
|
5
|
+
#ifndef JS_NODE_H
|
|
6
|
+
#define JS_NODE_H
|
|
7
|
+
|
|
8
|
+
#include "js_runtime.h"
|
|
9
|
+
|
|
10
|
+
/* host_fs.c */
|
|
11
|
+
JSValue js_host_fs_read_file(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
12
|
+
JSValue js_host_fs_write_file(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
13
|
+
JSValue js_host_fs_exists(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
14
|
+
JSValue js_host_fs_unlink(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
15
|
+
|
|
16
|
+
/* host_sys.c */
|
|
17
|
+
JSValue js_host_errno_name(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
18
|
+
JSValue js_host_tty_isatty(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
19
|
+
JSValue js_host_errno_message(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
20
|
+
|
|
21
|
+
/* host_http.c: TCP servers on libuv, requests parsed by llhttp (node:http) */
|
|
22
|
+
JSValue js_host_http_listen(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
23
|
+
JSValue js_host_http_address(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
24
|
+
JSValue js_host_http_close_server(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
25
|
+
JSValue js_host_http_write(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
26
|
+
JSValue js_host_http_date(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
27
|
+
JSValue js_host_http_end(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
28
|
+
|
|
29
|
+
/* host_os.c: node:os through libuv */
|
|
30
|
+
JSValue js_host_os_uname(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
31
|
+
JSValue js_host_os_hostname(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
32
|
+
JSValue js_host_os_homedir(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
33
|
+
JSValue js_host_os_tmpdir(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
34
|
+
JSValue js_host_os_memory(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
35
|
+
JSValue js_host_os_uptime(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
36
|
+
JSValue js_host_os_loadavg(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
37
|
+
JSValue js_host_os_parallelism(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
38
|
+
JSValue js_host_os_cpus(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
39
|
+
JSValue js_host_os_user_info(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
40
|
+
JSValue js_host_os_constants(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, JSValue new_target);
|
|
41
|
+
|
|
42
|
+
/* A string argument as a NUL-terminated UTF-8 path (malloc'd; the caller frees it), or NULL
|
|
43
|
+
* with a TypeError pending. */
|
|
44
|
+
char *js_host_path_arg(JSContext *ctx, uint32_t argc, const JSValue *argv, uint32_t i);
|
|
45
|
+
|
|
46
|
+
#endif /* JS_NODE_H */
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// node:async_hooks (ADR 0012, layer 3): AsyncResource, which libraries use to keep a callback's
|
|
2
|
+
// async context (on-finished, raw-body). visaljs keeps no async context: running "in" a resource
|
|
3
|
+
// is calling the function, and hooks never fire. AsyncLocalStorage, which needs the context
|
|
4
|
+
// carried through promises and timers, isn't provided yet.
|
|
5
|
+
import { notSupported, validateFunction, validateString } from "./internal/errors.js";
|
|
6
|
+
|
|
7
|
+
let nextAsyncId = 2; /* 1 is the main program's, as in Node */
|
|
8
|
+
|
|
9
|
+
export class AsyncResource {
|
|
10
|
+
#asyncId;
|
|
11
|
+
#triggerAsyncId;
|
|
12
|
+
|
|
13
|
+
constructor(type, opts = {}) {
|
|
14
|
+
validateString(type, "type");
|
|
15
|
+
this.#asyncId = nextAsyncId++;
|
|
16
|
+
this.#triggerAsyncId = typeof opts === "number" ? opts : (opts.triggerAsyncId ?? 1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
runInAsyncScope(fn, thisArg, ...args) {
|
|
20
|
+
return Reflect.apply(fn, thisArg, args);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
emitDestroy() {
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
asyncId() {
|
|
28
|
+
return this.#asyncId;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
triggerAsyncId() {
|
|
32
|
+
return this.#triggerAsyncId;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
bind(fn, thisArg) {
|
|
36
|
+
validateFunction(fn, "fn");
|
|
37
|
+
const run = (self, args) => this.runInAsyncScope(fn, self, ...args);
|
|
38
|
+
const bound = thisArg === undefined
|
|
39
|
+
? function (...args) {
|
|
40
|
+
return run(this, args);
|
|
41
|
+
}
|
|
42
|
+
: (...args) => run(thisArg, args);
|
|
43
|
+
Object.defineProperties(bound, {
|
|
44
|
+
length: { configurable: true, enumerable: false, value: fn.length, writable: false },
|
|
45
|
+
asyncResource: { configurable: true, enumerable: true, value: this, writable: true },
|
|
46
|
+
});
|
|
47
|
+
return bound;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static bind(fn, type, thisArg) {
|
|
51
|
+
type = type || fn.name || "bound-anonymous-fn";
|
|
52
|
+
return new AsyncResource(type).bind(fn, thisArg);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function executionAsyncId() {
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function triggerAsyncId() {
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function executionAsyncResource() {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** A hook that never fires: visaljs has no async resources to report. */
|
|
69
|
+
export function createHook() {
|
|
70
|
+
return {
|
|
71
|
+
enable() {
|
|
72
|
+
return this;
|
|
73
|
+
},
|
|
74
|
+
disable() {
|
|
75
|
+
return this;
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class AsyncLocalStorage {
|
|
81
|
+
constructor() {
|
|
82
|
+
throw notSupported("AsyncLocalStorage");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const asyncWrapProviders = Object.freeze({ __proto__: null });
|
|
87
|
+
|
|
88
|
+
export default { AsyncResource, AsyncLocalStorage, createHook, executionAsyncId, triggerAsyncId, executionAsyncResource, asyncWrapProviders };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// node:buffer (ADR 0012, layer 3): the globals Node also exports from the module (Buffer, Blob,
|
|
2
|
+
// File, atob, btoa; Buffer is the buffer component's, in C) and the module's constants.
|
|
3
|
+
export const Buffer = globalThis.Buffer;
|
|
4
|
+
export const Blob = globalThis.Blob;
|
|
5
|
+
export const File = globalThis.File;
|
|
6
|
+
export const atob = globalThis.atob;
|
|
7
|
+
export const btoa = globalThis.btoa;
|
|
8
|
+
|
|
9
|
+
export const INSPECT_MAX_BYTES = 50;
|
|
10
|
+
export const kMaxLength = 9007199254740991;
|
|
11
|
+
export const kStringMaxLength = 536870888;
|
|
12
|
+
export const constants = { MAX_LENGTH: kMaxLength, MAX_STRING_LENGTH: kStringMaxLength };
|
|
13
|
+
|
|
14
|
+
export function isUtf8(input) {
|
|
15
|
+
try {
|
|
16
|
+
new TextDecoder("utf-8", { fatal: true }).decode(input);
|
|
17
|
+
return true;
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isAscii(input) {
|
|
24
|
+
const bytes = input instanceof ArrayBuffer ? new Uint8Array(input) : new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
25
|
+
for (let i = 0; i < bytes.length; i++) if (bytes[i] > 127) return false;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const SlowBuffer = Buffer;
|
|
30
|
+
|
|
31
|
+
export default { Buffer, Blob, File, atob, btoa, INSPECT_MAX_BYTES, kMaxLength, kStringMaxLength, constants, isUtf8, isAscii, SlowBuffer };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// node:crypto (ADR 0018, layer 3): Node's API over the runtime's crypto primitives (C, on
|
|
2
|
+
// BearSSL), which Web Crypto (the `crypto` global, a runtime component) shares. What isn't
|
|
3
|
+
// provided yet throws ERR_VISALJS_UNSUPPORTED when called.
|
|
4
|
+
import { cryptoTimingSafeEqual } from "visaljs:host";
|
|
5
|
+
import { codeError, notSupported } from "./internal/errors.js";
|
|
6
|
+
import {
|
|
7
|
+
createECDH, createSign, createVerify, diffieHellman, ECDH, getCurves, privateDecrypt, privateEncrypt, publicDecrypt, publicEncrypt, Sign,
|
|
8
|
+
sign, Verify, verify,
|
|
9
|
+
} from "./internal/crypto/asym.js";
|
|
10
|
+
import { Cipheriv, createCipheriv, createDecipheriv, Decipheriv, getCipherInfo, getCiphers } from "./internal/crypto/cipher.js";
|
|
11
|
+
import { createHash, createHmac, getHashes, Hash, hash, Hmac } from "./internal/crypto/hash.js";
|
|
12
|
+
import {
|
|
13
|
+
createPrivateKey, createPublicKey, createSecretKey, generateKey, generateKeyPair, generateKeyPairSync, generateKeySync, KeyObject,
|
|
14
|
+
} from "./internal/crypto/keys.js";
|
|
15
|
+
import { hkdf, hkdfSync, pbkdf2, pbkdf2Sync, scrypt, scryptSync } from "./internal/crypto/kdf.js";
|
|
16
|
+
import { randomBytes, randomFill, randomFillSync, randomInt, randomUUID } from "./internal/crypto/random.js";
|
|
17
|
+
import { isAnyArrayBuffer, isArrayBufferView } from "./internal/crypto/util.js";
|
|
18
|
+
|
|
19
|
+
export { createHash, createHmac, getHashes, Hash, hash, Hmac, randomBytes, randomFill, randomFillSync, randomInt, randomUUID };
|
|
20
|
+
export { hkdf, hkdfSync, pbkdf2, pbkdf2Sync, scrypt, scryptSync };
|
|
21
|
+
export { createPrivateKey, createPublicKey, createSecretKey, generateKey, generateKeyPair, generateKeyPairSync, generateKeySync, KeyObject };
|
|
22
|
+
export { createECDH, createSign, createVerify, diffieHellman, ECDH, getCurves, privateDecrypt, privateEncrypt, publicDecrypt, publicEncrypt };
|
|
23
|
+
export { Sign, sign, Verify, verify };
|
|
24
|
+
export { Cipheriv, createCipheriv, createDecipheriv, Decipheriv, getCipherInfo, getCiphers };
|
|
25
|
+
|
|
26
|
+
export const webcrypto = globalThis.crypto;
|
|
27
|
+
export const subtle = webcrypto.subtle;
|
|
28
|
+
|
|
29
|
+
export function getRandomValues(array) {
|
|
30
|
+
return webcrypto.getRandomValues(array);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function timingSafeEqual(buf1, buf2) {
|
|
34
|
+
const check = (v, name) => {
|
|
35
|
+
if (!isAnyArrayBuffer(v) && !isArrayBufferView(v)) {
|
|
36
|
+
throw codeError(TypeError, "ERR_INVALID_ARG_TYPE", `The "${name}" argument must be an instance of ArrayBuffer, Buffer, TypedArray, or DataView.`);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
check(buf1, "buf1");
|
|
40
|
+
check(buf2, "buf2");
|
|
41
|
+
if (buf1.byteLength !== buf2.byteLength) throw codeError(RangeError, "ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH", "Input buffers must have the same byte length");
|
|
42
|
+
return cryptoTimingSafeEqual(buf1, buf2);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const CIPHER_LIST =
|
|
46
|
+
"TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:" +
|
|
47
|
+
"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:" +
|
|
48
|
+
"ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:" +
|
|
49
|
+
"DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA";
|
|
50
|
+
|
|
51
|
+
/* Node's (OpenSSL's) values: the RSA paddings and point formats are what the APIs here take */
|
|
52
|
+
export const constants = {
|
|
53
|
+
OPENSSL_VERSION_NUMBER: 810549328, SSL_OP_ALL: 2147485776, SSL_OP_ALLOW_NO_DHE_KEX: 1024,
|
|
54
|
+
SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: 262144, SSL_OP_CIPHER_SERVER_PREFERENCE: 4194304, SSL_OP_CISCO_ANYCONNECT: 32768,
|
|
55
|
+
SSL_OP_COOKIE_EXCHANGE: 8192, SSL_OP_CRYPTOPRO_TLSEXT_BUG: 2147483648, SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: 2048,
|
|
56
|
+
SSL_OP_LEGACY_SERVER_CONNECT: 4, SSL_OP_NO_COMPRESSION: 131072, SSL_OP_NO_ENCRYPT_THEN_MAC: 524288, SSL_OP_NO_QUERY_MTU: 4096,
|
|
57
|
+
SSL_OP_NO_RENEGOTIATION: 1073741824, SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: 65536, SSL_OP_NO_SSLv2: 0,
|
|
58
|
+
SSL_OP_NO_SSLv3: 33554432, SSL_OP_NO_TICKET: 16384, SSL_OP_NO_TLSv1: 67108864, SSL_OP_NO_TLSv1_1: 268435456,
|
|
59
|
+
SSL_OP_NO_TLSv1_2: 134217728, SSL_OP_NO_TLSv1_3: 536870912, SSL_OP_PRIORITIZE_CHACHA: 2097152, SSL_OP_TLS_ROLLBACK_BUG: 8388608,
|
|
60
|
+
ENGINE_METHOD_RSA: 1, ENGINE_METHOD_DSA: 2, ENGINE_METHOD_DH: 4, ENGINE_METHOD_RAND: 8, ENGINE_METHOD_EC: 2048,
|
|
61
|
+
ENGINE_METHOD_CIPHERS: 64, ENGINE_METHOD_DIGESTS: 128, ENGINE_METHOD_PKEY_METHS: 512, ENGINE_METHOD_PKEY_ASN1_METHS: 1024,
|
|
62
|
+
ENGINE_METHOD_ALL: 65535, ENGINE_METHOD_NONE: 0, DH_CHECK_P_NOT_SAFE_PRIME: 2, DH_CHECK_P_NOT_PRIME: 1,
|
|
63
|
+
DH_UNABLE_TO_CHECK_GENERATOR: 4, DH_NOT_SUITABLE_GENERATOR: 8, RSA_PKCS1_PADDING: 1, RSA_NO_PADDING: 3,
|
|
64
|
+
RSA_PKCS1_OAEP_PADDING: 4, RSA_X931_PADDING: 5, RSA_PKCS1_PSS_PADDING: 6, RSA_PSS_SALTLEN_DIGEST: -1,
|
|
65
|
+
RSA_PSS_SALTLEN_MAX_SIGN: -2, RSA_PSS_SALTLEN_AUTO: -2, defaultCoreCipherList: CIPHER_LIST, TLS1_VERSION: 769,
|
|
66
|
+
TLS1_1_VERSION: 770, TLS1_2_VERSION: 771, TLS1_3_VERSION: 772, POINT_CONVERSION_COMPRESSED: 2,
|
|
67
|
+
POINT_CONVERSION_UNCOMPRESSED: 4, POINT_CONVERSION_HYBRID: 6, defaultCipherList: CIPHER_LIST,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export function getFips() {
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function setFips(value) {
|
|
75
|
+
if (value) throw codeError(Error, "ERR_CRYPTO_FIPS_FORCED", "Cannot set FIPS mode in a non-FIPS build.");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function secureHeapUsed() {
|
|
79
|
+
return { total: 0, used: 0, utilization: 0, min: 0 };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function setEngine() {
|
|
83
|
+
throw notSupported("crypto.setEngine");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* not provided yet */
|
|
87
|
+
const unsupported = (name) =>
|
|
88
|
+
function () {
|
|
89
|
+
throw notSupported("crypto." + name);
|
|
90
|
+
};
|
|
91
|
+
export const Certificate = unsupported("Certificate");
|
|
92
|
+
export const Cipher = unsupported("Cipher");
|
|
93
|
+
export const Decipher = unsupported("Decipher");
|
|
94
|
+
export const DiffieHellman = unsupported("DiffieHellman");
|
|
95
|
+
export const DiffieHellmanGroup = unsupported("DiffieHellmanGroup");
|
|
96
|
+
export const X509Certificate = unsupported("X509Certificate");
|
|
97
|
+
export const checkPrime = unsupported("checkPrime");
|
|
98
|
+
export const checkPrimeSync = unsupported("checkPrimeSync");
|
|
99
|
+
export const createDiffieHellman = unsupported("createDiffieHellman");
|
|
100
|
+
export const createDiffieHellmanGroup = unsupported("createDiffieHellmanGroup");
|
|
101
|
+
export const generatePrime = unsupported("generatePrime");
|
|
102
|
+
export const generatePrimeSync = unsupported("generatePrimeSync");
|
|
103
|
+
export const getDiffieHellman = unsupported("getDiffieHellman");
|
|
104
|
+
|
|
105
|
+
export default {
|
|
106
|
+
Certificate, Cipher, Cipheriv, Decipher, Decipheriv, DiffieHellman, DiffieHellmanGroup, ECDH, Hash, Hmac, KeyObject, Sign,
|
|
107
|
+
Verify, X509Certificate, checkPrime, checkPrimeSync, constants, createCipheriv, createDecipheriv, createDiffieHellman,
|
|
108
|
+
createDiffieHellmanGroup, createECDH, createHash, createHmac, createPrivateKey, createPublicKey, createSecretKey, createSign,
|
|
109
|
+
createVerify, diffieHellman, generateKey, generateKeyPair, generateKeyPairSync, generateKeySync, generatePrime,
|
|
110
|
+
generatePrimeSync, getCipherInfo, getCiphers, getCurves, getDiffieHellman, getFips, getHashes, getRandomValues, hash, hkdf,
|
|
111
|
+
hkdfSync, pbkdf2, pbkdf2Sync, privateDecrypt, privateEncrypt, publicDecrypt, publicEncrypt, randomBytes, randomFill,
|
|
112
|
+
randomFillSync, randomInt, randomUUID, scrypt, scryptSync, secureHeapUsed, setEngine, setFips, sign, subtle, timingSafeEqual,
|
|
113
|
+
verify, webcrypto,
|
|
114
|
+
};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
// node:events (ADR 0012, layer 3): EventEmitter, Node's semantics for the common API:
|
|
2
|
+
// listeners in order (prepend first), once wrappers, 'newListener' and 'removeListener', an
|
|
3
|
+
// 'error' with no listener thrown, and the max-listeners warning.
|
|
4
|
+
const kCapture = Symbol("kCapture");
|
|
5
|
+
|
|
6
|
+
function checkListener(listener) {
|
|
7
|
+
if (typeof listener !== "function") {
|
|
8
|
+
const e = new TypeError('The "listener" argument must be of type function. Received ' + describe(listener));
|
|
9
|
+
e.code = "ERR_INVALID_ARG_TYPE";
|
|
10
|
+
throw e;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function describe(v) {
|
|
15
|
+
if (v === null || v === undefined) return String(v);
|
|
16
|
+
if (typeof v === "object") return "an instance of " + (v.constructor && v.constructor.name ? v.constructor.name : "Object");
|
|
17
|
+
return "type " + typeof v + " (" + (typeof v === "string" ? "'" + v + "'" : String(v)) + ")";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function EventEmitter(opts) {
|
|
21
|
+
EventEmitter.init.call(this, opts);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
EventEmitter.prototype._events = undefined;
|
|
25
|
+
EventEmitter.prototype._eventsCount = 0;
|
|
26
|
+
EventEmitter.prototype._maxListeners = undefined;
|
|
27
|
+
|
|
28
|
+
let defaultMaxListeners = 10;
|
|
29
|
+
Object.defineProperty(EventEmitter, "defaultMaxListeners", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get() {
|
|
32
|
+
return defaultMaxListeners;
|
|
33
|
+
},
|
|
34
|
+
set(n) {
|
|
35
|
+
defaultMaxListeners = n;
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
EventEmitter.init = function (opts) {
|
|
40
|
+
if (this._events === undefined || this._events === Object.getPrototypeOf(this)._events) {
|
|
41
|
+
this._events = Object.create(null);
|
|
42
|
+
this._eventsCount = 0;
|
|
43
|
+
}
|
|
44
|
+
this._maxListeners = this._maxListeners || undefined;
|
|
45
|
+
if (opts && opts.captureRejections) this[kCapture] = true;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
EventEmitter.prototype.setMaxListeners = function (n) {
|
|
49
|
+
this._maxListeners = n;
|
|
50
|
+
return this;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
EventEmitter.prototype.getMaxListeners = function () {
|
|
54
|
+
return this._maxListeners === undefined ? defaultMaxListeners : this._maxListeners;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
EventEmitter.prototype.emit = function (type, ...args) {
|
|
58
|
+
const events = this._events;
|
|
59
|
+
if (type === "error" && (events === undefined || events.error === undefined)) {
|
|
60
|
+
const er = args[0];
|
|
61
|
+
if (er instanceof Error) throw er;
|
|
62
|
+
const e = new Error("Unhandled error. (" + String(er) + ")");
|
|
63
|
+
e.code = "ERR_UNHANDLED_ERROR";
|
|
64
|
+
e.context = er;
|
|
65
|
+
throw e;
|
|
66
|
+
}
|
|
67
|
+
if (events === undefined) return false;
|
|
68
|
+
const handler = events[type];
|
|
69
|
+
if (handler === undefined) return false;
|
|
70
|
+
if (typeof handler === "function") {
|
|
71
|
+
handler.apply(this, args);
|
|
72
|
+
} else {
|
|
73
|
+
const listeners = handler.slice();
|
|
74
|
+
for (let i = 0; i < listeners.length; i++) listeners[i].apply(this, args);
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function addListener(target, type, listener, prepend) {
|
|
80
|
+
checkListener(listener);
|
|
81
|
+
let events = target._events;
|
|
82
|
+
if (events === undefined) {
|
|
83
|
+
events = target._events = Object.create(null);
|
|
84
|
+
target._eventsCount = 0;
|
|
85
|
+
} else if (events.newListener !== undefined) {
|
|
86
|
+
target.emit("newListener", type, listener.listener ? listener.listener : listener);
|
|
87
|
+
events = target._events;
|
|
88
|
+
}
|
|
89
|
+
const existing = events[type];
|
|
90
|
+
if (existing === undefined) {
|
|
91
|
+
events[type] = listener;
|
|
92
|
+
target._eventsCount++;
|
|
93
|
+
} else {
|
|
94
|
+
const list = typeof existing === "function" ? (events[type] = prepend ? [listener, existing] : [existing, listener]) : existing;
|
|
95
|
+
if (typeof existing !== "function") {
|
|
96
|
+
if (prepend) list.unshift(listener);
|
|
97
|
+
else list.push(listener);
|
|
98
|
+
}
|
|
99
|
+
const max = target.getMaxListeners();
|
|
100
|
+
if (max > 0 && list.length > max && !list.warned) {
|
|
101
|
+
list.warned = true;
|
|
102
|
+
process.emitWarning(
|
|
103
|
+
"Possible EventEmitter memory leak detected. " + list.length + " " + String(type) + " listeners added to " +
|
|
104
|
+
(target.constructor && target.constructor.name ? "[" + target.constructor.name + "]" : "[EventEmitter]") +
|
|
105
|
+
". MaxListeners is " + max + ". Use emitter.setMaxListeners() to increase limit",
|
|
106
|
+
"MaxListenersExceededWarning",
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return target;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
EventEmitter.prototype.addListener = function (type, listener) {
|
|
114
|
+
return addListener(this, type, listener, false);
|
|
115
|
+
};
|
|
116
|
+
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
117
|
+
EventEmitter.prototype.prependListener = function (type, listener) {
|
|
118
|
+
return addListener(this, type, listener, true);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
function onceWrapper(target, type, listener) {
|
|
122
|
+
const state = { fired: false, target, type, listener };
|
|
123
|
+
function wrapped(...args) {
|
|
124
|
+
if (!state.fired) {
|
|
125
|
+
state.target.removeListener(state.type, wrapped);
|
|
126
|
+
state.fired = true;
|
|
127
|
+
return state.listener.apply(state.target, args);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
wrapped.listener = listener;
|
|
131
|
+
return wrapped;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
EventEmitter.prototype.once = function (type, listener) {
|
|
135
|
+
checkListener(listener);
|
|
136
|
+
this.on(type, onceWrapper(this, type, listener));
|
|
137
|
+
return this;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
EventEmitter.prototype.prependOnceListener = function (type, listener) {
|
|
141
|
+
checkListener(listener);
|
|
142
|
+
this.prependListener(type, onceWrapper(this, type, listener));
|
|
143
|
+
return this;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
EventEmitter.prototype.removeListener = function (type, listener) {
|
|
147
|
+
checkListener(listener);
|
|
148
|
+
const events = this._events;
|
|
149
|
+
if (events === undefined) return this;
|
|
150
|
+
const list = events[type];
|
|
151
|
+
if (list === undefined) return this;
|
|
152
|
+
if (list === listener || list.listener === listener) {
|
|
153
|
+
if (--this._eventsCount === 0) this._events = Object.create(null);
|
|
154
|
+
else delete events[type];
|
|
155
|
+
if (events.removeListener) this.emit("removeListener", type, list.listener || listener);
|
|
156
|
+
} else if (typeof list !== "function") {
|
|
157
|
+
let position = -1;
|
|
158
|
+
for (let i = list.length - 1; i >= 0; i--) {
|
|
159
|
+
if (list[i] === listener || list[i].listener === listener) {
|
|
160
|
+
position = i;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (position < 0) return this;
|
|
165
|
+
list.splice(position, 1);
|
|
166
|
+
if (list.length === 1) events[type] = list[0];
|
|
167
|
+
if (events.removeListener !== undefined) this.emit("removeListener", type, listener);
|
|
168
|
+
}
|
|
169
|
+
return this;
|
|
170
|
+
};
|
|
171
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
172
|
+
|
|
173
|
+
EventEmitter.prototype.removeAllListeners = function (type) {
|
|
174
|
+
const events = this._events;
|
|
175
|
+
if (events === undefined) return this;
|
|
176
|
+
if (arguments.length === 0) {
|
|
177
|
+
this._events = Object.create(null);
|
|
178
|
+
this._eventsCount = 0;
|
|
179
|
+
} else if (events[type] !== undefined) {
|
|
180
|
+
if (--this._eventsCount === 0) this._events = Object.create(null);
|
|
181
|
+
else delete events[type];
|
|
182
|
+
}
|
|
183
|
+
return this;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
function listenersOf(target, type, unwrap) {
|
|
187
|
+
const events = target._events;
|
|
188
|
+
if (events === undefined || events[type] === undefined) return [];
|
|
189
|
+
const l = events[type];
|
|
190
|
+
if (typeof l === "function") return unwrap ? [l.listener || l] : [l];
|
|
191
|
+
return l.map((f) => (unwrap ? f.listener || f : f));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
EventEmitter.prototype.listeners = function (type) {
|
|
195
|
+
return listenersOf(this, type, true);
|
|
196
|
+
};
|
|
197
|
+
EventEmitter.prototype.rawListeners = function (type) {
|
|
198
|
+
return listenersOf(this, type, false);
|
|
199
|
+
};
|
|
200
|
+
EventEmitter.prototype.listenerCount = function (type) {
|
|
201
|
+
const l = this._events !== undefined ? this._events[type] : undefined;
|
|
202
|
+
return l === undefined ? 0 : typeof l === "function" ? 1 : l.length;
|
|
203
|
+
};
|
|
204
|
+
EventEmitter.prototype.eventNames = function () {
|
|
205
|
+
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
209
|
+
|
|
210
|
+
/** events.once(emitter, name): a promise of the next event's arguments. */
|
|
211
|
+
export function once(emitter, name) {
|
|
212
|
+
return new Promise((resolve, reject) => {
|
|
213
|
+
const onError = (err) => {
|
|
214
|
+
emitter.removeListener(name, onEvent);
|
|
215
|
+
reject(err);
|
|
216
|
+
};
|
|
217
|
+
const onEvent = (...args) => {
|
|
218
|
+
if (name !== "error") emitter.removeListener("error", onError);
|
|
219
|
+
resolve(args);
|
|
220
|
+
};
|
|
221
|
+
emitter.once(name, onEvent);
|
|
222
|
+
if (name !== "error") emitter.once("error", onError);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
EventEmitter.once = once;
|
|
226
|
+
|
|
227
|
+
export default EventEmitter;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// node:fs (ADR 0012, layer 3): the synchronous file API, over the host primitives. Contents are
|
|
2
|
+
// Buffers without an encoding, else strings in any of Buffer's encodings.
|
|
3
|
+
import { errnoName, fsExists, fsReadFile, fsUnlink, fsWriteFile } from "visaljs:host";
|
|
4
|
+
import { codeError, invalidArgType, invalidArgValue, notSupported, systemError } from "./internal/errors.js";
|
|
5
|
+
|
|
6
|
+
function validatePath(path) {
|
|
7
|
+
if (typeof path !== "string") {
|
|
8
|
+
if (typeof path === "number") throw notSupported("A file descriptor as a path");
|
|
9
|
+
if (typeof URL === "function" && path instanceof URL) throw notSupported("A file: URL as a path");
|
|
10
|
+
throw invalidArgType("path", "of type string or an instance of Buffer or URL", path);
|
|
11
|
+
}
|
|
12
|
+
if (path.indexOf("\u0000") !== -1) throw invalidArgValue("path", "must be a string without null bytes", path);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function encodingOf(options) {
|
|
16
|
+
if (options == null) return undefined;
|
|
17
|
+
if (typeof options === "string") return options;
|
|
18
|
+
if (typeof options === "object") return options.encoding ?? undefined;
|
|
19
|
+
throw invalidArgType("options", "one of type string or an instance of Object", options);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isUtf8(encoding) {
|
|
23
|
+
return encoding === "utf8" || encoding === "utf-8" || encoding === "UTF8" || encoding === "UTF-8";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function check(result, syscall, path) {
|
|
27
|
+
if (typeof result === "number") throw systemError(result, syscall, path);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function validateEncodingName(encoding) {
|
|
32
|
+
if (encoding !== undefined && encoding !== "buffer" && !Buffer.isEncoding(encoding)) {
|
|
33
|
+
throw codeError(TypeError, "ERR_INVALID_ARG_VALUE", "The argument 'encoding' is invalid encoding. Received '" + encoding + "'");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function readFileSync(path, options) {
|
|
38
|
+
validatePath(path);
|
|
39
|
+
const encoding = encodingOf(options);
|
|
40
|
+
validateEncodingName(encoding);
|
|
41
|
+
const asText = encoding !== undefined && isUtf8(encoding);
|
|
42
|
+
const result = fsReadFile(path, !asText);
|
|
43
|
+
/* opening a directory succeeds; reading it fails: Node reports that read, without a path */
|
|
44
|
+
if (typeof result === "number" && errnoName(result) === "EISDIR") throw systemError(result, "read");
|
|
45
|
+
const contents = check(result, "open", path);
|
|
46
|
+
return asText || encoding === undefined || encoding === "buffer" ? contents : contents.toString(encoding);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function write(path, data, options, append) {
|
|
50
|
+
validatePath(path);
|
|
51
|
+
if (typeof data !== "string" && !ArrayBuffer.isView(data)) {
|
|
52
|
+
throw invalidArgType("data", "of type string or an instance of Buffer, TypedArray, or DataView", data);
|
|
53
|
+
}
|
|
54
|
+
const encoding = encodingOf(options);
|
|
55
|
+
validateEncodingName(encoding);
|
|
56
|
+
if (typeof data === "string" && encoding !== undefined && encoding !== "buffer" && !isUtf8(encoding)) data = Buffer.from(data, encoding);
|
|
57
|
+
const flag = options != null && typeof options === "object" ? options.flag : undefined;
|
|
58
|
+
check(fsWriteFile(path, data, append || flag === "a"), "open", path);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function writeFileSync(path, data, options) {
|
|
62
|
+
write(path, data, options, false);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function appendFileSync(path, data, options) {
|
|
66
|
+
write(path, data, options, true);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function existsSync(path) {
|
|
70
|
+
if (typeof path !== "string" || path.indexOf("\u0000") !== -1) return false;
|
|
71
|
+
return fsExists(path);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function unlinkSync(path) {
|
|
75
|
+
validatePath(path);
|
|
76
|
+
check(fsUnlink(path), "unlink", path);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default { readFileSync, writeFileSync, appendFileSync, existsSync, unlinkSync };
|