@arcjet/redact 1.0.0 → 1.1.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 (2) hide show
  1. package/index.js +22 -5
  2. package/package.json +6 -7
package/index.js CHANGED
@@ -1,5 +1,15 @@
1
1
  import { initializeWasm } from '@arcjet/redact-wasm';
2
2
 
3
+ /**
4
+ * Turn an entity name into a `SensitiveInfoEntity`.
5
+ *
6
+ * See also `protocolSensitiveInfoEntitiesToAnalyze` in `arcjet/index.ts`.
7
+ *
8
+ * @param entity
9
+ * Entity name.
10
+ * @returns
11
+ * Entity object.
12
+ */
3
13
  function userEntitiesToWasm(entity) {
4
14
  if (typeof entity !== "string") {
5
15
  throw new Error("redaction entities must be strings");
@@ -10,11 +20,18 @@ function userEntitiesToWasm(entity) {
10
20
  entity === "phone-number") {
11
21
  return { tag: entity };
12
22
  }
13
- return {
14
- tag: "custom",
15
- val: entity,
16
- };
23
+ return { tag: "custom", val: entity };
17
24
  }
25
+ /**
26
+ * Turn a `SensitiveInfoEntity` object into its name.
27
+ *
28
+ * See also `analyzeSensitiveInfoEntitiesToString` in `arcjet/index.ts`.
29
+ *
30
+ * @param entity
31
+ * Entity object.
32
+ * @returns
33
+ * Entity name.
34
+ */
18
35
  function wasmEntitiesToString(entity) {
19
36
  if (entity.tag === "credit-card-number" ||
20
37
  entity.tag === "email" ||
@@ -84,7 +101,7 @@ async function callRedactWasm(candidate, options) {
84
101
  const replace = options.replace;
85
102
  convertedReplace = (identifiedType, plaintext) => {
86
103
  return replace(
87
- // @ts-ignore because we know this is coming from Wasm
104
+ // @ts-expect-error because we know this is coming from Wasm
88
105
  wasmEntitiesToString(identifiedType), plaintext);
89
106
  };
90
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcjet/redact",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Arcjet sensitive information redaction library",
5
5
  "keywords": [
6
6
  "arcjet",
@@ -37,19 +37,18 @@
37
37
  "scripts": {
38
38
  "build": "rollup --config rollup.config.js",
39
39
  "lint": "eslint .",
40
- "prepublishOnly": "npm run build",
41
40
  "test-api": "node --test -- test/*.test.js",
42
41
  "test-coverage": "node --experimental-test-coverage --test -- test/*.test.js",
43
42
  "test": "npm run build && npm run lint && npm run test-coverage"
44
43
  },
45
44
  "dependencies": {
46
- "@arcjet/redact-wasm": "1.0.0"
45
+ "@arcjet/redact-wasm": "1.1.0"
47
46
  },
48
47
  "devDependencies": {
49
- "@arcjet/eslint-config": "1.0.0",
50
- "@arcjet/rollup-config": "1.0.0",
51
- "@rollup/wasm-node": "4.55.1",
52
- "@types/node": "25.0.8",
48
+ "@arcjet/eslint-config": "1.1.0",
49
+ "@arcjet/rollup-config": "1.1.0",
50
+ "@rollup/wasm-node": "4.57.0",
51
+ "@types/node": "25.1.0",
53
52
  "eslint": "9.39.2",
54
53
  "typescript": "5.9.3"
55
54
  },