@taggor/contract 0.0.0-stage → 0.2.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.
Files changed (343) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -2
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/artifact-keys.d.ts +169 -0
  5. package/dist/artifact-keys.d.ts.map +1 -0
  6. package/dist/artifact-keys.js +195 -0
  7. package/dist/artifact-keys.js.map +1 -0
  8. package/dist/assets.d.ts +72 -0
  9. package/dist/assets.d.ts.map +1 -0
  10. package/dist/assets.js +94 -0
  11. package/dist/assets.js.map +1 -0
  12. package/dist/bounded-path.d.ts +29 -0
  13. package/dist/bounded-path.d.ts.map +1 -0
  14. package/dist/bounded-path.js +57 -0
  15. package/dist/bounded-path.js.map +1 -0
  16. package/dist/bounded.d.ts +47 -0
  17. package/dist/bounded.d.ts.map +1 -0
  18. package/dist/bounded.js +93 -0
  19. package/dist/bounded.js.map +1 -0
  20. package/dist/build-diagnostic.d.ts +89 -0
  21. package/dist/build-diagnostic.d.ts.map +1 -0
  22. package/dist/build-diagnostic.js +91 -0
  23. package/dist/build-diagnostic.js.map +1 -0
  24. package/dist/component-types.d.ts +61 -0
  25. package/dist/component-types.d.ts.map +1 -0
  26. package/dist/component-types.js +277 -0
  27. package/dist/component-types.js.map +1 -0
  28. package/dist/consent-text.d.ts +31 -0
  29. package/dist/consent-text.d.ts.map +1 -0
  30. package/dist/consent-text.js +41 -0
  31. package/dist/consent-text.js.map +1 -0
  32. package/dist/contract-version.d.ts +150 -0
  33. package/dist/contract-version.d.ts.map +1 -0
  34. package/dist/contract-version.js +198 -0
  35. package/dist/contract-version.js.map +1 -0
  36. package/dist/credential-fields.d.ts +31 -0
  37. package/dist/credential-fields.d.ts.map +1 -0
  38. package/dist/credential-fields.js +36 -0
  39. package/dist/credential-fields.js.map +1 -0
  40. package/dist/css-tokens.d.ts +46 -0
  41. package/dist/css-tokens.d.ts.map +1 -0
  42. package/dist/css-tokens.js +189 -0
  43. package/dist/css-tokens.js.map +1 -0
  44. package/dist/css-value.d.ts +42 -0
  45. package/dist/css-value.d.ts.map +1 -0
  46. package/dist/css-value.js +78 -0
  47. package/dist/css-value.js.map +1 -0
  48. package/dist/data-api.d.ts +127 -0
  49. package/dist/data-api.d.ts.map +1 -0
  50. package/dist/data-api.js +167 -0
  51. package/dist/data-api.js.map +1 -0
  52. package/dist/denylist-keys.d.ts +19 -0
  53. package/dist/denylist-keys.d.ts.map +1 -0
  54. package/dist/denylist-keys.js +48 -0
  55. package/dist/denylist-keys.js.map +1 -0
  56. package/dist/diagnostic-catalog.d.ts +1402 -0
  57. package/dist/diagnostic-catalog.d.ts.map +1 -0
  58. package/dist/diagnostic-catalog.js +1311 -0
  59. package/dist/diagnostic-catalog.js.map +1 -0
  60. package/dist/dom-members.snapshot.d.ts +33 -0
  61. package/dist/dom-members.snapshot.d.ts.map +1 -0
  62. package/dist/dom-members.snapshot.js +760 -0
  63. package/dist/dom-members.snapshot.js.map +1 -0
  64. package/dist/early-loading.d.ts +27 -0
  65. package/dist/early-loading.d.ts.map +1 -0
  66. package/dist/early-loading.js +44 -0
  67. package/dist/early-loading.js.map +1 -0
  68. package/dist/error-catalog.d.ts +749 -0
  69. package/dist/error-catalog.d.ts.map +1 -0
  70. package/dist/error-catalog.js +720 -0
  71. package/dist/error-catalog.js.map +1 -0
  72. package/dist/executable-config.d.ts +35 -0
  73. package/dist/executable-config.d.ts.map +1 -0
  74. package/dist/executable-config.js +44 -0
  75. package/dist/executable-config.js.map +1 -0
  76. package/dist/freeze.d.ts +17 -0
  77. package/dist/freeze.d.ts.map +1 -0
  78. package/dist/freeze.js +29 -0
  79. package/dist/freeze.js.map +1 -0
  80. package/dist/gunzip.d.ts +33 -0
  81. package/dist/gunzip.d.ts.map +1 -0
  82. package/dist/gunzip.js +330 -0
  83. package/dist/gunzip.js.map +1 -0
  84. package/dist/hostname.d.ts +74 -0
  85. package/dist/hostname.d.ts.map +1 -0
  86. package/dist/hostname.js +215 -0
  87. package/dist/hostname.js.map +1 -0
  88. package/dist/human-actions.d.ts +49 -0
  89. package/dist/human-actions.d.ts.map +1 -0
  90. package/dist/human-actions.js +272 -0
  91. package/dist/human-actions.js.map +1 -0
  92. package/dist/index.d.ts +73 -0
  93. package/dist/index.d.ts.map +1 -0
  94. package/dist/index.js +73 -0
  95. package/dist/index.js.map +1 -0
  96. package/dist/json-schema.d.ts +108 -0
  97. package/dist/json-schema.d.ts.map +1 -0
  98. package/dist/json-schema.js +240 -0
  99. package/dist/json-schema.js.map +1 -0
  100. package/dist/key-checksum.d.ts +33 -0
  101. package/dist/key-checksum.d.ts.map +1 -0
  102. package/dist/key-checksum.js +67 -0
  103. package/dist/key-checksum.js.map +1 -0
  104. package/dist/libraries.d.ts +60 -0
  105. package/dist/libraries.d.ts.map +1 -0
  106. package/dist/libraries.js +120 -0
  107. package/dist/libraries.js.map +1 -0
  108. package/dist/limit-catalog.d.ts +381 -0
  109. package/dist/limit-catalog.d.ts.map +1 -0
  110. package/dist/limit-catalog.js +429 -0
  111. package/dist/limit-catalog.js.map +1 -0
  112. package/dist/limits.d.ts +167 -0
  113. package/dist/limits.d.ts.map +1 -0
  114. package/dist/limits.js +175 -0
  115. package/dist/limits.js.map +1 -0
  116. package/dist/locale-tag.d.ts +21 -0
  117. package/dist/locale-tag.d.ts.map +1 -0
  118. package/dist/locale-tag.js +21 -0
  119. package/dist/locale-tag.js.map +1 -0
  120. package/dist/make-diagnostic.d.ts +74 -0
  121. package/dist/make-diagnostic.d.ts.map +1 -0
  122. package/dist/make-diagnostic.js +100 -0
  123. package/dist/make-diagnostic.js.map +1 -0
  124. package/dist/manifest-compat-diagnostics.d.ts +23 -0
  125. package/dist/manifest-compat-diagnostics.d.ts.map +1 -0
  126. package/dist/manifest-compat-diagnostics.js +150 -0
  127. package/dist/manifest-compat-diagnostics.js.map +1 -0
  128. package/dist/manifest-compat.d.ts +58 -0
  129. package/dist/manifest-compat.d.ts.map +1 -0
  130. package/dist/manifest-compat.js +377 -0
  131. package/dist/manifest-compat.js.map +1 -0
  132. package/dist/manifest.d.ts +1769 -0
  133. package/dist/manifest.d.ts.map +1 -0
  134. package/dist/manifest.js +421 -0
  135. package/dist/manifest.js.map +1 -0
  136. package/dist/metering.d.ts +126 -0
  137. package/dist/metering.d.ts.map +1 -0
  138. package/dist/metering.js +147 -0
  139. package/dist/metering.js.map +1 -0
  140. package/dist/migrate.d.ts +70 -0
  141. package/dist/migrate.d.ts.map +1 -0
  142. package/dist/migrate.js +159 -0
  143. package/dist/migrate.js.map +1 -0
  144. package/dist/money.d.ts +41 -0
  145. package/dist/money.d.ts.map +1 -0
  146. package/dist/money.js +52 -0
  147. package/dist/money.js.map +1 -0
  148. package/dist/names.d.ts +37 -0
  149. package/dist/names.d.ts.map +1 -0
  150. package/dist/names.js +55 -0
  151. package/dist/names.js.map +1 -0
  152. package/dist/overage-pricing.d.ts +89 -0
  153. package/dist/overage-pricing.d.ts.map +1 -0
  154. package/dist/overage-pricing.js +170 -0
  155. package/dist/overage-pricing.js.map +1 -0
  156. package/dist/plan-ids.d.ts +10 -0
  157. package/dist/plan-ids.d.ts.map +1 -0
  158. package/dist/plan-ids.js +8 -0
  159. package/dist/plan-ids.js.map +1 -0
  160. package/dist/plan-limits.d.ts +138 -0
  161. package/dist/plan-limits.d.ts.map +1 -0
  162. package/dist/plan-limits.js +112 -0
  163. package/dist/plan-limits.js.map +1 -0
  164. package/dist/plan-pricing.d.ts +145 -0
  165. package/dist/plan-pricing.d.ts.map +1 -0
  166. package/dist/plan-pricing.js +172 -0
  167. package/dist/plan-pricing.js.map +1 -0
  168. package/dist/plan-usage.d.ts +112 -0
  169. package/dist/plan-usage.d.ts.map +1 -0
  170. package/dist/plan-usage.js +134 -0
  171. package/dist/plan-usage.js.map +1 -0
  172. package/dist/preview-token.d.ts +52 -0
  173. package/dist/preview-token.d.ts.map +1 -0
  174. package/dist/preview-token.js +106 -0
  175. package/dist/preview-token.js.map +1 -0
  176. package/dist/prop-names.d.ts +51 -0
  177. package/dist/prop-names.d.ts.map +1 -0
  178. package/dist/prop-names.js +150 -0
  179. package/dist/prop-names.js.map +1 -0
  180. package/dist/prop-type-docs.d.ts +20 -0
  181. package/dist/prop-type-docs.d.ts.map +1 -0
  182. package/dist/prop-type-docs.js +89 -0
  183. package/dist/prop-type-docs.js.map +1 -0
  184. package/dist/prop-types.d.ts +97 -0
  185. package/dist/prop-types.d.ts.map +1 -0
  186. package/dist/prop-types.js +299 -0
  187. package/dist/prop-types.js.map +1 -0
  188. package/dist/props.d.ts +996 -0
  189. package/dist/props.d.ts.map +1 -0
  190. package/dist/props.js +183 -0
  191. package/dist/props.js.map +1 -0
  192. package/dist/proto-guard.d.ts +29 -0
  193. package/dist/proto-guard.d.ts.map +1 -0
  194. package/dist/proto-guard.js +79 -0
  195. package/dist/proto-guard.js.map +1 -0
  196. package/dist/runtime-errors.d.ts +42 -0
  197. package/dist/runtime-errors.d.ts.map +1 -0
  198. package/dist/runtime-errors.js +42 -0
  199. package/dist/runtime-errors.js.map +1 -0
  200. package/dist/runtime-pointers.d.ts +58 -0
  201. package/dist/runtime-pointers.d.ts.map +1 -0
  202. package/dist/runtime-pointers.js +84 -0
  203. package/dist/runtime-pointers.js.map +1 -0
  204. package/dist/secret-scan.d.ts +191 -0
  205. package/dist/secret-scan.d.ts.map +1 -0
  206. package/dist/secret-scan.js +542 -0
  207. package/dist/secret-scan.js.map +1 -0
  208. package/dist/semver.d.ts +89 -0
  209. package/dist/semver.d.ts.map +1 -0
  210. package/dist/semver.js +400 -0
  211. package/dist/semver.js.map +1 -0
  212. package/dist/server-key.d.ts +68 -0
  213. package/dist/server-key.d.ts.map +1 -0
  214. package/dist/server-key.js +150 -0
  215. package/dist/server-key.js.map +1 -0
  216. package/dist/site-manifest-keys.d.ts +107 -0
  217. package/dist/site-manifest-keys.d.ts.map +1 -0
  218. package/dist/site-manifest-keys.js +146 -0
  219. package/dist/site-manifest-keys.js.map +1 -0
  220. package/dist/site-manifest.d.ts +286 -0
  221. package/dist/site-manifest.d.ts.map +1 -0
  222. package/dist/site-manifest.js +100 -0
  223. package/dist/site-manifest.js.map +1 -0
  224. package/dist/source-archive.d.ts +119 -0
  225. package/dist/source-archive.d.ts.map +1 -0
  226. package/dist/source-archive.js +644 -0
  227. package/dist/source-archive.js.map +1 -0
  228. package/dist/source-package-corpus.d.ts +55 -0
  229. package/dist/source-package-corpus.d.ts.map +1 -0
  230. package/dist/source-package-corpus.js +303 -0
  231. package/dist/source-package-corpus.js.map +1 -0
  232. package/dist/source-package.d.ts +227 -0
  233. package/dist/source-package.d.ts.map +1 -0
  234. package/dist/source-package.js +361 -0
  235. package/dist/source-package.js.map +1 -0
  236. package/dist/source-secrets.d.ts +21 -0
  237. package/dist/source-secrets.d.ts.map +1 -0
  238. package/dist/source-secrets.js +43 -0
  239. package/dist/source-secrets.js.map +1 -0
  240. package/dist/ssr-cap.d.ts +61 -0
  241. package/dist/ssr-cap.d.ts.map +1 -0
  242. package/dist/ssr-cap.js +107 -0
  243. package/dist/ssr-cap.js.map +1 -0
  244. package/dist/ssr-kv.d.ts +18 -0
  245. package/dist/ssr-kv.d.ts.map +1 -0
  246. package/dist/ssr-kv.js +18 -0
  247. package/dist/ssr-kv.js.map +1 -0
  248. package/dist/ssr-version-ledger.d.ts +53 -0
  249. package/dist/ssr-version-ledger.d.ts.map +1 -0
  250. package/dist/ssr-version-ledger.js +88 -0
  251. package/dist/ssr-version-ledger.js.map +1 -0
  252. package/dist/style-references.d.ts +58 -0
  253. package/dist/style-references.d.ts.map +1 -0
  254. package/dist/style-references.js +241 -0
  255. package/dist/style-references.js.map +1 -0
  256. package/dist/tag-name.d.ts +87 -0
  257. package/dist/tag-name.d.ts.map +1 -0
  258. package/dist/tag-name.js +222 -0
  259. package/dist/tag-name.js.map +1 -0
  260. package/dist/tar-writer.d.ts +74 -0
  261. package/dist/tar-writer.d.ts.map +1 -0
  262. package/dist/tar-writer.js +148 -0
  263. package/dist/tar-writer.js.map +1 -0
  264. package/dist/testing.d.ts +11 -0
  265. package/dist/testing.d.ts.map +1 -0
  266. package/dist/testing.js +11 -0
  267. package/dist/testing.js.map +1 -0
  268. package/dist/text-codec.d.ts +36 -0
  269. package/dist/text-codec.d.ts.map +1 -0
  270. package/dist/text-codec.js +32 -0
  271. package/dist/text-codec.js.map +1 -0
  272. package/dist/url-value.d.ts +41 -0
  273. package/dist/url-value.d.ts.map +1 -0
  274. package/dist/url-value.js +147 -0
  275. package/dist/url-value.js.map +1 -0
  276. package/dist/usage-guard.d.ts +99 -0
  277. package/dist/usage-guard.d.ts.map +1 -0
  278. package/dist/usage-guard.js +104 -0
  279. package/dist/usage-guard.js.map +1 -0
  280. package/dist/usage-mirror.d.ts +55 -0
  281. package/dist/usage-mirror.d.ts.map +1 -0
  282. package/dist/usage-mirror.js +52 -0
  283. package/dist/usage-mirror.js.map +1 -0
  284. package/dist/value-check.d.ts +88 -0
  285. package/dist/value-check.d.ts.map +1 -0
  286. package/dist/value-check.js +279 -0
  287. package/dist/value-check.js.map +1 -0
  288. package/dist/value-patterns.d.ts +9 -0
  289. package/dist/value-patterns.d.ts.map +1 -0
  290. package/dist/value-patterns.js +17 -0
  291. package/dist/value-patterns.js.map +1 -0
  292. package/dist/value-schema.d.ts +796 -0
  293. package/dist/value-schema.d.ts.map +1 -0
  294. package/dist/value-schema.js +231 -0
  295. package/dist/value-schema.js.map +1 -0
  296. package/dist/zod-free.d.ts +60 -0
  297. package/dist/zod-free.d.ts.map +1 -0
  298. package/dist/zod-free.js +59 -0
  299. package/dist/zod-free.js.map +1 -0
  300. package/package.json +75 -3
  301. package/schema/DEPLOYED +12 -0
  302. package/schema/build-diagnostic.v1.json +63 -0
  303. package/schema/component-manifest.v1.json +1000 -0
  304. package/schema/data-api.v1.json +194 -0
  305. package/schema/library-manifest.v1.json +60 -0
  306. package/schema/published/SHA256SUMS +36 -0
  307. package/schema/published/build-diagnostic/v1.10.json +83 -0
  308. package/schema/published/build-diagnostic/v1.3.json +83 -0
  309. package/schema/published/build-diagnostic/v1.4.json +83 -0
  310. package/schema/published/build-diagnostic/v1.5.json +83 -0
  311. package/schema/published/build-diagnostic/v1.6.json +83 -0
  312. package/schema/published/build-diagnostic/v1.7.json +83 -0
  313. package/schema/published/build-diagnostic/v1.8.json +83 -0
  314. package/schema/published/build-diagnostic/v1.9.json +83 -0
  315. package/schema/published/component-manifest/v1.10.json +1443 -0
  316. package/schema/published/component-manifest/v1.3.json +1411 -0
  317. package/schema/published/component-manifest/v1.4.json +1419 -0
  318. package/schema/published/component-manifest/v1.5.json +1437 -0
  319. package/schema/published/component-manifest/v1.6.json +1437 -0
  320. package/schema/published/component-manifest/v1.7.json +1437 -0
  321. package/schema/published/component-manifest/v1.8.json +1437 -0
  322. package/schema/published/component-manifest/v1.9.json +1437 -0
  323. package/schema/published/data-api/v1.10.json +282 -0
  324. package/schema/published/data-api/v1.3.json +281 -0
  325. package/schema/published/data-api/v1.4.json +281 -0
  326. package/schema/published/data-api/v1.5.json +281 -0
  327. package/schema/published/data-api/v1.6.json +281 -0
  328. package/schema/published/data-api/v1.7.json +281 -0
  329. package/schema/published/data-api/v1.8.json +282 -0
  330. package/schema/published/data-api/v1.9.json +282 -0
  331. package/schema/published/library-manifest/v1.10.json +68 -0
  332. package/schema/published/library-manifest/v1.5.json +68 -0
  333. package/schema/published/library-manifest/v1.6.json +68 -0
  334. package/schema/published/library-manifest/v1.7.json +68 -0
  335. package/schema/published/library-manifest/v1.8.json +68 -0
  336. package/schema/published/library-manifest/v1.9.json +68 -0
  337. package/schema/published/taggor-config/v1.10.json +56 -0
  338. package/schema/published/taggor-config/v1.5.json +56 -0
  339. package/schema/published/taggor-config/v1.6.json +56 -0
  340. package/schema/published/taggor-config/v1.7.json +56 -0
  341. package/schema/published/taggor-config/v1.8.json +56 -0
  342. package/schema/published/taggor-config/v1.9.json +56 -0
  343. package/schema/taggor-config.v1.json +39 -0
@@ -0,0 +1,147 @@
1
+ /**
2
+ * URL values of component contract v1 without Zod (TAG-201, made Zod-free and stricter by TAG-205):
3
+ * the scheme allowlist, the text rule and `isAllowedUrl`, shared by `url` props (default, attribute
4
+ * and property) and by the `url` string format of value schemas.
5
+ *
6
+ * A URL value is printable ASCII only: no whitespace, no control or format characters (`\p{Cc}`,
7
+ * `\p{Cf}`, bidi overrides, zero-width), no quotes, angle brackets, backtick or backslash. Non-ASCII
8
+ * paths are percent-encoded and international domains written in punycode, as browsers send them.
9
+ * The scheme is lowercase and matched at the very start, so `javascript:`, `data:`, `vbscript:`,
10
+ * `JaVaScRiPt:` and scheme-relative `//host` are impossible. The WHATWG URL parser then confirms the
11
+ * text is a URL and that its scheme is the one the text starts with.
12
+ *
13
+ * TAG-303 (security review of TAG-205) closed two ways a URL could say something other than what
14
+ * a reader sees: `http`/`https` refuse userinfo (`https://good.com@evil.com` goes to `evil.com`),
15
+ * and `mailto:` takes exactly one address (no `,` list, no percent-encoding) with only the
16
+ * `subject` and `body` fields, so `cc`, `bcc`, `to` and any other header cannot add recipients;
17
+ * the whole text is checked (no `#`, one `?`, no `;` in values, encoded line breaks only in
18
+ * `body`), because the whole text is what reaches `href`.
19
+ * A scheme a declaration lists but `URL_PROTOCOLS` does not know (a newer contract, a hand-made
20
+ * manifest) is denied, never turned into a pattern.
21
+ * TAG-238: the length cap is the plain `URL_MAX_LENGTH`, so a component bundle does not carry the
22
+ * whole `MANIFEST_LIMITS` object for it.
23
+ */
24
+ import { URL_MAX_LENGTH } from "./limits.js";
25
+ import { EMAIL_PATTERN } from "./value-patterns.js";
26
+ /** URL schemes a `url` prop may accept; `javascript:`, `data:` and the rest are impossible. */
27
+ export const URL_PROTOCOLS = Object.freeze(["https", "http", "mailto"]);
28
+ /** Schemes a `url` prop accepts when it declares none. */
29
+ export const DEFAULT_URL_PROTOCOLS = Object.freeze(["https"]);
30
+ /** Schemes of the `url` string format in value schemas (event details, collection fields). */
31
+ export const WEB_URL_PROTOCOLS = Object.freeze(["https", "http"]);
32
+ /**
33
+ * One character of a URL value: printable ASCII (`!` to `~`) except `"`, `'`, `<`, `>`, `\` and
34
+ * the backtick. Written as ranges so the pattern needs no regex flag (the JSON Schema keeps it).
35
+ */
36
+ const URL_CHARACTER = "[!#-&(-;=?-\\[\\]-_a-z{-~]";
37
+ function schemePrefix(protocol) {
38
+ return protocol === "mailto" ? "mailto:" : `${protocol}://`;
39
+ }
40
+ /**
41
+ * Builds the text rule of a URL that uses one of `protocols`.
42
+ *
43
+ * Inputs: schemes from `URL_PROTOCOLS` (never manifest text). Output: an anchored pattern without
44
+ * flags. Errors: none. Side effects: none.
45
+ */
46
+ export function urlPattern(protocols) {
47
+ return new RegExp(`^(?:${protocols.map(schemePrefix).join("|")})${URL_CHARACTER}+$`);
48
+ }
49
+ /**
50
+ * The structural rule of any `url` prop default, whatever its `protocols`: the JSON Schema checks
51
+ * it, so a `javascript:` default is refused even by consumers that skip the Zod-only rules.
52
+ */
53
+ export const URL_VALUE_PATTERN = urlPattern(URL_PROTOCOLS);
54
+ function parseUrl(text) {
55
+ // Read from globalThis: the build has no DOM lib, and a missing parser must fail closed.
56
+ const Parser = globalThis.URL;
57
+ if (Parser === undefined)
58
+ return undefined;
59
+ try {
60
+ return new Parser(text);
61
+ }
62
+ catch {
63
+ return undefined;
64
+ }
65
+ }
66
+ /** The only `mailto:` header fields accepted; anything else (`cc`, `bcc`, `to`…) is refused. */
67
+ const MAILTO_FIELDS = /* @__PURE__ */ new Set(["subject", "body"]);
68
+ /** An encoded line break (`%0D`, `%0A`, any case): a header break everywhere but in `body`. */
69
+ const ENCODED_LINE_BREAK = /%0[ad]/i;
70
+ /** One `name=value` field of a `mailto:` query: a known name, no `;`, line breaks only in body. */
71
+ function isMailtoField(field) {
72
+ const equals = field.indexOf("=");
73
+ const name = (equals === -1 ? field : field.slice(0, equals)).toLowerCase();
74
+ const value = equals === -1 ? "" : field.slice(equals + 1);
75
+ if (!MAILTO_FIELDS.has(name) || value.includes(";"))
76
+ return false;
77
+ return name === "body" || !ENCODED_LINE_BREAK.test(value);
78
+ }
79
+ /**
80
+ * `mailto:` text after the scheme, all of it (the whole text reaches `href`, so nothing may hide
81
+ * after a `#` or a second `?`; security review of TAG-303): one address that `EMAIL_PATTERN`
82
+ * accepts as written (no comma list, no percent-encoded `@` or `,`), then optionally one `?` with
83
+ * `subject`/`body` fields only. No `#` at all. Field names are compared as written,
84
+ * case-insensitively (an encoded name is refused); no value holds `;`, and only `body` may hold
85
+ * an encoded line break (`%0D`/`%0A`), which elsewhere would start a new header.
86
+ */
87
+ function isSingleMailto(text) {
88
+ const rest = text.slice("mailto:".length);
89
+ if (rest.includes("#"))
90
+ return false;
91
+ const [address = "", query, ...extra] = rest.split("?");
92
+ if (extra.length > 0 || !EMAIL_PATTERN.test(address))
93
+ return false;
94
+ return query === undefined || query.split("&").every(isMailtoField);
95
+ }
96
+ /** `http(s)://` text: no `@` in the authority, which is what userinfo needs. */
97
+ function hasNoUserinfo(text, url) {
98
+ const afterScheme = text.slice(text.indexOf("://") + 3);
99
+ const authority = afterScheme.split(/[/?#]/, 1)[0] ?? "";
100
+ return !authority.includes("@") && url.username === "" && url.password === "";
101
+ }
102
+ function isKnownProtocol(protocol) {
103
+ return URL_PROTOCOLS.includes(protocol);
104
+ }
105
+ /** The common part of every URL rule: bounded text, known schemes, pattern, parser, same scheme. */
106
+ function parseAllowed(text, protocols) {
107
+ if (typeof text !== "string" || text.length > URL_MAX_LENGTH)
108
+ return undefined;
109
+ const known = protocols.filter(isKnownProtocol);
110
+ if (known.length === 0 || !urlPattern(known).test(text))
111
+ return undefined;
112
+ const url = parseUrl(text);
113
+ return url !== undefined && known.some((allowed) => `${allowed}:` === url.protocol)
114
+ ? url
115
+ : undefined;
116
+ }
117
+ /**
118
+ * Tells whether a text is an acceptable URL for one of `protocols`.
119
+ *
120
+ * Inputs: any value and the accepted schemes; entries that are not in `URL_PROTOCOLS` (a newer
121
+ * contract's scheme, a hand-made manifest) are ignored, so they deny instead of widening. Output:
122
+ * `true` only for a string of at most `MANIFEST_LIMITS.urlMaxLength` characters that matches
123
+ * `urlPattern` of the known schemes, that the WHATWG URL parser accepts with that same scheme and
124
+ * that has no userinfo (`http`, `https`) or is a single address with only `subject`/`body`
125
+ * (`mailto`). Errors: none (parser errors mean `false`). Side effects: none.
126
+ */
127
+ export function isAllowedUrl(text, protocols) {
128
+ const url = parseAllowed(text, protocols);
129
+ if (url === undefined)
130
+ return false;
131
+ return url.protocol === "mailto:"
132
+ ? isSingleMailto(text)
133
+ : hasNoUserinfo(text, url);
134
+ }
135
+ /**
136
+ * `isAllowedUrl(text, WEB_URL_PROTOCOLS)` without the `mailto:` rule, which it can never need: the
137
+ * `url` string format of value schemas uses it, so a bundle that only checks values (the SDK's
138
+ * `track`, TAG-203) leaves the `mailto:` code out (size budget of TAG-202, TAG-303).
139
+ *
140
+ * Inputs: any value. Output: `true` only for an `https://` or `http://` URL that `isAllowedUrl`
141
+ * accepts with those schemes. Errors: none. Side effects: none.
142
+ */
143
+ export function isAllowedWebUrl(text) {
144
+ const url = parseAllowed(text, WEB_URL_PROTOCOLS);
145
+ return url !== undefined && hasNoUserinfo(text, url);
146
+ }
147
+ //# sourceMappingURL=url-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-value.js","sourceRoot":"","sources":["../src/url-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,+FAA+F;AAC/F,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAU,CAAC,CAAC;AAGjF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,qBAAqB,GAA2B,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;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,aAAa,CAAC,IAAc,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAClD,OAAO,GAAG,KAAK,SAAS,IAAI,aAAa,CAAC,IAAc,EAAE,GAAG,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * The anomaly guard of the render count (TAG-1730, decisions 64 and 69): the pure rule that turns
3
+ * what the loader hit points say into the count a rendering cut may be judged on.
4
+ *
5
+ * Why it exists: the site key and its allowed domains are public, so anyone can forge loader hits
6
+ * with a `Referer` and a `User-Agent`. The raw count is fine to SHOW (warnings, the portal) but a
7
+ * cut of someone's components must never rest on it. The guarded count differs from the raw one in
8
+ * three ways, all of which can only LOWER it (every doubt falls on the customer's side):
9
+ * 1. only human-class traffic counts (the readers filter it; bots are kept for audit);
10
+ * 2. only deliveries that name their network count at all (TAG-1823: the network is written in a
11
+ * point of its own, without the visitor hash, so a request under a honored `Sec-GPC: 1` or
12
+ * without a known ASN adds nothing here);
13
+ * 3. no network source (an ASN) may contribute more than `sourceShare` of the cut line, so one
14
+ * network alone can never move a workspace over it: more than `1 / sourceShare` (ten) networks
15
+ * are needed.
16
+ * What it does NOT stop: a botnet spread over many networks that stays under the spike rule. That is
17
+ * why the cut also needs the open-flag exclusion (`suspectSiteKeys`: an open flag only holds the Free cut, it never holds a bill) and the
18
+ * owner's approval of the cut line (decision 69); the cut flag stays off until then.
19
+ *
20
+ * Zod-free. Privacy: a source is an ASN (a network, not a person); the visitor hash is never read here and never sits in the same point as the ASN (TAG-1823).
21
+ */
22
+ /**
23
+ * The provisional numbers of the guard. The cut line it judges a count against is the caller's
24
+ * (Free: 1x its number, `OVERAGE_RULES.freeCutMultiple`; decision 84 removed the 3x of decision 69).
25
+ */
26
+ export declare const USAGE_GUARD: Readonly<{
27
+ /**
28
+ * The most one source may add, as a share of the cut line. 0.10 since TAG-1823 (it was 0.25): the guard
29
+ * counts deliveries per network now, so one machine of one network reaches the cap; at 0.25 two VPS networks
30
+ * took the count to 1.5 times the allowance and could trigger the notice of an honest customer. At 0.10 a
31
+ * network adds at most 0.3 times the allowance and more than ten are needed to cross the line. A flood
32
+ * from many networks can still raise a notice; the cut needs the flag and a person (decision 69).
33
+ */
34
+ sourceShare: 0.1;
35
+ /**
36
+ * The share when the line is the allowance itself (TAG-1628, decision 84: the Free plan is cut at 1x, no
37
+ * grace). Cutting at 1x instead of 3x makes a forged flood three times cheaper, so each network adds half
38
+ * as much (5% of the line): more than TWENTY networks are needed to cross it (exactly twenty reach the line, and the cut reads
39
+ * the count ABOVE it, TAG-1628 review L1), where the 3x line needed
40
+ * more than ten at 30% of an allowance each. The cut still needs the open-flag exclusion and the 100% notice.
41
+ */
42
+ freeSourceShare: 0.05;
43
+ }>;
44
+ /**
45
+ * The spike rule of a site's stored submissions (TAG-1629): the daily signal that feeds `suspectSites`: it
46
+ * protects the Free cut by count (review B2) and triggers the customer's unusual-traffic e-mail. It never
47
+ * holds or changes a bill (decision 84 amendment: a customer pays what was used). A
48
+ * stored submission keeps no network (visitor privacy), so the guard of the renders (per network) is
49
+ * not possible; the signal is the SITE's own daily rate against its own baseline and an absolute floor,
50
+ * the same shape as `VIEW_SPIKE_RULE` (see `detectViewSpikes`, which judges both). A day with more than
51
+ * `multiplier` times the mean of the `baselineDays` days before it, and at least the floor, is a spike.
52
+ * PROVISIONAL, owner-confirmable. What it does not catch: steady forging under the floor (bounded by
53
+ * the floor times the days, per site) and a slow ramp.
54
+ */
55
+ export declare const SUBMISSION_SPIKE_RULE: Readonly<{
56
+ multiplier: 10;
57
+ baselineDays: 7;
58
+ /** The most a day's floor is, whatever the plan; see `submissionSpikeRule`. */
59
+ minCount: 50;
60
+ }>;
61
+ /**
62
+ * The submissions spike rule of a plan.
63
+ * Inputs: the plan's submissions per month. Output: the rule with the plan's floor: the lower of
64
+ * `SUBMISSION_SPIKE_RULE.minCount` and a thirtieth of the month (at least 1), so a Free site (250 a
65
+ * month) is judged at 8 a day. Shaped like `ViewSpikeRule` so `detectViewSpikes` reads it. Pure.
66
+ */
67
+ export declare function submissionSpikeRule(submissionsPerMonth: number): {
68
+ readonly multiplier: number;
69
+ readonly baselineDays: number;
70
+ readonly minViews: number;
71
+ };
72
+ /**
73
+ * The human deliveries one network brought to one site on one UTC day, counted in the network's own
74
+ * point (TAG-1823: never next to a visitor hash, so a distinct count per network is not possible;
75
+ * the per-source cap does the work a distinct count did: a loop from one place stays at its cap).
76
+ */
77
+ export interface SourceDay {
78
+ /** The network: an ASN as text, `""` when unknown (all unknown traffic is ONE source). */
79
+ readonly source: string;
80
+ /** Deliveries of that network to that site and day. */
81
+ readonly views: number;
82
+ }
83
+ /**
84
+ * The most one source may contribute to a count judged against `line`.
85
+ * Inputs: the cut line (visits) and, optionally, the share (default `sourceShare`; the Free plan's
86
+ * 1x line passes `freeSourceShare`). Output: that share of the line, rounded down, at least 1.
87
+ * Errors: none. No side effects.
88
+ */
89
+ export declare function sourceCapOf(line: number, share?: number): number;
90
+ /**
91
+ * The guarded count: views summed per source, each source capped, then added up.
92
+ * Inputs: the rows (any number per source: sites and days are folded together), the cut line
93
+ * the count will be read against and, optionally, the per-source share (default `sourceShare`).
94
+ * Output: the count; invalid rows (negative or not finite) are ignored. Because each source is capped
95
+ * at `share` of `line`, a count above `line` needs more than `1 / share` sources. Errors: none. No
96
+ * side effects.
97
+ */
98
+ export declare function guardedViews(rows: readonly SourceDay[], line: number, share?: number): number;
99
+ //# sourceMappingURL=usage-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-guard.d.ts","sourceRoot":"","sources":["../src/usage-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;GAGG;AACH,eAAO,MAAM,WAAW;IACtB;;;;;;OAMG;;IAEH;;;;;;OAMG;;EAEH,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB;;;IAGhC,+EAA+E;;EAE/E,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,mBAAmB,EAAE,MAAM,GAAG;IAChE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CASA;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,0FAA0F;IAC1F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAgC,GAAG,MAAM,CAEzF;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,SAAS,EAAE,EAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,MAAgC,GACtC,MAAM,CAUR"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * The anomaly guard of the render count (TAG-1730, decisions 64 and 69): the pure rule that turns
3
+ * what the loader hit points say into the count a rendering cut may be judged on.
4
+ *
5
+ * Why it exists: the site key and its allowed domains are public, so anyone can forge loader hits
6
+ * with a `Referer` and a `User-Agent`. The raw count is fine to SHOW (warnings, the portal) but a
7
+ * cut of someone's components must never rest on it. The guarded count differs from the raw one in
8
+ * three ways, all of which can only LOWER it (every doubt falls on the customer's side):
9
+ * 1. only human-class traffic counts (the readers filter it; bots are kept for audit);
10
+ * 2. only deliveries that name their network count at all (TAG-1823: the network is written in a
11
+ * point of its own, without the visitor hash, so a request under a honored `Sec-GPC: 1` or
12
+ * without a known ASN adds nothing here);
13
+ * 3. no network source (an ASN) may contribute more than `sourceShare` of the cut line, so one
14
+ * network alone can never move a workspace over it: more than `1 / sourceShare` (ten) networks
15
+ * are needed.
16
+ * What it does NOT stop: a botnet spread over many networks that stays under the spike rule. That is
17
+ * why the cut also needs the open-flag exclusion (`suspectSiteKeys`: an open flag only holds the Free cut, it never holds a bill) and the
18
+ * owner's approval of the cut line (decision 69); the cut flag stays off until then.
19
+ *
20
+ * Zod-free. Privacy: a source is an ASN (a network, not a person); the visitor hash is never read here and never sits in the same point as the ASN (TAG-1823).
21
+ */
22
+ /**
23
+ * The provisional numbers of the guard. The cut line it judges a count against is the caller's
24
+ * (Free: 1x its number, `OVERAGE_RULES.freeCutMultiple`; decision 84 removed the 3x of decision 69).
25
+ */
26
+ export const USAGE_GUARD = Object.freeze({
27
+ /**
28
+ * The most one source may add, as a share of the cut line. 0.10 since TAG-1823 (it was 0.25): the guard
29
+ * counts deliveries per network now, so one machine of one network reaches the cap; at 0.25 two VPS networks
30
+ * took the count to 1.5 times the allowance and could trigger the notice of an honest customer. At 0.10 a
31
+ * network adds at most 0.3 times the allowance and more than ten are needed to cross the line. A flood
32
+ * from many networks can still raise a notice; the cut needs the flag and a person (decision 69).
33
+ */
34
+ sourceShare: 0.1,
35
+ /**
36
+ * The share when the line is the allowance itself (TAG-1628, decision 84: the Free plan is cut at 1x, no
37
+ * grace). Cutting at 1x instead of 3x makes a forged flood three times cheaper, so each network adds half
38
+ * as much (5% of the line): more than TWENTY networks are needed to cross it (exactly twenty reach the line, and the cut reads
39
+ * the count ABOVE it, TAG-1628 review L1), where the 3x line needed
40
+ * more than ten at 30% of an allowance each. The cut still needs the open-flag exclusion and the 100% notice.
41
+ */
42
+ freeSourceShare: 0.05,
43
+ });
44
+ /**
45
+ * The spike rule of a site's stored submissions (TAG-1629): the daily signal that feeds `suspectSites`: it
46
+ * protects the Free cut by count (review B2) and triggers the customer's unusual-traffic e-mail. It never
47
+ * holds or changes a bill (decision 84 amendment: a customer pays what was used). A
48
+ * stored submission keeps no network (visitor privacy), so the guard of the renders (per network) is
49
+ * not possible; the signal is the SITE's own daily rate against its own baseline and an absolute floor,
50
+ * the same shape as `VIEW_SPIKE_RULE` (see `detectViewSpikes`, which judges both). A day with more than
51
+ * `multiplier` times the mean of the `baselineDays` days before it, and at least the floor, is a spike.
52
+ * PROVISIONAL, owner-confirmable. What it does not catch: steady forging under the floor (bounded by
53
+ * the floor times the days, per site) and a slow ramp.
54
+ */
55
+ export const SUBMISSION_SPIKE_RULE = Object.freeze({
56
+ multiplier: 10,
57
+ baselineDays: 7,
58
+ /** The most a day's floor is, whatever the plan; see `submissionSpikeRule`. */
59
+ minCount: 50,
60
+ });
61
+ /**
62
+ * The submissions spike rule of a plan.
63
+ * Inputs: the plan's submissions per month. Output: the rule with the plan's floor: the lower of
64
+ * `SUBMISSION_SPIKE_RULE.minCount` and a thirtieth of the month (at least 1), so a Free site (250 a
65
+ * month) is judged at 8 a day. Shaped like `ViewSpikeRule` so `detectViewSpikes` reads it. Pure.
66
+ */
67
+ export function submissionSpikeRule(submissionsPerMonth) {
68
+ return Object.freeze({
69
+ multiplier: SUBMISSION_SPIKE_RULE.multiplier,
70
+ baselineDays: SUBMISSION_SPIKE_RULE.baselineDays,
71
+ minViews: Math.max(1, Math.min(SUBMISSION_SPIKE_RULE.minCount, Math.floor(submissionsPerMonth / 30))),
72
+ });
73
+ }
74
+ /**
75
+ * The most one source may contribute to a count judged against `line`.
76
+ * Inputs: the cut line (visits) and, optionally, the share (default `sourceShare`; the Free plan's
77
+ * 1x line passes `freeSourceShare`). Output: that share of the line, rounded down, at least 1.
78
+ * Errors: none. No side effects.
79
+ */
80
+ export function sourceCapOf(line, share = USAGE_GUARD.sourceShare) {
81
+ return Math.max(1, Math.floor(line * share));
82
+ }
83
+ /**
84
+ * The guarded count: views summed per source, each source capped, then added up.
85
+ * Inputs: the rows (any number per source: sites and days are folded together), the cut line
86
+ * the count will be read against and, optionally, the per-source share (default `sourceShare`).
87
+ * Output: the count; invalid rows (negative or not finite) are ignored. Because each source is capped
88
+ * at `share` of `line`, a count above `line` needs more than `1 / share` sources. Errors: none. No
89
+ * side effects.
90
+ */
91
+ export function guardedViews(rows, line, share = USAGE_GUARD.sourceShare) {
92
+ const bySource = new Map();
93
+ for (const row of rows) {
94
+ if (!Number.isFinite(row.views) || row.views < 0)
95
+ continue;
96
+ bySource.set(row.source, (bySource.get(row.source) ?? 0) + row.views);
97
+ }
98
+ const cap = sourceCapOf(line, share);
99
+ let total = 0;
100
+ for (const views of bySource.values())
101
+ total += Math.min(views, cap);
102
+ return total;
103
+ }
104
+ //# sourceMappingURL=usage-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-guard.js","sourceRoot":"","sources":["../src/usage-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC;;;;;;OAMG;IACH,WAAW,EAAE,GAAG;IAChB;;;;;;OAMG;IACH,eAAe,EAAE,IAAI;CACtB,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,UAAU,EAAE,EAAE;IACd,YAAY,EAAE,CAAC;IACf,+EAA+E;IAC/E,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,mBAA2B;IAK7D,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,UAAU,EAAE,qBAAqB,CAAC,UAAU;QAC5C,YAAY,EAAE,qBAAqB,CAAC,YAAY;QAChD,QAAQ,EAAE,IAAI,CAAC,GAAG,CAChB,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC,CAC/E;KACF,CAAC,CAAC;AACL,CAAC;AAcD;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,QAAgB,WAAW,CAAC,WAAW;IAC/E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,IAA0B,EAC1B,IAAY,EACZ,QAAgB,WAAW,CAAC,WAAW;IAEvC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC;YAAE,SAAS;QAC3D,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE;QAAE,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACrE,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The `quota:<workspaceId>` mirror (TAG-712): the workspace's usage as the API's hourly job last
3
+ * measured it, in the Workers KV namespace the edge already reads, so a consumer on the request
4
+ * path (the edge; TAG-1607 enforces from it) never queries Postgres or the Analytics Engine.
5
+ * Written by apps/api (application/usage/usage-mirror.ts), read by whoever enforces. Zod-free.
6
+ *
7
+ * It is approximate and about an hour old or more by design. `enforceableRenders` leaves out the
8
+ * sites whose render count looks forged (`suspectSiteKeys`: an open spike flag, or one a person
9
+ * closed as forged): a reader must act on it, never on `renders.used`. The guard catches sudden
10
+ * spikes only; a slow ramp or steady forging under the plan's daily floor passes it (bounded by
11
+ * the plan, `spikeMinViews`). So a reader must never cut or degrade a workspace on renders alone:
12
+ * a person looks first (TAG-1607). Security review of TAG-801.
13
+ */
14
+ import type { UsageLevel } from "./plan-usage.js";
15
+ /** Layout version; a reader of a newer one treats the mirror as absent. */
16
+ export declare const QUOTA_MIRROR_VERSION = 1;
17
+ /** One measured quantity against its allowance. */
18
+ export interface QuotaMeasure {
19
+ readonly used: number;
20
+ readonly limit: number;
21
+ readonly percent: number;
22
+ readonly level: UsageLevel;
23
+ }
24
+ /** The mirror of one workspace and month. */
25
+ export interface QuotaMirror {
26
+ readonly v: typeof QUOTA_MIRROR_VERSION;
27
+ readonly workspaceId: string;
28
+ readonly planId: string;
29
+ /** First instant of the UTC month, ISO. */
30
+ readonly period: string;
31
+ /** When the job measured, ISO. */
32
+ readonly updatedAt: string;
33
+ /**
34
+ * The loader hit reader answered. When false the render measures hold zeros that mean
35
+ * "unknown": a reader must not read them as "under the limit" to act on, nor as "over".
36
+ */
37
+ readonly rendersKnown: boolean;
38
+ readonly renders: QuotaMeasure;
39
+ /** The measure of renders without the suspect sites: the only one to enforce from. */
40
+ readonly enforceableRenders: QuotaMeasure;
41
+ readonly submissions: QuotaMeasure;
42
+ readonly storage: QuotaMeasure;
43
+ /** Site keys whose renders look forged and wait for a review. */
44
+ readonly suspectSiteKeys: readonly string[];
45
+ }
46
+ /** The KV key of a workspace's mirror. Inputs: a workspace id. Output: the key. No side effects. */
47
+ export declare function quotaMirrorKey(workspaceId: string): string;
48
+ /**
49
+ * Reads a mirror back from its KV text.
50
+ * Inputs: the stored text (or `null`). Output: the mirror, or `null` when absent, not JSON, of
51
+ * another version or malformed (a reader then treats the workspace as unmeasured, never as over).
52
+ * Errors: none. No side effects.
53
+ */
54
+ export declare function parseQuotaMirror(text: string | null): QuotaMirror | null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C,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAmBxE"}
@@ -0,0 +1,52 @@
1
+ /** Layout version; a reader of a newer one treats the mirror as absent. */
2
+ export const QUOTA_MIRROR_VERSION = 1;
3
+ /** The KV key of a workspace's mirror. Inputs: a workspace id. Output: the key. No side effects. */
4
+ export function quotaMirrorKey(workspaceId) {
5
+ return `quota:${workspaceId}`;
6
+ }
7
+ function isMeasure(value) {
8
+ if (typeof value !== "object" || value === null)
9
+ return false;
10
+ const m = value;
11
+ return (typeof m["used"] === "number" &&
12
+ typeof m["limit"] === "number" &&
13
+ typeof m["percent"] === "number" &&
14
+ (m["level"] === "ok" || m["level"] === "warning" || m["level"] === "reached"));
15
+ }
16
+ /**
17
+ * Reads a mirror back from its KV text.
18
+ * Inputs: the stored text (or `null`). Output: the mirror, or `null` when absent, not JSON, of
19
+ * another version or malformed (a reader then treats the workspace as unmeasured, never as over).
20
+ * Errors: none. No side effects.
21
+ */
22
+ export function parseQuotaMirror(text) {
23
+ if (text === null)
24
+ return null;
25
+ let value;
26
+ try {
27
+ value = JSON.parse(text);
28
+ }
29
+ catch {
30
+ return null;
31
+ }
32
+ if (typeof value !== "object" || value === null)
33
+ return null;
34
+ const m = value;
35
+ if (m["v"] !== QUOTA_MIRROR_VERSION)
36
+ return null;
37
+ if (typeof m["workspaceId"] !== "string" || typeof m["planId"] !== "string")
38
+ return null;
39
+ if (typeof m["period"] !== "string" || typeof m["updatedAt"] !== "string")
40
+ return null;
41
+ if (typeof m["rendersKnown"] !== "boolean")
42
+ return null;
43
+ if (!isMeasure(m["renders"]) || !isMeasure(m["enforceableRenders"]))
44
+ return null;
45
+ if (!isMeasure(m["submissions"]) || !isMeasure(m["storage"]))
46
+ return null;
47
+ const suspects = m["suspectSiteKeys"];
48
+ if (!Array.isArray(suspects) || !suspects.every((key) => typeof key === "string"))
49
+ return null;
50
+ return value;
51
+ }
52
+ //# sourceMappingURL=usage-mirror.js.map
@@ -0,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AC,aAAa,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACzF,IAAI,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,WAAW,CAAC,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACvF,IAAI,OAAO,CAAC,CAAC,cAAc,CAAC,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACxD,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACjF,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1E,MAAM,QAAQ,GAAG,CAAC,CAAC,iBAAiB,CAAC,CAAC;IACtC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/F,OAAO,KAAoB,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,88 @@
1
+ import type { ValueSchema } from "./value-schema.js";
2
+ /** Why a value or an attribute was refused. Short codes, for debug warnings and tests. */
3
+ export type ValueProblem = "wrong-type" | "malformed" | "too-long" | "too-short" | "too-deep" | "too-large" | "below-min" | "above-max" | "not-integer" | "not-allowed" | "missing-field";
4
+ /** Result of a check: the accepted (fresh) value, or the first problem found. Never thrown. */
5
+ export type ValueOutcome<T> = {
6
+ readonly ok: true;
7
+ readonly value: T;
8
+ } | {
9
+ readonly ok: false;
10
+ readonly problem: ValueProblem;
11
+ };
12
+ /**
13
+ * Builds a successful outcome.
14
+ *
15
+ * Inputs: the accepted value. Output: `{ ok: true, value }`. Errors: none. Side effects: none.
16
+ */
17
+ export declare function accepted<T>(value: T): ValueOutcome<T>;
18
+ /**
19
+ * Builds a failed outcome.
20
+ *
21
+ * Inputs: the problem. Output: `{ ok: false, problem }`. Errors: none. Side effects: none.
22
+ */
23
+ export declare function refused(problem: ValueProblem): ValueOutcome<never>;
24
+ /**
25
+ * Length of a string in Unicode code points, the one unit of every string value limit in the
26
+ * contract (TAG-224, `SPEC.md` "Unidade de tamanho de string"): a surrogate pair counts as one
27
+ * and a lone surrogate as one, exactly as Zod's string `min`/`max` and JSON Schema's
28
+ * `minLength`/`maxLength` (Ajv with its default `unicode: true`) count.
29
+ *
30
+ * Inputs: any string. Output: its code point count. Errors: none. Side effects: none. Linear in
31
+ * the length (one native regex pass); callers bound the text first.
32
+ */
33
+ export declare function codePointLength(text: string): number;
34
+ /**
35
+ * The shape of a declared field name: `FIELD_NAME_PATTERN` (names.ts, which imports Zod) without
36
+ * its lookahead over `Object.prototype` members, which are harmless as own data keys. It starts
37
+ * with a letter, so it never matches `__proto__`. A test keeps the two sources in step.
38
+ */
39
+ export declare const FIELD_NAME_SHAPE: RegExp;
40
+ /**
41
+ * Checks a JS value against a declared value schema and returns a fresh copy of it.
42
+ *
43
+ * Inputs: a value schema already accepted by `valueSchema` (a prop declaration of a matching type
44
+ * works too: extra keys such as `default` are ignored), and any value. Output: `{ ok: true, value }`
45
+ * with a new array or object for containers (undeclared object keys dropped, like Zod's "strip"),
46
+ * or `{ ok: false, problem }` for the first problem (`not-allowed` for a schema `type` this release
47
+ * does not know, or a field name outside `FIELD_NAME_SHAPE` in a schema that was never
48
+ * validated). String lengths are in code points (`codePointLength`, TAG-224), as in Zod and JSON
49
+ * Schema. Strings without `maxLength` are capped at `MANIFEST_LIMITS.stringMaxLength`, arrays
50
+ * without `maxItems` at `arrayMaxItems`. Arrays are read by index from `0` to their `length`,
51
+ * which is read once and checked against `maxItems` first, never through `Symbol.iterator`, so a
52
+ * live array (own iterator, Proxy) cannot pass more items than it declares. Only own fields count:
53
+ * a declared field the value merely inherits is absent (TAG-304 parity test). Fields are defined
54
+ * by `Object.fromEntries`, never assigned (TAG-304); items are appended with `push`, which only a
55
+ * page setter on a numeric key of `Array.prototype`/`Object.prototype` could intercept (that page
56
+ * breaks every array, its own included). Recursion follows the schema, which nests at most
57
+ * `valueSchemaDepth` levels once validated. Each call has a budget of
58
+ * `MANIFEST_LIMITS.maxJsonLength` work units (TAG-226): every visited value costs 1, a string
59
+ * also its UTF-16 length and an object also the number of fields its schema declares (each is
60
+ * read, present or not); past the budget the call stops with `too-large`. A value costs at most
61
+ * its JSON text length plus one per declared field it leaves out (each value takes at least one
62
+ * character of JSON, a string its length plus two quotes, a present field its quoted name and a
63
+ * colon), so every value an attribute (`propJsonMaxLength`) or a `<script data-props>`
64
+ * (`propsScriptMaxLength`) can carry passes unless its objects omit tens of thousands of declared
65
+ * fields in all; Zod has no budget, the one other difference from it besides inherited fields.
66
+ * Only such values or live ones reach it: shared references (one array listed 1,000 times, as a
67
+ * `postMessage` copy keeps them) would otherwise be walked and copied once per
68
+ * reference, up to 1,000³ nodes or 10⁶ strings of 10,000. Errors: none for a validated schema
69
+ * and plain data; a throwing getter or Proxy trap propagates, and so does a schema that was never
70
+ * validated whose `required`, `values`, `fields` or `items` has the wrong type, or that is cyclic
71
+ * (a `RangeError` once the stack is exhausted, with a cyclic value). Callers given such schemas
72
+ * catch: `propertyToValue` gives the default, the runtime's `emit` drops the event. Side effects:
73
+ * reads `length`, each index and each declared key once. Work is linear in the size of the value
74
+ * and bounded by the budget.
75
+ */
76
+ export declare function checkValue(schema: ValueSchema, value: unknown): ValueOutcome<unknown>;
77
+ /**
78
+ * Parses untrusted JSON text within limits: length first, then nesting, then `JSON.parse` (no
79
+ * reviver), so a hostile text can neither make the parser recurse deeply nor run long.
80
+ *
81
+ * Inputs: the text, its maximum length in UTF-16 code units (a bound on the text itself, not a
82
+ * value limit, so not in code points) and the maximum nesting of arrays and
83
+ * objects. Output: the parsed value (not yet checked against any schema: pass it to `checkValue`),
84
+ * or `too-long`, `too-deep` or `malformed`. Errors: none (parser errors become `malformed`).
85
+ * Side effects: none.
86
+ */
87
+ export declare function parseBoundedJson(text: string, maxLength: number, maxDepth: number): ValueOutcome<unknown>;
88
+ //# sourceMappingURL=value-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-check.d.ts","sourceRoot":"","sources":["../src/value-check.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,0FAA0F;AAC1F,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,WAAW,GACX,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,WAAW,GACX,WAAW,GACX,aAAa,GACb,aAAa,GACb,eAAe,CAAC;AAEpB,+FAA+F;AAC/F,MAAM,MAAM,YAAY,CAAC,CAAC,IACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAA;CAAE,CAAC;AAEpG;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAErD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,CAElE;AAyBD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIpD;AAqBD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAA4B,CAAC;AAM1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,UAAU,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