• 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

0.0
/EdgeAgentSDK/Pollux/Sources/PolluxImpl+CredentialImporter.swift
1
import Domain
2
import Foundation
3

4
extension PolluxImpl: CredentialImporter {
5
    public func importCredential(credentialData: Data, restorationType: String, options: [CredentialOperationsOptions]) async throws -> Credential {
×
6
        switch restorationType {
×
7
        case "anoncred":
×
8
            guard
×
9
                let credDefinitionDownloaderOption = options.first(where: {
×
10
                    if case .credentialDefinitionDownloader = $0 { return true }
×
11
                    return false
×
12
                }),
×
13
                case let CredentialOperationsOptions.credentialDefinitionDownloader(defDownloader) = credDefinitionDownloaderOption
×
14
            else {
×
15
                throw PolluxError.invalidPrismDID
×
16
            }
×
17
            guard
×
18
                let credSchemaDownloaderOption = options.first(where: {
×
19
                    if case .schemaDownloader = $0 { return true }
×
20
                    return false
×
21
                }),
×
22
                case let CredentialOperationsOptions.schemaDownloader(schemaDownloader) = credSchemaDownloaderOption
×
23
            else {
×
24
                throw PolluxError.invalidPrismDID
×
25
            }
×
26
            return try await importAnoncredCredential(
×
27
                credentialData: credentialData,
×
28
                credentialDefinitionDownloader: defDownloader,
×
29
                schemaDownloader: schemaDownloader
×
30
            )
×
31
        case "jwt":
×
32
            return try JWTCredential(data: credentialData)
×
NEW
33
        case "sd-jwt":
×
NEW
34
            return try SDJWTCredential(sdjwtString: credentialData.tryToString())
×
35
        default:
×
36
            throw PolluxError.invalidCredentialError
×
37
        }
×
38
    }
×
39
}
40

41
private func importAnoncredCredential(
42
    credentialData: Data,
43
    credentialDefinitionDownloader: Downloader,
44
    schemaDownloader: Downloader
45
) async throws -> Credential {
×
46
    let domainCred = try JSONDecoder().decode(AnonCredential.self, from: credentialData)
×
47
    let credentialDefinitionData = try await credentialDefinitionDownloader
×
48
        .downloadFromEndpoint(urlOrDID: domainCred.credentialDefinitionId)
×
49
    let schemaData = try await schemaDownloader
×
50
        .downloadFromEndpoint(urlOrDID: domainCred.schemaId)
×
51
    return AnoncredsCredentialStack(
×
52
        schema: try? JSONDecoder.didComm().decode(AnonCredentialSchema.self, from: schemaData),
×
53
        definition: try JSONDecoder.didComm().decode(AnonCredentialDefinition.self, from: credentialDefinitionData),
×
54
        credential: domainCred
×
55
    )
×
56
}
×
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