@inkeep/agents-ui 0.0.0-dev-20260528153706 → 0.0.0-dev-20260528163433

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 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),v="[sentinel]",y="https://cdn.jsdelivr.net/npm/altcha@3.0.9/dist/main/altcha.min.js",P="sha384-SAvZpYmIwEwxkbER1dijvBKm10sobAn/28KXy+Z7/lGbsCshTPhYrFJ2kU7LKiFM",T=1e4,R=3e4;let f=null;function S(){if(typeof customElements>"u"||customElements.get("altcha-widget"))return Promise.resolve();if(f)return f;const u=i=>e=>{f=null,i(e)};return f=new Promise((i,e)=>{const n=u(e);if(document.querySelector(`script[src="${y}"]`)){customElements.whenDefined("altcha-widget").then(()=>i()).catch(n);return}const t=document.createElement("script");t.src=y,t.integrity=P,t.crossOrigin="anonymous",t.type="module",t.async=!0,t.onload=()=>{customElements.whenDefined("altcha-widget").then(()=>i()).catch(()=>n(new Error("altcha-widget custom element never registered")))},t.onerror=()=>{console.error(v,"failed to load widget script"),n(new Error("Failed to load altcha-widget script"))},document.head.appendChild(t)}),f}function b(u){const i=document.createElement("div");i.style.cssText="position:fixed;left:-9999px;top:-9999px;width:0;height:0;overflow:hidden;pointer-events:none",document.body.appendChild(i);const e=document.createElement("altcha-widget");e.setAttribute("challenge",u),e.setAttribute("auto","onload"),e.setAttribute("hidefooter","true"),e.setAttribute("hidelogo","true"),i.appendChild(e);let n=[],r,t="mounted",c=!1,m=!1,o=null,a=!1;const h=l=>{const s=n;n=[];for(const E of s)E(l)},g=()=>{c||a||(r=void 0,t="resetting",e.reset?.(),e.verify?.())},w=()=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,!(!c||a)&&(c=!1,r=void 0,t="resetting",e.reset?.(),e.verify?.())},R)},p=l=>{const s=l.detail;s&&(t=s.state??t,s.state==="verified"&&s.payload&&(m=!0,r=s.payload,h(s.payload)),s.state==="error"&&(r=void 0,h(void 0),m||(c=!0,console.warn(v,"Sentinel unavailable, requests will proceed without bot protection"),w())))};return e.addEventListener("statechange",p),{getPayload:()=>{if(a||c)return Promise.resolve(void 0);if(r){const l=r;return r=void 0,g(),Promise.resolve(l)}return t==="verified"&&g(),new Promise(l=>{n.push(l),setTimeout(()=>{const s=n.indexOf(l);s!==-1&&(n.splice(s,1),l(void 0))},T)})},startNextSolve:g,destroy:()=>{a=!0,e.removeEventListener("statechange",p),o&&(clearTimeout(o),o=null),h(void 0),i.remove()}}}const A=({baseUrl:u,appId:i,shouldBypassCaptcha:e=!1})=>{const n=d.useRef(null),r=d.useRef(null),t=d.useCallback(()=>n.current?Promise.resolve():r.current?r.current:i?(r.current=S().then(()=>{if(!n.current){const o=`${u}/run/auth/sentinel/challenge?appId=${encodeURIComponent(i)}`;n.current=b(o)}}).catch(o=>{console.error(v,"failed to mount widget",o),r.current=null}),r.current):Promise.resolve(),[u,i]);d.useEffect(()=>{if(!e)return t(),()=>{n.current?.destroy(),n.current=null,r.current=null}},[e,t]);const c=d.useCallback(async()=>{if(e)return{};await t();const o=n.current;if(!o)return{};const a=await o.getPayload();return a?{"x-inkeep-challenge-solution":btoa(JSON.stringify({payload:a}))}:{}},[e,t]),m=d.useCallback(()=>{n.current?.startNextSolve()},[]);return{getCaptchaHeader:c,invalidate:m}};exports.useCaptcha=A;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),v="[sentinel]",y="https://cdn.jsdelivr.net/npm/altcha@3.0.9/dist/main/altcha.min.js",P="sha384-SAvZpYmIwEwxkbER1dijvBKm10sobAn/28KXy+Z7/lGbsCshTPhYrFJ2kU7LKiFM",T=1e4,R=3e4;let m=null;function S(){if(typeof customElements>"u"||customElements.get("altcha-widget"))return Promise.resolve();if(m)return m;const d=o=>e=>{m=null,o(e)};return m=new Promise((o,e)=>{const r=d(e);if(document.querySelector(`script[src="${y}"]`)){customElements.whenDefined("altcha-widget").then(()=>o()).catch(r);return}const t=document.createElement("script");t.src=y,t.integrity=P,t.crossOrigin="anonymous",t.type="module",t.async=!0,t.onload=()=>{customElements.whenDefined("altcha-widget").then(()=>o()).catch(()=>r(new Error("altcha-widget custom element never registered")))},t.onerror=()=>{console.error(v,"failed to load widget script"),r(new Error("Failed to load altcha-widget script"))},document.head.appendChild(t)}),m}function b(d){const o=document.createElement("div");o.style.cssText="position:fixed;left:-9999px;top:-9999px;width:0;height:0;overflow:hidden;pointer-events:none",document.body.appendChild(o);const e=document.createElement("altcha-widget");e.setAttribute("challenge",d),e.setAttribute("auto","onload"),e.setAttribute("hidefooter","true"),e.setAttribute("hidelogo","true"),o.appendChild(e);let r=[],n,t="mounted",l=!1,h=!1,c=null,s=!1;const f=a=>{const i=r;r=[];for(const E of i)E(a)},g=()=>{l||s||(n=void 0,t="resetting",e.reset?.(),e.verify?.())},w=()=>{c&&clearTimeout(c),c=setTimeout(()=>{c=null,!(!l||s)&&(l=!1,n=void 0,t="resetting",e.reset?.(),e.verify?.())},R)},p=a=>{const i=a.detail;i&&(t=i.state??t,i.state==="verified"&&i.payload&&(h=!0,n=i.payload,f(i.payload)),i.state==="error"&&(n=void 0,f(void 0),h||(l=!0,console.warn(v,"Sentinel unavailable, requests will proceed without bot protection"),w())))};return e.addEventListener("statechange",p),{getPayload:()=>{if(s||l)return Promise.resolve(void 0);if(n){const a=n;return n=void 0,g(),Promise.resolve(a)}return t==="verified"&&g(),new Promise(a=>{r.push(a),setTimeout(()=>{const i=r.indexOf(a);i!==-1&&(r.splice(i,1),a(void 0))},T)})},startNextSolve:g,destroy:()=>{s=!0,e.removeEventListener("statechange",p),c&&(clearTimeout(c),c=null),f(void 0),o.remove()}}}const A=({baseUrl:d,appId:o,shouldBypassCaptcha:e=!1})=>{const r=u.useRef(null),n=u.useRef(null),t=u.useRef(!1),l=u.useCallback(()=>r.current?Promise.resolve():n.current?n.current:o?(n.current=S().then(()=>{if(!t.current&&!r.current){const s=`${d}/run/auth/sentinel/challenge?appId=${encodeURIComponent(o)}`;r.current=b(s)}}).catch(s=>{console.error(v,"failed to mount widget",s),n.current=null}),n.current):Promise.resolve(),[d,o]);u.useEffect(()=>{if(t.current=!1,!e)return l(),()=>{t.current=!0,r.current?.destroy(),r.current=null,n.current=null}},[e,l]);const h=u.useCallback(async()=>{if(e)return{};await l();const s=r.current;if(!s)return{};const f=await s.getPayload();return f?{"x-inkeep-challenge-solution":btoa(JSON.stringify({payload:f}))}:{}},[e,l]),c=u.useCallback(()=>{r.current?.startNextSolve()},[]);return{getCaptchaHeader:h,invalidate:c}};exports.useCaptcha=A;
@@ -1,96 +1,96 @@
1
1
  "use client";
2
- import { useRef as w, useCallback as v, useEffect as T } from "react";
3
- const g = "[sentinel]", y = "https://cdn.jsdelivr.net/npm/altcha@3.0.9/dist/main/altcha.min.js", A = "sha384-SAvZpYmIwEwxkbER1dijvBKm10sobAn/28KXy+Z7/lGbsCshTPhYrFJ2kU7LKiFM", R = 1e4, S = 3e4;
4
- let u = null;
2
+ import { useRef as v, useCallback as g, useEffect as T } from "react";
3
+ const p = "[sentinel]", y = "https://cdn.jsdelivr.net/npm/altcha@3.0.9/dist/main/altcha.min.js", A = "sha384-SAvZpYmIwEwxkbER1dijvBKm10sobAn/28KXy+Z7/lGbsCshTPhYrFJ2kU7LKiFM", R = 1e4, S = 3e4;
4
+ let f = null;
5
5
  function x() {
6
6
  if (typeof customElements > "u" || customElements.get("altcha-widget")) return Promise.resolve();
7
- if (u) return u;
8
- const d = (i) => (e) => {
9
- u = null, i(e);
7
+ if (f) return f;
8
+ const u = (o) => (e) => {
9
+ f = null, o(e);
10
10
  };
11
- return u = new Promise((i, e) => {
12
- const n = d(e);
11
+ return f = new Promise((o, e) => {
12
+ const r = u(e);
13
13
  if (document.querySelector(
14
14
  `script[src="${y}"]`
15
15
  )) {
16
- customElements.whenDefined("altcha-widget").then(() => i()).catch(n);
16
+ customElements.whenDefined("altcha-widget").then(() => o()).catch(r);
17
17
  return;
18
18
  }
19
19
  const t = document.createElement("script");
20
20
  t.src = y, t.integrity = A, t.crossOrigin = "anonymous", t.type = "module", t.async = !0, t.onload = () => {
21
- customElements.whenDefined("altcha-widget").then(() => i()).catch(() => n(new Error("altcha-widget custom element never registered")));
21
+ customElements.whenDefined("altcha-widget").then(() => o()).catch(() => r(new Error("altcha-widget custom element never registered")));
22
22
  }, t.onerror = () => {
23
- console.error(g, "failed to load widget script"), n(new Error("Failed to load altcha-widget script"));
23
+ console.error(p, "failed to load widget script"), r(new Error("Failed to load altcha-widget script"));
24
24
  }, document.head.appendChild(t);
25
- }), u;
25
+ }), f;
26
26
  }
27
- function b(d) {
28
- const i = document.createElement("div");
29
- i.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:0;height:0;overflow:hidden;pointer-events:none", document.body.appendChild(i);
27
+ function b(u) {
28
+ const o = document.createElement("div");
29
+ o.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:0;height:0;overflow:hidden;pointer-events:none", document.body.appendChild(o);
30
30
  const e = document.createElement("altcha-widget");
31
- e.setAttribute("challenge", d), e.setAttribute("auto", "onload"), e.setAttribute("hidefooter", "true"), e.setAttribute("hidelogo", "true"), i.appendChild(e);
32
- let n = [], r, t = "mounted", c = !1, f = !1, o = null, a = !1;
33
- const m = (l) => {
34
- const s = n;
35
- n = [];
36
- for (const P of s) P(l);
31
+ e.setAttribute("challenge", u), e.setAttribute("auto", "onload"), e.setAttribute("hidefooter", "true"), e.setAttribute("hidelogo", "true"), o.appendChild(e);
32
+ let r = [], n, t = "mounted", l = !1, m = !1, c = null, s = !1;
33
+ const d = (a) => {
34
+ const i = r;
35
+ r = [];
36
+ for (const P of i) P(a);
37
37
  }, h = () => {
38
- c || a || (r = void 0, t = "resetting", e.reset?.(), e.verify?.());
38
+ l || s || (n = void 0, t = "resetting", e.reset?.(), e.verify?.());
39
39
  }, E = () => {
40
- o && clearTimeout(o), o = setTimeout(() => {
41
- o = null, !(!c || a) && (c = !1, r = void 0, t = "resetting", e.reset?.(), e.verify?.());
40
+ c && clearTimeout(c), c = setTimeout(() => {
41
+ c = null, !(!l || s) && (l = !1, n = void 0, t = "resetting", e.reset?.(), e.verify?.());
42
42
  }, S);
43
- }, p = (l) => {
44
- const s = l.detail;
45
- s && (t = s.state ?? t, s.state === "verified" && s.payload && (f = !0, r = s.payload, m(s.payload)), s.state === "error" && (r = void 0, m(void 0), f || (c = !0, console.warn(
46
- g,
43
+ }, w = (a) => {
44
+ const i = a.detail;
45
+ i && (t = i.state ?? t, i.state === "verified" && i.payload && (m = !0, n = i.payload, d(i.payload)), i.state === "error" && (n = void 0, d(void 0), m || (l = !0, console.warn(
46
+ p,
47
47
  "Sentinel unavailable, requests will proceed without bot protection"
48
48
  ), E())));
49
49
  };
50
- return e.addEventListener("statechange", p), { getPayload: () => {
51
- if (a || c) return Promise.resolve(void 0);
52
- if (r) {
53
- const l = r;
54
- return r = void 0, h(), Promise.resolve(l);
50
+ return e.addEventListener("statechange", w), { getPayload: () => {
51
+ if (s || l) return Promise.resolve(void 0);
52
+ if (n) {
53
+ const a = n;
54
+ return n = void 0, h(), Promise.resolve(a);
55
55
  }
56
- return t === "verified" && h(), new Promise((l) => {
57
- n.push(l), setTimeout(() => {
58
- const s = n.indexOf(l);
59
- s !== -1 && (n.splice(s, 1), l(void 0));
56
+ return t === "verified" && h(), new Promise((a) => {
57
+ r.push(a), setTimeout(() => {
58
+ const i = r.indexOf(a);
59
+ i !== -1 && (r.splice(i, 1), a(void 0));
60
60
  }, R);
61
61
  });
62
62
  }, startNextSolve: h, destroy: () => {
63
- a = !0, e.removeEventListener("statechange", p), o && (clearTimeout(o), o = null), m(void 0), i.remove();
63
+ s = !0, e.removeEventListener("statechange", w), c && (clearTimeout(c), c = null), d(void 0), o.remove();
64
64
  } };
65
65
  }
66
- const L = ({ baseUrl: d, appId: i, shouldBypassCaptcha: e = !1 }) => {
67
- const n = w(null), r = w(null), t = v(() => n.current ? Promise.resolve() : r.current ? r.current : i ? (r.current = x().then(() => {
68
- if (!n.current) {
69
- const o = `${d}/run/auth/sentinel/challenge?appId=${encodeURIComponent(i)}`;
70
- n.current = b(o);
66
+ const L = ({ baseUrl: u, appId: o, shouldBypassCaptcha: e = !1 }) => {
67
+ const r = v(null), n = v(null), t = v(!1), l = g(() => r.current ? Promise.resolve() : n.current ? n.current : o ? (n.current = x().then(() => {
68
+ if (!t.current && !r.current) {
69
+ const s = `${u}/run/auth/sentinel/challenge?appId=${encodeURIComponent(o)}`;
70
+ r.current = b(s);
71
71
  }
72
- }).catch((o) => {
73
- console.error(g, "failed to mount widget", o), r.current = null;
74
- }), r.current) : Promise.resolve(), [d, i]);
72
+ }).catch((s) => {
73
+ console.error(p, "failed to mount widget", s), n.current = null;
74
+ }), n.current) : Promise.resolve(), [u, o]);
75
75
  T(() => {
76
- if (!e)
77
- return t(), () => {
78
- n.current?.destroy(), n.current = null, r.current = null;
76
+ if (t.current = !1, !e)
77
+ return l(), () => {
78
+ t.current = !0, r.current?.destroy(), r.current = null, n.current = null;
79
79
  };
80
- }, [e, t]);
81
- const c = v(async () => {
80
+ }, [e, l]);
81
+ const m = g(async () => {
82
82
  if (e) return {};
83
- await t();
84
- const o = n.current;
85
- if (!o) return {};
86
- const a = await o.getPayload();
87
- return a ? {
88
- "x-inkeep-challenge-solution": btoa(JSON.stringify({ payload: a }))
83
+ await l();
84
+ const s = r.current;
85
+ if (!s) return {};
86
+ const d = await s.getPayload();
87
+ return d ? {
88
+ "x-inkeep-challenge-solution": btoa(JSON.stringify({ payload: d }))
89
89
  } : {};
90
- }, [e, t]), f = v(() => {
91
- n.current?.startNextSolve();
90
+ }, [e, l]), c = g(() => {
91
+ r.current?.startNextSolve();
92
92
  }, []);
93
- return { getCaptchaHeader: c, invalidate: f };
93
+ return { getCaptchaHeader: m, invalidate: c };
94
94
  };
95
95
  export {
96
96
  L as useCaptcha
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-ui",
3
- "version": "0.0.0-dev-20260528153706",
3
+ "version": "0.0.0-dev-20260528163433",
4
4
  "description": "",
5
5
  "homepage": "",
6
6
  "repository": {