Installation and usage

The Tanker Identity SDK is distributed as the @tanker/identity npm package.

npm install @tanker/identity

Note

This documentation uses flow type annotations.
The custom b64string type represents binary data encoded in a Base64 string.

Create identity

Create a new Tanker identity. This identity is secret and must only be given to a user who has been authenticated by your application. This identity is used by the Tanker client SDK to open a Tanker session.

function createIdentity(appId: b64string, appSecret: b64string, userId: string): Promise<b64string>
Parameters
appId: b64string The app ID, you can access it from the Tanker dashboard
appSecret: b64string The app secret, secret that you have saved right after the creation of your app
userId: string The unique ID of a user in your application
Returns
Promise<b64string> An identity

Provisional identity

Create a Tanker provisional identity. It allows you to share a resource with a user who does not have an account in your application yet. It must be served to an authenticated user, and attached client-side to access the resource. You will need to verifiy the associated email.

function createProvisionalIdentity(appId: b64string, email: string): Promise<b64string>
Parameters
appId: b64string The app ID, you can access it from the Tanker dashboard
email: string The email associated with the provisional identity
Returns
Promise<b64string> A provisional identity

Public identity

Return the public identity from an identity or a provisional identity. This public identity can be used by the Tanker client SDK to share encrypted resources.

function getPublicIdentity(identity: b64string): Promise<b64string>
Parameters
identity: b64string An identity or a provisional identity
Returns
Promise<b64string> A public identity