Identity SDK
Tanker Identity generation in JavaScript for the Tanker SDK.
Installation
The preferred way of using the component is via NPM:
npm install --save @tanker/identity
Usage
The server-side code below demonstrates a typical flow to safely deliver identities to your users:
import { createIdentity } from '@tanker/identity';
const trustchainId = '<trustchain-id>';
const trustchainPrivateKey = '<trustchain-private-key>';
async function getUserIdentity(userId) {
const isAuthenticated = checkAuth(userId);
if (!isAuthenticated) {
throw new Error('unauthorized');
}
let identity = retrieveUserIdentity(userId);
if (!identity) {
identity = await createIdentity(trustchainId, trustchainPrivateKey, userId);
storeUserIdentity(userId, identity);
}
return identity;
}
Read more about user identity in the Tanker guide.