# white-token-urlsafe

> Generates tokens for `X-TB-TOKEN-AUTH` header when using White REST API.

Latest version **1.1.0** (published 2018-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install white-token-urlsafe
pnpm add white-token-urlsafe
yarn add white-token-urlsafe
bun add white-token-urlsafe
```

## 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.1.0 |
| Published | 2018-02-08 |
| First published | 2018-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 16.5 KB |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hare Bu |
| Maintainers | bugu1986 |
| Keywords | white, testing, tools, sign, hmac |

## Links

- npm: https://www.npmjs.com/package/white-token-urlsafe
- Repository: https://github.com/buhe/token-encoder-urlsafe
- Homepage: https://github.com/buhe/token-encoder-urlsafe#readme
- Issues: https://github.com/buhe/token-encoder-urlsafe/issues
- npm.io page: https://npm.io/package/white-token-urlsafe

## Dependencies (4)

- [nonce](https://npm.io/package/nonce.md) ^1.0.3
- [lodash](https://npm.io/package/lodash.md) ^3.2.0
- [unix-timestamp](https://npm.io/package/unix-timestamp.md) ^0.1.2
- [urlsafe-base64](https://npm.io/package/urlsafe-base64.md) ^1.0.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2018-02-08

## README

# A OpenTok Token Encoder Fork For White url token, Thank OpenTok Token.

## What is different?

- use url safe base64 encode for url query params
- add url encode tester

## Installation

```
npm install --save white-token-urlsafe
```

## Usage

**WARNING:** This module does not check for the validity of the data being encoded into the token.
It doesn't know about the OpenTok REST API semantics, and you can encode data that doesn't result in
a valid token. Its merely a utility. Use the [OpenTok Node Server
SDK](https://github.com/opentok/opentok-node) for a more complete module.

### Generating a token

```javascript
var encodeToken = require('white-token-urlsafe');

var tokenData = {
  session_id: 'SESSIONID',
  create_time: 1424221013,
  nonce: 50885,
  role: 'moderator',
  expire_time: 1424307413,
  connection_data: '{"name":"value"}'
};
var apiKey = 'APIKEY';
var apiSecret = 'APISECRET'

var token = encodeToken(tokenData, apiKey, apiSecret);
```
**NOTE:** The API key, secret, and session ID above are not real.


### Default values

If you do not specify certain properties of the `tokenData` parameter, defaults will be applied for
you.

| Property      | Type                                | Default                     |
|---------------|-------------------------------------|-----------------------------|
| `create_time` | unix timestamp in seconds (integer) | now                         |
| `expire_time` | unix timestamp in seconds (integer) | now + 1 day                 |
| `role`        | string                              | 'publisher'                 |
| `nonce`       | number                              | unique random number        |

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