@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.
- package/dist/chunk-MMJOGIM5.js +256 -0
- package/dist/chunk-MMJOGIM5.js.map +1 -0
- package/dist/chunk-RRETZWNI.cjs +266 -0
- package/dist/chunk-RRETZWNI.cjs.map +1 -0
- package/dist/index.cjs +881 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +120 -2
- package/dist/index.d.ts +120 -2
- package/dist/index.js +875 -14
- package/dist/index.js.map +1 -1
- package/dist/node-shield.cjs +10 -200
- package/dist/node-shield.cjs.map +1 -1
- package/dist/node-shield.d.cts +3 -22
- package/dist/node-shield.d.ts +3 -22
- package/dist/node-shield.js +5 -195
- package/dist/node-shield.js.map +1 -1
- package/dist/nodeChecks-B_vMN73N.d.cts +37 -0
- package/dist/nodeChecks-B_vMN73N.d.ts +37 -0
- package/package.json +1 -1
- package/dist/chunk-4AKOWHG3.js +0 -30
- package/dist/chunk-4AKOWHG3.js.map +0 -1
- package/dist/chunk-PYCIYVHN.cjs +0 -33
- package/dist/chunk-PYCIYVHN.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkRRETZWNI_cjs = require('./chunk-RRETZWNI.cjs');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var meroJs = require('@calimero-network/mero-js');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var reactDom = require('react-dom');
|
|
7
8
|
|
|
8
9
|
// src/components/styles.css
|
|
9
|
-
|
|
10
|
+
chunkRRETZWNI_cjs.styleInject(':root {\n --mero-bg: #0d1117;\n --mero-bg-secondary: #161b22;\n --mero-bg-tertiary: #1c2128;\n --mero-text: #e6edf3;\n --mero-text-secondary: #8b949e;\n --mero-accent: #a5ff11;\n --mero-accent-hover: #8ed40d;\n --mero-on-primary: #0d1117;\n --mero-error: #ff6b6b;\n --mero-border: #30363d;\n --mero-disabled: #555555;\n --mero-shadow: rgba(0, 0, 0, 0.5);\n --mero-overlay: rgba(0, 0, 0, 0.75);\n --mero-radius: 8px;\n}\n.mero-connect-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 10px 20px;\n background-color: var(--mero-accent);\n border: 1px solid var(--mero-accent);\n border-radius: var(--mero-radius);\n cursor: pointer;\n font-size: 14px;\n font-weight: 600;\n letter-spacing: 0.01em;\n color: var(--mero-on-primary);\n transition:\n background-color 0.15s ease,\n border-color 0.15s ease,\n box-shadow 0.15s ease,\n transform 0.1s ease;\n min-width: 140px;\n box-sizing: border-box;\n font-family:\n "Inter",\n -apple-system,\n BlinkMacSystemFont,\n "Segoe UI",\n Roboto,\n Oxygen,\n Ubuntu,\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n line-height: 1;\n}\n.mero-connect-button:hover:not(.mero-connected):not(.mero-reconnecting) {\n background-color: var(--mero-accent-hover);\n border-color: var(--mero-accent-hover);\n box-shadow: 0 0 0 4px rgba(165, 255, 17, 0.18);\n box-shadow: 0 0 0 4px color-mix(in srgb, var(--mero-accent) 18%, transparent);\n}\n.mero-connect-button:active:not(.mero-connected):not(.mero-reconnecting) {\n transform: translateY(1px);\n}\n.mero-connect-button:focus-visible {\n outline: none;\n box-shadow: 0 0 0 3px rgba(165, 255, 17, 0.45);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mero-accent) 45%, transparent);\n}\n.mero-connect-button.mero-logo-only {\n min-width: 0;\n width: 40px;\n height: 40px;\n padding: 0;\n gap: 0;\n}\n.mero-connect-button.mero-connected {\n background-color: var(--mero-accent);\n color: var(--mero-on-primary);\n border-color: var(--mero-accent);\n}\n.mero-connect-button.mero-connected:hover {\n background-color: var(--mero-accent-hover);\n border-color: var(--mero-accent-hover);\n}\n.mero-connect-button.mero-reconnecting {\n background-color: var(--mero-bg-secondary);\n color: var(--mero-text-secondary);\n border-color: var(--mero-border);\n cursor: not-allowed;\n}\n.mero-connect-container {\n position: relative;\n display: inline-block;\n}\n.mero-dropdown {\n position: absolute;\n top: 100%;\n left: 0;\n background-color: var(--mero-bg-secondary);\n border: 1px solid var(--mero-border);\n border-radius: var(--mero-radius);\n margin-top: 6px;\n padding: 0;\n z-index: 1001;\n width: 100%;\n min-width: 180px;\n overflow: hidden;\n box-shadow: 0 8px 24px var(--mero-shadow);\n}\n.mero-dropdown-info {\n padding: 10px 16px;\n color: var(--mero-text-secondary);\n font-size: 13px;\n border-bottom: 1px solid var(--mero-border);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 220px;\n}\n.mero-dropdown-item {\n display: block;\n width: 100%;\n padding: 10px 16px;\n background: none;\n border: none;\n color: var(--mero-text);\n text-align: left;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n font-family: inherit;\n}\n.mero-dropdown-item:hover {\n background-color: var(--mero-accent);\n color: var(--mero-on-primary);\n}\n.mero-logo {\n width: 24px;\n height: 24px;\n color: currentColor;\n}\n@keyframes meroFadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n@keyframes meroSlideIn {\n from {\n transform: translateY(-12px);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n}\n@keyframes meroSpin {\n to {\n transform: rotate(360deg);\n }\n}\n.mero-dialog-overlay {\n position: fixed;\n inset: 0;\n z-index: 2147483646;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 16px;\n background: var(--mero-overlay);\n font-family:\n "Inter",\n -apple-system,\n BlinkMacSystemFont,\n "Segoe UI",\n Roboto,\n Oxygen,\n Ubuntu,\n sans-serif;\n -webkit-font-smoothing: antialiased;\n}\n.mero-dialog-panel {\n box-sizing: border-box;\n width: min(420px, 100%);\n padding: 24px;\n border: 1px solid var(--mero-border);\n border-radius: calc(var(--mero-radius) * 1.5);\n background: var(--mero-bg-secondary);\n color: var(--mero-text);\n box-shadow: 0 16px 48px var(--mero-shadow);\n outline: none;\n animation: mero-dialog-in 0.16s ease-out;\n}\n.mero-dialog-app {\n margin: 0 0 12px;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n color: var(--mero-text-secondary);\n}\n.mero-dialog-head {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n.mero-dialog-title {\n margin: 0;\n min-width: 0;\n font-size: 18px;\n font-weight: 600;\n line-height: 1.3;\n overflow-wrap: anywhere;\n}\n.mero-dialog-body {\n margin: 12px 0 0;\n font-size: 14px;\n line-height: 1.5;\n color: var(--mero-text-secondary);\n}\n.mero-dialog-body-error {\n color: var(--mero-error);\n}\n.mero-dialog-icon {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n border-radius: 50%;\n background: var(--mero-bg-tertiary);\n color: var(--mero-accent);\n}\n.mero-dialog-icon-error {\n color: var(--mero-error);\n}\n.mero-dialog-spinner {\n box-sizing: border-box;\n width: 36px;\n height: 36px;\n border: 3px solid var(--mero-bg-tertiary);\n border-top-color: var(--mero-accent);\n background: none;\n animation: mero-dialog-spin 0.8s linear infinite;\n}\n.mero-dialog-progress {\n position: relative;\n height: 3px;\n margin-top: 16px;\n overflow: hidden;\n border-radius: 2px;\n background: var(--mero-bg-tertiary);\n}\n.mero-dialog-progress-bar {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 40%;\n border-radius: 2px;\n background: var(--mero-accent);\n animation: mero-dialog-progress 1.4s ease-in-out infinite;\n}\n.mero-dialog-actions {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: 8px;\n margin-top: 20px;\n}\n.mero-dialog-actions:empty {\n display: none;\n}\n.mero-dialog-button {\n padding: 9px 16px;\n border-radius: var(--mero-radius);\n font: inherit;\n font-size: 14px;\n font-weight: 600;\n line-height: 1.2;\n cursor: pointer;\n transition: background-color 0.15s ease, border-color 0.15s ease;\n}\n.mero-dialog-button:focus-visible {\n outline: 2px solid var(--mero-accent);\n outline-offset: 2px;\n}\n.mero-dialog-primary {\n border: 1px solid var(--mero-accent);\n background: var(--mero-accent);\n color: var(--mero-on-primary);\n}\n.mero-dialog-primary:hover {\n border-color: var(--mero-accent-hover);\n background: var(--mero-accent-hover);\n}\n.mero-dialog-secondary {\n border: 1px solid var(--mero-border);\n background: transparent;\n color: var(--mero-text);\n}\n.mero-dialog-secondary:hover {\n background: var(--mero-bg-tertiary);\n}\n@keyframes mero-dialog-spin {\n to {\n transform: rotate(360deg);\n }\n}\n@keyframes mero-dialog-progress {\n from {\n left: -40%;\n }\n to {\n left: 100%;\n }\n}\n@keyframes mero-dialog-in {\n from {\n opacity: 0;\n transform: translateY(6px) scale(0.98);\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .mero-dialog-panel,\n .mero-dialog-spinner,\n .mero-dialog-progress-bar {\n animation: none;\n }\n}\n.mero-dialog-field {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin: 16px 0 0;\n font-size: 13px;\n color: var(--mero-text-secondary);\n}\n.mero-dialog-input {\n box-sizing: border-box;\n width: 100%;\n padding: 9px 12px;\n border: 1px solid var(--mero-border);\n border-radius: var(--mero-radius);\n background: var(--mero-bg);\n color: var(--mero-text);\n font: inherit;\n font-size: 14px;\n}\n.mero-dialog-input:focus-visible {\n outline: 2px solid var(--mero-accent);\n outline-offset: 1px;\n}\n.mero-dialog-link {\n margin: 14px 0 0;\n padding: 0;\n border: 0;\n background: none;\n color: var(--mero-text-secondary);\n font: inherit;\n font-size: 13px;\n text-decoration: underline;\n cursor: pointer;\n}\n');
|
|
10
11
|
function resolvePolicy({ policy, minReleaseVersion, allowMock }) {
|
|
11
12
|
if (policy) return allowMock ? { ...policy, allowMock: true } : policy;
|
|
12
13
|
if (minReleaseVersion) return { release: { minReleaseVersion }, ...allowMock ? { allowMock: true } : {} };
|
|
@@ -500,10 +501,10 @@ function MeroProvider({
|
|
|
500
501
|
reportError
|
|
501
502
|
]
|
|
502
503
|
);
|
|
503
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
504
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkRRETZWNI_cjs.MeroContext.Provider, { value, children });
|
|
504
505
|
}
|
|
505
506
|
function useMero() {
|
|
506
|
-
const value = react.useContext(
|
|
507
|
+
const value = react.useContext(chunkRRETZWNI_cjs.MeroContext);
|
|
507
508
|
if (!value) throw new Error("useMero must be used within a MeroProvider");
|
|
508
509
|
return value;
|
|
509
510
|
}
|
|
@@ -775,10 +776,10 @@ function useSubscription(appIds, callback, options = {}) {
|
|
|
775
776
|
const optionsRef = react.useRef(options);
|
|
776
777
|
optionsRef.current = options;
|
|
777
778
|
react.useEffect(() => {
|
|
778
|
-
const
|
|
779
|
-
if (!client || !enabled ||
|
|
779
|
+
const list2 = JSON.parse(idsKey);
|
|
780
|
+
if (!client || !enabled || list2.length === 0) return;
|
|
780
781
|
const controller = new AbortController();
|
|
781
|
-
for (const appId of
|
|
782
|
+
for (const appId of list2) {
|
|
782
783
|
void followEvents({
|
|
783
784
|
client,
|
|
784
785
|
appId,
|
|
@@ -1409,10 +1410,10 @@ function useEphemeral(appId, options = {}) {
|
|
|
1409
1410
|
}
|
|
1410
1411
|
};
|
|
1411
1412
|
}, [client, id, enabled, send]);
|
|
1412
|
-
const
|
|
1413
|
+
const list2 = [...entries.values()].filter((e) => includeSelf || e.account !== accountId);
|
|
1413
1414
|
const peers = /* @__PURE__ */ new Map();
|
|
1414
|
-
for (const e of
|
|
1415
|
-
return { peers, entries:
|
|
1415
|
+
for (const e of list2) peers.set(e.account, e.state);
|
|
1416
|
+
return { peers, entries: list2, setPresence, leave, error };
|
|
1416
1417
|
}
|
|
1417
1418
|
function useAccount() {
|
|
1418
1419
|
const client = useSignedInClient();
|
|
@@ -1455,9 +1456,9 @@ function useApiKeys(options) {
|
|
|
1455
1456
|
const { withClient, ...state } = useClientAction(options);
|
|
1456
1457
|
const create = react.useCallback(
|
|
1457
1458
|
(input = {}) => withClient(async (c) => {
|
|
1458
|
-
const
|
|
1459
|
+
const created2 = await c.auth.apikeyCreate({ ...input }, confirmWith(passkey));
|
|
1459
1460
|
void refetch();
|
|
1460
|
-
return
|
|
1461
|
+
return created2;
|
|
1461
1462
|
}),
|
|
1462
1463
|
[withClient, passkey, refetch]
|
|
1463
1464
|
);
|
|
@@ -1867,22 +1868,887 @@ function ConnectButton({
|
|
|
1867
1868
|
] });
|
|
1868
1869
|
}
|
|
1869
1870
|
|
|
1871
|
+
// src/create-workspace/workspaceReview.css
|
|
1872
|
+
chunkRRETZWNI_cjs.styleInject('.mero-cw,\n.mero-cw-review {\n --_ink: var(--cw-ink, light-dark(#0f1117, #eceef5));\n --_muted: var(--cw-muted, light-dark(#6b7280, #9097ab));\n --_line: var(--cw-line, light-dark(#e6e8ee, rgba(255, 255, 255, 0.16)));\n --_surface: var(--cw-surface, light-dark(#ffffff, #161b2b));\n --_primary-bg: var(--cw-primary-bg, light-dark(#0f1117, #eceef5));\n --_primary-ink: var(--cw-primary-ink, light-dark(#ffffff, #0f1117));\n --_focus: var(--cw-link, light-dark(#3b5bfd, #9aafff));\n --_good-bg: var(--cw-good-bg, light-dark(#dcfce7, #0e3324));\n --_good-ink: var(--cw-good-ink, light-dark(#15803d, #7fe0b0));\n --_bad-bg: var(--cw-bad-bg, light-dark(#ffe4ea, #3d0f1e));\n --_bad-ink: var(--cw-bad-ink, light-dark(#a2194b, #f78bb0));\n --_busy-bg: var(--cw-busy-bg, light-dark(#e3e9ff, #1c2650));\n --_busy-ink: var(--cw-busy-ink, light-dark(#3451d1, #9aafff));\n --_warn-bg: var(--cw-warn-bg, light-dark(#fff1d6, #3a2a08));\n --_warn-ink: var(--cw-warn-ink, light-dark(#8a5a00, #f2c36b));\n --_code-bg: var(--cw-code-bg, light-dark(#f4f5f8, #1f2538));\n font-family: var(--cw-font, inherit);\n}\n.mero-cw-review [data-kind=verified] {\n --_tone: var(--_good-ink);\n --_tone-bg: var(--_good-bg);\n}\n.mero-cw-review [data-kind=refused] {\n --_tone: var(--_bad-ink);\n --_tone-bg: var(--_bad-bg);\n}\n.mero-cw-review [data-kind=checking] {\n --_tone: var(--_busy-ink);\n --_tone-bg: var(--_busy-bg);\n}\n.mero-cw-review [data-kind=unsealed] {\n --_tone: var(--_muted);\n --_tone-bg: color-mix(in srgb, var(--_muted) 14%, var(--_surface));\n}\n.mero-cw-shield__icon {\n flex: none;\n color: var(--_tone);\n}\n.mero-cw-shield__tick {\n flex: none;\n margin-top: 2px;\n color: var(--_muted);\n}\n@media (prefers-reduced-motion: no-preference) {\n [data-kind=checking] .mero-cw-shield__icon {\n animation: mero-cw-shield-pulse 1.4s ease-in-out infinite;\n }\n}\n@keyframes mero-cw-shield-pulse {\n 50% {\n opacity: 0.4;\n }\n}\n.mero-cw-review {\n box-sizing: border-box;\n width: 100%;\n color: var(--_ink);\n font-size: 14px;\n line-height: 1.45;\n text-align: left;\n}\n.mero-cw-review *,\n.mero-cw-review *::before,\n.mero-cw-review *::after {\n box-sizing: border-box;\n}\n.mero-cw-review__title {\n margin: 0;\n font-size: 18px;\n font-weight: 700;\n line-height: 1.3;\n}\n.mero-cw-review__title:focus {\n outline: none;\n}\n.mero-cw-review__lede {\n margin: 4px 0 6px;\n color: var(--_muted);\n}\n.mero-cw-review__muted,\n.mero-cw-review__sub {\n color: var(--_muted);\n font-size: 12.5px;\n}\n.mero-cw-review__muted {\n margin: 8px 0 0;\n}\n.mero-cw-review__sub {\n display: block;\n margin-top: 2px;\n}\n.mero-cw-review__mono {\n font-family:\n ui-monospace,\n "SF Mono",\n SFMono-Regular,\n Menlo,\n Consolas,\n monospace;\n font-size: 12.5px;\n overflow-wrap: anywhere;\n}\n.mero-cw-review__icon {\n flex: none;\n}\n.mero-cw-review__nobreak {\n white-space: nowrap;\n}\n.mero-cw-review__sec {\n padding: 14px 0;\n border-top: 1px solid var(--_line);\n}\n.mero-cw-review__h {\n display: flex;\n align-items: center;\n gap: 7px;\n margin: 0 0 10px;\n font-size: 13px;\n font-weight: 700;\n letter-spacing: 0.02em;\n}\n.mero-cw-review__h .mero-cw-shield__icon {\n margin-top: -1px;\n}\n.mero-cw-review__kv {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin: 0;\n}\n.mero-cw-review__kv > div {\n display: grid;\n grid-template-columns: 96px minmax(0, 1fr);\n gap: 12px;\n}\n.mero-cw-review__kv dt {\n color: var(--_muted);\n}\n.mero-cw-review__kv dd {\n margin: 0;\n overflow-wrap: anywhere;\n}\n.mero-cw-review__kv--raw {\n margin-bottom: 12px;\n}\n.mero-cw-review__tone--good {\n color: var(--_good-ink);\n}\n.mero-cw-review__tone--bad {\n color: var(--_bad-ink);\n font-weight: 600;\n}\n.mero-cw-review__copy,\n.mero-cw-review__link {\n margin-left: 8px;\n padding: 0;\n border: 0;\n background: none;\n color: var(--_focus);\n font: inherit;\n font-size: 12.5px;\n font-weight: 600;\n text-decoration: none;\n cursor: pointer;\n}\n.mero-cw-review__link {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n}\n.mero-cw-review__copy:hover,\n.mero-cw-review__link:hover {\n text-decoration: underline;\n}\n.mero-cw-review__sum {\n display: flex;\n flex-direction: column;\n gap: 10px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.mero-cw-review__sum li {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n}\n.mero-cw-review__ic {\n display: grid;\n place-items: center;\n flex: none;\n width: 28px;\n height: 28px;\n border-radius: 50%;\n background: var(--_chip-bg);\n color: var(--_muted);\n}\n.mero-cw-review__sum li[data-tone=warn] .mero-cw-review__ic {\n background: var(--_warn-bg);\n color: var(--_warn-ink);\n}\n.mero-cw-review__sum li[data-tone=ok] .mero-cw-review__ic {\n background: var(--_good-bg);\n color: var(--_good-ink);\n}\n.mero-cw-review__tx {\n display: flex;\n flex-direction: column;\n min-width: 0;\n padding-top: 3px;\n}\n.mero-cw-review__tx span {\n color: var(--_muted);\n font-size: 12.5px;\n overflow-wrap: anywhere;\n}\n.mero-cw-review__more {\n margin-top: 0;\n}\n.mero-cw-review__sum + .mero-cw-review__more {\n margin-top: 10px;\n}\n.mero-cw-review__more > summary,\n.mero-cw-review__how > summary {\n display: flex;\n align-items: center;\n gap: 6px;\n min-height: 32px;\n color: var(--_focus);\n font-weight: 600;\n cursor: pointer;\n list-style: none;\n}\n.mero-cw-review summary::-webkit-details-marker {\n display: none;\n}\n.mero-cw-review__more > summary::after,\n.mero-cw-review__how > summary::after,\n.mero-cw-review__grp > summary::after,\n.mero-cw-review__act > summary::after {\n content: "";\n flex: none;\n width: 7px;\n height: 7px;\n margin: 0 3px;\n border: solid currentColor;\n border-width: 0 2px 2px 0;\n transform: rotate(-45deg);\n transition: transform 0.15s ease;\n}\n.mero-cw-review details[open] > summary::after {\n transform: rotate(45deg);\n}\n.mero-cw-review summary:focus-visible,\n.mero-cw-review__btn:focus-visible,\n.mero-cw-review__chip:focus-visible,\n.mero-cw-review__copy:focus-visible,\n.mero-cw-review__link:focus-visible {\n outline: 2px solid var(--_focus);\n outline-offset: 2px;\n border-radius: 6px;\n}\n.mero-cw-review__chips {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin: 4px 0 10px;\n}\n.mero-cw-review__chip {\n min-height: 30px;\n padding: 0 11px;\n border: 1px solid var(--_line);\n border-radius: 999px;\n background: var(--_surface);\n color: var(--_ink);\n font: inherit;\n font-size: 12.5px;\n font-weight: 600;\n cursor: pointer;\n}\n.mero-cw-review__chip[aria-pressed=true] {\n border-color: transparent;\n background: var(--_primary-bg);\n color: var(--_primary-ink);\n}\n.mero-cw-review__grp {\n margin-top: 8px;\n border: 1px solid var(--_line);\n border-radius: 12px;\n}\n.mero-cw-review__grp > summary {\n display: flex;\n align-items: center;\n gap: 10px;\n min-height: 48px;\n padding: 8px 12px;\n cursor: pointer;\n list-style: none;\n color: var(--_muted);\n}\n.mero-cw-review__grp-text {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-width: 0;\n}\n.mero-cw-review__grp-text b {\n color: var(--_ink);\n}\n.mero-cw-review__grp-text span {\n font-size: 12.5px;\n}\n.mero-cw-review__count {\n flex: none;\n min-width: 22px;\n padding: 1px 7px;\n border-radius: 999px;\n background: var(--_chip-bg);\n color: var(--_ink);\n font-size: 12px;\n font-weight: 600;\n text-align: center;\n}\n.mero-cw-review__acts {\n border-top: 1px solid var(--_line);\n}\n.mero-cw-review__act + .mero-cw-review__act {\n border-top: 1px solid var(--_line);\n}\n.mero-cw-review__act > summary,\n.mero-cw-review__act-head {\n display: flex;\n align-items: center;\n gap: 8px;\n min-height: 40px;\n padding: 6px 12px;\n cursor: pointer;\n list-style: none;\n color: var(--_muted);\n}\n.mero-cw-review__act-head {\n cursor: default;\n}\n.mero-cw-review__act-main {\n display: flex;\n flex: 1 1 0;\n flex-direction: column;\n gap: 1px;\n min-width: 0;\n}\n.mero-cw-review__act-title {\n color: var(--_ink);\n font-weight: 600;\n overflow-wrap: anywhere;\n}\n.mero-cw-review__act-doc {\n font-size: 12px;\n font-style: italic;\n overflow-wrap: anywhere;\n}\n.mero-cw-review__act-doc code,\n.mero-cw-review__said code {\n font-family:\n ui-monospace,\n "SF Mono",\n SFMono-Regular,\n Menlo,\n Consolas,\n monospace;\n font-size: 0.92em;\n font-style: normal;\n}\n.mero-cw-review__act > summary::after {\n margin-left: 0;\n}\n.mero-cw-review__tags {\n display: flex;\n flex: none;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: 4px;\n max-width: 55%;\n}\n.mero-cw-review__tag {\n padding: 1px 8px;\n border-radius: 999px;\n background: var(--_chip-bg);\n color: var(--_muted);\n font-size: 11.5px;\n font-weight: 600;\n white-space: nowrap;\n}\n.mero-cw-review__tag--passkey {\n background: var(--_warn-bg);\n color: var(--_warn-ink);\n}\n.mero-cw-review__tag--public {\n background: var(--_busy-bg);\n color: var(--_busy-ink);\n}\n.mero-cw-review__facts {\n padding: 2px 12px 12px;\n}\n.mero-cw-review__facts .mero-cw-review__kv {\n font-size: 12.5px;\n}\n.mero-cw-review__said {\n margin-top: 10px;\n padding: 8px 10px;\n border: 1px dashed var(--_line);\n border-radius: 8px;\n}\n.mero-cw-review__said span {\n color: var(--_muted);\n font-size: 11.5px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n}\n.mero-cw-review__said p {\n margin: 2px 0 0;\n font-style: italic;\n overflow-wrap: anywhere;\n}\n.mero-cw-review__note {\n margin: 10px 0 0;\n color: var(--_muted);\n font-size: 12px;\n}\n.mero-cw-review__claims {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.mero-cw-review__claims li {\n display: flex;\n align-items: flex-start;\n gap: 7px;\n}\n.mero-cw-review__claims .mero-cw-shield__tick {\n margin-top: 3px;\n color: var(--_good-ink);\n}\n.mero-cw-review__claims--plain b {\n font-weight: 500;\n color: var(--_muted);\n}\n.mero-cw-review__claims + .mero-cw-review__grey {\n margin-top: 10px;\n}\n.mero-cw-review__how {\n margin-top: 6px;\n}\n.mero-cw-review__how ul {\n margin: 0 0 4px;\n padding-left: 18px;\n color: var(--_muted);\n font-size: 12.5px;\n}\n.mero-cw-review__except {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin: 10px 0 0;\n padding: 0;\n list-style: none;\n}\n.mero-cw-review__except li {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n padding: 8px 10px;\n border-radius: 10px;\n background: var(--_warn-bg);\n color: var(--_warn-ink);\n font-weight: 600;\n overflow-wrap: anywhere;\n}\n.mero-cw-review__except .mero-cw-review__icon {\n margin-top: 2px;\n}\n.mero-cw-review__grey {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin: 0;\n padding: 10px 12px;\n border-radius: 10px;\n background: var(--_tone-bg);\n color: var(--_ink);\n}\n.mero-cw-review__grey span {\n color: var(--_muted);\n font-size: 12.5px;\n}\n.mero-cw-review__alert {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px 12px;\n margin: 10px 0 4px;\n padding: 10px 12px;\n border-radius: 10px;\n background: var(--_bad-bg);\n color: var(--_bad-ink);\n}\n.mero-cw-review__alert p {\n flex: 1 1 220px;\n margin: 0;\n font-weight: 600;\n overflow-wrap: anywhere;\n}\n.mero-cw-review__buttons {\n position: sticky;\n bottom: calc(0px - var(--cw-review-inset, 0px));\n z-index: 1;\n display: flex;\n justify-content: space-between;\n gap: 10px;\n margin-top: 6px;\n padding: 14px 0 calc(env(safe-area-inset-bottom, 0px) + 8px);\n border-top: 1px solid var(--_line);\n background: var(--_surface);\n}\n.mero-cw-review__btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-height: 40px;\n padding: 0 18px;\n border: 1px solid var(--_line);\n border-radius: 999px;\n background: var(--_surface);\n color: var(--_ink);\n font: inherit;\n font-weight: 600;\n cursor: pointer;\n}\n.mero-cw-review__btn:hover:not(:disabled) {\n border-color: var(--_ink);\n}\n.mero-cw-review__btn:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n.mero-cw-review__buttons .mero-cw-review__btn {\n white-space: nowrap;\n}\n.mero-cw-review__btn--primary {\n border-color: transparent;\n background: var(--_primary-bg);\n color: var(--_primary-ink);\n}\n.mero-cw-review__btn--primary:hover:not(:disabled) {\n border-color: transparent;\n opacity: 0.88;\n}\n@media (max-width: 480px) {\n .mero-cw-review__kv > div {\n grid-template-columns: minmax(0, 1fr);\n gap: 0;\n }\n .mero-cw-review__kv dt {\n font-size: 12px;\n }\n .mero-cw-review__buttons .mero-cw-review__btn {\n flex: 1;\n padding: 0 12px;\n }\n .mero-cw-review__buttons .mero-cw-review__btn--primary {\n flex: 2;\n }\n}\n');
|
|
1873
|
+
|
|
1874
|
+
// src/create-workspace/createWorkspace.css
|
|
1875
|
+
chunkRRETZWNI_cjs.styleInject('.mero-cw-overlay {\n position: fixed;\n inset: 0;\n z-index: var(--cw-z, 2147483000);\n display: grid;\n place-items: center;\n padding: 16px;\n background: rgba(15, 17, 23, 0.45);\n}\n.mero-cw-card {\n position: relative;\n box-sizing: border-box;\n width: 100%;\n max-width: 420px;\n max-height: calc(100dvh - 32px);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n border-radius: 18px;\n background: var(--_surface);\n color: var(--_ink);\n box-shadow: 0 10px 30px rgba(15, 17, 23, 0.18);\n}\n.mero-cw-body {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n padding: 20px 22px 0;\n}\n.mero-cw-body > :last-child {\n margin-bottom: 20px;\n}\n.mero-cw-body .mero-cw-review__buttons {\n margin-bottom: 0;\n padding-bottom: 18px;\n}\n.mero-cw-card *,\n.mero-cw-card *::before,\n.mero-cw-card *::after {\n box-sizing: border-box;\n}\n.mero-cw-x {\n position: absolute;\n top: 12px;\n right: 14px;\n z-index: 2;\n display: grid;\n place-items: center;\n width: 28px;\n height: 28px;\n padding: 0;\n border: 0;\n border-radius: 50%;\n background: none;\n color: var(--_muted);\n cursor: pointer;\n}\n.mero-cw-x:hover {\n background: var(--_code-bg);\n color: var(--_ink);\n}\n.mero-cw-title {\n margin: 0 0 4px;\n padding-right: 28px;\n font-size: 17px;\n font-weight: 700;\n}\n.mero-cw-sub {\n margin: 0 0 14px;\n color: var(--_muted);\n font-size: 12.5px;\n line-height: 1.45;\n}\n.mero-cw-field {\n margin: 0 0 12px;\n}\n.mero-cw-field label {\n display: block;\n margin: 0 0 5px;\n font-size: 12px;\n font-weight: 600;\n}\n.mero-cw-field input {\n width: 100%;\n padding: 9px 11px;\n border: 1px solid var(--_line);\n border-radius: 10px;\n background: var(--_surface);\n color: var(--_ink);\n font: inherit;\n font-size: 13px;\n}\n.mero-cw-field input:focus-visible {\n outline: 2px solid var(--_focus);\n outline-offset: 1px;\n}\n.mero-cw-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-height: 38px;\n padding: 0 16px;\n border: 1px solid var(--_line);\n border-radius: 999px;\n background: var(--_surface);\n color: var(--_ink);\n font: inherit;\n font-size: 13px;\n font-weight: 600;\n cursor: pointer;\n}\n.mero-cw-btn:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n.mero-cw-btn--primary {\n border-color: transparent;\n background: var(--_primary-bg);\n color: var(--_primary-ink);\n}\n.mero-cw-btn--full {\n width: 100%;\n}\n.mero-cw-btn:focus-visible,\n.mero-cw-link:focus-visible,\n.mero-cw-x:focus-visible {\n outline: 2px solid var(--_focus);\n outline-offset: 2px;\n}\n.mero-cw-link {\n border: 0;\n background: none;\n color: var(--_focus);\n font: inherit;\n font-size: 12.5px;\n font-weight: 600;\n cursor: pointer;\n}\n.mero-cw-link:hover {\n text-decoration: underline;\n}\n.mero-cw-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n margin-top: 14px;\n}\n.mero-cw-code {\n margin: 10px 0;\n padding: 10px;\n border-radius: 12px;\n background: var(--_code-bg);\n font-family:\n ui-monospace,\n "SF Mono",\n SFMono-Regular,\n Menlo,\n Consolas,\n monospace;\n font-size: 22px;\n font-weight: 700;\n letter-spacing: 3px;\n text-align: center;\n}\n.mero-cw-wait {\n display: flex;\n align-items: center;\n gap: 8px;\n color: var(--_muted);\n font-size: 12.5px;\n}\n.mero-cw-dot {\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--_focus);\n}\n@media (prefers-reduced-motion: no-preference) {\n .mero-cw-dot {\n animation: mero-cw-pulse 1.2s infinite;\n }\n}\n@keyframes mero-cw-pulse {\n 50% {\n opacity: 0.25;\n }\n}\n.mero-cw-error {\n margin: 0 0 12px;\n padding: 10px 12px;\n border-radius: 10px;\n background: var(--_bad-bg);\n color: var(--_bad-ink);\n font-size: 13px;\n font-weight: 600;\n overflow-wrap: anywhere;\n}\n.mero-cw-notice {\n position: fixed;\n right: 16px;\n bottom: 16px;\n z-index: var(--cw-z, 2147483000);\n max-width: 360px;\n padding: 10px 14px;\n border-radius: 10px;\n background: var(--_surface);\n color: var(--_ink);\n font-size: 13px;\n line-height: 1.4;\n box-shadow: 0 0 0 1px var(--_line), 0 12px 28px -12px rgba(14, 18, 34, 0.4);\n}\n');
|
|
1876
|
+
|
|
1877
|
+
// src/create-workspace/clusterName.ts
|
|
1878
|
+
var LOCAL_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
1879
|
+
var NODE_HOST = /^(.+)-n\d+\./;
|
|
1880
|
+
function clusterName(nodeUrl) {
|
|
1881
|
+
let host;
|
|
1882
|
+
try {
|
|
1883
|
+
host = new URL(nodeUrl).hostname;
|
|
1884
|
+
} catch {
|
|
1885
|
+
return nodeUrl;
|
|
1886
|
+
}
|
|
1887
|
+
if (LOCAL_HOSTS.has(host)) return "merod local";
|
|
1888
|
+
return NODE_HOST.exec(host)?.[1] ?? host;
|
|
1889
|
+
}
|
|
1890
|
+
var ICONS = {
|
|
1891
|
+
key: ["M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.78 7.78 5.5 5.5 0 0 1 7.78-7.78zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"],
|
|
1892
|
+
globe: ["M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z", "M2 12h20", "M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"],
|
|
1893
|
+
out: ["M7 17 17 7M7 7h10v10"],
|
|
1894
|
+
clock: ["M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z", "M12 6v6l4 2"],
|
|
1895
|
+
check: ["m5 12.5 4.5 4.5L19 7.5"],
|
|
1896
|
+
link: ["M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"],
|
|
1897
|
+
pencil: ["M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"],
|
|
1898
|
+
eye: ["M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z", "M12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z"],
|
|
1899
|
+
bell: ["M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9M13.7 21a2 2 0 0 1-3.4 0"],
|
|
1900
|
+
dots: ["M5 12h.01M12 12h.01M19 12h.01"],
|
|
1901
|
+
warn: ["M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z", "M12 9v4M12 17h.01"]
|
|
1902
|
+
};
|
|
1903
|
+
function ShieldIcon({ kind }) {
|
|
1904
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "mero-cw-shield__icon", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", "aria-hidden": "true", children: [
|
|
1905
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 2 4 5v6c0 5 3.4 9.4 8 11 4.6-1.6 8-6 8-11V5l-8-3z", fill: "currentColor", opacity: ".18" }),
|
|
1906
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 2 4 5v6c0 5 3.4 9.4 8 11 4.6-1.6 8-6 8-11V5l-8-3z", stroke: "currentColor", strokeWidth: "2", strokeLinejoin: "round" }),
|
|
1907
|
+
kind === "verified" && /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m8.5 12 2.4 2.4L15.5 9.8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
1908
|
+
kind === "refused" && /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m9.5 9.5 5 5m0-5-5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }),
|
|
1909
|
+
kind === "unsealed" && /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 8v4.5M12 15.6v.1", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })
|
|
1910
|
+
] });
|
|
1911
|
+
}
|
|
1912
|
+
var Tick = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "mero-cw-shield__tick", viewBox: "0 0 24 24", width: "14", height: "14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: ICONS.check[0], stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1913
|
+
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" }) });
|
|
1914
|
+
function Icon({ name }) {
|
|
1915
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "mero-cw-review__icon", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: ICONS[name].map((d) => /* @__PURE__ */ jsxRuntime.jsx("path", { d }, d)) });
|
|
1916
|
+
}
|
|
1917
|
+
var MAX_UNBROKEN = 30;
|
|
1918
|
+
function HostText({ text }) {
|
|
1919
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: text.split(".").map((piece, i, all) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
1920
|
+
/^\S+$/.test(piece) && piece.length <= MAX_UNBROKEN ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-review__nobreak", children: piece }) : piece,
|
|
1921
|
+
i < all.length - 1 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1922
|
+
".",
|
|
1923
|
+
/* @__PURE__ */ jsxRuntime.jsx("wbr", {})
|
|
1924
|
+
] })
|
|
1925
|
+
] }, i)) });
|
|
1926
|
+
}
|
|
1927
|
+
var COPIED_MS = 2e3;
|
|
1928
|
+
function useCopy() {
|
|
1929
|
+
const [state, setState] = react.useState("idle");
|
|
1930
|
+
react.useEffect(() => {
|
|
1931
|
+
if (state === "idle") return;
|
|
1932
|
+
const timer = setTimeout(() => setState("idle"), COPIED_MS);
|
|
1933
|
+
return () => clearTimeout(timer);
|
|
1934
|
+
}, [state]);
|
|
1935
|
+
const copy = (text) => void Promise.resolve().then(() => navigator.clipboard.writeText(text)).then(
|
|
1936
|
+
() => setState("done"),
|
|
1937
|
+
() => setState("failed")
|
|
1938
|
+
);
|
|
1939
|
+
return [state, copy];
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
// src/create-workspace/workspaceFacts.ts
|
|
1943
|
+
var LIST_SHOWN = 3;
|
|
1944
|
+
var SIGNER_SHORT_AFTER = 16;
|
|
1945
|
+
var SIGNER_HEAD = 12;
|
|
1946
|
+
var EVERY_UNITS = { s: "second", m: "minute", h: "hour" };
|
|
1947
|
+
var INVITED_ONLY = "Only people invited to it can open it";
|
|
1948
|
+
var NOT_READABLE = "Calimero can't read it.";
|
|
1949
|
+
var TEST_SERVER_ENFORCES = ", as this test server enforces it";
|
|
1950
|
+
var CONTROL = { creator: "Only you control it", member: "Only the workspace's owners control it" };
|
|
1951
|
+
var MAX_DOC_CHARS = 4e3;
|
|
1952
|
+
var WORD_TAIL = 8;
|
|
1953
|
+
var ABBREVIATIONS = /* @__PURE__ */ new Set(["e.g", "i.e", "etc", "vs", "cf"]);
|
|
1954
|
+
var CALLED_KINDS = /* @__PURE__ */ new Set(["call", "view", "action"]);
|
|
1955
|
+
function humanize(name) {
|
|
1956
|
+
const words = name.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim().toLowerCase();
|
|
1957
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
1958
|
+
}
|
|
1959
|
+
function everyWords(every) {
|
|
1960
|
+
const match = /^(\d+)([smh])$/.exec(every);
|
|
1961
|
+
const unit = match?.[2] ? EVERY_UNITS[match[2]] : void 0;
|
|
1962
|
+
return match && unit ? `${match[1]} ${unit}${match[1] === "1" ? "" : "s"}` : every;
|
|
1963
|
+
}
|
|
1964
|
+
function docParagraphs(doc) {
|
|
1965
|
+
const bounded = doc.length > MAX_DOC_CHARS ? `${doc.slice(0, MAX_DOC_CHARS)}\u2026` : doc;
|
|
1966
|
+
const paragraphs = [];
|
|
1967
|
+
let lines = [];
|
|
1968
|
+
const flush = () => {
|
|
1969
|
+
if (lines.length) paragraphs.push(lines.join(" "));
|
|
1970
|
+
lines = [];
|
|
1971
|
+
};
|
|
1972
|
+
for (const line of bounded.split("\n")) {
|
|
1973
|
+
const text = line.trim();
|
|
1974
|
+
if (text) lines.push(text);
|
|
1975
|
+
else flush();
|
|
1976
|
+
}
|
|
1977
|
+
flush();
|
|
1978
|
+
return paragraphs;
|
|
1979
|
+
}
|
|
1980
|
+
function firstSentence(doc) {
|
|
1981
|
+
const first = docParagraphs(doc)[0] ?? "";
|
|
1982
|
+
for (const end of first.matchAll(/[.!?](?=\s+[A-Z`"'(])/g)) {
|
|
1983
|
+
const word = /[\w.]*$/.exec(first.slice(Math.max(0, end.index - WORD_TAIL), end.index))?.[0] ?? "";
|
|
1984
|
+
if (!ABBREVIATIONS.has(word.toLowerCase())) return first.slice(0, end.index + 1);
|
|
1985
|
+
}
|
|
1986
|
+
return first;
|
|
1987
|
+
}
|
|
1988
|
+
function list(items) {
|
|
1989
|
+
if (items.length <= LIST_SHOWN) return items.join(", ");
|
|
1990
|
+
return `${items.slice(0, LIST_SHOWN).join(", ")}, and ${items.length - LIST_SHOWN} more`;
|
|
1991
|
+
}
|
|
1992
|
+
var plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
1993
|
+
function namesOf(entries) {
|
|
1994
|
+
if (Array.isArray(entries)) return entries.map((e) => typeof e === "string" ? e : String(e?.name ?? ""));
|
|
1995
|
+
return entries && typeof entries === "object" ? Object.keys(entries) : [];
|
|
1996
|
+
}
|
|
1997
|
+
var hasApps = (m) => (m.allowApps?.length ?? 0) > 0;
|
|
1998
|
+
function reachable(m) {
|
|
1999
|
+
return CALLED_KINDS.has(m.kind) && !m.allowAction && !m.computeResult;
|
|
2000
|
+
}
|
|
2001
|
+
var plainCall = (m) => reachable(m) && (m.kind === "call" || m.kind === "view");
|
|
2002
|
+
var publicView = (m) => plainCall(m) && m.public && m.kind === "view";
|
|
2003
|
+
var publicCall = (m) => plainCall(m) && m.public && m.kind === "call";
|
|
2004
|
+
var sharedWithApps = (m) => plainCall(m) && hasApps(m);
|
|
2005
|
+
var openToAnyone = (m) => reachable(m) && m.public;
|
|
2006
|
+
function internal(m) {
|
|
2007
|
+
return (m.kind === "init" || !!m.computeResult || !!m.allowAction) && !m.confirm;
|
|
2008
|
+
}
|
|
2009
|
+
var allMethods = (abi) => Object.entries(abi?.methods ?? {});
|
|
2010
|
+
function visibleMethods(abi) {
|
|
2011
|
+
return allMethods(abi).filter(([, m]) => !internal(m));
|
|
2012
|
+
}
|
|
2013
|
+
function actionCount(abi) {
|
|
2014
|
+
return visibleMethods(abi).length;
|
|
2015
|
+
}
|
|
2016
|
+
function summarize(card, signed = true) {
|
|
2017
|
+
const lines = [];
|
|
2018
|
+
const all = allMethods(card.abi);
|
|
2019
|
+
const titles = (pick) => all.filter(([, m]) => pick(m)).map(([name]) => humanize(name));
|
|
2020
|
+
const passkey = titles((m) => m.confirm);
|
|
2021
|
+
if (passkey.length) lines.push({ id: "passkey", title: `Asks for your passkey before ${plural(passkey.length, "sensitive action")}`, detail: list(passkey), tone: "warn" });
|
|
2022
|
+
const seen = titles(publicView);
|
|
2023
|
+
if (seen.length) lines.push({ id: "public", title: `Shows ${plural(seen.length, "thing")} to anyone`, detail: list(seen), tone: "warn" });
|
|
2024
|
+
const changed = titles(publicCall);
|
|
2025
|
+
if (changed.length) lines.push({ id: "publicCalls", title: `Lets anyone use ${plural(changed.length, "action")} without signing in`, detail: list(changed), tone: "warn" });
|
|
2026
|
+
if (card.outbound.length) lines.push({ id: "outside", title: `Contacts ${plural(card.outbound.length, "outside service")}`, detail: list(card.outbound.map(chunkRRETZWNI_cjs.hostOf)) });
|
|
2027
|
+
const timers = all.filter(([, m]) => m.kind === "timer").map(([name, m]) => `${m.every ? `Every ${everyWords(m.every)}: ` : ""}${humanize(name)}`);
|
|
2028
|
+
if (timers.length) lines.push({ id: "timers", title: `Runs ${plural(timers.length, "task")} on its own`, detail: list(timers) });
|
|
2029
|
+
if (card.abi) {
|
|
2030
|
+
const methods = Object.values(card.abi.methods);
|
|
2031
|
+
const shared = methods.filter(sharedWithApps);
|
|
2032
|
+
if (shared.length > 0) {
|
|
2033
|
+
const apps = [...new Set(shared.flatMap((m) => m.allowApps ?? []))];
|
|
2034
|
+
lines.push({ id: "apps", title: `Lets other apps call ${plural(shared.length, "action")}`, detail: apps.includes("*") ? "Any app" : list(apps), tone: "warn" });
|
|
2035
|
+
} else if (!methods.some(openToAnyone)) {
|
|
2036
|
+
lines.push(
|
|
2037
|
+
signed ? { id: "apps", title: "No other app can use your data", detail: "No action is open to other apps", tone: "ok" } : { id: "apps", title: "No other app can use your data, as this test server lists it", detail: "No action is open to other apps" }
|
|
2038
|
+
);
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
return lines;
|
|
2042
|
+
}
|
|
2043
|
+
function whoCanTrigger(m) {
|
|
2044
|
+
if (m.kind === "timer") return "The system, on a schedule";
|
|
2045
|
+
if (m.allowAction) return "Only the app's own actions";
|
|
2046
|
+
if (m.kind === "action") return "You, signed in to this app";
|
|
2047
|
+
if (m.kind === "compute") return "The app itself";
|
|
2048
|
+
if (m.kind !== "call" && m.kind !== "view") return null;
|
|
2049
|
+
const who = [m.public ? "Anyone, no sign-in" : "You, signed in to this app"];
|
|
2050
|
+
if (m.allowSystem) who.push("the system");
|
|
2051
|
+
if (hasApps(m)) who.push(`apps: ${(m.allowApps ?? []).map((a) => a === "*" ? "any app" : a).join(", ")}`);
|
|
2052
|
+
return who.join("; ");
|
|
2053
|
+
}
|
|
2054
|
+
var KIND_LABEL = {
|
|
2055
|
+
call: "Change (call)",
|
|
2056
|
+
view: "Read (view)",
|
|
2057
|
+
timer: "Timer",
|
|
2058
|
+
action: "Action",
|
|
2059
|
+
compute: "Compute"
|
|
2060
|
+
};
|
|
2061
|
+
function methodTags(m) {
|
|
2062
|
+
const tags = [];
|
|
2063
|
+
if (m.confirm) tags.push("passkey");
|
|
2064
|
+
if (plainCall(m) && m.public) tags.push("public");
|
|
2065
|
+
if (m.kind === "call" || m.kind === "action") tags.push("changes data");
|
|
2066
|
+
else if (m.kind === "view") tags.push("reads data");
|
|
2067
|
+
else tags.push(m.kind);
|
|
2068
|
+
return tags;
|
|
2069
|
+
}
|
|
2070
|
+
function methodFacts(name, m) {
|
|
2071
|
+
const facts = [
|
|
2072
|
+
{ label: "Technical name", value: name, mono: true },
|
|
2073
|
+
{ label: "Type", value: KIND_LABEL[m.kind] ?? m.kind }
|
|
2074
|
+
];
|
|
2075
|
+
if (m.kind === "timer" && m.every) facts.push({ label: "Runs", value: `Every ${everyWords(m.every)}` });
|
|
2076
|
+
const who = whoCanTrigger(m);
|
|
2077
|
+
if (who) facts.push({ label: "Who can trigger", value: who });
|
|
2078
|
+
facts.push(
|
|
2079
|
+
{ label: "Confirmation", value: m.confirm ? "Passkey prompt every time" : "None" },
|
|
2080
|
+
{ label: "Takes", value: m.params.length ? m.params.map(([n, t]) => `${n}: ${t}`).join(", ") : "Nothing", mono: m.params.length > 0 },
|
|
2081
|
+
{ label: "Returns", value: m.returns ?? "Nothing", mono: m.returns !== null }
|
|
2082
|
+
);
|
|
2083
|
+
if (m.kind !== "timer") facts.push({ label: "Limit", value: m.rate ?? "None" });
|
|
2084
|
+
return facts;
|
|
2085
|
+
}
|
|
2086
|
+
function methodView(name, m) {
|
|
2087
|
+
const paragraphs = docParagraphs(m.doc ?? "");
|
|
2088
|
+
const doc = paragraphs.length ? { doc: paragraphs.join("\n\n"), summary: firstSentence(m.doc ?? "") } : {};
|
|
2089
|
+
return { name, title: humanize(name), ...doc, tags: methodTags(m), facts: methodFacts(name, m) };
|
|
2090
|
+
}
|
|
2091
|
+
var MEMBERS = [
|
|
2092
|
+
{ id: "passkey", label: "Needs your passkey", chip: "Needs passkey", blurb: "The app cannot do these without you confirming", has: (m) => m.confirm },
|
|
2093
|
+
{ id: "public", label: "Visible to anyone", chip: "Public", blurb: "Can be used without signing in", has: (m) => plainCall(m) && m.public },
|
|
2094
|
+
{ id: "changes", label: "Changes your data", chip: "Changes data", blurb: "Create, update or delete what is stored", has: (m) => m.kind === "call" || m.kind === "action" },
|
|
2095
|
+
{ id: "reads", label: "Reads your data", chip: "Reads data", blurb: "Look at what is stored without changing it", has: (m) => m.kind === "view" },
|
|
2096
|
+
{ id: "timers", label: "Runs on its own", chip: "On its own", blurb: "Starts without anyone asking, on a schedule", has: (m) => m.kind === "timer" }
|
|
2097
|
+
];
|
|
2098
|
+
var OTHER_KINDS = /* @__PURE__ */ new Set(["call", "action", "view", "timer"]);
|
|
2099
|
+
function actionGroups(card) {
|
|
2100
|
+
const visible = visibleMethods(card.abi);
|
|
2101
|
+
const groups = MEMBERS.map(({ has, ...group }) => ({
|
|
2102
|
+
...group,
|
|
2103
|
+
items: visible.filter(([, m]) => has(m)).map(([name, m]) => methodView(name, m))
|
|
2104
|
+
}));
|
|
2105
|
+
groups.push({
|
|
2106
|
+
id: "outside",
|
|
2107
|
+
label: "Outside services",
|
|
2108
|
+
chip: "Outside",
|
|
2109
|
+
blurb: "The only sites the app may contact, enforced by the node",
|
|
2110
|
+
items: card.outbound.map((host) => ({ name: host, title: chunkRRETZWNI_cjs.hostOf(host), tags: [], facts: [] }))
|
|
2111
|
+
});
|
|
2112
|
+
const events = card.abi?.events;
|
|
2113
|
+
groups.push({
|
|
2114
|
+
id: "events",
|
|
2115
|
+
label: "Updates it broadcasts",
|
|
2116
|
+
chip: "Updates",
|
|
2117
|
+
blurb: "Messages the app sends out when something happens",
|
|
2118
|
+
items: namesOf(events).map((name) => {
|
|
2119
|
+
const fields = events && !Array.isArray(events) ? events[name] : null;
|
|
2120
|
+
const facts = fields && typeof fields === "object" ? Object.entries(fields).map(([label, type]) => ({ label, value: String(type), mono: true })) : [];
|
|
2121
|
+
return { name, title: humanize(name), tags: [], facts };
|
|
2122
|
+
})
|
|
2123
|
+
});
|
|
2124
|
+
groups.push({
|
|
2125
|
+
id: "other",
|
|
2126
|
+
label: "Other methods",
|
|
2127
|
+
chip: "Other",
|
|
2128
|
+
blurb: "Do not fit the groups above",
|
|
2129
|
+
items: visible.filter(([, m]) => !OTHER_KINDS.has(m.kind)).map(([name, m]) => methodView(name, m))
|
|
2130
|
+
});
|
|
2131
|
+
return groups.filter((g) => g.items.length > 0);
|
|
2132
|
+
}
|
|
2133
|
+
function exceptions(card, sealed = true) {
|
|
2134
|
+
const named = (pick, prefix) => allMethods(card.abi).filter(([, m]) => pick(m)).map(([name]) => `${prefix}${humanize(name)}`);
|
|
2135
|
+
const hosts = card.outbound.map((host) => `${sealed ? "Leaves the sealed hardware" : "Contacts"}: ${chunkRRETZWNI_cjs.hostOf(host)}`);
|
|
2136
|
+
return [...named(publicView, "Anyone can see: "), ...named(publicCall, "Anyone can change: "), ...hosts];
|
|
2137
|
+
}
|
|
2138
|
+
function rawFacts(card) {
|
|
2139
|
+
return [
|
|
2140
|
+
{ label: "Manifest hash", value: card.manifestHash },
|
|
2141
|
+
{ label: "WASM (bundle) hash", value: card.bundle },
|
|
2142
|
+
{ label: "Signer", value: card.signer },
|
|
2143
|
+
{ label: ".mpk hash", value: card.mpk }
|
|
2144
|
+
];
|
|
2145
|
+
}
|
|
2146
|
+
var abiFileName = (card) => `${card.package}-${card.version}-abi.json`;
|
|
2147
|
+
function shortSigner(signer) {
|
|
2148
|
+
return signer.length > SIGNER_SHORT_AFTER ? `${signer.slice(0, SIGNER_HEAD)}\u2026${signer.slice(-4)}` : signer;
|
|
2149
|
+
}
|
|
2150
|
+
function codeLine(card, evidence, signed = true) {
|
|
2151
|
+
const fromRelease = `bundle ${chunkRRETZWNI_cjs.shortHash(card.bundle)}, from ${signed ? "the signed release" : "the release as this test server lists it"}`;
|
|
2152
|
+
return { text: fromRelease };
|
|
2153
|
+
}
|
|
2154
|
+
function dataStatements(kind, viewer) {
|
|
2155
|
+
if (kind === "verified") return [`${CONTROL[viewer]}.`, `${INVITED_ONLY}.`, NOT_READABLE];
|
|
2156
|
+
if (kind === "unsealed") return [`${CONTROL[viewer]}${TEST_SERVER_ENFORCES}`, `${INVITED_ONLY}${TEST_SERVER_ENFORCES}`];
|
|
2157
|
+
return [];
|
|
2158
|
+
}
|
|
2159
|
+
var OPEN_GROUP_MAX = 3;
|
|
2160
|
+
var SUMMARY_ICON = (line) => {
|
|
2161
|
+
const icons = { passkey: "key", public: "globe", publicCalls: "globe", outside: "out", timers: "clock", apps: line.tone === "warn" ? "link" : "check" };
|
|
2162
|
+
return icons[line.id];
|
|
2163
|
+
};
|
|
2164
|
+
var GROUP_ICON = { passkey: "key", public: "globe", changes: "pencil", reads: "eye", timers: "clock", outside: "out", events: "bell", other: "dots" };
|
|
2165
|
+
function CopyButton({ text, label }) {
|
|
2166
|
+
const [copied, copy] = useCopy();
|
|
2167
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-review__copy", "aria-label": label, onClick: () => copy(text), children: copied === "done" ? "Copied" : copied === "failed" ? "Could not copy" : "Copy" });
|
|
2168
|
+
}
|
|
2169
|
+
function downloadAbi(card) {
|
|
2170
|
+
const url = URL.createObjectURL(new Blob([JSON.stringify(card.abi, null, 2)], { type: "application/json" }));
|
|
2171
|
+
const link = document.createElement("a");
|
|
2172
|
+
link.href = url;
|
|
2173
|
+
link.download = abiFileName(card);
|
|
2174
|
+
link.click();
|
|
2175
|
+
setTimeout(() => URL.revokeObjectURL(url));
|
|
2176
|
+
}
|
|
2177
|
+
function Facts({ facts }) {
|
|
2178
|
+
return /* @__PURE__ */ jsxRuntime.jsx("dl", { className: "mero-cw-review__kv", children: facts.map((f) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2179
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: f.label }),
|
|
2180
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: f.mono ? "mero-cw-review__mono" : void 0, children: f.value })
|
|
2181
|
+
] }, f.label)) });
|
|
2182
|
+
}
|
|
2183
|
+
function DocText({ text }) {
|
|
2184
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: text.split("`").map((part, i) => i % 2 === 1 ? /* @__PURE__ */ jsxRuntime.jsx("code", { children: part }, i) : part) });
|
|
2185
|
+
}
|
|
2186
|
+
function ActionRow({ item, mono }) {
|
|
2187
|
+
const title = /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "mero-cw-review__act-main", children: [
|
|
2188
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: mono ? "mero-cw-review__act-title mero-cw-review__mono" : "mero-cw-review__act-title", children: item.title }),
|
|
2189
|
+
item.summary && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-review__act-doc", "data-publisher": "", children: /* @__PURE__ */ jsxRuntime.jsx(DocText, { text: item.summary }) })
|
|
2190
|
+
] });
|
|
2191
|
+
const tags = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-review__tags", children: item.tags.map((tag) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: `mero-cw-review__tag mero-cw-review__tag--${tag.split(" ")[0]}`, children: tag }, tag)) });
|
|
2192
|
+
if (item.facts.length === 0 && !item.doc) {
|
|
2193
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-review__act mero-cw-review__act--flat", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-review__act-head", children: [
|
|
2194
|
+
title,
|
|
2195
|
+
tags
|
|
2196
|
+
] }) });
|
|
2197
|
+
}
|
|
2198
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("details", { className: "mero-cw-review__act", children: [
|
|
2199
|
+
/* @__PURE__ */ jsxRuntime.jsxs("summary", { children: [
|
|
2200
|
+
title,
|
|
2201
|
+
tags
|
|
2202
|
+
] }),
|
|
2203
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-review__facts", children: [
|
|
2204
|
+
/* @__PURE__ */ jsxRuntime.jsx(Facts, { facts: item.facts }),
|
|
2205
|
+
item.doc && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-review__said", "data-publisher": "", children: [
|
|
2206
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Publisher's description" }),
|
|
2207
|
+
item.doc.split("\n\n").map((paragraph) => /* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(DocText, { text: paragraph }) }, paragraph))
|
|
2208
|
+
] })
|
|
2209
|
+
] })
|
|
2210
|
+
] });
|
|
2211
|
+
}
|
|
2212
|
+
function GroupView({ group, filtered }) {
|
|
2213
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("details", { className: "mero-cw-review__grp", open: filtered || group.items.length <= OPEN_GROUP_MAX, children: [
|
|
2214
|
+
/* @__PURE__ */ jsxRuntime.jsxs("summary", { children: [
|
|
2215
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { name: GROUP_ICON[group.id] }),
|
|
2216
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "mero-cw-review__grp-text", children: [
|
|
2217
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: group.label }),
|
|
2218
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: group.blurb })
|
|
2219
|
+
] }),
|
|
2220
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-review__count", children: group.items.length })
|
|
2221
|
+
] }),
|
|
2222
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-review__acts", children: group.items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(ActionRow, { item, mono: group.id === "outside" }, item.name)) })
|
|
2223
|
+
] });
|
|
2224
|
+
}
|
|
2225
|
+
function AllActions({ card, signed }) {
|
|
2226
|
+
const groups = actionGroups(card);
|
|
2227
|
+
const [only, setOnly] = react.useState(null);
|
|
2228
|
+
const count = actionCount(card.abi);
|
|
2229
|
+
if (groups.length === 0) return null;
|
|
2230
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("details", { className: "mero-cw-review__more", children: [
|
|
2231
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: count > 0 ? `See all ${count} ${count === 1 ? "action" : "actions"}` : "See details" }) }),
|
|
2232
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-review__chips", role: "group", "aria-label": "Filter actions", children: [
|
|
2233
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-review__chip", "aria-pressed": only === null, onClick: () => setOnly(null), children: "All" }),
|
|
2234
|
+
groups.map((g) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-review__chip", "aria-pressed": only === g.id, onClick: () => setOnly(g.id), children: `${g.chip} (${g.items.length})` }, g.id))
|
|
2235
|
+
] }),
|
|
2236
|
+
groups.filter((g) => only === null || g.id === only).map((g) => /* @__PURE__ */ jsxRuntime.jsx(GroupView, { group: g, filtered: only !== null }, g.id)),
|
|
2237
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mero-cw-review__note", children: [
|
|
2238
|
+
"Tags and facts come from ",
|
|
2239
|
+
signed ? "the app's signed release" : "the release as this test server lists it",
|
|
2240
|
+
". The publisher's description is the publisher's own words and is not checked."
|
|
2241
|
+
] })
|
|
2242
|
+
] });
|
|
2243
|
+
}
|
|
2244
|
+
function SignedFacts({ card, signed }) {
|
|
2245
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("details", { className: "mero-cw-review__more", children: [
|
|
2246
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: signed ? "Signed facts" : "Facts as this test server lists them" }) }),
|
|
2247
|
+
/* @__PURE__ */ jsxRuntime.jsx("dl", { className: "mero-cw-review__kv mero-cw-review__kv--raw", children: rawFacts(card).map((f) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2248
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: f.label }),
|
|
2249
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "mero-cw-review__mono", children: f.value })
|
|
2250
|
+
] }, f.label)) }),
|
|
2251
|
+
card.abi ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-review__btn", onClick: () => downloadAbi(card), children: "Download full ABI (JSON)" }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__muted", children: "There is no action list to download." })
|
|
2252
|
+
] });
|
|
2253
|
+
}
|
|
2254
|
+
function Section({ title, kind, children }) {
|
|
2255
|
+
const id = react.useId();
|
|
2256
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "mero-cw-review__sec", "aria-labelledby": id, children: [
|
|
2257
|
+
/* @__PURE__ */ jsxRuntime.jsxs("h3", { id, className: "mero-cw-review__h", "data-kind": kind, children: [
|
|
2258
|
+
kind && /* @__PURE__ */ jsxRuntime.jsx(ShieldIcon, { kind }),
|
|
2259
|
+
title
|
|
2260
|
+
] }),
|
|
2261
|
+
children
|
|
2262
|
+
] });
|
|
2263
|
+
}
|
|
2264
|
+
function useReview(client, release) {
|
|
2265
|
+
const [state] = chunkRRETZWNI_cjs.useNodeVerification(client);
|
|
2266
|
+
const [loaded, retry] = chunkRRETZWNI_cjs.useCard(client, release, state);
|
|
2267
|
+
return { client, state, loaded, retry };
|
|
2268
|
+
}
|
|
2269
|
+
function Diverged({ divergence }) {
|
|
2270
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__grey", "data-kind": "refused", children: divergence === "release" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2271
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: "The node runs another release than this one" }),
|
|
2272
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "No statement about your data is made here." })
|
|
2273
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2274
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: "Code does not match the release" }),
|
|
2275
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "This node runs different code than the release, so no statement about your data is made here." })
|
|
2276
|
+
] }) });
|
|
2277
|
+
}
|
|
2278
|
+
function ReviewBody({ review, release, cluster, local }) {
|
|
2279
|
+
const { client, state, loaded, retry } = review;
|
|
2280
|
+
const view = chunkRRETZWNI_cjs.describeShield(state, { code: null });
|
|
2281
|
+
const card = loaded.status === "ready" ? loaded.card : null;
|
|
2282
|
+
const sealed = view.kind === "verified";
|
|
2283
|
+
const nodeRelease = state.status === "verified" && !state.mock ? state.release : void 0;
|
|
2284
|
+
const code = card ? codeLine(card, null, sealed) : null;
|
|
2285
|
+
const summary = card ? summarize(card, sealed) : [];
|
|
2286
|
+
const risks = card ? exceptions(card, sealed) : [];
|
|
2287
|
+
const statements = dataStatements(view.kind, "creator");
|
|
2288
|
+
const nodes = client && !local ? `${client.nodes.length} ${client.nodes.length === 1 ? "node" : "nodes"}` : "";
|
|
2289
|
+
const unreleased = loaded.status === "none";
|
|
2290
|
+
const unknown = unreleased ? "This build has no signed release, so what it can do and what leaves the sealed hardware is not known." : !card ? "What leaves the sealed hardware is not known until the app's details load." : !card.abi ? "This app publishes no action list, so what it makes visible to anyone is not known." : null;
|
|
2291
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2292
|
+
loaded.status === "error" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-review__alert", role: "alert", children: [
|
|
2293
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { children: [
|
|
2294
|
+
loaded.message,
|
|
2295
|
+
client ? " You can still create the workspace." : ""
|
|
2296
|
+
] }),
|
|
2297
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-review__btn", onClick: retry, children: "Try again" })
|
|
2298
|
+
] }),
|
|
2299
|
+
/* @__PURE__ */ jsxRuntime.jsx(Section, { title: "The app", children: /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "mero-cw-review__kv", children: [
|
|
2300
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2301
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "App" }),
|
|
2302
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: unreleased ? `${release.package} (unreleased build)` : `${card?.name ?? release.package} v${release.version}` })
|
|
2303
|
+
] }),
|
|
2304
|
+
card && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2305
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Publisher" }),
|
|
2306
|
+
/* @__PURE__ */ jsxRuntime.jsxs("dd", { children: [
|
|
2307
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-review__mono", title: card.signer, children: shortSigner(card.signer) }),
|
|
2308
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyButton, { text: card.signer, label: "Copy publisher" })
|
|
2309
|
+
] })
|
|
2310
|
+
] }),
|
|
2311
|
+
code && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2312
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Code" }),
|
|
2313
|
+
/* @__PURE__ */ jsxRuntime.jsxs("dd", { className: code.tone ? `mero-cw-review__tone--${code.tone}` : void 0, children: [
|
|
2314
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: code.text }),
|
|
2315
|
+
code.note && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-review__sub", children: code.note })
|
|
2316
|
+
] })
|
|
2317
|
+
] })
|
|
2318
|
+
] }) }),
|
|
2319
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Section, { title: "What it can do", children: [
|
|
2320
|
+
loaded.status === "loading" && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__muted", role: "status", children: "Loading what this app can do\u2026" }),
|
|
2321
|
+
loaded.status === "error" && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__muted", children: "Not available until the review loads." }),
|
|
2322
|
+
unreleased && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__muted", children: "This app has no published release yet, so there is no signed review to show." }),
|
|
2323
|
+
loaded.status === "refused" && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__muted", children: "Not available: this node did not pass its check." }),
|
|
2324
|
+
card && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2325
|
+
summary.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mero-cw-review__sum", children: summary.map((line) => /* @__PURE__ */ jsxRuntime.jsxs("li", { "data-tone": line.tone, children: [
|
|
2326
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-review__ic", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: SUMMARY_ICON(line) }) }),
|
|
2327
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "mero-cw-review__tx", children: [
|
|
2328
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: line.title }),
|
|
2329
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: line.detail })
|
|
2330
|
+
] })
|
|
2331
|
+
] }, line.id)) }),
|
|
2332
|
+
!card.abi && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__muted", children: "This app publishes no action list." }),
|
|
2333
|
+
/* @__PURE__ */ jsxRuntime.jsx(AllActions, { card, signed: sealed }),
|
|
2334
|
+
/* @__PURE__ */ jsxRuntime.jsx(SignedFacts, { card, signed: sealed })
|
|
2335
|
+
] })
|
|
2336
|
+
] }),
|
|
2337
|
+
/* @__PURE__ */ jsxRuntime.jsx(Section, { title: "Where it runs", kind: view.kind, children: /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "mero-cw-review__kv", children: [
|
|
2338
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2339
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Cluster" }),
|
|
2340
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: cluster && /* @__PURE__ */ jsxRuntime.jsx(HostText, { text: cluster }) })
|
|
2341
|
+
] }),
|
|
2342
|
+
nodes && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2343
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Nodes" }),
|
|
2344
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: nodes })
|
|
2345
|
+
] }),
|
|
2346
|
+
nodeRelease && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2347
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Software" }),
|
|
2348
|
+
/* @__PURE__ */ jsxRuntime.jsxs("dd", { children: [
|
|
2349
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-review__mono", children: `mero-tee v${nodeRelease}` }),
|
|
2350
|
+
view.verifyUrl && /* @__PURE__ */ jsxRuntime.jsxs("a", { className: "mero-cw-review__link", href: view.verifyUrl, target: "_blank", rel: "noopener noreferrer", title: "Opens the public verifier, which re-checks this node from outside the app", children: [
|
|
2351
|
+
"Verify",
|
|
2352
|
+
/* @__PURE__ */ jsxRuntime.jsx(ExternalIcon, {})
|
|
2353
|
+
] })
|
|
2354
|
+
] })
|
|
2355
|
+
] }),
|
|
2356
|
+
!sealed && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2357
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Status" }),
|
|
2358
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { children: view.title })
|
|
2359
|
+
] }),
|
|
2360
|
+
state.status === "verified" && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2361
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { children: "Node" }),
|
|
2362
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "mero-cw-review__mono", children: /* @__PURE__ */ jsxRuntime.jsx(HostText, { text: chunkRRETZWNI_cjs.hostOf(state.url) }) })
|
|
2363
|
+
] })
|
|
2364
|
+
] }) }),
|
|
2365
|
+
/* @__PURE__ */ jsxRuntime.jsx(Section, { title: "Your data", kind: code?.divergence ? "refused" : view.kind, children: code?.divergence ? /* @__PURE__ */ jsxRuntime.jsx(Diverged, { divergence: code.divergence }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2366
|
+
statements.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: sealed ? "mero-cw-review__claims" : "mero-cw-review__claims mero-cw-review__claims--plain", children: statements.map((text) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
2367
|
+
sealed && /* @__PURE__ */ jsxRuntime.jsx(Tick, {}),
|
|
2368
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: text })
|
|
2369
|
+
] }, text)) }),
|
|
2370
|
+
sealed ? /* @__PURE__ */ jsxRuntime.jsxs("details", { className: "mero-cw-review__how", children: [
|
|
2371
|
+
/* @__PURE__ */ jsxRuntime.jsx("summary", { children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "How we know" }) }),
|
|
2372
|
+
/* @__PURE__ */ jsxRuntime.jsxs("ul", { children: [
|
|
2373
|
+
nodeRelease && /* @__PURE__ */ jsxRuntime.jsx("li", { children: `Runs Calimero's published, signed node software (release v${nodeRelease})` }),
|
|
2374
|
+
view.checks.map((text) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: text }, text))
|
|
2375
|
+
] })
|
|
2376
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mero-cw-review__grey", "data-kind": view.kind, children: [
|
|
2377
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: view.title }),
|
|
2378
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: view.sub })
|
|
2379
|
+
] }),
|
|
2380
|
+
risks.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2381
|
+
!sealed && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__muted", children: "As this test server lists the app:" }),
|
|
2382
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mero-cw-review__except", children: risks.map((text) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
2383
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "warn" }),
|
|
2384
|
+
text
|
|
2385
|
+
] }, text)) })
|
|
2386
|
+
] }),
|
|
2387
|
+
sealed && unknown && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__muted", children: unknown })
|
|
2388
|
+
] }) })
|
|
2389
|
+
] });
|
|
2390
|
+
}
|
|
2391
|
+
function WorkspaceReview({ client, cluster, local, release, creating = false, disabled = false, onBack, onCreate }) {
|
|
2392
|
+
const heading = react.useRef(null);
|
|
2393
|
+
react.useEffect(() => heading.current?.focus(), []);
|
|
2394
|
+
const review = useReview(client, release);
|
|
2395
|
+
const refused = review.state.status === "refused";
|
|
2396
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-review", children: [
|
|
2397
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { ref: heading, tabIndex: -1, className: "mero-cw-review__title", children: "Review before creating" }),
|
|
2398
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__lede", children: "Check what this app can do and where it will run before you create the workspace." }),
|
|
2399
|
+
/* @__PURE__ */ jsxRuntime.jsx(ReviewBody, { review, release, cluster, local }),
|
|
2400
|
+
refused && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-review__muted", children: "Create is unavailable: this node did not pass its check." }),
|
|
2401
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-review__buttons", children: [
|
|
2402
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-review__btn", disabled: creating, onClick: onBack, children: "Back" }),
|
|
2403
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-review__btn mero-cw-review__btn--primary", disabled: creating || disabled || refused, onClick: onCreate, children: creating ? "Creating\u2026" : "Create workspace" })
|
|
2404
|
+
] })
|
|
2405
|
+
] });
|
|
2406
|
+
}
|
|
2407
|
+
var CONSENT_RETURN_MESSAGE = "mero:consent-return";
|
|
2408
|
+
function popupReturn() {
|
|
2409
|
+
if (typeof window === "undefined" || !window.opener) return null;
|
|
2410
|
+
try {
|
|
2411
|
+
if (window.opener.location.origin !== window.location.origin) return null;
|
|
2412
|
+
return meroJs.consentReturn(window.location.href);
|
|
2413
|
+
} catch {
|
|
2414
|
+
return null;
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
var never = () => () => void 0;
|
|
2418
|
+
function ConsentPopupReturn({ children }) {
|
|
2419
|
+
const returned = react.useSyncExternalStore(never, () => JSON.stringify(popupReturn()), () => "null");
|
|
2420
|
+
react.useEffect(() => {
|
|
2421
|
+
const value = JSON.parse(returned);
|
|
2422
|
+
if (!value || !window.opener) return;
|
|
2423
|
+
window.opener.postMessage({ type: CONSENT_RETURN_MESSAGE, ...value }, window.location.origin);
|
|
2424
|
+
window.close();
|
|
2425
|
+
}, [returned]);
|
|
2426
|
+
return returned === "null" ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }) : null;
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
// src/create-workspace/useCreateWorkspace.ts
|
|
2430
|
+
var INTENT_KEY = "mero-react:create-workspace-intent";
|
|
2431
|
+
var POPUP_FEATURES = "popup,width=480,height=720";
|
|
2432
|
+
var NARROW_PX = 640;
|
|
2433
|
+
var CLOSED_POLL_MS = 400;
|
|
2434
|
+
var WAIT_POLL_MS = 1500;
|
|
2435
|
+
var MSG = {
|
|
2436
|
+
declined: "You declined the request on your node. Nothing was created.",
|
|
2437
|
+
closed: "The approval window was closed before you approved. Nothing was created.",
|
|
2438
|
+
expired: "The request expired before you approved it. Nothing was created.",
|
|
2439
|
+
noOrg: "Your node approved the request but named no workspace. Nothing was created."
|
|
2440
|
+
};
|
|
2441
|
+
function readIntent() {
|
|
2442
|
+
try {
|
|
2443
|
+
const v = JSON.parse(sessionStorage.getItem(INTENT_KEY) ?? "null");
|
|
2444
|
+
return v && typeof v.name === "string" && typeof v.selfName === "string" ? { name: v.name, selfName: v.selfName } : null;
|
|
2445
|
+
} catch {
|
|
2446
|
+
return null;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
function keepIntent(intent) {
|
|
2450
|
+
try {
|
|
2451
|
+
sessionStorage.setItem(INTENT_KEY, JSON.stringify(intent));
|
|
2452
|
+
} catch {
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
function forgetIntent() {
|
|
2456
|
+
try {
|
|
2457
|
+
sessionStorage.removeItem(INTENT_KEY);
|
|
2458
|
+
} catch {
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
var messageOf2 = (e) => e instanceof Error ? e.message : String(e);
|
|
2462
|
+
function created(result) {
|
|
2463
|
+
if (result.status === "declined") return { error: MSG.declined };
|
|
2464
|
+
const orgId = result.status === "approved" && result.kind === "createOrg" ? result.outcome?.orgId : void 0;
|
|
2465
|
+
return orgId ? { orgId } : { error: MSG.noOrg };
|
|
2466
|
+
}
|
|
2467
|
+
function useCreateWorkspace({ returnTo, onCreated }) {
|
|
2468
|
+
const { client } = useMero();
|
|
2469
|
+
const consent = useConsent({ throwOnError: true });
|
|
2470
|
+
const orgs = useCreateOrg({ throwOnError: true });
|
|
2471
|
+
const [bound, setBound] = react.useState(null);
|
|
2472
|
+
const [phase, setPhase] = react.useState("idle");
|
|
2473
|
+
const [error, setError] = react.useState(null);
|
|
2474
|
+
const popup = react.useRef(null);
|
|
2475
|
+
const stop = react.useRef(null);
|
|
2476
|
+
const busy = react.useRef(false);
|
|
2477
|
+
const decision = react.useRef(null);
|
|
2478
|
+
react.useEffect(() => {
|
|
2479
|
+
if (!client) return;
|
|
2480
|
+
let live = true;
|
|
2481
|
+
client.auth.me().then(
|
|
2482
|
+
(me) => live && setBound(typeof me.app === "string" && !!me.app),
|
|
2483
|
+
() => live && setBound(false)
|
|
2484
|
+
);
|
|
2485
|
+
return () => {
|
|
2486
|
+
live = false;
|
|
2487
|
+
};
|
|
2488
|
+
}, [client]);
|
|
2489
|
+
react.useEffect(() => () => stop.current?.(), []);
|
|
2490
|
+
const approveInPopup = async (win, name, selfName) => {
|
|
2491
|
+
if (!client) return;
|
|
2492
|
+
const started = await consent.open(meroJs.createOrgConsent(name, returnTo), {
|
|
2493
|
+
navigate: (url) => {
|
|
2494
|
+
if (popup.current) popup.current.url = url;
|
|
2495
|
+
win.location.href = url;
|
|
2496
|
+
},
|
|
2497
|
+
confirm: () => true
|
|
2498
|
+
});
|
|
2499
|
+
if (!started) return;
|
|
2500
|
+
let cause = null;
|
|
2501
|
+
const ctrl = new AbortController();
|
|
2502
|
+
const end = (why) => {
|
|
2503
|
+
cause ?? (cause = why);
|
|
2504
|
+
ctrl.abort();
|
|
2505
|
+
};
|
|
2506
|
+
const timer = setInterval(() => win.closed && end("closed"), CLOSED_POLL_MS);
|
|
2507
|
+
const onMessage = (e) => {
|
|
2508
|
+
const data = e.data;
|
|
2509
|
+
if (e.origin === window.location.origin && e.source === win && data?.type === CONSENT_RETURN_MESSAGE) end("returned");
|
|
2510
|
+
};
|
|
2511
|
+
window.addEventListener("message", onMessage);
|
|
2512
|
+
stop.current = () => end("cancelled");
|
|
2513
|
+
try {
|
|
2514
|
+
let result = await client.waitForConsent(started.requestId, { intervalMs: WAIT_POLL_MS, signal: ctrl.signal, expiresAt: started.expiresAt });
|
|
2515
|
+
if (result.status === "pending" && (cause === "closed" || cause === "returned")) {
|
|
2516
|
+
result = await client.consent.pageResult({ request: started.requestId });
|
|
2517
|
+
}
|
|
2518
|
+
if (result.status === "pending") {
|
|
2519
|
+
if (cause !== "cancelled") setError(cause === "closed" ? MSG.closed : MSG.expired);
|
|
2520
|
+
return;
|
|
2521
|
+
}
|
|
2522
|
+
const made = created(result);
|
|
2523
|
+
if ("error" in made) setError(made.error);
|
|
2524
|
+
else onCreated({ orgId: made.orgId, name, selfName });
|
|
2525
|
+
} finally {
|
|
2526
|
+
clearInterval(timer);
|
|
2527
|
+
window.removeEventListener("message", onMessage);
|
|
2528
|
+
stop.current = null;
|
|
2529
|
+
}
|
|
2530
|
+
};
|
|
2531
|
+
const redirect = async (name, selfName) => {
|
|
2532
|
+
keepIntent({ name, selfName });
|
|
2533
|
+
let went = false;
|
|
2534
|
+
try {
|
|
2535
|
+
await consent.open(meroJs.createOrgConsent(name, returnTo), {
|
|
2536
|
+
// The page opens once the person has seen the code and chosen to go.
|
|
2537
|
+
confirm: async () => {
|
|
2538
|
+
setPhase("redirect");
|
|
2539
|
+
went = await new Promise((resolve) => decision.current = resolve);
|
|
2540
|
+
decision.current = null;
|
|
2541
|
+
if (went) setPhase("creating");
|
|
2542
|
+
return went;
|
|
2543
|
+
}
|
|
2544
|
+
});
|
|
2545
|
+
} catch (e) {
|
|
2546
|
+
forgetIntent();
|
|
2547
|
+
throw e;
|
|
2548
|
+
}
|
|
2549
|
+
if (!went) forgetIntent();
|
|
2550
|
+
else await new Promise(() => void 0);
|
|
2551
|
+
};
|
|
2552
|
+
const create = (name, selfName) => {
|
|
2553
|
+
if (busy.current || bound === null) return;
|
|
2554
|
+
busy.current = true;
|
|
2555
|
+
setError(null);
|
|
2556
|
+
const win = bound && window.innerWidth > NARROW_PX ? window.open("", "mero-consent", POPUP_FEATURES) : null;
|
|
2557
|
+
if (win) popup.current = { win, url: null };
|
|
2558
|
+
setPhase(win ? "approving" : "creating");
|
|
2559
|
+
void (async () => {
|
|
2560
|
+
try {
|
|
2561
|
+
if (!bound) {
|
|
2562
|
+
const orgId = await orgs.create(name);
|
|
2563
|
+
if (orgId) onCreated({ orgId, name, selfName });
|
|
2564
|
+
} else if (win) await approveInPopup(win, name, selfName);
|
|
2565
|
+
else await redirect(name, selfName);
|
|
2566
|
+
} catch (e) {
|
|
2567
|
+
setError(messageOf2(e));
|
|
2568
|
+
} finally {
|
|
2569
|
+
if (win && !win.closed) win.close();
|
|
2570
|
+
popup.current = null;
|
|
2571
|
+
busy.current = false;
|
|
2572
|
+
setPhase("idle");
|
|
2573
|
+
}
|
|
2574
|
+
})();
|
|
2575
|
+
};
|
|
2576
|
+
const cancel = react.useCallback(() => {
|
|
2577
|
+
stop.current?.();
|
|
2578
|
+
decision.current?.(false);
|
|
2579
|
+
}, []);
|
|
2580
|
+
const proceed = react.useCallback(() => decision.current?.(true), []);
|
|
2581
|
+
const reopen = react.useCallback(() => {
|
|
2582
|
+
const p = popup.current;
|
|
2583
|
+
if (!p || p.win.closed) return;
|
|
2584
|
+
if (p.url) p.win.location.href = p.url;
|
|
2585
|
+
p.win.focus();
|
|
2586
|
+
}, []);
|
|
2587
|
+
return { create, cancel, reopen, proceed, phase, error, code: consent.code, ready: bound !== null };
|
|
2588
|
+
}
|
|
2589
|
+
function useCreateWorkspaceResume({ onCreated }) {
|
|
2590
|
+
const { client } = useMero();
|
|
2591
|
+
const [message, setMessage] = react.useState(null);
|
|
2592
|
+
const started = react.useRef(false);
|
|
2593
|
+
const latest = react.useRef(onCreated);
|
|
2594
|
+
latest.current = onCreated;
|
|
2595
|
+
react.useEffect(() => {
|
|
2596
|
+
if (!client || started.current || !meroJs.consentReturn(window.location.href)) return;
|
|
2597
|
+
const intent = readIntent();
|
|
2598
|
+
if (!intent) return;
|
|
2599
|
+
started.current = true;
|
|
2600
|
+
void (async () => {
|
|
2601
|
+
try {
|
|
2602
|
+
const result = await client.resumeConsent();
|
|
2603
|
+
if (!result) return;
|
|
2604
|
+
const made = created(result);
|
|
2605
|
+
if ("error" in made) setMessage(made.error);
|
|
2606
|
+
else latest.current({ orgId: made.orgId, name: intent.name, selfName: intent.selfName });
|
|
2607
|
+
} catch (e) {
|
|
2608
|
+
setMessage(messageOf2(e));
|
|
2609
|
+
} finally {
|
|
2610
|
+
forgetIntent();
|
|
2611
|
+
}
|
|
2612
|
+
})();
|
|
2613
|
+
}, [client]);
|
|
2614
|
+
return { message };
|
|
2615
|
+
}
|
|
2616
|
+
var DEFAULT_LABELS = {
|
|
2617
|
+
title: "Create workspace",
|
|
2618
|
+
subtitle: "Name your workspace, and choose how others in it will see you.",
|
|
2619
|
+
nameLabel: "Workspace name",
|
|
2620
|
+
namePlaceholder: "",
|
|
2621
|
+
selfLabel: "Your name",
|
|
2622
|
+
selfPlaceholder: "",
|
|
2623
|
+
next: "Continue"
|
|
2624
|
+
};
|
|
2625
|
+
var subscribeNothing = () => () => void 0;
|
|
2626
|
+
var useMounted = () => react.useSyncExternalStore(subscribeNothing, () => true, () => false);
|
|
2627
|
+
function ResumeNotice({ onCreated }) {
|
|
2628
|
+
const { message } = useCreateWorkspaceResume({ onCreated });
|
|
2629
|
+
const [dismissed, setDismissed] = react.useState(null);
|
|
2630
|
+
const mounted = useMounted();
|
|
2631
|
+
if (!mounted || !message || dismissed === message) return null;
|
|
2632
|
+
return reactDom.createPortal(
|
|
2633
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { role: "alert", className: "mero-cw mero-cw-notice", children: [
|
|
2634
|
+
message,
|
|
2635
|
+
" ",
|
|
2636
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-link", onClick: () => setDismissed(message), children: "Dismiss" })
|
|
2637
|
+
] }),
|
|
2638
|
+
document.body
|
|
2639
|
+
);
|
|
2640
|
+
}
|
|
2641
|
+
var CloseIcon = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 6 12 12M18 6 6 18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) });
|
|
2642
|
+
function CreateWorkspaceDialog({ client, passkey, ...props }) {
|
|
2643
|
+
const sessionStore = react.useMemo(() => ({ load: () => client?.session ?? null, save: () => void 0, clear: () => void 0 }), [client]);
|
|
2644
|
+
const inner = /* @__PURE__ */ jsxRuntime.jsx(Dialog, { ...props });
|
|
2645
|
+
return client ? /* @__PURE__ */ jsxRuntime.jsx(MeroProvider, { client, sessionStore, passkey, children: inner }) : inner;
|
|
2646
|
+
}
|
|
2647
|
+
function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSelfName = "", cluster }) {
|
|
2648
|
+
const text = { ...DEFAULT_LABELS, ...labels };
|
|
2649
|
+
const { client, cluster: ambientCluster, nodeUrl } = useMero();
|
|
2650
|
+
const flow = useCreateWorkspace({ returnTo: returnTo ?? `${typeof window === "undefined" ? "" : window.location.origin}/`, onCreated });
|
|
2651
|
+
const [step, setStep] = react.useState("names");
|
|
2652
|
+
const [name, setName] = react.useState("");
|
|
2653
|
+
const [selfName, setSelfName] = react.useState(defaultSelfName);
|
|
2654
|
+
const ids = [react.useId(), react.useId()];
|
|
2655
|
+
const first = react.useRef(null);
|
|
2656
|
+
const mounted = useMounted();
|
|
2657
|
+
react.useEffect(() => {
|
|
2658
|
+
if (open && release && step === "names") first.current?.focus();
|
|
2659
|
+
}, [open, release, step]);
|
|
2660
|
+
const node = client?.nodeUrl ?? nodeUrl;
|
|
2661
|
+
const where = cluster !== void 0 ? cluster ?? void 0 : ambientCluster ?? (node ? clusterName(node) : void 0);
|
|
2662
|
+
const trimmed = { name: name.trim(), self: selfName.trim() };
|
|
2663
|
+
const redirecting = flow.phase === "redirect";
|
|
2664
|
+
const approving = flow.phase === "approving" || redirecting;
|
|
2665
|
+
const body = !release ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-sub", role: "status", children: "Checking the newest release\u2026" }) : approving ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-approve", children: [
|
|
2666
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mero-cw-title", children: "Approve with your passkey" }),
|
|
2667
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-sub", children: redirecting ? "Your node will open its own page to ask for your passkey. Check that it shows this code." : "A window from your node opened. Check it shows this code, then approve there." }),
|
|
2668
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-code", "aria-live": "polite", children: flow.code ?? "..." }),
|
|
2669
|
+
redirecting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2670
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-btn mero-cw-btn--primary mero-cw-btn--full", onClick: flow.proceed, children: "Continue to your node" }),
|
|
2671
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-row", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-btn", onClick: flow.cancel, children: "Cancel" }) })
|
|
2672
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2673
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-wait", role: "status", children: [
|
|
2674
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-dot", "aria-hidden": "true" }),
|
|
2675
|
+
"Waiting for your approval..."
|
|
2676
|
+
] }),
|
|
2677
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-row", children: [
|
|
2678
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-btn", onClick: flow.cancel, children: "Cancel" }),
|
|
2679
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-link", onClick: flow.reopen, children: "Open the window again" })
|
|
2680
|
+
] })
|
|
2681
|
+
] })
|
|
2682
|
+
] }) : step === "names" ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2683
|
+
"form",
|
|
2684
|
+
{
|
|
2685
|
+
onSubmit: (e) => {
|
|
2686
|
+
e.preventDefault();
|
|
2687
|
+
if (trimmed.name && trimmed.self) setStep("review");
|
|
2688
|
+
},
|
|
2689
|
+
children: [
|
|
2690
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mero-cw-title", children: text.title }),
|
|
2691
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-sub", children: text.subtitle }),
|
|
2692
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-field", children: [
|
|
2693
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: ids[0], children: text.nameLabel }),
|
|
2694
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { id: ids[0], ref: first, value: name, placeholder: text.namePlaceholder, onChange: (e) => setName(e.target.value) })
|
|
2695
|
+
] }),
|
|
2696
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-field", children: [
|
|
2697
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: ids[1], children: text.selfLabel }),
|
|
2698
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { id: ids[1], value: selfName, placeholder: text.selfPlaceholder, onChange: (e) => setSelfName(e.target.value) })
|
|
2699
|
+
] }),
|
|
2700
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", className: "mero-cw-btn mero-cw-btn--primary mero-cw-btn--full", disabled: !trimmed.name || !trimmed.self, children: text.next })
|
|
2701
|
+
]
|
|
2702
|
+
}
|
|
2703
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2704
|
+
flow.error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-error", role: "alert", children: flow.error }),
|
|
2705
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2706
|
+
WorkspaceReview,
|
|
2707
|
+
{
|
|
2708
|
+
client,
|
|
2709
|
+
cluster: where,
|
|
2710
|
+
local: !!node && clusterName(node) === "merod local",
|
|
2711
|
+
release,
|
|
2712
|
+
creating: flow.phase === "creating",
|
|
2713
|
+
disabled: !flow.ready,
|
|
2714
|
+
onBack: () => setStep("names"),
|
|
2715
|
+
onCreate: () => flow.create(trimmed.name, trimmed.self)
|
|
2716
|
+
}
|
|
2717
|
+
)
|
|
2718
|
+
] });
|
|
2719
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2720
|
+
/* @__PURE__ */ jsxRuntime.jsx(ResumeNotice, { onCreated }),
|
|
2721
|
+
open && mounted && reactDom.createPortal(
|
|
2722
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw mero-cw-overlay", onKeyDown: (e) => e.key === "Escape" && !approving && onClose(), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-card", role: "dialog", "aria-modal": "true", "aria-label": text.title, children: [
|
|
2723
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-x", "aria-label": "Close", onClick: () => approving ? flow.cancel() : onClose(), children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {}) }),
|
|
2724
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-body", children: body })
|
|
2725
|
+
] }) }),
|
|
2726
|
+
document.body
|
|
2727
|
+
)
|
|
2728
|
+
] });
|
|
2729
|
+
}
|
|
2730
|
+
|
|
1870
2731
|
Object.defineProperty(exports, "MeroContext", {
|
|
1871
2732
|
enumerable: true,
|
|
1872
|
-
get: function () { return
|
|
2733
|
+
get: function () { return chunkRRETZWNI_cjs.MeroContext; }
|
|
1873
2734
|
});
|
|
2735
|
+
exports.CONSENT_RETURN_MESSAGE = CONSENT_RETURN_MESSAGE;
|
|
1874
2736
|
exports.CalimeroLogo = CalimeroLogo;
|
|
1875
2737
|
exports.ConnectButton = ConnectButton;
|
|
2738
|
+
exports.ConsentPopupReturn = ConsentPopupReturn;
|
|
2739
|
+
exports.CreateWorkspaceDialog = CreateWorkspaceDialog;
|
|
1876
2740
|
exports.LoginModal = LoginModal;
|
|
1877
2741
|
exports.MERO_CSS_VARS = MERO_CSS_VARS;
|
|
1878
2742
|
exports.MeroProvider = MeroProvider;
|
|
1879
2743
|
exports.NoAppError = NoAppError;
|
|
1880
2744
|
exports.NotConnectedError = NotConnectedError;
|
|
1881
2745
|
exports.SessionReportingClient = SessionReportingClient;
|
|
2746
|
+
exports.WorkspaceReview = WorkspaceReview;
|
|
1882
2747
|
exports.clearAllStorage = clearAllStorage;
|
|
1883
2748
|
exports.clearAppId = clearAppId;
|
|
1884
2749
|
exports.clearCluster = clearCluster;
|
|
1885
2750
|
exports.clearNodeUrl = clearNodeUrl;
|
|
2751
|
+
exports.clusterName = clusterName;
|
|
1886
2752
|
exports.cssVar = cssVar;
|
|
1887
2753
|
exports.defaultMeroTheme = defaultMeroTheme;
|
|
1888
2754
|
exports.describeError = describeError;
|
|
@@ -1917,6 +2783,8 @@ exports.useCreateApp = useCreateApp;
|
|
|
1917
2783
|
exports.useCreateInvite = useCreateInvite;
|
|
1918
2784
|
exports.useCreateOrg = useCreateOrg;
|
|
1919
2785
|
exports.useCreateTeam = useCreateTeam;
|
|
2786
|
+
exports.useCreateWorkspace = useCreateWorkspace;
|
|
2787
|
+
exports.useCreateWorkspaceResume = useCreateWorkspaceResume;
|
|
1920
2788
|
exports.useDeleteApp = useDeleteApp;
|
|
1921
2789
|
exports.useDeleteBlob = useDeleteBlob;
|
|
1922
2790
|
exports.useDeleteOrg = useDeleteOrg;
|