# swarm-backup

Latest version **1.0.3** (published 2021-03-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install swarm-backup
pnpm add swarm-backup
yarn add swarm-backup
bun add swarm-backup
```

## 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.3 |
| Published | 2021-03-25 |
| First published | 2021-03-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 2 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | 1up.digital |

## Links

- npm: https://www.npmjs.com/package/swarm-backup
- npm.io page: https://npm.io/package/swarm-backup

## Dependencies (5)

- [web3](https://npm.io/package/web3.md) ^1.3.0
- [elliptic](https://npm.io/package/elliptic.md) ^6.5.3
- [web3-utils](https://npm.io/package/web3-utils.md) ^1.3.4
- [swarm-lowlevel](https://npm.io/package/swarm-lowlevel.md) ^0.8.9
- [@ethersphere/bee-js](https://npm.io/package/@ethersphere/bee-js.md) ^0.6.0

## Recent versions

- 1.0.3 (latest) — 2021-03-25
- 1.0.2 — 2021-03-24
- 1.0.1 — 2021-03-24
- 1.0.0 — 2021-03-24

## README

<p float="left">
	<img src="https://raw.githubusercontent.com/1up-digital/swarm-backup/master/swarm-logo.svg" alt="Swarm" height="40px">        <img src="https://raw.githubusercontent.com/1up-digital/swarm-backup/master/1up-logo.svg" alt="1UP" height="40px">
</p>

# Swarm Backup

<hr>

A library to back up and restore encrypted data using swarm.

![Swarm Backup Demo](https://raw.githubusercontent.com/1up-digital/swarm-backup/master/demo.gif "Demo")

## Overview

### Installation

`$ npm i`

### Data Disclaimer

Swarm is in beta and as such data retention cannot be guaranteed, be sure to keep data safe and secure in a secondary location.   

### Usage

#### Instantiate the Class

**new SwarmBackup()**

Instantiate the class passing the URL of the Swarm gateway and a valid private key.  

| Param |	Type | Required | Default | Purpose |
| ----- | ---- | -------- | ------- | ------- |
| gateway | string | true |  | The URL of the Swarm Gateway |
| privateKey | string | true | | A valid Private Key |

##### Example

```
const gateway = 'http://localhost:1633';
const w1 = await new Wallet().generate('test-pw-1');
const privateKey = w1.wallet.privateKey;

const sb = new SwarmBackup(gateway, privateKey);
```

#### Backup Data

**backup()**

Pass the data key as a string and the value of the data you want to backup.  

| Param |	Type | Required | Default | Purpose |
| ----- | ---- | -------- | ------- | ------- |
| key | string | true | | A string to identify your data |
| data | any | true | | The data to backup |
 
##### Example

```
const key = 'name';
const value = 'John';
const backup = sb.backup(key, value); //returns private key on success
```

#### Restore Data

**restore()**

Pass the data key as a string and it returns the latest data available for this key and private key.  

| Param |	Type | Required | Default | Purpose |
| ----- | ---- | -------- | ------- | ------- |
| key | string | true |  | A string to identify your data |

##### Example

```
const key = 'name';
const backup = sb.restore(key); //returns "John"
```

### Use in a Web Browser

To use this library in the web browser use webpack to create a bundle.

```
npm run pack
```
The bundle will be generated and stored in dist/web/bundle.js

Include the library as normal and instantiate the class using the same example as above.  

### Testing

To run tests:

1.  Install bee following the instructions at https://docs.ethswarm.org.
2.  Run locally in standalone mode `bee start --standalone --password="password" --swap-enable="false"`
3.  `npm test`

### License

Swarm Backup is released under the MIT License.

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