1.1.1 • Published 2 years ago

mlauth-js v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

mlauth-js

The javascript client for mlAuth.

[built for the Planetscape x Hashnode Hackathon]

Quick Start

install

# npm
npm i mlauth-js

# pnpm
pnpm add mlauth-js

# yarn
yarn add mlauth-js

import

// ESM
import mlAuth from 'mlauth-js'

// CommonJS
const mlAuth = require('mlauth-js')

Start Authenticating Users

Initiate a new mlAuth instance

const client = new mlAuth({
	client: APP_CLIENT_KEY,
	secret: APP_SECRET_KEY
})

Make Login Requests (send magic login links to users)

const response = await client.login(EMAIL)

Authenticate magic links

Obtain the token passed as a query on the callbackUrl you added while creating your app, and pass it as the only argument of the verify method.

const response = await client.verify(TOKEN)

Both instance return Promises that resolve as follows:

  • Successful requests, return an Object with a data and message properties.
      // Example:
      {
        data: {
          // magic link details
        },
        message: "Magic link created"
      }
  • Failures, resolve with ohmyfetch's FetchError type. The error body is available on error.data.
      // Example:
      FetchError: 401 Not Authorized

Examples

Here are examples demonstrating how to use this package when authenticating users with mlAuth.

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago