• 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

8.51
/EdgeAgentSDK/Mercury/Sources/Helpers/SessionManager.swift
1
import Domain
2
import Foundation
3

4
struct SessionManager {
5
    enum Method: String {
6
        case get = "GET"
7
        case post = "POST"
8
    }
9

10
    private let session: URLSession
11
    private let timeout: TimeInterval
12

13
    init(session: URLSession, timeout: TimeInterval) {
3✔
14
        self.session = session
3✔
15
        self.timeout = timeout
3✔
16
    }
3✔
17

18
    func post(
19
        url: URL,
20
        body: Data? = nil,
21
        headers: [String: String] = [:],
22
        parameters: [String: String] = [:]
23
    ) async throws -> Data? {
×
NEW
24
        let url = URL(string: url.absoluteString.replacingOccurrences(of: "host.docker.internal", with: "localhost"))!
×
NEW
25
        return try await call(request: try makeRequest(
×
26
            url: url,
×
27
            method: .post,
×
28
            body: body,
×
29
            headers: headers,
×
30
            parameters: parameters
×
31
        ))
×
32
    }
×
33

34
    private func call(request: URLRequest) async throws -> Data? {
×
35
        let (data, response) = try await session.data(for: request)
×
36
        if let urlResponse = response as? HTTPURLResponse {
×
37
            guard 200...299 ~= urlResponse.statusCode else {
×
38
                throw CommonError.httpError(
×
39
                    code: urlResponse.statusCode,
×
40
                    message: String(data: data, encoding: .utf8) ?? ""
×
41
                )
×
42
            }
×
43
        }
×
44
        return data
×
45
    }
×
46

47
    private func makeRequest(
48
        url: URL,
49
        method: Method,
50
        body: Data?,
51
        headers: [String: String] = [:],
52
        parameters: [String: String]
53
    ) throws -> URLRequest {
×
54
        let urlParsed = URL(
×
55
            string: url
×
56
                .absoluteString
×
57
                .replacingOccurrences(
×
58
                    of: "http://host.docker.internal:8080",
×
59
                    with: "http://localhost:8080"
×
60
                )) ?? url
×
61
        var composition = URLComponents(url: urlParsed, resolvingAgainstBaseURL: true)
×
62
        if !parameters.isEmpty {
×
63
            composition?.queryItems = parameters.map { URLQueryItem(name: $0, value: $1) }
×
64
        }
×
65
        guard let url = composition?.url else {
×
66
            throw CommonError.invalidURLError(url: urlParsed.absoluteString)
×
67
        }
×
68
        var request = URLRequest(url: url, timeoutInterval: timeout)
×
69
        request.allHTTPHeaderFields = headers
×
70
        request.httpBody = body
×
71
        request.httpMethod = method.rawValue
×
72
        return request
×
73
    }
×
74
}
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