]> git.kaiwu.me - njs.git/log
njs.git
6 months agoFetch: refactored request building logic into separate function.
Dmitry Volyntsev [Thu, 9 Oct 2025 23:16:54 +0000 (16:16 -0700)]
Fetch: refactored request building logic into separate function.

6 months agoFetch: introduced port and protocol helper macros.
Dmitry Volyntsev [Thu, 9 Oct 2025 22:57:44 +0000 (15:57 -0700)]
Fetch: introduced port and protocol helper macros.

6 months agoTests: making sure dns stub in js_fetch_https.t resolves only known hosts.
Dmitry Volyntsev [Thu, 9 Oct 2025 01:41:47 +0000 (18:41 -0700)]
Tests: making sure dns stub in js_fetch_https.t resolves only known hosts.

6 months agoFetch: simplified ngx_js_http_resolve().
Dmitry Volyntsev [Wed, 15 Oct 2025 22:29:14 +0000 (15:29 -0700)]
Fetch: simplified ngx_js_http_resolve().

6 months agoModules: added error handling when logging a js exception string.
Vadim Zhestikov [Thu, 23 Oct 2025 20:27:41 +0000 (13:27 -0700)]
Modules: added error handling when logging a js exception string.

6 months agoQuickJS: fixed r.subrequest() to a location with JS handler.
Dmitry Volyntsev [Tue, 14 Oct 2025 00:37:11 +0000 (17:37 -0700)]
QuickJS: fixed r.subrequest() to a location with JS handler.

Previously, when a subrequest location had a JS handler, an object of a
subrequest JS context was provided as an argument to a parent contexts.
This may cause all sorts of problems due to incorrect reference
counting.

After this change in bellard/quickjs@42eb2795 the bug became apparent.

6 months agoVersion bump.
Dmitry Volyntsev [Thu, 9 Oct 2025 01:42:16 +0000 (18:42 -0700)]
Version bump.

7 months agoVersion 0.9.3. 0.9.3
Dmitry Volyntsev [Mon, 6 Oct 2025 16:13:36 +0000 (09:13 -0700)]
Version 0.9.3.

7 months agoFixed heap-use-after-free in js_set handler.
Dmitry Volyntsev [Tue, 30 Sep 2025 01:30:15 +0000 (18:30 -0700)]
Fixed heap-use-after-free in js_set handler.

The issue was introduced in commit 04f6dfb (0.9.2) by moving VM
destruction from the pool cleanup handler to the http cleanup handler.

Moving VM destruction to the http cleanup handler broke js_set variable
usage during the log phase, because these variables are called after the
VM has been destroyed.

The fix is to move VM destruction back to the pool cleanup handler, but
use a temporary pool while njs.on('exit', ...) is executing.

This fixes #969 and #971 issues on Github.

7 months agoModule: fixed heap-use-after-free while module loading.
Dmitry Volyntsev [Thu, 2 Oct 2025 03:07:14 +0000 (20:07 -0700)]
Module: fixed heap-use-after-free while module loading.

Making a copy of file argument because the engine may outlive
current ngx_cycle.

The bug became visible since 283282f (0.8.8).

7 months agoModules: fixed memory leak when module loading failed.
Dmitry Volyntsev [Thu, 2 Oct 2025 03:23:08 +0000 (20:23 -0700)]
Modules: fixed memory leak when module loading failed.

7 months agoFixed potential heap-use-after-free in njs_vm_compile_module().
Dmitry Volyntsev [Thu, 2 Oct 2025 03:10:43 +0000 (20:10 -0700)]
Fixed potential heap-use-after-free in njs_vm_compile_module().

Passing a local copy of name argument to njs_parser_init().

7 months agoVersion bump.
Dmitry Volyntsev [Tue, 30 Sep 2025 05:43:11 +0000 (22:43 -0700)]
Version bump.

7 months agoReadme: updated hero graphic.
Michael Vernik [Thu, 2 Oct 2025 21:41:16 +0000 (14:41 -0700)]
Readme: updated hero graphic.

7 months agoVersion 0.9.2. 0.9.2
Dmitry Volyntsev [Mon, 22 Sep 2025 17:12:15 +0000 (10:12 -0700)]
Version 0.9.2.

7 months agoModules: fixed building when http_ssl and stream_ssl unavailable.
Dmitry Volyntsev [Wed, 17 Sep 2025 22:34:19 +0000 (15:34 -0700)]
Modules: fixed building when http_ssl and stream_ssl unavailable.

This fixes issue introduced in 7b3c8a66.

7 months agoFixed build with gcc-15 and -O3.
Dmitry Volyntsev [Wed, 17 Sep 2025 01:28:05 +0000 (18:28 -0700)]
Fixed build with gcc-15 and -O3.

build/src/njs_object.dep -MT build/src/njs_object.o \ src/njs_object.c
In file included from src/njs_main.h:18, from src/njs_object.c:8: In
function ‘njs_utf8_copy’, inlined from ‘njs_object_enumerate_string’ at
src/njs_object.c:769:21: src/njs_utf8.h:115:20: error: writing 1 byte
into a region of size 0 [-Werror=stringop-overflow=] 115 |
*dst++ = c; |             ~~~~~~~^~~ src/njs_object.c: In function
‘njs_object_enumerate_string’: src/njs_object.c:719:24: note: at offset
4 into destination object ‘buf’ of size 4 719 |     u_char
buf[4], *c; |                        ^~~ In function ‘njs_utf8_copy’,
inlined from ‘njs_object_enumerate_string’ at src/njs_object.c:769:21:
src/njs_utf8.h:115:20: error: writing 1 byte into a region of size 0
[-Werror=stringop-overflow=]

GCC-15 does not know that the loop in njs_utf8_copy() is bounded
because the input is a valid UTF-8 here.

This fixes #967 issue on Github.

7 months agoFetch: added keepalive support for ngx.fetch() API.
Dmitry Volyntsev [Thu, 4 Sep 2025 03:27:16 +0000 (20:27 -0700)]
Fetch: added keepalive support for ngx.fetch() API.

This closes #957 feature request on Github.

7 months agoFetch: added parsing of HTTP version.
Dmitry Volyntsev [Sat, 13 Sep 2025 02:10:32 +0000 (19:10 -0700)]
Fetch: added parsing of HTTP version.

7 months agoModules: simplified access to nginx values from JS engines.
Dmitry Volyntsev [Thu, 4 Sep 2025 05:44:04 +0000 (22:44 -0700)]
Modules: simplified access to nginx values from JS engines.

8 months agoQuickJS: added njs.on('exit') API support.
Dmitry Volyntsev [Tue, 26 Aug 2025 21:22:19 +0000 (14:22 -0700)]
QuickJS: added njs.on('exit') API support.

This closes #955 issue on Github.

8 months agoQuickJS: removed extra copy of body argument in ngx.fetch().
Dmitry Volyntsev [Fri, 29 Aug 2025 02:15:01 +0000 (19:15 -0700)]
QuickJS: removed extra copy of body argument in ngx.fetch().

8 months agoQuickJS: fixed potential heap-use-after-free.
Dmitry Volyntsev [Thu, 28 Aug 2025 22:20:31 +0000 (15:20 -0700)]
QuickJS: fixed potential heap-use-after-free.

Previously in QuickJS engine, fields allocated from memory pool linked
to QuickJS engine lifetime were stored in nginx data structs.

This causes a heap-use-after-free if QuickJS engine is destroyed
earlier than a last access from nginx. For example, it becomes
visible when moving NJS cleanup handler from pool->cleanup to
r->cleanup.

The fix is to only store references in nginx objects allocated from
nginx memory pool.

8 months agoQuickJS: freeing temporary strings.
Dmitry Volyntsev [Thu, 28 Aug 2025 23:29:22 +0000 (16:29 -0700)]
QuickJS: freeing temporary strings.

8 months agoQuickJS: using enum instead of manual opaque id table.
Dmitry Volyntsev [Tue, 26 Aug 2025 05:26:24 +0000 (22:26 -0700)]
QuickJS: using enum instead of manual opaque id table.

8 months agoQuickJS: fix nginx configure with not configured njs module.
Vadim Zhestikov [Fri, 29 Aug 2025 16:42:18 +0000 (09:42 -0700)]
QuickJS: fix nginx configure with not configured njs module.

This fixes issue #960 which was introduced in 8259f9a.

8 months agoModules: optimized memory consumption while streaming in qjs.
Dmitry Volyntsev [Tue, 19 Aug 2025 04:21:09 +0000 (21:21 -0700)]
Modules: optimized memory consumption while streaming in qjs.

This allows to stream long tcp streams or large http response bodies
with low memory consumption.

This works only for qjs engine, because njs has no GC.

This fixes #943 issue on Github.

8 months agoModules: removing extra copy while streaming in qjs.
Dmitry Volyntsev [Thu, 14 Aug 2025 06:19:46 +0000 (23:19 -0700)]
Modules: removing extra copy while streaming in qjs.

8 months agoTests: added TypedArray test for js_filter in stream.
Dmitry Volyntsev [Wed, 20 Aug 2025 00:16:22 +0000 (17:16 -0700)]
Tests: added TypedArray test for js_filter in stream.

8 months agoFixed building QuickJS support with clang 19.
Dmitry Volyntsev [Mon, 25 Aug 2025 23:47:43 +0000 (16:47 -0700)]
Fixed building QuickJS support with clang 19.

checking for QuickJS library -lquickjs In file included from
build/autotest.c:6:
/home/xeioex/workspace/nginx/nginScript/quickjs/quickjs.h:1052:34:
error: cast from 'JSCFunctionMagic *' (aka 'struct JSValue (*)(struct
JSContext *, struct JSValue, int, struct JSValue *, int)') to
'JSCFunction *' (aka 'struct JSValue (*)(struct JSContext *, struct
JSValue, int, struct JSValue *)') converts to incompatible function type
[-Werror,-Wcast-function-type-mismatch] 1052 | return
JS_NewCFunction2(ctx, (JSCFunction *)func, name, length, cproto, magic);

-Wcast-function-type-mismatch become enabled by -Werror since
clang 19.

8 months agoModules: fixed incorrect config rejections introduced in d157f56.
Dmitry Volyntsev [Sat, 16 Aug 2025 00:28:47 +0000 (17:28 -0700)]
Modules: fixed incorrect config rejections introduced in d157f56.

d157f56 introduced configure time checks for js_set and js_periodic
directives. It turned out to be too strict.

The fix is to remove them completely as there is no way to track
variable usage context in configure time.

8 months agoModules: added configure time check when "js_import" is not defined.
Dmitry Volyntsev [Tue, 12 Aug 2025 06:26:12 +0000 (23:26 -0700)]
Modules: added configure time check when "js_import" is not defined.

8 months agoModules: fixed merging of js_path directives.
Dmitry Volyntsev [Tue, 12 Aug 2025 01:55:18 +0000 (18:55 -0700)]
Modules: fixed merging of js_path directives.

The issue initially appeared in 1b54abb (0.7.7).

8 months agoChange: increasing the default stack size to 160k.
Dmitry Volyntsev [Mon, 11 Aug 2025 23:25:47 +0000 (16:25 -0700)]
Change: increasing the default stack size to 160k.

This change allows EarleyBoyer benchmark from
arewefastyet/benchmarks/v8-v7 to pass with default settings.

Previous commit 5e9a6d5 (v0.7.9) reduced the stack size to prevent stack
overflow when compiling with -O0 in computed goto mode, where native
stack frames for njs_vmcode_interpreter() consume ~80KB each. To address
this, we now set a lower maximum stack size specifically for unit tests.

This fixes #939 issue on Github.

9 months agoAdded CLA workflow.
Vadim Zhestikov [Fri, 8 Aug 2025 00:41:09 +0000 (17:41 -0700)]
Added CLA workflow.

9 months agoRemoved remnants of level hash.
Vadim Zhestikov [Fri, 11 Jul 2025 22:51:14 +0000 (15:51 -0700)]
Removed remnants of level hash.

Level hash has not been compiled since e64a376 (0.8.1) when flat hash was
introduced. However, the compatibility layer remained to reduce the diff.

9 months agoVersion bump.
Dmitry Volyntsev [Sat, 12 Jul 2025 01:26:19 +0000 (18:26 -0700)]
Version bump.

10 months agoVersion 0.9.1. 0.9.1
Dmitry Volyntsev [Wed, 9 Jul 2025 21:34:05 +0000 (14:34 -0700)]
Version 0.9.1.

10 months agoFixed property set for objects with a TypedArray in prototype.
Dmitry Volyntsev [Thu, 10 Jul 2025 17:40:05 +0000 (10:40 -0700)]
Fixed property set for objects with a TypedArray in prototype.

The issue was introduced in 2f288a9c.

10 months agoOptimized memory consumption by object hash.
Vadim Zhestikov [Fri, 6 Jun 2025 23:52:57 +0000 (16:52 -0700)]
Optimized memory consumption by object hash.

The new hash takes 42% less memory per element.

10 months agoReplaced constant by sizeof value.
Vadim Zhestikov [Sun, 6 Jul 2025 18:30:38 +0000 (11:30 -0700)]
Replaced constant by sizeof value.

10 months agoImproved String.prototype.concat() with scalar values.
Vadim Zhestikov [Thu, 3 Jul 2025 21:14:43 +0000 (14:14 -0700)]
Improved String.prototype.concat() with scalar values.

10 months agoFixed NULL pointer dereference when processing If-* headers.
Dmitry Volyntsev [Tue, 8 Jul 2025 05:40:45 +0000 (22:40 -0700)]
Fixed NULL pointer dereference when processing If-* headers.

Previously, when processing requests with If-Match and
If-Unmodified-Since headers worker process crashed.

For example with the following code:
try { r.return(200) }
catch (e) { r.internalRedirect() }

The fix is to disable not_modified filter as it was done in
nginx perl module nginx/nginx@d9887ee2.

10 months agoFixed RegExp compilation after 17124c81.
Dmitry Volyntsev [Thu, 3 Jul 2025 23:53:33 +0000 (16:53 -0700)]
Fixed RegExp compilation after 17124c81.

Previously, heap-buffer-overflow happened due to incorrect copying of
[...] regexp parts.

Found by OSS-Fuzz.

10 months agoRemoved not used njs_scope_create_index_value().
Vadim Zhestikov [Fri, 27 Jun 2025 16:45:48 +0000 (09:45 -0700)]
Removed not used njs_scope_create_index_value().

10 months agoRemoved useless njs_value_assign() call.
Vadim Zhestikov [Mon, 16 Jun 2025 21:33:05 +0000 (14:33 -0700)]
Removed useless njs_value_assign() call.

10 months agoSimplified njs_object_prop_t.
Vadim Zhestikov [Fri, 6 Jun 2025 23:45:15 +0000 (16:45 -0700)]
Simplified njs_object_prop_t.

Removed enum_in_object_hash which is only set when prop->type is
NJS_WHITEOUT and this check can be used instead.

10 months agoIgnoring previous value in njs_flathsh_insert().
Vadim Zhestikov [Thu, 12 Jun 2025 15:34:17 +0000 (08:34 -0700)]
Ignoring previous value in njs_flathsh_insert().

Previously, fhq->value was set to a previous value if the value existed.
This is not used anymore in the code.

10 months agoReleased temporary template literal memory.
Vadim Zhestikov [Wed, 25 Jun 2025 18:50:25 +0000 (11:50 -0700)]
Released temporary template literal memory.

10 months agoImproved memory consumption of String.prototype.concat() with numbers.
Vadim Zhestikov [Tue, 24 Jun 2025 00:44:57 +0000 (17:44 -0700)]
Improved memory consumption of String.prototype.concat() with numbers.

10 months agoImproved memory consumption for concatenation of numbers and strings.
Vadim Zhestikov [Mon, 23 Jun 2025 19:33:18 +0000 (12:33 -0700)]
Improved memory consumption for concatenation of numbers and strings.

10 months agoFixed invalid link in README.md.
Xiaobo Liu [Tue, 1 Jul 2025 09:31:16 +0000 (17:31 +0800)]
Fixed invalid link in README.md.

10 months agoFixed regexp compilation of patterns with escaped '[' characters.
Dmitry Volyntsev [Tue, 1 Jul 2025 01:30:03 +0000 (18:30 -0700)]
Fixed regexp compilation of patterns with escaped '[' characters.

This fixes #934 issue on Github.

10 months agoModules: fixed qjs engine after bellard/quickjs@458c34d2.
Dmitry Volyntsev [Wed, 2 Jul 2025 06:01:57 +0000 (23:01 -0700)]
Modules: fixed qjs engine after bellard/quickjs@458c34d2.

Object leaks:
       ADDRESS REFS SHRF          PROTO CONTENT
0x512000007fc0    1 [module]
nginx: quickjs.c:1967: JS_FreeRuntime: Assertion `list_empty(&rt->gc_obj_list)' failed.

After bellard/quickjs@458c34d2 modules are treated as GC objects and
tracked in rt->gc_obj_list. Intermediary module object loaded in
ngx_qjs_clone() using JS_ReadObject() needed to be freed for proper
ref_count accounting.

10 months agoFetch: fixed handling of Content-Length header when body is provided.
Dmitry Volyntsev [Tue, 17 Jun 2025 02:36:35 +0000 (19:36 -0700)]
Fetch: fixed handling of Content-Length header when body is provided.

body value length takes precedence over Content-Length from header list.

    https://fetch.spec.whatwg.org/#http-network-or-cache-fetch

    Let contentLength be httpRequest’s body’s length, if httpRequest’s body
is non-null; otherwise null.

    Let contentLengthHeaderValue be null.

    If httpRequest’s body is null and httpRequest’s method is `POST` or
`PUT`, then set contentLengthHeaderValue to `0`.

    If contentLength is non-null, then set contentLengthHeaderValue to
contentLength, serialized and isomorphic encoded.

    If contentLengthHeaderValue is non-null, then append (`Content-Length`,
contentLengthHeaderValue) to httpRequest’s header list.

This fixes #930 issue in Github.

10 months agoTypes: added TS definitions for WebCrypto ECDH.
Dmitry Volyntsev [Tue, 17 Jun 2025 01:16:46 +0000 (18:16 -0700)]
Types: added TS definitions for WebCrypto ECDH.

10 months agoTypes: updated TS definitions.
Dmitry Volyntsev [Tue, 17 Jun 2025 01:03:41 +0000 (18:03 -0700)]
Types: updated TS definitions.

10 months agoParser: unused strict_semicolon cleanup.
Dmitry Volyntsev [Sat, 14 Jun 2025 03:19:36 +0000 (20:19 -0700)]
Parser: unused strict_semicolon cleanup.

10 months agoParser: simplifed working with function variables.
Dmitry Volyntsev [Fri, 13 Jun 2025 00:33:35 +0000 (17:33 -0700)]
Parser: simplifed working with function variables.

10 months agoFixed frame saving for awaited function with closures.
Dmitry Volyntsev [Wed, 11 Jun 2025 23:17:42 +0000 (16:17 -0700)]
Fixed frame saving for awaited function with closures.

The issue was introduced in 6335367 (0.7.0).

This fixes #530 issue on Github.

10 months agoMoving child function declaration instantiation to bytecode.
Dmitry Volyntsev [Tue, 10 Jun 2025 01:38:15 +0000 (18:38 -0700)]
Moving child function declaration instantiation to bytecode.

Children functions need to be hoisted and instantiated at the beginning
of a function call. Previously, it was done as a part of C code
that implements JS function call.

Now, each child function is instantiated by FUNCTION instruction at a
function prelude. This makes global and function code similar, which in
turn allows to get rid of FUNCTION COPY instruction which was only
needed for global code.

10 months agoTests: tuned periodic test for delays.
Dmitry Volyntsev [Fri, 13 Jun 2025 00:54:43 +0000 (17:54 -0700)]
Tests: tuned periodic test for delays.

10 months agoFixed handling of detached buffer for typed arrays.
Dmitry Volyntsev [Fri, 13 Jun 2025 00:20:07 +0000 (17:20 -0700)]
Fixed handling of detached buffer for typed arrays.

10 months agoFixed %TypedArray%.prototype.slice() with overlapping buffers.
Dmitry Volyntsev [Thu, 12 Jun 2025 22:34:39 +0000 (15:34 -0700)]
Fixed %TypedArray%.prototype.slice() with overlapping buffers.

10 months agoFixed %TypedArray%.from() with buffer is detached by mapper.
Dmitry Volyntsev [Thu, 12 Jun 2025 22:16:41 +0000 (15:16 -0700)]
Fixed %TypedArray%.from() with buffer is detached by mapper.

11 months agoRemoved NGX_MAX_PATH define.
Orgad Shaneh [Mon, 9 Jun 2025 13:59:22 +0000 (16:59 +0300)]
Removed NGX_MAX_PATH define.

Already defined in ngx_files.h (included from ngx_core.h).

11 months agoFixed compilation with old gcc.
Dmitry Volyntsev [Thu, 5 Jun 2025 06:07:11 +0000 (23:07 -0700)]
Fixed compilation with old gcc.

This fixed compilation issues with gcc-4.1.

11 months agoFixed constant is too large for 'long' warning on mips -mabi=n32.
Dmitry Volyntsev [Thu, 5 Jun 2025 05:54:54 +0000 (22:54 -0700)]
Fixed constant is too large for 'long' warning on mips -mabi=n32.

Prodded by Orgad Shaneh.

11 months agoFixed gcc compilation with O3 optimization level.
Dmitry Volyntsev [Tue, 3 Jun 2025 02:08:27 +0000 (19:08 -0700)]
Fixed gcc compilation with O3 optimization level.

11 months agoImproved README.md clarity with angle bracket explanations.
Dmitry Volyntsev [Wed, 4 Jun 2025 05:37:32 +0000 (22:37 -0700)]
Improved README.md clarity with angle bracket explanations.

11 months agoFixed Function constructor template injection.
Dmitry Volyntsev [Tue, 3 Jun 2025 00:18:22 +0000 (17:18 -0700)]
Fixed Function constructor template injection.

The Function constructor uses a `(function(<args>) {<body>})` template
to construct new functions. This approach was vulnerable to template
injection where malicious code could close the function body early.

This fixes issue #921.

11 months agoFixed segfault at error message in njs_property_query().
Vadim Zhestikov [Wed, 28 May 2025 16:16:38 +0000 (09:16 -0700)]
Fixed segfault at error message in njs_property_query().

The issue was introduced in b28e50b1 (0.9.0).
This closes #918 issue on Github.

11 months agoQuickJS: added memory limit check for reuse queue.
Dmitry Volyntsev [Thu, 22 May 2025 00:10:15 +0000 (17:10 -0700)]
QuickJS: added memory limit check for reuse queue.

11 months agoModules: added state file for the shared dictionary.
Dmitry Volyntsev [Thu, 15 May 2025 01:16:15 +0000 (18:16 -0700)]
Modules: added state file for the shared dictionary.

A new optional state parameter is added for js_shared_dict_zone
directive. state parameter specifies a file that keeps the current state
of the shared dict in the JSON format and makes it persistent
across nginx restarts.

This closes #709 feature request on Github.

11 months agoModules: engine independent method to add entries to a shared dict.
Dmitry Volyntsev [Fri, 16 May 2025 00:24:25 +0000 (17:24 -0700)]
Modules: engine independent method to add entries to a shared dict.

11 months agoModules: replaced njs_str_t with ngx_str_t in the shared dictionary.
Dmitry Volyntsev [Fri, 16 May 2025 00:01:25 +0000 (17:01 -0700)]
Modules: replaced njs_str_t with ngx_str_t in the shared dictionary.

This is a preparatory patch for upcoming changes to unify common code
for njs and QuickJS engines.

11 months agoModules: introduced NGX_CHB_CTX_INIT().
Dmitry Volyntsev [Thu, 15 May 2025 02:36:33 +0000 (19:36 -0700)]
Modules: introduced NGX_CHB_CTX_INIT().

11 months agoModules: separating different init worker components.
Dmitry Volyntsev [Thu, 15 May 2025 01:00:23 +0000 (18:00 -0700)]
Modules: separating different init worker components.

11 months agoTests: removed leftover engine checks.
Dmitry Volyntsev [Tue, 20 May 2025 01:53:00 +0000 (18:53 -0700)]
Tests: removed leftover engine checks.

11 months agoWebCrypto: fixed issue introduced in 637fc26e.
Dmitry Volyntsev [Mon, 19 May 2025 21:58:12 +0000 (14:58 -0700)]
WebCrypto: fixed issue introduced in 637fc26e.

Found by Clang static analyzer.

11 months agoWebCrypto: improved working with curve constants.
Dmitry Volyntsev [Wed, 14 May 2025 02:08:16 +0000 (19:08 -0700)]
WebCrypto: improved working with curve constants.

In crypto.subtle.generateKey().

11 months agoWebCrypto: added ECDH support.
Dmitry Volyntsev [Fri, 9 May 2025 00:13:01 +0000 (17:13 -0700)]
WebCrypto: added ECDH support.

11 months agoWebCrypto: making SHA-256 the default hash algorithm.
Dmitry Volyntsev [Fri, 9 May 2025 01:03:21 +0000 (18:03 -0700)]
WebCrypto: making SHA-256 the default hash algorithm.

11 months agoAdd missing null checks for promise code.
Dmitry Sviridkin [Thu, 15 May 2025 12:55:13 +0000 (13:55 +0100)]
Add missing null checks for promise code.

12 months agoFetch: QuickJS support.
Zhidao HONG [Tue, 22 Apr 2025 02:56:27 +0000 (10:56 +0800)]
Fetch: QuickJS support.

12 months agoFetch: unify string type to support both njs and QuickJS.
Zhidao HONG [Mon, 21 Apr 2025 17:09:15 +0000 (01:09 +0800)]
Fetch: unify string type to support both njs and QuickJS.

12 months agoFetch: separated ngx_js_http_* from ngx_js_fetch_*.
Zhidao HONG [Mon, 21 Apr 2025 17:04:31 +0000 (01:04 +0800)]
Fetch: separated ngx_js_http_* from ngx_js_fetch_*.

12 months agoWebCrypto: fixed extractable handling for crypto.subtle.deriveKey().
Dmitry Volyntsev [Thu, 8 May 2025 03:49:21 +0000 (20:49 -0700)]
WebCrypto: fixed extractable handling for crypto.subtle.deriveKey().

12 months agoWebCrypto: added support for HMAC as derivedKeyAlgorithm.
Dmitry Volyntsev [Thu, 8 May 2025 02:11:24 +0000 (19:11 -0700)]
WebCrypto: added support for HMAC as derivedKeyAlgorithm.

In crypto.subtle.deriveKey().

This closes #905 issue on Github.

12 months agoVersion bump.
Dmitry Volyntsev [Thu, 8 May 2025 16:25:24 +0000 (09:25 -0700)]
Version bump.

12 months agoVersion 0.9.0. 0.9.0
Vadim Zhestikov [Mon, 5 May 2025 19:38:32 +0000 (12:38 -0700)]
Version 0.9.0.

12 months agoHTTP: fixed GCC 15 build with -Wunterminated-string-initialization.
Dmitry Volyntsev [Mon, 5 May 2025 15:53:19 +0000 (08:53 -0700)]
HTTP: fixed GCC 15 build with -Wunterminated-string-initialization.

ngx_http_js_module.c:936:22: error: initializer-string for array of ‘char’ truncates NUL terminator
 but destination lacks ‘nonstring’ attribute (16 chars into 15 available) [-Werror=unterminated-string-initialization]
  936 |             .value = "PeriodicSession",
      |                      ^~~~~~~~~~~~~~~~~

12 months agoFixed GCC 15 build with -Wunterminated-string-initialization.
Dmitry Volyntsev [Fri, 2 May 2025 00:05:56 +0000 (17:05 -0700)]
Fixed GCC 15 build with -Wunterminated-string-initialization.

In file included from src/njs_main.h:48,
                 from src/njs_diyfp.c:12:
src/njs_string.h: In function ‘njs_string_encode’:
src/njs_string.h:229:36: error: initializer-string for array of ‘unsigned char’
truncates NUL terminator but destination lacks ‘nonstring’ attribute (
17 chars into 16 available) [-Werror=unterminated-string-initialization]
  229 |     static const u_char  hex[16] = "0123456789ABCDEF";

12 months agoTests: fixed js_body_filter.t.
Dmitry Volyntsev [Thu, 1 May 2025 16:06:25 +0000 (09:06 -0700)]
Tests: fixed js_body_filter.t.

The 1496ed3f commit made visible a problem with the fragile filter tests
which depend on the exact sequence of data chunks. The fix is to use
perl http server to ensure the order.

12 months agoFixed regexp undefined value of captured group.
Vadim Zhestikov [Wed, 30 Apr 2025 21:20:31 +0000 (14:20 -0700)]
Fixed regexp undefined value of captured group.

Found by OSS-Fuzz.

12 months agoUsing invalid UTF-8 string as atom number 0.
Dmitry Volyntsev [Thu, 1 May 2025 01:32:39 +0000 (18:32 -0700)]
Using invalid UTF-8 string as atom number 0.

This prevents a clash with possible valid UTF-8 strings.

12 months agoFixed building with --debug=YES after b28e50b1.
Dmitry Volyntsev [Thu, 1 May 2025 01:23:20 +0000 (18:23 -0700)]
Fixed building with --debug=YES after b28e50b1.

In file included from src/njs_main.h:37,
                 from src/njs_diyfp.c:12:
src/njs_atom.h: In function ‘njs_atom_to_value’:
src/njs_atom.h:54:31: error: invalid use of incomplete typedef
‘njs_flathsh_descr_t’ {aka ‘struct njs_flathsh_descr_s’}
   54 |         njs_assert(atom_id < h->elts_count);
      |                               ^~
src/njs_assert.h:14:15: note: in definition of macro ‘njs_assert’

12 months agoTests: improved js_body_filter.t tests.
Dmitry Volyntsev [Tue, 29 Apr 2025 01:34:29 +0000 (18:34 -0700)]
Tests: improved js_body_filter.t tests.

Dropping Content-Length header in locations where response body
length is modified.  This is not strictly needed for the test itself,
but can serve as an example for a typical body modification task.

12 months agoTests: fixed js_body_filter.t tests.
Dmitry Volyntsev [Tue, 29 Apr 2025 01:28:08 +0000 (18:28 -0700)]
Tests: fixed js_body_filter.t tests.

Previously, '|' was used incorrectly in test match pattern.

12 months agoIntroduced NJS_VMCODE_PROPERTY_ATOM_SET instruction.
Dmitry Volyntsev [Sat, 22 Mar 2025 05:52:55 +0000 (22:52 -0700)]
Introduced NJS_VMCODE_PROPERTY_ATOM_SET instruction.