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

tfa-node-sdk

v2.6.3

Published

Telegram Factor Authentication node library

Downloads

11

Readme

Telegram Factor Authentication - Node SDK

Node SDK document is in docs.tfasoft.com

If you are using TFA as your authentication service in your node applications, you can use our package.

How to use the package

So, let's have a quick review of our steps.

  • Installation
  • Configuration
  • Checking result

Installation

The easiest step is installation. You can install it with npm. Just go ahead and enter the command below:

$ npm i tfa-node-sdk

Congratulations! First step is done!

Configuration

After installation, go to your file and import the package:

const tfa = require('tfa-node-sdk');

Second, you need to epecify the accecc_token. You can get it in your dashboard panel. So, call the class:

const auth = new tfa('access_token');

Ok, now package know your access token. Now it's time to enter the user_token. User token is the code you get it from your form field or a post method. Importent is to get user token. So, we use authUser function to pass user token and get the result.

const result = auth.authUser('user_token');

You are done it this step. Let's move forward and check status codes and check user result.

Checking result

When you get the result, you have to use then and go for other stuff. Let's use then like this:

result.then((result) => {
    const data = result.data;
    const statCode = result.status;

    if (statCode === 200) {
        const user = data.user;
        console.log(user);
    } else {
        console.log(data.message);
    }
});

This was just knowing status codes. If you don't know them now, check out our docs and read them, and know what are result of every status code.

Ok, 800 and 290 just return you an 2 lenght object. One is error and second is message. But 800 doesn't return you a message. You check the stat, if it was 800, second item is user. User item is the user data that telegram uid is stored there and you can use it.

Returned Objects

Here let's know about them in deep.

  • 200

{
    "user": {
        "_id": "document id",
        "uid": "telegram user id",
        "token": "one time token. Every time become null",
        "createdAt": "when created",
        "updatedAt": "last update",
        "__v": 0
    }
}
  • 401

One is access token is wrong.

{
    "message": "User authentication token is not valid"
}

Another is when user token is wrong.

{
    "message": "Admin access token is not valid"
}

Development

If you want to develop the package, it is so simple. just follow steps below.

  • Link package
  • Test

Before you start: **Remember the base or codes are stored in lib/tfa.js. You need to edit there.

Link package

We asoume you are in tfa-node-sdk directory. Right. You can open a tmux or in another terminal to cd in test directory.

In tfa-node-sdk directory enter link command:

$ npm link

So, in other terminal, or other tmux part, link your development package to your test directory. If you are in the test directory ok, if not, just say cd test and enter the linking command:

$ npm link tfa-node-sdk

Linking step is done.

Test

Your test app is linked. Change anything in package and test it in test directory.