npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tanker/identity

v3.3.1

Published

Tanker Identity SDK

Downloads

346

Readme

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

API

createIdentity(appId, appSecret, userId);

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.

appId The app ID. You can access it from the Tanker dashboard.

appSecret The app secret key. A secret that you have saved right after the creation of your App.

userId The ID of a user in your application.

createProvisionalIdentity(appId, 'email', email);

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.

appId The app ID. You can access it from the Tanker dashboard.

email The email of the potential recipient of the resource.

getPublicIdentity(tankerIdentity);

Return the public identity from an identity. This public identity can be used by the Tanker client SDK to share encrypted resource.

tankerIdentity A Tanker identity.

Usage

The server-side code below demonstrates a typical flow to safely deliver identities to your users:

import { createIdentity } from '@tanker/identity';

// Store these configurations in a safe place
const appId = '<app-id>';
const appSecret = '<app-secret>';

// Example server-side function in which you would implement checkAuth(),
// retrieveUserIdentity() and storeUserIdentity() to use your own authentication
// and data storage mechanisms:
async function getUserIdentity(userId) {
  const isAuthenticated = checkAuth(userId);

  // Always ensure user is authenticated before returning a user identity
  if (!isAuthenticated) {
    throw new Error('unauthorized');
  }

  // Retrieve a previously stored user identity for this user
  let identity = retrieveUserIdentity(userId);

  // If not found, create a new user identity
  if (!identity) {
    identity = await createIdentity(appId, appSecret, userId);

    // Store the newly generated user identity
    storeUserIdentity(userId, identity);
  }

  // From now, the same user identity will always be returned to a given user
  return identity;
}

Read more about user identity in the Tanker guide.