diff --git a/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnonCredentialDefinition.swift b/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnonCredentialDefinition.swift index e599c807..e0fa3221 100644 --- a/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnonCredentialDefinition.swift +++ b/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnonCredentialDefinition.swift @@ -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 diff --git a/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnonCredentialSchema.swift b/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnonCredentialSchema.swift index 2e7e4ce0..49c048fb 100644 --- a/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnonCredentialSchema.swift +++ b/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnonCredentialSchema.swift @@ -3,7 +3,7 @@ import Foundation struct AnonCredentialSchema: Codable { let name: String let version: String - let attrNames: [String] + let attrNames: [String]? let issuerId: String } diff --git a/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnoncredsCredentialStack.swift b/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnoncredsCredentialStack.swift index 774fb14c..414309e1 100644 --- a/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnoncredsCredentialStack.swift +++ b/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnoncredsCredentialStack.swift @@ -3,7 +3,7 @@ import Domain import Foundation struct AnoncredsCredentialStack: Codable { - let schema: AnonCredentialSchema + let schema: AnonCredentialSchema? let definition: AnonCredentialDefinition let credential: AnonCredential } @@ -20,7 +20,7 @@ extension AnoncredsCredentialStack: Domain.Credential { } var issuer: String { - definition.issuerId + definition.issuerId ?? "" } var subject: String? { diff --git a/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnoncredsPresentation.swift b/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnoncredsPresentation.swift index 5d0686db..1967b968 100644 --- a/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnoncredsPresentation.swift +++ b/AtalaPrismSDK/Pollux/Sources/Models/AnonCreds/AnoncredsPresentation.swift @@ -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() diff --git a/AtalaPrismSDK/Pollux/Sources/Operation/Anoncreds/ParseAnoncredsCredentialFromMessage.swift b/AtalaPrismSDK/Pollux/Sources/Operation/Anoncreds/ParseAnoncredsCredentialFromMessage.swift index 221555f2..2e0f2379 100644 --- a/AtalaPrismSDK/Pollux/Sources/Operation/Anoncreds/ParseAnoncredsCredentialFromMessage.swift +++ b/AtalaPrismSDK/Pollux/Sources/Operation/Anoncreds/ParseAnoncredsCredentialFromMessage.swift @@ -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 )