+4
src/did.rs
+4
src/did.rs
···
8
}
9
10
fn get_txt_did(handle: &String) -> Result<String, ()> {
11
// create a txt resolver
12
let resolver = match Resolver::new(ResolverConfig::default(), ResolverOpts::default()) {
13
Ok(val) => val,
···
38
}
39
40
fn get_http_did(handle: &String) -> Result<String, ()> {
41
let res =
42
match reqwest::blocking::get("https://".to_owned() + handle + "/.well-known/atproto-did") {
43
Ok(val) => val,
···
126
}
127
128
pub fn get_did(handle: String) -> Result<DidDoc, ()> {
129
let did = if let Ok(did) = get_txt_did(&handle) {
130
did
131
} else {
···
136
}
137
};
138
139
let did_doc = if did.starts_with("did:plc:") {
140
get_plc_doc(&did[8..])
141
} else if did.starts_with("did:web:") {
···
8
}
9
10
fn get_txt_did(handle: &String) -> Result<String, ()> {
11
+
println!(" Trying dns TXT for _atproto.{}", handle);
12
// create a txt resolver
13
let resolver = match Resolver::new(ResolverConfig::default(), ResolverOpts::default()) {
14
Ok(val) => val,
···
39
}
40
41
fn get_http_did(handle: &String) -> Result<String, ()> {
42
+
println!(" Trying https for https://{}/.well-known/atproto-did", handle);
43
let res =
44
match reqwest::blocking::get("https://".to_owned() + handle + "/.well-known/atproto-did") {
45
Ok(val) => val,
···
128
}
129
130
pub fn get_did(handle: String) -> Result<DidDoc, ()> {
131
+
println!(" Getting DID for {}", handle);
132
let did = if let Ok(did) = get_txt_did(&handle) {
133
did
134
} else {
···
139
}
140
};
141
142
+
println!(" Getting DID document for {}", did);
143
let did_doc = if did.starts_with("did:plc:") {
144
get_plc_doc(&did[8..])
145
} else if did.starts_with("did:web:") {
+1
-2
src/main.rs
+1
-2
src/main.rs
···
10
return Err(());
11
}
12
};
13
-
println!("{:#?}", config);
14
15
// resolve handle to did
16
let did_doc = match did::get_did(config.handle) {
17
Ok(res) => res,
18
Err(_) => {
···
20
return Err(());
21
}
22
};
23
-
println!("{:#?}", did_doc);
24
// resolve did+repoName to knotserver
25
26
// connect to /events on knotserver
···
10
return Err(());
11
}
12
};
13
14
// resolve handle to did
15
+
println!("Resolving {}", config.handle);
16
let did_doc = match did::get_did(config.handle) {
17
Ok(res) => res,
18
Err(_) => {
···
20
return Err(());
21
}
22
};
23
// resolve did+repoName to knotserver
24
25
// connect to /events on knotserver