@redacto.io/consent-sdk-js 1.1.0 → 1.2.0-beta.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.
@@ -22,6 +22,7 @@ type SandboxOptions = {
22
22
  organisationUuid?: string;
23
23
  workspaceUuid?: string;
24
24
  };
25
+ type SelectionControlType = "checkbox" | "radio" | "dropdown";
25
26
  type Settings = {
26
27
  button: {
27
28
  /** Styles the "accept selected" button. */
@@ -52,6 +53,8 @@ type Settings = {
52
53
  textColor?: string;
53
54
  borderColor?: string;
54
55
  font?: string;
56
+ selectionControl?: SelectionControlType;
57
+ confirmBeforeSubmit?: boolean;
55
58
  };
56
59
 
57
60
  type ModalOptions = SandboxOptions & {
@@ -88,6 +91,8 @@ type ModalOptions = SandboxOptions & {
88
91
  digilockerCallbackUrl?: string;
89
92
  includeFullyConsentedData?: boolean;
90
93
  reviewModeButtonText?: string;
94
+ defaultOpenProducts?: string[];
95
+ otpGate?: OtpGateOptions;
91
96
  };
92
97
  type InlineOptions = {
93
98
  target: string | HTMLElement;
@@ -113,6 +118,68 @@ type DigiLockerCallbackOptions = {
113
118
  onSuccess?: (verificationReference: string) => void;
114
119
  onError?: (error: Error, errorCode?: string) => void;
115
120
  };
121
+ type OtpVerifyResult = {
122
+ ok: boolean;
123
+ message?: string;
124
+ };
125
+ type OtpGateOptions = {
126
+ required: boolean;
127
+ onVerify: (code: string) => Promise<OtpVerifyResult>;
128
+ title?: string;
129
+ description?: string;
130
+ submitLabel?: string;
131
+ };
132
+
133
+ type AssistedOptions = {
134
+ organisationUuid: string;
135
+ workspaceUuid: string;
136
+ noticeUuid: string;
137
+ baseUrl?: string;
138
+ ledgerBaseUrl?: string;
139
+ onDecline?: () => void;
140
+ onComplete?: () => void;
141
+ onError?: (error: Error) => void;
142
+ };
143
+
144
+ type PrivacyCenterOptions = {
145
+ /** Element, or CSS selector for it, that the Privacy Center is mounted in. */
146
+ target: string | HTMLElement;
147
+ /** The organisation's Privacy Center slug. Required unless `url` is given. */
148
+ slug?: string;
149
+ /** Full URL of the hosted Privacy Center, e.g. on a custom domain. Wins over `slug`. */
150
+ url?: string;
151
+ /** Where the hosted Privacy Center lives. Defaults to Redacto's production console. */
152
+ origin?: string;
153
+ /** Language to open in (`en`, `hi`, …), sent as `?lang=`. */
154
+ language?: string;
155
+ /**
156
+ * A fixed height (`640` or `"80vh"`). Leave it out (or pass `"auto"`) to let
157
+ * the frame grow to fit the page, starting at 720px.
158
+ */
159
+ height?: number | string;
160
+ /** The frame's accessible title. Defaults to "Privacy Center". */
161
+ title?: string;
162
+ };
163
+ type PrivacyCenterHandle = {
164
+ iframe: HTMLIFrameElement;
165
+ /** Removes the frame and stops listening for its height. */
166
+ destroy: () => void;
167
+ };
168
+
169
+ 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";
170
+ type ApiErrorCodeLike = ApiErrorCode | (string & {});
171
+
172
+ declare class ApiError extends Error {
173
+ readonly status: number;
174
+ readonly code?: ApiErrorCodeLike;
175
+ readonly shouldRequestNew?: boolean;
176
+ constructor(opts: {
177
+ status: number;
178
+ code?: ApiErrorCodeLike;
179
+ message: string;
180
+ shouldRequestNew?: boolean;
181
+ });
182
+ }
116
183
 
117
184
  /**
118
185
  * Initialize a modal consent dialog.
@@ -124,6 +191,13 @@ declare function init(options: ModalOptions): void;
124
191
  * Renders consent purposes inside a target container element.
125
192
  */
126
193
  declare function inline(options: InlineOptions): void;
194
+ declare function updateToken(accessToken: string): void;
195
+ declare function assisted(options: AssistedOptions): void;
196
+ /**
197
+ * Mount the hosted Privacy Center in an iframe inside a target element.
198
+ * Returns a handle whose `destroy()` removes it.
199
+ */
200
+ declare function privacyCenter(options: PrivacyCenterOptions): PrivacyCenterHandle;
127
201
  /**
128
202
  * Destroy all active consent instances.
129
203
  */
@@ -136,9 +210,12 @@ declare function digilockerCallback(options: DigiLockerCallbackOptions): void;
136
210
  declare const RedactoConsent: {
137
211
  init: typeof init;
138
212
  inline: typeof inline;
213
+ assisted: typeof assisted;
214
+ privacyCenter: typeof privacyCenter;
139
215
  destroy: typeof destroy;
140
216
  digilockerCallback: typeof digilockerCallback;
217
+ updateToken: typeof updateToken;
141
218
  version: string;
142
219
  };
143
220
 
144
- export { type DigiLockerCallbackOptions, type InlineOptions, type ModalOptions, type Settings, RedactoConsent as default, destroy, digilockerCallback, init, inline };
221
+ 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
@@ -22,6 +22,7 @@ type SandboxOptions = {
22
22
  organisationUuid?: string;
23
23
  workspaceUuid?: string;
24
24
  };
25
+ type SelectionControlType = "checkbox" | "radio" | "dropdown";
25
26
  type Settings = {
26
27
  button: {
27
28
  /** Styles the "accept selected" button. */
@@ -52,6 +53,8 @@ type Settings = {
52
53
  textColor?: string;
53
54
  borderColor?: string;
54
55
  font?: string;
56
+ selectionControl?: SelectionControlType;
57
+ confirmBeforeSubmit?: boolean;
55
58
  };
56
59
 
57
60
  type ModalOptions = SandboxOptions & {
@@ -88,6 +91,8 @@ type ModalOptions = SandboxOptions & {
88
91
  digilockerCallbackUrl?: string;
89
92
  includeFullyConsentedData?: boolean;
90
93
  reviewModeButtonText?: string;
94
+ defaultOpenProducts?: string[];
95
+ otpGate?: OtpGateOptions;
91
96
  };
92
97
  type InlineOptions = {
93
98
  target: string | HTMLElement;
@@ -113,6 +118,68 @@ type DigiLockerCallbackOptions = {
113
118
  onSuccess?: (verificationReference: string) => void;
114
119
  onError?: (error: Error, errorCode?: string) => void;
115
120
  };
121
+ type OtpVerifyResult = {
122
+ ok: boolean;
123
+ message?: string;
124
+ };
125
+ type OtpGateOptions = {
126
+ required: boolean;
127
+ onVerify: (code: string) => Promise<OtpVerifyResult>;
128
+ title?: string;
129
+ description?: string;
130
+ submitLabel?: string;
131
+ };
132
+
133
+ type AssistedOptions = {
134
+ organisationUuid: string;
135
+ workspaceUuid: string;
136
+ noticeUuid: string;
137
+ baseUrl?: string;
138
+ ledgerBaseUrl?: string;
139
+ onDecline?: () => void;
140
+ onComplete?: () => void;
141
+ onError?: (error: Error) => void;
142
+ };
143
+
144
+ type PrivacyCenterOptions = {
145
+ /** Element, or CSS selector for it, that the Privacy Center is mounted in. */
146
+ target: string | HTMLElement;
147
+ /** The organisation's Privacy Center slug. Required unless `url` is given. */
148
+ slug?: string;
149
+ /** Full URL of the hosted Privacy Center, e.g. on a custom domain. Wins over `slug`. */
150
+ url?: string;
151
+ /** Where the hosted Privacy Center lives. Defaults to Redacto's production console. */
152
+ origin?: string;
153
+ /** Language to open in (`en`, `hi`, …), sent as `?lang=`. */
154
+ language?: string;
155
+ /**
156
+ * A fixed height (`640` or `"80vh"`). Leave it out (or pass `"auto"`) to let
157
+ * the frame grow to fit the page, starting at 720px.
158
+ */
159
+ height?: number | string;
160
+ /** The frame's accessible title. Defaults to "Privacy Center". */
161
+ title?: string;
162
+ };
163
+ type PrivacyCenterHandle = {
164
+ iframe: HTMLIFrameElement;
165
+ /** Removes the frame and stops listening for its height. */
166
+ destroy: () => void;
167
+ };
168
+
169
+ 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";
170
+ type ApiErrorCodeLike = ApiErrorCode | (string & {});
171
+
172
+ declare class ApiError extends Error {
173
+ readonly status: number;
174
+ readonly code?: ApiErrorCodeLike;
175
+ readonly shouldRequestNew?: boolean;
176
+ constructor(opts: {
177
+ status: number;
178
+ code?: ApiErrorCodeLike;
179
+ message: string;
180
+ shouldRequestNew?: boolean;
181
+ });
182
+ }
116
183
 
117
184
  /**
118
185
  * Initialize a modal consent dialog.
@@ -124,6 +191,13 @@ declare function init(options: ModalOptions): void;
124
191
  * Renders consent purposes inside a target container element.
125
192
  */
126
193
  declare function inline(options: InlineOptions): void;
194
+ declare function updateToken(accessToken: string): void;
195
+ declare function assisted(options: AssistedOptions): void;
196
+ /**
197
+ * Mount the hosted Privacy Center in an iframe inside a target element.
198
+ * Returns a handle whose `destroy()` removes it.
199
+ */
200
+ declare function privacyCenter(options: PrivacyCenterOptions): PrivacyCenterHandle;
127
201
  /**
128
202
  * Destroy all active consent instances.
129
203
  */
@@ -136,9 +210,12 @@ declare function digilockerCallback(options: DigiLockerCallbackOptions): void;
136
210
  declare const RedactoConsent: {
137
211
  init: typeof init;
138
212
  inline: typeof inline;
213
+ assisted: typeof assisted;
214
+ privacyCenter: typeof privacyCenter;
139
215
  destroy: typeof destroy;
140
216
  digilockerCallback: typeof digilockerCallback;
217
+ updateToken: typeof updateToken;
141
218
  version: string;
142
219
  };
143
220
 
144
- export { type DigiLockerCallbackOptions, type InlineOptions, type ModalOptions, type Settings, RedactoConsent as default, destroy, digilockerCallback, init, inline };
221
+ 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 };