All hashes use the environment API secret from API Keys. Compute them on your server. Do not compute them in the browser.
Pass the hashes for the toggles that are on. With Novu In-App HMAC on,
subscriberHash is always required, and contextHash is required whenever you pass context.
subscriberHash
subscriberHash authenticates the signed-in subscriber. Without it, another person can guess a subscriberId and open that subscriber’s session, including Web Chat.
If Security HMAC encryption is on for Novu In-App, pass subscriberHash to NovuProvider. The hash is HMAC-SHA256(secretKey, subscriberId) as a lowercase hex string.
agentHash
agentHash authenticates which agent the subscriber can talk to. Without it, a client can send any public agent identifier that is linked to Web Chat.
If Security HMAC encryption is on for Web Chat:
- Open Integrations.
- Select the Web Chat integration.
- Enable Security HMAC encryption.
- On your server, compute
HMAC-SHA256(secretKey, agentIdentifier)as a lowercase hex string. - Pass that value as
agentHashtouseWebChat.
Context
You can pass acontext (for example, tenant) to NovuProvider. Your agent receives it as ctx.context on Web Chat turns only when Security HMAC encryption is on for Novu In-App.
With HMAC off, any client could send any context, so Novu does not pass it to your agent. With HMAC on, Novu rejects a session whose
contextHash does not match its context.
Before your agent uses the context to scope what it reads and changes:
- Trust the context
id, not itsdata. Novu sends thedatastored on the context, not thedatayou signed. That storeddatawas written when the context was first created, by your server through the Contexts API or by an earlier session. Look up anything else you need on your server, from theid. - Check that the subscriber belongs to that tenant. A
contextHashis the same for every subscriber, so a subscriber who has another tenant’s hash can reuse it. - Handle both value shapes. Each context value is either
{ id, data }or, when it has nodata, theidas a plain string.
contextHash on your server, see Secure your Inbox with HMAC.
Every active Novu In-App integration in the environment must have HMAC on. If one does not,
ctx.context stays null on Web Chat.