-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add library to perform redaction of sensitive information #1358
Conversation
😎 Merged successfully - details. |
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
Copying to the root of the PR so it doesn't get buried in comments: The sample that I've been playing with is: const [redacted, unredact] = await redact("abc, 123", {
// entities: ["credit-card-number", "abc"],
// detect: (tokens: string[]) => {
// return tokens.map((token) => {
// if (token == "abc") {
// return "abc";
// }
// });
// },
replace: (entity) => {
// if (entity === "abc") return "123456";
if (entity === "email") return "foobarbaz";
// if (entity === "") return "123";
},
}); Essentially, we should be able to comment/uncomment the various pieces and the type inference should be good. I have inlay hints enabled for all my TS so I can see how it is inferring things. I'm going to push up my changes, but be aware that they have the same caveat as #1446 (comment) and I'm not good enough at TypeScript to know how to make both ways work. |
I've also just discovered that the arguments of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big question on whether we should be defaulting to "no redactions" in the redact library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While trying to improve the type inference on #1358, I found that we weren't providing the correct type inference on the `sensitiveInfo` rule when a user **does not** specify a `detect()` function. This is likely the most common scenario so we want to have proper type inference here. To solve this, I made `Detect` very generic throughout the types and then used some techniques (commented inline) to figure out if the function was specified in the options.
Automatically generated with [Release Please](https://github.com/googleapis/release-please). --- <details><summary>@arcjet/analyze: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/analyze-v1.0.0-alpha.23) (2024-09-02) ### 🪲 Bug Fixes * **analyze:** Ensure headers are serialized correctly ([#1435](#1435)) ([0319412](0319412)) * Ensure instantiation throws if WebAssembly is unavailable ([#1458](#1458)) ([0edfd45](0edfd45)) ### 🧹 Miscellaneous Chores * remove sideEffects from analyze ([#1444](#1444)) ([572aaa0](572aaa0)) ### Dependencies * The following workspace dependencies were updated * dependencies * @arcjet/protocol bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/body: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/body-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/body:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/bun: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/bun-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/bun:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * dependencies * @arcjet/env bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/headers bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/ip bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/logger bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/protocol bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/transport bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * arcjet bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/decorate: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/decorate-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/decorate:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * dependencies * @arcjet/protocol bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/sprintf bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/duration: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/duration-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/duration:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/env: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/env-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/env:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/eslint-config: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/eslint-config-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/eslint-config:** Synchronize arcjet-js versions </details> <details><summary>@arcjet/headers: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/headers-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/headers:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/ip: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/ip-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/ip:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/logger: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/logger-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/logger:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * dependencies * @arcjet/sprintf bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/next: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/next-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/next:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * dependencies * @arcjet/env bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/headers bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/ip bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/logger bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/protocol bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/transport bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * arcjet bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/node: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/node-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/node:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * dependencies * @arcjet/env bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/headers bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/ip bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/logger bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/protocol bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/transport bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/body bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * arcjet bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/protocol: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/protocol-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/protocol:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/redact: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/redact-v1.0.0-alpha.23) (2024-09-02) ### 🚀 New Features * add library to perform redaction of sensitive information ([#1358](#1358)) ([59d4a0d](59d4a0d)) ### Dependencies * The following workspace dependencies were updated * dependencies * @arcjet/redact-wasm bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/redact-wasm: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/redact-wasm-v1.0.0-alpha.23) (2024-09-02) ### 🚀 New Features * add library to perform redaction of sensitive information ([#1358](#1358)) ([59d4a0d](59d4a0d)) ### 🪲 Bug Fixes * Ensure instantiation throws if WebAssembly is unavailable ([#1458](#1458)) ([0edfd45](0edfd45)) ### Dependencies * The following workspace dependencies were updated * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/rollup-config: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/rollup-config-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/rollup-config:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/runtime: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/runtime-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/runtime:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/sprintf: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/sprintf-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/sprintf:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/sveltekit: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/sveltekit-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/sveltekit:** Synchronize arcjet-js versions ### Dependencies * The following workspace dependencies were updated * dependencies * @arcjet/env bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/headers bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/ip bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/logger bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/protocol bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/transport bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * arcjet bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/transport: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/transport-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **transport:** Reduce idle timeout for AWS Global Accelerator ([#1479](#1479)) ([cd1df38](cd1df38)) ### Dependencies * The following workspace dependencies were updated * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>@arcjet/tsconfig: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](https://github.com/arcjet/arcjet-js/compare/v1.0.0-alpha.22...@arcjet/tsconfig-v1.0.0-alpha.23) (2024-09-02) ### 🧹 Miscellaneous Chores * **@arcjet/tsconfig:** Synchronize arcjet-js versions </details> <details><summary>arcjet: 1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](v1.0.0-alpha.22...arcjet-v1.0.0-alpha.23) (2024-09-02) ### 🪲 Bug Fixes * **analyze:** Ensure headers are serialized correctly ([#1435](#1435)) ([0319412](0319412)) * **arcjet:** Infer types when no detect function is specified ([#1446](#1446)) ([8ae0370](8ae0370)) ### Dependencies * The following workspace dependencies were updated * dependencies * @arcjet/analyze bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/duration bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/headers bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/protocol bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/runtime bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * devDependencies * @arcjet/eslint-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/rollup-config bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 * @arcjet/tsconfig bumped from 1.0.0-alpha.22 to 1.0.0-alpha.23 </details> <details><summary>1.0.0-alpha.23</summary> ## [1.0.0-alpha.23](v1.0.0-alpha.22...v1.0.0-alpha.23) (2024-09-02) ### 🚀 New Features * add library to perform redaction of sensitive information ([#1358](#1358)) ([59d4a0d](59d4a0d)) ### 🪲 Bug Fixes * **analyze:** Ensure headers are serialized correctly ([#1435](#1435)) ([0319412](0319412)) * **arcjet:** Infer types when no detect function is specified ([#1446](#1446)) ([8ae0370](8ae0370)) * Ensure instantiation throws if WebAssembly is unavailable ([#1458](#1458)) ([0edfd45](0edfd45)) ### 🧹 Miscellaneous Chores * **deps:** bump webpack and @nestjs/cli in /examples/nodejs-nestjs ([#1456](#1456)) ([8d125ac](8d125ac)) * **example:** Remove env package usage ([#1457](#1457)) ([f09f3d3](f09f3d3)) * remove sideEffects from analyze ([#1444](#1444)) ([572aaa0](572aaa0)) * **transport:** Reduce idle timeout for AWS Global Accelerator ([#1479](#1479)) ([cd1df38](cd1df38)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Adds the library to perform redaction on text using the Arcjet sensitive info primitive.
Redaction is performed by the
redact()
function, which takes astring
and any configuration that you want to use. It returns the redacted text and anunredact()
function as a[redacted, unredact]
tuple. Callingunredact()
with a string will replace the fake data with the original data.