@anonymask/core 0.1.0 → 0.3.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.
Files changed (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -28
  3. package/index.d.ts +0 -21
  4. package/index.js +154 -141
  5. package/package.json +54 -37
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 N-API for Rust
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,48 +1,87 @@
1
- # Anonymask Node.js Package
1
+ # `@napi-rs/package-template`
2
2
 
3
- This package provides Node.js bindings for the Anonymask core library, enabling secure anonymization and de-anonymization of PII data.
3
+ ![https://github.com/napi-rs/package-template/actions](https://github.com/napi-rs/package-template/workflows/CI/badge.svg)
4
4
 
5
- ## Installation
5
+ > Template project for writing node packages with napi-rs.
6
6
 
7
- ```bash
8
- npm install @anonymask/node
9
- ```
7
+ # Usage
10
8
 
11
- ## Building from Source
9
+ 1. Click **Use this template**.
10
+ 2. **Clone** your project.
11
+ 3. Run `yarn install` to install dependencies.
12
+ 4. Run `yarn napi rename -n [@your-scope/package-name] -b [binary-name]` command under the project folder to rename your package.
12
13
 
13
- 1. Ensure you have Rust and Node.js installed.
14
- 2. Clone the repository and navigate to the `anonymask-node` directory.
15
- 3. Install dependencies:
14
+ ## Install this test package
16
15
 
17
16
  ```bash
18
- npm install
17
+ yarn add @napi-rs/package-template
19
18
  ```
20
19
 
21
- 4. Build the package:
20
+ ## Ability
21
+
22
+ ### Build
23
+
24
+ After `yarn build/npm run build` command, you can see `package-template.[darwin|win32|linux].node` file in project root. This is the native addon built from [lib.rs](./src/lib.rs).
25
+
26
+ ### Test
27
+
28
+ With [ava](https://github.com/avajs/ava), run `yarn test/npm run test` to testing native addon. You can also switch to another testing framework if you want.
29
+
30
+ ### CI
31
+
32
+ With GitHub Actions, each commit and pull request will be built and tested automatically in [`node@20`, `@node22`] x [`macOS`, `Linux`, `Windows`] matrix. You will never be afraid of the native addon broken in these platforms.
33
+
34
+ ### Release
35
+
36
+ Release native package is very difficult in old days. Native packages may ask developers who use it to install `build toolchain` like `gcc/llvm`, `node-gyp` or something more.
37
+
38
+ With `GitHub actions`, we can easily prebuild a `binary` for major platforms. And with `N-API`, we should never be afraid of **ABI Compatible**.
39
+
40
+ The other problem is how to deliver prebuild `binary` to users. Downloading it in `postinstall` script is a common way that most packages do it right now. The problem with this solution is it introduced many other packages to download binary that has not been used by `runtime codes`. The other problem is some users may not easily download the binary from `GitHub/CDN` if they are behind a private network (But in most cases, they have a private NPM mirror).
41
+
42
+ In this package, we choose a better way to solve this problem. We release different `npm packages` for different platforms. And add it to `optionalDependencies` before releasing the `Major` package to npm.
43
+
44
+ `NPM` will choose which native package should download from `registry` automatically. You can see [npm](./npm) dir for details. And you can also run `yarn add @napi-rs/package-template` to see how it works.
45
+
46
+ ## Develop requirements
47
+
48
+ - Install the latest `Rust`
49
+ - Install `Node.js@10+` which fully supported `Node-API`
50
+ - Install `yarn@1.x`
51
+
52
+ ## Test in local
53
+
54
+ - yarn
55
+ - yarn build
56
+ - yarn test
57
+
58
+ And you will see:
22
59
 
23
60
  ```bash
24
- npm run build
61
+ $ ava --verbose
62
+
63
+ ✔ sync function from native code
64
+ ✔ sleep function from native code (201ms)
65
+
66
+
67
+ 2 tests passed
68
+ ✨ Done in 1.12s.
25
69
  ```
26
70
 
27
- This will compile the Rust code and generate the native Node.js module.
71
+ ## Release package
28
72
 
29
- ## Usage
73
+ Ensure you have set your **NPM_TOKEN** in the `GitHub` project setting.
30
74
 
31
- ```javascript
32
- const { Anonymizer } = require('@anonymask/node');
75
+ In `Settings -> Secrets`, add **NPM_TOKEN** into it.
33
76
 
34
- const anonymizer = new Anonymizer(['email', 'phone']);
35
- const result = anonymizer.anonymize('Contact john@email.com or call 555-123-4567');
77
+ When you want to release the package:
36
78
 
37
- console.log(result.anonymized_text); // "Contact EMAIL_xxx or call PHONE_xxx"
38
- console.log(result.mapping); // { "EMAIL_xxx": "john@email.com", "PHONE_xxx": "555-123-4567" }
39
- ```
79
+ ```bash
80
+ npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]
40
81
 
41
- ## Publishing to npm
82
+ git push
83
+ ```
42
84
 
43
- 1. Ensure you have an npm account and are logged in (`npm login`).
44
- 2. Update the version in `package.json`.
45
- 3. Build the package: `npm run build`.
46
- 4. Publish: `npm publish`.
85
+ GitHub actions will do the rest job for you.
47
86
 
48
- Note: The package will automatically build before publishing due to the `prepublishOnly` script.
87
+ > WARN: Don't run `npm publish` manually.
package/index.d.ts CHANGED
@@ -1,21 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- /* auto-generated by NAPI-RS */
5
-
6
- export interface Entity {
7
- entityType: string
8
- value: string
9
- start: number
10
- end: number
11
- }
12
- export interface AnonymizationResult {
13
- anonymizedText: string
14
- mapping: Record<string, string>
15
- entities: Array<Entity>
16
- }
17
- export declare class Anonymizer {
18
- constructor(entityTypes: Array<string>)
19
- anonymize(text: string): AnonymizationResult
20
- deanonymize(text: string, mapping: Record<string, string>): string
21
- }
package/index.js CHANGED
@@ -5,311 +5,324 @@
5
5
  /* auto-generated by NAPI-RS */
6
6
 
7
7
  const { existsSync, readFileSync } = require('fs')
8
- const { join } = require('path')
8
+ const { join } = require("path");
9
9
 
10
- const { platform, arch } = process
10
+ const { platform, arch } = process;
11
11
 
12
- let nativeBinding = null
13
- let localFileExisted = false
14
- let loadError = null
12
+ let nativeBinding = null;
13
+ let localFileExisted = false;
14
+ let loadError = null;
15
15
 
16
16
  function isMusl() {
17
17
  // For Node 10
18
- if (!process.report || typeof process.report.getReport !== 'function') {
18
+ if (!process.report || typeof process.report.getReport !== "function") {
19
19
  try {
20
- const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
- return readFileSync(lddPath, 'utf8').includes('musl')
20
+ const lddPath = require("child_process")
21
+ .execSync("which ldd")
22
+ .toString()
23
+ .trim();
24
+ return readFileSync(lddPath, "utf8").includes("musl");
22
25
  } catch (e) {
23
- return true
26
+ return true;
24
27
  }
25
28
  } else {
26
- const { glibcVersionRuntime } = process.report.getReport().header
27
- return !glibcVersionRuntime
29
+ const { glibcVersionRuntime } = process.report.getReport().header;
30
+ return !glibcVersionRuntime;
28
31
  }
29
32
  }
30
33
 
31
34
  switch (platform) {
32
- case 'android':
35
+ case "android":
33
36
  switch (arch) {
34
- case 'arm64':
35
- localFileExisted = existsSync(join(__dirname, 'anonymask.android-arm64.node'))
37
+ case "arm64":
38
+ localFileExisted = existsSync(
39
+ join(__dirname, "anonymask.android-arm64.node"),
40
+ );
36
41
  try {
37
42
  if (localFileExisted) {
38
- nativeBinding = require('./anonymask.android-arm64.node')
43
+ nativeBinding = require("./anonymask.android-arm64.node");
39
44
  } else {
40
- nativeBinding = require('@anonymask/core-android-arm64')
45
+ nativeBinding = require("@anonymask/core-android-arm64");
41
46
  }
42
47
  } catch (e) {
43
- loadError = e
48
+ loadError = e;
44
49
  }
45
- break
46
- case 'arm':
47
- localFileExisted = existsSync(join(__dirname, 'anonymask.android-arm-eabi.node'))
50
+ break;
51
+ case "arm":
52
+ localFileExisted = existsSync(
53
+ join(__dirname, "anonymask.android-arm-eabi.node"),
54
+ );
48
55
  try {
49
56
  if (localFileExisted) {
50
- nativeBinding = require('./anonymask.android-arm-eabi.node')
57
+ nativeBinding = require("./anonymask.android-arm-eabi.node");
51
58
  } else {
52
- nativeBinding = require('@anonymask/core-android-arm-eabi')
59
+ nativeBinding = require("@anonymask/core-android-arm-eabi");
53
60
  }
54
61
  } catch (e) {
55
- loadError = e
62
+ loadError = e;
56
63
  }
57
- break
64
+ break;
58
65
  default:
59
- throw new Error(`Unsupported architecture on Android ${arch}`)
66
+ throw new Error(`Unsupported architecture on Android ${arch}`);
60
67
  }
61
- break
62
- case 'win32':
68
+ break;
69
+ case "win32":
63
70
  switch (arch) {
64
- case 'x64':
71
+ case "x64":
65
72
  localFileExisted = existsSync(
66
- join(__dirname, 'anonymask.win32-x64-msvc.node')
67
- )
73
+ join(__dirname, "anonymask.win32-x64-msvc.node"),
74
+ );
68
75
  try {
69
76
  if (localFileExisted) {
70
- nativeBinding = require('./anonymask.win32-x64-msvc.node')
77
+ nativeBinding = require("./anonymask.win32-x64-msvc.node");
71
78
  } else {
72
- nativeBinding = require('@anonymask/core-win32-x64-msvc')
79
+ nativeBinding = require("@anonymask/core-win32-x64-msvc");
73
80
  }
74
81
  } catch (e) {
75
- loadError = e
82
+ loadError = e;
76
83
  }
77
- break
78
- case 'ia32':
84
+ break;
85
+ case "ia32":
79
86
  localFileExisted = existsSync(
80
- join(__dirname, 'anonymask.win32-ia32-msvc.node')
81
- )
87
+ join(__dirname, "anonymask.win32-ia32-msvc.node"),
88
+ );
82
89
  try {
83
90
  if (localFileExisted) {
84
- nativeBinding = require('./anonymask.win32-ia32-msvc.node')
91
+ nativeBinding = require("./anonymask.win32-ia32-msvc.node");
85
92
  } else {
86
- nativeBinding = require('@anonymask/core-win32-ia32-msvc')
93
+ nativeBinding = require("@anonymask/core-win32-ia32-msvc");
87
94
  }
88
95
  } catch (e) {
89
- loadError = e
96
+ loadError = e;
90
97
  }
91
- break
92
- case 'arm64':
98
+ break;
99
+ case "arm64":
93
100
  localFileExisted = existsSync(
94
- join(__dirname, 'anonymask.win32-arm64-msvc.node')
95
- )
101
+ join(__dirname, "anonymask.win32-arm64-msvc.node"),
102
+ );
96
103
  try {
97
104
  if (localFileExisted) {
98
- nativeBinding = require('./anonymask.win32-arm64-msvc.node')
105
+ nativeBinding = require("./anonymask.win32-arm64-msvc.node");
99
106
  } else {
100
- nativeBinding = require('@anonymask/core-win32-arm64-msvc')
107
+ nativeBinding = require("@anonymask/core-win32-arm64-msvc");
101
108
  }
102
109
  } catch (e) {
103
- loadError = e
110
+ loadError = e;
104
111
  }
105
- break
112
+ break;
106
113
  default:
107
- throw new Error(`Unsupported architecture on Windows: ${arch}`)
114
+ throw new Error(`Unsupported architecture on Windows: ${arch}`);
108
115
  }
109
- break
110
- case 'darwin':
111
- localFileExisted = existsSync(join(__dirname, 'anonymask.darwin-universal.node'))
116
+ break;
117
+ case "darwin":
118
+ localFileExisted = existsSync(
119
+ join(__dirname, "anonymask.darwin-universal.node"),
120
+ );
112
121
  try {
113
122
  if (localFileExisted) {
114
- nativeBinding = require('./anonymask.darwin-universal.node')
123
+ nativeBinding = require("./anonymask.darwin-universal.node");
115
124
  } else {
116
- nativeBinding = require('@anonymask/core-darwin-universal')
125
+ nativeBinding = require("@anonymask/core-darwin-universal");
117
126
  }
118
- break
127
+ break;
119
128
  } catch {}
120
129
  switch (arch) {
121
- case 'x64':
122
- localFileExisted = existsSync(join(__dirname, 'anonymask.darwin-x64.node'))
130
+ case "x64":
131
+ localFileExisted = existsSync(
132
+ join(__dirname, "anonymask.darwin-x64.node"),
133
+ );
123
134
  try {
124
135
  if (localFileExisted) {
125
- nativeBinding = require('./anonymask.darwin-x64.node')
136
+ nativeBinding = require("./anonymask.darwin-x64.node");
126
137
  } else {
127
- nativeBinding = require('@anonymask/core-darwin-x64')
138
+ nativeBinding = require("@anonymask/core-darwin-x64");
128
139
  }
129
140
  } catch (e) {
130
- loadError = e
141
+ loadError = e;
131
142
  }
132
- break
133
- case 'arm64':
143
+ break;
144
+ case "arm64":
134
145
  localFileExisted = existsSync(
135
- join(__dirname, 'anonymask.darwin-arm64.node')
136
- )
146
+ join(__dirname, "anonymask.darwin-arm64.node"),
147
+ );
137
148
  try {
138
149
  if (localFileExisted) {
139
- nativeBinding = require('./anonymask.darwin-arm64.node')
150
+ nativeBinding = require("./anonymask.darwin-arm64.node");
140
151
  } else {
141
- nativeBinding = require('@anonymask/core-darwin-arm64')
152
+ nativeBinding = require("@anonymask/core-darwin-arm64");
142
153
  }
143
154
  } catch (e) {
144
- loadError = e
155
+ loadError = e;
145
156
  }
146
- break
157
+ break;
147
158
  default:
148
- throw new Error(`Unsupported architecture on macOS: ${arch}`)
159
+ throw new Error(`Unsupported architecture on macOS: ${arch}`);
149
160
  }
150
- break
151
- case 'freebsd':
152
- if (arch !== 'x64') {
153
- throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
161
+ break;
162
+ case "freebsd":
163
+ if (arch !== "x64") {
164
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
154
165
  }
155
- localFileExisted = existsSync(join(__dirname, 'anonymask.freebsd-x64.node'))
166
+ localFileExisted = existsSync(
167
+ join(__dirname, "anonymask.freebsd-x64.node"),
168
+ );
156
169
  try {
157
170
  if (localFileExisted) {
158
- nativeBinding = require('./anonymask.freebsd-x64.node')
171
+ nativeBinding = require("./anonymask.freebsd-x64.node");
159
172
  } else {
160
- nativeBinding = require('@anonymask/core-freebsd-x64')
173
+ nativeBinding = require("@anonymask/core-freebsd-x64");
161
174
  }
162
175
  } catch (e) {
163
- loadError = e
176
+ loadError = e;
164
177
  }
165
- break
166
- case 'linux':
178
+ break;
179
+ case "linux":
167
180
  switch (arch) {
168
- case 'x64':
181
+ case "x64":
169
182
  if (isMusl()) {
170
183
  localFileExisted = existsSync(
171
- join(__dirname, 'anonymask.linux-x64-musl.node')
172
- )
184
+ join(__dirname, "anonymask.linux-x64-musl.node"),
185
+ );
173
186
  try {
174
187
  if (localFileExisted) {
175
- nativeBinding = require('./anonymask.linux-x64-musl.node')
188
+ nativeBinding = require("./anonymask.linux-x64-musl.node");
176
189
  } else {
177
- nativeBinding = require('@anonymask/core-linux-x64-musl')
190
+ nativeBinding = require("@anonymask/core-linux-x64-musl");
178
191
  }
179
192
  } catch (e) {
180
- loadError = e
193
+ loadError = e;
181
194
  }
182
195
  } else {
183
196
  localFileExisted = existsSync(
184
- join(__dirname, 'anonymask.linux-x64-gnu.node')
185
- )
197
+ join(__dirname, "anonymask.linux-x64-gnu.node"),
198
+ );
186
199
  try {
187
200
  if (localFileExisted) {
188
- nativeBinding = require('./anonymask.linux-x64-gnu.node')
201
+ nativeBinding = require("./anonymask.linux-x64-gnu.node");
189
202
  } else {
190
- nativeBinding = require('@anonymask/core-linux-x64-gnu')
203
+ nativeBinding = require("@anonymask/core-linux-x64-gnu");
191
204
  }
192
205
  } catch (e) {
193
- loadError = e
206
+ loadError = e;
194
207
  }
195
208
  }
196
- break
197
- case 'arm64':
209
+ break;
210
+ case "arm64":
198
211
  if (isMusl()) {
199
212
  localFileExisted = existsSync(
200
- join(__dirname, 'anonymask.linux-arm64-musl.node')
201
- )
213
+ join(__dirname, "anonymask.linux-arm64-musl.node"),
214
+ );
202
215
  try {
203
216
  if (localFileExisted) {
204
- nativeBinding = require('./anonymask.linux-arm64-musl.node')
217
+ nativeBinding = require("./anonymask.linux-arm64-musl.node");
205
218
  } else {
206
- nativeBinding = require('@anonymask/core-linux-arm64-musl')
219
+ nativeBinding = require("@anonymask/core-linux-arm64-musl");
207
220
  }
208
221
  } catch (e) {
209
- loadError = e
222
+ loadError = e;
210
223
  }
211
224
  } else {
212
225
  localFileExisted = existsSync(
213
- join(__dirname, 'anonymask.linux-arm64-gnu.node')
214
- )
226
+ join(__dirname, "anonymask.linux-arm64-gnu.node"),
227
+ );
215
228
  try {
216
229
  if (localFileExisted) {
217
- nativeBinding = require('./anonymask.linux-arm64-gnu.node')
230
+ nativeBinding = require("./anonymask.linux-arm64-gnu.node");
218
231
  } else {
219
- nativeBinding = require('@anonymask/core-linux-arm64-gnu')
232
+ nativeBinding = require("@anonymask/core-linux-arm64-gnu");
220
233
  }
221
234
  } catch (e) {
222
- loadError = e
235
+ loadError = e;
223
236
  }
224
237
  }
225
- break
226
- case 'arm':
238
+ break;
239
+ case "arm":
227
240
  if (isMusl()) {
228
241
  localFileExisted = existsSync(
229
- join(__dirname, 'anonymask.linux-arm-musleabihf.node')
230
- )
242
+ join(__dirname, "anonymask.linux-arm-musleabihf.node"),
243
+ );
231
244
  try {
232
245
  if (localFileExisted) {
233
- nativeBinding = require('./anonymask.linux-arm-musleabihf.node')
246
+ nativeBinding = require("./anonymask.linux-arm-musleabihf.node");
234
247
  } else {
235
- nativeBinding = require('@anonymask/core-linux-arm-musleabihf')
248
+ nativeBinding = require("@anonymask/core-linux-arm-musleabihf");
236
249
  }
237
250
  } catch (e) {
238
- loadError = e
251
+ loadError = e;
239
252
  }
240
253
  } else {
241
254
  localFileExisted = existsSync(
242
- join(__dirname, 'anonymask.linux-arm-gnueabihf.node')
243
- )
255
+ join(__dirname, "anonymask.linux-arm-gnueabihf.node"),
256
+ );
244
257
  try {
245
258
  if (localFileExisted) {
246
- nativeBinding = require('./anonymask.linux-arm-gnueabihf.node')
259
+ nativeBinding = require("./anonymask.linux-arm-gnueabihf.node");
247
260
  } else {
248
- nativeBinding = require('@anonymask/core-linux-arm-gnueabihf')
261
+ nativeBinding = require("@anonymask/core-linux-arm-gnueabihf");
249
262
  }
250
263
  } catch (e) {
251
- loadError = e
264
+ loadError = e;
252
265
  }
253
266
  }
254
- break
255
- case 'riscv64':
267
+ break;
268
+ case "riscv64":
256
269
  if (isMusl()) {
257
270
  localFileExisted = existsSync(
258
- join(__dirname, 'anonymask.linux-riscv64-musl.node')
259
- )
271
+ join(__dirname, "anonymask.linux-riscv64-musl.node"),
272
+ );
260
273
  try {
261
274
  if (localFileExisted) {
262
- nativeBinding = require('./anonymask.linux-riscv64-musl.node')
275
+ nativeBinding = require("./anonymask.linux-riscv64-musl.node");
263
276
  } else {
264
- nativeBinding = require('@anonymask/core-linux-riscv64-musl')
277
+ nativeBinding = require("@anonymask/core-linux-riscv64-musl");
265
278
  }
266
279
  } catch (e) {
267
- loadError = e
280
+ loadError = e;
268
281
  }
269
282
  } else {
270
283
  localFileExisted = existsSync(
271
- join(__dirname, 'anonymask.linux-riscv64-gnu.node')
272
- )
284
+ join(__dirname, "anonymask.linux-riscv64-gnu.node"),
285
+ );
273
286
  try {
274
287
  if (localFileExisted) {
275
- nativeBinding = require('./anonymask.linux-riscv64-gnu.node')
288
+ nativeBinding = require("./anonymask.linux-riscv64-gnu.node");
276
289
  } else {
277
- nativeBinding = require('@anonymask/core-linux-riscv64-gnu')
290
+ nativeBinding = require("@anonymask/core-linux-riscv64-gnu");
278
291
  }
279
292
  } catch (e) {
280
- loadError = e
293
+ loadError = e;
281
294
  }
282
295
  }
283
- break
284
- case 's390x':
296
+ break;
297
+ case "s390x":
285
298
  localFileExisted = existsSync(
286
- join(__dirname, 'anonymask.linux-s390x-gnu.node')
287
- )
299
+ join(__dirname, "anonymask.linux-s390x-gnu.node"),
300
+ );
288
301
  try {
289
302
  if (localFileExisted) {
290
- nativeBinding = require('./anonymask.linux-s390x-gnu.node')
303
+ nativeBinding = require("./anonymask.linux-s390x-gnu.node");
291
304
  } else {
292
- nativeBinding = require('@anonymask/core-linux-s390x-gnu')
305
+ nativeBinding = require("@anonymask/core-linux-s390x-gnu");
293
306
  }
294
307
  } catch (e) {
295
- loadError = e
308
+ loadError = e;
296
309
  }
297
- break
310
+ break;
298
311
  default:
299
- throw new Error(`Unsupported architecture on Linux: ${arch}`)
312
+ throw new Error(`Unsupported architecture on Linux: ${arch}`);
300
313
  }
301
- break
314
+ break;
302
315
  default:
303
- throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
316
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
304
317
  }
305
318
 
306
319
  if (!nativeBinding) {
307
320
  if (loadError) {
308
- throw loadError
321
+ throw loadError;
309
322
  }
310
- throw new Error(`Failed to load native binding`)
323
+ throw new Error(`Failed to load native binding`);
311
324
  }
312
325
 
313
- const { Anonymizer } = nativeBinding
326
+ const { Anonymizer } = nativeBinding;
314
327
 
315
- module.exports.Anonymizer = Anonymizer
328
+ module.exports.Anonymizer = Anonymizer;
package/package.json CHANGED
@@ -1,31 +1,16 @@
1
1
  {
2
2
  "name": "@anonymask/core",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Secure anonymization/de-anonymization library for PII data",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
- "publishConfig": {
8
- "access": "public",
9
- "registry": "https://registry.npmjs.org/"
10
- },
11
- "files": [
12
- "index.js",
13
- "index.d.ts"
14
- ],
15
- "scripts": {
16
- "build": "napi build --platform --release",
17
- "build:debug": "napi build --platform",
18
- "test": "jest",
19
- "prepublishOnly": "npm run build"
20
- },
7
+ "author": "Gokul Viswanathan <gokulviswanathan25@gmail.com>",
21
8
  "repository": {
22
9
  "type": "git",
23
10
  "url": "https://github.com/gokul-viswanathan/anonymask.git"
24
11
  },
25
- "homepage": "https://github.com/gokul-viswanathan/anonymask",
26
- "bugs": {
27
- "url": "https://github.com/gokul-viswanathan/anonymask/issues"
28
- },
12
+ "license": "MIT",
13
+ "browser": "browser.js",
29
14
  "keywords": [
30
15
  "anonymization",
31
16
  "PII",
@@ -35,26 +20,58 @@
35
20
  "security",
36
21
  "data-protection"
37
22
  ],
38
- "author": "Gokul Viswanathan <gokulviswanathan25@gmail.com>",
39
- "license": "MIT",
23
+ "files": [
24
+ "index.d.ts",
25
+ "index.js",
26
+ "browser.js"
27
+ ],
28
+ "napi": {
29
+ "binaryName": "anonymask",
30
+ "targets": [
31
+ "x86_64-pc-windows-msvc",
32
+ "x86_64-apple-darwin",
33
+ "x86_64-unknown-linux-gnu",
34
+ "aarch64-unknown-linux-gnu",
35
+ "aarch64-apple-darwin"
36
+ ]
37
+ },
40
38
  "engines": {
41
- "node": ">=14.0.0"
39
+ "node": ">= 16.0.0"
40
+ },
41
+ "publishConfig": {
42
+ "registry": "https://registry.npmjs.org/",
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "artifacts": "napi artifacts",
47
+ "bench": "node --import @oxc-node/core/register benchmark/bench.ts",
48
+ "build": "napi build --platform --release",
49
+ "build:debug": "napi build --platform",
50
+ "format": "run-p format:prettier format:rs format:toml",
51
+ "format:prettier": "prettier . -w",
52
+ "format:rs": "cargo fmt",
53
+ "prepublishOnly": "napi prepublish -t npm",
54
+ "test": "jest",
55
+ "preversion": "napi build --platform && git add .",
56
+ "version": "napi version"
42
57
  },
43
58
  "devDependencies": {
44
- "@napi-rs/cli": "^2.18.0",
45
- "jest": "^30.2.0"
59
+ "@napi-rs/cli": "^3.0.0",
60
+ "@tybys/wasm-util": "^0.10.0",
61
+ "chalk": "^5.6.2",
62
+ "husky": "^9.1.7",
63
+ "lint-staged": "^16.1.6",
64
+ "jest": "^30.2.0",
65
+ "npm-run-all2": "^8.0.4",
66
+ "prettier": "^3.6.2",
67
+ "tinybench": "^5.0.1",
68
+ "typescript": "^5.9.2"
46
69
  },
47
- "napi": {
48
- "name": "anonymask",
49
- "cargoManifestPath": "./Cargo.toml",
50
- "triples": {
51
- "defaults": true,
52
- "additional": [
53
- "aarch64-apple-darwin",
54
- "x86_64-unknown-linux-gnu",
55
- "x86_64-apple-darwin",
56
- "x86_64-pc-windows-msvc"
57
- ]
58
- }
70
+ "optionalDependencies": {
71
+ "@anonymask/core-win32-x64-msvc": "0.3.0",
72
+ "@anonymask/core-darwin-x64": "0.3.0",
73
+ "@anonymask/core-linux-x64-gnu": "0.3.0",
74
+ "@anonymask/core-linux-arm64-gnu": "0.3.0",
75
+ "@anonymask/core-darwin-arm64": "0.3.0"
59
76
  }
60
- }
77
+ }