The stable customer ID
claims.sub is a stable ID for this customer at your site. The same person gets the same ID on every visit. Another site gets a different ID for the same person.
- Store it against the customer’s account.
- On the next visit, look it up in your own database.
- If you find it, this is a returning customer.
Hashes
A credential can share a value as a hash instead of in plain text, for examplehashes.email. The hash looks like sha256:<hex>.
- Hash the value you have on file with the SDK.
- Compare it with the shared hash.
- If they match, the customer’s value is the same as yours, and you never received the plain text.
The KYA SDK is coming soon. The packages aren’t published yet, so the code below won’t run until they are.
Baselayer fills in
hashes.ssn from its own verification, and in Baselayer’s hosted flow the person never types an SSN. ssnHash is only for matching against an SSN you already hold on file.
A few details:
- Phone numbers without a country code are read as US numbers.
- Address fields are all optional.
countrydefaults to"US". Pass the parts you have, already in standard USPS form. - EIN and SSN keep digits only, so
12-3456789and123456789hash the same. - In TypeScript every hash function is async. In Python they are not.
Linking an agent to an existing account
As the warning above says, a matching hash is not proof of ownership. Email addresses get recycled, and the credential does not say the email is still theirs.
Before allowing sensitive actions, you can also require specific checks with
claims.attests(key), such as:
claims.attests("watchlist_clear")for a clear watchlist resultclaims.attests("phone_possession")for a confirmed phone
Next steps
- Handling Failures: know why a credential was refused and what to tell the agent.
- Business Agents: check an agent acting for a business.