UNPKG

@dsegovia90/redacted

Version:

Explicit access to sensitive data. Wraps values in a Redacted class to protect them from being leaked into loggers (ie: console.log) and serializers. Works with zod.

25 lines (24 loc) 831 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mutableRedactedZodV3 = exports.redactedZodV3 = void 0; const mod_js_1 = require("./mod.js"); /** * Creates a Zod schema that redacts the value. */ const redactedZodV3 = (zodType, properties) => { return zodType.transform((value) => { zodType.parse(value); return new mod_js_1.Redacted(value, properties); }); }; exports.redactedZodV3 = redactedZodV3; /** * Creates a Zod schema that mutably redacts the value. Allows for mutable access to the redacted value. */ const mutableRedactedZodV3 = (zodType, properties) => { return zodType.transform((value) => { zodType.parse(value); return new mod_js_1.MutableRedacted(value, properties); }); }; exports.mutableRedactedZodV3 = mutableRedactedZodV3;