@foliwake/server 0.12.1 → 0.13.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 CHANGED
@@ -7,6 +7,22 @@ minor release may break; breaking changes are marked **BREAKING**.
7
7
 
8
8
  Entries are written from the changesets of each pull request (`.changeset/`, CONTRIBUTING.md), newest first.
9
9
 
10
+ ## 0.13.0
11
+
12
+ ### Patch Changes
13
+
14
+ - 13383d1: A config file may no longer name one of Foliwake's own variables as a credential. `foliwake dev --remote`
15
+ (`foliwake.remote.json` and `--remote-auth-env`) and the `@foliwake/server` config (`passwordEnv`,
16
+ `privateKeyEnv`, the hook's `secretEnv`, also of `@foliwake/next`'s revalidate handler) now apply the engine's
17
+ rule: a variable the engine reads for itself, such as `FOLIWAKE_TOKEN` (the CI key), `FOLIWAKE_ADMIN_TOKEN` or
18
+ `FOLIWAKE_AUTH_SECRET`, is refused before anything is read or sent, with a message that says to use a variable
19
+ of the site's own instead (for example `MYSITE_PREVIEW_PASSWORD`). Before, a cloned repository's
20
+ `foliwake.remote.json` could name `FOLIWAKE_TOKEN`, and `foliwake dev --remote` sent its value as the Basic
21
+ password to the origin the same file names. The site credential defaults (`FOLIWAKE_PREVIEW_TOKEN`,
22
+ `FOLIWAKE_STORAGE_*`, `FOLIWAKE_S3_*`) and a site's own `FOLIWAKE_` names (`FOLIWAKE_LIVE_PASSWORD`,
23
+ `FOLIWAKE_HOOK_SECRET`) are still accepted.
24
+ - @foliwake/blocks-contract@0.13.0
25
+
10
26
  ## 0.12.1
11
27
 
12
28
  ### Patch Changes
@@ -1,2 +1,5 @@
1
- /** Why `name` cannot name a credential, or null. Browser-exposed prefixes (NEXT_PUBLIC_, VITE_) are refused too. */
1
+ /**
2
+ * Why `name` cannot name a credential, or null: not a variable name, one of Foliwake's own variables, or a
3
+ * system or browser-exposed one (NEXT_PUBLIC_, VITE_).
4
+ */
2
5
  export declare function basicEnvNameProblem(name: unknown, what: string): string | null;
package/dist/env-names.js CHANGED
@@ -1,6 +1,10 @@
1
1
  // Which environment variable names a config may give as a credential: the engine's rule
2
2
  // (src/sites/credential-env.ts), reduced to what an app needs. The engine's CLI passes its full rule
3
3
  // (`envNameProblem`) on top of this one.
4
+ //
5
+ // A config file names both an origin and the variable whose value is sent there, so a cloned repository's
6
+ // file must not be able to name a secret of Foliwake itself (FOLIWAKE_TOKEN, the CI key): the own-prefix
7
+ // rule below is the engine's, with the engine's own list of variables.
4
8
  const NAME = /^[A-Z_][A-Z0-9_]{0,127}$/;
5
9
  const SYSTEM_NAMES = new Set([
6
10
  'PATH', 'HOME', 'USER', 'USERNAME', 'LOGNAME', 'SHELL', 'PWD', 'OLDPWD', 'TMPDIR', 'TMP', 'TEMP', 'TERM', 'TERM_PROGRAM', 'LANG', 'LANGUAGE', 'TZ',
@@ -8,12 +12,53 @@ const SYSTEM_NAMES = new Set([
8
12
  'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'ALL_PROXY', 'ENV', 'PROMPT_COMMAND', 'IFS', 'CDPATH', 'MANPATH', 'INFOPATH', 'CLASSPATH', 'SSL_CERT_FILE', 'SSL_CERT_DIR', 'CURL_CA_BUNDLE',
9
13
  ]);
10
14
  const SYSTEM_PREFIXES = ['SSH_', 'LC_', 'XDG_', 'DYLD_', 'LD_', 'GIT_', 'NODE_', 'NPM_CONFIG_', 'YARN_', 'PNPM_', 'PYTHON', 'PIP_', 'RUBY', 'GEM_', 'BUNDLE_', 'PERL5', 'PERL_', 'JAVA_', '_JAVA_', 'JDK_', 'BASH_', 'ZSH', 'DOCKER_', 'KUBE', 'SUDO_', 'GPG_', 'GNUPG', 'NEXT_PUBLIC_', 'VITE_'];
11
- /** Why `name` cannot name a credential, or null. Browser-exposed prefixes (NEXT_PUBLIC_, VITE_) are refused too. */
15
+ /** The prefix of Foliwake's own variables. */
16
+ const OWN_PREFIX = 'FOLIWAKE_';
17
+ /**
18
+ * Every variable the engine reads for itself (without the prefix): never a credential a config may name. The
19
+ * engine's site-credential defaults (FOLIWAKE_PREVIEW_TOKEN, FOLIWAKE_S3_ACCESS_KEY, …) are not in it.
20
+ */
21
+ const ENGINE_VARIABLES = new Set([
22
+ 'CREDENTIALS_DIR', 'PUBLIC_SITE_PORT', 'GOOGLE_OAUTH_CLIENT_ID', 'GOOGLE_OAUTH_CLIENT_SECRET', 'ACME_EMAIL',
23
+ 'ADMIN_CHECK_TIMEOUT_MS', 'ADMIN_DRAFTS_DIR', 'ADMIN_HIDE_LOGIN_LINK', 'ADMIN_LOCK_WAIT_MS',
24
+ 'ADMIN_OPERATION_TIMEOUT_MS', 'ADMIN_PORT', 'ADMIN_REFRESH_TIMEOUT_MS', 'ADMIN_SYNC_TIMEOUT_MS',
25
+ 'ADMIN_TIMINGS_DIR', 'ADMIN_TOKEN', 'AUTH_ADAPTER', 'AUTH_SECRET', 'CACHE_BACKEND', 'CACHE_URL', 'CACHE_VCL_OUTPUT',
26
+ 'CAPABILITY_CACHE_TTL_MS', 'CLOUD_ORIGIN', 'CONFIG', 'CONFIG_DIR', 'DATA_DIR', 'DEFAULT_BRANCH', 'DEV_LISTEN_HOST',
27
+ 'DOMAIN', 'ENGINE_REVISION', 'ENVIRONMENT', 'HISTORY_DOMAIN', 'HISTORY_PORT', 'HOST_LEDGER_DIR',
28
+ 'INTEGRATION_TIMINGS_DIR', 'KEYCHAIN_SERVICE', 'LISTEN_HOST', 'LIVE_PORT', 'LOCK_WAIT_MS', 'MAIL', 'MAIL_FROM',
29
+ 'ORIGIN_PORT', 'OWNER_EMAIL', 'PLUGINS', 'PORT', 'PREVIEW_PORT', 'PREVIEW_SECRET', 'PUBLIC_ORIGIN', 'REMOTE',
30
+ 'RESCAN_INTERVAL_MS', 'RESEND_API_KEY', 'REVIEW_HOST', 'S3_BUCKET', 'S3_ENDPOINT', 'S3_REGION', 'S3_TIMEOUT_MS',
31
+ 'SERVER', 'SITES_RECONCILE_MS', 'SETTLE_DELAY_MS', 'SOURCE_MIN_FREE_BYTES', 'STATE_DIR', 'STORAGE_BUCKET',
32
+ 'STORAGE_CREATE_BUCKETS', 'STORAGE_ENDPOINT', 'STORAGE_REGION', 'STORE_CONCURRENCY', 'TIMINGS', 'TIMINGS_FILE',
33
+ 'TOKEN', 'TRACE_ORIGIN_RATIO', 'TRACE_STORE_REQUESTS', 'TRUST_PROXY', 'WATCH_POLLING',
34
+ ]);
35
+ /** True for a variable Foliwake reads for itself, such as FOLIWAKE_TOKEN (the CI key). */
36
+ function isOwnVariable(name) {
37
+ return name.startsWith(OWN_PREFIX) && ENGINE_VARIABLES.has(name.slice(OWN_PREFIX.length));
38
+ }
39
+ /** Why `name` (a well-formed variable name) is one of Foliwake's own variables, or null. */
40
+ function ownVariableProblem(name, what) {
41
+ if (!isOwnVariable(name))
42
+ return null;
43
+ return (`${what}: ${name} is one of Foliwake's own variables, and a site credential may not be read from it ` +
44
+ '(its value would be sent to the site the configuration names). ' +
45
+ 'Use a variable of its own, such as MYSITE_PREVIEW_PASSWORD.');
46
+ }
47
+ function isSystemVariable(name) {
48
+ return SYSTEM_NAMES.has(name) || SYSTEM_PREFIXES.some((prefix) => name.startsWith(prefix));
49
+ }
50
+ /**
51
+ * Why `name` cannot name a credential, or null: not a variable name, one of Foliwake's own variables, or a
52
+ * system or browser-exposed one (NEXT_PUBLIC_, VITE_).
53
+ */
12
54
  export function basicEnvNameProblem(name, what) {
13
55
  if (typeof name !== 'string' || !NAME.test(name)) {
14
56
  return `${what}: give the NAME of an environment variable (capital letters, digits and _), not the secret itself.`;
15
57
  }
16
- if (SYSTEM_NAMES.has(name) || SYSTEM_PREFIXES.some((prefix) => name.startsWith(prefix))) {
58
+ const own = ownVariableProblem(name, what);
59
+ if (own)
60
+ return own;
61
+ if (isSystemVariable(name)) {
17
62
  return `${what}: ${name} is a system or browser-exposed variable, not a credential; use a variable of its own.`;
18
63
  }
19
64
  return null;
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // What the hook endpoint of `@foliwake/server/handler` answers a ping with: this package and its version,
2
2
  // stamped in by tools/build.mjs.
3
- export const SERVER_SDK = '@foliwake/server/0.12.1';
3
+ export const SERVER_SDK = '@foliwake/server/0.13.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foliwake/server",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "Server toolkit for apps that show Foliwake pages: config v2, origin client, envelope read, page check and preparation, code/media proxy handlers, CSP. Web Request/Response, no framework.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -92,7 +92,7 @@
92
92
  "dependencies": {
93
93
  "htmlparser2": "10.1.0",
94
94
  "jose": "6.2.15",
95
- "@foliwake/blocks-contract": "0.12.1"
95
+ "@foliwake/blocks-contract": "0.13.0"
96
96
  },
97
97
  "files": [
98
98
  "dist/",