Coder Social home page Coder Social logo

authist's Introduction

Authist

NPM version Pipeline Status Deploy Status Coverage Vulnerabilities

Error codes

Code Message How to debug / fix
PasswordMismatch You entered a wrong password! Did you store password we hashed for you?
UsernameRequired Username is required field, please enter the username! ๐Ÿค”
PasswordRequired Password is required field, please enter the password! ๐Ÿค”
UserNotFound It seems this user doesn't exist, are you sure you entered correct credentials? Do you want to enable auto registration? Declare saveNonExistingUser function

๐Ÿšง๐Ÿ—๏ธ๐Ÿšง

Under heavy development

Features

  • supported features by Firebase Authentication, a fellow auth ideal service
    • email and password authentication ref
    • google authentication ref
    • facebook authentication ref
    • twitter authentication ref
    • github authentication ref
    • custom auth system authentication ref
    • anonymous auth ref kept forever
    • storing provider data ref what data
    • reset password email ref
    • recovery email ref
    • verify email ref

Email and password authentication

Usage

import { createAuthenticator } from 'authist';

const authenticator = createAuthenticator({
    getUserById: () => Promise.resolve(), // todo: add implementation
    emailPassword: {
        getUserByEmail: (email: string) => Promise.resolve(), // todo: add implementation
    },
});
const { user, credentials } = await authenticator.signInWithEmailAndPassword(email, password);

Express middleware

import express from 'express';

const app = express();
app.get('/users/me', authenticator.expressBearer, (req, res) => {
    res.json(req.user);
});

Facebook authentication

Usage

import { createAuthenticator } from 'authist';

const authenticator = createAuthenticator({
    getUserById: () => Promise.resolve(), // todo: add implementation
    facebook: {
        getUserByEmail: (email: string) => Promise.resolve(), // todo: add implementation
        graphApiVersion: 'v9.0',
    },
});
const { user, credentials } = await authenticator.signInWithFacebook(accessToken);

Google authentication

  • The signInWithGoogle method takes token parameter that is Google access token
  • Your Google access token must have the email scope assigned to successfully get the user's email

Usage

import { createAuthenticator } from 'authist';

const authenticator = createAuthenticator({
    getUserById: () => Promise.resolve(), // todo: add implementation
    google: {
        getUserByEmail: (email: string) => Promise.resolve(), // todo: add implementation
    },
});
const { user, credentials } = await authenticator.signInWithGoogle(accessToken);

License

This project is licensed under MIT.

authist's People

Contributors

smoliji avatar stefanprokopdev avatar

Watchers

 avatar  avatar  avatar  avatar

authist's Issues

Add google authentication provider

Add a new signInWithGoogle functionality and authentication flow.

What to do?

  • Create new googleProvider file under providers folder
  • Design GoogleProviderOptions interface - which data you need to successfully authenticate / register the user? Which data is optional / required? (hint: you will probably use google people API)
  • Implement signInWithGoogle authentication flow (you can inspire in emailPasswordProvider); Please keep in mind the authentication flow should be possible to implement without using the signInWithGoogle function. It means all helper functions should be calleble from the outside.
  • Appropriately export all necessary helper functions, interfaces and signInWithGoogle function

Add facebook authentication provider

Add a new signInWithFacebook functionality and authentication flow.

What to do?

  • Create new facebookProvider file under providers folder
  • Design FacebookProviderOptions interface - which data you need to successfully authenticate / register the user? Which data is optional / required? (hint: you will probably use FB graph /me endpoint)
  • Implement signInWithFacebook authentication flow (you can inspire in emailPasswordProvider); Please keep in mind the authentication flow should be possible to implement without using the signInWithFacebook function. It means all helper functions should be callable from the outside.
  • Appropriately export all necessary helper functions, interfaces and signInWithFacebook function

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.