@arcjet/redact 1.3.0 → 1.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 +69 -5
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<!-- trunk-ignore-all(markdownlint/MD001) -->
|
|
2
|
+
|
|
1
3
|
<a href="https://arcjet.com" target="_arcjet-home">
|
|
2
4
|
<picture>
|
|
3
5
|
<source media="(prefers-color-scheme: dark)" srcset="https://arcjet.com/logo/arcjet-dark-lockup-voyage-horizontal.svg">
|
|
@@ -26,6 +28,8 @@ redaction library.
|
|
|
26
28
|
- [npm package (`@arcjet/redact`)](https://www.npmjs.com/package/@arcjet/redact)
|
|
27
29
|
- [GitHub source code (`redact/` in `arcjet/arcjet-js`)](https://github.com/arcjet/arcjet-js/tree/main/redact)
|
|
28
30
|
|
|
31
|
+
See [`docs.arcjet.com`][redact-ref] for more on the API.
|
|
32
|
+
|
|
29
33
|
## What is this?
|
|
30
34
|
|
|
31
35
|
This package provides functionality to redact sensitive info.
|
|
@@ -52,10 +56,6 @@ Install with npm in Node.js:
|
|
|
52
56
|
npm install @arcjet/redact
|
|
53
57
|
```
|
|
54
58
|
|
|
55
|
-
## Reference
|
|
56
|
-
|
|
57
|
-
The full reference documentation can be found in the [Arcjet docs][redact-ref].
|
|
58
|
-
|
|
59
59
|
## Use
|
|
60
60
|
|
|
61
61
|
```ts
|
|
@@ -73,12 +73,76 @@ const unredacted = unredact("Your email address is <Redacted email #0>");
|
|
|
73
73
|
console.log(unredacted); // "Your email address is john@example.com"
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
## API
|
|
77
|
+
|
|
78
|
+
This package exports the identifiers
|
|
79
|
+
[`redact`][api-redact].
|
|
80
|
+
There is no default export.
|
|
81
|
+
|
|
82
|
+
This package exports the [TypeScript][] types
|
|
83
|
+
[`ArcjetSensitiveInfoType`][api-arcjet-sensitive-info-type] and
|
|
84
|
+
[`RedactOptions`][api-redact-options].
|
|
85
|
+
|
|
86
|
+
### `ArcjetSensitiveInfoType`
|
|
87
|
+
|
|
88
|
+
This type represents the kinds of sensitive information that can be detected
|
|
89
|
+
out of the box.
|
|
90
|
+
|
|
91
|
+
###### Type
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
type ArcjetSensitiveInfoType =
|
|
95
|
+
| "credit-card-number"
|
|
96
|
+
| "email"
|
|
97
|
+
| "ip-address"
|
|
98
|
+
| "phone-number";
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### `RedactOptions`
|
|
102
|
+
|
|
103
|
+
You can pass these options to configure how `redact` works.
|
|
104
|
+
|
|
105
|
+
###### Fields
|
|
106
|
+
|
|
107
|
+
- `contextWindowSize` (`number`, default: `1`)
|
|
108
|
+
— the number of tokens to consider for context
|
|
109
|
+
- `detect` (`(tokens: string[]) => ReadonlyArray<string | undefined>`, optional)
|
|
110
|
+
— a custom detection function to identify sensitive information
|
|
111
|
+
- `entities` (`Array<string>`, default: all builtin and detect entities)
|
|
112
|
+
— which entities to redact; this includes the builtin
|
|
113
|
+
[`ArcjetSensitiveInfoType`][api-arcjet-sensitive-info-type]s and
|
|
114
|
+
any custom types returned by your `detect` function
|
|
115
|
+
- `replace` (`(entity: string, plaintext: string) => string | undefined`, optional)
|
|
116
|
+
— a custom replace function to control how sensitive information is
|
|
117
|
+
redacted
|
|
118
|
+
|
|
119
|
+
### `redact(candidate[, options])`
|
|
120
|
+
|
|
121
|
+
Redacts sensitive information in a string. You can use the returned
|
|
122
|
+
`unredact` function to restore the original values later.
|
|
123
|
+
|
|
124
|
+
###### Parameters
|
|
125
|
+
|
|
126
|
+
- `candidate` (`string`)
|
|
127
|
+
— the string to redact
|
|
128
|
+
- `options` ([`RedactOptions`][api-redact-options], optional)
|
|
129
|
+
— configuration for what to redact and how
|
|
130
|
+
|
|
131
|
+
###### Returns
|
|
132
|
+
|
|
133
|
+
This function returns a `Promise` that resolves to a tuple with the redacted
|
|
134
|
+
string and a function to unredact it (`Promise<[string, Unredact]>`).
|
|
135
|
+
|
|
76
136
|
## License
|
|
77
137
|
|
|
78
138
|
[Apache License, Version 2.0][apache-license] © [Arcjet Labs, Inc.][arcjet]
|
|
79
139
|
|
|
80
140
|
[apache-license]: http://www.apache.org/licenses/LICENSE-2.0
|
|
141
|
+
[api-arcjet-sensitive-info-type]: #arcjetsensitiveinfotype
|
|
142
|
+
[api-redact-options]: #redactoptions
|
|
143
|
+
[api-redact]: #redactcandidate-options
|
|
81
144
|
[arcjet]: https://arcjet.com
|
|
82
|
-
[redact-ref]: https://docs.arcjet.com/redact/reference
|
|
83
145
|
[github-arcjet-analyze-wasm-what]: https://github.com/arcjet/arcjet-js/tree/main/analyze-wasm#what-is-this
|
|
84
146
|
[github-arcjet-redact-wasm]: https://github.com/arcjet/arcjet-js/tree/main/redact-wasm
|
|
147
|
+
[redact-ref]: https://docs.arcjet.com/redact/reference
|
|
148
|
+
[typescript]: https://www.typescriptlang.org/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcjet/redact",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Arcjet sensitive information redaction library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arcjet",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"test": "npm run build && npm run lint && npm run test-coverage"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@arcjet/redact-wasm": "1.
|
|
45
|
+
"@arcjet/redact-wasm": "1.4.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@arcjet/eslint-config": "1.
|
|
49
|
-
"@arcjet/rollup-config": "1.
|
|
50
|
-
"@rollup/wasm-node": "4.
|
|
48
|
+
"@arcjet/eslint-config": "1.4.0",
|
|
49
|
+
"@arcjet/rollup-config": "1.4.0",
|
|
50
|
+
"@rollup/wasm-node": "4.59.0",
|
|
51
51
|
"@types/node": "24.11.0",
|
|
52
|
-
"eslint": "9.39.
|
|
52
|
+
"eslint": "9.39.3",
|
|
53
53
|
"typescript": "5.9.3"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|