Skip to content

Commit aae8b05

Browse files
gpeacockcdmurph32
andauthored
feat: remove the v1_api feature and all associated code (#1387)
* chore: WIP on removing the v1_api feature * chore: get a lot more of the store unit tests running. * chore: repair a few more tests mime methods ignore case * chore: move test settings to a function * chore: more merge fixes * chore: get almost all the unit tests building and running again. * fix: Wasm file system changes in tests * chore: fix build when file_io is not enabled. * chore: adds lazyloaded includebytes assets for testing without file io * chore: add more in-memory test images. * chore: try something to get wasi to pass * chore: fmt * chore: fix logging Store::from_stream for invalid formats. * chore: handle some unit test file:/// paths on windows better clippy cleanup. * chore: clean up unused dependencies --------- Co-authored-by: Colin Murphy <[email protected]>
1 parent 3a26c53 commit aae8b05

24 files changed

+3138
-6679
lines changed

Cargo.lock

Lines changed: 1 addition & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ clippy:
2323
cargo clippy --features="file_io" --all-targets -- -D warnings
2424

2525
test-local:
26-
cargo test --features="file_io, fetch_remote_manifests, add_thumbnails, v1_api" --all-targets
26+
cargo test --features="file_io, fetch_remote_manifests, add_thumbnails" --all-targets
2727

2828
test-wasm:
2929
cd sdk && wasm-pack test --node -- --no-default-features --features="rust_native_crypto, fetch_remote_manifests"
@@ -36,7 +36,7 @@ test-wasi:
3636
ifeq ($(PLATFORM),mac)
3737
$(eval CC := /opt/homebrew/opt/llvm/bin/clang)
3838
endif
39-
CC=$(CC) CARGO_TARGET_WASM32_WASIP2_RUNNER="wasmtime -S cli -S http --dir ." cargo +nightly test --target wasm32-wasip2 -p c2pa --no-default-features --features="rust_native_crypto, file_io, fetch_remote_manifests, add_thumbnails, v1_api"
39+
CC=$(CC) CARGO_TARGET_WASM32_WASIP2_RUNNER="wasmtime -S cli -S http --dir ." cargo +nightly test --target wasm32-wasip2 -p c2pa --no-default-features --features="rust_native_crypto, file_io, fetch_remote_manifests, add_thumbnails"
4040
rm -r sdk/Users
4141

4242
# Full local validation, build and test all features including wasm

c2pa_c_ffi/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ serde = { version = "1.0", features = ["derive"] }
3434
serde_json = "1.0"
3535
thiserror = "1.0.64"
3636
tokio = { version = "1.36", features = ["rt-multi-thread", "rt"] }
37-
zip = { version = "3.0.0", default-features = false, features = ["deflate"] }
3837

3938
[dev-dependencies]
4039
tempfile = "3.7.0"

cli/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ env_logger = "0.11.7"
3333
glob = "0.3.1"
3434
log = "0.4"
3535
serde = { version = "1.0", features = ["derive"] }
36-
serde_derive = "1.0"
3736
serde_json = "1.0"
3837
toml = "0.8.23"
3938
tempfile = "3.3"

docs/usage.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,14 @@ The Rust library crate provides the following capabilities:
4242
* `json_schema` is used by `make schema` to produce a JSON schema document that represents the `ManifestStore` data structures.
4343
* `no_interleaved_io` forces fully-synchronous I/O; otherwise, the library uses threaded I/O for some operations to improve performance.
4444
* `serialize_thumbnails` includes binary thumbnail data in the [Serde](https://serde.rs/) serialization output.
45-
* `v1_api` - Use the old API (which will soon be deprecated) instead of the [new API](release-notes.md#new-api).
4645
* `pdf` - Enable support for reading claims on PDF files.
4746

48-
> [!NOTE]
49-
> If both `rust_native_crypto` and `openssl` are enabled, it will default to `rust_native_crypto`.
50-
> It is recommended to disable default features when using `rust_native_crypto` as to avoid including `openssl` as a dependency.
47+
* the `v1_api` feature is no longer supported.
5148

52-
### New API
49+
[!NOTE]
50+
If both `rust_native_crypto` and `openssl` are enabled, it will default to `rust_native_crypto`.
51+
It is recommended to disable default features when using `rust_native_crypto` as to avoid including `openssl` as a dependency.
5352

54-
The new API is now enabled by default. The `unstable_api` feature is no longer available.
55-
56-
To use the deprecated v1 API, enable the v1_api feature; for example:
57-
58-
```
59-
c2pa = {version="0.43.0", features=["v1_api"]}
60-
```
6153

6254
### Resource references
6355

make_test_images/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ c2pa = { path = "../sdk", version = "0.62.0", features = [
1919
"pdf"
2020
]}
2121
env_logger = "0.11"
22-
log = "0.4.8"
2322
lazy_static = "1.4.0"
2423
image = { version = "0.25.2", default-features = false, features = [
2524
"jpeg",

sdk/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ rust_native_crypto = [
4949
"dep:rsa",
5050
"dep:spki",
5151
]
52-
v1_api = []
5352

5453
# The diagnostics feature is unsupported and might be removed.
5554
# It enables some low-overhead timing features used in our development cycle.
@@ -61,6 +60,7 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(test)'] }
6160

6261
[[example]]
6362
name = "cawg_identity"
63+
required-features = ["file_io"]
6464

6565
[[example]]
6666
name = "client"
@@ -169,7 +169,6 @@ spki = { version = "0.7.3", optional = true }
169169
static-iref = "3.0"
170170
tempfile = "=3.15.0"
171171
thiserror = "2.0.8"
172-
treeline = "0.1.0"
173172
url = "2.5.3"
174173
uuid = { version = "1.18.0", features = ["serde", "v4"] }
175174
web-time = "1.1"
@@ -278,6 +277,7 @@ hex-literal = "0.4.1"
278277
jumbf = "0.4.0"
279278
c2pa_macros = { path = "../macros" }
280279
mockall = "0.13.1"
280+
once_cell = "1.17.2"
281281

282282
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dev-dependencies]
283283
wasm-bindgen-test = "0.3.45"

sdk/src/builder.rs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,42 +2313,6 @@ mod tests {
23132313
}
23142314
}
23152315

2316-
#[c2pa_test_async]
2317-
#[cfg(feature = "v1_api")]
2318-
async fn test_builder_remote_sign() {
2319-
let format = "image/jpeg";
2320-
let mut source = Cursor::new(TEST_IMAGE);
2321-
let mut dest = Cursor::new(Vec::new());
2322-
2323-
let mut builder = Builder::from_json(&simple_manifest_json()).unwrap();
2324-
builder
2325-
.add_ingredient_from_stream(parent_json(), format, &mut source)
2326-
.unwrap();
2327-
2328-
builder
2329-
.resources
2330-
.add("thumbnail.jpg", TEST_THUMBNAIL.to_vec())
2331-
.unwrap();
2332-
2333-
// sign the Builder and write it to the output stream
2334-
let signer = crate::utils::test::temp_async_remote_signer();
2335-
builder
2336-
.sign_async(signer.as_ref(), format, &mut source, &mut dest)
2337-
.await
2338-
.unwrap();
2339-
2340-
// read and validate the signed manifest store
2341-
dest.rewind().unwrap();
2342-
let manifest_store = Reader::from_stream(format, &mut dest).expect("from_bytes");
2343-
2344-
assert_eq!(manifest_store.validation_status(), None);
2345-
2346-
assert_eq!(
2347-
manifest_store.active_manifest().unwrap().title().unwrap(),
2348-
"Test_Manifest"
2349-
);
2350-
}
2351-
23522316
#[test]
23532317
#[cfg(feature = "file_io")]
23542318
fn test_builder_remote_url() {
@@ -2437,7 +2401,7 @@ mod tests {
24372401
}
24382402

24392403
#[c2pa_test_async]
2440-
#[cfg(any(target_arch = "wasm32", feature = "file_io"))]
2404+
#[cfg(target_arch = "wasm32")]
24412405
async fn test_builder_box_hashed_embeddable() {
24422406
use crate::asset_io::{CAIWriter, HashBlockObjectType};
24432407
const BOX_HASH_IMAGE: &[u8] = include_bytes!("../tests/fixtures/boxhash.jpg");

sdk/src/cose_sign.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,16 +273,18 @@ impl AsyncTimeStampProvider for AsyncSignerWrapper<'_> {
273273
#[cfg(test)]
274274
mod tests {
275275
#![allow(clippy::unwrap_used)]
276-
#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
276+
277277
// Only used for test with file_io
278278
use c2pa_macros::c2pa_test_async;
279+
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
280+
use wasm_bindgen_test::wasm_bindgen_test;
279281

280282
use super::sign_claim;
281-
#[cfg(feature = "file_io")]
282-
use crate::utils::test_signer::async_test_signer;
283283
use crate::{
284-
claim::Claim, crypto::raw_signature::SigningAlg, utils::test_signer::test_signer, Result,
285-
Signer,
284+
claim::Claim,
285+
crypto::raw_signature::SigningAlg,
286+
utils::test_signer::{async_test_signer, test_signer},
287+
Result, Signer,
286288
};
287289

288290
#[test]
@@ -307,7 +309,6 @@ mod tests {
307309
assert_eq!(cose_sign1.len(), box_size);
308310
}
309311

310-
#[cfg(feature = "file_io")]
311312
#[c2pa_test_async]
312313
async fn test_sign_claim_async() {
313314
// todo: we have to disable trust checks here for now because these

sdk/src/identity/identity_assertion/assertion.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -209,36 +209,6 @@ impl IdentityAssertion {
209209
}
210210
}
211211

212-
/// Summarize all of the identity assertions found for a [`ManifestStore`].
213-
///
214-
/// [`ManifestStore`]: crate::ManifestStore
215-
#[cfg(feature = "v1_api")]
216-
pub async fn summarize_manifest_store<SV: SignatureVerifier>(
217-
store: &crate::ManifestStore,
218-
status_tracker: &mut StatusTracker,
219-
verifier: &SV,
220-
) -> impl Serialize {
221-
// NOTE: We can't write this using .map(...).collect() because there are async
222-
// calls.
223-
let mut reports: BTreeMap<
224-
String,
225-
IdentityAssertionsForManifest<
226-
<<SV as SignatureVerifier>::Output as ToCredentialSummary>::CredentialSummary,
227-
>,
228-
> = BTreeMap::new();
229-
230-
for (id, manifest) in store.manifests() {
231-
let report = Self::summarize_all_impl(manifest, status_tracker, verifier).await;
232-
reports.insert(id.clone(), report);
233-
}
234-
235-
IdentityAssertionsForManifestStore::<
236-
<<SV as SignatureVerifier>::Output as ToCredentialSummary>::CredentialSummary,
237-
> {
238-
assertions_for_manifest: reports,
239-
}
240-
}
241-
242212
/// Summarize all of the identity assertions found for a [`Reader`].
243213
pub async fn summarize_from_reader<SV: SignatureVerifier>(
244214
reader: &Reader,

0 commit comments

Comments
 (0)