@didomi/react-native 1.7.0 → 1.8.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
@@ -25,12 +25,12 @@ export const Didomi = {
25
25
  disableDidomiRemoteConfig: boolean = false,
26
26
  languageCode?: string,
27
27
  noticeId?: string
28
- ) => {
28
+ ): Promise<void> => {
29
29
  // Init listener
30
30
  DidomiListener.init();
31
31
 
32
32
  // Trigger native SDK init
33
- RNDidomi.initialize(
33
+ return RNDidomi.initialize(
34
34
  DIDOMI_USER_AGENT_NAME,
35
35
  DIDOMI_VERSION,
36
36
  apiKey,
@@ -81,7 +81,7 @@ export const Didomi = {
81
81
  *
82
82
  * @param minLevel: Minimum level of messages to log
83
83
  */
84
- setLogLevel: (level: number): Promise<number> => RNDidomi.setLogLevel(level),
84
+ setLogLevel: (level: number): Promise<void> => RNDidomi.setLogLevel(level),
85
85
 
86
86
  /**
87
87
  * Add an event listener
@@ -109,48 +109,64 @@ export const Didomi = {
109
109
  /**
110
110
  * Method used to get an array of disabled purposes.
111
111
  * @returns: array of disabled purposes.
112
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
113
+ * has been replaced by getUserStatus().getPurposes().getConsent().getDisabled().
112
114
  */
113
115
  getDisabledPurposes: (): Promise<any[]> => RNDidomi.getDisabledPurposes(),
114
116
 
115
117
  /**
116
118
  * Method used to get a set of disabled purpose IDs.
117
119
  * @returns: set that contains the IDs of disabled purposes.
120
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
121
+ * has been replaced by getUserStatus().getPurposes().getConsent().getDisabled().
118
122
  */
119
123
  getDisabledPurposeIds: (): Promise<any[]> => RNDidomi.getDisabledPurposeIds(),
120
124
 
121
125
  /**
122
126
  * Method used to get an array of disabled vendors.
123
127
  * @returns: array of disabled vendors.
128
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
129
+ * has been replaced by getUserStatus().getVendors().getConsent().getDisabled().
124
130
  */
125
131
  getDisabledVendors: (): Promise<any[]> => RNDidomi.getDisabledVendors(),
126
132
 
127
133
  /**
128
134
  * Method used to get a set of disabled vendor IDs.
129
135
  * @returns: set that contains the IDs of disabled vendors.
136
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
137
+ * has been replaced by getUserStatus().getVendors().getConsent().getDisabled().
130
138
  */
131
139
  getDisabledVendorIds: (): Promise<any[]> => RNDidomi.getDisabledVendorIds(),
132
140
 
133
141
  /**
134
142
  * Method used to get an array of enabled purposes.
135
143
  * @returns: array of enabled purposes.
144
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
145
+ * has been replaced by getUserStatus().getPurposes().getConsent().getEnabled().
136
146
  */
137
147
  getEnabledPurposes: (): Promise<any[]> => RNDidomi.getEnabledPurposes(),
138
148
 
139
149
  /**
140
150
  * Method used to get a set of enabled purpose IDs.
141
151
  * @returns: set that contains the IDs of enabled purposes.
152
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
153
+ * has been replaced by getUserStatus().getPurposes().getConsent().getEnabled().
142
154
  */
143
155
  getEnabledPurposeIds: (): Promise<any[]> => RNDidomi.getEnabledPurposeIds(),
144
156
 
145
157
  /**
146
158
  * Method used to get an array of enabled vendors.
147
159
  * @returns: array of enabled vendors.
160
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
161
+ * has been replaced by getUserStatus().getVendors().getConsent().getEnabled().
148
162
  */
149
163
  getEnabledVendors: (): Promise<any[]> => RNDidomi.getEnabledVendors(),
150
164
 
151
165
  /**
152
166
  * Method used to get a set of enabled vendor IDs.
153
167
  * @returns: set that contains the IDs of enabled vendors.
168
+ * @deprecated use {@link #getUserStatus()} instead. The result of this method
169
+ * has been replaced by getUserStatus().getVendors().getConsent().getEnabled().
154
170
  */
155
171
  getEnabledVendorIds: (): Promise<any[]> => RNDidomi.getEnabledVendorIds(),
156
172
 
@@ -355,6 +371,11 @@ export const Didomi = {
355
371
  */
356
372
  isReady: (): Promise<boolean> => RNDidomi.isReady(),
357
373
 
374
+ /**
375
+ * Clear user information
376
+ */
377
+ clearUser: (): Promise<void> => RNDidomi.clearUser(),
378
+
358
379
  /**
359
380
  * Set user information without authentication
360
381
  *
@@ -365,20 +386,27 @@ export const Didomi = {
365
386
  * @param digest Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
366
387
  */
367
388
  setUser: (
368
- organizationUserId: string,
369
- organizationUserIdAuthAlgorithm?: string,
370
- organizationUserIdAuthSid?: string,
371
- organizationUserIdAuthSalt?: string,
372
- organizationUserIdAuthDigest?: string
389
+ id: string,
390
+ algorithm?: string,
391
+ secretId?: string,
392
+ salt?: string,
393
+ digest?: string
373
394
  ): Promise<void> =>
374
395
  RNDidomi.setUser(
375
- organizationUserId,
376
- organizationUserIdAuthAlgorithm,
377
- organizationUserIdAuthSid,
378
- organizationUserIdAuthSalt,
379
- organizationUserIdAuthDigest
396
+ id,
397
+ algorithm,
398
+ secretId,
399
+ salt,
400
+ digest
380
401
  ),
381
402
 
403
+ /**
404
+ * Set user information without authentication and check for missing consent
405
+ *
406
+ * @param id Organization user ID
407
+ */
408
+ setUserAndSetupUI: (id: string): Promise<void> => RNDidomi.setUserAndSetupUI(id),
409
+
382
410
  /**
383
411
  * Set user information with Hash authentication
384
412
  *
@@ -390,7 +418,7 @@ export const Didomi = {
390
418
  * @param expiration Expiration date as timestamp (to prevent replay attacks)
391
419
  */
392
420
  setUserWithHashAuth: (
393
- organizationUserId: string,
421
+ id: string,
394
422
  algorithm: string,
395
423
  secretId: string,
396
424
  digest: string,
@@ -399,7 +427,7 @@ export const Didomi = {
399
427
  ): void => {
400
428
  if (expiration === undefined) {
401
429
  RNDidomi.setUserWithHashAuth(
402
- organizationUserId,
430
+ id,
403
431
  algorithm,
404
432
  secretId,
405
433
  digest,
@@ -407,7 +435,7 @@ export const Didomi = {
407
435
  );
408
436
  } else {
409
437
  RNDidomi.setUserWithHashAuthWithExpiration(
410
- organizationUserId,
438
+ id,
411
439
  algorithm,
412
440
  secretId,
413
441
  digest,
@@ -417,39 +445,111 @@ export const Didomi = {
417
445
  }
418
446
  },
419
447
 
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
- },
448
+ /**
449
+ * Set user information with Hash authentication and check for missing consent
450
+ *
451
+ * @param id Organization user ID
452
+ * @param algorithm Algorithm used for computing the digest
453
+ * @param secretId ID of the secret used for computing the digest
454
+ * @param digest Digest of the organization user ID and secret
455
+ * @param salt Salt used for computing the digest (optional)
456
+ * @param expiration Expiration date as timestamp (to prevent replay attacks)
457
+ */
458
+ setUserWithHashAuthAndSetupUI: (
459
+ id: string,
460
+ algorithm: string,
461
+ secretId: string,
462
+ digest: string,
463
+ salt?: string,
464
+ expiration?: BigInt
465
+ ): void => {
466
+ if (expiration === undefined) {
467
+ RNDidomi.setUserWithHashAuthAndSetupUI(
468
+ id,
469
+ algorithm,
470
+ secretId,
471
+ digest,
472
+ salt
473
+ );
474
+ } else {
475
+ RNDidomi.setUserWithHashAuthWithExpirationAndSetupUI(
476
+ id,
477
+ algorithm,
478
+ secretId,
479
+ digest,
480
+ salt,
481
+ expiration
482
+ );
483
+ }
484
+ },
485
+
486
+ /**
487
+ * Set user information with Encryption authentication
488
+ *
489
+ * @param id Organization user ID
490
+ * @param algorithm Algorithm used for computing the digest
491
+ * @param secretId ID of the secret used for computing the digest
492
+ * @param initializationVector Initialization Vector used for computing the user ID
493
+ * @param expiration Expiration date as timestamp (to prevent replay attacks)
494
+ */
495
+ setUserWithEncryptionAuth: (
496
+ id: string,
497
+ algorithm: string,
498
+ secretId: string,
499
+ initializationVector: string,
500
+ expiration?: BigInt
501
+ ): void => {
502
+ if (expiration === undefined) {
503
+ RNDidomi.setUserWithEncryptionAuth(
504
+ id,
505
+ algorithm,
506
+ secretId,
507
+ initializationVector
508
+ );
509
+ } else {
510
+ RNDidomi.setUserWithEncryptionAuthWithExpiration(
511
+ id,
512
+ algorithm,
513
+ secretId,
514
+ initializationVector,
515
+ expiration
516
+ );
517
+ }
518
+ },
519
+
520
+ /**
521
+ * Set user information with Encryption authentication and check for missing consent
522
+ *
523
+ * @param id Organization user ID
524
+ * @param algorithm Algorithm used for computing the digest
525
+ * @param secretId ID of the secret used for computing the digest
526
+ * @param initializationVector Initialization Vector used for computing the user ID
527
+ * @param expiration Expiration date as timestamp (to prevent replay attacks)
528
+ */
529
+ setUserWithEncryptionAuthAndSetupUI: (
530
+ id: string,
531
+ algorithm: string,
532
+ secretId: string,
533
+ initializationVector: string,
534
+ expiration?: BigInt
535
+ ): void => {
536
+ if (expiration === undefined) {
537
+ RNDidomi.setUserWithEncryptionAuthAndSetupUI(
538
+ id,
539
+ algorithm,
540
+ secretId,
541
+ initializationVector
542
+ );
543
+ } else {
544
+ RNDidomi.setUserWithEncryptionAuthWithExpirationAndSetupUI(
545
+ id,
546
+ algorithm,
547
+ secretId,
548
+ initializationVector,
549
+ expiration
550
+ );
551
+ }
552
+ },
453
553
 
454
554
  /**
455
555
  * 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 {