diff --git a/plugins/authenticator/guest-js/index.ts b/plugins/authenticator/guest-js/index.ts index 6f9da943..8b4a533c 100644 --- a/plugins/authenticator/guest-js/index.ts +++ b/plugins/authenticator/guest-js/index.ts @@ -2,7 +2,7 @@ import { invoke } from "@tauri-apps/api/tauri"; export class Authenticator { async init(): Promise { - return await invoke("plugin:authenticator|init"); + return await invoke("plugin:authenticator|init_auth"); } async register(challenge: string, application: string): Promise { diff --git a/plugins/authenticator/src/lib.rs b/plugins/authenticator/src/lib.rs index bc0d4c35..1fb4fffa 100644 --- a/plugins/authenticator/src/lib.rs +++ b/plugins/authenticator/src/lib.rs @@ -6,13 +6,13 @@ mod auth; mod error; mod u2f; -use tauri::{plugin::Plugin, Invoke, Runtime}; +use tauri::{plugin::{Builder as PluginBuilder, TauriPlugin}, Runtime}; pub use error::Error; type Result = std::result::Result; #[tauri::command] -fn init() { +fn init_auth() { auth::init_usb(); } @@ -60,30 +60,14 @@ fn verify_signature( ) } -pub struct TauriAuthenticator { - invoke_handler: Box) + Send + Sync>, -} - -impl Default for TauriAuthenticator { - fn default() -> Self { - Self { - invoke_handler: Box::new(tauri::generate_handler![ - init, - register, - verify_registration, - sign, - verify_signature - ]), - } - } -} - -impl Plugin for TauriAuthenticator { - fn name(&self) -> &'static str { - "authenticator" - } - - fn extend_api(&mut self, invoke: Invoke) { - (self.invoke_handler)(invoke) - } -} +pub fn init() -> TauriPlugin { + PluginBuilder::new("authenticator") + .invoke_handler(tauri::generate_handler![ + init_auth, + register, + verify_registration, + sign, + verify_signature + ]) + .build() +} \ No newline at end of file