Skip to content

refactor: shared asset size validation - #169

Merged
ale-adobe merged 39 commits into
mainfrom
feat/shared-guards
Aug 12, 2026
Merged

refactor: shared asset size validation#169
ale-adobe merged 39 commits into
mainfrom
feat/shared-guards

Conversation

@ale-adobe

@ale-adobe ale-adobe commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

This PR pulls out asset size validation from c2pa-web into a shared utility library in c2pa-utilities, and then adds that validation check to c2pa-node's Reader factories.

c2pa-web maintains its existing 1 GB size limit, while c2pa-node gains a new 10 GB size limit. These are hard-coded at the moment in the source code and cannot be configured by clients. In the future, I intend to make these configurable once we have a more formalized concept of a Context and we can better support global settings per SDK instance in a way that is easily shared between both packages.

@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7dbf7f0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@contentauth/c2pa-utilities Minor
@contentauth/c2pa-node Minor
@contentauth/c2pa-web Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

expect(reader).toBeNull();
});

test('should throw UnsupportedFormatError for an unsupported format', async ({

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding some missing unit test coverage for error handling.

@ale-adobe
ale-adobe marked this pull request as ready for review August 3, 2026 23:46
@ale-adobe ale-adobe changed the title refactor: shared asset validation and error handling logic refactor: shared asset size validation Aug 3, 2026
@ale-adobe
ale-adobe marked this pull request as draft August 4, 2026 00:15

@tmathern tmathern left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • If fragmented media are supported, make sure also all fragments are checked as they go in (not just the first one).
  • This is a minor change (new error code exported in the API), not a patch.

Comment thread packages/c2pa-node/js-src/assetSize.ts Outdated
Comment thread packages/c2pa-utilities/src/assetSize.ts
Comment thread packages/c2pa-node/js-src/assetSize.ts
Base automatically changed from feat/unification to main August 10, 2026 21:43
throw new AssetTooLargeError(init.size);
}
validateAssetSize(init.size, MAX_SIZE_IN_BYTES);
validateAssetSize(fragment.size, MAX_SIZE_IN_BYTES);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were never checking the fragment size before, but we are now!

@ale-adobe
ale-adobe requested a review from tmathern August 10, 2026 22:01
@ale-adobe
ale-adobe marked this pull request as ready for review August 10, 2026 22:01
Comment thread packages/c2pa-node/js-src/assetSize.ts
Comment thread packages/c2pa-node/js-src/Reader.ts
Comment thread packages/c2pa-node/js-src/Reader.ts
Comment thread packages/c2pa-web/README.md Outdated
Comment thread packages/c2pa-node/js-src/assetSize.ts
@tmathern
tmathern requested a review from cdmurph32 August 11, 2026 02:45

@cdmurph32 cdmurph32 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ale-adobe
ale-adobe merged commit f2f6ada into main Aug 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants