@runtime-digital-twin/sdk 1.0.0 → 1.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Wraith On-Call Engineer Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md CHANGED
@@ -209,6 +209,21 @@ import {
209
209
 
210
210
  See the [Quickstart Guide](../../QUICKSTART.md) for complete examples.
211
211
 
212
+ ## Changelog
213
+
214
+ ### v1.1.0
215
+ - Enhanced trace upload with automatic retry
216
+ - Improved CORS support for browser-based services
217
+ - Better error handling and logging
218
+ - Support for demo mode autofix integration
219
+
220
+ ### v1.0.0
221
+ - Initial release
222
+ - Fastify tracing plugin
223
+ - Database query capture
224
+ - HTTP client wrapping
225
+ - Trace bundle writing
226
+
212
227
  ## License
213
228
 
214
229
  MIT
@@ -1 +1 @@
1
- {"version":3,"file":"http-wrapper.d.ts","sourceRoot":"","sources":["../src/http-wrapper.ts"],"names":[],"mappings":"AAwBA;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,EACvI,MAAM,EAAE,MAAM,GAAG,IAAI,QAQtB;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI;IACjC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;IACxI,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAMA;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,OAAO,KAAK,GAAG,OAAO,KAAK,CA2dnE"}
1
+ {"version":3,"file":"http-wrapper.d.ts","sourceRoot":"","sources":["../src/http-wrapper.ts"],"names":[],"mappings":"AAwBA;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,EACvI,MAAM,EAAE,MAAM,GAAG,IAAI,QAQtB;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI;IACjC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;IACxI,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAMA;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,OAAO,KAAK,GAAG,OAAO,KAAK,CA0gBnE"}
@@ -64,10 +64,53 @@ function wrapFetch(originalFetch) {
64
64
  // - If peerService is null → route to mock server (stub)
65
65
  if (peerService) {
66
66
  if (subgraphServices.includes(peerService)) {
67
- // Call is to a service in subgraph - should route to actual service
68
- // TODO: Implement actual service routing (requires service discovery/URL mapping)
69
- // For now, route to mock server as fallback
70
- shouldRouteToMock = true;
67
+ // Call is to a service in subgraph - route to actual service
68
+ // Check for service URL mapping via environment variables
69
+ const serviceUrlEnv = process.env[`${peerService.toUpperCase().replace(/-/g, '_')}_URL`];
70
+ const serviceUrls = process.env.SERVICE_URLS || '';
71
+ // Parse SERVICE_URLS: "service-a:http://localhost:3001,service-b:http://localhost:3002"
72
+ // Note: Split on first ':' only to handle URLs with colons
73
+ const urlMap = new Map();
74
+ if (serviceUrls) {
75
+ for (const mapping of serviceUrls.split(',')) {
76
+ const colonIndex = mapping.indexOf(':');
77
+ if (colonIndex > 0) {
78
+ const service = mapping.substring(0, colonIndex).trim();
79
+ const url = mapping.substring(colonIndex + 1).trim();
80
+ if (service && url) {
81
+ urlMap.set(service, url);
82
+ }
83
+ }
84
+ }
85
+ }
86
+ const serviceUrl = serviceUrlEnv || urlMap.get(peerService);
87
+ if (serviceUrl) {
88
+ // Route to actual service
89
+ try {
90
+ const path = urlObj.pathname + urlObj.search;
91
+ const fullUrl = new URL(path, serviceUrl).toString();
92
+ // Get trace context for propagation
93
+ const { bundle, spanId } = getTraceContext();
94
+ // Make request to actual service with trace headers
95
+ const enhancedInit = {
96
+ ...init,
97
+ headers: {
98
+ ...(init?.headers || {}),
99
+ ...(bundle?.traceId ? { 'x-trace-id': bundle.traceId } : {}),
100
+ ...(spanId ? { 'x-span-id': spanId } : {}),
101
+ },
102
+ };
103
+ return await originalFetch(fullUrl, enhancedInit);
104
+ }
105
+ catch (error) {
106
+ console.warn(`[SDK] Failed to route to ${peerService}: ${error}`);
107
+ shouldRouteToMock = true;
108
+ }
109
+ }
110
+ else {
111
+ // No service URL configured, route to mock
112
+ shouldRouteToMock = true;
113
+ }
71
114
  }
72
115
  else if (stubServices.includes(peerService)) {
73
116
  // Call is to a stubbed service - route to mock server
@@ -55,6 +55,7 @@ export declare function createRedactedValue(originalValue: string, includeHash?:
55
55
  export declare function loadRedactionConfig(configPath?: string): RedactionConfig;
56
56
  /**
57
57
  * Set global redaction config
58
+ * SECURITY: Redaction cannot be disabled - any attempt to set enabled: false will throw an error
58
59
  */
59
60
  export declare function setRedactionConfig(config: Partial<RedactionConfig>): void;
60
61
  /**
@@ -63,38 +64,47 @@ export declare function setRedactionConfig(config: Partial<RedactionConfig>): vo
63
64
  export declare function getRedactionConfig(): RedactionConfig;
64
65
  /**
65
66
  * Reset redaction config to defaults
67
+ * SECURITY: Always ensures enabled = true
66
68
  */
67
69
  export declare function resetRedactionConfig(): void;
68
70
  /**
69
71
  * Check if a header name should be redacted
72
+ * SECURITY: Redaction is always enabled - enabled check removed for enforcement
70
73
  */
71
74
  export declare function shouldRedactHeader(headerName: string): boolean;
72
75
  /**
73
76
  * Check if a query param should be redacted
77
+ * SECURITY: Redaction is always enabled - enabled check removed for enforcement
74
78
  */
75
79
  export declare function shouldRedactQueryParam(paramName: string): boolean;
76
80
  /**
77
81
  * Redact headers in a headers object
82
+ * SECURITY: Redaction is always enforced - enabled check removed
78
83
  */
79
84
  export declare function redactHeaders(headers: Record<string, string | string[] | undefined>): Record<string, string | string[] | undefined>;
80
85
  /**
81
86
  * Redact query parameters
87
+ * SECURITY: Redaction is always enforced - enabled check removed
82
88
  */
83
89
  export declare function redactQueryParams(query: Record<string, any>): Record<string, any>;
84
90
  /**
85
91
  * Redact sensitive fields from a body object (recursive)
92
+ * SECURITY: Redaction is always enforced - enabled check removed
86
93
  */
87
94
  export declare function redactBodyObject(body: any): any;
88
95
  /**
89
96
  * Redact patterns from a body string
97
+ * SECURITY: Redaction is always enforced - enabled check removed
90
98
  */
91
99
  export declare function redactBodyPatterns(body: string): string;
92
100
  /**
93
101
  * Redact a body (handles both string and object)
102
+ * SECURITY: Redaction is always enforced - enabled check removed
94
103
  */
95
104
  export declare function redactBody(body: string | object | null | undefined): string | object | null | undefined;
96
105
  /**
97
106
  * Redact a URL (query params)
107
+ * SECURITY: Redaction is always enforced - enabled check removed
98
108
  */
99
109
  export declare function redactUrl(url: string): string;
100
110
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"redaction.d.ts","sourceRoot":"","sources":["../src/redaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,YAAY,GACZ,cAAc,GACd,aAAa,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAC;IACxB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,+CAA+C;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,sCAAsC;IACtC,KAAK,EAAE,aAAa,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AAU,CACxB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GACvC,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CA8BpC;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA8B7C;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAYhE;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAA4B,CAAC;AAC3D,eAAO,MAAM,sBAAsB,UAAiC,CAAC;AACrE,eAAO,MAAM,qBAAqB,UAAgC,CAAC"}
package/dist/redaction.js CHANGED
@@ -66,8 +66,10 @@ const DEFAULT_SENSITIVE_QUERY_PARAMS = [
66
66
  ];
67
67
  /**
68
68
  * Default sensitive body field names (case-insensitive)
69
+ * Includes PII (Personally Identifiable Information) fields for GDPR/compliance
69
70
  */
70
71
  const DEFAULT_SENSITIVE_BODY_FIELDS = [
72
+ // Authentication & Secrets
71
73
  "password",
72
74
  "passwd",
73
75
  "pwd",
@@ -84,20 +86,86 @@ const DEFAULT_SENSITIVE_BODY_FIELDS = [
84
86
  "secretKey",
85
87
  "client_secret",
86
88
  "clientSecret",
87
- "ssn",
88
- "social_security",
89
+ "pin",
90
+ // Financial Information
89
91
  "credit_card",
90
92
  "creditCard",
91
93
  "card_number",
92
94
  "cardNumber",
93
95
  "cvv",
94
96
  "cvc",
95
- "pin",
97
+ "bank_account",
98
+ "bankAccount",
99
+ "routing_number",
100
+ "routingNumber",
101
+ // PII - Personal Identifiers
102
+ "ssn",
103
+ "social_security",
104
+ "social_security_number",
105
+ "tax_id",
106
+ "taxId",
107
+ "driver_license",
108
+ "driverLicense",
109
+ "passport",
110
+ "national_id",
111
+ "nationalId",
112
+ // PII - Contact Information
113
+ "email",
114
+ "email_address",
115
+ "emailAddress",
116
+ "phone",
117
+ "phone_number",
118
+ "phoneNumber",
119
+ "mobile",
120
+ "mobile_number",
121
+ "mobileNumber",
122
+ "telephone",
123
+ "address",
124
+ "street_address",
125
+ "streetAddress",
126
+ "home_address",
127
+ "homeAddress",
128
+ "billing_address",
129
+ "billingAddress",
130
+ "shipping_address",
131
+ "shippingAddress",
132
+ // PII - Personal Details
133
+ "first_name",
134
+ "firstName",
135
+ "last_name",
136
+ "lastName",
137
+ "full_name",
138
+ "fullName",
139
+ "name",
140
+ "date_of_birth",
141
+ "dateOfBirth",
142
+ "dob",
143
+ "birth_date",
144
+ "birthDate",
145
+ "age",
146
+ "gender",
147
+ "race",
148
+ "ethnicity",
149
+ // PII - Location
150
+ "city",
151
+ "state",
152
+ "province",
153
+ "zip",
154
+ "zip_code",
155
+ "zipCode",
156
+ "postal_code",
157
+ "postalCode",
158
+ "country",
159
+ "latitude",
160
+ "longitude",
161
+ "coordinates",
96
162
  ];
97
163
  /**
98
164
  * Default body patterns to redact (regex)
165
+ * Includes PII pattern detection for comprehensive data protection
99
166
  */
100
167
  const DEFAULT_SENSITIVE_BODY_PATTERNS = [
168
+ // Authentication tokens
101
169
  // Bearer tokens
102
170
  /Bearer\s+[A-Za-z0-9\-_]+\.[A-Za-z0-9\-_]+\.[A-Za-z0-9\-_]*/g,
103
171
  // JWT tokens
@@ -106,8 +174,21 @@ const DEFAULT_SENSITIVE_BODY_PATTERNS = [
106
174
  /(?:api[_-]?key|apikey)[=:]["']?[A-Za-z0-9\-_]{20,}["']?/gi,
107
175
  // AWS access keys
108
176
  /AKIA[0-9A-Z]{16}/g,
177
+ // Financial Information
109
178
  // Credit card numbers (basic pattern)
110
179
  /\b(?:\d{4}[- ]?){3}\d{4}\b/g,
180
+ // PII - Email addresses (pattern-based detection)
181
+ /\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\b/g,
182
+ // PII - Phone numbers (US and international formats)
183
+ /\b\+?[\d\s\-()]{10,}\b/g,
184
+ // PII - Social Security Numbers (US format)
185
+ /\b\d{3}-\d{2}-\d{4}\b/g,
186
+ /\b\d{9}\b/g, // 9 consecutive digits (potential SSN)
187
+ // PII - Dates that might be DOB (MM/DD/YYYY, YYYY-MM-DD, etc.)
188
+ /\b(0[1-9]|1[0-2])[\/\-](0[1-9]|[12]\d|3[01])[\/\-]\d{4}\b/g,
189
+ /\b\d{4}[\/\-](0[1-9]|1[0-2])[\/\-](0[1-9]|[12]\d|3[01])\b/g,
190
+ // PII - IP addresses (may contain sensitive location data)
191
+ /\b(?:\d{1,3}\.){3}\d{1,3}\b/g,
111
192
  ];
112
193
  /**
113
194
  * Build default redaction rules
@@ -150,11 +231,12 @@ function buildDefaultRules() {
150
231
  }
151
232
  /**
152
233
  * Default redaction configuration
234
+ * SECURITY: Redaction is ALWAYS enabled and cannot be disabled for compliance
153
235
  */
154
236
  const DEFAULT_CONFIG = {
155
- enabled: true,
237
+ enabled: true, // Always true - cannot be changed
156
238
  rules: buildDefaultRules(),
157
- hashSalt: "rdt-redaction-salt-v1",
239
+ hashSalt: process.env.REDACTION_SALT || process.env.REDACTION_HASH_SALT || "rdt-redaction-salt-v1",
158
240
  };
159
241
  /**
160
242
  * Global redaction config (can be overridden)
@@ -201,14 +283,20 @@ function loadRedactionConfig(configPath) {
201
283
  if (config.redaction) {
202
284
  const userConfig = config.redaction;
203
285
  // Merge with defaults
286
+ // SECURITY: Always enforce enabled = true, ignore user attempts to disable
204
287
  const mergedConfig = {
205
- enabled: userConfig.enabled ?? true,
288
+ enabled: true, // Always true - cannot be disabled
206
289
  rules: userConfig.overrideDefaults
207
290
  ? userConfig.rules || []
208
291
  : [...buildDefaultRules(), ...(userConfig.rules || [])],
209
292
  overrideDefaults: userConfig.overrideDefaults,
210
293
  hashSalt: userConfig.hashSalt || DEFAULT_CONFIG.hashSalt,
211
294
  };
295
+ // Warn if user tried to disable redaction
296
+ if (userConfig.enabled === false) {
297
+ console.warn('[Redaction] Attempted to disable redaction in config file. ' +
298
+ 'Redaction is always enabled for security compliance. Ignoring enabled: false.');
299
+ }
212
300
  return mergedConfig;
213
301
  }
214
302
  }
@@ -221,11 +309,18 @@ function loadRedactionConfig(configPath) {
221
309
  }
222
310
  /**
223
311
  * Set global redaction config
312
+ * SECURITY: Redaction cannot be disabled - any attempt to set enabled: false will throw an error
224
313
  */
225
314
  function setRedactionConfig(config) {
315
+ // SECURITY: Prevent disabling redaction for compliance
316
+ if (config.enabled === false) {
317
+ throw new Error('Redaction cannot be disabled for security and compliance requirements. ' +
318
+ 'All sensitive data must be redacted before storage.');
319
+ }
226
320
  globalConfig = {
227
321
  ...DEFAULT_CONFIG,
228
322
  ...config,
323
+ enabled: true, // Always enforce enabled = true
229
324
  rules: config.overrideDefaults
230
325
  ? config.rules || []
231
326
  : [...buildDefaultRules(), ...(config.rules || [])],
@@ -239,16 +334,22 @@ function getRedactionConfig() {
239
334
  }
240
335
  /**
241
336
  * Reset redaction config to defaults
337
+ * SECURITY: Always ensures enabled = true
242
338
  */
243
339
  function resetRedactionConfig() {
244
- globalConfig = { ...DEFAULT_CONFIG, rules: buildDefaultRules() };
340
+ globalConfig = {
341
+ ...DEFAULT_CONFIG,
342
+ enabled: true, // Always enforce enabled
343
+ rules: buildDefaultRules()
344
+ };
245
345
  }
246
346
  /**
247
347
  * Check if a header name should be redacted
348
+ * SECURITY: Redaction is always enabled - enabled check removed for enforcement
248
349
  */
249
350
  function shouldRedactHeader(headerName) {
250
- if (!globalConfig.enabled)
251
- return false;
351
+ // SECURITY: Redaction is always enabled - removed bypass check
352
+ // if (!globalConfig.enabled) return false; // REMOVED - cannot bypass
252
353
  const lowerName = headerName.toLowerCase();
253
354
  for (const rule of globalConfig.rules) {
254
355
  if (rule.type !== "header")
@@ -267,10 +368,11 @@ function shouldRedactHeader(headerName) {
267
368
  }
268
369
  /**
269
370
  * Check if a query param should be redacted
371
+ * SECURITY: Redaction is always enabled - enabled check removed for enforcement
270
372
  */
271
373
  function shouldRedactQueryParam(paramName) {
272
- if (!globalConfig.enabled)
273
- return false;
374
+ // SECURITY: Redaction is always enabled - removed bypass check
375
+ // if (!globalConfig.enabled) return false; // REMOVED - cannot bypass
274
376
  const lowerName = paramName.toLowerCase();
275
377
  for (const rule of globalConfig.rules) {
276
378
  if (rule.type !== "query_param")
@@ -289,10 +391,11 @@ function shouldRedactQueryParam(paramName) {
289
391
  }
290
392
  /**
291
393
  * Redact headers in a headers object
394
+ * SECURITY: Redaction is always enforced - enabled check removed
292
395
  */
293
396
  function redactHeaders(headers) {
294
- if (!globalConfig.enabled)
295
- return headers;
397
+ // SECURITY: Redaction is always enabled - removed bypass check
398
+ // if (!globalConfig.enabled) return headers; // REMOVED - cannot bypass
296
399
  const redacted = {};
297
400
  for (const [key, value] of Object.entries(headers)) {
298
401
  if (value === undefined) {
@@ -311,10 +414,11 @@ function redactHeaders(headers) {
311
414
  }
312
415
  /**
313
416
  * Redact query parameters
417
+ * SECURITY: Redaction is always enforced - enabled check removed
314
418
  */
315
419
  function redactQueryParams(query) {
316
- if (!globalConfig.enabled)
317
- return query;
420
+ // SECURITY: Redaction is always enabled - removed bypass check
421
+ // if (!globalConfig.enabled) return query; // REMOVED - cannot bypass
318
422
  const redacted = {};
319
423
  for (const [key, value] of Object.entries(query)) {
320
424
  if (shouldRedactQueryParam(key)) {
@@ -352,10 +456,11 @@ function shouldRedactBodyField(fieldName) {
352
456
  }
353
457
  /**
354
458
  * Redact sensitive fields from a body object (recursive)
459
+ * SECURITY: Redaction is always enforced - enabled check removed
355
460
  */
356
461
  function redactBodyObject(body) {
357
- if (!globalConfig.enabled)
358
- return body;
462
+ // SECURITY: Redaction is always enabled - removed bypass check
463
+ // if (!globalConfig.enabled) return body; // REMOVED - cannot bypass
359
464
  if (body === null || body === undefined) {
360
465
  return body;
361
466
  }
@@ -382,10 +487,11 @@ function redactBodyObject(body) {
382
487
  }
383
488
  /**
384
489
  * Redact patterns from a body string
490
+ * SECURITY: Redaction is always enforced - enabled check removed
385
491
  */
386
492
  function redactBodyPatterns(body) {
387
- if (!globalConfig.enabled)
388
- return body;
493
+ // SECURITY: Redaction is always enabled - removed bypass check
494
+ // if (!globalConfig.enabled) return body; // REMOVED - cannot bypass
389
495
  let result = body;
390
496
  for (const rule of globalConfig.rules) {
391
497
  if (rule.type !== "body_pattern" || !rule.pattern)
@@ -405,10 +511,11 @@ function redactBodyPatterns(body) {
405
511
  }
406
512
  /**
407
513
  * Redact a body (handles both string and object)
514
+ * SECURITY: Redaction is always enforced - enabled check removed
408
515
  */
409
516
  function redactBody(body) {
410
- if (!globalConfig.enabled)
411
- return body;
517
+ // SECURITY: Redaction is always enabled - removed bypass check
518
+ // if (!globalConfig.enabled) return body; // REMOVED - cannot bypass
412
519
  if (body === null || body === undefined) {
413
520
  return body;
414
521
  }
@@ -436,10 +543,11 @@ function redactBody(body) {
436
543
  }
437
544
  /**
438
545
  * Redact a URL (query params)
546
+ * SECURITY: Redaction is always enforced - enabled check removed
439
547
  */
440
548
  function redactUrl(url) {
441
- if (!globalConfig.enabled)
442
- return url;
549
+ // SECURITY: Redaction is always enabled - removed bypass check
550
+ // if (!globalConfig.enabled) return url; // REMOVED - cannot bypass
443
551
  try {
444
552
  const urlObj = new URL(url, "http://placeholder");
445
553
  const redactedParams = new URLSearchParams();
@@ -32,19 +32,17 @@ export declare function createTrace(options: CreateTraceOptions): Promise<TraceB
32
32
  * Helper to process body content and store as blob
33
33
  * Applies redaction to sensitive fields before storing
34
34
  * NOTE: Always stores bodies as blobs so they can be retrieved during replay
35
+ * SECURITY: Redaction is ALWAYS enforced - skipRedaction option removed
35
36
  */
36
- export declare function processBody(body: string | Buffer | object | null | undefined, writeBlobFn: (content: string | object) => Promise<string>, options?: {
37
- skipRedaction?: boolean;
38
- }): Promise<{
37
+ export declare function processBody(body: string | Buffer | object | null | undefined, writeBlobFn: (content: string | object) => Promise<string>): Promise<{
39
38
  bodyHash: string | null;
40
39
  bodyBlob: string | null;
41
40
  }>;
42
41
  /**
43
42
  * Filter headers based on allowlist and apply redaction
43
+ * SECURITY: Redaction is ALWAYS enforced - skipRedaction option removed
44
44
  */
45
- export declare function filterHeaders(headers: Record<string, string | string[] | undefined>, allowlist?: string[], options?: {
46
- skipRedaction?: boolean;
47
- }): Record<string, string>;
45
+ export declare function filterHeaders(headers: Record<string, string | string[] | undefined>, allowlist?: string[]): Record<string, string>;
48
46
  /**
49
47
  * Generate span ID (exported for use in middleware)
50
48
  */
@@ -1 +1 @@
1
- {"version":3,"file":"trace-bundle-writer.d.ts","sourceRoot":"","sources":["../src/trace-bundle-writer.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,QAAQ,EAAE,CAAC,cAAc,CAAC,EAAE;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AAED,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAM3D,OAAO,EAAE,4BAA4B,EAAE,CAAC;AAWxC;;GAEG;AACH,iBAAS,cAAc,IAA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ED;;GAEG;AACH,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -190,8 +190,11 @@ async function createTrace(options) {
190
190
  * Helper to process body content and store as blob
191
191
  * Applies redaction to sensitive fields before storing
192
192
  * NOTE: Always stores bodies as blobs so they can be retrieved during replay
193
+ * SECURITY: Redaction is ALWAYS enforced - skipRedaction option removed
193
194
  */
194
- function processBody(body, writeBlobFn, options) {
195
+ function processBody(body, writeBlobFn
196
+ // SECURITY: Removed skipRedaction option - redaction is always enforced
197
+ ) {
195
198
  if (!body) {
196
199
  return Promise.resolve({ bodyHash: null, bodyBlob: null });
197
200
  }
@@ -205,15 +208,13 @@ function processBody(body, writeBlobFn, options) {
205
208
  else {
206
209
  bodyStr = String(body);
207
210
  }
208
- // Apply redaction unless explicitly skipped
209
- if (!options?.skipRedaction) {
210
- const redacted = (0, redaction_1.redactBody)(bodyStr);
211
- if (typeof redacted === "string") {
212
- bodyStr = redacted;
213
- }
214
- else if (redacted !== null && redacted !== undefined) {
215
- bodyStr = JSON.stringify(redacted);
216
- }
211
+ // SECURITY: Redaction is ALWAYS applied - no bypass option
212
+ const redacted = (0, redaction_1.redactBody)(bodyStr);
213
+ if (typeof redacted === "string") {
214
+ bodyStr = redacted;
215
+ }
216
+ else if (redacted !== null && redacted !== undefined) {
217
+ bodyStr = JSON.stringify(redacted);
217
218
  }
218
219
  const hash = computeHash(bodyStr);
219
220
  const hashFormatted = formatHash(hash);
@@ -226,8 +227,11 @@ function processBody(body, writeBlobFn, options) {
226
227
  }
227
228
  /**
228
229
  * Filter headers based on allowlist and apply redaction
230
+ * SECURITY: Redaction is ALWAYS enforced - skipRedaction option removed
229
231
  */
230
- function filterHeaders(headers, allowlist, options) {
232
+ function filterHeaders(headers, allowlist
233
+ // SECURITY: Removed skipRedaction option - redaction is always enforced
234
+ ) {
231
235
  if (!allowlist || allowlist.length === 0) {
232
236
  // Default allowlist: common headers that are safe to capture
233
237
  const defaultAllowlist = [
@@ -241,7 +245,7 @@ function filterHeaders(headers, allowlist, options) {
241
245
  "x-request-id",
242
246
  "x-correlation-id",
243
247
  ];
244
- return filterHeaders(headers, defaultAllowlist, options);
248
+ return filterHeaders(headers, defaultAllowlist);
245
249
  }
246
250
  const filtered = {};
247
251
  const lowerAllowlist = allowlist.map((h) => h.toLowerCase());
@@ -252,16 +256,13 @@ function filterHeaders(headers, allowlist, options) {
252
256
  filtered[key] = Array.isArray(value) ? value.join(", ") : String(value);
253
257
  }
254
258
  }
255
- // Apply redaction unless explicitly skipped
256
- if (!options?.skipRedaction) {
257
- const redacted = (0, redaction_1.redactHeaders)(filtered);
258
- const result = {};
259
- for (const [key, value] of Object.entries(redacted)) {
260
- if (value !== undefined) {
261
- result[key] = Array.isArray(value) ? value.join(", ") : String(value);
262
- }
259
+ // SECURITY: Redaction is ALWAYS applied - no bypass option
260
+ const redacted = (0, redaction_1.redactHeaders)(filtered);
261
+ const result = {};
262
+ for (const [key, value] of Object.entries(redacted)) {
263
+ if (value !== undefined) {
264
+ result[key] = Array.isArray(value) ? value.join(", ") : String(value);
263
265
  }
264
- return result;
265
266
  }
266
- return filtered;
267
+ return result;
267
268
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@runtime-digital-twin/sdk",
3
- "version": "1.0.0",
4
- "description": "SDK for capturing runtime behavior - automatic incident response and debugging",
3
+ "version": "1.0.2",
4
+ "description": "SDK for capturing runtime behavior - automatic incident response and debugging with enhanced autofix support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",
41
- "url": "git+https://github.com/your-org/WraithOnCallEngineer.git",
41
+ "url": "git+https://github.com/alakhanpal23/Wraith-2.git",
42
42
  "directory": "packages/sdk"
43
43
  },
44
44
  "keywords": [