@autobusal/utilities 1.1.1 → 1.1.2
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/index.ts +2 -0
- package/package.json +5 -2
- package/sanitize.ts +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package are documented here. This project follows [Keep a Changelog](https://keepachangelog.com/) and [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [1.1.2] - 2026-07-24
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- New `sanitizeHtml(html)` helper (wraps DOMPurify) for sanitizing admin-authored CMS content (pages, articles, notifications, policies, affiliate terms, document previews) before rendering via `dangerouslySetInnerHTML`. Added `dompurify` as a dependency.
|
|
10
|
+
|
|
5
11
|
## [1.1.1] - 2026-07-19
|
|
6
12
|
|
|
7
13
|
### Added
|
package/index.ts
CHANGED
|
@@ -6,8 +6,10 @@ import { getSex, getOptionsSex } from './passengers';
|
|
|
6
6
|
import { GetStatus, GetEnvironment, DisplayStatus } from './users';
|
|
7
7
|
import { getRandomNumber } from './numbers';
|
|
8
8
|
import { getParams } from './manage';
|
|
9
|
+
import { sanitizeHtml } from './sanitize';
|
|
9
10
|
|
|
10
11
|
export {
|
|
12
|
+
sanitizeHtml,
|
|
11
13
|
Validate,
|
|
12
14
|
Display,
|
|
13
15
|
error,
|
package/package.json
CHANGED
package/sanitize.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import DOMPurify from 'dompurify';
|
|
2
|
+
|
|
3
|
+
// Sanitizes admin-authored HTML (CMS pages, articles, notifications, policies,
|
|
4
|
+
// affiliate terms, document previews) before it's rendered via
|
|
5
|
+
// dangerouslySetInnerHTML. These fields are only writable by an admin-type
|
|
6
|
+
// account today, but rendering them unsanitized still means a compromised or
|
|
7
|
+
// phished admin can persist JS that runs in every visitor's and every other
|
|
8
|
+
// admin's browser - this is the defense-in-depth layer for that case.
|
|
9
|
+
export const sanitizeHtml = (html: string | null | undefined): string => (
|
|
10
|
+
DOMPurify.sanitize(html ?? '')
|
|
11
|
+
);
|