# @jincor-tech/auth-ts-client

> A typescript library which encapsulates interaction with Jincor Auth

Latest version **0.1.4** (published 2018-02-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jincor-tech/auth-ts-client
pnpm add @jincor-tech/auth-ts-client
yarn add @jincor-tech/auth-ts-client
bun add @jincor-tech/auth-ts-client
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2018-02-01 |
| First published | 2018-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=6.0.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | aleserche |
| Maintainers | aleserche |
| Keywords | library, client, sdk, auth, jwt |

## Links

- npm: https://www.npmjs.com/package/@jincor-tech/auth-ts-client
- Repository: https://github.com/JincorTech/auth-ts-client
- Homepage: https://github.com/JincorTech/auth-ts-client#readme
- Issues: https://github.com/JincorTech/auth-ts-client/issues
- npm.io page: https://npm.io/package/@jincor-tech/auth-ts-client

## Dependencies (2)

- [winston](https://npm.io/package/winston.md) ^2.4.0
- [web-request](https://npm.io/package/web-request.md) ^1.0.7

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@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

## Recent versions

- 0.1.4 (latest) — 2018-02-01

## README

# Auth client

This is a client library which encapsulates interaction with [Auth service](https://github.com/JincorTech/backend-auth). With its help you can:

1. Register users and tenants.
2. Get tokens for users and tenants after authorization.
3. Perform verification of tokens for users and tenants.
4. Deactivate tokens for users and tenants.
5. Remove users.

The user can be attached to several tenants through the field tenant. It is filled from the tenant's token in the [Auth service](https://github.com/JincorTech/backend-auth) service.

## Usage

### Initialize Auth client

```javascript
let client = new AuthClient('http://auth:3000')
```

### Work with Tenant

```javascript
let registerResult = await client.registerTenant('test@test.com', 'Password1')
// { id: 'af8b13ea-02a9-4e73-b8d9-58c8215757b9', email: 'test@test.com', login: '...' }
let token = await client.loginTenant('test@test.com', 'Password1')
```

### Work with User

To work with users you need a tenant token. Field `scope` is optional.

```javascript
let user = await client.createUser({
    email: 'test@test.com',
    login: 'test@test.com',
    password: 'Password1',
    scope: 'admin',
    sub: '123'
    }, 'tenant-token'
)
// { id: '55096b7d-0f14-446a-b50d-ee6bc8431e39', email: 'test@test.com', login:... }
```

More details can be received in the tests.


### Project setup

1. Clone the repo
2. `cd /path/to/repo`
3. `docker-compose build` - build development containers
4. `docker-compose run --rm authclient sh -c "yarn"`

#### Local testing

To run all tests just type `docker-compose run --rm authclient sh -c "yarn test"`

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