@foliwake/server 0.10.0 → 0.11.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,34 @@ 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.11.0
11
+
12
+ ### Patch Changes
13
+
14
+ - @foliwake/blocks-contract@0.11.0
15
+
16
+ ## 0.10.2
17
+
18
+ ### Patch Changes
19
+
20
+ - 964b5e5: Links point to the public documentation on foliwake.org (`docs.foliwake.org`, `sdk.foliwake.org`); the config
21
+ schemas' `$id` is under `https://foliwake.org/schemas/`.
22
+ - Updated dependencies [964b5e5]
23
+ - @foliwake/blocks-contract@0.10.2
24
+
25
+ ## 0.10.1
26
+
27
+ ### Patch Changes
28
+
29
+ - 55ffb45: Site code may have an `editor/` folder: data that authoring tools read, such as a palette or block metadata. The
30
+ code proxy (`codeRoute` / `codeHandler`) now serves its files like the other site code, and `site-check` counts it
31
+ as site code. Pages never load it.
32
+ - 44822ad: The hook trims leading and trailing whitespace and newlines from the secret read from `secretEnv` and
33
+ `previousSecretEnv` (a secret pasted with a trailing newline used to fail every signature), warns once naming the
34
+ variable (never the value), and treats an all-whitespace value as unset. New: `hookSecretsFrom` in
35
+ `@foliwake/server/hook-endpoint`. The docs make the secret with `openssl rand -hex 32 | tr -d '\n'`.
36
+ - @foliwake/blocks-contract@0.10.1
37
+
10
38
  ## 0.10.0
11
39
 
12
40
  ### Minor Changes
package/README.md CHANGED
@@ -1351,6 +1351,16 @@ function deliveryTags(payload: FoliwakeDeliveryPayload, liveTag: (path?: string)
1351
1351
 
1352
1352
  **Returns** `string[]`
1353
1353
 
1354
+ #### `hookSecretsFrom()`
1355
+
1356
+ The `secrets()` of the hook endpoint read from environment variables: each value is trimmed of leading and trailing whitespace and newlines (a secret pasted from `openssl rand -hex 32` often ends in one), and an all-whitespace value counts as unset. The first time trimming changes a variable's value, one warning names the variable, never the value.
1357
+
1358
+ ```ts
1359
+ function hookSecretsFrom(source: HookSecretSource): () => (string | undefined)[]
1360
+ ```
1361
+
1362
+ **Returns** `() => (string \| undefined)[]`
1363
+
1354
1364
  #### `warmPaths()`
1355
1365
 
1356
1366
  The pages read again after a delivery: none on `all`, page paths only, at most WARM_LIMIT.
@@ -1396,6 +1406,20 @@ interface HookEndpointDeps
1396
1406
  | `now?` | `() => number` | |
1397
1407
  | `log` | `Pick<Console, 'warn' \| 'error'>` | |
1398
1408
 
1409
+ #### `HookSecretSource`
1410
+
1411
+ Where `hookSecretsFrom` reads and what it warns on.
1412
+
1413
+ ```ts
1414
+ interface HookSecretSource
1415
+ ```
1416
+
1417
+ | Member | Type | Description |
1418
+ | --- | --- | --- |
1419
+ | `names` | `readonly (string \| undefined)[]` | The variables, current first, then the previous one while it is rotated; undefined entries are skipped. |
1420
+ | `env?` | `NodeJS.ProcessEnv` | Where the variables are read, per call; default process.env. |
1421
+ | `log` | `Pick<Console, 'warn'>` | |
1422
+
1399
1423
  ### `@foliwake/server/discovery`
1400
1424
 
1401
1425
  **Functions and components**
@@ -4,7 +4,10 @@ export declare const CODE_ID_PATTERN: RegExp;
4
4
  export declare const CODE_FILE_TYPES: Readonly<Record<string, string>>;
5
5
  /** The sandbox an SVG code file is served with (release-formats `codeFileHeaders('.svg')`). */
6
6
  export declare const SVG_CODE_CSP = "default-src 'none'; style-src 'unsafe-inline'; img-src data:; sandbox";
7
- /** First segments of a path inside a code release the proxy serves. */
7
+ /**
8
+ * First segments of a path inside a code release the proxy serves. `editor/` holds data authoring tools read (a
9
+ * palette, block metadata); pages never load it, but it is served like the other site code.
10
+ */
8
11
  export declare const CODE_ROOTS: readonly string[];
9
12
  /**
10
13
  * A media key as the engine writes it: `<sha256>.<ext>`, images only. SVG (refused in 0.1) since 2026-11-16: the
package/dist/constants.js CHANGED
@@ -21,8 +21,11 @@ export const CODE_FILE_TYPES = Object.freeze({
21
21
  });
22
22
  /** The sandbox an SVG code file is served with (release-formats `codeFileHeaders('.svg')`). */
23
23
  export const SVG_CODE_CSP = "default-src 'none'; style-src 'unsafe-inline'; img-src data:; sandbox";
24
- /** First segments of a path inside a code release the proxy serves. */
25
- export const CODE_ROOTS = Object.freeze(['components', 'scripts', 'styles', '_foliwake']);
24
+ /**
25
+ * First segments of a path inside a code release the proxy serves. `editor/` holds data authoring tools read (a
26
+ * palette, block metadata); pages never load it, but it is served like the other site code.
27
+ */
28
+ export const CODE_ROOTS = Object.freeze(['components', 'scripts', 'styles', 'editor', '_foliwake']);
26
29
  /**
27
30
  * A media key as the engine writes it: `<sha256>.<ext>`, images only. SVG (refused in 0.1) since 2026-11-16: the
28
31
  * engine's inline reference images (content-components.md §3.7), served with SVG_CODE_CSP like a code SVG.
package/dist/handler.js CHANGED
@@ -10,7 +10,7 @@
10
10
  import { checkEnvName } from './config.js';
11
11
  import { PREFIX } from './config-parts.js';
12
12
  import { codeHandler, mediaHandler } from './handlers.js';
13
- import { createHookEndpoint } from './hook-endpoint.js';
13
+ import { createHookEndpoint, hookSecretsFrom } from './hook-endpoint.js';
14
14
  import { createOriginClient } from './origin.js';
15
15
  import { loadAppConfig } from './resolve.js';
16
16
  import { SERVER_SDK } from './version.js';
@@ -74,7 +74,7 @@ function defaultHook(config, opts, hook) {
74
74
  return createHookEndpoint({
75
75
  site: config.site,
76
76
  sdk: SERVER_SDK,
77
- secrets: () => [env[secretEnv], hook.previousSecretEnv && env[hook.previousSecretEnv]],
77
+ secrets: hookSecretsFrom({ names: [secretEnv, hook.previousSecretEnv], env, log }),
78
78
  liveTag: (path) => `foliwake:${config.site}:live${path === undefined ? '' : `:page:${path}`}`,
79
79
  expire: () => { },
80
80
  warm: async () => { },
@@ -24,6 +24,21 @@ export interface HookEndpointDeps {
24
24
  now?: () => number;
25
25
  log: Pick<Console, 'warn' | 'error'>;
26
26
  }
27
+ /** Where `hookSecretsFrom` reads and what it warns on. */
28
+ export interface HookSecretSource {
29
+ /** The variables, current first, then the previous one while it is rotated; undefined entries are skipped. */
30
+ names: readonly (string | undefined)[];
31
+ /** Where the variables are read, per call; default process.env. */
32
+ env?: NodeJS.ProcessEnv;
33
+ log: Pick<Console, 'warn'>;
34
+ }
35
+ /**
36
+ * The `secrets()` of the hook endpoint read from environment variables: each value is trimmed of leading and
37
+ * trailing whitespace and newlines (a secret pasted from `openssl rand -hex 32` often ends in one), and an
38
+ * all-whitespace value counts as unset. The first time trimming changes a variable's value, one warning names
39
+ * the variable, never the value.
40
+ */
41
+ export declare function hookSecretsFrom(source: HookSecretSource): () => (string | undefined)[];
27
42
  /** The tags a delivery expires: the site's live tag on `all`, else one tag per listed path. */
28
43
  export declare function deliveryTags(payload: FoliwakeDeliveryPayload, liveTag: (path?: string) => string): string[];
29
44
  /** The pages read again after a delivery: none on `all`, page paths only, at most WARM_LIMIT. */
@@ -4,6 +4,30 @@
4
4
  import { FoliwakeHookError, HOOK_BODY_LIMIT, isFoliwakePagePath, parseFoliwakeHook, verifyFoliwakeSignature, } from './hook.js';
5
5
  /** At most this many pages are read again right after a delivery (`warm`); never on `all`. */
6
6
  export const WARM_LIMIT = 20;
7
+ /** The value with surrounding whitespace removed; an all-whitespace value is unset. */
8
+ function trimmedSecret(value) {
9
+ const trimmed = value?.trim();
10
+ return trimmed ? trimmed : undefined;
11
+ }
12
+ /**
13
+ * The `secrets()` of the hook endpoint read from environment variables: each value is trimmed of leading and
14
+ * trailing whitespace and newlines (a secret pasted from `openssl rand -hex 32` often ends in one), and an
15
+ * all-whitespace value counts as unset. The first time trimming changes a variable's value, one warning names
16
+ * the variable, never the value.
17
+ */
18
+ export function hookSecretsFrom(source) {
19
+ const warned = new Set();
20
+ const read = (name) => {
21
+ const raw = (source.env ?? process.env)[name];
22
+ const secret = trimmedSecret(raw);
23
+ if (raw !== undefined && raw !== secret && !warned.has(name)) {
24
+ warned.add(name);
25
+ source.log.warn(`[foliwake] hook: ${name} has surrounding whitespace; it is trimmed. Store it without.`);
26
+ }
27
+ return secret;
28
+ };
29
+ return () => source.names.map((name) => (name ? read(name) : undefined));
30
+ }
7
31
  class TooLarge extends Error {
8
32
  }
9
33
  function answer(status, body) {
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.10.0';
3
+ export const SERVER_SDK = '@foliwake/server/0.11.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foliwake/server",
3
- "version": "0.10.0",
3
+ "version": "0.11.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",
@@ -13,7 +13,7 @@
13
13
  "url": "git+https://github.com/foliwake/foliwake-js.git",
14
14
  "directory": "packages/server"
15
15
  },
16
- "homepage": "https://sdk.foliwake.dev/reference/packages/server",
16
+ "homepage": "https://sdk.foliwake.org/reference/packages/server",
17
17
  "bugs": {
18
18
  "url": "https://github.com/foliwake/foliwake-js/issues"
19
19
  },
@@ -92,7 +92,7 @@
92
92
  "dependencies": {
93
93
  "htmlparser2": "10.1.0",
94
94
  "jose": "6.2.15",
95
- "@foliwake/blocks-contract": "0.10.0"
95
+ "@foliwake/blocks-contract": "0.11.0"
96
96
  },
97
97
  "files": [
98
98
  "dist/",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://foliwake.dev/schemas/remote-2.schema.json",
3
+ "$id": "https://foliwake.org/schemas/remote-2.schema.json",
4
4
  "title": "foliwake.remote.json version 2",
5
5
  "description": "Which Foliwake site an app (or `foliwake dev --remote`) reads, the NAMES of the variables holding its credentials, and the app's settings. No secrets: values are read from the environment on the server. The TypeScript parser (@foliwake/server/config) is the authority; test/packages/server-config-schema.test.js keeps both in step.",
6
6
  "type": "object",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://foliwake.dev/schemas/remote-3.schema.json",
3
+ "$id": "https://foliwake.org/schemas/remote-3.schema.json",
4
4
  "title": "foliwake.remote.json version 3",
5
5
  "description": "Optional overrides of an app configured by FOLIWAKE_URL: the site's discovery document (/.well-known/foliwake.json) gives its origins and media CDN; this file holds the app's own settings and the NAMES of the variables holding credentials. No secrets. The TypeScript parser (@foliwake/server/resolve) is the authority; test/server-config-v3.test.js keeps both in step.",
6
6
  "type": "object",