npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lanonasis/privacy-sdk

v1.0.0

Published

Enterprise-grade privacy utilities: PII detection, data masking, tokenization, and GDPR compliance. Part of the LanOnasis Security Suite.

Readme

@lanonasis/privacy-sdk

Enterprise-grade privacy utilities for PII detection, data masking, anonymization, and GDPR compliance.

Part of the LanOnasis Security Suite - Powered by VortexShield

npm version License: MIT


Features

  • Data Masking - Mask 15+ PII types (email, phone, SSN, cards, IBAN, etc.)
  • PII Detection - Automatic detection with confidence scoring
  • International Support - US, UK, EU formats (phone, postal, national IDs)
  • Validation - Luhn algorithm, checksum validation
  • Classification - Sensitivity levels and regulation mapping
  • Audit Logging - Track all privacy operations
  • Universal - Works in Node.js and browsers
  • Zero Dependencies - Lightweight and secure

Installation

npm install @lanonasis/privacy-sdk
# or
bun add @lanonasis/privacy-sdk

Quick Start

import { PrivacySDK, mask, detect, detectAndMask, scan } from '@lanonasis/privacy-sdk';

// Simple masking
mask('[email protected]', 'email');        // -> 'j**[email protected]'
mask('555-123-4567', 'phone');            // -> '***-***-4567'
mask('4111111111111111', 'credit-card');  // -> '************1111'

// PII detection
const results = detect('Contact [email protected] or call 555-123-4567');
// -> [{ type: 'email', value: '[email protected]', confidence: 0.99 }, ...]

// Detect and mask in one step
detectAndMask('Email me at [email protected]');
// -> 'Email me at s****[email protected]'

// Scan objects recursively
const report = scan({ user: { email: '[email protected]', phone: '555-111-2222' } });
// -> { piiFound: true, results: [...] }

API Reference

Masking

import { mask, PrivacySDK } from '@lanonasis/privacy-sdk';

// Basic masking
mask(data: string, type: PIIType, options?: MaskingOptions): string

// Supported types
type PIIType =
  | 'email'
  | 'phone'
  | 'ssn'
  | 'credit-card'
  | 'iban'
  | 'ip-address'
  | 'name'
  | 'uk-nino'
  | 'uk-postcode'
  | 'dob'
  | 'passport'
  | 'custom';

// Options
interface MaskingOptions {
  maskChar?: string;      // Default: '*'
  showFirst?: number;     // Characters to show at start
  showLast?: number;      // Characters to show at end
  preserveFormat?: boolean;
  locale?: 'US' | 'UK' | 'EU' | 'DE' | 'FR';
  pattern?: string | RegExp;  // For custom type
}

Examples

// Email
mask('[email protected]', 'email');
// -> 'j********[email protected]'

// Phone (international)
mask('+44 7911 123456', 'phone');
// -> '+** **** ***456'

// Credit card with options
mask('4111111111111111', 'credit-card', { showFirst: 4, showLast: 4 });
// -> '4111********1111'

// SSN
mask('123-45-6789', 'ssn');
// -> '***-**-6789'

// IBAN
mask('DE89 3704 0044 0532 0130 00', 'iban');
// -> 'DE** ************3000'

// UK National Insurance Number
mask('AB 12 34 56 C', 'uk-nino');
// -> '**********C'

// IP Address
mask('192.168.1.100', 'ip-address');
// -> '***.***..1.100'

// Custom pattern
mask('SECRET123', 'custom', { pattern: /[A-Z]+/g, maskChar: '#' });
// -> '######123'

Detection

import { detect, detectAndMask } from '@lanonasis/privacy-sdk';

// Detect PII
const results = detect(text: string, options?: { locale?: Locale });

// Returns
interface DetectionResult {
  type: PIIType;
  value: string;           // Original value
  masked: string;          // Masked version
  position: number;        // Position in text
  length: number;
  confidence: number;      // 0-1 confidence score
  sensitivity: 'low' | 'medium' | 'high' | 'critical';
  regulations: string[];   // ['GDPR', 'CCPA', 'PCI-DSS', etc.]
}

// Detect and mask in one step
const sanitized = detectAndMask(text);

Examples

const text = 'Contact [email protected] or call 555-987-6543. SSN: 123-45-6789';

const detected = detect(text);
// -> [
//   { type: 'email', value: '[email protected]', confidence: 0.99, sensitivity: 'high' },
//   { type: 'phone', value: '555-987-6543', confidence: 0.95, sensitivity: 'medium' },
//   { type: 'ssn', value: '123-45-6789', confidence: 0.98, sensitivity: 'critical' }
// ]

const sanitized = detectAndMask(text);
// -> 'Contact j***[email protected] or call ***-***-6543. SSN: ***-**-6789'

Object Scanning

import { scan, sanitize } from '@lanonasis/privacy-sdk';

// Scan objects recursively
const report = scan(obj, options?: ScanOptions);

interface ScanOptions {
  deep?: boolean;              // Scan nested objects (default: true)
  autoMask?: boolean;          // Return sanitized object
  confidenceThreshold?: number; // Min confidence (default: 0.7)
  includeFieldNames?: boolean;  // Use field name hints
}

// Returns
interface ScanResult {
  piiFound: boolean;
  results: Array<{ path: string; type: PIIType; value: string; masked: string }>;
  sanitized?: unknown;  // If autoMask: true
}

// Explicit field sanitization
const sanitized = sanitize(obj, fieldMappings);

Examples

// Recursive scan
const user = {
  id: 123,
  contact: {
    email: '[email protected]',
    phone: '555-111-2222'
  },
  cards: [{ number: '4111111111111111' }]
};

const report = scan(user, { deep: true, autoMask: true });
// report.piiFound = true
// report.results = [
//   { path: 'contact.email', type: 'email', ... },
//   { path: 'contact.phone', type: 'phone', ... },
//   { path: 'cards[0].number', type: 'credit-card', ... }
// ]
// report.sanitized = { ... masked object ... }

// Explicit sanitization
const customer = { email: '[email protected]', card: '4111111111111111' };
const safe = sanitize(customer, {
  email: 'email',
  card: { type: 'credit-card', showFirst: 4, showLast: 4 }
});
// -> { email: 't**[email protected]', card: '4111********1111' }

Classification

import { privacy } from '@lanonasis/privacy-sdk';

const result = privacy.classify('4111111111111111');
// -> {
//   type: 'credit-card',
//   sensitivity: 'critical',
//   confidence: 0.98,
//   regulations: ['PCI-DSS', 'GDPR', 'CCPA']
// }

Anonymization

import { privacy } from '@lanonasis/privacy-sdk';

// Deterministic anonymous ID (same input = same output)
privacy.generateAnonymousId('user123', 'salt');
// -> 'anon_a1b2c3d4e5f6g7h8'

// Random token
privacy.generateToken(16);
// -> 'f4c7e9a2b1d8c3f5...' (32 hex chars)

// One-way hash
privacy.hash('sensitive-data', 'salt');
// -> '8f14e45f...'

Custom Patterns

import { privacy } from '@lanonasis/privacy-sdk';

// Register custom pattern
privacy.registerPattern({
  type: 'employee-id',
  pattern: /EMP-\d{6}/gi,
  sensitivity: 'medium',
  regulations: ['Internal'],
  validate: (value) => value.startsWith('EMP-'),
});

// Now detects your custom type
privacy.detect('Contact EMP-123456 for help');
// -> [{ type: 'employee-id', value: 'EMP-123456', ... }]

Audit Logging

import { PrivacySDK } from '@lanonasis/privacy-sdk';

const privacy = new PrivacySDK({ auditLog: true });

privacy.mask('[email protected]', 'email');
privacy.detect('555-123-4567');

const log = privacy.getAuditLog();
// -> [
//   { timestamp, operation: 'mask', dataType: 'email', success: true },
//   { timestamp, operation: 'detect', success: true }
// ]

// Filter by operation
privacy.getAuditLog({ operation: 'mask' });

// Clear log
privacy.clearAuditLog();

Configuration

import { PrivacySDK } from '@lanonasis/privacy-sdk';

const privacy = new PrivacySDK({
  // Masking
  enableMasking: true,
  defaultMaskChar: '*',
  preserveFormat: true,

  // Detection
  enableAutoDetect: true,
  confidenceThreshold: 0.7,
  detectFieldNames: true,

  // Compliance
  gdprMode: true,
  auditLog: true,

  // Logging
  logLevel: 'basic',
});

// Update config at runtime
privacy.configure({ defaultMaskChar: '#' });

Supported PII Types

| Type | Format | Sensitivity | Regulations | |------|--------|-------------|-------------| | email | Standard email | High | GDPR, CCPA | | phone | US/UK/EU/International | Medium | CCPA | | ssn | XXX-XX-XXXX | Critical | HIPAA, CCPA | | credit-card | Major card formats | Critical | PCI-DSS, GDPR | | iban | EU bank accounts | High | GDPR, PCI-DSS | | ip-address | IPv4, IPv6 | Medium | GDPR | | dob | MM/DD/YYYY, DD/MM/YYYY | High | GDPR, HIPAA | | uk-nino | National Insurance | Critical | GDPR | | uk-postcode | UK postal codes | Medium | GDPR | | passport | US passport numbers | Critical | GDPR | | name | Personal names | Medium | GDPR |


Integration with LanOnasis Suite

// Use with @lanonasis/security-sdk for encryption
import { PrivacySDK } from '@lanonasis/privacy-sdk';
import { SecuritySDK } from '@lanonasis/security-sdk';

const privacy = new PrivacySDK();
const security = new SecuritySDK(process.env.MASTER_KEY);

// Mask, then encrypt sensitive data
const masked = privacy.mask(userSSN, 'ssn');
const encrypted = security.encrypt(masked, 'user_context');

Related Packages

| Package | Purpose | |---------|---------| | @lanonasis/security-sdk | Encryption, key management | | @lanonasis/security-shield | Edge bot protection | | @lanonasis/mem-intel-sdk | Memory intelligence |


License

MIT (c) LanOnasis


Built with care by the LanOnasis team - VortexShield