• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / atala-prism-wallet-sdk-swift / 9466819027

11 Jun 2024 01:48PM UTC coverage: 40.328% (-0.5%) from 40.822%
9466819027

Pull #145

github

web-flow
Merge 1399bca59 into 8e68386ce
Pull Request #145: feat(pollux): add support for sd-jwt

76 of 394 new or added lines in 20 files covered. (19.29%)

2 existing lines in 2 files now uncovered.

4518 of 11203 relevant lines covered (40.33%)

16.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.9
/EdgeAgentSDK/Pollux/Sources/PolluxImpl+ParseCredential.swift
1
import Domain
2
import Foundation
3

4
extension PolluxImpl {
5
    public func parseCredential(issuedCredential: Message, options: [CredentialOperationsOptions]) async throws -> Credential {
6✔
6
        guard let issuedAttachment = issuedCredential.attachments.first else {
6✔
7
            throw PolluxError.unsupportedIssuedMessage
×
8
        }
6✔
9
        
6✔
10
        switch issuedAttachment.format {
6✔
11
        case "jwt", "", "prism/jwt", .none:
6✔
12
            switch issuedAttachment.data {
×
13
            case let json as AttachmentJsonData:
×
14
                return try ParseJWTCredentialFromMessage.parse(issuerCredentialData: json.data)
×
15
            case let base64 as AttachmentBase64:
×
16
                return try ParseJWTCredentialFromMessage.parse(issuerCredentialData: try base64.decoded())
×
17
            default:
×
18
                throw PolluxError.unsupportedIssuedMessage
×
19
            }
×
20
        case "vc+sd-jwt":
6✔
NEW
21
            switch issuedAttachment.data {
×
NEW
22
            case let json as AttachmentJsonData:
×
NEW
23
                return try SDJWTCredential(sdjwtString: json.data.tryToString())
×
NEW
24
            case let base64 as AttachmentBase64:
×
NEW
25
                return try SDJWTCredential(sdjwtString: try base64.decoded().tryToString())
×
NEW
26
            default:
×
NEW
27
                throw PolluxError.unsupportedIssuedMessage
×
NEW
28
            }
×
29
        case "anoncreds", "prism/anoncreds", "anoncreds/credential@v1.0":
6✔
30
            guard let thid = issuedCredential.thid else {
6✔
31
                throw PolluxError.messageDoesntProvideEnoughInformation
×
32
            }
6✔
33
            guard
6✔
34
                let linkSecretOption = options.first(where: {
6✔
35
                    if case .linkSecret = $0 { return true }
6✔
36
                    return false
×
37
                }),
6✔
38
                case let CredentialOperationsOptions.linkSecret(_, secret: linkSecret) = linkSecretOption
6✔
39
            else {
6✔
40
                throw PolluxError.missingAndIsRequiredForOperation(type: "linkSecret")
×
41
            }
6✔
42

6✔
43
            guard
6✔
44
                let credDefinitionDownloaderOption = options.first(where: {
12✔
45
                    if case .credentialDefinitionDownloader = $0 { return true }
12✔
46
                    return false
6✔
47
                }),
12✔
48
                case let CredentialOperationsOptions.credentialDefinitionDownloader(definitionDownloader) = credDefinitionDownloaderOption
6✔
49
            else {
6✔
50
                throw PolluxError.missingAndIsRequiredForOperation(type: "credentialDefinitionDownloader")
×
51
            }
6✔
52

6✔
53
            guard
6✔
54
                let schemaDownloaderOption = options.first(where: {
18✔
55
                    if case .schemaDownloader = $0 { return true }
18✔
56
                    return false
12✔
57
                }),
18✔
58
                case let CredentialOperationsOptions.schemaDownloader(schemaDownloader) = schemaDownloaderOption
6✔
59
            else {
6✔
60
                throw PolluxError.missingAndIsRequiredForOperation(type: "schemaDownloader")
×
61
            }
6✔
62

6✔
63
            switch issuedAttachment.data {
6✔
64
            case let json as AttachmentJsonData:
6✔
65
                return try await ParseAnoncredsCredentialFromMessage.parse(
×
66
                    issuerCredentialData: json.data,
×
67
                    linkSecret: linkSecret,
×
68
                    credentialDefinitionDownloader: definitionDownloader,
×
69
                    schemaDownloader: schemaDownloader,
×
70
                    thid: thid,
×
71
                    pluto: self.pluto
×
72
                )
×
73
            case let base64 as AttachmentBase64:
6✔
74
                return try await ParseAnoncredsCredentialFromMessage.parse(
6✔
75
                    issuerCredentialData: try base64.decoded(),
6✔
76
                    linkSecret: linkSecret,
6✔
77
                    credentialDefinitionDownloader: definitionDownloader, 
6✔
78
                    schemaDownloader: schemaDownloader,
6✔
79
                    thid: thid,
6✔
80
                    pluto: self.pluto
6✔
81
                )
6✔
82
            default:
6✔
83
                throw PolluxError.unsupportedIssuedMessage
×
84
            }
6✔
85
        default:
6✔
86
            throw PolluxError.invalidCredentialError
×
87
        }
6✔
88
    }
6✔
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc