@taggor/contract 0.0.0-stage → 0.1.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 (339) 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 +72 -0
  93. package/dist/index.d.ts.map +1 -0
  94. package/dist/index.js +72 -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 +371 -0
  109. package/dist/limit-catalog.d.ts.map +1 -0
  110. package/dist/limit-catalog.js +414 -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/names.d.ts +37 -0
  145. package/dist/names.d.ts.map +1 -0
  146. package/dist/names.js +55 -0
  147. package/dist/names.js.map +1 -0
  148. package/dist/overage-pricing.d.ts +89 -0
  149. package/dist/overage-pricing.d.ts.map +1 -0
  150. package/dist/overage-pricing.js +170 -0
  151. package/dist/overage-pricing.js.map +1 -0
  152. package/dist/plan-ids.d.ts +10 -0
  153. package/dist/plan-ids.d.ts.map +1 -0
  154. package/dist/plan-ids.js +8 -0
  155. package/dist/plan-ids.js.map +1 -0
  156. package/dist/plan-limits.d.ts +138 -0
  157. package/dist/plan-limits.d.ts.map +1 -0
  158. package/dist/plan-limits.js +112 -0
  159. package/dist/plan-limits.js.map +1 -0
  160. package/dist/plan-pricing.d.ts +145 -0
  161. package/dist/plan-pricing.d.ts.map +1 -0
  162. package/dist/plan-pricing.js +172 -0
  163. package/dist/plan-pricing.js.map +1 -0
  164. package/dist/plan-usage.d.ts +112 -0
  165. package/dist/plan-usage.d.ts.map +1 -0
  166. package/dist/plan-usage.js +134 -0
  167. package/dist/plan-usage.js.map +1 -0
  168. package/dist/preview-token.d.ts +52 -0
  169. package/dist/preview-token.d.ts.map +1 -0
  170. package/dist/preview-token.js +106 -0
  171. package/dist/preview-token.js.map +1 -0
  172. package/dist/prop-names.d.ts +51 -0
  173. package/dist/prop-names.d.ts.map +1 -0
  174. package/dist/prop-names.js +150 -0
  175. package/dist/prop-names.js.map +1 -0
  176. package/dist/prop-type-docs.d.ts +20 -0
  177. package/dist/prop-type-docs.d.ts.map +1 -0
  178. package/dist/prop-type-docs.js +89 -0
  179. package/dist/prop-type-docs.js.map +1 -0
  180. package/dist/prop-types.d.ts +97 -0
  181. package/dist/prop-types.d.ts.map +1 -0
  182. package/dist/prop-types.js +299 -0
  183. package/dist/prop-types.js.map +1 -0
  184. package/dist/props.d.ts +996 -0
  185. package/dist/props.d.ts.map +1 -0
  186. package/dist/props.js +183 -0
  187. package/dist/props.js.map +1 -0
  188. package/dist/proto-guard.d.ts +29 -0
  189. package/dist/proto-guard.d.ts.map +1 -0
  190. package/dist/proto-guard.js +79 -0
  191. package/dist/proto-guard.js.map +1 -0
  192. package/dist/runtime-errors.d.ts +42 -0
  193. package/dist/runtime-errors.d.ts.map +1 -0
  194. package/dist/runtime-errors.js +42 -0
  195. package/dist/runtime-errors.js.map +1 -0
  196. package/dist/runtime-pointers.d.ts +58 -0
  197. package/dist/runtime-pointers.d.ts.map +1 -0
  198. package/dist/runtime-pointers.js +84 -0
  199. package/dist/runtime-pointers.js.map +1 -0
  200. package/dist/secret-scan.d.ts +191 -0
  201. package/dist/secret-scan.d.ts.map +1 -0
  202. package/dist/secret-scan.js +542 -0
  203. package/dist/secret-scan.js.map +1 -0
  204. package/dist/semver.d.ts +89 -0
  205. package/dist/semver.d.ts.map +1 -0
  206. package/dist/semver.js +400 -0
  207. package/dist/semver.js.map +1 -0
  208. package/dist/server-key.d.ts +68 -0
  209. package/dist/server-key.d.ts.map +1 -0
  210. package/dist/server-key.js +150 -0
  211. package/dist/server-key.js.map +1 -0
  212. package/dist/site-manifest-keys.d.ts +107 -0
  213. package/dist/site-manifest-keys.d.ts.map +1 -0
  214. package/dist/site-manifest-keys.js +146 -0
  215. package/dist/site-manifest-keys.js.map +1 -0
  216. package/dist/site-manifest.d.ts +286 -0
  217. package/dist/site-manifest.d.ts.map +1 -0
  218. package/dist/site-manifest.js +100 -0
  219. package/dist/site-manifest.js.map +1 -0
  220. package/dist/source-archive.d.ts +119 -0
  221. package/dist/source-archive.d.ts.map +1 -0
  222. package/dist/source-archive.js +644 -0
  223. package/dist/source-archive.js.map +1 -0
  224. package/dist/source-package-corpus.d.ts +55 -0
  225. package/dist/source-package-corpus.d.ts.map +1 -0
  226. package/dist/source-package-corpus.js +303 -0
  227. package/dist/source-package-corpus.js.map +1 -0
  228. package/dist/source-package.d.ts +227 -0
  229. package/dist/source-package.d.ts.map +1 -0
  230. package/dist/source-package.js +361 -0
  231. package/dist/source-package.js.map +1 -0
  232. package/dist/source-secrets.d.ts +21 -0
  233. package/dist/source-secrets.d.ts.map +1 -0
  234. package/dist/source-secrets.js +43 -0
  235. package/dist/source-secrets.js.map +1 -0
  236. package/dist/ssr-cap.d.ts +61 -0
  237. package/dist/ssr-cap.d.ts.map +1 -0
  238. package/dist/ssr-cap.js +107 -0
  239. package/dist/ssr-cap.js.map +1 -0
  240. package/dist/ssr-kv.d.ts +18 -0
  241. package/dist/ssr-kv.d.ts.map +1 -0
  242. package/dist/ssr-kv.js +18 -0
  243. package/dist/ssr-kv.js.map +1 -0
  244. package/dist/ssr-version-ledger.d.ts +53 -0
  245. package/dist/ssr-version-ledger.d.ts.map +1 -0
  246. package/dist/ssr-version-ledger.js +88 -0
  247. package/dist/ssr-version-ledger.js.map +1 -0
  248. package/dist/style-references.d.ts +58 -0
  249. package/dist/style-references.d.ts.map +1 -0
  250. package/dist/style-references.js +241 -0
  251. package/dist/style-references.js.map +1 -0
  252. package/dist/tag-name.d.ts +87 -0
  253. package/dist/tag-name.d.ts.map +1 -0
  254. package/dist/tag-name.js +222 -0
  255. package/dist/tag-name.js.map +1 -0
  256. package/dist/tar-writer.d.ts +74 -0
  257. package/dist/tar-writer.d.ts.map +1 -0
  258. package/dist/tar-writer.js +148 -0
  259. package/dist/tar-writer.js.map +1 -0
  260. package/dist/testing.d.ts +11 -0
  261. package/dist/testing.d.ts.map +1 -0
  262. package/dist/testing.js +11 -0
  263. package/dist/testing.js.map +1 -0
  264. package/dist/text-codec.d.ts +36 -0
  265. package/dist/text-codec.d.ts.map +1 -0
  266. package/dist/text-codec.js +32 -0
  267. package/dist/text-codec.js.map +1 -0
  268. package/dist/url-value.d.ts +41 -0
  269. package/dist/url-value.d.ts.map +1 -0
  270. package/dist/url-value.js +147 -0
  271. package/dist/url-value.js.map +1 -0
  272. package/dist/usage-guard.d.ts +99 -0
  273. package/dist/usage-guard.d.ts.map +1 -0
  274. package/dist/usage-guard.js +104 -0
  275. package/dist/usage-guard.js.map +1 -0
  276. package/dist/usage-mirror.d.ts +55 -0
  277. package/dist/usage-mirror.d.ts.map +1 -0
  278. package/dist/usage-mirror.js +52 -0
  279. package/dist/usage-mirror.js.map +1 -0
  280. package/dist/value-check.d.ts +88 -0
  281. package/dist/value-check.d.ts.map +1 -0
  282. package/dist/value-check.js +279 -0
  283. package/dist/value-check.js.map +1 -0
  284. package/dist/value-patterns.d.ts +9 -0
  285. package/dist/value-patterns.d.ts.map +1 -0
  286. package/dist/value-patterns.js +17 -0
  287. package/dist/value-patterns.js.map +1 -0
  288. package/dist/value-schema.d.ts +796 -0
  289. package/dist/value-schema.d.ts.map +1 -0
  290. package/dist/value-schema.js +231 -0
  291. package/dist/value-schema.js.map +1 -0
  292. package/dist/zod-free.d.ts +59 -0
  293. package/dist/zod-free.d.ts.map +1 -0
  294. package/dist/zod-free.js +57 -0
  295. package/dist/zod-free.js.map +1 -0
  296. package/package.json +75 -3
  297. package/schema/DEPLOYED +12 -0
  298. package/schema/build-diagnostic.v1.json +63 -0
  299. package/schema/component-manifest.v1.json +1000 -0
  300. package/schema/data-api.v1.json +194 -0
  301. package/schema/library-manifest.v1.json +60 -0
  302. package/schema/published/SHA256SUMS +36 -0
  303. package/schema/published/build-diagnostic/v1.10.json +83 -0
  304. package/schema/published/build-diagnostic/v1.3.json +83 -0
  305. package/schema/published/build-diagnostic/v1.4.json +83 -0
  306. package/schema/published/build-diagnostic/v1.5.json +83 -0
  307. package/schema/published/build-diagnostic/v1.6.json +83 -0
  308. package/schema/published/build-diagnostic/v1.7.json +83 -0
  309. package/schema/published/build-diagnostic/v1.8.json +83 -0
  310. package/schema/published/build-diagnostic/v1.9.json +83 -0
  311. package/schema/published/component-manifest/v1.10.json +1443 -0
  312. package/schema/published/component-manifest/v1.3.json +1411 -0
  313. package/schema/published/component-manifest/v1.4.json +1419 -0
  314. package/schema/published/component-manifest/v1.5.json +1437 -0
  315. package/schema/published/component-manifest/v1.6.json +1437 -0
  316. package/schema/published/component-manifest/v1.7.json +1437 -0
  317. package/schema/published/component-manifest/v1.8.json +1437 -0
  318. package/schema/published/component-manifest/v1.9.json +1437 -0
  319. package/schema/published/data-api/v1.10.json +282 -0
  320. package/schema/published/data-api/v1.3.json +281 -0
  321. package/schema/published/data-api/v1.4.json +281 -0
  322. package/schema/published/data-api/v1.5.json +281 -0
  323. package/schema/published/data-api/v1.6.json +281 -0
  324. package/schema/published/data-api/v1.7.json +281 -0
  325. package/schema/published/data-api/v1.8.json +282 -0
  326. package/schema/published/data-api/v1.9.json +282 -0
  327. package/schema/published/library-manifest/v1.10.json +68 -0
  328. package/schema/published/library-manifest/v1.5.json +68 -0
  329. package/schema/published/library-manifest/v1.6.json +68 -0
  330. package/schema/published/library-manifest/v1.7.json +68 -0
  331. package/schema/published/library-manifest/v1.8.json +68 -0
  332. package/schema/published/library-manifest/v1.9.json +68 -0
  333. package/schema/published/taggor-config/v1.10.json +56 -0
  334. package/schema/published/taggor-config/v1.5.json +56 -0
  335. package/schema/published/taggor-config/v1.6.json +56 -0
  336. package/schema/published/taggor-config/v1.7.json +56 -0
  337. package/schema/published/taggor-config/v1.8.json +56 -0
  338. package/schema/published/taggor-config/v1.9.json +56 -0
  339. package/schema/taggor-config.v1.json +39 -0
@@ -0,0 +1,78 @@
1
+ /**
2
+ * CSS values a manifest may declare (TAG-201): the default of a `color` prop and the defaults of
3
+ * public CSS variables, which the runtime writes into the component's stylesheet.
4
+ *
5
+ * A CSS value can fetch from the network (`url()`, `image-set()`, `src()`, `cross-fade()`…), so a
6
+ * free-form value would let a manifest leak every visitor's IP and Referer to an undeclared origin
7
+ * through `var(--x)` (threat T-64, golden rule 6). Values are therefore built from an allowlist:
8
+ * numbers, identifiers, `#`, `,`, `.`, `%`, `/`, `+`, whitespace, and `(` only right after a
9
+ * function in `CSS_FUNCTIONS` (lowercase). No `;`, braces, quotes, backslashes, `*` or angle
10
+ * brackets, so a value can neither close a declaration nor open a comment. JSON Schema cannot
11
+ * count parentheses, so only Zod checks that they are balanced (`SEMANTIC_RULES`).
12
+ *
13
+ * This module has no Zod (TAG-205), so the runtime may import it; `cssValueSchema` lives in
14
+ * `bounded.ts`.
15
+ */
16
+ /** CSS functions a declared value may call: colors, math and `var()`. None of them loads a URL. */
17
+ export const CSS_FUNCTIONS = Object.freeze([
18
+ "rgb",
19
+ "rgba",
20
+ "hsl",
21
+ "hsla",
22
+ "hwb",
23
+ "lab",
24
+ "lch",
25
+ "oklab",
26
+ "oklch",
27
+ "color",
28
+ "color-mix",
29
+ "calc",
30
+ "min",
31
+ "max",
32
+ "clamp",
33
+ "var",
34
+ ]);
35
+ // Longest names first so `rgba(` is not read as `rgb` + `a(`.
36
+ const FUNCTION_ALTERNATIVES = [...CSS_FUNCTIONS].sort((a, b) => b.length - a.length).join("|");
37
+ /**
38
+ * A CSS value from the allowlist. An identifier is read greedily and may be followed by `(` only
39
+ * when it is an allowed function, so `url(`, `image-set(`, `expression(` or `xrgb(` never match.
40
+ */
41
+ export const CSS_VALUE_PATTERN = new RegExp(`^(?:(?:${FUNCTION_ALTERNATIVES})\\(|[a-zA-Z-][a-zA-Z0-9-]*(?![a-zA-Z0-9(-])|[#0-9,.%/+\\s)])+$`);
42
+ /** A `font-family` list: names, commas and whitespace; no functions or quotes at all. */
43
+ export const FONT_FAMILY_PATTERN = /^[a-zA-Z0-9,\s-]+$/;
44
+ /**
45
+ * Tells whether every `(` in a value is closed, in order.
46
+ *
47
+ * Inputs: any string. Output: `true` when parentheses are balanced. Errors: none. Side effects:
48
+ * none.
49
+ */
50
+ export function hasBalancedParentheses(value) {
51
+ let depth = 0;
52
+ for (const character of value) {
53
+ if (character === "(")
54
+ depth += 1;
55
+ else if (character === ")") {
56
+ depth -= 1;
57
+ if (depth < 0)
58
+ return false;
59
+ }
60
+ }
61
+ return depth === 0;
62
+ }
63
+ /**
64
+ * Tells whether a text is a declared CSS value: within `maxLength`, built from the allowlist
65
+ * `pattern` and with balanced parentheses. The Zod form is `cssValueSchema` (bounded.ts); the
66
+ * prop catalog (TAG-205) uses this one, which the runtime may import without Zod.
67
+ *
68
+ * Inputs: the text, the maximum length, the allowlist pattern (`CSS_VALUE_PATTERN` or
69
+ * `FONT_FAMILY_PATTERN`). Output: `true` when every rule holds (empty text is refused). Errors:
70
+ * none. Side effects: none.
71
+ */
72
+ export function isCssValue(value, maxLength, pattern) {
73
+ return (value.length > 0 &&
74
+ value.length <= maxLength &&
75
+ pattern.test(value) &&
76
+ hasBalancedParentheses(value));
77
+ }
78
+ //# sourceMappingURL=css-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-value.js","sourceRoot":"","sources":["../src/css-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,mGAAmG;AACnG,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,OAAO;IACP,OAAO;IACP,OAAO;IACP,WAAW;IACX,MAAM;IACN,KAAK;IACL,KAAK;IACL,OAAO;IACP,KAAK;CACG,CAAC,CAAC;AAEZ,8DAA8D;AAC9D,MAAM,qBAAqB,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/F;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,MAAM,CACzC,UAAU,qBAAqB,iEAAiE,CACjG,CAAC;AAEF,yFAAyF;AACzF,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAExD;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,SAAS,IAAI,KAAK,EAAE,CAAC;QAC9B,IAAI,SAAS,KAAK,GAAG;YAAE,KAAK,IAAI,CAAC,CAAC;aAC7B,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;YAC3B,KAAK,IAAI,CAAC,CAAC;YACX,IAAI,KAAK,GAAG,CAAC;gBAAE,OAAO,KAAK,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,KAAK,KAAK,CAAC,CAAC;AACrB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,SAAiB,EAAE,OAAe;IAC1E,OAAO,CACL,KAAK,CAAC,MAAM,GAAG,CAAC;QAChB,KAAK,CAAC,MAAM,IAAI,SAAS;QACzB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QACnB,sBAAsB,CAAC,KAAK,CAAC,CAC9B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Data API of component contract v1 (TAG-201): the payloads a component exchanges with the edge through
3
+ * the SDK hooks (`useTaggorData`, `useTrack`, TAG-203): `submit` (form submissions), `read` (list a
4
+ * public collection) and `track` (declared interactions).
5
+ *
6
+ * The wire format is snake_case JSON, like every `/v1` API resource (TAG-905). Each envelope is
7
+ * strict; the `data` of a submission is checked against the collection the manifest declares with
8
+ * `collectionDataSchema`, which drops undeclared fields (TAG-703). Body sizes are bounded by
9
+ * `DATA_API_LIMITS` and must be enforced on the raw body before parsing (TAG-702). TAG-212 added
10
+ * the consent proof of submissions to components that collect personal data.
11
+ */
12
+ import * as z from "zod";
13
+ import type { CollectionDeclaration, TrackEventDeclaration } from "./manifest.js";
14
+ /**
15
+ * Proof of the visitor's consent sent with a submission of a component whose manifest declares
16
+ * `data.personal` (TAG-212): the consent was given, the SHA-256 (lowercase hex) of the exact text
17
+ * the visitor accepted and the language it was shown in. The text hashed is the SDK's: the
18
+ * checkbox label as rendered, a line feed and the privacy policy URL (`SPEC.md` §5).
19
+ */
20
+ export declare const consentProofSchema: z.ZodObject<{
21
+ given: z.ZodLiteral<true>;
22
+ text_hash: z.ZodString;
23
+ locale: z.ZodString;
24
+ }, z.core.$strict>;
25
+ /**
26
+ * Body of `submit` (`POST /d/<siteKey>/<collection>`).
27
+ *
28
+ * `data` holds the field values (validated afterwards by `collectionDataSchema`); `_hp` is the
29
+ * honeypot field that humans leave empty and `_t` the milliseconds between render and submit
30
+ * (TAG-730: they only mark a submission `suspect`, which is kept; nothing is dropped unless the
31
+ * site chose `protection.suspects: "drop"`). `consent` (TAG-212) is the visitor's consent,
32
+ * which the SDK always sends for a component with `data.personal` (the ingest of E07 refuses a
33
+ * submission of such a component without it, `consent_required`).
34
+ */
35
+ export declare const submitRequestSchema: z.ZodObject<{
36
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
37
+ idempotency_key: z.ZodString;
38
+ turnstile_token: z.ZodOptional<z.ZodString>;
39
+ _hp: z.ZodOptional<z.ZodString>;
40
+ _t: z.ZodOptional<z.ZodInt>;
41
+ consent: z.ZodOptional<z.ZodObject<{
42
+ given: z.ZodLiteral<true>;
43
+ text_hash: z.ZodString;
44
+ locale: z.ZodString;
45
+ }, z.core.$strict>>;
46
+ }, z.core.$strict>;
47
+ /** Answer to an accepted submission (HTTP 202): queued, not yet stored. */
48
+ export declare const submitAcceptedSchema: z.ZodObject<{
49
+ status: z.ZodLiteral<"accepted">;
50
+ }, z.core.$strict>;
51
+ /** Query of `read` (`GET /d/<siteKey>/<collection>`), after the edge decodes the query string. */
52
+ export declare const readRequestSchema: z.ZodObject<{
53
+ limit: z.ZodOptional<z.ZodInt>;
54
+ cursor: z.ZodOptional<z.ZodString>;
55
+ }, z.core.$strict>;
56
+ /** One page of `read`; only collections declared `public` can be read. */
57
+ export declare const readResponseSchema: z.ZodObject<{
58
+ data: z.ZodArray<z.ZodObject<{
59
+ id: z.ZodString;
60
+ created_at: z.ZodISODateTime;
61
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
62
+ }, z.core.$strict>>;
63
+ next_cursor: z.ZodNullable<z.ZodString>;
64
+ has_more: z.ZodBoolean;
65
+ }, z.core.$strict>;
66
+ /** Body of `track` (a beacon to the edge): one declared interaction of one component. */
67
+ export declare const trackRequestSchema: z.ZodObject<{
68
+ component: z.ZodString;
69
+ name: z.ZodString;
70
+ props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString]>>>;
71
+ }, z.core.$strict>;
72
+ /** Error codes of the data API; the SDK maps each to a friendly, translated message. */
73
+ export declare const DATA_ERROR_CODES: readonly ["validation_failed", "collection_not_found", "read_not_allowed", "event_not_declared", "origin_not_allowed", "rate_limited", "captcha_failed", "payload_too_large", "consent_required", "daily_cap_reached"];
74
+ /** Error body of the data API; `fields` lists per-field problems of `validation_failed`. */
75
+ export declare const dataErrorSchema: z.ZodObject<{
76
+ code: z.ZodEnum<{
77
+ validation_failed: "validation_failed";
78
+ collection_not_found: "collection_not_found";
79
+ read_not_allowed: "read_not_allowed";
80
+ event_not_declared: "event_not_declared";
81
+ origin_not_allowed: "origin_not_allowed";
82
+ rate_limited: "rate_limited";
83
+ captcha_failed: "captcha_failed";
84
+ payload_too_large: "payload_too_large";
85
+ consent_required: "consent_required";
86
+ daily_cap_reached: "daily_cap_reached";
87
+ }>;
88
+ message: z.ZodString;
89
+ fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
90
+ path: z.ZodString;
91
+ message: z.ZodString;
92
+ }, z.core.$strict>>>;
93
+ }, z.core.$strict>;
94
+ /** Body of `submit`. */
95
+ export type SubmitRequest = z.infer<typeof submitRequestSchema>;
96
+ /** The visitor's consent sent with a submission (`consent` of `SubmitRequest`). */
97
+ export type ConsentProof = z.infer<typeof consentProofSchema>;
98
+ /** Body of an accepted `submit`. */
99
+ export type SubmitAccepted = z.infer<typeof submitAcceptedSchema>;
100
+ /** Query of `read`. */
101
+ export type ReadRequest = z.infer<typeof readRequestSchema>;
102
+ /** One page of `read`. */
103
+ export type ReadResponse = z.infer<typeof readResponseSchema>;
104
+ /** Body of `track`. */
105
+ export type TrackRequest = z.infer<typeof trackRequestSchema>;
106
+ /** Error body of the data API. */
107
+ export type DataError = z.infer<typeof dataErrorSchema>;
108
+ /** Error code of the data API. */
109
+ export type DataErrorCode = (typeof DATA_ERROR_CODES)[number];
110
+ /**
111
+ * Builds the validator of the `data` of a submission to one declared collection.
112
+ *
113
+ * Inputs: the collection declaration from the manifest. Output: a Zod object schema; undeclared
114
+ * fields are dropped (TAG-703), required fields must be present, strings are capped at
115
+ * `MANIFEST_LIMITS.stringMaxLength`. Errors: none at build time; parsing returns Zod issues with
116
+ * the field path. Side effects: none.
117
+ */
118
+ export declare function collectionDataSchema(collection: CollectionDeclaration): z.ZodType;
119
+ /**
120
+ * Builds the validator of the `props` of one declared track event.
121
+ *
122
+ * Inputs: the track event declaration. Output: a strict Zod object schema (undeclared props are
123
+ * refused, so nothing unplanned reaches analytics); every declared prop is optional. Errors: none
124
+ * at build time. Side effects: none.
125
+ */
126
+ export declare function trackPropsSchema(declaration: TrackEventDeclaration): z.ZodType;
127
+ //# sourceMappingURL=data-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-api.d.ts","sourceRoot":"","sources":["../src/data-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAKzB,OAAO,KAAK,EAAE,qBAAqB,EAA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M,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,qBAAqB,GAAG,CAAC,CAAC,OAAO,CASjF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,qBAAqB,GAAG,CAAC,CAAC,OAAO,CAE9E"}
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Data API of component contract v1 (TAG-201): the payloads a component exchanges with the edge through
3
+ * the SDK hooks (`useTaggorData`, `useTrack`, TAG-203): `submit` (form submissions), `read` (list a
4
+ * public collection) and `track` (declared interactions).
5
+ *
6
+ * The wire format is snake_case JSON, like every `/v1` API resource (TAG-905). Each envelope is
7
+ * strict; the `data` of a submission is checked against the collection the manifest declares with
8
+ * `collectionDataSchema`, which drops undeclared fields (TAG-703). Body sizes are bounded by
9
+ * `DATA_API_LIMITS` and must be enforced on the raw body before parsing (TAG-702). TAG-212 added
10
+ * the consent proof of submissions to components that collect personal data.
11
+ */
12
+ import * as z from "zod";
13
+ import { boundedRecord } from "./bounded.js";
14
+ import { CONSENT_PROOF_LIMITS, DATA_API_LIMITS, MANIFEST_LIMITS } from "./limits.js";
15
+ import { LOCALE_TAG_MESSAGE, LOCALE_TAG_PATTERN } from "./locale-tag.js";
16
+ import { memberNameSchema, snakeNameSchema } from "./names.js";
17
+ import { tagNameSchema } from "./tag-name.js";
18
+ import { enumValueSchema, valueValidator } from "./value-schema.js";
19
+ /** Opaque, client-generated key that makes a retried submission idempotent. */
20
+ const idempotencyKeySchema = z
21
+ .string()
22
+ .min(DATA_API_LIMITS.idempotencyKeyMinLength)
23
+ .max(DATA_API_LIMITS.idempotencyKeyMaxLength)
24
+ .regex(/^[A-Za-z0-9_-]+$/, { error: "idempotency_key must use only A-Z, a-z, 0-9, _ and -" });
25
+ const cursorSchema = z
26
+ .string()
27
+ .min(1)
28
+ .max(DATA_API_LIMITS.cursorMaxLength)
29
+ .regex(/^[A-Za-z0-9_-]+$/, { error: "cursor must be the opaque value returned by the API" });
30
+ /**
31
+ * Proof of the visitor's consent sent with a submission of a component whose manifest declares
32
+ * `data.personal` (TAG-212): the consent was given, the SHA-256 (lowercase hex) of the exact text
33
+ * the visitor accepted and the language it was shown in. The text hashed is the SDK's: the
34
+ * checkbox label as rendered, a line feed and the privacy policy URL (`SPEC.md` §5).
35
+ */
36
+ export const consentProofSchema = z
37
+ .strictObject({
38
+ given: z.literal(true),
39
+ text_hash: z
40
+ .string()
41
+ .length(CONSENT_PROOF_LIMITS.consentTextHashLength)
42
+ .regex(/^[0-9a-f]+$/, { error: "text_hash must be a lowercase hex SHA-256" }),
43
+ locale: z
44
+ .string()
45
+ .max(CONSENT_PROOF_LIMITS.consentLocaleMaxLength)
46
+ .regex(LOCALE_TAG_PATTERN, { error: LOCALE_TAG_MESSAGE }),
47
+ })
48
+ .meta({ title: "Consent proof" });
49
+ /**
50
+ * Body of `submit` (`POST /d/<siteKey>/<collection>`).
51
+ *
52
+ * `data` holds the field values (validated afterwards by `collectionDataSchema`); `_hp` is the
53
+ * honeypot field that humans leave empty and `_t` the milliseconds between render and submit
54
+ * (TAG-730: they only mark a submission `suspect`, which is kept; nothing is dropped unless the
55
+ * site chose `protection.suspects: "drop"`). `consent` (TAG-212) is the visitor's consent,
56
+ * which the SDK always sends for a component with `data.personal` (the ingest of E07 refuses a
57
+ * submission of such a component without it, `consent_required`).
58
+ */
59
+ export const submitRequestSchema = z
60
+ .strictObject({
61
+ data: boundedRecord(z.string().max(MANIFEST_LIMITS.memberNameMaxLength), z.unknown(), DATA_API_LIMITS.submitDataMaxKeys, "data"),
62
+ idempotency_key: idempotencyKeySchema,
63
+ turnstile_token: z.string().min(1).max(DATA_API_LIMITS.turnstileTokenMaxLength).optional(),
64
+ _hp: z.string().max(DATA_API_LIMITS.honeypotMaxLength).optional(),
65
+ _t: z.int().min(0).optional(),
66
+ consent: consentProofSchema.optional(),
67
+ })
68
+ .meta({ title: "Submit request" });
69
+ /** Answer to an accepted submission (HTTP 202): queued, not yet stored. */
70
+ export const submitAcceptedSchema = z
71
+ .strictObject({ status: z.literal("accepted") })
72
+ .meta({ title: "Submit accepted" });
73
+ /** Query of `read` (`GET /d/<siteKey>/<collection>`), after the edge decodes the query string. */
74
+ export const readRequestSchema = z
75
+ .strictObject({
76
+ limit: z
77
+ .int()
78
+ .min(1)
79
+ .max(DATA_API_LIMITS.readPageMax)
80
+ .optional()
81
+ .meta({ description: `Defaults to ${String(DATA_API_LIMITS.readPageDefault)}.` }),
82
+ cursor: cursorSchema.optional(),
83
+ })
84
+ .meta({ title: "Read request" });
85
+ /** ULID-based public id of a submission (`sub_` prefix, TAG-905). */
86
+ const submissionIdSchema = z.string().regex(/^sub_[0-9A-HJKMNP-TV-Z]{26}$/, {
87
+ error: "id must be sub_ followed by a ULID",
88
+ });
89
+ /** One page of `read`; only collections declared `public` can be read. */
90
+ export const readResponseSchema = z
91
+ .strictObject({
92
+ data: z
93
+ .array(z.strictObject({
94
+ id: submissionIdSchema,
95
+ created_at: z.iso.datetime(),
96
+ data: boundedRecord(z.string().max(MANIFEST_LIMITS.memberNameMaxLength), z.unknown(), DATA_API_LIMITS.submitDataMaxKeys, "data"),
97
+ }))
98
+ .max(DATA_API_LIMITS.readPageMax),
99
+ next_cursor: cursorSchema.nullable(),
100
+ has_more: z.boolean(),
101
+ })
102
+ .meta({ title: "Read response" });
103
+ /** Body of `track` (a beacon to the edge): one declared interaction of one component. */
104
+ export const trackRequestSchema = z
105
+ .strictObject({
106
+ component: tagNameSchema,
107
+ name: memberNameSchema,
108
+ props: boundedRecord(snakeNameSchema, z.union([z.number(), z.boolean(), enumValueSchema]), MANIFEST_LIMITS.maxTrackProps, "props").optional(),
109
+ })
110
+ .meta({ title: "Track request" });
111
+ /** Error codes of the data API; the SDK maps each to a friendly, translated message. */
112
+ export const DATA_ERROR_CODES = Object.freeze([
113
+ "validation_failed",
114
+ "collection_not_found",
115
+ "read_not_allowed",
116
+ "event_not_declared",
117
+ "origin_not_allowed",
118
+ "rate_limited",
119
+ "captcha_failed",
120
+ "payload_too_large",
121
+ // TAG-212: a submission of a component with `data.personal` without the visitor's consent. The SDK
122
+ // refuses it before sending; the ingest (E07) answers it to anything else.
123
+ "consent_required",
124
+ // TAG-730 (contract 1.8): a form without a Turnstile key reached its daily cap of submissions;
125
+ // the visitor sees an error instead of a false success and the customer a notice in the portal.
126
+ "daily_cap_reached",
127
+ ]);
128
+ /** Error body of the data API; `fields` lists per-field problems of `validation_failed`. */
129
+ export const dataErrorSchema = z
130
+ .strictObject({
131
+ code: z.enum(DATA_ERROR_CODES),
132
+ message: z.string().max(DATA_API_LIMITS.errorMessageMaxLength),
133
+ fields: z
134
+ .array(z.strictObject({
135
+ path: z.string().max(MANIFEST_LIMITS.memberNameMaxLength * 4),
136
+ message: z.string().max(DATA_API_LIMITS.errorMessageMaxLength),
137
+ }))
138
+ .max(DATA_API_LIMITS.maxErrorFields)
139
+ .optional(),
140
+ })
141
+ .meta({ title: "Data API error" });
142
+ /**
143
+ * Builds the validator of the `data` of a submission to one declared collection.
144
+ *
145
+ * Inputs: the collection declaration from the manifest. Output: a Zod object schema; undeclared
146
+ * fields are dropped (TAG-703), required fields must be present, strings are capped at
147
+ * `MANIFEST_LIMITS.stringMaxLength`. Errors: none at build time; parsing returns Zod issues with
148
+ * the field path. Side effects: none.
149
+ */
150
+ export function collectionDataSchema(collection) {
151
+ return valueValidator({
152
+ type: "object",
153
+ fields: collection.fields,
154
+ ...(collection.required === undefined ? {} : { required: collection.required }),
155
+ }, "strip");
156
+ }
157
+ /**
158
+ * Builds the validator of the `props` of one declared track event.
159
+ *
160
+ * Inputs: the track event declaration. Output: a strict Zod object schema (undeclared props are
161
+ * refused, so nothing unplanned reaches analytics); every declared prop is optional. Errors: none
162
+ * at build time. Side effects: none.
163
+ */
164
+ export function trackPropsSchema(declaration) {
165
+ return valueValidator({ type: "object", fields: declaration.props ??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,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAmBrC;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAiC;IACpE,OAAO,cAAc,CACnB;QACE,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,GAAG,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC;KAChF,EACD,OAAO,CACR,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAkC;IACjE,OAAO,cAAc,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,KAAK,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;AACvF,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * KV key that denies a bundle or stylesheet hash.
3
+ * Inputs: 64 lowercase hexadecimal characters. Output: `deny:<sha256>`. Errors: `TypeError` for
4
+ * anything else (keys never carry caller text). Side effects: none.
5
+ */
6
+ export declare function denyBundleKvKey(sha256: string): string;
7
+ /**
8
+ * KV key that denies a site.
9
+ * Inputs: a well-formed site key. Output: `deny:site:<siteKey>`. Errors: `TypeError` for a
10
+ * malformed key. Side effects: none.
11
+ */
12
+ export declare function denySiteKvKey(siteKey: string): string;
13
+ /**
14
+ * KV key that denies a public asset hash (TAG-440).
15
+ * Inputs: 64 lowercase hexadecimal characters. Output: `asset:<sha256>`. Errors: `TypeError` for
16
+ * anything else. Side effects: none.
17
+ */
18
+ export declare function denyAssetKvKey(sha256: string): string;
19
+ //# sourceMappingURL=denylist-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"denylist-keys.d.ts","sourceRoot":"","sources":["../src/denylist-keys.ts"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGrD"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Zod-free KV key layout of the takedown denylist (TAG-609): the keys the API (operator surface)
3
+ * writes and the edge reads in the `TAKEDOWN` namespace. Like `site-manifest-keys.ts`, the layout
4
+ * lives in one place so the writer and the reader cannot drift apart (threat T-59, T-60).
5
+ *
6
+ * - `deny:<sha256>`: a bundle or stylesheet (`/b/<sha256>.js|css`) that must not be served (410).
7
+ * - `deny:site:<siteKey>`: a site that gets the inert loader, an empty manifest and no ingest.
8
+ * - `asset:<sha256>`: a public image or font (`/a/<sha256>.<ext>`), the scheme of TAG-440.
9
+ *
10
+ * Only the presence of a key matters to the edge; the value is the id of the takedown action that
11
+ * wrote it (never personal data, never a reason).
12
+ */
13
+ import { SHA256_HEX_PATTERN } from "./artifact-keys.js";
14
+ import { isSiteKey } from "./site-manifest-keys.js";
15
+ const SHA256_HEX = new RegExp(SHA256_HEX_PATTERN);
16
+ function assertHash(hash) {
17
+ if (!SHA256_HEX.test(hash))
18
+ throw new TypeError("not a sha256 hash");
19
+ }
20
+ /**
21
+ * KV key that denies a bundle or stylesheet hash.
22
+ * Inputs: 64 lowercase hexadecimal characters. Output: `deny:<sha256>`. Errors: `TypeError` for
23
+ * anything else (keys never carry caller text). Side effects: none.
24
+ */
25
+ export function denyBundleKvKey(sha256) {
26
+ assertHash(sha256);
27
+ return `deny:${sha256}`;
28
+ }
29
+ /**
30
+ * KV key that denies a site.
31
+ * Inputs: a well-formed site key. Output: `deny:site:<siteKey>`. Errors: `TypeError` for a
32
+ * malformed key. Side effects: none.
33
+ */
34
+ export function denySiteKvKey(siteKey) {
35
+ if (!isSiteKey(siteKey))
36
+ throw new TypeError("not a site key");
37
+ return `deny:site:${siteKey}`;
38
+ }
39
+ /**
40
+ * KV key that denies a public asset hash (TAG-440).
41
+ * Inputs: 64 lowercase hexadecimal characters. Output: `asset:<sha256>`. Errors: `TypeError` for
42
+ * anything else. Side effects: none.
43
+ */
44
+ export function denyAssetKvKey(sha256) {
45
+ assertHash(sha256);
46
+ return `asset:${sha256}`;
47
+ }
48
+ //# sourceMappingURL=denylist-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"denylist-keys.js","sourceRoot":"","sources":["../src/denylist-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAElD,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,UAAU,CAAC,MAAM,CAAC,CAAC;IACnB,OAAO,QAAQ,MAAM,EAAE,CAAC;AAC1B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC/D,OAAO,aAAa,OAAO,EAAE,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,UAAU,CAAC,MAAM,CAAC,CAAC;IACnB,OAAO,SAAS,MAAM,EAAE,CAAC;AAC3B,CAAC"}