]> git.kaiwu.me - njs.git/log
njs.git
2 years agoImproved memory footprint of RegExp.prototype.split().
Dmitry Volyntsev [Wed, 4 Oct 2023 20:35:38 +0000 (13:35 -0700)]
Improved memory footprint of RegExp.prototype.split().

2 years agoImproved memory footprint of RegExp.prototype.replace().
Dmitry Volyntsev [Wed, 4 Oct 2023 01:09:06 +0000 (18:09 -0700)]
Improved memory footprint of RegExp.prototype.replace().

2 years agoImproved memory footprint of RegExp.prototype.test().
Dmitry Volyntsev [Tue, 3 Oct 2023 07:39:04 +0000 (00:39 -0700)]
Improved memory footprint of RegExp.prototype.test().

2 years agoFS: introduced fs.existsSync().
Dmitry Volyntsev [Sat, 30 Sep 2023 04:41:34 +0000 (21:41 -0700)]
FS: introduced fs.existsSync().

2 years agoRegExp: improved memory footprint when match fails.
Dmitry Volyntsev [Fri, 29 Sep 2023 02:09:56 +0000 (19:09 -0700)]
RegExp: improved memory footprint when match fails.

2 years agoStream: adjusted periodic timeout in tests.
Dmitry Volyntsev [Fri, 29 Sep 2023 01:11:15 +0000 (18:11 -0700)]
Stream: adjusted periodic timeout in tests.

2 years agoFetch: fixed HEAD response handling with large Content-Length.
Dmitry Volyntsev [Thu, 28 Sep 2023 18:00:56 +0000 (11:00 -0700)]
Fetch: fixed HEAD response handling with large Content-Length.

This closes #658 issue on Github.

2 years agoModules: introduced console object.
Dmitry Volyntsev [Fri, 22 Sep 2023 20:00:06 +0000 (13:00 -0700)]
Modules: introduced console object.

The following methods were added: dump(), error(), info(),
log(), time(), timeEnd(), warn().

2 years agoIntroduced API to work with external value pointers.
Dmitry Volyntsev [Fri, 22 Sep 2023 20:00:05 +0000 (13:00 -0700)]
Introduced API to work with external value pointers.

This allows to allocate the necessary context for external
code on demand.

2 years agoModules: added debug log for vm cloning and destroying.
Dmitry Volyntsev [Fri, 22 Sep 2023 20:00:04 +0000 (13:00 -0700)]
Modules: added debug log for vm cloning and destroying.

2 years agoShell: simplified console.time()/timeEnd() pair.
Dmitry Volyntsev [Thu, 21 Sep 2023 19:40:53 +0000 (12:40 -0700)]
Shell: simplified console.time()/timeEnd() pair.

Using a queue instead of a hash here because we assume that the
number of profile timers will be low.

2 years agoShell: introduced error, info and warn methods for console object.
Dmitry Volyntsev [Thu, 21 Sep 2023 04:48:41 +0000 (21:48 -0700)]
Shell: introduced error, info and warn methods for console object.

2 years agoShell: improved shell_test.
Dmitry Volyntsev [Thu, 21 Sep 2023 02:19:58 +0000 (19:19 -0700)]
Shell: improved shell_test.

Setting more appropriate env variables for libedit since we moved to
libedit as a default readline library in 0.8.0.

2 years agoVersion bump.
Dmitry Volyntsev [Thu, 21 Sep 2023 23:11:20 +0000 (16:11 -0700)]
Version bump.

2 years agoAdded tag 0.8.1 for changeset a52b49f9afcf
Dmitry Volyntsev [Tue, 12 Sep 2023 18:57:00 +0000 (11:57 -0700)]
Added tag 0.8.1 for changeset a52b49f9afcf

2 years agoVersion 0.8.1. 0.8.1
Dmitry Volyntsev [Tue, 12 Sep 2023 18:54:22 +0000 (11:54 -0700)]
Version 0.8.1.

2 years agoTypes: added TS description for items() introduced in f5428bc87159.
Dmitry Volyntsev [Tue, 12 Sep 2023 18:36:15 +0000 (11:36 -0700)]
Types: added TS description for items() introduced in f5428bc87159.

2 years agoHTTP: avoid calling body filter when input chain is NULL.
Dmitry Volyntsev [Tue, 12 Sep 2023 03:34:48 +0000 (20:34 -0700)]
HTTP: avoid calling body filter when input chain is NULL.

This solves the problem of erroneous exception thrown in
r.internalRedirect() after 05c7f0b31856 (0.8.0).

2 years agoModules: improved debug log.
Dmitry Volyntsev [Sat, 9 Sep 2023 00:13:19 +0000 (17:13 -0700)]
Modules: improved debug log.

1) Ensuring that consistent prefixes are used:
"http js" in HTTP module and "stream js" in Stream module.
2) Added debug for every event/callback handler entrance.
3) Added debug with a method name for every JS call.

2 years agoFetch: renamed prefix http to fetch to avoid overlap with HTTP module.
Dmitry Volyntsev [Sat, 9 Sep 2023 00:52:07 +0000 (17:52 -0700)]
Fetch: renamed prefix http to fetch to avoid overlap with HTTP module.

2 years agoAdded flat hash overflow check.
Vadim Zhestikov [Fri, 8 Sep 2023 23:05:24 +0000 (16:05 -0700)]
Added flat hash overflow check.

2 years agoModules: implemented items() method of a shared dictionary.
Dmitry Volyntsev [Thu, 7 Sep 2023 23:12:40 +0000 (16:12 -0700)]
Modules: implemented items() method of a shared dictionary.

2 years agoTests: fixed incr() tests for a shared dictionary.
Dmitry Volyntsev [Thu, 7 Sep 2023 23:12:31 +0000 (16:12 -0700)]
Tests: fixed incr() tests for a shared dictionary.

Previously, the incr() method called SharedDict.incr() with a NaN value
as a second argument because parseInt(undefined) returns NaN.

The test itself failed to capture the issue because it matches the whole
HTTP response and the pattern itself was too short, so it matched
accidentally.

2 years agoShell: fixed file error message on CLI without interactive mode.
Dmitry Volyntsev [Thu, 7 Sep 2023 01:02:50 +0000 (18:02 -0700)]
Shell: fixed file error message on CLI without interactive mode.

This closes #669 issue on Github.

2 years agoModules: added a session object for js_periodic handler.
Dmitry Volyntsev [Wed, 6 Sep 2023 01:15:14 +0000 (18:15 -0700)]
Modules: added a session object for js_periodic handler.

Now js_periodic handler is provided with a session object as its first
argument. Session object can be used to access variables created with
js_set, js_var or map directives.

example.conf:
    js_var $js_var  JS-VAR;

    location @periodics {
        js_periodic main.handler interval=60s;
    }

example.js:
    function handler(s) {
        ngx.log(ngx.INFO, s.variables.js_var);
    }

2 years agoModules: added worker_affinity parameter for js_periodic directive.
Dmitry Volyntsev [Tue, 5 Sep 2023 16:17:10 +0000 (09:17 -0700)]
Modules: added worker_affinity parameter for js_periodic directive.

worker_affinity specifies on what set of workers the js_periodic handler
should be executed. By default the js_handler is executed only on worker 0.
The parameter accepts a binary mask or "all" to specify all workers.

example.conf:
worker_processes 4;

...
    location @periodics {
        # to be run at 1 minute intervals in worker 0
        js_periodic main.handler interval=60s;

        # to be run at 1 minute intervals in all the workers
        js_periodic main.handler interval=60s worker_affinity=all;

        # to be run at 1 minute intervals in workers 1 and 3
        js_periodic main.handler interval=60s worker_affinity=0101;
    }

2 years agoFixed typo introduced in c7d2a7846b0b.
Vadim Zhestikov [Thu, 31 Aug 2023 15:24:17 +0000 (08:24 -0700)]
Fixed typo introduced in c7d2a7846b0b.

Found by Coverity (CID 1542439).

2 years agoFixed js_periodic handler stopping after graceful shutdown.
Dmitry Volyntsev [Thu, 31 Aug 2023 03:59:11 +0000 (20:59 -0700)]
Fixed js_periodic handler stopping after graceful shutdown.

The issue was introduced in f1bd0b1db065.

2 years agoModules: fixed size() and keys() methods of a shared dictionary.
Dmitry Volyntsev [Thu, 31 Aug 2023 01:59:28 +0000 (18:59 -0700)]
Modules: fixed size() and keys() methods of a shared dictionary.

Previously, these methods did not take into the account exprired
entries. The expired entries appear in js_shared_dict_zone when timeout
directive is specified as the expired elements are not removed at the
moment they become stale right away.

This closes #665 issue on Github.

2 years agoIntroduced flat hash.
Vadim Zhestikov [Wed, 30 Aug 2023 19:06:12 +0000 (12:06 -0700)]
Introduced flat hash.

Object property enumeration order is corrected.
This fixes #189 issue on Github.

2 years agoFixed building by GCC with -O3.
Vadim Zhestikov [Wed, 23 Aug 2023 17:09:22 +0000 (10:09 -0700)]
Fixed building by GCC with -O3.

2 years agoModules: introduced js_periodic directive.
Dmitry Volyntsev [Tue, 22 Aug 2023 18:13:09 +0000 (11:13 -0700)]
Modules: introduced js_periodic directive.

The directive specifies a JS handler to run at regular intervals. The JS
handler will be executed in each worker process. The handler receives no
arguments. It has access to ngx and other global objects.

example.conf:
    location @periodics {
        # Specifies a JS handler to be run at 1 minute intervals
        js_periodic main.handler interval=60s jitter=5s;

        resolver 10.0.0.1;
        js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem;
    }

example.js:
    async function handler() {
        if (ngx.worker_id != 0) {
            /* using ngx.worker_id to run handler only in one worker. */
            return;
        }

        let reply = async ngx.fetch('https://nginx.org/en/docs/njs/');
        let body = async reply.text();

        ngx.log(ngx.INFO, body);
    }

This closes #660 issue on Github.

2 years agoHTTP: simplified events handling.
Dmitry Volyntsev [Tue, 22 Aug 2023 18:12:02 +0000 (11:12 -0700)]
HTTP: simplified events handling.

2 years agoFixed typos introduced in ff7eb3c4bf76.
Dmitry Volyntsev [Tue, 22 Aug 2023 18:12:01 +0000 (11:12 -0700)]
Fixed typos introduced in ff7eb3c4bf76.

2 years agoHTTP: fixed setting of Last-Modified header.
Dmitry Volyntsev [Wed, 12 Jul 2023 05:50:44 +0000 (22:50 -0700)]
HTTP: fixed setting of Last-Modified header.

Previously, r.headersOut['Last-Modified'] setter did not update
r->headers_out.last_modified. As a result a client might get two
Last-Modified headers.

2 years agoHTTP: fixed setting of Date header.
Dmitry Volyntsev [Wed, 12 Jul 2023 02:12:34 +0000 (19:12 -0700)]
HTTP: fixed setting of Date header.

Previously, r.headersOut['Date'] setter did not update
r->headers_out.date. As a result a client might get two
Date headers.

2 years agoVersion bump.
Dmitry Volyntsev [Tue, 11 Jul 2023 00:57:45 +0000 (17:57 -0700)]
Version bump.

2 years agoAdded tag 0.8.0 for changeset 0ed1952588ab
Dmitry Volyntsev [Thu, 6 Jul 2023 16:10:47 +0000 (09:10 -0700)]
Added tag 0.8.0 for changeset 0ed1952588ab

2 years agoVersion 0.8.0. 0.8.0
Dmitry Volyntsev [Thu, 6 Jul 2023 00:49:50 +0000 (17:49 -0700)]
Version 0.8.0.

2 years agoModules: introduced js_shared_dict_zone directive.
Dmitry Volyntsev [Mon, 3 Jul 2023 20:32:41 +0000 (13:32 -0700)]
Modules: introduced js_shared_dict_zone directive.

The directive allows to declare a dictionary that is shared among the
working processes. A dictionary expects strings as keys. It stores
string or number as values. The value type is declared using
type= argument of the directive. The default type is string.

example.conf:
    # Declares a shared dictionary of strings of size 1 Mb that
    # removes key-value after 60 seconds of inactivity.
    js_shared_dict_zone zone=foo:1M timeout=60s;

    # Declares a shared dictionary of strings of size 512Kb that
    # forcibly remove oldest key-value pairs when memory is not enough.
    js_shared_dict_zone zone=bar:512K timeout=30s evict;

    # Declares a permanent number shared dictionary of size 32Kb.
    js_shared_dict_zone zone=num:32k type=number;

example.js:
    function get(r) {
        r.return(200, ngx.shared.foo.get(r.args.key));
    }

    function set(r) {
        r.return(200, ngx.shared.foo.set(r.args.key, r.args.value));
    }

    function delete(r) {
        r.return(200, ngx.shared.bar.delete(r.args.key));
    }

    function increment(r) {
        r.return(200, ngx.shared.num.incr(r.args.key, 2));
    }

In collaboration with Artem S. Povalyukhin, Jakub Jirutka and
洪志道 (Hong Zhi Dao).

This closes #437 issue on Github.

2 years agoAdded njs_vm_external_constructor().
Dmitry Volyntsev [Mon, 3 Jul 2023 19:49:00 +0000 (12:49 -0700)]
Added njs_vm_external_constructor().

The new API allows to add new constructor/prototype pairs.

2 years agoTests: improved memory sanitizer build.
Dmitry Volyntsev [Sat, 1 Jul 2023 04:02:44 +0000 (21:02 -0700)]
Tests: improved memory sanitizer build.

Disable webcrypto tests because they required instrumented openssl.

2 years agoImproved interactive shell.
Vadim Zhestikov [Sat, 1 Jul 2023 02:49:46 +0000 (19:49 -0700)]
Improved interactive shell.

2 years agoFixed parsing of invalid for statement.
Vadim Zhestikov [Sat, 1 Jul 2023 02:49:45 +0000 (19:49 -0700)]
Fixed parsing of invalid for statement.

2 years agoTests: fixed benchmark after 57ca02d7404c.
Dmitry Volyntsev [Sat, 1 Jul 2023 00:03:11 +0000 (17:03 -0700)]
Tests: fixed benchmark after 57ca02d7404c.

2 years agoAdded constructor name for async function.
Vadim Zhestikov [Fri, 30 Jun 2023 13:38:36 +0000 (06:38 -0700)]
Added constructor name for async function.

2 years agoModules: introduced ngx.worker_id.
Dmitry Volyntsev [Fri, 30 Jun 2023 03:44:14 +0000 (20:44 -0700)]
Modules: introduced ngx.worker_id.

worker_id corresponds to an nginx internal worker id.
The value is between 0 and worker_processes - 1.

2 years agoIntroduced njs_vm_bind_handler().
Dmitry Volyntsev [Fri, 30 Jun 2023 01:58:45 +0000 (18:58 -0700)]
Introduced njs_vm_bind_handler().

2 years agoImproved Error.prototype.toString().
Dmitry Volyntsev [Thu, 29 Jun 2023 05:15:59 +0000 (22:15 -0700)]
Improved Error.prototype.toString().

Making method more generic by using njs_vm_property() when looking for
"name" and "message" properties in the prototype chain.

2 years agoUsing addon module API to unify injecting of external objects.
Dmitry Volyntsev [Thu, 29 Jun 2023 05:15:57 +0000 (22:15 -0700)]
Using addon module API to unify injecting of external objects.

2 years agoRemoved inappropriate "prototype" property for Math object.
Dmitry Volyntsev [Mon, 26 Jun 2023 23:47:17 +0000 (16:47 -0700)]
Removed inappropriate "prototype" property for Math object.

2 years agoFetch: fixed setting of Content-Type header.
Dmitry Volyntsev [Thu, 22 Jun 2023 22:40:36 +0000 (15:40 -0700)]
Fetch: fixed setting of Content-Type header.

Previously, Content-Type was set unconditionally to
"text/plain;charset=UTF-8" when fetch request contained a string body.
This may overlap with user's Content-Type.

The fix is to set the header only if it was not set before.

This fixes #654 issue on Github.

2 years agoXML: replaced Error with more suitable exception where approriate.
Dmitry Volyntsev [Thu, 22 Jun 2023 22:37:16 +0000 (15:37 -0700)]
XML: replaced Error with more suitable exception where approriate.

2 years agoZlib: replaced Error with more suitable exception where approriate.
Dmitry Volyntsev [Wed, 21 Jun 2023 23:30:12 +0000 (16:30 -0700)]
Zlib: replaced Error with more suitable exception where approriate.

2 years agoWebCrypto: added back custom exception types using new public API.
Dmitry Volyntsev [Wed, 21 Jun 2023 23:30:00 +0000 (16:30 -0700)]
WebCrypto: added back custom exception types using new public API.

In f1432043a6a4, when rewriting webcrypto module using public API all
the exceptions types were squashed into a single Error type. This patch
reintroduces the standard exception types back using new API.

2 years agoQueryString: added back custom exception types using new public API.
Dmitry Volyntsev [Wed, 21 Jun 2023 23:29:51 +0000 (16:29 -0700)]
QueryString: added back custom exception types using new public API.

In fd956d2a25a3, when rewriting querystring module using public API all
the exceptions types were squashed into a single Error type. This patch
reintroduces the standard exception types back using new API.

2 years agoCrypto: added back custom exception types using new public API.
Dmitry Volyntsev [Wed, 21 Jun 2023 23:29:48 +0000 (16:29 -0700)]
Crypto: added back custom exception types using new public API.

In b2cbf06ba017, when rewriting crypto module using public API all the
exceptions types were squashed into a single Error type. This patch
reintroduces the standard exception types back using new API.

2 years agoFS: added back custom exception types using new public API.
Dmitry Volyntsev [Wed, 21 Jun 2023 23:29:45 +0000 (16:29 -0700)]
FS: added back custom exception types using new public API.

In 18385a4a90ad, when rewriting FS module using public API all the
exceptions types were squashed into a single Error type. This patch
reintroduces the standard exception types back using new API.

2 years agoAdded public API to throw standard exceptions.
Dmitry Volyntsev [Wed, 21 Jun 2023 23:17:42 +0000 (16:17 -0700)]
Added public API to throw standard exceptions.

2 years agoTypes: updated compilerOptions.lib in tsconfig.json.
Jakub Jirutka [Sat, 10 Jun 2023 22:43:33 +0000 (00:43 +0200)]
Types: updated compilerOptions.lib in tsconfig.json.

2 years agoTypes: added TS types for TextDecoder and TextEncoder.
Jakub Jirutka [Sat, 10 Jun 2023 22:37:36 +0000 (00:37 +0200)]
Types: added TS types for TextDecoder and TextEncoder.

2 years agoFixed Date.parse() with ISO-8601 format and UTC time offset.
Dmitry Volyntsev [Tue, 13 Jun 2023 05:04:04 +0000 (22:04 -0700)]
Fixed Date.parse() with ISO-8601 format and UTC time offset.

2 years agoFixed Date.parse() with ISO-8601 date-only forms.
Dmitry Volyntsev [Tue, 13 Jun 2023 03:51:54 +0000 (20:51 -0700)]
Fixed Date.parse() with ISO-8601 date-only forms.

According to the spec when the UTC offset representation is absent,
date-only forms are interpreted as a UTC time and date-time forms
are interpreted as a local time.

2 years agoTypes: removed descryption for methods removed in 4df790f42ce7.
Dmitry Volyntsev [Wed, 7 Jun 2023 04:33:46 +0000 (21:33 -0700)]
Types: removed descryption for methods removed in 4df790f42ce7.

Since the disctinction between byte strings and ordinary strings
is eliminated the NjsByteString type is also removed.

2 years agoModules: renaming ngx_js_conf_t to ngx_js_loc_conf_t.
Dmitry Volyntsev [Wed, 7 Jun 2023 04:31:39 +0000 (21:31 -0700)]
Modules: renaming ngx_js_conf_t to ngx_js_loc_conf_t.

2 years agoTypes: fixed typos.
Dmitry Volyntsev [Tue, 6 Jun 2023 01:21:07 +0000 (18:21 -0700)]
Types: fixed typos.

2 years agoHTTP: fixed setting of Location header.
Dmitry Volyntsev [Tue, 6 Jun 2023 01:21:06 +0000 (18:21 -0700)]
HTTP: fixed setting of Location header.

Previously, r.headersOut['Location'] setter did not update
r->headers_out.location. As a result a client might get two
Location headers.

This fixes #648 issue on Github.

2 years agoHTTP: deduplicated special header handlers for nginx <= 1.22.
Dmitry Volyntsev [Tue, 6 Jun 2023 01:21:06 +0000 (18:21 -0700)]
HTTP: deduplicated special header handlers for nginx <= 1.22.

3 years agoTests: removed excessive tab characters from js_fetch_objects.t.
Dmitry Volyntsev [Mon, 6 Feb 2023 17:36:14 +0000 (09:36 -0800)]
Tests: removed excessive tab characters from js_fetch_objects.t.

3 years agoTests: fixed js tests for Fetch API for nginx-1.22 and below.
Dmitry Volyntsev [Mon, 6 Feb 2023 17:36:13 +0000 (09:36 -0800)]
Tests: fixed js tests for Fetch API for nginx-1.22 and below.

The fix is to move a test with multiple headers returned by $http_a
variable under an nginx version check.

2 years agoFixed parsing of invalid for-var statement.
Vadim Zhestikov [Thu, 1 Jun 2023 16:39:27 +0000 (09:39 -0700)]
Fixed parsing of invalid for-var statement.

2 years agoFixed parsing of invalid for-in statement.
Vadim Zhestikov [Thu, 1 Jun 2023 16:39:25 +0000 (09:39 -0700)]
Fixed parsing of invalid for-in statement.

The issue was introduced in: b9d18d4dd34e

2 years agoRandom: prioritise CCRandomGenerateBytes over getentropy on macOs.
David CARLIER [Sun, 28 May 2023 14:36:46 +0000 (15:36 +0100)]
Random: prioritise CCRandomGenerateBytes over getentropy on macOs.

It is recommended approach by Apple itself.

2 years agoParser: improved error message for import statement.
Dmitry Volyntsev [Sat, 27 May 2023 04:54:12 +0000 (21:54 -0700)]
Parser: improved error message for import statement.

This closes #642 issue on Github.

2 years agoAdded %TypedArray%.prototype.toReversed().
Dmitry Volyntsev [Sat, 27 May 2023 04:05:15 +0000 (21:05 -0700)]
Added %TypedArray%.prototype.toReversed().

2 years agoAdded %TypedArray%.prototype.toSorted().
Dmitry Volyntsev [Sat, 27 May 2023 03:58:22 +0000 (20:58 -0700)]
Added %TypedArray%.prototype.toSorted().

2 years agoRemoved dead store introduced in 398f4de34fe7.
Dmitry Volyntsev [Sat, 27 May 2023 03:58:19 +0000 (20:58 -0700)]
Removed dead store introduced in 398f4de34fe7.

Found by Coverity (CID 1530432).

2 years agoFixed parsing of for-in loops.
Vadim Zhestikov [Sat, 27 May 2023 02:43:24 +0000 (19:43 -0700)]
Fixed parsing of for-in loops.

This fixes parsing for input like: for (a(b * in d) ;

The issue was introduced in 283ae119d121 (0.7.9).

2 years agoIntroduced Array.prototype.toReversed().
Dmitry Volyntsev [Sat, 27 May 2023 02:13:41 +0000 (19:13 -0700)]
Introduced Array.prototype.toReversed().

2 years agoIntroduced Array.prototype.toSpliced().
Dmitry Volyntsev [Sat, 27 May 2023 02:13:41 +0000 (19:13 -0700)]
Introduced Array.prototype.toSpliced().

2 years agoHTTP: throwing an exception in r.internalRedirect() while filtering.
Dmitry Volyntsev [Sat, 27 May 2023 02:13:39 +0000 (19:13 -0700)]
HTTP: throwing an exception in r.internalRedirect() while filtering.

A user is notified explicitly that r.internalRedirect()
is not supported in filters.

2 years agoImplemented Array.prototype.toSorted().
Dmitry Volyntsev [Thu, 25 May 2023 05:04:38 +0000 (22:04 -0700)]
Implemented Array.prototype.toSorted().

2 years agoTypes: added TS types for ngx properties added in 25b55a064e42.
Dmitry Volyntsev [Wed, 24 May 2023 06:47:43 +0000 (23:47 -0700)]
Types: added TS types for ngx properties added in 25b55a064e42.

2 years agoWebCrypto: introduced CryptoKey properties.
Dmitry Volyntsev [Wed, 24 May 2023 03:58:40 +0000 (20:58 -0700)]
WebCrypto: introduced CryptoKey properties.

The following properties for CryptoKey were added:
    algorithm, extractable, type, usages.

2 years agoWebCrypto: making njs_webcrypto_key_t more compact by using union.
Dmitry Volyntsev [Tue, 23 May 2023 05:48:59 +0000 (22:48 -0700)]
WebCrypto: making njs_webcrypto_key_t more compact by using union.

2 years agoWebCrypto: sorted njs_webcrypto_alg accoding to njs_webcrypto_alg_t.
Dmitry Volyntsev [Tue, 23 May 2023 05:48:58 +0000 (22:48 -0700)]
WebCrypto: sorted njs_webcrypto_alg accoding to njs_webcrypto_alg_t.

So njs_webcrypto_alg[alg->type] can be used to get the algorithm name.

2 years agoTests: imported nginx modules tests from nginx-tests.
Dmitry Volyntsev [Tue, 23 May 2023 00:59:47 +0000 (17:59 -0700)]
Tests: imported nginx modules tests from nginx-tests.

2 years agoRemoved leftover String.prototype.toBytes() from benchmark test.
Dmitry Volyntsev [Sat, 20 May 2023 04:29:23 +0000 (21:29 -0700)]
Removed leftover String.prototype.toBytes() from benchmark test.

The String.prototype.toBytes() and friends were removed in
4df790f42ce7.

2 years agoShell: removed support for building with GNU readline.
Dmitry Volyntsev [Sat, 20 May 2023 03:22:16 +0000 (20:22 -0700)]
Shell: removed support for building with GNU readline.

2 years agoShell: improved working with libedit.
Dmitry Volyntsev [Sat, 20 May 2023 03:22:16 +0000 (20:22 -0700)]
Shell: improved working with libedit.

Previously, libedit unlike GNU readline does not reinstall
rl_callback_handler_install handler after the handler was called.  As a
result make shell_test executed ~20 times longer with libedit.

The fix is to reinstall the rl_callback_handler_install handler
explicitely every time the handler is invoked.

2 years agoFS: added support of OpenBSD for fs.stat() and friends.
Dmitry Volyntsev [Sat, 20 May 2023 03:22:15 +0000 (20:22 -0700)]
FS: added support of OpenBSD for fs.stat() and friends.

2 years agoAdded support of regular expressions not supported directly by PCRE2.
Dmitry Volyntsev [Sat, 20 May 2023 03:22:14 +0000 (20:22 -0700)]
Added support of regular expressions not supported directly by PCRE2.

The following patterns were fixed:
    `[]` - matches nothing, previously was rejected as invalid expression.
    `[^]` - matched any character, unlike `.` this syntax matches new
        line, previously was rejected as invalid expression.
    `++`, `*+`, `?+` - are rejected now, whereas in PCRE2 they are considered
        valid possessive quantifiers.

2 years agoImplemented Array.from().
Dmitry Volyntsev [Fri, 19 May 2023 01:33:36 +0000 (18:33 -0700)]
Implemented Array.from().

2 years agoModules: introduced global nginx properties.
Dmitry Volyntsev [Thu, 18 May 2023 04:16:19 +0000 (21:16 -0700)]
Modules: introduced global nginx properties.

The following properties were introduced:
    ngx.build - an optional nginx build name, corresponds to
        --build=name argument of configure script, by default is "".
    ngx.conf_file_path - the file path to current nginx configuration
        file.
    ngx.error_log_path - the file path to current error log file.
    ngx.prefix - the directory that keeps server files.
    ngx.version - the nginx version as a string, for example: "1.25.0".
    ngx.version_number - the nginx version as a number, for example:
        1025000.

2 years agoChange: removed deprecated r.requestBody and r.responseBody.
Dmitry Volyntsev [Thu, 18 May 2023 00:11:41 +0000 (17:11 -0700)]
Change: removed deprecated r.requestBody and r.responseBody.

Both properties were deprecated since 0.5.0.

2 years agoFixed implicit name for a function expression declared in arrays.
Dmitry Volyntsev [Wed, 17 May 2023 07:39:56 +0000 (00:39 -0700)]
Fixed implicit name for a function expression declared in arrays.

2 years agoFixed evaluation of computed property names with function expressions.
Dmitry Volyntsev [Wed, 17 May 2023 07:39:45 +0000 (00:39 -0700)]
Fixed evaluation of computed property names with function expressions.

Previously, while evaluating a property name expression with a function
expression as the right side, the evaluation modified the value used to
compute the property name in-place.  The in-place modification changes
values not intended to be changed.

The issue was introduced in 74d30c2d70f3 (0.7.8).

This fixes #640 issue on Github.

3 years agoAlways use a sharp (#) symbol as the sed separator.
Sergey A. Osokin [Fri, 12 May 2023 23:38:29 +0000 (19:38 -0400)]
Always use a sharp (#) symbol as the sed separator.

sed(1) command line utility may fail with the following error:
sed: 1: "s, at EXTRA_LIBS@,-lm   -L ...": bad in substitute command: '-'
when a replacement for @EXTRA_LIBS@ contains a comma symbol.

2 years agoRemoved unneeded variable after fd956d2a25a3.
Dmitry Volyntsev [Wed, 17 May 2023 03:58:23 +0000 (20:58 -0700)]
Removed unneeded variable after fd956d2a25a3.

3 years agoModules: added options to disable parts dependant on 3rd party libs.
Dmitry Volyntsev [Thu, 11 May 2023 05:36:53 +0000 (22:36 -0700)]
Modules: added options to disable parts dependant on 3rd party libs.

The following environment variables are added: NJS_OPENSSL, NJS_LIBXSLT,
NJS_ZLIB.  When a variable evaluates to "NO" the part of the module
related to the corresponsing library is disabled.

For example to disable libxslt related code:
    NJS_LIBXSLT=NO ./configure  .. --add-module=/path/to/njs/module