@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
34 lines (33 loc) • 1.5 kB
TypeScript
import type { Base64String, StringMap } from '@naturalcycles/js-lib/types';
/**
* Loads plaintext secrets from process.env, removes them, stores locally.
* Make sure to call this function early on server startup, so secrets are removed from process.env
*
* Does NOT delete previous secrets from secretMap.
*/
export declare function loadSecretsFromEnv(): void;
/**
* Removes process.env.SECRET_*
*/
export declare function removeSecretsFromEnv(): void;
/**
* Does NOT delete previous secrets from secretMap.
*
* If SECRET_ENCRYPTION_KEY argument is passed - will decrypt the contents of the file first, before parsing it as JSON.
*
* Whole file is encrypted.
* For "json-values encrypted" style - use `loadSecretsFromEncryptedJsonFileValues`
*/
export declare function loadSecretsFromEncryptedJsonFile(filePath: string, secretEncryptionKey?: Base64String): void;
/**
* Whole file is NOT encrypted, but instead individual json values ARE encrypted..
* For whole-file encryption - use `loadSecretsFromEncryptedJsonFile`
*/
export declare function loadSecretsFromEncryptedJsonFileValues(filePath: string, secretEncryptionKey?: Base64String): void;
export declare function secret<T = string>(k: string, parseJson?: boolean): T;
export declare function secretOptional<T = string>(k: string, parseJson?: boolean): T | undefined;
export declare function getSecretMap(): StringMap;
/**
* REPLACES secretMap with new map.
*/
export declare function setSecretMap(map: StringMap): void;