@svta/cml-c2pa 1.3.0 → 1.4.1
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 +5 -1
- package/dist/index.d.ts +260 -236
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +734 -368
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { ValueOf } from "@svta/cml-utils";
|
|
2
|
-
|
|
3
2
|
//#region src/C2paAssertion.d.ts
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
|
-
* A C2PA assertion within a manifest
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
4
|
+
* A C2PA assertion within a manifest
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
10
8
|
type C2paAssertion = {
|
|
11
9
|
readonly label: string;
|
|
12
10
|
readonly data: unknown;
|
|
@@ -14,10 +12,10 @@ type C2paAssertion = {
|
|
|
14
12
|
//#endregion
|
|
15
13
|
//#region src/C2paSignatureInfo.d.ts
|
|
16
14
|
/**
|
|
17
|
-
* Signature information extracted from a C2PA claim
|
|
18
|
-
*
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
15
|
+
* Signature information extracted from a C2PA claim
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
21
19
|
type C2paSignatureInfo = {
|
|
22
20
|
readonly issuer: string | null;
|
|
23
21
|
readonly certNotBefore: string | null;
|
|
@@ -25,10 +23,10 @@ type C2paSignatureInfo = {
|
|
|
25
23
|
//#endregion
|
|
26
24
|
//#region src/C2paManifest.d.ts
|
|
27
25
|
/**
|
|
28
|
-
* A C2PA manifest (the active manifest within a manifest store)
|
|
29
|
-
*
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
26
|
+
* A C2PA manifest (the active manifest within a manifest store)
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
32
30
|
type C2paManifest = {
|
|
33
31
|
readonly label: string;
|
|
34
32
|
readonly instanceId: string | null;
|
|
@@ -39,20 +37,24 @@ type C2paManifest = {
|
|
|
39
37
|
//#endregion
|
|
40
38
|
//#region src/C2paStatusCode.d.ts
|
|
41
39
|
/**
|
|
42
|
-
* Standard C2PA validation status codes for manifest integrity checks,
|
|
43
|
-
* as defined in the C2PA specification chapters 15 and 18.
|
|
44
|
-
*
|
|
45
|
-
* @see {@link https://c2pa.org/specifications/specifications/2.3/specs/C2PA_Specification.html#_claim_validation | C2PA Spec §15.10.3}
|
|
46
|
-
*
|
|
47
|
-
* @enum
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
declare const C2paStatusCode: {
|
|
40
|
+
* Standard C2PA validation status codes for manifest integrity checks,
|
|
41
|
+
* as defined in the C2PA specification chapters 15 and 18.
|
|
42
|
+
*
|
|
43
|
+
* @see {@link https://c2pa.org/specifications/specifications/2.3/specs/C2PA_Specification.html#_claim_validation | C2PA Spec §15.10.3}
|
|
44
|
+
*
|
|
45
|
+
* @enum
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export declare const C2paStatusCode: {
|
|
52
50
|
/** Assertion hash does not match the hashed URI in the claim (§15.10.3.1) */
|
|
53
51
|
readonly ASSERTION_HASHEDURI_MISMATCH: "assertion.hashedURI.mismatch";
|
|
54
|
-
/**
|
|
52
|
+
/** The assertion store has no box for a claim reference, or more than one box for its label (§8.4.1, §15.10.3.1) */
|
|
55
53
|
readonly ASSERTION_MISSING: "assertion.missing";
|
|
54
|
+
/** The manifest has more than one hard binding assertion (§9.1, §15.10.1.2) */
|
|
55
|
+
readonly ASSERTION_MULTIPLE_HARD_BINDINGS: "assertion.multipleHardBindings";
|
|
56
|
+
/** The assertion store holds an assertion that the claim does not reference (§15.10.3.1) */
|
|
57
|
+
readonly ASSERTION_UNDECLARED: "assertion.undeclared";
|
|
56
58
|
/** An action requiring an ingredient reference does not have one (§18.15.4.7) */
|
|
57
59
|
readonly ASSERTION_ACTION_INGREDIENT_MISMATCH: "assertion.action.ingredientMismatch";
|
|
58
60
|
/** Claim signature verification failed, or the signature carries no certificate (§15.7) */
|
|
@@ -61,25 +63,31 @@ declare const C2paStatusCode: {
|
|
|
61
63
|
readonly CLAIM_SIGNATURE_MISSING: "claimSignature.missing";
|
|
62
64
|
/** The manifest has no claim box (§15.6.1) */
|
|
63
65
|
readonly CLAIM_MISSING: "claim.missing";
|
|
66
|
+
/** The claim box holds CBOR that does not decode (§15.6.2) */
|
|
67
|
+
readonly CLAIM_CBOR_INVALID: "claim.cbor.invalid";
|
|
68
|
+
/** The claim box holds CBOR that is not a map (§15.6.2). The library does not check the fields of the claim. */
|
|
69
|
+
readonly CLAIM_MALFORMED: "claim.malformed";
|
|
70
|
+
/** The manifest has more than one claim box (§15.6.1) */
|
|
71
|
+
readonly CLAIM_MULTIPLE: "claim.multiple";
|
|
64
72
|
/** BMFF hash assertion or Merkle structure is malformed (§15.2.2.3) */
|
|
65
73
|
readonly ASSERTION_BMFFHASH_MALFORMED: "assertion.bmffHash.malformed";
|
|
66
74
|
/** BMFF content hash does not match the committed value (§15.2.2.3) */
|
|
67
75
|
readonly ASSERTION_BMFFHASH_MISMATCH: "assertion.bmffHash.mismatch";
|
|
68
76
|
};
|
|
69
77
|
/**
|
|
70
|
-
* Union type of all {@link (C2paStatusCode:variable)} values.
|
|
71
|
-
*
|
|
72
|
-
* @public
|
|
73
|
-
*/
|
|
74
|
-
type C2paStatusCode = ValueOf<typeof C2paStatusCode>;
|
|
78
|
+
* Union type of all {@link (C2paStatusCode:variable)} values.
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export type C2paStatusCode = ValueOf<typeof C2paStatusCode>;
|
|
75
83
|
//#endregion
|
|
76
84
|
//#region src/cose/CoseKeyJwk.d.ts
|
|
77
85
|
/**
|
|
78
|
-
* A JWK (JSON Web Key) representation of a COSE public key,
|
|
79
|
-
* suitable for use with the WebCrypto `importKey` API.
|
|
80
|
-
*
|
|
81
|
-
* @public
|
|
82
|
-
*/
|
|
86
|
+
* A JWK (JSON Web Key) representation of a COSE public key,
|
|
87
|
+
* suitable for use with the WebCrypto `importKey` API.
|
|
88
|
+
*
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
83
91
|
type CoseKeyJwk = {
|
|
84
92
|
readonly kty: string;
|
|
85
93
|
readonly crv: string;
|
|
@@ -89,27 +97,27 @@ type CoseKeyJwk = {
|
|
|
89
97
|
//#endregion
|
|
90
98
|
//#region src/LiveVideoStatusCode.d.ts
|
|
91
99
|
/**
|
|
92
|
-
* Standard C2PA failure status codes for live video validation,
|
|
93
|
-
* as defined in the C2PA specification section 19.7.
|
|
94
|
-
*
|
|
95
|
-
* @see {@link https://c2pa.org/specifications/specifications/2.3/specs/C2PA_Specification.html#_live_video_validation_process | C2PA Spec §19.7}
|
|
96
|
-
*
|
|
97
|
-
* @enum
|
|
98
|
-
*
|
|
99
|
-
* @public
|
|
100
|
-
*/
|
|
101
|
-
declare const LiveVideoStatusCode: {
|
|
100
|
+
* Standard C2PA failure status codes for live video validation,
|
|
101
|
+
* as defined in the C2PA specification section 19.7.
|
|
102
|
+
*
|
|
103
|
+
* @see {@link https://c2pa.org/specifications/specifications/2.3/specs/C2PA_Specification.html#_live_video_validation_process | C2PA Spec §19.7}
|
|
104
|
+
*
|
|
105
|
+
* @enum
|
|
106
|
+
*
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export declare const LiveVideoStatusCode: {
|
|
102
110
|
/** Init segment contains an `mdat` box (§19.7.1) */
|
|
103
111
|
readonly INIT_INVALID: "livevideo.init.invalid";
|
|
104
112
|
/** C2PA Manifest Box failed standard validation (§19.7.1) */
|
|
105
113
|
readonly MANIFEST_INVALID: "livevideo.manifest.invalid";
|
|
106
|
-
/** Segment
|
|
114
|
+
/** Segment invalid: missing Manifest Box/emsg, signature/hash/key failure, or session key outside its validity period (§19.7) */
|
|
107
115
|
readonly SEGMENT_INVALID: "livevideo.segment.invalid";
|
|
108
116
|
/**
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
117
|
+
* Live video assertion field invalid: sequenceNumber or streamId mismatch
|
|
118
|
+
* (§19.7.2). Also reused for VOD Merkle per-track location discontinuity
|
|
119
|
+
* (§15.12.2), which has no dedicated code.
|
|
120
|
+
*/
|
|
113
121
|
readonly ASSERTION_INVALID: "livevideo.assertion.invalid";
|
|
114
122
|
/** continuityMethod absent, unsupported, or companion fields incorrect (§19.7.2) */
|
|
115
123
|
readonly CONTINUITY_METHOD_INVALID: "livevideo.continuityMethod.invalid";
|
|
@@ -119,32 +127,32 @@ declare const LiveVideoStatusCode: {
|
|
|
119
127
|
readonly SESSIONKEY_INVALID: "livevideo.sessionkey.invalid";
|
|
120
128
|
};
|
|
121
129
|
/**
|
|
122
|
-
* Union type of all {@link (LiveVideoStatusCode:variable)} values.
|
|
123
|
-
*
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
|
-
type LiveVideoStatusCode = ValueOf<typeof LiveVideoStatusCode>;
|
|
130
|
+
* Union type of all {@link (LiveVideoStatusCode:variable)} values.
|
|
131
|
+
*
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
export type LiveVideoStatusCode = ValueOf<typeof LiveVideoStatusCode>;
|
|
127
135
|
//#endregion
|
|
128
136
|
//#region src/bmff/BmffHashExclusion.d.ts
|
|
129
137
|
/**
|
|
130
|
-
* A byte-level constraint used to match specific BMFF box content
|
|
131
|
-
* within a C2PA BMFF hash exclusion.
|
|
132
|
-
*
|
|
133
|
-
* @public
|
|
134
|
-
*/
|
|
138
|
+
* A byte-level constraint used to match specific BMFF box content
|
|
139
|
+
* within a C2PA BMFF hash exclusion.
|
|
140
|
+
*
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
135
143
|
type BmffHashConstraint = {
|
|
136
144
|
readonly offset: number;
|
|
137
145
|
readonly value: Uint8Array | readonly number[];
|
|
138
146
|
};
|
|
139
147
|
/**
|
|
140
|
-
* Identifies a BMFF box to exclude from the C2PA content hash (`c2pa.hash.bmff.v3`).
|
|
141
|
-
*
|
|
142
|
-
* The `xpath` uses C2PA path notation (e.g. `/emsg`, `/moof/traf`).
|
|
143
|
-
* Optional `data` constraints narrow the match to specific box content
|
|
144
|
-
* by byte offset within the box.
|
|
145
|
-
*
|
|
146
|
-
* @public
|
|
147
|
-
*/
|
|
148
|
+
* Identifies a BMFF box to exclude from the C2PA content hash (`c2pa.hash.bmff.v3`).
|
|
149
|
+
*
|
|
150
|
+
* The `xpath` uses C2PA path notation (e.g. `/emsg`, `/moof/traf`).
|
|
151
|
+
* Optional `data` constraints narrow the match to specific box content
|
|
152
|
+
* by byte offset within the box.
|
|
153
|
+
*
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
148
156
|
type BmffHashExclusion = {
|
|
149
157
|
readonly xpath: string;
|
|
150
158
|
readonly data?: readonly BmffHashConstraint[];
|
|
@@ -152,10 +160,10 @@ type BmffHashExclusion = {
|
|
|
152
160
|
//#endregion
|
|
153
161
|
//#region src/merkle/MerkleSegmentValidation.d.ts
|
|
154
162
|
/**
|
|
155
|
-
* One merkle map from the `c2pa.hash.bmff.v3` assertion (§18.6).
|
|
156
|
-
*
|
|
157
|
-
* @public
|
|
158
|
-
*/
|
|
163
|
+
* One merkle map from the `c2pa.hash.bmff.v3` assertion (§18.6).
|
|
164
|
+
*
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
159
167
|
type MerkleMap = {
|
|
160
168
|
readonly uniqueId: number;
|
|
161
169
|
readonly localId: number;
|
|
@@ -167,24 +175,24 @@ type MerkleMap = {
|
|
|
167
175
|
readonly offsetPrefixSize: number;
|
|
168
176
|
};
|
|
169
177
|
/**
|
|
170
|
-
* Continuity state carried between calls to `validateC2paMerkleSegment`.
|
|
171
|
-
* Reset (pass `undefined`) after a seek.
|
|
172
|
-
*
|
|
173
|
-
* `lastLocations` is keyed by `${uniqueId}:${localId}`, matching the
|
|
174
|
-
* `MerkleMap` fields of the track it tracks. The first location seen for a
|
|
175
|
-
* key is always accepted (no prior state to compare against), so a caller
|
|
176
|
-
* that needs strict start-at-zero enforcement must seed this map itself.
|
|
177
|
-
*
|
|
178
|
-
* @public
|
|
179
|
-
*/
|
|
178
|
+
* Continuity state carried between calls to `validateC2paMerkleSegment`.
|
|
179
|
+
* Reset (pass `undefined`) after a seek.
|
|
180
|
+
*
|
|
181
|
+
* `lastLocations` is keyed by `${uniqueId}:${localId}`, matching the
|
|
182
|
+
* `MerkleMap` fields of the track it tracks. The first location seen for a
|
|
183
|
+
* key is always accepted (no prior state to compare against), so a caller
|
|
184
|
+
* that needs strict start-at-zero enforcement must seed this map itself.
|
|
185
|
+
*
|
|
186
|
+
* @public
|
|
187
|
+
*/
|
|
180
188
|
type MerkleSegmentState = {
|
|
181
189
|
readonly lastLocations: ReadonlyMap<string, number>;
|
|
182
190
|
};
|
|
183
191
|
/**
|
|
184
|
-
* Result of `validateC2paMerkleSegment` for one media segment.
|
|
185
|
-
*
|
|
186
|
-
* @public
|
|
187
|
-
*/
|
|
192
|
+
* Result of `validateC2paMerkleSegment` for one media segment.
|
|
193
|
+
*
|
|
194
|
+
* @public
|
|
195
|
+
*/
|
|
188
196
|
type MerkleSegmentValidation = {
|
|
189
197
|
readonly location: number | null;
|
|
190
198
|
readonly bmffHashHex: string | null;
|
|
@@ -194,13 +202,13 @@ type MerkleSegmentValidation = {
|
|
|
194
202
|
//#endregion
|
|
195
203
|
//#region src/init/InitSegmentValidation.d.ts
|
|
196
204
|
/**
|
|
197
|
-
* A session key extracted and verified from a C2PA `c2pa.session-keys` assertion.
|
|
198
|
-
*
|
|
199
|
-
* Only keys whose signer binding is valid and whose validity period has not expired
|
|
200
|
-
* are included in {@link InitSegmentValidation.sessionKeys}.
|
|
201
|
-
*
|
|
202
|
-
* @public
|
|
203
|
-
*/
|
|
205
|
+
* A session key extracted and verified from a C2PA `c2pa.session-keys` assertion.
|
|
206
|
+
*
|
|
207
|
+
* Only keys whose signer binding is valid and whose validity period has not expired
|
|
208
|
+
* are included in {@link InitSegmentValidation.sessionKeys}.
|
|
209
|
+
*
|
|
210
|
+
* @public
|
|
211
|
+
*/
|
|
204
212
|
type ValidatedSessionKey = {
|
|
205
213
|
readonly kid: string;
|
|
206
214
|
readonly jwk: CoseKeyJwk;
|
|
@@ -209,12 +217,12 @@ type ValidatedSessionKey = {
|
|
|
209
217
|
readonly createdAt: string;
|
|
210
218
|
};
|
|
211
219
|
/**
|
|
212
|
-
* Result of validating a C2PA init segment.
|
|
213
|
-
*
|
|
214
|
-
* Returned by {@link validateC2paInitSegment}.
|
|
215
|
-
*
|
|
216
|
-
* @public
|
|
217
|
-
*/
|
|
220
|
+
* Result of validating a C2PA init segment.
|
|
221
|
+
*
|
|
222
|
+
* Returned by {@link validateC2paInitSegment}.
|
|
223
|
+
*
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
218
226
|
type InitSegmentValidation = {
|
|
219
227
|
readonly manifest: C2paManifest | null;
|
|
220
228
|
readonly certificate: Uint8Array | null;
|
|
@@ -227,54 +235,62 @@ type InitSegmentValidation = {
|
|
|
227
235
|
//#endregion
|
|
228
236
|
//#region src/init/validateC2paInitSegment.d.ts
|
|
229
237
|
/**
|
|
230
|
-
* Validates a C2PA init segment: parses the manifest, extracts and verifies
|
|
231
|
-
* the certificate, validates the BMFF hard binding hash, verifies all
|
|
232
|
-
* session keys from the `c2pa.session-keys` assertion, and performs
|
|
233
|
-
* manifest integrity checks (assertion hashes,
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
|
|
248
|
-
|
|
238
|
+
* Validates a C2PA init segment: parses the manifest, extracts and verifies
|
|
239
|
+
* the certificate, validates the BMFF hard binding hash, verifies all
|
|
240
|
+
* session keys from the `c2pa.session-keys` assertion, and performs
|
|
241
|
+
* manifest integrity checks (assertion references and hashes, undeclared
|
|
242
|
+
* assertions, the hard binding count, duplicate manifest boxes, action
|
|
243
|
+
* ingredients, and claim signature verification).
|
|
244
|
+
*
|
|
245
|
+
* Only session keys with a valid signer binding and an unexpired validity period
|
|
246
|
+
* are included in the result. The result holds `sessionKeys` and `merkleMaps` only when
|
|
247
|
+
* every manifest integrity check passes, so check `isValid` before you use either list.
|
|
248
|
+
*
|
|
249
|
+
* The result includes `LiveVideoStatusCode.SESSIONKEY_INVALID` if the function finds an invalid
|
|
250
|
+
* session key (C2PA section 19.7.3). A session key is invalid if it does not conform to section 18.25.2,
|
|
251
|
+
* or if its signer binding fails verification. The function does not check every rule of section 18.25.2.
|
|
252
|
+
* An expired session key does not count as invalid. A `c2pa.session-keys` assertion without a session key,
|
|
253
|
+
* or with CBOR that does not decode, also causes `SESSIONKEY_INVALID`.
|
|
254
|
+
*
|
|
255
|
+
* @param bytes - Raw init segment bytes
|
|
256
|
+
* @returns Structured validation result (with `INIT_INVALID` error code if `mdat` box is present)
|
|
257
|
+
* @throws If no C2PA UUID box is found
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* {@includeCode ../../test/init/validateC2paInitSegment.test.ts#example}
|
|
261
|
+
*
|
|
262
|
+
* @public
|
|
263
|
+
*/
|
|
264
|
+
export declare function validateC2paInitSegment(bytes: Uint8Array): Promise<InitSegmentValidation>;
|
|
249
265
|
//#endregion
|
|
250
266
|
//#region src/vsi/SequenceState.d.ts
|
|
251
267
|
/**
|
|
252
|
-
* State and result types for monotonic sequence number validation
|
|
253
|
-
* per C2PA Live Streaming Specification §18.4.
|
|
254
|
-
*
|
|
255
|
-
* @public
|
|
256
|
-
*/
|
|
268
|
+
* State and result types for monotonic sequence number validation
|
|
269
|
+
* per C2PA Live Streaming Specification §18.4.
|
|
270
|
+
*
|
|
271
|
+
* @public
|
|
272
|
+
*/
|
|
257
273
|
/**
|
|
258
|
-
* Immutable state snapshot for a single stream's sequence number history.
|
|
259
|
-
*
|
|
260
|
-
* Pass to {@link validateC2paSegment} via the `sequenceState` parameter.
|
|
261
|
-
*
|
|
262
|
-
* @public
|
|
263
|
-
*/
|
|
274
|
+
* Immutable state snapshot for a single stream's sequence number history.
|
|
275
|
+
*
|
|
276
|
+
* Pass to {@link validateC2paSegment} via the `sequenceState` parameter.
|
|
277
|
+
*
|
|
278
|
+
* @public
|
|
279
|
+
*/
|
|
264
280
|
type SequenceState = {
|
|
265
281
|
readonly lastSequenceNumber: number | null;
|
|
266
282
|
readonly seenSequences: ReadonlySet<number>;
|
|
267
283
|
};
|
|
268
284
|
/**
|
|
269
|
-
* Reason codes for sequence number validation outcomes.
|
|
270
|
-
*
|
|
271
|
-
* @see {@link SequenceValidationResult}
|
|
272
|
-
*
|
|
273
|
-
* @enum
|
|
274
|
-
*
|
|
275
|
-
* @public
|
|
276
|
-
*/
|
|
277
|
-
declare const SequenceValidationReason: {
|
|
285
|
+
* Reason codes for sequence number validation outcomes.
|
|
286
|
+
*
|
|
287
|
+
* @see {@link SequenceValidationResult}
|
|
288
|
+
*
|
|
289
|
+
* @enum
|
|
290
|
+
*
|
|
291
|
+
* @public
|
|
292
|
+
*/
|
|
293
|
+
export declare const SequenceValidationReason: {
|
|
278
294
|
/** Sequence number is the next expected value */
|
|
279
295
|
readonly VALID: "valid";
|
|
280
296
|
/** Sequence number was already seen */
|
|
@@ -287,19 +303,19 @@ declare const SequenceValidationReason: {
|
|
|
287
303
|
readonly SEQUENCE_NUMBER_BELOW_MINIMUM: "sequence_number_below_minimum";
|
|
288
304
|
};
|
|
289
305
|
/**
|
|
290
|
-
* Union type of all {@link (SequenceValidationReason:variable)} values.
|
|
291
|
-
*
|
|
292
|
-
* @public
|
|
293
|
-
*/
|
|
294
|
-
type SequenceValidationReason = ValueOf<typeof SequenceValidationReason>;
|
|
306
|
+
* Union type of all {@link (SequenceValidationReason:variable)} values.
|
|
307
|
+
*
|
|
308
|
+
* @public
|
|
309
|
+
*/
|
|
310
|
+
export type SequenceValidationReason = ValueOf<typeof SequenceValidationReason>;
|
|
295
311
|
/**
|
|
296
|
-
* Result of validating a single sequence number against the current stream state.
|
|
297
|
-
*
|
|
298
|
-
* Discriminated on `reason` — narrow to `'gap_detected'` to access
|
|
299
|
-
* `missingFrom` / `missingTo`.
|
|
300
|
-
*
|
|
301
|
-
* @public
|
|
302
|
-
*/
|
|
312
|
+
* Result of validating a single sequence number against the current stream state.
|
|
313
|
+
*
|
|
314
|
+
* Discriminated on `reason` — narrow to `'gap_detected'` to access
|
|
315
|
+
* `missingFrom` / `missingTo`.
|
|
316
|
+
*
|
|
317
|
+
* @public
|
|
318
|
+
*/
|
|
303
319
|
type SequenceValidationResult = {
|
|
304
320
|
readonly isValid: true;
|
|
305
321
|
readonly reason: typeof SequenceValidationReason.VALID;
|
|
@@ -315,12 +331,12 @@ type SequenceValidationResult = {
|
|
|
315
331
|
//#endregion
|
|
316
332
|
//#region src/segment/SegmentValidation.d.ts
|
|
317
333
|
/**
|
|
318
|
-
* The result of validating a single C2PA live stream segment (VSI/EMSG method).
|
|
319
|
-
*
|
|
320
|
-
* Returned by {@link validateC2paSegment}.
|
|
321
|
-
*
|
|
322
|
-
* @public
|
|
323
|
-
*/
|
|
334
|
+
* The result of validating a single C2PA live stream segment (VSI/EMSG method).
|
|
335
|
+
*
|
|
336
|
+
* Returned by {@link validateC2paSegment}.
|
|
337
|
+
*
|
|
338
|
+
* @public
|
|
339
|
+
*/
|
|
324
340
|
type SegmentValidationResult = {
|
|
325
341
|
readonly sequenceNumber: number;
|
|
326
342
|
readonly manifestId: string;
|
|
@@ -333,37 +349,40 @@ type SegmentValidationResult = {
|
|
|
333
349
|
//#endregion
|
|
334
350
|
//#region src/segment/validateC2paSegment.d.ts
|
|
335
351
|
/**
|
|
336
|
-
* Validates a C2PA live stream segment using the VSI/EMSG method (§19.7.3).
|
|
337
|
-
*
|
|
338
|
-
* Extracts the EMSG box, decodes the COSE_Sign1 and VSI map, matches the
|
|
339
|
-
* session key by kid, then performs all cryptographic checks: signature
|
|
340
|
-
* verification, BMFF content hash, sequence number floor, and key validity.
|
|
341
|
-
*
|
|
342
|
-
* Returns `null` if the segment does not contain a C2PA EMSG box.
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
* @
|
|
348
|
-
*
|
|
349
|
-
* @
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
* @
|
|
353
|
-
|
|
354
|
-
|
|
352
|
+
* Validates a C2PA live stream segment using the VSI/EMSG method (§19.7.3).
|
|
353
|
+
*
|
|
354
|
+
* Extracts the EMSG box, decodes the COSE_Sign1 and VSI map, matches the
|
|
355
|
+
* session key by kid, then performs all cryptographic checks: signature
|
|
356
|
+
* verification, BMFF content hash, sequence number floor, and key validity.
|
|
357
|
+
*
|
|
358
|
+
* Returns `null` if the segment does not contain a C2PA EMSG box.
|
|
359
|
+
*
|
|
360
|
+
* A segment whose signature, content hash, or key validity does not verify
|
|
361
|
+
* returns the received `sequenceState` unchanged.
|
|
362
|
+
*
|
|
363
|
+
* @param segmentBytes - Raw segment bytes
|
|
364
|
+
* @param sessionKeys - Available session keys from the init segment
|
|
365
|
+
* @param sequenceState - Current sequence state for this stream
|
|
366
|
+
* @returns Validation result and the sequence state for the next call, or `null` if no C2PA EMSG box
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* {@includeCode ../../test/segment/validateC2paSegment.test.ts#example}
|
|
370
|
+
*
|
|
371
|
+
* @public
|
|
372
|
+
*/
|
|
373
|
+
export declare function validateC2paSegment(segmentBytes: Uint8Array, sessionKeys: readonly ValidatedSessionKey[], sequenceState?: SequenceState): Promise<{
|
|
355
374
|
readonly result: SegmentValidationResult;
|
|
356
375
|
readonly nextSequenceState: SequenceState;
|
|
357
376
|
} | null>;
|
|
358
377
|
//#endregion
|
|
359
378
|
//#region src/manifestbox/ManifestBoxValidation.d.ts
|
|
360
379
|
/**
|
|
361
|
-
* The result of validating a single C2PA manifest-box live stream segment.
|
|
362
|
-
*
|
|
363
|
-
* Returned by {@link validateC2paManifestBoxSegment}.
|
|
364
|
-
*
|
|
365
|
-
* @public
|
|
366
|
-
*/
|
|
380
|
+
* The result of validating a single C2PA manifest-box live stream segment.
|
|
381
|
+
*
|
|
382
|
+
* Returned by {@link validateC2paManifestBoxSegment}.
|
|
383
|
+
*
|
|
384
|
+
* @public
|
|
385
|
+
*/
|
|
367
386
|
type ManifestBoxValidationResult = {
|
|
368
387
|
readonly manifest: C2paManifest | null;
|
|
369
388
|
readonly issuer: string | null;
|
|
@@ -378,16 +397,16 @@ type ManifestBoxValidationResult = {
|
|
|
378
397
|
readonly errorCodes: readonly (LiveVideoStatusCode | C2paStatusCode)[];
|
|
379
398
|
};
|
|
380
399
|
/**
|
|
381
|
-
* Validates continuity for an implementer-defined continuity method (§19.3.2).
|
|
382
|
-
*
|
|
383
|
-
* @public
|
|
384
|
-
*/
|
|
400
|
+
* Validates continuity for an implementer-defined continuity method (§19.3.2).
|
|
401
|
+
*
|
|
402
|
+
* @public
|
|
403
|
+
*/
|
|
385
404
|
type ManifestBoxContinuityValidator = (liveVideoAssertion: Readonly<Record<string, unknown>>, manifest: C2paManifest) => boolean | Promise<boolean>;
|
|
386
405
|
/**
|
|
387
|
-
* Options for `validateC2paManifestBoxSegment`.
|
|
388
|
-
*
|
|
389
|
-
* @public
|
|
390
|
-
*/
|
|
406
|
+
* Options for `validateC2paManifestBoxSegment`.
|
|
407
|
+
*
|
|
408
|
+
* @public
|
|
409
|
+
*/
|
|
391
410
|
type ManifestBoxValidationOptions = {
|
|
392
411
|
readonly continuityValidator?: {
|
|
393
412
|
readonly method: string;
|
|
@@ -395,13 +414,13 @@ type ManifestBoxValidationOptions = {
|
|
|
395
414
|
};
|
|
396
415
|
};
|
|
397
416
|
/**
|
|
398
|
-
* State to carry between consecutive manifest-box segment validations.
|
|
399
|
-
*
|
|
400
|
-
* Pass the `nextState` returned by {@link validateC2paManifestBoxSegment}
|
|
401
|
-
* into the next call to enable streamId, sequenceNumber, and continuity checks.
|
|
402
|
-
*
|
|
403
|
-
* @public
|
|
404
|
-
*/
|
|
417
|
+
* State to carry between consecutive manifest-box segment validations.
|
|
418
|
+
*
|
|
419
|
+
* Pass the `nextState` returned by {@link validateC2paManifestBoxSegment}
|
|
420
|
+
* into the next call to enable streamId, sequenceNumber, and continuity checks.
|
|
421
|
+
*
|
|
422
|
+
* @public
|
|
423
|
+
*/
|
|
405
424
|
type ManifestBoxValidationState = {
|
|
406
425
|
readonly lastStreamId?: string | null;
|
|
407
426
|
readonly lastSequenceNumber?: number | null;
|
|
@@ -409,31 +428,36 @@ type ManifestBoxValidationState = {
|
|
|
409
428
|
//#endregion
|
|
410
429
|
//#region src/manifestbox/validateC2paManifestBoxSegment.d.ts
|
|
411
430
|
/**
|
|
412
|
-
* Validates a C2PA manifest-box live stream segment.
|
|
413
|
-
*
|
|
414
|
-
* Parses the C2PA manifest embedded in the segment and validates per §19.7.1 and §19.7.2.
|
|
415
|
-
* Recomputes the `c2pa.hash.bmff.v3` content hash from the raw segment bytes and compares
|
|
416
|
-
* it against the expected hash in the manifest assertion. Checks live-video assertions
|
|
417
|
-
* (sequenceNumber, streamId, continuityMethod) and manifest-ID chain continuity.
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* @
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
* @
|
|
435
|
-
|
|
436
|
-
|
|
431
|
+
* Validates a C2PA manifest-box live stream segment.
|
|
432
|
+
*
|
|
433
|
+
* Parses the C2PA manifest embedded in the segment and validates per §19.7.1 and §19.7.2.
|
|
434
|
+
* Recomputes the `c2pa.hash.bmff.v3` content hash from the raw segment bytes and compares
|
|
435
|
+
* it against the expected hash in the manifest assertion. Checks live-video assertions
|
|
436
|
+
* (sequenceNumber, streamId, continuityMethod) and manifest-ID chain continuity.
|
|
437
|
+
* The live-video and BMFF hash fields of the result come only from assertions whose
|
|
438
|
+
* hash matches a claim reference. Check `isValid` before you use any field.
|
|
439
|
+
* A validator for an implementer-defined continuity method can be registered
|
|
440
|
+
* via {@link ManifestBoxValidationOptions}.
|
|
441
|
+
*
|
|
442
|
+
* This function is **pure** — it does not access any external state. The
|
|
443
|
+
* caller is responsible for persisting `nextManifestId` and `nextState`
|
|
444
|
+
* between calls. A segment that fails verification, is on another stream, or
|
|
445
|
+
* does not move the sequence number forward returns the received
|
|
446
|
+
* `lastManifestId` and `state` unchanged. A segment that fails only the
|
|
447
|
+
* continuity check still updates them.
|
|
448
|
+
*
|
|
449
|
+
* @param bytes - Raw segment bytes
|
|
450
|
+
* @param lastManifestId - Manifest ID from the last segment that updated the state, or `null` for the first segment
|
|
451
|
+
* @param state - Optional state from the last segment that updated the state, for the streamId and sequenceNumber checks
|
|
452
|
+
* @param options - Optional custom continuity method validator
|
|
453
|
+
* @returns Validation result, the manifest ID, and state to persist for the next call
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* {@includeCode ../../test/manifestbox/validateC2paManifestBoxSegment.test.ts#example}
|
|
457
|
+
*
|
|
458
|
+
* @public
|
|
459
|
+
*/
|
|
460
|
+
export declare function validateC2paManifestBoxSegment(bytes: Uint8Array, lastManifestId: string | null, state?: ManifestBoxValidationState, options?: ManifestBoxValidationOptions): Promise<{
|
|
437
461
|
readonly result: ManifestBoxValidationResult;
|
|
438
462
|
readonly nextManifestId: string | null;
|
|
439
463
|
readonly nextState: ManifestBoxValidationState;
|
|
@@ -441,23 +465,23 @@ declare function validateC2paManifestBoxSegment(bytes: Uint8Array, lastManifestI
|
|
|
441
465
|
//#endregion
|
|
442
466
|
//#region src/merkle/validateC2paMerkleSegment.d.ts
|
|
443
467
|
/**
|
|
444
|
-
* Validates a fragmented MP4 VOD media segment against the init manifest's
|
|
445
|
-
* merkle maps (§15.12.2.2). Pure: the caller persists `nextState` and resets
|
|
446
|
-
* `state` after a seek.
|
|
447
|
-
*
|
|
448
|
-
* `merkleMaps` must be non-empty; the caller is responsible for only calling
|
|
449
|
-
* this in VOD Merkle mode (i.e. after `InitSegmentValidation.merkleMaps` came
|
|
450
|
-
* back non-empty).
|
|
451
|
-
*
|
|
452
|
-
* @example
|
|
453
|
-
* {@includeCode ../../test/merkle/validateC2paMerkleSegment.test.ts#example}
|
|
454
|
-
*
|
|
455
|
-
* @public
|
|
456
|
-
*/
|
|
457
|
-
declare function validateC2paMerkleSegment(segmentBytes: Uint8Array, merkleMaps: readonly MerkleMap[], state?: MerkleSegmentState): Promise<{
|
|
468
|
+
* Validates a fragmented MP4 VOD media segment against the init manifest's
|
|
469
|
+
* merkle maps (§15.12.2.2). Pure: the caller persists `nextState` and resets
|
|
470
|
+
* `state` after a seek.
|
|
471
|
+
*
|
|
472
|
+
* `merkleMaps` must be non-empty; the caller is responsible for only calling
|
|
473
|
+
* this in VOD Merkle mode (i.e. after `InitSegmentValidation.merkleMaps` came
|
|
474
|
+
* back non-empty).
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* {@includeCode ../../test/merkle/validateC2paMerkleSegment.test.ts#example}
|
|
478
|
+
*
|
|
479
|
+
* @public
|
|
480
|
+
*/
|
|
481
|
+
export declare function validateC2paMerkleSegment(segmentBytes: Uint8Array, merkleMaps: readonly MerkleMap[], state?: MerkleSegmentState): Promise<{
|
|
458
482
|
readonly result: MerkleSegmentValidation;
|
|
459
483
|
readonly nextState: MerkleSegmentState;
|
|
460
484
|
}>;
|
|
461
485
|
//#endregion
|
|
462
|
-
export { BmffHashConstraint, BmffHashExclusion, C2paAssertion, C2paManifest, C2paSignatureInfo,
|
|
486
|
+
export type { BmffHashConstraint, BmffHashExclusion, C2paAssertion, C2paManifest, C2paSignatureInfo, CoseKeyJwk, InitSegmentValidation, ManifestBoxContinuityValidator, ManifestBoxValidationOptions, ManifestBoxValidationResult, ManifestBoxValidationState, MerkleMap, MerkleSegmentState, MerkleSegmentValidation, SegmentValidationResult, SequenceState, SequenceValidationResult, ValidatedSessionKey };
|
|
463
487
|
//# sourceMappingURL=index.d.ts.map
|