Giter Club home page Giter Club logo

verifier's Introduction

verifier gopher

coverage Maintainability

Verifier v0.1.0

Verifier package lets you verify emails & phone numbers, with customization available at different components. There's a functional (if provided with valid configurations) sample app provided here.

How does it work?

Verifier generates secrets with an expiry, appropriate for emails & mobile phones. In case of emails, it generates a 256 character long random alpha-numeric string, and a 6 character long numeric string for mobile phones.

By default, it uses AWS SES for sending e-mails & AWS SNS for sending SMS/text messages.

How to customize?

You can customize the following components of verifier.

    
    // Customize the default templates
    // there should be 2 string placeholders for email body. First is the 'callback URL' and 2nd is the expiry
    verifier.DefaultEmailOTPPayload = ``
    // there should be 1 string placeholder for SMS body. It will be the secret itself
    verifier.DefaultSMSOTPPayload = ``
    // ==

    vsvc, err := verifier.NewCustom(&Config{}, nil,nil,nil)
	if err != nil {
		log.Println(err)
		return
    }
    
    // Service provider for sending emails
    err := v.CustomEmailHandler(email)
	if err != nil {
        log.Println(err)
		return
    }
    // ==

    // Service provider for sending messages to mobile
	err = v.CustomMobileHandler(mobile)
	if err != nil {
        log.Println(err)
		return err
    }
    // ==
    
    // Persistent store used by verifier for storing secrets and all the requests
	err = v.CustomStore(verStore)
	if err != nil {
        log.Println(err)
		return
    }
    // ==

    // Using custom email & text message body
    verreq, err := vsvc.NewRequest(verifier.CommTypeEmail, recipient)
    if err != nil {
        log.Println(err)
        return
    }

    // callbackURL can be used inside the custom email body
    callbackURL, err := verifier.EmailCallbackURL("https://example.com", verreq.Recipient, verreq.Secret)
    if err != nil {
        log.Println(err)
        return
    }

    err = vsvc.NewEmailWithReq(verreq, "subject", "body")
    if err != nil {
        log.Println(err)
        return
    }

    err = vsvc.NewMobileWithReq(verreq, fmt.Sprintf("%s is your OTP", verreq.Secret))
    if err != nil {
        log.Println(err)
        return
    }
    // ==

TODO

  1. Unit tests
  2. Setup a web service, which can be independently run, and consumed via APIs

The gopher

The gopher used here was created using Gopherize.me. Verifier helps you keep those scammers and bots away just like our hacker gopher!

verifier's People

Contributors

bnkamalesh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

forkkit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.