1
-
2
1
/**
3
2
* Copyright 2025 Adobe
4
3
* All Rights Reserved.
@@ -15,15 +14,16 @@ import wasmSrc from '@contentauth/c2pa-wasm/assets/c2pa_bg.wasm?url';
15
14
16
15
import C_with_CAWG_data from '../../test/fixtures/assets/C_with_CAWG_data.jpg' ;
17
16
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' ;
21
20
import no_alg from '../../test/fixtures/assets/no_alg.jpg' ;
22
21
import dashinit from '../../test/fixtures/assets/dashinit.mp4' ;
23
22
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' ;
25
24
26
25
import anchor_correct from '../../test/fixtures/trust/anchor-correct.pem?raw' ;
26
+ import anchor_cawg from '../../test/fixtures/trust/anchor-cawg.pem?raw' ;
27
27
import anchor_incorrect from '../../test/fixtures/trust/anchor-incorrect.pem?raw' ;
28
28
29
29
describe ( 'c2pa' , ( ) => {
@@ -33,8 +33,8 @@ describe('c2pa', () => {
33
33
34
34
const blob = await getBlobForAsset ( C_with_CAWG_data ) ;
35
35
36
- const reader = await c2pa . reader . fromBlob ( blob . type , blob )
37
-
36
+ const reader = await c2pa . reader . fromBlob ( blob . type , blob ) ;
37
+
38
38
const manifestStore = await reader . manifestStore ( ) ;
39
39
40
40
expect ( manifestStore ) . toEqual ( C_with_CAWG_data_ManifestStore ) ;
@@ -47,7 +47,7 @@ describe('c2pa', () => {
47
47
48
48
const blob = await getBlobForAsset ( C_with_CAWG_data ) ;
49
49
50
- const reader = await c2pa . reader . fromBlob ( blob . type , blob )
50
+ const reader = await c2pa . reader . fromBlob ( blob . type , blob ) ;
51
51
52
52
const manifestStore = await reader . manifestStore ( ) ;
53
53
@@ -58,9 +58,7 @@ describe('c2pa', () => {
58
58
const thumbnailBuffer = await reader . resourceToBuffer ( thumbnailId ) ;
59
59
const thumbnail = new Uint8Array ( thumbnailBuffer ! ) ;
60
60
61
- const thumbnailBlob = await getBlobForAsset (
62
- C_with_CAWG_data_thumbnail
63
- ) ;
61
+ const thumbnailBlob = await getBlobForAsset ( C_with_CAWG_data_thumbnail ) ;
64
62
65
63
const expectedThumbnailBuffer = await thumbnailBlob . arrayBuffer ( ) ;
66
64
@@ -78,18 +76,23 @@ describe('c2pa', () => {
78
76
79
77
const readerPromise = c2pa . reader . fromBlob ( blob . type , blob ) ;
80
78
81
- await expect ( readerPromise ) . rejects . toThrowError ( 'C2pa(UnknownAlgorithm)' ) ;
79
+ await expect ( readerPromise ) . rejects . toThrowError (
80
+ 'C2pa(UnknownAlgorithm)'
81
+ ) ;
82
82
} ) ;
83
83
84
84
test ( 'should report a trusted asset when when configured to verify trust' , async ( ) => {
85
85
const settings : Settings = {
86
86
trust : {
87
87
trustAnchors : anchor_correct ,
88
88
} ,
89
+ cawgTrust : {
90
+ trustAnchors : anchor_cawg ,
91
+ } ,
89
92
verify : {
90
- verifyTrust : true
91
- }
92
- }
93
+ verifyTrust : true ,
94
+ } ,
95
+ } ;
93
96
94
97
const c2pa = await createC2pa ( { wasmSrc, settings } ) ;
95
98
@@ -110,9 +113,9 @@ describe('c2pa', () => {
110
113
trustAnchors : anchor_incorrect ,
111
114
} ,
112
115
verify : {
113
- verifyTrust : true
114
- }
115
- }
116
+ verifyTrust : true ,
117
+ } ,
118
+ } ;
116
119
117
120
const c2pa = await createC2pa ( { wasmSrc, settings } ) ;
118
121
@@ -133,7 +136,11 @@ describe('c2pa', () => {
133
136
const initBlob = await getBlobForAsset ( dashinit ) ;
134
137
const fragmentBlob = await getBlobForAsset ( dash1 ) ;
135
138
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
+ ) ;
137
144
138
145
const manifestStore = await reader . manifestStore ( ) ;
139
146
@@ -157,7 +164,6 @@ describe('c2pa', () => {
157
164
} ) ;
158
165
} ) ;
159
166
160
-
161
167
async function getBlobForAsset ( src : string ) : Promise < Blob > {
162
168
const response = await fetch ( src ) ;
163
169
const blob = await response . blob ( ) ;
0 commit comments