Skip to main content

Nip55Backend

Trait Nip55Backend 

Source
pub trait Nip55Backend:
    Send
    + Sync
    + 'static {
    // Required methods
    fn is_installed(&self) -> Result<bool, Nip55Error>;
    fn get_public_key_pairing(
        &self,
        perms_json: &str,
    ) -> Result<(String, String), Nip55Error>;
    fn resolver_op(
        &self,
        method: &str,
        data: &str,
        counterparty: &str,
        current_user: &str,
    ) -> Nip55ResolverOutcome;
    fn intent_op(
        &self,
        intent_type: &str,
        data: &str,
        counterparty: &str,
        current_user: &str,
    ) -> Result<(Option<String>, Option<String>), Nip55Error>;
    fn is_foreground(&self) -> bool;
}
Expand description

The Android-side transport for a NIP-55 signer. Implemented in the Tauri shell (JNI + ContentResolver + Intent-for-result); registered once at startup via set_nip55_backend.

All methods are blocking (JNI) — Nip55Signer wraps each in spawn_blocking behind a concurrency semaphore, so implementors may block freely (including parking on an Activity-result condvar for the foreground pairing/fallback path).

Hex strings are lowercase x-only pubkey hex. current_user_hex is always the paired identity; passing it on every op lets Amber route to the right account even if the user has several.

Required Methods§

Source

fn is_installed(&self) -> Result<bool, Nip55Error>

Whether an external signer app is installed and resolvable. Cheap; the login screen and boot path call it to avoid offering a dead button.

Source

fn get_public_key_pairing( &self, perms_json: &str, ) -> Result<(String, String), Nip55Error>

Pairing handshake (foreground get_public_key Intent). The user picks their identity and grants the remembered permission set. Returns (user_pubkey, signer_package); the package is pinned for every subsequent op. Called ONCE at login — never again while signed in.

Source

fn resolver_op( &self, method: &str, data: &str, counterparty: &str, current_user: &str, ) -> Nip55ResolverOutcome

Fast, silent background ContentResolver op. method is the uppercase content-authority suffix (SIGN_EVENT, NIP44_DECRYPT, …); data is the payload (event JSON / plaintext / ciphertext); counterparty is the other party’s pubkey hex (empty for SIGN_EVENT). Returns a TRI-STATE the caller must not collapse (see Nip55ResolverOutcome).

Source

fn intent_op( &self, intent_type: &str, data: &str, counterparty: &str, current_user: &str, ) -> Result<(Option<String>, Option<String>), Nip55Error>

Foreground Intent fallback (may block up to the sign timeout on user approval). Returns (result, event)result carries sig/ciphertext/plaintext, event the signed event JSON for sign_event. Only invoked when is_foreground is true.

Source

fn is_foreground(&self) -> bool

Whether a foreground Activity exists to prompt the user. False in the Activity-less background service, where an un-remembered op fails soft.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§