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

@berlinsms/react-twofa-component

v3.0.4

Published

A Two Factor Authentication by BerlinSMS written in typescript- https://www.berlinsms.de/

Downloads

18

Readme

@berlinsms/react-twofa-component is a TypeScript React Component to validate Phonenumbers or E-Mail Adresses using a Two Factor Authentification.

BerlinSMS

Install the package using

npm -i @berlinsms/react-twofa-component

Usage

The Mail and SMS verification are now located in the same Component. The Component will automaticly switch to the previously selected verificationmehtod (https://twofa.berlinsms.de/keygen).

import {TwoFA} from '@berlinsms/react-twofa-component';

// Minimal implementation:
<TwoFA
    bsmsSitekey = {"your sitekey"}
/>

// Complete implementation: 
<TwoFA
    ref={twoFARef}                    
    bsmsSitekey = {"your sitekey"}
    onError = {TwoFAonError}
    onVerify = {TwoFAonVerify}
    onExpire = {TwoFAonExpire}
/>

Parameters

To use this Component you have to configure your settings on https://twofa.berlinsms.de/keygen

By using the required bsmsSitekey Parameter your site will be validated and load all predefined settings. This Component will request your selected verification method and automaticly load the predefined configuration. Therefore it is not necessary to switch manualy between Mail-verification and SMS-verification. These settings also contain your captcha Type and Key.

The ref Parameter helps the user to keep track of the current object. By creating a reference additional informations can be gathers as for example the states. All of the state codes can be seen in the TwoFATypes.tsx file and are described below.

The onError function is called if an Error occures. This might be for example that component cant reach the API or the user has no more tries left. The function requires a error: string parameter, that describes the error.

The onVerify function is called when the user correctly entered the code and now your own webserver can validate the user request. The token (string) Parameter is required and is needed for the final verification. Optionally the inserted Two Factor Code can be requested: code?: string

The Language can be set by using the optional Parameter: bsmsLanguage. (bsmsLanguage?: "Eng" | "Ger";) This Parameter takes the values "Eng" or "Ger" (German). Default Language is German.

OnExpire is called when the time to fill out the component is run out. This function is still under development.

Status Codes

TwoFA Component

verificationType: verificationTypes; // gets the selected verification method (optin(sms) or optin(mail)
apiReady: boolean; // checks if the BerlinSMS API is reachable 
isAddressValid: boolean; // Checks whether an SMS/Mail can be sent to the phonenumber
codeReady: boolean; // The user clicked on send Code -> to send a code the user has to solve the captcha, which will send the code
codeSend: boolean; // The code was send via SMS to the entered Phonenumber
codeVerified: boolean; // This will be true if the inserted code is correct (onVerify will be called)
errorOccured: boolean; // This will be true if an error occured (onError will be called)
errorMessage: string; // This gives additional error feedback and shows it in the component
// internal status codes
renderstatus: renderStatusTypes; // states for the state machine to render the content
captchaSitekey: string; // The current captchaSitekey
captchaType: "reCaptcha" | "hCaptcha"; // what captchatype will be used
captchaToken: string; // Captchatoken when the captcha is solved
validationCode: string; // current userinput of the validation code
challengeToken: string; // challengeToken used for the BSMS TwoFA challenge
// internal variables
limitAttempts: number; // signals how many tries the user has left to solve the TwoFA Challenge
verificationAddress: string; // phonenumber/mailaddress the user has entered and send a code to