Function: validateC2paManifestBoxSegment()
function validateC2paManifestBoxSegment(
bytes,
lastManifestId,
state?,
options?
): Promise<{
nextManifestId: string | null;
nextState: ManifestBoxValidationState;
result: ManifestBoxValidationResult;
}>;Defined in: manifestbox/validateC2paManifestBoxSegment.ts:212
Validates a C2PA manifest-box live stream segment.
Parses the C2PA manifest embedded in the segment and validates per §19.7.1 and §19.7.2. Recomputes the c2pa.hash.bmff.v3 content hash from the raw segment bytes and compares it against the expected hash in the manifest assertion. A manifest without a c2pa.hash.bmff.v3 assertion, or with one that has no hash, fails. Checks live-video assertions (sequenceNumber, streamId, continuityMethod) and manifest-ID chain continuity. The live-video and BMFF hash fields of the result come only from assertions whose hash matches a claim reference. Check isValid before you use any field. A validator for an implementer-defined continuity method can be registered via ManifestBoxValidationOptions.
This function is pure — it does not access any external state. The caller is responsible for persisting nextManifestId and nextState between calls. A segment that fails verification, is on another stream, or does not move the sequence number forward returns the received lastManifestId and state unchanged. A segment that fails only the continuity check still updates them. A segment whose claim signature URI is relative to the manifest fails with SEGMENT_INVALID and does not update them, because that URI does not authenticate the manifest identifier.
Parameters
bytes
Raw segment bytes
lastManifestId
string | null
Manifest ID from the last segment that updated the state, or null for the first segment
state?
Optional state from the last segment that updated the state, for the streamId and sequenceNumber checks
options?
Optional custom continuity method validator
Returns
Promise<{ nextManifestId: string | null; nextState: ManifestBoxValidationState; result: ManifestBoxValidationResult; }>
Validation result, the manifest ID, and state to persist for the next call
Example
it('returns isValid=false with errorCodes for empty bytes', async () => {
const { result, nextManifestId } = await validateC2paManifestBoxSegment(new Uint8Array(0), null)
strictEqual(result.isValid, false)
strictEqual(result.errorCodes.length > 0, true)
strictEqual(result.manifest, null)
strictEqual(nextManifestId, null)
})