securenow 8.11.2 → 8.11.3

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/register.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- /**
2
- * SecureNow Register Module TypeScript Declarations
3
- *
4
- * Main entry point for Node.js/Express/Fastify/NestJS applications.
5
- * This module is automatically loaded when using NODE_OPTIONS="-r securenow/register"
6
- */
7
-
8
- /**
1
+ /**
2
+ * SecureNow Register Module TypeScript Declarations
3
+ *
4
+ * Main entry point for Node.js/Express/Fastify/NestJS applications.
5
+ * This module is automatically loaded when using NODE_OPTIONS="-r securenow/register"
6
+ */
7
+
8
+ /**
9
9
  * Configuration:
10
10
  *
11
11
  * Local development reads .securenow/credentials.json. Run
@@ -17,28 +17,28 @@
17
17
  * generated JSON to .securenow/credentials.json in the running app.
18
18
  *
19
19
  * Legacy env vars are fallback-only for existing installs.
20
- */
21
-
22
- // This module has side effects (initializes OpenTelemetry)
23
- // It's typically used via NODE_OPTIONS, not imported directly
24
- export {};
25
-
26
- /**
27
- * @example
28
- * ```bash
29
- * # Using with Node.js preload
30
- * NODE_OPTIONS="-r securenow/register" node app.js
31
- * ```
32
- *
33
- * @example
34
- * ```bash
35
- * # Using with PM2
36
- * pm2 start app.js --node-args="-r securenow/register"
37
- * ```
38
- *
39
- * @example
40
- * ```javascript
41
- * // ecosystem.config.js
20
+ */
21
+
22
+ // This module has side effects (initializes OpenTelemetry)
23
+ // It's typically used via NODE_OPTIONS, not imported directly
24
+ export {};
25
+
26
+ /**
27
+ * @example
28
+ * ```bash
29
+ * # Using with Node.js preload
30
+ * NODE_OPTIONS="-r securenow/register" node app.js
31
+ * ```
32
+ *
33
+ * @example
34
+ * ```bash
35
+ * # Using with PM2
36
+ * pm2 start app.js --node-args="-r securenow/register"
37
+ * ```
38
+ *
39
+ * @example
40
+ * ```javascript
41
+ * // ecosystem.config.js
42
42
  * module.exports = {
43
43
  * apps: [{
44
44
  * name: 'my-app',
@@ -47,15 +47,15 @@ export {};
47
47
  * // Local and production use .securenow/credentials.json.
48
48
  * }]
49
49
  * };
50
- * ```
51
- *
52
- * @example
53
- * ```typescript
54
- * // Explicit import (optional, mainly for side effects)
55
- * import 'securenow/register';
56
- *
57
- * import express from 'express';
58
- * const app = express();
59
- * // Your app code...
60
- * ```
61
- */
50
+ * ```
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // Explicit import (optional, mainly for side effects)
55
+ * import 'securenow/register';
56
+ *
57
+ * import express from 'express';
58
+ * const app = express();
59
+ * // Your app code...
60
+ * ```
61
+ */
package/register.js CHANGED
@@ -1,44 +1,44 @@
1
- // securenow/register.js — the only preload customers need:
2
- // node --require securenow/register app.js
3
- //
4
- // For ESM apps ("type": "module"), this file auto-registers the
5
- // OpenTelemetry ESM loader hook via module.register() (Node >=20.6).
6
- // On older Node versions it falls back to a warning.
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
13
- (() => {
14
- try {
15
- const fs = require('fs');
16
- const path = require('path');
17
- const pkgPath = path.resolve(process.cwd(), 'package.json');
18
- if (!fs.existsSync(pkgPath)) return;
19
-
20
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8').replace(/^\uFEFF/, ''));
21
- if (pkg.type !== 'module') return;
22
-
23
- // Already registered via --import?
24
- const execArgv = process.execArgv.join(' ');
25
- if (execArgv.includes('hook.mjs') || execArgv.includes('import-in-the-middle')) return;
26
-
27
- // Node >=20.6 exposes module.register() for programmatic ESM hooks
28
- const mod = require('node:module');
29
- if (typeof mod.register !== 'function') {
30
- console.warn('[securenow] ESM app detected but Node %s lacks module.register().', process.version);
31
- console.warn('[securenow] Upgrade to Node >=20.6 or add: --import @opentelemetry/instrumentation/hook.mjs');
32
- return;
33
- }
34
-
35
- const { pathToFileURL } = require('node:url');
36
- mod.register('@opentelemetry/instrumentation/hook.mjs', pathToFileURL(__filename));
37
- console.log('[securenow] ESM loader hook auto-registered (module.register)');
38
- } catch (_) {
39
- // Non-fatal — tracing.js will show its own ESM warning if the hook is missing
40
- }
41
- })();
42
-
43
- // 2. Run the OTel SDK setup
44
- require('./tracing');
1
+ // securenow/register.js — the only preload customers need:
2
+ // node --require securenow/register app.js
3
+ //
4
+ // For ESM apps ("type": "module"), this file auto-registers the
5
+ // OpenTelemetry ESM loader hook via module.register() (Node >=20.6).
6
+ // On older Node versions it falls back to a warning.
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
13
+ (() => {
14
+ try {
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+ const pkgPath = path.resolve(process.cwd(), 'package.json');
18
+ if (!fs.existsSync(pkgPath)) return;
19
+
20
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8').replace(/^\uFEFF/, ''));
21
+ if (pkg.type !== 'module') return;
22
+
23
+ // Already registered via --import?
24
+ const execArgv = process.execArgv.join(' ');
25
+ if (execArgv.includes('hook.mjs') || execArgv.includes('import-in-the-middle')) return;
26
+
27
+ // Node >=20.6 exposes module.register() for programmatic ESM hooks
28
+ const mod = require('node:module');
29
+ if (typeof mod.register !== 'function') {
30
+ console.warn('[securenow] ESM app detected but Node %s lacks module.register().', process.version);
31
+ console.warn('[securenow] Upgrade to Node >=20.6 or add: --import @opentelemetry/instrumentation/hook.mjs');
32
+ return;
33
+ }
34
+
35
+ const { pathToFileURL } = require('node:url');
36
+ mod.register('@opentelemetry/instrumentation/hook.mjs', pathToFileURL(__filename));
37
+ console.log('[securenow] ESM loader hook auto-registered (module.register)');
38
+ } catch (_) {
39
+ // Non-fatal — tracing.js will show its own ESM warning if the hook is missing
40
+ }
41
+ })();
42
+
43
+ // 2. Run the OTel SDK setup
44
+ require('./tracing');
package/resolve-ip.js CHANGED
@@ -1,5 +1,5 @@
1
- 'use strict';
2
-
1
+ 'use strict';
2
+
3
3
  const os = require('os');
4
4
  const appConfig = require('./app-config');
5
5
 
@@ -121,20 +121,20 @@ function resolveClientIpWithDetails(request) {
121
121
 
122
122
  return details;
123
123
  }
124
-
125
- /**
126
- * Resolve the real client IP from an HTTP request, respecting trusted proxies.
127
- * Reads X-Forwarded-For / X-Real-IP only when the direct connection comes
128
- * from a private/trusted proxy IP. Prevents client-side IP spoofing.
129
- */
124
+
125
+ /**
126
+ * Resolve the real client IP from an HTTP request, respecting trusted proxies.
127
+ * Reads X-Forwarded-For / X-Real-IP only when the direct connection comes
128
+ * from a private/trusted proxy IP. Prevents client-side IP spoofing.
129
+ */
130
130
  function resolveClientIp(request) {
131
131
  return resolveClientIpWithDetails(request).ip || '';
132
132
  }
133
-
134
- /**
135
- * Resolve IP from a raw TCP socket (no HTTP headers available).
136
- * Normalizes IPv6-mapped IPv4 addresses.
137
- */
133
+
134
+ /**
135
+ * Resolve IP from a raw TCP socket (no HTTP headers available).
136
+ * Normalizes IPv6-mapped IPv4 addresses.
137
+ */
138
138
  function resolveSocketIp(socket) {
139
139
  const raw = socket?.remoteAddress || '';
140
140
  return normalizeIp(raw);
@@ -111,12 +111,14 @@
111
111
  "userId": "attributes_string['enduser.id']",
112
112
  "sessionId": "attributes_string['session.id']",
113
113
  "ip": "attributes_string['http.client_ip']",
114
- "userAgent": "attributes_string['http.user_agent']",
114
+ "userAgent": "attributes_string['user_agent.original']",
115
115
  "severity": "severity_text",
116
116
  "attributes.string": "attributes_string['<custom-key>']",
117
117
  "attributes.number": "attributes_number['<custom-key>']",
118
118
  "attributes.boolean": "attributes_bool['<custom-key>']"
119
119
  },
120
+ "reservedAttributePrefixes": ["event.", "enduser.", "session.", "http.", "service.", "securenow.", "client."],
121
+ "reservedAttributeNote": "Custom attribute keys with a reserved prefix are stored as attr.<key>. Events keep the sender-supplied timestamp and carry no event ID. client.asn / client.as_org are added from ip only when the instance has ASN enrichment.",
120
122
  "recommendedAuthenticationEvents": [
121
123
  "auth.login.failure",
122
124
  "auth.login.success",