nostr-veil 0.35.0 → 0.37.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 +23 -15
- package/bin/cli.js +77 -16
- package/dist/profiles/issues.d.ts +1 -1
- package/dist/profiles/issues.d.ts.map +1 -1
- package/dist/profiles/issues.js +12 -2
- package/dist/profiles/issues.js.map +1 -1
- package/dist/profiles/policy.d.ts +27 -0
- package/dist/profiles/policy.d.ts.map +1 -1
- package/dist/profiles/policy.js +80 -12
- package/dist/profiles/policy.js.map +1 -1
- package/dist/profiles/profiles.d.ts.map +1 -1
- package/dist/profiles/profiles.js +6 -4
- package/dist/profiles/profiles.js.map +1 -1
- package/dist/profiles/report.d.ts +1 -1
- package/dist/profiles/report.d.ts.map +1 -1
- package/dist/profiles/report.js +20 -3
- package/dist/profiles/report.js.map +1 -1
- package/dist/proof/bounds.d.ts +4 -0
- package/dist/proof/bounds.d.ts.map +1 -1
- package/dist/proof/bounds.js +15 -2
- package/dist/proof/bounds.js.map +1 -1
- package/dist/proof/types.d.ts +8 -1
- package/dist/proof/types.d.ts.map +1 -1
- package/dist/proof/verify.d.ts +1 -1
- package/llms-full.txt +33 -9
- package/llms.txt +18 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -268,13 +268,13 @@ The root entry point re-exports all of `nostr-veil/nip85`, `nostr-veil/proof` an
|
|
|
268
268
|
kind?: number // aggregateContributions only; legacy, default 30382
|
|
269
269
|
expiration?: number // NIP-40 expiration tag, unix seconds
|
|
270
270
|
alt?: string // NIP-31 alt tag, non-empty
|
|
271
|
-
contributionBounds?: Record<string, { min?: number; max?: number; integer?: boolean }> // refuse a contribution outside these bounds
|
|
271
|
+
contributionBounds?: Record<string, { min?: number; max?: number; integer?: boolean; required?: boolean }> // refuse a contribution outside these bounds
|
|
272
272
|
}
|
|
273
273
|
```
|
|
274
274
|
|
|
275
275
|
`median` and `mean` round to an integer; `sum`, `min` and `max` do not. A non-finite result throws, and an unknown `aggregate` name throws `Unknown aggregate function: <name>`. A built-in name is written to the `veil-agg` tag and `verifyProof` reads it from there, so verifying a summed tally needs no option: `aggregateContributions(circle, subject, contributions, { aggregate: 'sum' })` verifies with a bare `verifyProof(event)`. A custom function is written as `veil-agg: custom` and must be passed to the verifier too (`verifyProof(event, { aggregateFn })` or a bare function), otherwise it fails with `veil-agg is "custom": pass the aggregate function via options to verify the metric tags`.
|
|
276
276
|
|
|
277
|
-
**The publisher chooses the aggregate, and each member chooses their value.** The circle does not sign `veil-agg`, and the signatures are public, so anyone can republish the same signatures under another function: three scores of 20, 20 and 95 read as 20 under `median` and 95 under `max`, and both pass a bare `verifyProof`. A verifier that expects a particular function says so with `requireAggregate` (the built-in profiles do). A key image stops a member contributing twice, not contributing one large value, and under `sum`, `mean`, `min` or `max` one contribution can move the result. Bound each contribution with `contributionBounds`, for example `{ rank: { min: 0, max: 1, integer: true } }` for a tally of ayes; a metric with no entry is not bounded. Aggregation then throws on a contribution outside the bounds (`Contribution index 2 metric "rank" value 3 is above the contribution maximum 1`), and `contributionBoundViolations(contribution.metrics, bounds)` lets an aggregator find and leave out such a contribution first.
|
|
277
|
+
**The publisher chooses the aggregate, and each member chooses their value.** The circle does not sign `veil-agg`, and the signatures are public, so anyone can republish the same signatures under another function: three scores of 20, 20 and 95 read as 20 under `median` and 95 under `max`, and both pass a bare `verifyProof`. A verifier that expects a particular function says so with `requireAggregate` (the built-in profiles do). A key image stops a member contributing twice, not contributing one large value, and under `sum`, `mean`, `min` or `max` one contribution can move the result. Bound each contribution with `contributionBounds`, for example `{ rank: { min: 0, max: 1, integer: true, required: true } }` for a tally of ayes; a metric with no entry is not bounded. Add `required: true` to reject a signer who left the metric out: without it that member still counts towards `distinctSigners`, so a value can rest on fewer contributions than the signer count. Aggregation then throws on a contribution outside the bounds (`Contribution index 2 metric "rank" value 3 is above the contribution maximum 1`), and `contributionBoundViolations(contribution.metrics, bounds)` lets an aggregator find and leave out such a contribution first.
|
|
278
278
|
|
|
279
279
|
`expiration` and `alt` are publisher tags: the circle does not sign them, and `verifyProof` does not read them as metrics. `expiration` must be a non-negative safe integer and `alt` a non-empty string, or aggregation throws. `verifyProof` accepts at most one of each, rejects an `expiration` that is not a unix time in seconds or an empty `alt`, and does not compare expiry with the clock, so archived events can still be re-checked. The profile verifiers (`verifyUseCaseProfile`, `verifyDeploymentPolicy` and the bundle verifiers built on them) do: they reject an assertion whose `expiration` is at or before `now`, because many relays and caches still serve expired events. These tags are only as trustworthy as the outer Nostr signature, which `verifyProof` does not check: verify the event signature (`verifySignedEvent`, or `requireNostrSignature` in a deployment policy) before relying on them. Other general tags (`client`, `nonce`, `-`, `L`, `l`, `i`, `content-warning`) are not accepted on veil events, and `verifyProof` reads them as unsigned metrics. A metric tag must be exactly `[name, value]`: the circle signs only those two, so `verifyProof` rejects a metric tag with anything after the value, and the same for the `d` tag and the `k` tag. The proof tags have a fixed shape too: a second `veil-ring`, `veil-threshold`, `veil-agg`, `veil-version` or `veil-scope` tag, or extra elements on any of them or on a `veil-sig`, makes the event invalid. Unknown `veil-*` tags are ignored, so a verifier keeps working when a later release adds one. A `k` tag is accepted only on kind 30385, where it names the identifier type.
|
|
280
280
|
|
|
@@ -286,7 +286,7 @@ The root entry point re-exports all of `nostr-veil/nip85`, `nostr-veil/proof` an
|
|
|
286
286
|
| `expectedKind` | `number` | Reject events of any other NIP-85 kind. Recommended for v1 proofs, which are not kind-bound |
|
|
287
287
|
| `requireProofVersion` | `'v1' \| 'v2'` | Reject signatures of the other proof version |
|
|
288
288
|
| `requireAggregate` | `'median' \| 'mean' \| 'sum' \| 'min' \| 'max' \| 'custom'` | Reject the event unless its `veil-agg` tag names this function, with `veil-agg is "max" but "median" is required`. An event with no `veil-agg` tag reads as `median`. When this names a built-in function the metric tags are recomputed with it, whatever `aggregateFn` is passed. Recommended: the publisher chooses the tag |
|
|
289
|
-
| `contributionBounds` | `Record<string, { min?, max?, integer? }>` | Reject the event if any contribution's value for a named metric is outside its bounds. Needed under `sum`, `mean`, `min` and `max`. Malformed bounds fail the proof; they are never ignored |
|
|
289
|
+
| `contributionBounds` | `Record<string, { min?, max?, integer?, required? }>` | Reject the event if any contribution's value for a named metric is outside its bounds. Needed under `sum`, `mean`, `min` and `max`. Malformed bounds fail the proof; they are never ignored |
|
|
290
290
|
| `rejectSubjectInRing` | `boolean` | Fail with `Subject is a veil-ring member` when the d-tag subject is a ring member. Default `false`; `subjectInRing` is reported either way |
|
|
291
291
|
| `limits` | `Partial<VerifyLimits>` | Override `DEFAULT_VERIFY_LIMITS`: `maxRingSize` 1000, `maxSigPayloadBytes` 128000, `maxSignedMessageBytes` 16384, `maxMetricCount` 128, `maxMetricNameLength` 64 |
|
|
292
292
|
|
|
@@ -302,7 +302,7 @@ It returns `{ valid, circleSize, threshold, distinctSigners, subjectInRing, inde
|
|
|
302
302
|
|----------|---------|
|
|
303
303
|
| `createCircleManifest(options)` | Required: `issuedAt`, `members`, `name`, `profileIds`, `purpose`. Optional: `expiresAt`, `status` (`'active' \| 'revoked' \| 'superseded'`), `supersedes`, `revokedCircleIds`, `contact`, `evidenceProcess`, `policyUri` |
|
|
304
304
|
| `verifyCircleManifest(manifest, options?)` | `allowSuperseded`, `now`, `profileId`, `revokedCircleIds` |
|
|
305
|
-
| `createDeploymentPolicy(profile, options)` | Required: `expectedSubject`, plus at least one active circle from `acceptedCircleIds` or `circleManifests`. Optional: `expectedSubjectTagValue`, `id` (default: the profile id), `maxAgeSeconds` and `minDistinctSigners` (default: the profile's), `metricPolicies` (`{ [metric]: { required?, min?, max?, integer? } }`, bounds on the published aggregate), `aggregate` (default: the profile's), `contributionBounds` (`{ [metric]: { min?, max?, integer? } }`, bounds on each contribution, replacing the profile's for that metric), `rejectUnknownMetrics` (default `false`), `requireNostrSignature` (default `false`), `companionEvidence`, `allowSupersededCircleIds` (default `false`), `now` |
|
|
305
|
+
| `createDeploymentPolicy(profile, options)` | Required: `expectedSubject`, plus at least one active circle from `acceptedCircleIds` or `circleManifests`. Optional: `expectedSubjectTagValue`, `id` (default: the profile id), `maxAgeSeconds` and `minDistinctSigners` (default: the profile's), `metricPolicies` (`{ [metric]: { required?, min?, max?, integer? } }`, bounds on the published aggregate), `aggregate` (default: the profile's), `contributionBounds` (`{ [metric]: { min?, max?, integer?, required? } }`, bounds on each contribution, replacing the profile's for that metric), `rejectUnknownMetrics` (default `false`), `requireNostrSignature` (default `false`), `acceptedPublishers` (hex pubkeys that may sign the assertion events; naming any turns `requireNostrSignature` on), `companionEvidence`, `allowSupersededCircleIds` (default `false`), `now` |
|
|
306
306
|
| `createSignedDeploymentBundle(policy, options)` | Required: `id`, `issuedAt`, `privateKey` (hex). Optional: `expiresAt` (must be greater than `issuedAt`). Returns a frozen bundle carrying the `signer` pubkey and `signature` |
|
|
307
307
|
| `verifyUseCaseProfile(events, profile, options?)` | `acceptedCircleIds`, `aggregate`, `aggregateFn`, `contributionBounds`, `expectedSubject`, `expectedSubjectTagValue`, `maxAgeSeconds`, `minDistinctSigners`, `now`, `requireKnownCircle` (fails when no accepted circle is supplied unless set to `false`) |
|
|
308
308
|
| `verifyDeploymentPolicy(events, policy, options?)` | `aggregateFn`, `companionEvidence` (the supplied `CompanionEvidence[]`), `now` |
|
|
@@ -314,6 +314,8 @@ It returns `{ valid, circleSize, threshold, distinctSigners, subjectInRing, inde
|
|
|
314
314
|
|
|
315
315
|
Every built-in profile pins the aggregate function: `median`, and `sum` for `anonymous-group-decisions`, which also bounds each ballot to 0 or 1. The profile verifiers reject an event published under any other function (issue code `proof.aggregate_mismatch`) or holding a contribution outside the bounds (`proof.contribution_out_of_bounds`). To publish under another function, say so in the policy (`aggregate: 'mean'`) and bound each contribution. A custom profile sets `aggregate` and, per metric, `contribution: { min, max, integer }`; `validateUseCaseProfileDefinition` warns when either is missing. A signed bundle embeds the profile it was issued with, so a bundle issued by an earlier release does not carry these checks: re-issue it.
|
|
316
316
|
|
|
317
|
+
A proof does not say who published it, or when. The ring signatures are public and carry no time, so anyone can republish a favourable subset of them, or an old proof under a new `created_at`, with their own key; `maxAgeSeconds` reads the timestamp that key set. Where the circle has a designated publisher, name it: `acceptedPublishers: [aggregator.pubkey]` in `createDeploymentPolicy`. The policy then checks every event's Nostr signature and rejects an event signed by any other key (issue code `event.publisher_unaccepted`). `createDeploymentPolicy` throws on an empty or malformed list, and a policy read from a bundle with one rejects every event (`policy.accepted_publishers_invalid`). A named publisher is still trusted to include every signature it was given, and a relay can still serve that publisher's earlier event for as long as the freshness window allows. The list is not `trustedPublishers`, which names who may sign a deployment bundle. A verifier on an earlier release ignores the field in a bundle.
|
|
318
|
+
|
|
317
319
|
### Profiles example
|
|
318
320
|
|
|
319
321
|
A production verifier pins the operator's publisher pubkey, loads a signed deployment bundle, and checks fetched assertions against it. This continues from the quick start (`alice`, `bob`, `carol`, `circle`, `subjectPubkey`, `aggregator`). The built-in `USER_REPUTATION_ABUSE_REPORTING_PROFILE` (id `user-reputation-abuse-reporting`) requires proof v2, the median aggregate, at least three distinct signers, and an assertion no older than 300 seconds, so the contributions below are v2 and all three members sign.
|
|
@@ -341,7 +343,8 @@ const event = signEvent(
|
|
|
341
343
|
const policy = createDeploymentPolicy(USER_REPUTATION_ABUSE_REPORTING_PROFILE, {
|
|
342
344
|
acceptedCircleIds: [circle.circleId],
|
|
343
345
|
expectedSubject: subjectPubkey,
|
|
344
|
-
|
|
346
|
+
acceptedPublishers: [aggregator.pubkey], // nobody else may republish the circle's signatures
|
|
347
|
+
requireNostrSignature: true, // verifyProductionDeployment needs this; naming acceptedPublishers also turns it on
|
|
345
348
|
})
|
|
346
349
|
const now = Math.floor(Date.now() / 1000)
|
|
347
350
|
const bundle = createSignedDeploymentBundle(policy, {
|
|
@@ -356,7 +359,7 @@ const verdict = verifyProductionDeployment([event], bundle, { trustedPublishers:
|
|
|
356
359
|
// verdict.decision === 'accept', verdict.valid === true, verdict.errors === []
|
|
357
360
|
```
|
|
358
361
|
|
|
359
|
-
A bundle signed by any other key fails with the issue code `bundle.signer_untrusted`. For the other built-in profiles, companion evidence and the report helpers, see [examples/production-recipes.ts](./examples/production-recipes.ts), which runs six production-shaped gates (`npm run test:production-recipes`).
|
|
362
|
+
A bundle signed by any other key fails with the issue code `bundle.signer_untrusted`, and an event signed by any key but the aggregator's fails with `event.publisher_unaccepted`. For the other built-in profiles, companion evidence and the report helpers, see [examples/production-recipes.ts](./examples/production-recipes.ts), which runs six production-shaped gates (`npm run test:production-recipes`).
|
|
360
363
|
|
|
361
364
|
---
|
|
362
365
|
|
|
@@ -370,14 +373,14 @@ nostr-veil assert event <event-id> [--json '<metrics>']
|
|
|
370
373
|
nostr-veil assert address <address> [--json '<metrics>']
|
|
371
374
|
nostr-veil assert identifier <id> <k-tag> [--json '<metrics>']
|
|
372
375
|
nostr-veil provider-declare [--json '<entries>']
|
|
373
|
-
nostr-veil verify '<event-json>' [--kind <n>]
|
|
376
|
+
nostr-veil verify '<event-json>' [--kind <n>] [--aggregate <fn>]
|
|
374
377
|
nostr-veil --help
|
|
375
378
|
```
|
|
376
379
|
|
|
377
380
|
- `assert` builds a plain NIP-85 assertion (kind 30382, 30383, 30384 or 30385 respectively) and signs it with one key. It does not make ring signatures; use the library for that. `--json` takes a JSON object of metrics, for example `--json '{"rank":74}'`. Without it the metrics are empty.
|
|
378
381
|
- `provider-declare` builds and signs a kind 10040 provider declaration. `--json` takes a JSON array of `{ kind, metric, servicePubkey, relayHint }` entries.
|
|
379
382
|
- `assert` and `provider-declare` read the signing key from `NOSTR_SECRET_KEY` (64-char hex) or from the file named by `NOSTR_SECRET_KEY_FILE`, which takes precedence. They print the signed event as JSON on stdout, ready to pipe to a relay publisher.
|
|
380
|
-
- `verify` needs no key. `<event-json>` is the event itself as an inline JSON string, not a file path
|
|
383
|
+
- `verify` needs no key. `<event-json>` is the event itself as an inline JSON string, not a file path (for a file use `nostr-veil verify "$(cat event.json)" --kind 30382`). The event must be a JSON object with a `tags` array. `--kind <n>` takes a non-negative integer and applies the `expectedKind` check; it is recommended for v1 proofs. `--aggregate <fn>` takes `median`, `mean`, `sum`, `min` or `max` and applies the `requireAggregate` check. Without it `verify` accepts whichever function the event names, and the publisher chooses that, so the same signatures also verify as a `max` or a `min`. An option may come before or after the event, written `--kind 30382` or `--kind=30382`. An option `verify` does not know, or one given twice, is an error: both options make the check stricter, so a mistyped one is never dropped in silence.
|
|
381
384
|
- `verify` prints the `verifyProof` result as JSON. It exits 0 even when `valid` is `false`, and exits 1 only for bad arguments or unparseable JSON, so read the `valid` field rather than the exit code.
|
|
382
385
|
|
|
383
386
|
---
|
|
@@ -477,12 +480,16 @@ application control:
|
|
|
477
480
|
conflict rules for circles that drive real decisions.
|
|
478
481
|
- A shared federation `scope` intentionally reveals cross-circle overlap by key
|
|
479
482
|
image; use scoped federation only when deduplication is worth that signal.
|
|
480
|
-
- The publisher chooses the aggregate function
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
`
|
|
484
|
-
|
|
485
|
-
|
|
483
|
+
- The publisher chooses the aggregate function, which signatures to include and
|
|
484
|
+
the event's `created_at`. The circle signs none of the three, and the
|
|
485
|
+
signatures are public. Anyone can republish a subset of them, the same set as
|
|
486
|
+
a `max` or a `min`, or an old proof under a new timestamp, with their own key.
|
|
487
|
+
Pin the function with `requireAggregate` (the built-in profiles do), set the
|
|
488
|
+
signer threshold to a turnout that matters for the circle, and where the
|
|
489
|
+
circle has a designated publisher name its key in the deployment policy
|
|
490
|
+
(`acceptedPublishers`). A named publisher is still trusted to include every
|
|
491
|
+
signature, and a relay can still serve its earlier event for as long as the
|
|
492
|
+
freshness window allows.
|
|
486
493
|
- A key image stops a member contributing twice, not contributing one large
|
|
487
494
|
value. Under `sum`, `mean`, `min` or `max`, bound each contribution with
|
|
488
495
|
`contributionBounds`.
|
|
@@ -505,7 +512,8 @@ and rotated.
|
|
|
505
512
|
Production verifiers should prefer `verifyProductionDeployment()` over manually
|
|
506
513
|
composing lower-level checks. It returns the existing human-readable `errors`
|
|
507
514
|
plus stable `issues[].code` values such as `bundle.signer_untrusted`,
|
|
508
|
-
`event.signature_invalid`, `
|
|
515
|
+
`event.signature_invalid`, `event.publisher_unaccepted`, `circle.unaccepted`,
|
|
516
|
+
and `metric.below_min`. Use
|
|
509
517
|
`explainVerificationIssue()` or `remediationForIssue()` to show the exact
|
|
510
518
|
operator action for each failure. For application UI, audit logs, and support
|
|
511
519
|
runbooks, `verifyProductionDeploymentReport()` returns the same decision with a
|
package/bin/cli.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
buildProviderDeclaration,
|
|
11
11
|
} from '../dist/nip85/builders.js'
|
|
12
12
|
import { verifyProof } from '../dist/proof/verify.js'
|
|
13
|
+
import { AGGREGATES, isAggregateName } from '../dist/proof/aggregate.js'
|
|
13
14
|
|
|
14
15
|
const USAGE = `nostr-veil — anonymous trust assertions for Nostr
|
|
15
16
|
|
|
@@ -19,9 +20,14 @@ Usage:
|
|
|
19
20
|
nostr-veil assert address <address> [--json metrics] Build kind 30384 addressable assertion
|
|
20
21
|
nostr-veil assert identifier <id> <k-tag> [--json metrics] Build kind 30385 identifier assertion
|
|
21
22
|
nostr-veil provider-declare [--json entries] Build kind 10040 provider declaration
|
|
22
|
-
nostr-veil verify <event-json> [--kind n]
|
|
23
|
+
nostr-veil verify <event-json> [--kind n] [--aggregate fn]
|
|
24
|
+
Verify veil ring proof, print result
|
|
23
25
|
(--kind binds the expected NIP-85 kind; recommended
|
|
24
|
-
for v1 proofs, which are not kind-bound
|
|
26
|
+
for v1 proofs, which are not kind-bound.
|
|
27
|
+
--aggregate requires that aggregate function: median,
|
|
28
|
+
mean, sum, min or max. The publisher chooses it and
|
|
29
|
+
the circle does not sign it, so without the flag the
|
|
30
|
+
same signatures also verify as a max or a min)
|
|
25
31
|
nostr-veil --help Show this message
|
|
26
32
|
|
|
27
33
|
Environment:
|
|
@@ -105,29 +111,79 @@ function cmdProviderDeclare(args) {
|
|
|
105
111
|
console.log(JSON.stringify(signed, null, 2))
|
|
106
112
|
}
|
|
107
113
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
const VERIFY_OPTIONS = new Set(['--kind', '--aggregate'])
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Split verify's arguments into the event JSON and its options. Every argument
|
|
118
|
+
* has to be accounted for: both options make the check stricter, so one that
|
|
119
|
+
* was mistyped and dropped in silence would let the proof verify without the
|
|
120
|
+
* check the caller asked for. An option is `--name value` or `--name=value`,
|
|
121
|
+
* before or after the event.
|
|
122
|
+
*/
|
|
123
|
+
function parseVerifyArgs(args) {
|
|
124
|
+
const options = new Map()
|
|
125
|
+
const positionals = []
|
|
126
|
+
for (let i = 0; i < args.length; i++) {
|
|
127
|
+
const arg = args[i]
|
|
128
|
+
// An event is a JSON object, so nothing that starts with a dash is one
|
|
129
|
+
if (!arg.startsWith('-')) {
|
|
130
|
+
positionals.push(arg)
|
|
131
|
+
continue
|
|
132
|
+
}
|
|
133
|
+
const equals = arg.indexOf('=')
|
|
134
|
+
const name = equals === -1 ? arg : arg.slice(0, equals)
|
|
135
|
+
if (!VERIFY_OPTIONS.has(name)) {
|
|
136
|
+
console.error(`Error: unknown option ${name}. Run nostr-veil --help for usage.`)
|
|
137
|
+
process.exit(1)
|
|
138
|
+
}
|
|
139
|
+
if (options.has(name)) {
|
|
140
|
+
console.error(`Error: ${name} given more than once`)
|
|
141
|
+
process.exit(1)
|
|
142
|
+
}
|
|
143
|
+
// The value is undefined when the option came last with no value
|
|
144
|
+
options.set(name, equals === -1 ? args[++i] : arg.slice(equals + 1))
|
|
115
145
|
}
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
console.error(
|
|
146
|
+
|
|
147
|
+
if (positionals.length > 1) {
|
|
148
|
+
console.error(`Error: verify takes one <event-json>, not ${positionals.length}`)
|
|
119
149
|
process.exit(1)
|
|
120
150
|
}
|
|
121
|
-
|
|
151
|
+
|
|
152
|
+
let expectedKind
|
|
153
|
+
if (options.has('--kind')) {
|
|
154
|
+
const value = options.get('--kind')
|
|
155
|
+
if (value === undefined) {
|
|
156
|
+
console.error('Error: --kind requires a value')
|
|
157
|
+
process.exit(1)
|
|
158
|
+
}
|
|
159
|
+
// Decimal digits only: Number() also reads '', ' ', '0x10' and '3e4' as integers
|
|
160
|
+
if (!/^(0|[1-9]\d*)$/.test(value) || !Number.isSafeInteger(Number(value))) {
|
|
161
|
+
console.error('Error: --kind must be a non-negative integer')
|
|
162
|
+
process.exit(1)
|
|
163
|
+
}
|
|
164
|
+
expectedKind = Number(value)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
let requireAggregate
|
|
168
|
+
if (options.has('--aggregate')) {
|
|
169
|
+
const name = options.get('--aggregate')
|
|
170
|
+
if (name === undefined || !isAggregateName(name)) {
|
|
171
|
+
const names = Object.keys(AGGREGATES)
|
|
172
|
+
console.error(`Error: --aggregate must be one of ${names.slice(0, -1).join(', ')} or ${names.at(-1)}`)
|
|
173
|
+
process.exit(1)
|
|
174
|
+
}
|
|
175
|
+
requireAggregate = name
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return { eventJson: positionals[0], expectedKind, requireAggregate }
|
|
122
179
|
}
|
|
123
180
|
|
|
124
181
|
function cmdVerify(args) {
|
|
125
|
-
const eventJson = args
|
|
182
|
+
const { eventJson, expectedKind, requireAggregate } = parseVerifyArgs(args)
|
|
126
183
|
if (!eventJson) {
|
|
127
184
|
console.error('Error: verify requires <event-json>')
|
|
128
185
|
process.exit(1)
|
|
129
186
|
}
|
|
130
|
-
const expectedKind = extractKindFlag(args)
|
|
131
187
|
|
|
132
188
|
let event
|
|
133
189
|
try {
|
|
@@ -140,7 +196,12 @@ function cmdVerify(args) {
|
|
|
140
196
|
console.error('Error: event must be a JSON object with a "tags" array')
|
|
141
197
|
process.exit(1)
|
|
142
198
|
}
|
|
143
|
-
const
|
|
199
|
+
const options = {
|
|
200
|
+
...(expectedKind === undefined ? {} : { expectedKind }),
|
|
201
|
+
...(requireAggregate === undefined ? {} : { requireAggregate }),
|
|
202
|
+
}
|
|
203
|
+
// With neither flag the call is the same bare verifyProof(event) as before
|
|
204
|
+
const result = verifyProof(event, Object.keys(options).length === 0 ? undefined : options)
|
|
144
205
|
console.log(JSON.stringify(result, null, 2))
|
|
145
206
|
}
|
|
146
207
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type VerificationIssueCode = 'assertion.created_at_missing' | 'assertion.stale' | 'bundle.expired' | 'bundle.expires_at_invalid' | 'bundle.expiry_required' | 'bundle.id_invalid' | 'bundle.issued_at_future' | 'bundle.issued_at_invalid' | 'bundle.signature_invalid' | 'bundle.signature_malformed' | 'bundle.signer_invalid' | 'bundle.signer_untrusted' | 'bundle.trusted_publisher_invalid' | 'bundle.trusted_publishers_missing' | 'bundle.type_invalid' | 'bundle.version_invalid' | 'circle.accepted_invalid' | 'circle.accepted_missing' | 'circle.manifest_expired' | 'circle.manifest_invalid' | 'circle.profile_not_allowed' | 'circle.revoked' | 'circle.superseded' | 'circle.unaccepted' | 'companion.checked_at_future' | 'companion.checked_at_missing' | 'companion.failed' | 'companion.invalid' | 'companion.missing' | 'companion.stale' | 'companion.subject_mismatch' | 'event.signature_invalid' | 'event.signature_missing' | 'federation.invalid' | 'federation.threshold_not_met' | 'metric.above_max' | 'metric.below_min' | 'metric.integer_required' | 'metric.invalid_value' | 'metric.required_missing' | 'metric.unknown' | 'nip85.syntax_invalid' | 'policy.nostr_signature_not_required' | 'profile.event_count_invalid' | 'profile.kind_mismatch' | 'profile.subject_format_invalid' | 'profile.subject_hint_mismatch' | 'profile.subject_mismatch' | 'proof.aggregate_mismatch' | 'proof.contribution_out_of_bounds' | 'proof.invalid' | 'proof.threshold_not_met' | 'verification.failed';
|
|
1
|
+
export type VerificationIssueCode = 'assertion.created_at_missing' | 'assertion.stale' | 'bundle.expired' | 'bundle.expires_at_invalid' | 'bundle.expiry_required' | 'bundle.id_invalid' | 'bundle.issued_at_future' | 'bundle.issued_at_invalid' | 'bundle.signature_invalid' | 'bundle.signature_malformed' | 'bundle.signer_invalid' | 'bundle.signer_untrusted' | 'bundle.trusted_publisher_invalid' | 'bundle.trusted_publishers_missing' | 'bundle.type_invalid' | 'bundle.version_invalid' | 'circle.accepted_invalid' | 'circle.accepted_missing' | 'circle.manifest_expired' | 'circle.manifest_invalid' | 'circle.profile_not_allowed' | 'circle.revoked' | 'circle.superseded' | 'circle.unaccepted' | 'companion.checked_at_future' | 'companion.checked_at_missing' | 'companion.failed' | 'companion.invalid' | 'companion.missing' | 'companion.stale' | 'companion.subject_mismatch' | 'event.publisher_unaccepted' | 'event.signature_invalid' | 'event.signature_missing' | 'federation.invalid' | 'federation.threshold_not_met' | 'metric.above_max' | 'metric.below_min' | 'metric.integer_required' | 'metric.invalid_value' | 'metric.required_missing' | 'metric.unknown' | 'nip85.syntax_invalid' | 'policy.accepted_publishers_invalid' | 'policy.nostr_signature_not_required' | 'profile.event_count_invalid' | 'profile.kind_mismatch' | 'profile.subject_format_invalid' | 'profile.subject_hint_mismatch' | 'profile.subject_mismatch' | 'proof.aggregate_mismatch' | 'proof.contribution_out_of_bounds' | 'proof.invalid' | 'proof.threshold_not_met' | 'verification.failed';
|
|
2
2
|
export interface VerificationIssue {
|
|
3
3
|
code: VerificationIssueCode;
|
|
4
4
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../../src/profiles/issues.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,8BAA8B,GAC9B,iBAAiB,GACjB,gBAAgB,GAChB,2BAA2B,GAC3B,wBAAwB,GACxB,mBAAmB,GACnB,yBAAyB,GACzB,0BAA0B,GAC1B,0BAA0B,GAC1B,4BAA4B,GAC5B,uBAAuB,GACvB,yBAAyB,GACzB,kCAAkC,GAClC,mCAAmC,GACnC,qBAAqB,GACrB,wBAAwB,GACxB,yBAAyB,GACzB,yBAAyB,GACzB,yBAAyB,GACzB,yBAAyB,GACzB,4BAA4B,GAC5B,gBAAgB,GAChB,mBAAmB,GACnB,mBAAmB,GACnB,6BAA6B,GAC7B,8BAA8B,GAC9B,kBAAkB,GAClB,mBAAmB,GACnB,mBAAmB,GACnB,iBAAiB,GACjB,4BAA4B,GAC5B,yBAAyB,GACzB,yBAAyB,GACzB,oBAAoB,GACpB,8BAA8B,GAC9B,kBAAkB,GAClB,kBAAkB,GAClB,yBAAyB,GACzB,sBAAsB,GACtB,yBAAyB,GACzB,gBAAgB,GAChB,sBAAsB,GACtB,qCAAqC,GACrC,6BAA6B,GAC7B,uBAAuB,GACvB,gCAAgC,GAChC,+BAA+B,GAC/B,0BAA0B,GAC1B,0BAA0B,GAC1B,kCAAkC,GAClC,eAAe,GACf,yBAAyB,GACzB,qBAAqB,CAAA;AAEzB,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,qBAAqB,CAAA;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,eAAe,GACf,iBAAiB,GACjB,mBAAmB,CAAA;AAEvB,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,qBAAqB,CAAA;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,uBAAuB,CAAA;CAChC;
|
|
1
|
+
{"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../../src/profiles/issues.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,8BAA8B,GAC9B,iBAAiB,GACjB,gBAAgB,GAChB,2BAA2B,GAC3B,wBAAwB,GACxB,mBAAmB,GACnB,yBAAyB,GACzB,0BAA0B,GAC1B,0BAA0B,GAC1B,4BAA4B,GAC5B,uBAAuB,GACvB,yBAAyB,GACzB,kCAAkC,GAClC,mCAAmC,GACnC,qBAAqB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,EAAE,MAAM,GAAG,iBAAiB,CAE5E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,iBAAiB,EAAE,CAE/E;AAED,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,iBAAiB,GAAG,qBAAqB,GACrD,4BAA4B,CAG9B;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,iBAAiB,GAAG,qBAAqB,GAAG,MAAM,CAElG"}
|
package/dist/profiles/issues.js
CHANGED
|
@@ -33,6 +33,7 @@ const VERIFICATION_ISSUE_EXPLANATION_INPUTS = {
|
|
|
33
33
|
'companion.missing': explanation('A required companion evidence check was not supplied.', 'Run the external resolver, provenance, SBOM, service, or list-revision check required by the deployment policy and pass the result to the verifier.', 'operator-action'),
|
|
34
34
|
'companion.stale': explanation('A companion evidence check is outside its freshness window.', 'Refresh the external package, domain, service, or list evidence before accepting the score.', 'refresh-and-retry'),
|
|
35
35
|
'companion.subject_mismatch': explanation('A companion evidence check was run against a different subject.', 'Run the external check against the same canonical subject used by the NIP-85 assertion.'),
|
|
36
|
+
'event.publisher_unaccepted': explanation('The assertion was published by a key the deployment policy does not accept.', 'Reject it. A proof\'s ring signatures are public and carry no time, so anyone can republish a subset of them, or an old proof under a new timestamp, with their own key. Fetch the assertion from an accepted publisher, or add the key to acceptedPublishers only through explicit governance.'),
|
|
36
37
|
'event.signature_invalid': explanation('The fetched Nostr event id or signature is invalid.', 'Reject the event, fetch it again from another relay if useful, and do not verify or act on mutated event data.'),
|
|
37
38
|
'event.signature_missing': explanation('The verifier expected a fully signed Nostr event but received an unsigned template.', 'Sign assertions before publishing and require relay-fetched events to include id, pubkey, created_at, and sig.'),
|
|
38
39
|
'federation.invalid': explanation('The federated proof set failed federation validation.', 'Ensure all events share the expected subject and scope, then verify only complete events from accepted circles.'),
|
|
@@ -44,6 +45,7 @@ const VERIFICATION_ISSUE_EXPLANATION_INPUTS = {
|
|
|
44
45
|
'metric.required_missing': explanation('A required metric is missing from the assertion.', 'Require the aggregate assertion to include the metric named in the deployment policy before acting on it.', 'manual-review'),
|
|
45
46
|
'metric.unknown': explanation('The assertion contains a metric not allowed by the deployment policy.', 'Reject unknown metrics or update the policy after reviewing the metric meaning and bounds.', 'manual-review'),
|
|
46
47
|
'nip85.syntax_invalid': explanation('The event does not pass NIP-85 syntax validation.', 'Reject the event and publish it again with the correct kind, tags, subject hint, and metric tag shape.'),
|
|
48
|
+
'policy.accepted_publishers_invalid': explanation('The deployment policy names accepted publishers, but the list is empty or malformed.', 'Re-issue the policy with acceptedPublishers as one or more 64-character lowercase hex pubkeys. Every assertion is rejected until then.', 'operator-action'),
|
|
47
49
|
'policy.nostr_signature_not_required': explanation('The production bundle policy would allow unsigned relay events.', 'Set requireNostrSignature: true in createDeploymentPolicy() for production relay-fetched assertions.', 'operator-action'),
|
|
48
50
|
'profile.event_count_invalid': explanation('The number of events does not match the selected profile.', 'Pass exactly one event for single-assertion profiles, or the complete scoped event set for federation profiles.', 'operator-action'),
|
|
49
51
|
'profile.kind_mismatch': explanation('The event kind does not match the selected profile.', 'Route the event to the matching NIP-85 profile, or rebuild the assertion with the profile-required kind.'),
|
|
@@ -51,7 +53,7 @@ const VERIFICATION_ISSUE_EXPLANATION_INPUTS = {
|
|
|
51
53
|
'profile.subject_hint_mismatch': explanation('The subject hint tag value does not match the profile policy.', 'Use the expected p, e, a, or k tag value and require proof v2 for workflows that rely on subject binding.'),
|
|
52
54
|
'profile.subject_mismatch': explanation('The assertion is about a different subject than the deployment expected.', 'Reject it and verify only assertions whose subject equals the canonical expectedSubject.'),
|
|
53
55
|
'proof.aggregate_mismatch': explanation('The assertion was published with a different aggregate function from the one the profile or policy requires.', 'Reject it. The publisher chooses the veil-agg tag, so the same signatures can be republished as a max or a min; fetch the assertion published with the expected aggregate, or change the policy aggregate only through explicit governance.'),
|
|
54
|
-
'proof.contribution_out_of_bounds': explanation('A contribution carries a value outside the bounds the profile or policy sets for one member.', 'Reject it. The aggregator should leave that contribution out and publish again; contributionBoundViolations() finds it before aggregating.'),
|
|
56
|
+
'proof.contribution_out_of_bounds': explanation('A contribution carries a value outside the bounds the profile or policy sets for one member, or leaves out a metric those bounds require.', 'Reject it. The aggregator should leave that contribution out and publish again; contributionBoundViolations() finds it before aggregating.'),
|
|
55
57
|
'proof.invalid': explanation('The nostr-veil ring proof is invalid.', 'Reject the assertion; collect a new aggregate from the circle rather than trying to repair proof tags.'),
|
|
56
58
|
'proof.threshold_not_met': explanation('The proof has fewer distinct signers than the deployment requires.', 'Collect more valid contributions from the circle or change the threshold only through explicit governance.', 'manual-review'),
|
|
57
59
|
'verification.failed': explanation('Verification failed with an unclassified error.', 'Reject by default, inspect result.errors, and add a more specific issue mapping if this becomes a supported failure mode.', 'manual-review'),
|
|
@@ -71,7 +73,7 @@ function pathFromMessage(message) {
|
|
|
71
73
|
const metric = message.match(/^(event\[\d+\]) metric "([^"]+)"/u);
|
|
72
74
|
if (metric !== null)
|
|
73
75
|
return `${metric[1]}.tags.${metric[2]}`;
|
|
74
|
-
const path = message.match(/^(event\[\d+\]|manifest\[\d+\]|trustedPublishers\[\d+\])/u)?.[1];
|
|
76
|
+
const path = message.match(/^(event\[\d+\]|manifest\[\d+\]|trustedPublishers\[\d+\]|acceptedPublishers\[\d+\])/u)?.[1];
|
|
75
77
|
if (path !== undefined)
|
|
76
78
|
return path;
|
|
77
79
|
return undefined;
|
|
@@ -128,6 +130,14 @@ function codeFromError(message) {
|
|
|
128
130
|
return 'event.signature_missing';
|
|
129
131
|
if (lower.includes('nostr event signature is invalid'))
|
|
130
132
|
return 'event.signature_invalid';
|
|
133
|
+
// Matched against the whole message, not a fragment: the syntax, proof and
|
|
134
|
+
// metric messages below quote tag names taken from the event, and an event
|
|
135
|
+
// must not be able to name its way into either of these codes
|
|
136
|
+
if (/^event\[\d+\] publisher is not accepted by deployment policy$/u.test(message)) {
|
|
137
|
+
return 'event.publisher_unaccepted';
|
|
138
|
+
}
|
|
139
|
+
if (/^acceptedPublishers(\[\d+\])? must be /u.test(message))
|
|
140
|
+
return 'policy.accepted_publishers_invalid';
|
|
131
141
|
if (lower.includes('no accepted circle ids were supplied'))
|
|
132
142
|
return 'circle.accepted_missing';
|
|
133
143
|
if (lower.includes('acceptedcircleids'))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issues.js","sourceRoot":"","sources":["../../src/profiles/issues.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"issues.js","sourceRoot":"","sources":["../../src/profiles/issues.ts"],"names":[],"mappings":"AA8EA,SAAS,WAAW,CAClB,OAAe,EACf,WAAmB,EACnB,SAAkC,QAAQ;IAE1C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAA;AACzC,CAAC;AAED,MAAM,qCAAqC,GAAG;IAC5C,8BAA8B,EAAE,WAAW,CACzC,kDAAkD,EAClD,kGAAkG,CACnG;IACD,iBAAiB,EAAE,WAAW,CAC5B,2DAA2D,EAC3D,8IAA8I,EAC9I,mBAAmB,CACpB;IACD,gBAAgB,EAAE,WAAW,CAC3B,2CAA2C,EAC3C,8GAA8G,EAC9G,mBAAmB,CACpB;IACD,2BAA2B,EAAE,WAAW,CACtC,0CAA0C,EAC1C,6EAA6E,EAC7E,iBAAiB,CAClB;IACD,wBAAwB,EAAE,WAAW,CACnC,4DAA4D,EAC5D,iGAAiG,EACjG,iBAAiB,CAClB;IACD,mBAAmB,EAAE,WAAW,CAC9B,wCAAwC,EACxC,uEAAuE,EACvE,iBAAiB,CAClB;IACD,yBAAyB,EAAE,WAAW,CACpC,mEAAmE,EACnE,6EAA6E,EAC7E,mBAAmB,CACpB;IACD,0BAA0B,EAAE,WAAW,CACrC,yCAAyC,EACzC,8DAA8D,EAC9D,iBAAiB,CAClB;IACD,0BAA0B,EAAE,WAAW,CACrC,sFAAsF,EACtF,8GAA8G,CAC/G;IACD,4BAA4B,EAAE,WAAW,CACvC,iEAAiE,EACjE,0FAA0F,EAC1F,iBAA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
|
45
45
|
acceptedCircleIds?: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* Accept assertion events only from these publisher keys: the pubkeys that
|
|
48
|
+
* sign the outer Nostr event, as 64-character lowercase hex. Naming them
|
|
49
|
+
* turns `requireNostrSignature` on, because an unsigned event has no
|
|
50
|
+
* publisher.
|
|
51
|
+
*
|
|
52
|
+
* A proof's ring signatures are public and carry no time. Without this list
|
|
53
|
+
* anyone can republish a favourable subset of them, or an old proof under a
|
|
54
|
+
* new `created_at`, with their own key. The list stops a third party doing
|
|
55
|
+
* that. It does not stop a named publisher leaving signatures out, or a
|
|
56
|
+
* relay serving that publisher's earlier event.
|
|
57
|
+
*
|
|
58
|
+
* Not the same as `trustedPublishers`, which names who may sign a
|
|
59
|
+
* deployment bundle.
|
|
60
|
+
*/
|
|
61
|
+
acceptedPublishers?: readonly string[];
|
|
46
62
|
/**
|
|
47
63
|
* Require this aggregate function in place of the one the profile pins. Use
|
|
48
64
|
* it when the deployment publishes with `mean`, say, under a built-in profile
|
|
@@ -76,6 +92,8 @@ export interface CreateDeploymentPolicyOptions {
|
|
|
76
92
|
}
|
|
77
93
|
export interface UseCaseDeploymentPolicy {
|
|
78
94
|
acceptedCircleIds: readonly string[];
|
|
95
|
+
/** Present only when the deployment names the keys that may publish its assertions. */
|
|
96
|
+
acceptedPublishers?: readonly string[];
|
|
79
97
|
/** Present only when the deployment overrides the aggregate the profile pins. */
|
|
80
98
|
aggregate?: AggregateTagValue;
|
|
81
99
|
allowSupersededCircleIds: boolean;
|
|
@@ -109,6 +127,15 @@ export interface DeploymentPolicyVerification {
|
|
|
109
127
|
valid: boolean;
|
|
110
128
|
};
|
|
111
129
|
policy: UseCaseDeploymentPolicy;
|
|
130
|
+
/**
|
|
131
|
+
* `checked` is true when the policy names its accepted publishers. `valid`
|
|
132
|
+
* is then true only if every event carries a sound Nostr signature from one
|
|
133
|
+
* of them.
|
|
134
|
+
*/
|
|
135
|
+
publishers: {
|
|
136
|
+
checked: boolean;
|
|
137
|
+
valid: boolean;
|
|
138
|
+
};
|
|
112
139
|
profileVerification: UseCaseProfileVerification;
|
|
113
140
|
revokedCircleIds: string[];
|
|
114
141
|
supersededCircleIds: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/profiles/policy.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAqB,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE9G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAI5E,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEpD,MAAM,WAAW,sBAAsB;IACrC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4DAA4D;IAC5D,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,4DAA4D;IAC5D,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,MAAM,CAAA;AAErD,MAAM,WAAW,4BAA4B;IAC3C,oFAAoF;IACpF,EAAE,EAAE,MAAM,CAAA;IACV,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oEAAoE;IACpE,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,qFAAqF;IACrF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC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mBAAmB,EAAE,MAAM,EAAE,CAAA;IAC7B,KAAK,EAAE,OAAO,CAAA;CACf;AA8MD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,6BAA6B,GACrC,uBAAuB,CAiDzB;AA0ND,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,GAAG,SAAS,aAAa,EAAE,EAChD,MAAM,EAAE,uBAAuB,EAC/B,OAAO,GAAE,6BAAkC,GAC1C,4BAA4B,CA8C9B"}
|
package/dist/profiles/policy.js
CHANGED
|
@@ -89,6 +89,39 @@ function assertHex64(value, label) {
|
|
|
89
89
|
throw new Error(`${label} must be a 64-character lowercase hex string`);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Problems with a list of accepted publisher keys. Used when a policy is
|
|
94
|
+
* created and again when one is verified, because a policy inside a signed
|
|
95
|
+
* bundle arrives as JSON and nothing has checked its shape.
|
|
96
|
+
*/
|
|
97
|
+
function acceptedPublisherProblems(publishers) {
|
|
98
|
+
if (!Array.isArray(publishers) || publishers.length === 0) {
|
|
99
|
+
return ['acceptedPublishers must be a list of at least one publisher key'];
|
|
100
|
+
}
|
|
101
|
+
const problems = [];
|
|
102
|
+
// By index: forEach would skip the holes of a sparse list
|
|
103
|
+
for (let index = 0; index < publishers.length; index++) {
|
|
104
|
+
const publisher = publishers[index];
|
|
105
|
+
if (typeof publisher !== 'string' || !/^[0-9a-f]{64}$/.test(publisher)) {
|
|
106
|
+
problems.push(`acceptedPublishers[${index}] must be a 64-character lowercase hex string`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return problems;
|
|
110
|
+
}
|
|
111
|
+
function checkedAcceptedPublishers(publishers) {
|
|
112
|
+
if (publishers === undefined)
|
|
113
|
+
return undefined;
|
|
114
|
+
const problems = acceptedPublisherProblems(publishers);
|
|
115
|
+
if (problems.length > 0)
|
|
116
|
+
throw new Error(problems.join('; '));
|
|
117
|
+
const seen = new Set();
|
|
118
|
+
for (const [index, publisher] of publishers.entries()) {
|
|
119
|
+
if (seen.has(publisher))
|
|
120
|
+
throw new Error(`acceptedPublishers[${index}] is duplicated`);
|
|
121
|
+
seen.add(publisher);
|
|
122
|
+
}
|
|
123
|
+
return Object.freeze([...publishers]);
|
|
124
|
+
}
|
|
92
125
|
function acceptedCircleIds(ids) {
|
|
93
126
|
if (ids.length === 0) {
|
|
94
127
|
throw new Error('acceptedCircleIds must contain at least one circle id');
|
|
@@ -163,8 +196,13 @@ export function createDeploymentPolicy(profile, options) {
|
|
|
163
196
|
const companionEvidence = cloneCompanionEvidenceRequirements(options.companionEvidence);
|
|
164
197
|
const aggregate = checkedAggregate(options.aggregate);
|
|
165
198
|
const contributionBounds = cloneContributionBounds(options.contributionBounds);
|
|
199
|
+
const acceptedPublishers = checkedAcceptedPublishers(options.acceptedPublishers);
|
|
200
|
+
if (acceptedPublishers !== undefined && options.requireNostrSignature === false) {
|
|
201
|
+
throw new Error('requireNostrSignature cannot be false when acceptedPublishers is set: an unsigned event has no publisher');
|
|
202
|
+
}
|
|
166
203
|
return Object.freeze({
|
|
167
204
|
acceptedCircleIds: rawCircleIds,
|
|
205
|
+
...(acceptedPublishers === undefined ? {} : { acceptedPublishers }),
|
|
168
206
|
...(aggregate === undefined ? {} : { aggregate }),
|
|
169
207
|
allowSupersededCircleIds,
|
|
170
208
|
circleManifests,
|
|
@@ -178,7 +216,7 @@ export function createDeploymentPolicy(profile, options) {
|
|
|
178
216
|
minDistinctSigners,
|
|
179
217
|
profile,
|
|
180
218
|
rejectUnknownMetrics: options.rejectUnknownMetrics ?? false,
|
|
181
|
-
requireNostrSignature: options.requireNostrSignature ?? false,
|
|
219
|
+
requireNostrSignature: acceptedPublishers !== undefined || (options.requireNostrSignature ?? false),
|
|
182
220
|
});
|
|
183
221
|
}
|
|
184
222
|
function cloneCompanionEvidence(evidence) {
|
|
@@ -316,21 +354,53 @@ function isSignedEvent(event) {
|
|
|
316
354
|
&& typeof candidate.sig === 'string'
|
|
317
355
|
&& typeof candidate.created_at === 'number';
|
|
318
356
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
357
|
+
/**
|
|
358
|
+
* Check each event's Nostr signature and, where the policy names its
|
|
359
|
+
* publishers, that one of them signed it.
|
|
360
|
+
*
|
|
361
|
+
* Naming publishers forces the signature check whatever
|
|
362
|
+
* `requireNostrSignature` says: the `pubkey` field of an unsigned event is a
|
|
363
|
+
* claim anyone can make. `verifySignedEvent` recomputes the event id from the
|
|
364
|
+
* event body, so a named publisher's id and signature cannot be moved onto
|
|
365
|
+
* other tags.
|
|
366
|
+
*/
|
|
367
|
+
function verifyPublishers(events, policy) {
|
|
368
|
+
const listed = policy.acceptedPublishers;
|
|
369
|
+
const named = listed !== undefined;
|
|
370
|
+
if (!named && !policy.requireNostrSignature) {
|
|
371
|
+
return {
|
|
372
|
+
errors: [],
|
|
373
|
+
nostrSignatures: { checked: false, valid: true },
|
|
374
|
+
publishers: { checked: false, valid: true },
|
|
375
|
+
};
|
|
322
376
|
}
|
|
323
|
-
|
|
377
|
+
// A malformed list accepts nobody. It never falls back to accepting anyone.
|
|
378
|
+
const listProblems = named ? acceptedPublisherProblems(listed) : [];
|
|
379
|
+
const accepted = named && listProblems.length === 0 ? new Set(listed) : undefined;
|
|
380
|
+
const errors = [...listProblems];
|
|
381
|
+
let signaturesValid = true;
|
|
382
|
+
let publishersAccepted = listProblems.length === 0;
|
|
324
383
|
for (const [index, event] of events.entries()) {
|
|
325
384
|
if (!isSignedEvent(event)) {
|
|
326
385
|
errors.push(`event[${index}] is not a fully signed Nostr event`);
|
|
386
|
+
signaturesValid = false;
|
|
327
387
|
continue;
|
|
328
388
|
}
|
|
329
389
|
if (!verifySignedEvent(event)) {
|
|
330
390
|
errors.push(`event[${index}] Nostr event signature is invalid`);
|
|
391
|
+
signaturesValid = false;
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (accepted !== undefined && !accepted.has(event.pubkey)) {
|
|
395
|
+
errors.push(`event[${index}] publisher is not accepted by deployment policy`);
|
|
396
|
+
publishersAccepted = false;
|
|
331
397
|
}
|
|
332
398
|
}
|
|
333
|
-
return {
|
|
399
|
+
return {
|
|
400
|
+
errors,
|
|
401
|
+
nostrSignatures: { checked: true, valid: signaturesValid },
|
|
402
|
+
publishers: { checked: named, valid: !named || (signaturesValid && publishersAccepted) },
|
|
403
|
+
};
|
|
334
404
|
}
|
|
335
405
|
export function verifyDeploymentPolicy(events, policy, options = {}) {
|
|
336
406
|
const eventList = normaliseEvents(events);
|
|
@@ -348,13 +418,13 @@ export function verifyDeploymentPolicy(events, policy, options = {}) {
|
|
|
348
418
|
});
|
|
349
419
|
const metricVerification = verifyMetricPolicies(eventList, policy);
|
|
350
420
|
const companionEvidence = verifyCompanionEvidence(policy, options);
|
|
351
|
-
const
|
|
421
|
+
const publisherVerification = verifyPublishers(eventList, policy);
|
|
352
422
|
const errors = [
|
|
353
423
|
...circleResolution.errors,
|
|
354
424
|
...profileVerification.errors,
|
|
355
425
|
...metricVerification.errors,
|
|
356
426
|
...companionEvidence.errors,
|
|
357
|
-
...
|
|
427
|
+
...publisherVerification.errors,
|
|
358
428
|
];
|
|
359
429
|
const valid = errors.length === 0;
|
|
360
430
|
return {
|
|
@@ -363,12 +433,10 @@ export function verifyDeploymentPolicy(events, policy, options = {}) {
|
|
|
363
433
|
errors,
|
|
364
434
|
issues: issuesFromErrors(errors),
|
|
365
435
|
metrics: metricVerification.metrics,
|
|
366
|
-
nostrSignatures:
|
|
367
|
-
checked: nostrSignatures.checked,
|
|
368
|
-
valid: nostrSignatures.valid,
|
|
369
|
-
},
|
|
436
|
+
nostrSignatures: publisherVerification.nostrSignatures,
|
|
370
437
|
policy,
|
|
371
438
|
profileVerification,
|
|
439
|
+
publishers: publisherVerification.publishers,
|
|
372
440
|
revokedCircleIds: circleResolution.revokedCircleIds,
|
|
373
441
|
supersededCircleIds: circleResolution.supersededCircleIds,
|
|
374
442
|
valid,
|