@didomi/react-native 1.4.0 → 1.7.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 +118 -29
- package/android/src/main/java/com/reactnativedidomi/EventTypes.kt +3 -2
- package/ios/Didomi.m +29 -14
- package/ios/RNDidomi.swift +127 -65
- 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 +88 -13
- 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.59.1"
|
|
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,40 +233,53 @@ 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
|
+
val application = currentActivity?.application ?: throw IllegalStateException("No activity present")
|
|
274
|
+
Didomi.getInstance().initialize(application, parameters)
|
|
275
|
+
|
|
256
276
|
Didomi.getInstance().onReady { prepareEvent(EventTypes.READY_CALLBACK.event, null) }
|
|
257
277
|
Didomi.getInstance().onError { prepareEvent(EventTypes.ERROR_CALLBACK.event, null) }
|
|
258
278
|
|
|
259
279
|
promise.resolve(0)
|
|
260
280
|
|
|
261
281
|
} catch (e: Exception) {
|
|
262
|
-
Log.e("initialize", "Error while initializing the Didomi SDK", e)
|
|
282
|
+
Log.e("initialize", "Error while initializing the Didomi SDK", e)
|
|
263
283
|
promise.reject(e)
|
|
264
284
|
}
|
|
265
285
|
}
|
|
@@ -268,7 +288,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
268
288
|
fun setupUI(promise: Promise) {
|
|
269
289
|
try {
|
|
270
290
|
runOnUiThread {
|
|
271
|
-
Didomi.getInstance().setupUI(currentActivity as FragmentActivity)
|
|
291
|
+
Didomi.getInstance().setupUI(currentActivity as? FragmentActivity)
|
|
272
292
|
}
|
|
273
293
|
promise.resolve(0)
|
|
274
294
|
} catch (e: Exception) {
|
|
@@ -512,7 +532,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
512
532
|
@ReactMethod
|
|
513
533
|
fun getUserStatus(promise: Promise) {
|
|
514
534
|
try {
|
|
515
|
-
promise.resolve(objectToWritableMap(Didomi.getInstance().
|
|
535
|
+
promise.resolve(objectToWritableMap(Didomi.getInstance().userStatus))
|
|
516
536
|
} catch (e: DidomiNotReadyException) {
|
|
517
537
|
promise.reject(e)
|
|
518
538
|
}
|
|
@@ -577,7 +597,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
577
597
|
@ReactMethod
|
|
578
598
|
fun isNoticeVisible(promise: Promise) {
|
|
579
599
|
try {
|
|
580
|
-
promise.resolve(Didomi.getInstance().isNoticeVisible)
|
|
600
|
+
promise.resolve(Didomi.getInstance().isNoticeVisible())
|
|
581
601
|
} catch (e: DidomiNotReadyException) {
|
|
582
602
|
promise.reject(e)
|
|
583
603
|
}
|
|
@@ -586,7 +606,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
586
606
|
@ReactMethod
|
|
587
607
|
fun isPreferencesVisible(promise: Promise) {
|
|
588
608
|
try {
|
|
589
|
-
promise.resolve(Didomi.getInstance().isPreferencesVisible)
|
|
609
|
+
promise.resolve(Didomi.getInstance().isPreferencesVisible())
|
|
590
610
|
} catch (e: DidomiNotReadyException) {
|
|
591
611
|
promise.reject(e)
|
|
592
612
|
}
|
|
@@ -612,7 +632,7 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
612
632
|
if (organizationUserIdAuthAlgorithm != null
|
|
613
633
|
&& organizationUserIdAuthSid != null
|
|
614
634
|
&& organizationUserIdAuthSalt != null
|
|
615
|
-
&& organizationUserIdAuthDigest != null)
|
|
635
|
+
&& organizationUserIdAuthDigest != null) {
|
|
616
636
|
Didomi.getInstance().setUser(
|
|
617
637
|
organizationUserId,
|
|
618
638
|
organizationUserIdAuthAlgorithm,
|
|
@@ -620,17 +640,86 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
620
640
|
organizationUserIdAuthSalt,
|
|
621
641
|
organizationUserIdAuthDigest
|
|
622
642
|
)
|
|
623
|
-
else
|
|
643
|
+
} else {
|
|
624
644
|
Didomi.getInstance().setUser(organizationUserId)
|
|
645
|
+
}
|
|
625
646
|
|
|
626
647
|
promise.resolve(0)
|
|
627
648
|
}
|
|
628
649
|
|
|
650
|
+
@ReactMethod
|
|
651
|
+
fun setUserWithHashAuth(organizationUserId: String,
|
|
652
|
+
algorithm: String,
|
|
653
|
+
secretId: String,
|
|
654
|
+
digest: String,
|
|
655
|
+
salt: String?,
|
|
656
|
+
promise: Promise) {
|
|
657
|
+
Didomi.getInstance().setUser(UserAuthWithHashParams(
|
|
658
|
+
organizationUserId,
|
|
659
|
+
algorithm,
|
|
660
|
+
secretId,
|
|
661
|
+
digest,
|
|
662
|
+
salt
|
|
663
|
+
))
|
|
664
|
+
promise.resolve(0)
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
@ReactMethod
|
|
668
|
+
fun setUserWithHashAuthWithExpiration(organizationUserId: String,
|
|
669
|
+
algorithm: String,
|
|
670
|
+
secretId: String,
|
|
671
|
+
digest: String,
|
|
672
|
+
salt: String?,
|
|
673
|
+
expiration: Int,
|
|
674
|
+
promise: Promise) {
|
|
675
|
+
Didomi.getInstance().setUser(UserAuthWithHashParams(
|
|
676
|
+
organizationUserId,
|
|
677
|
+
algorithm,
|
|
678
|
+
secretId,
|
|
679
|
+
digest,
|
|
680
|
+
salt,
|
|
681
|
+
expiration.toLong()
|
|
682
|
+
))
|
|
683
|
+
promise.resolve(0)
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
@ReactMethod
|
|
687
|
+
fun setUserWithEncryptionAuth(organizationUserId: String,
|
|
688
|
+
algorithm: String,
|
|
689
|
+
secretId: String,
|
|
690
|
+
initializationVector: String,
|
|
691
|
+
promise: Promise) {
|
|
692
|
+
Didomi.getInstance().setUser(UserAuthWithEncryptionParams(
|
|
693
|
+
organizationUserId,
|
|
694
|
+
algorithm,
|
|
695
|
+
secretId,
|
|
696
|
+
initializationVector
|
|
697
|
+
))
|
|
698
|
+
promise.resolve(0)
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
@ReactMethod
|
|
702
|
+
fun setUserWithEncryptionAuthWithExpiration(organizationUserId: String,
|
|
703
|
+
algorithm: String,
|
|
704
|
+
secretId: String,
|
|
705
|
+
initializationVector: String,
|
|
706
|
+
expiration: Int,
|
|
707
|
+
promise: Promise) {
|
|
708
|
+
Didomi.getInstance().setUser(UserAuthWithEncryptionParams(
|
|
709
|
+
organizationUserId,
|
|
710
|
+
algorithm,
|
|
711
|
+
secretId,
|
|
712
|
+
initializationVector,
|
|
713
|
+
expiration.toLong()
|
|
714
|
+
))
|
|
715
|
+
promise.resolve(0)
|
|
716
|
+
}
|
|
717
|
+
|
|
629
718
|
@ReactMethod
|
|
630
719
|
fun showNotice(promise: Promise) {
|
|
631
720
|
try {
|
|
632
721
|
runOnUiThread {
|
|
633
|
-
Didomi.getInstance().showNotice(currentActivity as FragmentActivity)
|
|
722
|
+
Didomi.getInstance().showNotice(currentActivity as? FragmentActivity)
|
|
634
723
|
}
|
|
635
724
|
promise.resolve(0)
|
|
636
725
|
} catch (e: Exception) {
|
|
@@ -644,8 +733,8 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
644
733
|
try {
|
|
645
734
|
runOnUiThread {
|
|
646
735
|
view?.also {
|
|
647
|
-
Didomi.getInstance().showPreferences(currentActivity as FragmentActivity, view)
|
|
648
|
-
} ?: Didomi.getInstance().showPreferences(currentActivity as FragmentActivity)
|
|
736
|
+
Didomi.getInstance().showPreferences(currentActivity as? FragmentActivity, view)
|
|
737
|
+
} ?: Didomi.getInstance().showPreferences(currentActivity as? FragmentActivity)
|
|
649
738
|
}
|
|
650
739
|
promise.resolve(0)
|
|
651
740
|
} catch (e: Exception) {
|
|
@@ -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
|
|