@pamoja/audit 0.1.15
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/LICENSE-MIT +21 -0
- package/README.md +81 -0
- package/package.json +40 -0
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anthony Wiedman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @pamoja/audit
|
|
2
|
+
|
|
3
|
+
A tamper-evident, hash-chained log; altering, reordering, or dropping a record breaks verification. One capability of [pamoja](https://github.com/molexxxx/pamoja), one memory-safe Rust core with bindings for TypeScript, Python, and C#.
|
|
4
|
+
|
|
5
|
+
[](https://pamoja.molex.cloud/docs/reference/node/modules/_pamoja_audit.html)
|
|
6
|
+
[](https://pamoja.molex.cloud/docs/guides/audit.html)
|
|
7
|
+
[](https://pamoja.molex.cloud/docs/)
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @pamoja/audit
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This pulls in `@pamoja/native`, the compiled engine, and `@pamoja/security`. `npm install pamoja` is the whole framework in one package.
|
|
16
|
+
|
|
17
|
+
## Example
|
|
18
|
+
|
|
19
|
+
The test that runs in CI, spliced here as it ran.
|
|
20
|
+
|
|
21
|
+
From [`bindings/node/guides/audit.ts`](https://github.com/molexxxx/pamoja/blob/main/bindings/node/guides/audit.ts):
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { AuditEntry, AuditLog, verifyChain } from '@pamoja/audit'
|
|
25
|
+
import { DeviceIdentity } from '@pamoja/security'
|
|
26
|
+
|
|
27
|
+
// The controller signs its own log with a provisioned seed and an auditor holds only the
|
|
28
|
+
// public half, so a log can be checked anywhere without the device present.
|
|
29
|
+
const keeper = DeviceIdentity.fromSeed(Buffer.alloc(32, 7))
|
|
30
|
+
const auditor = keeper.publicKey()
|
|
31
|
+
|
|
32
|
+
const log = new AuditLog(keeper)
|
|
33
|
+
const lit = log.append(Buffer.from('burner=on'))
|
|
34
|
+
const stopped = log.append(Buffer.from('burner=off'))
|
|
35
|
+
console.log(`recorded ${lit.index} then ${stopped.index}`)
|
|
36
|
+
|
|
37
|
+
// Each record hashes its own index, the digest of the record before it, and what it
|
|
38
|
+
// carries, so the chain fixes the order as well as the contents.
|
|
39
|
+
console.log(`chained ${stopped.previous.equals(lit.digest)}`)
|
|
40
|
+
verifyChain(auditor, [lit, stopped])
|
|
41
|
+
console.log('verified the whole log is authentic and in order')
|
|
42
|
+
|
|
43
|
+
// Editing a stored record changes the digest its signature covers.
|
|
44
|
+
const edited = Buffer.from(stopped.toBytes())
|
|
45
|
+
edited[edited.length - 1] ^= 0xff
|
|
46
|
+
const tampered = AuditEntry.fromBytes(edited)
|
|
47
|
+
try {
|
|
48
|
+
verifyChain(auditor, [lit, tampered])
|
|
49
|
+
console.log('an edited record verified, which should never happen')
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.log(`edited caught: ${(error as Error).message}`)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Dropping the first record leaves the survivor chained to a link that is no longer there,
|
|
55
|
+
// so a shortened log is caught as readily as an edited one.
|
|
56
|
+
try {
|
|
57
|
+
verifyChain(auditor, [stopped])
|
|
58
|
+
console.log('a shortened log verified, which should never happen')
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.log(`shortened caught: ${(error as Error).message}`)
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## The same capability in every language
|
|
65
|
+
|
|
66
|
+
| Language | Package | Reference |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| Rust | [`pamoja-audit`](https://crates.io/crates/pamoja-audit) | [reference](https://pamoja.molex.cloud/docs/reference/rust/pamoja_audit/index.html), [docs.rs](https://docs.rs/pamoja-audit) |
|
|
69
|
+
| TypeScript | [`@pamoja/audit`](https://www.npmjs.com/package/@pamoja/audit) | [reference](https://pamoja.molex.cloud/docs/reference/node/modules/_pamoja_audit.html) |
|
|
70
|
+
| Python | [`pamoja-audit`](https://pypi.org/project/pamoja-audit/) | [reference](https://pamoja.molex.cloud/docs/reference/python/pamoja/audit.html) |
|
|
71
|
+
| C# | [`Pamoja.Audit`](https://www.nuget.org/packages/Pamoja.Audit) | [reference](https://pamoja.molex.cloud/docs/reference/dotnet/api/Pamoja.Audit.html) |
|
|
72
|
+
|
|
73
|
+
## Documentation
|
|
74
|
+
|
|
75
|
+
- [`@pamoja/audit` reference](https://pamoja.molex.cloud/docs/reference/node/modules/_pamoja_audit.html), every class, function, and type this package exports.
|
|
76
|
+
- [The Audit log guide](https://pamoja.molex.cloud/docs/guides/audit.html), with the same example in Rust, Python, and C#.
|
|
77
|
+
- [Every capability](https://pamoja.molex.cloud/docs/), and the [install page](https://pamoja.molex.cloud/docs/install.html).
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pamoja/audit",
|
|
3
|
+
"version": "0.1.15",
|
|
4
|
+
"description": "A tamper-evident, hash-chained log; altering, reordering, or dropping a record breaks verification.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/molexxxx/pamoja.git",
|
|
12
|
+
"directory": "bindings/node/packages/audit"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://pamoja.molex.cloud/docs/guides/audit.html",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pamoja",
|
|
17
|
+
"iot",
|
|
18
|
+
"robotics",
|
|
19
|
+
"audit"
|
|
20
|
+
],
|
|
21
|
+
"main": "dist/index.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist/",
|
|
31
|
+
"LICENSE-MIT"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">= 16"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@pamoja/native": "0.1.15",
|
|
38
|
+
"@pamoja/security": "0.1.15"
|
|
39
|
+
}
|
|
40
|
+
}
|