Skip to content

Commit cd68747

Browse files
authored
feat: update c2pa rs + enable fetch_remote_manifests (#15)
* feat: update c2pa-rs, enable fetch_remote_manifests * chore: changeset * fix: do not include development exports field in published build * feat: add support for cawg trust * chore: changeset
1 parent 1c41d72 commit cd68747

19 files changed

+758
-495
lines changed

.changeset/lazy-actors-pump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@contentauth/c2pa-web': patch
3+
---
4+
5+
Remove incorrect "development" field from package.json exports in published builds

.changeset/major-tires-make.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@contentauth/c2pa-wasm': patch
3+
'@contentauth/c2pa-web': patch
4+
---
5+
6+
Update to c2pa-rs 0.62.0 and enable remote manifest fetching

Cargo.lock

Lines changed: 55 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/c2pa-wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ console_log = { version = "1.0.0", features = ["color"] }
2222
log = "0.4.27"
2323
js-sys = "0.3.77"
2424
wasm-bindgen-futures = "0.4.50"
25-
c2pa = { version = "0.58.0", features = ["pdf", "rust_native_crypto"], default-features = false }
25+
c2pa = { version = "0.62.0", features = ["pdf", "rust_native_crypto", "fetch_remote_manifests"], default-features = false }
2626
async-trait = "0.1.88"
2727
thiserror = "2.0.12"
2828

packages/c2pa-web/eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default [
1717
'error',
1818
{
1919
ignoredFiles: [
20+
'{projectRoot}/test/**/*',
2021
'{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}',
2122
'{projectRoot}/vite.config.{js,ts,mjs,mts}',
2223
],

packages/c2pa-web/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,23 @@
1212
"./package.json": "./package.json",
1313
"./resources/c2pa.wasm": "./dist/resources/c2pa_bg.wasm",
1414
".": {
15+
"development": "./src/index.ts",
1516
"types": "./dist/index.d.ts",
1617
"import": "./dist/index.js",
1718
"default": "./dist/index.js"
1819
}
1920
},
21+
"publishConfig": {
22+
"exports": {
23+
"./package.json": "./package.json",
24+
"./resources/c2pa.wasm": "./dist/resources/c2pa_bg.wasm",
25+
".": {
26+
"types": "./dist/index.d.ts",
27+
"import": "./dist/index.js",
28+
"default": "./dist/index.js"
29+
}
30+
}
31+
},
2032
"dependencies": {
2133
"@contentauth/c2pa-wasm": "workspace:*"
2234
},

packages/c2pa-web/src/lib/c2pa.spec.ts

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* Copyright 2025 Adobe
43
* All Rights Reserved.
@@ -15,15 +14,16 @@ import wasmSrc from '@contentauth/c2pa-wasm/assets/c2pa_bg.wasm?url';
1514

1615
import C_with_CAWG_data from '../../test/fixtures/assets/C_with_CAWG_data.jpg';
1716
import C_with_CAWG_data_thumbnail from '../../test/fixtures/assets/C_with_CAWG_data_thumbnail.jpg';
18-
import C_with_CAWG_data_ManifestStore from '../../test/fixtures/assets/C_with_CAWG_data.json' with { type: "json" };
19-
import C_with_CAWG_data_trusted_ManifestStore from '../../test/fixtures/assets/C_with_CAWG_data_trusted.json' with { type: "json" };
20-
import C_with_CAWG_data_untrusted_ManifestStore from '../../test/fixtures/assets/C_with_CAWG_data_untrusted.json' with { type: "json" };
17+
import C_with_CAWG_data_ManifestStore from '../../test/fixtures/manifests/C_with_CAWG_data.js';
18+
import C_with_CAWG_data_trusted_ManifestStore from '../../test/fixtures/manifests/C_with_CAWG_data_trusted.js';
19+
import C_with_CAWG_data_untrusted_ManifestStore from '../../test/fixtures/manifests/C_with_CAWG_data_untrusted.js';
2120
import no_alg from '../../test/fixtures/assets/no_alg.jpg';
2221
import dashinit from '../../test/fixtures/assets/dashinit.mp4';
2322
import dash1 from '../../test/fixtures/assets/dash1.m4s?url';
24-
import dashinit_ManifestStore from '../../test/fixtures/assets/dashinit.json' with { type: "json" };
23+
import dashinit_ManifestStore from '../../test/fixtures/manifests/dashinit.js';
2524

2625
import anchor_correct from '../../test/fixtures/trust/anchor-correct.pem?raw';
26+
import anchor_cawg from '../../test/fixtures/trust/anchor-cawg.pem?raw';
2727
import anchor_incorrect from '../../test/fixtures/trust/anchor-incorrect.pem?raw';
2828

2929
describe('c2pa', () => {
@@ -33,8 +33,8 @@ describe('c2pa', () => {
3333

3434
const blob = await getBlobForAsset(C_with_CAWG_data);
3535

36-
const reader = await c2pa.reader.fromBlob(blob.type, blob)
37-
36+
const reader = await c2pa.reader.fromBlob(blob.type, blob);
37+
3838
const manifestStore = await reader.manifestStore();
3939

4040
expect(manifestStore).toEqual(C_with_CAWG_data_ManifestStore);
@@ -47,7 +47,7 @@ describe('c2pa', () => {
4747

4848
const blob = await getBlobForAsset(C_with_CAWG_data);
4949

50-
const reader = await c2pa.reader.fromBlob(blob.type, blob)
50+
const reader = await c2pa.reader.fromBlob(blob.type, blob);
5151

5252
const manifestStore = await reader.manifestStore();
5353

@@ -58,9 +58,7 @@ describe('c2pa', () => {
5858
const thumbnailBuffer = await reader.resourceToBuffer(thumbnailId);
5959
const thumbnail = new Uint8Array(thumbnailBuffer!);
6060

61-
const thumbnailBlob = await getBlobForAsset(
62-
C_with_CAWG_data_thumbnail
63-
);
61+
const thumbnailBlob = await getBlobForAsset(C_with_CAWG_data_thumbnail);
6462

6563
const expectedThumbnailBuffer = await thumbnailBlob.arrayBuffer();
6664

@@ -78,18 +76,23 @@ describe('c2pa', () => {
7876

7977
const readerPromise = c2pa.reader.fromBlob(blob.type, blob);
8078

81-
await expect(readerPromise).rejects.toThrowError('C2pa(UnknownAlgorithm)');
79+
await expect(readerPromise).rejects.toThrowError(
80+
'C2pa(UnknownAlgorithm)'
81+
);
8282
});
8383

8484
test('should report a trusted asset when when configured to verify trust', async () => {
8585
const settings: Settings = {
8686
trust: {
8787
trustAnchors: anchor_correct,
8888
},
89+
cawgTrust: {
90+
trustAnchors: anchor_cawg,
91+
},
8992
verify: {
90-
verifyTrust: true
91-
}
92-
}
93+
verifyTrust: true,
94+
},
95+
};
9396

9497
const c2pa = await createC2pa({ wasmSrc, settings });
9598

@@ -110,9 +113,9 @@ describe('c2pa', () => {
110113
trustAnchors: anchor_incorrect,
111114
},
112115
verify: {
113-
verifyTrust: true
114-
}
115-
}
116+
verifyTrust: true,
117+
},
118+
};
116119

117120
const c2pa = await createC2pa({ wasmSrc, settings });
118121

@@ -133,7 +136,11 @@ describe('c2pa', () => {
133136
const initBlob = await getBlobForAsset(dashinit);
134137
const fragmentBlob = await getBlobForAsset(dash1);
135138

136-
const reader = await c2pa.reader.fromBlobFragment(initBlob.type, initBlob, fragmentBlob);
139+
const reader = await c2pa.reader.fromBlobFragment(
140+
initBlob.type,
141+
initBlob,
142+
fragmentBlob
143+
);
137144

138145
const manifestStore = await reader.manifestStore();
139146

@@ -157,7 +164,6 @@ describe('c2pa', () => {
157164
});
158165
});
159166

160-
161167
async function getBlobForAsset(src: string): Promise<Blob> {
162168
const response = await fetch(src);
163169
const blob = await response.blob();

packages/c2pa-web/src/lib/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
export interface Settings {
1111
trust?: TrustSettings;
12+
cawgTrust?: TrustSettings;
1213
verify?: VerifySettings;
1314
}
1415

129 KB
Loading

0 commit comments

Comments
 (0)