# @react-kit/auth

> ------ token处理工具（注：依赖 @react-kit/http ）

Latest version **0.4.0** (published 2019-05-10) · 0 weekly downloads

## Install

```sh
npm install @react-kit/auth
pnpm add @react-kit/auth
yarn add @react-kit/auth
bun add @react-kit/auth
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2019-05-10 |
| First published | 2018-12-24 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 26 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yang |
| Maintainers | guccihuiyuan |

## Links

- npm: https://www.npmjs.com/package/@react-kit/auth
- npm.io page: https://npm.io/package/@react-kit/auth

## Recent versions

- 0.4.0 (latest) — 2019-05-10
- 0.3.0 — 2019-05-03
- 0.2.0 — 2019-04-25
- 0.1.1 — 2018-12-24

## README

# react-kit/auth
------
token处理工具（注：依赖 @react-kit/http ）

# 特点
> * 处理 token 的保存、获取、删除
> * 内置 token 拦截器，根据需要使用
> * 使用 typescript 编写，内置 ts 声明文件 在编译器下获得友好的代码提示

# 示例
```js
import {TokenService, TokenStoreType} from '@react-kit/auth';

// 创建一个service对象，可传入配置，不传则使用默认值
const tokenService = new TokenService({
    token_send_key_header: 'Authorization',
    token_send_template_header: 'Bearer ${token}',
    token_store_key: 'token',
    token_store_type: TokenStoreType.LocalStorage
});

// 设置
tokenService.set({token: '123456'});

// 获取
tokenService.get();

// 清除
tokenService.clear();

// 增加token拦截器(自动将token添加到请求头中)
tokenService.addTokenInterceptors();

```

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