# hapi-vkminiapps-auth

> Authorization plugin for VK Mini Apps

Latest version **1.0.6** (published 2020-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install hapi-vkminiapps-auth
pnpm add hapi-vkminiapps-auth
yarn add hapi-vkminiapps-auth
bun add hapi-vkminiapps-auth
```

## 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.6 |
| Published | 2020-04-12 |
| First published | 2019-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Max Denushev |
| Maintainers | denushev |
| Keywords | hapi, auth, vk, vkminiapps, vkapps |

## Links

- npm: https://www.npmjs.com/package/hapi-vkminiapps-auth
- Repository: https://github.com/mdenushev/hapi-vkminiapps-auth
- Homepage: https://github.com/mdenushev/hapi-vkminiapps-auth#readme
- Issues: https://github.com/mdenushev/hapi-vkminiapps-auth/issues
- npm.io page: https://npm.io/package/hapi-vkminiapps-auth

## Dependencies (3)

- [@hapi/joi](https://npm.io/package/@hapi/joi.md) ^16.1.8
- [@hapi/boom](https://npm.io/package/@hapi/boom.md) ^8.0.1
- [@hapi/hoek](https://npm.io/package/@hapi/hoek.md) ^8.5.0

## 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

- 1.0.6 (latest) — 2020-04-12
- 1.0.5 — 2020-02-10
- 1.0.4 — 2020-02-04
- 1.0.3 — 2020-01-10
- 1.0.2 — 2020-01-10
- 1.0.1 — 2019-12-20
- 1.0.0 — 2019-12-20

## README

# VK Mini Apps auth fo Hapi

Simple implementation for auth flow in VK Mini Apps

[Docs](https://vk.com/dev/vk_apps_docs3?f=6.1%20Подпись%20параметров%20запуска)
```
npm install --save hapi-vkminiapps-auth
```

### Usage:
```javascript
const Hapi = require('@hapi/hapi');

const start = async () => {
    const server = Hapi.server({ port: 4000 });

    await server.register(require('hapi-vkminiapps-auth'));

    server.auth.strategy('vk', 'vk-mini-app', { clientSecret: '...', validate: async (credentials) => { // Credentials is same as below
      if (credentials.vk_user_id === 98712) {
        return {isValid: true, credentials}
      } else {
        return {isValid: false, error: 'Forbidden'}
      }    
    }});

    server.route({
        method: 'GET',
        path: '/',
        options: {
            auth: 'vk'
        },
        handler: function (request) {

            return request.auth.credentials;
        }
    });
    await server.start();

    console.log('server running at: ' + server.info.uri);
};

start();
```

Example `request.auth.credentials`:
```json
{
    "vk_access_token_settings": "friends",
    "vk_app_id": 7130099,
    "vk_are_notifications_enabled": 0,
    "vk_is_app_user": 0,
    "vk_is_favorite": 0,
    "vk_language": "ru",
    "vk_platform": "desktop_web",
    "vk_ref": "other",
    "vk_user_id": 1234
}
```

### Hint:
If you use nginx add `underscores_in_headers on;` to your server section.

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