Make contract entities inits public (#137)

This commit is contained in:
Sydney 2022-12-16 14:38:30 -05:00 коммит произвёл GitHub
Родитель 7e25576f3d
Коммит bf710616c2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
23 изменённых файлов: 188 добавлений и 22 удалений

Просмотреть файл

@ -12,4 +12,20 @@ public struct AccessTokenDescriptor: Codable, Equatable {
public let configuration: String?
public let resourceId: String?
public let oboScope: String?
public init(id: String? = nil,
encrypted: Bool? = nil,
claims: [ClaimDescriptor]? = nil,
required: Bool? = nil,
configuration: String? = nil,
resourceId: String? = nil,
oboScope: String? = nil) {
self.id = id
self.encrypted = encrypted
self.claims = claims
self.required = required
self.configuration = configuration
self.resourceId = resourceId
self.oboScope = oboScope
}
}

Просмотреть файл

@ -4,8 +4,20 @@
*--------------------------------------------------------------------------------------------*/
public struct AttestationsDescriptor: Codable, Equatable {
public let selfIssued: SelfIssuedClaimsDescriptor?
public let presentations: [PresentationDescriptor]?
public let idTokens: [IdTokenDescriptor]?
public let accessTokens: [AccessTokenDescriptor]?
public init(selfIssued: SelfIssuedClaimsDescriptor? = nil,
presentations: [PresentationDescriptor]? = nil,
idTokens: [IdTokenDescriptor]? = nil,
accessTokens: [AccessTokenDescriptor]? = nil) {
self.selfIssued = selfIssued
self.presentations = presentations
self.idTokens = idTokens
self.accessTokens = accessTokens
}
}

Просмотреть файл

@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
public struct ClaimDescriptor: Codable, Equatable {
public let claim: String
public let claimRequired: Bool?
public let indexed: Bool?
@ -13,4 +14,12 @@ public struct ClaimDescriptor: Codable, Equatable {
case claimRequired = "required"
case indexed
}
public init(claim: String,
claimRequired: Bool? = nil,
indexed: Bool? = nil) {
self.claim = claim
self.claimRequired = claimRequired
self.indexed = indexed
}
}

Просмотреть файл

@ -8,7 +8,7 @@ public struct ClaimDisplayDescriptor: Codable, Equatable {
public let type: String
public let label: String
public init(type:String, label:String) {
public init(type: String, label: String) {
self.type = type
self.label = label
}

Просмотреть файл

@ -11,6 +11,14 @@ public struct Contract: Claims, Equatable {
public let display: DisplayDescriptor
public let input: ContractInputDescriptor
public init(id: String,
display: DisplayDescriptor,
input: ContractInputDescriptor) {
self.id = id
self.display = display
self.input = input
}
}
public typealias SignedContract = JwsToken<Contract>

Просмотреть файл

@ -10,4 +10,13 @@ public struct ContractInputDescriptor: Codable, Equatable {
public let issuer: String
public let attestations: AttestationsDescriptor?
public init(id: String? = nil,
credentialIssuer: String,
issuer: String,
attestations: AttestationsDescriptor? = nil) {
self.id = id
self.credentialIssuer = credentialIssuer
self.issuer = issuer
self.attestations = attestations
}
}

Просмотреть файл

@ -21,4 +21,20 @@ public struct IdTokenDescriptor: Codable, Equatable {
case redirectURI = "redirect_uri"
case scope
}
public init(encrypted: Bool? = nil,
claims: [ClaimDescriptor],
idTokenRequired: Bool? = nil,
configuration: String,
clientID: String,
redirectURI: String? = nil,
scope: String? = nil) {
self.encrypted = encrypted
self.claims = claims
self.idTokenRequired = idTokenRequired
self.configuration = configuration
self.clientID = clientID
self.redirectURI = redirectURI
self.scope = scope
}
}

Просмотреть файл

@ -4,5 +4,10 @@
*--------------------------------------------------------------------------------------------*/
public struct IssuerDescriptor: Codable, Equatable {
public let iss: String?
public init(iss: String? = nil) {
self.iss = iss
}
}

Просмотреть файл

@ -17,4 +17,18 @@ public struct PresentationDescriptor: Codable, Equatable {
case presentationRequired = "required"
case credentialType, issuers, contracts
}
public init(encrypted: Bool? = nil,
claims: [ClaimDescriptor],
presentationRequired: Bool? = nil,
credentialType: String,
issuers: [IssuerDescriptor]? = nil,
contracts: [String]? = nil) {
self.encrypted = encrypted
self.claims = claims
self.presentationRequired = presentationRequired
self.credentialType = credentialType
self.issuers = issuers
self.contracts = contracts
}
}

Просмотреть файл

@ -13,4 +13,12 @@ public struct SelfIssuedClaimsDescriptor: Codable, Equatable {
case encrypted, claims
case selfIssuedRequired = "required"
}
public init(encrypted: Bool? = nil,
claims: [ClaimDescriptor]? = nil,
selfIssuedRequired: Bool? = nil) {
self.encrypted = encrypted
self.claims = claims
self.selfIssuedRequired = selfIssuedRequired
}
}

Просмотреть файл

@ -4,11 +4,16 @@
*--------------------------------------------------------------------------------------------*/
public struct AllowedAlgorithms: Codable, Equatable {
public let algorithms: [String]?
enum CodingKeys: String, CodingKey {
case algorithms = "alg"
}
public init(algorithms: [String]? = nil) {
self.algorithms = algorithms
}
}
public enum SupportedAlgorithms: String {

Просмотреть файл

@ -46,25 +46,25 @@ public struct PresentationRequestClaims: OIDCClaims, Equatable {
case state, nonce, prompt, registration, iat, exp, scope, claims, jti
}
init(jti: String?,
clientID: String?,
redirectURI: String?,
responseMode: String?,
responseType: String?,
claims: RequestedClaims?,
state: String?,
nonce: String?,
scope: String?,
prompt: String?,
registration: RegistrationClaims?,
public init(jti: String? = nil,
clientID: String? = nil,
redirectURI: String? = nil,
responseType: String? = nil,
responseMode: String? = nil,
claims: RequestedClaims? = nil,
state: String? = nil,
nonce: String? = nil,
scope: String? = nil,
prompt: String? = nil,
registration: RegistrationClaims? = nil,
idTokenHint: IssuerIdToken? = nil,
iat: Double?,
exp: Double?) {
iat: Double? = nil,
exp: Double? = nil) {
self.jti = jti
self.clientID = clientID
self.redirectURI = redirectURI
self.responseMode = responseMode
self.responseType = responseType
self.responseMode = responseMode
self.claims = claims
self.state = state
self.nonce = nonce

Просмотреть файл

@ -32,4 +32,16 @@ public struct RegistrationClaims: Codable, Equatable {
case subjectIdentifierTypesSupported = "subject_syntax_types_supported"
case vpFormats = "vp_formats"
}
public init(clientName: String? = nil,
clientPurpose: String? = nil,
logoURI: String? = nil,
subjectIdentifierTypesSupported: [String]? = nil,
vpFormats: SupportedVerifiablePresentationFormats? = nil) {
self.clientName = clientName
self.clientPurpose = clientPurpose
self.logoURI = logoURI
self.subjectIdentifierTypesSupported = subjectIdentifierTypesSupported
self.vpFormats = vpFormats
}
}

Просмотреть файл

@ -16,4 +16,9 @@ public struct SupportedVerifiablePresentationFormats: Codable, Equatable {
case jwtVP = "jwt_vp"
case jwtVC = "jwt_vc"
}
public init(jwtVP: AllowedAlgorithms? = nil, jwtVC: AllowedAlgorithms? = nil) {
self.jwtVP = jwtVP
self.jwtVC = jwtVC
}
}

Просмотреть файл

@ -13,4 +13,7 @@ public struct InputDescriptorSchema: Codable, Equatable {
case uri
}
public init(uri: String? = nil) {
self.uri = uri
}
}

Просмотреть файл

@ -13,4 +13,9 @@ public struct IssuanceMetadata: Codable, Equatable {
case contract = "manifest"
case issuerDid = "did"
}
public init(contract: String? = nil, issuerDid: String? = nil) {
self.contract = contract
self.issuerDid = issuerDid
}
}

Просмотреть файл

@ -23,4 +23,12 @@ public struct PresentationDefinition: Codable, Equatable {
case inputDescriptors = "input_descriptors"
case id, issuance
}
public init(id: String? = nil,
inputDescriptors: [PresentationInputDescriptor]? = nil,
issuance: [String]? = nil) {
self.id = id
self.inputDescriptors = inputDescriptors
self.issuance = issuance
}
}

Просмотреть файл

@ -16,4 +16,8 @@ public struct PresentationExchangeConstraints: Codable, Equatable {
enum CodingKeys: String, CodingKey {
case fields
}
public init(fields: [PresentationExchangeField]? = nil) {
self.fields = fields
}
}

Просмотреть файл

@ -23,4 +23,12 @@ public struct PresentationExchangeField: Codable, Equatable {
enum CodingKeys: String, CodingKey {
case path, purpose, filter
}
public init(path: [String]? = nil,
purpose: String? = nil,
filter: PresentationExchangeFilter? = nil) {
self.path = path
self.purpose = purpose
self.filter = filter
}
}

Просмотреть файл

@ -20,6 +20,11 @@ public struct PresentationExchangeFilter: Codable, Equatable {
case type, pattern
}
public init(type: String? = nil, pattern: NSRegularExpression? = nil) {
self.type = type
self.pattern = pattern
}
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
type = try values.decodeIfPresent(String.self, forKey: .type)

Просмотреть файл

@ -32,4 +32,18 @@ public struct PresentationInputDescriptor: Codable, Equatable {
case issuanceMetadata = "issuance"
case id, schema, name, purpose, constraints
}
public init(id: String? = nil,
schema: [InputDescriptorSchema]? = nil,
issuanceMetadata: [IssuanceMetadata]? = nil,
name: String? = nil,
purpose: String? = nil,
constraints: PresentationExchangeConstraints? = nil) {
self.id = id
self.schema = schema
self.issuanceMetadata = issuanceMetadata
self.name = name
self.purpose = purpose
self.constraints = constraints
}
}

Просмотреть файл

@ -133,8 +133,8 @@ class PresentationRequestValidatorTests: XCTestCase {
return PresentationRequestClaims(jti: "testId",
clientID: "clientID",
redirectURI: "redirectURI",
responseMode: responseMode,
responseType: responseType,
responseMode: responseMode,
claims: nil,
state: "state",
nonce: "nonce",

Просмотреть файл

@ -72,7 +72,7 @@ class PresentationServiceTests: XCTestCase {
func testGetRequestMalformedUri() throws {
let expec = self.expectation(description: "Fire")
let malformedUrl = " "
let malformedUrl = "//|\\"
service.getRequest(usingUrl: malformedUrl).done {
request in
print(request)