@parmanasystems/core 1.71.9 → 1.71.14
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/README.md +111 -31
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -20,6 +20,82 @@ npm install @parmanasystems/core
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
+
## ESM / CJS note
|
|
24
|
+
|
|
25
|
+
`@parmanasystems/core` bundles CJS dependencies. Do **not** set `"type": "module"` in `package.json` — it will break bundled transitive imports. Wrap all SDK calls in an `async` function instead of using top-level `await`:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
// ✅ Correct
|
|
29
|
+
async function main() {
|
|
30
|
+
const result = await executeFromSignals(...);
|
|
31
|
+
}
|
|
32
|
+
main().catch(console.error);
|
|
33
|
+
|
|
34
|
+
// ❌ Incorrect — top-level await fails in CJS mode
|
|
35
|
+
const result = await executeFromSignals(...);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Policy files
|
|
41
|
+
|
|
42
|
+
`executeFromSignals` reads policy rules from disk at:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
./policies/{policyId}/{policyVersion}/policy.json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Create this directory structure **before** calling `executeFromSignals`. Example for `policyId: "trade-risk-approval"`, `policyVersion: "1.0.0"`:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
policies/
|
|
52
|
+
trade-risk-approval/
|
|
53
|
+
1.0.0/
|
|
54
|
+
policy.json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Minimal `policy.json` with all required fields:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"policyId": "trade-risk-approval",
|
|
62
|
+
"policyVersion": "1.0.0",
|
|
63
|
+
"schemaVersion": "1.0.0",
|
|
64
|
+
"signalsSchema": {
|
|
65
|
+
"amount_usd": { "type": "integer" },
|
|
66
|
+
"risk_score": { "type": "integer" },
|
|
67
|
+
"counterparty": { "type": "string" }
|
|
68
|
+
},
|
|
69
|
+
"rules": [
|
|
70
|
+
{
|
|
71
|
+
"id": "low-risk-approve",
|
|
72
|
+
"condition": {
|
|
73
|
+
"all": [
|
|
74
|
+
{ "signal": "risk_score", "less_than": 30 },
|
|
75
|
+
{ "signal": "amount_usd", "less_than": 500000 }
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
"outcome": { "action": "approve", "requires_override": false, "reason": "low_risk_trade" }
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"id": "catch-all-reject",
|
|
82
|
+
"condition": { "all": [] },
|
|
83
|
+
"outcome": { "action": "reject", "requires_override": true, "reason": "requires_review" }
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
| Field | Required | Description |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| `policyId` | ✅ | Must match the directory name under `policies/` |
|
|
92
|
+
| `policyVersion` | ✅ | Must match the subdirectory name (e.g. `"1.0.0"`) |
|
|
93
|
+
| `schemaVersion` | ✅ | Always `"1.0.0"` for the current schema |
|
|
94
|
+
| `signalsSchema` | ✅ | Map of signal names to `{ "type": "integer" \| "boolean" \| "string" }` |
|
|
95
|
+
| `rules` | ✅ | Ordered list — evaluated top-to-bottom, first match wins |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
23
99
|
## Usage
|
|
24
100
|
|
|
25
101
|
```typescript
|
|
@@ -33,38 +109,42 @@ import {
|
|
|
33
109
|
getRuntimeManifest,
|
|
34
110
|
} from "@parmanasystems/core";
|
|
35
111
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
112
|
+
async function main() {
|
|
113
|
+
const { privateKey, publicKey } = crypto.generateKeyPairSync("ed25519", {
|
|
114
|
+
privateKeyEncoding: { type: "pkcs8", format: "pem" },
|
|
115
|
+
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const signer = new LocalSigner(privateKey);
|
|
119
|
+
const verifier = new LocalVerifier(publicKey);
|
|
120
|
+
const replayStore = new MemoryReplayStore();
|
|
121
|
+
|
|
122
|
+
const attestation = await executeFromSignals(
|
|
123
|
+
{
|
|
124
|
+
policyId: "trade-risk-approval",
|
|
125
|
+
policyVersion: "1.0.0",
|
|
126
|
+
signals: {
|
|
127
|
+
amount_usd: 450_000,
|
|
128
|
+
risk_score: 18,
|
|
129
|
+
counterparty: "acme-corp",
|
|
130
|
+
},
|
|
53
131
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
console.log(attestation.
|
|
61
|
-
console.log(attestation.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
132
|
+
signer,
|
|
133
|
+
verifier,
|
|
134
|
+
replayStore
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
console.log(attestation.execution_state); // "completed"
|
|
138
|
+
console.log(attestation.decision.action); // "approve"
|
|
139
|
+
console.log(attestation.signature); // Ed25519 over canonical attestation JSON
|
|
140
|
+
|
|
141
|
+
// Independently verify — no runtime state required beyond the manifest
|
|
142
|
+
const manifest = getRuntimeManifest();
|
|
143
|
+
const result = verifyAttestation(attestation, verifier, manifest);
|
|
144
|
+
console.log(result.valid); // true
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
main().catch(console.error);
|
|
68
148
|
```
|
|
69
149
|
|
|
70
150
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parmanasystems/core",
|
|
3
|
-
"version": "1.71.
|
|
3
|
+
"version": "1.71.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
],
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@parmanasystems/audit-db": "^1.71.
|
|
22
|
-
"@parmanasystems/bundle": "^1.71.
|
|
23
|
-
"@parmanasystems/crypto": "^1.71.
|
|
24
|
-
"@parmanasystems/execution": "^1.71.
|
|
25
|
-
"@parmanasystems/governance": "^1.71.
|
|
26
|
-
"@parmanasystems/verifier": "^1.71.
|
|
21
|
+
"@parmanasystems/audit-db": "^1.71.14",
|
|
22
|
+
"@parmanasystems/bundle": "^1.71.14",
|
|
23
|
+
"@parmanasystems/crypto": "^1.71.14",
|
|
24
|
+
"@parmanasystems/execution": "^1.71.14",
|
|
25
|
+
"@parmanasystems/governance": "^1.71.14",
|
|
26
|
+
"@parmanasystems/verifier": "^1.71.14"
|
|
27
27
|
},
|
|
28
28
|
"description": "Public orchestration and SDK surface for parmanasystems deterministic governance infrastructure.",
|
|
29
29
|
"license": "Apache-2.0",
|