@nomosprotocol/sdk 2.0.0 → 2.3.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.
- package/README.md +25 -5
- package/dist/index.cjs +1092 -109
- package/dist/index.d.cts +349 -9
- package/dist/index.d.ts +349 -9
- package/dist/index.js +1072 -108
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -50,7 +50,11 @@ verifier locally and then, in one transaction, records the nonce, re-reads your
|
|
|
50
50
|
`commit` exactly the verified action, and stores the receipt:
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
|
-
import
|
|
53
|
+
import pg from 'pg';
|
|
54
|
+
import { accept, postgresStore } from '@nomosprotocol/sdk';
|
|
55
|
+
|
|
56
|
+
const store = postgresStore(new pg.Pool({ connectionString: process.env.DATABASE_URL }));
|
|
57
|
+
await store.migrate(); // once: creates the nomos_acts table
|
|
54
58
|
|
|
55
59
|
const rp = accept({
|
|
56
60
|
relyingPartyId: 'orders.acme.example',
|
|
@@ -59,8 +63,8 @@ const rp = accept({
|
|
|
59
63
|
authorities: [{ artifactId: 'acme-purchasing', issuer: 'https://policy.acme.example',
|
|
60
64
|
actions: ['purchase'], currencyPolicy: 'record', inForceSealHash: POLICY_SEAL_HASH }],
|
|
61
65
|
localFacts: async (act) => ({ vendor_blocked: await isBlocked(act.action.params.vendor) }),
|
|
62
|
-
commit: async (action, { tx }) => createOrder(tx, action), // your existing code
|
|
63
|
-
store
|
|
66
|
+
commit: async (action, { tx }) => createOrder(tx, action), // your existing code, on the same transaction
|
|
67
|
+
store, // nonces, receipts and the Acts themselves
|
|
64
68
|
});
|
|
65
69
|
|
|
66
70
|
app.use(rp.express()); // Express, Connect, node:http
|
|
@@ -70,6 +74,13 @@ app.use(rp.express()); // Express, Connect, node:http
|
|
|
70
74
|
`accept()` serves your discovery document at `/.well-known/nomos-relying-party`, generated from this
|
|
71
75
|
same configuration, and answers every Act with the status NOMOS-SPEC-009 assigns.
|
|
72
76
|
|
|
77
|
+
`postgresStore()` records the nonce, your change and the receipt in one transaction: `commit`
|
|
78
|
+
receives `tx`, the same client. Under any number of concurrent submissions of one Act exactly one
|
|
79
|
+
commits and the rest get `409` with its receipt, and the exact Act is kept beside its receipt so
|
|
80
|
+
an auditor can re-verify it later. It takes a node-postgres `Pool` or anything with the same
|
|
81
|
+
`query`/`connect` methods (Neon's serverless driver on edge runtimes, for example) and depends on
|
|
82
|
+
no driver itself. `memoryStore()`, the default, is for development only.
|
|
83
|
+
|
|
73
84
|
| Verdict | Status |
|
|
74
85
|
|---|---|
|
|
75
86
|
| AUTHORIZED, committed | 201 |
|
|
@@ -79,12 +90,21 @@ same configuration, and answers every Act with the status NOMOS-SPEC-009 assigns
|
|
|
79
90
|
| REPLAYED | 409, with the original receipt |
|
|
80
91
|
| any other refusal | 400 |
|
|
81
92
|
|
|
93
|
+
**Certificates and revocations.** `act()` presents exactly the certificates an Act relies on
|
|
94
|
+
(NOMOS-SPEC-009 0.2.0), so an issuer can certify any number of approvers. Witnesses and approvers
|
|
95
|
+
can return their own chains with what they sign (`keyCerts`). On the relying party,
|
|
96
|
+
`revocations: revocationSource({ url, root, maxAgeSeconds })` reads the issuer's signed list
|
|
97
|
+
(NOMOS-SPEC-007 rev. 1.10). Revocations are never forgotten, and without a current list
|
|
98
|
+
`accept()` answers 503 instead of committing.
|
|
99
|
+
|
|
82
100
|
**The other roles** are one call each:
|
|
83
101
|
- `issuer()` publishes your sealed policies and certificates;
|
|
84
102
|
- `witness()` turns an existing lookup into signed statements;
|
|
85
|
-
- `approver()` shows a person the exact change and signs their consent
|
|
103
|
+
- `approver()` shows a person the exact change and signs their consent; `passkeyApprover()` has them
|
|
104
|
+
sign it with Face ID, Touch ID or a security key, enrolled through a single-use link
|
|
105
|
+
(`nomos enroll`), so no server can approve for them.
|
|
86
106
|
|
|
87
|
-
Keys are `Signer`s, so they can live in your KMS or HSM.
|
|
107
|
+
Keys are `Signer`s, so they can live in your KMS or HSM: [`@nomosprotocol/signers`](../packages/signers) has adapters for AWS KMS, Google Cloud KMS, Azure Key Vault and any other HSM.
|
|
88
108
|
|
|
89
109
|
**Any MCP agent** can carry Acts with no code: the `nomos-mcp` server has an `act` tool.
|
|
90
110
|
|