@calimero-network/mero-react 11.2.0 → 11.3.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.
package/README.md CHANGED
@@ -306,8 +306,21 @@ Props, all optional:
306
306
  - `cluster`: the label shown as "Cluster"; by default the provider's cluster. `cluster={null}` leaves the row out.
307
307
  - `compactBelow`: the window width in px at or below which the chip is the icon alone. It is always the icon alone at 560px or narrower.
308
308
  - `appCode`: `(client, url) => Promise<AppCodeCheck>`, the app's own check that node `url` runs its code. It is asked when the popover opens on a real, verified node, and its `match` or `mismatch` is shown as the "App code" row. A new function checks again, so memoise it (`useCallback`).
309
+ - `compact`: `true` shows the chip as the icon alone at every width, whatever `compactBelow` says; for a floating chip.
310
+ - `open` and `onOpenChange`: the popover's open state. Leave `open` out and the shield keeps its own; set it and the shield is controlled, opening and closing only when `open` changes. `onOpenChange(open)` is called either way when the shield asks to change it: on a chip click, Escape or an outside click.
309
311
  - `colors`: colours for this shield (below).
310
312
 
313
+ A floating chip, icon only, that a menu item can also open:
314
+
315
+ ```tsx
316
+ const [shieldOpen, setShieldOpen] = useState(false);
317
+
318
+ <NodeShield compact open={shieldOpen} onOpenChange={setShieldOpen} />
319
+ <button onClick={() => setShieldOpen(true)}>Node details</button>
320
+ ```
321
+
322
+ Opening it from code behaves like a click: the popover is placed by the chip, takes focus and runs the app code check, and closing it returns focus to the chip.
323
+
311
324
  `AppCodeCheck` is the shape an app's own code check returns:
312
325
 
313
326
  ```ts
@@ -286,8 +286,14 @@ function ShieldIcon({ kind }) {
286
286
  }
287
287
  var Tick = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "mero-node-shield__tick", viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m5 12.5 4.5 4.5L19 7.5", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round" }) });
288
288
  var ExternalIcon = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.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" }) });
289
- function Popover({ view, id, style, popRef }) {
289
+ function Popover({ view, id, style, popRef, chipRef }) {
290
290
  const [copied, copy2] = useCopy();
291
+ useClientLayoutEffect(() => {
292
+ const el = popRef.current;
293
+ return () => {
294
+ if (el?.contains(document.activeElement)) chipRef.current?.focus();
295
+ };
296
+ }, [popRef, chipRef]);
291
297
  return reactDom.createPortal(
292
298
  /* @__PURE__ */ jsxRuntime.jsxs(
293
299
  "div",
@@ -332,31 +338,47 @@ function Popover({ view, id, style, popRef }) {
332
338
  document.body
333
339
  );
334
340
  }
335
- function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, appCode, colors }) {
341
+ function NodeShield({
342
+ client: clientProp,
343
+ cluster: clusterProp,
344
+ compactBelow,
345
+ compact: compactProp = false,
346
+ open: openProp,
347
+ onOpenChange,
348
+ appCode,
349
+ colors
350
+ }) {
336
351
  const context = react.useContext(chunkPYCIYVHN_cjs.MeroContext);
337
352
  const client = clientProp !== void 0 ? clientProp : context?.client ?? null;
338
353
  const cluster = clusterProp !== void 0 ? clusterProp : context?.cluster ?? null;
339
354
  const [state, refresh] = useNodeVerification(client);
340
- const [open, setOpen] = react.useState(false);
355
+ const [ownOpen, setOwnOpen] = react.useState(false);
356
+ const controlled = openProp !== void 0;
357
+ const open = controlled ? openProp : ownOpen;
358
+ const setOpen = react.useCallback(
359
+ (next) => {
360
+ if (!controlled) setOwnOpen(next);
361
+ onOpenChange?.(next);
362
+ },
363
+ [controlled, onOpenChange]
364
+ );
341
365
  const root = react.useRef(null);
342
366
  const chip = react.useRef(null);
343
367
  const pop = react.useRef(null);
344
368
  const popId = react.useId();
345
369
  const placement = usePlacement(open, chip, pop);
346
- const compact = useNarrowerThan(compactBelow);
370
+ const compact = useNarrowerThan(compactProp ? void 0 : compactBelow) || compactProp;
347
371
  const real = state.status === "verified" && !state.mock;
348
372
  const code = useAppCode(client, appCode, open && real ? state.url : null);
373
+ react.useEffect(() => {
374
+ if (open) refresh();
375
+ }, [open, refresh]);
349
376
  react.useEffect(() => {
350
377
  if (!open) return;
351
- refresh();
352
- const close = (refocus) => {
353
- setOpen(false);
354
- if (refocus) chip.current?.focus();
355
- };
356
- const onKey = (e) => e.key === "Escape" && close(true);
378
+ const onKey = (e) => e.key === "Escape" && setOpen(false);
357
379
  const onDown = (e) => {
358
380
  const target = e.target;
359
- if (!chip.current?.contains(target) && !pop.current?.contains(target)) close(false);
381
+ if (!chip.current?.contains(target) && !pop.current?.contains(target)) setOpen(false);
360
382
  };
361
383
  document.addEventListener("keydown", onKey);
362
384
  document.addEventListener("mousedown", onDown);
@@ -364,7 +386,7 @@ function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, ap
364
386
  document.removeEventListener("keydown", onKey);
365
387
  document.removeEventListener("mousedown", onDown);
366
388
  };
367
- }, [open, refresh]);
389
+ }, [open, setOpen]);
368
390
  const placed = placement !== null;
369
391
  react.useEffect(() => {
370
392
  if (open && placed) pop.current?.focus();
@@ -384,7 +406,7 @@ function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, ap
384
406
  "aria-haspopup": "dialog",
385
407
  "aria-expanded": open,
386
408
  "aria-controls": open ? popId : void 0,
387
- onClick: () => setOpen((v) => !v),
409
+ onClick: () => setOpen(!open),
388
410
  "data-testid": "node-shield",
389
411
  children: [
390
412
  /* @__PURE__ */ jsxRuntime.jsx(ShieldIcon, { kind: view.kind }),
@@ -398,6 +420,7 @@ function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, ap
398
420
  view,
399
421
  id: popId,
400
422
  popRef: pop,
423
+ chipRef: chip,
401
424
  style: { ...inheritedVars(root.current), ...vars, ...placement ?? { visibility: "hidden" } }
402
425
  }
403
426
  )
@@ -1 +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":["useState","useEffect","useCallback","size","ago","verifyNodeUrl","styleInject","useLayoutEffect","copy","jsxs","jsx","createPortal","Fragment","useContext","MeroContext","useRef","useId"],"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;AAG3F,eAAe,MAAM,MAAA,EAA+D;AAClF,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,OAAO,MAAA,EAAO;AAAA,EAC7B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,SAAS,KAAK,MAAA,EAAsD;AAClE,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI;AACF,IAAA,KAAA,GAAQ,QAAQ,YAAA,EAAa;AAAA,EAC/B,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,SAAS,EAAE,MAAA,EAAQ,YAAY,GAAA,EAAK,MAAA,EAAQ,WAAW,EAAA,EAAG;AACnE;AAGO,SAAS,oBAAoB,MAAA,EAAoE;AAEtG,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAIA,cAAA,CAAS,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,IAAA,CAAK,MAAM,CAAA,EAAE,CAAE,CAAA;AACxE,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,eAAS,CAAC,CAAA;AACpC,EAAA,MAAM,CAAC,GAAA,EAAK,MAAM,CAAA,GAAIA,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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.cjs","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"]}
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":["useState","useEffect","useCallback","size","ago","verifyNodeUrl","styleInject","useLayoutEffect","copy","jsxs","jsx","createPortal","Fragment","useContext","MeroContext","useRef","useId"],"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;AAG3F,eAAe,MAAM,MAAA,EAA+D;AAClF,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,OAAO,MAAA,EAAO;AAAA,EAC7B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,SAAS,KAAK,MAAA,EAAsD;AAClE,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI;AACF,IAAA,KAAA,GAAQ,QAAQ,YAAA,EAAa;AAAA,EAC/B,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,SAAS,EAAE,MAAA,EAAQ,YAAY,GAAA,EAAK,MAAA,EAAQ,WAAW,EAAA,EAAG;AACnE;AAGO,SAAS,oBAAoB,MAAA,EAAoE;AAEtG,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAIA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'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, { useCallback, 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 /** Icon only at every width, whatever `compactBelow` says. */\n compact?: boolean;\n /** Whether the popover is open; set it to control the shield, leave it out to let the shield keep its own state. */\n open?: boolean;\n /** Called with the open state the shield asks for: on a chip click, Escape or an outside click. */\n onOpenChange?: (open: boolean) => void;\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 chipRef: React.RefObject<HTMLButtonElement>;\n}\n\nfunction Popover({ view, id, style, popRef, chipRef }: PopoverProps) {\n const [copied, copy] = useCopy();\n // A layout cleanup runs before the popover leaves the DOM, while it can still tell whether it holds focus.\n useClientLayoutEffect(() => {\n const el = popRef.current;\n return () => {\n if (el?.contains(document.activeElement)) chipRef.current?.focus();\n };\n }, [popRef, chipRef]);\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({\n client: clientProp,\n cluster: clusterProp,\n compactBelow,\n compact: compactProp = false,\n open: openProp,\n onOpenChange,\n appCode,\n colors,\n}: 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 [ownOpen, setOwnOpen] = useState(false);\n const controlled = openProp !== undefined;\n const open = controlled ? openProp : ownOpen;\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setOwnOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\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(compactProp ? undefined : compactBelow) || compactProp;\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) refresh();\n }, [open, refresh]);\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === 'Escape' && setOpen(false);\n const onDown = (e: MouseEvent) => {\n const target = e.target as Node;\n if (!chip.current?.contains(target) && !pop.current?.contains(target)) setOpen(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, setOpen]);\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(!open)}\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 chipRef={chip}\n style={{ ...inheritedVars(root.current), ...vars, ...(placement ?? { visibility: 'hidden' }) }}\n />\n )}\n </span>\n );\n}\n"]}
@@ -32,6 +32,12 @@ interface NodeShieldProps {
32
32
  cluster?: string | null;
33
33
  /** Icon only when the window is this many px wide or narrower (always at 560px or narrower). */
34
34
  compactBelow?: number;
35
+ /** Icon only at every width, whatever `compactBelow` says. */
36
+ compact?: boolean;
37
+ /** Whether the popover is open; set it to control the shield, leave it out to let the shield keep its own state. */
38
+ open?: boolean;
39
+ /** Called with the open state the shield asks for: on a chip click, Escape or an outside click. */
40
+ onOpenChange?: (open: boolean) => void;
35
41
  /** The app's own check that node `url` runs its code, asked when the popover opens on a real, verified node. Memoise it. */
36
42
  appCode?: AppCodeChecker;
37
43
  /** Colours, as an alternative to setting the `--node-shield-*` custom properties in CSS. */
@@ -41,6 +47,6 @@ interface NodeShieldProps {
41
47
  * A header chip for the node `client` talks to, with a popover of what the browser's check verified.
42
48
  * Renders nothing until there is a client.
43
49
  */
44
- declare function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, appCode, colors }: NodeShieldProps): react_jsx_runtime.JSX.Element | null;
50
+ declare function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, compact: compactProp, open: openProp, onOpenChange, appCode, colors, }: NodeShieldProps): react_jsx_runtime.JSX.Element | null;
45
51
 
46
52
  export { type AppCodeCheck, type AppCodeChecker, NodeShield, type NodeShieldColors, type NodeShieldProps };
@@ -32,6 +32,12 @@ interface NodeShieldProps {
32
32
  cluster?: string | null;
33
33
  /** Icon only when the window is this many px wide or narrower (always at 560px or narrower). */
34
34
  compactBelow?: number;
35
+ /** Icon only at every width, whatever `compactBelow` says. */
36
+ compact?: boolean;
37
+ /** Whether the popover is open; set it to control the shield, leave it out to let the shield keep its own state. */
38
+ open?: boolean;
39
+ /** Called with the open state the shield asks for: on a chip click, Escape or an outside click. */
40
+ onOpenChange?: (open: boolean) => void;
35
41
  /** The app's own check that node `url` runs its code, asked when the popover opens on a real, verified node. Memoise it. */
36
42
  appCode?: AppCodeChecker;
37
43
  /** Colours, as an alternative to setting the `--node-shield-*` custom properties in CSS. */
@@ -41,6 +47,6 @@ interface NodeShieldProps {
41
47
  * A header chip for the node `client` talks to, with a popover of what the browser's check verified.
42
48
  * Renders nothing until there is a client.
43
49
  */
44
- declare function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, appCode, colors }: NodeShieldProps): react_jsx_runtime.JSX.Element | null;
50
+ declare function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, compact: compactProp, open: openProp, onOpenChange, appCode, colors, }: NodeShieldProps): react_jsx_runtime.JSX.Element | null;
45
51
 
46
52
  export { type AppCodeCheck, type AppCodeChecker, NodeShield, type NodeShieldColors, type NodeShieldProps };
@@ -1,5 +1,5 @@
1
1
  import { styleInject, MeroContext } from './chunk-4AKOWHG3.js';
2
- import { useContext, useState, useRef, useId, useEffect, useCallback, useLayoutEffect } from 'react';
2
+ import { useContext, useState, useCallback, useRef, useId, useEffect, useLayoutEffect } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import { verifyNodeUrl } from '@calimero-network/mero-js';
5
5
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
@@ -284,8 +284,14 @@ function ShieldIcon({ kind }) {
284
284
  }
285
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
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 }) {
287
+ function Popover({ view, id, style, popRef, chipRef }) {
288
288
  const [copied, copy2] = useCopy();
289
+ useClientLayoutEffect(() => {
290
+ const el = popRef.current;
291
+ return () => {
292
+ if (el?.contains(document.activeElement)) chipRef.current?.focus();
293
+ };
294
+ }, [popRef, chipRef]);
289
295
  return createPortal(
290
296
  /* @__PURE__ */ jsxs(
291
297
  "div",
@@ -330,31 +336,47 @@ function Popover({ view, id, style, popRef }) {
330
336
  document.body
331
337
  );
332
338
  }
333
- function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, appCode, colors }) {
339
+ function NodeShield({
340
+ client: clientProp,
341
+ cluster: clusterProp,
342
+ compactBelow,
343
+ compact: compactProp = false,
344
+ open: openProp,
345
+ onOpenChange,
346
+ appCode,
347
+ colors
348
+ }) {
334
349
  const context = useContext(MeroContext);
335
350
  const client = clientProp !== void 0 ? clientProp : context?.client ?? null;
336
351
  const cluster = clusterProp !== void 0 ? clusterProp : context?.cluster ?? null;
337
352
  const [state, refresh] = useNodeVerification(client);
338
- const [open, setOpen] = useState(false);
353
+ const [ownOpen, setOwnOpen] = useState(false);
354
+ const controlled = openProp !== void 0;
355
+ const open = controlled ? openProp : ownOpen;
356
+ const setOpen = useCallback(
357
+ (next) => {
358
+ if (!controlled) setOwnOpen(next);
359
+ onOpenChange?.(next);
360
+ },
361
+ [controlled, onOpenChange]
362
+ );
339
363
  const root = useRef(null);
340
364
  const chip = useRef(null);
341
365
  const pop = useRef(null);
342
366
  const popId = useId();
343
367
  const placement = usePlacement(open, chip, pop);
344
- const compact = useNarrowerThan(compactBelow);
368
+ const compact = useNarrowerThan(compactProp ? void 0 : compactBelow) || compactProp;
345
369
  const real = state.status === "verified" && !state.mock;
346
370
  const code = useAppCode(client, appCode, open && real ? state.url : null);
371
+ useEffect(() => {
372
+ if (open) refresh();
373
+ }, [open, refresh]);
347
374
  useEffect(() => {
348
375
  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);
376
+ const onKey = (e) => e.key === "Escape" && setOpen(false);
355
377
  const onDown = (e) => {
356
378
  const target = e.target;
357
- if (!chip.current?.contains(target) && !pop.current?.contains(target)) close(false);
379
+ if (!chip.current?.contains(target) && !pop.current?.contains(target)) setOpen(false);
358
380
  };
359
381
  document.addEventListener("keydown", onKey);
360
382
  document.addEventListener("mousedown", onDown);
@@ -362,7 +384,7 @@ function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, ap
362
384
  document.removeEventListener("keydown", onKey);
363
385
  document.removeEventListener("mousedown", onDown);
364
386
  };
365
- }, [open, refresh]);
387
+ }, [open, setOpen]);
366
388
  const placed = placement !== null;
367
389
  useEffect(() => {
368
390
  if (open && placed) pop.current?.focus();
@@ -382,7 +404,7 @@ function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, ap
382
404
  "aria-haspopup": "dialog",
383
405
  "aria-expanded": open,
384
406
  "aria-controls": open ? popId : void 0,
385
- onClick: () => setOpen((v) => !v),
407
+ onClick: () => setOpen(!open),
386
408
  "data-testid": "node-shield",
387
409
  children: [
388
410
  /* @__PURE__ */ jsx(ShieldIcon, { kind: view.kind }),
@@ -396,6 +418,7 @@ function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, ap
396
418
  view,
397
419
  id: popId,
398
420
  popRef: pop,
421
+ chipRef: chip,
399
422
  style: { ...inheritedVars(root.current), ...vars, ...placement ?? { visibility: "hidden" } }
400
423
  }
401
424
  )
@@ -1 +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;AAG3F,eAAe,MAAM,MAAA,EAA+D;AAClF,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,OAAO,MAAA,EAAO;AAAA,EAC7B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,SAAS,KAAK,MAAA,EAAsD;AAClE,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI;AACF,IAAA,KAAA,GAAQ,QAAQ,YAAA,EAAa;AAAA,EAC/B,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,SAAS,EAAE,MAAA,EAAQ,YAAY,GAAA,EAAK,MAAA,EAAQ,WAAW,EAAA,EAAG;AACnE;AAGO,SAAS,oBAAoB,MAAA,EAAoE;AAEtG,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAAA,CAAS,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,IAAA,CAAK,MAAM,CAAA,EAAE,CAAE,CAAA;AACxE,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,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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"]}
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","useCallback"],"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;AAG3F,eAAe,MAAM,MAAA,EAA+D;AAClF,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,OAAO,MAAA,EAAO;AAAA,EAC7B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,SAAS,KAAK,MAAA,EAAsD;AAClE,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI;AACF,IAAA,KAAA,GAAQ,QAAQ,YAAA,EAAa;AAAA,EAC/B,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,SAAS,EAAE,MAAA,EAAQ,YAAY,GAAA,EAAK,MAAA,EAAQ,WAAW,EAAA,EAAG;AACnE;AAGO,SAAS,oBAAoB,MAAA,EAAoE;AAEtG,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAAA,CAAS,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,IAAA,CAA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,GAAU,4BAAA,GAA+B,EAAE,CAAA,CAAA,EAAI,KAAA,EAAO,IAAA,EACnG,QAAA,EAAA;AAAA,oBAAA,IAAA;AAAA,MAAC,QAAA;AAAA,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,OAAA,EAAS,MAAM,OAAA,CAAQ,CAAC,IAAI,CAAA;AAAA,QAC5B,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,OAAA,EAAS,IAAA;AAAA,QACT,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, { useCallback, 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 /** Icon only at every width, whatever `compactBelow` says. */\n compact?: boolean;\n /** Whether the popover is open; set it to control the shield, leave it out to let the shield keep its own state. */\n open?: boolean;\n /** Called with the open state the shield asks for: on a chip click, Escape or an outside click. */\n onOpenChange?: (open: boolean) => void;\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 chipRef: React.RefObject<HTMLButtonElement>;\n}\n\nfunction Popover({ view, id, style, popRef, chipRef }: PopoverProps) {\n const [copied, copy] = useCopy();\n // A layout cleanup runs before the popover leaves the DOM, while it can still tell whether it holds focus.\n useClientLayoutEffect(() => {\n const el = popRef.current;\n return () => {\n if (el?.contains(document.activeElement)) chipRef.current?.focus();\n };\n }, [popRef, chipRef]);\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({\n client: clientProp,\n cluster: clusterProp,\n compactBelow,\n compact: compactProp = false,\n open: openProp,\n onOpenChange,\n appCode,\n colors,\n}: 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 [ownOpen, setOwnOpen] = useState(false);\n const controlled = openProp !== undefined;\n const open = controlled ? openProp : ownOpen;\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setOwnOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\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(compactProp ? undefined : compactBelow) || compactProp;\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) refresh();\n }, [open, refresh]);\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === 'Escape' && setOpen(false);\n const onDown = (e: MouseEvent) => {\n const target = e.target as Node;\n if (!chip.current?.contains(target) && !pop.current?.contains(target)) setOpen(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, setOpen]);\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(!open)}\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 chipRef={chip}\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.2.0",
3
+ "version": "11.3.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",