diff --git a/Sources/Main/Resolvers/CredentialOffer/CredentialIssuerMetadataResolver.swift b/Sources/Main/Resolvers/CredentialOffer/CredentialIssuerMetadataResolver.swift index 52b75a9..397b64d 100644 --- a/Sources/Main/Resolvers/CredentialOffer/CredentialIssuerMetadataResolver.swift +++ b/Sources/Main/Resolvers/CredentialOffer/CredentialIssuerMetadataResolver.swift @@ -35,8 +35,8 @@ public protocol CredentialIssuerMetadataType { /// - source: The input source for resolving data. /// - Returns: An asynchronous result containing the resolved data or an error. func resolve( - source: InputType? - ) async -> Result + source: InputType + ) async -> Result } public actor CredentialIssuerMetadataResolver: CredentialIssuerMetadataType { @@ -56,26 +56,14 @@ public actor CredentialIssuerMetadataResolver: CredentialIssuerMetadataType { /// - source: The input source for resolving metadata. /// - Returns: An asynchronous result containing the resolved metadata or an error of type ResolvingError. public func resolve( - source: CredentialIssuerSource? - ) async -> Result { - switch source { - case .credentialIssuer(let issuerId): - - let pathComponent1 = ".well-known" - let pathComponent2 = "openid-credential-issuer" - - let url = issuerId.url - .appendingPathComponent(pathComponent1) - .appendingPathComponent(pathComponent2) - - let result = await fetcher.fetch(url: url) - let metaData = try? result.get() - if let metaData = metaData { - return .success(metaData) + source: CredentialIssuerSource + ) async -> Result { + switch source { + case .credentialIssuer(let issuerId): + let url = issuerId.url + .appendingPathComponent(".well-known") + .appendingPathComponent("openid-credential-issuer") + return await fetcher.fetch(url: url) } - return .failure(ValidationError.error(reason: "Unable to retrieve metadata")) - case .none: - return .failure(CredentialError.genericError) - } } } diff --git a/Tests/Helpers/Wallet.swift b/Tests/Helpers/Wallet.swift index 88029dc..5c7b7ef 100644 --- a/Tests/Helpers/Wallet.swift +++ b/Tests/Helpers/Wallet.swift @@ -66,8 +66,7 @@ extension Wallet { switch issuerMetadata { case .success(let metaData): - if let authorizationServer = metaData?.authorizationServers?.first, - let metaData { + if let authorizationServer = metaData.authorizationServers?.first { let resolver = AuthorizationServerMetadataResolver( oidcFetcher: Fetcher(session: self.session), oauthFetcher: Fetcher(session: self.session)