UNPKG

dotencr

Version:

Encrypt and decrypt individual lines inside a .env file. Supports multiple encryption keys. Keys and dotenv files can be read text file or read from the environment.

62 lines (61 loc) 2.29 kB
import { CryptoWrapperResult } from "./crypto_wrapper"; export declare enum LeftSideTokenIds { cryptoKeyName = "cryptoKeyName", pattern = "pattern", variableName = "variableName" } export declare enum RightSideTokenIds { iv = "iv", cipher = "cipher", tag = "tag" } declare type LeftSideTokenDict = Map<LeftSideTokenIds, string>; declare type RightSideTokenDict = Map<RightSideTokenIds, string>; export declare class DotenvVariable { /** * Use the term 'leftSide' to avoid confusion with the term 'encryption key'. * 'leftSide' refers to the KEY portion of the KEY=VALUE pair. */ leftSide: string; /** * Use the term 'rightSide' to avoid confusion with the term 'encryption key'. * 'rightSide' refers to the VALUE portion of the KEY=VALUE pair. */ rightSide: string; separatorLeft: string; separatorRight: string; leftSideTokens: LeftSideTokenDict; rightSideTokens: RightSideTokenDict; /** * If they name of the key is a reserved word, store the reserved word here. */ usingReservedWord?: string; errors: string[]; /** * Is the dotenv variable valid? * The variable is not considered valid if the key name is a reserved word. */ isValid: boolean; constructor(leftSide: string, rightSide: string, separatorLeft: string, separatorRight: string); leftCryptoKeyName(): string; leftPattern(): string; leftVariableName(): string; rightIV(): string; rightCipheredText(): string; rightSignature(): string; static isEqualCryptoKeyNameSeparatoVariableName(x: DotenvVariable, y: DotenvVariable): boolean; } /** * Struct for storing two matching dotenv variables. * The ciphered value must be decrypted first. The two unencrypted values can then be compared. * The encryption always generates a new value even when using the same text. This prevents * the ciphered values from being compared. */ export interface MatchingDotenvVariable { plainText: DotenvVariable; ciphered: DotenvVariable; plainTextEncryptionResult?: CryptoWrapperResult; cipheredDecryptionResult: CryptoWrapperResult; } export declare const isEqualMatchingDotenvVariable: (a: MatchingDotenvVariable, b: MatchingDotenvVariable) => boolean; export {};