@abraca/junis 2.100.0 → 2.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/dist/module.d.mts +14 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +32 -0
- package/dist/runtime/components/JunAccessGate.d.vue.ts +3 -0
- package/dist/runtime/components/JunAccessGate.vue +146 -0
- package/dist/runtime/components/JunAccessGate.vue.d.ts +3 -0
- package/dist/runtime/components/JunServiceCard.vue +2 -0
- package/dist/runtime/components/JunShell.vue +2 -0
- package/dist/runtime/components/renderers/JunConfigRenderer.vue +422 -0
- package/dist/runtime/components/renderers/JunStatsRenderer.vue +5 -1
- package/dist/runtime/composables/useJunAccess.d.ts +9 -0
- package/dist/runtime/composables/useJunAccess.js +25 -0
- package/dist/runtime/composables/useJunAccessAdmin.d.ts +90 -0
- package/dist/runtime/composables/useJunAccessAdmin.js +129 -0
- package/dist/runtime/composables/useJunApiFetch.d.ts +12 -0
- package/dist/runtime/composables/useJunApiFetch.js +4 -0
- package/dist/runtime/composables/useJunGarden.js +4 -2
- package/dist/runtime/composables/useJunSettings.d.ts +1 -1
- package/dist/runtime/composables/useJunSettings.js +6 -0
- package/dist/runtime/composables/useJunSiteConfigValues.js +2 -0
- package/dist/runtime/layouts/jun.d.vue.ts +2 -2
- package/dist/runtime/layouts/jun.vue +18 -1
- package/dist/runtime/layouts/jun.vue.d.ts +2 -2
- package/dist/runtime/pages/doc.vue +6 -1
- package/dist/runtime/pages/index.vue +7 -1
- package/dist/runtime/plugins/jun-session.client.d.ts +2 -0
- package/dist/runtime/plugins/jun-session.client.js +40 -0
- package/dist/runtime/server/api/links.get.js +2 -2
- package/dist/runtime/server/api/resolve/[...slug].get.js +4 -4
- package/dist/runtime/server/api/search.get.js +2 -2
- package/dist/runtime/server/api/tree.get.js +2 -2
- package/dist/runtime/server/middleware/jun-access.d.ts +2 -0
- package/dist/runtime/server/middleware/jun-access.js +34 -0
- package/dist/runtime/server/routes/jun-card.png.get.js +2 -2
- package/dist/runtime/server/routes/manifest.webmanifest.get.js +2 -2
- package/dist/runtime/server/routes/robots.txt.get.d.ts +2 -0
- package/dist/runtime/server/routes/robots.txt.get.js +16 -0
- package/dist/runtime/server/utils/junAccessGate.d.ts +36 -0
- package/dist/runtime/server/utils/junAccessGate.js +57 -0
- package/dist/runtime/server/utils/junFeed.js +2 -2
- package/dist/runtime/server/utils/junPages.js +2 -2
- package/dist/runtime/server/utils/junVisibility.d.ts +40 -0
- package/dist/runtime/server/utils/junVisibility.js +6 -0
- package/dist/runtime/types.d.ts +9 -0
- package/dist/runtime/utils/junAccess.d.ts +160 -0
- package/dist/runtime/utils/junAccess.js +62 -0
- package/dist/runtime/utils/junVisibility.d.ts +40 -0
- package/dist/runtime/utils/junVisibility.js +6 -0
- package/dist/types.d.mts +1 -1
- package/package.json +8 -3
|
@@ -9,12 +9,22 @@ import {
|
|
|
9
9
|
useAbracadabra,
|
|
10
10
|
useJunBackdrop,
|
|
11
11
|
useJunBackgroundImage,
|
|
12
|
+
useJunCurrentDoc,
|
|
12
13
|
useJunOptions,
|
|
13
14
|
useJunPageType,
|
|
14
15
|
useJunSiteConfig,
|
|
15
16
|
useJunStudio,
|
|
16
17
|
useJunUpload
|
|
17
18
|
} from "#imports";
|
|
19
|
+
import { useJunAccess } from "../../composables/useJunAccess";
|
|
20
|
+
import {
|
|
21
|
+
JUN_DOC_ACCESS_CHOICES,
|
|
22
|
+
useJunAccessAdmin
|
|
23
|
+
} from "../../composables/useJunAccessAdmin";
|
|
24
|
+
import {
|
|
25
|
+
JUN_PERSON_ROLES,
|
|
26
|
+
useJunPeopleAdmin
|
|
27
|
+
} from "../../composables/useJunPeopleAdmin";
|
|
18
28
|
import { JUN_DYNAMIC_SPEC_KEYS, JUN_VIEW_SPECS, junViewSpecFor } from "../../utils/junViewSpecs";
|
|
19
29
|
import { junResolveViewValue, junNextViewObject } from "../../utils/junViewValues";
|
|
20
30
|
const props = defineProps({
|
|
@@ -740,6 +750,71 @@ function writeHouse(typeKey, forType) {
|
|
|
740
750
|
if (forType && Object.keys(forType).length) next[typeKey] = forType;
|
|
741
751
|
set({ renderers: Object.keys(next).length ? next : void 0 });
|
|
742
752
|
}
|
|
753
|
+
const access = useJunAccess();
|
|
754
|
+
const accessAdmin = useJunAccessAdmin();
|
|
755
|
+
const people = useJunPeopleAdmin();
|
|
756
|
+
const { currentDocId } = useJunCurrentDoc();
|
|
757
|
+
const pageAccess = ref({ own: null, effective: null });
|
|
758
|
+
const pageAccessLoaded = ref(false);
|
|
759
|
+
const pageAccessChoice = computed({
|
|
760
|
+
get: () => pageAccess.value.own ?? "inherit",
|
|
761
|
+
set: (value) => {
|
|
762
|
+
const next = value === "inherit" ? null : value;
|
|
763
|
+
const docId = currentDocId.value;
|
|
764
|
+
if (!docId) return;
|
|
765
|
+
pageAccess.value = { ...pageAccess.value, own: next };
|
|
766
|
+
void accessAdmin.setDocAccess(docId, next).then(() => loadPageAccess());
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
async function loadPageAccess() {
|
|
770
|
+
const docId = currentDocId.value;
|
|
771
|
+
if (!docId) return;
|
|
772
|
+
pageAccess.value = await accessAdmin.docAccess(docId);
|
|
773
|
+
pageAccessLoaded.value = true;
|
|
774
|
+
}
|
|
775
|
+
const grantRows = computed(
|
|
776
|
+
() => Object.entries(people.grants.value).map(([userId, grant]) => ({
|
|
777
|
+
userId,
|
|
778
|
+
username: grant.username,
|
|
779
|
+
role: grant.role,
|
|
780
|
+
/**
|
|
781
|
+
* Whether this row's role is one the owner may HAND OUT.
|
|
782
|
+
*
|
|
783
|
+
* `admin` and `service` are not: the server refuses to grant an elevated
|
|
784
|
+
* role to anyone but a root admin, so offering them in the menu would be
|
|
785
|
+
* offering a button that fails. A row holding one is shown as a plain
|
|
786
|
+
* label instead of a control — the site's own service runner has a grant
|
|
787
|
+
* here, and it must be visible without being editable.
|
|
788
|
+
*/
|
|
789
|
+
editable: JUN_PERSON_ROLES.some((r) => r.value === grant.role)
|
|
790
|
+
})).sort((a, b) => (a.username || a.userId).localeCompare(b.username || b.userId))
|
|
791
|
+
);
|
|
792
|
+
const inviteRole = ref("viewer");
|
|
793
|
+
const inviteUses = ref(1);
|
|
794
|
+
async function loadAccess() {
|
|
795
|
+
await Promise.all([
|
|
796
|
+
accessAdmin.refreshServer(),
|
|
797
|
+
people.refresh(),
|
|
798
|
+
accessAdmin.refreshInvites(),
|
|
799
|
+
loadPageAccess()
|
|
800
|
+
]);
|
|
801
|
+
}
|
|
802
|
+
const strangerReads = computed(() => {
|
|
803
|
+
const server = accessAdmin.server.value;
|
|
804
|
+
if (!server) return "unknown";
|
|
805
|
+
if (server.anonymous !== "none") return "yes, without an account";
|
|
806
|
+
if (server.registrationOpen === false) return "no \u2014 registration is closed";
|
|
807
|
+
if (server.inviteOnly) return "no \u2014 an invite is required";
|
|
808
|
+
if (server.authenticated === "none") return "no \u2014 signed-in accounts get nothing by default";
|
|
809
|
+
return "yes, as a soft identity";
|
|
810
|
+
});
|
|
811
|
+
watch(
|
|
812
|
+
() => shows("access"),
|
|
813
|
+
(on) => {
|
|
814
|
+
if (on && canEdit.value) void loadAccess();
|
|
815
|
+
},
|
|
816
|
+
{ immediate: true }
|
|
817
|
+
);
|
|
743
818
|
function shows(id) {
|
|
744
819
|
return !props.section || props.section === id;
|
|
745
820
|
}
|
|
@@ -2983,6 +3058,353 @@ function shows(id) {
|
|
|
2983
3058
|
</UFormField>
|
|
2984
3059
|
</div>
|
|
2985
3060
|
</section>
|
|
3061
|
+
|
|
3062
|
+
<!-- Access.
|
|
3063
|
+
|
|
3064
|
+
The section that did not exist. Every permission in this system is
|
|
3065
|
+
real and server-enforced, and the only one an owner could SEE was
|
|
3066
|
+
whichever person happened to be standing at the campfire. What a
|
|
3067
|
+
stranger may read, whether anybody may join, who holds a grant here,
|
|
3068
|
+
and whether this page is public were all answerable only by reading
|
|
3069
|
+
a config file on the backend.
|
|
3070
|
+
|
|
3071
|
+
Two halves, and the split is deliberate: what the SERVER decides is
|
|
3072
|
+
shown and never edited (a panel that pretended to move
|
|
3073
|
+
`[access].authenticated` would be lying — that key lives in a file an
|
|
3074
|
+
operator deploys), and what the SITE decides is edited here. -->
|
|
3075
|
+
<section
|
|
3076
|
+
v-if="shows('access')"
|
|
3077
|
+
class="space-y-5"
|
|
3078
|
+
:class="bare ? '' : 'jun-card rounded-2xl p-6'"
|
|
3079
|
+
>
|
|
3080
|
+
<header class="flex items-start gap-3">
|
|
3081
|
+
<span class="flex size-9 flex-none items-center justify-center rounded-lg bg-black/5 dark:bg-white/10">
|
|
3082
|
+
<UIcon
|
|
3083
|
+
name="i-lucide-shield"
|
|
3084
|
+
class="size-4.5"
|
|
3085
|
+
/>
|
|
3086
|
+
</span>
|
|
3087
|
+
<div>
|
|
3088
|
+
<h2 class="text-sm font-semibold text-highlighted">
|
|
3089
|
+
Access
|
|
3090
|
+
</h2>
|
|
3091
|
+
<p class="text-xs text-muted">
|
|
3092
|
+
Who may read this site, who may write to it, and how somebody joins. The
|
|
3093
|
+
server is the authority on every line here — this is where you can see it.
|
|
3094
|
+
</p>
|
|
3095
|
+
</div>
|
|
3096
|
+
</header>
|
|
3097
|
+
|
|
3098
|
+
<!-- ── What the server says ──────────────────────────────────────── -->
|
|
3099
|
+
<div class="jun-card space-y-3 rounded-xl p-4">
|
|
3100
|
+
<div class="flex items-center gap-2">
|
|
3101
|
+
<UIcon
|
|
3102
|
+
name="i-lucide-server"
|
|
3103
|
+
class="size-4 text-dimmed"
|
|
3104
|
+
/>
|
|
3105
|
+
<h3 class="text-xs font-semibold uppercase tracking-wide text-muted">
|
|
3106
|
+
This server
|
|
3107
|
+
</h3>
|
|
3108
|
+
</div>
|
|
3109
|
+
|
|
3110
|
+
<p
|
|
3111
|
+
v-if="!accessAdmin.server.value"
|
|
3112
|
+
class="text-sm text-muted"
|
|
3113
|
+
>
|
|
3114
|
+
Asking the backend…
|
|
3115
|
+
</p>
|
|
3116
|
+
|
|
3117
|
+
<dl
|
|
3118
|
+
v-else
|
|
3119
|
+
class="grid grid-cols-1 gap-x-8 gap-y-2 text-sm sm:grid-cols-2"
|
|
3120
|
+
>
|
|
3121
|
+
<div class="flex items-baseline justify-between gap-4">
|
|
3122
|
+
<dt class="text-muted">
|
|
3123
|
+
A passer-by can read it
|
|
3124
|
+
</dt>
|
|
3125
|
+
<dd class="text-highlighted">
|
|
3126
|
+
{{ strangerReads }}
|
|
3127
|
+
</dd>
|
|
3128
|
+
</div>
|
|
3129
|
+
<div class="flex items-baseline justify-between gap-4">
|
|
3130
|
+
<dt class="text-muted">
|
|
3131
|
+
Signed in, with no grant
|
|
3132
|
+
</dt>
|
|
3133
|
+
<dd class="text-highlighted">
|
|
3134
|
+
{{ accessAdmin.server.value.authenticated }}
|
|
3135
|
+
</dd>
|
|
3136
|
+
</div>
|
|
3137
|
+
<div class="flex items-baseline justify-between gap-4">
|
|
3138
|
+
<dt class="text-muted">
|
|
3139
|
+
Anonymous
|
|
3140
|
+
</dt>
|
|
3141
|
+
<dd class="text-highlighted">
|
|
3142
|
+
{{ accessAdmin.server.value.anonymous }}
|
|
3143
|
+
</dd>
|
|
3144
|
+
</div>
|
|
3145
|
+
<div class="flex items-baseline justify-between gap-4">
|
|
3146
|
+
<dt class="text-muted">
|
|
3147
|
+
Registration
|
|
3148
|
+
</dt>
|
|
3149
|
+
<dd class="text-highlighted">
|
|
3150
|
+
<template v-if="accessAdmin.server.value.registrationOpen === null">
|
|
3151
|
+
not reported
|
|
3152
|
+
</template>
|
|
3153
|
+
<template v-else-if="!accessAdmin.server.value.registrationOpen">
|
|
3154
|
+
closed
|
|
3155
|
+
</template>
|
|
3156
|
+
<template v-else-if="accessAdmin.server.value.inviteOnly">
|
|
3157
|
+
invite only
|
|
3158
|
+
</template>
|
|
3159
|
+
<template v-else>
|
|
3160
|
+
open
|
|
3161
|
+
</template>
|
|
3162
|
+
</dd>
|
|
3163
|
+
</div>
|
|
3164
|
+
<div class="flex items-baseline justify-between gap-4">
|
|
3165
|
+
<dt class="text-muted">
|
|
3166
|
+
This site is built as
|
|
3167
|
+
</dt>
|
|
3168
|
+
<dd class="text-highlighted">
|
|
3169
|
+
{{ access.mode.value }}
|
|
3170
|
+
</dd>
|
|
3171
|
+
</div>
|
|
3172
|
+
<div class="flex items-baseline justify-between gap-4">
|
|
3173
|
+
<dt class="text-muted">
|
|
3174
|
+
Feeds, sitemap, cards
|
|
3175
|
+
</dt>
|
|
3176
|
+
<dd class="text-highlighted">
|
|
3177
|
+
{{ access.discovery.value ? "published" : "withheld" }}
|
|
3178
|
+
</dd>
|
|
3179
|
+
</div>
|
|
3180
|
+
</dl>
|
|
3181
|
+
|
|
3182
|
+
<p class="text-xs text-dimmed">
|
|
3183
|
+
These come from the backend's own <code>/info</code> and from this build. Changing
|
|
3184
|
+
them means changing <code>config.toml</code> (or <code>ABRA_ACCESS_*</code>) and
|
|
3185
|
+
<code>jun.access.mode</code> — see ACCESS.md.
|
|
3186
|
+
</p>
|
|
3187
|
+
</div>
|
|
3188
|
+
|
|
3189
|
+
<!-- ── This page ─────────────────────────────────────────────────── -->
|
|
3190
|
+
<div class="jun-card space-y-3 rounded-xl p-4">
|
|
3191
|
+
<div class="flex items-center gap-2">
|
|
3192
|
+
<UIcon
|
|
3193
|
+
name="i-lucide-file-lock"
|
|
3194
|
+
class="size-4 text-dimmed"
|
|
3195
|
+
/>
|
|
3196
|
+
<h3 class="text-xs font-semibold uppercase tracking-wide text-muted">
|
|
3197
|
+
The page you are on
|
|
3198
|
+
</h3>
|
|
3199
|
+
</div>
|
|
3200
|
+
|
|
3201
|
+
<JunConfigRow
|
|
3202
|
+
label="Public access"
|
|
3203
|
+
hint="Cascades to everything under it"
|
|
3204
|
+
>
|
|
3205
|
+
<USelectMenu
|
|
3206
|
+
v-model="pageAccessChoice"
|
|
3207
|
+
:items="JUN_DOC_ACCESS_CHOICES"
|
|
3208
|
+
value-key="value"
|
|
3209
|
+
label-key="label"
|
|
3210
|
+
:disabled="!editing || !currentDocId"
|
|
3211
|
+
size="xs"
|
|
3212
|
+
class="w-56"
|
|
3213
|
+
/>
|
|
3214
|
+
</JunConfigRow>
|
|
3215
|
+
|
|
3216
|
+
<p
|
|
3217
|
+
v-if="pageAccessLoaded"
|
|
3218
|
+
class="text-xs text-dimmed"
|
|
3219
|
+
>
|
|
3220
|
+
Resolves to <strong class="text-muted">{{ pageAccess.effective ?? "the server default" }}</strong>.
|
|
3221
|
+
The cascade takes the NEAREST ancestor that sets a value, not the strongest — so a
|
|
3222
|
+
page can publish itself back out of a private parent.
|
|
3223
|
+
</p>
|
|
3224
|
+
</div>
|
|
3225
|
+
|
|
3226
|
+
<!-- ── People ───────────────────────────────────────────────────── -->
|
|
3227
|
+
<div class="jun-card space-y-3 rounded-xl p-4">
|
|
3228
|
+
<div class="flex items-center gap-2">
|
|
3229
|
+
<UIcon
|
|
3230
|
+
name="i-lucide-users"
|
|
3231
|
+
class="size-4 text-dimmed"
|
|
3232
|
+
/>
|
|
3233
|
+
<h3 class="text-xs font-semibold uppercase tracking-wide text-muted">
|
|
3234
|
+
People with a grant here
|
|
3235
|
+
</h3>
|
|
3236
|
+
</div>
|
|
3237
|
+
|
|
3238
|
+
<p
|
|
3239
|
+
v-if="!people.loaded.value"
|
|
3240
|
+
class="text-sm text-muted"
|
|
3241
|
+
>
|
|
3242
|
+
Reading the permissions…
|
|
3243
|
+
</p>
|
|
3244
|
+
<p
|
|
3245
|
+
v-else-if="!grantRows.length"
|
|
3246
|
+
class="text-sm text-muted"
|
|
3247
|
+
>
|
|
3248
|
+
Nobody has an explicit grant. Everyone reaching this site gets
|
|
3249
|
+
<strong class="text-highlighted">{{ accessAdmin.server.value?.authenticated ?? "the server default" }}</strong>.
|
|
3250
|
+
</p>
|
|
3251
|
+
|
|
3252
|
+
<ul
|
|
3253
|
+
v-else
|
|
3254
|
+
class="divide-y divide-default"
|
|
3255
|
+
>
|
|
3256
|
+
<li
|
|
3257
|
+
v-for="row in grantRows"
|
|
3258
|
+
:key="row.userId"
|
|
3259
|
+
class="flex items-center justify-between gap-4 py-2"
|
|
3260
|
+
>
|
|
3261
|
+
<div class="min-w-0">
|
|
3262
|
+
<p class="truncate text-sm text-highlighted">
|
|
3263
|
+
{{ row.username || "An account with no name" }}
|
|
3264
|
+
</p>
|
|
3265
|
+
<p class="truncate font-mono text-xs text-dimmed">
|
|
3266
|
+
{{ row.userId.slice(0, 16) }}…
|
|
3267
|
+
</p>
|
|
3268
|
+
</div>
|
|
3269
|
+
<div class="flex flex-none items-center gap-2">
|
|
3270
|
+
<USelectMenu
|
|
3271
|
+
v-if="row.editable"
|
|
3272
|
+
:model-value="row.role"
|
|
3273
|
+
:items="JUN_PERSON_ROLES"
|
|
3274
|
+
value-key="value"
|
|
3275
|
+
label-key="label"
|
|
3276
|
+
:disabled="!editing || people.busy.value === row.userId"
|
|
3277
|
+
size="xs"
|
|
3278
|
+
class="w-32"
|
|
3279
|
+
@update:model-value="(value) => people.setRole(row.userId, value)"
|
|
3280
|
+
/>
|
|
3281
|
+
<!-- `admin` / `service` — real, visible, and not ours to move.
|
|
3282
|
+
The server refuses to grant either to anyone but a root
|
|
3283
|
+
admin, so a menu here would be a button that fails. -->
|
|
3284
|
+
<span
|
|
3285
|
+
v-else
|
|
3286
|
+
class="w-32 text-right text-xs text-dimmed"
|
|
3287
|
+
>{{ row.role }}</span>
|
|
3288
|
+
<UButton
|
|
3289
|
+
icon="i-lucide-x"
|
|
3290
|
+
variant="ghost"
|
|
3291
|
+
color="neutral"
|
|
3292
|
+
size="xs"
|
|
3293
|
+
:disabled="!editing || !row.editable"
|
|
3294
|
+
:aria-label="`Revoke ${row.username || row.userId}`"
|
|
3295
|
+
@click="people.revoke(row.userId)"
|
|
3296
|
+
/>
|
|
3297
|
+
</div>
|
|
3298
|
+
</li>
|
|
3299
|
+
</ul>
|
|
3300
|
+
|
|
3301
|
+
<p class="text-xs text-dimmed">
|
|
3302
|
+
A grant is a permission row on the space root and cascades to every page under it.
|
|
3303
|
+
Revoking is not a ban — the person falls back to whatever the server's default says.
|
|
3304
|
+
</p>
|
|
3305
|
+
</div>
|
|
3306
|
+
|
|
3307
|
+
<!-- ── Invites ──────────────────────────────────────────────────── -->
|
|
3308
|
+
<div class="jun-card space-y-3 rounded-xl p-4">
|
|
3309
|
+
<div class="flex items-center gap-2">
|
|
3310
|
+
<UIcon
|
|
3311
|
+
name="i-lucide-ticket"
|
|
3312
|
+
class="size-4 text-dimmed"
|
|
3313
|
+
/>
|
|
3314
|
+
<h3 class="text-xs font-semibold uppercase tracking-wide text-muted">
|
|
3315
|
+
Invites
|
|
3316
|
+
</h3>
|
|
3317
|
+
</div>
|
|
3318
|
+
|
|
3319
|
+
<p
|
|
3320
|
+
v-if="accessAdmin.error.value"
|
|
3321
|
+
class="text-sm text-muted"
|
|
3322
|
+
>
|
|
3323
|
+
{{ accessAdmin.error.value }}
|
|
3324
|
+
</p>
|
|
3325
|
+
|
|
3326
|
+
<template v-else>
|
|
3327
|
+
<div class="flex flex-wrap items-end gap-3">
|
|
3328
|
+
<UFormField
|
|
3329
|
+
label="Role"
|
|
3330
|
+
size="xs"
|
|
3331
|
+
>
|
|
3332
|
+
<USelectMenu
|
|
3333
|
+
v-model="inviteRole"
|
|
3334
|
+
:items="JUN_PERSON_ROLES"
|
|
3335
|
+
value-key="value"
|
|
3336
|
+
label-key="label"
|
|
3337
|
+
:disabled="!editing"
|
|
3338
|
+
size="xs"
|
|
3339
|
+
class="w-32"
|
|
3340
|
+
/>
|
|
3341
|
+
</UFormField>
|
|
3342
|
+
<UFormField
|
|
3343
|
+
label="Uses"
|
|
3344
|
+
size="xs"
|
|
3345
|
+
>
|
|
3346
|
+
<UInput
|
|
3347
|
+
v-model.number="inviteUses"
|
|
3348
|
+
type="number"
|
|
3349
|
+
min="1"
|
|
3350
|
+
:disabled="!editing"
|
|
3351
|
+
size="xs"
|
|
3352
|
+
class="w-20"
|
|
3353
|
+
/>
|
|
3354
|
+
</UFormField>
|
|
3355
|
+
<UButton
|
|
3356
|
+
icon="i-lucide-plus"
|
|
3357
|
+
color="neutral"
|
|
3358
|
+
size="xs"
|
|
3359
|
+
:loading="accessAdmin.busy.value === 'create'"
|
|
3360
|
+
:disabled="!editing"
|
|
3361
|
+
@click="accessAdmin.createInvite({ role: inviteRole, maxUses: inviteUses })"
|
|
3362
|
+
>
|
|
3363
|
+
New invite
|
|
3364
|
+
</UButton>
|
|
3365
|
+
</div>
|
|
3366
|
+
|
|
3367
|
+
<p
|
|
3368
|
+
v-if="accessAdmin.invitesLoaded.value && !accessAdmin.invites.value.length"
|
|
3369
|
+
class="text-sm text-muted"
|
|
3370
|
+
>
|
|
3371
|
+
No invites. On a private site this is how somebody joins without a shell on the
|
|
3372
|
+
backend.
|
|
3373
|
+
</p>
|
|
3374
|
+
|
|
3375
|
+
<ul
|
|
3376
|
+
v-else-if="accessAdmin.invites.value.length"
|
|
3377
|
+
class="divide-y divide-default"
|
|
3378
|
+
>
|
|
3379
|
+
<li
|
|
3380
|
+
v-for="invite in accessAdmin.invites.value"
|
|
3381
|
+
:key="invite.code"
|
|
3382
|
+
class="flex items-center justify-between gap-4 py-2"
|
|
3383
|
+
>
|
|
3384
|
+
<div class="min-w-0">
|
|
3385
|
+
<p class="truncate font-mono text-sm text-highlighted">
|
|
3386
|
+
{{ invite.code }}
|
|
3387
|
+
</p>
|
|
3388
|
+
<p class="text-xs text-dimmed">
|
|
3389
|
+
{{ invite.role }} · {{ invite.useCount }}/{{ invite.maxUses }} used
|
|
3390
|
+
<span v-if="invite.revoked"> · revoked</span>
|
|
3391
|
+
</p>
|
|
3392
|
+
</div>
|
|
3393
|
+
<UButton
|
|
3394
|
+
icon="i-lucide-x"
|
|
3395
|
+
variant="ghost"
|
|
3396
|
+
color="neutral"
|
|
3397
|
+
size="xs"
|
|
3398
|
+
:disabled="!editing || invite.revoked"
|
|
3399
|
+
:loading="accessAdmin.busy.value === invite.code"
|
|
3400
|
+
:aria-label="`Revoke invite ${invite.code}`"
|
|
3401
|
+
@click="accessAdmin.revokeInvite(invite.code)"
|
|
3402
|
+
/>
|
|
3403
|
+
</li>
|
|
3404
|
+
</ul>
|
|
3405
|
+
</template>
|
|
3406
|
+
</div>
|
|
3407
|
+
</section>
|
|
2986
3408
|
</div>
|
|
2987
3409
|
</div>
|
|
2988
3410
|
</template>
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
useJunViewOptions
|
|
15
15
|
} from "#imports";
|
|
16
16
|
import { useFetch } from "#app";
|
|
17
|
+
import { junApiFetch } from "../../composables/useJunApiFetch";
|
|
17
18
|
import { junIsVisibleMessage } from "../../utils/junModeration";
|
|
18
19
|
const props = defineProps({
|
|
19
20
|
docId: { type: String, required: true },
|
|
@@ -45,7 +46,10 @@ function renamePage(t) {
|
|
|
45
46
|
function renameSubtitle(s) {
|
|
46
47
|
tree.updateMeta(props.docId, { excerpt: s || void 0 });
|
|
47
48
|
}
|
|
48
|
-
const { data: ssrStats } = useFetch(`${opts.apiBase}/stats`, {
|
|
49
|
+
const { data: ssrStats } = useFetch(`${opts.apiBase}/stats`, {
|
|
50
|
+
key: "jun-stats",
|
|
51
|
+
$fetch: junApiFetch()
|
|
52
|
+
});
|
|
49
53
|
const liveEntries = computed(() => {
|
|
50
54
|
const all = entries.value ?? [];
|
|
51
55
|
return all.filter(
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function useJunAccess(): {
|
|
2
|
+
mode: import("vue").ComputedRef<import("#imports").JunAccessMode>;
|
|
3
|
+
isPrivate: import("vue").ComputedRef<boolean>;
|
|
4
|
+
discovery: import("vue").ComputedRef<boolean>;
|
|
5
|
+
gate: import("vue").ComputedRef<Required<import("#imports").JunAccessGateCopy>>;
|
|
6
|
+
serverGated: import("vue").Ref<boolean, boolean>;
|
|
7
|
+
admitted: import("vue").ComputedRef<boolean>;
|
|
8
|
+
gated: import("vue").ComputedRef<boolean>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useRequestEvent, useState } from "#app";
|
|
3
|
+
import { useAbracadabra } from "#imports";
|
|
4
|
+
import { useJunOptions } from "./useJunOptions.js";
|
|
5
|
+
export function useJunAccess() {
|
|
6
|
+
const { access } = useJunOptions();
|
|
7
|
+
const abra = useAbracadabra();
|
|
8
|
+
const serverGated = useState("jun-gated", () => {
|
|
9
|
+
if (!import.meta.server) return false;
|
|
10
|
+
const event = useRequestEvent();
|
|
11
|
+
return event?.context?.junGated === true;
|
|
12
|
+
});
|
|
13
|
+
const isPrivate = computed(() => access.mode === "private");
|
|
14
|
+
const admitted = computed(() => abra.synced.value === true);
|
|
15
|
+
const gated = computed(() => isPrivate.value && serverGated.value && !admitted.value);
|
|
16
|
+
return {
|
|
17
|
+
mode: computed(() => access.mode),
|
|
18
|
+
isPrivate,
|
|
19
|
+
discovery: computed(() => access.discovery),
|
|
20
|
+
gate: computed(() => access.gate),
|
|
21
|
+
serverGated,
|
|
22
|
+
admitted,
|
|
23
|
+
gated
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useJunAccessAdmin — the owner's view of who may do what, and the controls
|
|
3
|
+
* that change it.
|
|
4
|
+
*
|
|
5
|
+
* ## The gap this fills
|
|
6
|
+
*
|
|
7
|
+
* Every permission in this system is real, enforced and server-side, and until
|
|
8
|
+
* now none of it was VISIBLE. An owner could see who happened to be standing at
|
|
9
|
+
* the campfire (and change that person's role from the roster menu, if the
|
|
10
|
+
* campfire was even switched on), and that was the entire permission surface of
|
|
11
|
+
* a website whose whole premise is a shared document tree. Everything else —
|
|
12
|
+
* what a stranger may read, whether registration is open, who holds a grant on
|
|
13
|
+
* the site, how somebody is invited to a private one, whether THIS page is
|
|
14
|
+
* public — was a config file on a server, or a SQL statement.
|
|
15
|
+
*
|
|
16
|
+
* So this reads the four things that decide it and offers the three an owner
|
|
17
|
+
* may change from a browser:
|
|
18
|
+
*
|
|
19
|
+
* - `[access]` and `[users]`, from the backend's own `/info` — read only, and
|
|
20
|
+
* deliberately: the server-wide floor is an operator's decision, and a
|
|
21
|
+
* settings panel that pretended to move it would be lying.
|
|
22
|
+
* - **grants on the space root**, over `/docs/:id/permissions` — the roster
|
|
23
|
+
* without the presence requirement.
|
|
24
|
+
* - **invites**, over `/invites` — how a private site gains a member without
|
|
25
|
+
* a shell.
|
|
26
|
+
* - **this document's `public_access`**, over `/docs/:id/access` — the one
|
|
27
|
+
* per-page control, including `private`, which seals a subtree on a server
|
|
28
|
+
* whose floor would otherwise publish it.
|
|
29
|
+
*
|
|
30
|
+
* ## Every button here is convenience; the server is the gate
|
|
31
|
+
*
|
|
32
|
+
* `canAdmin` hides controls a visitor's call would be refused anyway. It is not
|
|
33
|
+
* a check. Each write reads back what the server STORED rather than assuming
|
|
34
|
+
* the request landed — the same rule `useJunPeopleAdmin` follows, and for the
|
|
35
|
+
* same reason: a grant keyed on a device key that the account never presents is
|
|
36
|
+
* accepted, stored, and does nothing.
|
|
37
|
+
*/
|
|
38
|
+
import { type ComputedRef, type Ref } from 'vue';
|
|
39
|
+
/** What the backend says about itself. Read-only — an operator's decisions. */
|
|
40
|
+
export interface JunServerAccess {
|
|
41
|
+
/** Strongest role an anonymous request may hold. `none` rejects them outright. */
|
|
42
|
+
anonymous: string;
|
|
43
|
+
/** Role an authenticated principal falls back to with no explicit grant. */
|
|
44
|
+
authenticated: string;
|
|
45
|
+
/** Whether the SDK can mint a soft identity for a passer-by. */
|
|
46
|
+
registrationOpen: boolean | null;
|
|
47
|
+
/** Registration is open, but only against a code. The private site's shape. */
|
|
48
|
+
inviteOnly: boolean | null;
|
|
49
|
+
serverName: string;
|
|
50
|
+
serverVersion: string;
|
|
51
|
+
}
|
|
52
|
+
export interface JunInvite {
|
|
53
|
+
code: string;
|
|
54
|
+
role: string;
|
|
55
|
+
maxUses: number;
|
|
56
|
+
useCount: number;
|
|
57
|
+
expiresAt: number | null;
|
|
58
|
+
revoked: boolean;
|
|
59
|
+
createdAt: number;
|
|
60
|
+
}
|
|
61
|
+
/** `public_access` on one document. `null` means "inherit from the ancestor chain". */
|
|
62
|
+
export type JunDocAccess = 'none' | 'private' | 'observer' | 'viewer' | 'editor' | null;
|
|
63
|
+
export declare const JUN_DOC_ACCESS_CHOICES: {
|
|
64
|
+
value: Exclude<JunDocAccess, null> | 'inherit';
|
|
65
|
+
label: string;
|
|
66
|
+
hint: string;
|
|
67
|
+
}[];
|
|
68
|
+
export declare function useJunAccessAdmin(): {
|
|
69
|
+
canAdmin: ComputedRef<boolean>;
|
|
70
|
+
server: Ref<JunServerAccess | null>;
|
|
71
|
+
invites: Ref<JunInvite[]>;
|
|
72
|
+
/** True once an invite read has completed — "none" and "not looked" differ. */
|
|
73
|
+
invitesLoaded: Ref<boolean>;
|
|
74
|
+
/** The last error worth showing beside a control, in plain words. */
|
|
75
|
+
error: Ref<string>;
|
|
76
|
+
busy: Ref<string>;
|
|
77
|
+
refreshServer: () => Promise<void>;
|
|
78
|
+
refreshInvites: () => Promise<void>;
|
|
79
|
+
createInvite: (opts?: {
|
|
80
|
+
role?: string;
|
|
81
|
+
maxUses?: number;
|
|
82
|
+
expiresIn?: number;
|
|
83
|
+
}) => Promise<string>;
|
|
84
|
+
revokeInvite: (code: string) => Promise<void>;
|
|
85
|
+
docAccess: (docId: string) => Promise<{
|
|
86
|
+
own: JunDocAccess;
|
|
87
|
+
effective: JunDocAccess;
|
|
88
|
+
}>;
|
|
89
|
+
setDocAccess: (docId: string, value: JunDocAccess) => Promise<void>;
|
|
90
|
+
};
|