@caelo-cms/shared 0.11.8 → 0.11.10

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.
Files changed (134) hide show
  1. package/certs/aws-rds-global.pem +2888 -0
  2. package/certs/cloudsql-global.pem +1897 -0
  3. package/dist/ai-tools.d.ts +2 -2
  4. package/dist/body-cap.d.ts +35 -0
  5. package/dist/body-cap.d.ts.map +1 -0
  6. package/dist/body-cap.js +63 -0
  7. package/dist/body-cap.js.map +1 -0
  8. package/dist/build-page.d.ts +4 -4
  9. package/dist/change-journal.d.ts.map +1 -1
  10. package/dist/change-journal.js +1 -0
  11. package/dist/change-journal.js.map +1 -1
  12. package/dist/client-address.d.ts +69 -0
  13. package/dist/client-address.d.ts.map +1 -0
  14. package/dist/client-address.js +99 -0
  15. package/dist/client-address.js.map +1 -0
  16. package/dist/content.d.ts +6 -6
  17. package/dist/content.d.ts.map +1 -1
  18. package/dist/content.js +8 -1
  19. package/dist/content.js.map +1 -1
  20. package/dist/context.d.ts +8 -0
  21. package/dist/context.d.ts.map +1 -1
  22. package/dist/database-tls.d.ts +64 -0
  23. package/dist/database-tls.d.ts.map +1 -0
  24. package/dist/database-tls.js +95 -0
  25. package/dist/database-tls.js.map +1 -0
  26. package/dist/database-url.d.ts +2 -15
  27. package/dist/database-url.d.ts.map +1 -1
  28. package/dist/database-url.js +14 -1
  29. package/dist/database-url.js.map +1 -1
  30. package/dist/index.d.ts +7 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +7 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/interim-forwarded-host.d.ts +15 -0
  35. package/dist/interim-forwarded-host.d.ts.map +1 -0
  36. package/dist/interim-forwarded-host.js +16 -0
  37. package/dist/interim-forwarded-host.js.map +1 -0
  38. package/dist/json-security-headers.d.ts +23 -0
  39. package/dist/json-security-headers.d.ts.map +1 -0
  40. package/dist/json-security-headers.js +53 -0
  41. package/dist/json-security-headers.js.map +1 -0
  42. package/dist/lists/fields.d.ts +6 -0
  43. package/dist/lists/fields.d.ts.map +1 -1
  44. package/dist/lists/fields.js +70 -7
  45. package/dist/lists/fields.js.map +1 -1
  46. package/dist/lists/index.d.ts +1 -0
  47. package/dist/lists/index.d.ts.map +1 -1
  48. package/dist/lists/index.js +1 -0
  49. package/dist/lists/index.js.map +1 -1
  50. package/dist/lists/list-type.d.ts +28 -6
  51. package/dist/lists/list-type.d.ts.map +1 -1
  52. package/dist/lists/list-type.js +43 -15
  53. package/dist/lists/list-type.js.map +1 -1
  54. package/dist/lists/overlay-scope.d.ts +68 -0
  55. package/dist/lists/overlay-scope.d.ts.map +1 -0
  56. package/dist/lists/overlay-scope.js +56 -0
  57. package/dist/lists/overlay-scope.js.map +1 -0
  58. package/dist/lists/query-merge.d.ts +27 -0
  59. package/dist/lists/query-merge.d.ts.map +1 -0
  60. package/dist/lists/query-merge.js +53 -0
  61. package/dist/lists/query-merge.js.map +1 -0
  62. package/dist/lists/resolve.d.ts +1 -0
  63. package/dist/lists/resolve.d.ts.map +1 -1
  64. package/dist/lists/resolve.js +11 -25
  65. package/dist/lists/resolve.js.map +1 -1
  66. package/dist/lists/scope.d.ts +4 -1
  67. package/dist/lists/scope.d.ts.map +1 -1
  68. package/dist/pool-budget.d.ts +10 -0
  69. package/dist/pool-budget.d.ts.map +1 -1
  70. package/dist/pool-budget.js +15 -0
  71. package/dist/pool-budget.js.map +1 -1
  72. package/dist/redirect-emit-gcp.d.ts +16 -8
  73. package/dist/redirect-emit-gcp.d.ts.map +1 -1
  74. package/dist/redirect-emit-gcp.js +22 -11
  75. package/dist/redirect-emit-gcp.js.map +1 -1
  76. package/dist/release-manifest.d.ts +18 -2
  77. package/dist/release-manifest.d.ts.map +1 -1
  78. package/dist/release-manifest.js +32 -4
  79. package/dist/release-manifest.js.map +1 -1
  80. package/dist/session-cookie.d.ts +88 -0
  81. package/dist/session-cookie.d.ts.map +1 -0
  82. package/dist/session-cookie.js +151 -0
  83. package/dist/session-cookie.js.map +1 -0
  84. package/dist/staging-plugin-stub.d.ts +28 -0
  85. package/dist/staging-plugin-stub.d.ts.map +1 -0
  86. package/dist/staging-plugin-stub.js +34 -0
  87. package/dist/staging-plugin-stub.js.map +1 -0
  88. package/dist/template-engine.d.ts.map +1 -1
  89. package/dist/template-engine.js +4 -1
  90. package/dist/template-engine.js.map +1 -1
  91. package/dist/version.d.ts +2 -2
  92. package/dist/version.d.ts.map +1 -1
  93. package/dist/version.js +1 -1
  94. package/dist/version.js.map +1 -1
  95. package/package.json +2 -1
  96. package/src/body-cap.test.ts +44 -0
  97. package/src/body-cap.ts +83 -0
  98. package/src/change-journal.ts +1 -0
  99. package/src/client-address.test.ts +90 -0
  100. package/src/client-address.ts +111 -0
  101. package/src/content.test.ts +54 -0
  102. package/src/content.ts +10 -1
  103. package/src/context.ts +8 -0
  104. package/src/database-tls.test.ts +83 -0
  105. package/src/database-tls.ts +99 -0
  106. package/src/database-url.test.ts +49 -11
  107. package/src/database-url.ts +21 -1
  108. package/src/index.ts +7 -0
  109. package/src/interim-forwarded-host.ts +16 -0
  110. package/src/json-security-headers.test.ts +31 -0
  111. package/src/json-security-headers.ts +53 -0
  112. package/src/lists/fields.ts +88 -7
  113. package/src/lists/index.ts +1 -0
  114. package/src/lists/list-type.ts +53 -18
  115. package/src/lists/lists.test.ts +70 -0
  116. package/src/lists/overlay-scope.test.ts +140 -0
  117. package/src/lists/overlay-scope.ts +120 -0
  118. package/src/lists/pagination.test.ts +15 -0
  119. package/src/lists/query-merge.ts +84 -0
  120. package/src/lists/resolve.test.ts +24 -4
  121. package/src/lists/resolve.ts +12 -33
  122. package/src/lists/scope.ts +4 -2
  123. package/src/pool-budget.test.ts +17 -3
  124. package/src/pool-budget.ts +19 -0
  125. package/src/redirect-emit-gcp.ts +24 -11
  126. package/src/redirect-emit.test.ts +6 -5
  127. package/src/release-manifest.ts +33 -4
  128. package/src/session-cookie.test.ts +96 -0
  129. package/src/session-cookie.ts +163 -0
  130. package/src/staging-plugin-stub.test.ts +23 -0
  131. package/src/staging-plugin-stub.ts +37 -0
  132. package/src/template-engine-lists.test.ts +27 -1
  133. package/src/template-engine.ts +4 -1
  134. package/src/version.ts +1 -1
@@ -0,0 +1,64 @@
1
+ /**
2
+ * TLS of every database connection (#1338, gateway hardening L6).
3
+ *
4
+ * Every connection to a database on another machine uses
5
+ * `sslmode=verify-full`: the server's certificate must chain to a CA the
6
+ * install trusts AND name the host the client dialled. `sslmode=require`
7
+ * (what every provider used before) encrypts but checks neither, so anyone
8
+ * who can answer on the database's address can read the passwords and the
9
+ * data. There is no weaker mode for a remote host and no automatic downgrade
10
+ * (CLAUDE.md §2, no fallbacks): a URL that asks for less is refused with
11
+ * {@link databaseTlsProblem} wherever a process reads one from its
12
+ * environment (`databaseUrlFromEnv`).
13
+ *
14
+ * Which CA each provider's server presents, and so which bundle the client
15
+ * passes as `sslrootcert`:
16
+ *
17
+ * - gcp / gcp-firebase: Cloud SQL with the shared CA
18
+ * (`GOOGLE_MANAGED_CAS_CA`); its server certificate names the instance's
19
+ * DNS name, not its IP, so clients dial that name (resolved by a private
20
+ * Cloud DNS zone in the install's VPC) and trust Google's published root
21
+ * + regional bundle ({@link CLOUD_SQL_CA_BUNDLE}).
22
+ * - aws: RDS, the endpoint host name, Amazon's RDS bundle
23
+ * ({@link AWS_RDS_CA_BUNDLE}).
24
+ * - azure: Flexible Server, the server's FQDN; its certificate chains to
25
+ * public roots (DigiCert Global Root G2 / Microsoft RSA Root CA 2017)
26
+ * that Bun trusts out of the box, so no `sslrootcert`.
27
+ * - self-hosted: the compose Postgres serves a certificate for the host
28
+ * name `postgres`, signed by a CA the installer generates once per
29
+ * install ({@link SELF_HOSTED_CA_FILE}).
30
+ *
31
+ * The bundles ship in every image at {@link DATABASE_CA_DIR}
32
+ * (packages/shared/certs/ in the repo), so a URL built on the operator's
33
+ * machine names a path that exists in the container.
34
+ *
35
+ * Pure module — no I/O.
36
+ */
37
+ /** Where every Caelo image carries the database CA bundles (copied from packages/shared/certs/). */
38
+ export declare const DATABASE_CA_DIR = "/etc/caelo/db-ca";
39
+ /** Google's Cloud SQL shared-CA bundle (all regions), `cloudsql-ca-bundles/global.pem`. */
40
+ export declare const CLOUD_SQL_CA_BUNDLE = "/etc/caelo/db-ca/cloudsql-global.pem";
41
+ /** Amazon's RDS bundle (all regions), `truststore.pki.rds.amazonaws.com/global/global-bundle.pem`. */
42
+ export declare const AWS_RDS_CA_BUNDLE = "/etc/caelo/db-ca/aws-rds-global.pem";
43
+ /** The self-hosted install's own CA, mounted read-only into every container that connects. */
44
+ export declare const SELF_HOSTED_CA_FILE = "/etc/caelo/db-ca/self-hosted-ca.pem";
45
+ /**
46
+ * The query string of a verify-full connection, with `caFile` as the trust
47
+ * anchor (omit it for a server whose chain ends in a public root).
48
+ *
49
+ * @example
50
+ * verifyFullQuery(CLOUD_SQL_CA_BUNDLE)
51
+ * // → "sslmode=verify-full&sslrootcert=/etc/caelo/db-ca/cloudsql-global.pem"
52
+ */
53
+ export declare function verifyFullQuery(caFile?: string): string;
54
+ /** Whether `host` is an IPv4 or IPv6 literal (with or without URL brackets). */
55
+ export declare function isIpLiteral(host: string): boolean;
56
+ /**
57
+ * Why `url` may not be used to reach a database, or null when it may: a
58
+ * remote host needs `sslmode=verify-full`. Loopback hosts and unix sockets
59
+ * (`?host=/path`) are exempt. The message names the variable and the fix.
60
+ *
61
+ * @param label how the URL is known to the operator, e.g. `ADMIN_DATABASE_URL`
62
+ */
63
+ export declare function databaseTlsProblem(url: string, label?: string): string | null;
64
+ //# sourceMappingURL=database-tls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database-tls.d.ts","sourceRoot":"","sources":["../src/database-tls.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,oGAAoG;AACpG,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD,2FAA2F;AAC3F,eAAO,MAAM,mBAAmB,yCAA2C,CAAC;AAE5E,sGAAsG;AACtG,eAAO,MAAM,iBAAiB,wCAA0C,CAAC;AAEzE,8FAA8F;AAC9F,eAAO,MAAM,mBAAmB,wCAA0C,CAAC;AAE3E;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGjD;AAWD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAiB,GAAG,MAAM,GAAG,IAAI,CAarF"}
@@ -0,0 +1,95 @@
1
+ // SPDX-License-Identifier: MPL-2.0
2
+ /**
3
+ * TLS of every database connection (#1338, gateway hardening L6).
4
+ *
5
+ * Every connection to a database on another machine uses
6
+ * `sslmode=verify-full`: the server's certificate must chain to a CA the
7
+ * install trusts AND name the host the client dialled. `sslmode=require`
8
+ * (what every provider used before) encrypts but checks neither, so anyone
9
+ * who can answer on the database's address can read the passwords and the
10
+ * data. There is no weaker mode for a remote host and no automatic downgrade
11
+ * (CLAUDE.md §2, no fallbacks): a URL that asks for less is refused with
12
+ * {@link databaseTlsProblem} wherever a process reads one from its
13
+ * environment (`databaseUrlFromEnv`).
14
+ *
15
+ * Which CA each provider's server presents, and so which bundle the client
16
+ * passes as `sslrootcert`:
17
+ *
18
+ * - gcp / gcp-firebase: Cloud SQL with the shared CA
19
+ * (`GOOGLE_MANAGED_CAS_CA`); its server certificate names the instance's
20
+ * DNS name, not its IP, so clients dial that name (resolved by a private
21
+ * Cloud DNS zone in the install's VPC) and trust Google's published root
22
+ * + regional bundle ({@link CLOUD_SQL_CA_BUNDLE}).
23
+ * - aws: RDS, the endpoint host name, Amazon's RDS bundle
24
+ * ({@link AWS_RDS_CA_BUNDLE}).
25
+ * - azure: Flexible Server, the server's FQDN; its certificate chains to
26
+ * public roots (DigiCert Global Root G2 / Microsoft RSA Root CA 2017)
27
+ * that Bun trusts out of the box, so no `sslrootcert`.
28
+ * - self-hosted: the compose Postgres serves a certificate for the host
29
+ * name `postgres`, signed by a CA the installer generates once per
30
+ * install ({@link SELF_HOSTED_CA_FILE}).
31
+ *
32
+ * The bundles ship in every image at {@link DATABASE_CA_DIR}
33
+ * (packages/shared/certs/ in the repo), so a URL built on the operator's
34
+ * machine names a path that exists in the container.
35
+ *
36
+ * Pure module — no I/O.
37
+ */
38
+ /** Where every Caelo image carries the database CA bundles (copied from packages/shared/certs/). */
39
+ export const DATABASE_CA_DIR = "/etc/caelo/db-ca";
40
+ /** Google's Cloud SQL shared-CA bundle (all regions), `cloudsql-ca-bundles/global.pem`. */
41
+ export const CLOUD_SQL_CA_BUNDLE = `${DATABASE_CA_DIR}/cloudsql-global.pem`;
42
+ /** Amazon's RDS bundle (all regions), `truststore.pki.rds.amazonaws.com/global/global-bundle.pem`. */
43
+ export const AWS_RDS_CA_BUNDLE = `${DATABASE_CA_DIR}/aws-rds-global.pem`;
44
+ /** The self-hosted install's own CA, mounted read-only into every container that connects. */
45
+ export const SELF_HOSTED_CA_FILE = `${DATABASE_CA_DIR}/self-hosted-ca.pem`;
46
+ /**
47
+ * The query string of a verify-full connection, with `caFile` as the trust
48
+ * anchor (omit it for a server whose chain ends in a public root).
49
+ *
50
+ * @example
51
+ * verifyFullQuery(CLOUD_SQL_CA_BUNDLE)
52
+ * // → "sslmode=verify-full&sslrootcert=/etc/caelo/db-ca/cloudsql-global.pem"
53
+ */
54
+ export function verifyFullQuery(caFile) {
55
+ return caFile ? `sslmode=verify-full&sslrootcert=${caFile}` : "sslmode=verify-full";
56
+ }
57
+ /** Whether `host` is an IPv4 or IPv6 literal (with or without URL brackets). */
58
+ export function isIpLiteral(host) {
59
+ const h = host.replace(/^\[|\]$/g, "");
60
+ return /^\d{1,3}(\.\d{1,3}){3}$/.test(h) || (h.includes(":") && /^[0-9a-f:.]+$/i.test(h));
61
+ }
62
+ /**
63
+ * Hosts on this machine: a connection to them never crosses a network, so
64
+ * dev, CI and the test suites connect without TLS.
65
+ */
66
+ function isLoopbackHost(host) {
67
+ const h = host.replace(/^\[|\]$/g, "").toLowerCase();
68
+ return h === "localhost" || h === "::1" || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(h);
69
+ }
70
+ /**
71
+ * Why `url` may not be used to reach a database, or null when it may: a
72
+ * remote host needs `sslmode=verify-full`. Loopback hosts and unix sockets
73
+ * (`?host=/path`) are exempt. The message names the variable and the fix.
74
+ *
75
+ * @param label how the URL is known to the operator, e.g. `ADMIN_DATABASE_URL`
76
+ */
77
+ export function databaseTlsProblem(url, label = "database URL") {
78
+ let parsed;
79
+ try {
80
+ parsed = new URL(url);
81
+ }
82
+ catch {
83
+ return `${label} is not a valid URL`;
84
+ }
85
+ const socket = parsed.searchParams.get("host");
86
+ if (socket?.startsWith("/"))
87
+ return null;
88
+ if (parsed.hostname === "" || isLoopbackHost(parsed.hostname))
89
+ return null;
90
+ const mode = parsed.searchParams.get("sslmode");
91
+ if (mode === "verify-full")
92
+ return null;
93
+ return `${label} reaches ${parsed.hostname} with sslmode=${mode ?? "(none)"}; every connection to a database on another machine must use sslmode=verify-full, which checks the server's certificate and host name (#1338). Cloud and self-hosted installs: run \`cms-provision upgrade\` (it sets the URLs and the database's certificate up). Local development: connect to localhost.`;
94
+ }
95
+ //# sourceMappingURL=database-tls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database-tls.js","sourceRoot":"","sources":["../src/database-tls.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,oGAAoG;AACpG,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAElD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,eAAe,sBAAsB,CAAC;AAE5E,sGAAsG;AACtG,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,eAAe,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,QAAQ,KAAK,EAAE,IAAI,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3E,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAChD,IAAI,IAAI,KAAK,aAAa;QAAE,OAAO,IAAI,CAAC;IACxC,OAAO,GAAG,KAAK,YAAY,MAAM,CAAC,QAAQ,iBAAiB,IAAI,IAAI,QAAQ,6SAA6S,CAAC;AAC3X,CAAC"}
@@ -1,18 +1,3 @@
1
- /**
2
- * Database connection URLs as every Caelo process reads them from its
3
- * environment.
4
- *
5
- * A URL var (`ADMIN_DATABASE_URL`, `PUBLIC_ADMIN_DATABASE_URL`,
6
- * `PUBLIC_DATABASE_URL`) may carry its password inline — the shape the
7
- * self-hosted compose stack, CI and `.env` use — or leave it out and have
8
- * the password come from a companion `<NAME>_PASSWORD` var
9
- * (`ADMIN_DATABASE_URL` → `ADMIN_DATABASE_PASSWORD`). Cloud installs use the
10
- * second shape: the URL (host, role, database) is a plain env var, the
11
- * password is a Secret Manager reference, so the password never shows up in
12
- * the service's configuration or its revision history.
13
- *
14
- * Pure module — no I/O.
15
- */
16
1
  /** The `<NAME>_PASSWORD` var that pairs with a `<NAME>_URL` var. */
17
2
  export declare function databasePasswordVar(urlVar: string): string;
18
3
  /**
@@ -40,6 +25,8 @@ export declare function databaseUrlFromEnv(urlVars: readonly string[], env?: Rea
40
25
  * how the in-cloud jobs (the operator-access sync job, the upgrader job)
41
26
  * connect: the user is the service account email without
42
27
  * `.gserviceaccount.com`, the password a short-lived OAuth access token.
28
+ * TLS is verify-full against Google's Cloud SQL shared-CA bundle, so `host`
29
+ * must be the instance's DNS name (its certificate names no IP).
43
30
  *
44
31
  * @example
45
32
  * cloudSqlIamDatabaseUrls("10.0.0.3", "job@p.iam.gserviceaccount.com", "ya29.x").user
@@ -1 +1 @@
1
- {"version":3,"file":"database-url.d.ts","sourceRoot":"","sources":["../src/database-url.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AAEH,oEAAoE;AACpE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAK1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,KAAK,SAAiB,GACrB,MAAM,CAoBR;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,GAAG,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAe,GAC9D,MAAM,GAAG,SAAS,CASpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,MAAM,GAClB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAKjD"}
1
+ {"version":3,"file":"database-url.d.ts","sourceRoot":"","sources":["../src/database-url.ts"],"names":[],"mappings":"AA6BA,oEAAoE;AACpE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAK1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,KAAK,SAAiB,GACrB,MAAM,CAoBR;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,GAAG,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAe,GAC9D,MAAM,GAAG,SAAS,CAWpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,MAAM,GAClB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAUjD"}
@@ -12,8 +12,13 @@
12
12
  * password is a Secret Manager reference, so the password never shows up in
13
13
  * the service's configuration or its revision history.
14
14
  *
15
+ * A URL that reaches a database on another machine must ask for
16
+ * `sslmode=verify-full` (database-tls.ts, #1338); {@link databaseUrlFromEnv}
17
+ * refuses one that does not.
18
+ *
15
19
  * Pure module — no I/O.
16
20
  */
21
+ import { CLOUD_SQL_CA_BUNDLE, databaseTlsProblem, isIpLiteral, verifyFullQuery, } from "./database-tls.js";
17
22
  /** The `<NAME>_PASSWORD` var that pairs with a `<NAME>_URL` var. */
18
23
  export function databasePasswordVar(urlVar) {
19
24
  if (!urlVar.endsWith("_URL")) {
@@ -64,6 +69,9 @@ export function databaseUrlFromEnv(urlVars, env = process.env) {
64
69
  const url = env[urlVar];
65
70
  if (!url)
66
71
  continue;
72
+ const tls = databaseTlsProblem(url, urlVar);
73
+ if (tls)
74
+ throw new Error(tls);
67
75
  const passwordVar = databasePasswordVar(urlVar);
68
76
  const password = env[passwordVar];
69
77
  return password ? withDatabasePassword(url, password, `${urlVar} (with ${passwordVar})`) : url;
@@ -75,14 +83,19 @@ export function databaseUrlFromEnv(urlVars, env = process.env) {
75
83
  * how the in-cloud jobs (the operator-access sync job, the upgrader job)
76
84
  * connect: the user is the service account email without
77
85
  * `.gserviceaccount.com`, the password a short-lived OAuth access token.
86
+ * TLS is verify-full against Google's Cloud SQL shared-CA bundle, so `host`
87
+ * must be the instance's DNS name (its certificate names no IP).
78
88
  *
79
89
  * @example
80
90
  * cloudSqlIamDatabaseUrls("10.0.0.3", "job@p.iam.gserviceaccount.com", "ya29.x").user
81
91
  * // → "job@p.iam"
82
92
  */
83
93
  export function cloudSqlIamDatabaseUrls(host, serviceAccountEmail, accessToken) {
94
+ if (isIpLiteral(host)) {
95
+ throw new Error(`the Cloud SQL host is the IP address ${host}, but the instance's certificate names only its DNS name, so a verify-full connection to it cannot succeed (#1338). Run the converge (\`cms-provision upgrade\`, or Install update for a cloud-setup release) — it moves the services onto the DNS name — then retry.`);
96
+ }
84
97
  const user = serviceAccountEmail.replace(/\.gserviceaccount\.com$/, "");
85
- const url = (db) => `postgresql://${encodeURIComponent(user)}:${encodeURIComponent(accessToken)}@${host}:5432/${db}?sslmode=require`;
98
+ const url = (db) => `postgresql://${encodeURIComponent(user)}:${encodeURIComponent(accessToken)}@${host}:5432/${db}?${verifyFullQuery(CLOUD_SQL_CA_BUNDLE)}`;
86
99
  return { admin: url("cms_admin"), public: url("cms_public"), user };
87
100
  }
88
101
  //# sourceMappingURL=database-url.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"database-url.js","sourceRoot":"","sources":["../src/database-url.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;;;;;;;GAcG;AAEH,oEAAoE;AACpE,MAAM,UAAU,mBAAmB,CAAC,MAAc;IAChD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,0CAA0C,MAAM,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;AACvD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAW,EACX,QAAgB,EAChB,KAAK,GAAG,cAAc;IAEtB,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qBAAqB,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,MAAM,CAAC,Q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AI,eAAe,CAAC,mBAAmB,CAAC,EAAE,CAAC;IAC3I,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC;AACtE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,10 +3,12 @@ export * from "./ai-tools.js";
3
3
  export * from "./auth-forms.js";
4
4
  export * from "./auto-update.js";
5
5
  export * from "./base-css.js";
6
+ export * from "./body-cap.js";
6
7
  export * from "./bug-intake.js";
7
8
  export * from "./build-page.js";
8
9
  export * from "./cap-failures.js";
9
10
  export * from "./change-journal.js";
11
+ export * from "./client-address.js";
10
12
  export * from "./cloud-shell-install.js";
11
13
  export * from "./content.js";
12
14
  export * from "./context.js";
@@ -14,6 +16,7 @@ export * from "./css-gradient-scan.js";
14
16
  export * from "./css-scope-scan.js";
15
17
  export * from "./css-var-aliases.js";
16
18
  export * from "./css-var-scan.js";
19
+ export * from "./database-tls.js";
17
20
  export * from "./database-url.js";
18
21
  export * from "./design-draft-shell.js";
19
22
  export * from "./document-language.js";
@@ -30,6 +33,8 @@ export * from "./google-oauth.js";
30
33
  export * from "./id-safe-truncate.js";
31
34
  export * from "./image-capabilities.js";
32
35
  export * from "./interactions.js";
36
+ export * from "./interim-forwarded-host.js";
37
+ export * from "./json-security-headers.js";
33
38
  export * from "./link-canonicalise.js";
34
39
  export * from "./link-refs.js";
35
40
  export * from "./lists/index.js";
@@ -63,11 +68,13 @@ export * from "./run-batched.js";
63
68
  export * from "./safe-keys.js";
64
69
  export * from "./screenshot-capture.js";
65
70
  export * from "./seo.js";
71
+ export * from "./session-cookie.js";
66
72
  export * from "./skills.js";
67
73
  export * from "./snapshots.js";
68
74
  export * from "./source-text-transport.js";
69
75
  export * from "./stage-status.js";
70
76
  export * from "./staging-gate.js";
77
+ export * from "./staging-plugin-stub.js";
71
78
  export * from "./static-cache-policy.js";
72
79
  export * from "./static-security-headers.js";
73
80
  export * from "./strip-cdata.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,cAAc,CAAC;AAExC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACL,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,UAAU,EACV,aAAa,EACb,MAAM,EACN,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB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BAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uCAAuC,CAAC;AACtD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACL,aAAa,EACb,aAAa,EACb,KAAK,YAAY,EACjB,cAAc,EACd,YAAY,GACb,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -4,10 +4,12 @@ export * from "./ai-tools.js";
4
4
  export * from "./auth-forms.js";
5
5
  export * from "./auto-update.js";
6
6
  export * from "./base-css.js";
7
+ export * from "./body-cap.js";
7
8
  export * from "./bug-intake.js";
8
9
  export * from "./build-page.js";
9
10
  export * from "./cap-failures.js";
10
11
  export * from "./change-journal.js";
12
+ export * from "./client-address.js";
11
13
  export * from "./cloud-shell-install.js";
12
14
  export * from "./content.js";
13
15
  export * from "./context.js";
@@ -15,6 +17,7 @@ export * from "./css-gradient-scan.js";
15
17
  export * from "./css-scope-scan.js";
16
18
  export * from "./css-var-aliases.js";
17
19
  export * from "./css-var-scan.js";
20
+ export * from "./database-tls.js";
18
21
  export * from "./database-url.js";
19
22
  export * from "./design-draft-shell.js";
20
23
  export * from "./document-language.js";
@@ -31,6 +34,8 @@ export * from "./google-oauth.js";
31
34
  export * from "./id-safe-truncate.js";
32
35
  export * from "./image-capabilities.js";
33
36
  export * from "./interactions.js";
37
+ export * from "./interim-forwarded-host.js";
38
+ export * from "./json-security-headers.js";
34
39
  export * from "./link-canonicalise.js";
35
40
  export * from "./link-refs.js";
36
41
  export * from "./lists/index.js";
@@ -64,11 +69,13 @@ export * from "./run-batched.js";
64
69
  export * from "./safe-keys.js";
65
70
  export * from "./screenshot-capture.js";
66
71
  export * from "./seo.js";
72
+ export * from "./session-cookie.js";
67
73
  export * from "./skills.js";
68
74
  export * from "./snapshots.js";
69
75
  export * from "./source-text-transport.js";
70
76
  export * from "./stage-status.js";
71
77
  export * from "./staging-gate.js";
78
+ export * from "./staging-plugin-stub.js";
72
79
  export * from "./static-cache-policy.js";
73
80
  export * from "./static-security-headers.js";
74
81
  export * from "./strip-cdata.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;AAExC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kB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;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uCAAuC,CAAC;AACtD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACL,aAAa,EACb,aAAa,EAEb,cAAc,EACd,YAAY,GACb,MAAM,cAAc,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * FIXME(issue #1331): the header the MCP-Auth-Proxy's interim forwarder
3
+ * (apps/mcp-auth-proxy server.ts) sets to the host a client asked for, and
4
+ * the visitor gateway's staging gate (apps/api-gateway staging-proxy.ts)
5
+ * reads. One name for both ends of the contract.
6
+ *
7
+ * On gcp-firebase the Cloud Run service `gateway` became the MCP-Auth-Proxy
8
+ * (#1328, E13 a), while an existing staging domain mapping (#650) and the
9
+ * live release's Firebase `/api/**` rewrite still point at it. The proxy
10
+ * streams that traffic to the data gateway's run.app URL; Cloud Run routes
11
+ * by Host, so the original host travels in this header. Removed with the
12
+ * staging cutover (P3b-3).
13
+ */
14
+ export declare const INTERIM_FORWARDED_HOST_HEADER = "x-caelo-forwarded-host";
15
+ //# sourceMappingURL=interim-forwarded-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interim-forwarded-host.d.ts","sourceRoot":"","sources":["../src/interim-forwarded-host.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,6BAA6B,2BAA2B,CAAC"}
@@ -0,0 +1,16 @@
1
+ // SPDX-License-Identifier: MPL-2.0
2
+ /**
3
+ * FIXME(issue #1331): the header the MCP-Auth-Proxy's interim forwarder
4
+ * (apps/mcp-auth-proxy server.ts) sets to the host a client asked for, and
5
+ * the visitor gateway's staging gate (apps/api-gateway staging-proxy.ts)
6
+ * reads. One name for both ends of the contract.
7
+ *
8
+ * On gcp-firebase the Cloud Run service `gateway` became the MCP-Auth-Proxy
9
+ * (#1328, E13 a), while an existing staging domain mapping (#650) and the
10
+ * live release's Firebase `/api/**` rewrite still point at it. The proxy
11
+ * streams that traffic to the data gateway's run.app URL; Cloud Run routes
12
+ * by Host, so the original host travels in this header. Removed with the
13
+ * staging cutover (P3b-3).
14
+ */
15
+ export const INTERIM_FORWARDED_HOST_HEADER = "x-caelo-forwarded-host";
16
+ //# sourceMappingURL=interim-forwarded-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interim-forwarded-host.js","sourceRoot":"","sources":["../src/interim-forwarded-host.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,wBAAwB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Security headers of a public service's JSON answers (#1326, #763 L2): the
3
+ * visitor gateway's and the MCP-Auth-Proxy's (#1328).
4
+ *
5
+ * A JSON answer is data, never a document: it must not be sniffed into
6
+ * HTML or script, framed, or handed to another origin's page. The headers
7
+ * say so to the browser on every JSON response, whichever route produced
8
+ * it. Pure Web APIs, so both services share the one definition.
9
+ */
10
+ /** The headers every JSON response carries. */
11
+ export declare const JSON_SECURITY_HEADERS: Readonly<Record<string, string>>;
12
+ /** Whether `res` is a JSON answer (any `application/json` or `+json` type). */
13
+ export declare function isJsonResponse(res: Response): boolean;
14
+ /** Set the {@link JSON_SECURITY_HEADERS} on `headers`, keeping a value already set. */
15
+ export declare function addJsonSecurityHeaders(headers: Headers): void;
16
+ /**
17
+ * `res` with the JSON security headers when it is JSON, else `res` as it
18
+ * is. A response whose headers are immutable (one passed through from a
19
+ * `fetch`) is rebuilt around the same body stream, so a streamed answer
20
+ * stays streamed.
21
+ */
22
+ export declare function withJsonSecurityHeaders(res: Response): Response;
23
+ //# sourceMappingURL=json-security-headers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-security-headers.d.ts","sourceRoot":"","sources":["../src/json-security-headers.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,+CAA+C;AAC/C,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOlE,CAAC;AAEF,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAGrD;AAED,uFAAuF;AACvF,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAI7D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAW/D"}
@@ -0,0 +1,53 @@
1
+ // SPDX-License-Identifier: MPL-2.0
2
+ /**
3
+ * Security headers of a public service's JSON answers (#1326, #763 L2): the
4
+ * visitor gateway's and the MCP-Auth-Proxy's (#1328).
5
+ *
6
+ * A JSON answer is data, never a document: it must not be sniffed into
7
+ * HTML or script, framed, or handed to another origin's page. The headers
8
+ * say so to the browser on every JSON response, whichever route produced
9
+ * it. Pure Web APIs, so both services share the one definition.
10
+ */
11
+ /** The headers every JSON response carries. */
12
+ export const JSON_SECURITY_HEADERS = {
13
+ "X-Content-Type-Options": "nosniff",
14
+ // Nothing in a JSON answer may load or run anything, nor be framed.
15
+ "Content-Security-Policy": "default-src 'none'; frame-ancestors 'none'",
16
+ "X-Frame-Options": "DENY",
17
+ "Referrer-Policy": "no-referrer",
18
+ "Cross-Origin-Resource-Policy": "same-origin",
19
+ };
20
+ /** Whether `res` is a JSON answer (any `application/json` or `+json` type). */
21
+ export function isJsonResponse(res) {
22
+ const type = (res.headers.get("content-type") ?? "").split(";")[0]?.trim().toLowerCase() ?? "";
23
+ return type === "application/json" || type.endsWith("+json");
24
+ }
25
+ /** Set the {@link JSON_SECURITY_HEADERS} on `headers`, keeping a value already set. */
26
+ export function addJsonSecurityHeaders(headers) {
27
+ for (const [name, value] of Object.entries(JSON_SECURITY_HEADERS)) {
28
+ if (!headers.has(name))
29
+ headers.set(name, value);
30
+ }
31
+ }
32
+ /**
33
+ * `res` with the JSON security headers when it is JSON, else `res` as it
34
+ * is. A response whose headers are immutable (one passed through from a
35
+ * `fetch`) is rebuilt around the same body stream, so a streamed answer
36
+ * stays streamed.
37
+ */
38
+ export function withJsonSecurityHeaders(res) {
39
+ if (!isJsonResponse(res))
40
+ return res;
41
+ if (Object.keys(JSON_SECURITY_HEADERS).every((h) => res.headers.has(h)))
42
+ return res;
43
+ try {
44
+ addJsonSecurityHeaders(res.headers);
45
+ return res;
46
+ }
47
+ catch {
48
+ const headers = new Headers(res.headers);
49
+ addJsonSecurityHeaders(headers);
50
+ return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
51
+ }
52
+ }
53
+ //# sourceMappingURL=json-security-headers.js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GAAG,CAAC,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IACpF,IAAI,CAAC;QACH,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACpC,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAChC,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC"}
@@ -156,4 +156,10 @@ export interface ListIssue {
156
156
  export declare function validateFieldValue(field: FieldDef, value: unknown, path: string): ListIssue[];
157
157
  /** Checks on one field declaration that Zod cannot express. */
158
158
  export declare function checkFieldDef(field: FieldDef, path: string): ListIssue[];
159
+ /**
160
+ * The Zod issues of an object value, in the caller's terms: `unknown key
161
+ * "url" (put the address in href), href missing, target must be "_self" |
162
+ * "_blank" (got "new")`.
163
+ */
164
+ export declare function describeObjectIssues(error: z.ZodError, value: Record<string, unknown>, keyHints?: Readonly<Record<string, string>>): string;
159
165
  //# sourceMappingURL=fields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/lists/fields.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,iDAAiD;AACjD,eAAO,MAAM,gBAAgB,iHAYnB,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAWlD,CAAC;AACH,4EAA4E;A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AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CA6E7F;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CA0BxE;AAgBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,CAAC,CAAC,QAAQ,EACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,QAAQ,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,GAC9C,MAAM,CA0CR"}
@@ -169,8 +169,15 @@ export function validateFieldValue(field, value, path) {
169
169
  ? [{ path, message: `"${field.name}" is required (${field.type}) — set a value.` }]
170
170
  : [];
171
171
  }
172
- const bad = (expected) => [
173
- { path, message: `"${field.name}" must be ${expected}, got ${describe(value)}.` },
172
+ // #1265 — for an object-shaped value, say WHAT is wrong in it (the Zod
173
+ // issues) instead of "got object", which names nothing to fix.
174
+ const bad = (expected, error, keyHints) => [
175
+ {
176
+ path,
177
+ message: error !== undefined && isPlainObject(value)
178
+ ? `"${field.name}" must be ${expected} — ${describeObjectIssues(error, value, keyHints)}.`
179
+ : `"${field.name}" must be ${expected}, got ${describe(value)}.`,
180
+ },
174
181
  ];
175
182
  switch (field.type) {
176
183
  case "text":
@@ -186,7 +193,9 @@ export function validateFieldValue(field, value, path) {
186
193
  }
187
194
  case "link": {
188
195
  const r = linkValueSchema.safeParse(value);
189
- return r.success ? [] : bad('{ href, target? } (href like "/about" or "https://…")');
196
+ return r.success
197
+ ? []
198
+ : bad('{ href, target? } (href like "/about" or "https://…")', r.error, LINK_KEY_HINTS);
190
199
  }
191
200
  case "media":
192
201
  return typeof value === "string" && MEDIA_REF_RE.test(value)
@@ -215,10 +224,10 @@ export function validateFieldValue(field, value, path) {
215
224
  : bad("an ISO date YYYY-MM-DD");
216
225
  case "icon":
217
226
  return typeof value === "string" && ICON_RE.test(value) ? [] : bad("an icon name");
218
- case "module":
219
- return embeddedModuleValueSchema.safeParse(value).success
220
- ? []
221
- : bad("{ moduleId, contentInstanceId }");
227
+ case "module": {
228
+ const r = embeddedModuleValueSchema.safeParse(value);
229
+ return r.success ? [] : bad("{ moduleId, contentInstanceId }", r.error);
230
+ }
222
231
  case "term": {
223
232
  if (!Array.isArray(value) ||
224
233
  value.some((v) => typeof v !== "string" || !TERM_REF_RE.test(v))) {
@@ -254,6 +263,60 @@ export function checkFieldDef(field, path) {
254
263
  }
255
264
  return issues;
256
265
  }
266
+ /** Keys a link value is often written with instead of `href`. */
267
+ const LINK_KEY_HINTS = {
268
+ url: "put the address in href",
269
+ link: "put the address in href",
270
+ path: "put the address in href",
271
+ to: "put the address in href",
272
+ label: "the link text is its own field, not part of the link value",
273
+ text: "the link text is its own field, not part of the link value",
274
+ };
275
+ function isPlainObject(value) {
276
+ return typeof value === "object" && value !== null && !Array.isArray(value);
277
+ }
278
+ /**
279
+ * The Zod issues of an object value, in the caller's terms: `unknown key
280
+ * "url" (put the address in href), href missing, target must be "_self" |
281
+ * "_blank" (got "new")`.
282
+ */
283
+ export function describeObjectIssues(error, value, keyHints = {}) {
284
+ const parts = [];
285
+ for (const issue of error.issues) {
286
+ const key = issue.path.map(String).join(".");
287
+ const got = issue.path.length > 0 ? value[String(issue.path[0])] : value;
288
+ switch (issue.code) {
289
+ case "unrecognized_keys":
290
+ for (const k of issue.keys) {
291
+ const hint = keyHints[k];
292
+ parts.push(`unknown key "${k}"${hint ? ` (${hint})` : ""}`);
293
+ }
294
+ break;
295
+ case "invalid_type":
296
+ parts.push(got === undefined
297
+ ? `${key} missing`
298
+ : `${key} must be a ${issue.expected}, got ${describe(got)}`);
299
+ break;
300
+ case "invalid_value":
301
+ parts.push(`${key} must be ${issue.values.map((v) => JSON.stringify(v)).join(" | ")} (got ${describe(got)})`);
302
+ break;
303
+ case "too_small":
304
+ parts.push(typeof got === "string" && got.length === 0
305
+ ? `${key} is empty`
306
+ : `${key} must have at least ${String(issue.minimum)} characters`);
307
+ break;
308
+ case "too_big":
309
+ parts.push(`${key} must have at most ${String(issue.maximum)} characters`);
310
+ break;
311
+ case "invalid_format":
312
+ parts.push(`${key} must be a ${issue.format} (got ${describe(got)})`);
313
+ break;
314
+ default:
315
+ parts.push(key.length > 0 ? `${key}: ${issue.message}` : issue.message);
316
+ }
317
+ }
318
+ return parts.length > 0 ? parts.join(", ") : "an object of another shape";
319
+ }
257
320
  function describe(value) {
258
321
  if (Array.isArray(value))
259
322
  return "an array";