@redacto.io/consent-sdk-js 1.1.0 → 2.0.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.
@@ -1,3 +1,28 @@
1
+ /** How checkbox rows are drawn: native checkboxes, or switches. */
2
+ declare const NOTICE_CONTROL_STYLES: readonly ["checkbox", "switch"];
3
+ /** Phones: a centred modal, or a sheet docked to the bottom edge. */
4
+ declare const NOTICE_MOBILE_LAYOUTS: readonly ["modal", "sheet"];
5
+ /** Where the notice sits on wider screens. */
6
+ declare const NOTICE_DESKTOP_POSITIONS: readonly ["center", "bottom-right", "bottom-left", "bottom-bar"];
7
+ /** The page behind the notice: dimmed with `colors.overlay`, or left as is. */
8
+ declare const NOTICE_BACKDROPS: readonly ["dim", "none"];
9
+ /** Phone footer: three stacked buttons, or Accept All over the other two. */
10
+ declare const NOTICE_PHONE_FOOTERS: readonly ["stacked", "paired"];
11
+ declare const NOTICE_TEXT_SCALES: readonly ["sm", "md", "lg"];
12
+
13
+ /**
14
+ * Surface and layout family a notice is drawn with, chosen in the Redacto
15
+ * console and served on `active_config.appearance.style`. Colours never come
16
+ * from the style: they come from the admin's palette, else the notice's brand.
17
+ */
18
+ type AppearanceStyle = "classic" | "glass" | "minimal" | "soft";
19
+ type NoticeControlStyle = (typeof NOTICE_CONTROL_STYLES)[number];
20
+ type NoticeMobileLayout = (typeof NOTICE_MOBILE_LAYOUTS)[number];
21
+ type NoticeDesktopPosition = (typeof NOTICE_DESKTOP_POSITIONS)[number];
22
+ type NoticeBackdrop = (typeof NOTICE_BACKDROPS)[number];
23
+ type NoticePhoneFooter = (typeof NOTICE_PHONE_FOOTERS)[number];
24
+ type NoticeTextScale = (typeof NOTICE_TEXT_SCALES)[number];
25
+
1
26
  /**
2
27
  * Optional sandbox options shared by the SDK's public option shapes and the
3
28
  * internal API params. When `token` is set the call sends the single
@@ -22,35 +47,109 @@ type SandboxOptions = {
22
47
  organisationUuid?: string;
23
48
  workspaceUuid?: string;
24
49
  };
25
- type Settings = {
50
+ type SelectionControlType = "checkbox" | "radio" | "dropdown";
51
+ type SettingsButtonColors = {
52
+ backgroundColor?: string;
53
+ textColor?: string;
54
+ };
55
+ /**
56
+ * The colours `settings` can set: the top-level palette, and the dark palette
57
+ * under `settings.darkPalette`. Colours are any CSS colour and are used as given.
58
+ */
59
+ type SettingsPalette = {
26
60
  button: {
27
- /** Styles the "accept selected" button. */
28
- accept: {
29
- backgroundColor: string;
30
- textColor: string;
61
+ /**
62
+ * The brand accent (checkboxes, switches, focus rings and Accept
63
+ * Selected's outline), and Accept All's colour when `acceptAll` is unset.
64
+ */
65
+ accept?: SettingsButtonColors;
66
+ /** The Accept All button; falls back to `accept`. */
67
+ acceptAll?: SettingsButtonColors;
68
+ /** The Accept Selected button itself. */
69
+ acceptSelected?: SettingsButtonColors;
70
+ decline?: SettingsButtonColors & {
71
+ borderColor?: string;
31
72
  };
32
- /** Optional: the accept-all shortcut falls back to `accept` when unset. */
33
- acceptAll?: {
34
- backgroundColor: string;
35
- textColor: string;
36
- };
37
- decline: {
38
- backgroundColor: string;
39
- textColor: string;
40
- };
41
- language: {
42
- backgroundColor: string;
43
- textColor: string;
73
+ language?: {
74
+ backgroundColor?: string;
75
+ textColor?: string;
44
76
  selectedBackgroundColor?: string;
45
77
  selectedTextColor?: string;
46
78
  };
47
79
  };
48
80
  link: string;
49
- borderRadius?: string;
50
81
  backgroundColor?: string;
82
+ /** Raised surfaces: menus and panels, and the tint of the glass style. */
83
+ surfaceColor?: string;
51
84
  headingColor?: string;
52
85
  textColor?: string;
86
+ /** Descriptions and hints. */
87
+ mutedTextColor?: string;
53
88
  borderColor?: string;
89
+ /** The page dim behind the notice. */
90
+ overlayColor?: string;
91
+ toggle?: {
92
+ onColor?: string;
93
+ offColor?: string;
94
+ knobColor?: string;
95
+ };
96
+ /** The element being read aloud by text-to-speech. */
97
+ ttsHighlight?: {
98
+ backgroundColor?: string;
99
+ textColor?: string;
100
+ };
101
+ };
102
+ /**
103
+ * Code-side styling for the notice. Everything here is optional and overrides,
104
+ * key by key, the appearance set in the Redacto console
105
+ * (`active_config.appearance`): host settings, then the console, then the
106
+ * notice's brand colours and the SDK defaults.
107
+ */
108
+ type Settings = SettingsPalette & {
109
+ /**
110
+ * Visual style: `"classic"`, `"glass"`, `"minimal"` or `"soft"`. Unknown
111
+ * values are ignored and the console's style (else classic) applies.
112
+ */
113
+ theme?: AppearanceStyle;
114
+ /** Defaults to "checkbox". Applies to purposes, product headings and data elements. */
115
+ selectionControl?: SelectionControlType;
116
+ /**
117
+ * How checkbox rows are drawn, in any style: `"checkbox"` or `"switch"`.
118
+ * Unset keeps checkboxes, in every style.
119
+ */
120
+ controlStyle?: NoticeControlStyle;
121
+ /**
122
+ * Asks "are you sure" before Accept All, Accept Selected or Decline submits
123
+ * (and before the inline embed auto-submits). Defaults to false.
124
+ */
125
+ confirmBeforeSubmit?: boolean;
126
+ borderRadius?: string;
127
+ /** Phones: `"modal"` (centred) or `"sheet"` (docked to the bottom edge). */
128
+ mobileLayout?: NoticeMobileLayout;
129
+ /** Wider screens: `"center"`, `"bottom-right"`, `"bottom-left"` or `"bottom-bar"`. */
130
+ desktopPosition?: NoticeDesktopPosition;
131
+ /** `"dim"` darkens the page behind the notice; `"none"` leaves it as is. */
132
+ backdrop?: NoticeBackdrop;
133
+ /** Collapse the notice text and the DPO block into disclosures. */
134
+ collapsibleSections?: boolean;
135
+ /** Phones: `"stacked"` buttons, or `"paired"` (Accept All over the other two). */
136
+ phoneFooter?: NoticePhoneFooter;
137
+ /** Follow the device's dark mode with `darkPalette` (else the console's). */
138
+ autoDark?: boolean;
139
+ darkPalette?: Partial<SettingsPalette>;
140
+ /** Desktop card width, any CSS length. */
141
+ maxWidth?: string;
142
+ /** Logo height, any CSS length. */
143
+ logoSize?: string;
144
+ /** `"sm"`, `"md"` or `"lg"`: scales every text size. */
145
+ textScale?: NoticeTextScale;
146
+ /** `false` turns entrances and transitions off. */
147
+ motion?: boolean;
148
+ /**
149
+ * CSS scoped to this notice. Target parts with `[data-redacto-part="…"]`;
150
+ * refused whole if it carries a disallowed token (`@import`, `javascript:`…).
151
+ */
152
+ customCss?: string;
54
153
  font?: string;
55
154
  };
56
155
 
@@ -73,8 +172,17 @@ type ModalOptions = SandboxOptions & {
73
172
  * customer code; optional third identifier alongside email/mobile.
74
173
  */
75
174
  ucic?: string;
175
+ /**
176
+ * The Redacto API host, e.g. `https://api.redacto.io` (recommended): the SDK
177
+ * reaches the consent server and the ledger under it. The consent server URL
178
+ * (`…/consent`) still works but is deprecated. Omit it and requests go to the
179
+ * production API.
180
+ */
76
181
  baseUrl?: string;
77
- /** Go ledger base URL — serves check-consent and the consent write; omit to use the legacy consent server. */
182
+ /**
183
+ * Go ledger base URL — serves check-consent and the consent write; omit to use the legacy consent server.
184
+ * @deprecated Read only when `baseUrl` is the consent server URL (`…/consent`) or omitted, as in earlier releases. Ignored when `baseUrl` is the API host.
185
+ */
78
186
  ledgerBaseUrl?: string;
79
187
  language?: string;
80
188
  blockUI?: boolean;
@@ -88,6 +196,8 @@ type ModalOptions = SandboxOptions & {
88
196
  digilockerCallbackUrl?: string;
89
197
  includeFullyConsentedData?: boolean;
90
198
  reviewModeButtonText?: string;
199
+ defaultOpenProducts?: string[];
200
+ otpGate?: OtpGateOptions;
91
201
  };
92
202
  type InlineOptions = {
93
203
  target: string | HTMLElement;
@@ -96,8 +206,17 @@ type InlineOptions = {
96
206
  notice_uuid: string;
97
207
  accessToken?: string;
98
208
  refreshToken?: string;
209
+ /**
210
+ * The Redacto API host, e.g. `https://api.redacto.io` (recommended): the SDK
211
+ * reaches the consent server and the ledger under it. The consent server URL
212
+ * (`…/consent`) still works but is deprecated. Omit it and requests go to the
213
+ * production API.
214
+ */
99
215
  baseUrl?: string;
100
- /** Go ledger base URL — serves check-consent and the consent write; omit to use the legacy consent server. */
216
+ /**
217
+ * Go ledger base URL — serves check-consent and the consent write; omit to use the legacy consent server.
218
+ * @deprecated Read only when `baseUrl` is the consent server URL (`…/consent`) or omitted, as in earlier releases. Ignored when `baseUrl` is the API host.
219
+ */
101
220
  ledgerBaseUrl?: string;
102
221
  language?: string;
103
222
  onAccept?: () => void;
@@ -109,10 +228,100 @@ type InlineOptions = {
109
228
  };
110
229
  type DigiLockerCallbackOptions = {
111
230
  accessToken: string;
231
+ /**
232
+ * The Redacto API host, e.g. `https://api.redacto.io`; the consent server URL
233
+ * (`…/consent`) still works but is deprecated. Omit it to use the one the
234
+ * notice stored before redirecting to DigiLocker.
235
+ */
112
236
  baseUrl?: string;
113
237
  onSuccess?: (verificationReference: string) => void;
114
238
  onError?: (error: Error, errorCode?: string) => void;
115
239
  };
240
+ type OtpVerifyResult = {
241
+ ok: boolean;
242
+ message?: string;
243
+ };
244
+ type OtpGateOptions = {
245
+ required: boolean;
246
+ onVerify: (code: string) => Promise<OtpVerifyResult>;
247
+ title?: string;
248
+ description?: string;
249
+ submitLabel?: string;
250
+ };
251
+
252
+ type AssistedOptions = {
253
+ organisationUuid: string;
254
+ workspaceUuid: string;
255
+ noticeUuid: string;
256
+ /**
257
+ * The Redacto API host, e.g. `https://api.redacto.io` (recommended): the SDK
258
+ * reaches the consent server and the ledger under it. The consent server URL
259
+ * (`…/consent`) still works but is deprecated. Omit it and requests go to the
260
+ * production API.
261
+ */
262
+ baseUrl?: string;
263
+ /**
264
+ * Go ledger base URL — serves check-consent and the consent write; omit to use the legacy consent server.
265
+ * @deprecated Read only when `baseUrl` is the consent server URL (`…/consent`) or omitted, as in earlier releases. Ignored when `baseUrl` is the API host.
266
+ */
267
+ ledgerBaseUrl?: string;
268
+ /**
269
+ * Optional code-side styling. The notice looks as set in the Redacto console
270
+ * (Display settings, Appearance); anything set here overrides the console
271
+ * for that key only. Display only: the submission and its verification are
272
+ * unchanged.
273
+ */
274
+ settings?: Partial<Settings>;
275
+ onDecline?: () => void;
276
+ onComplete?: () => void;
277
+ onError?: (error: Error) => void;
278
+ };
279
+
280
+ type PrivacyCenterOptions = {
281
+ /** Element, or CSS selector for it, that the Privacy Center is mounted in. */
282
+ target: string | HTMLElement;
283
+ /** The organisation's UUID. Required unless `url` is given. */
284
+ organisationUuid?: string;
285
+ /**
286
+ * @deprecated Pass `organisationUuid`. Still frames the hosted page for this
287
+ * slug when no `organisationUuid` is given, with a one-time console warning;
288
+ * will be removed in a future major release.
289
+ */
290
+ slug?: string;
291
+ /** Full URL of the hosted Privacy Center, e.g. on a custom domain. Wins over `organisationUuid`. */
292
+ url?: string;
293
+ /** Where the hosted Privacy Center lives. Defaults to Redacto's production console. */
294
+ origin?: string;
295
+ /** Language to open in (`en`, `hi`, …), sent as `?lang=`. */
296
+ language?: string;
297
+ /**
298
+ * A fixed height (`640` or `"80vh"`). Leave it out (or pass `"auto"`) to let
299
+ * the frame grow to fit the page, starting at 720px.
300
+ */
301
+ height?: number | string;
302
+ /** The frame's accessible title. Defaults to "Privacy Center". */
303
+ title?: string;
304
+ };
305
+ type PrivacyCenterHandle = {
306
+ iframe: HTMLIFrameElement;
307
+ /** Removes the frame and stops listening for its height. */
308
+ destroy: () => void;
309
+ };
310
+
311
+ type ApiErrorCode = "INVALID_TOKEN" | "TOKEN_TENANT_MISMATCH" | "UNAUTHORIZED" | "USER_NOT_FOUND" | "USER_EMAIL_MISMATCH" | "USER_MOBILE_MISMATCH" | "USER_CONTACT_MISMATCH" | "NO_IDENTIFIER_PROVIDED" | "INVALID_PAYLOAD" | "VALIDATION_ERROR" | "NOTICE_NOT_FOUND" | "NOTICE_CONFIGURATION_NOT_FOUND" | "NOTICE_STILL_IN_DRAFT" | "CONSENT_ALREADY_PROVIDED" | "PURPOSE_NOT_FOUND" | "INVALID_PURPOSE" | "INVALID_DATA_ELEMENTS" | "MISSING_PURPOSE" | "MISSING_DATA_ELEMENTS" | "REQUIRED_DATA_ELEMENT_NOT_ENABLED" | "AUDIO_NOT_FOUND" | "INVALID_LANGUAGE" | "VERIFICATION_FAILED" | "VERIFICATION_EXPIRED" | "GUARDIAN_INFO_NOT_FOUND" | "GUARDIAN_SESSION_INVALID" | "SESSION_EXPIRED" | "INTERNAL_ERROR";
312
+ type ApiErrorCodeLike = ApiErrorCode | (string & {});
313
+
314
+ declare class ApiError extends Error {
315
+ readonly status: number;
316
+ readonly code?: ApiErrorCodeLike;
317
+ readonly shouldRequestNew?: boolean;
318
+ constructor(opts: {
319
+ status: number;
320
+ code?: ApiErrorCodeLike;
321
+ message: string;
322
+ shouldRequestNew?: boolean;
323
+ });
324
+ }
116
325
 
117
326
  /**
118
327
  * Initialize a modal consent dialog.
@@ -124,6 +333,13 @@ declare function init(options: ModalOptions): void;
124
333
  * Renders consent purposes inside a target container element.
125
334
  */
126
335
  declare function inline(options: InlineOptions): void;
336
+ declare function updateToken(accessToken: string): void;
337
+ declare function assisted(options: AssistedOptions): void;
338
+ /**
339
+ * Mount the hosted Privacy Center in an iframe inside a target element.
340
+ * Returns a handle whose `destroy()` removes it.
341
+ */
342
+ declare function privacyCenter(options: PrivacyCenterOptions): PrivacyCenterHandle;
127
343
  /**
128
344
  * Destroy all active consent instances.
129
345
  */
@@ -136,9 +352,12 @@ declare function digilockerCallback(options: DigiLockerCallbackOptions): void;
136
352
  declare const RedactoConsent: {
137
353
  init: typeof init;
138
354
  inline: typeof inline;
355
+ assisted: typeof assisted;
356
+ privacyCenter: typeof privacyCenter;
139
357
  destroy: typeof destroy;
140
358
  digilockerCallback: typeof digilockerCallback;
359
+ updateToken: typeof updateToken;
141
360
  version: string;
142
361
  };
143
362
 
144
- export { type DigiLockerCallbackOptions, type InlineOptions, type ModalOptions, type Settings, RedactoConsent as default, destroy, digilockerCallback, init, inline };
363
+ export { ApiError, type ApiErrorCode, type AssistedOptions, type DigiLockerCallbackOptions, type InlineOptions, type ModalOptions, type OtpGateOptions, type OtpVerifyResult, type PrivacyCenterHandle, type PrivacyCenterOptions, type Settings, assisted, RedactoConsent as default, destroy, digilockerCallback, init, inline, privacyCenter, updateToken };
package/dist/redacto.d.ts CHANGED
@@ -1,3 +1,28 @@
1
+ /** How checkbox rows are drawn: native checkboxes, or switches. */
2
+ declare const NOTICE_CONTROL_STYLES: readonly ["checkbox", "switch"];
3
+ /** Phones: a centred modal, or a sheet docked to the bottom edge. */
4
+ declare const NOTICE_MOBILE_LAYOUTS: readonly ["modal", "sheet"];
5
+ /** Where the notice sits on wider screens. */
6
+ declare const NOTICE_DESKTOP_POSITIONS: readonly ["center", "bottom-right", "bottom-left", "bottom-bar"];
7
+ /** The page behind the notice: dimmed with `colors.overlay`, or left as is. */
8
+ declare const NOTICE_BACKDROPS: readonly ["dim", "none"];
9
+ /** Phone footer: three stacked buttons, or Accept All over the other two. */
10
+ declare const NOTICE_PHONE_FOOTERS: readonly ["stacked", "paired"];
11
+ declare const NOTICE_TEXT_SCALES: readonly ["sm", "md", "lg"];
12
+
13
+ /**
14
+ * Surface and layout family a notice is drawn with, chosen in the Redacto
15
+ * console and served on `active_config.appearance.style`. Colours never come
16
+ * from the style: they come from the admin's palette, else the notice's brand.
17
+ */
18
+ type AppearanceStyle = "classic" | "glass" | "minimal" | "soft";
19
+ type NoticeControlStyle = (typeof NOTICE_CONTROL_STYLES)[number];
20
+ type NoticeMobileLayout = (typeof NOTICE_MOBILE_LAYOUTS)[number];
21
+ type NoticeDesktopPosition = (typeof NOTICE_DESKTOP_POSITIONS)[number];
22
+ type NoticeBackdrop = (typeof NOTICE_BACKDROPS)[number];
23
+ type NoticePhoneFooter = (typeof NOTICE_PHONE_FOOTERS)[number];
24
+ type NoticeTextScale = (typeof NOTICE_TEXT_SCALES)[number];
25
+
1
26
  /**
2
27
  * Optional sandbox options shared by the SDK's public option shapes and the
3
28
  * internal API params. When `token` is set the call sends the single
@@ -22,35 +47,109 @@ type SandboxOptions = {
22
47
  organisationUuid?: string;
23
48
  workspaceUuid?: string;
24
49
  };
25
- type Settings = {
50
+ type SelectionControlType = "checkbox" | "radio" | "dropdown";
51
+ type SettingsButtonColors = {
52
+ backgroundColor?: string;
53
+ textColor?: string;
54
+ };
55
+ /**
56
+ * The colours `settings` can set: the top-level palette, and the dark palette
57
+ * under `settings.darkPalette`. Colours are any CSS colour and are used as given.
58
+ */
59
+ type SettingsPalette = {
26
60
  button: {
27
- /** Styles the "accept selected" button. */
28
- accept: {
29
- backgroundColor: string;
30
- textColor: string;
61
+ /**
62
+ * The brand accent (checkboxes, switches, focus rings and Accept
63
+ * Selected's outline), and Accept All's colour when `acceptAll` is unset.
64
+ */
65
+ accept?: SettingsButtonColors;
66
+ /** The Accept All button; falls back to `accept`. */
67
+ acceptAll?: SettingsButtonColors;
68
+ /** The Accept Selected button itself. */
69
+ acceptSelected?: SettingsButtonColors;
70
+ decline?: SettingsButtonColors & {
71
+ borderColor?: string;
31
72
  };
32
- /** Optional: the accept-all shortcut falls back to `accept` when unset. */
33
- acceptAll?: {
34
- backgroundColor: string;
35
- textColor: string;
36
- };
37
- decline: {
38
- backgroundColor: string;
39
- textColor: string;
40
- };
41
- language: {
42
- backgroundColor: string;
43
- textColor: string;
73
+ language?: {
74
+ backgroundColor?: string;
75
+ textColor?: string;
44
76
  selectedBackgroundColor?: string;
45
77
  selectedTextColor?: string;
46
78
  };
47
79
  };
48
80
  link: string;
49
- borderRadius?: string;
50
81
  backgroundColor?: string;
82
+ /** Raised surfaces: menus and panels, and the tint of the glass style. */
83
+ surfaceColor?: string;
51
84
  headingColor?: string;
52
85
  textColor?: string;
86
+ /** Descriptions and hints. */
87
+ mutedTextColor?: string;
53
88
  borderColor?: string;
89
+ /** The page dim behind the notice. */
90
+ overlayColor?: string;
91
+ toggle?: {
92
+ onColor?: string;
93
+ offColor?: string;
94
+ knobColor?: string;
95
+ };
96
+ /** The element being read aloud by text-to-speech. */
97
+ ttsHighlight?: {
98
+ backgroundColor?: string;
99
+ textColor?: string;
100
+ };
101
+ };
102
+ /**
103
+ * Code-side styling for the notice. Everything here is optional and overrides,
104
+ * key by key, the appearance set in the Redacto console
105
+ * (`active_config.appearance`): host settings, then the console, then the
106
+ * notice's brand colours and the SDK defaults.
107
+ */
108
+ type Settings = SettingsPalette & {
109
+ /**
110
+ * Visual style: `"classic"`, `"glass"`, `"minimal"` or `"soft"`. Unknown
111
+ * values are ignored and the console's style (else classic) applies.
112
+ */
113
+ theme?: AppearanceStyle;
114
+ /** Defaults to "checkbox". Applies to purposes, product headings and data elements. */
115
+ selectionControl?: SelectionControlType;
116
+ /**
117
+ * How checkbox rows are drawn, in any style: `"checkbox"` or `"switch"`.
118
+ * Unset keeps checkboxes, in every style.
119
+ */
120
+ controlStyle?: NoticeControlStyle;
121
+ /**
122
+ * Asks "are you sure" before Accept All, Accept Selected or Decline submits
123
+ * (and before the inline embed auto-submits). Defaults to false.
124
+ */
125
+ confirmBeforeSubmit?: boolean;
126
+ borderRadius?: string;
127
+ /** Phones: `"modal"` (centred) or `"sheet"` (docked to the bottom edge). */
128
+ mobileLayout?: NoticeMobileLayout;
129
+ /** Wider screens: `"center"`, `"bottom-right"`, `"bottom-left"` or `"bottom-bar"`. */
130
+ desktopPosition?: NoticeDesktopPosition;
131
+ /** `"dim"` darkens the page behind the notice; `"none"` leaves it as is. */
132
+ backdrop?: NoticeBackdrop;
133
+ /** Collapse the notice text and the DPO block into disclosures. */
134
+ collapsibleSections?: boolean;
135
+ /** Phones: `"stacked"` buttons, or `"paired"` (Accept All over the other two). */
136
+ phoneFooter?: NoticePhoneFooter;
137
+ /** Follow the device's dark mode with `darkPalette` (else the console's). */
138
+ autoDark?: boolean;
139
+ darkPalette?: Partial<SettingsPalette>;
140
+ /** Desktop card width, any CSS length. */
141
+ maxWidth?: string;
142
+ /** Logo height, any CSS length. */
143
+ logoSize?: string;
144
+ /** `"sm"`, `"md"` or `"lg"`: scales every text size. */
145
+ textScale?: NoticeTextScale;
146
+ /** `false` turns entrances and transitions off. */
147
+ motion?: boolean;
148
+ /**
149
+ * CSS scoped to this notice. Target parts with `[data-redacto-part="…"]`;
150
+ * refused whole if it carries a disallowed token (`@import`, `javascript:`…).
151
+ */
152
+ customCss?: string;
54
153
  font?: string;
55
154
  };
56
155
 
@@ -73,8 +172,17 @@ type ModalOptions = SandboxOptions & {
73
172
  * customer code; optional third identifier alongside email/mobile.
74
173
  */
75
174
  ucic?: string;
175
+ /**
176
+ * The Redacto API host, e.g. `https://api.redacto.io` (recommended): the SDK
177
+ * reaches the consent server and the ledger under it. The consent server URL
178
+ * (`…/consent`) still works but is deprecated. Omit it and requests go to the
179
+ * production API.
180
+ */
76
181
  baseUrl?: string;
77
- /** Go ledger base URL — serves check-consent and the consent write; omit to use the legacy consent server. */
182
+ /**
183
+ * Go ledger base URL — serves check-consent and the consent write; omit to use the legacy consent server.
184
+ * @deprecated Read only when `baseUrl` is the consent server URL (`…/consent`) or omitted, as in earlier releases. Ignored when `baseUrl` is the API host.
185
+ */
78
186
  ledgerBaseUrl?: string;
79
187
  language?: string;
80
188
  blockUI?: boolean;
@@ -88,6 +196,8 @@ type ModalOptions = SandboxOptions & {
88
196
  digilockerCallbackUrl?: string;
89
197
  includeFullyConsentedData?: boolean;
90
198
  reviewModeButtonText?: string;
199
+ defaultOpenProducts?: string[];
200
+ otpGate?: OtpGateOptions;
91
201
  };
92
202
  type InlineOptions = {
93
203
  target: string | HTMLElement;
@@ -96,8 +206,17 @@ type InlineOptions = {
96
206
  notice_uuid: string;
97
207
  accessToken?: string;
98
208
  refreshToken?: string;
209
+ /**
210
+ * The Redacto API host, e.g. `https://api.redacto.io` (recommended): the SDK
211
+ * reaches the consent server and the ledger under it. The consent server URL
212
+ * (`…/consent`) still works but is deprecated. Omit it and requests go to the
213
+ * production API.
214
+ */
99
215
  baseUrl?: string;
100
- /** Go ledger base URL — serves check-consent and the consent write; omit to use the legacy consent server. */
216
+ /**
217
+ * Go ledger base URL — serves check-consent and the consent write; omit to use the legacy consent server.
218
+ * @deprecated Read only when `baseUrl` is the consent server URL (`…/consent`) or omitted, as in earlier releases. Ignored when `baseUrl` is the API host.
219
+ */
101
220
  ledgerBaseUrl?: string;
102
221
  language?: string;
103
222
  onAccept?: () => void;
@@ -109,10 +228,100 @@ type InlineOptions = {
109
228
  };
110
229
  type DigiLockerCallbackOptions = {
111
230
  accessToken: string;
231
+ /**
232
+ * The Redacto API host, e.g. `https://api.redacto.io`; the consent server URL
233
+ * (`…/consent`) still works but is deprecated. Omit it to use the one the
234
+ * notice stored before redirecting to DigiLocker.
235
+ */
112
236
  baseUrl?: string;
113
237
  onSuccess?: (verificationReference: string) => void;
114
238
  onError?: (error: Error, errorCode?: string) => void;
115
239
  };
240
+ type OtpVerifyResult = {
241
+ ok: boolean;
242
+ message?: string;
243
+ };
244
+ type OtpGateOptions = {
245
+ required: boolean;
246
+ onVerify: (code: string) => Promise<OtpVerifyResult>;
247
+ title?: string;
248
+ description?: string;
249
+ submitLabel?: string;
250
+ };
251
+
252
+ type AssistedOptions = {
253
+ organisationUuid: string;
254
+ workspaceUuid: string;
255
+ noticeUuid: string;
256
+ /**
257
+ * The Redacto API host, e.g. `https://api.redacto.io` (recommended): the SDK
258
+ * reaches the consent server and the ledger under it. The consent server URL
259
+ * (`…/consent`) still works but is deprecated. Omit it and requests go to the
260
+ * production API.
261
+ */
262
+ baseUrl?: string;
263
+ /**
264
+ * Go ledger base URL — serves check-consent and the consent write; omit to use the legacy consent server.
265
+ * @deprecated Read only when `baseUrl` is the consent server URL (`…/consent`) or omitted, as in earlier releases. Ignored when `baseUrl` is the API host.
266
+ */
267
+ ledgerBaseUrl?: string;
268
+ /**
269
+ * Optional code-side styling. The notice looks as set in the Redacto console
270
+ * (Display settings, Appearance); anything set here overrides the console
271
+ * for that key only. Display only: the submission and its verification are
272
+ * unchanged.
273
+ */
274
+ settings?: Partial<Settings>;
275
+ onDecline?: () => void;
276
+ onComplete?: () => void;
277
+ onError?: (error: Error) => void;
278
+ };
279
+
280
+ type PrivacyCenterOptions = {
281
+ /** Element, or CSS selector for it, that the Privacy Center is mounted in. */
282
+ target: string | HTMLElement;
283
+ /** The organisation's UUID. Required unless `url` is given. */
284
+ organisationUuid?: string;
285
+ /**
286
+ * @deprecated Pass `organisationUuid`. Still frames the hosted page for this
287
+ * slug when no `organisationUuid` is given, with a one-time console warning;
288
+ * will be removed in a future major release.
289
+ */
290
+ slug?: string;
291
+ /** Full URL of the hosted Privacy Center, e.g. on a custom domain. Wins over `organisationUuid`. */
292
+ url?: string;
293
+ /** Where the hosted Privacy Center lives. Defaults to Redacto's production console. */
294
+ origin?: string;
295
+ /** Language to open in (`en`, `hi`, …), sent as `?lang=`. */
296
+ language?: string;
297
+ /**
298
+ * A fixed height (`640` or `"80vh"`). Leave it out (or pass `"auto"`) to let
299
+ * the frame grow to fit the page, starting at 720px.
300
+ */
301
+ height?: number | string;
302
+ /** The frame's accessible title. Defaults to "Privacy Center". */
303
+ title?: string;
304
+ };
305
+ type PrivacyCenterHandle = {
306
+ iframe: HTMLIFrameElement;
307
+ /** Removes the frame and stops listening for its height. */
308
+ destroy: () => void;
309
+ };
310
+
311
+ type ApiErrorCode = "INVALID_TOKEN" | "TOKEN_TENANT_MISMATCH" | "UNAUTHORIZED" | "USER_NOT_FOUND" | "USER_EMAIL_MISMATCH" | "USER_MOBILE_MISMATCH" | "USER_CONTACT_MISMATCH" | "NO_IDENTIFIER_PROVIDED" | "INVALID_PAYLOAD" | "VALIDATION_ERROR" | "NOTICE_NOT_FOUND" | "NOTICE_CONFIGURATION_NOT_FOUND" | "NOTICE_STILL_IN_DRAFT" | "CONSENT_ALREADY_PROVIDED" | "PURPOSE_NOT_FOUND" | "INVALID_PURPOSE" | "INVALID_DATA_ELEMENTS" | "MISSING_PURPOSE" | "MISSING_DATA_ELEMENTS" | "REQUIRED_DATA_ELEMENT_NOT_ENABLED" | "AUDIO_NOT_FOUND" | "INVALID_LANGUAGE" | "VERIFICATION_FAILED" | "VERIFICATION_EXPIRED" | "GUARDIAN_INFO_NOT_FOUND" | "GUARDIAN_SESSION_INVALID" | "SESSION_EXPIRED" | "INTERNAL_ERROR";
312
+ type ApiErrorCodeLike = ApiErrorCode | (string & {});
313
+
314
+ declare class ApiError extends Error {
315
+ readonly status: number;
316
+ readonly code?: ApiErrorCodeLike;
317
+ readonly shouldRequestNew?: boolean;
318
+ constructor(opts: {
319
+ status: number;
320
+ code?: ApiErrorCodeLike;
321
+ message: string;
322
+ shouldRequestNew?: boolean;
323
+ });
324
+ }
116
325
 
117
326
  /**
118
327
  * Initialize a modal consent dialog.
@@ -124,6 +333,13 @@ declare function init(options: ModalOptions): void;
124
333
  * Renders consent purposes inside a target container element.
125
334
  */
126
335
  declare function inline(options: InlineOptions): void;
336
+ declare function updateToken(accessToken: string): void;
337
+ declare function assisted(options: AssistedOptions): void;
338
+ /**
339
+ * Mount the hosted Privacy Center in an iframe inside a target element.
340
+ * Returns a handle whose `destroy()` removes it.
341
+ */
342
+ declare function privacyCenter(options: PrivacyCenterOptions): PrivacyCenterHandle;
127
343
  /**
128
344
  * Destroy all active consent instances.
129
345
  */
@@ -136,9 +352,12 @@ declare function digilockerCallback(options: DigiLockerCallbackOptions): void;
136
352
  declare const RedactoConsent: {
137
353
  init: typeof init;
138
354
  inline: typeof inline;
355
+ assisted: typeof assisted;
356
+ privacyCenter: typeof privacyCenter;
139
357
  destroy: typeof destroy;
140
358
  digilockerCallback: typeof digilockerCallback;
359
+ updateToken: typeof updateToken;
141
360
  version: string;
142
361
  };
143
362
 
144
- export { type DigiLockerCallbackOptions, type InlineOptions, type ModalOptions, type Settings, RedactoConsent as default, destroy, digilockerCallback, init, inline };
363
+ export { ApiError, type ApiErrorCode, type AssistedOptions, type DigiLockerCallbackOptions, type InlineOptions, type ModalOptions, type OtpGateOptions, type OtpVerifyResult, type PrivacyCenterHandle, type PrivacyCenterOptions, type Settings, assisted, RedactoConsent as default, destroy, digilockerCallback, init, inline, privacyCenter, updateToken };