@blogmcp/sdk 0.2.0 → 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.
@@ -8,7 +8,7 @@ var o, m;
8
8
  function S() {
9
9
  if (m) return o;
10
10
  m = 1;
11
- const t = Symbol("SemVer ANY");
11
+ const t = /* @__PURE__ */ Symbol("SemVer ANY");
12
12
  class i {
13
13
  static get ANY() {
14
14
  return t;
@@ -1,5 +1,5 @@
1
1
  import { inject as m } from "vue";
2
- const o = Symbol("ImgComponent");
2
+ const o = /* @__PURE__ */ Symbol("ImgComponent");
3
3
  function n() {
4
4
  return m(o, "img");
5
5
  }
@@ -1,6 +1,6 @@
1
1
  function s(...n) {
2
2
  const o = n.length === 1 ? n[0] : n[1];
3
- (n.length === 2 ? n[0] : !0) && process.env.NODE_ENV !== "production" && console.warn(o);
3
+ (n.length !== 2 || n[0]) && process.env.NODE_ENV !== "production" && console.warn(o);
4
4
  }
5
5
  function c(...n) {
6
6
  const o = n.length === 1 ? n[0] : n[1];
@@ -0,0 +1,2 @@
1
+ import "../../../node_modules/dompurify/dist/purify.es.js";
2
+ Number(process.env.SANITIZE_RECYCLE_AFTER_CALLS ?? 500);
@@ -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 "../../node_modules/dompurify/dist/purify.es.js";
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 f from "../../../node_modules/dompurify/dist/purify.es.js";
2
- let i;
3
- function u() {
4
- if (i)
5
- return i;
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
- i = f;
16
+ n = u;
8
17
  else {
9
- const { JSDOM: t } = require("jsdom");
10
- i = f(new t("").window);
18
+ const { JSDOM: t } = require("jsdom"), e = new t("");
19
+ r = e.window, n = u(e.window);
11
20
  }
12
- return a(i), m(i), i;
21
+ return S(n), _(n), n;
13
22
  }
14
- function a(t) {
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 c = /* @__PURE__ */ new Set([
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 A(t) {
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 S(t) {
41
+ function w(t) {
33
42
  const e = [];
34
- for (const r of t.split(";")) {
35
- const n = r.indexOf(":");
36
- if (n < 0)
43
+ for (const i of t.split(";")) {
44
+ const o = i.indexOf(":");
45
+ if (o < 0)
37
46
  continue;
38
- const o = r.slice(0, n).trim().toLowerCase(), s = r.slice(n + 1).trim();
39
- c.has(o) && A(s) && e.push(`${o}:${s}`);
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 m(t) {
52
+ function _(t) {
44
53
  t.addHook("afterSanitizeAttributes", (e) => {
45
54
  if (!e.hasAttribute("style"))
46
55
  return;
47
- const r = S(e.getAttribute("style") || "");
48
- r ? e.setAttribute("style", r) : e.removeAttribute("style");
56
+ const i = w(e.getAttribute("style") || "");
57
+ i ? e.setAttribute("style", i) : e.removeAttribute("style");
49
58
  });
50
59
  }
51
- const l = {
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 p(t, e = l) {
60
- return u().sanitize(t, e);
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
- ...l
83
+ ...c
73
84
  });
74
85
  export {
75
- l as STRICT_CONFIG,
76
- u as getPurifier,
77
- p as sanitizeHtml
86
+ c as STRICT_CONFIG,
87
+ d as getPurifier,
88
+ T as sanitizeHtml
78
89
  };
@@ -2,7 +2,7 @@ import { createKbClient as K } from "../core/client.js";
2
2
  import { createLocalStorageTokenStorage as c, createMemoryTokenStorage as i, createAuthManager as l } from "../core/auth.js";
3
3
  import { createKbI18n as b } from "../core/i18n.js";
4
4
  import { defaultImageHtml as d } from "../core/markdown.js";
5
- const s = Symbol("KbClient"), E = Symbol("KbAuth"), S = Symbol("KbI18n"), _ = Symbol("KbImageRenderer"), R = {
5
+ const s = /* @__PURE__ */ Symbol("KbClient"), E = /* @__PURE__ */ Symbol("KbAuth"), S = /* @__PURE__ */ Symbol("KbI18n"), _ = /* @__PURE__ */ Symbol("KbImageRenderer"), R = {
6
6
  install(o, e) {
7
7
  const t = e.tokenStorage || (typeof window < "u" ? c() : i()), r = K({ ...e, tokenStorage: t }), n = l(t), a = e.i18n || b(e.locale || "en"), m = e.imageRenderer || d;
8
8
  o.provide(s, r), o.provide(E, n), o.provide(S, a), o.provide(_, m);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blogmcp/sdk",
3
- "version": "0.2.0",
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.0",
65
- "@blogmcp/sanitize": "^0.2.0",
64
+ "@blogmcp/mdx-schema": "^0.2.2",
65
+ "@blogmcp/sanitize": "^0.2.2",
66
66
  "marked": "^15.0.7"
67
67
  },
68
68
  "optionalDependencies": {