@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/src/Didomi.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { NativeModules } from 'react-native';
2
2
  import { DidomiListener } from './DidomiListener';
3
3
  import { DidomiEventType } from './DidomiTypes';
4
+ import { DIDOMI_USER_AGENT_NAME, DIDOMI_VERSION } from './Constants';
4
5
 
5
6
  const { Didomi: RNDidomi } = NativeModules;
6
7
 
@@ -30,6 +31,8 @@ export const Didomi = {
30
31
 
31
32
  // Trigger native SDK init
32
33
  RNDidomi.initialize(
34
+ DIDOMI_USER_AGENT_NAME,
35
+ DIDOMI_VERSION,
33
36
  apiKey,
34
37
  localConfigurationPath,
35
38
  remoteConfigurationUrl,
@@ -42,17 +45,17 @@ export const Didomi = {
42
45
 
43
46
  /**
44
47
  * Listen to SDK ready state
45
- * */
48
+ */
46
49
  onReady: (): Promise<void> => DidomiListener.onReady(),
47
50
 
48
51
  /**
49
52
  * Listen to SDK errors
50
- * */
53
+ */
51
54
  onError: (): Promise<any> => DidomiListener.onError(),
52
55
 
53
56
  /**
54
- Provide the objects required to display UI elements
55
- */
57
+ * Provide the objects required to display UI elements
58
+ */
56
59
  setupUI: (): Promise<void> => RNDidomi.setupUI(),
57
60
 
58
61
  /**
@@ -353,20 +356,20 @@ export const Didomi = {
353
356
  isReady: (): Promise<boolean> => RNDidomi.isReady(),
354
357
 
355
358
  /**
356
- * Set user information with authentication
359
+ * Set user information without authentication
357
360
  *
358
361
  * @param id Organization user ID
359
- * @param algorithm Algorithm used for computing the digest
360
- * @param secretId ID of the secret used for computing the digest
361
- * @param salt Salt used for computing the digest (optional)
362
- * @param digest Digest of the organization user ID and secret
362
+ * @param algorithm Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
363
+ * @param secretId Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
364
+ * @param salt Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
365
+ * @param digest Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
363
366
  */
364
367
  setUser: (
365
368
  organizationUserId: string,
366
- organizationUserIdAuthAlgorithm: string,
367
- organizationUserIdAuthSid: string,
368
- organizationUserIdAuthSalt: string,
369
- organizationUserIdAuthDigest: string
369
+ organizationUserIdAuthAlgorithm?: string,
370
+ organizationUserIdAuthSid?: string,
371
+ organizationUserIdAuthSalt?: string,
372
+ organizationUserIdAuthDigest?: string
370
373
  ): Promise<void> =>
371
374
  RNDidomi.setUser(
372
375
  organizationUserId,
@@ -376,6 +379,78 @@ export const Didomi = {
376
379
  organizationUserIdAuthDigest
377
380
  ),
378
381
 
382
+ /**
383
+ * Set user information with Hash authentication
384
+ *
385
+ * @param id Organization user ID
386
+ * @param algorithm Algorithm used for computing the digest
387
+ * @param secretId ID of the secret used for computing the digest
388
+ * @param digest Digest of the organization user ID and secret
389
+ * @param salt Salt used for computing the digest (optional)
390
+ * @param expiration Expiration date as timestamp (to prevent replay attacks)
391
+ */
392
+ setUserWithHashAuth: (
393
+ organizationUserId: string,
394
+ algorithm: string,
395
+ secretId: string,
396
+ digest: string,
397
+ salt?: string,
398
+ expiration?: BigInt
399
+ ): void => {
400
+ if (expiration === undefined) {
401
+ RNDidomi.setUserWithHashAuth(
402
+ organizationUserId,
403
+ algorithm,
404
+ secretId,
405
+ digest,
406
+ salt
407
+ );
408
+ } else {
409
+ RNDidomi.setUserWithHashAuthWithExpiration(
410
+ organizationUserId,
411
+ algorithm,
412
+ secretId,
413
+ digest,
414
+ salt,
415
+ expiration
416
+ );
417
+ }
418
+ },
419
+
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
+ },
453
+
379
454
  /**
380
455
  * Show the consent notice (if required, not disabled in the config and not already displayed)
381
456
  */
@@ -15,6 +15,8 @@ export const DidomiListener = {
15
15
  init: () => {
16
16
  // Register all native event listeners
17
17
  Object.values(DidomiEventType).forEach((eventTypeValue) => {
18
+ // Remove previous listeners, as init() can be called several times in some configs
19
+ DidomiListener.eventEmitter.removeAllListeners(eventTypeValue);
18
20
  DidomiListener.eventEmitter.addListener(eventTypeValue, (_event: any) => {
19
21
  let events = DidomiListener.listeners.get(eventTypeValue);
20
22
  if (events) {
@@ -30,6 +30,7 @@ export enum DidomiEventType {
30
30
  PREFERENCES_CLICK_DISAGREE_TO_ALL_PURPOSES = 'on_preferences_click_disagree_to_all_purposes',
31
31
  PREFERENCES_CLICK_RESET_ALL_PURPOSES = 'on_preferences_click_reset_all_purposes',
32
32
  SYNC_DONE = 'on_sync_done',
33
+ SYNC_ERROR = 'on_sync_error',
33
34
  }
34
35
 
35
36
  export interface Vendor {
@@ -50,7 +51,7 @@ export interface VendorNamespaces {
50
51
 
51
52
  export interface Purpose {
52
53
  id: string;
53
- iAbId: string;
54
+ iabId: string;
54
55
  name: string;
55
56
  description: string;
56
57
  descriptionLegal: string;