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

@resistantai/resistant-documents-client

v3.3.0

Published

Client library to connect to Resistant Documents service.

Downloads

2,518

Readme

Resistant documents client

This library provides a Typescript client for a Resistant.AI document forgery analysis service. For a detailed description of the API please see API reference docs.

Prerequisites

During the customer onboarding process, you should be provided with the following:

  • CLIENT_ID : str
  • CLIENT_SECRET : str

Note: Those credentials are connected with specific environment (e.g. test, production etc.). Together with secret credentials for non-production environment you should be provided with the following URLs:

  • API_URL
  • TOKEN_URL

TOKEN_URL is used to authenticate with an identity provider, this library does not use it. Once authenticated, use `Bearer ${accessToken}` as API key.

Installation

Package can be installed using npm:

$ npm add @resistantai/resistant-documents-client

Usage

Import and init

Package can be imported as

import ResistantDocumentsApi from "@resistantai/resistant-documents-client";

or in Node as

const ResistantDocumentsApi = require("@resistantai/resistant-documents-client");

Client instance can be then initialized using

const client = new ResistantDocumentsApi(() => "YOUR_API_KEY", API_URL);

or if you wish to use it against the production environment you can skip the second parameter:

const client = new ResistantDocumentsApi(() => "YOUR_API_KEY");

Examples

Submit document for analysis and wait for results

client.analyze(file).then(results => console.log(results));

Information about original file name is not stored in the backed. You can manually store this information using query_id parameter:

client.analyze(file, file.name).then(analysisResponse => console.log(analysisResponse));

Provided query_id is always returned with AnalysisResponse.

Submit document and fetch results manually

client.submit(file, file.name)
    .then(submissionId => client.results(submissionId))
    .then(analysisResponse => console.log(analysisResponse));

Analysis is asynchronous, therefore the client needs to poll for the result until it is available. If desired, it is possible to change number of retries when fetching the result:

client.submit(file, file.name)
    .then(submissionId => client.results(submissionId, 10)) // will retry at most 10 times
    .then(analysisResponse => console.log(analysisResponse));

Submit document and fetch fraud analysis results, parsed content and quality information

Besides analysis result, one can also fetch quality information for the submitted document, if quality analysis was requested. By default, only fraud analysis is performed. To also request quality analysis, the submit method accepts an additional argument

// will perform quality and fraud analysis
const submissionId = await client.submit(file, PipelineConfiguration.QUALITY_AND_FRAUD)

// will perform only quality analysis
const submissionId = await client.submit(file, PipelineConfiguration.QUALITY_ONLY)

// TODO: what does this do?
const submissionId = await client.submit(file, PipelineConfiguration.CONTENT_AFTER_FRAUD_AFTER_QUALITY) 

Analysis, quality and content results can then be fetched as follows:

const analysisResponse = await client.results(submissionId); 
const qualityResponse = await client.quality(submissionId); 
const contentResponse = await client.content(submissionId); 

Please note that parsing content is available only for selected document types.

Download submitted file

Once file has been submitted, it can be downloaded as long as its retention period hasn't expired, after which it is permanently deleted.

const submissionId = await client.submit(file);
const rawFileContent = await client.data(submissionId);