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

hyperwallet / hyperwallet-ios-sdk / 15826401626

21 May 2025 02:36PM UTC coverage: 96.705%. Remained the same
15826401626

push

github

web-flow
Initial commit for CodeQL (#152)

* Initial commit for CodeQL

* Updating language

1937 of 2003 relevant lines covered (96.7%)

18.55 hits per line

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

100.0
/Sources/Configuration.swift
1
//
2
// Copyright 2018 - Present Hyperwallet
3
//
4
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
5
// and associated documentation files (the "Software"), to deal in the Software without restriction,
6
// including without limitation the rights to use, copy, modify, merge, publish, distribute,
7
// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8
// furnished to do so, subject to the following conditions:
9
//
10
// The above copyright notice and this permission notice shall be included in all copies or
11
// substantial portions of the Software.
12
//
13
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
14
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18

19
import Foundation
20

21
/// Configuration object retrieved on successful authentication
22
public struct Configuration: Codable {
23
    let createOn: Double
24
    let clientToken: String
25
    let expiresOn: Double
26
    let graphQlUrl: String
27
    let restUrl: String
28
    /// The environment type
29
    public let environment: String?
30
    /// The insights Url
31
    public let insightsUrl: String?
32
    /// The issuer
33
    public let issuer: String
34
    /// The user token
35
    public let userToken: String
36
    /// The program model
37
    public let programModel: String?
38
    var authorization: String!
39
    private static let stalePeriod = 30.0 // 30 seconds
40
    private let createOnBootTime = ProcessInfo.processInfo.systemUptime
20✔
41

42
    enum CodingKeys: String, CodingKey {
43
        case createOn = "iat"
44
        case clientToken = "aud"
45
        case expiresOn = "exp"
46
        case graphQlUrl = "graphql-uri"
47
        case issuer = "iss"
48
        case userToken = "sub"
49
        case restUrl = "rest-uri"
50
        case insightsUrl = "insights-uri"
51
        case environment = "environment"
52
        case programModel = "program-model"
53
    }
54

55
    func isTokenStale() -> Bool {
85✔
56
        let tokenLifespan = expiresOn - createOn
85✔
57
        return ProcessInfo.processInfo.systemUptime - createOnBootTime >= tokenLifespan - Configuration.stalePeriod
85✔
58
    }
85✔
59

60
    func isTokenExpired() -> Bool {
18✔
61
        let tokenLifespan = expiresOn - createOn
18✔
62
        return ProcessInfo.processInfo.systemUptime - createOnBootTime >= tokenLifespan
18✔
63
    }
18✔
64
}
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