securenow 8.11.0 → 8.11.1
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/firewall-only.js +31 -28
- package/internal-thread.js +22 -0
- package/package.json +3 -2
- package/register.js +9 -6
- package/tracing.js +855 -852
package/firewall-only.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// Do nothing inside Node's internal ESM-hooks thread (see internal-thread.js).
|
|
4
|
+
if (require('./internal-thread').inInternalThread()) return;
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* Standalone firewall preload — no OpenTelemetry, no tracing.
|
|
5
8
|
*
|
|
@@ -7,35 +10,35 @@
|
|
|
7
10
|
* node -r securenow/firewall-only app.js
|
|
8
11
|
* NODE_OPTIONS='-r securenow/firewall-only' next start
|
|
9
12
|
*
|
|
10
|
-
* Reads SecureNow runtime credentials from .securenow/*.json. Initialises the
|
|
11
|
-
* HTTP-level firewall when a snk_live_ API key is resolvable.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const appConfig = require('./app-config');
|
|
15
|
-
const firewallOptions = appConfig.resolveFirewallOptions();
|
|
13
|
+
* Reads SecureNow runtime credentials from .securenow/*.json. Initialises the
|
|
14
|
+
* HTTP-level firewall when a snk_live_ API key is resolvable.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const appConfig = require('./app-config');
|
|
18
|
+
const firewallOptions = appConfig.resolveFirewallOptions();
|
|
16
19
|
|
|
17
|
-
// Runtime enable/disable is controlled by the dashboard/API toggle. If a
|
|
18
|
-
// firewall key is present, start sync so the remote toggle can be applied.
|
|
19
|
-
if (firewallOptions.apiKey) {
|
|
20
|
-
require('./firewall').init({
|
|
21
|
-
apiKey: firewallOptions.apiKey,
|
|
22
|
-
appKey: firewallOptions.appKey,
|
|
23
|
-
environment: firewallOptions.environment,
|
|
24
|
-
apiUrl: firewallOptions.apiUrl,
|
|
25
|
-
apiUrlFallbacks: firewallOptions.apiUrlFallbacks,
|
|
26
|
-
versionCheckInterval: firewallOptions.versionCheckInterval,
|
|
27
|
-
syncInterval: firewallOptions.syncInterval,
|
|
28
|
-
failMode: firewallOptions.failMode,
|
|
29
|
-
statusCode: firewallOptions.statusCode,
|
|
30
|
-
log: firewallOptions.log,
|
|
31
|
-
tcp: firewallOptions.tcp,
|
|
32
|
-
iptables: firewallOptions.iptables,
|
|
33
|
-
cloud: firewallOptions.cloud,
|
|
34
|
-
cloudDryRun: firewallOptions.cloudDryRun,
|
|
35
|
-
cloudflare: firewallOptions.cloudflare,
|
|
36
|
-
aws: firewallOptions.aws,
|
|
37
|
-
gcp: firewallOptions.gcp,
|
|
38
|
-
});
|
|
20
|
+
// Runtime enable/disable is controlled by the dashboard/API toggle. If a
|
|
21
|
+
// firewall key is present, start sync so the remote toggle can be applied.
|
|
22
|
+
if (firewallOptions.apiKey) {
|
|
23
|
+
require('./firewall').init({
|
|
24
|
+
apiKey: firewallOptions.apiKey,
|
|
25
|
+
appKey: firewallOptions.appKey,
|
|
26
|
+
environment: firewallOptions.environment,
|
|
27
|
+
apiUrl: firewallOptions.apiUrl,
|
|
28
|
+
apiUrlFallbacks: firewallOptions.apiUrlFallbacks,
|
|
29
|
+
versionCheckInterval: firewallOptions.versionCheckInterval,
|
|
30
|
+
syncInterval: firewallOptions.syncInterval,
|
|
31
|
+
failMode: firewallOptions.failMode,
|
|
32
|
+
statusCode: firewallOptions.statusCode,
|
|
33
|
+
log: firewallOptions.log,
|
|
34
|
+
tcp: firewallOptions.tcp,
|
|
35
|
+
iptables: firewallOptions.iptables,
|
|
36
|
+
cloud: firewallOptions.cloud,
|
|
37
|
+
cloudDryRun: firewallOptions.cloudDryRun,
|
|
38
|
+
cloudflare: firewallOptions.cloudflare,
|
|
39
|
+
aws: firewallOptions.aws,
|
|
40
|
+
gcp: firewallOptions.gcp,
|
|
41
|
+
});
|
|
39
42
|
|
|
40
43
|
const shutdown = () => { try { require('./firewall').shutdown(); } catch (_) {} };
|
|
41
44
|
process.on('SIGINT', shutdown);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Node runs --require preloads inside its internal module-customization-hooks
|
|
5
|
+
* thread too (the worker module.register() starts for ESM loader hooks). The
|
|
6
|
+
* SecureNow preloads must only initialize in application threads: in that
|
|
7
|
+
* internal thread they started a second OpenTelemetry SDK and a second firewall
|
|
8
|
+
* poller, and registered the ESM hook twice ("The 'import-in-the-middle' hook
|
|
9
|
+
* has already been initialized").
|
|
10
|
+
*
|
|
11
|
+
* worker_threads.isInternalThread exists on Node >= 22.14 / 23.7. Older Node has
|
|
12
|
+
* no reliable way to tell that thread from a user Worker, so nothing changes there.
|
|
13
|
+
*/
|
|
14
|
+
function inInternalThread() {
|
|
15
|
+
try {
|
|
16
|
+
return require('node:worker_threads').isInternalThread === true;
|
|
17
|
+
} catch (_) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = { inInternalThread };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securenow",
|
|
3
|
-
"version": "8.11.
|
|
3
|
+
"version": "8.11.1",
|
|
4
4
|
"description": "OpenTelemetry instrumentation for Node.js, Next.js, and Nuxt - Send traces and logs to any OTLP-compatible backend",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "register.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"securenow-mcp": "mcp/server.js"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "node test-app-config.js && node test-resolve-ip.js && node test-otel-defaults.js && node test-telemetry.js && node test-legacy-semconv.js && node test-package-contents.js"
|
|
13
|
+
"test": "node test-app-config.js && node test-resolve-ip.js && node test-otel-defaults.js && node test-telemetry.js && node test-legacy-semconv.js && node test-internal-thread.js && node test-package-contents.js"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"opentelemetry",
|
|
@@ -159,6 +159,7 @@
|
|
|
159
159
|
"firewall.js",
|
|
160
160
|
"challenge.js",
|
|
161
161
|
"otel-defaults.js",
|
|
162
|
+
"internal-thread.js",
|
|
162
163
|
"legacy-semconv.js",
|
|
163
164
|
"rate-limits.js",
|
|
164
165
|
"rate-limits.d.ts",
|
package/register.js
CHANGED
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
// For ESM apps ("type": "module"), this file auto-registers the
|
|
5
5
|
// OpenTelemetry ESM loader hook via module.register() (Node >=20.6).
|
|
6
6
|
// On older Node versions it falls back to a warning.
|
|
7
|
-
'use strict';
|
|
8
|
-
|
|
9
|
-
//
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
// Do nothing inside Node's internal ESM-hooks thread (see internal-thread.js).
|
|
10
|
+
if (require('./internal-thread').inInternalThread()) return;
|
|
11
|
+
|
|
12
|
+
// 1. Auto-register the ESM loader hook so customers never need --import
|
|
10
13
|
(() => {
|
|
11
14
|
try {
|
|
12
15
|
const fs = require('fs');
|
|
@@ -14,7 +17,7 @@
|
|
|
14
17
|
const pkgPath = path.resolve(process.cwd(), 'package.json');
|
|
15
18
|
if (!fs.existsSync(pkgPath)) return;
|
|
16
19
|
|
|
17
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8').replace(/^\uFEFF/, ''));
|
|
20
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8').replace(/^\uFEFF/, ''));
|
|
18
21
|
if (pkg.type !== 'module') return;
|
|
19
22
|
|
|
20
23
|
// Already registered via --import?
|
|
@@ -37,5 +40,5 @@
|
|
|
37
40
|
}
|
|
38
41
|
})();
|
|
39
42
|
|
|
40
|
-
// 2. Run the OTel SDK setup
|
|
41
|
-
require('./tracing');
|
|
43
|
+
// 2. Run the OTel SDK setup
|
|
44
|
+
require('./tracing');
|