securenow 5.0.0 → 5.0.2
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/CONSUMING-APPS-GUIDE.md +415 -0
- package/NPM_README.md +1328 -0
- package/docs/ALL-FRAMEWORKS-QUICKSTART.md +455 -0
- package/docs/ENVIRONMENT-VARIABLES.md +652 -0
- package/docs/EXPRESS-SETUP-GUIDE.md +720 -0
- package/docs/INDEX.md +206 -147
- package/docs/NEXTJS-SETUP-COMPLETE.md +795 -0
- package/package.json +4 -2
- package/tracing.d.ts +182 -182
- package/tracing.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securenow",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "OpenTelemetry instrumentation for Node.js and Next.js - Send traces and logs to SigNoz or any OTLP backend",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "register.js",
|
|
@@ -90,7 +90,9 @@
|
|
|
90
90
|
"web-vite.mjs",
|
|
91
91
|
"examples/",
|
|
92
92
|
"docs/",
|
|
93
|
-
"README.md"
|
|
93
|
+
"README.md",
|
|
94
|
+
"NPM_README.md",
|
|
95
|
+
"CONSUMING-APPS-GUIDE.md"
|
|
94
96
|
],
|
|
95
97
|
"dependencies": {
|
|
96
98
|
"@opentelemetry/api": "1.7.0",
|
package/tracing.d.ts
CHANGED
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SecureNow Tracing Module TypeScript Declarations
|
|
3
|
-
*
|
|
4
|
-
* Core tracing functionality for Node.js applications.
|
|
5
|
-
* This is typically loaded via register.js, not imported directly.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Default sensitive fields that are automatically redacted from request bodies
|
|
10
|
-
*/
|
|
11
|
-
export const DEFAULT_SENSITIVE_FIELDS: readonly string[];
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Redact sensitive fields from an object (recursively)
|
|
15
|
-
*
|
|
16
|
-
* @param obj - Object to redact (can be nested)
|
|
17
|
-
* @param sensitiveFields - Array of field names to redact (case-insensitive substring match)
|
|
18
|
-
* @returns Redacted copy of the object
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { redactSensitiveData } from 'securenow/tracing';
|
|
23
|
-
*
|
|
24
|
-
* const data = {
|
|
25
|
-
* email: 'user@example.com',
|
|
26
|
-
* password: 'secret123',
|
|
27
|
-
* nested: {
|
|
28
|
-
* api_key: 'sk_live_abc123'
|
|
29
|
-
* }
|
|
30
|
-
* };
|
|
31
|
-
*
|
|
32
|
-
* const redacted = redactSensitiveData(data);
|
|
33
|
-
* // Result: {
|
|
34
|
-
* // email: 'user@example.com',
|
|
35
|
-
* // password: '[REDACTED]',
|
|
36
|
-
* // nested: { api_key: '[REDACTED]' }
|
|
37
|
-
* // }
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export function redactSensitiveData<T = any>(
|
|
41
|
-
obj: T,
|
|
42
|
-
sensitiveFields?: string[]
|
|
43
|
-
): T;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Redact sensitive data from GraphQL query strings
|
|
47
|
-
*
|
|
48
|
-
* @param query - GraphQL query string
|
|
49
|
-
* @param sensitiveFields - Array of field names to redact
|
|
50
|
-
* @returns Redacted query string
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* import { redactGraphQLQuery } from 'securenow/tracing';
|
|
55
|
-
*
|
|
56
|
-
* const query = `
|
|
57
|
-
* mutation {
|
|
58
|
-
* login(email: "user@example.com", password: "secret123") {
|
|
59
|
-
* token
|
|
60
|
-
* }
|
|
61
|
-
* }
|
|
62
|
-
* `;
|
|
63
|
-
*
|
|
64
|
-
* const redacted = redactGraphQLQuery(query);
|
|
65
|
-
* // Result: mutation { login(email: "user@example.com", password: "[REDACTED]") { token } }
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
export function redactGraphQLQuery(
|
|
69
|
-
query: string,
|
|
70
|
-
sensitiveFields?: string[]
|
|
71
|
-
): string;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* OpenTelemetry Logger interface
|
|
75
|
-
*/
|
|
76
|
-
export interface Logger {
|
|
77
|
-
emit(logRecord: LogRecord): void;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* OpenTelemetry LogRecord interface
|
|
82
|
-
*/
|
|
83
|
-
export interface LogRecord {
|
|
84
|
-
/**
|
|
85
|
-
* Severity number (OpenTelemetry standard)
|
|
86
|
-
* 5 = DEBUG, 9 = INFO, 13 = WARN, 17 = ERROR
|
|
87
|
-
*/
|
|
88
|
-
severityNumber: number;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Human-readable severity text
|
|
92
|
-
*/
|
|
93
|
-
severityText: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | string;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Log message body
|
|
97
|
-
*/
|
|
98
|
-
body: string;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Structured attributes for filtering/searching
|
|
102
|
-
*/
|
|
103
|
-
attributes?: Record<string, any>;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* OpenTelemetry LoggerProvider interface
|
|
108
|
-
*/
|
|
109
|
-
export interface LoggerProvider {
|
|
110
|
-
getLogger(name: string, version?: string): Logger;
|
|
111
|
-
shutdown?(): Promise<void> | void;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Get a logger instance for sending structured logs to SigNoz
|
|
116
|
-
*
|
|
117
|
-
* @param name - Logger name (e.g., 'my-service', 'auth-module')
|
|
118
|
-
* @param version - Logger version (optional, defaults to '1.0.0')
|
|
119
|
-
* @returns Logger instance or null if logging is not enabled
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```typescript
|
|
123
|
-
* import { getLogger } from 'securenow/tracing';
|
|
124
|
-
*
|
|
125
|
-
* const logger = getLogger('my-service', '1.0.0');
|
|
126
|
-
*
|
|
127
|
-
* if (logger) {
|
|
128
|
-
* logger.emit({
|
|
129
|
-
* severityNumber: 9,
|
|
130
|
-
* severityText: 'INFO',
|
|
131
|
-
* body: 'User logged in',
|
|
132
|
-
* attributes: {
|
|
133
|
-
* userId: 123,
|
|
134
|
-
* username: 'john',
|
|
135
|
-
* },
|
|
136
|
-
* });
|
|
137
|
-
* }
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
export function getLogger(name?: string, version?: string): Logger | null;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Check if logging is enabled
|
|
144
|
-
*
|
|
145
|
-
* @returns true if SECURENOW_LOGGING_ENABLED=1, false otherwise
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```typescript
|
|
149
|
-
* import { isLoggingEnabled } from 'securenow/tracing';
|
|
150
|
-
*
|
|
151
|
-
* if (isLoggingEnabled()) {
|
|
152
|
-
* console.log('Logging is enabled');
|
|
153
|
-
* }
|
|
154
|
-
* ```
|
|
155
|
-
*/
|
|
156
|
-
export function isLoggingEnabled(): boolean;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* The OpenTelemetry LoggerProvider instance (if logging is enabled)
|
|
160
|
-
* Use getLogger() instead of accessing this directly
|
|
161
|
-
*/
|
|
162
|
-
export const loggerProvider: LoggerProvider | null;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Environment Variables (same as register.js):
|
|
166
|
-
*
|
|
167
|
-
* Required:
|
|
168
|
-
* - SECURENOW_APPID=your-app-name
|
|
169
|
-
* - SECURENOW_INSTANCE=http://host:4318
|
|
170
|
-
*
|
|
171
|
-
* Optional:
|
|
172
|
-
* - SECURENOW_LOGGING_ENABLED=1 # Enable logging (default: 1)
|
|
173
|
-
* - SECURENOW_NO_UUID=1
|
|
174
|
-
* - SECURENOW_STRICT=1
|
|
175
|
-
* - SECURENOW_CAPTURE_BODY=1
|
|
176
|
-
* - SECURENOW_MAX_BODY_SIZE=10240
|
|
177
|
-
* - SECURENOW_SENSITIVE_FIELDS=field1,field2
|
|
178
|
-
* - SECURENOW_DISABLE_INSTRUMENTATIONS=pkg1,pkg2
|
|
179
|
-
* - OTEL_LOG_LEVEL=info|debug
|
|
180
|
-
* - SECURENOW_TEST_SPAN=1
|
|
181
|
-
* - OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=... # Override logs endpoint
|
|
182
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* SecureNow Tracing Module TypeScript Declarations
|
|
3
|
+
*
|
|
4
|
+
* Core tracing functionality for Node.js applications.
|
|
5
|
+
* This is typically loaded via register.js, not imported directly.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Default sensitive fields that are automatically redacted from request bodies
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_SENSITIVE_FIELDS: readonly string[];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Redact sensitive fields from an object (recursively)
|
|
15
|
+
*
|
|
16
|
+
* @param obj - Object to redact (can be nested)
|
|
17
|
+
* @param sensitiveFields - Array of field names to redact (case-insensitive substring match)
|
|
18
|
+
* @returns Redacted copy of the object
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { redactSensitiveData } from 'securenow/tracing';
|
|
23
|
+
*
|
|
24
|
+
* const data = {
|
|
25
|
+
* email: 'user@example.com',
|
|
26
|
+
* password: 'secret123',
|
|
27
|
+
* nested: {
|
|
28
|
+
* api_key: 'sk_live_abc123'
|
|
29
|
+
* }
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* const redacted = redactSensitiveData(data);
|
|
33
|
+
* // Result: {
|
|
34
|
+
* // email: 'user@example.com',
|
|
35
|
+
* // password: '[REDACTED]',
|
|
36
|
+
* // nested: { api_key: '[REDACTED]' }
|
|
37
|
+
* // }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function redactSensitiveData<T = any>(
|
|
41
|
+
obj: T,
|
|
42
|
+
sensitiveFields?: string[]
|
|
43
|
+
): T;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Redact sensitive data from GraphQL query strings
|
|
47
|
+
*
|
|
48
|
+
* @param query - GraphQL query string
|
|
49
|
+
* @param sensitiveFields - Array of field names to redact
|
|
50
|
+
* @returns Redacted query string
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* import { redactGraphQLQuery } from 'securenow/tracing';
|
|
55
|
+
*
|
|
56
|
+
* const query = `
|
|
57
|
+
* mutation {
|
|
58
|
+
* login(email: "user@example.com", password: "secret123") {
|
|
59
|
+
* token
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
* `;
|
|
63
|
+
*
|
|
64
|
+
* const redacted = redactGraphQLQuery(query);
|
|
65
|
+
* // Result: mutation { login(email: "user@example.com", password: "[REDACTED]") { token } }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function redactGraphQLQuery(
|
|
69
|
+
query: string,
|
|
70
|
+
sensitiveFields?: string[]
|
|
71
|
+
): string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* OpenTelemetry Logger interface
|
|
75
|
+
*/
|
|
76
|
+
export interface Logger {
|
|
77
|
+
emit(logRecord: LogRecord): void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* OpenTelemetry LogRecord interface
|
|
82
|
+
*/
|
|
83
|
+
export interface LogRecord {
|
|
84
|
+
/**
|
|
85
|
+
* Severity number (OpenTelemetry standard)
|
|
86
|
+
* 5 = DEBUG, 9 = INFO, 13 = WARN, 17 = ERROR
|
|
87
|
+
*/
|
|
88
|
+
severityNumber: number;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Human-readable severity text
|
|
92
|
+
*/
|
|
93
|
+
severityText: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | string;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Log message body
|
|
97
|
+
*/
|
|
98
|
+
body: string;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Structured attributes for filtering/searching
|
|
102
|
+
*/
|
|
103
|
+
attributes?: Record<string, any>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* OpenTelemetry LoggerProvider interface
|
|
108
|
+
*/
|
|
109
|
+
export interface LoggerProvider {
|
|
110
|
+
getLogger(name: string, version?: string): Logger;
|
|
111
|
+
shutdown?(): Promise<void> | void;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Get a logger instance for sending structured logs to SigNoz
|
|
116
|
+
*
|
|
117
|
+
* @param name - Logger name (e.g., 'my-service', 'auth-module')
|
|
118
|
+
* @param version - Logger version (optional, defaults to '1.0.0')
|
|
119
|
+
* @returns Logger instance or null if logging is not enabled
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* import { getLogger } from 'securenow/tracing';
|
|
124
|
+
*
|
|
125
|
+
* const logger = getLogger('my-service', '1.0.0');
|
|
126
|
+
*
|
|
127
|
+
* if (logger) {
|
|
128
|
+
* logger.emit({
|
|
129
|
+
* severityNumber: 9,
|
|
130
|
+
* severityText: 'INFO',
|
|
131
|
+
* body: 'User logged in',
|
|
132
|
+
* attributes: {
|
|
133
|
+
* userId: 123,
|
|
134
|
+
* username: 'john',
|
|
135
|
+
* },
|
|
136
|
+
* });
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export function getLogger(name?: string, version?: string): Logger | null;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Check if logging is enabled
|
|
144
|
+
*
|
|
145
|
+
* @returns true if SECURENOW_LOGGING_ENABLED=1, false otherwise
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* import { isLoggingEnabled } from 'securenow/tracing';
|
|
150
|
+
*
|
|
151
|
+
* if (isLoggingEnabled()) {
|
|
152
|
+
* console.log('Logging is enabled');
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export function isLoggingEnabled(): boolean;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The OpenTelemetry LoggerProvider instance (if logging is enabled)
|
|
160
|
+
* Use getLogger() instead of accessing this directly
|
|
161
|
+
*/
|
|
162
|
+
export const loggerProvider: LoggerProvider | null;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Environment Variables (same as register.js):
|
|
166
|
+
*
|
|
167
|
+
* Required:
|
|
168
|
+
* - SECURENOW_APPID=your-app-name
|
|
169
|
+
* - SECURENOW_INSTANCE=http://host:4318
|
|
170
|
+
*
|
|
171
|
+
* Optional:
|
|
172
|
+
* - SECURENOW_LOGGING_ENABLED=1 # Enable logging (default: 1)
|
|
173
|
+
* - SECURENOW_NO_UUID=1
|
|
174
|
+
* - SECURENOW_STRICT=1
|
|
175
|
+
* - SECURENOW_CAPTURE_BODY=1
|
|
176
|
+
* - SECURENOW_MAX_BODY_SIZE=10240
|
|
177
|
+
* - SECURENOW_SENSITIVE_FIELDS=field1,field2
|
|
178
|
+
* - SECURENOW_DISABLE_INSTRUMENTATIONS=pkg1,pkg2
|
|
179
|
+
* - OTEL_LOG_LEVEL=info|debug
|
|
180
|
+
* - SECURENOW_TEST_SPAN=1
|
|
181
|
+
* - OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=... # Override logs endpoint
|
|
182
|
+
*/
|
package/tracing.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Env:
|
|
7
7
|
* SECURENOW_APPID=logical-name # or OTEL_SERVICE_NAME=logical-name
|
|
8
8
|
* SECURENOW_NO_UUID=1 # one service.name across all workers
|
|
9
|
-
* SECURENOW_INSTANCE=http://host:4318 # OTLP/HTTP base (default
|
|
9
|
+
* SECURENOW_INSTANCE=http://host:4318 # OTLP/HTTP base (default https://freetrial.securenow.ai:4318)
|
|
10
10
|
* OTEL_EXPORTER_OTLP_ENDPOINT=... # alternative base
|
|
11
11
|
* OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=... # full traces URL
|
|
12
12
|
* OTEL_EXPORTER_OTLP_HEADERS="k=v,k2=v2"
|
|
@@ -109,7 +109,7 @@ function redactGraphQLQuery(query, sensitiveFields = DEFAULT_SENSITIVE_FIELDS) {
|
|
|
109
109
|
})();
|
|
110
110
|
|
|
111
111
|
// -------- endpoints --------
|
|
112
|
-
const endpointBase = (env('SECURENOW_INSTANCE') || env('OTEL_EXPORTER_OTLP_ENDPOINT') || '
|
|
112
|
+
const endpointBase = (env('SECURENOW_INSTANCE') || env('OTEL_EXPORTER_OTLP_ENDPOINT') || 'https://freetrial.securenow.ai:4318').replace(/\/$/, '');
|
|
113
113
|
const tracesUrl = env('OTEL_EXPORTER_OTLP_TRACES_ENDPOINT') || `${endpointBase}/v1/traces`;
|
|
114
114
|
const logsUrl = env('OTEL_EXPORTER_OTLP_LOGS_ENDPOINT') || `${endpointBase}/v1/logs`;
|
|
115
115
|
const headers = parseHeaders(env('OTEL_EXPORTER_OTLP_HEADERS'));
|