@foliwake/server 0.0.0-stage → 0.4.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/package.json CHANGED
@@ -1,6 +1,85 @@
1
1
  {
2
2
  "name": "@foliwake/server",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.4.0",
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
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "engines": {
9
+ "node": ">=22.22"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/foliwake/foliwake-js.git",
14
+ "directory": "packages/server"
15
+ },
16
+ "homepage": "https://docs.foliwake.dev/reference/packages/server",
17
+ "bugs": {
18
+ "url": "https://github.com/foliwake/foliwake-js/issues"
19
+ },
20
+ "keywords": [
21
+ "foliwake",
22
+ "cms",
23
+ "headless",
24
+ "blocks",
25
+ "server",
26
+ "csp",
27
+ "fetch"
28
+ ],
29
+ "publishConfig": {
30
+ "access": "public",
31
+ "provenance": true
32
+ },
33
+ "foliwake": {
34
+ "plain": 2,
35
+ "blocksContract": 2,
36
+ "remoteConfig": 2
37
+ },
38
+ "exports": {
39
+ "./config": {
40
+ "types": "./dist/config.d.ts",
41
+ "default": "./dist/config.js"
42
+ },
43
+ "./origin": {
44
+ "types": "./dist/origin.d.ts",
45
+ "default": "./dist/origin.js"
46
+ },
47
+ "./page": {
48
+ "types": "./dist/page.d.ts",
49
+ "default": "./dist/page.js"
50
+ },
51
+ "./handlers": {
52
+ "types": "./dist/handlers.d.ts",
53
+ "default": "./dist/handlers.js"
54
+ },
55
+ "./html": {
56
+ "types": "./dist/html.d.ts",
57
+ "default": "./dist/html.js"
58
+ },
59
+ "./csp": {
60
+ "types": "./dist/csp.d.ts",
61
+ "default": "./dist/csp.js"
62
+ },
63
+ "./preload": {
64
+ "types": "./dist/preload.d.ts",
65
+ "default": "./dist/preload.js"
66
+ },
67
+ "./schemas/remote-2.schema.json": "./schemas/remote-2.schema.json",
68
+ "./package.json": "./package.json"
69
+ },
70
+ "dependencies": {
71
+ "htmlparser2": "10.1.0",
72
+ "jose": "6.2.15",
73
+ "@foliwake/blocks-contract": "0.4.0"
74
+ },
75
+ "files": [
76
+ "dist/",
77
+ "!dist/**/*.map",
78
+ "!dist/.build-stamp",
79
+ "!dist/.build-manifest.json",
80
+ "schemas/",
81
+ "LICENSE",
82
+ "README.md",
83
+ "CHANGELOG.md"
84
+ ]
6
85
  }
@@ -0,0 +1,110 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://foliwake.dev/schemas/remote-2.schema.json",
4
+ "title": "foliwake.remote.json version 2",
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
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["version", "site"],
9
+ "anyOf": [{ "required": ["live"] }, { "required": ["preview"] }],
10
+ "properties": {
11
+ "$schema": { "type": "string" },
12
+ "$comment": { "type": "string" },
13
+ "version": { "const": 2 },
14
+ "site": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,62}$" },
15
+ "live": { "$ref": "#/$defs/endpoint" },
16
+ "preview": { "$ref": "#/$defs/endpoint" },
17
+ "app": {
18
+ "type": "object",
19
+ "additionalProperties": false,
20
+ "required": ["pages"],
21
+ "properties": {
22
+ "pages": {
23
+ "description": "Page globs the app may read (query-index grammar: [a-z0-9_-] literals, * within a segment, ** as a whole segment; /x/** also matches /x).",
24
+ "type": "array", "minItems": 1, "maxItems": 20,
25
+ "items": { "type": "string", "maxLength": 200, "pattern": "^/(?:(?:\\*\\*|[a-z0-9_*-]+)(?:/(?:\\*\\*|[a-z0-9_*-]+))*)?$" }
26
+ },
27
+ "proxies": {
28
+ "description": "App-origin URL prefixes of the proxies. Not /, /_next, /api, /code, /media or below them; code and media differ and neither is inside the other.",
29
+ "type": "object", "additionalProperties": false,
30
+ "properties": {
31
+ "code": { "$ref": "#/$defs/prefix", "default": "/foliwake-code" },
32
+ "media": { "$ref": "#/$defs/prefix", "default": "/foliwake-media" },
33
+ "pages": { "type": "null" }
34
+ }
35
+ },
36
+ "blocks": {
37
+ "type": "object", "additionalProperties": false,
38
+ "properties": {
39
+ "entry": {
40
+ "description": "Path of the blocks module inside a code release; absent or null: bodies stay static.",
41
+ "type": ["string", "null"],
42
+ "pattern": "^(?:scripts|components|_foliwake)(?:/[A-Za-z0-9_][A-Za-z0-9_.-]*){1,7}\\.js$"
43
+ },
44
+ "contract": { "type": "string", "pattern": "^foliwake-blocks/[1-9][0-9]{0,2}$", "default": "foliwake-blocks/2" },
45
+ "eventPrefix": { "type": "string", "pattern": "^[a-z][a-z0-9-]{0,31}$", "default": "block" }
46
+ }
47
+ },
48
+ "media": {
49
+ "description": "Live pictures through a transforming host (preview pictures always go through the media proxy).",
50
+ "type": ["object", "null"], "additionalProperties": false, "required": ["base"],
51
+ "properties": {
52
+ "base": { "type": "string", "pattern": "^https://[^/?#@]+$" },
53
+ "transform": { "enum": ["cloudflare-images", null] }
54
+ }
55
+ },
56
+ "revalidate": { "description": "Seconds before a cached envelope is stale (stale-while-revalidate; expire is 24 h).", "type": "integer", "minimum": 1, "maximum": 86400, "default": 300 }
57
+ }
58
+ }
59
+ },
60
+ "$defs": {
61
+ "prefix": { "type": "string", "pattern": "^(?:/[a-z0-9-]+)+$" },
62
+ "basicAuth": {
63
+ "type": "object", "additionalProperties": false, "required": ["type", "username", "passwordEnv"],
64
+ "properties": {
65
+ "type": { "const": "basic" },
66
+ "username": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[^:\\u0000-\\u001f\\u007f]+$" },
67
+ "passwordEnv": {
68
+ "type": "string",
69
+ "pattern": "^[A-Z_][A-Z0-9_]{0,127}$",
70
+ "description": "The NAME of the environment variable holding the password."
71
+ }
72
+ }
73
+ },
74
+ "serviceTokenAuth": {
75
+ "description": "Each request carries a fresh ES256 JWT for its exact path (exp = iat + 60), signed with the private key in privateKeyEnv; the delivery checks it with the public key of kid.",
76
+ "type": "object", "additionalProperties": false, "required": ["type", "issuer", "kid", "privateKeyEnv"],
77
+ "properties": {
78
+ "type": { "const": "service-token" },
79
+ "issuer": {
80
+ "type": "string",
81
+ "pattern": "^[A-Za-z0-9._:/-]{1,256}$",
82
+ "description": "The iss the delivery expects (its TOKEN_ISSUER)."
83
+ },
84
+ "kid": {
85
+ "type": "string",
86
+ "pattern": "^[A-Za-z0-9._-]{1,128}$",
87
+ "description": "The key id of the public key the delivery holds."
88
+ },
89
+ "privateKeyEnv": {
90
+ "type": "string",
91
+ "pattern": "^[A-Z_][A-Z0-9_]{0,127}$",
92
+ "description": "The NAME of the environment variable holding the ES256 private key as JWK JSON text."
93
+ }
94
+ }
95
+ },
96
+ "endpoint": {
97
+ "type": "object", "additionalProperties": false, "required": ["url"],
98
+ "properties": {
99
+ "url": { "type": "string", "description": "Site origin only: https (http only for loopback hosts), no credentials, path, query or fragment." },
100
+ "auth": {
101
+ "oneOf": [
102
+ { "type": "null" },
103
+ { "$ref": "#/$defs/basicAuth" },
104
+ { "$ref": "#/$defs/serviceTokenAuth" }
105
+ ]
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }