Skip to content

Commit d457207

Browse files
committed
Change platformURL to projectURL
1 parent f8d9efb commit d457207

File tree

47 files changed

+386
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+386
-241
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ jobs:
6767
TEST_ECV_PROJECT_ID: ${{ vars.TEST_ECV_PROJECT_ID }}
6868
GMAIL_TOKEN: ${{ secrets.GMAIL_TOKEN }}
6969
GMAIL_CREDENTIALS: ${{ secrets.GMAIL_CREDENTIALS }}
70+
TEST_ECV_PROJECT_URL: ${{ vars.TEST_ECV_PROJECT_URL }}
71+
TEST_DV_PROJECT_URL: ${{ vars.TEST_DV_PROJECT_URL }}
72+
TEST_CUV_PROJECT_URL: ${{ vars.TEST_CUV_PROJECT_URL }}
7073
run: |
7174
cd MIRACLTrust
7275
xcrun simctl erase "iPhone 16"

MIRACLTrust/MIRACLTrust-Sources/Configuration.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Foundation
22

33
/// Object that stores configurations of the SDK with values issued by MIRACL.
4-
/// - Tag: Configuration
54
@objc public class Configuration: NSObject {
65
/// Identifier of the project in the MIRACL Trust platform.
76
var projectId: String
@@ -10,7 +9,7 @@ import Foundation
109
var userStorage: UserStorage?
1110

1211
/// Base URL of the MIRACL platform.
13-
var platformURL: URL
12+
var projectURL: URL
1413

1514
/// URL Session configuration object. Use this when you want to set the custom configuration to the SDK's instance of URLSession.
1615
/// As a default value it uses `ephemeral` configuration, 30 seconds for `timeoutIntervalForRequest` and
@@ -31,7 +30,7 @@ import Foundation
3130

3231
override private init() {
3332
projectId = ""
34-
platformURL = MIRACL_API_URL
33+
projectURL = MIRACL_API_URL
3534
applicationInfo = nil
3635

3736
urlSessionConfiguration = URLSessionConfiguration.ephemeral
@@ -45,17 +44,22 @@ import Foundation
4544
/// Builds ``Configuration`` objects.
4645
@objc(ConfigurationBuilder) public class Builder: NSObject {
4746
private var configurationToBuild = Configuration()
47+
private let projectURL: String
4848

4949
/// Initializing ``Configuration/Builder`` object.
5050
/// - Parameters:
5151
/// - projectId: `Project ID` setting for the MIRACL Platform.
52+
/// - projectURL: `Project URL` setting for the MIRACL Platform.
5253
/// - deviceName: identifier that can help find the device on the MIRACL Trust Portal.
5354
/// If not provided, the value of `deviceName` is the name of the operation system (e.g `iOS`).
5455
@objc public init(
5556
projectId: String,
57+
projectURL: String,
5658
deviceName: String? = nil
5759
) {
5860
configurationToBuild.projectId = projectId.trimmingCharacters(in: .whitespacesAndNewlines)
61+
self.projectURL = projectURL
62+
5963
if let deviceName {
6064
configurationToBuild.deviceName = deviceName.trimmingCharacters(in: .whitespacesAndNewlines)
6165
} else {
@@ -110,16 +114,6 @@ import Foundation
110114
return self
111115
}
112116

113-
/// Sets custom MIRACL platform URL.
114-
/// - Parameter url: custom MIRACL platform URL.
115-
/// - Returns: Configuration.Builder object.
116-
@objc(platformURLWith:) @discardableResult public func platformURL(
117-
url: URL
118-
) -> Builder {
119-
configurationToBuild.platformURL = url
120-
return self
121-
}
122-
123117
/// Sets additional application information that will be sent via X-MIRACL-CLIENT HTTP header.
124118
/// - Parameter applicationInfo: application info.
125119
/// - Returns: Configuration.Builder object.
@@ -148,9 +142,15 @@ import Foundation
148142
/// - Returns: ``Configuration`` object.
149143
@objc public func build() throws -> Configuration {
150144
if configurationToBuild.projectId.isEmpty {
151-
throw ConfigurationError.configurationEmptyProjectId
145+
throw ConfigurationError.emptyProjectId
146+
}
147+
148+
guard let projectURL = URL(string: projectURL) else {
149+
throw ConfigurationError.invalidProjectURL
152150
}
153151

152+
configurationToBuild.projectURL = projectURL
153+
154154
return configurationToBuild
155155
}
156156
}
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import Foundation
22

33
/// An enumeration that describes issues with the SDK configuration.
4-
/// - Tag: enums-ConfigurationError
54
public enum ConfigurationError: Error, Equatable {
65
// Empty Proejct ID.
7-
case configurationEmptyProjectId
6+
case emptyProjectId
7+
8+
// Empty or invalid project URL.
9+
case invalidProjectURL
810
}
911

1012
extension ConfigurationError: LocalizedError {
1113
public var errorDescription: String? {
1214
switch self {
13-
case .configurationEmptyProjectId:
14-
return NSLocalizedString("\(ConfigurationError.configurationEmptyProjectId)", comment: "")
15+
case .emptyProjectId:
16+
return NSLocalizedString("\(ConfigurationError.emptyProjectId)", comment: "")
17+
case .invalidProjectURL:
18+
return NSLocalizedString("\(ConfigurationError.invalidProjectURL)", comment: "")
1519
}
1620
}
1721
}

MIRACLTrust/MIRACLTrust-Sources/MIRACLTrust.swift

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import Foundation
4141
)
4242

4343
miraclAPI = API(
44-
baseURL: configuration.platformURL,
44+
baseURL: configuration.projectURL,
4545
urlSessionConfiguration: configuration.urlSessionConfiguration,
4646
logger: logger
4747
)
@@ -83,7 +83,7 @@ import Foundation
8383
}
8484

8585
shared.miraclAPI = API(
86-
baseURL: configuration.platformURL,
86+
baseURL: configuration.projectURL,
8787
urlSessionConfiguration: configuration.urlSessionConfiguration,
8888
logger: shared.logger
8989
)
@@ -95,15 +95,28 @@ import Foundation
9595
}
9696
}
9797

98-
/// Configure a new project ID when the SDK have to work with a different project.
98+
/// Configures new project settings when the SDK have to work with a different project.
9999
/// - Parameters:
100-
/// - projectId: `Project ID` setting for the MIRACL Platform that needs to be updated.
101-
@objc public func setProjectId(projectId: String) throws {
100+
/// - projectId: The unique identifier for your MIRACL Trust project.
101+
/// - projectURL: MIRACL Trust Project URL that is used for communication with the MIRACL Trust API.
102+
@objc public func updateProjectSettings(
103+
projectId: String,
104+
projectURL: String
105+
) throws {
102106
if projectId.isEmpty {
103-
throw ConfigurationError.configurationEmptyProjectId
107+
throw ConfigurationError.emptyProjectId
108+
}
109+
110+
guard let validProjectURL = URL(string: projectURL) else {
111+
throw ConfigurationError.invalidProjectURL
104112
}
105113

106114
self.projectId = projectId
115+
miraclAPI = API(
116+
baseURL: validProjectURL,
117+
urlSessionConfiguration: urlSessionConfiguration,
118+
logger: logger
119+
)
107120
}
108121

109122
// MARK: Verification

MIRACLTrust/MIRACLTrust.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
6DD1778624B4A08C006CBF4C /* DBFileHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DD1778524B4A08C006CBF4C /* DBFileHelper.swift */; };
198198
6DD64B6228326B7D0056A9DA /* SigningSessionCompleterResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DD64B6128326B7D0056A9DA /* SigningSessionCompleterResponse.swift */; };
199199
6DD64B6428326BE90056A9DA /* SigningSessionUpdaterRequestBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DD64B6328326BE90056A9DA /* SigningSessionUpdaterRequestBody.swift */; };
200+
6DDB73612E61BDC600F32D2F /* TestConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DDB73602E61BDBF00F32D2F /* TestConstants.swift */; };
200201
6DDC22A8270AD0F7003A2DE8 /* AbortSessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DDC22A7270AD0F7003A2DE8 /* AbortSessionTests.swift */; };
201202
6DDEB14B2705F23900C3313D /* AuthenticationSessionAborter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DDEB14A2705F23900C3313D /* AuthenticationSessionAborter.swift */; };
202203
6DDEB14F2706F2CC00C3313D /* AbortSessionTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DDEB14E2706F2CB00C3313D /* AbortSessionTestCase.swift */; };
@@ -503,6 +504,7 @@
503504
6DD64B6328326BE90056A9DA /* SigningSessionUpdaterRequestBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigningSessionUpdaterRequestBody.swift; sourceTree = "<group>"; };
504505
6DDB209729E3F45100B809DF /* bridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bridge.h; sourceTree = "<group>"; };
505506
6DDB209829E3F45100B809DF /* bridge.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = bridge.c; sourceTree = "<group>"; };
507+
6DDB73602E61BDBF00F32D2F /* TestConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestConstants.swift; sourceTree = "<group>"; };
506508
6DDC22A7270AD0F7003A2DE8 /* AbortSessionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AbortSessionTests.swift; sourceTree = "<group>"; };
507509
6DDEB14A2705F23900C3313D /* AuthenticationSessionAborter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationSessionAborter.swift; sourceTree = "<group>"; };
508510
6DDEB14E2706F2CB00C3313D /* AbortSessionTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AbortSessionTestCase.swift; sourceTree = "<group>"; };
@@ -854,6 +856,7 @@
854856
6D953FBF24056F9800F22138 /* Helpers */ = {
855857
isa = PBXGroup;
856858
children = (
859+
6DDB73602E61BDBF00F32D2F /* TestConstants.swift */,
857860
6DFEC8CD26E1049100E8F682 /* MockURLSession.swift */,
858861
6D42DDAB2412799C00EFA78A /* MockAPI.swift */,
859862
6DB04A35241FD0010017F8C8 /* MockCrypto.swift */,
@@ -1449,6 +1452,7 @@
14491452
6D663D762E322EFA004B1D53 /* CrossDeviceSessionFetcherTest.swift in Sources */,
14501453
6D01C62F2AA7672D0059CA91 /* SQLiteUserStorageMigrationTests.swift in Sources */,
14511454
6DBD1A9425D16F6F002702F8 /* QuickCodeGeneratorTests.swift in Sources */,
1455+
6DDB73612E61BDC600F32D2F /* TestConstants.swift in Sources */,
14521456
6DAAC0EE24002D8D00652CD1 /* APIRequestTests.swift in Sources */,
14531457
6D49C10F2448497900C48178 /* SQLiteUserStorageTests.swift in Sources */,
14541458
6D6EBBAB24D29D2600E1B72D /* MockAuthenticator.swift in Sources */,

MIRACLTrust/MIRACLTrust.xcodeproj/xcshareddata/xcschemes/MIRACLTrust-IntegrationTests.xcscheme

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@
5252
</BuildableReference>
5353
</MacroExpansion>
5454
<EnvironmentVariables>
55-
<EnvironmentVariable
56-
key = "platformURL"
57-
value = "$(TEST_ENVIRONMENT_URL)"
58-
isEnabled = "YES">
59-
</EnvironmentVariable>
6055
<EnvironmentVariable
6156
key = "clientSecretCUV"
6257
value = "$(TEST_CUV_CLIENT_SECRET)"
@@ -102,6 +97,21 @@
10297
value = "$(GMAIL_TOKEN)"
10398
isEnabled = "YES">
10499
</EnvironmentVariable>
100+
<EnvironmentVariable
101+
key = "projectURLCUV"
102+
value = "$(TEST_CUV_PROJECT_URL)"
103+
isEnabled = "YES">
104+
</EnvironmentVariable>
105+
<EnvironmentVariable
106+
key = "projectURLDV"
107+
value = "$(TEST_DV_PROJECT_URL)"
108+
isEnabled = "YES">
109+
</EnvironmentVariable>
110+
<EnvironmentVariable
111+
key = "projectURLECV"
112+
value = "$(TEST_ECV_PROJECT_URL)"
113+
isEnabled = "YES">
114+
</EnvironmentVariable>
105115
</EnvironmentVariables>
106116
<CodeCoverageTargets>
107117
<BuildableReference

MIRACLTrust/MIRACLTrustIntegrationTests/Cases/Objective-C/MIRACLTrustCompatibilityTests.m

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,17 @@ - (void)testVerificationConfirmationError
9393
NSString *projectId = NSProcessInfo.processInfo.environment[@"projectIdCUV"];
9494
NSString *clientId = NSProcessInfo.processInfo.environment[@"clientIdCUV"];
9595
NSString *clientSecret = NSProcessInfo.processInfo.environment[@"clientSecretCUV"];
96-
NSString *platformURL = NSProcessInfo.processInfo.environment[@"platformURL"];
96+
NSString *projectURL = NSProcessInfo.processInfo.environment[@"projectURLCUV"];
9797

9898
NSString *deviceName = [[NSUUID UUID] UUIDString];
99-
ConfigurationBuilder *builder =
100-
[[ConfigurationBuilder alloc]
101-
initWithProjectId: projectId
102-
deviceName: deviceName
103-
];
99+
100+
ConfigurationBuilder *builder = [
101+
[ConfigurationBuilder alloc]
102+
initWithProjectId:projectId
103+
projectURL:projectURL
104+
deviceName:deviceName];
104105

105106
NSError *error;
106-
[builder platformURLWith:[NSURL URLWithString:platformURL]];
107107
Configuration *configuration = [builder buildAndReturnError:&error];
108108

109109
[MIRACLTrust configureWith:configuration error:&error];
@@ -115,7 +115,11 @@ - (void)testVerificationConfirmationError
115115

116116
self.userId = @"[email protected]";
117117
self.api = [[PlatformAPIWrapper alloc] init];
118-
self.accessId = [self.api getAccessIdWithProjectId:projectId userId:nil hash:nil description:nil];
118+
self.accessId = [self.api getAccessIdWithProjectId:projectId
119+
projectURL:projectURL
120+
userId:nil
121+
hash:nil
122+
description:nil];
119123

120124
NSNumber *expirationInSeconds = @(5);
121125
NSDate *expirationDate = [NSCalendar.currentCalendar
@@ -127,6 +131,7 @@ - (void)testVerificationConfirmationError
127131
NSURL *verificationURL = [self.api getVerificaitonURLWithClientId:clientId
128132
clientSecret:clientSecret
129133
projectId:projectId
134+
projectURL:projectURL
130135
userId:self.userId
131136
accessId:self.accessId
132137
expiration:expirationDate];
@@ -162,17 +167,16 @@ - (void)testCompatibility
162167
NSError *error;
163168

164169
NSString *projectId = NSProcessInfo.processInfo.environment[@"projectIdDV"];
165-
NSString *platformURL = NSProcessInfo.processInfo.environment[@"platformURL"];
170+
NSString *projectURL = NSProcessInfo.processInfo.environment[@"projectURLCUV"];
166171

167172
NSString *deviceName = [[NSUUID UUID] UUIDString];
168173
ConfigurationBuilder *builder =
169174
[[ConfigurationBuilder alloc]
170-
initWithProjectId: projectId
171-
deviceName: deviceName
175+
initWithProjectId:projectId
176+
projectURL:projectURL
177+
deviceName:deviceName
172178
];
173179

174-
175-
[builder platformURLWith:[NSURL URLWithString:platformURL]];
176180
Configuration *configuration = [builder buildAndReturnError:&error];
177181

178182

@@ -198,7 +202,11 @@ - (void)testCompatibility
198202
NSString *clientSecret = NSProcessInfo.processInfo.environment[@"clientSecretCUV"];
199203
self.userId = @"[email protected]";
200204
self.api = [[PlatformAPIWrapper alloc] init];
201-
self.accessId = [self.api getAccessIdWithProjectId:projectId userId:nil hash:nil description:nil];
205+
self.accessId = [self.api getAccessIdWithProjectId:projectId
206+
projectURL:projectURL
207+
userId:nil
208+
hash:nil
209+
description:nil];
202210

203211
self.qrCodeURL = [NSString stringWithFormat:@"https://mcl.mpin.io/mobile-login/#%@",self.accessId];
204212
self.projectId = projectId;
@@ -229,7 +237,11 @@ - (void)testCompatibility
229237
NSNumber *isAborted = dict[@"isAborted"];
230238
XCTAssertTrue([isAborted boolValue]);
231239

232-
self.accessId = [self.api getAccessIdWithProjectId:projectId userId:nil hash:nil description:nil];
240+
self.accessId = [self.api getAccessIdWithProjectId:projectId
241+
projectURL:projectURL
242+
userId:nil
243+
hash:nil
244+
description:nil];
233245
self.qrCodeURL = [NSString stringWithFormat:@"https://mcl.mpin.io/mobile-login/#%@",self.accessId];
234246

235247
dict = [self.getCrossDeviceSessionCompatibilityCase getCrossDeviceSessionForQRCode:self.qrCodeURL];
@@ -256,7 +268,11 @@ - (void)testCompatibility
256268
isAborted = dict[@"isAborted"];
257269
XCTAssertTrue([isAborted boolValue]);
258270

259-
self.accessId = [self.api getAccessIdWithProjectId:projectId userId:nil hash:nil description:nil];
271+
self.accessId = [self.api getAccessIdWithProjectId:projectId
272+
projectURL:projectURL
273+
userId:nil
274+
hash:nil
275+
description:nil];
260276
self.qrCodeURL = [NSString stringWithFormat:@"https://mcl.mpin.io/mobile-login/#%@",self.accessId];
261277

262278
dict = [self.getCrossDeviceSessionCompatibilityCase getCrossDeviceSessionForQRCode:self.qrCodeURL];
@@ -267,6 +283,7 @@ - (void)testCompatibility
267283
NSURL *verificationURL = [self.api getVerificaitonURLWithClientId:clientId
268284
clientSecret:clientSecret
269285
projectId:projectId
286+
projectURL:projectURL
270287
userId:self.userId
271288
accessId:self.accessId
272289
expiration:nil];
@@ -295,6 +312,7 @@ - (void)testCompatibility
295312
NSData *messageHash = [self messageHash:message];
296313

297314
NSString *signingQRCode = [self.api startSigningSessionWithProjectID:projectId
315+
projectURL:projectURL
298316
userID:user.userId
299317
hash:message
300318
description:@"Test Transaction"];

MIRACLTrust/MIRACLTrustIntegrationTests/Cases/Swift/AbortSessionIntergrationTest.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class AbortSessionIntegrationTests: XCTestCase {
77

88
var sessionDetails: AuthenticationSessionDetails?
99

10-
let platformURL = ProcessInfo.processInfo.environment["platformURL"]!
10+
let platformURLCUV = ProcessInfo.processInfo.environment["projectURLCUV"]!
1111
let projectId = ProcessInfo.processInfo.environment["projectIdCUV"]!
1212
let clientId = ProcessInfo.processInfo.environment["clientIdCUV"]!
1313
let clientSecret = ProcessInfo.processInfo.environment["clientSecretCUV"]!
@@ -31,21 +31,19 @@ class AbortSessionIntegrationTests: XCTestCase {
3131
registrationTestCase = RegistrationTestCase()
3232
registrationTestCase.pinCode = "8902"
3333

34-
let platformURL = try XCTUnwrap(URL(string: platformURL))
35-
3634
let configuration = try Configuration
37-
.Builder(projectId: projectId)
38-
.platformURL(url: platformURL)
35+
.Builder(projectId: projectId, projectURL: platformURLCUV)
3936
.userStorage(userStorage: storage)
4037
.build()
4138
try MIRACLTrust.configure(with: XCTUnwrap(configuration))
4239

43-
accessId = try XCTUnwrap(api.getAccessId(projectId: projectId))
40+
accessId = try XCTUnwrap(api.getAccessId(projectId: projectId, projectURL: platformURLCUV))
4441

4542
let (response, _) = getActivationToken.getActivationToken(
4643
clientId: clientId,
4744
clientSecret: clientSecret,
4845
projectId: projectId,
46+
projectURL: platformURLCUV,
4947
userId: userId,
5048
accessId: accessId
5149
)

0 commit comments

Comments
 (0)