@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,542 @@
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
+ /**
35
+ * The start of a prefixed token: a word boundary, or right after an escaped line break or tab in
36
+ * a string (`"Stripe:\nsk_live_…"`), where `\b` sees no boundary between the `n` and the `s`
37
+ * (TAG-1707 security review, M2).
38
+ */
39
+ const START = "(?:\\b|(?<=\\\\[nrt]))";
40
+ /** The end of a token: no further character of the token's alphabet. */
41
+ const END_ALNUM = "(?![A-Za-z0-9])";
42
+ const END_TOKEN = "(?![A-Za-z0-9_-])";
43
+ /**
44
+ * The rules. A new provider adds an entry here with a test in both directions in
45
+ * `secret-scan.test.ts` (a fake value that blocks, a near miss or public key that does not).
46
+ * The Taggor API key format (`tgr_live_` or `tgr_test_`, then base62 with a CRC32 at the end) is
47
+ * the one TAG-902 implements; the body length here is a range so the rule holds whatever length
48
+ * TAG-902 settles on within it. The SSR server key (`tgs_live_`/`tgs_test_`, server-key.ts) has the
49
+ * same shape and its own rule.
50
+ */
51
+ export const SECRET_RULES = Object.freeze([
52
+ {
53
+ id: "aws-access-token",
54
+ description: "an AWS access key id",
55
+ regex: `${START}((?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)([A-Z2-7]{16}))\\b`,
56
+ secretGroup: 1,
57
+ bodyGroup: 2,
58
+ keywords: ["a3t", "akia", "asia", "abia", "acca"],
59
+ },
60
+ {
61
+ id: "gcp-oauth-client-secret",
62
+ description: "a Google Cloud OAuth client secret",
63
+ regex: `${START}(GOCSPX-([A-Za-z0-9_-]{28}))${END_TOKEN}`,
64
+ secretGroup: 1,
65
+ bodyGroup: 2,
66
+ keywords: ["gocspx-"],
67
+ },
68
+ {
69
+ id: "cloudflare-api-key",
70
+ description: "a Cloudflare API token or global API key",
71
+ regex: `cloudflare[\\w.-]{0,20}[\\s'"\`]{0,3}(?:=|:|=>|,)[\\s'"\`]{0,5}([\\w-]{40}|[a-f0-9]{37})${END_TOKEN}`,
72
+ secretGroup: 1,
73
+ keywords: ["cloudflare"],
74
+ caseInsensitive: true,
75
+ byName: true,
76
+ },
77
+ {
78
+ id: "cloudflare-origin-ca-key",
79
+ description: "a Cloudflare Origin CA key",
80
+ regex: `${START}(v1\\.0-[a-f0-9]{24}-[a-f0-9]{146})(?![a-f0-9])`,
81
+ secretGroup: 1,
82
+ keywords: ["v1.0-"],
83
+ },
84
+ {
85
+ id: "stripe-access-token",
86
+ description: "a Stripe secret or restricted key",
87
+ regex: `${START}((?:sk|rk)_(?:live|test|prod)_([A-Za-z0-9]{10,99}))${END_ALNUM}`,
88
+ secretGroup: 1,
89
+ bodyGroup: 2,
90
+ keywords: ["sk_live_", "sk_test_", "sk_prod_", "rk_live_", "rk_test_", "rk_prod_"],
91
+ },
92
+ {
93
+ id: "stripe-webhook-secret",
94
+ description: "a Stripe webhook signing secret",
95
+ regex: `${START}(whsec_([A-Za-z0-9]{24,64}))${END_ALNUM}`,
96
+ secretGroup: 1,
97
+ bodyGroup: 2,
98
+ keywords: ["whsec_"],
99
+ },
100
+ {
101
+ id: "github-token",
102
+ description: "a GitHub token",
103
+ regex: `${START}((?:ghp|gho|ghu|ghs|ghr)_([A-Za-z0-9]{36}))${END_ALNUM}`,
104
+ secretGroup: 1,
105
+ bodyGroup: 2,
106
+ keywords: ["ghp_", "gho_", "ghu_", "ghs_", "ghr_"],
107
+ },
108
+ {
109
+ id: "github-fine-grained-pat",
110
+ description: "a GitHub fine-grained personal access token",
111
+ regex: `${START}(github_pat_([A-Za-z0-9_]{82}))(?![A-Za-z0-9_])`,
112
+ secretGroup: 1,
113
+ bodyGroup: 2,
114
+ keywords: ["github_pat_"],
115
+ },
116
+ {
117
+ id: "openai-api-key",
118
+ description: "an OpenAI API key",
119
+ // gitleaks' exact lengths: a range on both sides of the marker would backtrack.
120
+ regex: `${START}(sk-(?:proj|svcacct|admin)-(?:[A-Za-z0-9_-]{74}|[A-Za-z0-9_-]{58})T3BlbkFJ(?:[A-Za-z0-9_-]{74}|[A-Za-z0-9_-]{58})|sk-[A-Za-z0-9]{20}T3BlbkFJ[A-Za-z0-9]{20})${END_TOKEN}`,
121
+ secretGroup: 1,
122
+ keywords: ["t3blbkfj"],
123
+ },
124
+ {
125
+ id: "anthropic-api-key",
126
+ description: "an Anthropic API key",
127
+ regex: `${START}(sk-ant-(?:api03|admin01)-([A-Za-z0-9_-]{93})AA)${END_TOKEN}`,
128
+ secretGroup: 1,
129
+ bodyGroup: 2,
130
+ keywords: ["sk-ant-api03-", "sk-ant-admin01-"],
131
+ },
132
+ {
133
+ // The header, optional RFC 7468/4880 header lines and the start of the base64 body, so a
134
+ // placeholder ("-----BEGIN PRIVATE KEY-----\n...") does not block. Line breaks may be real
135
+ // or escaped in a string (`\n`), as in a service account JSON. A header line ends only at
136
+ // a line break: if it could end at a space, `a: a: a: …` would split into header lines in
137
+ // exponentially many ways (TAG-1707 security review, M1: 136 s for 1.5 KB gzipped).
138
+ id: "private-key",
139
+ description: "a PEM private key",
140
+ regex: "-----BEGIN[ A-Z0-9_-]{0,40}PRIVATE KEY(?: BLOCK)?-----[ \\t]{0,8}(?:\\r?\\n|(?:\\\\r)?\\\\n)(?:[A-Za-z-]{1,30}: [^\\r\\n\\\\]{1,100}(?:\\r?\\n|(?:\\\\r)?\\\\n)){0,4}(?:[ \\t\\r\\n]|\\\\[nr]){0,8}([A-Za-z0-9+/]{32})",
141
+ secretGroup: 0,
142
+ bodyGroup: 1,
143
+ keywords: ["private key"],
144
+ },
145
+ {
146
+ id: "taggor-api-key",
147
+ description: "a Taggor API key",
148
+ regex: `${START}(tgr_(?:live|test)_([A-Za-z0-9]{24,128}))${END_ALNUM}`,
149
+ secretGroup: 1,
150
+ bodyGroup: 2,
151
+ keywords: ["tgr_live_", "tgr_test_"],
152
+ },
153
+ {
154
+ // The SSR server key (server-key.ts, ADR 0066): a server secret that must never reach a page.
155
+ id: "taggor-server-key",
156
+ description: "a Taggor server key",
157
+ regex: `${START}(tgs_(?:live|test)_([A-Za-z0-9]{24,128}))${END_ALNUM}`,
158
+ secretGroup: 1,
159
+ bodyGroup: 2,
160
+ keywords: ["tgs_live_", "tgs_test_"],
161
+ },
162
+ ]);
163
+ /** Suffix of documented example values (AWS's `AKIAIOSFODNN7EXAMPLE`), as gitleaks allows. */
164
+ const SECRET_EXAMPLE_SUFFIX = "EXAMPLE";
165
+ /**
166
+ * Exact values that providers publish in their own documentation, so they are public and tied
167
+ * to a demo account: Stripe's sample test secret keys (docs.stripe.com/api/authentication and
168
+ * the code samples on stripe.com, checked 2026-10-31). Assembled from parts so no repository
169
+ * scanner reads a whole key here.
170
+ */
171
+ const PUBLISHED_EXAMPLE_VALUES = new Set([
172
+ "sk_test_" + "4eC39HqLyjWDarjtT1zdp7dc",
173
+ "sk_test_" + "BQokikJOvBiI2HlWgH4olfQ2",
174
+ ]);
175
+ /** Whether a text is one character repeated (empty: no). */
176
+ function isOneCharacterRepeated(text) {
177
+ if (text.length === 0)
178
+ return false;
179
+ const first = text.charCodeAt(0);
180
+ for (let index = 1; index < text.length; index += 1) {
181
+ if (text.charCodeAt(index) !== first)
182
+ return false;
183
+ }
184
+ return true;
185
+ }
186
+ /**
187
+ * Whether a value a rule matched is an obvious placeholder, never a real key (TAG-1724, the
188
+ * gitleaks allowlist idea, kept strict): the secret ends with `SECRET_EXAMPLE_SUFFIX`
189
+ * (`AKIAIOSFODNN7EXAMPLE`; a random body ends so with odds of 1 in 32^7, about 3·10^10, or less), its body is one
190
+ * character repeated (`sk_test_xxxxxxxxxxxxxxxx`, `tgr_test_0000…`), or it is a value the
191
+ * provider published as its own documentation sample. A body with two different characters is
192
+ * not a placeholder: `sk_test_xxxxxxxxxxxxxxxy` blocks.
193
+ *
194
+ * Inputs: the secret and its body (`SecretRule.bodyGroup`). Output: a boolean. Errors: none.
195
+ * Side effects: none.
196
+ */
197
+ export function isPlaceholderSecret(secret, body) {
198
+ return (secret.endsWith(SECRET_EXAMPLE_SUFFIX) ||
199
+ isOneCharacterRepeated(body) ||
200
+ PUBLISHED_EXAMPLE_VALUES.has(secret));
201
+ }
202
+ /** Whether a match of `rule` is a placeholder (`isPlaceholderSecret`). */
203
+ function isPlaceholderMatch(rule, match) {
204
+ const secret = match[rule.secretGroup] ?? "";
205
+ return isPlaceholderSecret(secret, match[rule.bodyGroup ?? rule.secretGroup] ?? secret);
206
+ }
207
+ /** Ceilings of one scan: the builder's own (`BUILD_LIMITS.maxFiles`, `maxUnpackedBytes`). */
208
+ export const SECRET_SCAN_LIMITS = Object.freeze({
209
+ /** Texts in one scan. */
210
+ maxFiles: 500,
211
+ /** UTF-16 units of all the texts together (20 MiB of UTF-8 is at most this many). */
212
+ maxChars: 20 * 1024 * 1024,
213
+ });
214
+ /** Findings of one scan, at most (the builder reports at most 50 diagnostics). */
215
+ export const SECRET_SCAN_MAX_FINDINGS = 50;
216
+ /** Characters of a secret a mask shows before the ellipsis. */
217
+ export const SECRET_MASK_VISIBLE_CHARS = 4;
218
+ /**
219
+ * The mask of a secret: its first `visible` characters (default `SECRET_MASK_VISIBLE_CHARS`; for
220
+ * the prefixed rules above, a prefix that names the provider and none of the random part) and
221
+ * `…`. A rule recognized by name (`byName`) masks with 0: the value has no prefix to show.
222
+ *
223
+ * Inputs: the value and how many characters to show. Output: the mask. Errors: none. Side
224
+ * effects: none.
225
+ */
226
+ export function maskSecret(value, visible = SECRET_MASK_VISIBLE_CHARS) {
227
+ return `${value.slice(0, visible)}…`;
228
+ }
229
+ /** The mask of a value a rule found. */
230
+ const maskFor = (rule, value) => maskSecret(value, rule.byName === true ? 0 : SECRET_MASK_VISIBLE_CHARS);
231
+ const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
232
+ // The keywords as one case-insensitive regex, not `toLowerCase` + `includes`: V8's `includes`
233
+ // degrades on repetitive text (250 ms per keyword on 20 MiB of "a"), its regex scan does not.
234
+ // `d` gives the index of the secret group; `g` lets one regex walk a whole text.
235
+ const COMPILED = SECRET_RULES.map((rule) => ({
236
+ rule,
237
+ keywords: new RegExp(rule.keywords.map(escapeRegExp).join("|"), "i"),
238
+ pattern: new RegExp(rule.regex, rule.caseInsensitive === true ? "dgi" : "dg"),
239
+ }));
240
+ /** The hits of every rule in one text, at most `max`, one per start index, in text order. */
241
+ function hitsIn(text, max) {
242
+ const byIndex = new Map();
243
+ for (const { rule, keywords, pattern } of COMPILED) {
244
+ if (!keywords.test(text))
245
+ continue;
246
+ pattern.lastIndex = 0;
247
+ for (let match = pattern.exec(text); match !== null; match = pattern.exec(text)) {
248
+ const value = match[rule.secretGroup];
249
+ const index = match.indices?.[rule.secretGroup]?.[0];
250
+ if (value !== undefined &&
251
+ index !== undefined &&
252
+ !byIndex.has(index) &&
253
+ !isPlaceholderMatch(rule, match)) {
254
+ byIndex.set(index, { index, rule, masked: maskFor(rule, value) });
255
+ }
256
+ if (byIndex.size >= max)
257
+ break;
258
+ }
259
+ if (byIndex.size >= max)
260
+ break;
261
+ }
262
+ return [...byIndex.values()].sort((a, b) => a.index - b.index).slice(0, max);
263
+ }
264
+ /** Whether the unit at `index` ends a line (JavaScript line terminators; CRLF counts once). */
265
+ function isLineBreak(text, index) {
266
+ const unit = text.charCodeAt(index);
267
+ if (unit === 0x0a || unit === 0x2028 || unit === 0x2029)
268
+ return true;
269
+ return unit === 0x0d && text.charCodeAt(index + 1) !== 0x0a;
270
+ }
271
+ /** Findings of sorted hits, with their lines and columns from one pass over the text. */
272
+ function findingsOf(path, text, hits) {
273
+ const findings = [];
274
+ let line = 1;
275
+ let lineStart = 0;
276
+ let cursor = 0;
277
+ for (const hit of hits) {
278
+ for (; cursor < hit.index; cursor += 1) {
279
+ if (isLineBreak(text, cursor)) {
280
+ line += 1;
281
+ lineStart = cursor + 1;
282
+ }
283
+ }
284
+ findings.push({
285
+ ruleId: hit.rule.id,
286
+ description: hit.rule.description,
287
+ path,
288
+ line,
289
+ column: hit.index - lineStart + 1,
290
+ masked: hit.masked,
291
+ });
292
+ }
293
+ return findings;
294
+ }
295
+ /**
296
+ * Scans texts for secrets.
297
+ *
298
+ * Inputs: the texts (a source package's files, or a bundle's outputs) and, optionally, other
299
+ * limits (tests). Output: `ok: true` with the findings in input and text order (at most
300
+ * `SECRET_SCAN_MAX_FINDINGS`; one per start position, the first rule in `SECRET_RULES` order
301
+ * when two match there; empty when nothing matches), or `ok: false` when the inputs are over the
302
+ * limits, checked before any text is read. Never holds or returns a secret's value. Errors: never
303
+ * throws. Side effects: none.
304
+ */
305
+ export function scanSecrets(inputs, limits = SECRET_SCAN_LIMITS) {
306
+ if (inputs.length > limits.maxFiles) {
307
+ return {
308
+ ok: false,
309
+ reason: "too-many-files",
310
+ message: `${String(inputs.length)} files to scan for secrets, over the ${String(limits.maxFiles)} the scan reads`,
311
+ };
312
+ }
313
+ const total = inputs.reduce((sum, input) => sum + input.text.length, 0);
314
+ if (total > limits.maxChars) {
315
+ return {
316
+ ok: false,
317
+ reason: "too-large",
318
+ message: `${String(total)} characters to scan for secrets, over the ${String(limits.maxChars)} the scan reads`,
319
+ };
320
+ }
321
+ const findings = [];
322
+ for (const input of inputs) {
323
+ const left = SECRET_SCAN_MAX_FINDINGS - findings.length;
324
+ if (left <= 0)
325
+ break;
326
+ const hits = hitsIn(input.text, left);
327
+ if (hits.length > 0)
328
+ findings.push(...findingsOf(input.path, input.text, hits));
329
+ }
330
+ return { ok: true, findings };
331
+ }
332
+ /** Any keyword of any rule, in any case. */
333
+ const ANY_KEYWORD = new RegExp(SECRET_RULES.flatMap((rule) => rule.keywords.map(escapeRegExp)).join("|"), "i");
334
+ /**
335
+ * Keywords that are also ordinary words in legitimate text (TAG-1725): those of a rule that
336
+ * recognizes the value by its variable name (`cloudflare`, as in `cloudflare-turnstile-loader.js`)
337
+ * and AWS prefixes that are common words or parts of them (`Asia/Ho_Chi_Minh`, `Arabia`,
338
+ * `accademia`). Such a keyword only counts when the token characters right after it mix letters
339
+ * and digits, as a key does; every other keyword (`sk_live_`, `ghp_`, `AKIA`) counts alone.
340
+ */
341
+ const WORD_KEYWORDS = new Set([
342
+ ...SECRET_RULES.filter((rule) => rule.byName === true).flatMap((rule) => rule.keywords),
343
+ "asia",
344
+ "abia",
345
+ "acca",
346
+ ]);
347
+ /** The keywords that count alone, as one alternation. */
348
+ const DISTINCTIVE_KEYWORDS = SECRET_RULES.flatMap((rule) => rule.keywords)
349
+ .filter((keyword) => !WORD_KEYWORDS.has(keyword))
350
+ .map(escapeRegExp)
351
+ .join("|");
352
+ /** Any keyword that counts alone. */
353
+ const DISTINCTIVE_KEYWORD = new RegExp(DISTINCTIVE_KEYWORDS, "i");
354
+ /** The most token characters a keyword run reads after its keyword. */
355
+ const RUN_MAX = 200;
356
+ /** The token characters a key may continue with after its keyword. */
357
+ const RUN = `[A-Za-z0-9_+/=.-]{0,${String(RUN_MAX)}}`;
358
+ /** A distinctive keyword and the token characters after it. */
359
+ const DISTINCTIVE_RUN = new RegExp(`(?:${DISTINCTIVE_KEYWORDS})${RUN}`, "gi");
360
+ /** A word keyword (group 1) and the token characters after it. */
361
+ const WORD_RUN = new RegExp(`(${[...WORD_KEYWORDS].map(escapeRegExp).join("|")})${RUN}`, "gi");
362
+ /** Whether a text has both an ASCII letter and an ASCII digit (native scans: hot in `keyRuns`). */
363
+ const mixesLettersAndDigits = (text) => /[0-9]/.test(text) && /[A-Za-z]/.test(text);
364
+ /**
365
+ * The keyword runs of a text that may be keys: every run of a distinctive keyword, and every run
366
+ * of a word keyword whose characters after the keyword mix letters and digits. Two passes, each
367
+ * reading at most `RUN_MAX` characters per start: a word keyword's run that does not mix is
368
+ * skipped whole when it ended before `RUN_MAX` (any word keyword inside it has a suffix of it as
369
+ * its own run, which does not mix either), and past its keyword only when it was cut at
370
+ * `RUN_MAX` (the next run may reach a digit beyond the cut).
371
+ */
372
+ function keyRuns(text) {
373
+ const runs = [];
374
+ DISTINCTIVE_RUN.lastIndex = 0;
375
+ for (let match = DISTINCTIVE_RUN.exec(text); match !== null; match = DISTINCTIVE_RUN.exec(text)) {
376
+ runs.push({ index: match.index, run: match[0] });
377
+ }
378
+ WORD_RUN.lastIndex = 0;
379
+ for (let match = WORD_RUN.exec(text); match !== null; match = WORD_RUN.exec(text)) {
380
+ const word = match[1] ?? "";
381
+ const after = match[0].slice(word.length);
382
+ if (mixesLettersAndDigits(after))
383
+ runs.push({ index: match.index, run: match[0] });
384
+ else if (after.length === RUN_MAX)
385
+ WORD_RUN.lastIndex = match.index + word.length;
386
+ }
387
+ return runs;
388
+ }
389
+ /** A JavaScript escape (string, template or identifier): its groups, by kind. */
390
+ const JS_ESCAPE = /\\(?:x([0-9A-Fa-f]{2})|u\{([0-9A-Fa-f]{1,6})\}|u([0-9A-Fa-f]{4})|([0-7]{1,3})|(\r\n|[\s\S]))/g;
391
+ /** A CSS escape: up to six hex digits and one optional white space, or any other character. */
392
+ const CSS_ESCAPE = /\\(?:([0-9A-Fa-f]{1,6})(?:\r\n|[ \t\n\r\f])?|([\s\S]))/g;
393
+ /** Single-character JavaScript escapes that are not the character itself. */
394
+ const JS_SINGLE = {
395
+ n: "\n",
396
+ r: "\r",
397
+ t: "\t",
398
+ b: "\b",
399
+ f: "\f",
400
+ v: "\v",
401
+ "\n": "",
402
+ "\r": "",
403
+ "\r\n": "",
404
+ "\u2028": "",
405
+ "\u2029": "",
406
+ };
407
+ /** The character of a code point, or `fallback` when it is not one. */
408
+ function codePoint(hex, fallback) {
409
+ const value = Number.parseInt(hex, 16);
410
+ return value <= 0x10ffff ? String.fromCodePoint(value) : fallback;
411
+ }
412
+ /**
413
+ * The most characters `escapeReadings`, `mentionsSecretKeyword` and `redactSecrets` read: they
414
+ * are for short diagnostic texts (a message is at most 2,000 characters, a snippet 300). Linear
415
+ * as they are, they take seconds of CPU on 20 MiB (TAG-1725 security review, B2), so a longer
416
+ * text is cut and its rest treated as one that may quote a secret.
417
+ */
418
+ export const SECRET_TEXT_MAX_CHARS = 4_000;
419
+ /**
420
+ * A text as it reads with its escapes decoded (TAG-1725): as written, as JavaScript decodes it
421
+ * (`\xNN`, `\uNNNN`, `\u{…}`, legacy octal, `\n` and the like, and any other `\c` as `c`) and as
422
+ * CSS does (`\73 `). A key written with escapes (`"\x73k_live_…"`) only shows its keyword in a
423
+ * decoded reading. Linear: one pass per reading. Only for short diagnostic texts: past
424
+ * `SECRET_TEXT_MAX_CHARS`, only the first `SECRET_TEXT_MAX_CHARS` characters are decoded.
425
+ *
426
+ * Inputs: any text. Output: the distinct readings, the text as written first (only it when the
427
+ * text has no backslash); for a longer text, the decoded readings are of its first
428
+ * `SECRET_TEXT_MAX_CHARS` characters. Errors: never throws. Side effects: none.
429
+ */
430
+ export function escapeReadings(text) {
431
+ if (text.length > SECRET_TEXT_MAX_CHARS) {
432
+ const head = escapeReadings(text.slice(0, SECRET_TEXT_MAX_CHARS));
433
+ return [text, ...head.slice(1)];
434
+ }
435
+ if (!text.includes("\\"))
436
+ return [text];
437
+ const js = text.replace(JS_ESCAPE, (whole, hex2, braced, hex4, octal, other) => {
438
+ const hex = hex2 ?? braced ?? hex4;
439
+ if (hex !== undefined)
440
+ return codePoint(hex, whole);
441
+ if (octal !== undefined)
442
+ return String.fromCharCode(Number.parseInt(octal, 8) & 0xff);
443
+ return other === undefined ? whole : (JS_SINGLE[other] ?? other);
444
+ });
445
+ const css = text.replace(CSS_ESCAPE, (whole, hex, other) => hex === undefined ? (other ?? whole) : codePoint(hex, whole));
446
+ return [...new Set([text, js, css])];
447
+ }
448
+ /**
449
+ * Whether a text may quote a secret, even one the rules miss (a value split across literals, an
450
+ * odd boundary), in any of its `escapeReadings`: a rule finds a value in it, or it names a
451
+ * rule's keyword, a keyword that is also an ordinary word (`cloudflare`, `Asia`:
452
+ * `WORD_KEYWORDS`) only when the token after it mixes letters and digits. Case-insensitive.
453
+ * Only for short diagnostic texts: one longer than `SECRET_TEXT_MAX_CHARS` may quote a secret
454
+ * as far as this function knows, without being read.
455
+ *
456
+ * Inputs: any text. Output: a boolean, `true` for a text over `SECRET_TEXT_MAX_CHARS`. Errors:
457
+ * none. Side effects: none.
458
+ */
459
+ export function mentionsSecretKeyword(text) {
460
+ if (text.length > SECRET_TEXT_MAX_CHARS)
461
+ return true;
462
+ return escapeReadings(text).some((reading) => DISTINCTIVE_KEYWORD.test(reading) ||
463
+ (ANY_KEYWORD.test(reading) &&
464
+ (keyRuns(reading).length > 0 || COMPILED.some((rule) => matchesRule(rule, reading)))));
465
+ }
466
+ /** Whether a rule finds a value in a text (a rule's regex is global: its cursor is reset). */
467
+ function matchesRule({ keywords, pattern }, text) {
468
+ if (!keywords.test(text))
469
+ return false;
470
+ pattern.lastIndex = 0;
471
+ return pattern.test(text);
472
+ }
473
+ /** Shorter keyword runs are words, not keys. */
474
+ const MIN_MASKED_RUN = 16;
475
+ /** `text` with every value a rule finds and every long key run (`keyRuns`) masked. */
476
+ function redactReading(text) {
477
+ if (!ANY_KEYWORD.test(text))
478
+ return text;
479
+ const ranges = [];
480
+ for (const { rule, keywords, pattern } of COMPILED) {
481
+ if (!keywords.test(text))
482
+ continue;
483
+ pattern.lastIndex = 0;
484
+ for (let match = pattern.exec(text); match !== null; match = pattern.exec(text)) {
485
+ const value = match[rule.secretGroup];
486
+ const span = match.indices?.[rule.secretGroup];
487
+ // Placeholders are masked too: masking costs nothing here, and the text is not a scan.
488
+ if (value !== undefined && span !== undefined) {
489
+ ranges.push({ start: span[0], end: span[1], mask: maskFor(rule, value) });
490
+ }
491
+ }
492
+ }
493
+ for (const { index, run } of keyRuns(text)) {
494
+ if (run.length >= MIN_MASKED_RUN) {
495
+ ranges.push({ start: index, end: index + run.length, mask: maskSecret(run) });
496
+ }
497
+ }
498
+ ranges.sort((a, b) => a.start - b.start || b.end - a.end);
499
+ let out = "";
500
+ let cursor = 0;
501
+ for (const range of ranges) {
502
+ if (range.start < cursor)
503
+ continue;
504
+ out += text.slice(cursor, range.start) + range.mask;
505
+ cursor = range.end;
506
+ }
507
+ return out + text.slice(cursor);
508
+ }
509
+ /**
510
+ * A text with every secret masked: each value a rule finds, and each run of a keyword and token
511
+ * characters of `MIN_MASKED_RUN` characters or more (a key a rule misses, such as one with an
512
+ * odd boundary), replaced by its mask; a keyword that is also an ordinary word (`WORD_KEYWORDS`)
513
+ * only starts a run when the token after it mixes letters and digits, so
514
+ * `cloudflare-turnstile-loader.js` and `Asia/Ho_Chi_Minh` stay whole (TAG-1725). When a decoded
515
+ * reading (`escapeReadings`) has something to mask, that reading is returned masked (the
516
+ * JavaScript one before the CSS one): `"\x73k_live_…"` becomes `"sk_l…"`. For texts that are not a
517
+ * source file but may quote one: a bundler's message, a thrown error. Only for short diagnostic
518
+ * texts (the builder passes messages of at most 2,000 characters): past `SECRET_TEXT_MAX_CHARS`,
519
+ * the rest is unread and replaced by `…`, since it may quote a secret.
520
+ *
521
+ * Inputs: any text. Output: the text, unchanged when nothing is found and it is not longer than
522
+ * `SECRET_TEXT_MAX_CHARS`; otherwise its first `SECRET_TEXT_MAX_CHARS` characters, less the
523
+ * token the cut splits, masked, then `…`. Errors: never throws. Side effects: none.
524
+ */
525
+ export function redactSecrets(text) {
526
+ if (text.length > SECRET_TEXT_MAX_CHARS) {
527
+ // The token the cut splits goes with the rest: its head could be most of a key.
528
+ let end = SECRET_TEXT_MAX_CHARS;
529
+ while (end > 0 && /[A-Za-z0-9_+/=.\\-]/.test(text.charAt(end - 1)))
530
+ end -= 1;
531
+ return `${redactSecrets(text.slice(0, end))}…`;
532
+ }
533
+ // A decoded reading first: decoding never breaks a key written plainly (keys have no
534
+ // backslash), so its mask covers those too, and the escaped ones as well.
535
+ for (const reading of escapeReadings(text).slice(1)) {
536
+ const decoded = redactReading(reading);
537
+ if (decoded !== reading)
538
+ return decoded;
539
+ }
540
+ return redactReading(text);
541
+ }
542
+ //# sourceMappingURL=secret-scan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret-scan.js","sourceRoot":"","sources":["../src/secret-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AA4BH;;;;GAIG;AACH,MAAM,KAAK,GAAG,wBAAwB,CAAC;AAEv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(TAG-402).
3
+ *
4
+ * The builder never resolves a range against a registry during a build: the versions come from
5
+ * Taggor's lock. Ranges are only *checked*: a component's `package.json` range against the locked
6
+ * version, the allowlist's range against the lock (repository tests), and the lock tool picking
7
+ * the newest version of a range when an operator refreshes the lock. So this is npm's grammar
8
+ * (`1.2.3`, `=1.2.3`, `^1.2`, `~1.2.3`, `1.x`, `*`, `>=1 <2`, `1 - 2`, `a || b`, optional `v`)
9
+ * with npm's prerelease rule, and nothing looser: tags (`latest`), URLs, `file:`, `git+`,
10
+ * `npm:` aliases and `workspace:` are not ranges and parse to `undefined`. Inputs are bounded
11
+ * (`MAX_RANGE_LENGTH`) and parsed without backtracking regexes, so a hostile `package.json`
12
+ * costs linear time.
13
+ *
14
+ * Pure: no I/O.
15
+ */
16
+ /** A parsed version: `major.minor.patch`, prerelease identifiers, no build metadata. */
17
+ export interface SemVer {
18
+ readonly major: number;
19
+ readonly minor: number;
20
+ readonly patch: number;
21
+ /** Prerelease identifiers (`1.0.0-beta.2` → `["beta", 2]`); empty for a release. */
22
+ readonly prerelease: readonly (string | number)[];
23
+ }
24
+ /** Longest version or range text accepted (npm's own limit is 256). */
25
+ export declare const MAX_RANGE_LENGTH = 256;
26
+ type Operator = "<" | "<=" | ">" | ">=" | "=";
27
+ interface Comparator {
28
+ readonly operator: Operator;
29
+ readonly version: SemVer;
30
+ }
31
+ /** A parsed range: alternatives (`||`), each a set of comparators that must all hold. */
32
+ export interface SemverRange {
33
+ readonly sets: readonly (readonly Comparator[])[];
34
+ }
35
+ /**
36
+ * Parses an exact version (`1.2.3`, `1.0.0-rc.1`, `1.2.3+build`).
37
+ *
38
+ * Inputs: the text. Output: the `SemVer`, or `undefined` for anything else (a range, a leading
39
+ * `v` or `=`, leading zeros, a number past `Number.MAX_SAFE_INTEGER`, over `MAX_RANGE_LENGTH`).
40
+ * Errors: none. Side effects: none.
41
+ */
42
+ export declare function parseVersion(text: string): SemVer | undefined;
43
+ /**
44
+ * Formats a version as npm writes it (`1.2.3-beta.1`).
45
+ *
46
+ * Inputs: a version. Output: its text. Errors: none. Side effects: none.
47
+ */
48
+ export declare function formatVersion(version: SemVer): string;
49
+ /**
50
+ * Orders two versions by semver precedence (build metadata ignored).
51
+ *
52
+ * Inputs: two versions. Output: negative, zero or positive. Errors: none. Side effects: none.
53
+ */
54
+ export declare function compareVersions(a: SemVer, b: SemVer): number;
55
+ /**
56
+ * Parses an npm range.
57
+ *
58
+ * Inputs: the text (`^1.2.0`, `>=1 <3 || 4.x`). Output: the `SemverRange`, or `undefined` for
59
+ * anything that is not a range in npm's grammar (tags, URLs, paths, protocols, aliases), an
60
+ * empty alternative (`1 ||`) or a text over `MAX_RANGE_LENGTH`. An empty or blank text is `*`,
61
+ * as npm reads it. Errors: none. Side effects: none.
62
+ */
63
+ export declare function parseRange(text: string): SemverRange | undefined;
64
+ /**
65
+ * Whether a version is inside a range, with npm's prerelease rule.
66
+ *
67
+ * Inputs: a parsed version and a parsed range. Output: true when some alternative holds.
68
+ * Errors: none. Side effects: none.
69
+ */
70
+ export declare function satisfies(candidate: SemVer, range: SemverRange): boolean;
71
+ /**
72
+ * Whether a version text is inside a range text (both parsed with the functions above).
73
+ *
74
+ * Inputs: an exact version and a range. Output: false when either does not parse. Errors: none.
75
+ * Side effects: none.
76
+ */
77
+ export declare function versionSatisfies(versionText: string, rangeText: string): boolean;
78
+ /**
79
+ * The newest version of a list inside a range, prereleases left out unless the range names
80
+ * one (the lock tool's choice, TAG-402). Versions with equal SemVer precedence use descending
81
+ * code-unit lexical order as a stable tie-breaker, so build metadata cannot make input order matter.
82
+ *
83
+ * Inputs: version texts (unparseable ones are skipped) and a range text. Output: the newest
84
+ * matching text, or `undefined` when none matches or the range does not parse. Errors: none.
85
+ * Side effects: none.
86
+ */
87
+ export declare function maxSatisfying(versions: readonly string[], rangeText: string): string | undefined;
88
+ export {};
89
+ //# sourceMappingURL=semver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semver.d.ts","sourceR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