0.5.0 • Published 3 years ago

authist v0.5.0

Weekly downloads
47
License
MIT
Repository
github
Last release
3 years ago

Authist

NPM version Pipeline Status Deploy Status Coverage Vulnerabilities

Error codes

CodeMessageHow to debug / fix
PasswordMismatchYou entered a wrong password!Did you store password we hashed for you?
UsernameRequiredUsername is required field, please enter the username!:thinking:
PasswordRequiredPassword is required field, please enter the password!:thinking:
UserNotFoundIt 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.

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.1.0-0

3 years ago