# mlauth-js

> A javascript client for the mlAuth authentication service

Latest version **1.1.1** (published 2022-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install mlauth-js
pnpm add mlauth-js
yarn add mlauth-js
bun add mlauth-js
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2022-08-01 |
| First published | 2022-07-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | James Sinkala |
| Maintainers | xinnks |
| Keywords | mlAuth, authentication, magic links, planetscape, hashnode, planetscale hackathon |

## Links

- npm: https://www.npmjs.com/package/mlauth-js
- Repository: https://github.com/xinnks/mlauth-js
- Homepage: https://github.com/xinnks/mlauth-js#readme
- Issues: https://github.com/xinnks/mlauth-js/issues
- npm.io page: https://npm.io/package/mlauth-js

## Dependencies (1)

- [ohmyfetch](https://npm.io/package/ohmyfetch.md) ^0.4.18

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2022-08-01
- 1.1.0 — 2022-08-01
- 1.0.0 — 2022-07-30
- 0.2.5 — 2022-07-30
- 0.2.4 — 2022-07-29
- 0.2.3 — 2022-07-29
- 0.1.1 — 2022-07-01
- 0.1.0 — 2022-07-01

## README

# mlauth-js

The javascript client for [mlAuth](https://github.com/xinnks/mlAuth).

[__built for the [Planetscape](https://planetscape.com) x [Hashnode](https://hashnode.com) Hackathon__]

## Quick Start

### install

```sh
# npm
npm i mlauth-js

# pnpm
pnpm add mlauth-js

# yarn
yarn add mlauth-js
```


### import

```js
// ESM
import mlAuth from 'mlauth-js'

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

## Start Authenticating Users

### Initiate a new mlAuth instance

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

### Make Login Requests (send magic login links to users)

```sh
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.

```sh
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.
  ```js
    // Example:
    {
      data: {
        // magic link details
      },
      message: "Magic link created"
    }
  ```
- Failures, resolve with [ohmyfetch]()'s `FetchError` type. The error body is available on `error.data`.
  ```js
    // Example:
    FetchError: 401 Not Authorized
  ```


## Examples

Here are examples demonstrating how to use this package when authenticating users with [mlAuth](https://github.com/xinnks/mlAuth).
- [mlauth-fe-demo](https://github.com/xinnks/mlauth-fe-demo) - Vite + Vue.js
- [mlauth-be-demo](https://github.com/xinnks/mlauth-be-demo) - NodeJs + Express

---
_Source: https://npm.io/package/mlauth-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
