@redacto.io/consent-sdk-react 3.4.0 → 4.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.
- package/.turbo/turbo-build.log +21 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +49 -2
- package/dist/index.d.ts +49 -2
- package/dist/index.js +1806 -345
- package/dist/index.mjs +1805 -345
- package/package.json +1 -1
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +201 -118
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +1192 -93
- package/src/RedactoNoticeConsent/api/index.ts +335 -246
- package/src/RedactoNoticeConsent/api/types.ts +138 -41
- package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +536 -0
- package/src/RedactoNoticeConsent/components/index.ts +7 -0
- package/src/RedactoNoticeConsent/injectStyles.ts +11 -0
- package/src/RedactoNoticeConsent/services/storage.ts +122 -0
- package/src/RedactoNoticeConsent/types.ts +2 -0
- package/src/RedactoNoticeConsentInline/api/index.ts +26 -64
- package/src/RedactoNoticeConsentInline/api/types.ts +0 -25
- package/src/index.ts +10 -0
- package/src/utils/isLegacyApi.ts +0 -12
|
@@ -171,33 +171,11 @@ export type ConsentEventPayload = {
|
|
|
171
171
|
source?: string;
|
|
172
172
|
declined?: boolean;
|
|
173
173
|
meta_data?: {
|
|
174
|
-
specific_uuid
|
|
174
|
+
specific_uuid?: string;
|
|
175
|
+
minor_age?: number;
|
|
175
176
|
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
// @deprecated Remove when production backend supports the new payload format.
|
|
179
|
-
export type LegacyConsentEventPayload = {
|
|
180
|
-
primary_email?: string;
|
|
181
|
-
notice_uuid: string;
|
|
182
|
-
source: string;
|
|
183
|
-
declined: boolean;
|
|
184
|
-
consents: {
|
|
185
|
-
purposes: Array<{
|
|
186
|
-
uuid: string;
|
|
187
|
-
name: string;
|
|
188
|
-
description: string;
|
|
189
|
-
industries?: string;
|
|
190
|
-
selected: boolean;
|
|
191
|
-
data_elements: Array<{
|
|
192
|
-
uuid: string;
|
|
193
|
-
name: string;
|
|
194
|
-
enabled: boolean;
|
|
195
|
-
required: boolean;
|
|
196
|
-
selected: boolean;
|
|
197
|
-
}>;
|
|
198
|
-
}>;
|
|
199
|
-
};
|
|
200
|
-
meta_data?: { specific_uuid: string };
|
|
177
|
+
guardian_verification_reference?: string;
|
|
178
|
+
self_declared_adult?: boolean;
|
|
201
179
|
};
|
|
202
180
|
|
|
203
181
|
export type DataElement = {
|
|
@@ -224,22 +202,11 @@ export type SubmitConsentEventParams = {
|
|
|
224
202
|
purposes: Array<Purpose>;
|
|
225
203
|
declined: boolean;
|
|
226
204
|
meta_data?: {
|
|
227
|
-
specific_uuid
|
|
205
|
+
specific_uuid?: string;
|
|
206
|
+
minor_age?: number;
|
|
228
207
|
};
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
export type SubmitGuardianInfoParams = {
|
|
232
|
-
accessToken: string;
|
|
233
|
-
baseUrl?: string;
|
|
234
|
-
guardianName: string;
|
|
235
|
-
guardianContact: string;
|
|
236
|
-
guardianRelationship: string;
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
export type GuardianInfoPayload = {
|
|
240
|
-
guardian_name: string;
|
|
241
|
-
guardian_contact: string;
|
|
242
|
-
guardian_relationship: string;
|
|
208
|
+
guardianVerificationReference?: string;
|
|
209
|
+
selfDeclaredAdult?: boolean;
|
|
243
210
|
};
|
|
244
211
|
|
|
245
212
|
// UI Component Types
|
|
@@ -355,3 +322,133 @@ export type FetchTTSAudioUrlsParams = {
|
|
|
355
322
|
noticeUuid: string;
|
|
356
323
|
language: string;
|
|
357
324
|
};
|
|
325
|
+
|
|
326
|
+
// =============================================================================
|
|
327
|
+
// Guardian Verification Types (aligned with backend API)
|
|
328
|
+
// =============================================================================
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Parameters for initiating guardian verification
|
|
332
|
+
* POST /guardian/initiate-verification
|
|
333
|
+
*/
|
|
334
|
+
export type InitiateGuardianVerificationParams = {
|
|
335
|
+
accessToken: string;
|
|
336
|
+
baseUrl?: string;
|
|
337
|
+
guardianName: string;
|
|
338
|
+
guardianContact: string;
|
|
339
|
+
guardianRelationship: string;
|
|
340
|
+
frontendCallbackUrl?: string;
|
|
341
|
+
metadata?: Record<string, unknown>;
|
|
342
|
+
signal?: AbortSignal;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Response from initiate verification API
|
|
347
|
+
*
|
|
348
|
+
* Two shapes:
|
|
349
|
+
* 1. New verification needed: already_verified=false, includes session_token + digilocker_redirect_url
|
|
350
|
+
* 2. Already verified: already_verified=true, includes verification_reference — skip DigiLocker
|
|
351
|
+
*/
|
|
352
|
+
export type InitiateGuardianVerificationResponse = {
|
|
353
|
+
success: boolean;
|
|
354
|
+
guardian_info_uuid: string;
|
|
355
|
+
already_verified: boolean;
|
|
356
|
+
/** Present only when already_verified=true */
|
|
357
|
+
verification_reference?: string;
|
|
358
|
+
/** Present only when already_verified=false (new flow) */
|
|
359
|
+
session_token?: string;
|
|
360
|
+
/** Present only when already_verified=false (new flow) */
|
|
361
|
+
digilocker_redirect_url?: string;
|
|
362
|
+
/** Present only when already_verified=false (new flow) */
|
|
363
|
+
expires_at?: string;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Parameters for checking verification status
|
|
368
|
+
* POST /guardian/verify-status
|
|
369
|
+
*/
|
|
370
|
+
export type VerifyGuardianStatusParams = {
|
|
371
|
+
accessToken: string;
|
|
372
|
+
baseUrl?: string;
|
|
373
|
+
sessionToken: string;
|
|
374
|
+
signal?: AbortSignal;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Guardian details returned after successful verification
|
|
379
|
+
*/
|
|
380
|
+
export type GuardianVerificationDetails = {
|
|
381
|
+
verified_name: string | null;
|
|
382
|
+
is_guardian_adult: boolean | null;
|
|
383
|
+
verified_at: string;
|
|
384
|
+
verification_reference: string | null;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Response from verify status API
|
|
389
|
+
*/
|
|
390
|
+
export type VerifyGuardianStatusResponse = {
|
|
391
|
+
status: "pending" | "in_progress" | "verified" | "failed" | "expired";
|
|
392
|
+
guardian_info_uuid: string | null;
|
|
393
|
+
verification_reference: string | null;
|
|
394
|
+
guardian_details: GuardianVerificationDetails | null;
|
|
395
|
+
error: string | null;
|
|
396
|
+
error_code: GuardianVerificationErrorCode | null;
|
|
397
|
+
can_retry: boolean;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Error codes from guardian verification
|
|
402
|
+
*/
|
|
403
|
+
export type GuardianVerificationErrorCode =
|
|
404
|
+
| "SESSION_EXPIRED"
|
|
405
|
+
| "GUARDIAN_UNDER_18"
|
|
406
|
+
| "TOKEN_FAILED"
|
|
407
|
+
| "DIGILOCKER_AUTH_FAILED"
|
|
408
|
+
| "NO_AUTH_CODE";
|
|
409
|
+
|
|
410
|
+
// =============================================================================
|
|
411
|
+
// Session Storage Types for redirect flow
|
|
412
|
+
// =============================================================================
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* State persisted during DigiLocker redirect flow.
|
|
416
|
+
* NOTE: accessToken is intentionally excluded — never store tokens in sessionStorage.
|
|
417
|
+
* The host app must provide the token when the component re-mounts.
|
|
418
|
+
*/
|
|
419
|
+
export type PersistedConsentState = {
|
|
420
|
+
flowState: ConsentFlowState;
|
|
421
|
+
sessionToken?: string;
|
|
422
|
+
guardianInfoUuid?: string;
|
|
423
|
+
verificationReference?: string;
|
|
424
|
+
selectedPurposes?: Record<string, boolean>;
|
|
425
|
+
selectedDataElements?: Record<string, boolean>;
|
|
426
|
+
timestamp: string;
|
|
427
|
+
originalUrl: string;
|
|
428
|
+
verificationResult?: "pending" | "verified" | "failed" | "in_progress" | "expired";
|
|
429
|
+
noticeId?: string;
|
|
430
|
+
baseUrl?: string;
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
export type ConsentFlowState =
|
|
434
|
+
| "age-check"
|
|
435
|
+
| "guardian-details"
|
|
436
|
+
| "digilocker-pending"
|
|
437
|
+
| "consent-form"
|
|
438
|
+
| "submitting"
|
|
439
|
+
| "success"
|
|
440
|
+
| "error";
|
|
441
|
+
|
|
442
|
+
// =============================================================================
|
|
443
|
+
// DigiLocker Callback Types
|
|
444
|
+
// =============================================================================
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Props for DigiLockerCallback component
|
|
448
|
+
*/
|
|
449
|
+
export type DigiLockerCallbackProps = {
|
|
450
|
+
accessToken: string;
|
|
451
|
+
baseUrl?: string;
|
|
452
|
+
onSuccess?: (verificationReference: string) => void;
|
|
453
|
+
onError?: (error: Error, errorCode?: GuardianVerificationErrorCode) => void;
|
|
454
|
+
};
|