@didomi/react-native 1.3.0 → 1.6.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 +4 -2
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/com/reactnativedidomi/DidomiModule.kt +109 -21
- package/android/src/main/java/com/reactnativedidomi/EventTypes.kt +3 -2
- package/ios/Didomi.m +29 -14
- package/ios/RNDidomi.swift +76 -30
- package/lib/commonjs/Constants.js +13 -0
- package/lib/commonjs/Constants.js.map +1 -0
- package/lib/commonjs/Didomi.js +46 -9
- package/lib/commonjs/Didomi.js.map +1 -1
- package/lib/commonjs/DidomiListener.js +2 -0
- package/lib/commonjs/DidomiListener.js.map +1 -1
- package/lib/commonjs/DidomiTypes.js +1 -0
- package/lib/commonjs/DidomiTypes.js.map +1 -1
- package/lib/module/Constants.js +5 -0
- package/lib/module/Constants.js.map +1 -0
- package/lib/module/Didomi.js +45 -9
- package/lib/module/Didomi.js.map +1 -1
- package/lib/module/DidomiListener.js +2 -0
- package/lib/module/DidomiListener.js.map +1 -1
- package/lib/module/DidomiTypes.js +1 -0
- package/lib/module/DidomiTypes.js.map +1 -1
- package/lib/typescript/Constants.d.ts +2 -0
- package/lib/typescript/Didomi.d.ts +28 -7
- package/lib/typescript/DidomiTypes.d.ts +3 -2
- package/package.json +2 -2
- package/react-native-didomi.podspec +1 -1
- package/src/Constants.ts +4 -0
- package/src/Didomi.ts +101 -47
- package/src/DidomiListener.ts +2 -0
- package/src/DidomiTypes.ts +2 -1
package/android/build.gradle
CHANGED
|
@@ -25,6 +25,8 @@ def getExtOrIntegerDefault(name) {
|
|
|
25
25
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Didomi_" + name]).toInteger()
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
def parsedPackage = new groovy.json.JsonSlurper().parseText(file("../package.json").text)
|
|
29
|
+
|
|
28
30
|
android {
|
|
29
31
|
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
30
32
|
buildToolsVersion getExtOrDefault("buildToolsVersion")
|
|
@@ -32,7 +34,7 @@ android {
|
|
|
32
34
|
minSdkVersion 16
|
|
33
35
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
34
36
|
versionCode 1
|
|
35
|
-
versionName "
|
|
37
|
+
versionName "${parsedPackage.version}"
|
|
36
38
|
|
|
37
39
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
38
40
|
multiDexEnabled = true
|
|
@@ -130,5 +132,5 @@ dependencies {
|
|
|
130
132
|
api "com.facebook.react:react-native:+"
|
|
131
133
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
132
134
|
|
|
133
|
-
implementation "io.didomi.sdk:android:1.
|
|
135
|
+
implementation "io.didomi.sdk:android:1.58.0"
|
|
134
136
|
}
|
|
@@ -9,9 +9,11 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
|
9
9
|
import com.google.gson.Gson
|
|
10
10
|
import com.google.gson.reflect.TypeToken
|
|
11
11
|
import io.didomi.sdk.Didomi
|
|
12
|
+
import io.didomi.sdk.DidomiInitializeParameters
|
|
12
13
|
import io.didomi.sdk.events.*
|
|
13
14
|
import io.didomi.sdk.exceptions.DidomiNotReadyException
|
|
14
|
-
|
|
15
|
+
import io.didomi.sdk.user.UserAuthWithEncryptionParams
|
|
16
|
+
import io.didomi.sdk.user.UserAuthWithHashParams
|
|
15
17
|
|
|
16
18
|
class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
17
19
|
|
|
@@ -169,6 +171,11 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
169
171
|
* Sync finished
|
|
170
172
|
*/
|
|
171
173
|
override fun syncDone(event: SyncDoneEvent) = prepareEvent(EventTypes.SYNC_DONE.event, event.organizationUserId)
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Sync error
|
|
177
|
+
*/
|
|
178
|
+
override fun syncError(event: SyncErrorEvent) = prepareEvent(EventTypes.SYNC_ERROR.event, event.error)
|
|
172
179
|
}
|
|
173
180
|
|
|
174
181
|
override fun getName() = "Didomi"
|
|
@@ -226,33 +233,45 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
226
233
|
|
|
227
234
|
private fun objectToWritableMap(obj: Any?): WritableMap {
|
|
228
235
|
val map = WritableNativeMap()
|
|
229
|
-
obj?.serializeToMap()?.entries?.forEach { entry ->
|
|
236
|
+
obj?.serializeToMap()?.entries?.forEach { entry ->
|
|
237
|
+
when (val value = entry.value) {
|
|
238
|
+
is Map<*,*> -> map.putMap(entry.key, objectToWritableMap(value))
|
|
239
|
+
is List<*> -> map.putArray(entry.key, Arguments.fromList(value))
|
|
240
|
+
else -> map.putString(entry.key, value.toString())
|
|
241
|
+
}
|
|
242
|
+
}
|
|
230
243
|
return map
|
|
231
244
|
}
|
|
232
245
|
|
|
233
246
|
@ReactMethod
|
|
234
|
-
fun initialize(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
247
|
+
fun initialize(
|
|
248
|
+
userAgentName: String,
|
|
249
|
+
userAgentVersion: String,
|
|
250
|
+
apiKey: String,
|
|
251
|
+
localConfigurationPath: String?,
|
|
252
|
+
remoteConfigurationUrl: String?,
|
|
253
|
+
providerId: String?,
|
|
254
|
+
disableDidomiRemoteConfig: Boolean,
|
|
255
|
+
languageCode: String?,
|
|
256
|
+
noticeId: String?,
|
|
257
|
+
promise: Promise) {
|
|
242
258
|
try {
|
|
243
259
|
Didomi.getInstance().addEventListener(eventListener)
|
|
244
260
|
|
|
245
|
-
Didomi.getInstance().
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
261
|
+
Didomi.getInstance().setUserAgent(userAgentName, userAgentVersion)
|
|
262
|
+
|
|
263
|
+
val parameters = DidomiInitializeParameters(
|
|
264
|
+
apiKey,
|
|
265
|
+
localConfigurationPath,
|
|
266
|
+
remoteConfigurationUrl,
|
|
267
|
+
providerId,
|
|
268
|
+
disableDidomiRemoteConfig,
|
|
269
|
+
languageCode,
|
|
270
|
+
noticeId
|
|
254
271
|
)
|
|
255
272
|
|
|
273
|
+
Didomi.getInstance().initialize(currentActivity?.application, parameters)
|
|
274
|
+
|
|
256
275
|
Didomi.getInstance().onReady { prepareEvent(EventTypes.READY_CALLBACK.event, null) }
|
|
257
276
|
Didomi.getInstance().onError { prepareEvent(EventTypes.ERROR_CALLBACK.event, null) }
|
|
258
277
|
|
|
@@ -612,7 +631,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
612
631
|
if (organizationUserIdAuthAlgorithm != null
|
|
613
632
|
&& organizationUserIdAuthSid != null
|
|
614
633
|
&& organizationUserIdAuthSalt != null
|
|
615
|
-
&& organizationUserIdAuthDigest != null)
|
|
634
|
+
&& organizationUserIdAuthDigest != null) {
|
|
616
635
|
Didomi.getInstance().setUser(
|
|
617
636
|
organizationUserId,
|
|
618
637
|
organizationUserIdAuthAlgorithm,
|
|
@@ -620,12 +639,81 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
620
639
|
organizationUserIdAuthSalt,
|
|
621
640
|
organizationUserIdAuthDigest
|
|
622
641
|
)
|
|
623
|
-
else
|
|
642
|
+
} else {
|
|
624
643
|
Didomi.getInstance().setUser(organizationUserId)
|
|
644
|
+
}
|
|
625
645
|
|
|
626
646
|
promise.resolve(0)
|
|
627
647
|
}
|
|
628
648
|
|
|
649
|
+
@ReactMethod
|
|
650
|
+
fun setUserWithHashAuth(organizationUserId: String,
|
|
651
|
+
algorithm: String,
|
|
652
|
+
secretId: String,
|
|
653
|
+
digest: String,
|
|
654
|
+
salt: String?,
|
|
655
|
+
promise: Promise) {
|
|
656
|
+
Didomi.getInstance().setUser(UserAuthWithHashParams(
|
|
657
|
+
organizationUserId,
|
|
658
|
+
algorithm,
|
|
659
|
+
secretId,
|
|
660
|
+
digest,
|
|
661
|
+
salt
|
|
662
|
+
))
|
|
663
|
+
promise.resolve(0)
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
@ReactMethod
|
|
667
|
+
fun setUserWithHashAuthWithExpiration(organizationUserId: String,
|
|
668
|
+
algorithm: String,
|
|
669
|
+
secretId: String,
|
|
670
|
+
digest: String,
|
|
671
|
+
salt: String?,
|
|
672
|
+
expiration: Int,
|
|
673
|
+
promise: Promise) {
|
|
674
|
+
Didomi.getInstance().setUser(UserAuthWithHashParams(
|
|
675
|
+
organizationUserId,
|
|
676
|
+
algorithm,
|
|
677
|
+
secretId,
|
|
678
|
+
digest,
|
|
679
|
+
salt,
|
|
680
|
+
expiration.toLong()
|
|
681
|
+
))
|
|
682
|
+
promise.resolve(0)
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
@ReactMethod
|
|
686
|
+
fun setUserWithEncryptionAuth(organizationUserId: String,
|
|
687
|
+
algorithm: String,
|
|
688
|
+
secretId: String,
|
|
689
|
+
initializationVector: String,
|
|
690
|
+
promise: Promise) {
|
|
691
|
+
Didomi.getInstance().setUser(UserAuthWithEncryptionParams(
|
|
692
|
+
organizationUserId,
|
|
693
|
+
algorithm,
|
|
694
|
+
secretId,
|
|
695
|
+
initializationVector
|
|
696
|
+
))
|
|
697
|
+
promise.resolve(0)
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
@ReactMethod
|
|
701
|
+
fun setUserWithEncryptionAuthWithExpiration(organizationUserId: String,
|
|
702
|
+
algorithm: String,
|
|
703
|
+
secretId: String,
|
|
704
|
+
initializationVector: String,
|
|
705
|
+
expiration: Int,
|
|
706
|
+
promise: Promise) {
|
|
707
|
+
Didomi.getInstance().setUser(UserAuthWithEncryptionParams(
|
|
708
|
+
organizationUserId,
|
|
709
|
+
algorithm,
|
|
710
|
+
secretId,
|
|
711
|
+
initializationVector,
|
|
712
|
+
expiration.toLong()
|
|
713
|
+
))
|
|
714
|
+
promise.resolve(0)
|
|
715
|
+
}
|
|
716
|
+
|
|
629
717
|
@ReactMethod
|
|
630
718
|
fun showNotice(promise: Promise) {
|
|
631
719
|
try {
|
|
@@ -32,5 +32,6 @@ enum class EventTypes(val event: String) {
|
|
|
32
32
|
PREFERENCES_CLICK_AGREE_TO_ALL_PURPOSES("on_preferences_click_agree_to_all_purposes"),
|
|
33
33
|
PREFERENCES_CLICK_DISAGREE_TO_ALL_PURPOSES("on_preferences_click_disagree_to_all_purposes"),
|
|
34
34
|
PREFERENCES_CLICK_RESET_ALL_PURPOSES("on_preferences_click_reset_all_purposes"),
|
|
35
|
-
SYNC_DONE("on_sync_done")
|
|
36
|
-
|
|
35
|
+
SYNC_DONE("on_sync_done"),
|
|
36
|
+
SYNC_ERROR("on_sync_error");
|
|
37
|
+
}
|
package/ios/Didomi.m
CHANGED
|
@@ -4,16 +4,12 @@
|
|
|
4
4
|
@interface RCT_EXTERN_MODULE(Didomi, RCTEventEmitter)
|
|
5
5
|
|
|
6
6
|
RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b
|
|
7
|
-
|
|
7
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
8
8
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// providerId:(nullable NSString *)providerId
|
|
14
|
-
// disableDidomiRemoteConfig:(BOOL)disableDidomiRemoteConfig)
|
|
15
|
-
|
|
16
|
-
RCT_EXTERN_METHOD(initialize:(NSString *)apikey
|
|
10
|
+
RCT_EXTERN_METHOD(initialize:(NSString *)userAgentName
|
|
11
|
+
userAgentVersion:(NSString *)userAgentVersion
|
|
12
|
+
apiKey:(NSString *)apiKey
|
|
17
13
|
localConfigurationPath:(nullable NSString *)localConfigurationPath
|
|
18
14
|
remoteConfigurationURL:(nullable NSString *)remoteConfigurationURL
|
|
19
15
|
providerId:(nullable NSString *)providerId
|
|
@@ -28,9 +24,6 @@ RCT_EXTERN_METHOD(onError)
|
|
|
28
24
|
RCT_EXTERN_METHOD(getQueryStringForWebView:(RCTPromiseResolveBlock)resolve
|
|
29
25
|
reject:(RCTPromiseRejectBlock)reject)
|
|
30
26
|
|
|
31
|
-
RCT_EXTERN_METHOD(setUserAgent:(NSString *)name
|
|
32
|
-
version:(NSString *)version)
|
|
33
|
-
|
|
34
27
|
RCT_EXTERN_METHOD(setUserConsentStatus:(NSArray<NSString *> *)enabledPurposeIds
|
|
35
28
|
disabledPurposeIds:(NSArray<NSString *> *)disabledPurposeIds
|
|
36
29
|
enabledVendorIds:(NSArray<NSString *> *)enabledVendorIds
|
|
@@ -210,13 +203,35 @@ RCT_EXTERN_METHOD(getText:(NSString *)key
|
|
|
210
203
|
|
|
211
204
|
RCT_EXTERN_METHOD(setLogLevel:(int)minLevel)
|
|
212
205
|
|
|
213
|
-
RCT_EXTERN_METHOD(setUser:(NSString *)id
|
|
206
|
+
RCT_EXTERN_METHOD(setUser:(NSString *)id
|
|
207
|
+
algorithm:(nullable NSString *)algorithm
|
|
208
|
+
secretId:(nullable NSString *)secretId
|
|
209
|
+
salt:(nullable NSString *)salt
|
|
210
|
+
digest:(nullable NSString *)digest)
|
|
211
|
+
|
|
212
|
+
RCT_EXTERN_METHOD(setUserWithHashAuth:(NSString *)id
|
|
213
|
+
algorithm:(NSString *)algorithm
|
|
214
|
+
secretId:(NSString *)secretId
|
|
215
|
+
digest:(NSString *)digest
|
|
216
|
+
salt:(nullable NSString *)salt)
|
|
214
217
|
|
|
215
|
-
RCT_EXTERN_METHOD(
|
|
218
|
+
RCT_EXTERN_METHOD(setUserWithHashAuthWithExpiration:(NSString *)id
|
|
216
219
|
algorithm:(NSString *)algorithm
|
|
217
220
|
secretId:(NSString *)secretId
|
|
221
|
+
digest:(NSString *)digest
|
|
218
222
|
salt:(nullable NSString *)salt
|
|
219
|
-
|
|
223
|
+
expiration: (double)expiration)
|
|
224
|
+
|
|
225
|
+
RCT_EXTERN_METHOD(setUserWithEncryptionAuth:(NSString *)id
|
|
226
|
+
algorithm:(NSString *)algorithm
|
|
227
|
+
secretId:(NSString *)secretId
|
|
228
|
+
initializationVector:(NSString *)initializationVector)
|
|
229
|
+
|
|
230
|
+
RCT_EXTERN_METHOD(setUserWithEncryptionAuthWithExpiration:(NSString *)id
|
|
231
|
+
algorithm:(NSString *)algorithm
|
|
232
|
+
secretId:(NSString *)secretId
|
|
233
|
+
initializationVector:(NSString *)initializationVector
|
|
234
|
+
expiration: (double)expiration)
|
|
220
235
|
|
|
221
236
|
RCT_EXTERN_METHOD(supportedEvents)
|
|
222
237
|
|
package/ios/RNDidomi.swift
CHANGED
|
@@ -5,23 +5,33 @@ import AppTrackingTransparency
|
|
|
5
5
|
@objc(Didomi)
|
|
6
6
|
class RNDidomi: RCTEventEmitter {
|
|
7
7
|
|
|
8
|
-
var initialized = false
|
|
8
|
+
public static var initialized = false
|
|
9
9
|
let didomiEventListener = EventListener()
|
|
10
10
|
|
|
11
11
|
override static func requiresMainQueueSetup() -> Bool {
|
|
12
12
|
return true
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
@objc(initialize:localConfigurationPath:remoteConfigurationURL:providerId:disableDidomiRemoteConfig:languageCode:noticeId:)
|
|
16
|
-
func initialize(apiKey: String, localConfigurationPath: String?, remoteConfigurationURL: String?, providerId: String?, disableDidomiRemoteConfig: Bool = false, languageCode: String? = nil, noticeId: String? = nil) {
|
|
15
|
+
@objc(initialize:userAgentVersion:apiKey:localConfigurationPath:remoteConfigurationURL:providerId:disableDidomiRemoteConfig:languageCode:noticeId:)
|
|
16
|
+
func initialize(userAgentName: String, userAgentVersion: String, apiKey: String, localConfigurationPath: String?, remoteConfigurationURL: String?, providerId: String?, disableDidomiRemoteConfig: Bool = false, languageCode: String? = nil, noticeId: String? = nil) {
|
|
17
17
|
onReady()
|
|
18
18
|
onError()
|
|
19
|
-
if !initialized {
|
|
19
|
+
if !RNDidomi.initialized {
|
|
20
20
|
initEventListener()
|
|
21
|
-
|
|
22
|
-
Didomi.shared.
|
|
21
|
+
|
|
22
|
+
Didomi.shared.setUserAgent(name: userAgentName, version: userAgentVersion)
|
|
23
|
+
|
|
24
|
+
Didomi.shared.initialize(DidomiInitializeParameters(
|
|
25
|
+
apiKey: apiKey,
|
|
26
|
+
localConfigurationPath: localConfigurationPath,
|
|
27
|
+
remoteConfigurationURL: remoteConfigurationURL,
|
|
28
|
+
providerID: providerId,
|
|
29
|
+
disableDidomiRemoteConfig: disableDidomiRemoteConfig,
|
|
30
|
+
languageCode: languageCode ?? Locale.current.languageCode ?? "",
|
|
31
|
+
noticeID: noticeId
|
|
32
|
+
))
|
|
23
33
|
}
|
|
24
|
-
initialized = true
|
|
34
|
+
RNDidomi.initialized = true
|
|
25
35
|
}
|
|
26
36
|
|
|
27
37
|
private func onReady() {
|
|
@@ -41,11 +51,6 @@ class RNDidomi: RCTEventEmitter {
|
|
|
41
51
|
resolve(Didomi.shared.getQueryStringForWebView())
|
|
42
52
|
}
|
|
43
53
|
|
|
44
|
-
@objc(setUserAgent:version:)
|
|
45
|
-
func setUserAgent(name: String, version: String) {
|
|
46
|
-
Didomi.shared.setUserAgent(name: name, version: version)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
54
|
@objc(setUserConsentStatus:disabledPurposeIds:enabledVendorIds:disabledVendorIds:resolve:reject:)
|
|
50
55
|
func setUserConsentStatus(enabledPurposeIds: Set<String>, disabledPurposeIds: Set<String>, enabledVendorIds: Set<String>, disabledVendorIds: Set<String>, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
51
56
|
resolve(Didomi.shared.setUserConsentStatus(enabledPurposeIds: Set(enabledPurposeIds), disabledPurposeIds: Set(disabledPurposeIds), enabledVendorIds: Set(enabledVendorIds), disabledVendorIds: Set(disabledVendorIds)))
|
|
@@ -150,7 +155,6 @@ class RNDidomi: RCTEventEmitter {
|
|
|
150
155
|
resolve(Array(Didomi.shared.getRequiredVendorIds()))
|
|
151
156
|
}
|
|
152
157
|
|
|
153
|
-
|
|
154
158
|
@objc(isReady:reject:)
|
|
155
159
|
func isReady(resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
156
160
|
resolve(Didomi.shared.isReady())
|
|
@@ -163,8 +167,6 @@ class RNDidomi: RCTEventEmitter {
|
|
|
163
167
|
resolve(purposes)
|
|
164
168
|
}
|
|
165
169
|
|
|
166
|
-
|
|
167
|
-
|
|
168
170
|
@objc(getRequiredVendors:reject:)
|
|
169
171
|
func getRequiredVendors(resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
170
172
|
let encoder = JSONEncoder()
|
|
@@ -179,7 +181,6 @@ class RNDidomi: RCTEventEmitter {
|
|
|
179
181
|
resolve(purposes)
|
|
180
182
|
}
|
|
181
183
|
|
|
182
|
-
|
|
183
184
|
@objc(getEnabledPurposeIds:reject:)
|
|
184
185
|
func getEnabledPurposeIds(resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) {
|
|
185
186
|
resolve(Array(Didomi.shared.getEnabledPurposeIds()))
|
|
@@ -249,7 +250,6 @@ class RNDidomi: RCTEventEmitter {
|
|
|
249
250
|
Didomi.shared.updateSelectedLanguage(languageCode: languageCode)
|
|
250
251
|
}
|
|
251
252
|
|
|
252
|
-
|
|
253
253
|
// MARK: ViewProviderDelegate
|
|
254
254
|
|
|
255
255
|
@objc(getNoticeViewController:resolve:reject:)
|
|
@@ -262,7 +262,6 @@ class RNDidomi: RCTEventEmitter {
|
|
|
262
262
|
resolve(Didomi.shared.getPreferencesViewController())
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
|
|
266
265
|
// MARK: Didomi extension
|
|
267
266
|
|
|
268
267
|
@objc(setupUI)
|
|
@@ -364,17 +363,60 @@ class RNDidomi: RCTEventEmitter {
|
|
|
364
363
|
|
|
365
364
|
Didomi.shared.setLogLevel(minLevel: level)
|
|
366
365
|
}
|
|
367
|
-
|
|
368
|
-
@objc(setUser:)
|
|
369
|
-
dynamic func setUser(id: String) {
|
|
370
|
-
Didomi.shared.setUser(id: id)
|
|
371
|
-
}
|
|
372
|
-
|
|
366
|
+
|
|
373
367
|
@objc(setUser:algorithm:secretId:salt:digest:)
|
|
374
|
-
dynamic func setUser(id: String, algorithm: String
|
|
375
|
-
|
|
368
|
+
dynamic func setUser(id: String, algorithm: String?, secretId: String?, salt: String?, digest: String?) {
|
|
369
|
+
if let algorithm = algorithm, let secretId = secretId, let digest = digest {
|
|
370
|
+
Didomi.shared.setUser(id: id, algorithm: algorithm, secretId: secretId, salt: salt, digest: digest)
|
|
371
|
+
} else {
|
|
372
|
+
Didomi.shared.setUser(id: id)
|
|
373
|
+
}
|
|
376
374
|
}
|
|
377
|
-
|
|
375
|
+
|
|
376
|
+
@objc(setUserWithHashAuth:algorithm:secretId:digest:salt:)
|
|
377
|
+
dynamic func setUserWithHashAuth(id: String, algorithm: String, secretId: String, digest: String, salt: String?) {
|
|
378
|
+
Didomi.shared.setUser(
|
|
379
|
+
userAuthParams: UserAuthWithHashParams(
|
|
380
|
+
id: id,
|
|
381
|
+
algorithm: algorithm,
|
|
382
|
+
secretID: secretId,
|
|
383
|
+
digest: digest,
|
|
384
|
+
salt: salt))
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
@objc(setUserWithHashAuthWithExpiration:algorithm:secretId:digest:salt:expiration:)
|
|
388
|
+
dynamic func setUserWithHashAuthWithExpiration(id: String, algorithm: String, secretId: String, digest: String, salt: String?, expiration: Double) {
|
|
389
|
+
Didomi.shared.setUser(
|
|
390
|
+
userAuthParams: UserAuthWithHashParams(
|
|
391
|
+
id: id,
|
|
392
|
+
algorithm: algorithm,
|
|
393
|
+
secretID: secretId,
|
|
394
|
+
digest: digest,
|
|
395
|
+
salt: salt,
|
|
396
|
+
legacyExpiration: expiration))
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
@objc(setUserWithEncryptionAuth:algorithm:secretId:initializationVector:)
|
|
400
|
+
dynamic func setUserWithEncryptionAuth(id: String, algorithm: String, secretId: String, initializationVector: String) {
|
|
401
|
+
Didomi.shared.setUser(
|
|
402
|
+
userAuthParams: UserAuthWithEncryptionParams(
|
|
403
|
+
id: id,
|
|
404
|
+
algorithm: algorithm,
|
|
405
|
+
secretID: secretId,
|
|
406
|
+
initializationVector: initializationVector))
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
@objc(setUserWithEncryptionAuthWithExpiration:algorithm:secretId:initializationVector:expiration:)
|
|
410
|
+
dynamic func setUserWithEncryptionAuthWithExpiration(id: String, algorithm: String, secretId: String, initializationVector: String, expiration: Double) {
|
|
411
|
+
Didomi.shared.setUser(
|
|
412
|
+
userAuthParams: UserAuthWithEncryptionParams(
|
|
413
|
+
id: id,
|
|
414
|
+
algorithm: algorithm,
|
|
415
|
+
secretID: secretId,
|
|
416
|
+
initializationVector: initializationVector,
|
|
417
|
+
legacyExpiration: expiration))
|
|
418
|
+
}
|
|
419
|
+
|
|
378
420
|
@objc public enum Views : Int, RawRepresentable {
|
|
379
421
|
|
|
380
422
|
case purposes = 0
|
|
@@ -484,11 +526,11 @@ extension RNDidomi {
|
|
|
484
526
|
"on_preferences_click_vendor_agree",
|
|
485
527
|
"on_preferences_click_vendor_disagree",
|
|
486
528
|
"on_preferences_click_vendor_save_choices",
|
|
487
|
-
"on_sync_done"
|
|
529
|
+
"on_sync_done",
|
|
530
|
+
"on_sync_error"
|
|
488
531
|
]
|
|
489
532
|
}
|
|
490
533
|
|
|
491
|
-
|
|
492
534
|
private func initEventListener(){
|
|
493
535
|
|
|
494
536
|
didomiEventListener.onConsentChanged = { event in
|
|
@@ -610,7 +652,11 @@ extension RNDidomi {
|
|
|
610
652
|
didomiEventListener.onSyncDone = { event, organizationUserId in
|
|
611
653
|
self.sendEvent(withName: "on_sync_done", body: organizationUserId)
|
|
612
654
|
}
|
|
613
|
-
|
|
655
|
+
|
|
656
|
+
didomiEventListener.onSyncError = { event, error in
|
|
657
|
+
self.sendEvent(withName: "on_sync_error", body: error)
|
|
658
|
+
}
|
|
659
|
+
|
|
614
660
|
Didomi.shared.addEventListener(listener: didomiEventListener)
|
|
615
661
|
}
|
|
616
662
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DIDOMI_VERSION = exports.DIDOMI_USER_AGENT_NAME = void 0;
|
|
7
|
+
// User agent name
|
|
8
|
+
const DIDOMI_USER_AGENT_NAME = "Didomi React-Native SDK"; // User agent version
|
|
9
|
+
|
|
10
|
+
exports.DIDOMI_USER_AGENT_NAME = DIDOMI_USER_AGENT_NAME;
|
|
11
|
+
const DIDOMI_VERSION = "1.6.0";
|
|
12
|
+
exports.DIDOMI_VERSION = DIDOMI_VERSION;
|
|
13
|
+
//# sourceMappingURL=Constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Constants.ts"],"names":["DIDOMI_USER_AGENT_NAME","DIDOMI_VERSION"],"mappings":";;;;;;AAAA;AACO,MAAMA,sBAAsB,GAAG,yBAA/B,C,CACP;;;AACO,MAAMC,cAAc,GAAG,OAAvB","sourcesContent":["// User agent name\nexport const DIDOMI_USER_AGENT_NAME = \"Didomi React-Native SDK\"\n// User agent version\nexport const DIDOMI_VERSION = \"1.6.0\"\n"]}
|
package/lib/commonjs/Didomi.js
CHANGED
|
@@ -9,6 +9,8 @@ var _reactNative = require("react-native");
|
|
|
9
9
|
|
|
10
10
|
var _DidomiListener = require("./DidomiListener");
|
|
11
11
|
|
|
12
|
+
var _Constants = require("./Constants");
|
|
13
|
+
|
|
12
14
|
const {
|
|
13
15
|
Didomi: RNDidomi
|
|
14
16
|
} = _reactNative.NativeModules;
|
|
@@ -29,22 +31,22 @@ const Didomi = {
|
|
|
29
31
|
_DidomiListener.DidomiListener.init(); // Trigger native SDK init
|
|
30
32
|
|
|
31
33
|
|
|
32
|
-
RNDidomi.initialize(apiKey, localConfigurationPath, remoteConfigurationUrl, providerId, disableDidomiRemoteConfig, languageCode, noticeId);
|
|
34
|
+
RNDidomi.initialize(_Constants.DIDOMI_USER_AGENT_NAME, _Constants.DIDOMI_VERSION, apiKey, localConfigurationPath, remoteConfigurationUrl, providerId, disableDidomiRemoteConfig, languageCode, noticeId);
|
|
33
35
|
},
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Listen to SDK ready state
|
|
37
|
-
|
|
39
|
+
*/
|
|
38
40
|
onReady: () => _DidomiListener.DidomiListener.onReady(),
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
43
|
* Listen to SDK errors
|
|
42
|
-
|
|
44
|
+
*/
|
|
43
45
|
onError: () => _DidomiListener.DidomiListener.onError(),
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
* Provide the objects required to display UI elements
|
|
49
|
+
*/
|
|
48
50
|
setupUI: () => RNDidomi.setupUI(),
|
|
49
51
|
|
|
50
52
|
/**
|
|
@@ -337,15 +339,50 @@ const Didomi = {
|
|
|
337
339
|
isReady: () => RNDidomi.isReady(),
|
|
338
340
|
|
|
339
341
|
/**
|
|
340
|
-
* Set user information
|
|
342
|
+
* Set user information without authentication
|
|
343
|
+
*
|
|
344
|
+
* @param id Organization user ID
|
|
345
|
+
* @param algorithm Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
|
|
346
|
+
* @param secretId Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
|
|
347
|
+
* @param salt Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
|
|
348
|
+
* @param digest Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
|
|
349
|
+
*/
|
|
350
|
+
setUser: (organizationUserId, organizationUserIdAuthAlgorithm, organizationUserIdAuthSid, organizationUserIdAuthSalt, organizationUserIdAuthDigest) => RNDidomi.setUser(organizationUserId, organizationUserIdAuthAlgorithm, organizationUserIdAuthSid, organizationUserIdAuthSalt, organizationUserIdAuthDigest),
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Set user information with Hash authentication
|
|
341
354
|
*
|
|
342
355
|
* @param id Organization user ID
|
|
343
356
|
* @param algorithm Algorithm used for computing the digest
|
|
344
357
|
* @param secretId ID of the secret used for computing the digest
|
|
345
|
-
* @param salt Salt used for computing the digest (optional)
|
|
346
358
|
* @param digest Digest of the organization user ID and secret
|
|
347
|
-
|
|
348
|
-
|
|
359
|
+
* @param salt Salt used for computing the digest (optional)
|
|
360
|
+
* @param expiration Expiration date as timestamp (to prevent replay attacks)
|
|
361
|
+
*/
|
|
362
|
+
setUserWithHashAuth: (organizationUserId, algorithm, secretId, digest, salt, expiration) => {
|
|
363
|
+
if (expiration === undefined) {
|
|
364
|
+
RNDidomi.setUserWithHashAuth(organizationUserId, algorithm, secretId, digest, salt);
|
|
365
|
+
} else {
|
|
366
|
+
RNDidomi.setUserWithHashAuthWithExpiration(organizationUserId, algorithm, secretId, digest, salt, expiration);
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Set user information with Encryption authentication
|
|
372
|
+
*
|
|
373
|
+
* @param id Organization user ID
|
|
374
|
+
* @param algorithm Algorithm used for computing the digest
|
|
375
|
+
* @param secretId ID of the secret used for computing the digest
|
|
376
|
+
* @param initializationVector Initialization Vector used for computing the user ID
|
|
377
|
+
* @param expiration Expiration date as timestamp (to prevent replay attacks)
|
|
378
|
+
*/
|
|
379
|
+
setUserWithEncryptionAuth: (organizationUserId, algorithm, secretId, initializationVector, expiration) => {
|
|
380
|
+
if (expiration === undefined) {
|
|
381
|
+
RNDidomi.setUserWithEncryptionAuth(organizationUserId, algorithm, secretId, initializationVector);
|
|
382
|
+
} else {
|
|
383
|
+
RNDidomi.setUserWithEncryptionAuthWithExpiration(organizationUserId, algorithm, secretId, initializationVector, expiration);
|
|
384
|
+
}
|
|
385
|
+
},
|
|
349
386
|
|
|
350
387
|
/**
|
|
351
388
|
* Show the consent notice (if required, not disabled in the config and not already displayed)
|