Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/blockchaincommons/bc-server

Lightweight modular server to allow BlockchainCommons tools to be exposed as web APIs
https://github.com/blockchaincommons/bc-server

Last synced: 15 days ago
JSON representation

Lightweight modular server to allow BlockchainCommons tools to be exposed as web APIs

Awesome Lists containing this project

README

        

# Blockchain Commons `bc-server`

### _by Nicholas Ochiel_

**Blockchain Commons Server** (bc-server) is a modular lightweight server codebase for use by BlockchainCommons projects.

The goal of this project is to provide re-usable code that any BlockchainCommons project can use to expose its API as a HTTP service in a standardized and easy way. A project can either re-use this code or integrate with it by adding a module that makes use of the project.

BlockchainCommons has several projects as commandline tools which could be made more accessible for testing and useful if a server is running that exposes their functionality.

bc-server will expose its functionality using a [REST](https://aws.amazon.com/what-is/restful-api/) interface.

To this end, we have the following requirements:

- A BlockchainCommons command line tool can describe a simple manifest specifying:
- routes: These are named endpoints (path and parameters)
- the command to be executed when an endpoint is called.
- The manifest should be written as a Rust crate and can contain arbitrary logic to process input and generate output.
- This library can then be put into the `modules` directory and the server will automatically make its functionality available.

The immediate use of `bc-server` will be to allow easy testing of the various BlockchainCommons tools. It will be hosted by Blockchain Commons.

## The bc-server API (How to write a module for bc-server)

- The `modules` folder in the root of the bc-server crate contains all modules.
- A module is defined as a sub-crate of bc-server. Each module corresponds to a bc-server crate [`feature`](cargo/reference/specifying-dependencies.html#specifying-path-dependencies)and can be enabled/disabled using `cargo build/run`.
- In the `modules` directory, copy and rename the `example` directory.
- Add dependencies to your module's Cargo.toml .
- Ensure that you fill in the following required module functions in `example.rs`:
- `make_routes()`: This function generates the routes that will be exposed by your module.
- `start_server()`:
- Put any startup code required by your module here e.g. initializing a database.
- Check for and configure any required dependencies here.
- To enable bc-server to run the module:
- Add your module as a dependeny in `bc-server`'s [Cargo.toml](/Cargo.toml) by copying the `example` dependency.
- Add the modules to [server.rs](src/server.rs):
- In `server::make_routes` add the lines:
```rust
#[cfg(feature = "example")]
example::start_server().await;
```
- In `server::start_server` copy the lines:
```rust
#[cfg(feature = "example")]
{
let example_routes = example::make_routes().await;
app = app.nest("/api", example_routes);
}
```

## Modules

The following modules are implemented:

- [x] `depo-module`:
- uses [blockchaincommons/bc-depo-rust](https://github.com/blockchaincommons/bc-depo-rust) for secure storage and retrieval of binary objects.
- [x] `example`: A template module that can be used when making new modules.

The following APIs are work-in-progress:

- [ ] torgap-demo:
- Torgap-demo uses `rsign` allows a user to sign objects which are then served from an ephemeral onion service.
- [ ] [`spotbit`](htttps://github.com/blockchaincommons/spotbit)
- Spotbit is currently a Python application that serves a Bitcoin price feed. It's web-server, in Python, can be deprecated so that it becomes a bc-server module.

## How to test bc-server

```sh
docker compose up
```

OR

```sh
docker compose run -it --service-ports bcserver bash

```

Then verify that you can connect to the API: `curl -vv 127.0.0.1:5332/api/status`

The output log of `docker compose` contains information on what ports and services are running.

## How to deploy bc-server

- Use the provided [Dockerfile](./Dockerfile)

## References

- [Core Lightning](https://github.com/ElementsProject/lightning) (aka `lightningd`) has a module/plugin system that will server as a model for BC-Server.
- See [A day in the life of a plugin
](https://github.com/ElementsProject/lightning/blob/master/doc/developers-guide/plugin-development/a-day-in-the-life-of-a-plugin.md)

## Bugs

- During compilation you might have to wrestle with:

```

Error[E0635]: unknown feature `stdsimd`
--> /home/nik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ahash-0.8.3/src/lib.rs:99:4

```

- To fix:
- `rustup default nightly`
- `rm Cargo.lock` (because it will have conflicting versions of ahash)

---

## Usage Instructions

- From within the bc-server directory run:

```sh
docker compose up
```

OR

```sh
docker compose run -it --service-ports bcserver bash

```

Then verify that you can connect to the API: `curl -vv 127.0.0.1:5332/api/status`

The output log of `docker compose` contains information on what ports and services are running.

## Gordian Principles

` bc-server` is a reference implementation meant to display the [Gordian Principles`](https://github.com/BlockchainCommons/Gordian#gordian-principles), which are philosophical and technical underpinnings to Blockchain Commons' Gordian technology. This includes:

- **Independence.** `how does it demonstrate independence`
- **Privacy.** `how does it demonstrate privacy`
- **Resilience.** `how does it demonstrate resilience`
- **Openness.** `how does it demonstrate openness`

Blockchain Commons apps do not phone home and do not run ads. Some are available through various app stores; all are available in our code repositories for your usage.

`REMOVE THIS SECTION UNLESS THIS IS A REFERENCE APP MEANT TO DEMONSTRATE GORDIAN PRINCIPLES`

## Status - Alpha

` bc-server` is currently under active development and in the alpha testing phase. It should not be used for production tasks until it has had further testing and auditing. See [Blockchain Commons' Development Phases](https://github.com/BlockchainCommons/Community/blob/master/release-path.md).

### Version History

### Roadmap

- [ ] `server.rs` has to be manually updated to include API routes for each module. Instead, server should scan the compiled list of modules and activate their routes.
- [ ] Add a UI to easily use modules.
- Modules won't describe their own UI.
- [ ] `depo-module`: Enable key share recovery using Oauth and Github login.

## Origin, Authors, Copyright & Licenses

Unless otherwise noted (either in this [/README.md](./README.md) or in the file's header comments) the contents of this repository are Copyright © 2020 by Blockchain Commons, LLC, and are [licensed](./LICENSE) under the [spdx:BSD-2-Clause Plus Patent License](https://spdx.org/licenses/BSD-2-Clause-Patent.html).

In most cases, the authors, copyright, and license for each file reside in header comments in the source code. When it does not, we have attempted to attribute it accurately in the table below.

This table below also establishes provenance (repository of origin, permalink, and commit id) for files included from repositories that are outside of this repo. Contributors to these files are listed in the commit history for each repository, first with changes found in the commit history of this repo, then in changes in the commit history of their repo of their origin.

| File | From | Commit | Authors & Copyright (c) | License |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | ----------------------- | ------------------------------------ |
| exception-to-the-rule.c or exception-folder | [https://github.com/community/repo-name/PERMALINK](https://github.com/community/repo-name/PERMALINK) | [https://github.com/community/repo-name/commit/COMMITHASH]() | 2020 Exception Author | [MIT](https://spdx.org/licenses/MIT) |

### Dependencies

To build `bc-server` you'll need to use the following tools:

- `rustup`
- `cargo`

### Libraries

Libraries used in bc-server are listed in the [Cargo.toml](/Cargo.toml).

- _Note_ We can no longer use the warp web server library because it's types are recondite and unweildy. In particular, there is no easy way to compose routes based on optional features (https://github.com/seanmonstar/warp/issues/1060).
- bc-server implements modules as features therefore we need an easy way to do this without the compiler constantly screaming inscrutable imprecations.

### Derived from ...

This `bc-server` project is either derived from:

- [blockchaincommons/bc-depo-rust](https://github.com/blockchaincommons/bc-depo-rust).

## Financial Support

`bc-server` is a project of [Blockchain Commons](https://www.blockchaincommons.com/). We are proudly a "not-for-profit" social benefit corporation committed to open source & open development. Our work is funded entirely by donations and collaborative partnerships with people like you. Every contribution will be spent on building open tools, technologies, and techniques that sustain and advance blockchain and internet security infrastructure and promote an open web.

To financially support further development of `bc-server` and other projects, please consider becoming a Patron of Blockchain Commons through ongoing monthly patronage as a [GitHub Sponsor](https://github.com/sponsors/BlockchainCommons). You can also support Blockchain Commons with bitcoins at our [BTCPay Server](https://btcpay.blockchaincommons.com/).

## Contributing

We encourage public contributions through issues and pull requests! Please review [CONTRIBUTING.md](./CONTRIBUTING.md) for details on our development process. All contributions to this repository require a GPG signed [Contributor License Agreement](./CLA.md).

### Discussions

The best place to talk about Blockchain Commons and its projects is in our GitHub Discussions areas.

[**Gordian Developer Community**](https://github.com/BlockchainCommons/Gordian-Developer-Community/discussions). For standards and open-source developers who want to talk about interoperable wallet specifications, please use the Discussions area of the [Gordian Developer Community repo](https://github.com/BlockchainCommons/Gordian-Developer-Community/discussions). This is where you talk about Gordian specifications such as [Gordian Envelope](https://github.com/BlockchainCommons/Gordian/tree/master/Envelope#articles), [bc-shamir](https://github.com/BlockchainCommons/bc-shamir), [Sharded Secret Key Reconstruction](https://github.com/BlockchainCommons/bc-sskr), and [bc-ur](https://github.com/BlockchainCommons/bc-ur) as well as the larger [Gordian Architecture](https://github.com/BlockchainCommons/Gordian/blob/master/Docs/Overview-Architecture.md), its [Principles](https://github.com/BlockchainCommons/Gordian#gordian-principles) of independence, privacy, resilience, and openness, and its macro-architectural ideas such as functional partition (including airgapping, the original name of this community).

[**Gordian User Community**](https://github.com/BlockchainCommons/Gordian/discussions). For users of the Gordian reference apps, including [Gordian Coordinator](https://github.com/BlockchainCommons/iOS-GordianCoordinator), [Gordian Seed Tool](https://github.com/BlockchainCommons/GordianSeedTool-iOS), [Gordian Server](https://github.com/BlockchainCommons/GordianServer-macOS), [Gordian Wallet](https://github.com/BlockchainCommons/GordianWallet-iOS), and [SpotBit](https://github.com/BlockchainCommons/spotbit) as well as our whole series of [CLI apps](https://github.com/BlockchainCommons/Gordian/blob/master/Docs/Overview-Apps.md#cli-apps). This is a place to talk about bug reports and feature requests as well as to explore how our reference apps embody the [Gordian Principles](https://github.com/BlockchainCommons/Gordian#gordian-principles).

[**Blockchain Commons Discussions**](https://github.com/BlockchainCommons/Community/discussions). For developers, interns, and patrons of Blockchain Commons, please use the discussions area of the [Community repo](https://github.com/BlockchainCommons/Community) to talk about general Blockchain Commons issues, the intern program, or topics other than those covered by the [Gordian Developer Community](https://github.com/BlockchainCommons/Gordian-Developer-Community/discussions) or the
[Gordian User Community](https://github.com/BlockchainCommons/Gordian/discussions).

### Other Questions & Problems

As an open-source, open-development community, Blockchain Commons does not have the resources to provide direct support of our projects. Please consider the discussions area as a locale where you might get answers to questions. Alternatively, please use this repository's [issues](./issues) feature. Unfortunately, we can not make any promises on response time.

If your company requires support to use our projects, please feel free to contact us directly about options. We may be able to offer you a contract for support from one of our contributors, or we might be able to point you to another entity who can offer the contractual support that you need.

### Credits

The following people directly contributed to this repository. You can add your name here by getting involved. The first step is learning how to contribute from our [CONTRIBUTING.md](./CONTRIBUTING.md) documentation.

| Name | Role | Github | Email | GPG Fingerprint |
| ----------------- | ------------------- | ------------------------------------------------ | ------------------------------------- | ------------------------------------------------- |
| Christopher Allen | Principal Architect | [@ChristopherA](https://github.com/ChristopherA) | \ | FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED |
| Nicholas Ochiel | Principal Architect | [@nochiel](https://github.com/ChristopherA) | \ | 45EA 5C81 9B7E E915 C2A2 7C64 4444 1190 7BE8 83D9 |

## Responsible Disclosure

We want to keep all of our software safe for everyone. If you have discovered a security vulnerability, we appreciate your help in disclosing it to us in a responsible manner. We are unfortunately not able to offer bug bounties at this time.

We do ask that you offer us good faith and use best efforts not to leak information or harm any user, their data, or our developer community. Please give us a reasonable amount of time to fix the issue before you publish it. Do not defraud our users or us in the process of discovery. We promise not to bring legal action against researchers who point out a problem provided they do their best to follow the these guidelines.

### Reporting a Vulnerability

Please report suspected security vulnerabilities in private via email to [email protected] (do not use this email for support). Please do NOT create publicly viewable issues for suspected security vulnerabilities.

The following keys may be used to communicate sensitive information to developers:

| Name | Fingerprint |
| ----------------- | ------------------------------------------------- |
| Christopher Allen | FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED |

You can import a key by running the following command with that individual’s fingerprint: `gpg --recv-keys ""` Ensure that you put quotes around fingerprints that contain spaces.

```

```