nostr-veil 0.17.0 → 0.18.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 +2 -0
- package/dist/profiles/bundle.d.ts +45 -0
- package/dist/profiles/bundle.d.ts.map +1 -0
- package/dist/profiles/bundle.js +162 -0
- package/dist/profiles/bundle.js.map +1 -0
- package/dist/profiles/index.d.ts +1 -0
- package/dist/profiles/index.d.ts.map +1 -1
- package/dist/profiles/index.js +1 -0
- package/dist/profiles/index.js.map +1 -1
- package/llms-full.txt +50 -0
- package/llms.txt +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -169,6 +169,8 @@ The resulting `assertion` is a plain `EventTemplate` you sign and publish like a
|
|
|
169
169
|
| `verifyCircleManifest(manifest, options?)` | Verify that a circle manifest matches its members and deployment constraints |
|
|
170
170
|
| `createDeploymentPolicy(profile, options)` | Build a fail-closed deployment policy with accepted circles, expected subject, metric bounds, freshness, threshold, and signature requirements |
|
|
171
171
|
| `verifyDeploymentPolicy(events, policy, options?)` | Verify a profile plus deployment-specific controls before acting on a score |
|
|
172
|
+
| `createSignedDeploymentBundle(policy, options)` | Sign a deployment policy and its manifests as trusted operator configuration |
|
|
173
|
+
| `verifyDeploymentBundle(events, bundle, options?)` | Verify a signed bundle from trusted publishers, then verify the bundled deployment policy |
|
|
172
174
|
| `canonicalRelaySubject`, `canonicalNip05Subject`, `canonicalDomainSubject`, `canonicalNpmPackageSubject` | Canonical subject helpers for common real-world identifiers |
|
|
173
175
|
| `canonicalPubkeySubject`, `canonicalEventSubject`, `canonicalAddressSubject` | Canonical subject helpers for Nostr-native subjects |
|
|
174
176
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { EventTemplate } from '../nip85/types.js';
|
|
2
|
+
import type { DeploymentPolicyVerification, UseCaseDeploymentPolicy, VerifyDeploymentPolicyOptions } from './policy.js';
|
|
3
|
+
export declare const DEPLOYMENT_BUNDLE_TYPE = "nostr-veil-deployment-bundle";
|
|
4
|
+
export interface DeploymentBundlePayload {
|
|
5
|
+
version: 1;
|
|
6
|
+
type: typeof DEPLOYMENT_BUNDLE_TYPE;
|
|
7
|
+
expiresAt?: number;
|
|
8
|
+
id: string;
|
|
9
|
+
issuedAt: number;
|
|
10
|
+
policy: UseCaseDeploymentPolicy;
|
|
11
|
+
signer: string;
|
|
12
|
+
}
|
|
13
|
+
export interface SignedDeploymentBundle extends DeploymentBundlePayload {
|
|
14
|
+
signature: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CreateSignedDeploymentBundleOptions {
|
|
17
|
+
expiresAt?: number;
|
|
18
|
+
id: string;
|
|
19
|
+
issuedAt: number;
|
|
20
|
+
privateKey: string;
|
|
21
|
+
}
|
|
22
|
+
export interface VerifySignedDeploymentBundleOptions {
|
|
23
|
+
now?: number;
|
|
24
|
+
trustedPublishers?: Iterable<string>;
|
|
25
|
+
}
|
|
26
|
+
export interface SignedDeploymentBundleVerification {
|
|
27
|
+
bundle: SignedDeploymentBundle;
|
|
28
|
+
errors: string[];
|
|
29
|
+
publisherTrusted: boolean;
|
|
30
|
+
signatureValid: boolean;
|
|
31
|
+
valid: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface VerifyDeploymentBundleOptions extends VerifyDeploymentPolicyOptions {
|
|
34
|
+
trustedPublishers?: Iterable<string>;
|
|
35
|
+
}
|
|
36
|
+
export interface DeploymentBundleVerification {
|
|
37
|
+
bundle: SignedDeploymentBundleVerification;
|
|
38
|
+
deployment: DeploymentPolicyVerification;
|
|
39
|
+
errors: string[];
|
|
40
|
+
valid: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function createSignedDeploymentBundle(policy: UseCaseDeploymentPolicy, options: CreateSignedDeploymentBundleOptions): SignedDeploymentBundle;
|
|
43
|
+
export declare function verifySignedDeploymentBundle(bundle: SignedDeploymentBundle, options?: VerifySignedDeploymentBundleOptions): SignedDeploymentBundleVerification;
|
|
44
|
+
export declare function verifyDeploymentBundle(events: EventTemplate | readonly EventTemplate[], bundle: SignedDeploymentBundle, options?: VerifyDeploymentBundleOptions): DeploymentBundleVerification;
|
|
45
|
+
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/profiles/bundle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAEvH,eAAO,MAAM,sBAAsB,iCAAiC,CAAA;AAEpE,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,CAAC,CAAA;IACV,IAAI,EAAE,OAAO,sBAAsB,CAAA;IACnC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,uBAAuB,CAAA;IAC/B,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,sBAAuB,SAAQ,uBAAuB;IACrE,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,mCAAmC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,mCAAmC;IAClD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,iBAAiB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;CACrC;AAED,MAAM,WAAW,kCAAkC;IACjD,MAAM,EAAE,sBAAsB,CAAA;IAC9B,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,gBAAgB,EAAE,OAAO,CAAA;IACzB,cAAc,EAAE,OAAO,CAAA;IACvB,KAAK,EAAE,OAAO,CAAA;CACf;AAED,MAAM,WAAW,6BAA8B,SAAQ,6BAA6B;IAClF,iBAAiB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;CACrC;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,kCAAkC,CAAA;IAC1C,UAAU,EAAE,4BAA4B,CAAA;IACxC,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;CACf;AAwED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,mCAAmC,GAC3C,sBAAsB,CAyBxB;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,sBAAsB,EAC9B,OAAO,GAAE,mCAAwC,GAChD,kCAAkC,CAsDpC;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,GAAG,SAAS,aAAa,EAAE,EAChD,MAAM,EAAE,sBAAsB,EAC9B,OAAO,GAAE,6BAAkC,GAC1C,4BAA4B,CAc9B"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { schnorr } from '@noble/curves/secp256k1.js';
|
|
2
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
3
|
+
import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';
|
|
4
|
+
import { verifyDeploymentPolicy } from './policy.js';
|
|
5
|
+
export const DEPLOYMENT_BUNDLE_TYPE = 'nostr-veil-deployment-bundle';
|
|
6
|
+
const HEX64_RE = /^[0-9a-f]{64}$/;
|
|
7
|
+
const HEX128_RE = /^[0-9a-f]{128}$/;
|
|
8
|
+
function assertHex64(value, label) {
|
|
9
|
+
if (!HEX64_RE.test(value)) {
|
|
10
|
+
throw new Error(`${label} must be a 64-character lowercase hex string`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function assertSafeUnix(value, label) {
|
|
14
|
+
if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {
|
|
15
|
+
throw new Error(`${label} must be a non-negative Unix timestamp`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function assertNonEmpty(value, label) {
|
|
19
|
+
if (value.trim() === '')
|
|
20
|
+
throw new Error(`${label} must be non-empty`);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
function stableStringify(value) {
|
|
24
|
+
return JSON.stringify(value, (_key, child) => {
|
|
25
|
+
if (child !== null && typeof child === 'object' && !Array.isArray(child)) {
|
|
26
|
+
const sorted = {};
|
|
27
|
+
for (const key of Object.keys(child).sort()) {
|
|
28
|
+
sorted[key] = child[key];
|
|
29
|
+
}
|
|
30
|
+
return sorted;
|
|
31
|
+
}
|
|
32
|
+
return child;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function deploymentBundleDigest(payload) {
|
|
36
|
+
const encoded = new TextEncoder().encode(`${DEPLOYMENT_BUNDLE_TYPE}:v1\n${stableStringify(payload)}`);
|
|
37
|
+
return sha256(encoded);
|
|
38
|
+
}
|
|
39
|
+
function payloadFromBundle(bundle) {
|
|
40
|
+
return {
|
|
41
|
+
version: bundle.version,
|
|
42
|
+
type: bundle.type,
|
|
43
|
+
...(bundle.expiresAt === undefined ? {} : { expiresAt: bundle.expiresAt }),
|
|
44
|
+
id: bundle.id,
|
|
45
|
+
issuedAt: bundle.issuedAt,
|
|
46
|
+
policy: bundle.policy,
|
|
47
|
+
signer: bundle.signer,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function trustedPublisherSet(publishers, errors) {
|
|
51
|
+
if (publishers === undefined) {
|
|
52
|
+
errors.push('no trusted bundle publishers configured');
|
|
53
|
+
return new Set();
|
|
54
|
+
}
|
|
55
|
+
const trusted = new Set();
|
|
56
|
+
let count = 0;
|
|
57
|
+
for (const publisher of publishers) {
|
|
58
|
+
count += 1;
|
|
59
|
+
if (!HEX64_RE.test(publisher)) {
|
|
60
|
+
errors.push(`trustedPublishers[${count - 1}] must be a 64-character lowercase hex string`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
trusted.add(publisher);
|
|
64
|
+
}
|
|
65
|
+
if (count === 0)
|
|
66
|
+
errors.push('no trusted bundle publishers configured');
|
|
67
|
+
return trusted;
|
|
68
|
+
}
|
|
69
|
+
export function createSignedDeploymentBundle(policy, options) {
|
|
70
|
+
assertNonEmpty(options.id, 'id');
|
|
71
|
+
assertSafeUnix(options.issuedAt, 'issuedAt');
|
|
72
|
+
assertSafeUnix(options.expiresAt, 'expiresAt');
|
|
73
|
+
if (options.expiresAt !== undefined && options.expiresAt <= options.issuedAt) {
|
|
74
|
+
throw new Error('expiresAt must be greater than issuedAt');
|
|
75
|
+
}
|
|
76
|
+
assertHex64(options.privateKey, 'privateKey');
|
|
77
|
+
const signer = bytesToHex(schnorr.getPublicKey(hexToBytes(options.privateKey)));
|
|
78
|
+
const payload = {
|
|
79
|
+
version: 1,
|
|
80
|
+
type: DEPLOYMENT_BUNDLE_TYPE,
|
|
81
|
+
...(options.expiresAt === undefined ? {} : { expiresAt: options.expiresAt }),
|
|
82
|
+
id: options.id,
|
|
83
|
+
issuedAt: options.issuedAt,
|
|
84
|
+
policy,
|
|
85
|
+
signer,
|
|
86
|
+
};
|
|
87
|
+
const signature = bytesToHex(schnorr.sign(deploymentBundleDigest(payload), hexToBytes(options.privateKey)));
|
|
88
|
+
return Object.freeze({
|
|
89
|
+
...payload,
|
|
90
|
+
signature,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export function verifySignedDeploymentBundle(bundle, options = {}) {
|
|
94
|
+
const errors = [];
|
|
95
|
+
const trustedPublishers = trustedPublisherSet(options.trustedPublishers, errors);
|
|
96
|
+
if (bundle.version !== 1)
|
|
97
|
+
errors.push('bundle version must be 1');
|
|
98
|
+
if (bundle.type !== DEPLOYMENT_BUNDLE_TYPE)
|
|
99
|
+
errors.push(`bundle type must be ${DEPLOYMENT_BUNDLE_TYPE}`);
|
|
100
|
+
if (bundle.id.trim() === '')
|
|
101
|
+
errors.push('bundle id must be non-empty');
|
|
102
|
+
if (!Number.isSafeInteger(bundle.issuedAt) || bundle.issuedAt < 0) {
|
|
103
|
+
errors.push('bundle issuedAt must be a non-negative Unix timestamp');
|
|
104
|
+
}
|
|
105
|
+
if (bundle.expiresAt !== undefined) {
|
|
106
|
+
if (!Number.isSafeInteger(bundle.expiresAt) || bundle.expiresAt < 0) {
|
|
107
|
+
errors.push('bundle expiresAt must be a non-negative Unix timestamp');
|
|
108
|
+
}
|
|
109
|
+
else if (bundle.expiresAt <= bundle.issuedAt) {
|
|
110
|
+
errors.push('bundle expiresAt must be greater than issuedAt');
|
|
111
|
+
}
|
|
112
|
+
else if (options.now !== undefined && options.now > bundle.expiresAt) {
|
|
113
|
+
errors.push('bundle is expired');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (options.now !== undefined && bundle.issuedAt > options.now) {
|
|
117
|
+
errors.push('bundle issuedAt is in the future');
|
|
118
|
+
}
|
|
119
|
+
const signerShapeValid = HEX64_RE.test(bundle.signer);
|
|
120
|
+
const signatureShapeValid = HEX128_RE.test(bundle.signature);
|
|
121
|
+
if (!signerShapeValid)
|
|
122
|
+
errors.push('bundle signer must be a 64-character lowercase hex string');
|
|
123
|
+
if (!signatureShapeValid)
|
|
124
|
+
errors.push('bundle signature must be a 128-character lowercase hex string');
|
|
125
|
+
let signatureValid = false;
|
|
126
|
+
if (signerShapeValid && signatureShapeValid) {
|
|
127
|
+
try {
|
|
128
|
+
signatureValid = schnorr.verify(hexToBytes(bundle.signature), deploymentBundleDigest(payloadFromBundle(bundle)), hexToBytes(bundle.signer));
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
signatureValid = false;
|
|
132
|
+
}
|
|
133
|
+
if (!signatureValid)
|
|
134
|
+
errors.push('bundle signature is invalid');
|
|
135
|
+
}
|
|
136
|
+
const publisherTrusted = trustedPublishers.has(bundle.signer);
|
|
137
|
+
if (!publisherTrusted && trustedPublishers.size > 0) {
|
|
138
|
+
errors.push('bundle signer is not trusted');
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
bundle,
|
|
142
|
+
errors,
|
|
143
|
+
publisherTrusted,
|
|
144
|
+
signatureValid,
|
|
145
|
+
valid: errors.length === 0,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
export function verifyDeploymentBundle(events, bundle, options = {}) {
|
|
149
|
+
const bundleVerification = verifySignedDeploymentBundle(bundle, options);
|
|
150
|
+
const deployment = verifyDeploymentPolicy(events, bundle.policy, options);
|
|
151
|
+
const errors = [
|
|
152
|
+
...bundleVerification.errors,
|
|
153
|
+
...deployment.errors,
|
|
154
|
+
];
|
|
155
|
+
return {
|
|
156
|
+
bundle: bundleVerification,
|
|
157
|
+
deployment,
|
|
158
|
+
errors,
|
|
159
|
+
valid: bundleVerification.valid && deployment.valid,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/profiles/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,8BAA8B,CAAA;AA+CpE,MAAM,QAAQ,GAAG,gBAAgB,CAAA;AACjC,MAAM,SAAS,GAAG,iBAAiB,CAAA;AAEnC,SAAS,WAAW,CAAC,KAAa,EAAE,KAAa;IAC/C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,8CAA8C,CAAC,CAAA;IACzE,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,KA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AC,CAAA;IACzE,MAAM,MAAM,GAAG;QACb,GAAG,kBAAkB,CAAC,MAAM;QAC5B,GAAG,UAAU,CAAC,MAAM;KACrB,CAAA;IAED,OAAO;QACL,MAAM,EAAE,kBAAkB;QAC1B,UAAU;QACV,MAAM;QACN,KAAK,EAAE,kBAAkB,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK;KACpD,CAAA;AACH,CAAC"}
|
package/dist/profiles/index.d.ts
CHANGED
|
@@ -1 +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;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA"}
|
|
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;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA"}
|
package/dist/profiles/index.js
CHANGED
|
@@ -1 +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;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA"}
|
|
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;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA"}
|
package/llms-full.txt
CHANGED
|
@@ -599,6 +599,56 @@ Produce the deterministic proof-v2 message. The context must include `kind`,
|
|
|
599
599
|
|
|
600
600
|
---
|
|
601
601
|
|
|
602
|
+
### `nostr-veil/profiles` -- Safer Deployment Profiles
|
|
603
|
+
|
|
604
|
+
Use this layer when an application wants to act on a score. It adds profile
|
|
605
|
+
checks, deployment policy, circle manifests, and signed policy bundles on top of
|
|
606
|
+
the low-level proof verifier.
|
|
607
|
+
|
|
608
|
+
#### `verifyUseCaseProfile(events, profile, options) → UseCaseProfileVerification`
|
|
609
|
+
|
|
610
|
+
Verify NIP-85 syntax, proof version, expected kind and subject tag, freshness,
|
|
611
|
+
threshold, accepted circles, expected subject, and federation policy.
|
|
612
|
+
|
|
613
|
+
#### `createCircleManifest(options) → CircleManifest`
|
|
614
|
+
|
|
615
|
+
Build a machine-readable circle manifest. A manifest binds a member list to its
|
|
616
|
+
circle ID and records allowed profile IDs, issue/expiry times, superseded
|
|
617
|
+
circles, revoked circles, policy URI, contact, and evidence process.
|
|
618
|
+
|
|
619
|
+
#### `createDeploymentPolicy(profile, options) → UseCaseDeploymentPolicy`
|
|
620
|
+
|
|
621
|
+
Build a fail-closed verifier policy with accepted circle IDs or manifests,
|
|
622
|
+
expected subject, optional subject-tag value, freshness, signer threshold,
|
|
623
|
+
metric bounds, unknown-metric handling, and optional Nostr event signature
|
|
624
|
+
requirements.
|
|
625
|
+
|
|
626
|
+
#### `createSignedDeploymentBundle(policy, options) → SignedDeploymentBundle`
|
|
627
|
+
|
|
628
|
+
Sign a deployment policy and its manifests as trusted operator configuration.
|
|
629
|
+
Use this when policy material is distributed separately from the verifier.
|
|
630
|
+
|
|
631
|
+
#### `verifyDeploymentBundle(events, bundle, options) → DeploymentBundleVerification`
|
|
632
|
+
|
|
633
|
+
Verify that the bundle signature is valid, the signer pubkey is pinned in
|
|
634
|
+
`trustedPublishers`, the bundle is fresh, and the bundled deployment policy
|
|
635
|
+
accepts the signed assertion events.
|
|
636
|
+
|
|
637
|
+
```ts
|
|
638
|
+
const bundle = createSignedDeploymentBundle(policy, {
|
|
639
|
+
id: 'package-release-gate',
|
|
640
|
+
issuedAt,
|
|
641
|
+
expiresAt,
|
|
642
|
+
privateKey: operatorPrivateKey,
|
|
643
|
+
})
|
|
644
|
+
const result = verifyDeploymentBundle(assertionFromRelay, bundle, {
|
|
645
|
+
now,
|
|
646
|
+
trustedPublishers: [operatorPubkey],
|
|
647
|
+
})
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
---
|
|
651
|
+
|
|
602
652
|
### `nostr-veil` root export -- Signing Utilities
|
|
603
653
|
|
|
604
654
|
#### `computeEventId(event) → string`
|
package/llms.txt
CHANGED
|
@@ -58,6 +58,14 @@ Two subpath exports, plus a root that re-exports everything:
|
|
|
58
58
|
**`nostr-veil/proof`** -- Ring-signature proof layer:
|
|
59
59
|
`createTrustCircle`, `contributeAssertion`, `contributeEventAssertion`, `contributeAddressableAssertion`, `contributeIdentifierAssertion`, `aggregateContributions`, `aggregateEventContributions`, `aggregateAddressableContributions`, `aggregateIdentifierContributions`, `verifyProof`, `verifyFederation`, `canonicalMessage`, `canonicalMessageV2`, `computeCircleId`
|
|
60
60
|
|
|
61
|
+
**`nostr-veil/profiles`** -- Safer deployment profiles:
|
|
62
|
+
`USE_CASE_PROFILES`, `USE_CASE_PROFILE_BY_ID`, `verifyUseCaseProfile`,
|
|
63
|
+
`createCircleManifest`, `verifyCircleManifest`, `createDeploymentPolicy`,
|
|
64
|
+
`verifyDeploymentPolicy`, `createSignedDeploymentBundle`,
|
|
65
|
+
`verifyDeploymentBundle`, and canonical subject helpers. Use signed deployment
|
|
66
|
+
bundles with pinned trusted publisher pubkeys when policy/manifests are
|
|
67
|
+
distributed outside the verifier binary.
|
|
68
|
+
|
|
61
69
|
## Limits
|
|
62
70
|
|
|
63
71
|
nostr-veil hides which public ring member contributed. It does not hide the ring
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nostr-veil",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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",
|