Custom Code Implementation for Vault
Following are the custom code implementation steps for external vault:
- Create a folder and initialize typescript project using command tsc –init from CMD.
NOTE:
- The folder name should be same as the vault name specified while adding the vault through API.
- Ensure created folder name is entered in small case.
- Create a type definition file named type.d.ts with the following content. This is also available at build location BUILD_ROOT/AddOns/AECredentialVaultCustomization/.
- Create a file <<vaultname>>-util.ts inside folder created in step1. See step1 for vault name and ensure the created file name is entered in small case.
- Create a class that implements interface IExternalVault. This interface will provide a method named fetchCredentialsImpl. This method is hooked to fetch credentials from any external vault and all the fetch logic should be inside this. This class should be exported (export: typescript keyword) from the file.
- etchCredentialsImpl method expects ExternalVaultInput as an input, this is a json object and will contain all the keys defined while adding the new vault through API.
- fetchCredentialsImpl returns ExternalVaultResponse object which contains username and password corresponding to input provided.
- Interface contract should be strictly followed. All the input and output object should be as per the type definition file.
Sample implementation for vault name ‘MyVault’ file name ‘myvault-util.ts’:
- Set target value as ‘ES2015’ in tsconfig.json file.
- Run command tsc from CMD. This should generate a JS file for the TS file created above.
- Copy the created folder (created in step 1) to location: ‘\AssistEdgeAutomation\app\Admin\util\externalVault\vaultimpl`.Remove .ts files from the folder.