@desert-ant-labs/redact 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +136 -0
- package/README.md +143 -0
- package/dist/deterministic.d.ts +4 -0
- package/dist/deterministic.js +449 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +42 -0
- package/dist/model.d.ts +40 -0
- package/dist/model.js +177 -0
- package/dist/pipeline.d.ts +15 -0
- package/dist/pipeline.js +353 -0
- package/dist/types.d.ts +39 -0
- package/dist/types.js +1 -0
- package/package.json +59 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Desert Ant Labs Source-Available License
|
|
2
|
+
|
|
3
|
+
Version 1.0 · 2026-06-15
|
|
4
|
+
|
|
5
|
+
Copyright © 2026 Studio Company B.V., trading as Desert Ant Labs (`desertant.ai`).
|
|
6
|
+
|
|
7
|
+
This license governs Your use of the software, model weights, datasets, documentation, and associated assets in this repository (collectively, the **"Licensed Materials"**). It is a **source-available license intended for professional and business use**; it is not an OSI-approved open-source license. The rights granted here are subject to a per-Model usage cap and the other terms set out below.
|
|
8
|
+
|
|
9
|
+
## Definitions
|
|
10
|
+
|
|
11
|
+
- **"Desert Ant Labs"** (also "We", "Us", "Our") — Studio Company B.V., a private limited liability company (*besloten vennootschap*) incorporated under the laws of the Netherlands, with statutory seat in Amsterdam, registered with the Dutch Chamber of Commerce (KvK) under number **81228112**, trading as Desert Ant Labs.
|
|
12
|
+
- **"Model"** — a set of trained weights published by Desert Ant Labs under a single HuggingFace repository (for example, `huggingface.co/desert-ant-labs/eye`). Each Model is a distinct work under this license.
|
|
13
|
+
- **"Monthly Active User"** or **"MAU"** — a unique end user who interacts with a feature powered by a Model during a calendar month. Internal use by Your own employees and contractors does not count.
|
|
14
|
+
- **"You"** — the individual or legal entity exercising rights under this license.
|
|
15
|
+
|
|
16
|
+
## 0. Acceptance
|
|
17
|
+
|
|
18
|
+
By downloading, accessing, using, copying, modifying, or distributing the Licensed Materials, You agree to be bound by this license. If You do not agree, You may not use the Licensed Materials.
|
|
19
|
+
|
|
20
|
+
## 1. Grant
|
|
21
|
+
|
|
22
|
+
Subject to Your continued compliance with this license, Desert Ant Labs grants You a worldwide, royalty-free, non-exclusive, non-transferable, non-sublicensable license to use, reproduce, modify, and distribute the Licensed Materials.
|
|
23
|
+
|
|
24
|
+
## 2. Free-tier use
|
|
25
|
+
|
|
26
|
+
You may use the Licensed Materials free of charge, including for commercial purposes, subject to the following per-Model threshold:
|
|
27
|
+
|
|
28
|
+
> **For each Desert Ant Labs Model that Your products incorporate, the aggregate Monthly Active Users across all Your products must not exceed 100,000 in any calendar month.**
|
|
29
|
+
|
|
30
|
+
The threshold applies independently to each Model. Two Models at 50,000 MAU each do not combine into 100,000 MAU; each is independently within its own free-tier limit.
|
|
31
|
+
|
|
32
|
+
If a repository contains only software (no trained Model weights), no MAU threshold applies to that software on its own. The threshold attaches to the Models the software is used with.
|
|
33
|
+
|
|
34
|
+
## 3. Research and academic use
|
|
35
|
+
|
|
36
|
+
Use of the Licensed Materials for non-commercial scientific research and academic publications is exempt from the MAU threshold in Section 2, provided that any resulting publication credits "Desert Ant Labs" and links to the relevant Model repository.
|
|
37
|
+
|
|
38
|
+
## 4. Commercial license
|
|
39
|
+
|
|
40
|
+
If Your aggregate MAU for any Model exceeds 100,000 (or You expect it to within the next calendar month), You must obtain a commercial license from Desert Ant Labs before continuing to distribute or operate any product that incorporates that Model. A commercial license covers only the Models named in it; other Models remain under the free tier subject to their own thresholds.
|
|
41
|
+
|
|
42
|
+
Contact: <licensing@desertant.ai>.
|
|
43
|
+
|
|
44
|
+
## 5. Patent grant
|
|
45
|
+
|
|
46
|
+
Each contributor to the Licensed Materials grants You a perpetual, worldwide, non-exclusive, royalty-free, irrevocable (except as stated in this Section) patent license to make, use, sell, offer to sell, and import the Licensed Materials, where such license applies only to those patent claims licensable by that contributor that are necessarily infringed by the Licensed Materials.
|
|
47
|
+
|
|
48
|
+
**If You institute patent litigation against any entity** (including a cross-claim or counterclaim in a lawsuit) alleging that the Licensed Materials infringe a patent, **all patent licenses granted to You under this license terminate as of the date such litigation is filed.**
|
|
49
|
+
|
|
50
|
+
## 6. Restrictions
|
|
51
|
+
|
|
52
|
+
You may not:
|
|
53
|
+
|
|
54
|
+
1. Sell, sublicense, or otherwise distribute the Licensed Materials themselves, or any substantially unmodified derivative of them, as a standalone product or hosted service.
|
|
55
|
+
2. Use the Licensed Materials to train, distill, fine-tune, or otherwise derive a model that You release or distribute under any license more permissive than this license, including any OSI-approved open-source license. Internal research, personal fine-tuning, and use of derivative models that remain under this license are not restricted.
|
|
56
|
+
3. Remove or alter the copyright, license, attribution, or third-party notices in the Licensed Materials.
|
|
57
|
+
|
|
58
|
+
You may freely embed the Licensed Materials in Your own product, subject to Section 2 and the rest of this license.
|
|
59
|
+
|
|
60
|
+
## 7. Attribution
|
|
61
|
+
|
|
62
|
+
You must retain this LICENSE file and the copyright notice in all copies and substantial portions of the Licensed Materials. Where Your product surfaces acknowledgements, third-party notices, or "About" / "Credits" screens, please credit **"Desert Ant Labs (`desertant.ai`)"**.
|
|
63
|
+
|
|
64
|
+
## 8. Modifications
|
|
65
|
+
|
|
66
|
+
You may modify the Licensed Materials. If You distribute modified Licensed Materials, You must:
|
|
67
|
+
|
|
68
|
+
(a) include a prominent notice stating that You have modified them, with the date of modification; and
|
|
69
|
+
(b) ensure that Your distributed modifications are licensed under this license.
|
|
70
|
+
|
|
71
|
+
This license governs the Licensed Materials and modifications to them. Applications and products that merely incorporate, link to, or call the Licensed Materials are Your own work; their structure, source, and license are not constrained by this license, subject only to Sections 2, 6, and 7.
|
|
72
|
+
|
|
73
|
+
## 9. Reporting
|
|
74
|
+
|
|
75
|
+
To enable Desert Ant Labs to administer the free tier, You agree:
|
|
76
|
+
|
|
77
|
+
(a) to maintain reasonable records of Your aggregate MAU per Model; and
|
|
78
|
+
(b) upon written request from Desert Ant Labs, to provide a reasonable summary of those records sufficient to confirm compliance with Section 2. Such requests will be made no more than once per calendar year per licensee, except in the case of a reasonable, specific suspicion of breach.
|
|
79
|
+
|
|
80
|
+
You are encouraged — but not required — to notify Desert Ant Labs at <licensing@desertant.ai> when Your aggregate MAU for any Model first exceeds 80,000.
|
|
81
|
+
|
|
82
|
+
## 10. Trademarks
|
|
83
|
+
|
|
84
|
+
This license does not grant You any right to use the trade names, trademarks, service marks, or product names of Desert Ant Labs, except for the limited attribution use specified in Section 7. All goodwill arising from such attribution use inures to the benefit of Desert Ant Labs.
|
|
85
|
+
|
|
86
|
+
## 11. Third-party components
|
|
87
|
+
|
|
88
|
+
The Licensed Materials may include or derive from components licensed by third parties. Those components remain subject to their own licenses; nothing in this license overrides those terms. Notices for such components are provided in the model card or in a `THIRD_PARTY_NOTICES.md` file alongside the Licensed Materials.
|
|
89
|
+
|
|
90
|
+
## 12. Termination
|
|
91
|
+
|
|
92
|
+
This license terminates automatically and immediately upon any of the following:
|
|
93
|
+
|
|
94
|
+
(a) Your aggregate MAU for any Model exceeds 100,000 and You do not obtain a commercial license within thirty (30) days;
|
|
95
|
+
(b) Your breach of Section 6 (Restrictions); or
|
|
96
|
+
(c) Your institution of patent litigation as described in Section 5.
|
|
97
|
+
|
|
98
|
+
For any other curable breach, Desert Ant Labs will provide written notice; if the breach is not cured within thirty (30) days of receipt of that notice, this license terminates as of the date the notice was sent.
|
|
99
|
+
|
|
100
|
+
Upon termination, You must cease using and distributing the Licensed Materials. Sections 7 (Attribution, with respect to copies already in the field), 10 (Trademarks), 11 (Third-Party Components), 13 (No Warranty), 14 (Limitation of Liability), and 15 (Governing Law) survive termination.
|
|
101
|
+
|
|
102
|
+
## 13. No warranty
|
|
103
|
+
|
|
104
|
+
THE LICENSED MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. Desert Ant Labs makes no representation that the Licensed Materials are error-free, secure, or suitable for any particular use.
|
|
105
|
+
|
|
106
|
+
## 14. Limitation of liability
|
|
107
|
+
|
|
108
|
+
IN NO EVENT SHALL DESERT ANT LABS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR EXEMPLARY DAMAGES (INCLUDING LOST PROFITS, LOSS OF DATA, OR BUSINESS INTERRUPTION) ARISING FROM OR IN CONNECTION WITH THE LICENSED MATERIALS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
109
|
+
|
|
110
|
+
DESERT ANT LABS' TOTAL CUMULATIVE LIABILITY UNDER OR IN CONNECTION WITH THIS LICENSE SHALL NOT EXCEED THE GREATER OF (A) ONE HUNDRED EUROS (€100) OR (B) THE TOTAL FEES PAID BY YOU TO DESERT ANT LABS UNDER A SEPARATE COMMERCIAL LICENSE IN THE TWELVE (12) MONTHS PRECEDING THE CLAIM.
|
|
111
|
+
|
|
112
|
+
Nothing in this license limits or excludes liability to the extent such limitation or exclusion is not permitted by applicable mandatory law, including liability for willful misconduct (*opzet*) or gross negligence (*bewuste roekeloosheid*) and any mandatory provision of Dutch consumer-protection law.
|
|
113
|
+
|
|
114
|
+
## 15. Governing law and jurisdiction
|
|
115
|
+
|
|
116
|
+
This license is governed by the laws of the Netherlands, without regard to its conflict-of-laws provisions. The competent courts of Amsterdam, the Netherlands, have exclusive jurisdiction over any dispute arising under or in connection with this license, subject to mandatory provisions of applicable consumer-protection law.
|
|
117
|
+
|
|
118
|
+
The United Nations Convention on Contracts for the International Sale of Goods (CISG, 1980) does not apply to this license.
|
|
119
|
+
|
|
120
|
+
## 16. Miscellaneous
|
|
121
|
+
|
|
122
|
+
(a) **Severability.** If any provision of this license is held unenforceable by a court of competent jurisdiction, the remaining provisions remain in full force and effect, and the unenforceable provision shall be interpreted to give effect to its intent to the greatest extent permitted by law.
|
|
123
|
+
|
|
124
|
+
(b) **No waiver.** Failure or delay by Desert Ant Labs to enforce any right under this license is not a waiver of that right.
|
|
125
|
+
|
|
126
|
+
(c) **Assignment.** You may not assign this license without Desert Ant Labs' prior written consent. Desert Ant Labs may freely assign this license to a successor in interest. This license binds and benefits each party's successors and permitted assigns.
|
|
127
|
+
|
|
128
|
+
(d) **Entire agreement.** This license, together with any separate commercial license referenced in Section 4, is the entire agreement between You and Desert Ant Labs regarding the Licensed Materials and supersedes all prior agreements on the same subject matter.
|
|
129
|
+
|
|
130
|
+
(e) **Language.** The authoritative version of this license is in English. Any translation is for convenience only; in the event of any conflict, the English version controls.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
Commercial licensing inquiries: <licensing@desertant.ai>.
|
|
135
|
+
|
|
136
|
+
© 2026 Studio Company B.V., trading as Desert Ant Labs. Statutory seat: Amsterdam, the Netherlands. KvK: **81228112**.
|
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# @desert-ant-labs/redact
|
|
2
|
+
|
|
3
|
+
On-device multilingual PII redaction for JavaScript and TypeScript. Detects and
|
|
4
|
+
masks personal data (names, addresses, emails, phone numbers, cards, IBANs,
|
|
5
|
+
national IDs, VAT numbers and more) in text across **all 24 official EU
|
|
6
|
+
languages** (Latin, Greek and Cyrillic scripts). Runs in Node and the browser via
|
|
7
|
+
[transformers.js](https://github.com/huggingface/transformers.js); the text never
|
|
8
|
+
leaves the device.
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
import { Redact } from "@desert-ant-labs/redact";
|
|
12
|
+
|
|
13
|
+
const redact = await Redact.load();
|
|
14
|
+
const r = await redact.redaction("Email Anna Kovács at anna@example.hu.");
|
|
15
|
+
|
|
16
|
+
r.redactedText; // "Email [GIVEN_NAME_1] [SURNAME_1] at [EMAIL_1]."
|
|
17
|
+
r.items[0].original; // "Anna"
|
|
18
|
+
r.restore(r.redactedText); // back to the original
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
A tiny 6-layer BIOES token classifier handles contextual PII (names, streets,
|
|
22
|
+
messy natural-language data) while a dependency-free deterministic layer owns the
|
|
23
|
+
structured fields with real validation (Luhn cards, ISO-13616 IBANs, checksum-
|
|
24
|
+
validated national IDs for all 24 EU countries, all 27 EU VAT numbers, IMEI, and
|
|
25
|
+
per-country driving licences). It mirrors the Python training pipeline and the
|
|
26
|
+
Swift SDK span-for-span.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm install @desert-ant-labs/redact
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The model (int8 ONNX, ~23 MB) and tokenizer are fetched from the
|
|
35
|
+
[`desert-ant-labs/redact`](https://huggingface.co/desert-ant-labs/redact) Hugging
|
|
36
|
+
Face repo on first load and cached locally (on disk in Node, in Cache Storage in
|
|
37
|
+
the browser).
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Create one `Redact` and reuse it. The model loads lazily on first call.
|
|
42
|
+
|
|
43
|
+
### Redact and restore (LLM round-trip)
|
|
44
|
+
|
|
45
|
+
Mask PII to unique placeholders, hand the placeholdered text to an LLM or any
|
|
46
|
+
external service, then fill the originals back in on-device. The sensitive values
|
|
47
|
+
never leave the machine.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
const r = await redact.redaction(userText);
|
|
51
|
+
// r.redactedText: "Email [EMAIL_1] and [EMAIL_2] about [BANK_ACCOUNT_1]."
|
|
52
|
+
|
|
53
|
+
const reply = await myLLM.rewrite(r.redactedText); // sees only placeholders
|
|
54
|
+
const final = r.restore(reply); // originals filled back in
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Placeholders are numbered per category (`[EMAIL_1]`, `[EMAIL_2]`, ...), so two
|
|
58
|
+
emails never collapse into one and restoration is order-independent. Instruct
|
|
59
|
+
your LLM to keep the `[LABEL_N]` tokens verbatim.
|
|
60
|
+
|
|
61
|
+
### Inspect detections
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const r = await redact.redaction(text);
|
|
65
|
+
for (const item of r.items) {
|
|
66
|
+
console.log(item.label, item.original, item.confidence, item.start, item.end);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Filter by category
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
const r = await redact.redaction(text, { labels: ["EMAIL", "PHONE", "CREDIT_CARD"] });
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Just the spans
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
const spans = await redact.detect(text); // [{ start, end, label }]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Module-level convenience
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
import { redaction, detect, env } from "@desert-ant-labs/redact";
|
|
86
|
+
|
|
87
|
+
env.revision = "v0.2.0"; // pin a model revision (optional)
|
|
88
|
+
const r = await redaction("Call +49 30 1234567"); // model loaded + cached lazily
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## API
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
class Redact {
|
|
95
|
+
static load(options?: LoadOptions): Promise<Redact>;
|
|
96
|
+
redaction(text: string, options?: Options): Promise<Redaction>;
|
|
97
|
+
detect(text: string, options?: Options): Promise<Span[]>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
interface Options {
|
|
101
|
+
minimumConfidence?: number; // neural threshold, default 0.6
|
|
102
|
+
labels?: Iterable<string>; // restrict categories; omit for all
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface Redaction {
|
|
106
|
+
redactedText: string; // "[LABEL_N]" placeholders
|
|
107
|
+
items: RedactionItem[]; // { label, original, placeholder, confidence, start, end }
|
|
108
|
+
restore(processed: string): string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface LoadOptions {
|
|
112
|
+
repo?: string; // default "desert-ant-labs/redact"
|
|
113
|
+
revision?: string; // default "v0.2.0"
|
|
114
|
+
localPath?: string; // load from a local dir instead of the Hub
|
|
115
|
+
useCache?: boolean; // default true
|
|
116
|
+
cacheDir?: string; // on-disk cache dir (Node)
|
|
117
|
+
dtype?: string; // transformers.js weight dtype, default "fp32"
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Categories
|
|
122
|
+
|
|
123
|
+
`GIVEN_NAME`, `SURNAME`, `STREET_NAME`, `BUILDING_NUMBER`, `SECONDARY_ADDRESS`,
|
|
124
|
+
`CITY`, `STATE`, `ZIP_CODE`, `EMAIL`, `PHONE`, `CREDIT_CARD`, `BANK_ACCOUNT`,
|
|
125
|
+
`ROUTING_NUMBER`, `IP_ADDRESS`, `URL`, `GOVERNMENT_ID`, `PASSPORT`,
|
|
126
|
+
`DRIVERS_LICENSE`, `TAX_ID`, `SSN`, and `IMEI` (deterministic-only).
|
|
127
|
+
|
|
128
|
+
## Example
|
|
129
|
+
|
|
130
|
+
A tiny browser demo is in [`Examples/RedactExample`](./Examples/RedactExample):
|
|
131
|
+
`cd Examples/RedactExample && node server.js`, then open the printed URL and type
|
|
132
|
+
some text.
|
|
133
|
+
|
|
134
|
+
## Other platforms
|
|
135
|
+
|
|
136
|
+
- **Swift (iOS/macOS/tvOS/visionOS):** [`redact-swift`](https://github.com/Desert-Ant-Labs/redact-swift)
|
|
137
|
+
- **Model + weights + card:** [`desert-ant-labs/redact`](https://huggingface.co/desert-ant-labs/redact)
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
[Desert Ant Labs Source-Available License](https://license.desertant.ai/1.0). Free
|
|
142
|
+
for most apps; a commercial license is required at scale. Full terms are in
|
|
143
|
+
[`LICENSE.md`](./LICENSE.md). Licensing: <licensing@desertant.ai>.
|