Skip to main content

Module methods

Module methods 

Source
Available on crate features did-jwk or did-key or did-web only.
Expand description

DID methods: did:key (key), did:jwk (jwk) and did:web (web).

Each method is a type implementing DidResolver and DidProducer, registered with a Resolver through ResolverBuilder::with; default_methods registers all three at once. The methods are behind the did-key, did-jwk and did-web Cargo features, all on by default; did:web needs an HttpClient, and the reqwest feature provides ReqwestClient, a hardened default.

§Examples

use identity_kit::did::DidUrl;
use identity_kit::methods::web::ReqwestClient;

let resolver = identity_kit::methods::default_methods(ReqwestClient::new()?).build();
assert_eq!(resolver.methods(), ["jwk", "key", "web"]);

// Embedded methods need no network: the document is derived from the DID.
let key = DidUrl::parse(
    "did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK#z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK",
)?;
let jwk = resolver.resolve_public_key(&key, None).await?;
assert_eq!(jwk.crv(), Some("Ed25519"));

Re-exports§

pub use jwk::DidJwk;did-jwk
pub use key::DidKey;did-key
pub use web::DidWeb;did-web

Modules§

jwkdid-jwk
did:jwk: a DID that is a base64url-encoded JSON Web Key.
keydid-key
did:key: a DID that is a public key.
webdid-web
did:web: a DID document served over HTTPS by a web origin.

Functions§

default_methodsdid-web
A ResolverBuilder with every method this crate ships registered, with their defaults: did:key (DidKey), did:jwk (DidJwk) and did:web over http.