From 4a4545482f8d54312da68108bb082f72ea9f4ed5 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 12 Nov 2024 11:36:02 +0100 Subject: [PATCH] Training and Data Mining Assertion: Always write entries field --- .changeset/happy-suns-listen.md | 5 +++++ .../assertions/TrainingAndDataMiningAssertion.ts | 11 +++++------ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .changeset/happy-suns-listen.md diff --git a/.changeset/happy-suns-listen.md b/.changeset/happy-suns-listen.md new file mode 100644 index 0000000..2b5407c --- /dev/null +++ b/.changeset/happy-suns-listen.md @@ -0,0 +1,5 @@ +--- +'@trustnxt/c2pa-ts': patch +--- + +Update Training and Data Mining assertion according to CAWG spec update diff --git a/src/manifest/assertions/TrainingAndDataMiningAssertion.ts b/src/manifest/assertions/TrainingAndDataMiningAssertion.ts index 57d74fa..4772f90 100644 --- a/src/manifest/assertions/TrainingAndDataMiningAssertion.ts +++ b/src/manifest/assertions/TrainingAndDataMiningAssertion.ts @@ -6,9 +6,8 @@ import { ValidationError } from '../ValidationError'; import { Assertion } from './Assertion'; import { AssertionLabels } from './AssertionLabels'; -// The specification is unclear about whether the individual entries should go into the `entries` field or -// directly into the top level of the payload content. Thus we support reading both. When writing, we include -// the `entries` field for the C2PA 1.x version of the assertion and omit it for the CAWG version. +// Early versions of the specification were unclear about whether the individual entries should go into +// the `entries` field or directly into the top level of the payload content. Thus we support reading both. // See also: https://github.com/creator-assertions/training-and-data-mining-assertion/issues/3 type RawTrainingMiningMap = Record & { entries?: Record; @@ -59,16 +58,16 @@ export class TrainingAndDataMiningAssertion extends Assertion { public generateJUMBFBoxForContent(): IBox { if (!Object.keys(this.entries).length) throw new Error('Assertion has no entries'); - const content: Record = {}; + const rawEntries: Record = {}; for (const [key, entry] of Object.entries(this.entries)) { - content[key] = { + rawEntries[key] = { use: entry.choice, constraint_info: entry.constraintInfo, }; } const box = new CBORBox(); - box.content = this.isCAWG ? content : { entries: content }; + box.content = { entries: rawEntries }; return box; } }