@revealui/security 0.0.1-pre.0 → 0.2.0

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.
@@ -0,0 +1,1358 @@
1
+ /**
2
+ * Audit Logging System
3
+ *
4
+ * Track security-relevant events and user actions for compliance
5
+ */
6
+ type AuditEventType = 'auth.login' | 'auth.logout' | 'auth.failed_login' | 'auth.password_change' | 'auth.password_reset' | 'auth.mfa_enabled' | 'auth.mfa_disabled' | 'user.create' | 'user.update' | 'user.delete' | 'user.view' | 'data.create' | 'data.read' | 'data.update' | 'data.delete' | 'data.export' | 'permission.grant' | 'permission.revoke' | 'role.assign' | 'role.remove' | 'config.change' | 'security.violation' | 'security.alert' | 'gdpr.consent' | 'gdpr.data_request' | 'gdpr.data_deletion' | `data.${string}` | `permission.${string}` | `security.${string}` | `gdpr.${string}`;
7
+ type AuditSeverity = 'low' | 'medium' | 'high' | 'critical';
8
+ interface AuditEvent {
9
+ id: string;
10
+ timestamp: string;
11
+ type: AuditEventType;
12
+ severity: AuditSeverity;
13
+ actor: {
14
+ id: string;
15
+ type: 'user' | 'system' | 'api';
16
+ ip?: string;
17
+ userAgent?: string;
18
+ };
19
+ resource?: {
20
+ type: string;
21
+ id: string;
22
+ name?: string;
23
+ };
24
+ action: string;
25
+ result: 'success' | 'failure' | 'partial';
26
+ changes?: {
27
+ before?: Record<string, unknown>;
28
+ after?: Record<string, unknown>;
29
+ };
30
+ metadata?: Record<string, unknown>;
31
+ message?: string;
32
+ }
33
+ interface AuditQuery {
34
+ types?: AuditEventType[];
35
+ actorId?: string;
36
+ resourceType?: string;
37
+ resourceId?: string;
38
+ startDate?: Date;
39
+ endDate?: Date;
40
+ severity?: AuditSeverity[];
41
+ result?: ('success' | 'failure' | 'partial')[];
42
+ limit?: number;
43
+ offset?: number;
44
+ }
45
+ interface AuditStorage {
46
+ write(event: AuditEvent): Promise<void>;
47
+ query(query: AuditQuery): Promise<AuditEvent[]>;
48
+ count(query: AuditQuery): Promise<number>;
49
+ }
50
+ /**
51
+ * Audit logging system
52
+ */
53
+ declare class AuditSystem {
54
+ private storage;
55
+ private filters;
56
+ constructor(storage: AuditStorage);
57
+ /**
58
+ * Log audit event
59
+ */
60
+ log(event: Omit<AuditEvent, 'id' | 'timestamp'>): Promise<void>;
61
+ /**
62
+ * Log authentication event
63
+ */
64
+ logAuth(type: Extract<AuditEventType, 'auth.login' | 'auth.logout' | 'auth.failed_login' | 'auth.password_change'>, actorId: string, result: 'success' | 'failure', metadata?: Record<string, unknown>): Promise<void>;
65
+ /**
66
+ * Log data access event
67
+ */
68
+ logDataAccess(action: 'create' | 'read' | 'update' | 'delete', actorId: string, resourceType: string, resourceId: string, result: 'success' | 'failure', changes?: {
69
+ before?: Record<string, unknown>;
70
+ after?: Record<string, unknown>;
71
+ }): Promise<void>;
72
+ /**
73
+ * Log permission change
74
+ */
75
+ logPermissionChange(action: 'grant' | 'revoke', actorId: string, targetUserId: string, permission: string, result: 'success' | 'failure'): Promise<void>;
76
+ /**
77
+ * Log security event
78
+ */
79
+ logSecurityEvent(type: 'violation' | 'alert', severity: AuditSeverity, actorId: string, message: string, metadata?: Record<string, unknown>): Promise<void>;
80
+ /**
81
+ * Log GDPR event
82
+ */
83
+ logGDPREvent(type: 'consent' | 'data_request' | 'data_deletion', actorId: string, result: 'success' | 'failure', metadata?: Record<string, unknown>): Promise<void>;
84
+ /**
85
+ * Query audit logs
86
+ */
87
+ query(query: AuditQuery): Promise<AuditEvent[]>;
88
+ /**
89
+ * Count audit logs
90
+ */
91
+ count(query: AuditQuery): Promise<number>;
92
+ /**
93
+ * Add filter
94
+ */
95
+ addFilter(filter: (event: AuditEvent) => boolean): void;
96
+ /**
97
+ * Remove filter
98
+ */
99
+ removeFilter(filter: (event: AuditEvent) => boolean): void;
100
+ }
101
+ /**
102
+ * In-memory audit storage (for development)
103
+ */
104
+ declare class InMemoryAuditStorage implements AuditStorage {
105
+ private events;
106
+ private maxEvents;
107
+ constructor(maxEvents?: number);
108
+ write(event: AuditEvent): Promise<void>;
109
+ query(query: AuditQuery): Promise<AuditEvent[]>;
110
+ count(query: AuditQuery): Promise<number>;
111
+ /**
112
+ * Clear all events
113
+ */
114
+ clear(): void;
115
+ /**
116
+ * Get all events
117
+ */
118
+ getAll(): AuditEvent[];
119
+ }
120
+ /**
121
+ * Audit trail decorator
122
+ */
123
+ declare function AuditTrail(type: AuditEventType, action: string, options?: {
124
+ severity?: AuditSeverity;
125
+ captureChanges?: boolean;
126
+ resourceType?: string;
127
+ }): (_target: object, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
128
+ /**
129
+ * Audit middleware
130
+ */
131
+ declare function createAuditMiddleware<TRequest = unknown, TResponse = unknown>(audit: AuditSystem, getUser: (request: TRequest) => {
132
+ id: string;
133
+ ip?: string;
134
+ userAgent?: string;
135
+ }): (request: TRequest & {
136
+ method: string;
137
+ url: string;
138
+ }, next: () => Promise<TResponse & {
139
+ status?: number;
140
+ }>) => Promise<TResponse & {
141
+ status?: number;
142
+ }>;
143
+ /**
144
+ * Audit report generator
145
+ */
146
+ declare class AuditReportGenerator {
147
+ private audit;
148
+ constructor(audit: AuditSystem);
149
+ /**
150
+ * Generate security report
151
+ */
152
+ generateSecurityReport(startDate: Date, endDate: Date): Promise<{
153
+ totalEvents: number;
154
+ securityViolations: number;
155
+ failedLogins: number;
156
+ permissionChanges: number;
157
+ dataExports: number;
158
+ criticalEvents: AuditEvent[];
159
+ }>;
160
+ /**
161
+ * Generate user activity report
162
+ */
163
+ generateUserActivityReport(userId: string, startDate: Date, endDate: Date): Promise<{
164
+ totalActions: number;
165
+ actionsByType: Record<string, number>;
166
+ failedActions: number;
167
+ recentActions: AuditEvent[];
168
+ }>;
169
+ /**
170
+ * Generate compliance report
171
+ */
172
+ generateComplianceReport(startDate: Date, endDate: Date): Promise<{
173
+ dataAccesses: number;
174
+ dataModifications: number;
175
+ dataDeletions: number;
176
+ gdprRequests: number;
177
+ auditTrailComplete: boolean;
178
+ }>;
179
+ /**
180
+ * Check audit trail continuity
181
+ */
182
+ private checkAuditTrailContinuity;
183
+ }
184
+ /**
185
+ * Global audit system
186
+ */
187
+ declare const audit: AuditSystem;
188
+
189
+ /**
190
+ * Authentication Utilities
191
+ *
192
+ * OAuth support, password hashing, and two-factor authentication.
193
+ * JWT-based auth was removed — session auth is handled by @revealui/auth.
194
+ */
195
+ interface User {
196
+ id: string;
197
+ email: string;
198
+ username?: string;
199
+ roles: string[];
200
+ permissions: string[];
201
+ metadata?: Record<string, unknown>;
202
+ }
203
+ /**
204
+ * OAuth configuration
205
+ */
206
+ interface OAuthConfig {
207
+ provider: 'google' | 'github' | 'microsoft' | 'custom';
208
+ clientId: string;
209
+ clientSecret: string;
210
+ redirectUri: string;
211
+ scope?: string[];
212
+ authorizationUrl?: string;
213
+ tokenUrl?: string;
214
+ userInfoUrl?: string;
215
+ }
216
+ /**
217
+ * OAuth provider configurations
218
+ */
219
+ declare const OAuthProviders: {
220
+ google: {
221
+ authorizationUrl: string;
222
+ tokenUrl: string;
223
+ userInfoUrl: string;
224
+ scope: string[];
225
+ };
226
+ github: {
227
+ authorizationUrl: string;
228
+ tokenUrl: string;
229
+ userInfoUrl: string;
230
+ scope: string[];
231
+ };
232
+ microsoft: {
233
+ authorizationUrl: string;
234
+ tokenUrl: string;
235
+ userInfoUrl: string;
236
+ scope: string[];
237
+ };
238
+ };
239
+ /**
240
+ * OAuth client
241
+ */
242
+ declare class OAuthClient {
243
+ private config;
244
+ constructor(config: OAuthConfig);
245
+ /**
246
+ * Get authorization URL
247
+ */
248
+ getAuthorizationUrl(state?: string): string;
249
+ /**
250
+ * Exchange code for token
251
+ */
252
+ exchangeCodeForToken(code: string): Promise<{
253
+ access_token: string;
254
+ refresh_token?: string;
255
+ expires_in: number;
256
+ token_type: string;
257
+ }>;
258
+ /**
259
+ * Get user info
260
+ */
261
+ getUserInfo(accessToken: string): Promise<{
262
+ id: string;
263
+ email: string;
264
+ name?: string;
265
+ picture?: string;
266
+ }>;
267
+ }
268
+ /**
269
+ * Hash password with PBKDF2 and random salt
270
+ */
271
+ declare function hashPassword(password: string): Promise<string>;
272
+ /**
273
+ * Verify password against stored hash
274
+ */
275
+ declare function verifyPassword(password: string, storedHash: string): Promise<boolean>;
276
+ declare const PasswordHasher: {
277
+ readonly hash: typeof hashPassword;
278
+ readonly verify: typeof verifyPassword;
279
+ };
280
+ /**
281
+ * Generate TOTP secret
282
+ */
283
+ declare function generateSecret(): string;
284
+ /**
285
+ * Generate TOTP code
286
+ */
287
+ declare function generateCode(secret: string, timestamp?: number): string;
288
+ /**
289
+ * Verify TOTP code
290
+ */
291
+ declare function verifyCode(secret: string, code: string, window?: number): boolean;
292
+ declare const TwoFactorAuth: {
293
+ readonly generateSecret: typeof generateSecret;
294
+ readonly generateCode: typeof generateCode;
295
+ readonly verifyCode: typeof verifyCode;
296
+ };
297
+
298
+ /**
299
+ * Authorization System
300
+ *
301
+ * Role-Based Access Control (RBAC) and Attribute-Based Access Control (ABAC)
302
+ */
303
+ interface Permission {
304
+ resource: string;
305
+ action: string;
306
+ conditions?: Record<string, unknown>;
307
+ }
308
+ interface Role {
309
+ id: string;
310
+ name: string;
311
+ description?: string;
312
+ permissions: Permission[];
313
+ inherits?: string[];
314
+ }
315
+ interface Policy {
316
+ id: string;
317
+ name: string;
318
+ effect: 'allow' | 'deny';
319
+ resources: string[];
320
+ actions: string[];
321
+ conditions?: PolicyCondition[];
322
+ priority?: number;
323
+ }
324
+ interface PolicyCondition {
325
+ field: string;
326
+ operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'contains';
327
+ value: unknown;
328
+ }
329
+ interface AuthorizationContext {
330
+ user: {
331
+ id: string;
332
+ roles: string[];
333
+ attributes?: Record<string, unknown>;
334
+ };
335
+ resource?: {
336
+ type: string;
337
+ id?: string;
338
+ owner?: string;
339
+ attributes?: Record<string, unknown>;
340
+ };
341
+ environment?: {
342
+ time?: Date;
343
+ ip?: string;
344
+ userAgent?: string;
345
+ };
346
+ }
347
+ /**
348
+ * Authorization system
349
+ */
350
+ declare class AuthorizationSystem {
351
+ private roles;
352
+ private policies;
353
+ /**
354
+ * Register role
355
+ */
356
+ registerRole(role: Role): void;
357
+ /**
358
+ * Get role
359
+ */
360
+ getRole(roleId: string): Role | undefined;
361
+ /**
362
+ * Register policy
363
+ */
364
+ registerPolicy(policy: Policy): void;
365
+ /**
366
+ * Check if user has permission (RBAC)
367
+ */
368
+ hasPermission(userRoles: string[], resource: string, action: string): boolean;
369
+ /**
370
+ * Check access with policies (ABAC)
371
+ */
372
+ checkAccess(context: AuthorizationContext, resource: string, action: string): {
373
+ allowed: boolean;
374
+ reason?: string;
375
+ };
376
+ /**
377
+ * Get all permissions for roles
378
+ */
379
+ private getUserPermissions;
380
+ /**
381
+ * Get applicable policies
382
+ */
383
+ private getApplicablePolicies;
384
+ /**
385
+ * Match resource pattern
386
+ */
387
+ private matchesResource;
388
+ /**
389
+ * Match action pattern
390
+ */
391
+ private matchesAction;
392
+ /**
393
+ * Evaluate policy conditions
394
+ */
395
+ private evaluateConditions;
396
+ /**
397
+ * Get value from context
398
+ */
399
+ private getContextValue;
400
+ /**
401
+ * Evaluate single condition
402
+ */
403
+ private evaluateCondition;
404
+ /**
405
+ * Check if user owns resource
406
+ */
407
+ ownsResource(userId: string, resource: {
408
+ owner?: string;
409
+ }): boolean;
410
+ /**
411
+ * Clear all roles and policies
412
+ */
413
+ clear(): void;
414
+ }
415
+ /**
416
+ * Global authorization instance
417
+ */
418
+ declare const authorization: AuthorizationSystem;
419
+ /**
420
+ * Common roles — aligned with DB schema (`users.role` column)
421
+ * and `UserRoleSchema` in @revealui/contracts.
422
+ *
423
+ * Values: owner | admin | editor | viewer | agent | contributor
424
+ */
425
+ declare const CommonRoles: Record<string, Role>;
426
+ /**
427
+ * Permission builder
428
+ */
429
+ declare class PermissionBuilder {
430
+ private permission;
431
+ resource(resource: string): this;
432
+ action(action: string): this;
433
+ conditions(conditions: Record<string, unknown>): this;
434
+ build(): Permission;
435
+ }
436
+ /**
437
+ * Policy builder
438
+ */
439
+ declare class PolicyBuilder {
440
+ private policy;
441
+ id(id: string): this;
442
+ name(name: string): this;
443
+ allow(): this;
444
+ deny(): this;
445
+ resources(...resources: string[]): this;
446
+ actions(...actions: string[]): this;
447
+ condition(field: string, operator: PolicyCondition['operator'], value: unknown): this;
448
+ priority(priority: number): this;
449
+ build(): Policy;
450
+ }
451
+ /**
452
+ * Authorization decorators
453
+ */
454
+ declare function RequirePermission(resource: string, action: string): (_target: object, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
455
+ declare function RequireRole(requiredRole: string): (_target: object, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
456
+ /**
457
+ * Authorization middleware
458
+ */
459
+ declare function createAuthorizationMiddleware<TRequest = unknown>(getUser: (request: TRequest) => {
460
+ id: string;
461
+ roles: string[];
462
+ }, resource: string, action: string): (request: TRequest, next: () => Promise<unknown>) => Promise<unknown>;
463
+ /**
464
+ * Resource ownership check
465
+ */
466
+ declare function canAccessResource(userId: string, userRoles: string[], resource: {
467
+ type: string;
468
+ id?: string;
469
+ owner?: string;
470
+ }, action: string): boolean;
471
+ /**
472
+ * Attribute-based access control helper
473
+ */
474
+ declare function checkAttributeAccess(context: AuthorizationContext, resource: string, action: string, requiredAttributes?: Record<string, unknown>): boolean;
475
+ /**
476
+ * Permission cache for performance
477
+ */
478
+ declare class PermissionCache {
479
+ private cache;
480
+ private ttl;
481
+ private maxEntries;
482
+ constructor(ttl?: number, maxEntries?: number);
483
+ /**
484
+ * Get cached permission
485
+ */
486
+ get(userId: string, resource: string, action: string): boolean | undefined;
487
+ /**
488
+ * Set cached permission
489
+ */
490
+ set(userId: string, resource: string, action: string, allowed: boolean): void;
491
+ /**
492
+ * Clear cache for user
493
+ */
494
+ clearUser(userId: string): void;
495
+ /**
496
+ * Clear all cache
497
+ */
498
+ clear(): void;
499
+ /**
500
+ * Get cache key
501
+ */
502
+ private getCacheKey;
503
+ }
504
+ /**
505
+ * Global permission cache
506
+ */
507
+ declare const permissionCache: PermissionCache;
508
+
509
+ /**
510
+ * Encryption Utilities
511
+ *
512
+ * Data encryption for at-rest and in-transit protection
513
+ */
514
+ interface EncryptionConfig {
515
+ algorithm: 'AES-GCM' | 'AES-CTR';
516
+ keySize: 128 | 192 | 256;
517
+ ivSize?: number;
518
+ /** Allow key export via exportKey(). Default: false (keys are non-extractable). */
519
+ extractable?: boolean;
520
+ }
521
+ interface EncryptedData {
522
+ data: string;
523
+ iv: string;
524
+ tag?: string;
525
+ algorithm: string;
526
+ }
527
+ /**
528
+ * Encryption system
529
+ */
530
+ declare class EncryptionSystem {
531
+ private config;
532
+ private keys;
533
+ constructor(config?: Partial<EncryptionConfig>);
534
+ /**
535
+ * Generate encryption key
536
+ */
537
+ generateKey(keyId?: string): Promise<CryptoKey>;
538
+ /**
539
+ * Import key from raw data
540
+ */
541
+ importKey(keyData: ArrayBuffer, keyId?: string): Promise<CryptoKey>;
542
+ /**
543
+ * Export key to raw data
544
+ */
545
+ exportKey(key: CryptoKey): Promise<ArrayBuffer>;
546
+ /**
547
+ * Encrypt data
548
+ */
549
+ encrypt(data: string, keyOrId: CryptoKey | string): Promise<EncryptedData>;
550
+ /**
551
+ * Decrypt data
552
+ */
553
+ decrypt(encryptedData: EncryptedData, keyOrId: CryptoKey | string): Promise<string>;
554
+ /**
555
+ * Encrypt object
556
+ */
557
+ encryptObject<T extends Record<string, unknown>>(obj: T, keyOrId: CryptoKey | string): Promise<EncryptedData>;
558
+ /**
559
+ * Decrypt object
560
+ */
561
+ decryptObject<T extends Record<string, unknown>>(encryptedData: EncryptedData, keyOrId: CryptoKey | string): Promise<T>;
562
+ /**
563
+ * Hash data
564
+ */
565
+ hash(data: string, algorithm?: 'SHA-256' | 'SHA-384' | 'SHA-512'): Promise<string>;
566
+ /**
567
+ * Generate random bytes
568
+ */
569
+ randomBytes(length: number): Uint8Array;
570
+ /**
571
+ * Generate random string
572
+ */
573
+ randomString(length: number, charset?: string): string;
574
+ /**
575
+ * Convert ArrayBuffer to base64
576
+ */
577
+ private arrayBufferToBase64;
578
+ /**
579
+ * Convert base64 to ArrayBuffer
580
+ */
581
+ private base64ToArrayBuffer;
582
+ /**
583
+ * Store key
584
+ */
585
+ storeKey(keyId: string, key: CryptoKey): void;
586
+ /**
587
+ * Get key
588
+ */
589
+ getKey(keyId: string): CryptoKey | undefined;
590
+ /**
591
+ * Remove key
592
+ */
593
+ removeKey(keyId: string): void;
594
+ /**
595
+ * Clear all keys
596
+ */
597
+ clearKeys(): void;
598
+ }
599
+ /**
600
+ * Global encryption instance
601
+ */
602
+ declare const encryption: EncryptionSystem;
603
+ /**
604
+ * Field-level encryption
605
+ */
606
+ declare class FieldEncryption {
607
+ private encryption;
608
+ private key;
609
+ constructor(encryption: EncryptionSystem);
610
+ /**
611
+ * Initialize with key
612
+ */
613
+ initialize(key: CryptoKey): Promise<void>;
614
+ /**
615
+ * Encrypt field
616
+ */
617
+ encryptField(value: unknown): Promise<EncryptedData>;
618
+ /**
619
+ * Decrypt field
620
+ */
621
+ decryptField(encryptedData: EncryptedData): Promise<unknown>;
622
+ /**
623
+ * Encrypt object fields
624
+ */
625
+ encryptFields<T extends Record<string, unknown>>(obj: T, fields: (keyof T)[]): Promise<T>;
626
+ /**
627
+ * Decrypt object fields
628
+ */
629
+ decryptFields<T extends Record<string, unknown>>(obj: T, fields: (keyof T)[]): Promise<T>;
630
+ }
631
+ /**
632
+ * Key rotation
633
+ */
634
+ declare class KeyRotationManager {
635
+ private encryption;
636
+ private currentKeyId;
637
+ private oldKeys;
638
+ private keyCreationDates;
639
+ constructor(encryption: EncryptionSystem, initialKeyId: string);
640
+ /**
641
+ * Rotate to new key
642
+ */
643
+ rotate(newKeyId: string, newKey: CryptoKey): Promise<void>;
644
+ /**
645
+ * Re-encrypt data with new key
646
+ */
647
+ reencrypt(encryptedData: EncryptedData, oldKeyId: string): Promise<EncryptedData>;
648
+ /**
649
+ * Get current key ID
650
+ */
651
+ getCurrentKeyId(): string;
652
+ /**
653
+ * Clean up old keys created before the specified date.
654
+ * Never removes the current active key.
655
+ */
656
+ cleanupOldKeys(olderThan: Date): void;
657
+ }
658
+ /**
659
+ * Envelope encryption for large data
660
+ */
661
+ declare class EnvelopeEncryption {
662
+ private encryption;
663
+ private masterKey;
664
+ constructor(encryption: EncryptionSystem, masterKey: CryptoKey);
665
+ /**
666
+ * Encrypt with envelope encryption
667
+ */
668
+ encrypt(data: string): Promise<{
669
+ encryptedData: EncryptedData;
670
+ encryptedKey: EncryptedData;
671
+ }>;
672
+ /**
673
+ * Decrypt with envelope encryption
674
+ */
675
+ decrypt(encryptedData: EncryptedData, encryptedKey: EncryptedData): Promise<string>;
676
+ private arrayBufferToBase64;
677
+ private base64ToArrayBuffer;
678
+ }
679
+ /**
680
+ * Data masking utilities
681
+ */
682
+ /**
683
+ * Mask email
684
+ */
685
+ declare function maskEmail(email: string): string;
686
+ /**
687
+ * Mask phone number
688
+ */
689
+ declare function maskPhone(phone: string): string;
690
+ /**
691
+ * Mask credit card
692
+ */
693
+ declare function maskCreditCard(card: string): string;
694
+ /**
695
+ * Mask SSN
696
+ */
697
+ declare function maskSSN(ssn: string): string;
698
+ /**
699
+ * Mask string (keep first and last character)
700
+ */
701
+ declare function maskString(str: string, keepChars?: number): string;
702
+ declare const DataMasking: {
703
+ readonly maskEmail: typeof maskEmail;
704
+ readonly maskPhone: typeof maskPhone;
705
+ readonly maskCreditCard: typeof maskCreditCard;
706
+ readonly maskSSN: typeof maskSSN;
707
+ readonly maskString: typeof maskString;
708
+ };
709
+ /**
710
+ * Secure random token generator
711
+ */
712
+ /**
713
+ * Generate secure token. `length` is the number of random bytes;
714
+ * the returned string is hex-encoded, so it will be `length * 2` characters.
715
+ */
716
+ declare function generateToken(length?: number): string;
717
+ /**
718
+ * Generate UUID v4
719
+ */
720
+ declare function generateUUID(): string;
721
+ /**
722
+ * Generate API key
723
+ */
724
+ declare function generateAPIKey(prefix?: string): string;
725
+ /**
726
+ * Generate session ID
727
+ */
728
+ declare function generateSessionID(): string;
729
+ declare const TokenGenerator: {
730
+ readonly generate: typeof generateToken;
731
+ readonly generateUUID: typeof generateUUID;
732
+ readonly generateAPIKey: typeof generateAPIKey;
733
+ readonly generateSessionID: typeof generateSessionID;
734
+ };
735
+
736
+ /**
737
+ * GDPR Storage Abstraction
738
+ *
739
+ * Record-oriented storage interface for GDPR compliance data.
740
+ * Provides a clean seam for replacing the default in-memory implementation
741
+ * with a database-backed store in production.
742
+ */
743
+
744
+ /**
745
+ * Storage interface for GDPR consent records and deletion requests.
746
+ *
747
+ * All methods are async to support database-backed implementations.
748
+ * The default `InMemoryGDPRStorage` is suitable for testing and development
749
+ * but must be replaced with a persistent store for production use.
750
+ */
751
+ interface GDPRStorage {
752
+ /**
753
+ * Store or update a consent record, keyed by `userId:consentType`.
754
+ */
755
+ setConsent(userId: string, type: ConsentType, record: ConsentRecord): Promise<void>;
756
+ /**
757
+ * Retrieve a consent record by user and type. Returns `undefined` if not found.
758
+ */
759
+ getConsent(userId: string, type: ConsentType): Promise<ConsentRecord | undefined>;
760
+ /**
761
+ * Retrieve all consent records for a given user.
762
+ */
763
+ getConsentsByUser(userId: string): Promise<ConsentRecord[]>;
764
+ /**
765
+ * Retrieve every consent record in storage (used for aggregate statistics).
766
+ */
767
+ getAllConsents(): Promise<ConsentRecord[]>;
768
+ /**
769
+ * Store a deletion request, keyed by its `id`.
770
+ */
771
+ setDeletionRequest(request: DataDeletionRequest): Promise<void>;
772
+ /**
773
+ * Retrieve a deletion request by ID. Returns `undefined` if not found.
774
+ */
775
+ getDeletionRequest(requestId: string): Promise<DataDeletionRequest | undefined>;
776
+ /**
777
+ * Retrieve all deletion requests for a given user.
778
+ */
779
+ getDeletionRequestsByUser(userId: string): Promise<DataDeletionRequest[]>;
780
+ }
781
+ /**
782
+ * Storage interface for data breach records.
783
+ *
784
+ * All methods are async to support database-backed implementations.
785
+ * The default `InMemoryBreachStorage` is suitable for testing and development
786
+ * but must be replaced with a persistent store for production GDPR compliance.
787
+ */
788
+ interface BreachStorage {
789
+ /**
790
+ * Store a data breach record.
791
+ */
792
+ setBreach(breach: DataBreach): Promise<void>;
793
+ /**
794
+ * Retrieve a breach by ID. Returns `undefined` if not found.
795
+ */
796
+ getBreach(id: string): Promise<DataBreach | undefined>;
797
+ /**
798
+ * Retrieve all breach records.
799
+ */
800
+ getAllBreaches(): Promise<DataBreach[]>;
801
+ /**
802
+ * Update an existing breach record (e.g., status change, add mitigation).
803
+ */
804
+ updateBreach(id: string, updates: Partial<DataBreach>): Promise<void>;
805
+ }
806
+ /**
807
+ * In-memory implementation of `BreachStorage`.
808
+ *
809
+ * WARNING: All data is lost on process restart or serverless cold start.
810
+ * GDPR requires breach records be retained — use database-backed storage in production.
811
+ */
812
+ declare class InMemoryBreachStorage implements BreachStorage {
813
+ private breaches;
814
+ setBreach(breach: DataBreach): Promise<void>;
815
+ getBreach(id: string): Promise<DataBreach | undefined>;
816
+ getAllBreaches(): Promise<DataBreach[]>;
817
+ updateBreach(id: string, updates: Partial<DataBreach>): Promise<void>;
818
+ }
819
+ /**
820
+ * In-memory implementation of `GDPRStorage`.
821
+ *
822
+ * WARNING: All data is lost on process restart or serverless cold start.
823
+ * Use this only for development, testing, or as a reference implementation.
824
+ * Production deployments MUST supply a database-backed `GDPRStorage`.
825
+ */
826
+ declare class InMemoryGDPRStorage implements GDPRStorage {
827
+ private consents;
828
+ private deletionRequests;
829
+ setConsent(userId: string, type: ConsentType, record: ConsentRecord): Promise<void>;
830
+ getConsent(userId: string, type: ConsentType): Promise<ConsentRecord | undefined>;
831
+ getConsentsByUser(userId: string): Promise<ConsentRecord[]>;
832
+ getAllConsents(): Promise<ConsentRecord[]>;
833
+ setDeletionRequest(request: DataDeletionRequest): Promise<void>;
834
+ getDeletionRequest(requestId: string): Promise<DataDeletionRequest | undefined>;
835
+ getDeletionRequestsByUser(userId: string): Promise<DataDeletionRequest[]>;
836
+ }
837
+
838
+ /**
839
+ * GDPR Compliance Utilities
840
+ *
841
+ * Data privacy, consent management, data export, and right to be forgotten
842
+ */
843
+
844
+ type ConsentType = 'necessary' | 'functional' | 'analytics' | 'marketing' | 'personalization';
845
+ type DataCategory = 'personal' | 'sensitive' | 'financial' | 'health' | 'behavioral' | 'location';
846
+ interface ConsentRecord {
847
+ id: string;
848
+ userId: string;
849
+ type: ConsentType;
850
+ granted: boolean;
851
+ timestamp: string;
852
+ expiresAt?: string;
853
+ source: 'explicit' | 'implicit' | 'legitimate_interest';
854
+ version: string;
855
+ metadata?: Record<string, unknown>;
856
+ }
857
+ interface DataProcessingPurpose {
858
+ id: string;
859
+ name: string;
860
+ description: string;
861
+ legalBasis: 'consent' | 'contract' | 'legal_obligation' | 'vital_interest' | 'public_interest' | 'legitimate_interest';
862
+ dataCategories: DataCategory[];
863
+ retentionPeriod: number;
864
+ consentRequired: boolean;
865
+ }
866
+ interface PersonalDataExport {
867
+ userId: string;
868
+ exportedAt: string;
869
+ data: {
870
+ profile: Record<string, unknown>;
871
+ activities: Record<string, unknown>[];
872
+ consents: ConsentRecord[];
873
+ dataProcessing: DataProcessingPurpose[];
874
+ };
875
+ format: 'json' | 'csv' | 'pdf';
876
+ }
877
+ interface DataDeletionRequest {
878
+ id: string;
879
+ userId: string;
880
+ requestedAt: string;
881
+ processedAt?: string;
882
+ status: 'pending' | 'processing' | 'completed' | 'failed';
883
+ dataCategories: DataCategory[];
884
+ reason?: string;
885
+ retainedData?: string[];
886
+ deletedData?: string[];
887
+ }
888
+ /**
889
+ * Consent management system
890
+ */
891
+ declare class ConsentManager {
892
+ private readonly storage;
893
+ private consentVersion;
894
+ constructor(storage: GDPRStorage);
895
+ /**
896
+ * Grant consent
897
+ */
898
+ grantConsent(userId: string, type: ConsentType, source?: ConsentRecord['source'], expiresIn?: number): Promise<ConsentRecord>;
899
+ /**
900
+ * Revoke consent
901
+ */
902
+ revokeConsent(userId: string, type: ConsentType): Promise<void>;
903
+ /**
904
+ * Check if consent is granted
905
+ */
906
+ hasConsent(userId: string, type: ConsentType): Promise<boolean>;
907
+ /**
908
+ * Get all consents for user
909
+ */
910
+ getUserConsents(userId: string): Promise<ConsentRecord[]>;
911
+ /**
912
+ * Update consent version
913
+ */
914
+ setConsentVersion(version: string): void;
915
+ /**
916
+ * Check if consent needs renewal
917
+ */
918
+ needsRenewal(userId: string, type: ConsentType, maxAge: number): Promise<boolean>;
919
+ /**
920
+ * Get consent statistics
921
+ */
922
+ getStatistics(): Promise<{
923
+ total: number;
924
+ granted: number;
925
+ revoked: number;
926
+ expired: number;
927
+ byType: Record<ConsentType, number>;
928
+ }>;
929
+ }
930
+ /**
931
+ * Data export system
932
+ */
933
+ declare class DataExportSystem {
934
+ /**
935
+ * Export user data
936
+ */
937
+ exportUserData(userId: string, getUserData: (userId: string) => Promise<{
938
+ profile: Record<string, unknown>;
939
+ activities: Record<string, unknown>[];
940
+ consents: ConsentRecord[];
941
+ }>, format?: PersonalDataExport['format']): Promise<PersonalDataExport>;
942
+ /**
943
+ * Format export as JSON
944
+ */
945
+ formatAsJSON(exportData: PersonalDataExport): string;
946
+ /**
947
+ * Format export as CSV
948
+ */
949
+ formatAsCSV(exportData: PersonalDataExport): string;
950
+ /**
951
+ * Create download link
952
+ */
953
+ createDownloadLink(content: string, _filename: string, mimeType: string): string;
954
+ }
955
+ /**
956
+ * Data deletion system (Right to be Forgotten)
957
+ */
958
+ declare class DataDeletionSystem {
959
+ private readonly storage;
960
+ constructor(storage: GDPRStorage);
961
+ /**
962
+ * Request data deletion
963
+ */
964
+ requestDeletion(userId: string, dataCategories: DataCategory[], reason?: string): Promise<DataDeletionRequest>;
965
+ /**
966
+ * Process deletion request
967
+ */
968
+ processDeletion(requestId: string, deleteData: (userId: string, categories: DataCategory[]) => Promise<{
969
+ deleted: string[];
970
+ retained: string[];
971
+ }>): Promise<void>;
972
+ /**
973
+ * Get deletion request
974
+ */
975
+ getRequest(requestId: string): Promise<DataDeletionRequest | undefined>;
976
+ /**
977
+ * Get user deletion requests
978
+ */
979
+ getUserRequests(userId: string): Promise<DataDeletionRequest[]>;
980
+ /**
981
+ * Check if data can be deleted
982
+ */
983
+ canDelete(_dataCategory: DataCategory, legalBasis: DataProcessingPurpose['legalBasis']): boolean;
984
+ /**
985
+ * Calculate retention period
986
+ */
987
+ calculateRetentionEnd(createdAt: Date, retentionPeriod: number): Date;
988
+ /**
989
+ * Check if data should be deleted (retention period expired)
990
+ */
991
+ shouldDelete(createdAt: Date, retentionPeriod: number): boolean;
992
+ }
993
+ /**
994
+ * Data anonymization utilities
995
+ */
996
+ /**
997
+ * Hash value (irreversible) using SHA-256
998
+ */
999
+ declare function hashValue(value: string): string;
1000
+ /**
1001
+ * Anonymize user data
1002
+ */
1003
+ declare function anonymizeUser(user: Record<string, unknown>): Record<string, unknown>;
1004
+ /**
1005
+ * Pseudonymize data (one-way, key-dependent)
1006
+ *
1007
+ * Uses HMAC-SHA256 — cryptographically bound to the key, resistant to
1008
+ * length-extension attacks and GPU brute-force (unlike plain SHA-256).
1009
+ */
1010
+ declare function pseudonymize(value: string, key: string): string;
1011
+ /**
1012
+ * Anonymize dataset
1013
+ */
1014
+ declare function anonymizeDataset<T extends Record<string, unknown>>(data: T[], sensitiveFields: (keyof T)[]): T[];
1015
+ /**
1016
+ * K-anonymity check
1017
+ */
1018
+ declare function checkKAnonymity<T extends Record<string, unknown>>(data: T[], quasiIdentifiers: (keyof T)[], k: number): boolean;
1019
+ declare const DataAnonymization: {
1020
+ readonly anonymizeUser: typeof anonymizeUser;
1021
+ readonly pseudonymize: typeof pseudonymize;
1022
+ readonly hashValue: typeof hashValue;
1023
+ readonly anonymizeDataset: typeof anonymizeDataset;
1024
+ readonly checkKAnonymity: typeof checkKAnonymity;
1025
+ };
1026
+ /**
1027
+ * Privacy policy manager
1028
+ */
1029
+ declare class PrivacyPolicyManager {
1030
+ private policies;
1031
+ private currentVersion;
1032
+ /**
1033
+ * Add policy version
1034
+ */
1035
+ addPolicy(version: string, content: string, effectiveDate: Date): void;
1036
+ /**
1037
+ * Get current policy
1038
+ */
1039
+ getCurrentPolicy(): {
1040
+ version: string;
1041
+ content: string;
1042
+ effectiveDate: Date;
1043
+ } | undefined;
1044
+ /**
1045
+ * Get policy by version
1046
+ */
1047
+ getPolicy(version: string): {
1048
+ version: string;
1049
+ content: string;
1050
+ effectiveDate: Date;
1051
+ } | undefined;
1052
+ /**
1053
+ * Check if user accepted current policy
1054
+ */
1055
+ hasAcceptedCurrent(userAcceptedVersion: string): boolean;
1056
+ /**
1057
+ * Get all versions
1058
+ */
1059
+ getAllVersions(): string[];
1060
+ }
1061
+ /**
1062
+ * Cookie consent banner
1063
+ */
1064
+ interface CookieConsentConfig {
1065
+ necessary: boolean;
1066
+ functional: boolean;
1067
+ analytics: boolean;
1068
+ marketing: boolean;
1069
+ }
1070
+ declare class CookieConsentManager {
1071
+ private config;
1072
+ /**
1073
+ * Set consent configuration
1074
+ */
1075
+ setConsent(config: Partial<CookieConsentConfig>): void;
1076
+ /**
1077
+ * Get consent configuration
1078
+ */
1079
+ getConsent(): CookieConsentConfig;
1080
+ /**
1081
+ * Check if specific consent is granted
1082
+ */
1083
+ hasConsent(type: keyof CookieConsentConfig): boolean;
1084
+ /**
1085
+ * Save to storage
1086
+ */
1087
+ private saveToStorage;
1088
+ /**
1089
+ * Load from storage
1090
+ */
1091
+ loadFromStorage(): void;
1092
+ /**
1093
+ * Clear consent
1094
+ */
1095
+ clearConsent(): void;
1096
+ }
1097
+ /**
1098
+ * Data breach notification system
1099
+ */
1100
+ interface DataBreach {
1101
+ id: string;
1102
+ detectedAt: string;
1103
+ reportedAt?: string;
1104
+ type: 'unauthorized_access' | 'data_loss' | 'data_leak' | 'system_compromise';
1105
+ severity: 'low' | 'medium' | 'high' | 'critical';
1106
+ affectedUsers: string[];
1107
+ dataCategories: DataCategory[];
1108
+ description: string;
1109
+ mitigation?: string;
1110
+ status: 'detected' | 'investigating' | 'notified' | 'resolved';
1111
+ }
1112
+ declare class DataBreachManager {
1113
+ private readonly storage;
1114
+ constructor(storage?: BreachStorage);
1115
+ /**
1116
+ * Report data breach
1117
+ */
1118
+ reportBreach(breach: Omit<DataBreach, 'id' | 'detectedAt' | 'status'>): Promise<DataBreach>;
1119
+ /**
1120
+ * Notify authorities (required within 72 hours under GDPR)
1121
+ */
1122
+ notifyAuthorities(breach: DataBreach): Promise<void>;
1123
+ /**
1124
+ * Notify affected users
1125
+ */
1126
+ notifyAffectedUsers(breachId: string, notifyFn: (userId: string, breach: DataBreach) => Promise<void>): Promise<void>;
1127
+ /**
1128
+ * Check if breach notification is required
1129
+ */
1130
+ requiresNotification(breach: DataBreach): boolean;
1131
+ /**
1132
+ * Get breach
1133
+ */
1134
+ getBreach(id: string): Promise<DataBreach | undefined>;
1135
+ /**
1136
+ * Get all breaches
1137
+ */
1138
+ getAllBreaches(): Promise<DataBreach[]>;
1139
+ }
1140
+ /**
1141
+ * Factory functions for GDPR subsystems.
1142
+ *
1143
+ * `ConsentManager` and `DataDeletionSystem` require a `GDPRStorage` implementation.
1144
+ * Use `InMemoryGDPRStorage` only in tests — production MUST use a database-backed store.
1145
+ *
1146
+ * `DataExportSystem`, `PrivacyPolicyManager`, `CookieConsentManager`, and
1147
+ * `DataBreachManager` are stateless or client-side only, so singletons are safe.
1148
+ */
1149
+ declare function createConsentManager(storage: GDPRStorage): ConsentManager;
1150
+ declare function createDataDeletionSystem(storage: GDPRStorage): DataDeletionSystem;
1151
+ declare const dataExportSystem: DataExportSystem;
1152
+ declare const privacyPolicyManager: PrivacyPolicyManager;
1153
+ declare const cookieConsentManager: CookieConsentManager;
1154
+ declare function createDataBreachManager(storage?: BreachStorage): DataBreachManager;
1155
+ declare const dataBreachManager: DataBreachManager;
1156
+
1157
+ /**
1158
+ * Security Headers and CORS Configuration
1159
+ *
1160
+ * HTTP security headers and CORS policy management
1161
+ */
1162
+ interface SecurityHeadersConfig {
1163
+ contentSecurityPolicy?: string | ContentSecurityPolicyConfig;
1164
+ strictTransportSecurity?: boolean | HSTSConfig;
1165
+ xFrameOptions?: 'DENY' | 'SAMEORIGIN' | string;
1166
+ xContentTypeOptions?: boolean;
1167
+ referrerPolicy?: ReferrerPolicyValue;
1168
+ permissionsPolicy?: string | PermissionsPolicyConfig;
1169
+ crossOriginEmbedderPolicy?: 'require-corp' | 'credentialless';
1170
+ crossOriginOpenerPolicy?: 'same-origin' | 'same-origin-allow-popups' | 'unsafe-none';
1171
+ crossOriginResourcePolicy?: 'same-origin' | 'same-site' | 'cross-origin';
1172
+ }
1173
+ interface ContentSecurityPolicyConfig {
1174
+ defaultSrc?: string[];
1175
+ scriptSrc?: string[];
1176
+ styleSrc?: string[];
1177
+ imgSrc?: string[];
1178
+ fontSrc?: string[];
1179
+ connectSrc?: string[];
1180
+ frameSrc?: string[];
1181
+ objectSrc?: string[];
1182
+ mediaSrc?: string[];
1183
+ workerSrc?: string[];
1184
+ childSrc?: string[];
1185
+ formAction?: string[];
1186
+ frameAncestors?: string[];
1187
+ baseUri?: string[];
1188
+ manifestSrc?: string[];
1189
+ upgradeInsecureRequests?: boolean;
1190
+ blockAllMixedContent?: boolean;
1191
+ reportUri?: string;
1192
+ reportTo?: string;
1193
+ }
1194
+ interface HSTSConfig {
1195
+ maxAge: number;
1196
+ includeSubDomains?: boolean;
1197
+ preload?: boolean;
1198
+ }
1199
+ type ReferrerPolicyValue = 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
1200
+ interface PermissionsPolicyConfig {
1201
+ accelerometer?: string[];
1202
+ ambientLightSensor?: string[];
1203
+ autoplay?: string[];
1204
+ battery?: string[];
1205
+ camera?: string[];
1206
+ displayCapture?: string[];
1207
+ documentDomain?: string[];
1208
+ encryptedMedia?: string[];
1209
+ fullscreen?: string[];
1210
+ geolocation?: string[];
1211
+ gyroscope?: string[];
1212
+ magnetometer?: string[];
1213
+ microphone?: string[];
1214
+ midi?: string[];
1215
+ payment?: string[];
1216
+ pictureInPicture?: string[];
1217
+ publicKeyCredentials?: string[];
1218
+ screenWakeLock?: string[];
1219
+ syncXhr?: string[];
1220
+ usb?: string[];
1221
+ webShare?: string[];
1222
+ xrSpatialTracking?: string[];
1223
+ }
1224
+ interface CORSConfig {
1225
+ origin?: string | string[] | ((origin: string) => boolean);
1226
+ methods?: string[];
1227
+ allowedHeaders?: string[];
1228
+ exposedHeaders?: string[];
1229
+ credentials?: boolean;
1230
+ maxAge?: number;
1231
+ preflightContinue?: boolean;
1232
+ optionsSuccessStatus?: number;
1233
+ }
1234
+ /**
1235
+ * Security headers manager
1236
+ */
1237
+ declare class SecurityHeaders {
1238
+ private config;
1239
+ constructor(config?: SecurityHeadersConfig);
1240
+ /**
1241
+ * Get all security headers
1242
+ */
1243
+ getHeaders(): Record<string, string>;
1244
+ /**
1245
+ * Build Content Security Policy header
1246
+ */
1247
+ private buildCSP;
1248
+ /**
1249
+ * Build HSTS header
1250
+ */
1251
+ private buildHSTS;
1252
+ /**
1253
+ * Build Permissions-Policy header
1254
+ */
1255
+ private buildPermissionsPolicy;
1256
+ /**
1257
+ * Apply headers to response
1258
+ */
1259
+ applyHeaders(response: Response): Response;
1260
+ }
1261
+ /**
1262
+ * CORS manager
1263
+ */
1264
+ declare class CORSManager {
1265
+ private config;
1266
+ constructor(config?: CORSConfig);
1267
+ /**
1268
+ * Check if origin is allowed
1269
+ */
1270
+ isOriginAllowed(origin: string): boolean;
1271
+ /**
1272
+ * Get CORS headers
1273
+ */
1274
+ getCORSHeaders(origin: string): Record<string, string>;
1275
+ /**
1276
+ * Get preflight headers
1277
+ */
1278
+ getPreflightHeaders(origin: string): Record<string, string>;
1279
+ /**
1280
+ * Handle CORS request
1281
+ */
1282
+ handleRequest(request: Request): Response | null;
1283
+ /**
1284
+ * Handle preflight request
1285
+ */
1286
+ handlePreflight(_request: Request, origin: string): Response;
1287
+ /**
1288
+ * Apply CORS headers to response
1289
+ */
1290
+ applyHeaders(response: Response, origin: string): Response;
1291
+ }
1292
+ /**
1293
+ * Common security header presets
1294
+ */
1295
+ declare const SecurityPresets: {
1296
+ /**
1297
+ * Strict security (recommended for production)
1298
+ */
1299
+ strict: () => SecurityHeadersConfig;
1300
+ /**
1301
+ * Moderate security (balanced)
1302
+ */
1303
+ moderate: () => SecurityHeadersConfig;
1304
+ /**
1305
+ * Development (permissive)
1306
+ */
1307
+ development: () => SecurityHeadersConfig;
1308
+ };
1309
+ /**
1310
+ * Common CORS presets
1311
+ */
1312
+ declare const CORSPresets: {
1313
+ /**
1314
+ * Strict CORS (same origin only)
1315
+ */
1316
+ strict: () => CORSConfig;
1317
+ /**
1318
+ * Moderate CORS (specific origins)
1319
+ */
1320
+ moderate: (allowedOrigins: string[]) => CORSConfig;
1321
+ /**
1322
+ * Permissive CORS (all origins) — development only.
1323
+ * Logs a warning if used when NODE_ENV === 'production'.
1324
+ */
1325
+ permissive: () => CORSConfig;
1326
+ /**
1327
+ * API CORS (public read-only APIs) — credentials disabled.
1328
+ * Logs a warning if used when NODE_ENV === 'production'.
1329
+ */
1330
+ api: () => CORSConfig;
1331
+ };
1332
+ /**
1333
+ * Security middleware creator
1334
+ */
1335
+ declare function createSecurityMiddleware(securityConfig?: SecurityHeadersConfig, corsConfig?: CORSConfig): (request: Request, next: () => Promise<Response>) => Promise<Response>;
1336
+ /**
1337
+ * Rate limiting headers
1338
+ */
1339
+ declare function setRateLimitHeaders(response: Response, limit: number, remaining: number, reset: number): void;
1340
+
1341
+ /**
1342
+ * Internal logger for @revealui/security.
1343
+ *
1344
+ * Defaults to `console`. Consumers should call `configureSecurityLogger()`
1345
+ * to supply a structured logger (e.g. from `@revealui/utils/logger`).
1346
+ */
1347
+ interface SecurityLogger {
1348
+ warn(message: string, ...args: unknown[]): void;
1349
+ error(message: string, ...args: unknown[]): void;
1350
+ info(message: string, ...args: unknown[]): void;
1351
+ debug(message: string, ...args: unknown[]): void;
1352
+ }
1353
+ /**
1354
+ * Replace the default console logger with a structured logger.
1355
+ */
1356
+ declare function configureSecurityLogger(logger: SecurityLogger): void;
1357
+
1358
+ export { type AuditEvent, type AuditEventType, type AuditQuery, AuditReportGenerator, type AuditSeverity, type AuditStorage, AuditSystem, AuditTrail, type AuthorizationContext, AuthorizationSystem, type BreachStorage, type CORSConfig, CORSManager, CORSPresets, CommonRoles, ConsentManager, type ConsentRecord, type ConsentType, type ContentSecurityPolicyConfig, type CookieConsentConfig, CookieConsentManager, DataAnonymization, type DataBreach, DataBreachManager, type DataCategory, type DataDeletionRequest, DataDeletionSystem, DataExportSystem, DataMasking, type DataProcessingPurpose, type EncryptedData, type EncryptionConfig, EncryptionSystem, EnvelopeEncryption, FieldEncryption, type GDPRStorage, type HSTSConfig, InMemoryAuditStorage, InMemoryBreachStorage, InMemoryGDPRStorage, KeyRotationManager, OAuthClient, type OAuthConfig, OAuthProviders, PasswordHasher, type Permission, PermissionBuilder, PermissionCache, type PermissionsPolicyConfig, type PersonalDataExport, type Policy, PolicyBuilder, type PolicyCondition, PrivacyPolicyManager, type ReferrerPolicyValue, RequirePermission, RequireRole, type Role, SecurityHeaders, type SecurityHeadersConfig, type SecurityLogger, SecurityPresets, TokenGenerator, TwoFactorAuth, type User, audit, authorization, canAccessResource, checkAttributeAccess, configureSecurityLogger, cookieConsentManager, createAuditMiddleware, createAuthorizationMiddleware, createConsentManager, createDataBreachManager, createDataDeletionSystem, createSecurityMiddleware, dataBreachManager, dataExportSystem, encryption, permissionCache, privacyPolicyManager, setRateLimitHeaders };