@calimero-network/mero-react 11.3.0 → 11.4.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.
@@ -1,202 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkPYCIYVHN_cjs = require('./chunk-PYCIYVHN.cjs');
3
+ var chunkRRETZWNI_cjs = require('./chunk-RRETZWNI.cjs');
4
4
  var react = require('react');
5
5
  var reactDom = require('react-dom');
6
- var meroJs = require('@calimero-network/mero-js');
7
6
  var jsxRuntime = require('react/jsx-runtime');
8
7
 
9
- var RETRY_BASE_MS = 2e3;
10
- var RETRY_MAX_MS = 3e4;
11
- var NODE_POLL_MS = 1e3;
12
- var retryDelay = (attempt) => Math.min(RETRY_BASE_MS * 2 ** attempt, RETRY_MAX_MS);
13
- async function check(client) {
14
- try {
15
- return await client.verify();
16
- } catch {
17
- return null;
18
- }
19
- }
20
- function peek(client) {
21
- let known;
22
- try {
23
- known = client?.verification();
24
- } catch {
25
- }
26
- return known ?? { status: "checking", url: client?.nodeUrl ?? "" };
27
- }
28
- function useNodeVerification(client) {
29
- const [held, setHeld] = react.useState(() => ({ client, state: peek(client) }));
30
- const [round, setRound] = react.useState(0);
31
- const [url, setUrl] = react.useState(client?.nodeUrl);
32
- react.useEffect(() => {
33
- setUrl(client?.nodeUrl);
34
- if (!client) return;
35
- const poll = setInterval(() => setUrl(client.nodeUrl), NODE_POLL_MS);
36
- return () => clearInterval(poll);
37
- }, [client]);
38
- react.useEffect(() => {
39
- if (!client) return;
40
- let live = true;
41
- let timer;
42
- const run = async (attempt) => {
43
- const next = await check(client);
44
- if (!live || !next) return;
45
- setHeld({ client, state: next });
46
- if (next.status === "unreachable") timer = setTimeout(() => void run(attempt + 1), retryDelay(attempt));
47
- };
48
- setHeld({ client, state: peek(client) });
49
- void run(0);
50
- return () => {
51
- live = false;
52
- clearTimeout(timer);
53
- };
54
- }, [client, round, url]);
55
- const state = held.client === client ? held.state : peek(client);
56
- const inUse = client?.nodeUrl;
57
- const shown = inUse && state.url !== inUse ? { status: "checking", url: inUse } : state;
58
- return [shown, react.useCallback(() => setRound((n) => n + 1), [])];
59
- }
60
- function useAppCode(client, appCode, url) {
61
- const [result, setResult] = react.useState(null);
62
- react.useEffect(() => {
63
- if (!client || !appCode || !url) return;
64
- let live = true;
65
- void Promise.resolve().then(() => appCode(client, url)).then(
66
- (code) => live && client.nodeUrl === url && setResult({ client, url, appCode, code }),
67
- () => void 0
68
- );
69
- return () => {
70
- live = false;
71
- };
72
- }, [client, appCode, url]);
73
- const current = result?.client === client && result?.url === url && result?.appCode === appCode && client?.nodeUrl === url;
74
- return current ? result.code : null;
75
- }
76
- var SEALED_PROFILE = "locked-read-only";
77
- var JUST_NOW_SECONDS = 10;
78
- var AGO = [
79
- ["day", 86400],
80
- ["hour", 3600],
81
- ["minute", 60]
82
- ];
83
- var ago = new Intl.RelativeTimeFormat("en");
84
- var SHIELD_LABEL = {
85
- checking: "Checking node\u2026",
86
- verified: "Verified node",
87
- unsealed: "Test server: not sealed",
88
- refused: "Node refused"
89
- };
90
- function shieldKind(state) {
91
- if (state.status === "refused") return "refused";
92
- if (state.status !== "verified") return "checking";
93
- return !state.mock && state.profile === SEALED_PROFILE ? "verified" : "unsealed";
94
- }
95
- function checkedAgo(at, now = Date.now()) {
96
- const seconds = Math.max(0, Math.round((now - at) / 1e3));
97
- if (seconds < JUST_NOW_SECONDS) return "just now";
98
- const [unit, size] = AGO.find(([, size2]) => seconds >= size2) ?? ["second", 1];
99
- return ago.format(-Math.floor(seconds / size), unit);
100
- }
101
- function shortHash(hash) {
102
- return hash.length > 12 ? `${hash.slice(0, 4)}\u2026${hash.slice(-4)}` : hash;
103
- }
104
- function hostOf(url) {
105
- try {
106
- return new URL(url).host;
107
- } catch {
108
- return url;
109
- }
110
- }
111
- function releaseName(code) {
112
- return code.package && code.version ? `${code.package} v${code.version}` : null;
113
- }
114
- function codeRow(code) {
115
- if (code?.status === "match") {
116
- const named = releaseName(code);
117
- return {
118
- label: "App code",
119
- value: named ? `${named} \xB7 ${shortHash(code.appHash)}` : shortHash(code.appHash),
120
- full: named ? `${named} \xB7 ${code.appHash}` : code.appHash,
121
- mono: true,
122
- hash: shortHash(code.appHash)
123
- };
124
- }
125
- if (code?.status === "mismatch") {
126
- return {
127
- label: "App code",
128
- value: `Does not match this app's release (node runs ${shortHash(code.appHash)})`,
129
- full: `Does not match this app's release (node runs ${code.appHash}, expected ${code.expected})`,
130
- tone: "bad"
131
- };
132
- }
133
- return null;
134
- }
135
- function copy(state, kind, ago2) {
136
- switch (kind) {
137
- case "verified":
138
- return {
139
- title: "You are talking to a genuine Calimero TEE node",
140
- sub: `Checked by this browser ${ago2}, before anything was sent.`
141
- };
142
- case "unsealed":
143
- return {
144
- title: SHIELD_LABEL.unsealed,
145
- sub: state.status === "verified" && state.mock ? `A test server with no hardware enclave, so its data is not sealed. Checked by this browser ${ago2}.` : `This node did not show it runs the sealed, read-only profile, so its data is not sealed. Checked by this browser ${ago2}.`
146
- };
147
- case "refused":
148
- return { title: SHIELD_LABEL.refused, sub: "This app refused the node and sent nothing." };
149
- case "checking":
150
- return {
151
- title: SHIELD_LABEL.checking,
152
- sub: state.status === "unreachable" ? "The node could not be reached. Trying again." : "This browser is checking the node before anything is sent."
153
- };
154
- }
155
- }
156
- function describeShield(state, { cluster, code, now = Date.now() }) {
157
- const kind = shieldKind(state);
158
- const real = state.status === "verified" && !state.mock ? state : null;
159
- const release = real?.release;
160
- const rows = [];
161
- if (cluster) rows.push({ label: "Cluster", value: cluster });
162
- rows.push({ label: "Node", value: hostOf(state.url), full: state.url, mono: true });
163
- if (real && release) rows.push({ label: "Software", value: `mero-tee v${release}${real.profile ? ` \xB7 ${real.profile}` : ""}` });
164
- const app = real ? codeRow(code) : null;
165
- if (app) rows.push(app);
166
- if (state.status === "refused" || state.status === "unreachable") {
167
- rows.push({ label: "Reason", value: state.reason, ...state.status === "refused" ? { tone: "bad" } : {} });
168
- }
169
- const checked = "checkedAt" in state ? checkedAgo(state.checkedAt, now) : null;
170
- if (checked) rows.push({ label: "Checked", value: checked });
171
- const checks = [];
172
- if (kind === "verified") checks.push("Running in an Intel TDX enclave (not debug)");
173
- if (real && release) checks.push(`Measurements match the signed v${release} release`);
174
- if (real) checks.push("Your connection is encrypted to this enclave's key");
175
- if (app && code?.status === "match") {
176
- const named = releaseName(code);
177
- checks.push(named ? `Node runs the code listed for ${named}` : "Node runs the code bundle this app was built for");
178
- }
179
- return {
180
- kind,
181
- label: SHIELD_LABEL[kind],
182
- ...copy(state, kind, checked ?? "just now"),
183
- rows,
184
- checks,
185
- verifyUrl: real && release ? meroJs.verifyNodeUrl(real.url, release) : null
186
- };
187
- }
188
- function shieldDetails(view) {
189
- return [
190
- view.title,
191
- view.sub,
192
- "",
193
- ...view.rows.map((r) => `${r.label}: ${r.full ?? r.value}`),
194
- ...view.checks.length ? ["", ...view.checks.map((c) => `- ${c}`)] : []
195
- ].join("\n");
196
- }
197
-
198
8
  // src/node-shield/nodeShield.css
199
- chunkPYCIYVHN_cjs.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');
9
+ chunkRRETZWNI_cjs.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');
200
10
  var EDGE_PX = 12;
201
11
  var GAP_PX = 8;
202
12
  var COPIED_MS = 2e3;
@@ -225,11 +35,11 @@ function useCopy() {
225
35
  const timer = setTimeout(() => setState("idle"), COPIED_MS);
226
36
  return () => clearTimeout(timer);
227
37
  }, [state]);
228
- const copy2 = (text) => void Promise.resolve().then(() => navigator.clipboard.writeText(text)).then(
38
+ const copy = (text) => void Promise.resolve().then(() => navigator.clipboard.writeText(text)).then(
229
39
  () => setState("done"),
230
40
  () => setState("failed")
231
41
  );
232
- return [state, copy2];
42
+ return [state, copy];
233
43
  }
234
44
  function usePlacement(open, chip, pop) {
235
45
  const [at, setAt] = react.useState(null);
@@ -287,7 +97,7 @@ function ShieldIcon({ kind }) {
287
97
  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
98
  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
99
  function Popover({ view, id, style, popRef, chipRef }) {
290
- const [copied, copy2] = useCopy();
100
+ const [copied, copy] = useCopy();
291
101
  useClientLayoutEffect(() => {
292
102
  const el = popRef.current;
293
103
  return () => {
@@ -329,7 +139,7 @@ function Popover({ view, id, style, popRef, chipRef }) {
329
139
  "Verify independently",
330
140
  /* @__PURE__ */ jsxRuntime.jsx(ExternalIcon, {})
331
141
  ] }),
332
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-node-shield-pop__btn", onClick: () => copy2(shieldDetails(view)), children: copied === "done" ? "Copied" : copied === "failed" ? "Could not copy" : "Copy details" })
142
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-node-shield-pop__btn", onClick: () => copy(chunkRRETZWNI_cjs.shieldDetails(view)), children: copied === "done" ? "Copied" : copied === "failed" ? "Could not copy" : "Copy details" })
333
143
  ] }),
334
144
  view.verifyUrl && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-node-shield-pop__foot", children: "Opens the public verifier, which re-checks this node from outside the app." })
335
145
  ]
@@ -348,10 +158,10 @@ function NodeShield({
348
158
  appCode,
349
159
  colors
350
160
  }) {
351
- const context = react.useContext(chunkPYCIYVHN_cjs.MeroContext);
161
+ const context = react.useContext(chunkRRETZWNI_cjs.MeroContext);
352
162
  const client = clientProp !== void 0 ? clientProp : context?.client ?? null;
353
163
  const cluster = clusterProp !== void 0 ? clusterProp : context?.cluster ?? null;
354
- const [state, refresh] = useNodeVerification(client);
164
+ const [state, refresh] = chunkRRETZWNI_cjs.useNodeVerification(client);
355
165
  const [ownOpen, setOwnOpen] = react.useState(false);
356
166
  const controlled = openProp !== void 0;
357
167
  const open = controlled ? openProp : ownOpen;
@@ -369,7 +179,7 @@ function NodeShield({
369
179
  const placement = usePlacement(open, chip, pop);
370
180
  const compact = useNarrowerThan(compactProp ? void 0 : compactBelow) || compactProp;
371
181
  const real = state.status === "verified" && !state.mock;
372
- const code = useAppCode(client, appCode, open && real ? state.url : null);
182
+ const code = chunkRRETZWNI_cjs.useAppCode(client, appCode, open && real ? state.url : null);
373
183
  react.useEffect(() => {
374
184
  if (open) refresh();
375
185
  }, [open, refresh]);
@@ -392,7 +202,7 @@ function NodeShield({
392
202
  if (open && placed) pop.current?.focus();
393
203
  }, [open, placed]);
394
204
  if (!client) return null;
395
- const view = describeShield(state, { cluster, code });
205
+ const view = chunkRRETZWNI_cjs.describeShield(state, { cluster, code });
396
206
  const vars = colorVars(colors);
397
207
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { ref: root, className: `mero-node-shield${compact ? " mero-node-shield--compact" : ""}`, style: vars, children: [
398
208
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -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","use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,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,0BAAAC,cAAA,CAAC,UAAA,EAAA,EAAW,IAAA,EAAM,IAAA,CAAK,IAAA,EAAM,CAAA;AAAA,0BAC7BA,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,yBAAA,EAA2B,eAAK,KAAA,EAAM;AAAA;AAAA;AAAA,KACxD;AAAA,IACC,IAAA,oBACCA,cAAA;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.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, { 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"]}
1
+ {"version":3,"sources":["../src/node-shield/nodeShield.css","../src/node-shield/NodeShield.tsx"],"names":["styleInject","useEffect","useLayoutEffect","useState","jsxs","jsx","createPortal","Fragment","shieldDetails","useContext","MeroContext","useNodeVerification","useCallback","useRef","useId","useAppCode","describeShield"],"mappings":";;;;;;;;AAAwCA,6BAAA,CAAY,k0MAAo0M,CAAA;ACQx3M,IAAM,OAAA,GAAU,EAAA;AAChB,IAAM,MAAA,GAAS,CAAA;AACf,IAAM,SAAA,GAAY,GAAA;AAElB,IAAM,qBAAA,GAAwB,OAAO,MAAA,KAAW,WAAA,GAAcC,eAAA,GAAYC,qBAAA;AAC1E,IAAM,UAAA,GAAa,CAAC,UAAA,EAAY,SAAA,EAAW,UAAA,EAAY,WAAW,SAAA,EAAW,MAAA,EAAQ,OAAA,EAAS,QAAA,EAAU,OAAO,CAAA;AAwB/G,IAAM,OAAA,GAAU,CAAC,GAAA,KAAgB,CAAA,cAAA,EAAiB,GAAG,CAAA,CAAA;AAErD,SAAS,UAAU,MAAA,EAA8D;AAC/E,EAAA,MAAM,OAA+B,EAAC;AACtC,EAAA,KAAA,MAAW,GAAA,IAAO,UAAA,EAAY,IAAI,MAAA,GAAS,GAAG,CAAA,EAAG,IAAA,CAAK,OAAA,CAAQ,GAAG,CAAC,CAAA,GAAI,MAAA,CAAO,GAAG,CAAA;AAChF,EAAA,OAAO,IAAA;AACT;AAGA,SAAS,cAAc,EAAA,EAAgD;AACrE,EAAA,MAAM,OAA+B,EAAC;AACtC,EAAA,IAAI,CAAC,IAAI,OAAO,IAAA;AAChB,EAAA,MAAM,KAAA,GAAQ,iBAAiB,EAAE,CAAA;AACjC,EAAA,KAAA,MAAW,OAAO,UAAA,EAAY;AAC5B,IAAA,MAAM,QAAQ,KAAA,CAA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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"]}
@@ -1,26 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { CalimeroClient } from '@calimero-network/mero-js';
3
-
4
- /** What the node shield says about a node, from the check mero-js ran: only what that check verified. */
5
-
6
- /** Whether the node runs the app's code: `match` only when both hashes are present and equal; anything not checked is `unknown`. */
7
- type AppCodeCheck = {
8
- status: 'match';
9
- appHash: string;
10
- checkedAt: number;
11
- package?: string;
12
- version?: string;
13
- } | {
14
- status: 'mismatch';
15
- appHash: string;
16
- expected: string;
17
- } | {
18
- status: 'unknown';
19
- reason: string;
20
- };
21
-
22
- /** The app's own check that a node runs its code; memoise it, since a new function checks again. */
23
- type AppCodeChecker = (client: CalimeroClient, url: string) => Promise<AppCodeCheck>;
3
+ import { A as AppCodeChecker } from './nodeChecks-B_vMN73N.cjs';
4
+ export { a as AppCodeCheck } from './nodeChecks-B_vMN73N.cjs';
24
5
 
25
6
  declare const COLOR_KEYS: readonly ["verified", "refused", "checking", "neutral", "surface", "text", "muted", "border", "focus"];
26
7
  /** Colours for the shield; each sets the `--node-shield-<key>` CSS custom property of the same name. */
@@ -49,4 +30,4 @@ interface NodeShieldProps {
49
30
  */
50
31
  declare function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, compact: compactProp, open: openProp, onOpenChange, appCode, colors, }: NodeShieldProps): react_jsx_runtime.JSX.Element | null;
51
32
 
52
- export { type AppCodeCheck, type AppCodeChecker, NodeShield, type NodeShieldColors, type NodeShieldProps };
33
+ export { AppCodeChecker, NodeShield, type NodeShieldColors, type NodeShieldProps };
@@ -1,26 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { CalimeroClient } from '@calimero-network/mero-js';
3
-
4
- /** What the node shield says about a node, from the check mero-js ran: only what that check verified. */
5
-
6
- /** Whether the node runs the app's code: `match` only when both hashes are present and equal; anything not checked is `unknown`. */
7
- type AppCodeCheck = {
8
- status: 'match';
9
- appHash: string;
10
- checkedAt: number;
11
- package?: string;
12
- version?: string;
13
- } | {
14
- status: 'mismatch';
15
- appHash: string;
16
- expected: string;
17
- } | {
18
- status: 'unknown';
19
- reason: string;
20
- };
21
-
22
- /** The app's own check that a node runs its code; memoise it, since a new function checks again. */
23
- type AppCodeChecker = (client: CalimeroClient, url: string) => Promise<AppCodeCheck>;
3
+ import { A as AppCodeChecker } from './nodeChecks-B_vMN73N.js';
4
+ export { a as AppCodeCheck } from './nodeChecks-B_vMN73N.js';
24
5
 
25
6
  declare const COLOR_KEYS: readonly ["verified", "refused", "checking", "neutral", "surface", "text", "muted", "border", "focus"];
26
7
  /** Colours for the shield; each sets the `--node-shield-<key>` CSS custom property of the same name. */
@@ -49,4 +30,4 @@ interface NodeShieldProps {
49
30
  */
50
31
  declare function NodeShield({ client: clientProp, cluster: clusterProp, compactBelow, compact: compactProp, open: openProp, onOpenChange, appCode, colors, }: NodeShieldProps): react_jsx_runtime.JSX.Element | null;
51
32
 
52
- export { type AppCodeCheck, type AppCodeChecker, NodeShield, type NodeShieldColors, type NodeShieldProps };
33
+ export { AppCodeChecker, NodeShield, type NodeShieldColors, type NodeShieldProps };