UNPKG

browse

Version:

Unified Browserbase CLI for browser automation and cloud APIs.

35 lines (34 loc) • 1.51 kB
import { Args } from "@oclif/core"; import { BrowseCommand } from "../../../base.js"; import { apiCommonFlags, toApiOptions } from "../../../lib/cloud/flags.js"; import { updateSecret } 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 SecretsUpdate extends BrowseCommand { static description = "Replace a secret value, encrypting it locally with the current project public key."; static examples = [ "browse cloud secrets update <secretId>", "browse cloud secrets update d2c4f48f-38e9-4b82-a36a-2b373fd14a65", "browse cloud secrets update <secretId> --env MY_SERVICE_TOKEN", "browse cloud secrets update <secretId> --stdin < ./secret.txt", ]; static args = { secretId: Args.string({ description: "Project secret ID (e.g. d2c4f48f-38e9-4b82-a36a-2b373fd14a65).", required: true, }), }; static flags = { ...apiCommonFlags, ...secretInputFlags }; async run() { const { args, flags } = await this.parse(SecretsUpdate); const options = toApiOptions(flags); const value = await readSecretValue({ stdin: flags.stdin, env: flags.env }); try { outputJson(await updateSecret(options, args.secretId, value)); } finally { value.fill(0); } } }