I am new to Salesforce B2C. I need to use the bcrypt dependency in a Controller, but I can't get it installed on the cartridge. I am not sure if this is possible. If it is not possible. Is there a Salesforce dependency that allows me to do what the "bcrypt.hash (pass, salt)" function would do? Thanks and sorry if there is something misspelled, I don't speak too much English
2 Answers
Unfortunately, bcrypt is written in C++. Node.JS can work with this, but not the server-side engine (Rhino) that Salesforce Commerce Cloud B2C runs on.
All supported functions related to cryptography is located in these packages:
Note: It might be possible to re-engineer, but start from a Java example as SFCC runs in Java with a JS -> Java interpreter (Rhino) in between.
You have to use sgmf-scripts: https://www.npmjs.com/package/sgmf-scripts. It's a package for SFCC that allows to build a custom SFRA cartridge app with node.js.
So you can create an app with node.js + bcrypt + sgmf-scripts. Just make sure the app is designed to override the core/default scripts where you need bcrypt.