@didomi/react-native 1.3.0 → 1.6.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.
@@ -14,15 +14,15 @@ export declare const Didomi: {
14
14
  initialize: (apiKey: string, localConfigurationPath?: string | undefined, remoteConfigurationUrl?: string | undefined, providerId?: string | undefined, disableDidomiRemoteConfig?: boolean, languageCode?: string | undefined, noticeId?: string | undefined) => void;
15
15
  /**
16
16
  * Listen to SDK ready state
17
- * */
17
+ */
18
18
  onReady: () => Promise<void>;
19
19
  /**
20
20
  * Listen to SDK errors
21
- * */
21
+ */
22
22
  onError: () => Promise<any>;
23
23
  /**
24
- Provide the objects required to display UI elements
25
- */
24
+ * Provide the objects required to display UI elements
25
+ */
26
26
  setupUI: () => Promise<void>;
27
27
  /**
28
28
  * Set the minimum level of messages to log
@@ -278,15 +278,36 @@ export declare const Didomi: {
278
278
  */
279
279
  isReady: () => Promise<boolean>;
280
280
  /**
281
- * Set user information with authentication
281
+ * Set user information without authentication
282
+ *
283
+ * @param id Organization user ID
284
+ * @param algorithm Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
285
+ * @param secretId Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
286
+ * @param salt Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
287
+ * @param digest Deprecated. To set user with authentication, use setUserWithHashAuth or setUserWithEncryptionAuth.
288
+ */
289
+ setUser: (organizationUserId: string, organizationUserIdAuthAlgorithm?: string | undefined, organizationUserIdAuthSid?: string | undefined, organizationUserIdAuthSalt?: string | undefined, organizationUserIdAuthDigest?: string | undefined) => Promise<void>;
290
+ /**
291
+ * Set user information with Hash authentication
282
292
  *
283
293
  * @param id Organization user ID
284
294
  * @param algorithm Algorithm used for computing the digest
285
295
  * @param secretId ID of the secret used for computing the digest
286
- * @param salt Salt used for computing the digest (optional)
287
296
  * @param digest Digest of the organization user ID and secret
297
+ * @param salt Salt used for computing the digest (optional)
298
+ * @param expiration Expiration date as timestamp (to prevent replay attacks)
299
+ */
300
+ setUserWithHashAuth: (organizationUserId: string, algorithm: string, secretId: string, digest: string, salt?: string | undefined, expiration?: BigInt | undefined) => void;
301
+ /**
302
+ * Set user information with Encryption authentication
303
+ *
304
+ * @param id Organization user ID
305
+ * @param algorithm Algorithm used for computing the digest
306
+ * @param secretId ID of the secret used for computing the digest
307
+ * @param initializationVector Initialization Vector used for computing the user ID
308
+ * @param expiration Expiration date as timestamp (to prevent replay attacks)
288
309
  */
289
- setUser: (organizationUserId: string, organizationUserIdAuthAlgorithm: string, organizationUserIdAuthSid: string, organizationUserIdAuthSalt: string, organizationUserIdAuthDigest: string) => Promise<void>;
310
+ setUserWithEncryptionAuth: (organizationUserId: string, algorithm: string, secretId: string, initializationVector: string, expiration?: BigInt | undefined) => void;
290
311
  /**
291
312
  * Show the consent notice (if required, not disabled in the config and not already displayed)
292
313
  */
@@ -28,7 +28,8 @@ export declare enum DidomiEventType {
28
28
  PREFERENCES_CLICK_AGREE_TO_ALL_PURPOSES = "on_preferences_click_agree_to_all_purposes",
29
29
  PREFERENCES_CLICK_DISAGREE_TO_ALL_PURPOSES = "on_preferences_click_disagree_to_all_purposes",
30
30
  PREFERENCES_CLICK_RESET_ALL_PURPOSES = "on_preferences_click_reset_all_purposes",
31
- SYNC_DONE = "on_sync_done"
31
+ SYNC_DONE = "on_sync_done",
32
+ SYNC_ERROR = "on_sync_error"
32
33
  }
33
34
  export interface Vendor {
34
35
  id: string;
@@ -46,7 +47,7 @@ export interface VendorNamespaces {
46
47
  }
47
48
  export interface Purpose {
48
49
  id: string;
49
- iAbId: string;
50
+ iabId: string;
50
51
  name: string;
51
52
  description: string;
52
53
  descriptionLegal: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@didomi/react-native",
3
- "version": "1.3.0",
4
- "description": "React Native Didomi SDK",
3
+ "version": "1.6.0",
4
+ "description": "Didomi React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
7
  "types": "lib/typescript/index.d.ts",
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
16
16
  s.source_files = "ios/**/*.{h,m,mm,swift}"
17
17
 
18
18
  s.dependency "React-Core"
19
- s.dependency "Didomi-XCFramework", "1.62.0"
19
+ s.dependency "Didomi-XCFramework", "1.67.1"
20
20
  end
@@ -0,0 +1,4 @@
1
+ // User agent name
2
+ export const DIDOMI_USER_AGENT_NAME = "Didomi React-Native SDK"
3
+ // User agent version
4
+ export const DIDOMI_VERSION = "1.6.0"
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
  /**
@@ -158,19 +161,16 @@ export const Didomi = {
158
161
  * @param extra: Extra JavaScript to inject in the returned code
159
162
  * @returns: JavaScript code to inject in a WebView
160
163
  */
161
- getJavaScriptForWebView: (extra?: string | null): Promise<string> =>
162
- RNDidomi.getJavaScriptForWebView(extra),
164
+ getJavaScriptForWebView: (extra?: string | null): Promise<string> => RNDidomi.getJavaScriptForWebView(extra),
163
165
 
164
- getQueryStringForWebView: (): Promise<string> =>
165
- RNDidomi.getQueryStringForWebView(),
166
+ getQueryStringForWebView: (): Promise<string> => RNDidomi.getQueryStringForWebView(),
166
167
 
167
168
  /**
168
169
  * Method used to get a Purpose based on its ID.
169
170
  * @param purposeId: purpose ID used in the search.
170
171
  * @returns: purpose found in the array.
171
172
  */
172
- getPurpose: (purposeId: string): Promise<any> =>
173
- RNDidomi.getPurpose(purposeId),
173
+ getPurpose: (purposeId: string): Promise<any> => RNDidomi.getPurpose(purposeId),
174
174
 
175
175
  /**
176
176
  * Method used to get an array of required purposes.
@@ -226,8 +226,7 @@ export const Didomi = {
226
226
  * @param key: used to find its corresponding value in one of the different sources.
227
227
  * @returns: a translated string if a translation was found, the same key that was passed otherwise.
228
228
  */
229
- getTranslatedText: (key: string): Promise<string> =>
230
- RNDidomi.getTranslatedText(key),
229
+ getTranslatedText: (key: string): Promise<string> => RNDidomi.getTranslatedText(key),
231
230
 
232
231
  /**
233
232
  * Get the user consent status for a specific purpose
@@ -237,8 +236,7 @@ export const Didomi = {
237
236
  * getUserStatus().getPurposes().getConsent().getEnabled() or
238
237
  * getUserStatus().getPurposes().getConsent().getDisabled().
239
238
  */
240
- getUserConsentStatusForPurpose: (purposeId: string): Promise<boolean> =>
241
- RNDidomi.getUserConsentStatusForPurpose(purposeId),
239
+ getUserConsentStatusForPurpose: (purposeId: string): Promise<boolean> => RNDidomi.getUserConsentStatusForPurpose(purposeId),
242
240
 
243
241
  /**
244
242
  * Get the user consent status for a specific vendor
@@ -248,8 +246,7 @@ export const Didomi = {
248
246
  * getUserStatus().getVendors().getConsent().getEnabled() or
249
247
  * getUserStatus().getVendors().getConsent().getDisabled().
250
248
  */
251
- getUserConsentStatusForVendor: (vendorId: string): Promise<boolean> =>
252
- RNDidomi.getUserConsentStatusForVendor(vendorId),
249
+ getUserConsentStatusForVendor: (vendorId: string): Promise<boolean> => RNDidomi.getUserConsentStatusForVendor(vendorId),
253
250
 
254
251
  /**
255
252
  * Get the user consent status for a specific vendor and all its purposes
@@ -259,10 +256,7 @@ export const Didomi = {
259
256
  * by getUserStatus().getVendors().getGlobalConsent().getEnabled() or
260
257
  * getUserStatus().getVendors().getGlobalConsent().getDisabled().
261
258
  */
262
- getUserConsentStatusForVendorAndRequiredPurposes: (
263
- vendorId: string
264
- ): Promise<boolean> =>
265
- RNDidomi.getUserConsentStatusForVendorAndRequiredPurposes(vendorId),
259
+ getUserConsentStatusForVendorAndRequiredPurposes: (vendorId: string): Promise<boolean> => RNDidomi.getUserConsentStatusForVendorAndRequiredPurposes(vendorId),
266
260
 
267
261
  /**
268
262
  * Get the user legitimate interest status for a specific purpose.
@@ -272,10 +266,7 @@ export const Didomi = {
272
266
  * getUserStatus().getPurposes().getLegitimateInterest().getEnabled() or
273
267
  * getUserStatus().getPurposes().getLegitimateInterest().getDisabled().
274
268
  */
275
- getUserLegitimateInterestStatusForPurpose: (
276
- purposeId: string
277
- ): Promise<boolean> =>
278
- RNDidomi.getUserLegitimateInterestStatusForPurpose(purposeId),
269
+ getUserLegitimateInterestStatusForPurpose: (purposeId: string): Promise<boolean> => RNDidomi.getUserLegitimateInterestStatusForPurpose(purposeId),
279
270
 
280
271
  /**
281
272
  * Get the user legitimate interest status for a specific vendor.
@@ -285,8 +276,7 @@ export const Didomi = {
285
276
  * getUserStatus().getVendors().getLegitimateInterest().getEnabled() or
286
277
  * getUserStatus().getVendors().getLegitimateInterest().getDisabled().
287
278
  */
288
- getUserLegitimateInterestForVendor: (vendorId: string): Promise<boolean> =>
289
- RNDidomi.getUserLegitimateInterestStatusForVendor(vendorId),
279
+ getUserLegitimateInterestForVendor: (vendorId: string): Promise<boolean> => RNDidomi.getUserLegitimateInterestStatusForVendor(vendorId),
290
280
 
291
281
  /**
292
282
  * Get the user LI status for a specific vendor and all its purposes.
@@ -296,12 +286,7 @@ export const Didomi = {
296
286
  * getUserStatus().getVendors().getGlobalLegitimateInterest().getEnabled() or
297
287
  * getUserStatus().getVendors().getGlobalLegitimateInterest().getDisabled().
298
288
  */
299
- getUserLegitimateInterestStatusForVendorAndRequiredPurposes: (
300
- vendorId: string
301
- ): boolean =>
302
- RNDidomi.getUserLegitimateInterestStatusForVendorAndRequiredPurposes(
303
- vendorId
304
- ),
289
+ getUserLegitimateInterestStatusForVendorAndRequiredPurposes: (vendorId: string): boolean => RNDidomi.getUserLegitimateInterestStatusForVendorAndRequiredPurposes(vendorId),
305
290
 
306
291
  /**
307
292
  * Get the user consent status.
@@ -317,8 +302,7 @@ export const Didomi = {
317
302
  * getUserStatus().getVendors().getGlobal().getEnabled() or
318
303
  * getUserStatus().getVendors().getGlobal().getDisabled().
319
304
  */
320
- getUserStatusForVendor: (vendorId: string): Promise<boolean> =>
321
- RNDidomi.getUserStatusForVendor(vendorId),
305
+ getUserStatusForVendor: (vendorId: string): Promise<boolean> => RNDidomi.getUserStatusForVendor(vendorId),
322
306
 
323
307
  /**
324
308
  * Method used to get a Vendor based on its ID.
@@ -350,8 +334,7 @@ export const Didomi = {
350
334
  * Determine if consent information is available for all purposes and vendors that are required
351
335
  * @returns: **true** if consent is required and consent information is available, **false** otherwise.
352
336
  */
353
- isUserConsentStatusPartial: (): Promise<boolean> =>
354
- RNDidomi.isUserConsentStatusPartial(),
337
+ isUserConsentStatusPartial: (): Promise<boolean> => RNDidomi.isUserConsentStatusPartial(),
355
338
 
356
339
  /**
357
340
  * Check if the consent notice is currently displayed
@@ -373,20 +356,20 @@ export const Didomi = {
373
356
  isReady: (): Promise<boolean> => RNDidomi.isReady(),
374
357
 
375
358
  /**
376
- * Set user information with authentication
359
+ * Set user information without authentication
377
360
  *
378
361
  * @param id Organization user ID
379
- * @param algorithm Algorithm used for computing the digest
380
- * @param secretId ID of the secret used for computing the digest
381
- * @param salt Salt used for computing the digest (optional)
382
- * @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.
383
366
  */
384
367
  setUser: (
385
368
  organizationUserId: string,
386
- organizationUserIdAuthAlgorithm: string,
387
- organizationUserIdAuthSid: string,
388
- organizationUserIdAuthSalt: string,
389
- organizationUserIdAuthDigest: string
369
+ organizationUserIdAuthAlgorithm?: string,
370
+ organizationUserIdAuthSid?: string,
371
+ organizationUserIdAuthSalt?: string,
372
+ organizationUserIdAuthDigest?: string
390
373
  ): Promise<void> =>
391
374
  RNDidomi.setUser(
392
375
  organizationUserId,
@@ -396,6 +379,78 @@ export const Didomi = {
396
379
  organizationUserIdAuthDigest
397
380
  ),
398
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
+
399
454
  /**
400
455
  * Show the consent notice (if required, not disabled in the config and not already displayed)
401
456
  */
@@ -405,8 +460,7 @@ export const Didomi = {
405
460
  * Show the preferences screen when/if the SDK is ready. By default the purposes list will be displayed.
406
461
  * @param view: It can be `purposes` or `vendors`
407
462
  */
408
- showPreferences: (view?: string): Promise<void> =>
409
- RNDidomi.showPreferences(view),
463
+ showPreferences: (view?: string): Promise<void> => RNDidomi.showPreferences(view),
410
464
 
411
465
  /**
412
466
  * Remove all consents for the user
@@ -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;