Refactor credential issuer metadata resolver api #76
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.
Description of change
CredentialIssuerMetadataType
protocol has API issues that make it hard to use and its only implementationCredentialIssuerMetadataResolver
can be improved too.List of improvements I propose in this PR:
CredentialIssuerMetadataType.resolve(source:)
parameter type to non-optional. There is no value for it being optional as the implementation cannot do anything but return an error if the source is not defined.CredentialIssuerMetadataType.resolve
function'sSuccess
result type to non-optional. The use ofResult
as the return type already provides a channel for errors and it is unclear what the result.success(nil)
should even mean from the client perspective, but all clients had to handle the "empty" result anyway. Furthermore the only implementationCredentialIssuerMetadataResolver.resolve
did not have a control flow that would have returned.success(nil)
in any case.Fetcher
error inCredentialIssuerMetadataResolver.resolve
. If there was an error fetching the metadata the error returned by theFetcher
was thrown away (converted tonil
withtry? result.get()
) and a genericValidationError.error(reason: "Unable to retrieve metadata")
was returned instead. This makes it hard to detect or debug what the actual error was when fetching the metadata and it is better not to mask the error and there is no reason to map it to some other error type either. AlsoValidationError
does not sound like a good match for e.g. a network error returned by theFetcher
. Omitting the error mapping also streamlines theresolve
implementation significantly, as it can directly return theFetcher
's result.CredentialIssuerMetadataResolver.resolve
. The constants have only a single use site and inlining them makes it more obvious in the code in what order the components are appended to the path.Type of change
Please delete options that are not relevant.
CredentialIssuerMetadataType.resolve(source:)
need to remove thenil
checking of success result.How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: