@redacto.io/consent-sdk-react 2.1.0 → 3.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @redacto.io/consent-sdk-react
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - purpose expiry for null validity
8
+
9
+ ## 3.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - downgrade react version in sdk
14
+
3
15
  ## 2.1.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -28,12 +28,10 @@ The SDK follows a client-server architecture pattern:
28
28
  ### How It Works
29
29
 
30
30
  1. **Your Backend Server**: Your server acts as a proxy between your React application and Redacto's API. It handles:
31
-
32
31
  - Generating access tokens
33
32
  - Token refresh operations
34
33
 
35
34
  2. **React Application**: Your React app uses the SDK components to:
36
-
37
35
  - Display consent notices
38
36
  - Collect user consent choices
39
37
  - Submit consent records to Redacto API
@@ -58,25 +56,21 @@ The SDK follows a client-server architecture pattern:
58
56
  ## Features
59
57
 
60
58
  - **Consent Notice Display**
61
-
62
59
  - Customizable consent notices
63
60
  - Multiple display formats (modal popup, inline form)
64
61
  - Responsive design
65
62
 
66
63
  - **Consent Collection**
67
-
68
64
  - User consent choices (accept, reject, manage preferences)
69
65
  - Granular consent management
70
66
  - Persistent consent storage
71
67
 
72
68
  - **API Integration**
73
-
74
69
  - Seamless communication with Redacto CMP API
75
70
  - Automatic error handling and retries
76
71
  - Token-based authentication
77
72
 
78
73
  - **Configuration**
79
-
80
74
  - Customizable UI settings
81
75
  - Language preferences
82
76
  - API endpoint configuration
@@ -194,7 +188,6 @@ app.post(
194
188
  Your backend needs to call the following Redacto API endpoints:
195
189
 
196
190
  1. **Generate Access Token**
197
-
198
191
  - **Endpoint**: `POST /public/organisations/{organisation_uuid}/workspaces/{workspace_uuid}/tokens/generate-access-token`
199
192
  - **Headers**: `X-CMS-API-Key: {your-cms-api-key}`
200
193
  - **Body**: `{ email, expires_in_days? }`
@@ -718,8 +711,8 @@ npm test --workspace=@redacto.io/consent-sdk-react
718
711
 
719
712
  ### Requirements
720
713
 
721
- - React 19.1.0 or higher
722
- - React DOM 19.1.0 or higher
714
+ - React 16.8.0 or higher (including React 17, 18, and 19)
715
+ - React DOM 16.8.0 or higher (including React DOM 17, 18, and 19)
723
716
 
724
717
  ### Additional Features
725
718
 
@@ -732,4 +725,4 @@ npm test --workspace=@redacto.io/consent-sdk-react
732
725
 
733
726
  ## License
734
727
 
735
- ISC
728
+ Apache-2.0
package/dist/index.js CHANGED
@@ -1962,12 +1962,19 @@ var RedactoNoticeConsent = ({
1962
1962
  const requiredElements = purpose.data_elements.filter(
1963
1963
  (el) => el.required
1964
1964
  );
1965
- const allRequiredElementsChecked = requiredElements.every(
1966
- (el) => newState[`${purposeUuid}-${el.uuid}`]
1967
- );
1965
+ let shouldCheckPurpose;
1966
+ if (requiredElements.length > 0) {
1967
+ shouldCheckPurpose = requiredElements.every(
1968
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
1969
+ );
1970
+ } else {
1971
+ shouldCheckPurpose = purpose.data_elements.some(
1972
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
1973
+ );
1974
+ }
1968
1975
  setSelectedPurposes((prevPurposes) => ({
1969
1976
  ...prevPurposes,
1970
- [purposeUuid]: allRequiredElementsChecked
1977
+ [purposeUuid]: shouldCheckPurpose
1971
1978
  }));
1972
1979
  }
1973
1980
  return newState;
@@ -3836,10 +3843,19 @@ var RedactoConsentInlineComponent = ({
3836
3843
  const requiredElements = purpose.data_elements.filter(
3837
3844
  (el) => el.required
3838
3845
  );
3839
- const allRequiredElementsChecked = requiredElements.length === 0 || requiredElements.every((el) => newState[`${purposeUuid}-${el.uuid}`]);
3846
+ let shouldCheckPurpose;
3847
+ if (requiredElements.length > 0) {
3848
+ shouldCheckPurpose = requiredElements.every(
3849
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
3850
+ );
3851
+ } else {
3852
+ shouldCheckPurpose = purpose.data_elements.some(
3853
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
3854
+ );
3855
+ }
3840
3856
  setSelectedPurposes((prevPurposes) => ({
3841
3857
  ...prevPurposes,
3842
- [purposeUuid]: allRequiredElementsChecked
3858
+ [purposeUuid]: shouldCheckPurpose
3843
3859
  }));
3844
3860
  return newState;
3845
3861
  });
package/dist/index.mjs CHANGED
@@ -1935,12 +1935,19 @@ var RedactoNoticeConsent = ({
1935
1935
  const requiredElements = purpose.data_elements.filter(
1936
1936
  (el) => el.required
1937
1937
  );
1938
- const allRequiredElementsChecked = requiredElements.every(
1939
- (el) => newState[`${purposeUuid}-${el.uuid}`]
1940
- );
1938
+ let shouldCheckPurpose;
1939
+ if (requiredElements.length > 0) {
1940
+ shouldCheckPurpose = requiredElements.every(
1941
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
1942
+ );
1943
+ } else {
1944
+ shouldCheckPurpose = purpose.data_elements.some(
1945
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
1946
+ );
1947
+ }
1941
1948
  setSelectedPurposes((prevPurposes) => ({
1942
1949
  ...prevPurposes,
1943
- [purposeUuid]: allRequiredElementsChecked
1950
+ [purposeUuid]: shouldCheckPurpose
1944
1951
  }));
1945
1952
  }
1946
1953
  return newState;
@@ -3809,10 +3816,19 @@ var RedactoConsentInlineComponent = ({
3809
3816
  const requiredElements = purpose.data_elements.filter(
3810
3817
  (el) => el.required
3811
3818
  );
3812
- const allRequiredElementsChecked = requiredElements.length === 0 || requiredElements.every((el) => newState[`${purposeUuid}-${el.uuid}`]);
3819
+ let shouldCheckPurpose;
3820
+ if (requiredElements.length > 0) {
3821
+ shouldCheckPurpose = requiredElements.every(
3822
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
3823
+ );
3824
+ } else {
3825
+ shouldCheckPurpose = purpose.data_elements.some(
3826
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
3827
+ );
3828
+ }
3813
3829
  setSelectedPurposes((prevPurposes) => ({
3814
3830
  ...prevPurposes,
3815
- [purposeUuid]: allRequiredElementsChecked
3831
+ [purposeUuid]: shouldCheckPurpose
3816
3832
  }));
3817
3833
  return newState;
3818
3834
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redacto.io/consent-sdk-react",
3
- "version": "2.1.0",
3
+ "version": "3.1.0",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -19,9 +19,7 @@
19
19
  "access": "public"
20
20
  },
21
21
  "dependencies": {
22
- "jwt-decode": "^4.0.0",
23
- "react": "^19.1.0",
24
- "react-dom": "^19.1.0"
22
+ "jwt-decode": "^4.0.0"
25
23
  },
26
24
  "devDependencies": {
27
25
  "@testing-library/jest-dom": "^6.6.3",
@@ -34,6 +32,10 @@
34
32
  "typescript": "5.8.2",
35
33
  "vitest": "^3.1.3"
36
34
  },
35
+ "peerDependencies": {
36
+ "react": "^16.8.0 || ^17 || ^18 || ^19",
37
+ "react-dom": "^16.8.0 || ^17 || ^18 || ^19"
38
+ },
37
39
  "scripts": {
38
40
  "build": "tsup",
39
41
  "dev": "tsup --watch",
@@ -1320,13 +1320,24 @@ export const RedactoNoticeConsent = ({
1320
1320
  const requiredElements = purpose.data_elements.filter(
1321
1321
  (el) => el.required
1322
1322
  );
1323
- const allRequiredElementsChecked = requiredElements.every(
1324
- (el) => newState[`${purposeUuid}-${el.uuid}`]
1325
- );
1323
+
1324
+ let shouldCheckPurpose: boolean;
1325
+
1326
+ if (requiredElements.length > 0) {
1327
+ // Has required elements: check purpose when all required are selected
1328
+ shouldCheckPurpose = requiredElements.every(
1329
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
1330
+ );
1331
+ } else {
1332
+ // No required elements: check purpose when ANY element is selected
1333
+ shouldCheckPurpose = purpose.data_elements.some(
1334
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
1335
+ );
1336
+ }
1326
1337
 
1327
1338
  setSelectedPurposes((prevPurposes) => ({
1328
1339
  ...prevPurposes,
1329
- [purposeUuid]: allRequiredElementsChecked,
1340
+ [purposeUuid]: shouldCheckPurpose,
1330
1341
  }));
1331
1342
  }
1332
1343
 
@@ -274,17 +274,27 @@ const RedactoConsentInlineComponent = ({
274
274
  };
275
275
 
276
276
  // Check if all required elements are checked
277
- // Purpose checkbox should only be checked when ALL required data elements are checked
278
277
  const requiredElements = purpose.data_elements.filter(
279
278
  (el) => el.required
280
279
  );
281
- const allRequiredElementsChecked =
282
- requiredElements.length === 0 ||
283
- requiredElements.every((el) => newState[`${purposeUuid}-${el.uuid}`]);
280
+
281
+ let shouldCheckPurpose: boolean;
282
+
283
+ if (requiredElements.length > 0) {
284
+ // Has required elements: check purpose when all required are selected
285
+ shouldCheckPurpose = requiredElements.every(
286
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
287
+ );
288
+ } else {
289
+ // No required elements: check purpose when ANY element is selected
290
+ shouldCheckPurpose = purpose.data_elements.some(
291
+ (el) => newState[`${purposeUuid}-${el.uuid}`]
292
+ );
293
+ }
284
294
 
285
295
  setSelectedPurposes((prevPurposes) => ({
286
296
  ...prevPurposes,
287
- [purposeUuid]: allRequiredElementsChecked,
297
+ [purposeUuid]: shouldCheckPurpose,
288
298
  }));
289
299
 
290
300
  return newState;
@@ -1,21 +0,0 @@
1
-
2
- 
3
- > @redacto.io/consent-sdk-react@1.4.0 build /Users/sadanmianredacto/Developer/consent-sdk/packages/consent-sdk-react
4
- > tsup
5
-
6
- CLI Building entry: {"index":"src/index.ts"}
7
- CLI Using tsconfig: tsconfig.json
8
- CLI tsup v8.5.1
9
- CLI Using tsup config: /Users/sadanmianredacto/Developer/consent-sdk/packages/consent-sdk-react/tsup.config.ts
10
- CLI Target: es2019
11
- CLI Cleaning output folder
12
- ESM Build start
13
- CJS Build start
14
- ESM dist/index.mjs 151.62 KB
15
- ESM ⚡️ Build success in 11ms
16
- CJS dist/index.js 157.42 KB
17
- CJS ⚡️ Build success in 11ms
18
- DTS Build start
19
- DTS ⚡️ Build success in 557ms
20
- DTS dist/index.d.mts 2.79 KB
21
- DTS dist/index.d.ts 2.79 KB