@redacto.io/consent-sdk-react-native 1.0.0 → 2.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/LICENSE +176 -0
- package/README.md +187 -44
- package/dist/chunk-Y6FXYEAI.mjs +10 -0
- package/dist/index.js +1601 -466
- package/dist/index.mjs +1556 -418
- package/dist/privacy-center.d.mts +652 -0
- package/dist/privacy-center.d.ts +652 -0
- package/dist/privacy-center.js +14592 -0
- package/dist/privacy-center.mjs +14593 -0
- package/package.json +33 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
CHANGED
|
@@ -1,18 +1,95 @@
|
|
|
1
1
|
# @redacto.io/consent-sdk-react-native
|
|
2
2
|
|
|
3
|
-
React Native SDK for Redacto
|
|
3
|
+
React Native SDK for Redacto's Consent Management Platform. Provides consent notice components and a full Privacy Center for end-user consent / DSR management on iOS and Android.
|
|
4
|
+
|
|
5
|
+
## Entry Points
|
|
6
|
+
|
|
7
|
+
| Import path | What you get |
|
|
8
|
+
| -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| `@redacto.io/consent-sdk-react-native` | Consent notice components: `RedactoNoticeConsent`, `RedactoNoticeConsentInline` |
|
|
10
|
+
| `@redacto.io/consent-sdk-react-native/privacy-center` | Privacy Center: certified `RedactoPrivacyCenter`, composable components, UI primitives, headless API client and hooks |
|
|
11
|
+
|
|
12
|
+
The notice entry point depends only on `react-native-svg`. The Privacy Center entry point depends on the optional peers listed below.
|
|
4
13
|
|
|
5
14
|
## Installation
|
|
6
15
|
|
|
7
16
|
```sh
|
|
8
17
|
pnpm add @redacto.io/consent-sdk-react-native react-native-svg
|
|
9
|
-
# Optional – required for TTS audio playback
|
|
10
|
-
pnpm add expo-av
|
|
11
18
|
```
|
|
12
19
|
|
|
13
20
|
> **Note:** `react-native-svg` must be linked for native builds. Follow the [react-native-svg setup guide](https://github.com/software-mansion/react-native-svg#installation).
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
### Peer Dependencies
|
|
23
|
+
|
|
24
|
+
| Peer | Required for | Notes |
|
|
25
|
+
| -------------------------- | --------------------------- | ------------------------------------------------------ |
|
|
26
|
+
| `react` | All | `^18 \|\| ^19` |
|
|
27
|
+
| `react-native` | All | `>=0.72` |
|
|
28
|
+
| `react-native-svg` | All | `>=13` |
|
|
29
|
+
| `expo-audio` | Notice TTS playback | Optional. Required to enable text-to-speech audio |
|
|
30
|
+
| `@tanstack/react-query` | Privacy Center | Optional. Required for `/privacy-center` imports |
|
|
31
|
+
| `i18next`, `react-i18next` | Privacy Center | Optional. Required for `/privacy-center` imports |
|
|
32
|
+
| `dayjs` | Privacy Center | Optional. Required for `/privacy-center` imports |
|
|
33
|
+
|
|
34
|
+
If you only use the consent notice components, install just the SDK + `react-native-svg`. If you use the Privacy Center, install the optional peers as well:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
pnpm add @tanstack/react-query i18next react-i18next dayjs
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
To enable TTS audio in the consent notice, install `expo-audio`:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
pnpm add expo-audio
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Backend Server Setup
|
|
47
|
+
|
|
48
|
+
The SDK never talks to Redacto with your CMS API key directly — your backend acts as a token broker. Obtain your **CMS-API-Key** from the Redacto Dashboard, store it in your backend's environment, and expose two endpoints to your mobile app:
|
|
49
|
+
|
|
50
|
+
1. **Generate access token** — `POST /public/organisations/{org_uuid}/workspaces/{workspace_uuid}/tokens/generate-access-token`
|
|
51
|
+
2. **Refresh access token** — `POST /consent/public/organisations/{org_uuid}/workspaces/{workspace_uuid}/tokens/refresh-token`
|
|
52
|
+
|
|
53
|
+
Both endpoints expect the `X-CMS-API-Key` header. Example (Express):
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import express from "express";
|
|
57
|
+
import axios from "axios";
|
|
58
|
+
|
|
59
|
+
const app = express();
|
|
60
|
+
app.use(express.json());
|
|
61
|
+
|
|
62
|
+
const CMS_API_KEY = process.env.CMS_API_KEY;
|
|
63
|
+
|
|
64
|
+
app.post("/api/consent/token", async (req, res) => {
|
|
65
|
+
const { email } = req.body;
|
|
66
|
+
const { organisation_uuid, workspace_uuid, base_url } = req.query;
|
|
67
|
+
|
|
68
|
+
const response = await axios.post(
|
|
69
|
+
`${base_url}/public/organisations/${organisation_uuid}/workspaces/${workspace_uuid}/tokens/generate-access-token`,
|
|
70
|
+
{ email },
|
|
71
|
+
{ headers: { "X-CMS-API-Key": CMS_API_KEY } }
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
res.json(response.data.detail); // { token, refresh_token, expires_at }
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
app.post("/api/consent/refresh-token", async (req, res) => {
|
|
78
|
+
const { refresh_token, organisation_uuid, workspace_uuid, base_url } = req.body;
|
|
79
|
+
|
|
80
|
+
const response = await axios.post(
|
|
81
|
+
`${base_url}/consent/public/organisations/${organisation_uuid}/workspaces/${workspace_uuid}/tokens/refresh-token`,
|
|
82
|
+
{ refresh_token },
|
|
83
|
+
{ headers: { "X-CMS-API-Key": CMS_API_KEY } }
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
res.json(response.data.detail);
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Never bundle `CMS_API_KEY` into the mobile app. In Expo apps, only non-sensitive values (UUIDs, URLs) belong in `EXPO_PUBLIC_*`.
|
|
91
|
+
|
|
92
|
+
## Consent Notice Components
|
|
16
93
|
|
|
17
94
|
### `RedactoNoticeConsent`
|
|
18
95
|
|
|
@@ -27,29 +104,27 @@ import { RedactoNoticeConsent } from "@redacto.io/consent-sdk-react-native";
|
|
|
27
104
|
refreshToken={refreshToken}
|
|
28
105
|
onAccept={() => navigation.navigate("Dashboard")}
|
|
29
106
|
onDecline={() => console.log("declined")}
|
|
30
|
-
|
|
107
|
+
/>;
|
|
31
108
|
```
|
|
32
109
|
|
|
33
110
|
#### Props
|
|
34
111
|
|
|
35
|
-
| Prop
|
|
36
|
-
|
|
37
|
-
| `noticeId`
|
|
38
|
-
| `accessToken`
|
|
39
|
-
| `refreshToken`
|
|
40
|
-
| `baseUrl`
|
|
41
|
-
| `settings`
|
|
42
|
-
| `language`
|
|
43
|
-
| `blockUI`
|
|
44
|
-
| `applicationId`
|
|
45
|
-
| `validateAgainst`
|
|
46
|
-
| `includeFullyConsentedData` | `boolean`
|
|
47
|
-
| `reviewModeButtonText`
|
|
48
|
-
| `onAccept`
|
|
49
|
-
| `onDecline`
|
|
50
|
-
| `onError`
|
|
51
|
-
|
|
52
|
-
---
|
|
112
|
+
| Prop | Type | Required | Description |
|
|
113
|
+
| --------------------------- | ----------------------------- | -------- | -------------------------------------------------------- |
|
|
114
|
+
| `noticeId` | `string` | ✓ | UUID of the consent notice |
|
|
115
|
+
| `accessToken` | `string` | ✓ | JWT access token |
|
|
116
|
+
| `refreshToken` | `string` | ✓ | JWT refresh token |
|
|
117
|
+
| `baseUrl` | `string` | | Override API base URL |
|
|
118
|
+
| `settings` | `Partial<Settings>` | | UI customisation (colours, border radius, fonts) |
|
|
119
|
+
| `language` | `string` | | Initial language code (e.g. `"en"`) |
|
|
120
|
+
| `blockUI` | `boolean` | | Block the modal from being dismissed |
|
|
121
|
+
| `applicationId` | `string` | | Application-specific UUID |
|
|
122
|
+
| `validateAgainst` | `"all" \| "required"` | | Validation mode |
|
|
123
|
+
| `includeFullyConsentedData` | `boolean` | | Include already-consented items (review mode) |
|
|
124
|
+
| `reviewModeButtonText` | `string` | | CTA text in review mode |
|
|
125
|
+
| `onAccept` | `() => void` | ✓ | Called on successful consent |
|
|
126
|
+
| `onDecline` | `() => void` | ✓ | Called when user declines |
|
|
127
|
+
| `onError` | `(error: Error) => void` | | Called on API errors |
|
|
53
128
|
|
|
54
129
|
### `RedactoNoticeConsentInline`
|
|
55
130
|
|
|
@@ -65,41 +140,109 @@ import { RedactoNoticeConsentInline } from "@redacto.io/consent-sdk-react-native
|
|
|
65
140
|
accessToken={accessToken}
|
|
66
141
|
onAccept={() => console.log("accepted")}
|
|
67
142
|
onValidationChange={(isValid) => setCanProceed(isValid)}
|
|
68
|
-
|
|
143
|
+
/>;
|
|
69
144
|
```
|
|
70
145
|
|
|
71
146
|
#### Props
|
|
72
147
|
|
|
73
|
-
| Prop
|
|
74
|
-
|
|
75
|
-
| `org_uuid`
|
|
76
|
-
| `workspace_uuid`
|
|
77
|
-
| `notice_uuid`
|
|
78
|
-
| `accessToken`
|
|
79
|
-
| `baseUrl`
|
|
80
|
-
| `language`
|
|
81
|
-
| `settings`
|
|
82
|
-
| `applicationId`
|
|
83
|
-
| `onAccept`
|
|
84
|
-
| `onDecline`
|
|
85
|
-
| `onError`
|
|
86
|
-
| `onValidationChange` | `(isValid: boolean) => void` |
|
|
148
|
+
| Prop | Type | Required | Description |
|
|
149
|
+
| -------------------- | ---------------------------- | -------- | ------------------------------------------------- |
|
|
150
|
+
| `org_uuid` | `string` | ✓ | Organisation UUID |
|
|
151
|
+
| `workspace_uuid` | `string` | ✓ | Workspace UUID |
|
|
152
|
+
| `notice_uuid` | `string` | ✓ | Notice UUID |
|
|
153
|
+
| `accessToken` | `string` | | JWT access token (triggers auto-submit when set) |
|
|
154
|
+
| `baseUrl` | `string` | | Override API base URL |
|
|
155
|
+
| `language` | `string` | | Language code |
|
|
156
|
+
| `settings` | `Partial<Settings>` | | UI customisation |
|
|
157
|
+
| `applicationId` | `string` | | Application-specific UUID |
|
|
158
|
+
| `onAccept` | `() => void` | | Called on successful consent |
|
|
159
|
+
| `onDecline` | `() => void` | | Called when user declines |
|
|
160
|
+
| `onError` | `(error: Error) => void` | | Called on errors |
|
|
161
|
+
| `onValidationChange` | `(isValid: boolean) => void` | | Fires when validation state changes |
|
|
87
162
|
|
|
88
163
|
## TTS Audio
|
|
89
164
|
|
|
90
|
-
If `expo-
|
|
165
|
+
If `expo-audio` is installed, the consent notice will dynamically load it and enable text-to-speech playback. The SDK calls `setAudioModeAsync` and creates an audio player internally — you don't need to set anything up beyond installing the package. See the [expo-audio docs](https://docs.expo.dev/versions/latest/sdk/audio/) if you need to customise audio session behaviour app-wide.
|
|
91
166
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
167
|
+
If `expo-audio` is not installed, the notice still renders and functions; only the TTS button is disabled.
|
|
168
|
+
|
|
169
|
+
## Privacy Center
|
|
170
|
+
|
|
171
|
+
The Privacy Center is a separate entry point (`@redacto.io/consent-sdk-react-native/privacy-center`) for letting end-users review and manage the consent they've given, see request activity, and file Data Subject Rights (DSR) cases — including in-app messaging on existing cases. It ships as a certified screen, composable components, UI primitives, and a headless core.
|
|
172
|
+
|
|
173
|
+
### Certified UI
|
|
174
|
+
|
|
175
|
+
`RedactoPrivacyCenter` renders the full Privacy Center experience with built-in navigation, auth, theming, and i18n.
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
import { RedactoPrivacyCenter } from "@redacto.io/consent-sdk-react-native/privacy-center";
|
|
179
|
+
|
|
180
|
+
<RedactoPrivacyCenter
|
|
181
|
+
baseUrl={BASE_URL}
|
|
182
|
+
slug="acme-co"
|
|
183
|
+
accessToken={accessToken}
|
|
184
|
+
refreshToken={refreshToken}
|
|
185
|
+
theme="light"
|
|
186
|
+
initialPage="consent-manager"
|
|
187
|
+
onError={(error) => {
|
|
188
|
+
console.error(error);
|
|
189
|
+
return false;
|
|
190
|
+
}}
|
|
191
|
+
/>;
|
|
95
192
|
```
|
|
96
193
|
|
|
97
|
-
|
|
194
|
+
#### Props
|
|
195
|
+
|
|
196
|
+
| Prop | Type | Required | Default | Description |
|
|
197
|
+
| -------------- | ----------------------------------------------------------------------------- | -------- | -------------------- | ---------------------------------------- |
|
|
198
|
+
| `baseUrl` | `string` | ✓ | - | Consent server base URL |
|
|
199
|
+
| `slug` | `string` | ✓ | - | Workspace slug |
|
|
200
|
+
| `accessToken` | `string` | ✓ | - | JWT access token |
|
|
201
|
+
| `refreshToken` | `string` | ✓ | - | JWT refresh token |
|
|
202
|
+
| `onError` | `(error: Error) => boolean` | ✓ | - | Error handler; return `true` if handled |
|
|
203
|
+
| `theme` | `"light" \| "dark"` | | `"light"` | Theme variant |
|
|
204
|
+
| `initialPage` | `"consent-manager" \| "form" \| "activity" \| "case-details"` | | `"consent-manager"` | Page to render first |
|
|
205
|
+
| `onBack` | `"back" \| "signout"` | | - | Navbar back / signout control behaviour |
|
|
206
|
+
|
|
207
|
+
### Composable Components
|
|
208
|
+
|
|
209
|
+
If you want to compose your own shell, import the screen-level building blocks instead of the certified component:
|
|
210
|
+
|
|
211
|
+
| Export | Purpose |
|
|
212
|
+
| ------------------ | ------------------------------------------------------ |
|
|
213
|
+
| `ConsentManager` | "Manage Consents" view |
|
|
214
|
+
| `Form`, `FormPage` | DSR / grievance form (component + full page wrapper) |
|
|
215
|
+
| `ActivitiesList` | List of past requests |
|
|
216
|
+
| `CaseHistory` | Per-product / per-purpose case history group |
|
|
217
|
+
| `CaseDetailsPage` | Case detail with messaging and document upload |
|
|
218
|
+
| `Navbar` | Top navigation bar |
|
|
219
|
+
| `SideMenu` | Drawer / side menu |
|
|
220
|
+
| `BottomTabBar` | Bottom tab navigation |
|
|
221
|
+
| `Footer` | Footer block |
|
|
222
|
+
|
|
223
|
+
These rely on the context providers (`AuthProvider`, `BaseUrlProvider`, `NavigationProvider`, `ThemeProvider`) — wrap them yourself if you compose the pages directly.
|
|
224
|
+
|
|
225
|
+
### UI Primitives
|
|
226
|
+
|
|
227
|
+
For building custom screens that match Privacy Center styling, the package exports themed primitives: `PCButton`, `PCInput`, `PCSelect`, `PCModal`, `PCCheckbox`, `PCLoader`, `PCEmpty`, `PCBadge`.
|
|
228
|
+
|
|
229
|
+
### Headless Core
|
|
230
|
+
|
|
231
|
+
For consumers who want fully custom UI, the headless core exposes the API client, orchestration helpers, hooks, and auth utilities:
|
|
232
|
+
|
|
233
|
+
- **API client**: `createConsentClient`
|
|
234
|
+
- **Orchestration helpers** (handle auth retry / token refresh internally): `getFormData`, `createCaseRequest`, `fetchProducts`, `fetchUserConsents`, `manageConsent`, `fetchActivities`, `fetchCaseHistory`, `getCaseMessages`, `sendCaseMessage`, `uploadCaseDocument`, `submitDocumentForRequest`, `createOtp`, `verifyOtp`, `exchangeToken`
|
|
235
|
+
- **Auth utilities**: `decodeJwtToken`, `isJwtExpired`, `ensureValidToken`, `signOutPrivacyCenter`, `compareEmails`, `getActivityTypeStatus`, `formatActivityType`
|
|
236
|
+
- **React Query hooks**: `useCaseHistory`, `useCaseMessages`
|
|
237
|
+
- **Context providers**: `AuthProvider` + `useAuth`, `BaseUrlProvider` + `useBaseUrl`, `NavigationProvider` + `useInternalNavigation`, `ThemeProvider` + `useTheme`
|
|
238
|
+
- **Types**: `Workspace`, `OrganizationDetail`, `DataElement`, `Purpose`, `UserConsent`, `Activity`, `CaseHistoryDetail`, `CaseMessage`, `MessageDocument`, `RequestTypeEnum`, `GrievanceTypeEnum`, `ConsentStatusEnum`, and more (see `privacy-center.ts` for the full export list)
|
|
239
|
+
|
|
240
|
+
## Configuration and Env Best Practices
|
|
98
241
|
|
|
99
242
|
- The SDK is runtime-configured via props and does not read from `.env` directly.
|
|
100
243
|
- Keep API keys and server secrets on your backend only.
|
|
101
244
|
- In Expo apps, values read from `EXPO_PUBLIC_*` are bundled into the app and should only contain non-sensitive config like UUIDs and URLs.
|
|
102
|
-
- If you do not pass `baseUrl`, the SDK defaults to `https://api.redacto.io/consent` for both
|
|
245
|
+
- If you do not pass `baseUrl`, the SDK defaults to `https://api.redacto.io/consent` for both notice and Privacy Center surfaces.
|
|
103
246
|
|
|
104
247
|
## License
|
|
105
248
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__require
|
|
10
|
+
};
|