From e21c504b33983bf44e3853b296cf72d27f660517 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 1 Nov 2024 09:18:58 +0000 Subject: [PATCH] Migrate to latest `age-plugin` crate commit --- Cargo.lock | 6 ++---- Cargo.toml | 4 ++++ src/main.rs | 6 +----- src/plugin.rs | 23 +++++++++++++++++++++-- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1fa8f7d..72af44e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,8 +36,7 @@ dependencies = [ [[package]] name = "age-core" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5f11899bc2bbddd135edbc30c36b1924fa59d0746bb45beb5933fafe3fe509b" +source = "git+https://github.com/str4d/rage.git?rev=baf277a749c839e49f93bffb58d36734ac94be83#baf277a749c839e49f93bffb58d36734ac94be83" dependencies = [ "base64 0.21.7", "chacha20poly1305", @@ -54,8 +53,7 @@ dependencies = [ [[package]] name = "age-plugin" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04740d993aac0e06eaf4cfbf8484a8a23a6a7f950cf5d53bdf2d6ea3f429eb9d" +source = "git+https://github.com/str4d/rage.git?rev=baf277a749c839e49f93bffb58d36734ac94be83#baf277a749c839e49f93bffb58d36734ac94be83" dependencies = [ "age-core", "base64 0.21.7", diff --git a/Cargo.toml b/Cargo.toml index 55e910c..bc97f68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,3 +56,7 @@ man = "0.3" tempfile = "3" test-with = "0.11" which = "5" + +[patch.crates-io] +age-core = { git = "https://github.com/str4d/rage.git", rev = "baf277a749c839e49f93bffb58d36734ac94be83" } +age-plugin = { git = "https://github.com/str4d/rage.git", rev = "baf277a749c839e49f93bffb58d36734ac94be83" } diff --git a/src/main.rs b/src/main.rs index 0bbb5f4..aa00930 100644 --- a/src/main.rs +++ b/src/main.rs @@ -327,11 +327,7 @@ fn main() -> Result<(), Error> { } if let Some(state_machine) = opts.age_plugin { - run_state_machine( - &state_machine, - Some(plugin::RecipientPlugin::default), - Some(plugin::IdentityPlugin::default), - )?; + run_state_machine(&state_machine, plugin::Handler)?; Ok(()) } else if opts.version { println!("age-plugin-yubikey {}", env!("CARGO_PKG_VERSION")); diff --git a/src/plugin.rs b/src/plugin.rs index c0cd18b..30d7ca0 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -2,13 +2,28 @@ use age_core::format::{FileKey, Stanza}; use age_plugin::{ identity::{self, IdentityPluginV1}, recipient::{self, RecipientPluginV1}, - Callbacks, + Callbacks, PluginHandler, }; -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::io; use crate::{fl, format, key, p256::Recipient, PLUGIN_NAME}; +pub(crate) struct Handler; + +impl PluginHandler for Handler { + type RecipientV1 = RecipientPlugin; + type IdentityV1 = IdentityPlugin; + + fn recipient_v1(self) -> io::Result { + Ok(RecipientPlugin::default()) + } + + fn identity_v1(self) -> io::Result { + Ok(IdentityPlugin::default()) + } +} + #[derive(Debug, Default)] pub(crate) struct RecipientPlugin { recipients: Vec, @@ -58,6 +73,10 @@ impl RecipientPluginV1 for RecipientPlugin { } } + fn labels(&mut self) -> HashSet { + HashSet::new() + } + fn wrap_file_keys( &mut self, file_keys: Vec,