@velocitycareerlabs/vcl-react-native 2.6.0 → 2.6.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.
- package/android/src/main/java/io/velocitycareerlabs/reactnative/utlis/Converter.kt +7 -2
- package/ios/Extensions/DictionaryExtensions.swift +7 -7
- package/ios/Extensions/StringExtensions.swift +8 -8
- package/ios/GlobalConfig.swift +8 -8
- package/ios/Utils/Converter.swift +478 -478
- package/ios/Utils/VCLLog.swift +25 -25
- package/ios/VclReactNative.swift +275 -275
- package/package.json +1 -1
|
@@ -12,679 +12,679 @@ import Foundation
|
|
|
12
12
|
import VCL
|
|
13
13
|
|
|
14
14
|
func dictionaryToInitializationDescriptor(
|
|
15
|
-
_ initializationDescriptorDictionary: [String:
|
|
15
|
+
_ initializationDescriptorDictionary: [String: Sendable]
|
|
16
16
|
) -> VCLInitializationDescriptor {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
return VCLInitializationDescriptor(
|
|
18
|
+
environment: dictionaryToEnvironment(
|
|
19
|
+
initializationDescriptorDictionary["environment"] as? String
|
|
20
|
+
),
|
|
21
|
+
xVnfProtocolVersion: dictionaryToXVnfProtocolVersion (
|
|
22
|
+
initializationDescriptorDictionary["xVnfProtocolVersion"] as? String
|
|
23
|
+
),
|
|
24
|
+
cacheSequence: initializationDescriptorDictionary["cacheSequence"] as? Int ?? 0,
|
|
25
|
+
isDebugOn: initializationDescriptorDictionary["isDebugOn"] as? Bool ?? false,
|
|
26
|
+
cryptoServicesDescriptor: dictionaryToCryptoServicesDescriptor(
|
|
27
|
+
initializationDescriptorDictionary["cryptoServicesDescriptor"] as? [String : Sendable]
|
|
28
|
+
),
|
|
29
|
+
isDirectIssuerCheckOn: initializationDescriptorDictionary["isDirectIssuerCheckOn"] as? Bool ?? true
|
|
30
|
+
)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
private func dictionaryToEnvironment(
|
|
34
34
|
_ environment: String?
|
|
35
35
|
) -> VCLEnvironment {
|
|
36
|
-
|
|
36
|
+
return VCLEnvironment.fromString(value: environment ?? "")
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
private func dictionaryToCryptoServicesDescriptor(
|
|
40
|
-
|
|
40
|
+
_ cryptoServicesDescriptorDictionary: [String: Sendable]?
|
|
41
41
|
) -> VCLCryptoServicesDescriptor {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
)
|
|
58
|
-
return VCLCryptoServicesDescriptor(
|
|
59
|
-
cryptoServiceType: cryptoServiceType,
|
|
60
|
-
remoteCryptoServicesUrlsDescriptor: remoteCryptoServicesUrlsDescriptor
|
|
42
|
+
let cryptoServiceType =
|
|
43
|
+
VCLCryptoServiceType.fromString(
|
|
44
|
+
value: cryptoServicesDescriptorDictionary?["cryptoServiceType"] as? String ?? ""
|
|
45
|
+
)
|
|
46
|
+
let remoteCryptoServicesUrlsDescriptorDictionary = cryptoServicesDescriptorDictionary?["remoteCryptoServicesUrlsDescriptor"] as? [String: Sendable]
|
|
47
|
+
let keyServiceUrls = remoteCryptoServicesUrlsDescriptorDictionary?["keyServiceUrls"] as? [String: Sendable]
|
|
48
|
+
let jwtServiceUrls = remoteCryptoServicesUrlsDescriptorDictionary?["jwtServiceUrls"] as? [String: Sendable]
|
|
49
|
+
let remoteCryptoServicesUrlsDescriptor = VCLRemoteCryptoServicesUrlsDescriptor(
|
|
50
|
+
keyServiceUrls: VCLKeyServiceUrls(
|
|
51
|
+
createDidKeyServiceUrl: keyServiceUrls?["createDidKeyServiceUrl"] as? String ?? ""
|
|
52
|
+
),
|
|
53
|
+
jwtServiceUrls: VCLJwtServiceUrls(
|
|
54
|
+
jwtSignServiceUrl: jwtServiceUrls?["jwtSignServiceUrl"] as? String ?? "",
|
|
55
|
+
jwtVerifyServiceUrl: jwtServiceUrls?["jwtVerifyServiceUrl"] as? String
|
|
61
56
|
)
|
|
57
|
+
)
|
|
58
|
+
return VCLCryptoServicesDescriptor(
|
|
59
|
+
cryptoServiceType: cryptoServiceType,
|
|
60
|
+
remoteCryptoServicesUrlsDescriptor: remoteCryptoServicesUrlsDescriptor
|
|
61
|
+
)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
private func dictionaryToXVnfProtocolVersion(
|
|
65
65
|
_ xVnfProtocolVersion: String?
|
|
66
66
|
) -> VCLXVnfProtocolVersion {
|
|
67
|
-
|
|
67
|
+
return VCLXVnfProtocolVersion.fromString(value: xVnfProtocolVersion ?? "")
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
func regionToDictionary(
|
|
71
71
|
_ region: VCLRegion
|
|
72
|
-
) -> [String:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
) -> [String: Sendable] {
|
|
73
|
+
var regionDict = [String: Sendable]()
|
|
74
|
+
regionDict["payload"] = region.payload
|
|
75
|
+
regionDict["code"] = region.code
|
|
76
|
+
regionDict["name"] = region.name
|
|
77
|
+
return regionDict
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
func regionsToDictionary(
|
|
81
81
|
_ regions: VCLRegions
|
|
82
|
-
) -> [String:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
) -> [String: Sendable] {
|
|
83
|
+
var regionsMap = [String: Sendable]()
|
|
84
|
+
var regionsArr = [[String: Sendable]]()
|
|
85
|
+
for i in 0..<regions.all.count {
|
|
86
|
+
regionsArr.append(regionToDictionary(regions.all[i]))
|
|
87
|
+
}
|
|
88
|
+
regionsMap["all"] = regionsArr
|
|
89
|
+
return regionsMap
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
func countryToDictionary(
|
|
93
93
|
_ country: VCLCountry
|
|
94
|
-
) -> [String:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
) -> [String: Sendable] {
|
|
95
|
+
var countryDict = [String: Sendable]()
|
|
96
|
+
countryDict["payload"] = country.payload
|
|
97
|
+
countryDict["code"] = country.code
|
|
98
|
+
countryDict["name"] = country.name
|
|
99
|
+
if let regions = country.regions {
|
|
100
|
+
countryDict["regions"] = regionsToDictionary(regions)
|
|
101
|
+
}
|
|
102
|
+
return countryDict
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
func countriesToDictionary(
|
|
106
106
|
_ countries: VCLCountries
|
|
107
|
-
) -> [String: [[String:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
107
|
+
) -> [String: [[String: Sendable]?]] {
|
|
108
|
+
var countriesArr = [[String: Sendable]?] ()
|
|
109
|
+
if let all = countries.all {
|
|
110
|
+
for i in 0..<all.count {
|
|
111
|
+
countriesArr.append(countryToDictionary(all[i]))
|
|
113
112
|
}
|
|
114
|
-
|
|
113
|
+
}
|
|
114
|
+
return ["all": countriesArr]
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
func credentialTypeSchemasToDictionary(
|
|
118
118
|
_ credentialTypeSchemas: VCLCredentialTypeSchemas
|
|
119
|
-
) -> [String: [String:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
119
|
+
) -> [String: [String: Sendable]] {
|
|
120
|
+
var credentialTypeSchemasMap = [String: [String: Sendable]]()
|
|
121
|
+
if let all = credentialTypeSchemas.all {
|
|
122
|
+
for (key, credentialTypeSchema) in all {
|
|
123
|
+
var credentialTypeSchemaDictionary = [String: Sendable]()
|
|
124
|
+
credentialTypeSchemaDictionary["payload"] = credentialTypeSchema.payload
|
|
125
|
+
credentialTypeSchemasMap[key] = credentialTypeSchemaDictionary
|
|
127
126
|
}
|
|
128
|
-
|
|
127
|
+
}
|
|
128
|
+
return ["all": credentialTypeSchemasMap]
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
func credentialTypesToDictionary(
|
|
132
132
|
_ credentialTypes: VCLCredentialTypes
|
|
133
|
-
) -> [String: [[String:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
private func parseCredentialTypesArray(_ credentialTypesArr: [VCLCredentialType]) -> [[String:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
133
|
+
) -> [String: [[String: Sendable?]]] {
|
|
134
|
+
var credentialTypesArray = [[String: Sendable?]]()
|
|
135
|
+
var recommendedCredentialTypesArray = [[String: Sendable?]]()
|
|
136
|
+
if let all = credentialTypes.all {
|
|
137
|
+
credentialTypesArray = parseCredentialTypesArray(all)
|
|
138
|
+
}
|
|
139
|
+
if let recommendedTypes = credentialTypes.recommendedTypes {
|
|
140
|
+
recommendedCredentialTypesArray = parseCredentialTypesArray(recommendedTypes)
|
|
141
|
+
}
|
|
142
|
+
return ["all": credentialTypesArray, "recommendedTypes": recommendedCredentialTypesArray]
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private func parseCredentialTypesArray(_ credentialTypesArr: [VCLCredentialType]) -> [[String: Sendable?]] {
|
|
146
|
+
var credentialTypesArray = [[String: Sendable?]]()
|
|
147
|
+
credentialTypesArr.forEach {
|
|
148
|
+
var credentialType = [String: Sendable?]()
|
|
149
|
+
credentialType["payload"] = $0.payload
|
|
150
|
+
credentialType["id"] = $0.id
|
|
151
|
+
credentialType["schema"] = $0.schema
|
|
152
|
+
credentialType["createdAt"] = $0.createdAt
|
|
153
|
+
credentialType["schemaName"] = $0.schemaName
|
|
154
|
+
credentialType["credentialType"] = $0.credentialType
|
|
155
|
+
credentialType["recommended"] = $0.recommended
|
|
156
|
+
credentialType["jsonldContext"] = $0.jsonldContext
|
|
157
|
+
credentialType["issuerCategory"] = $0.issuerCategory
|
|
158
|
+
credentialTypesArray.append(credentialType)
|
|
159
|
+
}
|
|
160
|
+
return credentialTypesArray
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
func dictionaryTopPresentationRequestDescriptor(
|
|
164
|
-
_ presentationRequestDescriptorLinkDictionary: [String:
|
|
164
|
+
_ presentationRequestDescriptorLinkDictionary: [String: Sendable]
|
|
165
165
|
) -> VCLPresentationRequestDescriptor {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
)
|
|
166
|
+
return VCLPresentationRequestDescriptor(
|
|
167
|
+
deepLink: dictionaryToDeepLink(presentationRequestDescriptorLinkDictionary["deepLink"] as? [String: Sendable]) ?? VCLDeepLink(value: ""),
|
|
168
|
+
pushDelegate: dictionaryToPushDelegate(presentationRequestDescriptorLinkDictionary["pushDelegate"] as? [String: Sendable]),
|
|
169
|
+
didJwk: dictionaryToDidJwk(presentationRequestDescriptorLinkDictionary["didJwk"] as? [String: Sendable]),
|
|
170
|
+
remoteCryptoServicesToken: dictionaryToToken(
|
|
171
|
+
presentationRequestDescriptorLinkDictionary["remoteCryptoServicesToken"] as? [String: Sendable]
|
|
173
172
|
)
|
|
173
|
+
)
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
func dictionaryToDeepLink(_ deepLinkDictionary: [String:
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
176
|
+
func dictionaryToDeepLink(_ deepLinkDictionary: [String: Sendable]?) -> VCLDeepLink? {
|
|
177
|
+
if let value = deepLinkDictionary?["value"] as? String {
|
|
178
|
+
return VCLDeepLink(value: value)
|
|
179
|
+
}
|
|
180
|
+
return nil
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
func deepLinkToDictionary(_ deepLink: VCLDeepLink?) -> [String:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
func deepLinkToDictionary(_ deepLink: VCLDeepLink?) -> [String: Sendable]? {
|
|
184
|
+
if let value = deepLink?.value {
|
|
185
|
+
return ["value": value]
|
|
186
|
+
}
|
|
187
|
+
return nil
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
func dictionaryToToken(_ tokenDictionary: [String:
|
|
191
|
-
|
|
190
|
+
func dictionaryToToken(_ tokenDictionary: [String: Sendable]?) -> VCLToken {
|
|
191
|
+
return VCLToken(value: tokenDictionary?["value"] as? String ?? "")
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
func tokenToDictionary(_ token: VCLToken?) -> [String:
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
194
|
+
func tokenToDictionary(_ token: VCLToken?) -> [String: Sendable] {
|
|
195
|
+
var retVal = [String: Sendable]()
|
|
196
|
+
retVal["value"] = token?.value
|
|
197
|
+
if let expiresIn = token?.expiresIn {
|
|
198
|
+
retVal["expiresIn"] = expiresIn
|
|
199
|
+
}
|
|
200
|
+
return retVal
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
func dictionaryToIssuingType(
|
|
204
|
-
issuingTypeDictionary: [String:
|
|
204
|
+
issuingTypeDictionary: [String: Sendable],
|
|
205
205
|
defaultIssuingType: VCLIssuingType
|
|
206
206
|
) -> VCLIssuingType {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
if let issuingType = issuingTypeDictionary["issuingType"] as? String {
|
|
208
|
+
return VCLIssuingType.fromString(value: issuingType)
|
|
209
|
+
}
|
|
210
|
+
return defaultIssuingType
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
func dictionaryToPresentationRequest(
|
|
214
|
-
_ presentationRequestDictionary: [String:
|
|
214
|
+
_ presentationRequestDictionary: [String: Sendable]?
|
|
215
215
|
) -> VCLPresentationRequest {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
216
|
+
return VCLPresentationRequest(
|
|
217
|
+
jwt: dictionaryToJwt(presentationRequestDictionary?["jwt"] as? [String : Sendable]),
|
|
218
|
+
verifiedProfile: dictionaryToVerifiedProfile(presentationRequestDictionary?["verifiedProfile"] as? [String: Sendable]),
|
|
219
|
+
deepLink: dictionaryToDeepLink(presentationRequestDictionary?["deepLink"] as? [String : Sendable]) ?? VCLDeepLink(value: ""),
|
|
220
|
+
pushDelegate: dictionaryToPushDelegate(presentationRequestDictionary?["pushDelegate"] as? [String : Sendable]),
|
|
221
|
+
didJwk: dictionaryToDidJwk(presentationRequestDictionary?["didJwk"] as? [String : Sendable]),
|
|
222
|
+
remoteCryptoServicesToken: dictionaryToToken(presentationRequestDictionary?["remoteCryptoServicesToken"] as? [String : Sendable])
|
|
223
|
+
)
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
func presentationRequestToDictionary(
|
|
227
227
|
_ presentationRequest: VCLPresentationRequest
|
|
228
|
-
) -> [String:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
228
|
+
) -> [String: Sendable] {
|
|
229
|
+
var presentationRequestDictionary = [String: Sendable]()
|
|
230
|
+
presentationRequestDictionary["jwt"] = ["encodedJwt": presentationRequest.jwt.encodedJwt]
|
|
231
|
+
presentationRequestDictionary["verifiedProfile"] = verifiedProfileToDictionary(presentationRequest.verifiedProfile)
|
|
232
|
+
presentationRequestDictionary["iss"] = presentationRequest.iss
|
|
233
|
+
presentationRequestDictionary["exchangeId"] = presentationRequest.exchangeId
|
|
234
|
+
presentationRequestDictionary["presentationDefinitionId"] = presentationRequest.presentationDefinitionId
|
|
235
|
+
presentationRequestDictionary["deepLink"] = deepLinkToDictionary(presentationRequest.deepLink)
|
|
236
|
+
presentationRequestDictionary["didJwk"] = didJwkToDictionary(presentationRequest.didJwk)
|
|
237
|
+
presentationRequestDictionary["remoteCryptoServicesToken"] = tokenToDictionary(presentationRequest.remoteCryptoServicesToken)
|
|
238
|
+
return presentationRequestDictionary
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
func dictionaryToPresentationSubmission(
|
|
242
|
-
_ presentationSubmissionDictionary: [String:
|
|
242
|
+
_ presentationSubmissionDictionary: [String: Sendable]?
|
|
243
243
|
) -> VCLPresentationSubmission {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
244
|
+
var verifiableCredentialsList = [VCLVerifiableCredential]()
|
|
245
|
+
if let verifiableCredentialsArr = (presentationSubmissionDictionary?["verifiableCredentials"] as? [[String: String]]) {
|
|
246
|
+
for verifiableCredential in verifiableCredentialsArr {
|
|
247
|
+
verifiableCredentialsList.append(
|
|
248
|
+
VCLVerifiableCredential(
|
|
249
|
+
inputDescriptor: verifiableCredential["inputDescriptor"] ?? "",
|
|
250
|
+
jwtVc: verifiableCredential["jwtVc"] ?? ""
|
|
251
|
+
)
|
|
252
|
+
)
|
|
254
253
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
}
|
|
255
|
+
return VCLPresentationSubmission(
|
|
256
|
+
presentationRequest: dictionaryToPresentationRequest(presentationSubmissionDictionary?["presentationRequest"] as? [String: Sendable]),
|
|
257
|
+
verifiableCredentials: verifiableCredentialsList
|
|
258
|
+
)
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
func presentationSubmissionResultToDictionary(
|
|
262
262
|
_ presentationSubmissionResult: VCLSubmissionResult
|
|
263
|
-
) -> [String:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
263
|
+
) -> [String: Sendable] {
|
|
264
|
+
var presentationSubmissionResulDictionary = [String: Sendable]()
|
|
265
|
+
presentationSubmissionResulDictionary[VCLSubmissionResult.CodingKeys.KeyToken] = tokenToDictionary(presentationSubmissionResult.sessionToken)
|
|
266
|
+
presentationSubmissionResulDictionary[VCLSubmissionResult.CodingKeys.KeyExchange] = exchangeToDictionary(presentationSubmissionResult.exchange)
|
|
267
|
+
presentationSubmissionResulDictionary[VCLSubmissionResult.CodingKeys.KeyJti] = presentationSubmissionResult.jti
|
|
268
|
+
presentationSubmissionResulDictionary[VCLSubmissionResult.CodingKeys.KeySubmissionId] = presentationSubmissionResult.submissionId
|
|
269
|
+
return presentationSubmissionResulDictionary
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
func exchangeToDictionary(
|
|
273
273
|
_ exchange: VCLExchange?
|
|
274
|
-
) -> [String:
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
func dictionaryToSubmissionResult(_ submissionResultDictionary: [String:
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
274
|
+
) -> [String: Sendable] {
|
|
275
|
+
var exchangeDictionary = [String: Sendable]()
|
|
276
|
+
exchangeDictionary["id"] = exchange?.id
|
|
277
|
+
exchangeDictionary["type"] = exchange?.type
|
|
278
|
+
exchangeDictionary["disclosureComplete"] = exchange?.disclosureComplete
|
|
279
|
+
exchangeDictionary["exchangeComplete"] = exchange?.exchangeComplete
|
|
280
|
+
return exchangeDictionary
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
func dictionaryToSubmissionResult(_ submissionResultDictionary: [String: Sendable]?) -> VCLSubmissionResult {
|
|
284
|
+
return VCLSubmissionResult(
|
|
285
|
+
sessionToken: dictionaryToToken(submissionResultDictionary?[VCLSubmissionResult.CodingKeys.KeyToken] as? [String: Sendable]),
|
|
286
|
+
exchange: dictionaryToExchange(submissionResultDictionary?[VCLSubmissionResult.CodingKeys.KeyExchange] as? [String: Sendable]),
|
|
287
|
+
jti: submissionResultDictionary?[VCLSubmissionResult.CodingKeys.KeyJti] as? String ?? "",
|
|
288
|
+
submissionId: submissionResultDictionary?[VCLSubmissionResult.CodingKeys.KeySubmissionId] as? String ?? ""
|
|
289
|
+
)
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
func dictionaryToExchange(
|
|
293
|
-
_ exchangeReadableMap: [String:
|
|
293
|
+
_ exchangeReadableMap: [String: Sendable]?
|
|
294
294
|
) -> VCLExchange {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
295
|
+
return VCLExchange(
|
|
296
|
+
id: exchangeReadableMap?["id"] as? String ?? "",
|
|
297
|
+
type: exchangeReadableMap?["type"] as? String ?? "",
|
|
298
|
+
disclosureComplete: exchangeReadableMap?["disclosureComplete"] as? Bool ?? false,
|
|
299
|
+
exchangeComplete: exchangeReadableMap?["exchangeComplete"] as? Bool ?? false
|
|
300
|
+
)
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
func dictionaryToExchangeDescriptor(
|
|
304
|
-
_ exchangeDescriptorDictionary: [String:
|
|
304
|
+
_ exchangeDescriptorDictionary: [String: Sendable]?
|
|
305
305
|
) -> VCLExchangeDescriptor {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
306
|
+
return VCLExchangeDescriptor(
|
|
307
|
+
presentationSubmission: dictionaryToPresentationSubmission(exchangeDescriptorDictionary?["presentationSubmission"] as? [String: Sendable]),
|
|
308
|
+
submissionResult: dictionaryToSubmissionResult(exchangeDescriptorDictionary?["submissionResult"] as? [String: Sendable])
|
|
309
|
+
)
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
func dictionayToOrganizationsSearchDescriptor(
|
|
313
|
-
_ organizationsDescriptorDictionary: [String:
|
|
313
|
+
_ organizationsDescriptorDictionary: [String: Sendable]
|
|
314
314
|
) -> VCLOrganizationsSearchDescriptor {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
315
|
+
return VCLOrganizationsSearchDescriptor(
|
|
316
|
+
filter: dictionaryToFilter(organizationsDescriptorDictionary["filter"] as? [String : Sendable]),
|
|
317
|
+
page: dictionaryToPage(organizationsDescriptorDictionary["page"] as? [String : Sendable]),
|
|
318
|
+
sort: organizationsDescriptorDictionary["sort"] as? [[String]],
|
|
319
|
+
query: organizationsDescriptorDictionary["query"] as? String
|
|
320
|
+
)
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
func dictionaryToFilter(
|
|
324
|
-
_ filterDictionary: [String:
|
|
324
|
+
_ filterDictionary: [String: Sendable]?
|
|
325
325
|
) -> VCLFilter {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
326
|
+
let did: String? = filterDictionary?["did"] as? String
|
|
327
|
+
var serviceTypesList: [VCLServiceType]? = nil
|
|
328
|
+
if let serviceTypesArr = (filterDictionary?["serviceTypes"] as? [String]) {
|
|
329
|
+
serviceTypesList = [VCLServiceType]()
|
|
330
|
+
for serviceTypeStr in serviceTypesArr {
|
|
331
|
+
serviceTypesList?.append(VCLServiceType.fromString(value: serviceTypeStr))
|
|
333
332
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
333
|
+
}
|
|
334
|
+
var credentialTypesList: [String]? = nil
|
|
335
|
+
if let credentialTypesArr = (filterDictionary?["credentialTypes"] as? [String]) {
|
|
336
|
+
credentialTypesList = [String]()
|
|
337
|
+
for credentialType in credentialTypesArr {
|
|
338
|
+
credentialTypesList?.append(credentialType)
|
|
340
339
|
}
|
|
341
|
-
|
|
342
|
-
|
|
340
|
+
}
|
|
341
|
+
let serviceTypes: VCLServiceTypes? = serviceTypesList != nil ? VCLServiceTypes(all: serviceTypesList ?? [VCLServiceType]()) : nil
|
|
342
|
+
return VCLFilter(did: did, serviceTypes: serviceTypes, credentialTypes: credentialTypesList)
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
func dictionaryToPage(_ pageDictionary: [String:
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
345
|
+
func dictionaryToPage(_ pageDictionary: [String: Sendable]?) -> VCLPage {
|
|
346
|
+
return VCLPage(
|
|
347
|
+
size: pageDictionary?["size"] as? String,
|
|
348
|
+
skip: pageDictionary?["skip"] as? String
|
|
349
|
+
)
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
func organizationsToDictionary(
|
|
353
353
|
_ organizations: VCLOrganizations
|
|
354
|
-
) -> [String:
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
}
|
|
372
|
-
organizationMap["serviceCredentialAgentIssuers"] = serviceCredentialAgentIssuersArr
|
|
373
|
-
organizationMap["payload"] = organization.payload
|
|
374
|
-
organizationsArr.append(organizationMap)
|
|
354
|
+
) -> [String: Sendable] {
|
|
355
|
+
var organizationsMap = [String: Sendable]()
|
|
356
|
+
var organizationsArr = [[String: Sendable]]()
|
|
357
|
+
organizations.all.forEach { organization in
|
|
358
|
+
var organizationMap = [String: Sendable]()
|
|
359
|
+
organizationMap["payload"] = organization.payload
|
|
360
|
+
var serviceCredentialAgentIssuersArr = [[String: Sendable]]()
|
|
361
|
+
organization.serviceCredentialAgentIssuers.forEach { service in
|
|
362
|
+
var serviceCredentialAgentIssuerMap = [String: Sendable]()
|
|
363
|
+
if let credentialTypes = service.credentialTypes {
|
|
364
|
+
serviceCredentialAgentIssuerMap["credentialTypes"] = credentialTypes
|
|
365
|
+
}
|
|
366
|
+
serviceCredentialAgentIssuerMap["id"] = service.id
|
|
367
|
+
serviceCredentialAgentIssuerMap["type"] = service.type
|
|
368
|
+
serviceCredentialAgentIssuerMap["serviceEndpoint"] = service.serviceEndpoint
|
|
369
|
+
serviceCredentialAgentIssuerMap["payload"] = service.payload
|
|
370
|
+
serviceCredentialAgentIssuersArr.append(serviceCredentialAgentIssuerMap)
|
|
375
371
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
372
|
+
organizationMap["serviceCredentialAgentIssuers"] = serviceCredentialAgentIssuersArr
|
|
373
|
+
organizationMap["payload"] = organization.payload
|
|
374
|
+
organizationsArr.append(organizationMap)
|
|
375
|
+
}
|
|
376
|
+
organizationsMap["all"] = organizationsArr
|
|
377
|
+
return organizationsMap
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
func dictionaryToPushDelegate(_ pushDelegateMap: [String: Sendable]?) -> VCLPushDelegate? {
|
|
381
|
+
let pushUrl = pushDelegateMap?["pushUrl"] as? String
|
|
382
|
+
let pushToken = pushDelegateMap?["pushToken"] as? String
|
|
383
|
+
if (pushUrl != nil && pushToken != nil) {
|
|
384
|
+
return VCLPushDelegate(
|
|
385
|
+
pushUrl: pushUrl!,
|
|
386
|
+
pushToken: pushToken!
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
else { return nil }
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
func dictionaryToCredentialManifestDescriptor(
|
|
393
|
-
_ credentialManifestDescriptorDictionary: [String:
|
|
393
|
+
_ credentialManifestDescriptorDictionary: [String: Sendable]
|
|
394
394
|
) -> VCLCredentialManifestDescriptor? {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}
|
|
395
|
+
if (credentialManifestDescriptorDictionary["deepLink"] != nil) {
|
|
396
|
+
return dictionaryToCredentialManifestDescriptorByDeepLink(credentialManifestDescriptorDictionary)
|
|
397
|
+
} else if (credentialManifestDescriptorDictionary["service"] != nil) {
|
|
398
|
+
if(credentialManifestDescriptorDictionary["credentialIds"] != nil) {
|
|
399
|
+
return dictionaryToCredentialManifestDescriptorRefresh(credentialManifestDescriptorDictionary)
|
|
400
|
+
} else {
|
|
401
|
+
return dictionaryToCredentialManifestDescriptorByService(credentialManifestDescriptorDictionary)
|
|
403
402
|
}
|
|
404
|
-
|
|
403
|
+
}
|
|
404
|
+
return nil
|
|
405
405
|
}
|
|
406
406
|
|
|
407
407
|
func dictionaryToCredentialManifestDescriptorByDeepLink(
|
|
408
|
-
_ credentialManifestDescriptorByDeepLinkDictionary: [String:
|
|
408
|
+
_ credentialManifestDescriptorByDeepLinkDictionary: [String: Sendable]
|
|
409
409
|
) -> VCLCredentialManifestDescriptorByDeepLink {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
)
|
|
410
|
+
return VCLCredentialManifestDescriptorByDeepLink(
|
|
411
|
+
deepLink: dictionaryToDeepLink(
|
|
412
|
+
credentialManifestDescriptorByDeepLinkDictionary["deepLink"] as? [String : Sendable]
|
|
413
|
+
) ?? VCLDeepLink(value: ""),
|
|
414
|
+
issuingType: dictionaryToIssuingType(
|
|
415
|
+
issuingTypeDictionary: credentialManifestDescriptorByDeepLinkDictionary,
|
|
416
|
+
defaultIssuingType: VCLIssuingType.Career
|
|
417
|
+
),
|
|
418
|
+
pushDelegate: dictionaryToPushDelegate(credentialManifestDescriptorByDeepLinkDictionary["pushDelegate"] as? [String: Sendable]),
|
|
419
|
+
didJwk: dictionaryToDidJwk(credentialManifestDescriptorByDeepLinkDictionary["didJwk"] as? [String: Sendable]),
|
|
420
|
+
remoteCryptoServicesToken: dictionaryToToken(
|
|
421
|
+
credentialManifestDescriptorByDeepLinkDictionary["remoteCryptoServicesToken"] as? [String: Sendable]
|
|
423
422
|
)
|
|
423
|
+
)
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
func dictionaryToCredentialManifestDescriptorByService(
|
|
427
|
-
_ credentialManifestDescriptorByServiceDictionary: [String:
|
|
427
|
+
_ credentialManifestDescriptorByServiceDictionary: [String: Sendable]
|
|
428
428
|
) -> VCLCredentialManifestDescriptorByService {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
)
|
|
429
|
+
return VCLCredentialManifestDescriptorByService(
|
|
430
|
+
service: dictionaryToService(
|
|
431
|
+
credentialManifestDescriptorByServiceDictionary["service"] as? [String : Sendable]
|
|
432
|
+
),
|
|
433
|
+
issuingType: dictionaryToIssuingType(
|
|
434
|
+
issuingTypeDictionary: credentialManifestDescriptorByServiceDictionary,
|
|
435
|
+
defaultIssuingType: VCLIssuingType.Career
|
|
436
|
+
),
|
|
437
|
+
credentialTypes: credentialManifestDescriptorByServiceDictionary["credentialTypes"] as? [String],
|
|
438
|
+
pushDelegate: dictionaryToPushDelegate(
|
|
439
|
+
credentialManifestDescriptorByServiceDictionary["pushDelegate"] as? [String: Sendable]
|
|
440
|
+
),
|
|
441
|
+
didJwk: dictionaryToDidJwk(credentialManifestDescriptorByServiceDictionary["didJwk"] as? [String: Sendable]),
|
|
442
|
+
remoteCryptoServicesToken: dictionaryToToken(
|
|
443
|
+
credentialManifestDescriptorByServiceDictionary["remoteCryptoServicesToken"] as? [String: Sendable]
|
|
445
444
|
)
|
|
445
|
+
)
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
func dictionaryToCredentialManifestDescriptorRefresh(
|
|
449
|
-
_ credentialManifestDescriptorRefreshDictionary: [String:
|
|
449
|
+
_ credentialManifestDescriptorRefreshDictionary: [String: Sendable]
|
|
450
450
|
) -> VCLCredentialManifestDescriptorRefresh {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
)
|
|
451
|
+
return VCLCredentialManifestDescriptorRefresh(
|
|
452
|
+
service: dictionaryToService(
|
|
453
|
+
credentialManifestDescriptorRefreshDictionary["service"] as? [String : Sendable]
|
|
454
|
+
),
|
|
455
|
+
credentialIds: credentialManifestDescriptorRefreshDictionary["credentialIds"] as? [String] ?? [],
|
|
456
|
+
didJwk: dictionaryToDidJwk(credentialManifestDescriptorRefreshDictionary["didJwk"] as? [String: Sendable]),
|
|
457
|
+
remoteCryptoServicesToken: dictionaryToToken(
|
|
458
|
+
credentialManifestDescriptorRefreshDictionary["remoteCryptoServicesToken"] as? [String: Sendable]
|
|
460
459
|
)
|
|
460
|
+
)
|
|
461
461
|
}
|
|
462
462
|
|
|
463
463
|
func dictionaryToService(
|
|
464
|
-
_ serviceDictionary: [String:
|
|
464
|
+
_ serviceDictionary: [String: Sendable]?
|
|
465
465
|
) -> VCLService {
|
|
466
|
-
|
|
466
|
+
return VCLService(payload: serviceDictionary?["payload"] as? [String : Sendable] ?? [:])
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
func credentialManifestToDictionary(
|
|
470
470
|
_ credentialManifest: VCLCredentialManifest
|
|
471
|
-
) -> [String:
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
471
|
+
) -> [String: Sendable] {
|
|
472
|
+
var credentialManifestDictinary = [String: Sendable]()
|
|
473
|
+
credentialManifestDictinary["jwt"] = ["encodedJwt": credentialManifest.jwt.encodedJwt]
|
|
474
|
+
credentialManifestDictinary["did"] = credentialManifest.did
|
|
475
|
+
credentialManifestDictinary["iss"] = credentialManifest.iss
|
|
476
|
+
credentialManifestDictinary["exchangeId"] = credentialManifest.exchangeId
|
|
477
|
+
credentialManifestDictinary["vendorOriginContext"] = credentialManifest.vendorOriginContext
|
|
478
|
+
credentialManifestDictinary["verifiedProfile"] = credentialManifest.verifiedProfile.payload
|
|
479
|
+
credentialManifestDictinary["deepLink"] = deepLinkToDictionary(credentialManifest.deepLink)
|
|
480
|
+
credentialManifestDictinary["didJwk"] = didJwkToDictionary(credentialManifest.didJwk)
|
|
481
|
+
credentialManifestDictinary["remoteCryptoServicesToken"] = tokenToDictionary(credentialManifest.remoteCryptoServicesToken)
|
|
482
|
+
return credentialManifestDictinary
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
func dictionaryToCredentialManifest(
|
|
486
|
-
_ credentialManifestDictionary: [String:
|
|
486
|
+
_ credentialManifestDictionary: [String: Sendable]?
|
|
487
487
|
) -> VCLCredentialManifest {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
488
|
+
let jwt = VCLJwt(encodedJwt: (credentialManifestDictionary?["jwt"] as? [String: Sendable])?["encodedJwt"] as? String ?? "")
|
|
489
|
+
let vendorOriginContext = credentialManifestDictionary?["vendorOriginContext"] as? String
|
|
490
|
+
let verifiedProfileDictionary = credentialManifestDictionary?["verifiedProfile"] as? [String: Sendable]
|
|
491
|
+
let deepLink = dictionaryToDeepLink(credentialManifestDictionary?["deepLink"] as? [String: Sendable])
|
|
492
|
+
let didJwk = dictionaryToDidJwk(credentialManifestDictionary?["didJwk"] as? [String: Sendable])
|
|
493
|
+
let remoteCryptoServicesToken = dictionaryToToken(credentialManifestDictionary?["remoteCryptoServicesToken"] as? [String: Sendable])
|
|
494
|
+
|
|
495
|
+
return VCLCredentialManifest(
|
|
496
|
+
jwt: jwt,
|
|
497
|
+
vendorOriginContext: vendorOriginContext,
|
|
498
|
+
verifiedProfile: VCLVerifiedProfile(payload: verifiedProfileDictionary ?? [:]),
|
|
499
|
+
deepLink: deepLink,
|
|
500
|
+
didJwk: didJwk,
|
|
501
|
+
remoteCryptoServicesToken: remoteCryptoServicesToken
|
|
502
|
+
)
|
|
503
503
|
}
|
|
504
504
|
|
|
505
505
|
func dictionaryToGenerateOffersDescriptor(
|
|
506
|
-
_ generateOffersDescriptorDictionary: [String:
|
|
506
|
+
_ generateOffersDescriptorDictionary: [String: Sendable]
|
|
507
507
|
) -> VCLGenerateOffersDescriptor {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
}
|
|
508
|
+
let verifiableCredentialsArr = generateOffersDescriptorDictionary["identificationVerifiableCredentials"] as? [Sendable]
|
|
509
|
+
var verifiableCredentialsList: [VCLVerifiableCredential]? = nil
|
|
510
|
+
if let verifiableCredentials = verifiableCredentialsArr {
|
|
511
|
+
verifiableCredentialsList = [VCLVerifiableCredential]()
|
|
512
|
+
for i in 0..<verifiableCredentials.count {
|
|
513
|
+
let verifiableCredentialDict = verifiableCredentials[i] as? [String: String]
|
|
514
|
+
verifiableCredentialsList?.append(
|
|
515
|
+
VCLVerifiableCredential(
|
|
516
|
+
inputDescriptor: verifiableCredentialDict?["inputDescriptor"] ?? "",
|
|
517
|
+
jwtVc: verifiableCredentialDict?["jwtVc"] ?? ""
|
|
518
|
+
)
|
|
519
|
+
)
|
|
521
520
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
521
|
+
}
|
|
522
|
+
return VCLGenerateOffersDescriptor(
|
|
523
|
+
credentialManifest: dictionaryToCredentialManifest(generateOffersDescriptorDictionary["credentialManifest"] as? [String: Sendable]),
|
|
524
|
+
types: generateOffersDescriptorDictionary["types"] as? [String],
|
|
525
|
+
offerHashes: generateOffersDescriptorDictionary["offerHashes"] as? [String],
|
|
526
|
+
identificationVerifiableCredentials: verifiableCredentialsList
|
|
527
|
+
)
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
-
func offersToDictionary(_ offers: VCLOffers) -> [String:
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
530
|
+
func offersToDictionary(_ offers: VCLOffers) -> [String: Sendable] {
|
|
531
|
+
var offersDictionary = [String: Sendable]()
|
|
532
|
+
offersDictionary["payload"] = offers.payload
|
|
533
|
+
offersDictionary["all"] = allOffersToArray(offers.all)
|
|
534
|
+
offersDictionary["responseCode"] = offers.responseCode
|
|
535
|
+
offersDictionary["sessionToken"] = tokenToDictionary(offers.sessionToken)
|
|
536
|
+
offersDictionary["challenge"] = offers.challenge
|
|
537
|
+
return offersDictionary
|
|
538
538
|
}
|
|
539
539
|
|
|
540
|
-
func dictionaryToOffers(_ offersDictionary: [String :
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
540
|
+
func dictionaryToOffers(_ offersDictionary: [String : Sendable]?) -> VCLOffers {
|
|
541
|
+
return VCLOffers(
|
|
542
|
+
payload: offersDictionary?["payload"] as? [String: Sendable] ?? [String: Sendable](),
|
|
543
|
+
all: arrayToAllOffers(offersDictionary!["all"] as? [[String : Sendable]]),
|
|
544
|
+
responseCode: offersDictionary?["responseCode"] as? Int ?? 0,
|
|
545
|
+
sessionToken: dictionaryToToken(offersDictionary?["sessionToken"] as? [String: Sendable]),
|
|
546
|
+
challenge: offersDictionary?["challenge"] as? String ?? ""
|
|
547
|
+
)
|
|
548
548
|
}
|
|
549
549
|
|
|
550
|
-
func arrayToAllOffers(_ allOffersArray: [[String :
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
550
|
+
func arrayToAllOffers(_ allOffersArray: [[String : Sendable]]?) -> [VCLOffer] {
|
|
551
|
+
return allOffersArray?.map {
|
|
552
|
+
VCLOffer(payload: $0["payload"] as? [String : Sendable] ?? [:])
|
|
553
|
+
} ?? [VCLOffer(payload: [:])]
|
|
554
554
|
}
|
|
555
555
|
|
|
556
|
-
func allOffersToArray(_ allOffers: [VCLOffer]?) -> [[String :
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
556
|
+
func allOffersToArray(_ allOffers: [VCLOffer]?) -> [[String : Sendable]]? {
|
|
557
|
+
return allOffers?.map { [
|
|
558
|
+
"payload": $0.payload,
|
|
559
|
+
"issuerId": $0.issuerId,
|
|
560
|
+
"id": $0.id
|
|
561
|
+
] }
|
|
562
562
|
}
|
|
563
563
|
|
|
564
564
|
func credentialTypesFormSchemaToDictionary(
|
|
565
565
|
_ credentialTypesFormSchema: VCLCredentialTypesUIFormSchema
|
|
566
|
-
) -> [String:
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
566
|
+
) -> [String: Sendable] {
|
|
567
|
+
var credentialTypesFormSchemaDictionary = [String: Sendable]()
|
|
568
|
+
credentialTypesFormSchemaDictionary["payload"] = credentialTypesFormSchema.payload
|
|
569
|
+
return credentialTypesFormSchemaDictionary
|
|
570
570
|
}
|
|
571
571
|
|
|
572
572
|
func dictionaryToJwt(
|
|
573
|
-
_ jwtDictionary: [String:
|
|
573
|
+
_ jwtDictionary: [String: Sendable]?
|
|
574
574
|
) -> VCLJwt {
|
|
575
|
-
|
|
575
|
+
return VCLJwt(encodedJwt: jwtDictionary?["encodedJwt"] as? String ?? "")
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
-
func jwtToDictionary(_ jwt: VCLJwt) -> [String:
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
578
|
+
func jwtToDictionary(_ jwt: VCLJwt) -> [String: Sendable?] {
|
|
579
|
+
return [
|
|
580
|
+
"encodedJwt": jwt.encodedJwt,
|
|
581
|
+
"header": jwt.header,
|
|
582
|
+
"payload": jwt.payload,
|
|
583
|
+
"signature": jwt.signature
|
|
584
|
+
]
|
|
585
585
|
}
|
|
586
586
|
|
|
587
587
|
func dictionaryToPublicJwk(
|
|
588
|
-
_ publicJwkDictionary: [String:
|
|
588
|
+
_ publicJwkDictionary: [String: Sendable]?
|
|
589
589
|
) -> VCLPublicJwk {
|
|
590
|
-
|
|
590
|
+
return VCLPublicJwk(valueStr: (publicJwkDictionary?["valueStr"] as? String ?? ""))
|
|
591
591
|
}
|
|
592
592
|
|
|
593
593
|
func publicJwkToDictionary(
|
|
594
594
|
_ publicJwk: VCLPublicJwk?
|
|
595
|
-
) -> [String:
|
|
596
|
-
|
|
595
|
+
) -> [String: Sendable] {
|
|
596
|
+
return ["valueStr": publicJwk?.valueStr ?? ""]
|
|
597
597
|
}
|
|
598
598
|
|
|
599
599
|
func dictionaryToFinalizedOffersDescriptor(
|
|
600
|
-
_ finalizedOffersDescriptorDictionary: [String:
|
|
600
|
+
_ finalizedOffersDescriptorDictionary: [String: Sendable]
|
|
601
601
|
) -> VCLFinalizeOffersDescriptor {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
602
|
+
return VCLFinalizeOffersDescriptor(
|
|
603
|
+
credentialManifest: dictionaryToCredentialManifest(finalizedOffersDescriptorDictionary["credentialManifest"] as? [String : Sendable]),
|
|
604
|
+
challenge: finalizedOffersDescriptorDictionary["challenge"] as? String,
|
|
605
|
+
approvedOfferIds: finalizedOffersDescriptorDictionary["approvedOfferIds"] as? [String] ?? [String](),
|
|
606
|
+
rejectedOfferIds: finalizedOffersDescriptorDictionary["rejectedOfferIds"] as? [String] ?? [String]()
|
|
607
|
+
)
|
|
608
608
|
}
|
|
609
609
|
|
|
610
610
|
func jwtVerifiableCredentialsToDictionary(
|
|
611
611
|
_ jwtVerifiableCredentials: VCLJwtVerifiableCredentials
|
|
612
|
-
) -> [String:
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
612
|
+
) -> [String: Sendable] {
|
|
613
|
+
var jwtVerifiableCredentialsDictionary = [String: Sendable]()
|
|
614
|
+
let passedCredentials = jwtVerifiableCredentials.passedCredentials.map {
|
|
615
|
+
jwtToDictionary($0)
|
|
616
|
+
}
|
|
617
|
+
let failedCredentials = jwtVerifiableCredentials.failedCredentials.map {
|
|
618
|
+
jwtToDictionary($0)
|
|
619
|
+
}
|
|
620
|
+
jwtVerifiableCredentialsDictionary["passedCredentials"] = passedCredentials
|
|
621
|
+
jwtVerifiableCredentialsDictionary["failedCredentials"] = failedCredentials
|
|
622
|
+
return jwtVerifiableCredentialsDictionary
|
|
623
623
|
}
|
|
624
624
|
|
|
625
625
|
func readableMapToCredentialTypesUIFormSchemaDescriptor(
|
|
626
|
-
_ credentialTypesUIFormSchemaDescriptorDictionary: [String:
|
|
626
|
+
_ credentialTypesUIFormSchemaDescriptorDictionary: [String: Sendable]
|
|
627
627
|
) -> VCLCredentialTypesUIFormSchemaDescriptor {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
628
|
+
return VCLCredentialTypesUIFormSchemaDescriptor(
|
|
629
|
+
credentialType: credentialTypesUIFormSchemaDescriptorDictionary["credentialType"] as? String ?? "",
|
|
630
|
+
countryCode: credentialTypesUIFormSchemaDescriptorDictionary["countryCode"] as? String ?? ""
|
|
631
|
+
)
|
|
632
632
|
}
|
|
633
633
|
|
|
634
634
|
func dictionaryToVerifiedProfileDescriptor(
|
|
635
|
-
_ verifiedProfileDescriptor: [String:
|
|
635
|
+
_ verifiedProfileDescriptor: [String: Sendable]
|
|
636
636
|
) -> VCLVerifiedProfileDescriptor {
|
|
637
|
-
|
|
637
|
+
return VCLVerifiedProfileDescriptor(did: (verifiedProfileDescriptor["did"] as? String) ?? "")
|
|
638
638
|
}
|
|
639
639
|
|
|
640
640
|
func verifiedProfileToDictionary(
|
|
641
641
|
_ verifiedProfile: VCLVerifiedProfile
|
|
642
|
-
) -> [String:
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
642
|
+
) -> [String: Sendable] {
|
|
643
|
+
var verifiedProfileDictionary = [String: Sendable]()
|
|
644
|
+
verifiedProfileDictionary["payload"] = verifiedProfile.payload
|
|
645
|
+
verifiedProfileDictionary["id"] = verifiedProfile.id
|
|
646
|
+
verifiedProfileDictionary["logo"] = verifiedProfile.logo
|
|
647
|
+
verifiedProfileDictionary["name"] = verifiedProfile.name
|
|
648
|
+
return verifiedProfileDictionary
|
|
649
649
|
}
|
|
650
650
|
|
|
651
651
|
func dictionaryToVerifiedProfile(
|
|
652
|
-
_ verifiedProfileDictionary: [String:
|
|
652
|
+
_ verifiedProfileDictionary: [String: Sendable]?
|
|
653
653
|
) -> VCLVerifiedProfile {
|
|
654
|
-
|
|
654
|
+
return VCLVerifiedProfile(payload: verifiedProfileDictionary?["payload"] as? [String : Sendable] ?? [String : Sendable]())
|
|
655
655
|
}
|
|
656
656
|
|
|
657
657
|
func dictionaryToJwtDescriptor(
|
|
658
|
-
_ jwtDescriptorDictionary: [String:
|
|
658
|
+
_ jwtDescriptorDictionary: [String: Sendable]
|
|
659
659
|
) -> VCLJwtDescriptor {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
func didJwkToDictionary(_ didJwk: VCLDidJwk) -> [String:
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
func dictionaryToDidJwk(_ didJwkDictionary: [String:
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
func dictionaryToDidJwkDescriptor(_ didJwkDescriptorDictionary: [String:
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
660
|
+
return VCLJwtDescriptor(
|
|
661
|
+
payload: jwtDescriptorDictionary["payload"] as? [String: Sendable] ?? [String: Sendable](),
|
|
662
|
+
jti: jwtDescriptorDictionary["jti"] as? String ?? "",
|
|
663
|
+
iss: jwtDescriptorDictionary["iss"] as? String ?? ""
|
|
664
|
+
)
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
func didJwkToDictionary(_ didJwk: VCLDidJwk) -> [String: Sendable] {
|
|
668
|
+
return [
|
|
669
|
+
"did": didJwk.did,
|
|
670
|
+
"publicJwk": publicJwkToDictionary(didJwk.publicJwk),
|
|
671
|
+
"kid": didJwk.kid,
|
|
672
|
+
"keyId": didJwk.keyId
|
|
673
|
+
]
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
func dictionaryToDidJwk(_ didJwkDictionary: [String: Sendable]?) -> VCLDidJwk {
|
|
677
|
+
return VCLDidJwk(
|
|
678
|
+
did: didJwkDictionary?["did"] as? String ?? "",
|
|
679
|
+
publicJwk: dictionaryToPublicJwk(didJwkDictionary?["publicJwk"] as? [String : Sendable]),
|
|
680
|
+
kid: didJwkDictionary?["kid"] as? String ?? "",
|
|
681
|
+
keyId: didJwkDictionary?["keyId"] as? String ?? ""
|
|
682
|
+
)
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
func dictionaryToDidJwkDescriptor(_ didJwkDescriptorDictionary: [String: Sendable]?) -> VCLDidJwkDescriptor {
|
|
686
|
+
return VCLDidJwkDescriptor(
|
|
687
|
+
signatureAlgorithm: VCLSignatureAlgorithm.fromString(value: didJwkDescriptorDictionary?["signatureAlgorithm"] as? String ?? ""),
|
|
688
|
+
remoteCryptoServicesToken: dictionaryToToken(didJwkDescriptorDictionary?["remoteCryptoServicesToken"] as? [String: Sendable])
|
|
689
|
+
)
|
|
690
690
|
}
|