# ssb-invite

> Invite-token system, mainly used for pubs. Creates invite codes as one of ways of onboarding.

Latest version **2.1.8** (published 2024-02-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install ssb-invite
pnpm add ssb-invite
yarn add ssb-invite
bun add ssb-invite
```

## 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 | 2.1.8 |
| Published | 2024-02-29 |
| First published | 2016-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 25.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Dominic Tarr |
| Maintainers | powersource, arj03, staltz, mixmix, cel, dominictarr |

## Links

- npm: https://www.npmjs.com/package/ssb-invite
- Repository: https://github.com/ssbc/ssb-invite
- Issues: https://github.com/ssbc/ssb-invite/issues
- npm.io page: https://npm.io/package/ssb-invite

## Dependencies (8)

- [ip](https://npm.io/package/ip.md) ^1.1.8
- [cont](https://npm.io/package/cont.md) ^1.0.3
- [level](https://npm.io/package/level.md) ^6.0.1
- [ssb-ref](https://npm.io/package/ssb-ref.md) ^2.16.0
- [ssb-keys](https://npm.io/package/ssb-keys.md) ^7.2.2
- [ssb-client](https://npm.io/package/ssb-client.md) ^4.9.0
- [explain-error](https://npm.io/package/explain-error.md) ^1.0.4
- [muxrpc-validation](https://npm.io/package/muxrpc-validation.md) ^3.0.2

## Recent versions

- 2.1.8 (latest) — 2024-02-29
- 3.0.3 — 2024-02-12
- 3.0.2 — 2023-12-07
- 3.0.1 — 2022-06-06
- 3.0.0 — 2022-02-28
- 2.1.7 — 2021-04-12
- 2.1.6 — 2020-08-07
- 2.1.5 — 2020-07-04
- 2.1.4 — 2019-09-25
- 2.1.3 — 2019-05-14
- 2.1.2 — 2019-05-13
- 2.1.1 — 2019-05-13
- 2.1.0 — 2019-05-13
- 2.0.4 — 2019-03-19
- 2.0.3 — 2019-01-15
- … 6 more at https://npm.io/package/ssb-invite/versions

## README

# ssb-invite

Invite-token system, mainly used for pubs. Creates invite codes as one of ways of onboarding.

Generally this ends being used for pubs:

- Users choose a pub from a [list of pubs](https://github.com/ssbc/ssb-server/wiki/Pub-Servers).
- The chosen pub gives out an invite code to the user via the pub's website.
- The user installs a Scuttlebutt client and copy and paste the invite code into the client's "accept invite" prompt.
- The pub validates the invite code and follows back the new user, making them visible to other Scuttlebutt users.

Soon, hopefully supercededed by [ssb-peer-invites](https://github.com/ssbc/ssb-peer-invites) but supported for backwards compatibity.

## api

### create ({uses, note, external, modern}, cb(err, invite_code))

Create a new invite code.

- `uses` (number): How many times the invite can be used before it expires.
- `note` (string): A note to associate with the invite code. The ssb-server instance will
    include this note in the follow message that it creates when `use` is
    called.
- `external` (string): An external hostname to use
- `modern` (boolean): if true the invite code will be a valid multiserver address.
    - if modern is enabled, uses will be set to 1.
    - :warning: "modern" invites with ipv6 addresses currently have some problems

This produces an invite-code which encodes the ssb-server instance's public address,
and a keypair seed. The keypair seed is used to generate a keypair, which is then used to authenticate a connection with the ssb-server instance.
The ssb-server instance will then grant access to the `use` call.

### accept(invite_code, cb)

Use an invite code.

 - invite_code (string): an invite code returned by `create`

This connects to the server address encoded in the invite-code, then calls `use()` on the server.
It will cause the server to follow the local user.


### use ({feed:feedId}), cb)

This method is used internally, it is called on the remote pub by your local instance
when you call `accept`. To call `use` you must authenticate
as a guest, by using the seed in an invite code, that was created by this pub.

`use({feed: feed_id}, cb)`

This commands the receiving server to follow the given feed.

An invite-code encodes the ssb-server instance's address, and a keypair seed.
The keypair seed must be used to generate a keypair, then authenticate a connection with the ssb-server instance, in order to use this function.

 - `feed` (feedid): The feed the server should follow.

## License

MIT

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