# gatekeeper-sol

> ## Install

Latest version **1.0.5** (published 2022-02-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install gatekeeper-sol
pnpm add gatekeeper-sol
yarn add gatekeeper-sol
bun add gatekeeper-sol
```

## 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.5 |
| Published | 2022-02-18 |
| First published | 2022-02-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | pbtripletree |

## Links

- npm: https://www.npmjs.com/package/gatekeeper-sol
- Repository: https://github.com/pbtripletree/gatekeeper-sol
- Homepage: https://github.com/pbtripletree/gatekeeper-sol#readme
- Issues: https://github.com/pbtripletree/gatekeeper-sol/issues
- npm.io page: https://npm.io/package/gatekeeper-sol

## Dependencies (6)

- [bs58](https://npm.io/package/bs58.md) ^4.0.1
- [siws](https://npm.io/package/siws.md) ^1.0.0
- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [tweetnacl](https://npm.io/package/tweetnacl.md) ^1.0.3
- [@solana/web3.js](https://npm.io/package/@solana/web3.js.md) ^1.34.0
- [@solana/spl-token](https://npm.io/package/@solana/spl-token.md) ^0.1.8

## Recent versions

- 1.0.5 (latest) — 2022-02-18
- 1.0.4 — 2022-02-18
- 1.0.2 — 2022-02-18
- 1.0.1 — 2022-02-18
- 1.0.0 — 2022-02-16

## README

# Usage

## Install

```
npm i gatekeeper-sol
```

Recommended to use with https://www.npmjs.com/package/siws

#### 1. Import

```
const { authorize } = require("gatekeeper-sol");
```

#### 2. authorize() expects a list of roles and token addresses that assume the role, as well as a decoded SiwsMessage

</br>
<i>authorize() will validate your SiwsMessage, but we suggest you .validate() yourself before incurring a network request</i>
</br>

```
const roles = [
  {
    role: "super-fan",
    addresses: ["AYcSvXDXUT292DgaTG9AJLmpNBtUPpzndAdC5KVabz86"],
  },
  {
    role: "fan",
    addresses: ["7rJ51pjsEvAAWETpu1iJj465FKSz5RgPFa3HwXu8kZwV"],
  },
];

const siwsMessage = new SiwsMessage({}).decode(token);
if (!siwsMessage.validate()) return false

const authorizeResponse = await authorize({
  request: siwsMessage,
  roles
})
```

#### 3. authorize will return an object with a success status, message, and a list of roles if valid roles are found for the requesting address

```
// roles found
{
  success: true,
  message: 'roles found',
  roles: [ 'super-fan' ]
}

//no roles found
{
  success: false,
  message: 'no roles found',
  roles: null
}
```

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