Node reference
Import from @cusuai/node. Integrators usually need only identifySign.
identifySign
import { identifySign } from "@cusuai/node";
const identity = identifySign({
isk: process.env.CUSU_IDENTIFY_SECRET,
visitorId,
externalId: customer.id,
traits: {
name: customer.name,
email: customer.email,
phone: customer.phone,
gender: customer.gender
}
}); | Field | Required | Description |
|---|---|---|
isk | yes | Identify secret, isk_… |
visitorId | yes | From the browser cookie cusu_vid |
externalId | yes | Your customer id, from the session |
traits | no | name, email, phone, gender |
signedAt | no | Unix milliseconds. Defaults to now. Omit it in production. |
Empty isk, visitorId, or externalId throws. signedAt must be a safe integer. The return value always includes externalId, signedAt, and signature, plus any trait you passed.
gender on the signed payload is male, female, or other. The helper forwards the string you pass. Cusu accepts those three values.
Other exports
| Export | What it does |
|---|---|
signIdentify(secret, payload) | Hex HMAC for a payload you already built. |
verifyIdentify(secret, payload, signature, signedAt, now?) | true when the signature matches and signedAt is within five minutes of now. |
buildCanonicalIdentifyPayload(payload) | The exact text that is signed. See Identify. |
generateIdentifySecret() | A new isk_… value. The app can create one for you. Prefer that. |
IDENTIFY_SIGNATURE_MAX_AGE_MS | Five minutes. It matches the Cusu service. It is not an environment variable and not an argument of identifySign. |