Skip to main content

Pluggable framework for personal data compliance (LGPD/GDPR)

Project description

PyPI version npm version License: MIT

PrivacySchema

Pluggable framework for anonymization, consent, retention, and access to personal data (LGPD/GDPR).

Purpose

Facilitate the implementation of sensitive data compliance in different languages (Node.js, Python, JS via CDN).

Features

  • Personal data validation (CPF, email, etc.)
  • Data masking (CPF, email, etc.)
  • Consent management (register, update, revoke)
  • Retention policy (mark for expiration/removal)
  • Audit logging (operations on sensitive data)

Usage examples

JavaScript/Node.js

const privacy = require('privacyschema');

// Validation
const validationResult = privacy.validation.validate({ cpf: '12345678909', email: 'test@example.com' });
console.log(validationResult); // { cpf: true, email: true }

// Masking
console.log(privacy.masking.mask('cpf', '12345678900')); // *********00
console.log(privacy.masking.mask('email', 'john.doe@example.com')); // j********e@example.com

// Consent
privacy.consent.registerConsent('user1', { purpose: 'marketing' });
console.log(privacy.consent.isConsentActive('user1')); // true
privacy.consent.revokeConsent('user1');
console.log(privacy.consent.isConsentActive('user1')); // false

// Retention
const now = new Date();
const past = new Date(now.getTime() - 10000);
privacy.retention.markForExpiration('user2', past);
console.log(privacy.retention.isExpired('user2')); // true

// Audit
privacy.audit.logOperation('user3', 'access', { field: 'cpf' });
console.log(privacy.audit.getAuditLogs());

Python

from privacyschema import (
    validate, is_valid_cpf, is_valid_email, mask,
    register_consent, update_consent, revoke_consent, is_consent_active,
    mark_for_expiration, is_expired,
    log_operation, get_audit_logs
)
from datetime import datetime, timedelta

# Validation
result = validate({'cpf': '12345678909', 'email': 'test@example.com'})
print(result)  # {'cpf': True, 'email': True}

# Masking
print(mask('cpf', '12345678900'))  # *********00
print(mask('email', 'john.doe@example.com'))  # j********e@example.com

# Consent
register_consent('user1', {'purpose': 'marketing'})
print(is_consent_active('user1'))  # True
revoke_consent('user1')
print(is_consent_active('user1'))  # False

# Retention
past = datetime.now() - timedelta(seconds=10)
mark_for_expiration('user2', past)
print(is_expired('user2'))  # True

# Audit
log_operation('user3', 'access', {'field': 'cpf'})
print(get_audit_logs())

Installation

Node.js

npm install privacyschema

Python

pip install privacyschema

CDN

<script src="https://cdn.jsdelivr.net/npm/privacyschema"></script>

Contributing

See CONTRIBUTING.md.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

privacyschema-0.2.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

privacyschema-0.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file privacyschema-0.2.0.tar.gz.

File metadata

  • Download URL: privacyschema-0.2.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for privacyschema-0.2.0.tar.gz
Algorithm Hash digest
SHA256 38613ea971ea6a9a786eb92f3e8cb3db6051bb8e5e1ffdc02e5b1eb96cdc79f8
MD5 c62b957e9cb23505642fe175960177ca
BLAKE2b-256 d650c82fcf0bf392e949917cd5ee7c77249ad547161eec65c34c1a69311a872f

See more details on using hashes here.

File details

Details for the file privacyschema-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: privacyschema-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for privacyschema-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd30e54e12d8fbfb025ddada9bd10ffdb9e7c5f953573d2e134648f3ce0be8fb
MD5 031652106b889cc3aa76402eb689d9cf
BLAKE2b-256 f33f2a9ad600f60185d51840b6598ad3bfc09e41648f4b4108a766ed4a50218d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page