Recognising signed-in customers
Show your signed-in customers’ real names in the inbox, verified by your server.
Your server signs the customer’s id with your site’s secret key, using HMAC-SHA256, and puts the result on the script tag. A hash that does not match is rejected, so nobody can pretend to be one of your customers.
Example
const hash = crypto.createHmac('sha256', process.env.XACUBE_SECRET_KEY)
.update(String(user.id)).digest('hex')
<script src=".../w.js" data-key="YOUR_PUBLIC_KEY"
data-user-id="USER_ID" data-user-hash="HASH"
data-user-name="NAME" data-user-email="EMAIL" async></script>Keep the secret key secret
It belongs on your server, in an environment variable. Never put it in a page or in browser code. The install guide for each server platform shows the exact code.