@procivis/react-native-one-core 1.75488.0 → 1.81885.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -14
- package/android/build.gradle +0 -11
- package/android/src/main/java/ch/procivis/one/core/DeserializeSpecific.kt +1 -15
- package/android/src/main/java/ch/procivis/one/core/ProcivisOneCoreModule.kt +4 -4
- package/android/src/main/java/ch/procivis/one/core/Serialize.kt +0 -2
- package/android/src/main/java/ch/procivis/one/core/SerializeSpecific.kt +124 -107
- package/android/src/main/java/ch/procivis/one/core/ubiqu/PinPadViewManager.kt +5 -8
- package/android/src/main/java/ch/procivis/one/core/ubiqu/UbiquKeyStorage.kt +17 -222
- package/core-sdk.json +6 -6
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/src/config.d.ts +3 -2
- package/dist/src/config.js +5 -0
- package/dist/src/core.d.ts +9 -182
- package/dist/src/core.js +9 -20
- package/dist/src/nfc.d.ts +0 -5
- package/dist/src/one-core-uniffi-intf.d.ts +1773 -0
- package/dist/src/one-core-uniffi-intf.js +356 -0
- package/ios/Deserialize.swift +0 -28
- package/ios/ProcivisOneCoreModule.m +4 -4
- package/ios/ProcivisOneCoreModule.swift +10 -10
- package/ios/RSEKeyStorage.swift +17 -571
- package/ios/RSEPinPad.swift +3 -56
- package/ios/Serialize.swift +80 -44
- package/package.json +4 -2
- package/react-native-one-core.podspec +1 -1
- package/android/build.gradle_opensource +0 -122
- package/android/libs/core-reactnative-compatible-2025.0305.1.aar +0 -0
- package/android/src/main/java/ch/procivis/one/core/ubiqu/PinPadRunner.kt +0 -123
- package/android/src/main/java/ch/procivis/one/core/ubiqu/PinPadViewManager.kt_opensource +0 -20
- package/android/src/main/java/ch/procivis/one/core/ubiqu/PinPadWrapper.kt +0 -396
- package/android/src/main/java/ch/procivis/one/core/ubiqu/RegistrationManager.kt +0 -59
- package/android/src/main/java/ch/procivis/one/core/ubiqu/TokenManager.kt +0 -48
- package/android/src/main/java/ch/procivis/one/core/ubiqu/UbiquKeyStorage.kt_opensource +0 -63
- package/android/src/main/java/ch/procivis/one/core/ubiqu/Util.kt +0 -74
- package/android/src/main/java/ch/procivis/one/core/ubiqu/dataformats/CreateIdentityRequest.kt +0 -9
- package/android/src/main/java/ch/procivis/one/core/ubiqu/dataformats/CreateIdentityResponse.kt +0 -9
- package/android/src/main/java/ch/procivis/one/core/ubiqu/dataformats/RegisterRSEResponse.kt +0 -10
- package/dist/src/backup.d.ts +0 -22
- package/dist/src/backup.js +0 -1
- package/dist/src/cache.d.ts +0 -11
- package/dist/src/cache.js +0 -12
- package/dist/src/credential.d.ts +0 -201
- package/dist/src/credential.js +0 -44
- package/dist/src/credentialSchema.d.ts +0 -135
- package/dist/src/credentialSchema.js +0 -34
- package/dist/src/did.d.ts +0 -63
- package/dist/src/did.js +0 -27
- package/dist/src/history.d.ts +0 -101
- package/dist/src/history.js +0 -63
- package/dist/src/identifier.d.ts +0 -133
- package/dist/src/identifier.js +0 -29
- package/dist/src/key.d.ts +0 -17
- package/dist/src/key.js +0 -1
- package/dist/src/list.d.ts +0 -14
- package/dist/src/list.js +0 -5
- package/dist/src/organisation.d.ts +0 -9
- package/dist/src/organisation.js +0 -1
- package/dist/src/proof.d.ts +0 -234
- package/dist/src/proof.js +0 -43
- package/dist/src/proofSchema.d.ts +0 -116
- package/dist/src/proofSchema.js +0 -9
- package/dist/src/trust.d.ts +0 -173
- package/dist/src/trust.js +0 -44
- package/dist/src/walletUnit.d.ts +0 -30
- package/dist/src/walletUnit.js +0 -11
- package/ios/RSEKeyStorage.swift_opensource +0 -61
- package/ios/RSEPinPad.swift_opensource +0 -21
- package/ios/UBQKit.xcframework/Info.plist +0 -44
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Assets.car +0 -0
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/AFCompatibilityMacros.h +0 -37
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/AFHTTPSessionManager.h +0 -304
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/AFNetworkReachabilityManager.h +0 -216
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/AFNetworking.h +0 -41
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/AFPlainTextRequestSerializer.h +0 -16
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/AFSecurityPolicy.h +0 -156
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/AFURLRequestSerialization.h +0 -479
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/AFURLResponseSerialization.h +0 -310
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/AFURLSessionManager.h +0 -501
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/CardRequestProtocol.h +0 -72
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/Constants.h +0 -222
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/DeviceBindProtocol.h +0 -38
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/DomainSecurityModule.h +0 -43
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/ErrorDomains.h +0 -68
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/FreeAssetProtocol.h +0 -40
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/GDataXMLNode.h +0 -214
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/NSDictionary+Utilities.h +0 -23
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/NSFileManager+Utilities.h +0 -20
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/NSString+Utilities.h +0 -23
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/NSURL+Utilities.h +0 -12
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/ProtocolBase.h +0 -38
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/ResetPinProtocol.h +0 -45
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/Settings.h +0 -120
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/UBQCardRequest.h +0 -58
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/UBQCardRequestBaseProcessor.h +0 -37
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/UBQCardRequestBindProcessor.h +0 -34
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/UBQCardRequestNullProcessor.h +0 -28
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/UBQCardRequestResetPinProcessor.h +0 -35
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/UBQCardRequestUnlockProcessor.h +0 -31
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/UBQCardRequestUseProcessor.h +0 -34
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/UBQKit-Swift.h +0 -761
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/UBQKit.h +0 -56
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Headers/UBQPacket.h +0 -38
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Info.plist +0 -0
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Modules/UBQKit.swiftmodule/arm64-apple-ios.abi.json +0 -89006
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Modules/UBQKit.swiftmodule/arm64-apple-ios.private.swiftinterface +0 -1099
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Modules/UBQKit.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Modules/UBQKit.swiftmodule/arm64-apple-ios.swiftinterface +0 -1099
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/Modules/module.modulemap +0 -11
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/UBQKit +0 -0
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/_CodeSignature/CodeResources +0 -597
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/certs +0 -0
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/checksums +0 -0
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/pinning_pub +0 -0
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/static +0 -0
- package/ios/UBQKit.xcframework/ios-arm64/UBQKit.framework/stream +0 -0
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Assets.car +0 -0
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/AFCompatibilityMacros.h +0 -37
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/AFHTTPSessionManager.h +0 -304
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/AFNetworkReachabilityManager.h +0 -216
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/AFNetworking.h +0 -41
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/AFPlainTextRequestSerializer.h +0 -16
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/AFSecurityPolicy.h +0 -156
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/AFURLRequestSerialization.h +0 -479
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/AFURLResponseSerialization.h +0 -310
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/AFURLSessionManager.h +0 -501
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/CardRequestProtocol.h +0 -72
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/Constants.h +0 -222
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/DeviceBindProtocol.h +0 -38
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/DomainSecurityModule.h +0 -43
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/ErrorDomains.h +0 -68
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/FreeAssetProtocol.h +0 -40
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/GDataXMLNode.h +0 -214
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/NSDictionary+Utilities.h +0 -23
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/NSFileManager+Utilities.h +0 -20
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/NSString+Utilities.h +0 -23
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/NSURL+Utilities.h +0 -12
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/ProtocolBase.h +0 -38
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/ResetPinProtocol.h +0 -45
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/Settings.h +0 -120
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/UBQCardRequest.h +0 -58
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/UBQCardRequestBaseProcessor.h +0 -37
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/UBQCardRequestBindProcessor.h +0 -34
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/UBQCardRequestNullProcessor.h +0 -28
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/UBQCardRequestResetPinProcessor.h +0 -35
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/UBQCardRequestUnlockProcessor.h +0 -31
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/UBQCardRequestUseProcessor.h +0 -34
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/UBQKit-Swift.h +0 -1522
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/UBQKit.h +0 -56
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Headers/UBQPacket.h +0 -38
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Info.plist +0 -0
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Modules/UBQKit.swiftmodule/arm64-apple-ios-simulator.abi.json +0 -89006
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Modules/UBQKit.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +0 -1099
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Modules/UBQKit.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Modules/UBQKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +0 -1099
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Modules/UBQKit.swiftmodule/x86_64-apple-ios-simulator.abi.json +0 -89006
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Modules/UBQKit.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +0 -1099
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Modules/UBQKit.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Modules/UBQKit.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +0 -1099
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/Modules/module.modulemap +0 -11
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/UBQKit +0 -0
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/_CodeSignature/CodeResources +0 -652
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/certs +0 -0
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/checksums +0 -0
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/pinning_pub +0 -0
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/static +0 -0
- package/ios/UBQKit.xcframework/ios-arm64_x86_64-simulator/UBQKit.framework/stream +0 -0
package/ios/RSEKeyStorage.swift
CHANGED
|
@@ -1,615 +1,61 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
-
import UBQKit
|
|
3
2
|
import ProcivisOneCore
|
|
4
3
|
|
|
5
4
|
class RSEKeyStorage: NativeKeyStorage {
|
|
6
5
|
|
|
7
|
-
struct TokenResponse: Decodable {
|
|
8
|
-
|
|
9
|
-
let accessToken: String
|
|
10
|
-
|
|
11
|
-
enum CodingKeys: String, CodingKey {
|
|
12
|
-
case accessToken = "access_token"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
struct CreateIdentityPayload: Encodable {
|
|
17
|
-
let sub: String
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
struct CreateIdentityResponse: Decodable {
|
|
21
|
-
let sub: String
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
struct RegisterRseResponse: Decodable {
|
|
25
|
-
let nonce: String
|
|
26
|
-
let puk: String
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private let identity_service_url = "https://api.identity.strongpin.ubiqu-sandbox.com"
|
|
30
|
-
private let organisation_id = "88e5fe80-106e-465c-a29d-1822d3790feb"
|
|
31
|
-
private let api_key = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2FwaS5pZGVudGl0eS5zdHJvbmdwaW4udWJpcXUtc2FuZGJveC5jb20iLCJpYXQiOjE3MzgzMzY2NTksImp0aSI6Ijc2NTY0M2FhLTI2NzgtNDFjZC04N2RiLThhODhmMzdjZDVhNSIsInNjb3BlIjoic2VydmljZV9hY2NvdW50Iiwic3ViIjoicHJvY2l2aXMtdGVzdCIsImF1ZCI6Imh0dHBzOi8vYXBpLnRva2VuLWdlbmVyYXRvci5zdHJvbmdwaW4udWJpcXUtc2FuZGJveC5jb20vdWJpcXUvIiwidG9rZW5fdHlwZSI6ImFwaV9rZXkifQ.RZtik0TlyoCd8M5BIKCsa0vQVols9eqB3QsvxPK-t5BvQO-v39VZoEQWahQCVQ2OKScEKX_EUeFiK0v1kzTLvKVGIIYuLYIBYJf6QQkc2MWroco54iDPMnK6_8J7EdRXdDhDH3-ukpzRrHwvOfAH50WGNco1U5QSqwvuwoWYWVANBZSBCSOMI4zYrNomEUbo04b-V10VjdHYMcpac14XxSNaxATSEliDVGv_JrAEOXSTs49ebGLT4OOdLHLoAfwu1NylpbvJQnhJYlpudzWf-46FM58uxCYs0DphYMtC6sC0XM1nhvcgli1ngzn-llSyaCQ1TY3PStU8RKxCtfa95A"
|
|
32
|
-
private let token_generator_url = "https://api.token-generator.strongpin.ubiqu-sandbox.com"
|
|
33
|
-
private let license = """
|
|
34
|
-
{"id": "26c46847-152e-44e8-b73a-b7d4c51c7074", "version": "0", "content": "OJ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77PVxCXegIic9U6tDOgelDgGLjKFLbZwkxpuK8kSRPnvSS/K8vkyl+5KxQEwNL6DC+glFWDwB3PpWi/reniqc5QzrBMUgsdMMoPTaWaXi9F8A=="}
|
|
35
|
-
""".data(using: .utf8)!
|
|
36
|
-
private let EDDSA_PREFIX_ASN1 = Data([0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00])
|
|
37
|
-
|
|
38
6
|
public static var available: Bool {
|
|
39
|
-
return
|
|
7
|
+
return false
|
|
40
8
|
}
|
|
41
9
|
|
|
42
|
-
private var subscriber: RSESubscriber?
|
|
43
|
-
private var signTransaction: UbqTransaction?
|
|
44
|
-
private var changePinTransaction: UbqChangePin?
|
|
45
|
-
|
|
46
10
|
init() {
|
|
47
|
-
|
|
11
|
+
fatalError("init() has not been implemented")
|
|
48
12
|
}
|
|
49
13
|
|
|
50
14
|
func generateKey(keyAlias: String) async throws -> GeneratedKeyBindingDto {
|
|
51
|
-
|
|
52
|
-
if let asset = UbqSdk.assets.first {
|
|
53
|
-
if asset.state != .normal {
|
|
54
|
-
// an asset can be left locked after an unfinished generation earlier (e.g. app forcefully closed during PIN setup)
|
|
55
|
-
try await delete()
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
do {
|
|
60
|
-
// Get or create the main asset
|
|
61
|
-
let mainAsset: UbqAsset
|
|
62
|
-
if let existingAsset = UbqSdk.assets.first, existingAsset.state == .normal {
|
|
63
|
-
// Main asset already exists and is ready - reuse it
|
|
64
|
-
mainAsset = existingAsset
|
|
65
|
-
} else {
|
|
66
|
-
// Need to create the main asset
|
|
67
|
-
mainAsset = try await createMainAsset()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Create a new derived asset from the main asset
|
|
71
|
-
let derivedAsset = try await withCheckedThrowingContinuation { continuation in
|
|
72
|
-
mainAsset.createDa(cryptoTypes: .EdDSA_25519) { derivedAsset in
|
|
73
|
-
continuation.resume(returning: derivedAsset)
|
|
74
|
-
} failure: { error in
|
|
75
|
-
continuation.resume(throwing: error)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
guard let keyReference = derivedAsset.uuid.uuidString.data(using: .utf8),
|
|
80
|
-
let pemString = derivedAsset.publicKey,
|
|
81
|
-
let publicKeyPrefixed = parsePEMPublicKeyContent(pemString) else {
|
|
82
|
-
throw NativeKeyStorageError.KeyGenerationFailure(reason: "Error getting keyReference or publicKey")
|
|
83
|
-
}
|
|
84
|
-
guard publicKeyPrefixed.subdata(in: 0..<12) == EDDSA_PREFIX_ASN1 else {
|
|
85
|
-
throw NativeKeyStorageError.KeyGenerationFailure(reason: "Invalid key prefix")
|
|
86
|
-
}
|
|
87
|
-
let publicKey = publicKeyPrefixed.subdata(in: 12..<44)
|
|
88
|
-
return GeneratedKeyBindingDto(keyReference: keyReference, publicKey: publicKey)
|
|
89
|
-
} catch {
|
|
90
|
-
self.subscriber = nil
|
|
91
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
92
|
-
// delete partially generated asset only if we were creating a new one
|
|
93
|
-
if UbqSdk.assets.isEmpty || UbqSdk.assets.first?.state != .normal {
|
|
94
|
-
try? await delete()
|
|
95
|
-
}
|
|
96
|
-
throw NativeKeyStorageError.KeyGenerationFailure(reason: error.localizedDescription)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private func createMainAsset() async throws -> UbqAsset {
|
|
101
|
-
let tokenUrl = URL(string: "\(token_generator_url)/ubiqu/")!
|
|
102
|
-
var tokenRequest = URLRequest(url: tokenUrl)
|
|
103
|
-
tokenRequest.httpMethod = "GET"
|
|
104
|
-
tokenRequest.setValue("bearer \(api_key)", forHTTPHeaderField: "Authorization")
|
|
105
|
-
let (tokenData, _) = try await URLSession.shared.data(for: tokenRequest)
|
|
106
|
-
|
|
107
|
-
let tokenResponse = try JSONDecoder().decode(TokenResponse.self, from: tokenData)
|
|
108
|
-
let accessToken = tokenResponse.accessToken
|
|
109
|
-
|
|
110
|
-
let identityUrl = URL(string: "\(identity_service_url)/organisation/\(organisation_id)/identity/")!
|
|
111
|
-
var identityRequest = URLRequest(url: identityUrl)
|
|
112
|
-
identityRequest.httpMethod = "POST"
|
|
113
|
-
identityRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
114
|
-
identityRequest.setValue("bearer \(accessToken)", forHTTPHeaderField: "Authorization")
|
|
115
|
-
identityRequest.httpBody = try JSONEncoder().encode(CreateIdentityPayload(sub: "ios-rse-example-\(generateRandomString(length: 16))"))
|
|
116
|
-
let (identityData, _) = try await URLSession.shared.data(for: identityRequest)
|
|
117
|
-
|
|
118
|
-
let identityResponse = try JSONDecoder().decode(CreateIdentityResponse.self, from: identityData)
|
|
119
|
-
let subject = identityResponse.sub
|
|
120
|
-
|
|
121
|
-
let rseUrl = URL(string: "\(identity_service_url)/organisation/\(organisation_id)/identity/\(subject)/register_rse/")!
|
|
122
|
-
var rseRequest = URLRequest(url: rseUrl)
|
|
123
|
-
rseRequest.httpMethod = "POST"
|
|
124
|
-
rseRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
125
|
-
rseRequest.setValue("bearer \(accessToken)", forHTTPHeaderField: "Authorization")
|
|
126
|
-
rseRequest.httpBody = try JSONEncoder().encode(CreateIdentityPayload(sub: "ios-rse-example-\(generateRandomString(length: 16))"))
|
|
127
|
-
let (rseData, _) = try await URLSession.shared.data(for: rseRequest)
|
|
128
|
-
|
|
129
|
-
let rseResponse = try JSONDecoder().decode(RegisterRseResponse.self, from: rseData)
|
|
130
|
-
|
|
131
|
-
let subscribeTransaction = try await withCheckedThrowingContinuation { continuation in
|
|
132
|
-
UbqSdk.subscribe(rseResponse.nonce, rseResponse.puk) { flow in
|
|
133
|
-
continuation.resume(returning: flow)
|
|
134
|
-
} onStartFailure: { error in
|
|
135
|
-
continuation.resume(throwing: error)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
self.subscriber = await RSESubscriber(pinPad: RSEPinPad.self.sharedPinPad, transaction: subscribeTransaction)
|
|
139
|
-
let asset = try await self.subscriber!.perform()
|
|
140
|
-
self.subscriber = nil
|
|
141
|
-
|
|
142
|
-
return asset
|
|
15
|
+
fatalError("generateKey(keyAlias:) has not been implemented")
|
|
143
16
|
}
|
|
144
17
|
|
|
145
18
|
func sign(keyReference: Data, message: Data) async throws -> Data {
|
|
146
|
-
|
|
147
|
-
throw NativeKeyStorageError.SignatureFailure(reason: "Key does not exist")
|
|
148
|
-
}
|
|
149
|
-
try await withCheckedThrowingContinuation { continuation in
|
|
150
|
-
asset.refreshDerivedAssets {
|
|
151
|
-
continuation.resume()
|
|
152
|
-
} failure: { error in
|
|
153
|
-
continuation.resume(throwing: error)
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
guard let keyReferenceUUIDString = String(data: keyReference, encoding: .utf8),
|
|
157
|
-
let keyReferenceUUID = UUID(uuidString: keyReferenceUUIDString),
|
|
158
|
-
let derivedAsset = asset.derivedAssets.first(where: { $0.uuid == keyReferenceUUID }) else {
|
|
159
|
-
throw NativeKeyStorageError.SignatureFailure(reason: "Key does not exist")
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
let signature: String?
|
|
163
|
-
|
|
164
|
-
DispatchQueue.main.async {
|
|
165
|
-
RSEPinPad.sharedPinPad.isHidden = false
|
|
166
|
-
RSEPinPad.sharedPinPad.clear(makeVisible: true)
|
|
167
|
-
RSEPinPad.fixSubviews(view: RSEPinPad.sharedPinPad)
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
do {
|
|
171
|
-
self.signTransaction = try await withCheckedThrowingContinuation { continuation in
|
|
172
|
-
derivedAsset.use(toBeSignedData: message.compactMap { String(format: "%02x", $0) }.joined()) { flow in
|
|
173
|
-
continuation.resume(returning: flow)
|
|
174
|
-
} failure: { error in
|
|
175
|
-
continuation.resume(throwing: error)
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
signature = try await RSESigner(pinPad: RSEPinPad.self.sharedPinPad).perform(transaction: self.signTransaction!)
|
|
180
|
-
self.signTransaction = nil
|
|
181
|
-
} catch {
|
|
182
|
-
self.signTransaction = nil
|
|
183
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
184
|
-
throw NativeKeyStorageError.SignatureFailure(reason: error.localizedDescription)
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
guard let signature else {
|
|
188
|
-
throw NativeKeyStorageError.SignatureFailure(reason: "No signature returned")
|
|
189
|
-
}
|
|
190
|
-
guard let base64SignatureData = signature.data(using: .utf8),
|
|
191
|
-
let signatureData = Data(base64Encoded: base64SignatureData) else {
|
|
192
|
-
throw NativeKeyStorageError.SignatureFailure(reason: "Can't convert signature data")
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return signatureData
|
|
19
|
+
fatalError("sign(keyReference:,message:) has not been implemented")
|
|
196
20
|
}
|
|
197
21
|
|
|
198
22
|
func generateAttestation(keyReference: Data, nonce: String?) async throws -> [String] {
|
|
199
|
-
|
|
23
|
+
fatalError("generateAttestation(keyReference:,nonce:) has not been implemented")
|
|
200
24
|
}
|
|
201
25
|
|
|
202
26
|
func generateAttestationKey(keyAlias: String, nonce: String?) async throws -> ProcivisOneCore.GeneratedKeyBindingDto {
|
|
203
|
-
|
|
27
|
+
fatalError("generateAttestationKey(keyAlias:,nonce:) has not been implemented")
|
|
204
28
|
}
|
|
205
|
-
|
|
29
|
+
|
|
206
30
|
func signWithAttestationKey(keyReference: Data, message: Data) async throws -> Data {
|
|
207
|
-
|
|
31
|
+
fatalError("signWithAttestationKey(keyReference:,message:) has not been implemented")
|
|
208
32
|
}
|
|
209
|
-
|
|
33
|
+
|
|
210
34
|
func changePin() async throws {
|
|
211
|
-
|
|
212
|
-
throw NativeKeyStorageError.SignatureFailure(reason: "Key does not exist")
|
|
213
|
-
}
|
|
214
|
-
do {
|
|
215
|
-
self.changePinTransaction = try await withCheckedThrowingContinuation { continuation in
|
|
216
|
-
asset.changePin { flow in
|
|
217
|
-
continuation.resume(returning: flow)
|
|
218
|
-
} failure: { error in
|
|
219
|
-
continuation.resume(throwing: error)
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
try await RSEPinChanger(pinPad: RSEPinPad.sharedPinPad).perform(transaction: self.changePinTransaction!)
|
|
224
|
-
self.changePinTransaction = nil
|
|
225
|
-
} catch {
|
|
226
|
-
self.changePinTransaction = nil
|
|
227
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
228
|
-
throw NativeKeyStorageError.Unknown(reason: error.localizedDescription)
|
|
229
|
-
}
|
|
35
|
+
fatalError("changePin() has not been implemented")
|
|
230
36
|
}
|
|
231
37
|
|
|
232
38
|
var areBiometricsSupported: Bool {
|
|
233
|
-
|
|
39
|
+
fatalError("areBiometricsSupported has not been implemented")
|
|
234
40
|
}
|
|
235
41
|
|
|
236
42
|
var areBiometricsEnabled: Bool {
|
|
237
|
-
|
|
238
|
-
return false
|
|
239
|
-
}
|
|
240
|
-
return asset.biometricAuthenticationEnabled
|
|
43
|
+
fatalError("areBiometricsEnabled has not been implemented")
|
|
241
44
|
}
|
|
242
45
|
|
|
243
46
|
func enableBiometrics() async throws {
|
|
244
|
-
|
|
245
|
-
throw NativeKeyStorageError.SignatureFailure(reason: "Key does not exist")
|
|
246
|
-
}
|
|
247
|
-
do {
|
|
248
|
-
try await withCheckedThrowingContinuation { continuation in
|
|
249
|
-
asset.addBiometrics {
|
|
250
|
-
continuation.resume(returning: Void())
|
|
251
|
-
} failure: { error in
|
|
252
|
-
continuation.resume(throwing: error)
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
} catch {
|
|
256
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
257
|
-
throw NativeKeyStorageError.Unknown(reason: error.localizedDescription)
|
|
258
|
-
}
|
|
47
|
+
fatalError("enableBiometrics() has not been implemented")
|
|
259
48
|
}
|
|
260
49
|
|
|
261
50
|
func disableBiometrics() throws {
|
|
262
|
-
|
|
263
|
-
throw NativeKeyStorageError.SignatureFailure(reason: "Key does not exist")
|
|
264
|
-
}
|
|
265
|
-
asset.removeBiometrics()
|
|
51
|
+
fatalError("disableBiometrics() has not been implemented")
|
|
266
52
|
}
|
|
267
53
|
|
|
268
54
|
func delete() async throws {
|
|
269
|
-
|
|
270
|
-
return
|
|
271
|
-
}
|
|
272
|
-
try await withCheckedThrowingContinuation { continuation in
|
|
273
|
-
UbqSdk.assets.forEach { asset in
|
|
274
|
-
asset.revoke() {
|
|
275
|
-
asset.delete() {
|
|
276
|
-
continuation.resume(returning: Void())
|
|
277
|
-
} failure: { error in
|
|
278
|
-
debugPrint("Error deleting RSE: \(error)")
|
|
279
|
-
continuation.resume(throwing: error)
|
|
280
|
-
}
|
|
281
|
-
} failure: { error in
|
|
282
|
-
debugPrint("Error revoking RSE: \(error)")
|
|
283
|
-
continuation.resume(throwing: error)
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
func resetPinFlow() async throws {
|
|
290
|
-
if let subscriber {
|
|
291
|
-
subscriber.cancel(error: NativeKeyStorageError.KeyGenerationFailure(reason: "User canceled"))
|
|
292
|
-
self.subscriber = nil
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if let signTransaction {
|
|
296
|
-
signTransaction.cancel()
|
|
297
|
-
self.signTransaction = nil
|
|
298
|
-
}
|
|
299
|
-
if self.changePinTransaction != nil {
|
|
300
|
-
self.changePinTransaction = nil
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
private extension RSEKeyStorage {
|
|
306
|
-
|
|
307
|
-
func generateRandomString(length: Int) -> String {
|
|
308
|
-
let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
309
|
-
return String((0..<length).map { _ in letters.randomElement()! })
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
func parsePEMPublicKeyContent(_ content: String) -> Data? {
|
|
313
|
-
let base64String = content
|
|
314
|
-
.replacingOccurrences(of: "-----BEGIN PUBLIC KEY-----\n", with: "")
|
|
315
|
-
.replacingOccurrences(of: "-----END PUBLIC KEY-----\n", with: "")
|
|
316
|
-
.split(separator: "\n")
|
|
317
|
-
.joined()
|
|
318
|
-
return Data(base64Encoded: base64String)
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
private class RSESubscriber: SubscribeUiProtocol, SubscribeFinishProtocol {
|
|
323
|
-
|
|
324
|
-
enum SubscribeTransactionError: Error {
|
|
325
|
-
|
|
326
|
-
case rejected
|
|
327
|
-
case exceededPinInputAttempts
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
private var continuation: CheckedContinuation<UbqAsset, any Error>?
|
|
331
|
-
private var transaction: UbqSubscribe?
|
|
332
|
-
private weak var pinPad: UBQPinPad!
|
|
333
|
-
|
|
334
|
-
init(pinPad: UBQPinPad, transaction: UbqSubscribe) {
|
|
335
|
-
self.pinPad = pinPad
|
|
336
|
-
self.transaction = transaction
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
func perform() async throws -> UbqAsset {
|
|
340
|
-
DispatchQueue.main.async { [self] in
|
|
341
|
-
self.pinPad.clear(makeVisible: true)
|
|
342
|
-
RSEPinPad.fixSubviews(view: self.pinPad)
|
|
343
|
-
}
|
|
344
|
-
return try await withCheckedThrowingContinuation { continuation in
|
|
345
|
-
guard let transaction = self.transaction else {
|
|
346
|
-
continuation.resume(throwing: NativeKeyStorageError.KeyGenerationFailure(reason: "User canceled"))
|
|
347
|
-
return
|
|
348
|
-
}
|
|
349
|
-
transaction.setUiProtocol(i: self)
|
|
350
|
-
|
|
351
|
-
do {
|
|
352
|
-
try ProcivisOneCoreEventEmitter.shared.sendShowPinEvent(flowType: .subscribe, stage: .newFirstPin)
|
|
353
|
-
} catch {
|
|
354
|
-
continuation.resume(throwing: error)
|
|
355
|
-
return
|
|
356
|
-
}
|
|
357
|
-
self.continuation = continuation
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
func cancel(error: Error) {
|
|
362
|
-
self.transaction = nil
|
|
363
|
-
self.continuation?.resume(throwing: error)
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// MARK: SubscribeUiProtocol
|
|
367
|
-
|
|
368
|
-
func onSubscribePukEntered() {
|
|
369
|
-
debugPrint("UBQ Subscribe Transaction puk entered")
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
func onSubscribeFirstPinEntered() {
|
|
373
|
-
debugPrint("UBQ Subscribe Transaction first PIN entered")
|
|
374
|
-
self.pinPad.clear(makeVisible: true)
|
|
375
|
-
RSEPinPad.fixSubviews(view: pinPad)
|
|
376
|
-
ProcivisOneCoreEventEmitter.shared.sendPinStageChangeEvent(stage: .newSecondPin)
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
func onSubscribeUnallowedPinEntered() {
|
|
380
|
-
debugPrint("UBQ Subscribe Transaction unallowed PIN entered")
|
|
381
|
-
self.pinPad.clear(makeVisible: true)
|
|
382
|
-
RSEPinPad.fixSubviews(view: pinPad)
|
|
383
|
-
ProcivisOneCoreEventEmitter.shared.sendPinStageChangeEvent(stage: .newFirstPin)
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
func onSubscribePinNotConfirmed() {
|
|
387
|
-
debugPrint("UBQ Subscribe Transaction PIN not confirmed")
|
|
388
|
-
self.pinPad?.clear(makeVisible: true)
|
|
389
|
-
RSEPinPad.fixSubviews(view: pinPad)
|
|
390
|
-
ProcivisOneCoreEventEmitter.shared.sendPinStageChangeEvent(stage: .newFirstPin)
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
func onSubscribePinConfirmed() {
|
|
394
|
-
debugPrint("UBQ Subscribe Transaction PIN confirmed")
|
|
395
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
396
|
-
self.transaction?.finish(subscribeFinishProtocol: self)
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
func onSubscribeUiError(error: UBQKit.UbqKitError) {
|
|
400
|
-
debugPrint("UBQ Subscribe Transaction UI error \(error)")
|
|
401
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
402
|
-
self.continuation?.resume(throwing: error)
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// MARK: SubscribeFinishProtocol
|
|
406
|
-
|
|
407
|
-
func onSubscribeCompleted(ubqAsset: UBQKit.UbqAsset) {
|
|
408
|
-
debugPrint("UBQ Subscribe Transaction completed with asset: \(ubqAsset)")
|
|
409
|
-
self.continuation?.resume(returning: ubqAsset)
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
func onSubscribeFinishFailure(error: UBQKit.UbqKitError) {
|
|
413
|
-
debugPrint("UBQ Subscribe Transaction finish failure \(error)")
|
|
414
|
-
self.continuation?.resume(throwing: error)
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
func onSubscribeIncorrectPukEntered(ubqAsset: UBQKit.UbqAsset) {
|
|
418
|
-
debugPrint("UBQ Subscribe Transaction incorrect puk entered \(ubqAsset)")
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
private class RSESigner: TransactionUiProtocol, TransactionFinishProtocol, TransactionRejectProtocol {
|
|
423
|
-
|
|
424
|
-
enum SignTransactionError: Error {
|
|
425
|
-
|
|
426
|
-
case rejected
|
|
427
|
-
case exceededPinInputAttempts
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
private var continuation: CheckedContinuation<String?, any Error>?
|
|
431
|
-
private weak var transaction: UbqTransaction?
|
|
432
|
-
private weak var pinPad: UBQPinPad!
|
|
433
|
-
|
|
434
|
-
init(pinPad: UBQPinPad) {
|
|
435
|
-
self.pinPad = pinPad
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
func perform(transaction: UbqTransaction) async throws -> String? {
|
|
439
|
-
if self.transaction != nil {
|
|
440
|
-
self.transaction!.cancel()
|
|
441
|
-
}
|
|
442
|
-
self.transaction = transaction
|
|
443
|
-
DispatchQueue.main.async {
|
|
444
|
-
self.pinPad.clear(makeVisible: true)
|
|
445
|
-
RSEPinPad.fixSubviews(view: self.pinPad)
|
|
446
|
-
}
|
|
447
|
-
transaction.setUiProtocol(i: self)
|
|
448
|
-
transaction.setRejectProtocol(i: self)
|
|
449
|
-
try ProcivisOneCoreEventEmitter.shared.sendShowPinEvent(flowType: .transaction, stage: .checkCurrentPin)
|
|
450
|
-
return try await withCheckedThrowingContinuation { continuation in
|
|
451
|
-
self.continuation = continuation
|
|
452
|
-
transaction.start()
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// MARK: TransactionUiProtocol
|
|
457
|
-
|
|
458
|
-
func onTransactionPinEntered() {
|
|
459
|
-
debugPrint("UBQ Sign Transaction PIN entered")
|
|
460
|
-
self.transaction?.finish(transactionFinishProtocol: self)
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
func onTransactionBiometricsEntered() {
|
|
464
|
-
debugPrint("UBQ Sign Transaction biometrics entered")
|
|
465
|
-
self.transaction?.finish(transactionFinishProtocol: self)
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
func onTransactionUiError(error: UBQKit.UbqKitError) {
|
|
469
|
-
debugPrint("UBQ Sign Transaction UI Error \(error)")
|
|
470
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
471
|
-
self.continuation?.resume(throwing: error)
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
// MARK: TransactionFinishProtocol
|
|
475
|
-
|
|
476
|
-
func onTransactionCompleted(result: String?) {
|
|
477
|
-
debugPrint("UBQ Sign Transaction completed with result: \(result ?? "")")
|
|
478
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
479
|
-
self.continuation?.resume(returning: result)
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
func onTransactionFinishFailure(error: UBQKit.UbqKitError) {
|
|
483
|
-
debugPrint("UBQ Sign Transaction finish failure \(error)")
|
|
484
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
485
|
-
self.continuation?.resume(throwing: error)
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
func onTransactionIncorrectPinEntered(pinAttemptsLeft: Int8) {
|
|
489
|
-
debugPrint("UBQ Sign Transaction incorrect PIN, \(pinAttemptsLeft) attempts left")
|
|
490
|
-
ProcivisOneCoreEventEmitter.shared.sendIncorrectPinEvent(attemptsLeft: Int(pinAttemptsLeft))
|
|
491
|
-
if pinAttemptsLeft == 0 {
|
|
492
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
493
|
-
self.transaction?.cancel()
|
|
494
|
-
self.continuation?.resume(throwing: SignTransactionError.exceededPinInputAttempts)
|
|
495
|
-
} else {
|
|
496
|
-
self.pinPad!.clear(makeVisible: true)
|
|
497
|
-
RSEPinPad.fixSubviews(view: pinPad)
|
|
498
|
-
ProcivisOneCoreEventEmitter.shared.sendPinStageChangeEvent(stage: .checkCurrentPin)
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
// MARK: TransactionRejectProtocol
|
|
503
|
-
|
|
504
|
-
func onTransactionRejected() {
|
|
505
|
-
debugPrint("UBQ Sign Transaction rejected")
|
|
506
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
507
|
-
self.continuation?.resume(throwing: SignTransactionError.rejected)
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
func onTransactionRejectFailure(error: UBQKit.UbqKitError) {
|
|
511
|
-
debugPrint("UBQ Sign Transaction reject failure \(error)")
|
|
512
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
513
|
-
self.continuation?.resume(throwing: error)
|
|
55
|
+
fatalError("delete() has not been implemented")
|
|
514
56
|
}
|
|
515
|
-
}
|
|
516
57
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
enum PinChangeError: Error {
|
|
520
|
-
|
|
521
|
-
case incorrectPinEntered
|
|
522
|
-
case unallowedPinEntered
|
|
523
|
-
case pinNotConfirmed
|
|
524
|
-
case exceededPinInputAttempts
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
private var continuation: CheckedContinuation<Void, any Error>?
|
|
528
|
-
private weak var transaction: UbqChangePin?
|
|
529
|
-
private weak var pinPad: UBQPinPad!
|
|
530
|
-
|
|
531
|
-
init(pinPad: UBQPinPad) {
|
|
532
|
-
self.pinPad = pinPad
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
func perform(transaction: UbqChangePin) async throws {
|
|
536
|
-
self.transaction = transaction
|
|
537
|
-
DispatchQueue.main.async {
|
|
538
|
-
self.pinPad.clear(makeVisible: true)
|
|
539
|
-
RSEPinPad.fixSubviews(view: self.pinPad)
|
|
540
|
-
}
|
|
541
|
-
transaction.setUiProtocol(i: self)
|
|
542
|
-
try ProcivisOneCoreEventEmitter.shared.sendShowPinEvent(flowType: .changePin, stage: .checkCurrentPin)
|
|
543
|
-
return try await withCheckedThrowingContinuation { continuation in
|
|
544
|
-
self.continuation = continuation
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
// MARK: ChangePinUiProtocol
|
|
549
|
-
|
|
550
|
-
func onChangePinPinEntered() {
|
|
551
|
-
debugPrint("UBQ Change PIN Transaction PIN entered")
|
|
552
|
-
self.pinPad.clear(makeVisible: true)
|
|
553
|
-
RSEPinPad.fixSubviews(view: pinPad)
|
|
554
|
-
ProcivisOneCoreEventEmitter.shared.sendPinStageChangeEvent(stage: .newFirstPin)
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
func onChangePinNewPinEntered() {
|
|
558
|
-
debugPrint("UBQ Change PIN Transaction new PIN entered")
|
|
559
|
-
self.pinPad.clear(makeVisible: true)
|
|
560
|
-
RSEPinPad.fixSubviews(view: pinPad)
|
|
561
|
-
ProcivisOneCoreEventEmitter.shared.sendPinStageChangeEvent(stage: .newSecondPin)
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
func onChangePinUnallowedPinEntered() {
|
|
565
|
-
debugPrint("UBQ Change PIN Transaction unallowed PIN entered")
|
|
566
|
-
self.pinPad.clear(makeVisible: true)
|
|
567
|
-
RSEPinPad.fixSubviews(view: pinPad)
|
|
568
|
-
ProcivisOneCoreEventEmitter.shared.sendPinStageChangeEvent(stage: .checkCurrentPin)
|
|
569
|
-
continuation?.resume(throwing: PinChangeError.unallowedPinEntered)
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
func onChangePinPinNotConfirmed() {
|
|
573
|
-
debugPrint("UBQ Change PIN Transaction PIN not confirmed")
|
|
574
|
-
self.pinPad.clear(makeVisible: true)
|
|
575
|
-
RSEPinPad.fixSubviews(view: pinPad)
|
|
576
|
-
ProcivisOneCoreEventEmitter.shared.sendPinStageChangeEvent(stage: .newFirstPin)
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
func onChangePinPinConfirmed() {
|
|
580
|
-
debugPrint("UBQ Change PIN Transaction PIN confirmed")
|
|
581
|
-
transaction?.finish(changePinFinishProtocol: self)
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
func onChangePinUiError(error: UBQKit.UbqKitError) {
|
|
585
|
-
debugPrint("UBQ Change PIN Transaction UI error \(error)")
|
|
586
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
587
|
-
continuation?.resume(throwing: error)
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
// MARK: ChangePinFinishProtocol
|
|
591
|
-
|
|
592
|
-
func onChangePinCompleted() {
|
|
593
|
-
debugPrint("UBQ Change PIN Transaction completed")
|
|
594
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
595
|
-
continuation?.resume(returning: Void())
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
func onChangePinFinishFailure(error: UBQKit.UbqKitError) {
|
|
599
|
-
debugPrint("UBQ Change PIN Transaction finish failure \(error)")
|
|
600
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
601
|
-
continuation?.resume(throwing: error)
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
func onChangePinIncorrectPinEntered(pinAttemptsLeft: Int8) {
|
|
605
|
-
debugPrint("UBQ Change PIN Transaction incorrect PIN, \(pinAttemptsLeft) attempts left")
|
|
606
|
-
ProcivisOneCoreEventEmitter.shared.sendIncorrectPinEvent(attemptsLeft: Int(pinAttemptsLeft))
|
|
607
|
-
if pinAttemptsLeft == 0 {
|
|
608
|
-
ProcivisOneCoreEventEmitter.shared.sendHidePinEvent()
|
|
609
|
-
self.continuation?.resume(throwing: PinChangeError.exceededPinInputAttempts)
|
|
610
|
-
} else {
|
|
611
|
-
ProcivisOneCoreEventEmitter.shared.sendPinStageChangeEvent(stage: .checkCurrentPin)
|
|
612
|
-
self.continuation?.resume(throwing: PinChangeError.incorrectPinEntered)
|
|
613
|
-
}
|
|
58
|
+
func resetPinFlow() async throws {
|
|
59
|
+
fatalError("resetPinFlow() has not been implemented")
|
|
614
60
|
}
|
|
615
61
|
}
|