@mulanjs/mulanjs 1.0.1-dev.20260212152134 → 1.0.1-dev.20260218164416
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 +1 -1
- package/dist/mulan.esm.js +5 -0
- package/dist/mulan.js +1 -1
- package/dist/security/sanitizer.js +5 -0
- package/dist/types/security/sanitizer.d.ts +5 -0
- package/package.json +1 -1
- package/src/cli/index.js +3 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ MulanJS is a high-performance, next-generation web framework designed to bridge
|
|
|
16
16
|
> Coming soon!
|
|
17
17
|
|
|
18
18
|
### Development Release (Latest)
|
|
19
|
-
To install the latest development version of MulanJS:
|
|
19
|
+
To install the latest development version of MulanJS (e.g., `1.0.1-dev.20260218163106`):
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
npm install @mulanjs/mulanjs@dev
|
package/dist/mulan.esm.js
CHANGED
|
@@ -1617,6 +1617,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1617
1617
|
/* harmony export */ Security: () => (/* binding */ Security)
|
|
1618
1618
|
/* harmony export */ });
|
|
1619
1619
|
class Security {
|
|
1620
|
+
/**
|
|
1621
|
+
* IRON FORTRESS PROTOCOL
|
|
1622
|
+
* Strictly escapes all HTML entities to prevent XSS.
|
|
1623
|
+
* Use `mu-raw` attribute in templates to bypass this for trusted content.
|
|
1624
|
+
*/
|
|
1620
1625
|
static sanitize(input) {
|
|
1621
1626
|
// 1. Basic entity encoding
|
|
1622
1627
|
let secure = input
|
package/dist/mulan.js
CHANGED
|
@@ -126,7 +126,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
126
126
|
\***********************************/
|
|
127
127
|
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
128
128
|
|
|
129
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Security: () => (/* binding */ Security)\n/* harmony export */ });\nclass Security {\n static sanitize(input) {\n // 1. Basic entity encoding\n let secure = input\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n // 2. Remove dangerous events (extra layer if encoding fails)\n const dangerousEvents = ['onload', 'onclick', 'onerror', 'onmouseover', 'onfocus'];\n dangerousEvents.forEach(event => {\n const regex = new RegExp(event, 'gi');\n secure = secure.replace(regex, 'data-blocked-' + event);\n });\n return secure;\n }\n /**\n * Generates a strict Content Security Policy header value.\n * @param options Configuration for allowed sources\n */\n static generateCSP(options = {}) {\n const scriptSrc = [\"'self'\", ...(options.scriptSrc || [])].join(\" \");\n const styleSrc = [\"'self'\", \"'unsafe-inline'\", ...(options.styleSrc || [])].join(\" \");\n return `default-src 'self'; script-src ${scriptSrc}; style-src ${styleSrc}; object-src 'none'; base-uri 'self';`;\n }\n static validateUrl(url) {\n // Basic URL validation\n const pattern = new RegExp('^(https?:\\\\/\\\\/)?' + // protocol\n '((([a-z\\\\d]([a-z\\\\d-]*[a-z\\\\d])*)\\\\.)+[a-z]{2,}|' + // domain name\n '((\\\\d{1,3}\\\\.){3}\\\\d{1,3}))' + // OR ip (v4) address\n '(\\\\:\\\\d+)?(\\\\/[-a-z\\\\d%_.~+]*)*' + // port and path\n '(\\\\?[;&a-z\\\\d%_.~+=-]*)?' + // query string\n '(\\\\#[-a-z\\\\d_]*)?$', 'i'); // fragment locator\n return !!pattern.test(url);\n }\n /**\n * Prevents XSS by sanitizing common input fields on blur.\n * Can be used as a utility in forms.\n */\n static preventXSS(inputElement) {\n inputElement.addEventListener('blur', (e) => {\n const target = e.target;\n target.value = Security.sanitize(target.value);\n });\n }\n}\n\n\n//# sourceURL=webpack://Mulan/./src/security/sanitizer.ts?\n}");
|
|
129
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Security: () => (/* binding */ Security)\n/* harmony export */ });\nclass Security {\n /**\n * IRON FORTRESS PROTOCOL\n * Strictly escapes all HTML entities to prevent XSS.\n * Use `mu-raw` attribute in templates to bypass this for trusted content.\n */\n static sanitize(input) {\n // 1. Basic entity encoding\n let secure = input\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n // 2. Remove dangerous events (extra layer if encoding fails)\n const dangerousEvents = ['onload', 'onclick', 'onerror', 'onmouseover', 'onfocus'];\n dangerousEvents.forEach(event => {\n const regex = new RegExp(event, 'gi');\n secure = secure.replace(regex, 'data-blocked-' + event);\n });\n return secure;\n }\n /**\n * Generates a strict Content Security Policy header value.\n * @param options Configuration for allowed sources\n */\n static generateCSP(options = {}) {\n const scriptSrc = [\"'self'\", ...(options.scriptSrc || [])].join(\" \");\n const styleSrc = [\"'self'\", \"'unsafe-inline'\", ...(options.styleSrc || [])].join(\" \");\n return `default-src 'self'; script-src ${scriptSrc}; style-src ${styleSrc}; object-src 'none'; base-uri 'self';`;\n }\n static validateUrl(url) {\n // Basic URL validation\n const pattern = new RegExp('^(https?:\\\\/\\\\/)?' + // protocol\n '((([a-z\\\\d]([a-z\\\\d-]*[a-z\\\\d])*)\\\\.)+[a-z]{2,}|' + // domain name\n '((\\\\d{1,3}\\\\.){3}\\\\d{1,3}))' + // OR ip (v4) address\n '(\\\\:\\\\d+)?(\\\\/[-a-z\\\\d%_.~+]*)*' + // port and path\n '(\\\\?[;&a-z\\\\d%_.~+=-]*)?' + // query string\n '(\\\\#[-a-z\\\\d_]*)?$', 'i'); // fragment locator\n return !!pattern.test(url);\n }\n /**\n * Prevents XSS by sanitizing common input fields on blur.\n * Can be used as a utility in forms.\n */\n static preventXSS(inputElement) {\n inputElement.addEventListener('blur', (e) => {\n const target = e.target;\n target.value = Security.sanitize(target.value);\n });\n }\n}\n\n\n//# sourceURL=webpack://Mulan/./src/security/sanitizer.ts?\n}");
|
|
130
130
|
|
|
131
131
|
/***/ },
|
|
132
132
|
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export class Security {
|
|
2
|
+
/**
|
|
3
|
+
* IRON FORTRESS PROTOCOL
|
|
4
|
+
* Strictly escapes all HTML entities to prevent XSS.
|
|
5
|
+
* Use `mu-raw` attribute in templates to bypass this for trusted content.
|
|
6
|
+
*/
|
|
2
7
|
static sanitize(input) {
|
|
3
8
|
// 1. Basic entity encoding
|
|
4
9
|
let secure = input
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export declare class Security {
|
|
2
|
+
/**
|
|
3
|
+
* IRON FORTRESS PROTOCOL
|
|
4
|
+
* Strictly escapes all HTML entities to prevent XSS.
|
|
5
|
+
* Use `mu-raw` attribute in templates to bypass this for trusted content.
|
|
6
|
+
*/
|
|
2
7
|
static sanitize(input: string): string;
|
|
3
8
|
/**
|
|
4
9
|
* Generates a strict Content Security Policy header value.
|
package/package.json
CHANGED
package/src/cli/index.js
CHANGED
|
@@ -120,7 +120,9 @@ program
|
|
|
120
120
|
name: projectName,
|
|
121
121
|
version: "1.0.0",
|
|
122
122
|
description: "Powered by MulanJS",
|
|
123
|
-
dependencies: {
|
|
123
|
+
dependencies: {
|
|
124
|
+
"@mulanjs/mulanjs": "^1.0.0"
|
|
125
|
+
},
|
|
124
126
|
devDependencies: {
|
|
125
127
|
"webpack": "^5.104.1",
|
|
126
128
|
"webpack-cli": "^6.0.1",
|