6cf86d5916
* Delete v2 Stripe routes * Delete v2 billing/usage pages * Delete v2 integration pages * Delete v2 project pages * Deleted a load of components and services * Deleted a load more components, presenters and services * Deleted another 100 files or so… * Removed old v2 paths * Removed named icons from form titles * Removed more string icons * Delete NamedIcon * Fixed some type errors * Delete endpointApi * Removed v2 from core/sdk * Post merge fixes * added explicit return types * using the new sdk export without v3 * Delete old v2 file * Added explicit return types because TS was complaining… * Don’t export RuntimeEnvironmentType from two core files. Was causing TS issue * Fix for removal of NamedIcon in new route * Removed strange eslintrc rule * Use the new redis client --------- Co-authored-by: James Ritchie <james@trigger.dev>
34 lines
951 B
TypeScript
34 lines
951 B
TypeScript
import { z } from "zod";
|
|
|
|
export const RedactStringSchema = z.object({
|
|
__redactedString: z.literal(true),
|
|
strings: z.array(z.string()),
|
|
interpolations: z.array(z.string()),
|
|
});
|
|
|
|
export type RedactString = z.infer<typeof RedactStringSchema>;
|
|
|
|
// Replaces redacted strings with "******".
|
|
// For example, this object: {"Authorization":{"__redactedString":true,"strings":["Bearer ",""],"interpolations":["sk-1234"]}}
|
|
// Would get stringified like so: {"Authorization": "Bearer ******"}
|
|
export function sensitiveDataReplacer(key: string, value: any): any {
|
|
if (typeof value === "object" && value !== null && value.__redactedString === true) {
|
|
return redactString(value);
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
function redactString(value: RedactString) {
|
|
let result = "";
|
|
|
|
for (let i = 0; i < value.strings.length; i++) {
|
|
result += value.strings[i];
|
|
if (i < value.interpolations.length) {
|
|
result += "********";
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|