# @boilerz/super-server-auth-core

> Core module for authentication support on super server

Latest version **1.6.41** (published 2022-04-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @boilerz/super-server-auth-core
pnpm add @boilerz/super-server-auth-core
yarn add @boilerz/super-server-auth-core
bun add @boilerz/super-server-auth-core
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.41 |
| Published | 2022-04-29 |
| First published | 2020-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 43 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| Author | boilerz |
| Maintainers | boilerz-tech |

## Links

- npm: https://www.npmjs.com/package/@boilerz/super-server-auth-core
- Repository: https://github.com/boilerz/super-server-auth-core
- Homepage: https://github.com/boilerz/super-server-auth-core#readme
- Issues: https://github.com/boilerz/super-server-auth-core/issues
- npm.io page: https://npm.io/package/@boilerz/super-server-auth-core

## Dependencies (4)

- [bson](https://npm.io/package/bson.md) ^4.6.3
- [pluralize](https://npm.io/package/pluralize.md) ^8.0.0
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [@sendgrid/mail](https://npm.io/package/@sendgrid/mail.md) ^7.6.2

## Recent versions

- 1.6.41 (latest) — 2022-04-29
- 1.6.40 — 2022-04-28
- 1.6.39 — 2022-04-25
- 1.6.38 — 2022-04-22
- 1.6.37 — 2022-04-22
- 1.6.36 — 2021-09-10
- 1.6.35 — 2021-07-09
- 1.6.34 — 2021-06-17
- 1.6.33 — 2021-06-11
- 1.6.32 — 2021-05-16
- 1.6.31 — 2021-05-06
- 1.6.30 — 2021-04-07
- 1.6.29 — 2021-03-29
- 1.6.28 — 2021-03-21
- 1.6.27 — 2021-03-03
- … 42 more at https://npm.io/package/@boilerz/super-server-auth-core/versions

## README

# @boilerz/super-server-auth-core

[![GitHub package.json version](https://img.shields.io/github/package-json/v/boilerz/super-server-auth-core)](https://www.npmjs.com/package/@boilerz/super-server-auth-core)
[![GH CI Action](https://github.com/boilerz/super-server-auth-core/workflows/CI/badge.svg)](https://github.com/boilerz/super-server-auth-core/actions?query=workflow:CI)
[![codecov](https://codecov.io/gh/boilerz/super-server-auth-core/branch/master/graph/badge.svg)](https://codecov.io/gh/boilerz/super-server-auth-core)

> Core module for authentication support on super server

### Install

```bash
npx install-peerdeps @boilerz/super-server-auth-core
```

### Usage

This plugin add support for a sign up resolver and it is required for other `super-server-auth-*` plugin.
It need a mongo setup to work so the plugin `@boilerz/super-server-mongo` need to be set before this one.

```typescript
import { Arg, Query, Resolver } from 'type-graphql';
import * as superServer from '@boilerz/super-server';
import mongoPlugin from '@boilerz/super-server-mongo';
import authCorePlugin from '@boilerz/super-server-auth-core';

@Resolver()
class GreetingResolver {
  @Query(() => String)
  public hello(@Arg('name') name: string): string {
    return `Hello ${name}`;
  }
}

superServer
  .start({
    resolvers: [GreetingResolver],
    plugins: [mongoPlugin, authCorePlugin], // <-- Plugin here (after mongoPlugin)
  })
  .catch(console.error);
```

In situation example with local auth plugin [example](https://github.com/boilerz/super-server/blob/master/examples/withLocalAuth.ts)

If mail support is not disabled (@see `DISABLE_MAILING_SUPPORT` below) the worker process defined below should be setup: 

```bash
node node_modules/@boilerz/super-server-auth-core/worker/email
```

### Release

```bash
yarn version
yarn build
yarn publish dist --access public
```

# Env vars

## Web plugin

| Name                                        | Default                      | Description                                                                                                        |
|---------------------------------------------|------------------------------|--------------------------------------------------------------------------------------------------------------------|
| JWT_SECRET                                  | `Math.random().toString(36)` | JWT secret                                                                                                         |
| JWT_EXPIRE_IN                               | `30 * 60 * 1000`             | Token expiration in seconds.                                                                                       |
| DISABLE_MAILING_SUPPORT                     | `false`                      | Disable mailing support.                                                                                           |
| EXTERNAL_PROVIDER_LINK_CODE_EXPIRES_DURATION| `2`                          | External provider link code expiration in hours.                                                                   |
| EMAIL_VALIDATION_EXPIRES_DURATION           | `48`                         | Validation code expiration in hours.                                                                               |
| AMQP_URL                                    | `amqp://localhost`           | AMQP url (*used for communication between the plugin and the email validation worker*).                            |

## Email validation worker

| Name                                        | Default                   | Description                                                                                                        |
|---------------------------------------------|---------------------------|--------------------------------------------------------------------------------------------------------------------|
| SENDGRID_API_KEY                            |                           | Sendgrid API Key for email validation.                                                                             |
| SENDER_EMAIL                                |                           | Sendgrid sender email (must be validated by sendgrid).                                                             |
| EMAIL_VALIDATION_TEMPLATE_ID                |                           | Sendgrid validation email template id. (Must handle `firstName`, `lastName` and `validationUrl` as template data). |
| LINK_ACCOUNT_TEMPLATE_ID                    |                           | Sendgrid link account template id. (Must handle `firstName`, `lastName` and `linkCode` as template data).          |
| WAITING_DURATION_BEFORE_NEXT_EMAIL_ATTEMPT  | `5000`                    | Waiting duration in ms between two email validation attempt.                                                       |
| AMQP_URL                                    | `amqp://localhost`        | See above                                                                                                              |

---
_Source: https://npm.io/package/@boilerz/super-server-auth-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
