# airic-api-gateway-key-server

> API Gateway Key Server

Latest version **0.1.0** (published 2017-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install airic-api-gateway-key-server
pnpm add airic-api-gateway-key-server
yarn add airic-api-gateway-key-server
bun add airic-api-gateway-key-server
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2017-12-12 |
| First published | 2017-12-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 7 \|\| 8 |
| Dependencies | 9 |
| Known vulnerabilities | 0 (+5 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Eric Yu |
| Maintainers | airicyu |

## Links

- npm: https://www.npmjs.com/package/airic-api-gateway-key-server
- Repository: https://github.com/airicyu/airic-api-gateway-key-server
- Homepage: https://github.com/airicyu/airic-api-gateway-key-server#readme
- Issues: https://github.com/airicyu/airic-api-gateway-key-server/issues
- npm.io page: https://npm.io/package/airic-api-gateway-key-server

## Dependencies (9)

- [mysql](https://npm.io/package/mysql.md) ^2.15.0
- [yamljs](https://npm.io/package/yamljs.md) ^0.3.0
- [express](https://npm.io/package/express.md) ^4.16.2
- [mongodb](https://npm.io/package/mongodb.md) ^2.2.33
- [request](https://npm.io/package/request.md) ^2.83.0
- [sqlite3](https://npm.io/package/sqlite3.md) ^3.1.13
- [body-parser](https://npm.io/package/body-parser.md) ^1.18.2
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.1.0
- [http-shutdown](https://npm.io/package/http-shutdown.md) ^1.2.0

## Recent versions

- 0.1.0 (latest) — 2017-12-12
- 0.0.4 — 2017-12-08
- 0.0.3 — 2017-12-08
- 0.0.2 — 2017-12-08
- 0.0.1 — 2017-12-07

## README

# airic-api-gateway-key-server

[![npm version](https://img.shields.io/npm/v/airic-api-gateway-key-server.svg)](https://www.npmjs.com/package/airic-api-gateway-key-server)
[![node](https://img.shields.io/node/v/airic-api-gateway-key-server.svg)](https://www.npmjs.com/package/airic-api-gateway-key-server)
[![Codecov branch](https://img.shields.io/codecov/c/github/airicyu/airic-api-gateway-key-server/master.svg)](https://codecov.io/gh/airicyu/airic-api-gateway-key-server)
[![Build](https://travis-ci.org/airicyu/airic-api-gateway-key-server.svg?branch=master)](https://travis-ci.org/airicyu/airic-api-gateway-key-server)

[![dependencies Status](https://david-dm.org/airicyu/airic-api-gateway-key-server/status.svg)](https://david-dm.org/airicyu/airic-api-gateway-key-server)
[![devDependencies Status](https://david-dm.org/airicyu/airic-api-gateway-key-server/dev-status.svg)](https://david-dm.org/airicyu/airic-api-gateway-key-server?type=dev)

## Description

airic-api-gateway-key-server module is the ID key/API key server component of airic-api-gateway.

------------------------

## Samples

### Hello world

Starting server:

```javascript
'use strict';
const YAML = require('yamljs');
const keyServer = require('airic-api-gateway-key-server');

const keyServerConfigYaml = YAML.load('./key-server-config.yaml');
keyServer.setConfig(keyServerYaml);

keyServer.run();
```

------------------------

## Key Server Config YAML

Sample:
```yaml
port: 3002
admin-token: d8745e9d03be41ad817a47176ade4dcc
pull-api-config-interval-second: 60
config-server-base-url: http://localhost:3001
id-key-cache-max-second: 15
api-key-cache-max-second: 10
private-key-path : './system-key-dir/private-key.pem'
public-key-path : './system-key-dir/public-key.pem'
```


------------------------

## REST APIs

### Generate Workspace ID key (with admin token)
```
POST http://localhost:3001/config/workspaces/{{workspaceId}}/id-keys
Content-type: application/json
id-key: {{adminToken}}

```

### Generate Workspace ID key (with workspace ID/secret)
```
POST http://localhost:3001/config/workspaces/{{workspaceId}}/id-keys
Content-type: application/json
id-key: {{adminToken}}

{
    "workspaceId": "{{workspaceId}}",
    "secret": "{{workspaceSecret}}"
}
```

### Generate App ID key (with admin token)
```
POST http://localhost:3001/config/workspaces/{{workspaceId}}/apps/{{appId}}/id-keys
Content-type: application/json
id-key: {{adminToken}}

```

### Generate App ID key (with workspace ID key)
```
POST http://localhost:3001/config/workspaces/{{workspaceId}}/apps/{{appId}}/id-keys
Content-type: application/json
id-key: {{workspaceIdKey}}

```

### Generate App ID key (with app ID/secret)
```
POST http://localhost:3001/config/workspaces/{{workspaceId}}/apps/{{appId}}/id-keys
Content-type: application/json
id-key: {{adminToken}}

{
    "appId": "{{appId}}",
    "secret": "{{appSecret}}"
}
```

### Verify Workspace ID key or App ID key
```
POST http://localhost:3001/keys/id-keys/verification
Content-type: application/json

{
    "key": "{{workspaceIdKey}}"
}
```

```
POST http://localhost:3001/keys/id-keys/verification
Content-type: application/json

{
    "key": "{{appIdKey}}"
}
```

### Register App API key for Client
```
POST http://localhost:3001/config/workspaces/{{workspaceId}}/apps/{{appId}}/api-keys
Content-type: application/json
id-key: {{adminToken}}

{
    "clientId": "{{clientId}}"
}
```

### Verify API key
```
POST http://localhost:3001/keys/api-keys/verification
Content-type: application/json

{
    "key": "{{apiKey}}"
}
```

---
_Source: https://npm.io/package/airic-api-gateway-key-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
