@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
@@ -6,791 +6,156 @@
6
6
  //
7
7
 
8
8
  import Foundation
9
+ import ProcivisOneCore
9
10
 
10
- struct SerializationError: LocalizedError {
11
- let description: String
12
-
13
- init(_ description: String) {
14
- self.description = description
15
- }
16
-
17
- var errorDescription: String? {
18
- description
19
- }
20
- }
21
-
22
- func deserializeKeyRequest(keyRequest: NSDictionary) throws -> KeyRequestBindingDto {
23
- let keyType: String = try safeCast(keyRequest.value(forKey: "keyType"));
24
- let name: String = try safeCast(keyRequest.value(forKey: "name"));
25
- let storageType: String = try safeCast(keyRequest.value(forKey: "storageType"));
26
- let organisationId: String = try safeCast(keyRequest.value(forKey: "organisationId"));
27
-
28
- let keyParamsRaw: NSDictionary = try safeCast(keyRequest.value(forKey: "keyParams"));
29
- var keyParams: [String: String] = [:];
30
- try keyParamsRaw.allKeys.forEach {
31
- let key: String = try safeCast($0);
32
- keyParams[key] = keyParamsRaw.value(forKey: key) as? String;
33
- }
34
-
35
- let storageParamsRaw: NSDictionary = try safeCast(keyRequest.value(forKey: "storageParams"));
36
- var storageParams: [String: String] = [:];
37
- try storageParamsRaw.allKeys.forEach {
38
- let key: String = try safeCast($0);
39
- storageParams[key] = storageParamsRaw.value(forKey: key) as? String;
40
- }
41
-
42
- return KeyRequestBindingDto(organisationId: organisationId, keyType: keyType, keyParams: keyParams, name: name, storageType: storageType, storageParams: storageParams);
43
- }
44
-
45
- func deserializeDidRequest(didRequest: NSDictionary) throws -> DidRequestBindingDto {
46
- let organisationId: String = try safeCast(didRequest.value(forKey: "organisationId"));
47
- let name: String = try safeCast(didRequest.value(forKey: "name"));
48
- let didMethod: String = try safeCast(didRequest.value(forKey: "didMethod"));
49
- let keys = try deserializeDidRequestKeys(didRequestKeys: try safeCast(didRequest.value(forKey: "keys")));
50
-
51
- let paramsRaw: NSDictionary = try safeCast(didRequest.value(forKey: "params"));
52
- var params: [String: String] = [:];
53
- try paramsRaw.allKeys.forEach {
54
- let key: String = try safeCast($0);
55
- params[key] = paramsRaw.value(forKey: key) as? String;
56
- }
57
-
58
- return DidRequestBindingDto(organisationId: organisationId, name: name, didMethod: didMethod, keys: keys, params: params);
59
- }
60
-
61
- func deserializeDidRequestKeys(didRequestKeys: NSDictionary) throws -> DidRequestKeysBindingDto {
62
- let authentication = try deserializeDidRequestKeySet(didRequestKeys: didRequestKeys, keyRole: "authentication");
63
- let assertionMethod = try deserializeDidRequestKeySet(didRequestKeys: didRequestKeys, keyRole: "assertionMethod");
64
- let keyAgreement = try deserializeDidRequestKeySet(didRequestKeys: didRequestKeys, keyRole: "keyAgreement");
65
- let capabilityInvocation = try deserializeDidRequestKeySet(didRequestKeys: didRequestKeys, keyRole: "capabilityInvocation");
66
- let capabilityDelegation = try deserializeDidRequestKeySet(didRequestKeys: didRequestKeys, keyRole: "capabilityDelegation");
67
- return DidRequestKeysBindingDto(authentication: authentication, assertionMethod: assertionMethod, keyAgreement: keyAgreement, capabilityInvocation: capabilityInvocation, capabilityDelegation: capabilityDelegation);
68
- }
69
-
70
- func deserializeDidRequestKeySet(didRequestKeys: NSDictionary, keyRole: String) throws -> [String] {
71
- let roleKeys: NSArray = try safeCast(didRequestKeys.value(forKey: keyRole));
72
- var result: [String] = [];
73
- try roleKeys.forEach { key in
74
- result.append(try safeCast(key));
75
- }
76
- return result;
77
- }
78
-
79
- func deserializeHistorySearch(text: String?, type: String?) throws -> HistorySearchBindingDto? {
80
- if text == nil {
81
- return nil
82
- }
83
-
84
- return HistorySearchBindingDto(
85
- text: text!,
86
- type: try opt(type, deserializeEnum)
87
- )
11
+ private func enumList<T: CaseIterable>(_ entries: NSArray) throws -> [T] {
12
+ var result: [T] = []
13
+ try entries.forEach { entry in
14
+ result.append(try deserializeEnum(try safeCast(entry)))
15
+ }
16
+ return result
88
17
  }
89
18
 
90
- func deserializeIds(_ ids: NSArray) throws -> [String] {
91
- var result: [String] = [];
92
- try ids.forEach { id in
93
- result.append(try safeCast(id));
94
- }
19
+ private func deserializeEnum<T: CaseIterable>(_ input: String) throws -> T {
20
+ if let entry = T.allCases.first(where: { value in
21
+ serializeEnumValue(value: value) == input
22
+ }) {
23
+ return entry
24
+ } else {
25
+ let description = "Invalid enum value for \(T.self): \(input)"
26
+ throw DecodingError.typeMismatch(
27
+ T.self,
28
+ DecodingError.Context(codingPath: [], debugDescription: description)
29
+ )
30
+ }
31
+ }
32
+
33
+ private func opt<F, T>(_ input: F?, _ deserializeFn: @escaping (_ input: F) throws -> T) throws
34
+ -> T?
35
+ {
36
+ if input != nil {
37
+ return try deserializeFn(input!)
38
+ }
39
+ return nil
40
+ }
41
+
42
+ private func safeCast<T>(_ input: Any?) throws -> T {
43
+ if let result = input as? T {
95
44
  return result
96
- }
97
-
98
- func deserializeCacheTypes(types: NSArray?) throws -> [CacheTypeBindingDto]? {
99
- return try opt(types, enumList)
100
- }
101
-
102
- func deserializeBypassCache(bypassCache: NSArray?) throws -> [BypassCacheBindingDto]? {
103
- return try opt(bypassCache, enumList)
104
- }
105
-
106
- func deserializePresentationSubmitCredentialRequest(_ input: NSDictionary) throws -> PresentationSubmitCredentialRequestBindingDto {
107
- let claims: NSArray = try safeCast(input.value(forKey: "submitClaims"));
108
- var submitClaims: [String] = [];
109
- try claims.forEach { claim in
110
- submitClaims.append(try safeCast(claim));
111
- }
112
- return PresentationSubmitCredentialRequestBindingDto(credentialId: try safeCast(input.value(forKey: "credentialId")), submitClaims: submitClaims);
113
- }
114
-
115
- func deserializeCredentialSchemaListQuery(_ query: NSDictionary) throws -> CredentialSchemaListQueryBindingDto {
116
- return CredentialSchemaListQueryBindingDto(
117
- page: try safeCast(query.value(forKey: "page")),
118
- pageSize: try safeCast(query.value(forKey: "pageSize")),
119
- organisationId: try safeCast(query.value(forKey: "organisationId")),
120
- sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
121
- sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
122
- name: query.value(forKey: "name") as? String,
123
- ids: try opt(query.value(forKey: "ids") as? NSArray, deserializeIds),
124
- exact: try opt(query.value(forKey: "exact") as? NSArray, enumList),
125
- include: try opt(query.value(forKey: "include") as? NSArray, enumList)
126
- )
127
- }
128
-
129
- func deserializeCredentialListQuery(_ query: NSDictionary) throws -> CredentialListQueryBindingDto {
130
- return CredentialListQueryBindingDto(
131
- page: try safeCast(query.value(forKey: "page")),
132
- pageSize: try safeCast(query.value(forKey: "pageSize")),
133
- sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
134
- sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
135
- organisationId: try safeCast(query.value(forKey: "organisationId")),
136
- name: query.value(forKey: "name") as? String,
137
- searchText: query.value(forKey: "searchText") as? String,
138
- searchType: try opt(query.value(forKey: "searchType") as? NSArray, enumList),
139
- exact: try opt(query.value(forKey: "exact") as? NSArray, enumList ),
140
- role: try opt(query.value(forKey: "role") as? String, deserializeEnum),
141
- ids: try opt(query.value(forKey: "ids") as? NSArray, deserializeIds),
142
- status: try opt(query.value(forKey: "status") as? NSArray, enumList),
143
- include: try opt(query.value(forKey: "include") as? NSArray, enumList)
144
- )
145
- }
146
-
147
- func deserializeDidListQuery(_ query: NSDictionary) throws -> DidListQueryBindingDto {
148
- return DidListQueryBindingDto(
149
- page: try safeCast(query.value(forKey: "page")),
150
- pageSize: try safeCast(query.value(forKey: "pageSize")),
151
- sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
152
- sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
153
- organisationId: try safeCast(query.value(forKey: "organisationId")),
154
- name: query.value(forKey: "name") as? String,
155
- did: query.value(forKey: "did") as? String,
156
- type: try opt(query.value(forKey: "type") as? String, deserializeEnum),
157
- deactivated: query.value(forKey: "deactivated") as? Bool,
158
- exact: try opt(query.value(forKey: "exact") as? NSArray, { columns in try enumList(columns) } ),
159
- keyAlgorithms: try opt(query.value(forKey: "keyAlgorithms") as? NSArray, deserializeIds),
160
- keyRoles: try opt(query.value(forKey: "keyRoles") as? NSArray, { roles in try enumList(roles) }),
161
- keyStorages: try opt(query.value(forKey: "keyStorages") as? NSArray, deserializeIds),
162
- keyIds: try opt(query.value(forKey: "keyIds") as? NSArray, deserializeIds),
163
- didMethods: try opt(query.value(forKey: "didMethods") as? NSArray, deserializeIds)
164
- )
165
- }
166
-
167
- func deserializeHistoryListQuery(_ query: NSDictionary) throws -> HistoryListQueryBindingDto {
168
- return HistoryListQueryBindingDto(
169
- page: try safeCast(query.value(forKey: "page")),
170
- pageSize: try safeCast(query.value(forKey: "pageSize")),
171
- organisationId: try safeCast(query.value(forKey: "organisationId")),
172
- entityId: query.value(forKey: "entityId") as? String,
173
- entityTypes: try opt(query.value(forKey: "entityTypes") as? NSArray, enumList),
174
- action: try opt(query.value(forKey: "action") as? String, deserializeEnum),
175
- createdDateFrom: query.value(forKey: "createdDateFrom") as? String,
176
- createdDateTo: query.value(forKey: "createdDateTo") as? String,
177
- didId: query.value(forKey: "didId") as? String,
178
- credentialId: query.value(forKey: "credentialId") as? String,
179
- credentialSchemaId: query.value(forKey: "credentialSchemaId") as? String,
180
- proofSchemaId: query.value(forKey: "proofSchemaId") as? String,
181
- search: try deserializeHistorySearch(
182
- text: query.value(forKey: "searchText") as? String,
183
- type: query.value(forKey: "searchType") as? String
184
- )
185
- )
186
- }
187
-
188
- func deserializeProofSchemaListQuery(_ query: NSDictionary) throws -> ListProofSchemasFiltersBindingDto {
189
- return ListProofSchemasFiltersBindingDto(
190
- page: try safeCast(query.value(forKey: "page")),
191
- pageSize: try safeCast(query.value(forKey: "pageSize")),
192
- sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
193
- sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
194
- organisationId: try safeCast(query.value(forKey: "organisationId")),
195
- name: query.value(forKey: "name") as? String,
196
- exact: try opt(query.value(forKey: "exact") as? NSArray, { columns in try enumList(columns) } ),
197
- ids: try opt(query.value(forKey: "ids") as? NSArray, deserializeIds)
198
- )
199
- }
200
-
201
- func deserializeProofListQuery(_ query: NSDictionary) throws -> ProofListQueryBindingDto {
202
- return ProofListQueryBindingDto(
203
- page: try safeCast(query.value(forKey: "page")),
204
- pageSize: try safeCast(query.value(forKey: "pageSize")),
205
- organisationId: try safeCast(query.value(forKey: "organisationId")),
206
- sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
207
- sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
208
- name: query.value(forKey: "name") as? String,
209
- ids: try opt(query.value(forKey: "ids") as? NSArray, deserializeIds),
210
- proofStates: try opt(query.value(forKey: "proofStates") as? NSArray, { columns in try enumList(columns) } ),
211
- proofSchemaIds: query.value(forKey: "proofSchemaIds") as? [String],
212
- exact: try opt(query.value(forKey: "exact") as? NSArray, { columns in try enumList(columns) } )
213
- )
214
- }
215
-
216
- func deserializeImportProofSchemaRequest(_ request: NSDictionary) throws -> ImportProofSchemaRequestBindingsDto {
217
- return ImportProofSchemaRequestBindingsDto(
218
- schema: try deserializeImportProofSchema(try safeCast(request.value(forKey: "schema"))),
219
- organisationId: try safeCast(request.value(forKey: "organisationId"))
220
- )
221
- }
222
-
223
- func deserializeImportProofSchema(_ schema: NSDictionary) throws -> ImportProofSchemaBindingDto {
224
- let proofInputSchemas: NSArray = try safeCast(schema.value(forKey: "proofInputSchemas"));
225
-
226
- return ImportProofSchemaBindingDto(
227
- id: try safeCast(schema.value(forKey: "id")),
228
- createdDate: try safeCast(schema.value(forKey: "createdDate")),
229
- lastModified: try safeCast(schema.value(forKey: "lastModified")),
230
- name: try safeCast(schema.value(forKey: "name")),
231
- organisationId: try safeCast(schema.value(forKey: "organisationId")),
232
- expireDuration: try safeCast(schema.value(forKey: "expireDuration")),
233
- importedSourceUrl: try safeCast(schema.value(forKey: "importedSourceUrl")),
234
- proofInputSchemas: try proofInputSchemas.map { try deserializeImportProofSchemaInputSchema(try safeCast($0)) }
235
- )
236
- }
237
-
238
- func deserializeCreateProofSchemaRequest(_ request: NSDictionary) throws -> CreateProofSchemaRequestDto {
239
- let proofInputSchemas: NSArray = try safeCast(request.value(forKey: "proofInputSchemas"));
240
-
241
- return CreateProofSchemaRequestDto(
242
- name: try safeCast(request.value(forKey: "name")),
243
- organisationId: try safeCast(request.value(forKey: "organisationId")),
244
- expireDuration: try safeCast(request.value(forKey: "expireDuration")),
245
- proofInputSchemas: try proofInputSchemas.map { try deserializeProofInputSchemaRequest(try safeCast($0)) }
246
- )
247
- }
248
-
249
- func deserializeProofInputSchemaRequest(_ request: NSDictionary) throws -> ProofInputSchemaRequestDto {
250
- let claimSchemas: NSArray = try safeCast(request.value(forKey: "claimSchemas"));
251
-
252
- return ProofInputSchemaRequestDto(
253
- credentialSchemaId: try safeCast(request.value(forKey: "credentialSchemaId")),
254
- validityConstraint: try safeCast(request.value(forKey: "validityConstraint")),
255
- claimSchemas: try claimSchemas.map { try deserializeProofClaimSchemaRequest(try safeCast($0)) }
256
- )
257
- }
258
-
259
- func deserializeImportProofSchemaInputSchema(_ inputSchema: NSDictionary) throws -> ImportProofSchemaInputSchemaBindingDto {
260
- let claimSchemas: NSArray = try safeCast(inputSchema.value(forKey: "claimSchemas"));
261
-
262
- return ImportProofSchemaInputSchemaBindingDto(
263
- claimSchemas: try claimSchemas.map { try deserializeImportProofSchemaClaimSchema(try safeCast($0)) },
264
- credentialSchema: try deserializeImportProofSchemaCredentialSchema(try safeCast(inputSchema.value(forKey: "credentialSchema"))),
265
- validityConstraint: inputSchema.value(forKey: "validityConstraint") as? Int64
266
- )
267
- }
268
-
269
- func deserializeProofClaimSchemaRequest(_ request: NSDictionary) throws -> CreateProofSchemaClaimRequestDto {
270
- return CreateProofSchemaClaimRequestDto(
271
- id: try safeCast(request.value(forKey: "id")),
272
- required: try safeCast(request.value(forKey: "required"))
273
- )
274
- }
275
-
276
- func deserializeImportProofSchemaClaimSchema(_ request: NSDictionary) throws -> ImportProofSchemaClaimSchemaBindingDto {
277
- let claims = request.value(forKey: "claims") as? NSArray;
278
-
279
- return ImportProofSchemaClaimSchemaBindingDto(
280
- id: try safeCast(request.value(forKey: "id")),
281
- requested: try safeCast(request.value(forKey: "requested")),
282
- required: try safeCast(request.value(forKey: "required")),
283
- key: try safeCast(request.value(forKey: "key")),
284
- dataType: try safeCast(request.value(forKey: "dataType")),
285
- claims: try claims?.map { try deserializeImportProofSchemaClaimSchema(try safeCast($0)) },
286
- array: try safeCast(request.value(forKey: "array"))
287
- )
288
- }
289
-
290
- func deserializeImportProofSchemaCredentialSchema(_ request: NSDictionary) throws -> ImportProofSchemaCredentialSchemaBindingDto {
291
- return ImportProofSchemaCredentialSchemaBindingDto(
292
- id: try safeCast(request.value(forKey: "id")),
293
- createdDate: try safeCast(request.value(forKey: "createdDate")),
294
- lastModified: try safeCast(request.value(forKey: "lastModified")),
295
- name: try safeCast(request.value(forKey: "name")),
296
- format: try safeCast(request.value(forKey: "format")),
297
- revocationMethod: try safeCast(request.value(forKey: "revocationMethod")),
298
- walletStorageType: try opt(request.value(forKey: "walletStorageType") as? String, deserializeEnum),
299
- schemaId: try safeCast(request.value(forKey: "schemaId")),
300
- importedSourceUrl: try safeCast(request.value(forKey: "importedSourceUrl")),
301
- schemaType: deserializeCredentialSchemaTypeBindingEnum(try safeCast(request.value(forKey: "schemaType"))),
302
- layoutType: try opt(request.value(forKey: "layoutType") as? String, deserializeEnum),
303
- layoutProperties: try opt((request.value(forKey: "layoutProperties") as? NSDictionary), deserializeCredentialSchemaRequestLayoutProperties)
304
- )
305
- }
306
-
307
- func deserializeImportCredentialSchemaRequest(_ request: NSDictionary) throws -> ImportCredentialSchemaRequestBindingDto {
308
- return ImportCredentialSchemaRequestBindingDto(
309
- organisationId: try safeCast(request.value(forKey: "organisationId")),
310
- schema: try deserializeImportCredentialSchemaRequestSchema(try safeCast(request.value(forKey: "schema")))
311
- )
312
- }
313
-
314
- func deserializeImportCredentialSchemaRequestSchema(_ request: NSDictionary) throws -> ImportCredentialSchemaRequestSchemaBindingDto {
315
- let claims: NSArray = try safeCast(request.value(forKey: "claims"));
316
-
317
- return ImportCredentialSchemaRequestSchemaBindingDto(
318
- id: try safeCast(request.value(forKey: "id")),
319
- createdDate: try safeCast(request.value(forKey: "createdDate")),
320
- lastModified: try safeCast(request.value(forKey: "lastModified")),
321
- name: try safeCast(request.value(forKey: "name")),
322
- format: try safeCast(request.value(forKey: "format")),
323
- revocationMethod: try safeCast(request.value(forKey: "revocationMethod")),
324
- organisationId: try safeCast(request.value(forKey: "organisationId")),
325
- claims: try claims.map { try deserializeImportCredentialSchemaRequestClaim(try safeCast($0)) },
326
- walletStorageType: try opt(request.value(forKey: "walletStorageType") as? String, deserializeEnum),
327
- schemaId: try safeCast(request.value(forKey: "schemaId")),
328
- importedSourceUrl: try safeCast(request.value(forKey: "importedSourceUrl")),
329
- schemaType: deserializeCredentialSchemaTypeBindingEnum(try safeCast(request.value(forKey: "schemaType"))),
330
- layoutType: try opt(request.value(forKey: "layoutType") as? String, deserializeEnum),
331
- layoutProperties: try opt((request.value(forKey: "layoutProperties") as? NSDictionary), deserializeImportCredentialSchemaRequestLayoutProperties),
332
- allowSuspension: request.value(forKey: "allowSuspension") as? Bool
333
- )
334
- }
335
-
336
- func deserializeImportCredentialSchemaRequestClaim(_ request: NSDictionary) throws -> ImportCredentialSchemaClaimSchemaBindingDto {
337
- let claims = request.value(forKey: "claims") as? NSArray;
338
-
339
- return ImportCredentialSchemaClaimSchemaBindingDto(
340
- id: try safeCast(request.value(forKey: "id")),
341
- createdDate: try safeCast(request.value(forKey: "createdDate")),
342
- lastModified: try safeCast(request.value(forKey: "lastModified")),
343
- required: try safeCast(request.value(forKey: "required")),
344
- key: try safeCast(request.value(forKey: "key")),
345
- datatype: try safeCast(request.value(forKey: "datatype")),
346
- array: request.value(forKey: "array") as? Bool,
347
- claims: try claims?.map { try deserializeImportCredentialSchemaRequestClaim(try safeCast($0)) }
348
- )
349
- }
350
-
351
- func deserializeImportCredentialSchemaRequestLayoutProperties(_ request: NSDictionary) throws -> ImportCredentialSchemaLayoutPropertiesBindingDto {
352
- return ImportCredentialSchemaLayoutPropertiesBindingDto(
353
- background: try opt(request.value(forKey: "background") as? NSDictionary, deserializeImportCredentialSchemaBackgroundProperties),
354
- logo: try opt(request.value(forKey: "logo") as? NSDictionary, deserializeImportCredentialSchemaLogoProperties),
355
- primaryAttribute: request.value(forKey: "primaryAttribute") as? String,
356
- secondaryAttribute: request.value(forKey: "secondaryAttribute") as? String,
357
- pictureAttribute: request.value(forKey: "pictureAttribute") as? String,
358
- code: try opt(request.value(forKey: "code") as? NSDictionary, deserializeImportCredentialSchemaCodeProperties)
359
- )
360
- }
361
-
362
- func deserializeCredentialSchemaRequestLayoutProperties(_ request: NSDictionary) throws -> CredentialSchemaLayoutPropertiesBindingDto {
363
- return CredentialSchemaLayoutPropertiesBindingDto(
364
- background: try opt(request.value(forKey: "background") as? NSDictionary, deserializeImportCredentialSchemaBackgroundProperties),
365
- logo: try opt(request.value(forKey: "logo") as? NSDictionary, deserializeImportCredentialSchemaLogoProperties),
366
- primaryAttribute: request.value(forKey: "primaryAttribute") as? String,
367
- secondaryAttribute: request.value(forKey: "secondaryAttribute") as? String,
368
- pictureAttribute: request.value(forKey: "pictureAttribute") as? String,
369
- code: try opt(request.value(forKey: "code") as? NSDictionary, deserializeImportCredentialSchemaCodeProperties)
370
- )
371
- }
372
-
373
- func deserializeImportCredentialSchemaBackgroundProperties(_ request: NSDictionary) throws -> CredentialSchemaBackgroundPropertiesBindingDto {
374
- return CredentialSchemaBackgroundPropertiesBindingDto(
375
- color: request.value(forKey: "color") as? String,
376
- image: request.value(forKey: "image") as? String
377
- )
378
- }
379
-
380
- func deserializeImportCredentialSchemaLogoProperties(_ request: NSDictionary) throws -> CredentialSchemaLogoPropertiesBindingDto {
381
- return CredentialSchemaLogoPropertiesBindingDto(
382
- fontColor: request.value(forKey: "fontColor") as? String,
383
- backgroundColor: request.value(forKey: "backgroundColor") as? String,
384
- image: request.value(forKey: "image") as? String
385
- )
386
- }
387
-
388
- func deserializeImportCredentialSchemaCodeProperties(_ request: NSDictionary) throws -> CredentialSchemaCodePropertiesBindingDto {
389
- return CredentialSchemaCodePropertiesBindingDto(
390
- attribute: try safeCast(request.value(forKey: "attribute")),
391
- type: try deserializeEnum(try safeCast(request.value(forKey: "type")))
392
- )
393
- }
394
-
395
- func deserializeCreateProofRequest(_ request: NSDictionary) throws -> CreateProofRequestBindingDto {
396
- return CreateProofRequestBindingDto(
397
- proofSchemaId: try safeCast(request.value(forKey: "proofSchemaId")),
398
- verifierDidId: try safeCast(request.value(forKey: "verifierDidId")),
399
- exchange: try safeCast(request.value(forKey: "exchange")),
400
- redirectUri: request.value(forKey: "redirectUri") as? String,
401
- verifierKey: request.value(forKey: "verifierKey") as? String,
402
- scanToVerify: try opt((request.value(forKey: "scanToVerify") as? NSDictionary), deserializeScanToVerifyRequest),
403
- isoMdlEngagement: request.value(forKey: "isoMdlEngagement") as? String,
404
- transport: request.value(forKey: "transport") as? [String]
405
- )
406
- }
407
-
408
- func deserializeShareProofRequest(_ request: NSDictionary) throws -> ShareProofRequestBindingDto {
409
- return ShareProofRequestBindingDto(
410
- params: try opt((request.value(forKey: "params") as? NSDictionary), deserializeShareProofRequestParams)
411
- )
412
- }
413
-
414
- func deserializeShareProofRequestParams(_ request: NSDictionary) throws -> ShareProofRequestParamsBindingDto {
415
- return ShareProofRequestParamsBindingDto(
416
- clientIdSchema: try opt(request.value(forKey: "clientIdSchema") as? String, deserializeEnum)
417
- )
418
- }
419
-
420
-
421
- func deserializeKeyCheckCertificateRequest(_ request: NSDictionary) throws -> KeyCheckCertificateRequestBindingDto {
422
- return KeyCheckCertificateRequestBindingDto(
423
- certificate: (request.value(forKey: "certificate") as? String)!
424
- )
425
- }
426
-
427
- func deserializeScanToVerifyRequest(_ request: NSDictionary) throws -> ScanToVerifyRequestBindingDto {
428
- return ScanToVerifyRequestBindingDto(
429
- credential: try safeCast(request.value(forKey: "credential")),
430
- barcode: try safeCast(request.value(forKey: "barcode")),
431
- barcodeType: try deserializeEnum(try safeCast(request.value(forKey: "barcodeType")))
432
- )
433
- }
434
-
435
- func deserializeCreateTrustAnchorRequest(_ request: NSDictionary) throws -> CreateTrustAnchorRequestBindingDto {
436
- return CreateTrustAnchorRequestBindingDto(
437
- name: try safeCast(request.value(forKey: "name")),
438
- type: try safeCast(request.value(forKey: "type")),
439
- isPublisher: request.value(forKey: "isPublisher") as? Bool,
440
- publisherReference: request.value(forKey: "publisherReference") as? String
441
- )
442
- }
443
-
444
- func deserializeTrustAnchorListQuery(_ query: NSDictionary) throws -> ListTrustAnchorsFiltersBindings {
445
- return ListTrustAnchorsFiltersBindings(
446
- page: try safeCast(query.value(forKey: "page")),
447
- pageSize: try safeCast(query.value(forKey: "pageSize")),
448
- sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
449
- sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
450
- name: query.value(forKey: "name") as? String,
451
- isPublisher: query.value(forKey: "isPublisher") as? Bool,
452
- type: query.value(forKey: "type") as? String,
453
- exact: try opt(query.value(forKey: "exact") as? NSArray, { columns in try enumList(columns) } )
454
- )
455
- }
456
-
457
- func deserializeCreateTrustEntityRequest(_ request: NSDictionary) throws -> CreateTrustEntityRequestBindingDto {
458
- return CreateTrustEntityRequestBindingDto(
459
- name: try safeCast(request.value(forKey: "name")),
460
- logo: request.value(forKey: "logo") as? String,
461
- website: request.value(forKey: "website") as? String,
462
- termsUrl: request.value(forKey: "termsUrl") as? String,
463
- privacyUrl: request.value(forKey: "privacyUrl") as? String,
464
- role: try deserializeEnum(try safeCast(request.value(forKey: "role"))),
465
- trustAnchorId: try safeCast(request.value(forKey: "trustAnchorId")),
466
- didId: try safeCast(request.value(forKey: "didId"))
467
- )
468
- }
469
-
470
- func deserializeCreateRemoteTrustEntityRequest(_ request: NSDictionary) throws -> CreateRemoteTrustEntityRequestBindingDto {
471
- return CreateRemoteTrustEntityRequestBindingDto(
472
- didId: try safeCast(request.value(forKey: "didId")),
473
- trustAnchorId: request.value(forKey: "trustAnchorId") as? String,
474
- name: try safeCast(request.value(forKey: "name")),
475
- logo: request.value(forKey: "logo") as? String,
476
- termsUrl: request.value(forKey: "termsUrl") as? String,
477
- privacyUrl: request.value(forKey: "privacyUrl") as? String,
478
- website: request.value(forKey: "website") as? String,
479
- role: try deserializeEnum(try safeCast(request.value(forKey: "role")))
480
- )
481
- }
482
-
483
- func deserializeUpdateRemoteTrustEntityRequest(_ request: NSDictionary) throws -> UpdateRemoteTrustEntityFromDidRequestBindingDto {
484
- return UpdateRemoteTrustEntityFromDidRequestBindingDto(
485
- didId: try safeCast(request.value(forKey: "didId")),
486
- action: try opt(request.value(forKey: "action") as? String, deserializeEnum),
487
- name: try safeCast(request.value(forKey: "name")),
488
- logo: try optionalString(request, key: "logo"),
489
- website: try optionalString(request, key: "website"),
490
- termsUrl: try optionalString(request, key: "termsUrl"),
491
- privacyUrl: try optionalString(request, key: "privacyUrl"),
492
- role: try opt(request.value(forKey: "role") as? String, deserializeEnum)
493
- )
494
- }
495
-
496
- func deserializeTrustEntityListQuery(_ query: NSDictionary) throws -> ListTrustEntitiesFiltersBindings {
497
- return ListTrustEntitiesFiltersBindings(
498
- page: try safeCast(query.value(forKey: "page")),
499
- pageSize: try safeCast(query.value(forKey: "pageSize")),
500
- sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
501
- sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
502
- name: query.value(forKey: "name") as? String,
503
- role: try opt(query.value(forKey: "role") as? String, deserializeEnum),
504
- trustAnchor: query.value(forKey: "trustAnchor") as? String,
505
- didId: query.value(forKey: "didId") as? String,
506
- organisationId: query.value(forKey: "organisationId") as? String,
507
- exact: try opt(query.value(forKey: "exact") as? NSArray, { columns in try enumList(columns) } )
45
+ } else {
46
+ let description = "Invalid input for type \(T.self): \(String(describing: input))"
47
+ throw DecodingError.typeMismatch(
48
+ T.self,
49
+ DecodingError.Context(codingPath: [], debugDescription: description)
508
50
  )
51
+ }
509
52
  }
510
53
 
511
- extension KeyRoleBindingEnum: CaseIterable {
512
- public static var allCases: [KeyRoleBindingEnum] {
513
- return [.authentication, .assertionMethod, .keyAgreement, .capabilityInvocation, .capabilityDelegation]
514
- }
515
- }
516
-
517
- extension DidTypeBindingEnum: CaseIterable {
518
- public static var allCases: [DidTypeBindingEnum] {
519
- return [.local, .remote]
520
- }
521
- }
522
-
523
- extension SortDirection: CaseIterable {
524
- public static var allCases: [SortDirection] {
525
- return [.ascending, .descending]
526
- }
527
- }
528
-
529
- extension SortableDidColumnBindingEnum: CaseIterable {
530
- public static var allCases: [SortableDidColumnBindingEnum] {
531
- return [.name, .createdDate, .method, .type, .did, .deactivated]
532
- }
533
- }
534
-
535
- extension SortableCredentialColumnBindingEnum: CaseIterable {
536
- public static var allCases: [SortableCredentialColumnBindingEnum] {
537
- return [.createdDate, .schemaName, .issuerDid, .state]
538
- }
539
- }
540
-
541
- extension CredentialListIncludeEntityTypeBindingEnum: CaseIterable {
542
- public static var allCases: [CredentialListIncludeEntityTypeBindingEnum] {
543
- return [.layoutProperties, .credential]
544
- }
545
- }
546
-
547
- extension CredentialStateBindingEnum: CaseIterable {
548
- public static var allCases: [CredentialStateBindingEnum] {
549
- return [.created, .pending, .offered, .accepted, .rejected, .revoked, .error, .suspended]
550
- }
551
- }
552
-
553
- extension ExactDidFilterColumnBindingEnum: CaseIterable {
554
- public static var allCases: [ExactDidFilterColumnBindingEnum] {
555
- return [.name, .did]
556
- }
557
- }
558
-
559
- extension CredentialListQueryExactColumnBindingEnum: CaseIterable {
560
- public static var allCases: [CredentialListQueryExactColumnBindingEnum] {
561
- return [.name]
562
- }
563
- }
564
-
565
- extension HistoryEntityTypeBindingEnum: CaseIterable {
566
- public static var allCases: [HistoryEntityTypeBindingEnum] {
567
- return [.key, .did, .credentialSchema, .credential, .proofSchema, .proof, .organisation, .backup]
568
- }
569
- }
570
-
571
- extension HistorySearchEnumBindingEnum: CaseIterable {
572
- public static var allCases: [HistorySearchEnumBindingEnum] {
573
- return [.claimName, .claimValue, .credentialSchemaName, .issuerDid, .issuerName, .verifierDid, .verifierName, .proofSchemaName]
574
- }
575
- }
576
-
577
- extension HistoryActionBindingEnum: CaseIterable {
578
- public static var allCases: [HistoryActionBindingEnum] {
579
- return [.accepted, .created, .deactivated, .deleted, .errored, .issued, .offered, .rejected, .requested, .revoked, .pending, .suspended, .restored, .shared, .imported, .claimsRemoved]
580
- }
581
- }
582
-
583
- extension CredentialRoleBindingDto: CaseIterable {
584
- public static var allCases: [CredentialRoleBindingDto] {
585
- return [.holder, .issuer, .verifier]
586
- }
587
- }
588
-
589
- extension SortableProofSchemaColumnBinding: CaseIterable {
590
- public static var allCases: [SortableProofSchemaColumnBinding] {
591
- return [.name, .createdDate]
592
- }
593
- }
594
-
595
- extension ProofSchemaListQueryExactColumnBinding: CaseIterable {
596
- public static var allCases: [ProofSchemaListQueryExactColumnBinding] {
597
- return [.name]
598
- }
599
- }
600
-
601
- extension SortableCredentialSchemaColumnBindingEnum: CaseIterable {
602
- public static var allCases: [SortableCredentialSchemaColumnBindingEnum] {
603
- return [.name, .format, .createdDate]
604
- }
605
- }
606
-
607
- extension CredentialSchemaListQueryExactColumnBindingEnum: CaseIterable {
608
- public static var allCases: [CredentialSchemaListQueryExactColumnBindingEnum] {
609
- return [.name]
610
- }
611
- }
612
-
613
- extension CredentialSchemaListIncludeEntityType: CaseIterable {
614
- public static var allCases: [CredentialSchemaListIncludeEntityType] {
615
- return [.layoutProperties]
616
- }
617
- }
618
-
619
- extension SortableProofListColumnBinding: CaseIterable {
620
- public static var allCases: [SortableProofListColumnBinding] {
621
- return [.createdDate, .schemaName, .state, .verifierDid]
622
- }
623
- }
624
-
625
- extension ProofListQueryExactColumnBindingEnum: CaseIterable {
626
- public static var allCases: [ProofListQueryExactColumnBindingEnum] {
627
- return [.name]
628
- }
629
- }
630
-
631
- extension CredentialSchemaCodeTypeBindingDto: CaseIterable {
632
- public static var allCases: [CredentialSchemaCodeTypeBindingDto] {
633
- return [.barcode, .mrz, .qrCode]
634
- }
635
- }
636
-
637
- extension LayoutTypeBindingEnum: CaseIterable {
638
- public static var allCases: [LayoutTypeBindingEnum] {
639
- return [.card, .document, .singleAttribute]
640
- }
54
+ func deserialize<T: Decodable>(_ value: Any) throws -> T {
55
+ let decoder = RNDecoder()
56
+ decoder.userInfo[customDecoderKey] = deserializeSpecific as CustomDecoder
57
+ return try decoder.decode(value)
641
58
  }
642
59
 
643
- extension WalletStorageTypeBindingEnum: CaseIterable {
644
- public static var allCases: [WalletStorageTypeBindingEnum] {
645
- return [.hardware, .software]
646
- }
647
- }
648
-
649
- extension ProofStateBindingEnum: CaseIterable {
650
- public static var allCases: [ProofStateBindingEnum] {
651
- return [
652
- .created,
653
- .pending,
654
- .requested,
655
- .accepted,
656
- .rejected,
657
- .error
658
- ]
659
- }
660
- }
661
-
662
- extension ShareProofRequestClientIdSchemaTypeBindingDto: CaseIterable {
663
- public static var allCases: [ShareProofRequestClientIdSchemaTypeBindingDto] {
664
- return [.redirectUri, .verifierAttestation]
665
- }
666
- }
667
-
668
- extension ScanToVerifyBarcodeTypeBindingEnum: CaseIterable {
669
- public static var allCases: [ScanToVerifyBarcodeTypeBindingEnum] {
670
- return [.mrz, .pdf417]
671
- }
672
- }
673
-
674
- extension SortableTrustAnchorColumnBindings: CaseIterable {
675
- public static var allCases: [SortableTrustAnchorColumnBindings] {
676
- return [.name, .createdDate, .type]
677
- }
678
- }
679
-
680
- extension ExactTrustAnchorFilterColumnBindings: CaseIterable {
681
- public static var allCases: [ExactTrustAnchorFilterColumnBindings] {
682
- return [.name, .type]
683
- }
684
- }
685
-
686
- extension SearchTypeBindingEnum: CaseIterable {
687
- public static var allCases: [SearchTypeBindingEnum] {
688
- return [.claimName, .claimValue, .credentialSchemaName]
689
- }
690
- }
691
-
692
- extension TrustEntityRoleBindingEnum: CaseIterable {
693
- public static var allCases: [TrustEntityRoleBindingEnum] {
694
- return [.issuer, .verifier, .both]
695
- }
696
- }
697
-
698
- extension TrustEntityStateBindingEnum: CaseIterable {
699
- public static var allCases: [TrustEntityStateBindingEnum] {
700
- return [.active, .removed, .withdrawn, .removedAndWithdrawn]
701
- }
702
- }
703
-
704
- extension SortableTrustEntityColumnBindings: CaseIterable {
705
- public static var allCases: [SortableTrustEntityColumnBindings] {
706
- return [.name, .role]
707
- }
708
- }
709
-
710
- extension ExactTrustEntityFilterColumnBindings: CaseIterable {
711
- public static var allCases: [ExactTrustEntityFilterColumnBindings] {
712
- return [.name]
713
- }
714
- }
715
-
716
- extension TrustEntityUpdateActionBindingEnum: CaseIterable {
717
- public static var allCases: [TrustEntityUpdateActionBindingEnum] {
718
- return [.activate, .remove, .withdraw]
719
- }
720
- }
721
-
722
- extension CacheTypeBindingDto: CaseIterable {
723
- public static var allCases: [CacheTypeBindingDto] {
724
- return [.didDocument, .jsonLdContext, .jsonSchema, .statusListCredential, .trustList, .vctMetadata]
725
- }
726
- }
727
-
728
- extension BypassCacheBindingDto: CaseIterable {
729
- public static var allCases: [BypassCacheBindingDto] {
730
- return [.didDocument, .statusListCredential]
731
- }
732
- }
733
-
734
- private func deserializeEnum<T: CaseIterable>(_ input: String) throws -> T {
735
- if let entry = T.allCases.first(where: { value in
736
- serializeEnumValue(value: value) == input
737
- }) {
738
- return entry;
739
- } else {
740
- throw SerializationError("Invalid enum value for \(T.self): " + input);
741
- }
742
- }
743
-
744
- private func opt<F, T>(_ input: F?, _ deserialize: @escaping (_ input: F) throws -> T) throws -> T? {
745
- if (input != nil) {
746
- return try deserialize(input!);
747
- }
60
+ func deserializeOpt<T: Decodable>(_ value: Any?) throws -> T? {
61
+ if value == nil {
748
62
  return nil
749
- }
750
-
751
- private func optionalString(_ input: NSDictionary, key: String) throws -> OptionalString? {
752
- var isThere: Bool = false;
753
- input.keyEnumerator().forEach { k in
754
- if (k as! String == key) {
755
- isThere = true;
756
- }
757
- }
758
- if (!isThere) {
759
- return nil;
760
- }
761
- let value = input[key] as? String;
762
- if value == nil {
763
- return OptionalString.none;
764
- }
765
- return OptionalString.some(value: value!);
766
- }
767
-
768
- func safeCast<T>(_ input: Any?) throws -> T {
769
- if let result = input as? T {
770
- return result
771
- } else {
772
- throw SerializationError("Invalid input for type \(T.self): " + String(describing: input));
773
- }
774
- }
775
-
776
- private func enumList<T: CaseIterable>(_ entries: NSArray) throws -> [T] {
777
- var result: [T] = [];
778
- try entries.forEach { entry in
779
- result.append(try deserializeEnum(try safeCast(entry)));
780
- }
781
- return result
782
- }
63
+ }
64
+
65
+ return try deserialize(value!)
66
+ }
67
+
68
+ private func deserializeSpecific(_ value: Any, _ type: Any.Type, _ codingPath: [CodingKey]) throws
69
+ -> Any?
70
+ {
71
+ if type == CredentialSchemaTypeBindingEnum.self {
72
+ guard let data = value as? String else {
73
+ let description = "Expected to decode \(type) but found '\(value)' instead."
74
+ throw DecodingError.typeMismatch(
75
+ type,
76
+ DecodingError.Context(codingPath: codingPath, debugDescription: description)
77
+ )
78
+ }
79
+ return deserializeCredentialSchemaTypeBindingEnum(data)
80
+ }
81
+
82
+ if type == HistoryListQueryBindingDto.self {
83
+ guard let data = value as? NSDictionary else {
84
+ let description = "Expected to decode \(type) but found '\(value)' instead."
85
+ throw DecodingError.typeMismatch(
86
+ type,
87
+ DecodingError.Context(codingPath: codingPath, debugDescription: description)
88
+ )
89
+ }
90
+ return try deserializeHistoryListQuery(data)
91
+ }
92
+
93
+ if type == OptionalString.self {
94
+ if value is NSNull {
95
+ return OptionalString.none
96
+ }
97
+
98
+ guard let data = value as? String else {
99
+ let description = "Expected to decode \(type) but found '\(value)' instead."
100
+ throw DecodingError.typeMismatch(
101
+ type,
102
+ DecodingError.Context(codingPath: codingPath, debugDescription: description)
103
+ )
104
+ }
105
+ return OptionalString.some(value: data)
106
+ }
107
+
108
+ return nil
109
+ }
110
+
111
+ private func deserializeCredentialSchemaTypeBindingEnum(_ credentialSchemaType: String)
112
+ -> CredentialSchemaTypeBindingEnum
113
+ {
114
+ switch credentialSchemaType {
115
+ case "PROCIVIS_ONE_SCHEMA2024":
116
+ return .procivisOneSchema2024
117
+ case "FALLBACK_SCHEMA2024":
118
+ return .fallbackSchema2024
119
+ case "MDOC":
120
+ return .mdoc
121
+ case "SD_JWT_VC":
122
+ return .sdJwtVc
123
+ case let other:
124
+ return .other(value: other)
125
+ }
126
+ }
127
+
128
+ private func deserializeHistoryListQuery(_ query: NSDictionary) throws -> HistoryListQueryBindingDto
129
+ {
130
+ return HistoryListQueryBindingDto(
131
+ page: try safeCast(query.value(forKey: "page")),
132
+ pageSize: try safeCast(query.value(forKey: "pageSize")),
133
+ organisationId: try safeCast(query.value(forKey: "organisationId")),
134
+ entityId: query.value(forKey: "entityId") as? String,
135
+ entityTypes: try opt(query.value(forKey: "entityTypes") as? NSArray, enumList),
136
+ action: try opt(query.value(forKey: "action") as? String, deserializeEnum),
137
+ createdDateFrom: query.value(forKey: "createdDateFrom") as? String,
138
+ createdDateTo: query.value(forKey: "createdDateTo") as? String,
139
+ identifierId: query.value(forKey: "identifierId") as? String,
140
+ credentialId: query.value(forKey: "credentialId") as? String,
141
+ credentialSchemaId: query.value(forKey: "credentialSchemaId") as? String,
142
+ proofSchemaId: query.value(forKey: "proofSchemaId") as? String,
143
+ search: try deserializeHistorySearch(
144
+ text: query.value(forKey: "searchText") as? String,
145
+ type: query.value(forKey: "searchType") as? String
146
+ )
147
+ )
148
+ }
149
+
150
+ private func deserializeHistorySearch(text: String?, type: String?) throws
151
+ -> HistorySearchBindingDto?
152
+ {
153
+ if text == nil {
154
+ return nil
155
+ }
783
156
 
784
- private func deserializeCredentialSchemaTypeBindingEnum(_ credentialSchemaType: String) -> CredentialSchemaTypeBindingEnum {
785
- switch (credentialSchemaType) {
786
- case "PROCIVIS_ONE_SCHEMA2024":
787
- return .procivisOneSchema2024
788
- case "FALLBACK_SCHEMA2024":
789
- return .fallbackSchema2024
790
- case "MDOC":
791
- return .mdoc
792
- case let other:
793
- return .other(value: other)
794
- }
795
-
157
+ return HistorySearchBindingDto(
158
+ text: text!,
159
+ type: try opt(type, deserializeEnum)
160
+ )
796
161
  }