1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
//
// DeviceCheckRemoteService.swift
// PacketTunnel
//
// Created by pronebird on 30/05/2023.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import Foundation
import MullvadREST
import MullvadTypes
import WireGuardKitTypes
/// An object that implements remote service used by `DeviceCheckOperation`.
struct DeviceCheckRemoteService: DeviceCheckRemoteServiceProtocol {
private let accountsProxy: RESTAccountHandling
private let devicesProxy: DeviceHandling
init(accountsProxy: RESTAccountHandling, devicesProxy: DeviceHandling) {
self.accountsProxy = accountsProxy
self.devicesProxy = devicesProxy
}
func getAccountData(
accountNumber: String,
completion: @escaping @Sendable (Result<Account, Error>) -> Void
) -> Cancellable {
accountsProxy.getAccountData(
accountNumber: accountNumber,
retryStrategy: .noRetry,
completion: completion
)
}
func getDevice(
accountNumber: String,
identifier: String,
completion: @escaping @Sendable (Result<Device, Error>) -> Void
) -> Cancellable {
devicesProxy.getDevice(
accountNumber: accountNumber,
identifier: identifier,
retryStrategy: .noRetry,
completion: completion
)
}
func rotateDeviceKey(
accountNumber: String,
identifier: String,
publicKey: PublicKey,
completion: @escaping @Sendable (Result<Device, Error>) -> Void
) -> Cancellable {
devicesProxy.rotateDeviceKey(
accountNumber: accountNumber,
identifier: identifier,
publicKey: publicKey,
retryStrategy: .default,
completion: completion
)
}
}
|