Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: schema download optional #116

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct AnonCredentialDefinition: Codable {
let z: String
}

let issuerId: String
let issuerId: String?
let schemaId: String
let type: String
let tag: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
struct AnonCredentialSchema: Codable {
let name: String
let version: String
let attrNames: [String]
let attrNames: [String]?
let issuerId: String
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Domain
import Foundation

struct AnoncredsCredentialStack: Codable {
let schema: AnonCredentialSchema
let schema: AnonCredentialSchema?
let definition: AnonCredentialDefinition
let credential: AnonCredential
}
Expand All @@ -20,7 +20,7 @@ extension AnoncredsCredentialStack: Domain.Credential {
}

var issuer: String {
definition.issuerId
definition.issuerId ?? ""
}

var subject: String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ struct AnoncredsPresentation {
)

let credential = stack.credential

guard let stackSchema = stack.schema else {
throw PolluxError.invalidCredentialError
}
let schema = Schema.init(
name: stack.schema.name,
version: stack.schema.version,
attrNames: AttributeNames(stack.schema.attrNames),
issuerId: stack.schema.issuerId
name: stackSchema.name,
version: stackSchema.version,
attrNames: AttributeNames(stackSchema.attrNames ?? []),
issuerId: stackSchema.issuerId
)

let credentialDefinition = try stack.definition.getAnoncred()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct ParseAnoncredsCredentialFromMessage {
let processedCredentialJson = try processedCredential.getJson().tryData(using: .utf8)
let finalCredential = try JSONDecoder().decode(AnonCredential.self, from: processedCredentialJson)
return AnoncredsCredentialStack(
schema: try JSONDecoder.didComm().decode(AnonCredentialSchema.self, from: schemaData),
schema: try? JSONDecoder.didComm().decode(AnonCredentialSchema.self, from: schemaData),
definition: try JSONDecoder.didComm().decode(AnonCredentialDefinition.self, from: credentialDefinitionData),
credential: finalCredential
)
Expand Down
Loading