@procivis/react-native-one-core 1.60807.0 → 1.73295.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,15 +16,15 @@ func serializeAny<T: Encodable>(_ value: T) throws -> Any {
16
16
 
17
17
  // Enum values serialization
18
18
  func serializeEnumValue<T>(value: T) -> String {
19
- return String(describing: value).snakeCased()
19
+ return String(describing: value).snakeCased()
20
20
  }
21
21
 
22
22
  private let snakeCaseRegex = try! NSRegularExpression(pattern: "([a-z0-9])([A-Z])", options: [])
23
23
  extension String {
24
- func snakeCased() -> String {
25
- let range = NSRange(location: 0, length: count)
26
- return snakeCaseRegex.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: "$1_$2").uppercased()
27
- }
24
+ func snakeCased() -> String {
25
+ let range = NSRange(location: 0, length: count)
26
+ return snakeCaseRegex.stringByReplacingMatches(in: self, options: [], range: range, withTemplate: "$1_$2").uppercased()
27
+ }
28
28
  }
29
29
 
30
30
  private func serializeSpecific(_ value: Encodable) throws -> Any? {
@@ -39,7 +39,11 @@ private func serializeSpecific(_ value: Encodable) throws -> Any? {
39
39
  return try serialize(proofRequestClaimValue: data)
40
40
  case let data as HandleInvitationResponseBindingEnum:
41
41
  return try serialize(invitationResponse: data)
42
-
42
+ case let data as CredentialQueryResponseBindingDto:
43
+ return try serialize(credentialQuery: data)
44
+ case let data as PresentationDefinitionV2ClaimValueBindingDto:
45
+ return try serialize(presentationDefinitionV2ClaimValue: data)
46
+
43
47
  default:
44
48
  return nil
45
49
  }
@@ -97,17 +101,21 @@ private func serialize(proofRequestClaimValue: ProofRequestClaimValueBindingDto)
97
101
 
98
102
  private func serialize(invitationResponse: HandleInvitationResponseBindingEnum) throws -> NSDictionary {
99
103
  switch (invitationResponse) {
100
- case let .credentialIssuance(interactionId, credentialIds, txCode, credentialConfigurationsSupported):
104
+ case let .credentialIssuance(interactionId, keyStorageSecurityLevels, keyAlgorithms, txCode):
101
105
  var result: [String: Any] = [
102
- "interactionId": interactionId,
103
- "credentialIds": credentialIds,
104
- "credentialConfigurationsSupported": try serializeAny(credentialConfigurationsSupported)
106
+ "interactionId": interactionId
105
107
  ];
108
+ if let keyStorageSecurityLevels = keyStorageSecurityLevels {
109
+ result["keyStorageSecurityLevels"] = keyStorageSecurityLevels.map { serializeEnumValue(value: $0) }
110
+ }
111
+ if let keyAlgorithms = keyAlgorithms {
112
+ result["keyAlgorithms"] = try serializeAny(keyAlgorithms)
113
+ }
106
114
  if let txCode = txCode {
107
115
  result["txCode"] = try serializeAny(txCode)
108
116
  }
109
117
  return result as NSDictionary;
110
-
118
+
111
119
  case let .proofRequest(interactionId, proofId):
112
120
  return [
113
121
  "interactionId": interactionId,
@@ -121,3 +129,29 @@ private func serialize(invitationResponse: HandleInvitationResponseBindingEnum)
121
129
  ];
122
130
  }
123
131
  }
132
+
133
+ private func serialize(credentialQuery: CredentialQueryResponseBindingDto) throws -> Any {
134
+ var result: [String: Any] = ["multiple": credentialQuery.multiple]
135
+ switch (credentialQuery.credentialOrFailureHint) {
136
+ case let .applicableCredentials(applicableCredentials: value):
137
+ result["applicableCredentials"] = try serializeAny(value);
138
+ case let .failureHint(failureHint: value):
139
+ result["failureHint"] = try serializeAny(value);
140
+ }
141
+ return result as NSDictionary;
142
+ }
143
+
144
+ private func serialize(presentationDefinitionV2ClaimValue: PresentationDefinitionV2ClaimValueBindingDto) throws -> Any {
145
+ switch (presentationDefinitionV2ClaimValue) {
146
+ case let .boolean(value):
147
+ return value;
148
+ case let .float(value):
149
+ return value;
150
+ case let .integer(value):
151
+ return NSNumber(value: value);
152
+ case let .string(value):
153
+ return value;
154
+ case .nested(value: let values):
155
+ return try values.map { try serializeAny($0) }
156
+ }
157
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procivis/react-native-one-core",
3
- "version": "1.60807.0",
3
+ "version": "1.73295.0",
4
4
  "author": "Procivis AG (https://procivis.ch)",
5
5
  "license": "Apache-2.0",
6
6
  "description": "ONE core bindings for React Native",