@calimero-network/mero-react 11.5.0 → 11.7.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/index.cjs +507 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +118 -7
- package/dist/index.d.ts +118 -7
- package/dist/index.js +506 -90
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1456,9 +1456,9 @@ function useApiKeys(options) {
|
|
|
1456
1456
|
const { withClient, ...state } = useClientAction(options);
|
|
1457
1457
|
const create = react.useCallback(
|
|
1458
1458
|
(input = {}) => withClient(async (c) => {
|
|
1459
|
-
const
|
|
1459
|
+
const created = await c.auth.apikeyCreate({ ...input }, confirmWith(passkey));
|
|
1460
1460
|
void refetch();
|
|
1461
|
-
return
|
|
1461
|
+
return created;
|
|
1462
1462
|
}),
|
|
1463
1463
|
[withClient, passkey, refetch]
|
|
1464
1464
|
);
|
|
@@ -1872,7 +1872,51 @@ function ConnectButton({
|
|
|
1872
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
1873
|
|
|
1874
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');
|
|
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 select {\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.mero-cw-field select: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.mero-cw-choices {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin: 0 0 12px;\n padding: 0;\n border: 0;\n}\n.mero-cw-choice {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 10px 12px;\n border: 1px solid var(--_line);\n border-radius: 12px;\n cursor: pointer;\n}\n.mero-cw-choice:has(input:checked) {\n border-color: var(--_ink);\n}\n.mero-cw-choice input {\n margin-top: 3px;\n accent-color: var(--_primary-bg);\n}\n.mero-cw-choice b {\n display: block;\n font-size: 13px;\n}\n.mero-cw-choice .mero-cw-sub {\n display: block;\n margin: 2px 0 0;\n}\n.mero-cw-caps {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin: 0 0 14px;\n padding: 6px 4px;\n border-top: 1px solid var(--_line);\n border-bottom: 1px solid var(--_line);\n max-height: 220px;\n overflow-y: auto;\n}\n.mero-cw-cap {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n gap: 0 10px;\n padding: 6px 8px;\n font-size: 13px;\n}\n.mero-cw-cap label {\n display: flex;\n align-items: center;\n gap: 10px;\n cursor: pointer;\n}\n.mero-cw-cap[data-disabled] {\n color: var(--_muted);\n}\n.mero-cw-cap[data-disabled] label {\n cursor: not-allowed;\n}\n.mero-cw-cap input {\n margin: 0;\n accent-color: var(--_primary-bg);\n}\n.mero-cw-hint {\n display: inline;\n color: var(--_muted);\n font-size: 11.5px;\n}\n.mero-cw-visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n white-space: nowrap;\n}\n');
|
|
1876
|
+
var subscribeNothing = () => () => void 0;
|
|
1877
|
+
var useMounted = () => react.useSyncExternalStore(subscribeNothing, () => true, () => false);
|
|
1878
|
+
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" }) });
|
|
1879
|
+
function DialogShell({ label, locked = false, onClose, children }) {
|
|
1880
|
+
const mounted = useMounted();
|
|
1881
|
+
if (!mounted) return null;
|
|
1882
|
+
return reactDom.createPortal(
|
|
1883
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw mero-cw-overlay", onKeyDown: (e) => e.key === "Escape" && !locked && onClose(), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-card", role: "dialog", "aria-modal": "true", "aria-label": label, children: [
|
|
1884
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-x", "aria-label": "Close", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {}) }),
|
|
1885
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-body", children })
|
|
1886
|
+
] }) }),
|
|
1887
|
+
document.body
|
|
1888
|
+
);
|
|
1889
|
+
}
|
|
1890
|
+
function WithClient({ client, passkey, children }) {
|
|
1891
|
+
const sessionStore = react.useMemo(() => ({ load: () => client?.session ?? null, save: () => void 0, clear: () => void 0 }), [client]);
|
|
1892
|
+
return client ? /* @__PURE__ */ jsxRuntime.jsx(MeroProvider, { client, sessionStore, passkey, children }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
1893
|
+
}
|
|
1894
|
+
function ApprovalCard({
|
|
1895
|
+
redirecting,
|
|
1896
|
+
code,
|
|
1897
|
+
onCancel,
|
|
1898
|
+
onProceed,
|
|
1899
|
+
onReopen
|
|
1900
|
+
}) {
|
|
1901
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-approve", children: [
|
|
1902
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mero-cw-title", children: "Approve with your passkey" }),
|
|
1903
|
+
/* @__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." }),
|
|
1904
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-code", "aria-live": "polite", children: code ?? "..." }),
|
|
1905
|
+
redirecting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1906
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-btn mero-cw-btn--primary mero-cw-btn--full", onClick: onProceed, children: "Continue to your node" }),
|
|
1907
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-row", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-btn", onClick: onCancel, children: "Cancel" }) })
|
|
1908
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1909
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-wait", role: "status", children: [
|
|
1910
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-dot", "aria-hidden": "true" }),
|
|
1911
|
+
"Waiting for your approval..."
|
|
1912
|
+
] }),
|
|
1913
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-row", children: [
|
|
1914
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-btn", onClick: onCancel, children: "Cancel" }),
|
|
1915
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-link", onClick: onReopen, children: "Open the window again" })
|
|
1916
|
+
] })
|
|
1917
|
+
] })
|
|
1918
|
+
] });
|
|
1919
|
+
}
|
|
1876
1920
|
|
|
1877
1921
|
// src/create-workspace/clusterName.ts
|
|
1878
1922
|
var LOCAL_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
@@ -2427,48 +2471,41 @@ function ConsentPopupReturn({ children }) {
|
|
|
2427
2471
|
return returned === "null" ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }) : null;
|
|
2428
2472
|
}
|
|
2429
2473
|
|
|
2430
|
-
// src/
|
|
2431
|
-
var INTENT_KEY = "mero-react:create-workspace-intent";
|
|
2474
|
+
// src/consent-flow/useNodeConsent.ts
|
|
2432
2475
|
var POPUP_FEATURES = "popup,width=480,height=720";
|
|
2433
2476
|
var NARROW_PX = 640;
|
|
2434
2477
|
var CLOSED_POLL_MS = 400;
|
|
2435
2478
|
var WAIT_POLL_MS = 1500;
|
|
2436
|
-
var
|
|
2437
|
-
declined: "You declined the request on your node. Nothing was
|
|
2438
|
-
closed: "The approval window was closed before you approved. Nothing was
|
|
2439
|
-
expired: "The request expired before you approved it. Nothing was
|
|
2440
|
-
noOrg: "Your node approved the request but named no workspace. Nothing was created."
|
|
2479
|
+
var CONSENT_MSG = {
|
|
2480
|
+
declined: "You declined the request on your node. Nothing was changed.",
|
|
2481
|
+
closed: "The approval window was closed before you approved. Nothing was changed.",
|
|
2482
|
+
expired: "The request expired before you approved it. Nothing was changed."
|
|
2441
2483
|
};
|
|
2442
|
-
|
|
2484
|
+
var messageOf2 = (e) => e instanceof Error ? e.message : String(e);
|
|
2485
|
+
var codeOf = (e) => typeof e?.code === "string" ? e.code : null;
|
|
2486
|
+
function readIntent(key2, valid) {
|
|
2443
2487
|
try {
|
|
2444
|
-
const v = JSON.parse(sessionStorage.getItem(
|
|
2445
|
-
return v
|
|
2488
|
+
const v = JSON.parse(sessionStorage.getItem(key2) ?? "null");
|
|
2489
|
+
return valid(v) ? v : null;
|
|
2446
2490
|
} catch {
|
|
2447
2491
|
return null;
|
|
2448
2492
|
}
|
|
2449
2493
|
}
|
|
2450
|
-
function keepIntent(intent) {
|
|
2494
|
+
function keepIntent(key2, intent) {
|
|
2451
2495
|
try {
|
|
2452
|
-
sessionStorage.setItem(
|
|
2496
|
+
sessionStorage.setItem(key2, JSON.stringify(intent));
|
|
2453
2497
|
} catch {
|
|
2454
2498
|
}
|
|
2455
2499
|
}
|
|
2456
|
-
function forgetIntent() {
|
|
2500
|
+
function forgetIntent(key2) {
|
|
2457
2501
|
try {
|
|
2458
|
-
sessionStorage.removeItem(
|
|
2502
|
+
sessionStorage.removeItem(key2);
|
|
2459
2503
|
} catch {
|
|
2460
2504
|
}
|
|
2461
2505
|
}
|
|
2462
|
-
|
|
2463
|
-
function created(result) {
|
|
2464
|
-
if (result.status === "declined") return { error: MSG.declined };
|
|
2465
|
-
const orgId = result.status === "approved" && result.kind === "createOrg" ? result.outcome?.orgId : void 0;
|
|
2466
|
-
return orgId ? { orgId } : { error: MSG.noOrg };
|
|
2467
|
-
}
|
|
2468
|
-
function useCreateWorkspace({ returnTo, onCreated }) {
|
|
2506
|
+
function useNodeConsent({ storageKey, onError }) {
|
|
2469
2507
|
const { client } = useMero();
|
|
2470
2508
|
const consent = useConsent({ throwOnError: true });
|
|
2471
|
-
const orgs = useCreateOrg({ throwOnError: true });
|
|
2472
2509
|
const [bound, setBound] = react.useState(null);
|
|
2473
2510
|
const [phase, setPhase] = react.useState("idle");
|
|
2474
2511
|
const [error, setError] = react.useState(null);
|
|
@@ -2488,16 +2525,16 @@ function useCreateWorkspace({ returnTo, onCreated }) {
|
|
|
2488
2525
|
};
|
|
2489
2526
|
}, [client]);
|
|
2490
2527
|
react.useEffect(() => () => stop.current?.(), []);
|
|
2491
|
-
const approveInPopup = async (win,
|
|
2492
|
-
if (!client) return;
|
|
2493
|
-
const started = await consent.open(
|
|
2528
|
+
const approveInPopup = async (win, request) => {
|
|
2529
|
+
if (!client) return null;
|
|
2530
|
+
const started = await consent.open(request, {
|
|
2494
2531
|
navigate: (url) => {
|
|
2495
2532
|
if (popup.current) popup.current.url = url;
|
|
2496
2533
|
win.location.href = url;
|
|
2497
2534
|
},
|
|
2498
2535
|
confirm: () => true
|
|
2499
2536
|
});
|
|
2500
|
-
if (!started) return;
|
|
2537
|
+
if (!started) return null;
|
|
2501
2538
|
let cause = null;
|
|
2502
2539
|
const ctrl = new AbortController();
|
|
2503
2540
|
const end = (why) => {
|
|
@@ -2517,23 +2554,25 @@ function useCreateWorkspace({ returnTo, onCreated }) {
|
|
|
2517
2554
|
result = await client.consent.pageResult({ request: started.requestId });
|
|
2518
2555
|
}
|
|
2519
2556
|
if (result.status === "pending") {
|
|
2520
|
-
if (cause !== "cancelled") setError(cause === "closed" ?
|
|
2521
|
-
return;
|
|
2557
|
+
if (cause !== "cancelled") setError({ message: cause === "closed" ? CONSENT_MSG.closed : CONSENT_MSG.expired, code: null });
|
|
2558
|
+
return null;
|
|
2559
|
+
}
|
|
2560
|
+
if (result.status === "declined") {
|
|
2561
|
+
setError({ message: CONSENT_MSG.declined, code: null });
|
|
2562
|
+
return null;
|
|
2522
2563
|
}
|
|
2523
|
-
|
|
2524
|
-
if ("error" in made) setError(made.error);
|
|
2525
|
-
else onCreated({ orgId: made.orgId, name, selfName });
|
|
2564
|
+
return result;
|
|
2526
2565
|
} finally {
|
|
2527
2566
|
clearInterval(timer);
|
|
2528
2567
|
window.removeEventListener("message", onMessage);
|
|
2529
2568
|
stop.current = null;
|
|
2530
2569
|
}
|
|
2531
2570
|
};
|
|
2532
|
-
const redirect = async (
|
|
2533
|
-
keepIntent(
|
|
2571
|
+
const redirect = async (request, intent) => {
|
|
2572
|
+
keepIntent(storageKey, intent);
|
|
2534
2573
|
let went = false;
|
|
2535
2574
|
try {
|
|
2536
|
-
await consent.open(
|
|
2575
|
+
await consent.open(request, {
|
|
2537
2576
|
// The page opens once the person has seen the code and chosen to go.
|
|
2538
2577
|
confirm: async () => {
|
|
2539
2578
|
setPhase("redirect");
|
|
@@ -2544,13 +2583,13 @@ function useCreateWorkspace({ returnTo, onCreated }) {
|
|
|
2544
2583
|
}
|
|
2545
2584
|
});
|
|
2546
2585
|
} catch (e) {
|
|
2547
|
-
forgetIntent();
|
|
2586
|
+
forgetIntent(storageKey);
|
|
2548
2587
|
throw e;
|
|
2549
2588
|
}
|
|
2550
|
-
if (!went) forgetIntent();
|
|
2589
|
+
if (!went) forgetIntent(storageKey);
|
|
2551
2590
|
else await new Promise(() => void 0);
|
|
2552
2591
|
};
|
|
2553
|
-
const
|
|
2592
|
+
const start = ({ request, intent, direct, done }) => {
|
|
2554
2593
|
if (busy.current || bound === null) return;
|
|
2555
2594
|
busy.current = true;
|
|
2556
2595
|
setError(null);
|
|
@@ -2559,13 +2598,17 @@ function useCreateWorkspace({ returnTo, onCreated }) {
|
|
|
2559
2598
|
setPhase(win ? "approving" : "creating");
|
|
2560
2599
|
void (async () => {
|
|
2561
2600
|
try {
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2601
|
+
let outcome = null;
|
|
2602
|
+
if (!bound) outcome = { direct: await direct() };
|
|
2603
|
+
else if (win) {
|
|
2604
|
+
const result = await approveInPopup(win, request);
|
|
2605
|
+
if (result) outcome = { consent: result };
|
|
2606
|
+
} else await redirect(request, intent);
|
|
2607
|
+
const problem = outcome && done(outcome);
|
|
2608
|
+
if (problem) setError({ message: problem, code: null });
|
|
2567
2609
|
} catch (e) {
|
|
2568
|
-
setError(messageOf2(e));
|
|
2610
|
+
setError({ message: messageOf2(e), code: codeOf(e) });
|
|
2611
|
+
onError?.(e);
|
|
2569
2612
|
} finally {
|
|
2570
2613
|
if (win && !win.closed) win.close();
|
|
2571
2614
|
popup.current = null;
|
|
@@ -2585,35 +2628,86 @@ function useCreateWorkspace({ returnTo, onCreated }) {
|
|
|
2585
2628
|
if (p.url) p.win.location.href = p.url;
|
|
2586
2629
|
p.win.focus();
|
|
2587
2630
|
}, []);
|
|
2588
|
-
|
|
2631
|
+
const clearError = react.useCallback(() => setError(null), []);
|
|
2632
|
+
return {
|
|
2633
|
+
start,
|
|
2634
|
+
cancel,
|
|
2635
|
+
reopen,
|
|
2636
|
+
proceed,
|
|
2637
|
+
clearError,
|
|
2638
|
+
phase,
|
|
2639
|
+
error: error?.message ?? null,
|
|
2640
|
+
errorCode: error?.code ?? null,
|
|
2641
|
+
code: consent.code,
|
|
2642
|
+
ready: bound !== null,
|
|
2643
|
+
bound
|
|
2644
|
+
};
|
|
2589
2645
|
}
|
|
2590
|
-
function
|
|
2646
|
+
function useConsentResume({
|
|
2647
|
+
storageKey,
|
|
2648
|
+
valid,
|
|
2649
|
+
onApproved
|
|
2650
|
+
}) {
|
|
2591
2651
|
const { client } = useMero();
|
|
2592
2652
|
const [message, setMessage] = react.useState(null);
|
|
2593
2653
|
const started = react.useRef(false);
|
|
2594
|
-
const latest = react.useRef(
|
|
2595
|
-
latest.current =
|
|
2654
|
+
const latest = react.useRef({ valid, onApproved });
|
|
2655
|
+
latest.current = { valid, onApproved };
|
|
2596
2656
|
react.useEffect(() => {
|
|
2597
2657
|
if (!client || started.current || !meroJs.consentReturn(window.location.href)) return;
|
|
2598
|
-
const intent = readIntent();
|
|
2658
|
+
const intent = readIntent(storageKey, latest.current.valid);
|
|
2599
2659
|
if (!intent) return;
|
|
2600
2660
|
started.current = true;
|
|
2601
2661
|
void (async () => {
|
|
2602
2662
|
try {
|
|
2603
2663
|
const result = await client.resumeConsent();
|
|
2604
2664
|
if (!result) return;
|
|
2605
|
-
|
|
2606
|
-
if ("
|
|
2607
|
-
else latest.current(
|
|
2665
|
+
if (result.status === "declined") setMessage(CONSENT_MSG.declined);
|
|
2666
|
+
else if (result.status === "pending") setMessage(CONSENT_MSG.expired);
|
|
2667
|
+
else setMessage(latest.current.onApproved(intent, result) ?? null);
|
|
2608
2668
|
} catch (e) {
|
|
2609
2669
|
setMessage(messageOf2(e));
|
|
2610
2670
|
} finally {
|
|
2611
|
-
forgetIntent();
|
|
2671
|
+
forgetIntent(storageKey);
|
|
2612
2672
|
}
|
|
2613
2673
|
})();
|
|
2614
|
-
}, [client]);
|
|
2674
|
+
}, [client, storageKey]);
|
|
2615
2675
|
return { message };
|
|
2616
2676
|
}
|
|
2677
|
+
|
|
2678
|
+
// src/create-workspace/useCreateWorkspace.ts
|
|
2679
|
+
var INTENT_KEY = "mero-react:create-workspace-intent";
|
|
2680
|
+
var NO_ORG = "Your node approved the request but named no workspace. Nothing was created.";
|
|
2681
|
+
var isIntent = (v) => !!v && typeof v.name === "string" && typeof v.selfName === "string";
|
|
2682
|
+
var orgIdOf = (result) => result.status === "approved" && result.kind === "createOrg" ? result.outcome?.orgId : void 0;
|
|
2683
|
+
function useCreateWorkspace({ returnTo, onCreated }) {
|
|
2684
|
+
const orgs = useCreateOrg({ throwOnError: true });
|
|
2685
|
+
const { start, ...flow } = useNodeConsent({ storageKey: INTENT_KEY });
|
|
2686
|
+
const create = (name, selfName) => start({
|
|
2687
|
+
request: meroJs.createOrgConsent(name, returnTo),
|
|
2688
|
+
intent: { name, selfName },
|
|
2689
|
+
direct: () => orgs.create(name),
|
|
2690
|
+
done: (outcome) => {
|
|
2691
|
+
const orgId = "direct" in outcome ? outcome.direct : orgIdOf(outcome.consent);
|
|
2692
|
+
if (!orgId) return NO_ORG;
|
|
2693
|
+
onCreated({ orgId, name, selfName });
|
|
2694
|
+
return void 0;
|
|
2695
|
+
}
|
|
2696
|
+
});
|
|
2697
|
+
return { create, ...flow };
|
|
2698
|
+
}
|
|
2699
|
+
function useCreateWorkspaceResume({ onCreated }) {
|
|
2700
|
+
return useConsentResume({
|
|
2701
|
+
storageKey: INTENT_KEY,
|
|
2702
|
+
valid: isIntent,
|
|
2703
|
+
onApproved: (intent, result) => {
|
|
2704
|
+
const orgId = orgIdOf(result);
|
|
2705
|
+
if (!orgId) return NO_ORG;
|
|
2706
|
+
onCreated({ orgId, name: intent.name, selfName: intent.selfName });
|
|
2707
|
+
return void 0;
|
|
2708
|
+
}
|
|
2709
|
+
});
|
|
2710
|
+
}
|
|
2617
2711
|
var NOUN = "workspace";
|
|
2618
2712
|
function wording(labels) {
|
|
2619
2713
|
const noun = labels?.noun ?? NOUN;
|
|
@@ -2629,8 +2723,6 @@ function wording(labels) {
|
|
|
2629
2723
|
...labels
|
|
2630
2724
|
};
|
|
2631
2725
|
}
|
|
2632
|
-
var subscribeNothing = () => () => void 0;
|
|
2633
|
-
var useMounted = () => react.useSyncExternalStore(subscribeNothing, () => true, () => false);
|
|
2634
2726
|
function ResumeNotice({ onCreated }) {
|
|
2635
2727
|
const { message } = useCreateWorkspaceResume({ onCreated });
|
|
2636
2728
|
const [dismissed, setDismissed] = react.useState(null);
|
|
@@ -2645,11 +2737,8 @@ function ResumeNotice({ onCreated }) {
|
|
|
2645
2737
|
document.body
|
|
2646
2738
|
);
|
|
2647
2739
|
}
|
|
2648
|
-
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" }) });
|
|
2649
2740
|
function CreateWorkspaceDialog({ client, passkey, ...props }) {
|
|
2650
|
-
|
|
2651
|
-
const inner = /* @__PURE__ */ jsxRuntime.jsx(Dialog, { ...props });
|
|
2652
|
-
return client ? /* @__PURE__ */ jsxRuntime.jsx(MeroProvider, { client, sessionStore, passkey, children: inner }) : inner;
|
|
2741
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WithClient, { client, passkey, children: /* @__PURE__ */ jsxRuntime.jsx(Dialog, { ...props }) });
|
|
2653
2742
|
}
|
|
2654
2743
|
function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSelfName = "", cluster, fields, fieldsValid = true }) {
|
|
2655
2744
|
const text = wording(labels);
|
|
@@ -2660,7 +2749,6 @@ function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSe
|
|
|
2660
2749
|
const [selfName, setSelfName] = react.useState(defaultSelfName);
|
|
2661
2750
|
const ids = [react.useId(), react.useId()];
|
|
2662
2751
|
const first = react.useRef(null);
|
|
2663
|
-
const mounted = useMounted();
|
|
2664
2752
|
react.useEffect(() => {
|
|
2665
2753
|
if (open && release && step === "names") first.current?.focus();
|
|
2666
2754
|
}, [open, release, step]);
|
|
@@ -2669,24 +2757,7 @@ function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSe
|
|
|
2669
2757
|
const trimmed = { name: name.trim(), self: selfName.trim() };
|
|
2670
2758
|
const redirecting = flow.phase === "redirect";
|
|
2671
2759
|
const approving = flow.phase === "approving" || redirecting;
|
|
2672
|
-
const body = !release ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-sub", role: "status", children: "Checking the newest release\u2026" }) : approving ? /* @__PURE__ */ jsxRuntime.
|
|
2673
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mero-cw-title", children: "Approve with your passkey" }),
|
|
2674
|
-
/* @__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." }),
|
|
2675
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-code", "aria-live": "polite", children: flow.code ?? "..." }),
|
|
2676
|
-
redirecting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2677
|
-
/* @__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" }),
|
|
2678
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-row", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-btn", onClick: flow.cancel, children: "Cancel" }) })
|
|
2679
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2680
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-wait", role: "status", children: [
|
|
2681
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-dot", "aria-hidden": "true" }),
|
|
2682
|
-
"Waiting for your approval..."
|
|
2683
|
-
] }),
|
|
2684
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-row", children: [
|
|
2685
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-btn", onClick: flow.cancel, children: "Cancel" }),
|
|
2686
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-link", onClick: flow.reopen, children: "Open the window again" })
|
|
2687
|
-
] })
|
|
2688
|
-
] })
|
|
2689
|
-
] }) : step === "names" ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2760
|
+
const body = !release ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-sub", role: "status", children: "Checking the newest release\u2026" }) : approving ? /* @__PURE__ */ jsxRuntime.jsx(ApprovalCard, { redirecting, code: flow.code, onCancel: flow.cancel, onProceed: flow.proceed, onReopen: flow.reopen }) : step === "names" ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2690
2761
|
"form",
|
|
2691
2762
|
{
|
|
2692
2763
|
onSubmit: (e) => {
|
|
@@ -2727,25 +2798,372 @@ function Dialog({ open, onClose, release, onCreated, returnTo, labels, defaultSe
|
|
|
2727
2798
|
] });
|
|
2728
2799
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2729
2800
|
/* @__PURE__ */ jsxRuntime.jsx(ResumeNotice, { onCreated }),
|
|
2730
|
-
open &&
|
|
2731
|
-
/* @__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: [
|
|
2732
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-x", "aria-label": "Close", onClick: () => approving ? flow.cancel() : onClose(), children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {}) }),
|
|
2733
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-body", children: body })
|
|
2734
|
-
] }) }),
|
|
2735
|
-
document.body
|
|
2736
|
-
)
|
|
2801
|
+
open && /* @__PURE__ */ jsxRuntime.jsx(DialogShell, { label: text.title, locked: approving, onClose: () => approving ? flow.cancel() : onClose(), children: body })
|
|
2737
2802
|
] });
|
|
2738
2803
|
}
|
|
2804
|
+
var CAPABILITY_LABELS = [
|
|
2805
|
+
{ name: "CREATE_APP", label: "Add apps" },
|
|
2806
|
+
{ name: "INVITE_MEMBERS", label: "Invite people" },
|
|
2807
|
+
{ name: "JOIN_OPEN_TEAMS", label: "Join open teams" },
|
|
2808
|
+
{ name: "MANAGE_MEMBERS", label: "Manage team members" },
|
|
2809
|
+
{ name: "MANAGE_APPLICATION", label: "Upgrade apps" },
|
|
2810
|
+
{ name: "CREATE_TEAM", label: "Create teams" },
|
|
2811
|
+
{ name: "CREATE_CHILD_TEAM", label: "Create child teams" },
|
|
2812
|
+
{ name: "DELETE_TEAM", label: "Delete teams" },
|
|
2813
|
+
{ name: "MANAGE_VISIBILITY", label: "Change who can join a team" },
|
|
2814
|
+
{ name: "MANAGE_METADATA", label: "Rename the workspace and its teams" },
|
|
2815
|
+
{ name: "APPROVE_RELEASES", label: "Approve app releases" }
|
|
2816
|
+
];
|
|
2817
|
+
var ALL_CAPABILITIES = Object.values(meroJs.ORG_CAPABILITIES).reduce((mask, bit) => mask | bit, 0);
|
|
2818
|
+
function describeCapabilities(mask) {
|
|
2819
|
+
return CAPABILITY_LABELS.filter(({ name }) => (mask & meroJs.ORG_CAPABILITIES[name]) !== 0).map(({ label }) => label);
|
|
2820
|
+
}
|
|
2821
|
+
function heldCapabilities(org, account) {
|
|
2822
|
+
const role = account ? org.members[account] : void 0;
|
|
2823
|
+
if (role === "owner" || role === "admin") return ALL_CAPABILITIES;
|
|
2824
|
+
return account ? org.capabilities[account] ?? org.defaultCapabilities : 0;
|
|
2825
|
+
}
|
|
2826
|
+
var INVITE_KEY = "mero-react:invite-intent";
|
|
2827
|
+
var ACCEPT_KEY = "mero-react:accept-invite-intent";
|
|
2828
|
+
var NO_TOKEN = "Your node approved the request but made no invite. Nothing was changed.";
|
|
2829
|
+
var noOrg = (noun) => `Your node approved the request but named no ${noun}. Nothing was changed.`;
|
|
2830
|
+
var isInviteIntent = (v) => !!v && typeof v.role === "string";
|
|
2831
|
+
var isObject = (v) => !!v && typeof v === "object";
|
|
2832
|
+
var tokenOf = (r) => r.status === "approved" && r.kind === "createInvite" ? r.outcome?.token : void 0;
|
|
2833
|
+
var orgOf = (r) => r.status === "approved" && r.kind === "acceptInvite" ? r.outcome?.org : void 0;
|
|
2834
|
+
function useInviteCreate({ returnTo, linkBase, onCreated }) {
|
|
2835
|
+
const { client, passkey } = useMero();
|
|
2836
|
+
const { start, ...flow } = useNodeConsent({ storageKey: INVITE_KEY });
|
|
2837
|
+
const finish = (token, capabilities) => {
|
|
2838
|
+
if (!token) return NO_TOKEN;
|
|
2839
|
+
onCreated({ token, link: inviteLink(token, linkBase), ...capabilities === void 0 ? {} : { capabilities } });
|
|
2840
|
+
return void 0;
|
|
2841
|
+
};
|
|
2842
|
+
const create = ({ org, role, teams, uses, ttlSecs, allApps, capabilities }) => {
|
|
2843
|
+
const terms = {
|
|
2844
|
+
...teams?.length ? { teams } : {},
|
|
2845
|
+
...uses === void 0 ? {} : { uses },
|
|
2846
|
+
...ttlSecs === void 0 ? {} : { ttlSecs },
|
|
2847
|
+
...allApps === void 0 ? {} : { allApps },
|
|
2848
|
+
...capabilities === void 0 ? {} : { capabilities }
|
|
2849
|
+
};
|
|
2850
|
+
return start({
|
|
2851
|
+
request: meroJs.createInviteConsent({ org, role, ...terms }, returnTo),
|
|
2852
|
+
intent: { role, ...capabilities === void 0 ? {} : { capabilities }, ...linkBase ? { linkBase } : {} },
|
|
2853
|
+
direct: async () => {
|
|
2854
|
+
if (!client) throw new Error("Not connected to a node.");
|
|
2855
|
+
const answer = await client.orgs.inviteCreate({ org, role, ...terms }, confirmWith(passkey));
|
|
2856
|
+
return answer.token;
|
|
2857
|
+
},
|
|
2858
|
+
done: (outcome) => finish("direct" in outcome ? outcome.direct : tokenOf(outcome.consent), capabilities)
|
|
2859
|
+
});
|
|
2860
|
+
};
|
|
2861
|
+
return { create, ...flow };
|
|
2862
|
+
}
|
|
2863
|
+
function useInviteResume({ linkBase, onCreated }) {
|
|
2864
|
+
return useConsentResume({
|
|
2865
|
+
storageKey: INVITE_KEY,
|
|
2866
|
+
valid: isInviteIntent,
|
|
2867
|
+
onApproved: (intent, result) => {
|
|
2868
|
+
const token = tokenOf(result);
|
|
2869
|
+
if (!token) return NO_TOKEN;
|
|
2870
|
+
onCreated({ token, link: inviteLink(token, intent.linkBase ?? linkBase), ...intent.capabilities === void 0 ? {} : { capabilities: intent.capabilities } });
|
|
2871
|
+
return void 0;
|
|
2872
|
+
}
|
|
2873
|
+
});
|
|
2874
|
+
}
|
|
2875
|
+
function useInviteAccept({ returnTo, noun, onJoined, onError }) {
|
|
2876
|
+
const ctx = useMero();
|
|
2877
|
+
const { start, ...flow } = useNodeConsent({ storageKey: ACCEPT_KEY, onError });
|
|
2878
|
+
const accept = (token) => start({
|
|
2879
|
+
request: meroJs.acceptInviteConsent(token, returnTo),
|
|
2880
|
+
intent: {},
|
|
2881
|
+
direct: async () => {
|
|
2882
|
+
if (!ctx.client) throw new Error("Not connected to a node.");
|
|
2883
|
+
return (await ctx.client.orgs.inviteRedeem({ token })).org;
|
|
2884
|
+
},
|
|
2885
|
+
done: (outcome) => {
|
|
2886
|
+
const org = "direct" in outcome ? outcome.direct : orgOf(outcome.consent);
|
|
2887
|
+
if (!org) return noOrg(noun);
|
|
2888
|
+
onJoined({ org });
|
|
2889
|
+
return void 0;
|
|
2890
|
+
}
|
|
2891
|
+
});
|
|
2892
|
+
return { accept, ...flow };
|
|
2893
|
+
}
|
|
2894
|
+
function useAcceptResume({ noun, onJoined }) {
|
|
2895
|
+
return useConsentResume({
|
|
2896
|
+
storageKey: ACCEPT_KEY,
|
|
2897
|
+
valid: isObject,
|
|
2898
|
+
onApproved: (_intent, result) => {
|
|
2899
|
+
const org = orgOf(result);
|
|
2900
|
+
if (!org) return noOrg(noun);
|
|
2901
|
+
onJoined({ org });
|
|
2902
|
+
return void 0;
|
|
2903
|
+
}
|
|
2904
|
+
});
|
|
2905
|
+
}
|
|
2906
|
+
var REFUSALS = {
|
|
2907
|
+
FEATURE_NOT_ACTIVE: { text: "This cluster doesn't support custom permissions yet.", fallback: true },
|
|
2908
|
+
CANNOT_GRANT_UNHELD: { text: "You can't give a permission you don't have.", fallback: false },
|
|
2909
|
+
UNKNOWN_CAPABILITIES: { text: "This cluster does not know one of the permissions you chose.", fallback: true }
|
|
2910
|
+
};
|
|
2911
|
+
var DEFAULT_LABELS = {
|
|
2912
|
+
noun: "workspace",
|
|
2913
|
+
title: "Invite people",
|
|
2914
|
+
subtitle: "Choose what the people you invite can do.",
|
|
2915
|
+
next: "Create invite"
|
|
2916
|
+
};
|
|
2917
|
+
function useOrgFacts(org, active) {
|
|
2918
|
+
const { client, accountId } = useMero();
|
|
2919
|
+
const [facts, setFacts] = react.useState(null);
|
|
2920
|
+
react.useEffect(() => {
|
|
2921
|
+
if (!client || !org || !active) return;
|
|
2922
|
+
let live = true;
|
|
2923
|
+
setFacts(null);
|
|
2924
|
+
client.orgs.get({ org }).then(
|
|
2925
|
+
(info) => live && setFacts({ defaults: info.defaultCapabilities, held: heldCapabilities(info, accountId) }),
|
|
2926
|
+
() => live && setFacts("unreadable")
|
|
2927
|
+
);
|
|
2928
|
+
return () => {
|
|
2929
|
+
live = false;
|
|
2930
|
+
};
|
|
2931
|
+
}, [client, org, active, accountId]);
|
|
2932
|
+
return facts;
|
|
2933
|
+
}
|
|
2934
|
+
function describeDuration(secs) {
|
|
2935
|
+
const [unit, size] = secs >= 86400 ? ["day", 86400] : secs >= 3600 ? ["hour", 3600] : ["minute", 60];
|
|
2936
|
+
const n = Math.round(secs / size);
|
|
2937
|
+
return `${n} ${unit}${n === 1 ? "" : "s"}`;
|
|
2938
|
+
}
|
|
2939
|
+
var originRoot = () => `${typeof window === "undefined" ? "" : window.location.origin}/`;
|
|
2940
|
+
function InviteDialog({ client, passkey, ...props }) {
|
|
2941
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WithClient, { client, passkey, children: /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { ...props }) });
|
|
2942
|
+
}
|
|
2943
|
+
function Dialog2({ open, onClose, org, teams, role = "member", appName, inviterName, labels, onInvited, linkBase, returnTo, uses, ttlSecs, expiryOptions, allApps, permissions = true, shareExtra }) {
|
|
2944
|
+
const text = { ...DEFAULT_LABELS, ...labels };
|
|
2945
|
+
const facts = useOrgFacts(org, open && permissions);
|
|
2946
|
+
const [expiry, setExpiry] = react.useState(null);
|
|
2947
|
+
const ttl = expiryOptions?.length ? expiry ?? (ttlSecs !== void 0 && expiryOptions.includes(ttlSecs) ? ttlSecs : expiryOptions[0]) : ttlSecs;
|
|
2948
|
+
const [mode, setMode] = react.useState("default");
|
|
2949
|
+
const [picked, setPicked] = react.useState(null);
|
|
2950
|
+
const [shared, setShared] = react.useState(null);
|
|
2951
|
+
const [copied, copy] = useCopy();
|
|
2952
|
+
const ids = [react.useId(), react.useId(), react.useId()];
|
|
2953
|
+
const onCreated = (invite) => {
|
|
2954
|
+
setShared(invite);
|
|
2955
|
+
onInvited?.(invite);
|
|
2956
|
+
};
|
|
2957
|
+
const flow = useInviteCreate({ returnTo: returnTo ?? originRoot(), linkBase, onCreated });
|
|
2958
|
+
const resume = useInviteResume({ linkBase, onCreated });
|
|
2959
|
+
const [dismissed, setDismissed] = react.useState(null);
|
|
2960
|
+
const readable = facts !== null && facts !== "unreadable";
|
|
2961
|
+
const bits = picked ?? (readable ? facts.defaults & facts.held : 0);
|
|
2962
|
+
const redirecting = flow.phase === "redirect";
|
|
2963
|
+
const approving = flow.phase === "approving" || redirecting;
|
|
2964
|
+
const notice = resume.message && dismissed !== resume.message ? resume.message : null;
|
|
2965
|
+
const refusal = flow.errorCode ? REFUSALS[flow.errorCode] : void 0;
|
|
2966
|
+
const close = () => {
|
|
2967
|
+
setShared(null);
|
|
2968
|
+
onClose();
|
|
2969
|
+
};
|
|
2970
|
+
if (!open && !shared && !notice) return null;
|
|
2971
|
+
let body;
|
|
2972
|
+
if (approving) {
|
|
2973
|
+
body = /* @__PURE__ */ jsxRuntime.jsx(ApprovalCard, { redirecting, code: flow.code, onCancel: flow.cancel, onProceed: flow.proceed, onReopen: flow.reopen });
|
|
2974
|
+
} else if (shared) {
|
|
2975
|
+
const perms = shared.capabilities === void 0 ? null : describeCapabilities(shared.capabilities);
|
|
2976
|
+
body = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2977
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mero-cw-title", children: "Invite link ready" }),
|
|
2978
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mero-cw-sub", children: [
|
|
2979
|
+
inviterName ? `${inviterName} invites you${appName ? ` to ${appName}` : ""}. ` : "",
|
|
2980
|
+
"Anyone with this link can join as a ",
|
|
2981
|
+
role,
|
|
2982
|
+
appName ? ` in ${appName}` : "",
|
|
2983
|
+
".",
|
|
2984
|
+
" ",
|
|
2985
|
+
perms ? perms.length ? `They can: ${perms.join(", ")}.` : "They get basic access only." : `They get the ${text.noun}'s member defaults.`
|
|
2986
|
+
] }),
|
|
2987
|
+
labels?.note && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-sub", children: labels.note }),
|
|
2988
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-field", children: [
|
|
2989
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: ids[0], children: "Invite link" }),
|
|
2990
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { id: ids[0], readOnly: true, value: shared.link, onFocus: (e) => e.currentTarget.select() })
|
|
2991
|
+
] }),
|
|
2992
|
+
shareExtra?.(shared.link),
|
|
2993
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-row", children: [
|
|
2994
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-btn mero-cw-btn--primary", onClick: () => copy(shared.link), children: "Copy link" }),
|
|
2995
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-wait", role: "status", children: copied === "done" ? "Copied" : copied === "failed" ? "Could not copy" : "" }),
|
|
2996
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-btn", onClick: close, children: "Done" })
|
|
2997
|
+
] })
|
|
2998
|
+
] });
|
|
2999
|
+
} else {
|
|
3000
|
+
const defaultWords = !readable ? `the ${text.noun}'s member defaults` : describeCapabilities(facts.defaults).join(", ") || "basic access only";
|
|
3001
|
+
body = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3002
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mero-cw-title", children: text.title }),
|
|
3003
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-sub", children: text.subtitle }),
|
|
3004
|
+
notice && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mero-cw-error", role: "alert", children: [
|
|
3005
|
+
notice,
|
|
3006
|
+
" ",
|
|
3007
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-link", onClick: () => setDismissed(notice), children: "Dismiss" })
|
|
3008
|
+
] }),
|
|
3009
|
+
flow.error && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mero-cw-error", role: "alert", children: [
|
|
3010
|
+
refusal ? refusal.text : flow.error,
|
|
3011
|
+
refusal?.fallback && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3012
|
+
" ",
|
|
3013
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3014
|
+
"button",
|
|
3015
|
+
{
|
|
3016
|
+
type: "button",
|
|
3017
|
+
className: "mero-cw-link",
|
|
3018
|
+
onClick: () => {
|
|
3019
|
+
setMode("default");
|
|
3020
|
+
flow.clearError();
|
|
3021
|
+
},
|
|
3022
|
+
children: "Send a default invite"
|
|
3023
|
+
}
|
|
3024
|
+
)
|
|
3025
|
+
] })
|
|
3026
|
+
] }),
|
|
3027
|
+
permissions && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3028
|
+
facts === "unreadable" && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mero-cw-sub", children: [
|
|
3029
|
+
"We could not read this ",
|
|
3030
|
+
text.noun,
|
|
3031
|
+
"'s permissions, so only a default invite is available."
|
|
3032
|
+
] }),
|
|
3033
|
+
/* @__PURE__ */ jsxRuntime.jsxs("fieldset", { className: "mero-cw-choices", children: [
|
|
3034
|
+
/* @__PURE__ */ jsxRuntime.jsx("legend", { className: "mero-cw-visually-hidden", children: "Permissions" }),
|
|
3035
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "mero-cw-choice", children: [
|
|
3036
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "radio", name: ids[1], checked: mode === "default", onChange: () => setMode("default") }),
|
|
3037
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
3038
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: "Default" }),
|
|
3039
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-sub", children: `They get the ${text.noun}'s member defaults: ${defaultWords}.` })
|
|
3040
|
+
] })
|
|
3041
|
+
] }),
|
|
3042
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "mero-cw-choice", children: [
|
|
3043
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "radio", name: ids[1], checked: mode === "custom", disabled: !readable, onChange: () => setMode("custom") }),
|
|
3044
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
3045
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: "Custom" }),
|
|
3046
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "mero-cw-sub", children: "Choose exactly what they can do." })
|
|
3047
|
+
] })
|
|
3048
|
+
] })
|
|
3049
|
+
] }),
|
|
3050
|
+
mode === "custom" && readable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mero-cw-caps", children: CAPABILITY_LABELS.map(({ name, label }) => {
|
|
3051
|
+
const bit = meroJs.ORG_CAPABILITIES[name];
|
|
3052
|
+
const mine = (facts.held & bit) !== 0;
|
|
3053
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-cap", "data-disabled": mine ? void 0 : "", children: [
|
|
3054
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
3055
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: mine && (bits & bit) !== 0, disabled: !mine, "aria-describedby": mine ? void 0 : `${ids[1]}-${name}`, onChange: (e) => setPicked(e.target.checked ? bits | bit : bits & ~bit) }),
|
|
3056
|
+
label
|
|
3057
|
+
] }),
|
|
3058
|
+
!mine && /* @__PURE__ */ jsxRuntime.jsx("span", { id: `${ids[1]}-${name}`, className: "mero-cw-hint", children: "You don't have this" })
|
|
3059
|
+
] }, name);
|
|
3060
|
+
}) })
|
|
3061
|
+
] }),
|
|
3062
|
+
expiryOptions && expiryOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mero-cw-field", children: [
|
|
3063
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: ids[2], children: "Expires after" }),
|
|
3064
|
+
/* @__PURE__ */ jsxRuntime.jsx("select", { id: ids[2], value: ttl, onChange: (e) => setExpiry(Number(e.target.value)), children: expiryOptions.map((secs) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: secs, children: describeDuration(secs) }, secs)) })
|
|
3065
|
+
] }),
|
|
3066
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3067
|
+
"button",
|
|
3068
|
+
{
|
|
3069
|
+
type: "button",
|
|
3070
|
+
className: "mero-cw-btn mero-cw-btn--primary mero-cw-btn--full",
|
|
3071
|
+
disabled: !flow.ready || flow.phase !== "idle" || mode === "custom" && !readable,
|
|
3072
|
+
onClick: () => flow.create({ org, role, teams, uses, ttlSecs: ttl, allApps, ...mode === "custom" ? { capabilities: bits } : {} }),
|
|
3073
|
+
children: flow.phase === "creating" ? "Creating\u2026" : text.next
|
|
3074
|
+
}
|
|
3075
|
+
)
|
|
3076
|
+
] });
|
|
3077
|
+
}
|
|
3078
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DialogShell, { label: text.title, locked: approving, onClose: () => approving ? flow.cancel() : close(), children: body });
|
|
3079
|
+
}
|
|
3080
|
+
function useMembership(org, active) {
|
|
3081
|
+
const { client } = useMero();
|
|
3082
|
+
const [state, setState] = react.useState(null);
|
|
3083
|
+
react.useEffect(() => {
|
|
3084
|
+
if (!org || !active || !client) return;
|
|
3085
|
+
let live = true;
|
|
3086
|
+
client.auth.me().then(
|
|
3087
|
+
(me) => {
|
|
3088
|
+
const found = me.orgs?.find((o) => o.orgId === org);
|
|
3089
|
+
if (live) setState({ org, value: found ? { name: found.name ?? "" } : "no" });
|
|
3090
|
+
},
|
|
3091
|
+
() => live && setState({ org, value: "no" })
|
|
3092
|
+
);
|
|
3093
|
+
return () => {
|
|
3094
|
+
live = false;
|
|
3095
|
+
};
|
|
3096
|
+
}, [client, org, active]);
|
|
3097
|
+
if (!org) return "no";
|
|
3098
|
+
return state?.org === org ? state.value : "checking";
|
|
3099
|
+
}
|
|
3100
|
+
var article = (noun) => /^[aeiou]/i.test(noun) ? "an" : "a";
|
|
3101
|
+
function AcceptInviteDialog({ client, passkey, ...props }) {
|
|
3102
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WithClient, { client, passkey, children: /* @__PURE__ */ jsxRuntime.jsx(Dialog3, { ...props }) });
|
|
3103
|
+
}
|
|
3104
|
+
function Dialog3({ open, onClose, token, org, appName, labels, onJoined, onError, returnTo }) {
|
|
3105
|
+
const noun = labels?.noun ?? "workspace";
|
|
3106
|
+
const text = {
|
|
3107
|
+
title: labels?.title ?? `Join ${noun}`,
|
|
3108
|
+
body: labels?.body ?? `You were invited to ${article(noun)} ${noun}${appName ? ` in ${appName}` : ""}. Join it with your account.`,
|
|
3109
|
+
join: labels?.join ?? "Join"
|
|
3110
|
+
};
|
|
3111
|
+
const flow = useInviteAccept({ returnTo: returnTo ?? `${typeof window === "undefined" ? "" : window.location.origin}/`, noun, onJoined, onError });
|
|
3112
|
+
const resume = useAcceptResume({ noun, onJoined });
|
|
3113
|
+
const member = useMembership(org, open);
|
|
3114
|
+
const [dismissed, setDismissed] = react.useState(null);
|
|
3115
|
+
const notice = resume.message && dismissed !== resume.message ? resume.message : null;
|
|
3116
|
+
const redirecting = flow.phase === "redirect";
|
|
3117
|
+
const approving = flow.phase === "approving" || redirecting;
|
|
3118
|
+
if (!open && !notice) return null;
|
|
3119
|
+
const already = typeof member === "object" ? member : null;
|
|
3120
|
+
const name = already?.name || `this ${noun}`;
|
|
3121
|
+
let body;
|
|
3122
|
+
if (approving) {
|
|
3123
|
+
body = /* @__PURE__ */ jsxRuntime.jsx(ApprovalCard, { redirecting, code: flow.code, onCancel: flow.cancel, onProceed: flow.proceed, onReopen: flow.reopen });
|
|
3124
|
+
} else if (already && org) {
|
|
3125
|
+
body = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3126
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mero-cw-title", children: `You're already in ${name}` }),
|
|
3127
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-sub", children: `The invitation was for ${name}, and you are already a member, so there is nothing to accept. It is still unused for the person it was meant for.` }),
|
|
3128
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-btn mero-cw-btn--primary mero-cw-btn--full", onClick: () => onJoined({ org }), children: "Continue" })
|
|
3129
|
+
] });
|
|
3130
|
+
} else {
|
|
3131
|
+
body = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3132
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "mero-cw-title", children: text.title }),
|
|
3133
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mero-cw-sub", children: text.body }),
|
|
3134
|
+
[notice, flow.error].filter(Boolean).map((message) => /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mero-cw-error", role: "alert", children: [
|
|
3135
|
+
message,
|
|
3136
|
+
message === notice && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3137
|
+
" ",
|
|
3138
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "mero-cw-link", onClick: () => setDismissed(message), children: "Dismiss" })
|
|
3139
|
+
] })
|
|
3140
|
+
] }, message)),
|
|
3141
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3142
|
+
"button",
|
|
3143
|
+
{
|
|
3144
|
+
type: "button",
|
|
3145
|
+
className: "mero-cw-btn mero-cw-btn--primary mero-cw-btn--full",
|
|
3146
|
+
disabled: !flow.ready || flow.phase !== "idle" || member === "checking",
|
|
3147
|
+
onClick: () => flow.accept(token),
|
|
3148
|
+
children: flow.phase === "creating" ? "Joining\u2026" : text.join
|
|
3149
|
+
}
|
|
3150
|
+
)
|
|
3151
|
+
] });
|
|
3152
|
+
}
|
|
3153
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DialogShell, { label: already ? `You're already in ${name}` : text.title, locked: approving, onClose: () => approving ? flow.cancel() : onClose(), children: body });
|
|
3154
|
+
}
|
|
2739
3155
|
|
|
2740
3156
|
Object.defineProperty(exports, "MeroContext", {
|
|
2741
3157
|
enumerable: true,
|
|
2742
3158
|
get: function () { return chunkRRETZWNI_cjs.MeroContext; }
|
|
2743
3159
|
});
|
|
3160
|
+
exports.AcceptInviteDialog = AcceptInviteDialog;
|
|
2744
3161
|
exports.CONSENT_RETURN_MESSAGE = CONSENT_RETURN_MESSAGE;
|
|
2745
3162
|
exports.CalimeroLogo = CalimeroLogo;
|
|
2746
3163
|
exports.ConnectButton = ConnectButton;
|
|
2747
3164
|
exports.ConsentPopupReturn = ConsentPopupReturn;
|
|
2748
3165
|
exports.CreateWorkspaceDialog = CreateWorkspaceDialog;
|
|
3166
|
+
exports.InviteDialog = InviteDialog;
|
|
2749
3167
|
exports.LoginModal = LoginModal;
|
|
2750
3168
|
exports.MERO_CSS_VARS = MERO_CSS_VARS;
|
|
2751
3169
|
exports.MeroProvider = MeroProvider;
|
|
@@ -2760,6 +3178,7 @@ exports.clearNodeUrl = clearNodeUrl;
|
|
|
2760
3178
|
exports.clusterName = clusterName;
|
|
2761
3179
|
exports.cssVar = cssVar;
|
|
2762
3180
|
exports.defaultMeroTheme = defaultMeroTheme;
|
|
3181
|
+
exports.describeCapabilities = describeCapabilities;
|
|
2763
3182
|
exports.describeError = describeError;
|
|
2764
3183
|
exports.followEvents = followEvents;
|
|
2765
3184
|
exports.getAppId = getAppId;
|