# ltpa-token

> Ltpa token generation and validation

Latest version **1.0.3** (published 2017-03-27) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ltpa-token
pnpm add ltpa-token
yarn add ltpa-token
bun add ltpa-token
```

## 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.0.3 |
| Published | 2017-03-27 |
| First published | 2017-03-27 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | landray |
| Maintainers | siwar |
| Keywords | ltpa, token, authentication, validation, lotus, ibm, websphere |

## Links

- npm: https://www.npmjs.com/package/ltpa-token
- Repository: https://github.com/landray/ltpa
- Homepage: https://github.com/landray/ltpa#readme
- Issues: https://github.com/landray/ltpa/issues
- npm.io page: https://npm.io/package/ltpa-token

## Dependencies (1)

- [iconv-lite](https://npm.io/package/iconv-lite.md) ~0.4.10

## 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.0.3 (latest) — 2017-03-27
- 1.0.2 — 2017-03-27
- 1.0.1 — 2017-03-27
- 1.0.0 — 2017-03-27

## README

# ltpa

> A small library for generating and validating ltpa tokens. Based on the 
[IBM specification](http://www-12.lotus.com/ldd/doc/tools/c/7.0/api70ug.nsf/85255d56004d2bfd85255b1800631684/ceda2cb8df47607f85256c3d005f816d).

> refer to [markusberg/ltpa](https://github.com/markusberg/ltpa/)


## 安装
`npm install ltpa-token --save`

## 初始化
```javascript
var ltpa = require('ltpa-token')

ltpa.init({
  secret: ,
  validity: ,
  gracePeriod: 
})
```

### options
- `secret`：秘钥。string
- `validity`：过期时间，单位秒。默认为43200秒(12小时)。number
- `gracePeriod`：设置一个时间，当有效期过了的这段时间内仍然有效，单位秒。默认为300秒(5分钟)。number


## api

### generate
```javascript
/**
 * 生成token
 */
var result = ltpa.generate(userName[, secret, timeStart])
```

- `userName`：存储到token的用户信息。string
- `secret`：可选，不加将使用初始化设置的secret.使用secret作为密钥生成token。string
- `timeStart`：可选，token的开始时间，默认为now。number

### validate
```javascript
/**
 * 校验token
 * {
 *   code: 0,   // 0正常
 *   data: user   // user信息
 * }
 */
var result = ltpa.validate(token[, secret])
```

- `token`：token字符串。string
- `secret`：可选，不加将使用初始化设置的secret.使用secret作为密钥校验。string

### refresh
```javascript

/**
 * 刷新token
 * 返回base64 token
 */
var token = ltpa.refresh(user[, secret])
```

- `user`：user信息
- `secret`：可选，不加将使用初始化设置的secret.使用secret作为密钥生成token。string

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