I would opt for a server-side solution, not a JavaScript one. As JavaScript is a client-side language, it is not suitable for handling sensitive data, as passwords, codes, private/secret issues....