nostr-veil 0.8.4 → 0.14.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 +157 -30
- package/dist/nip85/validators.d.ts +24 -1
- package/dist/nip85/validators.d.ts.map +1 -1
- package/dist/nip85/validators.js +235 -7
- package/dist/nip85/validators.js.map +1 -1
- package/dist/proof/aggregate.d.ts +54 -9
- package/dist/proof/aggregate.d.ts.map +1 -1
- package/dist/proof/aggregate.js +194 -33
- package/dist/proof/aggregate.js.map +1 -1
- package/dist/proof/circle.d.ts +54 -2
- package/dist/proof/circle.d.ts.map +1 -1
- package/dist/proof/circle.js +121 -22
- package/dist/proof/circle.js.map +1 -1
- package/dist/proof/contribute.d.ts +15 -3
- package/dist/proof/contribute.d.ts.map +1 -1
- package/dist/proof/contribute.js +46 -7
- package/dist/proof/contribute.js.map +1 -1
- package/dist/proof/federate.d.ts +45 -0
- package/dist/proof/federate.d.ts.map +1 -0
- package/dist/proof/federate.js +99 -0
- package/dist/proof/federate.js.map +1 -0
- package/dist/proof/index.d.ts +1 -0
- package/dist/proof/index.d.ts.map +1 -1
- package/dist/proof/index.js +1 -0
- package/dist/proof/index.js.map +1 -1
- package/dist/proof/types.d.ts +45 -0
- package/dist/proof/types.d.ts.map +1 -1
- package/dist/proof/verify.d.ts +31 -2
- package/dist/proof/verify.d.ts.map +1 -1
- package/dist/proof/verify.js +437 -44
- package/dist/proof/verify.js.map +1 -1
- package/llms-full.txt +114 -48
- package/llms.txt +30 -20
- package/package.json +8 -10
package/README.md
CHANGED
|
@@ -3,28 +3,43 @@
|
|
|
3
3
|
[](https://github.com/forgesworn/nostr-veil/actions/workflows/ci.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/nostr-veil)
|
|
5
5
|
[](./LICENCE)
|
|
6
|
+
[](https://github.com/sponsors/TheCryptoDonkey)
|
|
6
7
|
|
|
7
8
|
**Trust scores you can verify without seeing who contributed them.**
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
A privacy layer for Nostr reputation systems. A group of people can collectively score someone's trustworthiness, and anyone can verify the result -- but nobody can tell which group members actually contributed. Built for abuse reporting, whistleblowing, journalism, and anonymous peer review.
|
|
10
11
|
|
|
11
|
-
**
|
|
12
|
+
**New here?** The [**use-case overview**](https://veil.forgesworn.dev/use-cases/) covers what nostr-veil is, the problem it solves, and practical things you can build on it today.
|
|
12
13
|
|
|
13
14
|
---
|
|
14
15
|
|
|
15
|
-
##
|
|
16
|
+
## Key concepts
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
If you're new to this space, here's what the jargon means:
|
|
18
19
|
|
|
19
|
-
|
|
|
20
|
+
| Term | Plain English |
|
|
21
|
+
|------|--------------|
|
|
22
|
+
| **Web of Trust (WoT)** | Instead of a central authority deciding who's trustworthy, people vouch for each other. Your reputation is built from the opinions of people who know you. |
|
|
23
|
+
| **NIP-85** | A [Nostr standard](https://github.com/nostr-protocol/nips/blob/master/85.md) for publishing trust scores (e.g. "this person has 800 followers and a rank of 74"). Think of it as a shared format for reputation data. |
|
|
24
|
+
| **Ring signature** | A cryptographic technique where someone signs a message on behalf of a group. A verifier can confirm "someone in this group signed this" but cannot tell who. Like a sealed ballot -- you can count the votes but not trace them. |
|
|
25
|
+
| **LSAG** | Linkable Spontaneous Anonymous Group signature -- a specific type of ring signature that also detects duplicates. If the same person tries to vote twice, the system catches it, without revealing who they are. |
|
|
26
|
+
| **Trust circle** | The group of people who collectively produce a trust score. Each member contributes anonymously; the results are combined (median by default). |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## The trust trilemma
|
|
31
|
+
|
|
32
|
+
Today's Nostr trust scores (NIP-85) ask you to pick two:
|
|
33
|
+
|
|
34
|
+
| Property | Standard NIP-85 | With nostr-veil |
|
|
20
35
|
|-------------|:---:|:---:|
|
|
21
36
|
| Verifiable | ✓ | ✓ |
|
|
22
37
|
| Private | ✗ | ✓ |
|
|
23
38
|
| Portable | ✓ | ✓ |
|
|
24
39
|
|
|
25
|
-
Anyone who can see
|
|
40
|
+
Anyone who can see an ordinary score can see who published it, and multi-party reputation usually creates a visible contributor graph. That works fine for benign social signals. It fails the moment the subject matter is sensitive -- abuse reporting, whistleblowing, political dissent. The people who need reputation systems most are the ones who cannot afford to be identified.
|
|
26
41
|
|
|
27
|
-
nostr-veil solves all three.
|
|
42
|
+
nostr-veil solves all three for group assertions. The output is a standard NIP-85 event that NIP-85-aware apps can display. Apps that understand nostr-veil can go further and verify the cryptographic proofs that back the scores.
|
|
28
43
|
|
|
29
44
|
---
|
|
30
45
|
|
|
@@ -38,13 +53,13 @@ graph TB
|
|
|
38
53
|
end
|
|
39
54
|
|
|
40
55
|
subgraph Veil["nostr-veil"]
|
|
41
|
-
proof["nostr-veil/proof<br/>
|
|
42
|
-
nip85["nostr-veil/nip85<br/>
|
|
56
|
+
proof["nostr-veil/proof<br/>Ring signatures<br/>Anonymous contributions<br/>Threshold aggregation"]
|
|
57
|
+
nip85["nostr-veil/nip85<br/>Trust score events<br/>Provider declarations<br/>Builders · Parsers · Filters"]
|
|
43
58
|
end
|
|
44
59
|
|
|
45
60
|
subgraph Crypto["Cryptographic Primitives"]
|
|
46
|
-
ringsig["@forgesworn/ring-sig<br/>
|
|
47
|
-
noble["@noble/curves + hashes<br/>
|
|
61
|
+
ringsig["@forgesworn/ring-sig<br/>Ring signature engine"]
|
|
62
|
+
noble["@noble/curves + hashes<br/>Cryptographic primitives"]
|
|
48
63
|
end
|
|
49
64
|
|
|
50
65
|
subgraph Companions["Companion Libraries"]
|
|
@@ -117,7 +132,9 @@ The resulting `assertion` is a plain `EventTemplate` you sign and publish like a
|
|
|
117
132
|
| `buildProviderDeclaration(providers, encryptedContent?)` | Build a kind 10040 provider declaration |
|
|
118
133
|
| `parseAssertion(event)` | Parse a raw event into a `ParsedAssertion` |
|
|
119
134
|
| `parseProviderDeclaration(event, decryptFn?)` | Parse a kind 10040 provider declaration into `ParsedProvider[]` (supports optional NIP-44 decryption) |
|
|
120
|
-
| `validateAssertion(event)` | Validate a NIP-85 assertion --
|
|
135
|
+
| `validateAssertion(event, options?)` | Validate a NIP-85 assertion -- pass `{ strict: true }` for kind-specific metric checks and optional subject-hint validation |
|
|
136
|
+
| `validateAssertionStrict(event)` | Strict NIP-85 assertion validation shortcut |
|
|
137
|
+
| `validateProviderDeclarationStrict(event)` | Strict kind 10040 provider declaration validation for plaintext tags; encrypted declarations are accepted when tags are omitted |
|
|
121
138
|
| `assertionFilter({ kind, subject?, provider? })` | Build a relay query filter for assertions |
|
|
122
139
|
| `providerFilter(pubkey)` | Build a relay query filter for a provider declaration |
|
|
123
140
|
| `NIP85_KINDS` | Kind constants: `USER`, `EVENT`, `ADDRESSABLE`, `IDENTIFIER`, `PROVIDER` |
|
|
@@ -126,11 +143,19 @@ The resulting `assertion` is a plain `EventTemplate` you sign and publish like a
|
|
|
126
143
|
|
|
127
144
|
| Export | Description |
|
|
128
145
|
|--------|-------------|
|
|
129
|
-
| `createTrustCircle(memberPubkeys)` | Create a trust circle from an array of pubkeys |
|
|
130
|
-
| `contributeAssertion(circle, subject, metrics, privateKey, memberIndex)` | Produce an anonymous `Contribution`
|
|
131
|
-
| `
|
|
132
|
-
| `
|
|
146
|
+
| `createTrustCircle(memberPubkeys, options?)` | Create a trust circle from an array of pubkeys; pass `{ scope }` to federate circles for [cross-circle deduplication](#cross-circle-deduplication) |
|
|
147
|
+
| `contributeAssertion(circle, subject, metrics, privateKey, memberIndex, options?)` | Produce an anonymous ring-signed `Contribution`; v1 by default, v2 when `{ proofVersion: 'v2', kind, subjectTag, subjectTagValue }` is supplied |
|
|
148
|
+
| `contributeEventAssertion(circle, eventId, metrics, privateKey, memberIndex, options?)` | Produce a contribution for a kind 30383 event assertion |
|
|
149
|
+
| `contributeAddressableAssertion(circle, address, metrics, privateKey, memberIndex, options?)` | Produce a contribution for a kind 30384 addressable assertion |
|
|
150
|
+
| `contributeIdentifierAssertion(circle, identifier, kTag, metrics, privateKey, memberIndex, options?)` | Produce a contribution for a kind 30385 identifier assertion |
|
|
151
|
+
| `aggregateContributions(circle, subject, contributions, options?)` | Aggregate user-score contributions into a kind 30382 NIP-85 event with veil tags (default aggregation: median) |
|
|
152
|
+
| `aggregateEventContributions(circle, eventId, contributions, options?)` | Aggregate into a kind 30383 event assertion with `d`/`e` tags |
|
|
153
|
+
| `aggregateAddressableContributions(circle, address, contributions, options?)` | Aggregate into a kind 30384 addressable assertion with `d`/`a` tags |
|
|
154
|
+
| `aggregateIdentifierContributions(circle, identifier, kTag, contributions, options?)` | Aggregate into a kind 30385 identifier assertion with `d`/`k` tags |
|
|
155
|
+
| `verifyProof(event, options?)` | Verify ring signatures, threshold metadata, signed metric aggregation, and optional proof-version requirements |
|
|
156
|
+
| `verifyFederation(events, options?)` | Verify several scoped events together and count distinct contributors across circles ([cross-circle deduplication](#cross-circle-deduplication)) |
|
|
133
157
|
| `canonicalMessage(circleId, subject, metrics)` | Compute the canonical message signed by contributors |
|
|
158
|
+
| `canonicalMessageV2(circleId, subject, metrics, context)` | Compute the opt-in v2 canonical message that binds kind and subject hint tag |
|
|
134
159
|
| `computeCircleId(sortedPubkeys)` | Compute the deterministic circle ID (SHA-256 of colon-joined pubkeys) |
|
|
135
160
|
|
|
136
161
|
### Signing utility (root export)
|
|
@@ -144,22 +169,124 @@ The resulting `assertion` is a plain `EventTemplate` you sign and publish like a
|
|
|
144
169
|
|
|
145
170
|
## How it works
|
|
146
171
|
|
|
147
|
-
Each member of a trust circle
|
|
172
|
+
Each member of a trust circle independently submits their scores. Under the hood, each submission is wrapped in a ring signature -- a cryptographic envelope that proves "a member of this group signed this" without revealing which member.
|
|
148
173
|
|
|
149
|
-
The published
|
|
174
|
+
The published event carries extra tags on top of the standard NIP-85 format:
|
|
150
175
|
|
|
151
|
-
- `veil-ring` -- the full
|
|
152
|
-
- `veil-threshold` -- how many
|
|
153
|
-
- `veil-
|
|
176
|
+
- `veil-ring` -- the full list of circle members (the group who could have contributed)
|
|
177
|
+
- `veil-threshold` -- how many members actually contributed vs. total circle size
|
|
178
|
+
- `veil-agg` -- which aggregate function produced the metric tags (median by default)
|
|
179
|
+
- `veil-sig` (one per contributor) -- the ring signature and a duplicate-detection token
|
|
180
|
+
- `veil-version` -- present only for opt-in proof v2 events
|
|
181
|
+
- `veil-scope` -- present only for a federated circle; see [Cross-circle deduplication](#cross-circle-deduplication)
|
|
154
182
|
|
|
155
183
|
A verifier calls `verifyProof`, which:
|
|
156
184
|
|
|
157
|
-
1.
|
|
158
|
-
2.
|
|
159
|
-
3.
|
|
160
|
-
4. Confirms the
|
|
185
|
+
1. Checks each ring signature is valid (a real member signed it)
|
|
186
|
+
2. Checks the duplicate-detection tokens are all different (nobody voted twice)
|
|
187
|
+
3. Confirms the threshold metadata matches the ring and distinct signatures
|
|
188
|
+
4. Confirms the published metric tags match the aggregate of the signed contributions
|
|
189
|
+
|
|
190
|
+
At no point does verification require knowing which member produced which signature. The group membership is public. The identities of the actual contributors are not. The signed metric values are public inside the proof, so nostr-veil hides contributor identity, not the fact that an anonymous contributor submitted a particular score.
|
|
191
|
+
|
|
192
|
+
By default, verification expects the same median aggregation used by `aggregateContributions`. If you pass a custom `aggregateFn` to `aggregateContributions`, pass the same function to `verifyProof`.
|
|
193
|
+
|
|
194
|
+
### Proof v2
|
|
195
|
+
|
|
196
|
+
The original proof format remains the default. It signs the circle ID, the `d`-tag subject, and numeric metrics, and it uses `veil:v1:<scope-or-circleId>:<subject>` as the LSAG election ID.
|
|
197
|
+
|
|
198
|
+
Proof v2 is additive and opt-in. It signs the same data plus the NIP-85 assertion kind and the subject hint tag/value (`p`, `e`, `a`, or `k`), and derives the key image from that semantic context. That prevents a valid contribution for one assertion class being replayed as another when a subject string is reused.
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
import { contributeEventAssertion, aggregateEventContributions, verifyProof } from 'nostr-veil'
|
|
202
|
+
|
|
203
|
+
const contribution = contributeEventAssertion(
|
|
204
|
+
circle,
|
|
205
|
+
eventId,
|
|
206
|
+
{ rank: 90 },
|
|
207
|
+
alicePrivkey,
|
|
208
|
+
circle.members.indexOf(alicePubkey),
|
|
209
|
+
{ proofVersion: 'v2' },
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
const assertion = aggregateEventContributions(circle, eventId, [contribution], { proofVersion: 'v2' })
|
|
213
|
+
const result = verifyProof(assertion, { requireProofVersion: 'v2' })
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Old v1 events still verify without changes. Use `requireProofVersion: 'v2'` only when your application policy wants to reject legacy proofs for that workflow.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Threat model
|
|
221
|
+
|
|
222
|
+
nostr-veil is a privacy layer for already-defined trust circles. It gives you:
|
|
223
|
+
|
|
224
|
+
- Anonymous membership proof: each contribution was signed by some member of the public ring, without revealing which member.
|
|
225
|
+
- Duplicate detection: one member cannot contribute twice within the same circle/scope and subject without reusing the same LSAG key image.
|
|
226
|
+
- Signed metric integrity: `verifyProof` checks the published metric tags against the aggregate of the signed contribution messages.
|
|
227
|
+
- Optional semantic binding: proof v2 binds the assertion kind and subject hint tag into the signed message and election ID.
|
|
228
|
+
- Standard NIP-85 output: non-veil clients can still read the aggregate score.
|
|
229
|
+
|
|
230
|
+
It does not claim to solve every trust problem by itself:
|
|
231
|
+
|
|
232
|
+
- It does not hide the circle membership list; the ring is public.
|
|
233
|
+
- It does not hide individual anonymous metric values; they are needed so anyone can recompute the aggregate.
|
|
234
|
+
- It does not hide network, timing, relay, or collector metadata.
|
|
235
|
+
- It does not decide whether the circle members are trustworthy, human, independent, or correctly selected.
|
|
236
|
+
- A shared federation `scope` intentionally reveals cross-circle overlap by key image, while still hiding the contributor's identity.
|
|
237
|
+
|
|
238
|
+
For sensitive deployments, combine nostr-veil with careful collection, transport privacy, key hygiene, and a clear policy for how circles are admitted and rotated.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Use cases
|
|
243
|
+
|
|
244
|
+
The shipped primitives support more than user trust scores:
|
|
245
|
+
|
|
246
|
+
- User reputation and abuse reporting with kind 30382 user assertions.
|
|
247
|
+
- Source corroboration and peer review where contributors need protection from retaliation.
|
|
248
|
+
- Event and claim verification with kind 30383 event assertions via `aggregateEventContributions`.
|
|
249
|
+
- Article, long-form note, or research review with kind 30384 addressable assertions via `aggregateAddressableContributions`.
|
|
250
|
+
- Relay, service, vendor, marketplace, or external identifier reputation with kind 30385 identifier assertions via `aggregateIdentifierContributions`.
|
|
251
|
+
- Release, package, and maintainer reputation where reviewers can flag compromised releases or risky maintainership without exposing themselves.
|
|
252
|
+
- NIP-05, domain, and service-provider trust where communities can score identifiers outside a single Nostr pubkey.
|
|
253
|
+
- Community list, labeler, and moderation-list reputation where users can compare curation sources without mapping every reviewer.
|
|
254
|
+
- Federated moderation where scoped circles count overlapping contributors once, not once per circle.
|
|
255
|
+
- Privacy-preserving onboarding where an already-trusted circle can vouch for a new account without naming the individual vouchees.
|
|
256
|
+
- Future anonymous credential or attestation co-signing, once endorsement event formats are agreed: a circle can prove enough members backed a credential without naming which members.
|
|
257
|
+
- Future relay or community admission, once gated-access handshakes exist: a verifier can require a threshold-backed proof without learning which trusted member opened the door.
|
|
258
|
+
|
|
259
|
+
nostr-veil proves that distinct keys from a public trust circle contributed. Trust-circle formation, Sybil policy, revocation, and anonymous access control are separate application-layer decisions.
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Cross-circle deduplication
|
|
264
|
+
|
|
265
|
+
By default every trust circle is cryptographically isolated. A contributor's duplicate-detection token -- the LSAG key image -- is derived from the circle itself, so the same person contributing to two different circles produces two unrelated tokens. Nobody can tell the circles share a member.
|
|
266
|
+
|
|
267
|
+
That isolation is the right default, but it caps a trust score at one circle. To count honestly across a *federation* of circles all assessing the same subject, give them a shared `scope`:
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
// Two community moderation circles, one federation
|
|
271
|
+
const circleA = createTrustCircle(membersA, { scope: 'community-moderators' })
|
|
272
|
+
const circleB = createTrustCircle(membersB, { scope: 'community-moderators' })
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Circles sharing a `scope` derive the key image from the scope rather than the circle, so a contributor who appears in several of them produces the *same* token in each. `verifyFederation` gathers events from across the federation, verifies each one, and counts the distinct contributors -- matched by key image, never by identity:
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
import { verifyFederation } from 'nostr-veil'
|
|
279
|
+
|
|
280
|
+
// Aggregated events from every circle in the federation, all about the same subject
|
|
281
|
+
const result = verifyFederation([circleAEvent, circleBEvent, circleCEvent])
|
|
282
|
+
// { valid: true, scope: 'community-moderators', circleCount: 3,
|
|
283
|
+
// totalSignatures: 7, distinctSigners: 5, ... }
|
|
284
|
+
// distinctSigners < totalSignatures: two contributors signed in more than one circle
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
A scoped event carries a `veil-scope` tag, which both `verifyProof` and `verifyFederation` read automatically. `verifyFederation` rejects the federation if the events disagree on subject or scope, or if any event is unscoped -- an isolated circle's key images cannot be matched across circles. Circles created without a `scope` behave exactly as before: no tag, fully isolated.
|
|
161
288
|
|
|
162
|
-
|
|
289
|
+
**Trade-off.** A shared scope is what enables cross-circle counting, and equally what makes cross-circle membership *overlap* observable: anyone collecting the events can see that one contributor signed in several circles, still without learning who. Use a `scope` when federated counting is worth that signal, and omit it otherwise.
|
|
163
290
|
|
|
164
291
|
---
|
|
165
292
|
|
|
@@ -167,9 +294,9 @@ At no point does verification require knowing which member produced which signat
|
|
|
167
294
|
|
|
168
295
|
nostr-veil is one layer of a broader identity and trust stack:
|
|
169
296
|
|
|
170
|
-
- [@forgesworn/ring-sig](https://github.com/forgesworn/ring-sig) --
|
|
171
|
-
- [nsec-tree](https://github.com/forgesworn/nsec-tree) --
|
|
172
|
-
- [canary-kit](https://github.com/forgesworn/canary-kit) --
|
|
297
|
+
- [@forgesworn/ring-sig](https://github.com/forgesworn/ring-sig) -- The ring signature engine (the core cryptography)
|
|
298
|
+
- [nsec-tree](https://github.com/forgesworn/nsec-tree) -- Generate separate anonymous identities from a single master key
|
|
299
|
+
- [canary-kit](https://github.com/forgesworn/canary-kit) -- Detect when someone is being coerced (duress signals)
|
|
173
300
|
- [signet](https://github.com/forgesworn/signet) -- Decentralised identity verification for Nostr
|
|
174
301
|
- [dominion](https://github.com/forgesworn/dominion) -- Epoch-based encrypted content access control
|
|
175
302
|
|
|
@@ -192,7 +319,7 @@ Each project is independently maintained and published. nostr-veil focuses solel
|
|
|
192
319
|
| Library | What it does |
|
|
193
320
|
|---------|-------------|
|
|
194
321
|
| [nsec-tree](https://github.com/forgesworn/nsec-tree) | Deterministic sub-identity derivation |
|
|
195
|
-
| [ring-sig](https://github.com/forgesworn/ring-sig) |
|
|
322
|
+
| [ring-sig](https://github.com/forgesworn/ring-sig) | Ring signature engine (core cryptography) |
|
|
196
323
|
| [range-proof](https://github.com/forgesworn/range-proof) | Pedersen commitment range proofs |
|
|
197
324
|
| [canary-kit](https://github.com/forgesworn/canary-kit) | Coercion-resistant spoken verification |
|
|
198
325
|
| [spoken-token](https://github.com/forgesworn/spoken-token) | Human-speakable verification tokens |
|
|
@@ -4,6 +4,13 @@ interface RawEvent {
|
|
|
4
4
|
tags: string[][];
|
|
5
5
|
content: string;
|
|
6
6
|
}
|
|
7
|
+
export interface ValidationOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Enable kind-specific NIP-85 checks. Loose validation is kept as the default
|
|
10
|
+
* for backwards compatibility with older callers and extension tags.
|
|
11
|
+
*/
|
|
12
|
+
strict?: boolean;
|
|
13
|
+
}
|
|
7
14
|
/**
|
|
8
15
|
* Validates a NIP-85 assertion event.
|
|
9
16
|
*
|
|
@@ -11,8 +18,11 @@ interface RawEvent {
|
|
|
11
18
|
* - `kind` is one of the four NIP-85 assertion kinds (30382–30385)
|
|
12
19
|
* - A `d` tag is present
|
|
13
20
|
* - `rank`, if present, is a number in the range 0–100
|
|
21
|
+
* - when `{ strict: true }` is passed, kind-specific metric names are checked
|
|
22
|
+
* and optional subject hint tags (`p`, `e`, `a`) are validated if present
|
|
14
23
|
*
|
|
15
24
|
* @param event - A raw Nostr event with `kind`, `tags`, and `content` fields
|
|
25
|
+
* @param options - Optional validation mode. Strict mode is additive and opt-in.
|
|
16
26
|
* @returns A {@link ValidationResult} with `valid` boolean and an array of error strings
|
|
17
27
|
*
|
|
18
28
|
* @example
|
|
@@ -21,6 +31,19 @@ interface RawEvent {
|
|
|
21
31
|
* console.error('Validation failed:', result.errors)
|
|
22
32
|
* }
|
|
23
33
|
*/
|
|
24
|
-
export declare function validateAssertion(event: RawEvent): ValidationResult;
|
|
34
|
+
export declare function validateAssertion(event: RawEvent, options?: ValidationOptions): ValidationResult;
|
|
35
|
+
/**
|
|
36
|
+
* Strict NIP-85 assertion validation. This is equivalent to
|
|
37
|
+
* `validateAssertion(event, { strict: true })`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateAssertionStrict(event: RawEvent): ValidationResult;
|
|
40
|
+
/**
|
|
41
|
+
* Strict validation for plaintext kind 10040 provider declarations.
|
|
42
|
+
*
|
|
43
|
+
* Encrypted provider declarations cannot be inspected without a decrypt
|
|
44
|
+
* function, so this validator accepts the standard encrypted form when content
|
|
45
|
+
* is non-empty and plaintext tags are omitted.
|
|
46
|
+
*/
|
|
47
|
+
export declare function validateProviderDeclarationStrict(event: RawEvent): ValidationResult;
|
|
25
48
|
export {};
|
|
26
49
|
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/nip85/validators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAUlD,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/nip85/validators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAUlD,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAwLD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,GAAE,iBAAsB,GAAG,gBAAgB,CAiCpG;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,QAAQ,GAAG,gBAAgB,CAEzE;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,QAAQ,GAAG,gBAAgB,CAmDnF"}
|
package/dist/nip85/validators.js
CHANGED
|
@@ -5,6 +5,174 @@ const ASSERTION_KINDS = new Set([
|
|
|
5
5
|
NIP85_KINDS.ADDRESSABLE,
|
|
6
6
|
NIP85_KINDS.IDENTIFIER,
|
|
7
7
|
]);
|
|
8
|
+
const HEX64_RE = /^[0-9a-f]{64}$/;
|
|
9
|
+
const DECIMAL_INTEGER_RE = /^(0|[1-9]\d*)$/;
|
|
10
|
+
const ADDRESS_RE = /^(0|[1-9]\d*):[0-9a-f]{64}:.*$/;
|
|
11
|
+
const PROVIDER_TAG_RE = /^(0|[1-9]\d*):[A-Za-z0-9_.-]+$/;
|
|
12
|
+
const RELAY_HINT_RE = /^wss?:\/\/.+$/i;
|
|
13
|
+
const META_TAGS = new Set(['d', 'p', 'e', 'a', 'k']);
|
|
14
|
+
const LOOSE_NUMERIC_METRICS = new Set([
|
|
15
|
+
'rank',
|
|
16
|
+
'followers',
|
|
17
|
+
'following',
|
|
18
|
+
'zap_amt_sent',
|
|
19
|
+
'zap_amt_recd',
|
|
20
|
+
'zap_cnt_sent',
|
|
21
|
+
'zap_cnt_recd',
|
|
22
|
+
'post_cnt',
|
|
23
|
+
'reply_cnt',
|
|
24
|
+
'repost_cnt',
|
|
25
|
+
'reaction_cnt',
|
|
26
|
+
]);
|
|
27
|
+
const USER_NUMERIC_METRICS = new Set([
|
|
28
|
+
'followers',
|
|
29
|
+
'rank',
|
|
30
|
+
'first_created_at',
|
|
31
|
+
'post_cnt',
|
|
32
|
+
'reply_cnt',
|
|
33
|
+
'reactions_cnt',
|
|
34
|
+
'zap_amt_recd',
|
|
35
|
+
'zap_amt_sent',
|
|
36
|
+
'zap_cnt_recd',
|
|
37
|
+
'zap_cnt_sent',
|
|
38
|
+
'zap_avg_amt_day_recd',
|
|
39
|
+
'zap_avg_amt_day_sent',
|
|
40
|
+
'reports_cnt_recd',
|
|
41
|
+
'reports_cnt_sent',
|
|
42
|
+
'active_hours_start',
|
|
43
|
+
'active_hours_end',
|
|
44
|
+
]);
|
|
45
|
+
const USER_STRING_METRICS = new Set(['t']);
|
|
46
|
+
const EVENT_NUMERIC_METRICS = new Set([
|
|
47
|
+
'rank',
|
|
48
|
+
'comment_cnt',
|
|
49
|
+
'quote_cnt',
|
|
50
|
+
'repost_cnt',
|
|
51
|
+
'reaction_cnt',
|
|
52
|
+
'zap_cnt',
|
|
53
|
+
'zap_amount',
|
|
54
|
+
]);
|
|
55
|
+
const IDENTIFIER_NUMERIC_METRICS = new Set(['rank', 'comment_cnt', 'reaction_cnt']);
|
|
56
|
+
function tagValues(event, name) {
|
|
57
|
+
return event.tags.filter(t => t[0] === name).map(t => t[1]).filter((v) => typeof v === 'string');
|
|
58
|
+
}
|
|
59
|
+
function isFiniteNumberTag(value) {
|
|
60
|
+
if (value === undefined || value.trim() === '')
|
|
61
|
+
return false;
|
|
62
|
+
return Number.isFinite(Number(value));
|
|
63
|
+
}
|
|
64
|
+
function validateLooseRank(value, errors) {
|
|
65
|
+
const rankValue = Number(value);
|
|
66
|
+
if (isNaN(rankValue) || rankValue < 0 || rankValue > 100) {
|
|
67
|
+
errors.push(`Invalid rank value: "${value}". Must be a number between 0 and 100.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function validateStrictRank(value, errors) {
|
|
71
|
+
const rankValue = Number(value);
|
|
72
|
+
if (value === undefined || value.trim() === '' || !Number.isFinite(rankValue) || rankValue < 0 || rankValue > 100) {
|
|
73
|
+
errors.push(`Invalid rank value: "${value}". Must be a number between 0 and 100.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function requireSingletonTag(event, name, errors) {
|
|
77
|
+
const values = tagValues(event, name);
|
|
78
|
+
if (values.length === 0) {
|
|
79
|
+
errors.push(`Missing required ${name}-tag.`);
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
if (values.length > 1) {
|
|
83
|
+
errors.push(`Duplicate ${name}-tag.`);
|
|
84
|
+
}
|
|
85
|
+
return values[0];
|
|
86
|
+
}
|
|
87
|
+
function validateOptionalMatchingTag(event, name, subject, errors) {
|
|
88
|
+
const values = tagValues(event, name);
|
|
89
|
+
if (values.length === 0)
|
|
90
|
+
return;
|
|
91
|
+
if (values.length > 1) {
|
|
92
|
+
errors.push(`Duplicate ${name}-tag.`);
|
|
93
|
+
}
|
|
94
|
+
if (values[0] !== subject) {
|
|
95
|
+
errors.push(`${name}-tag must match d-tag.`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function validateStrictSubjectTags(event, errors) {
|
|
99
|
+
const subject = requireSingletonTag(event, 'd', errors);
|
|
100
|
+
if (subject === undefined)
|
|
101
|
+
return;
|
|
102
|
+
switch (event.kind) {
|
|
103
|
+
case NIP85_KINDS.USER:
|
|
104
|
+
if (!HEX64_RE.test(subject)) {
|
|
105
|
+
errors.push('User assertion d-tag must be a 64-character lowercase hex pubkey.');
|
|
106
|
+
}
|
|
107
|
+
validateOptionalMatchingTag(event, 'p', subject, errors);
|
|
108
|
+
break;
|
|
109
|
+
case NIP85_KINDS.EVENT:
|
|
110
|
+
if (!HEX64_RE.test(subject)) {
|
|
111
|
+
errors.push('Event assertion d-tag must be a 64-character lowercase hex event id.');
|
|
112
|
+
}
|
|
113
|
+
validateOptionalMatchingTag(event, 'e', subject, errors);
|
|
114
|
+
break;
|
|
115
|
+
case NIP85_KINDS.ADDRESSABLE:
|
|
116
|
+
if (!ADDRESS_RE.test(subject)) {
|
|
117
|
+
errors.push('Addressable assertion d-tag must be a NIP-33 address: kind:pubkey:d-tag.');
|
|
118
|
+
}
|
|
119
|
+
validateOptionalMatchingTag(event, 'a', subject, errors);
|
|
120
|
+
break;
|
|
121
|
+
case NIP85_KINDS.IDENTIFIER: {
|
|
122
|
+
if (subject === '') {
|
|
123
|
+
errors.push('Identifier assertion d-tag must be non-empty.');
|
|
124
|
+
}
|
|
125
|
+
const kTag = requireSingletonTag(event, 'k', errors);
|
|
126
|
+
if (kTag !== undefined && !DECIMAL_INTEGER_RE.test(kTag)) {
|
|
127
|
+
errors.push('Identifier assertion k-tag must be a decimal kind number.');
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function strictMetricSets(kind) {
|
|
134
|
+
switch (kind) {
|
|
135
|
+
case NIP85_KINDS.USER:
|
|
136
|
+
return { numeric: USER_NUMERIC_METRICS, string: USER_STRING_METRICS };
|
|
137
|
+
case NIP85_KINDS.EVENT:
|
|
138
|
+
case NIP85_KINDS.ADDRESSABLE:
|
|
139
|
+
return { numeric: EVENT_NUMERIC_METRICS, string: new Set() };
|
|
140
|
+
case NIP85_KINDS.IDENTIFIER:
|
|
141
|
+
return { numeric: IDENTIFIER_NUMERIC_METRICS, string: new Set() };
|
|
142
|
+
default:
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function validateStrictMetrics(event, errors) {
|
|
147
|
+
const allowed = strictMetricSets(event.kind);
|
|
148
|
+
if (allowed === undefined)
|
|
149
|
+
return;
|
|
150
|
+
const seen = new Set();
|
|
151
|
+
for (const tag of event.tags) {
|
|
152
|
+
const name = tag[0];
|
|
153
|
+
if (META_TAGS.has(name) || name.startsWith('veil-'))
|
|
154
|
+
continue;
|
|
155
|
+
if (seen.has(name)) {
|
|
156
|
+
errors.push(`Duplicate metric tag "${name}".`);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
seen.add(name);
|
|
160
|
+
if (!allowed.numeric.has(name) && !allowed.string.has(name)) {
|
|
161
|
+
errors.push(`Unknown metric tag "${name}" for kind ${event.kind}.`);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (tag[1] === undefined) {
|
|
165
|
+
errors.push(`Metric "${name}" is missing a value.`);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (name === 'rank') {
|
|
169
|
+
validateStrictRank(tag[1], errors);
|
|
170
|
+
}
|
|
171
|
+
else if (allowed.numeric.has(name) && !isFiniteNumberTag(tag[1])) {
|
|
172
|
+
errors.push(`Invalid metric "${name}": "${tag[1]}" is not a finite number.`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
8
176
|
/**
|
|
9
177
|
* Validates a NIP-85 assertion event.
|
|
10
178
|
*
|
|
@@ -12,8 +180,11 @@ const ASSERTION_KINDS = new Set([
|
|
|
12
180
|
* - `kind` is one of the four NIP-85 assertion kinds (30382–30385)
|
|
13
181
|
* - A `d` tag is present
|
|
14
182
|
* - `rank`, if present, is a number in the range 0–100
|
|
183
|
+
* - when `{ strict: true }` is passed, kind-specific metric names are checked
|
|
184
|
+
* and optional subject hint tags (`p`, `e`, `a`) are validated if present
|
|
15
185
|
*
|
|
16
186
|
* @param event - A raw Nostr event with `kind`, `tags`, and `content` fields
|
|
187
|
+
* @param options - Optional validation mode. Strict mode is additive and opt-in.
|
|
17
188
|
* @returns A {@link ValidationResult} with `valid` boolean and an array of error strings
|
|
18
189
|
*
|
|
19
190
|
* @example
|
|
@@ -22,7 +193,7 @@ const ASSERTION_KINDS = new Set([
|
|
|
22
193
|
* console.error('Validation failed:', result.errors)
|
|
23
194
|
* }
|
|
24
195
|
*/
|
|
25
|
-
export function validateAssertion(event) {
|
|
196
|
+
export function validateAssertion(event, options = {}) {
|
|
26
197
|
const errors = [];
|
|
27
198
|
if (!ASSERTION_KINDS.has(event.kind)) {
|
|
28
199
|
errors.push(`Invalid kind: ${event.kind}. Must be one of 30382, 30383, 30384, 30385.`);
|
|
@@ -33,21 +204,78 @@ export function validateAssertion(event) {
|
|
|
33
204
|
}
|
|
34
205
|
const rankTag = event.tags.find(t => t[0] === 'rank');
|
|
35
206
|
if (rankTag !== undefined) {
|
|
36
|
-
|
|
37
|
-
if (isNaN(rankValue) || rankValue < 0 || rankValue > 100) {
|
|
38
|
-
errors.push(`Invalid rank value: "${rankTag[1]}". Must be a number between 0 and 100.`);
|
|
39
|
-
}
|
|
207
|
+
validateLooseRank(rankTag[1], errors);
|
|
40
208
|
}
|
|
41
209
|
// Validate all numeric metric tags are finite numbers
|
|
42
|
-
const NUMERIC_METRICS = new Set(['rank', 'followers', 'following', 'zap_amt_sent', 'zap_amt_recd', 'zap_cnt_sent', 'zap_cnt_recd', 'post_cnt', 'reply_cnt', 'repost_cnt', 'reaction_cnt']);
|
|
43
210
|
for (const tag of event.tags) {
|
|
44
|
-
if (
|
|
211
|
+
if (LOOSE_NUMERIC_METRICS.has(tag[0]) && tag[0] !== 'rank') {
|
|
45
212
|
const value = Number(tag[1]);
|
|
46
213
|
if (!Number.isFinite(value)) {
|
|
47
214
|
errors.push(`Invalid metric "${tag[0]}": "${tag[1]}" is not a finite number.`);
|
|
48
215
|
}
|
|
49
216
|
}
|
|
50
217
|
}
|
|
218
|
+
if (options.strict) {
|
|
219
|
+
validateStrictSubjectTags(event, errors);
|
|
220
|
+
validateStrictMetrics(event, errors);
|
|
221
|
+
}
|
|
222
|
+
return { valid: errors.length === 0, errors };
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Strict NIP-85 assertion validation. This is equivalent to
|
|
226
|
+
* `validateAssertion(event, { strict: true })`.
|
|
227
|
+
*/
|
|
228
|
+
export function validateAssertionStrict(event) {
|
|
229
|
+
return validateAssertion(event, { strict: true });
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Strict validation for plaintext kind 10040 provider declarations.
|
|
233
|
+
*
|
|
234
|
+
* Encrypted provider declarations cannot be inspected without a decrypt
|
|
235
|
+
* function, so this validator accepts the standard encrypted form when content
|
|
236
|
+
* is non-empty and plaintext tags are omitted.
|
|
237
|
+
*/
|
|
238
|
+
export function validateProviderDeclarationStrict(event) {
|
|
239
|
+
const errors = [];
|
|
240
|
+
if (event.kind !== NIP85_KINDS.PROVIDER) {
|
|
241
|
+
errors.push(`Invalid kind: ${event.kind}. Must be 10040 for a provider declaration.`);
|
|
242
|
+
}
|
|
243
|
+
if (event.content !== '' && event.tags.length === 0) {
|
|
244
|
+
return { valid: errors.length === 0, errors };
|
|
245
|
+
}
|
|
246
|
+
if (event.tags.length === 0) {
|
|
247
|
+
errors.push('Provider declaration must contain at least one provider tag or encrypted content.');
|
|
248
|
+
}
|
|
249
|
+
const seen = new Set();
|
|
250
|
+
for (let i = 0; i < event.tags.length; i++) {
|
|
251
|
+
const tag = event.tags[i];
|
|
252
|
+
const name = tag[0];
|
|
253
|
+
if (typeof name !== 'string' || !PROVIDER_TAG_RE.test(name)) {
|
|
254
|
+
errors.push(`Provider tag at index ${i} must use kind:metric format.`);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const [kindText, metric] = name.split(':');
|
|
258
|
+
const kind = Number(kindText);
|
|
259
|
+
if (!ASSERTION_KINDS.has(kind)) {
|
|
260
|
+
errors.push(`Provider tag at index ${i} has unsupported assertion kind: ${kindText}.`);
|
|
261
|
+
}
|
|
262
|
+
if (metric === '') {
|
|
263
|
+
errors.push(`Provider tag at index ${i} has an empty metric name.`);
|
|
264
|
+
}
|
|
265
|
+
const key = `${kindText}:${metric}:${tag[1] ?? ''}`;
|
|
266
|
+
if (seen.has(key)) {
|
|
267
|
+
errors.push(`Duplicate provider declaration for ${kindText}:${metric}.`);
|
|
268
|
+
}
|
|
269
|
+
seen.add(key);
|
|
270
|
+
const servicePubkey = tag[1];
|
|
271
|
+
if (typeof servicePubkey !== 'string' || !HEX64_RE.test(servicePubkey)) {
|
|
272
|
+
errors.push(`Provider tag at index ${i} service pubkey must be a 64-character lowercase hex pubkey.`);
|
|
273
|
+
}
|
|
274
|
+
const relayHint = tag[2];
|
|
275
|
+
if (relayHint !== undefined && relayHint !== '' && !RELAY_HINT_RE.test(relayHint)) {
|
|
276
|
+
errors.push(`Provider tag at index ${i} relay hint must be a websocket URL.`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
51
279
|
return { valid: errors.length === 0, errors };
|
|
52
280
|
}
|
|
53
281
|
//# sourceMappingURL=validators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/nip85/validators.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAS;IACtC,WAAW,CAAC,IAAI;IAChB,WAAW,CAAC,KAAK;IACjB,WAAW,CAAC,WAAW;IACvB,WAAW,CAAC,UAAU;CACvB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/nip85/validators.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAS;IACtC,WAAW,CAAC,IAAI;IAChB,WAAW,CAAC,KAAK;IACjB,WAAW,CAAC,WAAW;IACvB,WAAW,CAAC,UAAU;CACvB,CAAC,CAAA;AAgBF,MAAM,QAAQ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