@contentauth/c2pa-node 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +35 -6
- package/Cargo.toml +1 -1
- package/README.md +142 -0
- package/dist/Builder.js +3 -0
- package/dist/Builder.spec.js +131 -67
- package/dist/Reader.js +2 -1
- package/dist/Reader.spec.js +1 -1
- package/dist/Settings.js +18 -34
- package/dist/Settings.spec.js +34 -39
- package/dist/Trustmark.spec.js +0 -4
- package/dist/binary.js +2 -1
- package/dist/index.node +0 -0
- package/dist/types/Builder.d.ts +2 -1
- package/dist/types/Settings.d.ts +2 -1
- package/dist/types/types.d.ts +22 -33
- package/package.json +24 -24
- package/src/lib.rs +4 -0
- package/src/neon_builder.rs +30 -6
- package/src/neon_reader.rs +4 -2
- package/src/neon_trustmark.rs +74 -30
- package/src/utils.rs +8 -6
package/src/utils.rs
CHANGED
|
@@ -46,25 +46,27 @@ pub fn parse_settings(
|
|
|
46
46
|
Some(js_value) => {
|
|
47
47
|
if js_value.is_a::<JsString, _>(cx) {
|
|
48
48
|
let settings_string = js_value
|
|
49
|
-
.downcast::<JsString, _>(cx)
|
|
49
|
+
.downcast::<JsString, _>(cx)
|
|
50
|
+
.map_err(|_| {
|
|
51
|
+
Error::Signing(format!("{error_prefix}: Expected settings string"))
|
|
52
|
+
})?
|
|
50
53
|
.value(cx);
|
|
51
54
|
|
|
52
55
|
// Create context with settings
|
|
53
56
|
let context = Context::new()
|
|
54
57
|
.with_settings(settings_string.as_str())
|
|
55
|
-
.map_err(|e|
|
|
56
|
-
|
|
58
|
+
.map_err(|e| {
|
|
59
|
+
Error::Signing(format!("{error_prefix}: Invalid settings: {e}"))
|
|
60
|
+
})?;
|
|
57
61
|
Ok(Some(context))
|
|
58
62
|
} else if js_value.is_a::<JsNull, _>(cx) || js_value.is_a::<JsUndefined, _>(cx) {
|
|
59
63
|
Ok(None)
|
|
60
64
|
} else {
|
|
61
65
|
Err(Error::Signing(format!(
|
|
62
|
-
"{}: Settings must be a string, null, or undefined",
|
|
63
|
-
error_prefix
|
|
66
|
+
"{error_prefix}: Settings must be a string, null, or undefined",
|
|
64
67
|
)))
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
None => Ok(None),
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
|
-
|