Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ jobs:
TEST_ECV_PROJECT_ID: ${{ vars.TEST_ECV_PROJECT_ID }}
GMAIL_TOKEN: ${{ secrets.GMAIL_TOKEN }}
GMAIL_CREDENTIALS: ${{ secrets.GMAIL_CREDENTIALS }}
TEST_ECV_PROJECT_URL: ${{ vars.TEST_ECV_PROJECT_URL }}
TEST_DV_PROJECT_URL: ${{ vars.TEST_DV_PROJECT_URL }}
TEST_CUV_PROJECT_URL: ${{ vars.TEST_CUV_PROJECT_URL }}
run: |
cd MIRACLTrust
xcrun simctl erase "iPhone 16"
Expand Down
2 changes: 1 addition & 1 deletion MIRACLTrust.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Pod::Spec.new do |s|
s.name = "MIRACLTrust"
s.summary = "MIRACL Trust SDK for iOS"
s.requires_arc = true
s.version = "1.5.0"
s.version = "1.6.0"
s.license = { :type => "Apache2", :file => "LICENSE" }
s.author = { "MIRACL" => "[email protected]" }
s.homepage = "https://github.com/miracl/trust-sdk-ios"
Expand Down
28 changes: 14 additions & 14 deletions MIRACLTrust/MIRACLTrust-Sources/Configuration.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import Foundation

/// Object that stores configurations of the SDK with values issued by MIRACL.
/// - Tag: Configuration
@objc public class Configuration: NSObject {
/// Identifier of the project in the MIRACL Trust platform.
var projectId: String

/// Base URL of the MIRACL platform.
var platformURL: URL
var projectURL: URL

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

override private init() {
projectId = ""
platformURL = MIRACL_API_URL
projectURL = URL(string: MIRACL_API_URL)!
applicationInfo = nil

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

/// Initializing ``Configuration/Builder`` object.
/// - Parameters:
/// - projectId: `Project ID` setting for the MIRACL Platform.
/// - projectURL: `Project URL` setting for the MIRACL Platform.
/// - deviceName: identifier that can help find the device on the MIRACL Trust Portal.
/// If not provided, the value of `deviceName` is the name of the operation system (e.g `iOS`).
@objc public init(
projectId: String,
projectURL: String = MIRACL_API_URL,
deviceName: String? = nil
) {
configurationToBuild.projectId = projectId.trimmingCharacters(in: .whitespacesAndNewlines)
self.projectURL = projectURL

if let deviceName {
configurationToBuild.deviceName = deviceName.trimmingCharacters(in: .whitespacesAndNewlines)
} else {
Expand Down Expand Up @@ -130,16 +134,6 @@ import Foundation
return self
}

/// Sets custom MIRACL platform URL.
/// - Parameter url: custom MIRACL platform URL.
/// - Returns: Configuration.Builder object.
@objc(platformURLWith:) @discardableResult public func platformURL(
url: URL
) -> Builder {
configurationToBuild.platformURL = url
return self
}

/// Sets additional application information that will be sent via X-MIRACL-CLIENT HTTP header.
/// - Parameter applicationInfo: application info.
/// - Returns: Configuration.Builder object.
Expand Down Expand Up @@ -168,9 +162,15 @@ import Foundation
/// - Returns: ``Configuration`` object.
@objc public func build() throws -> Configuration {
if configurationToBuild.projectId.isEmpty {
throw ConfigurationError.configurationEmptyProjectId
throw ConfigurationError.emptyProjectId
}

guard let projectURL = URL(string: projectURL) else {
throw ConfigurationError.invalidProjectURL
}

configurationToBuild.projectURL = projectURL

return configurationToBuild
}
}
Expand Down
12 changes: 8 additions & 4 deletions MIRACLTrust/MIRACLTrust-Sources/ConfigurationError.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import Foundation

/// An enumeration that describes issues with the SDK configuration.
/// - Tag: enums-ConfigurationError
public enum ConfigurationError: Error, Equatable {
// Empty Proejct ID.
case configurationEmptyProjectId
case emptyProjectId

// Invalid project URL.
case invalidProjectURL
}

extension ConfigurationError: LocalizedError {
public var errorDescription: String? {
switch self {
case .configurationEmptyProjectId:
return NSLocalizedString("\(ConfigurationError.configurationEmptyProjectId)", comment: "")
case .emptyProjectId:
return NSLocalizedString("\(ConfigurationError.emptyProjectId)", comment: "")
case .invalidProjectURL:
return NSLocalizedString("\(ConfigurationError.invalidProjectURL)", comment: "")
}
}
}
2 changes: 1 addition & 1 deletion MIRACLTrust/MIRACLTrust-Sources/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public typealias AuthenticationSessionAborterCompletionHandler = @MainActor @Sen
public typealias SigningSessionDetailsCompletionHandler = @MainActor @Sendable (SigningSessionDetails?, Error?) -> Void
public typealias SigningSessionAborterCompletionHandler = @MainActor @Sendable (Bool, Error?) -> Void

public let MIRACL_API_URL = URL(string: "https://api.mpin.io")!
public let MIRACL_API_URL = "https://api.mpin.io"

typealias AuthenticateCompletionHandler = @MainActor @Sendable (AuthenticateResponse?, Error?) -> Void
typealias APIRequestCompletionHandler<T> = @Sendable (APICallResult, T?, Error?) -> Void
Expand Down
25 changes: 19 additions & 6 deletions MIRACLTrust/MIRACLTrust-Sources/MIRACLTrust.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import Foundation
}

miraclAPI = API(
baseURL: configuration.platformURL,
baseURL: configuration.projectURL,
urlSessionConfiguration: configuration.urlSessionConfiguration,
logger: logger
)
Expand Down Expand Up @@ -92,7 +92,7 @@ import Foundation
}

shared.miraclAPI = API(
baseURL: configuration.platformURL,
baseURL: configuration.projectURL,
urlSessionConfiguration: configuration.urlSessionConfiguration,
logger: shared.logger
)
Expand All @@ -104,15 +104,28 @@ import Foundation
}
}

/// Configure a new project ID when the SDK have to work with a different project.
/// Configures new project settings when the SDK have to work with a different project.
/// - Parameters:
/// - projectId: `Project ID` setting for the MIRACL Platform that needs to be updated.
@objc public func setProjectId(projectId: String) throws {
/// - projectId: The unique identifier for your MIRACL Trust project.
/// - projectURL: MIRACL Trust Project URL that is used for communication with the MIRACL Trust API.
@objc public func updateProjectSettings(
projectId: String,
projectURL: String
) throws {
if projectId.isEmpty {
throw ConfigurationError.configurationEmptyProjectId
throw ConfigurationError.emptyProjectId
}

guard let validProjectURL = URL(string: projectURL) else {
throw ConfigurationError.invalidProjectURL
}

self.projectId = projectId
miraclAPI = API(
baseURL: validProjectURL,
urlSessionConfiguration: urlSessionConfiguration,
logger: logger
)
}

// MARK: Verification
Expand Down
28 changes: 16 additions & 12 deletions MIRACLTrust/MIRACLTrust.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,15 @@
6DC46A9425B9BB2B0099866C /* APISettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DAAC0EB24000DA700652CD1 /* APISettings.swift */; };
6DC89F612E2FCA1000683AFB /* CrossDeviceSessionAborter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC89F602E2FCA0900683AFB /* CrossDeviceSessionAborter.swift */; };
6DC89F632E2FDBE900683AFB /* CrossDeviceSessionError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC89F622E2FDBE400683AFB /* CrossDeviceSessionError.swift */; };
6DC987342E54C3CB00E1EDAB /* CrossDeviceSessionTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC987332E54C3C400E1EDAB /* CrossDeviceSessionTestCase.swift */; };
6DC987222E5332D200E1EDAB /* UserDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC987212E5332CF00E1EDAB /* UserDTO.swift */; };
6DC987342E54C3CB00E1EDAB /* CrossDeviceSessionTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC987332E54C3C400E1EDAB /* CrossDeviceSessionTestCase.swift */; };
6DCDC7542834EC22006974F6 /* GetSigningSessionDetailsTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DCDC7532834EC22006974F6 /* GetSigningSessionDetailsTestCase.swift */; };
6DCFDD4224AA0CEC00CED02F /* RegistrationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DCFDD4124AA0CEC00CED02F /* RegistrationTestCase.swift */; };
6DCFDD4424AA0E7D00CED02F /* QRAuthenticationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DCFDD4324AA0E7D00CED02F /* QRAuthenticationTestCase.swift */; };
6DD1778624B4A08C006CBF4C /* DBFileHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DD1778524B4A08C006CBF4C /* DBFileHelper.swift */; };
6DD64B6228326B7D0056A9DA /* SigningSessionCompleterResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DD64B6128326B7D0056A9DA /* SigningSessionCompleterResponse.swift */; };
6DD64B6428326BE90056A9DA /* SigningSessionUpdaterRequestBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DD64B6328326BE90056A9DA /* SigningSessionUpdaterRequestBody.swift */; };
6DDB73612E61BDC600F32D2F /* TestConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DDB73602E61BDBF00F32D2F /* TestConstants.swift */; };
6DDC22A8270AD0F7003A2DE8 /* AbortSessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DDC22A7270AD0F7003A2DE8 /* AbortSessionTests.swift */; };
6DDEB14B2705F23900C3313D /* AuthenticationSessionAborter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DDEB14A2705F23900C3313D /* AuthenticationSessionAborter.swift */; };
6DDEB14F2706F2CC00C3313D /* AbortSessionTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DDEB14E2706F2CB00C3313D /* AbortSessionTestCase.swift */; };
Expand Down Expand Up @@ -499,8 +500,8 @@
6DC80E32242CDDF5001C353F /* AuthenticateResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticateResponse.swift; sourceTree = "<group>"; };
6DC89F602E2FCA0900683AFB /* CrossDeviceSessionAborter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrossDeviceSessionAborter.swift; sourceTree = "<group>"; };
6DC89F622E2FDBE400683AFB /* CrossDeviceSessionError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrossDeviceSessionError.swift; sourceTree = "<group>"; };
6DC987332E54C3C400E1EDAB /* CrossDeviceSessionTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrossDeviceSessionTestCase.swift; sourceTree = "<group>"; };
6DC987212E5332CF00E1EDAB /* UserDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDTO.swift; sourceTree = "<group>"; };
6DC987332E54C3C400E1EDAB /* CrossDeviceSessionTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrossDeviceSessionTestCase.swift; sourceTree = "<group>"; };
6DCDC7532834EC22006974F6 /* GetSigningSessionDetailsTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetSigningSessionDetailsTestCase.swift; sourceTree = "<group>"; };
6DCFDD4124AA0CEC00CED02F /* RegistrationTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegistrationTestCase.swift; sourceTree = "<group>"; };
6DCFDD4324AA0E7D00CED02F /* QRAuthenticationTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRAuthenticationTestCase.swift; sourceTree = "<group>"; };
Expand All @@ -509,6 +510,7 @@
6DD64B6328326BE90056A9DA /* SigningSessionUpdaterRequestBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigningSessionUpdaterRequestBody.swift; sourceTree = "<group>"; };
6DDB209729E3F45100B809DF /* bridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bridge.h; sourceTree = "<group>"; };
6DDB209829E3F45100B809DF /* bridge.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = bridge.c; sourceTree = "<group>"; };
6DDB73602E61BDBF00F32D2F /* TestConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestConstants.swift; sourceTree = "<group>"; };
6DDC22A7270AD0F7003A2DE8 /* AbortSessionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AbortSessionTests.swift; sourceTree = "<group>"; };
6DDEB14A2705F23900C3313D /* AuthenticationSessionAborter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationSessionAborter.swift; sourceTree = "<group>"; };
6DDEB14E2706F2CB00C3313D /* AbortSessionTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AbortSessionTestCase.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -863,6 +865,7 @@
6D953FBF24056F9800F22138 /* Helpers */ = {
isa = PBXGroup;
children = (
6DDB73602E61BDBF00F32D2F /* TestConstants.swift */,
6DFEC8CD26E1049100E8F682 /* MockURLSession.swift */,
6D42DDAB2412799C00EFA78A /* MockAPI.swift */,
6DB04A35241FD0010017F8C8 /* MockCrypto.swift */,
Expand Down Expand Up @@ -1458,6 +1461,7 @@
6D663D762E322EFA004B1D53 /* CrossDeviceSessionFetcherTest.swift in Sources */,
6D01C62F2AA7672D0059CA91 /* SQLiteUserStorageMigrationTests.swift in Sources */,
6DBD1A9425D16F6F002702F8 /* QuickCodeGeneratorTests.swift in Sources */,
6DDB73612E61BDC600F32D2F /* TestConstants.swift in Sources */,
6DAAC0EE24002D8D00652CD1 /* APIRequestTests.swift in Sources */,
6D49C10F2448497900C48178 /* SQLiteUserStorageTests.swift in Sources */,
6D6EBBAB24D29D2600E1B72D /* MockAuthenticator.swift in Sources */,
Expand Down Expand Up @@ -1779,7 +1783,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
MARKETING_VERSION = "$(MIRACL_SDK_VERSION)";
MIRACL_SDK_VERSION = 1.5.0;
MIRACL_SDK_VERSION = 1.6.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -1842,7 +1846,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
MARKETING_VERSION = "$(MIRACL_SDK_VERSION)";
MIRACL_SDK_VERSION = 1.5.0;
MIRACL_SDK_VERSION = 1.6.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand All @@ -1866,7 +1870,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MIRACL_SDK_VERSION = 1.5.0;
MIRACL_SDK_VERSION = 1.6.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.miracl.trust.sdk-ios.MIRACLTrustTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -1886,7 +1890,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MIRACL_SDK_VERSION = 1.5.0;
MIRACL_SDK_VERSION = 1.6.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.miracl.trust.sdk-ios.MIRACLTrustTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -1908,7 +1912,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MIRACL_SDK_VERSION = 1.5.0;
MIRACL_SDK_VERSION = 1.6.0;
PRODUCT_BUNDLE_IDENTIFIER = com.radoslavpenev.MIRACLTrustIntegrationTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "MIRACLTrustIntegrationTests/Cases/MIRACLTrustIntegrationTests-Bridging-Header.h";
Expand All @@ -1933,7 +1937,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MIRACL_SDK_VERSION = 1.5.0;
MIRACL_SDK_VERSION = 1.6.0;
PRODUCT_BUNDLE_IDENTIFIER = com.radoslavpenev.MIRACLTrustIntegrationTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "MIRACLTrustIntegrationTests/Cases/MIRACLTrustIntegrationTests-Bridging-Header.h";
Expand All @@ -1956,7 +1960,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MIRACL_SDK_VERSION = 1.5.0;
MIRACL_SDK_VERSION = 1.6.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.miracl.applclippoc.MIRACLTrust-Test-Host-App";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -1976,7 +1980,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MIRACL_SDK_VERSION = 1.5.0;
MIRACL_SDK_VERSION = 1.6.0;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.miracl.applclippoc.MIRACLTrust-Test-Host-App";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -2015,7 +2019,7 @@
"$(PROJECT_DIR)/MIRACLTrust-Sources/Crypto/src",
);
MARKETING_VERSION = "$(MIRACL_SDK_VERSION)";
MIRACL_SDK_VERSION = 1.5.0;
MIRACL_SDK_VERSION = 1.6.0;
MODULEMAP_FILE = "$(SRCROOT)/MIRACLTrust-Sources/MIRACLTrust.modulemap";
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
Expand Down Expand Up @@ -2064,7 +2068,7 @@
"$(PROJECT_DIR)/MIRACLTrust-Sources/Crypto/src",
);
MARKETING_VERSION = "$(MIRACL_SDK_VERSION)";
MIRACL_SDK_VERSION = 1.5.0;
MIRACL_SDK_VERSION = 1.6.0;
MODULEMAP_FILE = "$(SRCROOT)/MIRACLTrust-Sources/MIRACLTrust.modulemap";
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
</BuildableReference>
</MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "platformURL"
value = "$(TEST_ENVIRONMENT_URL)"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "clientSecretCUV"
value = "$(TEST_CUV_CLIENT_SECRET)"
Expand Down Expand Up @@ -102,6 +97,21 @@
value = "$(GMAIL_TOKEN)"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "projectURLCUV"
value = "$(TEST_CUV_PROJECT_URL)"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "projectURLDV"
value = "$(TEST_DV_PROJECT_URL)"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "projectURLECV"
value = "$(TEST_ECV_PROJECT_URL)"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<CodeCoverageTargets>
<BuildableReference
Expand Down
Loading
Loading