browse
Version:
Unified Browserbase CLI for browser automation and cloud APIs.
34 lines (33 loc) • 1.42 kB
JavaScript
import { Args } from "@oclif/core";
import { BrowseCommand } from "../../../base.js";
import { apiCommonFlags, toApiOptions } from "../../../lib/cloud/flags.js";
import { createSecret } from "../../../lib/secrets/api.js";
import { readSecretValue } from "../../../lib/secrets/input.js";
import { secretInputFlags } from "../../../lib/secrets/flags.js";
import { outputJson } from "../../../lib/output.js";
export default class SecretsCreate extends BrowseCommand {
static description = "Create a project secret. Encrypts the value locally with the project public key.";
static examples = [
"browse cloud secrets create SERVICE_TOKEN",
"browse cloud secrets create SERVICE_TOKEN --env MY_SERVICE_TOKEN",
"browse cloud secrets create SERVICE_TOKEN --stdin < ./secret.txt",
];
static args = {
key: Args.string({
description: "Name exposed in the function context.secrets object.",
required: true,
}),
};
static flags = { ...apiCommonFlags, ...secretInputFlags };
async run() {
const { args, flags } = await this.parse(SecretsCreate);
const options = toApiOptions(flags);
const value = await readSecretValue({ stdin: flags.stdin, env: flags.env });
try {
outputJson(await createSecret(options, args.key, value));
}
finally {
value.fill(0);
}
}
}