diff --git a/Sources/Entities/AccessManagement/AuthorizationServerMetadata.swift b/Sources/Entities/AccessManagement/AuthorizationServerMetadata.swift index 7a3a90a..bc1d1f3 100644 --- a/Sources/Entities/AccessManagement/AuthorizationServerMetadata.swift +++ b/Sources/Entities/AccessManagement/AuthorizationServerMetadata.swift @@ -79,43 +79,43 @@ public struct AuthorizationServerMetadata: Codable, Equatable { } public init( - issuer: String?, - authorizationEndpoint: String?, - tokenEndpoint: String?, - introspectionEndpoint: String?, - jwksURI: String?, - grantTypesSupported: [String]?, - responseTypesSupported: [String]?, - requestObjectSigningAlgValuesSupported: [String]?, - requestObjectEncryptionAlgValuesSupported: [String]?, - requestObjectEncryptionEncValuesSupported: [String]?, - responseModesSupported: [String]?, - registrationEndpoint: String?, - tokenEndpointAuthMethodsSupported: [String]?, - tokenEndpointAuthSigningAlgValuesSupported: [String]?, - introspectionEndpointAuthMethodsSupported: [String]?, - introspectionEndpointAuthSigningAlgValuesSupported: [String]?, - authorizationSigningAlgValuesSupported: [String]?, - authorizationEncryptionAlgValuesSupported: [String]?, - authorizationEncryptionEncValuesSupported: [String]?, - scopesSupported: [String]?, - requestParameterSupported: Bool?, - requestURIParameterSupported: Bool?, - requireRequestURIRegistration: Bool?, - codeChallengeMethodsSupported: [String]?, - tlsClientCertificateBoundAccessTokens: Bool?, - dpopSigningAlgValuesSupported: [String]?, - revocationEndpoint: String?, - revocationEndpointAuthMethodsSupported: [String]?, - revocationEndpointAuthSigningAlgValuesSupported: [String]?, - deviceAuthorizationEndpoint: String?, - backchannelTokenDeliveryModesSupported: [String]?, - backchannelAuthenticationEndpoint: String?, - backchannelAuthenticationRequestSigningAlgValuesSupported: [String]?, - requirePushedAuthorizationRequests: Bool?, - pushedAuthorizationRequestEndpoint: String?, - mtlsEndpointAliases: MtlsEndpointAliases?, - authorizationResponseIssParameterSupported: Bool? + issuer: String? = nil, + authorizationEndpoint: String? = nil, + tokenEndpoint: String? = nil, + introspectionEndpoint: String? = nil, + jwksURI: String? = nil, + grantTypesSupported: [String]? = nil, + responseTypesSupported: [String]? = nil, + requestObjectSigningAlgValuesSupported: [String]? = nil, + requestObjectEncryptionAlgValuesSupported: [String]? = nil, + requestObjectEncryptionEncValuesSupported: [String]? = nil, + responseModesSupported: [String]? = nil, + registrationEndpoint: String? = nil, + tokenEndpointAuthMethodsSupported: [String]? = nil, + tokenEndpointAuthSigningAlgValuesSupported: [String]? = nil, + introspectionEndpointAuthMethodsSupported: [String]? = nil, + introspectionEndpointAuthSigningAlgValuesSupported: [String]? = nil, + authorizationSigningAlgValuesSupported: [String]? = nil, + authorizationEncryptionAlgValuesSupported: [String]? = nil, + authorizationEncryptionEncValuesSupported: [String]? = nil, + scopesSupported: [String]? = nil, + requestParameterSupported: Bool? = nil, + requestURIParameterSupported: Bool? = nil, + requireRequestURIRegistration: Bool? = nil, + codeChallengeMethodsSupported: [String]? = nil, + tlsClientCertificateBoundAccessTokens: Bool? = nil, + dpopSigningAlgValuesSupported: [String]? = nil, + revocationEndpoint: String? = nil, + revocationEndpointAuthMethodsSupported: [String]? = nil, + revocationEndpointAuthSigningAlgValuesSupported: [String]? = nil, + deviceAuthorizationEndpoint: String? = nil, + backchannelTokenDeliveryModesSupported: [String]? = nil, + backchannelAuthenticationEndpoint: String? = nil, + backchannelAuthenticationRequestSigningAlgValuesSupported: [String]? = nil, + requirePushedAuthorizationRequests: Bool? = nil, + pushedAuthorizationRequestEndpoint: String? = nil, + mtlsEndpointAliases: MtlsEndpointAliases? = nil, + authorizationResponseIssParameterSupported: Bool? = nil ) { self.issuer = issuer self.authorizationEndpoint = authorizationEndpoint diff --git a/Sources/Entities/CredentialIssuer/CredentialIssuerEndpoint.swift b/Sources/Entities/CredentialIssuer/CredentialIssuerEndpoint.swift index eb25954..9a9981c 100644 --- a/Sources/Entities/CredentialIssuer/CredentialIssuerEndpoint.swift +++ b/Sources/Entities/CredentialIssuer/CredentialIssuerEndpoint.swift @@ -45,4 +45,10 @@ public struct CredentialIssuerEndpoint: Codable, Equatable { let urlString = try container.decode(String.self) url = try URL(string: urlString) ?? { throw ValidationError.error(reason: "Invalid credential_issuer URL")}() } + + // Implement the encode(to encoder:) method + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(url.absoluteString) + } } diff --git a/Sources/Entities/CredentialIssuer/CredentialIssuerMetadata.swift b/Sources/Entities/CredentialIssuer/CredentialIssuerMetadata.swift index 6232bbf..f19ce2e 100644 --- a/Sources/Entities/CredentialIssuer/CredentialIssuerMetadata.swift +++ b/Sources/Entities/CredentialIssuer/CredentialIssuerMetadata.swift @@ -77,6 +77,20 @@ public struct CredentialIssuerMetadata: Decodable, Equatable { self.credentialIdentifiersSupported = credentialIdentifiersSupported } + public init(deferredCredentialEndpoint: CredentialIssuerEndpoint?) throws { + try self.init( + credentialIssuerIdentifier: .init(""), + authorizationServers: [], + credentialEndpoint: .init(string: ""), + batchCredentialEndpoint: nil, + deferredCredentialEndpoint: deferredCredentialEndpoint, + notificationEndpoint: nil, + credentialConfigurationsSupported: [:], + signedMetadata: nil, + display: nil + ) + } + // Implement a custom init(from decoder:) method to handle decoding. public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) diff --git a/Sources/Issuers/Issuer.swift b/Sources/Issuers/Issuer.swift index bce5634..65eb525 100644 --- a/Sources/Issuers/Issuer.swift +++ b/Sources/Issuers/Issuer.swift @@ -701,6 +701,19 @@ private extension Issuer { public extension Issuer { + static func createDeferredIssuer( + deferredCredentialEndpoint: CredentialIssuerEndpoint?, + deferredRequesterPoster: PostingType, + config: OpenId4VCIConfig + ) throws -> Issuer { + try Issuer( + authorizationServerMetadata: .oauth(.init()), + issuerMetadata: .init(deferredCredentialEndpoint: deferredCredentialEndpoint), + config: config, + deferredRequesterPoster: deferredRequesterPoster + ) + } + static func createResponseEncryptionSpec(_ issuerResponseEncryptionMetadata: CredentialResponseEncryption) -> IssuanceResponseEncryptionSpec? { switch issuerResponseEncryptionMetadata { case .notRequired: