confium 0.6.1 → 0.6.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d42dc62222d0c92dfa68876099cbac875766094cd9220c4ec10d5b6f605cd09
4
- data.tar.gz: 940eae5a8b8e090a5a1638885dc3bc3b4c9663deaa084dfed0852064432ee141
3
+ metadata.gz: 922db9bc620ddee90ba36a32d0c01d7a50dc13d685af98651288d7c913333af6
4
+ data.tar.gz: a46a79237e9b643fd31ee0e1f9fcfdf0df3a1d3f846f7f66bf22273394029944
5
5
  SHA512:
6
- metadata.gz: 04b73aaa3d4adf174c0c36af482de3b64d0e8ecaca91793a7996c04a50f78e8778189958697e4dc9a813f82d65c39ed36465871972584f03b509e3129c9242ef
7
- data.tar.gz: 0f2ee3e4d4d51958e278733bd3c7ee8160b9fea55d2073ca23ec88c321923c768469be5517d690b94d9308f8a85301389310c7591fbed934ee66d4a893c22f2c
6
+ metadata.gz: 84d6d5f4c7822d46d7f96fbc0d25800de7fd6d9548542c4deb8f219ec291750d932d079211b9a2e6671aa998cb340b77a26bf1678aa6a7b94e33ecebf4f32fc0
7
+ data.tar.gz: 1f95d17bf74f58728e280ca052519a2538afd1ec530538fc1aa7ebb6bdce2e60dcf7bd4b9c170db572634a23622b5b228d810548e4c89bde2c624a02fc6beb6c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.2] — 2026-08-26
4
+
5
+ ### Added
6
+
7
+ - `Confium::Store::Keystore` — Ruby surface for the store layer and
8
+ the sign-with-handle contract: `.new(backend, options)`,
9
+ `#sign(key_id, algorithm, message)` returning binary signature
10
+ bytes, plus `Confium::Store.backends`. Local backends raise a
11
+ typed `Confium::Error` for `#sign`; remote-holding backends (cloud
12
+ KMS) come via source builds that opt into their cargo features
13
+ (confium-store 0.5.8). `Confium::Error` now also accepts the
14
+ positional details-Hash form every typed subclass already accepts,
15
+ so native-constructed base errors carry `details` too.
16
+
3
17
  ## [0.6.1] — 2026-08-25
4
18
 
5
19
  ### Changed
data/Cargo.lock CHANGED
@@ -290,7 +290,7 @@ dependencies = [
290
290
  "chrono",
291
291
  "confium-api",
292
292
  "confium-net",
293
- "confium-store",
293
+ "confium-store 0.3.0",
294
294
  "confium-tc-core",
295
295
  "data-encoding",
296
296
  "hex",
@@ -463,6 +463,16 @@ dependencies = [
463
463
  "snafu 0.8.9",
464
464
  ]
465
465
 
466
+ [[package]]
467
+ name = "confium-store"
468
+ version = "0.5.8"
469
+ source = "registry+https://github.com/rust-lang/crates.io-index"
470
+ checksum = "5559e7f26bcf9f6dd3a76cf7eb0cf0684966c504cf662efef14f69ade8103e26"
471
+ dependencies = [
472
+ "inventory",
473
+ "snafu 0.9.2",
474
+ ]
475
+
466
476
  [[package]]
467
477
  name = "confium-tc"
468
478
  version = "0.3.1"
@@ -473,7 +483,7 @@ dependencies = [
473
483
  "confium-api",
474
484
  "confium-coordinator",
475
485
  "confium-net",
476
- "confium-store",
486
+ "confium-store 0.3.0",
477
487
  "confium-tc-keys",
478
488
  "data-encoding",
479
489
  "hex",
@@ -527,7 +537,7 @@ dependencies = [
527
537
  "chrono",
528
538
  "confium-api",
529
539
  "confium-net",
530
- "confium-store",
540
+ "confium-store 0.3.0",
531
541
  "data-encoding",
532
542
  "hex",
533
543
  "hmac",
@@ -638,6 +648,7 @@ dependencies = [
638
648
  "confium-observability",
639
649
  "confium-pki",
640
650
  "confium-privacy",
651
+ "confium-store 0.5.8",
641
652
  "confium-tc",
642
653
  "confium-tc-cmp20",
643
654
  "confium-tc-core",
@@ -37,6 +37,7 @@ confium-transparency = "0.4"
37
37
  confium-composite = "0.3.1"
38
38
  confium-attributes = "0.3.1"
39
39
  confium-pki = "0.5.6"
40
+ confium-store = "0.5.8"
40
41
  confium-deployment = "0.3"
41
42
  confium-tc = "0.3.1"
42
43
  confium-tc-frost-p256 = "0.3"
@@ -12,6 +12,7 @@ mod ers;
12
12
  mod openpgp_verify;
13
13
  mod path;
14
14
  mod pki;
15
+ mod store;
15
16
  mod tc;
16
17
  mod transparency;
17
18
  mod util;
@@ -49,6 +50,7 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
49
50
  composite::init(ruby, confium)?;
50
51
  attributes::init(ruby, confium)?;
51
52
  pki::init(ruby, confium)?;
53
+ store::init(ruby, confium)?;
52
54
  path::init(ruby, confium)?;
53
55
  deployment::init(ruby, confium)?;
54
56
  tc::init(ruby, confium)?;
@@ -0,0 +1,108 @@
1
+ //! Confium::Store — Ruby surface for `confium_store`.
2
+ //!
3
+ //! `Confium::Store::Keystore` opens a keystore by backend wire name
4
+ //! (`"memory"`, plus the remote-holding backends when the extension is
5
+ //! built with their features) and exposes the remote-sign path added
6
+ //! by the sign-with-handle contract:
7
+ //!
8
+ //! ks = Confium::Store::Keystore.new("memory")
9
+ //! ks.sign(key_id, algorithm, message) # => binary String
10
+ //!
11
+ //! Local backends raise for `#sign` — remote signing is implemented by
12
+ //! the cloud KMS backends (`aws-kms`, `gcp-kms`, `azure-keyvault`),
13
+ //! which source builds opt into via cargo features.
14
+
15
+ use confium_store::Keystore as RustKeystore;
16
+ use magnus::{
17
+ function, method, prelude::*, DataTypeFunctions, Error, Module, RHash, Ruby, TryConvert,
18
+ TypedData, Value,
19
+ };
20
+
21
+ use crate::util::{bytes_from_value, bytes_to_rstring, confium_error, new_details};
22
+
23
+ #[derive(TypedData, DataTypeFunctions)]
24
+ #[magnus(class = "Confium::Store::Keystore", size)]
25
+ pub struct Keystore {
26
+ inner: std::cell::RefCell<RustKeystore>,
27
+ }
28
+
29
+ fn store_error(e: confium_store::error::Error, operation: &str) -> Error {
30
+ let ruby = match Ruby::get() {
31
+ Ok(r) => r,
32
+ Err(_) => return Error::new(magnus::exception::runtime_error(), e.to_string()),
33
+ };
34
+ let details = new_details(&ruby);
35
+ let _ = details.aset("operation", operation);
36
+ match &e {
37
+ confium_store::error::Error::NotImplemented { what } => {
38
+ let _ = details.aset("what", *what);
39
+ }
40
+ confium_store::error::Error::UnknownBackend { name } => {
41
+ let _ = details.aset("backend", name.as_str());
42
+ }
43
+ _ => {}
44
+ }
45
+ confium_error(e.to_string(), "Error", details)
46
+ }
47
+
48
+ impl Keystore {
49
+ fn initialize(ruby: &Ruby, args: &[Value]) -> Result<Self, Error> {
50
+ let scanned = magnus::scan_args::scan_args::<(String,), (Option<RHash>,), (), (), (), ()>(args)
51
+ .map_err(|e| crate::util::arg_error(e.to_string()))?;
52
+ let backend = scanned.required.0;
53
+ let mut options = confium_store::backend::Options::new();
54
+ if let Some(hash) = scanned.optional.0 {
55
+ hash.foreach(|k: Value, v: Value| {
56
+ let key: String = <String as TryConvert>::try_convert(k)?;
57
+ let value: String = <String as TryConvert>::try_convert(v)?;
58
+ options.insert(key, value);
59
+ Ok(magnus::r_hash::ForEach::Continue)
60
+ })?;
61
+ }
62
+ let inner =
63
+ RustKeystore::new(&backend, &options).map_err(|e| store_error(e, "Keystore.new"))?;
64
+ let _ = ruby;
65
+ Ok(Self {
66
+ inner: std::cell::RefCell::new(inner),
67
+ })
68
+ }
69
+
70
+ /// Sign `message` with the remotely-held key `key_id` under the
71
+ /// provider algorithm name. Returns binary String signature bytes.
72
+ fn sign(&self, args: &[Value]) -> Result<magnus::RString, Error> {
73
+ let scanned = magnus::scan_args::scan_args::<(String, String), (Option<Value>,), (), (), (), ()>(args)
74
+ .map_err(|e| crate::util::arg_error(e.to_string()))?;
75
+ let (key_id, algorithm) = scanned.required;
76
+ let message = scanned
77
+ .optional
78
+ .0
79
+ .ok_or_else(|| crate::util::arg_error("Keystore#sign: message is required"))?;
80
+ let bytes = bytes_from_value(message)?;
81
+ let signature = self
82
+ .inner
83
+ .borrow()
84
+ .sign("confium", "ruby", &key_id, &algorithm, &bytes)
85
+ .map_err(|e| store_error(e, "Keystore#sign"))?;
86
+ Ok(bytes_to_rstring(
87
+ &Ruby::get().map_err(|e| crate::util::runtime(e.to_string()))?,
88
+ &signature,
89
+ ))
90
+ }
91
+ }
92
+
93
+ /// The backend wire names registered at link time
94
+ /// (`Confium::Store.backends`).
95
+ fn backends() -> Result<Vec<String>, Error> {
96
+ Ok(confium_store::backend::iter()
97
+ .map(|b| b.name().to_string())
98
+ .collect())
99
+ }
100
+
101
+ pub fn init(ruby: &Ruby, parent: magnus::RModule) -> Result<(), Error> {
102
+ let store = parent.define_module("Store")?;
103
+ let class = store.define_class("Keystore", ruby.class_object())?;
104
+ class.define_singleton_method("new", function!(Keystore::initialize, -1))?;
105
+ class.define_method("sign", method!(Keystore::sign, -1))?;
106
+ store.define_module_function("backends", function!(backends, 0))?;
107
+ Ok(())
108
+ }
@@ -12,8 +12,17 @@ module Confium
12
12
  class Error < StandardError
13
13
  attr_reader :details
14
14
 
15
- def initialize(message = nil, details: {})
16
- @details = details.transform_keys(&:to_sym)
15
+ # The native extension constructs errors positionally
16
+ # (message, details_hash) — the same shape every typed subclass
17
+ # accepts via Errors::Coerce. Accepting it here keeps the whole
18
+ # family uniform; the keyword form still works.
19
+ def initialize(message = nil, details_hash = nil, details: {})
20
+ base = if details_hash.is_a?(Hash) && !details_hash.empty?
21
+ details_hash
22
+ else
23
+ details
24
+ end
25
+ @details = base.transform_keys(&:to_sym)
17
26
  super(message)
18
27
  end
19
28
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Confium
4
- VERSION = '0.6.1'
4
+ VERSION = '0.6.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Open
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-25 00:00:00.000000000 Z
11
+ date: 2026-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys
@@ -124,6 +124,7 @@ files:
124
124
  - ext/confium_native/src/openpgp_verify.rs
125
125
  - ext/confium_native/src/path.rs
126
126
  - ext/confium_native/src/pki.rs
127
+ - ext/confium_native/src/store.rs
127
128
  - ext/confium_native/src/tc.rs
128
129
  - ext/confium_native/src/transparency.rs
129
130
  - ext/confium_native/src/util.rs