3.0.0 • Published 11 months ago

commondev-auth v3.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

commondev-auth

Authorization system via commondev api for everyone

Installation

npm i commondev-auth

Usage

const { CommondevAuth } = require('commondev-auth');
// or
import { CommondevAuth } from 'commondev-auth';

CommondevAuth.register

This method takes as input email. Sends 4-digit code to the specified email. This code expires in 5 minutes, to resend code use CommondevAuth.resendCode.

const registerRequest = await CommondevAuth.register({
  email: 'example@gmail.com'
});

This method returns next step of authorization. For example:

{
  error: null,
  data: { next: "complete" },
}

CommondevAuth.complete

This method takes as input email and code.

const completeRequest = await CommondevAuth.complete({
  email: 'example@gmail.com'
  code: 4232
});

This method returns authorization token. For example:

{
  error: null,
  data: { token: "EXAMPLE_TOKEN" },
}

CommondevAuth.login

This method takes as input email. Sends 4-digit code to the specified email. This code expires in 5 minutes, to resend code use CommondevAuth.resendCode.

const loginRequest = await CommondevAuth.login({
  email: 'example@gmail.com'
});

This method returns next step of authorization. For example:

{
  error: null,
  data: { next: "complete" },
}

CommondevAuth.getUserByToken

This method takes as input jwt token that you can get via CommondevAuth.complete.

const getUserDataRequest = await CommondevAuth.getUserByToken({
  token: 'TOKEN',
});

This method returns user data. For example:

{
    "error": null,
    "data": {
        "user": {
            "created": "2023-06-18T14:46:55.307Z",
            "email": "example@gmail.com",
            "token": "EXAMPLE_TOKEN"
        }
    }
}

CommondevAuth.resendCode

This method takes as input email. Sends 4-digit code to the specified email. This code expires in 5 minutes, to resend code use CommondevAuth.resendCode.

const resendCodeRequest = await CommondevAuth.resendCode({
  email: 'example@gmail.com'
});

This method returns next step of authorization. For example:

{
  error: null,
  data: { next: "complete" },
}
3.0.0

11 months ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago