Skip to content

fix(deps): upgrade c2pa-node to 0.12.3 and keep post-sign verification - #9406

Open
bokelley wants to merge 1 commit into
mainfrom
deps/c2pa-node-0.12
Open

bokelley wants to merge 1 commit into
mainfrom
deps/c2pa-node-0.12

Conversation

@bokelley

@bokelley bokelley commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Upgrades @contentauth/c2pa-node from 0.10.0 to 0.12.3 and ports server/src/services/c2pa.ts to its API. Every AI-generated portrait and illustration AAO signs keeps the same content credentials. This also unblocks the grouped dependabot PR #9403, which bumps c2pa-node to 0.11 and fails to compile: SettingsContext is no longer exported, and Builder.withJson is gone.

Once this lands, dependabot rebases #9403 without its c2pa change.

API mapping

0.10 0.12.3
type SettingsContext (raw settings object) new Context(settings)
Builder.withJson(json, settings) (sync) await Builder.withJsonAsync(json, context)
Reader.fromAsset(asset, settings?) Reader.fromAsset(asset, context?). Our callers pass no second argument, so nothing changes.
LocalSigner.newSigner(...), setIntent, addAssertion, builder.sign Unchanged

signC2PA is now async. All four callers await it inside their existing try blocks: portrait-generator.ts, illustration-generator.ts, scripts/generate-images.ts and scripts/backfill-c2pa-static.ts. The unit test now uses .rejects.toThrow.

Settings: this keeps what production actually ran

Up to 0.10, the old BUILDER_SETTINGS object (verify.verifyAfterSign: false, trust.verifyTrustList: false) was passed to c2pa-rs untouched, with camelCase keys. c2pa-rs reads only snake_case keys and ignores unknown ones, so neither setting ever took effect. A deliberately invalid value under verify_after_sign fails to parse; the same value under verifyAfterSign signs without complaint. Production therefore signed with c2pa-rs defaults, including verify_after_sign = true. A self-signed cert doesn't make that check fail: the sign succeeds and reports signingCredential.untrusted.

0.12.3's Context does convert and apply settings. A literal port, verifyAfterSign: false, would have turned off a post-sign check that has always run. So this PR pins the effective behaviour:

  • verify.verifyAfterSign: true. Unchanged from what production ran.
  • trust.verifyTrustList: false. It has no c2pa-rs counterpart; Context treats it as "add no trust anchors". We configure none, so it contributes nothing, as before.

The code comment records this history.

Signed output, old vs new

Same inputs and the same self-signed cert:

  • Unchanged: validation state Valid; the same status codes (signingCredential.untrusted only); title, instance_id, claim_generator_info name and version, both assertions' data, Es256, issuer, and the trainedAlgorithmicMedia source type.
  • Changed by the library, not by our settings:
    • The org.contentauth.c2pa_rs claim-generator entry goes from 0.91.10 to 0.92.4.
    • Claim structure: c2pa.actions.v2 and the thumbnail move from gathered to created assertions (created = actions, thumbnail, hash.data; gathered = the AAO generation assertion), so AAO now attests to the AI-generation action. No repo code depends on assertion placement.
    • The manifest grows by about 145 bytes.
  • Not exercised: timestamping via C2PA_TSA_URL. The LocalSigner API that takes the TSA URL is unchanged.

Install and runtime

  • The lockfile changes only @contentauth/c2pa-node (0.10.0 → 0.12.3), c2pa-types (0.7.8 → 0.8.0) and c2pa-utilities (0.4.0 → 0.5.3).
  • The npm tarball bundles a linux-x64 dist/index.node that needs glibc 2.34 or newer; the image's Debian bookworm has 2.36. The Dockerfile's npm ci --ignore-scripts ships that bundled binary, the same as with 0.10.0. The postinstall script is unchanged, and the allowScripts pin is left alone.

Tests

  • tsc --project server/tsconfig.json: clean.
  • c2pa.test.ts, portrait-c2pa-wiring.test.ts and illustration-c2pa-wiring.test.ts: 23/23 pass on 0.12.3, including real signing through the native module.

No changeset: this is a server dependency, not a protocol package.

🤖 Generated with Claude Code

c2pa-node 0.11 removed SettingsContext and the synchronous Builder.withJson.
Port signC2PA to Context and Builder.withJsonAsync. The 0.10 settings object
used camelCase keys that c2pa-rs ignored, so production always signed with
c2pa-rs defaults; pin verifyAfterSign true to keep that behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant