@didomi/react-native 2.3.0 → 2.5.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.
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativedidomi/DidomiModule.kt +108 -2
- package/ios/Didomi.m +12 -10
- package/ios/RNDidomi.swift +117 -3
- package/lib/commonjs/Constants.js +1 -1
- package/lib/commonjs/Constants.js.map +1 -1
- package/lib/commonjs/Didomi.js +43 -36
- package/lib/commonjs/Didomi.js.map +1 -1
- package/lib/commonjs/DidomiTypes.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Constants.js +1 -1
- package/lib/module/Constants.js.map +1 -1
- package/lib/module/Didomi.js +43 -36
- package/lib/module/Didomi.js.map +1 -1
- package/lib/module/DidomiTypes.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/Constants.d.ts +1 -1
- package/lib/typescript/Didomi.d.ts +43 -36
- package/lib/typescript/DidomiTypes.d.ts +13 -0
- package/lib/typescript/index.d.ts +1 -1
- package/package.json +1 -1
- package/react-native-didomi.podspec +1 -1
- package/src/Constants.ts +1 -1
- package/src/Didomi.ts +56 -37
- package/src/DidomiTypes.ts +16 -0
- package/src/index.tsx +15 -1
package/android/build.gradle
CHANGED
|
@@ -15,8 +15,12 @@ import io.didomi.sdk.DidomiInitializeParameters
|
|
|
15
15
|
import io.didomi.sdk.events.*
|
|
16
16
|
import io.didomi.sdk.exceptions.DidomiNotReadyException
|
|
17
17
|
import io.didomi.sdk.models.CurrentUserStatus
|
|
18
|
+
import io.didomi.sdk.user.UserAuthParams
|
|
18
19
|
import io.didomi.sdk.user.UserAuthWithEncryptionParams
|
|
19
20
|
import io.didomi.sdk.user.UserAuthWithHashParams
|
|
21
|
+
import org.json.JSONArray
|
|
22
|
+
import org.json.JSONException
|
|
23
|
+
import org.json.JSONObject
|
|
20
24
|
|
|
21
25
|
class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
22
26
|
|
|
@@ -231,6 +235,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
231
235
|
*/
|
|
232
236
|
override fun languageUpdateFailed(event: LanguageUpdateFailedEvent) = prepareEvent(EventTypes.LANGUAGE_UPDATE_FAILED.event, event.reason)
|
|
233
237
|
}
|
|
238
|
+
|
|
234
239
|
private val vendorStatusListeners: MutableSet<String> = mutableSetOf()
|
|
235
240
|
private val syncAcknowledgedCallbacks: MutableMap<Int, () -> Boolean> = mutableMapOf()
|
|
236
241
|
private var syncAcknowledgedCallbackIndex = 0
|
|
@@ -261,7 +266,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
261
266
|
val set = mutableSetOf<String>()
|
|
262
267
|
|
|
263
268
|
for (i in 0 until size()) {
|
|
264
|
-
set.add(getString(i)
|
|
269
|
+
set.add(getString(i))
|
|
265
270
|
}
|
|
266
271
|
|
|
267
272
|
return set
|
|
@@ -304,6 +309,9 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
304
309
|
map.putArray(entry.key, Arguments.makeNativeArray(listValues))
|
|
305
310
|
}
|
|
306
311
|
}
|
|
312
|
+
is Boolean -> map.putBoolean(entry.key, value)
|
|
313
|
+
is Int -> map.putInt(entry.key, value)
|
|
314
|
+
is Double -> map.putDouble(entry.key, value)
|
|
307
315
|
else -> map.putString(entry.key, value.toString())
|
|
308
316
|
}
|
|
309
317
|
}
|
|
@@ -323,6 +331,8 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
323
331
|
noticeId: String?,
|
|
324
332
|
androidTvNoticeId: String?,
|
|
325
333
|
androidTvEnabled: Boolean,
|
|
334
|
+
countryCode: String?,
|
|
335
|
+
regionCode: String?,
|
|
326
336
|
promise: Promise
|
|
327
337
|
) {
|
|
328
338
|
try {
|
|
@@ -339,7 +349,9 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
339
349
|
languageCode,
|
|
340
350
|
noticeId,
|
|
341
351
|
androidTvNoticeId,
|
|
342
|
-
androidTvEnabled
|
|
352
|
+
androidTvEnabled,
|
|
353
|
+
countryCode,
|
|
354
|
+
regionCode
|
|
343
355
|
)
|
|
344
356
|
|
|
345
357
|
val application = currentActivity?.application ?: throw IllegalStateException("No activity present")
|
|
@@ -615,6 +627,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
615
627
|
}
|
|
616
628
|
|
|
617
629
|
@ReactMethod
|
|
630
|
+
@Deprecated("Use setUserWithAuthParams instead", replaceWith = ReplaceWith("setUserWithAuthParams()"))
|
|
618
631
|
fun setUserWithHashAuth(
|
|
619
632
|
organizationUserId: String,
|
|
620
633
|
algorithm: String,
|
|
@@ -636,6 +649,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
636
649
|
}
|
|
637
650
|
|
|
638
651
|
@ReactMethod
|
|
652
|
+
@Deprecated("Use setUserWithAuthParamsAndSetupUI instead", replaceWith = ReplaceWith("setUserWithAuthParamsAndSetupUI()"))
|
|
639
653
|
fun setUserWithHashAuthAndSetupUI(
|
|
640
654
|
organizationUserId: String,
|
|
641
655
|
algorithm: String,
|
|
@@ -658,6 +672,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
658
672
|
}
|
|
659
673
|
|
|
660
674
|
@ReactMethod
|
|
675
|
+
@Deprecated("Use setUserWithAuthParams instead", replaceWith = ReplaceWith("setUserWithAuthParams()"))
|
|
661
676
|
fun setUserWithHashAuthWithExpiration(
|
|
662
677
|
organizationUserId: String,
|
|
663
678
|
algorithm: String,
|
|
@@ -681,6 +696,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
681
696
|
}
|
|
682
697
|
|
|
683
698
|
@ReactMethod
|
|
699
|
+
@Deprecated("Use setUserWithAuthParamsAndSetupUI instead", replaceWith = ReplaceWith("setUserWithAuthParamsAndSetupUI()"))
|
|
684
700
|
fun setUserWithHashAuthWithExpirationAndSetupUI(
|
|
685
701
|
organizationUserId: String,
|
|
686
702
|
algorithm: String,
|
|
@@ -705,6 +721,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
705
721
|
}
|
|
706
722
|
|
|
707
723
|
@ReactMethod
|
|
724
|
+
@Deprecated("Use setUserWithAuthParams instead", replaceWith = ReplaceWith("setUserWithAuthParams()"))
|
|
708
725
|
fun setUserWithEncryptionAuth(
|
|
709
726
|
organizationUserId: String,
|
|
710
727
|
algorithm: String,
|
|
@@ -724,6 +741,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
724
741
|
}
|
|
725
742
|
|
|
726
743
|
@ReactMethod
|
|
744
|
+
@Deprecated("Use setUserWithAuthParamsAndSetupUI instead", replaceWith = ReplaceWith("setUserWithAuthParamsAndSetupUI()"))
|
|
727
745
|
fun setUserWithEncryptionAuthAndSetupUI(
|
|
728
746
|
organizationUserId: String,
|
|
729
747
|
algorithm: String,
|
|
@@ -744,6 +762,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
744
762
|
}
|
|
745
763
|
|
|
746
764
|
@ReactMethod
|
|
765
|
+
@Deprecated("Use setUserWithAuthParams instead", replaceWith = ReplaceWith("setUserWithAuthParams()"))
|
|
747
766
|
fun setUserWithEncryptionAuthWithExpiration(
|
|
748
767
|
organizationUserId: String,
|
|
749
768
|
algorithm: String,
|
|
@@ -765,6 +784,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
765
784
|
}
|
|
766
785
|
|
|
767
786
|
@ReactMethod
|
|
787
|
+
@Deprecated("Use setUserWithAuthParamsAndSetupUI instead", replaceWith = ReplaceWith("setUserWithAuthParamsAndSetupUI()"))
|
|
768
788
|
fun setUserWithEncryptionAuthWithExpirationAndSetupUI(
|
|
769
789
|
organizationUserId: String,
|
|
770
790
|
algorithm: String,
|
|
@@ -786,6 +806,61 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
786
806
|
promise.resolve(0)
|
|
787
807
|
}
|
|
788
808
|
|
|
809
|
+
@ReactMethod
|
|
810
|
+
fun setUserWithAuthParams(
|
|
811
|
+
jsonUserAuthParams: String,
|
|
812
|
+
jsonSynchronizedUsers: String?,
|
|
813
|
+
promise: Promise
|
|
814
|
+
) {
|
|
815
|
+
try {
|
|
816
|
+
val userAuthParams = buildUserAuthParams(JSONObject(jsonUserAuthParams))
|
|
817
|
+
|
|
818
|
+
val synchronizedUsers = jsonSynchronizedUsers?.let {
|
|
819
|
+
JSONArray(it).run {
|
|
820
|
+
List(length()) { i -> buildUserAuthParams(getJSONObject(i)) }
|
|
821
|
+
}
|
|
822
|
+
} ?: emptyList()
|
|
823
|
+
|
|
824
|
+
Didomi.getInstance().setUser(
|
|
825
|
+
userAuthParams = userAuthParams,
|
|
826
|
+
synchronizedUsers = synchronizedUsers,
|
|
827
|
+
)
|
|
828
|
+
|
|
829
|
+
promise.resolve(0)
|
|
830
|
+
} catch (e: JSONException) {
|
|
831
|
+
Log.e("setUserWithAuthParams", "Error while parsing user with auth params", e)
|
|
832
|
+
promise.reject(e)
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
@ReactMethod
|
|
837
|
+
fun setUserWithAuthParamsAndSetupUI(
|
|
838
|
+
jsonUserAuthParams: String,
|
|
839
|
+
jsonSynchronizedUsers: String?,
|
|
840
|
+
promise: Promise
|
|
841
|
+
) {
|
|
842
|
+
try {
|
|
843
|
+
val userAuthParams = buildUserAuthParams(JSONObject(jsonUserAuthParams))
|
|
844
|
+
|
|
845
|
+
val synchronizedUsers = jsonSynchronizedUsers?.let {
|
|
846
|
+
JSONArray(it).run {
|
|
847
|
+
List(length()) { i -> buildUserAuthParams(getJSONObject(i)) }
|
|
848
|
+
}
|
|
849
|
+
} ?: emptyList()
|
|
850
|
+
|
|
851
|
+
Didomi.getInstance().setUser(
|
|
852
|
+
userAuthParams = userAuthParams,
|
|
853
|
+
synchronizedUsers = synchronizedUsers,
|
|
854
|
+
activity = currentActivity as? FragmentActivity,
|
|
855
|
+
)
|
|
856
|
+
|
|
857
|
+
promise.resolve(0)
|
|
858
|
+
} catch (e: JSONException) {
|
|
859
|
+
Log.e("setUserWithAuthParams", "Error while parsing user with auth params", e)
|
|
860
|
+
promise.reject(e)
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
789
864
|
@ReactMethod
|
|
790
865
|
fun showNotice(promise: Promise) {
|
|
791
866
|
try {
|
|
@@ -1018,4 +1093,35 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
1018
1093
|
private fun readableArrayToStringArray(readableArray: ReadableArray): Array<String> {
|
|
1019
1094
|
return Array(readableArray.size()) { i -> readableArray.getString(i) }
|
|
1020
1095
|
}
|
|
1096
|
+
|
|
1097
|
+
private fun buildUserAuthParams(jsonParameters: JSONObject): UserAuthParams {
|
|
1098
|
+
|
|
1099
|
+
val id = jsonParameters.getString("id")
|
|
1100
|
+
val algorithm = jsonParameters.getString("algorithm")
|
|
1101
|
+
val secretId = jsonParameters.getString("secretId")
|
|
1102
|
+
|
|
1103
|
+
return if (jsonParameters.has("initializationVector")) {
|
|
1104
|
+
val expiration = if (jsonParameters.has("expiration")) jsonParameters.getLong("expiration") else null
|
|
1105
|
+
val initializationVector = jsonParameters.getString("initializationVector")
|
|
1106
|
+
UserAuthWithEncryptionParams(
|
|
1107
|
+
id = id,
|
|
1108
|
+
algorithm = algorithm,
|
|
1109
|
+
secretId = secretId,
|
|
1110
|
+
initializationVector = initializationVector,
|
|
1111
|
+
expiration = expiration
|
|
1112
|
+
)
|
|
1113
|
+
} else {
|
|
1114
|
+
val expiration = if (jsonParameters.has("expiration")) jsonParameters.getLong("expiration") else null
|
|
1115
|
+
val digest = jsonParameters.getString("digest")
|
|
1116
|
+
val salt = if (jsonParameters.has("salt")) jsonParameters.getString("salt") else null
|
|
1117
|
+
UserAuthWithHashParams(
|
|
1118
|
+
id = id,
|
|
1119
|
+
algorithm = algorithm,
|
|
1120
|
+
secretId = secretId,
|
|
1121
|
+
digest = digest,
|
|
1122
|
+
salt = salt,
|
|
1123
|
+
expiration = expiration
|
|
1124
|
+
)
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1021
1127
|
}
|
package/ios/Didomi.m
CHANGED
|
@@ -14,6 +14,8 @@ RCT_EXTERN_METHOD(initialize:(NSString *)userAgentName
|
|
|
14
14
|
noticeId:(nullable NSString *)noticeId
|
|
15
15
|
androidTvNoticeId:(nullable NSString *)androidTvNoticeId
|
|
16
16
|
androidTvEnabled:(BOOL)androidTvEnabled
|
|
17
|
+
countryCode:(nullable NSString *)countryCode
|
|
18
|
+
regionCode:(nullable NSString *)regionCode
|
|
17
19
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
18
20
|
reject:(RCTPromiseRejectBlock)reject)
|
|
19
21
|
|
|
@@ -79,16 +81,6 @@ RCT_EXTERN_METHOD(setUserAgreeToAll:(RCTPromiseResolveBlock)resolve
|
|
|
79
81
|
RCT_EXTERN_METHOD(setUserDisagreeToAll:(RCTPromiseResolveBlock)resolve
|
|
80
82
|
reject:(RCTPromiseRejectBlock)reject)
|
|
81
83
|
|
|
82
|
-
// @objc(onReady:)
|
|
83
|
-
// func onReady(callback: @escaping RCTResponseSenderBlock) {
|
|
84
|
-
// Didomi.shared.onReady(callback: callback)
|
|
85
|
-
// }
|
|
86
|
-
|
|
87
|
-
// @objc(onError:)
|
|
88
|
-
// func onError(callback: @escaping (Didomi.DidomiErrorEvent)) {
|
|
89
|
-
// Didomi.shared.onError(callback: callback)
|
|
90
|
-
// }
|
|
91
|
-
|
|
92
84
|
RCT_EXTERN_METHOD(reset:(RCTPromiseResolveBlock)resolve
|
|
93
85
|
reject:(RCTPromiseRejectBlock)reject)
|
|
94
86
|
|
|
@@ -242,6 +234,16 @@ RCT_EXTERN_METHOD(setUserWithEncryptionAuthWithExpirationAndSetupUI:(NSString *)
|
|
|
242
234
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
243
235
|
reject:(RCTPromiseRejectBlock)reject)
|
|
244
236
|
|
|
237
|
+
RCT_EXTERN_METHOD(setUserWithAuthParams:(NSString *)jsonUserAuthParams
|
|
238
|
+
jsonSynchronizedUsers:(NSString)jsonSynchronizedUsers
|
|
239
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
240
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
241
|
+
|
|
242
|
+
RCT_EXTERN_METHOD(setUserWithAuthParamsAndSetupUI:(NSString *)jsonUserAuthParams
|
|
243
|
+
jsonSynchronizedUsers:(NSString)jsonSynchronizedUsers
|
|
244
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
245
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
246
|
+
|
|
245
247
|
RCT_EXTERN_METHOD(listenToVendorStatus:(NSString *)vendorId
|
|
246
248
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
247
249
|
reject:(RCTPromiseRejectBlock)reject)
|
package/ios/RNDidomi.swift
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Didomi
|
|
2
2
|
import AdSupport
|
|
3
3
|
import AppTrackingTransparency
|
|
4
|
+
import Foundation
|
|
4
5
|
|
|
5
6
|
@objc(Didomi)
|
|
6
7
|
class RNDidomi: RCTEventEmitter {
|
|
@@ -20,8 +21,8 @@ class RNDidomi: RCTEventEmitter {
|
|
|
20
21
|
return true
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
@objc(initialize:userAgentVersion:apiKey:localConfigurationPath:remoteConfigurationURL:providerId:disableDidomiRemoteConfig:languageCode:noticeId:androidTvNoticeId:androidTvEnabled:resolve:reject:)
|
|
24
|
-
func initialize(userAgentName: String, userAgentVersion: String, apiKey: String, localConfigurationPath: String?, remoteConfigurationURL: String?, providerId: String?, disableDidomiRemoteConfig: Bool = false, languageCode: String? = nil, noticeId: String? = nil, androidTvNoticeId: String? = nil, androidTvEnabled: Bool = false, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
|
|
24
|
+
@objc(initialize:userAgentVersion:apiKey:localConfigurationPath:remoteConfigurationURL:providerId:disableDidomiRemoteConfig:languageCode:noticeId:androidTvNoticeId:androidTvEnabled:countryCode:regionCode:resolve:reject:)
|
|
25
|
+
func initialize(userAgentName: String, userAgentVersion: String, apiKey: String, localConfigurationPath: String?, remoteConfigurationURL: String?, providerId: String?, disableDidomiRemoteConfig: Bool = false, languageCode: String? = nil, noticeId: String? = nil, androidTvNoticeId: String? = nil, androidTvEnabled: Bool = false, countryCode: String? = nil, regionCode: String? = nil, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
|
|
25
26
|
Didomi.shared.setUserAgent(name: userAgentName, version: userAgentVersion)
|
|
26
27
|
|
|
27
28
|
Didomi.shared.initialize(DidomiInitializeParameters(
|
|
@@ -31,7 +32,9 @@ class RNDidomi: RCTEventEmitter {
|
|
|
31
32
|
providerID: providerId,
|
|
32
33
|
disableDidomiRemoteConfig: disableDidomiRemoteConfig,
|
|
33
34
|
languageCode: languageCode ?? Locale.current.languageCode ?? "",
|
|
34
|
-
noticeID: noticeId
|
|
35
|
+
noticeID: noticeId,
|
|
36
|
+
countryCode: countryCode,
|
|
37
|
+
regionCode: regionCode
|
|
35
38
|
))
|
|
36
39
|
|
|
37
40
|
resolve(0)
|
|
@@ -477,6 +480,48 @@ class RNDidomi: RCTEventEmitter {
|
|
|
477
480
|
}
|
|
478
481
|
resolve(0)
|
|
479
482
|
}
|
|
483
|
+
|
|
484
|
+
@objc(setUserWithAuthParams:jsonSynchronizedUsers:resolve:reject:)
|
|
485
|
+
dynamic func setUserWithAuthParams(jsonUserAuthParams: String, jsonSynchronizedUsers: String?, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
|
|
486
|
+
do {
|
|
487
|
+
let userAuthParams = try buildUserAuthParams(from: jsonUserAuthParams)
|
|
488
|
+
let synchronizedUsers = try jsonSynchronizedUsers.flatMap { try buildUserAuthParamsArray(from: $0) } ?? []
|
|
489
|
+
|
|
490
|
+
Didomi.shared.setUser(
|
|
491
|
+
userAuthParams: userAuthParams,
|
|
492
|
+
synchronizedUsers: synchronizedUsers
|
|
493
|
+
)
|
|
494
|
+
resolve(0)
|
|
495
|
+
} catch {
|
|
496
|
+
reject("Error", "Error while setting user with auth params", error)
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
@objc(setUserWithAuthParamsAndSetupUI:jsonSynchronizedUsers:resolve:reject:)
|
|
501
|
+
dynamic func setUserWithAuthParamsAndSetupUI(jsonUserAuthParams: String, jsonSynchronizedUsers: String?, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
|
|
502
|
+
do {
|
|
503
|
+
let userAuthParams = try buildUserAuthParams(from: jsonUserAuthParams)
|
|
504
|
+
let synchronizedUsers = try jsonSynchronizedUsers.flatMap { try buildUserAuthParamsArray(from: $0) } ?? []
|
|
505
|
+
|
|
506
|
+
DispatchQueue.main.async {
|
|
507
|
+
if let containerController = RCTPresentedViewController() {
|
|
508
|
+
Didomi.shared.setUser(
|
|
509
|
+
userAuthParams: userAuthParams,
|
|
510
|
+
synchronizedUsers: synchronizedUsers,
|
|
511
|
+
containerController: containerController
|
|
512
|
+
)
|
|
513
|
+
} else {
|
|
514
|
+
Didomi.shared.setUser(
|
|
515
|
+
userAuthParams: userAuthParams,
|
|
516
|
+
synchronizedUsers: synchronizedUsers
|
|
517
|
+
)
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
resolve(0)
|
|
521
|
+
} catch {
|
|
522
|
+
reject("Error", "Error while setting user with auth params", error)
|
|
523
|
+
}
|
|
524
|
+
}
|
|
480
525
|
|
|
481
526
|
@objc(listenToVendorStatus:resolve:reject:)
|
|
482
527
|
dynamic func listenToVendorStatus(vendorId: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
|
|
@@ -811,6 +856,75 @@ extension RNDidomi {
|
|
|
811
856
|
Didomi.shared.removeEventListener(listener: didomiEventListener)
|
|
812
857
|
}
|
|
813
858
|
}
|
|
859
|
+
|
|
860
|
+
/// Build the user auth params from the JSON parameters
|
|
861
|
+
private func buildUserAuthParams(from jsonString: String) throws -> UserAuthParams {
|
|
862
|
+
let data = jsonString.data(using: .utf8)!
|
|
863
|
+
let json = try JSONSerialization.jsonObject(with: data, options: []) as! [String: Any]
|
|
864
|
+
|
|
865
|
+
guard let id = json["id"] as? String,
|
|
866
|
+
let algorithm = json["algorithm"] as? String,
|
|
867
|
+
let secretID = json["secretId"] as? String else {
|
|
868
|
+
fatalError("Missing required parameters")
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
let expiration = json["expiration"] as? CLong
|
|
872
|
+
let initializationVector = json["initializationVector"] as? String
|
|
873
|
+
let digest = json["digest"] as? String
|
|
874
|
+
let salt = json["salt"] as? String
|
|
875
|
+
|
|
876
|
+
if let initializationVector = initializationVector {
|
|
877
|
+
if let expiration = expiration {
|
|
878
|
+
return UserAuthWithEncryptionParams(
|
|
879
|
+
id: id,
|
|
880
|
+
algorithm: algorithm,
|
|
881
|
+
secretID: secretID,
|
|
882
|
+
initializationVector: initializationVector,
|
|
883
|
+
legacyExpiration: Double(expiration)
|
|
884
|
+
)
|
|
885
|
+
} else {
|
|
886
|
+
return UserAuthWithEncryptionParams(
|
|
887
|
+
id: id,
|
|
888
|
+
algorithm: algorithm,
|
|
889
|
+
secretID: secretID,
|
|
890
|
+
initializationVector: initializationVector
|
|
891
|
+
)
|
|
892
|
+
}
|
|
893
|
+
} else {
|
|
894
|
+
guard let digest = digest else {
|
|
895
|
+
fatalError("Missing required digest parameter")
|
|
896
|
+
}
|
|
897
|
+
if let expiration = expiration {
|
|
898
|
+
return UserAuthWithHashParams(
|
|
899
|
+
id: id,
|
|
900
|
+
algorithm: algorithm,
|
|
901
|
+
secretID: secretID,
|
|
902
|
+
digest: digest,
|
|
903
|
+
salt: salt,
|
|
904
|
+
legacyExpiration: Double(expiration)
|
|
905
|
+
)
|
|
906
|
+
} else {
|
|
907
|
+
return UserAuthWithHashParams(
|
|
908
|
+
id: id,
|
|
909
|
+
algorithm: algorithm,
|
|
910
|
+
secretID: secretID,
|
|
911
|
+
digest: digest,
|
|
912
|
+
salt: salt
|
|
913
|
+
)
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/// Build the user auth params list from the JSON parameters
|
|
919
|
+
private func buildUserAuthParamsArray(from jsonString: String) throws -> [UserAuthParams] {
|
|
920
|
+
let jsonData = jsonString.data(using: .utf8)!
|
|
921
|
+
let jsonArray = try JSONSerialization.jsonObject(with: jsonData, options: []) as! [[String: Any]]
|
|
922
|
+
return try jsonArray.map { dictionary in
|
|
923
|
+
let jsonData = try JSONSerialization.data(withJSONObject: dictionary, options: [])
|
|
924
|
+
let jsonString = String(data: jsonData, encoding: .utf8)!
|
|
925
|
+
return try buildUserAuthParams(from: jsonString)
|
|
926
|
+
}
|
|
927
|
+
}
|
|
814
928
|
}
|
|
815
929
|
|
|
816
930
|
extension Int {
|
|
@@ -7,5 +7,5 @@ exports.DIDOMI_VERSION = exports.DIDOMI_USER_AGENT_NAME = void 0;
|
|
|
7
7
|
// User agent name
|
|
8
8
|
const DIDOMI_USER_AGENT_NAME = exports.DIDOMI_USER_AGENT_NAME = "Didomi React-Native SDK";
|
|
9
9
|
// User agent version
|
|
10
|
-
const DIDOMI_VERSION = exports.DIDOMI_VERSION = "2.
|
|
10
|
+
const DIDOMI_VERSION = exports.DIDOMI_VERSION = "2.5.0";
|
|
11
11
|
//# sourceMappingURL=Constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DIDOMI_USER_AGENT_NAME","exports","DIDOMI_VERSION"],"sources":["Constants.ts"],"sourcesContent":["// User agent name\nexport const DIDOMI_USER_AGENT_NAME = \"Didomi React-Native SDK\"\n// User agent version\nexport const DIDOMI_VERSION = \"2.
|
|
1
|
+
{"version":3,"names":["DIDOMI_USER_AGENT_NAME","exports","DIDOMI_VERSION"],"sources":["Constants.ts"],"sourcesContent":["// User agent name\nexport const DIDOMI_USER_AGENT_NAME = \"Didomi React-Native SDK\"\n// User agent version\nexport const DIDOMI_VERSION = \"2.5.0\"\n"],"mappings":";;;;;;AAAA;AACO,MAAMA,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,yBAAyB;AAC/D;AACO,MAAME,cAAc,GAAAD,OAAA,CAAAC,cAAA,GAAG,OAAO","ignoreList":[]}
|