@procivis/react-native-one-core 1.26730.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.
Files changed (51) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +202 -0
  3. package/android/build.gradle +96 -0
  4. package/android/proguard-rules.pro +4 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/ch/procivis/one/core/Deserialize.kt +118 -0
  7. package/android/src/main/java/ch/procivis/one/core/DeserializeSpecific.kt +94 -0
  8. package/android/src/main/java/ch/procivis/one/core/ProcivisOneCoreModule.kt +444 -0
  9. package/android/src/main/java/ch/procivis/one/core/ProcivisOneCorePackage.kt +19 -0
  10. package/android/src/main/java/ch/procivis/one/core/Serialize.kt +115 -0
  11. package/android/src/main/java/ch/procivis/one/core/SerializeSpecific.kt +121 -0
  12. package/android/src/main/java/ch/procivis/one/core/Util.kt +23 -0
  13. package/bin/postinstall +12 -0
  14. package/core-sdk.json +16 -0
  15. package/dist/index.d.ts +15 -0
  16. package/dist/index.js +59 -0
  17. package/dist/src/backup.d.ts +22 -0
  18. package/dist/src/backup.js +1 -0
  19. package/dist/src/config.d.ts +100 -0
  20. package/dist/src/config.js +25 -0
  21. package/dist/src/core.d.ts +109 -0
  22. package/dist/src/core.js +11 -0
  23. package/dist/src/credential.d.ts +115 -0
  24. package/dist/src/credential.js +39 -0
  25. package/dist/src/credentialSchema.d.ts +130 -0
  26. package/dist/src/credentialSchema.js +37 -0
  27. package/dist/src/did.d.ts +59 -0
  28. package/dist/src/did.js +27 -0
  29. package/dist/src/error.d.ts +23 -0
  30. package/dist/src/error.js +25 -0
  31. package/dist/src/history.d.ts +66 -0
  32. package/dist/src/history.js +42 -0
  33. package/dist/src/key.d.ts +17 -0
  34. package/dist/src/key.js +1 -0
  35. package/dist/src/list.d.ts +14 -0
  36. package/dist/src/list.js +5 -0
  37. package/dist/src/proof.d.ts +137 -0
  38. package/dist/src/proof.js +30 -0
  39. package/dist/src/proofSchema.d.ts +106 -0
  40. package/dist/src/proofSchema.js +9 -0
  41. package/dist/src/trust.d.ts +46 -0
  42. package/dist/src/trust.js +18 -0
  43. package/ios/Deserialize.swift +655 -0
  44. package/ios/ProcivisOneCoreModule.m +216 -0
  45. package/ios/ProcivisOneCoreModule.swift +600 -0
  46. package/ios/ProcivisRNOneCore.xcodeproj/project.pbxproj +318 -0
  47. package/ios/Serialize.swift +607 -0
  48. package/ios/Util.swift +47 -0
  49. package/ios/react-native-one-core-Bridging-Header.h +1 -0
  50. package/package.json +40 -0
  51. package/react-native-one-core.podspec +46 -0
@@ -0,0 +1,655 @@
1
+ //
2
+ // Deserialize.swift
3
+ // react-native-one-core
4
+ //
5
+ // Created by Pavel Zarecky
6
+ //
7
+
8
+ import Foundation
9
+
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
+ )
88
+ }
89
+
90
+ func deserializeIds(_ ids: NSArray) throws -> [String] {
91
+ var result: [String] = [];
92
+ try ids.forEach { id in
93
+ result.append(try safeCast(id));
94
+ }
95
+ return result
96
+ }
97
+
98
+ func deserializePresentationSubmitCredentialRequest(_ input: NSDictionary) throws -> PresentationSubmitCredentialRequestBindingDto {
99
+ let claims: NSArray = try safeCast(input.value(forKey: "submitClaims"));
100
+ var submitClaims: [String] = [];
101
+ try claims.forEach { claim in
102
+ submitClaims.append(try safeCast(claim));
103
+ }
104
+ return PresentationSubmitCredentialRequestBindingDto(credentialId: try safeCast(input.value(forKey: "credentialId")), submitClaims: submitClaims);
105
+ }
106
+
107
+ func deserializeCredentialSchemaListQuery(_ query: NSDictionary) throws -> CredentialSchemaListQueryBindingDto {
108
+ return CredentialSchemaListQueryBindingDto(
109
+ page: try safeCast(query.value(forKey: "page")),
110
+ pageSize: try safeCast(query.value(forKey: "pageSize")),
111
+ organisationId: try safeCast(query.value(forKey: "organisationId")),
112
+ sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
113
+ sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
114
+ name: query.value(forKey: "name") as? String,
115
+ ids: try opt(query.value(forKey: "ids") as? NSArray, deserializeIds),
116
+ exact: try opt(query.value(forKey: "exact") as? NSArray, enumList),
117
+ include: try opt(query.value(forKey: "include") as? NSArray, enumList)
118
+ )
119
+ }
120
+
121
+ func deserializeCredentialListQuery(_ query: NSDictionary) throws -> CredentialListQueryBindingDto {
122
+ return CredentialListQueryBindingDto(
123
+ page: try safeCast(query.value(forKey: "page")),
124
+ pageSize: try safeCast(query.value(forKey: "pageSize")),
125
+ sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
126
+ sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
127
+ organisationId: try safeCast(query.value(forKey: "organisationId")),
128
+ name: query.value(forKey: "name") as? String,
129
+ searchText: query.value(forKey: "searchText") as? String,
130
+ searchType: try opt(query.value(forKey: "searchType") as? NSArray, enumList),
131
+ exact: try opt(query.value(forKey: "exact") as? NSArray, enumList ),
132
+ role: try opt(query.value(forKey: "role") as? String, deserializeEnum),
133
+ ids: try opt(query.value(forKey: "ids") as? NSArray, deserializeIds),
134
+ status: try opt(query.value(forKey: "status") as? NSArray, enumList),
135
+ include: try opt(query.value(forKey: "include") as? NSArray, enumList)
136
+ )
137
+ }
138
+
139
+ func deserializeDidListQuery(_ query: NSDictionary) throws -> DidListQueryBindingDto {
140
+ return DidListQueryBindingDto(
141
+ page: try safeCast(query.value(forKey: "page")),
142
+ pageSize: try safeCast(query.value(forKey: "pageSize")),
143
+ sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
144
+ sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
145
+ organisationId: try safeCast(query.value(forKey: "organisationId")),
146
+ name: query.value(forKey: "name") as? String,
147
+ did: query.value(forKey: "did") as? String,
148
+ type: try opt(query.value(forKey: "type") as? String, deserializeEnum),
149
+ deactivated: query.value(forKey: "deactivated") as? Bool,
150
+ exact: try opt(query.value(forKey: "exact") as? NSArray, { columns in try enumList(columns) } ),
151
+ keyAlgorithms: try opt(query.value(forKey: "keyAlgorithms") as? NSArray, deserializeIds),
152
+ keyRoles: try opt(query.value(forKey: "keyRoles") as? NSArray, { roles in try enumList(roles) })
153
+ )
154
+ }
155
+
156
+ func deserializeHistoryListQuery(_ query: NSDictionary) throws -> HistoryListQueryBindingDto {
157
+ return HistoryListQueryBindingDto(
158
+ page: try safeCast(query.value(forKey: "page")),
159
+ pageSize: try safeCast(query.value(forKey: "pageSize")),
160
+ organisationId: try safeCast(query.value(forKey: "organisationId")),
161
+ entityId: query.value(forKey: "entityId") as? String,
162
+ action: try opt(query.value(forKey: "action") as? String, deserializeEnum),
163
+ entityTypes: try opt(query.value(forKey: "entityTypes") as? NSArray, enumList),
164
+ createdDateFrom: query.value(forKey: "createdDateFrom") as? String,
165
+ createdDateTo: query.value(forKey: "createdDateTo") as? String,
166
+ didId: query.value(forKey: "didId") as? String,
167
+ credentialId: query.value(forKey: "credentialId") as? String,
168
+ credentialSchemaId: query.value(forKey: "credentialSchemaId") as? String,
169
+ search: try deserializeHistorySearch(
170
+ text: query.value(forKey: "searchText") as? String,
171
+ type: query.value(forKey: "searchType") as? String
172
+ ),
173
+ proofSchemaId: query.value(forKey: "proofSchemaId") as? String
174
+ )
175
+ }
176
+
177
+ func deserializeProofSchemaListQuery(_ query: NSDictionary) throws -> ListProofSchemasFiltersBindingDto {
178
+ return ListProofSchemasFiltersBindingDto(
179
+ page: try safeCast(query.value(forKey: "page")),
180
+ pageSize: try safeCast(query.value(forKey: "pageSize")),
181
+ sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
182
+ sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
183
+ organisationId: try safeCast(query.value(forKey: "organisationId")),
184
+ name: query.value(forKey: "name") as? String,
185
+ exact: try opt(query.value(forKey: "exact") as? NSArray, { columns in try enumList(columns) } ),
186
+ ids: try opt(query.value(forKey: "ids") as? NSArray, deserializeIds)
187
+ )
188
+ }
189
+
190
+ func deserializeProofListQuery(_ query: NSDictionary) throws -> ProofListQueryBindingDto {
191
+ return ProofListQueryBindingDto(
192
+ page: try safeCast(query.value(forKey: "page")),
193
+ pageSize: try safeCast(query.value(forKey: "pageSize")),
194
+ organisationId: try safeCast(query.value(forKey: "organisationId")),
195
+ sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
196
+ sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
197
+ name: query.value(forKey: "name") as? String,
198
+ ids: try opt(query.value(forKey: "ids") as? NSArray, deserializeIds),
199
+ proofStates: try opt(query.value(forKey: "proofStates") as? NSArray, { columns in try enumList(columns) } ),
200
+ proofSchemaIds: query.value(forKey: "proofSchemaIds") as? [String],
201
+ exact: try opt(query.value(forKey: "exact") as? NSArray, { columns in try enumList(columns) } )
202
+ )
203
+ }
204
+
205
+ func deserializeImportProofSchemaRequest(_ request: NSDictionary) throws -> ImportProofSchemaRequestBindingsDto {
206
+ return ImportProofSchemaRequestBindingsDto(
207
+ schema: try deserializeImportProofSchema(try safeCast(request.value(forKey: "schema"))),
208
+ organisationId: try safeCast(request.value(forKey: "organisationId"))
209
+ )
210
+ }
211
+
212
+ func deserializeImportProofSchema(_ schema: NSDictionary) throws -> ImportProofSchemaBindingDto {
213
+ let proofInputSchemas: NSArray = try safeCast(schema.value(forKey: "proofInputSchemas"));
214
+
215
+ return ImportProofSchemaBindingDto(
216
+ id: try safeCast(schema.value(forKey: "id")),
217
+ createdDate: try safeCast(schema.value(forKey: "createdDate")),
218
+ lastModified: try safeCast(schema.value(forKey: "lastModified")),
219
+ name: try safeCast(schema.value(forKey: "name")),
220
+ organisationId: try safeCast(schema.value(forKey: "organisationId")),
221
+ importedSourceUrl: try safeCast(schema.value(forKey: "importedSourceUrl")),
222
+ expireDuration: try safeCast(schema.value(forKey: "expireDuration")),
223
+ proofInputSchemas: try proofInputSchemas.map { try deserializeImportProofSchemaInputSchema(try safeCast($0)) }
224
+ )
225
+ }
226
+
227
+ func deserializeCreateProofSchemaRequest(_ request: NSDictionary) throws -> CreateProofSchemaRequestDto {
228
+ let proofInputSchemas: NSArray = try safeCast(request.value(forKey: "proofInputSchemas"));
229
+
230
+ return CreateProofSchemaRequestDto(
231
+ name: try safeCast(request.value(forKey: "name")),
232
+ organisationId: try safeCast(request.value(forKey: "organisationId")),
233
+ expireDuration: try safeCast(request.value(forKey: "expireDuration")),
234
+ proofInputSchemas: try proofInputSchemas.map { try deserializeProofInputSchemaRequest(try safeCast($0)) }
235
+ )
236
+ }
237
+
238
+ func deserializeProofInputSchemaRequest(_ request: NSDictionary) throws -> ProofInputSchemaRequestDto {
239
+ let claimSchemas: NSArray = try safeCast(request.value(forKey: "claimSchemas"));
240
+
241
+ return ProofInputSchemaRequestDto(
242
+ credentialSchemaId: try safeCast(request.value(forKey: "credentialSchemaId")),
243
+ validityConstraint: try safeCast(request.value(forKey: "validityConstraint")),
244
+ claimSchemas: try claimSchemas.map { try deserializeProofClaimSchemaRequest(try safeCast($0)) }
245
+ )
246
+ }
247
+
248
+ func deserializeImportProofSchemaInputSchema(_ inputSchema: NSDictionary) throws -> ImportProofSchemaInputSchemaBindingDto {
249
+ let claimSchemas: NSArray = try safeCast(inputSchema.value(forKey: "claimSchemas"));
250
+
251
+ return ImportProofSchemaInputSchemaBindingDto(
252
+ claimSchemas: try claimSchemas.map { try deserializeImportProofSchemaClaimSchema(try safeCast($0)) },
253
+ credentialSchema: try deserializeImportProofSchemaCredentialSchema(try safeCast(inputSchema.value(forKey: "credentialSchema"))),
254
+ validityConstraint: inputSchema.value(forKey: "validityConstraint") as? Int64
255
+ )
256
+ }
257
+
258
+ func deserializeProofClaimSchemaRequest(_ request: NSDictionary) throws -> CreateProofSchemaClaimRequestDto {
259
+ return CreateProofSchemaClaimRequestDto(
260
+ id: try safeCast(request.value(forKey: "id")),
261
+ required: try safeCast(request.value(forKey: "required"))
262
+ )
263
+ }
264
+
265
+ func deserializeImportProofSchemaClaimSchema(_ request: NSDictionary) throws -> ImportProofSchemaClaimSchemaBindingDto {
266
+ let claims = request.value(forKey: "claims") as? NSArray;
267
+
268
+ return ImportProofSchemaClaimSchemaBindingDto(
269
+ id: try safeCast(request.value(forKey: "id")),
270
+ required: try safeCast(request.value(forKey: "required")),
271
+ key: try safeCast(request.value(forKey: "key")),
272
+ dataType: try safeCast(request.value(forKey: "dataType")),
273
+ claims: try claims?.map { try deserializeImportProofSchemaClaimSchema(try safeCast($0)) },
274
+ array: try safeCast(request.value(forKey: "array"))
275
+ )
276
+ }
277
+
278
+ func deserializeImportProofSchemaCredentialSchema(_ request: NSDictionary) throws -> ImportProofSchemaCredentialSchemaBindingDto {
279
+ return ImportProofSchemaCredentialSchemaBindingDto(
280
+ id: try safeCast(request.value(forKey: "id")),
281
+ createdDate: try safeCast(request.value(forKey: "createdDate")),
282
+ lastModified: try safeCast(request.value(forKey: "lastModified")),
283
+ name: try safeCast(request.value(forKey: "name")),
284
+ format: try safeCast(request.value(forKey: "format")),
285
+ revocationMethod: try safeCast(request.value(forKey: "revocationMethod")),
286
+ walletStorageType: try opt(request.value(forKey: "walletStorageType") as? String, deserializeEnum),
287
+ schemaId: try safeCast(request.value(forKey: "schemaId")),
288
+ importedSourceUrl: try safeCast(request.value(forKey: "importedSourceUrl")),
289
+ schemaType: deserializeCredentialSchemaTypeBindingEnum(try safeCast(request.value(forKey: "schemaType"))),
290
+ layoutType: try opt(request.value(forKey: "layoutType") as? String, deserializeEnum),
291
+ layoutProperties: try opt((request.value(forKey: "layoutProperties") as? NSDictionary), deserializeCredentialSchemaRequestLayoutProperties)
292
+ )
293
+ }
294
+
295
+ func deserializeImportCredentialSchemaRequest(_ request: NSDictionary) throws -> ImportCredentialSchemaRequestBindingDto {
296
+ return ImportCredentialSchemaRequestBindingDto(
297
+ organisationId: try safeCast(request.value(forKey: "organisationId")),
298
+ schema: try deserializeImportCredentialSchemaRequestSchema(try safeCast(request.value(forKey: "schema")))
299
+ )
300
+ }
301
+
302
+ func deserializeImportCredentialSchemaRequestSchema(_ request: NSDictionary) throws -> ImportCredentialSchemaRequestSchemaBindingDto {
303
+ let claims: NSArray = try safeCast(request.value(forKey: "claims"));
304
+
305
+ return ImportCredentialSchemaRequestSchemaBindingDto(
306
+ id: try safeCast(request.value(forKey: "id")),
307
+ createdDate: try safeCast(request.value(forKey: "createdDate")),
308
+ lastModified: try safeCast(request.value(forKey: "lastModified")),
309
+ name: try safeCast(request.value(forKey: "name")),
310
+ format: try safeCast(request.value(forKey: "format")),
311
+ revocationMethod: try safeCast(request.value(forKey: "revocationMethod")),
312
+ organisationId: try safeCast(request.value(forKey: "organisationId")),
313
+ importedSourceUrl: try safeCast(request.value(forKey: "importedSourceUrl")),
314
+ claims: try claims.map { try deserializeImportCredentialSchemaRequestClaim(try safeCast($0)) },
315
+ walletStorageType: try opt(request.value(forKey: "walletStorageType") as? String, deserializeEnum),
316
+ schemaId: try safeCast(request.value(forKey: "schemaId")),
317
+ schemaType: deserializeCredentialSchemaTypeBindingEnum(try safeCast(request.value(forKey: "schemaType"))),
318
+ layoutType: try opt(request.value(forKey: "layoutType") as? String, deserializeEnum),
319
+ layoutProperties: try opt((request.value(forKey: "layoutProperties") as? NSDictionary), deserializeImportCredentialSchemaRequestLayoutProperties),
320
+ allowSuspension: request.value(forKey: "allowSuspension") as? Bool
321
+ )
322
+ }
323
+
324
+ func deserializeImportCredentialSchemaRequestClaim(_ request: NSDictionary) throws -> ImportCredentialSchemaClaimSchemaBindingDto {
325
+ let claims = request.value(forKey: "claims") as? NSArray;
326
+
327
+ return ImportCredentialSchemaClaimSchemaBindingDto(
328
+ id: try safeCast(request.value(forKey: "id")),
329
+ createdDate: try safeCast(request.value(forKey: "createdDate")),
330
+ lastModified: try safeCast(request.value(forKey: "lastModified")),
331
+ required: try safeCast(request.value(forKey: "required")),
332
+ key: try safeCast(request.value(forKey: "key")),
333
+ array: request.value(forKey: "array") as? Bool,
334
+ datatype: try safeCast(request.value(forKey: "datatype")),
335
+ claims: try claims?.map { try deserializeImportCredentialSchemaRequestClaim(try safeCast($0)) }
336
+ )
337
+ }
338
+
339
+ func deserializeImportCredentialSchemaRequestLayoutProperties(_ request: NSDictionary) throws -> ImportCredentialSchemaLayoutPropertiesBindingDto {
340
+ return ImportCredentialSchemaLayoutPropertiesBindingDto(
341
+ background: try opt(request.value(forKey: "background") as? NSDictionary, deserializeImportCredentialSchemaBackgroundProperties),
342
+ logo: try opt(request.value(forKey: "logo") as? NSDictionary, deserializeImportCredentialSchemaLogoProperties),
343
+ primaryAttribute: request.value(forKey: "primaryAttribute") as? String,
344
+ secondaryAttribute: request.value(forKey: "secondaryAttribute") as? String,
345
+ pictureAttribute: request.value(forKey: "pictureAttribute") as? String,
346
+ code: try opt(request.value(forKey: "code") as? NSDictionary, deserializeImportCredentialSchemaCodeProperties)
347
+ )
348
+ }
349
+
350
+ func deserializeCredentialSchemaRequestLayoutProperties(_ request: NSDictionary) throws -> CredentialSchemaLayoutPropertiesBindingDto {
351
+ return CredentialSchemaLayoutPropertiesBindingDto(
352
+ background: try opt(request.value(forKey: "background") as? NSDictionary, deserializeImportCredentialSchemaBackgroundProperties),
353
+ logo: try opt(request.value(forKey: "logo") as? NSDictionary, deserializeImportCredentialSchemaLogoProperties),
354
+ primaryAttribute: request.value(forKey: "primaryAttribute") as? String,
355
+ secondaryAttribute: request.value(forKey: "secondaryAttribute") as? String,
356
+ pictureAttribute: request.value(forKey: "pictureAttribute") as? String,
357
+ code: try opt(request.value(forKey: "code") as? NSDictionary, deserializeImportCredentialSchemaCodeProperties)
358
+ )
359
+ }
360
+
361
+ func deserializeImportCredentialSchemaBackgroundProperties(_ request: NSDictionary) throws -> CredentialSchemaBackgroundPropertiesBindingDto {
362
+ return CredentialSchemaBackgroundPropertiesBindingDto(
363
+ color: request.value(forKey: "color") as? String,
364
+ image: request.value(forKey: "image") as? String
365
+ )
366
+ }
367
+
368
+ func deserializeImportCredentialSchemaLogoProperties(_ request: NSDictionary) throws -> CredentialSchemaLogoPropertiesBindingDto {
369
+ return CredentialSchemaLogoPropertiesBindingDto(
370
+ fontColor: request.value(forKey: "fontColor") as? String,
371
+ backgroundColor: request.value(forKey: "backgroundColor") as? String,
372
+ image: request.value(forKey: "image") as? String
373
+ )
374
+ }
375
+
376
+ func deserializeImportCredentialSchemaCodeProperties(_ request: NSDictionary) throws -> CredentialSchemaCodePropertiesBindingDto {
377
+ return CredentialSchemaCodePropertiesBindingDto(
378
+ attribute: try safeCast(request.value(forKey: "attribute")),
379
+ type: try deserializeEnum(try safeCast(request.value(forKey: "type")))
380
+ )
381
+ }
382
+
383
+ func deserializeCreateProofRequest(_ request: NSDictionary) throws -> CreateProofRequestBindingDto {
384
+ return CreateProofRequestBindingDto(
385
+ proofSchemaId: try safeCast(request.value(forKey: "proofSchemaId")),
386
+ verifierDidId: try safeCast(request.value(forKey: "verifierDidId")),
387
+ exchange: try safeCast(request.value(forKey: "exchange")),
388
+ redirectUri: request.value(forKey: "redirectUri") as? String,
389
+ verifierKey: request.value(forKey: "verifierKey") as? String,
390
+ scanToVerify: try opt((request.value(forKey: "scanToVerify") as? NSDictionary), deserializeScanToVerifyRequest),
391
+ isoMdlEngagement: request.value(forKey: "isoMdlEngagement") as? String,
392
+ transport: request.value(forKey: "transport") as? [String]
393
+ )
394
+ }
395
+
396
+ func deserializeScanToVerifyRequest(_ request: NSDictionary) throws -> ScanToVerifyRequestBindingDto {
397
+ return ScanToVerifyRequestBindingDto(
398
+ credential: try safeCast(request.value(forKey: "credential")),
399
+ barcode: try safeCast(request.value(forKey: "barcode")),
400
+ barcodeType: try deserializeEnum(try safeCast(request.value(forKey: "barcodeType")))
401
+ )
402
+ }
403
+
404
+ func deserializeCreateTrustAnchorRequest(_ request: NSDictionary) throws -> CreateTrustAnchorRequestBindingDto {
405
+ return CreateTrustAnchorRequestBindingDto(
406
+ name: try safeCast(request.value(forKey: "name")),
407
+ type: try safeCast(request.value(forKey: "type")),
408
+ publisherReference: request.value(forKey: "publisherReference") as? String,
409
+ role: try deserializeEnum(try safeCast(request.value(forKey: "role"))),
410
+ priority: request.value(forKey: "priority") as? UInt32,
411
+ organisationId: try safeCast(request.value(forKey: "organisationId"))
412
+ )
413
+ }
414
+
415
+ func deserializeTrustAnchorListQuery(_ query: NSDictionary) throws -> ListTrustAnchorsFiltersBindings {
416
+ return ListTrustAnchorsFiltersBindings(
417
+ page: try safeCast(query.value(forKey: "page")),
418
+ pageSize: try safeCast(query.value(forKey: "pageSize")),
419
+ sort: try opt(query.value(forKey: "sort") as? String, deserializeEnum),
420
+ sortDirection: try opt(query.value(forKey: "sortDirection") as? String, deserializeEnum),
421
+ name: query.value(forKey: "name") as? String,
422
+ role: try opt(query.value(forKey: "role") as? String, deserializeEnum),
423
+ type: query.value(forKey: "type") as? String,
424
+ organisationId: try safeCast(query.value(forKey: "organisationId")),
425
+ exact: try opt(query.value(forKey: "exact") as? NSArray, { columns in try enumList(columns) } )
426
+ )
427
+ }
428
+
429
+ extension KeyRoleBindingEnum: CaseIterable {
430
+ public static var allCases: [KeyRoleBindingEnum] {
431
+ return [.authentication, .assertionMethod, .keyAgreement, .capabilityInvocation, .capabilityDelegation]
432
+ }
433
+ }
434
+
435
+ extension DidTypeBindingEnum: CaseIterable {
436
+ public static var allCases: [DidTypeBindingEnum] {
437
+ return [.local, .remote]
438
+ }
439
+ }
440
+
441
+ extension SortDirection: CaseIterable {
442
+ public static var allCases: [SortDirection] {
443
+ return [.ascending, .descending]
444
+ }
445
+ }
446
+
447
+ extension SortableDidColumnBindingEnum: CaseIterable {
448
+ public static var allCases: [SortableDidColumnBindingEnum] {
449
+ return [.name, .createdDate, .method, .type, .did, .deactivated]
450
+ }
451
+ }
452
+
453
+ extension SortableCredentialColumnBindingEnum: CaseIterable {
454
+ public static var allCases: [SortableCredentialColumnBindingEnum] {
455
+ return [.createdDate, .schemaName, .issuerDid, .state]
456
+ }
457
+ }
458
+
459
+ extension CredentialListIncludeEntityTypeBindingEnum: CaseIterable {
460
+ public static var allCases: [CredentialListIncludeEntityTypeBindingEnum] {
461
+ return [.layoutProperties, .credential]
462
+ }
463
+ }
464
+
465
+ extension CredentialStateBindingEnum: CaseIterable {
466
+ public static var allCases: [CredentialStateBindingEnum] {
467
+ return [.created, .pending, .offered, .accepted, .rejected, .revoked, .error, .suspended]
468
+ }
469
+ }
470
+
471
+ extension ExactDidFilterColumnBindingEnum: CaseIterable {
472
+ public static var allCases: [ExactDidFilterColumnBindingEnum] {
473
+ return [.name, .did]
474
+ }
475
+ }
476
+
477
+ extension CredentialListQueryExactColumnBindingEnum: CaseIterable {
478
+ public static var allCases: [CredentialListQueryExactColumnBindingEnum] {
479
+ return [.name]
480
+ }
481
+ }
482
+
483
+ extension HistoryEntityTypeBindingEnum: CaseIterable {
484
+ public static var allCases: [HistoryEntityTypeBindingEnum] {
485
+ return [.key, .did, .credentialSchema, .credential, .proofSchema, .proof, .organisation, .backup]
486
+ }
487
+ }
488
+
489
+ extension HistorySearchEnumBindingEnum: CaseIterable {
490
+ public static var allCases: [HistorySearchEnumBindingEnum] {
491
+ return [.claimName, .claimValue, .credentialSchemaName, .issuerDid, .issuerName, .verifierDid, .verifierName, .proofSchemaName]
492
+ }
493
+ }
494
+
495
+ extension HistoryActionBindingEnum: CaseIterable {
496
+ public static var allCases: [HistoryActionBindingEnum] {
497
+ return [.accepted, .created, .deactivated, .deleted, .errored, .issued, .offered, .reactivated, .rejected, .requested, .revoked, .pending, .suspended, .restored, .shared, .imported, .claimsRemoved]
498
+ }
499
+ }
500
+
501
+ extension CredentialRoleBindingDto: CaseIterable {
502
+ public static var allCases: [CredentialRoleBindingDto] {
503
+ return [.holder, .issuer, .verifier]
504
+ }
505
+ }
506
+
507
+ extension SortableProofSchemaColumnBinding: CaseIterable {
508
+ public static var allCases: [SortableProofSchemaColumnBinding] {
509
+ return [.name, .createdDate]
510
+ }
511
+ }
512
+
513
+ extension ProofSchemaListQueryExactColumnBinding: CaseIterable {
514
+ public static var allCases: [ProofSchemaListQueryExactColumnBinding] {
515
+ return [.name]
516
+ }
517
+ }
518
+
519
+ extension SortableCredentialSchemaColumnBindingEnum: CaseIterable {
520
+ public static var allCases: [SortableCredentialSchemaColumnBindingEnum] {
521
+ return [.name, .format, .createdDate]
522
+ }
523
+ }
524
+
525
+ extension CredentialSchemaListQueryExactColumnBindingEnum: CaseIterable {
526
+ public static var allCases: [CredentialSchemaListQueryExactColumnBindingEnum] {
527
+ return [.name]
528
+ }
529
+ }
530
+
531
+ extension CredentialSchemaListIncludeEntityType: CaseIterable {
532
+ public static var allCases: [CredentialSchemaListIncludeEntityType] {
533
+ return [.layoutProperties]
534
+ }
535
+ }
536
+
537
+ extension SortableProofListColumnBinding: CaseIterable {
538
+ public static var allCases: [SortableProofListColumnBinding] {
539
+ return [.createdDate, .schemaName, .state, .verifierDid]
540
+ }
541
+ }
542
+
543
+ extension ProofListQueryExactColumnBindingEnum: CaseIterable {
544
+ public static var allCases: [ProofListQueryExactColumnBindingEnum] {
545
+ return [.name]
546
+ }
547
+ }
548
+
549
+ extension CredentialSchemaCodeTypeBindingDto: CaseIterable {
550
+ public static var allCases: [CredentialSchemaCodeTypeBindingDto] {
551
+ return [.barcode, .mrz, .qrCode]
552
+ }
553
+ }
554
+
555
+ extension LayoutTypeBindingEnum: CaseIterable {
556
+ public static var allCases: [LayoutTypeBindingEnum] {
557
+ return [.card, .document, .singleAttribute]
558
+ }
559
+ }
560
+
561
+ extension WalletStorageTypeBindingEnum: CaseIterable {
562
+ public static var allCases: [WalletStorageTypeBindingEnum] {
563
+ return [.hardware, .software]
564
+ }
565
+ }
566
+
567
+ extension ProofStateBindingEnum: CaseIterable {
568
+ public static var allCases: [ProofStateBindingEnum] {
569
+ return [
570
+ .created,
571
+ .pending,
572
+ .requested,
573
+ .accepted,
574
+ .rejected,
575
+ .error
576
+ ]
577
+ }
578
+ }
579
+
580
+ extension ScanToVerifyBarcodeTypeBindingEnum: CaseIterable {
581
+ public static var allCases: [ScanToVerifyBarcodeTypeBindingEnum] {
582
+ return [.mrz, .pdf417]
583
+ }
584
+ }
585
+
586
+ extension TrustAnchorRoleBinding: CaseIterable {
587
+ public static var allCases: [TrustAnchorRoleBinding] {
588
+ return [.publisher, .client]
589
+ }
590
+ }
591
+
592
+ extension SortableTrustAnchorColumnBindings: CaseIterable {
593
+ public static var allCases: [SortableTrustAnchorColumnBindings] {
594
+ return [.name, .createdDate, .type, .role, .priority]
595
+ }
596
+ }
597
+
598
+ extension ExactTrustAnchorFilterColumnBindings: CaseIterable {
599
+ public static var allCases: [ExactTrustAnchorFilterColumnBindings] {
600
+ return [.name, .type]
601
+ }
602
+ }
603
+
604
+ extension SearchTypeBindingEnum: CaseIterable {
605
+ public static var allCases: [SearchTypeBindingEnum] {
606
+ return [.claimName, .claimValue, .credentialSchemaName]
607
+ }
608
+ }
609
+
610
+ private func deserializeEnum<T: CaseIterable>(_ input: String) throws -> T {
611
+ if let entry = T.allCases.first(where: { value in
612
+ serializeEnumValue(value: value) == input
613
+ }) {
614
+ return entry;
615
+ } else {
616
+ throw SerializationError("Invalid enum value for \(T.self): " + input);
617
+ }
618
+ }
619
+
620
+ private func opt<F, T>(_ input: F?, _ deserialize: @escaping (_ input: F) throws -> T) throws -> T? {
621
+ if (input != nil) {
622
+ return try deserialize(input!);
623
+ }
624
+ return nil
625
+ }
626
+
627
+ func safeCast<T>(_ input: Any?) throws -> T {
628
+ if let result = input as? T {
629
+ return result
630
+ } else {
631
+ throw SerializationError("Invalid input for type \(T.self): " + String(describing: input));
632
+ }
633
+ }
634
+
635
+ private func enumList<T: CaseIterable>(_ entries: NSArray) throws -> [T] {
636
+ var result: [T] = [];
637
+ try entries.forEach { entry in
638
+ result.append(try deserializeEnum(try safeCast(entry)));
639
+ }
640
+ return result
641
+ }
642
+
643
+ private func deserializeCredentialSchemaTypeBindingEnum(_ credentialSchemaType: String) -> CredentialSchemaTypeBindingEnum {
644
+ switch (credentialSchemaType) {
645
+ case "PROCIVIS_ONE_SCHEMA2024":
646
+ return .procivisOneSchema2024
647
+ case "FALLBACK_SCHEMA2024":
648
+ return .fallbackSchema2024
649
+ case "MDOC":
650
+ return .mdoc
651
+ case let other:
652
+ return .other(value: other)
653
+ }
654
+
655
+ }