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

@tsocial/trustvision-sdk

v2.11.2

Published

A SDK to interact with Trust Vision BE API

Downloads

931

Readme

Trust Vision JavaScript SDK

The JavaScript SDK of Trust Vision API

Using script tag

<script src="https://unpkg.com/@tsocial/[email protected]/dist/trustvision-sdk.umd.js"></script>
<script>
  // create and instance of API client with provided access key, secret key and environment
  // environment values should be testing, staging, production or the API URL
  const apiClient = new trustvisionSdk.default(
    'access key', // access key
    'secret key', // secret key
    'testing', // environment (testing, staging, production) or API URL
  );

  // start using services
  apiClient
    .clientSettings()
    .then((result) => {
        // result contains information about card types and other settings
    })
    .catch((error) => {

    });

</script>

Using NPM

// import API Client class
import TrustVisionAPI from '@tsocial/trustvision-sdk';


// create and instance of API client with provided access key, secret key and environment
// environment values should be testing, staging, production or the API URL
const apiClient = new TrustVisionAPI(
  'access key', // access key
  'secret key', // secret key
  'testing', // environment (testing, staging, production) or API URL
);

// start using services
apiClient
  .clientSettings()
  .then((result) => {
      // result contains information about card types and other settings
  })
  .catch((error) => {

  });

Services

Client settings

apiClient
  .clientSettings()
  .then((result) => {
      // please refer to API document for response's format
  })
  .catch((error) => {

  });

Upload image

API document

apiClient
  .uploadImage({
    file: imageFile, // file object
    imageLabel: 'portrait', // image label
  })
  .then((result) => {
      // please refer to API document for response's format
  })
  .catch((error) => {

  });

Compare faces

API document

apiClient
  .compareFaces({
    image1: {
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    },
    image2: {
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    }
  })
  .then((result) => {
      // please refer to API document for response's format
  })
  .catch((error) => {

  });

Verify face liveness

API document

apiClient
  .verifyFaceLiveness({
    images: [{
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    }, {
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    }],
    gestures: ['<image 1 gesture>', '<image 1 gesture>'], //array of expected gestures of the face in each image, optional
  })
  .then((result) => {
      // please refer to API document for response's format
  })
  .catch((error) => {

  });

Read ID card

API document

apiClient
  .readIDCard({
    card_type: 'card type', // card type of image
    image1: {
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    },
    image2: {
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    }, // optional
    qr1_images: [{
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    }], // array of uploaded back qr code, optional
    qr2_images: [{
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    }], // array of uploaded front qr code, optional
  })
  .then((result) => {
      // please refer to API document for response's format
  })
  .catch((error) => {

  });

Request verify ID card

API document

apiClient
  .requestVerifyIDCard({
    card_type: 'card type', // card type of image
    image1: {
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    },
    image2: {
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    }
  })
  .then((result) => {
      // please refer to API document for response's format
  })
  .catch((error) => {

  });

Request verify portrait

API document

apiClient
  .requestVerifyPortrait({
    image: {
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    }
  })
  .then((result) => {
      // please refer to API document for response's format
  })
  .catch((error) => {

  });

Search faces (Faces retrieval)

API document

apiClient
  .searchFaces({
    image: {
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    },
    collection: "", // index faces to this collection, optional
  })
  .then((result) => {
      // please refer to API document for response's format
  })
  .catch((error) => {

  });

Download image

API document

Example: Download an image and display it on a img HTML tag

const $img = document.getElementById('result'); // select an image tag with id result <img id="result" />
const imageId = 'd70b3fd3-253d-4e35-b2f7-fad564a36443';
apiClient.downloadImage(imageId)
  .then((dataURL) => $img.setAttribute('src', result));

Index faces

API document

apiClient
  .indexFaces({
    image: {
      id: '', //ID of the image in DB
      base64: '', //Base64 encoded text of image1 data
      label: '', //label of the image as described at Upload Image API
      metadata: {}, //any key-value metadata to save with the image, both key and value should be string
    },
    collection: "", // index faces to this collection, optional
  })
  .then((result) => {
      // please refer to API document for response's format
  })
  .catch((error) => {

  });

Update metadata

API document

apiClient
  .updateMetadata({
    "metadata": {} // any key-value metadata to save with the image, both key and value should be string,
    "label": '', //label of the image
    "override":  true, // boolean flag to allow override old metadata or not,
})
  .then((result) => {
      // please refer to API document for response's format
  })
  .catch((error) => {

  });