@asgardeo/react 0.18.0 → 0.19.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.
@@ -18,22 +18,11 @@
18
18
  import { type ConsentPurposeDataV2 as ConsentPurposeData } from '@asgardeo/browser';
19
19
  import { FC, ReactNode } from 'react';
20
20
  /**
21
- * Consent purpose structure as expected from the backend.
22
- * The `essential` and `optional` arrays contain the list of attribute names that fall under
23
- * each category for the given purpose.
21
+ * Backward-compatible consent purpose type exported by @asgardeo/react.
22
+ *
23
+ * Some consumers import this name directly; keep it as an alias to the v2 model.
24
24
  */
25
- export interface ConsentPurpose {
26
- /** Optional human-readable description of the purpose */
27
- description?: string;
28
- /** Attributes that are always required and cannot be declined */
29
- essential?: string[];
30
- /** Attributes that the user can optionally decline */
31
- optional?: string[];
32
- /** Unique identifier for the purpose */
33
- purpose_id: string;
34
- /** Name of the purpose to display in the UI */
35
- purpose_name: string;
36
- }
25
+ export type ConsentPurpose = ConsentPurposeData;
37
26
  /**
38
27
  * Render props exposed by Consent when using the render-prop pattern.
39
28
  */
@@ -59,7 +48,7 @@ export interface ConsentProps {
59
48
  * <Consent consentData={raw} formValues={formInputs} onInputChange={onChange} t={t}>
60
49
  * {({ purposes, formValues, onInputChange, t }) => (
61
50
  * <div>
62
- * {purposes.map(p => <MyConsentSection key={p.purpose_id} purpose={p} />)}
51
+ * {purposes.map(p => <MyConsentSection key={p.purposeId} purpose={p} />)}
63
52
  * </div>
64
53
  * )}
65
54
  * </Consent>
@@ -69,8 +58,8 @@ export interface ConsentProps {
69
58
  /**
70
59
  * The raw JSON string returned by the backend in `additionalData.consentPrompt`.
71
60
  */
72
- consentData?: string | ConsentPurpose[] | {
73
- purposes: ConsentPurpose[];
61
+ consentData?: string | ConsentPurposeData[] | {
62
+ purposes: ConsentPurposeData[];
74
63
  };
75
64
  /**
76
65
  * Current form values - used to read optional checkbox state.
package/dist/index.js CHANGED
@@ -8018,18 +8018,18 @@ var ConsentCheckboxList = ({
8018
8018
  if (isEssential) {
8019
8019
  return true;
8020
8020
  }
8021
- const key = getConsentOptionalKey(purpose.purpose_id, attrName);
8021
+ const key = getConsentOptionalKey(purpose.purposeId, attrName);
8022
8022
  return formValues[key] !== "false";
8023
8023
  };
8024
8024
  const handleChange = (attrName, checked) => {
8025
- const key = getConsentOptionalKey(purpose.purpose_id, attrName);
8025
+ const key = getConsentOptionalKey(purpose.purposeId, attrName);
8026
8026
  onInputChange(key, checked ? "true" : "false");
8027
8027
  };
8028
8028
  if (children) {
8029
8029
  return /* @__PURE__ */ jsx60(Fragment13, { children: children({ attributes, handleChange, isChecked, variant }) });
8030
8030
  }
8031
8031
  return /* @__PURE__ */ jsx60("div", { className: cx21(withVendorCSSClassPrefix21(bem17("consent-checkbox-list")), styles["listContainer"]), children: attributes.map((attr) => {
8032
- const inputId = `consent_${isEssential ? "ess" : "opt"}_${purpose.purpose_id}_${attr}`;
8032
+ const inputId = `consent_${isEssential ? "ess" : "opt"}_${purpose.purposeId}_${attr}`;
8033
8033
  const checked = isChecked(attr);
8034
8034
  return /* @__PURE__ */ jsxs28(
8035
8035
  "div",
@@ -8129,7 +8129,7 @@ var Consent = ({ consentData, formValues, onInputChange, children }) => {
8129
8129
  }
8130
8130
  )
8131
8131
  ] })
8132
- ] }, purpose.purpose_id || purposeIndex)) });
8132
+ ] }, purpose.purposeId || purposeIndex)) });
8133
8133
  };
8134
8134
  var Consent_default = Consent;
8135
8135
 
@@ -8458,12 +8458,12 @@ var createAuthComponentFromFlow = (component, formValues, touchedFields, formErr
8458
8458
  ...p.essential.map((attr) => ({ approved: !isDeny, name: attr })),
8459
8459
  ...p.optional.map(
8460
8460
  (attr) => ({
8461
- approved: isDeny ? false : formValues[getConsentOptionalKey(p.purpose_id, attr)] !== "false",
8461
+ approved: isDeny ? false : formValues[getConsentOptionalKey(p.purposeId, attr)] !== "false",
8462
8462
  name: attr
8463
8463
  })
8464
8464
  )
8465
8465
  ],
8466
- purpose_name: p.purpose_name
8466
+ purposeName: p.purposeName
8467
8467
  })
8468
8468
  )
8469
8469
  };
@@ -9530,14 +9530,14 @@ var SignIn = ({
9530
9530
  name: attr
9531
9531
  })),
9532
9532
  ...(p.optional || []).map((attr) => {
9533
- const key = `__consent_opt__${p.purpose_id}__${attr}`;
9533
+ const key = `__consent_opt__${p.purposeId}__${attr}`;
9534
9534
  return {
9535
9535
  approved: isDeny ? false : processedInputs[key] !== "false",
9536
9536
  name: attr
9537
9537
  };
9538
9538
  })
9539
9539
  ],
9540
- purpose_name: p.purpose_name
9540
+ purposeName: p.purposeName
9541
9541
  }))
9542
9542
  };
9543
9543
  processedInputs["consent_decisions"] = JSON.stringify(decisions);