Identity verification for the messenger

How OctaDezx identity verification works: a short-lived HS256 user token signed on your server proves a signed-in user to the messenger, unlocking their own orders, attributes and push. Available at version 0.1.

Status: available (v0.1). Messenger SDKs run on the customer's device, so anything they say about who the user is can be edited. OctaDezx identity verification lets your server prove a signed-in user with the business's identity secret. The recommended proof is a user token: an HS256 JWT with the user id, an issue time and an expiry of at most 24 hours, optionally carrying a verified email. The SDKs refresh it before it expires. An older user hash, an HMAC of the user id that never expires, is still accepted unless the business requires tokens. OctaDezx verifies either inside the database, where the secret is stored encrypted, so the secret never reaches the device. A verified user can ask about their own orders and bookings and can store attributes, events and push tokens; anyone else stays anonymous. Identity verification, with both tokens and hashes, is available at version 0.1, and signUserToken ships in @octadezx/sdk.

How it works

  • OctaDezx issues your business an identity secret (odxis_...). It lives on your server only.
  • When a signed-in user loads your site or app, your server signs a user token: an HS256 JWT with sub (the user id), iat and exp, at most 24 hours long, optionally with email, name and attributes.
  • You pass it to the messenger as userJwt, with a refreshToken callback that fetches a new one. The SDK refreshes a minute before expiry without signing the user out.
  • OctaDezx verifies the token inside the database: exactly HS256, the signature first, then the claims, with 60 seconds of clock skew. The secret never travels to the edge function or the device.

Token

header   { "alg": "HS256", "typ": "JWT" }
payload  { "sub": "u_123", "iat": 1793786400, "exp": 1793790000, "email": "jo@example.com" }
signed   HMAC-SHA256( key = utf8(identity secret), message = base64url(header) + "." + base64url(payload) )

What verification changes

A browser that only types an email into the chat stays anonymous, whatever it typed. This is enforced in the database, not in the client. WhatsApp, Instagram, Messenger, email, voice and the server Agent API are unaffected, because those identities come from a platform or from your server.

Anonymous (no proof, or a wrong or expired one)Verified
ChatWorks normallyWorks normally
Order and booking lookupsOnly those made in this conversationThe user's own orders and bookings, by contact, email or phone
Attributes and eventsNot storedStored on the user's contact
Push registrationRefusedAllowed
Customer history in repliesOnly what this conversation createdThe user's
InboxAnonymous visitorLinked to the user's contact

Sign a token and pass it

Node.js

import { signUserToken } from "@octadezx/sdk";
const token = signUserToken(user.id, process.env.OCTADEZX_IDENTITY_SECRET, { ttlSeconds: 3600, email: user.email });

Python

from octadezx import sign_user_token
token = sign_user_token(user.id, os.environ["OCTADEZX_IDENTITY_SECRET"], ttl_seconds=3600, email=user.email)

Messenger

OctaDezx.boot({ businessId, userJwt: await fetchToken(), refreshToken: fetchToken });

Tokens, hashes and requiring tokens

Once all your clients send tokens, switch the business to token_required so a leaked hash is useless. hash_or_token is the default.

User token (recommended)User hash (older)
ExpiresYes, at most 24 hours after it is issuedNever, until the secret rotates
Carries a verified emailYesNo
Accepted when tokens are requiredYesNo

Rotation and sign out

Rotating creates a new secret and keeps the previous one valid for a grace window, 24 hours by default and up to 168. Tokens and hashes signed with either verify during the window. Deploy the new secret within the window, or revoke the old one immediately after a leak.

Call shutdown() when the user signs out. A conversation bound to one user is never rebound to another, so the next person on the same device starts fresh.

Things to know

  • A token or hash is a bearer credential for that user. Serve it only to that user, over HTTPS, and never log it. A token limits a leak to its lifetime, so keep it short and rely on refreshToken.
  • Only a token's email claim is verified. An email passed to the messenger any other way is not used to identify anyone.
  • Tokens with alg none, any other algorithm, a tampered payload, the wrong secret, an issue time in the future or a lifetime over 24 hours are refused.
  • Never ship an odx_ API key in a browser or app.

Install

@octadezx/sdk (available, v0.1.0, MIT license)

Server SDK for Node.js 20 and newer: Agent API with streaming, signed user tokens, webhook verification and devices.

npm install @octadezx/sdk

@octadezx/sdk on npm

@octadezx/messenger (available, v0.1.0, MIT license)

Web messenger SDK, with React bindings at @octadezx/messenger/react.

npm install @octadezx/messenger

@octadezx/messenger on npm

Questions or a larger rollout? Contact us (kevin@octadezx.com).

Frequently asked questions

Keep reading

OctaDezx home · Pricing · Blog · Start free trial