@redacto.io/consent-sdk-react 10.0.0-beta.7 → 10.0.0-beta.8
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 +6 -0
- package/dist/privacy-center.d.mts +3 -2
- package/dist/privacy-center.d.ts +3 -2
- package/dist/privacy-center.js +15 -7
- package/dist/privacy-center.mjs +15 -7
- package/package.json +1 -1
- package/src/RedactoPrivacyCenter/api/actions.ts +3 -1
- package/src/RedactoPrivacyCenter/api/client.ts +6 -1
- package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +2 -1
- package/src/RedactoPrivacyCenter/lib/api.ts +3 -0
- package/tests/consentClient.test.ts +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -114,7 +114,7 @@ declare function createConsentClient(baseUrl: string, ledgerBaseUrl?: string): {
|
|
|
114
114
|
manageConsent(baseRequest: BaseRequest, purposeId: string, contact: string, status: "revoke" | "regrant" | "renew", authToken?: string, options?: Omit<ApiFetchOptions, "getAuthToken">, nominatorContact?: string, dataElementUuids?: string[], productUuid?: string, noticeUuid?: string, dataElements?: Array<{
|
|
115
115
|
uuid: string;
|
|
116
116
|
selected: boolean;
|
|
117
|
-
}
|
|
117
|
+
}>, language?: string): Promise<unknown>;
|
|
118
118
|
/**
|
|
119
119
|
* Get activities (privacy center)
|
|
120
120
|
*/
|
|
@@ -855,7 +855,7 @@ type FetchGroupPurposesParams = {
|
|
|
855
855
|
consentClient?: BaseUrlContextValue['consentClient'];
|
|
856
856
|
};
|
|
857
857
|
declare const fetchGroupPurposes: (params: FetchGroupPurposesParams) => Promise<GroupPurposesOut | null>;
|
|
858
|
-
declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact, action, authContext, consentClient, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, }: {
|
|
858
|
+
declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact, action, authContext, consentClient, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, language, }: {
|
|
859
859
|
organizationId: string;
|
|
860
860
|
workspaceId: string;
|
|
861
861
|
purposeId: string;
|
|
@@ -871,6 +871,7 @@ declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact,
|
|
|
871
871
|
uuid: string;
|
|
872
872
|
selected: boolean;
|
|
873
873
|
}>;
|
|
874
|
+
language?: string;
|
|
874
875
|
}) => Promise<boolean | null>;
|
|
875
876
|
declare const fetchActivities: (organizationId: string, workspaceId: string, offset?: number, limit?: number, authContext?: AuthContext, consentClient?: BaseUrlContextValue["consentClient"], language?: string) => Promise<ActivityDetail | null>;
|
|
876
877
|
declare const fetchCaseHistory: (organizationId: string, workspaceId: string, contact: string, offset?: number, limit?: number, authContext?: AuthContext, consentClient?: BaseUrlContextValue["consentClient"], language?: string) => Promise<CaseHistoryDetail | null>;
|
package/dist/privacy-center.d.ts
CHANGED
|
@@ -114,7 +114,7 @@ declare function createConsentClient(baseUrl: string, ledgerBaseUrl?: string): {
|
|
|
114
114
|
manageConsent(baseRequest: BaseRequest, purposeId: string, contact: string, status: "revoke" | "regrant" | "renew", authToken?: string, options?: Omit<ApiFetchOptions, "getAuthToken">, nominatorContact?: string, dataElementUuids?: string[], productUuid?: string, noticeUuid?: string, dataElements?: Array<{
|
|
115
115
|
uuid: string;
|
|
116
116
|
selected: boolean;
|
|
117
|
-
}
|
|
117
|
+
}>, language?: string): Promise<unknown>;
|
|
118
118
|
/**
|
|
119
119
|
* Get activities (privacy center)
|
|
120
120
|
*/
|
|
@@ -855,7 +855,7 @@ type FetchGroupPurposesParams = {
|
|
|
855
855
|
consentClient?: BaseUrlContextValue['consentClient'];
|
|
856
856
|
};
|
|
857
857
|
declare const fetchGroupPurposes: (params: FetchGroupPurposesParams) => Promise<GroupPurposesOut | null>;
|
|
858
|
-
declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact, action, authContext, consentClient, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, }: {
|
|
858
|
+
declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact, action, authContext, consentClient, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, language, }: {
|
|
859
859
|
organizationId: string;
|
|
860
860
|
workspaceId: string;
|
|
861
861
|
purposeId: string;
|
|
@@ -871,6 +871,7 @@ declare const manageConsent: ({ organizationId, workspaceId, purposeId, contact,
|
|
|
871
871
|
uuid: string;
|
|
872
872
|
selected: boolean;
|
|
873
873
|
}>;
|
|
874
|
+
language?: string;
|
|
874
875
|
}) => Promise<boolean | null>;
|
|
875
876
|
declare const fetchActivities: (organizationId: string, workspaceId: string, offset?: number, limit?: number, authContext?: AuthContext, consentClient?: BaseUrlContextValue["consentClient"], language?: string) => Promise<ActivityDetail | null>;
|
|
876
877
|
declare const fetchCaseHistory: (organizationId: string, workspaceId: string, contact: string, offset?: number, limit?: number, authContext?: AuthContext, consentClient?: BaseUrlContextValue["consentClient"], language?: string) => Promise<CaseHistoryDetail | null>;
|
package/dist/privacy-center.js
CHANGED
|
@@ -8506,7 +8506,8 @@ async function manageConsentServer(params) {
|
|
|
8506
8506
|
params.dataElementUuids,
|
|
8507
8507
|
params.productUuid,
|
|
8508
8508
|
params.noticeUuid,
|
|
8509
|
-
params.dataElements
|
|
8509
|
+
params.dataElements,
|
|
8510
|
+
params.language
|
|
8510
8511
|
);
|
|
8511
8512
|
if (result && typeof result === "object" && "success" in result) {
|
|
8512
8513
|
return Boolean(result.success);
|
|
@@ -9617,7 +9618,8 @@ var manageConsent = async ({
|
|
|
9617
9618
|
dataElementUuids,
|
|
9618
9619
|
productUuid,
|
|
9619
9620
|
noticeUuid,
|
|
9620
|
-
dataElements
|
|
9621
|
+
dataElements,
|
|
9622
|
+
language
|
|
9621
9623
|
}) => {
|
|
9622
9624
|
try {
|
|
9623
9625
|
const accessToken = await ensureValidToken(organizationId, workspaceId, void 0, authContext, consentClient);
|
|
@@ -9636,7 +9638,8 @@ var manageConsent = async ({
|
|
|
9636
9638
|
dataElementUuids,
|
|
9637
9639
|
productUuid,
|
|
9638
9640
|
noticeUuid,
|
|
9639
|
-
dataElements
|
|
9641
|
+
dataElements,
|
|
9642
|
+
language
|
|
9640
9643
|
});
|
|
9641
9644
|
return result;
|
|
9642
9645
|
} catch (error) {
|
|
@@ -10247,7 +10250,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
|
|
|
10247
10250
|
* Without a ledger, the legacy Python `/manage-consent?status=` endpoint is
|
|
10248
10251
|
* used with its `{ purpose_uuid, contact, ... }` payload.
|
|
10249
10252
|
*/
|
|
10250
|
-
async manageConsent(baseRequest, purposeId, contact, status, authToken, options, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements) {
|
|
10253
|
+
async manageConsent(baseRequest, purposeId, contact, status, authToken, options, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, language) {
|
|
10251
10254
|
if (!useLedger) {
|
|
10252
10255
|
const url2 = privacyCenterUrl(baseRequest, `/manage-consent?status=${status}`);
|
|
10253
10256
|
const body2 = { purpose_uuid: purposeId, contact };
|
|
@@ -10260,6 +10263,9 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
|
|
|
10260
10263
|
if (productUuid) {
|
|
10261
10264
|
body2.product_uuid = productUuid;
|
|
10262
10265
|
}
|
|
10266
|
+
if (language) {
|
|
10267
|
+
body2.language = language;
|
|
10268
|
+
}
|
|
10263
10269
|
return privacyCenterApiFetch(url2, {
|
|
10264
10270
|
...options,
|
|
10265
10271
|
method: "POST",
|
|
@@ -10294,7 +10300,8 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
|
|
|
10294
10300
|
selected: purposeSelected,
|
|
10295
10301
|
data_elements: elements
|
|
10296
10302
|
}
|
|
10297
|
-
]
|
|
10303
|
+
],
|
|
10304
|
+
...language ? { language } : {}
|
|
10298
10305
|
};
|
|
10299
10306
|
const url = ledgerUrl(baseRequest, "/submit-consent");
|
|
10300
10307
|
return privacyCenterApiFetch(url, {
|
|
@@ -18409,7 +18416,8 @@ function ConsentManager({ variant }) {
|
|
|
18409
18416
|
dataElementUuids,
|
|
18410
18417
|
productUuid,
|
|
18411
18418
|
noticeUuid,
|
|
18412
|
-
dataElements
|
|
18419
|
+
dataElements,
|
|
18420
|
+
language: langParam
|
|
18413
18421
|
});
|
|
18414
18422
|
if (response) {
|
|
18415
18423
|
toast.success(successMessages[action]);
|
|
@@ -18438,7 +18446,7 @@ function ConsentManager({ variant }) {
|
|
|
18438
18446
|
handleCloseModal();
|
|
18439
18447
|
}
|
|
18440
18448
|
},
|
|
18441
|
-
[organizationId, workspaceId, contact, fetchData, handleCloseModal, t, authContext, consentClient, selectedRecord]
|
|
18449
|
+
[organizationId, workspaceId, contact, fetchData, handleCloseModal, t, authContext, consentClient, selectedRecord, langParam]
|
|
18442
18450
|
);
|
|
18443
18451
|
const getVar26 = (varName) => `var(${varName})`;
|
|
18444
18452
|
const directBadge = (_c = (_b = consentDetail == null ? void 0 : consentDetail.status_summary) == null ? void 0 : _b.direct_purposes) != null ? _c : "";
|
package/dist/privacy-center.mjs
CHANGED
|
@@ -8440,7 +8440,8 @@ async function manageConsentServer(params) {
|
|
|
8440
8440
|
params.dataElementUuids,
|
|
8441
8441
|
params.productUuid,
|
|
8442
8442
|
params.noticeUuid,
|
|
8443
|
-
params.dataElements
|
|
8443
|
+
params.dataElements,
|
|
8444
|
+
params.language
|
|
8444
8445
|
);
|
|
8445
8446
|
if (result && typeof result === "object" && "success" in result) {
|
|
8446
8447
|
return Boolean(result.success);
|
|
@@ -9551,7 +9552,8 @@ var manageConsent = async ({
|
|
|
9551
9552
|
dataElementUuids,
|
|
9552
9553
|
productUuid,
|
|
9553
9554
|
noticeUuid,
|
|
9554
|
-
dataElements
|
|
9555
|
+
dataElements,
|
|
9556
|
+
language
|
|
9555
9557
|
}) => {
|
|
9556
9558
|
try {
|
|
9557
9559
|
const accessToken = await ensureValidToken(organizationId, workspaceId, void 0, authContext, consentClient);
|
|
@@ -9570,7 +9572,8 @@ var manageConsent = async ({
|
|
|
9570
9572
|
dataElementUuids,
|
|
9571
9573
|
productUuid,
|
|
9572
9574
|
noticeUuid,
|
|
9573
|
-
dataElements
|
|
9575
|
+
dataElements,
|
|
9576
|
+
language
|
|
9574
9577
|
});
|
|
9575
9578
|
return result;
|
|
9576
9579
|
} catch (error) {
|
|
@@ -10181,7 +10184,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
|
|
|
10181
10184
|
* Without a ledger, the legacy Python `/manage-consent?status=` endpoint is
|
|
10182
10185
|
* used with its `{ purpose_uuid, contact, ... }` payload.
|
|
10183
10186
|
*/
|
|
10184
|
-
async manageConsent(baseRequest, purposeId, contact, status, authToken, options, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements) {
|
|
10187
|
+
async manageConsent(baseRequest, purposeId, contact, status, authToken, options, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, language) {
|
|
10185
10188
|
if (!useLedger) {
|
|
10186
10189
|
const url2 = privacyCenterUrl(baseRequest, `/manage-consent?status=${status}`);
|
|
10187
10190
|
const body2 = { purpose_uuid: purposeId, contact };
|
|
@@ -10194,6 +10197,9 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
|
|
|
10194
10197
|
if (productUuid) {
|
|
10195
10198
|
body2.product_uuid = productUuid;
|
|
10196
10199
|
}
|
|
10200
|
+
if (language) {
|
|
10201
|
+
body2.language = language;
|
|
10202
|
+
}
|
|
10197
10203
|
return privacyCenterApiFetch(url2, {
|
|
10198
10204
|
...options,
|
|
10199
10205
|
method: "POST",
|
|
@@ -10228,7 +10234,8 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
|
|
|
10228
10234
|
selected: purposeSelected,
|
|
10229
10235
|
data_elements: elements
|
|
10230
10236
|
}
|
|
10231
|
-
]
|
|
10237
|
+
],
|
|
10238
|
+
...language ? { language } : {}
|
|
10232
10239
|
};
|
|
10233
10240
|
const url = ledgerUrl(baseRequest, "/submit-consent");
|
|
10234
10241
|
return privacyCenterApiFetch(url, {
|
|
@@ -18363,7 +18370,8 @@ function ConsentManager({ variant }) {
|
|
|
18363
18370
|
dataElementUuids,
|
|
18364
18371
|
productUuid,
|
|
18365
18372
|
noticeUuid,
|
|
18366
|
-
dataElements
|
|
18373
|
+
dataElements,
|
|
18374
|
+
language: langParam
|
|
18367
18375
|
});
|
|
18368
18376
|
if (response) {
|
|
18369
18377
|
toast.success(successMessages[action]);
|
|
@@ -18392,7 +18400,7 @@ function ConsentManager({ variant }) {
|
|
|
18392
18400
|
handleCloseModal();
|
|
18393
18401
|
}
|
|
18394
18402
|
},
|
|
18395
|
-
[organizationId, workspaceId, contact, fetchData, handleCloseModal, t, authContext, consentClient, selectedRecord]
|
|
18403
|
+
[organizationId, workspaceId, contact, fetchData, handleCloseModal, t, authContext, consentClient, selectedRecord, langParam]
|
|
18396
18404
|
);
|
|
18397
18405
|
const getVar26 = (varName) => `var(${varName})`;
|
|
18398
18406
|
const directBadge = (_c = (_b = consentDetail == null ? void 0 : consentDetail.status_summary) == null ? void 0 : _b.direct_purposes) != null ? _c : "";
|
package/package.json
CHANGED
|
@@ -357,6 +357,7 @@ export async function manageConsentServer(params: {
|
|
|
357
357
|
productUuid?: string;
|
|
358
358
|
noticeUuid?: string;
|
|
359
359
|
dataElements?: Array<{ uuid: string; selected: boolean }>;
|
|
360
|
+
language?: string;
|
|
360
361
|
}): Promise<boolean | null> {
|
|
361
362
|
try {
|
|
362
363
|
if (!params.consentClient) {
|
|
@@ -381,7 +382,8 @@ export async function manageConsentServer(params: {
|
|
|
381
382
|
params.dataElementUuids,
|
|
382
383
|
params.productUuid,
|
|
383
384
|
params.noticeUuid,
|
|
384
|
-
params.dataElements
|
|
385
|
+
params.dataElements,
|
|
386
|
+
params.language
|
|
385
387
|
);
|
|
386
388
|
if (result && typeof result === 'object' && 'success' in result) {
|
|
387
389
|
return Boolean((result as LegacyManageConsentResponse).success);
|
|
@@ -467,7 +467,8 @@ export function createConsentClient(baseUrl: string, ledgerBaseUrl?: string) {
|
|
|
467
467
|
dataElementUuids?: string[],
|
|
468
468
|
productUuid?: string,
|
|
469
469
|
noticeUuid?: string,
|
|
470
|
-
dataElements?: Array<{ uuid: string; selected: boolean }
|
|
470
|
+
dataElements?: Array<{ uuid: string; selected: boolean }>,
|
|
471
|
+
language?: string
|
|
471
472
|
): Promise<unknown> {
|
|
472
473
|
if (!useLedger) {
|
|
473
474
|
const url = privacyCenterUrl(baseRequest, `/manage-consent?status=${status}`);
|
|
@@ -481,6 +482,9 @@ export function createConsentClient(baseUrl: string, ledgerBaseUrl?: string) {
|
|
|
481
482
|
if (productUuid) {
|
|
482
483
|
body.product_uuid = productUuid;
|
|
483
484
|
}
|
|
485
|
+
if (language) {
|
|
486
|
+
body.language = language;
|
|
487
|
+
}
|
|
484
488
|
return privacyCenterApiFetch(url, {
|
|
485
489
|
...options,
|
|
486
490
|
method: "POST",
|
|
@@ -520,6 +524,7 @@ export function createConsentClient(baseUrl: string, ledgerBaseUrl?: string) {
|
|
|
520
524
|
data_elements: elements,
|
|
521
525
|
},
|
|
522
526
|
],
|
|
527
|
+
...(language ? { language } : {}),
|
|
523
528
|
};
|
|
524
529
|
const url = ledgerUrl(baseRequest, "/submit-consent");
|
|
525
530
|
return privacyCenterApiFetch(url, {
|
|
@@ -776,6 +776,7 @@ export default function ConsentManager({ variant }: ConsentManagerProps) {
|
|
|
776
776
|
productUuid,
|
|
777
777
|
noticeUuid,
|
|
778
778
|
dataElements,
|
|
779
|
+
language: langParam,
|
|
779
780
|
});
|
|
780
781
|
|
|
781
782
|
if (response) {
|
|
@@ -805,7 +806,7 @@ export default function ConsentManager({ variant }: ConsentManagerProps) {
|
|
|
805
806
|
handleCloseModal();
|
|
806
807
|
}
|
|
807
808
|
},
|
|
808
|
-
[organizationId, workspaceId, contact, fetchData, handleCloseModal, t, authContext, consentClient, selectedRecord]
|
|
809
|
+
[organizationId, workspaceId, contact, fetchData, handleCloseModal, t, authContext, consentClient, selectedRecord, langParam]
|
|
809
810
|
);
|
|
810
811
|
|
|
811
812
|
const getVar = (varName: string): string => `var(${varName})`;
|
|
@@ -394,6 +394,7 @@ export const manageConsent = async ({
|
|
|
394
394
|
productUuid,
|
|
395
395
|
noticeUuid,
|
|
396
396
|
dataElements,
|
|
397
|
+
language,
|
|
397
398
|
}: {
|
|
398
399
|
organizationId: string;
|
|
399
400
|
workspaceId: string;
|
|
@@ -407,6 +408,7 @@ export const manageConsent = async ({
|
|
|
407
408
|
productUuid?: string;
|
|
408
409
|
noticeUuid?: string;
|
|
409
410
|
dataElements?: Array<{ uuid: string; selected: boolean }>;
|
|
411
|
+
language?: string;
|
|
410
412
|
}): Promise<boolean | null> => {
|
|
411
413
|
try {
|
|
412
414
|
// Ensure we have a valid token before making the API call
|
|
@@ -429,6 +431,7 @@ export const manageConsent = async ({
|
|
|
429
431
|
productUuid,
|
|
430
432
|
noticeUuid,
|
|
431
433
|
dataElements,
|
|
434
|
+
language,
|
|
432
435
|
});
|
|
433
436
|
return result;
|
|
434
437
|
} catch (error: any) {
|
|
@@ -93,6 +93,24 @@ describe('createConsentClient — legacy mode (no ledgerBaseUrl)', () => {
|
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
+
it('records the selected language in the legacy manage-consent body', async () => {
|
|
97
|
+
await client.manageConsent(
|
|
98
|
+
baseRequest,
|
|
99
|
+
'purp-1',
|
|
100
|
+
'jane@example.com',
|
|
101
|
+
'revoke',
|
|
102
|
+
undefined,
|
|
103
|
+
undefined,
|
|
104
|
+
undefined,
|
|
105
|
+
undefined,
|
|
106
|
+
undefined,
|
|
107
|
+
undefined,
|
|
108
|
+
undefined,
|
|
109
|
+
'doi',
|
|
110
|
+
);
|
|
111
|
+
expect(fetchedBody()).toMatchObject({ language: 'doi' });
|
|
112
|
+
});
|
|
113
|
+
|
|
96
114
|
it('routes getReceipts to the legacy dsar/privacy-center path', async () => {
|
|
97
115
|
await client.getReceipts(baseRequest, { skip: 0, limit: 10 });
|
|
98
116
|
expect(fetchedUrl()).toBe(`${LEGACY_PREFIX}/receipts?skip=0&limit=10`);
|
|
@@ -103,6 +121,16 @@ describe('createConsentClient — legacy mode (no ledgerBaseUrl)', () => {
|
|
|
103
121
|
await client.getReceiptPdf(baseRequest, 'r-1');
|
|
104
122
|
expect(fetchedUrl()).toBe(`${LEGACY_PREFIX}/receipts/r-1/pdf`);
|
|
105
123
|
});
|
|
124
|
+
|
|
125
|
+
it('appends the language query param to getActivities when provided', async () => {
|
|
126
|
+
await client.getActivities(baseRequest, 0, 15, 'doi');
|
|
127
|
+
expect(fetchedUrl()).toContain('language=doi');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('omits the language query param from getActivities for the default language', async () => {
|
|
131
|
+
await client.getActivities(baseRequest, 0, 15);
|
|
132
|
+
expect(fetchedUrl()).not.toContain('language=');
|
|
133
|
+
});
|
|
106
134
|
});
|
|
107
135
|
|
|
108
136
|
describe('createConsentClient — ledger mode (ledgerBaseUrl set)', () => {
|
|
@@ -151,6 +179,24 @@ describe('createConsentClient — ledger mode (ledgerBaseUrl set)', () => {
|
|
|
151
179
|
});
|
|
152
180
|
});
|
|
153
181
|
|
|
182
|
+
it('records the selected language in the ledger partial submit body', async () => {
|
|
183
|
+
await client.manageConsent(
|
|
184
|
+
baseRequest,
|
|
185
|
+
'purp-1',
|
|
186
|
+
'jane@example.com',
|
|
187
|
+
'revoke',
|
|
188
|
+
undefined,
|
|
189
|
+
undefined,
|
|
190
|
+
undefined,
|
|
191
|
+
undefined,
|
|
192
|
+
undefined,
|
|
193
|
+
'notice-1',
|
|
194
|
+
[{ uuid: 'de-1', selected: true }],
|
|
195
|
+
'doi',
|
|
196
|
+
);
|
|
197
|
+
expect(fetchedBody()).toMatchObject({ language: 'doi' });
|
|
198
|
+
});
|
|
199
|
+
|
|
154
200
|
it('throws from manageConsent when noticeUuid is missing', async () => {
|
|
155
201
|
await expect(
|
|
156
202
|
client.manageConsent(baseRequest, 'purp-1', 'jane@example.com', 'revoke'),
|