feat: Implemented NIP-4e (#11)

* chore: refactor account registry

* wip: nip4e

* chore: rename account to device

* feat: nip44 encryption with master signer

* update

* refactor

* feat: unwrap with device keys

* chore: improve handler

* chore: fix rustls

* chore: refactor onboarding

* chore: fix compose

* chore: fix send message

* chore: fix forgot to request device

* fix send message

* chore: fix deadlock

* chore: small fixes

* chore: improve

* fix

* refactor

* refactor

* refactor

* fix

* add fetch request

* save keys

* fix

* update

* update

* update
This commit is contained in:
reya
2025-03-08 19:29:25 +07:00
committed by GitHub
parent 81664e3d4e
commit a53b2181ab
31 changed files with 1744 additions and 1065 deletions

View File

@@ -5,12 +5,15 @@ edition = "2021"
publish = false
[dependencies]
global = { path = "../global" }
gpui.workspace = true
nostr-sdk.workspace = true
anyhow.workspace = true
itertools.workspace = true
chrono.workspace = true
dirs.workspace = true
smallvec.workspace = true
random_name_generator = "0.3.6"
qrcode-generator = "5.0.0"

View File

@@ -1,26 +0,0 @@
pub const KEYRING_SERVICE: &str = "Coop Safe Storage";
pub const APP_NAME: &str = "Coop";
pub const APP_ID: &str = "su.reya.coop";
/// Bootstrap relays
pub const BOOTSTRAP_RELAYS: [&str; 3] = [
"wss://relay.damus.io",
"wss://relay.primal.net",
"wss://purplepag.es",
];
/// Subscriptions
pub const NEW_MESSAGE_SUB_ID: &str = "listen_new_giftwraps";
pub const ALL_MESSAGES_SUB_ID: &str = "listen_all_giftwraps";
/// Image Resizer Service
pub const IMAGE_SERVICE: &str = "https://wsrv.nl";
/// NIP96 Media Server
pub const NIP96_SERVER: &str = "https://nostrmedia.com";
/// Updater Public Key
pub const UPDATER_PUBKEY: &str = "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDkxM0EzQTQyRTBBMENENTYKUldSV3phRGdRam82a1dtU0JqYll4VnBaVUpSWUxCWlVQbnRkUnNERS96MzFMWDhqNW5zOXplMEwK";
/// Updater Server URL
pub const UPDATER_URL: &str =
"https://cdn.crabnebula.app/update/lume/coop/{{target}}-{{arch}}/{{current_version}}";

View File

@@ -1,4 +1,3 @@
pub mod constants;
pub mod last_seen;
pub mod profile;
pub mod qr;

View File

@@ -1,13 +1,14 @@
use global::constants::IMAGE_SERVICE;
use gpui::SharedString;
use nostr_sdk::prelude::*;
use crate::constants::IMAGE_SERVICE;
use smallvec::SmallVec;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NostrProfile {
public_key: PublicKey,
avatar: SharedString,
name: SharedString,
pub public_key: PublicKey,
pub avatar: SharedString,
pub name: SharedString,
pub messaging_relays: Option<SmallVec<[RelayUrl; 3]>>,
}
impl NostrProfile {
@@ -19,20 +20,14 @@ impl NostrProfile {
public_key,
name,
avatar,
messaging_relays: None,
}
}
/// Get contact's public key
pub fn public_key(&self) -> PublicKey {
self.public_key
}
pub fn avatar(&self) -> SharedString {
self.avatar.clone()
}
pub fn name(&self) -> SharedString {
self.name.clone()
/// Set contact's relays
pub fn relays(mut self, relays: Option<SmallVec<[RelayUrl; 3]>>) -> Self {
self.messaging_relays = relays;
self
}
fn extract_avatar(metadata: &Metadata) -> SharedString {

View File

@@ -1,4 +1,4 @@
use crate::constants::NIP96_SERVER;
use global::constants::NIP96_SERVER;
use itertools::Itertools;
use nostr_sdk::prelude::*;
use rnglib::{Language, RNG};