@blogmcp/sdk 0.2.1 → 0.2.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as m, computed as s, createElementBlock as l, openBlock as r, normalizeClass as i, toDisplayString as c } from "vue";
|
|
2
2
|
import { buttonStyles as e } from "../../../../mdx-schema/dist/styles/index.js";
|
|
3
|
-
import "../../
|
|
3
|
+
import "../../packages/sanitize/dist/html.js";
|
|
4
4
|
import { d as u } from "../../_virtual/index.js";
|
|
5
5
|
const d = ["href"], z = /* @__PURE__ */ m({
|
|
6
6
|
__name: "Button",
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
let
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import u from "../../../node_modules/dompurify/dist/purify.es.js";
|
|
2
|
+
let n, r, s = 0;
|
|
3
|
+
const a = Number(process.env.SANITIZE_RECYCLE_AFTER_CALLS ?? 500);
|
|
4
|
+
function A() {
|
|
5
|
+
const t = r;
|
|
6
|
+
n = void 0, r = void 0, s = 0;
|
|
7
|
+
try {
|
|
8
|
+
t?.close?.();
|
|
9
|
+
} catch {
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function d() {
|
|
13
|
+
if (n)
|
|
14
|
+
return n;
|
|
6
15
|
if (typeof window < "u" && typeof window.document < "u")
|
|
7
|
-
|
|
16
|
+
n = u;
|
|
8
17
|
else {
|
|
9
|
-
const { JSDOM: t } = require("jsdom");
|
|
10
|
-
|
|
18
|
+
const { JSDOM: t } = require("jsdom"), e = new t("");
|
|
19
|
+
r = e.window, n = u(e.window);
|
|
11
20
|
}
|
|
12
|
-
return
|
|
21
|
+
return S(n), _(n), n;
|
|
13
22
|
}
|
|
14
|
-
function
|
|
23
|
+
function S(t) {
|
|
15
24
|
t.addHook("afterSanitizeAttributes", (e) => {
|
|
16
25
|
e.tagName === "A" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer");
|
|
17
26
|
});
|
|
18
27
|
}
|
|
19
|
-
const
|
|
28
|
+
const m = /* @__PURE__ */ new Set([
|
|
20
29
|
"width",
|
|
21
30
|
"height",
|
|
22
31
|
"min-width",
|
|
@@ -26,29 +35,29 @@ const c = /* @__PURE__ */ new Set([
|
|
|
26
35
|
"aspect-ratio",
|
|
27
36
|
"object-fit"
|
|
28
37
|
]);
|
|
29
|
-
function
|
|
38
|
+
function p(t) {
|
|
30
39
|
return t.length > 0 && t.length <= 40 && /^[a-z0-9.%/\s-]+$/i.test(t) && !/url|expression|\\/i.test(t);
|
|
31
40
|
}
|
|
32
|
-
function
|
|
41
|
+
function w(t) {
|
|
33
42
|
const e = [];
|
|
34
|
-
for (const
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
43
|
+
for (const i of t.split(";")) {
|
|
44
|
+
const o = i.indexOf(":");
|
|
45
|
+
if (o < 0)
|
|
37
46
|
continue;
|
|
38
|
-
const
|
|
39
|
-
|
|
47
|
+
const l = i.slice(0, o).trim().toLowerCase(), f = i.slice(o + 1).trim();
|
|
48
|
+
m.has(l) && p(f) && e.push(`${l}:${f}`);
|
|
40
49
|
}
|
|
41
50
|
return e.join(";");
|
|
42
51
|
}
|
|
43
|
-
function
|
|
52
|
+
function _(t) {
|
|
44
53
|
t.addHook("afterSanitizeAttributes", (e) => {
|
|
45
54
|
if (!e.hasAttribute("style"))
|
|
46
55
|
return;
|
|
47
|
-
const
|
|
48
|
-
|
|
56
|
+
const i = w(e.getAttribute("style") || "");
|
|
57
|
+
i ? e.setAttribute("style", i) : e.removeAttribute("style");
|
|
49
58
|
});
|
|
50
59
|
}
|
|
51
|
-
const
|
|
60
|
+
const c = {
|
|
52
61
|
USE_PROFILES: { html: !0 },
|
|
53
62
|
ADD_ATTR: ["target", "rel"],
|
|
54
63
|
FORBID_TAGS: ["style", "form", "input", "iframe"],
|
|
@@ -56,8 +65,10 @@ const l = {
|
|
|
56
65
|
SANITIZE_NAMED_PROPS: !0,
|
|
57
66
|
ALLOW_DATA_ATTR: !1
|
|
58
67
|
};
|
|
59
|
-
function
|
|
60
|
-
|
|
68
|
+
function T(t, e = c) {
|
|
69
|
+
r && s >= a && A();
|
|
70
|
+
const i = d();
|
|
71
|
+
return s++, i.sanitize(t, e);
|
|
61
72
|
}
|
|
62
73
|
({
|
|
63
74
|
// Derive from STRICT_CONFIG so its security posture — and any FUTURE hardening (a new
|
|
@@ -69,10 +80,10 @@ function p(t, e = l) {
|
|
|
69
80
|
// renderer's intrinsic sizing (icon width/height) survives, while nothing that can overlay or
|
|
70
81
|
// reflow the contained host does, and customer JS still cannot run. STRICT_CONFIG (blog
|
|
71
82
|
// content) keeps `style` forbidden, so this exception is scoped to the embed host only.
|
|
72
|
-
...
|
|
83
|
+
...c
|
|
73
84
|
});
|
|
74
85
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
c as STRICT_CONFIG,
|
|
87
|
+
d as getPurifier,
|
|
88
|
+
T as sanitizeHtml
|
|
78
89
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blogmcp/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Headless SDK for Knowledge Base blog — core client, Vue composables, Nuxt adapter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@blogmcp/mdx-schema": "^0.2.
|
|
65
|
-
"@blogmcp/sanitize": "^0.2.
|
|
64
|
+
"@blogmcp/mdx-schema": "^0.2.2",
|
|
65
|
+
"@blogmcp/sanitize": "^0.2.2",
|
|
66
66
|
"marked": "^15.0.7"
|
|
67
67
|
},
|
|
68
68
|
"optionalDependencies": {
|