@redacto.io/consent-sdk-react 10.1.0 → 10.2.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -113,7 +113,9 @@ declare function createConsentClient(baseUrl: string, ledgerBaseUrl?: string): {
113
113
  * `selected: true` to regrant/renew, and `partial: true` so the rest of the
114
114
  * notice's purposes are left untouched. The principal is resolved from the
115
115
  * JWT, so no `contact`/identifiers are sent in the body, and
116
- * `consent_event_uuid` is omitted so the ledger mints a fresh event.
116
+ * `consent_event_uuid` is omitted so the ledger mints a fresh event, and
117
+ * `product_uuid` pins it to one card -- unscoped, the ledger fans the
118
+ * answer out over every product the notice covers.
117
119
  *
118
120
  * Without a ledger, the legacy Python `/manage-consent?status=` endpoint is
119
121
  * used with its `{ purpose_uuid, contact, ... }` payload.
@@ -113,7 +113,9 @@ declare function createConsentClient(baseUrl: string, ledgerBaseUrl?: string): {
113
113
  * `selected: true` to regrant/renew, and `partial: true` so the rest of the
114
114
  * notice's purposes are left untouched. The principal is resolved from the
115
115
  * JWT, so no `contact`/identifiers are sent in the body, and
116
- * `consent_event_uuid` is omitted so the ledger mints a fresh event.
116
+ * `consent_event_uuid` is omitted so the ledger mints a fresh event, and
117
+ * `product_uuid` pins it to one card -- unscoped, the ledger fans the
118
+ * answer out over every product the notice covers.
117
119
  *
118
120
  * Without a ledger, the legacy Python `/manage-consent?status=` endpoint is
119
121
  * used with its `{ purpose_uuid, contact, ... }` payload.
@@ -10180,8 +10180,15 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10180
10180
  const queryParams = new URLSearchParams();
10181
10181
  if (language) queryParams.append("language", language);
10182
10182
  const queryString = queryParams.toString();
10183
- const url = privacyCenterUrl(baseRequest, `/form/data${queryString ? `?${queryString}` : ""}`);
10184
- const { useSessionAuth = false, getAuthToken, ...fetchOptions } = options || {};
10183
+ const url = privacyCenterUrl(
10184
+ baseRequest,
10185
+ `/form/data${queryString ? `?${queryString}` : ""}`
10186
+ );
10187
+ const {
10188
+ useSessionAuth = false,
10189
+ getAuthToken,
10190
+ ...fetchOptions
10191
+ } = options || {};
10185
10192
  if (useSessionAuth) {
10186
10193
  return apiFetch(url, {
10187
10194
  ...fetchOptions,
@@ -10202,7 +10209,11 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10202
10209
  */
10203
10210
  async createCaseRequest(baseRequest, payload, authToken, options) {
10204
10211
  const url = privacyCenterUrl(baseRequest, "/case");
10205
- const { useSessionAuth = false, getAuthToken, ...fetchOptions } = options || {};
10212
+ const {
10213
+ useSessionAuth = false,
10214
+ getAuthToken,
10215
+ ...fetchOptions
10216
+ } = options || {};
10206
10217
  const contact = sandboxContact();
10207
10218
  const requestPayload = contact && payload && typeof payload === "object" ? { ...payload, contact } : payload;
10208
10219
  if (useSessionAuth) {
@@ -10256,7 +10267,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10256
10267
  const url = `${baseUrl}/public/tokens/token-exchange?token=${encodeURIComponent(token)}`;
10257
10268
  const response = await fetch(url, {
10258
10269
  method: "GET",
10259
- headers: { "Accept": "application/json" }
10270
+ headers: { Accept: "application/json" }
10260
10271
  });
10261
10272
  if (!response.ok) {
10262
10273
  const errorData = await response.json().catch(() => null);
@@ -10296,13 +10307,24 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10296
10307
  */
10297
10308
  async getUserConsents(baseRequest, params, authToken, options) {
10298
10309
  const queryParams = new URLSearchParams();
10299
- if (params.offset !== void 0) queryParams.append("offset", params.offset.toString());
10300
- if (params.limit !== void 0) queryParams.append("limit", params.limit.toString());
10301
- if (params.nominated_offset !== void 0) queryParams.append("nominated_offset", params.nominated_offset.toString());
10302
- if (params.nominated_limit !== void 0) queryParams.append("nominated_limit", params.nominated_limit.toString());
10310
+ if (params.offset !== void 0)
10311
+ queryParams.append("offset", params.offset.toString());
10312
+ if (params.limit !== void 0)
10313
+ queryParams.append("limit", params.limit.toString());
10314
+ if (params.nominated_offset !== void 0)
10315
+ queryParams.append(
10316
+ "nominated_offset",
10317
+ params.nominated_offset.toString()
10318
+ );
10319
+ if (params.nominated_limit !== void 0)
10320
+ queryParams.append(
10321
+ "nominated_limit",
10322
+ params.nominated_limit.toString()
10323
+ );
10303
10324
  if (params.search) queryParams.append("search", params.search);
10304
10325
  if (params.status) queryParams.append("status", params.status);
10305
- if (params.product_uuid) queryParams.append("product_uuid", params.product_uuid);
10326
+ if (params.product_uuid)
10327
+ queryParams.append("product_uuid", params.product_uuid);
10306
10328
  if (params.language) queryParams.append("language", params.language);
10307
10329
  appendSandboxIdentity(queryParams);
10308
10330
  const queryString = queryParams.toString();
@@ -10321,12 +10343,15 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10321
10343
  */
10322
10344
  async getGroupPurposes(baseRequest, productUuid, params, authToken, options) {
10323
10345
  const queryParams = new URLSearchParams();
10324
- if (params.offset !== void 0) queryParams.append("offset", params.offset.toString());
10325
- if (params.limit !== void 0) queryParams.append("limit", params.limit.toString());
10346
+ if (params.offset !== void 0)
10347
+ queryParams.append("offset", params.offset.toString());
10348
+ if (params.limit !== void 0)
10349
+ queryParams.append("limit", params.limit.toString());
10326
10350
  if (params.status) queryParams.append("status", params.status);
10327
10351
  if (params.search) queryParams.append("search", params.search);
10328
10352
  if (params.language) queryParams.append("language", params.language);
10329
- if (params.nominator_uuid) queryParams.append("nominator_uuid", params.nominator_uuid);
10353
+ if (params.nominator_uuid)
10354
+ queryParams.append("nominator_uuid", params.nominator_uuid);
10330
10355
  appendSandboxIdentity(queryParams);
10331
10356
  const queryString = queryParams.toString();
10332
10357
  const suffix = `/user-consents/${productUuid}/purposes${queryString ? `?${queryString}` : ""}`;
@@ -10348,7 +10373,9 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10348
10373
  * `selected: true` to regrant/renew, and `partial: true` so the rest of the
10349
10374
  * notice's purposes are left untouched. The principal is resolved from the
10350
10375
  * JWT, so no `contact`/identifiers are sent in the body, and
10351
- * `consent_event_uuid` is omitted so the ledger mints a fresh event.
10376
+ * `consent_event_uuid` is omitted so the ledger mints a fresh event, and
10377
+ * `product_uuid` pins it to one card -- unscoped, the ledger fans the
10378
+ * answer out over every product the notice covers.
10352
10379
  *
10353
10380
  * Without a ledger, the legacy Python `/manage-consent?status=` endpoint is
10354
10381
  * used with its `{ purpose_uuid, contact, ... }` payload.
@@ -10356,8 +10383,14 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10356
10383
  async manageConsent(baseRequest, purposeId, contact, status, authToken, options, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, language) {
10357
10384
  var _a;
10358
10385
  if (!useLedger()) {
10359
- const url2 = privacyCenterUrl(baseRequest, `/manage-consent?status=${status}`);
10360
- const body2 = { purpose_uuid: purposeId, contact };
10386
+ const url2 = privacyCenterUrl(
10387
+ baseRequest,
10388
+ `/manage-consent?status=${status}`
10389
+ );
10390
+ const body2 = {
10391
+ purpose_uuid: purposeId,
10392
+ contact
10393
+ };
10361
10394
  if (nominatorContact) {
10362
10395
  body2.nominator_contact = nominatorContact;
10363
10396
  }
@@ -10378,7 +10411,9 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10378
10411
  });
10379
10412
  }
10380
10413
  if (!noticeUuid) {
10381
- throw new Error("notice_uuid is required to manage consent via the ledger");
10414
+ throw new Error(
10415
+ "notice_uuid is required to manage consent via the ledger"
10416
+ );
10382
10417
  }
10383
10418
  const purposeSelected = status !== "revoke";
10384
10419
  const elements = (dataElements != null ? dataElements : []).map((de) => {
@@ -10397,6 +10432,12 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10397
10432
  // Sandbox has no JWT, so the ledger resolves the acting test principal
10398
10433
  // from this identity in the body; null (spread no-op) on the live JWT path.
10399
10434
  ...(_a = sandboxBodyIdentity()) != null ? _a : {},
10435
+ // Pins the action to the card the user acted on. Without it the ledger
10436
+ // scopes by the notice and applies the answer to every product the
10437
+ // notice covers, so revoking a purpose held on two products withdrew
10438
+ // both. Stamped on the envelope and the selection, mirroring the Python
10439
+ // relay this path was modelled on.
10440
+ ...productUuid ? { product_uuid: productUuid } : {},
10400
10441
  partial: true,
10401
10442
  declined: false,
10402
10443
  select_all_mandatory: false,
@@ -10404,6 +10445,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10404
10445
  purposes: [
10405
10446
  {
10406
10447
  purpose_uuid: purposeId,
10448
+ ...productUuid ? { product_uuid: productUuid } : {},
10407
10449
  selected: purposeSelected,
10408
10450
  data_elements: elements
10409
10451
  }
@@ -10428,7 +10470,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10428
10470
  if (language) queryParams.append("language", language);
10429
10471
  appendSandboxIdentity(queryParams);
10430
10472
  const queryString = queryParams.toString();
10431
- const url = privacyCenterUrl(baseRequest, `/activities${queryString ? `?${queryString}` : ""}`);
10473
+ const url = privacyCenterUrl(
10474
+ baseRequest,
10475
+ `/activities${queryString ? `?${queryString}` : ""}`
10476
+ );
10432
10477
  return privacyCenterApiFetch(url, {
10433
10478
  ...options,
10434
10479
  authToken: resolveAuthToken(authToken, baseRequest)
@@ -10466,13 +10511,19 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10466
10511
  */
10467
10512
  async getReceipts(baseRequest, params, authToken, options) {
10468
10513
  const queryParams = new URLSearchParams();
10469
- if (params.skip !== void 0) queryParams.append("skip", params.skip.toString());
10470
- if (params.limit !== void 0) queryParams.append("limit", params.limit.toString());
10471
- if (params.notice_uuid) queryParams.append("notice_uuid", params.notice_uuid);
10472
- if (params.event_type) queryParams.append("event_type", params.event_type);
10514
+ if (params.skip !== void 0)
10515
+ queryParams.append("skip", params.skip.toString());
10516
+ if (params.limit !== void 0)
10517
+ queryParams.append("limit", params.limit.toString());
10518
+ if (params.notice_uuid)
10519
+ queryParams.append("notice_uuid", params.notice_uuid);
10520
+ if (params.event_type)
10521
+ queryParams.append("event_type", params.event_type);
10473
10522
  if (params.status) queryParams.append("status", params.status);
10474
- if (params.created_after) queryParams.append("created_after", params.created_after);
10475
- if (params.created_before) queryParams.append("created_before", params.created_before);
10523
+ if (params.created_after)
10524
+ queryParams.append("created_after", params.created_after);
10525
+ if (params.created_before)
10526
+ queryParams.append("created_before", params.created_before);
10476
10527
  if (params.language) queryParams.append("language", params.language);
10477
10528
  appendSandboxIdentity(queryParams);
10478
10529
  const queryString = queryParams.toString();
@@ -10514,7 +10565,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10514
10565
  trimmedToken.startsWith("Bearer ") ? trimmedToken : `Bearer ${trimmedToken}`
10515
10566
  );
10516
10567
  }
10517
- const response = await fetch(url, { method: "GET", headers: requestHeaders });
10568
+ const response = await fetch(url, {
10569
+ method: "GET",
10570
+ headers: requestHeaders
10571
+ });
10518
10572
  if (!response.ok) {
10519
10573
  let errorMessage = `Request failed with status ${response.status}`;
10520
10574
  try {
@@ -10551,7 +10605,11 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10551
10605
  * Get messages for a case (privacy center)
10552
10606
  */
10553
10607
  async getCaseMessages(baseRequest, caseUuid, authToken) {
10554
- const url = caseUrl(baseRequest, caseUuid, `/messages${sandboxIdentitySuffix()}`);
10608
+ const url = caseUrl(
10609
+ baseRequest,
10610
+ caseUuid,
10611
+ `/messages${sandboxIdentitySuffix()}`
10612
+ );
10555
10613
  return privacyCenterApiFetch(url, {
10556
10614
  authToken: resolveAuthToken(authToken, baseRequest)
10557
10615
  });
@@ -10560,7 +10618,11 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10560
10618
  * Send a message on a case (privacy center)
10561
10619
  */
10562
10620
  async sendCaseMessage(baseRequest, caseUuid, body, documentUuids, authToken) {
10563
- const url = caseUrl(baseRequest, caseUuid, `/messages${sandboxIdentitySuffix()}`);
10621
+ const url = caseUrl(
10622
+ baseRequest,
10623
+ caseUuid,
10624
+ `/messages${sandboxIdentitySuffix()}`
10625
+ );
10564
10626
  return privacyCenterApiFetch(url, {
10565
10627
  method: "POST",
10566
10628
  body: JSON.stringify({ body, document_uuids: documentUuids }),
@@ -10571,7 +10633,11 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10571
10633
  * Upload a document on a case (multipart/form-data, privacy center)
10572
10634
  */
10573
10635
  async uploadCaseDocument(baseRequest, caseUuid, file, authToken) {
10574
- const url = caseUrl(baseRequest, caseUuid, `/upload-document${sandboxIdentitySuffix()}`);
10636
+ const url = caseUrl(
10637
+ baseRequest,
10638
+ caseUuid,
10639
+ `/upload-document${sandboxIdentitySuffix()}`
10640
+ );
10575
10641
  const formData = new FormData();
10576
10642
  formData.append("file", file, file.name);
10577
10643
  formData.append("payload", JSON.stringify({ metadata: null }));
@@ -10600,7 +10666,11 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10600
10666
  * Get document info/download URL for a case document (privacy center)
10601
10667
  */
10602
10668
  async getCaseDocument(baseRequest, caseUuid, documentUuid, authToken) {
10603
- const url = caseUrl(baseRequest, caseUuid, `/documents/${documentUuid}${sandboxIdentitySuffix()}`);
10669
+ const url = caseUrl(
10670
+ baseRequest,
10671
+ caseUuid,
10672
+ `/documents/${documentUuid}${sandboxIdentitySuffix()}`
10673
+ );
10604
10674
  return privacyCenterApiFetch(url, {
10605
10675
  authToken: resolveAuthToken(authToken, baseRequest)
10606
10676
  });
@@ -10633,7 +10703,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10633
10703
  queryParams.append("language", params.language);
10634
10704
  }
10635
10705
  const queryString = queryParams.toString();
10636
- const url = notificationUrl(baseRequest, queryString ? `?${queryString}` : "");
10706
+ const url = notificationUrl(
10707
+ baseRequest,
10708
+ queryString ? `?${queryString}` : ""
10709
+ );
10637
10710
  return privacyCenterApiFetch(url, {
10638
10711
  authToken: resolveAuthToken(authToken, baseRequest)
10639
10712
  });
@@ -10680,7 +10753,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10680
10753
  * Acknowledge a notification (sets is_read and is_acknowledged to true)
10681
10754
  */
10682
10755
  async acknowledgeNotification(baseRequest, notificationUuid, authToken) {
10683
- const url = notificationUrl(baseRequest, `/${notificationUuid}/acknowledge`);
10756
+ const url = notificationUrl(
10757
+ baseRequest,
10758
+ `/${notificationUuid}/acknowledge`
10759
+ );
10684
10760
  return privacyCenterApiFetch(url, {
10685
10761
  method: "POST",
10686
10762
  authToken: resolveAuthToken(authToken, baseRequest)
@@ -10112,8 +10112,15 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10112
10112
  const queryParams = new URLSearchParams();
10113
10113
  if (language) queryParams.append("language", language);
10114
10114
  const queryString = queryParams.toString();
10115
- const url = privacyCenterUrl(baseRequest, `/form/data${queryString ? `?${queryString}` : ""}`);
10116
- const { useSessionAuth = false, getAuthToken, ...fetchOptions } = options || {};
10115
+ const url = privacyCenterUrl(
10116
+ baseRequest,
10117
+ `/form/data${queryString ? `?${queryString}` : ""}`
10118
+ );
10119
+ const {
10120
+ useSessionAuth = false,
10121
+ getAuthToken,
10122
+ ...fetchOptions
10123
+ } = options || {};
10117
10124
  if (useSessionAuth) {
10118
10125
  return apiFetch(url, {
10119
10126
  ...fetchOptions,
@@ -10134,7 +10141,11 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10134
10141
  */
10135
10142
  async createCaseRequest(baseRequest, payload, authToken, options) {
10136
10143
  const url = privacyCenterUrl(baseRequest, "/case");
10137
- const { useSessionAuth = false, getAuthToken, ...fetchOptions } = options || {};
10144
+ const {
10145
+ useSessionAuth = false,
10146
+ getAuthToken,
10147
+ ...fetchOptions
10148
+ } = options || {};
10138
10149
  const contact = sandboxContact();
10139
10150
  const requestPayload = contact && payload && typeof payload === "object" ? { ...payload, contact } : payload;
10140
10151
  if (useSessionAuth) {
@@ -10188,7 +10199,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10188
10199
  const url = `${baseUrl}/public/tokens/token-exchange?token=${encodeURIComponent(token)}`;
10189
10200
  const response = await fetch(url, {
10190
10201
  method: "GET",
10191
- headers: { "Accept": "application/json" }
10202
+ headers: { Accept: "application/json" }
10192
10203
  });
10193
10204
  if (!response.ok) {
10194
10205
  const errorData = await response.json().catch(() => null);
@@ -10228,13 +10239,24 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10228
10239
  */
10229
10240
  async getUserConsents(baseRequest, params, authToken, options) {
10230
10241
  const queryParams = new URLSearchParams();
10231
- if (params.offset !== void 0) queryParams.append("offset", params.offset.toString());
10232
- if (params.limit !== void 0) queryParams.append("limit", params.limit.toString());
10233
- if (params.nominated_offset !== void 0) queryParams.append("nominated_offset", params.nominated_offset.toString());
10234
- if (params.nominated_limit !== void 0) queryParams.append("nominated_limit", params.nominated_limit.toString());
10242
+ if (params.offset !== void 0)
10243
+ queryParams.append("offset", params.offset.toString());
10244
+ if (params.limit !== void 0)
10245
+ queryParams.append("limit", params.limit.toString());
10246
+ if (params.nominated_offset !== void 0)
10247
+ queryParams.append(
10248
+ "nominated_offset",
10249
+ params.nominated_offset.toString()
10250
+ );
10251
+ if (params.nominated_limit !== void 0)
10252
+ queryParams.append(
10253
+ "nominated_limit",
10254
+ params.nominated_limit.toString()
10255
+ );
10235
10256
  if (params.search) queryParams.append("search", params.search);
10236
10257
  if (params.status) queryParams.append("status", params.status);
10237
- if (params.product_uuid) queryParams.append("product_uuid", params.product_uuid);
10258
+ if (params.product_uuid)
10259
+ queryParams.append("product_uuid", params.product_uuid);
10238
10260
  if (params.language) queryParams.append("language", params.language);
10239
10261
  appendSandboxIdentity(queryParams);
10240
10262
  const queryString = queryParams.toString();
@@ -10253,12 +10275,15 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10253
10275
  */
10254
10276
  async getGroupPurposes(baseRequest, productUuid, params, authToken, options) {
10255
10277
  const queryParams = new URLSearchParams();
10256
- if (params.offset !== void 0) queryParams.append("offset", params.offset.toString());
10257
- if (params.limit !== void 0) queryParams.append("limit", params.limit.toString());
10278
+ if (params.offset !== void 0)
10279
+ queryParams.append("offset", params.offset.toString());
10280
+ if (params.limit !== void 0)
10281
+ queryParams.append("limit", params.limit.toString());
10258
10282
  if (params.status) queryParams.append("status", params.status);
10259
10283
  if (params.search) queryParams.append("search", params.search);
10260
10284
  if (params.language) queryParams.append("language", params.language);
10261
- if (params.nominator_uuid) queryParams.append("nominator_uuid", params.nominator_uuid);
10285
+ if (params.nominator_uuid)
10286
+ queryParams.append("nominator_uuid", params.nominator_uuid);
10262
10287
  appendSandboxIdentity(queryParams);
10263
10288
  const queryString = queryParams.toString();
10264
10289
  const suffix = `/user-consents/${productUuid}/purposes${queryString ? `?${queryString}` : ""}`;
@@ -10280,7 +10305,9 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10280
10305
  * `selected: true` to regrant/renew, and `partial: true` so the rest of the
10281
10306
  * notice's purposes are left untouched. The principal is resolved from the
10282
10307
  * JWT, so no `contact`/identifiers are sent in the body, and
10283
- * `consent_event_uuid` is omitted so the ledger mints a fresh event.
10308
+ * `consent_event_uuid` is omitted so the ledger mints a fresh event, and
10309
+ * `product_uuid` pins it to one card -- unscoped, the ledger fans the
10310
+ * answer out over every product the notice covers.
10284
10311
  *
10285
10312
  * Without a ledger, the legacy Python `/manage-consent?status=` endpoint is
10286
10313
  * used with its `{ purpose_uuid, contact, ... }` payload.
@@ -10288,8 +10315,14 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10288
10315
  async manageConsent(baseRequest, purposeId, contact, status, authToken, options, nominatorContact, dataElementUuids, productUuid, noticeUuid, dataElements, language) {
10289
10316
  var _a;
10290
10317
  if (!useLedger()) {
10291
- const url2 = privacyCenterUrl(baseRequest, `/manage-consent?status=${status}`);
10292
- const body2 = { purpose_uuid: purposeId, contact };
10318
+ const url2 = privacyCenterUrl(
10319
+ baseRequest,
10320
+ `/manage-consent?status=${status}`
10321
+ );
10322
+ const body2 = {
10323
+ purpose_uuid: purposeId,
10324
+ contact
10325
+ };
10293
10326
  if (nominatorContact) {
10294
10327
  body2.nominator_contact = nominatorContact;
10295
10328
  }
@@ -10310,7 +10343,9 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10310
10343
  });
10311
10344
  }
10312
10345
  if (!noticeUuid) {
10313
- throw new Error("notice_uuid is required to manage consent via the ledger");
10346
+ throw new Error(
10347
+ "notice_uuid is required to manage consent via the ledger"
10348
+ );
10314
10349
  }
10315
10350
  const purposeSelected = status !== "revoke";
10316
10351
  const elements = (dataElements != null ? dataElements : []).map((de) => {
@@ -10329,6 +10364,12 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10329
10364
  // Sandbox has no JWT, so the ledger resolves the acting test principal
10330
10365
  // from this identity in the body; null (spread no-op) on the live JWT path.
10331
10366
  ...(_a = sandboxBodyIdentity()) != null ? _a : {},
10367
+ // Pins the action to the card the user acted on. Without it the ledger
10368
+ // scopes by the notice and applies the answer to every product the
10369
+ // notice covers, so revoking a purpose held on two products withdrew
10370
+ // both. Stamped on the envelope and the selection, mirroring the Python
10371
+ // relay this path was modelled on.
10372
+ ...productUuid ? { product_uuid: productUuid } : {},
10332
10373
  partial: true,
10333
10374
  declined: false,
10334
10375
  select_all_mandatory: false,
@@ -10336,6 +10377,7 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10336
10377
  purposes: [
10337
10378
  {
10338
10379
  purpose_uuid: purposeId,
10380
+ ...productUuid ? { product_uuid: productUuid } : {},
10339
10381
  selected: purposeSelected,
10340
10382
  data_elements: elements
10341
10383
  }
@@ -10360,7 +10402,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10360
10402
  if (language) queryParams.append("language", language);
10361
10403
  appendSandboxIdentity(queryParams);
10362
10404
  const queryString = queryParams.toString();
10363
- const url = privacyCenterUrl(baseRequest, `/activities${queryString ? `?${queryString}` : ""}`);
10405
+ const url = privacyCenterUrl(
10406
+ baseRequest,
10407
+ `/activities${queryString ? `?${queryString}` : ""}`
10408
+ );
10364
10409
  return privacyCenterApiFetch(url, {
10365
10410
  ...options,
10366
10411
  authToken: resolveAuthToken(authToken, baseRequest)
@@ -10398,13 +10443,19 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10398
10443
  */
10399
10444
  async getReceipts(baseRequest, params, authToken, options) {
10400
10445
  const queryParams = new URLSearchParams();
10401
- if (params.skip !== void 0) queryParams.append("skip", params.skip.toString());
10402
- if (params.limit !== void 0) queryParams.append("limit", params.limit.toString());
10403
- if (params.notice_uuid) queryParams.append("notice_uuid", params.notice_uuid);
10404
- if (params.event_type) queryParams.append("event_type", params.event_type);
10446
+ if (params.skip !== void 0)
10447
+ queryParams.append("skip", params.skip.toString());
10448
+ if (params.limit !== void 0)
10449
+ queryParams.append("limit", params.limit.toString());
10450
+ if (params.notice_uuid)
10451
+ queryParams.append("notice_uuid", params.notice_uuid);
10452
+ if (params.event_type)
10453
+ queryParams.append("event_type", params.event_type);
10405
10454
  if (params.status) queryParams.append("status", params.status);
10406
- if (params.created_after) queryParams.append("created_after", params.created_after);
10407
- if (params.created_before) queryParams.append("created_before", params.created_before);
10455
+ if (params.created_after)
10456
+ queryParams.append("created_after", params.created_after);
10457
+ if (params.created_before)
10458
+ queryParams.append("created_before", params.created_before);
10408
10459
  if (params.language) queryParams.append("language", params.language);
10409
10460
  appendSandboxIdentity(queryParams);
10410
10461
  const queryString = queryParams.toString();
@@ -10446,7 +10497,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10446
10497
  trimmedToken.startsWith("Bearer ") ? trimmedToken : `Bearer ${trimmedToken}`
10447
10498
  );
10448
10499
  }
10449
- const response = await fetch(url, { method: "GET", headers: requestHeaders });
10500
+ const response = await fetch(url, {
10501
+ method: "GET",
10502
+ headers: requestHeaders
10503
+ });
10450
10504
  if (!response.ok) {
10451
10505
  let errorMessage = `Request failed with status ${response.status}`;
10452
10506
  try {
@@ -10483,7 +10537,11 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10483
10537
  * Get messages for a case (privacy center)
10484
10538
  */
10485
10539
  async getCaseMessages(baseRequest, caseUuid, authToken) {
10486
- const url = caseUrl(baseRequest, caseUuid, `/messages${sandboxIdentitySuffix()}`);
10540
+ const url = caseUrl(
10541
+ baseRequest,
10542
+ caseUuid,
10543
+ `/messages${sandboxIdentitySuffix()}`
10544
+ );
10487
10545
  return privacyCenterApiFetch(url, {
10488
10546
  authToken: resolveAuthToken(authToken, baseRequest)
10489
10547
  });
@@ -10492,7 +10550,11 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10492
10550
  * Send a message on a case (privacy center)
10493
10551
  */
10494
10552
  async sendCaseMessage(baseRequest, caseUuid, body, documentUuids, authToken) {
10495
- const url = caseUrl(baseRequest, caseUuid, `/messages${sandboxIdentitySuffix()}`);
10553
+ const url = caseUrl(
10554
+ baseRequest,
10555
+ caseUuid,
10556
+ `/messages${sandboxIdentitySuffix()}`
10557
+ );
10496
10558
  return privacyCenterApiFetch(url, {
10497
10559
  method: "POST",
10498
10560
  body: JSON.stringify({ body, document_uuids: documentUuids }),
@@ -10503,7 +10565,11 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10503
10565
  * Upload a document on a case (multipart/form-data, privacy center)
10504
10566
  */
10505
10567
  async uploadCaseDocument(baseRequest, caseUuid, file, authToken) {
10506
- const url = caseUrl(baseRequest, caseUuid, `/upload-document${sandboxIdentitySuffix()}`);
10568
+ const url = caseUrl(
10569
+ baseRequest,
10570
+ caseUuid,
10571
+ `/upload-document${sandboxIdentitySuffix()}`
10572
+ );
10507
10573
  const formData = new FormData();
10508
10574
  formData.append("file", file, file.name);
10509
10575
  formData.append("payload", JSON.stringify({ metadata: null }));
@@ -10532,7 +10598,11 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10532
10598
  * Get document info/download URL for a case document (privacy center)
10533
10599
  */
10534
10600
  async getCaseDocument(baseRequest, caseUuid, documentUuid, authToken) {
10535
- const url = caseUrl(baseRequest, caseUuid, `/documents/${documentUuid}${sandboxIdentitySuffix()}`);
10601
+ const url = caseUrl(
10602
+ baseRequest,
10603
+ caseUuid,
10604
+ `/documents/${documentUuid}${sandboxIdentitySuffix()}`
10605
+ );
10536
10606
  return privacyCenterApiFetch(url, {
10537
10607
  authToken: resolveAuthToken(authToken, baseRequest)
10538
10608
  });
@@ -10565,7 +10635,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10565
10635
  queryParams.append("language", params.language);
10566
10636
  }
10567
10637
  const queryString = queryParams.toString();
10568
- const url = notificationUrl(baseRequest, queryString ? `?${queryString}` : "");
10638
+ const url = notificationUrl(
10639
+ baseRequest,
10640
+ queryString ? `?${queryString}` : ""
10641
+ );
10569
10642
  return privacyCenterApiFetch(url, {
10570
10643
  authToken: resolveAuthToken(authToken, baseRequest)
10571
10644
  });
@@ -10612,7 +10685,10 @@ function createConsentClient(baseUrl, ledgerBaseUrl) {
10612
10685
  * Acknowledge a notification (sets is_read and is_acknowledged to true)
10613
10686
  */
10614
10687
  async acknowledgeNotification(baseRequest, notificationUuid, authToken) {
10615
- const url = notificationUrl(baseRequest, `/${notificationUuid}/acknowledge`);
10688
+ const url = notificationUrl(
10689
+ baseRequest,
10690
+ `/${notificationUuid}/acknowledge`
10691
+ );
10616
10692
  return privacyCenterApiFetch(url, {
10617
10693
  method: "POST",
10618
10694
  authToken: resolveAuthToken(authToken, baseRequest)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redacto.io/consent-sdk-react",
3
- "version": "10.1.0",
3
+ "version": "10.2.0-beta.0",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",