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

client-verification-trential-sdk

v0.0.2

Published

Installation

Downloads

6

Readme

Installation

npm install client-verification-trential-sdk

This SDK is supported on React only (on version 16 and above)


The Vendor Client will hit the following API and send payload to generate a session token

Backend API call

curl --location --request POST '
https://api.trential.dev/verification/api/1.0/transactions/start-group-verification'
\
--header 'x-api-key: TRENTIAL_ORG_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "verificationNameList": ["aadhaar","dl","passport"]
}'

Response

{
    "code": 0,
    "message": "Success",
    "data": {
        "transactionId": "660bef7e6bbda02fb731b850",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmd1aWQiOiI2NTk0MGJkYjliMjcxZDdlMTIzYTkwY2MiLCJncm91cFR4bklkIjoiNjYwYmVmN2U2YmJkYTAyZmI3MzFiODUwIiwidHlwZSI6ImFjY2VzcyIsImlhdCI6MTcxMjA1ODI0NSwiZXhwIjoxNzEyMDYwMDQ1fQ.zBuW6aW4QdwZF2oLC1ZUqRuKq3h0ZfdpJlFYbbXpt7Q"
    }
}

On receiving the response, inject the token in the client SDK as follows

import { ClientVerificationUI } from '@trential/client-verification-sdk'

// component
<ClientVerificationUI
    token={"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvcmd1aWQiOiI2NTk0MGJkYjliMjcxZDdlMTIzYTkwY2MiLCJncm91cFR4bklkIjoiNjYwYmVmN2U2YmJkYTAyZmI3MzFiODUwIiwidHlwZSI6ImFjY2VzcyIsImlhdCI6MTcxMjA1ODI0NSwiZXhwIjoxNzEyMDYwMDQ1fQ.zBuW6aW4QdwZF2oLC1ZUqRuKq3h0ZfdpJlFYbbXpt7Q"}
    onSuccess={()=> successHandler()}
    onError={()=> errorHandler()}
/>

The ClientVerificationUI component can be rendered anywhere but it is best suited inside a modal view which will provide a better user experience

The token will be used to start the session and all the verifications will be listed accordingly

| Props | Description | Type | |------------|-----------------------------------------------------------|----------| | token | Required to start the session | string | | disclaimer | Rendered on Aadhaar Card Verification Screen | string | | onSuccess | Function called on successful verification | function | | onError | Function called on verification error | function |


Example Code

import axios from "axios";
import React from "react";
import { ClientVerificationUI } from "client-verification-trential-sdk";

function TrentialDemo() {
  const [token, setToken] = React.useState();

  // generate session token
  const generateSessionToken = async () => {
    const response = await axios({
      url: "https://api.trential.dev/verification/api/1.0/transactions/start-group-verification",
      method: "POST",
      headers: {
        "x-api-key": "8d388308-4023-4f83-94a3-9351c72a6690",
      },
      data: {
        verificationNameList: ["aadhaar", "dl", "passport"],
      },
    });
    if (response?.data?.data) {
      setToken(response?.data?.data?.token);
    }
  };

  const invokeSDK = () => {
    if (!token) {
      generateSessionToken();
    }
  };

  return (
    <div className="App">
      <div class="modal fade" id="myModal" role="dialog">
        <div class="modal-dialog">
          <div class="modal-content">
            {token && (
              <div style={{ margin: 20 }}>
                <ClientVerificationUI
                  onError={() => {}}
                  onSuccess={() => alert("hey")}
                  verifications={["aadhaar", "passport", "drivingLicense"]}
                  token={token}
                  disclaimer="I provide my consent to share my Aadhaar Card with Hudini"
                />
                <p style={{ marginTop: 20 }}>
                  Powered by{" "}
                  <img
                    src="https://storage.googleapis.com/indisi-wallet-app/trential-logo-white-bg.png"
                    style={{ height: 40, width: "auto" }}
                  />
                </p>
              </div>
            )}
          </div>
        </div>
      </div>
      <h1>Client Verification SDK Testing Sandbox</h1>
      <button
        type="button"
        style={{ backgroundColor: "rgb(4,77,160)" }}
        onClick={() => invokeSDK()}
        class="btn btn-info btn-lg"
        data-toggle="modal"
        data-target="#myModal"
      >
        Invoke SDK
      </button>
      <br />
      <div>
        <p>token - {token ? "Intialised" : "Not Initialised"}</p>
      </div>
    </div>
  );
}

export default TrentialDemo;

Update on Upcoming SDK Version

🚀 More customization is on the way in client-side verification SDK:-

  1. The developer would have an option to choose m out of n verifications, that is the choice for developers to pick specific verifications from a set.

  2. The developer would be able to set conditions whether to restart the verification whenever the client-verification-sdk is invoked or re-use earlier session