@velocitycareerlabs/vcl-react-native 1.12.1 → 1.14.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/.gradle/7.4.2/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4.2/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.4.2/checksums/sha1-checksums.bin +0 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/io/velocitycareerlabs/reactnative/VclReactNativeModule.kt +17 -10
- package/android/src/main/java/io/velocitycareerlabs/reactnative/extensions/MapExtensions.kt +16 -1
- package/android/src/main/java/io/velocitycareerlabs/reactnative/utlis/Converter.kt +76 -26
- package/ios/Utils/Converter.swift +96 -33
- package/ios/VclReactNative.m +3 -0
- package/ios/VclReactNative.swift +16 -8
- package/lib/commonjs/api/VCLApi.js +6 -6
- package/lib/commonjs/api/VCLApi.js.map +1 -1
- package/lib/commonjs/api/VCLEnvironment.js +9 -9
- package/lib/commonjs/api/VCLEnvironment.js.map +1 -1
- package/lib/commonjs/api/VCLKeyServiceType.js +19 -0
- package/lib/commonjs/api/VCLKeyServiceType.js.map +1 -0
- package/lib/commonjs/api/VCLXVnfProtocolVersion.js +19 -0
- package/lib/commonjs/api/VCLXVnfProtocolVersion.js.map +1 -0
- package/lib/commonjs/api/entities/VCLCredentialManifest.js.map +1 -1
- package/lib/commonjs/api/entities/VCLDidJwk.js.map +1 -1
- package/lib/commonjs/api/entities/VCLErrorCode.js +7 -2
- package/lib/commonjs/api/entities/VCLErrorCode.js.map +1 -1
- package/lib/commonjs/api/entities/VCLFinalizeOffersDescriptor.js.map +1 -1
- package/lib/commonjs/api/entities/VCLInitializationDescriptor.js.map +1 -1
- package/lib/commonjs/api/entities/VCLJwtDescriptor.js.map +1 -1
- package/lib/commonjs/api/entities/VCLOffers.js.map +1 -1
- package/lib/commonjs/api/entities/VCLStatusCode.js +19 -0
- package/lib/commonjs/api/entities/VCLStatusCode.js.map +1 -0
- package/lib/commonjs/index.js +17 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/api/VCLApi.js +6 -6
- package/lib/module/api/VCLApi.js.map +1 -1
- package/lib/module/api/VCLEnvironment.js +7 -7
- package/lib/module/api/VCLEnvironment.js.map +1 -1
- package/lib/module/api/VCLKeyServiceType.js +13 -0
- package/lib/module/api/VCLKeyServiceType.js.map +1 -0
- package/lib/module/api/VCLXVnfProtocolVersion.js +13 -0
- package/lib/module/api/VCLXVnfProtocolVersion.js.map +1 -0
- package/lib/module/api/entities/VCLCredentialManifest.js.map +1 -1
- package/lib/module/api/entities/VCLDidJwk.js.map +1 -1
- package/lib/module/api/entities/VCLErrorCode.js +7 -2
- package/lib/module/api/entities/VCLErrorCode.js.map +1 -1
- package/lib/module/api/entities/VCLFinalizeOffersDescriptor.js.map +1 -1
- package/lib/module/api/entities/VCLInitializationDescriptor.js.map +1 -1
- package/lib/module/api/entities/VCLJwtDescriptor.js.map +1 -1
- package/lib/module/api/entities/VCLOffers.js.map +1 -1
- package/lib/module/api/entities/VCLStatusCode.js +13 -0
- package/lib/module/api/entities/VCLStatusCode.js.map +1 -0
- package/lib/module/index.js +8 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/api/VCLApi.d.ts +3 -3
- package/lib/typescript/api/VCLEnvironment.d.ts +5 -8
- package/lib/typescript/api/VCLKeyServiceType.d.ts +10 -0
- package/lib/typescript/api/VCLXVnfProtocolVersion.d.ts +10 -0
- package/lib/typescript/api/entities/VCLCredentialManifest.d.ts +3 -0
- package/lib/typescript/api/entities/VCLDidJwk.d.ts +11 -0
- package/lib/typescript/api/entities/VCLErrorCode.d.ts +7 -2
- package/lib/typescript/api/entities/VCLFinalizeOffersDescriptor.d.ts +2 -0
- package/lib/typescript/api/entities/VCLInitializationDescriptor.d.ts +4 -0
- package/lib/typescript/api/entities/VCLJwtDescriptor.d.ts +18 -1
- package/lib/typescript/api/entities/VCLOffers.d.ts +2 -0
- package/lib/typescript/api/entities/VCLStatusCode.d.ts +10 -0
- package/lib/typescript/index.d.ts +5 -4
- package/package.json +1 -1
- package/src/api/VCLApi.ts +15 -5
- package/src/api/VCLEnvironment.ts +5 -9
- package/src/api/VCLKeyServiceType.ts +11 -0
- package/src/api/VCLXVnfProtocolVersion.ts +11 -0
- package/src/api/entities/VCLCredentialManifest.ts +3 -0
- package/src/api/entities/VCLDidJwk.ts +11 -0
- package/src/api/entities/VCLErrorCode.ts +8 -2
- package/src/api/entities/VCLFinalizeOffersDescriptor.ts +2 -0
- package/src/api/entities/VCLInitializationDescriptor.ts +4 -0
- package/src/api/entities/VCLJwtDescriptor.ts +18 -1
- package/src/api/entities/VCLOffers.ts +2 -0
- package/src/api/entities/VCLStatusCode.ts +11 -0
- package/src/index.tsx +9 -5
- package/vcl-react-native.podspec +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build.gradle
CHANGED
|
@@ -9,7 +9,7 @@ buildscript {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
dependencies {
|
|
12
|
-
classpath 'com.android.tools.build:gradle:7.4.
|
|
12
|
+
classpath 'com.android.tools.build:gradle:7.4.1'
|
|
13
13
|
// noinspection DifferentKotlinGradleVersion
|
|
14
14
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
15
15
|
}
|
|
@@ -131,5 +131,5 @@ dependencies {
|
|
|
131
131
|
|
|
132
132
|
// VCL:
|
|
133
133
|
implementation "com.nimbusds:nimbus-jose-jwt:9.31"
|
|
134
|
-
implementation "io.velocitycareerlabs:vcl:1.
|
|
134
|
+
implementation "io.velocitycareerlabs:vcl:1.14.1"
|
|
135
135
|
}
|
|
@@ -16,7 +16,7 @@ import io.velocitycareerlabs.reactnative.utlis.Converter.credentialTypesFormSche
|
|
|
16
16
|
import io.velocitycareerlabs.reactnative.utlis.Converter.credentialTypesToMap
|
|
17
17
|
import io.velocitycareerlabs.reactnative.utlis.Converter.exchangeToMap
|
|
18
18
|
import io.velocitycareerlabs.reactnative.utlis.Converter.jwtVerifiableCredentialsToMap
|
|
19
|
-
import io.velocitycareerlabs.reactnative.utlis.Converter.
|
|
19
|
+
import io.velocitycareerlabs.reactnative.utlis.Converter.offersToMap
|
|
20
20
|
import io.velocitycareerlabs.reactnative.utlis.Converter.mapToCredentialManifestDescriptor
|
|
21
21
|
import io.velocitycareerlabs.reactnative.utlis.Converter.organizationsToMap
|
|
22
22
|
import io.velocitycareerlabs.reactnative.utlis.Converter.mapToPresentationSubmission
|
|
@@ -37,6 +37,7 @@ import io.velocitycareerlabs.api.VCLProvider
|
|
|
37
37
|
import io.velocitycareerlabs.api.entities.VCLError
|
|
38
38
|
import io.velocitycareerlabs.reactnative.extensions.toThrowable
|
|
39
39
|
import io.velocitycareerlabs.reactnative.utlis.Converter.didJwkToMap
|
|
40
|
+
import io.velocitycareerlabs.reactnative.utlis.Converter.mapToDidJwk
|
|
40
41
|
import io.velocitycareerlabs.reactnative.utlis.Converter.mapToInitializationDescriptor
|
|
41
42
|
import io.velocitycareerlabs.reactnative.utlis.Converter.mapToJwtDescriptor
|
|
42
43
|
import java.lang.Exception
|
|
@@ -63,8 +64,8 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
|
|
|
63
64
|
) {
|
|
64
65
|
try {
|
|
65
66
|
vcl.initialize(
|
|
67
|
+
context = reactContext.applicationContext,
|
|
66
68
|
initializationDescriptor = mapToInitializationDescriptor(
|
|
67
|
-
reactContext,
|
|
68
69
|
initializationDescriptor
|
|
69
70
|
),
|
|
70
71
|
successHandler = {
|
|
@@ -110,12 +111,12 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
|
|
|
110
111
|
|
|
111
112
|
@ReactMethod
|
|
112
113
|
fun getPresentationRequest(
|
|
113
|
-
|
|
114
|
+
presentationRequestDescriptorMap: ReadableMap,
|
|
114
115
|
promise: Promise
|
|
115
116
|
) {
|
|
116
117
|
try {
|
|
117
118
|
vcl.getPresentationRequest(
|
|
118
|
-
mapTopPresentationRequestDescriptor(
|
|
119
|
+
mapTopPresentationRequestDescriptor(presentationRequestDescriptorMap),
|
|
119
120
|
{
|
|
120
121
|
promise.resolve(presentationRequestToMap(it))
|
|
121
122
|
},
|
|
@@ -129,12 +130,14 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
|
|
|
129
130
|
|
|
130
131
|
@ReactMethod
|
|
131
132
|
fun submitPresentation(
|
|
132
|
-
|
|
133
|
+
presentationSubmissionMap: ReadableMap,
|
|
134
|
+
didJwkMap: ReadableMap? = null,
|
|
133
135
|
promise: Promise
|
|
134
136
|
) {
|
|
135
137
|
try {
|
|
136
138
|
vcl.submitPresentation(
|
|
137
|
-
mapToPresentationSubmission(
|
|
139
|
+
mapToPresentationSubmission(presentationSubmissionMap),
|
|
140
|
+
mapToDidJwk(didJwkMap),
|
|
138
141
|
{
|
|
139
142
|
promise.resolve(presentationSubmissionResultToMap(it))
|
|
140
143
|
},
|
|
@@ -148,11 +151,11 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
|
|
|
148
151
|
|
|
149
152
|
@ReactMethod
|
|
150
153
|
fun getExchangeProgress(
|
|
151
|
-
|
|
154
|
+
exchangeDescriptorMap: ReadableMap,
|
|
152
155
|
promise: Promise
|
|
153
156
|
) {
|
|
154
157
|
try {
|
|
155
|
-
vcl.getExchangeProgress(mapToExchangeDescriptor(
|
|
158
|
+
vcl.getExchangeProgress(mapToExchangeDescriptor(exchangeDescriptorMap),
|
|
156
159
|
{
|
|
157
160
|
promise.resolve(exchangeToMap(it))
|
|
158
161
|
},
|
|
@@ -207,13 +210,15 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
|
|
|
207
210
|
@ReactMethod
|
|
208
211
|
fun generateOffers(
|
|
209
212
|
generateOffersDescriptorMap: ReadableMap,
|
|
213
|
+
didJwkMap: ReadableMap? = null,
|
|
210
214
|
promise: Promise
|
|
211
215
|
) {
|
|
212
216
|
try {
|
|
213
217
|
vcl.generateOffers(
|
|
214
218
|
mapToGenerateOffersDescriptor(generateOffersDescriptorMap),
|
|
219
|
+
mapToDidJwk(didJwkMap),
|
|
215
220
|
{
|
|
216
|
-
promise.resolve(
|
|
221
|
+
promise.resolve(offersToMap(it))
|
|
217
222
|
},
|
|
218
223
|
{
|
|
219
224
|
promise.reject(it.toThrowable())
|
|
@@ -234,7 +239,7 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
|
|
|
234
239
|
mapToGenerateOffersDescriptor(generateOffersDescriptorMap),
|
|
235
240
|
mapToToken(tokenMap),
|
|
236
241
|
{
|
|
237
|
-
promise.resolve(
|
|
242
|
+
promise.resolve(offersToMap(it))
|
|
238
243
|
},
|
|
239
244
|
{
|
|
240
245
|
promise.reject(it.toThrowable())
|
|
@@ -247,12 +252,14 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
|
|
|
247
252
|
@ReactMethod
|
|
248
253
|
fun finalizeOffers(
|
|
249
254
|
finalizeOffersDescriptorMap: ReadableMap,
|
|
255
|
+
didJwkMap: ReadableMap? = null,
|
|
250
256
|
tokenMap: ReadableMap,
|
|
251
257
|
promise: Promise
|
|
252
258
|
) {
|
|
253
259
|
try {
|
|
254
260
|
vcl.finalizeOffers(
|
|
255
261
|
mapToFinalizedOffersDescriptor(finalizeOffersDescriptorMap),
|
|
262
|
+
mapToDidJwk(didJwkMap),
|
|
256
263
|
mapToToken(tokenMap),
|
|
257
264
|
{
|
|
258
265
|
promise.resolve(jwtVerifiableCredentialsToMap(it))
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
import com.facebook.react.bridge.ReadableArray
|
|
11
11
|
import com.facebook.react.bridge.ReadableMap
|
|
12
|
+
import com.facebook.react.bridge.WritableArray
|
|
12
13
|
import com.facebook.react.bridge.WritableMap
|
|
14
|
+
import org.json.JSONArray
|
|
13
15
|
import org.json.JSONObject
|
|
14
16
|
import java.lang.Exception
|
|
15
17
|
|
|
@@ -100,7 +102,7 @@ fun ReadableMap.toJsonObject(): JSONObject {
|
|
|
100
102
|
JSONObject(this.toHashMap())
|
|
101
103
|
} catch (e: Exception) {
|
|
102
104
|
e.printStackTrace()
|
|
103
|
-
JSONObject(
|
|
105
|
+
JSONObject()
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -108,3 +110,16 @@ fun WritableMap.toJsonObject(): JSONObject {
|
|
|
108
110
|
return (this as ReadableMap).toJsonObject()
|
|
109
111
|
}
|
|
110
112
|
|
|
113
|
+
fun ReadableArray.toJsonArray(): JSONArray {
|
|
114
|
+
return try {
|
|
115
|
+
JSONArray(this.toArrayList())
|
|
116
|
+
} catch (e: Exception) {
|
|
117
|
+
e.printStackTrace()
|
|
118
|
+
JSONArray()
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
fun WritableArray.toJsonArray(): JSONArray {
|
|
123
|
+
return (this as ReadableArray).toJsonArray()
|
|
124
|
+
}
|
|
125
|
+
|
|
@@ -11,6 +11,7 @@ import com.facebook.react.bridge.*
|
|
|
11
11
|
import io.velocitycareerlabs.api.*
|
|
12
12
|
import io.velocitycareerlabs.api.entities.*
|
|
13
13
|
import io.velocitycareerlabs.reactnative.extensions.*
|
|
14
|
+
import org.json.JSONArray
|
|
14
15
|
import org.json.JSONObject
|
|
15
16
|
import java.lang.Exception
|
|
16
17
|
|
|
@@ -20,25 +21,41 @@ import java.lang.Exception
|
|
|
20
21
|
object Converter {
|
|
21
22
|
|
|
22
23
|
fun mapToInitializationDescriptor(
|
|
23
|
-
reactContext: ReactApplicationContext,
|
|
24
24
|
initializationDescriptorMap: ReadableMap
|
|
25
|
-
) =
|
|
26
|
-
VCLInitializationDescriptor(
|
|
27
|
-
context = reactContext,
|
|
25
|
+
) = VCLInitializationDescriptor(
|
|
28
26
|
environment = mapToEnvironment(
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
initializationDescriptorMap.getStringOpt("environment")
|
|
28
|
+
),
|
|
29
|
+
keyServiceType = mapToKeyServiceType(
|
|
30
|
+
initializationDescriptorMap.getStringOpt("keyServiceType")
|
|
31
|
+
),
|
|
32
|
+
xVnfProtocolVersion = mapToXVnfProtocolVersion(
|
|
33
|
+
(initializationDescriptorMap.getStringOpt("xVnfProtocolVersion"))
|
|
31
34
|
),
|
|
32
35
|
cacheSequence = initializationDescriptorMap.getIntOpt("cacheSequence") ?: 0
|
|
33
36
|
)
|
|
34
37
|
|
|
35
|
-
fun mapToEnvironment(
|
|
36
|
-
when
|
|
37
|
-
VCLEnvironment.
|
|
38
|
-
VCLEnvironment.
|
|
39
|
-
VCLEnvironment.
|
|
40
|
-
VCLEnvironment.
|
|
41
|
-
else -> VCLEnvironment.
|
|
38
|
+
private fun mapToEnvironment(environment: String?) =
|
|
39
|
+
when(environment) {
|
|
40
|
+
VCLEnvironment.Dev.value -> VCLEnvironment.Dev
|
|
41
|
+
VCLEnvironment.Qa.value -> VCLEnvironment.Qa
|
|
42
|
+
VCLEnvironment.Staging.value -> VCLEnvironment.Staging
|
|
43
|
+
VCLEnvironment.Prod.value -> VCLEnvironment.Prod
|
|
44
|
+
else -> VCLEnvironment.Prod
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private fun mapToKeyServiceType(keyServiceType: String?) =
|
|
48
|
+
when(keyServiceType) {
|
|
49
|
+
VCLKeyServiceType.Local.value -> VCLKeyServiceType.Local
|
|
50
|
+
VCLKeyServiceType.Remote.value -> VCLKeyServiceType.Remote
|
|
51
|
+
else -> VCLKeyServiceType.Local
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private fun mapToXVnfProtocolVersion(xVnfProtocolVersion: String?) =
|
|
55
|
+
when(xVnfProtocolVersion) {
|
|
56
|
+
VCLXVnfProtocolVersion.XVnfProtocolVersion1.value -> VCLXVnfProtocolVersion.XVnfProtocolVersion1
|
|
57
|
+
VCLXVnfProtocolVersion.XVnfProtocolVersion2.value -> VCLXVnfProtocolVersion.XVnfProtocolVersion2
|
|
58
|
+
else -> VCLXVnfProtocolVersion.XVnfProtocolVersion1
|
|
42
59
|
}
|
|
43
60
|
|
|
44
61
|
fun regionToMap(
|
|
@@ -178,7 +195,7 @@ object Converter {
|
|
|
178
195
|
): ReadableMap {
|
|
179
196
|
val presentationRequestMap = Arguments.createMap()
|
|
180
197
|
val jwtMap = Arguments.createMap()
|
|
181
|
-
jwtMap.putString("encodedJwt", presentationRequest.jwt.
|
|
198
|
+
jwtMap.putString("encodedJwt", presentationRequest.jwt.encodedJwt)
|
|
182
199
|
presentationRequestMap.putMap("jwt", jwtMap)
|
|
183
200
|
val jwkMap = Arguments.createMap()
|
|
184
201
|
jwkMap.putString("valueStr", presentationRequest.jwkPublic.valueStr)
|
|
@@ -444,12 +461,13 @@ object Converter {
|
|
|
444
461
|
): ReadableMap {
|
|
445
462
|
val credentialManifestMap = Arguments.createMap()
|
|
446
463
|
val jwtMap = Arguments.createMap()
|
|
447
|
-
jwtMap.putString("encodedJwt", credentialManifest.jwt.
|
|
464
|
+
jwtMap.putString("encodedJwt", credentialManifest.jwt.encodedJwt)
|
|
448
465
|
credentialManifestMap.putMap("jwt", jwtMap)
|
|
449
466
|
credentialManifestMap.putString("did", credentialManifest.did)
|
|
450
467
|
credentialManifestMap.putString("iss", credentialManifest.iss)
|
|
451
468
|
credentialManifestMap.putString("exchangeId", credentialManifest.exchangeId)
|
|
452
469
|
credentialManifestMap.putString("vendorOriginContext", credentialManifest.vendorOriginContext)
|
|
470
|
+
credentialManifestMap.putMap("verifiedProfile", credentialManifest.verifiedProfile.payload.toReadableMap())
|
|
453
471
|
return credentialManifestMap
|
|
454
472
|
}
|
|
455
473
|
|
|
@@ -459,7 +477,12 @@ object Converter {
|
|
|
459
477
|
val jwt =
|
|
460
478
|
VCLJwt(encodedJwt = credentialManifestMap?.getMapOpt("jwt")?.getStringOpt("encodedJwt") ?: "")
|
|
461
479
|
val vendorOriginContext: String? = credentialManifestMap?.getStringOpt("vendorOriginContext")
|
|
462
|
-
|
|
480
|
+
val verifiedProfileMap: ReadableMap? = credentialManifestMap?.getMapOpt("verifiedProfile")
|
|
481
|
+
return VCLCredentialManifest(
|
|
482
|
+
jwt = jwt,
|
|
483
|
+
vendorOriginContext = vendorOriginContext,
|
|
484
|
+
verifiedProfile = VCLVerifiedProfile(payload = verifiedProfileMap?.toJsonObject() ?: JSONObject())
|
|
485
|
+
)
|
|
463
486
|
}
|
|
464
487
|
|
|
465
488
|
fun mapToGenerateOffersDescriptor(
|
|
@@ -490,16 +513,28 @@ object Converter {
|
|
|
490
513
|
)
|
|
491
514
|
}
|
|
492
515
|
|
|
493
|
-
fun
|
|
516
|
+
fun offersToMap(
|
|
494
517
|
offers: VCLOffers
|
|
495
518
|
): ReadableMap {
|
|
496
519
|
val generatedOffersMap = Arguments.createMap()
|
|
520
|
+
generatedOffersMap.putMap("payload", offers.payload.toReadableMap())
|
|
497
521
|
generatedOffersMap.putArray("all", offers.all.toReadableArray())
|
|
498
522
|
generatedOffersMap.putInt("responseCode", offers.responseCode)
|
|
499
523
|
generatedOffersMap.putMap("token", tokenToMap(offers.token))
|
|
524
|
+
generatedOffersMap.putString("challenge", offers.challenge)
|
|
500
525
|
return generatedOffersMap
|
|
501
526
|
}
|
|
502
527
|
|
|
528
|
+
fun mapToOffers(offersMap: ReadableMap?): VCLOffers {
|
|
529
|
+
return VCLOffers(
|
|
530
|
+
payload = offersMap?.getMapOpt("payload")?.toJsonObject() ?: JSONObject(),
|
|
531
|
+
all = offersMap?.getArrayOpt("all")?.toJsonArray() ?: JSONArray(),
|
|
532
|
+
responseCode = offersMap?.getIntOpt("responseCode") ?: -1,
|
|
533
|
+
token = mapToToken(offersMap?.getMapOpt("token")),
|
|
534
|
+
challenge = offersMap?.getStringOpt("challenge") ?: ""
|
|
535
|
+
)
|
|
536
|
+
}
|
|
537
|
+
|
|
503
538
|
fun credentialTypesFormSchemaToMap(
|
|
504
539
|
credentialTypesFormSchema: VCLCredentialTypesUIFormSchema
|
|
505
540
|
): ReadableMap {
|
|
@@ -521,6 +556,7 @@ object Converter {
|
|
|
521
556
|
finalizedOffersDescriptorMap: ReadableMap
|
|
522
557
|
) = VCLFinalizeOffersDescriptor(
|
|
523
558
|
credentialManifest = mapToCredentialManifest(finalizedOffersDescriptorMap.getMapOpt("credentialManifest")),
|
|
559
|
+
offers = mapToOffers(finalizedOffersDescriptorMap.getMapOpt("offers")),
|
|
524
560
|
approvedOfferIds = (finalizedOffersDescriptorMap.getArrayOpt("approvedOfferIds")?.toArrayList()
|
|
525
561
|
?.toList() as? List<String>) ?: listOf(),
|
|
526
562
|
rejectedOfferIds = (finalizedOffersDescriptorMap.getArrayOpt("rejectedOfferIds")?.toArrayList()
|
|
@@ -534,10 +570,10 @@ object Converter {
|
|
|
534
570
|
val passedCredentials = Arguments.createArray()
|
|
535
571
|
val failedCredentials = Arguments.createArray()
|
|
536
572
|
jwtVerifiableCredentials.passedCredentials.forEach {
|
|
537
|
-
passedCredentials.pushString(it.
|
|
573
|
+
passedCredentials.pushString(it.encodedJwt)
|
|
538
574
|
}
|
|
539
575
|
jwtVerifiableCredentials.failedCredentials.forEach {
|
|
540
|
-
failedCredentials.pushString(it.
|
|
576
|
+
failedCredentials.pushString(it.encodedJwt)
|
|
541
577
|
}
|
|
542
578
|
jwtVerifiableCredentialsMap.putArray("passedCredentials", passedCredentials)
|
|
543
579
|
jwtVerifiableCredentialsMap.putArray("failedCredentials", failedCredentials)
|
|
@@ -546,7 +582,7 @@ object Converter {
|
|
|
546
582
|
|
|
547
583
|
fun jwtToMap(jwt: VCLJwt): ReadableMap {
|
|
548
584
|
val jwtReadableMap = Arguments.createMap()
|
|
549
|
-
jwtReadableMap.putString("encodedJwt", jwt.
|
|
585
|
+
jwtReadableMap.putString("encodedJwt", jwt.encodedJwt)
|
|
550
586
|
return jwtReadableMap
|
|
551
587
|
}
|
|
552
588
|
|
|
@@ -581,12 +617,26 @@ object Converter {
|
|
|
581
617
|
jti = jwtDescriptorDictionary.getStringOpt("jti") ?: ""
|
|
582
618
|
)
|
|
583
619
|
|
|
584
|
-
fun didJwkToMap(
|
|
585
|
-
didJwk
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
620
|
+
fun didJwkToMap(didJwk: VCLDidJwk?): ReadableMap? {
|
|
621
|
+
didJwk?.let {
|
|
622
|
+
val didJwkMap = Arguments.createMap()
|
|
623
|
+
didJwkMap.putString("keyId", it.keyId)
|
|
624
|
+
didJwkMap.putString("value", it.value)
|
|
625
|
+
didJwkMap.putString("kid", it.kid)
|
|
626
|
+
return didJwkMap
|
|
627
|
+
}
|
|
628
|
+
return null
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
fun mapToDidJwk(didJwkMap: ReadableMap?): VCLDidJwk? {
|
|
632
|
+
didJwkMap?.let {
|
|
633
|
+
return VCLDidJwk(
|
|
634
|
+
keyId = it.getStringOpt("keyId") ?: "",
|
|
635
|
+
value = it.getStringOpt("value") ?: "",
|
|
636
|
+
kid = it.getStringOpt("kid") ?: ""
|
|
637
|
+
)
|
|
638
|
+
}
|
|
639
|
+
return null
|
|
590
640
|
}
|
|
591
641
|
}
|
|
592
642
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Created by Michael Avoyan on 05/07/2021.
|
|
6
6
|
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
7
|
+
// Copyright 2022 Velocity Career Labs inc.
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
//
|
|
10
10
|
|
|
11
11
|
import Foundation
|
|
@@ -16,26 +16,58 @@ func dictionaryToInitializationDescriptor(
|
|
|
16
16
|
) -> VCLInitializationDescriptor {
|
|
17
17
|
return VCLInitializationDescriptor(
|
|
18
18
|
environment: dictionaryToEnvironment(
|
|
19
|
-
initializationDescriptorDictionary["environment"] as?
|
|
19
|
+
initializationDescriptorDictionary["environment"] as? String
|
|
20
|
+
),
|
|
21
|
+
keyServiceType: dictionaryToKeyServiceType(
|
|
22
|
+
initializationDescriptorDictionary["keyServiceType"] as? String
|
|
23
|
+
),
|
|
24
|
+
xVnfProtocolVersion: dictionaryToXVnfProtocolVersion (
|
|
25
|
+
initializationDescriptorDictionary["xVnfProtocolVersion"] as? String
|
|
20
26
|
),
|
|
21
27
|
cacheSequence: initializationDescriptorDictionary["cacheSequence"] as? Int ?? 0
|
|
22
28
|
)
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
func dictionaryToEnvironment(
|
|
26
|
-
_
|
|
31
|
+
private func dictionaryToEnvironment(
|
|
32
|
+
_ environment: String?
|
|
27
33
|
) -> VCLEnvironment {
|
|
28
|
-
switch
|
|
29
|
-
case VCLEnvironment.
|
|
30
|
-
return VCLEnvironment.
|
|
31
|
-
case VCLEnvironment.
|
|
32
|
-
return VCLEnvironment.
|
|
33
|
-
case VCLEnvironment.
|
|
34
|
-
return VCLEnvironment.
|
|
35
|
-
case VCLEnvironment.
|
|
36
|
-
return VCLEnvironment.
|
|
34
|
+
switch environment {
|
|
35
|
+
case VCLEnvironment.Dev.rawValue:
|
|
36
|
+
return VCLEnvironment.Dev
|
|
37
|
+
case VCLEnvironment.Qa.rawValue:
|
|
38
|
+
return VCLEnvironment.Qa
|
|
39
|
+
case VCLEnvironment.Staging.rawValue:
|
|
40
|
+
return VCLEnvironment.Staging
|
|
41
|
+
case VCLEnvironment.Prod.rawValue:
|
|
42
|
+
return VCLEnvironment.Prod
|
|
43
|
+
default:
|
|
44
|
+
return VCLEnvironment.Prod
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private func dictionaryToKeyServiceType(
|
|
49
|
+
_ keyServiceType: String?
|
|
50
|
+
) -> VCLKeyServiceType {
|
|
51
|
+
switch keyServiceType {
|
|
52
|
+
case VCLKeyServiceType.Local.rawValue:
|
|
53
|
+
return VCLKeyServiceType.Local
|
|
54
|
+
case VCLKeyServiceType.Remote.rawValue:
|
|
55
|
+
return VCLKeyServiceType.Remote
|
|
37
56
|
default:
|
|
38
|
-
return
|
|
57
|
+
return VCLKeyServiceType.Local
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private func dictionaryToXVnfProtocolVersion(
|
|
62
|
+
_ xVnfProtocolVersion: String?
|
|
63
|
+
) -> VCLXVnfProtocolVersion {
|
|
64
|
+
switch xVnfProtocolVersion {
|
|
65
|
+
case VCLXVnfProtocolVersion.XVnfProtocolVersion1.rawValue:
|
|
66
|
+
return VCLXVnfProtocolVersion.XVnfProtocolVersion1
|
|
67
|
+
case VCLXVnfProtocolVersion.XVnfProtocolVersion2.rawValue:
|
|
68
|
+
return VCLXVnfProtocolVersion.XVnfProtocolVersion2
|
|
69
|
+
default:
|
|
70
|
+
return VCLXVnfProtocolVersion.XVnfProtocolVersion1
|
|
39
71
|
}
|
|
40
72
|
}
|
|
41
73
|
|
|
@@ -414,15 +446,21 @@ func credentialManifestToDictionary(
|
|
|
414
446
|
credentialManifestDictinary["iss"] = credentialManifest.iss
|
|
415
447
|
credentialManifestDictinary["exchangeId"] = credentialManifest.exchangeId
|
|
416
448
|
credentialManifestDictinary["vendorOriginContext"] = credentialManifest.vendorOriginContext
|
|
449
|
+
credentialManifestDictinary["verifiedProfile"] = credentialManifest.verifiedProfile.payload
|
|
417
450
|
return credentialManifestDictinary
|
|
418
451
|
}
|
|
419
452
|
|
|
420
453
|
func dictionaryToCredentialManifest(
|
|
421
|
-
_
|
|
454
|
+
_ credentialManifestDictionary: [String: Any]?
|
|
422
455
|
) -> VCLCredentialManifest {
|
|
423
|
-
let jwt: VCLJwt = VCLJwt(encodedJwt: (
|
|
424
|
-
let vendorOriginContext: String? =
|
|
425
|
-
|
|
456
|
+
let jwt: VCLJwt = VCLJwt(encodedJwt: (credentialManifestDictionary?["jwt"] as? [String: Any])?["encodedJwt"] as? String ?? "")
|
|
457
|
+
let vendorOriginContext: String? = credentialManifestDictionary?["vendorOriginContext"] as? String
|
|
458
|
+
let verifiedProfileDictionary: [String: Any]? = credentialManifestDictionary?["verifiedProfile"] as? [String: Any]
|
|
459
|
+
return VCLCredentialManifest(
|
|
460
|
+
jwt: jwt,
|
|
461
|
+
vendorOriginContext: vendorOriginContext,
|
|
462
|
+
verifiedProfile: VCLVerifiedProfile(payload: verifiedProfileDictionary ?? [:])
|
|
463
|
+
)
|
|
426
464
|
}
|
|
427
465
|
|
|
428
466
|
func dictionaryToGenerateOffersDescriptor(
|
|
@@ -450,14 +488,24 @@ func dictionaryToGenerateOffersDescriptor(
|
|
|
450
488
|
)
|
|
451
489
|
}
|
|
452
490
|
|
|
453
|
-
func
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
return
|
|
491
|
+
func offersToDictionary(_ offers: VCLOffers) -> [String: Any] {
|
|
492
|
+
var offersDictionary = [String: Any]()
|
|
493
|
+
offersDictionary["payload"] = offers.payload
|
|
494
|
+
offersDictionary["all"] = offers.all
|
|
495
|
+
offersDictionary["responseCode"] = offers.responseCode
|
|
496
|
+
offersDictionary["token"] = tokenToDictionary(offers.token)
|
|
497
|
+
offersDictionary["challenge"] = offers.challenge
|
|
498
|
+
return offersDictionary
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
func dictionaryToOffers(_ offersDictionary: [String : Any]?) -> VCLOffers {
|
|
502
|
+
return VCLOffers(
|
|
503
|
+
payload: offersDictionary?["payload"] as? [String: Any] ?? [String: Any](),
|
|
504
|
+
all: offersDictionary?["all"] as? [[String: Any]] ?? [[String: Any]](),
|
|
505
|
+
responseCode: offersDictionary?["responseCode"] as? Int ?? 0,
|
|
506
|
+
token: dictionaryToToken(offersDictionary?["token"] as? [String: Any]),
|
|
507
|
+
challenge: offersDictionary?["challenge"] as? String ?? ""
|
|
508
|
+
)
|
|
461
509
|
}
|
|
462
510
|
|
|
463
511
|
func credentialTypesFormSchemaToDictionary(
|
|
@@ -485,6 +533,7 @@ func dictionaryToFinalizedOffersDescriptor(
|
|
|
485
533
|
) -> VCLFinalizeOffersDescriptor {
|
|
486
534
|
return VCLFinalizeOffersDescriptor(
|
|
487
535
|
credentialManifest: dictionaryToCredentialManifest(finalizedOffersDescriptorDictionary["credentialManifest"] as? [String : Any]),
|
|
536
|
+
offers: dictionaryToOffers(finalizedOffersDescriptorDictionary["offers"] as? [String : Any]),
|
|
488
537
|
approvedOfferIds: finalizedOffersDescriptorDictionary["approvedOfferIds"] as? [String] ?? [String](),
|
|
489
538
|
rejectedOfferIds: finalizedOffersDescriptorDictionary["rejectedOfferIds"] as? [String] ?? [String]()
|
|
490
539
|
)
|
|
@@ -545,10 +594,24 @@ func dictionaryToJwtDescriptor(
|
|
|
545
594
|
)
|
|
546
595
|
}
|
|
547
596
|
|
|
548
|
-
func didJwkToDictionary(
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
597
|
+
func didJwkToDictionary(_ didJwk: VCLDidJwk?) -> [String: Any]? {
|
|
598
|
+
if let didJwk = didJwk {
|
|
599
|
+
return [
|
|
600
|
+
"keyId": didJwk.keyId,
|
|
601
|
+
"value": didJwk.value,
|
|
602
|
+
"kid": didJwk.kid
|
|
603
|
+
]
|
|
604
|
+
}
|
|
605
|
+
return nil
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
func dictionaryToJwk(_ didJwkDictionary: [String: Any]?) -> VCLDidJwk? {
|
|
609
|
+
if let didJwkDictionary = didJwkDictionary {
|
|
610
|
+
return VCLDidJwk(
|
|
611
|
+
keyId: didJwkDictionary["keyId"] as? String ?? "",
|
|
612
|
+
value: didJwkDictionary["value"] as? String ?? "",
|
|
613
|
+
kid: didJwkDictionary["kid"] as? String ?? ""
|
|
614
|
+
)
|
|
615
|
+
}
|
|
616
|
+
return nil
|
|
554
617
|
}
|
package/ios/VclReactNative.m
CHANGED
|
@@ -26,6 +26,7 @@ RCT_EXTERN_METHOD(getPresentationRequest:(NSDictionary*)presentationRequestDescr
|
|
|
26
26
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
27
27
|
|
|
28
28
|
RCT_EXTERN_METHOD(submitPresentation:(NSDictionary*)presentationSubmissionDictionary
|
|
29
|
+
withDidJwkDictionary:(NSDictionary*)didJwkDictionary
|
|
29
30
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
30
31
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
31
32
|
|
|
@@ -42,6 +43,7 @@ RCT_EXTERN_METHOD(getCredentialManifest:(NSDictionary*)credentialManifestDescrip
|
|
|
42
43
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
43
44
|
|
|
44
45
|
RCT_EXTERN_METHOD(generateOffers:(NSDictionary*)generateOffersDescriptorDictionary
|
|
46
|
+
withDidJwkDictionary:(NSDictionary*)didJwkDictionary
|
|
45
47
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
46
48
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
47
49
|
|
|
@@ -51,6 +53,7 @@ RCT_EXTERN_METHOD(checkForOffers:(NSDictionary*)generateOffersDescriptorDictiona
|
|
|
51
53
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
52
54
|
|
|
53
55
|
RCT_EXTERN_METHOD(finalizeOffers:(NSDictionary*)finalizeOffersDescriptorDictionary
|
|
56
|
+
withDidJwkDictionary:(NSDictionary*)didJwkDictionary
|
|
54
57
|
withTokenDictionary:(NSDictionary*)tokenDictionary
|
|
55
58
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
56
59
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
package/ios/VclReactNative.swift
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Created by Michael Avoyan on 05/07/2021.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// Copyright 2022 Velocity Career Labs inc.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
//
|
|
6
6
|
|
|
7
7
|
import VCL
|
|
@@ -78,13 +78,17 @@ class VclReactNative: NSObject {
|
|
|
78
78
|
)
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
@objc(submitPresentation:withResolver:withRejecter:)
|
|
81
|
+
@objc(submitPresentation:withDidJwkDictionary:withResolver:withRejecter:)
|
|
82
82
|
func submitPresentation(
|
|
83
83
|
presentationSubmissionDictionary: [String: Any],
|
|
84
|
+
didJwkDictionary: [String: Any]? = nil,
|
|
84
85
|
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
|
|
85
86
|
) {
|
|
86
87
|
vcl.submitPresentation(
|
|
87
|
-
presentationSubmission: dictionaryToPresentationSubmission(
|
|
88
|
+
presentationSubmission: dictionaryToPresentationSubmission(
|
|
89
|
+
presentationSubmissionDictionary
|
|
90
|
+
),
|
|
91
|
+
didJwk: dictionaryToJwk(didJwkDictionary),
|
|
88
92
|
successHandler: {
|
|
89
93
|
resolve(presentationSubmissionResultToDictionary($0))
|
|
90
94
|
},
|
|
@@ -142,15 +146,17 @@ class VclReactNative: NSObject {
|
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
|
|
145
|
-
@objc(generateOffers:withResolver:withRejecter:)
|
|
149
|
+
@objc(generateOffers:withDidJwkDictionary:withResolver:withRejecter:)
|
|
146
150
|
func generateOffers(
|
|
147
151
|
generateOffersDescriptorDictionary: [String: Any],
|
|
152
|
+
didJwkDictionary: [String: Any]? = nil,
|
|
148
153
|
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
|
|
149
154
|
) {
|
|
150
155
|
vcl.generateOffers(
|
|
151
156
|
generateOffersDescriptor: dictionaryToGenerateOffersDescriptor(generateOffersDescriptorDictionary),
|
|
157
|
+
didJwk: dictionaryToJwk(didJwkDictionary),
|
|
152
158
|
successHandler: {
|
|
153
|
-
resolve(
|
|
159
|
+
resolve(offersToDictionary($0))
|
|
154
160
|
},
|
|
155
161
|
errorHandler: {
|
|
156
162
|
reject(nil, $0.toDictionary().toJsonString(), $0)
|
|
@@ -167,21 +173,23 @@ class VclReactNative: NSObject {
|
|
|
167
173
|
generateOffersDescriptor: dictionaryToGenerateOffersDescriptor(generateOffersDescriptorDictionary),
|
|
168
174
|
token: dictionaryToToken(tokenDictionary),
|
|
169
175
|
successHandler: {
|
|
170
|
-
resolve(
|
|
176
|
+
resolve(offersToDictionary($0))
|
|
171
177
|
},
|
|
172
178
|
errorHandler: {
|
|
173
179
|
reject(nil, $0.toDictionary().toJsonString(), $0)
|
|
174
180
|
})
|
|
175
181
|
}
|
|
176
182
|
|
|
177
|
-
@objc(finalizeOffers:withTokenDictionary:withResolver:withRejecter:)
|
|
183
|
+
@objc(finalizeOffers:withDidJwkDictionary:withTokenDictionary:withResolver:withRejecter:)
|
|
178
184
|
func finalizeOffers(
|
|
179
185
|
finalizeOffersDescriptorDictionary: [String: Any],
|
|
186
|
+
didJwkDictionary: [String: Any]? = nil,
|
|
180
187
|
tokenDictionary: [String: Any],
|
|
181
188
|
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
|
|
182
189
|
) {
|
|
183
190
|
vcl.finalizeOffers(
|
|
184
191
|
finalizeOffersDescriptor: dictionaryToFinalizedOffersDescriptor(finalizeOffersDescriptorDictionary),
|
|
192
|
+
didJwk: dictionaryToJwk(didJwkDictionary),
|
|
185
193
|
token: dictionaryToToken(tokenDictionary),
|
|
186
194
|
successHandler: {
|
|
187
195
|
resolve(jwtVerifiableCredentialsToDictionary($0))
|