@didomi/react-native 1.6.0 → 1.10.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/src/Didomi.ts CHANGED
@@ -13,9 +13,11 @@ export const Didomi = {
13
13
  * @param localConfigurationPath: Path to your local config file. Defaults to didomi_config.json if null.
14
14
  * @param remoteConfigurationURL: URL to a remote configuration file to load during initialization. This parameter is not used yet. Set it to null for now.
15
15
  * @param providerId: Your provider ID (if any).
16
- * @param disableDidomiRemoteConfig: Whether to disable loading the remove configuration from the Didomi config. Keep this to "false" for loading configuration from the Didomi Console.
16
+ * @param disableDidomiRemoteConfig: Whether to disable loading the remote configuration from the Didomi config. Keep this to "false" for loading configuration from the Didomi Console.
17
17
  * @param languageCode: Language in which the consent UI should be displayed. By default, the consent UI is displayed in the language configured in the device settings. This property allows you to override the default setting and specify a language to display the UI in. String containing the language code e.g.: "es", "fr", etc.
18
18
  * @param noticeId: Notice id for the remote configuration.
19
+ * @param androidTvNoticeId: Notice id for the remote configuration when running on Android TV device (ignored on iOS / tvOS). Note that using remote configuration is mandatory for TV devices.
20
+ * @param androidTvEnabled: Whether to allow Didomi SDK to run on Android TV, default to "false".
19
21
  */
20
22
  initialize: (
21
23
  apiKey: string,
@@ -24,13 +26,15 @@ export const Didomi = {
24
26
  providerId?: string,
25
27
  disableDidomiRemoteConfig: boolean = false,
26
28
  languageCode?: string,
27
- noticeId?: string
28
- ) => {
29
+ noticeId?: string,
30
+ androidTvNoticeId?: string,
31
+ androidTvEnabled: boolean = false
32
+ ): Promise<void> => {
29
33
  // Init listener
30
34
  DidomiListener.init();
31
35
 
32
36
  // Trigger native SDK init
33
- RNDidomi.initialize(
37
+ return RNDidomi.initialize(
34
38
  DIDOMI_USER_AGENT_NAME,
35
39
  DIDOMI_VERSION,
36
40
  apiKey,
@@ -39,7 +43,9 @@ export const Didomi = {
39
43
  providerId,
40
44
  disableDidomiRemoteConfig,
41
45
  languageCode,
42
- noticeId
46
+ noticeId,
47
+ androidTvNoticeId,
48
+ androidTvEnabled
43
49
  );
44
50
  },
45
51
 
@@ -81,7 +87,7 @@ export const Didomi = {
81
87
  *
82
88
  * @param minLevel: Minimum level of messages to log
83
89
  */
84
- setLogLevel: (level: number): Promise<number> => RNDidomi.setLogLevel(level),
90
+ setLogLevel: (level: number): Promise<void> => RNDidomi.setLogLevel(level),
85
91
 
86
92
  /**
87
93
  * Add an event listener
@@ -109,48 +115,64 @@ export const Didomi = {
109
115
  /**
110
116
  * Method used to get an array of disabled purposes.
111
117
  * @returns: array of disabled purposes.
118
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
119
+ * has been replaced by getUserStatus().getPurposes().getConsent().getDisabled().
112
120
  */
113
121
  getDisabledPurposes: (): Promise<any[]> => RNDidomi.getDisabledPurposes(),
114
122
 
115
123
  /**
116
124
  * Method used to get a set of disabled purpose IDs.
117
125
  * @returns: set that contains the IDs of disabled purposes.
126
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
127
+ * has been replaced by getUserStatus().getPurposes().getConsent().getDisabled().
118
128
  */
119
129
  getDisabledPurposeIds: (): Promise<any[]> => RNDidomi.getDisabledPurposeIds(),
120
130
 
121
131
  /**
122
132
  * Method used to get an array of disabled vendors.
123
133
  * @returns: array of disabled vendors.
134
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
135
+ * has been replaced by getUserStatus().getVendors().getConsent().getDisabled().
124
136
  */
125
137
  getDisabledVendors: (): Promise<any[]> => RNDidomi.getDisabledVendors(),
126
138
 
127
139
  /**
128
140
  * Method used to get a set of disabled vendor IDs.
129
141
  * @returns: set that contains the IDs of disabled vendors.
142
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
143
+ * has been replaced by getUserStatus().getVendors().getConsent().getDisabled().
130
144
  */
131
145
  getDisabledVendorIds: (): Promise<any[]> => RNDidomi.getDisabledVendorIds(),
132
146
 
133
147
  /**
134
148
  * Method used to get an array of enabled purposes.
135
149
  * @returns: array of enabled purposes.
150
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
151
+ * has been replaced by getUserStatus().getPurposes().getConsent().getEnabled().
136
152
  */
137
153
  getEnabledPurposes: (): Promise<any[]> => RNDidomi.getEnabledPurposes(),
138
154
 
139
155
  /**
140
156
  * Method used to get a set of enabled purpose IDs.
141
157
  * @returns: set that contains the IDs of enabled purposes.
158
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
159
+ * has been replaced by getUserStatus().getPurposes().getConsent().getEnabled().
142
160
  */
143
161
  getEnabledPurposeIds: (): Promise<any[]> => RNDidomi.getEnabledPurposeIds(),
144
162
 
145
163
  /**
146
164
  * Method used to get an array of enabled vendors.
147
165
  * @returns: array of enabled vendors.
166
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
167
+ * has been replaced by getUserStatus().getVendors().getConsent().getEnabled().
148
168
  */
149
169
  getEnabledVendors: (): Promise<any[]> => RNDidomi.getEnabledVendors(),
150
170
 
151
171
  /**
152
172
  * Method used to get a set of enabled vendor IDs.
153
173
  * @returns: set that contains the IDs of enabled vendors.
174
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
175
+ * has been replaced by getUserStatus().getVendors().getConsent().getEnabled().
154
176
  */
155
177
  getEnabledVendorIds: (): Promise<any[]> => RNDidomi.getEnabledVendorIds(),
156
178
 
@@ -355,6 +377,11 @@ export const Didomi = {
355
377
  */
356
378
  isReady: (): Promise<boolean> => RNDidomi.isReady(),
357
379
 
380
+ /**
381
+ * Clear user information
382
+ */
383
+ clearUser: (): Promise<void> => RNDidomi.clearUser(),
384
+
358
385
  /**
359
386
  * Set user information without authentication
360
387
  *
@@ -365,20 +392,27 @@ export const Didomi = {
365
392
  * @param digest Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
366
393
  */
367
394
  setUser: (
368
- organizationUserId: string,
369
- organizationUserIdAuthAlgorithm?: string,
370
- organizationUserIdAuthSid?: string,
371
- organizationUserIdAuthSalt?: string,
372
- organizationUserIdAuthDigest?: string
395
+ id: string,
396
+ algorithm?: string,
397
+ secretId?: string,
398
+ salt?: string,
399
+ digest?: string
373
400
  ): Promise<void> =>
374
401
  RNDidomi.setUser(
375
- organizationUserId,
376
- organizationUserIdAuthAlgorithm,
377
- organizationUserIdAuthSid,
378
- organizationUserIdAuthSalt,
379
- organizationUserIdAuthDigest
402
+ id,
403
+ algorithm,
404
+ secretId,
405
+ salt,
406
+ digest
380
407
  ),
381
408
 
409
+ /**
410
+ * Set user information without authentication and check for missing consent
411
+ *
412
+ * @param id Organization user ID
413
+ */
414
+ setUserAndSetupUI: (id: string): Promise<void> => RNDidomi.setUserAndSetupUI(id),
415
+
382
416
  /**
383
417
  * Set user information with Hash authentication
384
418
  *
@@ -390,7 +424,7 @@ export const Didomi = {
390
424
  * @param expiration Expiration date as timestamp (to prevent replay attacks)
391
425
  */
392
426
  setUserWithHashAuth: (
393
- organizationUserId: string,
427
+ id: string,
394
428
  algorithm: string,
395
429
  secretId: string,
396
430
  digest: string,
@@ -399,7 +433,7 @@ export const Didomi = {
399
433
  ): void => {
400
434
  if (expiration === undefined) {
401
435
  RNDidomi.setUserWithHashAuth(
402
- organizationUserId,
436
+ id,
403
437
  algorithm,
404
438
  secretId,
405
439
  digest,
@@ -407,7 +441,7 @@ export const Didomi = {
407
441
  );
408
442
  } else {
409
443
  RNDidomi.setUserWithHashAuthWithExpiration(
410
- organizationUserId,
444
+ id,
411
445
  algorithm,
412
446
  secretId,
413
447
  digest,
@@ -417,39 +451,111 @@ export const Didomi = {
417
451
  }
418
452
  },
419
453
 
420
- /**
421
- * Set user information with Encryption authentication
422
- *
423
- * @param id Organization user ID
424
- * @param algorithm Algorithm used for computing the digest
425
- * @param secretId ID of the secret used for computing the digest
426
- * @param initializationVector Initialization Vector used for computing the user ID
427
- * @param expiration Expiration date as timestamp (to prevent replay attacks)
428
- */
429
- setUserWithEncryptionAuth: (
430
- organizationUserId: string,
431
- algorithm: string,
432
- secretId: string,
433
- initializationVector: string,
434
- expiration?: BigInt
435
- ): void => {
436
- if (expiration === undefined) {
437
- RNDidomi.setUserWithEncryptionAuth(
438
- organizationUserId,
439
- algorithm,
440
- secretId,
441
- initializationVector
442
- );
443
- } else {
444
- RNDidomi.setUserWithEncryptionAuthWithExpiration(
445
- organizationUserId,
446
- algorithm,
447
- secretId,
448
- initializationVector,
449
- expiration
450
- );
451
- }
452
- },
454
+ /**
455
+ * Set user information with Hash authentication and check for missing consent
456
+ *
457
+ * @param id Organization user ID
458
+ * @param algorithm Algorithm used for computing the digest
459
+ * @param secretId ID of the secret used for computing the digest
460
+ * @param digest Digest of the organization user ID and secret
461
+ * @param salt Salt used for computing the digest (optional)
462
+ * @param expiration Expiration date as timestamp (to prevent replay attacks)
463
+ */
464
+ setUserWithHashAuthAndSetupUI: (
465
+ id: string,
466
+ algorithm: string,
467
+ secretId: string,
468
+ digest: string,
469
+ salt?: string,
470
+ expiration?: BigInt
471
+ ): void => {
472
+ if (expiration === undefined) {
473
+ RNDidomi.setUserWithHashAuthAndSetupUI(
474
+ id,
475
+ algorithm,
476
+ secretId,
477
+ digest,
478
+ salt
479
+ );
480
+ } else {
481
+ RNDidomi.setUserWithHashAuthWithExpirationAndSetupUI(
482
+ id,
483
+ algorithm,
484
+ secretId,
485
+ digest,
486
+ salt,
487
+ expiration
488
+ );
489
+ }
490
+ },
491
+
492
+ /**
493
+ * Set user information with Encryption authentication
494
+ *
495
+ * @param id Organization user ID
496
+ * @param algorithm Algorithm used for computing the digest
497
+ * @param secretId ID of the secret used for computing the digest
498
+ * @param initializationVector Initialization Vector used for computing the user ID
499
+ * @param expiration Expiration date as timestamp (to prevent replay attacks)
500
+ */
501
+ setUserWithEncryptionAuth: (
502
+ id: string,
503
+ algorithm: string,
504
+ secretId: string,
505
+ initializationVector: string,
506
+ expiration?: BigInt
507
+ ): void => {
508
+ if (expiration === undefined) {
509
+ RNDidomi.setUserWithEncryptionAuth(
510
+ id,
511
+ algorithm,
512
+ secretId,
513
+ initializationVector
514
+ );
515
+ } else {
516
+ RNDidomi.setUserWithEncryptionAuthWithExpiration(
517
+ id,
518
+ algorithm,
519
+ secretId,
520
+ initializationVector,
521
+ expiration
522
+ );
523
+ }
524
+ },
525
+
526
+ /**
527
+ * Set user information with Encryption authentication and check for missing consent
528
+ *
529
+ * @param id Organization user ID
530
+ * @param algorithm Algorithm used for computing the digest
531
+ * @param secretId ID of the secret used for computing the digest
532
+ * @param initializationVector Initialization Vector used for computing the user ID
533
+ * @param expiration Expiration date as timestamp (to prevent replay attacks)
534
+ */
535
+ setUserWithEncryptionAuthAndSetupUI: (
536
+ id: string,
537
+ algorithm: string,
538
+ secretId: string,
539
+ initializationVector: string,
540
+ expiration?: BigInt
541
+ ): void => {
542
+ if (expiration === undefined) {
543
+ RNDidomi.setUserWithEncryptionAuthAndSetupUI(
544
+ id,
545
+ algorithm,
546
+ secretId,
547
+ initializationVector
548
+ );
549
+ } else {
550
+ RNDidomi.setUserWithEncryptionAuthWithExpirationAndSetupUI(
551
+ id,
552
+ algorithm,
553
+ secretId,
554
+ initializationVector,
555
+ expiration
556
+ );
557
+ }
558
+ },
453
559
 
454
560
  /**
455
561
  * Show the consent notice (if required, not disabled in the config and not already displayed)
@@ -31,6 +31,8 @@ export enum DidomiEventType {
31
31
  PREFERENCES_CLICK_RESET_ALL_PURPOSES = 'on_preferences_click_reset_all_purposes',
32
32
  SYNC_DONE = 'on_sync_done',
33
33
  SYNC_ERROR = 'on_sync_error',
34
+ LANGUAGE_UPDATED = "on_language_updated",
35
+ LANGUAGE_UPDATE_FAILED = "on_language_update_failed",
34
36
  }
35
37
 
36
38
  export interface Vendor {
@@ -86,6 +88,7 @@ export interface UserStatus {
86
88
  updated: string;
87
89
  consentString: string;
88
90
  additionalConsent: string;
91
+ regulation: string;
89
92
  }
90
93
 
91
94
  export interface UserStatusPurposes {