@stll/anonymize 2.8.0 → 2.8.2

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.
package/LICENSE CHANGED
@@ -1,27 +1,202 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 stella labs, s.r.o.
4
-
5
- Permission is hereby granted, free of charge, to any
6
- person obtaining a copy of this software and associated
7
- documentation files (the "Software"), to deal in the
8
- Software without restriction, including without
9
- limitation the rights to use, copy, modify, merge,
10
- publish, distribute, sublicense, and/or sell copies of
11
- the Software, and to permit persons to whom the
12
- Software is furnished to do so, subject to the
13
- following conditions:
14
-
15
- The above copyright notice and this permission notice
16
- shall be included in all copies or substantial portions
17
- of the Software.
18
-
19
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
20
- ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
21
- TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
22
- PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
23
- SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
26
- IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
- DEALINGS IN THE SOFTWARE.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,20 @@
1
+ anonymize
2
+ Copyright 2026 stella labs, s.r.o.
3
+
4
+ This product includes software developed at stella labs, s.r.o.
5
+ (https://stll.app/).
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
8
+ not use this product except in compliance with the License. You may
9
+ obtain a copy of the License in the LICENSE file distributed with this product
10
+ or at https://www.apache.org/licenses/LICENSE-2.0.
11
+
12
+ --------------------------------------------------------------------------
13
+
14
+ Third-party notices
15
+
16
+ This product bundles and builds on third-party components distributed
17
+ under their own licenses (including MIT). Those components and their
18
+ attributions are listed in the ATTRIBUTION.md files under packages/ and
19
+ crates/, and the browser build's runtime attributions are listed in
20
+ packages/anonymize/wasm/README.md.
package/README.md CHANGED
@@ -8,6 +8,13 @@ Runtime package for multi-layer PII detection and anonymization.
8
8
 
9
9
  It combines regex detectors, trigger phrases, deny-list matching, and coreference handling in a single deterministic pipeline that works in native Node.js and in browser builds through the WASM entrypoint.
10
10
 
11
+ The default pipeline detects personal identifiers; it is not a general-purpose
12
+ secret scanner. Passwords, authentication tokens, API keys, and private
13
+ cryptographic material are outside its claimed scope. IP addresses, MAC
14
+ addresses, and URLs are explicit opt-in capabilities. Query
15
+ `CAPABILITY_MANIFEST` or `anonymize --capabilities` instead of assuming a label
16
+ is enabled.
17
+
11
18
  ## Install
12
19
 
13
20
  ```bash
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { a as DetectionSource, c as ENTITY_SELECTIONS, d as EntitySelection, f as OPERATOR_TYPES, i as DefaultEntityLabel, l as EntityCapability, n as DETECTION_SOURCES, o as ENTITY_CAPABILITIES, p as OperatorType, r as DETECTOR_PRIORITY, s as ENTITY_LABELS, t as DEFAULT_ENTITY_LABELS, u as EntityLabel } from "./constants2.mjs";
2
2
  import { CAPABILITY_MANIFEST, CAPABILITY_MANIFEST_SCHEMA_VERSION, CAPABILITY_PARITY_PROFILES, CAPABILITY_RUNTIMES, CAPABILITY_SURFACES, CapabilityManifest, CapabilityParityProfile, CapabilityRuntime, CapabilitySurface, CapabilitySurfaceId } from "./capabilities.mjs";
3
3
  import { $ as SharedNativeRedactTextJsonOptions, A as NativeRedactionResult, At as GazetteerEntry, B as NativeSessionRedactionAtOptions, Bt as TriggerValidation, C as NativeOpenSessionArchiveOptions, Ct as AnonymisationOperator, D as NativePreparedRedactionSessionBinding, Dt as Dictionaries, E as NativePipelineFromPackageOptions, Et as DenyListCategory, F as NativeSessionCallerRedactionInput, Ft as ReviewedEntity, G as PreparedNativeAnonymizer, H as NativeStaticRedactionResult, I as NativeSessionCallerRedactionPlanOptions, It as TriggerExtension, J as PreparedNativeSessionRedactionPlan, K as PreparedNativePipeline, L as NativeSessionDeletionSummary, Lt as TriggerGroupConfig, M as NativeSearchPackageInput, Mt as PipelineConfig, N as NativeSearchPackageOptions, Nt as RedactionResult, O as NativePreparedSearchBinding, Ot as DictionaryMeta, P as NativeSessionBlockRedactionPlan, Pt as ReviewDecision, Q as SharedNativePreparedPackageOptions, R as NativeSessionLifecycle, Rt as TriggerRule, S as NativeNormalizeOptions, T as NativePipelineEntity, Tt as CustomRegexPattern, U as NativeTextReplacement, V as NativeSessionStatus, Vt as NativePreparedSearchConfig, W as PreparedAnonymizer, X as SharedNativeDiagnosticsJsonOptions, Y as PreparedSearch, Z as SharedNativeDiagnosticsStreamJsonOptions, _ as NativeBindingVersionOptions, _t as prepareNativeSearchPackage, a as EXTERNAL_DETECTION_DOCUMENT_MAX_BYTES, at as createNativeAnonymizerFromConfig, b as NativeCreateSessionWithLifecycleOptions, c as EXTERNAL_DETECTION_MAX_METADATA_BYTES, d as ExternalDetectionBatch, dt as encodeNativeSearchConfigInput, et as SharedNativeRedactTextOptions, f as ExternalDetectionOffsetUnit, ft as getNativeBindingVersion, g as NativeAnonymizerFromPackageOptions, h as NativeAnonymizerFromConfigOptions, i as EXTERNAL_DETECTION_BATCH_VERSION, j as NativeResultEventCallback, jt as OperatorConfig, k as NativePreparedSessionRedactionPlanBinding, kt as Entity, l as EXTERNAL_DETECTION_OFFSET_UNITS, m as NativeAnonymizeBinding, n as ConvertExternalDetectionBatchOptions, nt as SharedNativeSearchPackageOptions, o as EXTERNAL_DETECTION_MAX_DETECTIONS, ot as createNativeAnonymizerFromPackage, p as NATIVE_BINDING_PARITY_MEMBERS, pt as isNativeAnonymizeBinding, q as PreparedNativeRedactionSession, r as EXTERNAL_DETECTION_BATCH_MAX_BYTES, rt as assertNativeBindingVersion, s as EXTERNAL_DETECTION_MAX_LABEL_MAPPINGS, st as createNativePipelineFromPackage, t as CALLER_DETECTION_CONTRACT_VERSION, tt as SharedNativeRedactTextStreamJsonOptions, u as EXTERNAL_DETECTION_PROVIDER_ID_MAX_BYTES, ut as encodeNativeSearchConfig, v as NativeCallerDetection, w as NativeOperatorConfig, wt as CustomDenyListEntry, x as NativeDiagnosticsBatchCallback, y as NativeCallerRedactionOptions, z as NativeSessionMetadata, zt as TriggerStrategy } from "./native.mjs";
4
- import { $ as prepareNativePipelinePackage, A as readDefaultNativePipelinePackageFile, B as redact_text_json, C as load_prepared_package_file, D as preloadDefaultNativePipelineAsync, E as preloadDefaultNativePipeline, F as redactDefaultText, G as NativePipelineBuildOptions, H as setNativeBindingOverride, I as redactDefaultTextJson, J as NativePipelineUnsupportedFeature, K as NativePipelineCompatibility, L as redact_default_text, M as readNativePipelinePackageFile, N as readNativePipelinePackageFileAsync, O as preload_default_native_pipeline, P as read_default_native_pipeline_package_file, Q as prepareNativePipelineConfig, R as redact_default_text_json, S as load_prepared_package, T as normalize_for_search, U as summary_diagnostics_json, V as redact_text_stream_json, W as DEFAULT_NATIVE_PIPELINE_CONFIG, X as createNativePipelineFromConfig, Y as assertNativePipelineSupported, Z as getNativePipelineCompatibility, _ as diagnostics_json, a as LoadNativeBindingOptions, b as get_default_native_pipeline, c as NativeRequire, d as availableDefaultNativePipelineLanguages, f as available_default_native_pipeline_languages, g as create_native_pipeline_from_default_package, h as createNativePipelineFromPackageFile, i as DefaultNativePipelineWarmup, j as readDefaultNativePipelinePackageFileAsync, k as prepare_search_package, l as NativeSdkOptions, m as createNativePipelineFromDefaultPackage, n as DefaultNativePipelinePackageFileOptions, o as NativeLibc, p as convert_external_detection_batch, q as NativePipelinePackageOptions, r as DefaultNativePipelinePackageOptions, s as NativePipelinePackageFileOptions, t as DEFAULT_NATIVE_PIPELINE_WARMUPS, u as NativeSdkPackageOptions, v as diagnostics_stream_json, w as native_package_version, x as loadNativeAnonymizeBinding, y as getDefaultNativePipeline, z as redact_text } from "./native-node.mjs";
4
+ import { $ as prepareNativePipelinePackage, A as readDefaultNativePipelinePackageFile, B as redact_text_json, C as load_prepared_package_file, D as preloadDefaultNativePipelineAsync, E as preloadDefaultNativePipeline, F as redactDefaultText, G as NativePipelineBuildOptions, H as setNativeBindingOverride, I as redactDefaultTextJson, J as NativePipelineUnsupportedFeature, K as NativePipelineCompatibility, L as redact_default_text, M as readNativePipelinePackageFile, N as readNativePipelinePackageFileAsync, O as preload_default_native_pipeline, P as read_default_native_pipeline_package_file, Q as prepareNativePipelineConfig, R as redact_default_text_json, S as load_prepared_package, T as normalize_for_search, U as summary_diagnostics_json, V as redact_text_stream_json, W as DEFAULT_NATIVE_PIPELINE_CONFIG, X as createNativePipelineFromConfig, Y as assertNativePipelineSupported, Z as getNativePipelineCompatibility, _ as diagnostics_json, a as LoadNativeBindingOptions, b as get_default_native_pipeline, c as NativeRequire, d as availableDefaultNativePipelineLanguages, et as PipelineContext, f as available_default_native_pipeline_languages, g as create_native_pipeline_from_default_package, h as createNativePipelineFromPackageFile, i as DefaultNativePipelineWarmup, j as readDefaultNativePipelinePackageFileAsync, k as prepare_search_package, l as NativeSdkOptions, m as createNativePipelineFromDefaultPackage, n as DefaultNativePipelinePackageFileOptions, o as NativeLibc, p as convert_external_detection_batch, q as NativePipelinePackageOptions, r as DefaultNativePipelinePackageOptions, s as NativePipelinePackageFileOptions, t as DEFAULT_NATIVE_PIPELINE_WARMUPS, tt as createPipelineContext, u as NativeSdkPackageOptions, v as diagnostics_stream_json, w as native_package_version, x as loadNativeAnonymizeBinding, y as getDefaultNativePipeline, z as redact_text } from "./native-node.mjs";
5
5
  //#region src/redact.d.ts
6
6
  /**
7
7
  * Serialize the redaction key to JSON for export.
@@ -15,5 +15,5 @@ declare const exportRedactionKey: (redactionMap: Map<string, string>, operatorMa
15
15
  */
16
16
  declare const deanonymise: (redactedText: string, redactionMap: Map<string, string>) => string;
17
17
  //#endregion
18
- export { type AnonymisationOperator, CALLER_DETECTION_CONTRACT_VERSION, CAPABILITY_MANIFEST, CAPABILITY_MANIFEST_SCHEMA_VERSION, CAPABILITY_PARITY_PROFILES, CAPABILITY_RUNTIMES, CAPABILITY_SURFACES, type CapabilityManifest, type CapabilityParityProfile, type CapabilityRuntime, type CapabilitySurface, type CapabilitySurfaceId, ConvertExternalDetectionBatchOptions, type CustomDenyListEntry, type CustomRegexPattern, DEFAULT_ENTITY_LABELS, DEFAULT_NATIVE_PIPELINE_CONFIG, DEFAULT_NATIVE_PIPELINE_WARMUPS, DETECTION_SOURCES, DETECTOR_PRIORITY, type DefaultEntityLabel, DefaultNativePipelinePackageFileOptions, DefaultNativePipelinePackageOptions, DefaultNativePipelineWarmup, type DenyListCategory, type DetectionSource, type Dictionaries, type DictionaryMeta, ENTITY_CAPABILITIES, ENTITY_LABELS, ENTITY_SELECTIONS, EXTERNAL_DETECTION_BATCH_MAX_BYTES, EXTERNAL_DETECTION_BATCH_VERSION, EXTERNAL_DETECTION_DOCUMENT_MAX_BYTES, EXTERNAL_DETECTION_MAX_DETECTIONS, EXTERNAL_DETECTION_MAX_LABEL_MAPPINGS, EXTERNAL_DETECTION_MAX_METADATA_BYTES, EXTERNAL_DETECTION_OFFSET_UNITS, EXTERNAL_DETECTION_PROVIDER_ID_MAX_BYTES, type Entity, type EntityCapability, type EntityLabel, type EntitySelection, ExternalDetectionBatch, ExternalDetectionOffsetUnit, type GazetteerEntry, LoadNativeBindingOptions, NATIVE_BINDING_PARITY_MEMBERS, NativeAnonymizeBinding, NativeAnonymizerFromConfigOptions, NativeAnonymizerFromPackageOptions, NativeBindingVersionOptions, NativeCallerDetection, NativeCallerRedactionOptions, NativeCreateSessionWithLifecycleOptions, NativeDiagnosticsBatchCallback, NativeLibc, NativeNormalizeOptions, NativeOpenSessionArchiveOptions, NativeOperatorConfig, type NativePipelineBuildOptions, type NativePipelineCompatibility, NativePipelineEntity, NativePipelineFromPackageOptions, NativePipelinePackageFileOptions, type NativePipelinePackageOptions, type NativePipelineUnsupportedFeature, NativePreparedRedactionSessionBinding, NativePreparedSearchBinding, type NativePreparedSearchConfig, NativePreparedSessionRedactionPlanBinding, NativeRedactionResult, NativeRequire, NativeResultEventCallback, NativeSdkOptions, NativeSdkPackageOptions, NativeSearchPackageInput, NativeSearchPackageOptions, NativeSessionBlockRedactionPlan, NativeSessionCallerRedactionInput, NativeSessionCallerRedactionPlanOptions, NativeSessionDeletionSummary, NativeSessionLifecycle, NativeSessionMetadata, NativeSessionRedactionAtOptions, NativeSessionStatus, NativeStaticRedactionResult, NativeTextReplacement, OPERATOR_TYPES, type OperatorConfig, type OperatorType, type PipelineConfig, PreparedAnonymizer, PreparedNativeAnonymizer, PreparedNativePipeline, PreparedNativeRedactionSession, PreparedNativeSessionRedactionPlan, PreparedSearch, type RedactionResult, type ReviewDecision, type ReviewedEntity, SharedNativeDiagnosticsJsonOptions, SharedNativeDiagnosticsStreamJsonOptions, SharedNativePreparedPackageOptions, SharedNativeRedactTextJsonOptions, SharedNativeRedactTextOptions, SharedNativeRedactTextStreamJsonOptions, SharedNativeSearchPackageOptions, type TriggerExtension, type TriggerGroupConfig, type TriggerRule, type TriggerStrategy, type TriggerValidation, assertNativeBindingVersion, assertNativePipelineSupported, availableDefaultNativePipelineLanguages, available_default_native_pipeline_languages, convert_external_detection_batch, createNativeAnonymizerFromConfig, createNativeAnonymizerFromPackage, createNativePipelineFromConfig, createNativePipelineFromDefaultPackage, createNativePipelineFromPackage, createNativePipelineFromPackageFile, create_native_pipeline_from_default_package, deanonymise, diagnostics_json, diagnostics_stream_json, encodeNativeSearchConfig, encodeNativeSearchConfigInput, exportRedactionKey, getDefaultNativePipeline, getNativeBindingVersion, getNativePipelineCompatibility, get_default_native_pipeline, isNativeAnonymizeBinding, loadNativeAnonymizeBinding, load_prepared_package, load_prepared_package_file, native_package_version, normalize_for_search, preloadDefaultNativePipeline, preloadDefaultNativePipelineAsync, preload_default_native_pipeline, prepareNativePipelineConfig, prepareNativePipelinePackage, prepareNativeSearchPackage, prepare_search_package, readDefaultNativePipelinePackageFile, readDefaultNativePipelinePackageFileAsync, readNativePipelinePackageFile, readNativePipelinePackageFileAsync, read_default_native_pipeline_package_file, redactDefaultText, redactDefaultTextJson, redact_default_text, redact_default_text_json, redact_text, redact_text_json, redact_text_stream_json, setNativeBindingOverride, summary_diagnostics_json };
18
+ export { type AnonymisationOperator, CALLER_DETECTION_CONTRACT_VERSION, CAPABILITY_MANIFEST, CAPABILITY_MANIFEST_SCHEMA_VERSION, CAPABILITY_PARITY_PROFILES, CAPABILITY_RUNTIMES, CAPABILITY_SURFACES, type CapabilityManifest, type CapabilityParityProfile, type CapabilityRuntime, type CapabilitySurface, type CapabilitySurfaceId, ConvertExternalDetectionBatchOptions, type CustomDenyListEntry, type CustomRegexPattern, DEFAULT_ENTITY_LABELS, DEFAULT_NATIVE_PIPELINE_CONFIG, DEFAULT_NATIVE_PIPELINE_WARMUPS, DETECTION_SOURCES, DETECTOR_PRIORITY, type DefaultEntityLabel, DefaultNativePipelinePackageFileOptions, DefaultNativePipelinePackageOptions, DefaultNativePipelineWarmup, type DenyListCategory, type DetectionSource, type Dictionaries, type DictionaryMeta, ENTITY_CAPABILITIES, ENTITY_LABELS, ENTITY_SELECTIONS, EXTERNAL_DETECTION_BATCH_MAX_BYTES, EXTERNAL_DETECTION_BATCH_VERSION, EXTERNAL_DETECTION_DOCUMENT_MAX_BYTES, EXTERNAL_DETECTION_MAX_DETECTIONS, EXTERNAL_DETECTION_MAX_LABEL_MAPPINGS, EXTERNAL_DETECTION_MAX_METADATA_BYTES, EXTERNAL_DETECTION_OFFSET_UNITS, EXTERNAL_DETECTION_PROVIDER_ID_MAX_BYTES, type Entity, type EntityCapability, type EntityLabel, type EntitySelection, ExternalDetectionBatch, ExternalDetectionOffsetUnit, type GazetteerEntry, LoadNativeBindingOptions, NATIVE_BINDING_PARITY_MEMBERS, NativeAnonymizeBinding, NativeAnonymizerFromConfigOptions, NativeAnonymizerFromPackageOptions, NativeBindingVersionOptions, NativeCallerDetection, NativeCallerRedactionOptions, NativeCreateSessionWithLifecycleOptions, NativeDiagnosticsBatchCallback, NativeLibc, NativeNormalizeOptions, NativeOpenSessionArchiveOptions, NativeOperatorConfig, type NativePipelineBuildOptions, type NativePipelineCompatibility, NativePipelineEntity, NativePipelineFromPackageOptions, NativePipelinePackageFileOptions, type NativePipelinePackageOptions, type NativePipelineUnsupportedFeature, NativePreparedRedactionSessionBinding, NativePreparedSearchBinding, type NativePreparedSearchConfig, NativePreparedSessionRedactionPlanBinding, NativeRedactionResult, NativeRequire, NativeResultEventCallback, NativeSdkOptions, NativeSdkPackageOptions, NativeSearchPackageInput, NativeSearchPackageOptions, NativeSessionBlockRedactionPlan, NativeSessionCallerRedactionInput, NativeSessionCallerRedactionPlanOptions, NativeSessionDeletionSummary, NativeSessionLifecycle, NativeSessionMetadata, NativeSessionRedactionAtOptions, NativeSessionStatus, NativeStaticRedactionResult, NativeTextReplacement, OPERATOR_TYPES, type OperatorConfig, type OperatorType, type PipelineConfig, type PipelineContext, PreparedAnonymizer, PreparedNativeAnonymizer, PreparedNativePipeline, PreparedNativeRedactionSession, PreparedNativeSessionRedactionPlan, PreparedSearch, type RedactionResult, type ReviewDecision, type ReviewedEntity, SharedNativeDiagnosticsJsonOptions, SharedNativeDiagnosticsStreamJsonOptions, SharedNativePreparedPackageOptions, SharedNativeRedactTextJsonOptions, SharedNativeRedactTextOptions, SharedNativeRedactTextStreamJsonOptions, SharedNativeSearchPackageOptions, type TriggerExtension, type TriggerGroupConfig, type TriggerRule, type TriggerStrategy, type TriggerValidation, assertNativeBindingVersion, assertNativePipelineSupported, availableDefaultNativePipelineLanguages, available_default_native_pipeline_languages, convert_external_detection_batch, createNativeAnonymizerFromConfig, createNativeAnonymizerFromPackage, createNativePipelineFromConfig, createNativePipelineFromDefaultPackage, createNativePipelineFromPackage, createNativePipelineFromPackageFile, createPipelineContext, create_native_pipeline_from_default_package, deanonymise, diagnostics_json, diagnostics_stream_json, encodeNativeSearchConfig, encodeNativeSearchConfigInput, exportRedactionKey, getDefaultNativePipeline, getNativeBindingVersion, getNativePipelineCompatibility, get_default_native_pipeline, isNativeAnonymizeBinding, loadNativeAnonymizeBinding, load_prepared_package, load_prepared_package_file, native_package_version, normalize_for_search, preloadDefaultNativePipeline, preloadDefaultNativePipelineAsync, preload_default_native_pipeline, prepareNativePipelineConfig, prepareNativePipelinePackage, prepareNativeSearchPackage, prepare_search_package, readDefaultNativePipelinePackageFile, readDefaultNativePipelinePackageFileAsync, readNativePipelinePackageFile, readNativePipelinePackageFileAsync, read_default_native_pipeline_package_file, redactDefaultText, redactDefaultTextJson, redact_default_text, redact_default_text_json, redact_text, redact_text_json, redact_text_stream_json, setNativeBindingOverride, summary_diagnostics_json };
19
19
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CALLER_DETECTION_CONTRACT_VERSION, EXTERNAL_DETECTION_BATCH_MAX_BYTES, EXTERNAL_DETECTION_BATCH_VERSION, EXTERNAL_DETECTION_DOCUMENT_MAX_BYTES, EXTERNAL_DETECTION_MAX_DETECTIONS, EXTERNAL_DETECTION_MAX_LABEL_MAPPINGS, EXTERNAL_DETECTION_MAX_METADATA_BYTES, EXTERNAL_DETECTION_OFFSET_UNITS, EXTERNAL_DETECTION_PROVIDER_ID_MAX_BYTES, NATIVE_BINDING_PARITY_MEMBERS, PreparedAnonymizer, PreparedNativeAnonymizer, PreparedNativePipeline, PreparedNativeRedactionSession, PreparedNativeSessionRedactionPlan, PreparedSearch, assertNativeBindingVersion, createNativeAnonymizerFromConfig, createNativeAnonymizerFromPackage, createNativePipelineFromPackage, encodeNativeSearchConfig, encodeNativeSearchConfigInput, getNativeBindingVersion, isNativeAnonymizeBinding, prepareNativeSearchPackage } from "./native.mjs";
2
- import { A as redact_text, B as prepareNativePipelinePackage, C as readNativePipelinePackageFile, D as redactDefaultTextJson, E as redactDefaultText, F as DEFAULT_NATIVE_PIPELINE_CONFIG, I as assertNativePipelineSupported, L as createNativePipelineFromConfig, M as redact_text_stream_json, N as setNativeBindingOverride, O as redact_default_text, P as summary_diagnostics_json, R as getNativePipelineCompatibility, S as readDefaultNativePipelinePackageFileAsync, T as read_default_native_pipeline_package_file, _ as preloadDefaultNativePipeline, a as createNativePipelineFromDefaultPackage, b as prepare_search_package, c as diagnostics_json, d as get_default_native_pipeline, f as loadNativeAnonymizeBinding, g as normalize_for_search, h as native_package_version, i as convert_external_detection_batch, j as redact_text_json, k as redact_default_text_json, l as diagnostics_stream_json, m as load_prepared_package_file, n as availableDefaultNativePipelineLanguages, o as createNativePipelineFromPackageFile, p as load_prepared_package, r as available_default_native_pipeline_languages, s as create_native_pipeline_from_default_package, t as DEFAULT_NATIVE_PIPELINE_WARMUPS, u as getDefaultNativePipeline, v as preloadDefaultNativePipelineAsync, w as readNativePipelinePackageFileAsync, x as readDefaultNativePipelinePackageFile, y as preload_default_native_pipeline, z as prepareNativePipelineConfig } from "./native-node2.mjs";
2
+ import { A as redact_text, B as prepareNativePipelinePackage, C as readNativePipelinePackageFile, D as redactDefaultTextJson, E as redactDefaultText, F as DEFAULT_NATIVE_PIPELINE_CONFIG, I as assertNativePipelineSupported, L as createNativePipelineFromConfig, M as redact_text_stream_json, N as setNativeBindingOverride, O as redact_default_text, P as summary_diagnostics_json, R as getNativePipelineCompatibility, S as readDefaultNativePipelinePackageFileAsync, T as read_default_native_pipeline_package_file, V as createPipelineContext, _ as preloadDefaultNativePipeline, a as createNativePipelineFromDefaultPackage, b as prepare_search_package, c as diagnostics_json, d as get_default_native_pipeline, f as loadNativeAnonymizeBinding, g as normalize_for_search, h as native_package_version, i as convert_external_detection_batch, j as redact_text_json, k as redact_default_text_json, l as diagnostics_stream_json, m as load_prepared_package_file, n as availableDefaultNativePipelineLanguages, o as createNativePipelineFromPackageFile, p as load_prepared_package, r as available_default_native_pipeline_languages, s as create_native_pipeline_from_default_package, t as DEFAULT_NATIVE_PIPELINE_WARMUPS, u as getDefaultNativePipeline, v as preloadDefaultNativePipelineAsync, w as readNativePipelinePackageFileAsync, x as readDefaultNativePipelinePackageFile, y as preload_default_native_pipeline, z as prepareNativePipelineConfig } from "./native-node2.mjs";
3
3
  import { DEFAULT_ENTITY_LABELS, DETECTION_SOURCES, DETECTOR_PRIORITY, ENTITY_CAPABILITIES, ENTITY_LABELS, ENTITY_SELECTIONS, OPERATOR_TYPES } from "./constants.mjs";
4
4
  import { CAPABILITY_MANIFEST, CAPABILITY_MANIFEST_SCHEMA_VERSION, CAPABILITY_PARITY_PROFILES, CAPABILITY_RUNTIMES, CAPABILITY_SURFACES } from "./capabilities.mjs";
5
5
  //#region src/redact.ts
@@ -26,6 +26,6 @@ const deanonymise = (redactedText, redactionMap) => {
26
26
  return result;
27
27
  };
28
28
  //#endregion
29
- export { CALLER_DETECTION_CONTRACT_VERSION, CAPABILITY_MANIFEST, CAPABILITY_MANIFEST_SCHEMA_VERSION, CAPABILITY_PARITY_PROFILES, CAPABILITY_RUNTIMES, CAPABILITY_SURFACES, DEFAULT_ENTITY_LABELS, DEFAULT_NATIVE_PIPELINE_CONFIG, DEFAULT_NATIVE_PIPELINE_WARMUPS, DETECTION_SOURCES, DETECTOR_PRIORITY, ENTITY_CAPABILITIES, ENTITY_LABELS, ENTITY_SELECTIONS, EXTERNAL_DETECTION_BATCH_MAX_BYTES, EXTERNAL_DETECTION_BATCH_VERSION, EXTERNAL_DETECTION_DOCUMENT_MAX_BYTES, EXTERNAL_DETECTION_MAX_DETECTIONS, EXTERNAL_DETECTION_MAX_LABEL_MAPPINGS, EXTERNAL_DETECTION_MAX_METADATA_BYTES, EXTERNAL_DETECTION_OFFSET_UNITS, EXTERNAL_DETECTION_PROVIDER_ID_MAX_BYTES, NATIVE_BINDING_PARITY_MEMBERS, OPERATOR_TYPES, PreparedAnonymizer, PreparedNativeAnonymizer, PreparedNativePipeline, PreparedNativeRedactionSession, PreparedNativeSessionRedactionPlan, PreparedSearch, assertNativeBindingVersion, assertNativePipelineSupported, availableDefaultNativePipelineLanguages, available_default_native_pipeline_languages, convert_external_detection_batch, createNativeAnonymizerFromConfig, createNativeAnonymizerFromPackage, createNativePipelineFromConfig, createNativePipelineFromDefaultPackage, createNativePipelineFromPackage, createNativePipelineFromPackageFile, create_native_pipeline_from_default_package, deanonymise, diagnostics_json, diagnostics_stream_json, encodeNativeSearchConfig, encodeNativeSearchConfigInput, exportRedactionKey, getDefaultNativePipeline, getNativeBindingVersion, getNativePipelineCompatibility, get_default_native_pipeline, isNativeAnonymizeBinding, loadNativeAnonymizeBinding, load_prepared_package, load_prepared_package_file, native_package_version, normalize_for_search, preloadDefaultNativePipeline, preloadDefaultNativePipelineAsync, preload_default_native_pipeline, prepareNativePipelineConfig, prepareNativePipelinePackage, prepareNativeSearchPackage, prepare_search_package, readDefaultNativePipelinePackageFile, readDefaultNativePipelinePackageFileAsync, readNativePipelinePackageFile, readNativePipelinePackageFileAsync, read_default_native_pipeline_package_file, redactDefaultText, redactDefaultTextJson, redact_default_text, redact_default_text_json, redact_text, redact_text_json, redact_text_stream_json, setNativeBindingOverride, summary_diagnostics_json };
29
+ export { CALLER_DETECTION_CONTRACT_VERSION, CAPABILITY_MANIFEST, CAPABILITY_MANIFEST_SCHEMA_VERSION, CAPABILITY_PARITY_PROFILES, CAPABILITY_RUNTIMES, CAPABILITY_SURFACES, DEFAULT_ENTITY_LABELS, DEFAULT_NATIVE_PIPELINE_CONFIG, DEFAULT_NATIVE_PIPELINE_WARMUPS, DETECTION_SOURCES, DETECTOR_PRIORITY, ENTITY_CAPABILITIES, ENTITY_LABELS, ENTITY_SELECTIONS, EXTERNAL_DETECTION_BATCH_MAX_BYTES, EXTERNAL_DETECTION_BATCH_VERSION, EXTERNAL_DETECTION_DOCUMENT_MAX_BYTES, EXTERNAL_DETECTION_MAX_DETECTIONS, EXTERNAL_DETECTION_MAX_LABEL_MAPPINGS, EXTERNAL_DETECTION_MAX_METADATA_BYTES, EXTERNAL_DETECTION_OFFSET_UNITS, EXTERNAL_DETECTION_PROVIDER_ID_MAX_BYTES, NATIVE_BINDING_PARITY_MEMBERS, OPERATOR_TYPES, PreparedAnonymizer, PreparedNativeAnonymizer, PreparedNativePipeline, PreparedNativeRedactionSession, PreparedNativeSessionRedactionPlan, PreparedSearch, assertNativeBindingVersion, assertNativePipelineSupported, availableDefaultNativePipelineLanguages, available_default_native_pipeline_languages, convert_external_detection_batch, createNativeAnonymizerFromConfig, createNativeAnonymizerFromPackage, createNativePipelineFromConfig, createNativePipelineFromDefaultPackage, createNativePipelineFromPackage, createNativePipelineFromPackageFile, createPipelineContext, create_native_pipeline_from_default_package, deanonymise, diagnostics_json, diagnostics_stream_json, encodeNativeSearchConfig, encodeNativeSearchConfigInput, exportRedactionKey, getDefaultNativePipeline, getNativeBindingVersion, getNativePipelineCompatibility, get_default_native_pipeline, isNativeAnonymizeBinding, loadNativeAnonymizeBinding, load_prepared_package, load_prepared_package_file, native_package_version, normalize_for_search, preloadDefaultNativePipeline, preloadDefaultNativePipelineAsync, preload_default_native_pipeline, prepareNativePipelineConfig, prepareNativePipelinePackage, prepareNativeSearchPackage, prepare_search_package, readDefaultNativePipelinePackageFile, readDefaultNativePipelinePackageFileAsync, readNativePipelinePackageFile, readNativePipelinePackageFileAsync, read_default_native_pipeline_package_file, redactDefaultText, redactDefaultTextJson, redact_default_text, redact_default_text_json, redact_text, redact_text_json, redact_text_stream_json, setNativeBindingOverride, summary_diagnostics_json };
30
30
 
31
31
  //# sourceMappingURL=index.mjs.map
@@ -12,6 +12,8 @@ type PipelineContext = {
12
12
  nativePipelinePackageKey: string;
13
13
  nativePipelinePackagePromise: Promise<Uint8Array> | null;
14
14
  };
15
+ /** Create a fresh, empty pipeline context. */
16
+ declare const createPipelineContext: () => PipelineContext;
15
17
  //#endregion
16
18
  //#region src/native-pipeline.d.ts
17
19
  type NativePipelineUnsupportedFeature = "enableNer";
@@ -108,5 +110,5 @@ declare const redactDefaultTextJson: (fullText: string, operators?: NativeOperat
108
110
  declare const redact_default_text_json: (fullText: string, operators?: NativeOperatorConfig, options?: DefaultNativePipelinePackageOptions) => string;
109
111
  declare const preloadDefaultNativePipelineAsync: (options?: DefaultNativePipelinePackageOptions) => Promise<PreparedNativePipeline>;
110
112
  //#endregion
111
- export { prepareNativePipelinePackage as $, readDefaultNativePipelinePackageFile as A, redact_text_json as B, load_prepared_package_file as C, preloadDefaultNativePipelineAsync as D, preloadDefaultNativePipeline as E, redactDefaultText as F, NativePipelineBuildOptions as G, setNativeBindingOverride as H, redactDefaultTextJson as I, NativePipelineUnsupportedFeature as J, NativePipelineCompatibility as K, redact_default_text as L, readNativePipelinePackageFile as M, readNativePipelinePackageFileAsync as N, preload_default_native_pipeline as O, read_default_native_pipeline_package_file as P, prepareNativePipelineConfig as Q, redact_default_text_json as R, load_prepared_package as S, normalize_for_search as T, summary_diagnostics_json as U, redact_text_stream_json as V, DEFAULT_NATIVE_PIPELINE_CONFIG as W, createNativePipelineFromConfig as X, assertNativePipelineSupported as Y, getNativePipelineCompatibility as Z, diagnostics_json as _, LoadNativeBindingOptions as a, get_default_native_pipeline as b, NativeRequire as c, availableDefaultNativePipelineLanguages as d, available_default_native_pipeline_languages as f, create_native_pipeline_from_default_package as g, createNativePipelineFromPackageFile as h, DefaultNativePipelineWarmup as i, readDefaultNativePipelinePackageFileAsync as j, prepare_search_package as k, NativeSdkOptions as l, createNativePipelineFromDefaultPackage as m, DefaultNativePipelinePackageFileOptions as n, NativeLibc as o, convert_external_detection_batch as p, NativePipelinePackageOptions as q, DefaultNativePipelinePackageOptions as r, NativePipelinePackageFileOptions as s, DEFAULT_NATIVE_PIPELINE_WARMUPS as t, NativeSdkPackageOptions as u, diagnostics_stream_json as v, native_package_version as w, loadNativeAnonymizeBinding as x, getDefaultNativePipeline as y, redact_text as z };
113
+ export { prepareNativePipelinePackage as $, readDefaultNativePipelinePackageFile as A, redact_text_json as B, load_prepared_package_file as C, preloadDefaultNativePipelineAsync as D, preloadDefaultNativePipeline as E, redactDefaultText as F, NativePipelineBuildOptions as G, setNativeBindingOverride as H, redactDefaultTextJson as I, NativePipelineUnsupportedFeature as J, NativePipelineCompatibility as K, redact_default_text as L, readNativePipelinePackageFile as M, readNativePipelinePackageFileAsync as N, preload_default_native_pipeline as O, read_default_native_pipeline_package_file as P, prepareNativePipelineConfig as Q, redact_default_text_json as R, load_prepared_package as S, normalize_for_search as T, summary_diagnostics_json as U, redact_text_stream_json as V, DEFAULT_NATIVE_PIPELINE_CONFIG as W, createNativePipelineFromConfig as X, assertNativePipelineSupported as Y, getNativePipelineCompatibility as Z, diagnostics_json as _, LoadNativeBindingOptions as a, get_default_native_pipeline as b, NativeRequire as c, availableDefaultNativePipelineLanguages as d, PipelineContext as et, available_default_native_pipeline_languages as f, create_native_pipeline_from_default_package as g, createNativePipelineFromPackageFile as h, DefaultNativePipelineWarmup as i, readDefaultNativePipelinePackageFileAsync as j, prepare_search_package as k, NativeSdkOptions as l, createNativePipelineFromDefaultPackage as m, DefaultNativePipelinePackageFileOptions as n, NativeLibc as o, convert_external_detection_batch as p, NativePipelinePackageOptions as q, DefaultNativePipelinePackageOptions as r, NativePipelinePackageFileOptions as s, DEFAULT_NATIVE_PIPELINE_WARMUPS as t, createPipelineContext as tt, NativeSdkPackageOptions as u, diagnostics_stream_json as v, native_package_version as w, loadNativeAnonymizeBinding as x, getDefaultNativePipeline as y, redact_text as z };
112
114
  //# sourceMappingURL=native-node.d.mts.map
@@ -4,6 +4,7 @@ import { createRequire } from "node:module";
4
4
  import { existsSync, readFileSync, readdirSync } from "node:fs";
5
5
  import { readFile } from "node:fs/promises";
6
6
  import process from "node:process";
7
+ import { loadNativeBinding } from "../index.cjs";
7
8
  //#region src/bun-version.ts
8
9
  const MINIMUM_BUN_MAJOR = 1;
9
10
  const MINIMUM_BUN_MINOR = 4;
@@ -399,7 +400,6 @@ const DEFAULT_NATIVE_PIPELINE_WARMUPS = {
399
400
  lazyRegex: "lazy-regex",
400
401
  none: "none"
401
402
  };
402
- const LOCAL_NATIVE_LOADER = "../index.cjs";
403
403
  const PACKAGE_SPECIFIC_NATIVE_PATH = "STELLA_ANONYMIZE_NATIVE_LIBRARY_PATH";
404
404
  const DEFAULT_NATIVE_PIPELINE_PACKAGE_URL = new URL("../native-pipeline.stlanonpkg", import.meta.url);
405
405
  const DEFAULT_NATIVE_PIPELINE_PACKAGE_DIR_URL = new URL("../", import.meta.url);
@@ -437,11 +437,21 @@ const loadNativeAnonymizeBinding = (options = {}) => {
437
437
  libc,
438
438
  platform
439
439
  });
440
+ const platformPackage = nativeBindingPackageName({
441
+ arch,
442
+ libc,
443
+ platform
444
+ });
440
445
  const errors = [];
441
446
  for (const specifier of specifiers) {
447
+ const loadModule = options.requireModule === void 0 && specifier === platformPackage && isHostNativeTarget({
448
+ arch,
449
+ libc,
450
+ platform
451
+ }) ? loadNativeBinding : () => requireModule(specifier);
442
452
  const binding = tryLoadNativeBinding({
443
453
  specifier,
444
- requireModule,
454
+ loadModule,
445
455
  errors
446
456
  });
447
457
  if (!binding) continue;
@@ -708,7 +718,6 @@ const nativeBindingSpecifiers = ({ arch, env, libc, platform }) => {
708
718
  const specifiers = [];
709
719
  const overridePath = env[PACKAGE_SPECIFIC_NATIVE_PATH];
710
720
  if (overridePath) specifiers.push(overridePath);
711
- specifiers.push(LOCAL_NATIVE_LOADER);
712
721
  const platformPackage = nativeBindingPackageName({
713
722
  arch,
714
723
  libc,
@@ -766,9 +775,10 @@ const detectNativeLibc = (platform) => {
766
775
  const report = process.report?.getReport();
767
776
  return typeof (isPropertyBag(report) && isPropertyBag(report["header"]) ? report["header"] : null)?.["glibcVersionRuntime"] === "string" ? "gnu" : "musl";
768
777
  };
769
- const tryLoadNativeBinding = ({ specifier, requireModule, errors }) => {
778
+ const isHostNativeTarget = ({ arch, libc, platform }) => platform === process.platform && arch === process.arch && (platform !== "linux" || libc === detectNativeLibc(process.platform));
779
+ const tryLoadNativeBinding = ({ specifier, loadModule, errors }) => {
770
780
  try {
771
- const loaded = requireModule(specifier);
781
+ const loaded = loadModule();
772
782
  const binding = toNativeAnonymizeBinding(loaded);
773
783
  if (binding) return binding;
774
784
  errors.push(`${specifier}: module does not match native binding shape`);
@@ -787,6 +797,6 @@ const formatLoadError = (error) => {
787
797
  return String(error);
788
798
  };
789
799
  //#endregion
790
- export { redact_text as A, prepareNativePipelinePackage as B, readNativePipelinePackageFile as C, redactDefaultTextJson as D, redactDefaultText as E, DEFAULT_NATIVE_PIPELINE_CONFIG as F, assertNativePipelineSupported as I, createNativePipelineFromConfig as L, redact_text_stream_json as M, setNativeBindingOverride as N, redact_default_text as O, summary_diagnostics_json as P, getNativePipelineCompatibility as R, readDefaultNativePipelinePackageFileAsync as S, read_default_native_pipeline_package_file as T, preloadDefaultNativePipeline as _, createNativePipelineFromDefaultPackage as a, prepare_search_package as b, diagnostics_json as c, get_default_native_pipeline as d, loadNativeAnonymizeBinding as f, normalize_for_search as g, native_package_version as h, convert_external_detection_batch as i, redact_text_json as j, redact_default_text_json as k, diagnostics_stream_json as l, load_prepared_package_file as m, availableDefaultNativePipelineLanguages as n, createNativePipelineFromPackageFile as o, load_prepared_package as p, available_default_native_pipeline_languages as r, create_native_pipeline_from_default_package as s, DEFAULT_NATIVE_PIPELINE_WARMUPS as t, getDefaultNativePipeline as u, preloadDefaultNativePipelineAsync as v, readNativePipelinePackageFileAsync as w, readDefaultNativePipelinePackageFile as x, preload_default_native_pipeline as y, prepareNativePipelineConfig as z };
800
+ export { redact_text as A, prepareNativePipelinePackage as B, readNativePipelinePackageFile as C, redactDefaultTextJson as D, redactDefaultText as E, DEFAULT_NATIVE_PIPELINE_CONFIG as F, assertNativePipelineSupported as I, createNativePipelineFromConfig as L, redact_text_stream_json as M, setNativeBindingOverride as N, redact_default_text as O, summary_diagnostics_json as P, getNativePipelineCompatibility as R, readDefaultNativePipelinePackageFileAsync as S, read_default_native_pipeline_package_file as T, createPipelineContext as V, preloadDefaultNativePipeline as _, createNativePipelineFromDefaultPackage as a, prepare_search_package as b, diagnostics_json as c, get_default_native_pipeline as d, loadNativeAnonymizeBinding as f, normalize_for_search as g, native_package_version as h, convert_external_detection_batch as i, redact_text_json as j, redact_default_text_json as k, diagnostics_stream_json as l, load_prepared_package_file as m, availableDefaultNativePipelineLanguages as n, createNativePipelineFromPackageFile as o, load_prepared_package as p, available_default_native_pipeline_languages as r, create_native_pipeline_from_default_package as s, DEFAULT_NATIVE_PIPELINE_WARMUPS as t, getDefaultNativePipeline as u, preloadDefaultNativePipelineAsync as v, readNativePipelinePackageFileAsync as w, readDefaultNativePipelinePackageFile as x, preload_default_native_pipeline as y, prepareNativePipelineConfig as z };
791
801
 
792
802
  //# sourceMappingURL=native-node2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"native-node2.mjs","names":["languageScopes","nativePackageVersionWithBinding","convertExternalDetectionBatchWithBinding","normalizeForSearchWithBinding","prepareSearchPackageWithBinding","loadPreparedPackageWithBinding","redactTextWithBinding","redactTextJsonWithBinding","redactTextStreamJsonWithBinding","diagnosticsJsonWithBinding","diagnosticsStreamJsonWithBinding","summaryDiagnosticsJsonWithBinding"],"sources":["../src/bun-version.ts","../src/context.ts","../src/data/language-scopes.json","../src/language-scope.ts","../src/types.ts","../src/util/language-selection.ts","../src/pipeline-cache-key.ts","../src/native-pipeline.ts","../src/native-default-config.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","","import languageScopes from \"./data/language-scopes.json\";\n\nimport type { PipelineConfig } from \"./types\";\n\ntype LanguageScope = {\n nameCorpusLanguages?: readonly string[];\n denyListCountries?: readonly string[];\n};\n\ntype LanguageScopeData = {\n languages: Record<string, LanguageScope>;\n};\n\nconst scopeData = languageScopes as LanguageScopeData;\n\nconst normalizeLanguage = (language: string): string =>\n language.trim().toLowerCase();\n\nconst fallbackLanguage = (language: string): string | null => {\n const index = language.indexOf(\"-\");\n return index === -1 ? null : language.slice(0, index);\n};\n\nconst uniquePush = (target: string[], values: readonly string[]): void => {\n const seen = new Set(target);\n for (const value of values) {\n if (seen.has(value)) {\n continue;\n }\n seen.add(value);\n target.push(value);\n }\n};\n\nconst resolveLanguageScope = (language: string): LanguageScope | null => {\n const normalized = normalizeLanguage(language);\n if (normalized.length === 0) {\n return null;\n }\n const exact = scopeData.languages[normalized];\n if (exact !== undefined) {\n return exact;\n }\n const fallback = fallbackLanguage(normalized);\n return fallback === null ? null : (scopeData.languages[fallback] ?? null);\n};\n\nconst configuredLanguages = (config: PipelineConfig): readonly string[] => {\n if (config.languages !== undefined) {\n return config.languages;\n }\n return config.language === undefined ? [] : [config.language];\n};\n\nexport const configuredContentLanguages = (\n config: Pick<PipelineConfig, \"language\" | \"languages\">,\n): readonly string[] | undefined => {\n if (config.languages !== undefined) {\n return config.languages;\n }\n return config.language === undefined ? undefined : [config.language];\n};\n\nexport const applyPipelineLanguageScope = (\n config: PipelineConfig,\n): PipelineConfig => {\n const languages = configuredLanguages(config);\n if (languages.length === 0) {\n return config;\n }\n\n const nameCorpusLanguages: string[] = [];\n const denyListCountries: string[] = [];\n for (const language of languages) {\n const scope = resolveLanguageScope(language);\n if (scope === null) {\n continue;\n }\n uniquePush(nameCorpusLanguages, scope.nameCorpusLanguages ?? []);\n uniquePush(denyListCountries, scope.denyListCountries ?? []);\n }\n\n const next: Partial<PipelineConfig> = {};\n if (\n config.nameCorpusLanguages === undefined &&\n nameCorpusLanguages.length > 0\n ) {\n next.nameCorpusLanguages = nameCorpusLanguages;\n }\n if (config.denyListCountries === undefined && denyListCountries.length > 0) {\n next.denyListCountries = denyListCountries;\n }\n\n return Object.keys(next).length === 0 ? config : { ...config, ...next };\n};\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 { createRequire } from \"node:module\";\nimport { existsSync, readFileSync, readdirSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport process from \"node:process\";\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\";\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 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 LOCAL_NATIVE_LOADER = \"../index.cjs\";\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 errors: string[] = [];\n\n for (const specifier of specifiers) {\n const binding = tryLoadNativeBinding({\n specifier,\n requireModule,\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 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 specifiers.push(LOCAL_NATIVE_LOADER);\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\ntype TryLoadNativeBindingOptions = {\n specifier: string;\n requireModule: NativeRequire;\n errors: string[];\n};\n\nconst tryLoadNativeBinding = ({\n specifier,\n requireModule,\n errors,\n}: TryLoadNativeBindingOptions): NativeAnonymizeBinding | null => {\n try {\n const loaded = requireModule(specifier);\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;CACt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 {"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/data/language-scopes.json","../src/language-scope.ts","../src/types.ts","../src/util/language-selection.ts","../src/pipeline-cache-key.ts","../src/native-pipeline.ts","../src/native-default-config.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","","import languageScopes from \"./data/language-scopes.json\";\n\nimport type { PipelineConfig } from \"./types\";\n\ntype LanguageScope = {\n nameCorpusLanguages?: readonly string[];\n denyListCountries?: readonly string[];\n};\n\ntype LanguageScopeData = {\n languages: Record<string, LanguageScope>;\n};\n\nconst scopeData = languageScopes as LanguageScopeData;\n\nconst normalizeLanguage = (language: string): string =>\n language.trim().toLowerCase();\n\nconst fallbackLanguage = (language: string): string | null => {\n const index = language.indexOf(\"-\");\n return index === -1 ? null : language.slice(0, index);\n};\n\nconst uniquePush = (target: string[], values: readonly string[]): void => {\n const seen = new Set(target);\n for (const value of values) {\n if (seen.has(value)) {\n continue;\n }\n seen.add(value);\n target.push(value);\n }\n};\n\nconst resolveLanguageScope = (language: string): LanguageScope | null => {\n const normalized = normalizeLanguage(language);\n if (normalized.length === 0) {\n return null;\n }\n const exact = scopeData.languages[normalized];\n if (exact !== undefined) {\n return exact;\n }\n const fallback = fallbackLanguage(normalized);\n return fallback === null ? null : (scopeData.languages[fallback] ?? null);\n};\n\nconst configuredLanguages = (config: PipelineConfig): readonly string[] => {\n if (config.languages !== undefined) {\n return config.languages;\n }\n return config.language === undefined ? [] : [config.language];\n};\n\nexport const configuredContentLanguages = (\n config: Pick<PipelineConfig, \"language\" | \"languages\">,\n): readonly string[] | undefined => {\n if (config.languages !== undefined) {\n return config.languages;\n }\n return config.language === undefined ? undefined : [config.language];\n};\n\nexport const applyPipelineLanguageScope = (\n config: PipelineConfig,\n): PipelineConfig => {\n const languages = configuredLanguages(config);\n if (languages.length === 0) {\n return config;\n }\n\n const nameCorpusLanguages: string[] = [];\n const denyListCountries: string[] = [];\n for (const language of languages) {\n const scope = resolveLanguageScope(language);\n if (scope === null) {\n continue;\n }\n uniquePush(nameCorpusLanguages, scope.nameCorpusLanguages ?? []);\n uniquePush(denyListCountries, scope.denyListCountries ?? []);\n }\n\n const next: Partial<PipelineConfig> = {};\n if (\n config.nameCorpusLanguages === undefined &&\n nameCorpusLanguages.length > 0\n ) {\n next.nameCorpusLanguages = nameCorpusLanguages;\n }\n if (config.denyListCountries === undefined && denyListCountries.length > 0) {\n next.denyListCountries = denyListCountries;\n }\n\n return Object.keys(next).length === 0 ? config : { ...config, ...next };\n};\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 { 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\";\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 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 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,U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iB,OACnB,OAAO,MAAM;CAEf,OAAO,OAAO,KAAK;AACrB"}
package/index.cjs CHANGED
@@ -1,3 +1,51 @@
1
1
  "use strict";
2
2
 
3
- module.exports = require("./stella_anonymize_napi.node");
3
+ exports.loadNativeBinding = () => {
4
+ if (process.platform === "darwin" && process.arch === "arm64") {
5
+ try {
6
+ return require("@stll/anonymize-darwin-arm64");
7
+ } catch (cause) {
8
+ throw nativeSidecarLoadError("@stll/anonymize-darwin-arm64", cause);
9
+ }
10
+ }
11
+ if (process.platform === "darwin" && process.arch === "x64") {
12
+ try {
13
+ return require("@stll/anonymize-darwin-x64");
14
+ } catch (cause) {
15
+ throw nativeSidecarLoadError("@stll/anonymize-darwin-x64", cause);
16
+ }
17
+ }
18
+ if (process.platform === "linux" && process.arch === "arm64") {
19
+ try {
20
+ return require("@stll/anonymize-linux-arm64-gnu");
21
+ } catch (cause) {
22
+ throw nativeSidecarLoadError("@stll/anonymize-linux-arm64-gnu", cause);
23
+ }
24
+ }
25
+ if (process.platform === "linux" && process.arch === "x64") {
26
+ try {
27
+ return require("@stll/anonymize-linux-x64-gnu");
28
+ } catch (cause) {
29
+ throw nativeSidecarLoadError("@stll/anonymize-linux-x64-gnu", cause);
30
+ }
31
+ }
32
+ if (process.platform === "win32" && process.arch === "x64") {
33
+ try {
34
+ return require("@stll/anonymize-win32-x64-msvc");
35
+ } catch (cause) {
36
+ throw nativeSidecarLoadError("@stll/anonymize-win32-x64-msvc", cause);
37
+ }
38
+ }
39
+ throw new Error(
40
+ `No native anonymize binding is published for ${process.platform}-${process.arch}`,
41
+ );
42
+ };
43
+
44
+ const nativeSidecarLoadError = (packageName, cause) =>
45
+ new Error(
46
+ `Failed to load native anonymize sidecar ${packageName}: ${causeMessage(cause)}`,
47
+ { cause },
48
+ );
49
+
50
+ const causeMessage = (cause) =>
51
+ cause instanceof Error ? cause.message : String(cause);
package/index.d.cts ADDED
@@ -0,0 +1 @@
1
+ export declare const loadNativeBinding: () => unknown;
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.8.0",
3
+ "version": "2.8.2",
4
4
  "description": "Deterministic PII detection and anonymization with regex, deny lists, and coreference resolution",
5
5
  "keywords": [
6
6
  "anonymization",
@@ -59,8 +59,11 @@
59
59
  },
60
60
  "files": [
61
61
  "ATTRIBUTION.md",
62
+ "LICENSE",
63
+ "NOTICE",
62
64
  "dist",
63
65
  "index.cjs",
66
+ "index.d.cts",
64
67
  "native-pipeline.stlanonpkg",
65
68
  "native-pipeline.*.stlanonpkg",
66
69
  "scripts/build-native-pipeline-package.mjs"
@@ -102,7 +105,7 @@
102
105
  "format": "oxfmt ."
103
106
  },
104
107
  "peerDependencies": {
105
- "@stll/anonymize-data": "^0.0.9"
108
+ "@stll/anonymize-data": "^0.0.10"
106
109
  },
107
110
  "peerDependenciesMeta": {
108
111
  "@stll/anonymize-data": {
@@ -110,19 +113,19 @@
110
113
  }
111
114
  },
112
115
  "optionalDependencies": {
113
- "@stll/anonymize-darwin-arm64": "2.8.0",
114
- "@stll/anonymize-darwin-x64": "2.8.0",
115
- "@stll/anonymize-linux-arm64-gnu": "2.8.0",
116
- "@stll/anonymize-linux-x64-gnu": "2.8.0",
117
- "@stll/anonymize-win32-x64-msvc": "2.8.0"
116
+ "@stll/anonymize-darwin-arm64": "2.8.2",
117
+ "@stll/anonymize-darwin-x64": "2.8.2",
118
+ "@stll/anonymize-linux-arm64-gnu": "2.8.2",
119
+ "@stll/anonymize-linux-x64-gnu": "2.8.2",
120
+ "@stll/anonymize-win32-x64-msvc": "2.8.2"
118
121
  },
119
122
  "devDependencies": {
120
- "@napi-rs/cli": "^3.8.5",
123
+ "@napi-rs/cli": "^3.8.6",
121
124
  "@stll/anonymize-data": "workspace:*",
122
125
  "bun-types": "1.4.0",
123
126
  "fast-check": "^4.9.0",
124
127
  "fflate": "^0.8.3",
125
- "puppeteer-core": "25.5.0",
128
+ "puppeteer-core": "25.7.0",
126
129
  "tsdown": "0.22.14",
127
130
  "typescript": "7.0.2",
128
131
  "vite": "^8.2.1"