@foam-ai/node 0.1.0-alpha.4 → 0.1.0-alpha.6
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/README.md +393 -214
- package/dist/before-send.d.ts +16 -0
- package/dist/before-send.js +41 -0
- package/dist/constants.d.ts +10 -8
- package/dist/constants.js +19 -6
- package/dist/endpoint.d.ts +2 -0
- package/dist/endpoint.js +11 -0
- package/dist/exporters.d.ts +11 -3
- package/dist/exporters.js +127 -53
- package/dist/index.d.ts +7 -2
- package/dist/index.js +8 -1
- package/dist/ingest.d.ts +8 -2
- package/dist/ingest.js +28 -16
- package/dist/init.d.ts +7 -3
- package/dist/init.js +85 -37
- package/dist/instrumentations.js +25 -3
- package/dist/logs.d.ts +10 -0
- package/dist/logs.js +61 -0
- package/dist/network-capture/collector.js +168 -69
- package/dist/network-capture/http.d.ts +0 -1
- package/dist/network-capture/http.js +23 -25
- package/dist/network-capture/index.js +10 -0
- package/dist/network-capture/redact.d.ts +9 -0
- package/dist/network-capture/redact.js +401 -0
- package/dist/network-capture/undici.d.ts +0 -4
- package/dist/network-capture/undici.js +55 -22
- package/dist/otlp.d.ts +8 -0
- package/dist/otlp.js +46 -0
- package/dist/propagation.d.ts +1 -1
- package/dist/propagation.js +6 -4
- package/dist/redaction-keys.d.ts +3 -0
- package/dist/redaction-keys.js +421 -0
- package/dist/redaction.d.ts +24 -0
- package/dist/redaction.js +270 -0
- package/dist/report.d.ts +9 -0
- package/dist/report.js +56 -0
- package/dist/state.d.ts +11 -4
- package/dist/state.js +26 -9
- package/dist/traces.d.ts +1 -0
- package/dist/traces.js +21 -0
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/diagnostics.d.ts +0 -13
- package/dist/diagnostics.js +0 -83
|
@@ -6,6 +6,7 @@ const node_diagnostics_channel_1 = require("node:diagnostics_channel");
|
|
|
6
6
|
const utils_js_1 = require("../utils.js");
|
|
7
7
|
const collector_js_1 = require("./collector.js");
|
|
8
8
|
const undiciSessions = new WeakMap();
|
|
9
|
+
const legacyWrappedRequests = new WeakSet();
|
|
9
10
|
let undiciBodyChannelsBound = false;
|
|
10
11
|
function appendHeader(headers, rawName, value) {
|
|
11
12
|
const name = String(rawName).toLowerCase();
|
|
@@ -90,19 +91,50 @@ function bindUndiciChannel(name, handle) {
|
|
|
90
91
|
});
|
|
91
92
|
});
|
|
92
93
|
}
|
|
94
|
+
function wrapLegacyBodyMethod(request, name, direction) {
|
|
95
|
+
const target = request;
|
|
96
|
+
const original = target[name];
|
|
97
|
+
if (typeof original !== "function")
|
|
98
|
+
return;
|
|
99
|
+
target[name] = function (chunk, ...rest) {
|
|
100
|
+
const result = original.call(this, chunk, ...rest);
|
|
101
|
+
(0, utils_js_1.safely)(() => {
|
|
102
|
+
const session = undiciSessions.get(request);
|
|
103
|
+
if (!session || session.modernBodyChannels)
|
|
104
|
+
return;
|
|
105
|
+
undiciCollector(session, direction)?.observe(chunk);
|
|
106
|
+
});
|
|
107
|
+
return result;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function bindLegacyUndiciBodyMethods(request) {
|
|
111
|
+
if (legacyWrappedRequests.has(request))
|
|
112
|
+
return;
|
|
113
|
+
legacyWrappedRequests.add(request);
|
|
114
|
+
wrapLegacyBodyMethod(request, "onBodySent", "request");
|
|
115
|
+
wrapLegacyBodyMethod(request, "onData", "response");
|
|
116
|
+
wrapLegacyBodyMethod(request, "onResponseData", "response");
|
|
117
|
+
}
|
|
93
118
|
function bindUndiciBodyChannels() {
|
|
94
119
|
if (undiciBodyChannelsBound)
|
|
95
120
|
return;
|
|
96
121
|
undiciBodyChannelsBound = true;
|
|
97
|
-
|
|
98
|
-
|
|
122
|
+
(0, node_diagnostics_channel_1.subscribe)("undici:request:create", (message) => {
|
|
123
|
+
(0, utils_js_1.safely)(() => {
|
|
124
|
+
const request = undiciRequest(message);
|
|
125
|
+
if (request)
|
|
126
|
+
bindLegacyUndiciBodyMethods(request);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
99
129
|
bindUndiciChannel("undici:request:bodyChunkSent", (message, _request, session) => {
|
|
130
|
+
session.modernBodyChannels = true;
|
|
100
131
|
undiciCollector(session, "request")?.observe(message.chunk);
|
|
101
132
|
});
|
|
102
133
|
bindUndiciChannel("undici:request:bodySent", (_message, _request, session) => {
|
|
103
134
|
session.requestBody?.finalize(true);
|
|
104
135
|
});
|
|
105
136
|
bindUndiciChannel("undici:request:bodyChunkReceived", (message, _request, session) => {
|
|
137
|
+
session.modernBodyChannels = true;
|
|
106
138
|
undiciCollector(session, "response")?.observe(message.chunk);
|
|
107
139
|
});
|
|
108
140
|
bindUndiciChannel("undici:request:trailers", (_message, request) => {
|
|
@@ -112,33 +144,34 @@ function bindUndiciBodyChannels() {
|
|
|
112
144
|
finishUndici(request, false);
|
|
113
145
|
});
|
|
114
146
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Builds OTel Undici/fetch hooks. Headers use the same allowlist as Node HTTP.
|
|
117
|
-
* Bodies are copied from diagnostics_channel chunks — never from fetch streams.
|
|
118
|
-
*/
|
|
119
147
|
function createUndiciNetworkCaptureHooks(bodyCaptureEnabled = true) {
|
|
120
148
|
if (bodyCaptureEnabled)
|
|
121
149
|
bindUndiciBodyChannels();
|
|
122
150
|
return {
|
|
123
151
|
requestHook(span, request) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
!
|
|
128
|
-
|
|
129
|
-
api_1.TraceFlags.SAMPLED)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
152
|
+
(0, utils_js_1.safely)(() => {
|
|
153
|
+
const headers = undiciRequestHeaders(request.headers);
|
|
154
|
+
(0, collector_js_1.setHeaderAttributes)(span, "request", headers);
|
|
155
|
+
if (!bodyCaptureEnabled ||
|
|
156
|
+
!span.isRecording() ||
|
|
157
|
+
(span.spanContext().traceFlags & api_1.TraceFlags.SAMPLED) !==
|
|
158
|
+
api_1.TraceFlags.SAMPLED) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
undiciSessions.set(request, { span, requestHeaders: headers });
|
|
162
|
+
bindLegacyUndiciBodyMethods(request);
|
|
163
|
+
});
|
|
133
164
|
},
|
|
134
165
|
responseHook(span, info) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
session
|
|
166
|
+
(0, utils_js_1.safely)(() => {
|
|
167
|
+
const headers = undiciResponseHeaders(info.response.headers);
|
|
168
|
+
(0, collector_js_1.setHeaderAttributes)(span, "response", headers);
|
|
169
|
+
if (!bodyCaptureEnabled || info.request === undefined)
|
|
170
|
+
return;
|
|
171
|
+
const session = undiciSessions.get(info.request);
|
|
172
|
+
if (session)
|
|
173
|
+
session.responseHeaders = headers;
|
|
174
|
+
});
|
|
142
175
|
},
|
|
143
176
|
};
|
|
144
177
|
}
|
package/dist/otlp.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SeverityNumber } from "@opentelemetry/api-logs";
|
|
2
|
+
export declare function sendOtlpLog({ token, resourceAttributes, scopeName, severityNumber, body, }: {
|
|
3
|
+
token: string;
|
|
4
|
+
resourceAttributes: Record<string, string>;
|
|
5
|
+
scopeName: string;
|
|
6
|
+
severityNumber: SeverityNumber;
|
|
7
|
+
body: string;
|
|
8
|
+
}): Promise<void>;
|
package/dist/otlp.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendOtlpLog = sendOtlpLog;
|
|
4
|
+
const constants_js_1 = require("./constants.js");
|
|
5
|
+
const endpoint_js_1 = require("./endpoint.js");
|
|
6
|
+
// pcga11: Pipeline-independent OTLP log delivery.
|
|
7
|
+
// Use when the SDK's LoggerProvider/exporter never got set up or is
|
|
8
|
+
// broken (diagnostics). Not a client surface: no batching, no resource
|
|
9
|
+
// detectors, no trace correlation, one fetch per record. Client logs go
|
|
10
|
+
// through the Foam LoggerProvider in logs.ts.
|
|
11
|
+
async function sendOtlpLog({ token, resourceAttributes, scopeName, severityNumber, body, }) {
|
|
12
|
+
try {
|
|
13
|
+
await fetch(`${endpoint_js_1.endpoint}${constants_js_1.FOAM_OTLP_LOGS_PATH}`, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${token}`,
|
|
17
|
+
"Content-Type": "application/json",
|
|
18
|
+
},
|
|
19
|
+
body: JSON.stringify({
|
|
20
|
+
resourceLogs: [
|
|
21
|
+
{
|
|
22
|
+
resource: {
|
|
23
|
+
attributes: Object.entries(resourceAttributes).map(([key, value]) => ({ key, value: { stringValue: value } })),
|
|
24
|
+
},
|
|
25
|
+
scopeLogs: [
|
|
26
|
+
{
|
|
27
|
+
scope: { name: scopeName },
|
|
28
|
+
logRecords: [
|
|
29
|
+
{
|
|
30
|
+
timeUnixNano: String(BigInt(Date.now()) * 1000000n),
|
|
31
|
+
severityNumber,
|
|
32
|
+
severityText: constants_js_1.SEVERITY_TEXT[severityNumber],
|
|
33
|
+
body: { stringValue: body },
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// pcga11: do not remove this catch block. Ingest must never throw into application code.
|
|
45
|
+
}
|
|
46
|
+
}
|
package/dist/propagation.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Context } from "@opentelemetry/api";
|
|
2
2
|
export declare function injectTraceContext(carrier: Record<string, string>): void;
|
|
3
3
|
export declare function extractTraceContext(carrier: Record<string, string>): Context;
|
|
4
|
-
export declare
|
|
4
|
+
export declare function setBaggage<T>(key: string, value: string, callback: () => T): T | undefined;
|
|
5
5
|
export declare function getBaggage(key: string): string | undefined;
|
package/dist/propagation.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setBaggage = void 0;
|
|
4
3
|
exports.injectTraceContext = injectTraceContext;
|
|
5
4
|
exports.extractTraceContext = extractTraceContext;
|
|
5
|
+
exports.setBaggage = setBaggage;
|
|
6
6
|
exports.getBaggage = getBaggage;
|
|
7
7
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
8
8
|
const api_1 = require("@opentelemetry/api");
|
|
@@ -34,11 +34,13 @@ function injectTraceContext(carrier) {
|
|
|
34
34
|
function extractTraceContext(carrier) {
|
|
35
35
|
return (0, utils_js_1.safely)(() => propagator.extract(api_1.context.active(), carrier, api_1.defaultTextMapGetter), api_1.context.active());
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
function setBaggage(key, value, callback) {
|
|
38
|
+
if ((0, state_js_1.getSignal)(state_js_1.Signals.baggage) === state_js_1.SignalSources.none)
|
|
39
|
+
return undefined;
|
|
38
40
|
const next = new Map(baggageStorage.getStore() ?? []);
|
|
39
41
|
next.set(key, value);
|
|
40
|
-
baggageStorage.
|
|
41
|
-
}
|
|
42
|
+
return baggageStorage.run(next, callback);
|
|
43
|
+
}
|
|
42
44
|
function getBaggage(key) {
|
|
43
45
|
return (0, utils_js_1.safely)(() => baggageStorage.getStore()?.get(key) ??
|
|
44
46
|
api_1.propagation.getBaggage(api_1.context.active())?.getEntry(key)?.value, undefined);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const SENSITIVE_KEYS: readonly ["admin_password", "basic_auth_password", "confirm_password", "connection_password", "current_password", "database_password", "db_pass", "db_password", "ftp_password", "http_password", "keystore_password", "master_password", "mail_password", "mysql_pwd", "new_password", "old_password", "pass", "passcode", "passphrase", "passwd", "password", "password_confirmation", "postgres_password", "pwd", "redis_password", "root_password", "smtp_password", "user_password", "access_token_secret", "activation_token", "access_token", "api_token", "assertion", "auth", "auth_token", "authentication_token", "authorization", "authorization_code", "bearer", "bearer_token", "bot_token", "ci_job_token", "client_assertion", "client_secret", "credential", "credentials", "deploy_token", "email_verification_token", "id_token", "identity_token", "invite_token", "jwt", "jwt_token", "magic_link_token", "oauth_token", "oauth2_token", "oauth_token_secret", "password_reset_token", "personal_access_token", "registration_token", "request_token", "refresh_token", "reset_token", "saml_assertion", "saml_response", "secret_token", "security_token", "service_token", "sso_token", "token", "unsubscribe_token", "verification_token", "access_key", "access_key_id", "api_key", "api_secret", "amqp_url", "apikey", "app_key", "app_secret", "application_key", "application_secret", "aws_access_key_id", "aws_secret_access_key", "consumer_key", "consumer_secret", "broker_url", "connection_string", "connection_uri", "credential_blob", "decryption_key", "database_url", "database_connection_string", "db_url", "dsn", "encryption_key", "gcp_service_account_key", "google_application_credentials", "key", "key_password", "key_store_password", "keystore", "license_key", "mnemonic", "mongodb_uri", "kube_config", "kubeconfig", "pem", "private_key", "privatekey", "proxy_authorization", "redis_url", "redis_uri", "rabbitmq_url", "secret", "secret_access_key", "secret_key", "seed_phrase", "service_account_json", "service_account_key", "shared_secret", "signature", "signing_key", "signing_secret", "ssh_private_key", "smtp_url", "tls_private_key", "wallet_private_key", "wallet_seed", "webhook_secret", "www_authenticate", "_csrf", "_csrf_token", "_session", "_xsrf", "aiohttp_session", "anti_forgery_token", "backup_code", "backup_codes", "connect.sid", "cookie", "csrf", "csrf_token", "csrftoken", "django_session", "hotp", "laravel_session", "mfa", "mfa_code", "otp", "phpsessid", "pin", "recovery_code", "recovery_codes", "remember_token", "session", "session_id", "session_key", "session_token", "sessionid", "set_cookie", "setcookie", "sid", "symfony", "totp", "user_session", "x_csrf_token", "x_csrftoken", "x_xsrf_token", "xsrf", "xsrf_token", "account_number", "bank_account", "card", "card_number", "credit_card", "credit_card_number", "cvc", "cvv", "date_of_birth", "dob", "driver_license", "drivers_license", "iban", "ip_address", "national_id", "passport_number", "remote_addr", "routing_number", "sort_code", "ssn", "tax_id", "x_forwarded_for", "x_real_ip", "algolia_admin_api_key", "anthropic_api_key", "artifactory_api_key", "airtable_api_key", "azure_api_key", "buildkite_agent_token", "circle_token", "cohere_api_key", "cloudflare_api_token", "consul_http_token", "datadog_api_key", "datadog_app_key", "discord_bot_token", "docker_password", "docker_config_json", "digitalocean_token", "firebase_service_account", "gemini_api_key", "github_token", "gitlab_token", "google_api_key", "groq_api_key", "honeycomb_api_key", "huggingface_token", "heroku_api_key", "jfrog_access_token", "linear_api_key", "mapbox_access_token", "new_relic_license_key", "nomad_token", "notion_token", "npm_token", "openai_api_key", "pagerduty_routing_key", "pypi_token", "sentry_auth_token", "sentry_dsn", "sendgrid_api_key", "shopify_access_token", "shopify_api_secret", "slack_app_token", "slack_bot_token", "slack_signing_secret", "stripe_secret_key", "stripe_webhook_secret", "supabase_service_role_key", "telegram_bot_token", "terraform_cloud_token", "twilio_auth_token", "vault_token", "vercel_oidc_token", "x_api_key", "x_auth_token"];
|
|
2
|
+
export declare const SENSITIVE_HTTP_HEADERS: readonly ["authentication_info", "authorization", "cf_access_authenticated_user_email", "cf_access_jwt_assertion", "cookie", "grpcgateway_authorization", "impersonate_group", "impersonate_user", "jenkins_crumb", "job_token", "ocp_apim_subscription_key", "private_token", "proxy_authenticate", "proxy_authentication_info", "proxy_authorization", "set_cookie", "stripe_signature", "www_authenticate", "x_access_token", "x_algolia_api_key", "x_amz_credential", "x_amz_security_token", "x_amz_signature", "x_amzn_oidc_accesstoken", "x_amzn_oidc_data", "x_amzn_oidc_identity", "x_api_key", "x_asana_request_token", "x_aws_ec2_metadata_token", "x_auth_request_access_token", "x_auth_request_email", "x_auth_request_groups", "x_auth_request_preferred_username", "x_auth_request_user", "x_auth_token", "x_box_signature_primary", "x_box_signature_secondary", "x_cf_access_jwt_assertion", "x_csrf_token", "x_circle_token", "x_consul_token", "x_credential_identifier", "x_datadog_api_key", "x_discord_signature_ed25519", "x_docusign_signature_1", "x_dropbox_signature", "x_elastic_client_authentication", "x_firebase_appcheck", "x_forwarded_access_token", "x_forwarded_email", "x_forwarded_for", "x_forwarded_user", "x_functions_key", "x_github_token", "x_gitlab_token", "x_goog_api_key", "x_goog_firebase_installations_auth", "x_goog_iap_jwt_assertion", "x_hub_signature", "x_hub_signature_256", "x_honeycomb_api_key", "x_honeycomb_team", "x_intercom_hmac", "x_jwt_assertion", "x_linear_signature", "x_mailgun_signature", "x_master_key", "x_meili_api_key", "x_ms_client_principal", "x_ms_token_aad_access_token", "x_ms_token_aad_id_token", "x_ms_token_aad_refresh_token", "x_nf_client_connection_ip", "x_nomad_token", "x_npm_token", "x_original_authorization", "x_real_ip", "x_remote_email", "x_remote_groups", "x_remote_user", "x_pagerduty_signature", "x_parse_rest_api_key", "x_sendgrid_event_webhook_signature", "x_session_token", "x_shopify_hmac_sha256", "x_signature", "x_signature_ed25519", "x_slack_signature", "x_sonarqube_passcode", "x_squarespace_hmacsha256_signature", "x_twilio_signature", "x_typesense_api_key", "x_userinfo", "x_vault_token", "x_vercel_oidc_token", "x_webhook_signature", "x_webhook_secret", "x_wix_webhook_signature", "x_xsrf_token", "x_zendesk_webhook_signature"];
|
|
3
|
+
export declare const SENSITIVE_QUERY_KEYS: readonly ["access_token", "api_key", "api_secret", "api_token", "apikey", "assertion", "auth", "auth_token", "authorization", "authorization_code", "bearer_token", "client_assertion", "client_secret", "code", "code_verifier", "credential", "hmac", "id_token", "invite_token", "jwt", "key", "magic_link_token", "oauth_token_secret", "otp", "password_reset_token", "password", "policy", "pin", "refresh_token", "reset_token", "saml_response", "secret", "secret_key", "session", "session_id", "session_token", "sig", "signature", "token", "token_secret", "unsubscribe_token", "verification_token", "x_amz_credential", "x_amz_security_token", "x_amz_signature", "x_goog_credential", "x_goog_signature"];
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SENSITIVE_QUERY_KEYS = exports.SENSITIVE_HTTP_HEADERS = exports.SENSITIVE_KEYS = void 0;
|
|
4
|
+
const PASSWORD_KEYS = [
|
|
5
|
+
"admin_password",
|
|
6
|
+
"basic_auth_password",
|
|
7
|
+
"confirm_password",
|
|
8
|
+
"connection_password",
|
|
9
|
+
"current_password",
|
|
10
|
+
"database_password",
|
|
11
|
+
"db_pass",
|
|
12
|
+
"db_password",
|
|
13
|
+
"ftp_password",
|
|
14
|
+
"http_password",
|
|
15
|
+
"keystore_password",
|
|
16
|
+
"master_password",
|
|
17
|
+
"mail_password",
|
|
18
|
+
"mysql_pwd",
|
|
19
|
+
"new_password",
|
|
20
|
+
"old_password",
|
|
21
|
+
"pass",
|
|
22
|
+
"passcode",
|
|
23
|
+
"passphrase",
|
|
24
|
+
"passwd",
|
|
25
|
+
"password",
|
|
26
|
+
"password_confirmation",
|
|
27
|
+
"postgres_password",
|
|
28
|
+
"pwd",
|
|
29
|
+
"redis_password",
|
|
30
|
+
"root_password",
|
|
31
|
+
"smtp_password",
|
|
32
|
+
"user_password",
|
|
33
|
+
];
|
|
34
|
+
const TOKEN_KEYS = [
|
|
35
|
+
"access_token_secret",
|
|
36
|
+
"activation_token",
|
|
37
|
+
"access_token",
|
|
38
|
+
"api_token",
|
|
39
|
+
"assertion",
|
|
40
|
+
"auth",
|
|
41
|
+
"auth_token",
|
|
42
|
+
"authentication_token",
|
|
43
|
+
"authorization",
|
|
44
|
+
"authorization_code",
|
|
45
|
+
"bearer",
|
|
46
|
+
"bearer_token",
|
|
47
|
+
"bot_token",
|
|
48
|
+
"ci_job_token",
|
|
49
|
+
"client_assertion",
|
|
50
|
+
"client_secret",
|
|
51
|
+
"credential",
|
|
52
|
+
"credentials",
|
|
53
|
+
"deploy_token",
|
|
54
|
+
"email_verification_token",
|
|
55
|
+
"id_token",
|
|
56
|
+
"identity_token",
|
|
57
|
+
"invite_token",
|
|
58
|
+
"jwt",
|
|
59
|
+
"jwt_token",
|
|
60
|
+
"magic_link_token",
|
|
61
|
+
"oauth_token",
|
|
62
|
+
"oauth2_token",
|
|
63
|
+
"oauth_token_secret",
|
|
64
|
+
"password_reset_token",
|
|
65
|
+
"personal_access_token",
|
|
66
|
+
"registration_token",
|
|
67
|
+
"request_token",
|
|
68
|
+
"refresh_token",
|
|
69
|
+
"reset_token",
|
|
70
|
+
"saml_assertion",
|
|
71
|
+
"saml_response",
|
|
72
|
+
"secret_token",
|
|
73
|
+
"security_token",
|
|
74
|
+
"service_token",
|
|
75
|
+
"sso_token",
|
|
76
|
+
"token",
|
|
77
|
+
"unsubscribe_token",
|
|
78
|
+
"verification_token",
|
|
79
|
+
];
|
|
80
|
+
const KEY_MATERIAL_KEYS = [
|
|
81
|
+
"access_key",
|
|
82
|
+
"access_key_id",
|
|
83
|
+
"api_key",
|
|
84
|
+
"api_secret",
|
|
85
|
+
"amqp_url",
|
|
86
|
+
"apikey",
|
|
87
|
+
"app_key",
|
|
88
|
+
"app_secret",
|
|
89
|
+
"application_key",
|
|
90
|
+
"application_secret",
|
|
91
|
+
"aws_access_key_id",
|
|
92
|
+
"aws_secret_access_key",
|
|
93
|
+
"consumer_key",
|
|
94
|
+
"consumer_secret",
|
|
95
|
+
"broker_url",
|
|
96
|
+
"connection_string",
|
|
97
|
+
"connection_uri",
|
|
98
|
+
"credential_blob",
|
|
99
|
+
"decryption_key",
|
|
100
|
+
"database_url",
|
|
101
|
+
"database_connection_string",
|
|
102
|
+
"db_url",
|
|
103
|
+
"dsn",
|
|
104
|
+
"encryption_key",
|
|
105
|
+
"gcp_service_account_key",
|
|
106
|
+
"google_application_credentials",
|
|
107
|
+
"key",
|
|
108
|
+
"key_password",
|
|
109
|
+
"key_store_password",
|
|
110
|
+
"keystore",
|
|
111
|
+
"license_key",
|
|
112
|
+
"mnemonic",
|
|
113
|
+
"mongodb_uri",
|
|
114
|
+
"kube_config",
|
|
115
|
+
"kubeconfig",
|
|
116
|
+
"pem",
|
|
117
|
+
"private_key",
|
|
118
|
+
"privatekey",
|
|
119
|
+
"proxy_authorization",
|
|
120
|
+
"redis_url",
|
|
121
|
+
"redis_uri",
|
|
122
|
+
"rabbitmq_url",
|
|
123
|
+
"secret",
|
|
124
|
+
"secret_access_key",
|
|
125
|
+
"secret_key",
|
|
126
|
+
"seed_phrase",
|
|
127
|
+
"service_account_json",
|
|
128
|
+
"service_account_key",
|
|
129
|
+
"shared_secret",
|
|
130
|
+
"signature",
|
|
131
|
+
"signing_key",
|
|
132
|
+
"signing_secret",
|
|
133
|
+
"ssh_private_key",
|
|
134
|
+
"smtp_url",
|
|
135
|
+
"tls_private_key",
|
|
136
|
+
"wallet_private_key",
|
|
137
|
+
"wallet_seed",
|
|
138
|
+
"webhook_secret",
|
|
139
|
+
"www_authenticate",
|
|
140
|
+
];
|
|
141
|
+
const SESSION_KEYS = [
|
|
142
|
+
"_csrf",
|
|
143
|
+
"_csrf_token",
|
|
144
|
+
"_session",
|
|
145
|
+
"_xsrf",
|
|
146
|
+
"aiohttp_session",
|
|
147
|
+
"anti_forgery_token",
|
|
148
|
+
"backup_code",
|
|
149
|
+
"backup_codes",
|
|
150
|
+
"connect.sid",
|
|
151
|
+
"cookie",
|
|
152
|
+
"csrf",
|
|
153
|
+
"csrf_token",
|
|
154
|
+
"csrftoken",
|
|
155
|
+
"django_session",
|
|
156
|
+
"hotp",
|
|
157
|
+
"laravel_session",
|
|
158
|
+
"mfa",
|
|
159
|
+
"mfa_code",
|
|
160
|
+
"otp",
|
|
161
|
+
"phpsessid",
|
|
162
|
+
"pin",
|
|
163
|
+
"recovery_code",
|
|
164
|
+
"recovery_codes",
|
|
165
|
+
"remember_token",
|
|
166
|
+
"session",
|
|
167
|
+
"session_id",
|
|
168
|
+
"session_key",
|
|
169
|
+
"session_token",
|
|
170
|
+
"sessionid",
|
|
171
|
+
"set_cookie",
|
|
172
|
+
"setcookie",
|
|
173
|
+
"sid",
|
|
174
|
+
"symfony",
|
|
175
|
+
"totp",
|
|
176
|
+
"user_session",
|
|
177
|
+
"x_csrf_token",
|
|
178
|
+
"x_csrftoken",
|
|
179
|
+
"x_xsrf_token",
|
|
180
|
+
"xsrf",
|
|
181
|
+
"xsrf_token",
|
|
182
|
+
];
|
|
183
|
+
const PERSONAL_AND_FINANCIAL_KEYS = [
|
|
184
|
+
"account_number",
|
|
185
|
+
"bank_account",
|
|
186
|
+
"card",
|
|
187
|
+
"card_number",
|
|
188
|
+
"credit_card",
|
|
189
|
+
"credit_card_number",
|
|
190
|
+
"cvc",
|
|
191
|
+
"cvv",
|
|
192
|
+
"date_of_birth",
|
|
193
|
+
"dob",
|
|
194
|
+
"driver_license",
|
|
195
|
+
"drivers_license",
|
|
196
|
+
"iban",
|
|
197
|
+
"ip_address",
|
|
198
|
+
"national_id",
|
|
199
|
+
"passport_number",
|
|
200
|
+
"remote_addr",
|
|
201
|
+
"routing_number",
|
|
202
|
+
"sort_code",
|
|
203
|
+
"ssn",
|
|
204
|
+
"tax_id",
|
|
205
|
+
"x_forwarded_for",
|
|
206
|
+
"x_real_ip",
|
|
207
|
+
];
|
|
208
|
+
const PROVIDER_KEYS = [
|
|
209
|
+
"algolia_admin_api_key",
|
|
210
|
+
"anthropic_api_key",
|
|
211
|
+
"artifactory_api_key",
|
|
212
|
+
"airtable_api_key",
|
|
213
|
+
"azure_api_key",
|
|
214
|
+
"buildkite_agent_token",
|
|
215
|
+
"circle_token",
|
|
216
|
+
"cohere_api_key",
|
|
217
|
+
"cloudflare_api_token",
|
|
218
|
+
"consul_http_token",
|
|
219
|
+
"datadog_api_key",
|
|
220
|
+
"datadog_app_key",
|
|
221
|
+
"discord_bot_token",
|
|
222
|
+
"docker_password",
|
|
223
|
+
"docker_config_json",
|
|
224
|
+
"digitalocean_token",
|
|
225
|
+
"firebase_service_account",
|
|
226
|
+
"gemini_api_key",
|
|
227
|
+
"github_token",
|
|
228
|
+
"gitlab_token",
|
|
229
|
+
"google_api_key",
|
|
230
|
+
"groq_api_key",
|
|
231
|
+
"honeycomb_api_key",
|
|
232
|
+
"huggingface_token",
|
|
233
|
+
"heroku_api_key",
|
|
234
|
+
"jfrog_access_token",
|
|
235
|
+
"linear_api_key",
|
|
236
|
+
"mapbox_access_token",
|
|
237
|
+
"new_relic_license_key",
|
|
238
|
+
"nomad_token",
|
|
239
|
+
"notion_token",
|
|
240
|
+
"npm_token",
|
|
241
|
+
"openai_api_key",
|
|
242
|
+
"pagerduty_routing_key",
|
|
243
|
+
"pypi_token",
|
|
244
|
+
"sentry_auth_token",
|
|
245
|
+
"sentry_dsn",
|
|
246
|
+
"sendgrid_api_key",
|
|
247
|
+
"shopify_access_token",
|
|
248
|
+
"shopify_api_secret",
|
|
249
|
+
"slack_app_token",
|
|
250
|
+
"slack_bot_token",
|
|
251
|
+
"slack_signing_secret",
|
|
252
|
+
"stripe_secret_key",
|
|
253
|
+
"stripe_webhook_secret",
|
|
254
|
+
"supabase_service_role_key",
|
|
255
|
+
"telegram_bot_token",
|
|
256
|
+
"terraform_cloud_token",
|
|
257
|
+
"twilio_auth_token",
|
|
258
|
+
"vault_token",
|
|
259
|
+
"vercel_oidc_token",
|
|
260
|
+
"x_api_key",
|
|
261
|
+
"x_auth_token",
|
|
262
|
+
];
|
|
263
|
+
exports.SENSITIVE_KEYS = [
|
|
264
|
+
...PASSWORD_KEYS,
|
|
265
|
+
...TOKEN_KEYS,
|
|
266
|
+
...KEY_MATERIAL_KEYS,
|
|
267
|
+
...SESSION_KEYS,
|
|
268
|
+
...PERSONAL_AND_FINANCIAL_KEYS,
|
|
269
|
+
...PROVIDER_KEYS,
|
|
270
|
+
];
|
|
271
|
+
exports.SENSITIVE_HTTP_HEADERS = [
|
|
272
|
+
"authentication_info",
|
|
273
|
+
"authorization",
|
|
274
|
+
"cf_access_authenticated_user_email",
|
|
275
|
+
"cf_access_jwt_assertion",
|
|
276
|
+
"cookie",
|
|
277
|
+
"grpcgateway_authorization",
|
|
278
|
+
"impersonate_group",
|
|
279
|
+
"impersonate_user",
|
|
280
|
+
"jenkins_crumb",
|
|
281
|
+
"job_token",
|
|
282
|
+
"ocp_apim_subscription_key",
|
|
283
|
+
"private_token",
|
|
284
|
+
"proxy_authenticate",
|
|
285
|
+
"proxy_authentication_info",
|
|
286
|
+
"proxy_authorization",
|
|
287
|
+
"set_cookie",
|
|
288
|
+
"stripe_signature",
|
|
289
|
+
"www_authenticate",
|
|
290
|
+
"x_access_token",
|
|
291
|
+
"x_algolia_api_key",
|
|
292
|
+
"x_amz_credential",
|
|
293
|
+
"x_amz_security_token",
|
|
294
|
+
"x_amz_signature",
|
|
295
|
+
"x_amzn_oidc_accesstoken",
|
|
296
|
+
"x_amzn_oidc_data",
|
|
297
|
+
"x_amzn_oidc_identity",
|
|
298
|
+
"x_api_key",
|
|
299
|
+
"x_asana_request_token",
|
|
300
|
+
"x_aws_ec2_metadata_token",
|
|
301
|
+
"x_auth_request_access_token",
|
|
302
|
+
"x_auth_request_email",
|
|
303
|
+
"x_auth_request_groups",
|
|
304
|
+
"x_auth_request_preferred_username",
|
|
305
|
+
"x_auth_request_user",
|
|
306
|
+
"x_auth_token",
|
|
307
|
+
"x_box_signature_primary",
|
|
308
|
+
"x_box_signature_secondary",
|
|
309
|
+
"x_cf_access_jwt_assertion",
|
|
310
|
+
"x_csrf_token",
|
|
311
|
+
"x_circle_token",
|
|
312
|
+
"x_consul_token",
|
|
313
|
+
"x_credential_identifier",
|
|
314
|
+
"x_datadog_api_key",
|
|
315
|
+
"x_discord_signature_ed25519",
|
|
316
|
+
"x_docusign_signature_1",
|
|
317
|
+
"x_dropbox_signature",
|
|
318
|
+
"x_elastic_client_authentication",
|
|
319
|
+
"x_firebase_appcheck",
|
|
320
|
+
"x_forwarded_access_token",
|
|
321
|
+
"x_forwarded_email",
|
|
322
|
+
"x_forwarded_for",
|
|
323
|
+
"x_forwarded_user",
|
|
324
|
+
"x_functions_key",
|
|
325
|
+
"x_github_token",
|
|
326
|
+
"x_gitlab_token",
|
|
327
|
+
"x_goog_api_key",
|
|
328
|
+
"x_goog_firebase_installations_auth",
|
|
329
|
+
"x_goog_iap_jwt_assertion",
|
|
330
|
+
"x_hub_signature",
|
|
331
|
+
"x_hub_signature_256",
|
|
332
|
+
"x_honeycomb_api_key",
|
|
333
|
+
"x_honeycomb_team",
|
|
334
|
+
"x_intercom_hmac",
|
|
335
|
+
"x_jwt_assertion",
|
|
336
|
+
"x_linear_signature",
|
|
337
|
+
"x_mailgun_signature",
|
|
338
|
+
"x_master_key",
|
|
339
|
+
"x_meili_api_key",
|
|
340
|
+
"x_ms_client_principal",
|
|
341
|
+
"x_ms_token_aad_access_token",
|
|
342
|
+
"x_ms_token_aad_id_token",
|
|
343
|
+
"x_ms_token_aad_refresh_token",
|
|
344
|
+
"x_nf_client_connection_ip",
|
|
345
|
+
"x_nomad_token",
|
|
346
|
+
"x_npm_token",
|
|
347
|
+
"x_original_authorization",
|
|
348
|
+
"x_real_ip",
|
|
349
|
+
"x_remote_email",
|
|
350
|
+
"x_remote_groups",
|
|
351
|
+
"x_remote_user",
|
|
352
|
+
"x_pagerduty_signature",
|
|
353
|
+
"x_parse_rest_api_key",
|
|
354
|
+
"x_sendgrid_event_webhook_signature",
|
|
355
|
+
"x_session_token",
|
|
356
|
+
"x_shopify_hmac_sha256",
|
|
357
|
+
"x_signature",
|
|
358
|
+
"x_signature_ed25519",
|
|
359
|
+
"x_slack_signature",
|
|
360
|
+
"x_sonarqube_passcode",
|
|
361
|
+
"x_squarespace_hmacsha256_signature",
|
|
362
|
+
"x_twilio_signature",
|
|
363
|
+
"x_typesense_api_key",
|
|
364
|
+
"x_userinfo",
|
|
365
|
+
"x_vault_token",
|
|
366
|
+
"x_vercel_oidc_token",
|
|
367
|
+
"x_webhook_signature",
|
|
368
|
+
"x_webhook_secret",
|
|
369
|
+
"x_wix_webhook_signature",
|
|
370
|
+
"x_xsrf_token",
|
|
371
|
+
"x_zendesk_webhook_signature",
|
|
372
|
+
];
|
|
373
|
+
exports.SENSITIVE_QUERY_KEYS = [
|
|
374
|
+
"access_token",
|
|
375
|
+
"api_key",
|
|
376
|
+
"api_secret",
|
|
377
|
+
"api_token",
|
|
378
|
+
"apikey",
|
|
379
|
+
"assertion",
|
|
380
|
+
"auth",
|
|
381
|
+
"auth_token",
|
|
382
|
+
"authorization",
|
|
383
|
+
"authorization_code",
|
|
384
|
+
"bearer_token",
|
|
385
|
+
"client_assertion",
|
|
386
|
+
"client_secret",
|
|
387
|
+
"code",
|
|
388
|
+
"code_verifier",
|
|
389
|
+
"credential",
|
|
390
|
+
"hmac",
|
|
391
|
+
"id_token",
|
|
392
|
+
"invite_token",
|
|
393
|
+
"jwt",
|
|
394
|
+
"key",
|
|
395
|
+
"magic_link_token",
|
|
396
|
+
"oauth_token_secret",
|
|
397
|
+
"otp",
|
|
398
|
+
"password_reset_token",
|
|
399
|
+
"password",
|
|
400
|
+
"policy",
|
|
401
|
+
"pin",
|
|
402
|
+
"refresh_token",
|
|
403
|
+
"reset_token",
|
|
404
|
+
"saml_response",
|
|
405
|
+
"secret",
|
|
406
|
+
"secret_key",
|
|
407
|
+
"session",
|
|
408
|
+
"session_id",
|
|
409
|
+
"session_token",
|
|
410
|
+
"sig",
|
|
411
|
+
"signature",
|
|
412
|
+
"token",
|
|
413
|
+
"token_secret",
|
|
414
|
+
"unsubscribe_token",
|
|
415
|
+
"verification_token",
|
|
416
|
+
"x_amz_credential",
|
|
417
|
+
"x_amz_security_token",
|
|
418
|
+
"x_amz_signature",
|
|
419
|
+
"x_goog_credential",
|
|
420
|
+
"x_goog_signature",
|
|
421
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface RedactOptions {
|
|
2
|
+
readonly secrets?: readonly string[];
|
|
3
|
+
readonly pii?: readonly string[];
|
|
4
|
+
}
|
|
5
|
+
export interface RedactionConfig {
|
|
6
|
+
readonly secretKeys: ReadonlySet<string>;
|
|
7
|
+
readonly piiKeys: ReadonlySet<string>;
|
|
8
|
+
}
|
|
9
|
+
export type KeyMatchKind = "floor" | "pii" | "secret";
|
|
10
|
+
export declare function setActiveRedactionConfig(config: RedactionConfig): void;
|
|
11
|
+
export declare function getActiveRedactionConfig(): RedactionConfig;
|
|
12
|
+
export declare function normalizeKey(key: string): string;
|
|
13
|
+
export declare function isFloorKey(key: string): boolean;
|
|
14
|
+
export declare function isSensitiveQueryKey(key: string): boolean;
|
|
15
|
+
export declare function keyMatch(key: string, config?: RedactionConfig): KeyMatchKind | undefined;
|
|
16
|
+
export declare function tailMask(value: unknown): string;
|
|
17
|
+
export declare function maskForMatch(kind: KeyMatchKind, value: unknown): string;
|
|
18
|
+
export declare function redactQueryPairs(query: string, config?: RedactionConfig): string;
|
|
19
|
+
export declare function redactUrlLike(text: string, config?: RedactionConfig): string;
|
|
20
|
+
export declare function redactString(text: string, config?: RedactionConfig): string;
|
|
21
|
+
export declare function redactDeep(value: unknown, config?: RedactionConfig): unknown;
|
|
22
|
+
export declare function redactAttributeValue(key: string, value: unknown, config?: RedactionConfig): unknown;
|
|
23
|
+
export declare function redactAttributesCopy(attributes: Readonly<Record<string, unknown>>, config?: RedactionConfig): Record<string, unknown>;
|
|
24
|
+
export declare function resolveRedactionConfig(redact: unknown): RedactionConfig;
|