@velocitycareerlabs/vcl-react-native 2.0.1 → 2.2.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 (44) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/io/velocitycareerlabs/reactnative/VclReactNativeModule.kt +2 -18
  3. package/android/src/main/java/io/velocitycareerlabs/reactnative/utlis/Converter.kt +57 -20
  4. package/ios/Utils/Converter.swift +53 -21
  5. package/ios/VclReactNative.mm +2 -10
  6. package/ios/VclReactNative.swift +8 -24
  7. package/lib/commonjs/api/VCLApi.js +12 -12
  8. package/lib/commonjs/api/VCLApi.js.map +1 -1
  9. package/lib/commonjs/api/VCLSignatureAlgorithm.js +18 -0
  10. package/lib/commonjs/api/VCLSignatureAlgorithm.js.map +1 -0
  11. package/lib/commonjs/index.js +7 -0
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/module/api/VCLApi.js +12 -12
  14. package/lib/module/api/VCLApi.js.map +1 -1
  15. package/lib/module/api/VCLSignatureAlgorithm.js +13 -0
  16. package/lib/module/api/VCLSignatureAlgorithm.js.map +1 -0
  17. package/lib/module/index.js +2 -1
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/typescript/api/VCLApi.d.ts +6 -6
  20. package/lib/typescript/api/VCLApi.d.ts.map +1 -1
  21. package/lib/typescript/api/VCLSignatureAlgorithm.d.ts +11 -0
  22. package/lib/typescript/api/VCLSignatureAlgorithm.d.ts.map +1 -0
  23. package/lib/typescript/api/entities/VCLCredentialManifest.d.ts +4 -0
  24. package/lib/typescript/api/entities/VCLCredentialManifest.d.ts.map +1 -1
  25. package/lib/typescript/api/entities/VCLCredentialManifestDescriptor.d.ts +4 -0
  26. package/lib/typescript/api/entities/VCLCredentialManifestDescriptor.d.ts.map +1 -1
  27. package/lib/typescript/api/entities/VCLPresentationRequest.d.ts +4 -0
  28. package/lib/typescript/api/entities/VCLPresentationRequest.d.ts.map +1 -1
  29. package/lib/typescript/api/entities/VCLPresentationRequestDescriptor.d.ts +4 -0
  30. package/lib/typescript/api/entities/VCLPresentationRequestDescriptor.d.ts.map +1 -1
  31. package/lib/typescript/api/entities/initialization/VCLCryptoServicesDescriptor.d.ts +2 -0
  32. package/lib/typescript/api/entities/initialization/VCLCryptoServicesDescriptor.d.ts.map +1 -1
  33. package/lib/typescript/index.d.ts +2 -1
  34. package/lib/typescript/index.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/api/VCLApi.ts +12 -32
  37. package/src/api/VCLSignatureAlgorithm.ts +11 -0
  38. package/src/api/entities/VCLCredentialManifest.ts +4 -0
  39. package/src/api/entities/VCLCredentialManifestDescriptor.ts +4 -0
  40. package/src/api/entities/VCLPresentationRequest.ts +4 -0
  41. package/src/api/entities/VCLPresentationRequestDescriptor.ts +4 -0
  42. package/src/api/entities/initialization/VCLCryptoServicesDescriptor.ts +2 -0
  43. package/src/index.tsx +2 -0
  44. package/velocitycareerlabs-vcl-react-native.podspec +1 -1
@@ -100,7 +100,7 @@ dependencies {
100
100
 
101
101
  // VCL:
102
102
  implementation "com.nimbusds:nimbus-jose-jwt:9.37"
103
- implementation "io.velocitycareerlabs:vcl:2.0.0"
103
+ implementation "io.velocitycareerlabs:vcl:2.2.0"
104
104
  }
105
105
 
106
106
  if (isNewArchitectureEnabled()) {
@@ -123,13 +123,11 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
123
123
  @ReactMethod
124
124
  fun getPresentationRequest(
125
125
  presentationRequestDescriptorMap: ReadableMap,
126
- remoteCryptoServicesTokenMap: ReadableMap? = null,
127
126
  promise: Promise
128
127
  ) {
129
128
  try {
130
129
  vcl.getPresentationRequest(
131
130
  presentationRequestDescriptor = mapTopPresentationRequestDescriptor(presentationRequestDescriptorMap),
132
- remoteCryptoServicesToken = mapToToken(remoteCryptoServicesTokenMap),
133
131
  successHandler = {
134
132
  promise.resolve(presentationRequestToMap(it))
135
133
  },
@@ -144,15 +142,11 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
144
142
  @ReactMethod
145
143
  fun submitPresentation(
146
144
  presentationSubmissionMap: ReadableMap,
147
- didJwkMap: ReadableMap,
148
- remoteCryptoServicesTokenMap: ReadableMap? = null,
149
145
  promise: Promise
150
146
  ) {
151
147
  try {
152
148
  vcl.submitPresentation(
153
149
  presentationSubmission = mapToPresentationSubmission(presentationSubmissionMap),
154
- didJwk = mapToDidJwk(didJwkMap),
155
- remoteCryptoServicesToken = mapToToken(remoteCryptoServicesTokenMap),
156
150
  successHandler = {
157
151
  promise.resolve(presentationSubmissionResultToMap(it))
158
152
  },
@@ -204,7 +198,6 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
204
198
  @ReactMethod
205
199
  fun getCredentialManifest(
206
200
  credentialManifestDescriptorMap: ReadableMap,
207
- remoteCryptoServicesTokenMap: ReadableMap? = null,
208
201
  promise: Promise
209
202
  ) {
210
203
  try {
@@ -216,7 +209,6 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
216
209
  )
217
210
  vcl.getCredentialManifest(
218
211
  credentialManifestDescriptor,
219
- mapToToken(remoteCryptoServicesTokenMap),
220
212
  successHandler = {
221
213
  promise.resolve(credentialManifestToMap(it))
222
214
  },
@@ -234,15 +226,11 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
234
226
  @ReactMethod
235
227
  fun generateOffers(
236
228
  generateOffersDescriptorMap: ReadableMap,
237
- didJwkMap: ReadableMap,
238
- remoteCryptoServicesTokenMap: ReadableMap? = null,
239
229
  promise: Promise
240
230
  ) {
241
231
  try {
242
232
  vcl.generateOffers(
243
233
  generateOffersDescriptor = mapToGenerateOffersDescriptor(generateOffersDescriptorMap),
244
- didJwk = mapToDidJwk(didJwkMap),
245
- remoteCryptoServicesToken = mapToToken(remoteCryptoServicesTokenMap),
246
234
  successHandler = {
247
235
  promise.resolve(offersToMap(it))
248
236
  },
@@ -278,17 +266,13 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
278
266
  @ReactMethod
279
267
  fun finalizeOffers(
280
268
  finalizeOffersDescriptorMap: ReadableMap,
281
- didJwkMap: ReadableMap,
282
269
  sessionTokenMap: ReadableMap,
283
- remoteCryptoServicesTokenMap: ReadableMap? = null,
284
270
  promise: Promise
285
271
  ) {
286
272
  try {
287
273
  vcl.finalizeOffers(
288
274
  finalizeOffersDescriptor = mapToFinalizedOffersDescriptor(finalizeOffersDescriptorMap),
289
- didJwk = mapToDidJwk(didJwkMap),
290
275
  sessionToken = mapToToken(sessionTokenMap),
291
- remoteCryptoServicesToken = mapToToken(remoteCryptoServicesTokenMap),
292
276
  successHandler = {
293
277
  promise.resolve(jwtVerifiableCredentialsToMap(it))
294
278
  },
@@ -363,15 +347,15 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
363
347
 
364
348
  @ReactMethod
365
349
  fun generateSignedJwt(
366
- didJwkMap: ReadableMap,
367
350
  jwtDescriptorMap: ReadableMap,
351
+ didJwkMap: ReadableMap,
368
352
  remoteCryptoServicesTokenMap: ReadableMap? = null,
369
353
  promise: Promise
370
354
  ) {
371
355
  try {
372
356
  vcl.generateSignedJwt(
373
- didJwk = mapToDidJwk(didJwkMap),
374
357
  jwtDescriptor = mapToJwtDescriptor(jwtDescriptorMap),
358
+ didJwk = mapToDidJwk(didJwkMap),
375
359
  remoteCryptoServicesToken = mapToToken(remoteCryptoServicesTokenMap),
376
360
  successHandler = {
377
361
  promise.resolve(Converter.jwtToMap(it))
@@ -46,6 +46,10 @@ object Converter {
46
46
  VCLCryptoServiceType.fromString(
47
47
  cryptoServicesDescriptorMap?.getStringOpt("cryptoServiceType") ?: ""
48
48
  )
49
+ val signatureAlgorithm =
50
+ VCLSignatureAlgorithm.fromString(
51
+ cryptoServicesDescriptorMap?.getStringOpt("signatureAlgorithm") ?: ""
52
+ )
49
53
  val remoteCryptoServicesUrlsDescriptorMap =
50
54
  cryptoServicesDescriptorMap?.getMap("remoteCryptoServicesUrlsDescriptor")
51
55
  val keyServiceUrls = remoteCryptoServicesUrlsDescriptorMap?.getMapOpt("keyServiceUrls")
@@ -61,6 +65,7 @@ object Converter {
61
65
  )
62
66
  return VCLCryptoServicesDescriptor(
63
67
  cryptoServiceType = cryptoServiceType,
68
+ signatureAlgorithm = signatureAlgorithm,
64
69
  remoteCryptoServicesUrlsDescriptor = remoteCryptoServicesUrlsDescriptor
65
70
  )
66
71
  }
@@ -166,7 +171,13 @@ object Converter {
166
171
  VCLPresentationRequestDescriptor(
167
172
  deepLink = mapToDeepLink(presentationRequestDescriptorLinkMap.getMapOpt("deepLink"))
168
173
  ?: VCLDeepLink(""),
169
- pushDelegate = mapToPushDelegate(presentationRequestDescriptorLinkMap.getMapOpt("pushDelegate"))
174
+ pushDelegate = mapToPushDelegate(
175
+ presentationRequestDescriptorLinkMap.getMapOpt("pushDelegate")
176
+ ),
177
+ didJwk = mapToDidJwk(presentationRequestDescriptorLinkMap.getMapOpt("didJwk")),
178
+ remoteCryptoServicesToken = mapToToken(
179
+ presentationRequestDescriptorLinkMap.getMapOpt("remoteCryptoServicesToken")
180
+ )
170
181
  )
171
182
 
172
183
  fun mapToDeepLink(deepLinkMap: ReadableMap?): VCLDeepLink? {
@@ -196,10 +207,10 @@ object Converter {
196
207
  fun mapToToken(tokenMap: ReadableMap?) =
197
208
  VCLToken(tokenMap?.getStringOpt("value") ?: "")
198
209
 
199
- fun tokenToMap(token: VCLToken): ReadableMap {
210
+ fun tokenToMap(token: VCLToken?): ReadableMap {
200
211
  val retVal = Arguments.createMap()
201
- retVal.putString("value", token.value)
202
- token.expiresIn?.toDouble()?.let {
212
+ retVal.putString("value", token?.value)
213
+ token?.expiresIn?.toDouble()?.let {
203
214
  retVal.putDouble("expiresIn", it)
204
215
  }
205
216
  return retVal
@@ -208,9 +219,12 @@ object Converter {
208
219
  fun mapToPresentationRequest(
209
220
  presentationRequestMap: ReadableMap?
210
221
  ) = VCLPresentationRequest(
211
- mapToJwt(presentationRequestMap?.getMapOpt("jwt")),
212
- mapToPublicJwk(presentationRequestMap?.getMapOpt("publicJwk")),
213
- mapToDeepLink(presentationRequestMap?.getMapOpt("deepLink")) ?: VCLDeepLink("")
222
+ jwt = mapToJwt(presentationRequestMap?.getMapOpt("jwt")),
223
+ publicJwk = mapToPublicJwk(presentationRequestMap?.getMapOpt("publicJwk")),
224
+ deepLink = mapToDeepLink(presentationRequestMap?.getMapOpt("deepLink")) ?: VCLDeepLink(""),
225
+ pushDelegate = mapToPushDelegate(presentationRequestMap?.getMapOpt("pushDelegate")),
226
+ didJwk = mapToDidJwk(presentationRequestMap?.getMapOpt("didJwk")),
227
+ remoteCryptoServicesToken = mapToToken(presentationRequestMap?.getMapOpt("remoteCryptoServicesToken"))
214
228
  )
215
229
 
216
230
  fun presentationRequestToMap(
@@ -230,6 +244,8 @@ object Converter {
230
244
  presentationRequest.presentationDefinitionId
231
245
  )
232
246
  presentationRequestMap.putMap("deepLink", deepLinkToMap(presentationRequest.deepLink))
247
+ presentationRequestMap.putMap("didJwk", didJwkToMap(presentationRequest.didJwk))
248
+ presentationRequestMap.putMap("remoteCryptoServicesToken", tokenToMap(presentationRequest.remoteCryptoServicesToken))
233
249
  return presentationRequestMap
234
250
  }
235
251
 
@@ -427,18 +443,22 @@ object Converter {
427
443
  credentialManifestDescriptorByDeepLinkMap: ReadableMap
428
444
  ): VCLCredentialManifestDescriptorByDeepLink {
429
445
  return VCLCredentialManifestDescriptorByDeepLink(
430
- mapToDeepLink(credentialManifestDescriptorByDeepLinkMap.getMapOpt("deepLink"))
446
+ deepLink = mapToDeepLink(credentialManifestDescriptorByDeepLinkMap.getMapOpt("deepLink"))
431
447
  ?: VCLDeepLink(""),
432
- mapToIssuingType(credentialManifestDescriptorByDeepLinkMap, VCLIssuingType.Career),
433
- mapToPushDelegate(credentialManifestDescriptorByDeepLinkMap.getMapOpt("pushDelegate"))
448
+ issuingType = mapToIssuingType(credentialManifestDescriptorByDeepLinkMap, VCLIssuingType.Career),
449
+ pushDelegate = mapToPushDelegate(
450
+ credentialManifestDescriptorByDeepLinkMap.getMapOpt("pushDelegate")
451
+ ),
452
+ didJwk = mapToDidJwk(credentialManifestDescriptorByDeepLinkMap.getMapOpt("didJwk")),
453
+ remoteCryptoServicesToken = mapToToken(
454
+ credentialManifestDescriptorByDeepLinkMap.getMapOpt("remoteCryptoServicesToken")
455
+ )
434
456
  )
435
457
  }
436
458
 
437
459
  fun mapToCredentialManifestDescriptorByService(
438
460
  credentialManifestDescriptorByServiceMap: ReadableMap
439
461
  ): VCLCredentialManifestDescriptorByService {
440
- val pushDelegate =
441
- mapToPushDelegate(credentialManifestDescriptorByServiceMap.getMapOpt("pushDelegate"))
442
462
  return VCLCredentialManifestDescriptorByService(
443
463
  service = mapToServiceCredentialAgentIssuer(
444
464
  credentialManifestDescriptorByServiceMap.getMapOpt("service")
@@ -450,7 +470,13 @@ object Converter {
450
470
  credentialTypes =
451
471
  (credentialManifestDescriptorByServiceMap.getArrayOpt("credentialTypes")?.toArrayList()
452
472
  ?.toList() as? List<String>),
453
- pushDelegate = pushDelegate
473
+ pushDelegate = mapToPushDelegate(
474
+ credentialManifestDescriptorByServiceMap.getMapOpt("pushDelegate")
475
+ ),
476
+ didJwk = mapToDidJwk(credentialManifestDescriptorByServiceMap.getMapOpt("didJwk")),
477
+ remoteCryptoServicesToken = mapToToken(
478
+ credentialManifestDescriptorByServiceMap.getMapOpt("remoteCryptoServicesToken")
479
+ )
454
480
  )
455
481
  }
456
482
 
@@ -462,7 +488,11 @@ object Converter {
462
488
  credentialManifestDescriptorRefreshMap.getMapOpt("service")
463
489
  ),
464
490
  credentialIds = credentialManifestDescriptorRefreshMap.getArrayOpt("credentialIds")
465
- ?.toArrayList()?.toList() as? List<String> ?: listOf()
491
+ ?.toArrayList()?.toList() as? List<String> ?: listOf(),
492
+ didJwk = mapToDidJwk(credentialManifestDescriptorRefreshMap.getMapOpt("didJwk")),
493
+ remoteCryptoServicesToken = mapToToken(
494
+ credentialManifestDescriptorRefreshMap.getMapOpt("remoteCryptoServicesToken")
495
+ )
466
496
  )
467
497
  }
468
498
 
@@ -489,6 +519,8 @@ object Converter {
489
519
  credentialManifest.verifiedProfile.payload.toReadableMap()
490
520
  )
491
521
  credentialManifestMap.putMap("deepLink", deepLinkToMap(credentialManifest.deepLink))
522
+ credentialManifestMap.putMap("didJwk", didJwkToMap(credentialManifest.didJwk))
523
+ credentialManifestMap.putMap("remoteCryptoServicesToken", tokenToMap(credentialManifest.remoteCryptoServicesToken))
492
524
  return credentialManifestMap
493
525
  }
494
526
 
@@ -500,13 +532,18 @@ object Converter {
500
532
  val vendorOriginContext: String? = credentialManifestMap?.getStringOpt("vendorOriginContext")
501
533
  val verifiedProfileMap: ReadableMap? = credentialManifestMap?.getMapOpt("verifiedProfile")
502
534
  val deepLinkMap: ReadableMap? = credentialManifestMap?.getMapOpt("deepLink")
535
+ val didJwkMap: ReadableMap? = credentialManifestMap?.getMapOpt("didJwk")
536
+ val remoteCryptoServicesTokenMap = credentialManifestMap?.getMapOpt("remoteCryptoServicesToken")
537
+
503
538
  return VCLCredentialManifest(
504
539
  jwt = jwt,
505
540
  vendorOriginContext = vendorOriginContext,
506
541
  verifiedProfile = VCLVerifiedProfile(
507
542
  payload = verifiedProfileMap?.toJsonObject() ?: JSONObject()
508
543
  ),
509
- deepLink = mapToDeepLink(deepLinkMap)
544
+ deepLink = mapToDeepLink(deepLinkMap),
545
+ didJwk = mapToDidJwk(didJwkMap),
546
+ remoteCryptoServicesToken = mapToToken(remoteCryptoServicesTokenMap)
510
547
  )
511
548
  }
512
549
 
@@ -677,12 +714,12 @@ object Converter {
677
714
  return didJwkMap
678
715
  }
679
716
 
680
- fun mapToDidJwk(didJwkMap: ReadableMap): VCLDidJwk {
717
+ fun mapToDidJwk(didJwkMap: ReadableMap?): VCLDidJwk {
681
718
  return VCLDidJwk(
682
- did = didJwkMap.getStringOpt("did") ?: "",
683
- publicJwk = mapToPublicJwk(didJwkMap.getMap("publicJwk")),
684
- kid = didJwkMap.getStringOpt("kid") ?: "",
685
- keyId = didJwkMap.getStringOpt("keyId") ?: ""
719
+ did = didJwkMap?.getStringOpt("did") ?: "",
720
+ publicJwk = mapToPublicJwk(didJwkMap?.getMap("publicJwk")),
721
+ kid = didJwkMap?.getStringOpt("kid") ?: "",
722
+ keyId = didJwkMap?.getStringOpt("keyId") ?: ""
686
723
  )
687
724
  }
688
725
  }
@@ -43,6 +43,9 @@ private func dictionaryToCryptoServicesDescriptor(
43
43
  VCLCryptoServiceType.fromString(
44
44
  value: cryptoServicesDescriptorDictionary?["cryptoServiceType"] as? String ?? ""
45
45
  )
46
+ let signatureAlgorithm = VCLSignatureAlgorithm.fromString(
47
+ value: cryptoServicesDescriptorDictionary?["signatureAlgorithm"] as? String ?? ""
48
+ )
46
49
  let remoteCryptoServicesUrlsDescriptorDictionary = cryptoServicesDescriptorDictionary?["remoteCryptoServicesUrlsDescriptor"] as? [String: Any]
47
50
  let keyServiceUrls = remoteCryptoServicesUrlsDescriptorDictionary?["keyServiceUrls"] as? [String: Any]
48
51
  let jwtServiceUrls = remoteCryptoServicesUrlsDescriptorDictionary?["jwtServiceUrls"] as? [String: Any]
@@ -57,6 +60,7 @@ private func dictionaryToCryptoServicesDescriptor(
57
60
  )
58
61
  return VCLCryptoServicesDescriptor(
59
62
  cryptoServiceType: cryptoServiceType,
63
+ signatureAlgorithm: signatureAlgorithm,
60
64
  remoteCryptoServicesUrlsDescriptor: remoteCryptoServicesUrlsDescriptor
61
65
  )
62
66
  }
@@ -165,7 +169,11 @@ func dictionaryTopPresentationRequestDescriptor(
165
169
  ) -> VCLPresentationRequestDescriptor {
166
170
  return VCLPresentationRequestDescriptor(
167
171
  deepLink: dictionaryToDeepLink(presentationRequestDescriptorLinkDictionary["deepLink"] as? [String: Any]) ?? VCLDeepLink(value: ""),
168
- pushDelegate: dictionaryToPushDelegate(presentationRequestDescriptorLinkDictionary["pushDelegate"] as? [String: Any])
172
+ pushDelegate: dictionaryToPushDelegate(presentationRequestDescriptorLinkDictionary["pushDelegate"] as? [String: Any]),
173
+ didJwk: dictionaryToDidJwk(presentationRequestDescriptorLinkDictionary["didJwk"] as? [String: Any]),
174
+ remoteCryptoServicesToken: dictionaryToToken(
175
+ presentationRequestDescriptorLinkDictionary["remoteCryptoServicesToken"] as? [String: Any]
176
+ )
169
177
  )
170
178
  }
171
179
 
@@ -187,10 +195,10 @@ func dictionaryToToken(_ tokenDictionary: [String: Any]?) -> VCLToken {
187
195
  return VCLToken(value: tokenDictionary?["value"] as? String ?? "")
188
196
  }
189
197
 
190
- func tokenToDictionary(_ token: VCLToken) -> [String: Any] {
198
+ func tokenToDictionary(_ token: VCLToken?) -> [String: Any] {
191
199
  var retVal = [String: Any]()
192
- retVal["value"] = token.value
193
- if let expiresIn = token.expiresIn {
200
+ retVal["value"] = token?.value
201
+ if let expiresIn = token?.expiresIn {
194
202
  retVal["expiresIn"] = expiresIn
195
203
  }
196
204
  return retVal
@@ -212,7 +220,10 @@ func dictionaryToPresentationRequest(
212
220
  return VCLPresentationRequest(
213
221
  jwt: dictionaryToJwt(presentationRequestDictionary?["jwt"] as? [String : Any]),
214
222
  publicJwk: dictionaryToPublicJwk(presentationRequestDictionary?["publicJwk"] as? [String: Any]),
215
- deepLink: dictionaryToDeepLink(presentationRequestDictionary?["deepLink"] as? [String : Any]) ?? VCLDeepLink(value: "")
223
+ deepLink: dictionaryToDeepLink(presentationRequestDictionary?["deepLink"] as? [String : Any]) ?? VCLDeepLink(value: ""),
224
+ pushDelegate: dictionaryToPushDelegate(presentationRequestDictionary?["pushDelegate"] as? [String : Any]),
225
+ didJwk: dictionaryToDidJwk(presentationRequestDictionary?["didJwk"] as? [String : Any]),
226
+ remoteCryptoServicesToken: dictionaryToToken(presentationRequestDictionary?["remoteCryptoServicesToken"] as? [String : Any])
216
227
  )
217
228
  }
218
229
 
@@ -228,6 +239,8 @@ func presentationRequestToDictionary(
228
239
  presentationRequestDictionary["exchangeId"] = presentationRequest.exchangeId
229
240
  presentationRequestDictionary["presentationDefinitionId"] = presentationRequest.presentationDefinitionId
230
241
  presentationRequestDictionary["deepLink"] = deepLinkToDictionary(presentationRequest.deepLink)
242
+ presentationRequestDictionary["didJwk"] = didJwkToDictionary(presentationRequest.didJwk)
243
+ presentationRequestDictionary["remoteCryptoServicesToken"] = tokenToDictionary(presentationRequest.remoteCryptoServicesToken)
231
244
  return presentationRequestDictionary
232
245
  }
233
246
 
@@ -408,15 +421,17 @@ func dictionaryToCredentialManifestDescriptorByDeepLink(
408
421
  issuingTypeDictionary: credentialManifestDescriptorByDeepLinkDictionary,
409
422
  defaultIssuingType: VCLIssuingType.Career
410
423
  ),
411
- pushDelegate: dictionaryToPushDelegate(credentialManifestDescriptorByDeepLinkDictionary["pushDelegate"] as? [String: Any])
424
+ pushDelegate: dictionaryToPushDelegate(credentialManifestDescriptorByDeepLinkDictionary["pushDelegate"] as? [String: Any]),
425
+ didJwk: dictionaryToDidJwk(credentialManifestDescriptorByDeepLinkDictionary["didJwk"] as? [String: Any]),
426
+ remoteCryptoServicesToken: dictionaryToToken(
427
+ credentialManifestDescriptorByDeepLinkDictionary["remoteCryptoServicesToken"] as? [String: Any]
428
+ )
412
429
  )
413
430
  }
414
431
 
415
432
  func dictionaryToCredentialManifestDescriptorByService(
416
433
  _ credentialManifestDescriptorByServiceDictionary: [String: Any]
417
434
  ) -> VCLCredentialManifestDescriptorByService {
418
- let pushDelegateDictionary = credentialManifestDescriptorByServiceDictionary["pushDelegate"] as? [String: Any]
419
- let pushDelegate = dictionaryToPushDelegate(pushDelegateDictionary)
420
435
  return VCLCredentialManifestDescriptorByService(
421
436
  service: dictionaryToServiceCredentialAgentIssuer(
422
437
  credentialManifestDescriptorByServiceDictionary["service"] as? [String : Any]
@@ -426,7 +441,13 @@ func dictionaryToCredentialManifestDescriptorByService(
426
441
  defaultIssuingType: VCLIssuingType.Career
427
442
  ),
428
443
  credentialTypes: credentialManifestDescriptorByServiceDictionary["credentialTypes"] as? [String],
429
- pushDelegate: pushDelegate
444
+ pushDelegate: dictionaryToPushDelegate(
445
+ credentialManifestDescriptorByServiceDictionary["pushDelegate"] as? [String: Any]
446
+ ),
447
+ didJwk: dictionaryToDidJwk(credentialManifestDescriptorByServiceDictionary["didJwk"] as? [String: Any]),
448
+ remoteCryptoServicesToken: dictionaryToToken(
449
+ credentialManifestDescriptorByServiceDictionary["remoteCryptoServicesToken"] as? [String: Any]
450
+ )
430
451
  )
431
452
  }
432
453
 
@@ -437,14 +458,18 @@ func dictionaryToCredentialManifestDescriptorRefresh(
437
458
  service: dictionaryToServiceCredentialAgentIssuer(
438
459
  credentialManifestDescriptorRefreshDictionary["service"] as? [String : Any]
439
460
  ),
440
- credentialIds: credentialManifestDescriptorRefreshDictionary["credentialIds"] as? [String] ?? [String]()
461
+ credentialIds: credentialManifestDescriptorRefreshDictionary["credentialIds"] as? [String] ?? [],
462
+ didJwk: dictionaryToDidJwk(credentialManifestDescriptorRefreshDictionary["didJwk"] as? [String: Any]),
463
+ remoteCryptoServicesToken: dictionaryToToken(
464
+ credentialManifestDescriptorRefreshDictionary["remoteCryptoServicesToken"] as? [String: Any]
465
+ )
441
466
  )
442
467
  }
443
468
 
444
469
  func dictionaryToServiceCredentialAgentIssuer(
445
470
  _ serviceDictionary: [String: Any]?
446
471
  ) -> VCLServiceCredentialAgentIssuer {
447
- return VCLServiceCredentialAgentIssuer(payload: serviceDictionary?["payload"] as? [String : Any] ?? [String: Any]())
472
+ return VCLServiceCredentialAgentIssuer(payload: serviceDictionary?["payload"] as? [String : Any] ?? [:])
448
473
  }
449
474
 
450
475
  func credentialManifestToDictionary(
@@ -458,21 +483,28 @@ func credentialManifestToDictionary(
458
483
  credentialManifestDictinary["vendorOriginContext"] = credentialManifest.vendorOriginContext
459
484
  credentialManifestDictinary["verifiedProfile"] = credentialManifest.verifiedProfile.payload
460
485
  credentialManifestDictinary["deepLink"] = deepLinkToDictionary(credentialManifest.deepLink)
486
+ credentialManifestDictinary["didJwk"] = didJwkToDictionary(credentialManifest.didJwk)
487
+ credentialManifestDictinary["remoteCryptoServicesToken"] = tokenToDictionary(credentialManifest.remoteCryptoServicesToken)
461
488
  return credentialManifestDictinary
462
489
  }
463
490
 
464
491
  func dictionaryToCredentialManifest(
465
492
  _ credentialManifestDictionary: [String: Any]?
466
493
  ) -> VCLCredentialManifest {
467
- let jwt: VCLJwt = VCLJwt(encodedJwt: (credentialManifestDictionary?["jwt"] as? [String: Any])?["encodedJwt"] as? String ?? "")
468
- let vendorOriginContext: String? = credentialManifestDictionary?["vendorOriginContext"] as? String
469
- let verifiedProfileDictionary: [String: Any]? = credentialManifestDictionary?["verifiedProfile"] as? [String: Any]
470
- let deepLink: VCLDeepLink? = dictionaryToDeepLink(credentialManifestDictionary?["deepLink"] as? [String: Any])
494
+ let jwt = VCLJwt(encodedJwt: (credentialManifestDictionary?["jwt"] as? [String: Any])?["encodedJwt"] as? String ?? "")
495
+ let vendorOriginContext = credentialManifestDictionary?["vendorOriginContext"] as? String
496
+ let verifiedProfileDictionary = credentialManifestDictionary?["verifiedProfile"] as? [String: Any]
497
+ let deepLink = dictionaryToDeepLink(credentialManifestDictionary?["deepLink"] as? [String: Any])
498
+ let didJwk = dictionaryToDidJwk(credentialManifestDictionary?["didJwk"] as? [String: Any])
499
+ let remoteCryptoServicesToken = dictionaryToToken(credentialManifestDictionary?["remoteCryptoServicesToken"] as? [String: Any])
500
+
471
501
  return VCLCredentialManifest(
472
502
  jwt: jwt,
473
503
  vendorOriginContext: vendorOriginContext,
474
504
  verifiedProfile: VCLVerifiedProfile(payload: verifiedProfileDictionary ?? [:]),
475
- deepLink: deepLink
505
+ deepLink: deepLink,
506
+ didJwk: didJwk,
507
+ remoteCryptoServicesToken: remoteCryptoServicesToken
476
508
  )
477
509
  }
478
510
 
@@ -636,11 +668,11 @@ func didJwkToDictionary(_ didJwk: VCLDidJwk) -> [String: Any] {
636
668
  ]
637
669
  }
638
670
 
639
- func dictionaryToJwk(_ didJwkDictionary: [String: Any]) -> VCLDidJwk {
671
+ func dictionaryToDidJwk(_ didJwkDictionary: [String: Any]?) -> VCLDidJwk {
640
672
  return VCLDidJwk(
641
- did: didJwkDictionary["did"] as? String ?? "",
642
- publicJwk: dictionaryToPublicJwk(didJwkDictionary["publicJwk"] as? [String : Any]),
643
- kid: didJwkDictionary["kid"] as? String ?? "",
644
- keyId: didJwkDictionary["keyId"] as? String ?? ""
673
+ did: didJwkDictionary?["did"] as? String ?? "",
674
+ publicJwk: dictionaryToPublicJwk(didJwkDictionary?["publicJwk"] as? [String : Any]),
675
+ kid: didJwkDictionary?["kid"] as? String ?? "",
676
+ keyId: didJwkDictionary?["keyId"] as? String ?? ""
645
677
  )
646
678
  }
@@ -22,13 +22,10 @@ RCT_EXTERN_METHOD(getCredentialTypes:(RCTPromiseResolveBlock)resolve
22
22
  withRejecter:(RCTPromiseRejectBlock)reject)
23
23
 
24
24
  RCT_EXTERN_METHOD(getPresentationRequest:(NSDictionary*)presentationRequestDescriptorDictionary
25
- withRemoteCryptoServicesTokenDictionary:(NSDictionary*)remoteCryptoServicesTokenDictionary
26
25
  withResolver:(RCTPromiseResolveBlock)resolve
27
26
  withRejecter:(RCTPromiseRejectBlock)reject)
28
27
 
29
28
  RCT_EXTERN_METHOD(submitPresentation:(NSDictionary*)presentationSubmissionDictionary
30
- withDidJwkDictionary:(NSDictionary*)didJwkDictionary
31
- withRemoteCryptoServicesTokenDictionary:(NSDictionary*)remoteCryptoServicesTokenDictionary
32
29
  withResolver:(RCTPromiseResolveBlock)resolve
33
30
  withRejecter:(RCTPromiseRejectBlock)reject)
34
31
 
@@ -41,13 +38,10 @@ RCT_EXTERN_METHOD(searchForOrganizations:(NSDictionary*)organizationsSearchDescr
41
38
  withRejecter:(RCTPromiseRejectBlock)reject)
42
39
 
43
40
  RCT_EXTERN_METHOD(getCredentialManifest:(NSDictionary*)credentialManifestDescriptorDictionary
44
- withRemoteCryptoServicesTokenDictionary:(NSDictionary*)remoteCryptoServicesTokenDictionary
45
41
  withResolver:(RCTPromiseResolveBlock)resolve
46
42
  withRejecter:(RCTPromiseRejectBlock)reject)
47
43
 
48
44
  RCT_EXTERN_METHOD(generateOffers:(NSDictionary*)generateOffersDescriptorDictionary
49
- withDidJwkDictionary:(NSDictionary*)didJwkDictionary
50
- withRemoteCryptoServicesTokenDictionary:(NSDictionary*)remoteCryptoServicesTokenDictionary
51
45
  withResolver:(RCTPromiseResolveBlock)resolve
52
46
  withRejecter:(RCTPromiseRejectBlock)reject)
53
47
 
@@ -57,9 +51,7 @@ RCT_EXTERN_METHOD(checkForOffers:(NSDictionary*)generateOffersDescriptorDictiona
57
51
  withRejecter:(RCTPromiseRejectBlock)reject)
58
52
 
59
53
  RCT_EXTERN_METHOD(finalizeOffers:(NSDictionary*)finalizeOffersDescriptorDictionary
60
- withDidJwkDictionary:(NSDictionary*)didJwkDictionary
61
54
  withSessionTokenDictionary:(NSDictionary*)sessionTokenDictionary
62
- withRemoteCryptoServicesTokenDictionary:(NSDictionary*)remoteCryptoServicesTokenDictionary
63
55
  withResolver:(RCTPromiseResolveBlock)resolve
64
56
  withRejecter:(RCTPromiseRejectBlock)reject)
65
57
 
@@ -77,8 +69,8 @@ RCT_EXTERN_METHOD(verifyJwt:(NSDictionary*)jwtDictionary
77
69
  withResolver:(RCTPromiseResolveBlock)resolve
78
70
  withRejecter:(RCTPromiseRejectBlock)reject)
79
71
 
80
- RCT_EXTERN_METHOD(generateSignedJwt:(NSDictionary*)didJwkDictionary
81
- withJwtDescriptorDictionary:(NSDictionary*)jwtDescriptorDictionary
72
+ RCT_EXTERN_METHOD(generateSignedJwt:(NSDictionary*)jwtDescriptorDictionary
73
+ withDidJwkDictionary:(NSDictionary*)didJwkDictionary
82
74
  withRemoteCryptoServicesTokenDictionary:(NSDictionary*)remoteCryptoServicesTokenDictionary
83
75
  withResolver:(RCTPromiseResolveBlock)resolve
84
76
  withRejecter:(RCTPromiseRejectBlock)reject)
@@ -71,15 +71,13 @@ class VclReactNative: NSObject {
71
71
  }
72
72
  }
73
73
 
74
- @objc(getPresentationRequest:withRemoteCryptoServicesTokenDictionary:withResolver:withRejecter:)
74
+ @objc(getPresentationRequest:withResolver:withRejecter:)
75
75
  func getPresentationRequest(
76
76
  presentationRequestDescriptorDictionary: [String: Any],
77
- remoteCryptoServicesTokenDictionary: [String: Any]? = nil,
78
77
  resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
79
78
  ) {
80
79
  vcl.getPresentationRequest(
81
80
  presentationRequestDescriptor: dictionaryTopPresentationRequestDescriptor(presentationRequestDescriptorDictionary),
82
- remoteCryptoServicesToken: dictionaryToToken(remoteCryptoServicesTokenDictionary),
83
81
  successHandler: {
84
82
  resolve(presentationRequestToDictionary($0))
85
83
  },
@@ -89,19 +87,15 @@ class VclReactNative: NSObject {
89
87
  )
90
88
  }
91
89
 
92
- @objc(submitPresentation:withDidJwkDictionary:withRemoteCryptoServicesTokenDictionary:withResolver:withRejecter:)
90
+ @objc(submitPresentation:withResolver:withRejecter:)
93
91
  func submitPresentation(
94
92
  presentationSubmissionDictionary: [String: Any],
95
- didJwkDictionary: [String: Any],
96
- remoteCryptoServicesTokenDictionary: [String: Any]? = nil,
97
93
  resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
98
94
  ) {
99
95
  vcl.submitPresentation(
100
96
  presentationSubmission: dictionaryToPresentationSubmission(
101
97
  presentationSubmissionDictionary
102
98
  ),
103
- didJwk: dictionaryToJwk(didJwkDictionary),
104
- remoteCryptoServicesToken: dictionaryToToken(remoteCryptoServicesTokenDictionary),
105
99
  successHandler: {
106
100
  resolve(presentationSubmissionResultToDictionary($0))
107
101
  },
@@ -140,10 +134,9 @@ class VclReactNative: NSObject {
140
134
  })
141
135
  }
142
136
 
143
- @objc(getCredentialManifest:withRemoteCryptoServicesTokenDictionary:withResolver:withRejecter:)
137
+ @objc(getCredentialManifest:withResolver:withRejecter:)
144
138
  func getCredentialManifest(
145
139
  credentialManifestDescriptorDictionary: [String: Any],
146
- remoteCryptoServicesTokenDictionary: [String: Any],
147
140
  resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
148
141
  ) {
149
142
  VCLLog.d("credentialManifestDescriptorDictionary dictionary: \(credentialManifestDescriptorDictionary)")
@@ -151,7 +144,6 @@ class VclReactNative: NSObject {
151
144
  VCLLog.d("credentialManifestDescriptor VCL entity: \(credentialManifestDescriptor.toPropsString())")
152
145
  vcl.getCredentialManifest(
153
146
  credentialManifestDescriptor: credentialManifestDescriptor,
154
- remoteCryptoServicesToken: dictionaryToToken(remoteCryptoServicesTokenDictionary),
155
147
  successHandler: {
156
148
  resolve(credentialManifestToDictionary($0))
157
149
  },
@@ -163,17 +155,13 @@ class VclReactNative: NSObject {
163
155
  }
164
156
  }
165
157
 
166
- @objc(generateOffers:withDidJwkDictionary:withRemoteCryptoServicesTokenDictionary:withResolver:withRejecter:)
158
+ @objc(generateOffers:withResolver:withRejecter:)
167
159
  func generateOffers(
168
160
  generateOffersDescriptorDictionary: [String: Any],
169
- didJwkDictionary: [String: Any],
170
- remoteCryptoServicesTokenDictionary: [String: Any]? = nil,
171
161
  resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
172
162
  ) {
173
163
  vcl.generateOffers(
174
164
  generateOffersDescriptor: dictionaryToGenerateOffersDescriptor(generateOffersDescriptorDictionary),
175
- didJwk: dictionaryToJwk(didJwkDictionary),
176
- remoteCryptoServicesToken: dictionaryToToken(remoteCryptoServicesTokenDictionary),
177
165
  successHandler: {
178
166
  resolve(offersToDictionary($0))
179
167
  },
@@ -199,19 +187,15 @@ class VclReactNative: NSObject {
199
187
  })
200
188
  }
201
189
 
202
- @objc(finalizeOffers:withDidJwkDictionary:withSessionTokenDictionary:withRemoteCryptoServicesTokenDictionary:withResolver:withRejecter:)
190
+ @objc(finalizeOffers:withSessionTokenDictionary:withResolver:withRejecter:)
203
191
  func finalizeOffers(
204
192
  finalizeOffersDescriptorDictionary: [String: Any],
205
- didJwkDictionary: [String: Any],
206
193
  sessionTokenDictionary: [String: Any],
207
- remoteCryptoServicesTokenDictionary: [String: Any]? = nil,
208
194
  resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
209
195
  ) {
210
196
  vcl.finalizeOffers(
211
197
  finalizeOffersDescriptor: dictionaryToFinalizedOffersDescriptor(finalizeOffersDescriptorDictionary),
212
- didJwk: dictionaryToJwk(didJwkDictionary),
213
198
  sessionToken: dictionaryToToken(sessionTokenDictionary),
214
- remoteCryptoServicesToken: dictionaryToToken(remoteCryptoServicesTokenDictionary),
215
199
  successHandler: {
216
200
  resolve(jwtVerifiableCredentialsToDictionary($0))
217
201
  },
@@ -270,16 +254,16 @@ class VclReactNative: NSObject {
270
254
  })
271
255
  }
272
256
 
273
- @objc(generateSignedJwt:withJwtDescriptorDictionary:withRemoteCryptoServicesTokenDictionary:withResolver:withRejecter:)
257
+ @objc(generateSignedJwt:withDidJwkDictionary:withRemoteCryptoServicesTokenDictionary:withResolver:withRejecter:)
274
258
  func generateSignedJwt(
275
- didJwkDictionary: [String: Any],
276
259
  jwtDescriptorDictionary: [String: Any],
260
+ didJwkDictionary: [String: Any],
277
261
  remoteCryptoServicesTokenDictionary: [String: Any]? = nil,
278
262
  resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
279
263
  ) {
280
264
  vcl.generateSignedJwt(
281
- didJwk: dictionaryToJwk(didJwkDictionary),
282
265
  jwtDescriptor: dictionaryToJwtDescriptor(jwtDescriptorDictionary),
266
+ didJwk: dictionaryToDidJwk(didJwkDictionary),
283
267
  remoteCryptoServicesToken: dictionaryToToken(remoteCryptoServicesTokenDictionary),
284
268
  successHandler: {
285
269
  resolve(jwtToReadableMap($0))