@samveys/env-crypt

svs env:encrypt dan env:decrypt

Versi
1.0.35 Nov 2026
Pasang
pnpm add @samveys/env-crypt
Dokumentasi
README paket ini

Daftar ini dibaca dari versi 1.0.2; jalankan pnpm sync untuk memperbaruinya.

Import
import { decryptEnv, encryptEnv, envCrypt, generateEnvKey, ENV_KEY_NAME, envDecryptCommand, … } from '@samveys/env-crypt'

Fungsi (4)

decryptEnv Fungsi

Reverses {@link encryptEnv}. Any change to the file, or the wrong key, is SVS_E118.

function decryptEnv(text: string, key: string | undefined): string;

Diekspor dari packages/env-crypt/src/crypt.ts

encryptEnv Fungsi

Encrypts env file text. - Whole-file mode (default): the entire file becomes one authenticated blob behind a marker line. - `readable: true`: every `NAME=value` keeps its `NAME=` and the value (everything after `=`, quotes and trailing comments included) becomes `enc:v1:<base64>`. Comments, blank lines and line endings stay as they were. `decryptEnv` returns the original text byte for byte.

function encryptEnv(text: string, key: string | undefined, options?: {

Diekspor dari packages/env-crypt/src/crypt.ts

envCrypt Fungsi

The `@samveys/env-crypt` plugin: adds `svs env:encrypt` and `svs env:decrypt`.

function envCrypt(): import("@samveys/core").Plugin<undefined>;

Diekspor dari packages/env-crypt/src/plugin.ts

generateEnvKey Fungsi

A fresh key in the format `SAMVEYS_ENV_KEY` expects.

function generateEnvKey(): string;

Diekspor dari packages/env-crypt/src/crypt.ts

Nilai (5)

ENV_KEY_NAME Nilai

Tidak ada komentar dokumentasi.

const ENV_KEY_NAME = "SAMVEYS_ENV_KEY";

Diekspor dari packages/env-crypt/src/commands.ts

envDecryptCommand Nilai

The `svs env:decrypt` command.

const envDecryptCommand: Command<typeof decryptFlags>;

Diekspor dari packages/env-crypt/src/commands.ts

envEncryptCommand Nilai

The `svs env:encrypt` command. The key comes from `SAMVEYS_ENV_KEY`; when it is missing one is generated and printed once.

const envEncryptCommand: Command<typeof encryptFlags>;

Diekspor dari packages/env-crypt/src/commands.ts

VALUE_PREFIX Nilai

Prefix of an encrypted value in readable mode: `NAME=enc:v1:<base64>`.

const VALUE_PREFIX = "enc:v1:";

Diekspor dari packages/env-crypt/src/crypt.ts

WHOLE_FILE_MARKER Nilai

First line of a whole-file encrypted env file.

const WHOLE_FILE_MARKER = "# svs-env v1 whole-file\n";

Diekspor dari packages/env-crypt/src/crypt.ts