Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DIDMethodResolver #12

Merged
merged 6 commits into from
Feb 9, 2024
Merged

DIDMethodResolver #12

merged 6 commits into from
Feb 9, 2024

Conversation

amika-sq
Copy link
Contributor

@amika-sq amika-sq commented Feb 9, 2024

My previous attempt at adding a DIDMethodResolver protocol in #9 didn't really work out how I intended it to, so I reverted it.

This PR re-introduces a DIDMethodResolver protocol, and handles the behaviors of a DID resolver much better.

DIDMethodResolver

DIDMethodResolver is a new protocol that defines what's required to resolve a DID method. There are two things:

  1. the methodName that's being resolved
  2. a func resolve(didURI: String) -> ResolutionResult function

Each DID method implements this DIDMethodResolver with a struct. This struct can then initiated and registered with DIDResolver, to customize the resolution experience for any SDK consumer's use case.

DIDResolver

DIDResolver now has a new function available on it:
public static func register(resolver: DIDMethodResolver)

This is how an SDK consumer can customize the behavior of the resolution of any DID Method. For example, if a user wanted to customize the experience of resolving did:ion, they would do the following:

let resolver = DIDIon.Resolver(options: .init(gatewayURI: "https://my-custom-gateway.org"))
DIDResolver.register(resolver: resolver)

@amika-sq amika-sq enabled auto-merge (squash) February 9, 2024 16:49
@amika-sq amika-sq merged commit 6dff82e into main Feb 9, 2024
1 check passed
@amika-sq amika-sq deleted the did-method-resolver branch February 9, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant