Skip to main content

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:

  1. 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.
  2. Open components/configuration/configuration.ts.
  3. Append the encrypted value(s) you want to add using the following format:
{
encrypted: true,
default: '...', // <-- Dev/UAT
prod_sandbox: '...'
}
  1. Open components/configuration/types.ts.
  2. 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: