kxco-pq-audit 1.0.2 → 1.0.3
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.
- package/package.json +9 -3
- package/src/index.d.ts +68 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kxco-pq-audit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Tamper-evident post-quantum audit log: ML-DSA-65-signed, hash-chained operation entries. Prove cryptographic operations happened, in order, and were not altered. Memory and append-only file backends.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"post-quantum",
|
|
@@ -28,9 +28,14 @@
|
|
|
28
28
|
"url": "https://github.com/JackKXCO/kxco-pq-audit/issues"
|
|
29
29
|
},
|
|
30
30
|
"type": "module",
|
|
31
|
-
"
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"main": "./src/index.js",
|
|
33
|
+
"types": "./src/index.d.ts",
|
|
32
34
|
"exports": {
|
|
33
|
-
".":
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./src/index.d.ts",
|
|
37
|
+
"import": "./src/index.js"
|
|
38
|
+
}
|
|
34
39
|
},
|
|
35
40
|
"files": [
|
|
36
41
|
"src",
|
|
@@ -47,6 +52,7 @@
|
|
|
47
52
|
"test": "node --test --test-timeout=30000 test/audit.test.js"
|
|
48
53
|
},
|
|
49
54
|
"publishConfig": {
|
|
55
|
+
"provenance": true,
|
|
50
56
|
"access": "public"
|
|
51
57
|
}
|
|
52
58
|
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
export interface AuditEntry {
|
|
4
|
+
seq: number
|
|
5
|
+
timestamp: string
|
|
6
|
+
operation: string
|
|
7
|
+
metadata: Record<string, unknown>
|
|
8
|
+
/** SHA-256 of the previous entry (entire JSON including signature). Null for the first entry. */
|
|
9
|
+
prevHash: string | null
|
|
10
|
+
/** base64url ML-DSA-65 signature over a canonical representation of all other fields. */
|
|
11
|
+
signature: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AuditVerifySuccess {
|
|
15
|
+
valid: true
|
|
16
|
+
count: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface AuditVerifyFailure {
|
|
20
|
+
valid: false
|
|
21
|
+
error: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type AuditVerifyResult = AuditVerifySuccess | AuditVerifyFailure
|
|
25
|
+
|
|
26
|
+
export interface AuditLogOptions {
|
|
27
|
+
keypair: {
|
|
28
|
+
publicKey: Uint8Array | Buffer
|
|
29
|
+
secretKey: Uint8Array | Buffer
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* In-memory tamper-evident audit log.
|
|
35
|
+
*
|
|
36
|
+
* Each entry is ML-DSA-65-signed and SHA-256 hash-chained to its predecessor.
|
|
37
|
+
* `verify()` replays the entire chain — any gap, reorder, or edit breaks either
|
|
38
|
+
* the chain or a signature.
|
|
39
|
+
*/
|
|
40
|
+
export declare class AuditLog {
|
|
41
|
+
constructor(options: AuditLogOptions)
|
|
42
|
+
|
|
43
|
+
/** Append a signed, hash-chained entry. Returns the created entry. */
|
|
44
|
+
append(operation: string, metadata?: Record<string, unknown>): Promise<AuditEntry>
|
|
45
|
+
|
|
46
|
+
/** Verify every entry's signature and the full hash chain. */
|
|
47
|
+
verify(publicKey: Uint8Array | Buffer): Promise<AuditVerifyResult>
|
|
48
|
+
|
|
49
|
+
/** Return a copy of all entries. */
|
|
50
|
+
export(): Promise<AuditEntry[]>
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface FileAuditLogOptions extends AuditLogOptions {
|
|
54
|
+
/** Path to the append-only NDJSON file. Created on first write if absent. */
|
|
55
|
+
path: string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* File-backed audit log. Entries are stored as newline-delimited JSON.
|
|
60
|
+
* The file is strictly append-only — entries are never modified after writing.
|
|
61
|
+
*/
|
|
62
|
+
export declare class FileAuditLog extends AuditLog {
|
|
63
|
+
constructor(options: FileAuditLogOptions)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class KxcoPqAuditError extends Error {
|
|
67
|
+
name: 'KxcoPqAuditError'
|
|
68
|
+
}
|