@stll/anonymize 2.9.0 → 2.9.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.
@@ -110,7 +110,8 @@ const sanitizeFeedbackText = (input) => {
110
110
  try {
111
111
  url = new URL(core);
112
112
  } catch {
113
- return match;
113
+ bump();
114
+ return `${REDACTED_URL}${trailing}`;
114
115
  }
115
116
  if (isPreservedPublicUrl(url)) return match;
116
117
  bump();
@@ -1 +1 @@
1
- {"version":3,"file":"feedback-sanitize.mjs","names":[],"sources":["../src/feedback-sanitize.ts"],"sourcesContent":["/**\n * Deterministic, regex-based redaction for agent-authored feedback text.\n *\n * Both agent surfaces (`@stll/anonymize-cli`, `@stll/anonymize-mcp`) can file a\n * bug or gap via feedback. The free-text title/body can accidentally carry a\n * client email, an id, an auth token, or an internal URL. This module strips the\n * obvious shapes before the text is ever shown to a human or placed into a\n * prefilled GitHub issue URL. It is a coarse safety net, not a guarantee: the\n * real control is human approval (nothing is published until the human opens and\n * submits the prefilled issue) and the fact that this surface never sends over\n * the network. The heavy WASM anonymization pipeline is deliberately not run\n * here: feedback is short free text, and regex plus human approval is the\n * accepted baseline (it also keeps this module runtime-free).\n *\n * Pass order is load-bearing: JWT/secret shapes run before URL so a secret in a\n * query string of a preserved public URL is still redacted while the URL is kept.\n */\n\nconst REDACTED_EMAIL = \"[redacted-email]\";\nconst REDACTED_ID = \"[redacted-id]\";\nconst REDACTED_SECRET = \"[redacted-secret]\";\nconst REDACTED_URL = \"[redacted-url]\";\nconst REDACTED_IP = \"[redacted-ip]\";\n\nconst hasNoPrivateUrlParts = (url: URL): boolean =>\n url.username === \"\" &&\n url.password === \"\" &&\n url.search === \"\" &&\n url.hash === \"\";\n\n/**\n * The only URL preserved verbatim is the project's own public GitHub repo, so a\n * feedback body can reference an existing issue or file without being redacted.\n * Everything else (including other hosts) is stripped.\n */\nconst isPreservedPublicUrl = (url: URL): boolean => {\n if (!hasNoPrivateUrlParts(url)) {\n return false;\n }\n if (url.hostname.toLowerCase() !== \"github.com\") {\n return false;\n }\n return (\n url.pathname === \"/stella/anonymize\" ||\n url.pathname.startsWith(\"/stella/anonymize/\")\n );\n};\n\n// Three dot-separated base64url segments, each long enough to be a real token\n// (>= 10 chars), so version strings (\"1.2.3\") and IPv4 literals never match.\nconst JWT_REGEX =\n /\\b[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\b/gu;\n\n// Long hex blob (>= 32 chars): API keys, hashes, un-hyphenated ids.\nconst HEX_SECRET_REGEX = /\\b[0-9a-fA-F]{32,}\\b/gu;\n\n// Long base64url blob (>= 40 chars): opaque access tokens, secrets. The\n// base64url alphabet (no `+` or `/`) is used on purpose: including `/` would let\n// this pass swallow whole URL path segments, and modern tokens (GitHub PATs, JWT\n// parts, most API keys) are base64url anyway. A hex secret is caught by\n// HEX_SECRET_REGEX above.\nconst BASE64_SECRET_REGEX = /\\b[A-Za-z0-9_-]{40,}={0,2}/gu;\n\n// Absolute http(s) URL. Parentheses/brackets are valid path characters and are\n// intentionally included; unmatched closing wrappers and sentence punctuation\n// are trimmed in the replacer.\nconst URL_REGEX = /\\bhttps?:\\/\\/[^\\s<>\"'`]+/giu;\nconst URL_TRAILING_PUNCTUATION_REGEX = /[.,;:!?]+$/u;\n\nconst EMAIL_REGEX = /\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}\\b/gu;\n\nconst UUID_REGEX =\n /\\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\\b/gu;\n\nconst IPV4_REGEX = /\\b\\d{1,3}(?:\\.\\d{1,3}){3}\\b/gu;\n\n// Full-form and mid/tail-compressed IPv6. Fully leading-compressed forms\n// (\"::1\") are intentionally out of scope: requiring at least one leading hex\n// group keeps code tokens like `std::vector` from being misread as an address.\nconst IPV6_REGEX =\n /\\b(?:[0-9a-fA-F]{1,4}:){2,7}[0-9a-fA-F]{1,4}\\b|\\b(?:[0-9a-fA-F]{1,4}:){1,6}:(?:[0-9a-fA-F]{1,4}:){0,5}[0-9a-fA-F]{1,4}\\b/gu;\n\nexport type SanitizeFeedbackResult = { text: string; redactions: number };\n\nconst trimTrailingUrlPunctuation = (\n match: string,\n): { core: string; trailing: string } => {\n let core = match;\n let trailing = \"\";\n\n const sentencePunctuation =\n URL_TRAILING_PUNCTUATION_REGEX.exec(core)?.[0] ?? \"\";\n if (sentencePunctuation.length > 0) {\n core = core.slice(0, -sentencePunctuation.length);\n trailing = sentencePunctuation;\n }\n\n const pairs = [\n { open: \"(\", close: \")\" },\n { open: \"[\", close: \"]\" },\n { open: \"{\", close: \"}\" },\n ] as const;\n let changed = true;\n while (changed) {\n changed = false;\n for (const { close, open } of pairs) {\n if (!core.endsWith(close)) {\n continue;\n }\n const opens = Array.from(core).filter((char) => char === open).length;\n const closes = Array.from(core).filter((char) => char === close).length;\n if (closes <= opens) {\n continue;\n }\n core = core.slice(0, -close.length);\n trailing = `${close}${trailing}`;\n changed = true;\n }\n }\n\n return { core, trailing };\n};\n\n/**\n * Redact the well-known sensitive shapes from one feedback field. Returns the\n * cleaned text and the number of substitutions made (surfaced to the human so\n * they can judge how much was stripped). Each pass replaces with a bracketed\n * placeholder, so a downstream pass never re-matches an earlier placeholder.\n */\nexport const sanitizeFeedbackText = (input: string): SanitizeFeedbackResult => {\n let redactions = 0;\n const bump = (): void => {\n redactions += 1;\n };\n\n let text = input;\n\n text = text.replace(JWT_REGEX, () => {\n bump();\n return REDACTED_SECRET;\n });\n text = text.replace(HEX_SECRET_REGEX, () => {\n bump();\n return REDACTED_SECRET;\n });\n text = text.replace(BASE64_SECRET_REGEX, () => {\n bump();\n return REDACTED_SECRET;\n });\n text = text.replace(URL_REGEX, (match) => {\n const { core, trailing } = trimTrailingUrlPunctuation(match);\n let url: URL;\n try {\n url = new URL(core);\n } catch {\n // Not a parseable URL; leave it untouched rather than guess.\n return match;\n }\n if (isPreservedPublicUrl(url)) {\n return match;\n }\n bump();\n return `${REDACTED_URL}${trailing}`;\n });\n text = text.replace(EMAIL_REGEX, () => {\n bump();\n return REDACTED_EMAIL;\n });\n text = text.replace(UUID_REGEX, () => {\n bump();\n return REDACTED_ID;\n });\n text = text.replace(IPV4_REGEX, () => {\n bump();\n return REDACTED_IP;\n });\n text = text.replace(IPV6_REGEX, () => {\n bump();\n return REDACTED_IP;\n });\n\n return { text, redactions };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAM,iBAAiB;AACvB,MAAM,cAAc;AACpB,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,cAAc;AAEpB,MAAM,wBAAwB,QAC5B,IAAI,aAAa,MACjB,IAAI,aAAa,MACjB,IAAI,WAAW,MACf,IAAI,SAAS;;;;;;AAOf,MAAM,wBAAwB,QAAsB;CAClD,IAAI,CAAC,qBAAqB,GAAG,GAC3B,OAAO;CAET,IAAI,IAAI,SAAS,YAAY,MAAM,cACjC,OAAO;CAET,OACE,IAAI,aAAa,uBACjB,IAAI,SAAS,WAAW,oBAAoB;AAEhD;AAIA,MAAM,YACJ;AAGF,MAAM,mBAAmB;AAOzB,MAAM,sBAAsB;AAK5B,MAAM,YAAY;AAClB,MAAM,iCAAiC;AAEvC,MAAM,cAAc;AAEpB,MAAM,aACJ;AAEF,MAAM,aAAa;AAKnB,MAAM,aACJ;AAIF,MAAM,8BACJ,UACuC;CACvC,IAAI,OAAO;CACX,IAAI,WAAW;CAEf,MAAM,sBACJ,+BAA+B,KAAK,IAAI,CAAC,GAAG,MAAM;CACpD,IAAI,oBAAoB,SAAS,GAAG;EAClC,OAAO,KAAK,MAAM,GAAG,CAAC,oBAAoB,MAAM;EAChD,WAAW;CACb;CAEA,MAAM,QAAQ;EACZ;GAAE,MAAM;GAAK,OAAO;EAAI;EACxB;GAAE,MAAM;GAAK,OAAO;EAAI;EACxB;GAAE,MAAM;G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O,KAAK,QAAQ,kBAAkB;EACpC,KAAK;EACL,OAAO;CACT,CAAC;CAED,OAAO;EAAE;EAAM;CAAW;AAC5B"}
1
+ {"version":3,"file":"feedback-sanitize.mjs","names":[],"sources":["../src/feedback-sanitize.ts"],"sourcesContent":["/**\n * Deterministic, regex-based redaction for agent-authored feedback text.\n *\n * Both agent surfaces (`@stll/anonymize-cli`, `@stll/anonymize-mcp`) can file a\n * bug or gap via feedback. The free-text title/body can accidentally carry a\n * client email, an id, an auth token, or an internal URL. This module strips the\n * obvious shapes before the text is ever shown to a human or placed into a\n * prefilled GitHub issue URL. It is a coarse safety net, not a guarantee: the\n * real control is human approval (nothing is published until the human opens and\n * submits the prefilled issue) and the fact that this surface never sends over\n * the network. The heavy WASM anonymization pipeline is deliberately not run\n * here: feedback is short free text, and regex plus human approval is the\n * accepted baseline (it also keeps this module runtime-free).\n *\n * Pass order is load-bearing: JWT/secret shapes run before URL so a secret in a\n * query string of a preserved public URL is still redacted while the URL is kept.\n */\n\nconst REDACTED_EMAIL = \"[redacted-email]\";\nconst REDACTED_ID = \"[redacted-id]\";\nconst REDACTED_SECRET = \"[redacted-secret]\";\nconst REDACTED_URL = \"[redacted-url]\";\nconst REDACTED_IP = \"[redacted-ip]\";\n\nconst hasNoPrivateUrlParts = (url: URL): boolean =>\n url.username === \"\" &&\n url.password === \"\" &&\n url.search === \"\" &&\n url.hash === \"\";\n\n/**\n * The only URL preserved verbatim is the project's own public GitHub repo, so a\n * feedback body can reference an existing issue or file without being redacted.\n * Everything else (including other hosts) is stripped.\n */\nconst isPreservedPublicUrl = (url: URL): boolean => {\n if (!hasNoPrivateUrlParts(url)) {\n return false;\n }\n if (url.hostname.toLowerCase() !== \"github.com\") {\n return false;\n }\n return (\n url.pathname === \"/stella/anonymize\" ||\n url.pathname.startsWith(\"/stella/anonymize/\")\n );\n};\n\n// Three dot-separated base64url segments, each long enough to be a real token\n// (>= 10 chars), so version strings (\"1.2.3\") and IPv4 literals never match.\nconst JWT_REGEX =\n /\\b[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\.[A-Za-z0-9_-]{10,}\\b/gu;\n\n// Long hex blob (>= 32 chars): API keys, hashes, un-hyphenated ids.\nconst HEX_SECRET_REGEX = /\\b[0-9a-fA-F]{32,}\\b/gu;\n\n// Long base64url blob (>= 40 chars): opaque access tokens, secrets. The\n// base64url alphabet (no `+` or `/`) is used on purpose: including `/` would let\n// this pass swallow whole URL path segments, and modern tokens (GitHub PATs, JWT\n// parts, most API keys) are base64url anyway. A hex secret is caught by\n// HEX_SECRET_REGEX above.\nconst BASE64_SECRET_REGEX = /\\b[A-Za-z0-9_-]{40,}={0,2}/gu;\n\n// Absolute http(s) URL. Parentheses/brackets are valid path characters and are\n// intentionally included; unmatched closing wrappers and sentence punctuation\n// are trimmed in the replacer.\nconst URL_REGEX = /\\bhttps?:\\/\\/[^\\s<>\"'`]+/giu;\nconst URL_TRAILING_PUNCTUATION_REGEX = /[.,;:!?]+$/u;\n\nconst EMAIL_REGEX = /\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}\\b/gu;\n\nconst UUID_REGEX =\n /\\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\\b/gu;\n\nconst IPV4_REGEX = /\\b\\d{1,3}(?:\\.\\d{1,3}){3}\\b/gu;\n\n// Full-form and mid/tail-compressed IPv6. Fully leading-compressed forms\n// (\"::1\") are intentionally out of scope: requiring at least one leading hex\n// group keeps code tokens like `std::vector` from being misread as an address.\nconst IPV6_REGEX =\n /\\b(?:[0-9a-fA-F]{1,4}:){2,7}[0-9a-fA-F]{1,4}\\b|\\b(?:[0-9a-fA-F]{1,4}:){1,6}:(?:[0-9a-fA-F]{1,4}:){0,5}[0-9a-fA-F]{1,4}\\b/gu;\n\nexport type SanitizeFeedbackResult = { text: string; redactions: number };\n\nconst trimTrailingUrlPunctuation = (\n match: string,\n): { core: string; trailing: string } => {\n let core = match;\n let trailing = \"\";\n\n const sentencePunctuation =\n URL_TRAILING_PUNCTUATION_REGEX.exec(core)?.[0] ?? \"\";\n if (sentencePunctuation.length > 0) {\n core = core.slice(0, -sentencePunctuation.length);\n trailing = sentencePunctuation;\n }\n\n const pairs = [\n { open: \"(\", close: \")\" },\n { open: \"[\", close: \"]\" },\n { open: \"{\", close: \"}\" },\n ] as const;\n let changed = true;\n while (changed) {\n changed = false;\n for (const { close, open } of pairs) {\n if (!core.endsWith(close)) {\n continue;\n }\n const opens = Array.from(core).filter((char) => char === open).length;\n const closes = Array.from(core).filter((char) => char === close).length;\n if (closes <= opens) {\n continue;\n }\n core = core.slice(0, -close.length);\n trailing = `${close}${trailing}`;\n changed = true;\n }\n }\n\n return { core, trailing };\n};\n\n/**\n * Redact the well-known sensitive shapes from one feedback field. Returns the\n * cleaned text and the number of substitutions made (surfaced to the human so\n * they can judge how much was stripped). Each pass replaces with a bracketed\n * placeholder, so a downstream pass never re-matches an earlier placeholder.\n */\nexport const sanitizeFeedbackText = (input: string): SanitizeFeedbackResult => {\n let redactions = 0;\n const bump = (): void => {\n redactions += 1;\n };\n\n let text = input;\n\n text = text.replace(JWT_REGEX, () => {\n bump();\n return REDACTED_SECRET;\n });\n text = text.replace(HEX_SECRET_REGEX, () => {\n bump();\n return REDACTED_SECRET;\n });\n text = text.replace(BASE64_SECRET_REGEX, () => {\n bump();\n return REDACTED_SECRET;\n });\n text = text.replace(URL_REGEX, (match) => {\n const { core, trailing } = trimTrailingUrlPunctuation(match);\n let url: URL;\n try {\n url = new URL(core);\n } catch {\n // Not a parseable URL, so fail closed: the only preserved case is the\n // positively-recognised public repo URL, which needs a successful parse.\n bump();\n return `${REDACTED_URL}${trailing}`;\n }\n if (isPreservedPublicUrl(url)) {\n return match;\n }\n bump();\n return `${REDACTED_URL}${trailing}`;\n });\n text = text.replace(EMAIL_REGEX, () => {\n bump();\n return REDACTED_EMAIL;\n });\n text = text.replace(UUID_REGEX, () => {\n bump();\n return REDACTED_ID;\n });\n text = text.replace(IPV4_REGEX, () => {\n bump();\n return REDACTED_IP;\n });\n text = text.replace(IPV6_REGEX, () => {\n bump();\n return REDACTED_IP;\n });\n\n return { text, redactions };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAM,iBAAiB;AACvB,MAAM,cAAc;AACpB,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,cAAc;AAEpB,MAAM,wBAAwB,QAC5B,IAAI,aAAa,MACjB,IAAI,aAAa,MACjB,IAAI,WAAW,MACf,IAAI,SAAS;;;;;;AAOf,MAAM,wBAAwB,QAAsB;CAClD,IAAI,CAAC,qBAAqB,GAAG,GAC3B,OAAO;CAET,IAAI,IAAI,SAAS,YAAY,MAAM,cACjC,OAAO;CAET,OACE,IAAI,aAAa,uBACjB,IAAI,SAAS,WAAW,oBAAoB;AAEhD;AAIA,MAAM,YACJ;AAGF,MAAM,mBAAmB;AAOzB,MAAM,sBAAsB;AAK5B,MAAM,YAAY;AAClB,MAAM,iCAAiC;AAEvC,MAAM,cAAc;AAEpB,MAAM,aACJ;AAEF,MAAM,aAAa;AAKnB,MAAM,aACJ;AAIF,MAAM,8BACJ,UACuC;CACvC,IAAI,OAAO;CACX,IAAI,WAAW;CAEf,MAAM,sBACJ,+BAA+B,KAAK,IAAI,CAAC,GAAG,MAAM;CACpD,IAAI,oBAAoB,SAAS,GAAG;EAClC,OAAO,KAAK,MAAM,GAAG,CAAC,oBAAoB,MAAM;EAChD,WAAW;CACb;CAEA,MAAM,QAAQ;EACZ;GAAE,MAAM;GAAK,OAAO;EAAI;EACxB;GAAE,MAAM;GAAK,OAAO;EAAI;EACxB;GAAE,MAAM;GAAK,OAAO;EAAI;CAC1B;CACA,IAAI,UAAU;CACd,OAAO,SAAS;EACd,UAAU;EACV,KAAK,MAAM,EAAE,OAAO,UAAU,OAAO;GACnC,IAAI,CAAC,KAAK,SAAS,KAAK,GACt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Key = (languages) => {
59
59
  //#region src/pipeline-cache-key.ts
60
60
  const DEFAULT_CUSTOM_REGEX_SCORE = .9;
61
61
  const contentLanguageFingerprint = (config) => {
62
- return languageSelectionKey(config.languages ?? (config.language === void 0 ? [] : [config.language]));
62
+ const languages = config.languages ?? (config.language === void 0 ? [] : [config.language]);
63
+ return languageSelectionKey(languages);
63
64
  };
64
65
  const pipelineConfigKey = (config, gazetteerEntries) => {
65
66
  const legalFormsEnabled = isLegalFormsEnabled(config);
@@ -169,14 +170,15 @@ const prepareNativePipelinePackage = async ({ binding, config, gazetteerEntries
169
170
  return new Uint8Array(packageBytes);
170
171
  };
171
172
  const createNativePipelineFromConfig = async ({ binding, config, gazetteerEntries = [], context }) => {
173
+ const packageBytes = await getCachedNativePipelinePackage({
174
+ binding,
175
+ config,
176
+ gazetteerEntries,
177
+ ...context ? { context } : {}
178
+ });
172
179
  return createNativePipelineFromPackage({
173
180
  binding,
174
- packageBytes: await getCachedNativePipelinePackage({
175
- binding,
176
- config,
177
- gazetteerEntries,
178
- ...context ? { context } : {}
179
- })
181
+ packageBytes
180
182
  });
181
183
  };
182
184
  const getCachedNativePipelinePackage = async ({ binding, config, gazetteerEntries = [], context, compressed = false }) => {
@@ -435,10 +437,11 @@ const convert_external_detection_batch = (document, batch, options = {}) => conv
435
437
  batch
436
438
  });
437
439
  const normalize_for_search = (text, options = {}) => {
438
- return normalize_for_search$1({
440
+ const args = {
439
441
  binding: resolveNativeSdkBinding(options),
440
442
  text
441
- });
443
+ };
444
+ return normalize_for_search$1(args);
442
445
  };
443
446
  const prepare_search_package = (config, { compressed = false, ...options } = {}) => prepare_search_package$1({
444
447
  binding: resolveNativeSdkBinding(options),
@@ -675,10 +678,12 @@ const defaultNativePipelinePackageUrl = (language) => {
675
678
  const defaultNativePipelineLanguagePackageUrl = (language) => new URL(`../native-pipeline.${language}.stlanonpkg`, import.meta.url);
676
679
  const resolveDefaultNativePipelineLanguage = (language) => {
677
680
  const normalized = normalizeDefaultNativePipelineLanguage(language);
678
- if (existsSync(defaultNativePipelineLanguagePackageUrl(normalized))) return normalized;
681
+ const exactUrl = defaultNativePipelineLanguagePackageUrl(normalized);
682
+ if (existsSync(exactUrl)) return normalized;
679
683
  const baseLanguage = normalized.split("-").at(0);
680
684
  if (baseLanguage === void 0 || baseLanguage === normalized) return normalized;
681
- if (existsSync(defaultNativePipelineLanguagePackageUrl(baseLanguage))) return baseLanguage;
685
+ const baseUrl = defaultNativePipelineLanguagePackageUrl(baseLanguage);
686
+ if (existsSync(baseUrl)) return baseLanguage;
682
687
  return normalized;
683
688
  };
684
689
  const defaultNativePipelinePackageDescription = (language) => language === void 0 ? "Default native pipeline package" : `Default native pipeline package for language "${resolveDefaultNativePipelineLanguage(language)}"`;
@@ -1 +1 @@
1
- {"version":3,"file":"native-node2.mjs","names":["languageScopes","loadDefaultPlatformNativePackage","nativePackageVersionWithBinding","convertExternalDetectionBatchWithBinding","normalizeForSearchWithBinding","prepareSearchPackageWithBinding","loadPreparedPackageWithBinding","redactTextWithBinding","redactTextJsonWithBinding","redactTextStreamJsonWithBinding","diagnosticsJsonWithBinding","diagnosticsStreamJsonWithBinding","summaryDiagnosticsJsonWithBinding"],"sources":["../src/bun-version.ts","../src/context.ts","../src/types.ts","../src/util/language-selection.ts","../src/pipeline-cache-key.ts","../src/native-pipeline.ts","../src/native-default-config.ts","../src/pipeline-language.ts","../src/create-pipeline.ts","../src/native-node.ts"],"sourcesContent":["const MINIMUM_BUN_MAJOR = 1;\nconst MINIMUM_BUN_MINOR = 4;\nconst BUN_VERSION_PATTERN =\n /^(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)(?:-(?<prerelease>[0-9A-Za-z.-]+))?(?:\\+[0-9A-Za-z.-]+)?$/u;\n\nexport const MINIMUM_SUPPORTED_BUN_VERSION = \"1.4.0\";\n\nexport const assertSupportedBunVersion = (bunVersion?: string): void => {\n if (bunVersion === undefined) {\n return;\n }\n\n const match = BUN_VERSION_PATTERN.exec(bunVersion);\n const { major, minor, patch, prerelease } = match?.groups ?? {};\n if (major === undefined || minor === undefined || patch === undefined) {\n throw unsupportedBunVersionError(bunVersion);\n }\n\n const majorNumber = Number(major);\n const minorNumber = Number(minor);\n const patchNumber = Number(patch);\n if (\n !Number.isSafeInteger(majorNumber) ||\n !Number.isSafeInteger(minorNumber) ||\n !Number.isSafeInteger(patchNumber)\n ) {\n throw unsupportedBunVersionError(bunVersion);\n }\n\n const coreVersionIsNewer =\n majorNumber > MINIMUM_BUN_MAJOR ||\n (majorNumber === MINIMUM_BUN_MAJOR &&\n (minorNumber > MINIMUM_BUN_MINOR ||\n (minorNumber === MINIMUM_BUN_MINOR && patchNumber > 0)));\n const minimumReleaseIsSupported =\n majorNumber === MINIMUM_BUN_MAJOR &&\n minorNumber === MINIMUM_BUN_MINOR &&\n patchNumber === 0 &&\n prerelease === undefined;\n if (!coreVersionIsNewer && !minimumReleaseIsSupported) {\n throw unsupportedBunVersionError(bunVersion);\n }\n};\n\nexport const assertSupportedBunRuntime = (): void => {\n const runtime: unknown = globalThis;\n if (!hasBunRuntime(runtime)) {\n return;\n }\n const bun = runtime.Bun;\n if (\n typeof bun !== \"object\" ||\n bun === null ||\n !(\"version\" in bun) ||\n typeof bun.version !== \"string\"\n ) {\n throw unsupportedBunVersionError(\"unknown\");\n }\n assertSupportedBunVersion(bun.version);\n};\n\nconst hasBunRuntime = (runtime: unknown): runtime is { Bun: unknown } =>\n typeof runtime === \"object\" && runtime !== null && \"Bun\" in runtime;\n\nconst unsupportedBunVersionError = (bunVersion: string): Error =>\n new Error(\n `Bun ${bunVersion} is unsupported; @stll/anonymize requires Bun >=${MINIMUM_SUPPORTED_BUN_VERSION}. Upgrade Bun before loading the native SDK.`,\n );\n","/**\n * Cached state for a single pipeline run (or a sequence of runs sharing the\n * same config). The native pipeline builds its prepared package once and reuses\n * it across calls with the same config; the package bytes and the key/promise\n * that guard concurrent builds live here so callers can share one warmed\n * context.\n */\nexport type PipelineContext = {\n // ── Native prepared-package cache ─────────────\n nativePipelinePackage: Uint8Array | null;\n nativePipelinePackageKey: string;\n nativePipelinePackagePromise: Promise<Uint8Array> | null;\n};\n\n/** Create a fresh, empty pipeline context. */\nexport const createPipelineContext = (): PipelineContext => ({\n nativePipelinePackage: null,\n nativePipelinePackageKey: \"\",\n nativePipelinePackagePromise: null,\n});\n\n/**\n * Module-level default context. Used when callers\n * don't provide an explicit context, preserving full\n * backward compatibility with the existing API.\n */\nexport const defaultContext: PipelineContext = createPipelineContext();\n","// Runtime-free constants live in `./constants`; re-exported\n// here for back-compat with existing call sites that import\n// from `@stll/anonymize` directly.\n//\n// `verbatimModuleSyntax` requires an explicit type-only\n// import for any name used locally as a type even when it\n// is also re-exported below — applies to `DetectionSource`\n// (used by `Entity`) and `OperatorType` (used by\n// `OperatorConfig`).\nimport type { DetectionSource, OperatorType } from \"./constants\";\nimport { DETECTION_SOURCES } from \"./constants\";\n\nexport {\n DETECTION_SOURCES,\n DETECTOR_PRIORITY,\n type DetectionSource,\n} from \"./constants\";\n\n/**\n * Fields shared by every entity span in the source text.\n */\ntype EntityBase = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n sourceDetail?: \"custom-deny-list\" | \"custom-regex\" | \"gazetteer-extension\";\n};\n\n/**\n * A PII entity span found by a primary detection layer\n * (regex, NER, legal forms, deny list, ...).\n */\nexport type DetectedEntity = EntityBase & {\n source: Exclude<DetectionSource, typeof DETECTION_SOURCES.COREFERENCE>;\n};\n\n/**\n * An alias mention of a previously detected entity: a\n * defined term (\"the Seller\") or a propagated bare\n * mention (\"Acme\" after \"Acme Corp.\").\n *\n * `corefSourceText` is required by construction, so an\n * alias cannot exist without the link back to its source\n * entity. Placeholder numbering reads it to give the\n * alias the same placeholder as the source. The link\n * travels with the entity instead of living in a\n * side-channel map that a producer could forget to\n * write — or that a later pass could clear.\n */\nexport type CorefAliasEntity = EntityBase & {\n source: typeof DETECTION_SOURCES.COREFERENCE;\n /** Full text of the source entity this alias refers to. */\n corefSourceText: string;\n};\n\n/**\n * A detected PII entity span in the source text.\n * Every detection layer produces these.\n */\nexport type Entity = DetectedEntity | CorefAliasEntity;\n\n/**\n * Entity after human review. Extends the base Entity\n * with a review decision.\n */\nexport type ReviewDecision = \"confirmed\" | \"rejected\" | \"relabeled\";\n\nexport type ReviewedEntity = Entity & {\n decision?: ReviewDecision;\n originalLabel?: string;\n};\n\n/**\n * A single entry in the workspace-scoped gazetteer\n * (deny list). Persisted in IndexedDB.\n */\nexport type GazetteerEntry = {\n id: string;\n canonical: string;\n label: string;\n variants: string[];\n workspaceId: string;\n createdAt: number;\n source: \"manual\" | \"confirmed-from-model\";\n};\n\n/** Extraction strategy — closed discriminated union. */\nexport type TriggerStrategy =\n | {\n type: \"to-next-comma\";\n /**\n * Optional list of lowercase keywords that terminate\n * the value scan, in addition to commas/newlines. Useful\n * for triggers like court names that may continue past\n * a missing comma into adjacent clause text (\"Městským\n * soudem v Praze dne 1. 1. 2020\"); listing `\"dne\"` here\n * stops the scan at the date boundary. Matched on a\n * word-boundary, case-insensitive.\n */\n stopWords?: string[];\n /**\n * Hard cap on the captured span length, in characters,\n * regardless of where the next comma / stop char sits.\n * Use for triggers that label short formulaic phrases\n * (\"State of Delaware\") and must not absorb the rest\n * of a long forum-selection clause when the comma is\n * sentences away. Falls back to the default 100-char\n * fallback when omitted.\n */\n maxLength?: number;\n }\n | { type: \"to-end-of-line\" }\n | { type: \"n-words\"; count: number }\n | { type: \"company-id-value\" }\n | { type: \"address\"; maxChars?: number }\n | {\n /**\n * Extract the first regex match in the value text.\n * Useful for shape-bounded values that follow a\n * label on the same line as other fields, where\n * `to-end-of-line` would over-capture. The pattern\n * is anchored to the start of the (already\n * leading-whitespace-stripped) value, so use\n * `(?:.*?)` prefix only when intentional.\n */\n type: \"match-pattern\";\n pattern: string;\n flags?: string;\n };\n\n/** Validation rules — closed discriminated union. */\nexport type TriggerValidation =\n | { type: \"starts-uppercase\" }\n | { type: \"min-length\"; min: number }\n | { type: \"max-length\"; max: number }\n | { type: \"no-digits\" }\n | { type: \"has-digits\" }\n | {\n type: \"matches-pattern\";\n pattern: string;\n flags?: string;\n }\n /**\n * Run a named stdnum validator (checksum + length)\n * against the captured value. Keeps the trigger\n * path symmetrical with the formatted-regex\n * detectors so e.g. `CPF nº 00000000000` does not\n * survive as a tax-ID entity.\n */\n | { type: \"valid-id\"; validator: ValidIdValidator };\n\n/** Built-in stdnum validators that can be referenced\n * by `valid-id` validations. */\nexport type ValidIdValidator = \"br.cpf\" | \"br.cnpj\" | \"us.rtn\";\n\n/** Auto-generated trigger variants — closed set. */\nexport type TriggerExtension =\n | \"add-colon\"\n | \"add-trailing-space\"\n | \"add-colon-space\"\n | \"normalize-spaces\";\n\n/** V2 trigger config entry (JSON shape). */\nexport type TriggerGroupConfig = {\n id?: string;\n triggers: string[];\n label: string;\n strategy: TriggerStrategy;\n extensions?: TriggerExtension[];\n validations?: TriggerValidation[];\n /** When true, include the trigger text in the\n * entity span (e.g., court names). */\n includeTrigger?: boolean;\n};\n\n/** Compiled validation with pre-built regex. */\nexport type CompiledValidation =\n | { type: \"starts-uppercase\"; re: RegExp }\n | { type: \"min-length\"; min: number }\n | { type: \"max-length\"; max: number }\n | { type: \"no-digits\"; re: RegExp }\n | { type: \"has-digits\"; re: RegExp }\n | { type: \"matches-pattern\"; re: RegExp }\n | {\n type: \"valid-id\";\n validator: ValidIdValidator;\n check: (value: string) => boolean;\n };\n\n/**\n * Runtime rule — one per trigger string after\n * expansion. Fed to the Aho-Corasick automaton.\n */\nexport type TriggerRule = {\n trigger: string;\n label: string;\n strategy: TriggerStrategy;\n validations: CompiledValidation[];\n includeTrigger: boolean;\n};\n\nexport {\n ENTITY_CAPABILITIES,\n ENTITY_LABELS,\n ENTITY_SELECTIONS,\n OPERATOR_TYPES,\n type DefaultEntityLabel,\n type EntityCapability,\n type EntityLabel,\n type EntitySelection,\n type OperatorType,\n} from \"./constants\";\n\n/** Per-label operator selection. Key is the entity label. */\nexport type MaskDirection = \"start\" | \"end\";\n\nexport type MaskOperatorConfig = {\n type: \"mask\";\n maskingCharacter: string;\n charactersToMask: number;\n direction: MaskDirection;\n};\n\nexport type OperatorSelection =\n | Exclude<OperatorType, \"mask\">\n | MaskOperatorConfig;\n\nexport type OperatorConfig = {\n /** Operator per label. Missing labels default to \"replace\". */\n operators: Record<string, OperatorSelection>;\n /** Custom replacement string for the redact operator. */\n redactString: string;\n};\n\n/** Whether an operator produces a reversible redaction entry. */\ntype OperatorReversibility = \"reversible\" | \"irreversible\" | \"preserving\";\n\nexport type AnonymisationOperator = {\n type: OperatorType;\n reversibility: OperatorReversibility;\n /**\n * Apply the operator to a single entity occurrence.\n * Returns the replacement string to embed in the document.\n */\n apply: (\n text: string,\n label: string,\n placeholder: string,\n redactString: string,\n selection: OperatorSelection,\n ) => string;\n};\n\n/**\n * Redacted document output with stable entity mapping.\n */\nexport type RedactionResult = {\n redactedText: string;\n /**\n * Maps placeholder to original text. Only populated for\n * reversible operators (replace). Empty for redact, keep, and mask.\n */\n redactionMap: Map<string, string>;\n /** Maps placeholder to the operator that produced it. */\n operatorMap: Map<string, OperatorType>;\n entityCount: number;\n};\n\n/**\n * Configuration for the detection pipeline.\n */\nexport type DenyListCategory =\n | \"Names\"\n | \"Places\"\n | \"Addresses\"\n | \"Courts\"\n | \"Financial\"\n | \"Government\"\n | \"Healthcare\"\n | \"Education\"\n | \"Political\"\n | \"Organizations\"\n | \"International\";\n\n/**\n * Metadata for a single dictionary entry in the\n * deny-list system. Mirrors the shape from\n * the anonymize-data package so consumers can pass\n * pre-loaded data without a runtime dependency.\n */\nexport type DictionaryMeta = {\n label: string;\n category: DenyListCategory;\n country: string | null;\n};\n\n/**\n * Caller-supplied exact terms for deny-list matching.\n * These entries are merged with the published deny-list\n * dictionaries when `enableDenyList` is enabled.\n */\nexport type CustomDenyListEntry = {\n value: string;\n label: string;\n variants?: readonly string[];\n};\n\n/**\n * Caller-supplied regex detector. The pattern is passed\n * to the native Rust regex engine, so use its supported\n * regex syntax. Inline flags such as `(?i)` are accepted\n * when supported by that engine.\n */\nexport type CustomRegexPattern = {\n pattern: string;\n label: string;\n score?: number;\n preparedArtifactPolicy?: \"include\" | \"omit\";\n};\n\n/**\n * Pre-loaded dictionary data for dependency injection.\n * Consumers that want name/city/deny-list detection\n * load dictionaries themselves (e.g. from the\n * anonymize-data package) and pass them here; the\n * anonymize package has zero cross-package imports.\n *\n * All fields are optional. When a field is absent,\n * the corresponding detection path is skipped (same\n * behavior as when no dictionaries are available).\n */\nexport type Dictionaries = {\n /**\n * First names per language code (e.g., \"cs\", \"de\").\n */\n firstNames?: Readonly<Record<string, readonly string[]>>;\n /**\n * Surnames per language code.\n */\n surnames?: Readonly<Record<string, readonly string[]>>;\n /**\n * Non-Western name tokens per locale code\n * (e.g., \"in\", \"ar\", \"ja-latn\", \"ko\", \"zh-latn\",\n * \"th\", \"vi\", \"fil\", \"id\"). Merged with bundled\n * names-nw-*.json data at init time.\n */\n nonWesternNames?: Readonly<Record<string, readonly string[]>>;\n /**\n * Pre-loaded deny-list dictionaries keyed by\n * dictionary ID (e.g., \"courts/CZ\", \"banks/DE\").\n * Each value is the array of terms for that\n * dictionary.\n */\n denyList?: Readonly<Record<string, readonly string[]>>;\n /**\n * Metadata per dictionary ID. Required when\n * `denyList` is provided so the pipeline knows\n * labels, categories, and country filters.\n */\n denyListMeta?: Readonly<Record<string, DictionaryMeta>>;\n /**\n * Pre-loaded city names, already merged across\n * all desired countries.\n *\n * Prefer `citiesByCountry` when callers also pass\n * `denyListCountries` / `denyListRegions`; merged\n * city arrays cannot be scoped after injection.\n */\n cities?: readonly string[];\n /**\n * Pre-loaded city names keyed by ISO 3166-1 alpha-2\n * country code. When provided, the deny-list builder\n * applies `denyListCountries` / `denyListRegions`\n * before adding city patterns to the search automaton.\n */\n citiesByCountry?: Readonly<Record<string, readonly string[]>>;\n};\n\n/**\n * Street-address detection without a known-city anchor.\n */\nexport type StandaloneStreetDetection = \"off\" | \"houseNumberAnchored\";\n\nexport type PipelineConfig = {\n threshold: number;\n enableTriggerPhrases: boolean;\n enableRegex: boolean;\n /**\n * Expected content language codes. When present, these\n * derive default dictionary scopes for name corpus and\n * deny-list matching unless the lower-level scope fields\n * below are set explicitly.\n */\n languages?: string[];\n /**\n * Convenience form for single-language documents. Ignored\n * when `languages` is also provided.\n */\n language?: string;\n /**\n * Enables legal-form organization detection.\n * Required for typed callers; legacy untyped\n * callers that omit this field are treated as\n * enabled at runtime for backward compatibility.\n */\n enableLegalForms: boolean;\n /**\n * Enables first-name/surname/title corpus matching.\n * When deny-list mode is enabled, this also controls\n * whether name-corpus entries are injected into the\n * deny-list search automaton.\n */\n enableNameCorpus: boolean;\n /**\n * Optional language scope for first-name/surname\n * dictionaries, using the keys present in\n * `dictionaries.firstNames` / `dictionaries.surnames`\n * (for example `[\"en\", \"de\"]`). When omitted, all\n * injected name languages are used for backward\n * compatibility.\n */\n nameCorpusLanguages?: string[];\n enableDenyList: boolean;\n denyListCountries?: string[];\n denyListRegions?: string[];\n denyListExcludeCategories?: string[];\n /**\n * Caller-owned exact terms to match through the\n * deny-list layer. Requires `enableDenyList: true`.\n */\n customDenyList?: readonly CustomDenyListEntry[];\n /**\n * Caller-owned regex detectors. Requires\n * `enableRegex: true`.\n */\n customRegexes?: readonly CustomRegexPattern[];\n enableGazetteer: boolean;\n /**\n * Detect country names (ISO 3166-1 names, curated\n * aliases, alpha-3 codes). Defaults to true. Names\n * span all manifest languages plus widely-used\n * additions (Dutch, Russian, Chinese, Arabic, etc.).\n */\n enableCountries?: boolean;\n enableConfidenceBoost: boolean;\n enableCoreference: boolean;\n enableZoneClassification?: boolean;\n enableHotwordRules?: boolean;\n /**\n * Detect a street address that carries no known-city\n * anchor. Defaults to `\"off\"`.\n *\n * `\"houseNumberAnchored\"` accepts a street-type word\n * with a house number directly beside it, in either\n * order (\"14 Rue de la Paix\", \"Hauptstraße 5\",\n * \"123 Main Street\"). A bare street name with no\n * number never fires.\n *\n * A street-type word plus a nearby number is a much\n * weaker signal than a city-anchored address and does\n * fire on contract prose (\"District Court 2019\"), so\n * this stays opt-in per workspace.\n */\n standaloneStreetDetection?: StandaloneStreetDetection;\n /**\n * Requested output labels. An empty array means\n * \"do not filter by label\" for deterministic detectors.\n */\n labels: string[];\n workspaceId: string;\n /**\n * Pre-loaded dictionary data for name, deny-list,\n * and city detection. When omitted, dictionary-based\n * detection paths are skipped. Consumers load from\n * the anonymize-data package and pass the data here.\n */\n dictionaries?: Dictionaries;\n};\n\nexport { DEFAULT_ENTITY_LABELS } from \"./constants\";\n\nexport const isLegalFormsEnabled = (\n config: Pick<PipelineConfig, \"enableLegalForms\">,\n): boolean => config.enableLegalForms !== false;\n","const normalizeLanguageCode = (language: string): string =>\n language.trim().toLowerCase();\n\nconst normalizeLanguageSelection = (\n languages: readonly string[] | undefined,\n): string[] =>\n languages === undefined\n ? []\n : languages\n .map(normalizeLanguageCode)\n .filter((language) => language.length > 0);\n\nexport const languageSelectionKey = (\n languages: readonly string[] | undefined,\n): string => {\n const normalized = normalizeLanguageSelection(languages).toSorted();\n return normalized.length === 0 ? \"*\" : normalized.join(\",\");\n};\n\nconst baseLanguage = (language: string): string => {\n const index = language.indexOf(\"-\");\n return index === -1 ? language : language.slice(0, index);\n};\n\nexport const languageConfigMatches = (\n configLanguage: string,\n selectedLanguages: readonly string[] | undefined,\n): boolean => {\n if (selectedLanguages === undefined || selectedLanguages.length === 0) {\n return true;\n }\n const normalizedSelectedLanguages =\n normalizeLanguageSelection(selectedLanguages);\n if (normalizedSelectedLanguages.length === 0) {\n return true;\n }\n\n const normalizedConfigLanguage = normalizeLanguageCode(configLanguage);\n if (normalizedConfigLanguage.length === 0) {\n return false;\n }\n\n const genericConfig =\n baseLanguage(normalizedConfigLanguage) === normalizedConfigLanguage;\n for (const normalizedLanguage of normalizedSelectedLanguages) {\n if (normalizedLanguage === normalizedConfigLanguage) {\n return true;\n }\n if (\n genericConfig &&\n baseLanguage(normalizedLanguage) === normalizedConfigLanguage\n ) {\n return true;\n }\n }\n\n return false;\n};\n","import {\n isLegalFormsEnabled,\n type GazetteerEntry,\n type PipelineConfig,\n} from \"./types\";\nimport { languageSelectionKey } from \"./util/language-selection\";\n\nconst DEFAULT_CUSTOM_REGEX_SCORE = 0.9;\n\nconst contentLanguageFingerprint = (\n config: Pick<PipelineConfig, \"language\" | \"languages\">,\n): string => {\n const languages =\n config.languages ??\n (config.language === undefined ? [] : [config.language]);\n return languageSelectionKey(languages);\n};\n\nexport const pipelineConfigKey = (\n config: PipelineConfig,\n gazetteerEntries: readonly GazetteerEntry[],\n): string => {\n const legalFormsEnabled = isLegalFormsEnabled(config);\n const customDenyFingerprint =\n config.enableDenyList && config.customDenyList\n ? config.customDenyList\n .map((entry) =>\n JSON.stringify({\n label: entry.label,\n value: entry.value,\n variants: [...(entry.variants ?? [])].sort(),\n }),\n )\n .sort()\n .join(\"\\n\")\n : \"\";\n const customRegexFingerprint =\n config.enableRegex && config.customRegexes\n ? config.customRegexes\n .map((entry) =>\n JSON.stringify({\n label: entry.label,\n pattern: entry.pattern,\n preparedArtifactPolicy: entry.preparedArtifactPolicy ?? null,\n score: entry.score ?? DEFAULT_CUSTOM_REGEX_SCORE,\n }),\n )\n .sort()\n .join(\"\\n\")\n : \"\";\n const gazFingerprint =\n config.enableGazetteer && gazetteerEntries.length > 0\n ? gazetteerEntries\n .map(\n (entry) =>\n `${entry.id}:${entry.canonical}:${entry.label}:${[\n ...entry.variants,\n ]\n .sort()\n .join(\",\")}`,\n )\n .toSorted()\n .join(\";\")\n : \"\";\n\n return (\n `${config.enableDenyList}:` +\n `${config.enableTriggerPhrases}:` +\n `${legalFormsEnabled}:` +\n `${config.enableNameCorpus}:` +\n `${contentLanguageFingerprint(config)}:` +\n `${config.nameCorpusLanguages?.toSorted().join(\",\") ?? \"\"}:` +\n `${config.enableRegex}:` +\n `${config.threshold}:` +\n `${config.enableConfidenceBoost}:` +\n `${config.enableHotwordRules === true}:` +\n `${config.enableCoreference === true}:` +\n `${config.enableZoneClassification === true}:` +\n `${config.labels.toSorted().join(\",\")}:` +\n `${config.denyListCountries?.toSorted().join(\",\") ?? \"\"}:` +\n `${config.denyListRegions?.toSorted().join(\",\") ?? \"\"}:` +\n `${config.denyListExcludeCategories?.toSorted().join(\",\") ?? \"\"}:` +\n `${customDenyFingerprint}:` +\n `${customRegexFingerprint}:` +\n `${config.enableGazetteer}:${gazFingerprint}:` +\n `${config.enableCountries !== false}:` +\n `${config.standaloneStreetDetection ?? \"off\"}`\n );\n};\n","import type { PipelineContext } from \"./context\";\nimport { defaultContext } from \"./context\";\nimport { applyPipelineLanguageScope } from \"./language-scope\";\nimport type { NativePreparedSearchConfig } from \"./native-search-config\";\nimport { pipelineConfigKey } from \"./pipeline-cache-key\";\nimport type { Dictionaries, GazetteerEntry, PipelineConfig } from \"./types\";\nimport {\n createNativePipelineFromPackage,\n PreparedNativePipeline,\n type NativeAnonymizeBinding,\n} from \"./native\";\n\nexport {\n PreparedNativePipeline,\n createNativePipelineFromPackage,\n} from \"./native\";\n\nexport type NativePipelineUnsupportedFeature = \"enableNer\";\n\nexport type NativePipelineCompatibility =\n | { status: \"supported\" }\n | {\n status: \"unsupported\";\n unsupportedFeatures: NativePipelineUnsupportedFeature[];\n };\n\nexport type NativePipelineBuildOptions = {\n binding: NativeAnonymizeBinding;\n config: PipelineConfig;\n gazetteerEntries?: GazetteerEntry[];\n context?: PipelineContext;\n};\n\nexport type NativePipelinePackageOptions = NativePipelineBuildOptions & {\n compressed?: boolean;\n};\n\nexport type { NativePipelineFromPackageOptions } from \"./native\";\n\ntype NativePipelinePackageCacheValue = Promise<Uint8Array> | Uint8Array;\n\n// Bounds each shared package cache (the dictionary-less bucket below, and\n// each per-`Dictionaries` bucket handed out by `sharedPackageCacheFor`) to a\n// fixed number of entries. `nativePackageCacheKey` fingerprints\n// caller-suppliable config (custom deny lists, custom regexes, gazetteer\n// entries) via `pipelineConfigKey`, so without a cap a caller that varies\n// those fields grows a bucket — and the multi-MB assembled packages it\n// holds — without limit.\nexport const SHARED_PACKAGE_CACHE_MAX_ENTRIES = 32;\n\nconst sharedPackageByDictionaries = new WeakMap<\n Dictionaries,\n Map<string, NativePipelinePackageCacheValue>\n>();\nconst sharedPackageWithoutDictionaries = new Map<\n string,\n NativePipelinePackageCacheValue\n>();\nconst dictionaryCacheIds = new WeakMap<Dictionaries, number>();\nlet nextDictionaryCacheId = 0;\n\n/** Record `key` as most-recently-used in `cache`, evicting the\n * least-recently-used entry first once the cache is at capacity. A `Map`'s\n * insertion order doubles as recency order here: touching an existing key\n * deletes then re-sets it to move it to the end, and eviction drops the\n * first (oldest) key.\n *\n * Evicting a still-in-flight build only drops the cache's reference to its\n * promise; the caller that started the build (and any concurrent caller that\n * already read the promise before eviction) still resolves it correctly via\n * the guarded `sharedCache.get(key) === promise` checks in\n * `getCachedNativePipelinePackage`. A later caller for the same key just\n * misses the dedupe and starts a fresh build — bounded memory takes priority\n * over perfect dedupe under cache pressure. */\nconst touchSharedPackageCacheEntry = (\n cache: Map<string, NativePipelinePackageCacheValue>,\n key: string,\n value: NativePipelinePackageCacheValue,\n): void => {\n cache.delete(key);\n if (cache.size >= SHARED_PACKAGE_CACHE_MAX_ENTRIES) {\n const oldestKey = cache.keys().next().value;\n if (oldestKey !== undefined) {\n cache.delete(oldestKey);\n }\n }\n cache.set(key, value);\n};\n\nconst dictionaryCacheKey = (dictionaries: Dictionaries | undefined): string => {\n if (dictionaries === undefined) {\n return \"none\";\n }\n const existing = dictionaryCacheIds.get(dictionaries);\n if (existing !== undefined) {\n return `dict:${existing}`;\n }\n nextDictionaryCacheId += 1;\n dictionaryCacheIds.set(dictionaries, nextDictionaryCacheId);\n return `dict:${nextDictionaryCacheId}`;\n};\n\nconst sharedPackageCacheFor = (\n dictionaries: Dictionaries | undefined,\n): Map<string, NativePipelinePackageCacheValue> => {\n if (dictionaries === undefined) {\n return sharedPackageWithoutDictionaries;\n }\n const cached = sharedPackageByDictionaries.get(dictionaries);\n if (cached !== undefined) {\n return cached;\n }\n const created = new Map<string, NativePipelinePackageCacheValue>();\n sharedPackageByDictionaries.set(dictionaries, created);\n return created;\n};\n\nexport const getNativePipelineCompatibility = (\n config: PipelineConfig,\n): NativePipelineCompatibility => {\n const unsupportedFeatures: NativePipelineUnsupportedFeature[] = [];\n\n // `enableNer` is no longer part of `PipelineConfig`; untyped callers that\n // still request it (any truthy value, e.g. `1` or `\"true\"` from loose\n // JSON) must fail fast instead of silently losing NER spans.\n if (\"enableNer\" in config && Boolean(config.enableNer)) {\n unsupportedFeatures.push(\"enableNer\");\n }\n if (unsupportedFeatures.length === 0) {\n return { status: \"supported\" };\n }\n return { status: \"unsupported\", unsupportedFeatures };\n};\n\nexport const assertNativePipelineSupported = (config: PipelineConfig): void => {\n const compatibility = getNativePipelineCompatibility(config);\n if (compatibility.status === \"supported\") {\n return;\n }\n throw new Error(\n `Native pipeline does not yet support: ${compatibility.unsupportedFeatures.join(\", \")}`,\n );\n};\n\nconst encoder = new TextEncoder();\n\ntype AssembleInputs = {\n pipelineConfigJson: Uint8Array;\n dictionariesJson: Uint8Array | undefined;\n gazetteerJson: Uint8Array | undefined;\n};\n\n/**\n * Serialize the assembler inputs the Rust binding expects. Dictionaries are\n * stripped from the pipeline config and passed out of band: the assembler reads\n * the separate bundle preferentially, and keeping the (large) dictionaries out\n * of the config JSON avoids serializing them twice.\n */\nconst toAssembleInputs = (\n { dictionaries, ...config }: PipelineConfig,\n gazetteerEntries: readonly GazetteerEntry[],\n): AssembleInputs => ({\n pipelineConfigJson: encoder.encode(JSON.stringify(config)),\n dictionariesJson:\n dictionaries === undefined\n ? undefined\n : encoder.encode(JSON.stringify(dictionaries)),\n gazetteerJson:\n gazetteerEntries.length === 0\n ? undefined\n : encoder.encode(JSON.stringify(gazetteerEntries)),\n});\n\nconst assemblePackageBytes = (\n binding: NativeAnonymizeBinding,\n { pipelineConfigJson, dictionariesJson, gazetteerJson }: AssembleInputs,\n compressed: boolean,\n): Uint8Array => {\n const assemble = compressed\n ? binding.assembleStaticSearchCompressedPackageBytes\n : binding.assembleStaticSearchPackageBytes;\n if (assemble === undefined) {\n throw new Error(\n \"Native anonymize binding does not support static-search config assembly\",\n );\n }\n return assemble(pipelineConfigJson, dictionariesJson, gazetteerJson);\n};\n\nexport const prepareNativePipelineConfig = async ({\n binding,\n config,\n gazetteerEntries = [],\n}: Omit<\n NativePipelineBuildOptions,\n \"context\"\n>): Promise<NativePreparedSearchConfig> => {\n const scopedConfig = applyPipelineLanguageScope(config);\n assertNativePipelineSupported(scopedConfig);\n const assemble = binding.assembleStaticSearchConfigJson;\n if (assemble === undefined) {\n throw new Error(\n \"Native anonymize binding does not support static-search config assembly\",\n );\n }\n const { pipelineConfigJson, dictionariesJson, gazetteerJson } =\n toAssembleInputs(scopedConfig, gazetteerEntries);\n const configJson = assemble(\n pipelineConfigJson,\n dictionariesJson,\n gazetteerJson,\n );\n return JSON.parse(new TextDecoder().decode(configJson));\n};\n\nexport const prepareNativePipelinePackage = async ({\n binding,\n config,\n gazetteerEntries = [],\n context,\n compressed = false,\n}: NativePipelinePackageOptions): Promise<Uint8Array> => {\n const packageBytes = await getCachedNativePipelinePackage({\n config,\n binding,\n gazetteerEntries,\n ...(context ? { context } : {}),\n compressed,\n });\n // Return a genuine copy: with the real NAPI binding packageBytes is a Node\n // Buffer, and Buffer.prototype.slice() yields a memory-sharing view, so a\n // caller mutating it would corrupt the shared cache and ctx.nativePipelinePackage.\n return new Uint8Array(packageBytes);\n};\n\nexport const createNativePipelineFromConfig = async ({\n binding,\n config,\n gazetteerEntries = [],\n context,\n}: NativePipelineBuildOptions): Promise<PreparedNativePipeline> => {\n const packageBytes = await getCachedNativePipelinePackage({\n binding,\n config,\n gazetteerEntries,\n ...(context ? { context } : {}),\n });\n return createNativePipelineFromPackage({ binding, packageBytes });\n};\n\nconst getCachedNativePipelinePackage = async ({\n binding,\n config,\n gazetteerEntries = [],\n context,\n compressed = false,\n}: NativePipelinePackageOptions): Promise<Uint8Array> => {\n const scopedConfig = applyPipelineLanguageScope(config);\n assertNativePipelineSupported(scopedConfig);\n const ctx = context ?? defaultContext;\n const key = nativePackageCacheKey({\n binding,\n config: scopedConfig,\n gazetteerEntries,\n compressed,\n });\n if (ctx.nativePipelinePackage && ctx.nativePipelinePackageKey === key) {\n return ctx.nativePipelinePackage;\n }\n if (\n ctx.nativePipelinePackagePromise &&\n ctx.nativePipelinePackageKey === key\n ) {\n return ctx.nativePipelinePackagePromise;\n }\n\n const sharedCache = sharedPackageCacheFor(scopedConfig.dictionaries);\n const shared = sharedCache.get(key);\n if (shared !== undefined) {\n touchSharedPackageCacheEntry(sharedCache, key, shared);\n const packageBytes = await shared;\n ctx.nativePipelinePackage = packageBytes;\n ctx.nativePipelinePackageKey = key;\n ctx.nativePipelinePackagePromise = null;\n return packageBytes;\n }\n\n ctx.nativePipelinePackage = null;\n ctx.nativePipelinePackageKey = key;\n const promise = buildNativePipelinePackage({\n binding,\n config: scopedConfig,\n gazetteerEntries,\n compressed,\n });\n ctx.nativePipelinePackagePromise = promise;\n touchSharedPackageCacheEntry(sharedCache, key, promise);\n let packageBytes: Uint8Array;\n try {\n packageBytes = await promise;\n } catch (error) {\n if (sharedCache.get(key) === promise) {\n sharedCache.delete(key);\n }\n if (\n ctx.nativePipelinePackageKey === key &&\n ctx.nativePipelinePackagePromise === promise\n ) {\n ctx.nativePipelinePackage = null;\n ctx.nativePipelinePackagePromise = null;\n }\n throw error;\n }\n if (sharedCache.get(key) === promise) {\n sharedCache.set(key, packageBytes);\n }\n if (ctx.nativePipelinePackageKey === key) {\n ctx.nativePipelinePackage = packageBytes;\n ctx.nativePipelinePackagePromise = null;\n }\n return packageBytes;\n};\n\n// `async` so the shared package cache can store the in-flight value and dedupe\n// concurrent builds for the same key, and so assembly failures (an older\n// binding without the assemble functions, or a config the assembler rejects)\n// surface as a rejected promise rather than a synchronous throw mid-cache-flow.\nconst buildNativePipelinePackage = async ({\n binding,\n config,\n gazetteerEntries,\n compressed,\n}: Required<\n Omit<NativePipelinePackageOptions, \"context\">\n>): Promise<Uint8Array> =>\n assemblePackageBytes(\n binding,\n toAssembleInputs(config, gazetteerEntries),\n compressed,\n );\n\ntype NativePackageCacheKeyOptions = {\n binding: NativeAnonymizeBinding;\n config: PipelineConfig;\n gazetteerEntries: readonly GazetteerEntry[];\n compressed: boolean;\n};\n\nconst nativePackageCacheKey = ({\n binding,\n config,\n gazetteerEntries,\n compressed,\n}: NativePackageCacheKeyOptions): string =>\n [\n binding.nativePackageVersion(),\n compressed ? \"compressed\" : \"raw\",\n dictionaryCacheKey(config.dictionaries),\n pipelineConfigKey(config, gazetteerEntries),\n ].join(\":\");\n","import { DEFAULT_ENTITY_LABELS } from \"./constants\";\nimport type { PipelineConfig } from \"./types\";\n\nexport const DEFAULT_NATIVE_PIPELINE_CONFIG: PipelineConfig = {\n threshold: 0.3,\n enableTriggerPhrases: true,\n enableRegex: true,\n enableLegalForms: true,\n enableNameCorpus: true,\n enableDenyList: true,\n enableGazetteer: false,\n enableCountries: true,\n enableConfidenceBoost: true,\n enableCoreference: true,\n enableHotwordRules: true,\n enableZoneClassification: true,\n standaloneStreetDetection: \"off\",\n labels: [...DEFAULT_ENTITY_LABELS],\n workspaceId: \"native-pipeline-default\",\n};\n","import languageScopes from \"./data/language-scopes.json\";\n\nexport type SupportedLanguage =\n | \"cs\"\n | \"de\"\n | \"en\"\n | \"es\"\n | \"fr\"\n | \"hu\"\n | \"it\"\n | \"lv\"\n | \"pl\"\n | \"pt-br\"\n | \"ro\"\n | \"sk\"\n | \"sv\";\n\nconst isSupportedLanguage = (language: string): language is SupportedLanguage =>\n Object.hasOwn(languageScopes.languages, language);\n\nexport const SUPPORTED_LANGUAGES = Object.freeze(\n Object.keys(languageScopes.languages).filter(isSupportedLanguage).toSorted(),\n);\n\nexport type PipelineLanguageSelection =\n | SupportedLanguage\n | readonly [SupportedLanguage, ...SupportedLanguage[]]\n | \"all\";\n\nexport type NormalizedPipelineLanguageSelection =\n | { type: \"all\" }\n | {\n type: \"languages\";\n languages: readonly [SupportedLanguage, ...SupportedLanguage[]];\n };\n\nconst normalizeLanguage = (language: unknown): SupportedLanguage => {\n if (typeof language !== \"string\") {\n throw new TypeError(\"Pipeline language codes must be strings\");\n }\n const normalized = language.trim().toLowerCase();\n if (!isSupportedLanguage(normalized)) {\n throw new RangeError(\n `Unsupported pipeline language ${JSON.stringify(language)}; expected one of: ${SUPPORTED_LANGUAGES.join(\", \")}`,\n );\n }\n return normalized;\n};\n\nexport const normalizePipelineLanguageSelection = (\n selection: PipelineLanguageSelection | undefined,\n): NormalizedPipelineLanguageSelection => {\n if (\n selection === undefined ||\n (typeof selection === \"string\" && selection.trim().toLowerCase() === \"all\")\n ) {\n return { type: \"all\" };\n }\n const requested = Array.isArray(selection) ? selection : [selection];\n if (requested.length === 0) {\n throw new RangeError(\"Pipeline language selection must not be empty\");\n }\n const normalized = [...new Set(requested.map(normalizeLanguage))].toSorted();\n const first = normalized.at(0);\n if (first === undefined) {\n throw new RangeError(\"Pipeline language selection must not be empty\");\n }\n return { type: \"languages\", languages: [first, ...normalized.slice(1)] };\n};\n\nexport const pipelineLanguageSelectionKey = (\n selection: NormalizedPipelineLanguageSelection,\n): string => (selection.type === \"all\" ? \"all\" : selection.languages.join(\",\"));\n","import type { Dictionaries, PipelineConfig } from \"./types\";\nimport type { NativeAnonymizeBinding, PreparedNativePipeline } from \"./native\";\nimport { defaultDictionaryBundleOptions } from \"./build-native-package\";\nimport { createNativePipelineFromConfig } from \"./native-pipeline\";\nimport { DEFAULT_NATIVE_PIPELINE_CONFIG } from \"./native-default-config\";\nimport { applyPipelineLanguageScope } from \"./language-scope\";\nimport {\n pipelineLanguageSelectionKey,\n type NormalizedPipelineLanguageSelection,\n} from \"./pipeline-language\";\n\ntype CreateSemanticPipelineOptions = {\n binding: NativeAnonymizeBinding;\n selection: NormalizedPipelineLanguageSelection;\n};\n\ntype AnonymizeDataModule = {\n loadDictionaryBundle: (options?: {\n countries?: readonly string[];\n cityCountries?: readonly string[];\n nameLanguages?: readonly string[];\n }) => Promise<Dictionaries>;\n};\n\nconst dictionaryCache = new Map<string, Promise<Dictionaries>>();\nconst semanticPipelineCache = new WeakMap<\n NativeAnonymizeBinding,\n Map<string, Promise<PreparedNativePipeline>>\n>();\nconst MAX_SEMANTIC_PIPELINE_CACHE_ENTRIES = 8;\n\nconst getCachedEntry = <Value>(\n cache: Map<string, Value>,\n key: string,\n): Value | undefined => {\n const cached = cache.get(key);\n if (cached === undefined) {\n return undefined;\n }\n cache.delete(key);\n cache.set(key, cached);\n return cached;\n};\n\nconst setCachedEntry = <Value>(\n cache: Map<string, Value>,\n key: string,\n value: Value,\n): void => {\n cache.set(key, value);\n if (cache.size <= MAX_SEMANTIC_PIPELINE_CACHE_ENTRIES) {\n return;\n }\n const oldestKey = cache.keys().next().value;\n if (oldestKey !== undefined) {\n cache.delete(oldestKey);\n }\n};\n\nconst loadSemanticDictionaries = (\n key: string,\n config: PipelineConfig,\n): Promise<Dictionaries> => {\n const cached = getCachedEntry(dictionaryCache, key);\n if (cached !== undefined) {\n return cached;\n }\n // Keep dictionary chunks out of the default-package import path. Bundlers\n // load only the chunks needed to assemble an unbundled semantic scope.\n let dictionaries: Promise<Dictionaries>;\n dictionaries = import(\"@stll/anonymize-data/cities\")\n .then(({ loadDictionaryBundle }: AnonymizeDataModule) =>\n loadDictionaryBundle(defaultDictionaryBundleOptions(config)),\n )\n .catch((error: unknown) => {\n if (dictionaryCache.get(key) === dictionaries) {\n dictionaryCache.delete(key);\n }\n throw error;\n });\n setCachedEntry(dictionaryCache, key, dictionaries);\n return dictionaries;\n};\n\nconst pipelineConfigFor = (\n selection: NormalizedPipelineLanguageSelection,\n): PipelineConfig => {\n if (selection.type === \"all\") {\n return {\n ...DEFAULT_NATIVE_PIPELINE_CONFIG,\n labels: [...DEFAULT_NATIVE_PIPELINE_CONFIG.labels],\n };\n }\n const [language, ...languages] = selection.languages;\n return applyPipelineLanguageScope({\n ...DEFAULT_NATIVE_PIPELINE_CONFIG,\n labels: [...DEFAULT_NATIVE_PIPELINE_CONFIG.labels],\n workspaceId: `default-pipeline:${pipelineLanguageSelectionKey(selection)}`,\n ...(languages.length === 0\n ? { language }\n : { languages: [language, ...languages] }),\n });\n};\n\nconst semanticPipelineCacheFor = (\n binding: NativeAnonymizeBinding,\n): Map<string, Promise<PreparedNativePipeline>> => {\n const cached = semanticPipelineCache.get(binding);\n if (cached !== undefined) {\n return cached;\n }\n const created = new Map<string, Promise<PreparedNativePipeline>>();\n semanticPipelineCache.set(binding, created);\n return created;\n};\n\nexport const createSemanticPipeline = ({\n binding,\n selection,\n}: CreateSemanticPipelineOptions): Promise<PreparedNativePipeline> => {\n const key = pipelineLanguageSelectionKey(selection);\n const cache = semanticPipelineCacheFor(binding);\n const cached = getCachedEntry(cache, key);\n if (cached !== undefined) {\n return cached;\n }\n const config = pipelineConfigFor(selection);\n let pipeline: Promise<PreparedNativePipeline>;\n pipeline = loadSemanticDictionaries(key, config)\n .then((dictionaries) =>\n createNativePipelineFromConfig({\n binding,\n config: { ...config, dictionaries },\n }),\n )\n .catch((error: unknown) => {\n if (cache.get(key) === pipeline) {\n cache.delete(key);\n }\n throw error;\n });\n setCachedEntry(cache, key, pipeline);\n return pipeline;\n};\n","import { createRequire } from \"node:module\";\nimport { existsSync, readFileSync, readdirSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport process from \"node:process\";\nimport { loadNativeBinding as loadDefaultPlatformNativePackage } from \"../index.cjs\";\n\nimport {\n assertNativeBindingVersion,\n createNativePipelineFromPackage,\n isNativeAnonymizeBinding,\n type NativeOperatorConfig,\n type NativeAnonymizeBinding,\n type NativeNormalizeOptions,\n type NativeSearchPackageInput,\n PreparedNativeAnonymizer,\n PreparedNativePipeline,\n type NativeStaticRedactionResult,\n diagnostics_json as diagnosticsJsonWithBinding,\n convert_external_detection_batch as convertExternalDetectionBatchWithBinding,\n diagnostics_stream_json as diagnosticsStreamJsonWithBinding,\n load_prepared_package as loadPreparedPackageWithBinding,\n native_package_version as nativePackageVersionWithBinding,\n normalize_for_search as normalizeForSearchWithBinding,\n prepare_search_package as prepareSearchPackageWithBinding,\n redact_text as redactTextWithBinding,\n redact_text_json as redactTextJsonWithBinding,\n redact_text_stream_json as redactTextStreamJsonWithBinding,\n summary_diagnostics_json as summaryDiagnosticsJsonWithBinding,\n} from \"./native\";\nimport { assertSupportedBunRuntime } from \"./bun-version\";\nimport { createSemanticPipeline } from \"./create-pipeline\";\nimport {\n normalizePipelineLanguageSelection,\n type PipelineLanguageSelection,\n} from \"./pipeline-language\";\n\nexport { SUPPORTED_LANGUAGES } from \"./pipeline-language\";\nexport type {\n PipelineLanguageSelection,\n SupportedLanguage,\n} from \"./pipeline-language\";\n\nexport * from \"./native\";\nexport {\n assertNativePipelineSupported,\n createNativePipelineFromConfig,\n getNativePipelineCompatibility,\n prepareNativePipelineConfig,\n prepareNativePipelinePackage,\n} from \"./native-pipeline\";\nexport type {\n NativePipelineBuildOptions,\n NativePipelineCompatibility,\n NativePipelinePackageOptions,\n NativePipelineUnsupportedFeature,\n} from \"./native-pipeline\";\n\nexport type NativeRequire = (specifier: string) => unknown;\n\nexport type NativeLibc = \"gnu\" | \"musl\";\n\nexport type LoadNativeBindingOptions = {\n expectedVersion?: string;\n platform?: string;\n arch?: string;\n libc?: NativeLibc;\n env?: Record<string, string | undefined>;\n requireModule?: NativeRequire;\n};\n\nexport type NativePipelinePackageFileOptions = LoadNativeBindingOptions & {\n binding?: NativeAnonymizeBinding;\n packagePath: string;\n};\n\nexport type NativeSdkOptions = LoadNativeBindingOptions & {\n binding?: NativeAnonymizeBinding;\n};\n\nexport type NativeSdkPackageOptions = NativeSdkOptions & {\n compressed?: boolean;\n};\n\nexport type CreatePipelineOptions = NativeSdkOptions & {\n language?: PipelineLanguageSelection;\n warmup?: DefaultNativePipelineWarmup;\n};\n\nexport type DefaultNativePipelinePackageOptions = LoadNativeBindingOptions & {\n binding?: NativeAnonymizeBinding;\n language?: string;\n packagePath?: string;\n warmup?: DefaultNativePipelineWarmup;\n};\n\ntype ResolvedDefaultNativePipelineOptions = {\n binding: NativeAnonymizeBinding;\n language?: string;\n packagePath?: string;\n warmup: DefaultNativePipelineWarmup;\n};\n\nexport const DEFAULT_NATIVE_PIPELINE_WARMUPS = {\n lazyRegex: \"lazy-regex\",\n none: \"none\",\n} as const;\n\nexport type DefaultNativePipelineWarmup =\n (typeof DEFAULT_NATIVE_PIPELINE_WARMUPS)[keyof typeof DEFAULT_NATIVE_PIPELINE_WARMUPS];\n\nexport type DefaultNativePipelinePackageFileOptions = {\n language?: string;\n};\n\nconst PACKAGE_SPECIFIC_NATIVE_PATH = \"STELLA_ANONYMIZE_NATIVE_LIBRARY_PATH\";\nconst DEFAULT_NATIVE_PIPELINE_PACKAGE_URL = new URL(\n \"../native-pipeline.stlanonpkg\",\n import.meta.url,\n);\nconst DEFAULT_NATIVE_PIPELINE_PACKAGE_DIR_URL = new URL(\"../\", import.meta.url);\nconst DEFAULT_NATIVE_PIPELINE_LANGUAGE_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;\nconst DEFAULT_NATIVE_PIPELINE_LANGUAGE_PACKAGE_PATTERN =\n /^native-pipeline\\.([a-z0-9]+(?:-[a-z0-9]+)*)\\.stlanonpkg$/u;\nconst DEFAULT_NATIVE_PIPELINE_PACKAGE_CACHE_KEY = \"<default>\";\nconst defaultNativePipelineCache = new WeakMap<\n NativeAnonymizeBinding,\n Map<string, PreparedNativePipeline>\n>();\nconst warmedDefaultNativePipelines = new WeakSet<PreparedNativePipeline>();\nconst defaultNativePipelineInflightCache = new WeakMap<\n NativeAnonymizeBinding,\n Map<string, Promise<PreparedNativePipeline>>\n>();\n\nexport { DEFAULT_NATIVE_PIPELINE_CONFIG } from \"./native-default-config\";\n\n/**\n * An explicit binding override for embedded runtimes and tests. Undefined by\n * default, so Node.js and Bun load their platform N-API package.\n */\nlet nativeBindingOverride: NativeAnonymizeBinding | undefined;\n\nexport const setNativeBindingOverride = (\n binding: NativeAnonymizeBinding | undefined,\n): void => {\n nativeBindingOverride = binding;\n};\n\nexport const loadNativeAnonymizeBinding = (\n options: LoadNativeBindingOptions = {},\n): NativeAnonymizeBinding => {\n assertSupportedBunRuntime();\n if (nativeBindingOverride !== undefined) {\n if (options.expectedVersion !== undefined) {\n assertNativeBindingVersion({\n binding: nativeBindingOverride,\n expectedVersion: options.expectedVersion,\n });\n }\n return nativeBindingOverride;\n }\n const requireModule = options.requireModule ?? createRequire(import.meta.url);\n const platform = options.platform ?? process.platform;\n const arch = options.arch ?? process.arch;\n const libc = options.libc ?? detectNativeLibc(platform);\n const env = options.env ?? process.env;\n const specifiers = nativeBindingSpecifiers({ arch, env, libc, platform });\n const platformPackage = nativeBindingPackageName({ arch, libc, platform });\n const errors: string[] = [];\n\n for (const specifier of specifiers) {\n const loadModule =\n options.requireModule === undefined &&\n specifier === platformPackage &&\n isHostNativeTarget({ arch, libc, platform })\n ? loadDefaultPlatformNativePackage\n : () => requireModule(specifier);\n const binding = tryLoadNativeBinding({\n specifier,\n loadModule,\n errors,\n });\n if (!binding) {\n continue;\n }\n if (options.expectedVersion !== undefined) {\n assertNativeBindingVersion({\n binding,\n expectedVersion: options.expectedVersion,\n });\n }\n return binding;\n }\n\n if (nativeBindingPackageName({ arch, libc, platform }) === null) {\n throw unsupportedNativeTargetError({ arch, errors, libc, platform });\n }\n throw new Error(\n `Unable to load native anonymize binding for ${platform}/${arch}:\\n${errors.join(\"\\n\")}`,\n );\n};\n\nexport const readNativePipelinePackageFile = (\n packagePath: string,\n): Uint8Array => readFileSync(packagePath);\n\nexport const readNativePipelinePackageFileAsync = async (\n packagePath: string,\n): Promise<Uint8Array> => readFile(packagePath);\n\nexport const native_package_version = (\n options: NativeSdkOptions = {},\n): string => nativePackageVersionWithBinding(resolveNativeSdkBinding(options));\n\nexport const convert_external_detection_batch = (\n document: Uint8Array,\n batch: import(\"./native\").ExternalDetectionBatch | string,\n options: NativeSdkOptions = {},\n): import(\"./native\").NativeCallerDetection[] =>\n convertExternalDetectionBatchWithBinding({\n binding: resolveNativeSdkBinding(options),\n document,\n batch,\n });\n\nexport const normalize_for_search = (\n text: string,\n options: NativeSdkOptions = {},\n): string => {\n const args: NativeNormalizeOptions = {\n binding: resolveNativeSdkBinding(options),\n text,\n };\n return normalizeForSearchWithBinding(args);\n};\n\nexport const prepare_search_package = (\n config: NativeSearchPackageInput,\n { compressed = false, ...options }: NativeSdkPackageOptions = {},\n): Uint8Array =>\n prepareSearchPackageWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n compressed,\n });\n\nexport const load_prepared_package = (\n packageBytes: Uint8Array,\n options: NativeSdkOptions = {},\n) =>\n loadPreparedPackageWithBinding({\n binding: resolveNativeSdkBinding(options),\n packageBytes,\n });\n\nexport const load_prepared_package_file = (\n packagePath: string,\n options: NativeSdkOptions = {},\n) => load_prepared_package(readNativePipelinePackageFile(packagePath), options);\n\nexport const redact_text = (\n config: NativeSearchPackageInput,\n fullText: string,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): NativeStaticRedactionResult =>\n redactTextWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const redact_text_json = (\n config: NativeSearchPackageInput,\n fullText: string,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): string =>\n redactTextJsonWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const redact_text_stream_json = (\n config: NativeSearchPackageInput,\n fullText: string,\n onEvent: (eventJson: string) => void,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): string =>\n redactTextStreamJsonWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n onEvent,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const diagnostics_json = (\n config: NativeSearchPackageInput,\n fullText: string,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): string =>\n diagnosticsJsonWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const diagnostics_stream_json = (\n config: NativeSearchPackageInput,\n fullText: string,\n onBatch: (diagnosticsJson: string) => void,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): string =>\n diagnosticsStreamJsonWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n onBatch,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const summary_diagnostics_json = (\n config: NativeSearchPackageInput,\n fullText: string,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): string =>\n summaryDiagnosticsJsonWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const readDefaultNativePipelinePackageFile = ({\n language,\n}: DefaultNativePipelinePackageFileOptions = {}): Uint8Array => {\n const packageUrl = defaultNativePipelinePackageUrl(language);\n try {\n return readFileSync(packageUrl);\n } catch (error) {\n throw new Error(\n `${defaultNativePipelinePackageDescription(language)} is unavailable: ${formatLoadError(error)}`,\n );\n }\n};\n\nexport const read_default_native_pipeline_package_file = (\n options: DefaultNativePipelinePackageFileOptions = {},\n): Uint8Array => readDefaultNativePipelinePackageFile(options);\n\nexport const availableDefaultNativePipelineLanguages = (): string[] => {\n const languages = new Set<string>();\n try {\n for (const fileName of readdirSync(\n DEFAULT_NATIVE_PIPELINE_PACKAGE_DIR_URL,\n )) {\n const match = fileName.match(\n DEFAULT_NATIVE_PIPELINE_LANGUAGE_PACKAGE_PATTERN,\n );\n if (match?.[1] !== undefined) {\n languages.add(match[1]);\n }\n }\n } catch (error) {\n throw new Error(\n `Default native pipeline package directory is unavailable: ${formatLoadError(error)}`,\n );\n }\n return [...languages].toSorted();\n};\n\nexport const available_default_native_pipeline_languages =\n availableDefaultNativePipelineLanguages;\n\nexport const readDefaultNativePipelinePackageFileAsync = async ({\n language,\n}: DefaultNativePipelinePackageFileOptions = {}): Promise<Uint8Array> => {\n const packageUrl = defaultNativePipelinePackageUrl(language);\n try {\n return await readFile(packageUrl);\n } catch (error) {\n throw new Error(\n `${defaultNativePipelinePackageDescription(language)} is unavailable: ${formatLoadError(error)}`,\n );\n }\n};\n\nexport const createNativePipelineFromPackageFile = ({\n binding,\n packagePath,\n expectedVersion,\n ...loadOptions\n}: NativePipelinePackageFileOptions): PreparedNativePipeline => {\n const resolvedBinding =\n binding ??\n loadNativeAnonymizeBinding({\n ...loadOptions,\n ...(expectedVersion !== undefined ? { expectedVersion } : {}),\n });\n if (binding && expectedVersion !== undefined) {\n assertNativeBindingVersion({ binding, expectedVersion });\n }\n return createNativePipelineFromPackage({\n binding: resolvedBinding,\n packageBytes: readNativePipelinePackageFile(packagePath),\n });\n};\n\nexport const createNativePipelineFromDefaultPackage = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => {\n const resolvedOptions = resolveDefaultNativePipelineOptions(options);\n return applyDefaultNativePipelineWarmup(\n createNativePipelineFromResolvedDefaultPackage(resolvedOptions),\n resolvedOptions.warmup,\n );\n};\n\nexport const create_native_pipeline_from_default_package = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => createNativePipelineFromDefaultPackage(options);\n\nexport const getDefaultNativePipeline = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => {\n const resolvedOptions = resolveDefaultNativePipelineOptions(options);\n const cache = defaultPipelineCacheFor(resolvedOptions.binding);\n const key = defaultPipelineCacheKey(resolvedOptions);\n const cached = cache.get(key);\n if (cached !== undefined) {\n return applyDefaultNativePipelineWarmup(cached, resolvedOptions.warmup);\n }\n const pipeline =\n createNativePipelineFromResolvedDefaultPackage(resolvedOptions);\n cache.set(key, pipeline);\n return applyDefaultNativePipelineWarmup(pipeline, resolvedOptions.warmup);\n};\n\nexport const get_default_native_pipeline = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => getDefaultNativePipeline(options);\n\nexport const createPipeline = async ({\n language,\n warmup,\n ...bindingOptions\n}: CreatePipelineOptions = {}): Promise<PreparedNativePipeline> => {\n const selection = normalizePipelineLanguageSelection(language);\n if (selection.type === \"all\") {\n return getDefaultNativePipeline({\n ...bindingOptions,\n ...(warmup !== undefined ? { warmup } : {}),\n });\n }\n const [singleLanguage, ...additionalLanguages] = selection.languages;\n if (\n additionalLanguages.length === 0 &&\n existsSync(defaultNativePipelineLanguagePackageUrl(singleLanguage))\n ) {\n return getDefaultNativePipeline({\n ...bindingOptions,\n language: singleLanguage,\n ...(warmup !== undefined ? { warmup } : {}),\n });\n }\n const resolvedWarmup = normalizeDefaultNativePipelineWarmup(warmup);\n const pipeline = await createSemanticPipeline({\n binding: resolveNativeSdkBinding(bindingOptions),\n selection,\n });\n return applyDefaultNativePipelineWarmup(pipeline, resolvedWarmup);\n};\n\nexport const create_pipeline = createPipeline;\n\nexport const preloadDefaultNativePipeline = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => {\n const pipeline = getDefaultNativePipeline(options);\n return applyDefaultNativePipelineWarmup(\n pipeline,\n DEFAULT_NATIVE_PIPELINE_WARMUPS.lazyRegex,\n );\n};\n\nexport const preload_default_native_pipeline = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => preloadDefaultNativePipeline(options);\n\nexport const redactDefaultText = (\n fullText: string,\n operators?: NativeOperatorConfig,\n options: DefaultNativePipelinePackageOptions = {},\n): NativeStaticRedactionResult =>\n getDefaultNativePipeline(options).redactText(fullText, operators);\n\nexport const redact_default_text = (\n fullText: string,\n operators?: NativeOperatorConfig,\n options: DefaultNativePipelinePackageOptions = {},\n): NativeStaticRedactionResult =>\n redactDefaultText(fullText, operators, options);\n\nexport const redactDefaultTextJson = (\n fullText: string,\n operators?: NativeOperatorConfig,\n options: DefaultNativePipelinePackageOptions = {},\n): string =>\n getDefaultNativePipeline(options).redact_text_json(fullText, operators);\n\nexport const redact_default_text_json = (\n fullText: string,\n operators?: NativeOperatorConfig,\n options: DefaultNativePipelinePackageOptions = {},\n): string => redactDefaultTextJson(fullText, operators, options);\n\nexport const preloadDefaultNativePipelineAsync = (\n options: DefaultNativePipelinePackageOptions = {},\n): Promise<PreparedNativePipeline> => {\n const resolvedOptions = {\n ...resolveDefaultNativePipelineOptions(options),\n warmup: DEFAULT_NATIVE_PIPELINE_WARMUPS.lazyRegex,\n };\n const cache = defaultPipelineCacheFor(resolvedOptions.binding);\n const key = defaultPipelineCacheKey(resolvedOptions);\n const cached = cache.get(key);\n if (cached !== undefined) {\n return Promise.resolve(\n applyDefaultNativePipelineWarmup(cached, resolvedOptions.warmup),\n );\n }\n\n const inflightCache = defaultPipelineInflightCacheFor(\n resolvedOptions.binding,\n );\n const inflight = inflightCache.get(key);\n if (inflight !== undefined) {\n return inflight;\n }\n\n const promise = createNativePipelineFromResolvedDefaultPackageAsync(\n resolvedOptions,\n )\n .then((pipeline) => {\n cache.set(key, pipeline);\n return applyDefaultNativePipelineWarmup(pipeline, resolvedOptions.warmup);\n })\n .finally(() => {\n inflightCache.delete(key);\n });\n inflightCache.set(key, promise);\n return promise;\n};\n\nconst resolveDefaultNativePipelineOptions = ({\n binding,\n language,\n packagePath,\n warmup,\n expectedVersion,\n ...loadOptions\n}: DefaultNativePipelinePackageOptions = {}): ResolvedDefaultNativePipelineOptions => {\n if (language !== undefined && packagePath !== undefined) {\n throw new Error(\"Use either language or packagePath, not both\");\n }\n const resolvedBinding =\n binding ??\n loadNativeAnonymizeBinding({\n ...loadOptions,\n ...(expectedVersion !== undefined ? { expectedVersion } : {}),\n });\n if (binding && expectedVersion !== undefined) {\n assertNativeBindingVersion({ binding, expectedVersion });\n }\n return {\n binding: resolvedBinding,\n warmup: normalizeDefaultNativePipelineWarmup(warmup),\n ...(language !== undefined\n ? { language: resolveDefaultNativePipelineLanguage(language) }\n : {}),\n ...(packagePath !== undefined ? { packagePath } : {}),\n };\n};\n\nconst applyDefaultNativePipelineWarmup = (\n pipeline: PreparedNativePipeline,\n warmup: DefaultNativePipelineWarmup,\n): PreparedNativePipeline => {\n if (warmup !== DEFAULT_NATIVE_PIPELINE_WARMUPS.lazyRegex) {\n return pipeline;\n }\n if (!warmedDefaultNativePipelines.has(pipeline)) {\n pipeline.warmLazyRegex();\n warmedDefaultNativePipelines.add(pipeline);\n }\n return pipeline;\n};\n\nconst createNativePipelineFromResolvedDefaultPackage = ({\n binding,\n language,\n packagePath,\n}: ResolvedDefaultNativePipelineOptions): PreparedNativePipeline => {\n const packageBytes =\n packagePath === undefined\n ? readDefaultNativePipelinePackageFile(\n defaultPackageFileOptions(language),\n )\n : readNativePipelinePackageFile(packagePath);\n return createNativePipelineFromTrustedDefaultPackage(binding, packageBytes);\n};\n\nconst createNativePipelineFromResolvedDefaultPackageAsync = async ({\n binding,\n language,\n packagePath,\n}: ResolvedDefaultNativePipelineOptions): Promise<PreparedNativePipeline> => {\n const packageBytes =\n packagePath === undefined\n ? await readDefaultNativePipelinePackageFileAsync(\n defaultPackageFileOptions(language),\n )\n : await readNativePipelinePackageFileAsync(packagePath);\n return createNativePipelineFromTrustedDefaultPackage(binding, packageBytes);\n};\n\nconst createNativePipelineFromTrustedDefaultPackage = (\n binding: NativeAnonymizeBinding,\n packageBytes: Uint8Array,\n): PreparedNativePipeline =>\n new PreparedNativePipeline(\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromTrustedPreparedPackageBytesWithoutCache(\n packageBytes,\n ),\n ),\n );\n\nconst defaultPackageFileOptions = (\n language: string | undefined,\n): DefaultNativePipelinePackageFileOptions =>\n language === undefined ? {} : { language };\n\nconst normalizeDefaultNativePipelineWarmup = (\n warmup: DefaultNativePipelineWarmup | undefined,\n): DefaultNativePipelineWarmup => {\n if (warmup === undefined) {\n return DEFAULT_NATIVE_PIPELINE_WARMUPS.none;\n }\n switch (warmup) {\n case DEFAULT_NATIVE_PIPELINE_WARMUPS.lazyRegex:\n case DEFAULT_NATIVE_PIPELINE_WARMUPS.none:\n return warmup;\n }\n throw new Error(\n 'Default native pipeline warmup must be \"lazy-regex\" or \"none\"',\n );\n};\n\nconst resolveNativeSdkBinding = ({\n binding,\n expectedVersion,\n ...loadOptions\n}: NativeSdkOptions): NativeAnonymizeBinding => {\n const resolvedBinding =\n binding ??\n loadNativeAnonymizeBinding({\n ...loadOptions,\n ...(expectedVersion !== undefined ? { expectedVersion } : {}),\n });\n if (binding && expectedVersion !== undefined) {\n assertNativeBindingVersion({ binding, expectedVersion });\n }\n return resolvedBinding;\n};\n\nconst defaultPipelineCacheFor = (\n binding: NativeAnonymizeBinding,\n): Map<string, PreparedNativePipeline> => {\n const cached = defaultNativePipelineCache.get(binding);\n if (cached !== undefined) {\n return cached;\n }\n const created = new Map<string, PreparedNativePipeline>();\n defaultNativePipelineCache.set(binding, created);\n return created;\n};\n\nconst defaultPipelineInflightCacheFor = (\n binding: NativeAnonymizeBinding,\n): Map<string, Promise<PreparedNativePipeline>> => {\n const cached = defaultNativePipelineInflightCache.get(binding);\n if (cached !== undefined) {\n return cached;\n }\n const created = new Map<string, Promise<PreparedNativePipeline>>();\n defaultNativePipelineInflightCache.set(binding, created);\n return created;\n};\n\nconst defaultPipelineCacheKey = ({\n binding,\n language,\n packagePath,\n}: ResolvedDefaultNativePipelineOptions): string =>\n [\n binding.nativePackageVersion(),\n packagePath ??\n (language === undefined\n ? DEFAULT_NATIVE_PIPELINE_PACKAGE_CACHE_KEY\n : `language:${language}`),\n ].join(\"\\0\");\n\nconst defaultNativePipelinePackageUrl = (language: string | undefined): URL => {\n if (language === undefined) {\n return DEFAULT_NATIVE_PIPELINE_PACKAGE_URL;\n }\n const normalized = resolveDefaultNativePipelineLanguage(language);\n return defaultNativePipelineLanguagePackageUrl(normalized);\n};\n\nconst defaultNativePipelineLanguagePackageUrl = (language: string): URL =>\n new URL(`../native-pipeline.${language}.stlanonpkg`, import.meta.url);\n\nconst resolveDefaultNativePipelineLanguage = (language: string): string => {\n const normalized = normalizeDefaultNativePipelineLanguage(language);\n const exactUrl = defaultNativePipelineLanguagePackageUrl(normalized);\n if (existsSync(exactUrl)) {\n return normalized;\n }\n const baseLanguage = normalized.split(\"-\").at(0);\n if (baseLanguage === undefined || baseLanguage === normalized) {\n return normalized;\n }\n const baseUrl = defaultNativePipelineLanguagePackageUrl(baseLanguage);\n if (existsSync(baseUrl)) {\n return baseLanguage;\n }\n return normalized;\n};\n\nconst defaultNativePipelinePackageDescription = (\n language: string | undefined,\n): string =>\n language === undefined\n ? \"Default native pipeline package\"\n : `Default native pipeline package for language \"${resolveDefaultNativePipelineLanguage(language)}\"`;\n\nconst normalizeDefaultNativePipelineLanguage = (language: string): string => {\n const normalized = language.trim().toLowerCase();\n if (!DEFAULT_NATIVE_PIPELINE_LANGUAGE_PATTERN.test(normalized)) {\n throw new Error(\n `Default native pipeline language must match ${DEFAULT_NATIVE_PIPELINE_LANGUAGE_PATTERN.source}`,\n );\n }\n return normalized;\n};\n\ntype NativeBindingSpecifiersOptions = {\n arch: string;\n env: Record<string, string | undefined>;\n libc: NativeLibc | undefined;\n platform: string;\n};\n\nconst nativeBindingSpecifiers = ({\n arch,\n env,\n libc,\n platform,\n}: NativeBindingSpecifiersOptions): string[] => {\n const specifiers: string[] = [];\n const overridePath = env[PACKAGE_SPECIFIC_NATIVE_PATH];\n if (overridePath) {\n specifiers.push(overridePath);\n }\n const platformPackage = nativeBindingPackageName({ arch, libc, platform });\n if (platformPackage !== null) {\n specifiers.push(platformPackage);\n }\n return specifiers;\n};\n\ntype NativeBindingTarget = {\n platform: string;\n arch: string;\n libc?: NativeLibc;\n package: string;\n};\n\n// Single source of truth for published native sidecars. Both the runtime\n// package lookup and the \"unsupported target\" error message derive from this\n// table, so a target is never advertised as supported without a package (and\n// vice versa). musl Linux is intentionally absent: no musl sidecar is shipped.\nconst NATIVE_BINDING_TARGETS: readonly NativeBindingTarget[] = [\n {\n platform: \"darwin\",\n arch: \"arm64\",\n package: \"@stll/anonymize-darwin-arm64\",\n },\n { platform: \"darwin\", arch: \"x64\", package: \"@stll/anonymize-darwin-x64\" },\n {\n platform: \"linux\",\n arch: \"arm64\",\n libc: \"gnu\",\n package: \"@stll/anonymize-linux-arm64-gnu\",\n },\n {\n platform: \"linux\",\n arch: \"x64\",\n libc: \"gnu\",\n package: \"@stll/anonymize-linux-x64-gnu\",\n },\n { platform: \"win32\", arch: \"x64\", package: \"@stll/anonymize-win32-x64-msvc\" },\n];\n\ntype NativeBindingPackageNameOptions = {\n arch: string;\n libc: NativeLibc | undefined;\n platform: string;\n};\n\ntype DescribeNativeTargetOptions = {\n arch: string;\n libc?: NativeLibc | undefined;\n platform: string;\n};\n\nconst describeNativeTarget = ({\n arch,\n libc,\n platform,\n}: DescribeNativeTargetOptions): string =>\n libc === undefined ? `${platform}-${arch}` : `${platform}-${arch}-${libc}`;\n\nconst SUPPORTED_NATIVE_TARGETS: readonly string[] = NATIVE_BINDING_TARGETS.map(\n (target) => describeNativeTarget(target),\n);\n\nconst nativeBindingPackageName = ({\n arch,\n libc,\n platform,\n}: NativeBindingPackageNameOptions): string | null => {\n const match = NATIVE_BINDING_TARGETS.find(\n (target) =>\n target.platform === platform &&\n target.arch === arch &&\n (target.libc === undefined || target.libc === libc),\n );\n return match?.package ?? null;\n};\n\nconst unsupportedNativeTargetError = ({\n arch,\n errors,\n libc,\n platform,\n}: NativeBindingPackageNameOptions & { errors: string[] }): Error => {\n const target = describeNativeTarget({ arch, libc, platform });\n const supported = SUPPORTED_NATIVE_TARGETS.join(\", \");\n const attempts = errors.length > 0 ? `\\n${errors.join(\"\\n\")}` : \"\";\n return new Error(\n `No native anonymize binding is published for ${target}; supported targets: ${supported}. Set ${PACKAGE_SPECIFIC_NATIVE_PATH} to a locally built binding to run on this platform.${attempts}`,\n );\n};\n\nconst detectNativeLibc = (platform: string): NativeLibc | undefined => {\n if (platform !== \"linux\") {\n return undefined;\n }\n const report = process.report?.getReport();\n const header =\n isPropertyBag(report) && isPropertyBag(report[\"header\"])\n ? report[\"header\"]\n : null;\n return typeof header?.[\"glibcVersionRuntime\"] === \"string\" ? \"gnu\" : \"musl\";\n};\n\nconst isHostNativeTarget = ({\n arch,\n libc,\n platform,\n}: NativeBindingPackageNameOptions): boolean =>\n platform === process.platform &&\n arch === process.arch &&\n (platform !== \"linux\" || libc === detectNativeLibc(process.platform));\n\ntype TryLoadNativeBindingOptions = {\n specifier: string;\n loadModule: () => unknown;\n errors: string[];\n};\n\nconst tryLoadNativeBinding = ({\n specifier,\n loadModule,\n errors,\n}: TryLoadNativeBindingOptions): NativeAnonymizeBinding | null => {\n try {\n const loaded = loadModule();\n const binding = toNativeAnonymizeBinding(loaded);\n if (binding) {\n return binding;\n }\n errors.push(`${specifier}: module does not match native binding shape`);\n } catch (error) {\n errors.push(`${specifier}: ${formatLoadError(error)}`);\n }\n return null;\n};\n\nconst toNativeAnonymizeBinding = (\n value: unknown,\n): NativeAnonymizeBinding | null => {\n const candidate =\n isPropertyBag(value) && isPropertyBag(value[\"default\"])\n ? value[\"default\"]\n : value;\n return isNativeAnonymizeBinding(candidate) ? candidate : null;\n};\n\nconst isPropertyBag = (value: unknown): value is Record<string, unknown> =>\n (typeof value === \"object\" && value !== null) || typeof value === \"function\";\n\nconst formatLoadError = (error: unknown): string => {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n};\n"],"mappings":";;;;;;;;;AAAA,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAC1B,MAAM,sBACJ;AAEF,MAAa,gCAAgC;AAE7C,MAAa,6BAA6B,eAA8B;CACtE,IAAI,eAAe,KAAA,GACjB;CAIF,MAAM,EAAE,OAAO,OAAO,OAAO,eADf,oBAAoB,KAAK,UACS,CAAC,EAAE,UAAU,CAAC;CAC9D,IAAI,UAAU,KAAA,KAAa,UAAU,KAAA,KAAa,UAAU,KAAA,GAC1D,MAAM,2BAA2B,UAAU;CAG7C,MAAM,cAAc,OAAO,KAAK;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UAAU;CAKzC,OAAO,QAHL,cAAc,MAAM,KAAK,cAAc,OAAO,SAAS,IACnD,OAAO,YACP,KAAA,GACiB,2BAA2B,WAAW,QAAQ;AACvE;AAEA,MAAM,sBAAsB,EAC1B,MACA,MACA,eAEA,aAAa,QAAQ,YACrB,SAAS,QAAQ,SAChB,aAAa,WAAW,SAAS,iBAAiB,QAAQ,QAAQ;AAQrE,MAAM,wBAAwB,EAC5B,WACA,YACA,aACgE;CAChE,IAAI;EACF,MAAM,SAAS,WAAW;EAC1B,MAAM,UAAU,yBAAyB,MAAM;EAC/C,IAAI,SACF,OAAO;EAET,OAAO,KAAK,GAAG,UAAU,6CAA6C;CACxE,SAAS,OAAO;EACd,OAAO,KAAK,GAAG,UAAU,IAAI,gBAAgB,KAAK,GAAG;CACvD;CACA,OAAO;AACT;AAEA,MAAM,4BACJ,UACkC;CAClC,MAAM,YACJ,cAAc,KAAK,KAAK,cAAc,MAAM,UAAU,IAClD,MAAM,aACN;CACN,OAAO,yBAAyB,SAAS,IAAI,YAAY;AAC3D;AAEA,MAAM,iBAAiB,UACpB,OAAO,UAAU,YAAY,UAAU,QAAS,OAAO,UAAU;AAEpE,MAAM,mBAAmB,UAA2B;CAClD,IAAI,iBAAiB,OACnB,OAAO,MAAM;CAEf,OAAO,OAAO,KAAK;AACrB"}
1
+ {"version":3,"file":"native-node2.mjs","names":["languageScopes","loadDefaultPlatformNativePackage","nativePackageVersionWithBinding","convertExternalDetectionBatchWithBinding","normalizeForSearchWithBinding","prepareSearchPackageWithBinding","loadPreparedPackageWithBinding","redactTextWithBinding","redactTextJsonWithBinding","redactTextStreamJsonWithBinding","diagnosticsJsonWithBinding","diagnosticsStreamJsonWithBinding","summaryDiagnosticsJsonWithBinding"],"sources":["../src/bun-version.ts","../src/context.ts","../src/types.ts","../src/util/language-selection.ts","../src/pipeline-cache-key.ts","../src/native-pipeline.ts","../src/native-default-config.ts","../src/pipeline-language.ts","../src/create-pipeline.ts","../src/native-node.ts"],"sourcesContent":["const MINIMUM_BUN_MAJOR = 1;\nconst MINIMUM_BUN_MINOR = 4;\nconst BUN_VERSION_PATTERN =\n /^(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)(?:-(?<prerelease>[0-9A-Za-z.-]+))?(?:\\+[0-9A-Za-z.-]+)?$/u;\n\nexport const MINIMUM_SUPPORTED_BUN_VERSION = \"1.4.0\";\n\nexport const assertSupportedBunVersion = (bunVersion?: string): void => {\n if (bunVersion === undefined) {\n return;\n }\n\n const match = BUN_VERSION_PATTERN.exec(bunVersion);\n const { major, minor, patch, prerelease } = match?.groups ?? {};\n if (major === undefined || minor === undefined || patch === undefined) {\n throw unsupportedBunVersionError(bunVersion);\n }\n\n const majorNumber = Number(major);\n const minorNumber = Number(minor);\n const patchNumber = Number(patch);\n if (\n !Number.isSafeInteger(majorNumber) ||\n !Number.isSafeInteger(minorNumber) ||\n !Number.isSafeInteger(patchNumber)\n ) {\n throw unsupportedBunVersionError(bunVersion);\n }\n\n const coreVersionIsNewer =\n majorNumber > MINIMUM_BUN_MAJOR ||\n (majorNumber === MINIMUM_BUN_MAJOR &&\n (minorNumber > MINIMUM_BUN_MINOR ||\n (minorNumber === MINIMUM_BUN_MINOR && patchNumber > 0)));\n const minimumReleaseIsSupported =\n majorNumber === MINIMUM_BUN_MAJOR &&\n minorNumber === MINIMUM_BUN_MINOR &&\n patchNumber === 0 &&\n prerelease === undefined;\n if (!coreVersionIsNewer && !minimumReleaseIsSupported) {\n throw unsupportedBunVersionError(bunVersion);\n }\n};\n\nexport const assertSupportedBunRuntime = (): void => {\n const runtime: unknown = globalThis;\n if (!hasBunRuntime(runtime)) {\n return;\n }\n const bun = runtime.Bun;\n if (\n typeof bun !== \"object\" ||\n bun === null ||\n !(\"version\" in bun) ||\n typeof bun.version !== \"string\"\n ) {\n throw unsupportedBunVersionError(\"unknown\");\n }\n assertSupportedBunVersion(bun.version);\n};\n\nconst hasBunRuntime = (runtime: unknown): runtime is { Bun: unknown } =>\n typeof runtime === \"object\" && runtime !== null && \"Bun\" in runtime;\n\nconst unsupportedBunVersionError = (bunVersion: string): Error =>\n new Error(\n `Bun ${bunVersion} is unsupported; @stll/anonymize requires Bun >=${MINIMUM_SUPPORTED_BUN_VERSION}. Upgrade Bun before loading the native SDK.`,\n );\n","/**\n * Cached state for a single pipeline run (or a sequence of runs sharing the\n * same config). The native pipeline builds its prepared package once and reuses\n * it across calls with the same config; the package bytes and the key/promise\n * that guard concurrent builds live here so callers can share one warmed\n * context.\n */\nexport type PipelineContext = {\n // ── Native prepared-package cache ─────────────\n nativePipelinePackage: Uint8Array | null;\n nativePipelinePackageKey: string;\n nativePipelinePackagePromise: Promise<Uint8Array> | null;\n};\n\n/** Create a fresh, empty pipeline context. */\nexport const createPipelineContext = (): PipelineContext => ({\n nativePipelinePackage: null,\n nativePipelinePackageKey: \"\",\n nativePipelinePackagePromise: null,\n});\n\n/**\n * Module-level default context. Used when callers\n * don't provide an explicit context, preserving full\n * backward compatibility with the existing API.\n */\nexport const defaultContext: PipelineContext = createPipelineContext();\n","// Runtime-free constants live in `./constants`; re-exported\n// here for back-compat with existing call sites that import\n// from `@stll/anonymize` directly.\n//\n// `verbatimModuleSyntax` requires an explicit type-only\n// import for any name used locally as a type even when it\n// is also re-exported below — applies to `DetectionSource`\n// (used by `Entity`) and `OperatorType` (used by\n// `OperatorConfig`).\nimport type { DetectionSource, OperatorType } from \"./constants\";\nimport { DETECTION_SOURCES } from \"./constants\";\n\nexport {\n DETECTION_SOURCES,\n DETECTOR_PRIORITY,\n type DetectionSource,\n} from \"./constants\";\n\n/**\n * Fields shared by every entity span in the source text.\n */\ntype EntityBase = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n sourceDetail?: \"custom-deny-list\" | \"custom-regex\" | \"gazetteer-extension\";\n};\n\n/**\n * A PII entity span found by a primary detection layer\n * (regex, NER, legal forms, deny list, ...).\n */\nexport type DetectedEntity = EntityBase & {\n source: Exclude<DetectionSource, typeof DETECTION_SOURCES.COREFERENCE>;\n};\n\n/**\n * An alias mention of a previously detected entity: a\n * defined term (\"the Seller\") or a propagated bare\n * mention (\"Acme\" after \"Acme Corp.\").\n *\n * `corefSourceText` is required by construction, so an\n * alias cannot exist without the link back to its source\n * entity. Placeholder numbering reads it to give the\n * alias the same placeholder as the source. The link\n * travels with the entity instead of living in a\n * side-channel map that a producer could forget to\n * write — or that a later pass could clear.\n */\nexport type CorefAliasEntity = EntityBase & {\n source: typeof DETECTION_SOURCES.COREFERENCE;\n /** Full text of the source entity this alias refers to. */\n corefSourceText: string;\n};\n\n/**\n * A detected PII entity span in the source text.\n * Every detection layer produces these.\n */\nexport type Entity = DetectedEntity | CorefAliasEntity;\n\n/**\n * Entity after human review. Extends the base Entity\n * with a review decision.\n */\nexport type ReviewDecision = \"confirmed\" | \"rejected\" | \"relabeled\";\n\nexport type ReviewedEntity = Entity & {\n decision?: ReviewDecision;\n originalLabel?: string;\n};\n\n/**\n * A single entry in the workspace-scoped gazetteer\n * (deny list). Persisted in IndexedDB.\n */\nexport type GazetteerEntry = {\n id: string;\n canonical: string;\n label: string;\n variants: string[];\n workspaceId: string;\n createdAt: number;\n source: \"manual\" | \"confirmed-from-model\";\n};\n\n/** Extraction strategy — closed discriminated union. */\nexport type TriggerStrategy =\n | {\n type: \"to-next-comma\";\n /**\n * Optional list of lowercase keywords that terminate\n * the value scan, in addition to commas/newlines. Useful\n * for triggers like court names that may continue past\n * a missing comma into adjacent clause text (\"Městským\n * soudem v Praze dne 1. 1. 2020\"); listing `\"dne\"` here\n * stops the scan at the date boundary. Matched on a\n * word-boundary, case-insensitive.\n */\n stopWords?: string[];\n /**\n * Hard cap on the captured span length, in characters,\n * regardless of where the next comma / stop char sits.\n * Use for triggers that label short formulaic phrases\n * (\"State of Delaware\") and must not absorb the rest\n * of a long forum-selection clause when the comma is\n * sentences away. Falls back to the default 100-char\n * fallback when omitted.\n */\n maxLength?: number;\n }\n | { type: \"to-end-of-line\" }\n | { type: \"n-words\"; count: number }\n | { type: \"company-id-value\" }\n | { type: \"address\"; maxChars?: number }\n | {\n /**\n * Extract the first regex match in the value text.\n * Useful for shape-bounded values that follow a\n * label on the same line as other fields, where\n * `to-end-of-line` would over-capture. The pattern\n * is anchored to the start of the (already\n * leading-whitespace-stripped) value, so use\n * `(?:.*?)` prefix only when intentional.\n */\n type: \"match-pattern\";\n pattern: string;\n flags?: string;\n };\n\n/** Validation rules — closed discriminated union. */\nexport type TriggerValidation =\n | { type: \"starts-uppercase\" }\n | { type: \"min-length\"; min: number }\n | { type: \"max-length\"; max: number }\n | { type: \"no-digits\" }\n | { type: \"has-digits\" }\n | {\n type: \"matches-pattern\";\n pattern: string;\n flags?: string;\n }\n /**\n * Run a named stdnum validator (checksum + length)\n * against the captured value. Keeps the trigger\n * path symmetrical with the formatted-regex\n * detectors so e.g. `CPF nº 00000000000` does not\n * survive as a tax-ID entity.\n */\n | { type: \"valid-id\"; validator: ValidIdValidator };\n\n/** Built-in stdnum validators that can be referenced\n * by `valid-id` validations. */\nexport type ValidIdValidator = \"br.cpf\" | \"br.cnpj\" | \"us.rtn\";\n\n/** Auto-generated trigger variants — closed set. */\nexport type TriggerExtension =\n | \"add-colon\"\n | \"add-trailing-space\"\n | \"add-colon-space\"\n | \"normalize-spaces\";\n\n/** V2 trigger config entry (JSON shape). */\nexport type TriggerGroupConfig = {\n id?: string;\n triggers: string[];\n label: string;\n strategy: TriggerStrategy;\n extensions?: TriggerExtension[];\n validations?: TriggerValidation[];\n /** When true, include the trigger text in the\n * entity span (e.g., court names). */\n includeTrigger?: boolean;\n};\n\n/** Compiled validation with pre-built regex. */\nexport type CompiledValidation =\n | { type: \"starts-uppercase\"; re: RegExp }\n | { type: \"min-length\"; min: number }\n | { type: \"max-length\"; max: number }\n | { type: \"no-digits\"; re: RegExp }\n | { type: \"has-digits\"; re: RegExp }\n | { type: \"matches-pattern\"; re: RegExp }\n | {\n type: \"valid-id\";\n validator: ValidIdValidator;\n check: (value: string) => boolean;\n };\n\n/**\n * Runtime rule — one per trigger string after\n * expansion. Fed to the Aho-Corasick automaton.\n */\nexport type TriggerRule = {\n trigger: string;\n label: string;\n strategy: TriggerStrategy;\n validations: CompiledValidation[];\n includeTrigger: boolean;\n};\n\nexport {\n ENTITY_CAPABILITIES,\n ENTITY_LABELS,\n ENTITY_SELECTIONS,\n OPERATOR_TYPES,\n type DefaultEntityLabel,\n type EntityCapability,\n type EntityLabel,\n type EntitySelection,\n type OperatorType,\n} from \"./constants\";\n\n/** Per-label operator selection. Key is the entity label. */\nexport type MaskDirection = \"start\" | \"end\";\n\nexport type MaskOperatorConfig = {\n type: \"mask\";\n maskingCharacter: string;\n charactersToMask: number;\n direction: MaskDirection;\n};\n\nexport type OperatorSelection =\n | Exclude<OperatorType, \"mask\">\n | MaskOperatorConfig;\n\nexport type OperatorConfig = {\n /** Operator per label. Missing labels default to \"replace\". */\n operators: Record<string, OperatorSelection>;\n /** Custom replacement string for the redact operator. */\n redactString: string;\n};\n\n/** Whether an operator produces a reversible redaction entry. */\ntype OperatorReversibility = \"reversible\" | \"irreversible\" | \"preserving\";\n\nexport type AnonymisationOperator = {\n type: OperatorType;\n reversibility: OperatorReversibility;\n /**\n * Apply the operator to a single entity occurrence.\n * Returns the replacement string to embed in the document.\n */\n apply: (\n text: string,\n label: string,\n placeholder: string,\n redactString: string,\n selection: OperatorSelection,\n ) => string;\n};\n\n/**\n * Redacted document output with stable entity mapping.\n */\nexport type RedactionResult = {\n redactedText: string;\n /**\n * Maps placeholder to original text. Only populated for\n * reversible operators (replace). Empty for redact, keep, and mask.\n */\n redactionMap: Map<string, string>;\n /** Maps placeholder to the operator that produced it. */\n operatorMap: Map<string, OperatorType>;\n entityCount: number;\n};\n\n/**\n * Configuration for the detection pipeline.\n */\nexport type DenyListCategory =\n | \"Names\"\n | \"Places\"\n | \"Addresses\"\n | \"Courts\"\n | \"Financial\"\n | \"Government\"\n | \"Healthcare\"\n | \"Education\"\n | \"Political\"\n | \"Organizations\"\n | \"International\";\n\n/**\n * Metadata for a single dictionary entry in the\n * deny-list system. Mirrors the shape from\n * the anonymize-data package so consumers can pass\n * pre-loaded data without a runtime dependency.\n */\nexport type DictionaryMeta = {\n label: string;\n category: DenyListCategory;\n country: string | null;\n};\n\n/**\n * Caller-supplied exact terms for deny-list matching.\n * These entries are merged with the published deny-list\n * dictionaries when `enableDenyList` is enabled.\n */\nexport type CustomDenyListEntry = {\n value: string;\n label: string;\n variants?: readonly string[];\n};\n\n/**\n * Caller-supplied regex detector. The pattern is passed\n * to the native Rust regex engine, so use its supported\n * regex syntax. Inline flags such as `(?i)` are accepted\n * when supported by that engine.\n */\nexport type CustomRegexPattern = {\n pattern: string;\n label: string;\n score?: number;\n preparedArtifactPolicy?: \"include\" | \"omit\";\n};\n\n/**\n * Pre-loaded dictionary data for dependency injection.\n * Consumers that want name/city/deny-list detection\n * load dictionaries themselves (e.g. from the\n * anonymize-data package) and pass them here; the\n * anonymize package has zero cross-package imports.\n *\n * All fields are optional. When a field is absent,\n * the corresponding detection path is skipped (same\n * behavior as when no dictionaries are available).\n */\nexport type Dictionaries = {\n /**\n * First names per language code (e.g., \"cs\", \"de\").\n */\n firstNames?: Readonly<Record<string, readonly string[]>>;\n /**\n * Surnames per language code.\n */\n surnames?: Readonly<Record<string, readonly string[]>>;\n /**\n * Non-Western name tokens per locale code\n * (e.g., \"in\", \"ar\", \"ja-latn\", \"ko\", \"zh-latn\",\n * \"th\", \"vi\", \"fil\", \"id\"). Merged with bundled\n * names-nw-*.json data at init time.\n */\n nonWesternNames?: Readonly<Record<string, readonly string[]>>;\n /**\n * Pre-loaded deny-list dictionaries keyed by\n * dictionary ID (e.g., \"courts/CZ\", \"banks/DE\").\n * Each value is the array of terms for that\n * dictionary.\n */\n denyList?: Readonly<Record<string, readonly string[]>>;\n /**\n * Metadata per dictionary ID. Required when\n * `denyList` is provided so the pipeline knows\n * labels, categories, and country filters.\n */\n denyListMeta?: Readonly<Record<string, DictionaryMeta>>;\n /**\n * Pre-loaded city names, already merged across\n * all desired countries.\n *\n * Prefer `citiesByCountry` when callers also pass\n * `denyListCountries` / `denyListRegions`; merged\n * city arrays cannot be scoped after injection.\n */\n cities?: readonly string[];\n /**\n * Pre-loaded city names keyed by ISO 3166-1 alpha-2\n * country code. When provided, the deny-list builder\n * applies `denyListCountries` / `denyListRegions`\n * before adding city patterns to the search automaton.\n */\n citiesByCountry?: Readonly<Record<string, readonly string[]>>;\n};\n\n/**\n * Street-address detection without a known-city anchor.\n */\nexport type StandaloneStreetDetection = \"off\" | \"houseNumberAnchored\";\n\nexport type PipelineConfig = {\n threshold: number;\n enableTriggerPhrases: boolean;\n enableRegex: boolean;\n /**\n * Expected content language codes. When present, these\n * derive default dictionary scopes for name corpus and\n * deny-list matching unless the lower-level scope fields\n * below are set explicitly.\n */\n languages?: string[];\n /**\n * Convenience form for single-language documents. Ignored\n * when `languages` is also provided.\n */\n language?: string;\n /**\n * Enables legal-form organization detection.\n * Required for typed callers; legacy untyped\n * callers that omit this field are treated as\n * enabled at runtime for backward compatibility.\n */\n enableLegalForms: boolean;\n /**\n * Enables first-name/surname/title corpus matching.\n * When deny-list mode is enabled, this also controls\n * whether name-corpus entries are injected into the\n * deny-list search automaton.\n */\n enableNameCorpus: boolean;\n /**\n * Optional language scope for first-name/surname\n * dictionaries, using the keys present in\n * `dictionaries.firstNames` / `dictionaries.surnames`\n * (for example `[\"en\", \"de\"]`). When omitted, all\n * injected name languages are used for backward\n * compatibility.\n */\n nameCorpusLanguages?: string[];\n enableDenyList: boolean;\n denyListCountries?: string[];\n denyListRegions?: string[];\n denyListExcludeCategories?: string[];\n /**\n * Caller-owned exact terms to match through the\n * deny-list layer. Requires `enableDenyList: true`.\n */\n customDenyList?: readonly CustomDenyListEntry[];\n /**\n * Caller-owned regex detectors. Requires\n * `enableRegex: true`.\n */\n customRegexes?: readonly CustomRegexPattern[];\n enableGazetteer: boolean;\n /**\n * Detect country names (ISO 3166-1 names, curated\n * aliases, alpha-3 codes). Defaults to true. Names\n * span all manifest languages plus widely-used\n * additions (Dutch, Russian, Chinese, Arabic, etc.).\n */\n enableCountries?: boolean;\n enableConfidenceBoost: boolean;\n enableCoreference: boolean;\n enableZoneClassification?: boolean;\n enableHotwordRules?: boolean;\n /**\n * Detect a street address that carries no known-city\n * anchor. Defaults to `\"off\"`.\n *\n * `\"houseNumberAnchored\"` accepts a street-type word\n * with a house number directly beside it, in either\n * order (\"14 Rue de la Paix\", \"Hauptstraße 5\",\n * \"123 Main Street\"). A bare street name with no\n * number never fires.\n *\n * A street-type word plus a nearby number is a much\n * weaker signal than a city-anchored address and does\n * fire on contract prose (\"District Court 2019\"), so\n * this stays opt-in per workspace.\n */\n standaloneStreetDetection?: StandaloneStreetDetection;\n /**\n * Requested output labels. An empty array means\n * \"do not filter by label\" for deterministic detectors.\n */\n labels: string[];\n workspaceId: string;\n /**\n * Pre-loaded dictionary data for name, deny-list,\n * and city detection. When omitted, dictionary-based\n * detection paths are skipped. Consumers load from\n * the anonymize-data package and pass the data here.\n */\n dictionaries?: Dictionaries;\n};\n\nexport { DEFAULT_ENTITY_LABELS } from \"./constants\";\n\nexport const isLegalFormsEnabled = (\n config: Pick<PipelineConfig, \"enableLegalForms\">,\n): boolean => config.enableLegalForms !== false;\n","const normalizeLanguageCode = (language: string): string =>\n language.trim().toLowerCase();\n\nconst normalizeLanguageSelection = (\n languages: readonly string[] | undefined,\n): string[] =>\n languages === undefined\n ? []\n : languages\n .map(normalizeLanguageCode)\n .filter((language) => language.length > 0);\n\nexport const languageSelectionKey = (\n languages: readonly string[] | undefined,\n): string => {\n const normalized = normalizeLanguageSelection(languages).toSorted();\n return normalized.length === 0 ? \"*\" : normalized.join(\",\");\n};\n\nconst baseLanguage = (language: string): string => {\n const index = language.indexOf(\"-\");\n return index === -1 ? language : language.slice(0, index);\n};\n\nexport const languageConfigMatches = (\n configLanguage: string,\n selectedLanguages: readonly string[] | undefined,\n): boolean => {\n if (selectedLanguages === undefined || selectedLanguages.length === 0) {\n return true;\n }\n const normalizedSelectedLanguages =\n normalizeLanguageSelection(selectedLanguages);\n if (normalizedSelectedLanguages.length === 0) {\n return true;\n }\n\n const normalizedConfigLanguage = normalizeLanguageCode(configLanguage);\n if (normalizedConfigLanguage.length === 0) {\n return false;\n }\n\n const genericConfig =\n baseLanguage(normalizedConfigLanguage) === normalizedConfigLanguage;\n for (const normalizedLanguage of normalizedSelectedLanguages) {\n if (normalizedLanguage === normalizedConfigLanguage) {\n return true;\n }\n if (\n genericConfig &&\n baseLanguage(normalizedLanguage) === normalizedConfigLanguage\n ) {\n return true;\n }\n }\n\n return false;\n};\n","import {\n isLegalFormsEnabled,\n type GazetteerEntry,\n type PipelineConfig,\n} from \"./types\";\nimport { languageSelectionKey } from \"./util/language-selection\";\n\nconst DEFAULT_CUSTOM_REGEX_SCORE = 0.9;\n\nconst contentLanguageFingerprint = (\n config: Pick<PipelineConfig, \"language\" | \"languages\">,\n): string => {\n const languages =\n config.languages ??\n (config.language === undefined ? [] : [config.language]);\n return languageSelectionKey(languages);\n};\n\nexport const pipelineConfigKey = (\n config: PipelineConfig,\n gazetteerEntries: readonly GazetteerEntry[],\n): string => {\n const legalFormsEnabled = isLegalFormsEnabled(config);\n const customDenyFingerprint =\n config.enableDenyList && config.customDenyList\n ? config.customDenyList\n .map((entry) =>\n JSON.stringify({\n label: entry.label,\n value: entry.value,\n variants: [...(entry.variants ?? [])].sort(),\n }),\n )\n .sort()\n .join(\"\\n\")\n : \"\";\n const customRegexFingerprint =\n config.enableRegex && config.customRegexes\n ? config.customRegexes\n .map((entry) =>\n JSON.stringify({\n label: entry.label,\n pattern: entry.pattern,\n preparedArtifactPolicy: entry.preparedArtifactPolicy ?? null,\n score: entry.score ?? DEFAULT_CUSTOM_REGEX_SCORE,\n }),\n )\n .sort()\n .join(\"\\n\")\n : \"\";\n const gazFingerprint =\n config.enableGazetteer && gazetteerEntries.length > 0\n ? gazetteerEntries\n .map(\n (entry) =>\n `${entry.id}:${entry.canonical}:${entry.label}:${[\n ...entry.variants,\n ]\n .sort()\n .join(\",\")}`,\n )\n .toSorted()\n .join(\";\")\n : \"\";\n\n return (\n `${config.enableDenyList}:` +\n `${config.enableTriggerPhrases}:` +\n `${legalFormsEnabled}:` +\n `${config.enableNameCorpus}:` +\n `${contentLanguageFingerprint(config)}:` +\n `${config.nameCorpusLanguages?.toSorted().join(\",\") ?? \"\"}:` +\n `${config.enableRegex}:` +\n `${config.threshold}:` +\n `${config.enableConfidenceBoost}:` +\n `${config.enableHotwordRules === true}:` +\n `${config.enableCoreference === true}:` +\n `${config.enableZoneClassification === true}:` +\n `${config.labels.toSorted().join(\",\")}:` +\n `${config.denyListCountries?.toSorted().join(\",\") ?? \"\"}:` +\n `${config.denyListRegions?.toSorted().join(\",\") ?? \"\"}:` +\n `${config.denyListExcludeCategories?.toSorted().join(\",\") ?? \"\"}:` +\n `${customDenyFingerprint}:` +\n `${customRegexFingerprint}:` +\n `${config.enableGazetteer}:${gazFingerprint}:` +\n `${config.enableCountries !== false}:` +\n `${config.standaloneStreetDetection ?? \"off\"}`\n );\n};\n","import type { PipelineContext } from \"./context\";\nimport { defaultContext } from \"./context\";\nimport { applyPipelineLanguageScope } from \"./language-scope\";\nimport type { NativePreparedSearchConfig } from \"./native-search-config\";\nimport { pipelineConfigKey } from \"./pipeline-cache-key\";\nimport type { Dictionaries, GazetteerEntry, PipelineConfig } from \"./types\";\nimport {\n createNativePipelineFromPackage,\n PreparedNativePipeline,\n type NativeAnonymizeBinding,\n} from \"./native\";\n\nexport {\n PreparedNativePipeline,\n createNativePipelineFromPackage,\n} from \"./native\";\n\nexport type NativePipelineUnsupportedFeature = \"enableNer\";\n\nexport type NativePipelineCompatibility =\n | { status: \"supported\" }\n | {\n status: \"unsupported\";\n unsupportedFeatures: NativePipelineUnsupportedFeature[];\n };\n\nexport type NativePipelineBuildOptions = {\n binding: NativeAnonymizeBinding;\n config: PipelineConfig;\n gazetteerEntries?: GazetteerEntry[];\n context?: PipelineContext;\n};\n\nexport type NativePipelinePackageOptions = NativePipelineBuildOptions & {\n compressed?: boolean;\n};\n\nexport type { NativePipelineFromPackageOptions } from \"./native\";\n\ntype NativePipelinePackageCacheValue = Promise<Uint8Array> | Uint8Array;\n\n// Bounds each shared package cache (the dictionary-less bucket below, and\n// each per-`Dictionaries` bucket handed out by `sharedPackageCacheFor`) to a\n// fixed number of entries. `nativePackageCacheKey` fingerprints\n// caller-suppliable config (custom deny lists, custom regexes, gazetteer\n// entries) via `pipelineConfigKey`, so without a cap a caller that varies\n// those fields grows a bucket — and the multi-MB assembled packages it\n// holds — without limit.\nexport const SHARED_PACKAGE_CACHE_MAX_ENTRIES = 32;\n\nconst sharedPackageByDictionaries = new WeakMap<\n Dictionaries,\n Map<string, NativePipelinePackageCacheValue>\n>();\nconst sharedPackageWithoutDictionaries = new Map<\n string,\n NativePipelinePackageCacheValue\n>();\nconst dictionaryCacheIds = new WeakMap<Dictionaries, number>();\nlet nextDictionaryCacheId = 0;\n\n/** Record `key` as most-recently-used in `cache`, evicting the\n * least-recently-used entry first once the cache is at capacity. A `Map`'s\n * insertion order doubles as recency order here: touching an existing key\n * deletes then re-sets it to move it to the end, and eviction drops the\n * first (oldest) key.\n *\n * Evicting a still-in-flight build only drops the cache's reference to its\n * promise; the caller that started the build (and any concurrent caller that\n * already read the promise before eviction) still resolves it correctly via\n * the guarded `sharedCache.get(key) === promise` checks in\n * `getCachedNativePipelinePackage`. A later caller for the same key just\n * misses the dedupe and starts a fresh build — bounded memory takes priority\n * over perfect dedupe under cache pressure. */\nconst touchSharedPackageCacheEntry = (\n cache: Map<string, NativePipelinePackageCacheValue>,\n key: string,\n value: NativePipelinePackageCacheValue,\n): void => {\n cache.delete(key);\n if (cache.size >= SHARED_PACKAGE_CACHE_MAX_ENTRIES) {\n const oldestKey = cache.keys().next().value;\n if (oldestKey !== undefined) {\n cache.delete(oldestKey);\n }\n }\n cache.set(key, value);\n};\n\nconst dictionaryCacheKey = (dictionaries: Dictionaries | undefined): string => {\n if (dictionaries === undefined) {\n return \"none\";\n }\n const existing = dictionaryCacheIds.get(dictionaries);\n if (existing !== undefined) {\n return `dict:${existing}`;\n }\n nextDictionaryCacheId += 1;\n dictionaryCacheIds.set(dictionaries, nextDictionaryCacheId);\n return `dict:${nextDictionaryCacheId}`;\n};\n\nconst sharedPackageCacheFor = (\n dictionaries: Dictionaries | undefined,\n): Map<string, NativePipelinePackageCacheValue> => {\n if (dictionaries === undefined) {\n return sharedPackageWithoutDictionaries;\n }\n const cached = sharedPackageByDictionaries.get(dictionaries);\n if (cached !== undefined) {\n return cached;\n }\n const created = new Map<string, NativePipelinePackageCacheValue>();\n sharedPackageByDictionaries.set(dictionaries, created);\n return created;\n};\n\nexport const getNativePipelineCompatibility = (\n config: PipelineConfig,\n): NativePipelineCompatibility => {\n const unsupportedFeatures: NativePipelineUnsupportedFeature[] = [];\n\n // `enableNer` is no longer part of `PipelineConfig`; untyped callers that\n // still request it (any truthy value, e.g. `1` or `\"true\"` from loose\n // JSON) must fail fast instead of silently losing NER spans.\n if (\"enableNer\" in config && Boolean(config.enableNer)) {\n unsupportedFeatures.push(\"enableNer\");\n }\n if (unsupportedFeatures.length === 0) {\n return { status: \"supported\" };\n }\n return { status: \"unsupported\", unsupportedFeatures };\n};\n\nexport const assertNativePipelineSupported = (config: PipelineConfig): void => {\n const compatibility = getNativePipelineCompatibility(config);\n if (compatibility.status === \"supported\") {\n return;\n }\n throw new Error(\n `Native pipeline does not yet support: ${compatibility.unsupportedFeatures.join(\", \")}`,\n );\n};\n\nconst encoder = new TextEncoder();\n\ntype AssembleInputs = {\n pipelineConfigJson: Uint8Array;\n dictionariesJson: Uint8Array | undefined;\n gazetteerJson: Uint8Array | undefined;\n};\n\n/**\n * Serialize the assembler inputs the Rust binding expects. Dictionaries are\n * stripped from the pipeline config and passed out of band: the assembler reads\n * the separate bundle preferentially, and keeping the (large) dictionaries out\n * of the config JSON avoids serializing them twice.\n */\nconst toAssembleInputs = (\n { dictionaries, ...config }: PipelineConfig,\n gazetteerEntries: readonly GazetteerEntry[],\n): AssembleInputs => ({\n pipelineConfigJson: encoder.encode(JSON.stringify(config)),\n dictionariesJson:\n dictionaries === undefined\n ? undefined\n : encoder.encode(JSON.stringify(dictionaries)),\n gazetteerJson:\n gazetteerEntries.length === 0\n ? undefined\n : encoder.encode(JSON.stringify(gazetteerEntries)),\n});\n\nconst assemblePackageBytes = (\n binding: NativeAnonymizeBinding,\n { pipelineConfigJson, dictionariesJson, gazetteerJson }: AssembleInputs,\n compressed: boolean,\n): Uint8Array => {\n const assemble = compressed\n ? binding.assembleStaticSearchCompressedPackageBytes\n : binding.assembleStaticSearchPackageBytes;\n if (assemble === undefined) {\n throw new Error(\n \"Native anonymize binding does not support static-search config assembly\",\n );\n }\n return assemble(pipelineConfigJson, dictionariesJson, gazetteerJson);\n};\n\nexport const prepareNativePipelineConfig = async ({\n binding,\n config,\n gazetteerEntries = [],\n}: Omit<\n NativePipelineBuildOptions,\n \"context\"\n>): Promise<NativePreparedSearchConfig> => {\n const scopedConfig = applyPipelineLanguageScope(config);\n assertNativePipelineSupported(scopedConfig);\n const assemble = binding.assembleStaticSearchConfigJson;\n if (assemble === undefined) {\n throw new Error(\n \"Native anonymize binding does not support static-search config assembly\",\n );\n }\n const { pipelineConfigJson, dictionariesJson, gazetteerJson } =\n toAssembleInputs(scopedConfig, gazetteerEntries);\n const configJson = assemble(\n pipelineConfigJson,\n dictionariesJson,\n gazetteerJson,\n );\n return JSON.parse(new TextDecoder().decode(configJson));\n};\n\nexport const prepareNativePipelinePackage = async ({\n binding,\n config,\n gazetteerEntries = [],\n context,\n compressed = false,\n}: NativePipelinePackageOptions): Promise<Uint8Array> => {\n const packageBytes = await getCachedNativePipelinePackage({\n config,\n binding,\n gazetteerEntries,\n ...(context ? { context } : {}),\n compressed,\n });\n // Return a genuine copy: with the real NAPI binding packageBytes is a Node\n // Buffer, and Buffer.prototype.slice() yields a memory-sharing view, so a\n // caller mutating it would corrupt the shared cache and ctx.nativePipelinePackage.\n return new Uint8Array(packageBytes);\n};\n\nexport const createNativePipelineFromConfig = async ({\n binding,\n config,\n gazetteerEntries = [],\n context,\n}: NativePipelineBuildOptions): Promise<PreparedNativePipeline> => {\n const packageBytes = await getCachedNativePipelinePackage({\n binding,\n config,\n gazetteerEntries,\n ...(context ? { context } : {}),\n });\n return createNativePipelineFromPackage({ binding, packageBytes });\n};\n\nconst getCachedNativePipelinePackage = async ({\n binding,\n config,\n gazetteerEntries = [],\n context,\n compressed = false,\n}: NativePipelinePackageOptions): Promise<Uint8Array> => {\n const scopedConfig = applyPipelineLanguageScope(config);\n assertNativePipelineSupported(scopedConfig);\n const ctx = context ?? defaultContext;\n const key = nativePackageCacheKey({\n binding,\n config: scopedConfig,\n gazetteerEntries,\n compressed,\n });\n if (ctx.nativePipelinePackage && ctx.nativePipelinePackageKey === key) {\n return ctx.nativePipelinePackage;\n }\n if (\n ctx.nativePipelinePackagePromise &&\n ctx.nativePipelinePackageKey === key\n ) {\n return ctx.nativePipelinePackagePromise;\n }\n\n const sharedCache = sharedPackageCacheFor(scopedConfig.dictionaries);\n const shared = sharedCache.get(key);\n if (shared !== undefined) {\n touchSharedPackageCacheEntry(sharedCache, key, shared);\n const packageBytes = await shared;\n ctx.nativePipelinePackage = packageBytes;\n ctx.nativePipelinePackageKey = key;\n ctx.nativePipelinePackagePromise = null;\n return packageBytes;\n }\n\n ctx.nativePipelinePackage = null;\n ctx.nativePipelinePackageKey = key;\n const promise = buildNativePipelinePackage({\n binding,\n config: scopedConfig,\n gazetteerEntries,\n compressed,\n });\n ctx.nativePipelinePackagePromise = promise;\n touchSharedPackageCacheEntry(sharedCache, key, promise);\n let packageBytes: Uint8Array;\n try {\n packageBytes = await promise;\n } catch (error) {\n if (sharedCache.get(key) === promise) {\n sharedCache.delete(key);\n }\n if (\n ctx.nativePipelinePackageKey === key &&\n ctx.nativePipelinePackagePromise === promise\n ) {\n ctx.nativePipelinePackage = null;\n ctx.nativePipelinePackagePromise = null;\n }\n throw error;\n }\n if (sharedCache.get(key) === promise) {\n sharedCache.set(key, packageBytes);\n }\n if (ctx.nativePipelinePackageKey === key) {\n ctx.nativePipelinePackage = packageBytes;\n ctx.nativePipelinePackagePromise = null;\n }\n return packageBytes;\n};\n\n// `async` so the shared package cache can store the in-flight value and dedupe\n// concurrent builds for the same key, and so assembly failures (an older\n// binding without the assemble functions, or a config the assembler rejects)\n// surface as a rejected promise rather than a synchronous throw mid-cache-flow.\nconst buildNativePipelinePackage = async ({\n binding,\n config,\n gazetteerEntries,\n compressed,\n}: Required<\n Omit<NativePipelinePackageOptions, \"context\">\n>): Promise<Uint8Array> =>\n assemblePackageBytes(\n binding,\n toAssembleInputs(config, gazetteerEntries),\n compressed,\n );\n\ntype NativePackageCacheKeyOptions = {\n binding: NativeAnonymizeBinding;\n config: PipelineConfig;\n gazetteerEntries: readonly GazetteerEntry[];\n compressed: boolean;\n};\n\nconst nativePackageCacheKey = ({\n binding,\n config,\n gazetteerEntries,\n compressed,\n}: NativePackageCacheKeyOptions): string =>\n [\n binding.nativePackageVersion(),\n compressed ? \"compressed\" : \"raw\",\n dictionaryCacheKey(config.dictionaries),\n pipelineConfigKey(config, gazetteerEntries),\n ].join(\":\");\n","import { DEFAULT_ENTITY_LABELS } from \"./constants\";\nimport type { PipelineConfig } from \"./types\";\n\nexport const DEFAULT_NATIVE_PIPELINE_CONFIG: PipelineConfig = {\n threshold: 0.3,\n enableTriggerPhrases: true,\n enableRegex: true,\n enableLegalForms: true,\n enableNameCorpus: true,\n enableDenyList: true,\n enableGazetteer: false,\n enableCountries: true,\n enableConfidenceBoost: true,\n enableCoreference: true,\n enableHotwordRules: true,\n enableZoneClassification: true,\n standaloneStreetDetection: \"off\",\n labels: [...DEFAULT_ENTITY_LABELS],\n workspaceId: \"native-pipeline-default\",\n};\n","import languageScopes from \"./data/language-scopes.json\";\n\nexport type SupportedLanguage =\n | \"cs\"\n | \"de\"\n | \"en\"\n | \"es\"\n | \"fr\"\n | \"hu\"\n | \"it\"\n | \"lv\"\n | \"pl\"\n | \"pt-br\"\n | \"ro\"\n | \"sk\"\n | \"sv\";\n\nconst isSupportedLanguage = (language: string): language is SupportedLanguage =>\n Object.hasOwn(languageScopes.languages, language);\n\nexport const SUPPORTED_LANGUAGES = Object.freeze(\n Object.keys(languageScopes.languages).filter(isSupportedLanguage).toSorted(),\n);\n\nexport type PipelineLanguageSelection =\n | SupportedLanguage\n | readonly [SupportedLanguage, ...SupportedLanguage[]]\n | \"all\";\n\nexport type NormalizedPipelineLanguageSelection =\n | { type: \"all\" }\n | {\n type: \"languages\";\n languages: readonly [SupportedLanguage, ...SupportedLanguage[]];\n };\n\nconst normalizeLanguage = (language: unknown): SupportedLanguage => {\n if (typeof language !== \"string\") {\n throw new TypeError(\"Pipeline language codes must be strings\");\n }\n const normalized = language.trim().toLowerCase();\n if (!isSupportedLanguage(normalized)) {\n throw new RangeError(\n `Unsupported pipeline language ${JSON.stringify(language)}; expected one of: ${SUPPORTED_LANGUAGES.join(\", \")}`,\n );\n }\n return normalized;\n};\n\nexport const normalizePipelineLanguageSelection = (\n selection: PipelineLanguageSelection | undefined,\n): NormalizedPipelineLanguageSelection => {\n if (\n selection === undefined ||\n (typeof selection === \"string\" && selection.trim().toLowerCase() === \"all\")\n ) {\n return { type: \"all\" };\n }\n const requested = Array.isArray(selection) ? selection : [selection];\n if (requested.length === 0) {\n throw new RangeError(\"Pipeline language selection must not be empty\");\n }\n const normalized = [...new Set(requested.map(normalizeLanguage))].toSorted();\n const first = normalized.at(0);\n if (first === undefined) {\n throw new RangeError(\"Pipeline language selection must not be empty\");\n }\n return { type: \"languages\", languages: [first, ...normalized.slice(1)] };\n};\n\nexport const pipelineLanguageSelectionKey = (\n selection: NormalizedPipelineLanguageSelection,\n): string => (selection.type === \"all\" ? \"all\" : selection.languages.join(\",\"));\n","import type { Dictionaries, PipelineConfig } from \"./types\";\nimport type { NativeAnonymizeBinding, PreparedNativePipeline } from \"./native\";\nimport { defaultDictionaryBundleOptions } from \"./build-native-package\";\nimport { createNativePipelineFromConfig } from \"./native-pipeline\";\nimport { DEFAULT_NATIVE_PIPELINE_CONFIG } from \"./native-default-config\";\nimport { applyPipelineLanguageScope } from \"./language-scope\";\nimport {\n pipelineLanguageSelectionKey,\n type NormalizedPipelineLanguageSelection,\n} from \"./pipeline-language\";\n\ntype CreateSemanticPipelineOptions = {\n binding: NativeAnonymizeBinding;\n selection: NormalizedPipelineLanguageSelection;\n};\n\ntype AnonymizeDataModule = {\n loadDictionaryBundle: (options?: {\n countries?: readonly string[];\n cityCountries?: readonly string[];\n nameLanguages?: readonly string[];\n }) => Promise<Dictionaries>;\n};\n\nconst dictionaryCache = new Map<string, Promise<Dictionaries>>();\nconst semanticPipelineCache = new WeakMap<\n NativeAnonymizeBinding,\n Map<string, Promise<PreparedNativePipeline>>\n>();\nconst MAX_SEMANTIC_PIPELINE_CACHE_ENTRIES = 8;\n\nconst getCachedEntry = <Value>(\n cache: Map<string, Value>,\n key: string,\n): Value | undefined => {\n const cached = cache.get(key);\n if (cached === undefined) {\n return undefined;\n }\n cache.delete(key);\n cache.set(key, cached);\n return cached;\n};\n\nconst setCachedEntry = <Value>(\n cache: Map<string, Value>,\n key: string,\n value: Value,\n): void => {\n cache.set(key, value);\n if (cache.size <= MAX_SEMANTIC_PIPELINE_CACHE_ENTRIES) {\n return;\n }\n const oldestKey = cache.keys().next().value;\n if (oldestKey !== undefined) {\n cache.delete(oldestKey);\n }\n};\n\nconst loadSemanticDictionaries = (\n key: string,\n config: PipelineConfig,\n): Promise<Dictionaries> => {\n const cached = getCachedEntry(dictionaryCache, key);\n if (cached !== undefined) {\n return cached;\n }\n // Keep dictionary chunks out of the default-package import path. Bundlers\n // load only the chunks needed to assemble an unbundled semantic scope.\n let dictionaries: Promise<Dictionaries>;\n dictionaries = import(\"@stll/anonymize-data/cities\")\n .then(({ loadDictionaryBundle }: AnonymizeDataModule) =>\n loadDictionaryBundle(defaultDictionaryBundleOptions(config)),\n )\n .catch((error: unknown) => {\n if (dictionaryCache.get(key) === dictionaries) {\n dictionaryCache.delete(key);\n }\n throw error;\n });\n setCachedEntry(dictionaryCache, key, dictionaries);\n return dictionaries;\n};\n\nconst pipelineConfigFor = (\n selection: NormalizedPipelineLanguageSelection,\n): PipelineConfig => {\n if (selection.type === \"all\") {\n return {\n ...DEFAULT_NATIVE_PIPELINE_CONFIG,\n labels: [...DEFAULT_NATIVE_PIPELINE_CONFIG.labels],\n };\n }\n const [language, ...languages] = selection.languages;\n return applyPipelineLanguageScope({\n ...DEFAULT_NATIVE_PIPELINE_CONFIG,\n labels: [...DEFAULT_NATIVE_PIPELINE_CONFIG.labels],\n workspaceId: `default-pipeline:${pipelineLanguageSelectionKey(selection)}`,\n ...(languages.length === 0\n ? { language }\n : { languages: [language, ...languages] }),\n });\n};\n\nconst semanticPipelineCacheFor = (\n binding: NativeAnonymizeBinding,\n): Map<string, Promise<PreparedNativePipeline>> => {\n const cached = semanticPipelineCache.get(binding);\n if (cached !== undefined) {\n return cached;\n }\n const created = new Map<string, Promise<PreparedNativePipeline>>();\n semanticPipelineCache.set(binding, created);\n return created;\n};\n\nexport const createSemanticPipeline = ({\n binding,\n selection,\n}: CreateSemanticPipelineOptions): Promise<PreparedNativePipeline> => {\n const key = pipelineLanguageSelectionKey(selection);\n const cache = semanticPipelineCacheFor(binding);\n const cached = getCachedEntry(cache, key);\n if (cached !== undefined) {\n return cached;\n }\n const config = pipelineConfigFor(selection);\n let pipeline: Promise<PreparedNativePipeline>;\n pipeline = loadSemanticDictionaries(key, config)\n .then((dictionaries) =>\n createNativePipelineFromConfig({\n binding,\n config: { ...config, dictionaries },\n }),\n )\n .catch((error: unknown) => {\n if (cache.get(key) === pipeline) {\n cache.delete(key);\n }\n throw error;\n });\n setCachedEntry(cache, key, pipeline);\n return pipeline;\n};\n","import { createRequire } from \"node:module\";\nimport { existsSync, readFileSync, readdirSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport process from \"node:process\";\nimport { loadNativeBinding as loadDefaultPlatformNativePackage } from \"../index.cjs\";\n\nimport {\n assertNativeBindingVersion,\n createNativePipelineFromPackage,\n isNativeAnonymizeBinding,\n type NativeOperatorConfig,\n type NativeAnonymizeBinding,\n type NativeNormalizeOptions,\n type NativeSearchPackageInput,\n PreparedNativeAnonymizer,\n PreparedNativePipeline,\n type NativeStaticRedactionResult,\n diagnostics_json as diagnosticsJsonWithBinding,\n convert_external_detection_batch as convertExternalDetectionBatchWithBinding,\n diagnostics_stream_json as diagnosticsStreamJsonWithBinding,\n load_prepared_package as loadPreparedPackageWithBinding,\n native_package_version as nativePackageVersionWithBinding,\n normalize_for_search as normalizeForSearchWithBinding,\n prepare_search_package as prepareSearchPackageWithBinding,\n redact_text as redactTextWithBinding,\n redact_text_json as redactTextJsonWithBinding,\n redact_text_stream_json as redactTextStreamJsonWithBinding,\n summary_diagnostics_json as summaryDiagnosticsJsonWithBinding,\n} from \"./native\";\nimport { assertSupportedBunRuntime } from \"./bun-version\";\nimport { createSemanticPipeline } from \"./create-pipeline\";\nimport {\n normalizePipelineLanguageSelection,\n type PipelineLanguageSelection,\n} from \"./pipeline-language\";\n\nexport { SUPPORTED_LANGUAGES } from \"./pipeline-language\";\nexport type {\n PipelineLanguageSelection,\n SupportedLanguage,\n} from \"./pipeline-language\";\n\nexport * from \"./native\";\nexport {\n assertNativePipelineSupported,\n createNativePipelineFromConfig,\n getNativePipelineCompatibility,\n prepareNativePipelineConfig,\n prepareNativePipelinePackage,\n} from \"./native-pipeline\";\nexport type {\n NativePipelineBuildOptions,\n NativePipelineCompatibility,\n NativePipelinePackageOptions,\n NativePipelineUnsupportedFeature,\n} from \"./native-pipeline\";\n\nexport type NativeRequire = (specifier: string) => unknown;\n\nexport type NativeLibc = \"gnu\" | \"musl\";\n\nexport type LoadNativeBindingOptions = {\n expectedVersion?: string;\n platform?: string;\n arch?: string;\n libc?: NativeLibc;\n env?: Record<string, string | undefined>;\n requireModule?: NativeRequire;\n};\n\nexport type NativePipelinePackageFileOptions = LoadNativeBindingOptions & {\n binding?: NativeAnonymizeBinding;\n packagePath: string;\n};\n\nexport type NativeSdkOptions = LoadNativeBindingOptions & {\n binding?: NativeAnonymizeBinding;\n};\n\nexport type NativeSdkPackageOptions = NativeSdkOptions & {\n compressed?: boolean;\n};\n\nexport type CreatePipelineOptions = NativeSdkOptions & {\n language?: PipelineLanguageSelection;\n warmup?: DefaultNativePipelineWarmup;\n};\n\nexport type DefaultNativePipelinePackageOptions = LoadNativeBindingOptions & {\n binding?: NativeAnonymizeBinding;\n language?: string;\n packagePath?: string;\n warmup?: DefaultNativePipelineWarmup;\n};\n\ntype ResolvedDefaultNativePipelineOptions = {\n binding: NativeAnonymizeBinding;\n language?: string;\n packagePath?: string;\n warmup: DefaultNativePipelineWarmup;\n};\n\nexport const DEFAULT_NATIVE_PIPELINE_WARMUPS = {\n lazyRegex: \"lazy-regex\",\n none: \"none\",\n} as const;\n\nexport type DefaultNativePipelineWarmup =\n (typeof DEFAULT_NATIVE_PIPELINE_WARMUPS)[keyof typeof DEFAULT_NATIVE_PIPELINE_WARMUPS];\n\nexport type DefaultNativePipelinePackageFileOptions = {\n language?: string;\n};\n\nconst PACKAGE_SPECIFIC_NATIVE_PATH = \"STELLA_ANONYMIZE_NATIVE_LIBRARY_PATH\";\nconst DEFAULT_NATIVE_PIPELINE_PACKAGE_URL = new URL(\n \"../native-pipeline.stlanonpkg\",\n import.meta.url,\n);\nconst DEFAULT_NATIVE_PIPELINE_PACKAGE_DIR_URL = new URL(\"../\", import.meta.url);\nconst DEFAULT_NATIVE_PIPELINE_LANGUAGE_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;\nconst DEFAULT_NATIVE_PIPELINE_LANGUAGE_PACKAGE_PATTERN =\n /^native-pipeline\\.([a-z0-9]+(?:-[a-z0-9]+)*)\\.stlanonpkg$/u;\nconst DEFAULT_NATIVE_PIPELINE_PACKAGE_CACHE_KEY = \"<default>\";\nconst defaultNativePipelineCache = new WeakMap<\n NativeAnonymizeBinding,\n Map<string, PreparedNativePipeline>\n>();\nconst warmedDefaultNativePipelines = new WeakSet<PreparedNativePipeline>();\nconst defaultNativePipelineInflightCache = new WeakMap<\n NativeAnonymizeBinding,\n Map<string, Promise<PreparedNativePipeline>>\n>();\n\nexport { DEFAULT_NATIVE_PIPELINE_CONFIG } from \"./native-default-config\";\n\n/**\n * An explicit binding override for embedded runtimes and tests. Undefined by\n * default, so Node.js and Bun load their platform N-API package.\n */\nlet nativeBindingOverride: NativeAnonymizeBinding | undefined;\n\nexport const setNativeBindingOverride = (\n binding: NativeAnonymizeBinding | undefined,\n): void => {\n nativeBindingOverride = binding;\n};\n\nexport const loadNativeAnonymizeBinding = (\n options: LoadNativeBindingOptions = {},\n): NativeAnonymizeBinding => {\n assertSupportedBunRuntime();\n if (nativeBindingOverride !== undefined) {\n if (options.expectedVersion !== undefined) {\n assertNativeBindingVersion({\n binding: nativeBindingOverride,\n expectedVersion: options.expectedVersion,\n });\n }\n return nativeBindingOverride;\n }\n const requireModule = options.requireModule ?? createRequire(import.meta.url);\n const platform = options.platform ?? process.platform;\n const arch = options.arch ?? process.arch;\n const libc = options.libc ?? detectNativeLibc(platform);\n const env = options.env ?? process.env;\n const specifiers = nativeBindingSpecifiers({ arch, env, libc, platform });\n const platformPackage = nativeBindingPackageName({ arch, libc, platform });\n const errors: string[] = [];\n\n for (const specifier of specifiers) {\n const loadModule =\n options.requireModule === undefined &&\n specifier === platformPackage &&\n isHostNativeTarget({ arch, libc, platform })\n ? loadDefaultPlatformNativePackage\n : () => requireModule(specifier);\n const binding = tryLoadNativeBinding({\n specifier,\n loadModule,\n errors,\n });\n if (!binding) {\n continue;\n }\n if (options.expectedVersion !== undefined) {\n assertNativeBindingVersion({\n binding,\n expectedVersion: options.expectedVersion,\n });\n }\n return binding;\n }\n\n if (nativeBindingPackageName({ arch, libc, platform }) === null) {\n throw unsupportedNativeTargetError({ arch, errors, libc, platform });\n }\n throw new Error(\n `Unable to load native anonymize binding for ${platform}/${arch}:\\n${errors.join(\"\\n\")}`,\n );\n};\n\nexport const readNativePipelinePackageFile = (\n packagePath: string,\n): Uint8Array => readFileSync(packagePath);\n\nexport const readNativePipelinePackageFileAsync = async (\n packagePath: string,\n): Promise<Uint8Array> => readFile(packagePath);\n\nexport const native_package_version = (\n options: NativeSdkOptions = {},\n): string => nativePackageVersionWithBinding(resolveNativeSdkBinding(options));\n\nexport const convert_external_detection_batch = (\n document: Uint8Array,\n batch: import(\"./native\").ExternalDetectionBatch | string,\n options: NativeSdkOptions = {},\n): import(\"./native\").NativeCallerDetection[] =>\n convertExternalDetectionBatchWithBinding({\n binding: resolveNativeSdkBinding(options),\n document,\n batch,\n });\n\nexport const normalize_for_search = (\n text: string,\n options: NativeSdkOptions = {},\n): string => {\n const args: NativeNormalizeOptions = {\n binding: resolveNativeSdkBinding(options),\n text,\n };\n return normalizeForSearchWithBinding(args);\n};\n\nexport const prepare_search_package = (\n config: NativeSearchPackageInput,\n { compressed = false, ...options }: NativeSdkPackageOptions = {},\n): Uint8Array =>\n prepareSearchPackageWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n compressed,\n });\n\nexport const load_prepared_package = (\n packageBytes: Uint8Array,\n options: NativeSdkOptions = {},\n) =>\n loadPreparedPackageWithBinding({\n binding: resolveNativeSdkBinding(options),\n packageBytes,\n });\n\nexport const load_prepared_package_file = (\n packagePath: string,\n options: NativeSdkOptions = {},\n) => load_prepared_package(readNativePipelinePackageFile(packagePath), options);\n\nexport const redact_text = (\n config: NativeSearchPackageInput,\n fullText: string,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): NativeStaticRedactionResult =>\n redactTextWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const redact_text_json = (\n config: NativeSearchPackageInput,\n fullText: string,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): string =>\n redactTextJsonWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const redact_text_stream_json = (\n config: NativeSearchPackageInput,\n fullText: string,\n onEvent: (eventJson: string) => void,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): string =>\n redactTextStreamJsonWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n onEvent,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const diagnostics_json = (\n config: NativeSearchPackageInput,\n fullText: string,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): string =>\n diagnosticsJsonWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const diagnostics_stream_json = (\n config: NativeSearchPackageInput,\n fullText: string,\n onBatch: (diagnosticsJson: string) => void,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): string =>\n diagnosticsStreamJsonWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n onBatch,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const summary_diagnostics_json = (\n config: NativeSearchPackageInput,\n fullText: string,\n operators?: NativeOperatorConfig,\n options: NativeSdkOptions = {},\n): string =>\n summaryDiagnosticsJsonWithBinding({\n binding: resolveNativeSdkBinding(options),\n config,\n fullText,\n ...(operators !== undefined ? { operators } : {}),\n });\n\nexport const readDefaultNativePipelinePackageFile = ({\n language,\n}: DefaultNativePipelinePackageFileOptions = {}): Uint8Array => {\n const packageUrl = defaultNativePipelinePackageUrl(language);\n try {\n return readFileSync(packageUrl);\n } catch (error) {\n throw new Error(\n `${defaultNativePipelinePackageDescription(language)} is unavailable: ${formatLoadError(error)}`,\n );\n }\n};\n\nexport const read_default_native_pipeline_package_file = (\n options: DefaultNativePipelinePackageFileOptions = {},\n): Uint8Array => readDefaultNativePipelinePackageFile(options);\n\nexport const availableDefaultNativePipelineLanguages = (): string[] => {\n const languages = new Set<string>();\n try {\n for (const fileName of readdirSync(\n DEFAULT_NATIVE_PIPELINE_PACKAGE_DIR_URL,\n )) {\n const match = fileName.match(\n DEFAULT_NATIVE_PIPELINE_LANGUAGE_PACKAGE_PATTERN,\n );\n if (match?.[1] !== undefined) {\n languages.add(match[1]);\n }\n }\n } catch (error) {\n throw new Error(\n `Default native pipeline package directory is unavailable: ${formatLoadError(error)}`,\n );\n }\n return [...languages].toSorted();\n};\n\nexport const available_default_native_pipeline_languages =\n availableDefaultNativePipelineLanguages;\n\nexport const readDefaultNativePipelinePackageFileAsync = async ({\n language,\n}: DefaultNativePipelinePackageFileOptions = {}): Promise<Uint8Array> => {\n const packageUrl = defaultNativePipelinePackageUrl(language);\n try {\n return await readFile(packageUrl);\n } catch (error) {\n throw new Error(\n `${defaultNativePipelinePackageDescription(language)} is unavailable: ${formatLoadError(error)}`,\n );\n }\n};\n\nexport const createNativePipelineFromPackageFile = ({\n binding,\n packagePath,\n expectedVersion,\n ...loadOptions\n}: NativePipelinePackageFileOptions): PreparedNativePipeline => {\n const resolvedBinding =\n binding ??\n loadNativeAnonymizeBinding({\n ...loadOptions,\n ...(expectedVersion !== undefined ? { expectedVersion } : {}),\n });\n if (binding && expectedVersion !== undefined) {\n assertNativeBindingVersion({ binding, expectedVersion });\n }\n return createNativePipelineFromPackage({\n binding: resolvedBinding,\n packageBytes: readNativePipelinePackageFile(packagePath),\n });\n};\n\nexport const createNativePipelineFromDefaultPackage = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => {\n const resolvedOptions = resolveDefaultNativePipelineOptions(options);\n return applyDefaultNativePipelineWarmup(\n createNativePipelineFromResolvedDefaultPackage(resolvedOptions),\n resolvedOptions.warmup,\n );\n};\n\nexport const create_native_pipeline_from_default_package = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => createNativePipelineFromDefaultPackage(options);\n\nexport const getDefaultNativePipeline = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => {\n const resolvedOptions = resolveDefaultNativePipelineOptions(options);\n const cache = defaultPipelineCacheFor(resolvedOptions.binding);\n const key = defaultPipelineCacheKey(resolvedOptions);\n const cached = cache.get(key);\n if (cached !== undefined) {\n return applyDefaultNativePipelineWarmup(cached, resolvedOptions.warmup);\n }\n const pipeline =\n createNativePipelineFromResolvedDefaultPackage(resolvedOptions);\n cache.set(key, pipeline);\n return applyDefaultNativePipelineWarmup(pipeline, resolvedOptions.warmup);\n};\n\nexport const get_default_native_pipeline = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => getDefaultNativePipeline(options);\n\nexport const createPipeline = async ({\n language,\n warmup,\n ...bindingOptions\n}: CreatePipelineOptions = {}): Promise<PreparedNativePipeline> => {\n const selection = normalizePipelineLanguageSelection(language);\n if (selection.type === \"all\") {\n return getDefaultNativePipeline({\n ...bindingOptions,\n ...(warmup !== undefined ? { warmup } : {}),\n });\n }\n const [singleLanguage, ...additionalLanguages] = selection.languages;\n if (\n additionalLanguages.length === 0 &&\n existsSync(defaultNativePipelineLanguagePackageUrl(singleLanguage))\n ) {\n return getDefaultNativePipeline({\n ...bindingOptions,\n language: singleLanguage,\n ...(warmup !== undefined ? { warmup } : {}),\n });\n }\n const resolvedWarmup = normalizeDefaultNativePipelineWarmup(warmup);\n const pipeline = await createSemanticPipeline({\n binding: resolveNativeSdkBinding(bindingOptions),\n selection,\n });\n return applyDefaultNativePipelineWarmup(pipeline, resolvedWarmup);\n};\n\nexport const create_pipeline = createPipeline;\n\nexport const preloadDefaultNativePipeline = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => {\n const pipeline = getDefaultNativePipeline(options);\n return applyDefaultNativePipelineWarmup(\n pipeline,\n DEFAULT_NATIVE_PIPELINE_WARMUPS.lazyRegex,\n );\n};\n\nexport const preload_default_native_pipeline = (\n options: DefaultNativePipelinePackageOptions = {},\n): PreparedNativePipeline => preloadDefaultNativePipeline(options);\n\nexport const redactDefaultText = (\n fullText: string,\n operators?: NativeOperatorConfig,\n options: DefaultNativePipelinePackageOptions = {},\n): NativeStaticRedactionResult =>\n getDefaultNativePipeline(options).redactText(fullText, operators);\n\nexport const redact_default_text = (\n fullText: string,\n operators?: NativeOperatorConfig,\n options: DefaultNativePipelinePackageOptions = {},\n): NativeStaticRedactionResult =>\n redactDefaultText(fullText, operators, options);\n\nexport const redactDefaultTextJson = (\n fullText: string,\n operators?: NativeOperatorConfig,\n options: DefaultNativePipelinePackageOptions = {},\n): string =>\n getDefaultNativePipeline(options).redact_text_json(fullText, operators);\n\nexport const redact_default_text_json = (\n fullText: string,\n operators?: NativeOperatorConfig,\n options: DefaultNativePipelinePackageOptions = {},\n): string => redactDefaultTextJson(fullText, operators, options);\n\nexport const preloadDefaultNativePipelineAsync = (\n options: DefaultNativePipelinePackageOptions = {},\n): Promise<PreparedNativePipeline> => {\n const resolvedOptions = {\n ...resolveDefaultNativePipelineOptions(options),\n warmup: DEFAULT_NATIVE_PIPELINE_WARMUPS.lazyRegex,\n };\n const cache = defaultPipelineCacheFor(resolvedOptions.binding);\n const key = defaultPipelineCacheKey(resolvedOptions);\n const cached = cache.get(key);\n if (cached !== undefined) {\n return Promise.resolve(\n applyDefaultNativePipelineWarmup(cached, resolvedOptions.warmup),\n );\n }\n\n const inflightCache = defaultPipelineInflightCacheFor(\n resolvedOptions.binding,\n );\n const inflight = inflightCache.get(key);\n if (inflight !== undefined) {\n return inflight;\n }\n\n const promise = createNativePipelineFromResolvedDefaultPackageAsync(\n resolvedOptions,\n )\n .then((pipeline) => {\n cache.set(key, pipeline);\n return applyDefaultNativePipelineWarmup(pipeline, resolvedOptions.warmup);\n })\n .finally(() => {\n inflightCache.delete(key);\n });\n inflightCache.set(key, promise);\n return promise;\n};\n\nconst resolveDefaultNativePipelineOptions = ({\n binding,\n language,\n packagePath,\n warmup,\n expectedVersion,\n ...loadOptions\n}: DefaultNativePipelinePackageOptions = {}): ResolvedDefaultNativePipelineOptions => {\n if (language !== undefined && packagePath !== undefined) {\n throw new Error(\"Use either language or packagePath, not both\");\n }\n const resolvedBinding =\n binding ??\n loadNativeAnonymizeBinding({\n ...loadOptions,\n ...(expectedVersion !== undefined ? { expectedVersion } : {}),\n });\n if (binding && expectedVersion !== undefined) {\n assertNativeBindingVersion({ binding, expectedVersion });\n }\n return {\n binding: resolvedBinding,\n warmup: normalizeDefaultNativePipelineWarmup(warmup),\n ...(language !== undefined\n ? { language: resolveDefaultNativePipelineLanguage(language) }\n : {}),\n ...(packagePath !== undefined ? { packagePath } : {}),\n };\n};\n\nconst applyDefaultNativePipelineWarmup = (\n pipeline: PreparedNativePipeline,\n warmup: DefaultNativePipelineWarmup,\n): PreparedNativePipeline => {\n if (warmup !== DEFAULT_NATIVE_PIPELINE_WARMUPS.lazyRegex) {\n return pipeline;\n }\n if (!warmedDefaultNativePipelines.has(pipeline)) {\n pipeline.warmLazyRegex();\n warmedDefaultNativePipelines.add(pipeline);\n }\n return pipeline;\n};\n\nconst createNativePipelineFromResolvedDefaultPackage = ({\n binding,\n language,\n packagePath,\n}: ResolvedDefaultNativePipelineOptions): PreparedNativePipeline => {\n const packageBytes =\n packagePath === undefined\n ? readDefaultNativePipelinePackageFile(\n defaultPackageFileOptions(language),\n )\n : readNativePipelinePackageFile(packagePath);\n return createNativePipelineFromTrustedDefaultPackage(binding, packageBytes);\n};\n\nconst createNativePipelineFromResolvedDefaultPackageAsync = async ({\n binding,\n language,\n packagePath,\n}: ResolvedDefaultNativePipelineOptions): Promise<PreparedNativePipeline> => {\n const packageBytes =\n packagePath === undefined\n ? await readDefaultNativePipelinePackageFileAsync(\n defaultPackageFileOptions(language),\n )\n : await readNativePipelinePackageFileAsync(packagePath);\n return createNativePipelineFromTrustedDefaultPackage(binding, packageBytes);\n};\n\nconst createNativePipelineFromTrustedDefaultPackage = (\n binding: NativeAnonymizeBinding,\n packageBytes: Uint8Array,\n): PreparedNativePipeline =>\n new PreparedNativePipeline(\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromTrustedPreparedPackageBytesWithoutCache(\n packageBytes,\n ),\n ),\n );\n\nconst defaultPackageFileOptions = (\n language: string | undefined,\n): DefaultNativePipelinePackageFileOptions =>\n language === undefined ? {} : { language };\n\nconst normalizeDefaultNativePipelineWarmup = (\n warmup: DefaultNativePipelineWarmup | undefined,\n): DefaultNativePipelineWarmup => {\n if (warmup === undefined) {\n return DEFAULT_NATIVE_PIPELINE_WARMUPS.none;\n }\n switch (warmup) {\n case DEFAULT_NATIVE_PIPELINE_WARMUPS.lazyRegex:\n case DEFAULT_NATIVE_PIPELINE_WARMUPS.none:\n return warmup;\n }\n throw new Error(\n 'Default native pipeline warmup must be \"lazy-regex\" or \"none\"',\n );\n};\n\nconst resolveNativeSdkBinding = ({\n binding,\n expectedVersion,\n ...loadOptions\n}: NativeSdkOptions): NativeAnonymizeBinding => {\n const resolvedBinding =\n binding ??\n loadNativeAnonymizeBinding({\n ...loadOptions,\n ...(expectedVersion !== undefined ? { expectedVersion } : {}),\n });\n if (binding && expectedVersion !== undefined) {\n assertNativeBindingVersion({ binding, expectedVersion });\n }\n return resolvedBinding;\n};\n\nconst defaultPipelineCacheFor = (\n binding: NativeAnonymizeBinding,\n): Map<string, PreparedNativePipeline> => {\n const cached = defaultNativePipelineCache.get(binding);\n if (cached !== undefined) {\n return cached;\n }\n const created = new Map<string, PreparedNativePipeline>();\n defaultNativePipelineCache.set(binding, created);\n return created;\n};\n\nconst defaultPipelineInflightCacheFor = (\n binding: NativeAnonymizeBinding,\n): Map<string, Promise<PreparedNativePipeline>> => {\n const cached = defaultNativePipelineInflightCache.get(binding);\n if (cached !== undefined) {\n return cached;\n }\n const created = new Map<string, Promise<PreparedNativePipeline>>();\n defaultNativePipelineInflightCache.set(binding, created);\n return created;\n};\n\nconst defaultPipelineCacheKey = ({\n binding,\n language,\n packagePath,\n}: ResolvedDefaultNativePipelineOptions): string =>\n [\n binding.nativePackageVersion(),\n packagePath ??\n (language === undefined\n ? DEFAULT_NATIVE_PIPELINE_PACKAGE_CACHE_KEY\n : `language:${language}`),\n ].join(\"\\0\");\n\nconst defaultNativePipelinePackageUrl = (language: string | undefined): URL => {\n if (language === undefined) {\n return DEFAULT_NATIVE_PIPELINE_PACKAGE_URL;\n }\n const normalized = resolveDefaultNativePipelineLanguage(language);\n return defaultNativePipelineLanguagePackageUrl(normalized);\n};\n\nconst defaultNativePipelineLanguagePackageUrl = (language: string): URL =>\n new URL(`../native-pipeline.${language}.stlanonpkg`, import.meta.url);\n\nconst resolveDefaultNativePipelineLanguage = (language: string): string => {\n const normalized = normalizeDefaultNativePipelineLanguage(language);\n const exactUrl = defaultNativePipelineLanguagePackageUrl(normalized);\n if (existsSync(exactUrl)) {\n return normalized;\n }\n const baseLanguage = normalized.split(\"-\").at(0);\n if (baseLanguage === undefined || baseLanguage === normalized) {\n return normalized;\n }\n const baseUrl = defaultNativePipelineLanguagePackageUrl(baseLanguage);\n if (existsSync(baseUrl)) {\n return baseLanguage;\n }\n return normalized;\n};\n\nconst defaultNativePipelinePackageDescription = (\n language: string | undefined,\n): string =>\n language === undefined\n ? \"Default native pipeline package\"\n : `Default native pipeline package for language \"${resolveDefaultNativePipelineLanguage(language)}\"`;\n\nconst normalizeDefaultNativePipelineLanguage = (language: string): string => {\n const normalized = language.trim().toLowerCase();\n if (!DEFAULT_NATIVE_PIPELINE_LANGUAGE_PATTERN.test(normalized)) {\n throw new Error(\n `Default native pipeline language must match ${DEFAULT_NATIVE_PIPELINE_LANGUAGE_PATTERN.source}`,\n );\n }\n return normalized;\n};\n\ntype NativeBindingSpecifiersOptions = {\n arch: string;\n env: Record<string, string | undefined>;\n libc: NativeLibc | undefined;\n platform: string;\n};\n\nconst nativeBindingSpecifiers = ({\n arch,\n env,\n libc,\n platform,\n}: NativeBindingSpecifiersOptions): string[] => {\n const specifiers: string[] = [];\n const overridePath = env[PACKAGE_SPECIFIC_NATIVE_PATH];\n if (overridePath) {\n specifiers.push(overridePath);\n }\n const platformPackage = nativeBindingPackageName({ arch, libc, platform });\n if (platformPackage !== null) {\n specifiers.push(platformPackage);\n }\n return specifiers;\n};\n\ntype NativeBindingTarget = {\n platform: string;\n arch: string;\n libc?: NativeLibc;\n package: string;\n};\n\n// Single source of truth for published native sidecars. Both the runtime\n// package lookup and the \"unsupported target\" error message derive from this\n// table, so a target is never advertised as supported without a package (and\n// vice versa). musl Linux is intentionally absent: no musl sidecar is shipped.\nconst NATIVE_BINDING_TARGETS: readonly NativeBindingTarget[] = [\n {\n platform: \"darwin\",\n arch: \"arm64\",\n package: \"@stll/anonymize-darwin-arm64\",\n },\n { platform: \"darwin\", arch: \"x64\", package: \"@stll/anonymize-darwin-x64\" },\n {\n platform: \"linux\",\n arch: \"arm64\",\n libc: \"gnu\",\n package: \"@stll/anonymize-linux-arm64-gnu\",\n },\n {\n platform: \"linux\",\n arch: \"x64\",\n libc: \"gnu\",\n package: \"@stll/anonymize-linux-x64-gnu\",\n },\n { platform: \"win32\", arch: \"x64\", package: \"@stll/anonymize-win32-x64-msvc\" },\n];\n\ntype NativeBindingPackageNameOptions = {\n arch: string;\n libc: NativeLibc | undefined;\n platform: string;\n};\n\ntype DescribeNativeTargetOptions = {\n arch: string;\n libc?: NativeLibc | undefined;\n platform: string;\n};\n\nconst describeNativeTarget = ({\n arch,\n libc,\n platform,\n}: DescribeNativeTargetOptions): string =>\n libc === undefined ? `${platform}-${arch}` : `${platform}-${arch}-${libc}`;\n\nconst SUPPORTED_NATIVE_TARGETS: readonly string[] = NATIVE_BINDING_TARGETS.map(\n (target) => describeNativeTarget(target),\n);\n\nconst nativeBindingPackageName = ({\n arch,\n libc,\n platform,\n}: NativeBindingPackageNameOptions): string | null => {\n const match = NATIVE_BINDING_TARGETS.find(\n (target) =>\n target.platform === platform &&\n target.arch === arch &&\n (target.libc === undefined || target.libc === libc),\n );\n return match?.package ?? null;\n};\n\nconst unsupportedNativeTargetError = ({\n arch,\n errors,\n libc,\n platform,\n}: NativeBindingPackageNameOptions & { errors: string[] }): Error => {\n const target = describeNativeTarget({ arch, libc, platform });\n const supported = SUPPORTED_NATIVE_TARGETS.join(\", \");\n const attempts = errors.length > 0 ? `\\n${errors.join(\"\\n\")}` : \"\";\n return new Error(\n `No native anonymize binding is published for ${target}; supported targets: ${supported}. Set ${PACKAGE_SPECIFIC_NATIVE_PATH} to a locally built binding to run on this platform.${attempts}`,\n );\n};\n\nconst detectNativeLibc = (platform: string): NativeLibc | undefined => {\n if (platform !== \"linux\") {\n return undefined;\n }\n const report = process.report?.getReport();\n const header =\n isPropertyBag(report) && isPropertyBag(report[\"header\"])\n ? report[\"header\"]\n : null;\n return typeof header?.[\"glibcVersionRuntime\"] === \"string\" ? \"gnu\" : \"musl\";\n};\n\nconst isHostNativeTarget = ({\n arch,\n libc,\n platform,\n}: NativeBindingPackageNameOptions): boolean =>\n platform === process.platform &&\n arch === process.arch &&\n (platform !== \"linux\" || libc === detectNativeLibc(process.platform));\n\ntype TryLoadNativeBindingOptions = {\n specifier: string;\n loadModule: () => unknown;\n errors: string[];\n};\n\nconst tryLoadNativeBinding = ({\n specifier,\n loadModule,\n errors,\n}: TryLoadNativeBindingOptions): NativeAnonymizeBinding | null => {\n try {\n const loaded = loadModule();\n const binding = toNativeAnonymizeBinding(loaded);\n if (binding) {\n return binding;\n }\n errors.push(`${specifier}: module does not match native binding shape`);\n } catch (error) {\n errors.push(`${specifier}: ${formatLoadError(error)}`);\n }\n return null;\n};\n\nconst toNativeAnonymizeBinding = (\n value: unknown,\n): NativeAnonymizeBinding | null => {\n const candidate =\n isPropertyBag(value) && isPropertyBag(value[\"default\"])\n ? value[\"default\"]\n : value;\n return isNativeAnonymizeBinding(candidate) ? candidate : null;\n};\n\nconst isPropertyBag = (value: unknown): value is Record<string, unknown> =>\n (typeof value === \"object\" && value !== null) || typeof value === \"function\";\n\nconst formatLoadError = (error: unknown): string => {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n};\n"],"mappings":";;;;;;;;;AAAA,MAA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@ -223,6 +223,7 @@ type NativeAddressSeedData = {
223
223
  boundary_words: string[];
224
224
  br_cep_cue_words: string[];
225
225
  unit_abbreviations: string[];
226
+ directional_abbreviations: string[];
226
227
  /** Present only when `standaloneStreetDetection` is enabled. */
227
228
  standalone_street?: NativeStandaloneStreetData;
228
229
  };
@@ -297,7 +298,9 @@ type NativeHotwordRuleData = {
297
298
  };
298
299
  type NativeSignatureData = {
299
300
  labels: string[];
301
+ person_value_labels: string[];
300
302
  person_list_labels: string[];
303
+ party_role_name_evidence: string;
301
304
  witness_phrases: string[];
302
305
  name_particles: string[];
303
306
  post_nominal_suffixes: string[];
package/dist/native.mjs CHANGED
@@ -68,13 +68,13 @@ const isNativeAnonymizeBinding = (candidate) => {
68
68
  };
69
69
  const CALLER_DETECTION_CONTRACT_VERSION = 2;
70
70
  const CALLER_DETECTION_MAX_COUNT = 1e6;
71
- const CALLER_DETECTION_TEXT_MAX_BYTES = 64 * 1024 * 1024;
72
- const CALLER_DETECTION_REQUEST_JSON_MAX_BYTES = 16 * 1024 * 1024;
71
+ const CALLER_DETECTION_TEXT_MAX_BYTES = 67108864;
72
+ const CALLER_DETECTION_REQUEST_JSON_MAX_BYTES = 16777216;
73
73
  const SESSION_CALLER_MAX_INPUTS = 1e5;
74
- const SESSION_CALLER_INPUTS_JSON_MAX_BYTES = 64 * 1024 * 1024;
74
+ const SESSION_CALLER_INPUTS_JSON_MAX_BYTES = 67108864;
75
75
  const EXTERNAL_DETECTION_BATCH_VERSION = 1;
76
- const EXTERNAL_DETECTION_BATCH_MAX_BYTES = 16 * 1024 * 1024;
77
- const EXTERNAL_DETECTION_DOCUMENT_MAX_BYTES = 64 * 1024 * 1024;
76
+ const EXTERNAL_DETECTION_BATCH_MAX_BYTES = 16777216;
77
+ const EXTERNAL_DETECTION_DOCUMENT_MAX_BYTES = 67108864;
78
78
  const EXTERNAL_DETECTION_MAX_DETECTIONS = 1e5;
79
79
  const EXTERNAL_DETECTION_MAX_LABEL_MAPPINGS = 4096;
80
80
  const EXTERNAL_DETECTION_MAX_METADATA_BYTES = 256;
@@ -1 +1 @@
1
- {"version":3,"file":"native.mjs","names":["#maximumBytes","#label","#reportedMaximumBytes","#reserve","#requireNumber","#appendNumber","#appendReservedRun","#bytes","#chunks","#suffix","#session","#plan","#prepared","#anonymizer"],"sources":["../src/native.ts"],"sourcesContent":["import type { NativePreparedSearchConfig } from \"./native-search-config\";\nimport type { OperatorSelection, OperatorType } from \"./types\";\n\nexport type { NativePreparedSearchConfig } from \"./native-search-config\";\n\ntype NativeBindingOperatorConfig = {\n operators?: Record<string, OperatorSelection>;\n redactString?: string;\n};\n\ntype NativeBindingCallerRedactionOptions = {\n requestJson: string;\n operators?: NativeBindingOperatorConfig;\n};\n\ntype NativeBindingSessionCallerRedactionInput = {\n fullText: string;\n requestJson: string;\n};\n\ntype NativeBindingSessionCallerRedactionPlanOptions = {\n inputs: NativeBindingSessionCallerRedactionInput[];\n operators?: NativeBindingOperatorConfig;\n observedAtEpochSeconds?: number;\n};\n\ntype NativeBindingOpenSessionArchiveOptions = {\n archive: Uint8Array;\n key: Uint8Array;\n expectedSessionId: string;\n observedAtEpochSeconds?: number;\n};\n\nexport type NativeDiagnosticsBatchCallback = (diagnosticsJson: string) => void;\nexport type NativeResultEventCallback = (eventJson: string) => void;\n\ntype NativeBindingRedactionEntry = {\n placeholder: string;\n original: string;\n};\n\ntype NativeBindingOperatorEntry = {\n placeholder: string;\n operator: OperatorType;\n};\n\ntype NativeBindingPipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n sourceDetail?: string | null;\n providerId?: string | null;\n detectionId?: string | null;\n};\n\ntype NativeBindingRedactionResult = {\n redactedText: string;\n redactionMap: NativeBindingRedactionEntry[];\n operatorMap: NativeBindingOperatorEntry[];\n entityCount: number;\n};\n\ntype NativeBindingStaticRedactionResult = {\n resolvedEntities: NativeBindingPipelineEntity[];\n redaction: NativeBindingRedactionResult;\n};\n\ntype CanonicalPipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n source_detail?: string | null;\n provider_id?: string | null;\n detection_id?: string | null;\n};\n\ntype CanonicalStaticRedactionResult = {\n resolved_entities: CanonicalPipelineEntity[];\n redaction: {\n redacted_text: string;\n redaction_map: NativeBindingRedactionEntry[];\n operator_map: NativeBindingOperatorEntry[];\n entity_count: number;\n };\n};\n\ntype CanonicalSessionMetadata = {\n session_id: string;\n created_at_epoch_seconds: number | null;\n expires_at_epoch_seconds: number | null;\n mapping_count: number;\n status: NativeSessionStatus;\n};\n\ntype CanonicalSessionDeletionSummary = {\n session_id: string;\n deleted_mapping_count: number;\n};\n\ntype CanonicalSessionRedactionPlanResult = {\n replacements: Array<{ start: number; end: number; replacement: string }>;\n entity_count: number;\n caller_entity_count: number;\n};\n\nexport type NativeSessionStatus =\n | \"active\"\n | \"not_yet_active\"\n | \"expired\"\n | \"deleted\";\n\nexport type NativeSessionLifecycle = {\n createdAtEpochSeconds: number;\n expiresAtEpochSeconds?: number;\n};\n\nexport type NativeSessionMetadata = {\n sessionId: string;\n createdAtEpochSeconds: number | null;\n expiresAtEpochSeconds: number | null;\n mappingCount: number;\n status: NativeSessionStatus;\n};\n\nexport type NativeSessionDeletionSummary = {\n sessionId: string;\n deletedMappingCount: number;\n};\n\nexport type NativeSessionRedactionAtOptions = {\n fullText: string;\n observedAtEpochSeconds: number;\n operators?: NativeOperatorConfig;\n};\n\nexport type NativeCreateSessionWithLifecycleOptions = NativeSessionLifecycle & {\n sessionId: string;\n};\n\nexport type NativeOpenSessionArchiveOptions = {\n archive: Uint8Array;\n key: Uint8Array;\n expectedSessionId: string;\n observedAtEpochSeconds?: number;\n};\n\nexport type NativePreparedRedactionSessionBinding = {\n sessionId: () => string;\n mappingCount: () => number;\n restoreText: (fullText: string) => string;\n restoreTextAt: (fullText: string, observedAtEpochSeconds: number) => string;\n toPlaintextJson: () => string;\n toPlaintextJsonAt: (observedAtEpochSeconds: number) => string;\n toEncryptedArchive: (key: Uint8Array) => Uint8Array;\n toEncryptedArchiveAt: (\n key: Uint8Array,\n observedAtEpochSeconds: number,\n ) => Uint8Array;\n inspectJson: (observedAtEpochSeconds?: number) => string;\n deleteJson: () => string;\n redactStaticEntitiesJson: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n redactStaticEntitiesJsonAt: (\n fullText: string,\n observedAtEpochSeconds: number,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n planStaticEntitiesWithCallerDetections: (\n options: NativeBindingSessionCallerRedactionPlanOptions,\n ) => NativePreparedSessionRedactionPlanBinding;\n};\n\nexport type NativePreparedSessionRedactionPlanBinding = {\n resultJson: () => string;\n commit: () => void;\n};\n\nexport type NativePreparedSearchBinding = {\n prepareDiagnosticsJson: () => string;\n warmLazyRegex: () => void;\n warmLazyRegexDiagnosticsJson: () => string;\n createRedactionSession: (\n sessionId: string,\n ) => NativePreparedRedactionSessionBinding;\n createRedactionSessionWithLifecycle: (\n sessionId: string,\n createdAtEpochSeconds: number,\n expiresAtEpochSeconds?: number,\n ) => NativePreparedRedactionSessionBinding;\n restoreRedactionSession: (\n plaintextJson: string,\n ) => NativePreparedRedactionSessionBinding;\n restoreEncryptedRedactionSession: (\n options: NativeBindingOpenSessionArchiveOptions,\n ) => NativePreparedRedactionSessionBinding;\n redactStaticEntities: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => NativeBindingStaticRedactionResult;\n redactStaticEntitiesJson: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n redactStaticEntitiesWithCallerDetectionsJson: (\n fullText: string,\n options: NativeBindingCallerRedactionOptions,\n ) => string;\n redactStaticEntitiesWithCallerDetectionsDiagnosticsJson: (\n fullText: string,\n options: NativeBindingCallerRedactionOptions,\n ) => string;\n redactStaticEntitiesResultStreamJson: (\n fullText: string,\n operators: NativeBindingOperatorConfig | undefined,\n onEvent: NativeResultEventCallback,\n ) => string;\n redactStaticEntitiesDiagnosticsJson: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n redactStaticEntitiesDiagnosticsStreamJson: (\n fullText: string,\n operators: NativeBindingOperatorConfig | undefined,\n onBatch: NativeDiagnosticsBatchCallback,\n ) => string;\n redactStaticEntitiesSummaryDiagnosticsJson: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n};\n\nexport type NativeAnonymizeBinding = {\n convertExternalDetectionBatch: (\n document: Uint8Array,\n batchJson: string,\n ) => NativeCallerDetection[];\n externalDetectionLimitsJson: () => string;\n extractDocxTextJson: (document: Uint8Array) => string;\n inspectPdfJson: (document: Uint8Array, observationsJson?: string) => string;\n rewritePdfRasterFromDetectionsJson: (\n document: Uint8Array,\n requestJson: string,\n pagePixels: readonly Uint8Array[],\n ) => { document: Uint8Array; certificateJson: string };\n rewriteDocxTextNative: (\n document: Uint8Array,\n rewritesJson: string,\n ) => {\n document: Uint8Array;\n rewrittenBlockCount: number;\n appliedReplacementCount: number;\n };\n planDocxRestorationJson: (document: Uint8Array, sessionId: string) => string;\n normalizeForSearch: (text: string) => string;\n nativePackageVersion: () => string;\n NativePreparedSearch: {\n fromConfigJsonBytes: (\n configJson: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromPreparedPackageBytes: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromPreparedPackageBytesWithoutCache: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromTrustedPreparedPackageBytes: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromTrustedPreparedPackageBytesWithoutCache: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n };\n prepareStaticSearchPackageBytes: (configJson: Uint8Array) => Uint8Array;\n prepareStaticSearchCompressedPackageBytes: (\n configJson: Uint8Array,\n ) => Uint8Array;\n // Rust config assembler (replaces the retired TypeScript config-assembly\n // layer). Takes the pipeline config plus out-of-band dictionaries and\n // gazetteer JSON and returns either the assembled config JSON or ready\n // package bytes. Every parity runtime must expose these required members.\n assembleStaticSearchConfigJson: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n assembleStaticSearchPackageBytes: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n assembleStaticSearchCompressedPackageBytes: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n};\n\ntype FunctionMemberNames<T> = {\n [Key in keyof T]-?: T[Key] extends (...args: never[]) => unknown\n ? Key\n : never;\n}[keyof T];\n\n/** Exhaustive runtime-member contract shared by loaders and parity gates. */\nexport const NATIVE_BINDING_PARITY_MEMBERS = {\n root: [\n \"convertExternalDetectionBatch\",\n \"externalDetectionLimitsJson\",\n \"extractDocxTextJson\",\n \"inspectPdfJson\",\n \"rewritePdfRasterFromDetectionsJson\",\n \"rewriteDocxTextNative\",\n \"planDocxRestorationJson\",\n \"normalizeForSearch\",\n \"nativePackageVersion\",\n \"prepareStaticSearchPackageBytes\",\n \"prepareStaticSearchCompressedPackageBytes\",\n \"assembleStaticSearchConfigJson\",\n \"assembleStaticSearchPackageBytes\",\n \"assembleStaticSearchCompressedPackageBytes\",\n ],\n factories: [\n \"fromConfigJsonBytes\",\n \"fromPreparedPackageBytes\",\n \"fromPreparedPackageBytesWithoutCache\",\n \"fromTrustedPreparedPackageBytes\",\n \"fromTrustedPreparedPackageBytesWithoutCache\",\n ],\n prepared: [\n \"prepareDiagnosticsJson\",\n \"warmLazyRegex\",\n \"warmLazyRegexDiagnosticsJson\",\n \"createRedactionSession\",\n \"createRedactionSessionWithLifecycle\",\n \"restoreRedactionSession\",\n \"restoreEncryptedRedactionSession\",\n \"redactStaticEntities\",\n \"redactStaticEntitiesJson\",\n \"redactStaticEntitiesWithCallerDetectionsJson\",\n \"redactStaticEntitiesWithCallerDetectionsDiagnosticsJson\",\n \"redactStaticEntitiesResultStreamJson\",\n \"redactStaticEntitiesDiagnosticsJson\",\n \"redactStaticEntitiesDiagnosticsStreamJson\",\n \"redactStaticEntitiesSummaryDiagnosticsJson\",\n ],\n session: [\n \"sessionId\",\n \"mappingCount\",\n \"restoreText\",\n \"restoreTextAt\",\n \"toPlaintextJson\",\n \"toPlaintextJsonAt\",\n \"toEncryptedArchive\",\n \"toEncryptedArchiveAt\",\n \"inspectJson\",\n \"deleteJson\",\n \"redactStaticEntitiesJson\",\n \"redactStaticEntitiesJsonAt\",\n \"planStaticEntitiesWithCallerDetections\",\n ],\n plan: [\"resultJson\", \"commit\"],\n} as const satisfies {\n root: readonly FunctionMemberNames<NativeAnonymizeBinding>[];\n factories: readonly FunctionMemberNames<\n NativeAnonymizeBinding[\"NativePreparedSearch\"]\n >[];\n prepared: readonly FunctionMemberNames<NativePreparedSearchBinding>[];\n session: readonly FunctionMemberNames<NativePreparedRedactionSessionBinding>[];\n plan: readonly FunctionMemberNames<NativePreparedSessionRedactionPlanBinding>[];\n};\n\nconst ROOT_PARITY_IS_EXHAUSTIVE: Exclude<\n FunctionMemberNames<NativeAnonymizeBinding>,\n (typeof NATIVE_BINDING_PARITY_MEMBERS.root)[number]\n> extends never\n ? true\n : never = true;\nconst FACTORY_PARITY_IS_EXHAUSTIVE: Exclude<\n FunctionMemberNames<NativeAnonymizeBinding[\"NativePreparedSearch\"]>,\n (typeof NATIVE_BINDING_PARITY_MEMBERS.factories)[number]\n> extends never\n ? true\n : never = true;\nconst PREPARED_PARITY_IS_EXHAUSTIVE: Exclude<\n FunctionMemberNames<NativePreparedSearchBinding>,\n (typeof NATIVE_BINDING_PARITY_MEMBERS.prepared)[number]\n> extends never\n ? true\n : never = true;\nconst SESSION_PARITY_IS_EXHAUSTIVE: Exclude<\n FunctionMemberNames<NativePreparedRedactionSessionBinding>,\n (typeof NATIVE_BINDING_PARITY_MEMBERS.session)[number]\n> extends never\n ? true\n : never = true;\nconst PLAN_PARITY_IS_EXHAUSTIVE: Exclude<\n FunctionMemberNames<NativePreparedSessionRedactionPlanBinding>,\n (typeof NATIVE_BINDING_PARITY_MEMBERS.plan)[number]\n> extends never\n ? true\n : never = true;\nvoid [\n ROOT_PARITY_IS_EXHAUSTIVE,\n FACTORY_PARITY_IS_EXHAUSTIVE,\n PREPARED_PARITY_IS_EXHAUSTIVE,\n SESSION_PARITY_IS_EXHAUSTIVE,\n PLAN_PARITY_IS_EXHAUSTIVE,\n];\n\nconst isBindingPropertyBag = (\n value: unknown,\n): value is Record<string, unknown> =>\n (typeof value === \"object\" && value !== null) || typeof value === \"function\";\n\n/** Validate the complete runtime-neutral root and factory binding shape. */\nexport const isNativeAnonymizeBinding = (\n candidate: unknown,\n): candidate is NativeAnonymizeBinding => {\n if (!isBindingPropertyBag(candidate)) {\n return false;\n }\n if (\n !NATIVE_BINDING_PARITY_MEMBERS.root.every(\n (name) => typeof candidate[name] === \"function\",\n )\n ) {\n return false;\n }\n const preparedSearch = candidate[\"NativePreparedSearch\"];\n return (\n isBindingPropertyBag(preparedSearch) &&\n NATIVE_BINDING_PARITY_MEMBERS.factories.every(\n (name) => typeof preparedSearch[name] === \"function\",\n )\n );\n};\n\nexport type NativeOperatorConfig = {\n operators?: Record<string, OperatorSelection>;\n redactString?: string;\n};\n\nexport const CALLER_DETECTION_CONTRACT_VERSION = 2;\nexport const CALLER_DETECTION_MAX_COUNT = 1_000_000;\nexport const CALLER_DETECTION_TEXT_MAX_BYTES = 64 * 1024 * 1024;\nexport const CALLER_DETECTION_REQUEST_JSON_MAX_BYTES = 16 * 1024 * 1024;\nexport const SESSION_CALLER_MAX_INPUTS = 100_000;\nexport const SESSION_CALLER_INPUTS_JSON_MAX_BYTES = 64 * 1024 * 1024;\n\nexport const EXTERNAL_DETECTION_BATCH_VERSION = 1 as const;\nexport const EXTERNAL_DETECTION_BATCH_MAX_BYTES = 16 * 1024 * 1024;\nexport const EXTERNAL_DETECTION_DOCUMENT_MAX_BYTES = 64 * 1024 * 1024;\nexport const EXTERNAL_DETECTION_MAX_DETECTIONS = 100_000;\nexport const EXTERNAL_DETECTION_MAX_LABEL_MAPPINGS = 4_096;\nexport const EXTERNAL_DETECTION_MAX_METADATA_BYTES = 256;\nexport const EXTERNAL_DETECTION_PROVIDER_ID_MAX_BYTES = 128;\n\nexport const EXTERNAL_DETECTION_OFFSET_UNITS = {\n unicodeCodePoint: \"unicode-code-point\",\n utf16CodeUnit: \"utf16-code-unit\",\n utf8Byte: \"utf8-byte\",\n} as const;\n\nexport type ExternalDetectionOffsetUnit =\n (typeof EXTERNAL_DETECTION_OFFSET_UNITS)[keyof typeof EXTERNAL_DETECTION_OFFSET_UNITS];\n\nexport type ExternalDetectionBatch = {\n version: typeof EXTERNAL_DETECTION_BATCH_VERSION;\n document: { sha256: string };\n offsetUnit: ExternalDetectionOffsetUnit;\n provider: { id: string; name: string; version: string };\n labelMap: readonly {\n providerLabel: string;\n entityLabel: string;\n }[];\n detections: readonly {\n id: string;\n start: number;\n end: number;\n label: string;\n score: number;\n }[];\n};\n\nexport type NativeCallerDetection = {\n start: number;\n end: number;\n label: string;\n score: number;\n providerId: string;\n detectionId: string;\n};\n\nexport type ConvertExternalDetectionBatchOptions = {\n binding: NativeAnonymizeBinding;\n document: Uint8Array;\n batch: ExternalDetectionBatch | string;\n};\n\nexport const convert_external_detection_batch = ({\n binding,\n document,\n batch,\n}: ConvertExternalDetectionBatchOptions): NativeCallerDetection[] => {\n return binding.convertExternalDetectionBatch(\n document,\n typeof batch === \"string\" ? batch : JSON.stringify(batch),\n );\n};\n\nexport type NativeCallerRedactionOptions = {\n detections: readonly NativeCallerDetection[];\n operators?: NativeOperatorConfig;\n};\n\nexport type NativeSessionCallerRedactionInput = {\n fullText: string;\n detections: readonly NativeCallerDetection[];\n};\n\nexport type NativeSessionCallerRedactionPlanOptions = {\n inputs: readonly NativeSessionCallerRedactionInput[];\n operators?: NativeOperatorConfig;\n observedAtEpochSeconds?: number;\n};\n\nexport type NativeTextReplacement = {\n start: number;\n end: number;\n replacement: string;\n};\n\nexport type NativeSessionBlockRedactionPlan = {\n replacements: readonly NativeTextReplacement[];\n entityCount: number;\n callerEntityCount: number;\n};\n\nconst utf8ByteLengthWithin = (\n text: string,\n maximum: number,\n): number | undefined => {\n let bytes = 0;\n for (let index = 0; index < text.length; index += 1) {\n const unit = text.charCodeAt(index);\n if (unit <= 0x7f) {\n bytes += 1;\n } else if (unit <= 0x7ff) {\n bytes += 2;\n } else if (\n unit >= 0xd800 &&\n unit <= 0xdbff &&\n index + 1 < text.length &&\n text.charCodeAt(index + 1) >= 0xdc00 &&\n text.charCodeAt(index + 1) <= 0xdfff\n ) {\n bytes += 4;\n index += 1;\n } else {\n bytes += 3;\n }\n if (bytes > maximum) {\n return undefined;\n }\n }\n return bytes;\n};\n\nconst validateCallerDetectionInput = (\n fullText: string,\n detections: readonly NativeCallerDetection[],\n): number => {\n if (!Array.isArray(detections)) {\n throw new TypeError(\"Caller detections must be an array\");\n }\n if (detections.length > CALLER_DETECTION_MAX_COUNT) {\n throw new RangeError(\n `Caller detections contains ${detections.length} items; the maximum is ${CALLER_DETECTION_MAX_COUNT}`,\n );\n }\n const textBytes = utf8ByteLengthWithin(\n fullText,\n CALLER_DETECTION_TEXT_MAX_BYTES,\n );\n if (textBytes === undefined) {\n throw new RangeError(\n `Caller detection text exceeds the ${CALLER_DETECTION_TEXT_MAX_BYTES}-byte maximum`,\n );\n }\n return textBytes;\n};\n\nabstract class BoundedJsonSink {\n readonly #maximumBytes: number;\n readonly #label: string;\n readonly #reportedMaximumBytes: number;\n #bytes = 0;\n\n constructor(maximumBytes: number, label: string, suffix: string) {\n this.#maximumBytes = maximumBytes - suffix.length;\n this.#label = label;\n this.#reportedMaximumBytes = maximumBytes;\n }\n\n appendAscii(value: string): void {\n this.#reserve(value.length);\n this.capture(value);\n }\n\n appendOffset(value: number, field: string): void {\n this.#requireNumber(value, field);\n if (!Number.isInteger(value) || value < 0 || value > 0xff_ff_ff_ff) {\n throw new RangeError(\n `${field} must be an integer between 0 and 4294967295`,\n );\n }\n this.#appendNumber(value);\n }\n\n appendScore(value: number, field: string): void {\n this.#requireNumber(value, field);\n if (!Number.isFinite(value) || value < 0 || value > 1) {\n throw new RangeError(`${field} must be finite and between 0 and 1`);\n }\n this.#appendNumber(value);\n }\n\n appendString(value: string, field: string): void {\n if (typeof value !== \"string\") {\n throw new TypeError(`${field} must be a string`);\n }\n this.appendAscii('\"');\n let runStart = 0;\n for (let index = 0; index < value.length; index += 1) {\n const unit = value.charCodeAt(index);\n const escape = jsonEscape(unit);\n if (escape !== undefined) {\n this.#appendReservedRun(value, runStart, index);\n this.appendAscii(escape);\n runStart = index + 1;\n continue;\n }\n if (\n unit >= 0xd800 &&\n unit <= 0xdbff &&\n index + 1 < value.length &&\n value.charCodeAt(index + 1) >= 0xdc00 &&\n value.charCodeAt(index + 1) <= 0xdfff\n ) {\n this.#reserve(4);\n index += 1;\n continue;\n }\n if (unit >= 0xd800 && unit <= 0xdfff) {\n this.#appendReservedRun(value, runStart, index);\n this.appendAscii(`\\\\u${unit.toString(16).padStart(4, \"0\")}`);\n runStart = index + 1;\n continue;\n }\n let unitBytes = 3;\n if (unit <= 0x7f) {\n unitBytes = 1;\n } else if (unit <= 0x7ff) {\n unitBytes = 2;\n }\n this.#reserve(unitBytes);\n }\n this.#appendReservedRun(value, runStart, value.length);\n this.appendAscii('\"');\n }\n\n #appendReservedRun(value: string, start: number, end: number): void {\n if (end > start) {\n this.capture(value.slice(start, end));\n }\n }\n\n #appendNumber(value: number): void {\n this.appendAscii(JSON.stringify(value));\n }\n\n #requireNumber(value: number, field: string): void {\n if (typeof value !== \"number\") {\n throw new TypeError(`${field} must be a number`);\n }\n }\n\n #reserve(bytes: number): void {\n if (bytes > this.#maximumBytes - this.#bytes) {\n throw new RangeError(\n `${this.#label} exceeds the ${this.#reportedMaximumBytes}-byte maximum`,\n );\n }\n this.#bytes += bytes;\n }\n\n protected abstract capture(value: string): void;\n}\n\nclass CountingJsonBudget extends BoundedJsonSink {\n protected capture(value: string): void {\n void value;\n }\n}\n\nclass BoundedJsonWriter extends BoundedJsonSink {\n readonly #chunks: string[] = [];\n readonly #suffix: string;\n\n constructor(maximumBytes: number, label: string, suffix: string) {\n super(maximumBytes, label, suffix);\n this.#suffix = suffix;\n }\n\n finish(): string {\n return this.#chunks.join(\"\") + this.#suffix;\n }\n\n protected capture(value: string): void {\n this.#chunks.push(value);\n }\n}\n\nconst jsonEscape = (unit: number): string | undefined => {\n switch (unit) {\n case 0x08:\n return \"\\\\b\";\n case 0x09:\n return \"\\\\t\";\n case 0x0a:\n return \"\\\\n\";\n case 0x0c:\n return \"\\\\f\";\n case 0x0d:\n return \"\\\\r\";\n case 0x22:\n return '\\\\\"';\n case 0x5c:\n return \"\\\\\\\\\";\n default:\n return unit < 0x20\n ? `\\\\u${unit.toString(16).padStart(4, \"0\")}`\n : undefined;\n }\n};\n\nconst callerDetectionRequestJson = (\n fullText: string,\n detections: readonly NativeCallerDetection[],\n): string => {\n validateCallerDetectionInput(fullText, detections);\n return serializeCallerDetectionRequest(detections);\n};\n\nconst serializeCallerDetectionRequest = (\n detections: readonly NativeCallerDetection[],\n): string => {\n const writer = new BoundedJsonWriter(\n CALLER_DETECTION_REQUEST_JSON_MAX_BYTES,\n \"Caller detection request JSON\",\n \"]}\",\n );\n writer.appendAscii(\n `{\"version\":${CALLER_DETECTION_CONTRACT_VERSION},\"detections\":[`,\n );\n for (let index = 0; index < detections.length; index += 1) {\n const detection = detections[index];\n if (detection === undefined) {\n throw new TypeError(\"Caller detections must not be sparse\");\n }\n if (index > 0) {\n writer.appendAscii(\",\");\n }\n writer.appendAscii('{\"start\":');\n writer.appendOffset(detection.start, \"Caller detection start\");\n writer.appendAscii(',\"end\":');\n writer.appendOffset(detection.end, \"Caller detection end\");\n writer.appendAscii(',\"label\":');\n writer.appendString(detection.label, \"Caller detection label\");\n writer.appendAscii(',\"score\":');\n writer.appendScore(detection.score, \"Caller detection score\");\n writer.appendAscii(',\"provider_id\":');\n writer.appendString(detection.providerId, \"Caller detection providerId\");\n writer.appendAscii(',\"detection_id\":');\n writer.appendString(detection.detectionId, \"Caller detection detectionId\");\n writer.appendAscii(\"}\");\n }\n return writer.finish();\n};\n\nconst toBindingSessionCallerInputs = (\n inputs: readonly NativeSessionCallerRedactionInput[],\n) => {\n if (!Array.isArray(inputs)) {\n throw new TypeError(\"Session caller inputs must be an array\");\n }\n if (inputs.length > SESSION_CALLER_MAX_INPUTS) {\n throw new RangeError(\n `Session caller inputs contains ${inputs.length} items; the maximum is ${SESSION_CALLER_MAX_INPUTS}`,\n );\n }\n let detectionCount = 0;\n let textBytes = 0;\n const bindingInputs: NativeBindingSessionCallerRedactionInput[] = [];\n const budget = new CountingJsonBudget(\n SESSION_CALLER_INPUTS_JSON_MAX_BYTES,\n \"Session caller inputs JSON\",\n \"]\",\n );\n budget.appendAscii(\"[\");\n for (let index = 0; index < inputs.length; index += 1) {\n const input = inputs[index];\n if (input === undefined) {\n throw new TypeError(\"Session caller inputs must not be sparse\");\n }\n const { detections, fullText } = input;\n const inputTextBytes = validateCallerDetectionInput(fullText, detections);\n detectionCount += detections.length;\n if (detectionCount > CALLER_DETECTION_MAX_COUNT) {\n throw new RangeError(\n `Session caller detections contains ${detectionCount} items; the maximum is ${CALLER_DETECTION_MAX_COUNT}`,\n );\n }\n textBytes += inputTextBytes;\n if (textBytes > CALLER_DETECTION_TEXT_MAX_BYTES) {\n throw new RangeError(\n `Session caller text contains ${textBytes} bytes; the maximum is ${CALLER_DETECTION_TEXT_MAX_BYTES}`,\n );\n }\n const requestJson = serializeCallerDetectionRequest(detections);\n if (index > 0) {\n budget.appendAscii(\",\");\n }\n budget.appendAscii('{\"full_text\":');\n budget.appendString(fullText, \"Session caller fullText\");\n budget.appendAscii(',\"request_json\":');\n budget.appendString(requestJson, \"Session caller requestJson\");\n budget.appendAscii(\"}\");\n bindingInputs.push({ fullText, requestJson });\n }\n return bindingInputs;\n};\n\nexport type NativePipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n sourceDetail?: string;\n providerId?: string;\n detectionId?: string;\n};\n\nexport type NativeRedactionResult = {\n redactedText: string;\n redactionMap: Map<string, string>;\n operatorMap: Map<string, OperatorType>;\n entityCount: number;\n};\n\nexport type NativeStaticRedactionResult = {\n resolvedEntities: NativePipelineEntity[];\n redaction: NativeRedactionResult;\n};\n\nexport type NativeSearchPackageOptions = {\n binding: NativeAnonymizeBinding;\n config: NativePreparedSearchConfig;\n compressed?: boolean;\n};\n\nexport type NativeSearchPackageInput =\n | NativePreparedSearchConfig\n | string\n | Uint8Array;\n\nexport type SharedNativeSearchPackageOptions = {\n binding: NativeAnonymizeBinding;\n config: NativeSearchPackageInput;\n compressed?: boolean;\n};\n\nexport type SharedNativePreparedPackageOptions = {\n binding: NativeAnonymizeBinding;\n packageBytes: Uint8Array;\n};\n\nexport type SharedNativeRedactTextJsonOptions = {\n binding: NativeAnonymizeBinding;\n config: NativeSearchPackageInput;\n fullText: string;\n operators?: NativeOperatorConfig;\n};\n\nexport type SharedNativeRedactTextOptions = SharedNativeRedactTextJsonOptions;\n\nexport type SharedNativeDiagnosticsJsonOptions =\n SharedNativeRedactTextJsonOptions;\n\nexport type SharedNativeDiagnosticsStreamJsonOptions =\n SharedNativeRedactTextJsonOptions & {\n onBatch: NativeDiagnosticsBatchCallback;\n };\n\nexport type SharedNativeRedactTextStreamJsonOptions =\n SharedNativeRedactTextJsonOptions & {\n onEvent: NativeResultEventCallback;\n };\n\nexport type NativeNormalizeOptions = {\n binding: NativeAnonymizeBinding;\n text: string;\n};\n\nexport type NativeAnonymizerFromConfigOptions = {\n binding: NativeAnonymizeBinding;\n config: NativePreparedSearchConfig;\n};\n\nexport type NativeAnonymizerFromPackageOptions = {\n binding: NativeAnonymizeBinding;\n packageBytes: Uint8Array;\n};\n\nexport type NativePipelineFromPackageOptions =\n NativeAnonymizerFromPackageOptions;\n\nexport type NativeBindingVersionOptions = {\n binding: NativeAnonymizeBinding;\n expectedVersion: string;\n};\n\nexport class PreparedNativeRedactionSession {\n readonly #session: NativePreparedRedactionSessionBinding;\n\n constructor(session: NativePreparedRedactionSessionBinding) {\n this.#session = session;\n }\n\n sessionId(): string {\n return this.#session.sessionId();\n }\n\n session_id(): string {\n return this.sessionId();\n }\n\n mappingCount(): number {\n return this.#session.mappingCount();\n }\n\n mapping_count(): number {\n return this.mappingCount();\n }\n\n restoreText(fullText: string, observedAtEpochSeconds?: number): string {\n if (observedAtEpochSeconds === undefined) {\n return this.#session.restoreText(fullText);\n }\n return this.#session.restoreTextAt(fullText, observedAtEpochSeconds);\n }\n\n restore_text(fullText: string, observedAtEpochSeconds?: number): string {\n return this.restoreText(fullText, observedAtEpochSeconds);\n }\n\n toPlaintextJson(): string {\n return this.#session.toPlaintextJson();\n }\n\n to_plaintext_json(): string {\n return this.toPlaintextJson();\n }\n\n toPlaintextJsonAt(observedAtEpochSeconds: number): string {\n return this.#session.toPlaintextJsonAt(observedAtEpochSeconds);\n }\n\n to_plaintext_json_at(observedAtEpochSeconds: number): string {\n return this.toPlaintextJsonAt(observedAtEpochSeconds);\n }\n\n toEncryptedArchive(key: Uint8Array): Uint8Array {\n return this.#session.toEncryptedArchive(key);\n }\n\n to_encrypted_archive(key: Uint8Array): Uint8Array {\n return this.toEncryptedArchive(key);\n }\n\n toEncryptedArchiveAt(\n key: Uint8Array,\n observedAtEpochSeconds: number,\n ): Uint8Array {\n return this.#session.toEncryptedArchiveAt(key, observedAtEpochSeconds);\n }\n\n to_encrypted_archive_at(\n key: Uint8Array,\n observedAtEpochSeconds: number,\n ): Uint8Array {\n return this.toEncryptedArchiveAt(key, observedAtEpochSeconds);\n }\n\n inspect(observedAtEpochSeconds?: number): NativeSessionMetadata {\n const metadata: CanonicalSessionMetadata = JSON.parse(\n this.#session.inspectJson(observedAtEpochSeconds),\n );\n return {\n sessionId: metadata.session_id,\n createdAtEpochSeconds: metadata.created_at_epoch_seconds,\n expiresAtEpochSeconds: metadata.expires_at_epoch_seconds,\n mappingCount: metadata.mapping_count,\n status: metadata.status,\n };\n }\n\n delete(): NativeSessionDeletionSummary {\n const summary: CanonicalSessionDeletionSummary = JSON.parse(\n this.#session.deleteJson(),\n );\n return {\n sessionId: summary.session_id,\n deletedMappingCount: summary.deleted_mapping_count,\n };\n }\n\n redactStaticEntities(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n const result: CanonicalStaticRedactionResult = JSON.parse(\n this.redact_text_json(fullText, operators),\n );\n return fromCanonicalStaticRedactionResult(result);\n }\n\n redactText(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntities(fullText, operators);\n }\n\n redact_text(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactText(fullText, operators);\n }\n\n redactTextJson(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redact_text_json(fullText, operators);\n }\n\n redact_text_json(fullText: string, operators?: NativeOperatorConfig): string {\n return this.#session.redactStaticEntitiesJson(\n fullText,\n toBindingOperatorConfig(operators),\n );\n }\n\n redactStaticEntitiesAt(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n const result: CanonicalStaticRedactionResult = JSON.parse(\n this.redactTextJsonAt(options),\n );\n return fromCanonicalStaticRedactionResult(result);\n }\n\n redactTextAt(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntitiesAt(options);\n }\n\n redact_text_at(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n return this.redactTextAt(options);\n }\n\n redact_static_entities_at(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntitiesAt(options);\n }\n\n redactTextJsonAt({\n fullText,\n observedAtEpochSeconds,\n operators,\n }: NativeSessionRedactionAtOptions): string {\n return this.#session.redactStaticEntitiesJsonAt(\n fullText,\n observedAtEpochSeconds,\n toBindingOperatorConfig(operators),\n );\n }\n\n redact_text_json_at(options: NativeSessionRedactionAtOptions): string {\n return this.redactTextJsonAt(options);\n }\n\n planTextBatchWithCallerDetections({\n inputs,\n operators,\n observedAtEpochSeconds,\n }: NativeSessionCallerRedactionPlanOptions): PreparedNativeSessionRedactionPlan {\n const bindingOperators = toBindingOperatorConfig(operators);\n const bindingPlan = this.#session.planStaticEntitiesWithCallerDetections({\n inputs: toBindingSessionCallerInputs(inputs),\n ...(bindingOperators === undefined\n ? {}\n : { operators: bindingOperators }),\n ...(observedAtEpochSeconds === undefined\n ? {}\n : { observedAtEpochSeconds }),\n });\n return new PreparedNativeSessionRedactionPlan(bindingPlan);\n }\n}\n\nexport class PreparedNativeSessionRedactionPlan {\n readonly blocks: readonly NativeSessionBlockRedactionPlan[];\n readonly #plan: NativePreparedSessionRedactionPlanBinding;\n\n constructor(plan: NativePreparedSessionRedactionPlanBinding) {\n this.#plan = plan;\n const blocks: CanonicalSessionRedactionPlanResult[] = JSON.parse(\n plan.resultJson(),\n );\n this.blocks = blocks.map(\n ({ caller_entity_count, entity_count, replacements }) => ({\n replacements,\n entityCount: entity_count,\n callerEntityCount: caller_entity_count,\n }),\n );\n }\n\n commit(): void {\n this.#plan.commit();\n }\n}\n\nexport class PreparedNativeAnonymizer {\n readonly #prepared: NativePreparedSearchBinding;\n\n constructor(prepared: NativePreparedSearchBinding) {\n this.#prepared = prepared;\n }\n\n prepareDiagnosticsJson(): string {\n return this.#prepared.prepareDiagnosticsJson();\n }\n\n prepare_diagnostics_json(): string {\n return this.prepareDiagnosticsJson();\n }\n\n warmLazyRegex(): void {\n this.#prepared.warmLazyRegex();\n }\n\n warm_lazy_regex(): void {\n this.warmLazyRegex();\n }\n\n warmLazyRegexDiagnosticsJson(): string {\n return this.#prepared.warmLazyRegexDiagnosticsJson();\n }\n\n warm_lazy_regex_diagnostics_json(): string {\n return this.warmLazyRegexDiagnosticsJson();\n }\n\n createRedactionSession(sessionId: string): PreparedNativeRedactionSession {\n return new PreparedNativeRedactionSession(\n this.#prepared.createRedactionSession(sessionId),\n );\n }\n\n create_redaction_session(sessionId: string): PreparedNativeRedactionSession {\n return this.createRedactionSession(sessionId);\n }\n\n createRedactionSessionWithLifecycle({\n sessionId,\n createdAtEpochSeconds,\n expiresAtEpochSeconds,\n }: NativeCreateSessionWithLifecycleOptions): PreparedNativeRedactionSession {\n return new PreparedNativeRedactionSession(\n this.#prepared.createRedactionSessionWithLifecycle(\n sessionId,\n createdAtEpochSeconds,\n expiresAtEpochSeconds,\n ),\n );\n }\n\n create_redaction_session_with_lifecycle(\n options: NativeCreateSessionWithLifecycleOptions,\n ): PreparedNativeRedactionSession {\n return this.createRedactionSessionWithLifecycle(options);\n }\n\n restoreRedactionSession(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n return new PreparedNativeRedactionSession(\n this.#prepared.restoreRedactionSession(plaintextJson),\n );\n }\n\n restore_redaction_session(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n return this.restoreRedactionSession(plaintextJson);\n }\n\n restoreEncryptedRedactionSession({\n archive,\n key,\n expectedSessionId,\n observedAtEpochSeconds,\n }: NativeOpenSessionArchiveOptions): PreparedNativeRedactionSession {\n return new PreparedNativeRedactionSession(\n this.#prepared.restoreEncryptedRedactionSession({\n archive,\n key,\n expectedSessionId,\n ...(observedAtEpochSeconds === undefined\n ? {}\n : { observedAtEpochSeconds }),\n }),\n );\n }\n\n restore_encrypted_redaction_session(\n options: NativeOpenSessionArchiveOptions,\n ): PreparedNativeRedactionSession {\n return this.restoreEncryptedRedactionSession(options);\n }\n\n redactStaticEntities(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return toNativeStaticRedactionResult(\n this.#prepared.redactStaticEntities(\n fullText,\n toBindingOperatorConfig(operators),\n ),\n );\n }\n\n redact_text(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntities(fullText, operators);\n }\n\n redact_text_json(fullText: string, operators?: NativeOperatorConfig): string {\n const bindingOperators = toBindingOperatorConfig(operators);\n return this.#prepared.redactStaticEntitiesJson(fullText, bindingOperators);\n }\n\n redactStaticEntitiesWithCallerDetections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n const requestJson = callerDetectionRequestJson(\n fullText,\n options.detections,\n );\n const operators = toBindingOperatorConfig(options.operators);\n const result: CanonicalStaticRedactionResult = JSON.parse(\n this.#prepared.redactStaticEntitiesWithCallerDetectionsJson(fullText, {\n requestJson,\n ...(operators ? { operators } : {}),\n }),\n );\n return fromCanonicalStaticRedactionResult(result);\n }\n\n redact_text_with_caller_detections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntitiesWithCallerDetections(fullText, options);\n }\n\n redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string {\n const requestJson = callerDetectionRequestJson(\n fullText,\n options.detections,\n );\n const operators = toBindingOperatorConfig(options.operators);\n return this.#prepared.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(\n fullText,\n {\n requestJson,\n ...(operators ? { operators } : {}),\n },\n );\n }\n\n redact_static_entities_with_caller_detections_diagnostics_json(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string {\n return this.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(\n fullText,\n options,\n );\n }\n\n redactTextJson(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redact_text_json(fullText, operators);\n }\n\n redactTextStreamJson(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#prepared.redactStaticEntitiesResultStreamJson(\n fullText,\n toBindingOperatorConfig(operators),\n onEvent,\n );\n }\n\n redact_text_stream_json(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redactStaticEntitiesDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#prepared.redactStaticEntitiesDiagnosticsJson(\n fullText,\n toBindingOperatorConfig(operators),\n );\n }\n\n diagnostics_json(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redactStaticEntitiesDiagnosticsJson(fullText, operators);\n }\n\n diagnosticsStreamJson(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#prepared.redactStaticEntitiesDiagnosticsStreamJson(\n fullText,\n toBindingOperatorConfig(operators),\n onBatch,\n );\n }\n\n diagnostics_stream_json(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n redactStaticEntitiesSummaryDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#prepared.redactStaticEntitiesSummaryDiagnosticsJson(\n fullText,\n toBindingOperatorConfig(operators),\n );\n }\n\n summary_diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.redactStaticEntitiesSummaryDiagnosticsJson(fullText, operators);\n }\n}\n\nexport class PreparedNativePipeline {\n readonly #anonymizer: PreparedNativeAnonymizer;\n\n constructor(anonymizer: PreparedNativeAnonymizer) {\n this.#anonymizer = anonymizer;\n }\n\n prepareDiagnosticsJson(): string {\n return this.#anonymizer.prepareDiagnosticsJson();\n }\n\n prepare_diagnostics_json(): string {\n return this.prepareDiagnosticsJson();\n }\n\n warmLazyRegex(): void {\n this.#anonymizer.warmLazyRegex();\n }\n\n warm_lazy_regex(): void {\n this.warmLazyRegex();\n }\n\n warmLazyRegexDiagnosticsJson(): string {\n return this.#anonymizer.warmLazyRegexDiagnosticsJson();\n }\n\n warm_lazy_regex_diagnostics_json(): string {\n return this.warmLazyRegexDiagnosticsJson();\n }\n\n createRedactionSession(sessionId: string): PreparedNativeRedactionSession {\n return this.#anonymizer.createRedactionSession(sessionId);\n }\n\n create_redaction_session(sessionId: string): PreparedNativeRedactionSession {\n return this.createRedactionSession(sessionId);\n }\n\n createRedactionSessionWithLifecycle(\n options: NativeCreateSessionWithLifecycleOptions,\n ): PreparedNativeRedactionSession {\n return this.#anonymizer.createRedactionSessionWithLifecycle(options);\n }\n\n create_redaction_session_with_lifecycle(\n options: NativeCreateSessionWithLifecycleOptions,\n ): PreparedNativeRedactionSession {\n return this.createRedactionSessionWithLifecycle(options);\n }\n\n restoreRedactionSession(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n return this.#anonymizer.restoreRedactionSession(plaintextJson);\n }\n\n restore_redaction_session(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n return this.restoreRedactionSession(plaintextJson);\n }\n\n restoreEncryptedRedactionSession(\n options: NativeOpenSessionArchiveOptions,\n ): PreparedNativeRedactionSession {\n return this.#anonymizer.restoreEncryptedRedactionSession(options);\n }\n\n restore_encrypted_redaction_session(\n options: NativeOpenSessionArchiveOptions,\n ): PreparedNativeRedactionSession {\n return this.restoreEncryptedRedactionSession(options);\n }\n\n redactText(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.#anonymizer.redactStaticEntities(fullText, operators);\n }\n\n redact_text(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactText(fullText, operators);\n }\n\n redact_text_json(fullText: string, operators?: NativeOperatorConfig): string {\n return this.#anonymizer.redact_text_json(fullText, operators);\n }\n\n redactTextWithCallerDetections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n return this.#anonymizer.redactStaticEntitiesWithCallerDetections(\n fullText,\n options,\n );\n }\n\n redact_text_with_caller_detections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n return this.redactTextWithCallerDetections(fullText, options);\n }\n\n redactTextWithCallerDetectionsDiagnosticsJson(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string {\n return this.#anonymizer.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(\n fullText,\n options,\n );\n }\n\n redact_text_with_caller_detections_diagnostics_json(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string {\n return this.redactTextWithCallerDetectionsDiagnosticsJson(\n fullText,\n options,\n );\n }\n\n redactTextJson(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redact_text_json(fullText, operators);\n }\n\n redactTextStreamJson(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#anonymizer.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redact_text_stream_json(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redactTextDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#anonymizer.redactStaticEntitiesDiagnosticsJson(\n fullText,\n operators,\n );\n }\n\n diagnostics_json(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redactTextDiagnosticsJson(fullText, operators);\n }\n\n diagnosticsStreamJson(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#anonymizer.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n diagnostics_stream_json(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n redactTextSummaryDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#anonymizer.redactStaticEntitiesSummaryDiagnosticsJson(\n fullText,\n operators,\n );\n }\n\n summary_diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.redactTextSummaryDiagnosticsJson(fullText, operators);\n }\n}\n\nexport const encodeNativeSearchConfig = (\n config: NativePreparedSearchConfig,\n): Uint8Array => new TextEncoder().encode(JSON.stringify(config));\n\nexport const encodeNativeSearchConfigInput = (\n config: NativeSearchPackageInput,\n): Uint8Array => {\n if (typeof config === \"string\") {\n return new TextEncoder().encode(config);\n }\n if (config instanceof Uint8Array) {\n return config;\n }\n return encodeNativeSearchConfig(config);\n};\n\nexport const getNativeBindingVersion = (\n binding: NativeAnonymizeBinding,\n): string => binding.nativePackageVersion();\n\nexport const native_package_version = getNativeBindingVersion;\n\nexport const normalize_for_search = ({\n binding,\n text,\n}: NativeNormalizeOptions): string => binding.normalizeForSearch(text);\n\nexport const assertNativeBindingVersion = ({\n binding,\n expectedVersion,\n}: NativeBindingVersionOptions): void => {\n const actualVersion = getNativeBindingVersion(binding);\n if (actualVersion !== expectedVersion) {\n throw new Error(\n `Native anonymize binding version ${actualVersion} does not match ${expectedVersion}`,\n );\n }\n};\n\nexport const prepareNativeSearchPackage = ({\n binding,\n config,\n compressed = false,\n}: NativeSearchPackageOptions): Uint8Array => {\n const configBytes = encodeNativeSearchConfig(config);\n return compressed\n ? binding.prepareStaticSearchCompressedPackageBytes(configBytes)\n : binding.prepareStaticSearchPackageBytes(configBytes);\n};\n\nexport const prepare_search_package = ({\n binding,\n config,\n compressed = false,\n}: SharedNativeSearchPackageOptions): Uint8Array => {\n const configBytes = encodeNativeSearchConfigInput(config);\n return compressed\n ? binding.prepareStaticSearchCompressedPackageBytes(configBytes)\n : binding.prepareStaticSearchPackageBytes(configBytes);\n};\n\nexport const createNativeAnonymizerFromConfig = ({\n binding,\n config,\n}: NativeAnonymizerFromConfigOptions): PreparedNativeAnonymizer =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfig(config),\n ),\n );\n\nexport const createNativeAnonymizerFromPackage = ({\n binding,\n packageBytes,\n}: NativeAnonymizerFromPackageOptions): PreparedNativeAnonymizer =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromPreparedPackageBytes(packageBytes),\n );\n\nexport const load_prepared_package = ({\n binding,\n packageBytes,\n}: SharedNativePreparedPackageOptions): PreparedNativeAnonymizer =>\n createNativeAnonymizerFromPackage({ binding, packageBytes });\n\nexport const redact_text_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeRedactTextJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text_json(fullText, operators);\n\nexport const redact_text = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeRedactTextOptions): NativeStaticRedactionResult =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text(fullText, operators);\n\nexport const redact_text_stream_json = ({\n binding,\n config,\n fullText,\n operators,\n onEvent,\n}: SharedNativeRedactTextStreamJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text_stream_json(fullText, onEvent, operators);\n\nexport const diagnostics_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeDiagnosticsJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).diagnostics_json(fullText, operators);\n\nexport const diagnostics_stream_json = ({\n binding,\n config,\n fullText,\n operators,\n onBatch,\n}: SharedNativeDiagnosticsStreamJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).diagnostics_stream_json(fullText, onBatch, operators);\n\nexport const summary_diagnostics_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeDiagnosticsJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).summary_diagnostics_json(fullText, operators);\n\nexport const createNativePipelineFromPackage = ({\n binding,\n packageBytes,\n}: NativePipelineFromPackageOptions): PreparedNativePipeline =>\n new PreparedNativePipeline(\n createNativeAnonymizerFromPackage({ binding, packageBytes }),\n );\n\nexport const PreparedSearch = PreparedNativeAnonymizer;\nexport type PreparedSearch = PreparedNativeAnonymizer;\nexport const PreparedAnonymizer = PreparedNativeAnonymizer;\nexport type PreparedAnonymizer = PreparedNativeAnonymizer;\n\nconst toBindingOperatorConfig = (\n config: NativeOperatorConfig | undefined,\n): NativeBindingOperatorConfig | undefined => {\n if (!config) {\n return undefined;\n }\n const bindingConfig: NativeBindingOperatorConfig = {};\n if (config.operators !== undefined) {\n bindingConfig.operators = config.operators;\n }\n if (config.redactString !== undefined) {\n bindingConfig.redactString = config.redactString;\n }\n return bindingConfig;\n};\n\nconst toNativeStaticRedactionResult = (\n result: NativeBindingStaticRedactionResult,\n): NativeStaticRedactionResult => ({\n resolvedEntities: result.resolvedEntities.map(toNativePipelineEntity),\n redaction: toNativeRedactionResult(result.redaction),\n});\n\nconst fromCanonicalStaticRedactionResult = (\n result: CanonicalStaticRedactionResult,\n): NativeStaticRedactionResult => ({\n resolvedEntities: result.resolved_entities.map(\n ({ source_detail, provider_id, detection_id, ...entity }) => ({\n ...entity,\n ...(source_detail ? { sourceDetail: source_detail } : {}),\n ...(provider_id ? { providerId: provider_id } : {}),\n ...(detection_id ? { detectionId: detection_id } : {}),\n }),\n ),\n redaction: {\n redactedText: result.redaction.redacted_text,\n redactionMap: toRedactionMap(result.redaction.redaction_map),\n operatorMap: toOperatorMap(result.redaction.operator_map),\n entityCount: result.redaction.entity_count,\n },\n});\n\nconst toNativePipelineEntity = (\n entity: NativeBindingPipelineEntity,\n): NativePipelineEntity => ({\n start: entity.start,\n end: entity.end,\n label: entity.label,\n text: entity.text,\n score: entity.score,\n source: entity.source,\n ...(entity.sourceDetail ? { sourceDetail: entity.sourceDetail } : {}),\n ...(entity.providerId ? { providerId: entity.providerId } : {}),\n ...(entity.detectionId ? { detectionId: entity.detectionId } : {}),\n});\n\nconst toNativeRedactionResult = (\n result: NativeBindingRedactionResult,\n): NativeRedactionResult => ({\n redactedText: result.redactedText,\n redactionMap: toRedactionMap(result.redactionMap),\n operatorMap: toOperatorMap(result.operatorMap),\n entityCount: result.entityCount,\n});\n\nconst toRedactionMap = (\n entries: readonly NativeBindingRedactionEntry[],\n): Map<string, string> => {\n const map = new Map<string, string>();\n for (const entry of entries) {\n map.set(entry.placeholder, entry.original);\n }\n return map;\n};\n\nconst toOperatorMap = (\n entries: readonly NativeBindingOperatorEntry[],\n): Map<string, OperatorType> => {\n const map = new Map<string, OperatorType>();\n for (const entry of entries) {\n map.set(entry.placeholder, entry.operator);\n }\n return map;\n};\n"],"mappings":";;AAwTA,MAAa,gCAAgC;CAC3C,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,WAAW;EACT;EACA;EACA;EACA;EACA;CACF;CACA,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,MAAM,CAAC,cAAc,QAAQ;AAC/B;AAgDA,MAAM,wBACJ,UAEC,OAAO,UAAU,YAAY,UAAU,QAAS,OAAO,UAAU;;AAGpE,MAAa,4BACX,cACwC;CACxC,IAAI,CAAC,qBAAqB,SAAS,GACjC,OAAO;CAET,IACE,CAAC,8BAA8B,KAAK,OACjC,SAAS,OAAO,UAAU,UAAU,UACvC,GAEA,OAAO;CAET,MAAM,iBAAiB,UAAU;CACjC,OACE,qBAAqB,cAAc,KACnC,8BAA8B,UAAU,OACrC,SAAS,OAAO,eAAe,UAAU,UAC5C;AAEJ;AAOA,MAAa,oCAAoC;AACjD,MAAa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AAa,OAAO,UAAU;CAChC;AACF;AAEA,MAAM,0BACJ,YAC0B;CAC1B,OAAO,OAAO;CACd,KAAK,OAAO;CACZ,OAAO,OAAO;CACd,MAAM,OAAO;CACb,OAAO,OAAO;CACd,QAAQ,OAAO;CACf,GAAI,OAAO,eAAe,EAAE,cAAc,OAAO,aAAa,IAAI,CAAC;CACnE,GAAI,OAAO,aAAa,EAAE,YAAY,OAAO,WAAW,IAAI,CAAC;CAC7D,GAAI,OAAO,cAAc,EAAE,aAAa,OAAO,YAAY,IAAI,CAAC;AAClE;AAEA,MAAM,2BACJ,YAC2B;CAC3B,cAAc,OAAO;CACrB,cAAc,eAAe,OAAO,YAAY;CAChD,aAAa,cAAc,OAAO,WAAW;CAC7C,aAAa,OAAO;AACtB;AAEA,MAAM,kBACJ,YACwB;CACxB,MAAM,sBAAM,IAAI,IAAoB;CACpC,KAAK,MAAM,SAAS,SAClB,IAAI,IAAI,MAAM,aAAa,MAAM,QAAQ;CAE3C,OAAO;AACT;AAEA,MAAM,iBACJ,YAC8B;CAC9B,MAAM,sBAAM,IAAI,IAA0B;CAC1C,KAAK,MAAM,SAAS,SAClB,IAAI,IAAI,MAAM,aAAa,MAAM,QAAQ;CAE3C,OAAO;AACT"}
1
+ {"version":3,"file":"native.mjs","names":["#maximumBytes","#label","#reportedMaximumBytes","#reserve","#requireNumber","#appendNumber","#appendReservedRun","#bytes","#chunks","#suffix","#session","#plan","#prepared","#anonymizer"],"sources":["../src/native.ts"],"sourcesContent":["import type { NativePreparedSearchConfig } from \"./native-search-config\";\nimport type { OperatorSelection, OperatorType } from \"./types\";\n\nexport type { NativePreparedSearchConfig } from \"./native-search-config\";\n\ntype NativeBindingOperatorConfig = {\n operators?: Record<string, OperatorSelection>;\n redactString?: string;\n};\n\ntype NativeBindingCallerRedactionOptions = {\n requestJson: string;\n operators?: NativeBindingOperatorConfig;\n};\n\ntype NativeBindingSessionCallerRedactionInput = {\n fullText: string;\n requestJson: string;\n};\n\ntype NativeBindingSessionCallerRedactionPlanOptions = {\n inputs: NativeBindingSessionCallerRedactionInput[];\n operators?: NativeBindingOperatorConfig;\n observedAtEpochSeconds?: number;\n};\n\ntype NativeBindingOpenSessionArchiveOptions = {\n archive: Uint8Array;\n key: Uint8Array;\n expectedSessionId: string;\n observedAtEpochSeconds?: number;\n};\n\nexport type NativeDiagnosticsBatchCallback = (diagnosticsJson: string) => void;\nexport type NativeResultEventCallback = (eventJson: string) => void;\n\ntype NativeBindingRedactionEntry = {\n placeholder: string;\n original: string;\n};\n\ntype NativeBindingOperatorEntry = {\n placeholder: string;\n operator: OperatorType;\n};\n\ntype NativeBindingPipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n sourceDetail?: string | null;\n providerId?: string | null;\n detectionId?: string | null;\n};\n\ntype NativeBindingRedactionResult = {\n redactedText: string;\n redactionMap: NativeBindingRedactionEntry[];\n operatorMap: NativeBindingOperatorEntry[];\n entityCount: number;\n};\n\ntype NativeBindingStaticRedactionResult = {\n resolvedEntities: NativeBindingPipelineEntity[];\n redaction: NativeBindingRedactionResult;\n};\n\ntype CanonicalPipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n source_detail?: string | null;\n provider_id?: string | null;\n detection_id?: string | null;\n};\n\ntype CanonicalStaticRedactionResult = {\n resolved_entities: CanonicalPipelineEntity[];\n redaction: {\n redacted_text: string;\n redaction_map: NativeBindingRedactionEntry[];\n operator_map: NativeBindingOperatorEntry[];\n entity_count: number;\n };\n};\n\ntype CanonicalSessionMetadata = {\n session_id: string;\n created_at_epoch_seconds: number | null;\n expires_at_epoch_seconds: number | null;\n mapping_count: number;\n status: NativeSessionStatus;\n};\n\ntype CanonicalSessionDeletionSummary = {\n session_id: string;\n deleted_mapping_count: number;\n};\n\ntype CanonicalSessionRedactionPlanResult = {\n replacements: Array<{ start: number; end: number; replacement: string }>;\n entity_count: number;\n caller_entity_count: number;\n};\n\nexport type NativeSessionStatus =\n | \"active\"\n | \"not_yet_active\"\n | \"expired\"\n | \"deleted\";\n\nexport type NativeSessionLifecycle = {\n createdAtEpochSeconds: number;\n expiresAtEpochSeconds?: number;\n};\n\nexport type NativeSessionMetadata = {\n sessionId: string;\n createdAtEpochSeconds: number | null;\n expiresAtEpochSeconds: number | null;\n mappingCount: number;\n status: NativeSessionStatus;\n};\n\nexport type NativeSessionDeletionSummary = {\n sessionId: string;\n deletedMappingCount: number;\n};\n\nexport type NativeSessionRedactionAtOptions = {\n fullText: string;\n observedAtEpochSeconds: number;\n operators?: NativeOperatorConfig;\n};\n\nexport type NativeCreateSessionWithLifecycleOptions = NativeSessionLifecycle & {\n sessionId: string;\n};\n\nexport type NativeOpenSessionArchiveOptions = {\n archive: Uint8Array;\n key: Uint8Array;\n expectedSessionId: string;\n observedAtEpochSeconds?: number;\n};\n\nexport type NativePreparedRedactionSessionBinding = {\n sessionId: () => string;\n mappingCount: () => number;\n restoreText: (fullText: string) => string;\n restoreTextAt: (fullText: string, observedAtEpochSeconds: number) => string;\n toPlaintextJson: () => string;\n toPlaintextJsonAt: (observedAtEpochSeconds: number) => string;\n toEncryptedArchive: (key: Uint8Array) => Uint8Array;\n toEncryptedArchiveAt: (\n key: Uint8Array,\n observedAtEpochSeconds: number,\n ) => Uint8Array;\n inspectJson: (observedAtEpochSeconds?: number) => string;\n deleteJson: () => string;\n redactStaticEntitiesJson: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n redactStaticEntitiesJsonAt: (\n fullText: string,\n observedAtEpochSeconds: number,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n planStaticEntitiesWithCallerDetections: (\n options: NativeBindingSessionCallerRedactionPlanOptions,\n ) => NativePreparedSessionRedactionPlanBinding;\n};\n\nexport type NativePreparedSessionRedactionPlanBinding = {\n resultJson: () => string;\n commit: () => void;\n};\n\nexport type NativePreparedSearchBinding = {\n prepareDiagnosticsJson: () => string;\n warmLazyRegex: () => void;\n warmLazyRegexDiagnosticsJson: () => string;\n createRedactionSession: (\n sessionId: string,\n ) => NativePreparedRedactionSessionBinding;\n createRedactionSessionWithLifecycle: (\n sessionId: string,\n createdAtEpochSeconds: number,\n expiresAtEpochSeconds?: number,\n ) => NativePreparedRedactionSessionBinding;\n restoreRedactionSession: (\n plaintextJson: string,\n ) => NativePreparedRedactionSessionBinding;\n restoreEncryptedRedactionSession: (\n options: NativeBindingOpenSessionArchiveOptions,\n ) => NativePreparedRedactionSessionBinding;\n redactStaticEntities: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => NativeBindingStaticRedactionResult;\n redactStaticEntitiesJson: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n redactStaticEntitiesWithCallerDetectionsJson: (\n fullText: string,\n options: NativeBindingCallerRedactionOptions,\n ) => string;\n redactStaticEntitiesWithCallerDetectionsDiagnosticsJson: (\n fullText: string,\n options: NativeBindingCallerRedactionOptions,\n ) => string;\n redactStaticEntitiesResultStreamJson: (\n fullText: string,\n operators: NativeBindingOperatorConfig | undefined,\n onEvent: NativeResultEventCallback,\n ) => string;\n redactStaticEntitiesDiagnosticsJson: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n redactStaticEntitiesDiagnosticsStreamJson: (\n fullText: string,\n operators: NativeBindingOperatorConfig | undefined,\n onBatch: NativeDiagnosticsBatchCallback,\n ) => string;\n redactStaticEntitiesSummaryDiagnosticsJson: (\n fullText: string,\n operators?: NativeBindingOperatorConfig,\n ) => string;\n};\n\nexport type NativeAnonymizeBinding = {\n convertExternalDetectionBatch: (\n document: Uint8Array,\n batchJson: string,\n ) => NativeCallerDetection[];\n externalDetectionLimitsJson: () => string;\n extractDocxTextJson: (document: Uint8Array) => string;\n inspectPdfJson: (document: Uint8Array, observationsJson?: string) => string;\n rewritePdfRasterFromDetectionsJson: (\n document: Uint8Array,\n requestJson: string,\n pagePixels: readonly Uint8Array[],\n ) => { document: Uint8Array; certificateJson: string };\n rewriteDocxTextNative: (\n document: Uint8Array,\n rewritesJson: string,\n ) => {\n document: Uint8Array;\n rewrittenBlockCount: number;\n appliedReplacementCount: number;\n };\n planDocxRestorationJson: (document: Uint8Array, sessionId: string) => string;\n normalizeForSearch: (text: string) => string;\n nativePackageVersion: () => string;\n NativePreparedSearch: {\n fromConfigJsonBytes: (\n configJson: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromPreparedPackageBytes: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromPreparedPackageBytesWithoutCache: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromTrustedPreparedPackageBytes: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n fromTrustedPreparedPackageBytesWithoutCache: (\n packageBytes: Uint8Array,\n ) => NativePreparedSearchBinding;\n };\n prepareStaticSearchPackageBytes: (configJson: Uint8Array) => Uint8Array;\n prepareStaticSearchCompressedPackageBytes: (\n configJson: Uint8Array,\n ) => Uint8Array;\n // Rust config assembler (replaces the retired TypeScript config-assembly\n // layer). Takes the pipeline config plus out-of-band dictionaries and\n // gazetteer JSON and returns either the assembled config JSON or ready\n // package bytes. Every parity runtime must expose these required members.\n assembleStaticSearchConfigJson: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n assembleStaticSearchPackageBytes: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n assembleStaticSearchCompressedPackageBytes: (\n pipelineConfigJson: Uint8Array,\n dictionariesJson?: Uint8Array,\n gazetteerJson?: Uint8Array,\n ) => Uint8Array;\n};\n\ntype FunctionMemberNames<T> = {\n [Key in keyof T]-?: T[Key] extends (...args: never[]) => unknown\n ? Key\n : never;\n}[keyof T];\n\n/** Exhaustive runtime-member contract shared by loaders and parity gates. */\nexport const NATIVE_BINDING_PARITY_MEMBERS = {\n root: [\n \"convertExternalDetectionBatch\",\n \"externalDetectionLimitsJson\",\n \"extractDocxTextJson\",\n \"inspectPdfJson\",\n \"rewritePdfRasterFromDetectionsJson\",\n \"rewriteDocxTextNative\",\n \"planDocxRestorationJson\",\n \"normalizeForSearch\",\n \"nativePackageVersion\",\n \"prepareStaticSearchPackageBytes\",\n \"prepareStaticSearchCompressedPackageBytes\",\n \"assembleStaticSearchConfigJson\",\n \"assembleStaticSearchPackageBytes\",\n \"assembleStaticSearchCompressedPackageBytes\",\n ],\n factories: [\n \"fromConfigJsonBytes\",\n \"fromPreparedPackageBytes\",\n \"fromPreparedPackageBytesWithoutCache\",\n \"fromTrustedPreparedPackageBytes\",\n \"fromTrustedPreparedPackageBytesWithoutCache\",\n ],\n prepared: [\n \"prepareDiagnosticsJson\",\n \"warmLazyRegex\",\n \"warmLazyRegexDiagnosticsJson\",\n \"createRedactionSession\",\n \"createRedactionSessionWithLifecycle\",\n \"restoreRedactionSession\",\n \"restoreEncryptedRedactionSession\",\n \"redactStaticEntities\",\n \"redactStaticEntitiesJson\",\n \"redactStaticEntitiesWithCallerDetectionsJson\",\n \"redactStaticEntitiesWithCallerDetectionsDiagnosticsJson\",\n \"redactStaticEntitiesResultStreamJson\",\n \"redactStaticEntitiesDiagnosticsJson\",\n \"redactStaticEntitiesDiagnosticsStreamJson\",\n \"redactStaticEntitiesSummaryDiagnosticsJson\",\n ],\n session: [\n \"sessionId\",\n \"mappingCount\",\n \"restoreText\",\n \"restoreTextAt\",\n \"toPlaintextJson\",\n \"toPlaintextJsonAt\",\n \"toEncryptedArchive\",\n \"toEncryptedArchiveAt\",\n \"inspectJson\",\n \"deleteJson\",\n \"redactStaticEntitiesJson\",\n \"redactStaticEntitiesJsonAt\",\n \"planStaticEntitiesWithCallerDetections\",\n ],\n plan: [\"resultJson\", \"commit\"],\n} as const satisfies {\n root: readonly FunctionMemberNames<NativeAnonymizeBinding>[];\n factories: readonly FunctionMemberNames<\n NativeAnonymizeBinding[\"NativePreparedSearch\"]\n >[];\n prepared: readonly FunctionMemberNames<NativePreparedSearchBinding>[];\n session: readonly FunctionMemberNames<NativePreparedRedactionSessionBinding>[];\n plan: readonly FunctionMemberNames<NativePreparedSessionRedactionPlanBinding>[];\n};\n\nconst ROOT_PARITY_IS_EXHAUSTIVE: Exclude<\n FunctionMemberNames<NativeAnonymizeBinding>,\n (typeof NATIVE_BINDING_PARITY_MEMBERS.root)[number]\n> extends never\n ? true\n : never = true;\nconst FACTORY_PARITY_IS_EXHAUSTIVE: Exclude<\n FunctionMemberNames<NativeAnonymizeBinding[\"NativePreparedSearch\"]>,\n (typeof NATIVE_BINDING_PARITY_MEMBERS.factories)[number]\n> extends never\n ? true\n : never = true;\nconst PREPARED_PARITY_IS_EXHAUSTIVE: Exclude<\n FunctionMemberNames<NativePreparedSearchBinding>,\n (typeof NATIVE_BINDING_PARITY_MEMBERS.prepared)[number]\n> extends never\n ? true\n : never = true;\nconst SESSION_PARITY_IS_EXHAUSTIVE: Exclude<\n FunctionMemberNames<NativePreparedRedactionSessionBinding>,\n (typeof NATIVE_BINDING_PARITY_MEMBERS.session)[number]\n> extends never\n ? true\n : never = true;\nconst PLAN_PARITY_IS_EXHAUSTIVE: Exclude<\n FunctionMemberNames<NativePreparedSessionRedactionPlanBinding>,\n (typeof NATIVE_BINDING_PARITY_MEMBERS.plan)[number]\n> extends never\n ? true\n : never = true;\nvoid [\n ROOT_PARITY_IS_EXHAUSTIVE,\n FACTORY_PARITY_IS_EXHAUSTIVE,\n PREPARED_PARITY_IS_EXHAUSTIVE,\n SESSION_PARITY_IS_EXHAUSTIVE,\n PLAN_PARITY_IS_EXHAUSTIVE,\n];\n\nconst isBindingPropertyBag = (\n value: unknown,\n): value is Record<string, unknown> =>\n (typeof value === \"object\" && value !== null) || typeof value === \"function\";\n\n/** Validate the complete runtime-neutral root and factory binding shape. */\nexport const isNativeAnonymizeBinding = (\n candidate: unknown,\n): candidate is NativeAnonymizeBinding => {\n if (!isBindingPropertyBag(candidate)) {\n return false;\n }\n if (\n !NATIVE_BINDING_PARITY_MEMBERS.root.every(\n (name) => typeof candidate[name] === \"function\",\n )\n ) {\n return false;\n }\n const preparedSearch = candidate[\"NativePreparedSearch\"];\n return (\n isBindingPropertyBag(preparedSearch) &&\n NATIVE_BINDING_PARITY_MEMBERS.factories.every(\n (name) => typeof preparedSearch[name] === \"function\",\n )\n );\n};\n\nexport type NativeOperatorConfig = {\n operators?: Record<string, OperatorSelection>;\n redactString?: string;\n};\n\nexport const CALLER_DETECTION_CONTRACT_VERSION = 2;\nexport const CALLER_DETECTION_MAX_COUNT = 1_000_000;\nexport const CALLER_DETECTION_TEXT_MAX_BYTES = 64 * 1024 * 1024;\nexport const CALLER_DETECTION_REQUEST_JSON_MAX_BYTES = 16 * 1024 * 1024;\nexport const SESSION_CALLER_MAX_INPUTS = 100_000;\nexport const SESSION_CALLER_INPUTS_JSON_MAX_BYTES = 64 * 1024 * 1024;\n\nexport const EXTERNAL_DETECTION_BATCH_VERSION = 1 as const;\nexport const EXTERNAL_DETECTION_BATCH_MAX_BYTES = 16 * 1024 * 1024;\nexport const EXTERNAL_DETECTION_DOCUMENT_MAX_BYTES = 64 * 1024 * 1024;\nexport const EXTERNAL_DETECTION_MAX_DETECTIONS = 100_000;\nexport const EXTERNAL_DETECTION_MAX_LABEL_MAPPINGS = 4_096;\nexport const EXTERNAL_DETECTION_MAX_METADATA_BYTES = 256;\nexport const EXTERNAL_DETECTION_PROVIDER_ID_MAX_BYTES = 128;\n\nexport const EXTERNAL_DETECTION_OFFSET_UNITS = {\n unicodeCodePoint: \"unicode-code-point\",\n utf16CodeUnit: \"utf16-code-unit\",\n utf8Byte: \"utf8-byte\",\n} as const;\n\nexport type ExternalDetectionOffsetUnit =\n (typeof EXTERNAL_DETECTION_OFFSET_UNITS)[keyof typeof EXTERNAL_DETECTION_OFFSET_UNITS];\n\nexport type ExternalDetectionBatch = {\n version: typeof EXTERNAL_DETECTION_BATCH_VERSION;\n document: { sha256: string };\n offsetUnit: ExternalDetectionOffsetUnit;\n provider: { id: string; name: string; version: string };\n labelMap: readonly {\n providerLabel: string;\n entityLabel: string;\n }[];\n detections: readonly {\n id: string;\n start: number;\n end: number;\n label: string;\n score: number;\n }[];\n};\n\nexport type NativeCallerDetection = {\n start: number;\n end: number;\n label: string;\n score: number;\n providerId: string;\n detectionId: string;\n};\n\nexport type ConvertExternalDetectionBatchOptions = {\n binding: NativeAnonymizeBinding;\n document: Uint8Array;\n batch: ExternalDetectionBatch | string;\n};\n\nexport const convert_external_detection_batch = ({\n binding,\n document,\n batch,\n}: ConvertExternalDetectionBatchOptions): NativeCallerDetection[] => {\n return binding.convertExternalDetectionBatch(\n document,\n typeof batch === \"string\" ? batch : JSON.stringify(batch),\n );\n};\n\nexport type NativeCallerRedactionOptions = {\n detections: readonly NativeCallerDetection[];\n operators?: NativeOperatorConfig;\n};\n\nexport type NativeSessionCallerRedactionInput = {\n fullText: string;\n detections: readonly NativeCallerDetection[];\n};\n\nexport type NativeSessionCallerRedactionPlanOptions = {\n inputs: readonly NativeSessionCallerRedactionInput[];\n operators?: NativeOperatorConfig;\n observedAtEpochSeconds?: number;\n};\n\nexport type NativeTextReplacement = {\n start: number;\n end: number;\n replacement: string;\n};\n\nexport type NativeSessionBlockRedactionPlan = {\n replacements: readonly NativeTextReplacement[];\n entityCount: number;\n callerEntityCount: number;\n};\n\nconst utf8ByteLengthWithin = (\n text: string,\n maximum: number,\n): number | undefined => {\n let bytes = 0;\n for (let index = 0; index < text.length; index += 1) {\n const unit = text.charCodeAt(index);\n if (unit <= 0x7f) {\n bytes += 1;\n } else if (unit <= 0x7ff) {\n bytes += 2;\n } else if (\n unit >= 0xd800 &&\n unit <= 0xdbff &&\n index + 1 < text.length &&\n text.charCodeAt(index + 1) >= 0xdc00 &&\n text.charCodeAt(index + 1) <= 0xdfff\n ) {\n bytes += 4;\n index += 1;\n } else {\n bytes += 3;\n }\n if (bytes > maximum) {\n return undefined;\n }\n }\n return bytes;\n};\n\nconst validateCallerDetectionInput = (\n fullText: string,\n detections: readonly NativeCallerDetection[],\n): number => {\n if (!Array.isArray(detections)) {\n throw new TypeError(\"Caller detections must be an array\");\n }\n if (detections.length > CALLER_DETECTION_MAX_COUNT) {\n throw new RangeError(\n `Caller detections contains ${detections.length} items; the maximum is ${CALLER_DETECTION_MAX_COUNT}`,\n );\n }\n const textBytes = utf8ByteLengthWithin(\n fullText,\n CALLER_DETECTION_TEXT_MAX_BYTES,\n );\n if (textBytes === undefined) {\n throw new RangeError(\n `Caller detection text exceeds the ${CALLER_DETECTION_TEXT_MAX_BYTES}-byte maximum`,\n );\n }\n return textBytes;\n};\n\nabstract class BoundedJsonSink {\n readonly #maximumBytes: number;\n readonly #label: string;\n readonly #reportedMaximumBytes: number;\n #bytes = 0;\n\n constructor(maximumBytes: number, label: string, suffix: string) {\n this.#maximumBytes = maximumBytes - suffix.length;\n this.#label = label;\n this.#reportedMaximumBytes = maximumBytes;\n }\n\n appendAscii(value: string): void {\n this.#reserve(value.length);\n this.capture(value);\n }\n\n appendOffset(value: number, field: string): void {\n this.#requireNumber(value, field);\n if (!Number.isInteger(value) || value < 0 || value > 0xff_ff_ff_ff) {\n throw new RangeError(\n `${field} must be an integer between 0 and 4294967295`,\n );\n }\n this.#appendNumber(value);\n }\n\n appendScore(value: number, field: string): void {\n this.#requireNumber(value, field);\n if (!Number.isFinite(value) || value < 0 || value > 1) {\n throw new RangeError(`${field} must be finite and between 0 and 1`);\n }\n this.#appendNumber(value);\n }\n\n appendString(value: string, field: string): void {\n if (typeof value !== \"string\") {\n throw new TypeError(`${field} must be a string`);\n }\n this.appendAscii('\"');\n let runStart = 0;\n for (let index = 0; index < value.length; index += 1) {\n const unit = value.charCodeAt(index);\n const escape = jsonEscape(unit);\n if (escape !== undefined) {\n this.#appendReservedRun(value, runStart, index);\n this.appendAscii(escape);\n runStart = index + 1;\n continue;\n }\n if (\n unit >= 0xd800 &&\n unit <= 0xdbff &&\n index + 1 < value.length &&\n value.charCodeAt(index + 1) >= 0xdc00 &&\n value.charCodeAt(index + 1) <= 0xdfff\n ) {\n this.#reserve(4);\n index += 1;\n continue;\n }\n if (unit >= 0xd800 && unit <= 0xdfff) {\n this.#appendReservedRun(value, runStart, index);\n this.appendAscii(`\\\\u${unit.toString(16).padStart(4, \"0\")}`);\n runStart = index + 1;\n continue;\n }\n let unitBytes = 3;\n if (unit <= 0x7f) {\n unitBytes = 1;\n } else if (unit <= 0x7ff) {\n unitBytes = 2;\n }\n this.#reserve(unitBytes);\n }\n this.#appendReservedRun(value, runStart, value.length);\n this.appendAscii('\"');\n }\n\n #appendReservedRun(value: string, start: number, end: number): void {\n if (end > start) {\n this.capture(value.slice(start, end));\n }\n }\n\n #appendNumber(value: number): void {\n this.appendAscii(JSON.stringify(value));\n }\n\n #requireNumber(value: number, field: string): void {\n if (typeof value !== \"number\") {\n throw new TypeError(`${field} must be a number`);\n }\n }\n\n #reserve(bytes: number): void {\n if (bytes > this.#maximumBytes - this.#bytes) {\n throw new RangeError(\n `${this.#label} exceeds the ${this.#reportedMaximumBytes}-byte maximum`,\n );\n }\n this.#bytes += bytes;\n }\n\n protected abstract capture(value: string): void;\n}\n\nclass CountingJsonBudget extends BoundedJsonSink {\n protected capture(value: string): void {\n void value;\n }\n}\n\nclass BoundedJsonWriter extends BoundedJsonSink {\n readonly #chunks: string[] = [];\n readonly #suffix: string;\n\n constructor(maximumBytes: number, label: string, suffix: string) {\n super(maximumBytes, label, suffix);\n this.#suffix = suffix;\n }\n\n finish(): string {\n return this.#chunks.join(\"\") + this.#suffix;\n }\n\n protected capture(value: string): void {\n this.#chunks.push(value);\n }\n}\n\nconst jsonEscape = (unit: number): string | undefined => {\n switch (unit) {\n case 0x08:\n return \"\\\\b\";\n case 0x09:\n return \"\\\\t\";\n case 0x0a:\n return \"\\\\n\";\n case 0x0c:\n return \"\\\\f\";\n case 0x0d:\n return \"\\\\r\";\n case 0x22:\n return '\\\\\"';\n case 0x5c:\n return \"\\\\\\\\\";\n default:\n return unit < 0x20\n ? `\\\\u${unit.toString(16).padStart(4, \"0\")}`\n : undefined;\n }\n};\n\nconst callerDetectionRequestJson = (\n fullText: string,\n detections: readonly NativeCallerDetection[],\n): string => {\n validateCallerDetectionInput(fullText, detections);\n return serializeCallerDetectionRequest(detections);\n};\n\nconst serializeCallerDetectionRequest = (\n detections: readonly NativeCallerDetection[],\n): string => {\n const writer = new BoundedJsonWriter(\n CALLER_DETECTION_REQUEST_JSON_MAX_BYTES,\n \"Caller detection request JSON\",\n \"]}\",\n );\n writer.appendAscii(\n `{\"version\":${CALLER_DETECTION_CONTRACT_VERSION},\"detections\":[`,\n );\n for (let index = 0; index < detections.length; index += 1) {\n const detection = detections[index];\n if (detection === undefined) {\n throw new TypeError(\"Caller detections must not be sparse\");\n }\n if (index > 0) {\n writer.appendAscii(\",\");\n }\n writer.appendAscii('{\"start\":');\n writer.appendOffset(detection.start, \"Caller detection start\");\n writer.appendAscii(',\"end\":');\n writer.appendOffset(detection.end, \"Caller detection end\");\n writer.appendAscii(',\"label\":');\n writer.appendString(detection.label, \"Caller detection label\");\n writer.appendAscii(',\"score\":');\n writer.appendScore(detection.score, \"Caller detection score\");\n writer.appendAscii(',\"provider_id\":');\n writer.appendString(detection.providerId, \"Caller detection providerId\");\n writer.appendAscii(',\"detection_id\":');\n writer.appendString(detection.detectionId, \"Caller detection detectionId\");\n writer.appendAscii(\"}\");\n }\n return writer.finish();\n};\n\nconst toBindingSessionCallerInputs = (\n inputs: readonly NativeSessionCallerRedactionInput[],\n) => {\n if (!Array.isArray(inputs)) {\n throw new TypeError(\"Session caller inputs must be an array\");\n }\n if (inputs.length > SESSION_CALLER_MAX_INPUTS) {\n throw new RangeError(\n `Session caller inputs contains ${inputs.length} items; the maximum is ${SESSION_CALLER_MAX_INPUTS}`,\n );\n }\n let detectionCount = 0;\n let textBytes = 0;\n const bindingInputs: NativeBindingSessionCallerRedactionInput[] = [];\n const budget = new CountingJsonBudget(\n SESSION_CALLER_INPUTS_JSON_MAX_BYTES,\n \"Session caller inputs JSON\",\n \"]\",\n );\n budget.appendAscii(\"[\");\n for (let index = 0; index < inputs.length; index += 1) {\n const input = inputs[index];\n if (input === undefined) {\n throw new TypeError(\"Session caller inputs must not be sparse\");\n }\n const { detections, fullText } = input;\n const inputTextBytes = validateCallerDetectionInput(fullText, detections);\n detectionCount += detections.length;\n if (detectionCount > CALLER_DETECTION_MAX_COUNT) {\n throw new RangeError(\n `Session caller detections contains ${detectionCount} items; the maximum is ${CALLER_DETECTION_MAX_COUNT}`,\n );\n }\n textBytes += inputTextBytes;\n if (textBytes > CALLER_DETECTION_TEXT_MAX_BYTES) {\n throw new RangeError(\n `Session caller text contains ${textBytes} bytes; the maximum is ${CALLER_DETECTION_TEXT_MAX_BYTES}`,\n );\n }\n const requestJson = serializeCallerDetectionRequest(detections);\n if (index > 0) {\n budget.appendAscii(\",\");\n }\n budget.appendAscii('{\"full_text\":');\n budget.appendString(fullText, \"Session caller fullText\");\n budget.appendAscii(',\"request_json\":');\n budget.appendString(requestJson, \"Session caller requestJson\");\n budget.appendAscii(\"}\");\n bindingInputs.push({ fullText, requestJson });\n }\n return bindingInputs;\n};\n\nexport type NativePipelineEntity = {\n start: number;\n end: number;\n label: string;\n text: string;\n score: number;\n source: string;\n sourceDetail?: string;\n providerId?: string;\n detectionId?: string;\n};\n\nexport type NativeRedactionResult = {\n redactedText: string;\n redactionMap: Map<string, string>;\n operatorMap: Map<string, OperatorType>;\n entityCount: number;\n};\n\nexport type NativeStaticRedactionResult = {\n resolvedEntities: NativePipelineEntity[];\n redaction: NativeRedactionResult;\n};\n\nexport type NativeSearchPackageOptions = {\n binding: NativeAnonymizeBinding;\n config: NativePreparedSearchConfig;\n compressed?: boolean;\n};\n\nexport type NativeSearchPackageInput =\n | NativePreparedSearchConfig\n | string\n | Uint8Array;\n\nexport type SharedNativeSearchPackageOptions = {\n binding: NativeAnonymizeBinding;\n config: NativeSearchPackageInput;\n compressed?: boolean;\n};\n\nexport type SharedNativePreparedPackageOptions = {\n binding: NativeAnonymizeBinding;\n packageBytes: Uint8Array;\n};\n\nexport type SharedNativeRedactTextJsonOptions = {\n binding: NativeAnonymizeBinding;\n config: NativeSearchPackageInput;\n fullText: string;\n operators?: NativeOperatorConfig;\n};\n\nexport type SharedNativeRedactTextOptions = SharedNativeRedactTextJsonOptions;\n\nexport type SharedNativeDiagnosticsJsonOptions =\n SharedNativeRedactTextJsonOptions;\n\nexport type SharedNativeDiagnosticsStreamJsonOptions =\n SharedNativeRedactTextJsonOptions & {\n onBatch: NativeDiagnosticsBatchCallback;\n };\n\nexport type SharedNativeRedactTextStreamJsonOptions =\n SharedNativeRedactTextJsonOptions & {\n onEvent: NativeResultEventCallback;\n };\n\nexport type NativeNormalizeOptions = {\n binding: NativeAnonymizeBinding;\n text: string;\n};\n\nexport type NativeAnonymizerFromConfigOptions = {\n binding: NativeAnonymizeBinding;\n config: NativePreparedSearchConfig;\n};\n\nexport type NativeAnonymizerFromPackageOptions = {\n binding: NativeAnonymizeBinding;\n packageBytes: Uint8Array;\n};\n\nexport type NativePipelineFromPackageOptions =\n NativeAnonymizerFromPackageOptions;\n\nexport type NativeBindingVersionOptions = {\n binding: NativeAnonymizeBinding;\n expectedVersion: string;\n};\n\nexport class PreparedNativeRedactionSession {\n readonly #session: NativePreparedRedactionSessionBinding;\n\n constructor(session: NativePreparedRedactionSessionBinding) {\n this.#session = session;\n }\n\n sessionId(): string {\n return this.#session.sessionId();\n }\n\n session_id(): string {\n return this.sessionId();\n }\n\n mappingCount(): number {\n return this.#session.mappingCount();\n }\n\n mapping_count(): number {\n return this.mappingCount();\n }\n\n restoreText(fullText: string, observedAtEpochSeconds?: number): string {\n if (observedAtEpochSeconds === undefined) {\n return this.#session.restoreText(fullText);\n }\n return this.#session.restoreTextAt(fullText, observedAtEpochSeconds);\n }\n\n restore_text(fullText: string, observedAtEpochSeconds?: number): string {\n return this.restoreText(fullText, observedAtEpochSeconds);\n }\n\n toPlaintextJson(): string {\n return this.#session.toPlaintextJson();\n }\n\n to_plaintext_json(): string {\n return this.toPlaintextJson();\n }\n\n toPlaintextJsonAt(observedAtEpochSeconds: number): string {\n return this.#session.toPlaintextJsonAt(observedAtEpochSeconds);\n }\n\n to_plaintext_json_at(observedAtEpochSeconds: number): string {\n return this.toPlaintextJsonAt(observedAtEpochSeconds);\n }\n\n toEncryptedArchive(key: Uint8Array): Uint8Array {\n return this.#session.toEncryptedArchive(key);\n }\n\n to_encrypted_archive(key: Uint8Array): Uint8Array {\n return this.toEncryptedArchive(key);\n }\n\n toEncryptedArchiveAt(\n key: Uint8Array,\n observedAtEpochSeconds: number,\n ): Uint8Array {\n return this.#session.toEncryptedArchiveAt(key, observedAtEpochSeconds);\n }\n\n to_encrypted_archive_at(\n key: Uint8Array,\n observedAtEpochSeconds: number,\n ): Uint8Array {\n return this.toEncryptedArchiveAt(key, observedAtEpochSeconds);\n }\n\n inspect(observedAtEpochSeconds?: number): NativeSessionMetadata {\n const metadata: CanonicalSessionMetadata = JSON.parse(\n this.#session.inspectJson(observedAtEpochSeconds),\n );\n return {\n sessionId: metadata.session_id,\n createdAtEpochSeconds: metadata.created_at_epoch_seconds,\n expiresAtEpochSeconds: metadata.expires_at_epoch_seconds,\n mappingCount: metadata.mapping_count,\n status: metadata.status,\n };\n }\n\n delete(): NativeSessionDeletionSummary {\n const summary: CanonicalSessionDeletionSummary = JSON.parse(\n this.#session.deleteJson(),\n );\n return {\n sessionId: summary.session_id,\n deletedMappingCount: summary.deleted_mapping_count,\n };\n }\n\n redactStaticEntities(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n const result: CanonicalStaticRedactionResult = JSON.parse(\n this.redact_text_json(fullText, operators),\n );\n return fromCanonicalStaticRedactionResult(result);\n }\n\n redactText(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntities(fullText, operators);\n }\n\n redact_text(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactText(fullText, operators);\n }\n\n redactTextJson(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redact_text_json(fullText, operators);\n }\n\n redact_text_json(fullText: string, operators?: NativeOperatorConfig): string {\n return this.#session.redactStaticEntitiesJson(\n fullText,\n toBindingOperatorConfig(operators),\n );\n }\n\n redactStaticEntitiesAt(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n const result: CanonicalStaticRedactionResult = JSON.parse(\n this.redactTextJsonAt(options),\n );\n return fromCanonicalStaticRedactionResult(result);\n }\n\n redactTextAt(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntitiesAt(options);\n }\n\n redact_text_at(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n return this.redactTextAt(options);\n }\n\n redact_static_entities_at(\n options: NativeSessionRedactionAtOptions,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntitiesAt(options);\n }\n\n redactTextJsonAt({\n fullText,\n observedAtEpochSeconds,\n operators,\n }: NativeSessionRedactionAtOptions): string {\n return this.#session.redactStaticEntitiesJsonAt(\n fullText,\n observedAtEpochSeconds,\n toBindingOperatorConfig(operators),\n );\n }\n\n redact_text_json_at(options: NativeSessionRedactionAtOptions): string {\n return this.redactTextJsonAt(options);\n }\n\n planTextBatchWithCallerDetections({\n inputs,\n operators,\n observedAtEpochSeconds,\n }: NativeSessionCallerRedactionPlanOptions): PreparedNativeSessionRedactionPlan {\n const bindingOperators = toBindingOperatorConfig(operators);\n const bindingPlan = this.#session.planStaticEntitiesWithCallerDetections({\n inputs: toBindingSessionCallerInputs(inputs),\n ...(bindingOperators === undefined\n ? {}\n : { operators: bindingOperators }),\n ...(observedAtEpochSeconds === undefined\n ? {}\n : { observedAtEpochSeconds }),\n });\n return new PreparedNativeSessionRedactionPlan(bindingPlan);\n }\n}\n\nexport class PreparedNativeSessionRedactionPlan {\n readonly blocks: readonly NativeSessionBlockRedactionPlan[];\n readonly #plan: NativePreparedSessionRedactionPlanBinding;\n\n constructor(plan: NativePreparedSessionRedactionPlanBinding) {\n this.#plan = plan;\n const blocks: CanonicalSessionRedactionPlanResult[] = JSON.parse(\n plan.resultJson(),\n );\n this.blocks = blocks.map(\n ({ caller_entity_count, entity_count, replacements }) => ({\n replacements,\n entityCount: entity_count,\n callerEntityCount: caller_entity_count,\n }),\n );\n }\n\n commit(): void {\n this.#plan.commit();\n }\n}\n\nexport class PreparedNativeAnonymizer {\n readonly #prepared: NativePreparedSearchBinding;\n\n constructor(prepared: NativePreparedSearchBinding) {\n this.#prepared = prepared;\n }\n\n prepareDiagnosticsJson(): string {\n return this.#prepared.prepareDiagnosticsJson();\n }\n\n prepare_diagnostics_json(): string {\n return this.prepareDiagnosticsJson();\n }\n\n warmLazyRegex(): void {\n this.#prepared.warmLazyRegex();\n }\n\n warm_lazy_regex(): void {\n this.warmLazyRegex();\n }\n\n warmLazyRegexDiagnosticsJson(): string {\n return this.#prepared.warmLazyRegexDiagnosticsJson();\n }\n\n warm_lazy_regex_diagnostics_json(): string {\n return this.warmLazyRegexDiagnosticsJson();\n }\n\n createRedactionSession(sessionId: string): PreparedNativeRedactionSession {\n return new PreparedNativeRedactionSession(\n this.#prepared.createRedactionSession(sessionId),\n );\n }\n\n create_redaction_session(sessionId: string): PreparedNativeRedactionSession {\n return this.createRedactionSession(sessionId);\n }\n\n createRedactionSessionWithLifecycle({\n sessionId,\n createdAtEpochSeconds,\n expiresAtEpochSeconds,\n }: NativeCreateSessionWithLifecycleOptions): PreparedNativeRedactionSession {\n return new PreparedNativeRedactionSession(\n this.#prepared.createRedactionSessionWithLifecycle(\n sessionId,\n createdAtEpochSeconds,\n expiresAtEpochSeconds,\n ),\n );\n }\n\n create_redaction_session_with_lifecycle(\n options: NativeCreateSessionWithLifecycleOptions,\n ): PreparedNativeRedactionSession {\n return this.createRedactionSessionWithLifecycle(options);\n }\n\n restoreRedactionSession(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n return new PreparedNativeRedactionSession(\n this.#prepared.restoreRedactionSession(plaintextJson),\n );\n }\n\n restore_redaction_session(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n return this.restoreRedactionSession(plaintextJson);\n }\n\n restoreEncryptedRedactionSession({\n archive,\n key,\n expectedSessionId,\n observedAtEpochSeconds,\n }: NativeOpenSessionArchiveOptions): PreparedNativeRedactionSession {\n return new PreparedNativeRedactionSession(\n this.#prepared.restoreEncryptedRedactionSession({\n archive,\n key,\n expectedSessionId,\n ...(observedAtEpochSeconds === undefined\n ? {}\n : { observedAtEpochSeconds }),\n }),\n );\n }\n\n restore_encrypted_redaction_session(\n options: NativeOpenSessionArchiveOptions,\n ): PreparedNativeRedactionSession {\n return this.restoreEncryptedRedactionSession(options);\n }\n\n redactStaticEntities(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return toNativeStaticRedactionResult(\n this.#prepared.redactStaticEntities(\n fullText,\n toBindingOperatorConfig(operators),\n ),\n );\n }\n\n redact_text(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntities(fullText, operators);\n }\n\n redact_text_json(fullText: string, operators?: NativeOperatorConfig): string {\n const bindingOperators = toBindingOperatorConfig(operators);\n return this.#prepared.redactStaticEntitiesJson(fullText, bindingOperators);\n }\n\n redactStaticEntitiesWithCallerDetections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n const requestJson = callerDetectionRequestJson(\n fullText,\n options.detections,\n );\n const operators = toBindingOperatorConfig(options.operators);\n const result: CanonicalStaticRedactionResult = JSON.parse(\n this.#prepared.redactStaticEntitiesWithCallerDetectionsJson(fullText, {\n requestJson,\n ...(operators ? { operators } : {}),\n }),\n );\n return fromCanonicalStaticRedactionResult(result);\n }\n\n redact_text_with_caller_detections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n return this.redactStaticEntitiesWithCallerDetections(fullText, options);\n }\n\n redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string {\n const requestJson = callerDetectionRequestJson(\n fullText,\n options.detections,\n );\n const operators = toBindingOperatorConfig(options.operators);\n return this.#prepared.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(\n fullText,\n {\n requestJson,\n ...(operators ? { operators } : {}),\n },\n );\n }\n\n redact_static_entities_with_caller_detections_diagnostics_json(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string {\n return this.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(\n fullText,\n options,\n );\n }\n\n redactTextJson(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redact_text_json(fullText, operators);\n }\n\n redactTextStreamJson(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#prepared.redactStaticEntitiesResultStreamJson(\n fullText,\n toBindingOperatorConfig(operators),\n onEvent,\n );\n }\n\n redact_text_stream_json(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redactStaticEntitiesDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#prepared.redactStaticEntitiesDiagnosticsJson(\n fullText,\n toBindingOperatorConfig(operators),\n );\n }\n\n diagnostics_json(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redactStaticEntitiesDiagnosticsJson(fullText, operators);\n }\n\n diagnosticsStreamJson(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#prepared.redactStaticEntitiesDiagnosticsStreamJson(\n fullText,\n toBindingOperatorConfig(operators),\n onBatch,\n );\n }\n\n diagnostics_stream_json(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n redactStaticEntitiesSummaryDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#prepared.redactStaticEntitiesSummaryDiagnosticsJson(\n fullText,\n toBindingOperatorConfig(operators),\n );\n }\n\n summary_diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.redactStaticEntitiesSummaryDiagnosticsJson(fullText, operators);\n }\n}\n\nexport class PreparedNativePipeline {\n readonly #anonymizer: PreparedNativeAnonymizer;\n\n constructor(anonymizer: PreparedNativeAnonymizer) {\n this.#anonymizer = anonymizer;\n }\n\n prepareDiagnosticsJson(): string {\n return this.#anonymizer.prepareDiagnosticsJson();\n }\n\n prepare_diagnostics_json(): string {\n return this.prepareDiagnosticsJson();\n }\n\n warmLazyRegex(): void {\n this.#anonymizer.warmLazyRegex();\n }\n\n warm_lazy_regex(): void {\n this.warmLazyRegex();\n }\n\n warmLazyRegexDiagnosticsJson(): string {\n return this.#anonymizer.warmLazyRegexDiagnosticsJson();\n }\n\n warm_lazy_regex_diagnostics_json(): string {\n return this.warmLazyRegexDiagnosticsJson();\n }\n\n createRedactionSession(sessionId: string): PreparedNativeRedactionSession {\n return this.#anonymizer.createRedactionSession(sessionId);\n }\n\n create_redaction_session(sessionId: string): PreparedNativeRedactionSession {\n return this.createRedactionSession(sessionId);\n }\n\n createRedactionSessionWithLifecycle(\n options: NativeCreateSessionWithLifecycleOptions,\n ): PreparedNativeRedactionSession {\n return this.#anonymizer.createRedactionSessionWithLifecycle(options);\n }\n\n create_redaction_session_with_lifecycle(\n options: NativeCreateSessionWithLifecycleOptions,\n ): PreparedNativeRedactionSession {\n return this.createRedactionSessionWithLifecycle(options);\n }\n\n restoreRedactionSession(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n return this.#anonymizer.restoreRedactionSession(plaintextJson);\n }\n\n restore_redaction_session(\n plaintextJson: string,\n ): PreparedNativeRedactionSession {\n return this.restoreRedactionSession(plaintextJson);\n }\n\n restoreEncryptedRedactionSession(\n options: NativeOpenSessionArchiveOptions,\n ): PreparedNativeRedactionSession {\n return this.#anonymizer.restoreEncryptedRedactionSession(options);\n }\n\n restore_encrypted_redaction_session(\n options: NativeOpenSessionArchiveOptions,\n ): PreparedNativeRedactionSession {\n return this.restoreEncryptedRedactionSession(options);\n }\n\n redactText(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.#anonymizer.redactStaticEntities(fullText, operators);\n }\n\n redact_text(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): NativeStaticRedactionResult {\n return this.redactText(fullText, operators);\n }\n\n redact_text_json(fullText: string, operators?: NativeOperatorConfig): string {\n return this.#anonymizer.redact_text_json(fullText, operators);\n }\n\n redactTextWithCallerDetections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n return this.#anonymizer.redactStaticEntitiesWithCallerDetections(\n fullText,\n options,\n );\n }\n\n redact_text_with_caller_detections(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): NativeStaticRedactionResult {\n return this.redactTextWithCallerDetections(fullText, options);\n }\n\n redactTextWithCallerDetectionsDiagnosticsJson(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string {\n return this.#anonymizer.redactStaticEntitiesWithCallerDetectionsDiagnosticsJson(\n fullText,\n options,\n );\n }\n\n redact_text_with_caller_detections_diagnostics_json(\n fullText: string,\n options: NativeCallerRedactionOptions,\n ): string {\n return this.redactTextWithCallerDetectionsDiagnosticsJson(\n fullText,\n options,\n );\n }\n\n redactTextJson(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redact_text_json(fullText, operators);\n }\n\n redactTextStreamJson(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#anonymizer.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redact_text_stream_json(\n fullText: string,\n onEvent: NativeResultEventCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.redactTextStreamJson(fullText, onEvent, operators);\n }\n\n redactTextDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#anonymizer.redactStaticEntitiesDiagnosticsJson(\n fullText,\n operators,\n );\n }\n\n diagnostics_json(fullText: string, operators?: NativeOperatorConfig): string {\n return this.redactTextDiagnosticsJson(fullText, operators);\n }\n\n diagnosticsStreamJson(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#anonymizer.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n diagnostics_stream_json(\n fullText: string,\n onBatch: NativeDiagnosticsBatchCallback,\n operators?: NativeOperatorConfig,\n ): string {\n return this.diagnosticsStreamJson(fullText, onBatch, operators);\n }\n\n redactTextSummaryDiagnosticsJson(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.#anonymizer.redactStaticEntitiesSummaryDiagnosticsJson(\n fullText,\n operators,\n );\n }\n\n summary_diagnostics_json(\n fullText: string,\n operators?: NativeOperatorConfig,\n ): string {\n return this.redactTextSummaryDiagnosticsJson(fullText, operators);\n }\n}\n\nexport const encodeNativeSearchConfig = (\n config: NativePreparedSearchConfig,\n): Uint8Array => new TextEncoder().encode(JSON.stringify(config));\n\nexport const encodeNativeSearchConfigInput = (\n config: NativeSearchPackageInput,\n): Uint8Array => {\n if (typeof config === \"string\") {\n return new TextEncoder().encode(config);\n }\n if (config instanceof Uint8Array) {\n return config;\n }\n return encodeNativeSearchConfig(config);\n};\n\nexport const getNativeBindingVersion = (\n binding: NativeAnonymizeBinding,\n): string => binding.nativePackageVersion();\n\nexport const native_package_version = getNativeBindingVersion;\n\nexport const normalize_for_search = ({\n binding,\n text,\n}: NativeNormalizeOptions): string => binding.normalizeForSearch(text);\n\nexport const assertNativeBindingVersion = ({\n binding,\n expectedVersion,\n}: NativeBindingVersionOptions): void => {\n const actualVersion = getNativeBindingVersion(binding);\n if (actualVersion !== expectedVersion) {\n throw new Error(\n `Native anonymize binding version ${actualVersion} does not match ${expectedVersion}`,\n );\n }\n};\n\nexport const prepareNativeSearchPackage = ({\n binding,\n config,\n compressed = false,\n}: NativeSearchPackageOptions): Uint8Array => {\n const configBytes = encodeNativeSearchConfig(config);\n return compressed\n ? binding.prepareStaticSearchCompressedPackageBytes(configBytes)\n : binding.prepareStaticSearchPackageBytes(configBytes);\n};\n\nexport const prepare_search_package = ({\n binding,\n config,\n compressed = false,\n}: SharedNativeSearchPackageOptions): Uint8Array => {\n const configBytes = encodeNativeSearchConfigInput(config);\n return compressed\n ? binding.prepareStaticSearchCompressedPackageBytes(configBytes)\n : binding.prepareStaticSearchPackageBytes(configBytes);\n};\n\nexport const createNativeAnonymizerFromConfig = ({\n binding,\n config,\n}: NativeAnonymizerFromConfigOptions): PreparedNativeAnonymizer =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfig(config),\n ),\n );\n\nexport const createNativeAnonymizerFromPackage = ({\n binding,\n packageBytes,\n}: NativeAnonymizerFromPackageOptions): PreparedNativeAnonymizer =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromPreparedPackageBytes(packageBytes),\n );\n\nexport const load_prepared_package = ({\n binding,\n packageBytes,\n}: SharedNativePreparedPackageOptions): PreparedNativeAnonymizer =>\n createNativeAnonymizerFromPackage({ binding, packageBytes });\n\nexport const redact_text_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeRedactTextJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text_json(fullText, operators);\n\nexport const redact_text = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeRedactTextOptions): NativeStaticRedactionResult =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text(fullText, operators);\n\nexport const redact_text_stream_json = ({\n binding,\n config,\n fullText,\n operators,\n onEvent,\n}: SharedNativeRedactTextStreamJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).redact_text_stream_json(fullText, onEvent, operators);\n\nexport const diagnostics_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeDiagnosticsJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).diagnostics_json(fullText, operators);\n\nexport const diagnostics_stream_json = ({\n binding,\n config,\n fullText,\n operators,\n onBatch,\n}: SharedNativeDiagnosticsStreamJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).diagnostics_stream_json(fullText, onBatch, operators);\n\nexport const summary_diagnostics_json = ({\n binding,\n config,\n fullText,\n operators,\n}: SharedNativeDiagnosticsJsonOptions): string =>\n new PreparedNativeAnonymizer(\n binding.NativePreparedSearch.fromConfigJsonBytes(\n encodeNativeSearchConfigInput(config),\n ),\n ).summary_diagnostics_json(fullText, operators);\n\nexport const createNativePipelineFromPackage = ({\n binding,\n packageBytes,\n}: NativePipelineFromPackageOptions): PreparedNativePipeline =>\n new PreparedNativePipeline(\n createNativeAnonymizerFromPackage({ binding, packageBytes }),\n );\n\nexport const PreparedSearch = PreparedNativeAnonymizer;\nexport type PreparedSearch = PreparedNativeAnonymizer;\nexport const PreparedAnonymizer = PreparedNativeAnonymizer;\nexport type PreparedAnonymizer = PreparedNativeAnonymizer;\n\nconst toBindingOperatorConfig = (\n config: NativeOperatorConfig | undefined,\n): NativeBindingOperatorConfig | undefined => {\n if (!config) {\n return undefined;\n }\n const bindingConfig: NativeBindingOperatorConfig = {};\n if (config.operators !== undefined) {\n bindingConfig.operators = config.operators;\n }\n if (config.redactString !== undefined) {\n bindingConfig.redactString = config.redactString;\n }\n return bindingConfig;\n};\n\nconst toNativeStaticRedactionResult = (\n result: NativeBindingStaticRedactionResult,\n): NativeStaticRedactionResult => ({\n resolvedEntities: result.resolvedEntities.map(toNativePipelineEntity),\n redaction: toNativeRedactionResult(result.redaction),\n});\n\nconst fromCanonicalStaticRedactionResult = (\n result: CanonicalStaticRedactionResult,\n): NativeStaticRedactionResult => ({\n resolvedEntities: result.resolved_entities.map(\n ({ source_detail, provider_id, detection_id, ...entity }) => ({\n ...entity,\n ...(source_detail ? { sourceDetail: source_detail } : {}),\n ...(provider_id ? { providerId: provider_id } : {}),\n ...(detection_id ? { detectionId: detection_id } : {}),\n }),\n ),\n redaction: {\n redactedText: result.redaction.redacted_text,\n redactionMap: toRedactionMap(result.redaction.redaction_map),\n operatorMap: toOperatorMap(result.redaction.operator_map),\n entityCount: result.redaction.entity_count,\n },\n});\n\nconst toNativePipelineEntity = (\n entity: NativeBindingPipelineEntity,\n): NativePipelineEntity => ({\n start: entity.start,\n end: entity.end,\n label: entity.label,\n text: entity.text,\n score: entity.score,\n source: entity.source,\n ...(entity.sourceDetail ? { sourceDetail: entity.sourceDetail } : {}),\n ...(entity.providerId ? { providerId: entity.providerId } : {}),\n ...(entity.detectionId ? { detectionId: entity.detectionId } : {}),\n});\n\nconst toNativeRedactionResult = (\n result: NativeBindingRedactionResult,\n): NativeRedactionResult => ({\n redactedText: result.redactedText,\n redactionMap: toRedactionMap(result.redactionMap),\n operatorMap: toOperatorMap(result.operatorMap),\n entityCount: result.entityCount,\n});\n\nconst toRedactionMap = (\n entries: readonly NativeBindingRedactionEntry[],\n): Map<string, string> => {\n const map = new Map<string, string>();\n for (const entry of entries) {\n map.set(entry.placeholder, entry.original);\n }\n return map;\n};\n\nconst toOperatorMap = (\n entries: readonly NativeBindingOperatorEntry[],\n): Map<string, OperatorType> => {\n const map = new Map<string, OperatorType>();\n for (const entry of entries) {\n map.set(entry.placeholder, entry.operator);\n }\n return map;\n};\n"],"mappings":";;AAwTA,MAAa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MAAM,QAAQ;CAE3C,OAAO;AACT;AAEA,MAAM,iBACJ,YAC8B;CAC9B,MAAM,sBAAM,IAAI,IAA0B;CAC1C,KAAK,MAAM,SAAS,SAClB,IAAI,IAAI,MAAM,aAAa,MAAM,QAAQ;CAE3C,OAAO;AACT"}
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/anonymize",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "description": "Deterministic PII detection and anonymization with regex, deny lists, and coreference resolution",
5
5
  "keywords": [
6
6
  "anonymization",
@@ -108,20 +108,20 @@
108
108
  "@stll/anonymize-data": "^0.0.10"
109
109
  },
110
110
  "optionalDependencies": {
111
- "@stll/anonymize-darwin-arm64": "2.9.0",
112
- "@stll/anonymize-darwin-x64": "2.9.0",
113
- "@stll/anonymize-linux-arm64-gnu": "2.9.0",
114
- "@stll/anonymize-linux-x64-gnu": "2.9.0",
115
- "@stll/anonymize-win32-x64-msvc": "2.9.0"
111
+ "@stll/anonymize-darwin-arm64": "2.9.1",
112
+ "@stll/anonymize-darwin-x64": "2.9.1",
113
+ "@stll/anonymize-linux-arm64-gnu": "2.9.1",
114
+ "@stll/anonymize-linux-x64-gnu": "2.9.1",
115
+ "@stll/anonymize-win32-x64-msvc": "2.9.1"
116
116
  },
117
117
  "devDependencies": {
118
118
  "@napi-rs/cli": "^3.8.6",
119
119
  "bun-types": "1.4.0",
120
120
  "fast-check": "^4.9.0",
121
121
  "fflate": "^0.8.3",
122
- "puppeteer-core": "25.7.0",
122
+ "puppeteer-core": "25.8.0",
123
123
  "tsdown": "0.22.14",
124
124
  "typescript": "7.0.2",
125
- "vite": "^8.2.1"
125
+ "vite": "^8.2.2"
126
126
  }
127
127
  }