@didomi/react-native 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativedidomi/DidomiModule.kt +21 -0
- package/ios/Didomi.m +7 -0
- package/ios/RNDidomi.swift +103 -86
- package/lib/commonjs/Constants.js +1 -1
- package/lib/commonjs/Constants.js.map +1 -1
- package/lib/commonjs/CurrentUserStatusTransaction.js +102 -0
- package/lib/commonjs/CurrentUserStatusTransaction.js.map +1 -0
- package/lib/commonjs/Didomi.js +9 -1
- package/lib/commonjs/Didomi.js.map +1 -1
- package/lib/module/Constants.js +1 -1
- package/lib/module/Constants.js.map +1 -1
- package/lib/module/CurrentUserStatusTransaction.js +95 -0
- package/lib/module/CurrentUserStatusTransaction.js.map +1 -0
- package/lib/module/Didomi.js +9 -1
- package/lib/module/Didomi.js.map +1 -1
- package/lib/typescript/Constants.d.ts +1 -1
- package/lib/typescript/CurrentUserStatusTransaction.d.ts +14 -0
- package/lib/typescript/Didomi.d.ts +8 -0
- package/package.json +1 -1
- package/react-native-didomi.podspec +1 -1
- package/src/Constants.ts +1 -1
- package/src/CurrentUserStatusTransaction.ts +140 -0
- package/src/Didomi.ts +9 -0
package/android/build.gradle
CHANGED
|
@@ -952,10 +952,31 @@ class DidomiModule(reactContext: ReactApplicationContext) : ReactContextBaseJava
|
|
|
952
952
|
}
|
|
953
953
|
}
|
|
954
954
|
|
|
955
|
+
@ReactMethod
|
|
956
|
+
fun commitCurrentUserStatusTransaction(
|
|
957
|
+
enabledPurposes: ReadableArray,
|
|
958
|
+
disabledPurposes: ReadableArray,
|
|
959
|
+
enabledVendors: ReadableArray,
|
|
960
|
+
disabledVendors: ReadableArray,
|
|
961
|
+
promise: Promise
|
|
962
|
+
) {
|
|
963
|
+
val transaction = Didomi.getInstance().openCurrentUserStatusTransaction()
|
|
964
|
+
transaction.enablePurposes(*readableArrayToStringArray(enabledPurposes))
|
|
965
|
+
transaction.disablePurposes(*readableArrayToStringArray(disabledPurposes))
|
|
966
|
+
transaction.enableVendors(*readableArrayToStringArray(enabledVendors))
|
|
967
|
+
transaction.disableVendors(*readableArrayToStringArray(disabledVendors))
|
|
968
|
+
promise.resolve(transaction.commit())
|
|
969
|
+
}
|
|
970
|
+
|
|
955
971
|
private fun prepareEvent(eventName: String, params: Any?) {
|
|
956
972
|
Log.d("prepareEvent", "Sending $eventName")
|
|
957
973
|
reactContext
|
|
958
974
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
959
975
|
.emit(eventName, params)
|
|
960
976
|
}
|
|
977
|
+
|
|
978
|
+
// Required to transform from array to variadic.
|
|
979
|
+
private fun readableArrayToStringArray(readableArray: ReadableArray): Array<String> {
|
|
980
|
+
return Array(readableArray.size()) { i -> readableArray.getString(i) ?: "" }
|
|
981
|
+
}
|
|
961
982
|
}
|
package/ios/Didomi.m
CHANGED
|
@@ -250,6 +250,13 @@ RCT_EXTERN_METHOD(stopListeningToVendorStatus:(NSString *)vendorId
|
|
|
250
250
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
251
251
|
reject:(RCTPromiseRejectBlock)reject)
|
|
252
252
|
|
|
253
|
+
RCT_EXTERN_METHOD(commitCurrentUserStatusTransaction:(NSArray<NSString *> *)enabledPurposes
|
|
254
|
+
disabledPurposes:(NSArray<NSString *> *)disabledPurposes
|
|
255
|
+
enabledVendors:(NSArray<NSString *> *)enabledVendors
|
|
256
|
+
disabledVendors:(NSArray<NSString *> *)disabledVendors
|
|
257
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
258
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
259
|
+
|
|
253
260
|
RCT_EXTERN_METHOD(supportedEvents)
|
|
254
261
|
|
|
255
262
|
@end
|
package/ios/RNDidomi.swift
CHANGED
|
@@ -37,16 +37,16 @@ class RNDidomi: RCTEventEmitter {
|
|
|
37
37
|
|
|
38
38
|
@objc(onReady:reject:)
|
|
39
39
|
func onReady(resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
|
|
40
|
-
Didomi.shared.onReady {
|
|
41
|
-
self
|
|
40
|
+
Didomi.shared.onReady { [weak self] in
|
|
41
|
+
self?.dispatchEvent(withName: "on_ready_callback", body: nil)
|
|
42
42
|
}
|
|
43
43
|
resolve(0)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
@objc(onError:reject:)
|
|
47
47
|
func onError(resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
|
|
48
|
-
Didomi.shared.onError { error in
|
|
49
|
-
self
|
|
48
|
+
Didomi.shared.onError { [weak self] error in
|
|
49
|
+
self?.dispatchEvent(withName: "on_error_callback", body: error.descriptionText)
|
|
50
50
|
}
|
|
51
51
|
resolve(0)
|
|
52
52
|
}
|
|
@@ -480,10 +480,10 @@ class RNDidomi: RCTEventEmitter {
|
|
|
480
480
|
dynamic func listenToVendorStatus(vendorId: String, resolve:RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
|
|
481
481
|
if (!vendorStatusListeners.contains(vendorId)) {
|
|
482
482
|
vendorStatusListeners.insert(vendorId)
|
|
483
|
-
Didomi.shared.addVendorStatusListener(id: vendorId) { vendorStatus in
|
|
483
|
+
Didomi.shared.addVendorStatusListener(id: vendorId) { [weak self] vendorStatus in
|
|
484
484
|
let encoder = JSONEncoder()
|
|
485
485
|
let statusJson = try? JSONSerialization.jsonObject(with: encoder.encode(vendorStatus)) as? [String: Any]
|
|
486
|
-
self
|
|
486
|
+
self?.dispatchEvent(withName: "on_vendor_status_change_\(vendorId)", body: statusJson)
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
489
|
resolve(0)
|
|
@@ -497,6 +497,23 @@ class RNDidomi: RCTEventEmitter {
|
|
|
497
497
|
}
|
|
498
498
|
resolve(0)
|
|
499
499
|
}
|
|
500
|
+
|
|
501
|
+
@objc(commitCurrentUserStatusTransaction:disabledPurposes:enabledVendors:disabledVendors:resolve:reject:)
|
|
502
|
+
dynamic func commitCurrentUserStatusTransaction(
|
|
503
|
+
enabledPurposes: [String],
|
|
504
|
+
disabledPurposes: [String],
|
|
505
|
+
enabledVendors: [String],
|
|
506
|
+
disabledVendors: [String],
|
|
507
|
+
resolve:RCTPromiseResolveBlock,
|
|
508
|
+
reject:RCTPromiseRejectBlock
|
|
509
|
+
) {
|
|
510
|
+
let transaction = Didomi.shared.openCurrentUserStatusTransaction()
|
|
511
|
+
transaction.enablePurposes(enabledPurposes)
|
|
512
|
+
transaction.disablePurposes(disabledPurposes)
|
|
513
|
+
transaction.enableVendors(enabledVendors)
|
|
514
|
+
transaction.disableVendors(disabledVendors)
|
|
515
|
+
resolve(transaction.commit())
|
|
516
|
+
}
|
|
500
517
|
}
|
|
501
518
|
|
|
502
519
|
// MARK: Didomi Specific structs
|
|
@@ -584,164 +601,164 @@ extension RNDidomi {
|
|
|
584
601
|
|
|
585
602
|
private func initEventListener() {
|
|
586
603
|
|
|
587
|
-
didomiEventListener.onConsentChanged = { event in
|
|
588
|
-
self
|
|
604
|
+
didomiEventListener.onConsentChanged = { [weak self] event in
|
|
605
|
+
self?.dispatchEvent(withName: "on_consent_changed", body: "")
|
|
589
606
|
}
|
|
590
607
|
|
|
591
|
-
didomiEventListener.onError = { event in
|
|
592
|
-
self
|
|
608
|
+
didomiEventListener.onError = { [weak self] event in
|
|
609
|
+
self?.dispatchEvent(withName: "on_error", body: event.descriptionText)
|
|
593
610
|
}
|
|
594
611
|
|
|
595
|
-
didomiEventListener.onReady = { event in
|
|
596
|
-
self
|
|
612
|
+
didomiEventListener.onReady = { [weak self] event in
|
|
613
|
+
self?.dispatchEvent(withName: "on_ready", body: "")
|
|
597
614
|
}
|
|
598
615
|
|
|
599
|
-
didomiEventListener.onHideNotice = { event in
|
|
600
|
-
self
|
|
616
|
+
didomiEventListener.onHideNotice = { [weak self] event in
|
|
617
|
+
self?.dispatchEvent(withName: "on_hide_notice", body: "")
|
|
601
618
|
}
|
|
602
619
|
|
|
603
|
-
didomiEventListener.onShowNotice = { event in
|
|
604
|
-
self
|
|
620
|
+
didomiEventListener.onShowNotice = { [weak self] event in
|
|
621
|
+
self?.dispatchEvent(withName: "on_show_notice", body: "")
|
|
605
622
|
}
|
|
606
623
|
|
|
607
|
-
didomiEventListener.onNoticeClickAgree = { event in
|
|
608
|
-
self
|
|
624
|
+
didomiEventListener.onNoticeClickAgree = { [weak self] event in
|
|
625
|
+
self?.dispatchEvent(withName: "on_notice_click_agree", body: "")
|
|
609
626
|
}
|
|
610
627
|
|
|
611
|
-
didomiEventListener.onNoticeClickDisagree = { event in
|
|
612
|
-
self
|
|
628
|
+
didomiEventListener.onNoticeClickDisagree = { [weak self] event in
|
|
629
|
+
self?.dispatchEvent(withName: "on_notice_click_disagree", body: "")
|
|
613
630
|
}
|
|
614
631
|
|
|
615
|
-
didomiEventListener.onNoticeClickViewVendors = { event in
|
|
616
|
-
self
|
|
632
|
+
didomiEventListener.onNoticeClickViewVendors = { [weak self] event in
|
|
633
|
+
self?.dispatchEvent(withName: "on_notice_click_view_vendors", body: "")
|
|
617
634
|
}
|
|
618
635
|
|
|
619
|
-
didomiEventListener.onNoticeClickViewSPIPurposes = { event in
|
|
620
|
-
self
|
|
636
|
+
didomiEventListener.onNoticeClickViewSPIPurposes = { [weak self] event in
|
|
637
|
+
self?.dispatchEvent(withName: "on_notice_click_view_spi_purposes", body: "")
|
|
621
638
|
}
|
|
622
639
|
|
|
623
|
-
didomiEventListener.onNoticeClickMoreInfo = { event in
|
|
624
|
-
self
|
|
640
|
+
didomiEventListener.onNoticeClickMoreInfo = { [weak self] event in
|
|
641
|
+
self?.dispatchEvent(withName: "on_notice_click_more_info", body: "")
|
|
625
642
|
}
|
|
626
643
|
|
|
627
|
-
didomiEventListener.onNoticeClickPrivacyPolicy = { event in
|
|
628
|
-
self
|
|
644
|
+
didomiEventListener.onNoticeClickPrivacyPolicy = { [weak self] event in
|
|
645
|
+
self?.dispatchEvent(withName: "on_notice_click_privacy_policy", body: "")
|
|
629
646
|
}
|
|
630
647
|
|
|
631
|
-
didomiEventListener.onHidePreferences = { event in
|
|
632
|
-
self
|
|
648
|
+
didomiEventListener.onHidePreferences = { [weak self] event in
|
|
649
|
+
self?.dispatchEvent(withName: "on_hide_preferences", body: "")
|
|
633
650
|
}
|
|
634
651
|
|
|
635
|
-
didomiEventListener.onShowPreferences = { event in
|
|
636
|
-
self
|
|
652
|
+
didomiEventListener.onShowPreferences = { [weak self] event in
|
|
653
|
+
self?.dispatchEvent(withName: "on_show_preferences", body: "")
|
|
637
654
|
}
|
|
638
655
|
|
|
639
|
-
didomiEventListener.onPreferencesClickViewPurposes = { event in
|
|
640
|
-
self
|
|
656
|
+
didomiEventListener.onPreferencesClickViewPurposes = { [weak self] event in
|
|
657
|
+
self?.dispatchEvent(withName: "on_preferences_click_view_purposes", body: "")
|
|
641
658
|
}
|
|
642
659
|
|
|
643
|
-
didomiEventListener.onPreferencesClickViewVendors = { event in
|
|
644
|
-
self
|
|
660
|
+
didomiEventListener.onPreferencesClickViewVendors = { [weak self] event in
|
|
661
|
+
self?.dispatchEvent(withName: "on_preferences_click_view_vendors", body: "")
|
|
645
662
|
}
|
|
646
663
|
|
|
647
|
-
didomiEventListener.onPreferencesClickViewSPIPurposes = { event in
|
|
648
|
-
self
|
|
664
|
+
didomiEventListener.onPreferencesClickViewSPIPurposes = { [weak self] event in
|
|
665
|
+
self?.dispatchEvent(withName: "on_preferences_click_view_spi_purposes", body: "")
|
|
649
666
|
}
|
|
650
667
|
|
|
651
|
-
didomiEventListener.onPreferencesClickAgreeToAll = { event in
|
|
652
|
-
self
|
|
668
|
+
didomiEventListener.onPreferencesClickAgreeToAll = { [weak self] event in
|
|
669
|
+
self?.dispatchEvent(withName: "on_preferences_click_agree_to_all", body: "")
|
|
653
670
|
}
|
|
654
671
|
|
|
655
|
-
didomiEventListener.onPreferencesClickDisagreeToAll = { event in
|
|
656
|
-
self
|
|
672
|
+
didomiEventListener.onPreferencesClickDisagreeToAll = { [weak self] event in
|
|
673
|
+
self?.dispatchEvent(withName: "on_preferences_click_disagree_to_all", body: "")
|
|
657
674
|
}
|
|
658
675
|
|
|
659
|
-
didomiEventListener.onPreferencesClickAgreeToAllPurposes = { event in
|
|
660
|
-
self
|
|
676
|
+
didomiEventListener.onPreferencesClickAgreeToAllPurposes = { [weak self] event in
|
|
677
|
+
self?.dispatchEvent(withName: "on_preferences_click_agree_to_all_purposes", body: "")
|
|
661
678
|
}
|
|
662
679
|
|
|
663
|
-
didomiEventListener.onPreferencesClickDisagreeToAllPurposes = { event in
|
|
664
|
-
self
|
|
680
|
+
didomiEventListener.onPreferencesClickDisagreeToAllPurposes = { [weak self] event in
|
|
681
|
+
self?.dispatchEvent(withName: "on_preferences_click_disagree_to_all_purposes", body: "")
|
|
665
682
|
}
|
|
666
683
|
|
|
667
|
-
didomiEventListener.onPreferencesClickResetAllPurposes = { event in
|
|
668
|
-
self
|
|
684
|
+
didomiEventListener.onPreferencesClickResetAllPurposes = { [weak self] event in
|
|
685
|
+
self?.dispatchEvent(withName: "on_preferences_click_reset_all_purposes", body: "")
|
|
669
686
|
}
|
|
670
687
|
|
|
671
|
-
didomiEventListener.onPreferencesClickPurposeAgree = { event, purposeId in
|
|
672
|
-
self
|
|
688
|
+
didomiEventListener.onPreferencesClickPurposeAgree = { [weak self] event, purposeId in
|
|
689
|
+
self?.dispatchEvent(withName: "on_preferences_click_purpose_agree", body: purposeId)
|
|
673
690
|
}
|
|
674
691
|
|
|
675
|
-
didomiEventListener.onPreferencesClickPurposeDisagree = { event, purposeId in
|
|
676
|
-
self
|
|
692
|
+
didomiEventListener.onPreferencesClickPurposeDisagree = { [weak self] event, purposeId in
|
|
693
|
+
self?.dispatchEvent(withName: "on_preferences_click_purpose_disagree", body: purposeId)
|
|
677
694
|
}
|
|
678
695
|
|
|
679
|
-
didomiEventListener.onPreferencesClickCategoryAgree = { event, categoryId in
|
|
680
|
-
self
|
|
696
|
+
didomiEventListener.onPreferencesClickCategoryAgree = { [weak self] event, categoryId in
|
|
697
|
+
self?.dispatchEvent(withName: "on_preferences_click_category_agree", body: categoryId)
|
|
681
698
|
}
|
|
682
699
|
|
|
683
|
-
didomiEventListener.onPreferencesClickCategoryDisagree = { event, categoryId in
|
|
684
|
-
self
|
|
700
|
+
didomiEventListener.onPreferencesClickCategoryDisagree = { [weak self] event, categoryId in
|
|
701
|
+
self?.dispatchEvent(withName: "on_preferences_click_category_disagree", body: categoryId)
|
|
685
702
|
}
|
|
686
703
|
|
|
687
|
-
didomiEventListener.onPreferencesClickSaveChoices = { event in
|
|
688
|
-
self
|
|
704
|
+
didomiEventListener.onPreferencesClickSaveChoices = { [weak self] event in
|
|
705
|
+
self?.dispatchEvent(withName: "on_preferences_click_save_choices", body: "")
|
|
689
706
|
}
|
|
690
707
|
|
|
691
|
-
didomiEventListener.onPreferencesClickAgreeToAllVendors = { event in
|
|
692
|
-
self
|
|
708
|
+
didomiEventListener.onPreferencesClickAgreeToAllVendors = { [weak self] event in
|
|
709
|
+
self?.dispatchEvent(withName: "on_preferences_click_agree_to_all_vendors", body: "")
|
|
693
710
|
}
|
|
694
711
|
|
|
695
|
-
didomiEventListener.onPreferencesClickDisagreeToAllVendors = { event in
|
|
696
|
-
self
|
|
712
|
+
didomiEventListener.onPreferencesClickDisagreeToAllVendors = { [weak self] event in
|
|
713
|
+
self?.dispatchEvent(withName: "on_preferences_click_disagree_to_all_vendors", body: "")
|
|
697
714
|
}
|
|
698
715
|
|
|
699
|
-
didomiEventListener.onPreferencesClickVendorAgree = { event, vendorId in
|
|
700
|
-
self
|
|
716
|
+
didomiEventListener.onPreferencesClickVendorAgree = { [weak self] event, vendorId in
|
|
717
|
+
self?.dispatchEvent(withName: "on_preferences_click_vendor_agree", body: vendorId)
|
|
701
718
|
}
|
|
702
719
|
|
|
703
|
-
didomiEventListener.onPreferencesClickVendorDisagree = { event, vendorId in
|
|
704
|
-
self
|
|
720
|
+
didomiEventListener.onPreferencesClickVendorDisagree = { [weak self] event, vendorId in
|
|
721
|
+
self?.dispatchEvent(withName: "on_preferences_click_vendor_disagree", body: vendorId)
|
|
705
722
|
}
|
|
706
723
|
|
|
707
|
-
didomiEventListener.onPreferencesClickVendorSaveChoices = { event in
|
|
708
|
-
self
|
|
724
|
+
didomiEventListener.onPreferencesClickVendorSaveChoices = { [weak self] event in
|
|
725
|
+
self?.dispatchEvent(withName: "on_preferences_click_vendor_save_choices", body: "")
|
|
709
726
|
}
|
|
710
727
|
|
|
711
|
-
didomiEventListener.onPreferencesClickSPIPurposeAgree = { event, purposeId in
|
|
712
|
-
self
|
|
728
|
+
didomiEventListener.onPreferencesClickSPIPurposeAgree = { [weak self] event, purposeId in
|
|
729
|
+
self?.dispatchEvent(withName: "on_preferences_click_spi_purpose_agree", body: purposeId)
|
|
713
730
|
}
|
|
714
731
|
|
|
715
|
-
didomiEventListener.onPreferencesClickSPIPurposeDisagree = { event, purposeId in
|
|
716
|
-
self
|
|
732
|
+
didomiEventListener.onPreferencesClickSPIPurposeDisagree = { [weak self] event, purposeId in
|
|
733
|
+
self?.dispatchEvent(withName: "on_preferences_click_spi_purpose_disagree", body: purposeId)
|
|
717
734
|
}
|
|
718
735
|
|
|
719
|
-
didomiEventListener.onPreferencesClickSPICategoryAgree = { event, categoryId in
|
|
720
|
-
self
|
|
736
|
+
didomiEventListener.onPreferencesClickSPICategoryAgree = { [weak self] event, categoryId in
|
|
737
|
+
self?.dispatchEvent(withName: "on_preferences_click_spi_category_agree", body: categoryId)
|
|
721
738
|
}
|
|
722
739
|
|
|
723
|
-
didomiEventListener.onPreferencesClickSPICategoryDisagree = { event, categoryId in
|
|
724
|
-
self
|
|
740
|
+
didomiEventListener.onPreferencesClickSPICategoryDisagree = { [weak self] event, categoryId in
|
|
741
|
+
self?.dispatchEvent(withName: "on_preferences_click_spi_category_disagree", body: categoryId)
|
|
725
742
|
}
|
|
726
743
|
|
|
727
|
-
didomiEventListener.onPreferencesClickSPIPurposeSaveChoices = { event in
|
|
728
|
-
self
|
|
744
|
+
didomiEventListener.onPreferencesClickSPIPurposeSaveChoices = { [weak self] event in
|
|
745
|
+
self?.dispatchEvent(withName: "on_preferences_click_spi_purpose_save_choices", body: "")
|
|
729
746
|
}
|
|
730
747
|
|
|
731
|
-
didomiEventListener.onSyncDone = { event, organizationUserId in
|
|
732
|
-
self
|
|
748
|
+
didomiEventListener.onSyncDone = { [weak self] event, organizationUserId in
|
|
749
|
+
self?.dispatchEvent(withName: "on_sync_done", body: organizationUserId)
|
|
733
750
|
}
|
|
734
751
|
|
|
735
|
-
didomiEventListener.onSyncError = { event, error in
|
|
736
|
-
self
|
|
752
|
+
didomiEventListener.onSyncError = { [weak self] event, error in
|
|
753
|
+
self?.dispatchEvent(withName: "on_sync_error", body: error)
|
|
737
754
|
}
|
|
738
755
|
|
|
739
|
-
didomiEventListener.onLanguageUpdated = { event, languageCode in
|
|
740
|
-
self
|
|
756
|
+
didomiEventListener.onLanguageUpdated = { [weak self] event, languageCode in
|
|
757
|
+
self?.dispatchEvent(withName: "on_language_updated", body: languageCode)
|
|
741
758
|
}
|
|
742
759
|
|
|
743
|
-
didomiEventListener.onLanguageUpdateFailed = { event, reason in
|
|
744
|
-
self
|
|
760
|
+
didomiEventListener.onLanguageUpdateFailed = { [weak self] event, reason in
|
|
761
|
+
self?.dispatchEvent(withName: "on_language_update_failed", body: reason)
|
|
745
762
|
}
|
|
746
763
|
|
|
747
764
|
Didomi.shared.addEventListener(listener: didomiEventListener)
|
|
@@ -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.2.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.2.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":[]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createCurrentUserStatusTransaction = void 0;
|
|
7
|
+
// Transaction type exposed to client's app that allows the enabling and disabling of vendors and purposes.
|
|
8
|
+
|
|
9
|
+
// Interface used to transfer enabled and disabled IDs between internal methods in a more convenient way.
|
|
10
|
+
|
|
11
|
+
// Callback executed once changes are committed to the native implementation.
|
|
12
|
+
|
|
13
|
+
// Create a `CurrentUserStatusTransaction` object based on the native implementation.
|
|
14
|
+
// Please note that this implementation delays the interaction with the native libraries until the changes are committed.
|
|
15
|
+
const createCurrentUserStatusTransaction = nativeCallback => {
|
|
16
|
+
// Variable used to store statuses before changes are committed against the transaction.
|
|
17
|
+
let purposesStatus = {};
|
|
18
|
+
let vendorsStatus = {};
|
|
19
|
+
const enablePurposes = ids => {
|
|
20
|
+
ids.forEach(enablePurpose);
|
|
21
|
+
return transaction;
|
|
22
|
+
};
|
|
23
|
+
const enablePurpose = id => {
|
|
24
|
+
purposesStatus[id] = {
|
|
25
|
+
id,
|
|
26
|
+
enabled: true
|
|
27
|
+
};
|
|
28
|
+
return transaction;
|
|
29
|
+
};
|
|
30
|
+
const enableVendors = ids => {
|
|
31
|
+
ids.forEach(enableVendor);
|
|
32
|
+
return transaction;
|
|
33
|
+
};
|
|
34
|
+
const enableVendor = id => {
|
|
35
|
+
vendorsStatus[id] = {
|
|
36
|
+
id,
|
|
37
|
+
enabled: true
|
|
38
|
+
};
|
|
39
|
+
return transaction;
|
|
40
|
+
};
|
|
41
|
+
const disablePurposes = ids => {
|
|
42
|
+
ids.forEach(disablePurpose);
|
|
43
|
+
return transaction;
|
|
44
|
+
};
|
|
45
|
+
const disablePurpose = id => {
|
|
46
|
+
purposesStatus[id] = {
|
|
47
|
+
id,
|
|
48
|
+
enabled: false
|
|
49
|
+
};
|
|
50
|
+
return transaction;
|
|
51
|
+
};
|
|
52
|
+
const disableVendors = ids => {
|
|
53
|
+
ids.forEach(disableVendor);
|
|
54
|
+
return transaction;
|
|
55
|
+
};
|
|
56
|
+
const disableVendor = id => {
|
|
57
|
+
vendorsStatus[id] = {
|
|
58
|
+
id,
|
|
59
|
+
enabled: false
|
|
60
|
+
};
|
|
61
|
+
return transaction;
|
|
62
|
+
};
|
|
63
|
+
const commit = () => {
|
|
64
|
+
const vendorIdsFromStatus = getIdsFromStatus(vendorsStatus);
|
|
65
|
+
const purposeIdsFromStatus = getIdsFromStatus(purposesStatus);
|
|
66
|
+
const result = nativeCallback(purposeIdsFromStatus.enabled, purposeIdsFromStatus.disabled, vendorIdsFromStatus.enabled, vendorIdsFromStatus.disabled);
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
const transaction = {
|
|
70
|
+
enablePurpose,
|
|
71
|
+
enablePurposes,
|
|
72
|
+
enableVendor,
|
|
73
|
+
enableVendors,
|
|
74
|
+
disablePurpose,
|
|
75
|
+
disablePurposes,
|
|
76
|
+
disableVendor,
|
|
77
|
+
disableVendors,
|
|
78
|
+
commit
|
|
79
|
+
};
|
|
80
|
+
return transaction;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Separates and returns IDs from the `status` object into `enabled` and `disabled` based on their `enabled` state.
|
|
84
|
+
exports.createCurrentUserStatusTransaction = createCurrentUserStatusTransaction;
|
|
85
|
+
const getIdsFromStatus = status => {
|
|
86
|
+
let enabled = [];
|
|
87
|
+
let disabled = [];
|
|
88
|
+
const keys = Object.keys(status);
|
|
89
|
+
keys.forEach(key => {
|
|
90
|
+
const value = status[key];
|
|
91
|
+
if (value.enabled) {
|
|
92
|
+
enabled.push(key);
|
|
93
|
+
} else {
|
|
94
|
+
disabled.push(key);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
enabled,
|
|
99
|
+
disabled
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=CurrentUserStatusTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createCurrentUserStatusTransaction","nativeCallback","purposesStatus","vendorsStatus","enablePurposes","ids","forEach","enablePurpose","transaction","id","enabled","enableVendors","enableVendor","disablePurposes","disablePurpose","disableVendors","disableVendor","commit","vendorIdsFromStatus","getIdsFromStatus","purposeIdsFromStatus","result","disabled","exports","status","keys","Object","key","value","push"],"sources":["CurrentUserStatusTransaction.ts"],"sourcesContent":["import { PurposeStatus, VendorStatus } from './DidomiTypes';\n\n// Transaction type exposed to client's app that allows the enabling and disabling of vendors and purposes.\nexport interface CurrentUserStatusTransaction {\n // Function to enable a specific purpose by its ID and returns the updated transaction\n enablePurpose(id: string): CurrentUserStatusTransaction;\n\n // Function to enable multiple purposes at once by their IDs and returns the updated transaction\n enablePurposes(ids: string[]): CurrentUserStatusTransaction;\n\n // Function to enable a specific vendor by its ID and returns the updated transaction\n enableVendor(id: string): CurrentUserStatusTransaction;\n\n // Function to enable multiple vendors at once by their IDs and returns the updated transaction\n enableVendors(ids: string[]): CurrentUserStatusTransaction;\n\n // Function to disable a specific purpose by its ID and returns the updated transaction\n disablePurpose(id: string): CurrentUserStatusTransaction;\n\n // Function to disable multiple purposes at once by their IDs and returns the updated transaction\n disablePurposes(ids: string[]): CurrentUserStatusTransaction;\n\n // Function to disable a specific vendor by its ID and returns the updated transaction\n disableVendor(id: string): CurrentUserStatusTransaction;\n\n // Function to disable multiple vendors at once by their IDs and returns the updated transaction\n disableVendors(ids: string[]): CurrentUserStatusTransaction;\n\n // Function to commit the changes made to the status of purposes and vendors\n // Returns a Promise that resolves to a boolean indicating whether the commit was successful\n commit(): Promise<boolean>;\n}\n\n// Interface used to transfer enabled and disabled IDs between internal methods in a more convenient way.\ninterface StatusIDs {\n enabled: string[];\n disabled: string[];\n}\n\n// Callback executed once changes are committed to the native implementation.\ntype NativeCallback = (\n enabledPurposes: string[],\n disabledPurposes: string[],\n enabledVendors: string[],\n disabledVendors: string[]\n ) => Promise<boolean>;\n\n// Create a `CurrentUserStatusTransaction` object based on the native implementation.\n// Please note that this implementation delays the interaction with the native libraries until the changes are committed.\nexport const createCurrentUserStatusTransaction = (nativeCallback: NativeCallback): CurrentUserStatusTransaction => {\n\n // Variable used to store statuses before changes are committed against the transaction.\n let purposesStatus: { [key: string]: PurposeStatus } = {};\n let vendorsStatus: { [key: string]: VendorStatus } = {};\n\n const enablePurposes = (ids: string[]): CurrentUserStatusTransaction => {\n ids.forEach(enablePurpose);\n return transaction;\n };\n\n const enablePurpose = (id: string): CurrentUserStatusTransaction => {\n purposesStatus[id] = { id, enabled: true };\n return transaction;\n };\n\n const enableVendors = (ids: string[]): CurrentUserStatusTransaction => {\n ids.forEach(enableVendor);\n return transaction;\n };\n\n const enableVendor = (id: string): CurrentUserStatusTransaction => {\n vendorsStatus[id] = { id, enabled: true };\n return transaction;\n };\n\n const disablePurposes = (ids: string[]): CurrentUserStatusTransaction => {\n ids.forEach(disablePurpose);\n return transaction;\n };\n\n const disablePurpose = (id: string): CurrentUserStatusTransaction => {\n purposesStatus[id] = { id, enabled: false };\n return transaction;\n };\n\n const disableVendors = (ids: string[]) => {\n ids.forEach(disableVendor);\n return transaction;\n };\n\n const disableVendor = (id: string): CurrentUserStatusTransaction => {\n vendorsStatus[id] = { id, enabled: false };\n return transaction;\n };\n\n const commit = (): Promise<boolean> => {\n const vendorIdsFromStatus = getIdsFromStatus(vendorsStatus);\n const purposeIdsFromStatus = getIdsFromStatus(purposesStatus);\n\n const result = nativeCallback(\n purposeIdsFromStatus.enabled,\n purposeIdsFromStatus.disabled,\n vendorIdsFromStatus.enabled,\n vendorIdsFromStatus.disabled,\n );\n\n return result;\n };\n\n const transaction: CurrentUserStatusTransaction = {\n enablePurpose,\n enablePurposes,\n enableVendor,\n enableVendors,\n disablePurpose,\n disablePurposes,\n disableVendor,\n disableVendors,\n commit,\n };\n\n return transaction;\n}\n\n// Separates and returns IDs from the `status` object into `enabled` and `disabled` based on their `enabled` state.\nconst getIdsFromStatus = (status: { [key: string]: PurposeStatus } | { [key: string]: VendorStatus }): StatusIDs => {\n let enabled: string[] = [];\n let disabled: string[] = [];\n const keys = Object.keys(status);\n keys.forEach((key) => {\n const value = status[key];\n if (value.enabled) {\n enabled.push(key);\n } else {\n disabled.push(key);\n }\n });\n\n return { enabled, disabled };\n}\n"],"mappings":";;;;;;AAEA;;AA+BA;;AAMA;;AAQA;AACA;AACO,MAAMA,kCAAkC,GAAIC,cAA8B,IAAmC;EAElH;EACA,IAAIC,cAAgD,GAAG,CAAC,CAAC;EACzD,IAAIC,aAA8C,GAAG,CAAC,CAAC;EAEvD,MAAMC,cAAc,GAAIC,GAAa,IAAmC;IACtEA,GAAG,CAACC,OAAO,CAACC,aAAa,CAAC;IAC1B,OAAOC,WAAW;EACpB,CAAC;EAED,MAAMD,aAAa,GAAIE,EAAU,IAAmC;IAClEP,cAAc,CAACO,EAAE,CAAC,GAAG;MAAEA,EAAE;MAAEC,OAAO,EAAE;IAAK,CAAC;IAC1C,OAAOF,WAAW;EACpB,CAAC;EAED,MAAMG,aAAa,GAAIN,GAAa,IAAmC;IACrEA,GAAG,CAACC,OAAO,CAACM,YAAY,CAAC;IACzB,OAAOJ,WAAW;EACpB,CAAC;EAED,MAAMI,YAAY,GAAIH,EAAU,IAAmC;IACjEN,aAAa,CAACM,EAAE,CAAC,GAAG;MAAEA,EAAE;MAAEC,OAAO,EAAE;IAAK,CAAC;IACzC,OAAOF,WAAW;EACpB,CAAC;EAED,MAAMK,eAAe,GAAIR,GAAa,IAAmC;IACvEA,GAAG,CAACC,OAAO,CAACQ,cAAc,CAAC;IAC3B,OAAON,WAAW;EACpB,CAAC;EAED,MAAMM,cAAc,GAAIL,EAAU,IAAmC;IACnEP,cAAc,CAACO,EAAE,CAAC,GAAG;MAAEA,EAAE;MAAEC,OAAO,EAAE;IAAM,CAAC;IAC3C,OAAOF,WAAW;EACpB,CAAC;EAED,MAAMO,cAAc,GAAIV,GAAa,IAAK;IACxCA,GAAG,CAACC,OAAO,CAACU,aAAa,CAAC;IAC1B,OAAOR,WAAW;EACpB,CAAC;EAED,MAAMQ,aAAa,GAAIP,EAAU,IAAmC;IAClEN,aAAa,CAACM,EAAE,CAAC,GAAG;MAAEA,EAAE;MAAEC,OAAO,EAAE;IAAM,CAAC;IAC1C,OAAOF,WAAW;EACpB,CAAC;EAED,MAAMS,MAAM,GAAGA,CAAA,KAAwB;IACrC,MAAMC,mBAAmB,GAAGC,gBAAgB,CAAChB,aAAa,CAAC;IAC3D,MAAMiB,oBAAoB,GAAGD,gBAAgB,CAACjB,cAAc,CAAC;IAE7D,MAAMmB,MAAM,GAAGpB,cAAc,CAC3BmB,oBAAoB,CAACV,OAAO,EAC5BU,oBAAoB,CAACE,QAAQ,EAC7BJ,mBAAmB,CAACR,OAAO,EAC3BQ,mBAAmB,CAACI,QACtB,CAAC;IAED,OAAOD,MAAM;EACf,CAAC;EAED,MAAMb,WAAyC,GAAG;IAChDD,aAAa;IACbH,cAAc;IACdQ,YAAY;IACZD,aAAa;IACbG,cAAc;IACdD,eAAe;IACfG,aAAa;IACbD,cAAc;IACdE;EACF,CAAC;EAED,OAAOT,WAAW;AACpB,CAAC;;AAED;AAAAe,OAAA,CAAAvB,kCAAA,GAAAA,kCAAA;AACA,MAAMmB,gBAAgB,GAAIK,MAA0E,IAAgB;EAClH,IAAId,OAAiB,GAAG,EAAE;EAC1B,IAAIY,QAAkB,GAAG,EAAE;EAC3B,MAAMG,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACD,MAAM,CAAC;EAChCC,IAAI,CAACnB,OAAO,CAAEqB,GAAG,IAAK;IACpB,MAAMC,KAAK,GAAGJ,MAAM,CAACG,GAAG,CAAC;IACzB,IAAIC,KAAK,CAAClB,OAAO,EAAE;MACjBA,OAAO,CAACmB,IAAI,CAACF,GAAG,CAAC;IACnB,CAAC,MAAM;MACLL,QAAQ,CAACO,IAAI,CAACF,GAAG,CAAC;IACpB;EACF,CAAC,CAAC;EAEF,OAAO;IAAEjB,OAAO;IAAEY;EAAS,CAAC;AAC9B,CAAC","ignoreList":[]}
|
package/lib/commonjs/Didomi.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.Didomi = void 0;
|
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _DidomiListener = require("./DidomiListener");
|
|
9
9
|
var _Constants = require("./Constants");
|
|
10
|
+
var _CurrentUserStatusTransaction = require("./CurrentUserStatusTransaction");
|
|
10
11
|
const {
|
|
11
12
|
Didomi: RNDidomi
|
|
12
13
|
} = _reactNative.NativeModules;
|
|
@@ -512,6 +513,13 @@ const Didomi = exports.Didomi = {
|
|
|
512
513
|
* In order to update the language of the views displayed by the Didomi SDK, this method needs to be called before these views are displayed.
|
|
513
514
|
* @param languageCode: string containing the language code e.g.: "es", "fr", etc.
|
|
514
515
|
*/
|
|
515
|
-
updateSelectedLanguage: languageCode => RNDidomi.updateSelectedLanguage(languageCode)
|
|
516
|
+
updateSelectedLanguage: languageCode => RNDidomi.updateSelectedLanguage(languageCode),
|
|
517
|
+
/**
|
|
518
|
+
* Creates a `CurrentUserStatusTransaction` object.
|
|
519
|
+
* This object provides mechanisms to stage updates to the user status regarding purposes and vendors, allowing for batch operations.
|
|
520
|
+
* Updates made through its methods are queued and applied simultaneously to the user status only once the commit method of the returned object is called.
|
|
521
|
+
* @returns A new `CurrentUserStatusTransaction` object.
|
|
522
|
+
*/
|
|
523
|
+
openCurrentUserStatusTransaction: () => (0, _CurrentUserStatusTransaction.createCurrentUserStatusTransaction)(RNDidomi.commitCurrentUserStatusTransaction)
|
|
516
524
|
};
|
|
517
525
|
//# sourceMappingURL=Didomi.js.map
|