@jini-ai/core 0.7.1 → 0.7.3-next.1

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/README.md +40 -12
  2. package/dist/admin-runtime/admin-api-error.d.ts +68 -0
  3. package/dist/admin-runtime/admin-api-error.js +72 -0
  4. package/dist/admin-runtime/admin-config-error.d.ts +8 -0
  5. package/dist/admin-runtime/admin-config-error.js +11 -0
  6. package/dist/admin-runtime/controller-store.d.ts +20 -0
  7. package/dist/admin-runtime/controller-store.js +32 -0
  8. package/dist/admin-runtime/index.d.ts +13 -0
  9. package/dist/admin-runtime/index.js +12 -0
  10. package/dist/admin-runtime/panel-access.d.ts +88 -0
  11. package/dist/admin-runtime/panel-access.js +76 -0
  12. package/dist/admin-runtime/query-suffix.d.ts +5 -0
  13. package/dist/admin-runtime/query-suffix.js +5 -0
  14. package/dist/agent-handles/element-handles.d.ts +134 -0
  15. package/dist/agent-handles/element-handles.js +45 -0
  16. package/dist/agent-handles/field-descriptor.d.ts +28 -0
  17. package/dist/agent-handles/field-descriptor.js +3 -0
  18. package/dist/agent-handles/handle.d.ts +109 -0
  19. package/dist/agent-handles/handle.js +109 -0
  20. package/dist/agent-handles/index.d.ts +9 -0
  21. package/dist/agent-handles/index.js +6 -0
  22. package/dist/agent-handles/list-handles.d.ts +46 -0
  23. package/dist/agent-handles/list-handles.js +67 -0
  24. package/dist/agent-handles/secret-attrs.d.ts +14 -0
  25. package/dist/agent-handles/secret-attrs.js +13 -0
  26. package/dist/approval-batch-chain.d.ts +45 -0
  27. package/dist/approval-batch-chain.js +75 -0
  28. package/dist/approval.d.ts +33 -14
  29. package/dist/approval.js +57 -43
  30. package/dist/batch-tool-inputs.js +24 -20
  31. package/dist/contracts/admin-module.d.ts +166 -0
  32. package/dist/contracts/admin-module.js +14 -0
  33. package/dist/contracts/agents/definition.d.ts +459 -0
  34. package/dist/contracts/agents/definition.js +2 -0
  35. package/dist/contracts/agents/index.d.ts +7 -0
  36. package/dist/contracts/agents/index.js +2 -0
  37. package/dist/contracts/agents/launch.d.ts +64 -0
  38. package/dist/contracts/agents/launch.js +2 -0
  39. package/dist/contracts/agents/model-catalog.d.ts +213 -0
  40. package/dist/contracts/agents/model-catalog.js +4 -0
  41. package/dist/contracts/agents/native-tool-policy.d.ts +42 -0
  42. package/dist/contracts/agents/native-tool-policy.js +2 -0
  43. package/dist/contracts/ai-trace/capture.d.ts +17 -0
  44. package/dist/contracts/ai-trace/capture.js +43 -0
  45. package/dist/contracts/ai-trace/classify.d.ts +12 -0
  46. package/dist/contracts/ai-trace/classify.js +16 -0
  47. package/dist/contracts/ai-trace/index.d.ts +13 -0
  48. package/dist/contracts/ai-trace/index.js +6 -0
  49. package/dist/contracts/ai-trace/recorder.d.ts +64 -0
  50. package/dist/contracts/ai-trace/recorder.js +283 -0
  51. package/dist/contracts/ai-trace/sinks.d.ts +51 -0
  52. package/dist/contracts/ai-trace/sinks.js +153 -0
  53. package/dist/contracts/ai-trace/types.d.ts +123 -0
  54. package/dist/contracts/ai-trace/types.js +17 -0
  55. package/dist/contracts/ai-trace/usage.d.ts +16 -0
  56. package/dist/contracts/ai-trace/usage.js +45 -0
  57. package/dist/contracts/blob.d.ts +31 -0
  58. package/dist/contracts/blob.js +10 -0
  59. package/dist/contracts/capabilities.d.ts +95 -0
  60. package/dist/contracts/capabilities.js +111 -0
  61. package/dist/contracts/charts.d.ts +75 -0
  62. package/dist/contracts/charts.js +4 -0
  63. package/dist/contracts/env.d.ts +96 -0
  64. package/dist/contracts/env.js +6 -0
  65. package/dist/contracts/events/change-set.d.ts +106 -0
  66. package/dist/contracts/events/change-set.js +2 -0
  67. package/dist/contracts/events/command.d.ts +118 -0
  68. package/dist/contracts/events/command.js +2 -0
  69. package/dist/contracts/events/ports.d.ts +172 -0
  70. package/dist/contracts/events/ports.js +2 -0
  71. package/dist/contracts/events.d.ts +5 -0
  72. package/dist/contracts/events.js +2 -0
  73. package/dist/contracts/forms.d.ts +110 -0
  74. package/dist/contracts/forms.js +4 -0
  75. package/dist/contracts/hosted-mcp/config.d.ts +19 -0
  76. package/dist/contracts/hosted-mcp/record.d.ts +61 -4
  77. package/dist/contracts/mail/email-sender.d.ts +118 -0
  78. package/dist/contracts/mail/email-sender.js +20 -0
  79. package/dist/contracts/mail/smtp-payload.d.ts +32 -0
  80. package/dist/contracts/mail/smtp-payload.js +2 -0
  81. package/dist/contracts/mail.d.ts +2 -0
  82. package/dist/contracts/mail.js +1 -1
  83. package/dist/contracts/observability.d.ts +232 -0
  84. package/dist/contracts/observability.js +27 -0
  85. package/dist/contracts/plugin-sdk.d.ts +186 -0
  86. package/dist/contracts/plugin-sdk.js +39 -0
  87. package/dist/contracts/runtime/command.d.ts +41 -0
  88. package/dist/contracts/runtime/command.js +60 -0
  89. package/dist/contracts/runtime/environment.d.ts +18 -0
  90. package/dist/contracts/runtime/environment.js +26 -0
  91. package/dist/contracts/runtime/file-lock.d.ts +94 -0
  92. package/dist/contracts/runtime/file-lock.js +25 -0
  93. package/dist/contracts/runtime/fs.d.ts +33 -0
  94. package/dist/contracts/runtime/fs.js +2 -0
  95. package/dist/contracts/runtime/http.d.ts +89 -0
  96. package/dist/contracts/runtime/http.js +2 -0
  97. package/dist/contracts/runtime/platform.d.ts +3 -0
  98. package/dist/contracts/runtime/platform.js +2 -0
  99. package/dist/contracts/runtime/process.d.ts +40 -0
  100. package/dist/contracts/runtime/process.js +31 -0
  101. package/dist/contracts/runtime/reader.d.ts +11 -0
  102. package/dist/contracts/runtime/reader.js +2 -0
  103. package/dist/contracts/runtime/terminal.d.ts +99 -0
  104. package/dist/contracts/runtime/terminal.js +2 -0
  105. package/dist/contracts/runtime/testing.d.ts +84 -0
  106. package/dist/contracts/runtime/testing.js +116 -0
  107. package/dist/contracts/runtime.d.ts +10 -0
  108. package/dist/contracts/runtime.js +10 -0
  109. package/dist/contracts/server/api-error.d.ts +43 -0
  110. package/dist/contracts/server/api-error.js +49 -0
  111. package/dist/contracts/server/auth.d.ts +20 -0
  112. package/dist/contracts/server/auth.js +21 -0
  113. package/dist/contracts/server/conformance.d.ts +25 -0
  114. package/dist/contracts/server/conformance.js +50 -0
  115. package/dist/contracts/server/json-route.d.ts +176 -0
  116. package/dist/contracts/server/json-route.js +155 -0
  117. package/dist/contracts/server/middleware.d.ts +35 -0
  118. package/dist/contracts/server/middleware.js +56 -0
  119. package/dist/contracts/server/origin.d.ts +44 -0
  120. package/dist/contracts/server/origin.js +32 -0
  121. package/dist/contracts/server/query.d.ts +16 -0
  122. package/dist/contracts/server/query.js +69 -0
  123. package/dist/contracts/server/rate-limit.d.ts +20 -0
  124. package/dist/contracts/server/rate-limit.js +8 -0
  125. package/dist/contracts/server/request-body.d.ts +26 -0
  126. package/dist/contracts/server/request-body.js +82 -0
  127. package/dist/contracts/server/result.d.ts +17 -0
  128. package/dist/contracts/server/result.js +5 -0
  129. package/dist/contracts/server/route-table.d.ts +54 -0
  130. package/dist/contracts/server/route-table.js +119 -0
  131. package/dist/contracts/server/same-origin-write.d.ts +18 -0
  132. package/dist/contracts/server/same-origin-write.js +31 -0
  133. package/dist/contracts/server/security-headers.d.ts +30 -0
  134. package/dist/contracts/server/security-headers.js +35 -0
  135. package/dist/contracts/server/sse.d.ts +82 -0
  136. package/dist/contracts/server/sse.js +103 -0
  137. package/dist/contracts/server/testing.d.ts +59 -0
  138. package/dist/contracts/server/testing.js +68 -0
  139. package/dist/contracts/server/verified-origin/configured-origin.d.ts +37 -0
  140. package/dist/contracts/server/verified-origin/configured-origin.js +103 -0
  141. package/dist/contracts/server/verified-origin/index.d.ts +7 -0
  142. package/dist/contracts/server/verified-origin/index.js +6 -0
  143. package/dist/contracts/server/verified-origin/loopback-host.d.ts +9 -0
  144. package/dist/contracts/server/verified-origin/loopback-host.js +17 -0
  145. package/dist/contracts/server/verified-origin/origin.d.ts +64 -0
  146. package/dist/contracts/server/verified-origin/origin.js +162 -0
  147. package/dist/contracts/server/verified-origin/ports.d.ts +38 -0
  148. package/dist/contracts/server/verified-origin/ports.js +2 -0
  149. package/dist/contracts/server/verified-origin/repo.memory.d.ts +32 -0
  150. package/dist/contracts/server/verified-origin/repo.memory.js +34 -0
  151. package/dist/contracts/server/verified-origin/site-path.d.ts +113 -0
  152. package/dist/contracts/server/verified-origin/site-path.js +188 -0
  153. package/dist/contracts/server/verified-origin/types.d.ts +33 -0
  154. package/dist/contracts/server/verified-origin/types.js +30 -0
  155. package/dist/contracts/server.d.ts +46 -2
  156. package/dist/contracts/server.js +17 -3
  157. package/dist/contracts/storage/kernel.d.ts +86 -0
  158. package/dist/contracts/storage/kernel.js +38 -0
  159. package/dist/contracts/storage/migration.d.ts +32 -0
  160. package/dist/contracts/storage/migration.js +2 -0
  161. package/dist/contracts/storage/rows.d.ts +33 -0
  162. package/dist/contracts/storage/rows.js +42 -0
  163. package/dist/contracts/storage/sqlite.d.ts +113 -0
  164. package/dist/contracts/storage/sqlite.js +8 -0
  165. package/dist/contracts/storage/values.d.ts +25 -0
  166. package/dist/contracts/storage/values.js +25 -0
  167. package/dist/contracts/storage.d.ts +8 -0
  168. package/dist/contracts/storage.js +6 -0
  169. package/dist/contracts/vault/invariants.d.ts +26 -0
  170. package/dist/contracts/vault/invariants.js +49 -0
  171. package/dist/contracts/vault.d.ts +1 -0
  172. package/dist/contracts/vault.js +1 -1
  173. package/dist/env/coercers.d.ts +21 -0
  174. package/dist/env/coercers.js +68 -0
  175. package/dist/env/describe-env-for-diagnostics.d.ts +16 -0
  176. package/dist/env/describe-env-for-diagnostics.js +23 -0
  177. package/dist/env/format-env-issue.d.ts +13 -0
  178. package/dist/env/format-env-issue.js +22 -0
  179. package/dist/env/parse-env.d.ts +24 -0
  180. package/dist/env/parse-env.js +102 -0
  181. package/dist/env/value-echo.d.ts +17 -0
  182. package/dist/env/value-echo.js +42 -0
  183. package/dist/errors/approved-cause.d.ts +36 -0
  184. package/dist/errors/approved-cause.js +17 -0
  185. package/dist/errors/bindings.d.ts +61 -0
  186. package/dist/errors/bindings.js +57 -0
  187. package/dist/errors/catalog.d.ts +84 -0
  188. package/dist/errors/catalog.js +151 -0
  189. package/dist/errors/disclosure.d.ts +48 -0
  190. package/dist/errors/disclosure.js +27 -0
  191. package/dist/errors/error-id.d.ts +26 -0
  192. package/dist/errors/error-id.js +23 -0
  193. package/dist/errors/idioms.d.ts +73 -0
  194. package/dist/errors/idioms.js +85 -0
  195. package/dist/errors/incident-text.d.ts +16 -0
  196. package/dist/errors/incident-text.js +77 -0
  197. package/dist/errors/reporter.d.ts +94 -0
  198. package/dist/errors/reporter.js +152 -0
  199. package/dist/errors/sentences.d.ts +68 -0
  200. package/dist/errors/sentences.js +93 -0
  201. package/dist/errors/testing.d.ts +50 -0
  202. package/dist/errors/testing.js +44 -0
  203. package/dist/fetch/cache.d.ts +12 -5
  204. package/dist/fetch/cache.js +46 -47
  205. package/dist/fetch/index.d.ts +1 -1
  206. package/dist/fetch/loader-read.d.ts +6 -2
  207. package/dist/fetch/loader-read.js +4 -4
  208. package/dist/format-error-for-log.d.ts +15 -0
  209. package/dist/format-error-for-log.js +55 -0
  210. package/dist/host-read-vocabulary.d.ts +47 -0
  211. package/dist/host-read-vocabulary.js +44 -0
  212. package/dist/index.d.ts +5 -1
  213. package/dist/index.js +4 -0
  214. package/dist/list-page.d.ts +93 -0
  215. package/dist/list-page.js +154 -0
  216. package/dist/model-facing-tool-errors.d.ts +67 -5
  217. package/dist/model-facing-tool-errors.js +155 -19
  218. package/dist/net/endpoint-policy.d.ts +39 -0
  219. package/dist/net/endpoint-policy.js +218 -0
  220. package/dist/net/fetch-timeouts.d.ts +38 -0
  221. package/dist/net/fetch-timeouts.js +31 -0
  222. package/dist/net/index.d.ts +4 -0
  223. package/dist/net/index.js +4 -0
  224. package/dist/net/loopback.d.ts +13 -0
  225. package/dist/net/loopback.js +39 -0
  226. package/dist/optimistic-concurrency.d.ts +183 -0
  227. package/dist/optimistic-concurrency.js +222 -0
  228. package/dist/primitives/errors.d.ts +9 -0
  229. package/dist/primitives/errors.js +12 -0
  230. package/dist/primitives/ids.d.ts +0 -2
  231. package/dist/primitives/ids.js +1 -4
  232. package/dist/primitives/index.d.ts +3 -0
  233. package/dist/primitives/index.js +2 -0
  234. package/dist/primitives/logger.d.ts +36 -1
  235. package/dist/primitives/logger.js +125 -9
  236. package/dist/primitives/node-shape.d.ts +24 -0
  237. package/dist/primitives/node-shape.js +21 -0
  238. package/dist/primitives/time.d.ts +9 -2
  239. package/dist/primitives/time.js +4 -3
  240. package/dist/provider-registry.js +26 -20
  241. package/dist/records.d.ts +40 -7
  242. package/dist/records.js +37 -3
  243. package/dist/redact.d.ts +1 -84
  244. package/dist/redact.js +2 -826
  245. package/dist/redaction-collectors.d.ts +7 -0
  246. package/dist/redaction-collectors.js +152 -0
  247. package/dist/redaction-exact-secrets.d.ts +14 -0
  248. package/dist/redaction-exact-secrets.js +115 -0
  249. package/dist/redaction-labels.d.ts +14 -0
  250. package/dist/redaction-labels.js +156 -0
  251. package/dist/redaction-patterns.d.ts +54 -0
  252. package/dist/redaction-patterns.js +178 -0
  253. package/dist/redaction-spans.d.ts +31 -0
  254. package/dist/redaction-spans.js +83 -0
  255. package/dist/registration-kit.d.ts +1 -1
  256. package/dist/revision-conflict-error.d.ts +18 -0
  257. package/dist/revision-conflict-error.js +20 -0
  258. package/dist/secret-shapes.d.ts +50 -0
  259. package/dist/secret-shapes.js +105 -0
  260. package/dist/settings/agent-tools.js +22 -8
  261. package/dist/settings/agent-value-write-tools.d.ts +4 -1
  262. package/dist/settings/agent-value-write-tools.js +7 -6
  263. package/dist/settings/agent-writable-preferences.d.ts +3 -1
  264. package/dist/settings/agent-writable-preferences.js +1 -1
  265. package/dist/settings/agent-write-denylist.d.ts +7 -4
  266. package/dist/settings/agent-write-denylist.js +1 -1
  267. package/dist/settings/{express/cms-adapter.d.ts → cms-adapter.d.ts} +3 -2
  268. package/dist/settings/{express/cms-adapter.js → cms-adapter.js} +21 -11
  269. package/dist/settings/definitions-dispatch.js +3 -1
  270. package/dist/settings/ensure-definitions.js +3 -1
  271. package/dist/settings/errors.d.ts +1 -13
  272. package/dist/settings/errors.js +2 -15
  273. package/dist/settings/index.d.ts +11 -2
  274. package/dist/settings/index.js +10 -2
  275. package/dist/settings/purge-service.js +63 -86
  276. package/dist/settings/{express/contracts.d.ts → route-policy.d.ts} +53 -47
  277. package/dist/settings/{express/shared.js → route-policy.js} +1 -16
  278. package/dist/settings/settings.d.ts +19 -11
  279. package/dist/settings/settings.js +9 -11
  280. package/dist/settings/tool-registrations.d.ts +3 -3
  281. package/dist/settings/tool-registrations.js +130 -125
  282. package/dist/settings/types.d.ts +1 -1
  283. package/dist/settings/write-definition-rename.d.ts +37 -0
  284. package/dist/settings/write-definition-rename.js +119 -0
  285. package/dist/settings/write-definition-retype.d.ts +61 -0
  286. package/dist/settings/write-definition-retype.js +109 -0
  287. package/dist/settings/write-definition-status.d.ts +81 -0
  288. package/dist/settings/write-definition-status.js +121 -0
  289. package/dist/settings/write-reset.d.ts +34 -0
  290. package/dist/settings/write-reset.js +73 -0
  291. package/dist/settings/write-service.d.ts +16 -287
  292. package/dist/settings/write-service.js +49 -681
  293. package/dist/settings/write-value-revisions.d.ts +68 -0
  294. package/dist/settings/write-value-revisions.js +124 -0
  295. package/dist/settings/write-values.d.ts +96 -0
  296. package/dist/settings/write-values.js +83 -0
  297. package/dist/surface-exchanges.d.ts +2 -2
  298. package/dist/text/dictionary-translator.d.ts +19 -0
  299. package/dist/text/dictionary-translator.js +14 -0
  300. package/dist/text/format-byte-size.d.ts +25 -0
  301. package/dist/text/format-byte-size.js +25 -0
  302. package/dist/text/format-timestamp.d.ts +22 -0
  303. package/dist/text/format-timestamp.js +57 -0
  304. package/dist/text/index.d.ts +12 -0
  305. package/dist/text/index.js +9 -0
  306. package/dist/text/is-abort-error.d.ts +5 -0
  307. package/dist/text/is-abort-error.js +5 -0
  308. package/dist/text/mime.d.ts +5 -0
  309. package/dist/text/mime.js +21 -0
  310. package/dist/text/redact-urls.d.ts +7 -0
  311. package/dist/text/redact-urls.js +5 -0
  312. package/dist/text/resolve-active-tab-id.d.ts +13 -0
  313. package/dist/text/resolve-active-tab-id.js +15 -0
  314. package/dist/text/sanitize-untrusted-text.d.ts +1 -1
  315. package/dist/text/sanitize-untrusted-text.js +2 -1
  316. package/dist/text/tagged-text-suppression.d.ts +103 -0
  317. package/dist/text/tagged-text-suppression.js +143 -0
  318. package/dist/text/template-i18n.d.ts +37 -0
  319. package/dist/text/template-i18n.js +48 -0
  320. package/dist/tool-call-text.d.ts +59 -0
  321. package/dist/tool-call-text.js +62 -0
  322. package/dist/tool-input-envelope.js +8 -4
  323. package/dist/tool-input-normalization.js +8 -1
  324. package/dist/tool-input-repairs.d.ts +58 -0
  325. package/dist/tool-input-repairs.js +154 -0
  326. package/dist/tool-tokens.js +1 -1
  327. package/dist/user-facing-error.d.ts +1 -1
  328. package/dist/user-facing-error.js +3 -1
  329. package/package.json +234 -13
  330. package/dist/settings/express/contracts.js +0 -2
  331. package/dist/settings/express/http-request.d.ts +0 -33
  332. package/dist/settings/express/http-request.js +0 -50
  333. package/dist/settings/express/http.d.ts +0 -10
  334. package/dist/settings/express/http.js +0 -196
  335. package/dist/settings/express/index.d.ts +0 -5
  336. package/dist/settings/express/index.js +0 -4
  337. package/dist/settings/express/shared.d.ts +0 -68
  338. package/dist/settings/express/stream.d.ts +0 -24
  339. package/dist/settings/express/stream.js +0 -171
@@ -0,0 +1,7 @@
1
+ import { type SecretRedactionOptions } from './redaction-patterns.js';
2
+ import { type Span } from './redaction-spans.js';
3
+ /** Every rule's spans over the original text, in rule-precedence order (see {@link mergeSpans}). */
4
+ export declare function collectSpans({ text }: {
5
+ text: string;
6
+ }, options: SecretRedactionOptions): Span[];
7
+ //# sourceMappingURL=redaction-collectors.d.ts.map
@@ -0,0 +1,152 @@
1
+ import { SECRET_SHAPE_PATTERNS } from './secret-shapes.js';
2
+ import { PATTERNS, CATEGORY, CARD_CANDIDATE, API_KEY_HEADER, API_KEY_QUERY, SHORT_BEARER_RE, BASIC_AUTH_RE, COOKIE_HEADER_RE, PROVIDER_API_KEY_QUERY, URL_CREDENTIALS_RE, SIGNED_QUERY_RE, URL_SECRET_PARAM_RE, LABELED_URL_PARAM_NAME_RE, OPAQUE_TOKEN_RE, NON_SECRET_TOKEN_RE, isMaskedValue } from './redaction-patterns.js';
3
+ import { collectMatches, trailingValue } from './redaction-spans.js';
4
+ import { collectLabeledSecrets, emptyAssignmentRanges, collectEmptyQuotedAssignments } from './redaction-labels.js';
5
+ import { collectExactSecrets } from './redaction-exact-secrets.js';
6
+ // The length guard and the per-digit `d < 0 || d > 9` guard from the origin
7
+ // were both dropped here (a documented deviation from the otherwise-verbatim
8
+ // port — see archived provenance ledger): `isLuhnValid` is private with exactly one call
9
+ // site (the `CARD_CANDIDATE.replace` callbacks below), and `CARD_CANDIDATE`'s
10
+ // own regex (`\b(?:\d[ -]?){12,18}\d\b`) already guarantees any string
11
+ // reaching here is 13-19 characters, and the preceding `match.replace(/\D/g,
12
+ // '')` strip guarantees every character is an ASCII digit — so both guards
13
+ // were provably unreachable, not speculative.
14
+ function isLuhnValid(digits) {
15
+ let sum = 0;
16
+ let alt = false;
17
+ for (let i = digits.length - 1; i >= 0; i -= 1) {
18
+ let d = digits.charCodeAt(i) - 48;
19
+ if (alt) {
20
+ d *= 2;
21
+ if (d > 9)
22
+ d -= 9;
23
+ }
24
+ sum += d;
25
+ alt = !alt;
26
+ }
27
+ return sum % 10 === 0;
28
+ }
29
+ /** Every rule's spans over the original text, in rule-precedence order (see {@link mergeSpans}). */
30
+ export function collectSpans({ text }, options) {
31
+ const spans = [];
32
+ const add = (start, end, category, suffix) => {
33
+ if (end > start || (end === start && suffix !== undefined))
34
+ spans.push({ start, end, category, suffix });
35
+ };
36
+ if (options.policy === 'exact-only') {
37
+ collectExactSecrets({ text, add, secrets: options.exactSecrets ?? [] }, { literalOnly: true });
38
+ return spans;
39
+ }
40
+ collectExactSecrets({ text, add, secrets: options.exactSecrets ?? [] });
41
+ // Whole PEM blocks use the existing shared vocabulary; every rule sees their original delimiters.
42
+ collectEmptyQuotedAssignments({ text, add });
43
+ collectUrlCredentials({ text, add });
44
+ collectPatterns({ text, add, patterns: credentialPatterns(options.extraPatterns ?? []) });
45
+ collectKeyedCredentials({ text, add });
46
+ collectLabeledSecrets({ text, add }, spans);
47
+ if (options.policy === 'aggressive')
48
+ collectOpaqueTokens({ text, add }, new Set(options.diagnosticToolIds));
49
+ if (options.redactPii !== false)
50
+ collectPii({ text, add }, spans);
51
+ return spans;
52
+ }
53
+ // PII rules are collected last (after credential and opt-in opaque rules) and only when PII
54
+ // redaction is on; splitting once keeps each list in PATTERNS order.
55
+ const PII_PATTERN_NAMES = ['email', 'ipv4', 'phone'];
56
+ const NON_PII_PATTERNS = PATTERNS.filter((pattern) => !PII_PATTERN_NAMES.includes(pattern.name));
57
+ const PII_PATTERNS = PATTERNS.filter((pattern) => PII_PATTERN_NAMES.includes(pattern.name));
58
+ /** Built-in credential rules, then the static-scan shapes (labeled `credential`), then the caller's extra rules. */
59
+ function credentialPatterns(extraPatterns) {
60
+ return [
61
+ ...NON_PII_PATTERNS,
62
+ ...SECRET_SHAPE_PATTERNS.map((shape) => ({ name: CATEGORY.credential, regex: shape.pattern })),
63
+ ...extraPatterns,
64
+ ];
65
+ }
66
+ function collectPatterns({ text, add, patterns }) {
67
+ for (const { name, regex } of patterns) {
68
+ collectMatches({ text, add }, regex, (match, index) => ({ start: index, end: index + match[0].length, category: name }));
69
+ }
70
+ }
71
+ /** URL userinfo and signed query values: credentials recognized by their URL context. */
72
+ function collectUrlCredentials(pass) {
73
+ collectMatches(pass, URL_CREDENTIALS_RE, (match, index) => {
74
+ const userinfo = match[1] ?? '';
75
+ if (isMaskedValue(userinfo))
76
+ return undefined;
77
+ const start = index + '//'.length;
78
+ return { start, end: start + userinfo.length, category: CATEGORY.urlCredentials };
79
+ });
80
+ collectMatches(pass, SIGNED_QUERY_RE, trailingValue({ category: CATEGORY.signedQuery, group: 2 }));
81
+ }
82
+ /** Values named by a header, query parameter or bearer prefix. Each rule matches the original
83
+ * text, so overlapping rules (the provider query rule includes a fragment the core rule stops
84
+ * before) merge into one span instead of one leaving a credential suffix beside the other's marker. */
85
+ function collectKeyedCredentials(pass) {
86
+ collectApiKeyHeaders(pass);
87
+ collectMatches(pass, PROVIDER_API_KEY_QUERY, trailingValue({ category: CATEGORY.apiKeyQuery, group: 2 }));
88
+ collectMatches(pass, API_KEY_QUERY, (match, index) => {
89
+ const start = index + (match[1] ?? '').length;
90
+ const end = index + match[0].length;
91
+ return isMaskedValue(match[0].slice(start - index)) ? undefined : { start, end, category: CATEGORY.apiKeyQuery };
92
+ });
93
+ collectMatches(pass, SHORT_BEARER_RE, (match, index) => {
94
+ const start = index + match[0].length;
95
+ return { start, end: start + (match[1] ?? '').length, category: CATEGORY.bearerToken };
96
+ });
97
+ collectMatches(pass, BASIC_AUTH_RE, trailingValue({ category: CATEGORY.labeledSecret, group: 1 }));
98
+ collectMatches(pass, COOKIE_HEADER_RE, trailingValue({ category: CATEGORY.labeledSecret, group: 1 }));
99
+ collectUrlSecretParams(pass);
100
+ }
101
+ /** Header values stop at their quotes; an empty quoted hint cannot borrow the next field.
102
+ * @complexity O(n) over input characters, no I/O. */
103
+ function collectApiKeyHeaders(pass) {
104
+ const hints = emptyAssignmentRanges(pass.text);
105
+ collectMatches(pass, API_KEY_HEADER, (match, index) => {
106
+ const labelStart = index + (match[1] ?? '').length;
107
+ if (hints.has(labelStart))
108
+ return undefined;
109
+ const value = match[5] ?? '';
110
+ if (isMaskedValue(value))
111
+ return undefined;
112
+ const end = index + match[0].length;
113
+ // A quoted value keeps its quotes around the marker.
114
+ const quoted = /^["']/.test(value) ? 1 : 0;
115
+ return { start: end - value.length + quoted, end: end - quoted, category: CATEGORY.apiKeyHeader };
116
+ });
117
+ }
118
+ /** Secret-named URL query/fragment values; values already masked keep their category. */
119
+ function collectUrlSecretParams(pass) {
120
+ collectMatches(pass, URL_SECRET_PARAM_RE, (match, index) => {
121
+ const separator = match[0].indexOf('=') + 1;
122
+ if (isMaskedValue(match[0].slice(separator)))
123
+ return undefined;
124
+ const category = LABELED_URL_PARAM_NAME_RE.test(match[1] ?? '') ? CATEGORY.labeledSecret : CATEGORY.urlSecretParam;
125
+ return { start: index + separator, end: index + match[0].length, category };
126
+ });
127
+ }
128
+ /** Opt-in bare opaque runs; whole trusted dotted IDs and non-secret diagnostic tokens stay readable. */
129
+ function collectOpaqueTokens({ text, add }, trustedIds) {
130
+ for (const token of text.matchAll(/[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*/g)) {
131
+ if (trustedIds.has(token[0]))
132
+ continue;
133
+ for (const run of token[0].matchAll(OPAQUE_TOKEN_RE)) {
134
+ if (NON_SECRET_TOKEN_RE.test(run[0]))
135
+ continue;
136
+ const start = (token.index ?? 0) + (run.index ?? 0);
137
+ add(start, start + run[0].length, CATEGORY.opaqueToken);
138
+ }
139
+ }
140
+ }
141
+ /** Email/IPv4/phone rules, then Luhn-checked card candidates. The email rule retains alphabetic TLDs so versioned paths stay readable. An "email" whose `@` ends URL userinfo
142
+ * (`scheme://user:pw@host`) is skipped: its local part is already the credential span, and
143
+ * merging it would mask the host, which stays readable for debugging. */
144
+ function collectPii(pass, earlier) {
145
+ const userinfoEnds = new Set(earlier.filter(({ category }) => category === CATEGORY.urlCredentials).map(({ end }) => end));
146
+ for (const { name, regex } of PII_PATTERNS) {
147
+ collectMatches(pass, regex, (match, index) => name === 'email' && userinfoEnds.has(index) ? undefined
148
+ : { start: index - (match.groups?.local?.length ?? 0), end: index + match[0].length, category: name });
149
+ }
150
+ collectMatches(pass, CARD_CANDIDATE, (match, index) => isLuhnValid(match[0].replace(/\D/g, '')) ? { start: index, end: index + match[0].length, category: CATEGORY.creditCard } : undefined);
151
+ }
152
+ //# sourceMappingURL=redaction-collectors.js.map
@@ -0,0 +1,14 @@
1
+ import { type SpanPass } from './redaction-spans.js';
2
+ /** Caller-supplied secrets as plain substrings at any length and every occurrence, overlapping
3
+ * ones included (a secret glued into other text stays masked). Matching the original text retains every value rule
4
+ * while wholly contained syntax occurrences preserve labels, markers and URL prefixes. Occurrences arrive
5
+ * in start order and each one either extends the current run or starts the next, so the runs are
6
+ * exactly the union of all occurrences.
7
+ * @complexity O(e·n + s) for e needles, n text chars and s needle chars; consecutive overlapping
8
+ * hits of one needle share a span. */
9
+ export declare function collectExactSecrets({ text, add, secrets }: SpanPass & {
10
+ secrets: ReadonlyArray<string | undefined | null>;
11
+ }, options?: {
12
+ literalOnly?: boolean;
13
+ }): void;
14
+ //# sourceMappingURL=redaction-exact-secrets.d.ts.map
@@ -0,0 +1,115 @@
1
+ import { CATEGORY, GENERATED_MARKER, MASK_AWARE_LABELED_SECRET_RE, URL_SECRET_PARAM_RE } from './redaction-patterns.js';
2
+ import { collectMatches, mergeSpans } from './redaction-spans.js';
3
+ /** Each usable secret plus its JSON-escaped spelling (`ab"cd` echoed inside JSON as `ab\"cd`). */
4
+ function exactNeedles(secrets, literalOnly = false) {
5
+ const needles = new Set();
6
+ for (const secret of secrets) {
7
+ if (typeof secret !== 'string' || secret.length === 0)
8
+ continue;
9
+ needles.add(secret);
10
+ if (!literalOnly)
11
+ needles.add(JSON.stringify(secret).slice(1, -1));
12
+ }
13
+ return needles;
14
+ }
15
+ /** Caller-supplied secrets as plain substrings at any length and every occurrence, overlapping
16
+ * ones included (a secret glued into other text stays masked). Matching the original text retains every value rule
17
+ * while wholly contained syntax occurrences preserve labels, markers and URL prefixes. Occurrences arrive
18
+ * in start order and each one either extends the current run or starts the next, so the runs are
19
+ * exactly the union of all occurrences.
20
+ * @complexity O(e·n + s) for e needles, n text chars and s needle chars; consecutive overlapping
21
+ * hits of one needle share a span. */
22
+ export function collectExactSecrets({ text, add, secrets }, options = {}) {
23
+ const needles = exactNeedles(secrets, options.literalOnly);
24
+ if (needles.size === 0)
25
+ return;
26
+ const protectedSyntax = options.literalOnly ? [] : exactSyntaxRanges({ text });
27
+ for (const needle of needles) {
28
+ const insideSyntax = syntaxContainment({ ranges: protectedSyntax });
29
+ let runStart = -1;
30
+ let runEnd = -1;
31
+ forEachOccurrence(text, needle, (at) => {
32
+ if (insideSyntax(at, at + needle.length))
33
+ return;
34
+ if (beginsSecretRun({ at, runEnd, literalOnly: options.literalOnly === true })) {
35
+ add(runStart, runEnd, CATEGORY.exactSecret);
36
+ runStart = at;
37
+ }
38
+ runEnd = at + needle.length;
39
+ });
40
+ add(runStart, runEnd, CATEGORY.exactSecret);
41
+ }
42
+ }
43
+ /** Preserve diagnostic syntax only when an exact occurrence fits wholly inside it.
44
+ * Crossing a label/marker boundary still masks the complete secret, retaining span-union safety.
45
+ * @complexity O(n + k) time/space over n characters and k syntax ranges; no I/O. */
46
+ function exactSyntaxRanges({ text }, _options = {}) {
47
+ const ranges = [];
48
+ const add = (start, end) => { ranges.push({ start, end, category: 'syntax' }); };
49
+ const pass = { text, add };
50
+ collectMatches(pass, new RegExp(`${GENERATED_MARKER}|\\[redacted\\]`, 'gi'), (m, at) => ({ start: at, end: at + m[0].length, category: 'syntax' }));
51
+ collectMatches(pass, MASK_AWARE_LABELED_SECRET_RE, (m, at) => ({ start: at, end: at + m[0].length - 1, category: 'syntax' }));
52
+ collectMatches(pass, /\bBearer\s+|\bhttps?:\/\/|(?:x-api-key|api-key|x-goog-api-key)\s*[:=]\s*/gi, (m, at) => ({ start: at, end: at + m[0].length, category: 'syntax' }));
53
+ collectMatches(pass, URL_SECRET_PARAM_RE, (m, at) => ({ start: at, end: at + m[0].indexOf('=') + 1, category: 'syntax' }));
54
+ return mergeSpans(ranges);
55
+ }
56
+ /** Increasing occurrence starts let each needle visit every protected range at most once.
57
+ * @complexity O(k + hits) across calls, O(1) retained state; no I/O. */
58
+ function syntaxContainment({ ranges }, _options = {}) {
59
+ let cursor = 0;
60
+ return (start, end) => {
61
+ while (cursor < ranges.length && ranges[cursor].end <= start)
62
+ cursor++;
63
+ const range = ranges[cursor];
64
+ return range !== undefined && range.start <= start && range.end >= end;
65
+ };
66
+ }
67
+ /** Heuristic union joins adjacent hits; exact-only retains one marker for each adjacent occurrence. */
68
+ function beginsSecretRun({ at, runEnd, literalOnly }, _options = {}) {
69
+ return literalOnly ? at >= runEnd : at > runEnd;
70
+ }
71
+ /** Calls `visit` with the start of every occurrence of `needle` in order, overlapping ones included.
72
+ * Knuth-Morris-Pratt: after a hit the scan keeps the needle's longest border instead of retrying one
73
+ * character later (which cost Θ(n·m) on long overlapping needles), so no text character is read
74
+ * twice; while no partial match is pending, native indexOf skips to the next occurrence.
75
+ * @complexity O(n + m) time, O(m) space for n text and m needle chars. */
76
+ function forEachOccurrence(text, needle, visit) {
77
+ const border = borderTable(needle);
78
+ let matched = 0;
79
+ let at = text.indexOf(needle);
80
+ while (at !== -1) {
81
+ const char = text.charCodeAt(at);
82
+ while (matched > 0 && char !== needle.charCodeAt(matched))
83
+ matched = border[matched - 1] ?? 0;
84
+ if (char === needle.charCodeAt(matched))
85
+ matched += 1;
86
+ if (matched === needle.length) {
87
+ visit(at + 1 - needle.length);
88
+ matched = border[matched - 1] ?? 0;
89
+ }
90
+ at = nextSearchOffset({ text, needle, at, matched });
91
+ }
92
+ }
93
+ /** Keep partial KMP matches moving one character at a time; native indexOf skips unmatched runs. */
94
+ function nextSearchOffset({ text, needle, at, matched }, _options = {}) {
95
+ const next = at + 1;
96
+ if (next >= text.length)
97
+ return -1;
98
+ return matched === 0 ? text.indexOf(needle, next) : next;
99
+ }
100
+ /** KMP failure table: `border[i]` is the length of the longest proper prefix of `needle[0..i]` that
101
+ * is also its suffix. @complexity O(m) time and space. */
102
+ function borderTable(needle) {
103
+ const border = new Int32Array(needle.length);
104
+ let length = 0;
105
+ for (let i = 1; i < needle.length; i += 1) {
106
+ const char = needle.charCodeAt(i);
107
+ while (length > 0 && char !== needle.charCodeAt(length))
108
+ length = border[length - 1] ?? 0;
109
+ if (char === needle.charCodeAt(length))
110
+ length += 1;
111
+ border[i] = length;
112
+ }
113
+ return border;
114
+ }
115
+ //# sourceMappingURL=redaction-exact-secrets.js.map
@@ -0,0 +1,14 @@
1
+ import type { Span, SpanPass } from './redaction-spans.js';
2
+ /** Label values (`password=...`): only the value is masked, so the label stays readable
3
+ * even when no whitespace separates it; a glued credential suffix fails the complete-marker check.
4
+ * A label whose value an earlier rule already masks (see {@link isCoveredField}) is skipped and the
5
+ * scan resumes at the value, so `api-key=x;password=y` and `?password=x&page=2` keep the following
6
+ * field instead of masking it beside the first value. A masked value resumes the scan past its end.
7
+ * @complexity O(n + k) for n chars and k earlier spans; each skip resumes past the label and value
8
+ * ends come from forward-only finders, so no run is rescanned. */
9
+ export declare function collectLabeledSecrets({ text, add }: SpanPass, earlier: readonly Span[]): void;
10
+ /** Quoted empty credential hints must not borrow the next field's key as their value. */
11
+ export declare function emptyAssignmentRanges(text: string): Set<number>;
12
+ /** Preserve the hint's quotes and neighboring fields; O(n) scan, no I/O. */
13
+ export declare function collectEmptyQuotedAssignments(pass: SpanPass): void;
14
+ //# sourceMappingURL=redaction-labels.d.ts.map
@@ -0,0 +1,156 @@
1
+ import { CATEGORY, QUOTED_SECRET_VALUE, EMPTY_QUOTED_ASSIGNMENT_RE, MASK_AWARE_LABELED_SECRET_RE, CHAINED_LABEL_RE, URL_SECRET_PARAM_RE, isMaskedValue } from './redaction-patterns.js';
2
+ /** Label values (`password=...`): only the value is masked, so the label stays readable
3
+ * even when no whitespace separates it; a glued credential suffix fails the complete-marker check.
4
+ * A label whose value an earlier rule already masks (see {@link isCoveredField}) is skipped and the
5
+ * scan resumes at the value, so `api-key=x;password=y` and `?password=x&page=2` keep the following
6
+ * field instead of masking it beside the first value. A masked value resumes the scan past its end.
7
+ * @complexity O(n + k) for n chars and k earlier spans; each skip resumes past the label and value
8
+ * ends come from forward-only finders, so no run is rescanned. */
9
+ export function collectLabeledSecrets({ text, add }, earlier) {
10
+ const covered = coveredLabelFields({ earlier });
11
+ const hints = emptyAssignmentRanges(text);
12
+ const extentOf = labelValueExtents(text);
13
+ const regex = new RegExp(MASK_AWARE_LABELED_SECRET_RE.source, MASK_AWARE_LABELED_SECRET_RE.flags);
14
+ const chained = new RegExp(CHAINED_LABEL_RE.source, CHAINED_LABEL_RE.flags);
15
+ const urlField = new RegExp(URL_SECRET_PARAM_RE.source, 'iy');
16
+ for (let match = regex.exec(text); match; match = regex.exec(text)) {
17
+ if (hints.has(match.index))
18
+ continue;
19
+ // The URL collector owns complete unquoted parameter values, including quote boundaries.
20
+ // A generic unquoted label would consume the URL's enclosing quote as a secret byte.
21
+ urlField.lastIndex = Math.max(0, match.index - 1);
22
+ if (urlField.exec(text)) {
23
+ regex.lastIndex = urlField.lastIndex;
24
+ continue;
25
+ }
26
+ const start = match.index + match[0].length - 1;
27
+ chained.lastIndex = start;
28
+ if (chained.test(text)) {
29
+ regex.lastIndex = start;
30
+ continue;
31
+ }
32
+ const value = extentOf(start);
33
+ if (covered(start, value) || isMaskedValue(text.slice(start, value.end))) {
34
+ regex.lastIndex = start;
35
+ continue;
36
+ }
37
+ addLabelValue({ text, add, start, value });
38
+ regex.lastIndex = value.end;
39
+ }
40
+ }
41
+ /** Preserve quoted diagnostic/JSON values, including the closing quote on truncated echoes. */
42
+ function addLabelValue({ text, add, start, value }) {
43
+ const quoted = value.quoted ? 1 : 0;
44
+ const closed = value.closingQuote === value.end - 1;
45
+ add(start + quoted, value.end - (quoted && closed ? 1 : 0), CATEGORY.labeledSecret, quoted ? (closed ? '' : text[start]) : undefined);
46
+ }
47
+ /** Index earlier spans once so each label's coverage check takes O(1), including dense headers.
48
+ * No I/O; O(k) time/space for k earlier spans. */
49
+ function coveredLabelFields({ earlier }) {
50
+ // Per earlier span start: the furthest end (scalars rather than per-start end lists:
51
+ // dense fields yield millions of spans). A separator proves coverage only at the full value end.
52
+ const furthest = new Map();
53
+ for (const { start, end } of earlier) {
54
+ furthest.set(start, Math.max(furthest.get(start) ?? end, end));
55
+ }
56
+ return (start, value) => {
57
+ const at = !value.quoted || furthest.has(start) ? start : start + 1;
58
+ return isCoveredField(furthest.get(at), value);
59
+ };
60
+ }
61
+ /** True when an earlier span starting at the label value (inside its opening quote, for a quoted
62
+ * value) masks it: `reach` is the furthest such span end.
63
+ * Inside quotes only the closing quote ends the value (`;` and `&` are value text:
64
+ * `password="sk-...;hunter2"` once left `hunter2`); unquoted values also need complete coverage
65
+ * so a provider-prefix rule ending at `;`/`&` cannot leave the rest of a secret visible. */
66
+ function isCoveredField(reach, { end, closingQuote }) {
67
+ const target = closingQuote === end - 1 ? closingQuote : end;
68
+ return (reach ?? -1) >= target;
69
+ }
70
+ /** Extent finder for label values whose starts increase between calls. An unquoted value runs to
71
+ * whitespace or a `;`/`&` followed by a new label (or end of text). Quotes inside an unquoted
72
+ * secret are secret bytes, not terminators. A quoted value runs through its closing quote (a backslash-escaped quote does not
73
+ * close it) and any text glued after it up to whitespace, `;`, `&` or `,` (`"abc def"hunter2` once
74
+ * left `hunter2`), or to the line end when the quote never closes, so spaces, `;` and `&` inside
75
+ * quotes stay in the value. Structured field delimiters after a closing quote stay readable.
76
+ * @complexity Amortized O(1) per call; all calls together scan the text once per finder. */
77
+ function labelValueExtents(text) {
78
+ const runEnd = forwardFinder(text, /\s|[;&](?=$|[\w.-]+\s*[:=])/);
79
+ const gluedEnd = forwardFinder(text, /[\s;&,}\]]/);
80
+ const lineEnd = forwardFinder(text, /[\r\n]/);
81
+ const closers = new Map([['"', unescapedQuoteFinder(text, /"/)], ["'", unescapedQuoteFinder(text, /'/)]]);
82
+ return (start) => {
83
+ const whitespace = runEnd(start);
84
+ const closer = closers.get(text[start] ?? '');
85
+ if (!closer)
86
+ return { end: whitespace, closingQuote: -1, quoted: false };
87
+ const closing = closer(start + 1);
88
+ const line = lineEnd(start);
89
+ return closing < text.length
90
+ ? { end: quotedValueEnd({ text, closing, gluedEnd: gluedEnd(closing + 1) }), closingQuote: closing, quoted: true }
91
+ : { end: line, closingQuote: -1, quoted: true };
92
+ };
93
+ }
94
+ /** `forwardFinder` for a quote that skips backslash-escaped ones: an odd run of backslashes before a
95
+ * quote escapes it (`\\"` is an escaped backslash, then a real quote). Same non-decreasing `from` rule.
96
+ * @complexity O(n) over all calls: each quote's backslash run is counted once. */
97
+ function unescapedQuoteFinder(text, quote) {
98
+ const next = forwardFinder(text, quote);
99
+ let found = -1;
100
+ return (from) => {
101
+ if (from > found) {
102
+ found = next(from);
103
+ while (found < text.length && isBackslashEscaped(text, found))
104
+ found = next(found + 1);
105
+ }
106
+ return found;
107
+ };
108
+ }
109
+ /** True when an odd run of backslashes ends right before `index`. */
110
+ function isBackslashEscaped(text, index) {
111
+ let backslashes = 0;
112
+ while (text[index - 1 - backslashes] === '\\')
113
+ backslashes++;
114
+ return backslashes % 2 === 1;
115
+ }
116
+ /** `find(from)`: the first index at or after `from` matching `pattern`, or `text.length`. `from` must
117
+ * not decrease between calls: one search answers every later `from` up to its result, since nothing
118
+ * matched between the earlier `from` and that result.
119
+ * @complexity O(n) over all calls for n chars. */
120
+ function forwardFinder(text, pattern) {
121
+ const regex = new RegExp(pattern.source, 'g');
122
+ let found = -1;
123
+ return (from) => {
124
+ if (from > found) {
125
+ regex.lastIndex = from;
126
+ found = regex.exec(text)?.index ?? text.length;
127
+ }
128
+ return found;
129
+ };
130
+ }
131
+ /** Quoted empty credential hints must not borrow the next field's key as their value. */
132
+ export function emptyAssignmentRanges(text) {
133
+ const starts = new Set();
134
+ for (const match of text.matchAll(new RegExp(QUOTED_SECRET_VALUE, 'g'))) {
135
+ if (!EMPTY_QUOTED_ASSIGNMENT_RE.test(match[0].slice(1, -1)))
136
+ continue;
137
+ // Only credential-label starts inside this quoted hint need skipping; no per-character index.
138
+ const labels = new RegExp(MASK_AWARE_LABELED_SECRET_RE.source, 'gi');
139
+ for (const label of match[0].matchAll(labels))
140
+ starts.add(match.index + label.index);
141
+ }
142
+ return starts;
143
+ }
144
+ /** Preserve the hint's quotes and neighboring fields; O(n) scan, no I/O. */
145
+ export function collectEmptyQuotedAssignments(pass) {
146
+ for (const match of pass.text.matchAll(new RegExp(QUOTED_SECRET_VALUE, 'g'))) {
147
+ if (EMPTY_QUOTED_ASSIGNMENT_RE.test(match[0].slice(1, -1))) {
148
+ pass.add(match.index + 1, match.index + match[0].length - 1, CATEGORY.labeledSecret);
149
+ }
150
+ }
151
+ }
152
+ /** Standalone diagnostic punctuation stays readable; punctuation glued to credential text is masked. */
153
+ function quotedValueEnd({ text, closing, gluedEnd }, _options = {}) {
154
+ return /^[.!)]*$/.test(text.slice(closing + 1, gluedEnd)) ? closing + 1 : gluedEnd;
155
+ }
156
+ //# sourceMappingURL=redaction-labels.js.map
@@ -0,0 +1,54 @@
1
+ export interface SecretRedactionPattern {
2
+ name: string;
3
+ regex: RegExp;
4
+ }
5
+ export declare const PATTERNS: readonly SecretRedactionPattern[];
6
+ export declare const CATEGORY: {
7
+ readonly exactSecret: "exact_secret";
8
+ readonly credential: "credential";
9
+ readonly urlCredentials: "url_credentials";
10
+ readonly signedQuery: "signed_query";
11
+ readonly apiKeyHeader: "api_key_header";
12
+ readonly apiKeyQuery: "api_key_query";
13
+ readonly bearerToken: "bearer_token";
14
+ readonly labeledSecret: "labeled_secret";
15
+ readonly urlSecretParam: "url_secret_param";
16
+ readonly opaqueToken: "opaque_token";
17
+ readonly creditCard: "credit_card";
18
+ };
19
+ export declare const GENERATED_MARKER: string;
20
+ /** Every marker redact can generate from its built-in categories; consumers normalize only these. */
21
+ export declare const GENERATED_MARKER_RE: RegExp;
22
+ export declare const CARD_CANDIDATE: RegExp;
23
+ export declare const QUOTED_SECRET_VALUE: string;
24
+ export declare const API_KEY_HEADER: RegExp;
25
+ export declare const API_KEY_QUERY: RegExp;
26
+ /** Optional caller-owned secrets and named lexical rules, without ambient credential lookup. */
27
+ export interface SecretRedactionOptions {
28
+ /** Diagnostic text can retain addresses/numbers while using the same credential rules. Default true. */
29
+ redactPii?: boolean;
30
+ /** Exact trusted registration IDs; credential patterns always take precedence. */
31
+ diagnosticToolIds?: readonly string[];
32
+ /** Conservative by default; aggressive masks opaque runs; exact-only replaces only supplied secrets. */
33
+ policy?: 'conservative' | 'aggressive' | 'exact-only';
34
+ /** Literal replacement under exact-only. Defaults to '[REDACTED:exact_secret]'; ignored otherwise. */
35
+ marker?: string;
36
+ exactSecrets?: ReadonlyArray<string | undefined | null>;
37
+ extraPatterns?: readonly SecretRedactionPattern[];
38
+ }
39
+ export declare const EMPTY_QUOTED_ASSIGNMENT_RE: RegExp;
40
+ export declare const LABELED_SECRET_RE: RegExp;
41
+ export declare const OPAQUE_TOKEN_RE: RegExp;
42
+ export declare const NON_SECRET_TOKEN_RE: RegExp;
43
+ export declare const MASK_AWARE_LABELED_SECRET_RE: RegExp;
44
+ export declare const CHAINED_LABEL_RE: RegExp;
45
+ export declare const SHORT_BEARER_RE: RegExp;
46
+ export declare const BASIC_AUTH_RE: RegExp;
47
+ export declare const COOKIE_HEADER_RE: RegExp;
48
+ export declare const PROVIDER_API_KEY_QUERY: RegExp;
49
+ export declare const URL_CREDENTIALS_RE: RegExp;
50
+ export declare const SIGNED_QUERY_RE: RegExp;
51
+ export declare const URL_SECRET_PARAM_RE: RegExp;
52
+ export declare const LABELED_URL_PARAM_NAME_RE: RegExp;
53
+ export declare function isMaskedValue(value: string): boolean;
54
+ //# sourceMappingURL=redaction-patterns.d.ts.map