@procivis/react-native-one-core 1.33398.0 → 1.43299.1

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