# authentic-client

> The client component of Authentic. This helps interact with an `authentic-server` so that you can easily signup, confirm, login, and change-password for users. It will also help send tokens to microservices that require authentication.

Latest version **3.0.1** (published 2025-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install authentic-client
pnpm add authentic-client
yarn add authentic-client
bun add authentic-client
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2025-08-07 |
| First published | 2015-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 21.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | David Guttman |
| Maintainers | dguttman |
| Keywords | authentic, authentication, jwt |

## Links

- npm: https://www.npmjs.com/package/authentic-client
- Repository: https://github.com/davidguttman/authentic-client
- Homepage: https://github.com/davidguttman/authentic-client#readme
- Issues: https://github.com/davidguttman/authentic-client/issues
- npm.io page: https://npm.io/package/authentic-client

## Dependencies (2)

- [wildemitter](https://npm.io/package/wildemitter.md) ^1.2.0
- [is-url-superb](https://npm.io/package/is-url-superb.md) ^2.0.0

## 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

- 3.0.1 (latest) — 2025-08-07
- 3.0.0 — 2025-08-02
- 2.2.0 — 2024-06-15
- 2.1.0 — 2024-03-27
- 1.3.0 — 2020-12-03
- 1.2.2 — 2018-06-25
- 1.2.1 — 2017-09-22
- 2.0.0 — 2017-09-07
- 1.1.0 — 2017-08-21
- 1.0.0 — 2017-07-10
- 0.2.1 — 2015-12-04
- 0.2.0 — 2015-12-04
- 0.1.0 — 2015-12-02
- 0.0.3 — 2015-11-13
- 0.0.2 — 2015-11-13
- … 2 more at https://npm.io/package/authentic-client/versions

## README

# AuthenticClient #

The client component of [authentic](https://github.com/davidguttman/authentic). This helps interact with an [authentic-server](https://github.com/davidguttman/authentic-server) so that you can easily signup, confirm, login, and change-password for users. It will also help send tokens to microservices that require authentication.

## Example ##

```js
var Authentic = require('authentic-client')

var auth = Authentic({
  server: 'https://auth.scalehaus.io'
})

var creds = {
  email: 'chet@scalehaus.io',
  password: 'notswordfish'
}

// Step 1: log in
auth.login(creds, function (err) {
  if (err) return console.error(err)

  // Step 2: make a JSON request with authentication
  var url = 'https://reporting.scalehaus.io/report'
  auth.get(url, function (err, data) {
    // show that report
    console.log(data)
  })
})
```

## Installation ##

```
npm install --save authentic-client
```

## API ##

### Authentic(opts) ###

This is the main entry point. Accepts an options object and returns an object with helper methods.

```js
var auth = Authentic({
  server: 'https://auth.scalehaus.io'
})

// auth is now an object with various methods:
auth.signup(opts, cb)
auth.confirm(opts, cb)
auth.login(opts, cb)
auth.changePasswordRequest(opts, cb)
auth.changePassword(opts, cb)
auth.magicRequest(opts, cb)
auth.magicLogin(opts, cb)
```

#### options ####

`Authentic()` takes an options object as its first argument, one of them is required:

* `server`: the url of the `authentic-server`, e.g. `'http://auth.yourdomain.com'`

Optional:

* `prefix`: defaults to `'/auth'` if you set a custom prefix for your `authentic-server`, use that same prefix here
* `authToken`: if you have an authToken from a previous login, you may pass it in for immediate use in `get` and `post`

### auth.signup(opts, cb)

### auth.confirm(opts, cb)

### auth.login(opts, cb)

### auth.changePasswordRequest(opts, cb)

### auth.changePassword(opts, cb)

### auth.magicRequest(opts, cb)

### auth.magicLogin(opts, cb)

See [authentic-server](https://github.com/davidguttman/authentic-server)'s Server API for usage

### auth.get(url, opts, cb)

Will make a request using an authToken if one is available, has the same API as [jsonist.get]
(https://github.com/rvagg/jsonist#jsonistgeturl--options--callback)

### auth.post(url, data, opts, cb)

Will make a request using an authToken if one is available, has the same API as [jsonist.post](https://github.com/rvagg/jsonist#jsonistposturl-data--options--callback)

### auth.put(url, data, opts, cb)

Will make a request using an authToken if one is available, has the same API as [jsonist.put](https://github.com/rvagg/jsonist#jsonistputurl-data--options--callback)

### auth.delete(url, opts, cb)

Will make a request using an authToken if one is available, has the same API as [jsonist.delete]
(https://github.com/rvagg/jsonist#jsonistdeleteurl--options--callback)

If token is present, it will be verified before request against authentic-server's public key, and options will be extended with authorization header prior to sending request. 
It will use `Bearer ${token}` scheme.

You can also call `verifyToken` explicitly yourself and provide a callback. (In case of invalid token, `err` is going to be provided by `jsonwebtoken`)

### auth.verifyToken(function(err){ ... })

# License #

MIT

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