@zanii/provenance 0.1.0 → 0.1.2

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 CHANGED
@@ -38,6 +38,9 @@ caller's concern.
38
38
  export adapters can come later.
39
39
 
40
40
  ## Changelog
41
+
42
+ - **0.1.2** — C2PA assertion round-trip, watermark bindings, edit chains (human vs AI), newsroom co-signing, subject disputes, commit credentials, TDM reservations, feed labelling, political-ad registry, exact royalty splits.
43
+ - **0.1.1** — now depends on `@zanii/core` 0.5 (protocol 1.2), so it shares one core with `@zanii/sdk` 0.5 instead of pulling in a second, older copy. No API change.
41
44
  - **0.1.0** — initial release: `buildContentCredential`, `verifyContentCredential`, `credentialReceipt`, `resolveCreator`.
42
45
 
43
46
  ## License
package/dist/index.d.ts CHANGED
@@ -41,4 +41,5 @@ export declare function resolveCreator(credential: ContentCredential, opts?: {
41
41
  server?: string;
42
42
  fetchImpl?: FetchLike;
43
43
  }): Promise<AgentTrust | null>;
44
+ export * from './media.js';
44
45
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGrF,MAAM,WAAW,iBAAiB;IAChC,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,oBAAoB,CAAC;IAC3B,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,gGAAgG;IAChG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,eAAe;IAC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CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAO,GACpD,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAE5B;AACD,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -94,4 +94,5 @@ export function credentialReceipt(credential) {
94
94
  export async function resolveCreator(credential, opts = {}) {
95
95
  return resolveAgent(credential.agent, opts);
96
96
  }
97
+ export * from './media.js';
97
98
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAmC,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA4BrF,+DAA+D;AAC/D,MAAM,UAAU,sBAAsB,CAAC,KAAsB,EAAE,eAA2B;IACxF,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACrG,IAAI,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;IACtC,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7F,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,YAAY,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;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AK,CAAC,IAAI,QAAQ,KAAK,SAAS,IAAI,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,CAAC;QAChG,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;AAC/C,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,iBAAiB,CAAC,UAA6B;IAC7D,OAAO;QACL,MAAM,EAAE,iBAAiB;QACzB,OAAO,EAAE;YACP,QAAQ,EAAE,YAAY;YACtB,CAAC,EAAE,CAAC;YACJ,aAAa,EAAE,UAAU,CAAC,aAAa;YACvC,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC;YACpC,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,UAAU,EAAE,UAAU,CAAC,UAAU;SAClC;KACF,CAAC;AACJ,CAAC;AAED,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAA6B,EAC7B,OAAmD,EAAE;IAErD,OAAO,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC9C,CAAC;AACD,cAAc,YAAY,CAAC"}
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Provenance in the field: a C2PA assertion carrying the credential, watermark bindings,
3
+ * edit chains (human vs AI steps), newsroom co-signing, disputes by depicted people,
4
+ * AI-authored commits, text-and-data-mining reservations, feed labelling, a political-ad
5
+ * disclosure registry and exact royalty splits. Built on `buildContentCredential`.
6
+ */
7
+ import { type SignedObject } from '@zanii/core';
8
+ import { type ContentCredential } from './index.js';
9
+ export declare const C2PA_LABEL = "org.zanii.credential";
10
+ /**
11
+ * A custom assertion to place in a C2PA manifest (your C2PA SDK signs the manifest with
12
+ * its X.509 identity; this assertion links it to the agent's DID and receipt).
13
+ */
14
+ export declare function c2paAssertion(credential: ContentCredential): {
15
+ label: string;
16
+ data: {
17
+ credential: ContentCredential;
18
+ credential_hash: string;
19
+ };
20
+ };
21
+ /** Find and verify the Zanii assertion inside a C2PA manifest's assertions (as JSON). */
22
+ export declare function credentialFromC2pa(assertions: Array<{
23
+ label: string;
24
+ data: unknown;
25
+ }>, artifact?: Uint8Array | string): {
26
+ found: false;
27
+ ok: boolean;
28
+ reasons: string[];
29
+ credential?: undefined;
30
+ } | {
31
+ found: true;
32
+ credential: ContentCredential;
33
+ ok: boolean;
34
+ reasons: string[];
35
+ };
36
+ export type WatermarkBinding = SignedObject<{
37
+ v: 1;
38
+ type: 'provenance.watermark';
39
+ credential: string;
40
+ artifact_hash: string;
41
+ detector: string;
42
+ watermark_id: string;
43
+ ts: string;
44
+ }>;
45
+ /**
46
+ * Bind an invisible watermark id to the credential, signed by the creating agent. The
47
+ * trust root for "this watermark is present" is the detector you name, not Zanii.
48
+ */
49
+ export declare function bindWatermark(credential: ContentCredential, w: {
50
+ detector: string;
51
+ watermarkId: string;
52
+ ts?: string;
53
+ }, agentPrivateKey: Uint8Array): WatermarkBinding;
54
+ export declare function verifyWatermarkBinding(b: WatermarkBinding, credential: ContentCredential): boolean;
55
+ export interface EditStep {
56
+ by: 'human' | 'ai';
57
+ description: string;
58
+ }
59
+ /** A credential for an edited version, linking to the previous one and stating the edits. */
60
+ export declare function editVersion(previous: ContentCredential, next: {
61
+ artifact: Uint8Array | string;
62
+ agentDid: string;
63
+ createdAt: string;
64
+ edits: EditStep[];
65
+ }, agentPrivateKey: Uint8Array): ContentCredential;
66
+ /** Verify a chain of versions (oldest first): every credential valid, every link and time in order; counts human and AI edits. */
67
+ export declare function verifyEditChain(chain: ContentCredential[]): {
68
+ ok: boolean;
69
+ reasons: string[];
70
+ versions: number;
71
+ humanEdits: number;
72
+ aiEdits: number;
73
+ };
74
+ export type CoSignature = SignedObject<{
75
+ v: 1;
76
+ type: 'provenance.cosign';
77
+ credential: string;
78
+ role: string;
79
+ ts: string;
80
+ }>;
81
+ /** A journalist, editor or fact-checker countersigns an article's credential in a stated role. */
82
+ export declare function coSign(credential: ContentCredential, role: string, privateKey: Uint8Array, ts?: string): CoSignature;
83
+ /** The credential is valid and every required role is countersigned by one of its allowed signers. */
84
+ export declare function verifyNewsroom(credential: ContentCredential, cosigs: CoSignature[], required: Record<string, string[]>): {
85
+ ok: boolean;
86
+ reasons: string[];
87
+ };
88
+ export type Dispute = SignedObject<{
89
+ v: 1;
90
+ type: 'provenance.dispute';
91
+ artifact_hash: string;
92
+ claim: 'not_me' | 'not_consented' | 'altered';
93
+ statement: string;
94
+ evidence: string[];
95
+ ts: string;
96
+ }>;
97
+ /** A person depicted in content disputes it, signed with their own DID, with hashes of their evidence. */
98
+ export declare function fileDispute(input: {
99
+ artifactHash: string;
100
+ claim: Dispute['claim'];
101
+ statement: string;
102
+ evidence?: Array<Uint8Array | string>;
103
+ ts?: string;
104
+ }, subjectPrivateKey: Uint8Array): Dispute;
105
+ /** For a platform: the dispute is genuine and about this artifact; includes whether the artifact had a valid credential at all. */
106
+ export declare function assessDispute(d: Dispute, credential?: ContentCredential): {
107
+ disputeValid: boolean;
108
+ subject: string;
109
+ claim: "not_me" | "not_consented" | "altered";
110
+ credentialed: boolean;
111
+ creator: string | null;
112
+ };
113
+ /** A credential for an AI-authored commit, plus a git trailer to put in the commit message. */
114
+ export declare function commitCredential(c: {
115
+ repo: string;
116
+ commit: string;
117
+ agentDid: string;
118
+ reviewer?: string;
119
+ createdAt: string;
120
+ }, agentPrivateKey: Uint8Array): {
121
+ credential: ContentCredential;
122
+ trailer: string;
123
+ };
124
+ export type TdmReservation = SignedObject<{
125
+ v: 1;
126
+ type: 'provenance.tdm_reservation';
127
+ artifact_hash: string;
128
+ reserved: boolean;
129
+ policy?: string;
130
+ ts: string;
131
+ }>;
132
+ /** A rightsholder's machine-readable text-and-data-mining reservation (EU CDSM Art. 4(3)) bound to an asset. */
133
+ export declare function reserveTdm(input: {
134
+ artifactHash: string;
135
+ reserved?: boolean;
136
+ policyUrl?: string;
137
+ ts?: string;
138
+ }, holderPrivateKey: Uint8Array): TdmReservation;
139
+ /** For a crawler: is mining this asset reserved? The latest valid statement from a trusted holder wins. */
140
+ export declare function tdmReserved(artifactHash: string, reservations: TdmReservation[], trustedHolders?: string[]): boolean;
141
+ /** Label every item in a feed from its credential: AI-generated by a named agent, credential invalid, or no credential. */
142
+ export declare function labelFeed(items: Array<{
143
+ id: string;
144
+ artifact?: Uint8Array | string;
145
+ credential?: ContentCredential;
146
+ }>): ({
147
+ id: string;
148
+ label: "no-credential";
149
+ agent: null;
150
+ } | {
151
+ id: string;
152
+ label: "ai-generated" | "credential-invalid";
153
+ agent: string | null;
154
+ })[];
155
+ export type PoliticalAdDisclosure = SignedObject<{
156
+ v: 1;
157
+ type: 'provenance.political_ad';
158
+ artifact_hash: string;
159
+ sponsor: string;
160
+ jurisdiction: string;
161
+ ai_used: boolean;
162
+ ai_description?: string;
163
+ ts: string;
164
+ }>;
165
+ /** A sponsor discloses a political ad and whether AI made or altered it. */
166
+ export declare function disclosePoliticalAd(input: {
167
+ artifactHash: string;
168
+ sponsor: string;
169
+ jurisdiction: string;
170
+ aiUsed: boolean;
171
+ aiDescription?: string;
172
+ ts?: string;
173
+ }, sponsorPrivateKey: Uint8Array): PoliticalAdDisclosure;
174
+ /** An in-memory registry a regulator can run: accepts only valid disclosures, looks ads up by hash. */
175
+ export declare function createAdRegistry(): {
176
+ register(d: PoliticalAdDisclosure): void;
177
+ lookup: (artifactHash: string) => PoliticalAdDisclosure[];
178
+ aiAds: (jurisdiction?: string) => PoliticalAdDisclosure[];
179
+ };
180
+ /** Contributor shares (basis points summing to 10,000) for a work, hashed so payouts can cite it. */
181
+ export declare function royaltySplit(artifactHash: string, contributors: Array<{
182
+ did: string;
183
+ bps: number;
184
+ role?: string;
185
+ }>): {
186
+ hash: string;
187
+ v: 1;
188
+ type: "provenance.royalty_split";
189
+ artifact_hash: string;
190
+ contributors: {
191
+ did: string;
192
+ bps: number;
193
+ role?: string;
194
+ }[];
195
+ };
196
+ /** Pay out an amount in integer minor units by the split; remainders go by largest fraction, so the total is exact. */
197
+ export declare function splitPayout(split: ReturnType<typeof royaltySplit>, amountMinor: bigint): {
198
+ split: string;
199
+ payouts: {
200
+ did: string;
201
+ minor: string;
202
+ }[];
203
+ };
204
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAwD,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACtG,OAAO,EAAmD,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAMrG,eAAO,MAAM,UAAU,yBAAyB,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,iBAAiB;;;;;;EAE1D;AAED,yFAAyF;AACzF,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,MAAM;;;;;;;;;;EAOrH;AAED,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC;IAAE,CAAC,EAAE,CAAC,CAAC;IAAC,IAAI,EAAE,sBAAsB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEnL;;;GAGG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,iBAAiB,EAAE,CAAC,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,eAAe,EAAE,UAAU,GAAG,gBAAgB,C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AAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;;;;;;aAArC,MAAM;aAAO,MAAM;eAAS,MAAM;;EAM/G;AAED,uHAAuH;AACvH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,EAAE,WAAW,EAAE,MAAM;;;;;;EAStF"}
package/dist/media.js ADDED
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Provenance in the field: a C2PA assertion carrying the credential, watermark bindings,
3
+ * edit chains (human vs AI steps), newsroom co-signing, disputes by depicted people,
4
+ * AI-authored commits, text-and-data-mining reservations, feed labelling, a political-ad
5
+ * disclosure registry and exact royalty splits. Built on `buildContentCredential`.
6
+ */
7
+ import { hashPayload, jcsHash, signObject, verifySignedObject } from '@zanii/core';
8
+ import { buildContentCredential, verifyContentCredential } from './index.js';
9
+ // ------------------------------------------------------------------------------ //
10
+ // C2PA and watermarks
11
+ // ------------------------------------------------------------------------------ //
12
+ export const C2PA_LABEL = 'org.zanii.credential';
13
+ /**
14
+ * A custom assertion to place in a C2PA manifest (your C2PA SDK signs the manifest with
15
+ * its X.509 identity; this assertion links it to the agent's DID and receipt).
16
+ */
17
+ export function c2paAssertion(credential) {
18
+ return { label: C2PA_LABEL, data: { credential, credential_hash: jcsHash(credential) } };
19
+ }
20
+ /** Find and verify the Zanii assertion inside a C2PA manifest's assertions (as JSON). */
21
+ export function credentialFromC2pa(assertions, artifact) {
22
+ const a = assertions.find((x) => x.label === C2PA_LABEL);
23
+ if (!a)
24
+ return { found: false, ok: false, reasons: ['no Zanii assertion in the manifest'] };
25
+ const { credential, credential_hash } = a.data;
26
+ const check = verifyContentCredential(credential, artifact);
27
+ if (check.ok && jcsHash(credential) !== credential_hash)
28
+ check.reasons.push('assertion hash does not match the credential');
29
+ return { found: true, credential, ok: check.reasons.length === 0, reasons: check.reasons };
30
+ }
31
+ /**
32
+ * Bind an invisible watermark id to the credential, signed by the creating agent. The
33
+ * trust root for "this watermark is present" is the detector you name, not Zanii.
34
+ */
35
+ export function bindWatermark(credential, w, agentPrivateKey) {
36
+ return signObject({ v: 1, type: 'provenance.watermark', credential: jcsHash(credential), artifact_hash: credential.artifact_hash, detector: w.detector, watermark_id: w.watermarkId, ts: w.ts ?? new Date().toISOString() }, agentPrivateKey);
37
+ }
38
+ export function verifyWatermarkBinding(b, credential) {
39
+ return verifySignedObject(b) && b.signer === credential.agent && b.credential === jcsHash(credential);
40
+ }
41
+ /** A credential for an edited version, linking to the previous one and stating the edits. */
42
+ export function editVersion(previous, next, agentPrivateKey) {
43
+ return buildContentCredential({ artifact: next.artifact, agentDid: next.agentDid, createdAt: next.createdAt, meta: { derivative_of: jcsHash(previous), edits: next.edits } }, agentPrivateKey);
44
+ }
45
+ /** Verify a chain of versions (oldest first): every credential valid, every link and time in order; counts human and AI edits. */
46
+ export function verifyEditChain(chain) {
47
+ const reasons = [];
48
+ let human = 0;
49
+ let ai = 0;
50
+ chain.forEach((c, i) => {
51
+ if (!verifyContentCredential(c).ok)
52
+ reasons.push(`version ${i}: invalid credential`);
53
+ if (i === 0)
54
+ return;
55
+ if (c.meta?.derivative_of !== jcsHash(chain[i - 1]))
56
+ reasons.push(`version ${i}: does not link to version ${i - 1}`);
57
+ if (c.created_at < chain[i - 1].created_at)
58
+ reasons.push(`version ${i}: earlier than its predecessor`);
59
+ for (const e of (c.meta?.edits ?? []))
60
+ e.by === 'ai' ? ai++ : human++;
61
+ });
62
+ return { ok: reasons.length === 0, reasons, versions: chain.length, humanEdits: human, aiEdits: ai };
63
+ }
64
+ /** A journalist, editor or fact-checker countersigns an article's credential in a stated role. */
65
+ export function coSign(credential, role, privateKey, ts = new Date().toISOString()) {
66
+ return signObject({ v: 1, type: 'provenance.cosign', credential: jcsHash(credential), role, ts }, privateKey);
67
+ }
68
+ /** The credential is valid and every required role is countersigned by one of its allowed signers. */
69
+ export function verifyNewsroom(credential, cosigs, required) {
70
+ const reasons = verifyContentCredential(credential).reasons;
71
+ const h = jcsHash(credential);
72
+ for (const [role, signers] of Object.entries(required)) {
73
+ if (!cosigs.some((c) => c.role === role && c.credential === h && signers.includes(c.signer) && verifySignedObject(c)))
74
+ reasons.push(`no valid ${role} countersignature`);
75
+ }
76
+ return { ok: reasons.length === 0, reasons };
77
+ }
78
+ /** A person depicted in content disputes it, signed with their own DID, with hashes of their evidence. */
79
+ export function fileDispute(input, subjectPrivateKey) {
80
+ return signObject({ v: 1, type: 'provenance.dispute', artifact_hash: input.artifactHash, claim: input.claim, statement: input.statement, evidence: (input.evidence ?? []).map((e) => hashPayload(e)), ts: input.ts ?? new Date().toISOString() }, subjectPrivateKey);
81
+ }
82
+ /** For a platform: the dispute is genuine and about this artifact; includes whether the artifact had a valid credential at all. */
83
+ export function assessDispute(d, credential) {
84
+ return { disputeValid: verifySignedObject(d), subject: d.signer, claim: d.claim, credentialed: !!credential && credential.artifact_hash === d.artifact_hash && verifyContentCredential(credential).ok, creator: credential?.agent ?? null };
85
+ }
86
+ // ------------------------------------------------------------------------------ //
87
+ // Code, opt-outs, feeds, political ads, royalties
88
+ // ------------------------------------------------------------------------------ //
89
+ /** A credential for an AI-authored commit, plus a git trailer to put in the commit message. */
90
+ export function commitCredential(c, agentPrivateKey) {
91
+ if (!/^[0-9a-f]{40}([0-9a-f]{24})?$/.test(c.commit))
92
+ throw new Error('provenance: commit must be a full SHA-1 or SHA-256 hex id');
93
+ const credential = buildContentCredential({ artifact: `${c.repo}@${c.commit}`, agentDid: c.agentDid, createdAt: c.createdAt, meta: { kind: 'code', repo: c.repo, commit: c.commit, ...(c.reviewer ? { reviewer: c.reviewer } : {}) } }, agentPrivateKey);
94
+ return { credential, trailer: `Zanii-Credential: ${jcsHash(credential)}` };
95
+ }
96
+ /** A rightsholder's machine-readable text-and-data-mining reservation (EU CDSM Art. 4(3)) bound to an asset. */
97
+ export function reserveTdm(input, holderPrivateKey) {
98
+ return signObject({ v: 1, type: 'provenance.tdm_reservation', artifact_hash: input.artifactHash, reserved: input.reserved ?? true, ...(input.policyUrl ? { policy: input.policyUrl } : {}), ts: input.ts ?? new Date().toISOString() }, holderPrivateKey);
99
+ }
100
+ /** For a crawler: is mining this asset reserved? The latest valid statement from a trusted holder wins. */
101
+ export function tdmReserved(artifactHash, reservations, trustedHolders) {
102
+ const latest = reservations.filter((r) => r.artifact_hash === artifactHash && verifySignedObject(r) && (!trustedHolders || trustedHolders.includes(r.signer))).sort((a, b) => a.ts.localeCompare(b.ts)).at(-1);
103
+ return latest?.reserved ?? false;
104
+ }
105
+ /** Label every item in a feed from its credential: AI-generated by a named agent, credential invalid, or no credential. */
106
+ export function labelFeed(items) {
107
+ return items.map((i) => {
108
+ if (!i.credential)
109
+ return { id: i.id, label: 'no-credential', agent: null };
110
+ const ok = verifyContentCredential(i.credential, i.artifact).ok;
111
+ return { id: i.id, label: ok ? 'ai-generated' : 'credential-invalid', agent: ok ? i.credential.agent : null };
112
+ });
113
+ }
114
+ /** A sponsor discloses a political ad and whether AI made or altered it. */
115
+ export function disclosePoliticalAd(input, sponsorPrivateKey) {
116
+ return signObject({ v: 1, type: 'provenance.political_ad', artifact_hash: input.artifactHash, sponsor: input.sponsor, jurisdiction: input.jurisdiction, ai_used: input.aiUsed, ...(input.aiDescription ? { ai_description: input.aiDescription } : {}), ts: input.ts ?? new Date().toISOString() }, sponsorPrivateKey);
117
+ }
118
+ /** An in-memory registry a regulator can run: accepts only valid disclosures, looks ads up by hash. */
119
+ export function createAdRegistry() {
120
+ const byHash = new Map();
121
+ return {
122
+ register(d) {
123
+ if (!verifySignedObject(d))
124
+ throw new Error('provenance: invalid political ad disclosure');
125
+ byHash.set(d.artifact_hash, [...(byHash.get(d.artifact_hash) ?? []), d]);
126
+ },
127
+ lookup: (artifactHash) => byHash.get(artifactHash) ?? [],
128
+ aiAds: (jurisdiction) => [...byHash.values()].flat().filter((d) => d.ai_used && (!jurisdiction || d.jurisdiction === jurisdiction)),
129
+ };
130
+ }
131
+ /** Contributor shares (basis points summing to 10,000) for a work, hashed so payouts can cite it. */
132
+ export function royaltySplit(artifactHash, contributors) {
133
+ if (contributors.some((c) => !Number.isInteger(c.bps) || c.bps <= 0))
134
+ throw new Error('provenance: shares must be positive integer basis points');
135
+ const total = contributors.reduce((s, c) => s + c.bps, 0);
136
+ if (total !== 10_000)
137
+ throw new Error(`provenance: shares sum to ${total} bps, not 10000`);
138
+ const split = { v: 1, type: 'provenance.royalty_split', artifact_hash: artifactHash, contributors };
139
+ return { ...split, hash: jcsHash(split) };
140
+ }
141
+ /** Pay out an amount in integer minor units by the split; remainders go by largest fraction, so the total is exact. */
142
+ export function splitPayout(split, amountMinor) {
143
+ const raw = split.contributors.map((c) => ({ did: c.did, q: (amountMinor * BigInt(c.bps)) / 10000n, r: (amountMinor * BigInt(c.bps)) % 10000n }));
144
+ let left = amountMinor - raw.reduce((s, x) => s + x.q, 0n);
145
+ for (const x of [...raw].sort((a, b) => (b.r > a.r ? 1 : b.r < a.r ? -1 : 0))) {
146
+ if (left === 0n)
147
+ break;
148
+ x.q += 1n;
149
+ left -= 1n;
150
+ }
151
+ return { split: split.hash, payouts: raw.map((x) => ({ did: x.did, minor: x.q.toString() })) };
152
+ }
153
+ //# sourceMappingURL=media.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAqB,MAAM,aAAa,CAAC;AACtG,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAA0B,MAAM,YAAY,CAAC;AAErG,oFAAoF;AACpF,sBAAsB;AACtB,oFAAoF;AAEpF,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,UAA6B;IACzD,OAAO,EAAE,KAAK,EAAE,UAAU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G,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3D,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9E,IAAI,IAAI,KAAK,EAAE;YAAE,MAAM;QACvB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,IAAI,EAAE,CAAC;IACb,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;AACjG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zanii/provenance",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "AI-content provenance: sign an artifact's hash with the creating agent's did:key, anchor it on the ledger, and resolve the creator to their verified history — 'made by a known, accountable agent' vs 'appeared from nowhere'.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://ledger.zanii.agency",
@@ -33,8 +33,8 @@
33
33
  "dependencies": {
34
34
  "@noble/curves": "^1.8.1",
35
35
  "@noble/hashes": "^1.7.1",
36
- "@zanii/core": "0.4.0",
37
- "@zanii/a2a-directory": "0.1.0"
36
+ "@zanii/a2a-directory": "^0.1.3",
37
+ "@zanii/core": "^0.5.4"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsc -p tsconfig.build.json",
package/src/index.ts CHANGED
@@ -123,3 +123,4 @@ export async function resolveCreator(
123
123
  ): Promise<AgentTrust | null> {
124
124
  return resolveAgent(credential.agent, opts);
125
125
  }
126
+ export * from './media.js';
package/src/media.ts ADDED
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Provenance in the field: a C2PA assertion carrying the credential, watermark bindings,
3
+ * edit chains (human vs AI steps), newsroom co-signing, disputes by depicted people,
4
+ * AI-authored commits, text-and-data-mining reservations, feed labelling, a political-ad
5
+ * disclosure registry and exact royalty splits. Built on `buildContentCredential`.
6
+ */
7
+ import { hashPayload, jcsHash, signObject, verifySignedObject, type SignedObject } from '@zanii/core';
8
+ import { buildContentCredential, verifyContentCredential, type ContentCredential } from './index.js';
9
+
10
+ // ------------------------------------------------------------------------------ //
11
+ // C2PA and watermarks
12
+ // ------------------------------------------------------------------------------ //
13
+
14
+ export const C2PA_LABEL = 'org.zanii.credential';
15
+
16
+ /**
17
+ * A custom assertion to place in a C2PA manifest (your C2PA SDK signs the manifest with
18
+ * its X.509 identity; this assertion links it to the agent's DID and receipt).
19
+ */
20
+ export function c2paAssertion(credential: ContentCredential) {
21
+ return { label: C2PA_LABEL, data: { credential, credential_hash: jcsHash(credential) } };
22
+ }
23
+
24
+ /** Find and verify the Zanii assertion inside a C2PA manifest's assertions (as JSON). */
25
+ export function credentialFromC2pa(assertions: Array<{ label: string; data: unknown }>, artifact?: Uint8Array | string) {
26
+ const a = assertions.find((x) => x.label === C2PA_LABEL);
27
+ if (!a) return { found: false as const, ok: false, reasons: ['no Zanii assertion in the manifest'] };
28
+ const { credential, credential_hash } = a.data as { credential: ContentCredential; credential_hash: string };
29
+ const check = verifyContentCredential(credential, artifact);
30
+ if (check.ok && jcsHash(credential) !== credential_hash) check.reasons.push('assertion hash does not match the credential');
31
+ return { found: true as const, credential, ok: check.reasons.length === 0, reasons: check.reasons };
32
+ }
33
+
34
+ export type WatermarkBinding = SignedObject<{ v: 1; type: 'provenance.watermark'; credential: string; artifact_hash: string; detector: string; watermark_id: string; ts: string }>;
35
+
36
+ /**
37
+ * Bind an invisible watermark id to the credential, signed by the creating agent. The
38
+ * trust root for "this watermark is present" is the detector you name, not Zanii.
39
+ */
40
+ export function bindWatermark(credential: ContentCredential, w: { detector: string; watermarkId: string; ts?: string }, agentPrivateKey: Uint8Array): WatermarkBinding {
41
+ return signObject({ v: 1 as const, type: 'provenance.watermark' as const, credential: jcsHash(credential), artifact_hash: credential.artifact_hash, detector: w.detector, watermark_id: w.watermarkId, ts: w.ts ?? new Date().toISOString() }, agentPrivateKey);
42
+ }
43
+
44
+ export function verifyWatermarkBinding(b: WatermarkBinding, credential: ContentCredential): boolean {
45
+ return verifySignedObject(b) && b.signer === credential.agent && b.credential === jcsHash(credential);
46
+ }
47
+
48
+ // ------------------------------------------------------------------------------ //
49
+ // Edits, newsrooms, disputes
50
+ // ------------------------------------------------------------------------------ //
51
+
52
+ export interface EditStep {
53
+ by: 'human' | 'ai';
54
+ description: string;
55
+ }
56
+
57
+ /** A credential for an edited version, linking to the previous one and stating the edits. */
58
+ export function editVersion(previous: ContentCredential, next: { artifact: Uint8Array | string; agentDid: string; createdAt: string; edits: EditStep[] }, agentPrivateKey: Uint8Array): ContentCredential {
59
+ return buildContentCredential({ artifact: next.artifact, agentDid: next.agentDid, createdAt: next.createdAt, meta: { derivative_of: jcsHash(previous), edits: next.edits } }, agentPrivateKey);
60
+ }
61
+
62
+ /** Verify a chain of versions (oldest first): every credential valid, every link and time in order; counts human and AI edits. */
63
+ export function verifyEditChain(chain: ContentCredential[]) {
64
+ const reasons: string[] = [];
65
+ let human = 0;
66
+ let ai = 0;
67
+ chain.forEach((c, i) => {
68
+ if (!verifyContentCredential(c).ok) reasons.push(`version ${i}: invalid credential`);
69
+ if (i === 0) return;
70
+ if ((c.meta as { derivative_of?: string } | undefined)?.derivative_of !== jcsHash(chain[i - 1]!)) reasons.push(`version ${i}: does not link to version ${i - 1}`);
71
+ if (c.created_at < chain[i - 1]!.created_at) reasons.push(`version ${i}: earlier than its predecessor`);
72
+ for (const e of ((c.meta as { edits?: EditStep[] } | undefined)?.edits ?? [])) e.by === 'ai' ? ai++ : human++;
73
+ });
74
+ return { ok: reasons.length === 0, reasons, versions: chain.length, humanEdits: human, aiEdits: ai };
75
+ }
76
+
77
+ export type CoSignature = SignedObject<{ v: 1; type: 'provenance.cosign'; credential: string; role: string; ts: string }>;
78
+
79
+ /** A journalist, editor or fact-checker countersigns an article's credential in a stated role. */
80
+ export function coSign(credential: ContentCredential, role: string, privateKey: Uint8Array, ts = new Date().toISOString()): CoSignature {
81
+ return signObject({ v: 1 as const, type: 'provenance.cosign' as const, credential: jcsHash(credential), role, ts }, privateKey);
82
+ }
83
+
84
+ /** The credential is valid and every required role is countersigned by one of its allowed signers. */
85
+ export function verifyNewsroom(credential: ContentCredential, cosigs: CoSignature[], required: Record<string, string[]>) {
86
+ const reasons = verifyContentCredential(credential).reasons;
87
+ const h = jcsHash(credential);
88
+ for (const [role, signers] of Object.entries(required)) {
89
+ if (!cosigs.some((c) => c.role === role && c.credential === h && signers.includes(c.signer) && verifySignedObject(c))) reasons.push(`no valid ${role} countersignature`);
90
+ }
91
+ return { ok: reasons.length === 0, reasons };
92
+ }
93
+
94
+ export type Dispute = SignedObject<{ v: 1; type: 'provenance.dispute'; artifact_hash: string; claim: 'not_me' | 'not_consented' | 'altered'; statement: string; evidence: string[]; ts: string }>;
95
+
96
+ /** A person depicted in content disputes it, signed with their own DID, with hashes of their evidence. */
97
+ export function fileDispute(input: { artifactHash: string; claim: Dispute['claim']; statement: string; evidence?: Array<Uint8Array | string>; ts?: string }, subjectPrivateKey: Uint8Array): Dispute {
98
+ return signObject({ v: 1 as const, type: 'provenance.dispute' as const, artifact_hash: input.artifactHash, claim: input.claim, statement: input.statement, evidence: (input.evidence ?? []).map((e) => hashPayload(e)), ts: input.ts ?? new Date().toISOString() }, subjectPrivateKey);
99
+ }
100
+
101
+ /** For a platform: the dispute is genuine and about this artifact; includes whether the artifact had a valid credential at all. */
102
+ export function assessDispute(d: Dispute, credential?: ContentCredential) {
103
+ return { disputeValid: verifySignedObject(d), subject: d.signer, claim: d.claim, credentialed: !!credential && credential.artifact_hash === d.artifact_hash && verifyContentCredential(credential).ok, creator: credential?.agent ?? null };
104
+ }
105
+
106
+ // ------------------------------------------------------------------------------ //
107
+ // Code, opt-outs, feeds, political ads, royalties
108
+ // ------------------------------------------------------------------------------ //
109
+
110
+ /** A credential for an AI-authored commit, plus a git trailer to put in the commit message. */
111
+ export function commitCredential(c: { repo: string; commit: string; agentDid: string; reviewer?: string; createdAt: string }, agentPrivateKey: Uint8Array) {
112
+ if (!/^[0-9a-f]{40}([0-9a-f]{24})?$/.test(c.commit)) throw new Error('provenance: commit must be a full SHA-1 or SHA-256 hex id');
113
+ const credential = buildContentCredential({ artifact: `${c.repo}@${c.commit}`, agentDid: c.agentDid, createdAt: c.createdAt, meta: { kind: 'code', repo: c.repo, commit: c.commit, ...(c.reviewer ? { reviewer: c.reviewer } : {}) } }, agentPrivateKey);
114
+ return { credential, trailer: `Zanii-Credential: ${jcsHash(credential)}` };
115
+ }
116
+
117
+ export type TdmReservation = SignedObject<{ v: 1; type: 'provenance.tdm_reservation'; artifact_hash: string; reserved: boolean; policy?: string; ts: string }>;
118
+
119
+ /** A rightsholder's machine-readable text-and-data-mining reservation (EU CDSM Art. 4(3)) bound to an asset. */
120
+ export function reserveTdm(input: { artifactHash: string; reserved?: boolean; policyUrl?: string; ts?: string }, holderPrivateKey: Uint8Array): TdmReservation {
121
+ return signObject({ v: 1 as const, type: 'provenance.tdm_reservation' as const, artifact_hash: input.artifactHash, reserved: input.reserved ?? true, ...(input.policyUrl ? { policy: input.policyUrl } : {}), ts: input.ts ?? new Date().toISOString() }, holderPrivateKey);
122
+ }
123
+
124
+ /** For a crawler: is mining this asset reserved? The latest valid statement from a trusted holder wins. */
125
+ export function tdmReserved(artifactHash: string, reservations: TdmReservation[], trustedHolders?: string[]): boolean {
126
+ const latest = reservations.filter((r) => r.artifact_hash === artifactHash && verifySignedObject(r) && (!trustedHolders || trustedHolders.includes(r.signer))).sort((a, b) => a.ts.localeCompare(b.ts)).at(-1);
127
+ return latest?.reserved ?? false;
128
+ }
129
+
130
+ /** Label every item in a feed from its credential: AI-generated by a named agent, credential invalid, or no credential. */
131
+ export function labelFeed(items: Array<{ id: string; artifact?: Uint8Array | string; credential?: ContentCredential }>) {
132
+ return items.map((i) => {
133
+ if (!i.credential) return { id: i.id, label: 'no-credential' as const, agent: null };
134
+ const ok = verifyContentCredential(i.credential, i.artifact).ok;
135
+ return { id: i.id, label: ok ? ('ai-generated' as const) : ('credential-invalid' as const), agent: ok ? i.credential.agent : null };
136
+ });
137
+ }
138
+
139
+ export type PoliticalAdDisclosure = SignedObject<{ v: 1; type: 'provenance.political_ad'; artifact_hash: string; sponsor: string; jurisdiction: string; ai_used: boolean; ai_description?: string; ts: string }>;
140
+
141
+ /** A sponsor discloses a political ad and whether AI made or altered it. */
142
+ export function disclosePoliticalAd(input: { artifactHash: string; sponsor: string; jurisdiction: string; aiUsed: boolean; aiDescription?: string; ts?: string }, sponsorPrivateKey: Uint8Array): PoliticalAdDisclosure {
143
+ return signObject({ v: 1 as const, type: 'provenance.political_ad' as const, artifact_hash: input.artifactHash, sponsor: input.sponsor, jurisdiction: input.jurisdiction, ai_used: input.aiUsed, ...(input.aiDescription ? { ai_description: input.aiDescription } : {}), ts: input.ts ?? new Date().toISOString() }, sponsorPrivateKey);
144
+ }
145
+
146
+ /** An in-memory registry a regulator can run: accepts only valid disclosures, looks ads up by hash. */
147
+ export function createAdRegistry() {
148
+ const byHash = new Map<string, PoliticalAdDisclosure[]>();
149
+ return {
150
+ register(d: PoliticalAdDisclosure) {
151
+ if (!verifySignedObject(d)) throw new Error('provenance: invalid political ad disclosure');
152
+ byHash.set(d.artifact_hash, [...(byHash.get(d.artifact_hash) ?? []), d]);
153
+ },
154
+ lookup: (artifactHash: string) => byHash.get(artifactHash) ?? [],
155
+ aiAds: (jurisdiction?: string) => [...byHash.values()].flat().filter((d) => d.ai_used && (!jurisdiction || d.jurisdiction === jurisdiction)),
156
+ };
157
+ }
158
+
159
+ /** Contributor shares (basis points summing to 10,000) for a work, hashed so payouts can cite it. */
160
+ export function royaltySplit(artifactHash: string, contributors: Array<{ did: string; bps: number; role?: string }>) {
161
+ if (contributors.some((c) => !Number.isInteger(c.bps) || c.bps <= 0)) throw new Error('provenance: shares must be positive integer basis points');
162
+ const total = contributors.reduce((s, c) => s + c.bps, 0);
163
+ if (total !== 10_000) throw new Error(`provenance: shares sum to ${total} bps, not 10000`);
164
+ const split = { v: 1 as const, type: 'provenance.royalty_split' as const, artifact_hash: artifactHash, contributors };
165
+ return { ...split, hash: jcsHash(split) };
166
+ }
167
+
168
+ /** Pay out an amount in integer minor units by the split; remainders go by largest fraction, so the total is exact. */
169
+ export function splitPayout(split: ReturnType<typeof royaltySplit>, amountMinor: bigint) {
170
+ const raw = split.contributors.map((c) => ({ did: c.did, q: (amountMinor * BigInt(c.bps)) / 10_000n, r: (amountMinor * BigInt(c.bps)) % 10_000n }));
171
+ let left = amountMinor - raw.reduce((s, x) => s + x.q, 0n);
172
+ for (const x of [...raw].sort((a, b) => (b.r > a.r ? 1 : b.r < a.r ? -1 : 0))) {
173
+ if (left === 0n) break;
174
+ x.q += 1n;
175
+ left -= 1n;
176
+ }
177
+ return { split: split.hash, payouts: raw.map((x) => ({ did: x.did, minor: x.q.toString() })) };
178
+ }