@calimero-network/mero-react 11.1.4 → 11.2.0

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.
@@ -0,0 +1,407 @@
1
+ import { styleInject, MeroContext } from './chunk-4AKOWHG3.js';
2
+ import { useContext, useState, useRef, useId, useEffect, useCallback, useLayoutEffect } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import { verifyNodeUrl } from '@calimero-network/mero-js';
5
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
+
7
+ var RETRY_BASE_MS = 2e3;
8
+ var RETRY_MAX_MS = 3e4;
9
+ var NODE_POLL_MS = 1e3;
10
+ var retryDelay = (attempt) => Math.min(RETRY_BASE_MS * 2 ** attempt, RETRY_MAX_MS);
11
+ async function check(client) {
12
+ try {
13
+ return await client.verify();
14
+ } catch {
15
+ return null;
16
+ }
17
+ }
18
+ function peek(client) {
19
+ let known;
20
+ try {
21
+ known = client?.verification();
22
+ } catch {
23
+ }
24
+ return known ?? { status: "checking", url: client?.nodeUrl ?? "" };
25
+ }
26
+ function useNodeVerification(client) {
27
+ const [held, setHeld] = useState(() => ({ client, state: peek(client) }));
28
+ const [round, setRound] = useState(0);
29
+ const [url, setUrl] = useState(client?.nodeUrl);
30
+ useEffect(() => {
31
+ setUrl(client?.nodeUrl);
32
+ if (!client) return;
33
+ const poll = setInterval(() => setUrl(client.nodeUrl), NODE_POLL_MS);
34
+ return () => clearInterval(poll);
35
+ }, [client]);
36
+ useEffect(() => {
37
+ if (!client) return;
38
+ let live = true;
39
+ let timer;
40
+ const run = async (attempt) => {
41
+ const next = await check(client);
42
+ if (!live || !next) return;
43
+ setHeld({ client, state: next });
44
+ if (next.status === "unreachable") timer = setTimeout(() => void run(attempt + 1), retryDelay(attempt));
45
+ };
46
+ setHeld({ client, state: peek(client) });
47
+ void run(0);
48
+ return () => {
49
+ live = false;
50
+ clearTimeout(timer);
51
+ };
52
+ }, [client, round, url]);
53
+ const state = held.client === client ? held.state : peek(client);
54
+ const inUse = client?.nodeUrl;
55
+ const shown = inUse && state.url !== inUse ? { status: "checking", url: inUse } : state;
56
+ return [shown, useCallback(() => setRound((n) => n + 1), [])];
57
+ }
58
+ function useAppCode(client, appCode, url) {
59
+ const [result, setResult] = useState(null);
60
+ useEffect(() => {
61
+ if (!client || !appCode || !url) return;
62
+ let live = true;
63
+ void Promise.resolve().then(() => appCode(client, url)).then(
64
+ (code) => live && client.nodeUrl === url && setResult({ client, url, appCode, code }),
65
+ () => void 0
66
+ );
67
+ return () => {
68
+ live = false;
69
+ };
70
+ }, [client, appCode, url]);
71
+ const current = result?.client === client && result?.url === url && result?.appCode === appCode && client?.nodeUrl === url;
72
+ return current ? result.code : null;
73
+ }
74
+ var SEALED_PROFILE = "locked-read-only";
75
+ var JUST_NOW_SECONDS = 10;
76
+ var AGO = [
77
+ ["day", 86400],
78
+ ["hour", 3600],
79
+ ["minute", 60]
80
+ ];
81
+ var ago = new Intl.RelativeTimeFormat("en");
82
+ var SHIELD_LABEL = {
83
+ checking: "Checking node\u2026",
84
+ verified: "Verified node",
85
+ unsealed: "Test server: not sealed",
86
+ refused: "Node refused"
87
+ };
88
+ function shieldKind(state) {
89
+ if (state.status === "refused") return "refused";
90
+ if (state.status !== "verified") return "checking";
91
+ return !state.mock && state.profile === SEALED_PROFILE ? "verified" : "unsealed";
92
+ }
93
+ function checkedAgo(at, now = Date.now()) {
94
+ const seconds = Math.max(0, Math.round((now - at) / 1e3));
95
+ if (seconds < JUST_NOW_SECONDS) return "just now";
96
+ const [unit, size] = AGO.find(([, size2]) => seconds >= size2) ?? ["second", 1];
97
+ return ago.format(-Math.floor(seconds / size), unit);
98
+ }
99
+ function shortHash(hash) {
100
+ return hash.length > 12 ? `${hash.slice(0, 4)}\u2026${hash.slice(-4)}` : hash;
101
+ }
102
+ function hostOf(url) {
103
+ try {
104
+ return new URL(url).host;
105
+ } catch {
106
+ return url;
107
+ }
108
+ }
109
+ function releaseName(code) {
110
+ return code.package && code.version ? `${code.package} v${code.version}` : null;
111
+ }
112
+ function codeRow(code) {
113
+ if (code?.status === "match") {
114
+ const named = releaseName(code);
115
+ return {
116
+ label: "App code",
117
+ value: named ? `${named} \xB7 ${shortHash(code.appHash)}` : shortHash(code.appHash),
118
+ full: named ? `${named} \xB7 ${code.appHash}` : code.appHash,
119
+ mono: true,
120
+ hash: shortHash(code.appHash)
121
+ };
122
+ }
123
+ if (code?.status === "mismatch") {
124
+ return {
125
+ label: "App code",
126
+ value: `Does not match this app's release (node runs ${shortHash(code.appHash)})`,
127
+ full: `Does not match this app's release (node runs ${code.appHash}, expected ${code.expected})`,
128
+ tone: "bad"
129
+ };
130
+ }
131
+ return null;
132
+ }
133
+ function copy(state, kind, ago2) {
134
+ switch (kind) {
135
+ case "verified":
136
+ return {
137
+ title: "You are talking to a genuine Calimero TEE node",
138
+ sub: `Checked by this browser ${ago2}, before anything was sent.`
139
+ };
140
+ case "unsealed":
141
+ return {
142
+ title: SHIELD_LABEL.unsealed,
143
+ sub: state.status === "verified" && state.mock ? `A test server with no hardware enclave, so its data is not sealed. Checked by this browser ${ago2}.` : `This node did not show it runs the sealed, read-only profile, so its data is not sealed. Checked by this browser ${ago2}.`
144
+ };
145
+ case "refused":
146
+ return { title: SHIELD_LABEL.refused, sub: "This app refused the node and sent nothing." };
147
+ case "checking":
148
+ return {
149
+ title: SHIELD_LABEL.checking,
150
+ sub: state.status === "unreachable" ? "The node could not be reached. Trying again." : "This browser is checking the node before anything is sent."
151
+ };
152
+ }
153
+ }
154
+ function describeShield(state, { cluster, code, now = Date.now() }) {
155
+ const kind = shieldKind(state);
156
+ const real = state.status === "verified" && !state.mock ? state : null;
157
+ const release = real?.release;
158
+ const rows = [];
159
+ if (cluster) rows.push({ label: "Cluster", value: cluster });
160
+ rows.push({ label: "Node", value: hostOf(state.url), full: state.url, mono: true });
161
+ if (real && release) rows.push({ label: "Software", value: `mero-tee v${release}${real.profile ? ` \xB7 ${real.profile}` : ""}` });
162
+ const app = real ? codeRow(code) : null;
163
+ if (app) rows.push(app);
164
+ if (state.status === "refused" || state.status === "unreachable") {
165
+ rows.push({ label: "Reason", value: state.reason, ...state.status === "refused" ? { tone: "bad" } : {} });
166
+ }
167
+ const checked = "checkedAt" in state ? checkedAgo(state.checkedAt, now) : null;
168
+ if (checked) rows.push({ label: "Checked", value: checked });
169
+ const checks = [];
170
+ if (kind === "verified") checks.push("Running in an Intel TDX enclave (not debug)");
171
+ if (real && release) checks.push(`Measurements match the signed v${release} release`);
172
+ if (real) checks.push("Your connection is encrypted to this enclave's key");
173
+ if (app && code?.status === "match") {
174
+ const named = releaseName(code);
175
+ checks.push(named ? `Node runs the code listed for ${named}` : "Node runs the code bundle this app was built for");
176
+ }
177
+ return {
178
+ kind,
179
+ label: SHIELD_LABEL[kind],
180
+ ...copy(state, kind, checked ?? "just now"),
181
+ rows,
182
+ checks,
183
+ verifyUrl: real && release ? verifyNodeUrl(real.url, release) : null
184
+ };
185
+ }
186
+ function shieldDetails(view) {
187
+ return [
188
+ view.title,
189
+ view.sub,
190
+ "",
191
+ ...view.rows.map((r) => `${r.label}: ${r.full ?? r.value}`),
192
+ ...view.checks.length ? ["", ...view.checks.map((c) => `- ${c}`)] : []
193
+ ].join("\n");
194
+ }
195
+
196
+ // src/node-shield/nodeShield.css
197
+ styleInject('.mero-node-shield,\n.mero-node-shield-pop {\n --_verified: var(--node-shield-verified, #0b7a4b);\n --_refused: var(--node-shield-refused, #c1264e);\n --_checking: var(--node-shield-checking, #3451d1);\n --_neutral: var(--node-shield-neutral, #687086);\n --_surface: var(--node-shield-surface, #ffffff);\n --_text: var(--node-shield-text, #0e1222);\n --_muted: var(--node-shield-muted, #5d6377);\n --_border: var(--node-shield-border, rgba(14, 18, 34, 0.14));\n --_focus: var(--node-shield-focus, #3e63f5);\n --_tone: var(--_neutral);\n}\n@media (prefers-color-scheme: dark) {\n .mero-node-shield,\n .mero-node-shield-pop {\n --_verified: var(--node-shield-verified, #4fd08f);\n --_refused: var(--node-shield-refused, #f47c9c);\n --_checking: var(--node-shield-checking, #93a8ff);\n --_neutral: var(--node-shield-neutral, #9aa1b4);\n --_surface: var(--node-shield-surface, #161b2b);\n --_text: var(--node-shield-text, #eceef5);\n --_muted: var(--node-shield-muted, #9aa0b4);\n --_border: var(--node-shield-border, rgba(255, 255, 255, 0.16));\n --_focus: var(--node-shield-focus, #9aafff);\n }\n}\n.mero-node-shield [data-kind=verified],\n.mero-node-shield-pop[data-kind=verified] {\n --_tone: var(--_verified);\n}\n.mero-node-shield [data-kind=refused],\n.mero-node-shield-pop[data-kind=refused] {\n --_tone: var(--_refused);\n}\n.mero-node-shield [data-kind=checking],\n.mero-node-shield-pop[data-kind=checking] {\n --_tone: var(--_checking);\n}\n.mero-node-shield {\n display: inline-flex;\n flex: none;\n vertical-align: middle;\n}\n.mero-node-shield__chip {\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: 6px;\n height: 28px;\n margin: 0;\n padding: 0 11px 0 8px;\n border: 1px solid color-mix(in srgb, var(--_tone) 40%, transparent);\n border-radius: 999px;\n background: color-mix(in srgb, var(--_tone) 13%, var(--_surface));\n color: var(--_text);\n font: inherit;\n font-size: 12px;\n font-weight: 600;\n line-height: 1;\n white-space: nowrap;\n cursor: pointer;\n transition: border-color 0.15s ease;\n}\nbutton.mero-node-shield__chip:hover,\nbutton.mero-node-shield__chip:focus,\nbutton.mero-node-shield__chip:active,\nbutton.mero-node-shield__chip[aria-expanded=true] {\n background: color-mix(in srgb, var(--_tone) 13%, var(--_surface));\n color: var(--_text);\n transform: none;\n}\nbutton.mero-node-shield__chip:hover,\nbutton.mero-node-shield__chip[aria-expanded=true] {\n border-color: var(--_tone);\n}\n.mero-node-shield__chip:focus-visible,\n.mero-node-shield-pop__btn:focus-visible {\n outline: 2px solid var(--_focus);\n outline-offset: 2px;\n}\n.mero-node-shield__icon {\n flex: none;\n color: var(--_tone);\n}\n.mero-node-shield--compact .mero-node-shield__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n}\n.mero-node-shield--compact .mero-node-shield__chip {\n width: 28px;\n padding: 0;\n justify-content: center;\n}\n@media (max-width: 560px) {\n .mero-node-shield__label {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n .mero-node-shield__chip {\n width: 28px;\n padding: 0;\n justify-content: center;\n }\n}\n@media (prefers-reduced-motion: no-preference) {\n .mero-node-shield [data-kind=checking] .mero-node-shield__icon {\n animation: mero-node-shield-pulse 1.4s ease-in-out infinite;\n }\n}\n@keyframes mero-node-shield-pulse {\n 50% {\n opacity: 0.4;\n }\n}\n.mero-node-shield-pop {\n position: fixed;\n z-index: 10000;\n box-sizing: border-box;\n width: min(340px, calc(100vw - 24px));\n overflow-y: auto;\n padding: 14px;\n border: 1px solid var(--_border);\n border-radius: 14px;\n background: var(--_surface);\n box-shadow: 0 18px 40px -16px rgba(14, 18, 34, 0.45);\n color: var(--_text);\n font-size: 12.5px;\n font-weight: 400;\n line-height: 1.45;\n text-align: left;\n}\n.mero-node-shield-pop:focus {\n outline: none;\n}\n.mero-node-shield-pop * {\n box-sizing: border-box;\n}\n.mero-node-shield-pop__title {\n display: flex;\n align-items: flex-start;\n gap: 7px;\n margin: 0;\n color: inherit;\n font-size: 13.5px;\n font-weight: 700;\n line-height: 1.35;\n}\n.mero-node-shield-pop__title .mero-node-shield__icon {\n margin-top: 1px;\n}\n.mero-node-shield-pop__sub {\n margin: 3px 0 11px;\n color: var(--_muted);\n}\n.mero-node-shield-pop__rows {\n display: flex;\n flex-direction: column;\n gap: 5px;\n margin: 0;\n}\n.mero-node-shield-pop__row {\n display: grid;\n grid-template-columns: 76px minmax(0, 1fr);\n gap: 10px;\n}\n.mero-node-shield-pop__row dt {\n margin: 0;\n color: var(--_muted);\n}\n.mero-node-shield-pop__row dd {\n margin: 0;\n overflow-wrap: anywhere;\n}\n.mero-node-shield-pop__row--bad dd {\n color: var(--_refused);\n font-weight: 600;\n}\n.mero-node-shield-pop__mono {\n font-family:\n ui-monospace,\n "SF Mono",\n SFMono-Regular,\n Menlo,\n Consolas,\n monospace;\n font-size: 11.5px;\n}\n.mero-node-shield-pop__nowrap {\n white-space: nowrap;\n}\n.mero-node-shield-pop__checks {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin: 11px 0 0;\n padding: 0;\n list-style: none;\n}\n.mero-node-shield-pop__checks li {\n display: flex;\n align-items: flex-start;\n gap: 6px;\n margin: 0;\n}\n.mero-node-shield__tick {\n flex: none;\n margin-top: 2px;\n color: var(--_tone);\n}\n.mero-node-shield-pop__buttons {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 13px;\n}\n.mero-node-shield-pop__btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n min-height: 32px;\n margin: 0;\n padding: 0 13px;\n border: 1px solid var(--_border);\n border-radius: 999px;\n background: var(--_surface);\n color: var(--_text);\n font: inherit;\n font-size: 12.5px;\n font-weight: 600;\n text-decoration: none;\n cursor: pointer;\n}\n.mero-node-shield-pop__btn:hover {\n border-color: var(--_text);\n}\n.mero-node-shield-pop__btn--primary,\n.mero-node-shield-pop__btn--primary:hover {\n border-color: transparent;\n background: var(--_text);\n color: var(--_surface);\n}\n.mero-node-shield-pop__btn--primary:hover {\n opacity: 0.88;\n}\n.mero-node-shield-pop__foot {\n margin: 8px 0 0;\n color: var(--_muted);\n font-size: 11.5px;\n}\n');
198
+ var EDGE_PX = 12;
199
+ var GAP_PX = 8;
200
+ var COPIED_MS = 2e3;
201
+ var useClientLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
202
+ var COLOR_KEYS = ["verified", "refused", "checking", "neutral", "surface", "text", "muted", "border", "focus"];
203
+ var cssName = (key) => `--node-shield-${key}`;
204
+ function colorVars(colors) {
205
+ const vars = {};
206
+ for (const key of COLOR_KEYS) if (colors?.[key]) vars[cssName(key)] = colors[key];
207
+ return vars;
208
+ }
209
+ function inheritedVars(el) {
210
+ const vars = {};
211
+ if (!el) return vars;
212
+ const style = getComputedStyle(el);
213
+ for (const key of COLOR_KEYS) {
214
+ const value = style.getPropertyValue(cssName(key)).trim();
215
+ if (value) vars[cssName(key)] = value;
216
+ }
217
+ return vars;
218
+ }
219
+ function useCopy() {
220
+ const [state, setState] = useState("idle");
221
+ useEffect(() => {
222
+ if (state === "idle") return;
223
+ const timer = setTimeout(() => setState("idle"), COPIED_MS);
224
+ return () => clearTimeout(timer);
225
+ }, [state]);
226
+ const copy2 = (text) => void Promise.resolve().then(() => navigator.clipboard.writeText(text)).then(
227
+ () => setState("done"),
228
+ () => setState("failed")
229
+ );
230
+ return [state, copy2];
231
+ }
232
+ function usePlacement(open, chip, pop) {
233
+ const [at, setAt] = useState(null);
234
+ useClientLayoutEffect(() => {
235
+ if (!open) return setAt(null);
236
+ const place = () => {
237
+ if (!chip.current || !pop.current) return;
238
+ const anchor = chip.current.getBoundingClientRect();
239
+ const { offsetWidth: width, scrollHeight: height } = pop.current;
240
+ const below = window.innerHeight - anchor.bottom - GAP_PX - EDGE_PX;
241
+ const above = anchor.top - GAP_PX - EDGE_PX;
242
+ const room = height <= below || below >= above ? below : above;
243
+ setAt({
244
+ top: room === below ? anchor.bottom + GAP_PX : anchor.top - GAP_PX - Math.min(height, room),
245
+ left: Math.min(Math.max(anchor.right - width, EDGE_PX), window.innerWidth - width - EDGE_PX),
246
+ maxHeight: Math.max(room, 0)
247
+ });
248
+ };
249
+ place();
250
+ window.addEventListener("resize", place);
251
+ window.addEventListener("scroll", place, true);
252
+ const grown = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(place);
253
+ if (pop.current) grown?.observe(pop.current);
254
+ return () => {
255
+ window.removeEventListener("resize", place);
256
+ window.removeEventListener("scroll", place, true);
257
+ grown?.disconnect();
258
+ };
259
+ }, [open, chip, pop]);
260
+ return at;
261
+ }
262
+ function useNarrowerThan(width) {
263
+ const [narrow, setNarrow] = useState(false);
264
+ useClientLayoutEffect(() => {
265
+ const query = width === void 0 || typeof window.matchMedia !== "function" ? null : `(max-width: ${width}px)`;
266
+ if (!query) return setNarrow(false);
267
+ const media = window.matchMedia(query);
268
+ const update = () => setNarrow(media.matches);
269
+ update();
270
+ media.addEventListener("change", update);
271
+ return () => media.removeEventListener("change", update);
272
+ }, [width]);
273
+ return narrow;
274
+ }
275
+ function ShieldIcon({ kind }) {
276
+ const outline = "M12 2 4 5v6c0 5 3.4 9.4 8 11 4.6-1.6 8-6 8-11V5l-8-3z";
277
+ return /* @__PURE__ */ jsxs("svg", { className: "mero-node-shield__icon", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", "aria-hidden": "true", children: [
278
+ /* @__PURE__ */ jsx("path", { d: outline, fill: "currentColor", opacity: ".18" }),
279
+ /* @__PURE__ */ jsx("path", { d: outline, stroke: "currentColor", strokeWidth: "2", strokeLinejoin: "round" }),
280
+ kind === "verified" && /* @__PURE__ */ jsx("path", { d: "m8.5 12 2.4 2.4L15.5 9.8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
281
+ kind === "refused" && /* @__PURE__ */ jsx("path", { d: "m9.5 9.5 5 5m0-5-5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }),
282
+ kind === "unsealed" && /* @__PURE__ */ jsx("path", { d: "M12 8v4.5M12 15.6v.1", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })
283
+ ] });
284
+ }
285
+ var Tick = () => /* @__PURE__ */ jsx("svg", { className: "mero-node-shield__tick", viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "m5 12.5 4.5 4.5L19 7.5", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round" }) });
286
+ var ExternalIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M14 4h6v6m0-6-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
287
+ function Popover({ view, id, style, popRef }) {
288
+ const [copied, copy2] = useCopy();
289
+ return createPortal(
290
+ /* @__PURE__ */ jsxs(
291
+ "div",
292
+ {
293
+ ref: popRef,
294
+ id,
295
+ role: "dialog",
296
+ "aria-labelledby": `${id}-title`,
297
+ tabIndex: -1,
298
+ className: "mero-node-shield-pop",
299
+ "data-kind": view.kind,
300
+ style,
301
+ "data-testid": "node-shield-popover",
302
+ children: [
303
+ /* @__PURE__ */ jsxs("h3", { id: `${id}-title`, className: "mero-node-shield-pop__title", children: [
304
+ /* @__PURE__ */ jsx(ShieldIcon, { kind: view.kind }),
305
+ view.title
306
+ ] }),
307
+ /* @__PURE__ */ jsx("p", { className: "mero-node-shield-pop__sub", children: view.sub }),
308
+ /* @__PURE__ */ jsx("dl", { className: "mero-node-shield-pop__rows", children: view.rows.map((row) => /* @__PURE__ */ jsxs("div", { className: `mero-node-shield-pop__row${row.tone === "bad" ? " mero-node-shield-pop__row--bad" : ""}`, children: [
309
+ /* @__PURE__ */ jsx("dt", { children: row.label }),
310
+ /* @__PURE__ */ jsx("dd", { className: row.mono ? "mero-node-shield-pop__mono" : void 0, title: row.full, children: row.hash ? /* @__PURE__ */ jsxs(Fragment, { children: [
311
+ row.value.slice(0, -row.hash.length),
312
+ /* @__PURE__ */ jsx("span", { className: "mero-node-shield-pop__nowrap", children: row.hash })
313
+ ] }) : row.value })
314
+ ] }, row.label)) }),
315
+ view.checks.length > 0 && /* @__PURE__ */ jsx("ul", { className: "mero-node-shield-pop__checks", children: view.checks.map((text) => /* @__PURE__ */ jsxs("li", { children: [
316
+ /* @__PURE__ */ jsx(Tick, {}),
317
+ text
318
+ ] }, text)) }),
319
+ /* @__PURE__ */ jsxs("div", { className: "mero-node-shield-pop__buttons", children: [
320
+ view.verifyUrl && /* @__PURE__ */ jsxs("a", { className: "mero-node-shield-pop__btn mero-node-shield-pop__btn--primary", href: view.verifyUrl, target: "_blank", rel: "noopener noreferrer", children: [
321
+ "Verify independently",
322
+ /* @__PURE__ */ jsx(ExternalIcon, {})
323
+ ] }),
324
+ /* @__PURE__ */ jsx("button", { type: "button", className: "mero-node-shield-pop__btn", onClick: () => copy2(shieldDetails(view)), children: copied === "done" ? "Copied" : copied === "failed" ? "Could not copy" : "Copy details" })
325
+ ] }),
326
+ view.verifyUrl && /* @__PURE__ */ jsx("p", { className: "mero-node-shield-pop__foot", children: "Opens the public verifier, which re-checks this node from outside the app." })
327
+ ]
328
+ }
329
+ ),
330
+ document.body
331
+ );
332
+ }
333
+ function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, appCode, colors }) {
334
+ const context = useContext(MeroContext);
335
+ const client = clientProp !== void 0 ? clientProp : context?.client ?? null;
336
+ const cluster = clusterProp !== void 0 ? clusterProp : context?.cluster ?? null;
337
+ const [state, refresh] = useNodeVerification(client);
338
+ const [open, setOpen] = useState(false);
339
+ const root = useRef(null);
340
+ const chip = useRef(null);
341
+ const pop = useRef(null);
342
+ const popId = useId();
343
+ const placement = usePlacement(open, chip, pop);
344
+ const compact = useNarrowerThan(compactBelow);
345
+ const real = state.status === "verified" && !state.mock;
346
+ const code = useAppCode(client, appCode, open && real ? state.url : null);
347
+ useEffect(() => {
348
+ if (!open) return;
349
+ refresh();
350
+ const close = (refocus) => {
351
+ setOpen(false);
352
+ if (refocus) chip.current?.focus();
353
+ };
354
+ const onKey = (e) => e.key === "Escape" && close(true);
355
+ const onDown = (e) => {
356
+ const target = e.target;
357
+ if (!chip.current?.contains(target) && !pop.current?.contains(target)) close(false);
358
+ };
359
+ document.addEventListener("keydown", onKey);
360
+ document.addEventListener("mousedown", onDown);
361
+ return () => {
362
+ document.removeEventListener("keydown", onKey);
363
+ document.removeEventListener("mousedown", onDown);
364
+ };
365
+ }, [open, refresh]);
366
+ const placed = placement !== null;
367
+ useEffect(() => {
368
+ if (open && placed) pop.current?.focus();
369
+ }, [open, placed]);
370
+ if (!client) return null;
371
+ const view = describeShield(state, { cluster, code });
372
+ const vars = colorVars(colors);
373
+ return /* @__PURE__ */ jsxs("span", { ref: root, className: `mero-node-shield${compact ? " mero-node-shield--compact" : ""}`, style: vars, children: [
374
+ /* @__PURE__ */ jsxs(
375
+ "button",
376
+ {
377
+ ref: chip,
378
+ type: "button",
379
+ className: "mero-node-shield__chip",
380
+ "data-kind": view.kind,
381
+ "aria-label": view.label,
382
+ "aria-haspopup": "dialog",
383
+ "aria-expanded": open,
384
+ "aria-controls": open ? popId : void 0,
385
+ onClick: () => setOpen((v) => !v),
386
+ "data-testid": "node-shield",
387
+ children: [
388
+ /* @__PURE__ */ jsx(ShieldIcon, { kind: view.kind }),
389
+ /* @__PURE__ */ jsx("span", { className: "mero-node-shield__label", children: view.label })
390
+ ]
391
+ }
392
+ ),
393
+ open && /* @__PURE__ */ jsx(
394
+ Popover,
395
+ {
396
+ view,
397
+ id: popId,
398
+ popRef: pop,
399
+ style: { ...inheritedVars(root.current), ...vars, ...placement ?? { visibility: "hidden" } }
400
+ }
401
+ )
402
+ ] });
403
+ }
404
+
405
+ export { NodeShield };
406
+ //# sourceMappingURL=node-shield.js.map
407
+ //# sourceMappingURL=node-shield.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/node-shield/nodeChecks.ts","../src/node-shield/shieldView.ts","../src/node-shield/nodeShield.css","../src/node-shield/NodeShield.tsx"],"names":["size","ago","useEffect","useState","copy"],"mappings":";;;;;;AAIA,IAAM,aAAA,GAAgB,GAAA;AACtB,IAAM,YAAA,GAAe,GAAA;AACrB,IAAM,YAAA,GAAe,GAAA;AAGrB,IAAM,UAAA,GAAa,CAAC,OAAA,KAAoB,IAAA,CAAK,IAAI,aAAA,GAAgB,CAAA,IAAK,SAAS,YAAY,CAAA;AAG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AAA,MAAA;AAAA,QACC,GAAA,EAAK,IAAA;AAAA,QACL,IAAA,EAAK,QAAA;AAAA,QACL,SAAA,EAAU,wBAAA;AAAA,QACV,aAAW,IAAA,CAAK,IAAA;AAAA,QAChB,cAAY,IAAA,CAAK,KAAA;AAAA,QACjB,eAAA,EAAc,QAAA;AAAA,QACd,eAAA,EAAe,IAAA;AAAA,QACf,eAAA,EAAe,OAAO,KAAA,GAAQ,MAAA;AAAA,QAC9B,SAAS,MAAM,OAAA,CAAQ,CAAC,CAAA,KAAM,CAAC,CAAC,CAAA;AAAA,QAChC,aAAA,EAAY,aAAA;AAAA,QAEZ,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,UAAA,EAAA,EAAW,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,CAAA;AAAA,0BAC7B,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,yBAAA,EAA2B,eAAK,KAAA,EAAM;AAAA;AAAA;AAAA,KACxD;AAAA,IACC,IAAA,oBACC,GAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,IAAA;AAAA,QACA,EAAA,EAAI,KAAA;AAAA,QACJ,MAAA,EAAQ,GAAA;AAAA,QACR,KAAA,EAAO,EAAE,GAAG,aAAA,CAAc,KAAK,OAAO,CAAA,EAAG,GAAG,IAAA,EAAM,GAAI,SAAA,IAAa,EAAE,UAAA,EAAY,UAAS;AAAG;AAAA;AAC/F,GAAA,EAEJ,CAAA;AAEJ","file":"node-shield.js","sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport type { CalimeroClient, NodeVerificationState } from '@calimero-network/mero-js';\nimport type { AppCodeCheck } from './shieldView';\n\nconst RETRY_BASE_MS = 2_000;\nconst RETRY_MAX_MS = 30_000;\nconst NODE_POLL_MS = 1_000; // how often to notice that the client failed over\n\n/** An unreachable node is asked again after 2 s, 4 s, 8 s, up to 30 s. */\nconst retryDelay = (attempt: number) => Math.min(RETRY_BASE_MS * 2 ** attempt, RETRY_MAX_MS);\n\n/** The check's outcome, or `null` for a client that cannot be checked: it stays \"checking\" instead of taking the app down. */\nasync function check(client: CalimeroClient): Promise<NodeVerificationState | null> {\n try {\n return await client.verify();\n } catch {\n return null;\n }\n}\n\nfunction peek(client: CalimeroClient | null): NodeVerificationState {\n let known: NodeVerificationState | undefined;\n try {\n known = client?.verification();\n } catch {\n // A client that cannot say is still being checked.\n }\n return known ?? { status: 'checking', url: client?.nodeUrl ?? '' };\n}\n\n/** The check of the node in use, asked again after a failure to reach it, a failover, and whenever `refresh` is called. */\nexport function useNodeVerification(client: CalimeroClient | null): [NodeVerificationState, () => void] {\n // Kept with its client: a state from the previous client is never shown for the next one.\n const [held, setHeld] = useState(() => ({ client, state: peek(client) }));\n const [round, setRound] = useState(0);\n const [url, setUrl] = useState(client?.nodeUrl);\n useEffect(() => {\n setUrl(client?.nodeUrl);\n if (!client) return;\n const poll = setInterval(() => setUrl(client.nodeUrl), NODE_POLL_MS);\n return () => clearInterval(poll);\n }, [client]);\n useEffect(() => {\n if (!client) return;\n let live = true;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const run = async (attempt: number) => {\n const next = await check(client);\n if (!live || !next) return;\n setHeld({ client, state: next });\n if (next.status === 'unreachable') timer = setTimeout(() => void run(attempt + 1), retryDelay(attempt));\n };\n setHeld({ client, state: peek(client) });\n void run(0);\n return () => {\n live = false;\n clearTimeout(timer);\n };\n }, [client, round, url]);\n const state = held.client === client ? held.state : peek(client);\n // Never describe a node the client has moved on from: compared with the node in use now, not the last poll.\n const inUse = client?.nodeUrl;\n const shown: NodeVerificationState = inUse && state.url !== inUse ? { status: 'checking', url: inUse } : state;\n return [shown, useCallback(() => setRound((n) => n + 1), [])];\n}\n\n/** The app's own check that a node runs its code; memoise it, since a new function checks again. */\nexport type AppCodeChecker = (client: CalimeroClient, url: string) => Promise<AppCodeCheck>;\n\n/** `appCode`'s answer for verified node `url`, shown only while the client, node and function are the ones it was asked for. */\nexport function useAppCode(client: CalimeroClient | null, appCode: AppCodeChecker | undefined, url: string | null): AppCodeCheck | null {\n const [result, setResult] = useState<{ client: CalimeroClient; url: string; appCode: AppCodeChecker; code: AppCodeCheck } | null>(null);\n useEffect(() => {\n if (!client || !appCode || !url) return;\n let live = true;\n void Promise.resolve()\n .then(() => appCode(client, url))\n .then(\n (code) => live && client.nodeUrl === url && setResult({ client, url, appCode, code }),\n () => undefined,\n );\n return () => {\n live = false;\n };\n }, [client, appCode, url]);\n const current = result?.client === client && result?.url === url && result?.appCode === appCode && client?.nodeUrl === url;\n return current ? result.code : null;\n}\n","/** What the node shield says about a node, from the check mero-js ran: only what that check verified. */\nimport { verifyNodeUrl, type NodeVerificationState } from '@calimero-network/mero-js';\n\nconst SEALED_PROFILE = 'locked-read-only'; // the release profile that seals a node's data\nconst JUST_NOW_SECONDS = 10;\nconst AGO = [\n ['day', 86_400],\n ['hour', 3_600],\n ['minute', 60],\n] as const;\nconst ago = new Intl.RelativeTimeFormat('en');\n\n/** Whether the node runs the app's code: `match` only when both hashes are present and equal; anything not checked is `unknown`. */\nexport type AppCodeCheck =\n | { status: 'match'; appHash: string; checkedAt: number; package?: string; version?: string }\n | { status: 'mismatch'; appHash: string; expected: string }\n | { status: 'unknown'; reason: string };\n\nexport type ShieldKind = 'checking' | 'verified' | 'unsealed' | 'refused';\n\nexport interface ShieldRow {\n label: string;\n value: string;\n /** What `value` abbreviates, for the copied details. */\n full?: string;\n mono?: boolean;\n tone?: 'bad';\n /** The short hash that ends `value`, kept on one line. */\n hash?: string;\n}\n\nexport interface ShieldView {\n kind: ShieldKind;\n /** The chip's text. */\n label: string;\n title: string;\n sub: string;\n rows: ShieldRow[];\n /** Facts the check verified for this node, and nothing else. */\n checks: string[];\n /** The public verifier's page for this node; `null` unless a signed release judged a real quote. */\n verifyUrl: string | null;\n}\n\nconst SHIELD_LABEL: Record<ShieldKind, string> = {\n checking: 'Checking node…',\n verified: 'Verified node',\n unsealed: 'Test server: not sealed',\n refused: 'Node refused',\n};\n\n/** Sealed means the locked profile on a real quote; `unreachable` is no answer yet, so it reads as checking. */\nexport function shieldKind(state: NodeVerificationState): ShieldKind {\n if (state.status === 'refused') return 'refused';\n if (state.status !== 'verified') return 'checking';\n return !state.mock && state.profile === SEALED_PROFILE ? 'verified' : 'unsealed';\n}\n\n/** \"2 minutes ago\", or \"just now\" for the last few seconds. */\nexport function checkedAgo(at: number, now: number = Date.now()): string {\n const seconds = Math.max(0, Math.round((now - at) / 1000));\n if (seconds < JUST_NOW_SECONDS) return 'just now';\n const [unit, size] = AGO.find(([, size]) => seconds >= size) ?? (['second', 1] as const);\n return ago.format(-Math.floor(seconds / size), unit);\n}\n\n/** `7f3a…c91e`. */\nexport function shortHash(hash: string): string {\n return hash.length > 12 ? `${hash.slice(0, 4)}…${hash.slice(-4)}` : hash;\n}\n\nfunction hostOf(url: string): string {\n try {\n return new URL(url).host;\n } catch {\n return url;\n }\n}\n\nfunction releaseName(code: Extract<AppCodeCheck, { status: 'match' }>): string | null {\n return code.package && code.version ? `${code.package} v${code.version}` : null;\n}\n\nfunction codeRow(code: AppCodeCheck | null): ShieldRow | null {\n if (code?.status === 'match') {\n const named = releaseName(code);\n return {\n label: 'App code',\n value: named ? `${named} · ${shortHash(code.appHash)}` : shortHash(code.appHash),\n full: named ? `${named} · ${code.appHash}` : code.appHash,\n mono: true,\n hash: shortHash(code.appHash),\n };\n }\n if (code?.status === 'mismatch') {\n return {\n label: 'App code',\n value: `Does not match this app's release (node runs ${shortHash(code.appHash)})`,\n full: `Does not match this app's release (node runs ${code.appHash}, expected ${code.expected})`,\n tone: 'bad',\n };\n }\n return null;\n}\n\nfunction copy(state: NodeVerificationState, kind: ShieldKind, ago: string): Pick<ShieldView, 'title' | 'sub'> {\n switch (kind) {\n case 'verified':\n return {\n title: 'You are talking to a genuine Calimero TEE node',\n sub: `Checked by this browser ${ago}, before anything was sent.`,\n };\n case 'unsealed':\n return {\n title: SHIELD_LABEL.unsealed,\n sub:\n state.status === 'verified' && state.mock\n ? `A test server with no hardware enclave, so its data is not sealed. Checked by this browser ${ago}.`\n : `This node did not show it runs the sealed, read-only profile, so its data is not sealed. Checked by this browser ${ago}.`,\n };\n case 'refused':\n return { title: SHIELD_LABEL.refused, sub: 'This app refused the node and sent nothing.' };\n case 'checking':\n return {\n title: SHIELD_LABEL.checking,\n sub:\n state.status === 'unreachable'\n ? 'The node could not be reached. Trying again.'\n : 'This browser is checking the node before anything is sent.',\n };\n }\n}\n\n/** Everything the chip and popover show for `state`, in `cluster`, with the app's code check. */\nexport function describeShield(\n state: NodeVerificationState,\n { cluster, code, now = Date.now() }: { cluster?: string | null; code: AppCodeCheck | null; now?: number },\n): ShieldView {\n const kind = shieldKind(state);\n // A mock is never a real node: nothing about releases or app code is claimed for one.\n const real = state.status === 'verified' && !state.mock ? state : null;\n const release = real?.release;\n const rows: ShieldRow[] = [];\n if (cluster) rows.push({ label: 'Cluster', value: cluster });\n rows.push({ label: 'Node', value: hostOf(state.url), full: state.url, mono: true });\n if (real && release) rows.push({ label: 'Software', value: `mero-tee v${release}${real.profile ? ` · ${real.profile}` : ''}` });\n const app = real ? codeRow(code) : null;\n if (app) rows.push(app);\n if (state.status === 'refused' || state.status === 'unreachable') {\n rows.push({ label: 'Reason', value: state.reason, ...(state.status === 'refused' ? { tone: 'bad' as const } : {}) });\n }\n const checked = 'checkedAt' in state ? checkedAgo(state.checkedAt, now) : null;\n if (checked) rows.push({ label: 'Checked', value: checked });\n\n const checks: string[] = [];\n if (kind === 'verified') checks.push('Running in an Intel TDX enclave (not debug)');\n if (real && release) checks.push(`Measurements match the signed v${release} release`);\n if (real) checks.push(\"Your connection is encrypted to this enclave's key\");\n if (app && code?.status === 'match') {\n const named = releaseName(code);\n checks.push(named ? `Node runs the code listed for ${named}` : 'Node runs the code bundle this app was built for');\n }\n\n return {\n kind,\n label: SHIELD_LABEL[kind],\n ...copy(state, kind, checked ?? 'just now'),\n rows,\n checks,\n verifyUrl: real && release ? verifyNodeUrl(real.url, release) : null,\n };\n}\n\n/** The popover's facts as plain text, for \"Copy details\". */\nexport function shieldDetails(view: ShieldView): string {\n return [\n view.title,\n view.sub,\n '',\n ...view.rows.map((r) => `${r.label}: ${r.full ?? r.value}`),\n ...(view.checks.length ? ['', ...view.checks.map((c) => `- ${c}`)] : []),\n ].join('\\n');\n}\n","import styleInject from '#style-inject';styleInject(\".mero-node-shield,\\n.mero-node-shield-pop {\\n --_verified: var(--node-shield-verified, #0b7a4b);\\n --_refused: var(--node-shield-refused, #c1264e);\\n --_checking: var(--node-shield-checking, #3451d1);\\n --_neutral: var(--node-shield-neutral, #687086);\\n --_surface: var(--node-shield-surface, #ffffff);\\n --_text: var(--node-shield-text, #0e1222);\\n --_muted: var(--node-shield-muted, #5d6377);\\n --_border: var(--node-shield-border, rgba(14, 18, 34, 0.14));\\n --_focus: var(--node-shield-focus, #3e63f5);\\n --_tone: var(--_neutral);\\n}\\n@media (prefers-color-scheme: dark) {\\n .mero-node-shield,\\n .mero-node-shield-pop {\\n --_verified: var(--node-shield-verified, #4fd08f);\\n --_refused: var(--node-shield-refused, #f47c9c);\\n --_checking: var(--node-shield-checking, #93a8ff);\\n --_neutral: var(--node-shield-neutral, #9aa1b4);\\n --_surface: var(--node-shield-surface, #161b2b);\\n --_text: var(--node-shield-text, #eceef5);\\n --_muted: var(--node-shield-muted, #9aa0b4);\\n --_border: var(--node-shield-border, rgba(255, 255, 255, 0.16));\\n --_focus: var(--node-shield-focus, #9aafff);\\n }\\n}\\n.mero-node-shield [data-kind=verified],\\n.mero-node-shield-pop[data-kind=verified] {\\n --_tone: var(--_verified);\\n}\\n.mero-node-shield [data-kind=refused],\\n.mero-node-shield-pop[data-kind=refused] {\\n --_tone: var(--_refused);\\n}\\n.mero-node-shield [data-kind=checking],\\n.mero-node-shield-pop[data-kind=checking] {\\n --_tone: var(--_checking);\\n}\\n.mero-node-shield {\\n display: inline-flex;\\n flex: none;\\n vertical-align: middle;\\n}\\n.mero-node-shield__chip {\\n box-sizing: border-box;\\n display: inline-flex;\\n align-items: center;\\n gap: 6px;\\n height: 28px;\\n margin: 0;\\n padding: 0 11px 0 8px;\\n border: 1px solid color-mix(in srgb, var(--_tone) 40%, transparent);\\n border-radius: 999px;\\n background: color-mix(in srgb, var(--_tone) 13%, var(--_surface));\\n color: var(--_text);\\n font: inherit;\\n font-size: 12px;\\n font-weight: 600;\\n line-height: 1;\\n white-space: nowrap;\\n cursor: pointer;\\n transition: border-color 0.15s ease;\\n}\\nbutton.mero-node-shield__chip:hover,\\nbutton.mero-node-shield__chip:focus,\\nbutton.mero-node-shield__chip:active,\\nbutton.mero-node-shield__chip[aria-expanded=true] {\\n background: color-mix(in srgb, var(--_tone) 13%, var(--_surface));\\n color: var(--_text);\\n transform: none;\\n}\\nbutton.mero-node-shield__chip:hover,\\nbutton.mero-node-shield__chip[aria-expanded=true] {\\n border-color: var(--_tone);\\n}\\n.mero-node-shield__chip:focus-visible,\\n.mero-node-shield-pop__btn:focus-visible {\\n outline: 2px solid var(--_focus);\\n outline-offset: 2px;\\n}\\n.mero-node-shield__icon {\\n flex: none;\\n color: var(--_tone);\\n}\\n.mero-node-shield--compact .mero-node-shield__label {\\n position: absolute;\\n width: 1px;\\n height: 1px;\\n overflow: hidden;\\n clip-path: inset(50%);\\n white-space: nowrap;\\n}\\n.mero-node-shield--compact .mero-node-shield__chip {\\n width: 28px;\\n padding: 0;\\n justify-content: center;\\n}\\n@media (max-width: 560px) {\\n .mero-node-shield__label {\\n position: absolute;\\n width: 1px;\\n height: 1px;\\n overflow: hidden;\\n clip-path: inset(50%);\\n white-space: nowrap;\\n }\\n .mero-node-shield__chip {\\n width: 28px;\\n padding: 0;\\n justify-content: center;\\n }\\n}\\n@media (prefers-reduced-motion: no-preference) {\\n .mero-node-shield [data-kind=checking] .mero-node-shield__icon {\\n animation: mero-node-shield-pulse 1.4s ease-in-out infinite;\\n }\\n}\\n@keyframes mero-node-shield-pulse {\\n 50% {\\n opacity: 0.4;\\n }\\n}\\n.mero-node-shield-pop {\\n position: fixed;\\n z-index: 10000;\\n box-sizing: border-box;\\n width: min(340px, calc(100vw - 24px));\\n overflow-y: auto;\\n padding: 14px;\\n border: 1px solid var(--_border);\\n border-radius: 14px;\\n background: var(--_surface);\\n box-shadow: 0 18px 40px -16px rgba(14, 18, 34, 0.45);\\n color: var(--_text);\\n font-size: 12.5px;\\n font-weight: 400;\\n line-height: 1.45;\\n text-align: left;\\n}\\n.mero-node-shield-pop:focus {\\n outline: none;\\n}\\n.mero-node-shield-pop * {\\n box-sizing: border-box;\\n}\\n.mero-node-shield-pop__title {\\n display: flex;\\n align-items: flex-start;\\n gap: 7px;\\n margin: 0;\\n color: inherit;\\n font-size: 13.5px;\\n font-weight: 700;\\n line-height: 1.35;\\n}\\n.mero-node-shield-pop__title .mero-node-shield__icon {\\n margin-top: 1px;\\n}\\n.mero-node-shield-pop__sub {\\n margin: 3px 0 11px;\\n color: var(--_muted);\\n}\\n.mero-node-shield-pop__rows {\\n display: flex;\\n flex-direction: column;\\n gap: 5px;\\n margin: 0;\\n}\\n.mero-node-shield-pop__row {\\n display: grid;\\n grid-template-columns: 76px minmax(0, 1fr);\\n gap: 10px;\\n}\\n.mero-node-shield-pop__row dt {\\n margin: 0;\\n color: var(--_muted);\\n}\\n.mero-node-shield-pop__row dd {\\n margin: 0;\\n overflow-wrap: anywhere;\\n}\\n.mero-node-shield-pop__row--bad dd {\\n color: var(--_refused);\\n font-weight: 600;\\n}\\n.mero-node-shield-pop__mono {\\n font-family:\\n ui-monospace,\\n \\\"SF Mono\\\",\\n SFMono-Regular,\\n Menlo,\\n Consolas,\\n monospace;\\n font-size: 11.5px;\\n}\\n.mero-node-shield-pop__nowrap {\\n white-space: nowrap;\\n}\\n.mero-node-shield-pop__checks {\\n display: flex;\\n flex-direction: column;\\n gap: 4px;\\n margin: 11px 0 0;\\n padding: 0;\\n list-style: none;\\n}\\n.mero-node-shield-pop__checks li {\\n display: flex;\\n align-items: flex-start;\\n gap: 6px;\\n margin: 0;\\n}\\n.mero-node-shield__tick {\\n flex: none;\\n margin-top: 2px;\\n color: var(--_tone);\\n}\\n.mero-node-shield-pop__buttons {\\n display: flex;\\n flex-wrap: wrap;\\n gap: 8px;\\n margin-top: 13px;\\n}\\n.mero-node-shield-pop__btn {\\n display: inline-flex;\\n align-items: center;\\n justify-content: center;\\n gap: 6px;\\n min-height: 32px;\\n margin: 0;\\n padding: 0 13px;\\n border: 1px solid var(--_border);\\n border-radius: 999px;\\n background: var(--_surface);\\n color: var(--_text);\\n font: inherit;\\n font-size: 12.5px;\\n font-weight: 600;\\n text-decoration: none;\\n cursor: pointer;\\n}\\n.mero-node-shield-pop__btn:hover {\\n border-color: var(--_text);\\n}\\n.mero-node-shield-pop__btn--primary,\\n.mero-node-shield-pop__btn--primary:hover {\\n border-color: transparent;\\n background: var(--_text);\\n color: var(--_surface);\\n}\\n.mero-node-shield-pop__btn--primary:hover {\\n opacity: 0.88;\\n}\\n.mero-node-shield-pop__foot {\\n margin: 8px 0 0;\\n color: var(--_muted);\\n font-size: 11.5px;\\n}\\n\")","import React, { useContext, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport type { CalimeroClient } from '@calimero-network/mero-js';\nimport { MeroContext } from '../context/context';\nimport { useAppCode, useNodeVerification, type AppCodeChecker } from './nodeChecks';\nimport { describeShield, shieldDetails, type ShieldKind, type ShieldView } from './shieldView';\nimport './nodeShield.css';\n\nconst EDGE_PX = 12; // the popover's distance from the viewport's edge\nconst GAP_PX = 8; // and from the chip\nconst COPIED_MS = 2_000; // how long \"Copied\" shows\n// Layout effects warn on the server, where there is no layout to measure.\nconst useClientLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\nconst COLOR_KEYS = ['verified', 'refused', 'checking', 'neutral', 'surface', 'text', 'muted', 'border', 'focus'] as const;\n\n/** Colours for the shield; each sets the `--node-shield-<key>` CSS custom property of the same name. */\nexport type NodeShieldColors = Partial<Record<(typeof COLOR_KEYS)[number], string>>;\n\nexport interface NodeShieldProps {\n /** The client whose node is checked; by default the `MeroProvider`'s. `null` shows nothing. */\n client?: CalimeroClient | null;\n /** The label shown as \"Cluster\"; by default the `MeroProvider`'s cluster. `null` leaves the row out. */\n cluster?: string | null;\n /** Icon only when the window is this many px wide or narrower (always at 560px or narrower). */\n compactBelow?: number;\n /** The app's own check that node `url` runs its code, asked when the popover opens on a real, verified node. Memoise it. */\n appCode?: AppCodeChecker;\n /** Colours, as an alternative to setting the `--node-shield-*` custom properties in CSS. */\n colors?: NodeShieldColors;\n}\n\nconst cssName = (key: string) => `--node-shield-${key}`;\n\nfunction colorVars(colors: NodeShieldColors | undefined): Record<string, string> {\n const vars: Record<string, string> = {};\n for (const key of COLOR_KEYS) if (colors?.[key]) vars[cssName(key)] = colors[key]!;\n return vars;\n}\n\n/** The colour properties the chip resolves from its ancestors, for the popover, which renders in `document.body`. */\nfunction inheritedVars(el: HTMLElement | null): Record<string, string> {\n const vars: Record<string, string> = {};\n if (!el) return vars;\n const style = getComputedStyle(el);\n for (const key of COLOR_KEYS) {\n const value = style.getPropertyValue(cssName(key)).trim();\n if (value) vars[cssName(key)] = value;\n }\n return vars;\n}\n\ntype CopyState = 'idle' | 'done' | 'failed';\n\n/** Copies text to the clipboard; the result shows for two seconds. Never throws, with or without a clipboard. */\nfunction useCopy(): [CopyState, (text: string) => void] {\n const [state, setState] = useState<CopyState>('idle');\n useEffect(() => {\n if (state === 'idle') return;\n const timer = setTimeout(() => setState('idle'), COPIED_MS);\n return () => clearTimeout(timer);\n }, [state]);\n const copy = (text: string) =>\n void Promise.resolve()\n .then(() => navigator.clipboard.writeText(text))\n .then(\n () => setState('done'),\n () => setState('failed'),\n );\n return [state, copy];\n}\n\ntype Placement = { top: number; left: number; maxHeight: number } | null;\n\n/** Right edges aligned with the chip, below it or above when that is where the room is, inside the viewport. */\nfunction usePlacement(open: boolean, chip: React.RefObject<HTMLElement>, pop: React.RefObject<HTMLElement>): Placement {\n const [at, setAt] = useState<Placement>(null);\n useClientLayoutEffect(() => {\n if (!open) return setAt(null);\n const place = () => {\n if (!chip.current || !pop.current) return;\n const anchor = chip.current.getBoundingClientRect();\n const { offsetWidth: width, scrollHeight: height } = pop.current;\n const below = window.innerHeight - anchor.bottom - GAP_PX - EDGE_PX;\n const above = anchor.top - GAP_PX - EDGE_PX;\n const room = height <= below || below >= above ? below : above;\n setAt({\n top: room === below ? anchor.bottom + GAP_PX : anchor.top - GAP_PX - Math.min(height, room),\n left: Math.min(Math.max(anchor.right - width, EDGE_PX), window.innerWidth - width - EDGE_PX),\n maxHeight: Math.max(room, 0),\n });\n };\n place();\n window.addEventListener('resize', place);\n window.addEventListener('scroll', place, true);\n // The popover grows when the app code check arrives: re-place it so it stays clear of the chip.\n const grown = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(place);\n if (pop.current) grown?.observe(pop.current);\n return () => {\n window.removeEventListener('resize', place);\n window.removeEventListener('scroll', place, true);\n grown?.disconnect();\n };\n }, [open, chip, pop]);\n return at;\n}\n\n/** Whether the window is `width` px wide or narrower; never without a width or a `matchMedia`. */\nfunction useNarrowerThan(width: number | undefined): boolean {\n const [narrow, setNarrow] = useState(false);\n // Measured after mount, never during render: the server and the first browser render agree.\n useClientLayoutEffect(() => {\n const query = width === undefined || typeof window.matchMedia !== 'function' ? null : `(max-width: ${width}px)`;\n if (!query) return setNarrow(false);\n const media = window.matchMedia(query);\n const update = () => setNarrow(media.matches);\n update();\n media.addEventListener('change', update);\n return () => media.removeEventListener('change', update);\n }, [width]);\n return narrow;\n}\n\nfunction ShieldIcon({ kind }: { kind: ShieldKind }) {\n const outline = 'M12 2 4 5v6c0 5 3.4 9.4 8 11 4.6-1.6 8-6 8-11V5l-8-3z';\n return (\n <svg className=\"mero-node-shield__icon\" viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" aria-hidden=\"true\">\n <path d={outline} fill=\"currentColor\" opacity=\".18\" />\n <path d={outline} stroke=\"currentColor\" strokeWidth=\"2\" strokeLinejoin=\"round\" />\n {kind === 'verified' && <path d=\"m8.5 12 2.4 2.4L15.5 9.8\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />}\n {kind === 'refused' && <path d=\"m9.5 9.5 5 5m0-5-5 5\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" />}\n {kind === 'unsealed' && <path d=\"M12 8v4.5M12 15.6v.1\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" />}\n </svg>\n );\n}\n\nconst Tick = () => (\n <svg className=\"mero-node-shield__tick\" viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"m5 12.5 4.5 4.5L19 7.5\" stroke=\"currentColor\" strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n);\n\nconst ExternalIcon = () => (\n <svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M14 4h6v6m0-6-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n);\n\ninterface PopoverProps {\n view: ShieldView;\n id: string;\n style: React.CSSProperties;\n popRef: React.RefObject<HTMLDivElement>;\n}\n\nfunction Popover({ view, id, style, popRef }: PopoverProps) {\n const [copied, copy] = useCopy();\n return createPortal(\n <div\n ref={popRef}\n id={id}\n role=\"dialog\"\n aria-labelledby={`${id}-title`}\n tabIndex={-1}\n className=\"mero-node-shield-pop\"\n data-kind={view.kind}\n style={style}\n data-testid=\"node-shield-popover\"\n >\n <h3 id={`${id}-title`} className=\"mero-node-shield-pop__title\">\n <ShieldIcon kind={view.kind} />\n {view.title}\n </h3>\n <p className=\"mero-node-shield-pop__sub\">{view.sub}</p>\n <dl className=\"mero-node-shield-pop__rows\">\n {view.rows.map((row) => (\n <div key={row.label} className={`mero-node-shield-pop__row${row.tone === 'bad' ? ' mero-node-shield-pop__row--bad' : ''}`}>\n <dt>{row.label}</dt>\n <dd className={row.mono ? 'mero-node-shield-pop__mono' : undefined} title={row.full}>\n {row.hash ? (\n <>\n {row.value.slice(0, -row.hash.length)}\n <span className=\"mero-node-shield-pop__nowrap\">{row.hash}</span>\n </>\n ) : (\n row.value\n )}\n </dd>\n </div>\n ))}\n </dl>\n {view.checks.length > 0 && (\n <ul className=\"mero-node-shield-pop__checks\">\n {view.checks.map((text) => (\n <li key={text}>\n <Tick />\n {text}\n </li>\n ))}\n </ul>\n )}\n <div className=\"mero-node-shield-pop__buttons\">\n {view.verifyUrl && (\n <a className=\"mero-node-shield-pop__btn mero-node-shield-pop__btn--primary\" href={view.verifyUrl} target=\"_blank\" rel=\"noopener noreferrer\">\n Verify independently\n <ExternalIcon />\n </a>\n )}\n <button type=\"button\" className=\"mero-node-shield-pop__btn\" onClick={() => copy(shieldDetails(view))}>\n {copied === 'done' ? 'Copied' : copied === 'failed' ? 'Could not copy' : 'Copy details'}\n </button>\n </div>\n {view.verifyUrl && <p className=\"mero-node-shield-pop__foot\">Opens the public verifier, which re-checks this node from outside the app.</p>}\n </div>,\n document.body,\n );\n}\n\n/**\n * A header chip for the node `client` talks to, with a popover of what the browser's check verified.\n * Renders nothing until there is a client.\n */\nexport function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, appCode, colors }: NodeShieldProps) {\n const context = useContext(MeroContext);\n const client = clientProp !== undefined ? clientProp : (context?.client ?? null);\n const cluster = clusterProp !== undefined ? clusterProp : (context?.cluster ?? null);\n const [state, refresh] = useNodeVerification(client);\n const [open, setOpen] = useState(false);\n const root = useRef<HTMLSpanElement>(null);\n const chip = useRef<HTMLButtonElement>(null);\n const pop = useRef<HTMLDivElement>(null);\n const popId = useId();\n const placement = usePlacement(open, chip, pop);\n const compact = useNarrowerThan(compactBelow);\n const real = state.status === 'verified' && !state.mock;\n const code = useAppCode(client, appCode, open && real ? state.url : null);\n\n useEffect(() => {\n if (!open) return;\n refresh();\n const close = (refocus: boolean) => {\n setOpen(false);\n if (refocus) chip.current?.focus();\n };\n const onKey = (e: KeyboardEvent) => e.key === 'Escape' && close(true);\n const onDown = (e: MouseEvent) => {\n const target = e.target as Node;\n if (!chip.current?.contains(target) && !pop.current?.contains(target)) close(false);\n };\n document.addEventListener('keydown', onKey);\n document.addEventListener('mousedown', onDown);\n return () => {\n document.removeEventListener('keydown', onKey);\n document.removeEventListener('mousedown', onDown);\n };\n }, [open, refresh]);\n\n // Focus waits for the placement: a popover still hidden for it cannot take focus.\n const placed = placement !== null;\n useEffect(() => {\n if (open && placed) pop.current?.focus();\n }, [open, placed]);\n\n if (!client) return null;\n const view = describeShield(state, { cluster, code });\n const vars = colorVars(colors);\n return (\n <span ref={root} className={`mero-node-shield${compact ? ' mero-node-shield--compact' : ''}`} style={vars}>\n <button\n ref={chip}\n type=\"button\"\n className=\"mero-node-shield__chip\"\n data-kind={view.kind}\n aria-label={view.label}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? popId : undefined}\n onClick={() => setOpen((v) => !v)}\n data-testid=\"node-shield\"\n >\n <ShieldIcon kind={view.kind} />\n <span className=\"mero-node-shield__label\">{view.label}</span>\n </button>\n {open && (\n <Popover\n view={view}\n id={popId}\n popRef={pop}\n style={{ ...inheritedVars(root.current), ...vars, ...(placement ?? { visibility: 'hidden' }) }}\n />\n )}\n </span>\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calimero-network/mero-react",
3
- "version": "11.1.4",
3
+ "version": "11.2.0",
4
4
  "description": "React bindings for the Calimero 1.0 client (mero-js CalimeroClient)",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -11,6 +11,11 @@
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs"
14
+ },
15
+ "./node-shield": {
16
+ "types": "./dist/node-shield.d.ts",
17
+ "import": "./dist/node-shield.js",
18
+ "require": "./dist/node-shield.cjs"
14
19
  }
15
20
  },
16
21
  "files": [
@@ -28,7 +33,7 @@
28
33
  "prepublishOnly": "pnpm build && pnpm typecheck"
29
34
  },
30
35
  "dependencies": {
31
- "@calimero-network/mero-js": "^33.0.0"
36
+ "@calimero-network/mero-js": "^35.3.0"
32
37
  },
33
38
  "peerDependencies": {
34
39
  "react": "^18.0.0 || ^19.0.0",