nostr-veil 0.14.0 → 0.15.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 +42 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/profiles/canonical.d.ts +22 -0
- package/dist/profiles/canonical.d.ts.map +1 -0
- package/dist/profiles/canonical.js +169 -0
- package/dist/profiles/canonical.js.map +1 -0
- package/dist/profiles/index.d.ts +5 -0
- package/dist/profiles/index.d.ts.map +1 -0
- package/dist/profiles/index.js +5 -0
- package/dist/profiles/index.js.map +1 -0
- package/dist/profiles/profiles.d.ts +19 -0
- package/dist/profiles/profiles.d.ts.map +1 -0
- package/dist/profiles/profiles.js +263 -0
- package/dist/profiles/profiles.js.map +1 -0
- package/dist/profiles/types.d.ts +54 -0
- package/dist/profiles/types.d.ts.map +1 -0
- package/dist/profiles/types.js +2 -0
- package/dist/profiles/types.js.map +1 -0
- package/dist/profiles/verify.d.ts +4 -0
- package/dist/profiles/verify.d.ts.map +1 -0
- package/dist/profiles/verify.js +148 -0
- package/dist/profiles/verify.js.map +1 -0
- package/llms-full.txt +31 -0
- package/llms.txt +25 -0
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -158,6 +158,16 @@ The resulting `assertion` is a plain `EventTemplate` you sign and publish like a
|
|
|
158
158
|
| `canonicalMessageV2(circleId, subject, metrics, context)` | Compute the opt-in v2 canonical message that binds kind and subject hint tag |
|
|
159
159
|
| `computeCircleId(sortedPubkeys)` | Compute the deterministic circle ID (SHA-256 of colon-joined pubkeys) |
|
|
160
160
|
|
|
161
|
+
### `nostr-veil/profiles` -- safer deployment profiles
|
|
162
|
+
|
|
163
|
+
| Export | Description |
|
|
164
|
+
|--------|-------------|
|
|
165
|
+
| `USE_CASE_PROFILES` | Built-in machine-readable profiles for the documented use cases |
|
|
166
|
+
| `USE_CASE_PROFILE_BY_ID` | Lookup table keyed by use-case slug |
|
|
167
|
+
| `verifyUseCaseProfile(events, profile, options)` | Verify NIP-85 syntax, proof v2, subject binding, threshold, freshness, accepted circles, and federation policy |
|
|
168
|
+
| `canonicalRelaySubject`, `canonicalNip05Subject`, `canonicalDomainSubject`, `canonicalNpmPackageSubject` | Canonical subject helpers for common real-world identifiers |
|
|
169
|
+
| `canonicalPubkeySubject`, `canonicalEventSubject`, `canonicalAddressSubject` | Canonical subject helpers for Nostr-native subjects |
|
|
170
|
+
|
|
161
171
|
### Signing utility (root export)
|
|
162
172
|
|
|
163
173
|
| Export | Description |
|
|
@@ -227,34 +237,48 @@ nostr-veil is a privacy layer for already-defined trust circles. It gives you:
|
|
|
227
237
|
- Optional semantic binding: proof v2 binds the assertion kind and subject hint tag into the signed message and election ID.
|
|
228
238
|
- Standard NIP-85 output: non-veil clients can still read the aggregate score.
|
|
229
239
|
|
|
230
|
-
|
|
240
|
+
The boundary is deliberately narrow. Pair each limitation with the right
|
|
241
|
+
application control:
|
|
231
242
|
|
|
232
|
-
-
|
|
233
|
-
|
|
234
|
-
-
|
|
235
|
-
|
|
236
|
-
-
|
|
243
|
+
- The ring membership list is public; use a cover set large enough for the risk
|
|
244
|
+
and avoid circles that reveal vulnerable participants by membership alone.
|
|
245
|
+
- Anonymous metric values are public so anyone can recompute the aggregate;
|
|
246
|
+
publish only metrics your workflow is comfortable exposing.
|
|
247
|
+
- Network, timing, relay, and collector metadata are outside the proof; use
|
|
248
|
+
batching, transport privacy, and careful logging for sensitive collection.
|
|
249
|
+
- Circle quality is social policy; publish admission, rotation, Sybil, and
|
|
250
|
+
conflict rules for circles that drive real decisions.
|
|
251
|
+
- A shared federation `scope` intentionally reveals cross-circle overlap by key
|
|
252
|
+
image; use scoped federation only when deduplication is worth that signal.
|
|
237
253
|
|
|
238
|
-
For sensitive deployments, combine nostr-veil with careful collection,
|
|
254
|
+
For sensitive deployments, combine nostr-veil with careful collection,
|
|
255
|
+
transport privacy, key hygiene, and a clear policy for how circles are admitted
|
|
256
|
+
and rotated.
|
|
239
257
|
|
|
240
258
|
---
|
|
241
259
|
|
|
242
260
|
## Use cases
|
|
243
261
|
|
|
244
|
-
The shipped primitives support more than user trust scores
|
|
262
|
+
The shipped primitives support more than user trust scores. See
|
|
263
|
+
[docs/use-cases.md](./docs/use-cases.md) for the implementation field guide:
|
|
264
|
+
one worked page per use case, subject formats, helper functions, metrics,
|
|
265
|
+
proof-v2 verification, and the operational controls needed beyond the proof.
|
|
266
|
+
|
|
267
|
+
Supported today:
|
|
245
268
|
|
|
246
269
|
- User reputation and abuse reporting with kind 30382 user assertions.
|
|
247
|
-
- Source corroboration and peer review
|
|
270
|
+
- Source corroboration and peer review, using kind 30382 for pubkeys or kind 30385 for external identifiers.
|
|
248
271
|
- Event and claim verification with kind 30383 event assertions via `aggregateEventContributions`.
|
|
249
|
-
- Article, long-form note,
|
|
250
|
-
- Relay, service, vendor, marketplace,
|
|
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.
|
|
272
|
+
- Article, long-form note, research, grant, and proposal review with kind 30384 addressable assertions via `aggregateAddressableContributions`.
|
|
273
|
+
- Relay, service, vendor, marketplace, package, release, maintainer, NIP-05, and domain reputation with kind 30385 identifier assertions via `aggregateIdentifierContributions`.
|
|
253
274
|
- Community list, labeler, and moderation-list reputation where users can compare curation sources without mapping every reviewer.
|
|
254
275
|
- Federated moderation where scoped circles count overlapping contributors once, not once per circle.
|
|
255
276
|
- Privacy-preserving onboarding where an already-trusted circle can vouch for a new account without naming the individual vouchees.
|
|
256
|
-
|
|
257
|
-
|
|
277
|
+
|
|
278
|
+
Future profiles:
|
|
279
|
+
|
|
280
|
+
- Anonymous credential or attestation co-signing, once endorsement event formats define subject, expiry, revocation, and presentation rules.
|
|
281
|
+
- Relay or community admission, once a gated-access handshake exists; today nostr-veil can publish the threshold-backed assertion, but it is not the whole anonymous access-control protocol.
|
|
258
282
|
|
|
259
283
|
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
284
|
|
|
@@ -272,6 +296,8 @@ const circleA = createTrustCircle(membersA, { scope: 'community-moderators' })
|
|
|
272
296
|
const circleB = createTrustCircle(membersB, { scope: 'community-moderators' })
|
|
273
297
|
```
|
|
274
298
|
|
|
299
|
+
Scopes are lowercase slugs: letters, digits, dot, hyphen, and underscore.
|
|
300
|
+
|
|
275
301
|
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
302
|
|
|
277
303
|
```ts
|
|
@@ -307,6 +333,7 @@ Each project is independently maintained and published. nostr-veil focuses solel
|
|
|
307
333
|
## Further reading
|
|
308
334
|
|
|
309
335
|
- [IMPACT.md](./IMPACT.md) -- Problem statement and ecosystem impact
|
|
336
|
+
- [docs/use-cases.md](./docs/use-cases.md) -- Concrete implementation map with individual worked use-case pages
|
|
310
337
|
- [CONTRIBUTING.md](./CONTRIBUTING.md) -- Setup, testing, and PR guidelines
|
|
311
338
|
- [SECURITY.md](./SECURITY.md) -- Vulnerability reporting and cryptographic scope
|
|
312
339
|
- [llms.txt](./llms.txt) -- Machine-readable project summary for LLMs
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SubjectFormat } from './types.js';
|
|
2
|
+
/** Canonical 64-char lowercase hex pubkey subject. */
|
|
3
|
+
export declare function canonicalPubkeySubject(pubkey: string): string;
|
|
4
|
+
/** Canonical 64-char lowercase hex event id subject. */
|
|
5
|
+
export declare function canonicalEventSubject(eventId: string): string;
|
|
6
|
+
/** Canonical NIP-33 address subject: `kind:pubkey:d-tag`. */
|
|
7
|
+
export declare function canonicalAddressSubject(kind: number | string, pubkey: string, dTag: string): string;
|
|
8
|
+
/** Canonical relay identifier subject: `relay:wss://host[/path]`. */
|
|
9
|
+
export declare function canonicalRelaySubject(relay: string): string;
|
|
10
|
+
/** Canonical NIP-05 identifier subject. Domain is lowercased; local part is preserved. */
|
|
11
|
+
export declare function canonicalNip05Subject(identifier: string): string;
|
|
12
|
+
/** Canonical domain identifier subject: `domain:example.com`. */
|
|
13
|
+
export declare function canonicalDomainSubject(domain: string): string;
|
|
14
|
+
/** Canonical npm package release subject: `npm:package@version`. */
|
|
15
|
+
export declare function canonicalNpmPackageSubject(name: string, version: string): string;
|
|
16
|
+
/** Canonical vendor identifier subject scoped to a marketplace hostname. */
|
|
17
|
+
export declare function canonicalVendorSubject(marketplace: string, vendorId: string): string;
|
|
18
|
+
/** Canonical source identifier subject scoped to an application namespace. */
|
|
19
|
+
export declare function canonicalSourceSubject(namespace: string, sourceId: string): string;
|
|
20
|
+
export declare function subjectMatchesFormat(subject: string, format: SubjectFormat): boolean;
|
|
21
|
+
export declare function subjectMatchesAnyFormat(subject: string, formats: SubjectFormat[]): boolean;
|
|
22
|
+
//# sourceMappingURL=canonical.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../src/profiles/canonical.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAuC/C,sDAAsD;AACtD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,wDAAwD;AACxD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,6DAA6D;AAC7D,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAOnG;AAED,qEAAqE;AACrE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY3D;AAED,0FAA0F;AAC1F,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAOhE;AAED,iEAAiE;AACjE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAM7D;AAED,oEAAoE;AACpE,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAQhF;AAED,4EAA4E;AAC5E,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpF;AAED,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMlF;AAwCD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAsBpF;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,OAAO,CAE1F"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
const HEX64_RE = /^[0-9a-f]{64}$/;
|
|
2
|
+
const ADDRESS_RE = /^(0|[1-9]\d*):[0-9a-f]{64}:.+$/;
|
|
3
|
+
const DECIMAL_KIND_RE = /^(0|[1-9]\d*)$/;
|
|
4
|
+
const PACKAGE_RE = /^npm:(?:@[a-z0-9_.-]+\/)?[a-z0-9_.-]+@[^@\s]+$/;
|
|
5
|
+
function trimRequired(value, label) {
|
|
6
|
+
const trimmed = value.trim();
|
|
7
|
+
if (trimmed === '')
|
|
8
|
+
throw new Error(`${label} must be non-empty`);
|
|
9
|
+
return trimmed;
|
|
10
|
+
}
|
|
11
|
+
function trimNoWhitespace(value, label) {
|
|
12
|
+
const trimmed = trimRequired(value, label);
|
|
13
|
+
if (/\s/.test(trimmed))
|
|
14
|
+
throw new Error(`${label} must not contain whitespace`);
|
|
15
|
+
return trimmed;
|
|
16
|
+
}
|
|
17
|
+
function assertHex64(value, label) {
|
|
18
|
+
const normalised = trimRequired(value, label).toLowerCase();
|
|
19
|
+
if (!HEX64_RE.test(normalised)) {
|
|
20
|
+
throw new Error(`${label} must be a 64-character lowercase hex string`);
|
|
21
|
+
}
|
|
22
|
+
return normalised;
|
|
23
|
+
}
|
|
24
|
+
function stripPrefix(value, prefix) {
|
|
25
|
+
return value.toLowerCase().startsWith(prefix) ? value.slice(prefix.length) : value;
|
|
26
|
+
}
|
|
27
|
+
function normaliseHostname(value) {
|
|
28
|
+
const hostname = value.trim().toLowerCase().replace(/\.$/, '');
|
|
29
|
+
if (hostname === '' || hostname.includes('..') || /\s/.test(hostname)) {
|
|
30
|
+
throw new Error('domain must be a non-empty hostname');
|
|
31
|
+
}
|
|
32
|
+
return hostname;
|
|
33
|
+
}
|
|
34
|
+
/** Canonical 64-char lowercase hex pubkey subject. */
|
|
35
|
+
export function canonicalPubkeySubject(pubkey) {
|
|
36
|
+
return assertHex64(pubkey, 'pubkey');
|
|
37
|
+
}
|
|
38
|
+
/** Canonical 64-char lowercase hex event id subject. */
|
|
39
|
+
export function canonicalEventSubject(eventId) {
|
|
40
|
+
return assertHex64(eventId, 'event id');
|
|
41
|
+
}
|
|
42
|
+
/** Canonical NIP-33 address subject: `kind:pubkey:d-tag`. */
|
|
43
|
+
export function canonicalAddressSubject(kind, pubkey, dTag) {
|
|
44
|
+
const kindText = String(kind);
|
|
45
|
+
if (!DECIMAL_KIND_RE.test(kindText)) {
|
|
46
|
+
throw new Error('address kind must be a decimal kind number');
|
|
47
|
+
}
|
|
48
|
+
const identifier = trimRequired(dTag, 'd-tag');
|
|
49
|
+
return `${kindText}:${canonicalPubkeySubject(pubkey)}:${identifier}`;
|
|
50
|
+
}
|
|
51
|
+
/** Canonical relay identifier subject: `relay:wss://host[/path]`. */
|
|
52
|
+
export function canonicalRelaySubject(relay) {
|
|
53
|
+
const raw = stripPrefix(trimRequired(relay, 'relay'), 'relay:');
|
|
54
|
+
const url = new URL(raw);
|
|
55
|
+
if (url.protocol !== 'wss:' && url.protocol !== 'ws:') {
|
|
56
|
+
throw new Error('relay subject must use ws:// or wss://');
|
|
57
|
+
}
|
|
58
|
+
url.protocol = url.protocol.toLowerCase();
|
|
59
|
+
url.hostname = normaliseHostname(url.hostname);
|
|
60
|
+
url.hash = '';
|
|
61
|
+
if (url.pathname === '/')
|
|
62
|
+
url.pathname = '';
|
|
63
|
+
const serialised = url.toString();
|
|
64
|
+
return `relay:${serialised.endsWith('/') && url.search === '' ? serialised.slice(0, -1) : serialised}`;
|
|
65
|
+
}
|
|
66
|
+
/** Canonical NIP-05 identifier subject. Domain is lowercased; local part is preserved. */
|
|
67
|
+
export function canonicalNip05Subject(identifier) {
|
|
68
|
+
const raw = stripPrefix(trimRequired(identifier, 'nip05 identifier'), 'nip05:');
|
|
69
|
+
const [name, domain, ...extra] = raw.split('@');
|
|
70
|
+
if (name === '' || domain === undefined || domain === '' || extra.length > 0 || /\s/.test(raw)) {
|
|
71
|
+
throw new Error('NIP-05 subject must be name@domain');
|
|
72
|
+
}
|
|
73
|
+
return `nip05:${name}@${normaliseHostname(domain)}`;
|
|
74
|
+
}
|
|
75
|
+
/** Canonical domain identifier subject: `domain:example.com`. */
|
|
76
|
+
export function canonicalDomainSubject(domain) {
|
|
77
|
+
const raw = stripPrefix(trimRequired(domain, 'domain'), 'domain:');
|
|
78
|
+
const hostname = raw.includes('://')
|
|
79
|
+
? new URL(raw).hostname
|
|
80
|
+
: raw;
|
|
81
|
+
return `domain:${normaliseHostname(hostname)}`;
|
|
82
|
+
}
|
|
83
|
+
/** Canonical npm package release subject: `npm:package@version`. */
|
|
84
|
+
export function canonicalNpmPackageSubject(name, version) {
|
|
85
|
+
const packageName = trimRequired(name, 'package name').toLowerCase();
|
|
86
|
+
const packageVersion = trimRequired(version, 'package version');
|
|
87
|
+
const subject = `npm:${packageName}@${packageVersion}`;
|
|
88
|
+
if (!PACKAGE_RE.test(subject)) {
|
|
89
|
+
throw new Error('npm package subject must be npm:package@version');
|
|
90
|
+
}
|
|
91
|
+
return subject;
|
|
92
|
+
}
|
|
93
|
+
/** Canonical vendor identifier subject scoped to a marketplace hostname. */
|
|
94
|
+
export function canonicalVendorSubject(marketplace, vendorId) {
|
|
95
|
+
return `vendor:${normaliseHostname(marketplace)}:${trimNoWhitespace(vendorId, 'vendor id')}`;
|
|
96
|
+
}
|
|
97
|
+
/** Canonical source identifier subject scoped to an application namespace. */
|
|
98
|
+
export function canonicalSourceSubject(namespace, sourceId) {
|
|
99
|
+
const ns = trimRequired(namespace, 'source namespace').toLowerCase();
|
|
100
|
+
if (!/^[a-z0-9._-]+$/.test(ns)) {
|
|
101
|
+
throw new Error('source namespace must be a lowercase slug');
|
|
102
|
+
}
|
|
103
|
+
return `source:${ns}:${trimNoWhitespace(sourceId, 'source id')}`;
|
|
104
|
+
}
|
|
105
|
+
function canonicalNpmPackageSubjectFromSubject(subject) {
|
|
106
|
+
if (!subject.startsWith('npm:'))
|
|
107
|
+
throw new Error('npm package subject must start with npm:');
|
|
108
|
+
const spec = subject.slice('npm:'.length);
|
|
109
|
+
const versionSeparator = spec.lastIndexOf('@');
|
|
110
|
+
if (versionSeparator <= 0 || versionSeparator === spec.length - 1) {
|
|
111
|
+
throw new Error('npm package subject must be npm:package@version');
|
|
112
|
+
}
|
|
113
|
+
return canonicalNpmPackageSubject(spec.slice(0, versionSeparator), spec.slice(versionSeparator + 1));
|
|
114
|
+
}
|
|
115
|
+
function canonicalVendorSubjectFromSubject(subject) {
|
|
116
|
+
if (!subject.startsWith('vendor:'))
|
|
117
|
+
throw new Error('vendor subject must start with vendor:');
|
|
118
|
+
const rest = subject.slice('vendor:'.length);
|
|
119
|
+
const separator = rest.indexOf(':');
|
|
120
|
+
if (separator <= 0 || separator === rest.length - 1) {
|
|
121
|
+
throw new Error('vendor subject must be vendor:marketplace:vendor-id');
|
|
122
|
+
}
|
|
123
|
+
return canonicalVendorSubject(rest.slice(0, separator), rest.slice(separator + 1));
|
|
124
|
+
}
|
|
125
|
+
function canonicalSourceSubjectFromSubject(subject) {
|
|
126
|
+
if (!subject.startsWith('source:'))
|
|
127
|
+
throw new Error('source subject must start with source:');
|
|
128
|
+
const rest = subject.slice('source:'.length);
|
|
129
|
+
const separator = rest.indexOf(':');
|
|
130
|
+
if (separator <= 0 || separator === rest.length - 1) {
|
|
131
|
+
throw new Error('source subject must be source:namespace:source-id');
|
|
132
|
+
}
|
|
133
|
+
return canonicalSourceSubject(rest.slice(0, separator), rest.slice(separator + 1));
|
|
134
|
+
}
|
|
135
|
+
function matchesCanonical(subject, canonicalise) {
|
|
136
|
+
try {
|
|
137
|
+
return canonicalise(subject) === subject;
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export function subjectMatchesFormat(subject, format) {
|
|
144
|
+
switch (format) {
|
|
145
|
+
case 'pubkey':
|
|
146
|
+
case 'event':
|
|
147
|
+
return HEX64_RE.test(subject);
|
|
148
|
+
case 'address':
|
|
149
|
+
return ADDRESS_RE.test(subject);
|
|
150
|
+
case 'identifier':
|
|
151
|
+
return subject.trim() !== '';
|
|
152
|
+
case 'relay':
|
|
153
|
+
return matchesCanonical(subject, canonicalRelaySubject);
|
|
154
|
+
case 'nip05':
|
|
155
|
+
return matchesCanonical(subject, canonicalNip05Subject);
|
|
156
|
+
case 'domain':
|
|
157
|
+
return matchesCanonical(subject, canonicalDomainSubject);
|
|
158
|
+
case 'package':
|
|
159
|
+
return matchesCanonical(subject, canonicalNpmPackageSubjectFromSubject);
|
|
160
|
+
case 'vendor':
|
|
161
|
+
return matchesCanonical(subject, canonicalVendorSubjectFromSubject);
|
|
162
|
+
case 'source':
|
|
163
|
+
return matchesCanonical(subject, canonicalSourceSubjectFromSubject);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export function subjectMatchesAnyFormat(subject, formats) {
|
|
167
|
+
return formats.some(format => subjectMatchesFormat(subject, format));
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=canonical.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical.js","sourceRoot":"","sources":["../../src/profiles/canonical.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG,gBAAgB,CAAA;AACjC,MAAM,UAAU,GAAG,gCAAgC,CAAA;AACnD,MAAM,eAAe,GAAG,gBAAgB,CAAA;AACxC,MAAM,UAAU,GAAG,gDAAgD,CAAA;AAEnE,SAAS,YAAY,CAAC,KAAa,EAAE,KAAa;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC5B,IAAI,OAAO,KAAK,EAAE;QAAE,M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Q;YACX,OAAO,gBAAgB,CAAC,OAAO,EAAE,iCAAiC,CAAC,CAAA;QACrE,KAAK,QAAQ;YACX,OAAO,gBAAgB,CAAC,OAAO,EAAE,iCAAiC,CAAC,CAAA;IACvE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAe,EAAE,OAAwB;IAC/E,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;AACtE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/profiles/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/profiles/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { UseCaseProfile } from './types.js';
|
|
2
|
+
export declare const USER_REPUTATION_ABUSE_REPORTING_PROFILE: UseCaseProfile;
|
|
3
|
+
export declare const PRIVACY_PRESERVING_ONBOARDING_PROFILE: UseCaseProfile;
|
|
4
|
+
export declare const SOURCE_CORROBORATION_PROFILE: UseCaseProfile;
|
|
5
|
+
export declare const EVENT_CLAIM_VERIFICATION_PROFILE: UseCaseProfile;
|
|
6
|
+
export declare const ARTICLE_RESEARCH_REVIEW_PROFILE: UseCaseProfile;
|
|
7
|
+
export declare const RELAY_SERVICE_REPUTATION_PROFILE: UseCaseProfile;
|
|
8
|
+
export declare const NIP05_DOMAIN_SERVICE_PROVIDER_TRUST_PROFILE: UseCaseProfile;
|
|
9
|
+
export declare const LIST_LABELER_MODERATION_LIST_REPUTATION_PROFILE: UseCaseProfile;
|
|
10
|
+
export declare const RELEASE_PACKAGE_MAINTAINER_REPUTATION_PROFILE: UseCaseProfile;
|
|
11
|
+
export declare const VENDOR_MARKETPLACE_SIGNALS_PROFILE: UseCaseProfile;
|
|
12
|
+
export declare const FEDERATED_MODERATION_PROFILE: UseCaseProfile;
|
|
13
|
+
export declare const GRANT_FUNDING_PROPOSAL_REVIEW_PROFILE: UseCaseProfile;
|
|
14
|
+
export declare const ANONYMOUS_CREDENTIAL_ATTESTATION_COSIGNING_PROFILE: UseCaseProfile;
|
|
15
|
+
export declare const RELAY_COMMUNITY_ADMISSION_PROFILE: UseCaseProfile;
|
|
16
|
+
export declare const USE_CASE_PROFILES: readonly [UseCaseProfile, UseCaseProfile, UseCaseProfile, UseCaseProfile, UseCaseProfile, UseCaseProfile, UseCaseProfile, UseCaseProfile, UseCaseProfile, UseCaseProfile, UseCaseProfile, UseCaseProfile, UseCaseProfile, UseCaseProfile];
|
|
17
|
+
export declare const USE_CASE_PROFILE_BY_ID: Readonly<Record<string, UseCaseProfile | undefined>>;
|
|
18
|
+
export declare function getUseCaseProfile(id: string): UseCaseProfile | undefined;
|
|
19
|
+
//# sourceMappingURL=profiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/profiles/profiles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,YAAY,CAAA;AA+B/D,eAAO,MAAM,uCAAuC,gBAalD,CAAA;AAEF,eAAO,MAAM,qCAAqC,gBAahD,CAAA;AAEF,eAAO,MAAM,4BAA4B,gBAcvC,CAAA;AAEF,eAAO,MAAM,gCAAgC,gBAa3C,CAAA;AAEF,eAAO,MAAM,+BAA+B,gBAa1C,CAAA;AAEF,eAAO,MAAM,gCAAgC,gBAc3C,CAAA;AAEF,eAAO,MAAM,2CAA2C,gBActD,CAAA;AAEF,eAAO,MAAM,+CAA+C,gBAa1D,CAAA;AAEF,eAAO,MAAM,6CAA6C,gBAiBxD,CAAA;AAEF,eAAO,MAAM,kCAAkC,gBAc7C,CAAA;AAEF,eAAO,MAAM,4BAA4B,gBAoBvC,CAAA;AAEF,eAAO,MAAM,qCAAqC,gBAahD,CAAA;AAEF,eAAO,MAAM,kDAAkD,gBAgB7D,CAAA;AAEF,eAAO,MAAM,iCAAiC,gBAgB5C,CAAA;AAEF,eAAO,MAAM,iBAAiB,2OAegB,CAAA;AAE9C,eAAO,MAAM,sBAAsB,EAE9B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC,CAAC,CAAA;AAEzD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAExE"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { NIP85_KINDS } from '../nip85/types.js';
|
|
2
|
+
const rankMetric = {
|
|
3
|
+
name: 'rank',
|
|
4
|
+
meaning: 'Application-defined confidence score from 0 to 100.',
|
|
5
|
+
direction: 'higher-is-better',
|
|
6
|
+
};
|
|
7
|
+
const reactionMetric = {
|
|
8
|
+
name: 'reaction_cnt',
|
|
9
|
+
meaning: 'Count-like corroborating interaction signal.',
|
|
10
|
+
direction: 'count',
|
|
11
|
+
};
|
|
12
|
+
const reportMetric = {
|
|
13
|
+
name: 'reports_cnt_recd',
|
|
14
|
+
meaning: 'Count of received reports included in the signed reviewer signal.',
|
|
15
|
+
direction: 'count',
|
|
16
|
+
};
|
|
17
|
+
function profile(profile) {
|
|
18
|
+
return profile;
|
|
19
|
+
}
|
|
20
|
+
const commonFailurePolicy = [
|
|
21
|
+
'Reject malformed NIP-85 events and invalid nostr-veil proofs.',
|
|
22
|
+
'Reject stale assertions outside the application freshness window.',
|
|
23
|
+
'Reject assertions from circles that are not accepted by the deployment policy.',
|
|
24
|
+
'Treat the score as a threshold signal, not as proof that the underlying real-world claim is true.',
|
|
25
|
+
];
|
|
26
|
+
export const USER_REPUTATION_ABUSE_REPORTING_PROFILE = profile({
|
|
27
|
+
id: 'user-reputation-abuse-reporting',
|
|
28
|
+
title: 'User reputation and abuse reporting',
|
|
29
|
+
group: 'People',
|
|
30
|
+
status: 'supported',
|
|
31
|
+
kind: NIP85_KINDS.USER,
|
|
32
|
+
subjectTag: 'p',
|
|
33
|
+
subjectFormats: ['pubkey'],
|
|
34
|
+
proofVersion: 'v2',
|
|
35
|
+
minDistinctSigners: 3,
|
|
36
|
+
maxAgeSeconds: 300,
|
|
37
|
+
metrics: [rankMetric, reportMetric],
|
|
38
|
+
failurePolicy: commonFailurePolicy,
|
|
39
|
+
});
|
|
40
|
+
export const PRIVACY_PRESERVING_ONBOARDING_PROFILE = profile({
|
|
41
|
+
id: 'privacy-preserving-onboarding',
|
|
42
|
+
title: 'Privacy-preserving onboarding',
|
|
43
|
+
group: 'People',
|
|
44
|
+
status: 'supported',
|
|
45
|
+
kind: NIP85_KINDS.USER,
|
|
46
|
+
subjectTag: 'p',
|
|
47
|
+
subjectFormats: ['pubkey'],
|
|
48
|
+
proofVersion: 'v2',
|
|
49
|
+
minDistinctSigners: 3,
|
|
50
|
+
maxAgeSeconds: 300,
|
|
51
|
+
metrics: [rankMetric],
|
|
52
|
+
failurePolicy: commonFailurePolicy,
|
|
53
|
+
});
|
|
54
|
+
export const SOURCE_CORROBORATION_PROFILE = profile({
|
|
55
|
+
id: 'source-corroboration',
|
|
56
|
+
title: 'Source corroboration',
|
|
57
|
+
group: 'Content',
|
|
58
|
+
status: 'supported',
|
|
59
|
+
kind: NIP85_KINDS.IDENTIFIER,
|
|
60
|
+
subjectTag: 'k',
|
|
61
|
+
subjectTagValue: '0',
|
|
62
|
+
subjectFormats: ['source'],
|
|
63
|
+
proofVersion: 'v2',
|
|
64
|
+
minDistinctSigners: 3,
|
|
65
|
+
maxAgeSeconds: 300,
|
|
66
|
+
metrics: [rankMetric],
|
|
67
|
+
failurePolicy: commonFailurePolicy,
|
|
68
|
+
});
|
|
69
|
+
export const EVENT_CLAIM_VERIFICATION_PROFILE = profile({
|
|
70
|
+
id: 'event-claim-verification',
|
|
71
|
+
title: 'Event and claim verification',
|
|
72
|
+
group: 'Content',
|
|
73
|
+
status: 'supported',
|
|
74
|
+
kind: NIP85_KINDS.EVENT,
|
|
75
|
+
subjectTag: 'e',
|
|
76
|
+
subjectFormats: ['event'],
|
|
77
|
+
proofVersion: 'v2',
|
|
78
|
+
minDistinctSigners: 3,
|
|
79
|
+
maxAgeSeconds: 300,
|
|
80
|
+
metrics: [rankMetric, reactionMetric],
|
|
81
|
+
failurePolicy: commonFailurePolicy,
|
|
82
|
+
});
|
|
83
|
+
export const ARTICLE_RESEARCH_REVIEW_PROFILE = profile({
|
|
84
|
+
id: 'article-research-review',
|
|
85
|
+
title: 'Article, research, and long-form review',
|
|
86
|
+
group: 'Content',
|
|
87
|
+
status: 'supported',
|
|
88
|
+
kind: NIP85_KINDS.ADDRESSABLE,
|
|
89
|
+
subjectTag: 'a',
|
|
90
|
+
subjectFormats: ['address'],
|
|
91
|
+
proofVersion: 'v2',
|
|
92
|
+
minDistinctSigners: 3,
|
|
93
|
+
maxAgeSeconds: 300,
|
|
94
|
+
metrics: [rankMetric, reactionMetric],
|
|
95
|
+
failurePolicy: commonFailurePolicy,
|
|
96
|
+
});
|
|
97
|
+
export const RELAY_SERVICE_REPUTATION_PROFILE = profile({
|
|
98
|
+
id: 'relay-service-reputation',
|
|
99
|
+
title: 'Relay and service reputation',
|
|
100
|
+
group: 'Infrastructure',
|
|
101
|
+
status: 'supported',
|
|
102
|
+
kind: NIP85_KINDS.IDENTIFIER,
|
|
103
|
+
subjectTag: 'k',
|
|
104
|
+
subjectTagValue: '10002',
|
|
105
|
+
subjectFormats: ['relay'],
|
|
106
|
+
proofVersion: 'v2',
|
|
107
|
+
minDistinctSigners: 3,
|
|
108
|
+
maxAgeSeconds: 300,
|
|
109
|
+
metrics: [rankMetric, reactionMetric],
|
|
110
|
+
failurePolicy: commonFailurePolicy,
|
|
111
|
+
});
|
|
112
|
+
export const NIP05_DOMAIN_SERVICE_PROVIDER_TRUST_PROFILE = profile({
|
|
113
|
+
id: 'nip05-domain-service-provider-trust',
|
|
114
|
+
title: 'NIP-05, domain, and service-provider trust',
|
|
115
|
+
group: 'Infrastructure',
|
|
116
|
+
status: 'supported',
|
|
117
|
+
kind: NIP85_KINDS.IDENTIFIER,
|
|
118
|
+
subjectTag: 'k',
|
|
119
|
+
subjectTagValue: '0',
|
|
120
|
+
subjectFormats: ['nip05', 'domain'],
|
|
121
|
+
proofVersion: 'v2',
|
|
122
|
+
minDistinctSigners: 3,
|
|
123
|
+
maxAgeSeconds: 300,
|
|
124
|
+
metrics: [rankMetric],
|
|
125
|
+
failurePolicy: commonFailurePolicy,
|
|
126
|
+
});
|
|
127
|
+
export const LIST_LABELER_MODERATION_LIST_REPUTATION_PROFILE = profile({
|
|
128
|
+
id: 'list-labeler-moderation-list-reputation',
|
|
129
|
+
title: 'Community list, labeler, and moderation-list reputation',
|
|
130
|
+
group: 'Infrastructure',
|
|
131
|
+
status: 'supported',
|
|
132
|
+
kind: NIP85_KINDS.ADDRESSABLE,
|
|
133
|
+
subjectTag: 'a',
|
|
134
|
+
subjectFormats: ['address'],
|
|
135
|
+
proofVersion: 'v2',
|
|
136
|
+
minDistinctSigners: 3,
|
|
137
|
+
maxAgeSeconds: 300,
|
|
138
|
+
metrics: [rankMetric],
|
|
139
|
+
failurePolicy: commonFailurePolicy,
|
|
140
|
+
});
|
|
141
|
+
export const RELEASE_PACKAGE_MAINTAINER_REPUTATION_PROFILE = profile({
|
|
142
|
+
id: 'release-package-maintainer-reputation',
|
|
143
|
+
title: 'Release, package, and maintainer reputation',
|
|
144
|
+
group: 'Infrastructure',
|
|
145
|
+
status: 'supported',
|
|
146
|
+
kind: NIP85_KINDS.IDENTIFIER,
|
|
147
|
+
subjectTag: 'k',
|
|
148
|
+
subjectTagValue: '0',
|
|
149
|
+
subjectFormats: ['package'],
|
|
150
|
+
proofVersion: 'v2',
|
|
151
|
+
minDistinctSigners: 3,
|
|
152
|
+
maxAgeSeconds: 300,
|
|
153
|
+
metrics: [rankMetric],
|
|
154
|
+
failurePolicy: [
|
|
155
|
+
...commonFailurePolicy,
|
|
156
|
+
'Do not treat the score as a package scan, SBOM, provenance, or reproducible-build proof.',
|
|
157
|
+
],
|
|
158
|
+
});
|
|
159
|
+
export const VENDOR_MARKETPLACE_SIGNALS_PROFILE = profile({
|
|
160
|
+
id: 'vendor-marketplace-signals',
|
|
161
|
+
title: 'Vendor and marketplace signals',
|
|
162
|
+
group: 'Markets',
|
|
163
|
+
status: 'supported',
|
|
164
|
+
kind: NIP85_KINDS.IDENTIFIER,
|
|
165
|
+
subjectTag: 'k',
|
|
166
|
+
subjectTagValue: '0',
|
|
167
|
+
subjectFormats: ['vendor'],
|
|
168
|
+
proofVersion: 'v2',
|
|
169
|
+
minDistinctSigners: 3,
|
|
170
|
+
maxAgeSeconds: 300,
|
|
171
|
+
metrics: [rankMetric, reactionMetric],
|
|
172
|
+
failurePolicy: commonFailurePolicy,
|
|
173
|
+
});
|
|
174
|
+
export const FEDERATED_MODERATION_PROFILE = profile({
|
|
175
|
+
id: 'federated-moderation',
|
|
176
|
+
title: 'Federated moderation',
|
|
177
|
+
group: 'Governance',
|
|
178
|
+
status: 'supported',
|
|
179
|
+
kind: NIP85_KINDS.USER,
|
|
180
|
+
subjectTag: 'p',
|
|
181
|
+
subjectFormats: ['pubkey'],
|
|
182
|
+
proofVersion: 'v2',
|
|
183
|
+
minDistinctSigners: 4,
|
|
184
|
+
maxAgeSeconds: 300,
|
|
185
|
+
metrics: [rankMetric, reportMetric],
|
|
186
|
+
federation: {
|
|
187
|
+
minCircles: 2,
|
|
188
|
+
requireScope: true,
|
|
189
|
+
},
|
|
190
|
+
failurePolicy: [
|
|
191
|
+
...commonFailurePolicy,
|
|
192
|
+
'Reject federations that mix subjects, scopes, or unscoped events.',
|
|
193
|
+
],
|
|
194
|
+
});
|
|
195
|
+
export const GRANT_FUNDING_PROPOSAL_REVIEW_PROFILE = profile({
|
|
196
|
+
id: 'grant-funding-proposal-review',
|
|
197
|
+
title: 'Grant, funding, and proposal review',
|
|
198
|
+
group: 'Governance',
|
|
199
|
+
status: 'supported',
|
|
200
|
+
kind: NIP85_KINDS.ADDRESSABLE,
|
|
201
|
+
subjectTag: 'a',
|
|
202
|
+
subjectFormats: ['address'],
|
|
203
|
+
proofVersion: 'v2',
|
|
204
|
+
minDistinctSigners: 3,
|
|
205
|
+
maxAgeSeconds: 300,
|
|
206
|
+
metrics: [rankMetric],
|
|
207
|
+
failurePolicy: commonFailurePolicy,
|
|
208
|
+
});
|
|
209
|
+
export const ANONYMOUS_CREDENTIAL_ATTESTATION_COSIGNING_PROFILE = profile({
|
|
210
|
+
id: 'anonymous-credential-attestation-cosigning',
|
|
211
|
+
title: 'Anonymous credential or attestation co-signing',
|
|
212
|
+
group: 'Future profiles',
|
|
213
|
+
status: 'profile-needed',
|
|
214
|
+
kind: NIP85_KINDS.EVENT,
|
|
215
|
+
subjectTag: 'e',
|
|
216
|
+
subjectFormats: ['event'],
|
|
217
|
+
proofVersion: 'v2',
|
|
218
|
+
minDistinctSigners: 3,
|
|
219
|
+
maxAgeSeconds: 300,
|
|
220
|
+
metrics: [rankMetric],
|
|
221
|
+
failurePolicy: [
|
|
222
|
+
...commonFailurePolicy,
|
|
223
|
+
'Treat this as today\'s proof building block until the credential endorsement profile is final.',
|
|
224
|
+
],
|
|
225
|
+
});
|
|
226
|
+
export const RELAY_COMMUNITY_ADMISSION_PROFILE = profile({
|
|
227
|
+
id: 'relay-community-admission',
|
|
228
|
+
title: 'Relay or community admission',
|
|
229
|
+
group: 'Future profiles',
|
|
230
|
+
status: 'profile-needed',
|
|
231
|
+
kind: NIP85_KINDS.USER,
|
|
232
|
+
subjectTag: 'p',
|
|
233
|
+
subjectFormats: ['pubkey'],
|
|
234
|
+
proofVersion: 'v2',
|
|
235
|
+
minDistinctSigners: 3,
|
|
236
|
+
maxAgeSeconds: 300,
|
|
237
|
+
metrics: [rankMetric],
|
|
238
|
+
failurePolicy: [
|
|
239
|
+
...commonFailurePolicy,
|
|
240
|
+
'Treat this as an admission signal, not as the complete access-control protocol.',
|
|
241
|
+
],
|
|
242
|
+
});
|
|
243
|
+
export const USE_CASE_PROFILES = [
|
|
244
|
+
USER_REPUTATION_ABUSE_REPORTING_PROFILE,
|
|
245
|
+
PRIVACY_PRESERVING_ONBOARDING_PROFILE,
|
|
246
|
+
SOURCE_CORROBORATION_PROFILE,
|
|
247
|
+
EVENT_CLAIM_VERIFICATION_PROFILE,
|
|
248
|
+
ARTICLE_RESEARCH_REVIEW_PROFILE,
|
|
249
|
+
RELAY_SERVICE_REPUTATION_PROFILE,
|
|
250
|
+
NIP05_DOMAIN_SERVICE_PROVIDER_TRUST_PROFILE,
|
|
251
|
+
LIST_LABELER_MODERATION_LIST_REPUTATION_PROFILE,
|
|
252
|
+
RELEASE_PACKAGE_MAINTAINER_REPUTATION_PROFILE,
|
|
253
|
+
VENDOR_MARKETPLACE_SIGNALS_PROFILE,
|
|
254
|
+
FEDERATED_MODERATION_PROFILE,
|
|
255
|
+
GRANT_FUNDING_PROPOSAL_REVIEW_PROFILE,
|
|
256
|
+
ANONYMOUS_CREDENTIAL_ATTESTATION_COSIGNING_PROFILE,
|
|
257
|
+
RELAY_COMMUNITY_ADMISSION_PROFILE,
|
|
258
|
+
];
|
|
259
|
+
export const USE_CASE_PROFILE_BY_ID = Object.freeze(Object.fromEntries(USE_CASE_PROFILES.map(profile => [profile.id, profile])));
|
|
260
|
+
export function getUseCaseProfile(id) {
|
|
261
|
+
return USE_CASE_PROFILE_BY_ID[id];
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=profiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../src/profiles/profiles.ts"],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QACb,GAAG,mBAAmB;QACtB,gGAAgG;KACjG;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,OAAO,CAAC;IACvD,EAAE,EAAE,2BAA2B;IAC/B,KAAK,EAAE,8BAA8B;IACrC,KAAK,EAAE,iBAAiB;IACxB,MAAM,EAAE,gBAAgB;IACxB,IAAI,EAAE,WAAW,CAAC,IAAI;IACtB,UAAU,EAAE,GAAG;IACf,cAAc,EAAE,CAAC,QAAQ,CAAC;IAC1B,YAAY,EAAE,IAAI;IAClB,kBAAkB,EAAE,CAAC;IACrB,aAAa,EAAE,GAAG;IAClB,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,aAAa,EAAE;QACb,GAAG,mBAAmB;QACtB,iFAAiF;KAClF;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,uCAAuC;IACvC,qCAAqC;IACrC,4BAA4B;IAC5B,gCAAgC;IAChC,+BAA+B;IAC/B,gCAAgC;IAChC,2CAA2C;IAC3C,+CAA+C;IAC/C,6CAA6C;IAC7C,kCAAkC;IAClC,4BAA4B;IAC5B,qCAAqC;IACrC,kDAAkD;IAClD,iCAAiC;CACW,CAAA;AAE9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CACjD,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CACpB,CAAA;AAEzD,MAAM,UAAU,iBAAiB,CAAC,EAAU;IAC1C,OAAO,sBAAsB,CAAC,EAAE,CAAC,CAAA;AACnC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { EventTemplate, ValidationResult } from '../nip85/types.js';
|
|
2
|
+
import type { AggregateFn, FederationVerification, ProofVerification, ProofVersion, SubjectTag } from '../proof/types.js';
|
|
3
|
+
export type UseCaseProfileStatus = 'supported' | 'profile-needed';
|
|
4
|
+
export type SubjectFormat = 'pubkey' | 'event' | 'address' | 'identifier' | 'relay' | 'nip05' | 'domain' | 'package' | 'vendor' | 'source';
|
|
5
|
+
export interface MetricProfile {
|
|
6
|
+
name: string;
|
|
7
|
+
meaning: string;
|
|
8
|
+
direction: 'higher-is-better' | 'lower-is-better' | 'count' | 'application-defined';
|
|
9
|
+
}
|
|
10
|
+
export interface FederationProfile {
|
|
11
|
+
minCircles: number;
|
|
12
|
+
requireScope: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface UseCaseProfile {
|
|
15
|
+
id: string;
|
|
16
|
+
title: string;
|
|
17
|
+
group: string;
|
|
18
|
+
status: UseCaseProfileStatus;
|
|
19
|
+
kind: number;
|
|
20
|
+
subjectTag: SubjectTag;
|
|
21
|
+
subjectTagValue?: string;
|
|
22
|
+
subjectFormats: SubjectFormat[];
|
|
23
|
+
proofVersion: ProofVersion;
|
|
24
|
+
minDistinctSigners: number;
|
|
25
|
+
maxAgeSeconds: number;
|
|
26
|
+
metrics: MetricProfile[];
|
|
27
|
+
federation?: FederationProfile;
|
|
28
|
+
failurePolicy: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface VerifyUseCaseProfileOptions {
|
|
31
|
+
acceptedCircleIds?: Iterable<string>;
|
|
32
|
+
aggregateFn?: AggregateFn;
|
|
33
|
+
expectedSubject?: string;
|
|
34
|
+
expectedSubjectTagValue?: string;
|
|
35
|
+
maxAgeSeconds?: number;
|
|
36
|
+
minDistinctSigners?: number;
|
|
37
|
+
now?: number;
|
|
38
|
+
requireKnownCircle?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface VerifiedProfileEvent {
|
|
41
|
+
event: EventTemplate;
|
|
42
|
+
circleId: string | null;
|
|
43
|
+
proof: ProofVerification;
|
|
44
|
+
subject: string | null;
|
|
45
|
+
syntax: ValidationResult;
|
|
46
|
+
}
|
|
47
|
+
export interface UseCaseProfileVerification {
|
|
48
|
+
valid: boolean;
|
|
49
|
+
errors: string[];
|
|
50
|
+
events: VerifiedProfileEvent[];
|
|
51
|
+
federation?: FederationVerification;
|
|
52
|
+
profile: UseCaseProfile;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/profiles/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,KAAK,EACV,WAAW,EACX,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACX,MAAM,mBAAmB,CAAA;AAE1B,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,gBAAgB,CAAA;AAEjE,MAAM,MAAM,aAAa,GACrB,QAAQ,GACR,OAAO,GACP,SAAS,GACT,YAAY,GACZ,OAAO,GACP,OAAO,GACP,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,QAAQ,CAAA;AAEZ,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,OAAO,GAAG,qBAAqB,CAAA;CACpF;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,oBAAoB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,cAAc,EAAE,aAAa,EAAE,CAAA;IAC/B,YAAY,EAAE,YAAY,CAAA;IAC1B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,aAAa,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,iBAAiB,CAAA;IAC9B,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB;AAED,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IACpC,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,aAAa,CAAA;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,KAAK,EAAE,iBAAiB,CAAA;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,gBAAgB,CAAA;CACzB;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,MAAM,EAAE,oBAAoB,EAAE,CAAA;IAC9B,UAAU,CAAC,EAAE,sBAAsB,CAAA;IACnC,OAAO,EAAE,cAAc,CAAA;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/profiles/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EventTemplate } from '../nip85/types.js';
|
|
2
|
+
import type { UseCaseProfile, UseCaseProfileVerification, VerifyUseCaseProfileOptions } from './types.js';
|
|
3
|
+
export declare function verifyUseCaseProfile(events: EventTemplate | readonly EventTemplate[], profile: UseCaseProfile, options?: VerifyUseCaseProfileOptions): UseCaseProfileVerification;
|
|
4
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/profiles/verify.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAE1B,2BAA2B,EAC5B,MAAM,YAAY,CAAA;AAwHnB,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,GAAG,SAAS,aAAa,EAAE,EAChD,OAAO,EAAE,cAAc,EACvB,OAAO,GAAE,2BAAgC,GACxC,0BAA0B,CAiD5B"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { validateAssertionStrict } from '../nip85/validators.js';
|
|
2
|
+
import { computeCircleId } from '../proof/circle.js';
|
|
3
|
+
import { verifyFederation } from '../proof/federate.js';
|
|
4
|
+
import { verifyProof } from '../proof/verify.js';
|
|
5
|
+
import { subjectMatchesAnyFormat } from './canonical.js';
|
|
6
|
+
function nowSeconds() {
|
|
7
|
+
return Math.floor(Date.now() / 1000);
|
|
8
|
+
}
|
|
9
|
+
function tagValues(event, name) {
|
|
10
|
+
return event.tags
|
|
11
|
+
.filter(tag => tag[0] === name)
|
|
12
|
+
.map(tag => tag[1])
|
|
13
|
+
.filter((value) => typeof value === 'string');
|
|
14
|
+
}
|
|
15
|
+
function singletonTagValue(event, name, errors, prefix) {
|
|
16
|
+
const values = tagValues(event, name);
|
|
17
|
+
if (values.length === 0) {
|
|
18
|
+
errors.push(`${prefix} missing ${name} tag`);
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
if (values.length > 1) {
|
|
22
|
+
errors.push(`${prefix} duplicate ${name} tag`);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return values[0];
|
|
26
|
+
}
|
|
27
|
+
function circleId(event, errors, prefix) {
|
|
28
|
+
const ring = event.tags.find(tag => tag[0] === 'veil-ring')?.slice(1);
|
|
29
|
+
if (ring === undefined) {
|
|
30
|
+
errors.push(`${prefix} missing veil-ring tag`);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return computeCircleId(ring);
|
|
34
|
+
}
|
|
35
|
+
function acceptedCircleSet(options) {
|
|
36
|
+
return options.acceptedCircleIds === undefined
|
|
37
|
+
? undefined
|
|
38
|
+
: new Set(options.acceptedCircleIds);
|
|
39
|
+
}
|
|
40
|
+
function verifyEvent(profile, event, index, options, acceptedCircles, errors) {
|
|
41
|
+
const prefix = `event[${index}]`;
|
|
42
|
+
const syntax = validateAssertionStrict(event);
|
|
43
|
+
if (!syntax.valid) {
|
|
44
|
+
errors.push(...syntax.errors.map(error => `${prefix} syntax: ${error}`));
|
|
45
|
+
}
|
|
46
|
+
if (event.kind !== profile.kind) {
|
|
47
|
+
errors.push(`${prefix} kind ${event.kind} does not match profile kind ${profile.kind}`);
|
|
48
|
+
}
|
|
49
|
+
const subject = singletonTagValue(event, 'd', errors, prefix);
|
|
50
|
+
if (subject !== null && !subjectMatchesAnyFormat(subject, profile.subjectFormats)) {
|
|
51
|
+
errors.push(`${prefix} subject does not match profile formats: ${profile.subjectFormats.join(', ')}`);
|
|
52
|
+
}
|
|
53
|
+
if (options.expectedSubject !== undefined && subject !== options.expectedSubject) {
|
|
54
|
+
errors.push(`${prefix} subject does not match expected subject`);
|
|
55
|
+
}
|
|
56
|
+
const subjectTagValue = singletonTagValue(event, profile.subjectTag, errors, prefix);
|
|
57
|
+
const expectedSubjectTagValue = options.expectedSubjectTagValue
|
|
58
|
+
?? profile.subjectTagValue
|
|
59
|
+
?? subject;
|
|
60
|
+
if (expectedSubjectTagValue !== null && subjectTagValue !== expectedSubjectTagValue) {
|
|
61
|
+
errors.push(`${prefix} ${profile.subjectTag} tag does not match expected subject hint`);
|
|
62
|
+
}
|
|
63
|
+
const proof = verifyProof(event, {
|
|
64
|
+
aggregateFn: options.aggregateFn,
|
|
65
|
+
requireProofVersion: profile.proofVersion,
|
|
66
|
+
});
|
|
67
|
+
if (!proof.valid) {
|
|
68
|
+
errors.push(...proof.errors.map(error => `${prefix} proof: ${error}`));
|
|
69
|
+
}
|
|
70
|
+
const minDistinctSigners = options.minDistinctSigners ?? profile.minDistinctSigners;
|
|
71
|
+
if (profile.federation === undefined && proof.distinctSigners < minDistinctSigners) {
|
|
72
|
+
errors.push(`${prefix} has fewer than ${minDistinctSigners} distinct signers`);
|
|
73
|
+
}
|
|
74
|
+
const maxAgeSeconds = options.maxAgeSeconds ?? profile.maxAgeSeconds;
|
|
75
|
+
if (maxAgeSeconds > 0) {
|
|
76
|
+
if (event.created_at === undefined) {
|
|
77
|
+
errors.push(`${prefix} missing created_at for freshness check`);
|
|
78
|
+
}
|
|
79
|
+
else if (event.created_at < (options.now ?? nowSeconds()) - maxAgeSeconds) {
|
|
80
|
+
errors.push(`${prefix} assertion is outside the accepted freshness window`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const eventCircleId = circleId(event, errors, prefix);
|
|
84
|
+
if (acceptedCircles === undefined || acceptedCircles.size === 0) {
|
|
85
|
+
if (options.requireKnownCircle !== false) {
|
|
86
|
+
errors.push(`${prefix} no accepted circle IDs were supplied`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (eventCircleId !== null && !acceptedCircles.has(eventCircleId)) {
|
|
90
|
+
errors.push(`${prefix} circle is not accepted by deployment policy`);
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
circleId: eventCircleId,
|
|
94
|
+
event,
|
|
95
|
+
proof,
|
|
96
|
+
subject,
|
|
97
|
+
syntax,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function normaliseEvents(events) {
|
|
101
|
+
if (Array.isArray(events))
|
|
102
|
+
return [...events];
|
|
103
|
+
return [events];
|
|
104
|
+
}
|
|
105
|
+
export function verifyUseCaseProfile(events, profile, options = {}) {
|
|
106
|
+
const eventList = normaliseEvents(events);
|
|
107
|
+
const errors = [];
|
|
108
|
+
const acceptedCircles = acceptedCircleSet(options);
|
|
109
|
+
if (eventList.length === 0) {
|
|
110
|
+
errors.push('profile verification requires at least one event');
|
|
111
|
+
}
|
|
112
|
+
if (profile.federation === undefined && eventList.length !== 1) {
|
|
113
|
+
errors.push('profile expects exactly one assertion event');
|
|
114
|
+
}
|
|
115
|
+
if (profile.federation !== undefined) {
|
|
116
|
+
if (eventList.length < profile.federation.minCircles) {
|
|
117
|
+
errors.push(`profile federation requires at least ${profile.federation.minCircles} circles`);
|
|
118
|
+
}
|
|
119
|
+
if (profile.federation.requireScope) {
|
|
120
|
+
for (let i = 0; i < eventList.length; i++) {
|
|
121
|
+
if (tagValues(eventList[i], 'veil-scope').length !== 1) {
|
|
122
|
+
errors.push(`event[${i}] federation profile requires exactly one veil-scope tag`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const verifiedEvents = eventList.map((event, index) => verifyEvent(profile, event, index, options, acceptedCircles, errors));
|
|
128
|
+
const federation = profile.federation === undefined
|
|
129
|
+
? undefined
|
|
130
|
+
: verifyFederation(eventList, options.aggregateFn);
|
|
131
|
+
if (federation !== undefined) {
|
|
132
|
+
if (!federation.valid) {
|
|
133
|
+
errors.push(...federation.errors.map(error => `federation: ${error}`));
|
|
134
|
+
}
|
|
135
|
+
const minDistinctSigners = options.minDistinctSigners ?? profile.minDistinctSigners;
|
|
136
|
+
if (federation.distinctSigners < minDistinctSigners) {
|
|
137
|
+
errors.push(`federation has fewer than ${minDistinctSigners} distinct signers`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
valid: errors.length === 0,
|
|
142
|
+
errors,
|
|
143
|
+
events: verifiedEvents,
|
|
144
|
+
federation,
|
|
145
|
+
profile,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=verify.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,SAAS,CAAC,0DAA0D,CAAC,CAAA;gBACnF,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CACpD,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,CAAC,CACrE,CAAA;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,KAAK,SAAS;QACjD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IACpD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,eAAe,KAAK,EAAE,CAAC,CAAC,CAAA;QACxE,CAAC;QACD,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,kBAAkB,CAAA;QACnF,IAAI,UAAU,CAAC,eAAe,GAAG,kBAAkB,EAAE,CAAC;YACpD,MAAM,CAAC,IAAI,CAAC,6BAA6B,kBAAkB,mBAAmB,CAAC,CAAA;QACjF,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;QACN,MAAM,EAAE,cAAc;QACtB,UAAU;QACV,OAAO;KACR,CAAA;AACH,CAAC"}
|
package/llms-full.txt
CHANGED
|
@@ -77,6 +77,36 @@ The `veil-sig` JSON excludes `ring` and `keyImage` (which live in the other
|
|
|
77
77
|
tags). It contains `c0`, `electionId`, `message`, `responses`, and optionally
|
|
78
78
|
`domain`.
|
|
79
79
|
|
|
80
|
+
## Use-Case Mapping
|
|
81
|
+
|
|
82
|
+
The shipped primitives cover these concrete shapes:
|
|
83
|
+
|
|
84
|
+
- Kind 30382 user assertions: user reputation, abuse reporting, source
|
|
85
|
+
corroboration where the source has a pubkey, onboarding vouches, and
|
|
86
|
+
pubkey-backed trade reputation.
|
|
87
|
+
- Kind 30383 event assertions: event, claim, announcement, and proposal review.
|
|
88
|
+
- Kind 30384 addressable assertions: long-form notes, research artefacts,
|
|
89
|
+
grant applications, community lists, labeler profiles, and moderation lists.
|
|
90
|
+
- Kind 30385 identifier assertions: relays, services, vendors, marketplaces,
|
|
91
|
+
packages, releases, maintainers, NIP-05 identifiers, domains, and other
|
|
92
|
+
external identifiers. The `k` namespace is chosen by the application profile,
|
|
93
|
+
not standardised by nostr-veil.
|
|
94
|
+
- Scoped federations: cross-circle moderation or review where overlapping
|
|
95
|
+
members should count once across several circles.
|
|
96
|
+
|
|
97
|
+
For new workflows, prefer proof v2 and verify with
|
|
98
|
+
`verifyProof(event, { requireProofVersion: 'v2' })`. Credential co-signing and
|
|
99
|
+
anonymous gated access are future profiles: nostr-veil can provide the
|
|
100
|
+
threshold proof, but those flows need separate credential/admission event
|
|
101
|
+
formats and handshakes.
|
|
102
|
+
|
|
103
|
+
The use-case documentation is written as implementation profiles. Each page
|
|
104
|
+
should identify the subject shape, helper, metric meaning, proof version,
|
|
105
|
+
verifier action, proof boundary, and the operational controls needed beyond
|
|
106
|
+
nostr-veil. Caveats should be paired with a concrete control such as evidence
|
|
107
|
+
workflow, canonicalisation, expiry, revocation, transport privacy, Sybil policy,
|
|
108
|
+
or a companion protocol.
|
|
109
|
+
|
|
80
110
|
## Type Definitions
|
|
81
111
|
|
|
82
112
|
### `TrustCircle`
|
|
@@ -635,5 +665,6 @@ These are not dependencies but complement nostr-veil:
|
|
|
635
665
|
## Optional
|
|
636
666
|
|
|
637
667
|
- [README](https://github.com/forgesworn/nostr-veil/blob/main/README.md): Full documentation with architecture diagram
|
|
668
|
+
- [docs/use-cases.md](https://github.com/forgesworn/nostr-veil/blob/main/docs/use-cases.md): Concrete use-case implementation map with individual worked pages
|
|
638
669
|
- [IMPACT.md](https://github.com/forgesworn/nostr-veil/blob/main/IMPACT.md): Problem statement and ecosystem impact
|
|
639
670
|
- [@forgesworn/ring-sig](https://github.com/forgesworn/ring-sig): Underlying ring signature library
|
package/llms.txt
CHANGED
|
@@ -64,6 +64,30 @@ nostr-veil hides which public ring member contributed. It does not hide the ring
|
|
|
64
64
|
membership list, individual anonymous metric values, network/timing metadata, or
|
|
65
65
|
whether the circle was socially well-chosen. Shared federation scopes intentionally
|
|
66
66
|
reveal cross-circle overlap by key image while still hiding the contributor's identity.
|
|
67
|
+
Use operational controls for the boundary: circle admission and rotation, evidence
|
|
68
|
+
workflow, appeals, identifier canonicalisation, expiry, revocation, batching,
|
|
69
|
+
transport privacy, and service-specific checks.
|
|
70
|
+
|
|
71
|
+
## Use-Case Mapping
|
|
72
|
+
|
|
73
|
+
Use `aggregateContributions` for user reputation, abuse reporting, source
|
|
74
|
+
corroboration, onboarding vouches, and pubkey-backed trade reputation. Use
|
|
75
|
+
`aggregateEventContributions` for event and claim verification. Use
|
|
76
|
+
`aggregateAddressableContributions` for long-form review, research, proposals,
|
|
77
|
+
lists, and labeler profiles. Use `aggregateIdentifierContributions` for relays,
|
|
78
|
+
services, packages, releases, maintainers, NIP-05 identifiers, domains, vendors,
|
|
79
|
+
and other external identifiers; the kind 30385 `k` namespace is chosen by the
|
|
80
|
+
application profile, not standardised by nostr-veil. Credential co-signing and
|
|
81
|
+
anonymous gated access are future profiles: nostr-veil can provide the threshold
|
|
82
|
+
proof, but those flows need separate credential/admission event formats and
|
|
83
|
+
handshakes.
|
|
84
|
+
|
|
85
|
+
Use-case pages are implementation profiles. Each page should identify the
|
|
86
|
+
subject shape, helper, metric meaning, proof version, verifier action, proof
|
|
87
|
+
boundary, and the operational controls needed outside nostr-veil. Caveats
|
|
88
|
+
should be paired with concrete controls such as evidence workflow,
|
|
89
|
+
canonicalisation, expiry, revocation, transport privacy, Sybil policy, or a
|
|
90
|
+
companion protocol.
|
|
67
91
|
|
|
68
92
|
## Companion Libraries
|
|
69
93
|
|
|
@@ -77,5 +101,6 @@ These are not dependencies but complement nostr-veil:
|
|
|
77
101
|
## Optional
|
|
78
102
|
|
|
79
103
|
- [README](https://github.com/forgesworn/nostr-veil/blob/main/README.md): Full documentation with architecture diagram
|
|
104
|
+
- [docs/use-cases.md](https://github.com/forgesworn/nostr-veil/blob/main/docs/use-cases.md): Concrete use-case field guide with individual worked pages and operational controls
|
|
80
105
|
- [IMPACT.md](https://github.com/forgesworn/nostr-veil/blob/main/IMPACT.md): Problem statement and ecosystem impact
|
|
81
106
|
- [@forgesworn/ring-sig](https://github.com/forgesworn/ring-sig): Underlying ring signature library
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nostr-veil",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Privacy layer for Nostr reputation systems. Groups collectively score trustworthiness using ring signatures -- scores are verifiable but contributors are unidentifiable.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"./proof": {
|
|
18
18
|
"types": "./dist/proof/index.d.ts",
|
|
19
19
|
"import": "./dist/proof/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./profiles": {
|
|
22
|
+
"types": "./dist/profiles/index.d.ts",
|
|
23
|
+
"import": "./dist/profiles/index.js"
|
|
20
24
|
}
|
|
21
25
|
},
|
|
22
26
|
"bin": {
|
|
@@ -35,6 +39,8 @@
|
|
|
35
39
|
"test:watch": "vitest",
|
|
36
40
|
"typecheck": "tsc --noEmit",
|
|
37
41
|
"lint": "tsc --noEmit",
|
|
42
|
+
"test:use-cases": "tsx examples/use-cases.ts",
|
|
43
|
+
"test:use-cases:relay": "tsx examples/use-cases-relay.ts",
|
|
38
44
|
"demo": "cd demo && npm run dev",
|
|
39
45
|
"prepublishOnly": "npm run build",
|
|
40
46
|
"prepare": "npm run build"
|