The tmp package with promises support and disposers.
93
Build a configuration management system that securely stores sensitive application settings in temporary files with appropriate permissions.
Your system should create temporary files to store sensitive configuration data (such as API keys, database credentials, or authentication tokens) with restricted file permissions to prevent unauthorized access.
Implement a function storeSecureConfig that:
Implement a function createSecureWorkspace that:
Both functions should properly handle cleanup of created resources.
@generates
/**
* Stores sensitive configuration data in a temporary file with restricted permissions.
*
* @param {Object} config - Configuration object to store
* @returns {Promise<{path: string, cleanup: () => Promise<void>}>} File path and cleanup function
*/
async function storeSecureConfig(config) {
// IMPLEMENTATION HERE
}
/**
* Creates a secure temporary workspace directory with restricted permissions.
*
* @returns {Promise<{path: string, cleanup: () => Promise<void>}>} Directory path and cleanup function
*/
async function createSecureWorkspace() {
// IMPLEMENTATION HERE
}
module.exports = {
storeSecureConfig,
createSecureWorkspace
};Provides temporary file and directory creation with permission control.
Provides file system operations for writing configuration data.
Install with Tessl CLI
npx tessl i tessl/npm-tmp-promisedocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10