@debugbundle/sdk-react-native 1.3.0 → 2.0.0
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/CHANGELOG.md +13 -2
- package/DebugBundleReactNative.podspec +2 -2
- package/README.md +3 -3
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/debugbundle/reactnative/DebugBundleReactNativeModule.java +2 -2
- package/app.plugin.js +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +42 -4
- package/dist/privacy-keys.d.ts +3 -0
- package/dist/privacy-keys.d.ts.map +1 -0
- package/dist/privacy-keys.js +35 -0
- package/dist/privacy-telemetry.d.ts +19 -0
- package/dist/privacy-telemetry.d.ts.map +1 -0
- package/dist/privacy-telemetry.js +164 -0
- package/dist/privacy-text.d.ts +3 -0
- package/dist/privacy-text.d.ts.map +1 -0
- package/dist/privacy-text.js +85 -0
- package/dist/redaction.d.ts.map +1 -1
- package/dist/redaction.js +29 -45
- package/ios/DebugBundleReactNative.swift +2 -2
- package/package.json +4 -4
- package/src/client.ts +42 -4
- package/src/privacy-keys.ts +39 -0
- package/src/privacy-telemetry.ts +168 -0
- package/src/privacy-text.ts +86 -0
- package/src/redaction.ts +26 -46
- package/android/src/test/java/com/debugbundle/reactnative/DebugBundleReactNativeModuleTest.java +0 -474
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## Unreleased
|
|
6
|
+
|
|
7
|
+
## [2.0.0] - 2026-09-21
|
|
8
|
+
|
|
9
|
+
### Security
|
|
10
|
+
|
|
11
|
+
- Enforce mandatory JavaScript capture protection before and after `beforeSend` and before native bridge calls, including the legacy bridge fallback.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Pin the protected Android 2.0.0 and Swift 2.0 release lines and fail the release when any wrapper, bridge, podspec, Android, or smoke-test version drifts.
|
|
16
|
+
- Require published-native Android 17/API 37.0 and Xcode 27/iOS 27 app-delivery gates before npm publication.
|
|
17
|
+
|
|
5
18
|
## [1.3.0] - 2026-09-12
|
|
6
19
|
|
|
7
20
|
### Changed
|
|
@@ -10,8 +23,6 @@ All notable changes to this project will be documented in this file.
|
|
|
10
23
|
- Use Android1.3.1 with complete packaged Apache licenses and the Apache-2.0 Swift SDK1.3.0.
|
|
11
24
|
- Publish npm releases through GitHub Actions trusted publishing without an npm token.
|
|
12
25
|
|
|
13
|
-
## Unreleased
|
|
14
|
-
|
|
15
26
|
## 1.2.0 - 2026-07-29
|
|
16
27
|
|
|
17
28
|
- Preserve React Native SDK identity, original JavaScript error fields, service, correlation, context, probes, and mobile metadata through additive Android and Swift external-event APIs.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Pod::Spec.new do |s|
|
|
2
2
|
s.name = "DebugBundleReactNative"
|
|
3
|
-
s.version = "
|
|
3
|
+
s.version = "2.0.0"
|
|
4
4
|
s.summary = "React Native wrapper for the DebugBundle mobile SDKs."
|
|
5
5
|
s.license = { :type => "Apache-2.0", :file => "LICENSE" }
|
|
6
6
|
s.author = { "DebugBundle" => "support@debugbundle.com" }
|
|
@@ -12,5 +12,5 @@ Pod::Spec.new do |s|
|
|
|
12
12
|
|
|
13
13
|
s.dependency "React-Core"
|
|
14
14
|
install_modules_dependencies(s) if defined?(install_modules_dependencies)
|
|
15
|
-
s.dependency "DebugBundle", "~>
|
|
15
|
+
s.dependency "DebugBundle", "~> 2.0"
|
|
16
16
|
end
|
package/README.md
CHANGED
|
@@ -25,9 +25,9 @@ Published implementation:
|
|
|
25
25
|
| Lane | Support |
|
|
26
26
|
| --- | --- |
|
|
27
27
|
| Minimum compatibility | React Native 0.76+, React 18.2+, iOS 15+, Android minSdk 23 |
|
|
28
|
-
| Recommended production | Current stable React Native 0.
|
|
28
|
+
| Recommended production | Current stable React Native 0.87.x with Hermes and the New Architecture enabled where your app supports it |
|
|
29
29
|
| Installed-base compatibility | React Native 0.76 through current stable, including legacy bridge apps |
|
|
30
|
-
| Rolling CI | TypeScript/package smoke, Android bridge compile on RN 0.76.9, 0.82.1,
|
|
30
|
+
| Rolling CI | TypeScript/package smoke, Android bridge compile on RN 0.76.9, 0.82.1, 0.85.3, and 0.87.1, bare iOS compatibility/current-installed-base lanes, plus Expo SDK 57 / RN 0.86 Android and iOS development builds |
|
|
31
31
|
| Expo | Expo development builds and prebuild; Expo Go is degraded because it cannot load custom native modules |
|
|
32
32
|
|
|
33
33
|
JSC compatibility is best-effort where the selected React Native lane still supports it. Hermes is the primary tested JavaScript engine.
|
|
@@ -141,4 +141,4 @@ checks.
|
|
|
141
141
|
|
|
142
142
|
## Release
|
|
143
143
|
|
|
144
|
-
The package publishes to npm from `v*` tags through GitHub Actions. Configure an npm GitHub Actions trusted publisher for `debugbundle/debugbundle-react-native` and `release.yml`, with a blank environment and direct `npm publish` enabled. Publishing uses OIDC without a long-lived npm token. Make sure the tag matches `package.json` exactly
|
|
144
|
+
The package publishes to npm from `v*` tags through GitHub Actions. Configure an npm GitHub Actions trusted publisher for `debugbundle/debugbundle-react-native` and `release.yml`, with a blank environment and direct `npm publish` enabled. Publishing uses OIDC without a long-lived npm token. Make sure the tag matches `package.json` exactly. The next protected release requires a matching 2.x wrapper/Swift pod line and a published Android 2.x BOM/module pin. `make check-protected-native-pins` refuses the current 1.x source line; update the wrapper version, native pins, and embedded SDK versions together only after the exact Android and Swift artifacts are available to Maven Central and CocoaPods consumers. The release workflow then compiles and runs clean apps against those published artifacts on Android API 37 and Xcode 27 before npm publication.
|
package/android/build.gradle
CHANGED
|
@@ -11,7 +11,7 @@ if (isReactNativeHostBuild) {
|
|
|
11
11
|
def hostKotlinVersion = rootProject.ext.has("kotlinVersion")
|
|
12
12
|
? rootProject.ext.get("kotlinVersion")
|
|
13
13
|
: "2.1.20"
|
|
14
|
-
def debugBundleAndroidVersion = rootProject.findProperty("debugBundleAndroidVersion") ?: "
|
|
14
|
+
def debugBundleAndroidVersion = rootProject.findProperty("debugBundleAndroidVersion") ?: "2.0.0"
|
|
15
15
|
|
|
16
16
|
android {
|
|
17
17
|
namespace "com.debugbundle.reactnative"
|
|
@@ -32,7 +32,7 @@ android {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
dependencies {
|
|
35
|
-
compileOnly "com.facebook.react:react-android:${rootProject.findProperty("reactNativeVersion") ?: "0.
|
|
35
|
+
compileOnly "com.facebook.react:react-android:${rootProject.findProperty("reactNativeVersion") ?: "0.87.1"}"
|
|
36
36
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:${hostKotlinVersion}"
|
|
37
37
|
implementation platform("com.debugbundle:debugbundle-android-bom:${debugBundleAndroidVersion}")
|
|
38
38
|
implementation("com.debugbundle:debugbundle-android") {
|
|
@@ -40,7 +40,7 @@ dependencies {
|
|
|
40
40
|
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-jdk7"
|
|
41
41
|
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-jdk8"
|
|
42
42
|
}
|
|
43
|
-
testImplementation "com.facebook.react:react-android:${rootProject.findProperty("reactNativeVersion") ?: "0.
|
|
43
|
+
testImplementation "com.facebook.react:react-android:${rootProject.findProperty("reactNativeVersion") ?: "0.87.1"}"
|
|
44
44
|
testImplementation "junit:junit:4.13.2"
|
|
45
45
|
testImplementation "org.mockito:mockito-core:5.14.2"
|
|
46
46
|
}
|
|
@@ -199,12 +199,12 @@ public final class DebugBundleReactNativeModule extends ReactContextBaseJavaModu
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
private String currentSdkVersion = "
|
|
202
|
+
private String currentSdkVersion = "2.0.0";
|
|
203
203
|
private String currentService = "react-native-app";
|
|
204
204
|
private String currentEnvironment = "production";
|
|
205
205
|
|
|
206
206
|
private DebugBundleConfig createConfig(ReadableMap config) {
|
|
207
|
-
currentSdkVersion = stringOrDefault(config, "sdkVersion", "
|
|
207
|
+
currentSdkVersion = stringOrDefault(config, "sdkVersion", "2.0.0");
|
|
208
208
|
currentService = stringOrDefault(config, "service", "react-native-app");
|
|
209
209
|
currentEnvironment = stringOrDefault(config, "environment", "production");
|
|
210
210
|
return DebugBundleConfig.create(
|
package/app.plugin.js
CHANGED
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EAEjB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EAIjB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AA6CpB,qBAAa,4BAA6B,YAAW,iBAAiB;IACpE,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,WAAW,CAAkE;IACrF,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,WAAW,CAAsC;IACzD,OAAO,CAAC,YAAY,CAAqD;IACzE,OAAO,CAAC,0BAA0B,CAAK;gBAE3B,MAAM,GAAE,iBAAsB;IAO1C,IAAI,MAAM,IAAI,iBAAiB,CAE9B;IAED,IAAI,WAAW,IAAI,MAAM,GAAG,IAAI,CAE/B;IAED,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IA8BrC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,yBAA8B,GAAG,IAAI;IAc/E,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,yBAA8B,GAAG,IAAI;IAI3E,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,mBAA+B,EAAE,OAAO,GAAE,yBAA8B,GAAG,IAAI;IAYlH,cAAc,CACZ,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,uBAAuB,EACjC,OAAO,GAAE,yBAA8B,GACtC,IAAI;IA+BP,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,mBAA+B,EAAE,OAAO,GAAE,yBAA8B,GAAG,IAAI;IAQtH,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAS7C,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,EAAE,OAAO,GAAE,uBAA4B,GAAG,IAAI;IA4B5F,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAWtB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWhE,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,IAAI;IAcxE,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,GAAE,MAAM,GAAG,IAAW,EAAE,MAAM,SAAqB,GAAG,IAAI;IAWzG,OAAO,CAAC,OAAO;IAiDf,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,0BAA0B;CAInC;AAED,wBAAgB,uBAAuB,CAAC,MAAM,GAAE,iBAAsB,GAAG,4BAA4B,CAEpG;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,yBAAyB,CAsClF"}
|
package/dist/client.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getNativeModule, degradedNativeState, safeNativeCall } from "./native.js";
|
|
2
2
|
import { applyBeforeSend } from "./before-send.js";
|
|
3
3
|
import { defaultRedactFields, DEFAULT_HEADER_ALLOWLIST, sanitizeHeaders, sanitizeValue } from "./redaction.js";
|
|
4
|
+
import { sanitizeTelemetry } from "./privacy-telemetry.js";
|
|
4
5
|
const SDK_NAME = "@debugbundle/sdk-react-native";
|
|
5
|
-
const DEFAULT_SDK_VERSION = "
|
|
6
|
+
const DEFAULT_SDK_VERSION = "2.0.0";
|
|
6
7
|
const LOG_LEVELS = {
|
|
7
8
|
debug: 10,
|
|
8
9
|
info: 20,
|
|
@@ -10,6 +11,37 @@ const LOG_LEVELS = {
|
|
|
10
11
|
error: 40,
|
|
11
12
|
critical: 50
|
|
12
13
|
};
|
|
14
|
+
function protectEventFields(event, additionalKeys) {
|
|
15
|
+
// Preserve typed identities only when their scalar values pass the mandatory policy.
|
|
16
|
+
for (const value of [event.schema_version, event.sdk_name, event.sdk_version,
|
|
17
|
+
...Object.values(event.correlation ?? {})]) {
|
|
18
|
+
if (typeof value !== "string")
|
|
19
|
+
continue;
|
|
20
|
+
const checked = sanitizeTelemetry(value, { additionalKeys });
|
|
21
|
+
if (!checked.ok || checked.value !== value)
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const result = sanitizeTelemetry({
|
|
25
|
+
service: event.service,
|
|
26
|
+
payload: event.payload,
|
|
27
|
+
...(event.context ? { context: event.context } : {})
|
|
28
|
+
}, { additionalKeys });
|
|
29
|
+
if (!result.ok || !result.value || typeof result.value !== "object" || Array.isArray(result.value)) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const safeFields = result.value;
|
|
33
|
+
if (!safeFields.service || !safeFields.payload ||
|
|
34
|
+
typeof safeFields.service !== "object" || Array.isArray(safeFields.service) ||
|
|
35
|
+
typeof safeFields.payload !== "object" || Array.isArray(safeFields.payload)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
...event,
|
|
40
|
+
service: safeFields.service,
|
|
41
|
+
payload: safeFields.payload,
|
|
42
|
+
...(event.context ? { context: safeFields.context } : {})
|
|
43
|
+
};
|
|
44
|
+
}
|
|
13
45
|
export class DebugBundleReactNativeClient {
|
|
14
46
|
config;
|
|
15
47
|
nativeModule = null;
|
|
@@ -216,19 +248,25 @@ export class DebugBundleReactNativeClient {
|
|
|
216
248
|
? { ...payload, device: canonicalDevice(this.nativeState.device, this.config) }
|
|
217
249
|
: payload
|
|
218
250
|
};
|
|
219
|
-
const
|
|
251
|
+
const initial = protectEventFields(authoredEvent, this.config.redactFields);
|
|
252
|
+
if (!initial)
|
|
253
|
+
return;
|
|
254
|
+
const event = applyBeforeSend(initial, this.config.beforeSend);
|
|
220
255
|
if (!event || !localPolicyAllows) {
|
|
221
256
|
return;
|
|
222
257
|
}
|
|
258
|
+
const safeEvent = protectEventFields(event, this.config.redactFields);
|
|
259
|
+
if (!safeEvent)
|
|
260
|
+
return;
|
|
223
261
|
if (!this.nativeModule) {
|
|
224
262
|
this.nativeState = degradedNativeState("native_module_unavailable");
|
|
225
263
|
return;
|
|
226
264
|
}
|
|
227
265
|
if (this.nativeModule.enqueueCanonicalEvent) {
|
|
228
|
-
void safeNativeCall(() => this.nativeModule.enqueueCanonicalEvent(
|
|
266
|
+
void safeNativeCall(() => this.nativeModule.enqueueCanonicalEvent(safeEvent), undefined);
|
|
229
267
|
}
|
|
230
268
|
else {
|
|
231
|
-
void safeNativeCall(() => this.nativeModule.enqueueEvent(toLegacyNativeEvent(
|
|
269
|
+
void safeNativeCall(() => this.nativeModule.enqueueEvent(toLegacyNativeEvent(safeEvent)), undefined);
|
|
232
270
|
}
|
|
233
271
|
}
|
|
234
272
|
canCapture(eventType, countTowardSession) {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const DEFAULT_SENSITIVE_KEYS: readonly ["password", "secret", "token", "api_key", "apikey", "access_token", "refresh_token", "private_key", "authorization", "bearer", "cookie", "session_id", "passwd", "ssn", "credit_card", "card_number", "cvv", "cvc", "pin", "expiry", "phone", "otp", "verification_code"];
|
|
2
|
+
export declare function isSensitiveKey(key: string, sensitiveKeys: readonly string[]): boolean;
|
|
3
|
+
//# sourceMappingURL=privacy-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy-keys.d.ts","sourceRoot":"","sources":["../src/privacy-keys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,qRAKzB,CAAC;AAeX,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAkBrF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const DEFAULT_SENSITIVE_KEYS = [
|
|
2
|
+
"password", "secret", "token", "api_key", "apikey", "access_token", "refresh_token",
|
|
3
|
+
"private_key", "authorization", "bearer", "cookie", "session_id", "passwd", "ssn",
|
|
4
|
+
"credit_card", "card_number", "cvv", "cvc", "pin", "expiry", "phone", "otp",
|
|
5
|
+
"verification_code"
|
|
6
|
+
];
|
|
7
|
+
function canonicalizeSensitiveKey(value) {
|
|
8
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
9
|
+
}
|
|
10
|
+
function splitKeyIntoSegments(key) {
|
|
11
|
+
return key
|
|
12
|
+
.trim()
|
|
13
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1_$2")
|
|
14
|
+
.toLowerCase()
|
|
15
|
+
.split(/[^a-z0-9]+/)
|
|
16
|
+
.filter((segment) => segment.length > 0);
|
|
17
|
+
}
|
|
18
|
+
export function isSensitiveKey(key, sensitiveKeys) {
|
|
19
|
+
const normalized = key.trim().toLowerCase();
|
|
20
|
+
if (sensitiveKeys.includes(normalized)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
const canonicalSensitiveKeys = new Set(sensitiveKeys.map(canonicalizeSensitiveKey));
|
|
24
|
+
const segments = splitKeyIntoSegments(key);
|
|
25
|
+
for (let start = 0; start < segments.length; start += 1) {
|
|
26
|
+
let combined = "";
|
|
27
|
+
for (let end = start; end < segments.length; end += 1) {
|
|
28
|
+
combined += segments[end];
|
|
29
|
+
if (canonicalSensitiveKeys.has(combined)) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
2
|
+
[key: string]: JsonValue;
|
|
3
|
+
};
|
|
4
|
+
export interface TelemetrySanitizationOptions {
|
|
5
|
+
additionalKeys?: readonly string[];
|
|
6
|
+
maxTotalBytes?: number;
|
|
7
|
+
}
|
|
8
|
+
export type TelemetrySanitizationResult = {
|
|
9
|
+
ok: true;
|
|
10
|
+
value: JsonValue;
|
|
11
|
+
redactionCount: number;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
reason: "unsafe_input" | "budget_exceeded";
|
|
15
|
+
};
|
|
16
|
+
/** Mandatory telemetry policy; unlike the legacy `redact` helper, custom keys are additive. */
|
|
17
|
+
export declare function sanitizeTelemetry(value: unknown, options?: TelemetrySanitizationOptions): TelemetrySanitizationResult;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=privacy-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy-telemetry.d.ts","sourceRoot":"","sources":["../src/privacy-telemetry.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAW/F,MAAM,WAAW,4BAA4B;IAC3C,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,2BAA2B,GACnC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,cAAc,GAAG,iBAAiB,CAAA;CAAE,CAAC;AAyH9D,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,4BAAiC,GAAG,2BAA2B,CA2BzH"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { DEFAULT_SENSITIVE_KEYS, isSensitiveKey } from "./privacy-keys.js";
|
|
2
|
+
import { scrubCredentialText } from "./privacy-text.js";
|
|
3
|
+
const REDACTED = "[REDACTED]";
|
|
4
|
+
const MAX_DEPTH = 16;
|
|
5
|
+
const MAX_NODES = 4096;
|
|
6
|
+
const MAX_ENTRIES = 256;
|
|
7
|
+
const MAX_STRING_BYTES = 16 * 1024;
|
|
8
|
+
const MAX_TOTAL_BYTES = 256 * 1024;
|
|
9
|
+
class BudgetExceeded extends Error {
|
|
10
|
+
}
|
|
11
|
+
function byteLength(value) {
|
|
12
|
+
let bytes = 0;
|
|
13
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
14
|
+
const code = value.charCodeAt(index);
|
|
15
|
+
if (code < 0x80)
|
|
16
|
+
bytes += 1;
|
|
17
|
+
else if (code < 0x800)
|
|
18
|
+
bytes += 2;
|
|
19
|
+
else if (code >= 0xd800 && code <= 0xdbff && index + 1 < value.length &&
|
|
20
|
+
value.charCodeAt(index + 1) >= 0xdc00 && value.charCodeAt(index + 1) <= 0xdfff) {
|
|
21
|
+
bytes += 4;
|
|
22
|
+
index += 1;
|
|
23
|
+
}
|
|
24
|
+
else
|
|
25
|
+
bytes += 3;
|
|
26
|
+
}
|
|
27
|
+
return bytes;
|
|
28
|
+
}
|
|
29
|
+
function mask(state) {
|
|
30
|
+
state.redactionCount += 1;
|
|
31
|
+
return REDACTED;
|
|
32
|
+
}
|
|
33
|
+
function sanitizeString(value, state, allowStructured) {
|
|
34
|
+
if (value.length > MAX_STRING_BYTES)
|
|
35
|
+
return mask(state);
|
|
36
|
+
const length = byteLength(value);
|
|
37
|
+
if (length > MAX_STRING_BYTES)
|
|
38
|
+
return mask(state);
|
|
39
|
+
state.textBytes += length;
|
|
40
|
+
if (state.textBytes > state.maxTotalBytes)
|
|
41
|
+
throw new BudgetExceeded();
|
|
42
|
+
if (allowStructured && (value.startsWith("{") || value.startsWith("["))) {
|
|
43
|
+
try {
|
|
44
|
+
const parsed = JSON.parse(value);
|
|
45
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
46
|
+
const nested = sanitizeValue(parsed, state, 0, false);
|
|
47
|
+
const encoded = JSON.stringify(nested);
|
|
48
|
+
if (encoded !== value)
|
|
49
|
+
state.redactionCount += 1;
|
|
50
|
+
return encoded;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (error instanceof BudgetExceeded)
|
|
55
|
+
throw error;
|
|
56
|
+
// Malformed structured content with a recognizable sensitive label is withheld below.
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const result = scrubCredentialText(value, state.extra);
|
|
60
|
+
if (result !== value)
|
|
61
|
+
state.redactionCount += 1;
|
|
62
|
+
if ((value.startsWith("{") || value.startsWith("[")) && result === value &&
|
|
63
|
+
/(?:password|token|secret|authorization|cookie)["']?\s*[:=]/i.test(value)) {
|
|
64
|
+
return mask(state);
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
function sanitizeValue(value, state, depth, allowStructured) {
|
|
69
|
+
state.nodes += 1;
|
|
70
|
+
if (state.nodes > MAX_NODES)
|
|
71
|
+
throw new BudgetExceeded();
|
|
72
|
+
if (depth > MAX_DEPTH)
|
|
73
|
+
return mask(state);
|
|
74
|
+
if (typeof value === "string")
|
|
75
|
+
return sanitizeString(value, state, allowStructured);
|
|
76
|
+
if (value === null || typeof value === "boolean")
|
|
77
|
+
return value;
|
|
78
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
79
|
+
return value;
|
|
80
|
+
if (typeof value !== "object")
|
|
81
|
+
throw new TypeError("unsafe_input");
|
|
82
|
+
if (state.seen.has(value))
|
|
83
|
+
return "[Circular]";
|
|
84
|
+
state.seen.add(value);
|
|
85
|
+
try {
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
if (value.length > MAX_ENTRIES)
|
|
88
|
+
return mask(state);
|
|
89
|
+
return Array.from({ length: value.length }, (_, index) => {
|
|
90
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
91
|
+
if (descriptor === undefined || !("value" in descriptor))
|
|
92
|
+
throw new TypeError("unsafe_input");
|
|
93
|
+
return sanitizeValue(descriptor.value, state, depth + 1, allowStructured);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) {
|
|
97
|
+
throw new TypeError("unsafe_input");
|
|
98
|
+
}
|
|
99
|
+
const keys = Object.keys(value);
|
|
100
|
+
if (keys.length > MAX_ENTRIES)
|
|
101
|
+
return mask(state);
|
|
102
|
+
const result = {};
|
|
103
|
+
for (const key of keys) {
|
|
104
|
+
if (key.length > 128) {
|
|
105
|
+
state.redactionCount += 1;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
state.textBytes += byteLength(key);
|
|
109
|
+
if (state.textBytes > state.maxTotalBytes)
|
|
110
|
+
throw new BudgetExceeded();
|
|
111
|
+
const safeKey = scrubCredentialText(key, state.extra);
|
|
112
|
+
if (safeKey !== key) {
|
|
113
|
+
state.redactionCount += 1;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
117
|
+
if (descriptor === undefined || !("value" in descriptor))
|
|
118
|
+
throw new TypeError("unsafe_input");
|
|
119
|
+
const safeValue = isSensitiveKey(key, state.keys)
|
|
120
|
+
? mask(state)
|
|
121
|
+
: sanitizeValue(descriptor.value, state, depth + 1, allowStructured);
|
|
122
|
+
Object.defineProperty(result, key, {
|
|
123
|
+
value: safeValue,
|
|
124
|
+
enumerable: true,
|
|
125
|
+
configurable: true,
|
|
126
|
+
writable: true
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
state.seen.delete(value);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/** Mandatory telemetry policy; unlike the legacy `redact` helper, custom keys are additive. */
|
|
136
|
+
export function sanitizeTelemetry(value, options = {}) {
|
|
137
|
+
try {
|
|
138
|
+
const extra = options.additionalKeys ?? [];
|
|
139
|
+
if (extra.length > 128 || extra.some((key) => typeof key !== "string" || key.length > 64 || !key.trim())) {
|
|
140
|
+
return { ok: false, reason: "unsafe_input" };
|
|
141
|
+
}
|
|
142
|
+
const maxTotalBytes = options.maxTotalBytes ?? MAX_TOTAL_BYTES;
|
|
143
|
+
if (!Number.isInteger(maxTotalBytes) || maxTotalBytes < 1 || maxTotalBytes > 512 * 1024) {
|
|
144
|
+
return { ok: false, reason: "unsafe_input" };
|
|
145
|
+
}
|
|
146
|
+
const state = {
|
|
147
|
+
nodes: 0,
|
|
148
|
+
textBytes: 0,
|
|
149
|
+
redactionCount: 0,
|
|
150
|
+
seen: new WeakSet(),
|
|
151
|
+
keys: [...DEFAULT_SENSITIVE_KEYS, ...extra],
|
|
152
|
+
extra,
|
|
153
|
+
maxTotalBytes
|
|
154
|
+
};
|
|
155
|
+
const sanitized = sanitizeValue(value, state, 0, true);
|
|
156
|
+
if (byteLength(JSON.stringify(sanitized)) > maxTotalBytes) {
|
|
157
|
+
return { ok: false, reason: "budget_exceeded" };
|
|
158
|
+
}
|
|
159
|
+
return { ok: true, value: sanitized, redactionCount: state.redactionCount };
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
return { ok: false, reason: error instanceof BudgetExceeded ? "budget_exceeded" : "unsafe_input" };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy-text.d.ts","sourceRoot":"","sources":["../src/privacy-text.ts"],"names":[],"mappings":"AAyDA,6FAA6F;AAC7F,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,UAAO,GAAG,MAAM,CA2B7G"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { DEFAULT_SENSITIVE_KEYS, isSensitiveKey } from "./privacy-keys.js";
|
|
2
|
+
const REDACTED = "[REDACTED]";
|
|
3
|
+
const BUILTIN_LABELS = [...DEFAULT_SENSITIVE_KEYS, "client_secret", "x_api_key",
|
|
4
|
+
"accessToken", "refreshToken", "privateKey", "clientSecret"];
|
|
5
|
+
const ASSIGNMENT = new RegExp(`\\b(${BUILTIN_LABELS.join("|")})\\b(["']?\\s*[:=]\\s*)(?:"[^"]*"|'[^']*'|[^\\s&,;]+)`, "gi");
|
|
6
|
+
const HEADER = /\b(Authorization|Proxy-Authorization|Cookie|Set-Cookie)\s*:\s*[^\r\n]*/gi;
|
|
7
|
+
const PEM = /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gi;
|
|
8
|
+
const PEM_COMPLETE = new RegExp(PEM.source, "i");
|
|
9
|
+
const PEM_START = /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/i;
|
|
10
|
+
const DEBUGBUNDLE_TOKEN = /\bdbundle_(?:proj|mem|probe|agent)_[A-Za-z0-9_-]+\b/g;
|
|
11
|
+
const BEARER = /\b(Bearer|Basic)\s+[A-Za-z0-9._~+\/-]{6,}/gi;
|
|
12
|
+
const URL_TEXT = /\bhttps?:\/\/[^\s<>"']+/gi;
|
|
13
|
+
// Do not treat numeric substrings inside UUIDs, hashes, or identifier slugs as cards.
|
|
14
|
+
const CARD = /(?<![A-Za-z0-9_-])(?:\d[ -]?){12,18}\d(?![A-Za-z0-9_-])/g;
|
|
15
|
+
function isValidCard(value) {
|
|
16
|
+
const digits = value.replace(/[^0-9]/g, "");
|
|
17
|
+
if (digits.length < 13 || digits.length > 19 || /^(\d)\1+$/.test(digits)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
let sum = 0;
|
|
21
|
+
for (let index = digits.length - 1; index >= 0; index -= 1) {
|
|
22
|
+
let digit = Number(digits[index]);
|
|
23
|
+
if ((digits.length - index) % 2 === 0) {
|
|
24
|
+
digit *= 2;
|
|
25
|
+
if (digit > 9)
|
|
26
|
+
digit -= 9;
|
|
27
|
+
}
|
|
28
|
+
sum += digit;
|
|
29
|
+
}
|
|
30
|
+
return sum % 10 === 0;
|
|
31
|
+
}
|
|
32
|
+
function scrubUrl(raw, keys) {
|
|
33
|
+
try {
|
|
34
|
+
const url = new URL(raw);
|
|
35
|
+
if (url.username || url.password) {
|
|
36
|
+
url.username = "REDACTED";
|
|
37
|
+
url.password = "";
|
|
38
|
+
}
|
|
39
|
+
const nextQuery = new URLSearchParams();
|
|
40
|
+
for (const [key, value] of url.searchParams) {
|
|
41
|
+
if (key.length > 128 || scrubCredentialText(key, keys, false) !== key)
|
|
42
|
+
continue;
|
|
43
|
+
nextQuery.append(key, isSensitiveKey(key, keys) || scrubCredentialText(value, keys, false) !== value ? REDACTED : value);
|
|
44
|
+
}
|
|
45
|
+
url.search = nextQuery.toString();
|
|
46
|
+
url.hash = "";
|
|
47
|
+
return url.toString();
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// A malformed URL with a recognizable credential must not be emitted verbatim.
|
|
51
|
+
return REDACTED;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Bounded caller input only. Returns stable replacement text, never the matching secret. */
|
|
55
|
+
export function scrubCredentialText(input, additionalKeys, scanUrls = true) {
|
|
56
|
+
const keys = [...DEFAULT_SENSITIVE_KEYS, ...additionalKeys];
|
|
57
|
+
if (PEM_START.test(input) && !PEM_COMPLETE.test(input))
|
|
58
|
+
return REDACTED;
|
|
59
|
+
let output = input;
|
|
60
|
+
if (/(?:password|token|secret|authorization|cookie)%3[ad]/i.test(output)) {
|
|
61
|
+
try {
|
|
62
|
+
output = decodeURIComponent(output);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return REDACTED;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
output = output.replace(PEM, REDACTED).replace(HEADER, "$1: [REDACTED]");
|
|
69
|
+
output = output.replace(BEARER, "$1 [REDACTED]").replace(DEBUGBUNDLE_TOKEN, REDACTED);
|
|
70
|
+
output = output.replace(ASSIGNMENT, "$1$2[REDACTED]");
|
|
71
|
+
if (additionalKeys.length > 0) {
|
|
72
|
+
for (const key of additionalKeys) {
|
|
73
|
+
const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
74
|
+
const named = new RegExp(`\\b(${escaped})\\b(["']?\\s*[:=]\\s*)(?:"[^"]*"|'[^']*'|[^\\s&,;]+)`, "gi");
|
|
75
|
+
output = output.replace(named, "$1$2[REDACTED]");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
output = output.replace(CARD, (candidate) => isValidCard(candidate) ? REDACTED : candidate);
|
|
79
|
+
if (!scanUrls)
|
|
80
|
+
return output;
|
|
81
|
+
return output.replace(URL_TEXT, (matched) => {
|
|
82
|
+
const trailing = matched.match(/[).,;]+$/)?.[0] ?? "";
|
|
83
|
+
return scrubUrl(matched.slice(0, matched.length - trailing.length), keys) + trailing;
|
|
84
|
+
});
|
|
85
|
+
}
|
package/dist/redaction.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redaction.d.ts","sourceRoot":"","sources":["../src/redaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"redaction.d.ts","sourceRoot":"","sources":["../src/redaction.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,wBAAwB,UAQpC,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAUpF;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC3C,SAAS,GAAE,MAAM,EAA6B,EAC9C,OAAO,GAAE,eAAoB,GAC5B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAaxB"}
|
package/dist/redaction.js
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
|
+
import { DEFAULT_SENSITIVE_KEYS, isSensitiveKey as privacySensitiveKey } from "./privacy-keys.js";
|
|
2
|
+
import { sanitizeTelemetry } from "./privacy-telemetry.js";
|
|
1
3
|
const DEFAULT_REDACT_FIELDS = [
|
|
2
|
-
|
|
3
|
-
"secret",
|
|
4
|
-
"token",
|
|
5
|
-
"api_key",
|
|
6
|
-
"apikey",
|
|
7
|
-
"access_token",
|
|
8
|
-
"refresh_token",
|
|
9
|
-
"private_key",
|
|
10
|
-
"passwd",
|
|
11
|
-
"card_number",
|
|
12
|
-
"cvv",
|
|
13
|
-
"cvc",
|
|
14
|
-
"pin",
|
|
15
|
-
"expiry",
|
|
16
|
-
"phone",
|
|
17
|
-
"bearer",
|
|
18
|
-
"session_id",
|
|
19
|
-
"otp",
|
|
20
|
-
"verification_code",
|
|
21
|
-
"authorization",
|
|
22
|
-
"cookie",
|
|
23
|
-
"ssn"
|
|
4
|
+
...DEFAULT_SENSITIVE_KEYS
|
|
24
5
|
];
|
|
25
6
|
export const DEFAULT_HEADER_ALLOWLIST = [
|
|
26
7
|
"user-agent",
|
|
@@ -35,8 +16,16 @@ export function defaultRedactFields() {
|
|
|
35
16
|
return [...DEFAULT_REDACT_FIELDS];
|
|
36
17
|
}
|
|
37
18
|
export function sanitizeValue(value, options = {}) {
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
try {
|
|
20
|
+
const normalized = normalizeOptions(options);
|
|
21
|
+
const visited = new WeakSet();
|
|
22
|
+
const prepared = sanitize(value, normalized, 0, visited, undefined);
|
|
23
|
+
const protectedValue = sanitizeTelemetry(prepared, { additionalKeys: options.redactFields ?? [] });
|
|
24
|
+
return protectedValue.ok ? protectedValue.value : "[REDACTED]";
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return "[REDACTED]";
|
|
28
|
+
}
|
|
40
29
|
}
|
|
41
30
|
export function sanitizeHeaders(headers, allowlist = DEFAULT_HEADER_ALLOWLIST, options = {}) {
|
|
42
31
|
if (!headers) {
|
|
@@ -54,7 +43,7 @@ export function sanitizeHeaders(headers, allowlist = DEFAULT_HEADER_ALLOWLIST, o
|
|
|
54
43
|
}
|
|
55
44
|
function normalizeOptions(options) {
|
|
56
45
|
return {
|
|
57
|
-
redactFields: options.redactFields ??
|
|
46
|
+
redactFields: [...DEFAULT_REDACT_FIELDS, ...(options.redactFields ?? [])],
|
|
58
47
|
maxDepth: options.maxDepth ?? 8,
|
|
59
48
|
maxStringLength: options.maxStringLength ?? 2048,
|
|
60
49
|
maxArrayLength: options.maxArrayLength ?? 50,
|
|
@@ -63,13 +52,13 @@ function normalizeOptions(options) {
|
|
|
63
52
|
}
|
|
64
53
|
function sanitize(value, options, depth, visited, key) {
|
|
65
54
|
if (key && isSensitiveKey(key, options.redactFields)) {
|
|
66
|
-
return "[
|
|
55
|
+
return "[REDACTED]";
|
|
67
56
|
}
|
|
68
57
|
if (value === null || value === undefined) {
|
|
69
58
|
return value ?? null;
|
|
70
59
|
}
|
|
71
60
|
if (typeof value === "string") {
|
|
72
|
-
return truncate(value, options.maxStringLength);
|
|
61
|
+
return truncate(value, options.maxStringLength, options.redactFields);
|
|
73
62
|
}
|
|
74
63
|
if (typeof value === "number" || typeof value === "boolean") {
|
|
75
64
|
return value;
|
|
@@ -106,27 +95,22 @@ function sanitize(value, options, depth, visited, key) {
|
|
|
106
95
|
}
|
|
107
96
|
function sanitizeError(error, options, depth, visited) {
|
|
108
97
|
return {
|
|
109
|
-
name: truncate(error.name || "Error", options.maxStringLength),
|
|
110
|
-
message: truncate(error.message || "", options.maxStringLength),
|
|
111
|
-
stack: typeof error.stack === "string" ? truncate(error.stack, options.maxStringLength * 4) : null,
|
|
98
|
+
name: truncate(error.name || "Error", options.maxStringLength, options.redactFields),
|
|
99
|
+
message: truncate(error.message || "", options.maxStringLength, options.redactFields),
|
|
100
|
+
stack: typeof error.stack === "string" ? truncate(error.stack, options.maxStringLength * 4, options.redactFields) : null,
|
|
112
101
|
cause: "cause" in error ? sanitize(error.cause, options, depth + 1, visited, "cause") : null
|
|
113
102
|
};
|
|
114
103
|
}
|
|
115
|
-
function truncate(value, maxLength) {
|
|
116
|
-
if (value.length
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
|
|
104
|
+
function truncate(value, maxLength, fields) {
|
|
105
|
+
if (value.length > 16 * 1024)
|
|
106
|
+
return "[REDACTED]";
|
|
107
|
+
const safe = sanitizeTelemetry(value, { additionalKeys: fields });
|
|
108
|
+
if (!safe.ok || typeof safe.value !== "string")
|
|
109
|
+
return "[REDACTED]";
|
|
110
|
+
if (safe.value.length <= maxLength)
|
|
111
|
+
return safe.value;
|
|
112
|
+
return `${safe.value.slice(0, maxLength)}...[Truncated]`;
|
|
120
113
|
}
|
|
121
114
|
function isSensitiveKey(key, sensitiveFields) {
|
|
122
|
-
|
|
123
|
-
const sensitive = new Set(sensitiveFields.flatMap(splitKey));
|
|
124
|
-
return segments.some((segment) => sensitive.has(segment));
|
|
125
|
-
}
|
|
126
|
-
function splitKey(key) {
|
|
127
|
-
return key
|
|
128
|
-
.replace(/([a-z0-9])([A-Z])/g, "$1_$2")
|
|
129
|
-
.split(/[^a-zA-Z0-9]+/)
|
|
130
|
-
.map((segment) => segment.toLowerCase())
|
|
131
|
-
.filter(Boolean);
|
|
115
|
+
return privacySensitiveKey(key, [...DEFAULT_SENSITIVE_KEYS, ...sensitiveFields]);
|
|
132
116
|
}
|