Releases: TrustNXT/c2pa-ts
v0.13.3
v0.13.2
Patch Changes
-
362c715: Fixed MP3 detection to handle raw MP3 files without ID3 tags
The MP3 asset detection now properly handles MP3 files that start with audio frame data instead of an ID3 tag header. This fixes the "unsupported image format" error when protecting MP3 files generated by encoders like lamejs that produce raw audio frames.
Changes:
- Added proper 11-bit sync word detection (
0xFF+(byte1 & 0xE0) === 0xE0) for MP3 frame headers
- Added proper 11-bit sync word detection (
v0.13.1
v0.13.0
Minor Changes
-
1e7491c: Runtime Agnostic Streaming - Breaking API Change
Changed APIs
-
writeToFile(path: string)→writeToStream(stream: WritableStream<Uint8Array>)This change affects:
-
AssetDataReader.writeToFile→AssetDataReader.writeToStream -
Asset.writeToFile→Asset.writeToStream -
BaseAsset.writeToFile→BaseAsset.writeToStream -
BlobDataReader.writeToFile→BlobDataReader.writeToStream -
BufferDataReader.writeToFile→BufferDataReader.writeToStreamMigration Guide
The caller is now responsible for creating the
WritableStreamusing their runtime:Node.js:
import { createWriteStream } from 'node:fs'; import { Writable } from 'node:stream'; const nodeStream = createWriteStream(outputPath); const writableStream = Writable.toWeb(nodeStream); await asset.writeToStream(writableStream);
Removed Node.js Imports
-
Removed
import { createWriteStream, WriteStream } from 'node:fs'fromBlobDataReader.ts -
Removed
import { writeFile } from 'node:fs/promises'fromBufferDataReader.tsThis enables the library to be bundled for client-side applications (e.g., Next.js with Turbopack) without Node.js polyfills.
-
v0.12.1
Patch Changes
-
0831623: ### Browser Compatibility Fix
Fixed a bundler error that occurred when using c2pa-ts in browser environments (e.g., Next.js with Turbopack).
Problem:
Top-level imports of Node.jsfsandfs/promisesmodules inBlobDataReaderandBufferDataReadercaused build failures in browser bundlers, even though thewriteToFile()method is only intended for Node.js usage.Solution:
Converted static top-level imports to dynamic imports insidewriteToFile()methods. This ensures thefsmodules are only loaded whenwriteToFile()is actually called at runtime, allowing the library to be bundled for browser environments without errors.Note: The
writeToFile()method remains Node.js-only and will fail if called in a browser environment.
v0.12.0
Minor Changes
- 1deb78f: Add MP4 video file support
- Added support for MP4 video files (mp41, mp42, isom brands)
- Implemented StcoBox and Co64Box classes for proper chunk offset patching when inserting C2PA manifests in MP4 files
- Fixed QuickTime-style MetaBox parsing to handle both ISO BMFF and QuickTime formats
- Fixed JUMBF extraction to exclude trailing padding bytes
- Made metadata assertion JSON-LD parser more lenient with undefined prefixes
- Added MP4 video signing and validation tests
- MP4 files can now be signed and validated using BMFF v2 and v3 hash assertions
Patch Changes
- 6f65a61: Increase interoperability when using LocalTimestampProvider
v0.11.0
Minor Changes
-
b3c0102: # Large Asset Support - Asset Abstraction
⚠️ Breaking API Changes — Several methods are now async. Addawaitwhere needed.What's New
-
Blob support: Assets accept
Uint8ArrayorBlob— enables streaming large files (multi-GB) without loading into memory -
writeToFile(path): Streams output directly to disk (preferred for large files) -
getBlob(): Returns underlying Blob if availableBreaking Changes
Asset Creation & Interface
The
AssetTypeinterface has been updated to support async creation andBlobsources. Usecreate()instead ofnew.// Before const asset = new JPEG(data); const canRead = JPEG.canRead(data); // After const asset = await JPEG.create(data); const canRead = await JPEG.canRead(data);
Async Methods
These methods are now async:
Method Now returns canRead()Promise<boolean>create()Promise<Asset>getManifestJUMBF()Promise<Uint8Array | undefined>ensureManifestSpace()Promise<void>writeManifestJUMBF()Promise<void>
-