mirror of
https://github.com/aljazceru/pubky-core.git
synced 2025-12-19 06:54:19 +01:00
* Add admin and signup config * Add signup tokens API, db, admin endpoint * Add client api for signup codes * Add tests and fixes * Fix wasm build * Lint * enable and use same admin pswd on all test homeservers * fix pr review comments * Add nodejs and browser signup token to tests * update signup example * admin authing as layer * Update pubky-homeserver/src/core/routes/auth.rs Co-authored-by: Severin Alexander Bühler <8782386+SeverinAlexB@users.noreply.github.com> * Update pubky-homeserver/src/core/routes/auth.rs Co-authored-by: Severin Alexander Bühler <8782386+SeverinAlexB@users.noreply.github.com> * rename getSignupToken util * add is_used() SignupToken method --------- Co-authored-by: Severin Alexander Bühler <8782386+SeverinAlexB@users.noreply.github.com>
55 lines
1.4 KiB
Rust
55 lines
1.4 KiB
Rust
use anyhow::Result;
|
|
use clap::Parser;
|
|
use pubky::{Client, PublicKey};
|
|
use std::path::PathBuf;
|
|
|
|
#[derive(Parser, Debug)]
|
|
#[command(version, about, long_about = None)]
|
|
struct Cli {
|
|
/// Homeserver Pkarr Domain (for example `5jsjx1o6fzu6aeeo697r3i5rx15zq41kikcye8wtwdqm4nb4tryo`)
|
|
homeserver: String,
|
|
|
|
/// Path to a recovery_file of the Pubky you want to sign in with
|
|
recovery_file: PathBuf,
|
|
|
|
/// Signup code (optional)
|
|
signup_code: Option<String>,
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
let cli = Cli::parse();
|
|
|
|
let recovery_file = std::fs::read(&cli.recovery_file)?;
|
|
println!("\nSuccessfully opened recovery file");
|
|
|
|
let homeserver = cli.homeserver;
|
|
|
|
let client = Client::builder().build()?;
|
|
|
|
println!("Enter your recovery_file's passphrase to signup:");
|
|
let passphrase = rpassword::read_password()?;
|
|
|
|
let keypair = pubky::recovery_file::decrypt_recovery_file(&recovery_file, &passphrase)?;
|
|
|
|
println!("Successfully decrypted the recovery file, signing up to the homeserver:");
|
|
|
|
client
|
|
.signup(
|
|
&keypair,
|
|
&PublicKey::try_from(homeserver).unwrap(),
|
|
cli.signup_code.as_deref(),
|
|
)
|
|
.await?;
|
|
|
|
println!("Successfully signed up. Checking session:");
|
|
|
|
let session = client.session(&keypair.public_key()).await?;
|
|
|
|
println!("Successfully resolved current session at the homeserver.");
|
|
|
|
println!("{:?}", session);
|
|
|
|
Ok(())
|
|
}
|