add Resolve* methods to Directory interface #872
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a step in the right direction for this package, I think:
Lookup*
for full bi-di verification, and gives a compact/ergonomic struct for atproto use-cases (and good for caching)Resolve*
does more bare-bones resolution: you get specifically what you ask for. Things like Relay, or pure service auth validation, which don't care about handles, can useResolveDID
Downsides and open questions:
ResolveDID
doesn't return the raw DID doc verbatim, it is a struct, and might be discarding info (like fields in DID core specification that we aren't using). I think this is good enough, maybeBaseDirectory
can expose more "Raw" variants which returnjson.RawMessage
ormap[string]any
or something.ResolveDID
isn't the sameIdentity
type used in possible function signatures. They can be converted, but it uses some allocs etc. I think adding a helper to quickly extract the DID signing key and/or PDS endpoint is probably sufficient? But feels a bit redundant withIdentity
structIdentity
struct (compact) or theDIDDocument
struct, and convert between? Or both, would be less conversions but more RAM? I think what we should do is cache what is actually requested.Lookup*
cachesIdentity
,ResolveDID
caches DIDDocument, and these caches aren't shared. Services will be using one or the other anyways. What about an identity caching layer? That could cache the raw DID document and handle resolution, and convert toIdentity
on demand.Alternative would be breaking changes to existing structs (which are heavily cached), or maybe a flag or variant like
LookupDIDWithoutHandle
?Another alternative is to set a flag to skip handle resolution; I don't like this: #854
An upcoming change here is to add
ResolveNSID
, which will be used for Lexicon resolution.(have not pushed implementation of exiting interfaces until design questions are resolved)