tangled
alpha
login
or
join now
vielle.dev
/
meview
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
resolve did to pds
vielle.dev
2 months ago
1fded173
6a56d7b9
verified
This commit was signed with the committer's
known signature
.
vielle.dev
SSH Key Fingerprint:
SHA256:/4bvxqoEh9iMdjAPgcgAgXKZZQTROL3ULiPt6nH9RSs=
+32
-5
5 changed files
expand all
collapse all
unified
split
Cargo.lock
Cargo.toml
src
db.rs
main.rs
resolver.rs
+1
Cargo.lock
···
1541
1541
dependencies = [
1542
1542
"jacquard",
1543
1543
"sqlx",
1544
1544
+
"thiserror 2.0.17",
1544
1545
"tokio",
1545
1546
]
1546
1547
+1
Cargo.toml
···
6
6
[dependencies]
7
7
jacquard = "0.9.0"
8
8
sqlx = { version = "0.8.6", features = ["runtime-tokio", "postgres"] }
9
9
+
thiserror = "2.0.17"
9
10
tokio = "1.48.0"
-1
src/db.rs
···
10
10
panic!()
11
11
}
12
12
};
13
13
-
println!("Connected to db with pool: {:?}", conn);
14
13
15
14
// initialise db tables
16
15
if let Err(err) = query!(
+9
-4
src/main.rs
···
1
1
mod config;
2
2
mod db;
3
3
+
mod resolver;
3
4
4
5
#[tokio::main]
5
6
async fn main() {
6
6
-
println!("Indexing {}", *config::USER);
7
7
+
println!("User: {}", *config::USER);
7
8
let conn = db::init().await;
8
8
-
println!("Database established");
9
9
+
println!("Database connected and initialized");
10
10
+
11
11
+
let pds = match resolver::resolve(&config::USER).await {
12
12
+
Ok(val) => val,
13
13
+
Err(err) => panic!("{}", err),
14
14
+
};
9
15
10
10
-
// to stop docker whinging
11
11
-
loop {}
16
16
+
println!("PDS: {}", pds);
12
17
}
+21
src/resolver.rs
···
1
1
+
use jacquard::prelude::IdentityResolver;
2
2
+
use jacquard::types::did::Did;
3
3
+
use thiserror::Error;
4
4
+
5
5
+
#[derive(Debug, Error)]
6
6
+
pub enum ResolveError {
7
7
+
#[error("Identity error: {}", .0)]
8
8
+
IdentityError(#[from] jacquard::identity::resolver::IdentityError),
9
9
+
#[error("Missing domain")]
10
10
+
MissingDomain,
11
11
+
}
12
12
+
13
13
+
pub async fn resolve(did: &Did<'_>) -> Result<String, ResolveError> {
14
14
+
// resolve did to pds
15
15
+
let resolver = jacquard::identity::PublicResolver::default();
16
16
+
let pds = resolver.pds_for_did(did).await?;
17
17
+
let Some(pds) = pds.domain() else {
18
18
+
return Err(ResolveError::MissingDomain);
19
19
+
};
20
20
+
Ok(String::from(pds))
21
21
+
}