Skip to content

Commit

Permalink
[fix] issuer conveniences
Browse files Browse the repository at this point in the history
  • Loading branch information
dtsiflit committed Jul 15, 2024
1 parent 9e512f9 commit 94f8968
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 37 deletions.
74 changes: 37 additions & 37 deletions Sources/Entities/AccessManagement/AuthorizationServerMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
14 changes: 14 additions & 0 deletions Sources/Entities/CredentialIssuer/CredentialIssuerMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions Sources/Issuers/Issuer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 94f8968

Please sign in to comment.