@foliwake/server 0.9.0 → 0.10.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/CHANGELOG.md +33 -0
- package/README.md +364 -7
- package/dist/blocks-header.d.ts +5 -0
- package/dist/blocks-header.js +47 -0
- package/dist/config-checks.d.ts +9 -0
- package/dist/config-checks.js +53 -0
- package/dist/config-parts.d.ts +50 -0
- package/dist/config-parts.js +190 -0
- package/dist/config-v3.d.ts +22 -0
- package/dist/config-v3.js +104 -0
- package/dist/config.d.ts +11 -11
- package/dist/config.js +7 -222
- package/dist/discovery.d.ts +48 -0
- package/dist/discovery.js +150 -0
- package/dist/handler.d.ts +46 -0
- package/dist/handler.js +153 -0
- package/dist/hook-endpoint.d.ts +35 -0
- package/dist/hook-endpoint.js +143 -0
- package/dist/page-title.d.ts +3 -0
- package/dist/page-title.js +16 -0
- package/dist/page.d.ts +12 -2
- package/dist/page.js +26 -10
- package/dist/preload.d.ts +1 -1
- package/dist/preload.js +4 -4
- package/dist/resolve.d.ts +31 -0
- package/dist/resolve.js +76 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +3 -0
- package/package.json +21 -3
- package/schemas/remote-3.schema.json +204 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// The parsers of the parts of a config file (auth, proxies, blocks, media, pages, app), shared by version 2
|
|
2
|
+
// (./config) and version 3 (./config-v3). Internal: not a package export.
|
|
3
|
+
import { FoliwakeConfigError } from './errors.js';
|
|
4
|
+
import { checkEnvName, checkUsername, parseRemoteUrl } from './config-checks.js';
|
|
5
|
+
import { globProblem, GLOB_LIMITS } from './glob.js';
|
|
6
|
+
export const SECRET_KEYS = /^(password|passwd|pass|secret|token|apikey|api_key|authorization|credentials?|private_?key|signing_?key|jwk|d)$/i;
|
|
7
|
+
export const ISSUER = /^[A-Za-z0-9._:/-]{1,256}$/;
|
|
8
|
+
export const KID = /^[A-Za-z0-9._-]{1,128}$/;
|
|
9
|
+
export const SITE = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
10
|
+
export const PREFIX = /^(?:\/[a-z0-9-]+)+$/;
|
|
11
|
+
export const RESERVED_PREFIXES = ['/', '/_next', '/api', '/code', '/media'];
|
|
12
|
+
export const ENTRY_SEGMENT = /^[A-Za-z0-9_][A-Za-z0-9_.-]*$/;
|
|
13
|
+
export const ENTRY_ROOTS = ['scripts', 'components', '_foliwake'];
|
|
14
|
+
export const CONTRACT = /^foliwake-blocks\/([1-9][0-9]{0,2})$/;
|
|
15
|
+
export const EVENT_PREFIX = /^[a-z][a-z0-9-]{0,31}$/;
|
|
16
|
+
export const DEFAULTS = { code: '/foliwake-code', media: '/foliwake-media', contract: 'foliwake-blocks/2', eventPrefix: 'block', revalidate: 300 };
|
|
17
|
+
export const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
18
|
+
export function refuseSecrets(value, at, file) {
|
|
19
|
+
if (Array.isArray(value))
|
|
20
|
+
value.forEach((item, i) => refuseSecrets(item, `${at}[${i}]`, file));
|
|
21
|
+
if (!isObject(value))
|
|
22
|
+
return;
|
|
23
|
+
for (const [key, child] of Object.entries(value)) {
|
|
24
|
+
if (SECRET_KEYS.test(key)) {
|
|
25
|
+
throw new FoliwakeConfigError(`${file}: "${at}${key}" looks like a stored secret. This file is committed: ` +
|
|
26
|
+
'keep only the NAME of an environment variable ("passwordEnv", "privateKeyEnv") ' +
|
|
27
|
+
'and remove the secret (rotate it if it was committed).');
|
|
28
|
+
}
|
|
29
|
+
refuseSecrets(child, `${at}${key}.`, file);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function onlyKeys(value, allowed, where) {
|
|
33
|
+
for (const key of Object.keys(value)) {
|
|
34
|
+
if (!allowed.includes(key))
|
|
35
|
+
throw new FoliwakeConfigError(`${where}: unknown key "${key}" (allowed: ${allowed.join(', ')}).`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function parseEndpoint(value, where, opts) {
|
|
39
|
+
if (!isObject(value))
|
|
40
|
+
throw new FoliwakeConfigError(`${where}: must be an object {"url": …, "auth": …}.`);
|
|
41
|
+
onlyKeys(value, ['url', 'auth'], where);
|
|
42
|
+
const origin = parseRemoteUrl(value.url, `${where}.url`);
|
|
43
|
+
if (value.auth === undefined || value.auth === null)
|
|
44
|
+
return { origin, auth: null };
|
|
45
|
+
return { origin, auth: parseAuth(value.auth, `${where}.auth`, opts) };
|
|
46
|
+
}
|
|
47
|
+
export const AUTH_SHAPES = '{"type": "basic", "username": …, "passwordEnv": …} or ' +
|
|
48
|
+
'{"type": "service-token", "issuer": …, "kid": …, "privateKeyEnv": …}';
|
|
49
|
+
export function parseBasicAuth(auth, where, opts) {
|
|
50
|
+
onlyKeys(auth, ['type', 'username', 'passwordEnv'], where);
|
|
51
|
+
return {
|
|
52
|
+
type: 'basic',
|
|
53
|
+
username: checkUsername(auth.username, `${where}.username`),
|
|
54
|
+
passwordEnv: checkEnvName(auth.passwordEnv, `${where}.passwordEnv`, opts.envNameProblem),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export function parseServiceTokenAuth(auth, where, opts) {
|
|
58
|
+
onlyKeys(auth, ['type', 'issuer', 'kid', 'privateKeyEnv'], where);
|
|
59
|
+
if (typeof auth.issuer !== 'string' || !ISSUER.test(auth.issuer)) {
|
|
60
|
+
throw new FoliwakeConfigError(`${where}.issuer: the issuer the delivery expects (its TOKEN_ISSUER), [A-Za-z0-9._:/-], such as "my-app".`);
|
|
61
|
+
}
|
|
62
|
+
if (typeof auth.kid !== 'string' || !KID.test(auth.kid)) {
|
|
63
|
+
throw new FoliwakeConfigError(`${where}.kid: the key id of the public key the delivery holds, [A-Za-z0-9._-], such as "my-app-2026-11".`);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
type: 'service-token',
|
|
67
|
+
issuer: auth.issuer,
|
|
68
|
+
kid: auth.kid,
|
|
69
|
+
privateKeyEnv: checkEnvName(auth.privateKeyEnv, `${where}.privateKeyEnv`, opts.envNameProblem),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function parseAuth(auth, where, opts) {
|
|
73
|
+
if (!isObject(auth))
|
|
74
|
+
throw new FoliwakeConfigError(`${where}: must be ${AUTH_SHAPES}.`);
|
|
75
|
+
if (auth.type === 'basic')
|
|
76
|
+
return parseBasicAuth(auth, where, opts);
|
|
77
|
+
if (auth.type === 'service-token')
|
|
78
|
+
return parseServiceTokenAuth(auth, where, opts);
|
|
79
|
+
throw new FoliwakeConfigError(`${where}.type: "basic" or "service-token"; the auth must be ${AUTH_SHAPES}.`);
|
|
80
|
+
}
|
|
81
|
+
export function parsePrefix(value, fallback, where) {
|
|
82
|
+
if (value === undefined)
|
|
83
|
+
return fallback;
|
|
84
|
+
if (typeof value !== 'string' || !PREFIX.test(value))
|
|
85
|
+
throw new FoliwakeConfigError(`${where}: an absolute app path of [a-z0-9-] segments, such as "${fallback}".`);
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
/** The proxy prefixes of a config without `proxies`: version 2, and version 3 (`/foliwake/…`, one handler). */
|
|
89
|
+
export const PROXY_DEFAULTS = {
|
|
90
|
+
2: { code: DEFAULTS.code, media: DEFAULTS.media },
|
|
91
|
+
3: { code: '/foliwake/code', media: '/foliwake/media' },
|
|
92
|
+
};
|
|
93
|
+
export function parseProxies(value, where, defaults = PROXY_DEFAULTS[2]) {
|
|
94
|
+
if (value === undefined)
|
|
95
|
+
return { code: defaults.code, media: defaults.media, pages: null };
|
|
96
|
+
if (!isObject(value))
|
|
97
|
+
throw new FoliwakeConfigError(`${where}: must be an object {"code": …, "media": …, "pages": null}.`);
|
|
98
|
+
onlyKeys(value, ['code', 'media', 'pages'], where);
|
|
99
|
+
if (value.pages !== undefined && value.pages !== null)
|
|
100
|
+
throw new FoliwakeConfigError(`${where}.pages: must be null in this version (the pages proxy comes with client-side reads).`);
|
|
101
|
+
const proxies = {
|
|
102
|
+
code: parsePrefix(value.code, defaults.code, `${where}.code`),
|
|
103
|
+
media: parsePrefix(value.media, defaults.media, `${where}.media`),
|
|
104
|
+
pages: null,
|
|
105
|
+
};
|
|
106
|
+
const list = [proxies.code, proxies.media];
|
|
107
|
+
for (const prefix of list) {
|
|
108
|
+
const reserved = RESERVED_PREFIXES.find((r) => prefix === r || (r !== '/' && prefix.startsWith(`${r}/`)));
|
|
109
|
+
if (reserved)
|
|
110
|
+
throw new FoliwakeConfigError(`${where}: "${prefix}" collides with the reserved app path ${reserved}.`);
|
|
111
|
+
}
|
|
112
|
+
if (proxies.code === proxies.media || proxies.code.startsWith(`${proxies.media}/`) || proxies.media.startsWith(`${proxies.code}/`)) {
|
|
113
|
+
throw new FoliwakeConfigError(`${where}: "code" and "media" must be different prefixes, neither inside the other.`);
|
|
114
|
+
}
|
|
115
|
+
return proxies;
|
|
116
|
+
}
|
|
117
|
+
export function parseEntry(value, where) {
|
|
118
|
+
if (value === undefined || value === null)
|
|
119
|
+
return null;
|
|
120
|
+
const problem = 'a path inside a code release, such as "scripts/blocks.js": 1–8 segments of [A-Za-z0-9_.-], the first one scripts, components or _foliwake, ending in .js';
|
|
121
|
+
if (typeof value !== 'string')
|
|
122
|
+
throw new FoliwakeConfigError(`${where}: ${problem}.`);
|
|
123
|
+
const segments = value.split('/');
|
|
124
|
+
if (segments.length < 2 || segments.length > 8 || !ENTRY_ROOTS.includes(segments[0]) || !value.endsWith('.js')
|
|
125
|
+
|| segments.some((s) => !ENTRY_SEGMENT.test(s) || s === '.' || s === '..' || s.includes('..'))) {
|
|
126
|
+
throw new FoliwakeConfigError(`${where}: ${problem}.`);
|
|
127
|
+
}
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
export function parseBlocks(value, where) {
|
|
131
|
+
const blocks = value === undefined ? {} : value;
|
|
132
|
+
if (!isObject(blocks))
|
|
133
|
+
throw new FoliwakeConfigError(`${where}: must be an object {"entry": …, "contract": …, "eventPrefix": …}.`);
|
|
134
|
+
onlyKeys(blocks, ['entry', 'contract', 'eventPrefix'], where);
|
|
135
|
+
const contract = blocks.contract === undefined ? DEFAULTS.contract : blocks.contract;
|
|
136
|
+
const match = typeof contract === 'string' ? CONTRACT.exec(contract) : null;
|
|
137
|
+
if (!match)
|
|
138
|
+
throw new FoliwakeConfigError(`${where}.contract: "foliwake-blocks/<major>", such as "foliwake-blocks/2".`);
|
|
139
|
+
const eventPrefix = blocks.eventPrefix === undefined ? DEFAULTS.eventPrefix : blocks.eventPrefix;
|
|
140
|
+
if (typeof eventPrefix !== 'string' || !EVENT_PREFIX.test(eventPrefix))
|
|
141
|
+
throw new FoliwakeConfigError(`${where}.eventPrefix: [a-z][a-z0-9-], at most 32 characters.`);
|
|
142
|
+
const entry = parseEntry(blocks.entry, `${where}.entry`);
|
|
143
|
+
return { entry, contract: contract, major: Number(match[1]), eventPrefix, fromRelease: false };
|
|
144
|
+
}
|
|
145
|
+
export function parseMedia(value, where) {
|
|
146
|
+
if (value === undefined || value === null)
|
|
147
|
+
return null;
|
|
148
|
+
if (!isObject(value))
|
|
149
|
+
throw new FoliwakeConfigError(`${where}: must be an object {"base": "https://…", "transform": "cloudflare-images"}.`);
|
|
150
|
+
onlyKeys(value, ['base', 'transform'], where);
|
|
151
|
+
const base = parseRemoteUrl(value.base, `${where}.base`);
|
|
152
|
+
if (!base.startsWith('https:'))
|
|
153
|
+
throw new FoliwakeConfigError(`${where}.base: must be https.`);
|
|
154
|
+
if (value.transform !== undefined && value.transform !== null && value.transform !== 'cloudflare-images') {
|
|
155
|
+
throw new FoliwakeConfigError(`${where}.transform: only "cloudflare-images" (or null) is supported.`);
|
|
156
|
+
}
|
|
157
|
+
return { base, transform: value.transform === 'cloudflare-images' ? 'cloudflare-images' : null };
|
|
158
|
+
}
|
|
159
|
+
export function parsePages(value, where) {
|
|
160
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > GLOB_LIMITS.globsPerList) {
|
|
161
|
+
throw new FoliwakeConfigError(`${where}: a list of 1–${GLOB_LIMITS.globsPerList} page globs, such as ["/lessons/**"].`);
|
|
162
|
+
}
|
|
163
|
+
return value.map((glob, i) => {
|
|
164
|
+
const problem = typeof glob === 'string' ? globProblem(glob) : 'must be a string';
|
|
165
|
+
if (problem)
|
|
166
|
+
throw new FoliwakeConfigError(`${where}[${i}]: ${problem}.`);
|
|
167
|
+
return glob;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/** `app.revalidate`: whole seconds, 1–86400; default 300. */
|
|
171
|
+
export function parseRevalidate(value, where) {
|
|
172
|
+
const revalidate = value === undefined ? DEFAULTS.revalidate : value;
|
|
173
|
+
if (typeof revalidate !== 'number' || !Number.isInteger(revalidate) || revalidate < 1 || revalidate > 86_400) {
|
|
174
|
+
throw new FoliwakeConfigError(`${where}: whole seconds between 1 and 86400.`);
|
|
175
|
+
}
|
|
176
|
+
return revalidate;
|
|
177
|
+
}
|
|
178
|
+
export function parseApp(value, where) {
|
|
179
|
+
if (!isObject(value))
|
|
180
|
+
throw new FoliwakeConfigError(`${where}: must be an object {"pages": […], …}.`);
|
|
181
|
+
onlyKeys(value, ['pages', 'proxies', 'blocks', 'media', 'revalidate'], where);
|
|
182
|
+
const revalidate = parseRevalidate(value.revalidate, `${where}.revalidate`);
|
|
183
|
+
return {
|
|
184
|
+
pages: Object.freeze(parsePages(value.pages, `${where}.pages`)),
|
|
185
|
+
proxies: parseProxies(value.proxies, `${where}.proxies`),
|
|
186
|
+
blocks: parseBlocks(value.blocks, `${where}.blocks`),
|
|
187
|
+
media: parseMedia(value.media, `${where}.media`),
|
|
188
|
+
revalidate,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type FoliwakeAppConfig, type RemoteAuth } from './config.js';
|
|
2
|
+
import { type Obj } from './config-parts.js';
|
|
3
|
+
import type { FoliwakeDiscovery } from './discovery.js';
|
|
4
|
+
/** The variable the default preview credential reads: Basic `preview:<site preview token>`. */
|
|
5
|
+
export declare const PREVIEW_TOKEN_ENV = "FOLIWAKE_PREVIEW_TOKEN";
|
|
6
|
+
/** A parsed version 3 file: every part optional. */
|
|
7
|
+
export interface FoliwakeOverrides {
|
|
8
|
+
site: string | null;
|
|
9
|
+
liveAuth: RemoteAuth | null;
|
|
10
|
+
previewAuth: RemoteAuth | null;
|
|
11
|
+
app: Obj;
|
|
12
|
+
from: string;
|
|
13
|
+
}
|
|
14
|
+
/** Parses the text of a version 3 file. Throws FoliwakeConfigError naming the field. */
|
|
15
|
+
export declare function parseOverrides(text: string, file?: string): FoliwakeOverrides;
|
|
16
|
+
/** No file: the overrides of an empty version 3 file. */
|
|
17
|
+
export declare function emptyOverrides(): FoliwakeOverrides;
|
|
18
|
+
/**
|
|
19
|
+
* The app config of a site: its discovery document, with the version 3 file's overrides. Preview, when the site
|
|
20
|
+
* has it, is read with Basic `preview` and the token in FOLIWAKE_PREVIEW_TOKEN unless the file names another auth.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveConfig(discovery: FoliwakeDiscovery, overrides?: FoliwakeOverrides): FoliwakeAppConfig;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Version 3: the app is configured by FOLIWAKE_URL. The site's discovery document gives the origins and the media
|
|
2
|
+
// CDN; `foliwake.remote.json` version 3 is optional and holds only the app's own decisions (overrides): pages,
|
|
3
|
+
// revalidate, proxies, media transform, blocks, and the credentials of each channel by variable NAME.
|
|
4
|
+
// Without FOLIWAKE_URL a version 2 file is read as before (./config).
|
|
5
|
+
import { CONFIG_FILE } from './config.js';
|
|
6
|
+
import { DEFAULTS, isObject, onlyKeys, parseAuth, parseBlocks, parseMedia, parsePages, parseProxies, parseRevalidate, PROXY_DEFAULTS, refuseSecrets, } from './config-parts.js';
|
|
7
|
+
import { FoliwakeConfigError } from './errors.js';
|
|
8
|
+
/** The variable the default preview credential reads: Basic `preview:<site preview token>`. */
|
|
9
|
+
export const PREVIEW_TOKEN_ENV = 'FOLIWAKE_PREVIEW_TOKEN';
|
|
10
|
+
const APP_KEYS = ['pages', 'proxies', 'blocks', 'media', 'revalidate'];
|
|
11
|
+
function channelAuth(value, where) {
|
|
12
|
+
if (value === undefined)
|
|
13
|
+
return null;
|
|
14
|
+
if (!isObject(value))
|
|
15
|
+
throw new FoliwakeConfigError(`${where}: must be an object {"auth": …}.`);
|
|
16
|
+
onlyKeys(value, ['auth'], where);
|
|
17
|
+
return value.auth === undefined || value.auth === null ? null : parseAuth(value.auth, `${where}.auth`, {});
|
|
18
|
+
}
|
|
19
|
+
function parsedObject(text, file) {
|
|
20
|
+
let parsed;
|
|
21
|
+
try {
|
|
22
|
+
parsed = JSON.parse(text);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw new FoliwakeConfigError(`${file} is not valid JSON: ${error.message}`);
|
|
26
|
+
}
|
|
27
|
+
if (!isObject(parsed))
|
|
28
|
+
throw new FoliwakeConfigError(`${file} must be a JSON object {"version": 3, …}.`);
|
|
29
|
+
refuseSecrets(parsed, '', file);
|
|
30
|
+
return parsed;
|
|
31
|
+
}
|
|
32
|
+
/** Parses the text of a version 3 file. Throws FoliwakeConfigError naming the field. */
|
|
33
|
+
export function parseOverrides(text, file = CONFIG_FILE) {
|
|
34
|
+
const parsed = parsedObject(text, file);
|
|
35
|
+
onlyKeys(parsed, ['$schema', '$comment', 'version', 'site', 'live', 'preview', 'app'], file);
|
|
36
|
+
if (parsed.version !== 3)
|
|
37
|
+
throw new FoliwakeConfigError(`${file}: "version" must be 3 here.`);
|
|
38
|
+
const app = parsed.app === undefined ? {} : parsed.app;
|
|
39
|
+
if (!isObject(app))
|
|
40
|
+
throw new FoliwakeConfigError(`${file} "app": must be an object.`);
|
|
41
|
+
onlyKeys(app, APP_KEYS, `${file} "app"`);
|
|
42
|
+
if (parsed.site !== undefined && typeof parsed.site !== 'string') {
|
|
43
|
+
throw new FoliwakeConfigError(`${file} "site": the site name, such as "my-site".`);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
site: parsed.site ?? null,
|
|
47
|
+
liveAuth: channelAuth(parsed.live, `${file} "live"`),
|
|
48
|
+
previewAuth: channelAuth(parsed.preview, `${file} "preview"`),
|
|
49
|
+
app,
|
|
50
|
+
from: file,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function defaultPreviewAuth() {
|
|
54
|
+
return { type: 'basic', username: 'preview', passwordEnv: PREVIEW_TOKEN_ENV };
|
|
55
|
+
}
|
|
56
|
+
/** No `app.blocks`: the code release of each page names its blocks module (`X-Foliwake-Blocks`). */
|
|
57
|
+
function releaseBlocks() {
|
|
58
|
+
return { entry: null, contract: DEFAULTS.contract, major: 2, eventPrefix: DEFAULTS.eventPrefix, fromRelease: true };
|
|
59
|
+
}
|
|
60
|
+
// `/**` is safe while live is read anonymously (the site's access rules decide). With a service token the app
|
|
61
|
+
// could read closed pages, so it must say which ones.
|
|
62
|
+
function pagesOf(app, liveAuth, where) {
|
|
63
|
+
if (app.pages !== undefined)
|
|
64
|
+
return Object.freeze(parsePages(app.pages, `${where}.pages`));
|
|
65
|
+
if (liveAuth?.type === 'service-token') {
|
|
66
|
+
throw new FoliwakeConfigError(`${where}.pages: required when "live" uses a service token (list the pages).`);
|
|
67
|
+
}
|
|
68
|
+
return Object.freeze(['/**']);
|
|
69
|
+
}
|
|
70
|
+
function mediaOf(app, discovery, where) {
|
|
71
|
+
if (app.media !== undefined)
|
|
72
|
+
return parseMedia(app.media, `${where}.media`);
|
|
73
|
+
return discovery.media ? { base: discovery.media.cdn, transform: null } : null;
|
|
74
|
+
}
|
|
75
|
+
function appSettings(overrides, discovery) {
|
|
76
|
+
const { app } = overrides;
|
|
77
|
+
const where = `${overrides.from} "app"`;
|
|
78
|
+
return {
|
|
79
|
+
pages: pagesOf(app, overrides.liveAuth, where),
|
|
80
|
+
proxies: parseProxies(app.proxies, `${where}.proxies`, PROXY_DEFAULTS[3]),
|
|
81
|
+
blocks: app.blocks === undefined ? releaseBlocks() : parseBlocks(app.blocks, `${where}.blocks`),
|
|
82
|
+
media: mediaOf(app, discovery, where),
|
|
83
|
+
revalidate: parseRevalidate(app.revalidate, `${where}.revalidate`),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** No file: the overrides of an empty version 3 file. */
|
|
87
|
+
export function emptyOverrides() {
|
|
88
|
+
return { site: null, liveAuth: null, previewAuth: null, app: {}, from: 'FOLIWAKE_URL' };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The app config of a site: its discovery document, with the version 3 file's overrides. Preview, when the site
|
|
92
|
+
* has it, is read with Basic `preview` and the token in FOLIWAKE_PREVIEW_TOKEN unless the file names another auth.
|
|
93
|
+
*/
|
|
94
|
+
export function resolveConfig(discovery, overrides = emptyOverrides()) {
|
|
95
|
+
if (overrides.site !== null && overrides.site !== discovery.site) {
|
|
96
|
+
const text = `"site" is ${overrides.site}, but ${discovery.live.url} serves the site ${discovery.site}.`;
|
|
97
|
+
throw new FoliwakeConfigError(`${overrides.from}: ${text}`);
|
|
98
|
+
}
|
|
99
|
+
const live = { origin: discovery.live.url, auth: overrides.liveAuth };
|
|
100
|
+
const previewAuth = overrides.previewAuth ?? defaultPreviewAuth();
|
|
101
|
+
const preview = discovery.preview ? { origin: discovery.preview.url, auth: previewAuth } : null;
|
|
102
|
+
const app = appSettings(overrides, discovery);
|
|
103
|
+
return Object.freeze({ version: 3, site: discovery.site, live, preview, app, from: overrides.from });
|
|
104
|
+
}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ChannelName, ClientSettings } from '@foliwake/blocks-contract/page';
|
|
2
2
|
export { FoliwakeConfigError } from './errors.js';
|
|
3
|
+
export { checkEnvName, checkUsername, isLoopbackName, parseRemoteUrl } from './config-checks.js';
|
|
3
4
|
export type { ClientSettings } from '@foliwake/blocks-contract/page';
|
|
4
5
|
/** The default config file name, looked up in the current directory. */
|
|
5
6
|
export declare const CONFIG_FILE = "foliwake.remote.json";
|
|
@@ -44,12 +45,16 @@ export interface FoliwakeAppSettings {
|
|
|
44
45
|
media: string;
|
|
45
46
|
pages: null;
|
|
46
47
|
};
|
|
47
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Where `mountBlocks` lives in a code release; null: bodies stay static. `fromRelease`: the config names no
|
|
50
|
+
* blocks (version 3), so each page's code release names them (`X-Foliwake-Blocks`); false for version 2.
|
|
51
|
+
*/
|
|
48
52
|
blocks: {
|
|
49
53
|
entry: string | null;
|
|
50
54
|
contract: string;
|
|
51
55
|
major: number;
|
|
52
56
|
eventPrefix: string;
|
|
57
|
+
fromRelease: boolean;
|
|
53
58
|
};
|
|
54
59
|
/** Live media through a transforming host; null: media through the proxy. */
|
|
55
60
|
media: {
|
|
@@ -59,9 +64,12 @@ export interface FoliwakeAppSettings {
|
|
|
59
64
|
/** Seconds before a cached envelope is stale (stale-while-revalidate). */
|
|
60
65
|
revalidate: number;
|
|
61
66
|
}
|
|
62
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* A validated app config: a `foliwake.remote.json` version 2, or (version 3) the site's discovery document merged
|
|
69
|
+
* with the optional version 3 file. It holds credential variable names, never secrets.
|
|
70
|
+
*/
|
|
63
71
|
export interface FoliwakeAppConfig {
|
|
64
|
-
version: 2;
|
|
72
|
+
version: 2 | 3;
|
|
65
73
|
site: string;
|
|
66
74
|
live: FoliwakeEndpoint | null;
|
|
67
75
|
preview: FoliwakeEndpoint | null;
|
|
@@ -79,14 +87,6 @@ export interface ParseOptions {
|
|
|
79
87
|
/** An additional rule for credential variable names (the engine CLI passes its own). */
|
|
80
88
|
envNameProblem?: (name: string, what: string) => string | null;
|
|
81
89
|
}
|
|
82
|
-
/** True for 127.x, localhost, *.localhost and ::1. */
|
|
83
|
-
export declare function isLoopbackName(hostname: string): boolean;
|
|
84
|
-
/** A site origin: https (http only for loopback), no credentials, path, query or fragment. */
|
|
85
|
-
export declare function parseRemoteUrl(value: unknown, where: string): string;
|
|
86
|
-
/** Validates an environment variable NAME (never a value). */
|
|
87
|
-
export declare function checkEnvName(value: unknown, where: string, extra?: ParseOptions['envNameProblem']): string;
|
|
88
|
-
/** Validates a Basic user name (no `:` or control characters, at most 128 characters). */
|
|
89
|
-
export declare function checkUsername(value: unknown, where: string): string;
|
|
90
90
|
/** Parses the text of a version 2 config. Throws FoliwakeConfigError with a message that names the field. */
|
|
91
91
|
export declare function parseFoliwakeConfig(text: string, opts?: ParseOptions): FoliwakeAppConfig;
|
|
92
92
|
/** The endpoint of a channel; a missing one is an error, never replaced by the other channel. */
|
package/dist/config.js
CHANGED
|
@@ -7,236 +7,21 @@
|
|
|
7
7
|
import { readFile } from 'node:fs/promises';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { FoliwakeConfigError } from './errors.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { compileGlob, globMatches } from './glob.js';
|
|
11
|
+
import { isObject, onlyKeys, parseApp, parseEndpoint, refuseSecrets, SITE } from './config-parts.js';
|
|
12
12
|
export { FoliwakeConfigError } from './errors.js';
|
|
13
|
+
export { checkEnvName, checkUsername, isLoopbackName, parseRemoteUrl } from './config-checks.js';
|
|
13
14
|
/** The default config file name, looked up in the current directory. */
|
|
14
15
|
export const CONFIG_FILE = 'foliwake.remote.json';
|
|
15
16
|
/** The environment variable that names another config file. */
|
|
16
17
|
export const CONFIG_ENV = 'FOLIWAKE_REMOTE';
|
|
17
18
|
/** The channels a config can name. */
|
|
18
19
|
export const CHANNELS = Object.freeze(['live', 'preview']);
|
|
19
|
-
const SECRET_KEYS = /^(password|passwd|pass|secret|token|apikey|api_key|authorization|credentials?|private_?key|signing_?key|jwk|d)$/i;
|
|
20
|
-
const ISSUER = /^[A-Za-z0-9._:/-]{1,256}$/;
|
|
21
|
-
const KID = /^[A-Za-z0-9._-]{1,128}$/;
|
|
22
|
-
const SITE = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
23
|
-
const PREFIX = /^(?:\/[a-z0-9-]+)+$/;
|
|
24
|
-
const RESERVED_PREFIXES = ['/', '/_next', '/api', '/code', '/media'];
|
|
25
|
-
const ENTRY_SEGMENT = /^[A-Za-z0-9_][A-Za-z0-9_.-]*$/;
|
|
26
|
-
const ENTRY_ROOTS = ['scripts', 'components', '_foliwake'];
|
|
27
|
-
const CONTRACT = /^foliwake-blocks\/([1-9][0-9]{0,2})$/;
|
|
28
|
-
const EVENT_PREFIX = /^[a-z][a-z0-9-]{0,31}$/;
|
|
29
|
-
const DEFAULTS = { code: '/foliwake-code', media: '/foliwake-media', contract: 'foliwake-blocks/2', eventPrefix: 'block', revalidate: 300 };
|
|
30
|
-
const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
31
|
-
/** True for 127.x, localhost, *.localhost and ::1. */
|
|
32
|
-
export function isLoopbackName(hostname) {
|
|
33
|
-
const name = hostname.toLowerCase().replace(/\.$/, '');
|
|
34
|
-
if (name === 'localhost' || name.endsWith('.localhost'))
|
|
35
|
-
return true;
|
|
36
|
-
if (name === '[::1]' || name === '::1')
|
|
37
|
-
return true;
|
|
38
|
-
return /^127(?:\.\d{1,3}){3}$/.test(name);
|
|
39
|
-
}
|
|
40
|
-
function safeUrlText(value) {
|
|
41
|
-
return value.replace(/\/\/[^/@]*@/, '//…@').slice(0, 200);
|
|
42
|
-
}
|
|
43
|
-
/** A site origin: https (http only for loopback), no credentials, path, query or fragment. */
|
|
44
|
-
export function parseRemoteUrl(value, where) {
|
|
45
|
-
if (typeof value !== 'string' || value.trim() === '')
|
|
46
|
-
throw new FoliwakeConfigError(`${where}: give the URL of the deployed site, e.g. "https://preview.example.org".`);
|
|
47
|
-
let url;
|
|
48
|
-
try {
|
|
49
|
-
url = new URL(value);
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
throw new FoliwakeConfigError(`${where}: "${safeUrlText(value)}" is not a valid URL.`);
|
|
53
|
-
}
|
|
54
|
-
if (url.username || url.password)
|
|
55
|
-
throw new FoliwakeConfigError(`${where}: the URL must not contain a user name or password; name the password's environment variable in "auth" instead.`);
|
|
56
|
-
if (url.protocol !== 'https:' && url.protocol !== 'http:')
|
|
57
|
-
throw new FoliwakeConfigError(`${where}: only https URLs are supported.`);
|
|
58
|
-
if (url.protocol === 'http:' && !isLoopbackName(url.hostname)) {
|
|
59
|
-
throw new FoliwakeConfigError(`${where}: ${url.origin} uses plain http; use https (http is accepted only for loopback hosts such as 127.0.0.1).`);
|
|
60
|
-
}
|
|
61
|
-
if (url.search || url.hash || (url.pathname !== '/' && url.pathname !== '')) {
|
|
62
|
-
throw new FoliwakeConfigError(`${where}: give the site origin only (scheme, host and port), without a path, query or fragment: ${url.origin}`);
|
|
63
|
-
}
|
|
64
|
-
return url.origin;
|
|
65
|
-
}
|
|
66
|
-
/** Validates an environment variable NAME (never a value). */
|
|
67
|
-
export function checkEnvName(value, where, extra) {
|
|
68
|
-
const problem = basicEnvNameProblem(value, where) ?? (extra ? extra(value, where) : null);
|
|
69
|
-
if (problem)
|
|
70
|
-
throw new FoliwakeConfigError(problem);
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
/** Validates a Basic user name (no `:` or control characters, at most 128 characters). */
|
|
74
|
-
export function checkUsername(value, where) {
|
|
75
|
-
if (typeof value !== 'string' || value === '' || value.length > 128 || /[:\u0000-\u001f\u007f]/.test(value)) {
|
|
76
|
-
throw new FoliwakeConfigError(`${where}: give a user name without ":" or control characters.`);
|
|
77
|
-
}
|
|
78
|
-
return value;
|
|
79
|
-
}
|
|
80
|
-
function refuseSecrets(value, at, file) {
|
|
81
|
-
if (Array.isArray(value))
|
|
82
|
-
value.forEach((item, i) => refuseSecrets(item, `${at}[${i}]`, file));
|
|
83
|
-
if (!isObject(value))
|
|
84
|
-
return;
|
|
85
|
-
for (const [key, child] of Object.entries(value)) {
|
|
86
|
-
if (SECRET_KEYS.test(key)) {
|
|
87
|
-
throw new FoliwakeConfigError(`${file}: "${at}${key}" looks like a stored secret. This file is committed: ` +
|
|
88
|
-
'keep only the NAME of an environment variable ("passwordEnv", "privateKeyEnv") ' +
|
|
89
|
-
'and remove the secret (rotate it if it was committed).');
|
|
90
|
-
}
|
|
91
|
-
refuseSecrets(child, `${at}${key}.`, file);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function onlyKeys(value, allowed, where) {
|
|
95
|
-
for (const key of Object.keys(value)) {
|
|
96
|
-
if (!allowed.includes(key))
|
|
97
|
-
throw new FoliwakeConfigError(`${where}: unknown key "${key}" (allowed: ${allowed.join(', ')}).`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function parseEndpoint(value, where, opts) {
|
|
101
|
-
if (!isObject(value))
|
|
102
|
-
throw new FoliwakeConfigError(`${where}: must be an object {"url": …, "auth": …}.`);
|
|
103
|
-
onlyKeys(value, ['url', 'auth'], where);
|
|
104
|
-
const origin = parseRemoteUrl(value.url, `${where}.url`);
|
|
105
|
-
if (value.auth === undefined || value.auth === null)
|
|
106
|
-
return { origin, auth: null };
|
|
107
|
-
return { origin, auth: parseAuth(value.auth, `${where}.auth`, opts) };
|
|
108
|
-
}
|
|
109
|
-
const AUTH_SHAPES = '{"type": "basic", "username": …, "passwordEnv": …} or ' +
|
|
110
|
-
'{"type": "service-token", "issuer": …, "kid": …, "privateKeyEnv": …}';
|
|
111
|
-
function parseBasicAuth(auth, where, opts) {
|
|
112
|
-
onlyKeys(auth, ['type', 'username', 'passwordEnv'], where);
|
|
113
|
-
return {
|
|
114
|
-
type: 'basic',
|
|
115
|
-
username: checkUsername(auth.username, `${where}.username`),
|
|
116
|
-
passwordEnv: checkEnvName(auth.passwordEnv, `${where}.passwordEnv`, opts.envNameProblem),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function parseServiceTokenAuth(auth, where, opts) {
|
|
120
|
-
onlyKeys(auth, ['type', 'issuer', 'kid', 'privateKeyEnv'], where);
|
|
121
|
-
if (typeof auth.issuer !== 'string' || !ISSUER.test(auth.issuer)) {
|
|
122
|
-
throw new FoliwakeConfigError(`${where}.issuer: the issuer the delivery expects (its TOKEN_ISSUER), [A-Za-z0-9._:/-], such as "my-app".`);
|
|
123
|
-
}
|
|
124
|
-
if (typeof auth.kid !== 'string' || !KID.test(auth.kid)) {
|
|
125
|
-
throw new FoliwakeConfigError(`${where}.kid: the key id of the public key the delivery holds, [A-Za-z0-9._-], such as "my-app-2026-11".`);
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
type: 'service-token',
|
|
129
|
-
issuer: auth.issuer,
|
|
130
|
-
kid: auth.kid,
|
|
131
|
-
privateKeyEnv: checkEnvName(auth.privateKeyEnv, `${where}.privateKeyEnv`, opts.envNameProblem),
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
function parseAuth(auth, where, opts) {
|
|
135
|
-
if (!isObject(auth))
|
|
136
|
-
throw new FoliwakeConfigError(`${where}: must be ${AUTH_SHAPES}.`);
|
|
137
|
-
if (auth.type === 'basic')
|
|
138
|
-
return parseBasicAuth(auth, where, opts);
|
|
139
|
-
if (auth.type === 'service-token')
|
|
140
|
-
return parseServiceTokenAuth(auth, where, opts);
|
|
141
|
-
throw new FoliwakeConfigError(`${where}.type: "basic" or "service-token"; the auth must be ${AUTH_SHAPES}.`);
|
|
142
|
-
}
|
|
143
|
-
function parsePrefix(value, fallback, where) {
|
|
144
|
-
if (value === undefined)
|
|
145
|
-
return fallback;
|
|
146
|
-
if (typeof value !== 'string' || !PREFIX.test(value))
|
|
147
|
-
throw new FoliwakeConfigError(`${where}: an absolute app path of [a-z0-9-] segments, such as "${fallback}".`);
|
|
148
|
-
return value;
|
|
149
|
-
}
|
|
150
|
-
function parseProxies(value, where) {
|
|
151
|
-
if (value === undefined)
|
|
152
|
-
return { code: DEFAULTS.code, media: DEFAULTS.media, pages: null };
|
|
153
|
-
if (!isObject(value))
|
|
154
|
-
throw new FoliwakeConfigError(`${where}: must be an object {"code": …, "media": …, "pages": null}.`);
|
|
155
|
-
onlyKeys(value, ['code', 'media', 'pages'], where);
|
|
156
|
-
if (value.pages !== undefined && value.pages !== null)
|
|
157
|
-
throw new FoliwakeConfigError(`${where}.pages: must be null in this version (the pages proxy comes with client-side reads).`);
|
|
158
|
-
const proxies = { code: parsePrefix(value.code, DEFAULTS.code, `${where}.code`), media: parsePrefix(value.media, DEFAULTS.media, `${where}.media`), pages: null };
|
|
159
|
-
const list = [proxies.code, proxies.media];
|
|
160
|
-
for (const prefix of list) {
|
|
161
|
-
const reserved = RESERVED_PREFIXES.find((r) => prefix === r || (r !== '/' && prefix.startsWith(`${r}/`)));
|
|
162
|
-
if (reserved)
|
|
163
|
-
throw new FoliwakeConfigError(`${where}: "${prefix}" collides with the reserved app path ${reserved}.`);
|
|
164
|
-
}
|
|
165
|
-
if (proxies.code === proxies.media || proxies.code.startsWith(`${proxies.media}/`) || proxies.media.startsWith(`${proxies.code}/`)) {
|
|
166
|
-
throw new FoliwakeConfigError(`${where}: "code" and "media" must be different prefixes, neither inside the other.`);
|
|
167
|
-
}
|
|
168
|
-
return proxies;
|
|
169
|
-
}
|
|
170
|
-
function parseEntry(value, where) {
|
|
171
|
-
if (value === undefined || value === null)
|
|
172
|
-
return null;
|
|
173
|
-
const problem = 'a path inside a code release, such as "scripts/blocks.js": 1–8 segments of [A-Za-z0-9_.-], the first one scripts, components or _foliwake, ending in .js';
|
|
174
|
-
if (typeof value !== 'string')
|
|
175
|
-
throw new FoliwakeConfigError(`${where}: ${problem}.`);
|
|
176
|
-
const segments = value.split('/');
|
|
177
|
-
if (segments.length < 2 || segments.length > 8 || !ENTRY_ROOTS.includes(segments[0]) || !value.endsWith('.js')
|
|
178
|
-
|| segments.some((s) => !ENTRY_SEGMENT.test(s) || s === '.' || s === '..' || s.includes('..'))) {
|
|
179
|
-
throw new FoliwakeConfigError(`${where}: ${problem}.`);
|
|
180
|
-
}
|
|
181
|
-
return value;
|
|
182
|
-
}
|
|
183
|
-
function parseBlocks(value, where) {
|
|
184
|
-
const blocks = value === undefined ? {} : value;
|
|
185
|
-
if (!isObject(blocks))
|
|
186
|
-
throw new FoliwakeConfigError(`${where}: must be an object {"entry": …, "contract": …, "eventPrefix": …}.`);
|
|
187
|
-
onlyKeys(blocks, ['entry', 'contract', 'eventPrefix'], where);
|
|
188
|
-
const contract = blocks.contract === undefined ? DEFAULTS.contract : blocks.contract;
|
|
189
|
-
const match = typeof contract === 'string' ? CONTRACT.exec(contract) : null;
|
|
190
|
-
if (!match)
|
|
191
|
-
throw new FoliwakeConfigError(`${where}.contract: "foliwake-blocks/<major>", such as "foliwake-blocks/2".`);
|
|
192
|
-
const eventPrefix = blocks.eventPrefix === undefined ? DEFAULTS.eventPrefix : blocks.eventPrefix;
|
|
193
|
-
if (typeof eventPrefix !== 'string' || !EVENT_PREFIX.test(eventPrefix))
|
|
194
|
-
throw new FoliwakeConfigError(`${where}.eventPrefix: [a-z][a-z0-9-], at most 32 characters.`);
|
|
195
|
-
return { entry: parseEntry(blocks.entry, `${where}.entry`), contract: contract, major: Number(match[1]), eventPrefix };
|
|
196
|
-
}
|
|
197
|
-
function parseMedia(value, where) {
|
|
198
|
-
if (value === undefined || value === null)
|
|
199
|
-
return null;
|
|
200
|
-
if (!isObject(value))
|
|
201
|
-
throw new FoliwakeConfigError(`${where}: must be an object {"base": "https://…", "transform": "cloudflare-images"}.`);
|
|
202
|
-
onlyKeys(value, ['base', 'transform'], where);
|
|
203
|
-
const base = parseRemoteUrl(value.base, `${where}.base`);
|
|
204
|
-
if (!base.startsWith('https:'))
|
|
205
|
-
throw new FoliwakeConfigError(`${where}.base: must be https.`);
|
|
206
|
-
if (value.transform !== undefined && value.transform !== null && value.transform !== 'cloudflare-images') {
|
|
207
|
-
throw new FoliwakeConfigError(`${where}.transform: only "cloudflare-images" (or null) is supported.`);
|
|
208
|
-
}
|
|
209
|
-
return { base, transform: value.transform === 'cloudflare-images' ? 'cloudflare-images' : null };
|
|
210
|
-
}
|
|
211
|
-
function parsePages(value, where) {
|
|
212
|
-
if (!Array.isArray(value) || value.length === 0 || value.length > GLOB_LIMITS.globsPerList) {
|
|
213
|
-
throw new FoliwakeConfigError(`${where}: a list of 1–${GLOB_LIMITS.globsPerList} page globs, such as ["/lessons/**"].`);
|
|
214
|
-
}
|
|
215
|
-
return value.map((glob, i) => {
|
|
216
|
-
const problem = typeof glob === 'string' ? globProblem(glob) : 'must be a string';
|
|
217
|
-
if (problem)
|
|
218
|
-
throw new FoliwakeConfigError(`${where}[${i}]: ${problem}.`);
|
|
219
|
-
return glob;
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
function parseApp(value, where) {
|
|
223
|
-
if (!isObject(value))
|
|
224
|
-
throw new FoliwakeConfigError(`${where}: must be an object {"pages": […], …}.`);
|
|
225
|
-
onlyKeys(value, ['pages', 'proxies', 'blocks', 'media', 'revalidate'], where);
|
|
226
|
-
const revalidate = value.revalidate === undefined ? DEFAULTS.revalidate : value.revalidate;
|
|
227
|
-
if (typeof revalidate !== 'number' || !Number.isInteger(revalidate) || revalidate < 1 || revalidate > 86_400) {
|
|
228
|
-
throw new FoliwakeConfigError(`${where}.revalidate: whole seconds between 1 and 86400.`);
|
|
229
|
-
}
|
|
230
|
-
return {
|
|
231
|
-
pages: Object.freeze(parsePages(value.pages, `${where}.pages`)),
|
|
232
|
-
proxies: parseProxies(value.proxies, `${where}.proxies`),
|
|
233
|
-
blocks: parseBlocks(value.blocks, `${where}.blocks`),
|
|
234
|
-
media: parseMedia(value.media, `${where}.media`),
|
|
235
|
-
revalidate,
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
20
|
function unsupportedVersion(file, version) {
|
|
239
|
-
|
|
21
|
+
const text = `${file}: unsupported "version" ${JSON.stringify(version)}; it must be 2.`;
|
|
22
|
+
if (version !== 3)
|
|
23
|
+
return new FoliwakeConfigError(text);
|
|
24
|
+
return new FoliwakeConfigError(`${text} Version 3 holds overrides for an app configured by FOLIWAKE_URL.`);
|
|
240
25
|
}
|
|
241
26
|
/** Parses the text of a version 2 config. Throws FoliwakeConfigError with a message that names the field. */
|
|
242
27
|
export function parseFoliwakeConfig(text, opts = {}) {
|