DRAFT: Feat(lib-config): implement audit logging with integrity verification#180
DRAFT: Feat(lib-config): implement audit logging with integrity verification#180larsroettig wants to merge 4 commits intoadobe:mainfrom
Conversation
* feat: implement cryptographic audit chain with SHA-256 hashing * feat: add audit log filtering by userId, action, and date range * feat: implement audit chain integrity verification * feat: add index-based pagination for audit log queries * test: comprehensive test coverage for audit functionality Features: - Tamper-proof audit trail using cryptographic hashing - GDPR-compliant with sensitive data redaction - Flexible filtering and pagination support Performance: - Single-pass filtering reduces memory usage by 75% - Supports up to 1000 audit entries efficiently - Clear scaling guidance for larger datasets
|
Removed links to Adobe Storage Best Practices and Storage Architecture documentation.
* style: improve code comments to be concise and professional
|
Thanks for the PR @larsroettig Do you have a usecase where you are using this alongside aio-commerce-sdk? |
| function calculateIntegrityHash( | ||
| entry: Omit<AuditEntry, "integrityHash">, | ||
| previousHash: string | null, | ||
| ): string { |
There was a problem hiding this comment.
| ): string { | |
| ) { |
Return types are inferred
| * @param data - Data to hash. | ||
| * @returns Hex-encoded hash string. | ||
| */ | ||
| function generateHash(data: unknown): string { |
There was a problem hiding this comment.
| function generateHash(data: unknown): string { | |
| function generateHash(data: unknown) { |
Return types are inferred
| export async function logChange( | ||
| context: AuditContext, | ||
| request: CreateAuditEntryRequest, | ||
| ): Promise<AuditEntry> { |
There was a problem hiding this comment.
| ): Promise<AuditEntry> { | |
| ) { |
Should be inferred from buildAuditEntry return type
| auditIdIndex, | ||
| ); | ||
|
|
||
| const validEntries = filterNullEntries(allAuditEntries); |
There was a problem hiding this comment.
filterNullEntries can be added to apply audit filters, to avoid 2 passes at filter a large audit entry collection. As it doesn't look like allAuditEntries is reused later in the function.
| * Compares two objects using JSON serialization. | ||
| * | ||
| * Note: This is a simple comparison method that works for plain objects. | ||
| * For complex objects with methods or circular references, use a dedicated library. |
There was a problem hiding this comment.
😬
I would say this is worthy of a property based test. Ensure, that this behaves as expected.
Features:
Performance:
Description
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: