Pluggable framework for personal data compliance (LGPD/GDPR)
Project description
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38613ea971ea6a9a786eb92f3e8cb3db6051bb8e5e1ffdc02e5b1eb96cdc79f8
|
|
| MD5 |
c62b957e9cb23505642fe175960177ca
|
|
| BLAKE2b-256 |
d650c82fcf0bf392e949917cd5ee7c77249ad547161eec65c34c1a69311a872f
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd30e54e12d8fbfb025ddada9bd10ffdb9e7c5f953573d2e134648f3ce0be8fb
|
|
| MD5 |
031652106b889cc3aa76402eb689d9cf
|
|
| BLAKE2b-256 |
f33f2a9ad600f60185d51840b6598ad3bfc09e41648f4b4108a766ed4a50218d
|