add keyout option
This commit is contained in:
parent
b5a1ab29bc
commit
94b624f312
17
keyout.ts
17
keyout.ts
@ -5,10 +5,21 @@ import { prepareSecretKey } from "./util/secret.ts";
|
|||||||
export const key_out_cmd = new Command();
|
export const key_out_cmd = new Command();
|
||||||
key_out_cmd.name("keyout")
|
key_out_cmd.name("keyout")
|
||||||
.description("Output the secret key.")
|
.description("Output the secret key.")
|
||||||
.action(async () => {
|
.option("-f, --file <file:string>", "The file to output the key to. (default: stdout)")
|
||||||
|
.option("--dotenv", "Output the key in dotenv format.")
|
||||||
|
.action(async ({file, dotenv}) => {
|
||||||
const key = await prepareSecretKey();
|
const key = await prepareSecretKey();
|
||||||
const out = await crypto.subtle.exportKey("jwk", key);
|
const keyout = await crypto.subtle.exportKey("jwk", key);
|
||||||
console.log(JSON.stringify(out));
|
let out = JSON.stringify(keyout);
|
||||||
|
if (dotenv){
|
||||||
|
out = [`SECRET_KEY='${out}'`].join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file){
|
||||||
|
await Deno.writeTextFile(file, out);
|
||||||
|
} else {
|
||||||
|
console.log(out);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if ( import.meta.main ){
|
if ( import.meta.main ){
|
||||||
|
Loading…
Reference in New Issue
Block a user