@lokal-id/core 0.2.2 → 0.4.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/README.md +61 -61
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/kembaran-data.d.ts +10 -0
- package/dist/kembaran-data.js +46 -0
- package/dist/kembaran-data.js.map +1 -0
- package/dist/kembaran.d.ts +46 -0
- package/dist/kembaran.js +426 -0
- package/dist/kembaran.js.map +1 -0
- package/dist/qris.d.ts +82 -0
- package/dist/qris.js +236 -0
- package/dist/qris.js.map +1 -0
- package/dist/samaran/detectors.js +96 -5
- package/dist/samaran/detectors.js.map +1 -1
- package/dist/samaran/fields.js +6 -4
- package/dist/samaran/fields.js.map +1 -1
- package/dist/samaran/index.d.ts +2 -0
- package/dist/samaran/index.js +1 -1
- package/dist/samaran/index.js.map +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
# @lokal-id/core
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@lokal-id/core)
|
|
4
|
-
[](https://github.com/lokal-id/lokal/blob/HEAD/LICENSE)
|
|
5
|
-
|
|
6
|
-
Indonesian data primitives for apps and AI agents: NIK, NPWP, phone numbers, Rupiah, *terbilang*, holidays and working days, Kemendagri regions with postal codes, and **Samaran**, which masks Indonesian personal data before it reaches an LLM and restores it afterwards.
|
|
7
|
-
|
|
8
|
-
No dependencies. Part of [Lokal](https://github.com/lokal-id/lokal) · [Bahasa Indonesia](https://github.com/lokal-id/lokal/blob/HEAD/README.id.md)
|
|
9
|
-
|
|
10
|
-
## Install
|
|
11
|
-
|
|
12
|
-
```sh
|
|
13
|
-
npm install @lokal-id/core
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
For Python backends there is a port with identical results: `pip install lokal-id` ([docs](https://github.com/lokal-id/lokal/tree/HEAD/python#readme)).
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
import { parseNik, parsePhone, formatRupiah, parseRupiah, terbilang, addWorkingDays, Samaran } from '@lokal-id/core';
|
|
22
|
-
import { listWilayah, searchWilayah, wilayahName, findByPostalCode } from '@lokal-id/core/wilayah';
|
|
23
|
-
|
|
24
|
-
parseNik('3201011508950001', { lookupWilayah: wilayahName });
|
|
25
|
-
// { valid: true, province: 'Jawa Barat', regency: 'Kabupaten Bogor', gender: 'L', birthDate: '1995-08-15', … }
|
|
26
|
-
parsePhone('0812 3456 7890'); // { e164: '+6281234567890', operator: 'Telkomsel', … }
|
|
27
|
-
formatRupiah(1500000); // 'Rp1.500.000'
|
|
28
|
-
parseRupiah('sejuta setengah'); // { amount: 1500000, approximate: false }
|
|
29
|
-
terbilang(1500000, { currency: true }); // 'satu juta lima ratus ribu rupiah'
|
|
30
|
-
addWorkingDays('2026-03-17', 1); // '2026-03-25', skipping Nyepi and Lebaran
|
|
31
|
-
listWilayah('32.76'); // districts of Kota Depok
|
|
32
|
-
findByPostalCode('16431'); // villages that use this postal code
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Samaran
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
const samaran = new Samaran();
|
|
39
|
-
const { text } = samaran.mask('nama saya budi santoso, NIK 3201011508950001, HP 0812-3456-7890');
|
|
40
|
-
// 'nama saya [NAME_1], NIK [NIK_1], HP [PHONE_1]'
|
|
41
|
-
|
|
42
|
-
samaran.unmask(await llm(text)); // placeholders are replaced with the original values
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
The same value always gets the same placeholder, so the model can still deduplicate and join. Use `mode: 'partial'` for logs and admin screens (`3201********0001`).
|
|
46
|
-
|
|
47
|
-
`@lokal-id/core/wilayah` loads about 4.4 MB of region data and runs on Node only. The main entry point does not load it and is safe for browsers.
|
|
48
|
-
|
|
49
|
-
## Data
|
|
50
|
-
|
|
51
|
-
| Data | Source |
|
|
52
|
-
|---|---|
|
|
53
|
-
| Regions: 38 provinces, 416 regencies, 98 cities, 7,285 districts, 8,496 *kelurahan*, 75,266 villages | [cahyadsn/wilayah](https://github.com/cahyadsn/wilayah) (MIT), following Kepmendagri 300.2.2-2138/2025 |
|
|
54
|
-
| Postal codes for all 83,762 villages | [cahyadsn/wilayah_kodepos](https://github.com/cahyadsn/wilayah_kodepos) (MIT) |
|
|
55
|
-
| Holidays and *cuti bersama* for 2026 and 2027 | SKB 3 Menteri. Other years return an error, not a guess |
|
|
56
|
-
|
|
57
|
-
Detection limits and full documentation are in the [Lokal README](https://github.com/lokal-id/lokal#limitations).
|
|
58
|
-
|
|
59
|
-
## License
|
|
60
|
-
|
|
61
|
-
[MIT](https://github.com/lokal-id/lokal/blob/HEAD/LICENSE)
|
|
1
|
+
# @lokal-id/core
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@lokal-id/core)
|
|
4
|
+
[](https://github.com/lokal-id/lokal/blob/HEAD/LICENSE)
|
|
5
|
+
|
|
6
|
+
Indonesian data primitives for apps and AI agents: NIK, NPWP, phone numbers, Rupiah, *terbilang*, holidays and working days, Kemendagri regions with postal codes, and **Samaran**, which masks Indonesian personal data before it reaches an LLM and restores it afterwards.
|
|
7
|
+
|
|
8
|
+
No dependencies. Part of [Lokal](https://github.com/lokal-id/lokal) · [Bahasa Indonesia](https://github.com/lokal-id/lokal/blob/HEAD/README.id.md)
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @lokal-id/core
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
For Python backends there is a port with identical results: `pip install lokal-id` ([docs](https://github.com/lokal-id/lokal/tree/HEAD/python#readme)).
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { parseNik, parsePhone, formatRupiah, parseRupiah, terbilang, addWorkingDays, Samaran } from '@lokal-id/core';
|
|
22
|
+
import { listWilayah, searchWilayah, wilayahName, findByPostalCode } from '@lokal-id/core/wilayah';
|
|
23
|
+
|
|
24
|
+
parseNik('3201011508950001', { lookupWilayah: wilayahName });
|
|
25
|
+
// { valid: true, province: 'Jawa Barat', regency: 'Kabupaten Bogor', gender: 'L', birthDate: '1995-08-15', … }
|
|
26
|
+
parsePhone('0812 3456 7890'); // { e164: '+6281234567890', operator: 'Telkomsel', … }
|
|
27
|
+
formatRupiah(1500000); // 'Rp1.500.000'
|
|
28
|
+
parseRupiah('sejuta setengah'); // { amount: 1500000, approximate: false }
|
|
29
|
+
terbilang(1500000, { currency: true }); // 'satu juta lima ratus ribu rupiah'
|
|
30
|
+
addWorkingDays('2026-03-17', 1); // '2026-03-25', skipping Nyepi and Lebaran
|
|
31
|
+
listWilayah('32.76'); // districts of Kota Depok
|
|
32
|
+
findByPostalCode('16431'); // villages that use this postal code
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Samaran
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const samaran = new Samaran();
|
|
39
|
+
const { text } = samaran.mask('nama saya budi santoso, NIK 3201011508950001, HP 0812-3456-7890');
|
|
40
|
+
// 'nama saya [NAME_1], NIK [NIK_1], HP [PHONE_1]'
|
|
41
|
+
|
|
42
|
+
samaran.unmask(await llm(text)); // placeholders are replaced with the original values
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The same value always gets the same placeholder, so the model can still deduplicate and join. Use `mode: 'partial'` for logs and admin screens (`3201********0001`).
|
|
46
|
+
|
|
47
|
+
`@lokal-id/core/wilayah` loads about 4.4 MB of region data and runs on Node only. The main entry point does not load it and is safe for browsers.
|
|
48
|
+
|
|
49
|
+
## Data
|
|
50
|
+
|
|
51
|
+
| Data | Source |
|
|
52
|
+
|---|---|
|
|
53
|
+
| Regions: 38 provinces, 416 regencies, 98 cities, 7,285 districts, 8,496 *kelurahan*, 75,266 villages | [cahyadsn/wilayah](https://github.com/cahyadsn/wilayah) (MIT), following Kepmendagri 300.2.2-2138/2025 |
|
|
54
|
+
| Postal codes for all 83,762 villages | [cahyadsn/wilayah_kodepos](https://github.com/cahyadsn/wilayah_kodepos) (MIT) |
|
|
55
|
+
| Holidays and *cuti bersama* for 2026 and 2027 | SKB 3 Menteri. Other years return an error, not a guess |
|
|
56
|
+
|
|
57
|
+
Detection limits and full documentation are in the [Lokal README](https://github.com/lokal-id/lokal#limitations).
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
[MIT](https://github.com/lokal-id/lokal/blob/HEAD/LICENSE)
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { parseNpwp, formatNpwp15, type NpwpInfo, type NpwpKind } from './npwp.ts
|
|
|
3
3
|
export { parsePhone, normalizePhone, type PhoneInfo, type PhoneType } from './phone.ts';
|
|
4
4
|
export { formatRupiah, formatRupiahShort, parseRupiah, type FormatRupiahOptions, type ParsedRupiah, } from './rupiah.ts';
|
|
5
5
|
export { terbilang, type TerbilangOptions } from './terbilang.ts';
|
|
6
|
+
export { parseQris, setQrisAmount, qrisCrc, type QrisInfo, type QrisField, type QrisMerchantAccount, type QrisTip, type QrisAdditionalData, type QrisAmountOptions, } from './qris.ts';
|
|
6
7
|
export { PROVINCES } from './provinces.ts';
|
|
7
8
|
export { getHolidays, holidaysOn, isWorkingDay, addWorkingDays, countWorkingDays, HOLIDAY_YEARS, type Holiday, type HolidayType, type HolidayYear, type WorkingDayOptions, } from './holidays.ts';
|
|
8
9
|
export { Samaran, maskPii, detectPii, partialMask, fieldType, PII_TYPES, UU_PDP_CATEGORY, type PiiType, type PiiMatch, type MaskedMatch, type MaskResult, type SamaranOptions, type DetectOptions, type Confidence, } from './samaran/index.ts';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { parseNpwp, formatNpwp15 } from './npwp.js';
|
|
|
3
3
|
export { parsePhone, normalizePhone } from './phone.js';
|
|
4
4
|
export { formatRupiah, formatRupiahShort, parseRupiah, } from './rupiah.js';
|
|
5
5
|
export { terbilang } from './terbilang.js';
|
|
6
|
+
export { parseQris, setQrisAmount, qrisCrc, } from './qris.js';
|
|
6
7
|
export { PROVINCES } from './provinces.js';
|
|
7
8
|
export { getHolidays, holidaysOn, isWorkingDay, addWorkingDays, countWorkingDays, HOLIDAY_YEARS, } from './holidays.js';
|
|
8
9
|
export { Samaran, maskPii, detectPii, partialMask, fieldType, PII_TYPES, UU_PDP_CATEGORY, } from './samaran/index.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAA+D,MAAM,UAAU,CAAC;AAC7G,OAAO,EAAE,SAAS,EAAE,YAAY,EAAgC,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAkC,MAAM,YAAY,CAAC;AACxF,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,WAAW,GAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,aAAa,GAKd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,OAAO,EACP,OAAO,EACP,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,eAAe,GAQhB,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAA+D,MAAM,UAAU,CAAC;AAC7G,OAAO,EAAE,SAAS,EAAE,YAAY,EAAgC,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAkC,MAAM,YAAY,CAAC;AACxF,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,WAAW,GAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EACL,SAAS,EACT,aAAa,EACb,OAAO,GAOR,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,aAAa,GAKd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,OAAO,EACP,OAAO,EACP,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,eAAe,GAQhB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const MALE_FIRST: readonly string[];
|
|
2
|
+
export declare const FEMALE_FIRST: readonly string[];
|
|
3
|
+
export declare const MALE_LAST: readonly string[];
|
|
4
|
+
export declare const FEMALE_LAST: readonly string[];
|
|
5
|
+
export declare const STREETS: readonly string[];
|
|
6
|
+
export declare const HEALTH: readonly string[];
|
|
7
|
+
export declare const RELIGIONS: readonly string[];
|
|
8
|
+
export declare const MARITAL: readonly string[];
|
|
9
|
+
/** Honorifics and connecting words in a name that say nothing about who the person is. */
|
|
10
|
+
export declare const NAME_KEEP: ReadonlySet<string>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Word lists for Kembaran's stand-in values: common Indonesian given names and family names from many regions,
|
|
2
|
+
// street names of the kind found in every town, and harmless health complaints. Combinations are random, so a
|
|
3
|
+
// stand-in that happens to match a real person's name is a coincidence, not a link to them.
|
|
4
|
+
// python/src/lokal/_kembaran_data.py holds the same lists, in the same order.
|
|
5
|
+
export const MALE_FIRST = [
|
|
6
|
+
'Agus', 'Ahmad', 'Andi', 'Anton', 'Arif', 'Asep', 'Bagus', 'Bambang', 'Bayu', 'Benny', 'Budi', 'Cecep', 'Dadang',
|
|
7
|
+
'Dani', 'Daniel', 'Dedi', 'Dimas', 'Doni', 'Edi', 'Eko', 'Fajar', 'Farhan', 'Fikri', 'Galih', 'Gede', 'Gilang',
|
|
8
|
+
'Hadi', 'Hari', 'Hendra', 'Heru', 'Ilham', 'Imam', 'Indra', 'Irfan', 'Ivan', 'Iwan', 'Joko', 'Ketut', 'Kevin',
|
|
9
|
+
'Komang', 'Krisna', 'Lukman', 'Made', 'Michael', 'Muhammad', 'Nyoman', 'Paulus', 'Putu', 'Rahmat', 'Rangga',
|
|
10
|
+
'Reza', 'Ridwan', 'Rizki', 'Rudi', 'Satria', 'Sigit', 'Slamet', 'Steven', 'Surya', 'Taufik', 'Teguh', 'Togar',
|
|
11
|
+
'Tono', 'Ujang', 'Wahyu', 'Wawan', 'Yoga', 'Yohanes', 'Yudi', 'Yusuf', 'Zainal',
|
|
12
|
+
];
|
|
13
|
+
export const FEMALE_FIRST = [
|
|
14
|
+
'Ana', 'Ani', 'Ayu', 'Butet', 'Citra', 'Desi', 'Dewi', 'Dian', 'Erna', 'Euis', 'Fitri', 'Fransiska', 'Grace',
|
|
15
|
+
'Hana', 'Iis', 'Indah', 'Intan', 'Irma', 'Jessica', 'Kartika', 'Lina', 'Lusi', 'Maya', 'Mega', 'Nadia', 'Neng',
|
|
16
|
+
'Nina', 'Novi', 'Nur', 'Nurul', 'Putri', 'Rahma', 'Ratna', 'Rina', 'Rini', 'Rosa', 'Santi', 'Sari', 'Siti', 'Sri',
|
|
17
|
+
'Susi', 'Tari', 'Tuti', 'Vina', 'Widya', 'Wulan', 'Yanti', 'Yohana', 'Yuni',
|
|
18
|
+
];
|
|
19
|
+
export const MALE_LAST = [
|
|
20
|
+
'Damanik', 'Daulay', 'Effendi', 'Firmansyah', 'Ginting', 'Gunawan', 'Hakim', 'Halim', 'Harahap', 'Hartono',
|
|
21
|
+
'Haryanto', 'Hermawan', 'Hidayat', 'Hutapea', 'Kurniawan', 'Lubis', 'Manurung', 'Matondang', 'Maulana', 'Nasution',
|
|
22
|
+
'Nugroho', 'Panjaitan', 'Pane', 'Pratama', 'Prasetyo', 'Purba', 'Purnomo', 'Rahman', 'Ramadhan', 'Rangkuti',
|
|
23
|
+
'Santoso', 'Saputra', 'Sembiring', 'Setiawan', 'Simanjuntak', 'Sinaga', 'Siregar', 'Sitepu', 'Sugiarto', 'Suryadi',
|
|
24
|
+
'Susanto', 'Sutrisno', 'Syahputra', 'Tambunan', 'Tanjung', 'Tarigan', 'Utomo', 'Wahyudi', 'Wibowo', 'Wijaya',
|
|
25
|
+
];
|
|
26
|
+
export const FEMALE_LAST = [
|
|
27
|
+
'Andriani', 'Anggraini', 'Astuti', 'Damayanti', 'Fitriani', 'Ginting', 'Halim', 'Handayani', 'Hapsari', 'Harahap',
|
|
28
|
+
'Kartini', 'Kusumawati', 'Lestari', 'Lubis', 'Maharani', 'Nasution', 'Ningsih', 'Novitasari', 'Oktaviani',
|
|
29
|
+
'Permata', 'Pertiwi', 'Puspita', 'Purnamasari', 'Rahayu', 'Rahmawati', 'Safitri', 'Sari', 'Sinaga', 'Siregar',
|
|
30
|
+
'Susanti', 'Suryani', 'Tanjung', 'Tarigan', 'Utami', 'Wahyuni', 'Wijaya', 'Wulandari', 'Yuliani',
|
|
31
|
+
];
|
|
32
|
+
export const STREETS = [
|
|
33
|
+
'Akasia', 'Anggrek', 'Bahagia', 'Bakti', 'Beringin', 'Cemara', 'Cempaka', 'Cendrawasih', 'Dahlia', 'Damai', 'Durian',
|
|
34
|
+
'Elang', 'Flamboyan', 'Harapan', 'Jati', 'Karya', 'Kelapa', 'Kemuning', 'Kenanga', 'Kutilang', 'Mahoni', 'Mangga',
|
|
35
|
+
'Melati', 'Merdeka', 'Merpati', 'Nusa Indah', 'Pahlawan', 'Pelita', 'Pemuda', 'Rajawali', 'Rambutan', 'Sejahtera',
|
|
36
|
+
'Seroja', 'Swadaya', 'Teratai',
|
|
37
|
+
];
|
|
38
|
+
export const HEALTH = ['Sehat', 'Flu', 'Demam', 'Batuk', 'Sakit kepala', 'Alergi ringan', 'Maag', 'Pegal linu'];
|
|
39
|
+
export const RELIGIONS = ['Islam', 'Kristen', 'Katolik', 'Hindu', 'Buddha', 'Konghucu'];
|
|
40
|
+
export const MARITAL = ['Belum Kawin', 'Kawin', 'Cerai Hidup', 'Cerai Mati'];
|
|
41
|
+
/** Honorifics and connecting words in a name that say nothing about who the person is. */
|
|
42
|
+
export const NAME_KEEP = new Set([
|
|
43
|
+
'bapak', 'bpk', 'ibu', 'bu', 'pak', 'sdr', 'sdri', 'tn', 'ny', 'nn', 'kak', 'mas', 'mbak', 'bin', 'binti', 'dr', 'drs',
|
|
44
|
+
'dra', 'ir', 'h', 'hj', 'prof', 'st', 'se', 'sh', 'mm', 'skom', 'spd', 'amd',
|
|
45
|
+
]);
|
|
46
|
+
//# sourceMappingURL=kembaran-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kembaran-data.js","sourceRoot":"","sources":["../src/kembaran-data.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,8GAA8G;AAC9G,4FAA4F;AAC5F,8EAA8E;AAE9E,MAAM,CAAC,MAAM,UAAU,GAAsB;IAC3C,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;IAChH,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ;IAC9G,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OA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EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ;IACjH,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW;IACjH,QAAQ,EAAE,SAAS,EAAE,SAAS;CAC/B,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AAEnI,MAAM,CAAC,MAAM,SAAS,GAAsB,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAC3G,MAAM,CAAC,MAAM,OAAO,GAAsB,CAAC,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AAEhG,0FAA0F;AAC1F,MAAM,CAAC,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC;IACpD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK;IACtH,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAC7E,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Confidence, type PiiType } from './samaran/index.ts';
|
|
2
|
+
export interface KembaranOptions {
|
|
3
|
+
/** The same secret gives the same stand-ins on every run. Without one, each run picks a random secret. */
|
|
4
|
+
secret?: string;
|
|
5
|
+
/** Types left as they are. Default: gender, religion, marital status, and nationality, which identify no one. */
|
|
6
|
+
keep?: readonly PiiType[];
|
|
7
|
+
/** Keep the whole birth date, not just the year: more useful for debugging, easier to single someone out. */
|
|
8
|
+
keepBirthDate?: boolean;
|
|
9
|
+
/** "high" replaces only validated or labeled matches. Default "medium". */
|
|
10
|
+
minConfidence?: Confidence;
|
|
11
|
+
}
|
|
12
|
+
export interface KembaranResult {
|
|
13
|
+
text: string;
|
|
14
|
+
/** How many values of each type were replaced. */
|
|
15
|
+
replaced: Partial<Record<PiiType, number>>;
|
|
16
|
+
}
|
|
17
|
+
export declare const KEEP_BY_DEFAULT: readonly PiiType[];
|
|
18
|
+
interface Day {
|
|
19
|
+
day: number;
|
|
20
|
+
month: number;
|
|
21
|
+
}
|
|
22
|
+
export declare class Kembaran {
|
|
23
|
+
private readonly key;
|
|
24
|
+
private readonly keep;
|
|
25
|
+
private readonly keepBirthDate;
|
|
26
|
+
private readonly minConfidence;
|
|
27
|
+
private readonly fakes;
|
|
28
|
+
private readonly used;
|
|
29
|
+
private readonly nikDays;
|
|
30
|
+
constructor(options?: KembaranOptions);
|
|
31
|
+
/** Replaces every piece of personal data in a text: a CSV, an SQL dump, JSON, a log, or prose. */
|
|
32
|
+
text(input: string): KembaranResult;
|
|
33
|
+
/** The stand-in for one value of a known type. */
|
|
34
|
+
value(type: PiiType, original: string, rowDay?: Day): string;
|
|
35
|
+
/** The words of a name that identify the person: not honorifics, titles, or "bin". */
|
|
36
|
+
private nameCore;
|
|
37
|
+
/** A stand-in in canonical form: digits for numbers, words joined by spaces for names. */
|
|
38
|
+
private make;
|
|
39
|
+
/** A stand-in in the original's format: its separators, its casing, its titles. */
|
|
40
|
+
private render;
|
|
41
|
+
private address;
|
|
42
|
+
private birthDate;
|
|
43
|
+
}
|
|
44
|
+
/** One-shot: replaces personal data in a text with stand-ins under a random secret. */
|
|
45
|
+
export declare function kembaran(text: string, options?: KembaranOptions): KembaranResult;
|
|
46
|
+
export {};
|