@aglyn/aglyn 1.25.0 → 1.26.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.
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * The cookie names behind "Show to" signed-in or signed-out visitors
19
+ * (AGL-4231), and the repair the tenant middleware makes on every page
20
+ * request. No imports, so the middleware can take it whole.
21
+ *
22
+ * The hint is written when a visitor signs in. A visitor who signed in BEFORE
23
+ * the hint existed, or whose hint went missing, still holds a member session
24
+ * and would see "Sign in" on every page. And a hint can outlive its session
25
+ * (the session expired or was cleared by something other than sign-out). So
26
+ * the middleware, which sees every page request before the cached page, keeps
27
+ * the two in step: a session with no hint gets one, a hint with no session
28
+ * loses it. The page's inline script then reads the corrected cookie, because
29
+ * a browser applies a response's cookies before it runs the page's scripts.
30
+ *
31
+ * Presence of the session cookie is enough here: the hint only decides what
32
+ * shows. Whether the session is valid is checked by every endpoint that acts
33
+ * on it, exactly as before.
34
+ */
35
+ /** The member session cookie's name prefix; the site's id follows. HttpOnly. */
36
+ export declare const MEMBER_SESSION_COOKIE_PREFIX = "aglyn_member_";
37
+ /** The readable sign-in hint's name prefix; the site's id follows, as the session's does. */
38
+ export declare const SIGNED_IN_HINT_COOKIE_PREFIX = "aglyn_signed_in_";
39
+ /** How long a hint the middleware writes lasts: a session's own lifetime. */
40
+ export declare const SIGNED_IN_HINT_MAX_AGE_SECONDS: number;
41
+ /** The suffix both cookies share for one site. */
42
+ export declare function siteCookieSuffix(hostId: string): string;
43
+ /** The member session cookie for one site. */
44
+ export declare function memberSessionCookieName(hostId: string): string;
45
+ /** The readable "signed in" hint cookie for one site. */
46
+ export declare function signedInHintCookieName(hostId: string): string;
47
+ /**
48
+ * The hint cookies to write (`set`) and to clear (`clear`) so that each site's
49
+ * hint matches whether the request carries that site's member session.
50
+ * Empty lists for the overwhelmingly common request: no session and no hint.
51
+ */
52
+ export declare function signedInHintCorrections(cookies: Iterable<{
53
+ name: string;
54
+ value: string;
55
+ }>): {
56
+ set: string[];
57
+ clear: string[];
58
+ };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /**
17
+ * The cookie names behind "Show to" signed-in or signed-out visitors
18
+ * (AGL-4231), and the repair the tenant middleware makes on every page
19
+ * request. No imports, so the middleware can take it whole.
20
+ *
21
+ * The hint is written when a visitor signs in. A visitor who signed in BEFORE
22
+ * the hint existed, or whose hint went missing, still holds a member session
23
+ * and would see "Sign in" on every page. And a hint can outlive its session
24
+ * (the session expired or was cleared by something other than sign-out). So
25
+ * the middleware, which sees every page request before the cached page, keeps
26
+ * the two in step: a session with no hint gets one, a hint with no session
27
+ * loses it. The page's inline script then reads the corrected cookie, because
28
+ * a browser applies a response's cookies before it runs the page's scripts.
29
+ *
30
+ * Presence of the session cookie is enough here: the hint only decides what
31
+ * shows. Whether the session is valid is checked by every endpoint that acts
32
+ * on it, exactly as before.
33
+ */ /** The member session cookie's name prefix; the site's id follows. HttpOnly. */ export const MEMBER_SESSION_COOKIE_PREFIX = 'aglyn_member_';
34
+ /** The readable sign-in hint's name prefix; the site's id follows, as the session's does. */ export const SIGNED_IN_HINT_COOKIE_PREFIX = 'aglyn_signed_in_';
35
+ /** How long a hint the middleware writes lasts: a session's own lifetime. */ export const SIGNED_IN_HINT_MAX_AGE_SECONDS = 30 * 24 * 60 * 60;
36
+ /** The suffix both cookies share for one site. */ export function siteCookieSuffix(hostId) {
37
+ return hostId.replace(/[^A-Za-z0-9_-]/g, '');
38
+ }
39
+ /** The member session cookie for one site. */ export function memberSessionCookieName(hostId) {
40
+ return `${MEMBER_SESSION_COOKIE_PREFIX}${siteCookieSuffix(hostId)}`;
41
+ }
42
+ /** The readable "signed in" hint cookie for one site. */ export function signedInHintCookieName(hostId) {
43
+ return `${SIGNED_IN_HINT_COOKIE_PREFIX}${siteCookieSuffix(hostId)}`;
44
+ }
45
+ /**
46
+ * The hint cookies to write (`set`) and to clear (`clear`) so that each site's
47
+ * hint matches whether the request carries that site's member session.
48
+ * Empty lists for the overwhelmingly common request: no session and no hint.
49
+ */ export function signedInHintCorrections(cookies) {
50
+ const sessions = new Set();
51
+ const hints = new Map();
52
+ for (const { name, value } of cookies){
53
+ if (name.startsWith(MEMBER_SESSION_COOKIE_PREFIX) && value) {
54
+ sessions.add(name.slice(MEMBER_SESSION_COOKIE_PREFIX.length));
55
+ } else if (name.startsWith(SIGNED_IN_HINT_COOKIE_PREFIX)) {
56
+ hints.set(name.slice(SIGNED_IN_HINT_COOKIE_PREFIX.length), value);
57
+ }
58
+ }
59
+ const set = [
60
+ ...sessions
61
+ ].filter((suffix)=>hints.get(suffix) !== '1').map((suffix)=>`${SIGNED_IN_HINT_COOKIE_PREFIX}${suffix}`);
62
+ const clear = [
63
+ ...hints
64
+ ].filter(([suffix, value])=>value && !sessions.has(suffix)).map(([suffix])=>`${SIGNED_IN_HINT_COOKIE_PREFIX}${suffix}`);
65
+ return {
66
+ set,
67
+ clear
68
+ };
69
+ }
70
+
71
+ //# sourceMappingURL=sign-in-hint-cookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/sign-in-hint-cookie.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The cookie names behind \"Show to\" signed-in or signed-out visitors\n * (AGL-4231), and the repair the tenant middleware makes on every page\n * request. No imports, so the middleware can take it whole.\n *\n * The hint is written when a visitor signs in. A visitor who signed in BEFORE\n * the hint existed, or whose hint went missing, still holds a member session\n * and would see \"Sign in\" on every page. And a hint can outlive its session\n * (the session expired or was cleared by something other than sign-out). So\n * the middleware, which sees every page request before the cached page, keeps\n * the two in step: a session with no hint gets one, a hint with no session\n * loses it. The page's inline script then reads the corrected cookie, because\n * a browser applies a response's cookies before it runs the page's scripts.\n *\n * Presence of the session cookie is enough here: the hint only decides what\n * shows. Whether the session is valid is checked by every endpoint that acts\n * on it, exactly as before.\n */\n\n/** The member session cookie's name prefix; the site's id follows. HttpOnly. */\nexport const MEMBER_SESSION_COOKIE_PREFIX = 'aglyn_member_'\n\n/** The readable sign-in hint's name prefix; the site's id follows, as the session's does. */\nexport const SIGNED_IN_HINT_COOKIE_PREFIX = 'aglyn_signed_in_'\n\n/** How long a hint the middleware writes lasts: a session's own lifetime. */\nexport const SIGNED_IN_HINT_MAX_AGE_SECONDS = 30 * 24 * 60 * 60\n\n/** The suffix both cookies share for one site. */\nexport function siteCookieSuffix(hostId: string): string {\n return hostId.replace(/[^A-Za-z0-9_-]/g, '')\n}\n\n/** The member session cookie for one site. */\nexport function memberSessionCookieName(hostId: string): string {\n return `${MEMBER_SESSION_COOKIE_PREFIX}${siteCookieSuffix(hostId)}`\n}\n\n/** The readable \"signed in\" hint cookie for one site. */\nexport function signedInHintCookieName(hostId: string): string {\n return `${SIGNED_IN_HINT_COOKIE_PREFIX}${siteCookieSuffix(hostId)}`\n}\n\n/**\n * The hint cookies to write (`set`) and to clear (`clear`) so that each site's\n * hint matches whether the request carries that site's member session.\n * Empty lists for the overwhelmingly common request: no session and no hint.\n */\nexport function signedInHintCorrections(\n cookies: Iterable<{ name: string; value: string }>,\n): { set: string[]; clear: string[] } {\n const sessions = new Set<string>()\n const hints = new Map<string, string>()\n for (const { name, value } of cookies) {\n if (name.startsWith(MEMBER_SESSION_COOKIE_PREFIX) && value) {\n sessions.add(name.slice(MEMBER_SESSION_COOKIE_PREFIX.length))\n } else if (name.startsWith(SIGNED_IN_HINT_COOKIE_PREFIX)) {\n hints.set(name.slice(SIGNED_IN_HINT_COOKIE_PREFIX.length), value)\n }\n }\n const set = [...sessions]\n .filter((suffix) => hints.get(suffix) !== '1')\n .map((suffix) => `${SIGNED_IN_HINT_COOKIE_PREFIX}${suffix}`)\n const clear = [...hints]\n .filter(([suffix, value]) => value && !sessions.has(suffix))\n .map(([suffix]) => `${SIGNED_IN_HINT_COOKIE_PREFIX}${suffix}`)\n return { set, clear }\n}\n"],"names":["MEMBER_SESSION_COOKIE_PREFIX","SIGNED_IN_HINT_COOKIE_PREFIX","SIGNED_IN_HINT_MAX_AGE_SECONDS","siteCookieSuffix","hostId","replace","memberSessionCookieName","signedInHintCookieName","signedInHintCorrections","cookies","sessions","Set","hints","Map","name","value","startsWith","add","slice","length","set","filter","suffix","get","map","clear","has"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;CAiBC,GAED,8EAA8E,GAC9E,OAAO,MAAMA,+BAA+B,gBAAe;AAE3D,2FA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of SHOW_TO_SIGNED_IN | typeof SHOW_TO_SIGNED_OU
50
50
  export declare const SHOW_TO_ATTRIBUTE = "data-aglyn-show-to";
51
51
  /** The attribute on `<html>` while the visitor is signed in. */
52
52
  export declare const SIGNED_IN_ROOT_ATTRIBUTE = "data-aglyn-signed-in";
53
- /** The readable sign-in hint's name prefix; the site's id follows, as the session's does. */
54
- export declare const SIGNED_IN_HINT_COOKIE_PREFIX = "aglyn_signed_in_";
55
- /** The readable "signed in" hint cookie for one site. */
56
- export declare function signedInHintCookieName(hostId: string): string;
53
+ export { MEMBER_SESSION_COOKIE_PREFIX, memberSessionCookieName, SIGNED_IN_HINT_COOKIE_PREFIX, SIGNED_IN_HINT_MAX_AGE_SECONDS, signedInHintCookieName, signedInHintCorrections, } from './sign-in-hint-cookie';
57
54
  /** A stored `showTo` as one of the two audiences, or `undefined` for everyone. */
58
55
  export declare function resolveShowTo(value: unknown): ShowToAudience | undefined;
59
56
  /** Whether any element of a page is shown to one audience only. */
@@ -42,10 +42,10 @@
42
42
  /** Shown only to a visitor who is not signed in. */ export const SHOW_TO_SIGNED_OUT = 'signedOut';
43
43
  /** The attribute the renderer writes on an element that is not for everyone. */ export const SHOW_TO_ATTRIBUTE = 'data-aglyn-show-to';
44
44
  /** The attribute on `<html>` while the visitor is signed in. */ export const SIGNED_IN_ROOT_ATTRIBUTE = 'data-aglyn-signed-in';
45
- /** The readable sign-in hint's name prefix; the site's id follows, as the session's does. */ export const SIGNED_IN_HINT_COOKIE_PREFIX = 'aglyn_signed_in_';
46
- /** The readable "signed in" hint cookie for one site. */ export function signedInHintCookieName(hostId) {
47
- return `${SIGNED_IN_HINT_COOKIE_PREFIX}${hostId.replace(/[^A-Za-z0-9_-]/g, '')}`;
48
- }
45
+ // The cookie names, and the middleware's repair of a missing or stale hint,
46
+ // live in a module with no imports so the tenant middleware can take it whole.
47
+ export { MEMBER_SESSION_COOKIE_PREFIX, memberSessionCookieName, SIGNED_IN_HINT_COOKIE_PREFIX, SIGNED_IN_HINT_MAX_AGE_SECONDS, signedInHintCookieName, signedInHintCorrections } from "./sign-in-hint-cookie.js";
48
+ import { SIGNED_IN_HINT_COOKIE_PREFIX } from "./sign-in-hint-cookie.js";
49
49
  /** A stored `showTo` as one of the two audiences, or `undefined` for everyone. */ export function resolveShowTo(value) {
50
50
  return value === SHOW_TO_SIGNED_IN || value === SHOW_TO_SIGNED_OUT ? value : undefined;
51
51
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/sign-in-visibility.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { NODE_SHOW_TO_PROP } from './reusable-component-keys'\n\n/**\n * SHOW AN ELEMENT TO SIGNED-IN OR SIGNED-OUT VISITORS (AGL-4231).\n *\n * A site with accounts wants \"Sign in\" in its header for visitors and\n * \"Account\" for members, a \"Join\" banner only for people who have not, a\n * \"Welcome back\" only for those who have. Any element can say which of the two\n * it is for, with its `showTo` setting.\n *\n * A published page is ONE cached page for every visitor, so the server cannot\n * decide this. The browser does, before the first paint, and nothing moves:\n *\n * - the renderer writes the setting onto the element as {@link SHOW_TO_ATTRIBUTE};\n * - signing in sets a second, readable cookie beside the member session\n * ({@link signedInHintCookieName}: a `1`, nothing more — the session itself\n * stays HttpOnly);\n * - a page that uses the setting carries a tiny inline script that marks\n * `<html>` with {@link SIGNED_IN_ROOT_ATTRIBUTE} when that cookie is there, and\n * a style rule that hides each element from the visitors it is not for.\n *\n * It decides what shows, never what anyone may see: the hint is a cookie any\n * visitor can set. Content for members only belongs on a members-only page,\n * and the Attributes panel says so.\n */\n\nexport { NODE_SHOW_TO_PROP }\n\n/** Shown to every visitor: the setting's \"nothing chosen\". */\nexport const SHOW_TO_EVERYONE = 'everyone'\n/** Shown only to a visitor signed in to the site's account. */\nexport const SHOW_TO_SIGNED_IN = 'signedIn'\n/** Shown only to a visitor who is not signed in. */\nexport const SHOW_TO_SIGNED_OUT = 'signedOut'\n\nexport type ShowToAudience = typeof SHOW_TO_SIGNED_IN | typeof SHOW_TO_SIGNED_OUT\n\n/** The attribute the renderer writes on an element that is not for everyone. */\nexport const SHOW_TO_ATTRIBUTE = 'data-aglyn-show-to'\n\n/** The attribute on `<html>` while the visitor is signed in. */\nexport const SIGNED_IN_ROOT_ATTRIBUTE = 'data-aglyn-signed-in'\n\n/** The readable sign-in hint's name prefix; the site's id follows, as the session's does. */\nexport const SIGNED_IN_HINT_COOKIE_PREFIX = 'aglyn_signed_in_'\n\n/** The readable \"signed in\" hint cookie for one site. */\nexport function signedInHintCookieName(hostId: string): string {\n return `${SIGNED_IN_HINT_COOKIE_PREFIX}${hostId.replace(/[^A-Za-z0-9_-]/g, '')}`\n}\n\n/** A stored `showTo` as one of the two audiences, or `undefined` for everyone. */\nexport function resolveShowTo(value: unknown): ShowToAudience | undefined {\n return value === SHOW_TO_SIGNED_IN || value === SHOW_TO_SIGNED_OUT ? value : undefined\n}\n\n/** Whether any element of a page is shown to one audience only. */\nexport function nodesUseShowTo(nodes: Record<string, unknown> | null | undefined): boolean {\n for (const node of Object.values(nodes ?? {})) {\n const props = (node as { props?: Record<string, unknown> } | null)?.props\n if (props && resolveShowTo(props[NODE_SHOW_TO_PROP])) return true\n }\n return false\n}\n\n/**\n * The style a page that uses the setting carries. `!important` because an\n * element's own `display` (a flex row, a grid) is an author's style and must\n * not decide whether a signed-out visitor sees \"Account\".\n */\nexport const SIGN_IN_VISIBILITY_STYLE =\n `html:not([${SIGNED_IN_ROOT_ATTRIBUTE}]) [${SHOW_TO_ATTRIBUTE}=\"${SHOW_TO_SIGNED_IN}\"]{display:none!important}` +\n `html[${SIGNED_IN_ROOT_ATTRIBUTE}] [${SHOW_TO_ATTRIBUTE}=\"${SHOW_TO_SIGNED_OUT}\"]{display:none!important}`\n\n/**\n * The inline script, run before the first paint. A constant of ours: no\n * author input reaches it. The cookie is any site's hint, because a page\n * is only ever read with its own site's cookies.\n */\nexport const SIGN_IN_VISIBILITY_SCRIPT =\n `try{if(/(?:^|;\\\\s*)${SIGNED_IN_HINT_COOKIE_PREFIX}[A-Za-z0-9_-]+=1(?:;|$)/.test(document.cookie))` +\n `document.documentElement.setAttribute('${SIGNED_IN_ROOT_ATTRIBUTE}','')}catch(e){}`\n\n/**\n * Flips the page to signed in or out without a reload: called where a visitor\n * signs in, signs up or signs out, and where the account page learns the\n * session was gone all along. A no-op outside a browser.\n */\nexport function markSignedIn(signedIn: boolean): void {\n if (typeof document === 'undefined') return\n if (signedIn) document.documentElement.setAttribute(SIGNED_IN_ROOT_ATTRIBUTE, '')\n else document.documentElement.removeAttribute(SIGNED_IN_ROOT_ATTRIBUTE)\n}\n"],"names":["NODE_SHOW_TO_PROP","SHOW_TO_EVERYONE","SHOW_TO_SIGNED_IN","SHOW_TO_SIGNED_OUT","SHOW_TO_ATTRIBUTE","SIGNED_IN_ROOT_ATTRIBUTE","SIGNED_IN_HINT_COOKIE_PREFIX","signedInHintCookieName","hostId","replace","resolveShowTo","value","undefined","nodesUseShowTo","nodes","node","Object","values","props","SIGN_IN_VISIBILITY_STYLE","SIGN_IN_VISIBILITY_SCRIPT","markSignedIn","signedIn","document","documentElement","setAttribute","removeAttribute"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,iBAAiB,QAAQ,+BAA2B;AAE7D;;;;;;;;;;;;;;;;;;;;;;CAsBC,GAED,SAASA,iBAAiB,GAAE;AAE5B,4DAA4D,GAC5D,OAAO,MAAMC,mBAAmB,WAAU;AAC1C,6DAA6D,GAC7D,OAAO,MAAMC,oBAAoB,WA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B;AAChD"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/sign-in-visibility.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { NODE_SHOW_TO_PROP } from './reusable-component-keys'\n\n/**\n * SHOW AN ELEMENT TO SIGNED-IN OR SIGNED-OUT VISITORS (AGL-4231).\n *\n * A site with accounts wants \"Sign in\" in its header for visitors and\n * \"Account\" for members, a \"Join\" banner only for people who have not, a\n * \"Welcome back\" only for those who have. Any element can say which of the two\n * it is for, with its `showTo` setting.\n *\n * A published page is ONE cached page for every visitor, so the server cannot\n * decide this. The browser does, before the first paint, and nothing moves:\n *\n * - the renderer writes the setting onto the element as {@link SHOW_TO_ATTRIBUTE};\n * - signing in sets a second, readable cookie beside the member session\n * ({@link signedInHintCookieName}: a `1`, nothing more — the session itself\n * stays HttpOnly);\n * - a page that uses the setting carries a tiny inline script that marks\n * `<html>` with {@link SIGNED_IN_ROOT_ATTRIBUTE} when that cookie is there, and\n * a style rule that hides each element from the visitors it is not for.\n *\n * It decides what shows, never what anyone may see: the hint is a cookie any\n * visitor can set. Content for members only belongs on a members-only page,\n * and the Attributes panel says so.\n */\n\nexport { NODE_SHOW_TO_PROP }\n\n/** Shown to every visitor: the setting's \"nothing chosen\". */\nexport const SHOW_TO_EVERYONE = 'everyone'\n/** Shown only to a visitor signed in to the site's account. */\nexport const SHOW_TO_SIGNED_IN = 'signedIn'\n/** Shown only to a visitor who is not signed in. */\nexport const SHOW_TO_SIGNED_OUT = 'signedOut'\n\nexport type ShowToAudience = typeof SHOW_TO_SIGNED_IN | typeof SHOW_TO_SIGNED_OUT\n\n/** The attribute the renderer writes on an element that is not for everyone. */\nexport const SHOW_TO_ATTRIBUTE = 'data-aglyn-show-to'\n\n/** The attribute on `<html>` while the visitor is signed in. */\nexport const SIGNED_IN_ROOT_ATTRIBUTE = 'data-aglyn-signed-in'\n\n// The cookie names, and the middleware's repair of a missing or stale hint,\n// live in a module with no imports so the tenant middleware can take it whole.\nexport {\n MEMBER_SESSION_COOKIE_PREFIX,\n memberSessionCookieName,\n SIGNED_IN_HINT_COOKIE_PREFIX,\n SIGNED_IN_HINT_MAX_AGE_SECONDS,\n signedInHintCookieName,\n signedInHintCorrections,\n} from './sign-in-hint-cookie'\nimport { SIGNED_IN_HINT_COOKIE_PREFIX } from './sign-in-hint-cookie'\n\n/** A stored `showTo` as one of the two audiences, or `undefined` for everyone. */\nexport function resolveShowTo(value: unknown): ShowToAudience | undefined {\n return value === SHOW_TO_SIGNED_IN || value === SHOW_TO_SIGNED_OUT ? value : undefined\n}\n\n/** Whether any element of a page is shown to one audience only. */\nexport function nodesUseShowTo(nodes: Record<string, unknown> | null | undefined): boolean {\n for (const node of Object.values(nodes ?? {})) {\n const props = (node as { props?: Record<string, unknown> } | null)?.props\n if (props && resolveShowTo(props[NODE_SHOW_TO_PROP])) return true\n }\n return false\n}\n\n/**\n * The style a page that uses the setting carries. `!important` because an\n * element's own `display` (a flex row, a grid) is an author's style and must\n * not decide whether a signed-out visitor sees \"Account\".\n */\nexport const SIGN_IN_VISIBILITY_STYLE =\n `html:not([${SIGNED_IN_ROOT_ATTRIBUTE}]) [${SHOW_TO_ATTRIBUTE}=\"${SHOW_TO_SIGNED_IN}\"]{display:none!important}` +\n `html[${SIGNED_IN_ROOT_ATTRIBUTE}] [${SHOW_TO_ATTRIBUTE}=\"${SHOW_TO_SIGNED_OUT}\"]{display:none!important}`\n\n/**\n * The inline script, run before the first paint. A constant of ours: no\n * author input reaches it. The cookie is any site's hint, because a page\n * is only ever read with its own site's cookies.\n */\nexport const SIGN_IN_VISIBILITY_SCRIPT =\n `try{if(/(?:^|;\\\\s*)${SIGNED_IN_HINT_COOKIE_PREFIX}[A-Za-z0-9_-]+=1(?:;|$)/.test(document.cookie))` +\n `document.documentElement.setAttribute('${SIGNED_IN_ROOT_ATTRIBUTE}','')}catch(e){}`\n\n/**\n * Flips the page to signed in or out without a reload: called where a visitor\n * signs in, signs up or signs out, and where the account page learns the\n * session was gone all along. A no-op outside a browser.\n */\nexport function markSignedIn(signedIn: boolean): void {\n if (typeof document === 'undefined') return\n if (signedIn) document.documentElement.setAttribute(SIGNED_IN_ROOT_ATTRIBUTE, '')\n else document.documentElement.removeAttribute(SIGNED_IN_ROOT_ATTRIBUTE)\n}\n"],"names":["NODE_SHOW_TO_PROP","SHOW_TO_EVERYONE","SHOW_TO_SIGNED_IN","SHOW_TO_SIGNED_OUT","SHOW_TO_ATTRIBUTE","SIGNED_IN_ROOT_ATTRIBUTE","MEMBER_SESSION_COOKIE_PREFIX","memberSessionCookieName","SIGNED_IN_HINT_COOKIE_PREFIX","SIGNED_IN_HINT_MAX_AGE_SECONDS","signedInHintCookieName","signedInHintCorrections","resolveShowTo","value","undefined","nodesUseShowTo","nodes","node","Object","values","props","SIGN_IN_VISIBILITY_STYLE","SIGN_IN_VISIBILITY_SCRIPT","markSignedIn","signedIn","document","documentElement","setAttribute","removeAttribute"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,iBAAiB,QAAQ,+BAA2B;AAE7D;;;;;;;;;;;;;;;;;;;;;;CAsBC,GAED,SAASA,iBAAiB,GAAE;AAE5B,4DAA4D,GAC5D,OAAO,MAAMC,mBAAmB,WAAU;AAC1C,6DAA6D,GAC7D,OAAO,MAAMC,oBAAoB,WAAU;AAC3C,kDAAkD,GAClD,OAAO,MAAMC,qBAAqB,YAAW;AAI7C,8EAA8E,GAC9E,OAAO,MAAMC,oBAAoB,qBAAoB;AAErD,8DAA8D,GAC9D,OAAO,MAAMC,2BAA2B,uBAAsB;AAE9D,4EAA4E;AAC5E,+EAA+E;AAC/E,SACEC,4BAA4B,EAC5BC,uBAAuB,EACvBC,4BAA4B,EAC5BC,8BAA8B,EAC9BC,sBAAsB,EACtBC,uBAAuB,QAClB,2BAAuB;AAC9B,SAASH,4BAA4B,QAAQ,2BAAuB;AAEpE,gFAAgF,GAChF,OAAO,SAASI,cAAcC,KAAc;IAC1C,OAAOA,UAAUX,qBAAqBW,UAAUV,qBAAqBU,QAAQC;AAC/E;AAEA,iEAAiE,GACjE,OAAO,SAASC,eAAeC,KAAiD;IAC9E,KAAK,MAAMC,QAAQC,OAAOC,MAAM,CAACH,gBAAAA,QAAS,CAAC,GAAI;QAC7C,MAAMI,QAASH,wBAAD,AAACA,KAAqDG,KAAK;QACzE,IAAIA,SAASR,cAAcQ,KAAK,CAACpB,kBAAkB,GAAG,OAAO;IAC/D;IACA,OAAO;AACT;AAEA;;;;CAIC,GACD,OAAO,MAAMqB,2BACX,CAAC,UAAU,EAAEhB,yBAAyB,IAAI,EAAED,kBAAkB,EAAE,EAAEF,kBAAkB,0BAA0B,CAAC,GAC/G,CAAC,KAAK,EAAEG,yBAAyB,GAAG,EAAED,kBAAkB,EAAE,EAAED,mBAAmB,0BAA0B,CAAC,CAAA;AAE5G;;;;CAIC,GACD,OAAO,MAAMmB,4BACX,CAAC,mBAAmB,EAAEd,6BAA6B,+CAA+C,CAAC,GACnG,CAAC,uCAAuC,EAAEH,yBAAyB,gBAAgB,CAAC,CAAA;AAEtF;;;;CAIC,GACD,OAAO,SAASkB,aAAaC,QAAiB;IAC5C,IAAI,OAAOC,aAAa,aAAa;IACrC,IAAID,UAAUC,SAASC,eAAe,CAACC,YAAY,CAACtB,0BAA0B;SACzEoB,SAASC,eAAe,CAACE,eAAe,CAACvB;AAChD"}
@@ -1033,6 +1033,19 @@ export interface OrgBandwidthCap {
1033
1033
  pageViews?: number;
1034
1034
  /** The band those page views were measured against. Diagnostic. */
1035
1035
  includedPageViews?: number;
1036
+ /**
1037
+ * The ONE-TIME grace (AGL-4232): epoch ms until which the org's sites stay
1038
+ * online although the cap is engaged. Present only on the engagement that
1039
+ * granted it, which is the first ever for the org's sites
1040
+ * (`AglynHost.bandwidthGraceUsedAt`). Read through `bandwidthCapEngaged`.
1041
+ */
1042
+ graceUntil?: number;
1043
+ /**
1044
+ * When the owner was told the grace above had ended and the sites are
1045
+ * paused (AGL-4232). Written once by the daily sweep, which is where a
1046
+ * grace's end is noticed, so the news goes out once.
1047
+ */
1048
+ pauseNotifiedAt?: number;
1036
1049
  }
1037
1050
  /**
1038
1051
  * The organization document.
@@ -1202,6 +1215,14 @@ export interface AglynOrgBilling extends AglynDocument {
1202
1215
  * mid-month start serving again without waiting for a cron to clear it.
1203
1216
  */
1204
1217
  bandwidthCap?: OrgBandwidthCap;
1218
+ /**
1219
+ * When this workspace's sites were first given the free plan's ONE-TIME
1220
+ * bandwidth grace (AGL-4232), epoch ms, written once by the cap's engage
1221
+ * writer and never cleared. Beside each site's own stamp so deleting the
1222
+ * site and making a new one does not give the workspace a second grace.
1223
+ * Admin-SDK only; denied in the rules.
1224
+ */
1225
+ bandwidthGraceUsedAt?: number;
1205
1226
  /**
1206
1227
  * The org's assist hard-cap switch (AGL-2653) — see `OrgAssistOverage`.
1207
1228
  * Admin-SDK-only, denied in the rules beside `storageOverage`; read