Skip to content

Commit acd934c

Browse files
committed
nip55: init
- Add `AndroidSigner` - Add `AndroidSigner::is_external_signer_installed` Closes #938 Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
1 parent 8b6a68a commit acd934c

File tree

9 files changed

+440
-2
lines changed

9 files changed

+440
-2
lines changed

Cargo.lock

Lines changed: 133 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ nostr-ndb = { version = "0.42", path = "./database/nostr-ndb", default-features
4949
nostr-relay-builder = { version = "0.42", path = "./crates/nostr-relay-builder", default-features = false }
5050
nostr-relay-pool = { version = "0.42", path = "./crates/nostr-relay-pool", default-features = false }
5151
nostr-sdk = { version = "0.42", path = "./crates/nostr-sdk", default-features = false }
52+
once_cell = "1.21"
5253
reqwest = { version = "0.12", default-features = false }
5354
serde = { version = "1.0", default-features = false }
5455
serde_json = { version = "1.0", default-features = false }

contrib/scripts/check-crates.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ buildargs=(
3737
"-p nostr --no-default-features --features alloc" # Only alloc feature
3838
"-p nostr --no-default-features --features alloc,all-nips" # alloc + all-nips
3939
"-p nip07 --target wasm32-unknown-unknown"
40+
"-p nip55"
4041
"-p nostr-blossom"
4142
"-p nostr-http-file-storage"
4243
"-p nostr-database"

contrib/scripts/release.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -euo pipefail
55
args=(
66
"-p nostr"
77
"-p nip07"
8+
"-p nip55"
89
"-p nostr-database"
910
"-p nostr-lmdb"
1011
"-p nostr-mls-storage"

crates/nip55/Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "nip55"
3+
version = "0.42.0"
4+
edition = "2021"
5+
description = "Nostr Android signer implementation (NIP-55)."
6+
authors.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
license.workspace = true
10+
readme = "README.md"
11+
rust-version.workspace = true
12+
keywords = ["nostr", "nip55", "android", "signer"]
13+
14+
[dependencies]
15+
jni = "0.21"
16+
jvm-getter = "0.1"
17+
nostr = { workspace = true, features = ["std"] }
18+
once_cell = "1.21"

crates/nip55/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Android signer (NIP-55)
2+
3+
## Description
4+
5+
Nostr Android signer implementation ([NIP-55](https://github.com/nostr-protocol/nips/blob/master/55.md)).
6+
7+
## State
8+
9+
**This library is in an ALPHA state**, things that are implemented generally work but the API will change in breaking ways.
10+
11+
## Donations
12+
13+
`rust-nostr` is free and open-source. This means we do not earn any revenue by selling it. Instead, we rely on your financial support. If you actively use any of the `rust-nostr` libs/software/services, then please [donate](https://rust-nostr.org/donate).
14+
15+
## License
16+
17+
This project is distributed under the MIT software license - see the [LICENSE](../../LICENSE) file for details

crates/nip55/src/error.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (c) 2022-2023 Yuki Kishimoto
2+
// Copyright (c) 2023-2025 Rust Nostr Developers
3+
// Distributed under the MIT software license
4+
5+
//! Android Signer error
6+
7+
use std::fmt;
8+
9+
use jni::errors::Error as JniError;
10+
use nostr::event;
11+
12+
/// Android Signer error
13+
#[derive(Debug)]
14+
pub enum Error {
15+
/// JNI error
16+
Jni(JniError),
17+
/// Nostr event error
18+
Event(event::Error),
19+
/// Can't find the JVM
20+
JVMNotFound,
21+
}
22+
23+
impl std::error::Error for Error {}
24+
25+
impl fmt::Display for Error {
26+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27+
match self {
28+
Self::Jni(e) => write!(f, "{e}"),
29+
Self::Event(e) => write!(f, "{e}"),
30+
Self::JVMNotFound => write!(f, "JVM not found"),
31+
}
32+
}
33+
}
34+
35+
impl From<JniError> for Error {
36+
fn from(e: JniError) -> Self {
37+
Self::Jni(e)
38+
}
39+
}
40+
41+
impl From<event::Error> for Error {
42+
fn from(e: event::Error) -> Self {
43+
Self::Event(e)
44+
}
45+
}

0 commit comments

Comments
 (0)