visaljs 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -4
- package/THIRD_PARTY_LICENSES +1216 -0
- package/cli.js +4461 -321
- package/node/include/js_node.h +57 -1
- package/node/include/js_uv.h +8 -1
- package/node/prelude/_http_agent.js +5 -0
- package/node/prelude/_http_server.js +7 -0
- package/node/prelude/_stream_duplex.js +4 -0
- package/node/prelude/_stream_passthrough.js +4 -0
- package/node/prelude/_stream_readable.js +4 -0
- package/node/prelude/_stream_transform.js +4 -0
- package/node/prelude/_stream_writable.js +4 -0
- package/node/prelude/assert.js +1334 -0
- package/node/prelude/assert_strict.js +12 -0
- package/node/prelude/async_hooks.js +1 -1
- package/node/prelude/buffer.js +43 -3
- package/node/prelude/child_process.js +1098 -0
- package/node/prelude/cluster.js +52 -0
- package/node/prelude/console.js +328 -0
- package/node/prelude/constants.js +10 -0
- package/node/prelude/crypto.js +1 -1
- package/node/prelude/diagnostics_channel.js +1 -1
- package/node/prelude/dns.js +8 -2
- package/node/prelude/domain.js +115 -0
- package/node/prelude/events.js +148 -16
- package/node/prelude/fs.js +1138 -151
- package/node/prelude/fs_promises.js +117 -11
- package/node/prelude/http.js +784 -301
- package/node/prelude/http2.js +1 -1
- package/node/prelude/https.js +159 -0
- package/node/prelude/inspector.js +27 -0
- package/node/prelude/inspector_promises.js +4 -0
- package/node/prelude/internal/async_context.js +1 -1
- package/node/prelude/internal/buffer_transcode.js +44 -0
- package/node/prelude/internal/comparisons.js +916 -0
- package/node/prelude/internal/compression_streams.js +153 -0
- package/node/prelude/internal/crypto/asym.js +27 -14
- package/node/prelude/internal/crypto/cipher.js +16 -5
- package/node/prelude/internal/crypto/diffiehellman.js +3 -2
- package/node/prelude/internal/crypto/hash.js +2 -1
- package/node/prelude/internal/crypto/kdf.js +14 -9
- package/node/prelude/internal/crypto/keys.js +63 -50
- package/node/prelude/internal/crypto/random.js +2 -1
- package/node/prelude/internal/crypto/util.js +4 -4
- package/node/prelude/internal/dotenv.js +98 -0
- package/node/prelude/internal/errors.js +21 -5
- package/node/prelude/internal/events_extras.js +113 -0
- package/node/prelude/internal/events_on.js +100 -0
- package/node/prelude/internal/features.js +72 -0
- package/node/prelude/internal/fetch.js +364 -0
- package/node/prelude/internal/form_data.js +376 -0
- package/node/prelude/internal/fs_bigint_stats.js +41 -0
- package/node/prelude/internal/fs_blob.js +19 -0
- package/node/prelude/internal/fs_cp.js +709 -0
- package/node/prelude/internal/fs_dir.js +166 -0
- package/node/prelude/internal/fs_filehandle.js +287 -0
- package/node/prelude/internal/fs_glob.js +296 -0
- package/node/prelude/internal/fs_statfs.js +42 -0
- package/node/prelude/internal/fs_stats.js +89 -0
- package/node/prelude/internal/fs_streams.js +541 -0
- package/node/prelude/internal/fs_utils.js +286 -0
- package/node/prelude/internal/fs_watch.js +580 -0
- package/node/prelude/internal/http_agent.js +114 -2
- package/node/prelude/internal/http_symbols.js +3 -0
- package/node/prelude/internal/mime.js +249 -0
- package/node/prelude/internal/net.js +1 -0
- package/node/prelude/internal/net_bound.js +123 -0
- package/node/prelude/internal/net_onread.js +73 -0
- package/node/prelude/internal/net_tos.js +54 -0
- package/node/prelude/internal/parse_args.js +288 -0
- package/node/prelude/internal/perf_histogram.js +435 -0
- package/node/prelude/internal/perf_observe.js +125 -0
- package/node/prelude/internal/performance_global.js +19 -0
- package/node/prelude/internal/process_events.js +49 -1
- package/node/prelude/internal/process_memory.js +14 -0
- package/node/prelude/internal/process_more.js +414 -0
- package/node/prelude/internal/process_signals.js +2 -1
- package/node/prelude/internal/process_stdin.js +52 -0
- package/node/prelude/internal/process_stdio.js +36 -0
- package/node/prelude/internal/querystring.js +0 -0
- package/node/prelude/internal/readline.js +338 -0
- package/node/prelude/internal/socketaddress.js +8 -4
- package/node/prelude/internal/source_map.js +122 -0
- package/node/prelude/internal/stream_compose.js +74 -0
- package/node/prelude/internal/stream_from.js +6 -0
- package/node/prelude/internal/stream_operators.js +23 -0
- package/node/prelude/internal/stream_pipeline.js +7 -0
- package/node/prelude/internal/stream_transform.js +10 -0
- package/node/prelude/internal/stream_web_adapters.js +143 -0
- package/node/prelude/internal/streams/add_abort_signal.js +58 -0
- package/node/prelude/internal/streams/compose.js +244 -0
- package/node/prelude/internal/streams/destroy.js +358 -0
- package/node/prelude/internal/streams/duplex.js +199 -0
- package/node/prelude/internal/streams/duplexify.js +378 -0
- package/node/prelude/internal/streams/end_of_stream.js +387 -0
- package/node/prelude/internal/streams/errors.js +216 -0
- package/node/prelude/internal/streams/from.js +211 -0
- package/node/prelude/internal/streams/legacy.js +120 -0
- package/node/prelude/internal/streams/operators.js +375 -0
- package/node/prelude/internal/streams/passthrough.js +45 -0
- package/node/prelude/internal/streams/pipeline.js +468 -0
- package/node/prelude/internal/streams/readable.js +1835 -0
- package/node/prelude/internal/streams/state.js +48 -0
- package/node/prelude/internal/streams/transform.js +203 -0
- package/node/prelude/internal/streams/utils.js +355 -0
- package/node/prelude/internal/streams/validators.js +108 -0
- package/node/prelude/internal/streams/writable.js +1160 -0
- package/node/prelude/internal/structured_clone.js +238 -0
- package/node/prelude/internal/system_errors.js +37 -0
- package/node/prelude/internal/test_runner/mock.js +431 -0
- package/node/prelude/internal/test_runner/reporters.js +404 -0
- package/node/prelude/internal/test_runner/test.js +1571 -0
- package/node/prelude/internal/timers.js +38 -7
- package/node/prelude/internal/timers_global.js +1 -1
- package/node/prelude/internal/tls/common.js +8 -2
- package/node/prelude/internal/tls/wrap.js +5 -16
- package/node/prelude/internal/tls/x509.js +1 -1
- package/node/prelude/internal/tty_read_stream.js +39 -0
- package/node/prelude/internal/tty_streams.js +3 -0
- package/node/prelude/internal/util_debuglog.js +68 -0
- package/node/prelude/internal/util_diff.js +63 -0
- package/node/prelude/internal/util_more.js +111 -0
- package/node/prelude/internal/util_styles.js +76 -0
- package/node/prelude/internal/zlib_engines.js +1 -1
- package/node/prelude/module.js +219 -8
- package/node/prelude/net.js +197 -49
- package/node/prelude/os.js +88 -11
- package/node/prelude/path.js +11 -7
- package/node/prelude/path_posix.js +1 -1
- package/node/prelude/path_win32.js +1 -1
- package/node/prelude/perf_hooks.js +151 -0
- package/node/prelude/process.js +36 -1
- package/node/prelude/punycode.js +188 -0
- package/node/prelude/querystring.js +1 -1
- package/node/prelude/readline.js +8 -0
- package/node/prelude/readline_promises.js +88 -0
- package/node/prelude/repl.js +38 -0
- package/node/prelude/sea.js +23 -0
- package/node/prelude/stream.js +70 -1332
- package/node/prelude/stream_consumers.js +34 -0
- package/node/prelude/stream_promises.js +1 -1
- package/node/prelude/stream_web.js +15 -2
- package/node/prelude/string_decoder.js +1 -1
- package/node/prelude/sys.js +7 -0
- package/node/prelude/test.js +56 -0
- package/node/prelude/test_reporters.js +269 -0
- package/node/prelude/timers.js +7 -84
- package/node/prelude/timers_promises.js +1 -1
- package/node/prelude/tls.js +2 -1
- package/node/prelude/trace_events.js +52 -0
- package/node/prelude/tty.js +10 -4
- package/node/prelude/url.js +88 -27
- package/node/prelude/util.js +121 -5
- package/node/prelude/util_types.js +4 -3
- package/node/prelude/v8.js +814 -0
- package/node/prelude/vm.js +86 -0
- package/node/prelude/wasi.js +10 -0
- package/node/prelude/worker_threads.js +56 -0
- package/node/prelude/zlib.js +58 -25
- package/node/src/host_brotli.c +59 -11
- package/node/src/host_fs.c +342 -11
- package/node/src/host_fswatch.c +170 -0
- package/node/src/host_http.c +292 -39
- package/node/src/host_loop.c +25 -2
- package/node/src/host_net.c +130 -16
- package/node/src/host_os.c +55 -1
- package/node/src/host_proc.c +291 -0
- package/node/src/host_process.c +488 -0
- package/node/src/host_sys.c +64 -2
- package/node/src/host_zlib.c +27 -7
- package/node/src/host_zstd.c +41 -6
- package/node/third_party/hdrhistogram/LICENSE +42 -0
- package/node/third_party/hdrhistogram/README.md +5 -0
- package/node/third_party/libuv/LICENSE +0 -0
- package/node/third_party/libuv/LICENSE-extra +36 -0
- package/node/third_party/libuv/include/uv/aix.h +0 -0
- package/node/third_party/libuv/include/uv/bsd.h +0 -0
- package/node/third_party/libuv/include/uv/darwin.h +0 -0
- package/node/third_party/libuv/include/uv/errno.h +0 -0
- package/node/third_party/libuv/include/uv/linux.h +0 -0
- package/node/third_party/libuv/include/uv/os390.h +0 -0
- package/node/third_party/libuv/include/uv/posix.h +0 -0
- package/node/third_party/libuv/include/uv/sunos.h +0 -0
- package/node/third_party/libuv/include/uv/threadpool.h +0 -0
- package/node/third_party/libuv/include/uv/tree.h +0 -0
- package/node/third_party/libuv/include/uv/unix.h +0 -0
- package/node/third_party/libuv/include/uv/version.h +0 -0
- package/node/third_party/libuv/include/uv/win.h +0 -0
- package/node/third_party/libuv/include/uv.h +0 -0
- package/node/third_party/libuv/src/fs-poll.c +0 -0
- package/node/third_party/libuv/src/heap-inl.h +0 -0
- package/node/third_party/libuv/src/idna.c +0 -0
- package/node/third_party/libuv/src/idna.h +0 -0
- package/node/third_party/libuv/src/inet.c +0 -0
- package/node/third_party/libuv/src/queue.h +0 -0
- package/node/third_party/libuv/src/random.c +0 -0
- package/node/third_party/libuv/src/strscpy.c +0 -0
- package/node/third_party/libuv/src/strscpy.h +0 -0
- package/node/third_party/libuv/src/strtok.c +0 -0
- package/node/third_party/libuv/src/strtok.h +0 -0
- package/node/third_party/libuv/src/thread-common.c +0 -0
- package/node/third_party/libuv/src/threadpool.c +0 -0
- package/node/third_party/libuv/src/timer.c +0 -0
- package/node/third_party/libuv/src/unix/async.c +0 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
- package/node/third_party/libuv/src/unix/core.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
- package/node/third_party/libuv/src/unix/darwin.c +0 -0
- package/node/third_party/libuv/src/unix/dl.c +0 -0
- package/node/third_party/libuv/src/unix/fs.c +0 -0
- package/node/third_party/libuv/src/unix/fsevents.c +0 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
- package/node/third_party/libuv/src/unix/internal.h +0 -0
- package/node/third_party/libuv/src/unix/kqueue.c +0 -0
- package/node/third_party/libuv/src/unix/linux.c +0 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
- package/node/third_party/libuv/src/unix/loop.c +0 -0
- package/node/third_party/libuv/src/unix/pipe.c +0 -0
- package/node/third_party/libuv/src/unix/poll.c +0 -0
- package/node/third_party/libuv/src/unix/process.c +0 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
- package/node/third_party/libuv/src/unix/proctitle.c +0 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
- package/node/third_party/libuv/src/unix/signal.c +0 -0
- package/node/third_party/libuv/src/unix/stream.c +0 -0
- package/node/third_party/libuv/src/unix/tcp.c +0 -0
- package/node/third_party/libuv/src/unix/thread.c +0 -0
- package/node/third_party/libuv/src/unix/tty.c +0 -0
- package/node/third_party/libuv/src/unix/udp.c +0 -0
- package/node/third_party/libuv/src/uv-common.c +0 -0
- package/node/third_party/libuv/src/uv-common.h +0 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
- package/node/third_party/libuv/src/version.c +0 -0
- package/node/third_party/llhttp/LICENSE +0 -0
- package/node/third_party/llhttp/api.c +0 -0
- package/node/third_party/llhttp/http.c +0 -0
- package/node/third_party/llhttp/llhttp.c +0 -0
- package/node/third_party/llhttp/llhttp.h +0 -0
- package/node/third_party/nodejs/LICENSE +47 -0
- package/node/third_party/nodejs/README.md +5 -0
- package/node/third_party/parseargs/LICENSE +21 -0
- package/node/third_party/parseargs/README.md +5 -0
- package/node/third_party/punycode/LICENSE +20 -0
- package/node/third_party/punycode/README.md +5 -0
- package/node/third_party/zlib/LICENSE.chromium +27 -0
- package/package.json +1 -1
- package/prebuilt/darwin-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/darwin-arm64/brotli-7995bbdacc52e51c.a +0 -0
- package/prebuilt/darwin-arm64/uv-72ab666eae197cd8.a +0 -0
- package/prebuilt/darwin-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/darwin-arm64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/darwin-x64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/darwin-x64/brotli-7995bbdacc52e51c.a +0 -0
- package/prebuilt/darwin-x64/uv-72ab666eae197cd8.a +0 -0
- package/prebuilt/darwin-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/darwin-x64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-arm64/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-arm64/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-arm64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-arm64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-arm64-musl/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-arm64-musl/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-arm64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-arm64-musl/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-x64/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-x64/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-x64/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-x64/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/linux-x64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
- package/prebuilt/linux-x64-musl/brotli-65481ff838ce9def.a +0 -0
- package/prebuilt/linux-x64-musl/uv-f1353f50ff983f3c.a +0 -0
- package/prebuilt/linux-x64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/linux-x64-musl/zstd-015315ac7c784c73.a +0 -0
- package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
- package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
- package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
- package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
- package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
- package/runtime/include/js_atoms.gen.h +0 -0
- package/runtime/include/js_atoms.h +5 -1
- package/runtime/include/js_bigint.h +1 -1
- package/runtime/include/js_buffer.h +4 -4
- package/runtime/include/js_builtins.h +41 -3
- package/runtime/include/js_console.h +9 -4
- package/runtime/include/js_convert.h +1 -1
- package/runtime/include/js_core.def +5 -4
- package/runtime/include/js_crypto.h +1 -1
- package/runtime/include/js_error.h +1 -1
- package/runtime/include/js_exception.h +21 -1
- package/runtime/include/js_function.h +33 -9
- package/runtime/include/js_gc.h +172 -30
- package/runtime/include/js_generator.h +2 -2
- package/runtime/include/js_host.h +19 -1
- package/runtime/include/js_jobs.h +5 -5
- package/runtime/include/js_module.h +1 -1
- package/runtime/include/js_object.h +142 -15
- package/runtime/include/js_ops.h +107 -5
- package/runtime/include/js_promise.h +3 -3
- package/runtime/include/js_regexp.h +1 -1
- package/runtime/include/js_runtime.h +0 -0
- package/runtime/include/js_symbol.h +1 -1
- package/runtime/include/js_web.h +5 -1
- package/runtime/include/jscell.h +22 -15
- package/runtime/include/jscontext.h +82 -39
- package/runtime/include/jsnum.h +1 -1
- package/runtime/include/jsstring.h +19 -6
- package/runtime/include/jsvalue.h +7 -3
- package/runtime/src/arguments.c +2 -2
- package/runtime/src/array.c +4 -1
- package/runtime/src/arraybuffer.c +19 -7
- package/runtime/src/async_iter.c +4 -3
- package/runtime/src/atoms.c +38 -4
- package/runtime/src/base64.c +2 -2
- package/runtime/src/bigint.c +1 -1
- package/runtime/src/blob.c +22 -9
- package/runtime/src/boringssl_support.cc +1 -1
- package/runtime/src/buffer.c +299 -91
- package/runtime/src/builtin_table.c +1 -1
- package/runtime/src/builtins.c +30 -4
- package/runtime/src/builtins_util.h +0 -0
- package/runtime/src/collections.c +18 -3
- package/runtime/src/components.c +1 -1
- package/runtime/src/console.c +14 -7
- package/runtime/src/convert.c +0 -0
- package/runtime/src/core_all.c +1 -1
- package/runtime/src/crypto.c +1 -1
- package/runtime/src/crypto_asym.c +1 -1
- package/runtime/src/crypto_bn.c +1 -1
- package/runtime/src/crypto_cipher.c +10 -3
- package/runtime/src/crypto_hash.c +1 -1
- package/runtime/src/crypto_host.c +1 -1
- package/runtime/src/crypto_internal.h +1 -1
- package/runtime/src/crypto_kdf.c +1 -1
- package/runtime/src/crypto_key.c +14 -1
- package/runtime/src/crypto_pkey.c +1 -1
- package/runtime/src/crypto_subtle.c +142 -58
- package/runtime/src/crypto_tls.c +1 -1
- package/runtime/src/date.c +5 -2
- package/runtime/src/domexception.c +2 -2
- package/runtime/src/elements.c +56 -17
- package/runtime/src/elements.h +7 -2
- package/runtime/src/encoding.c +1 -1
- package/runtime/src/error.c +4 -4
- package/runtime/src/events.c +42 -14
- package/runtime/src/exception.c +1 -1
- package/runtime/src/fetch.c +241 -17
- package/runtime/src/function.c +31 -19
- package/runtime/src/gc.c +1720 -211
- package/runtime/src/gc_visit.h +87 -0
- package/runtime/src/generator.c +5 -3
- package/runtime/src/global.c +14 -6
- package/runtime/src/headers.c +10 -10
- package/runtime/src/inspect.c +76 -17
- package/runtime/src/internal.h +9 -6
- package/runtime/src/iterate.c +94 -2
- package/runtime/src/iterator.c +1 -1
- package/runtime/src/jobs.c +11 -5
- package/runtime/src/jsnum.c +2 -2
- package/runtime/src/json.c +1 -1
- package/runtime/src/math.c +9 -1
- package/runtime/src/module.c +3 -3
- package/runtime/src/number.c +0 -0
- package/runtime/src/object.c +107 -74
- package/runtime/src/ops.c +21 -3
- package/runtime/src/os.c +192 -1
- package/runtime/src/os.h +33 -2
- package/runtime/src/process.c +73 -8
- package/runtime/src/promise.c +4 -4
- package/runtime/src/proxy.c +1 -1
- package/runtime/src/reflect.c +1 -1
- package/runtime/src/regexp.c +700 -11
- package/runtime/src/regexp_anchor.h +1 -1
- package/runtime/src/regexp_message.h +1 -1
- package/runtime/src/shape.c +78 -20
- package/runtime/src/shape.h +0 -0
- package/runtime/src/streams.c +22 -8
- package/runtime/src/streams.h +0 -0
- package/runtime/src/string.c +64 -25
- package/runtime/src/string_builtins.c +7 -7
- package/runtime/src/symbol.c +2 -7
- package/runtime/src/test_host.c +3 -3
- package/runtime/src/tls_roots.gen.h +102 -620
- package/runtime/src/typedarray.c +8 -3
- package/runtime/src/tznames.gen.h +2 -1
- package/runtime/src/uri.c +1 -1
- package/runtime/src/url.c +42 -39
- package/runtime/src/weak.c +110 -36
- package/runtime/src/web.c +21 -3
- package/runtime/src/wrapper.c +0 -0
- package/runtime/src/writable.c +7 -6
- package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
- package/runtime/third_party/ada-idna/README.md +7 -7
- package/runtime/third_party/ada-idna/convert.mjs +89 -27
- package/runtime/third_party/ada-idna/idna.c +30 -31
- package/runtime/third_party/ada-idna/idna.h +0 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2272 -1952
- package/runtime/third_party/boringssl/third_party/fiat/LICENSE +15 -0
- package/runtime/third_party/mozilla-ca/LICENSE +373 -0
- package/runtime/third_party/mozilla-ca/README.md +9 -0
- package/runtime/third_party/nodejs/LICENSE +47 -0
- package/runtime/third_party/nodejs/README.md +7 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
- package/runtime/third_party/quickjs-dtoa/README.md +1 -1
- package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
- package/runtime/third_party/quickjs-regexp/README.md +2 -2
- package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
- package/runtime/third_party/unicode/LICENSE +39 -0
- package/runtime/third_party/unicode/README.md +9 -0
- package/runtime/third_party/v8-ieee754/LICENSE +0 -0
- package/runtime/third_party/v8-ieee754/LICENSE.fdlibm +10 -0
- package/runtime/third_party/v8-ieee754/README.md +3 -2
- package/runtime/third_party/v8-ieee754/convert.py +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
- package/runtime/tools/regexp_compile.c +2 -2
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// CompressionStream and DecompressionStream, as Node's (lib/internal/webstreams/compression.js):
|
|
2
|
+
// a node:zlib stream as a readable and writable pair of web streams. Decompression rejects
|
|
3
|
+
// trailing data (rejectGarbageAfterEnd). Linked into programs that name them (implicitModules in
|
|
4
|
+
// node/index.ts); they are globals and node:stream/web's.
|
|
5
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
6
|
+
import { CompressionStream as CompressionWrapper, DecompressionStream as DecompressionWrapper } from "../stream_web.js";
|
|
7
|
+
import { createBrotliCompress, createBrotliDecompress, createDeflate, createDeflateRaw, createGunzip, createGzip, createInflate,
|
|
8
|
+
createInflateRaw } from "../zlib.js";
|
|
9
|
+
import { codeError, invalidArgType } from "./errors.js";
|
|
10
|
+
import { provideClass } from "./features.js";
|
|
11
|
+
|
|
12
|
+
const kInspect = Symbol.for("nodejs.util.inspect.custom");
|
|
13
|
+
const FORMATS = new Set(["deflate", "deflate-raw", "gzip", "brotli"]);
|
|
14
|
+
|
|
15
|
+
/** webidl's CompressionFormat enum */
|
|
16
|
+
function format(value, constructor) {
|
|
17
|
+
const s = String(value);
|
|
18
|
+
if (!FORMATS.has(s)) {
|
|
19
|
+
throw codeError(TypeError, "ERR_INVALID_ARG_VALUE",
|
|
20
|
+
`Failed to construct '${constructor}': 1st argument '${s}' is not a valid enum value of type CompressionFormat.`);
|
|
21
|
+
}
|
|
22
|
+
return s;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** newReadableWritablePairFromDuplex: the duplex's output as a ReadableStream, its input as a
|
|
26
|
+
* WritableStream; an error of either side errors both */
|
|
27
|
+
function pairFromDuplex(duplex) {
|
|
28
|
+
let readableController, writableController;
|
|
29
|
+
let closed = false;
|
|
30
|
+
const onError = (error) => {
|
|
31
|
+
if (closed) return;
|
|
32
|
+
closed = true;
|
|
33
|
+
readableController.error(error);
|
|
34
|
+
writableController.error(error);
|
|
35
|
+
};
|
|
36
|
+
duplex.on("error", onError);
|
|
37
|
+
const readable = new ReadableStream({
|
|
38
|
+
start(controller) {
|
|
39
|
+
readableController = controller;
|
|
40
|
+
duplex.on("data", (chunk) => {
|
|
41
|
+
controller.enqueue(new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength));
|
|
42
|
+
if (controller.desiredSize <= 0) duplex.pause();
|
|
43
|
+
});
|
|
44
|
+
duplex.on("end", () => {
|
|
45
|
+
if (closed) return;
|
|
46
|
+
closed = true;
|
|
47
|
+
controller.close();
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
pull() {
|
|
51
|
+
duplex.resume();
|
|
52
|
+
},
|
|
53
|
+
cancel(reason) {
|
|
54
|
+
duplex.destroy(reason);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const writable = new WritableStream({
|
|
58
|
+
start(controller) {
|
|
59
|
+
writableController = controller;
|
|
60
|
+
},
|
|
61
|
+
write(chunk) {
|
|
62
|
+
/* a BufferSource, not backed by a SharedArrayBuffer */
|
|
63
|
+
if (typeof SharedArrayBuffer === "function" && (ArrayBuffer.isView(chunk) ? chunk.buffer : chunk) instanceof SharedArrayBuffer) {
|
|
64
|
+
throw invalidArgType("chunk", "an instance of ArrayBuffer, Buffer, TypedArray, or DataView", chunk);
|
|
65
|
+
}
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
try {
|
|
68
|
+
if (duplex.write(chunk)) resolve();
|
|
69
|
+
else duplex.once("drain", resolve);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
duplex.destroy(error);
|
|
72
|
+
reject(error);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
close() {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
duplex.once("finish", resolve);
|
|
79
|
+
duplex.once("error", reject);
|
|
80
|
+
duplex.end();
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
abort(reason) {
|
|
84
|
+
duplex.destroy(reason);
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
return { readable, writable };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function inspectAs(name, self, depth, options, inspect) {
|
|
91
|
+
if (depth < 0) return self;
|
|
92
|
+
const opts = { ...options, depth: options.depth == null ? null : options.depth - 1 };
|
|
93
|
+
return `${name} ${inspect({ readable: self.readable, writable: self.writable }, opts)}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
class CompressionStream {
|
|
97
|
+
#transform;
|
|
98
|
+
|
|
99
|
+
constructor(kind) {
|
|
100
|
+
kind = format(kind, "CompressionStream");
|
|
101
|
+
const handle = kind === "deflate" ? createDeflate() : kind === "deflate-raw" ? createDeflateRaw() : kind === "gzip" ? createGzip()
|
|
102
|
+
: createBrotliCompress();
|
|
103
|
+
this.#transform = pairFromDuplex(handle);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get readable() {
|
|
107
|
+
return this.#transform.readable;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get writable() {
|
|
111
|
+
return this.#transform.writable;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
[kInspect](depth, options, inspect) {
|
|
115
|
+
return inspectAs("CompressionStream", this, depth, options, inspect);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
class DecompressionStream {
|
|
120
|
+
#transform;
|
|
121
|
+
|
|
122
|
+
constructor(kind) {
|
|
123
|
+
kind = format(kind, "DecompressionStream");
|
|
124
|
+
const options = { rejectGarbageAfterEnd: true };
|
|
125
|
+
const handle = kind === "deflate" ? createInflate(options) : kind === "deflate-raw" ? createInflateRaw(options)
|
|
126
|
+
: kind === "gzip" ? createGunzip(options) : createBrotliDecompress(options);
|
|
127
|
+
this.#transform = pairFromDuplex(handle);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get readable() {
|
|
131
|
+
return this.#transform.readable;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get writable() {
|
|
135
|
+
return this.#transform.writable;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
[kInspect](depth, options, inspect) {
|
|
139
|
+
return inspectAs("DecompressionStream", this, depth, options, inspect);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
for (const [Class, name] of [[CompressionStream, "CompressionStream"], [DecompressionStream, "DecompressionStream"]]) {
|
|
144
|
+
Object.defineProperties(Class.prototype, {
|
|
145
|
+
readable: { enumerable: true },
|
|
146
|
+
writable: { enumerable: true },
|
|
147
|
+
[Symbol.toStringTag]: { configurable: true, value: name },
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
provideClass(CompressionWrapper, CompressionStream);
|
|
151
|
+
provideClass(DecompressionWrapper, DecompressionStream);
|
|
152
|
+
Object.defineProperty(globalThis, "CompressionStream", { value: CompressionWrapper, writable: true, enumerable: false, configurable: true });
|
|
153
|
+
Object.defineProperty(globalThis, "DecompressionStream", { value: DecompressionWrapper, writable: true, enumerable: false, configurable: true });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
// node:crypto's asymmetric operations
|
|
1
|
+
// node:crypto's asymmetric operations: Sign and Verify (Writable streams, as Node's),
|
|
2
2
|
// sign and verify, publicEncrypt, privateDecrypt, privateEncrypt and publicDecrypt, ECDH,
|
|
3
3
|
// diffieHellman and getCurves: Node's lib/internal/crypto/{sig,cipher,diffiehellman}.js over the
|
|
4
4
|
// runtime's C (crypto_asym.c), which signs digests: the hashing is the Hash primitives'.
|
|
5
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
5
6
|
import {
|
|
6
7
|
cryptoDigestFinal, cryptoDigestUpdate, cryptoEcdh, cryptoEcPoint, cryptoEcPrivate, cryptoHashNew, cryptoKeyGenerate, cryptoKeyParts,
|
|
7
8
|
cryptoRsaCrypt, cryptoSign, cryptoSignMessage, cryptoVerify, cryptoVerifyMessage,
|
|
@@ -211,7 +212,9 @@ export function verify(algorithm, data, key, signature, callback) {
|
|
|
211
212
|
getIntOption("padding", key);
|
|
212
213
|
getIntOption("saltLength", key);
|
|
213
214
|
getDSASignatureEncoding(key);
|
|
214
|
-
|
|
215
|
+
/* Node 24: as the data, a string's UTF-8 bytes too */
|
|
216
|
+
signature = bytesOf(signature, "signature");
|
|
217
|
+
if (isAnyArrayBuffer(signature)) signature = new Uint8Array(signature);
|
|
215
218
|
const handle = preparePublicOrPrivateKey(key);
|
|
216
219
|
const run = signsMessages(handle) ? () => verifyMessage(handle, algorithm, data, signature) : () => {
|
|
217
220
|
const hash = hashFor(algorithm, handle);
|
|
@@ -338,23 +341,33 @@ export function createECDH(curve) {
|
|
|
338
341
|
|
|
339
342
|
/* ---- diffieHellman ----------------------------------------------------------------------------- */
|
|
340
343
|
|
|
341
|
-
|
|
342
|
-
|
|
344
|
+
/** The two keys' types must match, and be ones Diffie-Hellman takes. */
|
|
345
|
+
function dhKeyTypes(privateHandle, publicHandle) {
|
|
346
|
+
const privateType = asymmetricKeyTypeOf(privateHandle);
|
|
347
|
+
const publicType = asymmetricKeyTypeOf(publicHandle);
|
|
348
|
+
if (privateType !== publicType || (privateType !== "ec" && privateType !== "x25519" && privateType !== "dh")) {
|
|
349
|
+
throw codeError(Error, "ERR_CRYPTO_INCOMPATIBLE_KEY", `Incompatible key types for Diffie-Hellman: ${privateType} and ${publicType}`);
|
|
350
|
+
}
|
|
351
|
+
return privateType;
|
|
352
|
+
}
|
|
343
353
|
|
|
354
|
+
/* Node 24's: KeyObjects, or key material (PEM, DER, JWK) as createPrivateKey and createPublicKey
|
|
355
|
+
take it */
|
|
344
356
|
export function diffieHellman(options) {
|
|
345
357
|
validateObject(options, "options");
|
|
346
358
|
const { privateKey, publicKey } = options;
|
|
347
|
-
if (
|
|
348
|
-
if (
|
|
349
|
-
|
|
350
|
-
if (
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
if (privateType !== publicType || (privateType !== "ec" && privateType !== "x25519" && privateType !== "dh")) {
|
|
354
|
-
throw codeError(Error, "ERR_CRYPTO_INCOMPATIBLE_KEY", `Incompatible key types for Diffie-Hellman: ${privateType} and ${publicType}`);
|
|
359
|
+
if (privateKey === undefined) throw invalidArgValue("options.privateKey", "is invalid", privateKey);
|
|
360
|
+
if (publicKey === undefined) throw invalidArgValue("options.publicKey", "is invalid", publicKey);
|
|
361
|
+
/* two KeyObjects of usable types: their key types are checked first */
|
|
362
|
+
if (privateKey instanceof KeyObject && privateKey.type === "private" &&
|
|
363
|
+
publicKey instanceof KeyObject && (publicKey.type === "public" || publicKey.type === "private")) {
|
|
364
|
+
dhKeyTypes(privateKey[kHandle], publicKey[kHandle]);
|
|
355
365
|
}
|
|
356
|
-
|
|
357
|
-
const
|
|
366
|
+
const publicHandle = preparePublicOrPrivateKey(publicKey);
|
|
367
|
+
const privateHandle = preparePrivateKey(privateKey);
|
|
368
|
+
const type = dhKeyTypes(privateHandle, publicHandle);
|
|
369
|
+
if (type === "dh") return dhStateless(cryptoKeyParts(privateHandle), cryptoKeyParts(publicHandle));
|
|
370
|
+
const ret = cryptoEcdh(privateHandle, publicHandle);
|
|
358
371
|
if (typeof ret === "number") throw asymError(9);
|
|
359
372
|
return ret;
|
|
360
373
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
// node:crypto's ciphers
|
|
1
|
+
// node:crypto's ciphers: Cipheriv and Decipheriv (lazy Transform streams, as Node's),
|
|
2
2
|
// getCiphers and getCipherInfo, Node's lib/internal/crypto/cipher.js over the runtime's C cipher
|
|
3
3
|
// context. Output encodings go through a StringDecoder, so a multi-byte character or a base64
|
|
4
4
|
// group isn't split between update and final.
|
|
5
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
5
6
|
import {
|
|
6
7
|
cryptoCipherFinal, cryptoCipherGetAuthTag, cryptoCipherInfo, cryptoCipherNew, cryptoCiphers, cryptoCipherSetAAD,
|
|
7
8
|
cryptoCipherSetAuthTag, cryptoCipherSetPadding, cryptoCipherUpdate,
|
|
@@ -55,15 +56,18 @@ function bytesOf(value, name, encoding) {
|
|
|
55
56
|
throw invalidArgType(name, "of type string or an instance of ArrayBuffer, Buffer, TypedArray, or DataView", value);
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
/* Node 24's: an unknown encoding is ERR_UNKNOWN_ENCODING (StringDecoder's), a different one than
|
|
60
|
+
the first output's ERR_INVALID_ARG_VALUE */
|
|
58
61
|
function getDecoder(decoder, encoding) {
|
|
62
|
+
const normalized = new StringDecoder(encoding).encoding;
|
|
59
63
|
decoder ||= new StringDecoder(encoding);
|
|
60
|
-
if (decoder.encoding !==
|
|
61
|
-
throw codeError(Error, "ERR_INTERNAL_ASSERTION", "Cannot change encoding\nThis is caused by either a bug in Node.js or incorrect " +
|
|
62
|
-
"usage of Node.js internals.\nPlease open an issue with this stack trace at https://github.com/nodejs/node/issues\n");
|
|
63
|
-
}
|
|
64
|
+
if (decoder.encoding !== normalized) throw invalidArgValue("outputEncoding", `cannot be changed from '${decoder.encoding}'`, encoding);
|
|
64
65
|
return decoder;
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
const kGcmAnyTag = Symbol("kGcmAnyTag");
|
|
69
|
+
let warnedShortTag = false;
|
|
70
|
+
|
|
67
71
|
function createCipherWithIV(self, cipher, key, options, encrypt, iv) {
|
|
68
72
|
validateString(cipher, "cipher");
|
|
69
73
|
const encoding = getStringOption(options, "encoding");
|
|
@@ -73,6 +77,8 @@ function createCipherWithIV(self, cipher, key, options, encrypt, iv) {
|
|
|
73
77
|
const handle = cryptoCipherNew(cipher, encrypt, key, iv, authTagLength);
|
|
74
78
|
if (typeof handle === "number") throw cipherError(handle, cipher, authTagLength);
|
|
75
79
|
self[kHandle] = handle;
|
|
80
|
+
/* GCM without authTagLength: a short tag on decryption is deprecated (DEP0182) */
|
|
81
|
+
self[kGcmAnyTag] = /-gcm$/i.test(cipher) && authTagLength === -1;
|
|
76
82
|
self._decoder = null;
|
|
77
83
|
LazyTransform.call(self, options);
|
|
78
84
|
}
|
|
@@ -155,6 +161,11 @@ Decipheriv.prototype.setAuthTag = function setAuthTag(tagbuf, encoding) {
|
|
|
155
161
|
const code = cryptoCipherSetAuthTag(this[kHandle], tagbuf);
|
|
156
162
|
if (code === 5) throw invalidState("setAuthTag");
|
|
157
163
|
if (code !== 0) throw cipherError(code, undefined, tagbuf.byteLength);
|
|
164
|
+
if (this[kGcmAnyTag] && tagbuf.byteLength !== 16 && !warnedShortTag) {
|
|
165
|
+
warnedShortTag = true; /* once a process, as Node's */
|
|
166
|
+
process.emitWarning("Using AES-GCM authentication tags of less than 128 bits without specifying the authTagLength option " +
|
|
167
|
+
"when initializing decryption is deprecated.", "DeprecationWarning", "DEP0182");
|
|
168
|
+
}
|
|
158
169
|
return this;
|
|
159
170
|
};
|
|
160
171
|
Decipheriv.prototype.setAAD = setAAD;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
// node:crypto's finite-field Diffie-Hellman and primes
|
|
1
|
+
// node:crypto's finite-field Diffie-Hellman and primes: DiffieHellman, DiffieHellmanGroup,
|
|
2
2
|
// createDiffieHellman, getDiffieHellman (createDiffieHellmanGroup), generatePrime(Sync) and
|
|
3
3
|
// checkPrime(Sync), as Node's lib/internal/crypto/{diffiehellman,random}.js have them, over the
|
|
4
4
|
// runtime's big integers (crypto_bn.c: modular exponentiation, prime generation and testing).
|
|
5
5
|
// What OpenSSL decides beneath Node's API is OpenSSL's here too: the private key lengths of the
|
|
6
6
|
// MODP groups, DH_check's flags (verifyError), the public key checks of computeSecret.
|
|
7
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
7
8
|
import { cryptoCheckPrime, cryptoGeneratePrime, cryptoModExp, cryptoRandomFill } from "visaljs:host";
|
|
8
9
|
import { codeError, invalidArgType, outOfRange, validateFunction } from "../errors.js";
|
|
9
10
|
import { DH_GROUPS } from "./dh_groups.js";
|
|
@@ -157,7 +158,7 @@ function checkPeer(state, key) {
|
|
|
157
158
|
const pub = toBig(key);
|
|
158
159
|
const p = toBig(state.p);
|
|
159
160
|
if (pub <= 1n) throw codeError(RangeError, "ERR_CRYPTO_INVALID_KEYLEN", "Supplied key is too small");
|
|
160
|
-
if (pub >= p - 1n) throw codeError(RangeError, "
|
|
161
|
+
if (pub >= p - 1n) throw codeError(RangeError, "ERR_CRYPTO_INVALID_KEYLEN", "Supplied key is too large"); /* Node 24 (OpenSSL 3.5) */
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
function dhComputeSecret(key, inEnc, outEnc) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
// node:crypto's Hash and Hmac, and crypto.hash()
|
|
1
|
+
// node:crypto's Hash and Hmac, and crypto.hash(): Node's lib/internal/crypto/hash.js
|
|
2
2
|
// over the host primitives, which hash in C (BoringSSL, and SHA-3 of our own).
|
|
3
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
3
4
|
import {
|
|
4
5
|
cryptoDigestFinal, cryptoDigestUpdate, cryptoHashCopy, cryptoHashes, cryptoHashInfo, cryptoHashNew, cryptoHmacNew,
|
|
5
6
|
} from "visaljs:host";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// node:crypto's key derivation
|
|
1
|
+
// node:crypto's key derivation: pbkdf2, hkdf and scrypt, Node's
|
|
2
2
|
// lib/internal/crypto/{pbkdf2,hkdf,scrypt}.js over the runtime's C. The asynchronous forms
|
|
3
3
|
// derive at the call and call back from a timer, where Node's thread pool would.
|
|
4
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
4
5
|
import { cryptoHashInfo, cryptoHkdf, cryptoPbkdf2, cryptoScrypt, cryptoScryptCheck } from "visaljs:host";
|
|
5
6
|
import { codeError, invalidArgType, outOfRange, validateFunction, validateString } from "../errors.js";
|
|
6
7
|
import { KeyObject, prepareSecretKey } from "./keys.js";
|
|
@@ -8,6 +9,9 @@ import { isAnyArrayBuffer, isArrayBufferView, validateNumber } from "./util.js";
|
|
|
8
9
|
|
|
9
10
|
const later = (fn) => setTimeout(fn, 0);
|
|
10
11
|
const derivingFailed = () => new Error("Deriving bits failed");
|
|
12
|
+
/* PBKDF2 and HKDF over SHAKE: OpenSSL 3.5 refuses an extendable-output function, with this error */
|
|
13
|
+
const isXof = (digest) => typeof digest === "string" && /^shake(128|256)$/i.test(digest);
|
|
14
|
+
const kdfFailed = (digest) => (isXof(digest) ? new Error("error:1C8000B7:Provider routines::xof digests not allowed") : derivingFailed());
|
|
11
15
|
const invalidDigest = (digest) => codeError(TypeError, "ERR_CRYPTO_INVALID_DIGEST", "Invalid digest: " + digest);
|
|
12
16
|
|
|
13
17
|
function validateIntegerIn(value, name, min, max) {
|
|
@@ -40,7 +44,7 @@ function checkPbkdf2(password, salt, iterations, keylen, digest) {
|
|
|
40
44
|
function runPbkdf2({ password, salt, iterations, keylen, digest }) {
|
|
41
45
|
const result = cryptoPbkdf2(digest, password, salt, iterations, keylen);
|
|
42
46
|
if (result === null) throw invalidDigest(digest);
|
|
43
|
-
if (result === false) throw
|
|
47
|
+
if (result === false) throw kdfFailed(digest);
|
|
44
48
|
return result;
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -57,7 +61,7 @@ export function pbkdf2(password, salt, iterations, keylen, digest, callback) {
|
|
|
57
61
|
validateFunction(callback, "callback");
|
|
58
62
|
const result = cryptoPbkdf2(digest, args.password, args.salt, iterations, keylen);
|
|
59
63
|
if (result === null) throw invalidDigest(digest);
|
|
60
|
-
later(() => (result === false ? callback(
|
|
64
|
+
later(() => (result === false ? callback(kdfFailed(digest)) : callback(null, result)));
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
/* ---- HKDF -------------------------------------------------------------------------------------- */
|
|
@@ -91,7 +95,7 @@ function runHkdf({ hash, key, salt, info, length }) {
|
|
|
91
95
|
|
|
92
96
|
export function hkdfSync(hash, key, salt, info, length) {
|
|
93
97
|
const result = runHkdf(checkHkdf(hash, key, salt, info, length));
|
|
94
|
-
if (result === false) throw
|
|
98
|
+
if (result === false) throw kdfFailed(hash);
|
|
95
99
|
return result;
|
|
96
100
|
}
|
|
97
101
|
|
|
@@ -99,13 +103,14 @@ export function hkdf(hash, key, salt, info, length, callback) {
|
|
|
99
103
|
const args = checkHkdf(hash, key, salt, info, length);
|
|
100
104
|
validateFunction(callback, "callback");
|
|
101
105
|
const result = runHkdf(args);
|
|
102
|
-
later(() => (result === false ? callback(
|
|
106
|
+
later(() => (result === false ? callback(kdfFailed(hash)) : callback(null, result)));
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
/* ---- scrypt ------------------------------------------------------------------------------------ */
|
|
106
110
|
|
|
107
111
|
const defaults = { N: 16384, r: 8, p: 1, maxmem: 32 << 20 };
|
|
108
|
-
|
|
112
|
+
/* Node 24: an option given under both its names */
|
|
113
|
+
const optionPair = (a, b) => codeError(TypeError, "ERR_INCOMPATIBLE_OPTION_PAIR", `Option "${a}" cannot be used in combination with option "${b}"`);
|
|
109
114
|
|
|
110
115
|
function checkScrypt(password, salt, keylen, options) {
|
|
111
116
|
password = bytesOf(password, "password");
|
|
@@ -119,7 +124,7 @@ function checkScrypt(password, salt, keylen, options) {
|
|
|
119
124
|
validateUint32(N, "N");
|
|
120
125
|
}
|
|
121
126
|
if (options.cost !== undefined) {
|
|
122
|
-
if (hasN) throw
|
|
127
|
+
if (hasN) throw optionPair("N", "cost");
|
|
123
128
|
N = options.cost;
|
|
124
129
|
validateUint32(N, "cost");
|
|
125
130
|
}
|
|
@@ -129,7 +134,7 @@ function checkScrypt(password, salt, keylen, options) {
|
|
|
129
134
|
validateUint32(r, "r");
|
|
130
135
|
}
|
|
131
136
|
if (options.blockSize !== undefined) {
|
|
132
|
-
if (hasR) throw
|
|
137
|
+
if (hasR) throw optionPair("r", "blockSize");
|
|
133
138
|
r = options.blockSize;
|
|
134
139
|
validateUint32(r, "blockSize");
|
|
135
140
|
}
|
|
@@ -139,7 +144,7 @@ function checkScrypt(password, salt, keylen, options) {
|
|
|
139
144
|
validateUint32(p, "p");
|
|
140
145
|
}
|
|
141
146
|
if (options.parallelization !== undefined) {
|
|
142
|
-
if (hasP) throw
|
|
147
|
+
if (hasP) throw optionPair("p", "parallelization");
|
|
143
148
|
p = options.parallelization;
|
|
144
149
|
validateUint32(p, "parallelization");
|
|
145
150
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
// node:crypto's keys
|
|
2
|
-
// defines them (
|
|
1
|
+
// node:crypto's keys: KeyObject and its subclasses, as Node 24's lib/internal/crypto/keys.js
|
|
2
|
+
// defines them (their slots hidden, so they inspect as {} as Node's do), over the runtime's key handles,
|
|
3
3
|
// which CryptoKey shares. PEM (base64 and its labels) and JWK (base64url and its members) are
|
|
4
4
|
// here; DER is the runtime's.
|
|
5
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
5
6
|
import {
|
|
6
7
|
cryptoHashInfo, cryptoKeyEquals, cryptoRandomFill, cryptoKeyExport, cryptoKeyFromParts, cryptoKeyGenerate, cryptoKeyHandleOf, cryptoKeyInfo,
|
|
7
8
|
cryptoKeyParse, cryptoKeyParts, cryptoKeyPublic, cryptoKeySecret, cryptoKeySecretBytes, cryptoToCryptoKey,
|
|
@@ -15,6 +16,11 @@ const kAsymmetricKeyType = Symbol("kAsymmetricKeyType");
|
|
|
15
16
|
const kAsymmetricKeyDetails = Symbol("kAsymmetricKeyDetails");
|
|
16
17
|
|
|
17
18
|
const later = (fn) => setTimeout(fn, 0);
|
|
19
|
+
/* a slot of the key's: not enumerable, as Node 24's private fields aren't seen */
|
|
20
|
+
const slot = (o, key, value) => {
|
|
21
|
+
Object.defineProperty(o, key, { value, enumerable: false, configurable: false, writable: false });
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
18
24
|
const isStringOrBuffer = (v) => typeof v === "string" || isArrayBufferView(v) || isAnyArrayBuffer(v);
|
|
19
25
|
|
|
20
26
|
/* ---- errors ------------------------------------------------------------------------------------ */
|
|
@@ -23,7 +29,7 @@ const keyObjectType = (actual, expected) =>
|
|
|
23
29
|
codeError(TypeError, "ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE", `Invalid key object type ${actual}, expected ${expected}.`);
|
|
24
30
|
const incompatible = (encoding, why) =>
|
|
25
31
|
codeError(Error, "ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS", `The selected key encoding ${encoding} ${why}.`);
|
|
26
|
-
const invalidJwk = () => codeError(TypeError, "ERR_CRYPTO_INVALID_JWK",
|
|
32
|
+
const invalidJwk = (message = "Invalid JWK data") => codeError(TypeError, "ERR_CRYPTO_INVALID_JWK", message);
|
|
27
33
|
|
|
28
34
|
/* the runtime's error codes for a key it couldn't decode or encode */
|
|
29
35
|
function keyError(code) {
|
|
@@ -97,14 +103,21 @@ export class KeyObject {
|
|
|
97
103
|
constructor(type, handle) {
|
|
98
104
|
if (type !== "secret" && type !== "public" && type !== "private") throw invalidArgValue("type", "is invalid", type);
|
|
99
105
|
if (typeof handle !== "object" || handle === null || !isKeyHandle(handle)) throw invalidArgType("handle", "of type object", handle);
|
|
100
|
-
this
|
|
101
|
-
|
|
106
|
+
slot(this, kKeyType, type);
|
|
107
|
+
slot(this, kHandle, handle);
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
get type() {
|
|
105
111
|
return this[kKeyType];
|
|
106
112
|
}
|
|
107
113
|
|
|
114
|
+
/* Node 24: on KeyObject, for every type */
|
|
115
|
+
toCryptoKey(algorithm, extractable, keyUsages) {
|
|
116
|
+
if (this.type === "secret") return cryptoToCryptoKey("raw", cryptoKeySecretBytes(this[kHandle]), algorithm, extractable, keyUsages);
|
|
117
|
+
const der = cryptoKeyExport(this[kHandle], this.type === "public" ? 0 : 2);
|
|
118
|
+
return cryptoToCryptoKey(this.type === "public" ? "spki" : "pkcs8", der, algorithm, extractable, keyUsages);
|
|
119
|
+
}
|
|
120
|
+
|
|
108
121
|
static from(key) {
|
|
109
122
|
const handle = cryptoKeyHandleOf(key);
|
|
110
123
|
if (handle === undefined) throw invalidArgType("key", "an instance of CryptoKey", key);
|
|
@@ -134,10 +147,6 @@ class SecretKeyObject extends KeyObject {
|
|
|
134
147
|
}
|
|
135
148
|
return cryptoKeySecretBytes(this[kHandle]);
|
|
136
149
|
}
|
|
137
|
-
|
|
138
|
-
toCryptoKey(algorithm, extractable, keyUsages) {
|
|
139
|
-
return cryptoToCryptoKey("raw", cryptoKeySecretBytes(this[kHandle]), algorithm, extractable, keyUsages);
|
|
140
|
-
}
|
|
141
150
|
}
|
|
142
151
|
|
|
143
152
|
/* asymmetricKeyDetails: Node's normalized form of the key's details */
|
|
@@ -168,7 +177,7 @@ function keyDetails(handle) {
|
|
|
168
177
|
|
|
169
178
|
class AsymmetricKeyObject extends KeyObject {
|
|
170
179
|
get asymmetricKeyType() {
|
|
171
|
-
return this[kAsymmetricKeyType]
|
|
180
|
+
return this[kAsymmetricKeyType] ?? slot(this, kAsymmetricKeyType, cryptoKeyInfo(this[kHandle])[1]);
|
|
172
181
|
}
|
|
173
182
|
|
|
174
183
|
get asymmetricKeyDetails() {
|
|
@@ -177,16 +186,12 @@ class AsymmetricKeyObject extends KeyObject {
|
|
|
177
186
|
case "rsa-pss":
|
|
178
187
|
case "ec":
|
|
179
188
|
case "dsa":
|
|
180
|
-
return this[kAsymmetricKeyDetails]
|
|
189
|
+
return { ...(this[kAsymmetricKeyDetails] ?? slot(this, kAsymmetricKeyDetails, keyDetails(this[kHandle]))) };
|
|
181
190
|
default:
|
|
182
191
|
return {};
|
|
183
192
|
}
|
|
184
193
|
}
|
|
185
194
|
|
|
186
|
-
toCryptoKey(algorithm, extractable, keyUsages) {
|
|
187
|
-
const der = cryptoKeyExport(this[kHandle], this.type === "public" ? 0 : 2);
|
|
188
|
-
return cryptoToCryptoKey(this.type === "public" ? "spki" : "pkcs8", der, algorithm, extractable, keyUsages);
|
|
189
|
-
}
|
|
190
195
|
}
|
|
191
196
|
|
|
192
197
|
class PublicKeyObject extends AsymmetricKeyObject {
|
|
@@ -231,8 +236,9 @@ function wrapHandle(handle) {
|
|
|
231
236
|
const SPKI = 0, PKCS1 = 1, PKCS8 = 2, SEC1 = 3, CERT = 4;
|
|
232
237
|
const ENCODING_NAMES = { pkcs1: PKCS1, spki: SPKI, pkcs8: PKCS8, sec1: SEC1 };
|
|
233
238
|
|
|
234
|
-
|
|
235
|
-
|
|
239
|
+
/* an option's name in messages: options.format, or under a prefix (Node 24's), key.format */
|
|
240
|
+
function option(name, prefix) {
|
|
241
|
+
return prefix === undefined ? `options.${name}` : `${prefix}.${name}`;
|
|
236
242
|
}
|
|
237
243
|
|
|
238
244
|
function parseKeyFormat(formatStr, defaultFormat, optionName) {
|
|
@@ -347,50 +353,56 @@ function exportJwk(handle, isPrivate) {
|
|
|
347
353
|
throw codeError(Error, "ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE", "Unsupported JWK Key Type.");
|
|
348
354
|
}
|
|
349
355
|
|
|
350
|
-
function fromParts(kind, isPrivate, crv, parts) {
|
|
356
|
+
function fromParts(kind, isPrivate, crv, parts, message = "Invalid JWK data") {
|
|
351
357
|
const handle = cryptoKeyFromParts(kind, isPrivate, crv, parts);
|
|
352
|
-
if (typeof handle === "number") throw handle === 3 ? notSupported("This curve") : invalidJwk();
|
|
358
|
+
if (typeof handle === "number") throw handle === 3 ? notSupported("This curve") : invalidJwk(message);
|
|
353
359
|
return handle;
|
|
354
360
|
}
|
|
355
361
|
|
|
362
|
+
/* A JWK's key, checked as Node 24's native import checks it: one of its messages for each
|
|
363
|
+
failure. A JWK with "d" is a private key's, whichever is wanted. */
|
|
356
364
|
function keyFromJwk(key, isPublic) {
|
|
365
|
+
const handle = jwkHandle(key, isPublic);
|
|
366
|
+
/* a private JWK where a public key is wanted: its public half */
|
|
367
|
+
return isPublic && key.d !== undefined ? cryptoKeyPublic(handle) : handle;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function jwkHandle(key, isPublic) {
|
|
357
371
|
validateObject(key, "key");
|
|
358
|
-
|
|
372
|
+
if (typeof key.kty !== "string") throw invalidJwk("Invalid JWK format");
|
|
359
373
|
const b64 = (s) => Buffer.from(s, "base64");
|
|
374
|
+
const str = (v) => typeof v === "string";
|
|
375
|
+
const isPrivate = key.d !== undefined;
|
|
376
|
+
const noPrivate = () => invalidJwk("JWK does not contain private key material");
|
|
360
377
|
if (key.kty === "OKP") {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
if (!isPublic)
|
|
365
|
-
|
|
366
|
-
if (key.crv !== "X25519" && key.crv !== "Ed25519") throw notSupported(key.crv + " keys");
|
|
367
|
-
if (data.byteLength !== 32) throw invalidJwk();
|
|
378
|
+
const size = { Ed25519: 32, X25519: 32, Ed448: 57, X448: 56 }[key.crv];
|
|
379
|
+
if (size === undefined || !str(key.x) || b64(key.x).byteLength !== size) throw invalidJwk("Invalid JWK OKP key");
|
|
380
|
+
if (isPrivate && (!str(key.d) || b64(key.d).byteLength !== size)) throw invalidJwk("Invalid JWK OKP key");
|
|
381
|
+
if (!isPublic && !isPrivate) throw noPrivate();
|
|
382
|
+
if (size !== 32) throw notSupported(key.crv + " keys");
|
|
368
383
|
const kind = key.crv.toLowerCase();
|
|
369
|
-
return
|
|
384
|
+
return isPrivate ? fromParts(kind, true, undefined, [undefined, b64(key.d)]) : fromParts(kind, false, undefined, [b64(key.x)]);
|
|
370
385
|
}
|
|
371
386
|
if (key.kty === "EC") {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
validateString(key.y, "key.y");
|
|
376
|
-
if (!isPublic) validateString(key.d, "key.d");
|
|
387
|
+
if (!str(key.crv)) throw invalidJwk("Invalid JWK EC key");
|
|
388
|
+
if (!["P-256", "secp256k1", "P-384", "P-521"].includes(key.crv)) throw codeError(TypeError, "ERR_CRYPTO_INVALID_CURVE", "Invalid EC curve name");
|
|
389
|
+
if (!str(key.x) || !str(key.y) || (isPrivate && !str(key.d))) throw invalidJwk("Invalid JWK EC key");
|
|
377
390
|
const size = CURVE_SIZES[key.crv];
|
|
378
391
|
const x = b64(key.x);
|
|
379
392
|
const y = b64(key.y);
|
|
380
|
-
if (size !== undefined && (x.length !== size || y.length !== size)) throw invalidJwk();
|
|
393
|
+
if (size !== undefined && (x.length !== size || y.length !== size)) throw invalidJwk("Invalid JWK EC key");
|
|
394
|
+
if (!isPublic && !isPrivate) throw noPrivate();
|
|
381
395
|
const point = Buffer.concat([Buffer.from([4]), x, y]);
|
|
382
|
-
return
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
names.push(name);
|
|
391
|
-
}
|
|
396
|
+
return isPrivate ? fromParts("ec", true, key.crv, [point, b64(key.d)]) : fromParts("ec", false, key.crv, [point]);
|
|
397
|
+
}
|
|
398
|
+
if (key.kty === "RSA") {
|
|
399
|
+
const names = ["n", "e"];
|
|
400
|
+
if (isPrivate) names.push("d", "p", "q", "dp", "dq", "qi");
|
|
401
|
+
if (!names.every((name) => str(key[name]))) throw invalidJwk("Invalid JWK RSA key");
|
|
402
|
+
if (!isPublic && !isPrivate) throw noPrivate();
|
|
403
|
+
return fromParts("rsa", isPrivate, undefined, names.map((name) => b64(key[name])), "Invalid JWK RSA key");
|
|
392
404
|
}
|
|
393
|
-
|
|
405
|
+
throw invalidJwk(`${key.kty} is not a supported JWK key type`);
|
|
394
406
|
}
|
|
395
407
|
|
|
396
408
|
/* ---- createSecretKey, createPublicKey, createPrivateKey ---------------------------------------- */
|
|
@@ -405,7 +417,7 @@ const CREATE_PUBLIC = 0, CREATE_PRIVATE = 1, CONSUME_PUBLIC = 2, CONSUME_PRIVATE
|
|
|
405
417
|
|
|
406
418
|
/* a KeyObject (or CryptoKey) given where an asymmetric key is wanted */
|
|
407
419
|
function handleOfKeyObject(key, ctx) {
|
|
408
|
-
if (ctx === CREATE_PRIVATE) throw invalidArgType("key", "of type string or an instance of ArrayBuffer, Buffer, TypedArray, or
|
|
420
|
+
if (ctx === CREATE_PRIVATE) throw invalidArgType("key", "of type string or an instance of ArrayBuffer, Buffer, TypedArray, DataView, or URL", key);
|
|
409
421
|
if (key.type !== "private") {
|
|
410
422
|
if (ctx === CONSUME_PRIVATE || ctx === CREATE_PUBLIC) throw keyObjectType(key.type, "private");
|
|
411
423
|
if (key.type !== "public") throw keyObjectType(key.type, "private or public");
|
|
@@ -436,12 +448,13 @@ function prepareAsymmetricKey(key, ctx) {
|
|
|
436
448
|
if (!isStringOrBuffer(data)) {
|
|
437
449
|
throw invalidArgType("key.key", "of type string or an instance of ArrayBuffer, Buffer, TypedArray, or DataView", data);
|
|
438
450
|
}
|
|
439
|
-
const { format: fmt, type } = parseKeyEncoding(key, undefined, wantPrivate ? false : undefined);
|
|
451
|
+
const { format: fmt, type } = parseKeyEncoding(key, undefined, wantPrivate ? false : undefined, "key");
|
|
440
452
|
const bytes = typeof data === "string" && fmt === "der" ? Buffer.from(data, encoding ?? "utf8") : data;
|
|
441
453
|
return { key: parseKey(bytes, fmt, type, wantPrivate) };
|
|
442
454
|
}
|
|
455
|
+
/* Node 24 lists URL where a private key is wanted (an OpenSSL store's; not visaljs's yet) */
|
|
443
456
|
const expected = ctx === CREATE_PRIVATE
|
|
444
|
-
? "of type string or an instance of ArrayBuffer, Buffer, TypedArray, or
|
|
457
|
+
? "of type string or an instance of ArrayBuffer, Buffer, TypedArray, DataView, or URL"
|
|
445
458
|
: "of type string or an instance of ArrayBuffer, Buffer, TypedArray, DataView, KeyObject, or CryptoKey";
|
|
446
459
|
throw invalidArgType("key", expected, key);
|
|
447
460
|
}
|
|
@@ -518,11 +531,11 @@ function pairEncodings(keyType, options) {
|
|
|
518
531
|
let pub, priv;
|
|
519
532
|
if (publicKeyEncoding != null) {
|
|
520
533
|
if (typeof publicKeyEncoding !== "object") throw invalidArgValue("options.publicKeyEncoding", "is invalid", publicKeyEncoding);
|
|
521
|
-
pub = publicKeyEncoding.format === "jwk" ? { format: "jwk" } : parseKeyEncoding(publicKeyEncoding, keyType, true, "publicKeyEncoding");
|
|
534
|
+
pub = publicKeyEncoding.format === "jwk" ? { format: "jwk" } : parseKeyEncoding(publicKeyEncoding, keyType, true, "options.publicKeyEncoding");
|
|
522
535
|
}
|
|
523
536
|
if (privateKeyEncoding != null) {
|
|
524
537
|
if (typeof privateKeyEncoding !== "object") throw invalidArgValue("options.privateKeyEncoding", "is invalid", privateKeyEncoding);
|
|
525
|
-
priv = privateKeyEncoding.format === "jwk" ? { format: "jwk" } : parseKeyEncoding(privateKeyEncoding, keyType, false, "privateKeyEncoding");
|
|
538
|
+
priv = privateKeyEncoding.format === "jwk" ? { format: "jwk" } : parseKeyEncoding(privateKeyEncoding, keyType, false, "options.privateKeyEncoding");
|
|
526
539
|
if (priv.cipher != null) throw notSupported("Encrypting a private key");
|
|
527
540
|
}
|
|
528
541
|
return { pub, priv };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// node:crypto's random numbers
|
|
1
|
+
// node:crypto's random numbers: Node's lib/internal/crypto/random.js over the
|
|
2
2
|
// runtime's CSPRNG (an HMAC_DRBG seeded from the system). The asynchronous forms fill at the
|
|
3
3
|
// call and call back from a timer, where Node's thread pool would.
|
|
4
|
+
// Ported from Node.js (Copyright Node.js contributors, MIT): node/third_party/nodejs/LICENSE.
|
|
4
5
|
import { cryptoHostRandomUUID, cryptoRandomFill } from "visaljs:host";
|
|
5
6
|
import { invalidArgType, outOfRange, validateFunction } from "../errors.js";
|
|
6
7
|
import { isAnyArrayBuffer, isArrayBufferView, validateBoolean, validateNumber, validateObject } from "./util.js";
|