Private widget options API

This commit is contained in:
Michael Shamoon 2022-10-11 11:15:33 -07:00
parent 8e2ff61f1c
commit 7c39cd8960
3 changed files with 39 additions and 4 deletions

View file

@ -34,3 +34,16 @@ export function getSettings() {
const fileContents = readFileSync(settingsYaml, "utf8");
return yaml.load(fileContents);
}
export function sanitizePrivateOptions(options, privateOnly = false) {
const privateOptions = ["url", "username", "password", "key"];
const sanitizedOptions = {};
Object.keys(options).forEach((key) => {
if (!privateOnly && !privateOptions.includes(key)) {
sanitizedOptions[key] = options[key];
} else if (privateOnly && privateOptions.includes(key)) {
sanitizedOptions[key] = options[key];
}
});
return sanitizedOptions;
}