HMAC (Hash-based Message Authentication Code) is off by default. Turn it on before you ship. Web Chat can require up to three hashes, controlled by two dashboard toggles.
| Hash | Toggle | Input | Where the client passes it |
|---|---|---|---|
subscriberHash | Novu In-App integration | subscriberId | NovuProvider |
contextHash | Novu In-App integration | context | NovuProvider, only when you pass context |
agentHash | Web Chat integration | agent identifier | useWebChat |
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.
Generation recipes (Node.js, Python, and more): Secure your Inbox with HMAC.
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 a context (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.
| Novu In-App HMAC | What you pass to NovuProvider | ctx.context in your agent |
|---|---|---|
| On | context and contextHash | The context |
| Off | context | null. The context is not forwarded. |
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.
To compute 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.