@molecule/app-legal-pages-react 1.1.0 → 1.1.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/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-08-15T19:34:34.396Z
6
+ Generated: 2026-09-18T06:40:00.880Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-legal-pages-react
@@ -513,7 +513,7 @@ function useLegalModals({ appName, loadContent }?: UseLegalModalsOptions): Legal
513
513
 
514
514
  Peer dependencies:
515
515
 
516
- - `@molecule/app-react` ^1.0.1
516
+ - `@molecule/app-react` ^1.1.0
517
517
  - `@molecule/app-ui` ^1.0.1
518
518
  - `@molecule/app-ui-react` ^1.0.1
519
519
  - `react` ^18.0.0 || ^19.0.0
@@ -527,6 +527,10 @@ Peer dependencies:
527
527
  - `react`
528
528
  - `react-router`
529
529
 
530
+ - **`appName` is HTML-escaped before interpolation.** The legal bodies are
531
+ rendered as HTML (`dangerouslySetInnerHTML`); an `appName` carrying
532
+ markup is escaped to inert entities first, so it can never execute
533
+ inside the legal content.
530
534
  - `LegalContentPage` / `useLegalModals` render bonded HTML that defaults to an
531
535
  EMPTY string until the locale module is registered — pass your app's
532
536
  `loadContent` (from `src/config.ts`, re-exporting
@@ -1 +1 @@
1
- {"version":3,"file":"LegalContentPage.d.ts","sourceRoot":"","sources":["../src/LegalContentPage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAA;AAOrE,+DAA+D;AAC/D,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;AAiB3C;;GAEG;AACH,MAAM,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B,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAiBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,OAAO,EACP,WAAW,EACX,MAAM,EACN,MAAM,EACN,UAAwB,EACxB,cAAwB,GACzB,EAAE,qBAAqB,GAAG,GAAG,CAAC,OAAO,CAiCrC"}
@@ -15,6 +15,19 @@ const MODULE = {
15
15
  privacy: 'privacyPolicy',
16
16
  terms: 'termsOfService',
17
17
  };
18
+ /**
19
+ * HTML-escapes an interpolation value before it enters a translation whose
20
+ * result is rendered as HTML (`dangerouslySetInnerHTML`). React escapes
21
+ * text children automatically but NOT values interpolated into HTML
22
+ * strings — an `appName` containing markup would otherwise execute inside
23
+ * the legal content.
24
+ */
25
+ const escapeHtml = (value) => value
26
+ .replaceAll('&', '&')
27
+ .replaceAll('<', '&lt;')
28
+ .replaceAll('>', '&gt;')
29
+ .replaceAll('"', '&quot;')
30
+ .replaceAll("'", '&#39;');
18
31
  /**
19
32
  * Standalone Privacy / Terms page that renders the **same** bonded legal
20
33
  * HTML the footer modal shows (`content.privacyPolicy` /
@@ -46,6 +59,8 @@ export function LegalContentPage({ kind, appName, loadContent, header, footer, e
46
59
  cancelled = true;
47
60
  };
48
61
  }, [loadContent, kind]);
49
- const html = t(CONTENT_KEY[kind], appName ? { appName } : {}, { defaultValue: '' });
62
+ const html = t(CONTENT_KEY[kind], appName ? { appName: escapeHtml(appName) } : {}, {
63
+ defaultValue: '',
64
+ });
50
65
  return (_jsx(ContentPageShell, { dataMolId: `page-${kind}`, header: header, footer: footer, eyebrow: t(eyebrowKey, {}, { defaultValue: eyebrowDefault }), title: t(TITLE[kind].key, {}, { defaultValue: TITLE[kind].def }), children: _jsx("div", { className: cm.prose, dangerouslySetInnerHTML: { __html: html } }) }));
51
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LegalModalLinks.d.ts","sourceRoot":"","sources":["../src/LegalModalLinks.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAA;AAM1D,2DAA2D;AAC3D,MAAM,WAAW,qBAAqB;IACpC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,GAAG,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAChF;AAED,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAChC,6DAA6D;IAC7D,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9B,qEAAqE;IACrE,MAAM,EAAE,GAAG,CAAC,OAAO,CAAA;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,WAAW,GACZ,GAAE,qBAA0B,GAAG,cAAc,CA+C7C;AAED,yCAAyC;AACzC,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,oFAAoF;IACpF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;IACnC,4EAA4E;IAC5E,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,SAAS,CAAA;CACvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,EAC9B,aAAa,EACb,IAAa,EACb,YAAY,EACZ,UAAU,EACV,GAAG,IAAI,EACR,EAAE,oBAAoB,GAAG,GAAG,CAAC,OAAO,CAkBpC"}
1
+ {"version":3,"file":"LegalModalLinks.d.ts","sourceRoot":"","sources":["../src/LegalModalLinks.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAA;AAM1D,2DAA2D;AAC3D,MAAM,WAAW,qBAAqB;IACpC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,GAAG,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAChF;AAED,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAChC,6DAA6D;IAC7D,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9B,qEAAqE;IACrE,MAAM,EAAE,GAAG,CAAC,OAAO,CAAA;CACpB;AAiBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,WAAW,GACZ,GAAE,qBAA0B,GAAG,cAAc,CAmD7C;AAED,yCAAyC;AACzC,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,oFAAoF;IACpF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;IACnC,4EAA4E;IAC5E,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,SAAS,CAAA;CACvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,EAC9B,aAAa,EACb,IAAa,EACb,YAAY,EACZ,UAAU,EACV,GAAG,IAAI,EACR,EAAE,oBAAoB,GAAG,GAAG,CAAC,OAAO,CAkBpC"}
@@ -3,6 +3,19 @@ import { useState } from 'react';
3
3
  import { useTranslation } from '@molecule/app-react';
4
4
  import { getClassMap } from '@molecule/app-ui';
5
5
  import { Modal } from '@molecule/app-ui-react';
6
+ /**
7
+ * HTML-escapes an interpolation value before it enters a translation whose
8
+ * result is rendered as HTML (`dangerouslySetInnerHTML`). React escapes
9
+ * text children automatically but NOT values interpolated into HTML
10
+ * strings — an `appName` containing markup would otherwise execute inside
11
+ * the legal content.
12
+ */
13
+ const escapeHtml = (value) => value
14
+ .replaceAll('&', '&amp;')
15
+ .replaceAll('<', '&lt;')
16
+ .replaceAll('>', '&gt;')
17
+ .replaceAll('"', '&quot;')
18
+ .replaceAll("'", '&#39;');
6
19
  /**
7
20
  * Headless hook powering in-place Privacy/Terms modals. Use it when the
8
21
  * triggers live in different parts of a bespoke footer (or a signup
@@ -32,9 +45,13 @@ export function useLegalModals({ appName, loadContent, } = {}) {
32
45
  setTermsOpen(true);
33
46
  };
34
47
  const modals = (_jsxs(_Fragment, { children: [_jsx(Modal, { open: privacyOpen, onClose: () => setPrivacyOpen(false), title: t('footer.privacyPolicy', {}, { defaultValue: 'Privacy Policy' }), size: "lg", children: _jsx("div", { className: cm.prose, dangerouslySetInnerHTML: {
35
- __html: t('content.privacyPolicy', appName ? { appName } : {}, { defaultValue: '' }),
48
+ __html: t('content.privacyPolicy', appName ? { appName: escapeHtml(appName) } : {}, {
49
+ defaultValue: '',
50
+ }),
36
51
  } }) }), _jsx(Modal, { open: termsOpen, onClose: () => setTermsOpen(false), title: t('footer.termsOfService', {}, { defaultValue: 'Terms of Service' }), size: "lg", children: _jsx("div", { className: cm.prose, dangerouslySetInnerHTML: {
37
- __html: t('content.termsOfService', appName ? { appName } : {}, { defaultValue: '' }),
52
+ __html: t('content.termsOfService', appName ? { appName: escapeHtml(appName) } : {}, {
53
+ defaultValue: '',
54
+ }),
38
55
  } }) })] }));
39
56
  return { openPrivacy, openTerms, modals };
40
57
  }
package/dist/index.d.ts CHANGED
@@ -14,6 +14,10 @@
14
14
  * `<LegalPageLayout>`, `<LegalPageSection>`.
15
15
  *
16
16
  * @remarks
17
+ * - **`appName` is HTML-escaped before interpolation.** The legal bodies are
18
+ * rendered as HTML (`dangerouslySetInnerHTML`); an `appName` carrying
19
+ * markup is escaped to inert entities first, so it can never execute
20
+ * inside the legal content.
17
21
  * - `LegalContentPage` / `useLegalModals` render bonded HTML that defaults to an
18
22
  * EMPTY string until the locale module is registered — pass your app's
19
23
  * `loadContent` (from `src/config.ts`, re-exporting
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA"}
package/dist/index.js CHANGED
@@ -14,6 +14,10 @@
14
14
  * `<LegalPageLayout>`, `<LegalPageSection>`.
15
15
  *
16
16
  * @remarks
17
+ * - **`appName` is HTML-escaped before interpolation.** The legal bodies are
18
+ * rendered as HTML (`dangerouslySetInnerHTML`); an `appName` carrying
19
+ * markup is escaped to inert entities first, so it can never execute
20
+ * inside the legal content.
17
21
  * - `LegalContentPage` / `useLegalModals` render bonded HTML that defaults to an
18
22
  * EMPTY string until the locale module is registered — pass your app's
19
23
  * `loadContent` (from `src/config.ts`, re-exporting
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-legal-pages-react",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "React page scaffolds for Terms, Privacy, and PlanUpdated (i18n-driven, customizable keys)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -40,7 +40,7 @@
40
40
  "react-router": "^7.0.0 || ^8.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@molecule/app-react": "1.1.0",
43
+ "@molecule/app-react": "1.5.0",
44
44
  "@molecule/app-ui": "1.1.0",
45
45
  "@molecule/app-ui-react": "1.0.1",
46
46
  "@types/node": "26.1.2",
@@ -50,6 +50,6 @@
50
50
  "react-dom": "19.2.8",
51
51
  "react-router": "8.3.0",
52
52
  "typescript": "6.0.3",
53
- "vitest": "4.1.10"
53
+ "vitest": "4.1.11"
54
54
  }
55
55
  }