ruby-c2pa 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/c2pa/version.rb +1 -1
- data/lib/c2pa.rb +8 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bc05300f370b0f4e0ac3edf08d92b55b305e8a16d6554342a077f0ac3f397eea
|
|
4
|
+
data.tar.gz: c790eb285655a76e3fbe9ae46c0803718b5b08bbda9ff0841e4716775811ac9a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 144409841d84d8a311ffb785e60a5f59a0616d420df89c0daf03da4c0f772e005e6a4bc93da375fcfa5a078856bb2182f133be9d4a79319850f62c7324474343
|
|
7
|
+
data.tar.gz: 0c8b604f64fd03404bbb031478047859a965f40ed1328bd061d64ae68acef999d0ad351f3f365167c4bd36d96888a772b26056d1daff94772992f5d4d79dd13b
|
data/README.md
CHANGED
|
@@ -179,7 +179,7 @@ manifest.add_ingredient(
|
|
|
179
179
|
|
|
180
180
|
### Signing a file
|
|
181
181
|
|
|
182
|
-
The `output` path must not already exist —
|
|
182
|
+
The `output` path must not already exist — `C2PA.sign` will raise a `C2PA::SigningError` if the file is already there.
|
|
183
183
|
|
|
184
184
|
```ruby
|
|
185
185
|
manifest = C2PA::Manifest.new(title: "Sunset over the bay")
|
|
@@ -243,6 +243,8 @@ rescue C2PA::ReadError => e
|
|
|
243
243
|
end
|
|
244
244
|
|
|
245
245
|
# Or rescue any C2PA error broadly
|
|
246
|
+
begin
|
|
247
|
+
C2PA.sign(file: "photo.jpg", output: "photo_signed.jpg", certificate: "cert.pem", key: "key.pem", manifest: manifest)
|
|
246
248
|
rescue C2PA::Error => e
|
|
247
249
|
puts "C2PA error: #{e.message}"
|
|
248
250
|
end
|
|
@@ -289,7 +291,7 @@ The Rust extension (`ext/c2pa_native/src/lib.rs`) defines `C2PA::Native` with th
|
|
|
289
291
|
| `C2PA::Native.read_file` | Read and return the manifest JSON |
|
|
290
292
|
| `C2PA::Native.sdk_version` | Return the c2pa-rs version string |
|
|
291
293
|
|
|
292
|
-
|
|
294
|
+
Input validation (missing files, invalid manifests) is handled in Ruby before calling into Rust. Errors from the native layer are caught and re-raised as typed `C2PA::Error` subclasses.
|
|
293
295
|
|
|
294
296
|
## License
|
|
295
297
|
|
data/lib/c2pa/version.rb
CHANGED
data/lib/c2pa.rb
CHANGED
|
@@ -28,7 +28,14 @@ module C2PA
|
|
|
28
28
|
# manifest: manifest
|
|
29
29
|
# )
|
|
30
30
|
def self.sign(file:, output:, certificate:, key:, algorithm: "es256", manifest:)
|
|
31
|
-
|
|
31
|
+
manifest_json = manifest.to_json
|
|
32
|
+
|
|
33
|
+
raise SigningError, "Source file not found: '#{file}'" unless File.exist?(file)
|
|
34
|
+
raise SigningError, "Certificate file not found: '#{certificate}'" unless File.exist?(certificate)
|
|
35
|
+
raise SigningError, "Key file not found: '#{key}'" unless File.exist?(key)
|
|
36
|
+
raise SigningError, "Output file already exists: '#{output}'" if File.exist?(output)
|
|
37
|
+
|
|
38
|
+
Native.sign_file(file, output, certificate, key, algorithm, manifest_json)
|
|
32
39
|
rescue RuntimeError => e
|
|
33
40
|
raise SigningError, e.message
|
|
34
41
|
end
|