Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@bagdock/pii-patterns

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bagdock/pii-patterns

PII regex patterns and scrubbing utilities for Bagdock

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source
  ----++                                ----++                    ---+++     
  ---+++                                ---++                     ---++      
 ----+---     -----     ---------  --------++ ------     -----   ----++----- 
 ---------+ --------++----------++--------+++--------+ --------++---++---++++
 ---+++---++ ++++---++---+++---++---+++---++---+++---++---++---++------++++  
----++ ---++--------++---++----++---+++---++---++ ---+---++     -------++    
----+----+---+++---++---++----++---++----++---++---+++--++ --------+---++   
---------++--------+++--------+++--------++ -------+++ -------++---++----++  
 +++++++++   +++++++++- +++---++   ++++++++    ++++++    ++++++  ++++  ++++  
                     --------+++                                             
                       +++++++                                               

@bagdock/pii-patterns

PII regex patterns and scrubbing utilities for the Bagdock platform — 15-pattern defense-in-depth redaction for personally identifiable information.

npm version License: MIT

Install

npm install @bagdock/pii-patterns
yarn add @bagdock/pii-patterns
pnpm add @bagdock/pii-patterns
bun add @bagdock/pii-patterns

Usage

import { scrubPii, scrubPiiDeep, scrubMessagesForModel } from '@bagdock/pii-patterns'

// Scrub a single string
scrubPii('Email me at john@example.com')
// → 'Email me at [EMAIL_REDACTED]'

// Recursively scrub nested objects
scrubPiiDeep({ email: 'john@example.com', count: 42 })
// → { email: '[EMAIL_REDACTED]', count: 42 }

// Scrub user messages before sending to an AI model
const messages = [
  { role: 'system', content: 'You are helpful.' },
  { role: 'user', content: 'My SSN is 123-45-6789' },
]
scrubMessagesForModel(messages)
// → [{ role: 'system', content: 'You are helpful.' },
//    { role: 'user', content: 'My SSN is [SSN_REDACTED]' }]

API

scrubPii(text: string): string

Applies all 15 PII patterns in order and returns the redacted string.

scrubPiiDeep(value: unknown): unknown

Recursively walks objects and arrays, scrubbing any string values. Non-string primitives pass through unchanged.

scrubMessagesForModel<T>(messages: T[]): T[]

Scrubs PII from user role messages before AI inference. Assistant and system messages pass through unchanged. Returns a shallow copy — originals are not mutated.

Patterns

15 PII types are detected and redacted:

PatternTokenCoverage
Email address[EMAIL_REDACTED]Global
Social Security Number[SSN_REDACTED]US
National Insurance Number[NINO_REDACTED]UK
IBAN[IBAN_REDACTED]EU/UK
NHS Number[NHS_REDACTED]UK
PPS Number[PPSN_REDACTED]Ireland
Driving Licence[LICENCE_REDACTED]UK (DVLA format)
Sort Code + Account[BANKACCT_REDACTED]UK
VAT Number[VAT_REDACTED]EU
Credit/Debit Card[CARD_REDACTED]Global
Phone Number[PHONE_REDACTED]Global
Date of Birth[DOB_REDACTED]Global
Postcode[POSTCODE_REDACTED]UK
ZIP Code[ZIP_REDACTED]US
Passport/ID Number[ID_REDACTED]Global

Defense-in-depth

This package provides client-side PII scrubbing as a defense-in-depth layer. It is not a substitute for server-side controls. The Bagdock platform applies authoritative PII scrubbing on the server edge before any AI model receives input.

License

MIT — see LICENSE.

Keywords

pii

FAQs

Package last updated on 12 Apr 2026

Did you know?

Socket

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.

Install

Related posts