How do I add a new encrypted value to the configuration?
Objective: This article explains how to add a new encrypted value to the platform configuration.
Prerequisites:
- You have access to the encryption keys (Backend Secrets in LastPass).
Steps:
- In
components/configuration/builder.spec.ts
.- Use the
it('Encrypt', ...
test to encrypt the value(s) using the encryption keys. - Run the test and copy the encrypted values in the console.
- UNDO YOUR CHANGES; DO NOT COMMIT ENCRYPTION KEYS.
- Use the
- Open
components/configuration/configuration.ts
. - Append the encrypted value(s) you want to add using the following format:
{
encrypted: true,
default: '...', // <-- Dev/UAT
prod_sandbox: '...'
}
- Open
components/configuration/types.ts
. - Append the properties and/or interfaces that match the values you added to the
IConfiguration
interface.
Example:
Usage:
import { configuration } from '@hectare/platform.components.configuration'
...
configuration.myValue // This will be unencrypted at runtime
Related Articles: