Closed generalpiston closed 4 years ago
@Destreyf awesome! I think it makes sense to add this to the README as a guideline on how to handle secrets for this library.
I agree that file based config seems unnecessary and outside the scope of the library IMO.
Also it guides library consumers to wrong security decisions. I don't think you should be storing encryption keys in files anyways.
@moltar and @Destreyf let's adjust this issue to be a README update based on guidance from @Destreyf
@generalpiston This can be closed.
I just started using this library, and am happy to say that it's working great for me.
I do not believe that there needs to be any special treatment for a file based config and I've outlined my approach below using the library as is (in NPM).
Create a typescript file that exports the config for the
EncryptionTransformer
and just use it directly, so in my case i have the following:encryption-transformer-config.ts
And i use it by importing into my entity
MyEntity.ts
This allows me to use a unified configuration based on secrets that i'm already using in other places within my application and I can quickly change out config values across the platform for testing.
You could also easily add overrides per entity, imagine i added a second property to the above entity.
The power of the spread operator allows a ton of flexibility when dealing with these use cases.