@revealui/security 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +96 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # @revealui/security
2
+
3
+ Security infrastructure for RevealUI. Provides HTTP security headers, CORS management, RBAC/ABAC authorization, field-level encryption, audit logging, and GDPR compliance tooling.
4
+
5
+ ## When to Use This
6
+
7
+ - You need security headers (CSP, HSTS, CORS) on HTTP responses
8
+ - You're implementing role-based or attribute-based access control
9
+ - You need audit logging for compliance (SOC2, HIPAA)
10
+ - You need GDPR tooling: consent management, data export, breach reporting, anonymization
11
+ - You need field-level encryption or key rotation
12
+
13
+ If you only need session auth (login/logout/password reset), use `@revealui/auth` instead.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pnpm add @revealui/security
19
+ ```
20
+
21
+ Dependencies: `@revealui/contracts`, `@revealui/utils`
22
+
23
+ ## API Reference
24
+
25
+ ### Security Headers & CORS
26
+
27
+ | Export | Type | Purpose |
28
+ |--------|------|---------|
29
+ | `SecurityHeaders` | Class | Generate CSP, HSTS, Permissions-Policy, X-Frame-Options headers |
30
+ | `SecurityPresets` | Object | Pre-built header configs (strict, moderate, development) |
31
+ | `CORSManager` | Class | CORS origin/method/header management |
32
+ | `CORSPresets` | Object | Pre-built CORS configs (restrictive, public API, development) |
33
+ | `createSecurityMiddleware` | Function | Hono middleware applying all security headers |
34
+ | `setRateLimitHeaders` | Function | Add X-RateLimit-* headers to responses |
35
+
36
+ ### Authorization (RBAC + ABAC)
37
+
38
+ | Export | Type | Purpose |
39
+ |--------|------|---------|
40
+ | `AuthorizationSystem` | Class | Combined RBAC + ABAC policy engine |
41
+ | `CommonRoles` | Object | Pre-defined roles (admin, editor, viewer, superAdmin) |
42
+ | `PolicyBuilder` | Class | Fluent API for building ABAC policies |
43
+ | `PermissionBuilder` | Class | Fluent API for building RBAC permissions |
44
+ | `PermissionCache` | Class | LRU cache for permission lookups |
45
+ | `canAccessResource` | Function | Check if user can perform action on resource |
46
+ | `checkAttributeAccess` | Function | Evaluate ABAC policy conditions |
47
+ | `createAuthorizationMiddleware` | Function | Hono middleware for route-level authorization |
48
+ | `RequirePermission` | Decorator | Enforce permission on class methods |
49
+ | `RequireRole` | Decorator | Enforce role on class methods |
50
+
51
+ ### Encryption
52
+
53
+ | Export | Type | Purpose |
54
+ |--------|------|---------|
55
+ | `EncryptionSystem` | Class | AES-256 encryption with key management |
56
+ | `EnvelopeEncryption` | Class | Envelope encryption (data key + master key) |
57
+ | `FieldEncryption` | Class | Encrypt/decrypt individual database fields |
58
+ | `KeyRotationManager` | Class | Scheduled key rotation with re-encryption |
59
+ | `DataMasking` | Class | Mask sensitive data for display (email, phone, SSN) |
60
+ | `TokenGenerator` | Class | Secure random token generation |
61
+
62
+ ### Audit Logging
63
+
64
+ | Export | Type | Purpose |
65
+ |--------|------|---------|
66
+ | `AuditSystem` | Class | Structured audit event recording |
67
+ | `AuditTrail` | Class | Query and filter audit history |
68
+ | `AuditReportGenerator` | Class | Generate compliance reports from audit data |
69
+ | `createAuditMiddleware` | Function | Hono middleware for automatic request auditing |
70
+ | `InMemoryAuditStorage` | Class | In-memory storage for testing |
71
+
72
+ ### GDPR Compliance
73
+
74
+ | Export | Type | Purpose |
75
+ |--------|------|---------|
76
+ | `ConsentManager` | Class | Record and query user consent |
77
+ | `CookieConsentManager` | Class | Browser cookie consent banner state |
78
+ | `DataDeletionSystem` | Class | Right-to-erasure request processing |
79
+ | `DataExportSystem` | Class | Right-to-portability data export |
80
+ | `DataAnonymization` | Class | Anonymize user data while preserving analytics |
81
+ | `DataBreachManager` | Class | Breach detection, notification, and reporting |
82
+ | `PrivacyPolicyManager` | Class | Version and publish privacy policies |
83
+ | `InMemoryGDPRStorage` | Class | In-memory GDPR storage for testing |
84
+ | `InMemoryBreachStorage` | Class | In-memory breach storage for testing |
85
+
86
+ ## JOSHUA Alignment
87
+
88
+ - **Hermetic**: Security boundaries are sealed — auth checks happen at middleware, never inside business logic
89
+ - **Sovereign**: All security infrastructure runs in your deployment, no external auth service required
90
+ - **Justifiable**: Every security header and policy has a documented reason (CSP prevents XSS, HSTS forces HTTPS, etc.)
91
+
92
+ ## Related Packages
93
+
94
+ - `@revealui/auth` — Session-based authentication (login, password reset, OAuth)
95
+ - `@revealui/core` — Applies security middleware to CMS routes
96
+ - `@revealui/contracts` — Shared types for roles, permissions, consent records
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@revealui/security",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Security infrastructure for RevealUI - headers, CORS, RBAC/ABAC, encryption, audit, GDPR",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "@revealui/contracts": "1.3.3",
8
- "@revealui/utils": "0.3.0"
7
+ "@revealui/contracts": "1.3.4",
8
+ "@revealui/utils": "0.3.1"
9
9
  },
10
10
  "devDependencies": {
11
11
  "@types/node": "^25.5.0",