1
0

Move to website folder

This commit is contained in:
Zef Hemel
2022-07-15 14:59:47 +02:00
parent 7a86c4ef56
commit 307bd3be7a
17 changed files with 73 additions and 69 deletions
+25
View File
@@ -0,0 +1,25 @@
import { readYamlPage } from "./yaml_page";
// Read SECRETS page and retrieve specific set of secret keys
// Note: in this implementation there's no encryption employed at all so it's just a matter
// of not decising this SECRETS page to other places
export async function readSecrets(keys: string[]): Promise<any[]> {
try {
let allSecrets = await readYamlPage("SECRETS", ["yaml", "secrets"]);
let collectedSecrets: any[] = [];
for (let key of keys) {
let secret = allSecrets[key];
if (secret) {
collectedSecrets.push(secret);
} else {
throw new Error(`No such secret: ${key}`);
}
}
return collectedSecrets;
} catch (e: any) {
if (e.message === "Page not found") {
throw new Error(`No such secret: ${keys[0]}`);
}
throw e;
}
}