# ssb-client

> scuttlebot client

Latest version **4.9.0** (published 2020-02-11) · MIT license · 0 weekly downloads

## Install

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

## 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 | 4.9.0 |
| Published | 2020-02-11 |
| First published | 2015-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 14.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Paul Frazee |
| Maintainers | ahdinosaur, aljoscha-meyer, andregarzia, arj03, cel, chereseeriepa, christianbundy, cryp7ix, dominictarr, happy0, kyphae, luandro, marak, mixmix, mmckegg, noffle, pfraze, pfrazee, pietgeursen, regular, staltz, substack, vtduncan |

## Links

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

## Dependencies (8)

- [muxrpc](https://npm.io/package/muxrpc.md) ^6.5.0
- [multicb](https://npm.io/package/multicb.md) ^1.2.1
- [ssb-keys](https://npm.io/package/ssb-keys.md) ^7.2.1
- [pull-hash](https://npm.io/package/pull-hash.md) ^1.0.0
- [ssb-config](https://npm.io/package/ssb-config.md) ^3.4.4
- [multiserver](https://npm.io/package/multiserver.md) ^3.1.2
- [pull-stream](https://npm.io/package/pull-stream.md) ^3.6.0
- [explain-error](https://npm.io/package/explain-error.md) ^1.0.1

## Recent versions

- 4.9.0 (latest) — 2020-02-11
- 4.8.0 — 2020-01-23
- 4.7.9 — 2019-11-13
- 4.7.8 — 2019-07-29
- 4.7.7 — 2019-06-15
- 4.7.6 — 2019-05-28
- 4.7.5 — 2019-05-13
- 4.7.4 — 2019-05-02
- 4.7.3 — 2019-04-26
- 4.7.2 — 2019-04-10
- 4.7.1 — 2019-02-28
- 4.7.0 — 2019-02-24
- 4.6.5 — 2019-02-23
- 4.6.4 — 2019-02-23
- 4.6.3 — 2019-02-07
- … 28 more at https://npm.io/package/ssb-client/versions

## README

# ssb-client v2

[Scuttlebot](https://github.com/ssbc/scuttlebot) client.

Create an [rpc connection](https://ssbc.github.io/scuttlebutt-protocol-guide/#rpc-protocol) to an sbot running locally.

## example

```js
var ssbClient = require('ssb-client')
var ssbKeys = require('ssb-keys')

// simplest usage, connect to localhost sbot
// this will cb with an error if an sbot server is not running
ssbClient(function (err, sbot) {
  // ...
})

// configuration:
var keys = ssbKeys.loadOrCreateSync('./app-private.key')
ssbClient(
  keys,                // optional, defaults to ~/.ssb/secret
  {
    host: 'localhost', // optional, defaults to localhost
    port: 8008,        // optional, defaults to 8008
    key: keys.id,      // optional, defaults to keys.id

    caps: {
        // random string for `appKey` in secret-handshake
        shs: ''
    },

    // Optional muxrpc manifest. Defaults to manifest provided by server.
    manifest: {}

  },
  function (err, sbot, config) {
    // ...
  }
)
```

* Tutorials using this library to create basic clients: [ssb-client-basic](https://github.com/mixmix/ssb-client-basic)
* A simple command line wrapper around this library: [ssb-client-cli](https://github.com/qypea/ssb-client-cli)

## api

### require('ssb-client') => createEasyClient

#### createEasyClient(cb(err, sbot))

Create a connection to the local `ssb-server` instance, using the default keys.
Configuration and keys will be loaded from directory specified by `ssb_appname`.
(by default `~/.ssb`)

The manifest will be the manifest provided by that server.

Calling this without arguments is handy for scripts, but applications
should use the clearer apis.

there is a legacy api, that makes things as "easy" as possible,
by loading configuration and defaults. This is useful for scripts
but applications should probably use

##### createCustomClient({keys, config, manifest, remote}, cb(err, sbot))

Connect to a specific server with fixed settings. All fields are mandatory.

#### createLegacyClient(keys, opts, cb(err, sbot))

Connect to a client with some custom settings.

opts supports the keys:

* `remote` multiserver address to connect to
* `host, port, key` (legacy) if remote is not set, assemble address from host, port, key.
* `manifest` use a custom manifest.

If you need custom options, it's recommended to use the `createCustomClient` API
instead, but this is still provided for legacy support.


### keys

See [ssb-keys](https://github.com/ssbc/ssb-keys). The keys look like this:
```js
{
    id: String,
    public: String,
    private: String,
    curve: 'ed25519'
}
```

### caps
`caps.shs` is a random string passed to [secret-handshake](https://github.com/auditdrivencrypto/secret-handshake#example). It determines which sbot you are able to connect to. It defaults to a magic string in this repo and also in [scuttlebot](https://github.com/ssbc/scuttlebot/blob/master/lib/ssb-cap.js)

```js
var appKey = Buffer.from(opts.caps.shs, 'base64')
```


## License

MIT, Copyright 2015 Paul Frazee and Dominic Tarr

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