
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@tpmjs/tools-redact-secrets
Advanced tools
Redact detected secrets from text by replacing them with [REDACTED:type] placeholders.
@tpmjs/tools-secret-scan-textnpm install @tpmjs/tools-redact-secrets
import { redactSecrets } from '@tpmjs/tools-redact-secrets';
const code = `
const AWS_KEY = "AKIAIOSFODNN7EXAMPLE";
const apiKey = "sk-proj-1234567890abcdef";
const dbUrl = "postgres://user:password123@localhost:5432/mydb";
`;
const result = await redactSecrets.execute({ text: code });
console.log(result.redacted);
// const AWS_KEY = "[REDACTED:aws-access-key]";
// const apiKey = "[REDACTED:openai-api-key]";
// const dbUrl = "[REDACTED:postgres-connection]";
console.log(result.redactions);
// [
// {
// type: 'aws-access-key',
// originalLength: 20,
// line: 2,
// column: 18,
// replacement: '[REDACTED:aws-access-key]'
// },
// {
// type: 'openai-api-key',
// originalLength: 24,
// line: 3,
// column: 17,
// replacement: '[REDACTED:openai-api-key]'
// },
// {
// type: 'postgres-connection',
// originalLength: 50,
// line: 4,
// column: 17,
// replacement: '[REDACTED:postgres-connection]'
// }
// ]
const text = `
My email is user@example.com
My phone is 555-1234
`;
const result = await redactSecrets.execute({
text,
customPatterns: [
'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}', // Email
'\\d{3}-\\d{4}', // Phone
],
});
console.log(result.redacted);
// My email is [REDACTED:custom-pattern]
// My phone is [REDACTED:custom-pattern]
import { redactSecrets } from '@tpmjs/tools-redact-secrets';
function safelog(message: string) {
const result = await redactSecrets.execute({ text: message });
console.log(result.redacted);
}
// Safe to log - secrets automatically redacted
safelog('Error connecting to postgres://admin:secret@db.example.com/prod');
// Output: Error connecting to [REDACTED:postgres-connection]
The tool automatically redacts:
Custom patterns can be provided as:
"pattern" - Treated as literal regex with global flag"/pattern/flags" - Parsed as regex with flagsExamples:
customPatterns: [
'CUSTOM-[A-Z0-9]{10}', // Plain string
'/SECRET_\\w+/gi', // Regex with flags
'[0-9]{3}-[0-9]{2}-[0-9]{4}', // SSN pattern
]
interface RedactionResult {
redacted: string; // Text with secrets replaced
redactionCount: number; // Total number of redactions
redactions: Array<{ // Details of each redaction
type: string;
originalLength: number;
line: number;
column: number;
replacement: string;
}>;
metadata: {
originalLength: number;
redactedLength: number;
linesProcessed: number;
};
}
MIT
FAQs
Redact detected secrets from text
The npm package @tpmjs/tools-redact-secrets receives a total of 2 weekly downloads. As such, @tpmjs/tools-redact-secrets popularity was classified as not popular.
We found that @tpmjs/tools-redact-secrets demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.