I have a set up like this: Payment Server (PS) <> Front End (FE) <> Client JS.
I need to get some data from the Client JS to the PS, without the FE being able to modify it and have PS prove that correct. In this situation, the FE acts as store and forward (with some basic validation of the payload).
This is my plan:
When setting up their account, the user enters a PIN. This is hashed by the JS and the hash sent to the PS via FE for storage. It is not stored in the FE and PIN itself not seen by PS or FE in plain.
When required, the JS creates the JSON payload as normal. The user enters their PIN and this is hashed in the same way as when created.
JS takes the payload, the hashed PIN and nonce (which was previously sent by the server in an initial communication), and creates a HMAC-SHA256. This is sent, alongside the payload, to FE, validated/sanitised and then forwarded to PS untouched.
PS checks HMAC-SHA256 is unmodified, authenticated and nonce is unused, using own stored PIN hash.
When PS returns back to the JS with it's own result, it can do the same thing and JS can confirm the return is also authentic and unmodified.
Does this sound viable? I am aware a PIN is generally quite short, say 4 characters minimum. Is there anything I can do to help strengthen that?