@tantainnovative/ndpr-toolkit 4.1.0 → 5.0.1
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 +75 -0
- package/README.md +76 -12
- package/dist/chunk-4FXRJH37.js +1 -0
- package/dist/{chunk-UJGNW6CH.js → chunk-ASEUTU45.js} +1 -1
- package/dist/chunk-BRJKIF7E.mjs +1 -0
- package/dist/chunk-CSE36REY.js +6 -0
- package/dist/chunk-DKLJ5DYN.js +1 -0
- package/dist/chunk-FRMVSG4N.mjs +1 -0
- package/dist/chunk-MAD7QYRK.js +1 -0
- package/dist/chunk-NBOJ2KGN.mjs +1 -0
- package/dist/chunk-PQ5IPUJN.mjs +1 -0
- package/dist/chunk-QKXGVT2Q.js +1 -0
- package/dist/chunk-R2ZZMATR.js +1 -0
- package/dist/chunk-R3ZKV2J7.mjs +1 -0
- package/dist/chunk-RRVML7CU.mjs +1 -0
- package/dist/{chunk-6H6IXTHA.mjs → chunk-SBSYHCPK.mjs} +1 -1
- package/dist/chunk-TLIHFGIJ.js +1 -0
- package/dist/{chunk-O4ATGGVK.js → chunk-TVA6D6S4.js} +1 -1
- package/dist/chunk-WPH6CJDL.mjs +6 -0
- package/dist/{chunk-6OPGI27L.mjs → chunk-ZSRO4L3C.mjs} +1 -1
- package/dist/consent.d.mts +59 -21
- package/dist/consent.d.ts +59 -21
- package/dist/consent.js +1 -1
- package/dist/consent.mjs +1 -1
- package/dist/core.d.mts +116 -74
- package/dist/core.d.ts +116 -74
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/cross-border.d.mts +4 -27
- package/dist/cross-border.d.ts +4 -27
- package/dist/cross-border.js +1 -1
- package/dist/cross-border.mjs +1 -1
- package/dist/dsr.d.mts +86 -57
- package/dist/dsr.d.ts +86 -57
- package/dist/dsr.js +1 -1
- package/dist/dsr.mjs +1 -1
- package/dist/headless.d.mts +20 -27
- package/dist/headless.d.ts +20 -27
- package/dist/headless.js +1 -1
- package/dist/headless.mjs +1 -1
- package/dist/hooks.d.mts +20 -27
- package/dist/hooks.d.ts +20 -27
- package/dist/hooks.js +1 -1
- package/dist/hooks.mjs +1 -1
- package/dist/index.d.mts +37 -202
- package/dist/index.d.ts +37 -202
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lawful-basis.d.mts +3 -24
- package/dist/lawful-basis.d.ts +3 -24
- package/dist/lawful-basis.js +1 -1
- package/dist/lawful-basis.mjs +1 -1
- package/dist/presets.d.mts +1 -9
- package/dist/presets.d.ts +1 -9
- package/dist/presets.js +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/ropa-lite.d.mts +2 -11
- package/dist/ropa-lite.d.ts +2 -11
- package/dist/ropa-lite.js +1 -1
- package/dist/ropa-lite.mjs +1 -1
- package/dist/ropa.d.mts +10 -52
- package/dist/ropa.d.ts +10 -52
- package/dist/ropa.js +1 -1
- package/dist/ropa.mjs +1 -1
- package/dist/server.d.mts +20 -100
- package/dist/server.d.ts +20 -100
- package/dist/server.js +1 -1
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-3APT25XO.mjs +0 -1
- package/dist/chunk-45D7AMB3.js +0 -1
- package/dist/chunk-65J4P5ID.js +0 -1
- package/dist/chunk-7Z7NURIA.mjs +0 -1
- package/dist/chunk-D3HHDWBR.js +0 -1
- package/dist/chunk-DSIIEUAD.mjs +0 -1
- package/dist/chunk-H2FDWK4F.js +0 -6
- package/dist/chunk-HLFS3NXG.js +0 -1
- package/dist/chunk-JGY65SHX.mjs +0 -1
- package/dist/chunk-NI54X543.mjs +0 -1
- package/dist/chunk-P5MPUC5F.js +0 -1
- package/dist/chunk-ROOUYQD4.js +0 -1
- package/dist/chunk-UTXDZDYF.mjs +0 -6
- package/dist/chunk-W6VVLHRQ.mjs +0 -1
package/dist/server.d.mts
CHANGED
|
@@ -1019,7 +1019,7 @@ export declare type DSRStatus = 'pending' | 'awaitingVerification' | 'inProgress
|
|
|
1019
1019
|
/**
|
|
1020
1020
|
* Validated DSR submission shape — matches what `<DSRRequestForm onSubmit>`
|
|
1021
1021
|
* emits client-side. Use this as the typed parameter for your server-side
|
|
1022
|
-
* handler after `
|
|
1022
|
+
* handler after `validateDsrSubmissionStructured` returns `valid: true`.
|
|
1023
1023
|
*/
|
|
1024
1024
|
export declare interface DsrSubmissionPayload {
|
|
1025
1025
|
requestType: string;
|
|
@@ -1034,16 +1034,6 @@ export declare interface DsrSubmissionPayload {
|
|
|
1034
1034
|
submittedAt: number;
|
|
1035
1035
|
}
|
|
1036
1036
|
|
|
1037
|
-
/** Result of validating a raw DSR submission payload. */
|
|
1038
|
-
export declare interface DsrSubmissionValidationResult {
|
|
1039
|
-
/** True when the payload conforms to the DSR submission contract. */
|
|
1040
|
-
valid: boolean;
|
|
1041
|
-
/** Field-keyed error messages. Empty when `valid` is true. */
|
|
1042
|
-
errors: Record<string, string>;
|
|
1043
|
-
/** The narrowed, typed payload — only populated when `valid` is true. */
|
|
1044
|
-
data?: DsrSubmissionPayload;
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
1037
|
/**
|
|
1048
1038
|
* Data Subject Rights types aligned with NDPA 2023 Part VI (Sections 34-38)
|
|
1049
1039
|
* and the related provisions in Part V (Section 27 — information to the data subject)
|
|
@@ -1200,21 +1190,9 @@ export declare function exportROPAToCSV(ropa: RecordOfProcessingActivities): str
|
|
|
1200
1190
|
export declare function findUnfilledTokens(rendered: string): string[];
|
|
1201
1191
|
|
|
1202
1192
|
/**
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1205
|
-
*
|
|
1206
|
-
* @deprecated Use `formatDSRRequestStructured()` for typed `{ field, code, message }[]` errors. The legacy string-returning shape will be removed in 5.0.
|
|
1207
|
-
*/
|
|
1208
|
-
export declare function formatDSRRequest(request: DSRRequest): {
|
|
1209
|
-
formattedRequest: Record<string, unknown>;
|
|
1210
|
-
isValid: boolean;
|
|
1211
|
-
validationErrors: string[];
|
|
1212
|
-
};
|
|
1213
|
-
|
|
1214
|
-
/**
|
|
1215
|
-
* Structured-result variant of {@link formatDSRRequest}. Same formatting
|
|
1216
|
-
* output, but `validationErrors` is replaced with a typed `errors` array
|
|
1217
|
-
* of `{ field, code, message }`.
|
|
1193
|
+
* Format a DSR request for display or submission. Returns the formatted
|
|
1194
|
+
* payload plus a typed `errors` array of `{ field, code, message }` for any
|
|
1195
|
+
* required fields missing from the source request.
|
|
1218
1196
|
*
|
|
1219
1197
|
* Codes emitted:
|
|
1220
1198
|
* - `request_id_required`
|
|
@@ -2499,34 +2477,10 @@ export declare const UNFILLED_PREFIX = "\u00ABTODO: ";
|
|
|
2499
2477
|
export declare const UNFILLED_SUFFIX = "\u00BB";
|
|
2500
2478
|
|
|
2501
2479
|
/**
|
|
2502
|
-
* Validates consent
|
|
2503
|
-
*
|
|
2504
|
-
*
|
|
2505
|
-
*
|
|
2506
|
-
*/
|
|
2507
|
-
export declare function validateConsent(settings: ConsentSettings): {
|
|
2508
|
-
valid: boolean;
|
|
2509
|
-
errors: string[];
|
|
2510
|
-
};
|
|
2511
|
-
|
|
2512
|
-
/**
|
|
2513
|
-
* Validates that consent options meet NDPA Section 26 requirements.
|
|
2514
|
-
* Each consent option must specify a purpose for which data will be processed,
|
|
2515
|
-
* as consent must be specific and informed per the Nigeria Data Protection Act.
|
|
2516
|
-
* @param options The consent options to validate
|
|
2517
|
-
* @returns An object containing validation result and any error messages
|
|
2518
|
-
* @deprecated Use `validateConsentOptionsStructured()` for typed `{ field, code, message }[]` errors. The legacy string-returning shape will be removed in 5.0.
|
|
2519
|
-
*/
|
|
2520
|
-
export declare function validateConsentOptions(options: ConsentOption[]): {
|
|
2521
|
-
valid: boolean;
|
|
2522
|
-
errors: string[];
|
|
2523
|
-
};
|
|
2524
|
-
|
|
2525
|
-
/**
|
|
2526
|
-
* Structured-result variant of {@link validateConsentOptions}. Each option
|
|
2527
|
-
* is checked for a non-empty `purpose` (NDPA Section 26). Failing options
|
|
2528
|
-
* are reported with `field: 'options[i].purpose'` so consumers can map
|
|
2529
|
-
* errors back to the originating option index.
|
|
2480
|
+
* Validates consent options against NDPA Section 26 requirements. Each option
|
|
2481
|
+
* is checked for a non-empty `purpose`. Failing options are reported with
|
|
2482
|
+
* `field: 'options[i].purpose'` so consumers can map errors back to the
|
|
2483
|
+
* originating option index.
|
|
2530
2484
|
*
|
|
2531
2485
|
* Codes emitted:
|
|
2532
2486
|
* - `options_required` — empty / missing options array
|
|
@@ -2535,8 +2489,8 @@ export declare function validateConsentOptions(options: ConsentOption[]): {
|
|
|
2535
2489
|
export declare function validateConsentOptionsStructured(options: ConsentOption[]): StructuredValidationResult<ConsentOption[]>;
|
|
2536
2490
|
|
|
2537
2491
|
/**
|
|
2538
|
-
*
|
|
2539
|
-
*
|
|
2492
|
+
* Validates consent settings against NDPA requirements. Returns structured
|
|
2493
|
+
* `{ field, code, message }[]` errors so consumers can switch on `code`
|
|
2540
2494
|
* across locales without regex-matching English strings.
|
|
2541
2495
|
*
|
|
2542
2496
|
* Codes emitted:
|
|
@@ -2559,47 +2513,7 @@ export declare function validateConsentOptionsStructured(options: ConsentOption[
|
|
|
2559
2513
|
*/
|
|
2560
2514
|
export declare function validateConsentStructured(settings: ConsentSettings): StructuredValidationResult<ConsentSettings>;
|
|
2561
2515
|
|
|
2562
|
-
/**
|
|
2563
|
-
* Validate a raw DSR submission payload against the same rules
|
|
2564
|
-
* `<DSRRequestForm />` enforces client-side. Designed to be called from a
|
|
2565
|
-
* server-side handler (Next.js Route Handler, NestJS controller, Express
|
|
2566
|
-
* middleware, Cloudflare Worker) so client and server stay in sync without
|
|
2567
|
-
* the consumer hand-rolling zod / class-validator schemas.
|
|
2568
|
-
*
|
|
2569
|
-
* Defensive — accepts `unknown` and narrows. Safe to call directly on
|
|
2570
|
-
* `await request.json()`.
|
|
2571
|
-
*
|
|
2572
|
-
* @example **Next.js Route Handler**
|
|
2573
|
-
* ```ts
|
|
2574
|
-
* // app/api/dsr/route.ts
|
|
2575
|
-
* import { validateDsrSubmission } from '@tantainnovative/ndpr-toolkit/server';
|
|
2576
|
-
*
|
|
2577
|
-
* export async function POST(req: Request) {
|
|
2578
|
-
* const { valid, errors, data } = validateDsrSubmission(await req.json());
|
|
2579
|
-
* if (!valid) return Response.json({ errors }, { status: 422 });
|
|
2580
|
-
* // `data` is the typed DsrSubmissionPayload
|
|
2581
|
-
* await dsrStore.create(data);
|
|
2582
|
-
* return Response.json({ ok: true }, { status: 201 });
|
|
2583
|
-
* }
|
|
2584
|
-
* ```
|
|
2585
|
-
*
|
|
2586
|
-
* @example **Lock to specific request types**
|
|
2587
|
-
* ```ts
|
|
2588
|
-
* validateDsrSubmission(payload, {
|
|
2589
|
-
* allowedRequestTypes: ['access', 'erasure', 'rectification'],
|
|
2590
|
-
* });
|
|
2591
|
-
* ```
|
|
2592
|
-
*
|
|
2593
|
-
* @example **Skip identity verification (e.g. authenticated session)**
|
|
2594
|
-
* ```ts
|
|
2595
|
-
* validateDsrSubmission(payload, { requireIdentityVerification: false });
|
|
2596
|
-
* ```
|
|
2597
|
-
*
|
|
2598
|
-
* @deprecated Use `validateDsrSubmissionStructured()` for typed `{ field, code, message }[]` errors. The legacy string-returning shape will be removed in 5.0.
|
|
2599
|
-
*/
|
|
2600
|
-
export declare function validateDsrSubmission(payload: unknown, options?: ValidateDsrSubmissionOptions): DsrSubmissionValidationResult;
|
|
2601
|
-
|
|
2602
|
-
/** Options for {@link validateDsrSubmission}. */
|
|
2516
|
+
/** Options for {@link validateDsrSubmissionStructured}. */
|
|
2603
2517
|
export declare interface ValidateDsrSubmissionOptions {
|
|
2604
2518
|
/**
|
|
2605
2519
|
* Whether the data subject is required to provide an identifier
|
|
@@ -2617,9 +2531,15 @@ export declare interface ValidateDsrSubmissionOptions {
|
|
|
2617
2531
|
}
|
|
2618
2532
|
|
|
2619
2533
|
/**
|
|
2620
|
-
*
|
|
2621
|
-
*
|
|
2622
|
-
*
|
|
2534
|
+
* Validate a raw DSR submission payload against the same rules
|
|
2535
|
+
* `<DSRRequestForm />` enforces client-side. Designed to be called from a
|
|
2536
|
+
* server-side handler (Next.js Route Handler, NestJS controller, Express
|
|
2537
|
+
* middleware, Cloudflare Worker) so client and server stay in sync without
|
|
2538
|
+
* the consumer hand-rolling zod / class-validator schemas.
|
|
2539
|
+
*
|
|
2540
|
+
* Defensive — accepts `unknown` and narrows. Safe to call directly on
|
|
2541
|
+
* `await request.json()`. Returns `{ field, code, message }[]` errors so
|
|
2542
|
+
* callers can switch on `code` programmatically across locales.
|
|
2623
2543
|
*
|
|
2624
2544
|
* Codes emitted:
|
|
2625
2545
|
* - `payload_not_object`
|
package/dist/server.d.ts
CHANGED
|
@@ -1019,7 +1019,7 @@ export declare type DSRStatus = 'pending' | 'awaitingVerification' | 'inProgress
|
|
|
1019
1019
|
/**
|
|
1020
1020
|
* Validated DSR submission shape — matches what `<DSRRequestForm onSubmit>`
|
|
1021
1021
|
* emits client-side. Use this as the typed parameter for your server-side
|
|
1022
|
-
* handler after `
|
|
1022
|
+
* handler after `validateDsrSubmissionStructured` returns `valid: true`.
|
|
1023
1023
|
*/
|
|
1024
1024
|
export declare interface DsrSubmissionPayload {
|
|
1025
1025
|
requestType: string;
|
|
@@ -1034,16 +1034,6 @@ export declare interface DsrSubmissionPayload {
|
|
|
1034
1034
|
submittedAt: number;
|
|
1035
1035
|
}
|
|
1036
1036
|
|
|
1037
|
-
/** Result of validating a raw DSR submission payload. */
|
|
1038
|
-
export declare interface DsrSubmissionValidationResult {
|
|
1039
|
-
/** True when the payload conforms to the DSR submission contract. */
|
|
1040
|
-
valid: boolean;
|
|
1041
|
-
/** Field-keyed error messages. Empty when `valid` is true. */
|
|
1042
|
-
errors: Record<string, string>;
|
|
1043
|
-
/** The narrowed, typed payload — only populated when `valid` is true. */
|
|
1044
|
-
data?: DsrSubmissionPayload;
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
1037
|
/**
|
|
1048
1038
|
* Data Subject Rights types aligned with NDPA 2023 Part VI (Sections 34-38)
|
|
1049
1039
|
* and the related provisions in Part V (Section 27 — information to the data subject)
|
|
@@ -1200,21 +1190,9 @@ export declare function exportROPAToCSV(ropa: RecordOfProcessingActivities): str
|
|
|
1200
1190
|
export declare function findUnfilledTokens(rendered: string): string[];
|
|
1201
1191
|
|
|
1202
1192
|
/**
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1205
|
-
*
|
|
1206
|
-
* @deprecated Use `formatDSRRequestStructured()` for typed `{ field, code, message }[]` errors. The legacy string-returning shape will be removed in 5.0.
|
|
1207
|
-
*/
|
|
1208
|
-
export declare function formatDSRRequest(request: DSRRequest): {
|
|
1209
|
-
formattedRequest: Record<string, unknown>;
|
|
1210
|
-
isValid: boolean;
|
|
1211
|
-
validationErrors: string[];
|
|
1212
|
-
};
|
|
1213
|
-
|
|
1214
|
-
/**
|
|
1215
|
-
* Structured-result variant of {@link formatDSRRequest}. Same formatting
|
|
1216
|
-
* output, but `validationErrors` is replaced with a typed `errors` array
|
|
1217
|
-
* of `{ field, code, message }`.
|
|
1193
|
+
* Format a DSR request for display or submission. Returns the formatted
|
|
1194
|
+
* payload plus a typed `errors` array of `{ field, code, message }` for any
|
|
1195
|
+
* required fields missing from the source request.
|
|
1218
1196
|
*
|
|
1219
1197
|
* Codes emitted:
|
|
1220
1198
|
* - `request_id_required`
|
|
@@ -2499,34 +2477,10 @@ export declare const UNFILLED_PREFIX = "\u00ABTODO: ";
|
|
|
2499
2477
|
export declare const UNFILLED_SUFFIX = "\u00BB";
|
|
2500
2478
|
|
|
2501
2479
|
/**
|
|
2502
|
-
* Validates consent
|
|
2503
|
-
*
|
|
2504
|
-
*
|
|
2505
|
-
*
|
|
2506
|
-
*/
|
|
2507
|
-
export declare function validateConsent(settings: ConsentSettings): {
|
|
2508
|
-
valid: boolean;
|
|
2509
|
-
errors: string[];
|
|
2510
|
-
};
|
|
2511
|
-
|
|
2512
|
-
/**
|
|
2513
|
-
* Validates that consent options meet NDPA Section 26 requirements.
|
|
2514
|
-
* Each consent option must specify a purpose for which data will be processed,
|
|
2515
|
-
* as consent must be specific and informed per the Nigeria Data Protection Act.
|
|
2516
|
-
* @param options The consent options to validate
|
|
2517
|
-
* @returns An object containing validation result and any error messages
|
|
2518
|
-
* @deprecated Use `validateConsentOptionsStructured()` for typed `{ field, code, message }[]` errors. The legacy string-returning shape will be removed in 5.0.
|
|
2519
|
-
*/
|
|
2520
|
-
export declare function validateConsentOptions(options: ConsentOption[]): {
|
|
2521
|
-
valid: boolean;
|
|
2522
|
-
errors: string[];
|
|
2523
|
-
};
|
|
2524
|
-
|
|
2525
|
-
/**
|
|
2526
|
-
* Structured-result variant of {@link validateConsentOptions}. Each option
|
|
2527
|
-
* is checked for a non-empty `purpose` (NDPA Section 26). Failing options
|
|
2528
|
-
* are reported with `field: 'options[i].purpose'` so consumers can map
|
|
2529
|
-
* errors back to the originating option index.
|
|
2480
|
+
* Validates consent options against NDPA Section 26 requirements. Each option
|
|
2481
|
+
* is checked for a non-empty `purpose`. Failing options are reported with
|
|
2482
|
+
* `field: 'options[i].purpose'` so consumers can map errors back to the
|
|
2483
|
+
* originating option index.
|
|
2530
2484
|
*
|
|
2531
2485
|
* Codes emitted:
|
|
2532
2486
|
* - `options_required` — empty / missing options array
|
|
@@ -2535,8 +2489,8 @@ export declare function validateConsentOptions(options: ConsentOption[]): {
|
|
|
2535
2489
|
export declare function validateConsentOptionsStructured(options: ConsentOption[]): StructuredValidationResult<ConsentOption[]>;
|
|
2536
2490
|
|
|
2537
2491
|
/**
|
|
2538
|
-
*
|
|
2539
|
-
*
|
|
2492
|
+
* Validates consent settings against NDPA requirements. Returns structured
|
|
2493
|
+
* `{ field, code, message }[]` errors so consumers can switch on `code`
|
|
2540
2494
|
* across locales without regex-matching English strings.
|
|
2541
2495
|
*
|
|
2542
2496
|
* Codes emitted:
|
|
@@ -2559,47 +2513,7 @@ export declare function validateConsentOptionsStructured(options: ConsentOption[
|
|
|
2559
2513
|
*/
|
|
2560
2514
|
export declare function validateConsentStructured(settings: ConsentSettings): StructuredValidationResult<ConsentSettings>;
|
|
2561
2515
|
|
|
2562
|
-
/**
|
|
2563
|
-
* Validate a raw DSR submission payload against the same rules
|
|
2564
|
-
* `<DSRRequestForm />` enforces client-side. Designed to be called from a
|
|
2565
|
-
* server-side handler (Next.js Route Handler, NestJS controller, Express
|
|
2566
|
-
* middleware, Cloudflare Worker) so client and server stay in sync without
|
|
2567
|
-
* the consumer hand-rolling zod / class-validator schemas.
|
|
2568
|
-
*
|
|
2569
|
-
* Defensive — accepts `unknown` and narrows. Safe to call directly on
|
|
2570
|
-
* `await request.json()`.
|
|
2571
|
-
*
|
|
2572
|
-
* @example **Next.js Route Handler**
|
|
2573
|
-
* ```ts
|
|
2574
|
-
* // app/api/dsr/route.ts
|
|
2575
|
-
* import { validateDsrSubmission } from '@tantainnovative/ndpr-toolkit/server';
|
|
2576
|
-
*
|
|
2577
|
-
* export async function POST(req: Request) {
|
|
2578
|
-
* const { valid, errors, data } = validateDsrSubmission(await req.json());
|
|
2579
|
-
* if (!valid) return Response.json({ errors }, { status: 422 });
|
|
2580
|
-
* // `data` is the typed DsrSubmissionPayload
|
|
2581
|
-
* await dsrStore.create(data);
|
|
2582
|
-
* return Response.json({ ok: true }, { status: 201 });
|
|
2583
|
-
* }
|
|
2584
|
-
* ```
|
|
2585
|
-
*
|
|
2586
|
-
* @example **Lock to specific request types**
|
|
2587
|
-
* ```ts
|
|
2588
|
-
* validateDsrSubmission(payload, {
|
|
2589
|
-
* allowedRequestTypes: ['access', 'erasure', 'rectification'],
|
|
2590
|
-
* });
|
|
2591
|
-
* ```
|
|
2592
|
-
*
|
|
2593
|
-
* @example **Skip identity verification (e.g. authenticated session)**
|
|
2594
|
-
* ```ts
|
|
2595
|
-
* validateDsrSubmission(payload, { requireIdentityVerification: false });
|
|
2596
|
-
* ```
|
|
2597
|
-
*
|
|
2598
|
-
* @deprecated Use `validateDsrSubmissionStructured()` for typed `{ field, code, message }[]` errors. The legacy string-returning shape will be removed in 5.0.
|
|
2599
|
-
*/
|
|
2600
|
-
export declare function validateDsrSubmission(payload: unknown, options?: ValidateDsrSubmissionOptions): DsrSubmissionValidationResult;
|
|
2601
|
-
|
|
2602
|
-
/** Options for {@link validateDsrSubmission}. */
|
|
2516
|
+
/** Options for {@link validateDsrSubmissionStructured}. */
|
|
2603
2517
|
export declare interface ValidateDsrSubmissionOptions {
|
|
2604
2518
|
/**
|
|
2605
2519
|
* Whether the data subject is required to provide an identifier
|
|
@@ -2617,9 +2531,15 @@ export declare interface ValidateDsrSubmissionOptions {
|
|
|
2617
2531
|
}
|
|
2618
2532
|
|
|
2619
2533
|
/**
|
|
2620
|
-
*
|
|
2621
|
-
*
|
|
2622
|
-
*
|
|
2534
|
+
* Validate a raw DSR submission payload against the same rules
|
|
2535
|
+
* `<DSRRequestForm />` enforces client-side. Designed to be called from a
|
|
2536
|
+
* server-side handler (Next.js Route Handler, NestJS controller, Express
|
|
2537
|
+
* middleware, Cloudflare Worker) so client and server stay in sync without
|
|
2538
|
+
* the consumer hand-rolling zod / class-validator schemas.
|
|
2539
|
+
*
|
|
2540
|
+
* Defensive — accepts `unknown` and narrows. Safe to call directly on
|
|
2541
|
+
* `await request.json()`. Returns `{ field, code, message }[]` errors so
|
|
2542
|
+
* callers can switch on `code` programmatically across locales.
|
|
2623
2543
|
*
|
|
2624
2544
|
* Codes emitted:
|
|
2625
2545
|
* - `payload_not_object`
|
package/dist/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var chunkR3CU7DTT_js=require('./chunk-R3CU7DTT.js'),chunk6YFPDGNB_js=require('./chunk-6YFPDGNB.js'),chunkNUOHT3LO_js=require('./chunk-NUOHT3LO.js'),chunkJS7SYL5P_js=require('./chunk-JS7SYL5P.js'),chunkRDALAH3Y_js=require('./chunk-RDALAH3Y.js'),chunk3YTAOT5O_js=require('./chunk-3YTAOT5O.js'),chunkD2ZKDQVL_js=require('./chunk-D2ZKDQVL.js'),chunk6LJHLE6G_js=require('./chunk-6LJHLE6G.js'),chunkYFBDJ4FH_js=require('./chunk-YFBDJ4FH.js'),chunkWZYCBW2R_js=require('./chunk-WZYCBW2R.js'),chunk4CVBQC66_js=require('./chunk-4CVBQC66.js'),chunk3IA3KDII_js=require('./chunk-3IA3KDII.js'),chunkC2KEXHRX_js=require('./chunk-C2KEXHRX.js'),
|
|
1
|
+
'use strict';var chunkR3CU7DTT_js=require('./chunk-R3CU7DTT.js'),chunk6YFPDGNB_js=require('./chunk-6YFPDGNB.js'),chunkNUOHT3LO_js=require('./chunk-NUOHT3LO.js'),chunkJS7SYL5P_js=require('./chunk-JS7SYL5P.js'),chunkRDALAH3Y_js=require('./chunk-RDALAH3Y.js'),chunk3YTAOT5O_js=require('./chunk-3YTAOT5O.js'),chunkD2ZKDQVL_js=require('./chunk-D2ZKDQVL.js'),chunk6LJHLE6G_js=require('./chunk-6LJHLE6G.js'),chunkYFBDJ4FH_js=require('./chunk-YFBDJ4FH.js'),chunkWZYCBW2R_js=require('./chunk-WZYCBW2R.js'),chunk4CVBQC66_js=require('./chunk-4CVBQC66.js'),chunk3IA3KDII_js=require('./chunk-3IA3KDII.js'),chunkC2KEXHRX_js=require('./chunk-C2KEXHRX.js'),chunkDKLJ5DYN_js=require('./chunk-DKLJ5DYN.js'),chunkUXUMYP4L_js=require('./chunk-UXUMYP4L.js'),chunkR2ZZMATR_js=require('./chunk-R2ZZMATR.js'),chunkTQZWJGJ2_js=require('./chunk-TQZWJGJ2.js'),chunkZVOIR4QH_js=require('./chunk-ZVOIR4QH.js'),chunkTTMGFC6C_js=require('./chunk-TTMGFC6C.js'),chunkVWED6UTN_js=require('./chunk-VWED6UTN.js');require('./chunk-RFPLZDIO.js');Object.defineProperty(exports,"apiAdapter",{enumerable:true,get:function(){return chunkR3CU7DTT_js.a}});Object.defineProperty(exports,"composeAdapters",{enumerable:true,get:function(){return chunkR3CU7DTT_js.c}});Object.defineProperty(exports,"memoryAdapter",{enumerable:true,get:function(){return chunkR3CU7DTT_js.b}});Object.defineProperty(exports,"arabicLocale",{enumerable:true,get:function(){return chunk6YFPDGNB_js.e}});Object.defineProperty(exports,"frenchLocale",{enumerable:true,get:function(){return chunk6YFPDGNB_js.f}});Object.defineProperty(exports,"hausaLocale",{enumerable:true,get:function(){return chunk6YFPDGNB_js.c}});Object.defineProperty(exports,"igboLocale",{enumerable:true,get:function(){return chunk6YFPDGNB_js.b}});Object.defineProperty(exports,"pidginLocale",{enumerable:true,get:function(){return chunk6YFPDGNB_js.d}});Object.defineProperty(exports,"yorubaLocale",{enumerable:true,get:function(){return chunk6YFPDGNB_js.a}});Object.defineProperty(exports,"ORG_POLICY_TEMPLATE_REGISTRY",{enumerable:true,get:function(){return chunkNUOHT3LO_js.a}});Object.defineProperty(exports,"createOrgTemplate",{enumerable:true,get:function(){return chunkNUOHT3LO_js.b}});Object.defineProperty(exports,"templateContextFor",{enumerable:true,get:function(){return chunkNUOHT3LO_js.b}});Object.defineProperty(exports,"exportDOCX",{enumerable:true,get:function(){return chunkJS7SYL5P_js.d}});Object.defineProperty(exports,"exportHTML",{enumerable:true,get:function(){return chunkJS7SYL5P_js.a}});Object.defineProperty(exports,"exportMarkdown",{enumerable:true,get:function(){return chunkJS7SYL5P_js.b}});Object.defineProperty(exports,"exportPDF",{enumerable:true,get:function(){return chunkJS7SYL5P_js.c}});Object.defineProperty(exports,"getComplianceScore",{enumerable:true,get:function(){return chunkRDALAH3Y_js.a}});Object.defineProperty(exports,"calculateBreachSeverity",{enumerable:true,get:function(){return chunk3YTAOT5O_js.a}});Object.defineProperty(exports,"DEFAULT_POLICY_SECTIONS",{enumerable:true,get:function(){return chunkD2ZKDQVL_js.c}});Object.defineProperty(exports,"DEFAULT_POLICY_VARIABLES",{enumerable:true,get:function(){return chunkD2ZKDQVL_js.d}});Object.defineProperty(exports,"createBusinessPolicyTemplate",{enumerable:true,get:function(){return chunkD2ZKDQVL_js.e}});Object.defineProperty(exports,"findUnfilledTokens",{enumerable:true,get:function(){return chunkD2ZKDQVL_js.a}});Object.defineProperty(exports,"generatePolicyText",{enumerable:true,get:function(){return chunkD2ZKDQVL_js.b}});Object.defineProperty(exports,"DEFAULT_DATA_CATEGORIES",{enumerable:true,get:function(){return chunk6LJHLE6G_js.d}});Object.defineProperty(exports,"UNFILLED_PREFIX",{enumerable:true,get:function(){return chunk6LJHLE6G_js.a}});Object.defineProperty(exports,"UNFILLED_SUFFIX",{enumerable:true,get:function(){return chunk6LJHLE6G_js.b}});Object.defineProperty(exports,"assemblePolicy",{enumerable:true,get:function(){return chunk6LJHLE6G_js.c}});Object.defineProperty(exports,"createDefaultContext",{enumerable:true,get:function(){return chunk6LJHLE6G_js.e}});Object.defineProperty(exports,"evaluatePolicyCompliance",{enumerable:true,get:function(){return chunk6LJHLE6G_js.f}});Object.defineProperty(exports,"assessTransferRisk",{enumerable:true,get:function(){return chunkYFBDJ4FH_js.h}});Object.defineProperty(exports,"getTransferMechanismDescription",{enumerable:true,get:function(){return chunkYFBDJ4FH_js.f}});Object.defineProperty(exports,"isNDPCApprovalRequired",{enumerable:true,get:function(){return chunkYFBDJ4FH_js.e}});Object.defineProperty(exports,"validateTransfer",{enumerable:true,get:function(){return chunkYFBDJ4FH_js.g}});Object.defineProperty(exports,"assessComplianceGaps",{enumerable:true,get:function(){return chunkWZYCBW2R_js.c}});Object.defineProperty(exports,"generateLawfulBasisSummary",{enumerable:true,get:function(){return chunkWZYCBW2R_js.d}});Object.defineProperty(exports,"getLawfulBasisDescription",{enumerable:true,get:function(){return chunkWZYCBW2R_js.b}});Object.defineProperty(exports,"validateProcessingActivity",{enumerable:true,get:function(){return chunkWZYCBW2R_js.a}});Object.defineProperty(exports,"exportROPAToCSV",{enumerable:true,get:function(){return chunk4CVBQC66_js.c}});Object.defineProperty(exports,"generateROPASummary",{enumerable:true,get:function(){return chunk4CVBQC66_js.b}});Object.defineProperty(exports,"identifyComplianceGaps",{enumerable:true,get:function(){return chunk4CVBQC66_js.d}});Object.defineProperty(exports,"validateProcessingRecord",{enumerable:true,get:function(){return chunk4CVBQC66_js.a}});Object.defineProperty(exports,"appendAuditEntry",{enumerable:true,get:function(){return chunk3IA3KDII_js.c}});Object.defineProperty(exports,"createAuditEntry",{enumerable:true,get:function(){return chunk3IA3KDII_js.a}});Object.defineProperty(exports,"getAuditLog",{enumerable:true,get:function(){return chunk3IA3KDII_js.b}});Object.defineProperty(exports,"cookieAdapter",{enumerable:true,get:function(){return chunkC2KEXHRX_js.b}});Object.defineProperty(exports,"sessionStorageAdapter",{enumerable:true,get:function(){return chunkC2KEXHRX_js.a}});Object.defineProperty(exports,"validateConsentOptionsStructured",{enumerable:true,get:function(){return chunkDKLJ5DYN_js.b}});Object.defineProperty(exports,"validateConsentStructured",{enumerable:true,get:function(){return chunkDKLJ5DYN_js.a}});Object.defineProperty(exports,"sanitizeInput",{enumerable:true,get:function(){return chunkUXUMYP4L_js.a}});Object.defineProperty(exports,"formatDSRRequestStructured",{enumerable:true,get:function(){return chunkR2ZZMATR_js.b}});Object.defineProperty(exports,"validateDsrSubmissionStructured",{enumerable:true,get:function(){return chunkR2ZZMATR_js.a}});Object.defineProperty(exports,"assessDPIARisk",{enumerable:true,get:function(){return chunkTQZWJGJ2_js.a}});Object.defineProperty(exports,"LEGAL_DISCLAIMER_LONG",{enumerable:true,get:function(){return chunkZVOIR4QH_js.b}});Object.defineProperty(exports,"LEGAL_DISCLAIMER_SHORT",{enumerable:true,get:function(){return chunkZVOIR4QH_js.a}});Object.defineProperty(exports,"legalDisclaimerBlock",{enumerable:true,get:function(){return chunkZVOIR4QH_js.c}});Object.defineProperty(exports,"defaultLocale",{enumerable:true,get:function(){return chunkTTMGFC6C_js.a}});Object.defineProperty(exports,"mergeLocale",{enumerable:true,get:function(){return chunkTTMGFC6C_js.b}});Object.defineProperty(exports,"localStorageAdapter",{enumerable:true,get:function(){return chunkVWED6UTN_js.a}});
|
package/dist/server.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as apiAdapter,c as composeAdapters,b as memoryAdapter}from'./chunk-7PMPKVY3.mjs';export{e as arabicLocale,f as frenchLocale,c as hausaLocale,b as igboLocale,d as pidginLocale,a as yorubaLocale}from'./chunk-PSPYIRIF.mjs';export{a as ORG_POLICY_TEMPLATE_REGISTRY,b as createOrgTemplate,b as templateContextFor}from'./chunk-CWY2FMIC.mjs';export{d as exportDOCX,a as exportHTML,b as exportMarkdown,c as exportPDF}from'./chunk-IVSNHT24.mjs';export{a as getComplianceScore}from'./chunk-7RBO42IW.mjs';export{a as calculateBreachSeverity}from'./chunk-WTGKZX7J.mjs';export{c as DEFAULT_POLICY_SECTIONS,d as DEFAULT_POLICY_VARIABLES,e as createBusinessPolicyTemplate,a as findUnfilledTokens,b as generatePolicyText}from'./chunk-NBQQ2GN3.mjs';export{d as DEFAULT_DATA_CATEGORIES,a as UNFILLED_PREFIX,b as UNFILLED_SUFFIX,c as assemblePolicy,e as createDefaultContext,f as evaluatePolicyCompliance}from'./chunk-BIJSMSUU.mjs';export{h as assessTransferRisk,f as getTransferMechanismDescription,e as isNDPCApprovalRequired,g as validateTransfer}from'./chunk-7BJXI2HI.mjs';export{c as assessComplianceGaps,d as generateLawfulBasisSummary,b as getLawfulBasisDescription,a as validateProcessingActivity}from'./chunk-LWIKDDSU.mjs';export{c as exportROPAToCSV,b as generateROPASummary,d as identifyComplianceGaps,a as validateProcessingRecord}from'./chunk-XP5PL6K7.mjs';export{c as appendAuditEntry,a as createAuditEntry,b as getAuditLog}from'./chunk-V7UFP6QU.mjs';export{b as cookieAdapter,a as sessionStorageAdapter}from'./chunk-XC3DLYEG.mjs';export{
|
|
1
|
+
export{a as apiAdapter,c as composeAdapters,b as memoryAdapter}from'./chunk-7PMPKVY3.mjs';export{e as arabicLocale,f as frenchLocale,c as hausaLocale,b as igboLocale,d as pidginLocale,a as yorubaLocale}from'./chunk-PSPYIRIF.mjs';export{a as ORG_POLICY_TEMPLATE_REGISTRY,b as createOrgTemplate,b as templateContextFor}from'./chunk-CWY2FMIC.mjs';export{d as exportDOCX,a as exportHTML,b as exportMarkdown,c as exportPDF}from'./chunk-IVSNHT24.mjs';export{a as getComplianceScore}from'./chunk-7RBO42IW.mjs';export{a as calculateBreachSeverity}from'./chunk-WTGKZX7J.mjs';export{c as DEFAULT_POLICY_SECTIONS,d as DEFAULT_POLICY_VARIABLES,e as createBusinessPolicyTemplate,a as findUnfilledTokens,b as generatePolicyText}from'./chunk-NBQQ2GN3.mjs';export{d as DEFAULT_DATA_CATEGORIES,a as UNFILLED_PREFIX,b as UNFILLED_SUFFIX,c as assemblePolicy,e as createDefaultContext,f as evaluatePolicyCompliance}from'./chunk-BIJSMSUU.mjs';export{h as assessTransferRisk,f as getTransferMechanismDescription,e as isNDPCApprovalRequired,g as validateTransfer}from'./chunk-7BJXI2HI.mjs';export{c as assessComplianceGaps,d as generateLawfulBasisSummary,b as getLawfulBasisDescription,a as validateProcessingActivity}from'./chunk-LWIKDDSU.mjs';export{c as exportROPAToCSV,b as generateROPASummary,d as identifyComplianceGaps,a as validateProcessingRecord}from'./chunk-XP5PL6K7.mjs';export{c as appendAuditEntry,a as createAuditEntry,b as getAuditLog}from'./chunk-V7UFP6QU.mjs';export{b as cookieAdapter,a as sessionStorageAdapter}from'./chunk-XC3DLYEG.mjs';export{b as validateConsentOptionsStructured,a as validateConsentStructured}from'./chunk-R3ZKV2J7.mjs';export{a as sanitizeInput}from'./chunk-EWVK45Z3.mjs';export{b as formatDSRRequestStructured,a as validateDsrSubmissionStructured}from'./chunk-RRVML7CU.mjs';export{a as assessDPIARisk}from'./chunk-LRRENTT5.mjs';export{b as LEGAL_DISCLAIMER_LONG,a as LEGAL_DISCLAIMER_SHORT,c as legalDisclaimerBlock}from'./chunk-ITCY2Z66.mjs';export{a as defaultLocale,b as mergeLocale}from'./chunk-V5TZJJWU.mjs';export{a as localStorageAdapter}from'./chunk-DBZSN4WP.mjs';import'./chunk-ZJYULEER.mjs';
|
package/package.json
CHANGED
package/dist/chunk-3APT25XO.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var f=false,l=false;function m(e){if(e.length===0||e.length>254)return false;let t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@"))return false;let d=e.slice(0,t),n=e.slice(t+1);return !(d.length===0||n.length===0||/\s/.test(e)||!n.includes(".")||n.startsWith(".")||n.endsWith("."))}function s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function a(e){return typeof e=="string"&&e.trim().length>0}function c(e){if(!s(e)||!a(e.requestType)||!s(e.dataSubject))return false;let t=e.dataSubject;return !(!a(t.fullName)||!a(t.email)||typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))}function b(e,t={}){var u,o;f||(f=true,console.warn("[ndpr-toolkit] `validateDsrSubmission()` returns a field-keyed `Record<string, string>` of English messages and will be removed in 5.0. Use `validateDsrSubmissionStructured()` for typed `{ field, code, message }[]` errors."));let{requireIdentityVerification:d=true,allowedRequestTypes:n}=t,i={};if(!s(e))return {valid:false,errors:{_root:"Payload must be an object"}};a(e.requestType)?n&&!n.includes(e.requestType)&&(i.requestType=`Request type "${e.requestType}" is not in the allowed set`):i.requestType="Request type is required";let r=e.dataSubject;return s(r)?(a(r.fullName)||(i["dataSubject.fullName"]="Full name is required"),a(r.email)?m(r.email)||(i["dataSubject.email"]="Email address format is invalid"):i["dataSubject.email"]="Email address is required",r.phone!==void 0&&typeof r.phone!="string"&&(i["dataSubject.phone"]="Phone must be a string when provided"),d&&(a(r.identifierType)||(i["dataSubject.identifierType"]="Identifier type is required"),a(r.identifierValue)||(i["dataSubject.identifierValue"]="Identifier value is required"))):i.dataSubject="Data subject information is required",(typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))&&(i.submittedAt="submittedAt must be a finite number (ms timestamp)"),e.additionalInfo!==void 0&&!s(e.additionalInfo)&&(i.additionalInfo="additionalInfo must be an object when provided"),Object.keys(i).length>0?{valid:false,errors:i}:c(e)?{valid:true,errors:{},data:{requestType:e.requestType,dataSubject:{fullName:e.dataSubject.fullName,email:e.dataSubject.email,phone:e.dataSubject.phone,identifierType:(u=e.dataSubject.identifierType)!=null?u:"",identifierValue:(o=e.dataSubject.identifierValue)!=null?o:""},additionalInfo:e.additionalInfo,submittedAt:e.submittedAt}}:{valid:false,errors:{_root:"Payload failed final narrowing"}}}function p(e){var n,i;l||(l=true,console.warn("[ndpr-toolkit] `formatDSRRequest()` returns English error strings in `validationErrors` and will be removed in 5.0. Use `formatDSRRequestStructured()` for typed `{ field, code, message }[]` errors."));let t=[];return e.id||t.push("Request ID is required"),e.type||t.push("Request type is required"),e.status||t.push("Request status is required"),e.createdAt||t.push("Creation timestamp is required"),(n=e.subject)!=null&&n.name||t.push("Data subject name is required"),(i=e.subject)!=null&&i.email||t.push("Data subject email is required"),{formattedRequest:{requestId:e.id,requestType:e.type,status:e.status,createdDate:new Date(e.createdAt).toISOString(),lastUpdated:e.updatedAt?new Date(e.updatedAt).toISOString():void 0,dueDate:e.dueDate?new Date(e.dueDate).toISOString():void 0,dataSubject:e.subject?{name:e.subject.name,email:e.subject.email,phone:e.subject.phone||"Not provided",identifier:{type:e.subject.identifierType||"Not specified",value:e.subject.identifierValue||"Not provided"}}:void 0,additionalInformation:e.additionalInfo||{},verificationStatus:e.verification?`${e.verification.verified?"Verified":"Not verified"}${e.verification.method?` via ${e.verification.method}`:""}`:"Pending verification",attachments:e.attachments?e.attachments.map(r=>({name:r.name,type:r.type,addedOn:new Date(r.addedAt).toISOString()})):[]},isValid:t.length===0,validationErrors:t}}function S(e,t={}){var u,o;let{requireIdentityVerification:d=true,allowedRequestTypes:n}=t,i=[];if(!s(e))return {valid:false,errors:[{field:"_root",code:"payload_not_object",message:"Payload must be an object"}]};a(e.requestType)?n&&!n.includes(e.requestType)&&i.push({field:"requestType",code:"request_type_not_allowed",message:`Request type "${e.requestType}" is not in the allowed set`}):i.push({field:"requestType",code:"request_type_required",message:"Request type is required"});let r=e.dataSubject;return s(r)?(a(r.fullName)||i.push({field:"dataSubject.fullName",code:"full_name_required",message:"Full name is required"}),a(r.email)?m(r.email)||i.push({field:"dataSubject.email",code:"email_invalid_format",message:"Email address format is invalid"}):i.push({field:"dataSubject.email",code:"email_required",message:"Email address is required"}),r.phone!==void 0&&typeof r.phone!="string"&&i.push({field:"dataSubject.phone",code:"phone_invalid_type",message:"Phone must be a string when provided"}),d&&(a(r.identifierType)||i.push({field:"dataSubject.identifierType",code:"identifier_type_required",message:"Identifier type is required"}),a(r.identifierValue)||i.push({field:"dataSubject.identifierValue",code:"identifier_value_required",message:"Identifier value is required"}))):i.push({field:"dataSubject",code:"data_subject_required",message:"Data subject information is required"}),(typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))&&i.push({field:"submittedAt",code:"submitted_at_invalid",message:"submittedAt must be a finite number (ms timestamp)"}),e.additionalInfo!==void 0&&!s(e.additionalInfo)&&i.push({field:"additionalInfo",code:"additional_info_invalid_type",message:"additionalInfo must be an object when provided"}),i.length>0?{valid:false,errors:i}:c(e)?{valid:true,errors:[],data:{requestType:e.requestType,dataSubject:{fullName:e.dataSubject.fullName,email:e.dataSubject.email,phone:e.dataSubject.phone,identifierType:(u=e.dataSubject.identifierType)!=null?u:"",identifierValue:(o=e.dataSubject.identifierValue)!=null?o:""},additionalInfo:e.additionalInfo,submittedAt:e.submittedAt}}:{valid:false,errors:[{field:"_root",code:"payload_final_narrowing_failed",message:"Payload failed final narrowing"}]}}function g(e){var n,i;let t=[];e.id||t.push({field:"id",code:"request_id_required",message:"Request ID is required"}),e.type||t.push({field:"type",code:"request_type_required",message:"Request type is required"}),e.status||t.push({field:"status",code:"request_status_required",message:"Request status is required"}),e.createdAt||t.push({field:"createdAt",code:"created_at_required",message:"Creation timestamp is required"}),(n=e.subject)!=null&&n.name||t.push({field:"subject.name",code:"subject_name_required",message:"Data subject name is required"}),(i=e.subject)!=null&&i.email||t.push({field:"subject.email",code:"subject_email_required",message:"Data subject email is required"});let d={requestId:e.id,requestType:e.type,status:e.status,createdDate:new Date(e.createdAt).toISOString(),lastUpdated:e.updatedAt?new Date(e.updatedAt).toISOString():void 0,dueDate:e.dueDate?new Date(e.dueDate).toISOString():void 0,dataSubject:e.subject?{name:e.subject.name,email:e.subject.email,phone:e.subject.phone||"Not provided",identifier:{type:e.subject.identifierType||"Not specified",value:e.subject.identifierValue||"Not provided"}}:void 0,additionalInformation:e.additionalInfo||{},verificationStatus:e.verification?`${e.verification.verified?"Verified":"Not verified"}${e.verification.method?` via ${e.verification.method}`:""}`:"Pending verification",attachments:e.attachments?e.attachments.map(r=>({name:r.name,type:r.type,addedOn:new Date(r.addedAt).toISOString()})):[]};return t.length>0?{valid:false,errors:t,formattedRequest:d}:{valid:true,errors:[],formattedRequest:d,data:e}}export{b as a,p as b,S as c,g as d};
|
package/dist/chunk-45D7AMB3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var f=false,l=false;function m(e){if(e.length===0||e.length>254)return false;let t=e.indexOf("@");if(t<=0||t!==e.lastIndexOf("@"))return false;let d=e.slice(0,t),n=e.slice(t+1);return !(d.length===0||n.length===0||/\s/.test(e)||!n.includes(".")||n.startsWith(".")||n.endsWith("."))}function s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function a(e){return typeof e=="string"&&e.trim().length>0}function c(e){if(!s(e)||!a(e.requestType)||!s(e.dataSubject))return false;let t=e.dataSubject;return !(!a(t.fullName)||!a(t.email)||typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))}function b(e,t={}){var u,o;f||(f=true,console.warn("[ndpr-toolkit] `validateDsrSubmission()` returns a field-keyed `Record<string, string>` of English messages and will be removed in 5.0. Use `validateDsrSubmissionStructured()` for typed `{ field, code, message }[]` errors."));let{requireIdentityVerification:d=true,allowedRequestTypes:n}=t,i={};if(!s(e))return {valid:false,errors:{_root:"Payload must be an object"}};a(e.requestType)?n&&!n.includes(e.requestType)&&(i.requestType=`Request type "${e.requestType}" is not in the allowed set`):i.requestType="Request type is required";let r=e.dataSubject;return s(r)?(a(r.fullName)||(i["dataSubject.fullName"]="Full name is required"),a(r.email)?m(r.email)||(i["dataSubject.email"]="Email address format is invalid"):i["dataSubject.email"]="Email address is required",r.phone!==void 0&&typeof r.phone!="string"&&(i["dataSubject.phone"]="Phone must be a string when provided"),d&&(a(r.identifierType)||(i["dataSubject.identifierType"]="Identifier type is required"),a(r.identifierValue)||(i["dataSubject.identifierValue"]="Identifier value is required"))):i.dataSubject="Data subject information is required",(typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))&&(i.submittedAt="submittedAt must be a finite number (ms timestamp)"),e.additionalInfo!==void 0&&!s(e.additionalInfo)&&(i.additionalInfo="additionalInfo must be an object when provided"),Object.keys(i).length>0?{valid:false,errors:i}:c(e)?{valid:true,errors:{},data:{requestType:e.requestType,dataSubject:{fullName:e.dataSubject.fullName,email:e.dataSubject.email,phone:e.dataSubject.phone,identifierType:(u=e.dataSubject.identifierType)!=null?u:"",identifierValue:(o=e.dataSubject.identifierValue)!=null?o:""},additionalInfo:e.additionalInfo,submittedAt:e.submittedAt}}:{valid:false,errors:{_root:"Payload failed final narrowing"}}}function p(e){var n,i;l||(l=true,console.warn("[ndpr-toolkit] `formatDSRRequest()` returns English error strings in `validationErrors` and will be removed in 5.0. Use `formatDSRRequestStructured()` for typed `{ field, code, message }[]` errors."));let t=[];return e.id||t.push("Request ID is required"),e.type||t.push("Request type is required"),e.status||t.push("Request status is required"),e.createdAt||t.push("Creation timestamp is required"),(n=e.subject)!=null&&n.name||t.push("Data subject name is required"),(i=e.subject)!=null&&i.email||t.push("Data subject email is required"),{formattedRequest:{requestId:e.id,requestType:e.type,status:e.status,createdDate:new Date(e.createdAt).toISOString(),lastUpdated:e.updatedAt?new Date(e.updatedAt).toISOString():void 0,dueDate:e.dueDate?new Date(e.dueDate).toISOString():void 0,dataSubject:e.subject?{name:e.subject.name,email:e.subject.email,phone:e.subject.phone||"Not provided",identifier:{type:e.subject.identifierType||"Not specified",value:e.subject.identifierValue||"Not provided"}}:void 0,additionalInformation:e.additionalInfo||{},verificationStatus:e.verification?`${e.verification.verified?"Verified":"Not verified"}${e.verification.method?` via ${e.verification.method}`:""}`:"Pending verification",attachments:e.attachments?e.attachments.map(r=>({name:r.name,type:r.type,addedOn:new Date(r.addedAt).toISOString()})):[]},isValid:t.length===0,validationErrors:t}}function S(e,t={}){var u,o;let{requireIdentityVerification:d=true,allowedRequestTypes:n}=t,i=[];if(!s(e))return {valid:false,errors:[{field:"_root",code:"payload_not_object",message:"Payload must be an object"}]};a(e.requestType)?n&&!n.includes(e.requestType)&&i.push({field:"requestType",code:"request_type_not_allowed",message:`Request type "${e.requestType}" is not in the allowed set`}):i.push({field:"requestType",code:"request_type_required",message:"Request type is required"});let r=e.dataSubject;return s(r)?(a(r.fullName)||i.push({field:"dataSubject.fullName",code:"full_name_required",message:"Full name is required"}),a(r.email)?m(r.email)||i.push({field:"dataSubject.email",code:"email_invalid_format",message:"Email address format is invalid"}):i.push({field:"dataSubject.email",code:"email_required",message:"Email address is required"}),r.phone!==void 0&&typeof r.phone!="string"&&i.push({field:"dataSubject.phone",code:"phone_invalid_type",message:"Phone must be a string when provided"}),d&&(a(r.identifierType)||i.push({field:"dataSubject.identifierType",code:"identifier_type_required",message:"Identifier type is required"}),a(r.identifierValue)||i.push({field:"dataSubject.identifierValue",code:"identifier_value_required",message:"Identifier value is required"}))):i.push({field:"dataSubject",code:"data_subject_required",message:"Data subject information is required"}),(typeof e.submittedAt!="number"||!Number.isFinite(e.submittedAt))&&i.push({field:"submittedAt",code:"submitted_at_invalid",message:"submittedAt must be a finite number (ms timestamp)"}),e.additionalInfo!==void 0&&!s(e.additionalInfo)&&i.push({field:"additionalInfo",code:"additional_info_invalid_type",message:"additionalInfo must be an object when provided"}),i.length>0?{valid:false,errors:i}:c(e)?{valid:true,errors:[],data:{requestType:e.requestType,dataSubject:{fullName:e.dataSubject.fullName,email:e.dataSubject.email,phone:e.dataSubject.phone,identifierType:(u=e.dataSubject.identifierType)!=null?u:"",identifierValue:(o=e.dataSubject.identifierValue)!=null?o:""},additionalInfo:e.additionalInfo,submittedAt:e.submittedAt}}:{valid:false,errors:[{field:"_root",code:"payload_final_narrowing_failed",message:"Payload failed final narrowing"}]}}function g(e){var n,i;let t=[];e.id||t.push({field:"id",code:"request_id_required",message:"Request ID is required"}),e.type||t.push({field:"type",code:"request_type_required",message:"Request type is required"}),e.status||t.push({field:"status",code:"request_status_required",message:"Request status is required"}),e.createdAt||t.push({field:"createdAt",code:"created_at_required",message:"Creation timestamp is required"}),(n=e.subject)!=null&&n.name||t.push({field:"subject.name",code:"subject_name_required",message:"Data subject name is required"}),(i=e.subject)!=null&&i.email||t.push({field:"subject.email",code:"subject_email_required",message:"Data subject email is required"});let d={requestId:e.id,requestType:e.type,status:e.status,createdDate:new Date(e.createdAt).toISOString(),lastUpdated:e.updatedAt?new Date(e.updatedAt).toISOString():void 0,dueDate:e.dueDate?new Date(e.dueDate).toISOString():void 0,dataSubject:e.subject?{name:e.subject.name,email:e.subject.email,phone:e.subject.phone||"Not provided",identifier:{type:e.subject.identifierType||"Not specified",value:e.subject.identifierValue||"Not provided"}}:void 0,additionalInformation:e.additionalInfo||{},verificationStatus:e.verification?`${e.verification.verified?"Verified":"Not verified"}${e.verification.method?` via ${e.verification.method}`:""}`:"Pending verification",attachments:e.attachments?e.attachments.map(r=>({name:r.name,type:r.type,addedOn:new Date(r.addedAt).toISOString()})):[]};return t.length>0?{valid:false,errors:t,formattedRequest:d}:{valid:true,errors:[],formattedRequest:d,data:e}}exports.a=b;exports.b=p;exports.c=S;exports.d=g;
|
package/dist/chunk-65J4P5ID.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkWZYCBW2R_js=require('./chunk-WZYCBW2R.js'),chunkAME4HJR4_js=require('./chunk-AME4HJR4.js'),chunkYDKWD6MQ_js=require('./chunk-YDKWD6MQ.js'),chunkRFPLZDIO_js=require('./chunk-RFPLZDIO.js'),react=require('react'),jsxRuntime=require('react/jsx-runtime');var W={name:"",description:"",lawfulBasis:"consent",lawfulBasisJustification:"",dataCategories:"",involvesSensitiveData:false,sensitiveDataCondition:"",dataSubjectCategories:"",purposes:"",retentionPeriod:"",retentionJustification:"",recipients:"",crossBorderTransfer:false,reviewDate:"",liaPurposeTest:"",liaNecessityTest:"",liaBalancingTest:"",liaSafeguards:"",liaConclusion:""},de=[{value:"consent",label:"Consent"},{value:"contract",label:"Contract"},{value:"legal_obligation",label:"Legal Obligation"},{value:"vital_interests",label:"Vital Interests"},{value:"public_interest",label:"Public Interest"},{value:"legitimate_interests",label:"Legitimate Interests"}],oe=[{value:"explicit_consent",label:"Explicit Consent"},{value:"employment_law",label:"Employment Law"},{value:"vital_interests_incapable",label:"Vital Interests (Incapable)"},{value:"nonprofit_legitimate",label:"Nonprofit Legitimate Activities"},{value:"publicly_available",label:"Publicly Available Data"},{value:"legal_claims",label:"Legal Claims"},{value:"substantial_public_interest",label:"Substantial Public Interest"},{value:"health_purposes",label:"Health Purposes"},{value:"public_health",label:"Public Health"},{value:"archiving_research",label:"Archiving / Research"}],Le={active:"ndpr-badge ndpr-badge--success",inactive:"ndpr-badge ndpr-badge--neutral",under_review:"ndpr-badge ndpr-badge--warning",archived:"ndpr-badge ndpr-badge--destructive"},Te={active:"Active",inactive:"Inactive",under_review:"Under Review",archived:"Archived"},Fe={consent:"ndpr-badge ndpr-badge--info",contract:"ndpr-badge ndpr-badge--info",legal_obligation:"ndpr-badge ndpr-badge--info",vital_interests:"ndpr-badge ndpr-badge--destructive",public_interest:"ndpr-badge ndpr-badge--warning",legitimate_interests:"bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-200"},Ie={consent:"Consent",contract:"Contract",legal_obligation:"Legal Obligation",vital_interests:"Vital Interests",public_interest:"Public Interest",legitimate_interests:"Legitimate Interests"},$e=({activities:g,onAddActivity:f,onUpdateActivity:b,onArchiveActivity:h,onAdd:_,onUpdate:w,onArchive:x,title:R,description:N,className:se="",buttonClassName:C="",showSummary:pe=true,showComplianceGaps:ue=true,classNames:i,unstyled:l})=>{var ie,re;let Y=react.useRef(false);react.useEffect(()=>{if(process.env.NODE_ENV==="production"||Y.current)return;let e=[];f!==void 0&&_===void 0&&e.push("onAddActivity -> onAdd"),b!==void 0&&w===void 0&&e.push("onUpdateActivity -> onUpdate"),h!==void 0&&x===void 0&&e.push("onArchiveActivity -> onArchive"),e.length>0&&(Y.current=true,console.warn(`[ndpr-toolkit/lawful-basis] Deprecated callback prop name(s): ${e.join(", ")}. Will be removed in 5.0.`));},[f,b,h,_,w,x]);let z=chunkYDKWD6MQ_js.c(),ce=(ie=R!=null?R:z.lawfulBasis.title)!=null?ie:"Lawful Basis Tracker",ge=(re=N!=null?N:z.lawfulBasis.description)!=null?re:"Document and track the lawful basis for each processing activity as required by NDPA 2023 Section 25.",[S,D]=react.useState("list"),[a,A]=react.useState(W),[m,O]=react.useState(null),[$,ve]=react.useState(null),[T,me]=react.useState("all"),[F,fe]=react.useState("all"),[I,be]=react.useState(""),[c,P]=react.useState([]),K=react.useMemo(()=>{let e=[...g];if(T!=="all"&&(e=e.filter(o=>o.status===T)),F!=="all"&&(e=e.filter(o=>o.lawfulBasis===F)),I){let o=I.toLowerCase();e=e.filter(p=>p.name.toLowerCase().includes(o)||p.description.toLowerCase().includes(o)||p.purposes.some(V=>V.toLowerCase().includes(o)));}return e.sort((o,p)=>p.updatedAt-o.updatedAt),e},[g,T,F,I]),k=react.useCallback(e=>new Date(e).toLocaleDateString(),[]),j=react.useMemo(()=>chunkWZYCBW2R_js.d(g),[g]),B=react.useMemo(()=>chunkWZYCBW2R_js.c(g),[g]),L=react.useCallback(e=>e.split(",").map(o=>o.trim()).filter(o=>o.length>0),[]),he=react.useCallback(()=>{A(W),O(null),P([]),D("form");},[]),Q=react.useCallback(e=>{A({name:e.name,description:e.description,lawfulBasis:e.lawfulBasis,lawfulBasisJustification:e.lawfulBasisJustification,dataCategories:e.dataCategories.join(", "),involvesSensitiveData:e.involvesSensitiveData,sensitiveDataCondition:e.sensitiveDataCondition||"",dataSubjectCategories:e.dataSubjectCategories.join(", "),purposes:e.purposes.join(", "),retentionPeriod:e.retentionPeriod,retentionJustification:e.retentionJustification||"",recipients:(e.recipients||[]).join(", "),crossBorderTransfer:e.crossBorderTransfer,reviewDate:e.reviewDate?new Date(e.reviewDate).toISOString().split("T")[0]:"",liaPurposeTest:"",liaNecessityTest:"",liaBalancingTest:"",liaSafeguards:"",liaConclusion:""}),O(e.id),P([]),D("form");},[]),_e=react.useCallback(()=>{let e={name:a.name,description:a.description,lawfulBasis:a.lawfulBasis,lawfulBasisJustification:a.lawfulBasisJustification,dataCategories:L(a.dataCategories),involvesSensitiveData:a.involvesSensitiveData,sensitiveDataCondition:a.sensitiveDataCondition||void 0,dataSubjectCategories:L(a.dataSubjectCategories),purposes:L(a.purposes),retentionPeriod:a.retentionPeriod,retentionJustification:a.retentionJustification||void 0,recipients:a.recipients?L(a.recipients):void 0,crossBorderTransfer:a.crossBorderTransfer,reviewDate:a.reviewDate?new Date(a.reviewDate).getTime():void 0,status:"active"},o=chunkRFPLZDIO_js.b(chunkRFPLZDIO_js.a({},e),{id:m||"temp",createdAt:Date.now(),updatedAt:Date.now()}),p=chunkWZYCBW2R_js.a(o);if(!p.isValid){P(p.errors);return}m?(w==null||w(m,e),b==null||b(m,e)):(_==null||_(e),f==null||f(e)),A(W),O(null),P([]),D("list");},[a,m,b,f,w,_,L]),X=react.useCallback(e=>{x==null||x(e),h==null||h(e);},[h,x]),we=react.useCallback(e=>{ve(e),D("detail");},[]),n=react.useMemo(()=>$?g.find(e=>e.id===$):null,[g,$]),Z=react.useCallback(e=>jsxRuntime.jsx("span",{className:chunkAME4HJR4_js.a(`px-2 py-1 rounded text-xs font-medium ${Le[e]}`,i==null?void 0:i.statusBadge,l),children:Te[e]}),[i==null?void 0:i.statusBadge,l]),U=react.useCallback(e=>jsxRuntime.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${Fe[e]}`,children:Ie[e]}),[]),ee=react.useCallback(e=>e.dpoApproval?e.dpoApproval.approved?jsxRuntime.jsx("span",{className:"ndpr-badge ndpr-badge--success",children:"Approved"}):jsxRuntime.jsx("span",{className:"ndpr-badge ndpr-badge--warning",children:"Pending Approval"}):jsxRuntime.jsx("span",{className:"px-2 py-1 rounded text-xs font-medium bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400",children:"No DPO Review"}),[]),xe=()=>jsxRuntime.jsxs("div",{"data-ndpr-component":"lawful-basis-tracker",className:chunkAME4HJR4_js.a("grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",i==null?void 0:i.summary,l),role:"status","aria-label":"Compliance summary",children:[jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("ndpr-alert ndpr-alert--info",i==null?void 0:i.summaryCard,l),children:[jsxRuntime.jsx("p",{className:"ndpr-stat__value ndpr-text-info",children:j.totalActivities}),jsxRuntime.jsx("p",{className:"text-sm ndpr-text-info",children:"Total Activities"})]}),jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("bg-orange-50 dark:bg-orange-900/20 p-4 rounded-lg",i==null?void 0:i.summaryCard,l),children:[jsxRuntime.jsx("p",{className:"ndpr-stat__value ndpr-text-warning",children:j.sensitiveDataActivities}),jsxRuntime.jsx("p",{className:"text-sm ndpr-text-warning",children:"Sensitive Data"})]}),jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("ndpr-alert ndpr-alert--info",i==null?void 0:i.summaryCard,l),children:[jsxRuntime.jsx("p",{className:"ndpr-stat__value ndpr-text-info",children:j.crossBorderActivities}),jsxRuntime.jsx("p",{className:"text-sm ndpr-text-info",children:"Cross-Border Transfers"})]}),jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("ndpr-alert ndpr-alert--destructive",i==null?void 0:i.summaryCard,l),children:[jsxRuntime.jsx("p",{className:"ndpr-stat__value ndpr-text-destructive",children:j.activitiesWithoutApproval.length}),jsxRuntime.jsx("p",{className:"text-sm ndpr-text-destructive",children:"Pending Approval"})]})]}),G=react.useMemo(()=>B.filter(e=>e.severity==="high"),[B]),q=react.useMemo(()=>B.filter(e=>e.severity==="medium"),[B]),Ce=()=>B.length===0?jsxRuntime.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 p-4 rounded-lg mb-6",role:"status","aria-label":"No compliance gaps",children:[jsxRuntime.jsx("p",{className:"text-sm ndpr-text-success font-medium",children:"No compliance gaps detected."}),jsxRuntime.jsx("p",{className:"text-xs ndpr-text-success mt-1",children:"All processing activities appear to be properly documented."})]}):jsxRuntime.jsxs("div",{className:"mb-6",role:"status","aria-label":`${B.length} compliance gaps detected`,children:[G.length>0&&jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("bg-red-50 dark:bg-red-900/20 p-4 rounded-lg mb-3",i==null?void 0:i.gapAlert,l),children:[jsxRuntime.jsxs("p",{className:"text-sm ndpr-text-destructive font-medium mb-2",children:["High Priority (",G.length,")"]}),jsxRuntime.jsx("ul",{className:"space-y-1",children:G.map((e,o)=>jsxRuntime.jsx("li",{className:"text-xs ndpr-text-destructive",children:e.description},o))})]}),q.length>0&&jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("ndpr-alert ndpr-alert--warning",i==null?void 0:i.gapAlert,l),children:[jsxRuntime.jsxs("p",{className:"text-sm ndpr-text-warning font-medium mb-2",children:["Medium Priority (",q.length,")"]}),jsxRuntime.jsx("ul",{className:"space-y-1",children:q.map((e,o)=>jsxRuntime.jsx("li",{className:"text-xs ndpr-text-warning",children:e.description},o))})]})]}),te=react.useCallback(()=>{D("list"),P([]);},[]),De=react.useCallback(()=>{D("list");},[]),s=react.useCallback((e,o)=>{A(p=>chunkRFPLZDIO_js.b(chunkRFPLZDIO_js.a({},p),{[e]:o}));},[]),Be=react.useCallback(e=>{A(o=>chunkRFPLZDIO_js.b(chunkRFPLZDIO_js.a({},o),{involvesSensitiveData:e,sensitiveDataCondition:e?o.sensitiveDataCondition:""}));},[]),ye=()=>jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("",i==null?void 0:i.form,l),children:[jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a("flex justify-between items-center mb-4",i==null?void 0:i.header,l),children:[jsxRuntime.jsx("h3",{className:"ndpr-section-heading",children:m?"Edit Processing Activity":"New Processing Activity"}),jsxRuntime.jsx("button",{onClick:te,className:`px-4 py-2 ndpr-text-muted bg-gray-100 dark:bg-gray-700 rounded hover:bg-gray-200 dark:hover:bg-gray-600 ${C}`,children:"Cancel"})]}),c.length>0&&jsxRuntime.jsxs("div",{id:"form-errors",className:"bg-red-50 dark:bg-red-900/20 p-4 rounded-lg mb-4",role:"alert",children:[jsxRuntime.jsx("p",{className:"text-sm ndpr-text-destructive font-medium mb-2",children:"Please correct the following errors:"}),jsxRuntime.jsx("ul",{className:"list-disc list-inside space-y-1",children:c.map((e,o)=>jsxRuntime.jsx("li",{className:"text-xs ndpr-text-destructive",children:e},o))})]}),jsxRuntime.jsxs("div",{className:"ndpr-form-section",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"activityName",className:"ndpr-form-field__label",children:"Activity Name *"}),jsxRuntime.jsx("input",{type:"text",id:"activityName",value:a.name,onChange:e=>s("name",e.target.value),placeholder:"e.g., Customer Account Management","aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"activityDescription",className:"ndpr-form-field__label",children:"Description *"}),jsxRuntime.jsx("textarea",{id:"activityDescription",value:a.description,onChange:e=>s("description",e.target.value),placeholder:"Describe what processing is performed...",rows:3,"aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"lawfulBasis",className:"ndpr-form-field__label",children:"Lawful Basis (NDPA Section 25) *"}),jsxRuntime.jsx("select",{id:"lawfulBasis",value:a.lawfulBasis,onChange:e=>s("lawfulBasis",e.target.value),"aria-required":"true",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.select,l),children:de.map(e=>jsxRuntime.jsx("option",{value:e.value,children:e.label},e.value))}),jsxRuntime.jsx("p",{className:"mt-1 text-xs ndpr-text-muted",children:chunkWZYCBW2R_js.b(a.lawfulBasis)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"justification",className:"ndpr-form-field__label",children:"Lawful Basis Justification *"}),jsxRuntime.jsx("textarea",{id:"justification",value:a.lawfulBasisJustification,onChange:e=>s("lawfulBasisJustification",e.target.value),placeholder:"Document why this lawful basis applies to this processing activity...",rows:3,"aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),a.lawfulBasis==="legitimate_interests"&&jsxRuntime.jsxs("div",{className:"border border-indigo-200 dark:border-indigo-800 rounded-lg p-4 bg-indigo-50 dark:bg-indigo-900/20",children:[jsxRuntime.jsx("h4",{className:"text-sm font-semibold text-indigo-800 dark:text-indigo-200 mb-3",children:"Legitimate Interest Assessment (LIA)"}),jsxRuntime.jsx("p",{className:"text-xs text-indigo-600 dark:text-indigo-300 mb-4",children:"NDPA Section 25(1)(f) requires a balancing test when relying on legitimate interests."}),jsxRuntime.jsxs("div",{className:"ndpr-form-section",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"liaPurpose",className:"ndpr-form-field__label",children:"Purpose Test"}),jsxRuntime.jsx("textarea",{id:"liaPurpose",value:a.liaPurposeTest,onChange:e=>s("liaPurposeTest",e.target.value),placeholder:"Describe the legitimate interest being pursued...",rows:2,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"liaNecessity",className:"ndpr-form-field__label",children:"Necessity Test"}),jsxRuntime.jsx("textarea",{id:"liaNecessity",value:a.liaNecessityTest,onChange:e=>s("liaNecessityTest",e.target.value),placeholder:"Explain why this processing is necessary for the stated purpose...",rows:2,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"liaBalancing",className:"ndpr-form-field__label",children:"Balancing Test"}),jsxRuntime.jsx("textarea",{id:"liaBalancing",value:a.liaBalancingTest,onChange:e=>s("liaBalancingTest",e.target.value),placeholder:"Assess the impact on data subjects' rights and interests...",rows:2,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"liaSafeguards",className:"ndpr-form-field__label",children:"Safeguards"}),jsxRuntime.jsx("input",{type:"text",id:"liaSafeguards",value:a.liaSafeguards,onChange:e=>s("liaSafeguards",e.target.value),placeholder:"List safeguards (comma-separated)...",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"liaConclusion",className:"ndpr-form-field__label",children:"Conclusion"}),jsxRuntime.jsx("textarea",{id:"liaConclusion",value:a.liaConclusion,onChange:e=>s("liaConclusion",e.target.value),placeholder:"State your overall conclusion...",rows:2,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"dataCategories",className:"ndpr-form-field__label",children:"Data Categories *"}),jsxRuntime.jsx("input",{type:"text",id:"dataCategories",value:a.dataCategories,onChange:e=>s("dataCategories",e.target.value),placeholder:"e.g., Name, Email, Phone Number (comma-separated)","aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsxs("label",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:a.involvesSensitiveData,onChange:e=>Be(e.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-[rgb(var(--ndpr-primary))] focus:ring-[rgb(var(--ndpr-ring))]"}),jsxRuntime.jsx("span",{className:"ndpr-text-sm ndpr-font-medium",children:"Involves Sensitive Personal Data (NDPA Section 27)"})]})}),a.involvesSensitiveData&&jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"sensitiveCondition",className:"ndpr-form-field__label",children:"Sensitive Data Condition (NDPA Section 27) *"}),jsxRuntime.jsxs("select",{id:"sensitiveCondition",value:a.sensitiveDataCondition,onChange:e=>s("sensitiveDataCondition",e.target.value),"aria-required":"true",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.select,l),children:[jsxRuntime.jsx("option",{value:"",children:"Select a condition..."}),oe.map(e=>jsxRuntime.jsx("option",{value:e.value,children:e.label},e.value))]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"dataSubjectCategories",className:"ndpr-form-field__label",children:"Data Subject Categories *"}),jsxRuntime.jsx("input",{type:"text",id:"dataSubjectCategories",value:a.dataSubjectCategories,onChange:e=>s("dataSubjectCategories",e.target.value),placeholder:"e.g., Customers, Employees, Vendors (comma-separated)","aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"purposes",className:"ndpr-form-field__label",children:"Processing Purposes *"}),jsxRuntime.jsx("input",{type:"text",id:"purposes",value:a.purposes,onChange:e=>s("purposes",e.target.value),placeholder:"e.g., Account management, Service delivery (comma-separated)","aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{className:"ndpr-form-grid ndpr-form-grid--2",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"retentionPeriod",className:"ndpr-form-field__label",children:"Retention Period *"}),jsxRuntime.jsx("input",{type:"text",id:"retentionPeriod",value:a.retentionPeriod,onChange:e=>s("retentionPeriod",e.target.value),placeholder:"e.g., 3 years after account closure","aria-required":"true","aria-describedby":c.length>0?"form-errors":void 0,className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"retentionJustification",className:"ndpr-form-field__label",children:"Retention Justification"}),jsxRuntime.jsx("input",{type:"text",id:"retentionJustification",value:a.retentionJustification,onChange:e=>s("retentionJustification",e.target.value),placeholder:"Reason for the retention period",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"recipients",className:"ndpr-form-field__label",children:"Recipients"}),jsxRuntime.jsx("input",{type:"text",id:"recipients",value:a.recipients,onChange:e=>s("recipients",e.target.value),placeholder:"e.g., Payment processor, Cloud provider (comma-separated)",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsx("div",{children:jsxRuntime.jsxs("label",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx("input",{type:"checkbox",checked:a.crossBorderTransfer,onChange:e=>s("crossBorderTransfer",e.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-[rgb(var(--ndpr-primary))] focus:ring-[rgb(var(--ndpr-ring))]"}),jsxRuntime.jsx("span",{className:"ndpr-text-sm ndpr-font-medium",children:"Involves Cross-Border Transfer Outside Nigeria"})]})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"reviewDate",className:"ndpr-form-field__label",children:"Next Review Date"}),jsxRuntime.jsx("input",{type:"date",id:"reviewDate",value:a.reviewDate,onChange:e=>s("reviewDate",e.target.value),className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[jsxRuntime.jsx("button",{onClick:te,className:`px-4 py-2 ndpr-text-muted bg-gray-100 dark:bg-gray-700 rounded hover:bg-gray-200 dark:hover:bg-gray-600 ${C}`,children:"Cancel"}),jsxRuntime.jsx("button",{onClick:_e,className:chunkAME4HJR4_js.a(`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${C}`,(i==null?void 0:i.primaryButton)||(i==null?void 0:i.submitButton),l),children:m?"Update Activity":"Create Activity"})]})]})]}),Se=()=>{var o;if(!n)return jsxRuntime.jsx("div",{className:"ndpr-empty-state",children:jsxRuntime.jsx("p",{className:"ndpr-card__subtitle",children:"Activity not found."})});let e=chunkWZYCBW2R_js.a(n);return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex justify-between items-start mb-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("button",{onClick:De,className:"text-sm ndpr-text-primary hover:underline mb-2","aria-label":"Back to activities list",children:"Back to list"}),jsxRuntime.jsx("h3",{className:"ndpr-section-heading",children:n.name})]}),jsxRuntime.jsxs("div",{className:"ndpr-card__footer",children:[U(n.lawfulBasis),Z(n.status),ee(n)]})]}),e.warnings.length>0&&jsxRuntime.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 p-3 rounded-md mb-4",children:[jsxRuntime.jsx("p",{className:"text-sm ndpr-text-warning font-medium mb-1",children:"Warnings"}),jsxRuntime.jsx("ul",{className:"list-disc list-inside space-y-1",children:e.warnings.map((p,V)=>jsxRuntime.jsx("li",{className:"text-xs ndpr-text-warning",children:p},V))})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("p",{className:"ndpr-text-sm",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Description:"})," ",n.description]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Lawful Basis:"})," ",chunkWZYCBW2R_js.b(n.lawfulBasis)]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Justification:"})," ",n.lawfulBasisJustification]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("p",{className:"ndpr-text-sm",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Data Categories:"})," ",n.dataCategories.join(", ")]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Data Subject Categories:"})," ",n.dataSubjectCategories.join(", ")]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Purposes:"})," ",n.purposes.join(", ")]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Retention Period:"})," ",n.retentionPeriod,n.retentionJustification&&jsxRuntime.jsxs("span",{className:"ndpr-card__subtitle",children:[" ","(",n.retentionJustification,")"]})]})]})]}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("p",{className:"ndpr-text-sm",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Sensitive Data:"})," ",n.involvesSensitiveData?"Yes":"No",n.sensitiveDataCondition&&jsxRuntime.jsxs("span",{children:[" ","(Condition:"," ",((o=oe.find(p=>p.value===n.sensitiveDataCondition))==null?void 0:o.label)||n.sensitiveDataCondition,")"]})]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Cross-Border Transfer:"})," ",n.crossBorderTransfer?"Yes":"No"]}),n.recipients&&n.recipients.length>0&&jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Recipients:"})," ",n.recipients.join(", ")]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("p",{className:"ndpr-text-sm",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Created:"})," ",k(n.createdAt)]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Last Updated:"})," ",k(n.updatedAt)]}),n.reviewDate&&jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Next Review:"})," ",k(n.reviewDate),n.reviewDate<Date.now()&&jsxRuntime.jsx("span",{className:"ndpr-text-destructive font-medium",children:" (Overdue)"})]})]})]}),n.dpoApproval&&jsxRuntime.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 p-4 rounded-md mb-6",children:[jsxRuntime.jsx("h4",{className:"ndpr-section-heading",children:"DPO Approval"}),jsxRuntime.jsxs("p",{className:"ndpr-text-sm",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Status:"})," ",n.dpoApproval.approved?"Approved":"Not Approved"]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Approved By:"})," ",n.dpoApproval.approvedBy]}),jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Date:"})," ",k(n.dpoApproval.approvedAt)]}),n.dpoApproval.notes&&jsxRuntime.jsxs("p",{className:"ndpr-form-field__hint",children:[jsxRuntime.jsx("span",{className:"font-medium",children:"Notes:"})," ",n.dpoApproval.notes]})]}),jsxRuntime.jsxs("div",{className:"flex space-x-3",children:[jsxRuntime.jsx("button",{onClick:()=>Q(n),"aria-label":`Edit ${n.name}`,className:`px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${C}`,children:"Edit"}),n.status!=="archived"&&jsxRuntime.jsx("button",{onClick:()=>X(n.id),"aria-label":`Archive ${n.name}`,className:`px-4 py-2 bg-gray-600 text-white rounded hover:bg-gray-700 ${C}`,children:"Archive"})]})]})},Ae=()=>jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"mb-6 grid grid-cols-1 md:grid-cols-4 gap-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"basisFilter",className:"ndpr-form-field__label",children:"Lawful Basis"}),jsxRuntime.jsxs("select",{id:"basisFilter",value:F,onChange:e=>fe(e.target.value),"aria-label":"Filter by lawful basis",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.select,l),children:[jsxRuntime.jsx("option",{value:"all",children:"All Bases"}),de.map(e=>jsxRuntime.jsx("option",{value:e.value,children:e.label},e.value))]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"statusFilterSelect",className:"ndpr-form-field__label",children:"Status"}),jsxRuntime.jsxs("select",{id:"statusFilterSelect",value:T,onChange:e=>me(e.target.value),"aria-label":"Filter by status",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.select,l),children:[jsxRuntime.jsx("option",{value:"all",children:"All Statuses"}),jsxRuntime.jsx("option",{value:"active",children:"Active"}),jsxRuntime.jsx("option",{value:"inactive",children:"Inactive"}),jsxRuntime.jsx("option",{value:"under_review",children:"Under Review"}),jsxRuntime.jsx("option",{value:"archived",children:"Archived"})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("label",{htmlFor:"searchInput",className:"ndpr-form-field__label",children:"Search"}),jsxRuntime.jsx("input",{type:"text",id:"searchInput",value:I,onChange:e=>be(e.target.value),placeholder:"Search activities...",className:chunkAME4HJR4_js.a("ndpr-form-field__input",i==null?void 0:i.input,l)})]}),jsxRuntime.jsx("div",{className:"flex items-end",children:jsxRuntime.jsx("button",{onClick:he,className:chunkAME4HJR4_js.a(`w-full px-4 py-2 bg-[rgb(var(--ndpr-primary))] text-white rounded hover:bg-[rgb(var(--ndpr-primary-hover))] ${C}`,(i==null?void 0:i.primaryButton)||(i==null?void 0:i.submitButton),l),children:"Add Activity"})})]}),K.length===0?jsxRuntime.jsx("div",{className:"flex items-center justify-center h-32 bg-gray-50 dark:bg-gray-700 rounded-md",children:jsxRuntime.jsx("p",{className:"ndpr-card__subtitle",children:"No processing activities found."})}):jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsxs("table",{className:chunkAME4HJR4_js.a("w-full text-sm text-left",i==null?void 0:i.table,l),children:[jsxRuntime.jsx("thead",{className:chunkAME4HJR4_js.a("ndpr-table__head",i==null?void 0:i.tableHeader,l),children:jsxRuntime.jsxs("tr",{children:[jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Activity"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Lawful Basis"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Status"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"DPO Approval"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Sensitive Data"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Last Updated"}),jsxRuntime.jsx("th",{className:"ndpr-table__cell",children:"Actions"})]})}),jsxRuntime.jsx("tbody",{children:K.map(e=>jsxRuntime.jsxs("tr",{className:chunkAME4HJR4_js.a("border-b border-gray-200 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700",i==null?void 0:i.tableRow,l),children:[jsxRuntime.jsxs("td",{className:"ndpr-table__cell",children:[jsxRuntime.jsx("button",{onClick:()=>we(e.id),className:"font-medium ndpr-text-primary hover:underline text-left",children:e.name}),jsxRuntime.jsx("p",{className:"text-xs ndpr-text-muted mt-1 truncate max-w-xs",children:e.description})]}),jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:U(e.lawfulBasis)}),jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:Z(e.status)}),jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:ee(e)}),jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:jsxRuntime.jsx("span",{className:`text-xs ${e.involvesSensitiveData?"ndpr-text-warning font-medium":"ndpr-card__subtitle"}`,children:e.involvesSensitiveData?"Yes":"No"})}),jsxRuntime.jsx("td",{className:"ndpr-table__cell ndpr-table__cell--muted",children:k(e.updatedAt)}),jsxRuntime.jsx("td",{className:"ndpr-table__cell",children:jsxRuntime.jsxs("div",{className:"ndpr-card__footer",children:[jsxRuntime.jsx("button",{onClick:()=>Q(e),"aria-label":`Edit ${e.name}`,className:"text-xs ndpr-text-primary hover:underline",children:"Edit"}),e.status!=="archived"&&jsxRuntime.jsx("button",{onClick:()=>X(e.id),"aria-label":`Archive ${e.name}`,className:"text-xs ndpr-text-muted hover:underline",children:"Archive"})]})})]},e.id))})]})})]});return jsxRuntime.jsxs("div",{className:chunkAME4HJR4_js.a(`bg-white dark:bg-gray-800 p-6 rounded-lg shadow-md ${se}`,i==null?void 0:i.root,l),children:[jsxRuntime.jsx("h2",{className:chunkAME4HJR4_js.a("ndpr-section-heading",i==null?void 0:i.title,l),children:ce}),jsxRuntime.jsx("p",{className:"ndpr-card__subtitle",children:ge}),pe&&S==="list"&&xe(),ue&&S==="list"&&Ce(),S==="list"&&Ae(),S==="form"&&ye(),S==="detail"&&Se()]})};exports.a=$e;
|
package/dist/chunk-7Z7NURIA.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a as a$2,b}from'./chunk-XC3DLYEG.mjs';import {a}from'./chunk-NI54X543.mjs';import {a as a$1}from'./chunk-DBZSN4WP.mjs';import {useRef,useState,useEffect,useCallback}from'react';function F(n){if(!n)return a$1("ndpr_consent");let{storageKey:o="ndpr_consent",storageType:i="localStorage"}=n;return i==="sessionStorage"?a$2(o):i==="cookie"?b(o,n.cookieOptions):a$1(o)}function k(n,o,i,r,a$1,g,l){if(n){i(n);let{valid:s,errors:c}=a(n);r(s),a$1(c),g(!(s&&n.version===o));}else g(true);l(false);}function z({options:n,adapter:o,storageOptions:i,version:r="1.0",onChange:a$1}){let g=o!=null?o:F(i),l=useRef(g);l.current=g;let[s,c]=useState(null),[y,d]=useState(false),[E,C]=useState(false),[w,S]=useState([]),[x,v]=useState(true);useEffect(()=>{let e=false;try{let t=l.current.load();t instanceof Promise?t.then(m=>{e||k(m,r,c,C,S,d,v);},()=>{e||(d(!0),v(!1));}):k(t,r,c,C,S,d,v);}catch(t){e||(d(true),v(false));}return ()=>{e=true;}},[r]);let h=useCallback(e=>{let{valid:t,errors:m}=a(e);C(t),S(m),a$1==null||a$1(e),Promise.resolve(l.current.save(e)).catch(j=>{console.warn("[ndpr-toolkit] Failed to save consent:",j);});},[a$1]),p=useCallback(e=>{let t={consents:e,timestamp:Date.now(),version:r,method:"explicit",hasInteracted:true};c(t),h(t),d(false);},[r,h]),I=useCallback(()=>{let e={};n.forEach(t=>{e[t.id]=true;}),p(e);},[n,p]),L=useCallback(()=>{let e={};n.forEach(t=>{e[t.id]=t.required||false;}),p(e);},[n,p]),U=useCallback(e=>!!(s!=null&&s.consents[e]),[s]),V=useCallback(()=>{c(null),d(true),C(false),S([]),Promise.resolve(l.current.remove()).catch(e=>{console.warn("[ndpr-toolkit] Failed to remove consent:",e);});},[]);return {settings:s,hasConsent:U,updateConsent:p,acceptAll:I,rejectAll:L,shouldShowBanner:y,isValid:E,validationErrors:w,resetConsent:V,isLoading:x}}export{z as a};
|
package/dist/chunk-D3HHDWBR.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var n=false,i=false;function o(e){n||(n=true,console.warn("[ndpr-toolkit] `validateConsent()` returns English error strings and will be removed in 5.0. Use `validateConsentStructured()` for typed `{ field, code, message }[]` errors."));let t=[];if((!e.consents||Object.keys(e.consents).length===0)&&t.push("Consent settings must include at least one consent option"),e.timestamp?(typeof e.timestamp!="number"||isNaN(e.timestamp))&&t.push("Consent timestamp must be a valid number"):t.push("Consent timestamp is required"),e.version||t.push("Consent version is required"),e.method||t.push("Consent collection method is required"),e.hasInteracted===void 0&&t.push("User interaction status is required"),e.timestamp){let r=new Date;r.setMonth(r.getMonth()-13);let s=r.getTime();e.timestamp<s&&t.push("Consent is older than 13 months and should be refreshed");}return {valid:t.length===0,errors:t}}function a(e){let t=[];if((!e.consents||Object.keys(e.consents).length===0)&&t.push({field:"consents",code:"consents_required",message:"Consent settings must include at least one consent option"}),e.timestamp?(typeof e.timestamp!="number"||isNaN(e.timestamp))&&t.push({field:"timestamp",code:"timestamp_invalid",message:"Consent timestamp must be a valid number"}):t.push({field:"timestamp",code:"timestamp_required",message:"Consent timestamp is required"}),e.version||t.push({field:"version",code:"version_required",message:"Consent version is required"}),e.method||t.push({field:"method",code:"method_required",message:"Consent collection method is required"}),e.hasInteracted===void 0&&t.push({field:"hasInteracted",code:"has_interacted_required",message:"User interaction status is required"}),e.timestamp){let r=new Date;r.setMonth(r.getMonth()-13);let s=r.getTime();e.timestamp<s&&t.push({field:"timestamp",code:"consent_stale",message:"Consent is older than 13 months and should be refreshed"});}return t.length>0?{valid:false,errors:t}:{valid:true,errors:[],data:e}}function d(e){i||(i=true,console.warn("[ndpr-toolkit] `validateConsentOptions()` returns English error strings and will be removed in 5.0. Use `validateConsentOptionsStructured()` for typed `{ field, code, message }[]` errors."));let t=[];return (!e||e.length===0)&&t.push("At least one consent option is required"),e==null||e.forEach(r=>{(!r.purpose||r.purpose.trim()==="")&&t.push(`Consent option "${r.id}" is missing a purpose. NDPA Section 26 requires consent to be specific to a stated purpose.`);}),{valid:t.length===0,errors:t}}function u(e){let t=[];return (!e||e.length===0)&&t.push({field:"options",code:"options_required",message:"At least one consent option is required"}),e==null||e.forEach((r,s)=>{(!r.purpose||r.purpose.trim()==="")&&t.push({field:`options[${s}].purpose`,code:"purpose_required",message:`Consent option "${r.id}" is missing a purpose. NDPA Section 26 requires consent to be specific to a stated purpose.`});}),t.length>0?{valid:false,errors:t}:{valid:true,errors:[],data:e}}exports.a=o;exports.b=a;exports.c=d;exports.d=u;
|