@abraca/junis 2.99.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useRuntimeConfig } from "nitropack/runtime";
|
|
2
2
|
import { junDocHtml, junDocTree, junRootDocId, junSlugMap } from "./junCache.js";
|
|
3
|
-
import {
|
|
3
|
+
import { isJunWithheldDoc } from "./junVisibility.js";
|
|
4
4
|
const FEED_LIMIT = 50;
|
|
5
5
|
function toMs(v) {
|
|
6
6
|
if (typeof v === "number" && Number.isFinite(v)) return v;
|
|
@@ -40,7 +40,7 @@ export async function junFeedItems() {
|
|
|
40
40
|
if (!entry.parentId || !parents.has(entry.parentId)) continue;
|
|
41
41
|
const meta = entry.meta ?? {};
|
|
42
42
|
if (meta.draft === true || meta.hidden === true || meta.seedTest === true) continue;
|
|
43
|
-
if (
|
|
43
|
+
if (isJunWithheldDoc(entry)) continue;
|
|
44
44
|
if (!slugs[id]) continue;
|
|
45
45
|
const ms = toMs(meta.date) || toMs(entry.updatedAt);
|
|
46
46
|
if (!ms) continue;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { junDocTree, junRootDocId, junSlugMap } from "./junCache.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isJunWithheldDoc } from "./junVisibility.js";
|
|
3
3
|
const MAX_DEPTH = 32;
|
|
4
4
|
export function junIsPublicPage(entry) {
|
|
5
5
|
if (!entry || entry.trashed) return false;
|
|
6
|
-
if (
|
|
6
|
+
if (isJunWithheldDoc(entry)) return false;
|
|
7
7
|
if (entry.meta?.draft === true) return false;
|
|
8
8
|
if (entry.meta?.signerId) return false;
|
|
9
9
|
if ((entry.type ?? "").endsWith("-redirect")) return false;
|
|
@@ -29,3 +29,43 @@ export interface JunVisibilityEntry {
|
|
|
29
29
|
}
|
|
30
30
|
/** True for documents only the signed-in owner may see. */
|
|
31
31
|
export declare function isJunOwnerOnlyDoc(entry: JunVisibilityEntry | undefined | null): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* A document the owner sealed with `public_access = "private"`.
|
|
34
|
+
*
|
|
35
|
+
* ## Why a mirror on the tree entry exists at all
|
|
36
|
+
*
|
|
37
|
+
* `public_access` is SERVER state — a column on the document row, resolved by
|
|
38
|
+
* the backend's permission cascade — and nothing in the CRDT tree knows about
|
|
39
|
+
* it. The Nitro doc cache is filled by a SERVICE-ROLE runner, which reads every
|
|
40
|
+
* document regardless, so a page sealed on the server was still served to every
|
|
41
|
+
* visitor by SSR, by search, by the sitemap and by both feeds while the
|
|
42
|
+
* WebSocket correctly refused it.
|
|
43
|
+
*
|
|
44
|
+
* So `useJunAccessAdmin.setDocAccess` writes `meta.junPrivate` on the tree
|
|
45
|
+
* entry in the same breath as the REST call, **after reading the server's
|
|
46
|
+
* answer back**. The server stays the authority; this flag is a one-way cache
|
|
47
|
+
* of its answer, exactly like the space label's mirror. A stale `true` withholds
|
|
48
|
+
* a page that is actually public (recoverable, and visible to the owner); a
|
|
49
|
+
* stale `false` cannot outlive the read-back.
|
|
50
|
+
*
|
|
51
|
+
* ## What it does NOT mean
|
|
52
|
+
*
|
|
53
|
+
* It is not per-reader. One service-role cache cannot be rendered differently
|
|
54
|
+
* for each visitor, so a sealed page is withheld from the SHARED surfaces
|
|
55
|
+
* altogether — and the people who legitimately hold a grant on it read it the
|
|
56
|
+
* same way its owner does: live, over their own socket, which is where the
|
|
57
|
+
* backend's answer applies.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isJunPrivateDoc(entry: JunVisibilityEntry | undefined | null): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Everything the site's SHARED, service-role-filled caches must not publish.
|
|
62
|
+
*
|
|
63
|
+
* Two quite different reasons, one consequence. `ownerOnly` is infrastructure —
|
|
64
|
+
* the settings, the janitor's notebook, the campfire's channel — and belongs to
|
|
65
|
+
* nobody but the owner. `junPrivate` is a page somebody sealed deliberately.
|
|
66
|
+
* Neither may reach the search index, the sitemap, the feeds, the link cards,
|
|
67
|
+
* the offline manifest or the SSR payload, and every one of those surfaces
|
|
68
|
+
* should ask THIS rather than either half: a surface that filtered on only one
|
|
69
|
+
* of them was how each of these leaked in the first place.
|
|
70
|
+
*/
|
|
71
|
+
export declare function isJunWithheldDoc(entry: JunVisibilityEntry | undefined | null): boolean;
|
|
@@ -6,3 +6,9 @@ export function isJunOwnerOnlyDoc(entry) {
|
|
|
6
6
|
if (entry.meta?.janitorBaseline === true) return true;
|
|
7
7
|
return entry.meta?.campfire === true;
|
|
8
8
|
}
|
|
9
|
+
export function isJunPrivateDoc(entry) {
|
|
10
|
+
return entry?.meta?.junPrivate === true;
|
|
11
|
+
}
|
|
12
|
+
export function isJunWithheldDoc(entry) {
|
|
13
|
+
return isJunOwnerOnlyDoc(entry) || isJunPrivateDoc(entry);
|
|
14
|
+
}
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* `useJunLayoutPolicy`) read the resolved copy back out of
|
|
8
8
|
* `runtimeConfig.public.jun`. One definition, no drift.
|
|
9
9
|
*/
|
|
10
|
+
import type { JunAccessRuntime } from './utils/junAccess.js';
|
|
11
|
+
export type { JunAccessGateCopy, JunAccessMode, JunAccessOptions, JunAccessRuntime } from './utils/junAccess.js';
|
|
10
12
|
/**
|
|
11
13
|
* The website's page-type vocabulary. Each key registers a `jun-<key>` page
|
|
12
14
|
* type with the Abracadabra registry and mounts its renderer.
|
|
@@ -1187,6 +1189,13 @@ export interface JunRuntimeOptions {
|
|
|
1187
1189
|
schemaType: JunBrand['schemaType'];
|
|
1188
1190
|
};
|
|
1189
1191
|
features: Required<JunFeatures>;
|
|
1192
|
+
/**
|
|
1193
|
+
* The site's access shape — `open` / `public` / `private`, plus what follows
|
|
1194
|
+
* from it. Read by the layout, the gate, the settings panel and every server
|
|
1195
|
+
* surface that has to know whether this site is meant to be readable by a
|
|
1196
|
+
* stranger. See `runtime/utils/junAccess.ts`.
|
|
1197
|
+
*/
|
|
1198
|
+
access: JunAccessRuntime;
|
|
1190
1199
|
layout: Required<JunLayoutPolicy>;
|
|
1191
1200
|
siteConfigDefaults: JunSiteConfigDefaults;
|
|
1192
1201
|
guestNames: Required<JunGuestNames>;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The site's ACCESS SHAPE — the one thing a jun-is deployment has to decide
|
|
3
|
+
* before anything else, and the one thing the module never used to ask.
|
|
4
|
+
*
|
|
5
|
+
* Three shapes, and the module can build all three. Only one of them was ever
|
|
6
|
+
* shipped as something you can run, which is why the other two each had a hole
|
|
7
|
+
* in them nobody could see.
|
|
8
|
+
*
|
|
9
|
+
* - **`open`** — everyone reads, everyone writes. The demo: `public_access =
|
|
10
|
+
* "editor"` on the space and `features.openEditing` on. Handing the studio
|
|
11
|
+
* to whoever turns up is the entire point.
|
|
12
|
+
* - **`public`** — everyone reads, the OWNER writes. The ordinary website.
|
|
13
|
+
* Visitors are soft identities pinned to `viewer`; everything they
|
|
14
|
+
* contribute goes through the RPC v1 runner. This is the default, because a
|
|
15
|
+
* site that has not said what it is should not be an open demo.
|
|
16
|
+
* - **`private`** — MEMBERS read, members write per their grant. Registration
|
|
17
|
+
* is invite-only or closed, so there is no soft identity to be had, and a
|
|
18
|
+
* stranger has no way in at all.
|
|
19
|
+
*
|
|
20
|
+
* ## Why a mode exists at all, when every flag already did
|
|
21
|
+
*
|
|
22
|
+
* Because `private` is not a flag. It is a claim about the whole surface of the
|
|
23
|
+
* site, and the module's public surfaces are fed by a SERVICE-ROLE runner that
|
|
24
|
+
* can read everything — so on a "private" deployment the CRDT socket refused a
|
|
25
|
+
* stranger while `<apiBase>/tree`, `<apiBase>/search`, `<apiBase>/resolve/**`,
|
|
26
|
+
* the feeds, the sitemap and the SSR payload all handed them the site anyway.
|
|
27
|
+
* Every one of those is a separate file with no idea what kind of site it is
|
|
28
|
+
* part of. This is where they find out.
|
|
29
|
+
*
|
|
30
|
+
* ## The rule the derivation follows
|
|
31
|
+
*
|
|
32
|
+
* A mode contributes DEFAULTS. It never overrules a value the site stated —
|
|
33
|
+
* `resolveJunAccess` takes the site's own `features` block and only fills what
|
|
34
|
+
* is `undefined`. A mode that silently overrode a stated flag would be worse
|
|
35
|
+
* than no mode: the flag is right there in the config, and it would be lying.
|
|
36
|
+
*
|
|
37
|
+
* Pure, and importable from both bundles (Nitro server utils and the app's
|
|
38
|
+
* auto-imports are separate graphs — this file lives in `runtime/utils`, which
|
|
39
|
+
* `addImportsDir` and `addServerImportsDir` both take).
|
|
40
|
+
*/
|
|
41
|
+
/** The three shapes. See the header. */
|
|
42
|
+
export type JunAccessMode = 'open' | 'public' | 'private';
|
|
43
|
+
export declare const JUN_ACCESS_MODES: JunAccessMode[];
|
|
44
|
+
/**
|
|
45
|
+
* The name of the cookie the client mirrors its backend JWT into.
|
|
46
|
+
*
|
|
47
|
+
* A private site has to be able to answer a NAVIGATION, and a navigation
|
|
48
|
+
* carries cookies and nothing else — the token the SDK holds lives in
|
|
49
|
+
* `localStorage`, where SSR cannot reach it. Without this mirror the only
|
|
50
|
+
* honest private mode would be one that server-renders nothing at all.
|
|
51
|
+
*
|
|
52
|
+
* It is not a credential the module mints: it is the same JWT the browser
|
|
53
|
+
* already presents to the backend on its own socket, copied where the server
|
|
54
|
+
* can see it. `SameSite=Lax`, `Secure` on https, and NOT `HttpOnly` — the
|
|
55
|
+
* client writes it, so it could not be.
|
|
56
|
+
*/
|
|
57
|
+
export declare const JUN_SESSION_COOKIE = "jun_session";
|
|
58
|
+
/**
|
|
59
|
+
* Paths that stay reachable on a private site, always.
|
|
60
|
+
*
|
|
61
|
+
* The health endpoint is how a container proves it is alive and how
|
|
62
|
+
* `pnpm deploy:check` proves an image is the code you are looking at — gating
|
|
63
|
+
* it would make a private deployment undiagnosable from outside. Everything
|
|
64
|
+
* else here is what a browser needs before it has a session at all: the app's
|
|
65
|
+
* own assets, its icons, and the manifest that names them.
|
|
66
|
+
*/
|
|
67
|
+
export declare const JUN_PRIVATE_PUBLIC_PATHS: string[];
|
|
68
|
+
/** The sign-in screen's copy. Every field has a default; a site may restate any. */
|
|
69
|
+
export interface JunAccessGateCopy {
|
|
70
|
+
/** The line above the form. */
|
|
71
|
+
headline?: string;
|
|
72
|
+
/** One sentence under it. Say who the site is for, not how to log in. */
|
|
73
|
+
blurb?: string;
|
|
74
|
+
/** Offer an invite-code field beside the password form. */
|
|
75
|
+
invites?: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface JunAccessOptions {
|
|
78
|
+
/** Which of the three shapes this site is. See the module header. */
|
|
79
|
+
mode?: JunAccessMode;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the site advertises itself: feeds, sitemap, link-preview cards and
|
|
82
|
+
* an indexable `robots.txt`.
|
|
83
|
+
*
|
|
84
|
+
* Derived from the mode (`private` → off) and overridable, because the two
|
|
85
|
+
* are genuinely separable: a public site may want no feeds, and a members-only
|
|
86
|
+
* site on a private network may legitimately want a sitemap for its own search.
|
|
87
|
+
*/
|
|
88
|
+
discovery?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* `private` only. How long a verified token stays verified, in seconds.
|
|
91
|
+
*
|
|
92
|
+
* Every gated request would otherwise cost a round trip to the backend. The
|
|
93
|
+
* cost of the cache is that a REVOKED member keeps the site for up to this
|
|
94
|
+
* long — their CRDT socket drops immediately, so what they keep is the
|
|
95
|
+
* cached HTML, not live content. 60s is a reasonable trade; 0 disables it.
|
|
96
|
+
*/
|
|
97
|
+
sessionTtlS?: number;
|
|
98
|
+
/**
|
|
99
|
+
* `private` only. Extra paths the gate never asks about, on top of
|
|
100
|
+
* `JUN_PRIVATE_PUBLIC_PATHS`. Glob-ish: a trailing `/**` matches a prefix.
|
|
101
|
+
*/
|
|
102
|
+
publicPaths?: string[];
|
|
103
|
+
/** `private` only. The sign-in screen. */
|
|
104
|
+
gate?: JunAccessGateCopy;
|
|
105
|
+
}
|
|
106
|
+
/** The resolved block, as it reaches `runtimeConfig.public.jun.access`. */
|
|
107
|
+
export interface JunAccessRuntime {
|
|
108
|
+
mode: JunAccessMode;
|
|
109
|
+
discovery: boolean;
|
|
110
|
+
sessionTtlS: number;
|
|
111
|
+
publicPaths: string[];
|
|
112
|
+
gate: Required<JunAccessGateCopy>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The feature defaults a mode contributes.
|
|
116
|
+
*
|
|
117
|
+
* Only keys a mode has an OPINION about appear here. Everything else is the
|
|
118
|
+
* module's own default and stays that way — a mode is a statement about access,
|
|
119
|
+
* not a theme.
|
|
120
|
+
*/
|
|
121
|
+
export interface JunAccessFeatureDefaults {
|
|
122
|
+
openEditing?: boolean;
|
|
123
|
+
feeds?: boolean;
|
|
124
|
+
sitemap?: boolean;
|
|
125
|
+
socialCards?: boolean;
|
|
126
|
+
}
|
|
127
|
+
/** Resolve the site's access block. Pure — the module calls it at setup. */
|
|
128
|
+
export declare function resolveJunAccess(options?: JunAccessOptions): JunAccessRuntime;
|
|
129
|
+
/**
|
|
130
|
+
* What the mode contributes to `features`, for the module to fill UNDER the
|
|
131
|
+
* site's own block.
|
|
132
|
+
*
|
|
133
|
+
* `openEditing` is the one that has to be stated in both directions. It is the
|
|
134
|
+
* flag whose failure mode is silent and public, so `public`/`private` do not
|
|
135
|
+
* merely decline to turn it on — they say `false`, and a site that genuinely
|
|
136
|
+
* wants an open editor on a public site has to say so on the same line where it
|
|
137
|
+
* says the site is public.
|
|
138
|
+
*/
|
|
139
|
+
export declare function junAccessFeatureDefaults(access: JunAccessRuntime): JunAccessFeatureDefaults;
|
|
140
|
+
/**
|
|
141
|
+
* Does this path bypass the gate?
|
|
142
|
+
*
|
|
143
|
+
* Deliberately tiny: a prefix match for a trailing `/**`, an exact match
|
|
144
|
+
* otherwise. A real glob engine here would be a dependency and a surface, and
|
|
145
|
+
* the list it matches against is written in this file.
|
|
146
|
+
*/
|
|
147
|
+
export declare function junPathIsPublic(path: string, publicPaths: string[]): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* How a gated request should be REFUSED — and the distinction is the whole
|
|
150
|
+
* design of the private gate.
|
|
151
|
+
*
|
|
152
|
+
* A fetch gets `401`, because a fetch has a caller who can read a status code.
|
|
153
|
+
* A NAVIGATION gets the app, with no document payload in it: the browser holds
|
|
154
|
+
* the session the server could not see (a first visit, a cleared cookie, a
|
|
155
|
+
* different device), and the client can sign in and take over. Answering a
|
|
156
|
+
* navigation with 401 would strand a member who is perfectly entitled to the
|
|
157
|
+
* page on a browser error screen.
|
|
158
|
+
*/
|
|
159
|
+
export type JunGateRefusal = 'unauthorized' | 'gate';
|
|
160
|
+
export declare function junRefusalFor(path: string, accept: string | undefined, apiBase: string): JunGateRefusal;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export const JUN_ACCESS_MODES = ["open", "public", "private"];
|
|
2
|
+
export const JUN_SESSION_COOKIE = "jun_session";
|
|
3
|
+
export const JUN_PRIVATE_PUBLIC_PATHS = [
|
|
4
|
+
"/_nuxt/**",
|
|
5
|
+
"/_fonts/**",
|
|
6
|
+
"/_ipx/**",
|
|
7
|
+
"/favicon.ico",
|
|
8
|
+
"/robots.txt",
|
|
9
|
+
"/jun-icon.png",
|
|
10
|
+
"/jun-icon.svg",
|
|
11
|
+
"/jun-splash.png",
|
|
12
|
+
"/apple-touch-icon.png",
|
|
13
|
+
"/apple-touch-icon-precomposed.png",
|
|
14
|
+
"/manifest.webmanifest",
|
|
15
|
+
"/jun-sw.js"
|
|
16
|
+
];
|
|
17
|
+
const GATE_DEFAULTS = {
|
|
18
|
+
headline: "This site is private",
|
|
19
|
+
blurb: "Sign in to read it.",
|
|
20
|
+
invites: true
|
|
21
|
+
};
|
|
22
|
+
export function resolveJunAccess(options) {
|
|
23
|
+
const mode = JUN_ACCESS_MODES.includes(options?.mode) ? options.mode : "public";
|
|
24
|
+
return {
|
|
25
|
+
mode,
|
|
26
|
+
// A private site does not syndicate. Stated wins, in both directions.
|
|
27
|
+
discovery: options?.discovery ?? mode !== "private",
|
|
28
|
+
sessionTtlS: Math.max(0, options?.sessionTtlS ?? 60),
|
|
29
|
+
publicPaths: [...JUN_PRIVATE_PUBLIC_PATHS, ...options?.publicPaths ?? []],
|
|
30
|
+
gate: { ...GATE_DEFAULTS, ...options?.gate ?? {} }
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function junAccessFeatureDefaults(access) {
|
|
34
|
+
switch (access.mode) {
|
|
35
|
+
case "open":
|
|
36
|
+
return { openEditing: true };
|
|
37
|
+
case "private":
|
|
38
|
+
return {
|
|
39
|
+
openEditing: false,
|
|
40
|
+
feeds: access.discovery,
|
|
41
|
+
sitemap: access.discovery,
|
|
42
|
+
socialCards: access.discovery
|
|
43
|
+
};
|
|
44
|
+
default:
|
|
45
|
+
return { openEditing: false };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function junPathIsPublic(path, publicPaths) {
|
|
49
|
+
const clean = (path.split("?")[0] ?? path).replace(/\/+$/, "") || "/";
|
|
50
|
+
for (const pattern of publicPaths) {
|
|
51
|
+
if (pattern.endsWith("/**")) {
|
|
52
|
+
const prefix = pattern.slice(0, -3);
|
|
53
|
+
if (clean === prefix || clean.startsWith(`${prefix}/`)) return true;
|
|
54
|
+
} else if (clean === pattern.replace(/\/+$/, "") || clean === pattern) return true;
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
export function junRefusalFor(path, accept, apiBase) {
|
|
59
|
+
if (path === apiBase || path.startsWith(`${apiBase}/`)) return "unauthorized";
|
|
60
|
+
if (accept && !accept.includes("text/html")) return "unauthorized";
|
|
61
|
+
return "gate";
|
|
62
|
+
}
|
|
@@ -12,3 +12,43 @@ export interface JunVisibilityEntry {
|
|
|
12
12
|
}
|
|
13
13
|
/** True for documents only the signed-in owner may see. */
|
|
14
14
|
export declare function isJunOwnerOnlyDoc(entry: JunVisibilityEntry | undefined | null): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* A document the owner sealed with `public_access = "private"`.
|
|
17
|
+
*
|
|
18
|
+
* ## Why a mirror on the tree entry exists at all
|
|
19
|
+
*
|
|
20
|
+
* `public_access` is SERVER state — a column on the document row, resolved by
|
|
21
|
+
* the backend's permission cascade — and nothing in the CRDT tree knows about
|
|
22
|
+
* it. The Nitro doc cache is filled by a SERVICE-ROLE runner, which reads every
|
|
23
|
+
* document regardless, so a page sealed on the server was still served to every
|
|
24
|
+
* visitor by SSR, by search, by the sitemap and by both feeds while the
|
|
25
|
+
* WebSocket correctly refused it.
|
|
26
|
+
*
|
|
27
|
+
* So `useJunAccessAdmin.setDocAccess` writes `meta.junPrivate` on the tree
|
|
28
|
+
* entry in the same breath as the REST call, **after reading the server's
|
|
29
|
+
* answer back**. The server stays the authority; this flag is a one-way cache
|
|
30
|
+
* of its answer, exactly like the space label's mirror. A stale `true` withholds
|
|
31
|
+
* a page that is actually public (recoverable, and visible to the owner); a
|
|
32
|
+
* stale `false` cannot outlive the read-back.
|
|
33
|
+
*
|
|
34
|
+
* ## What it does NOT mean
|
|
35
|
+
*
|
|
36
|
+
* It is not per-reader. One service-role cache cannot be rendered differently
|
|
37
|
+
* for each visitor, so a sealed page is withheld from the SHARED surfaces
|
|
38
|
+
* altogether — and the people who legitimately hold a grant on it read it the
|
|
39
|
+
* same way its owner does: live, over their own socket, which is where the
|
|
40
|
+
* backend's answer applies.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isJunPrivateDoc(entry: JunVisibilityEntry | undefined | null): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Everything the site's SHARED, service-role-filled caches must not publish.
|
|
45
|
+
*
|
|
46
|
+
* Two quite different reasons, one consequence. `ownerOnly` is infrastructure —
|
|
47
|
+
* the settings, the janitor's notebook, the campfire's channel — and belongs to
|
|
48
|
+
* nobody but the owner. `junPrivate` is a page somebody sealed deliberately.
|
|
49
|
+
* Neither may reach the search index, the sitemap, the feeds, the link cards,
|
|
50
|
+
* the offline manifest or the SSR payload, and every one of those surfaces
|
|
51
|
+
* should ask THIS rather than either half: a surface that filtered on only one
|
|
52
|
+
* of them was how each of these leaked in the first place.
|
|
53
|
+
*/
|
|
54
|
+
export declare function isJunWithheldDoc(entry: JunVisibilityEntry | undefined | null): boolean;
|
|
@@ -6,3 +6,9 @@ export function isJunOwnerOnlyDoc(entry) {
|
|
|
6
6
|
if (entry.meta?.janitorBaseline === true) return true;
|
|
7
7
|
return entry.meta?.campfire === true;
|
|
8
8
|
}
|
|
9
|
+
export function isJunPrivateDoc(entry) {
|
|
10
|
+
return entry?.meta?.junPrivate === true;
|
|
11
|
+
}
|
|
12
|
+
export function isJunWithheldDoc(entry) {
|
|
13
|
+
return isJunOwnerOnlyDoc(entry) || isJunPrivateDoc(entry);
|
|
14
|
+
}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type JunBackdropKind, type JunBrand, type JunCampfireOptions, type JunCampfirePillMode, type JunCampfirePlacement, type JunCampfireRosterStyle, type JunCampfireSize, type JunCampfireTab, type JunContextMenuOptions, type JunEmbedOptions, type JunFeatures, type JunGuestNames, type JunJanitorBaselineMode, type JunJanitorIdentity, type JunJanitorIdentityMode, type JunJanitorMode, type JunJanitorOptions, type JunJsonLdSpec, type JunLayoutPolicy, type JunMosaicOptions, type JunNavActiveStyle, type JunNavItemMode, type JunNavPlacement, type JunNavShape, type JunNavSize, type JunNavigationOptions, type JunOfflineOptions, type JunPageTypeKey, type JunPageTypeOverride, type JunPageTypesOption, type JunPalette, type JunPaletteSet, type JunPrefetchPolicy, type JunRendererDefaults, type JunRuntimeOptions, type JunSeedNode, type JunSeedOptions, type JunServicesOptions, type JunSiteConfigDefaults } from '../dist/runtime/types.js'
|
|
1
|
+
export { type JunAccessGateCopy, type JunAccessMode, type JunAccessOptions, type JunAccessRuntime, type JunBackdropKind, type JunBrand, type JunCampfireOptions, type JunCampfirePillMode, type JunCampfirePlacement, type JunCampfireRosterStyle, type JunCampfireSize, type JunCampfireTab, type JunContextMenuOptions, type JunEmbedOptions, type JunFeatures, type JunGuestNames, type JunJanitorBaselineMode, type JunJanitorIdentity, type JunJanitorIdentityMode, type JunJanitorMode, type JunJanitorOptions, type JunJsonLdSpec, type JunLayoutPolicy, type JunMosaicOptions, type JunNavActiveStyle, type JunNavItemMode, type JunNavPlacement, type JunNavShape, type JunNavSize, type JunNavigationOptions, type JunOfflineOptions, type JunPageTypeKey, type JunPageTypeOverride, type JunPageTypesOption, type JunPalette, type JunPaletteSet, type JunPrefetchPolicy, type JunRendererDefaults, type JunRuntimeOptions, type JunSeedNode, type JunSeedOptions, type JunServicesOptions, type JunSiteConfigDefaults } from '../dist/runtime/types.js'
|
|
2
2
|
|
|
3
3
|
export { default } from './module.mjs'
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abraca/junis",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.101.0",
|
|
4
4
|
"description": "Website-builder Nuxt module for the Abracadabra CRDT platform — page-type renderers, presence chrome, studio editing and SSR, all driven by documents",
|
|
5
5
|
"repository": "abracadabra/jun-is",
|
|
6
6
|
"license": "MIT",
|
|
@@ -92,10 +92,14 @@
|
|
|
92
92
|
},
|
|
93
93
|
"scripts": {
|
|
94
94
|
"dev": "npm run dev:prepare && node scripts/dev.mjs",
|
|
95
|
+
"dev:atelier": "node scripts/dev.mjs atelier",
|
|
96
|
+
"dev:kammer": "node scripts/dev.mjs kammer",
|
|
95
97
|
"dev:backend": "node scripts/dev-backend.mjs",
|
|
96
98
|
"dev:nuxt": "nuxt dev playground --port 3003",
|
|
99
|
+
"dev:nuxt:atelier": "nuxt dev examples/atelier --port 3004",
|
|
100
|
+
"dev:nuxt:kammer": "nuxt dev examples/kammer --port 3005",
|
|
97
101
|
"dev:build": "nuxt build playground",
|
|
98
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
102
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground && nuxt prepare examples/atelier && nuxt prepare examples/kammer",
|
|
99
103
|
"dev:clean": "node scripts/dev-clean.mjs",
|
|
100
104
|
"lint": "eslint .",
|
|
101
105
|
"janitor:watch": "node scripts/janitor-watch.mjs",
|
|
@@ -109,9 +113,10 @@
|
|
|
109
113
|
"parity:mobile": "node scripts/parity-mobile.mjs",
|
|
110
114
|
"parity:offline": "node scripts/parity-offline.mjs",
|
|
111
115
|
"parity:weight": "node scripts/parity-weight.mjs",
|
|
116
|
+
"parity:access": "node scripts/parity-access.mjs",
|
|
112
117
|
"deploy:check": "node scripts/deploy-check.mjs",
|
|
113
118
|
"pins:check": "node scripts/pins-check.mjs",
|
|
114
|
-
"typecheck": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
119
|
+
"typecheck": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit && cd ../examples/atelier && vue-tsc --noEmit && cd ../kammer && vue-tsc --noEmit",
|
|
115
120
|
"release": "npm run lint && npm run deps:check && npm run pins:check && npm run prepack",
|
|
116
121
|
"docker:up": "docker compose up -d --build",
|
|
117
122
|
"docker:down": "docker compose down",
|