@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,191 @@
1
+ /**
2
+ * Secret detector (TAG-1707): finds credentials in the text of a component's source package or of
3
+ * its built bundle, so the build can refuse them with `SECRET_IN_SOURCE` (a component's code is
4
+ * public: anyone who loads the page can read it).
5
+ *
6
+ * The rules are data in the shape of gitleaks rules (`id`, `description`, `regex`,
7
+ * `secretGroup`, `keywords`; `caseInsensitive` stands in for gitleaks' inline `(?i)`, which
8
+ * JavaScript regular expressions lack), taken from the gitleaks default config and the
9
+ * providers' documented prefixes. Keys that are public by design (Stripe publishable keys
10
+ * `pk_…`, Google API keys `AIza…` that browser SDKs embed) have no rule and never block.
11
+ *
12
+ * Obvious placeholders never block (TAG-1724, gitleaks' allowlist kept strict): a value ending in
13
+ * `EXAMPLE`, a body of one repeated character, or a sample the provider itself publishes
14
+ * (`isPlaceholderSecret`). Every source file counts, documentation (`README.md`) included: the
15
+ * package is kept by Taggor and a key in it is leaked all the same.
16
+ *
17
+ * The value of a secret never leaves this module: a finding carries only the rule, the
18
+ * position and a mask (the first `SECRET_MASK_VISIBLE_CHARS` characters and `…`, or only `…`
19
+ * for a rule that recognizes the value by its variable name, whose first characters are already
20
+ * random), so nothing downstream (diagnostics, logs, the `builds` table, the API) can store or
21
+ * print it. `redactSecrets` masks the same way in texts that may quote a source file, and
22
+ * `mentionsSecretKeyword` tells whether such a text may quote a key; both read the text as
23
+ * written and with its JavaScript and CSS escapes decoded (`escapeReadings`), and count a keyword
24
+ * that is also an ordinary word (`cloudflare`, `Asia`) only before a token mixing letters and
25
+ * digits (TAG-1725).
26
+ *
27
+ * Cost is bounded (golden rule 5, the text is untrusted): at most `SECRET_SCAN_LIMITS.maxFiles`
28
+ * files and `maxChars` UTF-16 units per scan (the builder's own ceilings), a rule's regex runs
29
+ * only on texts that contain one of its keywords, every quantifier of every rule is bounded and
30
+ * starts after a literal, and the scan stops at `SECRET_SCAN_MAX_FINDINGS`. Zod-free and
31
+ * dependency-free, so the CLI (`taggor check`, `taggor publish`: TAG-1006, TAG-1004) and the API
32
+ * can run the same scan before a package leaves the agent's machine or is stored.
33
+ */
34
+ /** One detection rule, in the shape of a gitleaks rule. */
35
+ export interface SecretRule {
36
+ /** Stable id, as in gitleaks (`stripe-access-token`). */
37
+ readonly id: string;
38
+ /** What the secret is, in English, as a diagnostic names it: "a Stripe secret key". */
39
+ readonly description: string;
40
+ /** Regular expression source (JavaScript syntax); every quantifier bounded. */
41
+ readonly regex: string;
42
+ /** Capture group holding the secret (0: the whole match). */
43
+ readonly secretGroup: number;
44
+ /** Lowercase substrings; the regex only runs on a text that contains one of them. */
45
+ readonly keywords: readonly string[];
46
+ /** Match letters in any case (gitleaks' `(?i)`). */
47
+ readonly caseInsensitive?: boolean;
48
+ /**
49
+ * The secret has no prefix of its own and is recognized by the name it is assigned to
50
+ * (`CLOUDFLARE_API_TOKEN = "…"`): its first characters are random, so the mask shows none.
51
+ */
52
+ readonly byName?: boolean;
53
+ /**
54
+ * Capture group holding the random body of the secret, without its fixed prefix or marker
55
+ * (default: `secretGroup`). The placeholder allowlist (`isPlaceholderSecret`) reads it.
56
+ */
57
+ readonly bodyGroup?: number;
58
+ }
59
+ /**
60
+ * The rules. A new provider adds an entry here with a test in both directions in
61
+ * `secret-scan.test.ts` (a fake value that blocks, a near miss or public key that does not).
62
+ * The Taggor API key format (`tgr_live_` or `tgr_test_`, then base62 with a CRC32 at the end) is
63
+ * the one TAG-902 implements; the body length here is a range so the rule holds whatever length
64
+ * TAG-902 settles on within it. The SSR server key (`tgs_live_`/`tgs_test_`, server-key.ts) has the
65
+ * same shape and its own rule.
66
+ */
67
+ export declare const SECRET_RULES: readonly SecretRule[];
68
+ /**
69
+ * Whether a value a rule matched is an obvious placeholder, never a real key (TAG-1724, the
70
+ * gitleaks allowlist idea, kept strict): the secret ends with `SECRET_EXAMPLE_SUFFIX`
71
+ * (`AKIAIOSFODNN7EXAMPLE`; a random body ends so with odds of 1 in 32^7, about 3·10^10, or less), its body is one
72
+ * character repeated (`sk_test_xxxxxxxxxxxxxxxx`, `tgr_test_0000…`), or it is a value the
73
+ * provider published as its own documentation sample. A body with two different characters is
74
+ * not a placeholder: `sk_test_xxxxxxxxxxxxxxxy` blocks.
75
+ *
76
+ * Inputs: the secret and its body (`SecretRule.bodyGroup`). Output: a boolean. Errors: none.
77
+ * Side effects: none.
78
+ */
79
+ export declare function isPlaceholderSecret(secret: string, body: string): boolean;
80
+ /** Ceilings of one scan: the builder's own (`BUILD_LIMITS.maxFiles`, `maxUnpackedBytes`). */
81
+ export declare const SECRET_SCAN_LIMITS: Readonly<{
82
+ /** Texts in one scan. */
83
+ maxFiles: 500;
84
+ /** UTF-16 units of all the texts together (20 MiB of UTF-8 is at most this many). */
85
+ maxChars: number;
86
+ }>;
87
+ /** Findings of one scan, at most (the builder reports at most 50 diagnostics). */
88
+ export declare const SECRET_SCAN_MAX_FINDINGS = 50;
89
+ /** Characters of a secret a mask shows before the ellipsis. */
90
+ export declare const SECRET_MASK_VISIBLE_CHARS = 4;
91
+ /** One text to scan: a path (any label the caller understands) and its content. */
92
+ export interface SecretScanInput {
93
+ readonly path: string;
94
+ readonly text: string;
95
+ }
96
+ /** One secret found. Never holds the value. */
97
+ export interface SecretFinding {
98
+ /** `SecretRule.id`. */
99
+ readonly ruleId: string;
100
+ /** `SecretRule.description`. */
101
+ readonly description: string;
102
+ /** The `path` of the input it was found in. */
103
+ readonly path: string;
104
+ /** 1-based line and column (UTF-16 units) where the secret starts. */
105
+ readonly line: number;
106
+ readonly column: number;
107
+ /** `maskSecret` of the value. */
108
+ readonly masked: string;
109
+ }
110
+ /** The outcome of a scan. */
111
+ export type SecretScanResult = {
112
+ readonly ok: true;
113
+ readonly findings: readonly SecretFinding[];
114
+ } | {
115
+ readonly ok: false;
116
+ /** More inputs than `maxFiles`, or more characters than `maxChars`. */
117
+ readonly reason: "too-many-files" | "too-large";
118
+ readonly message: string;
119
+ };
120
+ /**
121
+ * The mask of a secret: its first `visible` characters (default `SECRET_MASK_VISIBLE_CHARS`; for
122
+ * the prefixed rules above, a prefix that names the provider and none of the random part) and
123
+ * `…`. A rule recognized by name (`byName`) masks with 0: the value has no prefix to show.
124
+ *
125
+ * Inputs: the value and how many characters to show. Output: the mask. Errors: none. Side
126
+ * effects: none.
127
+ */
128
+ export declare function maskSecret(value: string, visible?: number): string;
129
+ /**
130
+ * Scans texts for secrets.
131
+ *
132
+ * Inputs: the texts (a source package's files, or a bundle's outputs) and, optionally, other
133
+ * limits (tests). Output: `ok: true` with the findings in input and text order (at most
134
+ * `SECRET_SCAN_MAX_FINDINGS`; one per start position, the first rule in `SECRET_RULES` order
135
+ * when two match there; empty when nothing matches), or `ok: false` when the inputs are over the
136
+ * limits, checked before any text is read. Never holds or returns a secret's value. Errors: never
137
+ * throws. Side effects: none.
138
+ */
139
+ export declare function scanSecrets(inputs: readonly SecretScanInput[], limits?: {
140
+ readonly maxFiles: number;
141
+ readonly maxChars: number;
142
+ }): SecretScanResult;
143
+ /**
144
+ * The most characters `escapeReadings`, `mentionsSecretKeyword` and `redactSecrets` read: they
145
+ * are for short diagnostic texts (a message is at most 2,000 characters, a snippet 300). Linear
146
+ * as they are, they take seconds of CPU on 20 MiB (TAG-1725 security review, B2), so a longer
147
+ * text is cut and its rest treated as one that may quote a secret.
148
+ */
149
+ export declare const SECRET_TEXT_MAX_CHARS = 4000;
150
+ /**
151
+ * A text as it reads with its escapes decoded (TAG-1725): as written, as JavaScript decodes it
152
+ * (`\xNN`, `\uNNNN`, `\u{…}`, legacy octal, `\n` and the like, and any other `\c` as `c`) and as
153
+ * CSS does (`\73 `). A key written with escapes (`"\x73k_live_…"`) only shows its keyword in a
154
+ * decoded reading. Linear: one pass per reading. Only for short diagnostic texts: past
155
+ * `SECRET_TEXT_MAX_CHARS`, only the first `SECRET_TEXT_MAX_CHARS` characters are decoded.
156
+ *
157
+ * Inputs: any text. Output: the distinct readings, the text as written first (only it when the
158
+ * text has no backslash); for a longer text, the decoded readings are of its first
159
+ * `SECRET_TEXT_MAX_CHARS` characters. Errors: never throws. Side effects: none.
160
+ */
161
+ export declare function escapeReadings(text: string): readonly string[];
162
+ /**
163
+ * Whether a text may quote a secret, even one the rules miss (a value split across literals, an
164
+ * odd boundary), in any of its `escapeReadings`: a rule finds a value in it, or it names a
165
+ * rule's keyword, a keyword that is also an ordinary word (`cloudflare`, `Asia`:
166
+ * `WORD_KEYWORDS`) only when the token after it mixes letters and digits. Case-insensitive.
167
+ * Only for short diagnostic texts: one longer than `SECRET_TEXT_MAX_CHARS` may quote a secret
168
+ * as far as this function knows, without being read.
169
+ *
170
+ * Inputs: any text. Output: a boolean, `true` for a text over `SECRET_TEXT_MAX_CHARS`. Errors:
171
+ * none. Side effects: none.
172
+ */
173
+ export declare function mentionsSecretKeyword(text: string): boolean;
174
+ /**
175
+ * A text with every secret masked: each value a rule finds, and each run of a keyword and token
176
+ * characters of `MIN_MASKED_RUN` characters or more (a key a rule misses, such as one with an
177
+ * odd boundary), replaced by its mask; a keyword that is also an ordinary word (`WORD_KEYWORDS`)
178
+ * only starts a run when the token after it mixes letters and digits, so
179
+ * `cloudflare-turnstile-loader.js` and `Asia/Ho_Chi_Minh` stay whole (TAG-1725). When a decoded
180
+ * reading (`escapeReadings`) has something to mask, that reading is returned masked (the
181
+ * JavaScript one before the CSS one): `"\x73k_live_…"` becomes `"sk_l…"`. For texts that are not a
182
+ * source file but may quote one: a bundler's message, a thrown error. Only for short diagnostic
183
+ * texts (the builder passes messages of at most 2,000 characters): past `SECRET_TEXT_MAX_CHARS`,
184
+ * the rest is unread and replaced by `…`, since it may quote a secret.
185
+ *
186
+ * Inputs: any text. Output: the text, unchanged when nothing is found and it is not longer than
187
+ * `SECRET_TEXT_MAX_CHARS`; otherwise its first `SECRET_TEXT_MAX_CHARS` characters, less the
188
+ * token the cut splits, masked, then `…`. Errors: never throws. Side effects: none.
189
+ */
190
+ export declare function redactSecrets(text: string): string;
191
+ //# sourceMappingURL=secret-scan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret-scan.d.ts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