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

typingdna-verify-client

v1.0.2

Published

TypingDNA Verify Client

Downloads

151

Readme

TypingDNA Verify JavaScript Client

Usage and description

TypingDNA Verify helps you replace SMS 2FA codes with better UX: Just type 4 words!

Initializing the client

Firstly, you need to install the latest version of the client. This can be done using npm:

npm install --save typingdna-verify-client

Then import the TypingDNAVerifyClient class and creat a client object:

const TypingDNAVerifyClient = require('typingdna-verify-client');
...
const client = new TypingDNAVerifyClient({
    applicationId: 'APPLICATION_ID',
    clientId: 'CLIENT_ID',
    secret: 'SECRET',
});

The CLIENT_ID and SECRET can be found in the Verify dashboard of your TypingDNA account. The APPLICATION_ID will be generated when you create a new integration. For more information see the Initial Setup section of the TypingDNA Verify documentation.

Getting the user data that will be passed to the frontend

To authenticate a user, his/her phone number or email address or both must be passed to the TypingDNAVerifyClient.

Once initialized, the next step is to retrieve end-user data in the backend, for encryption and linking with the frontend button.

The getDataAttributes method is called to pass credentials and encrypted user data to the frontend snippet. Both the language and flow are optional parameters, defaulting to ‘EN’ and ‘STANDARD’ respectively. Support for additional languages is in progress.

const typingDNADataAttributes = client.getDataAttributes({
        email: "userEmail",
        phoneNumber: "userPhoneNumberWithCountryCode",
        language: "EN",
        flow: "STANDARD",  // "SHOW_OTP" alternatively
});

Validating an OTP received from the user

To validate an OTP received from the user simply call the validateOTP method.

const response = await client.validateOTP(
    {
        email: "userEmail",
        phoneNumber: "userPhoneNumberWithCountryCode",
    },
    "otpCode"
);

Manually sending an OTP

To manually send an OTP call the sendOTP method. This method manually triggers the sending of a verification code to the user’s email or phone. This bypasses the Verify window’s typing verification flow, and is useful for scenarios in which users cannot type to confirm their identity, such as access via a mobile device.

const response = await client.sendOTP({
    email: "userEmail",
    phoneNumber: "userPhoneNumberWithCountryCode",
});

Reference:

  • TypingDNAVerifyClient:
    • new TypingDNAVerifyClient(config):
      • config {Object}:
        • applicationId {String} - found in the TypingDNA Verify dashboard after creating an integration
        • clientId {String} - found in the TypingDNA Verify dashboard
        • secret {String} - found in the TypingDNA Verify dashboard
    • TypingDNAVerifyDataAttributes getDataAttributes(config):
      • config {Object}
        • email {String?} - user email
        • phoneNumber {String?} - user phone number with country code
        • language {String?} - (default "EN") the language code. All the supported languages can be found in the Verify documentation
        • flow {String?} - (default "STANDARD") "STANDARD" or "SHOW_OTP". For more information on the difference between these two flows check the Verify documentation
    • TypingDNAValidateOTPResponse validateOTP(config, code):
      • config {Object}
      • email {String?} - user email
      • phoneNumber {String?} - user phone number with country code
      • code {String} - the OTP code received from the user
    • TypingDNASendOTPResponse sendOTP(config):
      • config {Object}
        • email {String?} - user email
        • phoneNumber {String?} - user phone number with country code
  • TypingDNAVerifyDataAttributes:
    • clientId {String} - found in the TypingDNA Verify dashboard
    • applicationId {String} - found in the TypingDNA Verify dashboard after creating an integration
    • payload {String}
  • TypingDNASendOTPResponse:
    • success {number} - 1 or 0
    • code {number} - the TypingDNA Verify response code
    • message {String} - a description of the outcome of the operation
    • status {number} - the HTTP status code
    • otp {String?} - the OTP code sent to the user
  • TypingDNAValidateOTPResponse:
    • success {number} - 1 or 0
    • code {number} - the TypingDNA Verify response code
    • message {String} - a description of the outcome of the operation
    • status {number} - the HTTP status code