otp-token-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Otp Token SDK

This library provides functionality to work with OTP (One-Time Password) tokens. It includes methods for registering new secrets, generating OTP tokens, stopping the token generation process, adding event listeners, and emitting events.

Installation

To use this library, you can import it using the following statement:

import { OtpToken } from 'path/to/OtpToken';

Usage

Initialization

To initialize the OtpToken class, you can use the init method:

const otpToken = OtpToken.init({
  hostUrl: 'https://example.com',
  origin: 'example',
  timeout: 300,
});

Registering a New Secret

To register a new secret, you can call the register method:

otpToken.register({
  referenceId: 'exampleId',
  bearerToken: 'exampleToken'
  onSuccess: (secret) => {
    console.log('Secret registered:', secret);
  },
  onError: (error) => {
    console.error('Error:', error);
  },
});

Generating OTP Token

To generate an OTP token, you can use the run method:

otpToken.run('yourSecretKey');

Adding Event Listeners

You can add event listeners for 'tick' and 'update' events using the on method:

const unsubscribe = otpToken.on('tick', (data) => {
  console.log('Tick event:', data);
});

Stopping Token Generation

You can stop the token generation process by calling the stop method:

otpToken.stop();

Readme

Keywords

Package Sidebar

Install

npm i otp-token-sdk

Weekly Downloads

1

Version

1.2.0

License

UNLICENSED

Unpacked Size

32.6 kB

Total Files

8

Last publish

Collaborators

  • murilosandiego