38 lines
840 B
TypeScript
38 lines
840 B
TypeScript
import keypair from "keypair";
|
|
|
|
console.log(`
|
|
Generating Private Keys
|
|
-----------------
|
|
This script will go through and genrate all the keys necessary for running the Credential Manager API locally.
|
|
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 });
|
|
|
|
await Bun.write(v, keys.private);
|
|
}
|
|
return;
|
|
})
|
|
);
|
|
|
|
console.log("\nGenerated All Keys Successfully!");
|