@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,123 @@
1
+ package ch.procivis.one.core.ubiqu
2
+
3
+ import android.content.Intent
4
+ import ch.procivis.one.core.NativeKeyStorageException
5
+ import com.facebook.react.bridge.Arguments
6
+ import com.facebook.react.bridge.ReactContext
7
+ import com.facebook.react.bridge.WritableMap
8
+ import com.facebook.react.modules.core.DeviceEventManagerModule
9
+ import com.ubiqu.eid.sdk.requests.UbqRequestFlow
10
+
11
+ object PinPadRunner {
12
+ enum class RequestType {
13
+ SUBSCRIBE,
14
+ TRANSACTION,
15
+ ADD_BIOMETRICS,
16
+ CHANGE_PIN
17
+ }
18
+
19
+ enum class RNEvent {
20
+ RSE_SHOW_PIN,
21
+ RSE_HIDE_PIN,
22
+ RSE_DIGITS_ENTERED,
23
+ RSE_PIN_STAGE,
24
+ RSE_INCORRECT_PIN
25
+ }
26
+
27
+ enum class RNEventParam {
28
+ flowType,
29
+ digitsEntered,
30
+ stage,
31
+ attemptsLeft,
32
+ }
33
+
34
+ enum class RNEventStage {
35
+ CHECK_CURRENT_PIN,
36
+ NEW_FIRST_PIN,
37
+ NEW_SECOND_PIN,
38
+ }
39
+
40
+ data class Flow(
41
+ val flow: UbqRequestFlow,
42
+ val promise: Util.Promise<String?>,
43
+ val type: RequestType
44
+ )
45
+
46
+ @Volatile
47
+ private var activeFlow: Flow? = null
48
+
49
+ @Synchronized
50
+ fun getActiveFlow(): Flow {
51
+ return activeFlow ?: throw NativeKeyStorageException.Unknown("No active flow")
52
+ }
53
+
54
+ private fun sendRNEvent(context: ReactContext, eventName: String, params: WritableMap?) {
55
+ context
56
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
57
+ .emit(eventName, params)
58
+ }
59
+
60
+ // ==== called from UbiquKeyStorage
61
+ @Synchronized
62
+ fun startPinPadFlow(
63
+ context: ReactContext,
64
+ flow: UbqRequestFlow,
65
+ requestType: RequestType,
66
+ promise: Util.Promise<String?>
67
+ ) {
68
+ if (activeFlow != null) {
69
+ throw NativeKeyStorageException.Unknown("Another PinPad flow in progress")
70
+ }
71
+
72
+ activeFlow = Flow(flow, promise, requestType)
73
+
74
+ val params = Arguments.createMap()
75
+ params.putString(RNEventParam.flowType.name, requestType.name)
76
+
77
+ val initialStage = when (requestType) {
78
+ RequestType.SUBSCRIBE -> RNEventStage.NEW_FIRST_PIN
79
+ else -> RNEventStage.CHECK_CURRENT_PIN
80
+ }
81
+ params.putString(RNEventParam.stage.name, initialStage.name)
82
+ sendRNEvent(context, RNEvent.RSE_SHOW_PIN.name, params)
83
+ }
84
+
85
+ @Synchronized
86
+ fun cancelPinPadFlow() {
87
+ activeFlow?.promise?.fail(NativeKeyStorageException.Unknown("Canceled by user"))
88
+ activeFlow = null
89
+ }
90
+
91
+ // ==== called from PinPadWrapper
92
+ @Synchronized
93
+ fun finishPinPadFlowSuccess(context: ReactContext, data: String?) {
94
+ activeFlow?.promise?.succeed(data)
95
+ activeFlow = null
96
+ sendRNEvent(context, RNEvent.RSE_HIDE_PIN.name, null)
97
+ }
98
+
99
+ @Synchronized
100
+ fun finishPinPadFlowFailure(context: ReactContext, error: Throwable) {
101
+ activeFlow?.promise?.fail(error)
102
+ activeFlow = null
103
+ sendRNEvent(context, RNEvent.RSE_HIDE_PIN.name, null)
104
+ }
105
+
106
+ fun digitsEntered(context: ReactContext, numPins: Int) {
107
+ val params = Arguments.createMap()
108
+ params.putInt(RNEventParam.digitsEntered.name, numPins)
109
+ sendRNEvent(context, RNEvent.RSE_DIGITS_ENTERED.name, params)
110
+ }
111
+
112
+ fun pinStage(context: ReactContext, stage: RNEventStage) {
113
+ val params = Arguments.createMap()
114
+ params.putString(RNEventParam.stage.name, stage.name)
115
+ sendRNEvent(context, RNEvent.RSE_PIN_STAGE.name, params)
116
+ }
117
+
118
+ fun incorrectPin(context: ReactContext, attemptsLeft: Int) {
119
+ val params = Arguments.createMap()
120
+ params.putInt(RNEventParam.attemptsLeft.name, attemptsLeft)
121
+ sendRNEvent(context, RNEvent.RSE_INCORRECT_PIN.name, params)
122
+ }
123
+ }
@@ -0,0 +1,23 @@
1
+ package ch.procivis.one.core.ubiqu
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.uimanager.SimpleViewManager
5
+ import com.facebook.react.uimanager.ThemedReactContext
6
+ import com.ubiqu.eid.sdk.components.UbqInternalPad
7
+ import com.ubiqu.eid.sdk.components.UbqPinPad
8
+
9
+ class PinPadViewManager(private val callerContext: ReactApplicationContext) :
10
+ SimpleViewManager<UbqPinPad>() {
11
+ companion object {
12
+ const val REACT_CLASS = "RCTProcivisRSEPinPad"
13
+ }
14
+
15
+ override fun getName() = REACT_CLASS
16
+
17
+ override fun createViewInstance(context: ThemedReactContext): UbqPinPad {
18
+ val pinPad = UbqPinPad(context, extraButton = UbqInternalPad.ExtraButtonFunctionality.BIOMETRICS_AUTO.code)
19
+ val activeFlow = PinPadRunner.getActiveFlow()
20
+ PinPadWrapper(callerContext, pinPad, activeFlow.flow, activeFlow.type)
21
+ return pinPad
22
+ }
23
+ }
@@ -0,0 +1,20 @@
1
+ package ch.procivis.one.core.ubiqu
2
+
3
+ import android.view.View
4
+ import ch.procivis.one.core.NativeKeyStorageException
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.SimpleViewManager
7
+ import com.facebook.react.uimanager.ThemedReactContext
8
+
9
+ class PinPadViewManager(private val callerContext: ReactApplicationContext) :
10
+ SimpleViewManager<View>() {
11
+ companion object {
12
+ const val REACT_CLASS = "RCTProcivisRSEPinPad"
13
+ }
14
+
15
+ override fun getName() = REACT_CLASS
16
+
17
+ override fun createViewInstance(context: ThemedReactContext): View {
18
+ throw NativeKeyStorageException.Unsupported()
19
+ }
20
+ }
@@ -0,0 +1,396 @@
1
+ package ch.procivis.one.core.ubiqu
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.util.Log
5
+ import androidx.fragment.app.FragmentActivity
6
+ import ch.procivis.one.core.NativeKeyStorageException
7
+ import ch.procivis.one.core.ubiqu.PinPadRunner.digitsEntered
8
+ import ch.procivis.one.core.ubiqu.PinPadRunner.finishPinPadFlowFailure
9
+ import ch.procivis.one.core.ubiqu.PinPadRunner.finishPinPadFlowSuccess
10
+ import ch.procivis.one.core.ubiqu.PinPadRunner.incorrectPin
11
+ import ch.procivis.one.core.ubiqu.PinPadRunner.pinStage
12
+ import com.facebook.react.bridge.ReactContext
13
+ import com.ubiqu.eid.sdk.backend.assets.UbqAsset
14
+ import com.ubiqu.eid.sdk.components.UbqPinPad
15
+ import com.ubiqu.eid.sdk.enums.AddBiometricsState
16
+ import com.ubiqu.eid.sdk.enums.ChangePinState
17
+ import com.ubiqu.eid.sdk.enums.SubscribeState
18
+ import com.ubiqu.eid.sdk.enums.TransactionState
19
+ import com.ubiqu.eid.sdk.exceptions.UbqSdkException
20
+ import com.ubiqu.eid.sdk.interfaces.AddBiometricsFinishInterface
21
+ import com.ubiqu.eid.sdk.interfaces.AddBiometricsUiInterface
22
+ import com.ubiqu.eid.sdk.interfaces.ChangePinFinishInterface
23
+ import com.ubiqu.eid.sdk.interfaces.ChangePinUiInterface
24
+ import com.ubiqu.eid.sdk.interfaces.SubscribeFinishInterface
25
+ import com.ubiqu.eid.sdk.interfaces.SubscribeUiInterface
26
+ import com.ubiqu.eid.sdk.interfaces.TransactionFinishInterface
27
+ import com.ubiqu.eid.sdk.interfaces.TransactionUiInterface
28
+ import com.ubiqu.eid.sdk.interfaces.UbqPinPadReporting
29
+ import com.ubiqu.eid.sdk.requests.UbqAddBiometrics
30
+ import com.ubiqu.eid.sdk.requests.UbqChangePin
31
+ import com.ubiqu.eid.sdk.requests.UbqRequestFlow
32
+ import com.ubiqu.eid.sdk.requests.UbqSubscribe
33
+ import com.ubiqu.eid.sdk.requests.UbqTransaction
34
+
35
+
36
+ @SuppressLint("LogNotTimber")
37
+ class PinPadWrapper(
38
+ private val context: ReactContext,
39
+ private val pinPad: UbqPinPad,
40
+ private val flow: UbqRequestFlow,
41
+ flowType: PinPadRunner.RequestType
42
+ ) : SubscribeUiInterface, SubscribeFinishInterface,
43
+ UbqPinPadReporting, TransactionUiInterface, TransactionFinishInterface,
44
+ AddBiometricsUiInterface, AddBiometricsFinishInterface, ChangePinUiInterface,
45
+ ChangePinFinishInterface {
46
+
47
+ companion object {
48
+ private const val TAG = "ch.procivis.one.core.ubiqu.PinPadWrapper"
49
+ }
50
+
51
+ init {
52
+ pinPad.setKeyPadOnKeyListener(this)
53
+ pinPad.setOnPinInputFinishListener(flow)
54
+
55
+ when (flowType) {
56
+ PinPadRunner.RequestType.SUBSCRIBE -> {
57
+ (flow as UbqSubscribe).update(this)
58
+ }
59
+
60
+ PinPadRunner.RequestType.TRANSACTION -> {
61
+ val fragmentActivity = context.currentActivity as? FragmentActivity
62
+ val transaction = flow as UbqTransaction
63
+ transaction.update(this, fragmentActivity = fragmentActivity)
64
+ if (transaction.ubqAsset?.biometricsEnabled == true) {
65
+ pinPad.enableBiometrics(transaction)
66
+ }
67
+ }
68
+
69
+ PinPadRunner.RequestType.ADD_BIOMETRICS -> {
70
+ (flow as UbqAddBiometrics).update(this)
71
+ }
72
+
73
+ PinPadRunner.RequestType.CHANGE_PIN -> {
74
+ (flow as UbqChangePin).update(this)
75
+ }
76
+ }
77
+ }
78
+
79
+ // ========== SubscribeUiInterface
80
+ override fun onSubscribeFirstPinEntered() {
81
+ Log.d(TAG, "onSubscribeFirstPinEntered")
82
+ updateSubscribeFlow(flow as UbqSubscribe)
83
+ }
84
+
85
+ override fun onSubscribePinConfirmed() {
86
+ Log.d(TAG, "onSubscribePinConfirmed")
87
+ updateSubscribeFlow(flow as UbqSubscribe)
88
+ }
89
+
90
+ override fun onSubscribePinNotConfirmed() {
91
+ Log.d(TAG, "onSubscribePinNotConfirmed")
92
+ updateSubscribeFlow(flow as UbqSubscribe)
93
+ }
94
+
95
+ override fun onSubscribePukEntered() {
96
+ Log.d(TAG, "onSubscribePukEntered")
97
+ updateSubscribeFlow(flow as UbqSubscribe)
98
+ }
99
+
100
+ override fun onSubscribeUiError(error: UbqSdkException) {
101
+ Log.w(TAG, "onSubscribeUiError: $error")
102
+ finishPinPadFlowFailure(context, error)
103
+ }
104
+
105
+ override fun onSubscribeUnallowedPinEntered() {
106
+ Log.d(TAG, "onSubscribeUnallowedPinEntered")
107
+ updateSubscribeFlow(flow as UbqSubscribe)
108
+ }
109
+
110
+ // ========== SubscribeFinishInterface
111
+ override fun onSubscribeCompleted(ubqAsset: UbqAsset) {
112
+ Log.d(TAG, "onSubscribeCompleted")
113
+ updateSubscribeFlow(flow as UbqSubscribe)
114
+ }
115
+
116
+ override fun onSubscribeFinishFailure(error: UbqSdkException) {
117
+ Log.w(TAG, "onSubscribeFinishFailure: $error")
118
+ finishPinPadFlowFailure(context, error)
119
+ }
120
+
121
+ override fun onSubscribeIncorrectPukEntered(ubqAsset: UbqAsset) {
122
+ Log.d(TAG, "onSubscribeIncorrectPukEntered")
123
+ finishPinPadFlowFailure(context, NativeKeyStorageException.Unknown("Wrong PUK"))
124
+ }
125
+
126
+ // ========== TransactionUiInterface
127
+ override fun onTransactionBiometricsEntered() {
128
+ Log.d(TAG, "onTransactionBiometricsEntered")
129
+ updateTransactionFlow(flow as UbqTransaction)
130
+ }
131
+
132
+ override fun onTransactionPinEntered() {
133
+ Log.d(TAG, "onTransactionPinEntered")
134
+ updateTransactionFlow(flow as UbqTransaction)
135
+ }
136
+
137
+ override fun onTransactionUiError(error: UbqSdkException) {
138
+ Log.w(TAG, "onTransactionUiError: $error")
139
+ finishPinPadFlowFailure(context, error)
140
+ }
141
+
142
+ // ========== TransactionFinishInterface
143
+ override fun onTransactionCompleted(result: String?) {
144
+ Log.d(TAG, "onTransactionCompleted")
145
+ finishPinPadFlowSuccess(context, result)
146
+ }
147
+
148
+ override fun onTransactionIncorrectPinEntered(pinAttemptsLeft: Int) {
149
+ Log.d(TAG, "onTransactionIncorrectPinEntered (attempts left: $pinAttemptsLeft)")
150
+ incorrectPin(context, pinAttemptsLeft)
151
+ if (pinAttemptsLeft == 0) {
152
+ finishPinPadFlowFailure(
153
+ context,
154
+ NativeKeyStorageException.Unknown("Exceeded PIN input attempts")
155
+ )
156
+ } else {
157
+ pinPad.clear(true)
158
+ pinStage(context, PinPadRunner.RNEventStage.CHECK_CURRENT_PIN)
159
+ }
160
+ }
161
+
162
+ override fun onTransactionFinishFailure(error: UbqSdkException) {
163
+ Log.w(TAG, "onTransactionFinishFailure: $error")
164
+ finishPinPadFlowFailure(context, error)
165
+ }
166
+
167
+ // ========== AddBiometricsUiInterface
168
+ override fun onAddBiometricsIncorrectBiometricsEntered() {
169
+ Log.d(TAG, "onAddBiometricsIncorrectBiometricsEntered")
170
+ updateAddBiometricsFlow(flow as UbqAddBiometrics)
171
+ }
172
+
173
+ override fun onAddBiometricsPinEntered() {
174
+ Log.d(TAG, "onAddBiometricsPinEntered")
175
+ updateAddBiometricsFlow(flow as UbqAddBiometrics)
176
+ }
177
+
178
+ override fun onAddBiometricsUiError(error: UbqSdkException) {
179
+ Log.w(TAG, "onAddBiometricsUiError: $error")
180
+ finishPinPadFlowFailure(context, error)
181
+ }
182
+
183
+ // ========== AddBiometricsFinishInterface
184
+ override fun onAddBiometricsCompleted() {
185
+ Log.d(TAG, "onAddBiometricsCompleted")
186
+ updateAddBiometricsFlow(flow as UbqAddBiometrics)
187
+ }
188
+
189
+ override fun onAddBiometricsFinishFailure(error: UbqSdkException) {
190
+ Log.w(TAG, "onAddBiometricsFinishFailure: $error")
191
+ finishPinPadFlowFailure(context, error)
192
+ }
193
+
194
+ override fun onAddBiometricsIncorrectPinEntered(pinAttemptsLeft: Int) {
195
+ Log.d(TAG, "onAddBiometricsIncorrectPinEntered (attempts left: $pinAttemptsLeft)")
196
+ incorrectPin(context, pinAttemptsLeft)
197
+ if (pinAttemptsLeft == 0) {
198
+ finishPinPadFlowFailure(
199
+ context,
200
+ NativeKeyStorageException.Unknown("Exceeded PIN input attempts")
201
+ )
202
+ } else {
203
+ pinPad.clear(true)
204
+ pinStage(context, PinPadRunner.RNEventStage.CHECK_CURRENT_PIN)
205
+ }
206
+ }
207
+
208
+ // ========== ChangePinUiInterface
209
+ override fun onChangePinPinEntered() {
210
+ Log.d(TAG, "onChangePinPinEntered")
211
+ updateChangePinFlow(flow as UbqChangePin)
212
+ }
213
+
214
+ override fun onChangePinNewPinEntered() {
215
+ Log.d(TAG, "onChangePinNewPinEntered")
216
+ updateChangePinFlow(flow as UbqChangePin)
217
+ }
218
+
219
+ override fun onChangePinPinConfirmed() {
220
+ Log.d(TAG, "onChangePinPinConfirmed")
221
+ updateChangePinFlow(flow as UbqChangePin)
222
+ }
223
+
224
+ override fun onChangePinPinNotConfirmed() {
225
+ Log.d(TAG, "onChangePinPinNotConfirmed")
226
+ updateChangePinFlow(flow as UbqChangePin)
227
+ }
228
+
229
+ override fun onChangePinUiError(error: UbqSdkException) {
230
+ Log.w(TAG, "onChangePinUiError: $error")
231
+ finishPinPadFlowFailure(context, error)
232
+ }
233
+
234
+ override fun onChangePinUnallowedPinEntered() {
235
+ Log.d(TAG, "onChangePinUnallowedPinEntered")
236
+ updateChangePinFlow(flow as UbqChangePin)
237
+ }
238
+
239
+ // ========== ChangePinFinishInterface
240
+ override fun onChangePinCompleted() {
241
+ Log.d(TAG, "onChangePinCompleted")
242
+ updateChangePinFlow(flow as UbqChangePin)
243
+ }
244
+
245
+ override fun onChangePinFinishFailure(error: UbqSdkException) {
246
+ Log.w(TAG, "onChangePinFinishFailure: $error")
247
+ finishPinPadFlowFailure(context, error)
248
+ }
249
+
250
+ override fun onChangePinIncorrectPinEntered(pinAttemptsLeft: Int) {
251
+ Log.d(TAG, "onChangePinIncorrectPinEntered (attempts left: $pinAttemptsLeft)")
252
+ incorrectPin(context, pinAttemptsLeft)
253
+ if (pinAttemptsLeft == 0) {
254
+ finishPinPadFlowFailure(
255
+ context,
256
+ NativeKeyStorageException.Unknown("Exceeded PIN input attempts")
257
+ )
258
+ } else {
259
+ pinStage(context, PinPadRunner.RNEventStage.CHECK_CURRENT_PIN)
260
+ finishPinPadFlowFailure(
261
+ context,
262
+ NativeKeyStorageException.Unknown("Incorrect PIN entered")
263
+ )
264
+ }
265
+ }
266
+
267
+ // ========== UbqPinPadReporting
268
+ override fun onDigitsChanged(newAmount: Int) {
269
+ Log.d(TAG, "onDigitsChanged: $newAmount")
270
+ digitsEntered(context, newAmount)
271
+ }
272
+
273
+ // private
274
+ private fun updateChangePinFlow(flow: UbqChangePin) {
275
+ when (flow.state) {
276
+ ChangePinState.AWAITING_PIN -> {
277
+ pinPad.clear(true)
278
+ pinStage(context, PinPadRunner.RNEventStage.CHECK_CURRENT_PIN)
279
+ }
280
+
281
+ ChangePinState.AWAITING_NEW_PIN -> {
282
+ pinPad.clear(true)
283
+ pinStage(context, PinPadRunner.RNEventStage.NEW_FIRST_PIN)
284
+ }
285
+
286
+ ChangePinState.AWAITING_CONFIRMATION_PIN -> {
287
+ pinPad.clear(true)
288
+ pinStage(context, PinPadRunner.RNEventStage.NEW_SECOND_PIN)
289
+ }
290
+
291
+ ChangePinState.AWAITING_FINISH -> {
292
+ flow.finish(this)
293
+ }
294
+
295
+ ChangePinState.SUCCESS -> {
296
+ finishPinPadFlowSuccess(context, null)
297
+ }
298
+
299
+ ChangePinState.FAILURE -> {
300
+ finishPinPadFlowFailure(
301
+ context,
302
+ NativeKeyStorageException.Unknown("Change PIN flow failure")
303
+ )
304
+ }
305
+
306
+ null -> {
307
+ throw NativeKeyStorageException.Unknown("Missing change PIN flow state")
308
+ }
309
+ }
310
+ }
311
+
312
+ private fun updateAddBiometricsFlow(flow: UbqAddBiometrics) {
313
+ when (flow.state) {
314
+ AddBiometricsState.AWAITING_PIN -> {
315
+ pinPad.clear(true)
316
+ pinStage(context, PinPadRunner.RNEventStage.CHECK_CURRENT_PIN)
317
+ }
318
+
319
+ AddBiometricsState.AWAITING_FINISH -> {
320
+ flow.finish(this)
321
+ }
322
+
323
+ AddBiometricsState.SUCCESS -> {
324
+ finishPinPadFlowSuccess(context, null)
325
+ }
326
+
327
+ AddBiometricsState.FAILURE -> {
328
+ finishPinPadFlowFailure(
329
+ context,
330
+ NativeKeyStorageException.Unknown("Add biometrics flow failure")
331
+ )
332
+ }
333
+
334
+ null -> {
335
+ throw NativeKeyStorageException.Unknown("Missing add biometrics flow state")
336
+ }
337
+ }
338
+ }
339
+
340
+ private fun updateTransactionFlow(flow: UbqTransaction) {
341
+ when (flow.state) {
342
+ TransactionState.AWAITING_PIN -> {
343
+ pinPad.clear(true)
344
+ pinStage(context, PinPadRunner.RNEventStage.CHECK_CURRENT_PIN)
345
+ }
346
+
347
+ TransactionState.AWAITING_FINISH -> {
348
+ flow.finish(this)
349
+ }
350
+
351
+ TransactionState.FAILURE -> {
352
+ finishPinPadFlowFailure(
353
+ context,
354
+ NativeKeyStorageException.Unknown("Transaction flow failure")
355
+ )
356
+ }
357
+
358
+ else -> {
359
+ throw NativeKeyStorageException.Unknown("Invalid transaction flow state ${flow.state}")
360
+ }
361
+ }
362
+ }
363
+
364
+ private fun updateSubscribeFlow(flow: UbqSubscribe) {
365
+ when (flow.state) {
366
+ SubscribeState.AWAITING_FIRST_PIN -> {
367
+ pinPad.clear(true)
368
+ pinStage(context, PinPadRunner.RNEventStage.NEW_FIRST_PIN)
369
+ }
370
+
371
+ SubscribeState.AWAITING_CONFIRMATION_PIN -> {
372
+ pinPad.clear(true)
373
+ pinStage(context, PinPadRunner.RNEventStage.NEW_SECOND_PIN)
374
+ }
375
+
376
+ SubscribeState.AWAITING_FINISH -> {
377
+ flow.finish(this)
378
+ }
379
+
380
+ SubscribeState.SUCCESS -> {
381
+ finishPinPadFlowSuccess(context, null)
382
+ }
383
+
384
+ SubscribeState.FAILURE -> {
385
+ finishPinPadFlowFailure(
386
+ context,
387
+ NativeKeyStorageException.Unknown("Subscribe flow failure")
388
+ )
389
+ }
390
+
391
+ else -> {
392
+ throw NativeKeyStorageException.Unknown("Invalid subscribe flow state ${flow.state}")
393
+ }
394
+ }
395
+ }
396
+ }
@@ -0,0 +1,59 @@
1
+ package ch.procivis.one.core.ubiqu
2
+
3
+ import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
4
+ import ch.procivis.one.core.ubiqu.dataformats.CreateIdentityRequest
5
+ import ch.procivis.one.core.ubiqu.dataformats.CreateIdentityResponse
6
+ import ch.procivis.one.core.ubiqu.dataformats.RegisterRSEResponse
7
+ import kotlinx.serialization.json.Json
8
+ import okhttp3.MediaType.Companion.toMediaType
9
+ import okhttp3.OkHttpClient
10
+ import retrofit2.Response
11
+ import retrofit2.Retrofit
12
+ import retrofit2.converter.scalars.ScalarsConverterFactory
13
+ import retrofit2.http.Body
14
+ import retrofit2.http.Header
15
+ import retrofit2.http.POST
16
+ import retrofit2.http.Path
17
+
18
+ object RegistrationManager {
19
+ private lateinit var retrofitService: IdentityApi
20
+
21
+ private val client = OkHttpClient.Builder().build()
22
+
23
+ lateinit var organisationId: String
24
+
25
+ fun build(identityServiceUrl: String, organisationId: String) {
26
+ this.organisationId = organisationId
27
+
28
+ val retrofit = Retrofit.Builder()
29
+ .baseUrl(identityServiceUrl)
30
+ .client(client)
31
+ .addConverterFactory(ScalarsConverterFactory.create())
32
+ .addConverterFactory(Json{
33
+ ignoreUnknownKeys = true
34
+ }.asConverterFactory("application/json".toMediaType()))
35
+ .build()
36
+
37
+ retrofitService = retrofit.create(IdentityApi::class.java)
38
+ }
39
+
40
+ suspend fun createIdentity(accessToken: String, body: CreateIdentityRequest): Response<CreateIdentityResponse> {
41
+ val auth = "Bearer $accessToken"
42
+ return retrofitService.createIdentity(auth, organisationId, body)
43
+ }
44
+
45
+ suspend fun registerRse(accessToken: String, subject: String): Response<RegisterRSEResponse> {
46
+ val auth = "Bearer $accessToken"
47
+ return retrofitService.registerRse(auth, organisationId, subject)
48
+ }
49
+ }
50
+
51
+ interface IdentityApi {
52
+
53
+ @POST("/organisation/{id}/identity/")
54
+ suspend fun createIdentity(@Header("Authorization") authorization: String, @Path("id") organisationId: String, @Body body: CreateIdentityRequest): Response<CreateIdentityResponse>
55
+
56
+ @POST("/organisation/{id}/identity/{subject}/register_rse/")
57
+ suspend fun registerRse(@Header("Authorization") authorization: String, @Path("id") organisationId: String, @Path("subject") subject: String): Response<RegisterRSEResponse>
58
+ }
59
+
@@ -0,0 +1,48 @@
1
+ package ch.procivis.one.core.ubiqu
2
+
3
+ import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
4
+ import kotlinx.serialization.json.Json
5
+ import okhttp3.MediaType.Companion.toMediaType
6
+ import okhttp3.OkHttpClient
7
+ import org.json.JSONObject
8
+ import retrofit2.Response
9
+ import retrofit2.Retrofit
10
+ import retrofit2.converter.scalars.ScalarsConverterFactory
11
+ import retrofit2.http.GET
12
+ import retrofit2.http.Header
13
+
14
+ object TokenManager {
15
+ private lateinit var retrofitService: TokenApi
16
+
17
+ private val client = OkHttpClient.Builder().build()
18
+
19
+ lateinit var apiKey: String
20
+
21
+ fun build(tokenGeneratorUrl: String, apiKey: String) {
22
+ this.apiKey = apiKey
23
+
24
+ val retrofit = Retrofit.Builder()
25
+ .baseUrl(tokenGeneratorUrl)
26
+ .client(client)
27
+ .addConverterFactory(ScalarsConverterFactory.create())
28
+ .addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
29
+ .build()
30
+
31
+ retrofitService = retrofit.create(TokenApi::class.java)
32
+ }
33
+
34
+ suspend fun getAccessToken(): String {
35
+ val apiKey = apiKey
36
+ val auth = "Bearer $apiKey"
37
+ val response = retrofitService.getAccessToken(auth)
38
+
39
+ return JSONObject(response.body()!!).getString("access_token")
40
+ }
41
+
42
+ }
43
+
44
+ interface TokenApi {
45
+
46
+ @GET("/ubiqu/")
47
+ suspend fun getAccessToken(@Header("Authorization") authorization: String): Response<String>
48
+ }