Skip to content

Conversation

@ok-nick
Copy link
Contributor

@ok-nick ok-nick commented Jun 25, 2025

Changes in this pull request

Expands the interface of the Settings API, adding more ways to configure it and more ways to use it.

As part of this change, it standardizes on using the toml format for settings. Narrowing down supported formats on the config crate is estimated to reduce around 40-50 dependencies in the latest version.

New Options

  • signer
    • local
      • alg - algorithm used for signing
      • sign_cert - cert used for signing
      • private_key - private key used for signing
      • tsa_url - timestamp authority url used for signing
    • remote
      • url - URL to remote signer (simple POST sent for now)
      • alg - algorithm used for signing
      • sign_cert - cert used for signing
      • tsa_url - timestamp authority url used for signing
  • builder
    • claim_generator_info - claim generator info to use if not already specified in the builder when signing
      • operating_system - this is the only field that differs from the current claim generator info definition
        • infer - whether to infer the current operating system (default)
        • name - or override it manually with a specific string
    • thumbnail
      • enabled - whether to enable thumbnail generation
      • ignore_errors - whether to ignore errors on thumbnails generation (current behavior)
      • long_edge - longest edge of the thumbnail preserving aspect ratio
      • format - by default we now generate thumbnails matching the input, otherwise force this format
      • prefer_smallest_format - prefer smaller file size formats, like png/tiff with no alpha->jpeg
      • quality - low, medium, or high; we choose sensible defaults for each format
    • actions
      • all_actions_included - whether or not all actions are included in the actions assertion (default true)
      • actions - list of additional actions to add to the actions assertion
      • templates - list of additional templates to add to the actions assertion
      • auto_created_action and auto_opened_action and auto_placed_action
        • enabled - whether to enable the auto_X_action
        • source_tyoe - source type of the action (required for created action)

New API

TODO: doc

TODO

  • Auto generate example toml from doc comments and defaults for user-facing fields?
  • Block scoped settings?
  • Reader/Builder specific settings?

Related Issues

Checklist

  • This PR represents a single feature, fix, or change.
  • All applicable changes have been documented.
  • Any TO DO items (or similar) have been entered as GitHub issues and the link to that issue has been included in a comment.

@ok-nick ok-nick force-pushed the ok-nick/unified-config branch from 34380dd to 79d41ed Compare June 27, 2025 18:18
@ok-nick ok-nick force-pushed the ok-nick/unified-config branch from f0a4600 to ab32763 Compare July 8, 2025 19:47
@ok-nick ok-nick marked this pull request as ready for review July 9, 2025 17:47
@ok-nick ok-nick force-pushed the ok-nick/unified-config branch from 94f8422 to 0abb2a1 Compare July 21, 2025 16:46
@ok-nick ok-nick force-pushed the ok-nick/unified-config branch from 4dcff28 to c6948a4 Compare July 22, 2025 20:31
Copy link
Collaborator

@mauricefisher64 mauricefisher64 left a comment

Choose a reason for hiding this comment

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

I am OK with the changes to keep things moving.

Copy link
Collaborator

@gpeacock gpeacock left a comment

Choose a reason for hiding this comment

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

This looks good, we have some work to do before publishing, but this is ready to merge now. Thanks!

@gpeacock gpeacock merged commit 528eaac into main Jul 24, 2025
36 checks passed
@gpeacock gpeacock deleted the ok-nick/unified-config branch July 24, 2025 04:26
@caiopensrc caiopensrc mentioned this pull request Jul 23, 2025
@crandmck crandmck added the needs-doc Any change that affects user documentation label Jul 30, 2025
ok-nick added a commit that referenced this pull request Aug 11, 2025
* feat: unified config foundation

* refactor: separate user-facing settings and move thumbnail code

* feat: impl profiles, thumbnail.prefer_smallest_format, remove default_format

* feat: implement auto_opened, auto_created, and claim_generator_infos settings

* feat: impl auto_opened setting

* fix: default all_actions_included in actions assertion to true

* fix: all test cases

* docs: cleanup comments and document new functions

* test: add thumbnail tests

* fix: auto actions assertion, lots of tests, crash when empty actions, and optional settings values

* fix: optional signer settings and document get_profile_settings_signer

* docs: document Builder::add_auto_actions_assertion

* test: remove test code in test

* feat: add settings to CLI

* docs: create an example c2pa.toml settings

* fix: cli settings

* feat: add config path and env vars for cli settings arg

* fix: remove bmp and ico from supported thumbnails

* fix: single claim generator info and rename load settings functions

* test: remove scoped settings

* refactor: remove profiles and document digital source type

* feat: allow specifying digital source type for auto actions in settings

* refactor: convert usage of json settings to toml

* refactor: move global settings functions into public `Settings` struct

* refactor: move builder settings into its own module

* fix: add ingredient uris to auto actions, only add placed actions if not added already, and use builder claim gen info or settings

* feat: add `Settings::from_url`

* feat: setup base for remote signers and cawg signers in settings

* feat: impl `RemoteSigner` and fix when pulling optional settings

* feat: prefer_smallest_format tiff->jpeg

* feat: allow specifying infer operating system for claim generator info

* refactor: default test signer in `Settings`

* fix: source type optional for auto add actions and use ref for test signer to prevent freeze

* feat: add `ActionsSettings`, all_actions_included, action_templates, actions

* docs: add new fields to c2pa.toml

* fix: wip change serde_json::Value in settings to toml::Value (issues with this in TODO comments)

* fix: actions/action_templates and add tests, use toml for defining settings instead of setting each field

* test: cleanup and add more builder and settings tests

* fix: make_thumbnail_from_stream format before stream in parameters

* docs: finish documenting some settings structs

* fix: private Settings set/get_value

* test: add allActionsIncluded by default when signing to test

* style: +nightly fmt

* fix: feature flag thumbnails and wasm

* test: fix hash_alg string

* fix: remove cawg_signer, doc cli config path, move signer to top-level settings, fix wasi issue by reset settings before test, resourceref icons

* feat: define ActionSettings

* fix: remove Settings top-level export for now

* test: add remote signer test with mock server

* fix: change `builder.signer` setting to just `signer`

* fix: test sample toml and fix up fields

* test: don't use httpmock on wasm

* test: fix wasi test
@caiopensrc caiopensrc mentioned this pull request Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-doc Any change that affects user documentation safe to test

Projects

None yet

4 participants