host_import_user/
host_import_user.rs1use colink::*;
2use std::env;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
6 let args = env::args().skip(1).collect::<Vec<_>>();
7 let addr = &args[0];
8 let jwt = &args[1];
9 let expiration_timestamp: i64 = if args.len() > 2 {
10 args[2].parse().unwrap()
11 } else {
12 chrono::Utc::now().timestamp() + 86400 * 31
14 };
15
16 let cl = CoLink::new(addr, jwt);
17 let (pk, sk) = generate_user();
18 let core_pub_key = cl.request_info().await?.core_public_key;
19 let (signature_timestamp, sig) =
20 prepare_import_user_signature(&pk, &sk, &core_pub_key, expiration_timestamp);
21 println!(
22 "{}",
23 cl.import_user(&pk, signature_timestamp, expiration_timestamp, &sig)
24 .await?
25 );
26
27 Ok(())
28}