CREDENTIAL TYPE MANAGEMENT WORKS
This commit is contained in:
+41
-22
@@ -7,31 +7,50 @@ This script will go through and genrate all the keys necessary for running the C
|
||||
This process might take several minutes.
|
||||
-----------------`);
|
||||
|
||||
await Promise.all(
|
||||
[
|
||||
".accessToken.key",
|
||||
".refreshToken.key",
|
||||
".permissions.key",
|
||||
".apiKeyToken.key",
|
||||
].map(async (v) => {
|
||||
if (
|
||||
await Bun.file(v)
|
||||
.exists()
|
||||
.then((bool) => {
|
||||
if (bool) {
|
||||
console.log(`'${v}' already exists`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
) {
|
||||
console.log(`Generating '${v}'...`);
|
||||
const keys = keypair({ bits: 4096 });
|
||||
const keyFiles = [
|
||||
".accessToken.key",
|
||||
".refreshToken.key",
|
||||
".permissions.key",
|
||||
".secureValues.key",
|
||||
];
|
||||
|
||||
await Bun.write(v, keys.private);
|
||||
const publicDir = "public-keys";
|
||||
|
||||
await Promise.all(
|
||||
keyFiles.map(async (v) => {
|
||||
const privExists = await Bun.file(v)
|
||||
.exists()
|
||||
.then((bool) => {
|
||||
if (bool) {
|
||||
console.log(`'${v}' already exists`);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
const pubPath = `${publicDir}/${v.replace(/\.key$/, ".pub")}`;
|
||||
const pubExists = await Bun.file(pubPath)
|
||||
.exists()
|
||||
.then((bool) => {
|
||||
if (bool) {
|
||||
console.log(`'${pubPath}' already exists`);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!privExists || !pubExists) {
|
||||
console.log(`Generating '${v}' and '${pubPath}'...`);
|
||||
const keys = keypair({ bits: 4096 });
|
||||
if (!privExists) {
|
||||
await Bun.write(v, keys.private);
|
||||
}
|
||||
if (!pubExists) {
|
||||
await Bun.write(pubPath, keys.public);
|
||||
}
|
||||
}
|
||||
return;
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
console.log("\nGenerated All Keys Successfully!");
|
||||
|
||||
Reference in New Issue
Block a user